@malevich-studio/strapi-sdk-typescript 1.2.19 → 1.2.21
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 +10 -6
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +10 -6
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +16 -9
- package/dist/index.mjs +5 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,18 @@ type RelationInput = {
|
|
|
13
13
|
set?: RelationData[];
|
|
14
14
|
} | RelationData[];
|
|
15
15
|
|
|
16
|
+
type Permissions = {
|
|
17
|
+
[key: string]: {
|
|
18
|
+
controllers: {
|
|
19
|
+
[key: string]: {
|
|
20
|
+
[key: string]: {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
policy: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
16
28
|
type PermissionAction = 'find' | 'findOne' | 'create' | 'update' | 'delete';
|
|
17
29
|
type SuccessResponse<T> = {
|
|
18
30
|
data: T;
|
|
@@ -148,12 +160,12 @@ type DynamiczonePopulate<T> = {
|
|
|
148
160
|
[K in keyof T]: T[K];
|
|
149
161
|
};
|
|
150
162
|
};
|
|
151
|
-
declare
|
|
163
|
+
declare class Strapi {
|
|
152
164
|
private readonly url;
|
|
153
165
|
private token?;
|
|
154
166
|
constructor(url: string, token?: string | undefined);
|
|
155
167
|
fetch<T>(endpoint: string, data?: object | FormData, params?: RequestInit): Promise<Response<T>>;
|
|
156
|
-
|
|
168
|
+
fetchData<T>(endpoint: string, data?: object | FormData, params?: RequestInit): Promise<T>;
|
|
157
169
|
setToken(token: string): void;
|
|
158
170
|
getToken(): string | undefined;
|
|
159
171
|
protected baseLogin<T>(identifier: string, password: string): Promise<AuthResponse<T>>;
|
|
@@ -179,12 +191,7 @@ declare abstract class Strapi {
|
|
|
179
191
|
uploadForm(form: FormData): Promise<File[]>;
|
|
180
192
|
private baseFetch;
|
|
181
193
|
private permissionsList?;
|
|
182
|
-
|
|
183
|
-
role?: {
|
|
184
|
-
documentId?: string;
|
|
185
|
-
};
|
|
186
|
-
}>;
|
|
187
|
-
can(uid: string, controller: string, action: PermissionAction): Promise<boolean>;
|
|
194
|
+
can(uid: string, controller: string, action: string): Promise<boolean>;
|
|
188
195
|
}
|
|
189
196
|
|
|
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 };
|
|
197
|
+
export { type AuthResponse, type DynamiczoneComponent, type DynamiczonePopulate, type ErrorResponse, type File, type FilterValue, type Filters, type Folder, type Locale, type PermissionAction, type Permissions, type Query, type RelationInput, type Response, Strapi, type SuccessResponse, type UserResponse };
|
package/dist/index.mjs
CHANGED
|
@@ -21436,8 +21436,11 @@ class Strapi {
|
|
|
21436
21436
|
}
|
|
21437
21437
|
async can(uid, controller, action) {
|
|
21438
21438
|
if (!this.permissionsList) {
|
|
21439
|
-
const
|
|
21440
|
-
|
|
21439
|
+
const user = await this.baseMe({ populate: { role: { fields: ["id"] } } });
|
|
21440
|
+
if (user.error) {
|
|
21441
|
+
return false;
|
|
21442
|
+
}
|
|
21443
|
+
const response = await this.fetchData(`users-permissions/roles/${user.role.id}`);
|
|
21441
21444
|
this.permissionsList = response.role.permissions;
|
|
21442
21445
|
}
|
|
21443
21446
|
if (!this.permissionsList[uid]) {
|