Skip to main content
An app is a tree of declarations. app(tree) walks it, and every declaration in it (a table, a label, a role, a release, a guard, a secret, a target, a query or a mutation) takes its path as its name. Nothing is named by a string.
bijection/app.ts
Placed this way, notes.ts’s items table is notes.items, its list query is notes.list, and access.ts’s member role is access.member. A module namespace and a plain object are both subtrees; any depth works. app(tree) returns the tree as well, so a declaration is reachable by value: root.notes.list is the list query. A name exists only once app() has run, so code reads paths lazily, never while modules load.

Exposure

A function with allow is exposed: a client may call it at its path, if the caller holds one of the roles. A function without allow is internal. Its app’s code can reach it through a call, continuation, reaction or performer. Its app can also pass a reference to it down the tree. Leave out allow to declare an internal function.
bijection/notes.ts
role.anyone admits every principal, including signed-out callers. role.signedIn admits authenticated people. Each names a principal class: the program issues the class a grant at install that enters the functions listing it, and the lock prints that grant. A class grant clears only the public label. Use api<typeof App>() to name callable paths and connect(url) to run them.

The lock file

bijection check derives bijection.lock from the tree: every path, with its allow, its under, its grave acts and the guards on it, plus the class grants the program issues at install and the app’s contract. Commit it. bijection check refuses a lock that differs from the tree, and bijection check --write-lock rewrites it for review, so a change in what the app exposes or may do is a reviewed diff.

Libraries and mountable apps

A library is a module, or a function that returns a subtree. Placing it in the tree places its tables and functions there, with their paths:
Declare a mountable app with app((options) => tree) and call it at a path in the installer’s tree. The call records label, role, table, function and target references in its options as pass <kind> <path> lines in the receiving app’s lock block. An installer can pass only references it can name. A role reference can appear in allow. Each app holds its own roles for entries declared with roles:. App code can call its own functions, the exposed functions of apps it contains, and functions passed to it. It can read its own tables, non-private tables of apps it contains, passed tables, and tables that name its site in writers. The caller’s clearance still applies. A mountable app or library that owns its tables declares writers: () => [landing] on each table so only its own functions write to them, and exposes the table to callers through table.readOnly(...) so installers can read and index it without staging writes. A library whose facts the installer must not read at all (credentials, codes) declares those tables private: true instead: only the library’s own functions read or write them (private tables). See Mount an app and Write a mountable app.

Entry points

These four are the whole SDK. Checks, views, replicas and the partner sync placement are packages: @bijectionhq/library-checks, @bijectionhq/library-views, @bijectionhq/library-replicas and @bijectionhq/library-sync; the sync’s partner accounts and destinations are the connector catalog’s (@bijectionhq/library-connectors/sync).

Mount an app

Install a mountable app at a path, pass it roles and guard its acts.

Write a mountable app

Scaffold an app or library package and test it on the real kernel.