@malevich-studio/strapi-sdk-typescript 1.2.28 → 1.2.29
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.
- package/dist/cli.cjs +12 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +12 -4
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +12 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +12 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21411,9 +21411,17 @@ class Strapi {
|
|
|
21411
21411
|
log(data);
|
|
21412
21412
|
return data;
|
|
21413
21413
|
}
|
|
21414
|
-
|
|
21415
|
-
//
|
|
21416
|
-
|
|
21414
|
+
mergePermissionsPreferEnabled(parentPermissions, childPermissions) {
|
|
21415
|
+
// Merge permissions so that any action enabled in either source remains enabled in the result
|
|
21416
|
+
const customizer = (objValue, srcValue, key) => {
|
|
21417
|
+
if (key === 'enabled') {
|
|
21418
|
+
const a = typeof objValue === 'boolean' ? objValue : false;
|
|
21419
|
+
const b = typeof srcValue === 'boolean' ? srcValue : false;
|
|
21420
|
+
return a || b;
|
|
21421
|
+
}
|
|
21422
|
+
return undefined; // fall back to default merge behavior
|
|
21423
|
+
};
|
|
21424
|
+
return _.mergeWith({}, parentPermissions, childPermissions, customizer);
|
|
21417
21425
|
}
|
|
21418
21426
|
async fetchRolePermissions(roleId) {
|
|
21419
21427
|
const response = await this.fetchData(`users-permissions/roles/${roleId}`);
|
|
@@ -21427,7 +21435,7 @@ class Strapi {
|
|
|
21427
21435
|
let currentParentId = initialParentId;
|
|
21428
21436
|
while (currentParentId) {
|
|
21429
21437
|
const { permissions: parentPermissions, parentId } = await this.fetchRolePermissions(currentParentId);
|
|
21430
|
-
accumulatedPermissions = this.
|
|
21438
|
+
accumulatedPermissions = this.mergePermissionsPreferEnabled(parentPermissions, accumulatedPermissions);
|
|
21431
21439
|
currentParentId = parentId;
|
|
21432
21440
|
}
|
|
21433
21441
|
return accumulatedPermissions;
|