@constructive-io/data 0.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.
- package/LICENSE +21 -0
- package/README.md +34 -0
- package/dist/index.cjs +5837 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2616 -0
- package/dist/index.d.ts +2616 -0
- package/dist/index.js +5714 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2616 @@
|
|
|
1
|
+
import { DocumentNode, FieldNode, SelectionSetNode, VariableDefinitionNode } from 'graphql';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Runtime types for Constructive's PostGraphile `_meta` contract.
|
|
5
|
+
*
|
|
6
|
+
* `_meta` describes database facts that standard GraphQL introspection cannot:
|
|
7
|
+
* exact table inflections, PostgreSQL scalar encodings, relations, constraints,
|
|
8
|
+
* and Constructive capabilities such as storage, search, i18n, realtime, and
|
|
9
|
+
* provisioning scope. Standard introspection remains the source of truth for
|
|
10
|
+
* operation arguments, input objects, enums, pagination, and custom operations.
|
|
11
|
+
*/
|
|
12
|
+
interface MetaQuery {
|
|
13
|
+
__typename?: 'Query';
|
|
14
|
+
_meta?: Metaschema | null;
|
|
15
|
+
}
|
|
16
|
+
interface Metaschema {
|
|
17
|
+
__typename?: 'MetaSchema' | 'Metaschema';
|
|
18
|
+
tables?: Array<MetaschemaTable | null> | null;
|
|
19
|
+
}
|
|
20
|
+
/** Preferred current-contract name. `Metaschema` remains for API compatibility. */
|
|
21
|
+
type MetaSchema = Metaschema;
|
|
22
|
+
interface MetaschemaTable {
|
|
23
|
+
__typename?: 'MetaTable' | 'MetaschemaTable';
|
|
24
|
+
name: string;
|
|
25
|
+
schemaName?: string | null;
|
|
26
|
+
query?: MetaschemaTableQuery | null;
|
|
27
|
+
fields?: Array<MetaschemaField | null> | null;
|
|
28
|
+
inflection?: MetaschemaTableInflection | null;
|
|
29
|
+
indexes?: Array<MetaschemaIndex | null> | null;
|
|
30
|
+
constraints?: MetaschemaConstraints | MetaschemaConstraint[] | null;
|
|
31
|
+
foreignKeyConstraints?: Array<MetaschemaForeignKeyConstraint | null> | null;
|
|
32
|
+
primaryKeyConstraints?: Array<MetaschemaPrimaryKeyConstraint | null> | null;
|
|
33
|
+
uniqueConstraints?: Array<MetaschemaUniqueConstraint | null> | null;
|
|
34
|
+
relations?: MetaschemaTableRelation | null;
|
|
35
|
+
storage?: MetaschemaStorage | null;
|
|
36
|
+
search?: MetaschemaSearch | null;
|
|
37
|
+
i18n?: MetaschemaI18n | null;
|
|
38
|
+
realtime?: MetaschemaRealtime | null;
|
|
39
|
+
scope?: MetaschemaScope | null;
|
|
40
|
+
/** @deprecated Legacy pre-July contract field. */
|
|
41
|
+
checkConstraints?: Array<MetaschemaCheckConstraint | null> | null;
|
|
42
|
+
/** @deprecated Legacy pre-July contract field. */
|
|
43
|
+
exclusionConstraints?: Array<MetaschemaExclusionConstraint | null> | null;
|
|
44
|
+
}
|
|
45
|
+
interface MetaschemaTableQuery {
|
|
46
|
+
__typename?: 'MetaQuery';
|
|
47
|
+
all: string;
|
|
48
|
+
one?: string | null;
|
|
49
|
+
create?: string | null;
|
|
50
|
+
update?: string | null;
|
|
51
|
+
delete?: string | null;
|
|
52
|
+
}
|
|
53
|
+
interface MetaschemaField {
|
|
54
|
+
__typename?: 'MetaField';
|
|
55
|
+
name: string;
|
|
56
|
+
type: MetaschemaType;
|
|
57
|
+
isNotNull?: boolean | null;
|
|
58
|
+
hasDefault?: boolean | null;
|
|
59
|
+
isPrimaryKey?: boolean | null;
|
|
60
|
+
isForeignKey?: boolean | null;
|
|
61
|
+
description?: string | null;
|
|
62
|
+
enumValues?: MetaschemaEnum | null;
|
|
63
|
+
}
|
|
64
|
+
interface MetaschemaEnum {
|
|
65
|
+
__typename?: 'MetaEnum';
|
|
66
|
+
name: string;
|
|
67
|
+
values: string[];
|
|
68
|
+
}
|
|
69
|
+
type ScalarEncodingKind = 'bigint' | 'datetime' | 'date' | 'time' | 'interval' | 'uuid' | 'geojson' | 'point' | 'inet' | 'ltree' | 'vector' | 'bytea' | 'composite';
|
|
70
|
+
interface MetaschemaScalarEncoding {
|
|
71
|
+
__typename?: 'MetaScalarEncoding';
|
|
72
|
+
kind: ScalarEncodingKind;
|
|
73
|
+
elementType?: string | null;
|
|
74
|
+
dimensions?: number | null;
|
|
75
|
+
geometrySubtype?: string | null;
|
|
76
|
+
srid?: number | null;
|
|
77
|
+
dotPath?: boolean | null;
|
|
78
|
+
}
|
|
79
|
+
interface MetaschemaType {
|
|
80
|
+
__typename?: 'MetaType' | 'MetaschemaType';
|
|
81
|
+
gqlType: string;
|
|
82
|
+
isArray: boolean;
|
|
83
|
+
pgType: string;
|
|
84
|
+
isNotNull?: boolean | null;
|
|
85
|
+
hasDefault?: boolean | null;
|
|
86
|
+
subtype?: string | null;
|
|
87
|
+
encoding?: MetaschemaScalarEncoding | null;
|
|
88
|
+
/** @deprecated Legacy pre-July contract field. */
|
|
89
|
+
modifier?: number | null;
|
|
90
|
+
/** @deprecated Legacy pre-July contract field. */
|
|
91
|
+
pgAlias?: string | null;
|
|
92
|
+
/** @deprecated Legacy pre-July contract field. */
|
|
93
|
+
typmod?: number | null;
|
|
94
|
+
}
|
|
95
|
+
/** Preferred current-contract name. */
|
|
96
|
+
type MetaType = MetaschemaType;
|
|
97
|
+
interface MetaschemaTableInflection {
|
|
98
|
+
__typename?: 'MetaInflection';
|
|
99
|
+
tableType?: string | null;
|
|
100
|
+
allRows?: string | null;
|
|
101
|
+
connection?: string | null;
|
|
102
|
+
edge?: string | null;
|
|
103
|
+
filterType?: string | null;
|
|
104
|
+
orderByType?: string | null;
|
|
105
|
+
conditionType?: string | null;
|
|
106
|
+
patchType?: string | null;
|
|
107
|
+
createInputType?: string | null;
|
|
108
|
+
createPayloadType?: string | null;
|
|
109
|
+
updatePayloadType?: string | null;
|
|
110
|
+
deletePayloadType?: string | null;
|
|
111
|
+
/** @deprecated Legacy pre-July contract fields retained for source compatibility. */
|
|
112
|
+
allRowsSimple?: string | null;
|
|
113
|
+
createField?: string | null;
|
|
114
|
+
deleteByPrimaryKey?: string | null;
|
|
115
|
+
edgeField?: string | null;
|
|
116
|
+
enumType?: string | null;
|
|
117
|
+
inputType?: string | null;
|
|
118
|
+
patchField?: string | null;
|
|
119
|
+
tableFieldName?: string | null;
|
|
120
|
+
typeName?: string | null;
|
|
121
|
+
updateByPrimaryKey?: string | null;
|
|
122
|
+
}
|
|
123
|
+
interface MetaschemaIndex {
|
|
124
|
+
__typename?: 'MetaIndex';
|
|
125
|
+
name: string;
|
|
126
|
+
isUnique?: boolean | null;
|
|
127
|
+
isPrimary?: boolean | null;
|
|
128
|
+
columns?: string[] | null;
|
|
129
|
+
fields?: Array<MetaschemaField | null> | null;
|
|
130
|
+
}
|
|
131
|
+
interface MetaschemaConstraints {
|
|
132
|
+
__typename?: 'MetaConstraints';
|
|
133
|
+
primaryKey?: MetaschemaPrimaryKeyConstraint | null;
|
|
134
|
+
unique?: Array<MetaschemaUniqueConstraint | null> | null;
|
|
135
|
+
foreignKey?: Array<MetaschemaForeignKeyConstraint | null> | null;
|
|
136
|
+
}
|
|
137
|
+
/** Legacy flat constraint union retained for cached pre-July metadata. */
|
|
138
|
+
type MetaschemaConstraint = MetaschemaCheckConstraint | MetaschemaExclusionConstraint | MetaschemaForeignKeyConstraint | MetaschemaPrimaryKeyConstraint | MetaschemaUniqueConstraint;
|
|
139
|
+
interface MetaschemaCheckConstraint {
|
|
140
|
+
__typename?: 'MetaschemaCheckConstraint';
|
|
141
|
+
name: string;
|
|
142
|
+
fields?: Array<MetaschemaField | null> | null;
|
|
143
|
+
}
|
|
144
|
+
interface MetaschemaExclusionConstraint {
|
|
145
|
+
__typename?: 'MetaschemaExclusionConstraint';
|
|
146
|
+
name: string;
|
|
147
|
+
fields?: Array<MetaschemaField | null> | null;
|
|
148
|
+
}
|
|
149
|
+
interface MetaschemaForeignKeyConstraint {
|
|
150
|
+
__typename?: 'MetaForeignKeyConstraint';
|
|
151
|
+
name: string;
|
|
152
|
+
fields?: Array<MetaschemaField | null> | null;
|
|
153
|
+
referencedTable?: string | null;
|
|
154
|
+
referencedFields?: string[] | null;
|
|
155
|
+
refFields?: Array<MetaschemaField | null> | null;
|
|
156
|
+
refTable?: MetaschemaTableReference | null;
|
|
157
|
+
}
|
|
158
|
+
interface MetaschemaPrimaryKeyConstraint {
|
|
159
|
+
__typename?: 'MetaPrimaryKeyConstraint';
|
|
160
|
+
name: string;
|
|
161
|
+
fields?: Array<MetaschemaField | null> | null;
|
|
162
|
+
}
|
|
163
|
+
interface MetaschemaUniqueConstraint {
|
|
164
|
+
__typename?: 'MetaUniqueConstraint';
|
|
165
|
+
name: string;
|
|
166
|
+
fields?: Array<MetaschemaField | null> | null;
|
|
167
|
+
}
|
|
168
|
+
interface MetaschemaTableReference {
|
|
169
|
+
__typename?: 'MetaRefTable' | 'MetaschemaTable';
|
|
170
|
+
name: string;
|
|
171
|
+
}
|
|
172
|
+
interface MetaschemaTableRelation {
|
|
173
|
+
__typename?: 'MetaRelations';
|
|
174
|
+
belongsTo?: Array<MetaschemaTableBelongsToRelation | null> | null;
|
|
175
|
+
has?: Array<MetaschemaTableHasRelation | null> | null;
|
|
176
|
+
hasOne?: Array<MetaschemaTableHasRelation | null> | null;
|
|
177
|
+
hasMany?: Array<MetaschemaTableHasRelation | null> | null;
|
|
178
|
+
manyToMany?: Array<MetaschemaTableManyToManyRelation | null> | null;
|
|
179
|
+
}
|
|
180
|
+
interface MetaschemaTableBelongsToRelation {
|
|
181
|
+
__typename?: 'MetaBelongsToRelation';
|
|
182
|
+
fieldName?: string | null;
|
|
183
|
+
isUnique: boolean;
|
|
184
|
+
type?: string | null;
|
|
185
|
+
keys?: Array<MetaschemaField | null> | null;
|
|
186
|
+
references: MetaschemaTableReference;
|
|
187
|
+
}
|
|
188
|
+
interface MetaschemaTableHasRelation {
|
|
189
|
+
__typename?: 'MetaHasRelation';
|
|
190
|
+
fieldName?: string | null;
|
|
191
|
+
isUnique: boolean;
|
|
192
|
+
type?: string | null;
|
|
193
|
+
keys?: Array<MetaschemaField | null> | null;
|
|
194
|
+
referencedBy: MetaschemaTableReference;
|
|
195
|
+
/** @deprecated Legacy pre-July contract field. */
|
|
196
|
+
foreignKeys?: Array<MetaschemaField | null> | null;
|
|
197
|
+
}
|
|
198
|
+
interface MetaschemaTableManyToManyRelation {
|
|
199
|
+
__typename?: 'MetaManyToManyRelation';
|
|
200
|
+
fieldName?: string | null;
|
|
201
|
+
type?: string | null;
|
|
202
|
+
junctionLeftConstraint: MetaschemaForeignKeyConstraint;
|
|
203
|
+
junctionLeftKeyAttributes: Array<MetaschemaField | null>;
|
|
204
|
+
junctionRightConstraint: MetaschemaForeignKeyConstraint;
|
|
205
|
+
junctionRightKeyAttributes: Array<MetaschemaField | null>;
|
|
206
|
+
junctionTable: MetaschemaTableReference;
|
|
207
|
+
leftKeyAttributes: Array<MetaschemaField | null>;
|
|
208
|
+
rightKeyAttributes: Array<MetaschemaField | null>;
|
|
209
|
+
rightTable: MetaschemaTableReference;
|
|
210
|
+
}
|
|
211
|
+
interface MetaschemaStorage {
|
|
212
|
+
__typename?: 'MetaStorage';
|
|
213
|
+
isFilesTable: boolean;
|
|
214
|
+
isBucketsTable: boolean;
|
|
215
|
+
}
|
|
216
|
+
interface MetaschemaSearchColumn {
|
|
217
|
+
__typename?: 'MetaSearchColumn';
|
|
218
|
+
name: string;
|
|
219
|
+
algorithm: string;
|
|
220
|
+
}
|
|
221
|
+
interface MetaschemaSearchConfig {
|
|
222
|
+
__typename?: 'MetaSearchConfig';
|
|
223
|
+
/** JSON-encoded `Record<string, number>` at the GraphQL boundary. */
|
|
224
|
+
weights?: string | null;
|
|
225
|
+
boostRecent: boolean;
|
|
226
|
+
boostRecencyField?: string | null;
|
|
227
|
+
boostRecencyDecay?: number | null;
|
|
228
|
+
}
|
|
229
|
+
interface MetaschemaSearch {
|
|
230
|
+
__typename?: 'MetaSearch';
|
|
231
|
+
algorithms: string[];
|
|
232
|
+
columns: Array<MetaschemaSearchColumn | null>;
|
|
233
|
+
hasUnifiedSearch: boolean;
|
|
234
|
+
config?: MetaschemaSearchConfig | null;
|
|
235
|
+
}
|
|
236
|
+
interface MetaschemaI18nField {
|
|
237
|
+
__typename?: 'MetaI18nField';
|
|
238
|
+
name: string;
|
|
239
|
+
type: string;
|
|
240
|
+
}
|
|
241
|
+
interface MetaschemaI18n {
|
|
242
|
+
__typename?: 'MetaI18n';
|
|
243
|
+
translationTable: string;
|
|
244
|
+
translatableFields: Array<MetaschemaI18nField | null>;
|
|
245
|
+
}
|
|
246
|
+
interface MetaschemaRealtime {
|
|
247
|
+
__typename?: 'MetaRealtime';
|
|
248
|
+
subscriptionFieldName: string;
|
|
249
|
+
}
|
|
250
|
+
type MetaschemaScopeTier = 'global' | 'database' | 'entity';
|
|
251
|
+
interface MetaschemaScope {
|
|
252
|
+
__typename?: 'MetaScope';
|
|
253
|
+
scope: string;
|
|
254
|
+
tier: MetaschemaScopeTier;
|
|
255
|
+
keyColumn?: string | null;
|
|
256
|
+
entityTable?: string | null;
|
|
257
|
+
source: 'smartTag';
|
|
258
|
+
}
|
|
259
|
+
interface MetaIntrospectionField {
|
|
260
|
+
name: string;
|
|
261
|
+
}
|
|
262
|
+
interface MetaIntrospectionType {
|
|
263
|
+
name?: string | null;
|
|
264
|
+
fields?: Array<MetaIntrospectionField | null> | null;
|
|
265
|
+
}
|
|
266
|
+
type MetaContractTypeAlias = 'queryType' | 'metaSchema' | 'metaTable' | 'metaTableQuery' | 'metaField' | 'metaEnum' | 'metaType' | 'metaEncoding' | 'metaIndex' | 'metaPrimaryKey' | 'metaUnique' | 'metaForeignKey' | 'metaRefTable' | 'metaConstraints' | 'metaInflection' | 'metaRelations' | 'metaBelongsTo' | 'metaHas' | 'metaManyToMany' | 'metaStorage' | 'metaSearch' | 'metaSearchColumn' | 'metaSearchConfig' | 'metaI18n' | 'metaI18nField' | 'metaRealtime' | 'metaScope';
|
|
267
|
+
type MetaContractIntrospectionQuery = {
|
|
268
|
+
[Key in MetaContractTypeAlias]?: MetaIntrospectionType | null;
|
|
269
|
+
};
|
|
270
|
+
type MetaContractStatus = 'compatible' | 'incompatible' | 'unavailable';
|
|
271
|
+
interface MetaContractCompatibility {
|
|
272
|
+
contractVersion: string;
|
|
273
|
+
status: MetaContractStatus;
|
|
274
|
+
missing: string[];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* TypedDocumentString - Type-safe wrapper for GraphQL documents
|
|
279
|
+
* Compatible with GraphQL codegen client preset
|
|
280
|
+
*/
|
|
281
|
+
/**
|
|
282
|
+
* Document type decoration interface (from @graphql-typed-document-node/core)
|
|
283
|
+
*/
|
|
284
|
+
interface DocumentTypeDecoration<TResult, TVariables> {
|
|
285
|
+
/**
|
|
286
|
+
* This type is used to ensure that the variables you pass in to the query are assignable to Variables
|
|
287
|
+
* and that the Result is assignable to whatever you pass your result to.
|
|
288
|
+
*/
|
|
289
|
+
__apiType?: (variables: TVariables) => TResult;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Enhanced TypedDocumentString with type inference capabilities
|
|
293
|
+
* Compatible with GraphQL codegen client preset
|
|
294
|
+
*/
|
|
295
|
+
declare class TypedDocumentString<TResult = unknown, TVariables = unknown> extends String implements DocumentTypeDecoration<TResult, TVariables> {
|
|
296
|
+
/** Same shape as the codegen implementation for structural typing */
|
|
297
|
+
__apiType?: (variables: TVariables) => TResult;
|
|
298
|
+
__meta__?: Record<string, unknown>;
|
|
299
|
+
private value;
|
|
300
|
+
constructor(value: string, meta?: Record<string, unknown>);
|
|
301
|
+
private generateHash;
|
|
302
|
+
toString(): string;
|
|
303
|
+
/**
|
|
304
|
+
* Get the hash for caching purposes
|
|
305
|
+
*/
|
|
306
|
+
getHash(): string;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
declare const META_CONTRACT_VERSION: "2026-07";
|
|
310
|
+
/** Every GraphQL field referenced by {@link META_DOCUMENT}, grouped by owning type. */
|
|
311
|
+
declare const META_CONTRACT_REQUIREMENTS: {
|
|
312
|
+
readonly queryType: {
|
|
313
|
+
readonly typeName: "Query";
|
|
314
|
+
readonly fields: readonly ["_meta"];
|
|
315
|
+
};
|
|
316
|
+
readonly metaSchema: {
|
|
317
|
+
readonly typeName: "MetaSchema";
|
|
318
|
+
readonly fields: readonly ["tables"];
|
|
319
|
+
};
|
|
320
|
+
readonly metaTable: {
|
|
321
|
+
readonly typeName: "MetaTable";
|
|
322
|
+
readonly fields: readonly ["name", "schemaName", "query", "fields", "inflection", "indexes", "constraints", "foreignKeyConstraints", "primaryKeyConstraints", "uniqueConstraints", "relations", "storage", "search", "i18n", "realtime", "scope"];
|
|
323
|
+
};
|
|
324
|
+
readonly metaTableQuery: {
|
|
325
|
+
readonly typeName: "MetaQuery";
|
|
326
|
+
readonly fields: readonly ["all", "one", "create", "update", "delete"];
|
|
327
|
+
};
|
|
328
|
+
readonly metaField: {
|
|
329
|
+
readonly typeName: "MetaField";
|
|
330
|
+
readonly fields: readonly ["name", "type", "isNotNull", "hasDefault", "isPrimaryKey", "isForeignKey", "description", "enumValues"];
|
|
331
|
+
};
|
|
332
|
+
readonly metaEnum: {
|
|
333
|
+
readonly typeName: "MetaEnum";
|
|
334
|
+
readonly fields: readonly ["name", "values"];
|
|
335
|
+
};
|
|
336
|
+
readonly metaType: {
|
|
337
|
+
readonly typeName: "MetaType";
|
|
338
|
+
readonly fields: readonly ["pgType", "gqlType", "isArray", "isNotNull", "hasDefault", "subtype", "encoding"];
|
|
339
|
+
};
|
|
340
|
+
readonly metaEncoding: {
|
|
341
|
+
readonly typeName: "MetaScalarEncoding";
|
|
342
|
+
readonly fields: readonly ["kind", "elementType", "dimensions", "geometrySubtype", "srid", "dotPath"];
|
|
343
|
+
};
|
|
344
|
+
readonly metaIndex: {
|
|
345
|
+
readonly typeName: "MetaIndex";
|
|
346
|
+
readonly fields: readonly ["name", "isUnique", "isPrimary", "columns", "fields"];
|
|
347
|
+
};
|
|
348
|
+
readonly metaPrimaryKey: {
|
|
349
|
+
readonly typeName: "MetaPrimaryKeyConstraint";
|
|
350
|
+
readonly fields: readonly ["name", "fields"];
|
|
351
|
+
};
|
|
352
|
+
readonly metaUnique: {
|
|
353
|
+
readonly typeName: "MetaUniqueConstraint";
|
|
354
|
+
readonly fields: readonly ["name", "fields"];
|
|
355
|
+
};
|
|
356
|
+
readonly metaForeignKey: {
|
|
357
|
+
readonly typeName: "MetaForeignKeyConstraint";
|
|
358
|
+
readonly fields: readonly ["name", "fields", "referencedTable", "referencedFields", "refFields", "refTable"];
|
|
359
|
+
};
|
|
360
|
+
readonly metaRefTable: {
|
|
361
|
+
readonly typeName: "MetaRefTable";
|
|
362
|
+
readonly fields: readonly ["name"];
|
|
363
|
+
};
|
|
364
|
+
readonly metaConstraints: {
|
|
365
|
+
readonly typeName: "MetaConstraints";
|
|
366
|
+
readonly fields: readonly ["primaryKey", "unique", "foreignKey"];
|
|
367
|
+
};
|
|
368
|
+
readonly metaInflection: {
|
|
369
|
+
readonly typeName: "MetaInflection";
|
|
370
|
+
readonly fields: readonly ["tableType", "allRows", "connection", "edge", "filterType", "orderByType", "conditionType", "patchType", "createInputType", "createPayloadType", "updatePayloadType", "deletePayloadType"];
|
|
371
|
+
};
|
|
372
|
+
readonly metaRelations: {
|
|
373
|
+
readonly typeName: "MetaRelations";
|
|
374
|
+
readonly fields: readonly ["belongsTo", "has", "hasOne", "hasMany", "manyToMany"];
|
|
375
|
+
};
|
|
376
|
+
readonly metaBelongsTo: {
|
|
377
|
+
readonly typeName: "MetaBelongsToRelation";
|
|
378
|
+
readonly fields: readonly ["fieldName", "isUnique", "type", "keys", "references"];
|
|
379
|
+
};
|
|
380
|
+
readonly metaHas: {
|
|
381
|
+
readonly typeName: "MetaHasRelation";
|
|
382
|
+
readonly fields: readonly ["fieldName", "isUnique", "type", "keys", "referencedBy"];
|
|
383
|
+
};
|
|
384
|
+
readonly metaManyToMany: {
|
|
385
|
+
readonly typeName: "MetaManyToManyRelation";
|
|
386
|
+
readonly fields: readonly ["fieldName", "type", "junctionTable", "junctionLeftConstraint", "junctionLeftKeyAttributes", "junctionRightConstraint", "junctionRightKeyAttributes", "leftKeyAttributes", "rightKeyAttributes", "rightTable"];
|
|
387
|
+
};
|
|
388
|
+
readonly metaStorage: {
|
|
389
|
+
readonly typeName: "MetaStorage";
|
|
390
|
+
readonly fields: readonly ["isFilesTable", "isBucketsTable"];
|
|
391
|
+
};
|
|
392
|
+
readonly metaSearch: {
|
|
393
|
+
readonly typeName: "MetaSearch";
|
|
394
|
+
readonly fields: readonly ["algorithms", "columns", "hasUnifiedSearch", "config"];
|
|
395
|
+
};
|
|
396
|
+
readonly metaSearchColumn: {
|
|
397
|
+
readonly typeName: "MetaSearchColumn";
|
|
398
|
+
readonly fields: readonly ["name", "algorithm"];
|
|
399
|
+
};
|
|
400
|
+
readonly metaSearchConfig: {
|
|
401
|
+
readonly typeName: "MetaSearchConfig";
|
|
402
|
+
readonly fields: readonly ["weights", "boostRecent", "boostRecencyField", "boostRecencyDecay"];
|
|
403
|
+
};
|
|
404
|
+
readonly metaI18n: {
|
|
405
|
+
readonly typeName: "MetaI18n";
|
|
406
|
+
readonly fields: readonly ["translationTable", "translatableFields"];
|
|
407
|
+
};
|
|
408
|
+
readonly metaI18nField: {
|
|
409
|
+
readonly typeName: "MetaI18nField";
|
|
410
|
+
readonly fields: readonly ["name", "type"];
|
|
411
|
+
};
|
|
412
|
+
readonly metaRealtime: {
|
|
413
|
+
readonly typeName: "MetaRealtime";
|
|
414
|
+
readonly fields: readonly ["subscriptionFieldName"];
|
|
415
|
+
};
|
|
416
|
+
readonly metaScope: {
|
|
417
|
+
readonly typeName: "MetaScope";
|
|
418
|
+
readonly fields: readonly ["scope", "tier", "keyColumn", "entityTable", "source"];
|
|
419
|
+
};
|
|
420
|
+
};
|
|
421
|
+
declare const META_CONTRACT_INTROSPECTION_SOURCE: string;
|
|
422
|
+
declare const META_CONTRACT_INTROSPECTION_DOCUMENT: TypedDocumentString<MetaContractIntrospectionQuery, Record<string, never>>;
|
|
423
|
+
declare const META_QUERY_SOURCE = "\n\tquery ConstructiveMeta {\n\t\t_meta {\n\t\t\ttables {\n\t\t\t\tname\n\t\t\t\tschemaName\n\t\t\t\tquery { all one create update delete }\n\t\t\t\tfields { ...ConstructiveMetaField }\n\t\t\t\tinflection {\n\t\t\t\t\ttableType\n\t\t\t\t\tallRows\n\t\t\t\t\tconnection\n\t\t\t\t\tedge\n\t\t\t\t\tfilterType\n\t\t\t\t\torderByType\n\t\t\t\t\tconditionType\n\t\t\t\t\tpatchType\n\t\t\t\t\tcreateInputType\n\t\t\t\t\tcreatePayloadType\n\t\t\t\t\tupdatePayloadType\n\t\t\t\t\tdeletePayloadType\n\t\t\t\t}\n\t\t\t\tindexes {\n\t\t\t\t\tname\n\t\t\t\t\tisUnique\n\t\t\t\t\tisPrimary\n\t\t\t\t\tcolumns\n\t\t\t\t\tfields { ...ConstructiveMetaField }\n\t\t\t\t}\n\t\t\t\tconstraints {\n\t\t\t\t\tprimaryKey { name fields { ...ConstructiveMetaField } }\n\t\t\t\t\tunique { name fields { ...ConstructiveMetaField } }\n\t\t\t\t\tforeignKey { ...ConstructiveMetaForeignKey }\n\t\t\t\t}\n\t\t\t\tforeignKeyConstraints { ...ConstructiveMetaForeignKey }\n\t\t\t\tprimaryKeyConstraints { name fields { ...ConstructiveMetaField } }\n\t\t\t\tuniqueConstraints { name fields { ...ConstructiveMetaField } }\n\t\t\t\trelations {\n\t\t\t\t\tbelongsTo {\n\t\t\t\t\t\tfieldName\n\t\t\t\t\t\tisUnique\n\t\t\t\t\t\ttype\n\t\t\t\t\t\tkeys { ...ConstructiveMetaField }\n\t\t\t\t\t\treferences { name }\n\t\t\t\t\t}\n\t\t\t\t\thas {\n\t\t\t\t\t\tfieldName\n\t\t\t\t\t\tisUnique\n\t\t\t\t\t\ttype\n\t\t\t\t\t\tkeys { ...ConstructiveMetaField }\n\t\t\t\t\t\treferencedBy { name }\n\t\t\t\t\t}\n\t\t\t\t\thasOne {\n\t\t\t\t\t\tfieldName\n\t\t\t\t\t\tisUnique\n\t\t\t\t\t\ttype\n\t\t\t\t\t\tkeys { ...ConstructiveMetaField }\n\t\t\t\t\t\treferencedBy { name }\n\t\t\t\t\t}\n\t\t\t\t\thasMany {\n\t\t\t\t\t\tfieldName\n\t\t\t\t\t\tisUnique\n\t\t\t\t\t\ttype\n\t\t\t\t\t\tkeys { ...ConstructiveMetaField }\n\t\t\t\t\t\treferencedBy { name }\n\t\t\t\t\t}\n\t\t\t\t\tmanyToMany {\n\t\t\t\t\t\tfieldName\n\t\t\t\t\t\ttype\n\t\t\t\t\t\tjunctionTable { name }\n\t\t\t\t\t\tjunctionLeftConstraint { ...ConstructiveMetaForeignKey }\n\t\t\t\t\t\tjunctionLeftKeyAttributes { ...ConstructiveMetaField }\n\t\t\t\t\t\tjunctionRightConstraint { ...ConstructiveMetaForeignKey }\n\t\t\t\t\t\tjunctionRightKeyAttributes { ...ConstructiveMetaField }\n\t\t\t\t\t\tleftKeyAttributes { ...ConstructiveMetaField }\n\t\t\t\t\t\trightKeyAttributes { ...ConstructiveMetaField }\n\t\t\t\t\t\trightTable { name }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tstorage { isFilesTable isBucketsTable }\n\t\t\t\tsearch {\n\t\t\t\t\talgorithms\n\t\t\t\t\tcolumns { name algorithm }\n\t\t\t\t\thasUnifiedSearch\n\t\t\t\t\tconfig { weights boostRecent boostRecencyField boostRecencyDecay }\n\t\t\t\t}\n\t\t\t\ti18n { translationTable translatableFields { name type } }\n\t\t\t\trealtime { subscriptionFieldName }\n\t\t\t\tscope { scope tier keyColumn entityTable source }\n\t\t\t}\n\t\t}\n\t}\n\n\tfragment ConstructiveMetaType on MetaType {\n\t\tpgType\n\t\tgqlType\n\t\tisArray\n\t\tisNotNull\n\t\thasDefault\n\t\tsubtype\n\t\tencoding {\n\t\t\tkind\n\t\t\telementType\n\t\t\tdimensions\n\t\t\tgeometrySubtype\n\t\t\tsrid\n\t\t\tdotPath\n\t\t}\n\t}\n\n\tfragment ConstructiveMetaField on MetaField {\n\t\tname\n\t\ttype { ...ConstructiveMetaType }\n\t\tisNotNull\n\t\thasDefault\n\t\tisPrimaryKey\n\t\tisForeignKey\n\t\tdescription\n\t\tenumValues { name values }\n\t}\n\n\tfragment ConstructiveMetaForeignKey on MetaForeignKeyConstraint {\n\t\tname\n\t\tfields { ...ConstructiveMetaField }\n\t\treferencedTable\n\t\treferencedFields\n\t\trefFields { ...ConstructiveMetaField }\n\t\trefTable { name }\n\t}\n";
|
|
424
|
+
declare const META_DOCUMENT: TypedDocumentString<MetaQuery, Record<string, never>>;
|
|
425
|
+
declare function assessMetaContract(result: MetaContractIntrospectionQuery | null | undefined): MetaContractCompatibility;
|
|
426
|
+
declare class MetaContractError extends Error {
|
|
427
|
+
readonly code: 'META_CONTRACT_UNAVAILABLE' | 'META_CONTRACT_INCOMPATIBLE';
|
|
428
|
+
readonly compatibility: MetaContractCompatibility;
|
|
429
|
+
constructor(compatibility: MetaContractCompatibility);
|
|
430
|
+
}
|
|
431
|
+
declare function assertMetaContract(result: MetaContractIntrospectionQuery | null | undefined): MetaContractCompatibility;
|
|
432
|
+
declare function assertMetaQuery(result: MetaQuery | null | undefined): asserts result is MetaQuery;
|
|
433
|
+
/** Decode the JSON-string transport used by `MetaSearchConfig.weights`. */
|
|
434
|
+
declare function parseMetaSearchWeights(config: MetaschemaSearchConfig | null | undefined): Record<string, number> | null;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Core schema types for representing PostGraphile table metadata
|
|
438
|
+
* These are "clean" versions that remove nullable/undefined complexity
|
|
439
|
+
*/
|
|
440
|
+
/**
|
|
441
|
+
* Represents a database table with its fields and relations
|
|
442
|
+
*/
|
|
443
|
+
interface Table$1 {
|
|
444
|
+
name: string;
|
|
445
|
+
/** Description from PostgreSQL COMMENT (smart comments stripped) */
|
|
446
|
+
description?: string;
|
|
447
|
+
fields: Field$1[];
|
|
448
|
+
relations: Relations$1;
|
|
449
|
+
/** PostGraphile inflection rules for this table */
|
|
450
|
+
inflection?: TableInflection$1;
|
|
451
|
+
/** Query operation names from introspection */
|
|
452
|
+
query?: TableQueryNames$1;
|
|
453
|
+
/** Constraint information */
|
|
454
|
+
constraints?: TableConstraints$1;
|
|
455
|
+
/** Smart tags parsed from PostGraphile @-prefixed comment directives */
|
|
456
|
+
smartTags?: Record<string, string | true>;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* PostGraphile-generated names for this table
|
|
460
|
+
*/
|
|
461
|
+
interface TableInflection$1 {
|
|
462
|
+
/** All rows connection query name (e.g., "users") */
|
|
463
|
+
allRows: string;
|
|
464
|
+
/** Simple all rows query name */
|
|
465
|
+
allRowsSimple: string;
|
|
466
|
+
/** Condition type name (e.g., "UserCondition") */
|
|
467
|
+
conditionType: string;
|
|
468
|
+
/** Connection type name (e.g., "UsersConnection") */
|
|
469
|
+
connection: string;
|
|
470
|
+
/** Create field name */
|
|
471
|
+
createField: string;
|
|
472
|
+
/** Create input type (e.g., "CreateUserInput") */
|
|
473
|
+
createInputType: string;
|
|
474
|
+
/** Create payload type */
|
|
475
|
+
createPayloadType: string;
|
|
476
|
+
/** Delete by primary key mutation name */
|
|
477
|
+
deleteByPrimaryKey: string | null;
|
|
478
|
+
/** Delete payload type */
|
|
479
|
+
deletePayloadType: string;
|
|
480
|
+
/** Edge type name */
|
|
481
|
+
edge: string;
|
|
482
|
+
/** Edge field name */
|
|
483
|
+
edgeField: string;
|
|
484
|
+
/** Enum type name */
|
|
485
|
+
enumType: string;
|
|
486
|
+
/** Filter type name (e.g., "UserFilter") */
|
|
487
|
+
filterType: string | null;
|
|
488
|
+
/** Input type name (e.g., "UserInput") */
|
|
489
|
+
inputType: string;
|
|
490
|
+
/** OrderBy enum type (e.g., "UsersOrderBy") */
|
|
491
|
+
orderByType: string;
|
|
492
|
+
/** Patch field name */
|
|
493
|
+
patchField: string;
|
|
494
|
+
/** Patch type (e.g., "UserPatch") */
|
|
495
|
+
patchType: string | null;
|
|
496
|
+
/** Table field name (singular, e.g., "user") */
|
|
497
|
+
tableFieldName: string;
|
|
498
|
+
/** Table type name (e.g., "User") */
|
|
499
|
+
tableType: string;
|
|
500
|
+
/** Type name */
|
|
501
|
+
typeName: string;
|
|
502
|
+
/** Update by primary key mutation name */
|
|
503
|
+
updateByPrimaryKey: string | null;
|
|
504
|
+
/** Update payload type */
|
|
505
|
+
updatePayloadType: string | null;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Query operation names from introspection
|
|
509
|
+
*/
|
|
510
|
+
interface TableQueryNames$1 {
|
|
511
|
+
/** All rows query name */
|
|
512
|
+
all: string;
|
|
513
|
+
/** Single row query name */
|
|
514
|
+
one: string | null;
|
|
515
|
+
/** Create mutation name */
|
|
516
|
+
create: string;
|
|
517
|
+
/** Update mutation name */
|
|
518
|
+
update: string | null;
|
|
519
|
+
/** Delete mutation name */
|
|
520
|
+
delete: string | null;
|
|
521
|
+
/** Patch field name in update mutation input (e.g., "userPatch" for UpdateUserInput) */
|
|
522
|
+
patchFieldName?: string;
|
|
523
|
+
/** Bulk insert mutation name (e.g., "bulkCreateUsers") */
|
|
524
|
+
bulkInsert?: string | null;
|
|
525
|
+
/** Bulk upsert mutation name (e.g., "bulkUpsertUsers") */
|
|
526
|
+
bulkUpsert?: string | null;
|
|
527
|
+
/** Bulk update mutation name (e.g., "bulkUpdateUsers") */
|
|
528
|
+
bulkUpdate?: string | null;
|
|
529
|
+
/** Bulk delete mutation name (e.g., "bulkDeleteUsers") */
|
|
530
|
+
bulkDelete?: string | null;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Table constraints
|
|
534
|
+
*/
|
|
535
|
+
interface TableConstraints$1 {
|
|
536
|
+
primaryKey: ConstraintInfo$1[];
|
|
537
|
+
foreignKey: ForeignKeyConstraint$1[];
|
|
538
|
+
unique: ConstraintInfo$1[];
|
|
539
|
+
}
|
|
540
|
+
interface ConstraintInfo$1 {
|
|
541
|
+
name: string;
|
|
542
|
+
fields: Field$1[];
|
|
543
|
+
}
|
|
544
|
+
interface ForeignKeyConstraint$1 extends ConstraintInfo$1 {
|
|
545
|
+
refTable: string;
|
|
546
|
+
refFields: Field$1[];
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Represents a field/column in a table
|
|
550
|
+
*/
|
|
551
|
+
interface Field$1 {
|
|
552
|
+
name: string;
|
|
553
|
+
/** Description from PostgreSQL COMMENT (smart comments stripped) */
|
|
554
|
+
description?: string;
|
|
555
|
+
type: FieldType$1;
|
|
556
|
+
/** Whether the column has a NOT NULL constraint (inferred from NON_NULL wrapper on entity type field) */
|
|
557
|
+
isNotNull?: boolean | null;
|
|
558
|
+
/** Whether the column has a DEFAULT value (inferred by comparing entity vs CreateInput field nullability) */
|
|
559
|
+
hasDefault?: boolean | null;
|
|
560
|
+
/** Arguments for computed fields (e.g. requestUploadUrl on bucket types) */
|
|
561
|
+
args?: FieldArgument$1[];
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Argument on a computed field (not a root operation)
|
|
565
|
+
*/
|
|
566
|
+
interface FieldArgument$1 {
|
|
567
|
+
name: string;
|
|
568
|
+
/** GraphQL type reference */
|
|
569
|
+
type: TypeRef$1;
|
|
570
|
+
/** Whether this argument is required (NON_NULL) */
|
|
571
|
+
isRequired: boolean;
|
|
572
|
+
/** Description from schema */
|
|
573
|
+
description?: string;
|
|
574
|
+
/** Default value (as string) */
|
|
575
|
+
defaultValue?: string;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Field type information from PostGraphile introspection
|
|
579
|
+
*/
|
|
580
|
+
interface FieldType$1 {
|
|
581
|
+
/** GraphQL type name (e.g., "String", "UUID", "Int") */
|
|
582
|
+
gqlType: string;
|
|
583
|
+
/** Whether this is an array type */
|
|
584
|
+
isArray: boolean;
|
|
585
|
+
/** Type modifier (for precision, length, etc.) */
|
|
586
|
+
modifier?: string | number | null;
|
|
587
|
+
/** PostgreSQL type alias (domain name) */
|
|
588
|
+
pgAlias?: string | null;
|
|
589
|
+
/** PostgreSQL native type (e.g., "text", "uuid", "integer") */
|
|
590
|
+
pgType?: string | null;
|
|
591
|
+
/** Subtype for composite types */
|
|
592
|
+
subtype?: string | null;
|
|
593
|
+
/** Type modifier from PostgreSQL */
|
|
594
|
+
typmod?: number | null;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* All relation types for a table
|
|
598
|
+
*/
|
|
599
|
+
interface Relations$1 {
|
|
600
|
+
belongsTo: BelongsToRelation$1[];
|
|
601
|
+
hasOne: HasOneRelation$1[];
|
|
602
|
+
hasMany: HasManyRelation$1[];
|
|
603
|
+
manyToMany: ManyToManyRelation$1[];
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* BelongsTo relation (foreign key on this table)
|
|
607
|
+
*/
|
|
608
|
+
interface BelongsToRelation$1 {
|
|
609
|
+
fieldName: string | null;
|
|
610
|
+
isUnique: boolean;
|
|
611
|
+
referencesTable: string;
|
|
612
|
+
type: string | null;
|
|
613
|
+
keys: Field$1[];
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* HasOne relation (foreign key on other table, unique)
|
|
617
|
+
*/
|
|
618
|
+
interface HasOneRelation$1 {
|
|
619
|
+
fieldName: string | null;
|
|
620
|
+
isUnique: boolean;
|
|
621
|
+
referencedByTable: string;
|
|
622
|
+
type: string | null;
|
|
623
|
+
keys: Field$1[];
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* HasMany relation (foreign key on other table, not unique)
|
|
627
|
+
*/
|
|
628
|
+
interface HasManyRelation$1 {
|
|
629
|
+
fieldName: string | null;
|
|
630
|
+
isUnique: boolean;
|
|
631
|
+
referencedByTable: string;
|
|
632
|
+
type: string | null;
|
|
633
|
+
keys: Field$1[];
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* ManyToMany relation (through junction table)
|
|
637
|
+
*/
|
|
638
|
+
interface ManyToManyRelation$1 {
|
|
639
|
+
fieldName: string | null;
|
|
640
|
+
rightTable: string;
|
|
641
|
+
junctionTable: string;
|
|
642
|
+
type: string | null;
|
|
643
|
+
/** Junction FK field names pointing to the left table */
|
|
644
|
+
junctionLeftKeyFields?: string[];
|
|
645
|
+
/** Junction FK field names pointing to the right table */
|
|
646
|
+
junctionRightKeyFields?: string[];
|
|
647
|
+
/** Left table key fields (usually just 'id') */
|
|
648
|
+
leftKeyFields?: string[];
|
|
649
|
+
/** Right table key fields (usually just 'id') */
|
|
650
|
+
rightKeyFields?: string[];
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Clean representation of an operation argument
|
|
654
|
+
*/
|
|
655
|
+
interface Argument$1 {
|
|
656
|
+
/** Argument name */
|
|
657
|
+
name: string;
|
|
658
|
+
/** Argument type */
|
|
659
|
+
type: TypeRef$1;
|
|
660
|
+
/** Default value (as string) */
|
|
661
|
+
defaultValue?: string;
|
|
662
|
+
/** Description from schema */
|
|
663
|
+
description?: string;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Clean type reference - simplified from introspection TypeRef
|
|
667
|
+
*/
|
|
668
|
+
interface TypeRef$1 {
|
|
669
|
+
/** Type kind */
|
|
670
|
+
kind: 'SCALAR' | 'OBJECT' | 'INPUT_OBJECT' | 'ENUM' | 'LIST' | 'NON_NULL';
|
|
671
|
+
/** Type name (null for LIST and NON_NULL wrappers) */
|
|
672
|
+
name: string | null;
|
|
673
|
+
/** Inner type for LIST and NON_NULL wrappers */
|
|
674
|
+
ofType?: TypeRef$1;
|
|
675
|
+
/** Resolved TypeScript type string */
|
|
676
|
+
tsType?: string;
|
|
677
|
+
/** Fields for OBJECT types */
|
|
678
|
+
fields?: ObjectField$1[];
|
|
679
|
+
/** Input fields for INPUT_OBJECT types */
|
|
680
|
+
inputFields?: Argument$1[];
|
|
681
|
+
/** Values for ENUM types */
|
|
682
|
+
enumValues?: string[];
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Field on an object type
|
|
686
|
+
*/
|
|
687
|
+
interface ObjectField$1 {
|
|
688
|
+
/** Field name */
|
|
689
|
+
name: string;
|
|
690
|
+
/** Field type */
|
|
691
|
+
type: TypeRef$1;
|
|
692
|
+
/** Description */
|
|
693
|
+
description?: string;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Field selection types for controlling which fields are included in queries
|
|
698
|
+
*/
|
|
699
|
+
/**
|
|
700
|
+
* Simple field selection options
|
|
701
|
+
*/
|
|
702
|
+
interface SimpleFieldSelection$1 {
|
|
703
|
+
/** Specific fields to include */
|
|
704
|
+
select?: string[];
|
|
705
|
+
/** Relations to include with their fields */
|
|
706
|
+
include?: Record<string, string[] | boolean>;
|
|
707
|
+
/** Simple relation inclusion (just names) */
|
|
708
|
+
includeRelations?: string[];
|
|
709
|
+
/** Fields to exclude */
|
|
710
|
+
exclude?: string[];
|
|
711
|
+
/** Maximum depth for nested relations */
|
|
712
|
+
maxDepth?: number;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Predefined field selection presets
|
|
716
|
+
*/
|
|
717
|
+
type FieldSelectionPreset$1 =
|
|
718
|
+
/** Just id and primary display field */
|
|
719
|
+
'minimal'
|
|
720
|
+
/** Common display fields */
|
|
721
|
+
| 'display'
|
|
722
|
+
/** All scalar fields */
|
|
723
|
+
| 'all'
|
|
724
|
+
/** All fields including relations */
|
|
725
|
+
| 'full';
|
|
726
|
+
/**
|
|
727
|
+
* Main field selection type - preset or custom
|
|
728
|
+
*/
|
|
729
|
+
type FieldSelection$1 = FieldSelectionPreset$1 | SimpleFieldSelection$1;
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Query-related types for building GraphQL operations
|
|
733
|
+
*/
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Relay-style pagination info
|
|
737
|
+
*/
|
|
738
|
+
interface PageInfo {
|
|
739
|
+
hasNextPage: boolean;
|
|
740
|
+
hasPreviousPage: boolean;
|
|
741
|
+
startCursor?: string | null;
|
|
742
|
+
endCursor?: string | null;
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Relay-style connection result
|
|
746
|
+
*/
|
|
747
|
+
interface ConnectionResult<T = unknown> {
|
|
748
|
+
nodes: T[];
|
|
749
|
+
totalCount: number;
|
|
750
|
+
pageInfo: PageInfo;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Options for building SELECT queries
|
|
754
|
+
*/
|
|
755
|
+
interface QueryOptions$1 {
|
|
756
|
+
/** Number of records to fetch (alias for first) */
|
|
757
|
+
first?: number;
|
|
758
|
+
/** Alias for first */
|
|
759
|
+
limit?: number;
|
|
760
|
+
/** Offset for pagination */
|
|
761
|
+
offset?: number;
|
|
762
|
+
/** Cursor for forward pagination */
|
|
763
|
+
after?: string;
|
|
764
|
+
/** Cursor for backward pagination */
|
|
765
|
+
before?: string;
|
|
766
|
+
/** Filter conditions */
|
|
767
|
+
where?: Filter$1;
|
|
768
|
+
/** Sort order */
|
|
769
|
+
orderBy?: OrderByItem$1[];
|
|
770
|
+
/** Field selection options */
|
|
771
|
+
fieldSelection?: FieldSelection$1;
|
|
772
|
+
/**
|
|
773
|
+
* Maps requested relation field names to actual schema field names (or null to omit).
|
|
774
|
+
* When the mapped name differs from the key, a GraphQL alias is emitted so the
|
|
775
|
+
* consumer sees a stable field name regardless of the server-side name.
|
|
776
|
+
*
|
|
777
|
+
* Example: `{ contact: 'contactByOwnerId' }` emits `contact: contactByOwnerId { … }`
|
|
778
|
+
* Pass `null` to suppress a relation entirely: `{ internalNotes: null }`
|
|
779
|
+
*/
|
|
780
|
+
relationFieldMap?: Record<string, string | null>;
|
|
781
|
+
/** Include pageInfo in response */
|
|
782
|
+
includePageInfo?: boolean;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Single order by specification
|
|
786
|
+
*/
|
|
787
|
+
interface OrderByItem$1 {
|
|
788
|
+
field: string;
|
|
789
|
+
direction: 'asc' | 'desc';
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* All supported filter operators
|
|
793
|
+
*/
|
|
794
|
+
type FilterOperator$1 = 'isNull' | 'equalTo' | 'notEqualTo' | 'distinctFrom' | 'notDistinctFrom' | 'in' | 'notIn' | 'lessThan' | 'lessThanOrEqualTo' | 'greaterThan' | 'greaterThanOrEqualTo' | 'includes' | 'notIncludes' | 'includesInsensitive' | 'notIncludesInsensitive' | 'startsWith' | 'notStartsWith' | 'startsWithInsensitive' | 'notStartsWithInsensitive' | 'endsWith' | 'notEndsWith' | 'endsWithInsensitive' | 'notEndsWithInsensitive' | 'like' | 'notLike' | 'likeInsensitive' | 'notLikeInsensitive' | 'equalToInsensitive' | 'notEqualToInsensitive' | 'distinctFromInsensitive' | 'notDistinctFromInsensitive' | 'inInsensitive' | 'notInInsensitive' | 'contains' | 'containedBy' | 'overlaps' | 'intersects' | 'intersects3D' | 'containsProperly' | 'coveredBy' | 'covers' | 'crosses' | 'disjoint' | 'orderingEquals' | 'touches' | 'within' | 'bboxIntersects2D' | 'bboxIntersects3D' | 'bboxOverlapsOrLeftOf' | 'bboxOverlapsOrRightOf' | 'bboxOverlapsOrBelow' | 'bboxOverlapsOrAbove' | 'bboxLeftOf' | 'bboxRightOf' | 'bboxBelow' | 'bboxAbove' | 'bboxContains' | 'bboxEquals';
|
|
795
|
+
/**
|
|
796
|
+
* Filter on a single field
|
|
797
|
+
*/
|
|
798
|
+
type FieldFilter$1 = {
|
|
799
|
+
[K in FilterOperator$1]?: unknown;
|
|
800
|
+
};
|
|
801
|
+
/**
|
|
802
|
+
* Filter on related records
|
|
803
|
+
*/
|
|
804
|
+
interface RelationalFilter$1 {
|
|
805
|
+
/** All related records must match */
|
|
806
|
+
every?: Filter$1;
|
|
807
|
+
/** At least one related record must match */
|
|
808
|
+
some?: Filter$1;
|
|
809
|
+
/** No related records match */
|
|
810
|
+
none?: Filter$1;
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Main filter type - can be nested
|
|
814
|
+
*/
|
|
815
|
+
type Filter$1 = {
|
|
816
|
+
[field: string]: FieldFilter$1 | RelationalFilter$1 | Filter$1;
|
|
817
|
+
} & {
|
|
818
|
+
and?: Filter$1[];
|
|
819
|
+
or?: Filter$1[];
|
|
820
|
+
not?: Filter$1;
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Mutation-related types
|
|
825
|
+
*/
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Options for mutation operations
|
|
829
|
+
*/
|
|
830
|
+
interface MutationOptions$1 {
|
|
831
|
+
/** Fields to return after mutation */
|
|
832
|
+
returning?: string[];
|
|
833
|
+
/** Field selection for returned data */
|
|
834
|
+
fieldSelection?: FieldSelection$1;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Field selection types for controlling which fields are included in queries
|
|
839
|
+
*/
|
|
840
|
+
/**
|
|
841
|
+
* Simple field selection options
|
|
842
|
+
*/
|
|
843
|
+
interface SimpleFieldSelection {
|
|
844
|
+
/** Specific fields to include */
|
|
845
|
+
select?: string[];
|
|
846
|
+
/** Relations to include with their fields */
|
|
847
|
+
include?: Record<string, string[] | boolean>;
|
|
848
|
+
/** Simple relation inclusion (just names) */
|
|
849
|
+
includeRelations?: string[];
|
|
850
|
+
/** Fields to exclude */
|
|
851
|
+
exclude?: string[];
|
|
852
|
+
/** Maximum depth for nested relations */
|
|
853
|
+
maxDepth?: number;
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Predefined field selection presets
|
|
857
|
+
*/
|
|
858
|
+
type FieldSelectionPreset =
|
|
859
|
+
/** Just id and primary display field */
|
|
860
|
+
'minimal'
|
|
861
|
+
/** Common display fields */
|
|
862
|
+
| 'display'
|
|
863
|
+
/** All scalar fields */
|
|
864
|
+
| 'all'
|
|
865
|
+
/** All fields including relations */
|
|
866
|
+
| 'full';
|
|
867
|
+
/**
|
|
868
|
+
* Main field selection type - preset or custom
|
|
869
|
+
*/
|
|
870
|
+
type FieldSelection = FieldSelectionPreset | SimpleFieldSelection;
|
|
871
|
+
/**
|
|
872
|
+
* Internal selection options format used by query builder
|
|
873
|
+
*/
|
|
874
|
+
interface SelectionOptions {
|
|
875
|
+
[fieldName: string]: boolean | {
|
|
876
|
+
select: Record<string, boolean>;
|
|
877
|
+
variables?: Record<string, unknown>;
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
type CleanFieldType = FieldType$1 & {
|
|
882
|
+
encoding?: MetaschemaScalarEncoding | null;
|
|
883
|
+
};
|
|
884
|
+
type CleanField = Omit<Field$1, 'type'> & {
|
|
885
|
+
type: CleanFieldType;
|
|
886
|
+
isPrimaryKey?: boolean | null;
|
|
887
|
+
isForeignKey?: boolean | null;
|
|
888
|
+
enumValues?: string[];
|
|
889
|
+
};
|
|
890
|
+
type CleanTable = Omit<Table$1, 'fields'> & {
|
|
891
|
+
schemaName?: string | null;
|
|
892
|
+
fields: CleanField[];
|
|
893
|
+
indexes?: Array<NonNullable<MetaschemaIndex>>;
|
|
894
|
+
storage?: MetaschemaStorage | null;
|
|
895
|
+
search?: MetaschemaSearch | null;
|
|
896
|
+
i18n?: MetaschemaI18n | null;
|
|
897
|
+
realtime?: MetaschemaRealtime | null;
|
|
898
|
+
scope?: MetaschemaScope | null;
|
|
899
|
+
};
|
|
900
|
+
type MetaTable$2 = NonNullable<NonNullable<NonNullable<MetaQuery['_meta']>['tables']>[number]>;
|
|
901
|
+
type MetaField$2 = NonNullable<NonNullable<MetaTable$2['fields']>[number]>;
|
|
902
|
+
type MetaFieldType$2 = NonNullable<MetaField$2['type']>;
|
|
903
|
+
type MetaRelations = NonNullable<MetaTable$2['relations']>;
|
|
904
|
+
type MetaBelongsToRelation = NonNullable<NonNullable<MetaRelations['belongsTo']>[number]>;
|
|
905
|
+
type MetaHasOneRelation = NonNullable<NonNullable<MetaRelations['hasOne']>[number]>;
|
|
906
|
+
type MetaHasManyRelation = NonNullable<NonNullable<MetaRelations['hasMany']>[number]>;
|
|
907
|
+
type MetaManyToManyRelation = NonNullable<NonNullable<MetaRelations['manyToMany']>[number]>;
|
|
908
|
+
/** Convert PostgreSQL snake_case column name to camelCase GraphQL field name. */
|
|
909
|
+
declare function pgFieldToCamelCase(str: string): string;
|
|
910
|
+
declare function cleanTable(metaTable: MetaTable$2): CleanTable;
|
|
911
|
+
|
|
912
|
+
declare const DEFAULT_CONSOLE_APPLICATION_SCOPES: readonly ["app"];
|
|
913
|
+
interface SelectConsoleDataTablesOptions {
|
|
914
|
+
/** Exact semantic scopes that identify application-owned tables. */
|
|
915
|
+
applicationScopes?: readonly string[];
|
|
916
|
+
/** Exact table names or `schema.table` identifiers allowed by the host. */
|
|
917
|
+
includeTables?: readonly string[];
|
|
918
|
+
/** Table names or `schema.table` identifiers the host wants hidden. */
|
|
919
|
+
excludeTables?: readonly string[];
|
|
920
|
+
}
|
|
921
|
+
type MetaTableInput = MetaTable$2 | null | undefined;
|
|
922
|
+
/**
|
|
923
|
+
* Select tables for Console Kit's generic Data area. Application ownership is
|
|
924
|
+
* determined exclusively from the July `_meta` semantic scope smart tag. The
|
|
925
|
+
* physical schema name is retained only for identifiers and deduplication.
|
|
926
|
+
*/
|
|
927
|
+
declare function selectConsoleDataTables(metaTables: readonly MetaTableInput[], options?: SelectConsoleDataTablesOptions): MetaTable$2[];
|
|
928
|
+
|
|
929
|
+
interface RowIdentityObject {
|
|
930
|
+
readonly [key: string]: RowIdentityValue;
|
|
931
|
+
}
|
|
932
|
+
type RowIdentityValue = null | boolean | number | string | readonly RowIdentityValue[] | RowIdentityObject;
|
|
933
|
+
type RowIdentityField = Readonly<{
|
|
934
|
+
columnName: string;
|
|
935
|
+
fieldName: string;
|
|
936
|
+
value: RowIdentityValue;
|
|
937
|
+
}>;
|
|
938
|
+
type RowIdentity = Readonly<{
|
|
939
|
+
schemaName: string | null;
|
|
940
|
+
tableName: string;
|
|
941
|
+
fields: readonly RowIdentityField[];
|
|
942
|
+
}>;
|
|
943
|
+
type RowIdentityDefinition = Readonly<{
|
|
944
|
+
status: 'keyed';
|
|
945
|
+
schemaName: string | null;
|
|
946
|
+
tableName: string;
|
|
947
|
+
fields: readonly Readonly<{
|
|
948
|
+
columnName: string;
|
|
949
|
+
fieldName: string;
|
|
950
|
+
}>[];
|
|
951
|
+
}> | Readonly<{
|
|
952
|
+
status: 'read-only';
|
|
953
|
+
schemaName: string | null;
|
|
954
|
+
tableName: string;
|
|
955
|
+
reason: 'no-primary-key';
|
|
956
|
+
}>;
|
|
957
|
+
type RowIdentityResolution = Readonly<{
|
|
958
|
+
status: 'identified';
|
|
959
|
+
identity: RowIdentity;
|
|
960
|
+
}> | Extract<RowIdentityDefinition, {
|
|
961
|
+
status: 'read-only';
|
|
962
|
+
}> | Readonly<{
|
|
963
|
+
status: 'invalid-row';
|
|
964
|
+
schemaName: string | null;
|
|
965
|
+
tableName: string;
|
|
966
|
+
missingFields: readonly string[];
|
|
967
|
+
invalidFields: readonly string[];
|
|
968
|
+
}>;
|
|
969
|
+
type TableWriteCapability = Extract<RowIdentityDefinition, {
|
|
970
|
+
status: 'read-only';
|
|
971
|
+
}> | Readonly<{
|
|
972
|
+
status: 'mutable';
|
|
973
|
+
primaryKeyFields: readonly string[];
|
|
974
|
+
operations: Readonly<{
|
|
975
|
+
create: boolean;
|
|
976
|
+
update: boolean;
|
|
977
|
+
delete: boolean;
|
|
978
|
+
}>;
|
|
979
|
+
}>;
|
|
980
|
+
declare function getRowIdentityDefinition(table: MetaTable$2): RowIdentityDefinition;
|
|
981
|
+
/** Resolves an ordered, schema-qualified identity without assuming an `id` field. */
|
|
982
|
+
declare function resolveRowIdentity(table: MetaTable$2, row: Readonly<Record<string, unknown>>): RowIdentityResolution;
|
|
983
|
+
/** Produces a stable cache/selection key; it contains values, never credentials. */
|
|
984
|
+
declare function serializeRowIdentity(identity: RowIdentity): string;
|
|
985
|
+
/** Produces GraphQL primary-key arguments in the same order declared by `_meta`. */
|
|
986
|
+
declare function rowIdentityToPrimaryKey(identity: RowIdentity): Readonly<Record<string, RowIdentityValue>>;
|
|
987
|
+
declare function assessTableWriteCapability(table: MetaTable$2): TableWriteCapability;
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* GraphQL Introspection Types
|
|
991
|
+
*
|
|
992
|
+
* Standard types for GraphQL schema introspection via __schema query.
|
|
993
|
+
* These mirror the GraphQL introspection spec.
|
|
994
|
+
*/
|
|
995
|
+
/**
|
|
996
|
+
* Reference to a GraphQL type - can be nested for wrappers like NON_NULL and LIST
|
|
997
|
+
*/
|
|
998
|
+
interface IntrospectionTypeRef {
|
|
999
|
+
kind: IntrospectionTypeKind;
|
|
1000
|
+
name: string | null;
|
|
1001
|
+
ofType: IntrospectionTypeRef | null;
|
|
1002
|
+
}
|
|
1003
|
+
type IntrospectionTypeKind = 'SCALAR' | 'OBJECT' | 'INPUT_OBJECT' | 'ENUM' | 'LIST' | 'NON_NULL' | 'INTERFACE' | 'UNION';
|
|
1004
|
+
/**
|
|
1005
|
+
* Input value - used for both field arguments and INPUT_OBJECT fields
|
|
1006
|
+
*/
|
|
1007
|
+
interface IntrospectionInputValue {
|
|
1008
|
+
name: string;
|
|
1009
|
+
description: string | null;
|
|
1010
|
+
type: IntrospectionTypeRef;
|
|
1011
|
+
defaultValue: string | null;
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Field on an OBJECT or INTERFACE type
|
|
1015
|
+
*/
|
|
1016
|
+
interface IntrospectionField {
|
|
1017
|
+
name: string;
|
|
1018
|
+
description: string | null;
|
|
1019
|
+
args: IntrospectionInputValue[];
|
|
1020
|
+
type: IntrospectionTypeRef;
|
|
1021
|
+
isDeprecated: boolean;
|
|
1022
|
+
deprecationReason: string | null;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Enum value definition
|
|
1026
|
+
*/
|
|
1027
|
+
interface IntrospectionEnumValue {
|
|
1028
|
+
name: string;
|
|
1029
|
+
description: string | null;
|
|
1030
|
+
isDeprecated: boolean;
|
|
1031
|
+
deprecationReason: string | null;
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Complete type definition from introspection
|
|
1035
|
+
*/
|
|
1036
|
+
interface IntrospectionType {
|
|
1037
|
+
kind: IntrospectionTypeKind;
|
|
1038
|
+
name: string;
|
|
1039
|
+
description: string | null;
|
|
1040
|
+
/** Fields for OBJECT and INTERFACE types */
|
|
1041
|
+
fields: IntrospectionField[] | null;
|
|
1042
|
+
/** Input fields for INPUT_OBJECT types */
|
|
1043
|
+
inputFields: IntrospectionInputValue[] | null;
|
|
1044
|
+
/** Possible types for INTERFACE and UNION types */
|
|
1045
|
+
possibleTypes: Array<{
|
|
1046
|
+
name: string;
|
|
1047
|
+
}> | null;
|
|
1048
|
+
/** Enum values for ENUM types */
|
|
1049
|
+
enumValues: IntrospectionEnumValue[] | null;
|
|
1050
|
+
/** Interfaces implemented by OBJECT types */
|
|
1051
|
+
interfaces: Array<{
|
|
1052
|
+
name: string;
|
|
1053
|
+
}> | null;
|
|
1054
|
+
/** Whether this INPUT_OBJECT type uses @oneOf (GraphQL 16+ discriminated union input) */
|
|
1055
|
+
isOneOf?: boolean;
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Root type references in schema
|
|
1059
|
+
*/
|
|
1060
|
+
interface IntrospectionRootType {
|
|
1061
|
+
name: string;
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Full schema introspection result
|
|
1065
|
+
*/
|
|
1066
|
+
interface IntrospectionSchema {
|
|
1067
|
+
queryType: IntrospectionRootType;
|
|
1068
|
+
mutationType: IntrospectionRootType | null;
|
|
1069
|
+
subscriptionType: IntrospectionRootType | null;
|
|
1070
|
+
types: IntrospectionType[];
|
|
1071
|
+
directives: IntrospectionDirective[];
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Directive definition
|
|
1075
|
+
*/
|
|
1076
|
+
interface IntrospectionDirective {
|
|
1077
|
+
name: string;
|
|
1078
|
+
description: string | null;
|
|
1079
|
+
locations: string[];
|
|
1080
|
+
args: IntrospectionInputValue[];
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Response from introspection query
|
|
1084
|
+
*/
|
|
1085
|
+
interface IntrospectionQueryResponse {
|
|
1086
|
+
__schema: IntrospectionSchema;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* GraphQL Schema Introspection Query
|
|
1091
|
+
*
|
|
1092
|
+
* Full introspection query that captures all queries, mutations, and types
|
|
1093
|
+
* from a GraphQL endpoint via the standard __schema query.
|
|
1094
|
+
*/
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Full schema introspection query
|
|
1098
|
+
*
|
|
1099
|
+
* Captures:
|
|
1100
|
+
* - All Query fields with args and return types
|
|
1101
|
+
* - All Mutation fields with args and return types
|
|
1102
|
+
* - All types (OBJECT, INPUT_OBJECT, ENUM, SCALAR) for resolution
|
|
1103
|
+
*
|
|
1104
|
+
* Uses a recursive TypeRef fragment to handle deeply nested type wrappers
|
|
1105
|
+
* (e.g., [String!]! = NON_NULL(LIST(NON_NULL(SCALAR))))
|
|
1106
|
+
*/
|
|
1107
|
+
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 isOneOf\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";
|
|
1108
|
+
|
|
1109
|
+
type SchemaIntrospectionCompatibilityStatus = 'compatible' | 'incompatible';
|
|
1110
|
+
interface SchemaIntrospectionCompatibility {
|
|
1111
|
+
contractVersion: typeof META_CONTRACT_VERSION;
|
|
1112
|
+
status: SchemaIntrospectionCompatibilityStatus;
|
|
1113
|
+
/** GraphQL introspection paths required by the validated `_meta` response. */
|
|
1114
|
+
missingPaths: string[];
|
|
1115
|
+
}
|
|
1116
|
+
interface SchemaEnumValueToken {
|
|
1117
|
+
/** Exact value returned by the Constructive `_meta` contract. */
|
|
1118
|
+
metaValue: string;
|
|
1119
|
+
/** Exact token accepted by GraphQL variables for this enum field. */
|
|
1120
|
+
graphQLValue: string;
|
|
1121
|
+
}
|
|
1122
|
+
interface SchemaEnumFieldMapping {
|
|
1123
|
+
tableName: string;
|
|
1124
|
+
schemaName: string | null;
|
|
1125
|
+
fieldName: string;
|
|
1126
|
+
graphQLTypeName: string;
|
|
1127
|
+
values: SchemaEnumValueToken[];
|
|
1128
|
+
}
|
|
1129
|
+
interface SchemaIntrospectionAnalysis extends SchemaIntrospectionCompatibility {
|
|
1130
|
+
/** Exact, field-scoped mappings from `_meta` enum labels to GraphQL tokens. */
|
|
1131
|
+
enumMappings: SchemaEnumFieldMapping[];
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Cross-check a July `_meta` response against the endpoint's standard GraphQL
|
|
1135
|
+
* introspection result. This uses the schema's declared root type names rather
|
|
1136
|
+
* than assuming `Query` and `Mutation`.
|
|
1137
|
+
*
|
|
1138
|
+
* The `_meta` value must first pass the strict contract signature preflight;
|
|
1139
|
+
* this function still calls `assertMetaQuery` so malformed runtime data cannot
|
|
1140
|
+
* be mistaken for an incompatible GraphQL schema.
|
|
1141
|
+
*/
|
|
1142
|
+
declare function analyzeSchemaIntrospectionCompatibility(introspection: IntrospectionQueryResponse | null | undefined, metaQuery: MetaQuery): SchemaIntrospectionAnalysis;
|
|
1143
|
+
declare function assessSchemaIntrospectionCompatibility(introspection: IntrospectionQueryResponse | null | undefined, metaQuery: MetaQuery): SchemaIntrospectionCompatibility;
|
|
1144
|
+
/**
|
|
1145
|
+
* Translate `_meta` enum labels to the exact tokens accepted by GraphQL.
|
|
1146
|
+
* Unknown values are preserved so GraphQL remains the final input validator.
|
|
1147
|
+
*/
|
|
1148
|
+
declare function normalizeSchemaEnumInputValues(input: Record<string, unknown>, table: Pick<CleanTable, 'name' | 'schemaName'>, mappings: readonly SchemaEnumFieldMapping[]): Record<string, unknown>;
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* Core schema types for representing PostGraphile table metadata
|
|
1152
|
+
* These are "clean" versions that remove nullable/undefined complexity
|
|
1153
|
+
*/
|
|
1154
|
+
/**
|
|
1155
|
+
* Represents a database table with its fields and relations
|
|
1156
|
+
*/
|
|
1157
|
+
interface Table {
|
|
1158
|
+
name: string;
|
|
1159
|
+
/** Description from PostgreSQL COMMENT (smart comments stripped) */
|
|
1160
|
+
description?: string;
|
|
1161
|
+
fields: Field[];
|
|
1162
|
+
relations: Relations;
|
|
1163
|
+
/** PostGraphile inflection rules for this table */
|
|
1164
|
+
inflection?: TableInflection;
|
|
1165
|
+
/** Query operation names from introspection */
|
|
1166
|
+
query?: TableQueryNames;
|
|
1167
|
+
/** Constraint information */
|
|
1168
|
+
constraints?: TableConstraints;
|
|
1169
|
+
/** Smart tags parsed from PostGraphile @-prefixed comment directives */
|
|
1170
|
+
smartTags?: Record<string, string | true>;
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* PostGraphile-generated names for this table
|
|
1174
|
+
*/
|
|
1175
|
+
interface TableInflection {
|
|
1176
|
+
/** All rows connection query name (e.g., "users") */
|
|
1177
|
+
allRows: string;
|
|
1178
|
+
/** Simple all rows query name */
|
|
1179
|
+
allRowsSimple: string;
|
|
1180
|
+
/** Condition type name (e.g., "UserCondition") */
|
|
1181
|
+
conditionType: string;
|
|
1182
|
+
/** Connection type name (e.g., "UsersConnection") */
|
|
1183
|
+
connection: string;
|
|
1184
|
+
/** Create field name */
|
|
1185
|
+
createField: string;
|
|
1186
|
+
/** Create input type (e.g., "CreateUserInput") */
|
|
1187
|
+
createInputType: string;
|
|
1188
|
+
/** Create payload type */
|
|
1189
|
+
createPayloadType: string;
|
|
1190
|
+
/** Delete by primary key mutation name */
|
|
1191
|
+
deleteByPrimaryKey: string | null;
|
|
1192
|
+
/** Delete payload type */
|
|
1193
|
+
deletePayloadType: string;
|
|
1194
|
+
/** Edge type name */
|
|
1195
|
+
edge: string;
|
|
1196
|
+
/** Edge field name */
|
|
1197
|
+
edgeField: string;
|
|
1198
|
+
/** Enum type name */
|
|
1199
|
+
enumType: string;
|
|
1200
|
+
/** Filter type name (e.g., "UserFilter") */
|
|
1201
|
+
filterType: string | null;
|
|
1202
|
+
/** Input type name (e.g., "UserInput") */
|
|
1203
|
+
inputType: string;
|
|
1204
|
+
/** OrderBy enum type (e.g., "UsersOrderBy") */
|
|
1205
|
+
orderByType: string;
|
|
1206
|
+
/** Patch field name */
|
|
1207
|
+
patchField: string;
|
|
1208
|
+
/** Patch type (e.g., "UserPatch") */
|
|
1209
|
+
patchType: string | null;
|
|
1210
|
+
/** Table field name (singular, e.g., "user") */
|
|
1211
|
+
tableFieldName: string;
|
|
1212
|
+
/** Table type name (e.g., "User") */
|
|
1213
|
+
tableType: string;
|
|
1214
|
+
/** Type name */
|
|
1215
|
+
typeName: string;
|
|
1216
|
+
/** Update by primary key mutation name */
|
|
1217
|
+
updateByPrimaryKey: string | null;
|
|
1218
|
+
/** Update payload type */
|
|
1219
|
+
updatePayloadType: string | null;
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Query operation names from introspection
|
|
1223
|
+
*/
|
|
1224
|
+
interface TableQueryNames {
|
|
1225
|
+
/** All rows query name */
|
|
1226
|
+
all: string;
|
|
1227
|
+
/** Single row query name */
|
|
1228
|
+
one: string | null;
|
|
1229
|
+
/** Create mutation name */
|
|
1230
|
+
create: string;
|
|
1231
|
+
/** Update mutation name */
|
|
1232
|
+
update: string | null;
|
|
1233
|
+
/** Delete mutation name */
|
|
1234
|
+
delete: string | null;
|
|
1235
|
+
/** Patch field name in update mutation input (e.g., "userPatch" for UpdateUserInput) */
|
|
1236
|
+
patchFieldName?: string;
|
|
1237
|
+
/** Bulk insert mutation name (e.g., "bulkCreateUsers") */
|
|
1238
|
+
bulkInsert?: string | null;
|
|
1239
|
+
/** Bulk upsert mutation name (e.g., "bulkUpsertUsers") */
|
|
1240
|
+
bulkUpsert?: string | null;
|
|
1241
|
+
/** Bulk update mutation name (e.g., "bulkUpdateUsers") */
|
|
1242
|
+
bulkUpdate?: string | null;
|
|
1243
|
+
/** Bulk delete mutation name (e.g., "bulkDeleteUsers") */
|
|
1244
|
+
bulkDelete?: string | null;
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Table constraints
|
|
1248
|
+
*/
|
|
1249
|
+
interface TableConstraints {
|
|
1250
|
+
primaryKey: ConstraintInfo[];
|
|
1251
|
+
foreignKey: ForeignKeyConstraint[];
|
|
1252
|
+
unique: ConstraintInfo[];
|
|
1253
|
+
}
|
|
1254
|
+
interface ConstraintInfo {
|
|
1255
|
+
name: string;
|
|
1256
|
+
fields: Field[];
|
|
1257
|
+
}
|
|
1258
|
+
interface ForeignKeyConstraint extends ConstraintInfo {
|
|
1259
|
+
refTable: string;
|
|
1260
|
+
refFields: Field[];
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Represents a field/column in a table
|
|
1264
|
+
*/
|
|
1265
|
+
interface Field {
|
|
1266
|
+
name: string;
|
|
1267
|
+
/** Description from PostgreSQL COMMENT (smart comments stripped) */
|
|
1268
|
+
description?: string;
|
|
1269
|
+
type: FieldType;
|
|
1270
|
+
/** Whether the column has a NOT NULL constraint (inferred from NON_NULL wrapper on entity type field) */
|
|
1271
|
+
isNotNull?: boolean | null;
|
|
1272
|
+
/** Whether the column has a DEFAULT value (inferred by comparing entity vs CreateInput field nullability) */
|
|
1273
|
+
hasDefault?: boolean | null;
|
|
1274
|
+
/** Arguments for computed fields (e.g. requestUploadUrl on bucket types) */
|
|
1275
|
+
args?: FieldArgument[];
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* Argument on a computed field (not a root operation)
|
|
1279
|
+
*/
|
|
1280
|
+
interface FieldArgument {
|
|
1281
|
+
name: string;
|
|
1282
|
+
/** GraphQL type reference */
|
|
1283
|
+
type: TypeRef;
|
|
1284
|
+
/** Whether this argument is required (NON_NULL) */
|
|
1285
|
+
isRequired: boolean;
|
|
1286
|
+
/** Description from schema */
|
|
1287
|
+
description?: string;
|
|
1288
|
+
/** Default value (as string) */
|
|
1289
|
+
defaultValue?: string;
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Field type information from PostGraphile introspection
|
|
1293
|
+
*/
|
|
1294
|
+
interface FieldType {
|
|
1295
|
+
/** GraphQL type name (e.g., "String", "UUID", "Int") */
|
|
1296
|
+
gqlType: string;
|
|
1297
|
+
/** Whether this is an array type */
|
|
1298
|
+
isArray: boolean;
|
|
1299
|
+
/** Type modifier (for precision, length, etc.) */
|
|
1300
|
+
modifier?: string | number | null;
|
|
1301
|
+
/** PostgreSQL type alias (domain name) */
|
|
1302
|
+
pgAlias?: string | null;
|
|
1303
|
+
/** PostgreSQL native type (e.g., "text", "uuid", "integer") */
|
|
1304
|
+
pgType?: string | null;
|
|
1305
|
+
/** Subtype for composite types */
|
|
1306
|
+
subtype?: string | null;
|
|
1307
|
+
/** Type modifier from PostgreSQL */
|
|
1308
|
+
typmod?: number | null;
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* All relation types for a table
|
|
1312
|
+
*/
|
|
1313
|
+
interface Relations {
|
|
1314
|
+
belongsTo: BelongsToRelation[];
|
|
1315
|
+
hasOne: HasOneRelation[];
|
|
1316
|
+
hasMany: HasManyRelation[];
|
|
1317
|
+
manyToMany: ManyToManyRelation[];
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* BelongsTo relation (foreign key on this table)
|
|
1321
|
+
*/
|
|
1322
|
+
interface BelongsToRelation {
|
|
1323
|
+
fieldName: string | null;
|
|
1324
|
+
isUnique: boolean;
|
|
1325
|
+
referencesTable: string;
|
|
1326
|
+
type: string | null;
|
|
1327
|
+
keys: Field[];
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* HasOne relation (foreign key on other table, unique)
|
|
1331
|
+
*/
|
|
1332
|
+
interface HasOneRelation {
|
|
1333
|
+
fieldName: string | null;
|
|
1334
|
+
isUnique: boolean;
|
|
1335
|
+
referencedByTable: string;
|
|
1336
|
+
type: string | null;
|
|
1337
|
+
keys: Field[];
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* HasMany relation (foreign key on other table, not unique)
|
|
1341
|
+
*/
|
|
1342
|
+
interface HasManyRelation {
|
|
1343
|
+
fieldName: string | null;
|
|
1344
|
+
isUnique: boolean;
|
|
1345
|
+
referencedByTable: string;
|
|
1346
|
+
type: string | null;
|
|
1347
|
+
keys: Field[];
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* ManyToMany relation (through junction table)
|
|
1351
|
+
*/
|
|
1352
|
+
interface ManyToManyRelation {
|
|
1353
|
+
fieldName: string | null;
|
|
1354
|
+
rightTable: string;
|
|
1355
|
+
junctionTable: string;
|
|
1356
|
+
type: string | null;
|
|
1357
|
+
/** Junction FK field names pointing to the left table */
|
|
1358
|
+
junctionLeftKeyFields?: string[];
|
|
1359
|
+
/** Junction FK field names pointing to the right table */
|
|
1360
|
+
junctionRightKeyFields?: string[];
|
|
1361
|
+
/** Left table key fields (usually just 'id') */
|
|
1362
|
+
leftKeyFields?: string[];
|
|
1363
|
+
/** Right table key fields (usually just 'id') */
|
|
1364
|
+
rightKeyFields?: string[];
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Clean representation of a GraphQL operation (query or mutation)
|
|
1368
|
+
* Derived from introspection data
|
|
1369
|
+
*/
|
|
1370
|
+
interface Operation {
|
|
1371
|
+
/** Operation name (e.g., "login", "currentUser", "cars") */
|
|
1372
|
+
name: string;
|
|
1373
|
+
/** Operation kind */
|
|
1374
|
+
kind: 'query' | 'mutation';
|
|
1375
|
+
/** Arguments/variables for the operation */
|
|
1376
|
+
args: Argument[];
|
|
1377
|
+
/** Return type */
|
|
1378
|
+
returnType: TypeRef;
|
|
1379
|
+
/** Description from schema */
|
|
1380
|
+
description?: string;
|
|
1381
|
+
/** Whether this is deprecated */
|
|
1382
|
+
isDeprecated?: boolean;
|
|
1383
|
+
/** Deprecation reason */
|
|
1384
|
+
deprecationReason?: string;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Clean representation of an operation argument
|
|
1388
|
+
*/
|
|
1389
|
+
interface Argument {
|
|
1390
|
+
/** Argument name */
|
|
1391
|
+
name: string;
|
|
1392
|
+
/** Argument type */
|
|
1393
|
+
type: TypeRef;
|
|
1394
|
+
/** Default value (as string) */
|
|
1395
|
+
defaultValue?: string;
|
|
1396
|
+
/** Description from schema */
|
|
1397
|
+
description?: string;
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Clean type reference - simplified from introspection TypeRef
|
|
1401
|
+
*/
|
|
1402
|
+
interface TypeRef {
|
|
1403
|
+
/** Type kind */
|
|
1404
|
+
kind: 'SCALAR' | 'OBJECT' | 'INPUT_OBJECT' | 'ENUM' | 'LIST' | 'NON_NULL';
|
|
1405
|
+
/** Type name (null for LIST and NON_NULL wrappers) */
|
|
1406
|
+
name: string | null;
|
|
1407
|
+
/** Inner type for LIST and NON_NULL wrappers */
|
|
1408
|
+
ofType?: TypeRef;
|
|
1409
|
+
/** Resolved TypeScript type string */
|
|
1410
|
+
tsType?: string;
|
|
1411
|
+
/** Fields for OBJECT types */
|
|
1412
|
+
fields?: ObjectField[];
|
|
1413
|
+
/** Input fields for INPUT_OBJECT types */
|
|
1414
|
+
inputFields?: Argument[];
|
|
1415
|
+
/** Values for ENUM types */
|
|
1416
|
+
enumValues?: string[];
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Field on an object type
|
|
1420
|
+
*/
|
|
1421
|
+
interface ObjectField {
|
|
1422
|
+
/** Field name */
|
|
1423
|
+
name: string;
|
|
1424
|
+
/** Field type */
|
|
1425
|
+
type: TypeRef;
|
|
1426
|
+
/** Description */
|
|
1427
|
+
description?: string;
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* Registry of all types in the schema for resolution
|
|
1431
|
+
*/
|
|
1432
|
+
type TypeRegistry = Map<string, ResolvedType>;
|
|
1433
|
+
/**
|
|
1434
|
+
* Resolved type with all details populated
|
|
1435
|
+
*/
|
|
1436
|
+
interface ResolvedType {
|
|
1437
|
+
kind: 'SCALAR' | 'OBJECT' | 'INPUT_OBJECT' | 'ENUM' | 'INTERFACE' | 'UNION';
|
|
1438
|
+
name: string;
|
|
1439
|
+
description?: string;
|
|
1440
|
+
/** Fields for OBJECT types */
|
|
1441
|
+
fields?: ObjectField[];
|
|
1442
|
+
/** Input fields for INPUT_OBJECT types */
|
|
1443
|
+
inputFields?: Argument[];
|
|
1444
|
+
/** Values for ENUM types */
|
|
1445
|
+
enumValues?: string[];
|
|
1446
|
+
/** Possible types for UNION types */
|
|
1447
|
+
possibleTypes?: string[];
|
|
1448
|
+
/** Whether this INPUT_OBJECT uses @oneOf (GraphQL 16+ discriminated union input) */
|
|
1449
|
+
isOneOf?: boolean;
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
interface NestedProperties$1 {
|
|
1453
|
+
[key: string]: QueryProperty$1 | NestedProperties$1;
|
|
1454
|
+
}
|
|
1455
|
+
interface QueryProperty$1 {
|
|
1456
|
+
name: string;
|
|
1457
|
+
type: string;
|
|
1458
|
+
isNotNull: boolean;
|
|
1459
|
+
isArray: boolean;
|
|
1460
|
+
isArrayNotNull: boolean;
|
|
1461
|
+
properties?: NestedProperties$1;
|
|
1462
|
+
}
|
|
1463
|
+
interface QueryDefinition$1 {
|
|
1464
|
+
model: string;
|
|
1465
|
+
qtype: 'getMany' | 'getOne' | 'mutation';
|
|
1466
|
+
mutationType?: 'create' | 'patch' | 'delete';
|
|
1467
|
+
selection: string[];
|
|
1468
|
+
properties: Record<string, QueryProperty$1>;
|
|
1469
|
+
}
|
|
1470
|
+
interface MutationDefinition$1 extends QueryDefinition$1 {
|
|
1471
|
+
qtype: 'mutation';
|
|
1472
|
+
mutationType: 'create' | 'patch' | 'delete';
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Runtime QueryBuilder's internal schema map.
|
|
1476
|
+
* Named with 'Query' prefix to avoid collision with the standard
|
|
1477
|
+
* GraphQL IntrospectionSchema from ./introspection.ts
|
|
1478
|
+
*/
|
|
1479
|
+
interface QueryIntrospectionSchema$1 {
|
|
1480
|
+
[key: string]: QueryDefinition$1 | MutationDefinition$1;
|
|
1481
|
+
}
|
|
1482
|
+
interface MetaFieldType$1 {
|
|
1483
|
+
gqlType: string;
|
|
1484
|
+
isArray: boolean;
|
|
1485
|
+
modifier?: string | number | null;
|
|
1486
|
+
pgAlias?: string | null;
|
|
1487
|
+
pgType?: string | null;
|
|
1488
|
+
subtype?: string | null;
|
|
1489
|
+
typmod?: number | null;
|
|
1490
|
+
}
|
|
1491
|
+
interface MetaField$1 {
|
|
1492
|
+
name: string;
|
|
1493
|
+
type: MetaFieldType$1;
|
|
1494
|
+
}
|
|
1495
|
+
interface MetaConstraint$1 {
|
|
1496
|
+
name: string;
|
|
1497
|
+
type: MetaFieldType$1;
|
|
1498
|
+
alias?: string;
|
|
1499
|
+
}
|
|
1500
|
+
interface MetaForeignConstraint$1 {
|
|
1501
|
+
fromKey: MetaConstraint$1;
|
|
1502
|
+
refTable: string;
|
|
1503
|
+
toKey: MetaConstraint$1;
|
|
1504
|
+
}
|
|
1505
|
+
interface MetaTable$1 {
|
|
1506
|
+
name: string;
|
|
1507
|
+
fields: MetaField$1[];
|
|
1508
|
+
primaryConstraints: MetaConstraint$1[];
|
|
1509
|
+
uniqueConstraints: MetaConstraint$1[];
|
|
1510
|
+
foreignConstraints: MetaForeignConstraint$1[];
|
|
1511
|
+
}
|
|
1512
|
+
interface MetaObject$1 {
|
|
1513
|
+
tables: MetaTable$1[];
|
|
1514
|
+
}
|
|
1515
|
+
type GraphQLVariableValue$1 = string | number | boolean | null;
|
|
1516
|
+
interface GraphQLVariables$1 {
|
|
1517
|
+
[key: string]: GraphQLVariableValue$1 | GraphQLVariableValue$1[] | GraphQLVariables$1 | GraphQLVariables$1[];
|
|
1518
|
+
}
|
|
1519
|
+
interface QueryFieldSelection$1 {
|
|
1520
|
+
name: string;
|
|
1521
|
+
isObject: boolean;
|
|
1522
|
+
fieldDefn?: MetaField$1 | Field;
|
|
1523
|
+
selection?: QueryFieldSelection$1[];
|
|
1524
|
+
variables?: GraphQLVariables$1;
|
|
1525
|
+
isBelongTo?: boolean;
|
|
1526
|
+
}
|
|
1527
|
+
interface QuerySelectionOptions$1 {
|
|
1528
|
+
[fieldName: string]: boolean | {
|
|
1529
|
+
select: Record<string, boolean | QuerySelectionOptions$1>;
|
|
1530
|
+
variables?: GraphQLVariables$1;
|
|
1531
|
+
args?: Record<string, unknown>;
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
interface QueryBuilderInstance$1 {
|
|
1535
|
+
_introspection: QueryIntrospectionSchema$1;
|
|
1536
|
+
_meta: MetaObject$1;
|
|
1537
|
+
_edges?: boolean;
|
|
1538
|
+
}
|
|
1539
|
+
interface ASTFunctionParams$1 {
|
|
1540
|
+
queryName: string;
|
|
1541
|
+
operationName: string;
|
|
1542
|
+
query: QueryDefinition$1;
|
|
1543
|
+
selection: QueryFieldSelection$1[];
|
|
1544
|
+
builder?: QueryBuilderInstance$1;
|
|
1545
|
+
}
|
|
1546
|
+
interface MutationASTParams$1 {
|
|
1547
|
+
mutationName: string;
|
|
1548
|
+
operationName: string;
|
|
1549
|
+
mutation: MutationDefinition$1;
|
|
1550
|
+
selection?: QueryFieldSelection$1[];
|
|
1551
|
+
}
|
|
1552
|
+
interface QueryBuilderOptions$1 {
|
|
1553
|
+
meta: MetaObject$1;
|
|
1554
|
+
introspection: QueryIntrospectionSchema$1;
|
|
1555
|
+
}
|
|
1556
|
+
interface QueryBuilderResult$1 {
|
|
1557
|
+
_hash: string;
|
|
1558
|
+
_queryName: string;
|
|
1559
|
+
_ast: DocumentNode;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
/**
|
|
1563
|
+
* Query-related types for building GraphQL operations
|
|
1564
|
+
*/
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* Options for building SELECT queries
|
|
1568
|
+
*/
|
|
1569
|
+
interface QueryOptions {
|
|
1570
|
+
/** Number of records to fetch (alias for first) */
|
|
1571
|
+
first?: number;
|
|
1572
|
+
/** Alias for first */
|
|
1573
|
+
limit?: number;
|
|
1574
|
+
/** Offset for pagination */
|
|
1575
|
+
offset?: number;
|
|
1576
|
+
/** Cursor for forward pagination */
|
|
1577
|
+
after?: string;
|
|
1578
|
+
/** Cursor for backward pagination */
|
|
1579
|
+
before?: string;
|
|
1580
|
+
/** Filter conditions */
|
|
1581
|
+
where?: Filter;
|
|
1582
|
+
/** Sort order */
|
|
1583
|
+
orderBy?: OrderByItem[];
|
|
1584
|
+
/** Field selection options */
|
|
1585
|
+
fieldSelection?: FieldSelection$1;
|
|
1586
|
+
/**
|
|
1587
|
+
* Maps requested relation field names to actual schema field names (or null to omit).
|
|
1588
|
+
* When the mapped name differs from the key, a GraphQL alias is emitted so the
|
|
1589
|
+
* consumer sees a stable field name regardless of the server-side name.
|
|
1590
|
+
*
|
|
1591
|
+
* Example: `{ contact: 'contactByOwnerId' }` emits `contact: contactByOwnerId { … }`
|
|
1592
|
+
* Pass `null` to suppress a relation entirely: `{ internalNotes: null }`
|
|
1593
|
+
*/
|
|
1594
|
+
relationFieldMap?: Record<string, string | null>;
|
|
1595
|
+
/** Include pageInfo in response */
|
|
1596
|
+
includePageInfo?: boolean;
|
|
1597
|
+
}
|
|
1598
|
+
/**
|
|
1599
|
+
* Single order by specification
|
|
1600
|
+
*/
|
|
1601
|
+
interface OrderByItem {
|
|
1602
|
+
field: string;
|
|
1603
|
+
direction: 'asc' | 'desc';
|
|
1604
|
+
}
|
|
1605
|
+
/**
|
|
1606
|
+
* All supported filter operators
|
|
1607
|
+
*/
|
|
1608
|
+
type FilterOperator = 'isNull' | 'equalTo' | 'notEqualTo' | 'distinctFrom' | 'notDistinctFrom' | 'in' | 'notIn' | 'lessThan' | 'lessThanOrEqualTo' | 'greaterThan' | 'greaterThanOrEqualTo' | 'includes' | 'notIncludes' | 'includesInsensitive' | 'notIncludesInsensitive' | 'startsWith' | 'notStartsWith' | 'startsWithInsensitive' | 'notStartsWithInsensitive' | 'endsWith' | 'notEndsWith' | 'endsWithInsensitive' | 'notEndsWithInsensitive' | 'like' | 'notLike' | 'likeInsensitive' | 'notLikeInsensitive' | 'equalToInsensitive' | 'notEqualToInsensitive' | 'distinctFromInsensitive' | 'notDistinctFromInsensitive' | 'inInsensitive' | 'notInInsensitive' | 'contains' | 'containedBy' | 'overlaps' | 'intersects' | 'intersects3D' | 'containsProperly' | 'coveredBy' | 'covers' | 'crosses' | 'disjoint' | 'orderingEquals' | 'touches' | 'within' | 'bboxIntersects2D' | 'bboxIntersects3D' | 'bboxOverlapsOrLeftOf' | 'bboxOverlapsOrRightOf' | 'bboxOverlapsOrBelow' | 'bboxOverlapsOrAbove' | 'bboxLeftOf' | 'bboxRightOf' | 'bboxBelow' | 'bboxAbove' | 'bboxContains' | 'bboxEquals';
|
|
1609
|
+
/**
|
|
1610
|
+
* Filter on a single field
|
|
1611
|
+
*/
|
|
1612
|
+
type FieldFilter = {
|
|
1613
|
+
[K in FilterOperator]?: unknown;
|
|
1614
|
+
};
|
|
1615
|
+
/**
|
|
1616
|
+
* Filter on related records
|
|
1617
|
+
*/
|
|
1618
|
+
interface RelationalFilter {
|
|
1619
|
+
/** All related records must match */
|
|
1620
|
+
every?: Filter;
|
|
1621
|
+
/** At least one related record must match */
|
|
1622
|
+
some?: Filter;
|
|
1623
|
+
/** No related records match */
|
|
1624
|
+
none?: Filter;
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Main filter type - can be nested
|
|
1628
|
+
*/
|
|
1629
|
+
type Filter = {
|
|
1630
|
+
[field: string]: FieldFilter | RelationalFilter | Filter;
|
|
1631
|
+
} & {
|
|
1632
|
+
and?: Filter[];
|
|
1633
|
+
or?: Filter[];
|
|
1634
|
+
not?: Filter;
|
|
1635
|
+
};
|
|
1636
|
+
|
|
1637
|
+
/**
|
|
1638
|
+
* Mutation-related types
|
|
1639
|
+
*/
|
|
1640
|
+
|
|
1641
|
+
/**
|
|
1642
|
+
* Options for mutation operations
|
|
1643
|
+
*/
|
|
1644
|
+
interface MutationOptions {
|
|
1645
|
+
/** Fields to return after mutation */
|
|
1646
|
+
returning?: string[];
|
|
1647
|
+
/** Field selection for returned data */
|
|
1648
|
+
fieldSelection?: FieldSelection$1;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
declare class QueryBuilder$1 {
|
|
1652
|
+
_introspection: QueryIntrospectionSchema$1;
|
|
1653
|
+
_meta: MetaObject$1;
|
|
1654
|
+
private _models;
|
|
1655
|
+
private _model;
|
|
1656
|
+
private _key;
|
|
1657
|
+
private _queryName;
|
|
1658
|
+
private _ast;
|
|
1659
|
+
_edges: boolean;
|
|
1660
|
+
private _op;
|
|
1661
|
+
private _mutation;
|
|
1662
|
+
private _select;
|
|
1663
|
+
constructor({ meta, introspection }: QueryBuilderOptions$1);
|
|
1664
|
+
initModelMap(): void;
|
|
1665
|
+
clear(): void;
|
|
1666
|
+
query(model: string): QueryBuilder$1;
|
|
1667
|
+
_findQuery(): string;
|
|
1668
|
+
_findMutation(): string;
|
|
1669
|
+
select(selection?: QuerySelectionOptions$1 | null): QueryBuilder$1;
|
|
1670
|
+
edges(useEdges: boolean): QueryBuilder$1;
|
|
1671
|
+
getMany({ select }?: {
|
|
1672
|
+
select?: QuerySelectionOptions$1;
|
|
1673
|
+
}): QueryBuilder$1;
|
|
1674
|
+
all({ select }?: {
|
|
1675
|
+
select?: QuerySelectionOptions$1;
|
|
1676
|
+
}): QueryBuilder$1;
|
|
1677
|
+
count(): QueryBuilder$1;
|
|
1678
|
+
getOne({ select }?: {
|
|
1679
|
+
select?: QuerySelectionOptions$1;
|
|
1680
|
+
}): QueryBuilder$1;
|
|
1681
|
+
create({ select }?: {
|
|
1682
|
+
select?: QuerySelectionOptions$1;
|
|
1683
|
+
}): QueryBuilder$1;
|
|
1684
|
+
delete({ select }?: {
|
|
1685
|
+
select?: QuerySelectionOptions$1;
|
|
1686
|
+
}): QueryBuilder$1;
|
|
1687
|
+
update({ select }?: {
|
|
1688
|
+
select?: QuerySelectionOptions$1;
|
|
1689
|
+
}): QueryBuilder$1;
|
|
1690
|
+
queryName(name: string): QueryBuilder$1;
|
|
1691
|
+
print(): QueryBuilderResult$1;
|
|
1692
|
+
pickScalarFields: (selection: QuerySelectionOptions$1 | null, defn: QueryDefinition$1) => QueryFieldSelection$1[];
|
|
1693
|
+
pickAllFields: (selection: QuerySelectionOptions$1, defn: QueryDefinition$1) => QueryFieldSelection$1[];
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
/**
|
|
1697
|
+
* Convert Table to MetaObject format for QueryBuilder
|
|
1698
|
+
*/
|
|
1699
|
+
declare function cleanTableToMetaObject(tables: Table[]): MetaObject$1;
|
|
1700
|
+
/**
|
|
1701
|
+
* Generate basic IntrospectionSchema from Table array
|
|
1702
|
+
* This creates a minimal schema for AST generation
|
|
1703
|
+
*/
|
|
1704
|
+
declare function generateIntrospectionSchema(tables: Table[]): QueryIntrospectionSchema$1;
|
|
1705
|
+
/**
|
|
1706
|
+
* Create AST-based query builder for a table
|
|
1707
|
+
*/
|
|
1708
|
+
declare function createASTQueryBuilder(tables: Table[]): QueryBuilder$1;
|
|
1709
|
+
/**
|
|
1710
|
+
* Build a SELECT query for a table with optional filtering, sorting, and pagination
|
|
1711
|
+
* Uses direct AST generation without intermediate conversions
|
|
1712
|
+
*/
|
|
1713
|
+
declare function buildSelect(table: Table, allTables: readonly Table[], options?: QueryOptions): TypedDocumentString<Record<string, unknown>, QueryOptions>;
|
|
1714
|
+
/**
|
|
1715
|
+
* Build a single row query by primary key or unique field
|
|
1716
|
+
*/
|
|
1717
|
+
declare function buildFindOne(table: Table, _pkField?: string): TypedDocumentString<Record<string, unknown>, Record<string, unknown>>;
|
|
1718
|
+
/**
|
|
1719
|
+
* Build a count query for a table
|
|
1720
|
+
*/
|
|
1721
|
+
declare function buildCount(table: Table): TypedDocumentString<{
|
|
1722
|
+
[key: string]: {
|
|
1723
|
+
totalCount: number;
|
|
1724
|
+
};
|
|
1725
|
+
}, {
|
|
1726
|
+
condition?: Record<string, unknown>;
|
|
1727
|
+
filter?: Record<string, unknown>;
|
|
1728
|
+
}>;
|
|
1729
|
+
|
|
1730
|
+
/**
|
|
1731
|
+
* Build PostGraphile-style CREATE mutation
|
|
1732
|
+
* PostGraphile expects: mutation { createTableName(input: { tableName: TableNameInput! }) { tableName { ... } } }
|
|
1733
|
+
*/
|
|
1734
|
+
declare function buildPostGraphileCreate(table: Table, _allTables: Table[], _options?: MutationOptions): TypedDocumentString<Record<string, unknown>, {
|
|
1735
|
+
input: {
|
|
1736
|
+
[key: string]: Record<string, unknown>;
|
|
1737
|
+
};
|
|
1738
|
+
}>;
|
|
1739
|
+
/**
|
|
1740
|
+
* Build PostGraphile-style UPDATE mutation
|
|
1741
|
+
* PostGraphile expects: mutation { updateTableName(input: { id: UUID!, patch: TableNamePatch! }) { tableName { ... } } }
|
|
1742
|
+
*/
|
|
1743
|
+
declare function buildPostGraphileUpdate(table: Table, _allTables: Table[], _options?: MutationOptions): TypedDocumentString<Record<string, unknown>, {
|
|
1744
|
+
input: {
|
|
1745
|
+
id: string | number;
|
|
1746
|
+
} & Record<string, unknown>;
|
|
1747
|
+
}>;
|
|
1748
|
+
/**
|
|
1749
|
+
* Build PostGraphile-style DELETE mutation
|
|
1750
|
+
* PostGraphile expects: mutation { deleteTableName(input: { id: UUID! }) { clientMutationId } }
|
|
1751
|
+
*/
|
|
1752
|
+
declare function buildPostGraphileDelete(table: Table, _allTables: Table[], _options?: MutationOptions): TypedDocumentString<Record<string, unknown>, {
|
|
1753
|
+
input: {
|
|
1754
|
+
id: string | number;
|
|
1755
|
+
};
|
|
1756
|
+
}>;
|
|
1757
|
+
|
|
1758
|
+
/**
|
|
1759
|
+
* Simplified field selection system
|
|
1760
|
+
* Converts user-friendly selection options to internal SelectionOptions format
|
|
1761
|
+
*/
|
|
1762
|
+
|
|
1763
|
+
/**
|
|
1764
|
+
* Convert simplified field selection to QueryBuilder SelectionOptions
|
|
1765
|
+
*/
|
|
1766
|
+
declare function convertToSelectionOptions(table: Table, allTables: Table[], selection?: FieldSelection$1): QuerySelectionOptions$1 | null;
|
|
1767
|
+
/**
|
|
1768
|
+
* Check if a field is relational using table metadata
|
|
1769
|
+
*/
|
|
1770
|
+
declare function isRelationalField(fieldName: string, table: Table): boolean;
|
|
1771
|
+
/**
|
|
1772
|
+
* Get all available relation fields from a table
|
|
1773
|
+
*/
|
|
1774
|
+
declare function getAvailableRelations(table: Table): Array<{
|
|
1775
|
+
fieldName: string;
|
|
1776
|
+
type: 'belongsTo' | 'hasOne' | 'hasMany' | 'manyToMany';
|
|
1777
|
+
referencedTable?: string;
|
|
1778
|
+
}>;
|
|
1779
|
+
/**
|
|
1780
|
+
* Validate field selection against table schema
|
|
1781
|
+
*/
|
|
1782
|
+
declare function validateFieldSelection(selection: FieldSelection$1, table: Table): {
|
|
1783
|
+
isValid: boolean;
|
|
1784
|
+
errors: string[];
|
|
1785
|
+
};
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Safely normalise a server-provided inflection value.
|
|
1789
|
+
* Returns `null` for null, undefined, or whitespace-only strings.
|
|
1790
|
+
*/
|
|
1791
|
+
declare function normalizeInflectionValue(value: string | null | undefined): string | null;
|
|
1792
|
+
/**
|
|
1793
|
+
* Convert PascalCase table name to camelCase plural for GraphQL queries.
|
|
1794
|
+
* Prefers server-provided `table.query.all` / `table.inflection.allRows`
|
|
1795
|
+
* when available, with guards against naive pluralisation drift and
|
|
1796
|
+
* missing camelCase boundaries.
|
|
1797
|
+
*
|
|
1798
|
+
* Example: "ActionGoal" -> "actionGoals", "User" -> "users", "Person" -> "people"
|
|
1799
|
+
*/
|
|
1800
|
+
declare function toCamelCasePlural(tableName: string, table?: Table | null): string;
|
|
1801
|
+
/**
|
|
1802
|
+
* Convert PascalCase table name to camelCase singular field name.
|
|
1803
|
+
* Prefers server-provided names when available.
|
|
1804
|
+
*/
|
|
1805
|
+
declare function toCamelCaseSingular(tableName: string, table?: Table | null): string;
|
|
1806
|
+
declare function toCreateMutationName(tableName: string, table?: Table | null): string;
|
|
1807
|
+
declare function toUpdateMutationName(tableName: string, table?: Table | null): string;
|
|
1808
|
+
declare function toDeleteMutationName(tableName: string, table?: Table | null): string;
|
|
1809
|
+
declare function toCreateInputTypeName(tableName: string, table?: Table | null): string;
|
|
1810
|
+
declare function toUpdateInputTypeName(tableName: string): string;
|
|
1811
|
+
declare function toDeleteInputTypeName(tableName: string): string;
|
|
1812
|
+
declare function toFilterTypeName(tableName: string, table?: Table | null): string;
|
|
1813
|
+
/**
|
|
1814
|
+
* Resolve PostGraphile patch field name.
|
|
1815
|
+
* In v5 this is typically entity-specific: e.g. "userPatch", "contactPatch".
|
|
1816
|
+
* Prefers the value discovered from the schema (`table.query.patchFieldName`
|
|
1817
|
+
* or `table.inflection.patchField`), falls back to `${singularName}Patch`.
|
|
1818
|
+
*/
|
|
1819
|
+
declare function toPatchFieldName(tableName: string, table?: Table | null): string;
|
|
1820
|
+
/**
|
|
1821
|
+
* Convert camelCase field name to SCREAMING_SNAKE_CASE for PostGraphile
|
|
1822
|
+
* orderBy enums.
|
|
1823
|
+
*
|
|
1824
|
+
* "displayName" -> "DISPLAY_NAME_ASC"
|
|
1825
|
+
* "createdAt" -> "CREATED_AT_DESC"
|
|
1826
|
+
* "id" -> "ID_ASC"
|
|
1827
|
+
*/
|
|
1828
|
+
declare function toOrderByEnumValue(fieldName: string, direction: 'asc' | 'desc'): string;
|
|
1829
|
+
/**
|
|
1830
|
+
* Generate the PostGraphile OrderBy enum type name for a table.
|
|
1831
|
+
* Prefers server-provided `table.inflection.orderByType` when available.
|
|
1832
|
+
*/
|
|
1833
|
+
declare function toOrderByTypeName(tableName: string, table?: Table | null): string;
|
|
1834
|
+
|
|
1835
|
+
/**
|
|
1836
|
+
* Centralized error handling for the data layer
|
|
1837
|
+
* Provides consistent error types, messages, and handling patterns
|
|
1838
|
+
*/
|
|
1839
|
+
declare const DataErrorType: {
|
|
1840
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
1841
|
+
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
1842
|
+
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
1843
|
+
readonly REQUIRED_FIELD_MISSING: "REQUIRED_FIELD_MISSING";
|
|
1844
|
+
readonly INVALID_MUTATION_DATA: "INVALID_MUTATION_DATA";
|
|
1845
|
+
readonly QUERY_GENERATION_FAILED: "QUERY_GENERATION_FAILED";
|
|
1846
|
+
readonly QUERY_EXECUTION_FAILED: "QUERY_EXECUTION_FAILED";
|
|
1847
|
+
readonly UNAUTHORIZED: "UNAUTHORIZED";
|
|
1848
|
+
readonly FORBIDDEN: "FORBIDDEN";
|
|
1849
|
+
readonly TABLE_NOT_FOUND: "TABLE_NOT_FOUND";
|
|
1850
|
+
readonly BAD_REQUEST: "BAD_REQUEST";
|
|
1851
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
1852
|
+
readonly GRAPHQL_ERROR: "GRAPHQL_ERROR";
|
|
1853
|
+
readonly UNIQUE_VIOLATION: "UNIQUE_VIOLATION";
|
|
1854
|
+
readonly FOREIGN_KEY_VIOLATION: "FOREIGN_KEY_VIOLATION";
|
|
1855
|
+
readonly NOT_NULL_VIOLATION: "NOT_NULL_VIOLATION";
|
|
1856
|
+
readonly CHECK_VIOLATION: "CHECK_VIOLATION";
|
|
1857
|
+
readonly EXCLUSION_VIOLATION: "EXCLUSION_VIOLATION";
|
|
1858
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
1859
|
+
};
|
|
1860
|
+
type DataErrorType = (typeof DataErrorType)[keyof typeof DataErrorType];
|
|
1861
|
+
interface DataErrorOptions {
|
|
1862
|
+
/** Optional table name for data-layer operations */
|
|
1863
|
+
tableName?: string;
|
|
1864
|
+
/** Optional field name for data-layer operations */
|
|
1865
|
+
fieldName?: string;
|
|
1866
|
+
/** Optional constraint name for PostgreSQL constraint violations */
|
|
1867
|
+
constraint?: string;
|
|
1868
|
+
originalError?: Error;
|
|
1869
|
+
code?: string;
|
|
1870
|
+
context?: Record<string, unknown>;
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* Standard data layer error class
|
|
1874
|
+
*/
|
|
1875
|
+
declare class DataError extends Error {
|
|
1876
|
+
readonly type: DataErrorType;
|
|
1877
|
+
readonly code?: string;
|
|
1878
|
+
readonly originalError?: Error;
|
|
1879
|
+
readonly context?: Record<string, unknown>;
|
|
1880
|
+
readonly tableName?: string;
|
|
1881
|
+
readonly fieldName?: string;
|
|
1882
|
+
readonly constraint?: string;
|
|
1883
|
+
constructor(type: DataErrorType, message: string, options?: DataErrorOptions);
|
|
1884
|
+
/**
|
|
1885
|
+
* Get a user-friendly error message.
|
|
1886
|
+
* Checks constraint-specific messages first, then falls back to generic messages.
|
|
1887
|
+
*/
|
|
1888
|
+
getUserMessage(): string;
|
|
1889
|
+
/**
|
|
1890
|
+
* Check if this error is retryable
|
|
1891
|
+
*/
|
|
1892
|
+
isRetryable(): boolean;
|
|
1893
|
+
/**
|
|
1894
|
+
* Get error details for logging
|
|
1895
|
+
*/
|
|
1896
|
+
getLogDetails(): Record<string, unknown>;
|
|
1897
|
+
}
|
|
1898
|
+
interface GraphQLErrorLocation {
|
|
1899
|
+
line: number;
|
|
1900
|
+
column: number;
|
|
1901
|
+
}
|
|
1902
|
+
type GraphQLErrorPath = Array<string | number>;
|
|
1903
|
+
interface GraphQLError {
|
|
1904
|
+
message: string;
|
|
1905
|
+
extensions?: {
|
|
1906
|
+
code?: string;
|
|
1907
|
+
} & Record<string, unknown>;
|
|
1908
|
+
locations?: GraphQLErrorLocation[];
|
|
1909
|
+
path?: GraphQLErrorPath;
|
|
1910
|
+
}
|
|
1911
|
+
declare const createDataError: {
|
|
1912
|
+
networkError: (originalError?: Error, tableName?: string) => DataError;
|
|
1913
|
+
timeoutError: (originalError?: Error, tableName?: string) => DataError;
|
|
1914
|
+
validationFailed: (tableName: string | undefined, validationErrors: string[]) => DataError;
|
|
1915
|
+
requiredFieldMissing: (fieldName: string, tableName?: string) => DataError;
|
|
1916
|
+
unauthorized: (message?: string, tableName?: string) => DataError;
|
|
1917
|
+
forbidden: (tableName?: string) => DataError;
|
|
1918
|
+
queryGenerationFailed: (message: string, tableName?: string, code?: string) => DataError;
|
|
1919
|
+
queryExecutionFailed: (message: string, tableName?: string, code?: string) => DataError;
|
|
1920
|
+
tableNotFound: (message?: string, tableName?: string, code?: string) => DataError;
|
|
1921
|
+
invalidMutationData: (message: string, tableName?: string, code?: string, context?: Record<string, unknown>) => DataError;
|
|
1922
|
+
uniqueViolation: (message: string, tableName?: string, fieldName?: string, constraint?: string) => DataError;
|
|
1923
|
+
foreignKeyViolation: (message: string, tableName?: string, fieldName?: string, constraint?: string) => DataError;
|
|
1924
|
+
notNullViolation: (message: string, tableName?: string, fieldName?: string, constraint?: string) => DataError;
|
|
1925
|
+
checkViolation: (message: string, tableName?: string, fieldName?: string, constraint?: string) => DataError;
|
|
1926
|
+
exclusionViolation: (message: string, tableName?: string, constraint?: string) => DataError;
|
|
1927
|
+
unknown: (originalError: Error, tableName?: string) => DataError;
|
|
1928
|
+
};
|
|
1929
|
+
declare const createError: {
|
|
1930
|
+
network: (originalError?: Error) => DataError;
|
|
1931
|
+
timeout: (originalError?: Error) => DataError;
|
|
1932
|
+
unauthorized: (message?: string) => DataError;
|
|
1933
|
+
forbidden: (message?: string) => DataError;
|
|
1934
|
+
badRequest: (message: string, code?: string) => DataError;
|
|
1935
|
+
notFound: (message?: string) => DataError;
|
|
1936
|
+
graphql: (message: string, code?: string) => DataError;
|
|
1937
|
+
unknown: (originalError: Error) => DataError;
|
|
1938
|
+
};
|
|
1939
|
+
/**
|
|
1940
|
+
* PostgreSQL SQLSTATE error codes
|
|
1941
|
+
* https://www.postgresql.org/docs/current/errcodes-appendix.html
|
|
1942
|
+
*/
|
|
1943
|
+
declare const PG_ERROR_CODES: {
|
|
1944
|
+
readonly UNIQUE_VIOLATION: "23505";
|
|
1945
|
+
readonly FOREIGN_KEY_VIOLATION: "23503";
|
|
1946
|
+
readonly NOT_NULL_VIOLATION: "23502";
|
|
1947
|
+
readonly CHECK_VIOLATION: "23514";
|
|
1948
|
+
readonly EXCLUSION_VIOLATION: "23P01";
|
|
1949
|
+
readonly NUMERIC_VALUE_OUT_OF_RANGE: "22003";
|
|
1950
|
+
readonly STRING_DATA_RIGHT_TRUNCATION: "22001";
|
|
1951
|
+
readonly INVALID_TEXT_REPRESENTATION: "22P02";
|
|
1952
|
+
readonly DATETIME_FIELD_OVERFLOW: "22008";
|
|
1953
|
+
readonly UNDEFINED_TABLE: "42P01";
|
|
1954
|
+
readonly UNDEFINED_COLUMN: "42703";
|
|
1955
|
+
readonly INSUFFICIENT_PRIVILEGE: "42501";
|
|
1956
|
+
readonly DISK_FULL: "53100";
|
|
1957
|
+
readonly OUT_OF_MEMORY: "53200";
|
|
1958
|
+
readonly TOO_MANY_CONNECTIONS: "53300";
|
|
1959
|
+
};
|
|
1960
|
+
declare function parseGraphQLErrorCode(code: string | undefined): DataErrorType;
|
|
1961
|
+
/**
|
|
1962
|
+
* Generic error matching API.
|
|
1963
|
+
* Works with any DataErrorType — no need for per-type helper functions.
|
|
1964
|
+
*/
|
|
1965
|
+
declare const Errors: {
|
|
1966
|
+
/** Map a raw extensions.code to its DataErrorType */
|
|
1967
|
+
readonly parse: (code: string | undefined) => DataErrorType;
|
|
1968
|
+
/** Check if a raw extensions.code matches a DataErrorType */
|
|
1969
|
+
readonly is: (code: unknown, type: DataErrorType) => boolean;
|
|
1970
|
+
/** Check if any error object matches a DataErrorType */
|
|
1971
|
+
readonly match: (error: unknown, type: DataErrorType) => boolean;
|
|
1972
|
+
/** Parse any error into a classified DataError */
|
|
1973
|
+
readonly from: (error: unknown, tableName?: string) => DataError;
|
|
1974
|
+
};
|
|
1975
|
+
/**
|
|
1976
|
+
* Parse any error into a DataError.
|
|
1977
|
+
* Optional tableName adds context for data-layer operations.
|
|
1978
|
+
*/
|
|
1979
|
+
declare function parseGraphQLError(error: unknown, tableName?: string): DataError;
|
|
1980
|
+
declare function parseError(error: unknown): DataError;
|
|
1981
|
+
declare function handleDataError(error: unknown, tableName?: string): DataError;
|
|
1982
|
+
declare function withRetry<T>(fn: () => Promise<T>, maxRetries?: number, delayMs?: number): Promise<T>;
|
|
1983
|
+
/**
|
|
1984
|
+
* Constraint-specific human-friendly messages.
|
|
1985
|
+
* Keys can be:
|
|
1986
|
+
* - Exact constraint name: "database_schema_hash_key"
|
|
1987
|
+
* - Pattern with wildcard prefix: "*_name_key" (matches any table's name unique constraint)
|
|
1988
|
+
*
|
|
1989
|
+
* To add new translations, simply add entries to this map.
|
|
1990
|
+
*/
|
|
1991
|
+
declare const CONSTRAINT_MESSAGES: Record<string, string>;
|
|
1992
|
+
/**
|
|
1993
|
+
* Get human-friendly message for a constraint violation.
|
|
1994
|
+
* Checks exact match first, then pattern matches with * prefix.
|
|
1995
|
+
*/
|
|
1996
|
+
declare function getConstraintMessage(constraint: string | undefined): string | undefined;
|
|
1997
|
+
/**
|
|
1998
|
+
* Parse any error and return a human-readable message.
|
|
1999
|
+
* Use this in UI components for displaying errors to users.
|
|
2000
|
+
*
|
|
2001
|
+
* @param error - Any error (Error, GraphQL error, string, etc.)
|
|
2002
|
+
* @param tableName - Optional table name for context
|
|
2003
|
+
* @returns Human-friendly error message
|
|
2004
|
+
*/
|
|
2005
|
+
declare function getHumanReadableError(error: unknown, tableName?: string): string;
|
|
2006
|
+
|
|
2007
|
+
/**
|
|
2008
|
+
* Centralized mutation input filtering utilities.
|
|
2009
|
+
*
|
|
2010
|
+
* Provides consistent nullish value handling when passing data from React
|
|
2011
|
+
* components to GraphQL mutations. Supports recursive nested object filtering
|
|
2012
|
+
* and form dirty field tracking.
|
|
2013
|
+
*
|
|
2014
|
+
* @see apps/admin/docs/MUTATION_INPUT_FILTERING_SPEC.md
|
|
2015
|
+
*/
|
|
2016
|
+
/**
|
|
2017
|
+
* Makes specific keys of T optional while keeping the rest required.
|
|
2018
|
+
* Useful when a generated type marks a field as required (e.g. `inheritsId: string`)
|
|
2019
|
+
* but the GraphQL schema treats it as optional (server creates it).
|
|
2020
|
+
*
|
|
2021
|
+
* @example
|
|
2022
|
+
* type Input = { name: string; inheritsId: string; databaseId: string };
|
|
2023
|
+
* type SafeInput = PartialBy<Input, 'inheritsId' | 'databaseId'>;
|
|
2024
|
+
* // => { name: string; inheritsId?: string; databaseId?: string }
|
|
2025
|
+
*/
|
|
2026
|
+
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
2027
|
+
/**
|
|
2028
|
+
* Converts null, undefined, and empty strings to undefined.
|
|
2029
|
+
* Unlike `value || undefined`, this preserves `false`, `0`, and `[]`.
|
|
2030
|
+
*
|
|
2031
|
+
* Use in SDK hook call sites where `|| undefined` would incorrectly strip falsy values.
|
|
2032
|
+
*
|
|
2033
|
+
* @example
|
|
2034
|
+
* stripEmpty('') // undefined
|
|
2035
|
+
* stripEmpty(null) // undefined
|
|
2036
|
+
* stripEmpty(undefined) // undefined
|
|
2037
|
+
* stripEmpty(false) // false ← || undefined would break this
|
|
2038
|
+
* stripEmpty(0) // 0
|
|
2039
|
+
* stripEmpty('hello') // 'hello'
|
|
2040
|
+
*/
|
|
2041
|
+
declare function stripEmpty<T>(value: T | null | undefined): NonNullable<T> | undefined;
|
|
2042
|
+
/**
|
|
2043
|
+
* Casts a string array for array columns (e.g. `fieldIds`, `refFieldIds`).
|
|
2044
|
+
* Codegen types create inputs as `string[]` but patch inputs as `string` — runtime accepts both.
|
|
2045
|
+
*/
|
|
2046
|
+
declare const asFieldIds: (ids: string[]) => any;
|
|
2047
|
+
interface PrepareInputOptions {
|
|
2048
|
+
/** Operation type affects null/empty string handling */
|
|
2049
|
+
operation: 'create' | 'update' | 'patch';
|
|
2050
|
+
/**
|
|
2051
|
+
* Fields that user explicitly modified (from form dirty tracking).
|
|
2052
|
+
* Supports dot notation for nested fields: "settings.theme", "address.city"
|
|
2053
|
+
* If not provided, all fields are considered dirty (backward compat for non-form usage).
|
|
2054
|
+
*/
|
|
2055
|
+
dirtyFields?: Set<string>;
|
|
2056
|
+
/** Default values to compare against (for detecting changes) */
|
|
2057
|
+
defaultValues?: Record<string, unknown>;
|
|
2058
|
+
/** Fields that should always be included even if nullish */
|
|
2059
|
+
alwaysInclude?: string[];
|
|
2060
|
+
/** Fields that should never be sent (e.g., computed, read-only) */
|
|
2061
|
+
exclude?: string[];
|
|
2062
|
+
/**
|
|
2063
|
+
* Current path prefix for recursive calls (internal use).
|
|
2064
|
+
* Users don't need to set this - it's used during recursion.
|
|
2065
|
+
* @internal
|
|
2066
|
+
*/
|
|
2067
|
+
_pathPrefix?: string;
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* Prepares mutation input by filtering nullish values based on operation type
|
|
2071
|
+
* and dirty field tracking. Recursively processes nested objects.
|
|
2072
|
+
*
|
|
2073
|
+
* Filtering rules:
|
|
2074
|
+
* - `undefined`: Always omitted
|
|
2075
|
+
* - `null`: Omitted unless field is dirty (user explicitly cleared)
|
|
2076
|
+
* - `""` (empty string): For CREATE, omitted unless dirty. For UPDATE, kept.
|
|
2077
|
+
* - `[]` (empty array): Kept (valid value meaning "none selected")
|
|
2078
|
+
* - `{}` (empty object after filtering): Omitted
|
|
2079
|
+
* - Nested objects: Recursively filtered
|
|
2080
|
+
*
|
|
2081
|
+
* @example
|
|
2082
|
+
* // Simple CREATE - filters nullish
|
|
2083
|
+
* prepareMutationInput({ name: 'test', desc: undefined }, { operation: 'create' })
|
|
2084
|
+
* // => { name: 'test' }
|
|
2085
|
+
*
|
|
2086
|
+
* @example
|
|
2087
|
+
* // UPDATE with dirty tracking - keeps null for clearing
|
|
2088
|
+
* prepareMutationInput(
|
|
2089
|
+
* { name: 'test', desc: null },
|
|
2090
|
+
* { operation: 'update', dirtyFields: new Set(['name', 'desc']) }
|
|
2091
|
+
* )
|
|
2092
|
+
* // => { name: 'test', desc: null }
|
|
2093
|
+
*
|
|
2094
|
+
* @example
|
|
2095
|
+
* // Nested object filtering
|
|
2096
|
+
* prepareMutationInput(
|
|
2097
|
+
* { settings: { theme: 'dark', unused: undefined } },
|
|
2098
|
+
* { operation: 'create' }
|
|
2099
|
+
* )
|
|
2100
|
+
* // => { settings: { theme: 'dark' } }
|
|
2101
|
+
*/
|
|
2102
|
+
declare function prepareMutationInput<T extends Record<string, unknown>>(input: T, options: PrepareInputOptions): Partial<T>;
|
|
2103
|
+
/**
|
|
2104
|
+
* Prepare input for CREATE operations.
|
|
2105
|
+
*
|
|
2106
|
+
* Applies aggressive filtering:
|
|
2107
|
+
* - Omits `undefined`
|
|
2108
|
+
* - Omits `null` unless field is dirty
|
|
2109
|
+
* - Omits empty strings `""` unless field is dirty
|
|
2110
|
+
* - Keeps empty arrays `[]` (valid value)
|
|
2111
|
+
* - Recursively filters nested objects
|
|
2112
|
+
*
|
|
2113
|
+
* @example
|
|
2114
|
+
* prepareCreateInput({ name: 'test', desc: undefined, tags: [] })
|
|
2115
|
+
* // => { name: 'test', tags: [] }
|
|
2116
|
+
*/
|
|
2117
|
+
declare function prepareCreateInput<T extends Record<string, unknown>>(input: T, options?: Omit<PrepareInputOptions, 'operation'>): Partial<T>;
|
|
2118
|
+
/**
|
|
2119
|
+
* Prepare input for UPDATE operations.
|
|
2120
|
+
*
|
|
2121
|
+
* Preserves null values for field clearing:
|
|
2122
|
+
* - Omits `undefined`
|
|
2123
|
+
* - Keeps `null` when field is dirty (for clearing)
|
|
2124
|
+
* - Keeps empty strings `""`
|
|
2125
|
+
* - Keeps empty arrays `[]`
|
|
2126
|
+
* - Recursively filters nested objects
|
|
2127
|
+
*
|
|
2128
|
+
* @example
|
|
2129
|
+
* prepareUpdateInput(
|
|
2130
|
+
* { name: 'test', desc: null },
|
|
2131
|
+
* { dirtyFields: new Set(['name', 'desc']) }
|
|
2132
|
+
* )
|
|
2133
|
+
* // => { name: 'test', desc: null }
|
|
2134
|
+
*/
|
|
2135
|
+
declare function prepareUpdateInput<T extends Record<string, unknown>>(input: T, options?: Omit<PrepareInputOptions, 'operation'>): Partial<T>;
|
|
2136
|
+
/**
|
|
2137
|
+
* Prepare input for PATCH operations.
|
|
2138
|
+
*
|
|
2139
|
+
* Requires dirty fields - only sends fields that changed.
|
|
2140
|
+
* Same filtering rules as UPDATE.
|
|
2141
|
+
*
|
|
2142
|
+
* @example
|
|
2143
|
+
* preparePatchInput(
|
|
2144
|
+
* { name: 'test', desc: 'old', status: 'active' },
|
|
2145
|
+
* new Set(['name'])
|
|
2146
|
+
* )
|
|
2147
|
+
* // => { name: 'test' }
|
|
2148
|
+
*/
|
|
2149
|
+
declare function preparePatchInput<T extends Record<string, unknown>>(input: T, dirtyFields: Set<string>, options?: Omit<PrepareInputOptions, 'operation' | 'dirtyFields'>): Partial<T>;
|
|
2150
|
+
|
|
2151
|
+
declare class QueryBuilder {
|
|
2152
|
+
_introspection: QueryIntrospectionSchema$1;
|
|
2153
|
+
_meta: MetaObject$1;
|
|
2154
|
+
private _models;
|
|
2155
|
+
private _model;
|
|
2156
|
+
private _key;
|
|
2157
|
+
private _queryName;
|
|
2158
|
+
private _ast;
|
|
2159
|
+
_edges: boolean;
|
|
2160
|
+
private _op;
|
|
2161
|
+
private _mutation;
|
|
2162
|
+
private _select;
|
|
2163
|
+
constructor({ meta, introspection }: QueryBuilderOptions$1);
|
|
2164
|
+
initModelMap(): void;
|
|
2165
|
+
clear(): void;
|
|
2166
|
+
query(model: string): QueryBuilder;
|
|
2167
|
+
_findQuery(): string;
|
|
2168
|
+
_findMutation(): string;
|
|
2169
|
+
select(selection?: QuerySelectionOptions$1 | null): QueryBuilder;
|
|
2170
|
+
edges(useEdges: boolean): QueryBuilder;
|
|
2171
|
+
getMany({ select }?: {
|
|
2172
|
+
select?: QuerySelectionOptions$1;
|
|
2173
|
+
}): QueryBuilder;
|
|
2174
|
+
all({ select }?: {
|
|
2175
|
+
select?: QuerySelectionOptions$1;
|
|
2176
|
+
}): QueryBuilder;
|
|
2177
|
+
count(): QueryBuilder;
|
|
2178
|
+
getOne({ select }?: {
|
|
2179
|
+
select?: QuerySelectionOptions$1;
|
|
2180
|
+
}): QueryBuilder;
|
|
2181
|
+
create({ select }?: {
|
|
2182
|
+
select?: QuerySelectionOptions$1;
|
|
2183
|
+
}): QueryBuilder;
|
|
2184
|
+
delete({ select }?: {
|
|
2185
|
+
select?: QuerySelectionOptions$1;
|
|
2186
|
+
}): QueryBuilder;
|
|
2187
|
+
update({ select }?: {
|
|
2188
|
+
select?: QuerySelectionOptions$1;
|
|
2189
|
+
}): QueryBuilder;
|
|
2190
|
+
queryName(name: string): QueryBuilder;
|
|
2191
|
+
print(): QueryBuilderResult$1;
|
|
2192
|
+
pickScalarFields: (selection: QuerySelectionOptions$1 | null, defn: QueryDefinition$1) => QueryFieldSelection$1[];
|
|
2193
|
+
pickAllFields: (selection: QuerySelectionOptions$1, defn: QueryDefinition$1) => QueryFieldSelection$1[];
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
type ASTNode = DocumentNode | FieldNode | SelectionSetNode | VariableDefinitionNode;
|
|
2197
|
+
interface NestedProperties {
|
|
2198
|
+
[key: string]: QueryProperty | NestedProperties;
|
|
2199
|
+
}
|
|
2200
|
+
interface QueryProperty {
|
|
2201
|
+
name: string;
|
|
2202
|
+
type: string;
|
|
2203
|
+
isNotNull: boolean;
|
|
2204
|
+
isArray: boolean;
|
|
2205
|
+
isArrayNotNull: boolean;
|
|
2206
|
+
properties?: NestedProperties;
|
|
2207
|
+
}
|
|
2208
|
+
interface QueryDefinition {
|
|
2209
|
+
model: string;
|
|
2210
|
+
qtype: 'getMany' | 'getOne' | 'mutation';
|
|
2211
|
+
mutationType?: 'create' | 'patch' | 'delete';
|
|
2212
|
+
selection: string[];
|
|
2213
|
+
properties: Record<string, QueryProperty>;
|
|
2214
|
+
}
|
|
2215
|
+
interface MutationDefinition extends QueryDefinition {
|
|
2216
|
+
qtype: 'mutation';
|
|
2217
|
+
mutationType: 'create' | 'patch' | 'delete';
|
|
2218
|
+
}
|
|
2219
|
+
/**
|
|
2220
|
+
* Runtime QueryBuilder's internal schema map.
|
|
2221
|
+
* Named with 'Query' prefix to avoid collision with the standard
|
|
2222
|
+
* GraphQL IntrospectionSchema from ./introspection.ts
|
|
2223
|
+
*/
|
|
2224
|
+
interface QueryIntrospectionSchema {
|
|
2225
|
+
[key: string]: QueryDefinition | MutationDefinition;
|
|
2226
|
+
}
|
|
2227
|
+
interface MetaFieldType {
|
|
2228
|
+
gqlType: string;
|
|
2229
|
+
isArray: boolean;
|
|
2230
|
+
modifier?: string | number | null;
|
|
2231
|
+
pgAlias?: string | null;
|
|
2232
|
+
pgType?: string | null;
|
|
2233
|
+
subtype?: string | null;
|
|
2234
|
+
typmod?: number | null;
|
|
2235
|
+
}
|
|
2236
|
+
interface MetaField {
|
|
2237
|
+
name: string;
|
|
2238
|
+
type: MetaFieldType;
|
|
2239
|
+
}
|
|
2240
|
+
interface MetaConstraint {
|
|
2241
|
+
name: string;
|
|
2242
|
+
type: MetaFieldType;
|
|
2243
|
+
alias?: string;
|
|
2244
|
+
}
|
|
2245
|
+
interface MetaForeignConstraint {
|
|
2246
|
+
fromKey: MetaConstraint;
|
|
2247
|
+
refTable: string;
|
|
2248
|
+
toKey: MetaConstraint;
|
|
2249
|
+
}
|
|
2250
|
+
interface MetaTable {
|
|
2251
|
+
name: string;
|
|
2252
|
+
fields: MetaField[];
|
|
2253
|
+
primaryConstraints: MetaConstraint[];
|
|
2254
|
+
uniqueConstraints: MetaConstraint[];
|
|
2255
|
+
foreignConstraints: MetaForeignConstraint[];
|
|
2256
|
+
}
|
|
2257
|
+
interface MetaObject {
|
|
2258
|
+
tables: MetaTable[];
|
|
2259
|
+
}
|
|
2260
|
+
type GraphQLVariableValue = string | number | boolean | null;
|
|
2261
|
+
interface GraphQLVariables {
|
|
2262
|
+
[key: string]: GraphQLVariableValue | GraphQLVariableValue[] | GraphQLVariables | GraphQLVariables[];
|
|
2263
|
+
}
|
|
2264
|
+
interface QueryFieldSelection {
|
|
2265
|
+
name: string;
|
|
2266
|
+
isObject: boolean;
|
|
2267
|
+
fieldDefn?: MetaField | Field;
|
|
2268
|
+
selection?: QueryFieldSelection[];
|
|
2269
|
+
variables?: GraphQLVariables;
|
|
2270
|
+
isBelongTo?: boolean;
|
|
2271
|
+
}
|
|
2272
|
+
interface QuerySelectionOptions {
|
|
2273
|
+
[fieldName: string]: boolean | {
|
|
2274
|
+
select: Record<string, boolean | QuerySelectionOptions>;
|
|
2275
|
+
variables?: GraphQLVariables;
|
|
2276
|
+
args?: Record<string, unknown>;
|
|
2277
|
+
};
|
|
2278
|
+
}
|
|
2279
|
+
interface QueryBuilderInstance {
|
|
2280
|
+
_introspection: QueryIntrospectionSchema;
|
|
2281
|
+
_meta: MetaObject;
|
|
2282
|
+
_edges?: boolean;
|
|
2283
|
+
}
|
|
2284
|
+
interface ASTFunctionParams {
|
|
2285
|
+
queryName: string;
|
|
2286
|
+
operationName: string;
|
|
2287
|
+
query: QueryDefinition;
|
|
2288
|
+
selection: QueryFieldSelection[];
|
|
2289
|
+
builder?: QueryBuilderInstance;
|
|
2290
|
+
}
|
|
2291
|
+
interface MutationASTParams {
|
|
2292
|
+
mutationName: string;
|
|
2293
|
+
operationName: string;
|
|
2294
|
+
mutation: MutationDefinition;
|
|
2295
|
+
selection?: QueryFieldSelection[];
|
|
2296
|
+
}
|
|
2297
|
+
interface QueryBuilderOptions {
|
|
2298
|
+
meta: MetaObject;
|
|
2299
|
+
introspection: QueryIntrospectionSchema;
|
|
2300
|
+
}
|
|
2301
|
+
interface QueryBuilderResult {
|
|
2302
|
+
_hash: string;
|
|
2303
|
+
_queryName: string;
|
|
2304
|
+
_ast: DocumentNode;
|
|
2305
|
+
}
|
|
2306
|
+
interface IQueryBuilder {
|
|
2307
|
+
query(model: string): IQueryBuilder;
|
|
2308
|
+
getMany(options?: {
|
|
2309
|
+
select?: QuerySelectionOptions;
|
|
2310
|
+
}): IQueryBuilder;
|
|
2311
|
+
getOne(options?: {
|
|
2312
|
+
select?: QuerySelectionOptions;
|
|
2313
|
+
}): IQueryBuilder;
|
|
2314
|
+
all(options?: {
|
|
2315
|
+
select?: QuerySelectionOptions;
|
|
2316
|
+
}): IQueryBuilder;
|
|
2317
|
+
count(): IQueryBuilder;
|
|
2318
|
+
create(options?: {
|
|
2319
|
+
select?: QuerySelectionOptions;
|
|
2320
|
+
}): IQueryBuilder;
|
|
2321
|
+
update(options?: {
|
|
2322
|
+
select?: QuerySelectionOptions;
|
|
2323
|
+
}): IQueryBuilder;
|
|
2324
|
+
delete(options?: {
|
|
2325
|
+
select?: QuerySelectionOptions;
|
|
2326
|
+
}): IQueryBuilder;
|
|
2327
|
+
edges(useEdges: boolean): IQueryBuilder;
|
|
2328
|
+
print(): QueryBuilderResult;
|
|
2329
|
+
}
|
|
2330
|
+
interface ObjectArrayItem extends QueryProperty {
|
|
2331
|
+
name: string;
|
|
2332
|
+
key?: string;
|
|
2333
|
+
}
|
|
2334
|
+
declare function isGraphQLVariableValue(value: unknown): value is GraphQLVariableValue;
|
|
2335
|
+
declare function isGraphQLVariables(obj: unknown): obj is GraphQLVariables;
|
|
2336
|
+
type StrictRecord<K extends PropertyKey, V> = Record<K, V> & {
|
|
2337
|
+
[P in PropertyKey]: P extends K ? V : never;
|
|
2338
|
+
};
|
|
2339
|
+
|
|
2340
|
+
/**
|
|
2341
|
+
* Transform GraphQL introspection data to clean operation types
|
|
2342
|
+
*
|
|
2343
|
+
* This module converts raw introspection responses into the Operation
|
|
2344
|
+
* format used by code generators.
|
|
2345
|
+
*/
|
|
2346
|
+
|
|
2347
|
+
/**
|
|
2348
|
+
* Build a type registry from introspection types
|
|
2349
|
+
* Maps type names to their full resolved definitions
|
|
2350
|
+
*
|
|
2351
|
+
* This is a two-pass process to handle circular references:
|
|
2352
|
+
* 1. First pass: Create all type entries with basic info
|
|
2353
|
+
* 2. Second pass: Resolve fields with references to other types
|
|
2354
|
+
*/
|
|
2355
|
+
declare function buildTypeRegistry(types: IntrospectionType[]): TypeRegistry;
|
|
2356
|
+
interface TransformSchemaResult {
|
|
2357
|
+
queries: Operation[];
|
|
2358
|
+
mutations: Operation[];
|
|
2359
|
+
typeRegistry: TypeRegistry;
|
|
2360
|
+
}
|
|
2361
|
+
/**
|
|
2362
|
+
* Transform introspection response to clean operations
|
|
2363
|
+
*/
|
|
2364
|
+
declare function transformSchemaToOperations(response: IntrospectionQueryResponse): TransformSchemaResult;
|
|
2365
|
+
/**
|
|
2366
|
+
* Filter operations by include/exclude patterns
|
|
2367
|
+
* Uses glob-like patterns (supports * wildcard)
|
|
2368
|
+
*/
|
|
2369
|
+
declare function filterOperations(operations: Operation[], include?: string[], exclude?: string[]): Operation[];
|
|
2370
|
+
/**
|
|
2371
|
+
* Result type for table operation names lookup
|
|
2372
|
+
*/
|
|
2373
|
+
interface TableOperationNames {
|
|
2374
|
+
queries: Set<string>;
|
|
2375
|
+
mutations: Set<string>;
|
|
2376
|
+
}
|
|
2377
|
+
/**
|
|
2378
|
+
* Get the set of table-related operation names from tables
|
|
2379
|
+
* Used to identify which operations are already covered by table generators
|
|
2380
|
+
*
|
|
2381
|
+
* IMPORTANT: This uses EXACT matches only from _meta.query fields.
|
|
2382
|
+
* Any operation not explicitly listed in _meta will flow through as a
|
|
2383
|
+
* custom operation, ensuring 100% coverage of the schema.
|
|
2384
|
+
*
|
|
2385
|
+
* Table operations (generated by table generators):
|
|
2386
|
+
* - Queries: all (list), one (single by PK)
|
|
2387
|
+
* - Mutations: create, update (by PK), delete (by PK)
|
|
2388
|
+
*
|
|
2389
|
+
* Custom operations (generated by custom operation generators):
|
|
2390
|
+
* - Unique constraint lookups: *ByUsername, *ByEmail, etc.
|
|
2391
|
+
* - Unique constraint mutations: update*By*, delete*By*
|
|
2392
|
+
* - True custom operations: login, register, bootstrapUser, etc.
|
|
2393
|
+
*/
|
|
2394
|
+
declare function getTableOperationNames(tables: Array<{
|
|
2395
|
+
name: string;
|
|
2396
|
+
query?: {
|
|
2397
|
+
all: string;
|
|
2398
|
+
one: string | null;
|
|
2399
|
+
create: string;
|
|
2400
|
+
update: string | null;
|
|
2401
|
+
delete: string | null;
|
|
2402
|
+
bulkInsert?: string | null;
|
|
2403
|
+
bulkUpsert?: string | null;
|
|
2404
|
+
bulkUpdate?: string | null;
|
|
2405
|
+
bulkDelete?: string | null;
|
|
2406
|
+
};
|
|
2407
|
+
}>): TableOperationNames;
|
|
2408
|
+
/**
|
|
2409
|
+
* Check if an operation is a table operation (already handled by table generators)
|
|
2410
|
+
*
|
|
2411
|
+
* Uses EXACT match only - no pattern matching. This ensures:
|
|
2412
|
+
* 1. Only operations explicitly in _meta.query are treated as table operations
|
|
2413
|
+
* 2. All other operations (including update*By*, delete*By*) become custom operations
|
|
2414
|
+
* 3. 100% schema coverage is guaranteed
|
|
2415
|
+
*/
|
|
2416
|
+
declare function isTableOperation(operation: Operation, tableOperationNames: TableOperationNames): boolean;
|
|
2417
|
+
/**
|
|
2418
|
+
* Get only custom operations (not covered by table generators)
|
|
2419
|
+
*
|
|
2420
|
+
* This returns ALL operations that are not exact matches for table CRUD operations.
|
|
2421
|
+
* Includes:
|
|
2422
|
+
* - Unique constraint queries (*ByUsername, *ByEmail, etc.)
|
|
2423
|
+
* - Unique constraint mutations (update*By*, delete*By*)
|
|
2424
|
+
* - True custom operations (login, register, bootstrapUser, etc.)
|
|
2425
|
+
*/
|
|
2426
|
+
declare function getCustomOperations(operations: Operation[], tableOperationNames: TableOperationNames): Operation[];
|
|
2427
|
+
|
|
2428
|
+
declare const getAll: ({ queryName, operationName, selection, }: ASTFunctionParams$1) => DocumentNode;
|
|
2429
|
+
declare const getCount: ({ queryName, operationName, query, }: Omit<ASTFunctionParams$1, "selection">) => DocumentNode;
|
|
2430
|
+
declare const getMany: ({ builder, queryName, operationName, query, selection, }: ASTFunctionParams$1) => DocumentNode;
|
|
2431
|
+
declare const getOne: ({ queryName, operationName, query, selection, }: ASTFunctionParams$1) => DocumentNode;
|
|
2432
|
+
declare const createOne: ({ mutationName, operationName, mutation, selection, }: MutationASTParams$1) => DocumentNode;
|
|
2433
|
+
declare const patchOne: ({ mutationName, operationName, mutation, selection, }: MutationASTParams$1) => DocumentNode;
|
|
2434
|
+
declare const deleteOne: ({ mutationName, operationName, mutation, }: Omit<MutationASTParams$1, "selection">) => DocumentNode;
|
|
2435
|
+
declare function getSelections(selection?: QueryFieldSelection$1[]): FieldNode[];
|
|
2436
|
+
|
|
2437
|
+
/**
|
|
2438
|
+
* Get custom AST for MetaField type - handles PostgreSQL types that need subfield selections
|
|
2439
|
+
*/
|
|
2440
|
+
declare function getCustomAst(fieldDefn?: MetaField$1): FieldNode | null;
|
|
2441
|
+
/**
|
|
2442
|
+
* Generate custom AST for Field type - handles GraphQL types that need subfield selections
|
|
2443
|
+
*/
|
|
2444
|
+
declare function getCustomAstForCleanField(field: Field): FieldNode;
|
|
2445
|
+
/**
|
|
2446
|
+
* Check if a Field requires subfield selection based on its GraphQL type
|
|
2447
|
+
*/
|
|
2448
|
+
declare function requiresSubfieldSelection(field: Field): boolean;
|
|
2449
|
+
/**
|
|
2450
|
+
* Generate AST for GeometryPoint type
|
|
2451
|
+
*/
|
|
2452
|
+
declare function geometryPointAst(name: string): FieldNode;
|
|
2453
|
+
/**
|
|
2454
|
+
* Generate AST for GeometryGeometryCollection type
|
|
2455
|
+
*/
|
|
2456
|
+
declare function geometryCollectionAst(name: string): FieldNode;
|
|
2457
|
+
/**
|
|
2458
|
+
* Generate AST for generic geometry type (returns geojson)
|
|
2459
|
+
*/
|
|
2460
|
+
declare function geometryAst(name: string): FieldNode;
|
|
2461
|
+
/**
|
|
2462
|
+
* Generate AST for interval type
|
|
2463
|
+
*/
|
|
2464
|
+
declare function intervalAst(name: string): FieldNode;
|
|
2465
|
+
/**
|
|
2466
|
+
* Check if an object has interval type shape
|
|
2467
|
+
*/
|
|
2468
|
+
declare function isIntervalType(obj: unknown): boolean;
|
|
2469
|
+
|
|
2470
|
+
interface MetaSchemaField {
|
|
2471
|
+
name: string;
|
|
2472
|
+
type: MetaFieldType$1;
|
|
2473
|
+
}
|
|
2474
|
+
interface MetaSchemaConstraint {
|
|
2475
|
+
fields: MetaSchemaField[];
|
|
2476
|
+
}
|
|
2477
|
+
interface MetaSchemaForeignConstraint {
|
|
2478
|
+
fields: MetaSchemaField[];
|
|
2479
|
+
refFields: MetaSchemaField[];
|
|
2480
|
+
refTable: {
|
|
2481
|
+
name: string;
|
|
2482
|
+
};
|
|
2483
|
+
}
|
|
2484
|
+
interface MetaSchemaBelongsTo {
|
|
2485
|
+
keys: MetaSchemaField[];
|
|
2486
|
+
fieldName: string;
|
|
2487
|
+
}
|
|
2488
|
+
interface MetaSchemaRelations {
|
|
2489
|
+
belongsTo: MetaSchemaBelongsTo[];
|
|
2490
|
+
}
|
|
2491
|
+
interface MetaSchemaTable {
|
|
2492
|
+
name: string;
|
|
2493
|
+
fields: MetaSchemaField[];
|
|
2494
|
+
primaryKeyConstraints: MetaSchemaConstraint[];
|
|
2495
|
+
uniqueConstraints: MetaSchemaConstraint[];
|
|
2496
|
+
foreignKeyConstraints: MetaSchemaForeignConstraint[];
|
|
2497
|
+
relations: MetaSchemaRelations;
|
|
2498
|
+
}
|
|
2499
|
+
interface MetaSchemaInput {
|
|
2500
|
+
_meta: {
|
|
2501
|
+
tables: MetaSchemaTable[];
|
|
2502
|
+
};
|
|
2503
|
+
}
|
|
2504
|
+
interface ConvertedField {
|
|
2505
|
+
name: string;
|
|
2506
|
+
type: MetaFieldType$1;
|
|
2507
|
+
alias?: string;
|
|
2508
|
+
}
|
|
2509
|
+
interface ConvertedConstraint {
|
|
2510
|
+
name: string;
|
|
2511
|
+
type: MetaFieldType$1;
|
|
2512
|
+
alias?: string;
|
|
2513
|
+
}
|
|
2514
|
+
interface ConvertedForeignConstraint {
|
|
2515
|
+
refTable: string;
|
|
2516
|
+
fromKey: ConvertedField;
|
|
2517
|
+
toKey: ConvertedField;
|
|
2518
|
+
}
|
|
2519
|
+
interface ConvertedTable {
|
|
2520
|
+
name: string;
|
|
2521
|
+
fields: ConvertedField[];
|
|
2522
|
+
primaryConstraints: ConvertedConstraint[];
|
|
2523
|
+
uniqueConstraints: ConvertedConstraint[];
|
|
2524
|
+
foreignConstraints: ConvertedForeignConstraint[];
|
|
2525
|
+
}
|
|
2526
|
+
interface ConvertedMetaObject {
|
|
2527
|
+
tables: ConvertedTable[];
|
|
2528
|
+
}
|
|
2529
|
+
/**
|
|
2530
|
+
* Convert from raw _meta schema response to internal MetaObject format
|
|
2531
|
+
*/
|
|
2532
|
+
declare function convertFromMetaSchema(metaSchema: MetaSchemaInput): ConvertedMetaObject;
|
|
2533
|
+
|
|
2534
|
+
interface ValidationResult {
|
|
2535
|
+
errors: unknown[] | null | undefined;
|
|
2536
|
+
message: string;
|
|
2537
|
+
}
|
|
2538
|
+
/**
|
|
2539
|
+
* Validate a MetaObject against the JSON schema
|
|
2540
|
+
* @returns true if valid, or an object with errors and message if invalid
|
|
2541
|
+
*/
|
|
2542
|
+
declare function validateMetaObject(obj: unknown): true | ValidationResult;
|
|
2543
|
+
|
|
2544
|
+
declare const MEMBERSHIP_TYPES: {
|
|
2545
|
+
readonly APP: 1;
|
|
2546
|
+
readonly ORGANIZATION: 2;
|
|
2547
|
+
readonly GROUP: 3;
|
|
2548
|
+
};
|
|
2549
|
+
type PolicyFieldType = 'string' | 'boolean' | 'integer' | 'uuid' | 'uuid[]';
|
|
2550
|
+
type PolicyFieldComponent = 'table-select' | 'membership-type-select' | 'permission-select';
|
|
2551
|
+
type PolicyProvisioningCategory = 'has-module' | 'needs-fields' | 'needs-table' | 'no-fields';
|
|
2552
|
+
interface PolicyFieldOverride {
|
|
2553
|
+
type?: PolicyFieldType;
|
|
2554
|
+
component?: PolicyFieldComponent;
|
|
2555
|
+
label?: string;
|
|
2556
|
+
placeholder?: string;
|
|
2557
|
+
description?: string;
|
|
2558
|
+
defaultValue?: unknown;
|
|
2559
|
+
required?: boolean;
|
|
2560
|
+
hidden?: boolean;
|
|
2561
|
+
pgType?: 'uuid' | 'uuid[]' | 'timestamptz' | 'boolean';
|
|
2562
|
+
dependsOn?: string;
|
|
2563
|
+
options?: {
|
|
2564
|
+
value: string;
|
|
2565
|
+
label: string;
|
|
2566
|
+
description?: string;
|
|
2567
|
+
}[];
|
|
2568
|
+
}
|
|
2569
|
+
interface PolicyProvisioningConfig {
|
|
2570
|
+
category: PolicyProvisioningCategory;
|
|
2571
|
+
hasDataNode: boolean;
|
|
2572
|
+
dataNodeType?: string;
|
|
2573
|
+
fieldOverrides?: Record<string, PolicyFieldOverride>;
|
|
2574
|
+
disabled?: boolean;
|
|
2575
|
+
}
|
|
2576
|
+
interface GeneratedField {
|
|
2577
|
+
name: string;
|
|
2578
|
+
type: string;
|
|
2579
|
+
nullable: boolean;
|
|
2580
|
+
description: string;
|
|
2581
|
+
}
|
|
2582
|
+
type CrudOperation = 'create' | 'read' | 'update' | 'delete';
|
|
2583
|
+
interface CrudOperationPolicyConfig {
|
|
2584
|
+
roleName: string;
|
|
2585
|
+
isPermissive: boolean;
|
|
2586
|
+
}
|
|
2587
|
+
interface GroupedCrudPrivileges {
|
|
2588
|
+
roleName: string;
|
|
2589
|
+
isPermissive: boolean;
|
|
2590
|
+
privileges: string[];
|
|
2591
|
+
}
|
|
2592
|
+
declare const CRUD_OPERATIONS: CrudOperation[];
|
|
2593
|
+
declare const CRUD_TO_PRIVILEGE: Record<CrudOperation, string>;
|
|
2594
|
+
declare const DEFAULT_CRUD_GRANT_PRIVILEGES: Record<string, unknown>[];
|
|
2595
|
+
declare const POLICY_PROVISIONING_CONFIG: Record<string, PolicyProvisioningConfig>;
|
|
2596
|
+
declare const DATA_NODE_GENERATED_FIELDS: Record<string, GeneratedField[]>;
|
|
2597
|
+
declare function getPolicyProvisioningConfig(policyType: string): PolicyProvisioningConfig | undefined;
|
|
2598
|
+
declare function getPolicyCategory(policyType: string): PolicyProvisioningCategory;
|
|
2599
|
+
declare function getDataNodeForPolicy(policyType: string): string | undefined;
|
|
2600
|
+
declare function policyRequiresDataNode(policyType: string): boolean;
|
|
2601
|
+
declare function policyCanBeNodeless(policyType: string): boolean;
|
|
2602
|
+
declare function getGeneratedFields(dataNodeType: string): GeneratedField[];
|
|
2603
|
+
declare function hasGeneratedFields(dataNodeType: string): boolean;
|
|
2604
|
+
declare function getPolicyFieldDefaults(policyType: string): Record<string, unknown>;
|
|
2605
|
+
declare function getFieldsRequiringColumns(policyType: string): {
|
|
2606
|
+
key: string;
|
|
2607
|
+
defaultName: string | string[];
|
|
2608
|
+
pgType: NonNullable<PolicyFieldOverride['pgType']>;
|
|
2609
|
+
}[];
|
|
2610
|
+
declare function sanitizePolicyData(data: Record<string, unknown>): Record<string, unknown>;
|
|
2611
|
+
declare function injectSchemaFields(policyData: Record<string, unknown>, schemaId: string, policyType: string): Record<string, unknown>;
|
|
2612
|
+
declare function buildNodeDataForDataNodeType(dataNodeType: string | undefined, policyData: Record<string, unknown>): Record<string, unknown>;
|
|
2613
|
+
declare function buildNodeData(policyType: string, policyData: Record<string, unknown>): Record<string, unknown>;
|
|
2614
|
+
declare function groupCrudOperationsByConfig<T extends string>(enabledOperations: T[], operations: Record<T, CrudOperationPolicyConfig>, privilegeMap: Record<T, string>): GroupedCrudPrivileges[];
|
|
2615
|
+
|
|
2616
|
+
export { type ASTFunctionParams, type ASTNode, CONSTRAINT_MESSAGES, CRUD_OPERATIONS, CRUD_TO_PRIVILEGE, type BelongsToRelation$1 as CleanBelongsToRelation, type CleanField, type HasManyRelation$1 as CleanHasManyRelation, type HasOneRelation$1 as CleanHasOneRelation, type ManyToManyRelation$1 as CleanManyToManyRelation, type Relations$1 as CleanRelations, type CleanTable, type ConnectionResult, type CrudOperation, type CrudOperationPolicyConfig, DATA_NODE_GENERATED_FIELDS, DEFAULT_CONSOLE_APPLICATION_SCOPES, DEFAULT_CRUD_GRANT_PRIVILEGES, DataError, type DataErrorOptions, DataErrorType, Errors, type FieldFilter$1 as FieldFilter, type FieldSelection, type FieldSelectionPreset, type Filter$1 as Filter, type FilterOperator$1 as FilterOperator, type GeneratedField, type GraphQLError, type GraphQLErrorLocation, type GraphQLErrorPath, type GraphQLVariableValue, type GraphQLVariables, type GroupedCrudPrivileges, type IQueryBuilder, type IntrospectionQueryResponse, type QueryIntrospectionSchema as IntrospectionSchema, MEMBERSHIP_TYPES, META_CONTRACT_INTROSPECTION_DOCUMENT, META_CONTRACT_INTROSPECTION_SOURCE, META_CONTRACT_REQUIREMENTS, META_CONTRACT_VERSION, META_DOCUMENT, META_QUERY_SOURCE, type MetaBelongsToRelation, type MetaConstraint, type MetaContractCompatibility, MetaContractError, type MetaContractIntrospectionQuery, type MetaContractStatus, type MetaContractTypeAlias, type MetaField$2 as MetaField, type MetaFieldType$2 as MetaFieldType, type MetaForeignConstraint, type MetaHasManyRelation, type MetaHasOneRelation, type MetaManyToManyRelation, type MetaObject, type MetaQuery, type MetaRelations, type MetaSchema, type MetaTable$2 as MetaTable, type MetaType, type Metaschema, type MetaschemaCheckConstraint, type MetaschemaConstraint, type MetaschemaConstraints, type MetaschemaEnum, type MetaschemaExclusionConstraint, type MetaschemaField, type MetaschemaForeignKeyConstraint, type MetaschemaI18n, type MetaschemaI18nField, type MetaschemaIndex, type MetaschemaPrimaryKeyConstraint, type MetaschemaRealtime, type MetaschemaScalarEncoding, type MetaschemaScope, type MetaschemaScopeTier, type MetaschemaSearch, type MetaschemaSearchColumn, type MetaschemaSearchConfig, type MetaschemaStorage, type MetaschemaTable, type MetaschemaTableBelongsToRelation, type MetaschemaTableHasRelation, type MetaschemaTableInflection, type MetaschemaTableManyToManyRelation, type MetaschemaTableQuery, type MetaschemaTableRelation, type MetaschemaType, type MetaschemaUniqueConstraint, type MutationASTParams, type MutationDefinition, type MutationOptions$1 as MutationOptions, type NestedProperties, type ObjectArrayItem, type OrderByItem$1 as OrderByItem, PG_ERROR_CODES, POLICY_PROVISIONING_CONFIG, type PageInfo, type PartialBy, type PolicyFieldComponent, type PolicyFieldOverride, type PolicyFieldType, type PolicyProvisioningCategory, type PolicyProvisioningConfig, type PrepareInputOptions, type MetaField as QBMetaField, type MetaFieldType as QBMetaFieldType, type MetaTable as QBMetaTable, QueryBuilder, type QueryBuilderInstance, type QueryBuilderOptions, type QueryBuilderResult, type QueryDefinition, type QueryFieldSelection, type QueryOptions$1 as QueryOptions, type QueryProperty, type QuerySelectionOptions, type RelationalFilter$1 as RelationalFilter, type RowIdentity, type RowIdentityDefinition, type RowIdentityField, type RowIdentityObject, type RowIdentityResolution, type RowIdentityValue, SCHEMA_INTROSPECTION_QUERY, type ScalarEncodingKind, type SchemaEnumFieldMapping, type SchemaEnumValueToken, type SchemaIntrospectionAnalysis, type SchemaIntrospectionCompatibility, type SchemaIntrospectionCompatibilityStatus, type SelectConsoleDataTablesOptions, type SelectionOptions, type SimpleFieldSelection, type StrictRecord, type TableInflection$1 as TableInflection, type TableOperationNames, type TableQueryNames$1 as TableQueryNames, type TableWriteCapability, type TransformSchemaResult, TypedDocumentString, type ValidationResult, analyzeSchemaIntrospectionCompatibility, asFieldIds, assertMetaContract, assertMetaQuery, assessMetaContract, assessSchemaIntrospectionCompatibility, assessTableWriteCapability, buildCount, buildFindOne, buildNodeData, buildNodeDataForDataNodeType, buildPostGraphileCreate, buildPostGraphileDelete, buildPostGraphileUpdate, buildSelect, buildTypeRegistry, cleanTable, cleanTableToMetaObject, convertFromMetaSchema, convertToSelectionOptions, createASTQueryBuilder, createDataError, createError, createOne, deleteOne, filterOperations, generateIntrospectionSchema, geometryAst, geometryCollectionAst, geometryPointAst, getAll, getAvailableRelations, getConstraintMessage, getCount, getCustomAst, getCustomAstForCleanField, getCustomOperations, getDataNodeForPolicy, getFieldsRequiringColumns, getGeneratedFields, getHumanReadableError, getMany, getOne, getPolicyCategory, getPolicyFieldDefaults, getPolicyProvisioningConfig, getRowIdentityDefinition, getSelections, getTableOperationNames, groupCrudOperationsByConfig, handleDataError, hasGeneratedFields, injectSchemaFields, intervalAst, isGraphQLVariableValue, isGraphQLVariables, isIntervalType, isRelationalField, isTableOperation, normalizeInflectionValue, normalizeSchemaEnumInputValues, parseError, parseGraphQLError, parseGraphQLErrorCode, parseMetaSearchWeights, patchOne, pgFieldToCamelCase, policyCanBeNodeless, policyRequiresDataNode, prepareCreateInput, prepareMutationInput, preparePatchInput, prepareUpdateInput, requiresSubfieldSelection, resolveRowIdentity, rowIdentityToPrimaryKey, sanitizePolicyData, selectConsoleDataTables, serializeRowIdentity, stripEmpty, toCamelCasePlural, toCamelCaseSingular, toCreateInputTypeName, toCreateMutationName, toDeleteInputTypeName, toDeleteMutationName, toFilterTypeName, toOrderByEnumValue, toOrderByTypeName, toPatchFieldName, toUpdateInputTypeName, toUpdateMutationName, transformSchemaToOperations, validateFieldSelection, validateMetaObject, withRetry };
|