@malevich-studio/strapi-sdk-typescript 1.2.17 → 1.2.19
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 +9 -8
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +9 -8
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +8 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.mjs +8 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ type DynamiczonePopulate<T> = {
|
|
|
148
148
|
[K in keyof T]: T[K];
|
|
149
149
|
};
|
|
150
150
|
};
|
|
151
|
-
declare class Strapi {
|
|
151
|
+
declare abstract class Strapi {
|
|
152
152
|
private readonly url;
|
|
153
153
|
private token?;
|
|
154
154
|
constructor(url: string, token?: string | undefined);
|
|
@@ -178,8 +178,13 @@ declare class Strapi {
|
|
|
178
178
|
delete<T>(endpoint: string, id: string, params?: RequestInit): Promise<Response<T>>;
|
|
179
179
|
uploadForm(form: FormData): Promise<File[]>;
|
|
180
180
|
private baseFetch;
|
|
181
|
-
private
|
|
182
|
-
|
|
181
|
+
private permissionsList?;
|
|
182
|
+
abstract me(): Promise<{
|
|
183
|
+
role?: {
|
|
184
|
+
documentId?: string;
|
|
185
|
+
};
|
|
186
|
+
}>;
|
|
187
|
+
can(uid: string, controller: string, action: PermissionAction): Promise<boolean>;
|
|
183
188
|
}
|
|
184
189
|
|
|
185
190
|
export { type AuthResponse, type DynamiczoneComponent, type DynamiczonePopulate, type ErrorResponse, type File, type FilterValue, type Filters, type Folder, type Locale, type PermissionAction, type Query, type RelationInput, type Response, Strapi, type SuccessResponse, type UserResponse };
|
package/dist/index.mjs
CHANGED
|
@@ -21435,20 +21435,21 @@ class Strapi {
|
|
|
21435
21435
|
return data;
|
|
21436
21436
|
}
|
|
21437
21437
|
async can(uid, controller, action) {
|
|
21438
|
-
if (!this.
|
|
21439
|
-
const
|
|
21440
|
-
|
|
21438
|
+
if (!this.permissionsList) {
|
|
21439
|
+
const { role } = await this.me();
|
|
21440
|
+
const response = await this.fetchData(`users-permissions/role/${role?.documentId}`);
|
|
21441
|
+
this.permissionsList = response.role.permissions;
|
|
21441
21442
|
}
|
|
21442
|
-
if (!this.
|
|
21443
|
+
if (!this.permissionsList[uid]) {
|
|
21443
21444
|
throw new Error(`Permissions for ${uid} not found!`);
|
|
21444
21445
|
}
|
|
21445
|
-
if (!this.
|
|
21446
|
+
if (!this.permissionsList[uid].controllers[controller]) {
|
|
21446
21447
|
throw new Error(`Permissions for ${uid}.${controller} not found!`);
|
|
21447
21448
|
}
|
|
21448
|
-
if (!this.
|
|
21449
|
+
if (!this.permissionsList[uid].controllers[controller][action]) {
|
|
21449
21450
|
throw new Error(`Permission for ${uid}.${controller}.${action} not found!`);
|
|
21450
21451
|
}
|
|
21451
|
-
return this.
|
|
21452
|
+
return this.permissionsList[uid].controllers[controller][action].enabled;
|
|
21452
21453
|
}
|
|
21453
21454
|
}
|
|
21454
21455
|
|