@pgpm/metaschema-modules 0.23.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/deploy/schemas/metaschema_modules_public/tables/billing_module/table.sql +5 -0
- package/deploy/schemas/metaschema_modules_public/tables/config_secrets_org_module/table.sql +28 -0
- package/deploy/schemas/metaschema_modules_public/tables/{encrypted_secrets_module → config_secrets_user_module}/table.sql +4 -4
- package/deploy/schemas/metaschema_modules_public/tables/entity_type_provision/table.sql +44 -33
- package/deploy/schemas/metaschema_modules_public/tables/events_module/table.sql +85 -0
- package/deploy/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +39 -0
- package/deploy/schemas/metaschema_modules_public/tables/limits_module/table.sql +11 -1
- package/deploy/schemas/metaschema_modules_public/tables/rate_limit_meters_module/table.sql +51 -0
- package/deploy/schemas/metaschema_modules_public/tables/realtime_module/table.sql +2 -2
- package/deploy/schemas/metaschema_modules_public/tables/storage_module/table.sql +12 -3
- package/deploy/schemas/metaschema_modules_public/tables/{secrets_module → user_state_module}/table.sql +4 -4
- package/package.json +4 -4
- package/pgpm.plan +6 -3
- package/revert/schemas/metaschema_modules_public/tables/config_secrets_org_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/config_secrets_user_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/events_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +3 -0
- package/revert/schemas/metaschema_modules_public/tables/rate_limit_meters_module/table.sql +7 -0
- package/revert/schemas/metaschema_modules_public/tables/user_state_module/table.sql +7 -0
- package/sql/metaschema-modules--0.15.5.sql +325 -195
- package/verify/schemas/metaschema_modules_public/tables/config_secrets_org_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/config_secrets_user_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/events_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/inference_log_module/table.sql +21 -0
- package/verify/schemas/metaschema_modules_public/tables/rate_limit_meters_module/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/user_state_module/table.sql +7 -0
- package/deploy/schemas/metaschema_modules_public/tables/levels_module/table.sql +0 -64
- package/deploy/schemas/metaschema_modules_public/tables/table_template_module/table.sql +0 -43
- package/revert/schemas/metaschema_modules_public/tables/encrypted_secrets_module/table.sql +0 -7
- package/revert/schemas/metaschema_modules_public/tables/levels_module/table.sql +0 -7
- package/revert/schemas/metaschema_modules_public/tables/secrets_module/table.sql +0 -7
- package/revert/schemas/metaschema_modules_public/tables/table_template_module/table.sql +0 -7
- package/verify/schemas/metaschema_modules_public/tables/encrypted_secrets_module/table.sql +0 -7
- package/verify/schemas/metaschema_modules_public/tables/levels_module/table.sql +0 -7
- package/verify/schemas/metaschema_modules_public/tables/secrets_module/table.sql +0 -7
- package/verify/schemas/metaschema_modules_public/tables/table_template_module/table.sql +0 -18
package/README.md
CHANGED
|
@@ -95,7 +95,7 @@ The package provides metadata tables for the following modules:
|
|
|
95
95
|
- **permissions_module**: Permission system configuration
|
|
96
96
|
- **memberships_module**: Membership management settings
|
|
97
97
|
- **membership_types_module**: Membership type definitions
|
|
98
|
-
- **
|
|
98
|
+
- **events_module**: User level configurations
|
|
99
99
|
|
|
100
100
|
### Security
|
|
101
101
|
- **encrypted_secrets_module**: Encrypted secrets configuration
|
|
@@ -27,6 +27,10 @@ CREATE TABLE metaschema_modules_public.billing_module (
|
|
|
27
27
|
balances_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
28
28
|
balances_table_name text NOT NULL DEFAULT '',
|
|
29
29
|
|
|
30
|
+
-- Meter credits table: append-only credit grants for billing meters
|
|
31
|
+
meter_credits_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
32
|
+
meter_credits_table_name text NOT NULL DEFAULT '',
|
|
33
|
+
|
|
30
34
|
-- Generated functions
|
|
31
35
|
record_usage_function text NOT NULL DEFAULT '',
|
|
32
36
|
|
|
@@ -39,6 +43,7 @@ CREATE TABLE metaschema_modules_public.billing_module (
|
|
|
39
43
|
CONSTRAINT plan_subscriptions_table_fkey FOREIGN KEY (plan_subscriptions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
40
44
|
CONSTRAINT ledger_table_fkey FOREIGN KEY (ledger_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
41
45
|
CONSTRAINT balances_table_fkey FOREIGN KEY (balances_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
46
|
+
CONSTRAINT meter_credits_table_fkey FOREIGN KEY (meter_credits_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
42
47
|
CONSTRAINT billing_module_database_id_unique UNIQUE (database_id)
|
|
43
48
|
);
|
|
44
49
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/config_secrets_org_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.config_secrets_org_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
--
|
|
12
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
14
|
+
table_name text NOT NULL DEFAULT 'org_secrets',
|
|
15
|
+
--
|
|
16
|
+
|
|
17
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
18
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
19
|
+
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE INDEX config_secrets_org_module_database_id_idx ON metaschema_modules_public.config_secrets_org_module ( database_id );
|
|
23
|
+
CREATE INDEX config_secrets_org_module_schema_id_idx ON metaschema_modules_public.config_secrets_org_module ( schema_id );
|
|
24
|
+
CREATE INDEX config_secrets_org_module_table_id_idx ON metaschema_modules_public.config_secrets_org_module ( table_id );
|
|
25
|
+
|
|
26
|
+
COMMENT ON TABLE metaschema_modules_public.config_secrets_org_module IS 'Config row for the config_secrets_org_module, which provisions an organization-scoped encrypted key-value secrets store with manage_secrets permission and entity-membership RLS.';
|
|
27
|
+
|
|
28
|
+
COMMIT;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
-- Deploy schemas/metaschema_modules_public/tables/
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/config_secrets_user_module/table to pg
|
|
2
2
|
|
|
3
3
|
-- requires: schemas/metaschema_modules_public/schema
|
|
4
4
|
|
|
5
5
|
BEGIN;
|
|
6
6
|
|
|
7
|
-
CREATE TABLE metaschema_modules_public.
|
|
7
|
+
CREATE TABLE metaschema_modules_public.config_secrets_user_module (
|
|
8
8
|
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
9
|
database_id uuid NOT NULL,
|
|
10
10
|
|
|
11
11
|
--
|
|
12
12
|
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
13
|
table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
14
|
-
table_name text NOT NULL DEFAULT '
|
|
14
|
+
table_name text NOT NULL DEFAULT 'user_secrets',
|
|
15
15
|
--
|
|
16
16
|
|
|
17
17
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
@@ -19,6 +19,6 @@ CREATE TABLE metaschema_modules_public.encrypted_secrets_module (
|
|
|
19
19
|
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
-
CREATE INDEX
|
|
22
|
+
CREATE INDEX config_secrets_user_module_database_id_idx ON metaschema_modules_public.config_secrets_user_module ( database_id );
|
|
23
23
|
|
|
24
24
|
COMMIT;
|
|
@@ -51,9 +51,13 @@ CREATE TABLE metaschema_modules_public.entity_type_provision (
|
|
|
51
51
|
|
|
52
52
|
has_invites boolean NOT NULL DEFAULT false,
|
|
53
53
|
|
|
54
|
+
has_invite_achievements boolean NOT NULL DEFAULT false,
|
|
55
|
+
|
|
54
56
|
-- =========================================================================
|
|
55
|
-
-- Storage configuration:
|
|
56
|
-
--
|
|
57
|
+
-- Storage configuration: JSON array of storage module definitions.
|
|
58
|
+
-- Each element provisions a separate storage module with its own tables,
|
|
59
|
+
-- RLS policies, and feature flags. Only used when has_storage = true.
|
|
60
|
+
-- NULL = provision a single default storage module with default settings.
|
|
57
61
|
-- =========================================================================
|
|
58
62
|
|
|
59
63
|
storage_config jsonb DEFAULT NULL,
|
|
@@ -197,7 +201,7 @@ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_profiles I
|
|
|
197
201
|
When true, creates profile tables and applies profiles security.';
|
|
198
202
|
|
|
199
203
|
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_levels IS
|
|
200
|
-
'Whether to provision
|
|
204
|
+
'Whether to provision events_module for this type. Defaults to false.
|
|
201
205
|
Levels provide gamification/achievement tracking for members.
|
|
202
206
|
When true, creates level steps, achievements, and level tables with security.';
|
|
203
207
|
|
|
@@ -216,6 +220,15 @@ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_invites IS
|
|
|
216
220
|
UNIQUE (database_id, membership_type) constraint on invites_module combined with
|
|
217
221
|
ON CONFLICT DO NOTHING in the fan-out makes repeated INSERTs safe.';
|
|
218
222
|
|
|
223
|
+
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.has_invite_achievements IS
|
|
224
|
+
'Whether to auto-attach an EventTracker to the claimed_invites table for invite-based
|
|
225
|
+
achievements. Defaults to false. Requires has_invites=true AND has_levels=true.
|
|
226
|
+
When true, the trigger calls event_tracker() on the claimed_invites table with
|
|
227
|
+
event_name=''invite_claimed'', actor_field=''sender_id'', events=[''INSERT''],
|
|
228
|
+
crediting the SENDER (inviter) when someone claims their invite code.
|
|
229
|
+
Developers can then define achievements in the blueprint achievements[] section
|
|
230
|
+
that reference the ''invite_claimed'' event (e.g., "Invite 5 friends" = count: 5).';
|
|
231
|
+
|
|
219
232
|
-- =============================================================================
|
|
220
233
|
-- Escape hatch
|
|
221
234
|
-- =============================================================================
|
|
@@ -284,36 +297,34 @@ COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_installed_
|
|
|
284
297
|
Populated by the trigger. Useful for verifying which modules were provisioned.';
|
|
285
298
|
|
|
286
299
|
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.storage_config IS
|
|
287
|
-
'Optional
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
299
|
-
-
|
|
300
|
-
-
|
|
301
|
-
-
|
|
302
|
-
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
Example:
|
|
316
|
-
storage_config := ''{"buckets": [{"name": "documents", "is_public": false, "allowed_mime_types": ["application/pdf"]}], "provisions": {"files": {"nodes": [{"$type": "SearchBm25", "data": {"source_fields": ["description"]}}]}}}''::jsonb';
|
|
300
|
+
'Optional JSON array of storage module definitions. Each element provisions a separate
|
|
301
|
+
storage module with its own tables ({prefix}_{storage_key}_buckets/files), RLS policies,
|
|
302
|
+
and feature flags. Only used when has_storage = true; ignored otherwise.
|
|
303
|
+
NULL = provision a single default storage module with all defaults.
|
|
304
|
+
Each array element recognizes (all optional):
|
|
305
|
+
- storage_key (text) module discriminator, max 16 chars, lowercase snake_case.
|
|
306
|
+
Defaults to ''default'' (omitted from table names).
|
|
307
|
+
Non-default keys become infixes: {prefix}_{key}_buckets.
|
|
308
|
+
- upload_url_expiry_seconds (integer) presigned PUT URL expiry override
|
|
309
|
+
- download_url_expiry_seconds (integer) presigned GET URL expiry override
|
|
310
|
+
- default_max_file_size (bigint) global max file size in bytes for this module
|
|
311
|
+
- allowed_origins (text[]) default CORS origins for all buckets in this module
|
|
312
|
+
- restrict_reads (boolean) require read_files permission for SELECT on files
|
|
313
|
+
- has_path_shares (boolean) enable virtual filesystem + path share policies
|
|
314
|
+
- has_versioning (boolean) enable file version chains
|
|
315
|
+
- has_content_hash (boolean) enable content hash for dedup
|
|
316
|
+
- has_custom_keys (boolean) allow client-provided S3 keys
|
|
317
|
+
- has_audit_log (boolean) enable file events audit table
|
|
318
|
+
- has_confirm_upload (boolean) enable HeadObject confirmation flow
|
|
319
|
+
- confirm_upload_delay (interval) delay before first confirmation attempt
|
|
320
|
+
- buckets (jsonb[]) array of initial bucket definitions to seed.
|
|
321
|
+
Each bucket: { name (required), description, is_public, allowed_mime_types, max_file_size, allowed_origins }
|
|
322
|
+
- provisions (jsonb object) per-table customization keyed by "files" or "buckets".
|
|
323
|
+
Each value: { nodes, fields, grants, use_rls, policies }.
|
|
324
|
+
Example (single module, backward compat):
|
|
325
|
+
storage_config := ''[{"buckets": [{"name": "documents"}]}]''::jsonb
|
|
326
|
+
Example (multi-module):
|
|
327
|
+
storage_config := ''[{"has_path_shares": true, "buckets": [{"name": "documents"}]}, {"storage_key": "fn", "has_custom_keys": true, "buckets": [{"name": "functions"}]}]''::jsonb';
|
|
317
328
|
|
|
318
329
|
COMMENT ON COLUMN metaschema_modules_public.entity_type_provision.out_storage_module_id IS
|
|
319
330
|
'Output: the UUID of the storage_module row created for this entity type. Populated by the trigger when has_storage=true.';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/events_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.events_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
--
|
|
12
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
14
|
+
--
|
|
15
|
+
|
|
16
|
+
events_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
17
|
+
events_table_name text NOT NULL DEFAULT '',
|
|
18
|
+
|
|
19
|
+
event_aggregates_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
20
|
+
event_aggregates_table_name text NOT NULL DEFAULT '',
|
|
21
|
+
|
|
22
|
+
event_types_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
23
|
+
event_types_table_name text NOT NULL DEFAULT '',
|
|
24
|
+
|
|
25
|
+
levels_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
26
|
+
levels_table_name text NOT NULL DEFAULT '',
|
|
27
|
+
|
|
28
|
+
level_requirements_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
29
|
+
level_requirements_table_name text NOT NULL DEFAULT '',
|
|
30
|
+
|
|
31
|
+
level_grants_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
32
|
+
level_grants_table_name text NOT NULL DEFAULT '',
|
|
33
|
+
|
|
34
|
+
achievement_rewards_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
35
|
+
achievement_rewards_table_name text NOT NULL DEFAULT '',
|
|
36
|
+
|
|
37
|
+
record_event text NOT NULL DEFAULT '',
|
|
38
|
+
remove_event text NOT NULL DEFAULT '',
|
|
39
|
+
tg_event text NOT NULL DEFAULT '',
|
|
40
|
+
tg_event_toggle text NOT NULL DEFAULT '',
|
|
41
|
+
tg_event_toggle_bool text NOT NULL DEFAULT '',
|
|
42
|
+
tg_event_bool text NOT NULL DEFAULT '',
|
|
43
|
+
upsert_aggregate text NOT NULL DEFAULT '',
|
|
44
|
+
tg_update_aggregates text NOT NULL DEFAULT '',
|
|
45
|
+
prune_events text NOT NULL DEFAULT '',
|
|
46
|
+
steps_required text NOT NULL DEFAULT '',
|
|
47
|
+
level_achieved text NOT NULL DEFAULT '',
|
|
48
|
+
tg_check_achievements text NOT NULL DEFAULT '',
|
|
49
|
+
grant_achievement text NOT NULL DEFAULT '',
|
|
50
|
+
tg_achievement_reward text NOT NULL DEFAULT '',
|
|
51
|
+
|
|
52
|
+
-- Partition lifecycle configuration for events table
|
|
53
|
+
"interval" text NOT NULL DEFAULT '1 month',
|
|
54
|
+
retention text DEFAULT '12 months',
|
|
55
|
+
premake int NOT NULL DEFAULT 2,
|
|
56
|
+
|
|
57
|
+
prefix text NULL,
|
|
58
|
+
|
|
59
|
+
membership_type int NOT NULL,
|
|
60
|
+
-- if this is NOT NULL, then we add entity_id
|
|
61
|
+
-- e.g. limits to the app itself are considered global owned by app and no explicit owner
|
|
62
|
+
entity_table_id uuid NULL,
|
|
63
|
+
|
|
64
|
+
-- required tables
|
|
65
|
+
actor_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
69
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
70
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
71
|
+
|
|
72
|
+
CONSTRAINT events_table_fkey FOREIGN KEY (events_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
73
|
+
CONSTRAINT event_aggregates_table_fkey FOREIGN KEY (event_aggregates_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
74
|
+
CONSTRAINT event_types_table_fkey FOREIGN KEY (event_types_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
75
|
+
CONSTRAINT levels_table_fkey FOREIGN KEY (levels_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
76
|
+
CONSTRAINT level_requirements_table_fkey FOREIGN KEY (level_requirements_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
77
|
+
CONSTRAINT level_grants_table_fkey FOREIGN KEY (level_grants_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
78
|
+
CONSTRAINT achievement_rewards_table_fkey FOREIGN KEY (achievement_rewards_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
79
|
+
CONSTRAINT entity_table_fkey FOREIGN KEY (entity_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
80
|
+
CONSTRAINT actor_table_fkey FOREIGN KEY (actor_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
CREATE INDEX events_module_database_id_idx ON metaschema_modules_public.events_module ( database_id );
|
|
84
|
+
|
|
85
|
+
COMMIT;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/inference_log_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.inference_log_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
12
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
|
|
14
|
+
-- Inference log table (partitioned by created_at)
|
|
15
|
+
inference_log_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
16
|
+
inference_log_table_name text NOT NULL DEFAULT '',
|
|
17
|
+
|
|
18
|
+
-- Pre-aggregated daily rollup table
|
|
19
|
+
usage_daily_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
20
|
+
usage_daily_table_name text NOT NULL DEFAULT '',
|
|
21
|
+
|
|
22
|
+
-- Partition lifecycle configuration
|
|
23
|
+
"interval" text NOT NULL DEFAULT '1 month',
|
|
24
|
+
retention text NULL,
|
|
25
|
+
premake int NOT NULL DEFAULT 2,
|
|
26
|
+
|
|
27
|
+
prefix text NULL,
|
|
28
|
+
|
|
29
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
30
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
31
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
32
|
+
CONSTRAINT inference_log_table_fkey FOREIGN KEY (inference_log_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
33
|
+
CONSTRAINT usage_daily_table_fkey FOREIGN KEY (usage_daily_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
34
|
+
CONSTRAINT inference_log_module_database_id_unique UNIQUE (database_id)
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
CREATE INDEX inference_log_module_database_id_idx ON metaschema_modules_public.inference_log_module ( database_id );
|
|
38
|
+
|
|
39
|
+
COMMIT;
|
|
@@ -53,6 +53,14 @@ CREATE TABLE metaschema_modules_public.limits_module (
|
|
|
53
53
|
-- Resolve cap function (COALESCE lookup: per-entity → default → 0)
|
|
54
54
|
resolve_cap_function text NOT NULL DEFAULT '',
|
|
55
55
|
|
|
56
|
+
-- Warning tables for soft-limit notifications
|
|
57
|
+
limit_warnings_table_id uuid NULL,
|
|
58
|
+
limit_warning_state_table_id uuid NULL,
|
|
59
|
+
|
|
60
|
+
-- Soft limit check functions
|
|
61
|
+
limit_check_soft_function text NOT NULL DEFAULT '',
|
|
62
|
+
limit_aggregate_check_soft_function text NOT NULL DEFAULT '',
|
|
63
|
+
|
|
56
64
|
prefix text NULL,
|
|
57
65
|
|
|
58
66
|
membership_type int NOT NULL,
|
|
@@ -77,7 +85,9 @@ CREATE TABLE metaschema_modules_public.limits_module (
|
|
|
77
85
|
CONSTRAINT credit_code_items_table_fkey FOREIGN KEY (credit_code_items_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
78
86
|
CONSTRAINT credit_redemptions_table_fkey FOREIGN KEY (credit_redemptions_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
79
87
|
CONSTRAINT limit_caps_table_fkey FOREIGN KEY (limit_caps_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
80
|
-
CONSTRAINT limit_caps_defaults_table_fkey FOREIGN KEY (limit_caps_defaults_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
88
|
+
CONSTRAINT limit_caps_defaults_table_fkey FOREIGN KEY (limit_caps_defaults_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
89
|
+
CONSTRAINT limit_warnings_table_fkey FOREIGN KEY (limit_warnings_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
90
|
+
CONSTRAINT limit_warning_state_table_fkey FOREIGN KEY (limit_warning_state_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE
|
|
81
91
|
|
|
82
92
|
);
|
|
83
93
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/rate_limit_meters_module/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.rate_limit_meters_module (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
9
|
+
database_id uuid NOT NULL,
|
|
10
|
+
|
|
11
|
+
-- Public schema: rate_limit_overrides table (admin-manageable via GraphQL API)
|
|
12
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
-- Private schema: rate_limit_state table, check_rate_limit function (internal)
|
|
14
|
+
private_schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
15
|
+
|
|
16
|
+
-- State table: sliding window tracking per entity/actor/meter/window (private)
|
|
17
|
+
rate_limit_state_table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
18
|
+
rate_limit_state_table_name text NOT NULL DEFAULT '',
|
|
19
|
+
|
|
20
|
+
-- Overrides table: per-entity and per-actor rate limit overrides (public)
|
|
21
|
+
rate_limit_overrides_table_id uuid NULL,
|
|
22
|
+
rate_limit_overrides_table_name text NOT NULL DEFAULT '',
|
|
23
|
+
|
|
24
|
+
-- Rate window limits table: per-plan rate limit configuration (public)
|
|
25
|
+
rate_window_limits_table_id uuid NULL,
|
|
26
|
+
rate_window_limits_table_name text NOT NULL DEFAULT '',
|
|
27
|
+
|
|
28
|
+
-- Generated check function (private)
|
|
29
|
+
check_rate_limit_function text NOT NULL DEFAULT '',
|
|
30
|
+
|
|
31
|
+
prefix text NULL,
|
|
32
|
+
|
|
33
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
34
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
35
|
+
CONSTRAINT private_schema_fkey FOREIGN KEY (private_schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
36
|
+
CONSTRAINT rate_limit_state_table_fkey FOREIGN KEY (rate_limit_state_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
37
|
+
CONSTRAINT rate_limit_overrides_table_fkey FOREIGN KEY (rate_limit_overrides_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
38
|
+
CONSTRAINT rate_window_limits_table_fkey FOREIGN KEY (rate_window_limits_table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
39
|
+
CONSTRAINT rate_limit_meters_module_database_id_unique UNIQUE (database_id)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
CREATE INDEX rate_limit_meters_module_database_id_idx ON metaschema_modules_public.rate_limit_meters_module ( database_id );
|
|
43
|
+
|
|
44
|
+
COMMENT ON CONSTRAINT rate_limit_state_table_fkey
|
|
45
|
+
ON metaschema_modules_public.rate_limit_meters_module IS E'@fieldName rateLimitStateTableByRateLimitStateTableId';
|
|
46
|
+
COMMENT ON CONSTRAINT rate_limit_overrides_table_fkey
|
|
47
|
+
ON metaschema_modules_public.rate_limit_meters_module IS E'@fieldName rateLimitOverridesTableByRateLimitOverridesTableId';
|
|
48
|
+
COMMENT ON CONSTRAINT rate_window_limits_table_fkey
|
|
49
|
+
ON metaschema_modules_public.rate_limit_meters_module IS E'@fieldName rateWindowLimitsTableByRateWindowLimitsTableId';
|
|
50
|
+
|
|
51
|
+
COMMIT;
|
|
@@ -20,8 +20,8 @@ CREATE TABLE metaschema_modules_public.realtime_module (
|
|
|
20
20
|
|
|
21
21
|
-- Partition lifecycle configuration for change_log
|
|
22
22
|
retention_hours integer NOT NULL DEFAULT 168,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
premake int NOT NULL DEFAULT 7,
|
|
24
|
+
"interval" text NOT NULL DEFAULT '1 day',
|
|
25
25
|
|
|
26
26
|
-- NOTIFY hybrid wake-up channel name (NULL = use default)
|
|
27
27
|
notify_channel text NULL,
|
|
@@ -23,6 +23,12 @@ CREATE TABLE metaschema_modules_public.storage_module (
|
|
|
23
23
|
-- Multi-tenant storage identity
|
|
24
24
|
membership_type int DEFAULT NULL, -- NULL = global gate (AuthzMembership via app_sprt), non-NULL = entity-scoped (AuthzEntityMembership)
|
|
25
25
|
|
|
26
|
+
-- Storage module 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}_{storage_key}_{buckets|files}.
|
|
29
|
+
-- Max 16 chars, lowercase snake_case, cannot be 'buckets'/'files'/'bucket'/'file'.
|
|
30
|
+
storage_key text NOT NULL DEFAULT 'default',
|
|
31
|
+
|
|
26
32
|
-- Configurable security policies (NULL = use defaults based on membership_type).
|
|
27
33
|
-- When provided, replaces the default policy set in apply_storage_security.
|
|
28
34
|
-- Accepts a JSON array of policy objects:
|
|
@@ -76,6 +82,8 @@ CREATE TABLE metaschema_modules_public.storage_module (
|
|
|
76
82
|
has_content_hash boolean NOT NULL DEFAULT false, -- Content hash column for dedup + integrity verification
|
|
77
83
|
has_custom_keys boolean NOT NULL DEFAULT false, -- allow_custom_keys on buckets (implies has_versioning + has_content_hash)
|
|
78
84
|
has_audit_log boolean NOT NULL DEFAULT false, -- File events audit table: upload, delete, move, rename, download, share events
|
|
85
|
+
has_confirm_upload boolean NOT NULL DEFAULT false, -- Deferred HeadObject confirmation: enqueues storage:confirm_upload job on INSERT, creates status transition functions
|
|
86
|
+
confirm_upload_delay interval NOT NULL DEFAULT '30 seconds', -- Delay before first confirmation attempt (only used when has_confirm_upload = true)
|
|
79
87
|
|
|
80
88
|
-- Generated table ID for file_events (populated by the generator when has_audit_log=true)
|
|
81
89
|
file_events_table_id uuid NULL DEFAULT NULL,
|
|
@@ -93,8 +101,9 @@ CREATE TABLE metaschema_modules_public.storage_module (
|
|
|
93
101
|
|
|
94
102
|
CREATE INDEX storage_module_database_id_idx ON metaschema_modules_public.storage_module ( database_id );
|
|
95
103
|
|
|
96
|
-
-- Unique constraint on (database_id, membership_type) using COALESCE to handle NULLs.
|
|
97
|
-
-- NULL membership_type = app-level
|
|
98
|
-
|
|
104
|
+
-- Unique constraint on (database_id, membership_type, storage_key) using COALESCE to handle NULLs.
|
|
105
|
+
-- NULL membership_type = app-level, non-NULL = entity-scoped. storage_key discriminates
|
|
106
|
+
-- multiple storage modules for the same entity type (e.g. 'default' + 'fn').
|
|
107
|
+
CREATE UNIQUE INDEX storage_module_unique_scope ON metaschema_modules_public.storage_module ( database_id, COALESCE(membership_type, -1), storage_key );
|
|
99
108
|
|
|
100
109
|
COMMIT;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
-- Deploy schemas/metaschema_modules_public/tables/
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/user_state_module/table to pg
|
|
2
2
|
|
|
3
3
|
-- requires: schemas/metaschema_modules_public/schema
|
|
4
4
|
|
|
5
5
|
BEGIN;
|
|
6
6
|
|
|
7
|
-
CREATE TABLE metaschema_modules_public.
|
|
7
|
+
CREATE TABLE metaschema_modules_public.user_state_module (
|
|
8
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(),
|
|
12
12
|
table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
-
table_name text NOT NULL DEFAULT '
|
|
13
|
+
table_name text NOT NULL DEFAULT 'user_state',
|
|
14
14
|
--
|
|
15
15
|
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
16
16
|
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE,
|
|
@@ -18,6 +18,6 @@ CREATE TABLE metaschema_modules_public.secrets_module (
|
|
|
18
18
|
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
-
CREATE INDEX
|
|
21
|
+
CREATE INDEX user_state_module_database_id_idx ON metaschema_modules_public.user_state_module ( database_id );
|
|
22
22
|
|
|
23
23
|
COMMIT;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpm/metaschema-modules",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
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.
|
|
25
|
-
"@pgpm/verify": "0.
|
|
24
|
+
"@pgpm/metaschema-schema": "0.26.0",
|
|
25
|
+
"@pgpm/verify": "0.26.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"pgpm": "^4.23.2"
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/constructive-io/pgpm-modules/issues"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "3badf1e5e2fc71deae9e194b779599d17ab28a0d"
|
|
39
39
|
}
|
package/pgpm.plan
CHANGED
|
@@ -12,9 +12,9 @@ schemas/metaschema_modules_public/tables/crypto_auth_module/table [schemas/metas
|
|
|
12
12
|
schemas/metaschema_modules_public/tables/default_ids_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/default_ids_module/table
|
|
13
13
|
schemas/metaschema_modules_public/tables/denormalized_table_field/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/denormalized_table_field/table
|
|
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
|
-
schemas/metaschema_modules_public/tables/
|
|
15
|
+
schemas/metaschema_modules_public/tables/config_secrets_user_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/config_secrets_user_module/table
|
|
16
16
|
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
|
|
17
|
-
schemas/metaschema_modules_public/tables/
|
|
17
|
+
schemas/metaschema_modules_public/tables/events_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/events_module/table
|
|
18
18
|
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
|
|
19
19
|
schemas/metaschema_modules_public/tables/membership_types_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/membership_types_module/table
|
|
20
20
|
schemas/metaschema_modules_public/tables/memberships_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/memberships_module/table
|
|
@@ -22,7 +22,7 @@ schemas/metaschema_modules_public/tables/permissions_module/table [schemas/metas
|
|
|
22
22
|
schemas/metaschema_modules_public/tables/phone_numbers_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/phone_numbers_module/table
|
|
23
23
|
schemas/metaschema_modules_public/tables/profiles_module/table [schemas/metaschema_modules_public/schema] 2026-01-01T00:00:00Z devin <devin@cognition.ai> # add schemas/metaschema_modules_public/tables/profiles_module/table
|
|
24
24
|
schemas/metaschema_modules_public/tables/rls_module/table [schemas/metaschema_modules_public/schema schemas/services_public/tables/apis/table] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/rls_module/table
|
|
25
|
-
schemas/metaschema_modules_public/tables/
|
|
25
|
+
schemas/metaschema_modules_public/tables/user_state_module/table [schemas/metaschema_modules_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/metaschema_modules_public/tables/user_state_module/table
|
|
26
26
|
schemas/services_public/tables/sites/table [schemas/services_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/services_public/tables/sites/table
|
|
27
27
|
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
|
|
28
28
|
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
|
|
@@ -48,3 +48,6 @@ schemas/metaschema_modules_public/tables/plans_module/table [schemas/metaschema_
|
|
|
48
48
|
schemas/metaschema_modules_public/tables/billing_module/table [schemas/metaschema_modules_public/schema] 2026-05-02T23:45:00Z devin <devin@cognition.ai> # add billing_module config table for meters, plan_subscriptions, ledger, and balances
|
|
49
49
|
schemas/metaschema_modules_public/tables/billing_provider_module/table [schemas/metaschema_modules_public/schema] 2026-05-03T01:00:00Z devin <devin@cognition.ai> # add billing_provider_module config table for external billing provider integration
|
|
50
50
|
schemas/metaschema_modules_public/tables/realtime_module/table [schemas/metaschema_modules_public/schema] 2026-05-09T10:00:00Z devin <devin@cognition.ai> # add realtime_module config table for real-time subscription infrastructure
|
|
51
|
+
schemas/metaschema_modules_public/tables/rate_limit_meters_module/table [schemas/metaschema_modules_public/schema] 2026-05-16T00:00:00Z devin <devin@cognition.ai> # add rate_limit_meters_module for rolling window abuse protection (standalone rate limiting)
|
|
52
|
+
schemas/metaschema_modules_public/tables/config_secrets_org_module/table [schemas/metaschema_modules_public/schema] 2026-05-18T00:00:00Z devin <devin@cognition.ai> # add config_secrets_org_module config table for org-scoped encrypted secrets
|
|
53
|
+
schemas/metaschema_modules_public/tables/inference_log_module/table [schemas/metaschema_modules_public/schema] 2026-05-12T23:00:00Z devin <devin@cognition.ai> # add inference_log_module config table for partitioned LLM inference logging
|