@pgpmjs/export 0.27.0 → 0.28.1
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/export-graphql-meta.js +28 -107
- package/esm/export-meta.js +33 -129
- package/esm/export-utils.js +69 -497
- package/esm/index.js +1 -1
- package/esm/meta-export-tables.json +590 -0
- package/export-graphql-meta.js +27 -106
- package/export-meta.js +32 -128
- package/export-utils.d.ts +52 -8
- package/export-utils.js +73 -498
- package/index.d.ts +2 -2
- package/index.js +2 -1
- package/meta-export-tables.json +590 -0
- package/package.json +5 -5
package/export-utils.js
CHANGED
|
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.normalizeOutdir = exports.preparePackage = exports.makeReplacer = exports.installMissingModules = exports.detectMissingModules = exports.META_TABLE_CONFIG = exports.META_TABLE_ORDER = exports.META_COMMON_FOOTER = exports.META_COMMON_HEADER = exports.SERVICE_REQUIRED_EXTENSIONS = exports.mapPgTypeToFieldType = exports.DB_REQUIRED_EXTENSIONS = void 0;
|
|
6
|
+
exports.normalizeOutdir = exports.preparePackage = exports.makeReplacer = exports.installMissingModules = exports.detectMissingModules = exports.getTimestampDefaultColumnsForTable = exports.META_TABLE_TIMESTAMP_DEFAULTS = exports.META_TABLE_CONFIG = exports.META_TABLE_ORDER = exports.META_TABLE_OVERRIDES = exports.META_COMMON_FOOTER = exports.META_COMMON_HEADER = exports.SERVICE_REQUIRED_EXTENSIONS = exports.isTimestampDefaultColumn = exports.getTableColumnsWithDefaults = exports.mapPgTypeToFieldType = exports.DB_REQUIRED_EXTENSIONS = void 0;
|
|
7
|
+
const core_1 = require("@pgpmjs/core");
|
|
7
8
|
const fs_1 = require("fs");
|
|
8
9
|
const glob_1 = require("glob");
|
|
9
10
|
const inflekt_1 = require("inflekt");
|
|
10
11
|
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const
|
|
12
|
+
const meta_export_tables_json_1 = __importDefault(require("./meta-export-tables.json"));
|
|
12
13
|
const type_map_1 = require("./type-map");
|
|
13
14
|
// =============================================================================
|
|
14
15
|
// Shared constants
|
|
@@ -53,6 +54,40 @@ const mapPgTypeToFieldType = (udtName) => {
|
|
|
53
54
|
return entry?.fieldType ?? 'text';
|
|
54
55
|
};
|
|
55
56
|
exports.mapPgTypeToFieldType = mapPgTypeToFieldType;
|
|
57
|
+
/**
|
|
58
|
+
* Query actual columns from information_schema for a given table.
|
|
59
|
+
* Returns a map of column_name -> { udt_name, column_default }.
|
|
60
|
+
*/
|
|
61
|
+
const getTableColumnsWithDefaults = async (pool, schemaName, tableName) => {
|
|
62
|
+
const result = await pool.query(`
|
|
63
|
+
SELECT column_name, udt_name, column_default
|
|
64
|
+
FROM information_schema.columns
|
|
65
|
+
WHERE table_schema = $1 AND table_name = $2
|
|
66
|
+
ORDER BY ordinal_position
|
|
67
|
+
`, [schemaName, tableName]);
|
|
68
|
+
const columns = new Map();
|
|
69
|
+
for (const row of result.rows) {
|
|
70
|
+
columns.set(row.column_name, {
|
|
71
|
+
udt_name: row.udt_name,
|
|
72
|
+
column_default: row.column_default
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return columns;
|
|
76
|
+
};
|
|
77
|
+
exports.getTableColumnsWithDefaults = getTableColumnsWithDefaults;
|
|
78
|
+
/**
|
|
79
|
+
* Detect whether a column default expression is a non-deterministic timestamp
|
|
80
|
+
* default (now(), CURRENT_TIMESTAMP, clock_timestamp(), or now() + interval).
|
|
81
|
+
* Exported INSERT rows must omit these columns so the DDL DEFAULT applies at
|
|
82
|
+
* deploy time, keeping generated migrations deterministic.
|
|
83
|
+
*/
|
|
84
|
+
const isTimestampDefaultColumn = (columnDefault) => {
|
|
85
|
+
if (!columnDefault)
|
|
86
|
+
return false;
|
|
87
|
+
const normalized = columnDefault.trim().toLowerCase();
|
|
88
|
+
return /^(now\s*\(\s*\)|current_timestamp(?:\s*\(\s*\d*\s*\))?|clock_timestamp\s*\(\s*\))(?:\s*\+\s*'[^']*'\s*::\s*interval)?$/i.test(normalized);
|
|
89
|
+
};
|
|
90
|
+
exports.isTimestampDefaultColumn = isTimestampDefaultColumn;
|
|
56
91
|
/**
|
|
57
92
|
* Required extensions for service/meta exports.
|
|
58
93
|
* Includes native PostgreSQL extensions and pgpm modules for metadata management.
|
|
@@ -88,207 +123,17 @@ $LQLMIGRATION$;`;
|
|
|
88
123
|
exports.META_COMMON_FOOTER = `
|
|
89
124
|
SET session_replication_role TO DEFAULT;`;
|
|
90
125
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
126
|
+
* Hand-authored per-table overrides layered on top of the generated
|
|
127
|
+
* table manifest. Only exceptional exporter behavior lives here:
|
|
128
|
+
* conflict handling, special field types (image, upload, url) that
|
|
129
|
+
* cannot be inferred, GraphQL type name overrides, and columns whose
|
|
130
|
+
* values must come from DDL defaults at deploy time.
|
|
93
131
|
*/
|
|
94
|
-
exports.
|
|
95
|
-
'database',
|
|
96
|
-
'schema',
|
|
97
|
-
'function',
|
|
98
|
-
'table',
|
|
99
|
-
'field',
|
|
100
|
-
'spatial_relation',
|
|
101
|
-
'policy',
|
|
102
|
-
'index',
|
|
103
|
-
'trigger',
|
|
104
|
-
'trigger_function',
|
|
105
|
-
'rls_function',
|
|
106
|
-
'foreign_key_constraint',
|
|
107
|
-
'primary_key_constraint',
|
|
108
|
-
'unique_constraint',
|
|
109
|
-
'check_constraint',
|
|
110
|
-
'full_text_search',
|
|
111
|
-
'schema_grant',
|
|
112
|
-
'table_grant',
|
|
113
|
-
'default_privilege',
|
|
114
|
-
'domains',
|
|
115
|
-
'sites',
|
|
116
|
-
'apis',
|
|
117
|
-
'apps',
|
|
118
|
-
'site_modules',
|
|
119
|
-
'site_themes',
|
|
120
|
-
'site_metadata',
|
|
121
|
-
'api_modules',
|
|
122
|
-
'api_extensions',
|
|
123
|
-
'api_schemas',
|
|
124
|
-
'database_settings',
|
|
125
|
-
'api_settings',
|
|
126
|
-
'rls_settings',
|
|
127
|
-
'cors_settings',
|
|
128
|
-
'pubkey_settings',
|
|
129
|
-
'webauthn_settings',
|
|
130
|
-
'rls_module',
|
|
131
|
-
'user_auth_module',
|
|
132
|
-
'memberships_module',
|
|
133
|
-
'permissions_module',
|
|
134
|
-
'limits_module',
|
|
135
|
-
'levels_module',
|
|
136
|
-
'events_module',
|
|
137
|
-
'users_module',
|
|
138
|
-
'hierarchy_module',
|
|
139
|
-
'membership_types_module',
|
|
140
|
-
'invites_module',
|
|
141
|
-
'emails_module',
|
|
142
|
-
'sessions_module',
|
|
143
|
-
'user_state_module',
|
|
144
|
-
'profiles_module',
|
|
145
|
-
'config_secrets_user_module',
|
|
146
|
-
'user_credentials_module',
|
|
147
|
-
'user_settings_module',
|
|
148
|
-
'connected_accounts_module',
|
|
149
|
-
'phone_numbers_module',
|
|
150
|
-
'crypto_addresses_module',
|
|
151
|
-
'crypto_auth_module',
|
|
152
|
-
'field_module',
|
|
153
|
-
'table_module',
|
|
154
|
-
'secure_table_provision',
|
|
155
|
-
'uuid_module',
|
|
156
|
-
'default_ids_module',
|
|
157
|
-
'denormalized_table_field',
|
|
158
|
-
// NOTE: blueprint_template, blueprint, and blueprint_construction are intentionally
|
|
159
|
-
// excluded from the export flow — they are runtime-only tables not exported as metadata.
|
|
160
|
-
'relation_provision',
|
|
161
|
-
'entity_type_provision',
|
|
162
|
-
'rate_limits_module',
|
|
163
|
-
'storage_module',
|
|
164
|
-
'billing_module',
|
|
165
|
-
'billing_provider_module',
|
|
166
|
-
'devices_module',
|
|
167
|
-
'identity_providers_module',
|
|
168
|
-
'integration_providers_module',
|
|
169
|
-
'notifications_module',
|
|
170
|
-
'plans_module',
|
|
171
|
-
'realtime_module',
|
|
172
|
-
'session_secrets_module',
|
|
173
|
-
'infra_secrets_module',
|
|
174
|
-
'infra_config_module',
|
|
175
|
-
'internal_secrets_module',
|
|
176
|
-
'i18n_module',
|
|
177
|
-
'agent_module',
|
|
178
|
-
'function_module',
|
|
179
|
-
'namespace_module',
|
|
180
|
-
'merkle_store_module',
|
|
181
|
-
'graph_module',
|
|
182
|
-
'graph_execution_module',
|
|
183
|
-
'function_deployment_module',
|
|
184
|
-
'function_invocation_module',
|
|
185
|
-
'compute_log_module',
|
|
186
|
-
'db_usage_module',
|
|
187
|
-
'storage_log_module',
|
|
188
|
-
'transfer_log_module',
|
|
189
|
-
'webauthn_auth_module',
|
|
190
|
-
'webauthn_credentials_module',
|
|
191
|
-
'inference_log_module',
|
|
192
|
-
'rate_limit_meters_module'
|
|
193
|
-
];
|
|
194
|
-
/**
|
|
195
|
-
* Shared metadata table configuration.
|
|
196
|
-
*
|
|
197
|
-
* Fields are discovered dynamically at runtime via introspection:
|
|
198
|
-
* - SQL flow: uses information_schema.columns + mapPgTypeToFieldType()
|
|
199
|
-
* - GraphQL flow: uses __type introspection + mapGraphQLTypeToFieldType()
|
|
200
|
-
*
|
|
201
|
-
* Only `typeOverrides` are hardcoded for special types (image, upload, url)
|
|
202
|
-
* that cannot be inferred from database/GraphQL types alone.
|
|
203
|
-
*
|
|
204
|
-
*/
|
|
205
|
-
exports.META_TABLE_CONFIG = {
|
|
206
|
-
// =============================================================================
|
|
207
|
-
// metaschema_public tables
|
|
208
|
-
// =============================================================================
|
|
209
|
-
database: {
|
|
210
|
-
schema: 'metaschema_public',
|
|
211
|
-
table: 'database'
|
|
212
|
-
},
|
|
213
|
-
schema: {
|
|
214
|
-
schema: 'metaschema_public',
|
|
215
|
-
table: 'schema'
|
|
216
|
-
},
|
|
217
|
-
function: {
|
|
218
|
-
schema: 'metaschema_public',
|
|
219
|
-
table: 'function'
|
|
220
|
-
},
|
|
221
|
-
table: {
|
|
222
|
-
schema: 'metaschema_public',
|
|
223
|
-
table: 'table'
|
|
224
|
-
},
|
|
132
|
+
exports.META_TABLE_OVERRIDES = {
|
|
225
133
|
field: {
|
|
226
|
-
schema: 'metaschema_public',
|
|
227
|
-
table: 'field',
|
|
228
134
|
conflictDoNothing: true
|
|
229
135
|
},
|
|
230
|
-
policy: {
|
|
231
|
-
schema: 'metaschema_public',
|
|
232
|
-
table: 'policy'
|
|
233
|
-
},
|
|
234
|
-
index: {
|
|
235
|
-
schema: 'metaschema_public',
|
|
236
|
-
table: 'index'
|
|
237
|
-
},
|
|
238
|
-
trigger: {
|
|
239
|
-
schema: 'metaschema_public',
|
|
240
|
-
table: 'trigger'
|
|
241
|
-
},
|
|
242
|
-
trigger_function: {
|
|
243
|
-
schema: 'metaschema_public',
|
|
244
|
-
table: 'trigger_function'
|
|
245
|
-
},
|
|
246
|
-
rls_function: {
|
|
247
|
-
schema: 'metaschema_public',
|
|
248
|
-
table: 'rls_function'
|
|
249
|
-
},
|
|
250
|
-
foreign_key_constraint: {
|
|
251
|
-
schema: 'metaschema_public',
|
|
252
|
-
table: 'foreign_key_constraint'
|
|
253
|
-
},
|
|
254
|
-
primary_key_constraint: {
|
|
255
|
-
schema: 'metaschema_public',
|
|
256
|
-
table: 'primary_key_constraint'
|
|
257
|
-
},
|
|
258
|
-
unique_constraint: {
|
|
259
|
-
schema: 'metaschema_public',
|
|
260
|
-
table: 'unique_constraint'
|
|
261
|
-
},
|
|
262
|
-
check_constraint: {
|
|
263
|
-
schema: 'metaschema_public',
|
|
264
|
-
table: 'check_constraint'
|
|
265
|
-
},
|
|
266
|
-
full_text_search: {
|
|
267
|
-
schema: 'metaschema_public',
|
|
268
|
-
table: 'full_text_search'
|
|
269
|
-
},
|
|
270
|
-
schema_grant: {
|
|
271
|
-
schema: 'metaschema_public',
|
|
272
|
-
table: 'schema_grant'
|
|
273
|
-
},
|
|
274
|
-
table_grant: {
|
|
275
|
-
schema: 'metaschema_public',
|
|
276
|
-
table: 'table_grant'
|
|
277
|
-
},
|
|
278
|
-
default_privilege: {
|
|
279
|
-
schema: 'metaschema_public',
|
|
280
|
-
table: 'default_privilege'
|
|
281
|
-
},
|
|
282
|
-
// =============================================================================
|
|
283
|
-
// services_public tables
|
|
284
|
-
// =============================================================================
|
|
285
|
-
domains: {
|
|
286
|
-
schema: 'services_public',
|
|
287
|
-
table: 'domains'
|
|
288
|
-
},
|
|
289
136
|
sites: {
|
|
290
|
-
schema: 'services_public',
|
|
291
|
-
table: 'sites',
|
|
292
137
|
typeOverrides: {
|
|
293
138
|
og_image: 'image',
|
|
294
139
|
favicon: 'upload',
|
|
@@ -300,326 +145,56 @@ exports.META_TABLE_CONFIG = {
|
|
|
300
145
|
}
|
|
301
146
|
},
|
|
302
147
|
apis: {
|
|
303
|
-
schema: 'services_public',
|
|
304
|
-
table: 'apis',
|
|
305
148
|
columnDefaults: {
|
|
306
149
|
dbname: 'current_database()'
|
|
307
150
|
}
|
|
308
151
|
},
|
|
309
152
|
apps: {
|
|
310
|
-
schema: 'services_public',
|
|
311
|
-
table: 'apps',
|
|
312
153
|
typeOverrides: {
|
|
313
154
|
app_image: 'image',
|
|
314
155
|
app_store_link: 'url',
|
|
315
156
|
play_store_link: 'url'
|
|
316
157
|
}
|
|
317
158
|
},
|
|
318
|
-
site_modules: {
|
|
319
|
-
schema: 'services_public',
|
|
320
|
-
table: 'site_modules'
|
|
321
|
-
},
|
|
322
|
-
site_themes: {
|
|
323
|
-
schema: 'services_public',
|
|
324
|
-
table: 'site_themes'
|
|
325
|
-
},
|
|
326
159
|
site_metadata: {
|
|
327
|
-
schema: 'services_public',
|
|
328
|
-
table: 'site_metadata',
|
|
329
160
|
typeOverrides: {
|
|
330
161
|
og_image: 'image'
|
|
331
162
|
}
|
|
332
163
|
},
|
|
333
|
-
api_modules: {
|
|
334
|
-
schema: 'services_public',
|
|
335
|
-
table: 'api_modules'
|
|
336
|
-
},
|
|
337
|
-
api_extensions: {
|
|
338
|
-
schema: 'services_public',
|
|
339
|
-
table: 'api_extensions'
|
|
340
|
-
},
|
|
341
|
-
api_schemas: {
|
|
342
|
-
schema: 'services_public',
|
|
343
|
-
table: 'api_schemas'
|
|
344
|
-
},
|
|
345
|
-
database_settings: {
|
|
346
|
-
schema: 'services_public',
|
|
347
|
-
table: 'database_settings'
|
|
348
|
-
},
|
|
349
|
-
api_settings: {
|
|
350
|
-
schema: 'services_public',
|
|
351
|
-
table: 'api_settings'
|
|
352
|
-
},
|
|
353
|
-
rls_settings: {
|
|
354
|
-
schema: 'services_public',
|
|
355
|
-
table: 'rls_settings'
|
|
356
|
-
},
|
|
357
|
-
cors_settings: {
|
|
358
|
-
schema: 'services_public',
|
|
359
|
-
table: 'cors_settings'
|
|
360
|
-
},
|
|
361
|
-
pubkey_settings: {
|
|
362
|
-
schema: 'services_public',
|
|
363
|
-
table: 'pubkey_settings'
|
|
364
|
-
},
|
|
365
|
-
webauthn_settings: {
|
|
366
|
-
schema: 'services_public',
|
|
367
|
-
table: 'webauthn_settings'
|
|
368
|
-
},
|
|
369
|
-
// =============================================================================
|
|
370
|
-
// metaschema_modules_public tables
|
|
371
|
-
// =============================================================================
|
|
372
|
-
rls_module: {
|
|
373
|
-
schema: 'metaschema_modules_public',
|
|
374
|
-
table: 'rls_module'
|
|
375
|
-
},
|
|
376
|
-
user_auth_module: {
|
|
377
|
-
schema: 'metaschema_modules_public',
|
|
378
|
-
table: 'user_auth_module'
|
|
379
|
-
},
|
|
380
|
-
memberships_module: {
|
|
381
|
-
schema: 'metaschema_modules_public',
|
|
382
|
-
table: 'memberships_module'
|
|
383
|
-
},
|
|
384
|
-
permissions_module: {
|
|
385
|
-
schema: 'metaschema_modules_public',
|
|
386
|
-
table: 'permissions_module'
|
|
387
|
-
},
|
|
388
|
-
limits_module: {
|
|
389
|
-
schema: 'metaschema_modules_public',
|
|
390
|
-
table: 'limits_module'
|
|
391
|
-
},
|
|
392
|
-
levels_module: {
|
|
393
|
-
schema: 'metaschema_modules_public',
|
|
394
|
-
table: 'levels_module'
|
|
395
|
-
},
|
|
396
|
-
events_module: {
|
|
397
|
-
schema: 'metaschema_modules_public',
|
|
398
|
-
table: 'events_module'
|
|
399
|
-
},
|
|
400
|
-
users_module: {
|
|
401
|
-
schema: 'metaschema_modules_public',
|
|
402
|
-
table: 'users_module'
|
|
403
|
-
},
|
|
404
|
-
hierarchy_module: {
|
|
405
|
-
schema: 'metaschema_modules_public',
|
|
406
|
-
table: 'hierarchy_module'
|
|
407
|
-
},
|
|
408
|
-
membership_types_module: {
|
|
409
|
-
schema: 'metaschema_modules_public',
|
|
410
|
-
table: 'membership_types_module'
|
|
411
|
-
},
|
|
412
|
-
invites_module: {
|
|
413
|
-
schema: 'metaschema_modules_public',
|
|
414
|
-
table: 'invites_module'
|
|
415
|
-
},
|
|
416
|
-
emails_module: {
|
|
417
|
-
schema: 'metaschema_modules_public',
|
|
418
|
-
table: 'emails_module'
|
|
419
|
-
},
|
|
420
|
-
sessions_module: {
|
|
421
|
-
schema: 'metaschema_modules_public',
|
|
422
|
-
table: 'sessions_module'
|
|
423
|
-
},
|
|
424
|
-
user_state_module: {
|
|
425
|
-
schema: 'metaschema_modules_public',
|
|
426
|
-
table: 'user_state_module'
|
|
427
|
-
},
|
|
428
|
-
profiles_module: {
|
|
429
|
-
schema: 'metaschema_modules_public',
|
|
430
|
-
table: 'profiles_module'
|
|
431
|
-
},
|
|
432
|
-
config_secrets_user_module: {
|
|
433
|
-
schema: 'metaschema_modules_public',
|
|
434
|
-
table: 'config_secrets_user_module'
|
|
435
|
-
},
|
|
436
|
-
user_credentials_module: {
|
|
437
|
-
schema: 'metaschema_modules_public',
|
|
438
|
-
table: 'user_credentials_module'
|
|
439
|
-
},
|
|
440
|
-
user_settings_module: {
|
|
441
|
-
schema: 'metaschema_modules_public',
|
|
442
|
-
table: 'user_settings_module'
|
|
443
|
-
},
|
|
444
|
-
connected_accounts_module: {
|
|
445
|
-
schema: 'metaschema_modules_public',
|
|
446
|
-
table: 'connected_accounts_module'
|
|
447
|
-
},
|
|
448
|
-
phone_numbers_module: {
|
|
449
|
-
schema: 'metaschema_modules_public',
|
|
450
|
-
table: 'phone_numbers_module'
|
|
451
|
-
},
|
|
452
|
-
crypto_addresses_module: {
|
|
453
|
-
schema: 'metaschema_modules_public',
|
|
454
|
-
table: 'crypto_addresses_module'
|
|
455
|
-
},
|
|
456
|
-
crypto_auth_module: {
|
|
457
|
-
schema: 'metaschema_modules_public',
|
|
458
|
-
table: 'crypto_auth_module'
|
|
459
|
-
},
|
|
460
|
-
field_module: {
|
|
461
|
-
schema: 'metaschema_modules_public',
|
|
462
|
-
table: 'field_module'
|
|
463
|
-
},
|
|
464
|
-
table_module: {
|
|
465
|
-
schema: 'metaschema_modules_public',
|
|
466
|
-
table: 'table_module'
|
|
467
|
-
},
|
|
468
|
-
// NOTE: table_template_module has been removed from pgpm-modules (superseded by blueprints)
|
|
469
|
-
secure_table_provision: {
|
|
470
|
-
schema: 'metaschema_modules_public',
|
|
471
|
-
table: 'secure_table_provision'
|
|
472
|
-
},
|
|
473
|
-
uuid_module: {
|
|
474
|
-
schema: 'metaschema_modules_public',
|
|
475
|
-
table: 'uuid_module'
|
|
476
|
-
},
|
|
477
|
-
default_ids_module: {
|
|
478
|
-
schema: 'metaschema_modules_public',
|
|
479
|
-
table: 'default_ids_module'
|
|
480
|
-
},
|
|
481
|
-
denormalized_table_field: {
|
|
482
|
-
schema: 'metaschema_modules_public',
|
|
483
|
-
table: 'denormalized_table_field'
|
|
484
|
-
},
|
|
485
|
-
relation_provision: {
|
|
486
|
-
schema: 'metaschema_modules_public',
|
|
487
|
-
table: 'relation_provision'
|
|
488
|
-
},
|
|
489
|
-
entity_type_provision: {
|
|
490
|
-
schema: 'metaschema_modules_public',
|
|
491
|
-
table: 'entity_type_provision'
|
|
492
|
-
},
|
|
493
|
-
rate_limits_module: {
|
|
494
|
-
schema: 'metaschema_modules_public',
|
|
495
|
-
table: 'rate_limits_module'
|
|
496
|
-
},
|
|
497
|
-
storage_module: {
|
|
498
|
-
schema: 'metaschema_modules_public',
|
|
499
|
-
table: 'storage_module'
|
|
500
|
-
},
|
|
501
|
-
billing_module: {
|
|
502
|
-
schema: 'metaschema_modules_public',
|
|
503
|
-
table: 'billing_module'
|
|
504
|
-
},
|
|
505
|
-
billing_provider_module: {
|
|
506
|
-
schema: 'metaschema_modules_public',
|
|
507
|
-
table: 'billing_provider_module'
|
|
508
|
-
},
|
|
509
|
-
devices_module: {
|
|
510
|
-
schema: 'metaschema_modules_public',
|
|
511
|
-
table: 'devices_module'
|
|
512
|
-
},
|
|
513
|
-
identity_providers_module: {
|
|
514
|
-
schema: 'metaschema_modules_public',
|
|
515
|
-
table: 'identity_providers_module'
|
|
516
|
-
},
|
|
517
|
-
integration_providers_module: {
|
|
518
|
-
schema: 'metaschema_modules_public',
|
|
519
|
-
table: 'integration_providers_module'
|
|
520
|
-
},
|
|
521
|
-
notifications_module: {
|
|
522
|
-
schema: 'metaschema_modules_public',
|
|
523
|
-
table: 'notifications_module'
|
|
524
|
-
},
|
|
525
|
-
plans_module: {
|
|
526
|
-
schema: 'metaschema_modules_public',
|
|
527
|
-
table: 'plans_module'
|
|
528
|
-
},
|
|
529
|
-
realtime_module: {
|
|
530
|
-
schema: 'metaschema_modules_public',
|
|
531
|
-
table: 'realtime_module'
|
|
532
|
-
},
|
|
533
|
-
session_secrets_module: {
|
|
534
|
-
schema: 'metaschema_modules_public',
|
|
535
|
-
table: 'session_secrets_module'
|
|
536
|
-
},
|
|
537
|
-
infra_secrets_module: {
|
|
538
|
-
schema: 'metaschema_modules_public',
|
|
539
|
-
table: 'infra_secrets_module'
|
|
540
|
-
},
|
|
541
|
-
infra_config_module: {
|
|
542
|
-
schema: 'metaschema_modules_public',
|
|
543
|
-
table: 'infra_config_module'
|
|
544
|
-
},
|
|
545
|
-
internal_secrets_module: {
|
|
546
|
-
schema: 'metaschema_modules_public',
|
|
547
|
-
table: 'internal_secrets_module'
|
|
548
|
-
},
|
|
549
164
|
i18n_module: {
|
|
550
|
-
schema: 'metaschema_modules_public',
|
|
551
|
-
table: 'i18n_module',
|
|
552
165
|
gqlTypeName: 'I18NModule' // i18n is a well-known abbreviation; PostGraphile inflector capitalizes the N
|
|
553
|
-
},
|
|
554
|
-
agent_module: {
|
|
555
|
-
schema: 'metaschema_modules_public',
|
|
556
|
-
table: 'agent_module'
|
|
557
|
-
},
|
|
558
|
-
function_module: {
|
|
559
|
-
schema: 'metaschema_modules_public',
|
|
560
|
-
table: 'function_module'
|
|
561
|
-
},
|
|
562
|
-
namespace_module: {
|
|
563
|
-
schema: 'metaschema_modules_public',
|
|
564
|
-
table: 'namespace_module'
|
|
565
|
-
},
|
|
566
|
-
merkle_store_module: {
|
|
567
|
-
schema: 'metaschema_modules_public',
|
|
568
|
-
table: 'merkle_store_module'
|
|
569
|
-
},
|
|
570
|
-
graph_module: {
|
|
571
|
-
schema: 'metaschema_modules_public',
|
|
572
|
-
table: 'graph_module'
|
|
573
|
-
},
|
|
574
|
-
graph_execution_module: {
|
|
575
|
-
schema: 'metaschema_modules_public',
|
|
576
|
-
table: 'graph_execution_module'
|
|
577
|
-
},
|
|
578
|
-
function_deployment_module: {
|
|
579
|
-
schema: 'metaschema_modules_public',
|
|
580
|
-
table: 'function_deployment_module'
|
|
581
|
-
},
|
|
582
|
-
function_invocation_module: {
|
|
583
|
-
schema: 'metaschema_modules_public',
|
|
584
|
-
table: 'function_invocation_module'
|
|
585
|
-
},
|
|
586
|
-
compute_log_module: {
|
|
587
|
-
schema: 'metaschema_modules_public',
|
|
588
|
-
table: 'compute_log_module'
|
|
589
|
-
},
|
|
590
|
-
db_usage_module: {
|
|
591
|
-
schema: 'metaschema_modules_public',
|
|
592
|
-
table: 'db_usage_module'
|
|
593
|
-
},
|
|
594
|
-
storage_log_module: {
|
|
595
|
-
schema: 'metaschema_modules_public',
|
|
596
|
-
table: 'storage_log_module'
|
|
597
|
-
},
|
|
598
|
-
transfer_log_module: {
|
|
599
|
-
schema: 'metaschema_modules_public',
|
|
600
|
-
table: 'transfer_log_module'
|
|
601
|
-
},
|
|
602
|
-
webauthn_auth_module: {
|
|
603
|
-
schema: 'metaschema_modules_public',
|
|
604
|
-
table: 'webauthn_auth_module'
|
|
605
|
-
},
|
|
606
|
-
webauthn_credentials_module: {
|
|
607
|
-
schema: 'metaschema_modules_public',
|
|
608
|
-
table: 'webauthn_credentials_module'
|
|
609
|
-
},
|
|
610
|
-
inference_log_module: {
|
|
611
|
-
schema: 'metaschema_modules_public',
|
|
612
|
-
table: 'inference_log_module',
|
|
613
|
-
},
|
|
614
|
-
rate_limit_meters_module: {
|
|
615
|
-
schema: 'metaschema_modules_public',
|
|
616
|
-
table: 'rate_limit_meters_module',
|
|
617
|
-
},
|
|
618
|
-
spatial_relation: {
|
|
619
|
-
schema: 'metaschema_public',
|
|
620
|
-
table: 'spatial_relation'
|
|
621
166
|
}
|
|
622
167
|
};
|
|
168
|
+
/**
|
|
169
|
+
* Ordered list of meta tables for export, derived from the generated
|
|
170
|
+
* manifest. Tables are already topologically sorted by foreign key
|
|
171
|
+
* dependencies at generation time.
|
|
172
|
+
*/
|
|
173
|
+
exports.META_TABLE_ORDER = meta_export_tables_json_1.default.tables.map(t => t.key);
|
|
174
|
+
/**
|
|
175
|
+
* Shared metadata table configuration, built from the generated manifest
|
|
176
|
+
* plus META_TABLE_OVERRIDES.
|
|
177
|
+
*
|
|
178
|
+
* Fields are discovered dynamically at runtime via introspection:
|
|
179
|
+
* - SQL flow: uses information_schema.columns + mapPgTypeToFieldType()
|
|
180
|
+
* - GraphQL flow: uses __type introspection + mapGraphQLTypeToFieldType()
|
|
181
|
+
*
|
|
182
|
+
* Only `typeOverrides` are hardcoded for special types (image, upload, url)
|
|
183
|
+
* that cannot be inferred from database/GraphQL types alone.
|
|
184
|
+
*/
|
|
185
|
+
exports.META_TABLE_CONFIG = Object.fromEntries(meta_export_tables_json_1.default.tables.map(t => [
|
|
186
|
+
t.key,
|
|
187
|
+
{ schema: t.schema, table: t.table, ...exports.META_TABLE_OVERRIDES[t.key] }
|
|
188
|
+
]));
|
|
189
|
+
/**
|
|
190
|
+
* Per-table timestamptz columns whose DDL default is non-deterministic
|
|
191
|
+
* (now(), CURRENT_TIMESTAMP, clock_timestamp(), now() + interval).
|
|
192
|
+
* Generated by constructive-db and propagated here via constructive-hub.
|
|
193
|
+
* The GraphQL export path uses this to omit those columns without a DB pool.
|
|
194
|
+
*/
|
|
195
|
+
exports.META_TABLE_TIMESTAMP_DEFAULTS = meta_export_tables_json_1.default.timestampDefaultColumns || {};
|
|
196
|
+
const getTimestampDefaultColumnsForTable = (schema, table) => exports.META_TABLE_TIMESTAMP_DEFAULTS[`${schema}.${table}`] || [];
|
|
197
|
+
exports.getTimestampDefaultColumnsForTable = getTimestampDefaultColumnsForTable;
|
|
623
198
|
// =============================================================================
|
|
624
199
|
// Shared functions
|
|
625
200
|
// =============================================================================
|
package/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from './export-graphql';
|
|
|
4
4
|
export * from './export-graphql-meta';
|
|
5
5
|
export { GraphQLClient } from './graphql-client';
|
|
6
6
|
export { getGraphQLQueryName, getGraphQLTypeName, graphqlRowToPostgresRow, buildFieldsFragment, mapGraphQLTypeToFieldType, unwrapGraphQLType, GraphQLTypeInfo } from './graphql-naming';
|
|
7
|
-
export { DB_REQUIRED_EXTENSIONS, SERVICE_REQUIRED_EXTENSIONS, META_COMMON_HEADER, META_COMMON_FOOTER, META_TABLE_ORDER, META_TABLE_CONFIG, mapPgTypeToFieldType, makeReplacer, preparePackage, normalizeOutdir, detectMissingModules, installMissingModules } from './export-utils';
|
|
8
|
-
export type { FieldType, TableConfig, Schema, MakeReplacerOptions, ReplacerResult, PreparePackageOptions, MissingModulesResult } from './export-utils';
|
|
7
|
+
export { DB_REQUIRED_EXTENSIONS, SERVICE_REQUIRED_EXTENSIONS, META_COMMON_HEADER, META_COMMON_FOOTER, META_TABLE_ORDER, META_TABLE_CONFIG, META_TABLE_OVERRIDES, mapPgTypeToFieldType, makeReplacer, preparePackage, normalizeOutdir, detectMissingModules, installMissingModules } from './export-utils';
|
|
8
|
+
export type { FieldType, TableConfig, MetaExportTableEntry, Schema, MakeReplacerOptions, ReplacerResult, PreparePackageOptions, MissingModulesResult } from './export-utils';
|
|
9
9
|
export { PG_TYPE_MAP, TypeMapEntry, lookupByPgUdt, lookupByGqlType } from './type-map';
|
|
10
10
|
export { intervalToPostgres, parsePgInterval, PgInterval } from './interval-utils';
|
package/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.parsePgInterval = exports.intervalToPostgres = exports.lookupByGqlType = exports.lookupByPgUdt = exports.PG_TYPE_MAP = exports.installMissingModules = exports.detectMissingModules = exports.normalizeOutdir = exports.preparePackage = exports.makeReplacer = exports.mapPgTypeToFieldType = exports.META_TABLE_CONFIG = exports.META_TABLE_ORDER = exports.META_COMMON_FOOTER = exports.META_COMMON_HEADER = exports.SERVICE_REQUIRED_EXTENSIONS = exports.DB_REQUIRED_EXTENSIONS = exports.unwrapGraphQLType = exports.mapGraphQLTypeToFieldType = exports.buildFieldsFragment = exports.graphqlRowToPostgresRow = exports.getGraphQLTypeName = exports.getGraphQLQueryName = exports.GraphQLClient = void 0;
|
|
17
|
+
exports.parsePgInterval = exports.intervalToPostgres = exports.lookupByGqlType = exports.lookupByPgUdt = exports.PG_TYPE_MAP = exports.installMissingModules = exports.detectMissingModules = exports.normalizeOutdir = exports.preparePackage = exports.makeReplacer = exports.mapPgTypeToFieldType = exports.META_TABLE_OVERRIDES = exports.META_TABLE_CONFIG = exports.META_TABLE_ORDER = exports.META_COMMON_FOOTER = exports.META_COMMON_HEADER = exports.SERVICE_REQUIRED_EXTENSIONS = exports.DB_REQUIRED_EXTENSIONS = exports.unwrapGraphQLType = exports.mapGraphQLTypeToFieldType = exports.buildFieldsFragment = exports.graphqlRowToPostgresRow = exports.getGraphQLTypeName = exports.getGraphQLQueryName = exports.GraphQLClient = void 0;
|
|
18
18
|
__exportStar(require("./export-meta"), exports);
|
|
19
19
|
__exportStar(require("./export-migrations"), exports);
|
|
20
20
|
__exportStar(require("./export-graphql"), exports);
|
|
@@ -35,6 +35,7 @@ Object.defineProperty(exports, "META_COMMON_HEADER", { enumerable: true, get: fu
|
|
|
35
35
|
Object.defineProperty(exports, "META_COMMON_FOOTER", { enumerable: true, get: function () { return export_utils_1.META_COMMON_FOOTER; } });
|
|
36
36
|
Object.defineProperty(exports, "META_TABLE_ORDER", { enumerable: true, get: function () { return export_utils_1.META_TABLE_ORDER; } });
|
|
37
37
|
Object.defineProperty(exports, "META_TABLE_CONFIG", { enumerable: true, get: function () { return export_utils_1.META_TABLE_CONFIG; } });
|
|
38
|
+
Object.defineProperty(exports, "META_TABLE_OVERRIDES", { enumerable: true, get: function () { return export_utils_1.META_TABLE_OVERRIDES; } });
|
|
38
39
|
Object.defineProperty(exports, "mapPgTypeToFieldType", { enumerable: true, get: function () { return export_utils_1.mapPgTypeToFieldType; } });
|
|
39
40
|
Object.defineProperty(exports, "makeReplacer", { enumerable: true, get: function () { return export_utils_1.makeReplacer; } });
|
|
40
41
|
Object.defineProperty(exports, "preparePackage", { enumerable: true, get: function () { return export_utils_1.preparePackage; } });
|