@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 CHANGED
@@ -21436,9 +21436,17 @@ class Strapi {
21436
21436
  log(data);
21437
21437
  return data;
21438
21438
  }
21439
- mergePermissionsPreferChild(parentPermissions, childPermissions) {
21440
- // Child permissions should override parent on conflicts; missing entries inherit from parent
21441
- return _.merge({}, parentPermissions, childPermissions);
21439
+ mergePermissionsPreferEnabled(parentPermissions, childPermissions) {
21440
+ // Merge permissions so that any action enabled in either source remains enabled in the result
21441
+ const customizer = (objValue, srcValue, key) => {
21442
+ if (key === 'enabled') {
21443
+ const a = typeof objValue === 'boolean' ? objValue : false;
21444
+ const b = typeof srcValue === 'boolean' ? srcValue : false;
21445
+ return a || b;
21446
+ }
21447
+ return undefined; // fall back to default merge behavior
21448
+ };
21449
+ return _.mergeWith({}, parentPermissions, childPermissions, customizer);
21442
21450
  }
21443
21451
  async fetchRolePermissions(roleId) {
21444
21452
  const response = await this.fetchData(`users-permissions/roles/${roleId}`);
@@ -21452,7 +21460,7 @@ class Strapi {
21452
21460
  let currentParentId = initialParentId;
21453
21461
  while (currentParentId) {
21454
21462
  const { permissions: parentPermissions, parentId } = await this.fetchRolePermissions(currentParentId);
21455
- accumulatedPermissions = this.mergePermissionsPreferChild(parentPermissions, accumulatedPermissions);
21463
+ accumulatedPermissions = this.mergePermissionsPreferEnabled(parentPermissions, accumulatedPermissions);
21456
21464
  currentParentId = parentId;
21457
21465
  }
21458
21466
  return accumulatedPermissions;