@eka-care/ekascribe-ts-sdk 1.5.46 → 1.5.49
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/audio-chunker/audio-file-manager.js +9 -0
- package/dist/aws-services/upload-file-to-s3.d.ts +2 -1
- package/dist/aws-services/upload-file-to-s3.js +1 -4
- package/dist/constants/constant.d.ts +0 -1
- package/dist/constants/constant.js +0 -1
- package/dist/fetch-client/helper.d.ts +1 -0
- package/dist/fetch-client/helper.js +4 -3
- package/dist/shared-worker/s3-file-upload.js +2 -1
- package/dist/shared-worker/s3-file-upload.ts +3 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import { configureAWS } from '../aws-services/configure-aws';
|
|
|
5
5
|
import { CALLBACK_TYPE, SHARED_WORKER_ACTION } from '../constants/enums';
|
|
6
6
|
import compressAudioToMp3 from '../utils/compress-mp3-audio';
|
|
7
7
|
import EkaScribeStore from '../store/store';
|
|
8
|
+
import { GET_S3_BUCKET_NAME } from '../fetch-client/helper';
|
|
8
9
|
class AudioFileManager {
|
|
9
10
|
initialiseClassInstance() {
|
|
10
11
|
this.audioChunks = [];
|
|
@@ -308,8 +309,10 @@ class AudioFileManager {
|
|
|
308
309
|
},
|
|
309
310
|
});
|
|
310
311
|
}
|
|
312
|
+
const s3BucketName = GET_S3_BUCKET_NAME();
|
|
311
313
|
// Push upload promise to track status
|
|
312
314
|
const uploadPromise = pushFileToS3({
|
|
315
|
+
s3BucketName,
|
|
313
316
|
fileBlob: audioBlob,
|
|
314
317
|
fileName: s3FileName,
|
|
315
318
|
txnID: this.txnID,
|
|
@@ -397,9 +400,11 @@ class AudioFileManager {
|
|
|
397
400
|
},
|
|
398
401
|
});
|
|
399
402
|
}
|
|
403
|
+
const s3BucketName = GET_S3_BUCKET_NAME();
|
|
400
404
|
this.sharedWorkerInstance?.port.postMessage({
|
|
401
405
|
action: SHARED_WORKER_ACTION.UPLOAD_FILE_WITH_WORKER,
|
|
402
406
|
payload: {
|
|
407
|
+
s3BucketName,
|
|
403
408
|
audioFrames,
|
|
404
409
|
fileName: s3FileName,
|
|
405
410
|
txnID: this.txnID,
|
|
@@ -541,6 +546,7 @@ class AudioFileManager {
|
|
|
541
546
|
return [];
|
|
542
547
|
}
|
|
543
548
|
const onEventCallback = EkaScribeStore.eventCallback;
|
|
549
|
+
const s3BucketName = GET_S3_BUCKET_NAME();
|
|
544
550
|
if (this.sharedWorkerInstance) {
|
|
545
551
|
this.audioChunks.forEach((chunk, index) => {
|
|
546
552
|
const { fileName, fileBlob, status, audioFrames } = chunk;
|
|
@@ -549,6 +555,7 @@ class AudioFileManager {
|
|
|
549
555
|
this.sharedWorkerInstance?.port.postMessage({
|
|
550
556
|
action: SHARED_WORKER_ACTION.UPLOAD_FILE_WITH_WORKER,
|
|
551
557
|
payload: {
|
|
558
|
+
s3BucketName,
|
|
552
559
|
audioFrames,
|
|
553
560
|
fileBlob,
|
|
554
561
|
fileName: `${this.filePath}/${fileName}`,
|
|
@@ -575,6 +582,7 @@ class AudioFileManager {
|
|
|
575
582
|
},
|
|
576
583
|
});
|
|
577
584
|
}
|
|
585
|
+
const s3BucketName = GET_S3_BUCKET_NAME();
|
|
578
586
|
this.audioChunks.forEach((chunk, index) => {
|
|
579
587
|
const { fileName, fileBlob, status, audioFrames } = chunk;
|
|
580
588
|
if (status != 'success') {
|
|
@@ -591,6 +599,7 @@ class AudioFileManager {
|
|
|
591
599
|
}
|
|
592
600
|
if (failedFileBlob) {
|
|
593
601
|
const uploadPromise = pushFileToS3({
|
|
602
|
+
s3BucketName,
|
|
594
603
|
fileBlob: failedFileBlob,
|
|
595
604
|
fileName: `${this.filePath}/${fileName}`,
|
|
596
605
|
txnID: this.txnID,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
declare const pushFileToS3: ({ fileBlob, fileName, txnID, businessID, is_shared_worker, }: {
|
|
1
|
+
declare const pushFileToS3: ({ s3BucketName, fileBlob, fileName, txnID, businessID, is_shared_worker, }: {
|
|
2
|
+
s3BucketName: string;
|
|
2
3
|
fileBlob: Blob;
|
|
3
4
|
fileName: string;
|
|
4
5
|
txnID: string;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import * as AWS from 'aws-sdk';
|
|
3
3
|
import s3RetryWrapper from './s3-retry-wrapper';
|
|
4
|
-
|
|
5
|
-
const pushFileToS3 = async ({ fileBlob, fileName, txnID, businessID, is_shared_worker = false, }) => {
|
|
4
|
+
const pushFileToS3 = async ({ s3BucketName, fileBlob, fileName, txnID, businessID, is_shared_worker = false, }) => {
|
|
6
5
|
try {
|
|
7
|
-
const s3BucketName = GET_S3_BUCKET_NAME();
|
|
8
|
-
console.log('s3BucketName', s3BucketName);
|
|
9
6
|
const requestBody = {
|
|
10
7
|
Bucket: s3BucketName,
|
|
11
8
|
Key: fileName,
|
|
@@ -16,7 +16,6 @@ export declare const CHANNELS = 1;
|
|
|
16
16
|
export declare const AUDIO_BUFFER_SIZE_IN_S: number;
|
|
17
17
|
export declare const OUTPUT_FORMAT = "mp3";
|
|
18
18
|
export declare const AUDIO_EXTENSION_TYPE_MAP: Record<string, string>;
|
|
19
|
-
export declare const S3_BUCKET_NAME = "m-prod-voice-record";
|
|
20
19
|
export declare const SDK_STATUS_CODE: {
|
|
21
20
|
AUDIO_ERROR: number;
|
|
22
21
|
SUCCESS: number;
|
|
@@ -12,4 +12,5 @@ export declare const GET_EKA_VOICE_HOST_V3: () => string;
|
|
|
12
12
|
export declare const GET_COOK_HOST_V1: () => string;
|
|
13
13
|
export declare const GET_COG_HOST: () => string;
|
|
14
14
|
export declare const GET_EKA_HOST: () => string;
|
|
15
|
+
export declare const GET_CURRENT_ENV: () => "PROD" | "DEV";
|
|
15
16
|
export default setEnv;
|
|
@@ -5,6 +5,7 @@ const DEV = {
|
|
|
5
5
|
EKA_VOICE_HOST_V3: 'https://api.dev.eka.care/voice/api/v3',
|
|
6
6
|
COOK_V1: ' https://deepthought-genai.dev.eka.care/api/v1',
|
|
7
7
|
EKA_HOST: 'https://api.dev.eka.care',
|
|
8
|
+
S3_BUCKET_NAME: 'm-pp-voice2rx',
|
|
8
9
|
};
|
|
9
10
|
const PROD = {
|
|
10
11
|
COG_HOST: 'https://cog.eka.care',
|
|
@@ -13,12 +14,11 @@ const PROD = {
|
|
|
13
14
|
EKA_VOICE_HOST_V3: 'https://api.eka.care/voice/api/v3',
|
|
14
15
|
COOK_V1: ' https://cook.eka.care/api/v1',
|
|
15
16
|
EKA_HOST: 'https://api.eka.care',
|
|
17
|
+
S3_BUCKET_NAME: 'm-prod-voice-record',
|
|
16
18
|
};
|
|
17
19
|
let envVar = PROD;
|
|
18
20
|
let client_id = 'doc-web';
|
|
19
21
|
let auth;
|
|
20
|
-
const s3_prod_bucket_name = 'm-prod-voice-record';
|
|
21
|
-
const s3_dev_bucket_name = 'm-pp-voice2rx';
|
|
22
22
|
const setEnv = ({ env, clientId, auth_token, }) => {
|
|
23
23
|
if (env) {
|
|
24
24
|
envVar = env === 'PROD' ? PROD : DEV;
|
|
@@ -31,7 +31,7 @@ const setEnv = ({ env, clientId, auth_token, }) => {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
console.log(envVar, 'dev');
|
|
34
|
-
export const GET_S3_BUCKET_NAME = () => envVar
|
|
34
|
+
export const GET_S3_BUCKET_NAME = () => envVar.S3_BUCKET_NAME;
|
|
35
35
|
export const GET_CLIENT_ID = () => client_id;
|
|
36
36
|
export const GET_AUTH_TOKEN = () => auth;
|
|
37
37
|
export const GET_EKA_VOICE_HOST_V1 = () => envVar.EKA_VOICE_HOST_V1;
|
|
@@ -40,4 +40,5 @@ export const GET_EKA_VOICE_HOST_V3 = () => envVar.EKA_VOICE_HOST_V3;
|
|
|
40
40
|
export const GET_COOK_HOST_V1 = () => envVar.COOK_V1;
|
|
41
41
|
export const GET_COG_HOST = () => envVar.COG_HOST;
|
|
42
42
|
export const GET_EKA_HOST = () => envVar.EKA_HOST;
|
|
43
|
+
export const GET_CURRENT_ENV = () => (envVar === PROD ? 'PROD' : 'DEV');
|
|
43
44
|
export default setEnv;
|
|
@@ -41,7 +41,7 @@ onconnect = function (event) {
|
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
case SHARED_WORKER_ACTION.UPLOAD_FILE_WITH_WORKER: {
|
|
44
|
-
const { fileName, audioFrames, txnID, businessID, fileBlob } = workerData.payload;
|
|
44
|
+
const { fileName, audioFrames, txnID, businessID, fileBlob, s3BucketName } = workerData.payload;
|
|
45
45
|
uploadRequestReceived++;
|
|
46
46
|
let audioBlob;
|
|
47
47
|
let compressedAudioBuffer;
|
|
@@ -55,6 +55,7 @@ onconnect = function (event) {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
await pushFileToS3({
|
|
58
|
+
s3BucketName,
|
|
58
59
|
fileBlob: audioBlob,
|
|
59
60
|
fileName,
|
|
60
61
|
txnID,
|
|
@@ -49,7 +49,8 @@ onconnect = function (event: MessageEvent) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
case SHARED_WORKER_ACTION.UPLOAD_FILE_WITH_WORKER: {
|
|
52
|
-
const { fileName, audioFrames, txnID, businessID, fileBlob } =
|
|
52
|
+
const { fileName, audioFrames, txnID, businessID, fileBlob, s3BucketName } =
|
|
53
|
+
workerData.payload;
|
|
53
54
|
uploadRequestReceived++;
|
|
54
55
|
|
|
55
56
|
let audioBlob: Blob;
|
|
@@ -66,6 +67,7 @@ onconnect = function (event: MessageEvent) {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
await pushFileToS3({
|
|
70
|
+
s3BucketName,
|
|
69
71
|
fileBlob: audioBlob,
|
|
70
72
|
fileName,
|
|
71
73
|
txnID,
|