Skip to content

Conversation

@nclsndr
Copy link
Contributor

@nclsndr nclsndr commented Oct 24, 2025

What does it do?

Solution Implemented

Added auto-detection for well-known Strapi resources like users:

Key Changes:

  1. src/client.ts

    • Added WELL_KNOWN_STRAPI_RESOURCES mapping that identifies special content-types
    • Modified collection() method to auto-apply plugin configuration for 'users'
    • Preserved backward compatibility (explicit plugin options override auto-detection)
  2. tests/unit/client.test.ts

    • Added test for auto-detection of 'users' resource
    • Added test for explicit plugin override
  3. tests/unit/content-types/collection/collection-manager.test.ts

    • Added test verifying data wrapping behavior for regular vs special content-types
  4. README.md

    • Added documentation section explaining users-permissions auto-detection

Usage

Before (required manual configuration):

const users = client.collection('users', {
  plugin: { name: 'users-permissions', prefix: '' }
});

After (works automatically):

const users = client.collection('users');
await users.create({
  username: 'john',
  email: 'john@example.com',
  password: 'SecurePass123!'
});

How to test it?

const users = client.collection('users');
await users.create({
  username: 'john',
  email: 'john@example.com',
  password: 'SecurePass123!'
});

Related issue(s)/PR(s)

Fixes #90

@nclsndr nclsndr self-assigned this Oct 24, 2025
@nclsndr nclsndr changed the title fix: add WELL_KNOWN_STRAPI_RESOURCES for users-permissions case fix: use users-permissions as non-plugin collections Oct 24, 2025
@nclsndr nclsndr force-pushed the fix/users-permissions branch from a213789 to 4c0613b Compare October 24, 2025 13:40
@nclsndr nclsndr marked this pull request as ready for review October 24, 2025 13:40
@nclsndr nclsndr marked this pull request as draft October 24, 2025 13:40
@nclsndr nclsndr marked this pull request as ready for review October 24, 2025 13:41
@nclsndr nclsndr added pr: feature New or updates to features pr: fix Bug fix labels Oct 24, 2025
Copy link
Member

@Convly Convly left a comment

Choose a reason for hiding this comment

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

@Convly
Copy link
Member

Convly commented Oct 27, 2025

Could you also update main/CONTRIBUTING.md#-testing-the-changes ?

🤦 I meant this review to be for #105 but you've already modified the file over there, feel free to ignore this one

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.

Very nice, lgtm! Tested and works for me.

I don't see any issues aside from the question about single types, which I think can be resolved later, unless you want to address it here.

@nclsndr nclsndr requested a review from Convly October 28, 2025 08:41
Copy link
Member

@Convly Convly left a comment

Choose a reason for hiding this comment

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

LGTM with the upcoming PR for single types.

As a quick note, I'm a bit concerned about the addition of all those edge cases (first for prefixes, then hard-coded stuff for plugins & U&P, and now WELL_KNOWN_STRAPI_RESOURCES). But hopefully this is the last hard coded edge case we'll have to deal with thanks to the upcoming generated API which should eliminate the need for these 🙏

@innerdvations
Copy link
Contributor

innerdvations commented Oct 28, 2025

edge cases

The thing is, these are kind of like edge cases in Strapi CMS and are the exact sort of thing the client should work around, to make it transparent to the user and easier to work with.

But yes, almost every workaround we build into strapi/client is something that in Strapi v6 we should probably make a breaking change to align with the standard way of doing things.

@nclsndr nclsndr merged commit a18818f into main Oct 28, 2025
7 checks passed
@nclsndr nclsndr deleted the fix/users-permissions branch October 28, 2025 14:47
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 pr: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: When using collections.create/update with the users-permissions user content-type, fails with bad request

4 participants