whio-api-sdk 1.0.168 → 1.0.170

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.
@@ -1,4 +1,4 @@
1
- import { LoginResponse, LoginCredentials, SDKConfig, User, UpdateUserDto, Organization, TemplateCategory, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse, PasswordChangeResponse, Session, CreateSessionDto, UpdateSessionDto, Agent } from './types';
1
+ import { LoginResponse, LoginCredentials, SDKConfig, User, UpdateUserDto, Organization, TemplateCategory, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse, PasswordChangeResponse, Session, CreateSessionDto, UpdateSessionDto, Agent, AudioFile, UpdateAudioFileDto } from './types';
2
2
  export declare class ApiSDK {
3
3
  private baseUrl;
4
4
  private storage;
@@ -89,6 +89,7 @@ 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>;
92
93
  createAgent(name: string): Promise<Agent>;
93
94
  getAgents(): Promise<Agent[]>;
94
95
  getAgent(id: string): Promise<Agent>;
@@ -96,4 +97,14 @@ export declare class ApiSDK {
96
97
  deleteAgent(id: string): Promise<void>;
97
98
  addAgentToOrganization(agentId: string, organizationId: string): Promise<void>;
98
99
  removeAgentFromOrganization(agentId: string, organizationId: string): Promise<void>;
100
+ uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string): Promise<AudioFile>;
101
+ getMyAudioFiles(): Promise<AudioFile[]>;
102
+ getAllAudioFiles(): Promise<AudioFile[]>;
103
+ getOrganizationAudioFiles(): Promise<AudioFile[]>;
104
+ getAudioFilesBySession(sessionId: string): Promise<AudioFile[]>;
105
+ getAudioFile(id: string): Promise<AudioFile>;
106
+ updateAudioFile(id: string, updates: UpdateAudioFileDto): Promise<AudioFile>;
107
+ deleteAudioFile(id: string): Promise<void>;
108
+ downloadAudioFile(id: string): Promise<Blob>;
109
+ downloadAudioFileAsUrl(id: string): Promise<string>;
99
110
  }
@@ -678,6 +678,11 @@ export class ApiSDK {
678
678
  return this.request(`${urls.sessions}/${sessionId}/primary-summary/${summaryId}`, 'PATCH');
679
679
  });
680
680
  }
681
+ getPapareoTranscriptionStatus(sessionId) {
682
+ return __awaiter(this, void 0, void 0, function* () {
683
+ return this.request(`${urls.getPapareoTranscriptionStatus}/${sessionId}`, 'GET');
684
+ });
685
+ }
681
686
  // ======================
682
687
  // AGENT METHODS
683
688
  // ======================
@@ -718,4 +723,78 @@ export class ApiSDK {
718
723
  yield this.request(`${urls.agents}/${agentId}/organizations/${organizationId}`, 'DELETE');
719
724
  });
720
725
  }
726
+ // ======================
727
+ // AUDIO FILE METHODS
728
+ // ======================
729
+ uploadAudioFileToSession(sessionId, file, fileName) {
730
+ return __awaiter(this, void 0, void 0, function* () {
731
+ const formData = new FormData();
732
+ formData.append('file', file, fileName);
733
+ return this.fileUploadRequest(`${urls.audioFiles}/upload/${sessionId}`, formData);
734
+ });
735
+ }
736
+ getMyAudioFiles() {
737
+ return __awaiter(this, void 0, void 0, function* () {
738
+ return this.request(`${urls.audioFiles}/my-files`, 'GET');
739
+ });
740
+ }
741
+ getAllAudioFiles() {
742
+ return __awaiter(this, void 0, void 0, function* () {
743
+ return this.request(`${urls.audioFiles}/all`, 'GET');
744
+ });
745
+ }
746
+ getOrganizationAudioFiles() {
747
+ return __awaiter(this, void 0, void 0, function* () {
748
+ return this.request(`${urls.audioFiles}/organization`, 'GET');
749
+ });
750
+ }
751
+ getAudioFilesBySession(sessionId) {
752
+ return __awaiter(this, void 0, void 0, function* () {
753
+ return this.request(`${urls.audioFiles}/session/${sessionId}`, 'GET');
754
+ });
755
+ }
756
+ getAudioFile(id) {
757
+ return __awaiter(this, void 0, void 0, function* () {
758
+ return this.request(`${urls.audioFiles}/${id}`, 'GET');
759
+ });
760
+ }
761
+ updateAudioFile(id, updates) {
762
+ return __awaiter(this, void 0, void 0, function* () {
763
+ return this.request(`${urls.audioFiles}/${id}`, 'PATCH', updates);
764
+ });
765
+ }
766
+ deleteAudioFile(id) {
767
+ return __awaiter(this, void 0, void 0, function* () {
768
+ yield this.request(`${urls.audioFiles}/${id}`, 'DELETE');
769
+ });
770
+ }
771
+ downloadAudioFile(id) {
772
+ return __awaiter(this, void 0, void 0, function* () {
773
+ // For file downloads, we need a different approach than JSON requests
774
+ const url = `${this.baseUrl}${urls.audioFiles}/${id}/download`;
775
+ // Get token first
776
+ yield this.getToken();
777
+ const defaultHeaders = {
778
+ 'ngrok-skip-browser-warning': 'true'
779
+ };
780
+ if (this.accessToken) {
781
+ defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
782
+ }
783
+ const response = yield fetch(url, {
784
+ method: 'GET',
785
+ headers: defaultHeaders,
786
+ });
787
+ if (!response.ok) {
788
+ const errorData = yield response.json().catch(() => ({}));
789
+ throw new Error(errorData.message || `Download failed with status ${response.status}`);
790
+ }
791
+ return response.blob();
792
+ });
793
+ }
794
+ downloadAudioFileAsUrl(id) {
795
+ return __awaiter(this, void 0, void 0, function* () {
796
+ const blob = yield this.downloadAudioFile(id);
797
+ return URL.createObjectURL(blob);
798
+ });
799
+ }
721
800
  }
@@ -327,3 +327,61 @@ export interface CreateAgentDto {
327
327
  export interface UpdateAgentDto {
328
328
  name?: string;
329
329
  }
330
+ export declare enum AudioFileStatus {
331
+ UPLOADED = "UPLOADED",
332
+ PROCESSING = "PROCESSING",
333
+ TRANSCRIBED = "TRANSCRIBED",
334
+ FAILED = "FAILED"
335
+ }
336
+ export interface AudioFile {
337
+ id: string;
338
+ originalName: string;
339
+ fileName: string;
340
+ filePath: string;
341
+ fileSize: number;
342
+ mimeType: string;
343
+ uploadId?: string;
344
+ transcriptionUrl?: string;
345
+ status: AudioFileStatus;
346
+ taskId?: string;
347
+ uploadStatus?: string;
348
+ statusLink?: string;
349
+ cancelLink?: string;
350
+ downloadLink?: string;
351
+ progressPercent?: number;
352
+ createdAt: string;
353
+ updatedAt: string;
354
+ sessionId: string;
355
+ userId: string;
356
+ session?: Session;
357
+ user?: User;
358
+ }
359
+ export interface CreateAudioFileDto {
360
+ originalName: string;
361
+ fileName: string;
362
+ filePath: string;
363
+ fileSize: number;
364
+ mimeType: string;
365
+ uploadId?: string;
366
+ sessionId: string;
367
+ }
368
+ export interface UpdateAudioFileDto {
369
+ transcriptionUrl?: string;
370
+ status?: AudioFileStatus;
371
+ taskId?: string;
372
+ uploadStatus?: string;
373
+ statusLink?: string;
374
+ cancelLink?: string;
375
+ downloadLink?: string;
376
+ progressPercent?: number;
377
+ }
378
+ export interface UploadedFileData {
379
+ task_id: string;
380
+ status: string;
381
+ links: {
382
+ status: string;
383
+ cancel: string;
384
+ download: string;
385
+ };
386
+ progress_percent: number;
387
+ }
@@ -13,3 +13,11 @@ export var RoleType;
13
13
  RoleType["TRIAL"] = "TRIAL";
14
14
  RoleType["PAID"] = "PAID";
15
15
  })(RoleType || (RoleType = {}));
16
+ // Audio File types
17
+ export var AudioFileStatus;
18
+ (function (AudioFileStatus) {
19
+ AudioFileStatus["UPLOADED"] = "UPLOADED";
20
+ AudioFileStatus["PROCESSING"] = "PROCESSING";
21
+ AudioFileStatus["TRANSCRIBED"] = "TRANSCRIBED";
22
+ AudioFileStatus["FAILED"] = "FAILED";
23
+ })(AudioFileStatus || (AudioFileStatus = {}));
@@ -25,6 +25,8 @@ declare const urls: {
25
25
  roles: string;
26
26
  userRoles: string;
27
27
  sessions: string;
28
+ getPapareoTranscriptionStatus: string;
28
29
  agents: string;
30
+ audioFiles: string;
29
31
  };
30
32
  export default urls;
@@ -33,7 +33,10 @@ const urls = {
33
33
  userRoles: '/user-roles',
34
34
  // Sessions
35
35
  sessions: '/sessions',
36
+ getPapareoTranscriptionStatus: '/sessions/get-papareo-server-transcription-status',
36
37
  // Agents
37
38
  agents: '/agents',
39
+ // Audio Files
40
+ audioFiles: '/audio-files',
38
41
  };
39
42
  export default urls;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whio-api-sdk",
3
- "version": "1.0.168",
3
+ "version": "1.0.170",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
package/src/sdk/sdk.ts CHANGED
@@ -40,6 +40,11 @@ import {
40
40
  Agent,
41
41
  CreateAgentDto,
42
42
  UpdateAgentDto,
43
+ AudioFile,
44
+ AudioFileStatus,
45
+ CreateAudioFileDto,
46
+ UpdateAudioFileDto,
47
+ UploadedFileData,
43
48
  } from './types';
44
49
  import urls from './urls';
45
50
  import { jwtDecode } from 'jwt-decode';
@@ -750,6 +755,10 @@ export class ApiSDK {
750
755
  return this.request<Session>(`${urls.sessions}/${sessionId}/primary-summary/${summaryId}`, 'PATCH');
751
756
  }
752
757
 
758
+ public async getPapareoTranscriptionStatus(sessionId: string): Promise<Session> {
759
+ return this.request<Session>(`${urls.getPapareoTranscriptionStatus}/${sessionId}`, 'GET');
760
+ }
761
+
753
762
  // ======================
754
763
  // AGENT METHODS
755
764
  // ======================
@@ -784,4 +793,78 @@ export class ApiSDK {
784
793
  await this.request(`${urls.agents}/${agentId}/organizations/${organizationId}`, 'DELETE');
785
794
  }
786
795
 
796
+ // ======================
797
+ // AUDIO FILE METHODS
798
+ // ======================
799
+
800
+ public async uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string): Promise<AudioFile> {
801
+ const formData = new FormData();
802
+ formData.append('file', file, fileName);
803
+
804
+ return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData);
805
+ }
806
+
807
+ public async getMyAudioFiles(): Promise<AudioFile[]> {
808
+ return this.request<AudioFile[]>(`${urls.audioFiles}/my-files`, 'GET');
809
+ }
810
+
811
+ public async getAllAudioFiles(): Promise<AudioFile[]> {
812
+ return this.request<AudioFile[]>(`${urls.audioFiles}/all`, 'GET');
813
+ }
814
+
815
+ public async getOrganizationAudioFiles(): Promise<AudioFile[]> {
816
+ return this.request<AudioFile[]>(`${urls.audioFiles}/organization`, 'GET');
817
+ }
818
+
819
+ public async getAudioFilesBySession(sessionId: string): Promise<AudioFile[]> {
820
+ return this.request<AudioFile[]>(`${urls.audioFiles}/session/${sessionId}`, 'GET');
821
+ }
822
+
823
+ public async getAudioFile(id: string): Promise<AudioFile> {
824
+ return this.request<AudioFile>(`${urls.audioFiles}/${id}`, 'GET');
825
+ }
826
+
827
+ public async updateAudioFile(id: string, updates: UpdateAudioFileDto): Promise<AudioFile> {
828
+ return this.request<AudioFile>(`${urls.audioFiles}/${id}`, 'PATCH', updates);
829
+ }
830
+
831
+ public async deleteAudioFile(id: string): Promise<void> {
832
+ await this.request(`${urls.audioFiles}/${id}`, 'DELETE');
833
+ }
834
+
835
+ public async downloadAudioFile(id: string): Promise<Blob> {
836
+ // For file downloads, we need a different approach than JSON requests
837
+ const url = `${this.baseUrl}${urls.audioFiles}/${id}/download`;
838
+
839
+ // Get token first
840
+ await this.getToken();
841
+
842
+ const defaultHeaders: Record<string, string> = {
843
+ 'ngrok-skip-browser-warning': 'true'
844
+ };
845
+
846
+ if (this.accessToken) {
847
+ defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
848
+ }
849
+
850
+ const response = await fetch(url, {
851
+ method: 'GET',
852
+ headers: defaultHeaders,
853
+ });
854
+
855
+ if (!response.ok) {
856
+ const errorData = await response.json().catch(() => ({}));
857
+ throw new Error(
858
+ errorData.message || `Download failed with status ${response.status}`
859
+ );
860
+ }
861
+
862
+ return response.blob();
863
+ }
864
+
865
+ public async downloadAudioFileAsUrl(id: string): Promise<string> {
866
+ const blob = await this.downloadAudioFile(id);
867
+ return URL.createObjectURL(blob);
868
+ }
869
+
787
870
  }
package/src/sdk/types.ts CHANGED
@@ -415,3 +415,72 @@ export interface CreateAgentDto {
415
415
  export interface UpdateAgentDto {
416
416
  name?: string;
417
417
  }
418
+
419
+ // Audio File types
420
+ export enum AudioFileStatus {
421
+ UPLOADED = 'UPLOADED',
422
+ PROCESSING = 'PROCESSING',
423
+ TRANSCRIBED = 'TRANSCRIBED',
424
+ FAILED = 'FAILED',
425
+ }
426
+
427
+ export interface AudioFile {
428
+ id: string;
429
+ originalName: string;
430
+ fileName: string;
431
+ filePath: string;
432
+ fileSize: number;
433
+ mimeType: string;
434
+ uploadId?: string;
435
+ transcriptionUrl?: string;
436
+ status: AudioFileStatus;
437
+ taskId?: string;
438
+ uploadStatus?: string;
439
+ statusLink?: string;
440
+ cancelLink?: string;
441
+ downloadLink?: string;
442
+ progressPercent?: number;
443
+ createdAt: string;
444
+ updatedAt: string;
445
+ sessionId: string;
446
+ userId: string;
447
+
448
+ // Relationships (populated by API)
449
+ session?: Session;
450
+ user?: User;
451
+ }
452
+
453
+ // Audio File DTOs
454
+ export interface CreateAudioFileDto {
455
+ originalName: string;
456
+ fileName: string;
457
+ filePath: string;
458
+ fileSize: number;
459
+ mimeType: string;
460
+ uploadId?: string;
461
+ sessionId: string;
462
+ // userId will be auto-injected by API
463
+ }
464
+
465
+ export interface UpdateAudioFileDto {
466
+ transcriptionUrl?: string;
467
+ status?: AudioFileStatus;
468
+ taskId?: string;
469
+ uploadStatus?: string;
470
+ statusLink?: string;
471
+ cancelLink?: string;
472
+ downloadLink?: string;
473
+ progressPercent?: number;
474
+ }
475
+
476
+ // UploadedFileData interface for the upload response
477
+ export interface UploadedFileData {
478
+ task_id: string;
479
+ status: string;
480
+ links: {
481
+ status: string;
482
+ cancel: string;
483
+ download: string;
484
+ };
485
+ progress_percent: number;
486
+ }
package/src/sdk/urls.ts CHANGED
@@ -40,9 +40,13 @@ const urls = {
40
40
 
41
41
  // Sessions
42
42
  sessions: '/sessions',
43
+ getPapareoTranscriptionStatus: '/sessions/get-papareo-server-transcription-status',
43
44
 
44
45
  // Agents
45
46
  agents: '/agents',
47
+
48
+ // Audio Files
49
+ audioFiles: '/audio-files',
46
50
  }
47
51
 
48
52
  export default urls;
@@ -0,0 +1,92 @@
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();