From 7826ceb2d91e3aac242febf7528f33d5a812f51f Mon Sep 17 00:00:00 2001 From: SandipBajracharya Date: Fri, 6 Feb 2026 16:27:20 +0545 Subject: [PATCH 1/2] feat(OUT-3058): add latest @assembly/node-sdk --- package.json | 4 ++-- src/utils/copilotAPI.ts | 8 ++++---- yarn.lock | 22 +++++++++++----------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 0247e09e..be853676 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,12 @@ "cmd:rename-qb-accounts": "tsx src/cmd/renameQbAccount/index.ts" }, "dependencies": { + "@assembly-js/node-sdk": "^3.19.1", "@sentry/nextjs": "^9.13.0", "@supabase/supabase-js": "^2.49.4", "@trigger.dev/sdk": "4.3.0", "bottleneck": "^2.19.5", "copilot-design-system": "^2.0.10", - "copilot-node-sdk": "^3.11.1", "dayjs": "^1.11.13", "deep-equal": "^2.2.3", "drizzle-orm": "^0.42.0", @@ -88,4 +88,4 @@ "yarn prettier:fix" ] } -} +} \ No newline at end of file diff --git a/src/utils/copilotAPI.ts b/src/utils/copilotAPI.ts index 389dfeb1..215e54da 100644 --- a/src/utils/copilotAPI.ts +++ b/src/utils/copilotAPI.ts @@ -44,8 +44,8 @@ import { WorkspaceResponseSchema, } from '@/type/common' import Bottleneck from 'bottleneck' -import type { CopilotAPI as SDK } from 'copilot-node-sdk' -import { copilotApi } from 'copilot-node-sdk' +import type { AssemblyAPI as SDK } from '@assembly-js/node-sdk' +import { assemblyApi } from '@assembly-js/node-sdk' import { z } from 'zod' import { API_DOMAIN } from '@/constant/domains' import httpStatus from 'http-status' @@ -55,7 +55,7 @@ export class CopilotAPI { copilot: SDK constructor(private token: string) { - this.copilot = copilotApi({ apiKey, token }) + this.copilot = assemblyApi({ apiKey, token }) } private async manualFetch( @@ -270,7 +270,7 @@ export class CopilotAPI { async _getCustomFields(): Promise { console.info('CopilotAPI#getCustomFields | token =', this.token) return CustomFieldResponseSchema.parse( - await this.copilot.listCustomFields(), + await this.copilot.listCustomFields({}), ) } diff --git a/yarn.lock b/yarn.lock index e88e43c7..4b51f7ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,6 +29,16 @@ __metadata: languageName: node linkType: hard +"@assembly-js/node-sdk@npm:^3.19.1": + version: 3.19.1 + resolution: "@assembly-js/node-sdk@npm:3.19.1" + dependencies: + isomorphic-fetch: "npm:^3.0.0" + next: "npm:^14.0.2" + checksum: 10c0/8385b54c6426f7867db8c308c96f5e535aeab59ff1150fc96809d080a1004792920d0390e8a7d26775e5480a8a10f2b7f7db1d29c1e42267a9a03e12e8418785 + languageName: node + linkType: hard + "@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.27.1": version: 7.27.1 resolution: "@babel/code-frame@npm:7.27.1" @@ -5200,16 +5210,6 @@ __metadata: languageName: node linkType: hard -"copilot-node-sdk@npm:^3.11.1": - version: 3.11.1 - resolution: "copilot-node-sdk@npm:3.11.1" - dependencies: - isomorphic-fetch: "npm:^3.0.0" - next: "npm:^14.0.2" - checksum: 10c0/f98ef7fa04ab4e49dacc0732a227e234a90a63d9d7a3e510a1c383ce4f6ca23e6a393f981e36ea68c0b2e6cb316a7c5fc97e47ce53a8bc20bbaa2afa383bf537 - languageName: node - linkType: hard - "copy-anything@npm:^4": version: 4.0.5 resolution: "copy-anything@npm:4.0.5" @@ -5313,6 +5313,7 @@ __metadata: version: 0.0.0-use.local resolution: "custom-app-base@workspace:." dependencies: + "@assembly-js/node-sdk": "npm:^3.19.1" "@eslint/eslintrc": "npm:^3.3.1" "@eslint/js": "npm:^9.24.0" "@ngrok/ngrok": "npm:^1.4.1" @@ -5331,7 +5332,6 @@ __metadata: autoprefixer: "npm:^10.4.0" bottleneck: "npm:^2.19.5" copilot-design-system: "npm:^2.0.10" - copilot-node-sdk: "npm:^3.11.1" dayjs: "npm:^1.11.13" deep-equal: "npm:^2.2.3" dotenv: "npm:^16.4.5" From bfd14ea9021fb36531a9cade9f779289e836a4f6 Mon Sep 17 00:00:00 2001 From: SandipBajracharya Date: Fri, 6 Feb 2026 16:41:59 +0545 Subject: [PATCH 2/2] perf(OUT-3058): increase max duration for the webhook endpoint --- src/app/api/quickbooks/webhook/webhook.controller.ts | 2 ++ src/app/api/quickbooks/webhook/webhook.service.ts | 3 +++ src/utils/sleep.ts | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 src/utils/sleep.ts diff --git a/src/app/api/quickbooks/webhook/webhook.controller.ts b/src/app/api/quickbooks/webhook/webhook.controller.ts index 817787b0..fb3d709d 100644 --- a/src/app/api/quickbooks/webhook/webhook.controller.ts +++ b/src/app/api/quickbooks/webhook/webhook.controller.ts @@ -3,6 +3,8 @@ import { AuthService } from '@/app/api/quickbooks/auth/auth.service' import { WebhookService } from '@/app/api/quickbooks/webhook/webhook.service' import { NextRequest, NextResponse } from 'next/server' +export const maxDuration = 300 // 5 minutes + export async function captureWebhookEvent(req: NextRequest) { console.info('\n\n####### Webhook triggered #######') const user = await authenticate(req) diff --git a/src/app/api/quickbooks/webhook/webhook.service.ts b/src/app/api/quickbooks/webhook/webhook.service.ts index ab94f21a..8e7ab9b4 100644 --- a/src/app/api/quickbooks/webhook/webhook.service.ts +++ b/src/app/api/quickbooks/webhook/webhook.service.ts @@ -25,6 +25,7 @@ import { CopilotAPI } from '@/utils/copilotAPI' import { ErrorMessageAndCode, getMessageAndCodeFromError } from '@/utils/error' import { IntuitAPITokensType } from '@/utils/intuitAPI' import CustomLogger from '@/utils/logger' +import { sleep } from '@/utils/sleep' import { getDeletedAtForAuthAccountCategoryLog, getCategory, @@ -377,6 +378,8 @@ export class WebhookService extends BaseService { payload: unknown, qbTokenInfo: IntuitAPITokensType, ) { + await sleep(1000) // Payment succeed event can sometimes trigger before invoice created. + console.info('###### PAYMENT SUCCEEDED ######') const parsedPaymentSucceed = PaymentSucceededResponseSchema.safeParse(payload) diff --git a/src/utils/sleep.ts b/src/utils/sleep.ts new file mode 100644 index 00000000..1f5ea0ac --- /dev/null +++ b/src/utils/sleep.ts @@ -0,0 +1,2 @@ +export const sleep = (ms: number) => + new Promise((resolve) => setTimeout(resolve, ms))