@eka-care/ekascribe-ts-sdk 1.5.83 → 1.5.85
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 +6 -9
- package/dist/constants/types.d.ts +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/main/poll-output-summary.d.ts +49 -0
- package/dist/main/poll-output-summary.js +71 -0
- 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
- package/dist/shared-worker/worker-code.generated.d.ts +0 -1
- package/dist/shared-worker/worker-code.generated.js +0 -4
|
@@ -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,12 +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 { SHARED_WORKER_CODE } from '../shared-worker/worker-code.generated';
|
|
8
|
-
import EkaScribeStore from '../store/store';
|
|
9
6
|
import compressAudioToMp3 from '../utils/compress-mp3-audio';
|
|
7
|
+
import EkaScribeStore from '../store/store';
|
|
8
|
+
import { GET_S3_BUCKET_NAME } from '../fetch-client/helper';
|
|
10
9
|
class AudioFileManager {
|
|
11
10
|
initialiseClassInstance() {
|
|
12
11
|
this.audioChunks = [];
|
|
@@ -134,10 +133,8 @@ class AudioFileManager {
|
|
|
134
133
|
}
|
|
135
134
|
createSharedWorkerInstance() {
|
|
136
135
|
try {
|
|
137
|
-
//
|
|
138
|
-
const
|
|
139
|
-
const workerUrl = URL.createObjectURL(blob);
|
|
140
|
-
const worker = new SharedWorker(workerUrl);
|
|
136
|
+
// new URL(relativeOrAbsolutePath, baseUrl)
|
|
137
|
+
const worker = new SharedWorker(new URL('../shared-worker/s3-file-upload.js', import.meta.url));
|
|
141
138
|
this.sharedWorkerInstance = worker;
|
|
142
139
|
const onEventCallback = EkaScribeStore.eventCallback;
|
|
143
140
|
this.sharedWorkerInstance.port.onmessage = async (event) => {
|
|
@@ -66,7 +66,7 @@ export type TStartRecordingRequest = {
|
|
|
66
66
|
auto_download: boolean;
|
|
67
67
|
model_training_consent: boolean;
|
|
68
68
|
transfer: string;
|
|
69
|
-
system_info
|
|
69
|
+
system_info?: TSystemInfo;
|
|
70
70
|
patient_details?: TPatientDetails;
|
|
71
71
|
model_type: string;
|
|
72
72
|
version?: string;
|
|
@@ -131,7 +131,7 @@ export type TPostTransactionInitRequest = {
|
|
|
131
131
|
transfer: string;
|
|
132
132
|
auto_download: boolean;
|
|
133
133
|
model_training_consent: boolean;
|
|
134
|
-
system_info
|
|
134
|
+
system_info?: TSystemInfo;
|
|
135
135
|
patient_details?: TPatientDetails;
|
|
136
136
|
model_type: string;
|
|
137
137
|
version?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,10 @@ declare class EkaScribe {
|
|
|
37
37
|
getOutputTranscription({ txn_id }: {
|
|
38
38
|
txn_id: string;
|
|
39
39
|
}): Promise<TGetStatusResponse>;
|
|
40
|
+
pollSessionOutput(request: {
|
|
41
|
+
txn_id: string;
|
|
42
|
+
max_polling_time: number;
|
|
43
|
+
}): Promise<import("./main/poll-output-summary").TPollingResponse>;
|
|
40
44
|
getSessionHistory({ txn_count }: {
|
|
41
45
|
txn_count: number;
|
|
42
46
|
}): Promise<TGetTransactionHistoryResponse>;
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ import { getConfigV2MyTemplates } from './api/config/get-voice-api-v2-config-my-
|
|
|
34
34
|
import putVoiceApiV2Config from './api/config/patch-voice-api-v2-config';
|
|
35
35
|
import postConvertTranscriptionToTemplate from './api/templates/post-convert-transcription-to-template';
|
|
36
36
|
import { getVoiceApiV3StatusTranscript } from './api/transaction/get-voice-api-v3-status-transcript';
|
|
37
|
+
import { pollOutputSummary } from './main/poll-output-summary';
|
|
37
38
|
class EkaScribe {
|
|
38
39
|
// Private constructor to prevent direct instantiation
|
|
39
40
|
constructor() {
|
|
@@ -251,6 +252,10 @@ class EkaScribe {
|
|
|
251
252
|
};
|
|
252
253
|
}
|
|
253
254
|
}
|
|
255
|
+
async pollSessionOutput(request) {
|
|
256
|
+
const pollingResponse = await pollOutputSummary(request);
|
|
257
|
+
return pollingResponse;
|
|
258
|
+
}
|
|
254
259
|
async getSessionHistory({ txn_count }) {
|
|
255
260
|
try {
|
|
256
261
|
const transactionsResponse = await getTransactionHistory({
|