Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Node engine requirements to ^18.12 || ^22.13 #2730

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
]
},
"engines": {
"node": "14 || ^18.12"
"node": "^18.12 || ^22.13"
},
"scripts": {
"alpha": "lerna version prerelease --allow-branch $(git branch --show-current) --preid $(git branch --show-current) --no-push --no-git-tag-version",
Expand Down Expand Up @@ -72,7 +72,7 @@
"timers-browserify": "^2.0.12",
"ts-jest": "^27.0.7",
"ts-node": "^9.1.1",
"typescript": "4.3.5",
"typescript": "4.9.5",
"ws": "^8.5.0"
},
"resolutions": {
Expand Down
2 changes: 1 addition & 1 deletion packages/actions-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"package.json"
],
"engines": {
"node": "14 || ^18.12"
"node": "^18.12 || ^22.13"
},
"engineStrict": true,
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { RequestClient } from '@segment/actions-core/create-request-client'
import { EngageDestinationCache, ExecuteInput } from '@segment/actions-core/destination-kit'
import { MaybePromise } from '@segment/actions-core/destination-kit/types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { CacheSerializer, EngageActionPerformer } from './EngageActionPerformer'
import { isRetryableError } from './isRetryableError'
import { AggregateError } from './AggregateError'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Friendbuy.trackCustomEvent', () => {
const [trackCustomEvent] = await friendbuyDestination({
merchantId,
subscriptions
})
} as any)
// console.log('trackCustomEvent', JSON.stringify(trackCustomEvent, null, 2), trackCustomEvent)
expect(trackCustomEvent).toBeDefined()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Friendbuy.trackPage', () => {
const [trackPage] = await friendbuyDestination({
merchantId,
subscriptions
})
} as any)
expect(trackPage).toBeDefined()

await trackPage.load(Context.system(), {} as Analytics)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Friendbuy.trackPurchase', () => {

test('all fields', async () => {
const orderId = 'my order'
const products = [
const products: Record<string, unknown>[] = [
{ sku: 'sku1', name: 'shorts', price: 19.99, quantity: 2 },
{ price: 5.99 },
{
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('Friendbuy.trackPurchase', () => {
const [trackPurchase] = await friendbuyDestination({
merchantId,
subscriptions
})
} as any)
// console.log('trackPurchase', JSON.stringify(trackPurchase, null, 2), trackPurchase)
expect(trackPurchase).toBeDefined()

Expand Down Expand Up @@ -117,8 +117,8 @@ describe('Friendbuy.trackPurchase', () => {
},
true
])
expect((window.friendbuyAPI?.push as any).mock.calls[0][0][2].products[1].quantity).toBe(1)
expect((window.friendbuyAPI?.push as any).mock.calls[0][0][2].products[2].imageUrl).toBe(products[2].image_url)
expect((window.friendbuyAPI!.push as any).mock.calls[0][0][2].products[1].quantity).toBe(1)
expect((window.friendbuyAPI!.push as any).mock.calls[0][0][2].products[2].imageUrl).toBe(products[2].image_url)
}

{
Expand Down
4 changes: 2 additions & 2 deletions packages/browser-destinations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"size": "size-limit"
},
"dependencies": {
"tslib": "^2.3.1",
"tslib": "^2.8.1",
"vm-browserify": "^1.1.2"
},
"devDependencies": {
Expand All @@ -43,7 +43,7 @@
"serve": "^12.0.1",
"size-limit": "^11.0.1",
"terser-webpack-plugin": "^5.1.1",
"ts-loader": "^9.2.6",
"ts-loader": "^9.5.2",
"webpack": "^5.82.0",
"webpack-bundle-analyzer": "^4.4.1",
"webpack-cli": "^5.1.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"directory": "packages/cli"
},
"engines": {
"node": "14 || ^18.12"
"node": "^18.12 || ^22.13"
},
"engineStrict": true,
"bin": {
Expand Down Expand Up @@ -43,7 +43,7 @@
"@types/json-schema": "^7.0.7",
"@types/lodash": "^4.14.175",
"@types/mustache": "^4.1.0",
"@types/node": "^14.0.0",
"@types/node": "^22.13.1",
"@types/prompts": "^2.0.10",
"@types/rimraf": "^3.0.2",
"@types/to-title-case": "^1.0.0",
Expand All @@ -59,7 +59,7 @@
"@segment/action-destinations": "^3.288.0",
"@segment/actions-core": "^3.121.0",
"@segment/destinations-manifest": "^1.71.0",
"@types/node": "^18.11.15",
"@types/node": "^22.13.1",
"chalk": "^4.1.1",
"chokidar": "^3.5.1",
"dotenv": "^10.0.0",
Expand All @@ -72,14 +72,14 @@
"jsdom": "^24.1.1",
"json-diff": "^0.5.4",
"json-schema-to-typescript": "^10.1.5",
"lodash": "^4.17.20",
"lodash": "^4.17.21",
"mustache": "^4.2.0",
"ora": "^5.4.0",
"prompts": "^2.4.2",
"slugify": "^1.6.1",
"to-title-case": "^1.0.0",
"tsconfig-paths": "^3.9.0",
"tslib": "^2.3.1"
"tslib": "^2.8.1"
},
"oclif": {
"commands": "./dist/commands",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"package.json"
],
"engines": {
"node": ">=14"
"node": "^18.12 || ^22.13"
},
"engineStrict": true,
"license": "MIT",
Expand Down Expand Up @@ -83,7 +83,7 @@
"@segment/action-emitters": "^1.3.6",
"@segment/ajv-human-errors": "^2.14.0",
"@segment/destination-subscriptions": "^3.36.0",
"@types/node": "^18.11.15",
"@types/node": "^22.13.1",
"aggregate-error": "^3.1.0",
"ajv": "^8.6.3",
"ajv-formats": "^2.1.1",
Expand Down
16 changes: 8 additions & 8 deletions packages/core/src/destination-kit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,13 +742,13 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
// Add datadog stats for events that are discarded by Actions
options?.statsContext?.statsClient?.incr(
'action.multistatus_discard',
(events as SegmentEvent[]).length,
events.length,
options.statsContext?.tags
)

return [
{
multistatus: Array((events as SegmentEvent[]).length).fill(response)
multistatus: Array(events.length).fill(response)
}
]
}
Expand All @@ -770,21 +770,21 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
// Add datadog stats for events that are discarded by Actions
options?.statsContext?.statsClient?.incr(
'action.multistatus_discard',
(events as SegmentEvent[]).length,
events.length,
options.statsContext?.tags
)

return [
{
multistatus: Array((events as SegmentEvent[]).length).fill(response)
multistatus: Array(events.length).fill(response)
}
]
}

return [{ output: response.errormessage }]
}

const allEvents = (isBatch ? events : [events]) as SegmentEvent[]
const allEvents = isBatch ? events : [events]

// Filter invalid events and record discards
const subscribedEvents: SegmentEvent[] = []
Expand Down Expand Up @@ -938,10 +938,10 @@ export class Destination<Settings = JSONObject, AudienceSettings = JSONObject> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const shouldRetry = async (response: any, attemptCount: number) => {
const results = response as Result[]
/*
/*
Here, we iterate over results array. Each result in the array is a response from a single subscription.
However, we always execute one subscription at a time despite receiving an array of subscriptions as input.
So, results array will always have a single result.
However, we always execute one subscription at a time despite receiving an array of subscriptions as input.
So, results array will always have a single result.
TODO: Get rid of onSubscriptions method to reflect execution model in the code accurately.
*/
for (const result of results) {
Expand Down
10 changes: 5 additions & 5 deletions packages/destination-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"package.json"
],
"engines": {
"node": "14 || ^18.12"
"node": "^18.12 || ^22.13"
},
"engineStrict": true,
"license": "MIT",
Expand All @@ -33,7 +33,7 @@
"devDependencies": {
"@types/google-libphonenumber": "^7.4.23",
"@types/jest": "^27.0.0",
"@types/ssh2-sftp-client": "^9.0.0",
"@types/ssh2-sftp-client": "^9.0.4",
"jest": "^27.3.1",
"nock": "^13.1.4"
},
Expand All @@ -46,7 +46,7 @@
"@segment/a1-notation": "^2.1.4",
"@segment/actions-core": "^3.145.0",
"@segment/actions-shared": "^1.126.0",
"@types/node": "^18.11.15",
"@types/node": "^22.13.1",
"ajv-formats": "^2.1.1",
"aws4": "^1.12.0",
"cheerio": "^1.0.0-rc.10",
Expand All @@ -57,7 +57,7 @@
"liquidjs": "^10.8.4",
"lodash": "^4.17.21",
"lru-cache": "10.4.3",
"ssh2-sftp-client": "^9.1.0"
"ssh2-sftp-client": "^10.0.3"
},
"jest": {
"preset": "ts-jest",
Expand Down Expand Up @@ -89,4 +89,4 @@
]
},
"gitHead": "9c04e12c4a0e81f6b68dca0a297fb2c0209d2431"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function removeEmpty(obj: unknown) {

const cleaned = removeUndefined(obj)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (typeof cleaned === 'object' && Object.keys(cleaned!).length > 0) {
if (typeof cleaned === 'object' && Object.keys(cleaned).length > 0) {
return cleaned
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { ExtId, MessageSendPerformer, OperationContext, ResponseError, track, Profile } from '@segment/actions-shared'
import type { Settings } from '../generated-types'
import type { Payload } from './generated-types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { TwilioMessageSender } from '../utils'
import { ExtId, track } from '@segment/actions-shared'
import type { Payload as PushPayload } from './generated-types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { Payload } from './generated-types'
import { PayloadValidationError } from '@segment/actions-core'
import { PhoneMessageSender } from '../utils'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Liquid as LiquidJs } from 'liquidjs'
import type { Payload } from './generated-types'
import { IntegrationError } from '@segment/actions-core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Liquid as LiquidJs } from 'liquidjs'
import type { Settings } from '../generated-types'
import { IntegrationError, PayloadValidationError } from '@segment/actions-core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Settings } from '../generated-types'
import type { ExecuteInput, ModifiedResponse, RequestClient } from '@segment/actions-core'
import type { DynamicFieldItem, ExecuteInput, ModifiedResponse, RequestClient } from '@segment/actions-core'
import get from 'lodash/get'
import { ActivityTypes, PipedriveFields } from './domain'
import { DynamicFieldResponse } from '@segment/actions-core'
Expand Down Expand Up @@ -45,7 +45,7 @@ interface SearchRequest<T extends ItemType> {
field_key: string
}

const cache = {}
const cache: Record<string, DynamicFieldItem[]> = {}

class PipedriveClient {
private settings: Settings
Expand Down Expand Up @@ -85,9 +85,11 @@ class PipedriveClient {
}

async getFields(item: keyof PipedriveFieldTypes): Promise<DynamicFieldResponse> {
const cachedFields = get(cache, item, [])
const cachedFields = cache[item] ?? []
if (cachedFields.length > 0) {
return cachedFields
return {
choices: cachedFields
}
}
const response = await this._request<PipedriveFields>(
`https://${this.settings.domain}.pipedrive.com/api/v1/${pipedriveFieldMap[item]}`,
Expand All @@ -97,16 +99,16 @@ class PipedriveClient {
}
)
const body = response.data
const fields = body.data.map((f) => ({
const fields: DynamicFieldItem[] = body.data.map((f) => ({
label: f.name,
value: f.key
}))
const record = {
choices: fields,
pagination: {}

cache[item] = fields

return {
choices: cachedFields
}
cachedFields[item] = record
return record
}

async getActivityTypes(): Promise<DynamicFieldResponse> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function removeEmpty(obj: unknown) {

const cleaned = removeUndefined(obj)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (typeof cleaned === 'object' && Object.keys(cleaned!).length > 0) {
if (typeof cleaned === 'object' && Object.keys(cleaned).length > 0) {
return cleaned
}

Expand Down
3 changes: 2 additions & 1 deletion packages/destination-actions/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "dist"
"outDir": "dist",
"useUnknownInCatchVariables": false
},
"exclude": ["**/__tests__/**/*.ts"],
"include": ["src"],
Expand Down
Loading
Loading