@constructive-io/graphql-codegen 4.25.0 → 4.27.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.
- package/core/codegen/cli/command-map-generator.js +9 -9
- package/core/codegen/cli/custom-command-generator.js +2 -2
- package/core/codegen/cli/docs-generator.js +23 -31
- package/core/codegen/cli/index.d.ts +3 -1
- package/core/codegen/cli/index.js +16 -1
- package/core/codegen/cli/table-command-generator.d.ts +2 -0
- package/core/codegen/cli/table-command-generator.js +251 -37
- package/core/codegen/cli/utils-generator.d.ts +8 -0
- package/core/codegen/cli/utils-generator.js +14 -0
- package/core/codegen/docs-utils.d.ts +17 -0
- package/core/codegen/docs-utils.js +137 -3
- package/core/codegen/hooks-docs-generator.js +3 -3
- package/core/codegen/index.js +1 -1
- package/core/codegen/orm/docs-generator.js +3 -3
- package/core/codegen/orm/index.js +1 -1
- package/core/codegen/orm/input-types-generator.js +1 -1
- package/core/codegen/orm/model-generator.js +1 -1
- package/core/codegen/queries.js +1 -1
- package/core/codegen/templates/cli-utils.ts +11 -11
- package/core/codegen/templates/embedder.ts +175 -0
- package/core/generate.js +2 -0
- package/esm/core/codegen/cli/command-map-generator.js +1 -1
- package/esm/core/codegen/cli/custom-command-generator.js +1 -1
- package/esm/core/codegen/cli/docs-generator.js +7 -15
- package/esm/core/codegen/cli/index.d.ts +3 -1
- package/esm/core/codegen/cli/index.js +16 -2
- package/esm/core/codegen/cli/table-command-generator.d.ts +2 -0
- package/esm/core/codegen/cli/table-command-generator.js +251 -37
- package/esm/core/codegen/cli/utils-generator.d.ts +8 -0
- package/esm/core/codegen/cli/utils-generator.js +13 -0
- package/esm/core/codegen/docs-utils.d.ts +17 -0
- package/esm/core/codegen/docs-utils.js +135 -3
- package/esm/core/codegen/hooks-docs-generator.js +1 -1
- package/esm/core/codegen/index.js +1 -1
- package/esm/core/codegen/orm/docs-generator.js +1 -1
- package/esm/core/codegen/orm/index.js +1 -1
- package/esm/core/codegen/orm/input-types-generator.js +1 -1
- package/esm/core/codegen/orm/model-generator.js +1 -1
- package/esm/core/codegen/queries.js +1 -1
- package/esm/core/generate.js +2 -0
- package/package.json +15 -16
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toKebabCase } from '
|
|
1
|
+
import { toKebabCase } from 'inflekt';
|
|
2
2
|
import { buildSkillFile, buildSkillReference, formatArgType, fieldPlaceholder, pkPlaceholder, argPlaceholder, getEditableFields, categorizeSpecialFields, buildSpecialFieldsMarkdown, getReadmeHeader, getReadmeFooter, } from '../docs-utils';
|
|
3
3
|
import { getScalarFields, getTableNames, getPrimaryKeyInfo, lcFirst, } from '../utils';
|
|
4
4
|
export function generateOrmReadme(tables, customOperations, registry) {
|
|
@@ -9,7 +9,7 @@ import { generateAllModelFiles } from './model-generator';
|
|
|
9
9
|
export function generateOrm(options) {
|
|
10
10
|
const { tables, customOperations, sharedTypesPath } = options;
|
|
11
11
|
const commentsEnabled = options.config.codegen?.comments !== false;
|
|
12
|
-
const conditionEnabled = options.config.codegen?.condition
|
|
12
|
+
const conditionEnabled = options.config.codegen?.condition === true;
|
|
13
13
|
const files = [];
|
|
14
14
|
// Use shared types when a sharedTypesPath is provided (unified output mode)
|
|
15
15
|
const useSharedTypes = !!sharedTypesPath;
|
|
@@ -1382,7 +1382,7 @@ function collectConditionExtraInputTypes(tables, typeRegistry) {
|
|
|
1382
1382
|
* Generate comprehensive input-types.ts file using Babel AST
|
|
1383
1383
|
*/
|
|
1384
1384
|
export function generateInputTypesFile(typeRegistry, usedInputTypes, tables, usedPayloadTypes, comments = true, options) {
|
|
1385
|
-
const conditionEnabled = options?.condition
|
|
1385
|
+
const conditionEnabled = options?.condition === true;
|
|
1386
1386
|
const statements = [];
|
|
1387
1387
|
const tablesList = tables ?? [];
|
|
1388
1388
|
const hasTables = tablesList.length > 0;
|
|
@@ -67,7 +67,7 @@ function strictSelectGuard(selectTypeName) {
|
|
|
67
67
|
]));
|
|
68
68
|
}
|
|
69
69
|
export function generateModelFile(table, _useSharedTypes, options, allTables) {
|
|
70
|
-
const conditionEnabled = options?.condition
|
|
70
|
+
const conditionEnabled = options?.condition === true;
|
|
71
71
|
const { typeName, singularName, pluralName } = getTableNames(table);
|
|
72
72
|
const modelName = `${typeName}Model`;
|
|
73
73
|
const baseFileName = lcFirst(typeName);
|
|
@@ -11,7 +11,7 @@ import { asConst } from './babel-ast';
|
|
|
11
11
|
import { addJSDocComment, buildFindManyCallExpr, buildFindOneCallExpr, buildListSelectionArgsCall, buildSelectionArgsCall, callExpr, createFunctionParam, createImportDeclaration, createSAndTDataTypeParams, createSTypeParam, createTypeReExport, destructureParamsWithSelection, destructureParamsWithSelectionAndScope, exportAsyncDeclareFunction, exportAsyncFunction, exportDeclareFunction, exportFunction, generateHookFileCode, listQueryResultType, listSelectionConfigType, objectProp, omitType, returnUseQuery, scopeTypeLiteral, selectionConfigType, singleQueryResultType, spreadObj, sRef, typeRef, useQueryOptionsImplType, voidStatement, withFieldsListSelectionType, withFieldsSelectionType, } from './hooks-ast';
|
|
12
12
|
import { getAllRowsQueryName, getConditionTypeName, getFilterTypeName, getListQueryFileName, getListQueryHookName, getOrderByTypeName, getPrimaryKeyInfo, getSingleQueryFileName, getSingleQueryHookName, getSingleRowQueryName, getTableNames, hasValidPrimaryKey, lcFirst, ucFirst, } from './utils';
|
|
13
13
|
export function generateListQueryHook(table, options = {}) {
|
|
14
|
-
const { reactQueryEnabled = true, useCentralizedKeys = true, hasRelationships = false, condition: conditionEnabled =
|
|
14
|
+
const { reactQueryEnabled = true, useCentralizedKeys = true, hasRelationships = false, condition: conditionEnabled = false, } = options;
|
|
15
15
|
const { typeName, pluralName, singularName } = getTableNames(table);
|
|
16
16
|
const hookName = getListQueryHookName(table);
|
|
17
17
|
const queryName = getAllRowsQueryName(table);
|
package/esm/core/generate.js
CHANGED
|
@@ -545,12 +545,14 @@ export async function generateMulti(options) {
|
|
|
545
545
|
const firstTargetConfig = configs[names[0]];
|
|
546
546
|
const multiNodeHttpAdapter = firstTargetConfig?.nodeHttpAdapter === true ||
|
|
547
547
|
(firstTargetConfig?.nodeHttpAdapter !== false);
|
|
548
|
+
const multiConditionEnabled = firstTargetConfig?.codegen?.condition === true;
|
|
548
549
|
const { files } = generateMultiTargetCli({
|
|
549
550
|
toolName,
|
|
550
551
|
builtinNames: cliConfig.builtinNames,
|
|
551
552
|
targets: cliTargets,
|
|
552
553
|
nodeHttpAdapter: multiNodeHttpAdapter,
|
|
553
554
|
entryPoint: cliConfig.entryPoint,
|
|
555
|
+
condition: multiConditionEnabled,
|
|
554
556
|
});
|
|
555
557
|
const cliFilesToWrite = files.map((file) => ({
|
|
556
558
|
path: path.posix.join('cli', file.fileName),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-codegen",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.27.0",
|
|
4
4
|
"description": "GraphQL SDK generator for Constructive databases with React Query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -56,26 +56,25 @@
|
|
|
56
56
|
"@0no-co/graphql.web": "^1.1.2",
|
|
57
57
|
"@babel/generator": "^7.29.1",
|
|
58
58
|
"@babel/types": "^7.29.0",
|
|
59
|
-
"@constructive-io/graphql-query": "^3.12.
|
|
60
|
-
"@constructive-io/graphql-types": "^3.4.
|
|
61
|
-
"@inquirerer/utils": "^3.3.
|
|
62
|
-
"@pgpmjs/core": "^6.10.
|
|
59
|
+
"@constructive-io/graphql-query": "^3.12.6",
|
|
60
|
+
"@constructive-io/graphql-types": "^3.4.2",
|
|
61
|
+
"@inquirerer/utils": "^3.3.5",
|
|
62
|
+
"@pgpmjs/core": "^6.10.4",
|
|
63
63
|
"ajv": "^8.18.0",
|
|
64
64
|
"deepmerge": "^4.3.1",
|
|
65
65
|
"find-and-require-package-json": "^0.9.1",
|
|
66
|
-
"gql-ast": "^3.4.
|
|
67
|
-
"graphile-schema": "^1.11.
|
|
66
|
+
"gql-ast": "^3.4.2",
|
|
67
|
+
"graphile-schema": "^1.11.3",
|
|
68
68
|
"graphql": "16.13.0",
|
|
69
|
-
"inflekt": "^0.
|
|
69
|
+
"inflekt": "^0.7.0",
|
|
70
70
|
"inquirerer": "^4.7.0",
|
|
71
71
|
"jiti": "^2.6.1",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"pg-
|
|
75
|
-
"
|
|
76
|
-
"pgsql-
|
|
77
|
-
"
|
|
78
|
-
"undici": "^7.24.3"
|
|
72
|
+
"oxfmt": "^0.42.0",
|
|
73
|
+
"pg-cache": "^3.4.2",
|
|
74
|
+
"pg-env": "^1.8.2",
|
|
75
|
+
"pgsql-client": "^3.7.4",
|
|
76
|
+
"pgsql-seed": "^2.7.4",
|
|
77
|
+
"undici": "^7.24.6"
|
|
79
78
|
},
|
|
80
79
|
"peerDependencies": {
|
|
81
80
|
"@tanstack/react-query": "^5.0.0",
|
|
@@ -101,5 +100,5 @@
|
|
|
101
100
|
"tsx": "^4.21.0",
|
|
102
101
|
"typescript": "^5.9.3"
|
|
103
102
|
},
|
|
104
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "2f6e083d11764a04b2a6bc14df5b2ca2725defc6"
|
|
105
104
|
}
|