@constructive-io/graphql-codegen 4.6.1 → 4.7.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 (71) hide show
  1. package/client/error.d.ts +2 -93
  2. package/client/error.js +9 -273
  3. package/client/execute.d.ts +2 -55
  4. package/client/execute.js +5 -120
  5. package/client/typed-document.d.ts +2 -29
  6. package/client/typed-document.js +3 -39
  7. package/core/ast.d.ts +8 -10
  8. package/core/ast.js +17 -592
  9. package/core/custom-ast.d.ts +5 -33
  10. package/core/custom-ast.js +16 -203
  11. package/core/introspect/infer-tables.d.ts +2 -40
  12. package/core/introspect/infer-tables.js +4 -696
  13. package/core/introspect/schema-query.d.ts +3 -18
  14. package/core/introspect/schema-query.js +3 -118
  15. package/core/introspect/transform-schema.d.ts +2 -84
  16. package/core/introspect/transform-schema.js +14 -279
  17. package/core/introspect/transform.d.ts +2 -18
  18. package/core/introspect/transform.js +6 -39
  19. package/core/meta-object/convert.d.ts +2 -63
  20. package/core/meta-object/convert.js +4 -59
  21. package/core/meta-object/validate.d.ts +2 -7
  22. package/core/meta-object/validate.js +4 -30
  23. package/core/query-builder.d.ts +7 -46
  24. package/core/query-builder.js +8 -408
  25. package/core/types.d.ts +9 -139
  26. package/core/types.js +12 -26
  27. package/esm/client/error.d.ts +2 -93
  28. package/esm/client/error.js +2 -269
  29. package/esm/client/execute.d.ts +2 -55
  30. package/esm/client/execute.js +2 -118
  31. package/esm/client/typed-document.d.ts +2 -29
  32. package/esm/client/typed-document.js +2 -38
  33. package/esm/core/ast.d.ts +8 -10
  34. package/esm/core/ast.js +8 -550
  35. package/esm/core/custom-ast.d.ts +5 -33
  36. package/esm/core/custom-ast.js +5 -160
  37. package/esm/core/introspect/infer-tables.d.ts +2 -40
  38. package/esm/core/introspect/infer-tables.js +2 -695
  39. package/esm/core/introspect/schema-query.d.ts +3 -18
  40. package/esm/core/introspect/schema-query.js +2 -118
  41. package/esm/core/introspect/transform-schema.d.ts +2 -84
  42. package/esm/core/introspect/transform-schema.js +2 -269
  43. package/esm/core/introspect/transform.d.ts +2 -18
  44. package/esm/core/introspect/transform.js +2 -36
  45. package/esm/core/meta-object/convert.d.ts +2 -63
  46. package/esm/core/meta-object/convert.js +2 -58
  47. package/esm/core/meta-object/validate.d.ts +2 -7
  48. package/esm/core/meta-object/validate.js +2 -26
  49. package/esm/core/query-builder.d.ts +7 -46
  50. package/esm/core/query-builder.js +5 -373
  51. package/esm/core/types.d.ts +9 -139
  52. package/esm/core/types.js +9 -24
  53. package/esm/generators/field-selector.d.ts +5 -28
  54. package/esm/generators/field-selector.js +5 -379
  55. package/esm/generators/mutations.d.ts +5 -28
  56. package/esm/generators/mutations.js +5 -198
  57. package/esm/generators/naming-helpers.d.ts +3 -45
  58. package/esm/generators/naming-helpers.js +3 -151
  59. package/esm/generators/select.d.ts +6 -37
  60. package/esm/generators/select.js +6 -659
  61. package/generators/field-selector.d.ts +5 -28
  62. package/generators/field-selector.js +12 -385
  63. package/generators/mutations.d.ts +5 -28
  64. package/generators/mutations.js +9 -234
  65. package/generators/naming-helpers.d.ts +3 -45
  66. package/generators/naming-helpers.js +15 -164
  67. package/generators/select.d.ts +6 -37
  68. package/generators/select.js +17 -703
  69. package/package.json +7 -6
  70. package/core/meta-object/format.json +0 -93
  71. package/esm/core/meta-object/format.json +0 -93
@@ -1,20 +1,5 @@
1
1
  /**
2
- * GraphQL Schema Introspection Query
3
- *
4
- * Full introspection query that captures all queries, mutations, and types
5
- * from a GraphQL endpoint via the standard __schema query.
2
+ * Re-export schema query from @constructive-io/graphql-query.
6
3
  */
7
- import type { IntrospectionQueryResponse } from '../../types/introspection';
8
- /**
9
- * Full schema introspection query
10
- *
11
- * Captures:
12
- * - All Query fields with args and return types
13
- * - All Mutation fields with args and return types
14
- * - All types (OBJECT, INPUT_OBJECT, ENUM, SCALAR) for resolution
15
- *
16
- * Uses a recursive TypeRef fragment to handle deeply nested type wrappers
17
- * (e.g., [String!]! = NON_NULL(LIST(NON_NULL(SCALAR))))
18
- */
19
- export declare const SCHEMA_INTROSPECTION_QUERY = "\nquery IntrospectSchema {\n __schema {\n queryType {\n name\n }\n mutationType {\n name\n }\n subscriptionType {\n name\n }\n types {\n kind\n name\n description\n fields(includeDeprecated: true) {\n name\n description\n args {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n interfaces {\n name\n }\n enumValues(includeDeprecated: true) {\n name\n description\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n name\n }\n }\n directives {\n name\n description\n locations\n args {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n }\n }\n}\n\nfragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n}\n";
20
- export type { IntrospectionQueryResponse };
4
+ export { SCHEMA_INTROSPECTION_QUERY } from '@constructive-io/graphql-query';
5
+ export type { IntrospectionQueryResponse } from '@constructive-io/graphql-query';
@@ -1,120 +1,4 @@
1
1
  /**
2
- * GraphQL Schema Introspection Query
3
- *
4
- * Full introspection query that captures all queries, mutations, and types
5
- * from a GraphQL endpoint via the standard __schema query.
2
+ * Re-export schema query from @constructive-io/graphql-query.
6
3
  */
7
- /**
8
- * Full schema introspection query
9
- *
10
- * Captures:
11
- * - All Query fields with args and return types
12
- * - All Mutation fields with args and return types
13
- * - All types (OBJECT, INPUT_OBJECT, ENUM, SCALAR) for resolution
14
- *
15
- * Uses a recursive TypeRef fragment to handle deeply nested type wrappers
16
- * (e.g., [String!]! = NON_NULL(LIST(NON_NULL(SCALAR))))
17
- */
18
- export const SCHEMA_INTROSPECTION_QUERY = `
19
- query IntrospectSchema {
20
- __schema {
21
- queryType {
22
- name
23
- }
24
- mutationType {
25
- name
26
- }
27
- subscriptionType {
28
- name
29
- }
30
- types {
31
- kind
32
- name
33
- description
34
- fields(includeDeprecated: true) {
35
- name
36
- description
37
- args {
38
- name
39
- description
40
- type {
41
- ...TypeRef
42
- }
43
- defaultValue
44
- }
45
- type {
46
- ...TypeRef
47
- }
48
- isDeprecated
49
- deprecationReason
50
- }
51
- inputFields {
52
- name
53
- description
54
- type {
55
- ...TypeRef
56
- }
57
- defaultValue
58
- }
59
- interfaces {
60
- name
61
- }
62
- enumValues(includeDeprecated: true) {
63
- name
64
- description
65
- isDeprecated
66
- deprecationReason
67
- }
68
- possibleTypes {
69
- name
70
- }
71
- }
72
- directives {
73
- name
74
- description
75
- locations
76
- args {
77
- name
78
- description
79
- type {
80
- ...TypeRef
81
- }
82
- defaultValue
83
- }
84
- }
85
- }
86
- }
87
-
88
- fragment TypeRef on __Type {
89
- kind
90
- name
91
- ofType {
92
- kind
93
- name
94
- ofType {
95
- kind
96
- name
97
- ofType {
98
- kind
99
- name
100
- ofType {
101
- kind
102
- name
103
- ofType {
104
- kind
105
- name
106
- ofType {
107
- kind
108
- name
109
- ofType {
110
- kind
111
- name
112
- }
113
- }
114
- }
115
- }
116
- }
117
- }
118
- }
119
- }
120
- `;
4
+ export { SCHEMA_INTROSPECTION_QUERY } from '@constructive-io/graphql-query';
@@ -1,86 +1,4 @@
1
1
  /**
2
- * Transform GraphQL introspection data to clean operation types
3
- *
4
- * This module converts raw introspection responses into the CleanOperation
5
- * format used by code generators.
2
+ * Re-export schema transformation utilities from @constructive-io/graphql-query.
6
3
  */
7
- import type { IntrospectionQueryResponse, IntrospectionType } from '../../types/introspection';
8
- import { getBaseTypeName, isNonNull, unwrapType } from '../../types/introspection';
9
- import type { CleanOperation, TypeRegistry } from '../../types/schema';
10
- /**
11
- * Build a type registry from introspection types
12
- * Maps type names to their full resolved definitions
13
- *
14
- * This is a two-pass process to handle circular references:
15
- * 1. First pass: Create all type entries with basic info
16
- * 2. Second pass: Resolve fields with references to other types
17
- */
18
- export declare function buildTypeRegistry(types: IntrospectionType[]): TypeRegistry;
19
- export interface TransformSchemaResult {
20
- queries: CleanOperation[];
21
- mutations: CleanOperation[];
22
- typeRegistry: TypeRegistry;
23
- }
24
- /**
25
- * Transform introspection response to clean operations
26
- */
27
- export declare function transformSchemaToOperations(response: IntrospectionQueryResponse): TransformSchemaResult;
28
- /**
29
- * Filter operations by include/exclude patterns
30
- * Uses glob-like patterns (supports * wildcard)
31
- */
32
- export declare function filterOperations(operations: CleanOperation[], include?: string[], exclude?: string[]): CleanOperation[];
33
- /**
34
- * Result type for table operation names lookup
35
- */
36
- export interface TableOperationNames {
37
- queries: Set<string>;
38
- mutations: Set<string>;
39
- }
40
- /**
41
- * Get the set of table-related operation names from tables
42
- * Used to identify which operations are already covered by table generators
43
- *
44
- * IMPORTANT: This uses EXACT matches only from _meta.query fields.
45
- * Any operation not explicitly listed in _meta will flow through as a
46
- * custom operation, ensuring 100% coverage of the schema.
47
- *
48
- * Table operations (generated by table generators):
49
- * - Queries: all (list), one (single by PK)
50
- * - Mutations: create, update (by PK), delete (by PK)
51
- *
52
- * Custom operations (generated by custom operation generators):
53
- * - Unique constraint lookups: *ByUsername, *ByEmail, etc.
54
- * - Unique constraint mutations: update*By*, delete*By*
55
- * - True custom operations: login, register, bootstrapUser, etc.
56
- */
57
- export declare function getTableOperationNames(tables: Array<{
58
- name: string;
59
- query?: {
60
- all: string;
61
- one: string | null;
62
- create: string;
63
- update: string | null;
64
- delete: string | null;
65
- };
66
- }>): TableOperationNames;
67
- /**
68
- * Check if an operation is a table operation (already handled by table generators)
69
- *
70
- * Uses EXACT match only - no pattern matching. This ensures:
71
- * 1. Only operations explicitly in _meta.query are treated as table operations
72
- * 2. All other operations (including update*By*, delete*By*) become custom operations
73
- * 3. 100% schema coverage is guaranteed
74
- */
75
- export declare function isTableOperation(operation: CleanOperation, tableOperationNames: TableOperationNames): boolean;
76
- /**
77
- * Get only custom operations (not covered by table generators)
78
- *
79
- * This returns ALL operations that are not exact matches for table CRUD operations.
80
- * Includes:
81
- * - Unique constraint queries (*ByUsername, *ByEmail, etc.)
82
- * - Unique constraint mutations (update*By*, delete*By*)
83
- * - True custom operations (login, register, bootstrapUser, etc.)
84
- */
85
- export declare function getCustomOperations(operations: CleanOperation[], tableOperationNames: TableOperationNames): CleanOperation[];
86
- export { getBaseTypeName, isNonNull, unwrapType };
4
+ export { buildTypeRegistry, transformSchemaToOperations, filterOperations, getTableOperationNames, isTableOperation, getCustomOperations, getBaseTypeName, isNonNull, unwrapType, type TransformSchemaResult, type TableOperationNames, } from '@constructive-io/graphql-query';
@@ -1,271 +1,4 @@
1
- import { getBaseTypeName, isNonNull, unwrapType, } from '../../types/introspection';
2
- // ============================================================================
3
- // Type Registry Builder
4
- // ============================================================================
5
1
  /**
6
- * Build a type registry from introspection types
7
- * Maps type names to their full resolved definitions
8
- *
9
- * This is a two-pass process to handle circular references:
10
- * 1. First pass: Create all type entries with basic info
11
- * 2. Second pass: Resolve fields with references to other types
2
+ * Re-export schema transformation utilities from @constructive-io/graphql-query.
12
3
  */
13
- export function buildTypeRegistry(types) {
14
- const registry = new Map();
15
- // First pass: Create all type entries
16
- for (const type of types) {
17
- // Skip built-in types that start with __
18
- if (type.name.startsWith('__'))
19
- continue;
20
- const resolvedType = {
21
- kind: type.kind,
22
- name: type.name,
23
- description: type.description ?? undefined,
24
- };
25
- // Resolve enum values for ENUM types (no circular refs possible)
26
- if (type.kind === 'ENUM' && type.enumValues) {
27
- resolvedType.enumValues = type.enumValues.map((ev) => ev.name);
28
- }
29
- // Resolve possible types for UNION types (no circular refs for names)
30
- if (type.kind === 'UNION' && type.possibleTypes) {
31
- resolvedType.possibleTypes = type.possibleTypes.map((pt) => pt.name);
32
- }
33
- registry.set(type.name, resolvedType);
34
- }
35
- // Second pass: Resolve fields (now that all types exist in registry)
36
- for (const type of types) {
37
- if (type.name.startsWith('__'))
38
- continue;
39
- const resolvedType = registry.get(type.name);
40
- if (!resolvedType)
41
- continue;
42
- // Resolve fields for OBJECT types
43
- if (type.kind === 'OBJECT' && type.fields) {
44
- resolvedType.fields = type.fields.map((field) => transformFieldToCleanObjectFieldShallow(field));
45
- }
46
- // Resolve input fields for INPUT_OBJECT types
47
- if (type.kind === 'INPUT_OBJECT' && type.inputFields) {
48
- resolvedType.inputFields = type.inputFields.map((field) => transformInputValueToCleanArgumentShallow(field));
49
- }
50
- }
51
- return registry;
52
- }
53
- /**
54
- * Transform field to CleanObjectField without resolving nested types
55
- * (shallow transformation to avoid circular refs)
56
- */
57
- function transformFieldToCleanObjectFieldShallow(field) {
58
- return {
59
- name: field.name,
60
- type: transformTypeRefShallow(field.type),
61
- description: field.description ?? undefined,
62
- };
63
- }
64
- /**
65
- * Transform input value to CleanArgument without resolving nested types
66
- */
67
- function transformInputValueToCleanArgumentShallow(inputValue) {
68
- return {
69
- name: inputValue.name,
70
- type: transformTypeRefShallow(inputValue.type),
71
- defaultValue: inputValue.defaultValue ?? undefined,
72
- description: inputValue.description ?? undefined,
73
- };
74
- }
75
- /**
76
- * Transform TypeRef without resolving nested types
77
- * Only handles wrappers (LIST, NON_NULL) and stores the type name
78
- */
79
- function transformTypeRefShallow(typeRef) {
80
- const cleanRef = {
81
- kind: typeRef.kind,
82
- name: typeRef.name,
83
- };
84
- if (typeRef.ofType) {
85
- cleanRef.ofType = transformTypeRefShallow(typeRef.ofType);
86
- }
87
- return cleanRef;
88
- }
89
- /**
90
- * Transform introspection response to clean operations
91
- */
92
- export function transformSchemaToOperations(response) {
93
- const { __schema: schema } = response;
94
- const { types, queryType, mutationType } = schema;
95
- // Build type registry first
96
- const typeRegistry = buildTypeRegistry(types);
97
- // Find Query and Mutation types
98
- const queryTypeDef = types.find((t) => t.name === queryType.name);
99
- const mutationTypeDef = mutationType
100
- ? types.find((t) => t.name === mutationType.name)
101
- : null;
102
- // Transform queries
103
- const queries = queryTypeDef?.fields
104
- ? queryTypeDef.fields.map((field) => transformFieldToCleanOperation(field, 'query', types))
105
- : [];
106
- // Transform mutations
107
- const mutations = mutationTypeDef?.fields
108
- ? mutationTypeDef.fields.map((field) => transformFieldToCleanOperation(field, 'mutation', types))
109
- : [];
110
- return { queries, mutations, typeRegistry };
111
- }
112
- // ============================================================================
113
- // Field to Operation Transformation
114
- // ============================================================================
115
- /**
116
- * Transform an introspection field to a CleanOperation
117
- */
118
- function transformFieldToCleanOperation(field, kind, types) {
119
- return {
120
- name: field.name,
121
- kind,
122
- args: field.args.map((arg) => transformInputValueToCleanArgument(arg, types)),
123
- returnType: transformTypeRefToCleanTypeRef(field.type, types),
124
- description: field.description ?? undefined,
125
- isDeprecated: field.isDeprecated,
126
- deprecationReason: field.deprecationReason ?? undefined,
127
- };
128
- }
129
- /**
130
- * Transform an input value to CleanArgument
131
- */
132
- function transformInputValueToCleanArgument(inputValue, types) {
133
- return {
134
- name: inputValue.name,
135
- type: transformTypeRefToCleanTypeRef(inputValue.type, types),
136
- defaultValue: inputValue.defaultValue ?? undefined,
137
- description: inputValue.description ?? undefined,
138
- };
139
- }
140
- // ============================================================================
141
- // Type Reference Transformation
142
- // ============================================================================
143
- /**
144
- * Transform an introspection TypeRef to CleanTypeRef
145
- * Recursively handles wrapper types (LIST, NON_NULL)
146
- *
147
- * NOTE: We intentionally do NOT resolve nested fields here to avoid
148
- * infinite recursion from circular type references. Fields are resolved
149
- * lazily via the TypeRegistry when needed for code generation.
150
- */
151
- function transformTypeRefToCleanTypeRef(typeRef, types) {
152
- const cleanRef = {
153
- kind: typeRef.kind,
154
- name: typeRef.name,
155
- };
156
- // Recursively transform ofType for wrappers (LIST, NON_NULL)
157
- if (typeRef.ofType) {
158
- cleanRef.ofType = transformTypeRefToCleanTypeRef(typeRef.ofType, types);
159
- }
160
- // For named types, only resolve enum values (they don't have circular refs)
161
- // Fields are NOT resolved here - they're resolved via TypeRegistry during codegen
162
- if (typeRef.name && !typeRef.ofType) {
163
- const typeDef = types.find((t) => t.name === typeRef.name);
164
- if (typeDef) {
165
- // Add enum values for ENUM types (safe, no recursion)
166
- if (typeDef.kind === 'ENUM' && typeDef.enumValues) {
167
- cleanRef.enumValues = typeDef.enumValues.map((ev) => ev.name);
168
- }
169
- // NOTE: OBJECT and INPUT_OBJECT fields are resolved via TypeRegistry
170
- // to avoid circular reference issues
171
- }
172
- }
173
- return cleanRef;
174
- }
175
- // ============================================================================
176
- // Operation Filtering
177
- // ============================================================================
178
- /**
179
- * Filter operations by include/exclude patterns
180
- * Uses glob-like patterns (supports * wildcard)
181
- */
182
- export function filterOperations(operations, include, exclude) {
183
- let result = operations;
184
- if (include && include.length > 0) {
185
- result = result.filter((op) => matchesPatterns(op.name, include));
186
- }
187
- if (exclude && exclude.length > 0) {
188
- result = result.filter((op) => !matchesPatterns(op.name, exclude));
189
- }
190
- return result;
191
- }
192
- /**
193
- * Check if a name matches any of the patterns
194
- * Supports simple glob patterns with * wildcard
195
- */
196
- function matchesPatterns(name, patterns) {
197
- return patterns.some((pattern) => {
198
- if (pattern === '*')
199
- return true;
200
- if (pattern.includes('*')) {
201
- const regex = new RegExp('^' + pattern.replace(/\*/g, '.*').replace(/\?/g, '.') + '$');
202
- return regex.test(name);
203
- }
204
- return name === pattern;
205
- });
206
- }
207
- /**
208
- * Get the set of table-related operation names from tables
209
- * Used to identify which operations are already covered by table generators
210
- *
211
- * IMPORTANT: This uses EXACT matches only from _meta.query fields.
212
- * Any operation not explicitly listed in _meta will flow through as a
213
- * custom operation, ensuring 100% coverage of the schema.
214
- *
215
- * Table operations (generated by table generators):
216
- * - Queries: all (list), one (single by PK)
217
- * - Mutations: create, update (by PK), delete (by PK)
218
- *
219
- * Custom operations (generated by custom operation generators):
220
- * - Unique constraint lookups: *ByUsername, *ByEmail, etc.
221
- * - Unique constraint mutations: update*By*, delete*By*
222
- * - True custom operations: login, register, bootstrapUser, etc.
223
- */
224
- export function getTableOperationNames(tables) {
225
- const queries = new Set();
226
- const mutations = new Set();
227
- for (const table of tables) {
228
- if (table.query) {
229
- // Add exact query names from _meta
230
- queries.add(table.query.all);
231
- if (table.query.one) {
232
- queries.add(table.query.one);
233
- }
234
- // Add exact mutation names from _meta
235
- mutations.add(table.query.create);
236
- if (table.query.update)
237
- mutations.add(table.query.update);
238
- if (table.query.delete)
239
- mutations.add(table.query.delete);
240
- }
241
- }
242
- return { queries, mutations };
243
- }
244
- /**
245
- * Check if an operation is a table operation (already handled by table generators)
246
- *
247
- * Uses EXACT match only - no pattern matching. This ensures:
248
- * 1. Only operations explicitly in _meta.query are treated as table operations
249
- * 2. All other operations (including update*By*, delete*By*) become custom operations
250
- * 3. 100% schema coverage is guaranteed
251
- */
252
- export function isTableOperation(operation, tableOperationNames) {
253
- if (operation.kind === 'query') {
254
- return tableOperationNames.queries.has(operation.name);
255
- }
256
- return tableOperationNames.mutations.has(operation.name);
257
- }
258
- /**
259
- * Get only custom operations (not covered by table generators)
260
- *
261
- * This returns ALL operations that are not exact matches for table CRUD operations.
262
- * Includes:
263
- * - Unique constraint queries (*ByUsername, *ByEmail, etc.)
264
- * - Unique constraint mutations (update*By*, delete*By*)
265
- * - True custom operations (login, register, bootstrapUser, etc.)
266
- */
267
- export function getCustomOperations(operations, tableOperationNames) {
268
- return operations.filter((op) => !isTableOperation(op, tableOperationNames));
269
- }
270
- // Re-export utility functions from introspection types
271
- export { getBaseTypeName, isNonNull, unwrapType };
4
+ export { buildTypeRegistry, transformSchemaToOperations, filterOperations, getTableOperationNames, isTableOperation, getCustomOperations, getBaseTypeName, isNonNull, unwrapType, } from '@constructive-io/graphql-query';
@@ -1,20 +1,4 @@
1
1
  /**
2
- * Table utility functions for CleanTable[]
3
- *
4
- * Note: The _meta transform functions have been removed.
5
- * Tables are now inferred from standard GraphQL introspection
6
- * using inferTablesFromIntrospection() in ./infer-tables.ts
2
+ * Re-export transform utilities from @constructive-io/graphql-query.
7
3
  */
8
- import type { CleanTable } from '../../types/schema';
9
- /**
10
- * Get table names from CleanTable array
11
- */
12
- export declare function getTableNames(tables: CleanTable[]): string[];
13
- /**
14
- * Find a table by name
15
- */
16
- export declare function findTable(tables: CleanTable[], name: string): CleanTable | undefined;
17
- /**
18
- * Filter tables by name pattern (glob-like)
19
- */
20
- export declare function filterTables(tables: CleanTable[], include?: string[], exclude?: string[]): CleanTable[];
4
+ export { filterTables, findTable, getTableNames, } from '@constructive-io/graphql-query';
@@ -1,38 +1,4 @@
1
1
  /**
2
- * Get table names from CleanTable array
2
+ * Re-export transform utilities from @constructive-io/graphql-query.
3
3
  */
4
- export function getTableNames(tables) {
5
- return tables.map((t) => t.name);
6
- }
7
- /**
8
- * Find a table by name
9
- */
10
- export function findTable(tables, name) {
11
- return tables.find((t) => t.name === name);
12
- }
13
- /**
14
- * Filter tables by name pattern (glob-like)
15
- */
16
- export function filterTables(tables, include, exclude) {
17
- let result = tables;
18
- if (include && include.length > 0) {
19
- result = result.filter((t) => matchesPatterns(t.name, include));
20
- }
21
- if (exclude && exclude.length > 0) {
22
- result = result.filter((t) => !matchesPatterns(t.name, exclude));
23
- }
24
- return result;
25
- }
26
- /**
27
- * Check if a name matches any of the patterns
28
- * Supports simple glob patterns with * wildcard
29
- */
30
- function matchesPatterns(name, patterns) {
31
- return patterns.some((pattern) => {
32
- if (pattern.includes('*')) {
33
- const regex = new RegExp('^' + pattern.replace(/\*/g, '.*').replace(/\?/g, '.') + '$');
34
- return regex.test(name);
35
- }
36
- return name === pattern;
37
- });
38
- }
4
+ export { filterTables, findTable, getTableNames, } from '@constructive-io/graphql-query';
@@ -1,65 +1,4 @@
1
- import type { MetaFieldType } from '../types';
2
- interface MetaSchemaField {
3
- name: string;
4
- type: MetaFieldType;
5
- }
6
- interface MetaSchemaConstraint {
7
- fields: MetaSchemaField[];
8
- }
9
- interface MetaSchemaForeignConstraint {
10
- fields: MetaSchemaField[];
11
- refFields: MetaSchemaField[];
12
- refTable: {
13
- name: string;
14
- };
15
- }
16
- interface MetaSchemaBelongsTo {
17
- keys: MetaSchemaField[];
18
- fieldName: string;
19
- }
20
- interface MetaSchemaRelations {
21
- belongsTo: MetaSchemaBelongsTo[];
22
- }
23
- interface MetaSchemaTable {
24
- name: string;
25
- fields: MetaSchemaField[];
26
- primaryKeyConstraints: MetaSchemaConstraint[];
27
- uniqueConstraints: MetaSchemaConstraint[];
28
- foreignKeyConstraints: MetaSchemaForeignConstraint[];
29
- relations: MetaSchemaRelations;
30
- }
31
- interface MetaSchemaInput {
32
- _meta: {
33
- tables: MetaSchemaTable[];
34
- };
35
- }
36
- interface ConvertedField {
37
- name: string;
38
- type: MetaFieldType;
39
- alias?: string;
40
- }
41
- interface ConvertedConstraint {
42
- name: string;
43
- type: MetaFieldType;
44
- alias?: string;
45
- }
46
- interface ConvertedForeignConstraint {
47
- refTable: string;
48
- fromKey: ConvertedField;
49
- toKey: ConvertedField;
50
- }
51
- interface ConvertedTable {
52
- name: string;
53
- fields: ConvertedField[];
54
- primaryConstraints: ConvertedConstraint[];
55
- uniqueConstraints: ConvertedConstraint[];
56
- foreignConstraints: ConvertedForeignConstraint[];
57
- }
58
- interface ConvertedMetaObject {
59
- tables: ConvertedTable[];
60
- }
61
1
  /**
62
- * Convert from raw _meta schema response to internal MetaObject format
2
+ * Re-export meta-object conversion from @constructive-io/graphql-query.
63
3
  */
64
- export declare function convertFromMetaSchema(metaSchema: MetaSchemaInput): ConvertedMetaObject;
65
- export {};
4
+ export { convertFromMetaSchema } from '@constructive-io/graphql-query';