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