Skip to content

Commit 098dc7d

Browse files
authored
Merge pull request #899 from constructive-io/devin/1774503925-add-new-data-node-types
feat(node-type-registry): add DataInheritFromParent, DataForceCurrentUser, DataImmutableFields
2 parents 457d21a + 066ff6d commit 098dc7d

4 files changed

Lines changed: 98 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { NodeTypeDefinition } from '../types';
2+
3+
export const DataForceCurrentUser: NodeTypeDefinition = {
4+
"name": "DataForceCurrentUser",
5+
"slug": "data_force_current_user",
6+
"category": "data",
7+
"display_name": "Force Current User",
8+
"description": "BEFORE INSERT trigger that forces a field to the value of jwt_public.current_user_id(). Prevents clients from spoofing the actor/uploader identity. The field value is always overwritten regardless of what the client provides.",
9+
"parameter_schema": {
10+
"type": "object",
11+
"properties": {
12+
"field_name": {
13+
"type": "string",
14+
"description": "Name of the field to force to current_user_id()",
15+
"default": "actor_id"
16+
}
17+
}
18+
},
19+
"tags": [
20+
"trigger",
21+
"security",
22+
"schema"
23+
]
24+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import type { NodeTypeDefinition } from '../types';
2+
3+
export const DataImmutableFields: NodeTypeDefinition = {
4+
"name": "DataImmutableFields",
5+
"slug": "data_immutable_fields",
6+
"category": "data",
7+
"display_name": "Immutable Fields",
8+
"description": "BEFORE UPDATE trigger that prevents changes to a list of specified fields after INSERT. Raises an exception if any of the listed fields have changed. Unlike FieldImmutable (single-field), this handles multiple fields in a single trigger for efficiency.",
9+
"parameter_schema": {
10+
"type": "object",
11+
"properties": {
12+
"fields": {
13+
"type": "array",
14+
"items": {
15+
"type": "string"
16+
},
17+
"description": "Field names that cannot be modified after INSERT (e.g. [\"key\", \"bucket_id\", \"owner_id\"])"
18+
}
19+
},
20+
"required": [
21+
"fields"
22+
]
23+
},
24+
"tags": [
25+
"trigger",
26+
"constraint",
27+
"schema"
28+
]
29+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import type { NodeTypeDefinition } from '../types';
2+
3+
export const DataInheritFromParent: NodeTypeDefinition = {
4+
"name": "DataInheritFromParent",
5+
"slug": "data_inherit_from_parent",
6+
"category": "data",
7+
"display_name": "Inherit From Parent",
8+
"description": "BEFORE INSERT trigger that copies specified fields from a parent table via a foreign key. The parent row is looked up through RLS (SECURITY INVOKER), so the insert fails if the caller cannot see the parent. Used by the storage module to inherit owner_id and is_public from buckets to files.",
9+
"parameter_schema": {
10+
"type": "object",
11+
"properties": {
12+
"parent_fk_field": {
13+
"type": "string",
14+
"description": "Name of the FK field on this table that references the parent (e.g. bucket_id)"
15+
},
16+
"fields": {
17+
"type": "array",
18+
"items": {
19+
"type": "string"
20+
},
21+
"description": "Field names to copy from the parent row (e.g. [\"owner_id\", \"is_public\"])"
22+
},
23+
"parent_table": {
24+
"type": "string",
25+
"description": "Parent table name (optional fallback if FK not yet registered in metaschema)"
26+
},
27+
"parent_schema": {
28+
"type": "string",
29+
"description": "Parent table schema (optional, defaults to same schema as child table)"
30+
}
31+
},
32+
"required": [
33+
"parent_fk_field",
34+
"fields"
35+
]
36+
},
37+
"tags": [
38+
"trigger",
39+
"inheritance",
40+
"schema"
41+
]
42+
};

‎graphile/node-type-registry/src/data/index.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export { DataTrgm } from './data-trgm';
2020
export { DataSlug } from './data-slug';
2121
export { DataInflection } from './data-inflection';
2222
export { DataOwnedFields } from './data-owned-fields';
23+
export { DataInheritFromParent } from './data-inherit-from-parent';
24+
export { DataForceCurrentUser } from './data-force-current-user';
25+
export { DataImmutableFields } from './data-immutable-fields';
2326
export { TableUserProfiles } from './table-user-profiles';
2427
export { TableOrganizationSettings } from './table-organization-settings';
2528
export { TableUserSettings } from './table-user-settings';

0 commit comments

Comments
 (0)