@malevich-studio/strapi-sdk-typescript 1.2.17 → 1.2.18

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
@@ -21441,20 +21441,20 @@ class Strapi {
21441
21441
  return data;
21442
21442
  }
21443
21443
  async can(uid, controller, action) {
21444
- if (!this.permissions) {
21444
+ if (!this.permissionsList) {
21445
21445
  const response = await this.fetchData('users-permissions/permissions');
21446
- this.permissions = response.permissions;
21446
+ this.permissionsList = response.permissions;
21447
21447
  }
21448
- if (!this.permissions[uid]) {
21448
+ if (!this.permissionsList[uid]) {
21449
21449
  throw new Error(`Permissions for ${uid} not found!`);
21450
21450
  }
21451
- if (!this.permissions[uid].controllers[controller]) {
21451
+ if (!this.permissionsList[uid].controllers[controller]) {
21452
21452
  throw new Error(`Permissions for ${uid}.${controller} not found!`);
21453
21453
  }
21454
- if (!this.permissions[uid].controllers[controller][action]) {
21454
+ if (!this.permissionsList[uid].controllers[controller][action]) {
21455
21455
  throw new Error(`Permission for ${uid}.${controller}.${action} not found!`);
21456
21456
  }
21457
- return this.permissions[uid].controllers[controller][action].enabled;
21457
+ return this.permissionsList[uid].controllers[controller][action].enabled;
21458
21458
  }
21459
21459
  }
21460
21460
 
@@ -21952,7 +21952,7 @@ function generateMethodsCode(contentType) {
21952
21952
  if (contentType.uid.startsWith('api::')) {
21953
21953
  methods.push([
21954
21954
  ` public async can${getContentTypeName(contentType.schema.singularName)}(action: PermissionAction) {`,
21955
- ` return await this.can('${contentType.uid}', '${contentType.schema.singularName.replace(/^api::/, '')}', action);`,
21955
+ ` return await this.can('${contentType.uid.split('.')[0]}', '${contentType.schema.singularName}', action);`,
21956
21956
  ' }',
21957
21957
  ].join('\n'));
21958
21958
  }