Skip to content

feat(permissions): allow opting out of implicit READ via READ: false#469

Merged
dwirz merged 1 commit into
mainfrom
feat/ZWEI-3796-permission-block-read-false
May 12, 2026
Merged

feat(permissions): allow opting out of implicit READ via READ: false#469
dwirz merged 1 commit into
mainfrom
feat/ZWEI-3796-permission-block-read-false

Conversation

@nicola-smartive
Copy link
Copy Markdown
Collaborator

Every PermissionsBlock previously emitted an implicit READ chain — the short-circuit action === 'READ' || action in block in both generatePermissions and addPermissions always pushed READ regardless of whether the block declared one. That made it impossible to declare a mutation-only sub-block (e.g. user: { UPDATE: true }) without also contributing a READ chain to the OR'd EXISTS subtree on the linked type.

This adds an explicit opt-out: set READ: false on any block to suppress the implicit READ-chain emission while keeping the other action grants intact. Default behavior is unchanged (omit READ ⇒ READ emitted as before; READ: true ⇒ same).

  • PermissionsBlock type widens READ?: boolean (other actions stay true-only).
  • Generated per-model ${Model}Permissions type widens READ?: boolean to match.
  • Both READ short-circuits switch to block.READ !== false.

Unblocks consumer-side cleanup of redundant implicit READ chains where the same path is already covered by a flatter grant on the same role — shrinks the OR'd EXISTS subtree on heavily-joined types like User.

Every `PermissionsBlock` previously emitted an implicit READ chain — the
short-circuit `action === 'READ' || action in block` in both
`generatePermissions` and `addPermissions` always pushed READ regardless
of whether the block declared one. That made it impossible to declare a
mutation-only sub-block (e.g. `user: { UPDATE: true }`) without also
contributing a READ chain to the OR'd EXISTS subtree on the linked type.

This adds an explicit opt-out: set `READ: false` on any block to suppress
the implicit READ-chain emission while keeping the other action grants
intact. Default behavior is unchanged (omit READ ⇒ READ emitted as
before; `READ: true` ⇒ same).

- `PermissionsBlock` type widens `READ?: boolean` (other actions stay
  `true`-only).
- Generated per-model `${Model}Permissions` type widens `READ?: boolean`
  to match.
- Both READ short-circuits switch to `block.READ !== false`.

Unblocks consumer-side cleanup of redundant implicit READ chains where
the same path is already covered by a flatter grant on the same role —
shrinks the OR'd EXISTS subtree on heavily-joined types like User.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dwirz dwirz merged commit fda01f5 into main May 12, 2026
12 checks passed
@dwirz dwirz deleted the feat/ZWEI-3796-permission-block-read-false branch May 12, 2026 12:10
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 23.16.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nicola-smartive nicola-smartive restored the feat/ZWEI-3796-permission-block-read-false branch May 12, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants