Repository navigation
v0.8.0
Claims are declared values. Breaking for code that uses claims; everything else is unchanged from 0.7.0, and the protocol's session claims map keeps its shape (a value is never a list).
Breaking changes
- Declare each claim once, in a file the server and the client both import:
declareClaim("staff")is yes or no;declareClaim("currentTeam").uuid()holds a UUID;.string()holds any text.
- Sessions set values by calling the claim:
claims: [staffClaim(isStaff), currentTeamClaim(teamId)]. Each call is typed by the claim's kind, and a UUID claim refuses a value that isn't one. A claim left out isfalseornull. - Rules read claims with
$.claim(…):$.claim(staffClaim)is a condition;tag.teamId.is($.claim(currentTeamClaim))compares a column (or a membership row insidesome()) with the claim's value;enforce: ($) => ({ teamId: $.claim(currentTeamClaim) })works too.
- The engine learns claims from the rules that read them. Two claims of one name with different kinds are refused, and so is a session setting a claim whose kind differs from the one the rules read.
- Clients read
db.$session.claim(currentTeamClaim), typed by its kind. Swift:Claim("currentTeam").uuid()anddb.session.claim(_:). - Migrating from 0.7.0:
- drop the schema's
claimsoption, from bothcreateSchemaandfromPrisma; - replace
claim.*builders withdeclareClaim,$.claims.<name>with$.claim(claim),claims: { name: value }withclaims: [claim(value)], anddb.$session.claims.<name>withdb.$session.claim(claim); claim.idOf,idsOf,stringsand list values are gone: use.uuid()or.string();- Swift's
isGranted,value(of:)andvalues(of:)are replaced bydb.session.claim(_:).
- drop the schema's
Fixes
sequenceNow()drains everything committed before the call, also when another process holds the drain. Change ids are drawn at insert, so a change can commit after one with a later id. A caller that waited for another process's drain could find nothing past the last drained id and return with its own change still queued; it went into the log only with the next drain. The leader's idle check had the same blind spot. Nothing was lost.