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