@malevich-studio/strapi-sdk-typescript 1.2.20 → 1.2.22

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/index.cjs CHANGED
@@ -21409,6 +21409,12 @@ class Strapi {
21409
21409
  ...params,
21410
21410
  });
21411
21411
  }
21412
+ async updateUser(endpoint, id, data, params = {}) {
21413
+ return await this.fetchData(`${endpoint}/${id}`, data, {
21414
+ method: 'PUT',
21415
+ ...params,
21416
+ });
21417
+ }
21412
21418
  async delete(endpoint, id, params = {}) {
21413
21419
  return await this.fetch(`${endpoint}/${id}`, {}, {
21414
21420
  method: 'DELETE',
@@ -21430,7 +21436,11 @@ class Strapi {
21430
21436
  } : {}),
21431
21437
  }, params);
21432
21438
  const response = await fetch(`${this.url}/api/${endpoint}`, mergedParams);
21433
- const data = await response.json();
21439
+ let data = null;
21440
+ try {
21441
+ data = await response?.json() || null;
21442
+ }
21443
+ catch (error) { }
21434
21444
  log(mergedParams);
21435
21445
  log(response);
21436
21446
  log(data);
@@ -21438,8 +21448,11 @@ class Strapi {
21438
21448
  }
21439
21449
  async can(uid, controller, action) {
21440
21450
  if (!this.permissionsList) {
21441
- const { role } = await this.me({ populate: { role: { fields: ["id"] } } });
21442
- const response = await this.fetchData(`users-permissions/roles/${role?.id}`);
21451
+ const user = await this.baseMe({ populate: { role: { fields: ["id"] } } });
21452
+ if (user.error) {
21453
+ return false;
21454
+ }
21455
+ const response = await this.fetchData(`users-permissions/roles/${user.role.id}`);
21443
21456
  this.permissionsList = response.role.permissions;
21444
21457
  }
21445
21458
  if (!this.permissionsList[uid]) {