Skip to content

Conversation

@jhoward1994
Copy link
Contributor

@jhoward1994 jhoward1994 commented Jul 21, 2025

What does it do?

Adds plugin-specific handling to the Strapi client library. The changes include:

  • Added optional plugin configuration parameter to ContentTypeManagerOptions with configurable name and prefix
  • Implemented conditional data wrapping logic that skips wrapping payloads for the users-permissions plugin
  • Enhanced route construction to support plugin-specific prefixes (e.g., /plugin-name/resource or /resource for plugins without prefixes)
  • Updated the client's collection() method to accept plugin configuration options

Why is it needed?

The users-permissions plugin in Strapi has a different API contract than regular content-types. It expects raw payload data without the standard { data: {...} } wrapper that other content-types require. Without this change, attempting to create users via the client fails with validation errors because the API receives the data in an unexpected format.

How to test it?

  1. Set up a Strapi application with users-permissions plugin enabled
  2. Use the client to create a user with plugin configuration:
    const users = client.collection('users', { 
      plugin: { name: 'users-permissions', prefix: '' } 
    });
    
    await users.create({
      username: 'testuser',
      email: '[email protected]',
      password: 'password123',
      role: 1
    });
  3. Verify the request succeeds and the user is created
  4. Run the test suite to verify all plugin-specific behaviors work correctly

Related issue(s)/PR(s)

@jhoward1994 jhoward1994 self-assigned this Jul 21, 2025
@jhoward1994 jhoward1994 added pr: feature New or updates to features source: client-content-types Source are the content types' managers labels Jul 21, 2025
@jhoward1994 jhoward1994 marked this pull request as ready for review July 21, 2025 11:37
@jhoward1994 jhoward1994 changed the title feat(content-types): users-permissions plugin specific support Plugin specific support (users-permissions) Jul 24, 2025
it('should NOT wrap data for update operations when plugin is set to "users-permissions"', async () => {
// Arrange
const usersManager = new CollectionTypeManager(
{ resource: 'users', plugin: { name: 'users-permissions', prefix: '' } },
Copy link
Contributor

@innerdvations innerdvations Jul 31, 2025

Choose a reason for hiding this comment

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

shouldn't prefix be undefined here (and the test above this) to make sure it doesn't prefix that specific plugin? or am I misunderstanding it?

Copy link
Contributor

@innerdvations innerdvations left a comment

Choose a reason for hiding this comment

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

LGTM!

Still not 100% happy with needing the prefix but that's u&p's fault and we can work on improving it later

@jhoward1994 jhoward1994 merged commit 7fcac34 into main Jul 31, 2025
7 checks passed
@jhoward1994 jhoward1994 deleted the feat/plugin-specific-handling branch August 18, 2025 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: feature New or updates to features source: client-content-types Source are the content types' managers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants