Zero 0.7

Read Permissions and Docker

Install

npm install @rocicorp/zero@0.7

Features

  • Read permissions. You can now control read access to data using ZQL (docs).
  • Deployment. We now have a single-node Docker container (docs). Future work will add multinode support.
  • Compound FKs. Zero already supported compound primary keys, but now it also supports compound foreign keys (docs).
  • Schema DX:
    • Columns types can use bare strings now if optional is not needed (example).
    • PK can be a single string in the common case where it’s non-compound (example).

Breaking Changes

  • Several changes to schema.ts. See update to hello-zero for overview. Details:
    • defineAuthorization was renamed to definedPermissions to avoid confusion with authentication.
    • The way that many:many relationships are defined has changed to be more general and easy to remember. See example.
    • The signature of definePermissions and the related rule functions have changed:
      • Now rules return an expression instead of full query. This was required to make read permissions work and we did it for write permissions for consitency (see example).
      • The update policy now has two child policies: preMutation and postMutation. The rules we used to have were preMutation. They run before a change and can be used to validate a user has permission to change a row. The postMutation rules run after and can be used to limit the changes a user is allowed to make.
    • The schema.ts file should export an object having two fields: schema and permissions.
  • The way that schema.ts is consumed has also changed. Rather than zero-cache directly reading the typescript source, we compile it to JSON and read that. (example).
    • ZERO_SCHEMA_FILE should now point to a JSON file, not .ts. It defaults to ./zero-schema.json which we’ve found to be pretty useful so you’ll probably just remove this key from your .env entirely.
    • Use npx zero-build-schema to generate the JSON. You must currently do this manually each time you change the schema, we will automate it soon.
🤔Note

zbugs

  • Comments now have permalinks. Implementing permalinks in an SPA with local-first is fun!
  • Private issues. Zbugs now supports private (to team only) issues. I wonder what’s in them … 👀.

Docs