Types
What this is for
A type is the design schema for a runtime record kind. It defines the fields, default list/detail views, record permissions, icon, and color that the generic admin and runtime UIs use to create, validate, and display records. Every items/threads/messages/etc. record is stamped with its type's design_schema at creation.
Why it exists
Without types, a row in items could be any kind of record. Types turn generic tables into domain-specific records.
Why it exists (5-whys):
- A table per entity means the shared runtime (CRUD, permissions, triggers, views, admin UI) needs custom code per entity — the domain gets tangled back into the platform.
- Letting every app write its own handlers means each re-implements validation, permission checks, and audit differently — the foundation bugs the framework exists to eliminate.
- The schema lives in the database, not app code, because a schema in code only runs where that code is deployed; a schema in the database is enforced on every write path — UI, API, pipelines, agents, integrations.
- The schema is declarative (
design_schema), not code, because declarative data can be validated, diffed, seeded, reconciled on upgrade, and interpreted generically by UI and validators alike. - Root: reusable foundations die when domain knowledge is hardcoded.
typesis the seam where the platform ends and the app begins — without a data-defined schema registry there is no generic middle layer at all. (confirmed 2026-11-13)
Fields and settings
- Name — string. Display label for the type. Empty name blocks save.
- Slug — string. URL-friendly identifier, unique per
kind. Callers resolve types by slug; duplicates breakresolveTypeId/.single()lookups. Rarely change after records exist. - Description — string, optional. Human-readable context.
- Kind — select:
item,account,person,thread,message,link,attachment,watcher. Determines which runtime table the type governs. - Ownership — select:
system(platform types, protected from deletion),app(owned by an app),tenant(account-specific). - Is Active — checkbox. Inactive types are hidden from lists and cannot have records created.
- App ID — select. Required whenever ownership is not
system— the form rejects save otherwise. - Icon / Color — UI presentation stored on the
typesrow. - Design Schema (JSON) — the full schema:
fields,views(default_list,default_detail),record_permissions,scope,functionality. - Validation Schema — read-only, regenerated from
design_schemaon every save by the API.
Downstream effects
- Generic list/detail pages render directly from
views. A missingdefault_list/default_detailor unknowndisplay_typebreaks those pages. record_permissionsis the base, most restrictive grant: if a role can read/update a record, all fields default to read/write.fields.*.permissionsonly loosen access per field or restrictsystem: truefields.system: truefields are read fromrecord.<field>; non-system fields fromrecord.data.<field>.- Changing
data_typeon a field with existing records does not migrate data — old values remain until rewritten. - Type seeds use
conflict: "kind,slug"withinject_app_id: false— types are global, not duplicated per app install.
Minimal configuration
{
"scope": "account",
"fields": {
"title": { "data_type": "text", "label": "Title", "required": true, "system": true }
},
"views": {
"default_list": {
"type": "list", "display": "table", "label": "List",
"fields": {
"title": { "sortable": true, "display_type": "text" },
"created_at": { "sortable": true, "display_type": "timestamp" }
},
"default_sort": { "field": "created_at", "direction": "desc" }
},
"default_detail": {
"type": "detail", "label": "Detail",
"sections": [{ "title": "Details", "fields": { "title": { "display_type": "input" } } }]
}
},
"record_permissions": { "system_admin": ["create", "read", "update", "delete"] },
"functionality": null
}Full configuration
Adds typed fields, select options, per-field permissions overrides, multiple views with sorting/badges, and per-role record grants (admin, member). See the design schema reference for the full data_type list (text, number, select, multiselect, reference, json, date, boolean, ...) and display_type list (badge, timestamp, select, currency, ...).
Example
A support app defines a ticket type (kind item, ownership app): title (system text), status (select: open/pending/closed), priority (select), assignee_id (reference). record_permissions grants system_admin all actions, admin create/read/update, member read. fields.assignee_id.permissions loosens write to member so agents can self-assign.
Core files
.framework/functions/types.ts— API (list/get/create/update/delete; regeneratesvalidation_schema).framework/src/pages/admin/TypesPage.tsx/TypeDetailPage.tsx— admin UI.framework/src/components/app-shell/GenericListPage.tsx/GenericDetailPage.tsx— generic renderer.framework/functions/_shared/permissions.ts— record/field permission evaluation- Design schema reference — full field/view schema reference in this book
- Table:
public.types
Agent notes
- Never hand-edit
validation_schema; changedesign_schemaand the API regenerates it. - Slug uniqueness is per
(kind, slug)— reuse across kinds is fine, reuse within a kind breaks lookups. - Every field needs
data_type,label,required;select/multiselect/radioalso needoptions. - Don't add
fields.*.permissionsunless overriding the base grant — the common mistake is re-stating record-level permissions per field. - Custom apps CRUD runtime records through
/api/admin-data— never custom wrappers.