graphile-settings 6.5.2 → 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.
Files changed (67) hide show
  1. package/esm/plugins/index.d.ts +1 -1
  2. package/esm/plugins/meta-schema.d.ts +3 -18
  3. package/esm/plugins/meta-schema.js +3 -19
  4. package/package.json +3 -2
  5. package/plugins/index.d.ts +1 -1
  6. package/plugins/meta-schema.d.ts +3 -18
  7. package/plugins/meta-schema.js +11 -16
  8. package/esm/plugins/meta-schema/cache.d.ts +0 -4
  9. package/esm/plugins/meta-schema/cache.js +0 -7
  10. package/esm/plugins/meta-schema/constraint-meta-builders.d.ts +0 -13
  11. package/esm/plugins/meta-schema/constraint-meta-builders.js +0 -51
  12. package/esm/plugins/meta-schema/encoding-meta-builders.d.ts +0 -2
  13. package/esm/plugins/meta-schema/encoding-meta-builders.js +0 -84
  14. package/esm/plugins/meta-schema/graphql-meta-field.d.ts +0 -4
  15. package/esm/plugins/meta-schema/graphql-meta-field.js +0 -314
  16. package/esm/plugins/meta-schema/inflection-utils.d.ts +0 -4
  17. package/esm/plugins/meta-schema/inflection-utils.js +0 -20
  18. package/esm/plugins/meta-schema/name-meta-builders.d.ts +0 -4
  19. package/esm/plugins/meta-schema/name-meta-builders.js +0 -38
  20. package/esm/plugins/meta-schema/plugin.d.ts +0 -2
  21. package/esm/plugins/meta-schema/plugin.js +0 -23
  22. package/esm/plugins/meta-schema/relation-meta-builders.d.ts +0 -8
  23. package/esm/plugins/meta-schema/relation-meta-builders.js +0 -119
  24. package/esm/plugins/meta-schema/scope-meta-builders.d.ts +0 -15
  25. package/esm/plugins/meta-schema/scope-meta-builders.js +0 -40
  26. package/esm/plugins/meta-schema/storage-search-meta-builders.d.ts +0 -29
  27. package/esm/plugins/meta-schema/storage-search-meta-builders.js +0 -180
  28. package/esm/plugins/meta-schema/table-meta-builder.d.ts +0 -2
  29. package/esm/plugins/meta-schema/table-meta-builder.js +0 -99
  30. package/esm/plugins/meta-schema/table-meta-context.d.ts +0 -13
  31. package/esm/plugins/meta-schema/table-meta-context.js +0 -11
  32. package/esm/plugins/meta-schema/table-resource-utils.d.ts +0 -12
  33. package/esm/plugins/meta-schema/table-resource-utils.js +0 -50
  34. package/esm/plugins/meta-schema/type-mappings.d.ts +0 -7
  35. package/esm/plugins/meta-schema/type-mappings.js +0 -100
  36. package/esm/plugins/meta-schema/types.d.ts +0 -325
  37. package/esm/plugins/meta-schema/types.js +0 -1
  38. package/plugins/meta-schema/cache.d.ts +0 -4
  39. package/plugins/meta-schema/cache.js +0 -12
  40. package/plugins/meta-schema/constraint-meta-builders.d.ts +0 -13
  41. package/plugins/meta-schema/constraint-meta-builders.js +0 -58
  42. package/plugins/meta-schema/encoding-meta-builders.d.ts +0 -2
  43. package/plugins/meta-schema/encoding-meta-builders.js +0 -87
  44. package/plugins/meta-schema/graphql-meta-field.d.ts +0 -4
  45. package/plugins/meta-schema/graphql-meta-field.js +0 -317
  46. package/plugins/meta-schema/inflection-utils.d.ts +0 -4
  47. package/plugins/meta-schema/inflection-utils.js +0 -25
  48. package/plugins/meta-schema/name-meta-builders.d.ts +0 -4
  49. package/plugins/meta-schema/name-meta-builders.js +0 -43
  50. package/plugins/meta-schema/plugin.d.ts +0 -2
  51. package/plugins/meta-schema/plugin.js +0 -26
  52. package/plugins/meta-schema/relation-meta-builders.d.ts +0 -8
  53. package/plugins/meta-schema/relation-meta-builders.js +0 -124
  54. package/plugins/meta-schema/scope-meta-builders.d.ts +0 -15
  55. package/plugins/meta-schema/scope-meta-builders.js +0 -43
  56. package/plugins/meta-schema/storage-search-meta-builders.d.ts +0 -29
  57. package/plugins/meta-schema/storage-search-meta-builders.js +0 -186
  58. package/plugins/meta-schema/table-meta-builder.d.ts +0 -2
  59. package/plugins/meta-schema/table-meta-builder.js +0 -102
  60. package/plugins/meta-schema/table-meta-context.d.ts +0 -13
  61. package/plugins/meta-schema/table-meta-context.js +0 -15
  62. package/plugins/meta-schema/table-resource-utils.d.ts +0 -12
  63. package/plugins/meta-schema/table-resource-utils.js +0 -60
  64. package/plugins/meta-schema/type-mappings.d.ts +0 -7
  65. package/plugins/meta-schema/type-mappings.js +0 -104
  66. package/plugins/meta-schema/types.d.ts +0 -325
  67. package/plugins/meta-schema/types.js +0 -2
@@ -1,317 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extendQueryWithMetaField = extendQueryWithMetaField;
4
- const graphql_1 = require("graphql");
5
- function nn(type) {
6
- return new graphql_1.GraphQLNonNull(type);
7
- }
8
- function nnList(type) {
9
- return nn(new graphql_1.GraphQLList(nn(type)));
10
- }
11
- function createMetaSchemaType() {
12
- const MetaScalarEncodingType = new graphql_1.GraphQLObjectType({
13
- name: 'MetaScalarEncoding',
14
- description: 'How a client must serialize/parse a scalar — the one field-type detail standard GraphQL introspection cannot describe. Null for plain scalars whose wire format is obvious from gqlType.',
15
- fields: () => ({
16
- kind: {
17
- type: nn(graphql_1.GraphQLString),
18
- description: "Machine kind: bigint, datetime, date, time, interval, uuid, geojson, point, inet, ltree, vector, bytea, or composite."
19
- },
20
- elementType: { type: graphql_1.GraphQLString, description: "For 'vector': element scalar (e.g. 'float')." },
21
- dimensions: { type: graphql_1.GraphQLInt, description: "For 'vector': declared length, else null." },
22
- geometrySubtype: { type: graphql_1.GraphQLString, description: "For 'geojson': Point/LineString/Polygon/…, else null." },
23
- srid: { type: graphql_1.GraphQLInt, description: "For 'geojson': spatial reference id, else null." },
24
- dotPath: { type: graphql_1.GraphQLBoolean, description: "For 'ltree': values are dot-separated path strings." }
25
- })
26
- });
27
- const MetaTypeType = new graphql_1.GraphQLObjectType({
28
- name: 'MetaType',
29
- description: 'Information about a PostgreSQL type',
30
- fields: () => ({
31
- pgType: { type: nn(graphql_1.GraphQLString) },
32
- gqlType: { type: nn(graphql_1.GraphQLString) },
33
- isArray: { type: nn(graphql_1.GraphQLBoolean) },
34
- isNotNull: { type: graphql_1.GraphQLBoolean },
35
- hasDefault: { type: graphql_1.GraphQLBoolean },
36
- subtype: { type: graphql_1.GraphQLString },
37
- encoding: {
38
- type: MetaScalarEncodingType,
39
- description: 'Scalar serialization contract (null for plain scalars)'
40
- }
41
- })
42
- });
43
- const MetaEnumType = new graphql_1.GraphQLObjectType({
44
- name: 'MetaEnum',
45
- description: 'Information about a PostgreSQL enum type',
46
- fields: () => ({
47
- name: { type: nn(graphql_1.GraphQLString), description: 'The PostgreSQL enum type name' },
48
- values: { type: nnList(graphql_1.GraphQLString), description: 'Allowed values for this enum' }
49
- })
50
- });
51
- const MetaFieldType = new graphql_1.GraphQLObjectType({
52
- name: 'MetaField',
53
- description: 'Information about a table field/column',
54
- fields: () => ({
55
- name: { type: nn(graphql_1.GraphQLString) },
56
- type: { type: nn(MetaTypeType) },
57
- isNotNull: { type: nn(graphql_1.GraphQLBoolean) },
58
- hasDefault: { type: nn(graphql_1.GraphQLBoolean) },
59
- isPrimaryKey: { type: nn(graphql_1.GraphQLBoolean) },
60
- isForeignKey: { type: nn(graphql_1.GraphQLBoolean) },
61
- description: { type: graphql_1.GraphQLString },
62
- enumValues: { type: MetaEnumType, description: 'Enum metadata if this field has an enum type' }
63
- })
64
- });
65
- const MetaIndexType = new graphql_1.GraphQLObjectType({
66
- name: 'MetaIndex',
67
- description: 'Information about a database index',
68
- fields: () => ({
69
- name: { type: nn(graphql_1.GraphQLString) },
70
- isUnique: { type: nn(graphql_1.GraphQLBoolean) },
71
- isPrimary: { type: nn(graphql_1.GraphQLBoolean) },
72
- columns: { type: nnList(graphql_1.GraphQLString) },
73
- fields: { type: new graphql_1.GraphQLList(nn(MetaFieldType)) }
74
- })
75
- });
76
- const MetaPrimaryKeyConstraintType = new graphql_1.GraphQLObjectType({
77
- name: 'MetaPrimaryKeyConstraint',
78
- description: 'Information about a primary key constraint',
79
- fields: () => ({
80
- name: { type: nn(graphql_1.GraphQLString) },
81
- fields: { type: nnList(MetaFieldType) }
82
- })
83
- });
84
- const MetaUniqueConstraintType = new graphql_1.GraphQLObjectType({
85
- name: 'MetaUniqueConstraint',
86
- description: 'Information about a unique constraint',
87
- fields: () => ({
88
- name: { type: nn(graphql_1.GraphQLString) },
89
- fields: { type: nnList(MetaFieldType) }
90
- })
91
- });
92
- const MetaRefTableType = new graphql_1.GraphQLObjectType({
93
- name: 'MetaRefTable',
94
- description: 'Reference to a related table',
95
- fields: () => ({
96
- name: { type: nn(graphql_1.GraphQLString) }
97
- })
98
- });
99
- const MetaForeignKeyConstraintType = new graphql_1.GraphQLObjectType({
100
- name: 'MetaForeignKeyConstraint',
101
- description: 'Information about a foreign key constraint',
102
- fields: () => ({
103
- name: { type: nn(graphql_1.GraphQLString) },
104
- fields: { type: nnList(MetaFieldType) },
105
- referencedTable: { type: nn(graphql_1.GraphQLString) },
106
- referencedFields: { type: nnList(graphql_1.GraphQLString) },
107
- refFields: { type: new graphql_1.GraphQLList(nn(MetaFieldType)) },
108
- refTable: { type: MetaRefTableType }
109
- })
110
- });
111
- const MetaConstraintsType = new graphql_1.GraphQLObjectType({
112
- name: 'MetaConstraints',
113
- description: 'Table constraints',
114
- fields: () => ({
115
- primaryKey: { type: MetaPrimaryKeyConstraintType },
116
- unique: { type: nnList(MetaUniqueConstraintType) },
117
- foreignKey: { type: nnList(MetaForeignKeyConstraintType) }
118
- })
119
- });
120
- const MetaInflectionType = new graphql_1.GraphQLObjectType({
121
- name: 'MetaInflection',
122
- description: 'Table inflection names',
123
- fields: () => ({
124
- tableType: { type: nn(graphql_1.GraphQLString) },
125
- allRows: { type: nn(graphql_1.GraphQLString) },
126
- connection: { type: nn(graphql_1.GraphQLString) },
127
- edge: { type: nn(graphql_1.GraphQLString) },
128
- filterType: { type: graphql_1.GraphQLString },
129
- orderByType: { type: nn(graphql_1.GraphQLString) },
130
- conditionType: { type: nn(graphql_1.GraphQLString) },
131
- patchType: { type: graphql_1.GraphQLString },
132
- createInputType: { type: nn(graphql_1.GraphQLString) },
133
- createPayloadType: { type: nn(graphql_1.GraphQLString) },
134
- updatePayloadType: { type: graphql_1.GraphQLString },
135
- deletePayloadType: { type: nn(graphql_1.GraphQLString) }
136
- })
137
- });
138
- const MetaQueryType = new graphql_1.GraphQLObjectType({
139
- name: 'MetaQuery',
140
- description: 'Table query/mutation names',
141
- fields: () => ({
142
- all: { type: nn(graphql_1.GraphQLString) },
143
- one: { type: graphql_1.GraphQLString },
144
- create: { type: graphql_1.GraphQLString },
145
- update: { type: graphql_1.GraphQLString },
146
- delete: { type: graphql_1.GraphQLString }
147
- })
148
- });
149
- const MetaBelongsToRelationType = new graphql_1.GraphQLObjectType({
150
- name: 'MetaBelongsToRelation',
151
- description: 'A belongs-to (forward FK) relation',
152
- fields: () => ({
153
- fieldName: { type: graphql_1.GraphQLString },
154
- isUnique: { type: nn(graphql_1.GraphQLBoolean) },
155
- type: { type: graphql_1.GraphQLString },
156
- keys: { type: nnList(MetaFieldType) },
157
- references: { type: nn(MetaRefTableType) }
158
- })
159
- });
160
- const MetaHasRelationType = new graphql_1.GraphQLObjectType({
161
- name: 'MetaHasRelation',
162
- description: 'A has-one or has-many (reverse FK) relation',
163
- fields: () => ({
164
- fieldName: { type: graphql_1.GraphQLString },
165
- isUnique: { type: nn(graphql_1.GraphQLBoolean) },
166
- type: { type: graphql_1.GraphQLString },
167
- keys: { type: nnList(MetaFieldType) },
168
- referencedBy: { type: nn(MetaRefTableType) }
169
- })
170
- });
171
- const MetaManyToManyRelationType = new graphql_1.GraphQLObjectType({
172
- name: 'MetaManyToManyRelation',
173
- description: 'A many-to-many relation via junction table',
174
- fields: () => ({
175
- fieldName: { type: graphql_1.GraphQLString },
176
- type: { type: graphql_1.GraphQLString },
177
- junctionTable: { type: nn(MetaRefTableType) },
178
- junctionLeftConstraint: { type: nn(MetaForeignKeyConstraintType) },
179
- junctionLeftKeyAttributes: { type: nnList(MetaFieldType) },
180
- junctionRightConstraint: { type: nn(MetaForeignKeyConstraintType) },
181
- junctionRightKeyAttributes: { type: nnList(MetaFieldType) },
182
- leftKeyAttributes: { type: nnList(MetaFieldType) },
183
- rightKeyAttributes: { type: nnList(MetaFieldType) },
184
- rightTable: { type: nn(MetaRefTableType) }
185
- })
186
- });
187
- const MetaRelationsType = new graphql_1.GraphQLObjectType({
188
- name: 'MetaRelations',
189
- description: 'Table relations',
190
- fields: () => ({
191
- belongsTo: { type: nnList(MetaBelongsToRelationType) },
192
- has: { type: nnList(MetaHasRelationType) },
193
- hasOne: { type: nnList(MetaHasRelationType) },
194
- hasMany: { type: nnList(MetaHasRelationType) },
195
- manyToMany: { type: nnList(MetaManyToManyRelationType) }
196
- })
197
- });
198
- const MetaStorageType = new graphql_1.GraphQLObjectType({
199
- name: 'MetaStorage',
200
- description: 'Storage metadata for a table',
201
- fields: () => ({
202
- isFilesTable: { type: nn(graphql_1.GraphQLBoolean), description: 'Whether this table is a storage files table' },
203
- isBucketsTable: { type: nn(graphql_1.GraphQLBoolean), description: 'Whether this table is a storage buckets table' }
204
- })
205
- });
206
- const MetaSearchConfigType = new graphql_1.GraphQLObjectType({
207
- name: 'MetaSearchConfig',
208
- description: 'Per-table search configuration from @searchConfig smart tag',
209
- fields: () => ({
210
- weights: {
211
- type: graphql_1.GraphQLString,
212
- description: 'JSON-encoded per-adapter score weights',
213
- resolve(source) {
214
- return source.weights ? JSON.stringify(source.weights) : null;
215
- }
216
- },
217
- boostRecent: { type: nn(graphql_1.GraphQLBoolean), description: 'Whether recency boosting is enabled' },
218
- boostRecencyField: { type: graphql_1.GraphQLString, description: 'Field used for recency decay' },
219
- boostRecencyDecay: { type: graphql_1.GraphQLFloat, description: 'Exponential decay factor per day' }
220
- })
221
- });
222
- const MetaSearchColumnType = new graphql_1.GraphQLObjectType({
223
- name: 'MetaSearchColumn',
224
- description: 'A searchable column with its algorithm',
225
- fields: () => ({
226
- name: { type: nn(graphql_1.GraphQLString), description: 'Column name (camelCase)' },
227
- algorithm: { type: nn(graphql_1.GraphQLString), description: 'Search algorithm: tsvector, bm25, trgm, or vector' }
228
- })
229
- });
230
- const MetaSearchType = new graphql_1.GraphQLObjectType({
231
- name: 'MetaSearch',
232
- description: 'Search metadata for a table',
233
- fields: () => ({
234
- algorithms: { type: nnList(graphql_1.GraphQLString), description: 'Active search algorithms on this table' },
235
- columns: { type: nnList(MetaSearchColumnType), description: 'Searchable columns with their algorithm' },
236
- hasUnifiedSearch: { type: nn(graphql_1.GraphQLBoolean), description: 'Whether unifiedSearch composite filter is available' },
237
- config: { type: MetaSearchConfigType, description: 'Per-table search configuration' }
238
- })
239
- });
240
- const MetaI18nFieldType = new graphql_1.GraphQLObjectType({
241
- name: 'MetaI18nField',
242
- description: 'A translatable field',
243
- fields: () => ({
244
- name: { type: nn(graphql_1.GraphQLString), description: 'GraphQL field name' },
245
- type: { type: nn(graphql_1.GraphQLString), description: 'PostgreSQL column type (text, citext)' }
246
- })
247
- });
248
- const MetaI18nType = new graphql_1.GraphQLObjectType({
249
- name: 'MetaI18n',
250
- description: 'i18n metadata for a table with @i18n tag',
251
- fields: () => ({
252
- translationTable: { type: nn(graphql_1.GraphQLString), description: 'Name of the translation table' },
253
- translatableFields: { type: nnList(MetaI18nFieldType), description: 'Fields that are translatable' }
254
- })
255
- });
256
- const MetaRealtimeType = new graphql_1.GraphQLObjectType({
257
- name: 'MetaRealtime',
258
- description: 'Realtime metadata for a table with @realtime tag',
259
- fields: () => ({
260
- subscriptionFieldName: { type: nn(graphql_1.GraphQLString), description: 'The generated subscription field name (e.g. onPostChanged)' }
261
- })
262
- });
263
- const MetaScopeType = new graphql_1.GraphQLObjectType({
264
- name: 'MetaScope',
265
- description: 'Provisioning scope metadata for a table',
266
- fields: () => ({
267
- scope: { type: nn(graphql_1.GraphQLString), description: "Provisioning scope: 'platform', 'app', 'database', or an entity scope (e.g. 'org')" },
268
- tier: { type: nn(graphql_1.GraphQLString), description: "Coarse bucket: 'global', 'database', or 'entity'" },
269
- keyColumn: { type: graphql_1.GraphQLString, description: 'Inflected scope key column (e.g. databaseId, orgId), null for global tiers' },
270
- entityTable: { type: graphql_1.GraphQLString, description: 'SQL name of the entity table for entity scopes, else null' },
271
- source: { type: nn(graphql_1.GraphQLString), description: "Provenance of the scope metadata (always 'smartTag')" }
272
- })
273
- });
274
- const MetaTableType = new graphql_1.GraphQLObjectType({
275
- name: 'MetaTable',
276
- description: 'Information about a database table',
277
- fields: () => ({
278
- name: { type: nn(graphql_1.GraphQLString) },
279
- schemaName: { type: nn(graphql_1.GraphQLString) },
280
- fields: { type: nnList(MetaFieldType) },
281
- indexes: { type: nnList(MetaIndexType) },
282
- constraints: { type: nn(MetaConstraintsType) },
283
- foreignKeyConstraints: { type: nnList(MetaForeignKeyConstraintType) },
284
- primaryKeyConstraints: { type: nnList(MetaPrimaryKeyConstraintType) },
285
- uniqueConstraints: { type: nnList(MetaUniqueConstraintType) },
286
- relations: { type: nn(MetaRelationsType) },
287
- inflection: { type: nn(MetaInflectionType) },
288
- query: { type: nn(MetaQueryType) },
289
- storage: { type: MetaStorageType, description: 'Storage metadata (null if not a storage table)' },
290
- search: { type: MetaSearchType, description: 'Search metadata (null if no search configured)' },
291
- i18n: { type: MetaI18nType, description: 'i18n metadata (null if no @i18n tag)' },
292
- realtime: { type: MetaRealtimeType, description: 'Realtime metadata (null if no @realtime tag)' },
293
- scope: { type: MetaScopeType, description: 'Provisioning scope metadata (null if no @scope tag)' }
294
- })
295
- });
296
- return new graphql_1.GraphQLObjectType({
297
- name: 'MetaSchema',
298
- description: 'Root meta schema type',
299
- fields: () => ({
300
- tables: { type: nnList(MetaTableType) }
301
- })
302
- });
303
- }
304
- function extendQueryWithMetaField(fields, tablesMeta) {
305
- const metaSchemaType = createMetaSchemaType();
306
- const metaField = {
307
- type: metaSchemaType,
308
- description: 'Metadata about the database schema, including tables, fields, indexes, and constraints. Useful for code generation tools.',
309
- resolve() {
310
- return { tables: tablesMeta };
311
- }
312
- };
313
- return {
314
- ...fields,
315
- _meta: metaField
316
- };
317
- }
@@ -1,4 +0,0 @@
1
- import type { MetaInflection, PgCodec } from './types';
2
- export declare function safeInflection<T>(fn: () => T, fallback: T): T;
3
- export declare function createAttributeInflector(inflection: MetaInflection): (attrName: string, codec: PgCodec) => string;
4
- export declare function fallbackTableType(codecName: string): string;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.safeInflection = safeInflection;
4
- exports.createAttributeInflector = createAttributeInflector;
5
- exports.fallbackTableType = fallbackTableType;
6
- function safeInflection(fn, fallback) {
7
- try {
8
- return fn() ?? fallback;
9
- }
10
- catch {
11
- return fallback;
12
- }
13
- }
14
- function createAttributeInflector(inflection) {
15
- return (attrName, codec) => {
16
- const attributeName = safeInflection(() => inflection._attributeName?.({ attributeName: attrName, codec }), attrName);
17
- return safeInflection(() => inflection.camelCase?.(attributeName), attributeName);
18
- };
19
- }
20
- function fallbackTableType(codecName) {
21
- return codecName
22
- .replace(/_/g, ' ')
23
- .replace(/\b\w/g, (char) => char.toUpperCase())
24
- .replace(/ /g, '');
25
- }
@@ -1,4 +0,0 @@
1
- import type { InflectionMeta, MetaBuild, PgCodec, PgTableResource, PgUnique, QueryMeta } from './types';
2
- export declare function resolveTableType(build: MetaBuild, codec: PgCodec): string;
3
- export declare function buildInflectionMeta(resource: PgTableResource, tableType: string, build: MetaBuild): InflectionMeta;
4
- export declare function buildQueryMeta(resource: PgTableResource, uniques: PgUnique[], tableType: string, build: MetaBuild): QueryMeta;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveTableType = resolveTableType;
4
- exports.buildInflectionMeta = buildInflectionMeta;
5
- exports.buildQueryMeta = buildQueryMeta;
6
- const inflection_utils_1 = require("./inflection-utils");
7
- function resolveTableType(build, codec) {
8
- return (0, inflection_utils_1.safeInflection)(() => build.inflection.tableType(codec), (0, inflection_utils_1.fallbackTableType)(codec.name));
9
- }
10
- function buildInflectionMeta(resource, tableType, build) {
11
- const inflection = build.inflection;
12
- return {
13
- tableType,
14
- allRows: (0, inflection_utils_1.safeInflection)(() => inflection.allRows?.(resource), `${tableType.toLowerCase()}s`),
15
- connection: (0, inflection_utils_1.safeInflection)(() => inflection.connectionType?.(tableType), `${tableType}Connection`),
16
- edge: (0, inflection_utils_1.safeInflection)(() => inflection.edgeType?.(tableType), `${tableType}Edge`),
17
- filterType: (0, inflection_utils_1.safeInflection)(() => inflection.filterType?.(tableType), `${tableType}Filter`),
18
- orderByType: (0, inflection_utils_1.safeInflection)(() => inflection.orderByType?.(tableType), `${tableType}OrderBy`),
19
- conditionType: (0, inflection_utils_1.safeInflection)(() => inflection.conditionType?.(tableType), `${tableType}Condition`),
20
- patchType: (0, inflection_utils_1.safeInflection)(() => inflection.patchType?.(tableType), `${tableType}Patch`),
21
- createInputType: (0, inflection_utils_1.safeInflection)(() => inflection.createInputType?.(resource), `Create${tableType}Input`),
22
- createPayloadType: (0, inflection_utils_1.safeInflection)(() => inflection.createPayloadType?.(resource), `Create${tableType}Payload`),
23
- updatePayloadType: (0, inflection_utils_1.safeInflection)(() => inflection.updatePayloadType?.(resource), `Update${tableType}Payload`),
24
- deletePayloadType: (0, inflection_utils_1.safeInflection)(() => inflection.deletePayloadType?.(resource), `Delete${tableType}Payload`),
25
- };
26
- }
27
- function buildQueryMeta(resource, uniques, tableType, build) {
28
- const inflection = build.inflection;
29
- const hasPrimaryKey = uniques.some((unique) => unique.isPrimary);
30
- return {
31
- all: (0, inflection_utils_1.safeInflection)(() => inflection.allRows?.(resource), `${tableType.toLowerCase()}s`),
32
- one: hasPrimaryKey
33
- ? (0, inflection_utils_1.safeInflection)(() => inflection.tableFieldName?.(resource), tableType.toLowerCase())
34
- : null,
35
- create: (0, inflection_utils_1.safeInflection)(() => inflection.createField?.(resource), `create${tableType}`),
36
- update: hasPrimaryKey
37
- ? (0, inflection_utils_1.safeInflection)(() => inflection.updateByKeys?.(resource), `update${tableType}`)
38
- : null,
39
- delete: hasPrimaryKey
40
- ? (0, inflection_utils_1.safeInflection)(() => inflection.deleteByKeys?.(resource), `delete${tableType}`)
41
- : null,
42
- };
43
- }
@@ -1,2 +0,0 @@
1
- import type { GraphileConfig } from 'graphile-config';
2
- export declare const MetaSchemaPlugin: GraphileConfig.Plugin;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MetaSchemaPlugin = void 0;
4
- const cache_1 = require("./cache");
5
- const graphql_meta_field_1 = require("./graphql-meta-field");
6
- const table_meta_builder_1 = require("./table-meta-builder");
7
- exports.MetaSchemaPlugin = {
8
- name: 'MetaSchemaPlugin',
9
- version: '1.0.0',
10
- description: 'Exposes _meta query for database schema introspection',
11
- schema: {
12
- hooks: {
13
- init(input, rawBuild) {
14
- const build = rawBuild;
15
- (0, cache_1.setCachedTablesMeta)((0, table_meta_builder_1.collectTablesMeta)(build));
16
- return input;
17
- },
18
- GraphQLObjectType_fields(rawFields, _rawBuild, rawContext) {
19
- const context = rawContext;
20
- if (context.Self?.name !== 'Query')
21
- return rawFields;
22
- return (0, graphql_meta_field_1.extendQueryWithMetaField)(rawFields, (0, cache_1.getCachedTablesMeta)());
23
- },
24
- },
25
- },
26
- };
@@ -1,8 +0,0 @@
1
- import { type BuildContext } from './table-meta-context';
2
- import type { BelongsToRelation, HasRelation, ManyToManyRelation, PgAttribute, PgCodec, PgRelation, PgTableResource, PgUnique } from './types';
3
- export declare function buildBelongsToRelations(codec: PgCodec, attributes: Record<string, PgAttribute>, uniques: PgUnique[], relations: Record<string, PgRelation>, context: BuildContext): BelongsToRelation[];
4
- export declare function buildReverseRelations(codec: PgCodec, attributes: Record<string, PgAttribute>, relations: Record<string, PgRelation>, context: BuildContext): {
5
- hasOne: HasRelation[];
6
- hasMany: HasRelation[];
7
- };
8
- export declare function buildManyToManyRelations(resource: PgTableResource, codec: PgCodec, context: BuildContext): ManyToManyRelation[];
@@ -1,124 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildBelongsToRelations = buildBelongsToRelations;
4
- exports.buildReverseRelations = buildReverseRelations;
5
- exports.buildManyToManyRelations = buildManyToManyRelations;
6
- const inflection_utils_1 = require("./inflection-utils");
7
- const constraint_meta_builders_1 = require("./constraint-meta-builders");
8
- const table_meta_context_1 = require("./table-meta-context");
9
- const table_resource_utils_1 = require("./table-resource-utils");
10
- function isRecord(value) {
11
- return typeof value === 'object' && value !== null;
12
- }
13
- function buildBelongsToRelations(codec, attributes, uniques, relations, context) {
14
- const belongsTo = [];
15
- for (const [relationName, relation] of Object.entries(relations)) {
16
- // PostGraphile only sets isReferencee when true (reverse FK);
17
- // forward relations have isReferencee undefined, not false.
18
- if (relation.isReferencee)
19
- continue;
20
- const localAttributes = relation.localAttributes || [];
21
- const isUnique = uniques.some((unique) => (0, table_resource_utils_1.sameAttributes)(unique.attributes, localAttributes));
22
- const remoteCodec = relation.remoteResource?.codec;
23
- belongsTo.push({
24
- fieldName: relationName,
25
- isUnique,
26
- type: remoteCodec?.name || null,
27
- keys: (0, table_meta_context_1.buildFieldList)(localAttributes, codec, attributes, context),
28
- references: { name: remoteCodec?.name || 'unknown' },
29
- });
30
- }
31
- return belongsTo;
32
- }
33
- function buildReverseRelations(codec, attributes, relations, context) {
34
- const hasOne = [];
35
- const hasMany = [];
36
- for (const [relationName, relation] of Object.entries(relations)) {
37
- if (relation.isReferencee !== true)
38
- continue;
39
- const remoteUniques = (0, table_resource_utils_1.getUniques)(relation.remoteResource || {});
40
- const remoteAttributes = relation.remoteAttributes || [];
41
- const isUnique = remoteUniques.some((unique) => (0, table_resource_utils_1.sameAttributes)(unique.attributes, remoteAttributes));
42
- const remoteCodec = relation.remoteResource?.codec;
43
- const meta = {
44
- fieldName: relationName,
45
- isUnique,
46
- type: remoteCodec?.name || null,
47
- keys: (0, table_meta_context_1.buildFieldList)(relation.localAttributes || [], codec, attributes, context),
48
- referencedBy: { name: remoteCodec?.name || 'unknown' },
49
- };
50
- if (isUnique) {
51
- hasOne.push(meta);
52
- }
53
- else {
54
- hasMany.push(meta);
55
- }
56
- }
57
- return { hasOne, hasMany };
58
- }
59
- function isManyToManyDetails(value) {
60
- if (!isRecord(value))
61
- return false;
62
- return (isRecord(value.leftTable) &&
63
- isRecord(value.junctionTable) &&
64
- isRecord(value.rightTable) &&
65
- typeof value.leftRelationName === 'string' &&
66
- typeof value.rightRelationName === 'string');
67
- }
68
- function parseManyToManyRelationships(value) {
69
- if (!Array.isArray(value))
70
- return [];
71
- return value.filter(isManyToManyDetails);
72
- }
73
- function getManyToManyRelationships(build, tableResource, codec) {
74
- const relationshipsByResource = build.pgManyToManyRealtionshipsByResource;
75
- if (!(relationshipsByResource instanceof Map))
76
- return [];
77
- const direct = parseManyToManyRelationships(relationshipsByResource.get(tableResource));
78
- if (direct.length > 0)
79
- return direct;
80
- for (const [leftTable, relationships] of relationshipsByResource.entries()) {
81
- const details = parseManyToManyRelationships(relationships);
82
- if (details.length === 0 || !isRecord(leftTable))
83
- continue;
84
- if (leftTable.codec === codec) {
85
- return details;
86
- }
87
- }
88
- return [];
89
- }
90
- function buildManyToManyRelation(details, context) {
91
- const leftCodec = (0, table_resource_utils_1.getResourceCodec)(details.leftTable);
92
- const junctionCodec = (0, table_resource_utils_1.getResourceCodec)(details.junctionTable);
93
- const rightCodec = (0, table_resource_utils_1.getResourceCodec)(details.rightTable);
94
- if (!leftCodec || !junctionCodec || !rightCodec)
95
- return null;
96
- const leftRelation = (0, table_resource_utils_1.getRelation)(details.leftTable, details.leftRelationName);
97
- const junctionRightRelation = (0, table_resource_utils_1.getRelation)(details.junctionTable, details.rightRelationName);
98
- if (!leftRelation || !junctionRightRelation)
99
- return null;
100
- const leftJunctionAttributes = leftRelation.remoteAttributes || [];
101
- const leftTableAttributes = leftRelation.localAttributes || [];
102
- const rightJunctionAttributes = junctionRightRelation.localAttributes || [];
103
- const rightTableAttributes = junctionRightRelation.remoteAttributes || [];
104
- const relationFieldName = (0, inflection_utils_1.safeInflection)(() => context.build.inflection._manyToManyRelation?.(details), details.rightRelationName || rightCodec.name || null);
105
- const junctionLeftConstraint = (0, constraint_meta_builders_1.buildForeignKeyConstraint)(details.leftRelationName || `${junctionCodec.name}_${leftCodec.name}_fkey`, junctionCodec, junctionCodec.attributes, leftJunctionAttributes, leftCodec, leftCodec.attributes, leftTableAttributes, context);
106
- const junctionRightConstraint = (0, constraint_meta_builders_1.buildForeignKeyConstraint)(details.rightRelationName || `${junctionCodec.name}_${rightCodec.name}_fkey`, junctionCodec, junctionCodec.attributes, rightJunctionAttributes, rightCodec, rightCodec.attributes, rightTableAttributes, context);
107
- return {
108
- fieldName: relationFieldName,
109
- type: rightCodec.name || null,
110
- junctionTable: { name: junctionCodec.name || 'unknown' },
111
- junctionLeftConstraint,
112
- junctionLeftKeyAttributes: (0, table_meta_context_1.buildFieldList)(leftJunctionAttributes, junctionCodec, junctionCodec.attributes, context),
113
- junctionRightConstraint,
114
- junctionRightKeyAttributes: (0, table_meta_context_1.buildFieldList)(rightJunctionAttributes, junctionCodec, junctionCodec.attributes, context),
115
- leftKeyAttributes: (0, table_meta_context_1.buildFieldList)(leftTableAttributes, leftCodec, leftCodec.attributes, context),
116
- rightKeyAttributes: (0, table_meta_context_1.buildFieldList)(rightTableAttributes, rightCodec, rightCodec.attributes, context),
117
- rightTable: { name: rightCodec.name || 'unknown' },
118
- };
119
- }
120
- function buildManyToManyRelations(resource, codec, context) {
121
- return getManyToManyRelationships(context.build, resource, codec)
122
- .map((details) => buildManyToManyRelation(details, context))
123
- .filter((relation) => relation !== null);
124
- }
@@ -1,15 +0,0 @@
1
- import type { PgCodec, ScopeMeta } from './types';
2
- /**
3
- * Detect provisioning scope metadata for a table.
4
- *
5
- * The `@scope` smart tag emitted by the constructive-db generators is the sole
6
- * source of truth. `apply_scope_fields` knows the exact scope, tier, key column,
7
- * and entity table, and emits them via
8
- * `metaschema.append_table_smart_tags(id, { scope, scopeTier, scopeKey, scopeEntityTable })`.
9
- * PostGraphile surfaces these as `codec.extensions.tags.*`.
10
- *
11
- * There is NO inference from column names — a table without the tag returns
12
- * `null` (the same convention as every other nullable metadata block). This
13
- * avoids guessing key columns, whose names are chosen freely by each generator.
14
- */
15
- export declare function buildScopeMeta(codec: PgCodec, inflectAttr: (attrName: string, codec: PgCodec) => string): ScopeMeta | null;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildScopeMeta = buildScopeMeta;
4
- const VALID_TIERS = new Set(['global', 'database', 'entity']);
5
- function readString(value) {
6
- return typeof value === 'string' && value.length > 0 ? value : null;
7
- }
8
- /**
9
- * Detect provisioning scope metadata for a table.
10
- *
11
- * The `@scope` smart tag emitted by the constructive-db generators is the sole
12
- * source of truth. `apply_scope_fields` knows the exact scope, tier, key column,
13
- * and entity table, and emits them via
14
- * `metaschema.append_table_smart_tags(id, { scope, scopeTier, scopeKey, scopeEntityTable })`.
15
- * PostGraphile surfaces these as `codec.extensions.tags.*`.
16
- *
17
- * There is NO inference from column names — a table without the tag returns
18
- * `null` (the same convention as every other nullable metadata block). This
19
- * avoids guessing key columns, whose names are chosen freely by each generator.
20
- */
21
- function buildScopeMeta(codec, inflectAttr) {
22
- const tags = codec.extensions?.tags;
23
- const scope = readString(tags?.scope);
24
- if (!scope)
25
- return null;
26
- const rawTier = readString(tags.scopeTier);
27
- const tier = rawTier && VALID_TIERS.has(rawTier)
28
- ? rawTier
29
- : null;
30
- if (!tier) {
31
- throw new Error(`@scope tag on codec "${codec.name}" is missing a valid scopeTier ` +
32
- `(expected one of global|database|entity, got ${JSON.stringify(rawTier)})`);
33
- }
34
- const keyColumn = readString(tags.scopeKey);
35
- const entityTable = readString(tags.scopeEntityTable);
36
- return {
37
- scope,
38
- tier,
39
- keyColumn: keyColumn ? inflectAttr(keyColumn, codec) : null,
40
- entityTable,
41
- source: 'smartTag'
42
- };
43
- }
@@ -1,29 +0,0 @@
1
- import type { I18nMeta, PgCodec, RealtimeMeta, SearchMeta, StorageMeta } from './types';
2
- /**
3
- * Detect storage metadata from a codec's smart tags.
4
- * Storage tables are identified by @storageFiles and @storageBuckets smart tags.
5
- */
6
- export declare function buildStorageMeta(codec: PgCodec): StorageMeta | null;
7
- /**
8
- * Detect search metadata from a codec's columns and smart tags.
9
- *
10
- * Looks for:
11
- * - tsvector columns (full-text search)
12
- * - vector columns (pgvector semantic search)
13
- * - @searchConfig smart tag (per-table search configuration)
14
- * - @bm25Index smart tag on columns (BM25 search)
15
- * - @trgmSearch smart tag (trigram search)
16
- */
17
- export declare function buildSearchMeta(codec: PgCodec, _build: unknown, inflectAttr: (attrName: string, codec: PgCodec) => string): SearchMeta | null;
18
- /**
19
- * Detect i18n metadata from a codec's @i18n smart tag.
20
- * The @i18n tag value is the name of the translation table.
21
- * Translatable fields are discovered by matching text/citext columns
22
- * between the base table and the translation table codec.
23
- */
24
- export declare function buildI18nMeta(codec: PgCodec, build: unknown, inflectAttr: (attrName: string, codec: PgCodec) => string): I18nMeta | null;
25
- /**
26
- * Detect realtime metadata from a codec's @realtime smart tag.
27
- * Tables tagged with @realtime get subscription fields generated.
28
- */
29
- export declare function buildRealtimeMeta(codec: PgCodec, build: unknown): RealtimeMeta | null;