Fix SDK typecheck: add type declaration for twenty-sdk/generated

- Add twenty-sdk-generated.d.ts so TypeScript can resolve the
  twenty-sdk/generated import used by check-core-client.function.ts
- Restore the 4th integration test assertion (stub check) that was
  lost during merge

Made-with: Cursor
This commit is contained in:
Félix Malfait
2026-03-09 13:41:45 +01:00
parent d6ca54cec3
commit bf3f606ad1
2 changed files with 31 additions and 1 deletions
@@ -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');
});
});
+10
View File
@@ -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<R>(request: R): Promise<unknown>;
mutation<R>(request: R): Promise<unknown>;
}
export class MetadataApiClient {}
}