[Backport v8] Allow declaring content scope dimensions at runtime - #6318
Draft
VPS-thodax wants to merge 1 commit into
Draft
[Backport v8] Allow declaring content scope dimensions at runtime#6318VPS-thodax wants to merge 1 commit into
VPS-thodax wants to merge 1 commit into
Conversation
## Problem
Content scope dimensions were only known implicitly from the keys of the
`availableContentScopes` values. An optional dimension that is not part
of `availableContentScopes` (e.g. one with too many values to enumerate)
therefore had no runtime representation at all — it could neither be
declared nor used with arbitrary values.
## Solution
Add an optional `availableContentScopeDimensions` option to the
`UserPermissionsModule` to declare the content scope dimensions (with
optional labels) at runtime. When omitted, the dimensions are derived
from the keys of `availableContentScopes` as before, so existing apps
are unaffected. The declared dimensions are used to represent access to
all content scopes as a per-dimension wildcard (`{ domain: "*", ... }`),
which therefore also covers dimensions that are not part of
`availableContentScopes`.
A content scope for a dimension that is not part of
`availableContentScopes` may now hold any value (including the `"*"`
wildcard).
(cherry picked from commit f4d091f)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DeZZCJgNydRxnbPuRBkTjp
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
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.
Backport of #6115 to
v8.x.x.Note
This PR is stacked on #6292 (the backport of #6114 to
v8.x.x, layer 1). It targetsclaude/backport-v8-6114becausev8.x.xdoesn't have the wildcard content scope dimension support (#6114) yet. Once #6292 is merged intov8.x.x, this PR's base will need to be retargeted tov8.x.x(or GitHub will do so automatically once #6292 merges, matching how the original stacked PRs behaved).Original description
Problem
Content scope dimensions were only known implicitly from the keys of the
availableContentScopesvalues. An optional dimension that is not part ofavailableContentScopes(e.g. one with too many values to enumerate) therefore had no runtime representation at all — it could neither be declared nor used with arbitrary values.Solution
Add an optional
availableContentScopeDimensionsoption to theUserPermissionsModuleto declare the content scope dimensions (with optional labels) at runtime. When omitted, the dimensions are derived from the keys ofavailableContentScopesas before, so existing apps are unaffected. The declared dimensions are used to represent access to all content scopes as a per-dimension wildcard ({ domain: "*", ... }), which therefore also covers dimensions that are not part ofavailableContentScopes.A content scope for a dimension that is not part of
availableContentScopesmay now hold any value (including the"*"wildcard).Removing
checkContentScopesContent scopes are no longer validated against
availableContentScopes(thecheckContentScopesmethod is removed) — see the original PR (#6115) for the full rationale.Backport notes
Cherry-picking the squash commit (
f4d091fa71ffe1c3c0f72431bbdb6151b6e93faa) frommainontoclaude/backport-v8-6114produced conflicts in two files, both resolved by applying the incoming change againstv8.x.x's existing code:packages/api/cms-api/src/user-permissions/user-content-scopes.resolver.ts: the incoming code useduserService.findUserOrThrow(userId), butfindUserOrThrowdoesn't exist onv8.x.x(it was introduced by a later, unrelatedmaincommit). Kept usingv8.x.x's existinguserService.getUser(userId)instead, combined with the newfilterContentScopesForUser(already present via Support wildcard values for content scope dimensions #6114's backport).demo/api/src/content-scope/content-scope.interface.ts: module augmentation naming conflict (@dextinity/cms-apivs.@comet/cms-api, matchingv8.x.x's pre-rename package naming — see [Backport v8] Remove the Permissions and Scopes columns from the user permissions users list #6280 for precedent). Kept@comet/cms-apiand added the newproductdimension.Also converted the cherry-picked
user-permissions.service.spec.tsfromvitesttojest(matching@comet/cms-api's test runner on this branch — same adjustment as #6144/#6280), and updated the changeset package name from@dextinity/cms-apito@comet/cms-api(per the pre-rename naming convention, per the routine's own caveat).Verification
@comet/cms-api: build, lint (prettier/eslint/tsc) pass.@comet/cms-apifull test suite: 204/204 passing, including the 7 new tests forgetAvailableContentScopeDimensions/filterContentScopesForUser.demo/api:api-generatorregenerates cleanly with no diff to the generated files; lint (prettier/eslint/tsc) passes.demo/apiAppModule/GraphQLModuleinitialize correctly viapnpm run console --help(schema/block-meta regenerate); it only fails afterwards on connecting to Postgres, since the full Docker demo could not be started in this sandbox — Docker Hub image pulls are blocked by the environment's network policy (403 from CloudFront), consistent with the same limitation noted on prior v8 backport PRs (e.g. [Backport v8] Remove the Permissions and Scopes columns from the user permissions users list #6280, [Backport v8] Support wildcard values for content scope dimensions #6292). Please verify the runtime-declared content scope dimensions manually before merging.🤖 Generated with Claude Code
https://claude.ai/code/session_01DeZZCJgNydRxnbPuRBkTjp
Generated by Claude Code