Skip to content

v0.8.0

Choose a tag to compare

@github-actions github-actions released this 04 Dec 17:45
bf2c31d

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 is false or null.
  • Rules read claims with $.claim(…):
    • $.claim(staffClaim) is a condition;
    • tag.teamId.is($.claim(currentTeamClaim)) compares a column (or a membership row inside some()) 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() and db.session.claim(_:).
  • Migrating from 0.7.0:
    • drop the schema's claims option, from both createSchema and fromPrisma;
    • replace claim.* builders with declareClaim, $.claims.<name> with $.claim(claim), claims: { name: value } with claims: [claim(value)], and db.$session.claims.<name> with db.$session.claim(claim);
    • claim.idOf, idsOf, strings and list values are gone: use .uuid() or .string();
    • Swift's isGranted, value(of:) and values(of:) are replaced by db.session.claim(_:).

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.

Published to npm