BeechCMS / @beechcms/core / Branch
Interface: Branch
Branch: definition of a single field. alias is the SQL column name.
Properties
alias
alias:
string
Human-readable alias, used in the API payload and as the SQL column name in the dedicated table.
avatarSource?
optionalavatarSource?:string
Alias of a single image file branch on the target seed whose URL is the avatar of this relation's entries. relation only; absent = no avatar. Presentation metadata: never emits DDL, never touches rows. Validated by seed-validation.ts (must be an image file branch of the target).
fields?
optionalfields?:Branch[]
Sub-schema for type === 'repeater'. Each item of the repeater's array value is a record keyed by sub-branch alias, validated against this list. Sub-branches are restricted to leaf/scalar types (no nested repeater, relation, or file) — enforced by validation.ts and seed-validation.ts. Ignored for any other branch type.
fileOptions?
optionalfileOptions?:FileFieldOptions
Advanced options for file fields. Ignored if type !== 'file'.
format?
optionalformat?:"date"|"plain"|"markdown"|"html"|"datetime"|"asset-list"
Optional semantic variant of the field for UI/validation purposes. asset-list on a multiple file branch enables gallery management.
hint?
optionalhint?:string
Optional help text shown as a tooltip next to the label in the form. UI-only, ignored by the engine.
id
id:
string
Stable logical id of this branch, e.g. 'br_01', 'br_title'. Format: ^br_[A-Za-z0-9]+$ — enforced by SeedRegistry at boot (sprint 04-pre).
Used by every persistence layer that needs a reference that survives alias renames (FTS triggers, draft indexing, layout JSON, automations). NEVER use alias for that purpose.
The Botanical Engine still emits alias as the SQL column name; id is a logical handle.
label
label:
string
UI display label.
localized?
optionallocalized?:boolean
Field-level localization. When true, the branch's existing column stores a locale dictionary ({"it": "Scarpa", "en": "Shoe"}) instead of a single value. Metadata-only: toggling it never emits DDL and never rewrites rows — values written before the toggle stay readable as-is. Valid only on top-level text | richtext | json branches with plain storage (not confidential / restricted); never on repeater sub-fields. Enforced by seed-validation.ts (Fatal 17). Default: false.
maxItems?
optionalmaxItems?:number
Maximum number of items a repeater value may contain. Repeater-only — ignored for every other branch type. maxItems: 1 models a single "object" column. Must be a non-negative integer and >= minItems when both are set.
minItems?
optionalminItems?:number
Minimum number of items a repeater value must contain when a value is provided. Repeater-only — ignored for every other branch type.
NOTE: this constrains array length when the field is present. It does NOT by itself make the field mandatory — an absent/null payload is still allowed unless requiredOnCreate / requiredOnUpdate is also set. To model "exactly one required object", combine minItems: 1, maxItems: 1, requiredOnCreate: true. Must be a non-negative integer and <= maxItems when both are set (enforced at boot by seed-validation.ts).
multiple?
optionalmultiple?:boolean
Cardinality:
file: false/undefined → single URL; true → URL list.relation: false/undefined → FK column; true → junction table.tags: undefined/true → multiple choice (default); false → at most one value. The value is always an array.
numberOptions?
optionalnumberOptions?:NumberFieldOptions
Advanced options for number fields. Ignored if type !== 'number'.
onDelete?
optionalonDelete?:"CASCADE"|"SET NULL"|"RESTRICT"
SQLite ON DELETE rule applied to the foreign-key constraint. Defaults to 'SET NULL' when type === 'relation' and no value is provided.
- CASCADE : delete dependent rows when the parent is deleted.
- SET NULL : null out the column when the parent is deleted (default).
- RESTRICT : block parent deletion while dependent rows exist.
NOTE: When multiple: true (introduced in Sprint 5 for many-to-many), this rule applies to the FK from the junction table to the target table.
options?
optionaloptions?:TagOption[]
Closed vocabulary — valid ONLY on tags (any other type is a fatal seed error). When present: non-empty, at most TAG_OPTIONS_MAX_COUNT entries, unique canonical values, #RRGGBB colors; written values must be one of the option values. Static seed metadata, never persisted in entries.
policies?
optionalpolicies?:object
Access and handling policy for the field. All values are optional — resolvePolicies(branch) supplies the defaults.
classification?
optionalclassification?:DataClassification|"Public"|"Internal"|"Confidential"|"Restricted"
4-tier data classification level. Default: 'public'.
filter?
optionalfilter?:boolean
Whether the field is available as a filter column in the dashboard. Default: true.
privacy?
optionalprivacy?:DataClassification|"plain"|"Public"|"Internal"|"Confidential"|"Restricted"|"hash"|"encrypt"
How the value is stored. Default: 'plain'.
public?
optionalpublic?:boolean
Whether the field is included in Public API responses. Default: true.
publicEdit?
optionalpublicEdit?:boolean
Whether the field can be updated via public edit endpoints. Default: false for confidential/internal/restricted, true for public.
search?
optionalsearch?:boolean
Whether the field is included in full-text search queries. Default: true.
sort?
optionalsort?:boolean
Whether the field is available as a sort column in the dashboard. Default: true.
visibility?
optionalvisibility?:"full"|"masked"|"hidden"
How the value is returned in API responses. Default: 'full'.
requiredOnCreate?
optionalrequiredOnCreate?:boolean
Required on create — generates NOT NULL in generateCreateTable.
requiredOnUpdate?
optionalrequiredOnUpdate?:boolean
Required on update.
targetSeed?
optionaltargetSeed?:string
Slug of the referenced Seed (without the content_ prefix). REQUIRED when type === 'relation'. Ignored otherwise. Example: 'team' → references table content_team(id).
type
type:
BranchType
Value type.