Repository navigation
v0.7.0
Claims with values, server logic in the client's transaction, refusals in the app's words, open tabs that survive deploys, and connections no slow download can hold. Two breaking changes, in the claims API and the client; the session's claims changed shape in the protocol, so update clients and server together.
Breaking changes
- Claims hold values and are declared in the schema.
createSchema(models, { claims: { staff: claim.boolean(), currentTeam: claim.idOf("team") } })(alsofromPrisma(datamodel, { claims })); the session callback setsclaims: { staff, currentTeam }; rules read$.claims.staffand compare columns with$.claims.currentTeam.declareClaim,$staff(…)grants anddb.$session.hasClaimare removed; readdb.$session.claims.<name>. The protocol's sessionclaimsis now a map. Swift:db.session.isGranted(_:),value(of:),values(of:). db.$viewerIdreplacesdb.$session.viewerId.
Features
- Server logic in the same transaction:
createEngine({ transaction }), withprismaTransaction(prisma, …)from@clientdb/prisma(Prisma 5, 6 and 7), writes a device's change in a transaction you open;beforeCommit(writes, $)sees every row it wrote and can write more, or refuse;$.afterCommit(work)runs after the commit.
- Refusals in your words:
createEngine({ messages: defineMessages(schema, { conflict, forbidden, fallback }) })words what devices are told;- duplicates are matched by unique key through Postgres's catalog;
TransactionRejected(code, message)refuses frombeforeCommitwith your message;- composite unique keys come from the
uniquemodel option or Prisma's@@unique.
- Deploys and open tabs:
- clients and server exchange per-model hashes, and the server sends each client only the models it knows;
db.$versionis"current","updateAvailable"(the server only added models; the client keeps working) or"reloadRequired"(a model it uses changed: writes throw andonReloadRequiredasks to reload);- Swift:
db.versionandSyncOptions(onReloadRequired:); - the deploy docs now run setup when the new release starts serving, not in the build.
fromPrisma:sync: [...]lists the models that sync, andsyncAuthModelsreplacesinclude;models.<Model>.uniquedeclares keys schema.prisma can't;- the types now refuse everything startup refuses, including fields of schema.prisma that can't sync and calls without options.
validateis typed by model.onErroron the fetch and Next.js handlers and oncreateSyncServer.- The permission helpers on
$can be destructured without lint errors.
Fixes
- Slow or abandoned downloads hold no database connection:
- a bootstrap reads each page in its own short transaction;
- a pull commits before it sends;
- a stream whose device takes nothing for 60 s is ended (
downloadIdleTimeoutMs); - the Node server no longer leaks
closelisteners.
indexedDb()storage can't hang:- opening, loading and writing time out after 10 s;
- a load that can't read what is stored downloads afresh;
- other tabs' upgrades and deletes never block.
- The capture trigger ignores updates that change only columns that don't sync.
npx clientdb setupexplains a missing generated module, the usual monorepo mistake.