Skip to main content
An event states a fact, such as an order shipping. Publish it in the mutation that makes it true, so the business write and the event commit together. A task asks a performer to do work and settles separately; an event is a fact other code reacts to.

Declare and publish

event({ fields, label, type }) from @bijectionhq/library-events declares one append-only table of events. Place the value in the app tree; its table is <path>.events. Choose a label, or pass per: family to place each event under the family’s member.
bijection/shipping.ts
publish answers the event’s minted key. Each publish is a distinct event, even when two payloads and instants are equal.

Follow

follow(event, { roles, allow, batch }, handler) is a reaction on the event table’s change log (on: shipped.events.changes). The host runs it once per committed event, in commit order, with the roles you give it. The handler runs in the delivery’s transaction and receives the event { id, type, data, occurredAt, version } and { once }, the follower’s identity for this event. Pass that once to anything the handler submits.
bijection/app.ts
toWebhooks(publish, map) calls a mounted Webhooks app’s events.publish with the event’s key, as the follower’s notifier role, which the mount allows because the app passes it in publishers. toStream(target, map) submits one task per event to a stream target with the follower’s once. Every delivery marks the event handled in the handler’s commit, so no event is handled twice.

Replay

<path>.events.start replays the event table’s change log, a page per delivery, from a retained version or from the earliest retained change (null). Roles in the follower’s allow may call it; without allow, only your own code may. A replay whose range the table’s history no longer holds starts again from the whole table, and the marks skip what was already handled.

Follow one family member

Declare the event with per: family. Publish from a frame under one member, and the event is that member’s fact. The live reaction runs under each event’s member, so its mark and the handler’s writes are that member’s.

Pin a registry schema

For a payload held in a schema registry, scaffold the fields into an authored TypeScript module, pinned to an exact version:
The scaffold carries the registry identity, schema id and digest beside the fields. Review it and commit it. check resolves the pin again and compares its id and digest. --connection <file> supplies registry settings and credential environment names. --format also takes json-schema and protobuf; select a Protobuf message with --message.