Skip to content

Commit 331d894

Browse files
authored
Merge pull request #988 from constructive-io/devin/1776414667-blueprint-table-provision-types
feat(node-type-registry): add table_provision to BlueprintMembershipType
2 parents 0e97757 + 10bf488 commit 331d894

2 files changed

Lines changed: 70 additions & 4 deletions

File tree

graphql/node-type-registry/src/blueprint-types.generated.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,21 @@ export interface BlueprintTableUniqueConstraint {
813813
/** Optional schema name override. */
814814
schema_name?: string;
815815
}
816+
/** Override object for the entity table created by a BlueprintMembershipType. Shape mirrors BlueprintTable / secure_table_provision vocabulary. When supplied, policies[] replaces the default entity-table policies entirely. */
817+
export interface BlueprintEntityTableProvision {
818+
/** Whether to enable RLS on the entity table. Forwarded to secure_table_provision. Defaults to true. */
819+
use_rls?: boolean;
820+
/** Node objects applied to the entity table for field creation (e.g., DataTimestamps, DataPeoplestamps). Forwarded to secure_table_provision as-is. */
821+
nodes?: BlueprintNode[];
822+
/** Custom fields (columns) to add to the entity table. Forwarded to secure_table_provision as-is. */
823+
fields?: BlueprintField[];
824+
/** Privilege grants for the entity table as [verb, columns] tuples (e.g. [["select","*"],["insert","*"]]). Forwarded to secure_table_provision as-is. */
825+
grant_privileges?: unknown[];
826+
/** Database roles to grant privileges to. Forwarded to secure_table_provision as-is. Defaults to ["authenticated"]. */
827+
grant_roles?: string[];
828+
/** RLS policies for the entity table. When present, these policies fully replace the five default entity-table policies (is_visible becomes a no-op). */
829+
policies?: BlueprintPolicy[];
830+
}
816831
/** A membership type entry for Phase 0 of construct_blueprint(). Provisions a full entity type with its own entity table, membership modules, and security policies via entity_type_provision. */
817832
export interface BlueprintMembershipType {
818833
/** Entity type name (e.g., "data_room", "channel", "department"). Must be unique per database. */
@@ -825,16 +840,18 @@ export interface BlueprintMembershipType {
825840
parent_entity?: string;
826841
/** Custom table name for the entity table. Defaults to name-derived convention. */
827842
table_name?: string;
828-
/** Whether this entity type is visible in the API. Defaults to true. */
843+
/** Whether parent-entity members can see child entities via the default parent_member SELECT policy. Gates one of the five default policies. No-op when table_provision is supplied. Defaults to true. */
829844
is_visible?: boolean;
830845
/** Whether to provision a limits module for this entity type. Defaults to false. */
831846
has_limits?: boolean;
832847
/** Whether to provision a profiles module for this entity type. Defaults to false. */
833848
has_profiles?: boolean;
834849
/** Whether to provision a levels module for this entity type. Defaults to false. */
835850
has_levels?: boolean;
836-
/** Whether to skip creating default RLS policies on the entity table. Defaults to false. */
851+
/** Escape hatch: when true AND table_provision is NULL, zero policies are provisioned on the entity table. Defaults to false. */
837852
skip_entity_policies?: boolean;
853+
/** Override for the entity table. Shape mirrors BlueprintTable / secure_table_provision vocabulary. When supplied, its policies[] replaces the five default entity-table policies; is_visible becomes a no-op. When NULL (default), the five default policies are applied (gated by is_visible). */
854+
table_provision?: BlueprintEntityTableProvision;
838855
}
839856
/**
840857
* ===========================================================================

graphql/node-type-registry/src/codegen/generate-types.ts

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,47 @@ function buildBlueprintTableUniqueConstraint(): t.ExportNamedDeclaration {
599599
);
600600
}
601601

602+
function buildBlueprintEntityTableProvision(): t.ExportNamedDeclaration {
603+
return addJSDoc(
604+
exportInterface('BlueprintEntityTableProvision', [
605+
addJSDoc(
606+
optionalProp('use_rls', t.tsBooleanKeyword()),
607+
'Whether to enable RLS on the entity table. Forwarded to secure_table_provision. Defaults to true.'
608+
),
609+
addJSDoc(
610+
optionalProp(
611+
'nodes',
612+
t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintNode')))
613+
),
614+
'Node objects applied to the entity table for field creation (e.g., DataTimestamps, DataPeoplestamps). Forwarded to secure_table_provision as-is.'
615+
),
616+
addJSDoc(
617+
optionalProp(
618+
'fields',
619+
t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintField')))
620+
),
621+
'Custom fields (columns) to add to the entity table. Forwarded to secure_table_provision as-is.'
622+
),
623+
addJSDoc(
624+
optionalProp('grant_privileges', t.tsArrayType(t.tsUnknownKeyword())),
625+
'Privilege grants for the entity table as [verb, columns] tuples (e.g. [["select","*"],["insert","*"]]). Forwarded to secure_table_provision as-is.'
626+
),
627+
addJSDoc(
628+
optionalProp('grant_roles', t.tsArrayType(t.tsStringKeyword())),
629+
'Database roles to grant privileges to. Forwarded to secure_table_provision as-is. Defaults to ["authenticated"].'
630+
),
631+
addJSDoc(
632+
optionalProp(
633+
'policies',
634+
t.tsArrayType(t.tsTypeReference(t.identifier('BlueprintPolicy')))
635+
),
636+
'RLS policies for the entity table. When present, these policies fully replace the five default entity-table policies (is_visible becomes a no-op).'
637+
),
638+
]),
639+
'Override object for the entity table created by a BlueprintMembershipType. Shape mirrors BlueprintTable / secure_table_provision vocabulary. When supplied, policies[] replaces the default entity-table policies entirely.'
640+
);
641+
}
642+
602643
function buildBlueprintMembershipType(): t.ExportNamedDeclaration {
603644
return addJSDoc(
604645
exportInterface('BlueprintMembershipType', [
@@ -624,7 +665,7 @@ function buildBlueprintMembershipType(): t.ExportNamedDeclaration {
624665
),
625666
addJSDoc(
626667
optionalProp('is_visible', t.tsBooleanKeyword()),
627-
'Whether this entity type is visible in the API. Defaults to true.'
668+
'Whether parent-entity members can see child entities via the default parent_member SELECT policy. Gates one of the five default policies. No-op when table_provision is supplied. Defaults to true.'
628669
),
629670
addJSDoc(
630671
optionalProp('has_limits', t.tsBooleanKeyword()),
@@ -640,7 +681,14 @@ function buildBlueprintMembershipType(): t.ExportNamedDeclaration {
640681
),
641682
addJSDoc(
642683
optionalProp('skip_entity_policies', t.tsBooleanKeyword()),
643-
'Whether to skip creating default RLS policies on the entity table. Defaults to false.'
684+
'Escape hatch: when true AND table_provision is NULL, zero policies are provisioned on the entity table. Defaults to false.'
685+
),
686+
addJSDoc(
687+
optionalProp(
688+
'table_provision',
689+
t.tsTypeReference(t.identifier('BlueprintEntityTableProvision'))
690+
),
691+
'Override for the entity table. Shape mirrors BlueprintTable / secure_table_provision vocabulary. When supplied, its policies[] replaces the five default entity-table policies; is_visible becomes a no-op. When NULL (default), the five default policies are applied (gated by is_visible).'
644692
),
645693
]),
646694
'A membership type entry for Phase 0 of construct_blueprint(). Provisions a full entity type with its own entity table, membership modules, and security policies via entity_type_provision.'
@@ -839,6 +887,7 @@ function buildProgram(meta?: MetaTableInfo[]): string {
839887
statements.push(buildBlueprintTableIndex());
840888
statements.push(buildBlueprintUniqueConstraint());
841889
statements.push(buildBlueprintTableUniqueConstraint());
890+
statements.push(buildBlueprintEntityTableProvision());
842891
statements.push(buildBlueprintMembershipType());
843892

844893
// -- Node types discriminated union --

0 commit comments

Comments
 (0)