whio-api-sdk 1.0.172 โ†’ 1.0.174

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.
@@ -39,7 +39,7 @@ export declare class ApiSDK {
39
39
  getTemplates(): Promise<Template[]>;
40
40
  getTemplatesByOrganization(): Promise<Template[]>;
41
41
  getUserTemplates(): Promise<UserTemplate[]>;
42
- generateTranscriptionSummary(transcript: string, templateId: string): Promise<TranscriptionSummary>;
42
+ generateTranscriptionSummary(transcript: string, templateId: string, sessionId: string): Promise<TranscriptionSummary>;
43
43
  getByOrganizationTranscriptionSummaries(organizationId: string): Promise<TranscriptionSummary[]>;
44
44
  generateTranscriptionSummaryFromUserTemplate(transcript: string, userTemplateId: string): Promise<TranscriptionSummary>;
45
45
  updateTranscriptionSummary(id: string, content: string): Promise<TranscriptionSummary>;
@@ -89,7 +89,6 @@ export declare class ApiSDK {
89
89
  updateSession(id: string, sessionData: UpdateSessionDto): Promise<Session>;
90
90
  deleteSession(id: string): Promise<void>;
91
91
  setPrimaryTranscriptionSummary(sessionId: string, summaryId: string): Promise<Session>;
92
- getPapareoTranscriptionStatus(sessionId: string): Promise<Session>;
93
92
  createAgent(name: string): Promise<Agent>;
94
93
  getAgents(): Promise<Agent[]>;
95
94
  getAgent(id: string): Promise<Agent>;
@@ -132,7 +132,12 @@ export class ApiSDK {
132
132
  }
133
133
  logout() {
134
134
  return __awaiter(this, void 0, void 0, function* () {
135
- yield this.clearAuth();
135
+ try {
136
+ yield this.request('/auth/logout', 'POST');
137
+ }
138
+ finally {
139
+ yield this.clearAuth();
140
+ }
136
141
  });
137
142
  }
138
143
  clearAuth() {
@@ -361,13 +366,14 @@ export class ApiSDK {
361
366
  // ======================
362
367
  // trANSCRIPTION SUMMARY METHODS
363
368
  // ======================
364
- generateTranscriptionSummary(transcript, templateId) {
369
+ generateTranscriptionSummary(transcript, templateId, sessionId) {
365
370
  return __awaiter(this, void 0, void 0, function* () {
366
371
  const generateSummaryDto = {
367
372
  transcript,
368
373
  templateId,
369
374
  userId: this.user.id,
370
375
  fromUserTemplate: false,
376
+ sessionId: sessionId,
371
377
  };
372
378
  const transcriptionSummary = yield this.request(urls.transcriptionSummary, 'POST', generateSummaryDto);
373
379
  return transcriptionSummary;
@@ -678,11 +684,6 @@ export class ApiSDK {
678
684
  return this.request(`${urls.sessions}/${sessionId}/primary-summary/${summaryId}`, 'PATCH');
679
685
  });
680
686
  }
681
- getPapareoTranscriptionStatus(sessionId) {
682
- return __awaiter(this, void 0, void 0, function* () {
683
- return this.request(`${urls.getPapareoTranscriptionStatus}/${sessionId}`, 'GET');
684
- });
685
- }
686
687
  // ======================
687
688
  // AGENT METHODS
688
689
  // ======================
@@ -97,6 +97,7 @@ export interface GenerateTranscriptionSummaryDto {
97
97
  templateId: string;
98
98
  userId?: string;
99
99
  fromUserTemplate?: boolean;
100
+ sessionId?: string;
100
101
  }
101
102
  export interface UpdateTranscriptionSummaryDto {
102
103
  anonymisedTranscript?: string;
@@ -277,21 +278,20 @@ export interface Session {
277
278
  sessionName?: string;
278
279
  createdAt: string;
279
280
  updatedAt: string;
280
- templateId?: string;
281
+ templateId: string;
281
282
  userId: string;
282
283
  primaryTranscriptionSummaryId?: string;
283
284
  user?: User;
284
285
  template?: Template;
285
286
  transcriptionSummaries?: TranscriptionSummary[];
286
287
  primaryTranscriptionSummary?: TranscriptionSummary;
287
- audioFiles?: AudioFile[];
288
288
  }
289
289
  export interface CreateSessionDto {
290
290
  transcript: string;
291
291
  dateTime: string;
292
292
  startDateTime?: string;
293
293
  stopDateTime?: string;
294
- templateId?: string;
294
+ templateId: string;
295
295
  templateName?: string;
296
296
  summary?: string;
297
297
  sessionName?: string;
@@ -344,12 +344,6 @@ export interface AudioFile {
344
344
  uploadId?: string;
345
345
  transcriptionUrl?: string;
346
346
  status: AudioFileStatus;
347
- taskId?: string;
348
- uploadStatus?: string;
349
- statusLink?: string;
350
- cancelLink?: string;
351
- downloadLink?: string;
352
- progressPercent?: number;
353
347
  createdAt: string;
354
348
  updatedAt: string;
355
349
  sessionId: string;
@@ -369,20 +363,4 @@ export interface CreateAudioFileDto {
369
363
  export interface UpdateAudioFileDto {
370
364
  transcriptionUrl?: string;
371
365
  status?: AudioFileStatus;
372
- taskId?: string;
373
- uploadStatus?: string;
374
- statusLink?: string;
375
- cancelLink?: string;
376
- downloadLink?: string;
377
- progressPercent?: number;
378
- }
379
- export interface UploadedFileData {
380
- task_id: string;
381
- status: string;
382
- links: {
383
- status: string;
384
- cancel: string;
385
- download: string;
386
- };
387
- progress_percent: number;
388
366
  }
@@ -25,7 +25,6 @@ declare const urls: {
25
25
  roles: string;
26
26
  userRoles: string;
27
27
  sessions: string;
28
- getPapareoTranscriptionStatus: string;
29
28
  agents: string;
30
29
  audioFiles: string;
31
30
  };
@@ -33,7 +33,6 @@ const urls = {
33
33
  userRoles: '/user-roles',
34
34
  // Sessions
35
35
  sessions: '/sessions',
36
- getPapareoTranscriptionStatus: '/sessions/get-papareo-server-transcription-status',
37
36
  // Agents
38
37
  agents: '/agents',
39
38
  // Audio Files
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whio-api-sdk",
3
- "version": "1.0.172",
3
+ "version": "1.0.174",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
package/src/sdk/sdk.ts CHANGED
@@ -44,7 +44,6 @@ import {
44
44
  AudioFileStatus,
45
45
  CreateAudioFileDto,
46
46
  UpdateAudioFileDto,
47
- UploadedFileData,
48
47
  } from './types';
49
48
  import urls from './urls';
50
49
  import { jwtDecode } from 'jwt-decode';
@@ -200,7 +199,11 @@ export class ApiSDK {
200
199
  }
201
200
 
202
201
  public async logout(): Promise<void> {
203
- await this.clearAuth();
202
+ try {
203
+ await this.request('/auth/logout', 'POST');
204
+ } finally {
205
+ await this.clearAuth();
206
+ }
204
207
  }
205
208
 
206
209
  private async clearAuth(): Promise<void> {
@@ -451,12 +454,13 @@ export class ApiSDK {
451
454
  // ======================
452
455
 
453
456
  public async generateTranscriptionSummary(
454
- transcript: string, templateId: string): Promise<TranscriptionSummary> {
457
+ transcript: string, templateId: string, sessionId: string): Promise<TranscriptionSummary> {
455
458
  const generateSummaryDto: GenerateTranscriptionSummaryDto = {
456
459
  transcript,
457
460
  templateId,
458
461
  userId: this.user!.id,
459
462
  fromUserTemplate: false,
463
+ sessionId: sessionId,
460
464
  };
461
465
  const transcriptionSummary:TranscriptionSummary = await this.request(
462
466
  urls.transcriptionSummary,
@@ -755,10 +759,6 @@ export class ApiSDK {
755
759
  return this.request<Session>(`${urls.sessions}/${sessionId}/primary-summary/${summaryId}`, 'PATCH');
756
760
  }
757
761
 
758
- public async getPapareoTranscriptionStatus(sessionId: string): Promise<Session> {
759
- return this.request<Session>(`${urls.getPapareoTranscriptionStatus}/${sessionId}`, 'GET');
760
- }
761
-
762
762
  // ======================
763
763
  // AGENT METHODS
764
764
  // ======================
package/src/sdk/types.ts CHANGED
@@ -129,6 +129,7 @@ export interface GenerateTranscriptionSummaryDto {
129
129
  templateId: string;
130
130
  userId?: string;
131
131
  fromUserTemplate?: boolean;
132
+ sessionId?: string; // Optional session ID for linking to a session
132
133
  }
133
134
 
134
135
  // Transcription summary update DTO
@@ -352,7 +353,7 @@ export interface Session {
352
353
  sessionName?: string;
353
354
  createdAt: string;
354
355
  updatedAt: string;
355
- templateId?: string;
356
+ templateId: string;
356
357
  userId: string;
357
358
  primaryTranscriptionSummaryId?: string;
358
359
 
@@ -361,7 +362,6 @@ export interface Session {
361
362
  template?: Template;
362
363
  transcriptionSummaries?: TranscriptionSummary[];
363
364
  primaryTranscriptionSummary?: TranscriptionSummary;
364
- audioFiles?: AudioFile[];
365
365
  }
366
366
 
367
367
  // Session DTOs
@@ -370,7 +370,7 @@ export interface CreateSessionDto {
370
370
  dateTime: string;
371
371
  startDateTime?: string;
372
372
  stopDateTime?: string;
373
- templateId?: string;
373
+ templateId: string;
374
374
  templateName?: string;
375
375
  summary?: string;
376
376
  sessionName?: string;
@@ -435,12 +435,6 @@ export interface AudioFile {
435
435
  uploadId?: string;
436
436
  transcriptionUrl?: string;
437
437
  status: AudioFileStatus;
438
- taskId?: string;
439
- uploadStatus?: string;
440
- statusLink?: string;
441
- cancelLink?: string;
442
- downloadLink?: string;
443
- progressPercent?: number;
444
438
  createdAt: string;
445
439
  updatedAt: string;
446
440
  sessionId: string;
@@ -466,22 +460,4 @@ export interface CreateAudioFileDto {
466
460
  export interface UpdateAudioFileDto {
467
461
  transcriptionUrl?: string;
468
462
  status?: AudioFileStatus;
469
- taskId?: string;
470
- uploadStatus?: string;
471
- statusLink?: string;
472
- cancelLink?: string;
473
- downloadLink?: string;
474
- progressPercent?: number;
475
- }
476
-
477
- // UploadedFileData interface for the upload response
478
- export interface UploadedFileData {
479
- task_id: string;
480
- status: string;
481
- links: {
482
- status: string;
483
- cancel: string;
484
- download: string;
485
- };
486
- progress_percent: number;
487
463
  }
package/src/sdk/urls.ts CHANGED
@@ -40,7 +40,6 @@ const urls = {
40
40
 
41
41
  // Sessions
42
42
  sessions: '/sessions',
43
- getPapareoTranscriptionStatus: '/sessions/get-papareo-server-transcription-status',
44
43
 
45
44
  // Agents
46
45
  agents: '/agents',
package/quick-test.mjs DELETED
@@ -1,155 +0,0 @@
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);
@@ -1,92 +0,0 @@
1
- // Test audio files functionality
2
- import { ApiSDK, AudioFileStatus } from './dist/index.js';
3
-
4
- const sdk = new ApiSDK({
5
- baseUrl: 'http://localhost:3000/api'
6
- });
7
-
8
- async function testAudioFiles() {
9
- try {
10
- // Login
11
- const loginResponse = await sdk.login({
12
- email: 'rimu.boddy@make.nz',
13
- password: 'cbr400rr'
14
- });
15
- console.log('โœ… Login successful');
16
-
17
- // Get user sessions to find a session for audio upload
18
- const sessions = await sdk.getSessions();
19
- if (sessions.length === 0) {
20
- console.log('โŒ No sessions found. Create a session first.');
21
- return;
22
- }
23
- const sessionId = sessions[0].id;
24
- console.log('โœ… Found session:', sessionId);
25
-
26
- // Create a mock audio file (small MP3-like buffer)
27
- const mockAudioData = new Uint8Array([
28
- // Minimal MP3 header
29
- 0x49, 0x44, 0x33, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
30
- // Some fake MP3 data
31
- 0x54, 0x58, 0x58, 0x58, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00,
32
- 0x03, 0x74, 0x65, 0x73, 0x74, 0x20, 0x61, 0x75, 0x64, 0x69,
33
- 0x6F, 0x20, 0x64, 0x61, 0x74, 0x61
34
- ]);
35
-
36
- const audioBlob = new Blob([mockAudioData], { type: 'audio/mpeg' });
37
-
38
- // Test upload audio file
39
- console.log('๐Ÿ”„ Testing audio file upload...');
40
- const uploadedFile = await sdk.uploadAudioFileToSession(sessionId, audioBlob, 'test-audio.mp3');
41
- console.log('โœ… Audio file uploaded:', uploadedFile.id);
42
- console.log(' - Original name:', uploadedFile.originalName);
43
- console.log(' - Status:', uploadedFile.status);
44
- console.log(' - File size:', uploadedFile.fileSize, 'bytes');
45
-
46
- // Test get my audio files
47
- console.log('๐Ÿ”„ Testing get my audio files...');
48
- const myFiles = await sdk.getMyAudioFiles();
49
- console.log('โœ… Found', myFiles.length, 'audio files');
50
-
51
- // Test get audio file details
52
- console.log('๐Ÿ”„ Testing get audio file details...');
53
- const fileDetails = await sdk.getAudioFile(uploadedFile.id);
54
- console.log('โœ… Audio file details:', fileDetails.originalName);
55
-
56
- // Test get audio files by session
57
- console.log('๐Ÿ”„ Testing get audio files by session...');
58
- const sessionFiles = await sdk.getAudioFilesBySession(sessionId);
59
- console.log('โœ… Found', sessionFiles.length, 'audio files for session');
60
-
61
- // Test update audio file
62
- console.log('๐Ÿ”„ Testing update audio file...');
63
- const updatedFile = await sdk.updateAudioFile(uploadedFile.id, {
64
- status: AudioFileStatus.TRANSCRIBED,
65
- transcriptionUrl: 'https://example.com/transcription'
66
- });
67
- console.log('โœ… Audio file updated. New status:', updatedFile.status);
68
-
69
- // Test download audio file
70
- console.log('๐Ÿ”„ Testing download audio file...');
71
- const downloadedBlob = await sdk.downloadAudioFile(uploadedFile.id);
72
- console.log('โœ… Audio file downloaded. Size:', downloadedBlob.size, 'bytes');
73
-
74
- // Test download as URL
75
- console.log('๐Ÿ”„ Testing download as URL...');
76
- const downloadUrl = await sdk.downloadAudioFileAsUrl(uploadedFile.id);
77
- console.log('โœ… Audio file URL created:', downloadUrl.substring(0, 50) + '...');
78
-
79
- // Clean up - delete the test file
80
- console.log('๐Ÿ”„ Cleaning up - deleting test file...');
81
- await sdk.deleteAudioFile(uploadedFile.id);
82
- console.log('โœ… Test file deleted');
83
-
84
- console.log('\n๐ŸŽ‰ All audio file SDK tests passed!');
85
-
86
- } catch (error) {
87
- console.error('โŒ Test failed:', error.message);
88
- console.error('Error details:', error);
89
- }
90
- }
91
-
92
- testAudioFiles();