whio-api-sdk 1.0.155 → 1.0.157
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 +41 -5
- package/dist/src/sdk/sdk.js +238 -9
- package/dist/src/sdk/types.d.ts +44 -2
- package/dist/src/sdk/types.js +8 -0
- package/dist/src/sdk/urls.d.ts +10 -5
- package/dist/src/sdk/urls.js +17 -5
- package/package.json +3 -2
- package/quick-test.mjs +155 -0
- package/src/sdk/index.ts +2 -1
- package/src/sdk/sdk.ts +233 -16
- package/src/sdk/types.ts +60 -7
- package/src/sdk/urls.ts +23 -5
- package/test-comprehensive.mjs +276 -0
- package/test-password-change.ts +34 -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/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";
|
package/src/sdk/sdk.ts
CHANGED
|
@@ -11,12 +11,19 @@ import {
|
|
|
11
11
|
UpdateTemplateDto,
|
|
12
12
|
GenerateTranscriptionSummaryDto,
|
|
13
13
|
UpdateTranscriptionSummaryDto,
|
|
14
|
+
CreateTranscriptionSummaryDto,
|
|
14
15
|
AssignOrganizationRoleDto,
|
|
15
16
|
CreateUserTemplateDto,
|
|
16
17
|
UpdateUserTemplateDto,
|
|
17
18
|
CreateUserDto,
|
|
18
19
|
UpdateUserDto,
|
|
20
|
+
CreateOrganizationDto,
|
|
21
|
+
UpdateOrganizationDto,
|
|
22
|
+
CreateTemplateCategoryDto,
|
|
23
|
+
UpdateTemplateCategoryDto,
|
|
24
|
+
AssignTeamTemplateDto,
|
|
19
25
|
OrganizationRoleType,
|
|
26
|
+
RoleType,
|
|
20
27
|
Organization,
|
|
21
28
|
TemplateCategory,
|
|
22
29
|
Template,
|
|
@@ -24,6 +31,9 @@ import {
|
|
|
24
31
|
UserTemplate,
|
|
25
32
|
TranscriptionSummary,
|
|
26
33
|
TranscriptionAudioUploadResponse,
|
|
34
|
+
ChangePasswordDto,
|
|
35
|
+
AdminChangePasswordDto,
|
|
36
|
+
PasswordChangeResponse,
|
|
27
37
|
} from './types';
|
|
28
38
|
import urls from './urls';
|
|
29
39
|
import jwtDecode from 'jwt-decode';
|
|
@@ -117,7 +127,6 @@ export class ApiSDK {
|
|
|
117
127
|
): Promise<T> {
|
|
118
128
|
const url = `${this.baseUrl}${endpoint}`;
|
|
119
129
|
const defaultHeaders: Record<string, string> = {
|
|
120
|
-
'Content-Type': 'multipart/form-data',
|
|
121
130
|
'ngrok-skip-browser-warning': 'true'
|
|
122
131
|
};
|
|
123
132
|
|
|
@@ -125,6 +134,7 @@ export class ApiSDK {
|
|
|
125
134
|
defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
|
|
126
135
|
}
|
|
127
136
|
|
|
137
|
+
// Don't set Content-Type for FormData - let browser set it with boundary
|
|
128
138
|
const response = await fetch(url, {
|
|
129
139
|
method: 'POST',
|
|
130
140
|
headers: { ...defaultHeaders, ...headers },
|
|
@@ -151,7 +161,7 @@ export class ApiSDK {
|
|
|
151
161
|
true
|
|
152
162
|
);
|
|
153
163
|
this.accessToken = response.access_token;
|
|
154
|
-
this.refreshToken = response.
|
|
164
|
+
this.refreshToken = response.refresh_token;
|
|
155
165
|
|
|
156
166
|
this.user = response.user;
|
|
157
167
|
|
|
@@ -277,12 +287,12 @@ export class ApiSDK {
|
|
|
277
287
|
return this.request(urls.teams, 'POST', teamDto);
|
|
278
288
|
}
|
|
279
289
|
|
|
280
|
-
public async updateTeam(id: string, name: string, description: string): Promise<
|
|
290
|
+
public async updateTeam(id: string, name: string, description: string): Promise<Team> {
|
|
281
291
|
const teamDto: UpdateTeamDto = {
|
|
282
292
|
name,
|
|
283
293
|
description,
|
|
284
294
|
};
|
|
285
|
-
return this.request(`${urls.teams}/${id}`, '
|
|
295
|
+
return this.request<Team>(`${urls.teams}/${id}`, 'PATCH', teamDto);
|
|
286
296
|
}
|
|
287
297
|
|
|
288
298
|
public async addUserToTeam(teamId: string, userId: string, roleName: string): Promise<any> {
|
|
@@ -294,25 +304,31 @@ export class ApiSDK {
|
|
|
294
304
|
return this.request(urls.teamRoles, 'POST', assignRoleDto);
|
|
295
305
|
}
|
|
296
306
|
|
|
297
|
-
public async removeUserFromTeam(teamId: string, userId: string): Promise<
|
|
298
|
-
|
|
299
|
-
return this.request(urls.teamRoles, 'DELETE');
|
|
307
|
+
public async removeUserFromTeam(teamId: string, userId: string): Promise<void> {
|
|
308
|
+
await this.request(`${urls.teamRoles}/user/${userId}/team/${teamId}`, 'DELETE');
|
|
300
309
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
310
|
+
public async createTemplate(title: string, content: string, categoryId?: string): Promise<Template> {
|
|
311
|
+
let finalCategoryId = categoryId;
|
|
312
|
+
if (!finalCategoryId) {
|
|
313
|
+
const templateCategories = await this.request<TemplateCategory[]>(
|
|
314
|
+
urls.templateCategories,
|
|
315
|
+
'GET'
|
|
316
|
+
);
|
|
317
|
+
finalCategoryId = templateCategories[0]?.id;
|
|
318
|
+
if (!finalCategoryId) {
|
|
319
|
+
throw new Error('No template categories available. Please create one first.');
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
307
323
|
const createTemplateDto: CreateTemplateDto = {
|
|
308
324
|
title,
|
|
309
325
|
content,
|
|
310
326
|
isGlobal: false,
|
|
311
|
-
categoryId:
|
|
327
|
+
categoryId: finalCategoryId,
|
|
312
328
|
createdById: this.user!.id,
|
|
313
329
|
organizationId: this.user!.organizationId,
|
|
314
330
|
};
|
|
315
|
-
return this.request(urls.templates, 'POST', createTemplateDto);
|
|
331
|
+
return this.request<Template>(urls.templates, 'POST', createTemplateDto);
|
|
316
332
|
}
|
|
317
333
|
|
|
318
334
|
public async createUserTemplate(
|
|
@@ -363,6 +379,10 @@ export class ApiSDK {
|
|
|
363
379
|
return this.request<UserTemplate[]>(url, 'GET');
|
|
364
380
|
}
|
|
365
381
|
|
|
382
|
+
// ======================
|
|
383
|
+
// trANSCRIPTION SUMMARY METHODS
|
|
384
|
+
// ======================
|
|
385
|
+
|
|
366
386
|
public async generateTranscriptionSummary(
|
|
367
387
|
transcript: string, templateId: string): Promise<TranscriptionSummary> {
|
|
368
388
|
const generateSummaryDto: GenerateTranscriptionSummaryDto = {
|
|
@@ -379,6 +399,14 @@ export class ApiSDK {
|
|
|
379
399
|
return transcriptionSummary;
|
|
380
400
|
}
|
|
381
401
|
|
|
402
|
+
public async getByOrganizationTranscriptionSummaries(
|
|
403
|
+
organizationId: string): Promise<TranscriptionSummary[]> {
|
|
404
|
+
return this.request<TranscriptionSummary[]>(
|
|
405
|
+
`${urls.transcriptionSummaries}/organization/${organizationId}`,
|
|
406
|
+
'GET'
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
|
|
382
410
|
public async generateTranscriptionSummaryFromUserTemplate(
|
|
383
411
|
transcript: string, userTemplateId: string): Promise<TranscriptionSummary> {
|
|
384
412
|
const generateSummaryDto: GenerateTranscriptionSummaryDto = {
|
|
@@ -426,7 +454,7 @@ export class ApiSDK {
|
|
|
426
454
|
return data;
|
|
427
455
|
}
|
|
428
456
|
|
|
429
|
-
public async transcribeBase64Audio(base64String:
|
|
457
|
+
public async transcribeBase64Audio(base64String: string): Promise<string> {
|
|
430
458
|
const transcript = await this.request<any>(
|
|
431
459
|
urls.transcribeBase64Audio,
|
|
432
460
|
'POST',
|
|
@@ -434,4 +462,193 @@ export class ApiSDK {
|
|
|
434
462
|
return transcript.transcript;
|
|
435
463
|
}
|
|
436
464
|
|
|
465
|
+
// ======================
|
|
466
|
+
// AUTH METHODS
|
|
467
|
+
// ======================
|
|
468
|
+
|
|
469
|
+
public async getProfile(): Promise<User> {
|
|
470
|
+
return this.request<User>(urls.profile, 'GET');
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
public async changePassword(currentPassword: string, newPassword: string): Promise<PasswordChangeResponse> {
|
|
474
|
+
const dto: ChangePasswordDto = {
|
|
475
|
+
currentPassword,
|
|
476
|
+
newPassword,
|
|
477
|
+
};
|
|
478
|
+
return this.request<PasswordChangeResponse>(urls.changePassword, 'PATCH', dto);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
public async adminChangePassword(userId: string, newPassword: string): Promise<PasswordChangeResponse> {
|
|
482
|
+
const dto: AdminChangePasswordDto = {
|
|
483
|
+
userId,
|
|
484
|
+
newPassword,
|
|
485
|
+
};
|
|
486
|
+
return this.request<PasswordChangeResponse>(urls.adminChangePassword, 'PATCH', dto);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// ======================
|
|
490
|
+
// ORGANIZATION METHODS
|
|
491
|
+
// ======================
|
|
492
|
+
|
|
493
|
+
public async createOrganization(name: string, description?: string): Promise<Organization> {
|
|
494
|
+
const dto: CreateOrganizationDto = { name, description };
|
|
495
|
+
return this.request<Organization>(urls.organizations, 'POST', dto);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
public async getOrganizations(): Promise<Organization[]> {
|
|
499
|
+
return this.request<Organization[]>(urls.organizations, 'GET');
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
public async getOrganization(id: string): Promise<Organization> {
|
|
503
|
+
return this.request<Organization>(`${urls.organizations}/${id}`, 'GET');
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
public async updateOrganization(id: string, name?: string, description?: string): Promise<Organization> {
|
|
507
|
+
const dto: UpdateOrganizationDto = { name, description };
|
|
508
|
+
return this.request<Organization>(`${urls.organizations}/${id}`, 'PATCH', dto);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
public async deleteOrganization(id: string): Promise<void> {
|
|
512
|
+
await this.request(`${urls.organizations}/${id}`, 'DELETE');
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
public async addUserToOrganization(organizationId: string, userId: string): Promise<void> {
|
|
516
|
+
await this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'POST');
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
public async removeUserFromOrganization(organizationId: string, userId: string): Promise<void> {
|
|
520
|
+
await this.request(`${urls.organizations}/${organizationId}/users/${userId}`, 'DELETE');
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// ======================
|
|
524
|
+
// USER METHODS
|
|
525
|
+
// ======================
|
|
526
|
+
|
|
527
|
+
public async getUsers(): Promise<User[]> {
|
|
528
|
+
return this.request<User[]>(urls.users, 'GET');
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
public async getUser(id: string): Promise<User> {
|
|
532
|
+
return this.request<User>(`${urls.users}/${id}`, 'GET');
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
public async getUsersByOrganization(organizationId: string): Promise<User[]> {
|
|
536
|
+
return this.request<User[]>(`${urls.users}/organization/${organizationId}`, 'GET');
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
public async updateUser(id: string, data: UpdateUserDto): Promise<User> {
|
|
540
|
+
return this.request<User>(`${urls.users}/${id}`, 'PATCH', data);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
public async deleteUser(id: string): Promise<void> {
|
|
544
|
+
await this.request(`${urls.users}/${id}`, 'DELETE');
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// ======================
|
|
548
|
+
// TEAM METHODS
|
|
549
|
+
// ======================
|
|
550
|
+
|
|
551
|
+
public async getTeams(): Promise<Team[]> {
|
|
552
|
+
return this.request<Team[]>(urls.teams, 'GET');
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
public async getTeam(id: string): Promise<Team> {
|
|
556
|
+
return this.request<Team>(`${urls.teams}/${id}`, 'GET');
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
public async getTeamsByOrganization(organizationId: string): Promise<Team[]> {
|
|
560
|
+
return this.request<Team[]>(`${urls.teams}/organization/${organizationId}`, 'GET');
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
public async deleteTeam(id: string): Promise<void> {
|
|
564
|
+
await this.request(`${urls.teams}/${id}`, 'DELETE');
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// ======================
|
|
568
|
+
// TEMPLATE CATEGORY METHODS
|
|
569
|
+
// ======================
|
|
570
|
+
|
|
571
|
+
public async getTemplateCategories(): Promise<TemplateCategory[]> {
|
|
572
|
+
return this.request<TemplateCategory[]>(urls.templateCategories, 'GET');
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
public async getTemplateCategory(id: string): Promise<TemplateCategory> {
|
|
576
|
+
return this.request<TemplateCategory>(`${urls.templateCategories}/${id}`, 'GET');
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
public async createTemplateCategory(name: string): Promise<TemplateCategory> {
|
|
580
|
+
const dto: CreateTemplateCategoryDto = { name };
|
|
581
|
+
return this.request<TemplateCategory>(urls.templateCategories, 'POST', dto);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
public async updateTemplateCategory(id: string, name: string): Promise<TemplateCategory> {
|
|
585
|
+
const dto: UpdateTemplateCategoryDto = { name };
|
|
586
|
+
return this.request<TemplateCategory>(`${urls.templateCategories}/${id}`, 'PATCH', dto);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
public async deleteTemplateCategory(id: string): Promise<void> {
|
|
590
|
+
await this.request(`${urls.templateCategories}/${id}`, 'DELETE');
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// ======================
|
|
594
|
+
// ENHANCED TEMPLATE METHODS
|
|
595
|
+
// ======================
|
|
596
|
+
|
|
597
|
+
public async getTemplate(id: string): Promise<Template> {
|
|
598
|
+
return this.request<Template>(`${urls.templates}/${id}`, 'GET');
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
public async deleteTemplate(id: string): Promise<void> {
|
|
602
|
+
await this.request(`${urls.templates}/${id}`, 'DELETE');
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
public async getUserTemplate(id: string): Promise<UserTemplate> {
|
|
606
|
+
return this.request<UserTemplate>(`${urls.userTemplates}/${id}`, 'GET');
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
public async deleteUserTemplate(id: string): Promise<void> {
|
|
610
|
+
await this.request(`${urls.userTemplates}/${id}`, 'DELETE');
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// ======================
|
|
614
|
+
// TEAM TEMPLATE METHODS
|
|
615
|
+
// ======================
|
|
616
|
+
|
|
617
|
+
public async assignTemplateToTeam(teamId: string, templateId: string): Promise<void> {
|
|
618
|
+
const dto: AssignTeamTemplateDto = { teamId, templateId };
|
|
619
|
+
await this.request(urls.teamTemplates, 'POST', dto);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
public async removeTemplateFromTeam(teamId: string, templateId: string): Promise<void> {
|
|
623
|
+
await this.request(`${urls.teamTemplates}/team/${teamId}/template/${templateId}`, 'DELETE');
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// ======================
|
|
627
|
+
// TRANSCRIPTION SUMMARY METHODS
|
|
628
|
+
// ======================
|
|
629
|
+
|
|
630
|
+
public async getTranscriptionSummaries(): Promise<TranscriptionSummary[]> {
|
|
631
|
+
return this.request<TranscriptionSummary[]>(urls.transcriptionSummaries, 'GET');
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
public async getTranscriptionSummary(id: string): Promise<TranscriptionSummary> {
|
|
635
|
+
return this.request<TranscriptionSummary>(`${urls.transcriptionSummaries}/${id}`, 'GET');
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
public async getTranscriptionSummariesByUser(userId: string): Promise<TranscriptionSummary[]> {
|
|
639
|
+
return this.request<TranscriptionSummary[]>(`${urls.transcriptionSummaries}/user/${userId}`, 'GET');
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
public async deleteTranscriptionSummary(id: string): Promise<void> {
|
|
643
|
+
await this.request(`${urls.transcriptionSummaries}/${id}`, 'DELETE');
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// ======================
|
|
647
|
+
// ENHANCED TEAM ROLE METHODS
|
|
648
|
+
// ======================
|
|
649
|
+
|
|
650
|
+
public async removeUserFromTeamFixed(teamId: string, userId: string): Promise<void> {
|
|
651
|
+
await this.request(`${urls.teamRoles}/user/${userId}/team/${teamId}`, 'DELETE');
|
|
652
|
+
}
|
|
653
|
+
|
|
437
654
|
}
|
package/src/sdk/types.ts
CHANGED
|
@@ -62,7 +62,7 @@ export interface User {
|
|
|
62
62
|
// Login response type
|
|
63
63
|
export interface LoginResponse {
|
|
64
64
|
access_token: string;
|
|
65
|
-
|
|
65
|
+
refresh_token: string;
|
|
66
66
|
user: User;
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -276,12 +276,65 @@ export interface Team {
|
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
export interface TranscriptionAudioUploadResponse {
|
|
279
|
-
success:
|
|
280
|
-
transcription: string
|
|
281
|
-
model_version: string
|
|
282
|
-
metadata: any[]
|
|
283
|
-
duration: number
|
|
284
|
-
log: string
|
|
279
|
+
success: boolean;
|
|
280
|
+
transcription: string;
|
|
281
|
+
model_version: string;
|
|
282
|
+
metadata: any[];
|
|
283
|
+
duration: number;
|
|
284
|
+
log: string;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
+
// Additional DTOs for missing functionality
|
|
288
|
+
export interface CreateOrganizationDto {
|
|
289
|
+
name: string;
|
|
290
|
+
description?: string;
|
|
291
|
+
}
|
|
287
292
|
|
|
293
|
+
export interface UpdateOrganizationDto {
|
|
294
|
+
name?: string;
|
|
295
|
+
description?: string;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface CreateTemplateCategoryDto {
|
|
299
|
+
name: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface UpdateTemplateCategoryDto {
|
|
303
|
+
name?: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface CreateTranscriptionSummaryDto {
|
|
307
|
+
userId: string;
|
|
308
|
+
templateId: string;
|
|
309
|
+
content: string;
|
|
310
|
+
anonymisedTranscript?: string;
|
|
311
|
+
metadata?: Record<string, any>;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export interface AssignTeamTemplateDto {
|
|
315
|
+
teamId: string;
|
|
316
|
+
templateId: string;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// Enum for global role types to match API
|
|
320
|
+
export enum RoleType {
|
|
321
|
+
SUPERUSER = 'SUPERUSER',
|
|
322
|
+
ADMIN = 'ADMIN',
|
|
323
|
+
TRIAL = 'TRIAL',
|
|
324
|
+
PAID = 'PAID',
|
|
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
|
@@ -1,24 +1,42 @@
|
|
|
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
|
+
changePassword: '/auth/change-password',
|
|
9
|
+
adminChangePassword: '/auth/admin/change-password',
|
|
10
|
+
|
|
11
|
+
// Users
|
|
6
12
|
user: '/users',
|
|
7
13
|
users: '/users',
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
|
|
15
|
+
// Organizations
|
|
10
16
|
organizations: '/organizations',
|
|
11
17
|
organizationRoles: '/organization-roles',
|
|
12
|
-
|
|
18
|
+
userOrganizationRoles: '/user-organization-roles',
|
|
19
|
+
|
|
20
|
+
// Teams
|
|
21
|
+
teams: '/teams',
|
|
13
22
|
teamRoles: '/team-roles',
|
|
23
|
+
teamTemplates: '/team-templates',
|
|
24
|
+
|
|
25
|
+
// Templates
|
|
14
26
|
templates: '/templates',
|
|
15
|
-
|
|
27
|
+
templateCategories: '/template-categories',
|
|
16
28
|
userTemplates: '/user-templates',
|
|
17
|
-
|
|
29
|
+
|
|
30
|
+
// Transcription Summaries
|
|
31
|
+
transcriptionSummaries: '/transcription-summaries',
|
|
18
32
|
transcriptionSummary: '/transcription-summaries/generate',
|
|
19
33
|
uploadAudioLarge: '/transcription-summaries/upload-audio-large',
|
|
20
34
|
uploadAudio: '/transcription-summaries/upload-audio',
|
|
21
35
|
transcribeBase64Audio: '/transcription-summaries/transcribe-base64',
|
|
36
|
+
|
|
37
|
+
// Roles
|
|
38
|
+
roles: '/roles',
|
|
39
|
+
userRoles: '/user-roles',
|
|
22
40
|
}
|
|
23
41
|
|
|
24
42
|
export default urls;
|