whio-api-sdk 1.0.156 โ 1.0.158
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 +4 -1
- package/dist/src/sdk/sdk.js +23 -0
- package/dist/src/sdk/types.d.ts +11 -0
- package/dist/src/sdk/urls.d.ts +2 -0
- package/dist/src/sdk/urls.js +2 -0
- package/package.json +1 -1
- package/src/sdk/sdk.ts +23 -0
- package/src/sdk/types.ts +15 -0
- package/src/sdk/urls.ts +2 -0
- package/test-password-change.ts +34 -0
- package/test-sdk-findAllByOrganization.js +64 -0
package/dist/src/sdk/sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LoginResponse, LoginCredentials, SDKConfig, User, UpdateUserDto, Organization, TemplateCategory, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse } from './types';
|
|
1
|
+
import { LoginResponse, LoginCredentials, SDKConfig, User, UpdateUserDto, Organization, TemplateCategory, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse, PasswordChangeResponse } from './types';
|
|
2
2
|
export declare class ApiSDK {
|
|
3
3
|
private baseUrl;
|
|
4
4
|
private storage;
|
|
@@ -35,6 +35,7 @@ export declare class ApiSDK {
|
|
|
35
35
|
updateTemplate(title: string, content: string, id: string): Promise<Template>;
|
|
36
36
|
updateUserTemplate(title: string, content: string, id: string): Promise<UserTemplate>;
|
|
37
37
|
getTemplates(): Promise<Template[]>;
|
|
38
|
+
getTemplatesByOrganization(): Promise<Template[]>;
|
|
38
39
|
getUserTemplates(): Promise<UserTemplate[]>;
|
|
39
40
|
generateTranscriptionSummary(transcript: string, templateId: string): Promise<TranscriptionSummary>;
|
|
40
41
|
getByOrganizationTranscriptionSummaries(organizationId: string): Promise<TranscriptionSummary[]>;
|
|
@@ -44,6 +45,8 @@ export declare class ApiSDK {
|
|
|
44
45
|
uploadAudioFile(formData: FormData): Promise<TranscriptionAudioUploadResponse | null>;
|
|
45
46
|
transcribeBase64Audio(base64String: string): Promise<string>;
|
|
46
47
|
getProfile(): Promise<User>;
|
|
48
|
+
changePassword(currentPassword: string, newPassword: string): Promise<PasswordChangeResponse>;
|
|
49
|
+
adminChangePassword(userId: string, newPassword: string): Promise<PasswordChangeResponse>;
|
|
47
50
|
createOrganization(name: string, description?: string): Promise<Organization>;
|
|
48
51
|
getOrganizations(): Promise<Organization[]>;
|
|
49
52
|
getOrganization(id: string): Promise<Organization>;
|
package/dist/src/sdk/sdk.js
CHANGED
|
@@ -303,6 +303,11 @@ export class ApiSDK {
|
|
|
303
303
|
return this.request(urls.templates, 'GET');
|
|
304
304
|
});
|
|
305
305
|
}
|
|
306
|
+
getTemplatesByOrganization() {
|
|
307
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
308
|
+
return this.request(`${urls.templates}/organization`, 'GET');
|
|
309
|
+
});
|
|
310
|
+
}
|
|
306
311
|
getUserTemplates() {
|
|
307
312
|
return __awaiter(this, void 0, void 0, function* () {
|
|
308
313
|
const url = `${urls.userTemplates}/user/${this.user.id}`;
|
|
@@ -378,6 +383,24 @@ export class ApiSDK {
|
|
|
378
383
|
return this.request(urls.profile, 'GET');
|
|
379
384
|
});
|
|
380
385
|
}
|
|
386
|
+
changePassword(currentPassword, newPassword) {
|
|
387
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
388
|
+
const dto = {
|
|
389
|
+
currentPassword,
|
|
390
|
+
newPassword,
|
|
391
|
+
};
|
|
392
|
+
return this.request(urls.changePassword, 'PATCH', dto);
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
adminChangePassword(userId, newPassword) {
|
|
396
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
397
|
+
const dto = {
|
|
398
|
+
userId,
|
|
399
|
+
newPassword,
|
|
400
|
+
};
|
|
401
|
+
return this.request(urls.adminChangePassword, 'PATCH', dto);
|
|
402
|
+
});
|
|
403
|
+
}
|
|
381
404
|
// ======================
|
|
382
405
|
// ORGANIZATION METHODS
|
|
383
406
|
// ======================
|
package/dist/src/sdk/types.d.ts
CHANGED
|
@@ -254,3 +254,14 @@ export declare enum RoleType {
|
|
|
254
254
|
TRIAL = "TRIAL",
|
|
255
255
|
PAID = "PAID"
|
|
256
256
|
}
|
|
257
|
+
export interface ChangePasswordDto {
|
|
258
|
+
currentPassword: string;
|
|
259
|
+
newPassword: string;
|
|
260
|
+
}
|
|
261
|
+
export interface AdminChangePasswordDto {
|
|
262
|
+
userId: string;
|
|
263
|
+
newPassword: string;
|
|
264
|
+
}
|
|
265
|
+
export interface PasswordChangeResponse {
|
|
266
|
+
message: string;
|
|
267
|
+
}
|
package/dist/src/sdk/urls.d.ts
CHANGED
package/dist/src/sdk/urls.js
CHANGED
package/package.json
CHANGED
package/src/sdk/sdk.ts
CHANGED
|
@@ -31,6 +31,9 @@ import {
|
|
|
31
31
|
UserTemplate,
|
|
32
32
|
TranscriptionSummary,
|
|
33
33
|
TranscriptionAudioUploadResponse,
|
|
34
|
+
ChangePasswordDto,
|
|
35
|
+
AdminChangePasswordDto,
|
|
36
|
+
PasswordChangeResponse,
|
|
34
37
|
} from './types';
|
|
35
38
|
import urls from './urls';
|
|
36
39
|
import jwtDecode from 'jwt-decode';
|
|
@@ -371,6 +374,10 @@ export class ApiSDK {
|
|
|
371
374
|
return this.request<Template[]>(urls.templates, 'GET');
|
|
372
375
|
}
|
|
373
376
|
|
|
377
|
+
public async getTemplatesByOrganization(): Promise<Template[]> {
|
|
378
|
+
return this.request<Template[]>(`${urls.templates}/organization`, 'GET');
|
|
379
|
+
}
|
|
380
|
+
|
|
374
381
|
public async getUserTemplates(): Promise<UserTemplate[]> {
|
|
375
382
|
const url = `${urls.userTemplates}/user/${this.user!.id}`;
|
|
376
383
|
return this.request<UserTemplate[]>(url, 'GET');
|
|
@@ -467,6 +474,22 @@ export class ApiSDK {
|
|
|
467
474
|
return this.request<User>(urls.profile, 'GET');
|
|
468
475
|
}
|
|
469
476
|
|
|
477
|
+
public async changePassword(currentPassword: string, newPassword: string): Promise<PasswordChangeResponse> {
|
|
478
|
+
const dto: ChangePasswordDto = {
|
|
479
|
+
currentPassword,
|
|
480
|
+
newPassword,
|
|
481
|
+
};
|
|
482
|
+
return this.request<PasswordChangeResponse>(urls.changePassword, 'PATCH', dto);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
public async adminChangePassword(userId: string, newPassword: string): Promise<PasswordChangeResponse> {
|
|
486
|
+
const dto: AdminChangePasswordDto = {
|
|
487
|
+
userId,
|
|
488
|
+
newPassword,
|
|
489
|
+
};
|
|
490
|
+
return this.request<PasswordChangeResponse>(urls.adminChangePassword, 'PATCH', dto);
|
|
491
|
+
}
|
|
492
|
+
|
|
470
493
|
// ======================
|
|
471
494
|
// ORGANIZATION METHODS
|
|
472
495
|
// ======================
|
package/src/sdk/types.ts
CHANGED
|
@@ -323,3 +323,18 @@ export enum RoleType {
|
|
|
323
323
|
TRIAL = 'TRIAL',
|
|
324
324
|
PAID = 'PAID',
|
|
325
325
|
}
|
|
326
|
+
|
|
327
|
+
// Password change DTOs
|
|
328
|
+
export interface ChangePasswordDto {
|
|
329
|
+
currentPassword: string;
|
|
330
|
+
newPassword: string;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export interface AdminChangePasswordDto {
|
|
334
|
+
userId: string;
|
|
335
|
+
newPassword: string;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export interface PasswordChangeResponse {
|
|
339
|
+
message: string;
|
|
340
|
+
}
|
package/src/sdk/urls.ts
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Test file for new password change functionality
|
|
2
|
+
import { ApiSDK, ChangePasswordDto, AdminChangePasswordDto, PasswordChangeResponse } from './index';
|
|
3
|
+
|
|
4
|
+
// Test function to verify the new methods compile correctly
|
|
5
|
+
async function testPasswordChangeMethods() {
|
|
6
|
+
const sdk = new ApiSDK({
|
|
7
|
+
baseUrl: 'http://localhost:3000/api'
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
// Test user password change
|
|
12
|
+
const changeResponse: PasswordChangeResponse = await sdk.changePassword(
|
|
13
|
+
'currentPassword123',
|
|
14
|
+
'newPassword456'
|
|
15
|
+
);
|
|
16
|
+
console.log('Change password response:', changeResponse);
|
|
17
|
+
|
|
18
|
+
// Test admin password change
|
|
19
|
+
const adminChangeResponse: PasswordChangeResponse = await sdk.adminChangePassword(
|
|
20
|
+
'user-uuid-here',
|
|
21
|
+
'newPassword789'
|
|
22
|
+
);
|
|
23
|
+
console.log('Admin change password response:', adminChangeResponse);
|
|
24
|
+
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error('Password change error:', error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Export for potential testing
|
|
31
|
+
export { testPasswordChangeMethods };
|
|
32
|
+
|
|
33
|
+
console.log('Password change methods are available on SDK');
|
|
34
|
+
console.log('Methods: changePassword(), adminChangePassword()');
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Test SDK findAllByOrganization methods
|
|
2
|
+
import { ApiSDK } from './index.js';
|
|
3
|
+
|
|
4
|
+
async function testSDKFindAllByOrganization() {
|
|
5
|
+
console.log('๐ Testing SDK findAllByOrganization methods...\n');
|
|
6
|
+
|
|
7
|
+
// Initialize SDK
|
|
8
|
+
const sdk = new ApiSDK({
|
|
9
|
+
baseUrl: 'http://localhost:3000/api',
|
|
10
|
+
storage: {
|
|
11
|
+
getItem: (key) => global.storage?.[key] || null,
|
|
12
|
+
setItem: (key, value) => {
|
|
13
|
+
if (!global.storage) global.storage = {};
|
|
14
|
+
global.storage[key] = value;
|
|
15
|
+
},
|
|
16
|
+
removeItem: (key) => {
|
|
17
|
+
if (global.storage) delete global.storage[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
// Login
|
|
24
|
+
console.log('๐ Logging in...');
|
|
25
|
+
const loginResponse = await sdk.login({
|
|
26
|
+
email: 'rimu.boddy@make.nz',
|
|
27
|
+
password: 'cbr400rr'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
console.log('โ
Login successful');
|
|
31
|
+
console.log(`User: ${loginResponse.user.email}`);
|
|
32
|
+
console.log(`Organization: ${loginResponse.user.organizationId}\n`);
|
|
33
|
+
|
|
34
|
+
// Test getTemplatesByOrganization
|
|
35
|
+
console.log('๐งช Testing getTemplatesByOrganization()...');
|
|
36
|
+
const templates = await sdk.getTemplatesByOrganization();
|
|
37
|
+
console.log('โ
Templates retrieved successfully');
|
|
38
|
+
console.log(`Found ${templates.length} templates for organization:`);
|
|
39
|
+
templates.forEach((template, index) => {
|
|
40
|
+
console.log(` ${index + 1}. ${template.title} (ID: ${template.id})`);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Test getUsersByOrganization
|
|
44
|
+
console.log('\n๐งช Testing getUsersByOrganization()...');
|
|
45
|
+
const users = await sdk.getUsersByOrganization(loginResponse.user.organizationId);
|
|
46
|
+
console.log('โ
Users retrieved successfully');
|
|
47
|
+
console.log(`Found ${users.length} users in organization:`);
|
|
48
|
+
users.forEach((user, index) => {
|
|
49
|
+
console.log(` ${index + 1}. ${user.email} - ${user.firstName} ${user.lastName}`);
|
|
50
|
+
console.log(` Org roles: ${user.organizationRoles?.map(r => r.organizationRole.name).join(', ') || 'None'}`);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
console.log('\nโ
All SDK tests completed successfully!');
|
|
54
|
+
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error('โ SDK test failed:', error.message);
|
|
57
|
+
if (error.stack) {
|
|
58
|
+
console.error('Stack trace:', error.stack);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Run the test
|
|
64
|
+
testSDKFindAllByOrganization();
|