@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.
Files changed (41) hide show
  1. package/core/codegen/cli/command-map-generator.js +9 -9
  2. package/core/codegen/cli/custom-command-generator.js +2 -2
  3. package/core/codegen/cli/docs-generator.js +23 -31
  4. package/core/codegen/cli/index.d.ts +3 -1
  5. package/core/codegen/cli/index.js +16 -1
  6. package/core/codegen/cli/table-command-generator.d.ts +2 -0
  7. package/core/codegen/cli/table-command-generator.js +251 -37
  8. package/core/codegen/cli/utils-generator.d.ts +8 -0
  9. package/core/codegen/cli/utils-generator.js +14 -0
  10. package/core/codegen/docs-utils.d.ts +17 -0
  11. package/core/codegen/docs-utils.js +137 -3
  12. package/core/codegen/hooks-docs-generator.js +3 -3
  13. package/core/codegen/index.js +1 -1
  14. package/core/codegen/orm/docs-generator.js +3 -3
  15. package/core/codegen/orm/index.js +1 -1
  16. package/core/codegen/orm/input-types-generator.js +1 -1
  17. package/core/codegen/orm/model-generator.js +1 -1
  18. package/core/codegen/queries.js +1 -1
  19. package/core/codegen/templates/cli-utils.ts +11 -11
  20. package/core/codegen/templates/embedder.ts +175 -0
  21. package/core/generate.js +2 -0
  22. package/esm/core/codegen/cli/command-map-generator.js +1 -1
  23. package/esm/core/codegen/cli/custom-command-generator.js +1 -1
  24. package/esm/core/codegen/cli/docs-generator.js +7 -15
  25. package/esm/core/codegen/cli/index.d.ts +3 -1
  26. package/esm/core/codegen/cli/index.js +16 -2
  27. package/esm/core/codegen/cli/table-command-generator.d.ts +2 -0
  28. package/esm/core/codegen/cli/table-command-generator.js +251 -37
  29. package/esm/core/codegen/cli/utils-generator.d.ts +8 -0
  30. package/esm/core/codegen/cli/utils-generator.js +13 -0
  31. package/esm/core/codegen/docs-utils.d.ts +17 -0
  32. package/esm/core/codegen/docs-utils.js +135 -3
  33. package/esm/core/codegen/hooks-docs-generator.js +1 -1
  34. package/esm/core/codegen/index.js +1 -1
  35. package/esm/core/codegen/orm/docs-generator.js +1 -1
  36. package/esm/core/codegen/orm/index.js +1 -1
  37. package/esm/core/codegen/orm/input-types-generator.js +1 -1
  38. package/esm/core/codegen/orm/model-generator.js +1 -1
  39. package/esm/core/codegen/queries.js +1 -1
  40. package/esm/core/generate.js +2 -0
  41. package/package.json +15 -16
@@ -1,4 +1,4 @@
1
- import { toKebabCase } from 'komoji';
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 !== false;
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 !== false;
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 !== false;
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 = true, } = options;
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);
@@ -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.25.0",
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.4",
60
- "@constructive-io/graphql-types": "^3.4.1",
61
- "@inquirerer/utils": "^3.3.4",
62
- "@pgpmjs/core": "^6.10.2",
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.1",
67
- "graphile-schema": "^1.11.1",
66
+ "gql-ast": "^3.4.2",
67
+ "graphile-schema": "^1.11.3",
68
68
  "graphql": "16.13.0",
69
- "inflekt": "^0.6.0",
69
+ "inflekt": "^0.7.0",
70
70
  "inquirerer": "^4.7.0",
71
71
  "jiti": "^2.6.1",
72
- "komoji": "^0.9.0",
73
- "oxfmt": "^0.40.0",
74
- "pg-cache": "^3.4.1",
75
- "pg-env": "^1.8.1",
76
- "pgsql-client": "^3.7.2",
77
- "pgsql-seed": "^2.7.2",
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": "93deca687ce109bf90d2a0a73ea6b05b22724160"
103
+ "gitHead": "2f6e083d11764a04b2a6bc14df5b2ca2725defc6"
105
104
  }