Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix(ts/cli): fix package resolution issues
jkomyno committed
Jan 15, 2026 at 12:15 UTC
d1e08a145e3232f517e22551e1661d1369f56768
1 file changed
+101
ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts
+101
@@ -53,6 +53,38 @@ describe('CLI: composio ts generate', () => {
53
yield* fs.makeDirectory(nodeModulesDir, { recursive: true });
54
yield* fs.makeDirectory(generatedDir, { recursive: true });
55
56
+ // Create a mock package.json to override the symlink resolution for ESM imports.
57
+ // This is necessary because we're using symlinks in test-layer.ts to isolate the test environment.
58
+ const corePackageJson = path.join(nodeModulesDir, 'package.json');
59
+ yield* fs.writeFileString(
60
+ corePackageJson,
61
+ JSON.stringify(
62
+ {
63
+ name: '@composio/core',
64
+ type: 'module',
65
+ exports: {
66
+ '.': {
67
+ types: './index.d.ts',
68
+ default: './index.js',
69
+ },
70
+ './generated': {
71
+ types: './generated/index.d.ts',
72
+ default: './generated/index.js',
73
+ },
74
+ },
75
+ },
76
+ null,
77
+ 2
78
+ )
79
+ );
80
+
81
+ // Create minimal type stubs for @composio/core root exports (needed for transpilation)
82
+ yield* fs.writeFileString(
83
+ path.join(nodeModulesDir, 'index.d.ts'),
84
+ 'export type TriggerEvent<T> = { payload: T };'
85
+ );
86
+ yield* fs.writeFileString(path.join(nodeModulesDir, 'index.js'), 'export {};');
87
+
88
const outputDir = path.join(cwd, 'node_modules', '@composio', 'core', 'generated');
89
const args = ['ts', 'generate'];
90
yield* cli(args);
@@ -262,6 +294,37 @@ describe('CLI: composio ts generate', () => {
294
yield* fs.makeDirectory(nodeModulesDir, { recursive: true });
295
yield* fs.makeDirectory(generatedDir, { recursive: true });
296
297
+ // Create a mock package.json to override the symlink resolution for ESM imports
298
+ const corePackageJson = path.join(nodeModulesDir, 'package.json');
299
+ yield* fs.writeFileString(
300
+ corePackageJson,
301
+ JSON.stringify(
302
+ {
303
+ name: '@composio/core',
304
+ type: 'module',
305
+ exports: {
306
+ '.': {
307
+ types: './index.d.ts',
308
+ default: './index.js',
309
+ },
310
+ './generated': {
311
+ types: './generated/index.d.ts',
312
+ default: './generated/index.js',
313
+ },
314
+ },
315
+ },
316
+ null,
317
+ 2
318
+ )
319
+ );
320
+
321
+ // Create minimal type stubs for @composio/core root exports (needed for transpilation)
322
+ yield* fs.writeFileString(
323
+ path.join(nodeModulesDir, 'index.d.ts'),
324
+ 'export type TriggerEvent<T> = { payload: T };'
325
+ );
326
+ yield* fs.writeFileString(path.join(nodeModulesDir, 'index.js'), 'export {};');
327
+
328
const outputDir = path.join(cwd, 'node_modules', '@composio', 'core', 'generated');
329
const args = ['ts', 'generate', '--type-tools'];
330
yield* cli(args);
@@ -714,6 +777,23 @@ describe('CLI: composio ts generate', () => {
777
const fs = yield* FileSystem.FileSystem;
778
const outputDir = path.join(cwd, 'generated-compiled');
779
780
+ // Create mock @composio/core for transpilation to resolve imports
781
+ const nodeModulesDir = path.join(cwd, 'node_modules', '@composio', 'core');
782
+ yield* fs.makeDirectory(nodeModulesDir, { recursive: true });
783
+ yield* fs.writeFileString(
784
+ path.join(nodeModulesDir, 'package.json'),
785
+ JSON.stringify({
786
+ name: '@composio/core',
787
+ type: 'module',
788
+ exports: { '.': { types: './index.d.ts', default: './index.js' } },
789
+ })
790
+ );
791
+ yield* fs.writeFileString(
792
+ path.join(nodeModulesDir, 'index.d.ts'),
793
+ 'export type TriggerEvent<T> = { payload: T };'
794
+ );
795
+ yield* fs.writeFileString(path.join(nodeModulesDir, 'index.js'), 'export {};');
796
+
797
const args = ['ts', 'generate', '--transpiled', '--output-dir', outputDir];
798
yield* cli(args);
799
@@ -752,6 +832,27 @@ describe('CLI: composio ts generate', () => {
832
yield* fs.makeDirectory(nodeModulesDir, { recursive: true });
833
yield* fs.makeDirectory(generatedDir, { recursive: true });
834
835
+ // Create mock package.json and type stubs for transpilation
836
+ yield* fs.writeFileString(
837
+ path.join(nodeModulesDir, 'package.json'),
838
+ JSON.stringify({
839
+ name: '@composio/core',
840
+ type: 'module',
841
+ exports: {
842
+ '.': { types: './index.d.ts', default: './index.js' },
843
+ './generated': {
844
+ types: './generated/index.d.ts',
845
+ default: './generated/index.js',
846
+ },
847
+ },
848
+ })
849
+ );
850
+ yield* fs.writeFileString(
851
+ path.join(nodeModulesDir, 'index.d.ts'),
852
+ 'export type TriggerEvent<T> = { payload: T };'
853
+ );
854
+ yield* fs.writeFileString(path.join(nodeModulesDir, 'index.js'), 'export {};');
855
+
856
const args = ['ts', 'generate'];
857
yield* cli(args);
858