@constructive-io/graphql-codegen 4.0.2 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/cli/handler.d.ts +13 -0
  2. package/cli/handler.js +74 -0
  3. package/cli/index.js +11 -57
  4. package/core/codegen/barrel.d.ts +1 -0
  5. package/core/codegen/barrel.js +5 -2
  6. package/core/codegen/cli/arg-mapper.d.ts +4 -0
  7. package/core/codegen/cli/arg-mapper.js +117 -0
  8. package/core/codegen/cli/command-map-generator.d.ts +16 -0
  9. package/core/codegen/cli/command-map-generator.js +338 -0
  10. package/core/codegen/cli/custom-command-generator.d.ts +8 -0
  11. package/core/codegen/cli/custom-command-generator.js +155 -0
  12. package/core/codegen/cli/docs-generator.d.ts +26 -0
  13. package/core/codegen/cli/docs-generator.js +1399 -0
  14. package/core/codegen/cli/executor-generator.d.ts +11 -0
  15. package/core/codegen/cli/executor-generator.js +217 -0
  16. package/core/codegen/cli/index.d.ts +53 -0
  17. package/core/codegen/cli/index.js +153 -0
  18. package/core/codegen/cli/infra-generator.d.ts +9 -0
  19. package/core/codegen/cli/infra-generator.js +1195 -0
  20. package/core/codegen/cli/table-command-generator.d.ts +7 -0
  21. package/core/codegen/cli/table-command-generator.js +323 -0
  22. package/core/codegen/docs-utils.d.ts +30 -0
  23. package/core/codegen/docs-utils.js +122 -0
  24. package/core/codegen/hooks-docs-generator.d.ts +6 -0
  25. package/core/codegen/hooks-docs-generator.js +468 -0
  26. package/core/codegen/orm/docs-generator.d.ts +6 -0
  27. package/core/codegen/orm/docs-generator.js +416 -0
  28. package/core/codegen/target-docs-generator.d.ts +20 -0
  29. package/core/codegen/target-docs-generator.js +110 -0
  30. package/core/database/index.d.ts +0 -12
  31. package/core/database/index.js +2 -19
  32. package/core/generate.d.ts +34 -2
  33. package/core/generate.js +453 -12
  34. package/core/index.d.ts +0 -2
  35. package/core/index.js +0 -2
  36. package/core/introspect/source/database.js +2 -2
  37. package/core/introspect/source/pgpm-module.js +2 -2
  38. package/core/output/index.d.ts +1 -1
  39. package/core/output/index.js +1 -2
  40. package/core/output/writer.d.ts +0 -10
  41. package/core/output/writer.js +0 -31
  42. package/esm/cli/handler.d.ts +13 -0
  43. package/esm/cli/handler.js +71 -0
  44. package/esm/cli/index.js +11 -57
  45. package/esm/core/codegen/barrel.d.ts +1 -0
  46. package/esm/core/codegen/barrel.js +5 -2
  47. package/esm/core/codegen/cli/arg-mapper.d.ts +4 -0
  48. package/esm/core/codegen/cli/arg-mapper.js +80 -0
  49. package/esm/core/codegen/cli/command-map-generator.d.ts +16 -0
  50. package/esm/core/codegen/cli/command-map-generator.js +301 -0
  51. package/esm/core/codegen/cli/custom-command-generator.d.ts +8 -0
  52. package/esm/core/codegen/cli/custom-command-generator.js +119 -0
  53. package/esm/core/codegen/cli/docs-generator.d.ts +26 -0
  54. package/esm/core/codegen/cli/docs-generator.js +1387 -0
  55. package/esm/core/codegen/cli/executor-generator.d.ts +11 -0
  56. package/esm/core/codegen/cli/executor-generator.js +180 -0
  57. package/esm/core/codegen/cli/index.d.ts +53 -0
  58. package/esm/core/codegen/cli/index.js +128 -0
  59. package/esm/core/codegen/cli/infra-generator.d.ts +9 -0
  60. package/esm/core/codegen/cli/infra-generator.js +1156 -0
  61. package/esm/core/codegen/cli/table-command-generator.d.ts +7 -0
  62. package/esm/core/codegen/cli/table-command-generator.js +287 -0
  63. package/esm/core/codegen/docs-utils.d.ts +30 -0
  64. package/esm/core/codegen/docs-utils.js +112 -0
  65. package/esm/core/codegen/hooks-docs-generator.d.ts +6 -0
  66. package/esm/core/codegen/hooks-docs-generator.js +462 -0
  67. package/esm/core/codegen/orm/docs-generator.d.ts +6 -0
  68. package/esm/core/codegen/orm/docs-generator.js +410 -0
  69. package/esm/core/codegen/target-docs-generator.d.ts +20 -0
  70. package/esm/core/codegen/target-docs-generator.js +105 -0
  71. package/esm/core/database/index.d.ts +0 -12
  72. package/esm/core/database/index.js +1 -17
  73. package/esm/core/generate.d.ts +34 -2
  74. package/esm/core/generate.js +417 -12
  75. package/esm/core/index.d.ts +0 -2
  76. package/esm/core/index.js +0 -2
  77. package/esm/core/introspect/source/database.js +2 -2
  78. package/esm/core/introspect/source/pgpm-module.js +2 -2
  79. package/esm/core/output/index.d.ts +1 -1
  80. package/esm/core/output/index.js +1 -1
  81. package/esm/core/output/writer.d.ts +0 -10
  82. package/esm/core/output/writer.js +0 -30
  83. package/esm/generators/index.d.ts +0 -3
  84. package/esm/generators/index.js +0 -3
  85. package/esm/index.d.ts +4 -3
  86. package/esm/index.js +4 -2
  87. package/esm/types/config.d.ts +78 -0
  88. package/generators/index.d.ts +0 -3
  89. package/generators/index.js +0 -3
  90. package/index.d.ts +4 -3
  91. package/index.js +7 -2
  92. package/package.json +8 -7
  93. package/types/config.d.ts +78 -0
@@ -0,0 +1,11 @@
1
+ export interface GeneratedFile {
2
+ fileName: string;
3
+ content: string;
4
+ }
5
+ export interface MultiTargetExecutorInput {
6
+ name: string;
7
+ endpoint: string;
8
+ ormImportPath: string;
9
+ }
10
+ export declare function generateExecutorFile(toolName: string): GeneratedFile;
11
+ export declare function generateMultiTargetExecutorFile(toolName: string, targets: MultiTargetExecutorInput[]): GeneratedFile;
@@ -0,0 +1,180 @@
1
+ import * as t from '@babel/types';
2
+ import { generateCode } from '../babel-ast';
3
+ import { getGeneratedFileHeader } from '../utils';
4
+ function createImportDeclaration(moduleSpecifier, namedImports, typeOnly = false) {
5
+ const specifiers = namedImports.map((name) => t.importSpecifier(t.identifier(name), t.identifier(name)));
6
+ const decl = t.importDeclaration(specifiers, t.stringLiteral(moduleSpecifier));
7
+ decl.importKind = typeOnly ? 'type' : 'value';
8
+ return decl;
9
+ }
10
+ export function generateExecutorFile(toolName) {
11
+ const statements = [];
12
+ statements.push(createImportDeclaration('appstash', ['createConfigStore']));
13
+ statements.push(createImportDeclaration('../orm', ['createClient']));
14
+ statements.push(t.variableDeclaration('const', [
15
+ t.variableDeclarator(t.identifier('store'), t.callExpression(t.identifier('createConfigStore'), [
16
+ t.stringLiteral(toolName),
17
+ ])),
18
+ ]));
19
+ const getStoreExport = t.variableDeclaration('const', [
20
+ t.variableDeclarator(t.identifier('getStore'), t.arrowFunctionExpression([], t.identifier('store'))),
21
+ ]);
22
+ statements.push(t.exportNamedDeclaration(getStoreExport));
23
+ const contextNameParam = t.identifier('contextName');
24
+ contextNameParam.optional = true;
25
+ contextNameParam.typeAnnotation = t.tsTypeAnnotation(t.tsStringKeyword());
26
+ const getClientBody = t.blockStatement([
27
+ t.variableDeclaration('let', [
28
+ t.variableDeclarator(t.identifier('ctx'), t.nullLiteral()),
29
+ ]),
30
+ t.ifStatement(t.identifier('contextName'), t.blockStatement([
31
+ t.expressionStatement(t.assignmentExpression('=', t.identifier('ctx'), t.callExpression(t.memberExpression(t.identifier('store'), t.identifier('loadContext')), [t.identifier('contextName')]))),
32
+ t.ifStatement(t.unaryExpression('!', t.identifier('ctx')), t.blockStatement([
33
+ t.throwStatement(t.newExpression(t.identifier('Error'), [
34
+ t.templateLiteral([
35
+ t.templateElement({ raw: 'Context "', cooked: 'Context "' }),
36
+ t.templateElement({ raw: '" not found.', cooked: '" not found.' }, true),
37
+ ], [t.identifier('contextName')]),
38
+ ])),
39
+ ])),
40
+ ]), t.blockStatement([
41
+ t.expressionStatement(t.assignmentExpression('=', t.identifier('ctx'), t.callExpression(t.memberExpression(t.identifier('store'), t.identifier('getCurrentContext')), []))),
42
+ t.ifStatement(t.unaryExpression('!', t.identifier('ctx')), t.blockStatement([
43
+ t.throwStatement(t.newExpression(t.identifier('Error'), [
44
+ t.stringLiteral('No active context. Run "context create" or "context use" first.'),
45
+ ])),
46
+ ])),
47
+ ])),
48
+ t.variableDeclaration('const', [
49
+ t.variableDeclarator(t.identifier('headers'), t.objectExpression([])),
50
+ ]),
51
+ t.ifStatement(t.callExpression(t.memberExpression(t.identifier('store'), t.identifier('hasValidCredentials')), [t.memberExpression(t.identifier('ctx'), t.identifier('name'))]), t.blockStatement([
52
+ t.variableDeclaration('const', [
53
+ t.variableDeclarator(t.identifier('creds'), t.callExpression(t.memberExpression(t.identifier('store'), t.identifier('getCredentials')), [t.memberExpression(t.identifier('ctx'), t.identifier('name'))])),
54
+ ]),
55
+ t.ifStatement(t.optionalMemberExpression(t.identifier('creds'), t.identifier('token'), false, true), t.blockStatement([
56
+ t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.identifier('headers'), t.identifier('Authorization')), t.templateLiteral([
57
+ t.templateElement({ raw: 'Bearer ', cooked: 'Bearer ' }),
58
+ t.templateElement({ raw: '', cooked: '' }, true),
59
+ ], [
60
+ t.memberExpression(t.identifier('creds'), t.identifier('token')),
61
+ ]))),
62
+ ])),
63
+ ])),
64
+ t.returnStatement(t.callExpression(t.identifier('createClient'), [
65
+ t.objectExpression([
66
+ t.objectProperty(t.identifier('endpoint'), t.memberExpression(t.identifier('ctx'), t.identifier('endpoint'))),
67
+ t.objectProperty(t.identifier('headers'), t.identifier('headers')),
68
+ ]),
69
+ ])),
70
+ ]);
71
+ const getClientFunc = t.functionDeclaration(t.identifier('getClient'), [contextNameParam], getClientBody);
72
+ statements.push(t.exportNamedDeclaration(getClientFunc));
73
+ const header = getGeneratedFileHeader('Executor and config store for CLI');
74
+ const code = generateCode(statements);
75
+ return {
76
+ fileName: 'executor.ts',
77
+ content: header + '\n' + code,
78
+ };
79
+ }
80
+ export function generateMultiTargetExecutorFile(toolName, targets) {
81
+ const statements = [];
82
+ statements.push(createImportDeclaration('appstash', ['createConfigStore']));
83
+ for (const target of targets) {
84
+ const aliasName = `create${target.name[0].toUpperCase()}${target.name.slice(1)}Client`;
85
+ const specifier = t.importSpecifier(t.identifier(aliasName), t.identifier('createClient'));
86
+ statements.push(t.importDeclaration([specifier], t.stringLiteral(target.ormImportPath)));
87
+ }
88
+ statements.push(t.variableDeclaration('const', [
89
+ t.variableDeclarator(t.identifier('store'), t.callExpression(t.identifier('createConfigStore'), [
90
+ t.stringLiteral(toolName),
91
+ ])),
92
+ ]));
93
+ const getStoreExport = t.variableDeclaration('const', [
94
+ t.variableDeclarator(t.identifier('getStore'), t.arrowFunctionExpression([], t.identifier('store'))),
95
+ ]);
96
+ statements.push(t.exportNamedDeclaration(getStoreExport));
97
+ const targetClientsProps = targets.map((target) => {
98
+ const aliasName = `create${target.name[0].toUpperCase()}${target.name.slice(1)}Client`;
99
+ return t.objectProperty(t.stringLiteral(target.name), t.identifier(aliasName));
100
+ });
101
+ const targetClientsDecl = t.variableDeclaration('const', [
102
+ t.variableDeclarator(t.identifier('targetClients'), t.objectExpression(targetClientsProps)),
103
+ ]);
104
+ statements.push(targetClientsDecl);
105
+ const defaultEndpointProps = targets.map((target) => t.objectProperty(t.stringLiteral(target.name), t.stringLiteral(target.endpoint)));
106
+ const defaultEndpointsDecl = t.variableDeclaration('const', [
107
+ t.variableDeclarator(t.identifier('defaultEndpoints'), t.objectExpression(defaultEndpointProps)),
108
+ ]);
109
+ statements.push(defaultEndpointsDecl);
110
+ const getTargetNamesFunc = t.variableDeclaration('const', [
111
+ t.variableDeclarator(t.identifier('getTargetNames'), t.arrowFunctionExpression([], t.callExpression(t.memberExpression(t.identifier('Object'), t.identifier('keys')), [t.identifier('targetClients')]))),
112
+ ]);
113
+ statements.push(t.exportNamedDeclaration(getTargetNamesFunc));
114
+ const getDefaultEndpointParam = t.identifier('targetName');
115
+ getDefaultEndpointParam.typeAnnotation = t.tsTypeAnnotation(t.tsStringKeyword());
116
+ const getDefaultEndpointFunc = t.variableDeclaration('const', [
117
+ t.variableDeclarator(t.identifier('getDefaultEndpoint'), t.arrowFunctionExpression([getDefaultEndpointParam], t.logicalExpression('||', t.memberExpression(t.identifier('defaultEndpoints'), t.identifier('targetName'), true), t.stringLiteral('')))),
118
+ ]);
119
+ statements.push(t.exportNamedDeclaration(getDefaultEndpointFunc));
120
+ const targetNameParam = t.identifier('targetName');
121
+ targetNameParam.typeAnnotation = t.tsTypeAnnotation(t.tsStringKeyword());
122
+ const contextNameParam = t.identifier('contextName');
123
+ contextNameParam.optional = true;
124
+ contextNameParam.typeAnnotation = t.tsTypeAnnotation(t.tsStringKeyword());
125
+ const getClientBody = t.blockStatement([
126
+ t.variableDeclaration('const', [
127
+ t.variableDeclarator(t.identifier('createFn'), t.memberExpression(t.identifier('targetClients'), t.identifier('targetName'), true)),
128
+ ]),
129
+ t.ifStatement(t.unaryExpression('!', t.identifier('createFn')), t.blockStatement([
130
+ t.throwStatement(t.newExpression(t.identifier('Error'), [
131
+ t.templateLiteral([
132
+ t.templateElement({ raw: 'Unknown target: ', cooked: 'Unknown target: ' }),
133
+ t.templateElement({ raw: '', cooked: '' }, true),
134
+ ], [t.identifier('targetName')]),
135
+ ])),
136
+ ])),
137
+ t.variableDeclaration('const', [
138
+ t.variableDeclarator(t.identifier('headers'), t.objectExpression([])),
139
+ ]),
140
+ t.variableDeclaration('let', [
141
+ t.variableDeclarator(t.identifier('endpoint'), t.stringLiteral('')),
142
+ ]),
143
+ t.variableDeclaration('const', [
144
+ t.variableDeclarator(t.identifier('ctx'), t.conditionalExpression(t.identifier('contextName'), t.callExpression(t.memberExpression(t.identifier('store'), t.identifier('loadContext')), [t.identifier('contextName')]), t.callExpression(t.memberExpression(t.identifier('store'), t.identifier('getCurrentContext')), []))),
145
+ ]),
146
+ t.ifStatement(t.identifier('ctx'), t.blockStatement([
147
+ t.variableDeclaration('const', [
148
+ t.variableDeclarator(t.identifier('resolved'), t.callExpression(t.memberExpression(t.identifier('store'), t.identifier('getTargetEndpoint')), [t.identifier('targetName'), t.memberExpression(t.identifier('ctx'), t.identifier('name'))])),
149
+ ]),
150
+ t.expressionStatement(t.assignmentExpression('=', t.identifier('endpoint'), t.logicalExpression('||', t.identifier('resolved'), t.logicalExpression('||', t.memberExpression(t.identifier('defaultEndpoints'), t.identifier('targetName'), true), t.stringLiteral(''))))),
151
+ t.ifStatement(t.callExpression(t.memberExpression(t.identifier('store'), t.identifier('hasValidCredentials')), [t.memberExpression(t.identifier('ctx'), t.identifier('name'))]), t.blockStatement([
152
+ t.variableDeclaration('const', [
153
+ t.variableDeclarator(t.identifier('creds'), t.callExpression(t.memberExpression(t.identifier('store'), t.identifier('getCredentials')), [t.memberExpression(t.identifier('ctx'), t.identifier('name'))])),
154
+ ]),
155
+ t.ifStatement(t.optionalMemberExpression(t.identifier('creds'), t.identifier('token'), false, true), t.blockStatement([
156
+ t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.identifier('headers'), t.identifier('Authorization')), t.templateLiteral([
157
+ t.templateElement({ raw: 'Bearer ', cooked: 'Bearer ' }),
158
+ t.templateElement({ raw: '', cooked: '' }, true),
159
+ ], [t.memberExpression(t.identifier('creds'), t.identifier('token'))]))),
160
+ ])),
161
+ ])),
162
+ ]), t.blockStatement([
163
+ t.expressionStatement(t.assignmentExpression('=', t.identifier('endpoint'), t.logicalExpression('||', t.memberExpression(t.identifier('defaultEndpoints'), t.identifier('targetName'), true), t.stringLiteral('')))),
164
+ ])),
165
+ t.returnStatement(t.callExpression(t.identifier('createFn'), [
166
+ t.objectExpression([
167
+ t.objectProperty(t.identifier('endpoint'), t.identifier('endpoint')),
168
+ t.objectProperty(t.identifier('headers'), t.identifier('headers')),
169
+ ]),
170
+ ])),
171
+ ]);
172
+ const getClientFunc = t.functionDeclaration(t.identifier('getClient'), [targetNameParam, contextNameParam], getClientBody);
173
+ statements.push(t.exportNamedDeclaration(getClientFunc));
174
+ const header = getGeneratedFileHeader('Multi-target executor and config store for CLI');
175
+ const code = generateCode(statements);
176
+ return {
177
+ fileName: 'executor.ts',
178
+ content: header + '\n' + code,
179
+ };
180
+ }
@@ -0,0 +1,53 @@
1
+ import type { BuiltinNames, GraphQLSDKConfigTarget } from '../../../types/config';
2
+ import type { CleanOperation, CleanTable } from '../../../types/schema';
3
+ import type { GeneratedFile } from './executor-generator';
4
+ export interface GenerateCliOptions {
5
+ tables: CleanTable[];
6
+ customOperations?: {
7
+ queries: CleanOperation[];
8
+ mutations: CleanOperation[];
9
+ };
10
+ config: GraphQLSDKConfigTarget;
11
+ }
12
+ export interface GenerateCliResult {
13
+ files: GeneratedFile[];
14
+ stats: {
15
+ tables: number;
16
+ customQueries: number;
17
+ customMutations: number;
18
+ infraFiles: number;
19
+ totalFiles: number;
20
+ };
21
+ }
22
+ export declare function generateCli(options: GenerateCliOptions): GenerateCliResult;
23
+ export interface MultiTargetCliTarget {
24
+ name: string;
25
+ endpoint: string;
26
+ ormImportPath: string;
27
+ tables: CleanTable[];
28
+ customOperations: {
29
+ queries: CleanOperation[];
30
+ mutations: CleanOperation[];
31
+ };
32
+ isAuthTarget?: boolean;
33
+ }
34
+ export interface GenerateMultiTargetCliOptions {
35
+ toolName: string;
36
+ builtinNames?: BuiltinNames;
37
+ targets: MultiTargetCliTarget[];
38
+ }
39
+ export declare function resolveBuiltinNames(targetNames: string[], userOverrides?: BuiltinNames): {
40
+ auth: string;
41
+ context: string;
42
+ };
43
+ export declare function generateMultiTargetCli(options: GenerateMultiTargetCliOptions): GenerateCliResult;
44
+ export { generateExecutorFile, generateMultiTargetExecutorFile } from './executor-generator';
45
+ export { generateTableCommand } from './table-command-generator';
46
+ export { generateCustomCommand } from './custom-command-generator';
47
+ export { generateCommandMap, generateMultiTargetCommandMap } from './command-map-generator';
48
+ export { generateContextCommand, generateAuthCommand, generateMultiTargetContextCommand, generateAuthCommandWithName, } from './infra-generator';
49
+ export { generateReadme, generateAgentsDocs, getCliMcpTools, generateSkills, generateMultiTargetReadme, generateMultiTargetAgentsDocs, getMultiTargetCliMcpTools, generateMultiTargetSkills, } from './docs-generator';
50
+ export type { MultiTargetDocsInput } from './docs-generator';
51
+ export { resolveDocsConfig } from '../docs-utils';
52
+ export type { GeneratedDocFile, McpTool } from '../docs-utils';
53
+ export type { GeneratedFile, MultiTargetExecutorInput } from './executor-generator';
@@ -0,0 +1,128 @@
1
+ import { generateCommandMap, generateMultiTargetCommandMap } from './command-map-generator';
2
+ import { generateCustomCommand } from './custom-command-generator';
3
+ import { generateExecutorFile, generateMultiTargetExecutorFile } from './executor-generator';
4
+ import { generateAuthCommand, generateAuthCommandWithName, generateContextCommand, generateMultiTargetContextCommand, } from './infra-generator';
5
+ import { generateTableCommand } from './table-command-generator';
6
+ export function generateCli(options) {
7
+ const { tables, customOperations, config } = options;
8
+ const files = [];
9
+ const cliConfig = config.cli;
10
+ const toolName = typeof cliConfig === 'object' && cliConfig.toolName
11
+ ? cliConfig.toolName
12
+ : 'app';
13
+ const executorFile = generateExecutorFile(toolName);
14
+ files.push(executorFile);
15
+ const contextFile = generateContextCommand(toolName);
16
+ files.push(contextFile);
17
+ const authFile = generateAuthCommand(toolName);
18
+ files.push(authFile);
19
+ for (const table of tables) {
20
+ const tableFile = generateTableCommand(table);
21
+ files.push(tableFile);
22
+ }
23
+ const allCustomOps = [
24
+ ...(customOperations?.queries ?? []),
25
+ ...(customOperations?.mutations ?? []),
26
+ ];
27
+ for (const op of allCustomOps) {
28
+ const customFile = generateCustomCommand(op);
29
+ files.push(customFile);
30
+ }
31
+ const commandMapFile = generateCommandMap(tables, allCustomOps, toolName);
32
+ files.push(commandMapFile);
33
+ return {
34
+ files,
35
+ stats: {
36
+ tables: tables.length,
37
+ customQueries: customOperations?.queries.length ?? 0,
38
+ customMutations: customOperations?.mutations.length ?? 0,
39
+ infraFiles: 3,
40
+ totalFiles: files.length,
41
+ },
42
+ };
43
+ }
44
+ export function resolveBuiltinNames(targetNames, userOverrides) {
45
+ let authName = userOverrides?.auth ?? 'auth';
46
+ let contextName = userOverrides?.context ?? 'context';
47
+ if (targetNames.includes(authName) && !userOverrides?.auth) {
48
+ authName = 'credentials';
49
+ }
50
+ if (targetNames.includes(contextName) && !userOverrides?.context) {
51
+ contextName = 'env';
52
+ }
53
+ return { auth: authName, context: contextName };
54
+ }
55
+ export function generateMultiTargetCli(options) {
56
+ const { toolName, targets } = options;
57
+ const files = [];
58
+ const targetNames = targets.map((t) => t.name);
59
+ const builtinNames = resolveBuiltinNames(targetNames, options.builtinNames);
60
+ const executorInputs = targets.map((t) => ({
61
+ name: t.name,
62
+ endpoint: t.endpoint,
63
+ ormImportPath: t.ormImportPath,
64
+ }));
65
+ const executorFile = generateMultiTargetExecutorFile(toolName, executorInputs);
66
+ files.push(executorFile);
67
+ const contextFile = generateMultiTargetContextCommand(toolName, builtinNames.context, targets.map((t) => ({ name: t.name, endpoint: t.endpoint })));
68
+ files.push(contextFile);
69
+ const authFile = generateAuthCommandWithName(toolName, builtinNames.auth);
70
+ files.push(authFile);
71
+ let totalTables = 0;
72
+ let totalQueries = 0;
73
+ let totalMutations = 0;
74
+ const commandMapTargets = [];
75
+ for (const target of targets) {
76
+ const allOps = [
77
+ ...(target.customOperations?.queries ?? []),
78
+ ...(target.customOperations?.mutations ?? []),
79
+ ];
80
+ for (const table of target.tables) {
81
+ const tableFile = generateTableCommand(table, {
82
+ targetName: target.name,
83
+ executorImportPath: '../../executor',
84
+ });
85
+ files.push(tableFile);
86
+ }
87
+ for (const op of allOps) {
88
+ const isSaveToken = !!target.isAuthTarget && op.kind === 'mutation';
89
+ const customFile = generateCustomCommand(op, {
90
+ targetName: target.name,
91
+ executorImportPath: '../../executor',
92
+ saveToken: isSaveToken,
93
+ });
94
+ files.push(customFile);
95
+ }
96
+ totalTables += target.tables.length;
97
+ totalQueries += target.customOperations?.queries?.length ?? 0;
98
+ totalMutations += target.customOperations?.mutations?.length ?? 0;
99
+ commandMapTargets.push({
100
+ name: target.name,
101
+ tables: target.tables,
102
+ customOperations: allOps,
103
+ });
104
+ }
105
+ const commandMapFile = generateMultiTargetCommandMap({
106
+ toolName,
107
+ builtinNames,
108
+ targets: commandMapTargets,
109
+ });
110
+ files.push(commandMapFile);
111
+ return {
112
+ files,
113
+ stats: {
114
+ tables: totalTables,
115
+ customQueries: totalQueries,
116
+ customMutations: totalMutations,
117
+ infraFiles: 3,
118
+ totalFiles: files.length,
119
+ },
120
+ };
121
+ }
122
+ export { generateExecutorFile, generateMultiTargetExecutorFile } from './executor-generator';
123
+ export { generateTableCommand } from './table-command-generator';
124
+ export { generateCustomCommand } from './custom-command-generator';
125
+ export { generateCommandMap, generateMultiTargetCommandMap } from './command-map-generator';
126
+ export { generateContextCommand, generateAuthCommand, generateMultiTargetContextCommand, generateAuthCommandWithName, } from './infra-generator';
127
+ export { generateReadme, generateAgentsDocs, getCliMcpTools, generateSkills, generateMultiTargetReadme, generateMultiTargetAgentsDocs, getMultiTargetCliMcpTools, generateMultiTargetSkills, } from './docs-generator';
128
+ export { resolveDocsConfig } from '../docs-utils';
@@ -0,0 +1,9 @@
1
+ import type { GeneratedFile } from './executor-generator';
2
+ export declare function generateContextCommand(toolName: string): GeneratedFile;
3
+ export declare function generateAuthCommand(toolName: string): GeneratedFile;
4
+ export interface MultiTargetContextInput {
5
+ name: string;
6
+ endpoint: string;
7
+ }
8
+ export declare function generateMultiTargetContextCommand(toolName: string, commandName: string, targets: MultiTargetContextInput[]): GeneratedFile;
9
+ export declare function generateAuthCommandWithName(toolName: string, commandName: string): GeneratedFile;