Skip to content

Commit c99433d

Browse files
committed
feat: add BlueprintMembershipType interface for Phase 0 entity type provisioning
1 parent 98019c5 commit c99433d

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,29 @@ export interface BlueprintTableUniqueConstraint {
796796
/** Optional schema name override. */
797797
schema_name?: string;
798798
}
799+
/** 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. */
800+
export interface BlueprintMembershipType {
801+
/** Entity type name (e.g., "data_room", "channel", "department"). Must be unique per database. */
802+
name: string;
803+
/** Short prefix for generated objects (e.g., "dr", "ch", "dept"). Used in table/trigger naming. */
804+
prefix: string;
805+
/** Human-readable description of this entity type. */
806+
description?: string;
807+
/** Parent entity type name. Defaults to "org". */
808+
parent_entity?: string;
809+
/** Custom table name for the entity table. Defaults to name-derived convention. */
810+
table_name?: string;
811+
/** Whether this entity type is visible in the API. Defaults to true. */
812+
is_visible?: boolean;
813+
/** Whether to provision a limits module for this entity type. Defaults to false. */
814+
has_limits?: boolean;
815+
/** Whether to provision a profiles module for this entity type. Defaults to false. */
816+
has_profiles?: boolean;
817+
/** Whether to provision a levels module for this entity type. Defaults to false. */
818+
has_levels?: boolean;
819+
/** Whether to skip creating default RLS policies on the entity table. Defaults to false. */
820+
skip_entity_policies?: boolean;
821+
}
799822
/**
800823
* ===========================================================================
801824
* Node types -- discriminated union for nodes[] entries
@@ -1015,4 +1038,6 @@ export interface BlueprintDefinition {
10151038
full_text_searches?: BlueprintFullTextSearch[];
10161039
/** Unique constraints on table columns. */
10171040
unique_constraints?: BlueprintUniqueConstraint[];
1041+
/** Entity types to provision in Phase 0 (before tables). Each entry creates an entity table with membership modules and security. */
1042+
membership_types?: BlueprintMembershipType[];
10181043
}

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

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

602+
function buildBlueprintMembershipType(): t.ExportNamedDeclaration {
603+
return addJSDoc(
604+
exportInterface('BlueprintMembershipType', [
605+
addJSDoc(
606+
requiredProp('name', t.tsStringKeyword()),
607+
'Entity type name (e.g., "data_room", "channel", "department"). Must be unique per database.'
608+
),
609+
addJSDoc(
610+
requiredProp('prefix', t.tsStringKeyword()),
611+
'Short prefix for generated objects (e.g., "dr", "ch", "dept"). Used in table/trigger naming.'
612+
),
613+
addJSDoc(
614+
optionalProp('description', t.tsStringKeyword()),
615+
'Human-readable description of this entity type.'
616+
),
617+
addJSDoc(
618+
optionalProp('parent_entity', t.tsStringKeyword()),
619+
'Parent entity type name. Defaults to "org".'
620+
),
621+
addJSDoc(
622+
optionalProp('table_name', t.tsStringKeyword()),
623+
'Custom table name for the entity table. Defaults to name-derived convention.'
624+
),
625+
addJSDoc(
626+
optionalProp('is_visible', t.tsBooleanKeyword()),
627+
'Whether this entity type is visible in the API. Defaults to true.'
628+
),
629+
addJSDoc(
630+
optionalProp('has_limits', t.tsBooleanKeyword()),
631+
'Whether to provision a limits module for this entity type. Defaults to false.'
632+
),
633+
addJSDoc(
634+
optionalProp('has_profiles', t.tsBooleanKeyword()),
635+
'Whether to provision a profiles module for this entity type. Defaults to false.'
636+
),
637+
addJSDoc(
638+
optionalProp('has_levels', t.tsBooleanKeyword()),
639+
'Whether to provision a levels module for this entity type. Defaults to false.'
640+
),
641+
addJSDoc(
642+
optionalProp('skip_entity_policies', t.tsBooleanKeyword()),
643+
'Whether to skip creating default RLS policies on the entity table. Defaults to false.'
644+
),
645+
]),
646+
'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.'
647+
);
648+
}
649+
602650
function buildBlueprintTable(): t.ExportNamedDeclaration {
603651
return addJSDoc(
604652
exportInterface('BlueprintTable', [
@@ -711,6 +759,15 @@ function buildBlueprintDefinition(): t.ExportNamedDeclaration {
711759
),
712760
'Unique constraints on table columns.'
713761
),
762+
addJSDoc(
763+
optionalProp(
764+
'membership_types',
765+
t.tsArrayType(
766+
t.tsTypeReference(t.identifier('BlueprintMembershipType'))
767+
)
768+
),
769+
'Entity types to provision in Phase 0 (before tables). Each entry creates an entity table with membership modules and security.'
770+
),
714771
]),
715772
'The complete blueprint definition -- the JSONB shape accepted by construct_blueprint().'
716773
);
@@ -782,6 +839,7 @@ function buildProgram(meta?: MetaTableInfo[]): string {
782839
statements.push(buildBlueprintTableIndex());
783840
statements.push(buildBlueprintUniqueConstraint());
784841
statements.push(buildBlueprintTableUniqueConstraint());
842+
statements.push(buildBlueprintMembershipType());
785843

786844
// -- Node types discriminated union --
787845
statements.push(

0 commit comments

Comments
 (0)