@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.d.ts
CHANGED
|
@@ -192,7 +192,7 @@ declare class Strapi {
|
|
|
192
192
|
uploadForm(form: FormData): Promise<File[]>;
|
|
193
193
|
private baseFetch;
|
|
194
194
|
private permissionsList?;
|
|
195
|
-
private
|
|
195
|
+
private mergePermissionsPreferEnabled;
|
|
196
196
|
private fetchRolePermissions;
|
|
197
197
|
private collectRolePermissions;
|
|
198
198
|
can(uid: string, controller: string, action: string): Promise<boolean>;
|
package/dist/index.mjs
CHANGED
|
@@ -21398,7 +21398,9 @@ class Strapi {
|
|
|
21398
21398
|
const response = await fetch(`${this.url}/api/${endpoint}`, mergedParams);
|
|
21399
21399
|
let data = null;
|
|
21400
21400
|
try {
|
|
21401
|
-
|
|
21401
|
+
if (response.status !== 204) {
|
|
21402
|
+
data = await response?.clone().json() || null;
|
|
21403
|
+
}
|
|
21402
21404
|
}
|
|
21403
21405
|
catch (error) {
|
|
21404
21406
|
console.error(await response.text());
|
|
@@ -21409,9 +21411,17 @@ class Strapi {
|
|
|
21409
21411
|
log(data);
|
|
21410
21412
|
return data;
|
|
21411
21413
|
}
|
|
21412
|
-
|
|
21413
|
-
//
|
|
21414
|
-
|
|
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);
|
|
21415
21425
|
}
|
|
21416
21426
|
async fetchRolePermissions(roleId) {
|
|
21417
21427
|
const response = await this.fetchData(`users-permissions/roles/${roleId}`);
|
|
@@ -21425,7 +21435,7 @@ class Strapi {
|
|
|
21425
21435
|
let currentParentId = initialParentId;
|
|
21426
21436
|
while (currentParentId) {
|
|
21427
21437
|
const { permissions: parentPermissions, parentId } = await this.fetchRolePermissions(currentParentId);
|
|
21428
|
-
accumulatedPermissions = this.
|
|
21438
|
+
accumulatedPermissions = this.mergePermissionsPreferEnabled(parentPermissions, accumulatedPermissions);
|
|
21429
21439
|
currentParentId = parentId;
|
|
21430
21440
|
}
|
|
21431
21441
|
return accumulatedPermissions;
|