@constructive-io/graphql-codegen 4.22.6 → 4.23.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.
@@ -1,14 +1,9 @@
1
+ /**
2
+ * Codegen utilities - naming conventions, type mapping, and helpers
3
+ */
4
+ import { lcFirst, toCamelCase, toPascalCase, toScreamingSnake, ucFirst } from 'inflekt';
1
5
  import type { Field, FieldType, Table, TypeRegistry } from '../../types/schema';
2
- /** Lowercase first character */
3
- export declare function lcFirst(str: string): string;
4
- /** Uppercase first character */
5
- export declare function ucFirst(str: string): string;
6
- /** Convert to camelCase */
7
- export declare function toCamelCase(str: string): string;
8
- /** Convert to PascalCase */
9
- export declare function toPascalCase(str: string): string;
10
- /** Convert to SCREAMING_SNAKE_CASE */
11
- export declare function toScreamingSnake(str: string): string;
6
+ export { lcFirst, toCamelCase, toPascalCase, toScreamingSnake, ucFirst };
12
7
  export interface TableNames {
13
8
  /** PascalCase singular (e.g., "Car") */
14
9
  typeName: string;
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lcFirst = lcFirst;
4
- exports.ucFirst = ucFirst;
5
- exports.toCamelCase = toCamelCase;
6
- exports.toPascalCase = toPascalCase;
7
- exports.toScreamingSnake = toScreamingSnake;
3
+ exports.ucFirst = exports.toScreamingSnake = exports.toPascalCase = exports.toCamelCase = exports.lcFirst = void 0;
8
4
  exports.getTableNames = getTableNames;
9
5
  exports.getListQueryHookName = getListQueryHookName;
10
6
  exports.getSingleQueryHookName = getSingleQueryHookName;
@@ -47,48 +43,22 @@ exports.indent = indent;
47
43
  * Codegen utilities - naming conventions, type mapping, and helpers
48
44
  */
49
45
  const inflekt_1 = require("inflekt");
46
+ Object.defineProperty(exports, "lcFirst", { enumerable: true, get: function () { return inflekt_1.lcFirst; } });
47
+ Object.defineProperty(exports, "toCamelCase", { enumerable: true, get: function () { return inflekt_1.toCamelCase; } });
48
+ Object.defineProperty(exports, "toPascalCase", { enumerable: true, get: function () { return inflekt_1.toPascalCase; } });
49
+ Object.defineProperty(exports, "toScreamingSnake", { enumerable: true, get: function () { return inflekt_1.toScreamingSnake; } });
50
+ Object.defineProperty(exports, "ucFirst", { enumerable: true, get: function () { return inflekt_1.ucFirst; } });
50
51
  const scalars_1 = require("./scalars");
51
- // ============================================================================
52
- // String manipulation
53
- // ============================================================================
54
- /** Lowercase first character */
55
- function lcFirst(str) {
56
- return str.charAt(0).toLowerCase() + str.slice(1);
57
- }
58
- /** Uppercase first character */
59
- function ucFirst(str) {
60
- return str.charAt(0).toUpperCase() + str.slice(1);
61
- }
62
- /** Convert to camelCase */
63
- function toCamelCase(str) {
64
- return str
65
- .replace(/[-_](.)/g, (_, char) => char.toUpperCase())
66
- .replace(/^(.)/, (_, char) => char.toLowerCase());
67
- }
68
- /** Convert to PascalCase */
69
- function toPascalCase(str) {
70
- return str
71
- .replace(/[-_](.)/g, (_, char) => char.toUpperCase())
72
- .replace(/^(.)/, (_, char) => char.toUpperCase());
73
- }
74
- /** Convert to SCREAMING_SNAKE_CASE */
75
- function toScreamingSnake(str) {
76
- return str
77
- .replace(/([A-Z])/g, '_$1')
78
- .replace(/[-\s]/g, '_')
79
- .toUpperCase()
80
- .replace(/^_/, '');
81
- }
82
52
  /**
83
53
  * Derive all naming variants from a table
84
54
  */
85
55
  function getTableNames(table) {
86
56
  const typeName = table.name;
87
- const singularName = table.inflection?.tableFieldName || lcFirst(typeName);
57
+ const singularName = table.inflection?.tableFieldName || (0, inflekt_1.lcFirst)(typeName);
88
58
  const pluralName = table.query?.all ||
89
59
  table.inflection?.allRows ||
90
- lcFirst((0, inflekt_1.pluralize)(typeName));
91
- const pluralTypeName = ucFirst(pluralName);
60
+ (0, inflekt_1.lcFirst)((0, inflekt_1.pluralize)(typeName));
61
+ const pluralTypeName = (0, inflekt_1.ucFirst)(pluralName);
92
62
  return {
93
63
  typeName,
94
64
  singularName,
@@ -102,7 +72,7 @@ function getTableNames(table) {
102
72
  */
103
73
  function getListQueryHookName(table) {
104
74
  const { pluralName } = getTableNames(table);
105
- return `use${ucFirst(pluralName)}Query`;
75
+ return `use${(0, inflekt_1.ucFirst)(pluralName)}Query`;
106
76
  }
107
77
  /**
108
78
  * Generate hook function name for single item query
@@ -110,7 +80,7 @@ function getListQueryHookName(table) {
110
80
  */
111
81
  function getSingleQueryHookName(table) {
112
82
  const { singularName } = getTableNames(table);
113
- return `use${ucFirst(singularName)}Query`;
83
+ return `use${(0, inflekt_1.ucFirst)(singularName)}Query`;
114
84
  }
115
85
  /**
116
86
  * Generate hook function name for create mutation
@@ -178,13 +148,13 @@ function getDeleteMutationFileName(table) {
178
148
  function getAllRowsQueryName(table) {
179
149
  return (table.query?.all ||
180
150
  table.inflection?.allRows ||
181
- lcFirst((0, inflekt_1.pluralize)(table.name)));
151
+ (0, inflekt_1.lcFirst)((0, inflekt_1.pluralize)(table.name)));
182
152
  }
183
153
  /**
184
154
  * Get the GraphQL query name for fetching single row
185
155
  */
186
156
  function getSingleRowQueryName(table) {
187
- return (table.query?.one || table.inflection?.tableFieldName || lcFirst(table.name));
157
+ return (table.query?.one || table.inflection?.tableFieldName || (0, inflekt_1.lcFirst)(table.name));
188
158
  }
189
159
  /**
190
160
  * Get the GraphQL mutation name for creating
@@ -249,7 +219,7 @@ function getPatchTypeName(table) {
249
219
  */
250
220
  function getUpdateInputTypeName(table) {
251
221
  const mutationName = table.query?.update;
252
- return mutationName ? ucFirst(mutationName) + 'Input' : `Update${table.name}Input`;
222
+ return mutationName ? (0, inflekt_1.ucFirst)(mutationName) + 'Input' : `Update${table.name}Input`;
253
223
  }
254
224
  /**
255
225
  * Get PostGraphile delete input type name
@@ -258,7 +228,7 @@ function getUpdateInputTypeName(table) {
258
228
  */
259
229
  function getDeleteInputTypeName(table) {
260
230
  const mutationName = table.query?.delete;
261
- return mutationName ? ucFirst(mutationName) + 'Input' : `Delete${table.name}Input`;
231
+ return mutationName ? (0, inflekt_1.ucFirst)(mutationName) + 'Input' : `Delete${table.name}Input`;
262
232
  }
263
233
  // ============================================================================
264
234
  // Type mapping: GraphQL → TypeScript
@@ -417,7 +387,7 @@ function hasValidPrimaryKey(table) {
417
387
  * e.g., "cars" for list queries, "car" for detail queries
418
388
  */
419
389
  function getQueryKeyPrefix(table) {
420
- return lcFirst(table.name);
390
+ return (0, inflekt_1.lcFirst)(table.name);
421
391
  }
422
392
  // ============================================================================
423
393
  // Smart Comment Utilities
@@ -1,14 +1,9 @@
1
+ /**
2
+ * Codegen utilities - naming conventions, type mapping, and helpers
3
+ */
4
+ import { lcFirst, toCamelCase, toPascalCase, toScreamingSnake, ucFirst } from 'inflekt';
1
5
  import type { Field, FieldType, Table, TypeRegistry } from '../../types/schema';
2
- /** Lowercase first character */
3
- export declare function lcFirst(str: string): string;
4
- /** Uppercase first character */
5
- export declare function ucFirst(str: string): string;
6
- /** Convert to camelCase */
7
- export declare function toCamelCase(str: string): string;
8
- /** Convert to PascalCase */
9
- export declare function toPascalCase(str: string): string;
10
- /** Convert to SCREAMING_SNAKE_CASE */
11
- export declare function toScreamingSnake(str: string): string;
6
+ export { lcFirst, toCamelCase, toPascalCase, toScreamingSnake, ucFirst };
12
7
  export interface TableNames {
13
8
  /** PascalCase singular (e.g., "Car") */
14
9
  typeName: string;
@@ -1,39 +1,10 @@
1
1
  /**
2
2
  * Codegen utilities - naming conventions, type mapping, and helpers
3
3
  */
4
- import { pluralize } from 'inflekt';
4
+ import { lcFirst, pluralize, toCamelCase, toPascalCase, toScreamingSnake, ucFirst, } from 'inflekt';
5
5
  import { scalarToFilterType, scalarToTsType } from './scalars';
6
- // ============================================================================
7
- // String manipulation
8
- // ============================================================================
9
- /** Lowercase first character */
10
- export function lcFirst(str) {
11
- return str.charAt(0).toLowerCase() + str.slice(1);
12
- }
13
- /** Uppercase first character */
14
- export function ucFirst(str) {
15
- return str.charAt(0).toUpperCase() + str.slice(1);
16
- }
17
- /** Convert to camelCase */
18
- export function toCamelCase(str) {
19
- return str
20
- .replace(/[-_](.)/g, (_, char) => char.toUpperCase())
21
- .replace(/^(.)/, (_, char) => char.toLowerCase());
22
- }
23
- /** Convert to PascalCase */
24
- export function toPascalCase(str) {
25
- return str
26
- .replace(/[-_](.)/g, (_, char) => char.toUpperCase())
27
- .replace(/^(.)/, (_, char) => char.toUpperCase());
28
- }
29
- /** Convert to SCREAMING_SNAKE_CASE */
30
- export function toScreamingSnake(str) {
31
- return str
32
- .replace(/([A-Z])/g, '_$1')
33
- .replace(/[-\s]/g, '_')
34
- .toUpperCase()
35
- .replace(/^_/, '');
36
- }
6
+ // Re-export string manipulation helpers from inflekt (single source of truth)
7
+ export { lcFirst, toCamelCase, toPascalCase, toScreamingSnake, ucFirst };
37
8
  /**
38
9
  * Derive all naming variants from a table
39
10
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/graphql-codegen",
3
- "version": "4.22.6",
3
+ "version": "4.23.0",
4
4
  "description": "GraphQL SDK generator for Constructive databases with React Query hooks",
5
5
  "keywords": [
6
6
  "graphql",
@@ -56,7 +56,7 @@
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.10.4",
59
+ "@constructive-io/graphql-query": "^3.11.0",
60
60
  "@constructive-io/graphql-types": "^3.3.4",
61
61
  "@inquirerer/utils": "^3.3.4",
62
62
  "@pgpmjs/core": "^6.9.3",
@@ -64,9 +64,9 @@
64
64
  "deepmerge": "^4.3.1",
65
65
  "find-and-require-package-json": "^0.9.1",
66
66
  "gql-ast": "^3.3.3",
67
- "graphile-schema": "^1.9.4",
67
+ "graphile-schema": "^1.9.5",
68
68
  "graphql": "16.13.0",
69
- "inflekt": "^0.3.3",
69
+ "inflekt": "^0.5.0",
70
70
  "inquirerer": "^4.7.0",
71
71
  "jiti": "^2.6.1",
72
72
  "komoji": "^0.8.1",
@@ -101,5 +101,5 @@
101
101
  "tsx": "^4.21.0",
102
102
  "typescript": "^5.9.3"
103
103
  },
104
- "gitHead": "6eb4389816805b64af3a2aa18b29a08f37bb013f"
104
+ "gitHead": "2660dbd64e96cdb785ace8b28fbf9275cb3812aa"
105
105
  }