@constructive-io/graphql-query 3.2.4 → 3.3.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 (88) hide show
  1. package/README.md +411 -65
  2. package/ast.d.ts +4 -4
  3. package/ast.js +24 -9
  4. package/client/error.d.ts +95 -0
  5. package/client/error.js +277 -0
  6. package/client/execute.d.ts +57 -0
  7. package/client/execute.js +124 -0
  8. package/client/index.d.ts +8 -0
  9. package/client/index.js +20 -0
  10. package/client/typed-document.d.ts +31 -0
  11. package/client/typed-document.js +44 -0
  12. package/custom-ast.d.ts +22 -8
  13. package/custom-ast.js +16 -1
  14. package/esm/ast.js +22 -7
  15. package/esm/client/error.js +271 -0
  16. package/esm/client/execute.js +120 -0
  17. package/esm/client/index.js +8 -0
  18. package/esm/client/typed-document.js +40 -0
  19. package/esm/custom-ast.js +16 -1
  20. package/esm/generators/field-selector.js +381 -0
  21. package/esm/generators/index.js +13 -0
  22. package/esm/generators/mutations.js +200 -0
  23. package/esm/generators/naming-helpers.js +154 -0
  24. package/esm/generators/select.js +661 -0
  25. package/esm/index.js +30 -0
  26. package/esm/introspect/index.js +9 -0
  27. package/esm/introspect/infer-tables.js +697 -0
  28. package/esm/introspect/schema-query.js +120 -0
  29. package/esm/introspect/transform-schema.js +271 -0
  30. package/esm/introspect/transform.js +38 -0
  31. package/esm/meta-object/convert.js +3 -0
  32. package/esm/meta-object/format.json +11 -41
  33. package/esm/meta-object/validate.js +20 -4
  34. package/esm/query-builder.js +14 -18
  35. package/esm/types/index.js +18 -0
  36. package/esm/types/introspection.js +54 -0
  37. package/esm/types/mutation.js +4 -0
  38. package/esm/types/query.js +4 -0
  39. package/esm/types/schema.js +5 -0
  40. package/esm/types/selection.js +4 -0
  41. package/esm/utils.js +69 -0
  42. package/generators/field-selector.d.ts +30 -0
  43. package/generators/field-selector.js +387 -0
  44. package/generators/index.d.ts +9 -0
  45. package/generators/index.js +42 -0
  46. package/generators/mutations.d.ts +30 -0
  47. package/generators/mutations.js +238 -0
  48. package/generators/naming-helpers.d.ts +48 -0
  49. package/generators/naming-helpers.js +169 -0
  50. package/generators/select.d.ts +39 -0
  51. package/generators/select.js +705 -0
  52. package/index.d.ts +19 -0
  53. package/index.js +34 -1
  54. package/introspect/index.d.ts +9 -0
  55. package/introspect/index.js +25 -0
  56. package/introspect/infer-tables.d.ts +42 -0
  57. package/introspect/infer-tables.js +700 -0
  58. package/introspect/schema-query.d.ts +20 -0
  59. package/introspect/schema-query.js +123 -0
  60. package/introspect/transform-schema.d.ts +86 -0
  61. package/introspect/transform-schema.js +281 -0
  62. package/introspect/transform.d.ts +20 -0
  63. package/introspect/transform.js +43 -0
  64. package/meta-object/convert.d.ts +3 -0
  65. package/meta-object/convert.js +3 -0
  66. package/meta-object/format.json +11 -41
  67. package/meta-object/validate.d.ts +8 -3
  68. package/meta-object/validate.js +20 -4
  69. package/package.json +4 -3
  70. package/query-builder.d.ts +11 -12
  71. package/query-builder.js +25 -29
  72. package/{types.d.ts → types/core.d.ts} +25 -18
  73. package/types/index.d.ts +12 -0
  74. package/types/index.js +34 -0
  75. package/types/introspection.d.ts +121 -0
  76. package/types/introspection.js +62 -0
  77. package/types/mutation.d.ts +45 -0
  78. package/types/mutation.js +5 -0
  79. package/types/query.d.ts +91 -0
  80. package/types/query.js +5 -0
  81. package/types/schema.d.ts +265 -0
  82. package/types/schema.js +6 -0
  83. package/types/selection.d.ts +43 -0
  84. package/types/selection.js +5 -0
  85. package/utils.d.ts +17 -0
  86. package/utils.js +72 -0
  87. /package/esm/{types.js → types/core.js} +0 -0
  88. /package/{types.js → types/core.js} +0 -0
@@ -0,0 +1,54 @@
1
+ /**
2
+ * GraphQL Introspection Types
3
+ *
4
+ * Standard types for GraphQL schema introspection via __schema query.
5
+ * These mirror the GraphQL introspection spec.
6
+ */
7
+ // ============================================================================
8
+ // Type Guards
9
+ // ============================================================================
10
+ /**
11
+ * Check if type kind is a wrapper (LIST or NON_NULL)
12
+ */
13
+ export function isWrapperType(kind) {
14
+ return kind === 'LIST' || kind === 'NON_NULL';
15
+ }
16
+ /**
17
+ * Check if type kind is a named type (has a name)
18
+ */
19
+ export function isNamedType(kind) {
20
+ return !isWrapperType(kind);
21
+ }
22
+ /**
23
+ * Unwrap a type reference to get the base named type
24
+ */
25
+ export function unwrapType(typeRef) {
26
+ let current = typeRef;
27
+ while (current.ofType) {
28
+ current = current.ofType;
29
+ }
30
+ return current;
31
+ }
32
+ /**
33
+ * Get the base type name from a possibly wrapped type
34
+ */
35
+ export function getBaseTypeName(typeRef) {
36
+ return unwrapType(typeRef).name;
37
+ }
38
+ /**
39
+ * Check if a type reference is non-null (required)
40
+ */
41
+ export function isNonNull(typeRef) {
42
+ return typeRef.kind === 'NON_NULL';
43
+ }
44
+ /**
45
+ * Check if a type reference is a list
46
+ */
47
+ export function isList(typeRef) {
48
+ if (typeRef.kind === 'LIST')
49
+ return true;
50
+ if (typeRef.kind === 'NON_NULL' && typeRef.ofType) {
51
+ return typeRef.ofType.kind === 'LIST';
52
+ }
53
+ return false;
54
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Mutation-related types
3
+ */
4
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Query-related types for building GraphQL operations
3
+ */
4
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Core schema types for representing PostGraphile table metadata
3
+ * These are "clean" versions that remove nullable/undefined complexity
4
+ */
5
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Field selection types for controlling which fields are included in queries
3
+ */
4
+ export {};
package/esm/utils.js ADDED
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Utility functions for GraphQL query generation
3
+ */
4
+ /**
5
+ * PostGraphile boilerplate description prefixes that should be suppressed
6
+ */
7
+ const POSTGRAPHILE_BOILERPLATE = [
8
+ 'The exclusive input argument for this mutation.',
9
+ 'An arbitrary string value with no semantic meaning.',
10
+ 'The exact same `clientMutationId` that was provided in the mutation input,',
11
+ 'The output of our',
12
+ 'All input for the',
13
+ 'A cursor for use in pagination.',
14
+ 'An edge for our',
15
+ 'Information to aid in pagination.',
16
+ 'Reads and enables pagination through a set of',
17
+ 'A list of edges which contains the',
18
+ 'The count of *all* `',
19
+ 'A list of `',
20
+ 'Our root query field',
21
+ 'Reads a single',
22
+ 'The root query type',
23
+ 'The root mutation type',
24
+ ];
25
+ /**
26
+ * Check if a description is generic PostGraphile boilerplate that should be suppressed.
27
+ */
28
+ function isBoilerplateDescription(description) {
29
+ const trimmed = description.trim();
30
+ return POSTGRAPHILE_BOILERPLATE.some((bp) => trimmed.startsWith(bp));
31
+ }
32
+ /**
33
+ * Strip PostGraphile smart comments and boilerplate from a description string.
34
+ *
35
+ * Smart comments are lines starting with `@` (e.g., `@omit`, `@name newName`).
36
+ * Boilerplate descriptions are generic PostGraphile-generated text that repeats
37
+ * on every mutation input, clientMutationId field, etc.
38
+ *
39
+ * This returns only the meaningful human-readable portion of the comment,
40
+ * or undefined if the result is empty or boilerplate.
41
+ *
42
+ * @param description - Raw description from GraphQL introspection
43
+ * @returns Cleaned description, or undefined if empty/boilerplate
44
+ */
45
+ export function stripSmartComments(description, enabled = true) {
46
+ if (!enabled)
47
+ return undefined;
48
+ if (!description)
49
+ return undefined;
50
+ // Check if entire description is boilerplate
51
+ if (isBoilerplateDescription(description))
52
+ return undefined;
53
+ const lines = description.split('\n');
54
+ const cleanLines = [];
55
+ for (const line of lines) {
56
+ const trimmed = line.trim();
57
+ // Skip lines that start with @ (smart comment directives)
58
+ if (trimmed.startsWith('@'))
59
+ continue;
60
+ cleanLines.push(line);
61
+ }
62
+ const result = cleanLines.join('\n').trim();
63
+ if (result.length === 0)
64
+ return undefined;
65
+ // Re-check after stripping smart comments
66
+ if (isBoilerplateDescription(result))
67
+ return undefined;
68
+ return result;
69
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Simplified field selection system
3
+ * Converts user-friendly selection options to internal SelectionOptions format
4
+ */
5
+ import type { QuerySelectionOptions } from '../types';
6
+ import type { CleanTable } from '../types/schema';
7
+ import type { FieldSelection } from '../types/selection';
8
+ /**
9
+ * Convert simplified field selection to QueryBuilder SelectionOptions
10
+ */
11
+ export declare function convertToSelectionOptions(table: CleanTable, allTables: CleanTable[], selection?: FieldSelection): QuerySelectionOptions | null;
12
+ /**
13
+ * Check if a field is relational using table metadata
14
+ */
15
+ export declare function isRelationalField(fieldName: string, table: CleanTable): boolean;
16
+ /**
17
+ * Get all available relation fields from a table
18
+ */
19
+ export declare function getAvailableRelations(table: CleanTable): Array<{
20
+ fieldName: string;
21
+ type: 'belongsTo' | 'hasOne' | 'hasMany' | 'manyToMany';
22
+ referencedTable?: string;
23
+ }>;
24
+ /**
25
+ * Validate field selection against table schema
26
+ */
27
+ export declare function validateFieldSelection(selection: FieldSelection, table: CleanTable): {
28
+ isValid: boolean;
29
+ errors: string[];
30
+ };
@@ -0,0 +1,387 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertToSelectionOptions = convertToSelectionOptions;
4
+ exports.isRelationalField = isRelationalField;
5
+ exports.getAvailableRelations = getAvailableRelations;
6
+ exports.validateFieldSelection = validateFieldSelection;
7
+ const relationalFieldSetCache = new WeakMap();
8
+ function getRelationalFieldSet(table) {
9
+ const cached = relationalFieldSetCache.get(table);
10
+ if (cached)
11
+ return cached;
12
+ const set = new Set();
13
+ for (const rel of table.relations.belongsTo) {
14
+ if (rel.fieldName)
15
+ set.add(rel.fieldName);
16
+ }
17
+ for (const rel of table.relations.hasOne) {
18
+ if (rel.fieldName)
19
+ set.add(rel.fieldName);
20
+ }
21
+ for (const rel of table.relations.hasMany) {
22
+ if (rel.fieldName)
23
+ set.add(rel.fieldName);
24
+ }
25
+ for (const rel of table.relations.manyToMany) {
26
+ if (rel.fieldName)
27
+ set.add(rel.fieldName);
28
+ }
29
+ relationalFieldSetCache.set(table, set);
30
+ return set;
31
+ }
32
+ /**
33
+ * Convert simplified field selection to QueryBuilder SelectionOptions
34
+ */
35
+ function convertToSelectionOptions(table, allTables, selection) {
36
+ if (!selection) {
37
+ return convertPresetToSelection(table, 'display');
38
+ }
39
+ if (typeof selection === 'string') {
40
+ return convertPresetToSelection(table, selection);
41
+ }
42
+ return convertCustomSelectionToOptions(table, allTables, selection);
43
+ }
44
+ /**
45
+ * Convert preset to selection options
46
+ */
47
+ function convertPresetToSelection(table, preset) {
48
+ const options = {};
49
+ switch (preset) {
50
+ case 'minimal': {
51
+ // Just id and first display field
52
+ const minimalFields = getMinimalFields(table);
53
+ minimalFields.forEach((field) => {
54
+ options[field] = true;
55
+ });
56
+ break;
57
+ }
58
+ case 'display': {
59
+ // Common display fields
60
+ const displayFields = getDisplayFields(table);
61
+ displayFields.forEach((field) => {
62
+ options[field] = true;
63
+ });
64
+ break;
65
+ }
66
+ case 'all': {
67
+ // All non-relational fields (includes complex fields like JSON, geometry, etc.)
68
+ const allFields = getNonRelationalFields(table);
69
+ allFields.forEach((field) => {
70
+ options[field] = true;
71
+ });
72
+ break;
73
+ }
74
+ case 'full':
75
+ // All fields including basic relations
76
+ table.fields.forEach((field) => {
77
+ options[field.name] = true;
78
+ });
79
+ break;
80
+ default: {
81
+ // Default to display
82
+ const defaultFields = getDisplayFields(table);
83
+ defaultFields.forEach((field) => {
84
+ options[field] = true;
85
+ });
86
+ }
87
+ }
88
+ return options;
89
+ }
90
+ /**
91
+ * Convert custom selection to options
92
+ */
93
+ function convertCustomSelectionToOptions(table, allTables, selection) {
94
+ const options = {};
95
+ // Start with selected fields or all non-relational fields (including complex types)
96
+ let fieldsToInclude;
97
+ if (selection.select) {
98
+ fieldsToInclude = selection.select;
99
+ }
100
+ else {
101
+ fieldsToInclude = getNonRelationalFields(table);
102
+ }
103
+ // Add basic fields
104
+ fieldsToInclude.forEach((field) => {
105
+ if (table.fields.some((f) => f.name === field)) {
106
+ options[field] = true;
107
+ }
108
+ });
109
+ // Handle includeRelations (simple API for relation fields)
110
+ if (selection.includeRelations) {
111
+ selection.includeRelations.forEach((relationField) => {
112
+ if (isRelationalField(relationField, table)) {
113
+ // Include with dynamically determined scalar fields from the related table
114
+ options[relationField] = {
115
+ select: getRelatedTableScalarFields(relationField, table, allTables),
116
+ variables: {},
117
+ };
118
+ }
119
+ });
120
+ }
121
+ // Handle includes (relations) - more detailed API
122
+ if (selection.include) {
123
+ Object.entries(selection.include).forEach(([relationField, relationSelection]) => {
124
+ if (isRelationalField(relationField, table)) {
125
+ if (relationSelection === true) {
126
+ // Include with dynamically determined scalar fields from the related table
127
+ options[relationField] = {
128
+ select: getRelatedTableScalarFields(relationField, table, allTables),
129
+ variables: {},
130
+ };
131
+ }
132
+ else if (Array.isArray(relationSelection)) {
133
+ // Include with specific fields
134
+ const selectObj = {};
135
+ relationSelection.forEach((field) => {
136
+ selectObj[field] = true;
137
+ });
138
+ options[relationField] = {
139
+ select: selectObj,
140
+ variables: {},
141
+ };
142
+ }
143
+ }
144
+ });
145
+ }
146
+ // Handle excludes
147
+ if (selection.exclude) {
148
+ selection.exclude.forEach((field) => {
149
+ delete options[field];
150
+ });
151
+ }
152
+ return options;
153
+ }
154
+ /**
155
+ * Get minimal fields - completely schema-driven, no hardcoded assumptions
156
+ */
157
+ function getMinimalFields(table) {
158
+ // Get all non-relational fields from the actual schema
159
+ const nonRelationalFields = getNonRelationalFields(table);
160
+ // Return the first few fields from the schema (typically includes primary key and basic fields)
161
+ // This is completely dynamic based on what the schema actually provides
162
+ return nonRelationalFields.slice(0, 3); // Limit to first 3 fields for minimal selection
163
+ }
164
+ /**
165
+ * Get display fields - completely schema-driven, no hardcoded field names
166
+ */
167
+ function getDisplayFields(table) {
168
+ // Get all non-relational fields from the actual schema
169
+ const nonRelationalFields = getNonRelationalFields(table);
170
+ // Return a reasonable subset for display purposes (first half of available fields)
171
+ // This is completely dynamic based on what the schema actually provides
172
+ const maxDisplayFields = Math.max(5, Math.floor(nonRelationalFields.length / 2));
173
+ return nonRelationalFields.slice(0, maxDisplayFields);
174
+ }
175
+ /**
176
+ * Get all non-relational fields (includes both scalar and complex fields)
177
+ * Complex fields like JSON, geometry, images should be included by default
178
+ */
179
+ function getNonRelationalFields(table) {
180
+ return table.fields
181
+ .filter((field) => !isRelationalField(field.name, table))
182
+ .map((field) => field.name);
183
+ }
184
+ /**
185
+ * Check if a field is relational using table metadata
186
+ */
187
+ function isRelationalField(fieldName, table) {
188
+ return getRelationalFieldSet(table).has(fieldName);
189
+ }
190
+ /**
191
+ * Get scalar fields for a related table to include in relation queries
192
+ * Uses only the _meta query data - no hardcoded field names or assumptions
193
+ */
194
+ function getRelatedTableScalarFields(relationField, table, allTables) {
195
+ // Find the related table name
196
+ let referencedTableName;
197
+ // Check belongsTo relations
198
+ const belongsToRel = table.relations.belongsTo.find((rel) => rel.fieldName === relationField);
199
+ if (belongsToRel) {
200
+ referencedTableName = belongsToRel.referencesTable;
201
+ }
202
+ // Check hasOne relations
203
+ if (!referencedTableName) {
204
+ const hasOneRel = table.relations.hasOne.find((rel) => rel.fieldName === relationField);
205
+ if (hasOneRel) {
206
+ referencedTableName = hasOneRel.referencedByTable;
207
+ }
208
+ }
209
+ // Check hasMany relations
210
+ if (!referencedTableName) {
211
+ const hasManyRel = table.relations.hasMany.find((rel) => rel.fieldName === relationField);
212
+ if (hasManyRel) {
213
+ referencedTableName = hasManyRel.referencedByTable;
214
+ }
215
+ }
216
+ // Check manyToMany relations
217
+ if (!referencedTableName) {
218
+ const manyToManyRel = table.relations.manyToMany.find((rel) => rel.fieldName === relationField);
219
+ if (manyToManyRel) {
220
+ referencedTableName = manyToManyRel.rightTable;
221
+ }
222
+ }
223
+ if (!referencedTableName) {
224
+ // No related table found - return empty selection
225
+ return {};
226
+ }
227
+ // Find the related table in allTables
228
+ const relatedTable = allTables.find((t) => t.name === referencedTableName);
229
+ if (!relatedTable) {
230
+ // Related table not found in schema - return empty selection
231
+ return {};
232
+ }
233
+ // Get ALL scalar fields from the related table (non-relational fields)
234
+ // This is completely dynamic based on the actual schema
235
+ const scalarFields = relatedTable.fields
236
+ .filter((field) => !isRelationalField(field.name, relatedTable))
237
+ .map((field) => field.name);
238
+ // Perf guardrail: select a small, display-oriented subset.
239
+ const MAX_RELATED_FIELDS = 8;
240
+ const preferred = [
241
+ 'displayName',
242
+ 'fullName',
243
+ 'preferredName',
244
+ 'nickname',
245
+ 'firstName',
246
+ 'lastName',
247
+ 'username',
248
+ 'email',
249
+ 'name',
250
+ 'title',
251
+ 'label',
252
+ 'slug',
253
+ 'code',
254
+ 'createdAt',
255
+ 'updatedAt',
256
+ ];
257
+ const scalarFieldSet = new Set(scalarFields);
258
+ // Use Set for O(1) duplicate checking
259
+ const includedSet = new Set();
260
+ const included = [];
261
+ const push = (fieldName) => {
262
+ if (!fieldName)
263
+ return;
264
+ if (!scalarFieldSet.has(fieldName))
265
+ return;
266
+ if (includedSet.has(fieldName))
267
+ return;
268
+ if (included.length >= MAX_RELATED_FIELDS)
269
+ return;
270
+ includedSet.add(fieldName);
271
+ included.push(fieldName);
272
+ };
273
+ // Always try to include stable identifiers first.
274
+ push('id');
275
+ push('rowId');
276
+ push('nodeId');
277
+ for (const fieldName of preferred)
278
+ push(fieldName);
279
+ for (const fieldName of scalarFields)
280
+ push(fieldName);
281
+ const selection = {};
282
+ for (const fieldName of included)
283
+ selection[fieldName] = true;
284
+ return selection;
285
+ }
286
+ /**
287
+ * Get all available relation fields from a table
288
+ */
289
+ function getAvailableRelations(table) {
290
+ const relations = [];
291
+ // Add belongsTo relations
292
+ table.relations.belongsTo.forEach((rel) => {
293
+ if (rel.fieldName) {
294
+ relations.push({
295
+ fieldName: rel.fieldName,
296
+ type: 'belongsTo',
297
+ referencedTable: rel.referencesTable || undefined,
298
+ });
299
+ }
300
+ });
301
+ // Add hasOne relations
302
+ table.relations.hasOne.forEach((rel) => {
303
+ if (rel.fieldName) {
304
+ relations.push({
305
+ fieldName: rel.fieldName,
306
+ type: 'hasOne',
307
+ referencedTable: rel.referencedByTable || undefined,
308
+ });
309
+ }
310
+ });
311
+ // Add hasMany relations
312
+ table.relations.hasMany.forEach((rel) => {
313
+ if (rel.fieldName) {
314
+ relations.push({
315
+ fieldName: rel.fieldName,
316
+ type: 'hasMany',
317
+ referencedTable: rel.referencedByTable || undefined,
318
+ });
319
+ }
320
+ });
321
+ // Add manyToMany relations
322
+ table.relations.manyToMany.forEach((rel) => {
323
+ if (rel.fieldName) {
324
+ relations.push({
325
+ fieldName: rel.fieldName,
326
+ type: 'manyToMany',
327
+ referencedTable: rel.rightTable || undefined,
328
+ });
329
+ }
330
+ });
331
+ return relations;
332
+ }
333
+ /**
334
+ * Validate field selection against table schema
335
+ */
336
+ function validateFieldSelection(selection, table) {
337
+ const errors = [];
338
+ if (typeof selection === 'string') {
339
+ // Presets are always valid
340
+ return { isValid: true, errors: [] };
341
+ }
342
+ const tableFieldNames = table.fields.map((f) => f.name);
343
+ // Validate select fields
344
+ if (selection.select) {
345
+ selection.select.forEach((field) => {
346
+ if (!tableFieldNames.includes(field)) {
347
+ errors.push(`Field '${field}' does not exist in table '${table.name}'`);
348
+ }
349
+ });
350
+ }
351
+ // Validate includeRelations fields
352
+ if (selection.includeRelations) {
353
+ selection.includeRelations.forEach((field) => {
354
+ if (!isRelationalField(field, table)) {
355
+ errors.push(`Field '${field}' is not a relational field in table '${table.name}'`);
356
+ }
357
+ });
358
+ }
359
+ // Validate include fields
360
+ if (selection.include) {
361
+ Object.keys(selection.include).forEach((field) => {
362
+ if (!isRelationalField(field, table)) {
363
+ errors.push(`Field '${field}' is not a relational field in table '${table.name}'`);
364
+ }
365
+ });
366
+ }
367
+ // Validate exclude fields
368
+ if (selection.exclude) {
369
+ selection.exclude.forEach((field) => {
370
+ if (!tableFieldNames.includes(field)) {
371
+ errors.push(`Exclude field '${field}' does not exist in table '${table.name}'`);
372
+ }
373
+ });
374
+ }
375
+ // Validate maxDepth
376
+ if (selection.maxDepth !== undefined) {
377
+ if (typeof selection.maxDepth !== 'number' ||
378
+ selection.maxDepth < 0 ||
379
+ selection.maxDepth > 5) {
380
+ errors.push('maxDepth must be a number between 0 and 5');
381
+ }
382
+ }
383
+ return {
384
+ isValid: errors.length === 0,
385
+ errors,
386
+ };
387
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generators barrel export
3
+ *
4
+ * Re-exports all query/mutation generation functions and naming helpers.
5
+ */
6
+ export { buildSelect, buildFindOne, buildCount, cleanTableToMetaObject, createASTQueryBuilder, generateIntrospectionSchema, toCamelCasePlural, toOrderByTypeName, } from './select';
7
+ export { buildPostGraphileCreate, buildPostGraphileUpdate, buildPostGraphileDelete, } from './mutations';
8
+ export { convertToSelectionOptions, isRelationalField, getAvailableRelations, validateFieldSelection, } from './field-selector';
9
+ export { normalizeInflectionValue, toCamelCaseSingular, toCreateMutationName, toUpdateMutationName, toDeleteMutationName, toCreateInputTypeName, toUpdateInputTypeName, toDeleteInputTypeName, toFilterTypeName, toPatchFieldName, toOrderByEnumValue, } from './naming-helpers';
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * Generators barrel export
4
+ *
5
+ * Re-exports all query/mutation generation functions and naming helpers.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.toOrderByEnumValue = exports.toPatchFieldName = exports.toFilterTypeName = exports.toDeleteInputTypeName = exports.toUpdateInputTypeName = exports.toCreateInputTypeName = exports.toDeleteMutationName = exports.toUpdateMutationName = exports.toCreateMutationName = exports.toCamelCaseSingular = exports.normalizeInflectionValue = exports.validateFieldSelection = exports.getAvailableRelations = exports.isRelationalField = exports.convertToSelectionOptions = exports.buildPostGraphileDelete = exports.buildPostGraphileUpdate = exports.buildPostGraphileCreate = exports.toOrderByTypeName = exports.toCamelCasePlural = exports.generateIntrospectionSchema = exports.createASTQueryBuilder = exports.cleanTableToMetaObject = exports.buildCount = exports.buildFindOne = exports.buildSelect = void 0;
9
+ // SELECT, FindOne, Count query generators
10
+ var select_1 = require("./select");
11
+ Object.defineProperty(exports, "buildSelect", { enumerable: true, get: function () { return select_1.buildSelect; } });
12
+ Object.defineProperty(exports, "buildFindOne", { enumerable: true, get: function () { return select_1.buildFindOne; } });
13
+ Object.defineProperty(exports, "buildCount", { enumerable: true, get: function () { return select_1.buildCount; } });
14
+ Object.defineProperty(exports, "cleanTableToMetaObject", { enumerable: true, get: function () { return select_1.cleanTableToMetaObject; } });
15
+ Object.defineProperty(exports, "createASTQueryBuilder", { enumerable: true, get: function () { return select_1.createASTQueryBuilder; } });
16
+ Object.defineProperty(exports, "generateIntrospectionSchema", { enumerable: true, get: function () { return select_1.generateIntrospectionSchema; } });
17
+ Object.defineProperty(exports, "toCamelCasePlural", { enumerable: true, get: function () { return select_1.toCamelCasePlural; } });
18
+ Object.defineProperty(exports, "toOrderByTypeName", { enumerable: true, get: function () { return select_1.toOrderByTypeName; } });
19
+ // Mutation generators (CREATE, UPDATE, DELETE)
20
+ var mutations_1 = require("./mutations");
21
+ Object.defineProperty(exports, "buildPostGraphileCreate", { enumerable: true, get: function () { return mutations_1.buildPostGraphileCreate; } });
22
+ Object.defineProperty(exports, "buildPostGraphileUpdate", { enumerable: true, get: function () { return mutations_1.buildPostGraphileUpdate; } });
23
+ Object.defineProperty(exports, "buildPostGraphileDelete", { enumerable: true, get: function () { return mutations_1.buildPostGraphileDelete; } });
24
+ // Field selection utilities
25
+ var field_selector_1 = require("./field-selector");
26
+ Object.defineProperty(exports, "convertToSelectionOptions", { enumerable: true, get: function () { return field_selector_1.convertToSelectionOptions; } });
27
+ Object.defineProperty(exports, "isRelationalField", { enumerable: true, get: function () { return field_selector_1.isRelationalField; } });
28
+ Object.defineProperty(exports, "getAvailableRelations", { enumerable: true, get: function () { return field_selector_1.getAvailableRelations; } });
29
+ Object.defineProperty(exports, "validateFieldSelection", { enumerable: true, get: function () { return field_selector_1.validateFieldSelection; } });
30
+ // Naming helpers (server-aware inflection)
31
+ var naming_helpers_1 = require("./naming-helpers");
32
+ Object.defineProperty(exports, "normalizeInflectionValue", { enumerable: true, get: function () { return naming_helpers_1.normalizeInflectionValue; } });
33
+ Object.defineProperty(exports, "toCamelCaseSingular", { enumerable: true, get: function () { return naming_helpers_1.toCamelCaseSingular; } });
34
+ Object.defineProperty(exports, "toCreateMutationName", { enumerable: true, get: function () { return naming_helpers_1.toCreateMutationName; } });
35
+ Object.defineProperty(exports, "toUpdateMutationName", { enumerable: true, get: function () { return naming_helpers_1.toUpdateMutationName; } });
36
+ Object.defineProperty(exports, "toDeleteMutationName", { enumerable: true, get: function () { return naming_helpers_1.toDeleteMutationName; } });
37
+ Object.defineProperty(exports, "toCreateInputTypeName", { enumerable: true, get: function () { return naming_helpers_1.toCreateInputTypeName; } });
38
+ Object.defineProperty(exports, "toUpdateInputTypeName", { enumerable: true, get: function () { return naming_helpers_1.toUpdateInputTypeName; } });
39
+ Object.defineProperty(exports, "toDeleteInputTypeName", { enumerable: true, get: function () { return naming_helpers_1.toDeleteInputTypeName; } });
40
+ Object.defineProperty(exports, "toFilterTypeName", { enumerable: true, get: function () { return naming_helpers_1.toFilterTypeName; } });
41
+ Object.defineProperty(exports, "toPatchFieldName", { enumerable: true, get: function () { return naming_helpers_1.toPatchFieldName; } });
42
+ Object.defineProperty(exports, "toOrderByEnumValue", { enumerable: true, get: function () { return naming_helpers_1.toOrderByEnumValue; } });
@@ -0,0 +1,30 @@
1
+ import { TypedDocumentString } from '../client/typed-document';
2
+ import type { MutationOptions } from '../types/mutation';
3
+ import type { CleanTable } from '../types/schema';
4
+ /**
5
+ * Build PostGraphile-style CREATE mutation
6
+ * PostGraphile expects: mutation { createTableName(input: { tableName: TableNameInput! }) { tableName { ... } } }
7
+ */
8
+ export declare function buildPostGraphileCreate(table: CleanTable, _allTables: CleanTable[], _options?: MutationOptions): TypedDocumentString<Record<string, unknown>, {
9
+ input: {
10
+ [key: string]: Record<string, unknown>;
11
+ };
12
+ }>;
13
+ /**
14
+ * Build PostGraphile-style UPDATE mutation
15
+ * PostGraphile expects: mutation { updateTableName(input: { id: UUID!, patch: TableNamePatch! }) { tableName { ... } } }
16
+ */
17
+ export declare function buildPostGraphileUpdate(table: CleanTable, _allTables: CleanTable[], _options?: MutationOptions): TypedDocumentString<Record<string, unknown>, {
18
+ input: {
19
+ id: string | number;
20
+ } & Record<string, unknown>;
21
+ }>;
22
+ /**
23
+ * Build PostGraphile-style DELETE mutation
24
+ * PostGraphile expects: mutation { deleteTableName(input: { id: UUID! }) { clientMutationId } }
25
+ */
26
+ export declare function buildPostGraphileDelete(table: CleanTable, _allTables: CleanTable[], _options?: MutationOptions): TypedDocumentString<Record<string, unknown>, {
27
+ input: {
28
+ id: string | number;
29
+ };
30
+ }>;