whio-api-sdk 1.0.227-beta-staging → 1.0.229-beta-staging

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.
@@ -6,6 +6,7 @@ export declare class UserModule extends BaseClient {
6
6
  assignEditorToRoleToUser(userId: string, organizationId?: string): Promise<User>;
7
7
  assignAdminToRoleToUser(userId: string, organizationId?: string): Promise<User>;
8
8
  assignDisabledToRoleToUser(userId: string, organizationId?: string): Promise<User>;
9
+ removeRoleFromUser(userId: string, organizationRoleId: string): Promise<void>;
9
10
  createEditorUser(firstName: string, lastName: string, email: string, password: string): Promise<User>;
10
11
  createAdminUser(firstName: string, lastName: string, email: string, password: string): Promise<User>;
11
12
  createDisabledUser(firstName: string, lastName: string, email: string, password: string): Promise<User>;
@@ -26,11 +26,14 @@ export class UserModule extends BaseClient {
26
26
  });
27
27
  }
28
28
  assignRoleToUser(userId, roleName, organizationId) {
29
- var _a;
29
+ var _a, _b;
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
31
  const orgId = organizationId || ((_a = this.user) === null || _a === void 0 ? void 0 : _a.organizationId);
32
32
  const organization = yield this.request(`${urls.organizations}/${orgId}`, 'GET');
33
- const orgRoleEditor = organization.roles.find(r => r.name === roleName);
33
+ const orgRoleEditor = (_b = organization.roles) === null || _b === void 0 ? void 0 : _b.find(r => r.name === roleName);
34
+ if (!orgRoleEditor) {
35
+ throw new Error(`Role ${roleName} not found in organization ${orgId}`);
36
+ }
34
37
  const assignRoleDto = {
35
38
  userId: userId,
36
39
  organizationRoleId: orgRoleEditor.id,
@@ -55,6 +58,11 @@ export class UserModule extends BaseClient {
55
58
  return this.assignRoleToUser(userId, OrganizationRoleType.DISABLED, organizationId);
56
59
  });
57
60
  }
61
+ removeRoleFromUser(userId, organizationRoleId) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ yield this.request(`${urls.userOrganizationRoles}/${userId}/${organizationRoleId}`, 'DELETE');
64
+ });
65
+ }
58
66
  createEditorUser(firstName, lastName, email, password) {
59
67
  return __awaiter(this, void 0, void 0, function* () {
60
68
  const user = yield this.createUser(firstName, lastName, email, password);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whio-api-sdk",
3
- "version": "1.0.227-beta-staging",
3
+ "version": "1.0.229-beta-staging",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -27,10 +27,13 @@ export class UserModule extends BaseClient {
27
27
  `${urls.organizations}/${orgId}`,
28
28
  'GET'
29
29
  );
30
- const orgRoleEditor = organization.roles!.find(r => r.name === roleName);
30
+ const orgRoleEditor = organization.roles?.find(r => r.name === roleName);
31
+ if (!orgRoleEditor) {
32
+ throw new Error(`Role ${roleName} not found in organization ${orgId}`);
33
+ }
31
34
  const assignRoleDto: AssignOrganizationRoleDto = {
32
35
  userId: userId,
33
- organizationRoleId: orgRoleEditor!.id,
36
+ organizationRoleId: orgRoleEditor.id,
34
37
  };
35
38
  this.request(urls.userOrganizationRoles, 'POST', assignRoleDto);
36
39
  const userWithOrgRole = await this.request<User>(`${urls.user}/${userId}`, 'GET');
@@ -49,6 +52,10 @@ export class UserModule extends BaseClient {
49
52
  return this.assignRoleToUser(userId, OrganizationRoleType.DISABLED, organizationId);
50
53
  }
51
54
 
55
+ public async removeRoleFromUser(userId: string, organizationRoleId: string): Promise<void> {
56
+ await this.request(`${urls.userOrganizationRoles}/${userId}/${organizationRoleId}`, 'DELETE');
57
+ }
58
+
52
59
  public async createEditorUser(firstName: string, lastName: string, email: string, password: string): Promise<User> {
53
60
  const user = await this.createUser(firstName, lastName, email, password);
54
61
  const userWithOrgRole = await this.assignEditorToRoleToUser(user.id);