@sensinum/strapi-plugin-multi-domain 5.2.0-beta.1 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +64 -35
  2. package/dist/_chunks/About-DNyaGrYn.mjs +435 -0
  3. package/dist/_chunks/About-DaPMT-kj.js +38 -0
  4. package/dist/_chunks/{Settings-q2-wnMsh.mjs → Settings-B823hBAu.mjs} +2 -2
  5. package/dist/_chunks/{Settings-De2gPisD.js → Settings-B_1YuoN9.js} +1 -1
  6. package/dist/_chunks/{TenantCustomField-B3_kP4Hn.mjs → TenantCustomField-B9Ntpj-S.mjs} +1 -1
  7. package/dist/_chunks/{TenantCustomField-D-7Si38A.js → TenantCustomField-CHUfO3Xh.js} +1 -1
  8. package/dist/_chunks/{TenantEdit-Cb072LMV.mjs → TenantEdit-BFvwBQFd.mjs} +4 -4
  9. package/dist/_chunks/{TenantEdit-BkdAbMuN.js → TenantEdit-Bkw_eaGW.js} +1 -1
  10. package/dist/_chunks/{TenantList-CL42iP37.js → TenantList-C9nnIaGg.js} +1 -1
  11. package/dist/_chunks/{TenantList-kV9ECrto.mjs → TenantList-DRfWswjS.mjs} +4 -4
  12. package/dist/_chunks/{en-BPIaGv4M.mjs → en-Cf69p5po.mjs} +6 -2
  13. package/dist/_chunks/en-hAVH8fH0.js +1 -0
  14. package/dist/_chunks/{index-BlQO7jXj.mjs → index-2nR8Jd1x.mjs} +1 -1
  15. package/dist/_chunks/{index-DAX0vpn7.js → index-Cvs1ZCFy.js} +1 -1
  16. package/dist/_chunks/{index-ChL08Dcz.mjs → index-DEoxiYwP.mjs} +5 -5
  17. package/dist/_chunks/index-DuSOcmV4.js +1 -0
  18. package/dist/_chunks/useGetMessage-B1Xnqz3k.js +1 -0
  19. package/dist/_chunks/{useGetMessage-2uaqSNHA.mjs → useGetMessage-K3OG9Tv0.mjs} +1 -1
  20. package/dist/_chunks/{useSettings-Hd_Y-NfK.js → useSettings-BCMuYsbx.js} +1 -1
  21. package/dist/_chunks/{useSettings-BCXs1q_c.mjs → useSettings-QOof9ZTx.mjs} +1 -1
  22. package/dist/_chunks/{useTenants-CVYBr-JE.mjs → useTenants-CT-L6xX1.mjs} +2 -2
  23. package/dist/_chunks/{useTenants-DAdjIYEf.js → useTenants-_putKXAO.js} +1 -1
  24. package/dist/admin/index.js +1 -1
  25. package/dist/admin/index.mjs +1 -1
  26. package/dist/server/index.js +4 -2
  27. package/dist/server/index.mjs +5544 -5234
  28. package/package.json +1 -1
  29. package/dist/_chunks/en-D2iOtyKE.js +0 -1
  30. package/dist/_chunks/index-1D9AeLxE.mjs +0 -445
  31. package/dist/_chunks/index-C0pkYQjH.js +0 -3
  32. package/dist/_chunks/index-TelSPPuG.js +0 -1
  33. package/dist/_chunks/useGetMessage-R3JXzZcF.js +0 -1
package/README.md CHANGED
@@ -22,7 +22,7 @@ This plugin brings multi-domain support to your Strapi application. It allows yo
22
22
  > ✅ **GET THE LICENSE**: To obtain the license we encourage you to [**visit the plugin commercial website**](http://sensinum.com/strapi-multi-domain-plugin), select the appropriate plan, and reach out to your preferred reseller or directly contact the plugin authors via [**this form**](http://sensinum.com/contact)
23
23
 
24
24
  > ⚠️ **This plugin is licensed by VirtusLab Ltd. under the [End User License Agreement (EULA)](https://sensinum.com/eula-strapi-multi-domain-plugin).**
25
- Unauthorized use, including usage without a valid license key or modification of the code in a way that breaches the integrity of the software, is strictly prohibited and will be treated as a violation of the [EULA](https://sensinum.com/eula-strapi-multi-domain-plugin), with all associated legal consequences.
25
+ > Unauthorized use, including usage without a valid license key or modification of the code in a way that breaches the integrity of the software, is strictly prohibited and will be treated as a violation of the [EULA](https://sensinum.com/eula-strapi-multi-domain-plugin), with all associated legal consequences.
26
26
 
27
27
  ### Table of Contents
28
28
 
@@ -33,23 +33,24 @@ Unauthorized use, including usage without a valid license key or modification of
33
33
  5. [🔧 Configuration](#-configuration)
34
34
  6. [🧪 Testing](#-testing)
35
35
  7. [👨‍💻 For Developers: Advanced Customization](#-for-developers-advanced-customization-via-sharedpluginidsts)
36
- 8. [📝 License](#-license)
36
+ 8. [🔌 Supported Third-Party Plugins](#-supported-third-party-plugins)
37
+ 9. [📝 License](#-license)
37
38
 
38
39
  ## ✨ Features
39
40
 
40
- - **Domain-based Data Isolation**: Automatically scopes content types to the current user's domain.
41
- - **Media Library Segregation**: Each domain has its own isolated section within the media library.
42
- - **User-Domain Association**: Users can be associated with one or more domains through Strapi roles.
43
- - **Domain Selector**: A convenient domain selector is added to the admin UI for users who belong to multiple domains.
44
- - **Super Admin Access**: Super admins have the ability to view data across all domains.
45
- - **Configurable**: Easily configure which content types should be domain-aware.
41
+ - **Domain-based Data Isolation**: Automatically scopes content types to the current user's domain.
42
+ - **Media Library Segregation**: Each domain has its own isolated section within the media library.
43
+ - **User-Domain Association**: Users can be associated with one or more domains through Strapi roles.
44
+ - **Domain Selector**: A convenient domain selector is added to the admin UI for users who belong to multiple domains.
45
+ - **Super Admin Access**: Super admins have the ability to view data across all domains.
46
+ - **Configurable**: Easily configure which content types should be domain-aware.
46
47
 
47
48
  ## 🎨 Admin Panel Features
48
49
 
49
- - **Domain Management UI**: A dedicated settings page in the admin panel (`Settings > Multi-Domain Settings`) allows administrators to create, view, update, and delete domains.
50
- - **Domain Selector**: Users belonging to multiple domains will see a "Select domain" option in the user menu (top right). This opens a modal allowing them to easily switch between their assigned domains, reloading the app context for the selected domain.
51
- - **"Unique by Domain" Custom Field**: The plugin registers a new custom field type named "Unique by domain". When applied to a text field on a content type, it ensures that the value of that field is unique among all entries of that type within the *same domain*.
52
- - **Content Manager Integration**: To prevent content from being created without a domain, the "Create new entry" button in the Content Manager is hidden when the "Super Admin" domain is selected.
50
+ - **Domain Management UI**: A dedicated settings page in the admin panel (`Settings > Multi-Domain Settings`) allows administrators to create, view, update, and delete domains.
51
+ - **Domain Selector**: Users belonging to multiple domains will see a "Select domain" option in the user menu (top right). This opens a modal allowing them to easily switch between their assigned domains, reloading the app context for the selected domain.
52
+ - **"Unique by Domain" Custom Field**: The plugin registers a new custom field type named "Unique by domain". When applied to a text field on a content type, it ensures that the value of that field is unique among all entries of that type within the _same domain_.
53
+ - **Content Manager Integration**: To prevent content from being created without a domain, the "Create new entry" button in the Content Manager is hidden when the "Super Admin" domain is selected.
53
54
 
54
55
  ## ⚙️ How it works
55
56
 
@@ -70,6 +71,7 @@ When using the **Users & Permissions plugin** with multi-domain functionality, t
70
71
  2. **Use API tokens assigned to domains**: Ensure all requests include an API token that is properly assigned to a specific domain. This allows the plugin to identify the correct domain context for the request.
71
72
 
72
73
  #### Example:
74
+
73
75
  ```javascript
74
76
  // In your route configuration
75
77
  module.exports = {
@@ -114,9 +116,7 @@ module.exports = {
114
116
  * By default, all content-types are scoped except for some internal Strapi models.
115
117
  * @returns {Set<string>}
116
118
  */
117
- getOmitContentTypes: () => new Set([
118
- 'api::my-global-content-type.my-global-content-type',
119
- ]),
119
+ getOmitContentTypes: () => new Set(['api::my-global-content-type.my-global-content-type']),
120
120
  /**
121
121
  * A list of content-api endpoints to exclude from domain logic.
122
122
  * e.g., ['/api/my-public-endpoint']
@@ -150,14 +150,14 @@ module.exports = {
150
150
 
151
151
  ### Configuration Options
152
152
 
153
- - `defaultDomain` (object): Configures the domain that is automatically created for super admins.
154
- - `name` (string): The display name for the default domain.
155
- - `customFields` (object): A JSON object for any custom data you want to associate with the domain.
156
- - `getOmitContentTypes` (function): Returns a `Set` of content-type UIDs that should be excluded from multi-domain. Use this for global, non-domain-specific content.
157
- - `getExcludedContentAPIEndpoints` (function): Returns an array of URL paths for Content API endpoints that should be publicly accessible and not scoped by domain.
158
- - `getExtraProxyDecorators` (function): An advanced feature that allows you to add custom logic to the database query proxy. This is useful for implementing complex, domain-specific business rules. It should return an array of objects, each with a `condition` and a `handler` function.
159
- - `condition` (function): Takes a `modelName` and returns `true` if the handler should be applied.
160
- - `handler` (function): A function that wraps the original database method, allowing you to modify its behavior. It receives the `target` repository, the original `targetElement` method, the Koa `ctx`, the method `prop` name, and the `modelName`.
153
+ - `defaultDomain` (object): Configures the domain that is automatically created for super admins.
154
+ - `name` (string): The display name for the default domain.
155
+ - `customFields` (object): A JSON object for any custom data you want to associate with the domain.
156
+ - `getOmitContentTypes` (function): Returns a `Set` of content-type UIDs that should be excluded from multi-domain. Use this for global, non-domain-specific content.
157
+ - `getExcludedContentAPIEndpoints` (function): Returns an array of URL paths for Content API endpoints that should be publicly accessible and not scoped by domain.
158
+ - `getExtraProxyDecorators` (function): An advanced feature that allows you to add custom logic to the database query proxy. This is useful for implementing complex, domain-specific business rules. It should return an array of objects, each with a `condition` and a `handler` function.
159
+ - `condition` (function): Takes a `modelName` and returns `true` if the handler should be applied.
160
+ - `handler` (function): A function that wraps the original database method, allowing you to modify its behavior. It receives the `target` repository, the original `targetElement` method, the Koa `ctx`, the method `prop` name, and the `modelName`.
161
161
 
162
162
  Here's an example of how you might use `getExtraProxyDecorators` to add an additional filter to a specific content type:
163
163
 
@@ -182,9 +182,7 @@ module.exports = {
182
182
  * By default, all content-types are scoped except for some internal Strapi models.
183
183
  * @returns {Set<string>}
184
184
  */
185
- getOmitContentTypes: () => new Set([
186
- 'api::my-global-content-type.my-global-content-type',
187
- ]),
185
+ getOmitContentTypes: () => new Set(['api::my-global-content-type.my-global-content-type']),
188
186
  /**
189
187
  * A list of content-api endpoints to exclude from domain logic.
190
188
  * e.g., ['/api/my-public-endpoint']
@@ -220,7 +218,6 @@ module.exports = {
220
218
 
221
219
  To run the tests for this plugin, navigate to the plugin's directory and run the following command:
222
220
 
223
-
224
221
  This will execute the Jest test suite. To run tests in watch mode, you can use `yarn test:watch`.
225
222
 
226
223
  ## 👨‍💻 For Developers: Advanced Customization via `shared/pluginIds.ts`
@@ -235,16 +232,48 @@ By changing the values in this file, you can fundamentally alter the plugin's id
235
232
 
236
233
  Here's a breakdown of the constants and what you can control by changing them:
237
234
 
238
- - `pluginId`: The official ID of the plugin (`multi-domain`). Changing this will alter the plugin's root path in Strapi, including settings URLs and permission domains.
235
+ - `pluginId`: The official ID of the plugin (`multi-domain`). Changing this will alter the plugin's root path in Strapi, including settings URLs and permission domains.
236
+
237
+ > **Note:** This value is derived from the `strapi.name` property in `package.json` and should always be kept in sync with it.
238
+
239
+ - `modelId`: The singular ID for the domain content type (default: `'domain'`). Changing this renames the content type itself, which affects the database table, API endpoints, and the name of the relationship field added to other content types.
240
+ - `modelServiceId`: The identifier for the domain service (default: `'domain'`). This should typically be kept in sync with `modelId`.
241
+ - `userField`: The property name on the `user` object where associated domain information is stored (default: `'domain'`).
242
+ - `modelRoute`: The base route for the domain management API (default: `'domains'`). This is derived from `modelId`, so changing `modelId` will automatically update this.
243
+ - `COOKIE_NAME`: The name of the cookie used to store the user's currently selected domain (default: `'domain'`). You might change this to avoid naming conflicts with other cookies in your application.
244
+
245
+ ## 🔌 Supported Third-Party Plugins
246
+
247
+ This plugin provides domain-scoped data isolation for the following third-party plugins:
248
+
249
+ - [strapi-plugin-navigation](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation)
250
+ - [strapi-plugin-comments](https://github.com/VirtusLab-Open-Source/strapi-plugin-comments)
251
+ - [strapi-plugin-reactions](https://github.com/VirtusLab-Open-Source/strapi-plugin-reactions)
252
+
253
+ ### strapi-plugin-navigation
254
+
255
+ Navigation items and navigations are automatically scoped to the current domain.
256
+
257
+ ### strapi-plugin-comments
239
258
 
240
- > **Note:** This value is derived from the `strapi.name` property in `package.json` and should always be kept in sync with it.
259
+ Comments and comment reports are automatically scoped to the current domain. Since the `Authorization` header is reserved for the domain API token, author identification for comments is handled via the `X-Author-Authorization` header:
260
+
261
+ ```
262
+ X-Author-Authorization: Bearer <users-permissions-jwt>
263
+ ```
264
+
265
+ This header is processed on comment endpoints that require author context: creating, updating, and deleting comments. If the token is valid, the resolved Strapi user is set as the comment author. Without this header, the comment must include an `author` object in the request body with `id`, `name`, and `email` fields.
266
+
267
+ ### strapi-plugin-reactions
268
+
269
+ Reactions and reaction types are automatically scoped to the current domain. Since the `Authorization` header is reserved for the domain API token, author identification for reactions is handled via the `X-Author-Authorization` header:
270
+
271
+ ```
272
+ X-Author-Authorization: Bearer <users-permissions-jwt>
273
+ ```
241
274
 
242
- - `modelId`: The singular ID for the domain content type (default: `'domain'`). Changing this renames the content type itself, which affects the database table, API endpoints, and the name of the relationship field added to other content types.
243
- - `modelServiceId`: The identifier for the domain service (default: `'domain'`). This should typically be kept in sync with `modelId`.
244
- - `userField`: The property name on the `user` object where associated domain information is stored (default: `'domain'`).
245
- - `modelRoute`: The base route for the domain management API (default: `'domains'`). This is derived from `modelId`, so changing `modelId` will automatically update this.
246
- - `COOKIE_NAME`: The name of the cookie used to store the user's currently selected domain (default: `'domain'`). You might change this to avoid naming conflicts with other cookies in your application.
275
+ This header is processed on reaction endpoints: listing, creating, deleting, and toggling reactions. If the token is valid, the resolved Strapi user is set as the reaction author. The reactions plugin also supports its own `X-Reactions-Author` header for custom (non-Strapi) users. When `X-Reactions-Author` is present, `X-Author-Authorization` is ignored — custom author identification takes precedence.
247
276
 
248
277
  ## 📝 License
249
278
 
250
- All rights reserved. Copyright (c) [VirtusLab Ltd](https://virtuslab.com/).
279
+ All rights reserved. Copyright (c) [VirtusLab Ltd](https://virtuslab.com/).