@constructive-io/graphql-codegen 5.14.2 → 5.15.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.
@@ -7,5 +7,5 @@ export interface MultiTargetExecutorInput {
7
7
  endpoint: string;
8
8
  ormImportPath: string;
9
9
  }
10
- export declare function generateExecutorFile(toolName: string): GeneratedFile;
11
- export declare function generateMultiTargetExecutorFile(toolName: string, targets: MultiTargetExecutorInput[]): GeneratedFile;
10
+ export declare function generateExecutorFile(toolName: string, stashName?: string): GeneratedFile;
11
+ export declare function generateMultiTargetExecutorFile(toolName: string, targets: MultiTargetExecutorInput[], stashName?: string): GeneratedFile;
@@ -44,14 +44,25 @@ function createImportDeclaration(moduleSpecifier, namedImports, typeOnly = false
44
44
  decl.importKind = typeOnly ? 'type' : 'value';
45
45
  return decl;
46
46
  }
47
- function generateExecutorFile(toolName) {
47
+ /**
48
+ * `createConfigStore(toolName)`, or `createConfigStore(toolName, { stashName })`
49
+ * when the CLI shares its signed-in state with other tools of the same product.
50
+ */
51
+ function createStoreCall(toolName, stashName) {
52
+ const args = [t.stringLiteral(toolName)];
53
+ if (stashName) {
54
+ args.push(t.objectExpression([
55
+ t.objectProperty(t.identifier('stashName'), t.stringLiteral(stashName)),
56
+ ]));
57
+ }
58
+ return t.callExpression(t.identifier('createConfigStore'), args);
59
+ }
60
+ function generateExecutorFile(toolName, stashName) {
48
61
  const statements = [];
49
62
  statements.push(createImportDeclaration('appstash', ['createConfigStore']));
50
63
  statements.push(createImportDeclaration('../orm', ['createClient']));
51
64
  statements.push(t.variableDeclaration('const', [
52
- t.variableDeclarator(t.identifier('store'), t.callExpression(t.identifier('createConfigStore'), [
53
- t.stringLiteral(toolName),
54
- ])),
65
+ t.variableDeclarator(t.identifier('store'), createStoreCall(toolName, stashName)),
55
66
  ]));
56
67
  const getStoreExport = t.variableDeclaration('const', [
57
68
  t.variableDeclarator(t.identifier('getStore'), t.arrowFunctionExpression([], t.identifier('store'))),
@@ -121,7 +132,7 @@ function generateExecutorFile(toolName) {
121
132
  content: header + '\n' + code,
122
133
  };
123
134
  }
124
- function generateMultiTargetExecutorFile(toolName, targets) {
135
+ function generateMultiTargetExecutorFile(toolName, targets, stashName) {
125
136
  const statements = [];
126
137
  statements.push(createImportDeclaration('appstash', ['createConfigStore']));
127
138
  for (const target of targets) {
@@ -130,9 +141,7 @@ function generateMultiTargetExecutorFile(toolName, targets) {
130
141
  statements.push(t.importDeclaration([specifier], t.stringLiteral(target.ormImportPath)));
131
142
  }
132
143
  statements.push(t.variableDeclaration('const', [
133
- t.variableDeclarator(t.identifier('store'), t.callExpression(t.identifier('createConfigStore'), [
134
- t.stringLiteral(toolName),
135
- ])),
144
+ t.variableDeclarator(t.identifier('store'), createStoreCall(toolName, stashName)),
136
145
  ]));
137
146
  const getStoreExport = t.variableDeclaration('const', [
138
147
  t.variableDeclarator(t.identifier('getStore'), t.arrowFunctionExpression([], t.identifier('store'))),
@@ -12,4 +12,4 @@ export interface HelpersGeneratorInput {
12
12
  *
13
13
  * Also re-exports the store for direct config/var access.
14
14
  */
15
- export declare function generateHelpersFile(toolName: string, targets: HelpersGeneratorInput[]): GeneratedFile;
15
+ export declare function generateHelpersFile(toolName: string, targets: HelpersGeneratorInput[], stashName?: string): GeneratedFile;
@@ -52,7 +52,7 @@ function createImportDeclaration(moduleSpecifier, namedImports, typeOnly = false
52
52
  *
53
53
  * Also re-exports the store for direct config/var access.
54
54
  */
55
- function generateHelpersFile(toolName, targets) {
55
+ function generateHelpersFile(toolName, targets, stashName) {
56
56
  const statements = [];
57
57
  // import { createConfigStore } from 'appstash';
58
58
  statements.push(createImportDeclaration('appstash', ['createConfigStore']));
@@ -64,11 +64,15 @@ function generateHelpersFile(toolName, targets) {
64
64
  const specifier = t.importSpecifier(t.identifier(aliasName), t.identifier('createClient'));
65
65
  statements.push(t.importDeclaration([specifier], t.stringLiteral(target.ormImportPath)));
66
66
  }
67
- // const store = createConfigStore('toolName');
67
+ // const store = createConfigStore('toolName', { stashName: 'product' });
68
+ const storeArgs = [t.stringLiteral(toolName)];
69
+ if (stashName) {
70
+ storeArgs.push(t.objectExpression([
71
+ t.objectProperty(t.identifier('stashName'), t.stringLiteral(stashName)),
72
+ ]));
73
+ }
68
74
  statements.push(t.variableDeclaration('const', [
69
- t.variableDeclarator(t.identifier('store'), t.callExpression(t.identifier('createConfigStore'), [
70
- t.stringLiteral(toolName),
71
- ])),
75
+ t.variableDeclarator(t.identifier('store'), t.callExpression(t.identifier('createConfigStore'), storeArgs)),
72
76
  ]));
73
77
  // export const getStore = () => store;
74
78
  const getStoreExport = t.variableDeclaration('const', [
@@ -37,6 +37,8 @@ export interface MultiTargetCliTarget {
37
37
  }
38
38
  export interface GenerateMultiTargetCliOptions {
39
39
  toolName: string;
40
+ /** Directory identity to share signed-in state with sibling tools. */
41
+ stashName?: string;
40
42
  builtinNames?: BuiltinNames;
41
43
  targets: MultiTargetCliTarget[];
42
44
  /** Generate a runnable index.ts entry point */
@@ -19,7 +19,8 @@ function generateCli(options) {
19
19
  const toolName = typeof cliConfig === 'object' && cliConfig.toolName
20
20
  ? cliConfig.toolName
21
21
  : 'app';
22
- const executorFile = (0, executor_generator_1.generateExecutorFile)(toolName);
22
+ const stashName = typeof cliConfig === 'object' ? cliConfig.stashName : undefined;
23
+ const executorFile = (0, executor_generator_1.generateExecutorFile)(toolName, stashName);
23
24
  files.push(executorFile);
24
25
  const utilsFile = (0, utils_generator_1.generateUtilsFile)();
25
26
  files.push(utilsFile);
@@ -80,7 +81,7 @@ function resolveBuiltinNames(targetNames, userOverrides) {
80
81
  return { auth: authName, context: contextName, config: configName };
81
82
  }
82
83
  function generateMultiTargetCli(options) {
83
- const { toolName, targets } = options;
84
+ const { toolName, stashName, targets } = options;
84
85
  const files = [];
85
86
  const targetNames = targets.map((t) => t.name);
86
87
  const builtinNames = resolveBuiltinNames(targetNames, options.builtinNames);
@@ -89,7 +90,7 @@ function generateMultiTargetCli(options) {
89
90
  endpoint: t.endpoint,
90
91
  ormImportPath: t.ormImportPath,
91
92
  }));
92
- const executorFile = (0, executor_generator_1.generateMultiTargetExecutorFile)(toolName, executorInputs);
93
+ const executorFile = (0, executor_generator_1.generateMultiTargetExecutorFile)(toolName, executorInputs, stashName);
93
94
  files.push(executorFile);
94
95
  const utilsFile = (0, utils_generator_1.generateUtilsFile)();
95
96
  files.push(utilsFile);
@@ -108,7 +109,7 @@ function generateMultiTargetCli(options) {
108
109
  name: t.name,
109
110
  ormImportPath: t.ormImportPath,
110
111
  }));
111
- const helpersFile = (0, helpers_generator_1.generateHelpersFile)(toolName, helpersInputs);
112
+ const helpersFile = (0, helpers_generator_1.generateHelpersFile)(toolName, helpersInputs, stashName);
112
113
  files.push(helpersFile);
113
114
  let totalTables = 0;
114
115
  let totalQueries = 0;
package/core/generate.js CHANGED
@@ -618,6 +618,7 @@ async function generateMulti(options) {
618
618
  const firstTargetConfig = configs[names[0]];
619
619
  const { files } = (0, cli_1.generateMultiTargetCli)({
620
620
  toolName,
621
+ stashName: cliConfig.stashName,
621
622
  builtinNames: cliConfig.builtinNames,
622
623
  targets: cliTargets,
623
624
  entryPoint: cliConfig.entryPoint,
@@ -7,5 +7,5 @@ export interface MultiTargetExecutorInput {
7
7
  endpoint: string;
8
8
  ormImportPath: string;
9
9
  }
10
- export declare function generateExecutorFile(toolName: string): GeneratedFile;
11
- export declare function generateMultiTargetExecutorFile(toolName: string, targets: MultiTargetExecutorInput[]): GeneratedFile;
10
+ export declare function generateExecutorFile(toolName: string, stashName?: string): GeneratedFile;
11
+ export declare function generateMultiTargetExecutorFile(toolName: string, targets: MultiTargetExecutorInput[], stashName?: string): GeneratedFile;
@@ -7,14 +7,25 @@ function createImportDeclaration(moduleSpecifier, namedImports, typeOnly = false
7
7
  decl.importKind = typeOnly ? 'type' : 'value';
8
8
  return decl;
9
9
  }
10
- export function generateExecutorFile(toolName) {
10
+ /**
11
+ * `createConfigStore(toolName)`, or `createConfigStore(toolName, { stashName })`
12
+ * when the CLI shares its signed-in state with other tools of the same product.
13
+ */
14
+ function createStoreCall(toolName, stashName) {
15
+ const args = [t.stringLiteral(toolName)];
16
+ if (stashName) {
17
+ args.push(t.objectExpression([
18
+ t.objectProperty(t.identifier('stashName'), t.stringLiteral(stashName)),
19
+ ]));
20
+ }
21
+ return t.callExpression(t.identifier('createConfigStore'), args);
22
+ }
23
+ export function generateExecutorFile(toolName, stashName) {
11
24
  const statements = [];
12
25
  statements.push(createImportDeclaration('appstash', ['createConfigStore']));
13
26
  statements.push(createImportDeclaration('../orm', ['createClient']));
14
27
  statements.push(t.variableDeclaration('const', [
15
- t.variableDeclarator(t.identifier('store'), t.callExpression(t.identifier('createConfigStore'), [
16
- t.stringLiteral(toolName),
17
- ])),
28
+ t.variableDeclarator(t.identifier('store'), createStoreCall(toolName, stashName)),
18
29
  ]));
19
30
  const getStoreExport = t.variableDeclaration('const', [
20
31
  t.variableDeclarator(t.identifier('getStore'), t.arrowFunctionExpression([], t.identifier('store'))),
@@ -84,7 +95,7 @@ export function generateExecutorFile(toolName) {
84
95
  content: header + '\n' + code,
85
96
  };
86
97
  }
87
- export function generateMultiTargetExecutorFile(toolName, targets) {
98
+ export function generateMultiTargetExecutorFile(toolName, targets, stashName) {
88
99
  const statements = [];
89
100
  statements.push(createImportDeclaration('appstash', ['createConfigStore']));
90
101
  for (const target of targets) {
@@ -93,9 +104,7 @@ export function generateMultiTargetExecutorFile(toolName, targets) {
93
104
  statements.push(t.importDeclaration([specifier], t.stringLiteral(target.ormImportPath)));
94
105
  }
95
106
  statements.push(t.variableDeclaration('const', [
96
- t.variableDeclarator(t.identifier('store'), t.callExpression(t.identifier('createConfigStore'), [
97
- t.stringLiteral(toolName),
98
- ])),
107
+ t.variableDeclarator(t.identifier('store'), createStoreCall(toolName, stashName)),
99
108
  ]));
100
109
  const getStoreExport = t.variableDeclaration('const', [
101
110
  t.variableDeclarator(t.identifier('getStore'), t.arrowFunctionExpression([], t.identifier('store'))),
@@ -12,4 +12,4 @@ export interface HelpersGeneratorInput {
12
12
  *
13
13
  * Also re-exports the store for direct config/var access.
14
14
  */
15
- export declare function generateHelpersFile(toolName: string, targets: HelpersGeneratorInput[]): GeneratedFile;
15
+ export declare function generateHelpersFile(toolName: string, targets: HelpersGeneratorInput[], stashName?: string): GeneratedFile;
@@ -16,7 +16,7 @@ function createImportDeclaration(moduleSpecifier, namedImports, typeOnly = false
16
16
  *
17
17
  * Also re-exports the store for direct config/var access.
18
18
  */
19
- export function generateHelpersFile(toolName, targets) {
19
+ export function generateHelpersFile(toolName, targets, stashName) {
20
20
  const statements = [];
21
21
  // import { createConfigStore } from 'appstash';
22
22
  statements.push(createImportDeclaration('appstash', ['createConfigStore']));
@@ -28,11 +28,15 @@ export function generateHelpersFile(toolName, targets) {
28
28
  const specifier = t.importSpecifier(t.identifier(aliasName), t.identifier('createClient'));
29
29
  statements.push(t.importDeclaration([specifier], t.stringLiteral(target.ormImportPath)));
30
30
  }
31
- // const store = createConfigStore('toolName');
31
+ // const store = createConfigStore('toolName', { stashName: 'product' });
32
+ const storeArgs = [t.stringLiteral(toolName)];
33
+ if (stashName) {
34
+ storeArgs.push(t.objectExpression([
35
+ t.objectProperty(t.identifier('stashName'), t.stringLiteral(stashName)),
36
+ ]));
37
+ }
32
38
  statements.push(t.variableDeclaration('const', [
33
- t.variableDeclarator(t.identifier('store'), t.callExpression(t.identifier('createConfigStore'), [
34
- t.stringLiteral(toolName),
35
- ])),
39
+ t.variableDeclarator(t.identifier('store'), t.callExpression(t.identifier('createConfigStore'), storeArgs)),
36
40
  ]));
37
41
  // export const getStore = () => store;
38
42
  const getStoreExport = t.variableDeclaration('const', [
@@ -37,6 +37,8 @@ export interface MultiTargetCliTarget {
37
37
  }
38
38
  export interface GenerateMultiTargetCliOptions {
39
39
  toolName: string;
40
+ /** Directory identity to share signed-in state with sibling tools. */
41
+ stashName?: string;
40
42
  builtinNames?: BuiltinNames;
41
43
  targets: MultiTargetCliTarget[];
42
44
  /** Generate a runnable index.ts entry point */
@@ -13,7 +13,8 @@ export function generateCli(options) {
13
13
  const toolName = typeof cliConfig === 'object' && cliConfig.toolName
14
14
  ? cliConfig.toolName
15
15
  : 'app';
16
- const executorFile = generateExecutorFile(toolName);
16
+ const stashName = typeof cliConfig === 'object' ? cliConfig.stashName : undefined;
17
+ const executorFile = generateExecutorFile(toolName, stashName);
17
18
  files.push(executorFile);
18
19
  const utilsFile = generateUtilsFile();
19
20
  files.push(utilsFile);
@@ -74,7 +75,7 @@ export function resolveBuiltinNames(targetNames, userOverrides) {
74
75
  return { auth: authName, context: contextName, config: configName };
75
76
  }
76
77
  export function generateMultiTargetCli(options) {
77
- const { toolName, targets } = options;
78
+ const { toolName, stashName, targets } = options;
78
79
  const files = [];
79
80
  const targetNames = targets.map((t) => t.name);
80
81
  const builtinNames = resolveBuiltinNames(targetNames, options.builtinNames);
@@ -83,7 +84,7 @@ export function generateMultiTargetCli(options) {
83
84
  endpoint: t.endpoint,
84
85
  ormImportPath: t.ormImportPath,
85
86
  }));
86
- const executorFile = generateMultiTargetExecutorFile(toolName, executorInputs);
87
+ const executorFile = generateMultiTargetExecutorFile(toolName, executorInputs, stashName);
87
88
  files.push(executorFile);
88
89
  const utilsFile = generateUtilsFile();
89
90
  files.push(utilsFile);
@@ -102,7 +103,7 @@ export function generateMultiTargetCli(options) {
102
103
  name: t.name,
103
104
  ormImportPath: t.ormImportPath,
104
105
  }));
105
- const helpersFile = generateHelpersFile(toolName, helpersInputs);
106
+ const helpersFile = generateHelpersFile(toolName, helpersInputs, stashName);
106
107
  files.push(helpersFile);
107
108
  let totalTables = 0;
108
109
  let totalQueries = 0;
@@ -574,6 +574,7 @@ export async function generateMulti(options) {
574
574
  const firstTargetConfig = configs[names[0]];
575
575
  const { files } = generateMultiTargetCli({
576
576
  toolName,
577
+ stashName: cliConfig.stashName,
577
578
  builtinNames: cliConfig.builtinNames,
578
579
  targets: cliTargets,
579
580
  entryPoint: cliConfig.entryPoint,
@@ -180,6 +180,14 @@ export interface CliConfig {
180
180
  * @default derived from output directory name
181
181
  */
182
182
  toolName?: string;
183
+ /**
184
+ * Directory identity for the stored contexts and credentials, when several
185
+ * tools are one product and should share a single signed-in state (e.g. a
186
+ * generated CLI, an agent CLI and a desktop app all using `constructive`).
187
+ * `toolName` still drives env-var prefixes and help text.
188
+ * @default toolName
189
+ */
190
+ stashName?: string;
183
191
  /**
184
192
  * Override infra command names (for collision handling)
185
193
  * Defaults: auth -> 'auth' (renamed to 'credentials' on collision),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/graphql-codegen",
3
- "version": "5.14.2",
3
+ "version": "5.15.1",
4
4
  "description": "GraphQL SDK generator for Constructive databases with React Query hooks",
5
5
  "keywords": [
6
6
  "graphql",
@@ -53,27 +53,27 @@
53
53
  "example:sdk:typecheck": "tsc --noEmit --jsx react --esModuleInterop --skipLibCheck --moduleResolution node examples/react-hooks-sdk-test.tsx"
54
54
  },
55
55
  "dependencies": {
56
- "@0no-co/graphql.web": "^1.1.2",
56
+ "@0no-co/graphql.web": "^1.3.3",
57
57
  "@babel/generator": "^7.29.1",
58
58
  "@babel/types": "^7.29.0",
59
- "@constructive-io/graphql-query": "^4.12.2",
60
- "@constructive-io/graphql-types": "^3.28.1",
61
- "@inquirerer/utils": "^3.3.9",
62
- "@pgpmjs/core": "^7.24.0",
59
+ "@constructive-io/graphql-query": "^4.12.4",
60
+ "@constructive-io/graphql-types": "^3.28.3",
61
+ "@inquirerer/utils": "^3.3.11",
62
+ "@pgpmjs/core": "^7.25.1",
63
63
  "ajv": "^8.20.0",
64
64
  "deepmerge": "^4.3.1",
65
65
  "find-and-require-package-json": "^0.9.1",
66
66
  "gql-ast": "^3.23.0",
67
- "graphile-schema": "^2.11.2",
67
+ "graphile-schema": "^2.11.4",
68
68
  "graphql": "16.13.0",
69
69
  "inflekt": "^0.7.1",
70
- "inquirerer": "^4.9.1",
70
+ "inquirerer": "^4.9.3",
71
71
  "jiti": "^2.7.0",
72
72
  "oxfmt": "^0.51.0",
73
- "pg-cache": "^3.25.1",
74
- "pg-env": "^1.29.0",
75
- "pgsql-client": "^4.10.2",
76
- "pgsql-seed": "^3.10.2",
73
+ "pg-cache": "^3.25.3",
74
+ "pg-env": "^1.29.1",
75
+ "pgsql-client": "^4.10.4",
76
+ "pgsql-seed": "^3.10.4",
77
77
  "query-spec": "^0.11.0",
78
78
  "undici": "^8.3.0"
79
79
  },
@@ -94,12 +94,12 @@
94
94
  "@types/babel__generator": "^7.27.0",
95
95
  "@types/jest": "^30.0.0",
96
96
  "@types/node": "^22.19.11",
97
- "@types/react": "^19.2.15",
97
+ "@types/react": "^19.2.18",
98
98
  "jest": "^30.4.2",
99
- "react": "^19.2.4",
100
- "ts-jest": "^29.4.11",
99
+ "react": "^19.2.8",
100
+ "ts-jest": "^29.4.12",
101
101
  "tsx": "^4.21.0",
102
102
  "typescript": "^5.9.3"
103
103
  },
104
- "gitHead": "c9dcb0c96174dfb0bc6fd63e46cc7776ea7af173"
104
+ "gitHead": "0d9f0718a8c768cc8b7659525953dc762833bd6b"
105
105
  }
package/types/config.d.ts CHANGED
@@ -180,6 +180,14 @@ export interface CliConfig {
180
180
  * @default derived from output directory name
181
181
  */
182
182
  toolName?: string;
183
+ /**
184
+ * Directory identity for the stored contexts and credentials, when several
185
+ * tools are one product and should share a single signed-in state (e.g. a
186
+ * generated CLI, an agent CLI and a desktop app all using `constructive`).
187
+ * `toolName` still drives env-var prefixes and help text.
188
+ * @default toolName
189
+ */
190
+ stashName?: string;
183
191
  /**
184
192
  * Override infra command names (for collision handling)
185
193
  * Defaults: auth -> 'auth' (renamed to 'credentials' on collision),