whio-api-sdk 1.0.173 → 1.0.175

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 } 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,4 +89,21 @@ 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
+ createAgent(name: string): Promise<Agent>;
93
+ getAgents(): Promise<Agent[]>;
94
+ getAgent(id: string): Promise<Agent>;
95
+ updateAgent(id: string, name: string): Promise<Agent>;
96
+ deleteAgent(id: string): Promise<void>;
97
+ addAgentToOrganization(agentId: string, organizationId: string): Promise<void>;
98
+ removeAgentFromOrganization(agentId: string, organizationId: string): Promise<void>;
99
+ uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string): Promise<AudioFile>;
100
+ getMyAudioFiles(): Promise<AudioFile[]>;
101
+ getAllAudioFiles(): Promise<AudioFile[]>;
102
+ getOrganizationAudioFiles(): Promise<AudioFile[]>;
103
+ getAudioFilesBySession(sessionId: string): Promise<AudioFile[]>;
104
+ getAudioFile(id: string): Promise<AudioFile>;
105
+ updateAudioFile(id: string, updates: UpdateAudioFileDto): Promise<AudioFile>;
106
+ deleteAudioFile(id: string): Promise<void>;
107
+ downloadAudioFile(id: string): Promise<Blob>;
108
+ downloadAudioFileAsUrl(id: string): Promise<string>;
92
109
  }
@@ -684,4 +684,118 @@ export class ApiSDK {
684
684
  return this.request(`${urls.sessions}/${sessionId}/primary-summary/${summaryId}`, 'PATCH');
685
685
  });
686
686
  }
687
+ // ======================
688
+ // AGENT METHODS
689
+ // ======================
690
+ createAgent(name) {
691
+ return __awaiter(this, void 0, void 0, function* () {
692
+ const dto = { name };
693
+ return this.request(urls.agents, 'POST', dto);
694
+ });
695
+ }
696
+ getAgents() {
697
+ return __awaiter(this, void 0, void 0, function* () {
698
+ return this.request(urls.agents, 'GET');
699
+ });
700
+ }
701
+ getAgent(id) {
702
+ return __awaiter(this, void 0, void 0, function* () {
703
+ return this.request(`${urls.agents}/${id}`, 'GET');
704
+ });
705
+ }
706
+ updateAgent(id, name) {
707
+ return __awaiter(this, void 0, void 0, function* () {
708
+ const dto = { name };
709
+ return this.request(`${urls.agents}/${id}`, 'PATCH', dto);
710
+ });
711
+ }
712
+ deleteAgent(id) {
713
+ return __awaiter(this, void 0, void 0, function* () {
714
+ yield this.request(`${urls.agents}/${id}`, 'DELETE');
715
+ });
716
+ }
717
+ addAgentToOrganization(agentId, organizationId) {
718
+ return __awaiter(this, void 0, void 0, function* () {
719
+ yield this.request(`${urls.agents}/${agentId}/organizations/${organizationId}`, 'POST');
720
+ });
721
+ }
722
+ removeAgentFromOrganization(agentId, organizationId) {
723
+ return __awaiter(this, void 0, void 0, function* () {
724
+ yield this.request(`${urls.agents}/${agentId}/organizations/${organizationId}`, 'DELETE');
725
+ });
726
+ }
727
+ // ======================
728
+ // AUDIO FILE METHODS
729
+ // ======================
730
+ uploadAudioFileToSession(sessionId, file, fileName) {
731
+ return __awaiter(this, void 0, void 0, function* () {
732
+ const formData = new FormData();
733
+ formData.append('file', file, fileName);
734
+ return this.fileUploadRequest(`${urls.audioFiles}/upload/${sessionId}`, formData);
735
+ });
736
+ }
737
+ getMyAudioFiles() {
738
+ return __awaiter(this, void 0, void 0, function* () {
739
+ return this.request(`${urls.audioFiles}/my-files`, 'GET');
740
+ });
741
+ }
742
+ getAllAudioFiles() {
743
+ return __awaiter(this, void 0, void 0, function* () {
744
+ return this.request(`${urls.audioFiles}/all`, 'GET');
745
+ });
746
+ }
747
+ getOrganizationAudioFiles() {
748
+ return __awaiter(this, void 0, void 0, function* () {
749
+ return this.request(`${urls.audioFiles}/organization`, 'GET');
750
+ });
751
+ }
752
+ getAudioFilesBySession(sessionId) {
753
+ return __awaiter(this, void 0, void 0, function* () {
754
+ return this.request(`${urls.audioFiles}/session/${sessionId}`, 'GET');
755
+ });
756
+ }
757
+ getAudioFile(id) {
758
+ return __awaiter(this, void 0, void 0, function* () {
759
+ return this.request(`${urls.audioFiles}/${id}`, 'GET');
760
+ });
761
+ }
762
+ updateAudioFile(id, updates) {
763
+ return __awaiter(this, void 0, void 0, function* () {
764
+ return this.request(`${urls.audioFiles}/${id}`, 'PATCH', updates);
765
+ });
766
+ }
767
+ deleteAudioFile(id) {
768
+ return __awaiter(this, void 0, void 0, function* () {
769
+ yield this.request(`${urls.audioFiles}/${id}`, 'DELETE');
770
+ });
771
+ }
772
+ downloadAudioFile(id) {
773
+ return __awaiter(this, void 0, void 0, function* () {
774
+ // For file downloads, we need a different approach than JSON requests
775
+ const url = `${this.baseUrl}${urls.audioFiles}/${id}/download`;
776
+ // Get token first
777
+ yield this.getToken();
778
+ const defaultHeaders = {
779
+ 'ngrok-skip-browser-warning': 'true'
780
+ };
781
+ if (this.accessToken) {
782
+ defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
783
+ }
784
+ const response = yield fetch(url, {
785
+ method: 'GET',
786
+ headers: defaultHeaders,
787
+ });
788
+ if (!response.ok) {
789
+ const errorData = yield response.json().catch(() => ({}));
790
+ throw new Error(errorData.message || `Download failed with status ${response.status}`);
791
+ }
792
+ return response.blob();
793
+ });
794
+ }
795
+ downloadAudioFileAsUrl(id) {
796
+ return __awaiter(this, void 0, void 0, function* () {
797
+ const blob = yield this.downloadAudioFile(id);
798
+ return URL.createObjectURL(blob);
799
+ });
800
+ }
687
801
  }
@@ -31,6 +31,7 @@ export interface Organization {
31
31
  updatedAt: string;
32
32
  users?: User[];
33
33
  roles?: OrganizationRole[];
34
+ agents?: AgentOrganization[];
34
35
  }
35
36
  export interface User {
36
37
  id: string;
@@ -277,7 +278,7 @@ 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;
@@ -307,3 +308,59 @@ export interface UpdateSessionDto {
307
308
  sessionName?: string;
308
309
  primaryTranscriptionSummaryId?: string;
309
310
  }
311
+ export interface Agent {
312
+ id: string;
313
+ name: string;
314
+ createdAt: string;
315
+ updatedAt: string;
316
+ organizations?: AgentOrganization[];
317
+ }
318
+ export interface AgentOrganization {
319
+ agentId: string;
320
+ organizationId: string;
321
+ createdAt: string;
322
+ agent?: Agent;
323
+ organization?: Organization;
324
+ }
325
+ export interface CreateAgentDto {
326
+ name: string;
327
+ }
328
+ export interface UpdateAgentDto {
329
+ name?: string;
330
+ }
331
+ export declare enum AudioFileStatus {
332
+ UPLOADED = "UPLOADED",
333
+ PROCESSING = "PROCESSING",
334
+ TRANSCRIBED = "TRANSCRIBED",
335
+ FAILED = "FAILED"
336
+ }
337
+ export interface AudioFile {
338
+ id: string;
339
+ originalName: string;
340
+ fileName: string;
341
+ filePath: string;
342
+ fileSize: number;
343
+ mimeType: string;
344
+ uploadId?: string;
345
+ transcriptionUrl?: string;
346
+ status: AudioFileStatus;
347
+ createdAt: string;
348
+ updatedAt: string;
349
+ sessionId: string;
350
+ userId: string;
351
+ session?: Session;
352
+ user?: User;
353
+ }
354
+ export interface CreateAudioFileDto {
355
+ originalName: string;
356
+ fileName: string;
357
+ filePath: string;
358
+ fileSize: number;
359
+ mimeType: string;
360
+ uploadId?: string;
361
+ sessionId: string;
362
+ }
363
+ export interface UpdateAudioFileDto {
364
+ transcriptionUrl?: string;
365
+ status?: AudioFileStatus;
366
+ }
@@ -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,5 +25,7 @@ declare const urls: {
25
25
  roles: string;
26
26
  userRoles: string;
27
27
  sessions: string;
28
+ agents: string;
29
+ audioFiles: string;
28
30
  };
29
31
  export default urls;
@@ -33,5 +33,9 @@ const urls = {
33
33
  userRoles: '/user-roles',
34
34
  // Sessions
35
35
  sessions: '/sessions',
36
+ // Agents
37
+ agents: '/agents',
38
+ // Audio Files
39
+ audioFiles: '/audio-files',
36
40
  };
37
41
  export default urls;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whio-api-sdk",
3
- "version": "1.0.173",
3
+ "version": "1.0.175",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
package/src/sdk/sdk.ts CHANGED
@@ -37,6 +37,13 @@ import {
37
37
  Session,
38
38
  CreateSessionDto,
39
39
  UpdateSessionDto,
40
+ Agent,
41
+ CreateAgentDto,
42
+ UpdateAgentDto,
43
+ AudioFile,
44
+ AudioFileStatus,
45
+ CreateAudioFileDto,
46
+ UpdateAudioFileDto,
40
47
  } from './types';
41
48
  import urls from './urls';
42
49
  import { jwtDecode } from 'jwt-decode';
@@ -752,4 +759,112 @@ export class ApiSDK {
752
759
  return this.request<Session>(`${urls.sessions}/${sessionId}/primary-summary/${summaryId}`, 'PATCH');
753
760
  }
754
761
 
762
+ // ======================
763
+ // AGENT METHODS
764
+ // ======================
765
+
766
+ public async createAgent(name: string): Promise<Agent> {
767
+ const dto: CreateAgentDto = { name };
768
+ return this.request<Agent>(urls.agents, 'POST', dto);
769
+ }
770
+
771
+ public async getAgents(): Promise<Agent[]> {
772
+ return this.request<Agent[]>(urls.agents, 'GET');
773
+ }
774
+
775
+ public async getAgent(id: string): Promise<Agent> {
776
+ return this.request<Agent>(`${urls.agents}/${id}`, 'GET');
777
+ }
778
+
779
+ public async updateAgent(id: string, name: string): Promise<Agent> {
780
+ const dto: UpdateAgentDto = { name };
781
+ return this.request<Agent>(`${urls.agents}/${id}`, 'PATCH', dto);
782
+ }
783
+
784
+ public async deleteAgent(id: string): Promise<void> {
785
+ await this.request(`${urls.agents}/${id}`, 'DELETE');
786
+ }
787
+
788
+ public async addAgentToOrganization(agentId: string, organizationId: string): Promise<void> {
789
+ await this.request(`${urls.agents}/${agentId}/organizations/${organizationId}`, 'POST');
790
+ }
791
+
792
+ public async removeAgentFromOrganization(agentId: string, organizationId: string): Promise<void> {
793
+ await this.request(`${urls.agents}/${agentId}/organizations/${organizationId}`, 'DELETE');
794
+ }
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
+
755
870
  }
package/src/sdk/types.ts CHANGED
@@ -43,6 +43,7 @@ export interface Organization {
43
43
 
44
44
  users?: User[];
45
45
  roles?: OrganizationRole[];
46
+ agents?: AgentOrganization[];
46
47
  }
47
48
 
48
49
  // User type
@@ -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
 
@@ -388,3 +389,75 @@ export interface UpdateSessionDto {
388
389
  sessionName?: string;
389
390
  primaryTranscriptionSummaryId?: string;
390
391
  }
392
+
393
+ // Agent types
394
+ export interface Agent {
395
+ id: string;
396
+ name: string;
397
+ createdAt: string;
398
+ updatedAt: string;
399
+ organizations?: AgentOrganization[];
400
+ }
401
+
402
+ // Agent Organization association
403
+ export interface AgentOrganization {
404
+ agentId: string;
405
+ organizationId: string;
406
+ createdAt: string;
407
+ agent?: Agent;
408
+ organization?: Organization;
409
+ }
410
+
411
+ // Agent DTOs
412
+ export interface CreateAgentDto {
413
+ name: string;
414
+ }
415
+
416
+ export interface UpdateAgentDto {
417
+ name?: string;
418
+ }
419
+
420
+ // Audio File types
421
+ export enum AudioFileStatus {
422
+ UPLOADED = 'UPLOADED',
423
+ PROCESSING = 'PROCESSING',
424
+ TRANSCRIBED = 'TRANSCRIBED',
425
+ FAILED = 'FAILED',
426
+ }
427
+
428
+ export interface AudioFile {
429
+ id: string;
430
+ originalName: string;
431
+ fileName: string;
432
+ filePath: string;
433
+ fileSize: number;
434
+ mimeType: string;
435
+ uploadId?: string;
436
+ transcriptionUrl?: string;
437
+ status: AudioFileStatus;
438
+ createdAt: string;
439
+ updatedAt: string;
440
+ sessionId: string;
441
+ userId: string;
442
+
443
+ // Relationships (populated by API)
444
+ session?: Session;
445
+ user?: User;
446
+ }
447
+
448
+ // Audio File DTOs
449
+ export interface CreateAudioFileDto {
450
+ originalName: string;
451
+ fileName: string;
452
+ filePath: string;
453
+ fileSize: number;
454
+ mimeType: string;
455
+ uploadId?: string;
456
+ sessionId: string;
457
+ // userId will be auto-injected by API
458
+ }
459
+
460
+ export interface UpdateAudioFileDto {
461
+ transcriptionUrl?: string;
462
+ status?: AudioFileStatus;
463
+ }
package/src/sdk/urls.ts CHANGED
@@ -40,6 +40,12 @@ const urls = {
40
40
 
41
41
  // Sessions
42
42
  sessions: '/sessions',
43
+
44
+ // Agents
45
+ agents: '/agents',
46
+
47
+ // Audio Files
48
+ audioFiles: '/audio-files',
43
49
  }
44
50
 
45
51
  export default urls;