smithable.yml — spec version 0.1
smithable.yml describes what an application does, in technology-neutral terms. This page is the complete reference for version 0.1, together with its companions smithable.auth.yml (required) and smithable.content.yml (optional), and smithable.ux.yml (optional). Later versions add more.
Check a spec with smithable validate. For autocomplete and checking in your editor (VS Code with the YAML extension, or any editor using yaml-language-server), start the file with:
# yaml-language-server: $schema=https://docs.smithable.ai/schema/smithable-0.1.json
The companion files have schemas of their own: smithable-auth-0.1.json, smithable-ux-0.1.json, smithable-content-0.1.json and smithable-context-0.1.json, each started the same way. They say what may stand where; smithable validate is the judge of the rules between the files.
The JSON Schema covers smithable.yml; the companions are checked by smithable validate. The files are changed through operations, not by hand: the operations reference lists every one, generated from Smithable itself.
Example
smithable: 0.1
app:
name: Acme CRM
description: Lightweight CRM for a small B2B sales team.
currency: EUR
timezone: Europe/Mariehamn
models:
Customer:
description: A company we have a commercial relationship with.
fields:
name: string!
email: email unique
segment: smb | enterprise | government
creditLimit:
type: money
min: 0
pages:
customers:
intent: Find a customer quickly and keep their details current.
crud: Customer
navigation: [customers]
Top level
| Key | Required | Meaning |
|---|---|---|
smithable |
yes | The format version: 0.1. Always the first key |
app |
yes | The application as a whole |
models |
no | The data the application stores |
actions |
no | Operations beyond create, edit and delete: custom ones in code, standard ones without |
timers |
no | What the app does on a clock: an event at a time, on a schedule or relative to a record's date, running an action |
outgoing |
no | What the app tells someone when something happens to a record or a timer comes: mail, or a signed call |
incoming |
no | Addresses where another service calls the app, and what a call does |
queries |
no | Records chosen or ordered by code, for what a filter cannot say |
pages |
no | The application's pages |
navigation |
no | Menus. Defaults to one menu with every page, in declaration order |
- The operation
editSpecreplacessmithable.yml, or one of its companion files, as a whole, checked like any other change: for an edit no other operation makes.
app
| Key | Required | Meaning |
|---|---|---|
name |
yes | The application's name |
currency |
no | ISO 4217 code of an active currency, e.g. EUR (a code no country uses is an error, with the nearest suggested). Used for money fields |
timezone |
no | IANA time zone, e.g. Europe/Mariehamn, or UTC; one the runtime does not know is refused with the nearest name. smithable new --timezone sets it; otherwise, where the starter or draft names none, new writes the machine's unless that is UTC, and an app with no pages gets none |
clock |
no | How times are written: 24h (the default) or 12h; smithable validate --explain says which |
date |
no | The order of a date's day and month: day-month ("5 Nov 2026", the default) or month-day ("Nov 5, 2026"). Dates are always written with the month's name, in the page's language (design/formats.md) |
week |
no | The first day of a calendar's week: monday (the default, with ISO week numbers) or sunday (no week numbers) |
numbers |
no | How numbers and amounts are written: point ("1,234.56", "12.5%", "€9.90") or comma ("1 234,56", "12,5 %", "9,90 €"). Unsaid, the language's: en is point, sv is comma. Form inputs read the app's decimal mark and ignore its grouping. setApp --numbers none goes back to the language's; --explain says which and why |
Plus the semantic text keys.
models
Model names are PascalCase (Customer, InvoiceLine). Each model has fields (at least one) and may have semantic text.
Every model automatically has id, owner (the user who created the record, when users sign in), createdAt and updatedAt. These names cannot be declared, and no model may be called User: that is the people who sign in.
smithable validate warns when a field's name looks like data an app should not hold, or should hold only with great care: a payment card's number, security code or expiry (card-data: take payments through a payment provider and keep its reference), a password, key or token (secret-field: sign-in is the app's own, and keys for other services belong in the environment), a national identity or passport number (identity-number), and health or another specially protected kind of personal data (special-category-data). The warning goes by the name alone (a library card's number or a machine's health is not flagged), so whether it is right is yours to judge. smithable validate --json prints every finding with its code, file, line and column as one JSON document ({ valid, diagnostics }), for a program that acts on them. A finding may also have plain: { message, path }: wording for someone who does not read the spec, and the affected thing's path within its file (for a timer, ["timers", "markOverdue"]). The detailed message and text output stay unchanged; programs must allow findings without plain.
| Key | Meaning |
|---|---|
fields |
The fields (below) |
namedBy |
What names a record, its title wherever one record is shown or referred to (design/record-names.md): a field (namedBy: company: a text, a choice, a date, a number or an amount), a reference (namedBy: session: that record's own name), a field one reference away (classType.name), or a list of such parts joined with " · " ([classType, startsAt]: "Hatha · Mon 19 Oct, 08:00"), empty parts left out. A name that would come back to itself through references is refused. Left out, the title is picked by rule: the first short text field, else the first long text, else the record's number |
ownedBy |
The field that owns the record instead of its creator, of three shapes (design/support-portal-path.md §2). A User field, e.g. ownedBy: accountManager: left empty on a new record, it is the creator. On a change the field keeps what is given, and left empty it stays empty: a record with no one in it is changed only by roles with write on the model, and neither a form nor an action takes it for whoever makes the change; setOwner without a field, or choosing someone, is the way. Only a role that may change everyone's records chooses whose a record is: anyone else makes their own, and the form leaves the field out for them. An email field, e.g. ownedBy: customerEmail: the record belongs to whoever has signed in with that address, proven (a code by mail proves it; a provider's account counts only when the provider says the address is verified). The address is stored lower-case and trimmed on every write and compared as stored; an empty address owns nothing, and no account is made from an address. A viewer who may not choose gets their own proven address written in, whatever the form sent, and is refused while their address is not proven ("Prove your address first"); a visitor's public form takes the address written. A reference to a model with an owner of either kind, e.g. ownedBy: supportCase on a message: owning through a reference is reading. The record is read by whoever may read the record it refers to, one step, never two (a chain, or a reference to a model without ownedBy, is an error); the record referred to must be one the viewer may read, and the reference is locked once the record exists. The record keeps its creator as the app's own owner column, so changing or deleting it, and the owner's standard actions on it, stay the creator's and the roles granted write or delete. The operation setOwner <model> [field] sets any of the three, and without a field returns the record to its creator |
capacity |
At most so many records per referenced record, e.g. a booking's places (see Capacity) |
schedule |
Its records are people (or rooms, chairs) whose time is booked: weekly hours, breaks, a gap, time away (see One person's time) |
occupies |
Each record takes a scheduled record's time, e.g. an appointment its barber's (see One person's time) |
trash |
true keeps deleted records in a trash for thirty days (see Trash) |
review |
Holds the uploads of the fields it names until a reviewer approves them (see Review) |
unique |
Fields unique together, e.g. [[customer, number]]: no two records hold the same values in all of them (see Unique values) |
thread |
What a conversation reads from the records when a page shows a list of them as a thread: { body: content, author: sender, side: { field: direction, ours: out } }, each part optional; what is left out is read from the fields (record.lists) |
- The operation
setNamedBy <model> <parts…>setsnamedBy(--noneleaves the title to the rule again);nameRecords <model> <one> <several>calls a kind of record by other names, for one and for several, and retitles the list pages that carried the old name.
Fields
Field names are camelCase (email, creditLimit); any word may be one, default and new too (an action's name may not be such a word, actions). A field is written in the short form or the long form.
Short form: <type>[!] [unique] [= default]
| Example | Meaning |
|---|---|
name: string |
Optional text |
name: string! |
Required text (! = required) |
email: email unique |
No two records may have the same email |
capacity: int! = 12 |
Required whole number, default 12 |
status: draft | sent | paid |
One of these values. The first value is the default |
Long form, for anything more:
level:
type: beginner | allLevels | advanced
default: allLevels # a default other than the first value
rating:
type: int
required: true
min: 1
max: 5
default: 3
description: Stars from one to five.
priority:
type: low | high
default: none # stays empty until someone chooses
| Key | Meaning |
|---|---|
type |
A type, optionally with !, or choices (a | b | c) |
required |
true or false (same as !); or a condition, required while the record fits it: required: { status: [inProgress, closed] } |
by |
app: the form never shows the field; its value comes from its default, an action, an incoming entry, an import or code. For example agent: { type: User, by: app, default: ME() } |
sequence |
true on an int! with no default: each new record gets the next number, counting up from the records' highest in the same transaction, and a number given once is never given again, not after a delete nor after a restore from the trash (an order or invoice number); the field is unique, among an owner's records where unique fields are, else in the app. Numbers may skip (a refused create keeps its number); a backup restored puts the count back where the backup had it. The form never shows it, as with by: app. For example number: { type: int!, sequence: true } |
locked |
true: set when the record is made, never changed after; or a condition, read-only while the record fits it: locked: { status: closed }. The form shows it as fixed and the server refuses a change; an action's set may still change it, which is how a closed case is reopened |
unique |
true or false; or where the value is unique: owner (among one owner's records) or app (in the whole app). true is per owner when the model's records are read by their owners only, else in the app; see Unique values |
default |
A value of the field's type, or a formula like TODAY(), or ME() on a field that refers to User: who makes the record. For choices, none means no default |
formula |
Makes the field computed: its value comes from a formula and is not entered |
examples |
Inputs and expected results of the formula; each becomes a test |
min, max |
Bounds for int, decimal and money; for string and text, the length in characters (by default at most 200 for string and 10,000 for text) |
Plus the semantic text keys.
A condition in required or locked is written as an action's when: a choice field's value or a list of them, a yes/no field's true or false, or a computed text or yes/no field's value (a computed one worked out as the record is loaded). A locked condition is read on the record as it is before the change, so an edit that both closes a case and changes a locked field is refused; a required condition on the record as it would be after it, when it is made or changed, so choosing the status that needs a field without giving the field is refused. setFieldRules Order total --locked status=shipped sets it (--once for locked: true, --by app, --required status=placed, --sequence true for a number in turn; an empty one removes it). A field's default is set by setFieldDefault Order minutes 60 (a number for a number field, true or false for yes/no, a choice's value or none for no default at all, written as the default key on a choice; --remove takes it away), and its bounds by setFieldRange Order minutes --min 15 --max 240 (a text's shortest and longest length on a text field; --none takes both away).
Changing a choice field's values (changeField Order status "draft | placed | onItsWay | canceled" --renames shipped=onItsWay) says what the records and samples holding a value that goes get instead (shipped= leaves them empty); a value still held that the change does not mention is refused, with how many hold it. A renamed value is followed wherever the app names it: in conditions (where, when, a field's locked and required), in what an action sets, in formulas that compare with it and their examples, in a long-form default, in what visitors may read, and in its tone and text. Where a value that is simply gone is named, the change is refused with the place. A choice field with a default always has a value, so it counts as required. A choice field with default: none is optional unless required: true.
Types
| Type | Holds | Default example |
|---|---|---|
string |
Short text | = Unnamed |
text |
Long text | |
markdown |
Long text with formatting (headings, lists, links, emphasis, quotes), written as Markdown and shown formatted; raw HTML in it is shown as text | |
int |
Whole number | = 60 |
decimal |
Number with decimals | = 0.5 |
money |
Amount in the app's currency | = 9.90 |
bool |
Yes or no | = true |
date |
Calendar date | = 2026-09-01 |
datetime |
Date and time | = 2026-09-01T09:30 |
email |
Email address | |
phone |
Phone number | |
url |
Web address | = "https://smithable.ai" |
picture |
A stored picture with its description (see Pictures); no default, never unique | |
pictures |
Up to ten stored pictures, the first the cover (see Pictures); no default, never unique | |
file |
A stored document: a PDF, an Office or OpenDocument file, a text, a CSV or a picture (see Documents); no default, never unique | |
files |
Up to ten stored documents, in order (see Documents); no default, never unique | |
a | b | c |
One of the listed values (camelCase) | first value |
Customer, Customer! |
A reference to one record of another model (see Relations) | |
Order[] |
The records of another model that refer to this one | |
User, User! |
One of the people who sign in (see smithable.auth.yml) |
Relations
A field whose type is a model name refers to records of that model:
models:
Customer:
fields:
name: string!
orders: Order[] # every order that refers to this customer
Order:
fields:
number: string! unique
customer: Customer! # each order belongs to exactly one customer
customer: Customer!is a reference. Each order stores which customer it belongs to (in acustomerIdcolumn);!makes it required, anduniqueallows each customer at most once. Forms show a list to choose from, and tables show the related record's name.- A record's title is what the model's
namedBynames, one part or several (a reference part is that record's own name, so names compose one step at a time); without it, by rule, its first short text field, else the first line of its first long text (sixty characters at most where it is shown), else its number. What a field is called plays no part:smithable validate --explainsays which field the rule picked, andnamedBysettles it. orders: Order[]is the other direction. It stores nothing: it lists the orders whosecustomeris this customer, and the customer's page shows them. The other model must have exactly one reference back, so it is always clear which records are listed. When the other model has a page of its own, the list has Addfor those who may create one: the new form opens with the reference to this record filled in and fixed, and goes back to it. - A required reference prevents deleting the referenced record while it is in use (a customer with orders); an optional one is cleared instead.
- A model may refer to itself, e.g.
reportsTo: Employee.
Pictures
models:
Instructor:
fields:
name: string!
portrait: picture
- A picture is chosen in the record's form. The browser scales it to at most 1600 px on the long side and encodes it as WebP before sending, so a phone's photo never travels whole; the server checks the file again (WebP by its header, at most 1 MB, its size read from the file) and stores it under
DATA_DIR/uploads/, whichsmithable backupcopies with the database. The record keeps{ file, alt, width, height }; the description (alt) is what those who cannot see the picture get, and lists show a thumbnail. - A picture is shown at
/files/<model>/<id>/<field>, loaded through the model's data function, so it can be seen exactly when its record can: a draft's cover is as private as the draft. Replacing or removing a picture removes its file when no other record shows it; deleting the record does the same. Whoever may add or change the model's records may send one; sending counts against the app's write limits. picturesholds up to ten pictures on one record, chosen in the form as a strip (add several at once, remove, reorder); the first is the cover that cards and tables show, and the record page shows them all, each opening large.- A picture field cannot be
unique, have a default, or appear in formulas, searches, dashboards or calendars. Sample data uses the starter's sample pictures (public/images/samples/<n>.webp) when it has any, one to three for apicturesfield; a sample file gives several as a list.
Documents
A file field holds one document on a record, as picture holds one picture: a contract on an invoice, a CV on an application, a receipt on an expense. files holds up to ten, in order.
models:
Invoice:
fields:
number: string! unique
contract: file
receipts: files
- A document is chosen in the record's form and sent as it is. The server reads its kind from the file's own first bytes, not its name: a PDF, an Office file (docx, xlsx, pptx), an OpenDocument file (odt, ods, odp), plain text, CSV, or a picture (PNG, JPEG, GIF, WebP), at most 10 MB; anything else is refused in the app's words. It is stored under
DATA_DIR/uploads/, named by its content, sosmithable backupcopies it with the database. The record keeps{ file, name, type, size }. - A document is served at
/files/<model>/<id>/<field>(the n-th of several at…/<field>/<n>) through the model's data function, so it can be read exactly when its record can. It is sent with its stored type, never sniffed, and sandboxed: a PDF or a picture opens in the browser, anything else downloads. The record page shows each document's name and size as a link. - Replacing or removing a document removes its file when no other record holds it; deleting the record does the same. Whoever may add or change the model's records may send one; sending counts against the app's write limits.
- A document field cannot be
unique, have a default, or appear in formulas, searches, filters, sorts, dashboards or calendars. Sample data has no documents.
Formulas
Computed fields and defaults use spreadsheet-style formulas:
Order:
fields:
total: money!
shippingMethod: standard | express
shippingCost:
type: money
formula: IF(AND(shippingMethod = "standard", total > 100), 0, IF(shippingMethod = "express", 15, 5))
examples:
- input: { total: 150, shippingMethod: standard }
expected: 0
Invoice:
fields:
issuedOn: date! = TODAY()
dueOn:
type: date!
default: DATEADD(issuedOn, 30, "day")
lines: InvoiceLine[]
total:
type: money
formula: SUM(lines.amount)
- Values: numbers, text in double quotes (
"standard"),TRUE/FALSE, and the fields of the same record by name. Money is in whole currency units (100is 100 EUR). Empty fields count as0or"", like blank cells. - Operators:
+ - * /,&joins text, comparisons= <> < > <= >=. - Functions:
IF,AND,OR,NOT,ROUND,ABS,MIN,MAX,PMT(rate per period, periods, amount)(a loan's payment per period),TODAY,NOW(the date and time, for date-and-time fields),DATEADD(date, n, "day" | "month" | "year"),DAYS(end, start),CONCAT. - Over a list of related records:
SUM(lines.amount),AVG,MIN,MAX,COUNT(lines),COUNTIF(bookings.status, "confirmed"), andLAST(messages.sender)andFIRST: the value of the newest (oldest) record in the list by when it was made, empty for an empty list. - A computed field is shown everywhere (forms show it read-only and update it as you type) but never entered. It cannot be required, unique or have a default.
- A formula default is filled in for new records, and can be changed.
- The operation
addField <model> <field> <type> --formula "<formula>"adds a computed field (addField InvoiceLine amount money --formula "quantity * unitPrice"); inaddModelandaddCalculatorPagea field is the shorthand or, for a computed one,{ "type": "money", "formula": "quantity * unitPrice" }. A shorthand default that reads like a formula over other fields (money = quantity * unitPrice) is refused with that hint:=gives a default, set once. - Formulas are checked when the spec is validated: unknown fields, wrong kinds of values, choice values that do not exist, and formulas that depend on themselves are reported. There are no user-defined functions or loops: anything beyond a spreadsheet cell is custom code.
Unique values
A field's unique says no two records hold the same value, and where (design/uniqueness.md):
fields:
email: email unique # the short form: where, as the access says
reference: { type: string, unique: owner } # among one owner's records
code: { type: string, unique: app } # in the whole app
unique: [[customer, number]] # the two together, where as the access says
- The short form
unique(orunique: true) is unique per owner when the model's records are read by their owners only (privateaccess without a role that reads them all, and not public), else in the whole app: two members can both have invoice2026-001in a private app.ownerandappsay it outright, so a change of roles or public pages never moves the index.ownerneeds sign-in. - Fields unique together: a model's
uniquelists sets of two or more stored fields;{ fields: [customer, number], scope: app }says where. A field unique by itself is not listed again. - A number counting up (
sequence: true) is unique by its nature, where itsuniquesays, or as the access says when it has none. - Changing where a value is unique, or adding a rule, is a change of the database's indexes, made by the next
smithable generatelike any schema change; records already breaking the new rule make that migration fail with the database's message, so check for duplicates first. - The operations
setFieldRules <model> <field> --unique true|false|owner|appandsetUnique <model> <field…> [--scope owner|app](--removetakes the rule away) set them.smithable upgradewrites the short form out once, as the access read it then (unique: ownerorapp), so the spec says what the database does; new specs may keep writing the short form.
Trash
trash: true on a model keeps its deleted records in a trash for thirty days, where whoever may delete them can restore them or remove them for good; the rest of the app does not see them (design/trash.md). A unique value holds among the live records only, so a value a trashed record has can be used again, and restoring that record is then refused with the same words a new record gets; a record other records point to with a required reference goes to the trash together with them when their models have a trash too, after a dialog with the facts, and comes back with them; otherwise it cannot be trashed, and the refusal says what uses it (design/delete-together.md). The outgoing deleted event fires when the record is trashed. The operation setTrash <Model> true|false turns it on or off; off removes what is in the trash for good and asks first.
models:
Customer:
trash: true
fields: { name: string!, email: email }
Review
review on a model holds the uploads of the picture, pictures, file and files fields it names (or all of them) until a reviewer approves them (design/file-review.md). A reviewed field that is required holds the whole record: until its file is approved, the record is out of lists, search, dashboards, calendars, the API and the assistant's tools for everyone but its owner and the reviewers, and its owner sees it marked as awaiting review. An optional one holds only the file: the record shows as usual, and to others the picture is a blank awaiting review and the document is not offered. A new upload, and one replacing a file, starts waiting; a rejected one is removed and the reason is shown to the owner. A name that is no picture or file field is an error (review-not-file); all on a model without one is a warning (review-nothing), and so are files with no review page to wait on (review-no-page). Reviewers are the admins and the roles granted review in smithable.auth.yml; they are told by mail, each at most every fifteen minutes, how many files wait, and the review page's menu entry shows the number. Files a reviewer sends, sample data and files from before review was turned on are not held. The operation setReview <Model> <fields…|all|none> sets it.
models:
Listing:
fields: { title: string!, photo: picture!, contract: file }
review: [photo] # or all; photo is required, so a listing waits for it
pages
Page names are camelCase or kebab-case (customers, my-bookings). Each page uses one pattern:
- crud: a list, detail view, and create/edit/delete for one model;
- landing: a page for visitors, built from sections;
- dashboard: numbers, charts by month and the latest records;
- settings: the form for the viewer's one record of a model;
- onboarding: that record filled in steps, the first time someone signs in;
- users: who has access: invite people by email with a role, change roles, remove users;
- data: an administrator's view of the app's records, every model or some;
- calendar: a model's records by week or month;
- articles: a model's records as articles: a blog, news or a knowledge base;
- calculator: inputs and results computed as you type, stored nowhere;
- legal: a privacy page written from the app itself;
- review: the uploads waiting for a reviewer;
- custom: a page of your own, written in code.
| Key | Required | Meaning |
|---|---|---|
crud, landing, dashboard, settings, onboarding, users, data, calendar, articles, calculator, legal, review or custom |
one of them | The pattern (see below) |
sections |
no | Parts of the page beside its kind's own, in order (a text, a FAQ, a model's records); alone, with no kind, a page of parts |
route |
no | Defaults to / plus the page name in kebab-case (classTypes → /class-types). /health, /sign-in and /api/… are reserved |
actions |
no | Crud pages: actions offered as buttons, e.g. [mergeCustomers] |
filters |
no | The days of a date filter are those of the viewer's own zone when they have chosen one, else the app's. A crud page's may go one reference away, session.startsAt: a date, choice, reference, number or yes/no field of the record the reference names (not two steps, not a list, not a person), in the address as ?session.startsAt=today, and defaultFilter may name it. Crud and calendar pages (on a calendar only choices, references, people and yes/no fields: its days are the range; drawn over it as on a list, the ux file's filters look applying): fields the list can be filtered by, e.g. [category, price, available]: a choice or a reference becomes chips (a select when there are more than eight values; a reference whose records the viewer may read number 200 or more, a field that finds them as you type, see filters.pick in the ux file), a number, amount or date a range with "from" and "to", yes/no a toggle. Free text is searched, not filtered; pictures never; a field that refers to a person (assignee: User) gives chips for Mine, Unassigned and the people by name (a select when there are more than eight), in the address as ?assignee=me, none or a person; owner gives signed-in viewers a "Mine" toggle. The state lives in the address (?category=furniture&price=100.), so a filtered view can be linked; the query applies filters, search and sort together, within what the viewer may read. A date or date-time filter also takes a relative value, upcoming (from this moment; for a date without a time, from today), past (before that), today, thisWeek (from Monday) or thisMonth, resolved when the query runs in the app's time zone and kept in the address as written (?startsAt=upcoming). On phones the filters fold behind a "Filters" button; smithable.ux.yml may name the filters shown first on every screen |
defaultFilter |
no | Crud pages: filter values applied when the address says nothing, by filter, e.g. { startsAt: upcoming } so a list of sessions opens on what is to come, or { status: [open, pending] }; each must be among the page's filters and a value its filter takes (a date a relative value or a range, a number a range, a choice its values, yes/no true or false, owner mine, a person me or none; a reference to another record takes none). It shows as a chip the viewer can take away; the address then says ?startsAt=all, which clears it. setDefaultFilter sessions startsAt upcoming sets one, setDefaultFilter sessions startsAt none removes it |
sortable |
no | Crud pages: fields the visitor may sort the list by, either way, from a "Sort by" control, e.g. [price, createdAt]; smithable.ux.yml's table.sort stays the order until someone chooses. Not pictures, long text, lists of records or calculated fields (the query sorts by a stored column) |
mine |
no | Crud pages: true makes the page list only the viewer's own records (my items, my orders), with the same form to add one; it needs sign-in, so it never belongs under public.pages. The list's query keeps only the viewer's records, whatever the address says, and filters: [owner] gives no Mine toggle there |
period |
no | Dashboards: a date field every tile's model has, or a field per model (period: { Invoice: issuedOn, Payment: paidOn }). The page then has period chips (thisWeek, thisMonth, lastMonth, thisYear, a range), in the address as ?period=lastMonth, in the viewer's own zone or the app's. Each count, sum, average, list and by chart is scoped to it; a when list, activity and a custom query ignore it. A by chart then shows only the bars inside. Unsaid, all time. |
export |
no | Crud pages: false takes away the list's Export CSV, for records an owner wants kept in the app (the API's CSV, for a key, stays). Unsaid, a list offers it: the list as filtered and sorted, within what the viewer may read, named <page>-<date>.csv, times ISO in the app's zone with their offset, amounts as plain decimals. |
favorites |
no | Crud pages: true gives each record a heart and the list a "Saved" view of the viewer's own marks (a visitor who clicks is asked to sign in; nothing is shown to others); only makes the page a list of the viewer's saved records. Each mark is the person's own (a table of its own, one row per person and record, gone with either); marking checks that the viewer may read the record. Needs sign-in: without it, nothing is generated |
contact |
no | Crud pages: a "Contact" block on the record page that mails the record's owner (contact: owner) or the user a field of the model names (contact: seller), with the record's title and link; the sender's address is the reply-to, the recipient's is never shown; nothing is stored unless { to: owner, keep: Message } names a model of its own to keep a copy in. That model may have one reference to the page's own model (an Enquiry with project: Project on a projects page), which the server fills with the record the block is on, never from the request (smithable validate --explain names it); any other reference is refused, since visitors would pick among records. Its other plain fields (not by: app) are asked in the block's form, with the landing contact form's fields; a model that asks more than a message still has name, email and message, filled with the sender's. The block's texts are pages.<page>.contact: { title, text, button, thanks } in smithable.content.yml, the kit's words where unsaid. Visitors may send on a public page, otherwise signed-in viewers (a signed-in sender's name and email are filled in and locked); limited like other writes; refused when the recipient cannot be reached |
document |
no | Crud pages: the record as a document (an invoice, a quote, a receipt), printed or saved as PDF from its page at /<page>/<id>/document, read with the viewer's own rights (design/record-documents.md §4). Each block names its fields, and nothing else is printed: show (required) the record's, to: { ref, show } those of a record it refers to, lines: { list, show } a list field's records as a table, totals the record's fields under it, note one text field, and from the settings page's fields (refused without a settings page). A file, a list or a field that looks like a card number, a password or an identity number is refused, and so is a worked-out field read from one. One per model. Its headings and the Print button's words are under pages.<page>.document in smithable.content.yml (title, from, to, lines, totals, note, print) |
search |
no | Crud pages: fields the list can be searched by, e.g. [name, email]: a search box finds records containing the text in any of them, ignoring case. Text, email, phone, web address and choice fields, and references ([number, customer] finds orders by their customer's name) |
Plus the semantic text keys. Visible text such as titles does not belong here; it goes in smithable.content.yml.
- The operation
addPage <page> <model> [route]adds a crud page and puts it in the main menu. Each crud page key above has its own:setSearch,setFiltersandsetSortabletake the page and its fields,setMine,setExportandsetFavoritesthe page and a mode,setContactthe page and who is mailed, andsetDocumentthe page and the document's blocks as thedocumentkey has them (withoutshowit takes the document away); with no fields, oroff, each takes its key away.
Sections
Any page is a list of named sections (docs/design/page-sections.md): its kind's own part first (a crud page's list, a dashboard's tiles, a calendar), and the sections written beside it. A page may also have sections alone, with no kind: a page of parts, in the app's frame unless the ux file says otherwise.
pages:
about: # a page of parts, no kind
sections:
story: { text: } # a heading and paragraphs, from the content file
team: { records: Instructor } # a model's records as cards, as on a landing page
faq: # a section named after its kind
visit: { contact: } # a kind as an option gives the section any name
sessions:
crud: Session # the page's kind: its list and record pages
sections: # more parts around it
notice: { text: }
crud: # where the page's own list sits (first, when not named)
faq:
planning:
sections:
week: { records: Session, view: calendar, starts: startsAt } # a calendar on a page of parts
- The section kinds are the landing page's (
hero,features,records,pricing,testimonials,faq,callToAction,contact,gallery,footer,calculator,custom) andtext. A section is named after its kind, or has any name with the kind as an option written alone (visit: { contact: }), withrecords: <Model>,text,calculatororcustom. Arecordssection takesview: cards | table | calendar(cards by default) withsearch,filters,whereandlimitas on a landing page; a calendar view takesstarts, the date field the records are placed by, needed when the model has more than one. - Sections show in the order written. The page kind's own section comes first unless the kind's name stands among the sections, with nothing after it, to place it. A page's kind is written once, as its own key:
crud: Sessionamong the sections is refused, since a flow (a list with its record pages, an order's checkout) is a page, never a part of one. A landing page's sections stay underlanding. - Their texts are in
smithable.content.ymlunder the page and the section's name, for every kind of page:pages.sessions.notice: { title: Closed on Friday, text: … }. A text section has a title and a text; the others as on a landing page. addSection <page> <section> [--records Model] [--view table] [--starts field] [--text] [--calculator fields] [--custom Name] [--before|--after <other>]adds one below the others (above the footer), or above or below the section named,removeSectiontakes one and its texts away (never the page kind's own),moveSection <page> <section> --before|--after <other>moves one, the kind's own too once its name stands among the sections.changeSectionKind <page> <section> <kind> [--records Model] [--custom Name] [--calculator fields]makes one another kind, in its place and with its name, keeping the options and texts the new kind also has; what goes is named in its description.setSectionList <page> <section> [--search true|false] [--filters f,g|none] [--limit n]gives a records section its search box, filter chips and limit (false,noneand0take them away).- The page's frame (the public frame with a top menu, the workspace with its side menu, or none) is
smithable.ux.yml'spages.<id>.frame. - The operation
addSectionsPage <page> <route>adds a page of sections and no kind (an about page), starting with a text section, and puts it in the main menu;addSectionadds the next.
Landing pages
pages:
home:
route: /
landing:
hero: { button: sessions, secondButton: pricing, shortcuts: [sessions, blog] } # its buttons' pages; up to four shortcuts
classes: { records: ClassType } # a model's records as cards (limit: 6 by default)
latest: { records: Item, search: true, filters: [category, price], limit: 8 } # a catalog's door: the box and chips lead to the model's list page
open: { records: Incident, where: { status: [investigating, identified] } } # only the records these values fit
features:
pricing:
testimonials:
faq:
callToAction: { button: sessions }
gallery: # pictures that open large
contact: { form: Message } # details, and a form visitors send
footer: # the page's own footer, wherever it is listed
- A records section may take
search: trueandfilters(fields of its model, as on a crud page): the box and the chips lead to the model's list page with the same address state (/?q=sofa,/?category=furniture), so a front page can be a catalog's door without a second list. It offers what that list page reads: the box when the page hassearch, a chip row for each choice field among the page'sfilters. When the list page is public, each card opens its record. A crud page may takeroute: /, so the app starts on the list, in the site frame for visitors (with its records and its new form), and the landing page is optional. - A records section may take
where: it shows only the records whose choice fields have one of the values named (one value, or a list of them) and whose yes/no fields aretrueorfalse, as a dashboard tile does. A status page's front page shows the incidents not yet resolved; a shop's the featured products. The condition follows a renamed field and refuses to lose the field or a value it names.addSection home open --records Incident --where "status=investigating | identified"adds such a section,setSectionWhere home open status=resolvedchanges the condition andsetSectionWhere home openclears it. - Sections appear in the order written;
moveSection home faq --before features(or--after) moves one. A section is named after its kind (hero,features,pricing,testimonials,faq,callToAction,contact,gallery,footer), or has any name andrecords: <Model>,calculator: { fields: … }(see Calculators) orcustom: <Component>(see Pages and sections of your own). - A hero's
shortcutsare up to four pages, shown as round icons over its lower edge, each with its page's title and its navigation icon (smithable.ux.yml). ThesetShortcutsoperation sets them. - A hero's
buttonis the page its button opens; without one, the page another section's button opens, else the app's first page (validate --explainsays which).secondButton(a hero only) adds a second button beside it, an outline one, opening the page it names; a hero has none unless it is given. Its words are the content file'ssecondButton, the page's title when not given.setHeroButtons home --button sessions --secondButton pricingsets them,nonetakes one away; a removed page takes its button with it. - A contact section shows an address (with a link to a map), phone, email and opening hours. With
form: <Model>it also has that model's form: visitors add a record without an account, so the model must be listed underpublic.createinsmithable.auth.yml(a warning says so) and cannot link to other records. A model of its own, likeMessagewith a name, an email and a message, read only by admins, is the usual choice. - Their texts are in
smithable.content.ymlunder the page and the section's name. Without them, the hero shows the app's name and description, and records use the model's name. Features, pricing, testimonials and questions show nothing until the content file gives them items. - A landing page has its own frame (the app's name and a way in), not the app's navigation, and is not in the default navigation. List it under
public.pagesinsmithable.auth.ymlto show it without sign-in; records cards show only what the visitor may read. - A landing footer can use
layout: contactBandin its section look (setSectionLook home footer layout contactBand). It uses the site's existing contact section for its address, telephone, email and opening hours, beside the footer links. Opening hours get their own labelled block and keep their line breaks. The band applies only once the site has one of those details. A theme cannot select it. Uselayout: standardto choose the standard footer, or runsetSectionLook home footer layout defaultto remove the setting. - The operation
setItems <page> <section>sets a landing section's items, in place of the ones it had: a feature's title and text, a FAQ's question and answer, a testimonial's quote, name and role, a footer's label and link, a price's name, price, period, text and button. No items removes them. - The operation
setSectionPicture <page> <section> [src] --alt "…"(or--asset <id>for a stored file, from the hosted service only, below) sets a hero's or a media-and-text section's own picture to a file under the app'spublic/images/(webp, avif, jpg or png). Another file loses the old one'sgenerated,kindand widths, which say nothing of it;altstays unless given, and a picture where there was none must say it. Without a file it removes the picture, in every language file too, and the section shows its text alone. Studio's section form uploads the owner's own file with it, under a new name, never over a file that is there. - The operation
setSectionFilm <page> <section> [src]sets a hero's film, a short silent loop that plays over its picture, to an MP4 file under the app'spublic/images/, or with--assetto a stored video from the photo library (only the service gives one, with its record); without either it removes it. It is refused when the hero has no picture. The film is the owner's file: any origin the old one had goes.setSectionPicturewith another file removes the film, which was made for the old picture.
Dashboards
pages:
overview:
dashboard:
outstanding: { sum: Invoice.total, where: { status: sent } } # a number
open: { count: Invoice, where: { status: sent } }
average: { average: Invoice.total }
invoiced: { sum: Invoice.total, by: issuedOn } # by month: a bar chart
weekly: { count: Invoice, by: issuedOn, period: week } # the last eight weeks
byStatus: { count: Invoice, by: status } # a bar per value of a choice
bySegment: { sum: Invoice.total, by: customer.segment } # a choice one reference away
latest: { list: Invoice, limit: 5 } # the newest records
due: { list: Invoice, when: dueOn, within: 2 weeks } # what is due, the overdue first
recent: { activity: changes, limit: 8 } # the app's latest changes
- Each tile is
count: <Model>,sum: <Model.field>,average: <Model.field>(number or amount fields),list: <Model>,query: <query>(a query's records), oractivity: changes(the app's latest changes, as the Activity page has them). What a tile is comes from its key, never from its name. - A list with
whenis a list of what is due:whennames a date or date-time field of the model, and the list holds the records whose date falls before the end ofwithinfrom today (<n> daysor<n> weeks; 7 days unsaid, whichsmithable validate --explainsays), in the app's time zone, earliest first, so the overdue come first, marked. With nothing due the tile says so in a line.wherenarrows it as any list (where: { done: false }). activity: changesshows the latest changes (limit, 8 unsaid) to those who may open Activity; for anyone else the tile is not there at all. It takes nowhere,byorwhen.- A dashboard may be the app's start page (
route: /). One over no records at all is a quiet page: a sentence and the way to the first list, not a row of zeros. wherekeeps records whose choice fields have a value (status: sent) or one of several (status: [sent, overdue]), or whose yes/no fields aretrueorfalse.byturns a number into a bar chart (design/intents.md §5). By a date field, one bar per month over the last six months, or asperiodsays:week(eight weeks, from Monday),month(six),quarter(four) oryear(three), in the app's time zone (app.timezone). By a choice field, or a choice field of the model a reference points to (customer.segment, one reference away), one bar per value, in the choice's order. A record with no value in the field is left out, as a record with no date is, andwherenarrows the records first, so only the values that remain have bars. A reference itself (by: customer) is refused, since its values are unbounded, as is a computed field, andperiodgoes with a date only. A tile grouped by a field the viewer may not read is not shown, as a tile over a model they may not read is not.limitis how many records a list shows (5 by default).- The numbers are worked out from the records the viewer may read, so a dashboard follows the same access rules as the lists. Labels are in
smithable.content.yml; by default they come from the tile names, which are camelCase like field names (totalCost, nottotal-cost). - The operation
addTile <page> <tile> <measure> <of>adds a tile (a count, sum or average of records, the latest ones, or a custom query's records), making the dashboard and its menu entry when there is none;setPeriod <page> <field>gives the dashboard itsperiod, and with no field takes it away. A list takes--when <date field> [--within "2 weeks"]for what falls due;addTile home recent activity changesadds the app's latest changes.
Settings and onboarding
pages:
settings:
settings: BusinessProfile # the viewer's business details
welcome:
onboarding:
model: BusinessProfile
steps: # in order; each asks for some fields
business: [businessName, vatNumber]
payment: [iban, paymentTermDays]
- A settings page edits one record of its model: the viewer's own when the model's records are private, the app's when they are shared (the first one, when there are several). Saving the first time creates it.
- An onboarding fills that record in steps, with Back, Continue and "Do this later". Signing in opens it (unless the visitor was on their way to another page), and once the record exists it hands over to the app's first page. The steps must ask for every required field without a default.
- Step titles and texts are in
smithable.content.yml, under the page and the step's name (business: { title: Your business, text: … }); the heading is "Welcome to" the app, or the page's title. Onboarding pages have their own frame and are not in the default navigation. - The operations
addSettingsPage page model(in the main menu) andaddOnboardingPage page model --steps '{"business": ["businessName"]}'add them.
Users
pages:
team:
users: manage # invite people, change roles, remove users
# for administrators; a role gets it by naming it in its "pages" (smithable.auth.yml)
- The page lists everyone with access and the open invitations, with their role. From it, an administrator invites an email address with a role, changes a role, resends or withdraws an invitation, and removes a user. It is for admins unless a role's
pagesnames it, needs sign-in, and an app has one. A role that is not administrator and has the page may invite people too, but only to the roles within its own rights (below). - An invitation is a mail with a link to the sign-in page (also shown on the page, to send by hand). The invited person signs in with a configured provider using the invited address and has the invited role; the address decides, never the link. Invitations are valid for 14 days.
- Only an administrator makes, unmakes or removes an administrator. A role that has the page without being administrator invites to, gives, takes and removes only the roles whose rights are all its own (each of
pages,read,create,write,delete,actionsandreviewamong its own, and no actions when it may run none); the page offers it only those, and shows the others without a control. - Nobody can change their own role or remove themselves, and the last administrator stays one. Removing a user says which records name them (a reference to them, the records that are theirs, the trash included) and gives those to another member chosen in the dialog, in the same change; without one, what may be empty is cleared, and a required reference needs someone.
- With
selfSignUp: falseinsmithable.auth.yml, only invited addresses and theadminscan sign in at all. - Everyone signed in sets the name others see from their name at the bottom of the menu; an invited person starts without one.
- Beside it, under its route and with its access, are the administrator's other pages: Trash (
/team/trash, every model with a trash, each under its name, with Restore and Delete for good) and Activity (/team/activity). When the navigation shows the users page, the menu's last group, Admin, holds it with those two (docs/design/admin.md). - The operation
addUsersPage <page> <route>adds it and puts it in the main menu. An app has one.
Calendars
pages:
schedule:
calendar: Session # short form: the model's one date or date-time field places records
# calendar: { model: Session, starts: startsAt, duration: classType.durationMinutes, title: classType }
- A week view (days side by side, hours down the side, overlapping records side by side), a month view one button away, and on a phone a day-by-day list. Previous, Today and Next; the week or month is in the address (
/schedule?week=2026-W40,?month=2026-10), so it can be shared. startsis the date or date-time field that places a record; it is inferred when the model has exactly one.ends(a field of the same kind) orduration(whole minutes: a field, or one reference away asreference.field) gives a record its length; without them a date-time record lasts an hour and a date one the day.titleis what a block says (a field, or a reference's title); by default the model's title field, else its first required reference's title.- Records are placed in the app's time zone (
app.timezone); without one the calendar warns and uses UTC. A signed-in person may choose their own zone and clock under their name in the menu: lists, calendars, record pages and forms then show and take times in theirs, on the same instants, and the API and exports answer ISO as before. A landing page's days and a list's date filters stay in the app's zone, and so do mails. - Only the records whose start falls in the range shown are loaded, through the model's access rules, so visitors see what
public.readallows. A record opens on its crud page (or a data page showing it) for those who may open that page; a visitor gets its details in a small panel. Those who may create records click an empty hour, and the new record's form starts then. - The operation
addCalendarPage page model [starts]adds one; "add a calendar for sessions" does too, without a model.setCalendar page [--starts f] [--ends f] [--duration f] [--title f]names the fields it reads (nonetakes one away, so it is inferred again;endsanddurationreplace each other), and goes back tocalendar: Modelwhen only the model is left.
Orders
pages:
menu:
route: /
order:
from: Dish # what is chosen: one money field is its price
into: Order # one record per order, with its one list of lines
ask: [name, phone, wanted, note] # the order's fields the customer fills, in order
hours: { mon-thu: "11:00-20:00", fri-sat: "11:00-22:00" }
lead: 20 # minutes from now to the earliest wanted time
- Visitors choose records of
fromwith quantities and send them as one order: oneintorecord and its lines in one write. The browser sends ids and quantities only; the server reads each chosen record, copies its price into the line, and refuses one that is not available (available: boolonfrom, when it has one) or that visitors may not read. fromhas one money field, its price, and may have one yes/no field, which says what can be ordered; with several,priceandavailablename them (available: nonefor always).intohas exactly one list, whose model has one reference tofromand one money field for the price when ordered (the amount is a formula over it), a number counting up (number: { type: int!, sequence: true }), which the customer is told, and may have one whole-number field for how many (quantitynames it when there are several,quantity: nonefor one of each). Nothing is read from a field's name (inference).asknamesinto's own fields the customer fills: its plain values, so not a formula, the number, the list, a reference or a choice (a status is staff's). Without it, the required ones. A required field that is not asked and has no default is an error.hourssays when orders are taken, in the app's time zone: a day (mon…sun) or a range (mon-fri) to a span"11:00-20:00"or a list of them; a day not named is closed. Without hours orders are always taken.- The page is public when it is under
public.pages;intomust be underpublic.createandfromunderpublic.read, or a warning says so. It is not in the menu. - The operation
addOrderPage page from into [--ask f,g] [--route /]adds one, andsetOrder page [--price f] [--available f|none] [--quantity f|none] [--hours "mon-fri 11:00-20:00"|none] [--lead minutes]changes it (an empty value infers a field again,--lead 0takes the lead away). A renamed field inaskfollows; a field the page relies on cannot be removed while the page is there.
Calculators
pages:
mortgage:
calculator:
fields:
price: { type: money, min: 0, default: 300000 }
deposit: { type: money, min: 0, default: 60000 }
years: { type: int, min: 5, max: 40, default: 25 }
rate: { type: decimal, min: 0, max: 20, default: 4.5 }
monthly: { type: money, formula: "PMT(rate / 100 / 12, years * 12, price - deposit)" }
total: { type: money, formula: monthly * years * 12 }
examples:
- input: { price: 300000, deposit: 60000, years: 25, rate: 4.5 }
expected: { monthly: 1334, total: 400200 }
fieldsare written as a model's: the entered ones are the inputs, the formula fields the results, shown beside the inputs and computed as you type. No references, lists or pictures, nothing required or unique: nothing is stored, and an empty input counts as 0 or "". A formula inside{ … }goes in quotes, since its commas would otherwise split the line.examplesbecome tests: each gives inputs and the results they must produce (several at once).addFormulaExample calculator:mortgage --input {…} --expected {…}adds one (a section's calculator iscalculator:<page>.<section>, and a model's formula fieldfield:Model.field, expecting one value), andremoveFormulaExample <of> <n>removes the n-th.- A calculator page needs no sign-in by itself (list it under
public.pagesfor visitors) and reads nothing. Its texts are keyed under the page:pages.mortgage: { title: …, results: { title: Your payment }, fields: { rate: { label: Interest rate, help: The bank's yearly rate } } }. - On a landing page, a section of any name with
calculator: { fields: … }is the same thing among the other sections; its texts aretitle,text,results(the results' heading) andfieldsunder the section. - The field operations (
addField,changeField,renameField,removeField) take a calculator page's name where they take a model's; a rename follows into its formulas and examples.renameModel <from> <to>andrenamePage <from> <to>rename a kind of record (its table and rows kept) or a page: every place the files name it follows, since the parser records where each name is written; a page without arouteof its own moves to/<new name>.addCalculatorPage mortgage price=money years=intadds one; results are added withaddField … --formula(see Formulas).
Privacy page
legal: privacy is a privacy page written from the app itself (design/legal-page.md): who runs it, what it stores about people and why (every model with an email, phone or user field, with who may read it), uploads, cookies and the analytics setting, mail, logs and backups, and a person's rights. The facts come from the spec, the auth file and the context file, so the page stays true as the app changes; the operator's details are texts in smithable.content.yml under the page's operator (name, address, email, country, hosting), and a more part holds the maker's own words after the generated text. Three more keys hold what only the maker knows (legal-page.md §6.2): keeps, how long each kind of record is kept, in the maker's words, by the model's name (a model named there is listed even when its fields hold nothing personal, and one with no line is said to be kept until removed or asked for; a name that is no model is a warning, privacy-keeps-unknown); services, other services the operator uses that the files do not show, a list of { name, for, where }; and custom, what the owner's own functions (custom code and custom actions) do with people's details. The owner reviews the page's description of the app with reviewPrivacyPage <page> <facts> <day> (Studio supplies the facts' fingerprint and the day), which writes reviewed: { facts, on } under the page; while the facts are the ones reviewed the page says so with the day, and once they change smithable validate warns privacy-unreviewed (legal-page.md §6.4). validate also warns privacy-missing (no privacy page where people sign in, fill in a public form, send mail in, ask the assistant as visitors or are counted by analytics), privacy-custom (custom code and no custom text) and operator-unknown when the contact email is missing. smithable validate warns while the operator's name is missing. The page is public and linked from the site's footer and the consent bar, never a menu entry; addPrivacyPage [page] [route] adds it at /privacy, one per app.
pages:
privacy:
route: /privacy
legal: privacy
Pages and sections of your own
pages:
planner:
custom: Planner # src/custom/pages/Planner.tsx, created once
home:
landing:
hero:
repayment: { custom: RepaymentChart } # src/custom/sections/RepaymentChart.tsx, created once
- For what no pattern covers (a chart, a map, a planner, an embedded video): the value names a component, a capital letter then letters and digits. Its file is created once as a stub and then belongs to the project; Smithable never changes or removes it, also when the page or section leaves the spec.
- The page's route, access, menu entry and texts stay generated, as for any page; a section's place and texts are the landing page's (
titleandtext). The component gets them as props, typed insrc/generated/custom.ts(CustomPageProps,CustomSectionProps). - Code that reads records uses the generated data functions (
src/) inside a server function, as custom queries do.generated/ <model>. server. ts addCustomPage planner Planneradds a page;addSection home repayment --custom RepaymentCharta section.
Articles
pages:
blog:
articles: Post # short form: its parts are inferred
# articles: { model: Post, title: title, body: body, picture: cover, date: publishedOn, address: address, summary: summary, author: author }
posts: { crud: Post } # where staff write them: a page the roles' grants name
- The short form reads each part from the fields' types, never from their names (inference):
titleis the record's title field, which must be a string (namedByon the model settles it);bodythe model's onemarkdownfield;pictureits onepicturefield;dateits onedateordatetimefield;addressits oneuniquestring besides the title;summaryits onetextfield (the long form may name a string);authorits one field that refers to aUser. Only title and body are required. A part found twice is an error that names the long form, which settles it or leaves the part out withnone(author: none). /bloglists the articles the viewer may read, newest first by the date (else by creation), 12 at a time, each with its picture, date and summary (the summary field, else the body's first paragraph)./blog/<address>shows one: its picture, title, date, the author's name when the articles have anauthor(named, or the model's oneUserfield), the formatted body, links to the articles before and after it, and an Edit link for those who may change it on its crud page. Without an address field, articles are at/blog/<id>.- On a public page (
public: pagesinsmithable.auth.yml) the articles have the site's frame (the landing pages'), and each article's head carries its title, summary and picture for links shared elsewhere. Signed-in pages have the app's shell. - Visitors read what the model's public read allows. With
- Post: { where: { status: published } }a draft is neither listed nor found;smithable validatewarns when a public articles page shows a model with a choice or yes/no field and nowhere. - A new record's address, left empty, is made from its title (
Yin for beginners→yin-for-beginners). A landing page's records section of the model links each card to its article. - The operation
addArticlesPage page modeladds one; "add a blog for posts" and "add a news page for posts" do too, without a model.setArticles page [--title f] [--body f] [--picture f] [--date f] [--address f] [--summary f] [--author f]names a part when the inferred one is not right;nonetakes it away.
Data
pages:
admin:
data: all # every model; or a list, e.g. data: [Customer, Order]
# for administrators; a role gets it by naming it in its "pages" (smithable.auth.yml)
- An administrator's view of the app's records. The page lists each model with how many of its records the viewer may read; each model has its own list (at the page's route plus the model's name in kebab-case plural, e.g.
/admin/order-lines), newest first, searchable by its text, email, phone, web address and choice fields, showing the newest 500 with a note when there are more; and a form to create, open, change and delete a record, as on a crud page. A related record opens inside the data page. - Every read and write goes through the models' own access rules, owners, validation and hooks: naming the page in a role's
pageslets that role open it, never do more with the records. - The model lists' routes count as the page's: another page at
/admin/customers(or a crud pagecustomersnext to a data page at/) is aduplicate-routeerror. allis every model in the spec's order, including models added later. It is for admins unlessaccesssays otherwise, needs sign-in, and an app may have more than one (a support view with fewer models).Useris not a model: the users page covers people.- The operation
addDataPage [page] [route] [models…]adds one (admin, every model, when nothing is given).
Review
pages:
review:
review: all # every model with review; or a list, e.g. review: [Listing]
- What waits for review (Review), newest first, each file with its record, who uploaded it and when, and Approve and Reject (with a reason, shown to the uploader; the file is removed). The menu entry shows how many wait.
- For admins and the roles granted
reviewon its models in smithable.auth.yml;pages: alldoes not open it. It needs sign-in. - The operation
addReviewPage [page] [route] [models…]adds one (review, every reviewed model, when nothing is given).
actions
An action is something the application does beyond create, edit and delete. A custom action declares what it takes and returns, and its behavior is code. A standard action sets fields of one record and needs no code (below).
An action's name is camelCase like a field's, and is refused when it is a word the code reserves (return, delete, new, …) or a model's name with a small first letter (checkIn beside a model CheckIn): the refusal names one that fits, the action's name with its model's (returnTool, checkInHabit).
actions:
mergeCustomers:
custom: true
input: { keep: Customer!, duplicate: Customer! }
output: { moved: int! } # optional
intent: Merge a duplicate customer record into the one we keep.
rules:
- All orders of the duplicate move to the kept customer.
touches: { reads: [Customer, Order], writes: [Order.customer, Customer] } # optional: what the code reaches
triggers: [customerMerged] # optional: the outgoing entries the code may fire
examples: # optional: tests of the code, run by the app
- given: { Customer: [{ id: 1, name: Arctic Outdoor Co }, { id: 2, name: Arctic Outdoor }], Order: [{ id: 1, customer: 2 }] }
input: { keep: 1, duplicate: 2 }
after: { Order: [{ id: 1, customer: 1 }] }
output: { moved: 1 }
inputandoutputuse the field shorthand, including references (Customer!means choosing a customer).uniqueand defaults do not apply. One input may be a list of records,customers: Customer[](always required, at most one, never of users): the action then runs on the rows picked in a list, its button in the selection bar, and its function gets the records the person may read; an output holds no list.- Smithable generates the input schema, the input and output types and a server function, and creates
src/once, with the intent and rules as a guide. That file is yours: Smithable never changes it. If the action's input or output changes in the spec, code that no longer fits fails type checking.custom/ actions/ merge-customers. ts - A page lists actions to offer (
actions: [mergeCustomers]); each gets a button and a form for its input. - The action runs for the roles whose
actionsgrant names it insmithable.auth.yml(admins always; see Access). The implementation can ask who is signed in, and the generated data functions check access for that user. - The operation
addAction <action> [name=type…] [--output name=type,…] [--intent "…"]adds one, e.g.smithable op addAction mergeCustomers keep=Customer! duplicate=Customer!. Builder's form is "An action", and "add an action to merge customers" needs no model. touchesandtriggers, both optional, are the code's contract (design/intents.md §6):touches: { reads: [Invoice, Payment], writes: [Payment, Invoice.status] }names the models the code reads and the models, or stored fields of them, it writes (Usermay be named as a whole);triggers: [paymentBooked]names the outgoing entries its work sets off: the entry on the action itself (when: reconcilePayments), or a record entry on a model the code writes (Payment created); it is not a way to fire one, and an entry the action cannot set off is refused. The generated server function hands the code data functions for those models and fields alone, so honest code that reaches further fails type checking: a fence, not a wall. Studio says it in words ("reads invoices and payments, writes payments and an invoice's status, may send paymentBooked") and draws it; an action without a contract may reach anything the person may, and nothing is drawn. An empty list, ortouches: {}, says the code reaches nothing of that kind; withouttouchesat all there is no fence. A written field follows its rename, and its removal, or an entry's intriggers, is refused while the contract names it.addAction … [--reads Model…] [--writes Model|Model.field…] [--triggers entry…]writes it;setAction <action> [--reads …] [--writes …] [--triggers …] [--touches none]replaces each list given:--reads noneor--writes noneis an empty list (the code reaches nothing of that kind),--touches noneremoves the fence, and--triggers noneremoves the list.examples, optional, are tests of the code the app runs (design/intents.md §6), at the first build and whenever one is added, by Smith or by hand: each gives the records before (given, by model, with the example's own ids; a field left out takes the sample data's value for its kind, so required fields need not be spelled out), theinput, and what must hold after:after(records by model; fields not named are not checked, records not named are not checked unlessnothingElse: true, which fails on any other record created, changed or deleted) andoutput(the values returned, orrefusedwhen the action must refuse).asnames the role it runs as (the first admin when left out) andnowthe clock (today when left out). A file input names a file undersamples/, and the list input of an action on rows the ids of the records picked. Models and fields named must exist, a list is given as its records, a computed field is checked inafterbut never given, and a record's field follows its rename; a field an example names cannot be removed until the example changes.smithable code action:<name>has the model write the code until the examples and the app's other tests pass; Studio shows the examples as a table, not the code.addExample <action> --given … [--input …] [--after …] [--output …|refused] [--as role] [--now date] [--nothingElse]adds one (the records as JSON) andremoveExample <action> <n>removes the n-th.
Standard actions
A standard action is a button that moves a record to its next state: resolve an incident, mark an invoice paid, cancel a booking. It names the model, when it applies, and the new values. Buttons that change a record walks through each kind on the invoicing starter.
actions:
resolve:
on: Incident # the record it changes
when: { status: [investigating, identified, monitoring] } # optional: offered and allowed only then
set: { status: resolved, resolvedAt: NOW() } # the new values
markPaid:
on: Invoice
when: { status: sent }
set: { status: paid, paidOn: TODAY() }
onnames a model; the action runs on one record of it.setgives fields of that model their new values (oraddcreates a related record; an action hasset,addor both). A value with parentheses is a formula from the formula library, worked out on the record as it was before the change (NOW(),DATEADD(TODAY(), 14, "day"),(total * 0.25)); anything else is a literal the field accepts (a choice value,true, a number, a text), as for defaults. Computed fields, references, lists and pictures cannot be set; a field without a value is asked for (below).Asking for a value: a key in
setwith no value (cancelReason:) is asked for when the button is pressed. A dialog titled with the action holds the asked fields with their own controls, starting at the record's values and required as on the model. Several may be asked at once.Asking first:
confirm: truemakes the button ask before it runs, in a dialog with Cancel and the action's label; a selection's bulk run asks too. The question is the content file'sactions.<name>.confirm, with{field},{reference}(its record's name),{reference.field}and{title}of the record as it is before the action, worked-out fields included, read with the person's own rights (Send invoice {number} of {total} to {client} at {client.email}?); a mail's placeholders ({view},{pay},{link},{by},{before}) and fields that are never sent (secrets, card or identity numbers) are refused. Without a text it asks with the label and the record's title. When a mail the action sends (anoutgoingentry on it withoutwhere, to an email field of the record or one reference away) would reach nobody on this record, the dialog says so and offers only Close. Not on a custom action, a merge or a split.Adding a related record:
addmaps a model that refers to this one exactly once to the values of one new record, created in the same transaction asset. The reference back is filled with the record and is not given; values work as inset(a literal, a formula on this record, or nothing to ask for it), and every required field without a default needs one. Running the action then also needs the right to create that model's records.resolve: on: Incident when: { status: [investigating, identified, monitoring] } set: { status: resolved, resolvedAt: NOW() } add: IncidentUpdate: { at: NOW(), status: resolved, message: This incident is resolved. }Copying:
copymakes a new record of the model from the one the action runs on, instead of changing it: every stored field and reference is copied except computed fields, the automatic ones (the copy is owned by whoever pressed the button), pictures and unique fields; the map says what differs, with values as inset(copy: {}copies as is).with: [lines]copies the records of those lists too, pointing at the new record; a list's records the person may not read are not copied. A required unique field must get a formula or be asked for; a model with a required picture cannot be copied yet. The person lands on the copy. An action hascopy, orsetandadd, never both; it needs the right to read the record and to create such records (and the lists' records).duplicate: on: Invoice copy: { status: draft, issuedOn: TODAY(), number: } with: [lines]The person pressing the button:
ME()as a whole value, inset,addorcopy, puts in the signed-in person, for a field that refers toUser(set: { assignee: ME() }). A reference left empty (set: { assignee: }) is asked for in the dialog, with the form's own control for it; a literal reference is refused.whenis a condition like the others: a choice field's value or a list of them, a yes/no field'strueorfalse; a computed text or yes/no field may be named too (lastSender: agent, withlastSender: { type: string, formula: LAST(messages.sender) }), read on the record as it is loaded, so never inwhere, filters or sort. Such a condition is text: a renamed choice value is not followed in it. A reference field may be named too, only here:none(empty),any(set), and for a field that refers toUserME()(the record is the signed-in person's) ornot ME()(anyone's but theirs, or nobody's), so "Assign to me" shows only on cases that are not already yours (when: { assignee: not ME() }) and "Release" only on yours. The button shows only on records it fits, and the server refuses the action on others ("This cannot be done now").No
input,outputorcustom: an action is custom or standard.rulesare documentation only, and a warning says so.Access: a standard action follows its model's write access: whoever may change the record may run it, which is each one for their own records and the roles granted
writeon the model insmithable.auth.yml(admins always); and a role whoseactionsgrant names it runs it too, withoutwriteon the model (grant customer actions cancel: a customer cancels their own booking but changes nothing else), as a role opens the pages itspagesgrant names;actions: allis every action. An action that adds a related record also needs the right to create one. The action writes only the fields itssetnames and the ones it asks for, and may change alockedfield only whensetnames it; a copy follows the right to create.A page lists it as any action (
actions: [resolve]), and it must be a crud page of the action's model.Renaming a field renames it in
when,setand the formulas there. Removing a field the action uses, or a choice value it wants or sets, is refused until the action changes.The operation
addAction <action> --on <Model> [--when field=value…] [--set field=value…] [--add Model.field=value…] [--copy field=value…] [--with list…]adds one (an empty value asks for the field; a bare--copycopies as is), and puts it on the model's crud page when the model has exactly one, e.g.smithable op addAction resolve --on Incident --when "status=investigating | identified" --set status=resolved --set "resolvedAt=NOW()".The operation
setAction <action> [--intent "…"] [--when field=value…] [--set field=value…] [--ask-first true|false]changes an action there is: each part named replaces what was there (a bare--whenor--intent ""removes it,--ask-first falsethe question), and the rest stays;--when,--setand--ask-firstare for standard actions (--ask-firstnot for a merge or a split), the intent for any.removeAction <action>removes one, from the pages that list it and fromapi.actionsinsmithable.auth.yml; a custom action's code insrc/custom/actions/stays. Who may run an action isgrant <role> actions <name>insmithable.auth.yml(Access).
timers
What the app does on a clock (design/timed-actions.md): a timer is an event the app raises itself at a time, on a schedule or relative to a date-time of a record, and may run an action over the records the time has come for. Mail and calls stay outgoing's, whose when names a timer as it names an action. The spec holds the timer because what the app does on a clock is what the app does: versioned, generated, shown in What it does, undoable.
timers:
remind:
on: Booking # the records it runs for
at: 1 day before session.startsAt # a date-time of the record, or one reference away, with an offset
where: { status: confirmed } # optional: only records that fit
# no run: the timer only raises its event; outgoing listens
markOverdue:
on: Invoice
at: 7 days after dueOn
where: { status: sent }
run: markOverdue # a standard action of Invoice; a record its when does not fit is skipped
publish:
on: Post
at: publishAt # as it is: when the time comes
run: publish
weeklyDigest:
every: monday # day | weekday | week | month | monday … sunday
at: "08:00" # a clock time, in the app's time zone
run: sendDigest # a custom action, once
payroll:
cron: "0 6 25 * *" # what every cannot say: five fields, the app's time zone
run: closePayroll
outgoing:
reminder:
when: remind # a timer's name, as an action's
to: mail
recipient: owner
- A timer has one of three forms. At a date of its records:
onandat: <field> [N minutes|hours|days before|after], the field a stored date or date-time of the model or one reference away (session.startsAt); it fires once per record for that time, follows a moved time, and leaves alone a record whose time had passed when the timer was added. On a clock:every(day,weekday,week,month, which fire on the first day of theirs, or a weekday's name) withat, a clock time in the app's time zone. By cron: the five-field expression (minute, hour, day of the month, month, weekday;*, numbers, ranges, steps and lists; no names, which areevery's), for whateverycannot say. runis a standard action ofon(run for each record the timer is due for; one itswhendoes not fit is skipped and Activity says so) or a custom action (run once, so the timer has noon). A timer withoutrunonly raises its event, which is how a reminder with no state change is written: the timer and an outgoing entry on it. A clock timer withonruns its action over every record fittingwhere, and its event fires once per record. A clock timer with neitheronnorrun(morning: { every: day, at: "06:30" }) only raises its event, for a list mail: an outgoing entry withlistthat names it.- A timer runs as the app, with no viewer: no role's grants apply, as for incoming calls. Delivery is never the timer's: a channel is
outgoing'sto. - The summary says each timer in one sentence ("A day before a booking's session's starts at, where status is confirmed: raises its event"; "Every Monday at 08:00: runs “Send digest”"; "At 06:00 on the 25th of every month: runs “Close payroll”").
- A timer follows a renamed field in its
atandwhere, and refuses the removal of a field or an action it uses;removeTimerrefuses while an outgoing entry listens to the timer. - Operations:
addTimer <name> [--on Model] [--at "1 day before session.startsAt" | --every day --at 08:00 | --cron "0 6 * * *"] [--where field=value…] [--run action],setTimer <name> …(a new time form replaces the old; changingeveryalone keeps an existing clock time, and switching to a clock needsat;nonetakeswhere,runoronaway) andremoveTimer <name>. - The generated app's tick,
smithable timersand Studio's picker follow the core (timed-actions.md §5, §7).
Merging records
A merge is an action that makes two or more records of a model one (design/intents.md §3):
actions:
mergeCustomers:
merge: Customer # two or more customers become one; the person picks which stays
fields: # what each field does; a field not named is asked when the records differ
email: ask # the person picks one of the values
segment: keep # the kept record's value (the first other's when the kept is empty)
revenue: add # numbers and amounts: the sum
notes: append # texts: the kept's, then each other's, a blank line between
combineLines:
merge: Line
into: new # a new record is made from the picked ones, which stay as they are
fields: { quantity: add }
- The picked records have an order (the order picked in a list, the order of the ids given to the API or Ask), the kept record first. Every reference to the other records, in every model, moves to the kept one, in one transaction; the kept record keeps its owner, and each field follows its rule:
keep(the kept record's value, the first other's that is not empty when the kept is),other(the first other's that is not empty),add(numbers and amounts: the sum),append(text and markdown: the kept's, then each other's, a blank line between),ask(picked in the form). A field not named isask; computed fields are worked out, sequences andby: appfields stay the kept record's, the owner and a reference to the model itself take no rule, and references between models are not fields here: they move. The others go to the trash, markedmerged into <title>, and their unique values are released. The moved records are moved, not changed: nochangedevent and no outgoing mail or call fires for them. Where more than one of the records holds a unique reference or a one-to-one, the merge is refused with the field named; a join record with a unique pair the kept record already has goes to the trash with its record; a list holds the kept record once; a reference between the picked records is cleared. Users cannot be merged. into: newmakes a new record of the model from the picked ones, which stay as they are: the rules give its values with the first picked in the kept record's place, sequences andby: appfields are new, nothing moves and nothing goes to the trash. A unique field's value stays with the source that holds it, so the new record's is left empty and the form says so, unless the picked records are the same apart from what was summed or joined and nothing refers to them: then the form offers to remove them (to a viewer who may delete them), which frees the value. The new record belongs to whoever ran it, as a record they add. There is no link back; the checkpoint names the sources and a notice at the time says what happened.- Undo is the trash's Restore: what is still as the merge left it moves back or is cleared; what was edited since stays and is reported. A unique value taken since refuses the restore. A combine's undo is its checkpoint in the app's history, not the trash: the new record goes and the removed come back.
- It is offered in a list's selection bar when two or more records are picked ("Merge", or "Combine" with
into: new), and a merge on a record's page too, as "Merge into…"; a combine only in the selection bar. The form has a dropdown for which record stays (the first picked preselected), then only the fields that areaskand whose values differ among the records (an empty one is no difference: it is left out of the pick), each with the values and, for a number or an amount, the sum, for a text the join; fields the spec decides do not show. The role needs the action's grant, write on every picked record and on every record that moves (withinto: new: the grant and create on the model, and read on the picked); the delete grant on the others decides whether they go to the trash or stay, emptied of what moved. Through the API and Ask too: a merge runs on the record that stays withothersandchoices(per differing field,keepor the id whose value is taken; one missing is asked back); a combine runs on the model withids,choicesandremove, and answers the new record. mergetakesintoandfieldsand nothing else: noon,when,set,custom,inputoroutput.- The operation:
addAction mergeCustomers --merge Customer [--into chosen|new] [--fields email=ask,revenue=add,…] [--intent "…"]; the action is offered on the model's crud page when there is just one.
Splitting a record
A split is an action that makes one record of a model two (design/intents.md §4):
actions:
splitOrder:
split: Order # one order becomes two
move: lines # the list whose picked records go to the new order
copy: [customer, deliverTo] # the fields the new order takes from the old; unsaid: every stored field but the unique, the sequences, the app's, the pictures, the documents and the lists
- A new record of the model is made with the copied fields, as any new record is (sequences and
by: appfields get their own values, so an order number is new; computed fields are worked out), the picked records ofmovego to it, the other lists stay on the original, and nothing is deleted. One transaction. A field that is unique, computed, a sequence, the app's, a picture, a document or a list is not copied; a required field the new record would not get refuses the split, naming it (name it incopy, or make a unique one a sequence or optional). - Undo is the trash's Restore of the new record: the picked records that are still on it move back, then it goes to the trash; a number it took stays taken.
- It is offered on a record's page as "Split…", not in a list's selection bar: the records of
movethe viewer may see, a checkbox each, at least one picked and at least one left. The role needs the action's grant and the right to add records of the model; the records that move need write. Users cannot be split. splittakesmoveandcopyand nothing else: noon,when,set,custom,input,output,keeporfields.- The operation:
addAction splitOrder --split Order --move lines [--fields customer,deliverTo] [--intent "…"](--fieldsnames whatcopylists); the action is offered on the model's crud page when there is just one.
outgoing
Something happens to a record and the app tells someone. An entry names what happens, whom to tell and how: by the built-in channels, mail, browser push and text messages (design/notifications.md), or by a signed call to a named target (design/integrations.md §4).
outgoing:
bookingMade:
when: Booking created # <Model> created | changed | deleted, or an action's name
to: mail
recipient: owner # the record's owner; a role (admin); or an address on the record
bookingConfirmed:
when: Booking changed
where: { status: confirmed } # optional: only records that fit
to: mail
recipient: customer.email # an email field, or a field that refers to User, one reference away at most
show: [number, wanted, total] # optional: the fields the mail lists under its text (a call's record carries), in this order; none for the text alone
previous: true # optional, for "<Model> changed": what the changed fields were, too
sessionMoved:
when: Session changed
fields: [startsAt] # optional: only a change of these fields counts
to: mail
recipient: bookings.owner # a list field, then the owner or an address of each of its records
orderPlaced:
when: Order created
to: [mail, push] # a channel, or a list of channels that each reach the recipient
recipient: staff
orderReadyText:
when: ready
to: sms
recipient: phone # a phone field of the record
todaysBookings:
when: morning # a clock timer with no records: a list mail
to: mail
recipient: admin # a role that reads every record of the list's model
list: { model: Booking, when: session.startsAt, within: today, columns: [session, attendee, status] }
empty: skip # optional: skip (unsaid; nothing to send, no mail) or send (a mail that says so)
whenis<Model> created,<Model> changedor<Model> deleted, the name of a standard action (the model is the action'son), the name of a custom action (fired after its function returns without an error; there is no record, so a call's body carries the action'sinputandoutput, a mail shows them, a mail goes to a role, andwhereandfieldsare refused), or the name of a timer: one that hason(the model is the timer's; its event comes per record the timer is due for), or a clock timer with noon, which makes the entry a list mail (below), or the name of a payments entry (fired when a payment of it succeeds, on the paid record). A name that is both an action's and a timer's is refused, sincewhencannot tell them apart. Withwhere, a creation or deletion counts when the record fits it, and a change counts when the record fits it after the change and did not before, so an edit to a record that already fits sends nothing. Withoutwhere, every change counts. A<Model> changedentry may namefields: then only a change of one of those stored fields counts (a session'sstartsAt, not its description), withwhereas well when both are given.recipient, for the channels, isowner(the record's owner; a record without an owner sends nothing; for a record owned through a reference,owneris who made it, and the parent's owner is reached by the path,supportCase.customerEmail), a role fromsmithable.auth.yml(every user who has it), anemailfield of the record (for mail), aphonefield (for sms) or a field that refers to User, or any of those one reference away (customer.email,customer.manager); or a list field of the record and thenowneror such an address of each of its records (bookings.owner,bookings.contact): every booking's owner is told when the session changes, each person once, none for a record in the trash. One recipient per entry. The person whose change it is gets no mail about their own change or deletion; a confirmation of what they created (<Model> created) is theirs, as a booking's is.- The mail's subject is the record's title unless
smithable.content.ymlgives one underoutgoing: { bookingMade: { subject, text } }; the body is that text, if any, then the record's fields as the record page shows them (labels and formatted values, references by their titles; nothing a files or pictures field holds, nothing sensitive, no lists of other records, no worked-out fields), and a link to the record (design/outgoing-templates.md). - The subject and the text may hold placeholders in the
{path}form the spec has elsewhere, filled from the record as its page shows the value:{number}a field of the record;{customer}a reference's record by its title and{customer.name}a field of that record, one hop;{title}the record's title,{link}its page's address,{by}the name of the person whose change it is (empty for a timer's or an incoming call's event);{before.status}what a field was, on<Model> changedonly. An empty value is an empty text; there are no conditions, fallbacks or formatting codes, and no way to write a literal brace (a text with braces is a template since this change).title,link,byandbeforeare the mail's own words: a field with one of those names is not reached by a placeholder. A worked-out field of the record itself ({total}) is filled as described undershowbelow; one a hop away ({customer.total}) or before the change ({before.total}) is not. A path that is not a field, holds files, looks sensitive, lists records, or goes two hops is refused when the content file is checked; so is a reference's field the recipient may not read (its title is fine; another field needs a role recipient who may read that model), and{by}to an address on the record is a warning. A custom action's entry takes no placeholders. {view}, the sent document (design/record-documents.md §5): on a model whose crud page has adocument, a mail about one record may hold{view}, the address of a copy of the document as it was when the mail was sent. The copy is kept with the mail; the address carries a random key the app stores only as a hash, so it cannot be guessed or rebuilt. It opens for 60 days from the send, or the entry'sviewDays(a whole number from 1 to 365), and ends for good when the record is deleted or its owner withdraws the links; a wrong, ended or withdrawn address all answer the same "not found". The page is not indexed, cached or followed by a referrer, opening it changes nothing, and it never pays. The outbox and the access log show the address as/d/….{view}is refused on a list mail and on a model with no document page.shownames the fields the mail lists under its text and a call's record carries, in that order, each one the record page could show (no files, nothing sensitive, no lists), or isnonefor the text alone (a call's record then has its id only). A worked-out field of the record itself (total: SUM(lines.amount)) may be listed or be a placeholder in a mail, a push or an sms, never in a call or on<Model> deleted(design/record-documents.md §3): it is worked out in the change's own transaction, after the action's writes, with the lists its formula reads, and written as the record page writes it. One with no value (its formula fails or gives nothing) refuses the change: nothing is changed or sent, and the person is told which value is missing. Unsaid,showlists no worked-out field, so a mail that names none never refuses.previous: true, on<Model> changed, adds what the changed fields among the sent ones were: the mail's line reads "Status: ready (was accepted)" and a call's body getsbeforewith those fields. A role recipient who may not read the model is a warning for the default body and an error when the entry hasshowor a text with placeholders.- The mail is written to an outbox in the same transaction as the change and sent after it, so a change never waits for the mail; one that cannot be sent is tried again with growing pauses for a day, then given up. Activity has a line for each mail sent or given up, and an administrator can send a given-up mail again from it.
tois a channel,mail,pushorsms; a list of channels ([mail, push]), each of which must reach the recipient (a person, the owner, a role's users or a field that refers to User, by every channel; an email field by mail alone; a phone field by sms alone:[mail, sms]with an email field is refused, "sms cannot reach an email field"); or, alone, the camelCase name of a target whose address and secret are settings (OUTGOING_<TARGET>_URL,OUTGOING_<TARGET>_SECRET, e.g.OUTGOING_STATUSFEED_URL); a target takes norecipient. A call is a POST of{ event, model, happened, at, record }, the record as the API gives it (without computed values or what looks sensitive), withX-Event: <entry>andX-Signature-256: sha256=<the HMAC-SHA256 of the body with the secret>, so the receiver can check it came from the app; it should also refuse a call whoseatis more than a few minutes old, so a call caught on the way cannot be sent again later. It goes through an outbox like the mail, retried for a day; a target without its settings keeps its calls until they are set, andsmithable deploynames the missing settings. The app refuses an address that is not http(s), is the app itself, or (in a release) is on a private or local network; it does not follow redirects. Activity has a line per call made or given up, with "Send again".pushandsmsare not target names: an entry withto: pushorto: smsand no recipient is refused as a target of the old name, to be renamed by hand with its settings.pushsends a browser notification to the recipient's own browsers and phones, those where the person has turned it on for the entry, so it reaches the owner, a role's users or a field that refers to User, never an email or phone field (no account, no browser). It carries the subject and the link; the kit's side is built in a later step (design/notifications.md §4).smssends a text through the owner's SMS provider (its settings), to aphonefield of the record or one reference away (customer.phone), or to the owner, a role's users or a field that refers to User who gave a number themselves. It carries the subject, never a default in a starter, and a list mail takes neitherpushnorsms(design/notifications.md §5).- A list mail (design/reports.md §2.2): when
whennames a clock timer with no records (everyorcron, noon), the entry tells about a list instead of a record, and must carrylist: the dashboard list tile's keys,model(orquery, a query's records),where,when(a stored date or date-time field of the model, or one reference away,session.startsAt) withwithin(today, the day that starts when the timer fires, in the app's time zone;tomorrow, the next; or<n> daysor<n> weeksup to the end of the span as a due list has it, 7 days unsaid; withmodelonly, since a query chooses its own records) andlimit, which the mail says when it cuts, pluscolumns: the fields the mail's table shows in that order, each one the record page could show (the rule ofshow). A<n> daysor<n> weeksspan has no lower bound, so the overdue come first, on purpose;todayandtomorroware that day alone, so a morning mail that wants only today sayswithin: today.emptyisskip(unsaid: nothing to send, no mail) orsend(a mail that says so). The entry goes by mail (to: mail; a call to a target comes later) to a role, since there is no record whose owner or address could be meant, and the role must read every record of the model (adminalways does; a role with the record rule alone is refused by the auth file's check, since the mail would show it records it cannot open). A timer runs as the app, so the list is everyone's records.where,fields,showandpreviousare refused on a list mail (the list's ownwheregoes underlist), andlistandemptyon any other entry. The content file'ssubjectandtexttake{count}and{date}as placeholders, not a record's fields. The summary line reads "Every day at 06:30: the day's bookings (session, attendee, status) to the administrators by mail; nothing to send is skipped." - An entry follows a renamed field or choice value and refuses the removal of a field, a value or an action it uses; a list mail follows them in its columns, condition and date too.
smithable validatewarns when a mail's recipient is an email field, or a text's a phone field, on a model visitors may create (the app does not send those: a stranger could make it mail or text anyone), when a role recipient may not read the model (the mail would tell them what the record holds), and when a push's or a text's subject in the content file has a placeholder that reaches an email, a phone, a user or{by}(it shows on a locked screen). - Operations:
addOutgoing <name> <when> [--where field=value…] [--fields field…] [--show field…|none] [--previous true] [--to mail|push|sms|mail,push|<target>] [--recipient …],setOutgoingTo <name> <channels|target> [--recipient …](the channels, comma-separated, or a target, which takes the recipient away; the same checks as the spec),setOutgoingBody <name> [--show field…|none|default] [--previous true|false] [--view-days n](--view-days 0back to the 60 days unsaid) andremoveOutgoing <name>, e.g.smithable op addOutgoing bookingMade "Booking created" --recipient owneroraddOutgoing sessionMoved "Session changed" --fields startsAt --recipient bookings.owner. A list mail:addOutgoing <name> <clock timer> --recipient <role> --list <Model>|--query <query> [--where field=value…] [--date field|ref.field] [--within today|tomorrow|"2 weeks"] [--columns a,b,c] [--limit n] [--empty skip|send](--dateis the list'swhen, sincewhenis the entry's timer; a query list takes nowhere,dateorwithin) andsetOutgoingList <name> …with the same keys, each given one replacing the old (--listreplaces a query and--querya model;--where {}takes the condition away,nonethe date, within or limit; the table keeps at least one column). The summary line reads "When a booking is added: mails its owner.", "When a session's starts at changes: mails every booking's owner." or "When an order is added: mails and pushes to every staff."
payments
A record paid for on a payment provider's own page (design/payments.md): the app sends the payer there and records the payment when the provider's verified word comes, never on the payer's return. The app never touches card data. The section says what is paid, how much, when and what a payment changes; the provider is named in smithable.context.yml (below), the only file that names a technology.
app: { name: Kiosk, currency: EUR } # payments need the app's currency
payments:
orderPayment:
on: Order # the model whose record is paid for; one entry per model
amount: total # a money field of the record, stored or computed
when: created # pay to create: the record is held until paid
paid: { set: { paid: true } } # optional: what a successful payment sets on the record
refund: { by: [admin], when: { status: declined } } # optional: who may refund, and on which records
description: "Order {number}" # optional: what the payer sees on the provider's page
invoicePayment:
on: Invoice
amount: total
when: { status: [sent, overdue] } # Pay is offered on the records that fit
paid: { set: { status: paid } }
outgoing:
receipt:
when: orderPayment # a payment of the entry succeeded, on the paid record
to: mail
recipient: customer.email
onnames a model, and a model has one entry (a second is refused).amountnames a money field of it, stored or computed; it is read on the server when a payment starts, never taken from the browser.wheniscreatedor a condition in an action'swhengrammar onon's fields (a choice field's value or a list of them, a yes/no field's true or false, a reference'snoneorany; notME(), since a payment is recorded as the app).createdis "pay to create": the record is written when the form is sent, but held: counted where counting protects something (a capacity, a sequence), shown nowhere else, itscreatedevents and timers waiting until it is paid; one not paid within the hold time (PAYMENTS_HOLD_MINUTES, 30 unsaid) is removed. The IR marks such a modelheldByPayment, and a visitor's create through the API is refused for it. A record is created unheld and unpaid only by the app itself or by a role among the model's write roles (staff entering one by hand, an import, an incoming call or a key acting as such a role); anyone else's create, by whichever function, is held until it is paid, andsmithable validatewarns about an incoming call that makes them. A condition offers Pay on every unpaid record that fits, checked again when the payment starts and when it is recorded.paid.setgives stored fields of the record their values when the payment succeeds, as an action'ssetdoes: a literal or a formula, nothing asked and noME(), not a computed field, a reference, a list, a picture or a document. It runs as the app, once, on the first move of a pending Payment to paid.refund.bynames roles ofsmithable.auth.ymlthat may refund in the app (admins always may);refund.when, a condition on the record, limits which records. Withoutrefundthe app offers no refund; the owner refunds at the provider, and the app records it. Refunds are of the whole amount.descriptionis a text with the outgoing texts'{path}placeholders: a field of the record, or of a record one reference away, that the record page could show (nothing sensitive, no files, no lists, nothing worked out);{title}is the record's title, and{link},{by},{pay}and{before.…}mean nothing there. Unsaid, the record's title.- The app's
currencymust be set, and a currency counted in thousandths (BHD, IQD, JOD, KWD, LYD, OMR, TND) is refused, since amounts are kept in hundredths. One currency per app. - A payment's name is a camelCase name that is not an action's or a timer's, since outgoing's
whennames all three. - The Payment. A spec with
paymentshas two built-in models, written only by the generated app, like its audit log:Payment(entry,recordthe paid record's id as a plain value,amount,currency,status,providerthe provider's name,providerModetest or live,providerAccountits account id where it gives one,referencethe provider's id,notewhat went wrong,createdAt,paidAt,refundedAt, andrefunds) andPaymentRefund, a refund line (payment,amount,reference,statusasked, done or refused,by,createdAt). They are in the IR'sbuiltInModels, not among the spec's models; a model of the spec namedPaymentorPaymentRefundbeside apaymentssection is refused (rename it, e.g.ManualPayment). - The states. A Payment is
pending,paid,failed,refundingorrefunded, and moves only this way (core'sPAYMENT_MOVES): pending to paid (the provider's success, the amounts equal); pending to failed (the provider's failure or expiry, the hold timer, an unfinished checkout replaced); failed to paid (a success after it was given up, then refunded by the app); paid to refunding (a refund asked in the app); paid or refunding to refunded (the provider's word that the whole amount went back); refunding to paid (the provider refused the refund). Any other event changes nothing. - Outgoing may name a payments entry in
when: it fires when a payment of the entry succeeds, on the paid record, withwhereas for an action. A record's mail may hold{pay}, the address of a page where someone without an account pays the record: it shows the payments entry's description and the amount, nothing else, and a Pay button. It needs an entry that pays an existing record of the mail's model (notwhen: created);validate --explainnames it. Each recipient gets a link of their own, bound to the amount the record asks for when the mail is written; it opens for 60 days while the record fits the entry'swhen, is unpaid and asks for that amount, and ends when the record is trashed or deleted. A wrong or ended address answers "not found"; the page is not indexed, cached or followed by a referrer, and the access log shows it as/p/…. Refused in a subject, on a list mail and on a mail about a deletion (design/payments.md §4.1). - The summary says each entry in a sentence or two: "An order is paid when it is added, on the payment provider's page; a paid order becomes paid: yes. Admins may refund a declined order." / "An invoice can be paid while it is sent or overdue; a paid invoice becomes paid."
- An entry follows a renamed field or choice value in
amount,when,paid.set,refund.whenand the description, and refuses the removal of a field it uses. - Operations:
addPayment <name> --on <Model> --amount <field> --when created|<field=value…> [--paid-set field=value…] [--refund-by role,…] [--refund-when field=value…] [--description "…"],setPayment <name> …(each part given replaces the old;noneremovespaid.set, the refund (--refund-by none) or the description; an empty--refund-whenits condition) andremovePayment <name>(refused while an outgoing entry listens to it; the Payment lines already made stay until the owner removes their table).setPaymentProvider stripe|mollie|fake|nonewrites the context file.
incoming
Another service calls the app: a monitor that finds a site down, a form service, a payment provider. An entry names an address of the app, /incoming/<name>, and what a call does (design/integrations.md §3).
incoming:
monitorDown:
create: Incident # one record per call
set:
title: "{check.name} is not responding" # {path}: a value from the call's JSON
status: investigating
detectedAt: NOW()
id: "{event.id}" # optional: a call seen in the last day is not acted on again
as: staff # the role the call acts as (admin when not said)
paymentReceived:
custom: true # src/custom/incoming/payment-received.ts decides
signed: sha256 # a signature of the body, not the secret itself
chatCommand: # a chat tool's slash command opens an incident
create: Incident
set: { title: "{text}", status: investigating, detectedAt: NOW() }
body: form # the command comes form-encoded, not as JSON
signed: { sha256: "v0:{timestamp}:{body}", prefix: "v0=", timestamp: X-Slack-Request-Timestamp }
header: X-Slack-Signature
challenge: challenge # the tool's setup check: answered with the value, nothing else
as: staff
createwithsetadds one record per call. A value is a literal the field accepts, a formula (NOW()), or a text with{path}placeholders filled from the call's JSON body ({check.name},{items.0.id}); a missing path is an empty text, and a required field left empty refuses the call. References, lists and files are not set by a call yet.custom: truehands the verified call tosrc/custom/incoming/<name>.ts, created once as a stub that answers "received"; it uses the generated data functions, so the access rules hold. For what a template cannot say: find a record and change it, several records, another answer.- The secret is a setting,
INCOMING_<NAME>_SECRET(e.g.INCOMING_MONITORDOWN_SECRET): the caller sends it asAuthorization: Bearer <secret>; withsigned: sha256it sendssha256=<hex>of an HMAC of the body instead, inX-Signature-256unlessheadernames another. Without the setting the address refuses every call. signedmay be a map for a service's own form of the same signature:sha256is what is signed, a text of{body}and, when the service signs the call's time too,{timestamp}("v0:{timestamp}:{body}");prefixwhat comes before the hex (sha256=unless said;v0=);timestampthe header the time comes in, seconds since 1970 (or milliseconds). A call whose time is more than five minutes off is refused, and within those minutes a call with the same signature is a repeat (answered as received, not acted on again), so a captured call cannot be sent again. The text must take{body}, and{timestamp}andtimestampgo together.signed: sha256is{ sha256: "{body}", prefix: "sha256=" }.body: form: the call's body is form-encoded (key=value&…, as slash commands and interactive messages come) rather than JSON;{path}reads its fields, and a field whose value is JSON (payload) is read as JSON, so{payload.user.name}reaches into it. A call that says it is JSON (itsContent-Type) is read as JSON all the same, so one address takes a service's commands and its events. Not for a mail.challenge: <path>: a call whose body has a value at that path is the service's setup check of the address: the app answers200with the value as plain text and does nothing else, whatever else the call carries. The call is verified first, like any other. Not for a mail.asis a role fromsmithable.auth.yml; the record goes through that role's create rule and has no owner, as a key's.smithable validatewarns when the role may not create the model. Withoutasthe call acts asadmin, and the summary says so. For acustom: trueentry, whose code may do anything that role may, a lower role is the safer choice.- A call carrying an id seen in the last day (the
Idempotency-Keyheader, the valueidnames, or for a mail entry the mail'smessageId, without one a digest of the mail) is answered as received and not acted on again: services retry, and a mail is delivered twice. A signed call is known by what is signed, never by the header, which the signature leaves out: the valueidnames, or where that is missing the signature itself (so a signature of the body alone makes two calls with the same body one call). The id is taken before the call is acted on, so two deliveries of one id at the same moment make one record. - Answers:
201with the new record's id,200for a repeat or a custom call,401for a wrong secret or signature,422when the record is refused (a required field empty, a value the field does not take). mail: truemakes each call a mail that becomes a record: the body is the mail a host passes on,{ from, to, subject, text, html, attachments: [{ name, type, data }] }(data in base64), andfieldsnames where its parts go:fromto an email or text field (the address alone, out of "Name "),subjectto a text field,bodyto a text or Markdown field (the text, or the HTML without its tags),attachmentsto afilesorfilefield. Attachments are kept as uploads are: at most 10 MB each, checked, and held for review when the model reviews that field.setgives the rest (status: new). Who passes the mail on is the host's: on smithable.ai a mailbox the owner connects, self-hosted the owner's own receiver.
incoming:
support:
mail: true
create: Request
set: { status: new }
fields: { from: email, subject: title, body: body, attachments: files }
reply: # a mail of one of its requests' threads
create: Message # refers to Request once (Message.request)
fields: { from: from, body: body, attachments: files }
set: { direction: in }
then: { status: open } # on the request it joins: a reply reopens it
replymakes a mail that belongs to the thread of a record the entry made into one record ofreply.create, referring to that record, instead of a new one. That model must refer to the entry'screateexactly once; the engine fills the reference.fieldsandsetwork as the entry's own;thensets fields of the record the reply joins. A mail finds its thread by itsIn-Reply-ToandReferencesheaders first, among the message ids the app sent or received about the record (kept in the kit'smail_threadstable), else by a tag[<app> #<id>]in its subject; neither is a new record. An automatic reply (Auto-Submitted, a bulk or listPrecedence, a delivery report) joins its thread but sends nothing back. A host passesmessageId,inReplyTo,references(an array) andautoSubmittedbeside the mail; without them the tag still works.- Every mail the app sends about such a record or its replies is a thread mail: its subject ends with the tag (
Printer out of toner [Harbour Support #12]), it carriesIn-Reply-ToandReferencesof the thread andReply-Tothe mailbox the entry is fed from (the settingINCOMING_<NAME>_ADDRESS, elseMAIL_FROM), and a mail about a reply is the reply's body alone, a letter rather than a record with labels. Every mail the app sends is markedAuto-Submitted: auto-generated, so auto-responders do not answer it and a mailbox watcher does not take it back in (on smithable.ai the relay also marks it as the app's). - Operations:
addIncoming <name> --create <Model> --set field=value… [--signed | --signed-text "v0:{timestamp}:{body}" --signed-prefix v0= --timestamp <Header>] [--header <Header>] [--form] [--challenge <path>] [--as <role>] [--id "{event.id}"],addIncoming <name> --custom [--id …],addIncoming <name> --mail --create <Model> --fields from=email,subject=title,body=body,attachments=files [--reply Message --reply-fields from=from,body=body [--reply-set direction=in] [--reply-then status=open]],setIncomingReply <name> --create Message --fields … [--set …] [--after …]orsetIncomingReply <name> --none,removeIncoming <name>. A renamed field follows into the entry; removing one it names is refused.
queries
A query is records chosen or ordered by code, for what a filter cannot say:
queries:
churnRisk:
custom: true
returns: Customer[]
intent: Customers most likely to stop buying, most at risk first.
rules:
- A customer without an order in 90 days is at risk.
- Smithable generates the result's type (
src/) and createsgenerated/ queries/ churn-risk. ts src/once, as a stub that returns every record the viewer may read. That file is yours; its code starts from the data functions, which apply the access rules.custom/ queries/ churn-risk. ts - A dashboard shows a query's records with
atRisk: { query: churnRisk, limit: 5 }. smithable code query:churnRisk "<what to do>"has a model write the code (see docs/ai.md); only files insrc/custom/may change, and the type check and tests must pass.- The operation
addQuery <query> <returns>adds one; its code is written afterwards, insrc/custom/queries/.
Sections Smithable does not know: project plugins
A top-level key that no built-in section or plugin handles is an error, never ignored. smithable teach <key> has a model write a project plugin for it once: smithable/, declared in smithable.context.yml (plugins: [newsletter]). After that, the section is handled without AI:
newsletter: # handled by smithable/plugins/newsletter/plugin.mjs
from: hello@stillwater.ax
lists: [classes, offers]
A plugin is one ES module without imports, exporting { key, description, schema, expand?, patch?, generate?, operations?, summarize? }, or a function of the plugin API (OperationError, didYouMean, identifier, kebab, refTo) returning it:
schema: the JSON Schema of the section (type, properties, required, additionalProperties, items, enum, pattern, minItems and uniqueItems are checked).expand(value): the ordinary spec the section stands for (models,pages,queries,actions), merged in as if written by hand, so the database, pages, forms and access checks are built as usual. Clashes with names insmithable.ymlare errors, reported at the plugin's section.patch(value): additions to entriessmithable.ymlalready has, never changes or removals:{ add: "field", model, field, type },{ add: "section", page, section, value? }on a landing page,{ add: "menu", page, menu?, position? }. A missing target or a clash is an error at the plugin's section.operations: operations on the section, shaped like Smithable's own (name,summary,schema,positional,describe,destructive,apply(editors, args, ir)); they appear insmithable op, the MCP tools, Studio and what the AI may propose. A name a built-in operation has is offered as<key>:<name>.summarize(value): the section in plain language for the Builder, one sentence per item.generate(value, ir): optional extra files, only undersrc/generated/plugins/<key>/, the same for the same input.
Capacity
models:
Session:
fields: { startsAt: datetime!, capacity: int! = 12, bookings: Booking[] }
Booking:
fields:
session: Session! unique # with private access: one booking per member and session
status: confirmed | canceled
capacity:
per: session
max: session.capacity
where: { status: confirmed }
closes: 2 hours before session.startsAt # optional: booking until then (the start itself, written as the field)
cancelUntil: 24 hours before session.startsAt # optional: the owner cancels until then; staff always may
peris one of the model's required references;maxa whole number, or a whole-number field of the referenced record written asreference.field;where(optional) counts only records with these choice values (one, or a list of them) or yes/no values.- The check happens where the record is saved, in the same transaction as the write: two people taking the last place at once cannot both get it. A record over the limit is refused ("No places left"); lowering the referenced record's number below what is taken is refused too ("3 are already taken").
- One booking per person is the field's
unique, which under private access means unique per owner.smithable validatewarns whenperis not unique ("one person can take several places"), which is sometimes intended (tickets). It warns too whenperis unique and the records are not private: thenuniqueholds across the app, one booking per session in all, and amaxabove 1 is never reached. closesandcancelUntil(optional) are deadlines: a date-time field of the referenced record, written asreference.field(until that time) or as a period before it,<number> <minutes|hours|days> before reference.field. Pastcloses, a new record is refused on every path (the form, Book a place, the API, the assistant) with "Booking has closed."; pastcancelUntil, its owner's deletion is refused with "Cancelling has closed.". A role that may change (forcloses) or delete (forcancelUntil) everyone's records passes, and Activity has the line as for any change. Nothing is stored: the deadline is read from the referenced record when a write is checked, so a moved session moves its deadlines. The places (below) sayclosesAtandcancelUntilAtfor the block's words.- The operation
setCapacity <model> <per> <max> [key=value…] [--closes …] [--cancelUntil …]sets it (nonelifts a deadline);setCapacity <model> noneremoves it. - Book and Cancel. With sign-in, the referenced record's page (and its panel in a calendar) shows its places ("3 of 12 places left", "Full") and a reservation block. A visitor gets "Sign in to book", which comes back to the page. A signed-in person who may create the model gets Book a place, which creates the record in one step (its other fields take their defaults). After that the block says "You're booked", with Cancel booking, which asks first and deletes the record through its data function. The places are counted over every record, and only the numbers leave the server.
- Records with a capacity get no sample data: every place starts free.
One person's time
models:
Service:
fields: { name: string!, minutes: int!, price: money }
Barber:
fields: { name: string!, phone: phone }
schedule:
hours: { mon-fri: "09:00-17:00", sat: "10:00-14:00" }
breaks: "12:00-12:30"
gap: 10 # minutes kept free after each appointment
away: TimeOff # records of days or hours away
TimeOff:
fields: { barber: Barber!, from: datetime!, until: datetime!, note: string }
Appointment:
fields:
service: Service!
barber: Barber!
startsAt: datetime!
status: requested | confirmed | cancelled
occupies:
resource: barber
starts: startsAt
duration: service.minutes
while: { status: [requested, confirmed] }
cancelUntil: 12h
A class takes places on a session (Capacity); a barber, a physiotherapist or a court is booked by its time: one appointment at a time, inside its hours.
schedulesays a model's records are booked by their time.hoursare the business's week in the app's time zone (app.timezone), as an order page's: a weekday or a range of them (mon-fri,fri-sun) to a span ("09:00-17:00") or a list of spans; a day not named is closed.breaks(a span or a list) are kept free every open day;gapis the minutes kept free after each booking.awaynames a model whose records block time (days off, holidays, an afternoon at the dentist): its name alone takes its one reference to this model and its first two date-and-time fields, in the order it writes them, as when the time away starts and ends;away: { model: TimeOff, resource: barber, from: from, until: until }says them. The summary names the fields it reads.occupiessays each record takesresource's time (one of the model's required references, to a model with aschedule) fromstarts(a date-and-time field) fordurationminutes (a whole-number field, of the record or of one it refers to, as a calendar'sduration), whilewhileholds (choice values, or yes/no, as a capacity'swhere; without it, always). Oneoccupiesper model.- Cancel. It needs
whileto name one choice field, the one it sets. WithcancelUntil(a whole number and a unit:30m,12h,2d) the record's owner gets Cancel until that long before its start; after that the button says to contact the business, and roles with write on the model may still change it. It sets the one choice field ofwhileto the value outside it (cancelledhere); when several values are outside it,cancelTonames the one.cancelToalone gives the Cancel until the start. - Never two at once. The check happens where the record is saved, in the same transaction as the write: a time outside the hours, in a break, while away, or overlapping another record of the same resource (with the gap after it) is refused, with the next free times. Two people taking the same time at once cannot both get it.
- Records that occupy someone's time, and the records of time away, get no sample data: every free time starts free.
- The operations:
setSchedule <model> <hours> [--breaks …] [--gap …] [--away <model>](hours as"mon-fri 09:00-17:00, sat 10:00-14:00";noneremoves it, refused while a model occupies it) andsetOccupies <model> <resource> <starts> <duration> [key=value…] [--cancel-until …] [--cancel-to …](noneas the resource removes it).
Access
Who may do what is said in smithable.auth.yml, in full; smithable.yml names no role (design/access-in-auth.md). Three rules, and nothing implied beyond them:
- The record rule is
defaultAccess: withsharedeveryone who signs in reads every record, withprivateonly their own. Everyone changes and deletes their own records. - A role does what its block grants, shaped like
public: the pages it opens, the models it adds records to (create), reads everyone's records of (read, withprivate), changes (write) or deletes (delete) everyone's records of, and the custom actions it runs (actions). Each is a list of names, orall. A role with no block has the record rule and nothing more;smithable validatewarns when a role can open no page. - Administrators do everything:
admin: all, written in the file; anything else underadminis an error.
shared (internal tools, teams) |
private (SaaS, consumer apps) |
|
|---|---|---|
| Read | Everyone who signs in | The owner, and roles granted read |
| Create | Roles granted create |
Roles granted create |
| Change and delete | The owner, and roles granted write or delete |
The owner, and roles granted write or delete |
| Open a page | Roles whose pages name it (public pages: anyone) |
The same |
| Run a standard action | The owner and roles granted write on its model, unless their actions grant is none, and roles whose actions name it |
The same |
| Run a custom action | Roles whose actions name it |
The same |
| Everything | Admins | Admins |
roles:
admin: all
sales:
description: Works with customers and orders.
pages: all # every page but the administrators' (the users page, a data page), which a role gets by naming them;
# on the users page it then invites and gives only roles within its own rights (see Users)
create: all
write: [Customer, Order] # anyone's customers and orders; deleting them stays each one's own, and admins'
actions: [mergeCustomers] # custom or standard; a standard one also follows "write" on its model
- A role's block with
actions: noneruns no action at all: not on its own records, not by itswritegrant (none wins;smithable validatewarns,actions-none-with-write): a role that owns records and runs no action on them (design/support-portal-path.md §3). A list, or an empty list, keeps its meaning (those actions, beside the owner's own), and without the key the owner runs the standard actions on their own records, as the table says;grant <role> actions nonewrites the key.noneis a grant foractionsonly. What such a role's form can still write, an action it cannot run would set:validatewarns (actions-none-form-writes) until the field is locked or the action is named. accesson a model or a page andallowon an action are errors that say where it went.- A role that opens no page is warned about (
role-opens-nothing), unless the app has anapiblock and the role is granted something on a model the API offers: a role for keys needs no page. Withprivateaccess,writeordeleteon records the role is not grantedreadon is a warning too (write-without-read): nothing would let it open them.createwithoutreadis fine (a form-only role). - The operation
grant <role> <what> <names…|all|none>sets a grant:grant sales write Customer Order,grant sales pages all,grant sales delete none;grant sales allis the whole app andgrant sales nonethe record rule only. Administrators are not granted: they do everything. - With
privateaccess, the short formuniquemeans unique per owner: two users can both have invoice2026-001;unique: ownerorunique: appsays it outright (Unique values). - Everything is enforced on the server, for every read and write: a record the user may not read cannot be opened, even by guessing its id, and cannot be chosen in a form.
- A page the role may not open, reached by its address, answers 403 with the kit's refusal ("Not for your role", and why) rather than an error; a visitor is sent to sign in first. A record out of reach answers 404, as if it were not there. A server function refused answers 403 (401 before signing in).
navigation
Either a list of pages (the main menu), or named menus:
navigation: [customers, orders]
navigation:
main: [customers, orders]
admin: [settings]
The operation setNavigation <menu> <pages…> sets which pages a menu shows, in order. The list replaces the menu, so it names every page that stays.
Semantic text
Any app, model, field or page may carry free text that explains meaning to AI and developers. It is never shown to visitors.
| Key | Meaning |
|---|---|
description |
What it is. On a choice field, a short one (120 characters at most) is also in the assistant's summary line, so a model reads the app's words for the values before it filters on one |
intent |
The outcome or experience it should achieve |
rules |
Domain rules as sentences. A rule does nothing by itself until something implements it; implemented rules get an id: { id: capacity, rule: … } |
The operation setMeaning <concept> <description> gives the app, a model, a field (Model.field), an action, a page or a query (query:<name> when a page or an action has its name) its description (or, with --intent, its intent); setRuleId <concept> <number> <id> gives a rule its id, so code and tests can say they implement it. addRule <concept> <rule> [--id name] writes one (on app, model:Order, field:Order.total, action:…, query:… or page:…; a field gets its long form) and removeRule <concept> <number> takes one away, asking first when it has an id.
smithable.content.yml: visible text
Optional, next to smithable.yml. Every text a visitor sees is derived from names (creditLimit → "Credit limit", class-types → "Class types"). This file lists only what should read differently.
smithableContent: 0.1
language: en # the language of everything a person reads; en is the default
logo: { src: images/logo.webp, alt: A lotus on still water } # the app's mark
initials: SY # the tile's letters (by rule when unsaid)
models:
Customer:
label: Client # singular; the plural defaults to "Clients"
pluralLabel: Clients
fields:
creditLimit:
label: Credit limit (EUR)
help: Orders are held above this amount. # shown under the form field
segment:
values: { smb: Small business } # text for a choice value
Booking: # a model with a capacity: the reservation block's words
reserve: { book: Reserve a mat, cancel: Give up my mat, full: No mats left, booked: You have a mat }
pages:
customers:
title: Our clients # page heading and menu entry
subtitle: Keep every relationship in view. # a line under the heading
description: Every client of Acme, with their orders. # what search engines show (public pages)
menus:
admin: { label: Administration } # heading of a named menu
actions:
resolve: { label: Mark as resolved, help: Closes the incident and tells the subscribers. } # label: its button and page title, else its name in words; help: the button's tooltip and a line under its dialog's title (the intent, in smithable.yml, is never shown)
markSent: { confirm: "Send invoice {number} to {client.email}?" } # the question of an action with confirm: true (Standard actions, Asking first)
outgoing:
bookingMade: { subject: "Your booking #{number}", text: "Thank you, {customer}! See you on {wanted}." } # an outgoing entry's mail; {path} is filled from the record (see outgoing)
assistant: # Ask, the assistant in the app: its texts
name: Nova # the panel's name ("Ask" by default)
greeting: Ask me about your customers and orders. # the first line it shows
placeholder: How many orders are open? # the question box's placeholder
about: Finds and counts customers and orders. # what it is for: shown, and given to the model
assistant holds Ask's visible texts, in the app's language; who gets it is smithable.auth.yml's assistant, its voice smithable.ux.yml's. setAssistantTexts --name Nova --greeting "…" sets them, and an empty one (--name "") clears it, so the kit's words come back.
A landing page's sections and a dashboard's tiles have their texts under the page, by name:
pages:
home:
hero: { title: Find your calm, subtitle: Small classes for every level., button: See the schedule, secondButton: Our prices }
classes: { title: Our classes, text: A little time, just for you. }
features:
title: Why Stillwater
items:
- { title: Small groups, text: Never more than twelve. }
pricing:
items:
- { name: Drop-in, price: €15, period: per class, features: [Any class], button: Book }
testimonials:
items:
- { quote: My favorite hour of the week., name: Aino, role: Member }
faq:
items:
- { question: Do I need experience?, answer: No. }
callToAction: { title: Your first class is waiting, text: …, button: Book a class }
overview:
outstanding: { label: Outstanding }
The new sections' texts:
contact:
title: Questions? Write to us
address: | # one line per line; "Show on map" opens OpenStreetMap
Storagatan 1
22100 Mariehamn
phone: +358 18 123 456
email: hello@stillwater.ax
hours: |
Monday to Friday 7–21
button: Send message # the form's button
thanks: Thank you! We will get back to you within a day.
gallery:
title: Inside the studio
items:
- image: { src: images/gallery/studio.webp, alt: A yoga mat by a window }
caption: Morning light in the studio
footer:
text: Stillwater Yoga · Storagatan 1, Mariehamn
items:
- { label: Class schedule, link: /sessions } # a page's address,
- { label: Email us, link: "mailto:hello@stillwater.ax" } # or https:, mailto:, tel:
A crud page's contact block (contact: owner) has its texts under the page too:
pages:
projects:
contact:
title: Ask for an estimate
text: Tell us about the job; we answer within two days.
button: Send enquiry
thanks: Thank you, we will be in touch.
A text, callToAction or features section may put a picture behind its content with
image: { src: images/team.webp, alt: The team at work } in the content file. The section keeps
the dark scrim facing its text on desktop and rising from the foot on mobile. The scrim stays
strong enough for white type even over a white picture. It supplies the surface in place of the
section's band for as long as the picture is present. Without the picture the existing surface is
used. A features.items entry can also have its own image, with the same picture fields as a
hero image. setSectionPicture changes the section picture or, with --item <zero-based index>,
one feature card's picture. Removing a card's picture keeps its title and text.
A hero may use mark: logo in its look in smithable.ux.yml. The app's logo takes the place of
the visible heading. The title still names the heading for assistive technology. The regular
title appears when the logo is absent or the mark is title. In Studio these choices belong to
the section's existing form.
A hero, and a features, records, pricing, testimonials, faq, contact, gallery or text section, may have an eyebrow: a short line over its title, such as what the section is (dishes: { eyebrow: Popular dishes, title: Favorite meals }), in the primary color (in a hero, in the hero's own text color). A section without one has none; setText "Popular dishes" pages home dishes eyebrow sets it.
A hero can have a picture beside its text: image: { src: images/hero.webp, alt: People stretching in a yoga studio }. The file lives in the app's public/images/ (webp, avif, jpg or png, about 1200×800), which generation never touches; alt says what the picture shows, for people who cannot see it, and is required. The Booking and Invoicing starters come with one. A picture may come in several widths, so a wide screen loads a sharp picture and a phone a small one: width: 1536 is the file's own width in pixels, and widths: [800, 2400] lists its copies', narrowest first, each a file beside it named by its width (images/hero-800.webp, images/hero-2400.webp); one to six copies, each from 100 to 4000 pixels, not on the logo; widths needs width beside it and a file name ending in a lower-case extension. A new app from a description gets them with its hero from the Smithable image library; choosing another picture style or changing src (Studio, setText) takes them off, since the copies were the old picture's. To replace the file by hand, remove width and widths or replace the copies too.
On the hosted service a picture may instead be a stored file from the business's photo library: image: { asset: m_01hz…, alt: …, width: 2400, widths: [480, 960, 1600] } names it by its id in place of src (exactly one of the two), and the app serves its copies as media/<asset>/w<width>.webp, fetched into public/media/ by the workspace (docs/design/media-storage.md). Only the service sets one, through setSectionPicture with --asset, after it has made the copies: it fills width (the largest) and widths from its own record, which nobody writes by hand, and a model is never offered a stored file. setText changes neither asset nor src over it, and a language file has none. An operation that would leave a place without the stored file it held (removing the picture, the section or the page, or choosing another) is confirmed for each such place, as any change that loses data. When the owner deletes a file from the library, the service takes it out of every app with removeMedia --asset <id> [--asset <id>…]: one change, one undo step, that empties every place naming those files, in every language file too. A section's own picture goes (a hero is then shown without one), a gallery's or media-and-text section's item goes with its caption, a features card keeps its words and a tile its label, and a hero's film goes whole; a gallery that lost every item is left with none. A file named nowhere changes nothing, and the change says so. Like --asset, it is a person's choice: no model is offered removeMedia.
A hero's picture may move: film: { src: images/hero.mp4 } beside its src plays a short silent loop over it, under the same wash, text and badge (docs/design/section-film.md). The picture stays: it shows first, and it is all that a visitor who asked for less motion or to save data, a printed page or a page without scripts gets. The film starts only while the hero is in view, is invisible until it plays, and a Pause button is shown while it runs; a visitor's pause holds for the page view. The file is an MP4 (H.264, no sound track, its index before its data), 3 to 12 seconds long, at most 1920 pixels on its long side and 1080 on its short, and at most 5 000 000 bytes and 5 Mbit/s on average; Smithable checks the name, and smithable validate reads the file and names the rule it breaks. On the hosted service a film may instead be a stored video, film: { asset: m_01hz…, heights: [720, 1080] }, served as media/<asset>/<height>.mp4 with media/<asset>/poster.webp (docs/design/media-storage.md §7): the service makes its renditions silent and at most 1080 high, so its source may be larger or have sound, and setSectionFilm --asset fills heights from the service's record and refuses a video that runs under 3 or over 12 seconds or has no rendition yet; a narrow screen plays the 720 rendition. Like a stored picture, only a person chooses one, and removeMedia takes it out. A film has its own origin, generated and kind as a picture has, and none of the picture's. Only a hero's picture takes one, and only in the content file: a language file's picture has none. An app without a film gets no film code.
generated: true on a picture (a hero's, a gallery's, or the logo) says an AI made it. The app then marks it, as the EU's AI Act asks of pictures that could pass for photographs, with the EU's common icon for AI-generated content in the bottom right corner, as one badge: on a picture across the page the EU's worded label ("AI GENERATED") in an English app, and in another language the icon with "AI-generated" in the app's language joined to it; alone on a small one, such as a gallery's. A picture styled where it is used is not marked (the cover hero under the theme's color, the centered one under its veil, the photo one under its scrim), and the logo never is, since a mark is not a photograph. The pictures from the Smithable image library carry it; a maker's own pictures carry it only when the maker says so, and changing a picture's src with setText takes it off. A hero's, a tile's or a gallery's picture may also say what it is with kind: ai-realistic (made by an AI and looking real), ai-drawn (made by an AI and drawn, such as a pastel or an ink wash) or photograph; Smithable writes it from the image library when it places a picture, and the badge's default follows it (aiBadge in the ux file). A picture marked generated: true without a kind counts as ai-realistic.
A gallery or mediaText section whose pictures present the owner's own work (finished jobs, a project) says so in the spec with pictures: work (jobs: { gallery:, pictures: work }); any other section with it is refused, and it is never guessed from a section's name. Before an app is published, Studio's release review lists the hero's picture and the pictures of such sections that an image model made (generated: true), since published as they are they would present work nobody did, and offers to replace each with the owner's own picture, to keep it, or to remove it. The review never stops a release. A gallery's picture is given by its place from 0: setSectionPicture home jobs 2 images/jobs-own.webp replaces it, and without a file removes it. Keep is the operation keepPicture <page> <section> [item], which writes kept: true on that picture in smithable.content.yml (--kept false takes it off); a kept picture is not listed again, and only the hero's pictures and those of a pictures: work section are kept. Both operations take --was <file>, the file the caller saw there, and change nothing when another file is there now (Studio's review sends it with each choice). kept is only allowed beside generated: true, and it goes by itself whenever another file takes the picture's place, by any operation; new words for the same file keep it. setSectionPictures home jobs work sets it; without work it takes it off.
Every model, field, choice value, page and menu named here must exist in smithable.yml; smithable validate checks this. Semantic text (description, intent, rules) is never shown to visitors, so help text belongs here.
Libraries for custom code (src/custom/) are declared in smithable.context.yml, the one file that names technologies, with exact versions: packages: { chart.js: 4.4.1 }, or with the operation setPackage chart.js 4.4.1 (none removes one). Smithable adds them to package.json; the stack profile's own packages (React, Drizzle, …) are refused, since Smithable keeps their versions in step.
A counter of visits is one line in smithable.context.yml, naming one provider with the app's id there: analytics: { plausible: shop.example.com }, { umami: <website id> }, { fathom: ABCDEFGH } or { google: G-XXXXXXXXXX }; the operation setAnalytics plausible shop.example.com sets it and setAnalytics none takes it away. Its script is loaded in a production build only (never in development or a preview), and the app's Content-Security-Policy allows its addresses and nothing more. Plausible, Umami and Fathom set no cookie and start at once; Google Analytics waits for the visitor's yes in the consent bar (design/analytics.md).
The consent bar is the kit's: shown at the bottom of every page when something asks for consent and no choice is kept, with Accept and Decline as equal buttons and a link to the page named privacy when there is one; the choice is kept in the browser for a year, and "Cookie settings" in the menu or the footer asks again. Its words can be changed in smithable.content.yml under consent: { text, accept, decline }. Custom code that embeds something needing consent (a map, a video, a chat widget) calls afterConsent(run) from #/kit/consent: run runs once the visitor has said yes, and the call makes the bar appear.
language is the language of the app for the people who use it: the words the app brings itself (Save, Cancel, the sign-in page, the mails) are in it, and dates and numbers in sentences the app writes follow it. The maker's own texts are as written, whatever it says. It must be a language the app kit has words in (en and sv so far; design/language.md); in another language than English every model should give its pluralLabel, since the plural made by an English rule would read wrong, and smithable validate warns about those that do not. The operation setLanguage sv sets it.
languages lists the other languages the app is offered in (languages: [sv]), each one the kit has words in and none the app's own. Each has its own file, smithable., with the same keys as the content file and the texts in that language: any text a person reads, the content file's own and those Smithable derives from names (a model's label and plural, a field's label, a choice's values, a page's title, an action's button). It holds texts only: no language, languages, logo or initials, nor what no person reads as words (a picture's file, an address to go to, the operator's email or phone). addLanguage on a language listed whose file is missing writes the file again. A text left empty, or not there, shows in the app's own language, and smithable validate says how many there are (text-untranslated). smithable op addLanguage sv lists the language and writes its file with every text empty, to be filled in; setText … --language sv writes one; removeLanguage sv takes the language and its file away. smithable translate sv has the configured model draft the texts still empty (Studio's Languages tab has a button for it); they are saved with setTexts as one change, and undo takes it back. A renamed field or choice value follows into every language file. (design/languages.md.) The app's own language is at /; each other one at its code first (/sv/, /sv/menu): a public page in Swedish is a page of its own for search engines, with the other versions named beside it, and the sitemap lists every version. Signed-in pages keep one address and show the language last chosen with the switch at the foot of each page. A text the same in several places is translated once: when two places give it different words, the app shows the first and validate says so (text-shared).
logo is the app's mark: a file under the app's public/images/ (webp, avif, jpg, png or svg; square or nearly, about 512 px) and what it shows. It is drawn before the app's name in the menu and the landing page's header, and the browser's tab and an installed app's icons show it; without it the app shows its name alone. src must have that form (logo-src) and alt must be there (logo-alt); whether the file is there is not checked. The operation setLogo images/logo.webp --alt "A lotus" sets it, and setLogo without a file removes it. An app made from a description gets one from the Smithable image library when one of its marks fits the description, and none otherwise (design/app-logo.md).
The app's name is always its wordmark: in the heading font, a little tight, in the theme's heading weight and case. The browser's tab shows a tile of the app's initials (unless the logo stands in), a square with a fifth of its side rounded in the theme's light primary, the letters in the color on it, the same file for the same spec. The initials by rule are the first letter or digit of the first two words that have one (words are what spaces separate; emoji and signs are passed over; upper-cased, ß gives S and ʼn gives N; at most three combining marks on a letter), one when there is one word, none when the name has no letter. initials in the content file gives one or two letters or digits instead, each with at most three combining marks (initials-form otherwise); it is not translated. setInitials SW sets it and setInitials without letters goes back to the rule. smithable validate --explain says which initials are in force and why.
The operation setText changes one text by its path, e.g. setText "All our customers" pages customers subtitle (an empty text restores the default). A list item's text is addressed by its position, e.g. pages home faq items 0 question. Studio uses it when a text is changed in place in the preview. removePage removes a page's texts along with the page and takes it out of public.pages and off a landing hero's button and shortcuts (its confirmation says so), and removeSection a landing section's; addSection home gallery adds a section (with records, form or button as its options), which Builder offers as "A section on a landing page". addLandingPage home makes a landing page with a hero and a footer, at / when that is free, and lists it under public.pages unless public is false.
smithable.auth.yml: sign-in, roles and what is public
Required, next to smithable.yml. It is technology-neutral: no library names or keys (those are environment variables).
smithableAuth: 0.1
signIn:
providers: [email] # email (a code by mail, no keys), google, facebook; the order is the button order
allowedDomains: [acme.com] # optional: only these email domains may sign in
selfSignUp: false # optional: only invited people and admins (needs a users page)
defaultAccess: shared # shared | private; required with sign-in (see Access)
roles: # optional; "admin" always exists and is always all
admin: all
sales: # what the role may do beyond the record rule (see Access)
description: Works with customers and orders.
pages: all
create: all
write: [Customer, Order]
defaultRole: sales # the role new users get; needed with several roles
admins: [owner@acme.com] # become admins when they sign in
# ⚠ PUBLIC: visible to anyone on the internet, without signing in.
public:
pages: [schedule] # pages anyone may open (the sign-in page always is)
read:
- Session # models anyone may read
- Post: { where: { status: published } } # …or only the records with these values
- Incident: { where: { status: [investigating, identified, monitoring, resolved] } } # one of several
create: [ContactMessage] # models anyone may create, e.g. a contact form
# What other programs may reach with a key (a key is made in the app, with a role).
api:
models: [Customer, Order] # or all, with except: [AuditEntry] for the ones left out
actions: [markPaid] # the standard actions they may run, and custom actions on rows (run on ids); or all
assistants: true # optional: offered to AI assistants as tools too
# "Ask", the assistant in the app, for the people who use it.
assistant:
for: [admin, staff] # roles; or signed-in (everyone who signs in); or anyone (visitors too)
may: read # read (the default) | change: it also adds, changes and runs actions
| Key | Meaning |
|---|---|
signIn |
none for an app without sign-in (then only public is reachable), or providers with optional allowedDomains and selfSignUp (true by default; false lets only invited addresses and the admins sign in, and needs a users page). setProviders email google sets the providers, in button order; setDomains acme.com sets allowedDomains (setDomains none lifts it) |
defaultAccess |
shared or private: the default access to records (Access). The operation setDefaultAccess shared sets it |
roles |
Role names (camelCase), each all (the whole app) or a block: an optional description and the grants pages, read, create, write, delete, actions and review (the models whose waiting files the role approves or rejects, Review), each a list of names or all (Access). admin always exists and is always all; so does a role for everyone else, member, when none is named. The operation grant <role> <what> <names…> sets a grant |
defaultRole |
The role new users get; never admin (that would make everyone who signs in an administrator: an error) |
admins |
Email addresses that get the admin role when they sign in with the address proven, also an address added after its account was made, and may always sign in. setAdmins you@your-domain sets them; smithable new puts in --admin or the Git user's address. A warning says when only invited people may sign in and there is no administrator (nobody could), and when an address is on a domain nobody receives mail at (.example) |
public |
pages, read and create: what anyone may open, read or create without signing in. A users, data or review page is never public: it is refused under pages. A public page shows a visitor only records of models under read: smithable validate warns when a public page shows a model that is not there (its list or its cards would be empty). A model in read may be limited to records with certain values, Post: { where: { status: published } } (a choice field's value or a list of them, or a yes/no field's true or false): visitors, and signed-in people who read only because it is public, see those records everywhere (lists, searches, cards, references), while roles that may read the model and a record's owner see the rest as before. A mapping needs a real condition: - Post: {} or where: {} is refused (list the name alone to let visitors read every record), and so is a model listed twice. Removing the field or the value is refused until the condition is changed. The operation setPublicWhere Post status=published sets it (several values as the choices are written, `"status=investigating |
api |
What other programs may reach with a key: models (a list, or all, which also offers models added later, as setApi and the summary say, with except for the ones left out), actions (standard actions of offered models, a list or all) and assistants (true to offer the same to AI assistants as tools; { delete: true } lets them delete too). Nothing is offered unless it is said here. Listing is not granting: a key is made in the running app by an administrator, with a role, and that role's access decides what the key may do, exactly as for a person. api needs sign-in. A warning names offered models with personal data. The operation setApi Customer Order --actions markPaid sets it (setApi all --except AuditEntry; setApi alone turns it off). The app serves it under /api/v1 with its description at /api/v1/openapi.json; Let other programs use your app walks through it. With assistants, the same is offered as tools for AI assistants at /mcp; they may delete only with assistants: { delete: true } (setApi … --assistants true --assistants-delete true) and a key whose role may delete. Without a key, a program or assistant is a visitor: it may list and read the offered models that public.read lets anyone read (with their where) and add to those public.create lets anyone add, never change, delete or run an action; the description and the tools show it only that (a key or a session that may open the users page sees the whole description), and with nothing public every call needs a key and the description names nothing |
assistant |
"Ask", the assistant in the app (design): for is the roles that get it ([admin, staff]), or signed-in (everyone who signs in), or anyone (visitors too, who are answered by the app's wording rules over what is public and never by a model); may is read (the default: it finds, counts and adds up) or change (it also adds, changes and runs standard actions, each confirmed by the person; it never deletes). It acts as the person asking, so it reaches what they may. Without the block the people who use the app do not get it. The operation setAssistant [roles… | signed-in | anyone] [--may read|change] sets it; with nothing it is switched off |
smithable validate warns about risky combinations, and never changes their meaning: shared access with open sign-up and no allowedDomains (anyone with an account at the provider can sign up and read everything), and public reading of models with personal data (email, phone or User fields). Everything named in public must exist in smithable.yml, and every role used there must exist here.
In development, the sign-in page also offers signing in as any role, without contacting the provider. Production builds leave that out.
- The operations:
setSignUp <who>chooses who may sign in (anyone with an account at the provider, withinallowedDomains, or only invited people and the admins, which needs a users page);setRoles <roles…>sets the roles with a description each and the role new users get (a role keeps what it was granted; a new one starts with the record rule only);setPublicsets what anyone may open, read and create without signing in, each list replacing the old one, and its confirmation says what visitors lose.
smithable.ux.yml: how the app looks
Optional, next to smithable.yml. It changes how the app looks, never what it does, and names no technology: presets and choices, not CSS.
smithableUx: 0.1
theme:
preset: corporate # modern (default) | minimal | playful | corporate
brand: { primary: "#1d4ed8", background: "#f5efe6", font: Inter } # optional
density: compact # comfortable | standard | compact; the preset's own unless set (corporate is compact)
motion: subtle # none | subtle | lively; the preset's own unless set (playful is lively)
pages:
customers:
icon: users # its icon in navigation (optional)
filters: { shown: [segment, creditLimit] } # the filters shown when the list is first reached; the rest fold behind "More filters" (one with a value in the address shows anyway)
# on orders: filters: { pick: { customer: search } } # how a filter on a reference is picked: list (every related record as a choice) or search (a field that finds them as you type); unsaid, by the count: a search from 200 records the viewer may read. Which fields filter is smithable.yml's; this says only how a filter is picked; a reference to a person keeps its own filter (Mine, Unassigned, the people)
table:
columns: [name, email, segment] # which fields the list shows, in order; without it: the title, a picture, the required fields, then the rest, five at most, no long text unless the model has no short text to be titled by
below: { email: phone } # a second field under a column's value
sort: -creditLimit # the order until someone sorts; "-" for largest or latest first
view: cards # cards on wide screens too (table by default)
totals: [creditLimit] # a last row with the sum of each of these numbers or amounts, and the count, over every record the viewer may see that fits the filters and the search
record:
lists: { orders: table } # a list on the record page: table (default) or thread
subtitle: email # the line under a record's name on cards and in pickers: a name part
detail: [segment, creditLimit] # smaller parts after it
form:
fieldOrder: [name, email, phone] # these first; the other fields follow (or sections, not both)
sections: # groups with headings; fields in none follow at the end
- { name: contact, fields: [name, email, phone] }
- { name: terms, fields: [creditLimit, segment] }
columns: 2 # short fields two abreast on wide screens
control: { creditLimit: slider, segment: radio } # how a field is entered
mortgage:
form: { results: below } # a calculator's results under its inputs
about:
frame: site # site | app | none: the public frame, the workspace, or the page alone
home:
theme: { preset: playful, brand: { font: Nunito Sans } } # a landing page's own theme
header: { position: scrolling } # sticky | scrolling: the header kept at the top as the page scrolls, or away with it (sticky); over: hero
width: wide # contained (72rem) | wide (80rem) | full
sections: # a landing page's sections' looks, by section name
hero: { layout: split, image: left } # split | centered | plain | cover | photo; the picture's side
features: { columns: 4 } # 2 | 3 | 4 | 5 | 6 (3)
classes: { layout: grid, columns: 6 } # records: cards | list | grid; columns 2–6 (cards 3, grid 4)
testimonials: { layout: carousel } # cards | carousel | one
pricing: { highlight: Pro } # the plan drawn forward, by its name
faq: { layout: list, columns: 2 } # accordion | list; a list's columns 1 | 2 (1)
gallery: { columns: 4 } # 2 | 3 | 4 | 5 | 6 (3)
callToAction: { band: primary } # any section but the hero and footer: none | muted | inverse | primary (none)
tones: # colors of choice values, by meaning
Order.status: { shipped: success, canceled: danger } # success | warning | danger | neutral
navigation: topbar # the menu in a bar across the top (sidebar by default)
chrome: light # the menu on the page's own colours (the theme's by default)
aiBadge: false # no badge on pictures an AI made (unsaid: by each picture's kind)
pictures: { style: pastel } # the image style of the app's library pictures
assistant: { voice: friendly } # Ask's manner: plain (the default) | friendly | formal
primaryis a color like"#1d4ed8". The theme derives its colors from it and adjusts its lightness where needed, so text on it stays readable in light and dark mode.backgroundis a color like"#f5efe6"for the page behind everything: a pale wash of it in light mode and a deep one of the same hue in dark mode, quiet enough for text. Cards, borders and muted text are derived from it again, while the primary, the states and the charts stay the theme's. A color the theme's text could not read on is warned about and not used. In Studio: Look → Color → Background.fontis one of Inter, Nunito Sans and Source Sans 3: open-license fonts the app hosts itself. Without it, the preset's font is used (Inter for modern and minimal, Nunito Sans for playful, Source Sans 3 for corporate).density:comfortableis the default for apps that do not say,compactmakes controls, rows and padding smaller, for data-heavy tools, andstandardsits between them. One density per theme: a landing page's own theme gives the public pages theirs, so "customer pages comfortable, staff pages standard" is a page theme withdensity: comfortable. Touch screens keep 44 px controls whatever the density.record.subtitleandrecord.detailare the lines under a record's name on the page's cards and in reference pickers (design/record-names.md §3): the same parts as a model'snamedBy(a field, a reference, a field one reference away), read by the same formatter; a page that says nothing shows the name alone.setRecordLines sessions instructor.name --detail classType.levelsets them;noneand an empty list take them away.belowshows a second field under a column's value, like the phone number under the email; the column's heading names both.markputs a round mark before each record's title in the list:initials(the title's first letters on a colour of their own, the same for the same name) orpicture(the model's first picture, initials where a record has none; refused for a model without a picture field).setTableMark customers initialssets it,noneexplicitly shows no mark, andinheritremoves the override.actions: menuputs each row's actions behind a "…" button at the row's end instead of buttons in the row (below, the default).setRowActions invoices menusets it,belowkeeps the buttons as an explicit choice, andinheritleaves it to the theme.calendar(a calendar page only) gives its blocks a colour and their places left.colorBynames a choice field of the calendar's model (each block on its value's tone, thetonesthe ux file gives; a value with none takes a chart hue by its place among the values, andneutralstays plain), a reference (each referenced record its own colour from the chart hues, by its number, the same for everyone) or a choice one reference away (classType.level).capacity: { left, of, look }names two number fields, the places left (a computed one is fine) and the places there are, shown asnumber("4 of 12 left", the default),pips(a dot a place, filled when taken, up to 20, else the number) or abar. Both follow a renamed field and go with a removed one.setCalendarColor schedule classType.levelandsetCalendarCapacity schedule placesLeft capacity --look pipsset them,nonetakes them away.viewis how the records show:week(the default: the week's grid, its hours from the week's first record to its last, 07:00 to 21:00 for an empty week),agenda(the coming four weeks as one list, a heading for each day with records) ordays(the coming seven days side by side, each a list, three to a phone's width and the rest scrolled to), from today or thefromday in the address.filters: [timeOfDay]adds chips for Morning (a start before 12:00), Afternoon (12:00 to 17:00) and Evening (from 17:00), kept in the address astime; the boundaries are the kit's, whichsmithable validate --explainnames.setCalendarView schedule daysandsetCalendarFilters schedule timeOfDayset them (weekkeeps the grid as an explicit choice andinheritleaves the view to the theme; no filters take them away).frameis the frame a page shows in (docs/design/page-sections.md §4):site, the public frame with the app's name, a top menu and the site's footer;app, the workspace with the side menu;none, no menu and no header, for a screen that stands alone. Without it, the page kind's own: landing and articles pagessite, the restapp. The frame is the page's, never the role's: staff open asitepage from the workspace and see it as members do.setFrame about sitesets it;defaultreturns to the kind's.filters.shownnames the page's filters (fromsmithable.yml) that show at once; the others fold behind "More filters" until wanted, a folded one with a value in the address showing anyway. Without it every filter shows.setFiltersShown customers segment creditLimitsets it; with no fields it is removed.filters.lookis how the page's filters show: unsaid (ordefault), chips for a choice or reference up to eight values and a list to pick from above;chips, every choice and reference as a row of chips however many values it has, a referenced record's picture (its model's first picture field) on its chip when it has one. A reference whose readable records reach 200 is still a search (filters.pick). Ranges, yes/no and Mine stay as they are.setFiltersLook orders chipssets it,defaultexplicitly uses the platform presentation, andinheritremoves the override.filters.picksays how a filter on a reference is picked, by the filter's name:list, every related record the viewer may read as a choice (chips, a select above eight), orsearch, a field that finds them by name as you type, one chosen. Unsaid, the count decides each time the list loads: a search from 200 related records the viewer may read, else the list;smithable validate --explainsays which. A chosen record the viewer may not read, or that is gone, shows as not found and filters nothing. Only the page's own filters on a reference to a record may be named; a reference to a person keeps its own filter (Mine, Unassigned, the people).setFilterPick orders customer searchsets it;autoreturns it to the count.themeon a landing page (only there: it has its own frame, while a list page in another theme would look like another app) changes the keys it names from the app's theme, with the same keys (preset,brand,density,motion). Its font is installed too.setTheme --page home preset playfulsets one, andnonereturns a key to the app's; formotion,noneis a value (no motion), not a return.sectionsgives a supported landing or mixed-page section a look. A hero issplit(the text beside its picture,image: rightorleft),centered(the text over the picture),cover(the picture across the width, the theme's primary color washing over it behind the text; in dark mode the dark background tinted with the primary, under the page's own text color),photo(the picture across the width at least 80% of the window's height on a wide screen, a dark scrim from the start side, the text and buttons at the start; on a phone the scrim rises from the foot, where the text sits; the text is always white on the scrim, in light and dark mode alike, so it reads whatever the theme)plain,stage(the app's own list beside the headline, seestagebelow), orinset(the picture as a tall card on the page, in the card's surface with its edge and shadow, about five twelfths of the width, the text beside it; on a phone the card first, wider than tall), ortiles(the picture large with the text on its dark scrim, and the hero'sshortcutsas picture tiles beside it: two or three, a tiles hero with fewer or more is refused; each tile is dressed in the content file by its page,hero: { tiles: { menu: { image: { src, alt }, label: Our menu } } }, its label unsaid the page's title, its picture unsaid the page's own hero picture when it is a landing page, else the title on the primary color; a renamed page's tile follows it); without a picture every hero is plain. A cover or photo hero may take the other's wash withoverlay: brandoroverlay: dark(unsaid, its own; with another layout it is refused, andnoneis refused since the text stands on the picture).stage(a hero withlayout: stage) names a list page of the app that everyone sees (not a page of the viewer's own or saved records), drawn beside the headline by the kit's own table with its first six records in the list's own order, a picture of the list (nothing in it opens), on the card's surface (glass where the theme's cards are); unsaid, the first such list page in the navigation, whichsmithable validate --explainnames. Any other page is refused, and on a public page so is a list visitors may not read. A records section of the same landing over the stage's model is a warning, since the page would show the same records twice (awhereof its own may make both right). A hero'sheightisauto(only as tall as its content, so the next section shows above the fold) orfull(the window's height under the header, the whole window when the header stands over it); unsaid, its layout's own (a photo hero most of the window, the rest their content).facts: [Instructor, ClassType]puts a row of figures under the hero's text, each the count of a model's records the viewer may read, labelled by the model's plural; on a public page a model visitors may not read is refused.eyebrow: addressoreyebrow: hourswrites a line over the title from the page's contact section: its address's city, or the first line of its hours (the content file's own eyebrow wins); a page without a contact section is refused. Features and a gallery havecolumns, how many stand side by side on a wide screen (2 to 6; 3 when not said; fewer on a phone); a records section iscards,list(rows with a small picture),grid(the pictures, titled)week(each record under its day, the days side by side on a wide screen, up to seven, one under the other on a phone, days with nothing left out; the day is the date fieldbynames, else the model's first date or date-time field, whichsmithable validate --explainnames; a model with no date is refused, andbynaming anything but a date is refused; a renamed field is followed into it), orledger(ruled rows with the record's figure at the end, its first money field, else its first number, chosen by type; without either, ruled rows alone; no pictures: prices, sessions, accounts), withcolumns(2 to 6) for cards and a grid, 3 for cards and 4 for a grid when not said (a list and a ledger have none: columns there are a warning); testimonials arecards, acarouselthat scrolls sideways, oronelarge quote; a pricing section'shighlightnames the plan drawn forward; a FAQ is anaccordionor alistwith every answer shown, a list incolumns1 (the default) or 2 (columns with the accordion are a warning: it is one column). Every section but the hero and the footer (features, records, pricing, testimonials, faq, callToAction, contact, gallery, text, calculator) may have aband:none(the default, an open section),muted,inverseorprimary, the section across the window's width on that surface of the theme (mutedthe theme's muted surface under the page's text;inversethe text color as the surface, the background's color as the text;primarythe primary under its own text color), its content in the page's measure. Inside a band the text, cards, buttons and links take the band's colors: oninverseandprimaryevery text is the band's text color, cards and lines are a step from the surface, and a button turns inverse (the band's text color as its fill). A band whose text would read under 4.5:1 on its surface in the page's theme, in light or dark mode, is a warning (band-contrast); the built-in themes' bands all read, and a brand primary's text color is chosen to read on it. A section of your own (custom) draws its own frame and has none. On a page in the app's frame a band stays in its column.setSectionLook home gallery columns 5sets one,defaultremoves it. Removing a section removes its look.header(a landing page only) is the look of the page's header, the frame's top row with the app's name and menu, not a section. Itspositionissticky(the default: it stays at the top while the page scrolls, on the theme's card color with its bottom border, on a phone too; a section reached by its link stops below it) orscrolling(it goes up and away with the page). Itsoverisheroornone(the default; written, an explicit choice that masks a theme'sover: hero): over the hero, the header stands on the hero's own wash (dark, or the brand's on a brand cover) with the hero's text color, and takes its own surface once the hero has scrolled under it, in one transition of its colors (at once under reduced motion); it needs acoverorphotohero, whose picture runs across the width, and is refused with any other. Each landing page says its own.setSectionLook home header position scrollingsets it (the header is named like a section; a section of the page namedheadertakes the name first),defaultorinheritremoves it and leaves it to the theme.width(a landing page only) is how wide the page's content runs:contained(72rem, the default),wide(80rem) orfull(edge to edge, the page's side gutter kept); the header, the sections and the footer follow it, a text's line length does not.setLandingWidth home widesets it;containedkeeps an explicit choice,inheritleaves it to the theme.results(a calculator page'sformonly) isbeside(the default: next to the inputs on a wide screen) orbelow. A phone always shows the results under the inputs.iconis one of users, user, file, receipt, cart, package, calendar, layers, book, briefcase, building, chart, clipboard, home, mail, settings, star, tag, truck and list. Without it, one is chosen from the name of the page's model (Customer: users, Invoice: file, Session: calendar; list when nothing fits).navigationis where the app's menu sits on a wide screen:sidebar(the default),topbar(a bar across the top, the name at the start and the links beside it) ortopbar-centered(the name centred between the links). A phone always shows the bar with the menu behind its button.setMenuLayout topbarsets it;sidebaris explicit, whileinherit(or the legacydefault) removes the override.chromeis the menu's surface, apart from where it sits:light(the page's own colours) ordark(in light mode the text colour as its surface and the page's as its text; in dark mode, whose page is dark already, a step below the page); unsaid, the theme's own menu colours.setChrome lightsets it,defaultremoves it.menuActiveis how the menu marks the page that is open:filled(the primary behind it),subtle(a tint behind it) orunderline; unsaid, the menu's own, filled in the sidebar and underlined in a bar across the top.setMenuActive subtlesets it,defaultremoves it.pictures.styleis the image style the app's library pictures are in (the hero and the sample pictures), a style of the Smithable image library such aslifelike,photographs,pastelorink-wash. Set it withsetPictureStyle pastel, which reads the library's current version (latest.json, thenversions/<version>.json), fetches that style's pictures, checks each against the library's hash and writes them withpublic/images/pictures.json, the record of what was placed (each file's library version, entry, hash, role, whether an image model made it, and its credit), all in one change that undo takes back; without the network it refuses and changes nothing. A picture you changed or added yourself is never replaced. Records in the project's development data that were seeded with a replaced sample picture get the new one; a deployed app's data is never touched. A style is offered only when it has a picture for every library picture the app holds. Unsaid,pictures.jsonsays what the pictures are. When the key and the placed pictures disagree (after a hand edit),smithable validatesays so; generation never fetches.aiBadgesets the badge on pictures an AI made (see the content file's pictures). Unsaid, each picture by itskind: anai-realisticone (or one without a kind) carries it, anai-drawnone does not.trueputs it on every picture an AI made,falseon none; a photograph never has it, and neither does the logo. Whether your audience needs it is your responsibility.setAiBadge on,setAiBadge offandsetAiBadge default(which removes the key) set it; switching it off while a realistic AI picture is placed is refused unless you say--acknowledged, the same acknowledgement Studio asks for.smithable validate --explainsays the state in force and, by default, how many placed pictures it badges.setPictureStyle ink-wash --recolourapplies the light tint from the current theme, using each library drawing's original. Greyscale themes use the original drawings. The placed record gives each tinted file's source hash, colours, and rule, and undo restores the earlier pictures. An Ink wash style without a library wash hue cannot be tinted.assistant'svoiceis Ask's manner, a fixed set of lines given to its model:plain(the default: short, no pleasantries),friendlyorformal. Its texts are the content file's, who gets it the auth file's.setAssistantVoice friendlysets it.tonesname a choice field asModel.fieldand give some of its values a meaning (success,warningordanger), which the app shows as the badge's color. Values not listed areneutral.- Every page and field named must exist in
smithable.yml; computed fields can be columns but not in a form. Renaming or removing a field updates this file, and so does removing a choice value. controlchooses how a field is entered:slider(a number withminandmax),stepper(a whole number),radio(a choice of at most five values, or a yes/no),select(a choice or a reference),combobox(a reference),textarea(a text),switch(a yes/no);inputis the default for its kind. A control that does not fit its field is an error. A calculator page's fields take one too.sectionsgroup the form under headings, whose texts are insmithable.content.yml(pages.; the name otherwise);customers. { title: How to reach them }form. sections. contact: columns: 2puts short fields two abreast, long texts and pictures full width.sortandviewshape the list.record.listsshows a list of related records on the record page as athread: a conversation with a reply box, for messages, notes or remarks (lists: { messages: thread }), instead of a table. The thread reads the listed model as itsthreadkey says (Message: { thread: { body: content, author: sender, side: { field: sender, ours: agent } } }insmithable.yml), and what that leaves out by rule: its first long text field (textormarkdown) is the message, its first field that refers to a person (else its first email) the writer,createdAtthe time, its files and pictures the attachments, and its first two-valued choice the side, the first value being ours (sender: agent | customer). Where the rule has several fields to pick from,smithable validatewarns (thread-ambiguous) and names the words to write;setThread Message --body content --author sender --side sender --ours agentwrites them (--noneremoves them). A model with no long text field cannot be a thread.smithable validate --explainsays what every such rule settled: each model's title field, where its unique values are unique, what a conversation reads, and who may run each action. The reply box adds a record by the ordinary create, the reference back filled in, so every other required field needs a default orby: app; one that has neither is a warning (thread-needs-form).setRecordList customers notes threadsets it. A list may also beinline(lists: { lines: inline }): its records as rows edited in place on the record page, each row its values as inputs and its references as pickers (not the reference back, lists, files, pictures, the owner or what the app fills; computed fields shown as text), an empty row at the end to add one and a button to remove each, every row saved on its own by the related model's own create, change and delete when the focus leaves it or on Enter, with their access, rules and undo. Under the rows stands the record's own money formula over the list (total: SUM(lines.amount)). A related model that does not refer back to the record, or has a required field the row cannot give (a file or a picture with no default), is refused inline, and a related model that is also a page in the menu is a warning (inline-in-menu): the page stays reachable by its address.record.header: summaryputs the record's summary in its title row andform.aside: summarybeside its form (under it on a phone, before the lists): its status as a badge (its first choice field with tones, else its first choice field), its amount (its first money field or money formula) and its first two dates, read by type and named bysmithable validate --explain;noneis the default. With both, each part stands in one place: the status badge in the title row (none when the model has no status) and the amount and dates beside the form.setRecordSummary invoices header summary(oraside, ornone, an explicit choice;inheritleaves it to the theme) sets one. Every record page opens with a link back to its list and says when the record last changed, and by whom for those who may read its history.record.picturesshows a record's pictures large on its read-only view (not on the form that edits it):asidebeside the fields (about seven twelfths of a wide screen, on top on a phone) ortopacross the top, the first large and the rest as a strip of thumbnails that switch it in place; they come from the model's first picture or pictures field, whichsmithable validate --explainnames, and a model with none is refused.setRecordPictures catalog asidesets it (none, the default, keeps them among the fields as an explicit choice;inheritleaves it to the theme).record.first: threadputs the lists shown as threads before the form, so a case page leads with its conversation;form(the default) keeps the form first, and a page with no list as a thread is refused.setRecordFirst cases thread(orform, an explicit choice;inheritleaves it to the theme) sets it; the last thread shown as a table or inline (setRecordList) takesfirstwith it.- The operations
addTheme(a theme of the project's own,--useto apply it),setTheme,setColumns,setTotals,setFieldOrder,setTone,setIcon,setBelow,setControl,setFormSections(each sectionname:field,field),setFormColumns,setResults(a calculator page),setView,setFiltersShown,setFrame,setSort,setRecordLinesandsetSectionLookchange it. A value they write is an explicit choice that masks the theme's default,none,default,containedandweekincluded;inheritleaves the key to the theme (see Themes, defaults). presetnames an installed built-in theme (smithable themes) or one of the project's own (see Themes).
Section rhythm, media composition and named record emphasis
A named mediaText section reuses plain content text, an optional image and an optional page
button. For example, story: { mediaText: true, button: schedule } belongs under a landing
page or the existing mixed-page sections. Its content at pages.about.story accepts
eyebrow, title, text, button, caption and image: { src, alt, generated }.
The image uses the existing path/alt validation; paragraphs split on blank lines. No image
leaves the text and link. The section has an h2 under the page heading.
Choose layout: collage to place the main image and up to three extra pictures in the same
section. The pictures overlap at wider widths and form a grid on a phone. Each can be opened
at full size. Write extras under the section's items as - image: { src, alt }, or add them
in order with setSectionPicture about story images/work.webp --item 0 --alt "Wooden stool".
Using a different layout keeps the extras in the content file for when the collage is restored.
The collage choice belongs to the section, and is unavailable as a theme default.
# smithable.ux.yml
pages:
about:
sections:
story:
layout: split # split | stacked | collage; split stacks below the wide breakpoint
image: left # left | right; semantic/keyboard order stays text then picture
rhythm: airy # compact | standard | airy
measure: reading # reading (66ch) | wide (80ch), body copy only
fit: cover # cover | contain
aspect: portrait # landscape (3:2) | portrait (3:4) | square
focal: left # center | top | bottom | left | right
setSectionLook about story rhythm airy uses the normal operation; inherit removes the
choice. Rhythm is separate from theme control density: compact uses spacing 6 (4 on phones),
airy uses 20 (12 on phones), standard preserves the section's own spacing. It changes section
padding and section gaps, never button/input/row sizes. Existing framed sections offer rhythm;
text and mediaText offer measure. Hero, footer and custom sections have their own controls.
Omitting these choices preserves existing output. Theme section defaults use the same finite
choices and normal provenance; explicit section values win.
Gallery, mediaText and the hero offer fit/aspect/focal; record pictures keep their existing
presentation. A split or inset hero's framed picture takes all three (unsaid, its own shape); a
picture across the hero fills it and takes focal alone, the point kept in view when it is cut. Named ratios reserve space before loading, and the full-image native dialog
always uses contain so cropping never removes access to the complete image. Caption and alt
remain content. Cover, including duotone styling, is presentation and cannot promise that an
arbitrary crop tells the whole story. Missing/slow images keep the reserved frame.
On a CRUD page, optional record.summary: { status: [payment], amount: [actual], dates: [due] }
selects readable fields for the existing header/aside summary. Status takes at most one choice,
amount one money field/formula, dates up to two date/date-time fields in authored order. An
omitted slot keeps the existing automatic selection; [] explicitly shows none. It grants no
field or record access. All-empty selection removes the summary and its empty aside.
setRecordEmphasis invoices amount actual selects a field; omit fields to restore automatic,
or pass --fields "" for none. Studio offers automatic, none and compatible field pickers.
Renaming follows the binding; removing a selected field requires changing/resetting the
selection first. Existing summary/activity/queue sections compose workflows without tab groups
or a new page kind. Form errors keep the existing visible field/error behavior.
Themes
A theme is data, never CSS: a font, a corner radius, a shadow and the colors the app uses, in light and dark mode. The mode shown is the visitor's: System (the device's setting) unless they chose Light or Dark under Appearance, kept in their browser and applied before the page first paints. The built-in catalogue contains the themes Smithable ships (smithable themes lists your installed version); a project's own go in themes/<name>.yml (written through addTheme <name> --text @file [--use], refused with the file's problems) and theme.preset names either. smithable theme --from <url> [--name x] [--use] makes one from a site: a browser (Playwright) reads its background (the page's own before its bands), text, primary button color (a link styled as a button counts), cards, corners and font (a hosted font by its own name, its headings' too when they differ) in light and dark, in any CSS color (Tailwind 4's oklch too), with the dark mode a page switches by a class (.dark or data-theme="dark" on <html>) when the device's setting changes nothing; it derives the rest, raises contrast where it would not read, and adds it with addTheme.
A strong pink, orange or blue accent needs a look on real pages in both modes. Contrast is the automatic floor; visual balance is judged in the preview. There is no automatic accent-strength limit.
The built-in themes, each in light and dark:
| Preset | What it looks like |
|---|---|
arcade |
Bungee headings over Chivo; #f3580e primary on #fdf8ff |
darkmatter |
JetBrains Mono headings over JetBrains Mono; #d87943 primary on #ffffff |
halftone |
Zilla Slab headings over Hanken Grotesk; #c92d09 primary on #f9f3db |
starry-night |
Newsreader headings over Newsreader; #3a5ba0 primary on #f5f7fa |
nature |
Outfit headings over Outfit; #2e7d32 primary on #f8f5f0 |
dusk |
Hanken Grotesk headings over Instrument Sans; #7581b5 primary on #f1f4ff |
hallmark-midnight |
Mona Sans headings over Hanken Grotesk; #4d95b6 primary on #f8faff |
ultraviolet |
Outfit headings over Hanken Grotesk; #6b2ae3 primary on #f0ecfa |
ribbon |
Instrument Sans headings over Hanken Grotesk; #035f5c primary on #fcf9f3 |
studio |
Instrument Serif headings over Inter; #e97219 primary on #f1f7f8 |
vantage |
Hanken Grotesk headings over Hanken Grotesk; #7c9d39 primary on #f6fcff |
specimen |
Bodoni Moda headings over Inter; #144bb7 primary on #f9f3e8 |
spore |
Young Serif headings over Instrument Sans; #be8176 primary on #fff7f0 |
sticker |
Big Shoulders Display headings over Hanken Grotesk; #d3036a primary on #f5f0e7 |
broadside |
Oswald headings over Hanken Grotesk; #c12b09 primary on #ece4d0 |
solstice |
Bodoni Moda headings over Hanken Grotesk; #c9212e primary on #f6e9d5 |
kiln |
Bodoni Moda headings over Inter; #e5610a primary on #fffbfa |
refract |
Hanken Grotesk headings over Hanken Grotesk; #066c95 primary on #faf9f5 |
terrazzo |
Outfit headings over Hanken Grotesk; #b14420 primary on #f5f1eb |
sunset-horizon |
Outfit headings over Outfit; #ff7e5f primary on #fff9f5 |
amber-minimal |
Inter headings over Inter; #f59e0b primary on #ffffff |
coral |
Hanken Grotesk headings over Hanken Grotesk; #ef8b7b primary on #f8f4f1 |
amethyst-haze |
Inter headings over Inter; #8a79ab primary on #f8f7fa |
cosmic-night |
Inter headings over Inter; #6e56cf primary on #f5f5ff |
caffeine |
Inter headings over Inter; #644a40 primary on #f9f9f9 |
ink |
Hanken Grotesk headings over Hanken Grotesk; #01736c primary on #fefdfb |
riso |
Mona Sans headings over Source Serif 4; #fe419d primary on #f8f5ed |
vellum |
Bricolage Grotesque headings over Hanken Grotesk; #2942ab primary on #f3eada |
loom |
Instrument Serif headings over Hanken Grotesk; #1d3172 primary on #f4f0e6 |
terminal |
JetBrains Mono headings over Hanken Grotesk; #54a14d primary on #f6fef8 |
neo-brutalism |
DM Sans headings over DM Sans; #ff3333 primary on #ffffff |
sport |
Oswald headings over Hanken Grotesk; #c8e928 primary on #f6f9fc |
squeeze |
Outfit headings over Hanken Grotesk; #8d6344 primary on #d0e4d5 |
midnight-bloom |
Outfit headings over Outfit; #6c5ce7 primary on #f9f9f9 |
rim |
Instrument Sans headings over Hanken Grotesk; #e17038 primary on #fffbf6 |
elegant-luxury |
Outfit headings over Outfit; #9b2c2c primary on #faf7f5 |
darkroom |
Oswald headings over Hanken Grotesk; #c1732f primary on #fffbf8 |
tangerine |
Inter headings over Inter; #e05d38 primary on #e8ebed |
mono |
JetBrains Mono headings over JetBrains Mono; #737373 primary on #ffffff |
mocha-mousse |
DM Sans headings over DM Sans; #a37764 primary on #f1f0e5 |
graphite |
Outfit headings over Outfit; #606060 primary on #f0f0f0 |
notebook |
Nunito Sans headings over Nunito Sans; #606060 primary on #f9f9f9 |
modern-minimal |
Inter headings over Inter; #3b82f6 primary on #ffffff |
manifesto |
Oswald headings over Hanken Grotesk; #db0310 primary on #fffbf6 |
solar-dusk |
Outfit headings over Outfit; #b45309 primary on #fdfbf7 |
sage-garden |
Hanken Grotesk headings over Hanken Grotesk; #7c9082 primary on #f8f7f4 |
grid |
Hanken Grotesk headings over Hanken Grotesk; #1f40be primary on #f8f7f3 |
furrow |
Hanken Grotesk headings over Hanken Grotesk; #fc6b33 primary on #f5f1ea |
modern |
indigo on a cool white, rounded, Inter; the default |
minimal |
near-black on a warm white, quiet colors, light borders, Inter |
playful |
bright violet, very round, pill buttons, Nunito Sans |
corporate |
muted teal on a cool grey-white, square corners, compact, tabular numbers, Source Sans 3 |
coastal |
deep teal on warm sand, rounded, soft shadows, Nunito Sans |
navy |
deep blue on a cool white, square corners, compact, Source Sans 3 |
editorial |
plum on warm paper, nearly square, no shadows, Source Sans 3 |
woodland |
forest green on a green-tinted white, soft corners, Source Sans 3 |
contrast |
dark red on pure white with near-black text and strong borders, Inter |
nordic |
petrol blue on a cool white, calm, soft shadows, Inter |
pastel |
mauve on a pink-tinted white, very round, raised shadows, Nunito Sans |
midnight |
indigo on a cool grey-white, crisp corners, no shadows, a deep navy dark mode, Inter |
craft |
rust on warm cream, rounded, soft shadows, Nunito Sans |
restaurant |
forest green on cream, flat cards, large Fraunces headings over Source Sans 3 |
street-food |
a hot red on near-black and white, square, boxed sections, strong lines, Archivo Narrow headings in capitals over DM Sans |
cafe |
terracotta on warm neutrals, very round, raised cards, pill buttons, no lines, Nunito Sans |
warm-service |
deep green on warm off-white, rounded, no shadows, DM Sans |
quiet-workspace |
calm blue on a cool grey-white, compact, small shadows, Inter |
ink-and-brass |
ink navy on warm paper, with a brass primary in dark mode, no shadows, Source Sans 3 |
workbench |
a quiet near-white workspace with a light sidebar and a teal primary, compact, tight Inter headings at weight 600, round pictures (the CRM starter's) |
stillwater |
one ink on warm paper, DM Sans headings at 800, large and tight, over Source Sans 3, square bold buttons, 4px corners, a soft shadow (the booking starter's) |
The gallery begins with the selected catalog themes, in palette and typography order; modern remains the default. Modern, minimal, playful and corporate come from the design delivery. The other built-ins (including the theme lab's styles and the starters' own) are theme files like a project's own, kept inside Smithable and checked the same way; a project may still have a theme of its own under any other name (forest, say).
# themes/forest.yml
smithableTheme: 0.1
name: forest # kebab-case; the file's name when left out
fonts:
body: Nunito Sans # a hosted font (below); not a display face
heading: Fraunces # optional: the headings' font; the body font when left out
labels: JetBrains Mono # optional: the face of column labels, eyebrows, tags and small figures; the body font when left out
radius: 12px # corners: a length in px or rem
shadow: soft # none | soft | raised
motion: subtle # optional: none | subtle (default) | lively
density: comfortable # optional: comfortable (default) | standard | compact
chroma: 0.22 # optional: how much color a brand color keeps on this theme (0–0.4)
texture: none # optional: none (default) | grain | paper, a quiet surface noise or a paper fibre, drawn by the app's stylesheet alone
modes: both # optional: both (default) | light | dark; a one-mode theme gives that mode's colors alone, the app shows it whatever the device says, and has no mode switch
headings: { weight: 600, tracking: normal, scale: large } # optional, like the groups below
surfaces: { cards: flat }
light:
primary: "#2f6b3a"
background: "#f6f8f4"
foreground: "#1f2a1f"
dark:
primary: "#8fd19a"
background: "#141a14"
foreground: "#e6ece4"
A theme may also supply finite UX defaults:
defaults:
app: { navigation: topbar, menuActive: underline }
kinds:
landing: { width: wide, header: { position: scrolling } }
crud: { table: { mark: initials, actions: menu }, record: { header: summary } }
calendar: { calendar: { view: agenda } }
sections:
hero: { layout: cover, overlay: dark }
records: { layout: ledger }
The order is platform fallback, app theme defaults, a landing page's own theme defaults,
then explicit UX. app takes menu layout/surface/active indication. kinds takes the finite
shell/list/calendar/record choices offered for that page kind. sections takes finite section
looks such as layout, columns and band. Page ids, field/model references, content, permissions,
CSS and expressions are refused. The published theme schema lists the exact choices.
An unusable inherited choice is skipped through the normal contextual validation, with its
reason in smithable validate --explain. Explicit invalid UX still reports an error at its
source. Inferred values are never written into smithable.ux.yml. Existing themes without
defaults keep their behavior. Literal platform choices (including none, contained, week
and filters' default) mask theme defaults; their operations offer a separate inherit reset.
A theme change preserves explicit choices. Studio distinguishes authored and inherited values.
- Each mode needs at least
background,foregroundandprimary; the other 25 colors (card,muted,accent,border,ring,destructive,success,warning, the charts, and every-foreground) may be given or are derived the way a brand color is: the text on a color is whichever of dark and white reads better, muted and secondary step the background towards the foreground, borders a step further, the accent tints the background with the primary, the focus ring is the primary (a step towards the text where a bright one would not show on a card), the charts spread around the primary's hue. Colors are#rrggbboroklch(L C H). - The hosted fonts, every one under the SIL Open Font License and shipped with the app (no font service is called): Inter, Nunito Sans, Source Sans 3, Source Serif 4, Fraunces, Archivo Narrow, DM Sans, Outfit, Hanken Grotesk, Instrument Sans, Mona Sans, Bricolage Grotesque, Oswald, Big Shoulders Display, Instrument Serif, Young Serif, Newsreader, Bodoni Moda, Zilla Slab, JetBrains Mono. The display faces (Fraunces, Archivo Narrow, Bricolage Grotesque, Oswald, Big Shoulders Display, Instrument Serif, Young Serif, Bodoni Moda) are for headings and labels; as the body font they are refused, since long text in them does not read.
- The style of a theme is a few groups of fields, each from a fixed set of values, never CSS; what a theme leaves out is the default (given first):
headings:weight300–900 in hundreds (700), within the heading font's own range (Archivo Narrow goes from 400 to 700, Instrument Serif has 400 alone),trackingtight|normal|wide,scaleregular|small|large|huge(the size of page and section titles; huge is display-led),casenone|upper(the landing page's and the frame's titles only, never a record's name; capitals neednormalorwidetracking),alignstart|center(a landing section's eyebrow, title and lead, at the start or centered over the section; a hero keeps its own layout).labels(column labels, eyebrows, tags and small figures):casenone|upper,trackingnormal|wide. Left out, labels follow the headings: their case, and wide tracking with capitals.surfaces:cardsbordered|raised(a shadow) |flat|glass(translucent and blurred over what is behind, with a lit top edge; its text is checked on the glass's tint over a band),sectionsopen|boxed|banded(a landing page's sections alternate: counting the sections after the hero that show and can have a band, the second, fourth and so on are on themutedband, unless a section says its ownbandin the ux file; the footer is not counted),bandssoft|strong(how far a band's paper steps from the background),dividerslight|strong|none.buttons:shaperounded|pill|square,weightregular|bold.pictures:cornerstheme|square|round,framenone|border,treatmentnatural|muted|warm|mono|duotone(what the theme does to every photograph; duotone is the primary over the background).tables:numbersnormal|tabular,rowslined|zebra|plain.font(the body font alone) still reads; naming it and a differentfonts.bodyis an error.
- A theme is checked for contrast: authored colors that may be hard to read produce warnings and remain selectable. Curated theme checks may enforce contrast separately.
smithable themeslists the themes the ux file may name;smithable validatechecks the project's. A project theme with a built-in's name replaces it for that project. Studio shows every theme with a picture drawn from its colors.smithable theme lab [--project <dir>] [--port 4330]opens the theme lab: the theme's fields as controls and as the file's text, beside a booking app's landing page, list, form and record in light and dark, with the fit lines and the check's errors under them; Save adds the theme throughaddTheme. The how-to Make a theme makes one both ways.- A theme ships no CSS, components or fonts from elsewhere, so switching themes is always safe and the hosted service can offer them without vetting code.
- The operation
applyTheme <name>makes or updates a project theme and selects it, as one change (a built-in theme is copied under a new name first);resetThemeOverride <key>takes one of the theme's own settings away, so it inherits again.
smithable.context.yml: how the app is built
The one file that may name a technology. It says how the app is built, never what it does: a functional requirement belongs in smithable.yml, a look in smithable.ux.yml, a text in smithable.content.yml.
smithableContext: 0.1
adapter: tanstack # the stack profile (one so far) and its database
database: sqlite
conventions: # read by a model that writes custom code or a plugin
- Prefer existing components before creating new ones.
guidance: >
Tables should be compact; this is a back-office tool used all day.
plugins: [newsletter] # project plugins, see "Sections Smithable does not know"
packages: { chart.js: 4.4.1 } # libraries for src/custom/, at exact versions
analytics: { plausible: shop.example.com } # a counter of visits, one provider
payments: { provider: mollie } # stripe | mollie | fake: who takes the payments
ai:
policy: best-available # local-only | eu-only | best-available (the default) | custom
adapteranddatabasename the stack profile the app is generated with; the generated code follows that stack's own idioms.conventions(a list) andguidance(free text) are preferences for the code a model writes for the project, custom pages and plugins; they never change generated code, and they never hold functional requirements.pluginsdeclares the project plugins whose sectionssmithable.ymlmay use.packagesdeclares the libraries custom code may import, at exact versions;setPackageadds or removes one, and the stack profile's own packages are refused (the content section above says why).analyticsnames one counter of visits with the app's id there;setAnalyticssets it. The cookie-free providers start at once; Google waits for consent.payments.providernames the payment provider that takes the app's payments, one per app:stripe,mollieorfake(a page of the app itself, for development, tests and previews). Its keys are settings, never in a file of the project (PAYMENTS_SECRET_KEY,PAYMENTS_WEBHOOK_SECRET,PAYMENTS_PUBLIC_KEY). Without it the app usesfakein development and preview and a release refuses to start the payments;smithable validatesays so as a note.setPaymentProvidersets it, and choosing a real provider the first time says whose part is what: the owner is the merchant.ai.policysays where a model may run for this project (ai.md):local-only,eu-only,best-available(what nothing said means) orcustomwithallowlisting the providers by name.
The file is checked against its JSON Schema (CONTEXT_SCHEMA in core): smithableContext: 0.1 and only the keys above. smithable validate reports a problem on its key, and an operation that changes the file is refused if it would leave it invalid.
Sample data
A project may give its models sample records in samples/<Model>.yml, beside themes/: a list of records with the model's field names as keys. pnpm db:seed (and smithable new) adds them instead of generated ones; a model without a file still gets generated records.
# samples/ClassType.yml
- name: Hatha
summary: Slow, steady postures held for a few breaths each.
level: allLevels # a choice by its value or its label
price: 16.50 # money as an amount
instructor: Emma Lindqvist # a reference by the record's title (samples/Instructor.yml)
photo: { file: hatha.webp, alt: A class stretching } # a file in public/images/samples/
- Dates are written
2026-10-05, dates with times2026-10-05 08:00. A calendar's records are moved to this week and the next, keeping their weekday and time. - A reference names the other record by its title, which needs the other model's sample file; without one, give the number of a generated record (1 for the first).
- A picture is a file name under
public/images/samples/, or{ file, alt }; withoutalt, it says what the record is.{ file, alt, generated: true }says an AI made it, and the app marks it where it shows it ("AI" in a corner; see the content file's pictures); the numbered pictures (0.webp,1.webp, …) seeded where a model has no sample file are the image library's and always are.kind(ai-realistic,ai-drawnorphotograph) says what it is, for the badge's default (aiBadgein the ux file); without it,public/images/pictures.json's word for that file counts. smithable validatechecks the files: an unknown model or field, a value of the wrong kind, a missing required field, a reference to a record that is not there. Lists of related records and calculated fields are not set in samples.smithable new --no-sample-datastarts with nosamples/folder and an empty database.samples/people.ymlis the sample users (docs/design/sample-users.md): a list of people with aname, aroleof the auth file orvisitor, apersonain a sentence and apacein minutes between moves (1 unless said). They act only in a development or demo build, through the app's own forms and actions as that role, and go with the sample data; a published app never has them. The file is written by the operationsaddSampleUser <name> <role> [persona…](--pacefor the minutes; without a persona, the role's description) andremoveSampleUser <name>, at most five people; a role a sample user has cannot be set away.samples/ask.ymlis the app's own Ask check (docs/design/ask-words.md §4): a list of questions a person with arole(one of the auth file's, orvisitor) would ask the in-app assistant, each withexpects, the shape of the answer: thekind, awhere(field to value, list of values or range) or ameasure(a number field), andanswer:count,namesornumber. Written by Smith's question pass and editable by hand. A kind, field, value or role it names that is no longer in the spec is a warning naming the line, and the question stays as written, so a rename leaves nothing silently broken; the sample validators leave the file alone, likepeople.yml, and it goes with the sample data.
Importing records
Existing records come in from a spreadsheet saved as CSV: smithable op importRecords Customer --from customers.csv (in Studio: Change → Records from a CSV file).
- The first row names the columns. A column fills the field whose name or label it matches, ignoring case, spaces and underscores (
Credit limitfillscreditLimit);--map "Company=name,Mail=email"names others. Columns that fill no field are left out and listed; pictures, calculated fields, lists of records and people who sign in are not imported. - Values are read like sample data: an amount in units (
12.50,12,50or1 200), a date as2026-10-05, a date and time as2026-10-05 08:00in the app's time zone, yes or no (true,yes,1), a choice by its value or label, a reference by the referenced record's title (exactly one must match). An empty cell is the field's default, or no value. A file with;between columns (a spreadsheet set to a decimal comma) is read too. --dry-runshows the first five records as they would be stored and every problem, each with its line. Without it the records are added in one go, at most 10,000: any problem (a required value missing, a value of the wrong kind, a reference that matches nothing or several records, a unique value already taken) adds none and says where.- The import is one change:
smithable undotakes the records back. The records belong to the first admin who has signed in, or to the userSMITHABLE_IMPORT_OWNERnames (an id or email; the hosted service sets it to whoever imports), and the dry run says whom; the model's hooks do not run.
Not supported
Smithable specs are plain data. YAML anchors (&name), aliases (*name) and tags (!!str) are rejected, because they make specs hard to read and unsafe to edit automatically.
Text is plain text too, in every spec file. A name, a label, a title or a subject is one line; the longer texts (description, intent, the rules, a section's text, help, answer, quote, an address or opening hours) may run over several. Invisible control characters, the rare line breaks U+2028, U+2029 and U+0085, and the characters that reverse the order text is shown in are refused anywhere, since they make a text read otherwise than it is.