@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/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 mergePermissionsPreferChild;
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
@@ -21409,9 +21409,17 @@ class Strapi {
21409
21409
  log(data);
21410
21410
  return data;
21411
21411
  }
21412
- mergePermissionsPreferChild(parentPermissions, childPermissions) {
21413
- // Child permissions should override parent on conflicts; missing entries inherit from parent
21414
- return _.merge({}, parentPermissions, childPermissions);
21412
+ mergePermissionsPreferEnabled(parentPermissions, childPermissions) {
21413
+ // Merge permissions so that any action enabled in either source remains enabled in the result
21414
+ const customizer = (objValue, srcValue, key) => {
21415
+ if (key === 'enabled') {
21416
+ const a = typeof objValue === 'boolean' ? objValue : false;
21417
+ const b = typeof srcValue === 'boolean' ? srcValue : false;
21418
+ return a || b;
21419
+ }
21420
+ return undefined; // fall back to default merge behavior
21421
+ };
21422
+ return _.mergeWith({}, parentPermissions, childPermissions, customizer);
21415
21423
  }
21416
21424
  async fetchRolePermissions(roleId) {
21417
21425
  const response = await this.fetchData(`users-permissions/roles/${roleId}`);
@@ -21425,7 +21433,7 @@ class Strapi {
21425
21433
  let currentParentId = initialParentId;
21426
21434
  while (currentParentId) {
21427
21435
  const { permissions: parentPermissions, parentId } = await this.fetchRolePermissions(currentParentId);
21428
- accumulatedPermissions = this.mergePermissionsPreferChild(parentPermissions, accumulatedPermissions);
21436
+ accumulatedPermissions = this.mergePermissionsPreferEnabled(parentPermissions, accumulatedPermissions);
21429
21437
  currentParentId = parentId;
21430
21438
  }
21431
21439
  return accumulatedPermissions;