Verb functions
A Verb function file holds the Function behind one Verb, bound by its file name with no registration.
A file named [Noun].[verb].ts in nouns/ holds the Function behind one Verb. The file name binds it; nothing registers it.
nouns/Lease.mdxLease.renew.tsruns Lease.renew
Reference
TypeScript with one default export. .sb/ declares the Noun, each Verb's input type and $ globally, so the file needs no import.
| Export | Type | Holds |
|---|---|---|
default | (thing: | The Function: the record, the Verb's typed input, and the client acting as this Function's Worker |
The input type is named for the Noun and Verb: renew on Lease takes LeaseRenewInput, compiled from the Verb's entry in the Nouns file.
The kind is read from the code. $.Noun.verb() calls are code, $`…` is one model call, an Agent's tag such as rae`…` is agentic, and a person's tag is a human Task. The caller never sees which ran.
Examples
Minimal
export default async (lease: Lease, input: LeaseRenewInput, $: $) => {
const end = new Date(lease.endsOn)
end.setMonth(end.getMonth() + input.months)
return $.Lease.update({ id: lease.$id, endsOn: end.toISOString().slice(0, 10) })
}Leaseline
Leaseline declares a Lease Noun whose renew Verb takes months and an optional increase (the Nouns file declares them). Renewal extends the end date by the term and raises the rent within the increase the manager allows.
export default async (lease: Lease, input: LeaseRenewInput, $: $) => {
const end = new Date(lease.endsOn)
end.setMonth(end.getMonth() + input.months)
const rent = lease.rent && { ...lease.rent, amount: Math.round(lease.rent.amount * (1 + (input.increase ?? 0))) }
return $.Lease.update({ id: lease.$id, endsOn: end.toISOString().slice(0, 10), rent })
}The Function never sets status, and update takes no status input. When the Action succeeds, the Verb's Event, Lease.renewed, moves the record to renewed.
What it builds
The SoftwareBuilder compiles the file into one Function Version for the Verb.
- a
Functionwithkindread from the code - each call returns one Action pinned to that Function Version, with input, output and cost
- the Verb's Event,
Lease.renewed, when the Action succeeds