@eka-care/ekascribe-ts-sdk 1.5.80 → 1.5.81
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/api/get-transaction-history.d.ts +5 -0
- package/dist/api/get-transaction-history.js +28 -0
- package/dist/api/get-voice-api-v2-config.d.ts +2 -0
- package/dist/api/get-voice-api-v2-config.js +26 -0
- package/dist/api/get-voice-api-v2-status.d.ts +51 -0
- package/dist/api/get-voice-api-v2-status.js +25 -0
- package/dist/api/get-voice-api-v3-status.d.ts +51 -0
- package/dist/api/get-voice-api-v3-status.js +26 -0
- package/dist/api/patch-transaction-status.d.ts +4 -0
- package/dist/api/patch-transaction-status.js +43 -0
- package/dist/api/post-transaction-commit.d.ts +3 -0
- package/dist/api/post-transaction-commit.js +32 -0
- package/dist/api/post-transaction-init.d.ts +3 -0
- package/dist/api/post-transaction-init.js +40 -0
- package/dist/api/post-transaction-stop.d.ts +3 -0
- package/dist/api/post-transaction-stop.js +32 -0
- package/dist/api/templates/post-convert-transaction-to-template.d.ts +3 -0
- package/dist/api/templates/post-convert-transaction-to-template.js +32 -0
- package/dist/api/transaction/get-voice-api-v2-config.d.ts +2 -0
- package/dist/api/transaction/get-voice-api-v2-config.js +26 -0
- package/dist/api/transaction/get-voice-api-v3-status-transcription.d.ts +61 -0
- package/dist/api/transaction/get-voice-api-v3-status-transcription.js +26 -0
- package/dist/audio-chunker/__tests__/audio-file-manager.test.d.ts +1 -0
- package/dist/audio-chunker/__tests__/audio-file-manager.test.js +5 -0
- package/dist/audio-chunker/audio-file-manager.js +24 -6
- package/dist/shared-worker/s3-file-upload.js +110 -60
- package/dist/shared-worker/s3-file-upload.ts +128 -0
- package/dist/utils/search-sessions-by-patient-name.d.ts +7 -0
- package/dist/utils/search-sessions-by-patient-name.js +27 -0
- package/package.json +2 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SDK_STATUS_CODE } from '../constants/constant';
|
|
2
|
+
import fetchWrapper from '../fetch-client';
|
|
3
|
+
import { GET_EKA_V2RX_HOST_V2 } from '../fetch-client/helper';
|
|
4
|
+
// TODO: pagination changes
|
|
5
|
+
const getTransactionHistory = async ({ txn_count, }) => {
|
|
6
|
+
try {
|
|
7
|
+
const headers = new Headers();
|
|
8
|
+
headers.append('Content-Type', 'application/json');
|
|
9
|
+
const options = {
|
|
10
|
+
method: 'GET',
|
|
11
|
+
headers,
|
|
12
|
+
};
|
|
13
|
+
const responseJson = await fetchWrapper(`${GET_EKA_V2RX_HOST_V2()}/transaction/history?count=${txn_count}`, options);
|
|
14
|
+
const response = await responseJson.json();
|
|
15
|
+
return {
|
|
16
|
+
data: response.data,
|
|
17
|
+
status_code: responseJson.status,
|
|
18
|
+
message: `Past ${txn_count} transactions fetched successfully.`,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return {
|
|
23
|
+
status_code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
24
|
+
message: `Something went wrong in fetching transactions. ${error}`,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export default getTransactionHistory;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SDK_STATUS_CODE } from '../constants/constant';
|
|
2
|
+
import fetchWrapper from '../fetch-client';
|
|
3
|
+
import { GET_EKA_V2RX_HOST_V2 } from '../fetch-client/helper';
|
|
4
|
+
export const getConfigV2 = async () => {
|
|
5
|
+
try {
|
|
6
|
+
const options = {
|
|
7
|
+
method: 'GET',
|
|
8
|
+
headers: {
|
|
9
|
+
'Content-Type': 'application/json',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
const response = await fetchWrapper(`${GET_EKA_V2RX_HOST_V2()}/config/`, options);
|
|
13
|
+
const res = await response.json();
|
|
14
|
+
return {
|
|
15
|
+
...res,
|
|
16
|
+
code: response.status,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.log('Error in getConfigV2 api: ', error);
|
|
21
|
+
return {
|
|
22
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
23
|
+
message: `Failed to fetch initial configurations, ${error}`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type TTemplateMessage = {
|
|
2
|
+
type: 'warning' | 'error';
|
|
3
|
+
code?: string;
|
|
4
|
+
msg: string;
|
|
5
|
+
};
|
|
6
|
+
export type TOutputSummary = {
|
|
7
|
+
template_id: string;
|
|
8
|
+
value?: string | null;
|
|
9
|
+
type: string;
|
|
10
|
+
name: string;
|
|
11
|
+
status: TTemplateStatus;
|
|
12
|
+
errors?: TTemplateMessage[];
|
|
13
|
+
warnings?: TTemplateMessage[];
|
|
14
|
+
};
|
|
15
|
+
export type TTemplateStatus = 'success' | 'partial_success' | 'failure';
|
|
16
|
+
type TAdditionalData = {
|
|
17
|
+
doctor: {
|
|
18
|
+
_id: string;
|
|
19
|
+
profile: {
|
|
20
|
+
personal: {
|
|
21
|
+
name: {
|
|
22
|
+
l: string;
|
|
23
|
+
f: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
type TApiResponse = {
|
|
30
|
+
data: {
|
|
31
|
+
output?: TOutputSummary[];
|
|
32
|
+
additional_data?: TAdditionalData;
|
|
33
|
+
meta_data?: {
|
|
34
|
+
total_resources?: number;
|
|
35
|
+
total_parsed_resources?: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
error?: {
|
|
39
|
+
code: string;
|
|
40
|
+
msg: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export type TGetStatusResponse = {
|
|
44
|
+
response?: TApiResponse | null;
|
|
45
|
+
code: number;
|
|
46
|
+
message?: string;
|
|
47
|
+
};
|
|
48
|
+
export declare const getVoiceApiV2Status: ({ txnId, }: {
|
|
49
|
+
txnId: string;
|
|
50
|
+
}) => Promise<TGetStatusResponse>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SDK_STATUS_CODE } from '../constants/constant';
|
|
2
|
+
import fetchWrapper from '../fetch-client';
|
|
3
|
+
import { GET_EKA_V2RX_HOST_V3 } from '../fetch-client/helper';
|
|
4
|
+
export const getVoiceApiV2Status = async ({ txnId, }) => {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
const options = {
|
|
9
|
+
method: 'GET',
|
|
10
|
+
headers,
|
|
11
|
+
};
|
|
12
|
+
const getResponse = await fetchWrapper(`${GET_EKA_V2RX_HOST_V3()}/status/${txnId}`, options);
|
|
13
|
+
const response = await getResponse.json();
|
|
14
|
+
return {
|
|
15
|
+
response,
|
|
16
|
+
code: getResponse.status,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return {
|
|
21
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
22
|
+
message: `Something went wrong! ${error}`,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type TTemplateMessage = {
|
|
2
|
+
type: 'warning' | 'error';
|
|
3
|
+
code?: string;
|
|
4
|
+
msg: string;
|
|
5
|
+
};
|
|
6
|
+
export type TOutputSummary = {
|
|
7
|
+
template_id: string;
|
|
8
|
+
value?: string | null;
|
|
9
|
+
type: string;
|
|
10
|
+
name: string;
|
|
11
|
+
status: TTemplateStatus;
|
|
12
|
+
errors?: TTemplateMessage[];
|
|
13
|
+
warnings?: TTemplateMessage[];
|
|
14
|
+
};
|
|
15
|
+
export type TTemplateStatus = 'success' | 'partial_success' | 'failure';
|
|
16
|
+
type TAdditionalData = {
|
|
17
|
+
doctor: {
|
|
18
|
+
_id: string;
|
|
19
|
+
profile: {
|
|
20
|
+
personal: {
|
|
21
|
+
name: {
|
|
22
|
+
l: string;
|
|
23
|
+
f: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
type TApiResponse = {
|
|
30
|
+
data: {
|
|
31
|
+
output?: TOutputSummary[];
|
|
32
|
+
additional_data?: TAdditionalData;
|
|
33
|
+
meta_data?: {
|
|
34
|
+
total_resources?: number;
|
|
35
|
+
total_parsed_resources?: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
error?: {
|
|
39
|
+
code: string;
|
|
40
|
+
msg: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export type TGetStatusResponse = {
|
|
44
|
+
response?: TApiResponse | null;
|
|
45
|
+
status_code: number;
|
|
46
|
+
message?: string;
|
|
47
|
+
};
|
|
48
|
+
export declare const getVoiceApiV3Status: ({ txnId, }: {
|
|
49
|
+
txnId: string;
|
|
50
|
+
}) => Promise<TGetStatusResponse>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SDK_STATUS_CODE } from '../constants/constant';
|
|
2
|
+
import fetchWrapper from '../fetch-client';
|
|
3
|
+
import { GET_EKA_V2RX_HOST_V3 } from '../fetch-client/helper';
|
|
4
|
+
export const getVoiceApiV3Status = async ({ txnId, }) => {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
const options = {
|
|
9
|
+
method: 'GET',
|
|
10
|
+
headers,
|
|
11
|
+
};
|
|
12
|
+
// Use custom timeout for this API (16 seconds instead of default 5 seconds)
|
|
13
|
+
const getResponse = await fetchWrapper(`${GET_EKA_V2RX_HOST_V3()}/status/${txnId}`, options, 16000);
|
|
14
|
+
const response = await getResponse.json();
|
|
15
|
+
return {
|
|
16
|
+
response,
|
|
17
|
+
status_code: getResponse.status,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return {
|
|
22
|
+
status_code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
23
|
+
message: `Something went wrong! ${error}`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TPatchTransactionError, TPatchTransactionRequest, TPostTransactionResponse } from '../constants/types';
|
|
2
|
+
export declare const processingError: TPatchTransactionError;
|
|
3
|
+
declare const patchTransactionStatus: ({ sessionId, processing_status, processing_error, }: TPatchTransactionRequest) => Promise<TPostTransactionResponse>;
|
|
4
|
+
export default patchTransactionStatus;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SDK_STATUS_CODE } from '../constants/constant';
|
|
2
|
+
import fetchWrapper from '../fetch-client';
|
|
3
|
+
import { GET_EKA_V2RX_HOST_V2 } from '../fetch-client/helper';
|
|
4
|
+
export const processingError = {
|
|
5
|
+
error: {
|
|
6
|
+
type: '',
|
|
7
|
+
code: 'cancelled_by_user',
|
|
8
|
+
msg: 'Cancelled_by_user',
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
const patchTransactionStatus = async ({ sessionId, processing_status, processing_error, }) => {
|
|
12
|
+
try {
|
|
13
|
+
const headers = new Headers();
|
|
14
|
+
headers.append('Content-Type', 'application/json');
|
|
15
|
+
const raw = {
|
|
16
|
+
processing_status,
|
|
17
|
+
processing_error,
|
|
18
|
+
};
|
|
19
|
+
const options = {
|
|
20
|
+
method: 'PATCH',
|
|
21
|
+
headers,
|
|
22
|
+
body: JSON.stringify(raw),
|
|
23
|
+
};
|
|
24
|
+
const response = await fetchWrapper(`${GET_EKA_V2RX_HOST_V2()}/transaction/${sessionId}`, options);
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
throw new Error(`Error: ${response.statusText}`);
|
|
27
|
+
}
|
|
28
|
+
let res = await response.json();
|
|
29
|
+
res = {
|
|
30
|
+
...res,
|
|
31
|
+
code: response.status,
|
|
32
|
+
};
|
|
33
|
+
return res;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error('Patch transaction status api failed', error);
|
|
37
|
+
return {
|
|
38
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
39
|
+
message: `Something went wrong! ${error}`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export default patchTransactionStatus;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SDK_STATUS_CODE } from '../constants/constant';
|
|
2
|
+
import fetchWrapper from '../fetch-client';
|
|
3
|
+
import { GET_EKA_V2RX_HOST_V2 } from '../fetch-client/helper';
|
|
4
|
+
async function postTransactionCommit({ audioFiles, txnId, }) {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
const raw = {
|
|
9
|
+
audio_files: audioFiles,
|
|
10
|
+
};
|
|
11
|
+
const options = {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
headers,
|
|
14
|
+
body: JSON.stringify(raw),
|
|
15
|
+
};
|
|
16
|
+
const response = await fetchWrapper(`${GET_EKA_V2RX_HOST_V2()}/transaction/commit/${txnId}`, options);
|
|
17
|
+
let res = await response.json();
|
|
18
|
+
res = {
|
|
19
|
+
...res,
|
|
20
|
+
code: response.status,
|
|
21
|
+
};
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.log('%c Line:52 🥖 postTransactionInit -> error', 'color:#f5ce50', error);
|
|
26
|
+
return {
|
|
27
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
28
|
+
message: `Something went wrong! ${error}`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export default postTransactionCommit;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TPostTransactionInitRequest, TPostTransactionResponse } from '../constants/types';
|
|
2
|
+
declare function postTransactionInit({ mode, txnId, s3Url, input_language, output_format_template, model_training_consent, auto_download, transfer, system_info, model_type, }: TPostTransactionInitRequest): Promise<TPostTransactionResponse>;
|
|
3
|
+
export default postTransactionInit;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SDK_STATUS_CODE } from '../constants/constant';
|
|
2
|
+
import fetchWrapper from '../fetch-client';
|
|
3
|
+
import { GET_EKA_V2RX_HOST_V2 } from '../fetch-client/helper';
|
|
4
|
+
async function postTransactionInit({ mode, txnId, s3Url, input_language, output_format_template, model_training_consent, auto_download, transfer, system_info, model_type, }) {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
const raw = {
|
|
9
|
+
mode,
|
|
10
|
+
s3_url: s3Url,
|
|
11
|
+
input_language,
|
|
12
|
+
output_format_template,
|
|
13
|
+
model_training_consent,
|
|
14
|
+
auto_download,
|
|
15
|
+
transfer,
|
|
16
|
+
system_info,
|
|
17
|
+
model_type,
|
|
18
|
+
};
|
|
19
|
+
const options = {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers,
|
|
22
|
+
body: JSON.stringify(raw),
|
|
23
|
+
};
|
|
24
|
+
const response = await fetchWrapper(`${GET_EKA_V2RX_HOST_V2()}/transaction/init/${txnId}`, options);
|
|
25
|
+
let res = await response.json();
|
|
26
|
+
res = {
|
|
27
|
+
...res,
|
|
28
|
+
code: response.status,
|
|
29
|
+
};
|
|
30
|
+
return res;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.log('%c Line:52 🥖 postTransactionInit -> error', 'color:#f5ce50', error);
|
|
34
|
+
return {
|
|
35
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
36
|
+
message: `Something went wrong! ${error}`,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export default postTransactionInit;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SDK_STATUS_CODE } from '../constants/constant';
|
|
2
|
+
import fetchWrapper from '../fetch-client';
|
|
3
|
+
import { GET_EKA_V2RX_HOST_V2 } from '../fetch-client/helper';
|
|
4
|
+
async function postTransactionStop({ txnId, audioFiles, }) {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
const raw = {
|
|
9
|
+
audio_files: audioFiles,
|
|
10
|
+
};
|
|
11
|
+
const options = {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
headers,
|
|
14
|
+
body: JSON.stringify(raw),
|
|
15
|
+
};
|
|
16
|
+
const response = await fetchWrapper(`${GET_EKA_V2RX_HOST_V2()}/transaction/stop/${txnId}`, options);
|
|
17
|
+
let res = await response.json();
|
|
18
|
+
res = {
|
|
19
|
+
...res,
|
|
20
|
+
code: response.status,
|
|
21
|
+
};
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.log('%c Line:52 🥖 postTransactionInit -> error', 'color:#f5ce50', error);
|
|
26
|
+
return {
|
|
27
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
28
|
+
message: `Something went wrong! ${error}`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export default postTransactionStop;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TPostV1ConvertToTemplateRequest, TPostV1ConvertToTemplateResponse } from '../../constants/types';
|
|
2
|
+
declare function postConvertTransactionToTemplate({ txn_id, template_id, transcript, }: TPostV1ConvertToTemplateRequest): Promise<TPostV1ConvertToTemplateResponse>;
|
|
3
|
+
export default postConvertTransactionToTemplate;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SDK_STATUS_CODE } from '../../constants/constant';
|
|
2
|
+
import fetchWrapper from '../../fetch-client';
|
|
3
|
+
import { GET_EKA_VOICE_HOST_V1 } from '../../fetch-client/helper';
|
|
4
|
+
async function postConvertTransactionToTemplate({ txn_id, template_id, transcript, }) {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
const options = {
|
|
9
|
+
method: 'POST',
|
|
10
|
+
headers,
|
|
11
|
+
body: JSON.stringify({
|
|
12
|
+
transcript,
|
|
13
|
+
template_id,
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
const response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V1()}/transaction/${txn_id}/convert-to-template`, options, 60000);
|
|
17
|
+
let res = await response.json();
|
|
18
|
+
res = {
|
|
19
|
+
...res,
|
|
20
|
+
code: response.status,
|
|
21
|
+
};
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.log('%c postV1ConvertToTemplate -> error', 'color:#f5ce50', error);
|
|
26
|
+
return {
|
|
27
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
28
|
+
message: `Something went wrong! ${error}`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export default postConvertTransactionToTemplate;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SDK_STATUS_CODE } from '../../constants/constant';
|
|
2
|
+
import fetchWrapper from '../../fetch-client';
|
|
3
|
+
import { GET_EKA_VOICE_HOST_V2 } from '../../fetch-client/helper';
|
|
4
|
+
export const getConfigV2 = async () => {
|
|
5
|
+
try {
|
|
6
|
+
const options = {
|
|
7
|
+
method: 'GET',
|
|
8
|
+
headers: {
|
|
9
|
+
'Content-Type': 'application/json',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
const response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V2()}/config/`, options);
|
|
13
|
+
const res = await response.json();
|
|
14
|
+
return {
|
|
15
|
+
...res,
|
|
16
|
+
code: response.status,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.log('Error in getConfigV2 api: ', error);
|
|
21
|
+
return {
|
|
22
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
23
|
+
message: `Failed to fetch initial configurations, ${error}`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type TTemplateMessage = {
|
|
2
|
+
type: 'warning' | 'error';
|
|
3
|
+
code?: string;
|
|
4
|
+
msg: string;
|
|
5
|
+
};
|
|
6
|
+
export type TOutputSummary = {
|
|
7
|
+
template_id: string;
|
|
8
|
+
value?: string | null;
|
|
9
|
+
type: string;
|
|
10
|
+
name: string;
|
|
11
|
+
lang?: string;
|
|
12
|
+
status: TTemplateStatus;
|
|
13
|
+
errors?: TTemplateMessage[];
|
|
14
|
+
warnings?: TTemplateMessage[];
|
|
15
|
+
};
|
|
16
|
+
export type TTemplateStatus = 'success' | 'partial_success' | 'failure';
|
|
17
|
+
type TAdditionalData = {
|
|
18
|
+
doctor: {
|
|
19
|
+
_id: string;
|
|
20
|
+
profile: {
|
|
21
|
+
personal: {
|
|
22
|
+
name: {
|
|
23
|
+
l: string;
|
|
24
|
+
f: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
type TApiResponse = {
|
|
31
|
+
data: {
|
|
32
|
+
output: TOutputSummary[];
|
|
33
|
+
audio_matrix?: {
|
|
34
|
+
quality: string;
|
|
35
|
+
};
|
|
36
|
+
additional_data?: TAdditionalData;
|
|
37
|
+
meta_data?: {
|
|
38
|
+
total_resources?: number;
|
|
39
|
+
total_parsed_resources?: number;
|
|
40
|
+
};
|
|
41
|
+
created_at?: string;
|
|
42
|
+
template_results: {
|
|
43
|
+
integration: TOutputSummary[];
|
|
44
|
+
custom: TOutputSummary[];
|
|
45
|
+
transcript: TOutputSummary[];
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
error?: {
|
|
49
|
+
code: string;
|
|
50
|
+
msg: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export type TGetStatusResponse = {
|
|
54
|
+
response?: TApiResponse | null;
|
|
55
|
+
status_code: number;
|
|
56
|
+
message?: string;
|
|
57
|
+
};
|
|
58
|
+
export declare const getVoiceApiV3StatusTranscription: ({ txnId, }: {
|
|
59
|
+
txnId: string;
|
|
60
|
+
}) => Promise<TGetStatusResponse>;
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SDK_STATUS_CODE } from '../../constants/constant';
|
|
2
|
+
import fetchWrapper from '../../fetch-client';
|
|
3
|
+
import { GET_EKA_VOICE_HOST_V3 } from '../../fetch-client/helper';
|
|
4
|
+
export const getVoiceApiV3StatusTranscription = async ({ txnId, }) => {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
const options = {
|
|
9
|
+
method: 'GET',
|
|
10
|
+
headers,
|
|
11
|
+
};
|
|
12
|
+
// Use custom timeout for this API (16 seconds instead of default 5 seconds)
|
|
13
|
+
const getResponse = await fetchWrapper(`${GET_EKA_VOICE_HOST_V3()}/status/transcription/${txnId}`, options, 16000);
|
|
14
|
+
const response = await getResponse.json();
|
|
15
|
+
return {
|
|
16
|
+
response,
|
|
17
|
+
status_code: getResponse.status,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return {
|
|
22
|
+
status_code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
23
|
+
message: `Something went wrong! ${error}`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { AUDIO_EXTENSION_TYPE_MAP, OUTPUT_FORMAT } from '../constants/constant';
|
|
2
|
+
import pushFileToS3 from '../aws-services/upload-file-to-s3';
|
|
1
3
|
import postCogInit from '../api/post-cog-init';
|
|
2
4
|
import { configureAWS } from '../aws-services/configure-aws';
|
|
3
|
-
import pushFileToS3 from '../aws-services/upload-file-to-s3';
|
|
4
|
-
import { AUDIO_EXTENSION_TYPE_MAP, OUTPUT_FORMAT } from '../constants/constant';
|
|
5
5
|
import { CALLBACK_TYPE, SHARED_WORKER_ACTION } from '../constants/enums';
|
|
6
|
-
import { GET_S3_BUCKET_NAME } from '../fetch-client/helper';
|
|
7
|
-
import EkaScribeStore from '../store/store';
|
|
8
6
|
import compressAudioToMp3 from '../utils/compress-mp3-audio';
|
|
7
|
+
import EkaScribeStore from '../store/store';
|
|
8
|
+
import { GET_S3_BUCKET_NAME } from '../fetch-client/helper';
|
|
9
9
|
class AudioFileManager {
|
|
10
10
|
initialiseClassInstance() {
|
|
11
11
|
this.audioChunks = [];
|
|
@@ -246,7 +246,16 @@ class AudioFileManager {
|
|
|
246
246
|
return true;
|
|
247
247
|
}
|
|
248
248
|
catch (error) {
|
|
249
|
-
|
|
249
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
250
|
+
if (errorMessage.includes('SecurityError') || errorMessage.includes('Failed to construct')) {
|
|
251
|
+
console.error('Error creating shared worker instance: CORS/Same-origin policy violation. ' +
|
|
252
|
+
'The SharedWorker script must be served from the same origin as your application, ' +
|
|
253
|
+
'or the server must allow cross-origin access with proper CORS headers. ' +
|
|
254
|
+
'Falling back to non-worker upload method.', error);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
console.error('Error creating shared worker instance:', error);
|
|
258
|
+
}
|
|
250
259
|
return false;
|
|
251
260
|
}
|
|
252
261
|
}
|
|
@@ -428,7 +437,14 @@ class AudioFileManager {
|
|
|
428
437
|
// Shared Workers are supported
|
|
429
438
|
console.log('Shared Workers are supported in this browser.');
|
|
430
439
|
if (!this.sharedWorkerInstance) {
|
|
431
|
-
this.createSharedWorkerInstance();
|
|
440
|
+
const workerCreated = this.createSharedWorkerInstance();
|
|
441
|
+
if (!workerCreated) {
|
|
442
|
+
// SharedWorker creation failed (likely due to CORS/same-origin policy)
|
|
443
|
+
// Fall back to non-worker upload
|
|
444
|
+
console.warn('Failed to create SharedWorker instance. Falling back to non-worker upload method.');
|
|
445
|
+
await this.uploadAudioToS3WithoutWorker({ audioFrames, fileName, chunkIndex });
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
432
448
|
}
|
|
433
449
|
await this.uploadAudioToS3WithWorker({ audioFrames, fileName, chunkIndex });
|
|
434
450
|
}
|
|
@@ -447,6 +463,8 @@ class AudioFileManager {
|
|
|
447
463
|
}
|
|
448
464
|
catch (error) {
|
|
449
465
|
console.error('Error uploading audio to S3: uploadAudioToS3WithWorker: ', error);
|
|
466
|
+
// Fall back to non-worker upload if worker fails
|
|
467
|
+
await this.uploadAudioToS3WithoutWorker({ audioFrames, fileName, chunkIndex });
|
|
450
468
|
}
|
|
451
469
|
}
|
|
452
470
|
async uploadAudioToS3WithoutWorker({ audioFrames, fileName, chunkIndex, }) {
|