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

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.
@@ -26,8 +26,8 @@ export type RelationAttribute = BaseAttribute & {
26
26
  relation: AttributeRelation;
27
27
  target: string;
28
28
  targetAttribute?: string;
29
- inversedBy: string;
30
- mappedBy: string;
29
+ inversedBy?: string;
30
+ mappedBy?: string;
31
31
  };
32
32
  export default class Relation extends BaseRelation {
33
33
  protected readonly name: string;
package/dist/index.cjs CHANGED
@@ -21436,6 +21436,22 @@ class Strapi {
21436
21436
  log(data);
21437
21437
  return data;
21438
21438
  }
21439
+ async can(uid, controller, action) {
21440
+ if (!this.permissions) {
21441
+ const response = await this.fetchData('users-permissions/permissions');
21442
+ this.permissions = response.permissions;
21443
+ }
21444
+ if (!this.permissions[uid]) {
21445
+ throw new Error(`Permissions for ${uid} not found!`);
21446
+ }
21447
+ if (!this.permissions[uid].controllers[controller]) {
21448
+ throw new Error(`Permissions for ${uid}.${controller} not found!`);
21449
+ }
21450
+ if (!this.permissions[uid].controllers[controller][action]) {
21451
+ throw new Error(`Permission for ${uid}.${controller}.${action} not found!`);
21452
+ }
21453
+ return this.permissions[uid].controllers[controller][action].enabled;
21454
+ }
21439
21455
  }
21440
21456
 
21441
21457
  exports.Strapi = Strapi;