feat(permissions): allow opting out of implicit READ via READ: false#470
Closed
nicola-smartive wants to merge 1 commit into
Closed
feat(permissions): allow opting out of implicit READ via READ: false#470nicola-smartive wants to merge 1 commit into
READ: false#470nicola-smartive wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every
PermissionsBlockpreviously emitted an implicit READ chain — the short-circuitaction === 'READ' || action in blockin bothgeneratePermissionsandaddPermissionsalways 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: falseon 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).PermissionsBlocktype widensREAD?: boolean(other actions staytrue-only).${Model}Permissionstype widensREAD?: booleanto match.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.