@pgpmjs/export 1.1.1 → 1.2.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/README.md CHANGED
@@ -20,6 +20,13 @@ Export tools for extracting database migrations from existing PostgreSQL databas
20
20
  - **GraphQL Export** — Extract migrations via a PostGraphile GraphQL endpoint
21
21
  - **Cross-flow parity** — Both flows produce identical output for the same source data
22
22
  - **Metadata export** — Export metaschema, services, and module metadata tables
23
+ - **Table-data export** — Generic deterministic row-data dumps (`exportTablesData`,
24
+ `buildDataDeployScript` / `buildDataRevertScript` / `buildDataVerifyScript`): one
25
+ INSERT per table in stable order, volatile-default columns excluded via pg_catalog
26
+ volatility (no regex on default text), replayed under
27
+ `session_replication_role = replica`, with ID-precise reverts and divide-by-zero
28
+ verify checks. These scripts are the data/fixtures parts a `@pgpmjs/bundle`
29
+ envelope ships. All SQL is emitted through `@constructive-io/query-builder`.
23
30
 
24
31
  ## Usage
25
32
 
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * GraphQL equivalent of export-meta.ts.
3
3
  *
4
- * Fetches metadata from metaschema_public, services_public, and metaschema_modules_public
4
+ * Fetches metadata from metaschema_public, constructive_routing_public,
5
+ * constructive_apps_public, and metaschema_modules_public
5
6
  * via GraphQL queries instead of direct SQL, then uses the same csv-to-pg Parser to
6
7
  * generate SQL INSERT statements.
7
8
  */
@@ -103,6 +104,13 @@ export const exportGraphQLMeta = async ({ client, database_id }) => {
103
104
  const tableConfig = META_TABLE_CONFIG[key];
104
105
  if (!tableConfig)
105
106
  return;
107
+ // Schema-qualified manifest keys (e.g. constructive_catalog_public.apis)
108
+ // mark tables whose name collides with a table in another plane. GraphQL
109
+ // type/query names are derived from the bare table name, so these cannot
110
+ // be addressed unambiguously through the meta API — only the SQL flow
111
+ // exports them.
112
+ if (key.includes('.'))
113
+ return;
106
114
  // Build fields dynamically: either from hardcoded config or via introspection
107
115
  const { fields: configFields, enumFields } = await buildDynamicFieldsFromGraphQL(client, tableConfig);
108
116
  if (Object.keys(configFields).length === 0)
@@ -4,7 +4,7 @@ import { GraphQLClient } from './graphql-client';
4
4
  import { exportGraphQLMeta } from './export-graphql-meta';
5
5
  import { graphqlRowToPostgresRow } from './graphql-naming';
6
6
  import { DB_REQUIRED_EXTENSIONS, SERVICE_REQUIRED_EXTENSIONS, META_COMMON_HEADER, META_COMMON_FOOTER, META_TABLE_ORDER, detectMissingModules, installMissingModules, makeReplacer, preparePackage, normalizeOutdir } from './export-utils';
7
- export const exportGraphQL = async ({ project, metaEndpoint, migrateEndpoint, token, headers, migrateHeaders, databaseId, databaseName, schema_names, schemas, author, outdir, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, argv, repoName, username, serviceOutdir, skipSchemaRenaming = false, excludeCategories }) => {
7
+ export const exportGraphQL = async ({ project, metaEndpoint, migrateEndpoint, token, headers, migrateHeaders, databaseId, databaseName, schema_names, schemas, author, outdir, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, argv, repoName, username, serviceOutdir, skipSchemaRenaming = false }) => {
8
8
  const normalizedOutdir = normalizeOutdir(outdir);
9
9
  const svcOutdir = normalizeOutdir(serviceOutdir || outdir);
10
10
  const name = extensionName;
@@ -49,19 +49,10 @@ export const exportGraphQL = async ({ project, metaEndpoint, migrateEndpoint, to
49
49
  actionName: true,
50
50
  actionId: true,
51
51
  actorId: true,
52
- payload: true,
53
- category: true
52
+ payload: true
54
53
  },
55
54
  where: {
56
- databaseId: { equalTo: databaseId },
57
- ...(excludeCategories && excludeCategories.length > 0
58
- ? {
59
- or: [
60
- { category: { isNull: true } },
61
- { category: { notIn: excludeCategories } }
62
- ]
63
- }
64
- : {})
55
+ databaseId: { equalTo: databaseId }
65
56
  },
66
57
  orderBy: ['ID_ASC'],
67
58
  first: PAGE_SIZE,
@@ -23,7 +23,7 @@ const exportMigrationsToDisk = async ({ project, options, database, databaseId,
23
23
  const name = extensionName || db.rows[0].name;
24
24
  // When skipSchemaRenaming is true, pass empty schemas array to avoid renaming
25
25
  // This is useful for self-referential introspection where you want to apply
26
- // policies to real infrastructure schemas (metaschema_public, services_public, etc.)
26
+ // policies to real infrastructure schemas (metaschema_public, constructive_routing_public, etc.)
27
27
  const schemasForReplacement = skipSchemaRenaming
28
28
  ? []
29
29
  : schemas.rows.filter((schema) => schema_names.includes(schema.schema_name));
@@ -9,7 +9,9 @@
9
9
  * Examples:
10
10
  * metaschema_public.database -> databases (query), Database (type)
11
11
  * metaschema_public.foreign_key_constraint -> foreignKeyConstraints
12
- * services_public.api_schemas -> apiSchemas
12
+ * constructive_routing_public.api_schemas -> apiSchemas
13
+ * constructive_apps_public.apps -> apps
14
+ * metaschema_modules_public.api_surface_module -> apiSurfaceModules
13
15
  * db_migrate.sql_actions -> sqlActions
14
16
  * column database_id -> databaseId
15
17
  */
@@ -16,26 +16,6 @@
16
16
  "schema": "metaschema_public",
17
17
  "table": "trigger_function"
18
18
  },
19
- {
20
- "key": "apis",
21
- "schema": "services_public",
22
- "table": "apis"
23
- },
24
- {
25
- "key": "database_settings",
26
- "schema": "services_public",
27
- "table": "database_settings"
28
- },
29
- {
30
- "key": "managed_domains",
31
- "schema": "services_public",
32
- "table": "managed_domains"
33
- },
34
- {
35
- "key": "sites",
36
- "schema": "services_public",
37
- "table": "sites"
38
- },
39
19
  {
40
20
  "key": "default_ids_module",
41
21
  "schema": "metaschema_modules_public",
@@ -76,56 +56,16 @@
76
56
  "schema": "metaschema_public",
77
57
  "table": "table"
78
58
  },
79
- {
80
- "key": "api_modules",
81
- "schema": "services_public",
82
- "table": "api_modules"
83
- },
84
- {
85
- "key": "api_schemas",
86
- "schema": "services_public",
87
- "table": "api_schemas"
88
- },
89
- {
90
- "key": "api_settings",
91
- "schema": "services_public",
92
- "table": "api_settings"
93
- },
94
- {
95
- "key": "apps",
96
- "schema": "services_public",
97
- "table": "apps"
98
- },
99
- {
100
- "key": "cors_settings",
101
- "schema": "services_public",
102
- "table": "cors_settings"
103
- },
104
- {
105
- "key": "domains",
106
- "schema": "services_public",
107
- "table": "domains"
108
- },
109
- {
110
- "key": "site_metadata",
111
- "schema": "services_public",
112
- "table": "site_metadata"
113
- },
114
- {
115
- "key": "site_modules",
116
- "schema": "services_public",
117
- "table": "site_modules"
118
- },
119
- {
120
- "key": "site_themes",
121
- "schema": "services_public",
122
- "table": "site_themes"
123
- },
124
59
  {
125
60
  "key": "check_constraint",
126
61
  "schema": "metaschema_public",
127
62
  "table": "check_constraint"
128
63
  },
64
+ {
65
+ "key": "exclusion_constraint",
66
+ "schema": "metaschema_public",
67
+ "table": "exclusion_constraint"
68
+ },
129
69
  {
130
70
  "key": "field",
131
71
  "schema": "metaschema_public",
@@ -176,21 +116,6 @@
176
116
  "schema": "metaschema_public",
177
117
  "table": "view"
178
118
  },
179
- {
180
- "key": "http_routes",
181
- "schema": "services_public",
182
- "table": "http_routes"
183
- },
184
- {
185
- "key": "pubkey_settings",
186
- "schema": "services_public",
187
- "table": "pubkey_settings"
188
- },
189
- {
190
- "key": "rls_settings",
191
- "schema": "services_public",
192
- "table": "rls_settings"
193
- },
194
119
  {
195
120
  "key": "agent_module",
196
121
  "schema": "metaschema_modules_public",
@@ -206,6 +131,11 @@
206
131
  "schema": "metaschema_modules_public",
207
132
  "table": "billing_provider_module"
208
133
  },
134
+ {
135
+ "key": "catalog_module",
136
+ "schema": "metaschema_modules_public",
137
+ "table": "catalog_module"
138
+ },
209
139
  {
210
140
  "key": "compute_log_module",
211
141
  "schema": "metaschema_modules_public",
@@ -231,6 +161,11 @@
231
161
  "schema": "metaschema_modules_public",
232
162
  "table": "crypto_auth_module"
233
163
  },
164
+ {
165
+ "key": "database_settings_module",
166
+ "schema": "metaschema_modules_public",
167
+ "table": "database_settings_module"
168
+ },
234
169
  {
235
170
  "key": "db_usage_module",
236
171
  "schema": "metaschema_modules_public",
@@ -472,9 +407,14 @@
472
407
  "table": "view_table"
473
408
  },
474
409
  {
475
- "key": "webauthn_settings",
476
- "schema": "services_public",
477
- "table": "webauthn_settings"
410
+ "key": "api_surface_module",
411
+ "schema": "metaschema_modules_public",
412
+ "table": "api_surface_module"
413
+ },
414
+ {
415
+ "key": "app_module",
416
+ "schema": "metaschema_modules_public",
417
+ "table": "app_module"
478
418
  },
479
419
  {
480
420
  "key": "db_preset_module",
@@ -486,6 +426,11 @@
486
426
  "schema": "metaschema_modules_public",
487
427
  "table": "denormalized_table_field"
488
428
  },
429
+ {
430
+ "key": "domain_module",
431
+ "schema": "metaschema_modules_public",
432
+ "table": "domain_module"
433
+ },
489
434
  {
490
435
  "key": "function_deployment_module",
491
436
  "schema": "metaschema_modules_public",
@@ -506,6 +451,11 @@
506
451
  "schema": "metaschema_modules_public",
507
452
  "table": "resource_module"
508
453
  },
454
+ {
455
+ "key": "site_surface_module",
456
+ "schema": "metaschema_modules_public",
457
+ "table": "site_surface_module"
458
+ },
509
459
  {
510
460
  "key": "webhook_module",
511
461
  "schema": "metaschema_modules_public",
@@ -520,9 +470,284 @@
520
470
  "key": "http_route_module",
521
471
  "schema": "metaschema_modules_public",
522
472
  "table": "http_route_module"
473
+ },
474
+ {
475
+ "key": "route_module",
476
+ "schema": "metaschema_modules_public",
477
+ "table": "route_module"
478
+ },
479
+ {
480
+ "key": "api_modules",
481
+ "schema": "constructive_routing_public",
482
+ "table": "api_modules"
483
+ },
484
+ {
485
+ "key": "api_schemas",
486
+ "schema": "constructive_routing_public",
487
+ "table": "api_schemas"
488
+ },
489
+ {
490
+ "key": "api_settings",
491
+ "schema": "constructive_routing_public",
492
+ "table": "api_settings"
493
+ },
494
+ {
495
+ "key": "apis",
496
+ "schema": "constructive_routing_public",
497
+ "table": "apis"
498
+ },
499
+ {
500
+ "key": "cors_settings",
501
+ "schema": "constructive_routing_public",
502
+ "table": "cors_settings"
503
+ },
504
+ {
505
+ "key": "database_settings",
506
+ "schema": "constructive_routing_public",
507
+ "table": "database_settings"
508
+ },
509
+ {
510
+ "key": "domain_events",
511
+ "schema": "constructive_routing_public",
512
+ "table": "domain_events"
513
+ },
514
+ {
515
+ "key": "domain_verifications",
516
+ "schema": "constructive_routing_public",
517
+ "table": "domain_verifications"
518
+ },
519
+ {
520
+ "key": "domains",
521
+ "schema": "constructive_routing_public",
522
+ "table": "domains"
523
+ },
524
+ {
525
+ "key": "http_routes",
526
+ "schema": "constructive_routing_public",
527
+ "table": "http_routes"
528
+ },
529
+ {
530
+ "key": "managed_domains",
531
+ "schema": "constructive_routing_public",
532
+ "table": "managed_domains"
533
+ },
534
+ {
535
+ "key": "pubkey_settings",
536
+ "schema": "constructive_routing_public",
537
+ "table": "pubkey_settings"
538
+ },
539
+ {
540
+ "key": "rls_settings",
541
+ "schema": "constructive_routing_public",
542
+ "table": "rls_settings"
543
+ },
544
+ {
545
+ "key": "routes",
546
+ "schema": "constructive_routing_public",
547
+ "table": "routes"
548
+ },
549
+ {
550
+ "key": "site_metadata",
551
+ "schema": "constructive_routing_public",
552
+ "table": "site_metadata"
553
+ },
554
+ {
555
+ "key": "site_modules",
556
+ "schema": "constructive_routing_public",
557
+ "table": "site_modules"
558
+ },
559
+ {
560
+ "key": "site_themes",
561
+ "schema": "constructive_routing_public",
562
+ "table": "site_themes"
563
+ },
564
+ {
565
+ "key": "sites",
566
+ "schema": "constructive_routing_public",
567
+ "table": "sites"
568
+ },
569
+ {
570
+ "key": "webauthn_settings",
571
+ "schema": "constructive_routing_public",
572
+ "table": "webauthn_settings"
573
+ },
574
+ {
575
+ "key": "app_components",
576
+ "schema": "constructive_apps_public",
577
+ "table": "app_components"
578
+ },
579
+ {
580
+ "key": "apps",
581
+ "schema": "constructive_apps_public",
582
+ "table": "apps"
583
+ },
584
+ {
585
+ "key": "constructive_catalog_public.apis",
586
+ "schema": "constructive_catalog_public",
587
+ "table": "apis"
588
+ },
589
+ {
590
+ "key": "constructive_catalog_public.apps",
591
+ "schema": "constructive_catalog_public",
592
+ "table": "apps"
593
+ },
594
+ {
595
+ "key": "constructive_catalog_public.domains",
596
+ "schema": "constructive_catalog_public",
597
+ "table": "domains"
598
+ },
599
+ {
600
+ "key": "functions",
601
+ "schema": "constructive_catalog_public",
602
+ "table": "functions"
603
+ },
604
+ {
605
+ "key": "namespaces",
606
+ "schema": "constructive_catalog_public",
607
+ "table": "namespaces"
608
+ },
609
+ {
610
+ "key": "resource_definitions",
611
+ "schema": "constructive_catalog_public",
612
+ "table": "resource_definitions"
613
+ },
614
+ {
615
+ "key": "resource_installations",
616
+ "schema": "constructive_catalog_public",
617
+ "table": "resource_installations"
618
+ },
619
+ {
620
+ "key": "resources",
621
+ "schema": "constructive_catalog_public",
622
+ "table": "resources"
623
+ },
624
+ {
625
+ "key": "constructive_catalog_public.sites",
626
+ "schema": "constructive_catalog_public",
627
+ "table": "sites"
523
628
  }
524
629
  ],
525
630
  "timestampDefaultColumns": {
631
+ "constructive_apps_public.app_components": [
632
+ "created_at",
633
+ "updated_at"
634
+ ],
635
+ "constructive_apps_public.apps": [
636
+ "created_at",
637
+ "updated_at"
638
+ ],
639
+ "constructive_catalog_public.apis": [
640
+ "created_at",
641
+ "updated_at"
642
+ ],
643
+ "constructive_catalog_public.apps": [
644
+ "created_at",
645
+ "updated_at"
646
+ ],
647
+ "constructive_catalog_public.domains": [
648
+ "created_at",
649
+ "updated_at"
650
+ ],
651
+ "constructive_catalog_public.functions": [
652
+ "created_at",
653
+ "updated_at"
654
+ ],
655
+ "constructive_catalog_public.namespaces": [
656
+ "created_at",
657
+ "updated_at"
658
+ ],
659
+ "constructive_catalog_public.resource_definitions": [
660
+ "created_at",
661
+ "updated_at"
662
+ ],
663
+ "constructive_catalog_public.resource_installations": [
664
+ "created_at",
665
+ "updated_at"
666
+ ],
667
+ "constructive_catalog_public.resources": [
668
+ "created_at",
669
+ "updated_at"
670
+ ],
671
+ "constructive_catalog_public.sites": [
672
+ "created_at",
673
+ "updated_at"
674
+ ],
675
+ "constructive_routing_public.api_modules": [
676
+ "created_at",
677
+ "updated_at"
678
+ ],
679
+ "constructive_routing_public.api_schemas": [
680
+ "created_at",
681
+ "updated_at"
682
+ ],
683
+ "constructive_routing_public.api_settings": [
684
+ "created_at",
685
+ "updated_at"
686
+ ],
687
+ "constructive_routing_public.apis": [
688
+ "created_at",
689
+ "updated_at"
690
+ ],
691
+ "constructive_routing_public.cors_settings": [
692
+ "created_at",
693
+ "updated_at"
694
+ ],
695
+ "constructive_routing_public.database_settings": [
696
+ "created_at",
697
+ "updated_at"
698
+ ],
699
+ "constructive_routing_public.domain_events": [
700
+ "created_at",
701
+ "updated_at"
702
+ ],
703
+ "constructive_routing_public.domain_verifications": [
704
+ "created_at",
705
+ "updated_at"
706
+ ],
707
+ "constructive_routing_public.domains": [
708
+ "created_at",
709
+ "updated_at"
710
+ ],
711
+ "constructive_routing_public.http_routes": [
712
+ "created_at",
713
+ "updated_at"
714
+ ],
715
+ "constructive_routing_public.managed_domains": [
716
+ "created_at",
717
+ "updated_at"
718
+ ],
719
+ "constructive_routing_public.pubkey_settings": [
720
+ "created_at",
721
+ "updated_at"
722
+ ],
723
+ "constructive_routing_public.rls_settings": [
724
+ "created_at",
725
+ "updated_at"
726
+ ],
727
+ "constructive_routing_public.routes": [
728
+ "created_at",
729
+ "updated_at"
730
+ ],
731
+ "constructive_routing_public.site_metadata": [
732
+ "created_at",
733
+ "updated_at"
734
+ ],
735
+ "constructive_routing_public.site_modules": [
736
+ "created_at",
737
+ "updated_at"
738
+ ],
739
+ "constructive_routing_public.site_themes": [
740
+ "created_at",
741
+ "updated_at"
742
+ ],
743
+ "constructive_routing_public.sites": [
744
+ "created_at",
745
+ "updated_at"
746
+ ],
747
+ "constructive_routing_public.webauthn_settings": [
748
+ "created_at",
749
+ "updated_at"
750
+ ],
526
751
  "metaschema_modules_public.db_preset_module": [
527
752
  "created_at"
528
753
  ],
@@ -550,6 +775,10 @@
550
775
  "created_at",
551
776
  "updated_at"
552
777
  ],
778
+ "metaschema_public.exclusion_constraint": [
779
+ "created_at",
780
+ "updated_at"
781
+ ],
553
782
  "metaschema_public.field": [
554
783
  "created_at",
555
784
  "updated_at"
@@ -605,10 +834,6 @@
605
834
  "metaschema_public.unique_constraint": [
606
835
  "created_at",
607
836
  "updated_at"
608
- ],
609
- "services_public.http_routes": [
610
- "created_at",
611
- "updated_at"
612
837
  ]
613
838
  }
614
839
  }
@@ -4,7 +4,8 @@ exports.exportGraphQLMeta = void 0;
4
4
  /**
5
5
  * GraphQL equivalent of export-meta.ts.
6
6
  *
7
- * Fetches metadata from metaschema_public, services_public, and metaschema_modules_public
7
+ * Fetches metadata from metaschema_public, constructive_routing_public,
8
+ * constructive_apps_public, and metaschema_modules_public
8
9
  * via GraphQL queries instead of direct SQL, then uses the same csv-to-pg Parser to
9
10
  * generate SQL INSERT statements.
10
11
  */
@@ -106,6 +107,13 @@ const exportGraphQLMeta = async ({ client, database_id }) => {
106
107
  const tableConfig = export_utils_1.META_TABLE_CONFIG[key];
107
108
  if (!tableConfig)
108
109
  return;
110
+ // Schema-qualified manifest keys (e.g. constructive_catalog_public.apis)
111
+ // mark tables whose name collides with a table in another plane. GraphQL
112
+ // type/query names are derived from the bare table name, so these cannot
113
+ // be addressed unambiguously through the meta API — only the SQL flow
114
+ // exports them.
115
+ if (key.includes('.'))
116
+ return;
109
117
  // Build fields dynamically: either from hardcoded config or via introspection
110
118
  const { fields: configFields, enumFields } = await buildDynamicFieldsFromGraphQL(client, tableConfig);
111
119
  if (Object.keys(configFields).length === 0)
@@ -50,9 +50,10 @@ export interface ExportGraphQLOptions {
50
50
  skipSchemaRenaming?: boolean;
51
51
  /**
52
52
  * sql_actions categories to exclude from the export (e.g. ['security',
53
- * 'permissions']). Rows whose category matches are omitted; rows with a
54
- * null category are always kept.
53
+ * 'permissions']). The migrate API no longer exposes the category column;
54
+ * exclusion is enforced server-side by the export_category_filter RLS
55
+ * policy (export.exclude_categories), so this flag is not applied client-side.
55
56
  */
56
57
  excludeCategories?: string[];
57
58
  }
58
- export declare const exportGraphQL: ({ project, metaEndpoint, migrateEndpoint, token, headers, migrateHeaders, databaseId, databaseName, schema_names, schemas, author, outdir, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, argv, repoName, username, serviceOutdir, skipSchemaRenaming, excludeCategories }: ExportGraphQLOptions) => Promise<void>;
59
+ export declare const exportGraphQL: ({ project, metaEndpoint, migrateEndpoint, token, headers, migrateHeaders, databaseId, databaseName, schema_names, schemas, author, outdir, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, argv, repoName, username, serviceOutdir, skipSchemaRenaming }: ExportGraphQLOptions) => Promise<void>;
package/export-graphql.js CHANGED
@@ -7,7 +7,7 @@ const graphql_client_1 = require("./graphql-client");
7
7
  const export_graphql_meta_1 = require("./export-graphql-meta");
8
8
  const graphql_naming_1 = require("./graphql-naming");
9
9
  const export_utils_1 = require("./export-utils");
10
- const exportGraphQL = async ({ project, metaEndpoint, migrateEndpoint, token, headers, migrateHeaders, databaseId, databaseName, schema_names, schemas, author, outdir, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, argv, repoName, username, serviceOutdir, skipSchemaRenaming = false, excludeCategories }) => {
10
+ const exportGraphQL = async ({ project, metaEndpoint, migrateEndpoint, token, headers, migrateHeaders, databaseId, databaseName, schema_names, schemas, author, outdir, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, argv, repoName, username, serviceOutdir, skipSchemaRenaming = false }) => {
11
11
  const normalizedOutdir = (0, export_utils_1.normalizeOutdir)(outdir);
12
12
  const svcOutdir = (0, export_utils_1.normalizeOutdir)(serviceOutdir || outdir);
13
13
  const name = extensionName;
@@ -52,19 +52,10 @@ const exportGraphQL = async ({ project, metaEndpoint, migrateEndpoint, token, he
52
52
  actionName: true,
53
53
  actionId: true,
54
54
  actorId: true,
55
- payload: true,
56
- category: true
55
+ payload: true
57
56
  },
58
57
  where: {
59
- databaseId: { equalTo: databaseId },
60
- ...(excludeCategories && excludeCategories.length > 0
61
- ? {
62
- or: [
63
- { category: { isNull: true } },
64
- { category: { notIn: excludeCategories } }
65
- ]
66
- }
67
- : {})
58
+ databaseId: { equalTo: databaseId }
68
59
  },
69
60
  orderBy: ['ID_ASC'],
70
61
  first: PAGE_SIZE,
@@ -26,7 +26,7 @@ interface ExportOptions {
26
26
  serviceOutdir?: string;
27
27
  /**
28
28
  * Skip schema name replacement for infrastructure schemas.
29
- * When true, schema names like metaschema_public, services_public will not be renamed.
29
+ * When true, schema names like metaschema_public, constructive_routing_public will not be renamed.
30
30
  * Useful for self-referential introspection where you want to apply policies to real schemas.
31
31
  */
32
32
  skipSchemaRenaming?: boolean;
@@ -26,7 +26,7 @@ const exportMigrationsToDisk = async ({ project, options, database, databaseId,
26
26
  const name = extensionName || db.rows[0].name;
27
27
  // When skipSchemaRenaming is true, pass empty schemas array to avoid renaming
28
28
  // This is useful for self-referential introspection where you want to apply
29
- // policies to real infrastructure schemas (metaschema_public, services_public, etc.)
29
+ // policies to real infrastructure schemas (metaschema_public, constructive_routing_public, etc.)
30
30
  const schemasForReplacement = skipSchemaRenaming
31
31
  ? []
32
32
  : schemas.rows.filter((schema) => schema_names.includes(schema.schema_name));
package/graphql-naming.js CHANGED
@@ -12,7 +12,9 @@ exports.getGraphQLTypeName = exports.mapGraphQLTypeToFieldType = exports.unwrapG
12
12
  * Examples:
13
13
  * metaschema_public.database -> databases (query), Database (type)
14
14
  * metaschema_public.foreign_key_constraint -> foreignKeyConstraints
15
- * services_public.api_schemas -> apiSchemas
15
+ * constructive_routing_public.api_schemas -> apiSchemas
16
+ * constructive_apps_public.apps -> apps
17
+ * metaschema_modules_public.api_surface_module -> apiSurfaceModules
16
18
  * db_migrate.sql_actions -> sqlActions
17
19
  * column database_id -> databaseId
18
20
  */
@@ -16,26 +16,6 @@
16
16
  "schema": "metaschema_public",
17
17
  "table": "trigger_function"
18
18
  },
19
- {
20
- "key": "apis",
21
- "schema": "services_public",
22
- "table": "apis"
23
- },
24
- {
25
- "key": "database_settings",
26
- "schema": "services_public",
27
- "table": "database_settings"
28
- },
29
- {
30
- "key": "managed_domains",
31
- "schema": "services_public",
32
- "table": "managed_domains"
33
- },
34
- {
35
- "key": "sites",
36
- "schema": "services_public",
37
- "table": "sites"
38
- },
39
19
  {
40
20
  "key": "default_ids_module",
41
21
  "schema": "metaschema_modules_public",
@@ -76,56 +56,16 @@
76
56
  "schema": "metaschema_public",
77
57
  "table": "table"
78
58
  },
79
- {
80
- "key": "api_modules",
81
- "schema": "services_public",
82
- "table": "api_modules"
83
- },
84
- {
85
- "key": "api_schemas",
86
- "schema": "services_public",
87
- "table": "api_schemas"
88
- },
89
- {
90
- "key": "api_settings",
91
- "schema": "services_public",
92
- "table": "api_settings"
93
- },
94
- {
95
- "key": "apps",
96
- "schema": "services_public",
97
- "table": "apps"
98
- },
99
- {
100
- "key": "cors_settings",
101
- "schema": "services_public",
102
- "table": "cors_settings"
103
- },
104
- {
105
- "key": "domains",
106
- "schema": "services_public",
107
- "table": "domains"
108
- },
109
- {
110
- "key": "site_metadata",
111
- "schema": "services_public",
112
- "table": "site_metadata"
113
- },
114
- {
115
- "key": "site_modules",
116
- "schema": "services_public",
117
- "table": "site_modules"
118
- },
119
- {
120
- "key": "site_themes",
121
- "schema": "services_public",
122
- "table": "site_themes"
123
- },
124
59
  {
125
60
  "key": "check_constraint",
126
61
  "schema": "metaschema_public",
127
62
  "table": "check_constraint"
128
63
  },
64
+ {
65
+ "key": "exclusion_constraint",
66
+ "schema": "metaschema_public",
67
+ "table": "exclusion_constraint"
68
+ },
129
69
  {
130
70
  "key": "field",
131
71
  "schema": "metaschema_public",
@@ -176,21 +116,6 @@
176
116
  "schema": "metaschema_public",
177
117
  "table": "view"
178
118
  },
179
- {
180
- "key": "http_routes",
181
- "schema": "services_public",
182
- "table": "http_routes"
183
- },
184
- {
185
- "key": "pubkey_settings",
186
- "schema": "services_public",
187
- "table": "pubkey_settings"
188
- },
189
- {
190
- "key": "rls_settings",
191
- "schema": "services_public",
192
- "table": "rls_settings"
193
- },
194
119
  {
195
120
  "key": "agent_module",
196
121
  "schema": "metaschema_modules_public",
@@ -206,6 +131,11 @@
206
131
  "schema": "metaschema_modules_public",
207
132
  "table": "billing_provider_module"
208
133
  },
134
+ {
135
+ "key": "catalog_module",
136
+ "schema": "metaschema_modules_public",
137
+ "table": "catalog_module"
138
+ },
209
139
  {
210
140
  "key": "compute_log_module",
211
141
  "schema": "metaschema_modules_public",
@@ -231,6 +161,11 @@
231
161
  "schema": "metaschema_modules_public",
232
162
  "table": "crypto_auth_module"
233
163
  },
164
+ {
165
+ "key": "database_settings_module",
166
+ "schema": "metaschema_modules_public",
167
+ "table": "database_settings_module"
168
+ },
234
169
  {
235
170
  "key": "db_usage_module",
236
171
  "schema": "metaschema_modules_public",
@@ -472,9 +407,14 @@
472
407
  "table": "view_table"
473
408
  },
474
409
  {
475
- "key": "webauthn_settings",
476
- "schema": "services_public",
477
- "table": "webauthn_settings"
410
+ "key": "api_surface_module",
411
+ "schema": "metaschema_modules_public",
412
+ "table": "api_surface_module"
413
+ },
414
+ {
415
+ "key": "app_module",
416
+ "schema": "metaschema_modules_public",
417
+ "table": "app_module"
478
418
  },
479
419
  {
480
420
  "key": "db_preset_module",
@@ -486,6 +426,11 @@
486
426
  "schema": "metaschema_modules_public",
487
427
  "table": "denormalized_table_field"
488
428
  },
429
+ {
430
+ "key": "domain_module",
431
+ "schema": "metaschema_modules_public",
432
+ "table": "domain_module"
433
+ },
489
434
  {
490
435
  "key": "function_deployment_module",
491
436
  "schema": "metaschema_modules_public",
@@ -506,6 +451,11 @@
506
451
  "schema": "metaschema_modules_public",
507
452
  "table": "resource_module"
508
453
  },
454
+ {
455
+ "key": "site_surface_module",
456
+ "schema": "metaschema_modules_public",
457
+ "table": "site_surface_module"
458
+ },
509
459
  {
510
460
  "key": "webhook_module",
511
461
  "schema": "metaschema_modules_public",
@@ -520,9 +470,284 @@
520
470
  "key": "http_route_module",
521
471
  "schema": "metaschema_modules_public",
522
472
  "table": "http_route_module"
473
+ },
474
+ {
475
+ "key": "route_module",
476
+ "schema": "metaschema_modules_public",
477
+ "table": "route_module"
478
+ },
479
+ {
480
+ "key": "api_modules",
481
+ "schema": "constructive_routing_public",
482
+ "table": "api_modules"
483
+ },
484
+ {
485
+ "key": "api_schemas",
486
+ "schema": "constructive_routing_public",
487
+ "table": "api_schemas"
488
+ },
489
+ {
490
+ "key": "api_settings",
491
+ "schema": "constructive_routing_public",
492
+ "table": "api_settings"
493
+ },
494
+ {
495
+ "key": "apis",
496
+ "schema": "constructive_routing_public",
497
+ "table": "apis"
498
+ },
499
+ {
500
+ "key": "cors_settings",
501
+ "schema": "constructive_routing_public",
502
+ "table": "cors_settings"
503
+ },
504
+ {
505
+ "key": "database_settings",
506
+ "schema": "constructive_routing_public",
507
+ "table": "database_settings"
508
+ },
509
+ {
510
+ "key": "domain_events",
511
+ "schema": "constructive_routing_public",
512
+ "table": "domain_events"
513
+ },
514
+ {
515
+ "key": "domain_verifications",
516
+ "schema": "constructive_routing_public",
517
+ "table": "domain_verifications"
518
+ },
519
+ {
520
+ "key": "domains",
521
+ "schema": "constructive_routing_public",
522
+ "table": "domains"
523
+ },
524
+ {
525
+ "key": "http_routes",
526
+ "schema": "constructive_routing_public",
527
+ "table": "http_routes"
528
+ },
529
+ {
530
+ "key": "managed_domains",
531
+ "schema": "constructive_routing_public",
532
+ "table": "managed_domains"
533
+ },
534
+ {
535
+ "key": "pubkey_settings",
536
+ "schema": "constructive_routing_public",
537
+ "table": "pubkey_settings"
538
+ },
539
+ {
540
+ "key": "rls_settings",
541
+ "schema": "constructive_routing_public",
542
+ "table": "rls_settings"
543
+ },
544
+ {
545
+ "key": "routes",
546
+ "schema": "constructive_routing_public",
547
+ "table": "routes"
548
+ },
549
+ {
550
+ "key": "site_metadata",
551
+ "schema": "constructive_routing_public",
552
+ "table": "site_metadata"
553
+ },
554
+ {
555
+ "key": "site_modules",
556
+ "schema": "constructive_routing_public",
557
+ "table": "site_modules"
558
+ },
559
+ {
560
+ "key": "site_themes",
561
+ "schema": "constructive_routing_public",
562
+ "table": "site_themes"
563
+ },
564
+ {
565
+ "key": "sites",
566
+ "schema": "constructive_routing_public",
567
+ "table": "sites"
568
+ },
569
+ {
570
+ "key": "webauthn_settings",
571
+ "schema": "constructive_routing_public",
572
+ "table": "webauthn_settings"
573
+ },
574
+ {
575
+ "key": "app_components",
576
+ "schema": "constructive_apps_public",
577
+ "table": "app_components"
578
+ },
579
+ {
580
+ "key": "apps",
581
+ "schema": "constructive_apps_public",
582
+ "table": "apps"
583
+ },
584
+ {
585
+ "key": "constructive_catalog_public.apis",
586
+ "schema": "constructive_catalog_public",
587
+ "table": "apis"
588
+ },
589
+ {
590
+ "key": "constructive_catalog_public.apps",
591
+ "schema": "constructive_catalog_public",
592
+ "table": "apps"
593
+ },
594
+ {
595
+ "key": "constructive_catalog_public.domains",
596
+ "schema": "constructive_catalog_public",
597
+ "table": "domains"
598
+ },
599
+ {
600
+ "key": "functions",
601
+ "schema": "constructive_catalog_public",
602
+ "table": "functions"
603
+ },
604
+ {
605
+ "key": "namespaces",
606
+ "schema": "constructive_catalog_public",
607
+ "table": "namespaces"
608
+ },
609
+ {
610
+ "key": "resource_definitions",
611
+ "schema": "constructive_catalog_public",
612
+ "table": "resource_definitions"
613
+ },
614
+ {
615
+ "key": "resource_installations",
616
+ "schema": "constructive_catalog_public",
617
+ "table": "resource_installations"
618
+ },
619
+ {
620
+ "key": "resources",
621
+ "schema": "constructive_catalog_public",
622
+ "table": "resources"
623
+ },
624
+ {
625
+ "key": "constructive_catalog_public.sites",
626
+ "schema": "constructive_catalog_public",
627
+ "table": "sites"
523
628
  }
524
629
  ],
525
630
  "timestampDefaultColumns": {
631
+ "constructive_apps_public.app_components": [
632
+ "created_at",
633
+ "updated_at"
634
+ ],
635
+ "constructive_apps_public.apps": [
636
+ "created_at",
637
+ "updated_at"
638
+ ],
639
+ "constructive_catalog_public.apis": [
640
+ "created_at",
641
+ "updated_at"
642
+ ],
643
+ "constructive_catalog_public.apps": [
644
+ "created_at",
645
+ "updated_at"
646
+ ],
647
+ "constructive_catalog_public.domains": [
648
+ "created_at",
649
+ "updated_at"
650
+ ],
651
+ "constructive_catalog_public.functions": [
652
+ "created_at",
653
+ "updated_at"
654
+ ],
655
+ "constructive_catalog_public.namespaces": [
656
+ "created_at",
657
+ "updated_at"
658
+ ],
659
+ "constructive_catalog_public.resource_definitions": [
660
+ "created_at",
661
+ "updated_at"
662
+ ],
663
+ "constructive_catalog_public.resource_installations": [
664
+ "created_at",
665
+ "updated_at"
666
+ ],
667
+ "constructive_catalog_public.resources": [
668
+ "created_at",
669
+ "updated_at"
670
+ ],
671
+ "constructive_catalog_public.sites": [
672
+ "created_at",
673
+ "updated_at"
674
+ ],
675
+ "constructive_routing_public.api_modules": [
676
+ "created_at",
677
+ "updated_at"
678
+ ],
679
+ "constructive_routing_public.api_schemas": [
680
+ "created_at",
681
+ "updated_at"
682
+ ],
683
+ "constructive_routing_public.api_settings": [
684
+ "created_at",
685
+ "updated_at"
686
+ ],
687
+ "constructive_routing_public.apis": [
688
+ "created_at",
689
+ "updated_at"
690
+ ],
691
+ "constructive_routing_public.cors_settings": [
692
+ "created_at",
693
+ "updated_at"
694
+ ],
695
+ "constructive_routing_public.database_settings": [
696
+ "created_at",
697
+ "updated_at"
698
+ ],
699
+ "constructive_routing_public.domain_events": [
700
+ "created_at",
701
+ "updated_at"
702
+ ],
703
+ "constructive_routing_public.domain_verifications": [
704
+ "created_at",
705
+ "updated_at"
706
+ ],
707
+ "constructive_routing_public.domains": [
708
+ "created_at",
709
+ "updated_at"
710
+ ],
711
+ "constructive_routing_public.http_routes": [
712
+ "created_at",
713
+ "updated_at"
714
+ ],
715
+ "constructive_routing_public.managed_domains": [
716
+ "created_at",
717
+ "updated_at"
718
+ ],
719
+ "constructive_routing_public.pubkey_settings": [
720
+ "created_at",
721
+ "updated_at"
722
+ ],
723
+ "constructive_routing_public.rls_settings": [
724
+ "created_at",
725
+ "updated_at"
726
+ ],
727
+ "constructive_routing_public.routes": [
728
+ "created_at",
729
+ "updated_at"
730
+ ],
731
+ "constructive_routing_public.site_metadata": [
732
+ "created_at",
733
+ "updated_at"
734
+ ],
735
+ "constructive_routing_public.site_modules": [
736
+ "created_at",
737
+ "updated_at"
738
+ ],
739
+ "constructive_routing_public.site_themes": [
740
+ "created_at",
741
+ "updated_at"
742
+ ],
743
+ "constructive_routing_public.sites": [
744
+ "created_at",
745
+ "updated_at"
746
+ ],
747
+ "constructive_routing_public.webauthn_settings": [
748
+ "created_at",
749
+ "updated_at"
750
+ ],
526
751
  "metaschema_modules_public.db_preset_module": [
527
752
  "created_at"
528
753
  ],
@@ -550,6 +775,10 @@
550
775
  "created_at",
551
776
  "updated_at"
552
777
  ],
778
+ "metaschema_public.exclusion_constraint": [
779
+ "created_at",
780
+ "updated_at"
781
+ ],
553
782
  "metaschema_public.field": [
554
783
  "created_at",
555
784
  "updated_at"
@@ -605,10 +834,6 @@
605
834
  "metaschema_public.unique_constraint": [
606
835
  "created_at",
607
836
  "updated_at"
608
- ],
609
- "services_public.http_routes": [
610
- "created_at",
611
- "updated_at"
612
837
  ]
613
838
  }
614
839
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpmjs/export",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PGPM export tools for SQL and GraphQL database migration extraction",
6
6
  "main": "index.js",
@@ -41,20 +41,20 @@
41
41
  "@pgsql/types": "^18.0.0",
42
42
  "@types/pg": "^8.20.0",
43
43
  "makage": "^0.3.0",
44
- "pgsql-test": "^5.0.4"
44
+ "pgsql-test": "^5.0.5"
45
45
  },
46
46
  "dependencies": {
47
47
  "@constructive-io/query-builder": "^3.0.1",
48
- "@pgpmjs/core": "^7.2.2",
49
- "@pgpmjs/migrate-client": "^1.0.4",
50
- "@pgpmjs/types": "^2.35.1",
51
- "csv-to-pg": "^4.0.0",
48
+ "@pgpmjs/core": "^7.3.0",
49
+ "@pgpmjs/migrate-client": "^1.0.6",
50
+ "@pgpmjs/types": "^2.36.0",
51
+ "csv-to-pg": "^4.0.1",
52
52
  "glob": "^13.0.6",
53
53
  "inflekt": "^0.7.1",
54
54
  "inquirerer": "^4.9.1",
55
55
  "pg": "^8.21.0",
56
- "pg-cache": "^3.15.2",
56
+ "pg-cache": "^3.15.3",
57
57
  "pg-env": "^1.18.1"
58
58
  },
59
- "gitHead": "d48f39ebd4b7dcbab22df7c57438c06efd9e223d"
59
+ "gitHead": "ebba3f838664032e6f6adf6c9c6d2b6cdddd994a"
60
60
  }