whio-api-sdk 1.0.213-beta-staging → 1.0.214-beta-staging

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,11 +1,11 @@
1
1
  import { BaseClient } from './base-client';
2
- import { AudioFile, UpdateAudioFileDto, Base64AudioFile, CreateBase64AudioFileDto, UpdateBase64AudioFileDto, AddBase64ChunkResponse, SDKConfig } from '../types';
2
+ import { AudioFile, UpdateAudioFileDto, Base64AudioFile, CreateBase64AudioFileDto, UpdateBase64AudioFileDto, AddBase64ChunkResponse } from '../types';
3
3
  export declare class AudioModule extends BaseClient {
4
- constructor(config?: SDKConfig, parentEventEmitter?: BaseClient);
5
- uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string, culturalTranscription?: string): Promise<AudioFile>;
4
+ uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string, onProgress?: (percentage: number) => void): Promise<AudioFile>;
6
5
  uploadAudioFileWithTranscriptionQueue(sessionId: string, file: File | Blob, options?: {
7
6
  fileName?: string;
8
7
  culturalTranscription?: string;
8
+ onProgress?: (percentage: number) => void;
9
9
  }): Promise<AudioFile>;
10
10
  getMyAudioFiles(): Promise<AudioFile[]>;
11
11
  getAllAudioFiles(): Promise<AudioFile[]>;
@@ -11,20 +11,14 @@ import { BaseClient } from './base-client';
11
11
  import { AudioFileStatus, } from '../types';
12
12
  import urls from '../urls';
13
13
  export class AudioModule extends BaseClient {
14
- constructor(config = {}, parentEventEmitter) {
15
- super(config, parentEventEmitter);
16
- }
17
14
  // ======================
18
15
  // AUDIO FILE METHODS
19
16
  // ======================
20
- uploadAudioFileToSession(sessionId, file, fileName, culturalTranscription) {
17
+ uploadAudioFileToSession(sessionId, file, fileName, onProgress) {
21
18
  return __awaiter(this, void 0, void 0, function* () {
22
19
  const formData = new FormData();
23
20
  formData.append('file', file, fileName);
24
- if (culturalTranscription) {
25
- formData.append('cultural_transcription', culturalTranscription);
26
- }
27
- return this.fileUploadRequest(`${urls.audioFiles}/upload/${sessionId}`, formData);
21
+ return this.fileUploadRequest(`${urls.audioFiles}/upload/${sessionId}`, formData, {}, onProgress);
28
22
  });
29
23
  }
30
24
  uploadAudioFileWithTranscriptionQueue(sessionId, file, options) {
@@ -34,7 +28,7 @@ export class AudioModule extends BaseClient {
34
28
  if (options === null || options === void 0 ? void 0 : options.culturalTranscription) {
35
29
  formData.append('cultural_transcription', options.culturalTranscription);
36
30
  }
37
- return this.fileUploadRequest(`${urls.audioFiles}/upload/${sessionId}`, formData);
31
+ return this.fileUploadRequest(`${urls.audioFiles}/upload/${sessionId}`, formData, {}, options === null || options === void 0 ? void 0 : options.onProgress);
38
32
  });
39
33
  }
40
34
  getMyAudioFiles() {
@@ -1,5 +1,4 @@
1
1
  import { SDKConfig, User } from '../types';
2
- import { BaseClientEvents } from '../types/base-client.types';
3
2
  /**
4
3
  * Base HTTP client for making authenticated requests
5
4
  */
@@ -9,14 +8,12 @@ export declare class BaseClient {
9
8
  protected accessToken: string | null;
10
9
  protected refreshToken: string | null;
11
10
  protected user: User | null;
12
- private baseEventHandlers;
13
- protected parentEventEmitter?: BaseClient;
14
- constructor(config?: SDKConfig, parentEventEmitter?: BaseClient);
11
+ constructor(config?: SDKConfig);
15
12
  protected initialize(): Promise<void>;
16
13
  fetchConfig(url: string): Promise<void>;
17
14
  protected getToken(): Promise<void>;
18
15
  protected request<T>(endpoint: string, method?: string, body?: any, headers?: Record<string, string>, noToken?: boolean): Promise<T>;
19
- protected fileUploadRequest<T>(endpoint: string, body?: FormData, headers?: Record<string, string>): Promise<T>;
16
+ protected fileUploadRequest<T>(endpoint: string, body?: FormData, headers?: Record<string, string>, onProgress?: (percentage: number) => void): Promise<T>;
20
17
  protected downloadRequest(endpoint: string): Promise<Blob>;
21
18
  protected clearAuth(): Promise<void>;
22
19
  protected isTokenExpired(token: string, bufferMinutes?: number): boolean;
@@ -25,7 +22,4 @@ export declare class BaseClient {
25
22
  getCurrentUser(): User | null;
26
23
  getAccessToken(): string | null;
27
24
  getRefreshToken(): string | null;
28
- onUploadProgress(handler: (uploadPercentage: number) => void): void;
29
- offUploadProgress(handler: (uploadPercentage: number) => void): void;
30
- protected emitEvent<K extends keyof BaseClientEvents>(event: K, ...args: Parameters<BaseClientEvents[K]>): void;
31
25
  }
@@ -12,14 +12,12 @@ import { jwtDecode } from 'jwt-decode';
12
12
  * Base HTTP client for making authenticated requests
13
13
  */
14
14
  export class BaseClient {
15
- constructor(config = {}, parentEventEmitter) {
15
+ constructor(config = {}) {
16
16
  this.accessToken = null;
17
17
  this.refreshToken = null;
18
18
  this.user = null;
19
- this.baseEventHandlers = new Map();
20
19
  this.baseUrl = config.baseUrl || '/api';
21
20
  this.storage = config.storage;
22
- this.parentEventEmitter = parentEventEmitter;
23
21
  this.initialize();
24
22
  }
25
23
  initialize() {
@@ -87,7 +85,7 @@ export class BaseClient {
87
85
  return response.json();
88
86
  });
89
87
  }
90
- fileUploadRequest(endpoint, body, headers = {}) {
88
+ fileUploadRequest(endpoint, body, headers = {}, onProgress) {
91
89
  return __awaiter(this, void 0, void 0, function* () {
92
90
  const url = `${this.baseUrl}${endpoint}`;
93
91
  const defaultHeaders = {
@@ -99,9 +97,9 @@ export class BaseClient {
99
97
  return new Promise((resolve, reject) => {
100
98
  const xhr = new XMLHttpRequest();
101
99
  xhr.upload.addEventListener('progress', (event) => {
102
- if (event.lengthComputable) {
100
+ if (event.lengthComputable && onProgress) {
103
101
  const percentage = Math.round((event.loaded / event.total) * 100);
104
- this.emitEvent('upload-progress', percentage);
102
+ onProgress(percentage);
105
103
  }
106
104
  });
107
105
  xhr.addEventListener('load', () => {
@@ -211,36 +209,4 @@ export class BaseClient {
211
209
  getRefreshToken() {
212
210
  return this.refreshToken;
213
211
  }
214
- onUploadProgress(handler) {
215
- if (!this.baseEventHandlers.has('upload-progress')) {
216
- this.baseEventHandlers.set('upload-progress', []);
217
- }
218
- this.baseEventHandlers.get('upload-progress').push(handler);
219
- }
220
- offUploadProgress(handler) {
221
- const handlers = this.baseEventHandlers.get('upload-progress');
222
- if (handlers) {
223
- const index = handlers.indexOf(handler);
224
- if (index > -1) {
225
- handlers.splice(index, 1);
226
- }
227
- }
228
- }
229
- emitEvent(event, ...args) {
230
- const handlers = this.baseEventHandlers.get(event);
231
- if (handlers) {
232
- handlers.forEach(handler => {
233
- try {
234
- handler(...args);
235
- }
236
- catch (error) {
237
- console.error(`Error in BaseClient event handler for ${event}:`, error);
238
- }
239
- });
240
- }
241
- // Forward event to parent emitter if available
242
- if (this.parentEventEmitter) {
243
- this.parentEventEmitter.emitEvent(event, ...args);
244
- }
245
- }
246
212
  }
@@ -1,7 +1,6 @@
1
1
  import { BaseClient } from './base-client';
2
- import { Template, TemplateCategory, UserTemplate, TranscriptionAudioUploadResponse, SDKConfig } from '../types';
2
+ import { Template, TemplateCategory, UserTemplate, TranscriptionAudioUploadResponse } from '../types';
3
3
  export declare class TemplateModule extends BaseClient {
4
- constructor(config?: SDKConfig, parentEventEmitter?: BaseClient);
5
4
  createTemplate(title: string, content: string, categoryId?: string, workflowId?: string, agentId?: string): Promise<Template>;
6
5
  updateTemplate(title: string, content: string, id: string, workflowId?: string, agentId?: string): Promise<Template>;
7
6
  getTemplates(): Promise<Template[]>;
@@ -20,7 +19,7 @@ export declare class TemplateModule extends BaseClient {
20
19
  deleteTemplateCategory(id: string): Promise<void>;
21
20
  assignTemplateToTeam(teamId: string, templateId: string): Promise<void>;
22
21
  removeTemplateFromTeam(teamId: string, templateId: string): Promise<void>;
23
- uploadLargeAudioFile(formData: FormData): Promise<string>;
24
- uploadAudioFile(formData: FormData): Promise<TranscriptionAudioUploadResponse | null>;
22
+ uploadLargeAudioFile(formData: FormData, onProgress?: (percentage: number) => void): Promise<string>;
23
+ uploadAudioFile(formData: FormData, onProgress?: (percentage: number) => void): Promise<TranscriptionAudioUploadResponse | null>;
25
24
  transcribeBase64Audio(base64String: string): Promise<string>;
26
25
  }
@@ -10,9 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { BaseClient } from './base-client';
11
11
  import urls from '../urls';
12
12
  export class TemplateModule extends BaseClient {
13
- constructor(config = {}, parentEventEmitter) {
14
- super(config, parentEventEmitter);
15
- }
16
13
  // ======================
17
14
  // TEMPLATE METHODS
18
15
  // ======================
@@ -159,18 +156,18 @@ export class TemplateModule extends BaseClient {
159
156
  // ======================
160
157
  // AUDIO UPLOAD METHODS (for transcription)
161
158
  // ======================
162
- uploadLargeAudioFile(formData) {
159
+ uploadLargeAudioFile(formData, onProgress) {
163
160
  return __awaiter(this, void 0, void 0, function* () {
164
- const uploadId = yield this.fileUploadRequest(urls.uploadAudioLarge, formData);
161
+ const uploadId = yield this.fileUploadRequest(urls.uploadAudioLarge, formData, {}, onProgress);
165
162
  const uploadIds = (yield this.storage.getItem('uploadIds')) || '[]';
166
163
  const uploadIdsArray = JSON.parse(uploadIds);
167
164
  yield this.storage.setItem('uploadIds', JSON.stringify([...uploadIdsArray, uploadId]));
168
165
  return uploadId;
169
166
  });
170
167
  }
171
- uploadAudioFile(formData) {
168
+ uploadAudioFile(formData, onProgress) {
172
169
  return __awaiter(this, void 0, void 0, function* () {
173
- const data = yield this.fileUploadRequest(urls.uploadAudio, formData);
170
+ const data = yield this.fileUploadRequest(urls.uploadAudio, formData, {}, onProgress);
174
171
  return data;
175
172
  });
176
173
  }
@@ -197,6 +197,4 @@ export declare class ApiSDK extends BaseClient {
197
197
  getWebSocketStats(): import("./types").WebSocketConnectionStats;
198
198
  subscribe(...args: Parameters<WebSocketModule['on']>): void;
199
199
  unsubscribe(...args: Parameters<WebSocketModule['off']>): void;
200
- onUploadProgress(handler: (uploadPercentage: number) => void): void;
201
- offUploadProgress(handler: (uploadPercentage: number) => void): void;
202
200
  }
@@ -28,16 +28,16 @@ import { WebSocketModule } from './modules/websocket.module';
28
28
  export class ApiSDK extends BaseClient {
29
29
  constructor(config = {}) {
30
30
  super(config);
31
- // Initialize all domain modules with the same config and this as parent event emitter
31
+ // Initialize all domain modules with the same config
32
32
  this.auth = new AuthModule(config);
33
33
  this.users = new UserModule(config);
34
34
  this.organizations = new OrganizationModule(config);
35
35
  this.teams = new TeamModule(config);
36
- this.templates = new TemplateModule(config, this);
36
+ this.templates = new TemplateModule(config);
37
37
  this.transcriptionSummaries = new TranscriptionSummaryModule(config);
38
38
  this.sessions = new SessionModule(config);
39
39
  this.agents = new AgentModule(config);
40
- this.audio = new AudioModule(config, this);
40
+ this.audio = new AudioModule(config);
41
41
  this.workflows = new WorkflowModule(config);
42
42
  this.logs = new LogModule(config);
43
43
  this.debug = new DebugModule(config);
@@ -806,11 +806,4 @@ export class ApiSDK extends BaseClient {
806
806
  unsubscribe(...args) {
807
807
  return this.websocket.off(...args);
808
808
  }
809
- // Upload progress methods
810
- onUploadProgress(handler) {
811
- return super.onUploadProgress(handler);
812
- }
813
- offUploadProgress(handler) {
814
- return super.offUploadProgress(handler);
815
- }
816
809
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whio-api-sdk",
3
- "version": "1.0.213-beta-staging",
3
+ "version": "1.0.214-beta-staging",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -12,25 +12,17 @@ import {
12
12
  import urls from '../urls';
13
13
 
14
14
  export class AudioModule extends BaseClient {
15
- constructor(config: SDKConfig = {}, parentEventEmitter?: BaseClient) {
16
- super(config, parentEventEmitter);
17
- }
18
15
  // ======================
19
16
  // AUDIO FILE METHODS
20
17
  // ======================
21
18
 
22
- public async uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string, culturalTranscription?: string): Promise<AudioFile> {
19
+ public async uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string, onProgress?: (percentage: number) => void): Promise<AudioFile> {
23
20
  const formData = new FormData();
24
21
  formData.append('file', file, fileName);
25
-
26
- if (culturalTranscription) {
27
- formData.append('cultural_transcription', culturalTranscription);
28
- }
29
-
30
- return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData);
22
+ return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData, {}, onProgress);
31
23
  }
32
24
 
33
- public async uploadAudioFileWithTranscriptionQueue(sessionId: string, file: File | Blob, options?: { fileName?: string; culturalTranscription?: string }): Promise<AudioFile> {
25
+ public async uploadAudioFileWithTranscriptionQueue(sessionId: string, file: File | Blob, options?: { fileName?: string; culturalTranscription?: string; onProgress?: (percentage: number) => void }): Promise<AudioFile> {
34
26
  const formData = new FormData();
35
27
  formData.append('file', file, options?.fileName);
36
28
 
@@ -38,7 +30,7 @@ export class AudioModule extends BaseClient {
38
30
  formData.append('cultural_transcription', options.culturalTranscription);
39
31
  }
40
32
 
41
- return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData);
33
+ return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData, {}, options?.onProgress);
42
34
  }
43
35
 
44
36
  public async getMyAudioFiles(): Promise<AudioFile[]> {
@@ -1,6 +1,5 @@
1
1
  import { jwtDecode } from 'jwt-decode';
2
2
  import { SDKConfig, User, LoginResponse } from '../types';
3
- import { BaseClientEvents } from '../types/base-client.types';
4
3
 
5
4
  /**
6
5
  * Base HTTP client for making authenticated requests
@@ -11,13 +10,9 @@ export class BaseClient {
11
10
  protected accessToken: string | null = null;
12
11
  protected refreshToken: string | null = null;
13
12
  protected user: User | null = null;
14
- private baseEventHandlers: Map<keyof BaseClientEvents, Function[]> = new Map();
15
- protected parentEventEmitter?: BaseClient;
16
-
17
- constructor(config: SDKConfig = {}, parentEventEmitter?: BaseClient) {
13
+ constructor(config: SDKConfig = {}) {
18
14
  this.baseUrl = config.baseUrl || '/api';
19
15
  this.storage = config.storage;
20
- this.parentEventEmitter = parentEventEmitter;
21
16
  this.initialize();
22
17
  }
23
18
 
@@ -97,7 +92,8 @@ export class BaseClient {
97
92
  protected async fileUploadRequest<T>(
98
93
  endpoint: string,
99
94
  body?: FormData,
100
- headers: Record<string, string> = {}
95
+ headers: Record<string, string> = {},
96
+ onProgress?: (percentage: number) => void
101
97
  ): Promise<T> {
102
98
  const url = `${this.baseUrl}${endpoint}`;
103
99
  const defaultHeaders: Record<string, string> = {
@@ -112,9 +108,9 @@ export class BaseClient {
112
108
  const xhr = new XMLHttpRequest();
113
109
 
114
110
  xhr.upload.addEventListener('progress', (event) => {
115
- if (event.lengthComputable) {
111
+ if (event.lengthComputable && onProgress) {
116
112
  const percentage = Math.round((event.loaded / event.total) * 100);
117
- this.emitEvent('upload-progress', percentage);
113
+ onProgress(percentage);
118
114
  }
119
115
  });
120
116
 
@@ -244,41 +240,4 @@ export class BaseClient {
244
240
  return this.refreshToken;
245
241
  }
246
242
 
247
- public onUploadProgress(handler: (uploadPercentage: number) => void): void {
248
- if (!this.baseEventHandlers.has('upload-progress')) {
249
- this.baseEventHandlers.set('upload-progress', []);
250
- }
251
- this.baseEventHandlers.get('upload-progress')!.push(handler);
252
- }
253
-
254
- public offUploadProgress(handler: (uploadPercentage: number) => void): void {
255
- const handlers = this.baseEventHandlers.get('upload-progress');
256
- if (handlers) {
257
- const index = handlers.indexOf(handler);
258
- if (index > -1) {
259
- handlers.splice(index, 1);
260
- }
261
- }
262
- }
263
-
264
- protected emitEvent<K extends keyof BaseClientEvents>(
265
- event: K,
266
- ...args: Parameters<BaseClientEvents[K]>
267
- ): void {
268
- const handlers = this.baseEventHandlers.get(event);
269
- if (handlers) {
270
- handlers.forEach(handler => {
271
- try {
272
- (handler as Function)(...args);
273
- } catch (error) {
274
- console.error(`Error in BaseClient event handler for ${event}:`, error);
275
- }
276
- });
277
- }
278
-
279
- // Forward event to parent emitter if available
280
- if (this.parentEventEmitter) {
281
- this.parentEventEmitter.emitEvent(event, ...args);
282
- }
283
- }
284
243
  }
@@ -16,9 +16,6 @@ import {
16
16
  import urls from '../urls';
17
17
 
18
18
  export class TemplateModule extends BaseClient {
19
- constructor(config: SDKConfig = {}, parentEventEmitter?: BaseClient) {
20
- super(config, parentEventEmitter);
21
- }
22
19
  // ======================
23
20
  // TEMPLATE METHODS
24
21
  // ======================
@@ -156,18 +153,20 @@ export class TemplateModule extends BaseClient {
156
153
  // AUDIO UPLOAD METHODS (for transcription)
157
154
  // ======================
158
155
 
159
- public async uploadLargeAudioFile(formData: FormData): Promise<string> {
160
- const uploadId: string = await this.fileUploadRequest(urls.uploadAudioLarge, formData);
156
+ public async uploadLargeAudioFile(formData: FormData, onProgress?: (percentage: number) => void): Promise<string> {
157
+ const uploadId: string = await this.fileUploadRequest(urls.uploadAudioLarge, formData, {}, onProgress);
161
158
  const uploadIds: string = await this.storage!.getItem('uploadIds') || '[]';
162
159
  const uploadIdsArray = JSON.parse(uploadIds);
163
160
  await this.storage!.setItem('uploadIds', JSON.stringify([...uploadIdsArray, uploadId]));
164
161
  return uploadId;
165
162
  }
166
163
 
167
- public async uploadAudioFile(formData: FormData): Promise<TranscriptionAudioUploadResponse | null> {
164
+ public async uploadAudioFile(formData: FormData, onProgress?: (percentage: number) => void): Promise<TranscriptionAudioUploadResponse | null> {
168
165
  const data: TranscriptionAudioUploadResponse = await this.fileUploadRequest(
169
166
  urls.uploadAudio,
170
167
  formData,
168
+ {},
169
+ onProgress
171
170
  );
172
171
  return data;
173
172
  }
package/src/sdk/sdk.ts CHANGED
@@ -38,16 +38,16 @@ export class ApiSDK extends BaseClient {
38
38
  constructor(config: SDKConfig = {}) {
39
39
  super(config);
40
40
 
41
- // Initialize all domain modules with the same config and this as parent event emitter
41
+ // Initialize all domain modules with the same config
42
42
  this.auth = new AuthModule(config);
43
43
  this.users = new UserModule(config);
44
44
  this.organizations = new OrganizationModule(config);
45
45
  this.teams = new TeamModule(config);
46
- this.templates = new TemplateModule(config, this);
46
+ this.templates = new TemplateModule(config);
47
47
  this.transcriptionSummaries = new TranscriptionSummaryModule(config);
48
48
  this.sessions = new SessionModule(config);
49
49
  this.agents = new AgentModule(config);
50
- this.audio = new AudioModule(config, this);
50
+ this.audio = new AudioModule(config);
51
51
  this.workflows = new WorkflowModule(config);
52
52
  this.logs = new LogModule(config);
53
53
  this.debug = new DebugModule(config);
@@ -685,12 +685,4 @@ export class ApiSDK extends BaseClient {
685
685
  return this.websocket.off(...args);
686
686
  }
687
687
 
688
- // Upload progress methods
689
- public onUploadProgress(handler: (uploadPercentage: number) => void): void {
690
- return super.onUploadProgress(handler);
691
- }
692
-
693
- public offUploadProgress(handler: (uploadPercentage: number) => void): void {
694
- return super.offUploadProgress(handler);
695
- }
696
688
  }