@eka-care/ekascribe-ts-sdk 1.4.4 → 1.4.6
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/template-sections/delete-v1-template-section.d.ts +3 -0
- package/dist/api/template-sections/delete-v1-template-section.js +28 -0
- package/dist/api/template-sections/get-v1-template-sections.d.ts +3 -0
- package/dist/api/template-sections/get-v1-template-sections.js +29 -0
- package/dist/api/template-sections/patch-v1-template-section.d.ts +3 -0
- package/dist/api/template-sections/patch-v1-template-section.js +40 -0
- package/dist/api/template-sections/post-v1-template-section.d.ts +3 -0
- package/dist/api/template-sections/post-v1-template-section.js +36 -0
- package/dist/api/templates/delete-v1-template.d.ts +3 -0
- package/dist/api/templates/delete-v1-template.js +28 -0
- package/dist/api/templates/get-v1-templates.d.ts +3 -0
- package/dist/api/templates/get-v1-templates.js +28 -0
- package/dist/api/templates/patch-v1-template.d.ts +3 -0
- package/dist/api/templates/patch-v1-template.js +34 -0
- package/dist/api/templates/post-v1-template.d.ts +3 -0
- package/dist/api/templates/post-v1-template.js +34 -0
- package/dist/api/transaction/get-transaction-history.d.ts +5 -0
- package/dist/api/transaction/get-transaction-history.js +28 -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.d.ts +51 -0
- package/dist/api/transaction/get-voice-api-v3-status.js +26 -0
- package/dist/api/transaction/patch-transaction-status.d.ts +4 -0
- package/dist/api/transaction/patch-transaction-status.js +43 -0
- package/dist/api/transaction/post-transaction-commit.d.ts +3 -0
- package/dist/api/transaction/post-transaction-commit.js +32 -0
- package/dist/api/transaction/post-transaction-init.d.ts +3 -0
- package/dist/api/transaction/post-transaction-init.js +40 -0
- package/dist/api/transaction/post-transaction-stop.d.ts +3 -0
- package/dist/api/transaction/post-transaction-stop.js +32 -0
- package/dist/constants/types.d.ts +68 -0
- package/dist/fetch-client/helper.d.ts +4 -3
- package/dist/fetch-client/helper.js +12 -7
- package/dist/index.d.ts +10 -2
- package/dist/index.js +52 -12
- package/dist/main/end-recording.js +2 -2
- package/dist/main/init-transaction.js +1 -1
- package/dist/main/retry-upload-recording.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
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 deleteV1TemplateSection(section_id) {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
const options = {
|
|
9
|
+
method: 'DELETE',
|
|
10
|
+
headers,
|
|
11
|
+
};
|
|
12
|
+
const response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V1()}/api/v1/template/section/${section_id}`, options);
|
|
13
|
+
let res = await response.json();
|
|
14
|
+
res = {
|
|
15
|
+
...res,
|
|
16
|
+
code: response.status,
|
|
17
|
+
};
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.log('%c deleteV1TemplateSection -> error', 'color:#f5ce50', error);
|
|
22
|
+
return {
|
|
23
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
24
|
+
msg: `Something went wrong! ${error}`,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export default deleteV1TemplateSection;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 getV1TemplateSections() {
|
|
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 response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V1()}/api/v1/template/section`, options);
|
|
13
|
+
let res = await response.json();
|
|
14
|
+
res = {
|
|
15
|
+
...res,
|
|
16
|
+
code: response.status,
|
|
17
|
+
};
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.log('%c getV1TemplateSections -> error', 'color:#f5ce50', error);
|
|
22
|
+
return {
|
|
23
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
24
|
+
default_sections: [],
|
|
25
|
+
custom_sections: [],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export default getV1TemplateSections;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TPostV1TemplateSectionRequest, TPostV1TemplateSectionResponse } from '../../constants/types';
|
|
2
|
+
declare function patchV1TemplateSection({ section_id, template_id, title, desc, format, example, }: TPostV1TemplateSectionRequest): Promise<TPostV1TemplateSectionResponse>;
|
|
3
|
+
export default patchV1TemplateSection;
|
|
@@ -0,0 +1,40 @@
|
|
|
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 patchV1TemplateSection({ section_id, template_id, title, desc, format, example, }) {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
if (template_id) {
|
|
9
|
+
headers.append('template-id', template_id);
|
|
10
|
+
}
|
|
11
|
+
const raw = {
|
|
12
|
+
title,
|
|
13
|
+
desc,
|
|
14
|
+
format,
|
|
15
|
+
example,
|
|
16
|
+
};
|
|
17
|
+
const options = {
|
|
18
|
+
method: 'PATCH',
|
|
19
|
+
headers,
|
|
20
|
+
body: JSON.stringify(raw),
|
|
21
|
+
};
|
|
22
|
+
const response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V1()}/api/v1/template/section/${section_id}`, options);
|
|
23
|
+
let res = await response.json();
|
|
24
|
+
res = {
|
|
25
|
+
...res,
|
|
26
|
+
code: response.status,
|
|
27
|
+
};
|
|
28
|
+
return res;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.log('%c patchV1TemplateSection -> error', 'color:#f5ce50', error);
|
|
32
|
+
return {
|
|
33
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
34
|
+
msg: `Something went wrong! ${error}`,
|
|
35
|
+
section_id: '',
|
|
36
|
+
action: 'updated',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export default patchV1TemplateSection;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TPostV1TemplateSectionRequest, TPostV1TemplateSectionResponse } from '../../constants/types';
|
|
2
|
+
declare function postV1TemplateSection({ title, desc, format, example, }: TPostV1TemplateSectionRequest): Promise<TPostV1TemplateSectionResponse>;
|
|
3
|
+
export default postV1TemplateSection;
|
|
@@ -0,0 +1,36 @@
|
|
|
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 postV1TemplateSection({ title, desc, format, example, }) {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
const raw = {
|
|
9
|
+
title,
|
|
10
|
+
desc,
|
|
11
|
+
format,
|
|
12
|
+
example,
|
|
13
|
+
};
|
|
14
|
+
const options = {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers,
|
|
17
|
+
body: JSON.stringify(raw),
|
|
18
|
+
};
|
|
19
|
+
const response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V1()}/api/v1/template/section`, options);
|
|
20
|
+
let res = await response.json();
|
|
21
|
+
res = {
|
|
22
|
+
...res,
|
|
23
|
+
code: response.status,
|
|
24
|
+
};
|
|
25
|
+
return res;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.log('%c postV1TemplateSection -> error', 'color:#f5ce50', error);
|
|
29
|
+
return {
|
|
30
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
31
|
+
msg: `Something went wrong! ${error}`,
|
|
32
|
+
section_id: '',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export default postV1TemplateSection;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 deleteV1Template(template_id) {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
const options = {
|
|
9
|
+
method: 'DELETE',
|
|
10
|
+
headers,
|
|
11
|
+
};
|
|
12
|
+
const response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V1()}/api/v1/template/${template_id}`, options);
|
|
13
|
+
let res = await response.json();
|
|
14
|
+
res = {
|
|
15
|
+
...res,
|
|
16
|
+
code: response.status,
|
|
17
|
+
};
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.log('%c deleteV1Template -> error', 'color:#f5ce50', error);
|
|
22
|
+
return {
|
|
23
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
24
|
+
msg: `Something went wrong! ${error}`,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export default deleteV1Template;
|
|
@@ -0,0 +1,28 @@
|
|
|
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 getV1Templates() {
|
|
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 response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V1()}/api/v1/template`, options);
|
|
13
|
+
let res = await response.json();
|
|
14
|
+
res = {
|
|
15
|
+
...res,
|
|
16
|
+
code: response.status,
|
|
17
|
+
};
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.log('%c getV1Templates -> error', 'color:#f5ce50', error);
|
|
22
|
+
return {
|
|
23
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
24
|
+
items: [],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export default getV1Templates;
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
export async function patchV1Template({ template_id, title, desc, section_ids, }) {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
const raw = {
|
|
9
|
+
title,
|
|
10
|
+
desc,
|
|
11
|
+
section_ids,
|
|
12
|
+
};
|
|
13
|
+
const options = {
|
|
14
|
+
method: 'PATCH',
|
|
15
|
+
headers,
|
|
16
|
+
body: JSON.stringify(raw),
|
|
17
|
+
};
|
|
18
|
+
const response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V1()}/api/v1/template/${template_id}`, options);
|
|
19
|
+
let res = await response.json();
|
|
20
|
+
res = {
|
|
21
|
+
...res,
|
|
22
|
+
code: response.status,
|
|
23
|
+
};
|
|
24
|
+
return res;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.log('%c patchV1Template -> error', 'color:#f5ce50', error);
|
|
28
|
+
return {
|
|
29
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
30
|
+
msg: `Something went wrong! ${error}`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export default patchV1Template;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 postV1Template({ title, desc, section_ids, }) {
|
|
5
|
+
try {
|
|
6
|
+
const headers = new Headers();
|
|
7
|
+
headers.append('Content-Type', 'application/json');
|
|
8
|
+
const raw = {
|
|
9
|
+
title,
|
|
10
|
+
desc,
|
|
11
|
+
section_ids,
|
|
12
|
+
};
|
|
13
|
+
const options = {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
headers,
|
|
16
|
+
body: JSON.stringify(raw),
|
|
17
|
+
};
|
|
18
|
+
const response = await fetchWrapper(`${GET_EKA_VOICE_HOST_V1()}/api/v1/template`, options);
|
|
19
|
+
let res = await response.json();
|
|
20
|
+
res = {
|
|
21
|
+
...res,
|
|
22
|
+
code: response.status,
|
|
23
|
+
};
|
|
24
|
+
return res;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.log('%c postV1Template -> error', 'color:#f5ce50', error);
|
|
28
|
+
return {
|
|
29
|
+
code: SDK_STATUS_CODE.INTERNAL_SERVER_ERROR,
|
|
30
|
+
message: `Something went wrong! ${error}`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export default postV1Template;
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
// 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_VOICE_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_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,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_VOICE_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_VOICE_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_VOICE_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_VOICE_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_VOICE_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_VOICE_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, patient_details, }: 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_VOICE_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, patient_details, }) {
|
|
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
|
+
patient_details,
|
|
18
|
+
};
|
|
19
|
+
const options = {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers,
|
|
22
|
+
body: JSON.stringify(raw),
|
|
23
|
+
};
|
|
24
|
+
const response = await fetchWrapper(`${GET_EKA_VOICE_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_VOICE_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_VOICE_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;
|
|
@@ -222,3 +222,71 @@ export type TFileUploadProgressCallback = (args: {
|
|
|
222
222
|
msg: string;
|
|
223
223
|
};
|
|
224
224
|
}) => void;
|
|
225
|
+
export interface TPostV1TemplateRequest {
|
|
226
|
+
title: string;
|
|
227
|
+
desc?: string;
|
|
228
|
+
section_ids: string[];
|
|
229
|
+
template_id?: string;
|
|
230
|
+
}
|
|
231
|
+
export interface TPostV1TemplateResponse {
|
|
232
|
+
code: number;
|
|
233
|
+
msg: string;
|
|
234
|
+
template_id?: string;
|
|
235
|
+
message?: string;
|
|
236
|
+
error?: {
|
|
237
|
+
code: string;
|
|
238
|
+
msg: string;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
export interface TTemplate {
|
|
242
|
+
id: string;
|
|
243
|
+
title: string;
|
|
244
|
+
desc: string;
|
|
245
|
+
section_ids: string[];
|
|
246
|
+
sections: TSection[];
|
|
247
|
+
is_editable: boolean;
|
|
248
|
+
}
|
|
249
|
+
export interface TGetV1TemplatesResponse {
|
|
250
|
+
items: TTemplate[];
|
|
251
|
+
code: number;
|
|
252
|
+
error?: {
|
|
253
|
+
code: string;
|
|
254
|
+
msg: string;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
export interface TPostV1TemplateSectionRequest {
|
|
258
|
+
title: string;
|
|
259
|
+
desc?: string;
|
|
260
|
+
format?: 'P' | 'B';
|
|
261
|
+
example?: string;
|
|
262
|
+
template_id?: string;
|
|
263
|
+
section_id?: string;
|
|
264
|
+
}
|
|
265
|
+
export interface TPostV1TemplateSectionResponse {
|
|
266
|
+
msg: string;
|
|
267
|
+
section_id: string;
|
|
268
|
+
code: number;
|
|
269
|
+
action: 'updated' | 'created_custom';
|
|
270
|
+
error?: {
|
|
271
|
+
code: string;
|
|
272
|
+
msg: string;
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
export interface TSection {
|
|
276
|
+
id: string;
|
|
277
|
+
title: string;
|
|
278
|
+
desc: string;
|
|
279
|
+
format: 'P' | 'B';
|
|
280
|
+
example: string;
|
|
281
|
+
custom: boolean;
|
|
282
|
+
parent_section_id?: string;
|
|
283
|
+
}
|
|
284
|
+
export interface TGetV1TemplateSectionsResponse {
|
|
285
|
+
default_sections: TSection[];
|
|
286
|
+
custom_sections: TSection[];
|
|
287
|
+
code: number;
|
|
288
|
+
error?: {
|
|
289
|
+
code: string;
|
|
290
|
+
message: string;
|
|
291
|
+
};
|
|
292
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
declare const setEnv: ({ env, clientId, auth_token, }: {
|
|
2
2
|
env?: "PROD" | "DEV";
|
|
3
3
|
clientId?: string;
|
|
4
|
-
auth_token
|
|
4
|
+
auth_token?: string;
|
|
5
5
|
}) => void;
|
|
6
6
|
export declare const GET_EKA_HOST: () => string;
|
|
7
7
|
export declare const GET_CLIENT_ID: () => string;
|
|
8
8
|
export declare const GET_AUTH_TOKEN: () => string;
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
9
|
+
export declare const GET_EKA_VOICE_HOST_V1: () => string;
|
|
10
|
+
export declare const GET_EKA_VOICE_HOST_V2: () => string;
|
|
11
|
+
export declare const GET_EKA_VOICE_HOST_V3: () => string;
|
|
11
12
|
export default setEnv;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
const DEV = {
|
|
2
2
|
EKA_HOST: 'https://api.dev.eka.care',
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
EKA_VOICE_HOST_V1: 'https://api.dev.eka.care/api/v1',
|
|
4
|
+
EKA_VOICE_HOST_V2: 'https://v2rxbe.dev.eka.care/voice/api/v2',
|
|
5
|
+
EKA_VOICE_HOST_V3: 'https://v2rxbe.dev.eka.care/voice/api/v3',
|
|
5
6
|
};
|
|
6
7
|
const PROD = {
|
|
7
8
|
EKA_HOST: 'https://api.eka.care',
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
EKA_VOICE_HOST_V1: 'https://api.eka.care/voice/api/v1',
|
|
10
|
+
EKA_VOICE_HOST_V2: 'https://api.eka.care/voice/api/v2',
|
|
11
|
+
EKA_VOICE_HOST_V3: 'https://api.eka.care/voice/api/v3',
|
|
10
12
|
};
|
|
11
13
|
let envVar = PROD;
|
|
12
14
|
let client_id = 'doc-web';
|
|
@@ -18,11 +20,14 @@ const setEnv = ({ env, clientId, auth_token, }) => {
|
|
|
18
20
|
if (clientId) {
|
|
19
21
|
client_id = clientId;
|
|
20
22
|
}
|
|
21
|
-
|
|
23
|
+
if (auth_token) {
|
|
24
|
+
auth = auth_token;
|
|
25
|
+
}
|
|
22
26
|
};
|
|
23
27
|
export const GET_EKA_HOST = () => envVar.EKA_HOST;
|
|
24
28
|
export const GET_CLIENT_ID = () => client_id;
|
|
25
29
|
export const GET_AUTH_TOKEN = () => auth;
|
|
26
|
-
export const
|
|
27
|
-
export const
|
|
30
|
+
export const GET_EKA_VOICE_HOST_V1 = () => envVar.EKA_VOICE_HOST_V1;
|
|
31
|
+
export const GET_EKA_VOICE_HOST_V2 = () => envVar.EKA_VOICE_HOST_V2;
|
|
32
|
+
export const GET_EKA_VOICE_HOST_V3 = () => envVar.EKA_VOICE_HOST_V3;
|
|
28
33
|
export default setEnv;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TGetStatusResponse } from './api/get-voice-api-v3-status';
|
|
2
|
-
import { TEndRecordingResponse, TErrorCallback, TFileUploadProgressCallback, TGetTransactionHistoryResponse, TPatchTransactionRequest, TPostTransactionResponse, TStartRecordingRequest } from './constants/types';
|
|
1
|
+
import { TGetStatusResponse } from './api/transaction/get-voice-api-v3-status';
|
|
2
|
+
import { TEndRecordingResponse, TErrorCallback, TFileUploadProgressCallback, TGetTransactionHistoryResponse, TPatchTransactionRequest, TPostTransactionResponse, TPostV1TemplateRequest, TPostV1TemplateSectionRequest, TStartRecordingRequest } from './constants/types';
|
|
3
3
|
declare class EkaScribe {
|
|
4
4
|
private static instance;
|
|
5
5
|
private vadInstance;
|
|
@@ -51,6 +51,14 @@ declare class EkaScribe {
|
|
|
51
51
|
short_thsld: number;
|
|
52
52
|
long_thsld: number;
|
|
53
53
|
}): void;
|
|
54
|
+
getAllTemplates(): Promise<import("./constants/types").TGetV1TemplatesResponse>;
|
|
55
|
+
createTemplate(template: TPostV1TemplateRequest): Promise<import("./constants/types").TPostV1TemplateResponse>;
|
|
56
|
+
updateTemplate(template: TPostV1TemplateRequest): Promise<import("./constants/types").TPostV1TemplateResponse>;
|
|
57
|
+
deleteTemplate(template_id: string): Promise<import("./constants/types").TPostV1TemplateResponse>;
|
|
58
|
+
getAllTemplateSections(): Promise<import("./constants/types").TGetV1TemplateSectionsResponse>;
|
|
59
|
+
createTemplateSection(templateSection: TPostV1TemplateSectionRequest): Promise<import("./constants/types").TPostV1TemplateSectionResponse>;
|
|
60
|
+
updateTemplateSection(templateSection: TPostV1TemplateSectionRequest): Promise<import("./constants/types").TPostV1TemplateSectionResponse>;
|
|
61
|
+
deleteTemplateSection(section_id: string): Promise<import("./constants/types").TPostV1TemplateSectionResponse>;
|
|
54
62
|
}
|
|
55
63
|
export declare const getEkaScribeInstance: ({ access_token, env, clientId, }: {
|
|
56
64
|
access_token?: string;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// ekascribe main Class having all the methods - Entry point
|
|
2
|
-
import { getConfigV2 } from './api/get-voice-api-v2-config';
|
|
3
|
-
import { getVoiceApiV3Status } from './api/get-voice-api-v3-status';
|
|
4
|
-
import patchTransactionStatus from './api/patch-transaction-status';
|
|
5
|
-
import postTransactionCommit from './api/post-transaction-commit';
|
|
2
|
+
import { getConfigV2 } from './api/transaction/get-voice-api-v2-config';
|
|
3
|
+
import { getVoiceApiV3Status } from './api/transaction/get-voice-api-v3-status';
|
|
4
|
+
import patchTransactionStatus from './api/transaction/patch-transaction-status';
|
|
5
|
+
import postTransactionCommit from './api/transaction/post-transaction-commit';
|
|
6
6
|
import AudioBufferManager from './audio-chunker/audio-buffer-manager';
|
|
7
7
|
import AudioFileManager from './audio-chunker/audio-file-manager';
|
|
8
8
|
import VadWebClient from './audio-chunker/vad-web';
|
|
@@ -16,7 +16,15 @@ import retryUploadFailedFiles from './main/retry-upload-recording';
|
|
|
16
16
|
import startVoiceRecording from './main/start-recording';
|
|
17
17
|
import EkaScribeStore from './store/store';
|
|
18
18
|
import initialiseTransaction from './main/init-transaction';
|
|
19
|
-
import getTransactionHistory from './api/get-transaction-history';
|
|
19
|
+
import getTransactionHistory from './api/transaction/get-transaction-history';
|
|
20
|
+
import getV1Templates from './api/templates/get-v1-templates';
|
|
21
|
+
import postV1Template from './api/templates/post-v1-template';
|
|
22
|
+
import patchV1Template from './api/templates/patch-v1-template';
|
|
23
|
+
import deleteV1Template from './api/templates/delete-v1-template';
|
|
24
|
+
import getV1TemplateSections from './api/template-sections/get-v1-template-sections';
|
|
25
|
+
import postV1TemplateSection from './api/template-sections/post-v1-template-section';
|
|
26
|
+
import patchV1TemplateSection from './api/template-sections/patch-v1-template-section';
|
|
27
|
+
import deleteV1TemplateSection from './api/template-sections/delete-v1-template-section';
|
|
20
28
|
class EkaScribe {
|
|
21
29
|
// Private constructor to prevent direct instantiation
|
|
22
30
|
constructor() {
|
|
@@ -50,13 +58,11 @@ class EkaScribe {
|
|
|
50
58
|
}
|
|
51
59
|
// Static method to get the singleton instance with optional initialization
|
|
52
60
|
static getInstance({ access_token, env, clientId, }) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
}
|
|
61
|
+
setEnv({
|
|
62
|
+
...(access_token ? { auth_token: access_token } : {}),
|
|
63
|
+
...(env ? { env } : {}),
|
|
64
|
+
...(clientId ? { clientId } : {}),
|
|
65
|
+
});
|
|
60
66
|
if (!EkaScribe.instance) {
|
|
61
67
|
EkaScribe.instance = new EkaScribe();
|
|
62
68
|
console.log('EkaScribe.instance', EkaScribe.instance);
|
|
@@ -257,6 +263,40 @@ class EkaScribe {
|
|
|
257
263
|
long_thsld,
|
|
258
264
|
});
|
|
259
265
|
}
|
|
266
|
+
// Template SDK methods
|
|
267
|
+
async getAllTemplates() {
|
|
268
|
+
const templatesResponse = await getV1Templates();
|
|
269
|
+
return templatesResponse;
|
|
270
|
+
}
|
|
271
|
+
async createTemplate(template) {
|
|
272
|
+
const templatesResponse = await postV1Template(template);
|
|
273
|
+
return templatesResponse;
|
|
274
|
+
}
|
|
275
|
+
async updateTemplate(template) {
|
|
276
|
+
const templatesResponse = await patchV1Template(template);
|
|
277
|
+
return templatesResponse;
|
|
278
|
+
}
|
|
279
|
+
async deleteTemplate(template_id) {
|
|
280
|
+
const templatesResponse = await deleteV1Template(template_id);
|
|
281
|
+
return templatesResponse;
|
|
282
|
+
}
|
|
283
|
+
// Template Section SDK methods
|
|
284
|
+
async getAllTemplateSections() {
|
|
285
|
+
const templateSectionsResponse = await getV1TemplateSections();
|
|
286
|
+
return templateSectionsResponse;
|
|
287
|
+
}
|
|
288
|
+
async createTemplateSection(templateSection) {
|
|
289
|
+
const templateSectionsResponse = await postV1TemplateSection(templateSection);
|
|
290
|
+
return templateSectionsResponse;
|
|
291
|
+
}
|
|
292
|
+
async updateTemplateSection(templateSection) {
|
|
293
|
+
const templateSectionsResponse = await patchV1TemplateSection(templateSection);
|
|
294
|
+
return templateSectionsResponse;
|
|
295
|
+
}
|
|
296
|
+
async deleteTemplateSection(section_id) {
|
|
297
|
+
const templateSectionsResponse = await deleteV1TemplateSection(section_id);
|
|
298
|
+
return templateSectionsResponse;
|
|
299
|
+
}
|
|
260
300
|
}
|
|
261
301
|
Object.defineProperty(EkaScribe, "instance", {
|
|
262
302
|
enumerable: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import postTransactionCommit from '../api/post-transaction-commit';
|
|
2
|
-
import postTransactionStop from '../api/post-transaction-stop';
|
|
1
|
+
import postTransactionCommit from '../api/transaction/post-transaction-commit';
|
|
2
|
+
import postTransactionStop from '../api/transaction/post-transaction-stop';
|
|
3
3
|
import { OUTPUT_FORMAT, SDK_STATUS_CODE } from '../constants/constant';
|
|
4
4
|
import { ERROR_CODE } from '../constants/enums';
|
|
5
5
|
import EkaScribeStore from '../store/store';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import postTransactionInit from '../api/post-transaction-init';
|
|
1
|
+
import postTransactionInit from '../api/transaction/post-transaction-init';
|
|
2
2
|
import { S3_BUCKET_NAME, SDK_STATUS_CODE } from '../constants/constant';
|
|
3
3
|
import { ERROR_CODE } from '../constants/enums';
|
|
4
4
|
import EkaScribeStore from '../store/store';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import postTransactionCommit from '../api/post-transaction-commit';
|
|
1
|
+
import postTransactionCommit from '../api/transaction/post-transaction-commit';
|
|
2
2
|
import { SDK_STATUS_CODE } from '../constants/constant';
|
|
3
3
|
import { ERROR_CODE } from '../constants/enums';
|
|
4
4
|
import EkaScribeStore from '../store/store';
|