graphile-settings 6.5.1 → 6.5.3
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/esm/plugins/index.d.ts +1 -1
- package/esm/plugins/meta-schema.d.ts +3 -18
- package/esm/plugins/meta-schema.js +3 -19
- package/package.json +12 -11
- package/plugins/index.d.ts +1 -1
- package/plugins/meta-schema.d.ts +3 -18
- package/plugins/meta-schema.js +11 -16
- package/esm/plugins/meta-schema/cache.d.ts +0 -4
- package/esm/plugins/meta-schema/cache.js +0 -7
- package/esm/plugins/meta-schema/constraint-meta-builders.d.ts +0 -13
- package/esm/plugins/meta-schema/constraint-meta-builders.js +0 -51
- package/esm/plugins/meta-schema/encoding-meta-builders.d.ts +0 -2
- package/esm/plugins/meta-schema/encoding-meta-builders.js +0 -84
- package/esm/plugins/meta-schema/graphql-meta-field.d.ts +0 -4
- package/esm/plugins/meta-schema/graphql-meta-field.js +0 -314
- package/esm/plugins/meta-schema/inflection-utils.d.ts +0 -4
- package/esm/plugins/meta-schema/inflection-utils.js +0 -20
- package/esm/plugins/meta-schema/name-meta-builders.d.ts +0 -4
- package/esm/plugins/meta-schema/name-meta-builders.js +0 -38
- package/esm/plugins/meta-schema/plugin.d.ts +0 -2
- package/esm/plugins/meta-schema/plugin.js +0 -23
- package/esm/plugins/meta-schema/relation-meta-builders.d.ts +0 -8
- package/esm/plugins/meta-schema/relation-meta-builders.js +0 -119
- package/esm/plugins/meta-schema/scope-meta-builders.d.ts +0 -15
- package/esm/plugins/meta-schema/scope-meta-builders.js +0 -40
- package/esm/plugins/meta-schema/storage-search-meta-builders.d.ts +0 -29
- package/esm/plugins/meta-schema/storage-search-meta-builders.js +0 -180
- package/esm/plugins/meta-schema/table-meta-builder.d.ts +0 -2
- package/esm/plugins/meta-schema/table-meta-builder.js +0 -99
- package/esm/plugins/meta-schema/table-meta-context.d.ts +0 -13
- package/esm/plugins/meta-schema/table-meta-context.js +0 -11
- package/esm/plugins/meta-schema/table-resource-utils.d.ts +0 -12
- package/esm/plugins/meta-schema/table-resource-utils.js +0 -50
- package/esm/plugins/meta-schema/type-mappings.d.ts +0 -7
- package/esm/plugins/meta-schema/type-mappings.js +0 -100
- package/esm/plugins/meta-schema/types.d.ts +0 -325
- package/esm/plugins/meta-schema/types.js +0 -1
- package/plugins/meta-schema/cache.d.ts +0 -4
- package/plugins/meta-schema/cache.js +0 -12
- package/plugins/meta-schema/constraint-meta-builders.d.ts +0 -13
- package/plugins/meta-schema/constraint-meta-builders.js +0 -58
- package/plugins/meta-schema/encoding-meta-builders.d.ts +0 -2
- package/plugins/meta-schema/encoding-meta-builders.js +0 -87
- package/plugins/meta-schema/graphql-meta-field.d.ts +0 -4
- package/plugins/meta-schema/graphql-meta-field.js +0 -317
- package/plugins/meta-schema/inflection-utils.d.ts +0 -4
- package/plugins/meta-schema/inflection-utils.js +0 -25
- package/plugins/meta-schema/name-meta-builders.d.ts +0 -4
- package/plugins/meta-schema/name-meta-builders.js +0 -43
- package/plugins/meta-schema/plugin.d.ts +0 -2
- package/plugins/meta-schema/plugin.js +0 -26
- package/plugins/meta-schema/relation-meta-builders.d.ts +0 -8
- package/plugins/meta-schema/relation-meta-builders.js +0 -124
- package/plugins/meta-schema/scope-meta-builders.d.ts +0 -15
- package/plugins/meta-schema/scope-meta-builders.js +0 -43
- package/plugins/meta-schema/storage-search-meta-builders.d.ts +0 -29
- package/plugins/meta-schema/storage-search-meta-builders.js +0 -186
- package/plugins/meta-schema/table-meta-builder.d.ts +0 -2
- package/plugins/meta-schema/table-meta-builder.js +0 -102
- package/plugins/meta-schema/table-meta-context.d.ts +0 -13
- package/plugins/meta-schema/table-meta-context.js +0 -15
- package/plugins/meta-schema/table-resource-utils.d.ts +0 -12
- package/plugins/meta-schema/table-resource-utils.js +0 -60
- package/plugins/meta-schema/type-mappings.d.ts +0 -7
- package/plugins/meta-schema/type-mappings.js +0 -104
- package/plugins/meta-schema/types.d.ts +0 -325
- package/plugins/meta-schema/types.js +0 -2
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
export interface TableMeta {
|
|
2
|
-
name: string;
|
|
3
|
-
schemaName: string;
|
|
4
|
-
fields: FieldMeta[];
|
|
5
|
-
indexes: IndexMeta[];
|
|
6
|
-
constraints: ConstraintsMeta;
|
|
7
|
-
foreignKeyConstraints: ForeignKeyConstraintMeta[];
|
|
8
|
-
primaryKeyConstraints: PrimaryKeyConstraintMeta[];
|
|
9
|
-
uniqueConstraints: UniqueConstraintMeta[];
|
|
10
|
-
relations: RelationsMeta;
|
|
11
|
-
inflection: InflectionMeta;
|
|
12
|
-
query: QueryMeta;
|
|
13
|
-
storage: StorageMeta | null;
|
|
14
|
-
search: SearchMeta | null;
|
|
15
|
-
i18n: I18nMeta | null;
|
|
16
|
-
realtime: RealtimeMeta | null;
|
|
17
|
-
scope: ScopeMeta | null;
|
|
18
|
-
}
|
|
19
|
-
/** Coarse provisioning tier a table's scope belongs to. */
|
|
20
|
-
export type ScopeTier = 'global' | 'database' | 'entity';
|
|
21
|
-
export interface ScopeMeta {
|
|
22
|
-
/** The provisioning scope, e.g. 'platform', 'app', 'database', 'org', 'user' */
|
|
23
|
-
scope: string;
|
|
24
|
-
/** Coarse bucket: global (platform/app), database, or entity */
|
|
25
|
-
tier: ScopeTier;
|
|
26
|
-
/** Inflected scope key column (e.g. 'databaseId', 'orgId'), or null for global tiers */
|
|
27
|
-
keyColumn: string | null;
|
|
28
|
-
/** SQL name of the entity table for entity scopes, else null */
|
|
29
|
-
entityTable: string | null;
|
|
30
|
-
/** Provenance of the scope metadata. Always the @scope smart tag. */
|
|
31
|
-
source: 'smartTag';
|
|
32
|
-
}
|
|
33
|
-
export interface StorageMeta {
|
|
34
|
-
/** Whether this table is tagged as a storage files table */
|
|
35
|
-
isFilesTable: boolean;
|
|
36
|
-
/** Whether this table is tagged as a storage buckets table */
|
|
37
|
-
isBucketsTable: boolean;
|
|
38
|
-
}
|
|
39
|
-
export interface SearchColumnMeta {
|
|
40
|
-
/** Column name (camelCase inflected) */
|
|
41
|
-
name: string;
|
|
42
|
-
/** Search algorithm: 'tsvector', 'bm25', 'trgm', 'vector' */
|
|
43
|
-
algorithm: string;
|
|
44
|
-
}
|
|
45
|
-
export interface SearchMeta {
|
|
46
|
-
/** Which search algorithms are active on this table */
|
|
47
|
-
algorithms: string[];
|
|
48
|
-
/** Searchable columns with their algorithm */
|
|
49
|
-
columns: SearchColumnMeta[];
|
|
50
|
-
/** Whether unifiedSearch composite filter is available */
|
|
51
|
-
hasUnifiedSearch: boolean;
|
|
52
|
-
/** Per-table search config from @searchConfig smart tag */
|
|
53
|
-
config: SearchConfigMeta | null;
|
|
54
|
-
}
|
|
55
|
-
export interface SearchConfigMeta {
|
|
56
|
-
/** Per-adapter score weights */
|
|
57
|
-
weights: Record<string, number> | null;
|
|
58
|
-
/** Whether recency boosting is enabled */
|
|
59
|
-
boostRecent: boolean;
|
|
60
|
-
/** Field used for recency decay */
|
|
61
|
-
boostRecencyField: string | null;
|
|
62
|
-
/** Exponential decay factor per day */
|
|
63
|
-
boostRecencyDecay: number | null;
|
|
64
|
-
}
|
|
65
|
-
export interface I18nFieldMeta {
|
|
66
|
-
/** Inflected GraphQL field name */
|
|
67
|
-
name: string;
|
|
68
|
-
/** PostgreSQL column type (text, citext) */
|
|
69
|
-
type: string;
|
|
70
|
-
}
|
|
71
|
-
export interface I18nMeta {
|
|
72
|
-
/** Name of the translation table */
|
|
73
|
-
translationTable: string;
|
|
74
|
-
/** Fields that are translatable */
|
|
75
|
-
translatableFields: I18nFieldMeta[];
|
|
76
|
-
}
|
|
77
|
-
export interface RealtimeMeta {
|
|
78
|
-
/** The generated subscription field name (e.g. onPostChanged) */
|
|
79
|
-
subscriptionFieldName: string;
|
|
80
|
-
}
|
|
81
|
-
export interface EnumMeta {
|
|
82
|
-
/** The PostgreSQL enum type name */
|
|
83
|
-
name: string;
|
|
84
|
-
/** Allowed values for this enum */
|
|
85
|
-
values: string[];
|
|
86
|
-
}
|
|
87
|
-
export interface FieldMeta {
|
|
88
|
-
name: string;
|
|
89
|
-
type: TypeMeta;
|
|
90
|
-
isNotNull: boolean;
|
|
91
|
-
hasDefault: boolean;
|
|
92
|
-
isPrimaryKey: boolean;
|
|
93
|
-
isForeignKey: boolean;
|
|
94
|
-
description: string | null;
|
|
95
|
-
enumValues: EnumMeta | null;
|
|
96
|
-
}
|
|
97
|
-
export interface TypeMeta {
|
|
98
|
-
pgType: string;
|
|
99
|
-
gqlType: string;
|
|
100
|
-
isArray: boolean;
|
|
101
|
-
isNotNull?: boolean;
|
|
102
|
-
hasDefault?: boolean;
|
|
103
|
-
subtype?: string | null;
|
|
104
|
-
/**
|
|
105
|
-
* How the client must serialize/parse this scalar. `null` for plain scalars
|
|
106
|
-
* (String/Int/Float/Boolean/JSON/enum) whose wire format is obvious from
|
|
107
|
-
* `gqlType` — populated only for scalars introspection can't fully describe.
|
|
108
|
-
*/
|
|
109
|
-
encoding?: ScalarEncodingMeta | null;
|
|
110
|
-
}
|
|
111
|
-
/** The machine kind a scalar marshals as on the client. */
|
|
112
|
-
export type ScalarEncodingKind = 'bigint' | 'datetime' | 'date' | 'time' | 'interval' | 'uuid' | 'geojson' | 'point' | 'inet' | 'ltree' | 'vector' | 'bytea' | 'composite';
|
|
113
|
-
export interface ScalarEncodingMeta {
|
|
114
|
-
/** Deterministic kind derived from the underlying (unwrapped) codec. */
|
|
115
|
-
kind: ScalarEncodingKind;
|
|
116
|
-
/** For 'vector': element scalar (e.g. 'float'), else null. */
|
|
117
|
-
elementType?: string | null;
|
|
118
|
-
/** For 'vector': declared length from typmod, else null. */
|
|
119
|
-
dimensions?: number | null;
|
|
120
|
-
/** For 'geojson': geometry subtype (Point/LineString/Polygon/…), else null. */
|
|
121
|
-
geometrySubtype?: string | null;
|
|
122
|
-
/** For 'geojson': spatial reference id, else null. */
|
|
123
|
-
srid?: number | null;
|
|
124
|
-
/** For 'ltree': values are dot-separated path strings ('a.b.c'). */
|
|
125
|
-
dotPath?: boolean;
|
|
126
|
-
/** For 'composite': nested attribute encodings. */
|
|
127
|
-
fields?: {
|
|
128
|
-
name: string;
|
|
129
|
-
type: TypeMeta;
|
|
130
|
-
}[] | null;
|
|
131
|
-
}
|
|
132
|
-
export interface IndexMeta {
|
|
133
|
-
name: string;
|
|
134
|
-
isUnique: boolean;
|
|
135
|
-
isPrimary: boolean;
|
|
136
|
-
columns: string[];
|
|
137
|
-
fields: FieldMeta[];
|
|
138
|
-
}
|
|
139
|
-
export interface ConstraintsMeta {
|
|
140
|
-
primaryKey: PrimaryKeyConstraintMeta | null;
|
|
141
|
-
unique: UniqueConstraintMeta[];
|
|
142
|
-
foreignKey: ForeignKeyConstraintMeta[];
|
|
143
|
-
}
|
|
144
|
-
export interface PrimaryKeyConstraintMeta {
|
|
145
|
-
name: string;
|
|
146
|
-
fields: FieldMeta[];
|
|
147
|
-
}
|
|
148
|
-
export interface UniqueConstraintMeta {
|
|
149
|
-
name: string;
|
|
150
|
-
fields: FieldMeta[];
|
|
151
|
-
}
|
|
152
|
-
export interface ForeignKeyConstraintMeta {
|
|
153
|
-
name: string;
|
|
154
|
-
fields: FieldMeta[];
|
|
155
|
-
referencedTable: string;
|
|
156
|
-
referencedFields: string[];
|
|
157
|
-
refFields: FieldMeta[];
|
|
158
|
-
refTable: {
|
|
159
|
-
name: string;
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
export interface RelationsMeta {
|
|
163
|
-
belongsTo: BelongsToRelation[];
|
|
164
|
-
has: HasRelation[];
|
|
165
|
-
hasOne: HasRelation[];
|
|
166
|
-
hasMany: HasRelation[];
|
|
167
|
-
manyToMany: ManyToManyRelation[];
|
|
168
|
-
}
|
|
169
|
-
export interface BelongsToRelation {
|
|
170
|
-
fieldName: string | null;
|
|
171
|
-
isUnique: boolean;
|
|
172
|
-
type: string | null;
|
|
173
|
-
keys: FieldMeta[];
|
|
174
|
-
references: {
|
|
175
|
-
name: string;
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
export interface HasRelation {
|
|
179
|
-
fieldName: string | null;
|
|
180
|
-
isUnique: boolean;
|
|
181
|
-
type: string | null;
|
|
182
|
-
keys: FieldMeta[];
|
|
183
|
-
referencedBy: {
|
|
184
|
-
name: string;
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
export interface ManyToManyRelation {
|
|
188
|
-
fieldName: string | null;
|
|
189
|
-
type: string | null;
|
|
190
|
-
junctionTable: {
|
|
191
|
-
name: string;
|
|
192
|
-
};
|
|
193
|
-
junctionLeftConstraint: ForeignKeyConstraintMeta;
|
|
194
|
-
junctionLeftKeyAttributes: FieldMeta[];
|
|
195
|
-
junctionRightConstraint: ForeignKeyConstraintMeta;
|
|
196
|
-
junctionRightKeyAttributes: FieldMeta[];
|
|
197
|
-
leftKeyAttributes: FieldMeta[];
|
|
198
|
-
rightKeyAttributes: FieldMeta[];
|
|
199
|
-
rightTable: {
|
|
200
|
-
name: string;
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
export interface InflectionMeta {
|
|
204
|
-
tableType: string;
|
|
205
|
-
allRows: string;
|
|
206
|
-
connection: string;
|
|
207
|
-
edge: string;
|
|
208
|
-
filterType: string | null;
|
|
209
|
-
orderByType: string;
|
|
210
|
-
conditionType: string;
|
|
211
|
-
patchType: string | null;
|
|
212
|
-
createInputType: string;
|
|
213
|
-
createPayloadType: string;
|
|
214
|
-
updatePayloadType: string | null;
|
|
215
|
-
deletePayloadType: string;
|
|
216
|
-
}
|
|
217
|
-
export interface QueryMeta {
|
|
218
|
-
all: string;
|
|
219
|
-
one: string | null;
|
|
220
|
-
create: string | null;
|
|
221
|
-
update: string | null;
|
|
222
|
-
delete: string | null;
|
|
223
|
-
}
|
|
224
|
-
export interface PgCodec {
|
|
225
|
-
name: string;
|
|
226
|
-
attributes?: Record<string, PgAttribute>;
|
|
227
|
-
arrayOfCodec?: PgCodec | null;
|
|
228
|
-
domainOfCodec?: PgCodec | null;
|
|
229
|
-
isAnonymous?: boolean;
|
|
230
|
-
extensions?: {
|
|
231
|
-
pg?: {
|
|
232
|
-
schemaName?: string;
|
|
233
|
-
};
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
export interface PgAttributeExtensions extends Record<string, unknown> {
|
|
237
|
-
geometrySubtype?: string | null;
|
|
238
|
-
geometrySrid?: number | null;
|
|
239
|
-
vectorDimensions?: number | null;
|
|
240
|
-
}
|
|
241
|
-
export interface PgAttribute {
|
|
242
|
-
codec?: PgCodec | null;
|
|
243
|
-
notNull?: boolean;
|
|
244
|
-
hasDefault?: boolean;
|
|
245
|
-
description?: string | null;
|
|
246
|
-
extensions?: PgAttributeExtensions | null;
|
|
247
|
-
}
|
|
248
|
-
export interface PgUnique {
|
|
249
|
-
attributes: string[];
|
|
250
|
-
isPrimary?: boolean;
|
|
251
|
-
tags?: {
|
|
252
|
-
name?: string;
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
export interface PgRelation {
|
|
256
|
-
isReferencee?: boolean;
|
|
257
|
-
localAttributes?: string[];
|
|
258
|
-
remoteAttributes?: string[];
|
|
259
|
-
remoteResource?: PgTableResource | null;
|
|
260
|
-
}
|
|
261
|
-
export interface PgTableResource {
|
|
262
|
-
codec?: PgCodec;
|
|
263
|
-
uniques?: PgUnique[];
|
|
264
|
-
relations?: Record<string, PgRelation>;
|
|
265
|
-
parameters?: unknown;
|
|
266
|
-
isVirtual?: boolean;
|
|
267
|
-
isUnique?: boolean;
|
|
268
|
-
getRelation?: (relationName: string) => PgRelation | undefined;
|
|
269
|
-
getRelations?: () => Record<string, PgRelation>;
|
|
270
|
-
}
|
|
271
|
-
export interface PgManyToManyRelationDetails {
|
|
272
|
-
leftTable: PgTableResource;
|
|
273
|
-
leftRelationName: string;
|
|
274
|
-
junctionTable: PgTableResource;
|
|
275
|
-
rightRelationName: string;
|
|
276
|
-
rightTable: PgTableResource;
|
|
277
|
-
allowsMultipleEdgesToNode?: boolean;
|
|
278
|
-
}
|
|
279
|
-
export interface MetaInflection {
|
|
280
|
-
tableType: (codec: PgCodec) => string;
|
|
281
|
-
_attributeName?: (input: {
|
|
282
|
-
attributeName: string;
|
|
283
|
-
codec: PgCodec;
|
|
284
|
-
}) => string;
|
|
285
|
-
camelCase?: (value: string) => string;
|
|
286
|
-
_manyToManyRelation?: (details: PgManyToManyRelationDetails) => string | null | undefined;
|
|
287
|
-
allRows?: (resource: PgTableResource) => string | null | undefined;
|
|
288
|
-
connectionType?: (tableType: string) => string | null | undefined;
|
|
289
|
-
edgeType?: (tableType: string) => string | null | undefined;
|
|
290
|
-
filterType?: (tableType: string) => string | null | undefined;
|
|
291
|
-
orderByType?: (tableType: string) => string | null | undefined;
|
|
292
|
-
conditionType?: (tableType: string) => string | null | undefined;
|
|
293
|
-
patchType?: (tableType: string) => string | null | undefined;
|
|
294
|
-
createInputType?: (resource: PgTableResource) => string | null | undefined;
|
|
295
|
-
createPayloadType?: (resource: PgTableResource) => string | null | undefined;
|
|
296
|
-
updatePayloadType?: (resource: PgTableResource) => string | null | undefined;
|
|
297
|
-
deletePayloadType?: (resource: PgTableResource) => string | null | undefined;
|
|
298
|
-
tableFieldName?: (resource: PgTableResource) => string | null | undefined;
|
|
299
|
-
createField?: (resource: PgTableResource) => string | null | undefined;
|
|
300
|
-
updateByKeys?: (resource: PgTableResource) => string | null | undefined;
|
|
301
|
-
deleteByKeys?: (resource: PgTableResource) => string | null | undefined;
|
|
302
|
-
}
|
|
303
|
-
export interface GqlTypeResolverBuild {
|
|
304
|
-
hasGraphQLTypeForPgCodec?: (codec: PgCodec, mode?: 'output' | 'input' | string) => boolean;
|
|
305
|
-
getGraphQLTypeNameByPgCodec?: (codec: PgCodec, mode?: 'output' | 'input' | string) => string | null | undefined;
|
|
306
|
-
}
|
|
307
|
-
export interface MetaBuild extends GqlTypeResolverBuild {
|
|
308
|
-
input: {
|
|
309
|
-
pgRegistry: {
|
|
310
|
-
pgResources: Record<string, PgTableResource>;
|
|
311
|
-
};
|
|
312
|
-
};
|
|
313
|
-
inflection: MetaInflection;
|
|
314
|
-
options?: {
|
|
315
|
-
pgSchemas?: string[];
|
|
316
|
-
[key: string]: unknown;
|
|
317
|
-
};
|
|
318
|
-
pgManyToManyRealtionshipsByResource?: Map<unknown, unknown>;
|
|
319
|
-
}
|
|
320
|
-
export interface PgCodecExtensions {
|
|
321
|
-
pg?: {
|
|
322
|
-
schemaName?: string;
|
|
323
|
-
};
|
|
324
|
-
tags?: Record<string, unknown>;
|
|
325
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cachedTablesMeta = void 0;
|
|
4
|
-
exports.getCachedTablesMeta = getCachedTablesMeta;
|
|
5
|
-
exports.setCachedTablesMeta = setCachedTablesMeta;
|
|
6
|
-
exports.cachedTablesMeta = [];
|
|
7
|
-
function getCachedTablesMeta() {
|
|
8
|
-
return exports.cachedTablesMeta;
|
|
9
|
-
}
|
|
10
|
-
function setCachedTablesMeta(tablesMeta) {
|
|
11
|
-
exports.cachedTablesMeta = tablesMeta;
|
|
12
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type BuildContext } from './table-meta-context';
|
|
2
|
-
import type { ForeignKeyConstraintMeta, PgAttribute, PgCodec, PgRelation, PgUnique, PrimaryKeyConstraintMeta, UniqueConstraintMeta } from './types';
|
|
3
|
-
export declare function buildForeignKeyConstraint(constraintName: string, localCodec: PgCodec, localAttributes: Record<string, PgAttribute>, localAttributeNames: string[], remoteCodec: PgCodec | undefined, remoteAttributes: Record<string, PgAttribute>, remoteAttributeNames: string[], context: BuildContext): ForeignKeyConstraintMeta;
|
|
4
|
-
export declare function buildIndexes(codec: PgCodec, attributes: Record<string, PgAttribute>, uniques: PgUnique[], context: BuildContext): {
|
|
5
|
-
name: string;
|
|
6
|
-
isUnique: boolean;
|
|
7
|
-
isPrimary: boolean;
|
|
8
|
-
columns: string[];
|
|
9
|
-
fields: import("./types").FieldMeta[];
|
|
10
|
-
}[];
|
|
11
|
-
export declare function buildPrimaryKey(codec: PgCodec, attributes: Record<string, PgAttribute>, uniques: PgUnique[], context: BuildContext): PrimaryKeyConstraintMeta | null;
|
|
12
|
-
export declare function buildUniqueConstraints(codec: PgCodec, attributes: Record<string, PgAttribute>, uniques: PgUnique[], context: BuildContext): UniqueConstraintMeta[];
|
|
13
|
-
export declare function buildForeignKeyConstraints(codec: PgCodec, attributes: Record<string, PgAttribute>, relations: Record<string, PgRelation>, context: BuildContext): ForeignKeyConstraintMeta[];
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildForeignKeyConstraint = buildForeignKeyConstraint;
|
|
4
|
-
exports.buildIndexes = buildIndexes;
|
|
5
|
-
exports.buildPrimaryKey = buildPrimaryKey;
|
|
6
|
-
exports.buildUniqueConstraints = buildUniqueConstraints;
|
|
7
|
-
exports.buildForeignKeyConstraints = buildForeignKeyConstraints;
|
|
8
|
-
const type_mappings_1 = require("./type-mappings");
|
|
9
|
-
const table_meta_context_1 = require("./table-meta-context");
|
|
10
|
-
function buildForeignKeyConstraint(constraintName, localCodec, localAttributes, localAttributeNames, remoteCodec, remoteAttributes, remoteAttributeNames, context) {
|
|
11
|
-
const referencedTable = remoteCodec?.name || 'unknown';
|
|
12
|
-
const referencedFields = remoteAttributeNames.map((attrName) => remoteCodec ? context.inflectAttr(attrName, remoteCodec) : attrName);
|
|
13
|
-
return {
|
|
14
|
-
name: constraintName,
|
|
15
|
-
fields: (0, table_meta_context_1.buildFieldList)(localAttributeNames, localCodec, localAttributes, context),
|
|
16
|
-
referencedTable,
|
|
17
|
-
referencedFields,
|
|
18
|
-
refFields: remoteAttributeNames.map((attrName) => (0, type_mappings_1.buildFieldMeta)(remoteCodec ? context.inflectAttr(attrName, remoteCodec) : attrName, remoteAttributes[attrName], context.build)),
|
|
19
|
-
refTable: { name: referencedTable },
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function buildIndexes(codec, attributes, uniques, context) {
|
|
23
|
-
return uniques.map((unique) => ({
|
|
24
|
-
name: unique.tags?.name || `${codec.name}_${unique.attributes.join('_')}_idx`,
|
|
25
|
-
isUnique: true,
|
|
26
|
-
isPrimary: !!unique.isPrimary,
|
|
27
|
-
columns: unique.attributes.map((attrName) => context.inflectAttr(attrName, codec)),
|
|
28
|
-
fields: (0, table_meta_context_1.buildFieldList)(unique.attributes, codec, attributes, context),
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
function buildPrimaryKey(codec, attributes, uniques, context) {
|
|
32
|
-
const primaryUnique = uniques.find((unique) => unique.isPrimary);
|
|
33
|
-
if (!primaryUnique)
|
|
34
|
-
return null;
|
|
35
|
-
return {
|
|
36
|
-
name: primaryUnique.tags?.name || `${codec.name}_pkey`,
|
|
37
|
-
fields: (0, table_meta_context_1.buildFieldList)(primaryUnique.attributes, codec, attributes, context),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function buildUniqueConstraints(codec, attributes, uniques, context) {
|
|
41
|
-
return uniques
|
|
42
|
-
.filter((unique) => !unique.isPrimary)
|
|
43
|
-
.map((unique) => ({
|
|
44
|
-
name: unique.tags?.name || `${codec.name}_${unique.attributes.join('_')}_key`,
|
|
45
|
-
fields: (0, table_meta_context_1.buildFieldList)(unique.attributes, codec, attributes, context),
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
function buildForeignKeyConstraints(codec, attributes, relations, context) {
|
|
49
|
-
const constraints = [];
|
|
50
|
-
for (const [relationName, relation] of Object.entries(relations)) {
|
|
51
|
-
if (relation.isReferencee)
|
|
52
|
-
continue;
|
|
53
|
-
const remoteCodec = relation.remoteResource?.codec;
|
|
54
|
-
const remoteAttributes = remoteCodec?.attributes || {};
|
|
55
|
-
constraints.push(buildForeignKeyConstraint(relationName, codec, attributes, relation.localAttributes || [], remoteCodec, remoteAttributes, relation.remoteAttributes || [], context));
|
|
56
|
-
}
|
|
57
|
-
return constraints;
|
|
58
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildScalarEncoding = buildScalarEncoding;
|
|
4
|
-
/**
|
|
5
|
-
* Scalar encoding contracts — the one piece of field metadata standard GraphQL
|
|
6
|
-
* introspection can't provide.
|
|
7
|
-
*
|
|
8
|
-
* Introspection tells a client a field's scalar *name* (`GeoJSON`, `LTree`,
|
|
9
|
-
* `Interval`, `BigInt`, `vector`, …) but not how to serialize/parse it or its
|
|
10
|
-
* structural parameters (geometry subtype/SRID, vector dimensions, ltree
|
|
11
|
-
* dot-path semantics). Without that, generated clients treat these as opaque
|
|
12
|
-
* strings / `any` and mis-encode inputs or fail to parse outputs.
|
|
13
|
-
*
|
|
14
|
-
* `kind` is derived deterministically from the *underlying* codec (array and
|
|
15
|
-
* domain wrappers unwrapped first, first match wins) so exactly one kind is
|
|
16
|
-
* ever assigned and nothing can clobber it. Structural extras (subtype, SRID,
|
|
17
|
-
* dimensions) are read verbatim from attribute extensions — never guessed, and
|
|
18
|
-
* `null` when absent.
|
|
19
|
-
*/
|
|
20
|
-
/** pg type name → encoding kind. Plain scalars are intentionally absent → null. */
|
|
21
|
-
const KIND_BY_PG_TYPE = {
|
|
22
|
-
int8: 'bigint',
|
|
23
|
-
bigint: 'bigint',
|
|
24
|
-
numeric: 'bigint',
|
|
25
|
-
timestamptz: 'datetime',
|
|
26
|
-
timestamp: 'datetime',
|
|
27
|
-
date: 'date',
|
|
28
|
-
time: 'time',
|
|
29
|
-
timetz: 'time',
|
|
30
|
-
interval: 'interval',
|
|
31
|
-
uuid: 'uuid',
|
|
32
|
-
geometry: 'geojson',
|
|
33
|
-
geography: 'geojson',
|
|
34
|
-
point: 'point',
|
|
35
|
-
inet: 'inet',
|
|
36
|
-
cidr: 'inet',
|
|
37
|
-
ltree: 'ltree',
|
|
38
|
-
vector: 'vector',
|
|
39
|
-
bytea: 'bytea'
|
|
40
|
-
};
|
|
41
|
-
/** Unwrap array-of and domain-of wrappers to the underlying scalar/record codec. */
|
|
42
|
-
function underlyingCodec(codec) {
|
|
43
|
-
let current = codec ?? null;
|
|
44
|
-
const seen = new Set();
|
|
45
|
-
while (current && !seen.has(current) && (current.arrayOfCodec || current.domainOfCodec)) {
|
|
46
|
-
seen.add(current);
|
|
47
|
-
current = current.arrayOfCodec || current.domainOfCodec || null;
|
|
48
|
-
}
|
|
49
|
-
return current;
|
|
50
|
-
}
|
|
51
|
-
/** True when a codec is a composite/record type (has named attributes). */
|
|
52
|
-
function isCompositeCodec(codec) {
|
|
53
|
-
return !!codec?.attributes && Object.keys(codec.attributes).length > 0;
|
|
54
|
-
}
|
|
55
|
-
function buildScalarEncoding(attr) {
|
|
56
|
-
const codec = underlyingCodec(attr?.codec);
|
|
57
|
-
if (!codec)
|
|
58
|
-
return null;
|
|
59
|
-
const ext = attr?.extensions ?? undefined;
|
|
60
|
-
const kind = KIND_BY_PG_TYPE[codec.name];
|
|
61
|
-
if (!kind) {
|
|
62
|
-
// Composite/record types are the only non-mapped scalars worth describing;
|
|
63
|
-
// everything else (text, int, bool, json, enum, …) is fully covered by gqlType.
|
|
64
|
-
if (isCompositeCodec(codec)) {
|
|
65
|
-
return { kind: 'composite', fields: null };
|
|
66
|
-
}
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
switch (kind) {
|
|
70
|
-
case 'geojson':
|
|
71
|
-
return {
|
|
72
|
-
kind,
|
|
73
|
-
geometrySubtype: typeof ext?.geometrySubtype === 'string' ? ext.geometrySubtype : null,
|
|
74
|
-
srid: typeof ext?.geometrySrid === 'number' ? ext.geometrySrid : null
|
|
75
|
-
};
|
|
76
|
-
case 'vector':
|
|
77
|
-
return {
|
|
78
|
-
kind,
|
|
79
|
-
elementType: 'float',
|
|
80
|
-
dimensions: typeof ext?.vectorDimensions === 'number' ? ext.vectorDimensions : null
|
|
81
|
-
};
|
|
82
|
-
case 'ltree':
|
|
83
|
-
return { kind, dotPath: true };
|
|
84
|
-
default:
|
|
85
|
-
return { kind };
|
|
86
|
-
}
|
|
87
|
-
}
|