Skip to content

Commit 42960c4

Browse files
committed
chore: reorganize package.json and update SDK imports
- Restored the version field in package.json and reorganized scripts for better clarity. - Updated imports from '@trigger.dev/sdk/v3' to '@trigger.dev/sdk' across multiple files for consistency. - Removed unused queue configuration in onboarding tasks to streamline the code. - Adjusted zod schema definitions for improved type safety in update-policies-helpers.ts.
1 parent c685963 commit 42960c4

File tree

5 files changed

+30
-67
lines changed

5 files changed

+30
-67
lines changed

apps/api/package.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
11
{
22
"name": "@comp/api",
3-
"version": "0.0.1",
43
"description": "",
4+
"version": "0.0.1",
55
"author": "",
6-
"private": true,
7-
"license": "UNLICENSED",
8-
"scripts": {
9-
"build": "nest build",
10-
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
11-
"start": "nest start",
12-
"dev": "nest start --watch",
13-
"start:dev": "nest start --watch",
14-
"start:debug": "nest start --debug --watch",
15-
"start:prod": "node dist/main",
16-
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
17-
"test": "jest",
18-
"test:watch": "jest --watch",
19-
"test:cov": "jest --coverage",
20-
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
21-
"test:e2e": "jest --config ./test/jest-e2e.json",
22-
"typecheck": "tsc --noEmit",
23-
"db:generate": "bun run db:getschema && prisma generate",
24-
"db:getschema": "cp ../../node_modules/@trycompai/db/dist/schema.prisma prisma/schema.prisma",
25-
"prebuild": "bun run db:generate"
26-
},
276
"dependencies": {
287
"@aws-sdk/client-s3": "^3.859.0",
298
"@aws-sdk/s3-request-presigner": "^3.859.0",
@@ -83,5 +62,26 @@
8362
],
8463
"coverageDirectory": "../coverage",
8564
"testEnvironment": "node"
65+
},
66+
"license": "UNLICENSED",
67+
"private": true,
68+
"scripts": {
69+
"build": "nest build",
70+
"db:generate": "bun run db:getschema && prisma generate",
71+
"db:getschema": "cp ../../node_modules/@trycompai/db/dist/schema.prisma prisma/schema.prisma",
72+
"dev": "nest start --watch",
73+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
74+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
75+
"prebuild": "bun run db:generate",
76+
"start": "nest start",
77+
"start:debug": "nest start --debug --watch",
78+
"start:dev": "nest start --watch",
79+
"start:prod": "node dist/main",
80+
"test": "jest",
81+
"test:cov": "jest --coverage",
82+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
83+
"test:e2e": "jest --config ./test/jest-e2e.json",
84+
"test:watch": "jest --watch",
85+
"typecheck": "tsc --noEmit"
8686
}
8787
}

apps/app/src/jobs/tasks/onboarding/onboard-organization-helpers.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
RiskTreatmentType,
1212
VendorCategory,
1313
} from '@db';
14-
import { logger, tasks } from '@trigger.dev/sdk/v3';
14+
import { logger, tasks } from '@trigger.dev/sdk';
1515
import { generateObject, generateText } from 'ai';
1616
import axios from 'axios';
1717
import z from 'zod';
@@ -371,10 +371,6 @@ export async function triggerPolicyUpdates(
371371
contextHub: questionsAndAnswers.map((c) => `${c.question}\n${c.answer}`).join('\n'),
372372
frameworks,
373373
},
374-
queue: {
375-
name: 'update-policies',
376-
concurrencyLimit: 5,
377-
},
378374
concurrencyKey: organizationId,
379375
})),
380376
);

apps/app/src/jobs/tasks/onboarding/onboard-organization.ts

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { db } from '@db';
2-
import { queue } from '@trigger.dev/sdk';
3-
import { logger, task } from '@trigger.dev/sdk/v3';
2+
import { logger, queue, task } from '@trigger.dev/sdk';
43
import axios from 'axios';
54
import {
65
createRisks,
@@ -9,7 +8,6 @@ import {
98
getOrganizationContext,
109
updateOrganizationPolicies,
1110
} from './onboard-organization-helpers';
12-
import { updatePolicies } from './update-policies';
1311

1412
// v4 queues must be declared in advance
1513
const onboardOrgQueue = queue({ name: 'onboard-organization', concurrencyLimit: 10 });
@@ -67,43 +65,12 @@ export const onboardOrganization = task({
6765
throw error;
6866
}
6967

70-
// Re-fetch policies with full data for policy updates
71-
const fullPolicies = await db.policy.findMany({
72-
where: {
73-
organizationId: payload.organizationId,
74-
},
75-
});
76-
77-
if (fullPolicies.length > 0) {
78-
// v4: queues are predefined on the task; trigger without on-demand queue options
79-
await updatePolicies.batchTriggerAndWait(
80-
fullPolicies.map((policy) => ({
81-
payload: {
82-
organizationId: payload.organizationId,
83-
policyId: policy.id,
84-
contextHub: contextHub.map((c) => `${c.question}\n${c.answer}`).join('\n'),
85-
},
86-
concurrencyKey: payload.organizationId,
87-
})),
88-
);
89-
}
90-
91-
await db.onboarding.update({
92-
where: {
93-
organizationId: payload.organizationId,
94-
},
95-
data: { triggerJobCompleted: true },
96-
});
97-
98-
logger.info(`Created ${extractRisks.object.risks.length} risks`);
99-
logger.info(`Created ${extractVendors.object.vendors.length} vendors`);
100-
10168
const organizationId = payload.organizationId;
10269
await db.onboarding.update({
10370
where: {
10471
organizationId,
10572
},
106-
data: { triggerJobId: null },
73+
data: { triggerJobId: null, triggerJobCompleted: true },
10774
});
10875

10976
try {

apps/app/src/jobs/tasks/onboarding/update-policies-helpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { openai } from '@ai-sdk/openai';
22
import { db, FrameworkEditorFramework, type Policy } from '@db';
33
import type { JSONContent } from '@tiptap/react';
4-
import { logger } from '@trigger.dev/sdk/v3';
4+
import { logger } from '@trigger.dev/sdk';
55
import { generateObject, NoObjectGeneratedError } from 'ai';
66
import { z } from 'zod';
77
import { generatePrompt } from '../../lib/prompts';
@@ -211,7 +211,7 @@ Given an ORIGINAL policy TipTap JSON and a DRAFT TipTap JSON, produce a FINAL Ti
211211
Follow the structure rules above strictly.`,
212212
schema: z.object({
213213
type: z.literal('document'),
214-
content: z.array(z.record(z.unknown())),
214+
content: z.array(z.record(z.string(), z.unknown())),
215215
}),
216216
});
217217
return object;
@@ -465,7 +465,7 @@ ${prompt.replace(/\\n/g, '\n')}
465465
Return the complete TipTap document following ALL the above requirements using proper TipTap JSON structure.`,
466466
schema: z.object({
467467
type: z.literal('document'),
468-
content: z.array(z.record(z.unknown())),
468+
content: z.array(z.record(z.string(), z.unknown())),
469469
}),
470470
});
471471

packages/ui/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,13 @@
456456
"format": "prettier --write .",
457457
"lint": "prettier --check .",
458458
"test": "vitest",
459-
"test:run": "vitest run",
460459
"test:coverage": "vitest run --coverage",
460+
"test:run": "vitest run",
461461
"test:ui": "vitest --ui",
462462
"test:watch": "vitest --watch",
463463
"typecheck": "tsc --noEmit"
464464
},
465465
"sideEffects": false,
466466
"type": "module",
467467
"types": "./dist/index.d.ts"
468-
}
468+
}

0 commit comments

Comments
 (0)