whio-api-sdk 1.0.212-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.
- package/dist/src/sdk/modules/audio.module.d.ts +2 -1
- package/dist/src/sdk/modules/audio.module.js +3 -6
- package/dist/src/sdk/modules/base-client.d.ts +1 -6
- package/dist/src/sdk/modules/base-client.js +3 -32
- package/dist/src/sdk/modules/template.module.d.ts +2 -2
- package/dist/src/sdk/modules/template.module.js +4 -4
- package/dist/src/sdk/sdk.d.ts +0 -2
- package/dist/src/sdk/sdk.js +0 -7
- package/package.json +1 -1
- package/src/sdk/modules/audio.module.ts +5 -9
- package/src/sdk/modules/base-client.ts +4 -38
- package/src/sdk/modules/template.module.ts +6 -3
- package/src/sdk/sdk.ts +0 -8
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BaseClient } from './base-client';
|
|
2
2
|
import { AudioFile, UpdateAudioFileDto, Base64AudioFile, CreateBase64AudioFileDto, UpdateBase64AudioFileDto, AddBase64ChunkResponse } from '../types';
|
|
3
3
|
export declare class AudioModule extends BaseClient {
|
|
4
|
-
uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string,
|
|
4
|
+
uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string, onProgress?: (percentage: number) => void): Promise<AudioFile>;
|
|
5
5
|
uploadAudioFileWithTranscriptionQueue(sessionId: string, file: File | Blob, options?: {
|
|
6
6
|
fileName?: string;
|
|
7
7
|
culturalTranscription?: string;
|
|
8
|
+
onProgress?: (percentage: number) => void;
|
|
8
9
|
}): Promise<AudioFile>;
|
|
9
10
|
getMyAudioFiles(): Promise<AudioFile[]>;
|
|
10
11
|
getAllAudioFiles(): Promise<AudioFile[]>;
|
|
@@ -14,14 +14,11 @@ export class AudioModule extends BaseClient {
|
|
|
14
14
|
// ======================
|
|
15
15
|
// AUDIO FILE METHODS
|
|
16
16
|
// ======================
|
|
17
|
-
uploadAudioFileToSession(sessionId, file, fileName,
|
|
17
|
+
uploadAudioFileToSession(sessionId, file, fileName, onProgress) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
const formData = new FormData();
|
|
20
20
|
formData.append('file', file, fileName);
|
|
21
|
-
|
|
22
|
-
formData.append('cultural_transcription', culturalTranscription);
|
|
23
|
-
}
|
|
24
|
-
return this.fileUploadRequest(`${urls.audioFiles}/upload/${sessionId}`, formData);
|
|
21
|
+
return this.fileUploadRequest(`${urls.audioFiles}/upload/${sessionId}`, formData, {}, onProgress);
|
|
25
22
|
});
|
|
26
23
|
}
|
|
27
24
|
uploadAudioFileWithTranscriptionQueue(sessionId, file, options) {
|
|
@@ -31,7 +28,7 @@ export class AudioModule extends BaseClient {
|
|
|
31
28
|
if (options === null || options === void 0 ? void 0 : options.culturalTranscription) {
|
|
32
29
|
formData.append('cultural_transcription', options.culturalTranscription);
|
|
33
30
|
}
|
|
34
|
-
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);
|
|
35
32
|
});
|
|
36
33
|
}
|
|
37
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,13 +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
11
|
constructor(config?: SDKConfig);
|
|
14
12
|
protected initialize(): Promise<void>;
|
|
15
13
|
fetchConfig(url: string): Promise<void>;
|
|
16
14
|
protected getToken(): Promise<void>;
|
|
17
15
|
protected request<T>(endpoint: string, method?: string, body?: any, headers?: Record<string, string>, noToken?: boolean): Promise<T>;
|
|
18
|
-
protected fileUploadRequest<T>(endpoint: string, body?: FormData, headers?: Record<string, string
|
|
16
|
+
protected fileUploadRequest<T>(endpoint: string, body?: FormData, headers?: Record<string, string>, onProgress?: (percentage: number) => void): Promise<T>;
|
|
19
17
|
protected downloadRequest(endpoint: string): Promise<Blob>;
|
|
20
18
|
protected clearAuth(): Promise<void>;
|
|
21
19
|
protected isTokenExpired(token: string, bufferMinutes?: number): boolean;
|
|
@@ -24,7 +22,4 @@ export declare class BaseClient {
|
|
|
24
22
|
getCurrentUser(): User | null;
|
|
25
23
|
getAccessToken(): string | null;
|
|
26
24
|
getRefreshToken(): string | null;
|
|
27
|
-
onUploadProgress(handler: (uploadPercentage: number) => void): void;
|
|
28
|
-
offUploadProgress(handler: (uploadPercentage: number) => void): void;
|
|
29
|
-
protected emitEvent<K extends keyof BaseClientEvents>(event: K, ...args: Parameters<BaseClientEvents[K]>): void;
|
|
30
25
|
}
|
|
@@ -16,7 +16,6 @@ export class BaseClient {
|
|
|
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
21
|
this.initialize();
|
|
@@ -86,7 +85,7 @@ export class BaseClient {
|
|
|
86
85
|
return response.json();
|
|
87
86
|
});
|
|
88
87
|
}
|
|
89
|
-
fileUploadRequest(endpoint, body, headers = {}) {
|
|
88
|
+
fileUploadRequest(endpoint, body, headers = {}, onProgress) {
|
|
90
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
90
|
const url = `${this.baseUrl}${endpoint}`;
|
|
92
91
|
const defaultHeaders = {
|
|
@@ -98,9 +97,9 @@ export class BaseClient {
|
|
|
98
97
|
return new Promise((resolve, reject) => {
|
|
99
98
|
const xhr = new XMLHttpRequest();
|
|
100
99
|
xhr.upload.addEventListener('progress', (event) => {
|
|
101
|
-
if (event.lengthComputable) {
|
|
100
|
+
if (event.lengthComputable && onProgress) {
|
|
102
101
|
const percentage = Math.round((event.loaded / event.total) * 100);
|
|
103
|
-
|
|
102
|
+
onProgress(percentage);
|
|
104
103
|
}
|
|
105
104
|
});
|
|
106
105
|
xhr.addEventListener('load', () => {
|
|
@@ -210,32 +209,4 @@ export class BaseClient {
|
|
|
210
209
|
getRefreshToken() {
|
|
211
210
|
return this.refreshToken;
|
|
212
211
|
}
|
|
213
|
-
onUploadProgress(handler) {
|
|
214
|
-
if (!this.baseEventHandlers.has('upload-progress')) {
|
|
215
|
-
this.baseEventHandlers.set('upload-progress', []);
|
|
216
|
-
}
|
|
217
|
-
this.baseEventHandlers.get('upload-progress').push(handler);
|
|
218
|
-
}
|
|
219
|
-
offUploadProgress(handler) {
|
|
220
|
-
const handlers = this.baseEventHandlers.get('upload-progress');
|
|
221
|
-
if (handlers) {
|
|
222
|
-
const index = handlers.indexOf(handler);
|
|
223
|
-
if (index > -1) {
|
|
224
|
-
handlers.splice(index, 1);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
emitEvent(event, ...args) {
|
|
229
|
-
const handlers = this.baseEventHandlers.get(event);
|
|
230
|
-
if (handlers) {
|
|
231
|
-
handlers.forEach(handler => {
|
|
232
|
-
try {
|
|
233
|
-
handler(...args);
|
|
234
|
-
}
|
|
235
|
-
catch (error) {
|
|
236
|
-
console.error(`Error in BaseClient event handler for ${event}:`, error);
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
212
|
}
|
|
@@ -19,7 +19,7 @@ export declare class TemplateModule extends BaseClient {
|
|
|
19
19
|
deleteTemplateCategory(id: string): Promise<void>;
|
|
20
20
|
assignTemplateToTeam(teamId: string, templateId: string): Promise<void>;
|
|
21
21
|
removeTemplateFromTeam(teamId: string, templateId: string): Promise<void>;
|
|
22
|
-
uploadLargeAudioFile(formData: FormData): Promise<string>;
|
|
23
|
-
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>;
|
|
24
24
|
transcribeBase64Audio(base64String: string): Promise<string>;
|
|
25
25
|
}
|
|
@@ -156,18 +156,18 @@ export class TemplateModule extends BaseClient {
|
|
|
156
156
|
// ======================
|
|
157
157
|
// AUDIO UPLOAD METHODS (for transcription)
|
|
158
158
|
// ======================
|
|
159
|
-
uploadLargeAudioFile(formData) {
|
|
159
|
+
uploadLargeAudioFile(formData, onProgress) {
|
|
160
160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
const uploadId = yield this.fileUploadRequest(urls.uploadAudioLarge, formData);
|
|
161
|
+
const uploadId = yield this.fileUploadRequest(urls.uploadAudioLarge, formData, {}, onProgress);
|
|
162
162
|
const uploadIds = (yield this.storage.getItem('uploadIds')) || '[]';
|
|
163
163
|
const uploadIdsArray = JSON.parse(uploadIds);
|
|
164
164
|
yield this.storage.setItem('uploadIds', JSON.stringify([...uploadIdsArray, uploadId]));
|
|
165
165
|
return uploadId;
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
|
-
uploadAudioFile(formData) {
|
|
168
|
+
uploadAudioFile(formData, onProgress) {
|
|
169
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
-
const data = yield this.fileUploadRequest(urls.uploadAudio, formData);
|
|
170
|
+
const data = yield this.fileUploadRequest(urls.uploadAudio, formData, {}, onProgress);
|
|
171
171
|
return data;
|
|
172
172
|
});
|
|
173
173
|
}
|
package/dist/src/sdk/sdk.d.ts
CHANGED
|
@@ -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
|
}
|
package/dist/src/sdk/sdk.js
CHANGED
|
@@ -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
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
CreateBase64AudioFileDto,
|
|
8
8
|
UpdateBase64AudioFileDto,
|
|
9
9
|
AddBase64ChunkResponse,
|
|
10
|
+
SDKConfig,
|
|
10
11
|
} from '../types';
|
|
11
12
|
import urls from '../urls';
|
|
12
13
|
|
|
@@ -15,18 +16,13 @@ export class AudioModule extends BaseClient {
|
|
|
15
16
|
// AUDIO FILE METHODS
|
|
16
17
|
// ======================
|
|
17
18
|
|
|
18
|
-
public async uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string,
|
|
19
|
+
public async uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string, onProgress?: (percentage: number) => void): Promise<AudioFile> {
|
|
19
20
|
const formData = new FormData();
|
|
20
21
|
formData.append('file', file, fileName);
|
|
21
|
-
|
|
22
|
-
if (culturalTranscription) {
|
|
23
|
-
formData.append('cultural_transcription', culturalTranscription);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData);
|
|
22
|
+
return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData, {}, onProgress);
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
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> {
|
|
30
26
|
const formData = new FormData();
|
|
31
27
|
formData.append('file', file, options?.fileName);
|
|
32
28
|
|
|
@@ -34,7 +30,7 @@ export class AudioModule extends BaseClient {
|
|
|
34
30
|
formData.append('cultural_transcription', options.culturalTranscription);
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData);
|
|
33
|
+
return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData, {}, options?.onProgress);
|
|
38
34
|
}
|
|
39
35
|
|
|
40
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,8 +10,6 @@ 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
|
-
|
|
16
13
|
constructor(config: SDKConfig = {}) {
|
|
17
14
|
this.baseUrl = config.baseUrl || '/api';
|
|
18
15
|
this.storage = config.storage;
|
|
@@ -95,7 +92,8 @@ export class BaseClient {
|
|
|
95
92
|
protected async fileUploadRequest<T>(
|
|
96
93
|
endpoint: string,
|
|
97
94
|
body?: FormData,
|
|
98
|
-
headers: Record<string, string> = {}
|
|
95
|
+
headers: Record<string, string> = {},
|
|
96
|
+
onProgress?: (percentage: number) => void
|
|
99
97
|
): Promise<T> {
|
|
100
98
|
const url = `${this.baseUrl}${endpoint}`;
|
|
101
99
|
const defaultHeaders: Record<string, string> = {
|
|
@@ -110,9 +108,9 @@ export class BaseClient {
|
|
|
110
108
|
const xhr = new XMLHttpRequest();
|
|
111
109
|
|
|
112
110
|
xhr.upload.addEventListener('progress', (event) => {
|
|
113
|
-
if (event.lengthComputable) {
|
|
111
|
+
if (event.lengthComputable && onProgress) {
|
|
114
112
|
const percentage = Math.round((event.loaded / event.total) * 100);
|
|
115
|
-
|
|
113
|
+
onProgress(percentage);
|
|
116
114
|
}
|
|
117
115
|
});
|
|
118
116
|
|
|
@@ -242,36 +240,4 @@ export class BaseClient {
|
|
|
242
240
|
return this.refreshToken;
|
|
243
241
|
}
|
|
244
242
|
|
|
245
|
-
public onUploadProgress(handler: (uploadPercentage: number) => void): void {
|
|
246
|
-
if (!this.baseEventHandlers.has('upload-progress')) {
|
|
247
|
-
this.baseEventHandlers.set('upload-progress', []);
|
|
248
|
-
}
|
|
249
|
-
this.baseEventHandlers.get('upload-progress')!.push(handler);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
public offUploadProgress(handler: (uploadPercentage: number) => void): void {
|
|
253
|
-
const handlers = this.baseEventHandlers.get('upload-progress');
|
|
254
|
-
if (handlers) {
|
|
255
|
-
const index = handlers.indexOf(handler);
|
|
256
|
-
if (index > -1) {
|
|
257
|
-
handlers.splice(index, 1);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
protected emitEvent<K extends keyof BaseClientEvents>(
|
|
263
|
-
event: K,
|
|
264
|
-
...args: Parameters<BaseClientEvents[K]>
|
|
265
|
-
): void {
|
|
266
|
-
const handlers = this.baseEventHandlers.get(event);
|
|
267
|
-
if (handlers) {
|
|
268
|
-
handlers.forEach(handler => {
|
|
269
|
-
try {
|
|
270
|
-
(handler as Function)(...args);
|
|
271
|
-
} catch (error) {
|
|
272
|
-
console.error(`Error in BaseClient event handler for ${event}:`, error);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
243
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
UpdateTemplateCategoryDto,
|
|
12
12
|
AssignTeamTemplateDto,
|
|
13
13
|
TranscriptionAudioUploadResponse,
|
|
14
|
+
SDKConfig,
|
|
14
15
|
} from '../types';
|
|
15
16
|
import urls from '../urls';
|
|
16
17
|
|
|
@@ -152,18 +153,20 @@ export class TemplateModule extends BaseClient {
|
|
|
152
153
|
// AUDIO UPLOAD METHODS (for transcription)
|
|
153
154
|
// ======================
|
|
154
155
|
|
|
155
|
-
public async uploadLargeAudioFile(formData: FormData): Promise<string> {
|
|
156
|
-
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);
|
|
157
158
|
const uploadIds: string = await this.storage!.getItem('uploadIds') || '[]';
|
|
158
159
|
const uploadIdsArray = JSON.parse(uploadIds);
|
|
159
160
|
await this.storage!.setItem('uploadIds', JSON.stringify([...uploadIdsArray, uploadId]));
|
|
160
161
|
return uploadId;
|
|
161
162
|
}
|
|
162
163
|
|
|
163
|
-
public async uploadAudioFile(formData: FormData): Promise<TranscriptionAudioUploadResponse | null> {
|
|
164
|
+
public async uploadAudioFile(formData: FormData, onProgress?: (percentage: number) => void): Promise<TranscriptionAudioUploadResponse | null> {
|
|
164
165
|
const data: TranscriptionAudioUploadResponse = await this.fileUploadRequest(
|
|
165
166
|
urls.uploadAudio,
|
|
166
167
|
formData,
|
|
168
|
+
{},
|
|
169
|
+
onProgress
|
|
167
170
|
);
|
|
168
171
|
return data;
|
|
169
172
|
}
|
package/src/sdk/sdk.ts
CHANGED
|
@@ -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
|
}
|