@pgpm/metaschema-modules 0.26.2 → 0.26.5

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 (55) hide show
  1. package/Makefile +1 -1
  2. package/deploy/schemas/metaschema_modules_public/tables/agent_module/table.sql +35 -24
  3. package/deploy/schemas/metaschema_modules_public/tables/billing_module/table.sql +13 -0
  4. package/deploy/schemas/metaschema_modules_public/tables/billing_provider_module/table.sql +4 -0
  5. package/deploy/schemas/metaschema_modules_public/tables/compute_log_module/table.sql +7 -2
  6. package/deploy/schemas/metaschema_modules_public/tables/config_secrets_module/table.sql +82 -0
  7. package/deploy/schemas/metaschema_modules_public/tables/config_secrets_org_module/table.sql +4 -0
  8. package/deploy/schemas/metaschema_modules_public/tables/config_secrets_user_module/table.sql +4 -0
  9. package/deploy/schemas/metaschema_modules_public/tables/connected_accounts_module/table.sql +4 -0
  10. package/deploy/schemas/metaschema_modules_public/tables/crypto_addresses_module/table.sql +4 -0
  11. package/deploy/schemas/metaschema_modules_public/tables/db_usage_module/table.sql +11 -2
  12. package/deploy/schemas/metaschema_modules_public/tables/emails_module/table.sql +4 -0
  13. package/deploy/schemas/metaschema_modules_public/tables/entity_type_provision/table.sql +0 -4
  14. package/deploy/schemas/metaschema_modules_public/tables/events_module/table.sql +14 -4
  15. package/deploy/schemas/metaschema_modules_public/tables/function_module/table.sql +14 -27
  16. package/deploy/schemas/metaschema_modules_public/tables/graph_module/table.sql +10 -8
  17. package/deploy/schemas/metaschema_modules_public/tables/hierarchy_module/table.sql +10 -3
  18. package/deploy/schemas/metaschema_modules_public/tables/i18n_module/table.sql +31 -0
  19. package/deploy/schemas/metaschema_modules_public/tables/identity_providers_module/table.sql +35 -3
  20. package/deploy/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +7 -2
  21. package/deploy/schemas/metaschema_modules_public/tables/invites_module/table.sql +12 -10
  22. package/deploy/schemas/metaschema_modules_public/tables/limits_module/table.sql +10 -4
  23. package/deploy/schemas/metaschema_modules_public/tables/memberships_module/table.sql +13 -6
  24. package/deploy/schemas/metaschema_modules_public/tables/merkle_store_module/table.sql +3 -2
  25. package/deploy/schemas/metaschema_modules_public/tables/namespace_module/table.sql +13 -12
  26. package/deploy/schemas/metaschema_modules_public/tables/notifications_module/table.sql +8 -0
  27. package/deploy/schemas/metaschema_modules_public/tables/permissions_module/table.sql +12 -5
  28. package/deploy/schemas/metaschema_modules_public/tables/phone_numbers_module/table.sql +4 -0
  29. package/deploy/schemas/metaschema_modules_public/tables/plans_module/table.sql +16 -0
  30. package/deploy/schemas/metaschema_modules_public/tables/profiles_module/table.sql +10 -4
  31. package/deploy/schemas/metaschema_modules_public/tables/rate_limit_meters_module/table.sql +8 -0
  32. package/deploy/schemas/metaschema_modules_public/tables/realtime_module/table.sql +4 -0
  33. package/deploy/schemas/metaschema_modules_public/tables/rls_module/table.sql +4 -0
  34. package/deploy/schemas/metaschema_modules_public/tables/storage_log_module/table.sql +7 -2
  35. package/deploy/schemas/metaschema_modules_public/tables/storage_module/table.sql +19 -14
  36. package/deploy/schemas/metaschema_modules_public/tables/transfer_log_module/table.sql +7 -2
  37. package/deploy/schemas/metaschema_modules_public/tables/user_auth_module/table.sql +4 -0
  38. package/deploy/schemas/metaschema_modules_public/tables/user_credentials_module/table.sql +42 -0
  39. package/deploy/schemas/metaschema_modules_public/tables/user_settings_module/table.sql +34 -0
  40. package/deploy/schemas/metaschema_modules_public/tables/users_module/table.sql +4 -0
  41. package/deploy/schemas/metaschema_modules_public/tables/webauthn_credentials_module/table.sql +4 -0
  42. package/metaschema-modules.control +1 -1
  43. package/package.json +3 -3
  44. package/pgpm.plan +4 -0
  45. package/revert/schemas/metaschema_modules_public/tables/agent_chat_module/table.sql +3 -0
  46. package/revert/schemas/metaschema_modules_public/tables/config_secrets_module/table.sql +7 -0
  47. package/revert/schemas/metaschema_modules_public/tables/i18n_module/table.sql +7 -0
  48. package/revert/schemas/metaschema_modules_public/tables/user_credentials_module/table.sql +7 -0
  49. package/revert/schemas/metaschema_modules_public/tables/user_settings_module/table.sql +7 -0
  50. package/sql/{metaschema-modules--0.26.1.sql → metaschema-modules--0.26.3.sql} +318 -62
  51. package/verify/schemas/metaschema_modules_public/tables/config_secrets_module/table.sql +7 -0
  52. package/verify/schemas/metaschema_modules_public/tables/i18n_module/table.sql +9 -0
  53. package/verify/schemas/metaschema_modules_public/tables/namespace_module/table.sql +3 -1
  54. package/verify/schemas/metaschema_modules_public/tables/user_credentials_module/table.sql +7 -0
  55. package/verify/schemas/metaschema_modules_public/tables/user_settings_module/table.sql +7 -0
@@ -24,12 +24,17 @@ CREATE TABLE metaschema_modules_public.inference_log_module (
24
24
  retention text NOT NULL DEFAULT '12 months',
25
25
  premake int NOT NULL DEFAULT 2,
26
26
 
27
- -- Scope configuration: 'app' = per-app usage (actor_id RLS), 'platform' = tenant metering (database_id RLS)
27
+ -- Scope configuration: 'app' = per-app usage (actor_id RLS)
28
28
  scope text NOT NULL DEFAULT 'app',
29
29
  actor_fk_table_id uuid NULL,
30
30
  entity_fk_table_id uuid NULL,
31
31
 
32
- prefix text NULL,
32
+ -- Table name prefix. Auto-derived from scope by the trigger when empty.
33
+ prefix text NOT NULL DEFAULT '',
34
+
35
+ -- API routing (configurable per-module)
36
+ api_name text DEFAULT 'usage',
37
+ private_api_name text DEFAULT NULL,
33
38
 
34
39
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
35
40
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
@@ -21,13 +21,19 @@ CREATE TABLE metaschema_modules_public.invites_module (
21
21
  claimed_invites_table_name text NOT NULL DEFAULT '',
22
22
  submit_invite_code_function text NOT NULL DEFAULT '',
23
23
 
24
- prefix text NULL,
24
+ -- Scope: determines the security level for this module instance.
25
+ scope text NOT NULL DEFAULT 'app',
25
26
 
26
- membership_type int NOT NULL,
27
- -- if this is NOT NULL, then we add entity_id
28
- -- e.g. limits to the app itself are considered global owned by app and no explicit owner
27
+ -- Table name prefix. Auto-derived from scope by the trigger when empty.
28
+ prefix text NOT NULL DEFAULT '',
29
+
30
+ -- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
29
31
  entity_table_id uuid NULL,
30
32
 
33
+ -- API routing (configurable per-module)
34
+ api_name text DEFAULT 'admin',
35
+ private_api_name text DEFAULT NULL,
36
+
31
37
  --
32
38
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
33
39
  CONSTRAINT invites_table_fkey FOREIGN KEY (invites_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
@@ -41,12 +47,8 @@ CREATE TABLE metaschema_modules_public.invites_module (
41
47
 
42
48
  CREATE INDEX invites_module_database_id_idx ON metaschema_modules_public.invites_module ( database_id );
43
49
 
44
- -- Unique constraint on (database_id, membership_type) so the
45
- -- entity_type_provision fan-out can use ON CONFLICT DO NOTHING for idempotent
46
- -- re-provisioning. invites_module is always entity-scoped (membership_type
47
- -- is NOT NULL on this table), so no COALESCE-NULL trick is needed here,
48
- -- unlike storage_module which supports an app-level singleton row.
50
+ -- Unique constraint: one invites module per database per scope per prefix.
49
51
  CREATE UNIQUE INDEX invites_module_unique_scope
50
- ON metaschema_modules_public.invites_module (database_id, membership_type);
52
+ ON metaschema_modules_public.invites_module (database_id, scope, prefix);
51
53
 
52
54
  COMMIT;
@@ -61,16 +61,22 @@ CREATE TABLE metaschema_modules_public.limits_module (
61
61
  limit_check_soft_function text NOT NULL DEFAULT '',
62
62
  limit_aggregate_check_soft_function text NOT NULL DEFAULT '',
63
63
 
64
- prefix text NULL,
64
+ -- Scope: determines the security level for this module instance.
65
+ scope text NOT NULL DEFAULT 'app',
65
66
 
66
- membership_type int NOT NULL,
67
- -- if this is NOT NULL, then we add entity_id
68
- -- e.g. limits to the app itself are considered global owned by app and no explicit owner
67
+ -- Table name prefix. Auto-derived from scope by the trigger when empty.
68
+ prefix text NOT NULL DEFAULT '',
69
+
70
+ -- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
69
71
  entity_table_id uuid NULL,
70
72
 
71
73
  -- required tables
72
74
  actor_table_id uuid NOT NULL DEFAULT uuid_nil(),
73
75
 
76
+ -- API routing (configurable per-module)
77
+ api_name text DEFAULT 'usage',
78
+ private_api_name text DEFAULT NULL,
79
+
74
80
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
75
81
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
76
82
  CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
@@ -41,15 +41,16 @@ CREATE TABLE metaschema_modules_public.memberships_module (
41
41
  owner_grants_table_id uuid NOT NULL DEFAULT uuid_nil(),
42
42
  owner_grants_table_name text NOT NULL DEFAULT '',
43
43
 
44
- membership_type int NOT NULL,
44
+ -- Scope: determines the security level for this module instance.
45
+ scope text NOT NULL DEFAULT 'app',
45
46
 
46
- -- if this is NOT NULL, then we add entity_id
47
- -- e.g. memberships to the app itself are considered global owned by app and no explicit owner
47
+ -- Table name prefix. Auto-derived from scope by the trigger when empty.
48
+ prefix text NOT NULL DEFAULT '',
49
+
50
+ -- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
48
51
  entity_table_id uuid NULL,
49
52
  entity_table_owner_id uuid NULL,
50
53
 
51
- prefix text NULL,
52
-
53
54
  -- Populated by memberships_module generator when get_organization_id is created
54
55
  get_org_fn text NULL,
55
56
 
@@ -65,6 +66,10 @@ CREATE TABLE metaschema_modules_public.memberships_module (
65
66
 
66
67
  --
67
68
 
69
+ -- API routing (configurable per-module)
70
+ api_name text DEFAULT 'admin',
71
+ private_api_name text DEFAULT NULL,
72
+
68
73
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
69
74
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
70
75
  CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
@@ -83,7 +88,9 @@ CREATE TABLE metaschema_modules_public.memberships_module (
83
88
  CONSTRAINT default_limits_table_fkey FOREIGN KEY (default_limits_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
84
89
 
85
90
  CONSTRAINT permissions_table_fkey FOREIGN KEY (permissions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
86
- CONSTRAINT default_permissions_table_fkey FOREIGN KEY (default_permissions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
91
+ CONSTRAINT default_permissions_table_fkey FOREIGN KEY (default_permissions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
92
+
93
+ CONSTRAINT memberships_module_unique UNIQUE (database_id, scope, prefix)
87
94
  );
88
95
 
89
96
  CREATE INDEX memberships_module_database_id_idx ON metaschema_modules_public.memberships_module ( database_id );
@@ -30,8 +30,9 @@ CREATE TABLE metaschema_modules_public.merkle_store_module (
30
30
  api_name text,
31
31
  private_api_name text,
32
32
 
33
- -- Scope field name (column used for multi-tenant isolation)
34
- scope_field text NOT NULL DEFAULT 'scope_id',
33
+ -- Scope: 'app' for app-level, 'platform' for database-scoped with
34
+ -- RLS through metaschema_public.database ownership.
35
+ scope text NOT NULL DEFAULT 'app',
35
36
 
36
37
  -- Timestamps
37
38
  created_at timestamptz NOT NULL DEFAULT now(),
@@ -28,19 +28,18 @@ CREATE TABLE metaschema_modules_public.namespace_module (
28
28
  api_name text,
29
29
  private_api_name text,
30
30
 
31
- -- Multi-tenant namespace identity
32
- membership_type int DEFAULT NULL, -- NULL = database-root (AuthzMembership via app_sprt), non-NULL = entity-scoped (AuthzEntityMembership)
31
+ -- Scope: determines the security level for this module instance.
32
+ -- Resolved to a membership_type integer at trigger time via membership_types table.
33
+ scope text NOT NULL DEFAULT 'app',
33
34
 
34
- -- Module key discriminator: allows multiple namespace modules per scope.
35
- -- 'default' is omitted from table names, any other value becomes
36
- -- an infix: {prefix}_{key}_namespaces.
37
- -- Max 16 chars, lowercase snake_case.
38
- key text NOT NULL DEFAULT 'default',
35
+ -- Table name prefix. Auto-derived from scope by the trigger when empty.
36
+ -- Override to create multiple module instances at the same scope.
37
+ prefix text NOT NULL DEFAULT '',
39
38
 
40
39
  -- Entity table for RLS (NULL for app-level namespaces, entity table for entity-scoped namespaces)
41
40
  entity_table_id uuid NULL,
42
41
 
43
- -- Configurable security policies (NULL = use defaults based on membership_type).
42
+ -- Configurable security policies (NULL = use defaults based on scope).
44
43
  -- When provided, replaces the default policy set in apply_namespace_security.
45
44
  -- Accepts a JSON array of policy objects:
46
45
  -- {"$type": "AuthzEntityMembership", "privileges": ["select", "update"], "data": {...}}
@@ -52,6 +51,10 @@ CREATE TABLE metaschema_modules_public.namespace_module (
52
51
  -- secure_table_provision applies the custom grants/policies instead.
53
52
  provisions jsonb NULL,
54
53
 
54
+ -- Default permissions: permission names auto-granted to new members.
55
+ -- NULL uses the module's built-in defaults; explicit array overrides them.
56
+ default_permissions text[] DEFAULT NULL,
57
+
55
58
  -- Constraints
56
59
  CONSTRAINT namespace_module_db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
57
60
  CONSTRAINT namespace_module_schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
@@ -63,9 +66,7 @@ CREATE TABLE metaschema_modules_public.namespace_module (
63
66
 
64
67
  CREATE INDEX namespace_module_database_id_idx ON metaschema_modules_public.namespace_module ( database_id );
65
68
 
66
- -- Unique constraint on (database_id, membership_type, key) using COALESCE to handle NULLs.
67
- -- NULL membership_type = app-level, non-NULL = entity-scoped. key discriminates
68
- -- multiple namespace modules for the same scope (e.g. 'config' + 'content').
69
- CREATE UNIQUE INDEX namespace_module_unique_scope ON metaschema_modules_public.namespace_module ( database_id, COALESCE(membership_type, -1), key );
69
+ -- Unique constraint: one namespace module per database per scope per prefix.
70
+ CREATE UNIQUE INDEX namespace_module_unique_scope ON metaschema_modules_public.namespace_module ( database_id, scope, prefix );
70
71
 
71
72
  COMMIT;
@@ -36,6 +36,14 @@ CREATE TABLE metaschema_modules_public.notifications_module (
36
36
  has_digest_metadata boolean NOT NULL DEFAULT false,
37
37
  has_subscriptions boolean NOT NULL DEFAULT false,
38
38
 
39
+ -- Default permissions: permission names auto-granted to new members.
40
+ -- NULL uses the module's built-in defaults; explicit array overrides them.
41
+ default_permissions text[] DEFAULT NULL,
42
+
43
+ -- API routing (configurable per-module)
44
+ api_name text DEFAULT 'notifications',
45
+ private_api_name text DEFAULT NULL,
46
+
39
47
  --
40
48
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
41
49
  CONSTRAINT notifications_table_fkey FOREIGN KEY (notifications_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
@@ -42,16 +42,19 @@ CREATE TABLE metaschema_modules_public.permissions_module (
42
42
  -- Existing databases are unaffected; this only changes the default for
43
43
  -- newly inserted permissions_module rows.
44
44
  bitlen int NOT NULL DEFAULT 64,
45
- membership_type int NOT NULL,
46
- -- if this is NOT NULL, then we add entity_id
47
- -- e.g. limits to the app itself are considered global owned by app and no explicit owner
45
+
46
+ -- Scope: determines the security level for this module instance.
47
+ scope text NOT NULL DEFAULT 'app',
48
+
49
+ -- Table name prefix. Auto-derived from scope by the trigger when empty.
50
+ prefix text NOT NULL DEFAULT '',
51
+
52
+ -- Entity table for RLS (NULL for app-level, entity table for entity-scoped)
48
53
  entity_table_id uuid NULL,
49
54
 
50
55
  -- required tables
51
56
  actor_table_id uuid NOT NULL DEFAULT uuid_nil(),
52
57
 
53
- prefix text NULL,
54
-
55
58
  --
56
59
 
57
60
  get_padded_mask text NOT NULL DEFAULT '',
@@ -61,6 +64,10 @@ CREATE TABLE metaschema_modules_public.permissions_module (
61
64
 
62
65
  --
63
66
 
67
+ -- API routing (configurable per-module)
68
+ api_name text DEFAULT 'admin',
69
+ private_api_name text DEFAULT NULL,
70
+
64
71
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
65
72
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
66
73
  CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
@@ -16,6 +16,10 @@ CREATE TABLE metaschema_modules_public.phone_numbers_module (
16
16
 
17
17
  table_name text NOT NULL,
18
18
 
19
+ -- API routing (configurable per-module)
20
+ api_name text DEFAULT 'auth',
21
+ private_api_name text DEFAULT NULL,
22
+
19
23
  --
20
24
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
21
25
  CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
@@ -25,12 +25,26 @@ CREATE TABLE metaschema_modules_public.plans_module (
25
25
  -- Plan overrides table: per-entity custom limit overrides
26
26
  plan_overrides_table_id uuid NULL,
27
27
 
28
+ -- Plan meter limits table: maps plan → meter slug → billing quota
29
+ plan_meter_limits_table_id uuid NULL,
30
+
31
+ -- Plan caps table: maps plan → cap name → cap value (feature flags)
32
+ plan_caps_table_id uuid NULL,
33
+
28
34
  -- Generated apply_plan functions (one per limits scope)
29
35
  apply_plan_function text NOT NULL DEFAULT '',
30
36
  apply_plan_aggregate_function text NOT NULL DEFAULT '',
31
37
 
38
+ -- Generated apply functions for billing and caps (set when respective modules are installed)
39
+ apply_billing_plan_function text NULL,
40
+ apply_plan_caps_function text NULL,
41
+
32
42
  prefix text NULL,
33
43
 
44
+ -- API routing (configurable per-module)
45
+ api_name text DEFAULT 'usage',
46
+ private_api_name text DEFAULT NULL,
47
+
34
48
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
35
49
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
36
50
  CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
@@ -38,6 +52,8 @@ CREATE TABLE metaschema_modules_public.plans_module (
38
52
  CONSTRAINT plan_limits_table_fkey FOREIGN KEY (plan_limits_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
39
53
  CONSTRAINT plan_pricing_table_fkey FOREIGN KEY (plan_pricing_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
40
54
  CONSTRAINT plan_overrides_table_fkey FOREIGN KEY (plan_overrides_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
55
+ CONSTRAINT plan_meter_limits_table_fkey FOREIGN KEY (plan_meter_limits_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
56
+ CONSTRAINT plan_caps_table_fkey FOREIGN KEY (plan_caps_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
41
57
  CONSTRAINT plans_module_database_id_unique UNIQUE (database_id)
42
58
  );
43
59
 
@@ -31,7 +31,11 @@ CREATE TABLE metaschema_modules_public.profiles_module (
31
31
  profile_templates_table_id uuid NOT NULL DEFAULT uuid_nil(),
32
32
  profile_templates_table_name text NOT NULL DEFAULT '',
33
33
 
34
- membership_type int NOT NULL,
34
+ -- Scope: determines the security level for this module instance.
35
+ scope text NOT NULL DEFAULT 'app',
36
+
37
+ -- Table name prefix. Auto-derived from scope by the trigger when empty.
38
+ prefix text NOT NULL DEFAULT '',
35
39
 
36
40
  -- Entity table for org/group scoped profiles (NULL for app-level)
37
41
  entity_table_id uuid NULL,
@@ -41,8 +45,10 @@ CREATE TABLE metaschema_modules_public.profiles_module (
41
45
  permissions_table_id uuid NOT NULL DEFAULT uuid_nil(),
42
46
  memberships_table_id uuid NOT NULL DEFAULT uuid_nil(),
43
47
 
44
- prefix text NULL,
45
-
48
+ -- API routing (configurable per-module)
49
+ api_name text DEFAULT 'admin',
50
+ private_api_name text DEFAULT NULL,
51
+
46
52
  --
47
53
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
48
54
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
@@ -57,7 +63,7 @@ CREATE TABLE metaschema_modules_public.profiles_module (
57
63
  CONSTRAINT permissions_table_fkey FOREIGN KEY (permissions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
58
64
  CONSTRAINT memberships_table_fkey FOREIGN KEY (memberships_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
59
65
 
60
- CONSTRAINT profiles_module_unique UNIQUE (database_id, membership_type)
66
+ CONSTRAINT profiles_module_unique UNIQUE (database_id, scope, prefix)
61
67
  );
62
68
 
63
69
  CREATE INDEX profiles_module_database_id_idx ON metaschema_modules_public.profiles_module ( database_id );
@@ -30,6 +30,14 @@ CREATE TABLE metaschema_modules_public.rate_limit_meters_module (
30
30
 
31
31
  prefix text NULL,
32
32
 
33
+ -- Default permissions: permission names auto-granted to new members.
34
+ -- NULL uses the module's built-in defaults; explicit array overrides them.
35
+ default_permissions text[] DEFAULT NULL,
36
+
37
+ -- API routing (configurable per-module)
38
+ api_name text DEFAULT 'usage',
39
+ private_api_name text DEFAULT NULL,
40
+
33
41
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
34
42
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
35
43
  CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
@@ -27,6 +27,10 @@ CREATE TABLE metaschema_modules_public.realtime_module (
27
27
  notify_channel text NULL,
28
28
 
29
29
  -- Constraints
30
+ -- API routing (configurable per-module)
31
+ api_name text DEFAULT 'realtime',
32
+ private_api_name text DEFAULT NULL,
33
+
30
34
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
31
35
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
32
36
  CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
@@ -22,6 +22,10 @@ CREATE TABLE metaschema_modules_public.rls_module (
22
22
  "current_role" text NOT NULL DEFAULT 'current_user',
23
23
  current_role_id text NOT NULL DEFAULT 'current_user_id',
24
24
 
25
+ -- API routing (configurable per-module)
26
+ api_name text DEFAULT 'auth',
27
+ private_api_name text DEFAULT NULL,
28
+
25
29
  --
26
30
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
27
31
  CONSTRAINT session_credentials_table_fkey FOREIGN KEY (session_credentials_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
@@ -24,12 +24,17 @@ CREATE TABLE metaschema_modules_public.storage_log_module (
24
24
  retention text NOT NULL DEFAULT '12 months',
25
25
  premake int NOT NULL DEFAULT 2,
26
26
 
27
- -- Scope configuration: 'app' = per-app usage (actor_id RLS), 'platform' = tenant metering (database_id RLS)
27
+ -- Scope configuration: 'app' = per-app usage (actor_id RLS)
28
28
  scope text NOT NULL DEFAULT 'app',
29
29
  actor_fk_table_id uuid NULL,
30
30
  entity_fk_table_id uuid NULL,
31
31
 
32
- prefix text NULL,
32
+ -- Table name prefix. Auto-derived from scope by the trigger when empty.
33
+ prefix text NOT NULL DEFAULT '',
34
+
35
+ -- API routing (configurable per-module)
36
+ api_name text DEFAULT 'usage',
37
+ private_api_name text DEFAULT NULL,
33
38
 
34
39
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
35
40
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
@@ -17,19 +17,18 @@ CREATE TABLE metaschema_modules_public.storage_module (
17
17
  files_table_id uuid NOT NULL DEFAULT uuid_nil(),
18
18
 
19
19
  -- Table names (input to the generator)
20
- buckets_table_name text NOT NULL DEFAULT 'app_buckets',
21
- files_table_name text NOT NULL DEFAULT 'app_files',
20
+ buckets_table_name text NOT NULL DEFAULT 'buckets',
21
+ files_table_name text NOT NULL DEFAULT 'files',
22
22
 
23
- -- Multi-tenant storage identity
24
- membership_type int DEFAULT NULL, -- NULL = global gate (AuthzMembership via app_sprt), non-NULL = entity-scoped (AuthzEntityMembership)
23
+ -- Scope: determines the security level for this module instance.
24
+ -- Resolved to a membership_type integer at trigger time via membership_types table.
25
+ scope text NOT NULL DEFAULT 'app',
25
26
 
26
- -- Module key discriminator: allows multiple storage modules per entity type.
27
- -- 'default' is omitted from table names (backward compat), any other value becomes
28
- -- an infix: {prefix}_{key}_{buckets|files}.
29
- -- Max 16 chars, lowercase snake_case, cannot be 'buckets'/'files'/'bucket'/'file'.
30
- key text NOT NULL DEFAULT 'default',
27
+ -- Table name prefix. Auto-derived from scope by the trigger when empty.
28
+ -- Override to create multiple module instances at the same scope.
29
+ prefix text NOT NULL DEFAULT '',
31
30
 
32
- -- Configurable security policies (NULL = use defaults based on membership_type).
31
+ -- Configurable security policies (NULL = use defaults based on scope).
33
32
  -- When provided, replaces the default policy set in apply_storage_security.
34
33
  -- Accepts a JSON array of policy objects:
35
34
  -- {"$type": "AuthzEntityMembership", "privileges": ["select", "update"], "data": {...}}
@@ -87,7 +86,15 @@ CREATE TABLE metaschema_modules_public.storage_module (
87
86
  -- Generated table ID for file_events (populated by the generator when has_audit_log=true)
88
87
  file_events_table_id uuid NULL DEFAULT NULL,
89
88
 
89
+ -- Default permissions: permission names auto-granted to new members.
90
+ -- NULL uses the module's built-in defaults; explicit array overrides them.
91
+ default_permissions text[] DEFAULT NULL,
92
+
90
93
  -- Constraints
94
+ -- API routing (configurable per-module)
95
+ api_name text DEFAULT 'admin',
96
+ private_api_name text DEFAULT NULL,
97
+
91
98
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
92
99
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
93
100
  CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
@@ -100,9 +107,7 @@ CREATE TABLE metaschema_modules_public.storage_module (
100
107
 
101
108
  CREATE INDEX storage_module_database_id_idx ON metaschema_modules_public.storage_module ( database_id );
102
109
 
103
- -- Unique constraint on (database_id, membership_type, key) using COALESCE to handle NULLs.
104
- -- NULL membership_type = app-level, non-NULL = entity-scoped. key discriminates
105
- -- multiple storage modules for the same entity type (e.g. 'default' + 'fn').
106
- CREATE UNIQUE INDEX storage_module_unique_scope ON metaschema_modules_public.storage_module ( database_id, COALESCE(membership_type, -1), key );
110
+ -- Unique constraint: one storage module per database per scope per prefix.
111
+ CREATE UNIQUE INDEX storage_module_unique_scope ON metaschema_modules_public.storage_module ( database_id, scope, prefix );
107
112
 
108
113
  COMMIT;
@@ -24,12 +24,17 @@ CREATE TABLE metaschema_modules_public.transfer_log_module (
24
24
  retention text NOT NULL DEFAULT '12 months',
25
25
  premake int NOT NULL DEFAULT 2,
26
26
 
27
- -- Scope configuration: 'app' = per-app usage (actor_id RLS), 'platform' = tenant metering (database_id RLS)
27
+ -- Scope configuration: 'app' = per-app usage (actor_id RLS)
28
28
  scope text NOT NULL DEFAULT 'app',
29
29
  actor_fk_table_id uuid NULL,
30
30
  entity_fk_table_id uuid NULL,
31
31
 
32
- prefix text NULL,
32
+ -- Table name prefix. Auto-derived from scope by the trigger when empty.
33
+ prefix text NOT NULL DEFAULT '',
34
+
35
+ -- API routing (configurable per-module)
36
+ api_name text DEFAULT 'usage',
37
+ private_api_name text DEFAULT NULL,
33
38
 
34
39
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
35
40
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
@@ -44,6 +44,10 @@ CREATE TABLE metaschema_modules_public.user_auth_module (
44
44
 
45
45
  -- UNIQUE(api_id),
46
46
 
47
+ -- API routing (configurable per-module)
48
+ api_name text DEFAULT 'auth',
49
+ private_api_name text DEFAULT NULL,
50
+
47
51
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
48
52
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
49
53
  CONSTRAINT email_table_fkey FOREIGN KEY (emails_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
@@ -0,0 +1,42 @@
1
+ -- Deploy schemas/metaschema_modules_public/tables/user_credentials_module/table to pg
2
+
3
+ -- requires: schemas/metaschema_modules_public/schema
4
+
5
+ BEGIN;
6
+
7
+ CREATE TABLE metaschema_modules_public.user_credentials_module (
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
+ database_id uuid NOT NULL,
10
+
11
+ -- Schema references (resolved by BEFORE INSERT trigger when uuid_nil)
12
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
+
14
+ -- Generated table ID (populated by the generator)
15
+ table_id uuid NOT NULL DEFAULT uuid_nil(),
16
+
17
+ -- Table name (input — defaults to 'user_secrets')
18
+ table_name text NOT NULL DEFAULT 'user_secrets',
19
+
20
+ -- API routing (get-or-create: if set, schema is added to this API)
21
+ api_name text DEFAULT 'config',
22
+ private_api_name text DEFAULT NULL,
23
+
24
+ -- Constraints
25
+ CONSTRAINT user_credentials_module_db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
26
+ CONSTRAINT user_credentials_module_schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
27
+ CONSTRAINT user_credentials_module_table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
28
+ );
29
+
30
+ CREATE INDEX user_credentials_module_database_id_idx ON metaschema_modules_public.user_credentials_module ( database_id );
31
+ CREATE INDEX user_credentials_module_schema_id_idx ON metaschema_modules_public.user_credentials_module ( schema_id );
32
+ CREATE INDEX user_credentials_module_table_id_idx ON metaschema_modules_public.user_credentials_module ( table_id );
33
+
34
+ -- One user_credentials_module per database.
35
+ CREATE UNIQUE INDEX user_credentials_module_unique ON metaschema_modules_public.user_credentials_module ( database_id );
36
+
37
+ COMMENT ON TABLE metaschema_modules_public.user_credentials_module IS
38
+ 'Per-user bcrypt credential store (password hashes, API key hashes).
39
+ Always user-scoped with AuthzDirectOwner RLS. Consumed by user_auth_module,
40
+ identity_providers_module, and bootstrap procedures.';
41
+
42
+ COMMIT;
@@ -0,0 +1,34 @@
1
+ -- Deploy schemas/metaschema_modules_public/tables/user_settings_module/table to pg
2
+
3
+ -- requires: schemas/metaschema_modules_public/schema
4
+
5
+ BEGIN;
6
+
7
+ CREATE TABLE metaschema_modules_public.user_settings_module (
8
+ id uuid PRIMARY KEY DEFAULT uuidv7(),
9
+ database_id uuid NOT NULL,
10
+
11
+ -- Schema reference (populated by the insert trigger)
12
+ schema_id uuid NOT NULL DEFAULT uuid_nil(),
13
+
14
+ -- Table reference (populated by the generator)
15
+ table_id uuid NOT NULL DEFAULT uuid_nil(),
16
+
17
+ -- Owner table reference (resolved to users table by trigger)
18
+ owner_table_id uuid NOT NULL DEFAULT uuid_nil(),
19
+
20
+ table_name text NOT NULL DEFAULT 'user_settings',
21
+
22
+ -- API routing (configurable per-module)
23
+ api_name text DEFAULT NULL,
24
+
25
+ CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
26
+ CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
27
+ CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
28
+ CONSTRAINT owner_table_fkey FOREIGN KEY (owner_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
29
+ );
30
+
31
+ CREATE INDEX user_settings_module_database_id_idx ON metaschema_modules_public.user_settings_module ( database_id );
32
+ CREATE UNIQUE INDEX user_settings_module_unique_per_db ON metaschema_modules_public.user_settings_module ( database_id );
33
+
34
+ COMMIT;
@@ -18,6 +18,10 @@ CREATE TABLE metaschema_modules_public.users_module (
18
18
  type_table_name text NOT NULL DEFAULT 'role_types',
19
19
  --
20
20
 
21
+ -- API routing (configurable per-module)
22
+ api_name text DEFAULT 'auth',
23
+ private_api_name text DEFAULT NULL,
24
+
21
25
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
22
26
  CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
23
27
  CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
@@ -16,6 +16,10 @@ CREATE TABLE metaschema_modules_public.webauthn_credentials_module (
16
16
 
17
17
  table_name text NOT NULL DEFAULT 'webauthn_credentials',
18
18
 
19
+ -- API routing (configurable per-module)
20
+ api_name text DEFAULT 'auth',
21
+ private_api_name text DEFAULT NULL,
22
+
19
23
  --
20
24
  CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
21
25
  CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
@@ -1,6 +1,6 @@
1
1
  # metaschema-modules extension
2
2
  comment = 'metaschema-modules extension'
3
- default_version = '0.26.1'
3
+ default_version = '0.26.3'
4
4
  module_pathname = '$libdir/metaschema-modules'
5
5
  requires = 'plpgsql,uuid-ossp,metaschema-schema,services,pgpm-verify'
6
6
  relocatable = false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpm/metaschema-modules",
3
- "version": "0.26.2",
3
+ "version": "0.26.5",
4
4
  "description": "Module metadata handling and dependency tracking",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "contributors": [
@@ -21,7 +21,7 @@
21
21
  "test:watch": "jest --watch"
22
22
  },
23
23
  "dependencies": {
24
- "@pgpm/metaschema-schema": "0.26.2",
24
+ "@pgpm/metaschema-schema": "0.26.5",
25
25
  "@pgpm/verify": "0.26.0"
26
26
  },
27
27
  "devDependencies": {
@@ -35,5 +35,5 @@
35
35
  "bugs": {
36
36
  "url": "https://github.com/constructive-io/pgpm-modules/issues"
37
37
  },
38
- "gitHead": "d938867e5d7c0e7b2e130a2bdc5d58cd0d5874e1"
38
+ "gitHead": "a496a00d89c37d874f4a7207265b9972b6f05c7d"
39
39
  }
package/pgpm.plan CHANGED
@@ -60,4 +60,8 @@ schemas/metaschema_modules_public/tables/merkle_store_module/table [schemas/meta
60
60
  schemas/metaschema_modules_public/tables/graph_module/table [schemas/metaschema_modules_public/schema schemas/metaschema_modules_public/tables/merkle_store_module/table] 2026-05-21T01:00:00Z devin <devin@cognition.ai> # add graph_module config table for FBP graph utilities on top of merkle store
61
61
  schemas/metaschema_modules_public/tables/namespace_module/table [schemas/metaschema_modules_public/schema] 2026-05-21T02:00:00Z devin <devin@cognition.ai> # add namespace_module config table for entity-aware namespace provisioning
62
62
  schemas/metaschema_modules_public/tables/function_module/table [schemas/metaschema_modules_public/schema] 2026-05-21T03:00:00Z devin <devin@cognition.ai> # add function_module config table for entity-aware function definitions
63
+ schemas/metaschema_modules_public/tables/config_secrets_module/table [schemas/metaschema_modules_public/schema] 2026-05-29T00:00:00Z devin <devin@cognition.ai> # add entity-aware config_secrets_module (replaces config_secrets_user_module + config_secrets_org_module)
64
+ schemas/metaschema_modules_public/tables/user_credentials_module/table [schemas/metaschema_modules_public/schema] 2026-05-30T00:00:00Z devin <devin@cognition.ai> # add user_credentials_module for per-user bcrypt credential store (split from config_secrets_module)
65
+ schemas/metaschema_modules_public/tables/user_settings_module/table [schemas/metaschema_modules_public/schema] 2026-05-28T00:00:00Z devin <devin@cognition.ai> # add user_settings_module for extensible per-user preferences (1:1 with users)
63
66
 
67
+ schemas/metaschema_modules_public/tables/i18n_module/table [schemas/metaschema_modules_public/schema] 2026-05-28T00:00:00Z devin <devin@cognition.ai> # add i18n_module config table for internationalization settings