Table and column metadata
View as MarkdownIdentity
Section titled “Identity”SapportaMeta, SapportaTableInputMeta, ColumnMeta, ChildMeta,
columnBySqlName(), and columnPropertyName() from @sapporta/server;
serialized TableSchema, ColumnSchema, and ChildSchema from
@sapporta/shared/contracts.
Contract
Section titled “Contract”SapportaTableInputMetais the sparse authoring shape accepted bysapportaTable().SapportaMetais its normalized server form.- Authoring metadata includes
label, requiredrowLabelColumns,rowScope,immutable,references,defaultSort,children,columns, andsearch. rowLabelColumnsmust contain at least one real SQL column name from the current table. Labels concatenate those stored values; they do not resolve referenced-row labels.rowScopedefaults toworkspaceUserScoped, which requiresworkspace_idandscoped_to_user_id.workspaceGlobalrequiresworkspace_id;systemGlobalrequires neither scope column.- Child metadata includes
table,foreignKey,label,columns,defaultSort, andwidth. Child display metadata does not configure search. searchisfalse,"allColumns", or an object with optionalselfandchildren. Search defaults to"allColumns". Aselfvalue isfalse,"allColumns", or an array of SQL column names;childrenis a recursive record keyed by SQL child table names already declared inmeta.children.- An empty
self: []is invalid; useself: falseto search descendants without searching values from the current table. "allColumns"includes visible application columns at the current node. Foreign keys search the target row label, not the stored ID. Has-many traversal is explicit, and expanded child grids do not inherit the root search term.- Column metadata includes semantic kind, formatting, label, visibility, width
bounds, additive behavior, color/zero/strong hints, notes, and
apiWritable. - Select options belong to the Drizzle column. Use Sapporta
select()or raw Drizzletext(name, { enum: options }); schema extraction serializes the same option list for browser controls. columnBySqlName(table, sqlName)returns the table’sSQLiteColumnornull.columnPropertyName(table, column)performs the reverse lookup and returns the Drizzle property name ornull. SQL column names remain the public query vocabulary even when a Drizzle property uses a different name.- Application validation belongs to the top-level
validate()callback onsapportaTable(). It composes with structural column validation. apiWritable: falseremoves a column from generated write schemas and forms, and generated table APIs reject callers that submit it. Reference-levelapiSettable: falseapplies the same policy to a server-authored foreign key.- A table declaring
meta.childrendeclares the child’s foreign key non-writable, through eitherreferences: { fk: { apiSettable: false } }on the child orcolumns: { fk: { apiWritable: false } }. Either removes the key from the child insert shape, which is what the master-with-$detailscreate branch is built on. Without one of them a$detailsrow carrying that key is accepted and the value is silently replaced by the created master’s key. - Browser
TableSchemacontainsname,label,immutable,columns,children, optionalrowLinks,rowLabelColumns, optionalrowCount, andsearchable. It does not serialize row scope, abilities, request authority, authoring references, validation callbacks, the table-level DrizzledefaultSort, or the recursive search plan. - Visual metadata, hidden fields, and a protected frontend route do not replace server authorization or row scope.