Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions graphile/node-type-registry/src/data/data-force-current-user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { NodeTypeDefinition } from '../types';

export const DataForceCurrentUser: NodeTypeDefinition = {
"name": "DataForceCurrentUser",
"slug": "data_force_current_user",
"category": "data",
"display_name": "Force Current User",
"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.",
"parameter_schema": {
"type": "object",
"properties": {
"field_name": {
"type": "string",
"description": "Name of the field to force to current_user_id()",
"default": "actor_id"
}
}
},
"tags": [
"trigger",
"security",
"schema"
]
};
29 changes: 29 additions & 0 deletions graphile/node-type-registry/src/data/data-immutable-fields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { NodeTypeDefinition } from '../types';

export const DataImmutableFields: NodeTypeDefinition = {
"name": "DataImmutableFields",
"slug": "data_immutable_fields",
"category": "data",
"display_name": "Immutable Fields",
"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.",
"parameter_schema": {
"type": "object",
"properties": {
"fields": {
"type": "array",
"items": {
"type": "string"
},
"description": "Field names that cannot be modified after INSERT (e.g. [\"key\", \"bucket_id\", \"owner_id\"])"
}
},
"required": [
"fields"
]
},
"tags": [
"trigger",
"constraint",
"schema"
]
};
42 changes: 42 additions & 0 deletions graphile/node-type-registry/src/data/data-inherit-from-parent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { NodeTypeDefinition } from '../types';

export const DataInheritFromParent: NodeTypeDefinition = {
"name": "DataInheritFromParent",
"slug": "data_inherit_from_parent",
"category": "data",
"display_name": "Inherit From Parent",
"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.",
"parameter_schema": {
"type": "object",
"properties": {
"parent_fk_field": {
"type": "string",
"description": "Name of the FK field on this table that references the parent (e.g. bucket_id)"
},
"fields": {
"type": "array",
"items": {
"type": "string"
},
"description": "Field names to copy from the parent row (e.g. [\"owner_id\", \"is_public\"])"
},
"parent_table": {
"type": "string",
"description": "Parent table name (optional fallback if FK not yet registered in metaschema)"
},
"parent_schema": {
"type": "string",
"description": "Parent table schema (optional, defaults to same schema as child table)"
}
},
"required": [
"parent_fk_field",
"fields"
]
},
"tags": [
"trigger",
"inheritance",
"schema"
]
};
3 changes: 3 additions & 0 deletions graphile/node-type-registry/src/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export { DataTrgm } from './data-trgm';
export { DataSlug } from './data-slug';
export { DataInflection } from './data-inflection';
export { DataOwnedFields } from './data-owned-fields';
export { DataInheritFromParent } from './data-inherit-from-parent';
export { DataForceCurrentUser } from './data-force-current-user';
export { DataImmutableFields } from './data-immutable-fields';
export { TableUserProfiles } from './table-user-profiles';
export { TableOrganizationSettings } from './table-organization-settings';
export { TableUserSettings } from './table-user-settings';
Loading