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