whio-api-sdk 1.0.155 โ 1.0.156
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/.claude/settings.local.json +6 -1
- package/dist/src/sdk/index.d.ts +1 -0
- package/dist/src/sdk/index.js +1 -0
- package/dist/src/sdk/sdk.d.ts +39 -5
- package/dist/src/sdk/sdk.js +220 -9
- package/dist/src/sdk/types.d.ts +33 -2
- package/dist/src/sdk/types.js +8 -0
- package/dist/src/sdk/urls.d.ts +8 -5
- package/dist/src/sdk/urls.js +15 -5
- package/package.json +3 -2
- package/quick-test.mjs +155 -0
- package/src/sdk/index.ts +2 -1
- package/src/sdk/sdk.ts +214 -16
- package/src/sdk/types.ts +45 -7
- package/src/sdk/urls.ts +21 -5
- package/test-comprehensive.mjs +276 -0
- package/test-sdk.cjs +190 -0
- package/test-sdk.mjs +228 -0
- package/test-sdk.ts +167 -0
- package/test-simple.mjs +90 -0
package/dist/src/sdk/index.d.ts
CHANGED
package/dist/src/sdk/index.js
CHANGED
package/dist/src/sdk/sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LoginResponse, LoginCredentials, SDKConfig, User, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse } from './types';
|
|
1
|
+
import { LoginResponse, LoginCredentials, SDKConfig, User, UpdateUserDto, Organization, TemplateCategory, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse } from './types';
|
|
2
2
|
export declare class ApiSDK {
|
|
3
3
|
private baseUrl;
|
|
4
4
|
private storage;
|
|
@@ -27,19 +27,53 @@ export declare class ApiSDK {
|
|
|
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>;
|
|
29
29
|
createTeam(name: string, description: string): Promise<Team>;
|
|
30
|
-
updateTeam(id: string, name: string, description: string): Promise<
|
|
30
|
+
updateTeam(id: string, name: string, description: string): Promise<Team>;
|
|
31
31
|
addUserToTeam(teamId: string, userId: string, roleName: string): Promise<any>;
|
|
32
|
-
removeUserFromTeam(teamId: string, userId: string): Promise<
|
|
33
|
-
createTemplate(title: string, content: string): Promise<
|
|
32
|
+
removeUserFromTeam(teamId: string, userId: string): Promise<void>;
|
|
33
|
+
createTemplate(title: string, content: string, categoryId?: string): Promise<Template>;
|
|
34
34
|
createUserTemplate(title: string, content: string, originalTemplateId: string | undefined): Promise<UserTemplate>;
|
|
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
38
|
getUserTemplates(): Promise<UserTemplate[]>;
|
|
39
39
|
generateTranscriptionSummary(transcript: string, templateId: string): Promise<TranscriptionSummary>;
|
|
40
|
+
getByOrganizationTranscriptionSummaries(organizationId: string): Promise<TranscriptionSummary[]>;
|
|
40
41
|
generateTranscriptionSummaryFromUserTemplate(transcript: string, userTemplateId: string): Promise<TranscriptionSummary>;
|
|
41
42
|
updateTranscriptionSummary(id: string, content: string): Promise<TranscriptionSummary>;
|
|
42
43
|
uploadLargeAudioFile(formData: FormData): Promise<string>;
|
|
43
44
|
uploadAudioFile(formData: FormData): Promise<TranscriptionAudioUploadResponse | null>;
|
|
44
|
-
transcribeBase64Audio(base64String:
|
|
45
|
+
transcribeBase64Audio(base64String: string): Promise<string>;
|
|
46
|
+
getProfile(): Promise<User>;
|
|
47
|
+
createOrganization(name: string, description?: string): Promise<Organization>;
|
|
48
|
+
getOrganizations(): Promise<Organization[]>;
|
|
49
|
+
getOrganization(id: string): Promise<Organization>;
|
|
50
|
+
updateOrganization(id: string, name?: string, description?: string): Promise<Organization>;
|
|
51
|
+
deleteOrganization(id: string): Promise<void>;
|
|
52
|
+
addUserToOrganization(organizationId: string, userId: string): Promise<void>;
|
|
53
|
+
removeUserFromOrganization(organizationId: string, userId: string): Promise<void>;
|
|
54
|
+
getUsers(): Promise<User[]>;
|
|
55
|
+
getUser(id: string): Promise<User>;
|
|
56
|
+
getUsersByOrganization(organizationId: string): Promise<User[]>;
|
|
57
|
+
updateUser(id: string, data: UpdateUserDto): Promise<User>;
|
|
58
|
+
deleteUser(id: string): Promise<void>;
|
|
59
|
+
getTeams(): Promise<Team[]>;
|
|
60
|
+
getTeam(id: string): Promise<Team>;
|
|
61
|
+
getTeamsByOrganization(organizationId: string): Promise<Team[]>;
|
|
62
|
+
deleteTeam(id: string): Promise<void>;
|
|
63
|
+
getTemplateCategories(): Promise<TemplateCategory[]>;
|
|
64
|
+
getTemplateCategory(id: string): Promise<TemplateCategory>;
|
|
65
|
+
createTemplateCategory(name: string): Promise<TemplateCategory>;
|
|
66
|
+
updateTemplateCategory(id: string, name: string): Promise<TemplateCategory>;
|
|
67
|
+
deleteTemplateCategory(id: string): Promise<void>;
|
|
68
|
+
getTemplate(id: string): Promise<Template>;
|
|
69
|
+
deleteTemplate(id: string): Promise<void>;
|
|
70
|
+
getUserTemplate(id: string): Promise<UserTemplate>;
|
|
71
|
+
deleteUserTemplate(id: string): Promise<void>;
|
|
72
|
+
assignTemplateToTeam(teamId: string, templateId: string): Promise<void>;
|
|
73
|
+
removeTemplateFromTeam(teamId: string, templateId: string): Promise<void>;
|
|
74
|
+
getTranscriptionSummaries(): Promise<TranscriptionSummary[]>;
|
|
75
|
+
getTranscriptionSummary(id: string): Promise<TranscriptionSummary>;
|
|
76
|
+
getTranscriptionSummariesByUser(userId: string): Promise<TranscriptionSummary[]>;
|
|
77
|
+
deleteTranscriptionSummary(id: string): Promise<void>;
|
|
78
|
+
removeUserFromTeamFixed(teamId: string, userId: string): Promise<void>;
|
|
45
79
|
}
|
package/dist/src/sdk/sdk.js
CHANGED
|
@@ -82,12 +82,12 @@ export class ApiSDK {
|
|
|
82
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
83
|
const url = `${this.baseUrl}${endpoint}`;
|
|
84
84
|
const defaultHeaders = {
|
|
85
|
-
'Content-Type': 'multipart/form-data',
|
|
86
85
|
'ngrok-skip-browser-warning': 'true'
|
|
87
86
|
};
|
|
88
87
|
if (this.accessToken) {
|
|
89
88
|
defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
|
|
90
89
|
}
|
|
90
|
+
// Don't set Content-Type for FormData - let browser set it with boundary
|
|
91
91
|
const response = yield fetch(url, {
|
|
92
92
|
method: 'POST',
|
|
93
93
|
headers: Object.assign(Object.assign({}, defaultHeaders), headers),
|
|
@@ -105,7 +105,7 @@ export class ApiSDK {
|
|
|
105
105
|
try {
|
|
106
106
|
const response = yield this.request('/auth/login', 'POST', credentials, {}, true);
|
|
107
107
|
this.accessToken = response.access_token;
|
|
108
|
-
this.refreshToken = response.
|
|
108
|
+
this.refreshToken = response.refresh_token;
|
|
109
109
|
this.user = response.user;
|
|
110
110
|
yield this.storage.setItem('access_token', response.access_token);
|
|
111
111
|
yield this.storage.setItem('user', JSON.stringify(response.user));
|
|
@@ -227,7 +227,7 @@ export class ApiSDK {
|
|
|
227
227
|
name,
|
|
228
228
|
description,
|
|
229
229
|
};
|
|
230
|
-
return this.request(`${urls.teams}/${id}`, '
|
|
230
|
+
return this.request(`${urls.teams}/${id}`, 'PATCH', teamDto);
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
233
|
addUserToTeam(teamId, userId, roleName) {
|
|
@@ -242,19 +242,25 @@ export class ApiSDK {
|
|
|
242
242
|
}
|
|
243
243
|
removeUserFromTeam(teamId, userId) {
|
|
244
244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
-
|
|
246
|
-
return this.request(urls.teamRoles, 'DELETE');
|
|
245
|
+
yield this.request(`${urls.teamRoles}/user/${userId}/team/${teamId}`, 'DELETE');
|
|
247
246
|
});
|
|
248
247
|
}
|
|
249
|
-
|
|
250
|
-
|
|
248
|
+
createTemplate(title, content, categoryId) {
|
|
249
|
+
var _a;
|
|
251
250
|
return __awaiter(this, void 0, void 0, function* () {
|
|
252
|
-
|
|
251
|
+
let finalCategoryId = categoryId;
|
|
252
|
+
if (!finalCategoryId) {
|
|
253
|
+
const templateCategories = yield this.request(urls.templateCategories, 'GET');
|
|
254
|
+
finalCategoryId = (_a = templateCategories[0]) === null || _a === void 0 ? void 0 : _a.id;
|
|
255
|
+
if (!finalCategoryId) {
|
|
256
|
+
throw new Error('No template categories available. Please create one first.');
|
|
257
|
+
}
|
|
258
|
+
}
|
|
253
259
|
const createTemplateDto = {
|
|
254
260
|
title,
|
|
255
261
|
content,
|
|
256
262
|
isGlobal: false,
|
|
257
|
-
categoryId:
|
|
263
|
+
categoryId: finalCategoryId,
|
|
258
264
|
createdById: this.user.id,
|
|
259
265
|
organizationId: this.user.organizationId,
|
|
260
266
|
};
|
|
@@ -303,6 +309,9 @@ export class ApiSDK {
|
|
|
303
309
|
return this.request(url, 'GET');
|
|
304
310
|
});
|
|
305
311
|
}
|
|
312
|
+
// ======================
|
|
313
|
+
// trANSCRIPTION SUMMARY METHODS
|
|
314
|
+
// ======================
|
|
306
315
|
generateTranscriptionSummary(transcript, templateId) {
|
|
307
316
|
return __awaiter(this, void 0, void 0, function* () {
|
|
308
317
|
const generateSummaryDto = {
|
|
@@ -315,6 +324,11 @@ export class ApiSDK {
|
|
|
315
324
|
return transcriptionSummary;
|
|
316
325
|
});
|
|
317
326
|
}
|
|
327
|
+
getByOrganizationTranscriptionSummaries(organizationId) {
|
|
328
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
329
|
+
return this.request(`${urls.transcriptionSummaries}/organization/${organizationId}`, 'GET');
|
|
330
|
+
});
|
|
331
|
+
}
|
|
318
332
|
generateTranscriptionSummaryFromUserTemplate(transcript, userTemplateId) {
|
|
319
333
|
return __awaiter(this, void 0, void 0, function* () {
|
|
320
334
|
const generateSummaryDto = {
|
|
@@ -356,4 +370,201 @@ export class ApiSDK {
|
|
|
356
370
|
return transcript.transcript;
|
|
357
371
|
});
|
|
358
372
|
}
|
|
373
|
+
// ======================
|
|
374
|
+
// AUTH METHODS
|
|
375
|
+
// ======================
|
|
376
|
+
getProfile() {
|
|
377
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
378
|
+
return this.request(urls.profile, 'GET');
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
// ======================
|
|
382
|
+
// ORGANIZATION METHODS
|
|
383
|
+
// ======================
|
|
384
|
+
createOrganization(name, description) {
|
|
385
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
386
|
+
const dto = { name, description };
|
|
387
|
+
return this.request(urls.organizations, 'POST', dto);
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
getOrganizations() {
|
|
391
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
392
|
+
return this.request(urls.organizations, 'GET');
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
getOrganization(id) {
|
|
396
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
397
|
+
return this.request(`${urls.organizations}/${id}`, 'GET');
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
updateOrganization(id, name, description) {
|
|
401
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
402
|
+
const dto = { name, description };
|
|
403
|
+
return this.request(`${urls.organizations}/${id}`, 'PATCH', dto);
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
deleteOrganization(id) {
|
|
407
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
408
|
+
yield this.request(`${urls.organizations}/${id}`, 'DELETE');
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
addUserToOrganization(organizationId, userId) {
|
|
412
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
413
|
+
yield this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'POST');
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
removeUserFromOrganization(organizationId, userId) {
|
|
417
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
418
|
+
yield this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'DELETE');
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
// ======================
|
|
422
|
+
// USER METHODS
|
|
423
|
+
// ======================
|
|
424
|
+
getUsers() {
|
|
425
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
426
|
+
return this.request(urls.users, 'GET');
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
getUser(id) {
|
|
430
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
431
|
+
return this.request(`${urls.users}/${id}`, 'GET');
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
getUsersByOrganization(organizationId) {
|
|
435
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
436
|
+
return this.request(`${urls.users}/organization/${organizationId}`, 'GET');
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
updateUser(id, data) {
|
|
440
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
441
|
+
return this.request(`${urls.users}/${id}`, 'PATCH', data);
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
deleteUser(id) {
|
|
445
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
446
|
+
yield this.request(`${urls.users}/${id}`, 'DELETE');
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
// ======================
|
|
450
|
+
// TEAM METHODS
|
|
451
|
+
// ======================
|
|
452
|
+
getTeams() {
|
|
453
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
454
|
+
return this.request(urls.teams, 'GET');
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
getTeam(id) {
|
|
458
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
459
|
+
return this.request(`${urls.teams}/${id}`, 'GET');
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
getTeamsByOrganization(organizationId) {
|
|
463
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
464
|
+
return this.request(`${urls.teams}/organization/${organizationId}`, 'GET');
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
deleteTeam(id) {
|
|
468
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
469
|
+
yield this.request(`${urls.teams}/${id}`, 'DELETE');
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
// ======================
|
|
473
|
+
// TEMPLATE CATEGORY METHODS
|
|
474
|
+
// ======================
|
|
475
|
+
getTemplateCategories() {
|
|
476
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
477
|
+
return this.request(urls.templateCategories, 'GET');
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
getTemplateCategory(id) {
|
|
481
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
482
|
+
return this.request(`${urls.templateCategories}/${id}`, 'GET');
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
createTemplateCategory(name) {
|
|
486
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
487
|
+
const dto = { name };
|
|
488
|
+
return this.request(urls.templateCategories, 'POST', dto);
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
updateTemplateCategory(id, name) {
|
|
492
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
493
|
+
const dto = { name };
|
|
494
|
+
return this.request(`${urls.templateCategories}/${id}`, 'PATCH', dto);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
deleteTemplateCategory(id) {
|
|
498
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
499
|
+
yield this.request(`${urls.templateCategories}/${id}`, 'DELETE');
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
// ======================
|
|
503
|
+
// ENHANCED TEMPLATE METHODS
|
|
504
|
+
// ======================
|
|
505
|
+
getTemplate(id) {
|
|
506
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
507
|
+
return this.request(`${urls.templates}/${id}`, 'GET');
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
deleteTemplate(id) {
|
|
511
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
512
|
+
yield this.request(`${urls.templates}/${id}`, 'DELETE');
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
getUserTemplate(id) {
|
|
516
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
517
|
+
return this.request(`${urls.userTemplates}/${id}`, 'GET');
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
deleteUserTemplate(id) {
|
|
521
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
522
|
+
yield this.request(`${urls.userTemplates}/${id}`, 'DELETE');
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
// ======================
|
|
526
|
+
// TEAM TEMPLATE METHODS
|
|
527
|
+
// ======================
|
|
528
|
+
assignTemplateToTeam(teamId, templateId) {
|
|
529
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
530
|
+
const dto = { teamId, templateId };
|
|
531
|
+
yield this.request(urls.teamTemplates, 'POST', dto);
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
removeTemplateFromTeam(teamId, templateId) {
|
|
535
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
536
|
+
yield this.request(`${urls.teamTemplates}/team/${teamId}/template/${templateId}`, 'DELETE');
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
// ======================
|
|
540
|
+
// TRANSCRIPTION SUMMARY METHODS
|
|
541
|
+
// ======================
|
|
542
|
+
getTranscriptionSummaries() {
|
|
543
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
544
|
+
return this.request(urls.transcriptionSummaries, 'GET');
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
getTranscriptionSummary(id) {
|
|
548
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
549
|
+
return this.request(`${urls.transcriptionSummaries}/${id}`, 'GET');
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
getTranscriptionSummariesByUser(userId) {
|
|
553
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
554
|
+
return this.request(`${urls.transcriptionSummaries}/user/${userId}`, 'GET');
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
deleteTranscriptionSummary(id) {
|
|
558
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
559
|
+
yield this.request(`${urls.transcriptionSummaries}/${id}`, 'DELETE');
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
// ======================
|
|
563
|
+
// ENHANCED TEAM ROLE METHODS
|
|
564
|
+
// ======================
|
|
565
|
+
removeUserFromTeamFixed(teamId, userId) {
|
|
566
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
567
|
+
yield this.request(`${urls.teamRoles}/user/${userId}/team/${teamId}`, 'DELETE');
|
|
568
|
+
});
|
|
569
|
+
}
|
|
359
570
|
}
|
package/dist/src/sdk/types.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export interface User {
|
|
|
46
46
|
}
|
|
47
47
|
export interface LoginResponse {
|
|
48
48
|
access_token: string;
|
|
49
|
-
|
|
49
|
+
refresh_token: string;
|
|
50
50
|
user: User;
|
|
51
51
|
}
|
|
52
52
|
export interface LoginCredentials {
|
|
@@ -216,10 +216,41 @@ export interface Team {
|
|
|
216
216
|
teamTemplates?: TeamTemplate[];
|
|
217
217
|
}
|
|
218
218
|
export interface TranscriptionAudioUploadResponse {
|
|
219
|
-
success:
|
|
219
|
+
success: boolean;
|
|
220
220
|
transcription: string;
|
|
221
221
|
model_version: string;
|
|
222
222
|
metadata: any[];
|
|
223
223
|
duration: number;
|
|
224
224
|
log: string;
|
|
225
225
|
}
|
|
226
|
+
export interface CreateOrganizationDto {
|
|
227
|
+
name: string;
|
|
228
|
+
description?: string;
|
|
229
|
+
}
|
|
230
|
+
export interface UpdateOrganizationDto {
|
|
231
|
+
name?: string;
|
|
232
|
+
description?: string;
|
|
233
|
+
}
|
|
234
|
+
export interface CreateTemplateCategoryDto {
|
|
235
|
+
name: string;
|
|
236
|
+
}
|
|
237
|
+
export interface UpdateTemplateCategoryDto {
|
|
238
|
+
name?: string;
|
|
239
|
+
}
|
|
240
|
+
export interface CreateTranscriptionSummaryDto {
|
|
241
|
+
userId: string;
|
|
242
|
+
templateId: string;
|
|
243
|
+
content: string;
|
|
244
|
+
anonymisedTranscript?: string;
|
|
245
|
+
metadata?: Record<string, any>;
|
|
246
|
+
}
|
|
247
|
+
export interface AssignTeamTemplateDto {
|
|
248
|
+
teamId: string;
|
|
249
|
+
templateId: string;
|
|
250
|
+
}
|
|
251
|
+
export declare enum RoleType {
|
|
252
|
+
SUPERUSER = "SUPERUSER",
|
|
253
|
+
ADMIN = "ADMIN",
|
|
254
|
+
TRIAL = "TRIAL",
|
|
255
|
+
PAID = "PAID"
|
|
256
|
+
}
|
package/dist/src/sdk/types.js
CHANGED
|
@@ -5,3 +5,11 @@ export var OrganizationRoleType;
|
|
|
5
5
|
OrganizationRoleType["EDITOR"] = "EDITOR";
|
|
6
6
|
OrganizationRoleType["DISABLED"] = "DISABLED";
|
|
7
7
|
})(OrganizationRoleType || (OrganizationRoleType = {}));
|
|
8
|
+
// Enum for global role types to match API
|
|
9
|
+
export var RoleType;
|
|
10
|
+
(function (RoleType) {
|
|
11
|
+
RoleType["SUPERUSER"] = "SUPERUSER";
|
|
12
|
+
RoleType["ADMIN"] = "ADMIN";
|
|
13
|
+
RoleType["TRIAL"] = "TRIAL";
|
|
14
|
+
RoleType["PAID"] = "PAID";
|
|
15
|
+
})(RoleType || (RoleType = {}));
|
package/dist/src/sdk/urls.d.ts
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
declare const urls: {
|
|
2
2
|
login: string;
|
|
3
|
+
profile: string;
|
|
3
4
|
register: string;
|
|
4
5
|
refreshToken: string;
|
|
5
6
|
logout: string;
|
|
6
7
|
user: string;
|
|
7
8
|
users: string;
|
|
8
|
-
roles: string;
|
|
9
|
-
teams: string;
|
|
10
9
|
organizations: string;
|
|
11
10
|
organizationRoles: string;
|
|
12
|
-
|
|
11
|
+
userOrganizationRoles: string;
|
|
12
|
+
teams: string;
|
|
13
13
|
teamRoles: string;
|
|
14
|
+
teamTemplates: string;
|
|
14
15
|
templates: string;
|
|
15
|
-
|
|
16
|
+
templateCategories: string;
|
|
16
17
|
userTemplates: string;
|
|
17
|
-
|
|
18
|
+
transcriptionSummaries: string;
|
|
18
19
|
transcriptionSummary: string;
|
|
19
20
|
uploadAudioLarge: string;
|
|
20
21
|
uploadAudio: string;
|
|
21
22
|
transcribeBase64Audio: string;
|
|
23
|
+
roles: string;
|
|
24
|
+
userRoles: string;
|
|
22
25
|
};
|
|
23
26
|
export default urls;
|
package/dist/src/sdk/urls.js
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
const urls = {
|
|
2
|
+
// Auth
|
|
2
3
|
login: '/auth/login',
|
|
4
|
+
profile: '/auth/profile',
|
|
3
5
|
register: '/auth/register',
|
|
4
6
|
refreshToken: '/auth/refresh-token',
|
|
5
7
|
logout: '/auth/logout',
|
|
8
|
+
// Users
|
|
6
9
|
user: '/users',
|
|
7
10
|
users: '/users',
|
|
8
|
-
|
|
9
|
-
teams: '/teams',
|
|
11
|
+
// Organizations
|
|
10
12
|
organizations: '/organizations',
|
|
11
13
|
organizationRoles: '/organization-roles',
|
|
12
|
-
|
|
14
|
+
userOrganizationRoles: '/user-organization-roles',
|
|
15
|
+
// Teams
|
|
16
|
+
teams: '/teams',
|
|
13
17
|
teamRoles: '/team-roles',
|
|
18
|
+
teamTemplates: '/team-templates',
|
|
19
|
+
// Templates
|
|
14
20
|
templates: '/templates',
|
|
15
|
-
|
|
21
|
+
templateCategories: '/template-categories',
|
|
16
22
|
userTemplates: '/user-templates',
|
|
17
|
-
|
|
23
|
+
// Transcription Summaries
|
|
24
|
+
transcriptionSummaries: '/transcription-summaries',
|
|
18
25
|
transcriptionSummary: '/transcription-summaries/generate',
|
|
19
26
|
uploadAudioLarge: '/transcription-summaries/upload-audio-large',
|
|
20
27
|
uploadAudio: '/transcription-summaries/upload-audio',
|
|
21
28
|
transcribeBase64Audio: '/transcription-summaries/transcribe-base64',
|
|
29
|
+
// Roles
|
|
30
|
+
roles: '/roles',
|
|
31
|
+
userRoles: '/user-roles',
|
|
22
32
|
};
|
|
23
33
|
export default urls;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whio-api-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.156",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"typescript": "^4.0.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@types/node": "^14.
|
|
17
|
+
"@types/node": "^14.18.63",
|
|
18
|
+
"ts-node": "^10.9.2"
|
|
18
19
|
}
|
|
19
20
|
}
|
package/quick-test.mjs
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Quick test of localhost:3000 API
|
|
2
|
+
console.log('๐ Testing localhost:3000 API directly...\n');
|
|
3
|
+
|
|
4
|
+
// Test 1: Check if API is running
|
|
5
|
+
async function testAPIHealth() {
|
|
6
|
+
try {
|
|
7
|
+
console.log('1. ๐ฅ Testing API health...');
|
|
8
|
+
const response = await fetch('http://localhost:3000');
|
|
9
|
+
console.log('โ
API is running! Status:', response.status);
|
|
10
|
+
return true;
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.log('โ API is not running:', error.message);
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Test 2: Try to create a user
|
|
18
|
+
async function testCreateUser() {
|
|
19
|
+
try {
|
|
20
|
+
console.log('\n2. ๐ค Testing user creation...');
|
|
21
|
+
const userData = {
|
|
22
|
+
email: 'sdk-test@example.com',
|
|
23
|
+
password: 'testpassword123',
|
|
24
|
+
firstName: 'SDK',
|
|
25
|
+
lastName: 'Test'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const response = await fetch('http://localhost:3000/users', {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
headers: {
|
|
31
|
+
'Content-Type': 'application/json',
|
|
32
|
+
},
|
|
33
|
+
body: JSON.stringify(userData)
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const responseData = await response.json().catch(() => null);
|
|
37
|
+
|
|
38
|
+
if (response.ok) {
|
|
39
|
+
console.log('โ
User created successfully!');
|
|
40
|
+
console.log('๐ง Email:', responseData?.email);
|
|
41
|
+
return userData;
|
|
42
|
+
} else {
|
|
43
|
+
console.log('โ ๏ธ User creation failed:', response.status, responseData?.message || 'Unknown error');
|
|
44
|
+
console.log('๐ Will try to login with existing credentials...');
|
|
45
|
+
return userData; // Return credentials anyway for login test
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.log('โ Error creating user:', error.message);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Test 3: Try to login
|
|
54
|
+
async function testLogin(credentials) {
|
|
55
|
+
try {
|
|
56
|
+
console.log('\n3. ๐ Testing login...');
|
|
57
|
+
const response = await fetch('http://localhost:3000/auth/login', {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
headers: {
|
|
60
|
+
'Content-Type': 'application/json',
|
|
61
|
+
},
|
|
62
|
+
body: JSON.stringify({
|
|
63
|
+
email: credentials.email,
|
|
64
|
+
password: credentials.password
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const responseData = await response.json().catch(() => null);
|
|
69
|
+
|
|
70
|
+
if (response.ok && responseData?.access_token) {
|
|
71
|
+
console.log('โ
Login successful!');
|
|
72
|
+
console.log('๐ Token received:', responseData.access_token.substring(0, 20) + '...');
|
|
73
|
+
console.log('๐ค User ID:', responseData.user?.id);
|
|
74
|
+
return responseData;
|
|
75
|
+
} else {
|
|
76
|
+
console.log('โ Login failed:', response.status, responseData?.message || 'Unknown error');
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.log('โ Error during login:', error.message);
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Test 4: Test authenticated endpoint
|
|
86
|
+
async function testAuthenticatedEndpoint(token) {
|
|
87
|
+
try {
|
|
88
|
+
console.log('\n4. ๐ก๏ธ Testing authenticated endpoint (profile)...');
|
|
89
|
+
const response = await fetch('http://localhost:3000/auth/profile', {
|
|
90
|
+
method: 'GET',
|
|
91
|
+
headers: {
|
|
92
|
+
'Authorization': `Bearer ${token}`,
|
|
93
|
+
'Content-Type': 'application/json',
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const responseData = await response.json().catch(() => null);
|
|
98
|
+
|
|
99
|
+
if (response.ok) {
|
|
100
|
+
console.log('โ
Profile retrieved successfully!');
|
|
101
|
+
console.log('๐ง Email:', responseData?.email);
|
|
102
|
+
console.log('๐ข Organization ID:', responseData?.organizationId);
|
|
103
|
+
return responseData;
|
|
104
|
+
} else {
|
|
105
|
+
console.log('โ Profile fetch failed:', response.status, responseData?.message || 'Unknown error');
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.log('โ Error fetching profile:', error.message);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Run all tests
|
|
115
|
+
async function runTests() {
|
|
116
|
+
console.log('๐งช Running API connectivity tests...\n');
|
|
117
|
+
|
|
118
|
+
const isHealthy = await testAPIHealth();
|
|
119
|
+
if (!isHealthy) {
|
|
120
|
+
console.log('\nโ API is not running. Please start the medical-assistant-api on localhost:3000');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const credentials = await testCreateUser();
|
|
125
|
+
if (!credentials) {
|
|
126
|
+
console.log('\nโ Cannot proceed without user credentials');
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const loginData = await testLogin(credentials);
|
|
131
|
+
if (!loginData) {
|
|
132
|
+
console.log('\nโ Cannot proceed without successful login');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const profile = await testAuthenticatedEndpoint(loginData.access_token);
|
|
137
|
+
if (!profile) {
|
|
138
|
+
console.log('\nโ Authentication is not working properly');
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
console.log('\n๐ Basic API tests passed!');
|
|
143
|
+
console.log('๐ก The API is ready for SDK testing');
|
|
144
|
+
console.log('\n๐ Test Summary:');
|
|
145
|
+
console.log(' โ
API is running on localhost:3000');
|
|
146
|
+
console.log(' โ
User creation/login flow works');
|
|
147
|
+
console.log(' โ
Authentication is working');
|
|
148
|
+
console.log(' โ
Protected endpoints are accessible');
|
|
149
|
+
|
|
150
|
+
console.log('\n๐ง You can now use these credentials with the SDK:');
|
|
151
|
+
console.log(' ๐ง Email:', credentials.email);
|
|
152
|
+
console.log(' ๐ Password:', credentials.password);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
runTests().catch(console.error);
|
package/src/sdk/index.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { ApiSDK } from "./sdk";
|
|
1
|
+
export { ApiSDK } from "./sdk";
|
|
2
|
+
export * from "./types";
|