Skip to main content
@bijectionhq/library-automations turns an occurrence into a run of one of your mutations. Rules are facts editors save; the trigger contracts and the actions are your code.
bijection/app.ts
  • Rules (ops.tables.rules) hold a trigger kind, typed where clauses over the trigger’s payload contract, an action name, an argument mapping, a delay, an optional review requirement and an enabled flag. Editors call ops.rules.save, setEnabled and archive. Each save is a new revision, checked against the revision the editor saw.
  • Offer. Your code calls ops.offer(ctx, { kind, key, payload }) in the transaction that makes the occurrence true. Each matching enabled rule submits its action as a function task with once: ["run", rule, revision, occurrence], so offering the same occurrence again answers the original task. The rule’s delay is the task’s due. Clients holding offerers (editors by default) offer through ops.occurrences.offer.
  • Review. A rule with review first asks the Approvals app. Its continuation submits the action only when the decision is approved and the rule still stands at the reviewed revision.
  • Runs (ops.tables.runs) hold one fact per run. ops.runs.state answers the run’s task state: the action’s, or the review’s while it waits.
An action is an ordinary mutation run as a function task, at its own under. It holds no roles, so its authority is its commit label. It validates its own arguments when it runs.