Skip to content

fix(sdk): reflect policies permission system in policy/user types#27152

Merged
AlexGaillard merged 2 commits intodirectus:mainfrom
yogeshwaran-c:fix/25757-sdk-policy-user-access-types
Apr 16, 2026
Merged

fix(sdk): reflect policies permission system in policy/user types#27152
AlexGaillard merged 2 commits intodirectus:mainfrom
yogeshwaran-c:fix/25757-sdk-policy-user-access-types

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

@Nitwel pointed out in #25757 that users on directus_policies is typed as a plain user array in the SDK, even though the policies permission system stores it as M2M through directus_access. Same pattern applies to directus_policies.roles and directus_users.policies.

This PR retypes those three relation fields to DirectusAccess[] to match the actual schema (confirmed by packages/system-data/src/fields/policies.yaml and users.yaml — both declare the fields as list-m2m with a directus_access junction).

This is a breaking type change in the sense that strictly-typed user code will now need to reference DirectusAccess shapes instead of DirectusUser/DirectusPolicy directly, but it matches the runtime payload the API expects.

Closes #25757

directus_policies.users, directus_policies.roles and directus_users.policies
are M2M relations through directus_access, but the SDK types had them typed
as direct arrays of DirectusUser / DirectusRole / DirectusPolicy. That meant
payloads built from these types didn't match the API at runtime (e.g.
creating a policy with users required each entry to be a { user: id } access
item, not a user id).

Retype them as DirectusAccess[] to match the schema.

Closes directus#25757
@AlexGaillard
Copy link
Copy Markdown
Member

@Nitwel
Copy link
Copy Markdown
Member

Nitwel commented Apr 16, 2026

We will reopen this as an exception as these changes are simple enough to review quickly.

@Nitwel Nitwel reopened this Apr 16, 2026
Updated SDK types to correctly link to the directus_access junction collection, reflecting the policies permission system.
Copy link
Copy Markdown
Member

@Nitwel Nitwel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@AlexGaillard AlexGaillard merged commit 2777bed into directus:main Apr 16, 2026
67 checks passed
@github-actions github-actions Bot added this to the Next Release milestone Apr 16, 2026
formfcw pushed a commit that referenced this pull request Apr 20, 2026
…7152)

* fix(sdk): reflect policies permission system in policy/user types

directus_policies.users, directus_policies.roles and directus_users.policies
are M2M relations through directus_access, but the SDK types had them typed
as direct arrays of DirectusUser / DirectusRole / DirectusPolicy. That meant
payloads built from these types didn't match the API at runtime (e.g.
creating a policy with users required each entry to be a { user: id } access
item, not a user id).

Retype them as DirectusAccess[] to match the schema.

Closes #25757

* Fix SDK types for user access relations

Updated SDK types to correctly link to the directus_access junction collection, reflecting the policies permission system.

---------

Co-authored-by: Nitwel <mail@nitwel.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK types still reflect the old permission system

3 participants