@pgpmjs/export 0.27.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/export-graphql-meta.js +13 -106
- package/esm/export-meta.js +9 -106
- package/esm/export-utils.js +28 -496
- package/esm/index.js +1 -1
- package/esm/meta-export-tables.json +505 -0
- package/export-graphql-meta.js +12 -105
- package/export-meta.js +8 -105
- package/export-utils.d.ts +26 -7
- package/export-utils.js +29 -497
- package/index.d.ts +2 -2
- package/index.js +2 -1
- package/meta-export-tables.json +505 -0
- package/package.json +2 -2
package/export-meta.js
CHANGED
|
@@ -140,111 +140,14 @@ const exportMeta = async ({ opts, dbname, database_id }) => {
|
|
|
140
140
|
throw err;
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
await queryAndParse('field', `SELECT * FROM metaschema_public.field WHERE database_id = $1 ORDER BY id`);
|
|
152
|
-
await queryAndParse('policy', `SELECT * FROM metaschema_public.policy WHERE database_id = $1 ORDER BY id`);
|
|
153
|
-
await queryAndParse('index', `SELECT * FROM metaschema_public.index WHERE database_id = $1 ORDER BY id`);
|
|
154
|
-
await queryAndParse('trigger', `SELECT * FROM metaschema_public.trigger WHERE database_id = $1 ORDER BY id`);
|
|
155
|
-
await queryAndParse('trigger_function', `SELECT * FROM metaschema_public.trigger_function WHERE database_id = $1 ORDER BY id`);
|
|
156
|
-
await queryAndParse('rls_function', `SELECT * FROM metaschema_public.rls_function WHERE database_id = $1 ORDER BY id`);
|
|
157
|
-
await queryAndParse('foreign_key_constraint', `SELECT * FROM metaschema_public.foreign_key_constraint WHERE database_id = $1 ORDER BY id`);
|
|
158
|
-
await queryAndParse('primary_key_constraint', `SELECT * FROM metaschema_public.primary_key_constraint WHERE database_id = $1 ORDER BY id`);
|
|
159
|
-
await queryAndParse('unique_constraint', `SELECT * FROM metaschema_public.unique_constraint WHERE database_id = $1 ORDER BY id`);
|
|
160
|
-
await queryAndParse('check_constraint', `SELECT * FROM metaschema_public.check_constraint WHERE database_id = $1 ORDER BY id`);
|
|
161
|
-
await queryAndParse('full_text_search', `SELECT * FROM metaschema_public.full_text_search WHERE database_id = $1 ORDER BY id`);
|
|
162
|
-
await queryAndParse('schema_grant', `SELECT * FROM metaschema_public.schema_grant WHERE database_id = $1 ORDER BY id`);
|
|
163
|
-
await queryAndParse('table_grant', `SELECT * FROM metaschema_public.table_grant WHERE database_id = $1 ORDER BY id`);
|
|
164
|
-
await queryAndParse('default_privilege', `SELECT * FROM metaschema_public.default_privilege WHERE database_id = $1 ORDER BY id`);
|
|
165
|
-
// =============================================================================
|
|
166
|
-
// services_public tables
|
|
167
|
-
// =============================================================================
|
|
168
|
-
await queryAndParse('domains', `SELECT * FROM services_public.domains WHERE database_id = $1 ORDER BY id`);
|
|
169
|
-
await queryAndParse('sites', `SELECT * FROM services_public.sites WHERE database_id = $1 ORDER BY id`);
|
|
170
|
-
await queryAndParse('apis', `SELECT * FROM services_public.apis WHERE database_id = $1 ORDER BY id`);
|
|
171
|
-
await queryAndParse('apps', `SELECT * FROM services_public.apps WHERE database_id = $1 ORDER BY id`);
|
|
172
|
-
await queryAndParse('site_modules', `SELECT * FROM services_public.site_modules WHERE database_id = $1 ORDER BY id`);
|
|
173
|
-
await queryAndParse('site_themes', `SELECT * FROM services_public.site_themes WHERE database_id = $1 ORDER BY id`);
|
|
174
|
-
await queryAndParse('site_metadata', `SELECT * FROM services_public.site_metadata WHERE database_id = $1 ORDER BY id`);
|
|
175
|
-
await queryAndParse('api_modules', `SELECT * FROM services_public.api_modules WHERE database_id = $1 ORDER BY id`);
|
|
176
|
-
await queryAndParse('api_extensions', `SELECT * FROM services_public.api_extensions WHERE database_id = $1 ORDER BY id`);
|
|
177
|
-
await queryAndParse('api_schemas', `SELECT * FROM services_public.api_schemas WHERE database_id = $1 ORDER BY id`);
|
|
178
|
-
await queryAndParse('database_settings', `SELECT * FROM services_public.database_settings WHERE database_id = $1 ORDER BY id`);
|
|
179
|
-
await queryAndParse('api_settings', `SELECT * FROM services_public.api_settings WHERE database_id = $1 ORDER BY id`);
|
|
180
|
-
await queryAndParse('rls_settings', `SELECT * FROM services_public.rls_settings WHERE database_id = $1 ORDER BY id`);
|
|
181
|
-
await queryAndParse('cors_settings', `SELECT * FROM services_public.cors_settings WHERE database_id = $1 ORDER BY id`);
|
|
182
|
-
await queryAndParse('pubkey_settings', `SELECT * FROM services_public.pubkey_settings WHERE database_id = $1 ORDER BY id`);
|
|
183
|
-
await queryAndParse('webauthn_settings', `SELECT * FROM services_public.webauthn_settings WHERE database_id = $1 ORDER BY id`);
|
|
184
|
-
// =============================================================================
|
|
185
|
-
// metaschema_modules_public tables
|
|
186
|
-
// =============================================================================
|
|
187
|
-
await queryAndParse('rls_module', `SELECT * FROM metaschema_modules_public.rls_module WHERE database_id = $1 ORDER BY id`);
|
|
188
|
-
await queryAndParse('user_auth_module', `SELECT * FROM metaschema_modules_public.user_auth_module WHERE database_id = $1 ORDER BY id`);
|
|
189
|
-
await queryAndParse('memberships_module', `SELECT * FROM metaschema_modules_public.memberships_module WHERE database_id = $1 ORDER BY id`);
|
|
190
|
-
await queryAndParse('permissions_module', `SELECT * FROM metaschema_modules_public.permissions_module WHERE database_id = $1 ORDER BY id`);
|
|
191
|
-
await queryAndParse('limits_module', `SELECT * FROM metaschema_modules_public.limits_module WHERE database_id = $1 ORDER BY id`);
|
|
192
|
-
await queryAndParse('levels_module', `SELECT * FROM metaschema_modules_public.levels_module WHERE database_id = $1 ORDER BY id`);
|
|
193
|
-
await queryAndParse('events_module', `SELECT * FROM metaschema_modules_public.events_module WHERE database_id = $1 ORDER BY id`);
|
|
194
|
-
await queryAndParse('users_module', `SELECT * FROM metaschema_modules_public.users_module WHERE database_id = $1 ORDER BY id`);
|
|
195
|
-
await queryAndParse('hierarchy_module', `SELECT * FROM metaschema_modules_public.hierarchy_module WHERE database_id = $1 ORDER BY id`);
|
|
196
|
-
await queryAndParse('membership_types_module', `SELECT * FROM metaschema_modules_public.membership_types_module WHERE database_id = $1 ORDER BY id`);
|
|
197
|
-
await queryAndParse('invites_module', `SELECT * FROM metaschema_modules_public.invites_module WHERE database_id = $1 ORDER BY id`);
|
|
198
|
-
await queryAndParse('emails_module', `SELECT * FROM metaschema_modules_public.emails_module WHERE database_id = $1 ORDER BY id`);
|
|
199
|
-
await queryAndParse('sessions_module', `SELECT * FROM metaschema_modules_public.sessions_module WHERE database_id = $1 ORDER BY id`);
|
|
200
|
-
await queryAndParse('user_state_module', `SELECT * FROM metaschema_modules_public.user_state_module WHERE database_id = $1 ORDER BY id`);
|
|
201
|
-
await queryAndParse('profiles_module', `SELECT * FROM metaschema_modules_public.profiles_module WHERE database_id = $1 ORDER BY id`);
|
|
202
|
-
await queryAndParse('config_secrets_user_module', `SELECT * FROM metaschema_modules_public.config_secrets_user_module WHERE database_id = $1 ORDER BY id`);
|
|
203
|
-
await queryAndParse('user_credentials_module', `SELECT * FROM metaschema_modules_public.user_credentials_module WHERE database_id = $1 ORDER BY id`);
|
|
204
|
-
await queryAndParse('user_settings_module', `SELECT * FROM metaschema_modules_public.user_settings_module WHERE database_id = $1 ORDER BY id`);
|
|
205
|
-
await queryAndParse('connected_accounts_module', `SELECT * FROM metaschema_modules_public.connected_accounts_module WHERE database_id = $1 ORDER BY id`);
|
|
206
|
-
await queryAndParse('phone_numbers_module', `SELECT * FROM metaschema_modules_public.phone_numbers_module WHERE database_id = $1 ORDER BY id`);
|
|
207
|
-
await queryAndParse('crypto_addresses_module', `SELECT * FROM metaschema_modules_public.crypto_addresses_module WHERE database_id = $1 ORDER BY id`);
|
|
208
|
-
await queryAndParse('crypto_auth_module', `SELECT * FROM metaschema_modules_public.crypto_auth_module WHERE database_id = $1 ORDER BY id`);
|
|
209
|
-
await queryAndParse('field_module', `SELECT * FROM metaschema_modules_public.field_module WHERE database_id = $1 ORDER BY id`);
|
|
210
|
-
await queryAndParse('table_module', `SELECT * FROM metaschema_modules_public.table_module WHERE database_id = $1 ORDER BY id`);
|
|
211
|
-
await queryAndParse('secure_table_provision', `SELECT * FROM metaschema_modules_public.secure_table_provision WHERE database_id = $1 ORDER BY id`);
|
|
212
|
-
await queryAndParse('uuid_module', `SELECT * FROM metaschema_modules_public.uuid_module WHERE database_id = $1 ORDER BY id`);
|
|
213
|
-
await queryAndParse('default_ids_module', `SELECT * FROM metaschema_modules_public.default_ids_module WHERE database_id = $1 ORDER BY id`);
|
|
214
|
-
await queryAndParse('denormalized_table_field', `SELECT * FROM metaschema_modules_public.denormalized_table_field WHERE database_id = $1 ORDER BY id`);
|
|
215
|
-
await queryAndParse('relation_provision', `SELECT * FROM metaschema_modules_public.relation_provision WHERE database_id = $1 ORDER BY id`);
|
|
216
|
-
await queryAndParse('entity_type_provision', `SELECT * FROM metaschema_modules_public.entity_type_provision WHERE database_id = $1 ORDER BY id`);
|
|
217
|
-
await queryAndParse('rate_limits_module', `SELECT * FROM metaschema_modules_public.rate_limits_module WHERE database_id = $1 ORDER BY id`);
|
|
218
|
-
await queryAndParse('storage_module', `SELECT * FROM metaschema_modules_public.storage_module WHERE database_id = $1 ORDER BY id`);
|
|
219
|
-
await queryAndParse('billing_module', `SELECT * FROM metaschema_modules_public.billing_module WHERE database_id = $1 ORDER BY id`);
|
|
220
|
-
await queryAndParse('billing_provider_module', `SELECT * FROM metaschema_modules_public.billing_provider_module WHERE database_id = $1 ORDER BY id`);
|
|
221
|
-
await queryAndParse('devices_module', `SELECT * FROM metaschema_modules_public.devices_module WHERE database_id = $1 ORDER BY id`);
|
|
222
|
-
await queryAndParse('identity_providers_module', `SELECT * FROM metaschema_modules_public.identity_providers_module WHERE database_id = $1 ORDER BY id`);
|
|
223
|
-
await queryAndParse('integration_providers_module', `SELECT * FROM metaschema_modules_public.integration_providers_module WHERE database_id = $1 ORDER BY id`);
|
|
224
|
-
await queryAndParse('notifications_module', `SELECT * FROM metaschema_modules_public.notifications_module WHERE database_id = $1 ORDER BY id`);
|
|
225
|
-
await queryAndParse('plans_module', `SELECT * FROM metaschema_modules_public.plans_module WHERE database_id = $1 ORDER BY id`);
|
|
226
|
-
await queryAndParse('realtime_module', `SELECT * FROM metaschema_modules_public.realtime_module WHERE database_id = $1 ORDER BY id`);
|
|
227
|
-
await queryAndParse('session_secrets_module', `SELECT * FROM metaschema_modules_public.session_secrets_module WHERE database_id = $1 ORDER BY id`);
|
|
228
|
-
await queryAndParse('infra_secrets_module', `SELECT * FROM metaschema_modules_public.infra_secrets_module WHERE database_id = $1 ORDER BY id`);
|
|
229
|
-
await queryAndParse('infra_config_module', `SELECT * FROM metaschema_modules_public.infra_config_module WHERE database_id = $1 ORDER BY id`);
|
|
230
|
-
await queryAndParse('internal_secrets_module', `SELECT * FROM metaschema_modules_public.internal_secrets_module WHERE database_id = $1 ORDER BY id`);
|
|
231
|
-
await queryAndParse('i18n_module', `SELECT * FROM metaschema_modules_public.i18n_module WHERE database_id = $1 ORDER BY id`);
|
|
232
|
-
await queryAndParse('agent_module', `SELECT * FROM metaschema_modules_public.agent_module WHERE database_id = $1 ORDER BY id`);
|
|
233
|
-
await queryAndParse('function_module', `SELECT * FROM metaschema_modules_public.function_module WHERE database_id = $1 ORDER BY id`);
|
|
234
|
-
await queryAndParse('namespace_module', `SELECT * FROM metaschema_modules_public.namespace_module WHERE database_id = $1 ORDER BY id`);
|
|
235
|
-
await queryAndParse('merkle_store_module', `SELECT * FROM metaschema_modules_public.merkle_store_module WHERE database_id = $1 ORDER BY id`);
|
|
236
|
-
await queryAndParse('graph_module', `SELECT * FROM metaschema_modules_public.graph_module WHERE database_id = $1 ORDER BY id`);
|
|
237
|
-
await queryAndParse('graph_execution_module', `SELECT * FROM metaschema_modules_public.graph_execution_module WHERE database_id = $1 ORDER BY id`);
|
|
238
|
-
await queryAndParse('function_deployment_module', `SELECT * FROM metaschema_modules_public.function_deployment_module WHERE database_id = $1 ORDER BY id`);
|
|
239
|
-
await queryAndParse('function_invocation_module', `SELECT * FROM metaschema_modules_public.function_invocation_module WHERE database_id = $1 ORDER BY id`);
|
|
240
|
-
await queryAndParse('compute_log_module', `SELECT * FROM metaschema_modules_public.compute_log_module WHERE database_id = $1 ORDER BY id`);
|
|
241
|
-
await queryAndParse('db_usage_module', `SELECT * FROM metaschema_modules_public.db_usage_module WHERE database_id = $1 ORDER BY id`);
|
|
242
|
-
await queryAndParse('storage_log_module', `SELECT * FROM metaschema_modules_public.storage_log_module WHERE database_id = $1 ORDER BY id`);
|
|
243
|
-
await queryAndParse('transfer_log_module', `SELECT * FROM metaschema_modules_public.transfer_log_module WHERE database_id = $1 ORDER BY id`);
|
|
244
|
-
await queryAndParse('webauthn_auth_module', `SELECT * FROM metaschema_modules_public.webauthn_auth_module WHERE database_id = $1 ORDER BY id`);
|
|
245
|
-
await queryAndParse('webauthn_credentials_module', `SELECT * FROM metaschema_modules_public.webauthn_credentials_module WHERE database_id = $1 ORDER BY id`);
|
|
246
|
-
await queryAndParse('inference_log_module', `SELECT * FROM metaschema_modules_public.inference_log_module WHERE database_id = $1 ORDER BY id`);
|
|
247
|
-
await queryAndParse('rate_limit_meters_module', `SELECT * FROM metaschema_modules_public.rate_limit_meters_module WHERE database_id = $1 ORDER BY id`);
|
|
143
|
+
// Iterate the generated table manifest (already topologically sorted by FK
|
|
144
|
+
// dependencies). All tables are keyed by database_id except `database`
|
|
145
|
+
// itself, which is keyed by id.
|
|
146
|
+
for (const key of export_utils_1.META_TABLE_ORDER) {
|
|
147
|
+
const tableConfig = export_utils_1.META_TABLE_CONFIG[key];
|
|
148
|
+
const filterColumn = key === 'database' ? 'id' : 'database_id';
|
|
149
|
+
await queryAndParse(key, `SELECT * FROM ${tableConfig.schema}.${tableConfig.table} WHERE ${filterColumn} = $1 ORDER BY id`);
|
|
150
|
+
}
|
|
248
151
|
return sql;
|
|
249
152
|
};
|
|
250
153
|
exports.exportMeta = exportMeta;
|
package/export-utils.d.ts
CHANGED
|
@@ -25,11 +25,6 @@ export declare const META_COMMON_HEADER = "SET session_replication_role TO repli
|
|
|
25
25
|
* Common SQL footer for meta export files.
|
|
26
26
|
*/
|
|
27
27
|
export declare const META_COMMON_FOOTER = "\nSET session_replication_role TO DEFAULT;";
|
|
28
|
-
/**
|
|
29
|
-
* Ordered list of meta tables for export.
|
|
30
|
-
* Tables are processed in this order to satisfy foreign key dependencies.
|
|
31
|
-
*/
|
|
32
|
-
export declare const META_TABLE_ORDER: readonly ["database", "schema", "function", "table", "field", "spatial_relation", "policy", "index", "trigger", "trigger_function", "rls_function", "foreign_key_constraint", "primary_key_constraint", "unique_constraint", "check_constraint", "full_text_search", "schema_grant", "table_grant", "default_privilege", "domains", "sites", "apis", "apps", "site_modules", "site_themes", "site_metadata", "api_modules", "api_extensions", "api_schemas", "database_settings", "api_settings", "rls_settings", "cors_settings", "pubkey_settings", "webauthn_settings", "rls_module", "user_auth_module", "memberships_module", "permissions_module", "limits_module", "levels_module", "events_module", "users_module", "hierarchy_module", "membership_types_module", "invites_module", "emails_module", "sessions_module", "user_state_module", "profiles_module", "config_secrets_user_module", "user_credentials_module", "user_settings_module", "connected_accounts_module", "phone_numbers_module", "crypto_addresses_module", "crypto_auth_module", "field_module", "table_module", "secure_table_provision", "uuid_module", "default_ids_module", "denormalized_table_field", "relation_provision", "entity_type_provision", "rate_limits_module", "storage_module", "billing_module", "billing_provider_module", "devices_module", "identity_providers_module", "integration_providers_module", "notifications_module", "plans_module", "realtime_module", "session_secrets_module", "infra_secrets_module", "infra_config_module", "internal_secrets_module", "i18n_module", "agent_module", "function_module", "namespace_module", "merkle_store_module", "graph_module", "graph_execution_module", "function_deployment_module", "function_invocation_module", "compute_log_module", "db_usage_module", "storage_log_module", "transfer_log_module", "webauthn_auth_module", "webauthn_credentials_module", "inference_log_module", "rate_limit_meters_module"];
|
|
33
28
|
export type FieldType = 'uuid' | 'uuid[]' | 'text' | 'text[]' | 'boolean' | 'image' | 'upload' | 'url' | 'jsonb' | 'jsonb[]' | 'int' | 'interval' | 'timestamptz';
|
|
34
29
|
export interface TableConfig {
|
|
35
30
|
schema: string;
|
|
@@ -45,7 +40,32 @@ export interface TableConfig {
|
|
|
45
40
|
columnDefaults?: Record<string, string>;
|
|
46
41
|
}
|
|
47
42
|
/**
|
|
48
|
-
*
|
|
43
|
+
* A single entry in the generated meta export table manifest
|
|
44
|
+
* (meta-export-tables.json, generated by constructive-db and propagated
|
|
45
|
+
* here via constructive-hub's schema-propagation workflow).
|
|
46
|
+
*/
|
|
47
|
+
export interface MetaExportTableEntry {
|
|
48
|
+
key: string;
|
|
49
|
+
schema: string;
|
|
50
|
+
table: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Hand-authored per-table overrides layered on top of the generated
|
|
54
|
+
* table manifest. Only exceptional exporter behavior lives here:
|
|
55
|
+
* conflict handling, special field types (image, upload, url) that
|
|
56
|
+
* cannot be inferred, GraphQL type name overrides, and columns whose
|
|
57
|
+
* values must come from DDL defaults at deploy time.
|
|
58
|
+
*/
|
|
59
|
+
export declare const META_TABLE_OVERRIDES: Record<string, Omit<TableConfig, 'schema' | 'table'>>;
|
|
60
|
+
/**
|
|
61
|
+
* Ordered list of meta tables for export, derived from the generated
|
|
62
|
+
* manifest. Tables are already topologically sorted by foreign key
|
|
63
|
+
* dependencies at generation time.
|
|
64
|
+
*/
|
|
65
|
+
export declare const META_TABLE_ORDER: string[];
|
|
66
|
+
/**
|
|
67
|
+
* Shared metadata table configuration, built from the generated manifest
|
|
68
|
+
* plus META_TABLE_OVERRIDES.
|
|
49
69
|
*
|
|
50
70
|
* Fields are discovered dynamically at runtime via introspection:
|
|
51
71
|
* - SQL flow: uses information_schema.columns + mapPgTypeToFieldType()
|
|
@@ -53,7 +73,6 @@ export interface TableConfig {
|
|
|
53
73
|
*
|
|
54
74
|
* Only `typeOverrides` are hardcoded for special types (image, upload, url)
|
|
55
75
|
* that cannot be inferred from database/GraphQL types alone.
|
|
56
|
-
*
|
|
57
76
|
*/
|
|
58
77
|
export declare const META_TABLE_CONFIG: Record<string, TableConfig>;
|
|
59
78
|
export interface Schema {
|