@constructive-io/graphql-codegen 2.19.0 → 2.20.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/README.md +1818 -113
- package/__tests__/codegen/input-types-generator.test.d.ts +1 -0
- package/__tests__/codegen/input-types-generator.test.js +635 -0
- package/cli/codegen/barrel.d.ts +27 -0
- package/cli/codegen/barrel.js +163 -0
- package/cli/codegen/client.d.ts +4 -0
- package/cli/codegen/client.js +170 -0
- package/cli/codegen/custom-mutations.d.ts +38 -0
- package/cli/codegen/custom-mutations.js +149 -0
- package/cli/codegen/custom-queries.d.ts +38 -0
- package/cli/codegen/custom-queries.js +358 -0
- package/cli/codegen/filters.d.ts +27 -0
- package/cli/codegen/filters.js +357 -0
- package/cli/codegen/gql-ast.d.ts +41 -0
- package/cli/codegen/gql-ast.js +329 -0
- package/cli/codegen/index.d.ts +71 -0
- package/cli/codegen/index.js +147 -0
- package/cli/codegen/mutations.d.ts +30 -0
- package/cli/codegen/mutations.js +410 -0
- package/cli/codegen/orm/barrel.d.ts +18 -0
- package/cli/codegen/orm/barrel.js +48 -0
- package/cli/codegen/orm/client-generator.d.ts +45 -0
- package/cli/codegen/orm/client-generator.js +646 -0
- package/cli/codegen/orm/custom-ops-generator.d.ts +30 -0
- package/cli/codegen/orm/custom-ops-generator.js +350 -0
- package/cli/codegen/orm/index.d.ts +38 -0
- package/cli/codegen/orm/index.js +88 -0
- package/cli/codegen/orm/input-types-generator.d.ts +21 -0
- package/cli/codegen/orm/input-types-generator.js +705 -0
- package/cli/codegen/orm/input-types-generator.test.d.ts +1 -0
- package/cli/codegen/orm/input-types-generator.test.js +75 -0
- package/cli/codegen/orm/model-generator.d.ts +32 -0
- package/cli/codegen/orm/model-generator.js +264 -0
- package/cli/codegen/orm/query-builder.d.ts +161 -0
- package/cli/codegen/orm/query-builder.js +366 -0
- package/cli/codegen/orm/select-types.d.ts +169 -0
- package/cli/codegen/orm/select-types.js +16 -0
- package/cli/codegen/orm/select-types.test.d.ts +11 -0
- package/cli/codegen/orm/select-types.test.js +22 -0
- package/cli/codegen/queries.d.ts +25 -0
- package/cli/codegen/queries.js +438 -0
- package/cli/codegen/scalars.d.ts +12 -0
- package/cli/codegen/scalars.js +71 -0
- package/cli/codegen/schema-gql-ast.d.ts +51 -0
- package/cli/codegen/schema-gql-ast.js +385 -0
- package/cli/codegen/ts-ast.d.ts +122 -0
- package/cli/codegen/ts-ast.js +280 -0
- package/cli/codegen/type-resolver.d.ts +96 -0
- package/cli/codegen/type-resolver.js +246 -0
- package/cli/codegen/types.d.ts +12 -0
- package/cli/codegen/types.js +69 -0
- package/cli/codegen/utils.d.ts +163 -0
- package/cli/codegen/utils.js +326 -0
- package/cli/commands/generate-orm.d.ts +37 -0
- package/cli/commands/generate-orm.js +195 -0
- package/cli/commands/generate.d.ts +39 -0
- package/cli/commands/generate.js +299 -0
- package/cli/commands/index.d.ts +7 -0
- package/cli/commands/index.js +12 -0
- package/cli/commands/init.d.ts +35 -0
- package/cli/commands/init.js +176 -0
- package/cli/index.d.ts +4 -0
- package/cli/index.js +291 -0
- package/cli/introspect/fetch-meta.d.ts +31 -0
- package/cli/introspect/fetch-meta.js +108 -0
- package/cli/introspect/fetch-schema.d.ts +21 -0
- package/cli/introspect/fetch-schema.js +86 -0
- package/cli/introspect/index.d.ts +8 -0
- package/cli/introspect/index.js +16 -0
- package/cli/introspect/meta-query.d.ts +111 -0
- package/cli/introspect/meta-query.js +191 -0
- package/cli/introspect/schema-query.d.ts +20 -0
- package/cli/introspect/schema-query.js +123 -0
- package/cli/introspect/transform-schema.d.ts +74 -0
- package/cli/introspect/transform-schema.js +269 -0
- package/cli/introspect/transform-schema.test.d.ts +1 -0
- package/cli/introspect/transform-schema.test.js +67 -0
- package/cli/introspect/transform.d.ts +21 -0
- package/cli/introspect/transform.js +216 -0
- package/cli/watch/cache.d.ts +45 -0
- package/cli/watch/cache.js +111 -0
- package/cli/watch/debounce.d.ts +19 -0
- package/cli/watch/debounce.js +89 -0
- package/cli/watch/hash.d.ts +17 -0
- package/cli/watch/hash.js +48 -0
- package/cli/watch/index.d.ts +10 -0
- package/cli/watch/index.js +22 -0
- package/cli/watch/orchestrator.d.ts +63 -0
- package/cli/watch/orchestrator.js +228 -0
- package/cli/watch/poller.d.ts +65 -0
- package/cli/watch/poller.js +203 -0
- package/cli/watch/types.d.ts +67 -0
- package/cli/watch/types.js +5 -0
- package/client/error.d.ts +95 -0
- package/client/error.js +255 -0
- package/client/execute.d.ts +57 -0
- package/client/execute.js +124 -0
- package/client/index.d.ts +6 -0
- package/client/index.js +18 -0
- package/client/typed-document.d.ts +31 -0
- package/client/typed-document.js +44 -0
- package/core/ast.d.ts +10 -0
- package/core/ast.js +593 -0
- package/core/custom-ast.d.ts +35 -0
- package/core/custom-ast.js +204 -0
- package/core/index.d.ts +8 -0
- package/core/index.js +33 -0
- package/core/meta-object/convert.d.ts +65 -0
- package/core/meta-object/convert.js +63 -0
- package/core/meta-object/format.json +93 -0
- package/core/meta-object/index.d.ts +2 -0
- package/core/meta-object/index.js +18 -0
- package/core/meta-object/validate.d.ts +9 -0
- package/core/meta-object/validate.js +34 -0
- package/core/query-builder.d.ts +46 -0
- package/core/query-builder.js +412 -0
- package/core/types.d.ts +139 -0
- package/core/types.js +28 -0
- package/esm/__tests__/codegen/input-types-generator.test.d.ts +1 -0
- package/esm/__tests__/codegen/input-types-generator.test.js +633 -0
- package/esm/cli/codegen/barrel.d.ts +27 -0
- package/esm/cli/codegen/barrel.js +156 -0
- package/esm/cli/codegen/client.d.ts +4 -0
- package/esm/cli/codegen/client.js +167 -0
- package/esm/cli/codegen/custom-mutations.d.ts +38 -0
- package/esm/cli/codegen/custom-mutations.js +145 -0
- package/esm/cli/codegen/custom-queries.d.ts +38 -0
- package/esm/cli/codegen/custom-queries.js +354 -0
- package/esm/cli/codegen/filters.d.ts +27 -0
- package/esm/cli/codegen/filters.js +351 -0
- package/esm/cli/codegen/gql-ast.d.ts +41 -0
- package/esm/cli/codegen/gql-ast.js +288 -0
- package/esm/cli/codegen/index.d.ts +71 -0
- package/esm/cli/codegen/index.js +124 -0
- package/esm/cli/codegen/mutations.d.ts +30 -0
- package/esm/cli/codegen/mutations.js +404 -0
- package/esm/cli/codegen/orm/barrel.d.ts +18 -0
- package/esm/cli/codegen/orm/barrel.js +44 -0
- package/esm/cli/codegen/orm/client-generator.d.ts +45 -0
- package/esm/cli/codegen/orm/client-generator.js +640 -0
- package/esm/cli/codegen/orm/custom-ops-generator.d.ts +30 -0
- package/esm/cli/codegen/orm/custom-ops-generator.js +346 -0
- package/esm/cli/codegen/orm/index.d.ts +38 -0
- package/esm/cli/codegen/orm/index.js +75 -0
- package/esm/cli/codegen/orm/input-types-generator.d.ts +21 -0
- package/esm/cli/codegen/orm/input-types-generator.js +700 -0
- package/esm/cli/codegen/orm/input-types-generator.test.d.ts +1 -0
- package/esm/cli/codegen/orm/input-types-generator.test.js +73 -0
- package/esm/cli/codegen/orm/model-generator.d.ts +32 -0
- package/esm/cli/codegen/orm/model-generator.js +260 -0
- package/esm/cli/codegen/orm/query-builder.d.ts +161 -0
- package/esm/cli/codegen/orm/query-builder.js +353 -0
- package/esm/cli/codegen/orm/select-types.d.ts +169 -0
- package/esm/cli/codegen/orm/select-types.js +15 -0
- package/esm/cli/codegen/orm/select-types.test.d.ts +11 -0
- package/esm/cli/codegen/orm/select-types.test.js +21 -0
- package/esm/cli/codegen/queries.d.ts +25 -0
- package/esm/cli/codegen/queries.js +433 -0
- package/esm/cli/codegen/scalars.d.ts +12 -0
- package/esm/cli/codegen/scalars.js +66 -0
- package/esm/cli/codegen/schema-gql-ast.d.ts +51 -0
- package/esm/cli/codegen/schema-gql-ast.js +343 -0
- package/esm/cli/codegen/ts-ast.d.ts +122 -0
- package/esm/cli/codegen/ts-ast.js +260 -0
- package/esm/cli/codegen/type-resolver.d.ts +96 -0
- package/esm/cli/codegen/type-resolver.js +224 -0
- package/esm/cli/codegen/types.d.ts +12 -0
- package/esm/cli/codegen/types.js +65 -0
- package/esm/cli/codegen/utils.d.ts +163 -0
- package/esm/cli/codegen/utils.js +288 -0
- package/esm/cli/commands/generate-orm.d.ts +37 -0
- package/esm/cli/commands/generate-orm.js +192 -0
- package/esm/cli/commands/generate.d.ts +39 -0
- package/esm/cli/commands/generate.js +262 -0
- package/esm/cli/commands/index.d.ts +7 -0
- package/esm/cli/commands/index.js +5 -0
- package/esm/cli/commands/init.d.ts +35 -0
- package/esm/cli/commands/init.js +138 -0
- package/esm/cli/index.d.ts +4 -0
- package/esm/cli/index.js +256 -0
- package/esm/cli/introspect/fetch-meta.d.ts +31 -0
- package/esm/cli/introspect/fetch-meta.js +104 -0
- package/esm/cli/introspect/fetch-schema.d.ts +21 -0
- package/esm/cli/introspect/fetch-schema.js +83 -0
- package/esm/cli/introspect/index.d.ts +8 -0
- package/esm/cli/introspect/index.js +6 -0
- package/esm/cli/introspect/meta-query.d.ts +111 -0
- package/esm/cli/introspect/meta-query.js +188 -0
- package/esm/cli/introspect/schema-query.d.ts +20 -0
- package/esm/cli/introspect/schema-query.js +120 -0
- package/esm/cli/introspect/transform-schema.d.ts +74 -0
- package/esm/cli/introspect/transform-schema.js +259 -0
- package/esm/cli/introspect/transform-schema.test.d.ts +1 -0
- package/esm/cli/introspect/transform-schema.test.js +65 -0
- package/esm/cli/introspect/transform.d.ts +21 -0
- package/esm/cli/introspect/transform.js +210 -0
- package/esm/cli/watch/cache.d.ts +45 -0
- package/esm/cli/watch/cache.js +73 -0
- package/esm/cli/watch/debounce.d.ts +19 -0
- package/esm/cli/watch/debounce.js +85 -0
- package/esm/cli/watch/hash.d.ts +17 -0
- package/esm/cli/watch/hash.js +43 -0
- package/esm/cli/watch/index.d.ts +10 -0
- package/esm/cli/watch/index.js +8 -0
- package/esm/cli/watch/orchestrator.d.ts +63 -0
- package/esm/cli/watch/orchestrator.js +223 -0
- package/esm/cli/watch/poller.d.ts +65 -0
- package/esm/cli/watch/poller.js +198 -0
- package/esm/cli/watch/types.d.ts +67 -0
- package/esm/cli/watch/types.js +4 -0
- package/esm/client/error.d.ts +95 -0
- package/esm/client/error.js +249 -0
- package/esm/client/execute.d.ts +57 -0
- package/esm/client/execute.js +120 -0
- package/esm/client/index.d.ts +6 -0
- package/esm/client/index.js +6 -0
- package/esm/client/typed-document.d.ts +31 -0
- package/esm/client/typed-document.js +40 -0
- package/esm/core/ast.d.ts +10 -0
- package/esm/core/ast.js +549 -0
- package/esm/core/custom-ast.d.ts +35 -0
- package/esm/core/custom-ast.js +161 -0
- package/esm/core/index.d.ts +8 -0
- package/esm/core/index.js +12 -0
- package/esm/core/meta-object/convert.d.ts +65 -0
- package/esm/core/meta-object/convert.js +60 -0
- package/esm/core/meta-object/format.json +93 -0
- package/esm/core/meta-object/index.d.ts +2 -0
- package/esm/core/meta-object/index.js +2 -0
- package/esm/core/meta-object/validate.d.ts +9 -0
- package/esm/core/meta-object/validate.js +28 -0
- package/esm/core/query-builder.d.ts +46 -0
- package/esm/core/query-builder.js +375 -0
- package/esm/core/types.d.ts +139 -0
- package/esm/core/types.js +24 -0
- package/esm/generators/field-selector.d.ts +30 -0
- package/esm/generators/field-selector.js +355 -0
- package/esm/generators/index.d.ts +6 -0
- package/esm/generators/index.js +9 -0
- package/esm/generators/mutations.d.ts +31 -0
- package/esm/generators/mutations.js +197 -0
- package/esm/generators/select.d.ts +50 -0
- package/esm/generators/select.js +636 -0
- package/esm/index.d.ts +12 -0
- package/esm/index.js +17 -3
- package/esm/react/index.d.ts +5 -0
- package/esm/react/index.js +6 -0
- package/esm/types/config.d.ts +199 -0
- package/esm/types/config.js +106 -0
- package/esm/types/index.d.ts +9 -0
- package/esm/types/index.js +4 -0
- package/esm/types/introspection.d.ts +121 -0
- package/esm/types/introspection.js +54 -0
- package/esm/types/mutation.d.ts +45 -0
- package/esm/types/mutation.js +4 -0
- package/esm/types/query.d.ts +82 -0
- package/esm/types/query.js +4 -0
- package/esm/types/schema.d.ts +253 -0
- package/esm/types/schema.js +5 -0
- package/esm/types/selection.d.ts +43 -0
- package/esm/types/selection.js +4 -0
- package/esm/utils/index.d.ts +4 -0
- package/esm/utils/index.js +4 -0
- package/generators/field-selector.d.ts +30 -0
- package/generators/field-selector.js +361 -0
- package/generators/index.d.ts +6 -0
- package/generators/index.js +27 -0
- package/generators/mutations.d.ts +31 -0
- package/generators/mutations.js +235 -0
- package/generators/select.d.ts +50 -0
- package/generators/select.js +679 -0
- package/index.d.ts +12 -3
- package/index.js +19 -3
- package/package.json +59 -38
- package/react/index.d.ts +5 -0
- package/react/index.js +9 -0
- package/types/config.d.ts +199 -0
- package/types/config.js +111 -0
- package/types/index.d.ts +9 -0
- package/types/index.js +10 -0
- package/types/introspection.d.ts +121 -0
- package/types/introspection.js +62 -0
- package/types/mutation.d.ts +45 -0
- package/types/mutation.js +5 -0
- package/types/query.d.ts +82 -0
- package/types/query.js +5 -0
- package/types/schema.d.ts +253 -0
- package/types/schema.js +6 -0
- package/types/selection.d.ts +43 -0
- package/types/selection.js +5 -0
- package/utils/index.d.ts +4 -0
- package/utils/index.js +7 -0
- package/codegen.d.ts +0 -13
- package/codegen.js +0 -293
- package/esm/codegen.js +0 -253
- package/esm/gql.js +0 -939
- package/esm/options.js +0 -27
- package/gql.d.ts +0 -188
- package/gql.js +0 -992
- package/options.d.ts +0 -45
- package/options.js +0 -31
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core schema types for representing PostGraphile table metadata
|
|
3
|
+
* These are "clean" versions that remove nullable/undefined complexity
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Represents a database table with its fields and relations
|
|
7
|
+
*/
|
|
8
|
+
export interface CleanTable {
|
|
9
|
+
name: string;
|
|
10
|
+
fields: CleanField[];
|
|
11
|
+
relations: CleanRelations;
|
|
12
|
+
/** PostGraphile inflection rules for this table */
|
|
13
|
+
inflection?: TableInflection;
|
|
14
|
+
/** Query operation names from _meta */
|
|
15
|
+
query?: TableQueryNames;
|
|
16
|
+
/** Constraint information */
|
|
17
|
+
constraints?: TableConstraints;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* PostGraphile-generated names for this table
|
|
21
|
+
*/
|
|
22
|
+
export interface TableInflection {
|
|
23
|
+
/** All rows connection query name (e.g., "users") */
|
|
24
|
+
allRows: string;
|
|
25
|
+
/** Simple all rows query name */
|
|
26
|
+
allRowsSimple: string;
|
|
27
|
+
/** Condition type name (e.g., "UserCondition") */
|
|
28
|
+
conditionType: string;
|
|
29
|
+
/** Connection type name (e.g., "UsersConnection") */
|
|
30
|
+
connection: string;
|
|
31
|
+
/** Create field name */
|
|
32
|
+
createField: string;
|
|
33
|
+
/** Create input type (e.g., "CreateUserInput") */
|
|
34
|
+
createInputType: string;
|
|
35
|
+
/** Create payload type */
|
|
36
|
+
createPayloadType: string;
|
|
37
|
+
/** Delete by primary key mutation name */
|
|
38
|
+
deleteByPrimaryKey: string | null;
|
|
39
|
+
/** Delete payload type */
|
|
40
|
+
deletePayloadType: string;
|
|
41
|
+
/** Edge type name */
|
|
42
|
+
edge: string;
|
|
43
|
+
/** Edge field name */
|
|
44
|
+
edgeField: string;
|
|
45
|
+
/** Enum type name */
|
|
46
|
+
enumType: string;
|
|
47
|
+
/** Filter type name (e.g., "UserFilter") */
|
|
48
|
+
filterType: string | null;
|
|
49
|
+
/** Input type name (e.g., "UserInput") */
|
|
50
|
+
inputType: string;
|
|
51
|
+
/** OrderBy enum type (e.g., "UsersOrderBy") */
|
|
52
|
+
orderByType: string;
|
|
53
|
+
/** Patch field name */
|
|
54
|
+
patchField: string;
|
|
55
|
+
/** Patch type (e.g., "UserPatch") */
|
|
56
|
+
patchType: string | null;
|
|
57
|
+
/** Table field name (singular, e.g., "user") */
|
|
58
|
+
tableFieldName: string;
|
|
59
|
+
/** Table type name (e.g., "User") */
|
|
60
|
+
tableType: string;
|
|
61
|
+
/** Type name */
|
|
62
|
+
typeName: string;
|
|
63
|
+
/** Update by primary key mutation name */
|
|
64
|
+
updateByPrimaryKey: string | null;
|
|
65
|
+
/** Update payload type */
|
|
66
|
+
updatePayloadType: string | null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Query operation names from _meta.query
|
|
70
|
+
*/
|
|
71
|
+
export interface TableQueryNames {
|
|
72
|
+
/** All rows query name */
|
|
73
|
+
all: string;
|
|
74
|
+
/** Single row query name */
|
|
75
|
+
one: string;
|
|
76
|
+
/** Create mutation name */
|
|
77
|
+
create: string;
|
|
78
|
+
/** Update mutation name */
|
|
79
|
+
update: string | null;
|
|
80
|
+
/** Delete mutation name */
|
|
81
|
+
delete: string | null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Table constraints
|
|
85
|
+
*/
|
|
86
|
+
export interface TableConstraints {
|
|
87
|
+
primaryKey: ConstraintInfo[];
|
|
88
|
+
foreignKey: ForeignKeyConstraint[];
|
|
89
|
+
unique: ConstraintInfo[];
|
|
90
|
+
}
|
|
91
|
+
export interface ConstraintInfo {
|
|
92
|
+
name: string;
|
|
93
|
+
fields: CleanField[];
|
|
94
|
+
}
|
|
95
|
+
export interface ForeignKeyConstraint extends ConstraintInfo {
|
|
96
|
+
refTable: string;
|
|
97
|
+
refFields: CleanField[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Represents a field/column in a table
|
|
101
|
+
*/
|
|
102
|
+
export interface CleanField {
|
|
103
|
+
name: string;
|
|
104
|
+
type: CleanFieldType;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Field type information from PostGraphile introspection
|
|
108
|
+
*/
|
|
109
|
+
export interface CleanFieldType {
|
|
110
|
+
/** GraphQL type name (e.g., "String", "UUID", "Int") */
|
|
111
|
+
gqlType: string;
|
|
112
|
+
/** Whether this is an array type */
|
|
113
|
+
isArray: boolean;
|
|
114
|
+
/** Type modifier (for precision, length, etc.) */
|
|
115
|
+
modifier?: string | number | null;
|
|
116
|
+
/** PostgreSQL type alias (domain name) */
|
|
117
|
+
pgAlias?: string | null;
|
|
118
|
+
/** PostgreSQL native type (e.g., "text", "uuid", "integer") */
|
|
119
|
+
pgType?: string | null;
|
|
120
|
+
/** Subtype for composite types */
|
|
121
|
+
subtype?: string | null;
|
|
122
|
+
/** Type modifier from PostgreSQL */
|
|
123
|
+
typmod?: number | null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* All relation types for a table
|
|
127
|
+
*/
|
|
128
|
+
export interface CleanRelations {
|
|
129
|
+
belongsTo: CleanBelongsToRelation[];
|
|
130
|
+
hasOne: CleanHasOneRelation[];
|
|
131
|
+
hasMany: CleanHasManyRelation[];
|
|
132
|
+
manyToMany: CleanManyToManyRelation[];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* BelongsTo relation (foreign key on this table)
|
|
136
|
+
*/
|
|
137
|
+
export interface CleanBelongsToRelation {
|
|
138
|
+
fieldName: string | null;
|
|
139
|
+
isUnique: boolean;
|
|
140
|
+
referencesTable: string;
|
|
141
|
+
type: string | null;
|
|
142
|
+
keys: CleanField[];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* HasOne relation (foreign key on other table, unique)
|
|
146
|
+
*/
|
|
147
|
+
export interface CleanHasOneRelation {
|
|
148
|
+
fieldName: string | null;
|
|
149
|
+
isUnique: boolean;
|
|
150
|
+
referencedByTable: string;
|
|
151
|
+
type: string | null;
|
|
152
|
+
keys: CleanField[];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* HasMany relation (foreign key on other table, not unique)
|
|
156
|
+
*/
|
|
157
|
+
export interface CleanHasManyRelation {
|
|
158
|
+
fieldName: string | null;
|
|
159
|
+
isUnique: boolean;
|
|
160
|
+
referencedByTable: string;
|
|
161
|
+
type: string | null;
|
|
162
|
+
keys: CleanField[];
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* ManyToMany relation (through junction table)
|
|
166
|
+
*/
|
|
167
|
+
export interface CleanManyToManyRelation {
|
|
168
|
+
fieldName: string | null;
|
|
169
|
+
rightTable: string;
|
|
170
|
+
junctionTable: string;
|
|
171
|
+
type: string | null;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Clean representation of a GraphQL operation (query or mutation)
|
|
175
|
+
* Derived from introspection data
|
|
176
|
+
*/
|
|
177
|
+
export interface CleanOperation {
|
|
178
|
+
/** Operation name (e.g., "login", "currentUser", "cars") */
|
|
179
|
+
name: string;
|
|
180
|
+
/** Operation kind */
|
|
181
|
+
kind: 'query' | 'mutation';
|
|
182
|
+
/** Arguments/variables for the operation */
|
|
183
|
+
args: CleanArgument[];
|
|
184
|
+
/** Return type */
|
|
185
|
+
returnType: CleanTypeRef;
|
|
186
|
+
/** Description from schema */
|
|
187
|
+
description?: string;
|
|
188
|
+
/** Whether this is deprecated */
|
|
189
|
+
isDeprecated?: boolean;
|
|
190
|
+
/** Deprecation reason */
|
|
191
|
+
deprecationReason?: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Clean representation of an operation argument
|
|
195
|
+
*/
|
|
196
|
+
export interface CleanArgument {
|
|
197
|
+
/** Argument name */
|
|
198
|
+
name: string;
|
|
199
|
+
/** Argument type */
|
|
200
|
+
type: CleanTypeRef;
|
|
201
|
+
/** Default value (as string) */
|
|
202
|
+
defaultValue?: string;
|
|
203
|
+
/** Description from schema */
|
|
204
|
+
description?: string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Clean type reference - simplified from introspection TypeRef
|
|
208
|
+
*/
|
|
209
|
+
export interface CleanTypeRef {
|
|
210
|
+
/** Type kind */
|
|
211
|
+
kind: 'SCALAR' | 'OBJECT' | 'INPUT_OBJECT' | 'ENUM' | 'LIST' | 'NON_NULL';
|
|
212
|
+
/** Type name (null for LIST and NON_NULL wrappers) */
|
|
213
|
+
name: string | null;
|
|
214
|
+
/** Inner type for LIST and NON_NULL wrappers */
|
|
215
|
+
ofType?: CleanTypeRef;
|
|
216
|
+
/** Resolved TypeScript type string */
|
|
217
|
+
tsType?: string;
|
|
218
|
+
/** Fields for OBJECT types */
|
|
219
|
+
fields?: CleanObjectField[];
|
|
220
|
+
/** Input fields for INPUT_OBJECT types */
|
|
221
|
+
inputFields?: CleanArgument[];
|
|
222
|
+
/** Values for ENUM types */
|
|
223
|
+
enumValues?: string[];
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Field on an object type
|
|
227
|
+
*/
|
|
228
|
+
export interface CleanObjectField {
|
|
229
|
+
/** Field name */
|
|
230
|
+
name: string;
|
|
231
|
+
/** Field type */
|
|
232
|
+
type: CleanTypeRef;
|
|
233
|
+
/** Description */
|
|
234
|
+
description?: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Registry of all types in the schema for resolution
|
|
238
|
+
*/
|
|
239
|
+
export type TypeRegistry = Map<string, ResolvedType>;
|
|
240
|
+
/**
|
|
241
|
+
* Resolved type with all details populated
|
|
242
|
+
*/
|
|
243
|
+
export interface ResolvedType {
|
|
244
|
+
kind: 'SCALAR' | 'OBJECT' | 'INPUT_OBJECT' | 'ENUM' | 'INTERFACE' | 'UNION';
|
|
245
|
+
name: string;
|
|
246
|
+
description?: string;
|
|
247
|
+
/** Fields for OBJECT types */
|
|
248
|
+
fields?: CleanObjectField[];
|
|
249
|
+
/** Input fields for INPUT_OBJECT types */
|
|
250
|
+
inputFields?: CleanArgument[];
|
|
251
|
+
/** Values for ENUM types */
|
|
252
|
+
enumValues?: string[];
|
|
253
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field selection types for controlling which fields are included in queries
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Simple field selection options
|
|
6
|
+
*/
|
|
7
|
+
export interface SimpleFieldSelection {
|
|
8
|
+
/** Specific fields to include */
|
|
9
|
+
select?: string[];
|
|
10
|
+
/** Relations to include with their fields */
|
|
11
|
+
include?: Record<string, string[] | boolean>;
|
|
12
|
+
/** Simple relation inclusion (just names) */
|
|
13
|
+
includeRelations?: string[];
|
|
14
|
+
/** Fields to exclude */
|
|
15
|
+
exclude?: string[];
|
|
16
|
+
/** Maximum depth for nested relations */
|
|
17
|
+
maxDepth?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Predefined field selection presets
|
|
21
|
+
*/
|
|
22
|
+
export type FieldSelectionPreset =
|
|
23
|
+
/** Just id and primary display field */
|
|
24
|
+
'minimal'
|
|
25
|
+
/** Common display fields */
|
|
26
|
+
| 'display'
|
|
27
|
+
/** All scalar fields */
|
|
28
|
+
| 'all'
|
|
29
|
+
/** All fields including relations */
|
|
30
|
+
| 'full';
|
|
31
|
+
/**
|
|
32
|
+
* Main field selection type - preset or custom
|
|
33
|
+
*/
|
|
34
|
+
export type FieldSelection = FieldSelectionPreset | SimpleFieldSelection;
|
|
35
|
+
/**
|
|
36
|
+
* Internal selection options format used by query builder
|
|
37
|
+
*/
|
|
38
|
+
export interface SelectionOptions {
|
|
39
|
+
[fieldName: string]: boolean | {
|
|
40
|
+
select: Record<string, boolean>;
|
|
41
|
+
variables?: Record<string, unknown>;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -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 '../core/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
|
+
};
|