Skip to main content
A target is a contract for work done outside the transaction: what it takes (args), what it gives back (returns), the app codes it may refuse with (refuses), how long it may take (within), and who carries it out (via, its performer). ctx.submit commits the intent atomically with the mutation’s writes. The performer runs after the commit, and the task settles once, with a Result.

Declare a target over HTTP

http(url, { bearer }) performs a task as one JSON POST of its args. A 2xx answer’s JSON body is the value. A 4xx answer whose body names one of the target’s refuses codes settles with that code. An answer that never arrived settles Unknown.
bijection/payments.ts
For an API whose requests need a method, a path, headers or a keyed retry contract, declare a receiver({ endpoint, auth, contract, operations }) from @bijectionhq/bijection. Each operation({ method, path, args, returns, request, answer }) is a target, and the receiver’s contract states what the API promises about a repeated request (once or keyed). The controlled HTTP example declares one.

Submit and continue

bijection/orders.ts
  • once is the effect’s identity. Submitting again with the same once and args returns the original task; the same once with other args refuses Invalid.
  • then names the continuation, a mutation with its other args bound by fn.with(args). The delivery fills result. The continuation is internal: it declares no allow.
  • due holds the task until an instant; within overrides the target’s deadline. Past the deadline, a pending task settles Expired.
The continuation is decided afresh, in its own transaction, through the submitter’s grants recorded at submit that are still live. A revoked grant refuses the step.

Performed by people

A target whose performer is a list of roles waits for a principal holding one of them to settle it:
ctx.answer(task, result) settles a pending task, and ctx.withdraw(task, { message }) settles it Withdrawn. Both are grave acts: bijection check lists the functions that perform them. A role-performed target always declares within, since a person may never answer. For structured, attributed approvals, use the Approvals app.

Performed by a mutation

via: mutation makes a mutation the performer. The host runs it in its own transaction with the task’s args, and its value (or refusal) settles the task. A performer that needs to wait returns its own task, ctx.frame.on.task. Declare the mutations that may answer it with target({ via: perform, answeredBy: [review] }). An answerer calls ctx.answer. A mutation is also a target in its own right: ctx.submit(recount, { day }, { due }) runs it later.

Lost replies

Unknown means the work may have happened. The host never performs the task again. Keep the receiver’s own identity for the command and ask the receiver what happened, as Reconciliation describes, before you submit a second business effect. The outbound webhook example shows a continuation that records a mounted app’s delivery result.