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
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
onceis the effect’s identity. Submitting again with the sameonceand args returns the original task; the sameoncewith other args refusesInvalid.thennames the continuation, a mutation with its other args bound byfn.with(args). The delivery fillsresult. The continuation is internal: it declares noallow.dueholds the task until an instant;withinoverrides the target’s deadline. Past the deadline, a pending task settlesExpired.
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.