whio-api-sdk 1.0.158 → 1.0.160
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/src/sdk/sdk.d.ts +3 -3
- package/dist/src/sdk/sdk.js +10 -8
- package/package.json +1 -1
- package/src/sdk/sdk.ts +10 -8
package/dist/src/sdk/sdk.d.ts
CHANGED
|
@@ -20,9 +20,9 @@ export declare class ApiSDK {
|
|
|
20
20
|
getRefreshToken(): string | null;
|
|
21
21
|
private createUser;
|
|
22
22
|
private assignRoleToUser;
|
|
23
|
-
assignEditorToRoleToUser(userId: string): Promise<User>;
|
|
24
|
-
assignAdminToRoleToUser(userId: string): Promise<User>;
|
|
25
|
-
assignDisabledToRoleToUser(userId: string): Promise<User>;
|
|
23
|
+
assignEditorToRoleToUser(userId: string, organizationId?: string): Promise<User>;
|
|
24
|
+
assignAdminToRoleToUser(userId: string, organizationId?: string): Promise<User>;
|
|
25
|
+
assignDisabledToRoleToUser(userId: string, organizationId?: string): Promise<User>;
|
|
26
26
|
createEditorUser(firstName: string, lastName: string, email: string, password: string): Promise<User>;
|
|
27
27
|
createAdminUser(firstName: string, lastName: string, email: string, password: string): Promise<User>;
|
|
28
28
|
createDisabledUser(firstName: string, lastName: string, email: string, password: string): Promise<User>;
|
package/dist/src/sdk/sdk.js
CHANGED
|
@@ -161,10 +161,11 @@ export class ApiSDK {
|
|
|
161
161
|
return user;
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
-
assignRoleToUser(userId, roleName) {
|
|
164
|
+
assignRoleToUser(userId, roleName, organizationId) {
|
|
165
165
|
var _a;
|
|
166
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
const
|
|
167
|
+
const orgId = organizationId || ((_a = this.user) === null || _a === void 0 ? void 0 : _a.organizationId);
|
|
168
|
+
const organization = yield this.request(`${urls.organizations}/${orgId}`, 'GET');
|
|
168
169
|
const orgRoleEditor = organization.roles.find(r => r.name === roleName);
|
|
169
170
|
const assignRoleDto = {
|
|
170
171
|
userId: userId,
|
|
@@ -175,19 +176,19 @@ export class ApiSDK {
|
|
|
175
176
|
return userWithOrgRole;
|
|
176
177
|
});
|
|
177
178
|
}
|
|
178
|
-
assignEditorToRoleToUser(userId) {
|
|
179
|
+
assignEditorToRoleToUser(userId, organizationId) {
|
|
179
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
return this.assignRoleToUser(userId, OrganizationRoleType.EDITOR);
|
|
181
|
+
return this.assignRoleToUser(userId, OrganizationRoleType.EDITOR, organizationId);
|
|
181
182
|
});
|
|
182
183
|
}
|
|
183
|
-
assignAdminToRoleToUser(userId) {
|
|
184
|
+
assignAdminToRoleToUser(userId, organizationId) {
|
|
184
185
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
return this.assignRoleToUser(userId, OrganizationRoleType.ADMIN);
|
|
186
|
+
return this.assignRoleToUser(userId, OrganizationRoleType.ADMIN, organizationId);
|
|
186
187
|
});
|
|
187
188
|
}
|
|
188
|
-
assignDisabledToRoleToUser(userId) {
|
|
189
|
+
assignDisabledToRoleToUser(userId, organizationId) {
|
|
189
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
190
|
-
return this.assignRoleToUser(userId, OrganizationRoleType.DISABLED);
|
|
191
|
+
return this.assignRoleToUser(userId, OrganizationRoleType.DISABLED, organizationId);
|
|
191
192
|
});
|
|
192
193
|
}
|
|
193
194
|
createEditorUser(firstName, lastName, email, password) {
|
|
@@ -433,6 +434,7 @@ export class ApiSDK {
|
|
|
433
434
|
}
|
|
434
435
|
addUserToOrganization(organizationId, userId) {
|
|
435
436
|
return __awaiter(this, void 0, void 0, function* () {
|
|
437
|
+
console.log('Adding user to organization:', organizationId, userId);
|
|
436
438
|
yield this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'POST');
|
|
437
439
|
});
|
|
438
440
|
}
|
package/package.json
CHANGED
package/src/sdk/sdk.ts
CHANGED
|
@@ -226,9 +226,10 @@ export class ApiSDK {
|
|
|
226
226
|
return user;
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
private async assignRoleToUser(userId: string, roleName: OrganizationRoleType): Promise<User> {
|
|
229
|
+
private async assignRoleToUser(userId: string, roleName: OrganizationRoleType, organizationId?: string): Promise<User> {
|
|
230
|
+
const orgId = organizationId || this.user?.organizationId;
|
|
230
231
|
const organization = await this.request<Organization>(
|
|
231
|
-
`${urls.organizations}/${
|
|
232
|
+
`${urls.organizations}/${orgId}`,
|
|
232
233
|
'GET'
|
|
233
234
|
);
|
|
234
235
|
const orgRoleEditor = organization.roles!.find(
|
|
@@ -245,16 +246,16 @@ export class ApiSDK {
|
|
|
245
246
|
return userWithOrgRole;
|
|
246
247
|
}
|
|
247
248
|
|
|
248
|
-
public async assignEditorToRoleToUser(userId: string): Promise<User> {
|
|
249
|
-
return this.assignRoleToUser(userId, OrganizationRoleType.EDITOR);
|
|
249
|
+
public async assignEditorToRoleToUser(userId: string, organizationId?: string): Promise<User> {
|
|
250
|
+
return this.assignRoleToUser(userId, OrganizationRoleType.EDITOR, organizationId);
|
|
250
251
|
}
|
|
251
252
|
|
|
252
|
-
public async assignAdminToRoleToUser(userId: string): Promise<User> {
|
|
253
|
-
return this.assignRoleToUser(userId, OrganizationRoleType.ADMIN);
|
|
253
|
+
public async assignAdminToRoleToUser(userId: string, organizationId?: string): Promise<User> {
|
|
254
|
+
return this.assignRoleToUser(userId, OrganizationRoleType.ADMIN, organizationId);
|
|
254
255
|
}
|
|
255
256
|
|
|
256
|
-
public async assignDisabledToRoleToUser(userId: string): Promise<User> {
|
|
257
|
-
return this.assignRoleToUser(userId, OrganizationRoleType.DISABLED);
|
|
257
|
+
public async assignDisabledToRoleToUser(userId: string, organizationId?: string): Promise<User> {
|
|
258
|
+
return this.assignRoleToUser(userId, OrganizationRoleType.DISABLED, organizationId);
|
|
258
259
|
}
|
|
259
260
|
|
|
260
261
|
public async createEditorUser(firstName: string, lastName: string,
|
|
@@ -517,6 +518,7 @@ export class ApiSDK {
|
|
|
517
518
|
}
|
|
518
519
|
|
|
519
520
|
public async addUserToOrganization(organizationId: string, userId: string): Promise<void> {
|
|
521
|
+
console.log('Adding user to organization:', organizationId, userId);
|
|
520
522
|
await this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'POST');
|
|
521
523
|
}
|
|
522
524
|
|