@constructive-io/graphql-codegen 4.12.2 → 4.13.1
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.
- package/core/codegen/cli/command-map-generator.d.ts +1 -0
- package/core/codegen/cli/command-map-generator.js +4 -0
- package/core/codegen/cli/config-command-generator.d.ts +11 -0
- package/core/codegen/cli/config-command-generator.js +458 -0
- package/core/codegen/cli/docs-generator.d.ts +1 -0
- package/core/codegen/cli/docs-generator.js +267 -1
- package/core/codegen/cli/helpers-generator.d.ts +15 -0
- package/core/codegen/cli/helpers-generator.js +119 -0
- package/core/codegen/cli/index.d.ts +4 -0
- package/core/codegen/cli/index.js +21 -3
- package/core/codegen/orm/index.js +3 -2
- package/core/codegen/orm/input-types-generator.d.ts +3 -1
- package/core/codegen/orm/input-types-generator.js +14 -6
- package/core/codegen/orm/model-generator.d.ts +6 -2
- package/core/codegen/orm/model-generator.js +59 -37
- package/core/codegen/templates/query-builder.ts +2 -2
- package/core/codegen/templates/select-types.ts +2 -2
- package/esm/core/codegen/cli/command-map-generator.d.ts +1 -0
- package/esm/core/codegen/cli/command-map-generator.js +4 -0
- package/esm/core/codegen/cli/config-command-generator.d.ts +11 -0
- package/esm/core/codegen/cli/config-command-generator.js +422 -0
- package/esm/core/codegen/cli/docs-generator.d.ts +1 -0
- package/esm/core/codegen/cli/docs-generator.js +267 -1
- package/esm/core/codegen/cli/helpers-generator.d.ts +15 -0
- package/esm/core/codegen/cli/helpers-generator.js +83 -0
- package/esm/core/codegen/cli/index.d.ts +4 -0
- package/esm/core/codegen/cli/index.js +18 -2
- package/esm/core/codegen/orm/index.js +3 -2
- package/esm/core/codegen/orm/input-types-generator.d.ts +3 -1
- package/esm/core/codegen/orm/input-types-generator.js +14 -6
- package/esm/core/codegen/orm/model-generator.d.ts +6 -2
- package/esm/core/codegen/orm/model-generator.js +59 -37
- package/esm/types/config.d.ts +9 -0
- package/esm/types/config.js +1 -0
- package/package.json +4 -4
- package/types/config.d.ts +9 -0
- package/types/config.js +1 -0
|
@@ -37,6 +37,7 @@ function generateReadme(tables, customOperations, toolName, registry) {
|
|
|
37
37
|
lines.push('|---------|-------------|');
|
|
38
38
|
lines.push('| `context` | Manage API contexts (endpoints) |');
|
|
39
39
|
lines.push('| `auth` | Manage authentication tokens |');
|
|
40
|
+
lines.push('| `config` | Manage config key-value store (per-context) |');
|
|
40
41
|
for (const table of tables) {
|
|
41
42
|
const { singularName } = (0, utils_1.getTableNames)(table);
|
|
42
43
|
const kebab = (0, komoji_1.toKebabCase)(singularName);
|
|
@@ -73,6 +74,19 @@ function generateReadme(tables, customOperations, toolName, registry) {
|
|
|
73
74
|
lines.push('| `status` | Show auth status across all contexts |');
|
|
74
75
|
lines.push('| `logout` | Remove credentials for current context |');
|
|
75
76
|
lines.push('');
|
|
77
|
+
lines.push('### `config`');
|
|
78
|
+
lines.push('');
|
|
79
|
+
lines.push('Manage per-context key-value configuration variables.');
|
|
80
|
+
lines.push('');
|
|
81
|
+
lines.push('| Subcommand | Description |');
|
|
82
|
+
lines.push('|------------|-------------|');
|
|
83
|
+
lines.push('| `get <key>` | Get a config value |');
|
|
84
|
+
lines.push('| `set <key> <value>` | Set a config value |');
|
|
85
|
+
lines.push('| `list` | List all config values |');
|
|
86
|
+
lines.push('| `delete <key>` | Delete a config value |');
|
|
87
|
+
lines.push('');
|
|
88
|
+
lines.push(`Variables are scoped to the active context and stored at \`~/.${toolName}/config/\`.`);
|
|
89
|
+
lines.push('');
|
|
76
90
|
if (tables.length > 0) {
|
|
77
91
|
lines.push('## Table Commands');
|
|
78
92
|
lines.push('');
|
|
@@ -233,6 +247,28 @@ function generateAgentsDocs(tables, customOperations, toolName, registry) {
|
|
|
233
247
|
lines.push(' logout: { context, status: "logged out" }');
|
|
234
248
|
lines.push('```');
|
|
235
249
|
lines.push('');
|
|
250
|
+
lines.push('### TOOL: config');
|
|
251
|
+
lines.push('');
|
|
252
|
+
lines.push('Manage per-context key-value configuration variables.');
|
|
253
|
+
lines.push('');
|
|
254
|
+
lines.push('```');
|
|
255
|
+
lines.push('SUBCOMMANDS:');
|
|
256
|
+
lines.push(` ${toolName} config get <key> Get a config value`);
|
|
257
|
+
lines.push(` ${toolName} config set <key> <value> Set a config value`);
|
|
258
|
+
lines.push(` ${toolName} config list List all config values`);
|
|
259
|
+
lines.push(` ${toolName} config delete <key> Delete a config value`);
|
|
260
|
+
lines.push('');
|
|
261
|
+
lines.push('INPUT:');
|
|
262
|
+
lines.push(' key: string (required for get/set/delete) - Variable name');
|
|
263
|
+
lines.push(' value: string (required for set) - Variable value');
|
|
264
|
+
lines.push('');
|
|
265
|
+
lines.push('OUTPUT: JSON');
|
|
266
|
+
lines.push(' get: { key, value }');
|
|
267
|
+
lines.push(' set: { key, value }');
|
|
268
|
+
lines.push(' list: { vars: { key: value, ... } }');
|
|
269
|
+
lines.push(' delete: { deleted: key }');
|
|
270
|
+
lines.push('```');
|
|
271
|
+
lines.push('');
|
|
236
272
|
for (const table of tables) {
|
|
237
273
|
const { singularName } = (0, utils_1.getTableNames)(table);
|
|
238
274
|
const kebab = (0, komoji_1.toKebabCase)(singularName);
|
|
@@ -440,6 +476,45 @@ function getCliMcpTools(tables, customOperations, toolName, registry) {
|
|
|
440
476
|
description: 'Remove credentials for the current context',
|
|
441
477
|
inputSchema: { type: 'object', properties: {} },
|
|
442
478
|
});
|
|
479
|
+
tools.push({
|
|
480
|
+
name: `${toolName}_config_get`,
|
|
481
|
+
description: 'Get a config variable value for the current context',
|
|
482
|
+
inputSchema: {
|
|
483
|
+
type: 'object',
|
|
484
|
+
properties: {
|
|
485
|
+
key: { type: 'string', description: 'Variable name' },
|
|
486
|
+
},
|
|
487
|
+
required: ['key'],
|
|
488
|
+
},
|
|
489
|
+
});
|
|
490
|
+
tools.push({
|
|
491
|
+
name: `${toolName}_config_set`,
|
|
492
|
+
description: 'Set a config variable value for the current context',
|
|
493
|
+
inputSchema: {
|
|
494
|
+
type: 'object',
|
|
495
|
+
properties: {
|
|
496
|
+
key: { type: 'string', description: 'Variable name' },
|
|
497
|
+
value: { type: 'string', description: 'Variable value' },
|
|
498
|
+
},
|
|
499
|
+
required: ['key', 'value'],
|
|
500
|
+
},
|
|
501
|
+
});
|
|
502
|
+
tools.push({
|
|
503
|
+
name: `${toolName}_config_list`,
|
|
504
|
+
description: 'List all config variables for the current context',
|
|
505
|
+
inputSchema: { type: 'object', properties: {} },
|
|
506
|
+
});
|
|
507
|
+
tools.push({
|
|
508
|
+
name: `${toolName}_config_delete`,
|
|
509
|
+
description: 'Delete a config variable for the current context',
|
|
510
|
+
inputSchema: {
|
|
511
|
+
type: 'object',
|
|
512
|
+
properties: {
|
|
513
|
+
key: { type: 'string', description: 'Variable name to delete' },
|
|
514
|
+
},
|
|
515
|
+
required: ['key'],
|
|
516
|
+
},
|
|
517
|
+
});
|
|
443
518
|
for (const table of tables) {
|
|
444
519
|
const { singularName } = (0, utils_1.getTableNames)(table);
|
|
445
520
|
const kebab = (0, komoji_1.toKebabCase)(singularName);
|
|
@@ -617,6 +692,34 @@ function generateSkills(tables, customOperations, toolName, targetName, registry
|
|
|
617
692
|
],
|
|
618
693
|
}),
|
|
619
694
|
});
|
|
695
|
+
// Config reference
|
|
696
|
+
referenceNames.push('config');
|
|
697
|
+
files.push({
|
|
698
|
+
fileName: `${skillName}/references/config.md`,
|
|
699
|
+
content: (0, docs_utils_1.buildSkillReference)({
|
|
700
|
+
title: 'Config Variables',
|
|
701
|
+
description: `Manage per-context key-value configuration variables for ${toolName}`,
|
|
702
|
+
usage: [
|
|
703
|
+
`${toolName} config get <key>`,
|
|
704
|
+
`${toolName} config set <key> <value>`,
|
|
705
|
+
`${toolName} config list`,
|
|
706
|
+
`${toolName} config delete <key>`,
|
|
707
|
+
],
|
|
708
|
+
examples: [
|
|
709
|
+
{
|
|
710
|
+
description: 'Store and retrieve a config variable',
|
|
711
|
+
code: [
|
|
712
|
+
`${toolName} config set orgId abc-123`,
|
|
713
|
+
`${toolName} config get orgId`,
|
|
714
|
+
],
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
description: 'List all config variables',
|
|
718
|
+
code: [`${toolName} config list`],
|
|
719
|
+
},
|
|
720
|
+
],
|
|
721
|
+
}),
|
|
722
|
+
});
|
|
620
723
|
// Table references
|
|
621
724
|
for (const table of tables) {
|
|
622
725
|
const { singularName } = (0, utils_1.getTableNames)(table);
|
|
@@ -698,6 +801,10 @@ function generateSkills(tables, customOperations, toolName, targetName, registry
|
|
|
698
801
|
`# Authentication`,
|
|
699
802
|
`${toolName} auth set-token <token>`,
|
|
700
803
|
'',
|
|
804
|
+
`# Config variables`,
|
|
805
|
+
`${toolName} config set <key> <value>`,
|
|
806
|
+
`${toolName} config get <key>`,
|
|
807
|
+
'',
|
|
701
808
|
`# CRUD for any table (e.g. ${tableKebabs[0] || 'model'})`,
|
|
702
809
|
`${toolName} ${tableKebabs[0] || 'model'} list`,
|
|
703
810
|
`${toolName} ${tableKebabs[0] || 'model'} get --id <value>`,
|
|
@@ -793,6 +900,7 @@ function generateMultiTargetReadme(input) {
|
|
|
793
900
|
lines.push('|---------|-------------|');
|
|
794
901
|
lines.push(`| \`${builtinNames.context}\` | Manage API contexts (per-target endpoints) |`);
|
|
795
902
|
lines.push(`| \`${builtinNames.auth}\` | Manage authentication tokens |`);
|
|
903
|
+
lines.push(`| \`${builtinNames.config}\` | Manage config key-value store (per-context) |`);
|
|
796
904
|
lines.push('');
|
|
797
905
|
for (const tgt of targets) {
|
|
798
906
|
lines.push(`### ${tgt.name}`);
|
|
@@ -842,6 +950,40 @@ function generateMultiTargetReadme(input) {
|
|
|
842
950
|
lines.push('| `status` | Show auth status across all contexts |');
|
|
843
951
|
lines.push('| `logout` | Remove credentials for current context |');
|
|
844
952
|
lines.push('');
|
|
953
|
+
lines.push(`### \`${builtinNames.config}\``);
|
|
954
|
+
lines.push('');
|
|
955
|
+
lines.push('Manage per-context key-value configuration variables.');
|
|
956
|
+
lines.push('');
|
|
957
|
+
lines.push('| Subcommand | Description |');
|
|
958
|
+
lines.push('|------------|-------------|');
|
|
959
|
+
lines.push('| `get <key>` | Get a config value |');
|
|
960
|
+
lines.push('| `set <key> <value>` | Set a config value |');
|
|
961
|
+
lines.push('| `list` | List all config values |');
|
|
962
|
+
lines.push('| `delete <key>` | Delete a config value |');
|
|
963
|
+
lines.push('');
|
|
964
|
+
lines.push(`Variables are scoped to the active context and stored at \`~/.${toolName}/config/\`.`);
|
|
965
|
+
lines.push('');
|
|
966
|
+
lines.push('## SDK Helpers');
|
|
967
|
+
lines.push('');
|
|
968
|
+
lines.push('The generated `helpers.ts` provides typed client factories for use in scripts and services:');
|
|
969
|
+
lines.push('');
|
|
970
|
+
lines.push('```typescript');
|
|
971
|
+
for (const tgt of targets) {
|
|
972
|
+
const pascalName = tgt.name.charAt(0).toUpperCase() + tgt.name.slice(1);
|
|
973
|
+
lines.push(`import { create${pascalName}Client } from './helpers';`);
|
|
974
|
+
}
|
|
975
|
+
lines.push('');
|
|
976
|
+
for (const tgt of targets) {
|
|
977
|
+
const pascalName = tgt.name.charAt(0).toUpperCase() + tgt.name.slice(1);
|
|
978
|
+
lines.push(`const ${tgt.name} = create${pascalName}Client();`);
|
|
979
|
+
}
|
|
980
|
+
lines.push('```');
|
|
981
|
+
lines.push('');
|
|
982
|
+
lines.push('Credential resolution order:');
|
|
983
|
+
lines.push(`1. appstash store (\`~/.${toolName}/config/\`)`);
|
|
984
|
+
lines.push(`2. Environment variables (\`${toolName.toUpperCase().replace(/-/g, '_')}_TOKEN\`, \`${toolName.toUpperCase().replace(/-/g, '_')}_<TARGET>_ENDPOINT\`)`);
|
|
985
|
+
lines.push('3. Throws with actionable error message');
|
|
986
|
+
lines.push('');
|
|
845
987
|
for (const tgt of targets) {
|
|
846
988
|
if (tgt.tables.length === 0 && tgt.customOperations.length === 0)
|
|
847
989
|
continue;
|
|
@@ -968,6 +1110,7 @@ function generateMultiTargetAgentsDocs(input) {
|
|
|
968
1110
|
lines.push(` ${toolName} <target>:<command> <subcommand> [flags] Target-specific commands`);
|
|
969
1111
|
lines.push(` ${toolName} ${builtinNames.context} <subcommand> [flags] Context management`);
|
|
970
1112
|
lines.push(` ${toolName} ${builtinNames.auth} <subcommand> [flags] Authentication`);
|
|
1113
|
+
lines.push(` ${toolName} ${builtinNames.config} <subcommand> [flags] Config key-value store`);
|
|
971
1114
|
lines.push('');
|
|
972
1115
|
lines.push('## PREREQUISITES');
|
|
973
1116
|
lines.push('');
|
|
@@ -1032,6 +1175,51 @@ function generateMultiTargetAgentsDocs(input) {
|
|
|
1032
1175
|
lines.push(' logout: { context, status: "logged out" }');
|
|
1033
1176
|
lines.push('```');
|
|
1034
1177
|
lines.push('');
|
|
1178
|
+
lines.push(`### TOOL: ${builtinNames.config}`);
|
|
1179
|
+
lines.push('');
|
|
1180
|
+
lines.push('Manage per-context key-value configuration variables.');
|
|
1181
|
+
lines.push('');
|
|
1182
|
+
lines.push('```');
|
|
1183
|
+
lines.push('SUBCOMMANDS:');
|
|
1184
|
+
lines.push(` ${toolName} ${builtinNames.config} get <key> Get a config value`);
|
|
1185
|
+
lines.push(` ${toolName} ${builtinNames.config} set <key> <value> Set a config value`);
|
|
1186
|
+
lines.push(` ${toolName} ${builtinNames.config} list List all config values`);
|
|
1187
|
+
lines.push(` ${toolName} ${builtinNames.config} delete <key> Delete a config value`);
|
|
1188
|
+
lines.push('');
|
|
1189
|
+
lines.push('INPUT:');
|
|
1190
|
+
lines.push(' key: string (required for get/set/delete) - Variable name');
|
|
1191
|
+
lines.push(' value: string (required for set) - Variable value');
|
|
1192
|
+
lines.push('');
|
|
1193
|
+
lines.push('OUTPUT: JSON');
|
|
1194
|
+
lines.push(' get: { key, value }');
|
|
1195
|
+
lines.push(' set: { key, value }');
|
|
1196
|
+
lines.push(' list: { vars: { key: value, ... } }');
|
|
1197
|
+
lines.push(' delete: { deleted: key }');
|
|
1198
|
+
lines.push('```');
|
|
1199
|
+
lines.push('');
|
|
1200
|
+
lines.push('### TOOL: helpers (SDK)');
|
|
1201
|
+
lines.push('');
|
|
1202
|
+
lines.push('Typed client factories for use in scripts and services (generated helpers.ts).');
|
|
1203
|
+
lines.push('Resolves credentials via: appstash store -> env vars -> throw.');
|
|
1204
|
+
lines.push('');
|
|
1205
|
+
lines.push('```');
|
|
1206
|
+
lines.push('FACTORIES:');
|
|
1207
|
+
for (const tgt of targets) {
|
|
1208
|
+
const pascalName = tgt.name.charAt(0).toUpperCase() + tgt.name.slice(1);
|
|
1209
|
+
lines.push(` create${pascalName}Client(contextName?) Create a configured ${tgt.name} ORM client`);
|
|
1210
|
+
}
|
|
1211
|
+
lines.push('');
|
|
1212
|
+
lines.push('USAGE:');
|
|
1213
|
+
lines.push(` import { create${targets[0] ? targets[0].name.charAt(0).toUpperCase() + targets[0].name.slice(1) : 'Target'}Client } from './helpers';`);
|
|
1214
|
+
lines.push(` const client = create${targets[0] ? targets[0].name.charAt(0).toUpperCase() + targets[0].name.slice(1) : 'Target'}Client();`);
|
|
1215
|
+
lines.push('');
|
|
1216
|
+
lines.push('CREDENTIAL RESOLUTION:');
|
|
1217
|
+
lines.push(` 1. appstash store (~/.${toolName}/config/)`);
|
|
1218
|
+
const envPrefix = toolName.toUpperCase().replace(/-/g, '_');
|
|
1219
|
+
lines.push(` 2. env vars (${envPrefix}_TOKEN, ${envPrefix}_<TARGET>_ENDPOINT)`);
|
|
1220
|
+
lines.push(' 3. throws with actionable error message');
|
|
1221
|
+
lines.push('```');
|
|
1222
|
+
lines.push('');
|
|
1035
1223
|
for (const tgt of targets) {
|
|
1036
1224
|
for (const table of tgt.tables) {
|
|
1037
1225
|
const { singularName } = (0, utils_1.getTableNames)(table);
|
|
@@ -1257,6 +1445,45 @@ function getMultiTargetCliMcpTools(input) {
|
|
|
1257
1445
|
description: 'Remove credentials for the current context',
|
|
1258
1446
|
inputSchema: { type: 'object', properties: {} },
|
|
1259
1447
|
});
|
|
1448
|
+
tools.push({
|
|
1449
|
+
name: `${toolName}_${builtinNames.config}_get`,
|
|
1450
|
+
description: 'Get a config variable value for the current context',
|
|
1451
|
+
inputSchema: {
|
|
1452
|
+
type: 'object',
|
|
1453
|
+
properties: {
|
|
1454
|
+
key: { type: 'string', description: 'Variable name' },
|
|
1455
|
+
},
|
|
1456
|
+
required: ['key'],
|
|
1457
|
+
},
|
|
1458
|
+
});
|
|
1459
|
+
tools.push({
|
|
1460
|
+
name: `${toolName}_${builtinNames.config}_set`,
|
|
1461
|
+
description: 'Set a config variable value for the current context',
|
|
1462
|
+
inputSchema: {
|
|
1463
|
+
type: 'object',
|
|
1464
|
+
properties: {
|
|
1465
|
+
key: { type: 'string', description: 'Variable name' },
|
|
1466
|
+
value: { type: 'string', description: 'Variable value' },
|
|
1467
|
+
},
|
|
1468
|
+
required: ['key', 'value'],
|
|
1469
|
+
},
|
|
1470
|
+
});
|
|
1471
|
+
tools.push({
|
|
1472
|
+
name: `${toolName}_${builtinNames.config}_list`,
|
|
1473
|
+
description: 'List all config variables for the current context',
|
|
1474
|
+
inputSchema: { type: 'object', properties: {} },
|
|
1475
|
+
});
|
|
1476
|
+
tools.push({
|
|
1477
|
+
name: `${toolName}_${builtinNames.config}_delete`,
|
|
1478
|
+
description: 'Delete a config variable for the current context',
|
|
1479
|
+
inputSchema: {
|
|
1480
|
+
type: 'object',
|
|
1481
|
+
properties: {
|
|
1482
|
+
key: { type: 'string', description: 'Variable name to delete' },
|
|
1483
|
+
},
|
|
1484
|
+
required: ['key'],
|
|
1485
|
+
},
|
|
1486
|
+
});
|
|
1260
1487
|
for (const tgt of targets) {
|
|
1261
1488
|
for (const table of tgt.tables) {
|
|
1262
1489
|
const { singularName } = (0, utils_1.getTableNames)(table);
|
|
@@ -1451,12 +1678,40 @@ function generateMultiTargetSkills(input) {
|
|
|
1451
1678
|
],
|
|
1452
1679
|
}),
|
|
1453
1680
|
});
|
|
1681
|
+
// Config reference
|
|
1682
|
+
commonReferenceNames.push('config');
|
|
1683
|
+
files.push({
|
|
1684
|
+
fileName: `${commonSkillName}/references/config.md`,
|
|
1685
|
+
content: (0, docs_utils_1.buildSkillReference)({
|
|
1686
|
+
title: 'Config Variables',
|
|
1687
|
+
description: `Manage per-context key-value configuration variables for ${toolName}`,
|
|
1688
|
+
usage: [
|
|
1689
|
+
`${toolName} ${builtinNames.config} get <key>`,
|
|
1690
|
+
`${toolName} ${builtinNames.config} set <key> <value>`,
|
|
1691
|
+
`${toolName} ${builtinNames.config} list`,
|
|
1692
|
+
`${toolName} ${builtinNames.config} delete <key>`,
|
|
1693
|
+
],
|
|
1694
|
+
examples: [
|
|
1695
|
+
{
|
|
1696
|
+
description: 'Store and retrieve a config variable',
|
|
1697
|
+
code: [
|
|
1698
|
+
`${toolName} ${builtinNames.config} set orgId abc-123`,
|
|
1699
|
+
`${toolName} ${builtinNames.config} get orgId`,
|
|
1700
|
+
],
|
|
1701
|
+
},
|
|
1702
|
+
{
|
|
1703
|
+
description: 'List all config variables',
|
|
1704
|
+
code: [`${toolName} ${builtinNames.config} list`],
|
|
1705
|
+
},
|
|
1706
|
+
],
|
|
1707
|
+
}),
|
|
1708
|
+
});
|
|
1454
1709
|
// Common SKILL.md
|
|
1455
1710
|
files.push({
|
|
1456
1711
|
fileName: `${commonSkillName}/SKILL.md`,
|
|
1457
1712
|
content: (0, docs_utils_1.buildSkillFile)({
|
|
1458
1713
|
name: commonSkillName,
|
|
1459
|
-
description: `Shared CLI utilities for ${toolName} — context management and
|
|
1714
|
+
description: `Shared CLI utilities for ${toolName} — context management, authentication, and config across targets: ${targets.map((t) => t.name).join(', ')}`,
|
|
1460
1715
|
usage: [
|
|
1461
1716
|
`# Context management`,
|
|
1462
1717
|
`${toolName} ${builtinNames.context} create <name>`,
|
|
@@ -1465,6 +1720,11 @@ function generateMultiTargetSkills(input) {
|
|
|
1465
1720
|
`# Authentication`,
|
|
1466
1721
|
`${toolName} ${builtinNames.auth} set-token <token>`,
|
|
1467
1722
|
`${toolName} ${builtinNames.auth} status`,
|
|
1723
|
+
'',
|
|
1724
|
+
`# Config variables`,
|
|
1725
|
+
`${toolName} ${builtinNames.config} set <key> <value>`,
|
|
1726
|
+
`${toolName} ${builtinNames.config} get <key>`,
|
|
1727
|
+
`${toolName} ${builtinNames.config} list`,
|
|
1468
1728
|
],
|
|
1469
1729
|
examples: [
|
|
1470
1730
|
{
|
|
@@ -1475,6 +1735,12 @@ function generateMultiTargetSkills(input) {
|
|
|
1475
1735
|
`${toolName} ${builtinNames.auth} set-token <token>`,
|
|
1476
1736
|
],
|
|
1477
1737
|
},
|
|
1738
|
+
{
|
|
1739
|
+
description: 'Store a config variable',
|
|
1740
|
+
code: [
|
|
1741
|
+
`${toolName} ${builtinNames.config} set orgId abc-123`,
|
|
1742
|
+
],
|
|
1743
|
+
},
|
|
1478
1744
|
],
|
|
1479
1745
|
}, commonReferenceNames),
|
|
1480
1746
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GeneratedFile } from './executor-generator';
|
|
2
|
+
export interface HelpersGeneratorInput {
|
|
3
|
+
name: string;
|
|
4
|
+
ormImportPath: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Generate helpers.ts with typed per-target client factories.
|
|
8
|
+
*
|
|
9
|
+
* Each target gets a `createXxxClient(contextName?)` function that uses
|
|
10
|
+
* `store.getClientConfig(targetName, contextName)` under the hood with
|
|
11
|
+
* 3-tier resolution: appstash store -> env vars -> throw.
|
|
12
|
+
*
|
|
13
|
+
* Also re-exports the store for direct config/var access.
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateHelpersFile(toolName: string, targets: HelpersGeneratorInput[]): GeneratedFile;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.generateHelpersFile = generateHelpersFile;
|
|
37
|
+
const t = __importStar(require("@babel/types"));
|
|
38
|
+
const babel_ast_1 = require("../babel-ast");
|
|
39
|
+
const utils_1 = require("../utils");
|
|
40
|
+
function createImportDeclaration(moduleSpecifier, namedImports, typeOnly = false) {
|
|
41
|
+
const specifiers = namedImports.map((name) => t.importSpecifier(t.identifier(name), t.identifier(name)));
|
|
42
|
+
const decl = t.importDeclaration(specifiers, t.stringLiteral(moduleSpecifier));
|
|
43
|
+
decl.importKind = typeOnly ? 'type' : 'value';
|
|
44
|
+
return decl;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generate helpers.ts with typed per-target client factories.
|
|
48
|
+
*
|
|
49
|
+
* Each target gets a `createXxxClient(contextName?)` function that uses
|
|
50
|
+
* `store.getClientConfig(targetName, contextName)` under the hood with
|
|
51
|
+
* 3-tier resolution: appstash store -> env vars -> throw.
|
|
52
|
+
*
|
|
53
|
+
* Also re-exports the store for direct config/var access.
|
|
54
|
+
*/
|
|
55
|
+
function generateHelpersFile(toolName, targets) {
|
|
56
|
+
const statements = [];
|
|
57
|
+
// import { createConfigStore } from 'appstash';
|
|
58
|
+
statements.push(createImportDeclaration('appstash', ['createConfigStore']));
|
|
59
|
+
// import type { ClientConfig } from 'appstash';
|
|
60
|
+
statements.push(createImportDeclaration('appstash', ['ClientConfig'], true));
|
|
61
|
+
// Import createClient from each target's ORM
|
|
62
|
+
for (const target of targets) {
|
|
63
|
+
const aliasName = `create${target.name[0].toUpperCase()}${target.name.slice(1)}OrmClient`;
|
|
64
|
+
const specifier = t.importSpecifier(t.identifier(aliasName), t.identifier('createClient'));
|
|
65
|
+
statements.push(t.importDeclaration([specifier], t.stringLiteral(target.ormImportPath)));
|
|
66
|
+
}
|
|
67
|
+
// const store = createConfigStore('toolName');
|
|
68
|
+
statements.push(t.variableDeclaration('const', [
|
|
69
|
+
t.variableDeclarator(t.identifier('store'), t.callExpression(t.identifier('createConfigStore'), [
|
|
70
|
+
t.stringLiteral(toolName),
|
|
71
|
+
])),
|
|
72
|
+
]));
|
|
73
|
+
// export const getStore = () => store;
|
|
74
|
+
const getStoreExport = t.variableDeclaration('const', [
|
|
75
|
+
t.variableDeclarator(t.identifier('getStore'), t.arrowFunctionExpression([], t.identifier('store'))),
|
|
76
|
+
]);
|
|
77
|
+
statements.push(t.exportNamedDeclaration(getStoreExport));
|
|
78
|
+
// export function getClientConfig(targetName: string, contextName?: string): ClientConfig
|
|
79
|
+
const targetNameParam = t.identifier('targetName');
|
|
80
|
+
targetNameParam.typeAnnotation = t.tsTypeAnnotation(t.tsStringKeyword());
|
|
81
|
+
const contextNameParam = t.identifier('contextName');
|
|
82
|
+
contextNameParam.optional = true;
|
|
83
|
+
contextNameParam.typeAnnotation = t.tsTypeAnnotation(t.tsStringKeyword());
|
|
84
|
+
const getClientConfigBody = t.blockStatement([
|
|
85
|
+
t.returnStatement(t.callExpression(t.memberExpression(t.identifier('store'), t.identifier('getClientConfig')), [t.identifier('targetName'), t.identifier('contextName')])),
|
|
86
|
+
]);
|
|
87
|
+
const getClientConfigFunc = t.functionDeclaration(t.identifier('getClientConfig'), [targetNameParam, contextNameParam], getClientConfigBody);
|
|
88
|
+
// Add return type annotation
|
|
89
|
+
const returnTypeAnnotation = t.tsTypeAnnotation(t.tsTypeReference(t.identifier('ClientConfig')));
|
|
90
|
+
getClientConfigFunc.returnType = returnTypeAnnotation;
|
|
91
|
+
statements.push(t.exportNamedDeclaration(getClientConfigFunc));
|
|
92
|
+
// Generate typed factory for each target
|
|
93
|
+
for (const target of targets) {
|
|
94
|
+
const factoryName = `create${target.name[0].toUpperCase()}${target.name.slice(1)}Client`;
|
|
95
|
+
const ormAliasName = `create${target.name[0].toUpperCase()}${target.name.slice(1)}OrmClient`;
|
|
96
|
+
const ctxParam = t.identifier('contextName');
|
|
97
|
+
ctxParam.optional = true;
|
|
98
|
+
ctxParam.typeAnnotation = t.tsTypeAnnotation(t.tsStringKeyword());
|
|
99
|
+
const factoryBody = t.blockStatement([
|
|
100
|
+
t.variableDeclaration('const', [
|
|
101
|
+
t.variableDeclarator(t.identifier('config'), t.callExpression(t.memberExpression(t.identifier('store'), t.identifier('getClientConfig')), [t.stringLiteral(target.name), t.identifier('contextName')])),
|
|
102
|
+
]),
|
|
103
|
+
t.returnStatement(t.callExpression(t.identifier(ormAliasName), [
|
|
104
|
+
t.objectExpression([
|
|
105
|
+
t.objectProperty(t.identifier('endpoint'), t.memberExpression(t.identifier('config'), t.identifier('endpoint'))),
|
|
106
|
+
t.objectProperty(t.identifier('headers'), t.memberExpression(t.identifier('config'), t.identifier('headers'))),
|
|
107
|
+
]),
|
|
108
|
+
])),
|
|
109
|
+
]);
|
|
110
|
+
const factoryFunc = t.functionDeclaration(t.identifier(factoryName), [ctxParam], factoryBody);
|
|
111
|
+
statements.push(t.exportNamedDeclaration(factoryFunc));
|
|
112
|
+
}
|
|
113
|
+
const header = (0, utils_1.getGeneratedFileHeader)('SDK helpers — typed per-target client factories with 3-tier credential resolution');
|
|
114
|
+
const code = (0, babel_ast_1.generateCode)(statements);
|
|
115
|
+
return {
|
|
116
|
+
fileName: 'helpers.ts',
|
|
117
|
+
content: header + '\n' + code,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
@@ -47,12 +47,16 @@ export interface GenerateMultiTargetCliOptions {
|
|
|
47
47
|
export declare function resolveBuiltinNames(targetNames: string[], userOverrides?: BuiltinNames): {
|
|
48
48
|
auth: string;
|
|
49
49
|
context: string;
|
|
50
|
+
config: string;
|
|
50
51
|
};
|
|
51
52
|
export declare function generateMultiTargetCli(options: GenerateMultiTargetCliOptions): GenerateCliResult;
|
|
52
53
|
export { generateExecutorFile, generateMultiTargetExecutorFile } from './executor-generator';
|
|
53
54
|
export { generateTableCommand } from './table-command-generator';
|
|
54
55
|
export { generateCustomCommand } from './custom-command-generator';
|
|
55
56
|
export { generateCommandMap, generateMultiTargetCommandMap } from './command-map-generator';
|
|
57
|
+
export { generateConfigCommand } from './config-command-generator';
|
|
58
|
+
export { generateHelpersFile } from './helpers-generator';
|
|
59
|
+
export type { HelpersGeneratorInput } from './helpers-generator';
|
|
56
60
|
export { generateContextCommand, generateAuthCommand, generateMultiTargetContextCommand, generateAuthCommandWithName, } from './infra-generator';
|
|
57
61
|
export { generateReadme, generateAgentsDocs, getCliMcpTools, generateSkills, generateMultiTargetReadme, generateMultiTargetAgentsDocs, getMultiTargetCliMcpTools, generateMultiTargetSkills, } from './docs-generator';
|
|
58
62
|
export type { MultiTargetDocsInput } from './docs-generator';
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateEntryPointFile = exports.generateUtilsFile = exports.resolveDocsConfig = exports.generateMultiTargetSkills = exports.getMultiTargetCliMcpTools = exports.generateMultiTargetAgentsDocs = exports.generateMultiTargetReadme = exports.generateSkills = exports.getCliMcpTools = exports.generateAgentsDocs = exports.generateReadme = exports.generateAuthCommandWithName = exports.generateMultiTargetContextCommand = exports.generateAuthCommand = exports.generateContextCommand = exports.generateMultiTargetCommandMap = exports.generateCommandMap = exports.generateCustomCommand = exports.generateTableCommand = exports.generateMultiTargetExecutorFile = exports.generateExecutorFile = void 0;
|
|
3
|
+
exports.generateEntryPointFile = exports.generateUtilsFile = exports.resolveDocsConfig = exports.generateMultiTargetSkills = exports.getMultiTargetCliMcpTools = exports.generateMultiTargetAgentsDocs = exports.generateMultiTargetReadme = exports.generateSkills = exports.getCliMcpTools = exports.generateAgentsDocs = exports.generateReadme = exports.generateAuthCommandWithName = exports.generateMultiTargetContextCommand = exports.generateAuthCommand = exports.generateContextCommand = exports.generateHelpersFile = exports.generateConfigCommand = exports.generateMultiTargetCommandMap = exports.generateCommandMap = exports.generateCustomCommand = exports.generateTableCommand = exports.generateMultiTargetExecutorFile = exports.generateExecutorFile = void 0;
|
|
4
4
|
exports.generateCli = generateCli;
|
|
5
5
|
exports.resolveBuiltinNames = resolveBuiltinNames;
|
|
6
6
|
exports.generateMultiTargetCli = generateMultiTargetCli;
|
|
7
7
|
const command_map_generator_1 = require("./command-map-generator");
|
|
8
|
+
const config_command_generator_1 = require("./config-command-generator");
|
|
8
9
|
const custom_command_generator_1 = require("./custom-command-generator");
|
|
9
10
|
const executor_generator_1 = require("./executor-generator");
|
|
11
|
+
const helpers_generator_1 = require("./helpers-generator");
|
|
10
12
|
const infra_generator_1 = require("./infra-generator");
|
|
11
13
|
const table_command_generator_1 = require("./table-command-generator");
|
|
12
14
|
const utils_generator_1 = require("./utils-generator");
|
|
@@ -68,13 +70,17 @@ function generateCli(options) {
|
|
|
68
70
|
function resolveBuiltinNames(targetNames, userOverrides) {
|
|
69
71
|
let authName = userOverrides?.auth ?? 'auth';
|
|
70
72
|
let contextName = userOverrides?.context ?? 'context';
|
|
73
|
+
let configName = userOverrides?.config ?? 'config';
|
|
71
74
|
if (targetNames.includes(authName) && !userOverrides?.auth) {
|
|
72
75
|
authName = 'credentials';
|
|
73
76
|
}
|
|
74
77
|
if (targetNames.includes(contextName) && !userOverrides?.context) {
|
|
75
78
|
contextName = 'env';
|
|
76
79
|
}
|
|
77
|
-
|
|
80
|
+
if (targetNames.includes(configName) && !userOverrides?.config) {
|
|
81
|
+
configName = 'vars';
|
|
82
|
+
}
|
|
83
|
+
return { auth: authName, context: contextName, config: configName };
|
|
78
84
|
}
|
|
79
85
|
function generateMultiTargetCli(options) {
|
|
80
86
|
const { toolName, targets } = options;
|
|
@@ -100,6 +106,14 @@ function generateMultiTargetCli(options) {
|
|
|
100
106
|
files.push(contextFile);
|
|
101
107
|
const authFile = (0, infra_generator_1.generateAuthCommandWithName)(toolName, builtinNames.auth);
|
|
102
108
|
files.push(authFile);
|
|
109
|
+
const configFile = (0, config_command_generator_1.generateConfigCommand)(toolName, builtinNames.config);
|
|
110
|
+
files.push(configFile);
|
|
111
|
+
const helpersInputs = targets.map((t) => ({
|
|
112
|
+
name: t.name,
|
|
113
|
+
ormImportPath: t.ormImportPath,
|
|
114
|
+
}));
|
|
115
|
+
const helpersFile = (0, helpers_generator_1.generateHelpersFile)(toolName, helpersInputs);
|
|
116
|
+
files.push(helpersFile);
|
|
103
117
|
let totalTables = 0;
|
|
104
118
|
let totalQueries = 0;
|
|
105
119
|
let totalMutations = 0;
|
|
@@ -151,7 +165,7 @@ function generateMultiTargetCli(options) {
|
|
|
151
165
|
tables: totalTables,
|
|
152
166
|
customQueries: totalQueries,
|
|
153
167
|
customMutations: totalMutations,
|
|
154
|
-
infraFiles:
|
|
168
|
+
infraFiles: 6,
|
|
155
169
|
totalFiles: files.length,
|
|
156
170
|
},
|
|
157
171
|
};
|
|
@@ -166,6 +180,10 @@ Object.defineProperty(exports, "generateCustomCommand", { enumerable: true, get:
|
|
|
166
180
|
var command_map_generator_2 = require("./command-map-generator");
|
|
167
181
|
Object.defineProperty(exports, "generateCommandMap", { enumerable: true, get: function () { return command_map_generator_2.generateCommandMap; } });
|
|
168
182
|
Object.defineProperty(exports, "generateMultiTargetCommandMap", { enumerable: true, get: function () { return command_map_generator_2.generateMultiTargetCommandMap; } });
|
|
183
|
+
var config_command_generator_2 = require("./config-command-generator");
|
|
184
|
+
Object.defineProperty(exports, "generateConfigCommand", { enumerable: true, get: function () { return config_command_generator_2.generateConfigCommand; } });
|
|
185
|
+
var helpers_generator_2 = require("./helpers-generator");
|
|
186
|
+
Object.defineProperty(exports, "generateHelpersFile", { enumerable: true, get: function () { return helpers_generator_2.generateHelpersFile; } });
|
|
169
187
|
var infra_generator_2 = require("./infra-generator");
|
|
170
188
|
Object.defineProperty(exports, "generateContextCommand", { enumerable: true, get: function () { return infra_generator_2.generateContextCommand; } });
|
|
171
189
|
Object.defineProperty(exports, "generateAuthCommand", { enumerable: true, get: function () { return infra_generator_2.generateAuthCommand; } });
|
|
@@ -13,6 +13,7 @@ const model_generator_1 = require("./model-generator");
|
|
|
13
13
|
function generateOrm(options) {
|
|
14
14
|
const { tables, customOperations, sharedTypesPath } = options;
|
|
15
15
|
const commentsEnabled = options.config.codegen?.comments !== false;
|
|
16
|
+
const conditionEnabled = options.config.codegen?.condition !== false;
|
|
16
17
|
const files = [];
|
|
17
18
|
// Use shared types when a sharedTypesPath is provided (unified output mode)
|
|
18
19
|
const useSharedTypes = !!sharedTypesPath;
|
|
@@ -33,7 +34,7 @@ function generateOrm(options) {
|
|
|
33
34
|
content: selectTypesFile.content,
|
|
34
35
|
});
|
|
35
36
|
// 2. Generate model files
|
|
36
|
-
const modelFiles = (0, model_generator_1.generateAllModelFiles)(tables, useSharedTypes);
|
|
37
|
+
const modelFiles = (0, model_generator_1.generateAllModelFiles)(tables, useSharedTypes, { condition: conditionEnabled });
|
|
37
38
|
for (const modelFile of modelFiles) {
|
|
38
39
|
files.push({
|
|
39
40
|
path: `models/${modelFile.fileName}`,
|
|
@@ -70,7 +71,7 @@ function generateOrm(options) {
|
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
|
-
const inputTypesFile = (0, input_types_generator_1.generateInputTypesFile)(typeRegistry ?? new Map(), usedInputTypes, tables, usedPayloadTypes, commentsEnabled);
|
|
74
|
+
const inputTypesFile = (0, input_types_generator_1.generateInputTypesFile)(typeRegistry ?? new Map(), usedInputTypes, tables, usedPayloadTypes, commentsEnabled, { condition: conditionEnabled });
|
|
74
75
|
files.push({
|
|
75
76
|
path: inputTypesFile.fileName,
|
|
76
77
|
content: inputTypesFile.content,
|
|
@@ -18,4 +18,6 @@ export declare function collectPayloadTypeNames(operations: Array<{
|
|
|
18
18
|
/**
|
|
19
19
|
* Generate comprehensive input-types.ts file using Babel AST
|
|
20
20
|
*/
|
|
21
|
-
export declare function generateInputTypesFile(typeRegistry: TypeRegistry, usedInputTypes: Set<string>, tables?: CleanTable[], usedPayloadTypes?: Set<string>, comments?: boolean
|
|
21
|
+
export declare function generateInputTypesFile(typeRegistry: TypeRegistry, usedInputTypes: Set<string>, tables?: CleanTable[], usedPayloadTypes?: Set<string>, comments?: boolean, options?: {
|
|
22
|
+
condition?: boolean;
|
|
23
|
+
}): GeneratedInputTypesFile;
|