diff --git a/packages/twenty-sdk/src/app-seeds/rich-app/__integration__/app-build/app-build.integration.spec.ts b/packages/twenty-sdk/src/app-seeds/rich-app/__integration__/app-build/app-build.integration.spec.ts index f815dd62909..a99235b6e76 100644 --- a/packages/twenty-sdk/src/app-seeds/rich-app/__integration__/app-build/app-build.integration.spec.ts +++ b/packages/twenty-sdk/src/app-seeds/rich-app/__integration__/app-build/app-build.integration.spec.ts @@ -1,4 +1,4 @@ -import { readdir, rm } from 'node:fs/promises'; +import { readdir, readFile, rm } from 'node:fs/promises'; import { join } from 'path'; import { appBuild } from '@/cli/public-operations/app-build'; @@ -43,4 +43,24 @@ describe('rich-app app:build', () => { expect(functionFiles.length).toBeGreaterThan(0); }); + + // app:build only creates client stubs (empty CoreApiClient / MetadataApiClient) + // because it doesn't sync with the server or generate the real API client. + // Logic functions that use CoreApiClient will get an empty class at runtime. + // When this is fixed, update this test to assert the client IS fully generated. + // See: https://github.com/twentyhq/twenty/pull/18460 + it('should only produce client stubs (not a fully generated CoreApiClient)', async () => { + const clientIndexPath = join( + APP_PATH, + 'node_modules', + 'twenty-sdk', + GENERATED_DIR, + 'core', + 'index.ts', + ); + + const content = await readFile(clientIndexPath, 'utf-8'); + + expect(content).toBe('export class CoreApiClient {}\n'); + }); }); diff --git a/packages/twenty-sdk/src/twenty-sdk-generated.d.ts b/packages/twenty-sdk/src/twenty-sdk-generated.d.ts new file mode 100644 index 00000000000..c22134468fe --- /dev/null +++ b/packages/twenty-sdk/src/twenty-sdk-generated.d.ts @@ -0,0 +1,10 @@ +// Type stubs for the generated API client module. +// At build time, esbuild resolves twenty-sdk/generated to the actual +// generated client (or stubs) in the app's node_modules. +declare module 'twenty-sdk/generated' { + export class CoreApiClient { + query(request: R): Promise; + mutation(request: R): Promise; + } + export class MetadataApiClient {} +}