feat(core): RoleAssignmentPlugin (WIP)#4937
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Dashboard Preview: https://admin-dashboard-1kgkuw5s4-vendure.vercel.app |
…ross-multiple-channels-in-multi-vendor
1c45377 to
f1e5070
Compare
|
Vendure Core — View preview Changed pages: |
53bfd10 to
f1e5070
Compare
|



Description
First slice of channel-scoped role assignments for multi-vendor setups (design discussion in #3779): a skeleton
RoleAssignmentPluginshipped inside@vendure/core, activated only via a newexperimental.roleAssignments.enabledconfig flag.RoleAssignmententity:(user, role, channel)bridge with a unique constraint on the triple, non-nullable FK columns (@EntityId()), CASCADE deletes, and indexes onroleId/channelId(userIdlookups are covered by the unique constraint's leftmost column)@VendurePluginshell that registers the entity — no permission resolution, services, or API extensions yetexperimentalsection onVendureConfig; whenroleAssignments.enabledis set,preBootstrapConfigregisters the plugin internally (users never touchplugins: [])RoleAssignmentMigrationService), run on server bootstrap only while therole_assignmenttable is empty (run-once semantics; deleting all rows re-triggers it, and the service can be invoked manually):user_roles_role→role_channels_channel, one row per (user, role, channel). All users are treated alike — this mirrors legacy permission resolution exactly (a customer holds the Customer role, which is assigned to every channel, just asgetUserChannelsPermissions()grantsAuthenticatedeverywhere today). Row count therefore scales with users × channels-per-roleINSERT ... orIgnore); legacy relations are never modified, so disabling the flag stays non-destructiveWith the flag disabled (default) there is zero schema or behavior change. With it enabled, the effects are the new
role_assignmenttable (requires a migration, same asDefaultJobQueuePlugin) and the one-time backfill. Permission resolution still uses only the legacy relations — the rows are inert until the resolver-strategy pass, which follows in subsequent PRs per the plan on the linked issue.Relates to #3779
TODOs
Migration tooling
migrateRoleAssignmentData(queryRunner)helper inmigration-utils/(the v3.6migrateProductOptionGroupData()pattern), so it can run inside the same TypeORM migration that creates the table instead of boot-time run-once logicvendorX-*copies)Breaking changes
None. The feature is opt-in via an experimental flag; disabled by default.
Screenshots
N/A
Checklist
📌 Always:
👍 Most of the time: