@pgpm/metaschema-modules 0.16.7 → 0.17.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/deploy/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql +104 -0
- package/package.json +5 -5
- package/pgpm.plan +1 -0
- package/revert/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql +7 -0
- package/verify/schemas/metaschema_modules_public/tables/secure_table_provision/table.sql +25 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
-- Deploy schemas/metaschema_modules_public/tables/secure_table_provision/table to pg
|
|
2
|
+
|
|
3
|
+
-- requires: schemas/metaschema_modules_public/schema
|
|
4
|
+
|
|
5
|
+
BEGIN;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE metaschema_modules_public.secure_table_provision (
|
|
8
|
+
id uuid PRIMARY KEY DEFAULT uuid_generate_v4 (),
|
|
9
|
+
|
|
10
|
+
database_id uuid NOT NULL,
|
|
11
|
+
|
|
12
|
+
schema_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
13
|
+
|
|
14
|
+
table_id uuid NOT NULL DEFAULT uuid_nil(),
|
|
15
|
+
|
|
16
|
+
table_name text DEFAULT NULL,
|
|
17
|
+
|
|
18
|
+
node_type text DEFAULT NULL,
|
|
19
|
+
|
|
20
|
+
use_rls boolean NOT NULL DEFAULT true,
|
|
21
|
+
|
|
22
|
+
node_data jsonb NOT NULL DEFAULT '{}',
|
|
23
|
+
|
|
24
|
+
grant_roles text[] NOT NULL DEFAULT ARRAY['authenticated'],
|
|
25
|
+
|
|
26
|
+
grant_privileges jsonb NOT NULL DEFAULT '[]',
|
|
27
|
+
|
|
28
|
+
policy_type text DEFAULT NULL,
|
|
29
|
+
|
|
30
|
+
policy_privileges text[] DEFAULT NULL,
|
|
31
|
+
|
|
32
|
+
policy_role text DEFAULT NULL,
|
|
33
|
+
|
|
34
|
+
policy_permissive boolean NOT NULL DEFAULT true,
|
|
35
|
+
|
|
36
|
+
policy_data jsonb NOT NULL DEFAULT '{}',
|
|
37
|
+
|
|
38
|
+
out_fields uuid[] DEFAULT NULL,
|
|
39
|
+
|
|
40
|
+
CONSTRAINT db_fkey FOREIGN KEY (database_id) REFERENCES metaschema_public.database (id) ON DELETE CASCADE,
|
|
41
|
+
CONSTRAINT table_fkey FOREIGN KEY (table_id) REFERENCES metaschema_public.table (id) ON DELETE CASCADE,
|
|
42
|
+
CONSTRAINT schema_fkey FOREIGN KEY (schema_id) REFERENCES metaschema_public.schema (id) ON DELETE CASCADE
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
COMMENT ON TABLE metaschema_modules_public.secure_table_provision IS
|
|
46
|
+
'Provisions security, fields, grants, and policies onto a table. Each row can independently: (1) create fields via node_type, (2) grant privileges via grant_privileges, (3) create RLS policies via policy_type. Multiple rows can target the same table to compose different concerns. All three concerns are optional and independent.';
|
|
47
|
+
|
|
48
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.id IS
|
|
49
|
+
'Unique identifier for this provision row.';
|
|
50
|
+
|
|
51
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.database_id IS
|
|
52
|
+
'The database this provision belongs to. Required.';
|
|
53
|
+
|
|
54
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.schema_id IS
|
|
55
|
+
'Target schema for the table. Defaults to uuid_nil(); the trigger resolves this to the app_public schema if not explicitly provided.';
|
|
56
|
+
|
|
57
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.table_id IS
|
|
58
|
+
'Target table to provision. Defaults to uuid_nil(); the trigger creates or resolves the table via table_name if not explicitly provided.';
|
|
59
|
+
|
|
60
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.table_name IS
|
|
61
|
+
'Name of the target table. Used to create or look up the table when table_id is not provided. If omitted, it is backfilled from the resolved table.';
|
|
62
|
+
|
|
63
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.node_type IS
|
|
64
|
+
'Which generator to invoke for field creation. One of: DataId, DataDirectOwner, DataEntityMembership, DataOwnershipInEntity, DataTimestamps, DataPeoplestamps, DataPublishable, DataSoftDelete. NULL means no field creation — the row only provisions grants and/or policies.';
|
|
65
|
+
|
|
66
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.use_rls IS
|
|
67
|
+
'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.';
|
|
68
|
+
|
|
69
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.node_data IS
|
|
70
|
+
'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 ''{}''.';
|
|
71
|
+
|
|
72
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.grant_roles IS
|
|
73
|
+
'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''].';
|
|
74
|
+
|
|
75
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.grant_privileges IS
|
|
76
|
+
'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.';
|
|
77
|
+
|
|
78
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.policy_type IS
|
|
79
|
+
'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.';
|
|
80
|
+
|
|
81
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.policy_privileges IS
|
|
82
|
+
'Privileges the policy applies to, e.g. ARRAY[''select'',''update'']. NULL means privileges are derived from the grant_privileges verbs.';
|
|
83
|
+
|
|
84
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.policy_role IS
|
|
85
|
+
'Role the policy targets. NULL means it falls back to the first role in grant_roles.';
|
|
86
|
+
|
|
87
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.policy_permissive IS
|
|
88
|
+
'Whether the policy is PERMISSIVE (true) or RESTRICTIVE (false). Defaults to true.';
|
|
89
|
+
|
|
90
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.policy_data IS
|
|
91
|
+
'Opaque configuration passed through to metaschema.create_policy(). Structure varies by policy_type and is not interpreted by this trigger. Defaults to ''{}''.';
|
|
92
|
+
|
|
93
|
+
COMMENT ON COLUMN metaschema_modules_public.secure_table_provision.out_fields IS
|
|
94
|
+
'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.';
|
|
95
|
+
|
|
96
|
+
COMMENT ON CONSTRAINT schema_fkey ON metaschema_modules_public.secure_table_provision IS E'@omit manyToMany';
|
|
97
|
+
COMMENT ON CONSTRAINT table_fkey ON metaschema_modules_public.secure_table_provision IS E'@omit manyToMany';
|
|
98
|
+
COMMENT ON CONSTRAINT db_fkey ON metaschema_modules_public.secure_table_provision IS E'@omit manyToMany';
|
|
99
|
+
|
|
100
|
+
CREATE INDEX secure_table_provision_database_id_idx ON metaschema_modules_public.secure_table_provision ( database_id );
|
|
101
|
+
CREATE INDEX secure_table_provision_table_id_idx ON metaschema_modules_public.secure_table_provision ( table_id );
|
|
102
|
+
CREATE INDEX secure_table_provision_node_type_idx ON metaschema_modules_public.secure_table_provision ( node_type );
|
|
103
|
+
|
|
104
|
+
COMMIT;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpm/metaschema-modules",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Module metadata handling and dependency tracking",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"test:watch": "jest --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@pgpm/metaschema-schema": "0.
|
|
25
|
-
"@pgpm/services": "0.
|
|
26
|
-
"@pgpm/verify": "0.
|
|
24
|
+
"@pgpm/metaschema-schema": "0.17.0",
|
|
25
|
+
"@pgpm/services": "0.17.0",
|
|
26
|
+
"@pgpm/verify": "0.17.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"pgpm": "^1.3.0"
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"bugs": {
|
|
37
37
|
"url": "https://github.com/constructive-io/pgpm-modules/issues"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "8eb8b9e3a6784fb45a3a9e86838f8417f061925c"
|
|
40
40
|
}
|
package/pgpm.plan
CHANGED
|
@@ -32,3 +32,4 @@ schemas/metaschema_modules_public/tables/users_module/table [schemas/metaschema_
|
|
|
32
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
|
|
33
33
|
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
34
|
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
|
+
schemas/metaschema_modules_public/tables/secure_table_provision/table [schemas/metaschema_modules_public/schema] 2026-02-26T00:00:00Z devin <devin@cognition.ai> # add schemas/metaschema_modules_public/tables/secure_table_provision/table
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-- Verify schemas/metaschema_modules_public/tables/secure_table_provision/table on pg
|
|
2
|
+
|
|
3
|
+
BEGIN;
|
|
4
|
+
|
|
5
|
+
SELECT
|
|
6
|
+
id,
|
|
7
|
+
database_id,
|
|
8
|
+
schema_id,
|
|
9
|
+
table_id,
|
|
10
|
+
table_name,
|
|
11
|
+
node_type,
|
|
12
|
+
use_rls,
|
|
13
|
+
node_data,
|
|
14
|
+
grant_roles,
|
|
15
|
+
grant_privileges,
|
|
16
|
+
policy_type,
|
|
17
|
+
policy_privileges,
|
|
18
|
+
policy_role,
|
|
19
|
+
policy_permissive,
|
|
20
|
+
policy_data,
|
|
21
|
+
out_fields
|
|
22
|
+
FROM metaschema_modules_public.secure_table_provision
|
|
23
|
+
WHERE FALSE;
|
|
24
|
+
|
|
25
|
+
ROLLBACK;
|