Skip to content

Definition and compile

Definition and compile turns one file into a checked, versioned Definition that every Interface, price and record reads. A deploy is the only way it changes, and the diff is the change.

Capability families

FamilyWhat it does
The grammarNouns with fields and Relationships, Verbs, lifecycles, Sources, Triggers, Workflows, Offers, Roles, staffing and terms, in one typed definition.ts
The checkRefuses a file that does not fit the grammar, and a business that does not add up
The planCompares the file with the live Version: every change, each marked when it breaks a caller, with each price and your margin per Verb
Deploy and cutoverPublishes the file as a Version with its Digest, and moves every Interface to it at once
Pinning and migrationKeeps each Key, run and open case on the Version it started on, and moves live records to a new shape once, checked first
RollbackMoves every Interface back as one; publishing an older Digest is a rollback
LineageStamps every output, from a reply to a docs page, with the Digest it came from
LayersA template per pattern to start from, each Customer's extension inside the limits you set, and extensions other builders publish
GenerationCompiles routes, machines, prices, terms, the eleven Interfaces, the landing site, the portal, the docs, the files agents read and the UI contracts

What the check refuses

The check reads the business as well as the syntax. Every refusal is a Problem with a code, a JSON Pointer at and its fix, and nothing that serves changes.

CheckWhat it refuses
GrammarA key the schema does not hold, a type out of order, a state no move enters
NamesA Verb on a reserved path, two Verbs on one name, a Relationship with one side
EconomicsA Verb with no price, plan or outcome; a price below what its Sources cost you
StaffingA human step whose Role no member, supplier or roster can hold
AuthorityA move no Role can make, an agent with no mandate that pays for its tools, a legally human act given to an agent
CompatibilityA Customer's extension the new file no longer holds, unless that Customer stays on the Version before

A breaking change is never silent. The plan names it, the deploy asks you to confirm it, and it reaches no caller pinned to the Version before.

Lifecycles and states

ThingStatesWhat moves it
A deploypending, then done or refusednpx apis.dev deploy; a refused deploy changes nothing that serves
A Versionlive, superseded, deprecated, retiredThe next deploy supersedes it; you deprecate it with a window; it retires when the window ends and no Key, run or case is pinned to it
A migrationplanned, running, then done or haltedIt runs with the deploy that needs it; a halted one leaves every record on its old shape
A Customer's extensionchecked, live, heldThe Customer's admin deploys it; your deploy holds it when it no longer checks

A deploy is an Action: it waits while it builds, and answers its Version or its Problems. A rollback makes the Version before live again, and the one it replaced is superseded, never deleted. A held extension keeps its Customer on the Version before, and that Customer's admin sees which line no longer checks.

What you declare, what the platform does

You declareThe platform does
name, domain and the five blocksGives every Verb one name on every Interface, and derives each state and Event from its move
Prices in offerPrints your margin per Verb, to you alone, and refuses a price below cost
A rename, with wasMoves live records to the new name once, and answers the old name to Keys pinned to the old Version
extend: what each Customer may addRuns the same check on each Customer's extension, which lives in that Customer's Namespace only
A Role on a move or a stepChecks that someone can hold it before the deploy goes live
Nothing elseThe Digest, the changelog, docs pinned per Version, cutover, pinning, rollback and lineage

Example

A rename and an extension policy in one deploy, and the plan that shows both before anything serves.

definition.ts
21 lines
import { define } from 'apis.dev'

/** Deals for each Customer, kicked off when won. */
export default define({
  name: 'pipeline', domain: 'pipeline.apis.dev',
  Company: { name: 'string', domain: 'url!#', deals: '<-Deal.company' },
  Deal: {
    title: 'string',
    amount: 'decimal(12,2)',
    value: { type: 'decimal(12,2)', was: 'amount' },
    company: '->Company.deals',
    stage: { open: [], qualify: 'opened', win: { in: 'qualified', role: 'manager' },
             lose: ['opened', 'qualified'] },
  },
  extend: { Deal: { fields: 10, rules: true } },
  offer: {
    Free: { month: 0, seats: 1, includes: { 'Deal.open': 25 } },
    Team: { month: 49, seats: 5, seat: 9, includes: { 'Deal.open': 1000 } },
    'Deal.open': 0.001,
  },
})
Terminal
$ npx apis.dev plan
! breaking: Deal.amount is renamed to Deal.value
  each Key keeps v3, which still answers amount, until it sends Api-Version: v4
  migrate: 1,204 Deals in 38 Customers' Namespaces, checked
+ extend: each Customer may add 10 fields and its own rules to Deal
✓ 38 Customer extensions still check
✓ no price changes: Team 49, Deal.open 0.001

Contracts with the other subsystems

The Definition is what may happen. Every other subsystem reads it and none writes it.

SubsystemWhat the Definition gives itWhat it gives back
Identity, access and policyRoles, the Role on each move, approvals, the mandate an agent needs, the extension policyWho deployed, under which Role or mandate: a deploy is a Verb like any other
Model and recordsNouns, fields, keys, Relationships, lifecycles, was renamesThe live record a migration is checked against, Namespace by Namespace
Data and SourcesSources, Mappings, a ranked from, licence terms, schedulesWhat each Source costs you, which the economic check reads
RuntimeCompiled routes, machines, Triggers, Functions and WorkflowsEvery Action stamped with its Digest; every run pinned to its Version
WorkStaffing: which Role does each human step, at which gradeThe roster the staffing check reads
CommerceOffers, the one source of every priceA plan's new price reaching each subscriber at renewal, with a Stripe notice
Interfaces and distributionEverything they render, in one compileAtomic cutover: every Interface, the site, the portal and the docs on one Version
Trust and operationsTest and Live, brakes, retentionThe deploy's evidence, the changelog and the outside check of each Version

What Customers and their agents meet

Customers never see the file. They see its outputs, all from one Version at a time.

  • A stable contract. A Key keeps the Version it first called until it sends Api-Version. A breaking change reaches no caller who did not ask for it.
  • One changelog. The landing site prints each Version's changes, and the docs keep a page set per Version with its migration guide.
  • Their own extension. A Customer's admin adds a field, a rule or a Workflow over any Interface, inside the limits your extend sets. The same check answers with the same Problems.
  • Agents read the change. An agent reads /openapi.json and llms.txt per Version, sees Api-Version on every reply, and moves when its owner moves it.

One file, one check and one deploy, so nothing a Customer meets drifts from what the file says.