@bijectionhq/app-rest for one collection on a fixed HTTPS GET
path. Records, cursor positions and task results live under the data label
you pass to the mount.
Mount and bind
rest({ data, receivers }) returns the app to place at a path of your tree.
Bind the collection with one of the package’s binders, declare each credential
with secret(), and place them beside the mount. Only receivers.provider is
required; a feature whose receiver you did not pass refuses ReceiverUnbound.
app.ts
operator role, which clears data. The operator runs
the mount’s clocks and is the only role its functions allow:
catalog.source.*, catalog.records.*, catalog.schema.*, catalog.files.*,
catalog.reports.* and catalog.writes.*. Set each credential, grant the role,
and initialize the source with a profile:
catalog.operator is granted from code: ctx.grant(catalog.operator, { to, under }) in one of your
mutations (Grants).
profile.json
auth; keep them out of profiles and arguments.
Every binder takes the data label as its last argument, and the receiver
answers under it. For protected data, declare a concrete label and pass it to
both the binder and the mount. The host charges clock and send capacity at
that label.
The provider guides give the fixed path and a profile for each native
mode. For those modes, set mode: "provider", use the catalog’s exact mode
as provider, and bind the collection with
providerEndpoint(mode, origin, path, auth, data). A guide lists the
profile members its mode uses; every other member is null. Use one mount
per mode and resource. For HTTP Basic, use header authentication with
name: "Authorization" and prefix: "Basic ", and set only the
Base64-encoded credential value.
Protected SaaS mounts
Declare a label appropriate to the data, such aslabel(). Pass it to
providerEndpoint and to the mount as data. Grant the mount’s operator
role only to principals who may read that data: the operator reads the
records. The source stores its observations and positions under data.
Provider responses reach the continuation under the same label and may
contain more provider fields than the listed record projection. A mode that
requires a protected label refuses ProtectedLabelRequired under the public
label.
Pass the receiver as receivers.provider and set each of its credentials.
Initialize with the exact provider mode and the limit shown in its guide.
Use one mount per tenant or feed. Each page must fit in 36 KiB and the
configured row limit. Oversized or invalid pages leave the last landed
position intact. Traversals commit one page at a time. An ordinary
observation sweep starts again after its terminal page and keeps rows that
disappear from later responses.
Multiple sealed credentials
For a fixed HTTPS receiver that needs several credentials, declareauth: { kind: "multiSecret", bindings: [...] } with two to eight
separate secret() declarations. Each binding uses kind: "header" and
a header name, with an optional prefix, or kind: "query" and a query
parameter name. Set each value with bijection secret set. The host owns
those names and adds the values immediately before dispatch. Keep
credentials out of source profiles and request arguments.
A fixed HTTPS POST can also use multiSecret with one or more
jsonBody bindings. Give each binding its own secret and a
fieldPath, such as ["access_token"] or
["getSettledBatchListRequest", "merchantAuthentication"]. The request
must supply any parent objects and leave the credential fields absent.
The host opens each seal and inserts text, or parsed JSON when
json: true. Seal separate root fields such as secret and
access_token independently.
Feed contracts
The app accepts at most 36 KiB of UTF-8 response data per page and uses the
bundled parser to bound records, fields and nesting while preserving exact
text for decimals and integers outside the safe range. It commits keyed
upserts and deletions with the page position. A traversal yields after 16
pages and reports a failed page if its continuation makes no progress or
would exceed 4,096 pages. An HTTP 410 for a retained position records a gap
and stops the source.
Use
records.get with the provider key or page records.list.
records.list({ cursor }) returns { facts, next }; pass next as the
following call’s cursor, and start with null. A mount under a labelled
data is protected: its store keeps only a
token of each key, so records.list, relationships.list and
occurrences.list page in row order. A public mount pages records in key
order. The mount’s orders release keeps only schema generations, write
states and due times, and report run keys and row ordinals public, so its
generation sweep, write queue and report rows walk in order.
The mounted clock starts due reads and recovers stalled runs. A manual
poll marks the feed due for its next clock turn. Use the revision shown
by source.health when calling poll, pause or resume; a stale
revision refuses RevisionMoved. Pass both the displayed revision and gap instant to source.reset
after reviewing a lost position. Reset starts at the configured baseline
and preserves published rows. For a different collection, account or
provider incarnation, install a new mount so its cursor and rows start fresh.
The minute cadence and per-page commits provide current observations only.
Deploying this app requires the bundled parser module.
Discover and approve a provider schema
For Airtable, Salesforce, HubSpot, Pipedrive, Zoho CRM, Close, Attio, NetSuite, Dataverse, Zendesk or Jira, use the provider guide’sselection with
declaredResourceEndpoint(selection, auth, data). Pass it as
receivers.resource and use a protected label for the receiver and the
mount. The one receiver carries the fixed collection and metadata
routes under the same HTTPS origin and sealed credential.
- Call
schema.discover({ selection, revision: null })before first initialization. For an existing source, use the current source revision. - Call
schema.get()until the proposal is ready. Review the provider fields, normalized types, key, paging and deletion contract. The receiver stages each complete metadata response in sealed 512 KiB parts, up to 2 MiB per response. The app checks the size and digest, parses the staged JSON and retires the parts. A review accepts up to 512 supported fields across at most 32 pages, with a 15-minute discovery deadline. - Call
schema.approve({ proposal, fingerprint, revision, fields, limit })with the exact proposal, fingerprint and discovery basis (reviewedAtRevision), 1–32 of its field names and a 1–100 row page limit. Approval starts the initial source. Later approvals that change the schema or selected fields start a new record generation and baseline. The previous generation stops appearing in record reads. - While the source is active, the app schedules a daily metadata refresh.
A changed schema pauses acquisition and exposes a new proposal.
Approve the revision, then use its returned source revision with
source.resume. Usesource.healthandsource.resetfirst if the source has a continuity gap. An unchanged schema keeps its active projection and cursor.
Create and update records
Declare a separate write credential and writer. For a generic REST API, bind one create path, one update collection prefix and the update method. The writer appends exactly one validated record ID under that prefix.receivers.writers holds one writer per write mode; the generic mode is
rest. Bind the writer under the same label as the mount. The operator calls
catalog.writes.submit and catalog.writes.get. A pull-only mount passes no
writers.
Call writes.submit with a command key, mode: "rest" and
command: { action: "create", payload } or
command: { action: "update", id, payload }. The payload is one JSON
object encoded as text, up to 24 KiB. The command key is 1–100 ASCII letters,
digits, dots, dashes or underscores. A repeated key with the same exact
inputs answers replayed. Changing the mode, action, ID or payload under that
key refuses KeyReused.
The mount queues under data and its clock submits one task per command
key, once on that key. Work that waits in the queue for five minutes
expires. The clock submits at most one write per ten-second turn. Use
writes.get({ key }) for the labelled evidence. Read polling and cursor
advancement are independent of write evidence.
A generic 200, 201 or 204 acknowledges the request at the installed
endpoint. For a JSON response, the app can retain an id that fits its key
contract. A 202 or a redirect provides insufficient application evidence.
httpError records an HTTP status the endpoint returned. unexpected
records a reply without the mode’s expected evidence. unknown records a task
that settled Unknown. A write may have applied when either the reply
or its expected evidence is unavailable.
Each command has one send and one final result. Resolve an Unknown
result against the provider’s records before acting on it.
Native provider writes
Each provider guide lists its exact mode, origin, resource scope, credential and reply evidence. Bind the writer withproviderWriter(mode, options, label)
and pass it in receivers.writers under its own mode. Bind the writer and the
mount under the same data label. Use a credential with write permission for
the specific resource.
app.ts
writes.get({ key }) reports pending, sending or settled evidence
with a provider HTTP status and record ID where the mode can establish them.
The write has no cursor and updates no observed row. A later pull follows
its regular cursor and deletion rules. An unexpected or missing reply can
leave the provider effect unresolved.
Typed commands
Use the exact mode and command shape in the provider’s guide. Bind the reviewed writer to the same protecteddata label as the mount; typed writes refuse
ProtectedLabelRequired under the public label. Only the mount’s operator
calls writes.submit and writes.get.
The key binds the entire command. Each provider follow-up takes its own
ordered task under that key and the writer’s receiver contract.
writes.get({ key }) returns state, the last HTTP status, and the
provider-specific record and detail. The job field identifies an
acknowledged background job and outcomes holds any per-record evidence.
The app bounds the initial queue to five minutes and any follow-up to
30 minutes. A send that settles Unknown is never resent.
Write commands have no read cursor and never move a source position.