Skip to content

Commit 34fd713

Browse files
committed
chore: merge main into release for new releases
2 parents 91d7d36 + 912f418 commit 34fd713

File tree

10 files changed

+207
-12
lines changed

10 files changed

+207
-12
lines changed

.github/workflows/trigger-api-tasks-deploy-main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ jobs:
2525
- name: Install DB package dependencies
2626
working-directory: ./packages/db
2727
run: bun install --frozen-lockfile --ignore-scripts
28+
- name: Install Integration Platform package dependencies
29+
working-directory: ./packages/integration-platform
30+
run: bun install --frozen-lockfile --ignore-scripts
31+
- name: Build Integration Platform package
32+
working-directory: ./packages/integration-platform
33+
run: bun run build
2834
- name: Build DB package
2935
working-directory: ./packages/db
3036
run: bun run build

.github/workflows/trigger-api-tasks-deploy-release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ jobs:
2828
working-directory: ./packages/db
2929
run: bun install --frozen-lockfile --ignore-scripts
3030

31+
- name: Install Integration Platform package dependencies
32+
working-directory: ./packages/integration-platform
33+
run: bun install --frozen-lockfile --ignore-scripts
34+
- name: Build Integration Platform package
35+
working-directory: ./packages/integration-platform
36+
run: bun run build
37+
3138
- name: Build DB package
3239
working-directory: ./packages/db
3340
run: bun run build

.github/workflows/trigger-tasks-deploy-main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ jobs:
2424
- name: Install Email package dependencies
2525
working-directory: ./packages/email
2626
run: bun install --frozen-lockfile --ignore-scripts
27+
- name: Install Integration Platform package dependencies
28+
working-directory: ./packages/integration-platform
29+
run: bun install --frozen-lockfile --ignore-scripts
2730
- name: Build DB package
2831
working-directory: ./packages/db
2932
run: bun run build
33+
- name: Build Integration Platform package
34+
working-directory: ./packages/integration-platform
35+
run: bun run build
3036
- name: Copy schema to app and generate client
3137
working-directory: ./apps/app
3238
run: |

.github/workflows/trigger-tasks-deploy-release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,18 @@ jobs:
2727
- name: Install Email package dependencies
2828
working-directory: ./packages/email
2929
run: bun install --frozen-lockfile --ignore-scripts
30+
- name: Install Integration Platform package dependencies
31+
working-directory: ./packages/integration-platform
32+
run: bun install --frozen-lockfile --ignore-scripts
3033

3134
- name: Build DB package
3235
working-directory: ./packages/db
3336
run: bun run build
3437

38+
- name: Build Integration Platform package
39+
working-directory: ./packages/integration-platform
40+
run: bun run build
41+
3542
- name: Copy schema to app and generate client
3643
working-directory: ./apps/app
3744
run: |
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import type {
2+
BuildContext,
3+
BuildExtension,
4+
BuildManifest,
5+
} from '@trigger.dev/build';
6+
import type { Plugin } from 'esbuild';
7+
import { existsSync } from 'node:fs';
8+
import { cp, mkdir } from 'node:fs/promises';
9+
import { dirname, resolve } from 'node:path';
10+
11+
const PACKAGE_NAME = '@comp/integration-platform';
12+
13+
/**
14+
* Custom Trigger.dev build extension for @comp/integration-platform workspace package.
15+
*
16+
* Since @comp/integration-platform is a workspace package (not published to npm),
17+
* we need to:
18+
* 1. Add an esbuild plugin to resolve the import path during build
19+
* 2. Copy the built dist files into the trigger.dev deployment
20+
*/
21+
export function integrationPlatformExtension(): IntegrationPlatformExtension {
22+
return new IntegrationPlatformExtension();
23+
}
24+
25+
class IntegrationPlatformExtension implements BuildExtension {
26+
public readonly name = 'IntegrationPlatformExtension';
27+
private _packagePath: string | undefined;
28+
29+
async onBuildStart(context: BuildContext) {
30+
if (context.target === 'dev') {
31+
return;
32+
}
33+
34+
// Find the package path
35+
this._packagePath = this.findPackageRoot(context.workingDir);
36+
37+
if (!this._packagePath) {
38+
throw new Error(
39+
[
40+
`IntegrationPlatformExtension could not find ${PACKAGE_NAME}.`,
41+
'Make sure the package is built (run `bun run build` in packages/integration-platform).',
42+
].join('\n'),
43+
);
44+
}
45+
46+
context.logger.debug(`Found integration-platform at ${this._packagePath}`);
47+
48+
// Register esbuild plugin to resolve the workspace package
49+
const packagePath = this._packagePath;
50+
const resolvePlugin: Plugin = {
51+
name: 'resolve-integration-platform',
52+
setup(build) {
53+
// Resolve bare import
54+
build.onResolve({ filter: /^@comp\/integration-platform$/ }, () => {
55+
return {
56+
path: resolve(packagePath, 'dist/index.js'),
57+
};
58+
});
59+
60+
// Resolve subpath imports like @comp/integration-platform/types
61+
build.onResolve(
62+
{ filter: /^@comp\/integration-platform\// },
63+
(args) => {
64+
const subpath = args.path.replace(`${PACKAGE_NAME}/`, '');
65+
return {
66+
path: resolve(packagePath, 'dist', `${subpath}/index.js`),
67+
};
68+
},
69+
);
70+
},
71+
};
72+
73+
context.registerPlugin(resolvePlugin);
74+
}
75+
76+
async onBuildComplete(context: BuildContext, manifest: BuildManifest) {
77+
if (context.target === 'dev') {
78+
return;
79+
}
80+
81+
const packagePath = this._packagePath;
82+
if (!packagePath) {
83+
return;
84+
}
85+
86+
const packageDistPath = resolve(packagePath, 'dist');
87+
88+
// Copy the entire dist to the build output
89+
const destPath = resolve(
90+
manifest.outputPath,
91+
'node_modules/@comp/integration-platform',
92+
);
93+
const destDistPath = resolve(destPath, 'dist');
94+
95+
await mkdir(destDistPath, { recursive: true });
96+
97+
// Copy dist files
98+
await cp(packageDistPath, destDistPath, { recursive: true });
99+
100+
// Copy package.json for proper module resolution
101+
const packageJsonPath = resolve(packagePath, 'package.json');
102+
if (existsSync(packageJsonPath)) {
103+
await cp(packageJsonPath, resolve(destPath, 'package.json'));
104+
}
105+
106+
context.logger.log(
107+
'Copied @comp/integration-platform to deployment bundle',
108+
);
109+
}
110+
111+
private findPackageRoot(workingDir: string): string | undefined {
112+
// Look for the package relative to the api app
113+
const candidates = [
114+
resolve(workingDir, '../../packages/integration-platform'),
115+
resolve(workingDir, '../packages/integration-platform'),
116+
];
117+
118+
for (const candidate of candidates) {
119+
if (
120+
existsSync(candidate) &&
121+
existsSync(resolve(candidate, 'dist/index.js'))
122+
) {
123+
return candidate;
124+
}
125+
}
126+
127+
return undefined;
128+
}
129+
}

apps/api/trigger.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { PrismaInstrumentation } from '@prisma/instrumentation';
22
import { syncVercelEnvVars } from '@trigger.dev/build/extensions/core';
33
import { defineConfig } from '@trigger.dev/sdk';
44
import { prismaExtension } from './customPrismaExtension';
5+
import { integrationPlatformExtension } from './integrationPlatformExtension';
56

67
export default defineConfig({
78
project: 'proj_zhioyrusqertqgafqgpj', // API project
@@ -14,6 +15,7 @@ export default defineConfig({
1415
version: '6.13.0',
1516
dbPackageVersion: '^1.3.15', // Version of @trycompai/db package with compiled JS
1617
}),
18+
integrationPlatformExtension(),
1719
syncVercelEnvVars(),
1820
],
1921
},

apps/app/src/app/(app)/[orgId]/cloud-tests/components/TestsLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function TestsLayout({ initialFindings, initialProviders, orgId }: TestsL
7575
const { disconnectConnection } = useIntegrationMutations();
7676

7777
const { data: findings = initialFindings, mutate: mutateFindings } = useSWR<Finding[]>(
78-
'/api/cloud-tests/findings',
78+
`/api/cloud-tests/findings?orgId=${orgId}`,
7979
async (url) => {
8080
const res = await fetch(url);
8181
if (!res.ok) throw new Error('Failed to fetch');
@@ -89,7 +89,7 @@ export function TestsLayout({ initialFindings, initialProviders, orgId }: TestsL
8989
);
9090

9191
const { data: providers = initialProviders, mutate: mutateProviders } = useSWR<Provider[]>(
92-
'/api/cloud-tests/providers',
92+
`/api/cloud-tests/providers?orgId=${orgId}`,
9393
async (url) => {
9494
const res = await fetch(url);
9595
if (!res.ok) throw new Error('Failed to fetch');

apps/app/src/app/(app)/[orgId]/tasks/[taskId]/components/SingleTask.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,10 @@ export function SingleTask({
205205
{/* Browser Automations Section */}
206206
{isWebAutomationsEnabled && <BrowserAutomations taskId={task.id} />}
207207

208-
{/* Custom Automations Section - only show if no mapped integration checks available */}
209-
{!hasMappedChecks && <TaskAutomations automations={automations || []} />}
208+
{/* Custom Automations Section - always show if automations exist, or show empty state if no integration checks */}
209+
{((automations && automations.length > 0) || !hasMappedChecks) && (
210+
<TaskAutomations automations={automations || []} />
211+
)}
210212

211213
{/* Comments Section */}
212214
<div>

apps/app/src/app/api/cloud-tests/findings/route.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
import { auth } from '@/utils/auth';
22
import { db } from '@db';
33
import { headers } from 'next/headers';
4-
import { NextResponse } from 'next/server';
4+
import { NextRequest, NextResponse } from 'next/server';
55

66
const CLOUD_PROVIDER_SLUGS = ['aws', 'gcp', 'azure'];
77

8-
export async function GET() {
8+
export async function GET(request: NextRequest) {
99
try {
1010
const session = await auth.api.getSession({
1111
headers: await headers(),
1212
});
1313

14-
const orgId = session?.session.activeOrganizationId;
14+
if (!session?.user?.id) {
15+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
16+
}
17+
18+
const { searchParams } = new URL(request.url);
19+
const orgId = searchParams.get('orgId');
1520

1621
if (!orgId) {
17-
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
22+
return NextResponse.json({ error: 'Organization ID is required' }, { status: 400 });
23+
}
24+
25+
// Verify the user belongs to the requested organization
26+
const member = await db.member.findFirst({
27+
where: {
28+
userId: session.user.id,
29+
organizationId: orgId,
30+
deactivated: false,
31+
},
32+
});
33+
34+
if (!member) {
35+
return NextResponse.json({ error: 'Forbidden' }, { status: 403 });
1836
}
1937

2038
// ====================================================================

apps/app/src/app/api/cloud-tests/providers/route.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { auth } from '@/utils/auth';
22
import { getManifest } from '@comp/integration-platform';
33
import { db } from '@db';
44
import { headers } from 'next/headers';
5-
import { NextResponse } from 'next/server';
5+
import { NextRequest, NextResponse } from 'next/server';
66

77
const CLOUD_PROVIDER_SLUGS = ['aws', 'gcp', 'azure'];
88

@@ -24,16 +24,34 @@ const getRequiredVariables = (providerSlug: string): string[] => {
2424
return Array.from(requiredVars);
2525
};
2626

27-
export async function GET() {
27+
export async function GET(request: NextRequest) {
2828
try {
2929
const session = await auth.api.getSession({
3030
headers: await headers(),
3131
});
3232

33-
const orgId = session?.session.activeOrganizationId;
33+
if (!session?.user?.id) {
34+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
35+
}
36+
37+
const { searchParams } = new URL(request.url);
38+
const orgId = searchParams.get('orgId');
3439

3540
if (!orgId) {
36-
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
41+
return NextResponse.json({ error: 'Organization ID is required' }, { status: 400 });
42+
}
43+
44+
// Verify the user belongs to the requested organization
45+
const member = await db.member.findFirst({
46+
where: {
47+
userId: session.user.id,
48+
organizationId: orgId,
49+
deactivated: false,
50+
},
51+
});
52+
53+
if (!member) {
54+
return NextResponse.json({ error: 'Forbidden' }, { status: 403 });
3755
}
3856

3957
// Fetch from NEW integration platform (IntegrationConnection)

0 commit comments

Comments
 (0)