whio-api-sdk 1.0.8 → 1.0.10
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/src/sdk/exampleuse.d.ts +1 -1
- package/dist/src/sdk/exampleuse.js +6 -1
- package/dist/src/sdk/sdk.d.ts +3 -2
- package/dist/src/sdk/sdk.js +25 -6
- package/dist/src/sdk/types.d.ts +8 -0
- package/index.ts +2 -1
- package/package.json +1 -1
- package/src/sdk/exampleuse.ts +6 -2
- package/src/sdk/sdk.ts +38 -13
- package/src/sdk/types.ts +9 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function main(): Promise<void>;
|
|
@@ -33,7 +33,7 @@ const loginCredentials = {
|
|
|
33
33
|
password: "",
|
|
34
34
|
};
|
|
35
35
|
const sdk = new ApiSDK(config);
|
|
36
|
-
function main() {
|
|
36
|
+
export function main() {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
yield sdk.login(loginCredentials);
|
|
39
39
|
const user = sdk.getCurrentUser();
|
|
@@ -49,6 +49,11 @@ function main() {
|
|
|
49
49
|
//console.log("Updated User Template", updatedUserTemplate);
|
|
50
50
|
const templates = yield sdk.getTemplates();
|
|
51
51
|
const userTemplates = yield sdk.getUserTemplates();
|
|
52
|
+
const filepath = "/Users/rimu/Downloads/combined_1749168962192.m4a"; // Replace with your actual file path
|
|
53
|
+
const formData = new FormData();
|
|
54
|
+
formData.append('file', new Blob([filepath]), 'audio.m4a'); // Adjust the Blob as necessary
|
|
55
|
+
const transcriptionSummary = yield sdk.uploadAudioFile(formData);
|
|
56
|
+
console.log("Transcription Summary:", transcriptionSummary);
|
|
52
57
|
});
|
|
53
58
|
}
|
|
54
59
|
main().catch((error) => {
|
package/dist/src/sdk/sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LoginResponse, LoginCredentials, SDKConfig, User, Template, Team, UserTemplate, TranscriptionSummary } from './types';
|
|
1
|
+
import { LoginResponse, LoginCredentials, SDKConfig, User, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse } from './types';
|
|
2
2
|
export declare class ApiSDK {
|
|
3
3
|
private baseUrl;
|
|
4
4
|
private storage;
|
|
@@ -8,6 +8,7 @@ export declare class ApiSDK {
|
|
|
8
8
|
constructor(config?: SDKConfig);
|
|
9
9
|
private initialize;
|
|
10
10
|
private request;
|
|
11
|
+
private fileUploadRequest;
|
|
11
12
|
login(credentials: LoginCredentials): Promise<LoginResponse>;
|
|
12
13
|
logout(): Promise<void>;
|
|
13
14
|
private clearAuth;
|
|
@@ -37,5 +38,5 @@ export declare class ApiSDK {
|
|
|
37
38
|
generateTranscriptionSummaryFromUserTemplate(transcript: string, userTemplateId: string): Promise<TranscriptionSummary>;
|
|
38
39
|
updateTranscriptionSummary(id: string, content: string): Promise<TranscriptionSummary>;
|
|
39
40
|
uploadLargeAudioFile(formData: FormData): Promise<string>;
|
|
40
|
-
uploadAudioFile(formData: FormData): Promise<
|
|
41
|
+
uploadAudioFile(formData: FormData): Promise<TranscriptionAudioUploadResponse | null>;
|
|
41
42
|
}
|
package/dist/src/sdk/sdk.js
CHANGED
|
@@ -52,6 +52,28 @@ export class ApiSDK {
|
|
|
52
52
|
return response.json();
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
+
fileUploadRequest(endpoint, body, headers = {}) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
58
|
+
const defaultHeaders = {
|
|
59
|
+
'Content-Type': 'multipart/form-data',
|
|
60
|
+
'ngrok-skip-browser-warning': 'true'
|
|
61
|
+
};
|
|
62
|
+
if (this.accessToken) {
|
|
63
|
+
defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
|
|
64
|
+
}
|
|
65
|
+
const response = yield fetch(url, {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
headers: Object.assign(Object.assign({}, defaultHeaders), headers),
|
|
68
|
+
body,
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
const errorData = yield response.json().catch(() => ({}));
|
|
72
|
+
throw new Error(errorData.message || `Request failed with status ${response.status}`);
|
|
73
|
+
}
|
|
74
|
+
return response.json();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
55
77
|
login(credentials) {
|
|
56
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
79
|
try {
|
|
@@ -289,7 +311,7 @@ export class ApiSDK {
|
|
|
289
311
|
}
|
|
290
312
|
uploadLargeAudioFile(formData) {
|
|
291
313
|
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
-
const uploadId = yield this.
|
|
314
|
+
const uploadId = yield this.fileUploadRequest(urls.uploadAudioLarge, formData);
|
|
293
315
|
const uploadIds = (yield this.storage.getItem('uploadIds')) || '[]';
|
|
294
316
|
const uploadIdsArray = JSON.parse(uploadIds);
|
|
295
317
|
yield this.storage.setItem('uploadIds', JSON.stringify([...uploadIdsArray, uploadId]));
|
|
@@ -298,11 +320,8 @@ export class ApiSDK {
|
|
|
298
320
|
}
|
|
299
321
|
uploadAudioFile(formData) {
|
|
300
322
|
return __awaiter(this, void 0, void 0, function* () {
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
const uploadIdsArray = JSON.parse(uploadIds);
|
|
304
|
-
yield this.storage.setItem('uploadIds', JSON.stringify([...uploadIdsArray, uploadId]));
|
|
305
|
-
return uploadId;
|
|
323
|
+
const data = yield this.fileUploadRequest(urls.uploadAudio, formData);
|
|
324
|
+
return data;
|
|
306
325
|
});
|
|
307
326
|
}
|
|
308
327
|
}
|
package/dist/src/sdk/types.d.ts
CHANGED
|
@@ -215,3 +215,11 @@ export interface Team {
|
|
|
215
215
|
teamRoles?: TeamRole[];
|
|
216
216
|
teamTemplates?: TeamTemplate[];
|
|
217
217
|
}
|
|
218
|
+
export interface TranscriptionAudioUploadResponse {
|
|
219
|
+
success: Boolean;
|
|
220
|
+
transcription: string;
|
|
221
|
+
model_version: string;
|
|
222
|
+
metadata: any[];
|
|
223
|
+
duration: number;
|
|
224
|
+
log: string;
|
|
225
|
+
}
|
package/index.ts
CHANGED
package/package.json
CHANGED
package/src/sdk/exampleuse.ts
CHANGED
|
@@ -35,7 +35,7 @@ const loginCredentials: LoginCredentials = {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const sdk = new ApiSDK(config);
|
|
38
|
-
async function main() {
|
|
38
|
+
export async function main() {
|
|
39
39
|
await sdk.login(loginCredentials);
|
|
40
40
|
const user: User | null = sdk.getCurrentUser();
|
|
41
41
|
const newUser: User = await sdk.createEditorUser(
|
|
@@ -83,7 +83,11 @@ async function main() {
|
|
|
83
83
|
const templates = await sdk.getTemplates();
|
|
84
84
|
const userTemplates = await sdk.getUserTemplates();
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
const filepath = "/Users/rimu/Downloads/combined_1749168962192.m4a"; // Replace with your actual file path
|
|
87
|
+
const formData = new FormData();
|
|
88
|
+
formData.append('file', new Blob([filepath]), 'audio.m4a'); // Adjust the Blob as necessary
|
|
89
|
+
const transcriptionSummary = await sdk.uploadAudioFile(formData);
|
|
90
|
+
console.log("Transcription Summary:", transcriptionSummary);
|
|
87
91
|
|
|
88
92
|
}
|
|
89
93
|
|
package/src/sdk/sdk.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
Team,
|
|
24
24
|
UserTemplate,
|
|
25
25
|
TranscriptionSummary,
|
|
26
|
+
TranscriptionAudioUploadResponse,
|
|
26
27
|
} from './types';
|
|
27
28
|
import urls from './urls';
|
|
28
29
|
import jwtDecode from 'jwt-decode';
|
|
@@ -83,6 +84,37 @@ export class ApiSDK {
|
|
|
83
84
|
return response.json();
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
private async fileUploadRequest<T>(
|
|
88
|
+
endpoint: string,
|
|
89
|
+
body?: FormData,
|
|
90
|
+
headers: Record<string, string> = {}
|
|
91
|
+
): Promise<T> {
|
|
92
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
93
|
+
const defaultHeaders: Record<string, string> = {
|
|
94
|
+
'Content-Type': 'multipart/form-data',
|
|
95
|
+
'ngrok-skip-browser-warning': 'true'
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
if (this.accessToken) {
|
|
99
|
+
defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const response = await fetch(url, {
|
|
103
|
+
method: 'POST',
|
|
104
|
+
headers: { ...defaultHeaders, ...headers },
|
|
105
|
+
body,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
if (!response.ok) {
|
|
109
|
+
const errorData = await response.json().catch(() => ({}));
|
|
110
|
+
throw new Error(
|
|
111
|
+
errorData.message || `Request failed with status ${response.status}`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return response.json();
|
|
116
|
+
}
|
|
117
|
+
|
|
86
118
|
public async login(credentials: LoginCredentials): Promise<LoginResponse> {
|
|
87
119
|
try {
|
|
88
120
|
const response = await this.request<LoginResponse>(
|
|
@@ -348,11 +380,9 @@ export class ApiSDK {
|
|
|
348
380
|
}
|
|
349
381
|
|
|
350
382
|
public async uploadLargeAudioFile(formData: FormData): Promise<string> {
|
|
351
|
-
const uploadId: string = await this.
|
|
383
|
+
const uploadId: string = await this.fileUploadRequest(
|
|
352
384
|
urls.uploadAudioLarge,
|
|
353
|
-
|
|
354
|
-
formData,
|
|
355
|
-
{ 'Content-Type': 'multipart/form-data' }
|
|
385
|
+
formData
|
|
356
386
|
);
|
|
357
387
|
const uploadIds: string = await this.storage!.getItem('uploadIds') || '[]';
|
|
358
388
|
const uploadIdsArray = JSON.parse(uploadIds);
|
|
@@ -360,17 +390,12 @@ export class ApiSDK {
|
|
|
360
390
|
return uploadId;
|
|
361
391
|
}
|
|
362
392
|
|
|
363
|
-
public async uploadAudioFile(formData: FormData): Promise<
|
|
364
|
-
const
|
|
365
|
-
urls.
|
|
366
|
-
'POST',
|
|
393
|
+
public async uploadAudioFile(formData: FormData): Promise<TranscriptionAudioUploadResponse | null> {
|
|
394
|
+
const data: TranscriptionAudioUploadResponse = await this.fileUploadRequest(
|
|
395
|
+
urls.uploadAudio,
|
|
367
396
|
formData,
|
|
368
|
-
{ 'Content-Type': 'multipart/form-data' }
|
|
369
397
|
);
|
|
370
|
-
|
|
371
|
-
const uploadIdsArray = JSON.parse(uploadIds);
|
|
372
|
-
await this.storage!.setItem('uploadIds', JSON.stringify([...uploadIdsArray, uploadId]));
|
|
373
|
-
return uploadId;
|
|
398
|
+
return data;
|
|
374
399
|
}
|
|
375
400
|
|
|
376
401
|
|
package/src/sdk/types.ts
CHANGED
|
@@ -275,4 +275,13 @@ export interface Team {
|
|
|
275
275
|
teamTemplates?: TeamTemplate[];
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
+
export interface TranscriptionAudioUploadResponse {
|
|
279
|
+
success: Boolean,
|
|
280
|
+
transcription: string,
|
|
281
|
+
model_version: string,
|
|
282
|
+
metadata: any[],
|
|
283
|
+
duration: number,
|
|
284
|
+
log: string,
|
|
285
|
+
}
|
|
286
|
+
|
|
278
287
|
|