Skip to content

Declaring your own Noun

Tutorial 2 of 12 declares Leaseline's own Noun, lease, in one file and reads the API, types and Events it compiles to.

A Noun file declares a record the template does not have. Leaseline declares a Lease Noun, and one file gives it an API, types and events.

What you build

You write nouns/Lease.mdx: a unit, a resident, an end date, a rent, a lifecycle and two Verbs, renew and notify. The body of the file is the Noun's documentation on every Interface.

Steps

Terminal4 steps
  1. To declare the Noun, create its file at the project root:

    nouns/Lease.mdx
    ---
    extends: [Thing]
    properties:
      unit: string
      resident?: Contact
      endsOn: date
      rent?: money
      status: active | renewing | renewed | ended
    verbs:
      renew: { months: integer, increase?: number }
      notify: {}
    ---
    A Lease is one resident's agreement on one unit, from signing to renewal.

    A name ending in ? is optional. status holds the states, and only a Verb or an Event moves it.

  2. To read what the save compiled, print the Verb's schema:

    npx startup-builder schema Lease.renew
  3. To read the generated types, open .sb/types/Lease.d.ts:

    .sb/types/Lease.d.ts
    interface LeaseRenewInput {
      lease: SB.Id
      months: number
      increase?: number
    }
  4. To try the Verb without storing anything, call it with --try:

    npx startup-builder do Lease.renew --json '{"lease":"lease_4loEed1JG4","months":12}' --try

Result

One file gave Lease create, get, list, update and delete, and the Verbs Lease.renew and Lease.notify. It also gave the Events Lease.created, Lease.renewed and Lease.notified, and typed SDK methods, CLI operations, MCP tools and OpenAPI paths. Checkpoint leaseline@ch02 (status planned) adds nouns/Lease.mdx.

Next steps