@pgpm/metaschema-modules 0.18.0 → 0.19.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.
Files changed (43) hide show
  1. package/README.md +7 -7
  2. package/deploy/schemas/metaschema_modules_public/tables/blueprint/table.sql +119 -0
  3. package/deploy/schemas/metaschema_modules_public/tables/blueprint_template/table.sql +137 -0
  4. package/deploy/schemas/metaschema_modules_public/tables/connected_accounts_module/table.sql +1 -6
  5. package/deploy/schemas/metaschema_modules_public/tables/crypto_addresses_module/table.sql +1 -6
  6. package/deploy/schemas/metaschema_modules_public/tables/crypto_auth_module/table.sql +1 -7
  7. package/deploy/schemas/metaschema_modules_public/tables/default_ids_module/table.sql +1 -2
  8. package/deploy/schemas/metaschema_modules_public/tables/denormalized_table_field/table.sql +1 -6
  9. package/deploy/schemas/metaschema_modules_public/tables/emails_module/table.sql +1 -6
  10. package/deploy/schemas/metaschema_modules_public/tables/encrypted_secrets_module/table.sql +1 -6
  11. package/deploy/schemas/metaschema_modules_public/tables/field_module/table.sql +1 -5
  12. package/deploy/schemas/metaschema_modules_public/tables/hierarchy_module/table.sql +1 -19
  13. package/deploy/schemas/metaschema_modules_public/tables/invites_module/table.sql +1 -8
  14. package/deploy/schemas/metaschema_modules_public/tables/levels_module/table.sql +1 -8
  15. package/deploy/schemas/metaschema_modules_public/tables/limits_module/table.sql +1 -14
  16. package/deploy/schemas/metaschema_modules_public/tables/membership_types_module/table.sql +1 -6
  17. package/deploy/schemas/metaschema_modules_public/tables/memberships_module/table.sql +1 -40
  18. package/deploy/schemas/metaschema_modules_public/tables/permissions_module/table.sql +1 -13
  19. package/deploy/schemas/metaschema_modules_public/tables/phone_numbers_module/table.sql +1 -6
  20. package/deploy/schemas/metaschema_modules_public/tables/profiles_module/table.sql +1 -28
  21. package/deploy/schemas/metaschema_modules_public/tables/relation_provision/table.sql +45 -7
  22. package/deploy/schemas/metaschema_modules_public/tables/rls_module/table.sql +2 -7
  23. package/deploy/schemas/metaschema_modules_public/tables/secrets_module/table.sql +1 -6
  24. package/deploy/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql +9 -7
  25. package/deploy/schemas/metaschema_modules_public/tables/sessions_module/table.sql +4 -8
  26. package/deploy/schemas/metaschema_modules_public/tables/table_template_module/table.sql +1 -6
  27. package/deploy/schemas/metaschema_modules_public/tables/user_auth_module/table.sql +1 -3
  28. package/deploy/schemas/metaschema_modules_public/tables/users_module/table.sql +1 -10
  29. package/metaschema-modules.control +1 -1
  30. package/package.json +4 -4
  31. package/pgpm.plan +3 -2
  32. package/revert/schemas/metaschema_modules_public/tables/blueprint/table.sql +7 -0
  33. package/revert/schemas/metaschema_modules_public/tables/blueprint_template/table.sql +7 -0
  34. package/verify/schemas/metaschema_modules_public/tables/blueprint/table.sql +26 -0
  35. package/verify/schemas/metaschema_modules_public/tables/blueprint_template/table.sql +29 -0
  36. package/verify/schemas/metaschema_modules_public/tables/relation_provision/table.sql +1 -0
  37. package/verify/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql +1 -0
  38. package/deploy/schemas/metaschema_modules_public/tables/table_module/table.sql +0 -37
  39. package/deploy/schemas/metaschema_modules_public/tables/uuid_module/table.sql +0 -23
  40. package/revert/schemas/metaschema_modules_public/tables/table_module/table.sql +0 -7
  41. package/revert/schemas/metaschema_modules_public/tables/uuid_module/table.sql +0 -7
  42. package/verify/schemas/metaschema_modules_public/tables/table_module/table.sql +0 -18
  43. package/verify/schemas/metaschema_modules_public/tables/uuid_module/table.sql +0 -7
@@ -5,7 +5,7 @@
5
5
  BEGIN;
6
6
 
7
7
  CREATE TABLE metaschema_modules_public.memberships_module (
8
- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
9
  database_id uuid NOT NULL,
10
10
  --
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -76,45 +76,6 @@ CREATE TABLE metaschema_modules_public.memberships_module (
76
76
  CONSTRAINT default_permissions_table_fkey FOREIGN KEY (default_permissions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
77
77
  );
78
78
 
79
- COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
80
- COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
81
- COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
82
79
  CREATE INDEX memberships_module_database_id_idx ON metaschema_modules_public.memberships_module ( database_id );
83
80
 
84
- COMMENT ON CONSTRAINT entity_table_fkey
85
- ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
86
-
87
- COMMENT ON CONSTRAINT entity_table_owner_fkey
88
- ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
89
-
90
- COMMENT ON CONSTRAINT memberships_table_fkey
91
- ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
92
-
93
- COMMENT ON CONSTRAINT members_table_fkey
94
- ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
95
-
96
- COMMENT ON CONSTRAINT membership_defaults_table_fkey
97
- ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
98
-
99
- COMMENT ON CONSTRAINT grants_table_fkey
100
- ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
101
-
102
- COMMENT ON CONSTRAINT sprt_table_fkey
103
- ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
104
-
105
- COMMENT ON CONSTRAINT actor_table_fkey
106
- ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
107
-
108
- COMMENT ON CONSTRAINT limits_table_fkey
109
- ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
110
-
111
- COMMENT ON CONSTRAINT default_limits_table_fkey
112
- ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
113
-
114
- COMMENT ON CONSTRAINT permissions_table_fkey
115
- ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
116
-
117
- COMMENT ON CONSTRAINT default_permissions_table_fkey
118
- ON metaschema_modules_public.memberships_module IS E'@omit manyToMany';
119
-
120
81
  COMMIT;
@@ -5,7 +5,7 @@
5
5
  BEGIN;
6
6
 
7
7
  CREATE TABLE metaschema_modules_public.permissions_module (
8
- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
9
  database_id uuid NOT NULL,
10
10
  --
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -48,18 +48,6 @@ CREATE TABLE metaschema_modules_public.permissions_module (
48
48
  CONSTRAINT actor_table_fkey FOREIGN KEY (actor_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
49
49
  );
50
50
 
51
- COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.permissions_module IS E'@omit manyToMany';
52
- COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.permissions_module IS E'@omit manyToMany';
53
- COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.permissions_module IS E'@omit manyToMany';
54
51
  CREATE INDEX permissions_module_database_id_idx ON metaschema_modules_public.permissions_module ( database_id );
55
52
 
56
- COMMENT ON CONSTRAINT table_fkey
57
- ON metaschema_modules_public.permissions_module IS E'@omit manyToMany';
58
-
59
- COMMENT ON CONSTRAINT default_table_fkey
60
- ON metaschema_modules_public.permissions_module IS E'@omit manyToMany';
61
-
62
- COMMENT ON CONSTRAINT actor_table_fkey
63
- ON metaschema_modules_public.permissions_module IS E'@omit manyToMany';
64
-
65
53
  COMMIT;
@@ -5,7 +5,7 @@
5
5
  BEGIN;
6
6
 
7
7
  CREATE TABLE metaschema_modules_public.phone_numbers_module (
8
- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
9
  database_id uuid NOT NULL,
10
10
 
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -24,11 +24,6 @@ CREATE TABLE metaschema_modules_public.phone_numbers_module (
24
24
  CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE
25
25
  );
26
26
 
27
- COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.phone_numbers_module IS E'@omit manyToMany';
28
- COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.phone_numbers_module IS E'@omit manyToMany';
29
- COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.phone_numbers_module IS E'@omit manyToMany';
30
- COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.phone_numbers_module IS E'@omit manyToMany';
31
- COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.phone_numbers_module IS E'@omit manyToMany';
32
27
  CREATE INDEX phone_numbers_module_database_id_idx ON metaschema_modules_public.phone_numbers_module ( database_id );
33
28
 
34
29
  COMMIT;
@@ -5,7 +5,7 @@
5
5
  BEGIN;
6
6
 
7
7
  CREATE TABLE metaschema_modules_public.profiles_module (
8
- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
9
  database_id uuid NOT NULL,
10
10
  --
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -55,33 +55,6 @@ CREATE TABLE metaschema_modules_public.profiles_module (
55
55
  CONSTRAINT profiles_module_unique UNIQUE (database_id, membership_type)
56
56
  );
57
57
 
58
- COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.profiles_module IS E'@omit manyToMany';
59
- COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.profiles_module IS E'@omit manyToMany';
60
- COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.profiles_module IS E'@omit manyToMany';
61
58
  CREATE INDEX profiles_module_database_id_idx ON metaschema_modules_public.profiles_module ( database_id );
62
59
 
63
- COMMENT ON CONSTRAINT table_fkey
64
- ON metaschema_modules_public.profiles_module IS E'@omit manyToMany';
65
-
66
- COMMENT ON CONSTRAINT profile_permissions_table_fkey
67
- ON metaschema_modules_public.profiles_module IS E'@omit manyToMany';
68
-
69
- COMMENT ON CONSTRAINT profile_grants_table_fkey
70
- ON metaschema_modules_public.profiles_module IS E'@omit manyToMany';
71
-
72
- COMMENT ON CONSTRAINT profile_definition_grants_table_fkey
73
- ON metaschema_modules_public.profiles_module IS E'@omit manyToMany';
74
-
75
- COMMENT ON CONSTRAINT entity_table_fkey
76
- ON metaschema_modules_public.profiles_module IS E'@omit manyToMany';
77
-
78
- COMMENT ON CONSTRAINT actor_table_fkey
79
- ON metaschema_modules_public.profiles_module IS E'@omit manyToMany';
80
-
81
- COMMENT ON CONSTRAINT permissions_table_fkey
82
- ON metaschema_modules_public.profiles_module IS E'@omit manyToMany';
83
-
84
- COMMENT ON CONSTRAINT memberships_table_fkey
85
- ON metaschema_modules_public.profiles_module IS E'@omit manyToMany';
86
-
87
60
  COMMIT;
@@ -5,7 +5,7 @@
5
5
  BEGIN;
6
6
 
7
7
  CREATE TABLE metaschema_modules_public.relation_provision (
8
- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
9
 
10
10
  database_id uuid NOT NULL,
11
11
 
@@ -31,6 +31,8 @@ CREATE TABLE metaschema_modules_public.relation_provision (
31
31
 
32
32
  is_required boolean NOT NULL DEFAULT true,
33
33
 
34
+ api_required boolean NOT NULL DEFAULT false,
35
+
34
36
  -- =========================================================================
35
37
  -- ManyToMany: junction table identity
36
38
  -- =========================================================================
@@ -51,6 +53,18 @@ CREATE TABLE metaschema_modules_public.relation_provision (
51
53
 
52
54
  use_composite_key boolean NOT NULL DEFAULT false,
53
55
 
56
+ -- =========================================================================
57
+ -- Index creation on FK fields
58
+ -- =========================================================================
59
+
60
+ create_index boolean NOT NULL DEFAULT true,
61
+
62
+ -- =========================================================================
63
+ -- ManyToMany: API visibility (PostGraphile v5 @behavior +manyToMany)
64
+ -- =========================================================================
65
+
66
+ expose_in_api boolean NOT NULL DEFAULT true,
67
+
54
68
  -- =========================================================================
55
69
  -- ManyToMany: field creation (forwarded to secure_table_provision)
56
70
  -- =========================================================================
@@ -65,7 +79,7 @@ CREATE TABLE metaschema_modules_public.relation_provision (
65
79
 
66
80
  grant_roles text[] NOT NULL DEFAULT ARRAY['authenticated'],
67
81
 
68
- grant_privileges jsonb NOT NULL DEFAULT '[["select","*"],["insert","*"],["delete","*"]]',
82
+ grant_privileges jsonb[] NOT NULL DEFAULT ARRAY['["select","*"]'::jsonb, '["insert","*"]'::jsonb, '["delete","*"]'::jsonb],
69
83
 
70
84
  -- =========================================================================
71
85
  -- ManyToMany: RLS policies (forwarded to secure_table_provision)
@@ -167,6 +181,12 @@ COMMENT ON COLUMN metaschema_modules_public.relation_provision.is_required IS
167
181
  - RelationHasOne: typically true.
168
182
  Ignored for RelationManyToMany (junction FK fields are always required).';
169
183
 
184
+ COMMENT ON COLUMN metaschema_modules_public.relation_provision.api_required IS
185
+ 'Whether the FK field should be required at the API level even though it is nullable at the database level. Defaults to false.
186
+ When true and is_required is false, the field is created as nullable (allowing SET NULL cascade) but a @requiredInput smart tag is added so PostGraphile treats it as non-null in create/update input types.
187
+ When is_required is true, api_required is ignored (the field is already required at both levels).
188
+ Ignored for RelationManyToMany (junction FK fields are always required).';
189
+
170
190
  -- =============================================================================
171
191
  -- ManyToMany: junction table identity
172
192
  -- =============================================================================
@@ -200,6 +220,28 @@ COMMENT ON COLUMN metaschema_modules_public.relation_provision.use_composite_key
200
220
  use_composite_key and node_type=''DataId'' are mutually exclusive — using both would create two conflicting PKs.
201
221
  Ignored for RelationBelongsTo/RelationHasOne.';
202
222
 
223
+ COMMENT ON COLUMN metaschema_modules_public.relation_provision.create_index IS
224
+ 'Whether to create a btree index on FK fields created by this relation. Defaults to true.
225
+ PostgreSQL does not automatically index foreign key columns (only the referenced PK side is indexed).
226
+ Without indexes on FK columns, JOINs, CASCADE deletes, and RLS policy lookups perform sequential scans.
227
+ - RelationBelongsTo: creates an index on the FK field on the source table.
228
+ - RelationHasMany: creates an index on the FK field on the target table.
229
+ - RelationHasOne: skipped — the unique constraint already creates an implicit index.
230
+ - RelationManyToMany: creates indexes on both FK fields on the junction table.
231
+ Set to false only for very small tables or write-heavy tables where index maintenance cost outweighs read performance.';
232
+
233
+ -- =============================================================================
234
+ -- ManyToMany: API visibility
235
+ -- =============================================================================
236
+
237
+ COMMENT ON COLUMN metaschema_modules_public.relation_provision.expose_in_api IS
238
+ 'For RelationManyToMany: whether to expose the M:N shortcut fields in the GraphQL API. Defaults to true.
239
+ When true, sets @behavior +manyToMany on the junction table smart_tags so PostGraphile generates
240
+ clean M:N connection fields (e.g., event.contacts instead of event.contactEventsByEventId).
241
+ When false (or toggled off via UPDATE), the behavior tag is removed and the M:N fields disappear from GraphQL.
242
+ Toggling is supported: UPDATE expose_in_api to true/false and the smart tag is added/removed automatically.
243
+ Ignored for RelationBelongsTo/RelationHasOne/RelationHasMany.';
244
+
203
245
  -- =============================================================================
204
246
  -- ManyToMany: field creation (forwarded to secure_table_provision)
205
247
  -- =============================================================================
@@ -227,7 +269,7 @@ COMMENT ON COLUMN metaschema_modules_public.relation_provision.grant_roles IS
227
269
  'For RelationManyToMany: database roles to grant privileges to on the junction table. Forwarded to secure_table_provision as-is. Supports multiple roles, e.g. ARRAY[''authenticated'', ''admin'']. Each role receives all privileges defined in grant_privileges. Defaults to ARRAY[''authenticated'']. Ignored for RelationBelongsTo/RelationHasOne.';
228
270
 
229
271
  COMMENT ON COLUMN metaschema_modules_public.relation_provision.grant_privileges IS
230
- 'For RelationManyToMany: privilege grants for the junction table. Forwarded to secure_table_provision as-is. Format: array of [privilege, columns] tuples. Examples: [["select","*"],["insert","*"]] for full access, or [["update",["name","bio"]]] for column-level grants. "*" means all columns. Defaults to select/insert/delete for all columns. Ignored for RelationBelongsTo/RelationHasOne.';
272
+ 'For RelationManyToMany: privilege grants for the junction table. Forwarded to secure_table_provision as-is. Format: PostgreSQL array of jsonb [privilege, columns] tuples. Examples: ARRAY[''["select","*"]''::jsonb, ''["insert","*"]''::jsonb] for full access, or ARRAY[''["update",["name","bio"]]''::jsonb] for column-level grants. "*" means all columns. Defaults to select/insert/delete for all columns. Ignored for RelationBelongsTo/RelationHasOne.';
231
273
 
232
274
  -- =============================================================================
233
275
  -- ManyToMany: RLS policies (forwarded to secure_table_provision)
@@ -275,10 +317,6 @@ COMMENT ON COLUMN metaschema_modules_public.relation_provision.out_source_field_
275
317
  COMMENT ON COLUMN metaschema_modules_public.relation_provision.out_target_field_id IS
276
318
  'Output column for RelationManyToMany: the UUID of the FK field on the junction table referencing the target table. Populated by the trigger. NULL for RelationBelongsTo/RelationHasOne. Callers should not set this directly.';
277
319
 
278
- COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.relation_provision IS E'@omit manyToMany';
279
- COMMENT ON CONSTRAINT source_table_fkey ON metaschema_modules_public.relation_provision IS E'@omit manyToMany';
280
- COMMENT ON CONSTRAINT target_table_fkey ON metaschema_modules_public.relation_provision IS E'@omit manyToMany';
281
-
282
320
  CREATE INDEX relation_provision_database_id_idx ON metaschema_modules_public.relation_provision ( database_id );
283
321
  CREATE INDEX relation_provision_relation_type_idx ON metaschema_modules_public.relation_provision ( relation_type );
284
322
  CREATE INDEX relation_provision_source_table_id_idx ON metaschema_modules_public.relation_provision ( source_table_id );
@@ -6,10 +6,9 @@
6
6
  BEGIN;
7
7
 
8
8
  CREATE TABLE metaschema_modules_public.rls_module (
9
- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
9
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
10
10
  database_id uuid NOT NULL,
11
11
 
12
- api_id uuid NOT NULL DEFAULT uuid_nil(),
13
12
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
14
13
  private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
15
14
  session_credentials_table_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -25,7 +24,6 @@ CREATE TABLE metaschema_modules_public.rls_module (
25
24
 
26
25
  --
27
26
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
28
- CONSTRAINT api_fkey FOREIGN KEY (api_id) REFERENCES services_public.apis (id) ON DELETE CASCADE,
29
27
  CONSTRAINT session_credentials_table_fkey FOREIGN KEY (session_credentials_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
30
28
  CONSTRAINT sessions_table_fkey FOREIGN KEY (sessions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
31
29
  CONSTRAINT users_table_fkey FOREIGN KEY (users_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
@@ -33,12 +31,9 @@ CREATE TABLE metaschema_modules_public.rls_module (
33
31
  CONSTRAINT pschema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
34
32
 
35
33
  --
36
- CONSTRAINT api_id_uniq UNIQUE(api_id)
34
+ CONSTRAINT database_id_uniq UNIQUE(database_id)
37
35
  );
38
36
 
39
- COMMENT ON CONSTRAINT api_fkey ON metaschema_modules_public.rls_module IS E'@omit manyToMany';
40
- COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.rls_module IS E'@omit manyToMany';
41
- COMMENT ON CONSTRAINT pschema_fkey ON metaschema_modules_public.rls_module IS E'@omit manyToMany';
42
37
 
43
38
  COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.rls_module IS E'@omit';
44
39
  COMMENT ON CONSTRAINT session_credentials_table_fkey ON metaschema_modules_public.rls_module IS E'@omit';
@@ -5,7 +5,7 @@
5
5
  BEGIN;
6
6
 
7
7
  CREATE TABLE metaschema_modules_public.secrets_module (
8
- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
9
  database_id uuid NOT NULL,
10
10
  --
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -18,11 +18,6 @@ CREATE TABLE metaschema_modules_public.secrets_module (
18
18
 
19
19
  );
20
20
 
21
- COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.secrets_module IS E'@omit manyToMany';
22
- COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.secrets_module IS E'@omit manyToMany';
23
21
  CREATE INDEX secrets_module_database_id_idx ON metaschema_modules_public.secrets_module ( database_id );
24
22
 
25
- COMMENT ON CONSTRAINT table_fkey
26
- ON metaschema_modules_public.secrets_module IS E'@omit manyToMany';
27
-
28
23
  COMMIT;
@@ -5,7 +5,7 @@
5
5
  BEGIN;
6
6
 
7
7
  CREATE TABLE metaschema_modules_public.secure_table_provision (
8
- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
9
 
10
10
  database_id uuid NOT NULL,
11
11
 
@@ -21,9 +21,11 @@ CREATE TABLE metaschema_modules_public.secure_table_provision (
21
21
 
22
22
  node_data jsonb NOT NULL DEFAULT '{}',
23
23
 
24
+ fields jsonb[] NOT NULL DEFAULT '{}',
25
+
24
26
  grant_roles text[] NOT NULL DEFAULT ARRAY['authenticated'],
25
27
 
26
- grant_privileges jsonb NOT NULL DEFAULT '[]',
28
+ grant_privileges jsonb[] NOT NULL DEFAULT '{}',
27
29
 
28
30
  policy_type text DEFAULT NULL,
29
31
 
@@ -69,13 +71,16 @@ COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.use_rls IS
69
71
  'If true and Row Level Security is not yet enabled on the target table, enable it. Automatically set to true by the trigger when policy_type is provided. Defaults to true.';
70
72
 
71
73
  COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.node_data IS
72
- 'Configuration passed to the generator function for field creation (only used when node_type is set). Known keys include: field_name (text, default ''id'') for DataId, owner_field_name (text, default ''owner_id'') for DataDirectOwner/DataOwnershipInEntity, entity_field_name (text, default ''entity_id'') for DataEntityMembership/DataOwnershipInEntity, include_id (boolean, default true) for most node_types, include_user_fk (boolean, default true) to add FK to users table. Defaults to ''{}''.';
74
+ 'Configuration passed to the generator function for field creation (only used when node_type is set). Known keys include: field_name (text, default ''id'') for DataId, owner_field_name (text, default ''owner_id'') for DataDirectOwner/DataOwnershipInEntity, entity_field_name (text, default ''entity_id'') for DataEntityMembership/DataOwnershipInEntity, include_id (boolean, default true) for most node_types, include_user_fk (boolean, default true) to add FK to users table, create_index (boolean, default true) to create btree indexes on FK fields for join and cascade performance. Defaults to ''{}''.';
75
+
76
+ COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.fields IS
77
+ 'PostgreSQL array of jsonb field definition objects to create on the target table. Each object has keys: "name" (text, required), "type" (text, required), "default" (text, optional), "is_required" (boolean, optional, defaults to false), "min" (float, optional), "max" (float, optional), "regexp" (text, optional), "index" (boolean, optional, defaults to false — creates a btree index on the field). min/max generate CHECK constraints: for text/citext they constrain character_length, for integer/float types they constrain the value. regexp generates a CHECK (col ~ pattern) constraint for text/citext. Fields are created via metaschema.create_field() after any node_type generator runs, and their IDs are appended to out_fields. Example: ARRAY[''{"name":"username","type":"citext","max":256,"regexp":"^[a-z0-9_]+$"}''::jsonb, ''{"name":"score","type":"integer","min":0,"max":100}''::jsonb]. Defaults to ''{}'' (no additional fields).';
73
78
 
74
79
  COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.grant_roles IS
75
80
  'Database roles to grant privileges to. Supports multiple roles, e.g. ARRAY[''authenticated'', ''admin'']. Each role receives all privileges defined in grant_privileges. Defaults to ARRAY[''authenticated''].';
76
81
 
77
82
  COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.grant_privileges IS
78
- 'Array of [privilege, columns] tuples defining table grants. Examples: [["select","*"],["insert","*"]] for full access, or [["update",["name","bio"]]] for column-level grants. "*" means all columns; an array means column-level grant. Defaults to ''[]'' (no grants). The trigger validates this is a proper jsonb array.';
83
+ 'PostgreSQL array of jsonb [privilege, columns] tuples defining table grants. Examples: ARRAY[''["select","*"]''::jsonb, ''["insert","*"]''::jsonb] for full access, or ARRAY[''["update",["name","bio"]]''::jsonb] for column-level grants. "*" means all columns; an array means column-level grant. Defaults to ''{}'' (no grants). Type safety is enforced by PostgreSQL at INSERT time.';
79
84
 
80
85
  COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.policy_type IS
81
86
  'Policy generator type, e.g. ''AuthzEntityMembership'', ''AuthzMembership'', ''AuthzAllowAll''. NULL means no policy is created. When set, the trigger automatically enables RLS on the target table.';
@@ -98,9 +103,6 @@ COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.policy_data I
98
103
  COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.out_fields IS
99
104
  'Output column populated by the trigger after field creation. Contains the UUIDs of the metaschema fields created on the target table by this provision row''s generator. NULL when node_type is NULL or before the trigger runs. Callers should not set this directly.';
100
105
 
101
- COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.secure_table_provision IS E'@omit manyToMany';
102
- COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.secure_table_provision IS E'@omit manyToMany';
103
- COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.secure_table_provision IS E'@omit manyToMany';
104
106
 
105
107
  CREATE INDEX secure_table_provision_database_id_idx ON metaschema_modules_public.secure_table_provision ( database_id );
106
108
  CREATE INDEX secure_table_provision_table_id_idx ON metaschema_modules_public.secure_table_provision ( table_id );
@@ -5,7 +5,7 @@
5
5
  BEGIN;
6
6
 
7
7
  CREATE TABLE metaschema_modules_public.sessions_module (
8
- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
9
  database_id uuid NOT NULL,
10
10
 
11
11
  --
@@ -29,17 +29,13 @@ CREATE TABLE metaschema_modules_public.sessions_module (
29
29
  CONSTRAINT users_table_fkey FOREIGN KEY (users_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
30
30
  );
31
31
 
32
- COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.sessions_module IS E'@omit manyToMany';
33
- COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.sessions_module IS E'@omit manyToMany';
34
32
  CREATE INDEX sessions_module_database_id_idx ON metaschema_modules_public.sessions_module ( database_id );
35
33
 
36
34
  COMMENT ON CONSTRAINT sessions_table_fkey
37
- ON metaschema_modules_public.sessions_module IS E'@fieldName sessionsTableBySessionsTableId\n@omit manyToMany';
35
+ ON metaschema_modules_public.sessions_module IS E'@fieldName sessionsTableBySessionsTableId';
38
36
  COMMENT ON CONSTRAINT session_credentials_table_fkey
39
- ON metaschema_modules_public.sessions_module IS E'@fieldName sessionCredentialsTableBySessionCredentialsTableId\n@omit manyToMany';
37
+ ON metaschema_modules_public.sessions_module IS E'@fieldName sessionCredentialsTableBySessionCredentialsTableId';
40
38
  COMMENT ON CONSTRAINT auth_settings_table_fkey
41
- ON metaschema_modules_public.sessions_module IS E'@fieldName authSettingsTableByAuthSettingsTableId\n@omit manyToMany';
42
- COMMENT ON CONSTRAINT users_table_fkey
43
- ON metaschema_modules_public.sessions_module IS E'@omit manyToMany';
39
+ ON metaschema_modules_public.sessions_module IS E'@fieldName authSettingsTableByAuthSettingsTableId';
44
40
 
45
41
  COMMIT;
@@ -5,7 +5,7 @@
5
5
  BEGIN;
6
6
 
7
7
  CREATE TABLE metaschema_modules_public.table_template_module (
8
- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
9
  database_id uuid NOT NULL,
10
10
 
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -33,11 +33,6 @@ CREATE TABLE metaschema_modules_public.table_template_module (
33
33
  CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE
34
34
  );
35
35
 
36
- COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.table_template_module IS E'@omit manyToMany';
37
- COMMENT ON CONSTRAINT private_schema_fkey ON metaschema_modules_public.table_template_module IS E'@omit manyToMany';
38
- COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.table_template_module IS E'@omit manyToMany';
39
- COMMENT ON CONSTRAINT owner_table_fkey ON metaschema_modules_public.table_template_module IS E'@omit manyToMany';
40
- COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.table_template_module IS E'@omit manyToMany';
41
36
  CREATE INDEX table_template_module_database_id_idx ON metaschema_modules_public.table_template_module ( database_id );
42
37
  CREATE INDEX table_template_module_schema_id_idx ON metaschema_modules_public.table_template_module ( schema_id );
43
38
  CREATE INDEX table_template_module_private_schema_id_idx ON metaschema_modules_public.table_template_module ( private_schema_id );
@@ -5,7 +5,7 @@
5
5
  BEGIN;
6
6
 
7
7
  CREATE TABLE metaschema_modules_public.user_auth_module (
8
- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
9
  database_id uuid NOT NULL,
10
10
 
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -56,8 +56,6 @@ CREATE TABLE metaschema_modules_public.user_auth_module (
56
56
  CONSTRAINT session_credentials_table_fkey FOREIGN KEY (session_credentials_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
57
57
  );
58
58
 
59
- COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.user_auth_module IS E'@omit manyToMany';
60
- COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.user_auth_module IS E'@omit manyToMany';
61
59
  CREATE INDEX user_auth_module_database_id_idx ON metaschema_modules_public.user_auth_module ( database_id );
62
60
 
63
61
  COMMENT ON CONSTRAINT email_table_fkey
@@ -5,7 +5,7 @@
5
5
  BEGIN;
6
6
 
7
7
  CREATE TABLE metaschema_modules_public.users_module (
8
- id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
9
  database_id uuid NOT NULL,
10
10
  --
11
11
  schema_id uuid NOT NULL DEFAULT uuid_nil(),
@@ -24,15 +24,6 @@ CREATE TABLE metaschema_modules_public.users_module (
24
24
  CONSTRAINT type_table_fkey FOREIGN KEY (type_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
25
25
  );
26
26
 
27
- COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.users_module IS E'@omit manyToMany';
28
- COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.users_module IS E'@omit manyToMany';
29
27
  CREATE INDEX users_module_database_id_idx ON metaschema_modules_public.users_module ( database_id );
30
28
 
31
- COMMENT ON CONSTRAINT table_fkey
32
- ON metaschema_modules_public.users_module IS E'@omit manyToMany';
33
-
34
- COMMENT ON CONSTRAINT type_table_fkey
35
- ON metaschema_modules_public.users_module IS E'@omit manyToMany';
36
-
37
-
38
29
  COMMIT;
@@ -2,6 +2,6 @@
2
2
  comment = 'metaschema-modules extension'
3
3
  default_version = '0.15.5'
4
4
  module_pathname = '$libdir/metaschema-modules'
5
- requires = 'plpgsql,metaschema-schema,services,pgpm-verify'
5
+ requires = 'plpgsql,uuid-ossp,metaschema-schema,services,pgpm-verify'
6
6
  relocatable = false
7
7
  superuser = false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpm/metaschema-modules",
3
- "version": "0.18.0",
3
+ "version": "0.19.1",
4
4
  "description": "Module metadata handling and dependency tracking",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "contributors": [
@@ -21,8 +21,8 @@
21
21
  "test:watch": "jest --watch"
22
22
  },
23
23
  "dependencies": {
24
- "@pgpm/metaschema-schema": "0.18.0",
25
- "@pgpm/verify": "0.18.0"
24
+ "@pgpm/metaschema-schema": "0.19.1",
25
+ "@pgpm/verify": "0.19.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "pgpm": "^4.2.3"
@@ -35,5 +35,5 @@
35
35
  "bugs": {
36
36
  "url": "https://github.com/constructive-io/pgpm-modules/issues"
37
37
  },
38
- "gitHead": "8144027c7fab4956bcdebd736d04c0d4f57344bc"
38
+ "gitHead": "874490c55094ce0232bf230c613ee58685f369dc"
39
39
  }
package/pgpm.plan CHANGED
@@ -14,7 +14,6 @@ schemas/metaschema_modules_public/tables/denormalized_table_field/table [schemas
14
14
  schemas/metaschema_modules_public/tables/emails_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/emails_module/table
15
15
  schemas/metaschema_modules_public/tables/encrypted_secrets_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/encrypted_secrets_module/table
16
16
  schemas/metaschema_modules_public/tables/field_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/field_module/table
17
- schemas/metaschema_modules_public/tables/table_module/table [schemas/metaschema_modules_public/schema] 2026-01-12T00:00:00Z devin <devin@cognition.ai> # add schemas/metaschema_modules_public/tables/table_module/table
18
17
  schemas/metaschema_modules_public/tables/invites_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/invites_module/table
19
18
  schemas/metaschema_modules_public/tables/levels_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/levels_module/table
20
19
  schemas/metaschema_modules_public/tables/limits_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/limits_module/table
@@ -29,8 +28,10 @@ schemas/services_public/tables/sites/table [schemas/services_public/schema] 2017
29
28
  schemas/metaschema_modules_public/tables/sessions_module/table [schemas/metaschema_modules_public/schema] 2026-01-24T00:00:00Z devin <devin@cognition.ai> # add schemas/metaschema_modules_public/tables/sessions_module/table
30
29
  schemas/metaschema_modules_public/tables/user_auth_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/user_auth_module/table
31
30
  schemas/metaschema_modules_public/tables/users_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/users_module/table
32
- schemas/metaschema_modules_public/tables/uuid_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/uuid_module/table
31
+
33
32
  schemas/metaschema_modules_public/tables/hierarchy_module/table [schemas/metaschema_modules_public/schema] 2024-12-28T00:00:00Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/hierarchy_module/table
34
33
  schemas/metaschema_modules_public/tables/table_template_module/table [schemas/metaschema_modules_public/schema] 2026-01-14T00:00:00Z devin <devin@cognition.ai> # add schemas/metaschema_modules_public/tables/table_template_module/table
35
34
  schemas/metaschema_modules_public/tables/secure_table_provision/table [schemas/metaschema_modules_public/schema] 2026-02-25T00:00:00Z Constructive <developers@constructive.io> # add schemas/metaschema_modules_public/tables/secure_table_provision/table
36
35
  schemas/metaschema_modules_public/tables/relation_provision/table [schemas/metaschema_modules_public/schema] 2026-02-26T00:00:00Z Constructive <developers@constructive.io> # add schemas/metaschema_modules_public/tables/relation_provision/table
36
+ schemas/metaschema_modules_public/tables/blueprint_template/table [schemas/metaschema_modules_public/schema] 2026-03-20T00:00:00Z Constructive <developers@constructive.io> # add blueprint_template table for shareable schema recipes
37
+ schemas/metaschema_modules_public/tables/blueprint/table [schemas/metaschema_modules_public/schema schemas/metaschema_modules_public/tables/blueprint_template/table] 2026-03-20T00:00:01Z Constructive <developers@constructive.io> # add blueprint table for owned executable blueprints
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/blueprint/table from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TABLE IF EXISTS metaschema_modules_public.blueprint;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/metaschema_modules_public/tables/blueprint_template/table from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TABLE IF EXISTS metaschema_modules_public.blueprint_template;
6
+
7
+ COMMIT;
@@ -0,0 +1,26 @@
1
+ -- Verify schemas/metaschema_modules_public/tables/blueprint/table on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT
6
+ id,
7
+ owner_id,
8
+ database_id,
9
+ name,
10
+ display_name,
11
+ description,
12
+ definition,
13
+ template_id,
14
+ status,
15
+ constructed_at,
16
+ error_details,
17
+ ref_map,
18
+ constructed_definition,
19
+ definition_hash,
20
+ table_hashes,
21
+ created_at,
22
+ updated_at
23
+ FROM metaschema_modules_public.blueprint
24
+ WHERE FALSE;
25
+
26
+ ROLLBACK;
@@ -0,0 +1,29 @@
1
+ -- Verify schemas/metaschema_modules_public/tables/blueprint_template/table on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT
6
+ id,
7
+ name,
8
+ version,
9
+ display_name,
10
+ description,
11
+ owner_id,
12
+ visibility,
13
+ categories,
14
+ tags,
15
+ definition,
16
+ definition_schema_version,
17
+ source,
18
+ complexity,
19
+ copy_count,
20
+ fork_count,
21
+ forked_from_id,
22
+ definition_hash,
23
+ table_hashes,
24
+ created_at,
25
+ updated_at
26
+ FROM metaschema_modules_public.blueprint_template
27
+ WHERE FALSE;
28
+
29
+ ROLLBACK;
@@ -11,6 +11,7 @@ SELECT
11
11
  field_name,
12
12
  delete_action,
13
13
  is_required,
14
+ api_required,
14
15
  junction_table_id,
15
16
  junction_table_name,
16
17
  junction_schema_id,
@@ -11,6 +11,7 @@ SELECT
11
11
  node_type,
12
12
  use_rls,
13
13
  node_data,
14
+ fields,
14
15
  grant_roles,
15
16
  grant_privileges,
16
17
  policy_type,