From f9c6150b9b7ddbc762e848209bbd50fbfb9cfecf Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Wed, 15 Jan 2025 15:15:31 -0500 Subject: [PATCH 01/18] Share code to check in on if this is a decent path --- packages/jobs/lib/execution/sync.ts | 20 +++++++++++++++++++- packages/logs/lib/models/helpers.ts | 1 + packages/types/lib/logs/messages.ts | 11 +++++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index 46e9ede9394..16bf4af5e7b 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -216,6 +216,11 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps provider_config_key: nangoProps.providerConfigKey }; + const providerConfig = await configService.getProviderConfig(connection.provider_config_key, connection.environment_id); + if (providerConfig === null) { + throw new Error(`Provider config not found for connection: ${connection.connection_id} in handleSyncSuccess`); + } + const syncPayload = { records: {} as Record, runTimeSecs: runTime @@ -295,6 +300,16 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps }); void tracer.scope().activate(span, async () => { try { + const webhookLogCtx = await logContextGetter.create( + { operation: { type: 'nango-webhook', action: 'deliver' } }, + { + account: team!, + environment, + integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, + connection: { id: connection.id!, name: connection.connection_id } + } + ); + const res = await sendSyncWebhook({ connection: connection, environment: environment!, @@ -309,11 +324,14 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps deleted }, operation: lastSyncDate ? SyncType.INCREMENTAL : SyncType.FULL, - logCtx + logCtx: webhookLogCtx }); if (res.isErr()) { + await webhookLogCtx.failed(); throw new Error(`Failed to send webhook for sync: ${nangoProps.syncConfig.sync_name}`); + } else { + await webhookLogCtx.success(); } } catch (err) { span?.setTag('error', err); diff --git a/packages/logs/lib/models/helpers.ts b/packages/logs/lib/models/helpers.ts index 00714d336c9..75c6ef78f3a 100644 --- a/packages/logs/lib/models/helpers.ts +++ b/packages/logs/lib/models/helpers.ts @@ -140,6 +140,7 @@ export const operationTypeToMessage: Record = { 'sync:unpause': 'Sync schedule started', 'webhook:incoming': 'Received a webhook', 'webhook:forward': 'Forwarding Webhook', + 'nango-webhook:deliver': 'Delivering Nango Webhook', 'events:post_connection_creation': 'Post connection creation script execution', 'events:pre_connection_deletion': 'Pre connection creation script execution' }; diff --git a/packages/types/lib/logs/messages.ts b/packages/types/lib/logs/messages.ts index 0a1e7a9f951..ed911ae7d63 100644 --- a/packages/types/lib/logs/messages.ts +++ b/packages/types/lib/logs/messages.ts @@ -58,10 +58,16 @@ export interface OperationAdmin { type: 'admin'; action: 'impersonation'; } -export interface OperationWebhook { +export interface OperationExternalWebhook { type: 'webhook'; action: 'incoming' | 'forward'; } + +export interface OperationNangoWebhook { + type: 'nango-webhook'; + action: 'deliver'; +} + export interface OperationDeploy { type: 'deploy'; action: 'prebuilt' | 'custom'; @@ -70,7 +76,8 @@ export type OperationList = | OperationSync | OperationProxy | OperationAction - | OperationWebhook + | OperationExternalWebhook + | OperationNangoWebhook | OperationOnEvents | OperationDeploy | OperationAuth From 8623fa360c1b7e6757f2e7049e0a42b5efd5f458 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Wed, 15 Jan 2025 15:23:53 -0500 Subject: [PATCH 02/18] Add sync details to webhook log --- packages/jobs/lib/execution/sync.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index 16bf4af5e7b..6cd0c8ec01a 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -306,7 +306,9 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps account: team!, environment, integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, - connection: { id: connection.id!, name: connection.connection_id } + connection: { id: connection.id!, name: connection.connection_id }, + syncConfig: { id: nangoProps.syncConfig.id!, name: nangoProps.syncConfig.sync_name }, + meta: { scriptVersion: nangoProps.syncConfig.version } } ); From 9eef2a5057c31d73586dec2e7d4d386fddd54627 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Wed, 15 Jan 2025 16:30:17 -0500 Subject: [PATCH 03/18] Remove assertion --- packages/jobs/lib/execution/sync.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index 6cd0c8ec01a..361f902166c 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -307,7 +307,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps environment, integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, connection: { id: connection.id!, name: connection.connection_id }, - syncConfig: { id: nangoProps.syncConfig.id!, name: nangoProps.syncConfig.sync_name }, + syncConfig: { id: nangoProps.syncConfig.id, name: nangoProps.syncConfig.sync_name }, meta: { scriptVersion: nangoProps.syncConfig.version } } ); From 387457bf3b2b68bef64965825b98df362543ec7b Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Wed, 15 Jan 2025 16:34:07 -0500 Subject: [PATCH 04/18] Revert previous update - I'm not sure how that works --- packages/jobs/lib/execution/sync.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index 361f902166c..6cd0c8ec01a 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -307,7 +307,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps environment, integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, connection: { id: connection.id!, name: connection.connection_id }, - syncConfig: { id: nangoProps.syncConfig.id, name: nangoProps.syncConfig.sync_name }, + syncConfig: { id: nangoProps.syncConfig.id!, name: nangoProps.syncConfig.sync_name }, meta: { scriptVersion: nangoProps.syncConfig.version } } ); From ff1d0db36af875ded14780c1d8c59ec9ee9d86b3 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Thu, 16 Jan 2025 14:41:37 -0500 Subject: [PATCH 05/18] Clean up message types based on convo with Bastien --- packages/jobs/lib/execution/sync.ts | 2 +- packages/logs/lib/models/helpers.ts | 2 +- packages/types/lib/logs/messages.ts | 12 +++--------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index 6cd0c8ec01a..c7ed74e7177 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -301,7 +301,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps void tracer.scope().activate(span, async () => { try { const webhookLogCtx = await logContextGetter.create( - { operation: { type: 'nango-webhook', action: 'deliver' } }, + { operation: { type: 'webhook', action: 'sync' } }, { account: team!, environment, diff --git a/packages/logs/lib/models/helpers.ts b/packages/logs/lib/models/helpers.ts index 75c6ef78f3a..6ab72831cb3 100644 --- a/packages/logs/lib/models/helpers.ts +++ b/packages/logs/lib/models/helpers.ts @@ -140,7 +140,7 @@ export const operationTypeToMessage: Record = { 'sync:unpause': 'Sync schedule started', 'webhook:incoming': 'Received a webhook', 'webhook:forward': 'Forwarding Webhook', - 'nango-webhook:deliver': 'Delivering Nango Webhook', + 'webhook:sync': 'Delivering Webhook from Sync', 'events:post_connection_creation': 'Post connection creation script execution', 'events:pre_connection_deletion': 'Pre connection creation script execution' }; diff --git a/packages/types/lib/logs/messages.ts b/packages/types/lib/logs/messages.ts index ed911ae7d63..a71285f40d8 100644 --- a/packages/types/lib/logs/messages.ts +++ b/packages/types/lib/logs/messages.ts @@ -58,14 +58,9 @@ export interface OperationAdmin { type: 'admin'; action: 'impersonation'; } -export interface OperationExternalWebhook { +export interface OperationWebhook { type: 'webhook'; - action: 'incoming' | 'forward'; -} - -export interface OperationNangoWebhook { - type: 'nango-webhook'; - action: 'deliver'; + action: 'incoming' | 'forward' | 'sync'; } export interface OperationDeploy { @@ -76,8 +71,7 @@ export type OperationList = | OperationSync | OperationProxy | OperationAction - | OperationExternalWebhook - | OperationNangoWebhook + | OperationWebhook | OperationOnEvents | OperationDeploy | OperationAuth From 76c29e399eb0be62f0a783ce4cf3972962fca271 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Thu, 16 Jan 2025 14:54:54 -0500 Subject: [PATCH 06/18] Try fixing type assertion --- packages/jobs/lib/execution/sync.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index c7ed74e7177..c09d1fede80 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -307,7 +307,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps environment, integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, connection: { id: connection.id!, name: connection.connection_id }, - syncConfig: { id: nangoProps.syncConfig.id!, name: nangoProps.syncConfig.sync_name }, + syncConfig: { id: nangoProps.syncConfig.id as number, name: nangoProps.syncConfig.sync_name }, meta: { scriptVersion: nangoProps.syncConfig.version } } ); From b263749b2375748ee4f80d3054d5a88831d19679 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Thu, 16 Jan 2025 15:01:26 -0500 Subject: [PATCH 07/18] Nevermind, that didn't fix it --- packages/jobs/lib/execution/sync.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index c09d1fede80..c7ed74e7177 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -307,7 +307,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps environment, integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, connection: { id: connection.id!, name: connection.connection_id }, - syncConfig: { id: nangoProps.syncConfig.id as number, name: nangoProps.syncConfig.sync_name }, + syncConfig: { id: nangoProps.syncConfig.id!, name: nangoProps.syncConfig.sync_name }, meta: { scriptVersion: nangoProps.syncConfig.version } } ); From e33eb61df646008f90ba1fe79f76583b078ff854 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Thu, 16 Jan 2025 15:13:56 -0500 Subject: [PATCH 08/18] Does this fix the failed build? --- packages/jobs/lib/execution/sync.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index c7ed74e7177..19f8ac933d8 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -300,6 +300,8 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps }); void tracer.scope().activate(span, async () => { try { + const syncConfigId = nangoProps.syncConfig.id!; + const webhookLogCtx = await logContextGetter.create( { operation: { type: 'webhook', action: 'sync' } }, { @@ -307,7 +309,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps environment, integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, connection: { id: connection.id!, name: connection.connection_id }, - syncConfig: { id: nangoProps.syncConfig.id!, name: nangoProps.syncConfig.sync_name }, + syncConfig: { id: syncConfigId, name: nangoProps.syncConfig.sync_name }, meta: { scriptVersion: nangoProps.syncConfig.version } } ); From 9600038c660c2bc1b63189dafe662619c53582bc Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Thu, 16 Jan 2025 15:27:01 -0500 Subject: [PATCH 09/18] it did not fix the error --- packages/jobs/lib/execution/sync.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index 19f8ac933d8..c7ed74e7177 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -300,8 +300,6 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps }); void tracer.scope().activate(span, async () => { try { - const syncConfigId = nangoProps.syncConfig.id!; - const webhookLogCtx = await logContextGetter.create( { operation: { type: 'webhook', action: 'sync' } }, { @@ -309,7 +307,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps environment, integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, connection: { id: connection.id!, name: connection.connection_id }, - syncConfig: { id: syncConfigId, name: nangoProps.syncConfig.sync_name }, + syncConfig: { id: nangoProps.syncConfig.id!, name: nangoProps.syncConfig.sync_name }, meta: { scriptVersion: nangoProps.syncConfig.version } } ); From 5409aebeaa24d6907ab5e46fea1527f035097cc5 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Thu, 16 Jan 2025 15:49:55 -0500 Subject: [PATCH 10/18] Bump package-lock.json --- package-lock.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c6d5c54fad8..7e1d73350ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18616,7 +18616,6 @@ "dev": true, "license": "BSD-3-Clause", "optional": true, - "peer": true, "engines": { "node": ">=0.10.0" } @@ -32341,7 +32340,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "darwin" From e7da415cf6a8837dbf7f62cf4d2b0fd430cace1f Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Thu, 16 Jan 2025 15:53:53 -0500 Subject: [PATCH 11/18] Does bumping typescript-eslint to latest help? --- package-lock.json | 522 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 4 +- 2 files changed, 503 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7e1d73350ea..421b8ead235 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,8 +14,8 @@ "devDependencies": { "@eslint/js": "9.17.0", "@types/node": "20.12.2", - "@typescript-eslint/eslint-plugin": "8.19.1", - "@typescript-eslint/parser": "8.19.1", + "@typescript-eslint/eslint-plugin": "8.20.0", + "@typescript-eslint/parser": "8.20.0", "concurrently": "8.2.2", "eslint": "9.17.0", "eslint-config-prettier": "9.1.0", @@ -12796,16 +12796,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.19.1.tgz", - "integrity": "sha512-tJzcVyvvb9h/PB96g30MpxACd9IrunT7GF9wfA9/0TJ1LxGOJx1TdPzSbBBnNED7K9Ka8ybJsnEpiXPktolTLg==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.20.0.tgz", + "integrity": "sha512-naduuphVw5StFfqp4Gq4WhIBE2gN1GEmMUExpJYknZJdRnc+2gDzB8Z3+5+/Kv33hPQRDGzQO/0opHE72lZZ6A==", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.19.1", - "@typescript-eslint/type-utils": "8.19.1", - "@typescript-eslint/utils": "8.19.1", - "@typescript-eslint/visitor-keys": "8.19.1", + "@typescript-eslint/scope-manager": "8.20.0", + "@typescript-eslint/type-utils": "8.20.0", + "@typescript-eslint/utils": "8.20.0", + "@typescript-eslint/visitor-keys": "8.20.0", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -12824,16 +12825,157 @@ "typescript": ">=4.8.4 <5.8.0" } }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.20.0.tgz", + "integrity": "sha512-J7+VkpeGzhOt3FeG1+SzhiMj9NzGD/M6KoGn9f4dbz3YzK9hvbhVTmLj/HiTp9DazIzJ8B4XcM80LrR9Dm1rJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.20.0", + "@typescript-eslint/visitor-keys": "8.20.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.20.0.tgz", + "integrity": "sha512-cqaMiY72CkP+2xZRrFt3ExRBu0WmVitN/rYPZErA80mHjHx/Svgp8yfbzkJmDoQ/whcytOPO9/IZXnOc+wigRA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.20.0.tgz", + "integrity": "sha512-Y7ncuy78bJqHI35NwzWol8E0X7XkRVS4K4P4TCyzWkOJih5NDvtoRDW4Ba9YJJoB2igm9yXDdYI/+fkiiAxPzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.20.0", + "@typescript-eslint/visitor-keys": "8.20.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.20.0.tgz", + "integrity": "sha512-dq70RUw6UK9ei7vxc4KQtBRk7qkHZv447OUZ6RPQMQl71I3NZxQJX/f32Smr+iqWrB02pHKn2yAdHBb0KNrRMA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.20.0", + "@typescript-eslint/types": "8.20.0", + "@typescript-eslint/typescript-estree": "8.20.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.20.0.tgz", + "integrity": "sha512-v/BpkeeYAsPkKCkR8BDwcno0llhzWVqPOamQrAEMdpZav2Y9OVjd9dwJyBLJWwf335B5DmlifECIkZRJCaGaHA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.20.0", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@typescript-eslint/parser": { - "version": "8.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.19.1.tgz", - "integrity": "sha512-67gbfv8rAwawjYx3fYArwldTQKoYfezNUT4D5ioWetr/xCrxXxvleo3uuiFuKfejipvq+og7mjz3b0G2bVyUCw==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.20.0.tgz", + "integrity": "sha512-gKXG7A5HMyjDIedBi6bUrDcun8GIjnI8qOwVLiY3rx6T/sHP/19XLJOnIq/FgQvWLHja5JN/LSE7eklNBr612g==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.19.1", - "@typescript-eslint/types": "8.19.1", - "@typescript-eslint/typescript-estree": "8.19.1", - "@typescript-eslint/visitor-keys": "8.19.1", + "@typescript-eslint/scope-manager": "8.20.0", + "@typescript-eslint/types": "8.20.0", + "@typescript-eslint/typescript-estree": "8.20.0", + "@typescript-eslint/visitor-keys": "8.20.0", "debug": "^4.3.4" }, "engines": { @@ -12848,6 +12990,122 @@ "typescript": ">=4.8.4 <5.8.0" } }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.20.0.tgz", + "integrity": "sha512-J7+VkpeGzhOt3FeG1+SzhiMj9NzGD/M6KoGn9f4dbz3YzK9hvbhVTmLj/HiTp9DazIzJ8B4XcM80LrR9Dm1rJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.20.0", + "@typescript-eslint/visitor-keys": "8.20.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.20.0.tgz", + "integrity": "sha512-cqaMiY72CkP+2xZRrFt3ExRBu0WmVitN/rYPZErA80mHjHx/Svgp8yfbzkJmDoQ/whcytOPO9/IZXnOc+wigRA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.20.0.tgz", + "integrity": "sha512-Y7ncuy78bJqHI35NwzWol8E0X7XkRVS4K4P4TCyzWkOJih5NDvtoRDW4Ba9YJJoB2igm9yXDdYI/+fkiiAxPzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.20.0", + "@typescript-eslint/visitor-keys": "8.20.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.20.0.tgz", + "integrity": "sha512-v/BpkeeYAsPkKCkR8BDwcno0llhzWVqPOamQrAEMdpZav2Y9OVjd9dwJyBLJWwf335B5DmlifECIkZRJCaGaHA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.20.0", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@typescript-eslint/scope-manager": { "version": "8.19.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.19.1.tgz", @@ -12866,13 +13124,14 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.19.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.19.1.tgz", - "integrity": "sha512-Rp7k9lhDKBMRJB/nM9Ksp1zs4796wVNyihG9/TU9R6KCJDNkQbc2EOKjrBtLYh3396ZdpXLtr/MkaSEmNMtykw==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.20.0.tgz", + "integrity": "sha512-bPC+j71GGvA7rVNAHAtOjbVXbLN5PkwqMvy1cwGeaxUoRQXVuKCebRoLzm+IPW/NtFFpstn1ummSIasD5t60GA==", "dev": true, + "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "8.19.1", - "@typescript-eslint/utils": "8.19.1", + "@typescript-eslint/typescript-estree": "8.20.0", + "@typescript-eslint/utils": "8.20.0", "debug": "^4.3.4", "ts-api-utils": "^2.0.0" }, @@ -12888,6 +13147,146 @@ "typescript": ">=4.8.4 <5.8.0" } }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/scope-manager": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.20.0.tgz", + "integrity": "sha512-J7+VkpeGzhOt3FeG1+SzhiMj9NzGD/M6KoGn9f4dbz3YzK9hvbhVTmLj/HiTp9DazIzJ8B4XcM80LrR9Dm1rJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.20.0", + "@typescript-eslint/visitor-keys": "8.20.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/types": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.20.0.tgz", + "integrity": "sha512-cqaMiY72CkP+2xZRrFt3ExRBu0WmVitN/rYPZErA80mHjHx/Svgp8yfbzkJmDoQ/whcytOPO9/IZXnOc+wigRA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.20.0.tgz", + "integrity": "sha512-Y7ncuy78bJqHI35NwzWol8E0X7XkRVS4K4P4TCyzWkOJih5NDvtoRDW4Ba9YJJoB2igm9yXDdYI/+fkiiAxPzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.20.0", + "@typescript-eslint/visitor-keys": "8.20.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^2.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/utils": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.20.0.tgz", + "integrity": "sha512-dq70RUw6UK9ei7vxc4KQtBRk7qkHZv447OUZ6RPQMQl71I3NZxQJX/f32Smr+iqWrB02pHKn2yAdHBb0KNrRMA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.20.0", + "@typescript-eslint/types": "8.20.0", + "@typescript-eslint/typescript-estree": "8.20.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.20.0.tgz", + "integrity": "sha512-v/BpkeeYAsPkKCkR8BDwcno0llhzWVqPOamQrAEMdpZav2Y9OVjd9dwJyBLJWwf335B5DmlifECIkZRJCaGaHA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.20.0", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@typescript-eslint/types": { "version": "8.19.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.19.1.tgz", @@ -18616,6 +19015,7 @@ "dev": true, "license": "BSD-3-Clause", "optional": true, + "peer": true, "engines": { "node": ">=0.10.0" } @@ -32340,6 +32740,7 @@ "cpu": [ "arm64" ], + "dev": true, "optional": true, "os": [ "darwin" @@ -32563,6 +32964,85 @@ "typescript": ">=4.8.4 <5.8.0" } }, + "node_modules/typescript-eslint/node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.19.1.tgz", + "integrity": "sha512-tJzcVyvvb9h/PB96g30MpxACd9IrunT7GF9wfA9/0TJ1LxGOJx1TdPzSbBBnNED7K9Ka8ybJsnEpiXPktolTLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.19.1", + "@typescript-eslint/type-utils": "8.19.1", + "@typescript-eslint/utils": "8.19.1", + "@typescript-eslint/visitor-keys": "8.19.1", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/typescript-eslint/node_modules/@typescript-eslint/parser": { + "version": "8.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.19.1.tgz", + "integrity": "sha512-67gbfv8rAwawjYx3fYArwldTQKoYfezNUT4D5ioWetr/xCrxXxvleo3uuiFuKfejipvq+og7mjz3b0G2bVyUCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.19.1", + "@typescript-eslint/types": "8.19.1", + "@typescript-eslint/typescript-estree": "8.19.1", + "@typescript-eslint/visitor-keys": "8.19.1", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.8.0" + } + }, + "node_modules/typescript-eslint/node_modules/@typescript-eslint/type-utils": { + "version": "8.19.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.19.1.tgz", + "integrity": "sha512-Rp7k9lhDKBMRJB/nM9Ksp1zs4796wVNyihG9/TU9R6KCJDNkQbc2EOKjrBtLYh3396ZdpXLtr/MkaSEmNMtykw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/typescript-estree": "8.19.1", + "@typescript-eslint/utils": "8.19.1", + "debug": "^4.3.4", + "ts-api-utils": "^2.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.8.0" + } + }, "node_modules/uid-safe": { "version": "2.1.5", "license": "MIT", diff --git a/package.json b/package.json index 0aa79f5fbe6..e8a20c09c71 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,8 @@ "devDependencies": { "@eslint/js": "9.17.0", "@types/node": "20.12.2", - "@typescript-eslint/eslint-plugin": "8.19.1", - "@typescript-eslint/parser": "8.19.1", + "@typescript-eslint/eslint-plugin": "8.20.0", + "@typescript-eslint/parser": "8.20.0", "concurrently": "8.2.2", "eslint": "9.17.0", "eslint-config-prettier": "9.1.0", From ebe465ec1daa36fc7c4dc6ae20d7a94e60691000 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Thu, 16 Jan 2025 16:00:29 -0500 Subject: [PATCH 12/18] Just ignore CI error --- packages/jobs/lib/execution/sync.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index c7ed74e7177..f43a94ea6b9 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -307,6 +307,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps environment, integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, connection: { id: connection.id!, name: connection.connection_id }, + // eslint-ignore-next-line @typescript-eslint/no-unnecessary-type-assertion syncConfig: { id: nangoProps.syncConfig.id!, name: nangoProps.syncConfig.sync_name }, meta: { scriptVersion: nangoProps.syncConfig.version } } From fc008682fc5c962e4fd0fad6005d110f762aba98 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Thu, 16 Jan 2025 16:11:38 -0500 Subject: [PATCH 13/18] I goofed up that ignore, and it gets removed by linter --- packages/jobs/lib/execution/sync.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index f43a94ea6b9..c7ed74e7177 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -307,7 +307,6 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps environment, integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, connection: { id: connection.id!, name: connection.connection_id }, - // eslint-ignore-next-line @typescript-eslint/no-unnecessary-type-assertion syncConfig: { id: nangoProps.syncConfig.id!, name: nangoProps.syncConfig.sync_name }, meta: { scriptVersion: nangoProps.syncConfig.version } } From fc646d21c3832320d3e322d128bee2c408da421b Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Thu, 16 Jan 2025 17:17:35 -0500 Subject: [PATCH 14/18] Another try at fixing build errors --- packages/jobs/lib/execution/sync.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index c7ed74e7177..7293ce5c172 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -300,14 +300,30 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps }); void tracer.scope().activate(span, async () => { try { + if (!team) { + throw new Error('Missing team'); + } + + if (!providerConfig.id) { + throw new Error('Missing providerConfig.id'); + } + + if (!connection.id) { + throw new Error('Missing connection.id'); + } + + if (!nangoProps.syncConfig.id) { + throw new Error('Missing synConfig.id'); + } + const webhookLogCtx = await logContextGetter.create( { operation: { type: 'webhook', action: 'sync' } }, { - account: team!, + account: team, environment, - integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, - connection: { id: connection.id!, name: connection.connection_id }, - syncConfig: { id: nangoProps.syncConfig.id!, name: nangoProps.syncConfig.sync_name }, + integration: { id: providerConfig.id, name: providerConfig.unique_key, provider: providerConfig.provider }, + connection: { id: connection.id, name: connection.connection_id }, + syncConfig: { id: nangoProps.syncConfig.id, name: nangoProps.syncConfig.sync_name }, meta: { scriptVersion: nangoProps.syncConfig.version } } ); From f83ec0d85c525afb1c56119d6bf918e1954ea298 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Fri, 17 Jan 2025 08:00:36 -0500 Subject: [PATCH 15/18] Remove checks after updating --- packages/jobs/lib/execution/sync.ts | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index 5b3daea509f..411490c6e14 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -226,7 +226,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps runTimeSecs: runTime }; const webhookSettings = await externalWebhookService.get(nangoProps.environmentId); - for (const model of nangoProps.syncConfig.models!) { + for (const model of nangoProps.syncConfig.models) { let deletedKeys: string[] = []; if (nangoProps.syncConfig.track_deletes) { deletedKeys = await records.markPreviousGenerationRecordsAsDeleted({ @@ -300,29 +300,13 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps }); void tracer.scope().activate(span, async () => { try { - if (!team) { - throw new Error('Missing team'); - } - - if (!providerConfig.id) { - throw new Error('Missing providerConfig.id'); - } - - if (!connection.id) { - throw new Error('Missing connection.id'); - } - - if (!nangoProps.syncConfig.id) { - throw new Error('Missing synConfig.id'); - } - const webhookLogCtx = await logContextGetter.create( { operation: { type: 'webhook', action: 'sync' } }, { - account: team, + account: team!, environment, - integration: { id: providerConfig.id, name: providerConfig.unique_key, provider: providerConfig.provider }, - connection: { id: connection.id, name: connection.connection_id }, + integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, + connection: { id: connection.id!, name: connection.connection_id }, syncConfig: { id: nangoProps.syncConfig.id, name: nangoProps.syncConfig.sync_name }, meta: { scriptVersion: nangoProps.syncConfig.version } } @@ -455,7 +439,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps activityLogId: nangoProps.activityLogId!, syncConfig: nangoProps.syncConfig, debug: nangoProps.debug, - models: nangoProps.syncConfig.models!, + models: nangoProps.syncConfig.models, runTime: (new Date().getTime() - nangoProps.startedAt.getTime()) / 1000, failureSource: ErrorSourceEnum.CUSTOMER, isCancel: false, @@ -490,7 +474,7 @@ export async function handleSyncError({ nangoProps, error }: { nangoProps: Nango activityLogId: nangoProps.activityLogId!, debug: nangoProps.debug, syncConfig: nangoProps.syncConfig, - models: nangoProps.syncConfig.models!, + models: nangoProps.syncConfig.models, runTime: (new Date().getTime() - nangoProps.startedAt.getTime()) / 1000, failureSource: ErrorSourceEnum.CUSTOMER, isCancel: false, From 39a498f70ea666df16b948edd1bd796224f18023 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Fri, 17 Jan 2025 08:04:46 -0500 Subject: [PATCH 16/18] Fix throw based on feedback from Samuel --- packages/jobs/lib/execution/sync.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index 411490c6e14..5d2d760943a 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -218,7 +218,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps const providerConfig = await configService.getProviderConfig(connection.provider_config_key, connection.environment_id); if (providerConfig === null) { - throw new Error(`Provider config not found for connection: ${connection.connection_id} in handleSyncSuccess`); + throw new Error(`Provider config not found for connection: ${connection.connection_id}`); } const syncPayload = { @@ -440,6 +440,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps syncConfig: nangoProps.syncConfig, debug: nangoProps.debug, models: nangoProps.syncConfig.models, + runTime: (new Date().getTime() - nangoProps.startedAt.getTime()) / 1000, failureSource: ErrorSourceEnum.CUSTOMER, isCancel: false, From 001c7b8428664f3e0718678ef0ed7f64c7a833d0 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Fri, 17 Jan 2025 08:06:22 -0500 Subject: [PATCH 17/18] Fix some possibly null values --- packages/jobs/lib/execution/sync.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index 5d2d760943a..a1a10d1af25 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -226,7 +226,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps runTimeSecs: runTime }; const webhookSettings = await externalWebhookService.get(nangoProps.environmentId); - for (const model of nangoProps.syncConfig.models) { + for (const model of nangoProps.syncConfig.models || []) { let deletedKeys: string[] = []; if (nangoProps.syncConfig.track_deletes) { deletedKeys = await records.markPreviousGenerationRecordsAsDeleted({ @@ -439,7 +439,7 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps activityLogId: nangoProps.activityLogId!, syncConfig: nangoProps.syncConfig, debug: nangoProps.debug, - models: nangoProps.syncConfig.models, + models: nangoProps.syncConfig.models || [], runTime: (new Date().getTime() - nangoProps.startedAt.getTime()) / 1000, failureSource: ErrorSourceEnum.CUSTOMER, @@ -475,7 +475,7 @@ export async function handleSyncError({ nangoProps, error }: { nangoProps: Nango activityLogId: nangoProps.activityLogId!, debug: nangoProps.debug, syncConfig: nangoProps.syncConfig, - models: nangoProps.syncConfig.models, + models: nangoProps.syncConfig.models || [], runTime: (new Date().getTime() - nangoProps.startedAt.getTime()) / 1000, failureSource: ErrorSourceEnum.CUSTOMER, isCancel: false, From 78645ffa1468c39ce39d141360dd3f286dad524d Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Fri, 17 Jan 2025 08:45:36 -0500 Subject: [PATCH 18/18] WIP restructure to create logger in sendSync --- packages/jobs/lib/execution/sync.ts | 27 +++++------------ packages/webhooks/lib/sync.ts | 45 +++++++++++++++++++++++------ 2 files changed, 44 insertions(+), 28 deletions(-) diff --git a/packages/jobs/lib/execution/sync.ts b/packages/jobs/lib/execution/sync.ts index a1a10d1af25..8926c58e38b 100644 --- a/packages/jobs/lib/execution/sync.ts +++ b/packages/jobs/lib/execution/sync.ts @@ -300,21 +300,12 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps }); void tracer.scope().activate(span, async () => { try { - const webhookLogCtx = await logContextGetter.create( - { operation: { type: 'webhook', action: 'sync' } }, - { - account: team!, - environment, - integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, - connection: { id: connection.id!, name: connection.connection_id }, - syncConfig: { id: nangoProps.syncConfig.id, name: nangoProps.syncConfig.sync_name }, - meta: { scriptVersion: nangoProps.syncConfig.version } - } - ); - const res = await sendSyncWebhook({ + account: team!, connection: connection, environment: environment!, + syncConfig: nangoProps.syncConfig, + providerConfig, webhookSettings, syncName: nangoProps.syncConfig.sync_name, model, @@ -325,15 +316,11 @@ export async function handleSyncSuccess({ nangoProps }: { nangoProps: NangoProps updated, deleted }, - operation: lastSyncDate ? SyncType.INCREMENTAL : SyncType.FULL, - logCtx: webhookLogCtx + operation: lastSyncDate ? SyncType.INCREMENTAL : SyncType.FULL }); if (res.isErr()) { - await webhookLogCtx.failed(); throw new Error(`Failed to send webhook for sync: ${nangoProps.syncConfig.sync_name}`); - } else { - await webhookLogCtx.success(); } } catch (err) { span?.setTag('error', err); @@ -657,6 +644,9 @@ async function onFailure({ void tracer.scope().activate(span, async () => { try { const res = await sendSyncWebhook({ + account: team!, + providerConfig, + syncConfig, connection: connection, environment: environment, webhookSettings, @@ -668,8 +658,7 @@ async function onFailure({ description: error.message }, now: lastSyncDate, - operation: lastSyncDate ? SyncType.INCREMENTAL : SyncType.FULL, - logCtx: logCtx + operation: lastSyncDate ? SyncType.INCREMENTAL : SyncType.FULL }); if (res.isErr()) { diff --git a/packages/webhooks/lib/sync.ts b/packages/webhooks/lib/sync.ts index c8e9f42c019..1ff2c62a9ca 100644 --- a/packages/webhooks/lib/sync.ts +++ b/packages/webhooks/lib/sync.ts @@ -1,25 +1,31 @@ import type { - Connection, SyncResult, ErrorPayload, SyncType, ExternalWebhook, NangoSyncWebhookBody, NangoSyncWebhookBodyBase, - DBEnvironment + DBEnvironment, + DBTeam, + DBSyncConfig, + NangoConnection } from '@nangohq/types'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc.js'; -import type { LogContext } from '@nangohq/logs'; +import { logContextGetter } from '@nangohq/logs'; import { deliver, shouldSend } from './utils.js'; import { Ok } from '@nangohq/utils'; import type { Result } from '@nangohq/utils'; +import type { Config } from '@nangohq/shared'; dayjs.extend(utc); export const sendSync = async ({ connection, environment, + account, + providerConfig, + syncConfig, webhookSettings, syncName, model, @@ -27,11 +33,13 @@ export const sendSync = async ({ responseResults, success, operation, - error, - logCtx + error }: { - connection: Connection | Pick; + connection: NangoConnection; environment: DBEnvironment; + account: DBTeam; + providerConfig: Config; + syncConfig: DBSyncConfig; webhookSettings: ExternalWebhook | null; syncName: string; model: string; @@ -40,7 +48,6 @@ export const sendSync = async ({ error?: ErrorPayload; responseResults?: SyncResult; success: boolean; - logCtx?: LogContext | undefined; } & ({ success: true; responseResults: SyncResult } | { success: false; error: ErrorPayload })): Promise> => { if (!webhookSettings) { return Ok(undefined); @@ -50,6 +57,18 @@ export const sendSync = async ({ return Ok(undefined); } + const logCtx = await logContextGetter.create( + { operation: { type: 'webhook', action: 'sync' } }, + { + account, + environment, + integration: { id: providerConfig.id!, name: providerConfig.unique_key, provider: providerConfig.provider }, + connection: { id: connection.id!, name: connection.connection_id }, + syncConfig: { id: syncConfig.id, name: syncConfig.sync_name }, + meta: { scriptVersion: syncConfig.version } + } + ); + const bodyBase: NangoSyncWebhookBodyBase = { from: 'nango', type: 'sync', @@ -69,7 +88,7 @@ export const sendSync = async ({ responseResults?.added === 0 && responseResults?.updated === 0 && (responseResults.deleted === 0 || responseResults.deleted === undefined); if (!webhookSettings.on_sync_completion_always && noChanges) { - await logCtx?.info(`There were no added, updated, or deleted results for model ${model}. No webhook sent, as per your environment settings`); + await logCtx.info(`There were no added, updated, or deleted results for model ${model}. No webhook sent, as per your environment settings`); return Ok(undefined); } @@ -105,7 +124,7 @@ export const sendSync = async ({ { url: webhookSettings.secondary_url, type: 'secondary webhook url' } ].filter((webhook) => webhook.url) as { url: string; type: string }[]; - return deliver({ + const result = await deliver({ webhooks, body: finalBody, webhookType: 'sync', @@ -113,4 +132,12 @@ export const sendSync = async ({ environment, logCtx }); + + if (result.isErr()) { + await logCtx.failed(); + } else { + await logCtx.success(); + } + + return result; };