@malevich-studio/strapi-sdk-typescript 1.2.28 → 1.2.30
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 +15 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +15 -5
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +15 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +15 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/index.cjs
CHANGED
|
@@ -21400,7 +21400,9 @@ class Strapi {
|
|
|
21400
21400
|
const response = await fetch(`${this.url}/api/${endpoint}`, mergedParams);
|
|
21401
21401
|
let data = null;
|
|
21402
21402
|
try {
|
|
21403
|
-
|
|
21403
|
+
if (response.status !== 204) {
|
|
21404
|
+
data = await response?.clone().json() || null;
|
|
21405
|
+
}
|
|
21404
21406
|
}
|
|
21405
21407
|
catch (error) {
|
|
21406
21408
|
console.error(await response.text());
|
|
@@ -21411,9 +21413,17 @@ class Strapi {
|
|
|
21411
21413
|
log(data);
|
|
21412
21414
|
return data;
|
|
21413
21415
|
}
|
|
21414
|
-
|
|
21415
|
-
//
|
|
21416
|
-
|
|
21416
|
+
mergePermissionsPreferEnabled(parentPermissions, childPermissions) {
|
|
21417
|
+
// Merge permissions so that any action enabled in either source remains enabled in the result
|
|
21418
|
+
const customizer = (objValue, srcValue, key) => {
|
|
21419
|
+
if (key === 'enabled') {
|
|
21420
|
+
const a = typeof objValue === 'boolean' ? objValue : false;
|
|
21421
|
+
const b = typeof srcValue === 'boolean' ? srcValue : false;
|
|
21422
|
+
return a || b;
|
|
21423
|
+
}
|
|
21424
|
+
return undefined; // fall back to default merge behavior
|
|
21425
|
+
};
|
|
21426
|
+
return _.mergeWith({}, parentPermissions, childPermissions, customizer);
|
|
21417
21427
|
}
|
|
21418
21428
|
async fetchRolePermissions(roleId) {
|
|
21419
21429
|
const response = await this.fetchData(`users-permissions/roles/${roleId}`);
|
|
@@ -21427,7 +21437,7 @@ class Strapi {
|
|
|
21427
21437
|
let currentParentId = initialParentId;
|
|
21428
21438
|
while (currentParentId) {
|
|
21429
21439
|
const { permissions: parentPermissions, parentId } = await this.fetchRolePermissions(currentParentId);
|
|
21430
|
-
accumulatedPermissions = this.
|
|
21440
|
+
accumulatedPermissions = this.mergePermissionsPreferEnabled(parentPermissions, accumulatedPermissions);
|
|
21431
21441
|
currentParentId = parentId;
|
|
21432
21442
|
}
|
|
21433
21443
|
return accumulatedPermissions;
|