@eka-care/ekascribe-ts-sdk 1.4.39
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/README.md +437 -0
- 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-cog-init.d.ts +3 -0
- package/dist/api/post-cog-init.js +15 -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/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-buffer-manager.d.ts +53 -0
- package/dist/audio-chunker/audio-buffer-manager.js +136 -0
- package/dist/audio-chunker/audio-file-manager.d.ts +96 -0
- package/dist/audio-chunker/audio-file-manager.js +579 -0
- package/dist/audio-chunker/vad-web.d.ts +90 -0
- package/dist/audio-chunker/vad-web.js +389 -0
- package/dist/aws-services/configure-aws.d.ts +5 -0
- package/dist/aws-services/configure-aws.js +13 -0
- package/dist/aws-services/get-files-s3.d.ts +10 -0
- package/dist/aws-services/get-files-s3.js +30 -0
- package/dist/aws-services/s3-retry-wrapper.d.ts +2 -0
- package/dist/aws-services/s3-retry-wrapper.js +38 -0
- package/dist/aws-services/translate-text-to-target-language.d.ts +6 -0
- package/dist/aws-services/translate-text-to-target-language.js +18 -0
- package/dist/aws-services/upload-file-to-s3.d.ts +13 -0
- package/dist/aws-services/upload-file-to-s3.js +48 -0
- package/dist/constants/constant.d.ts +27 -0
- package/dist/constants/constant.js +33 -0
- package/dist/constants/enums.d.ts +46 -0
- package/dist/constants/enums.js +51 -0
- package/dist/constants/setup-config.d.ts +14 -0
- package/dist/constants/setup-config.js +31 -0
- package/dist/constants/types.d.ts +224 -0
- package/dist/constants/types.js +1 -0
- package/dist/fetch-client/helper.d.ts +11 -0
- package/dist/fetch-client/helper.js +28 -0
- package/dist/fetch-client/index.d.ts +1 -0
- package/dist/fetch-client/index.js +36 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +267 -0
- package/dist/main/end-recording.d.ts +3 -0
- package/dist/main/end-recording.js +141 -0
- package/dist/main/init-transaction.d.ts +3 -0
- package/dist/main/init-transaction.js +86 -0
- package/dist/main/pause-recording.d.ts +3 -0
- package/dist/main/pause-recording.js +59 -0
- package/dist/main/resume-recording.d.ts +3 -0
- package/dist/main/resume-recording.js +33 -0
- package/dist/main/retry-upload-recording.d.ts +5 -0
- package/dist/main/retry-upload-recording.js +69 -0
- package/dist/main/start-recording.d.ts +3 -0
- package/dist/main/start-recording.js +55 -0
- package/dist/shared-worker/s3-file-upload.d.ts +1 -0
- package/dist/shared-worker/s3-file-upload.js +109 -0
- package/dist/shared-worker/s3-file-upload.ts +126 -0
- package/dist/store/store.d.ts +35 -0
- package/dist/store/store.js +121 -0
- package/dist/utils/compress-mp3-audio.d.ts +2 -0
- package/dist/utils/compress-mp3-audio.js +24 -0
- package/package.json +53 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare enum TEMPLATE_ID {
|
|
2
|
+
EKA_EMR_TEMPLATE = "eka_emr_template",
|
|
3
|
+
CLINICAL_NOTE_TEMPLATE = "clinical_notes_template",
|
|
4
|
+
TRANSCRIPT_TEMPLATE = "transcript_template",
|
|
5
|
+
EKA_EMR_TO_FHIR_TEMPLATE = "eka_emr_to_fhir_template",
|
|
6
|
+
NIC_TEMPLATE = "nic_template"
|
|
7
|
+
}
|
|
8
|
+
export declare enum RESULT_STATUS {
|
|
9
|
+
SUCCESS = "success",
|
|
10
|
+
FAILURE = "failure",
|
|
11
|
+
PARTIAL_COMPLETE = "partial_complete",
|
|
12
|
+
IN_PROGRESS = "in-progress"
|
|
13
|
+
}
|
|
14
|
+
export declare enum ERROR_CODE {
|
|
15
|
+
MICROPHONE = "microphone",
|
|
16
|
+
TXN_INIT_FAILED = "txn_init_failed",
|
|
17
|
+
TXN_LIMIT_EXCEEDED = "txn_limit_exceeded",
|
|
18
|
+
INTERNAL_SERVER_ERROR = "internal_server_error",
|
|
19
|
+
TXN_STOP_FAILED = "txn_stop_failed",
|
|
20
|
+
AUDIO_UPLOAD_FAILED = "audio_upload_failed",
|
|
21
|
+
TXN_COMMIT_FAILED = "txn_commit_failed",
|
|
22
|
+
INVALID_REQUEST = "invalid_request",
|
|
23
|
+
VAD_NOT_INITIALIZED = "vad_not_initialized",
|
|
24
|
+
NO_AUDIO_CAPTURE = "no_audio_capture",
|
|
25
|
+
SPEECH_DETECTED = "speech_detected",
|
|
26
|
+
TXN_STATUS_MISMATCH = "txn_status_mismatch",
|
|
27
|
+
LONG_SILENCE = "long_silence"
|
|
28
|
+
}
|
|
29
|
+
export declare enum PROCESSING_STATUS {
|
|
30
|
+
SUCCESS = "success",
|
|
31
|
+
IN_PROGRESS = "in-progress",
|
|
32
|
+
FAILED = "failed",
|
|
33
|
+
CANCELLED = "cancelled"
|
|
34
|
+
}
|
|
35
|
+
export declare enum SHARED_WORKER_ACTION {
|
|
36
|
+
UPLOAD_FILE_WITH_WORKER = "upload_file_with_worker",
|
|
37
|
+
UPLOAD_FILE_WITH_WORKER_SUCCESS = "upload_file_with_worker_success",
|
|
38
|
+
UPLOAD_FILE_WITH_WORKER_ERROR = "upload_file_with_worker_error",
|
|
39
|
+
TEST_WORKER = "test_worker",
|
|
40
|
+
CONFIGURE_AWS = "configure_aws",
|
|
41
|
+
CONFIGURE_AWS_SUCCESS = "configure_aws_success",
|
|
42
|
+
CONFIGURE_AWS_ERROR = "configure_aws_error",
|
|
43
|
+
WAIT_FOR_ALL_UPLOADS = "wait_for_all_uploads",
|
|
44
|
+
WAIT_FOR_ALL_UPLOADS_SUCCESS = "wait_for_all_uploads_success",
|
|
45
|
+
WAIT_FOR_ALL_UPLOADS_ERROR = "wait_for_all_uploads_error"
|
|
46
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export var TEMPLATE_ID;
|
|
2
|
+
(function (TEMPLATE_ID) {
|
|
3
|
+
TEMPLATE_ID["EKA_EMR_TEMPLATE"] = "eka_emr_template";
|
|
4
|
+
TEMPLATE_ID["CLINICAL_NOTE_TEMPLATE"] = "clinical_notes_template";
|
|
5
|
+
TEMPLATE_ID["TRANSCRIPT_TEMPLATE"] = "transcript_template";
|
|
6
|
+
TEMPLATE_ID["EKA_EMR_TO_FHIR_TEMPLATE"] = "eka_emr_to_fhir_template";
|
|
7
|
+
TEMPLATE_ID["NIC_TEMPLATE"] = "nic_template";
|
|
8
|
+
})(TEMPLATE_ID || (TEMPLATE_ID = {}));
|
|
9
|
+
export var RESULT_STATUS;
|
|
10
|
+
(function (RESULT_STATUS) {
|
|
11
|
+
RESULT_STATUS["SUCCESS"] = "success";
|
|
12
|
+
RESULT_STATUS["FAILURE"] = "failure";
|
|
13
|
+
RESULT_STATUS["PARTIAL_COMPLETE"] = "partial_complete";
|
|
14
|
+
RESULT_STATUS["IN_PROGRESS"] = "in-progress";
|
|
15
|
+
})(RESULT_STATUS || (RESULT_STATUS = {}));
|
|
16
|
+
export var ERROR_CODE;
|
|
17
|
+
(function (ERROR_CODE) {
|
|
18
|
+
ERROR_CODE["MICROPHONE"] = "microphone";
|
|
19
|
+
ERROR_CODE["TXN_INIT_FAILED"] = "txn_init_failed";
|
|
20
|
+
ERROR_CODE["TXN_LIMIT_EXCEEDED"] = "txn_limit_exceeded";
|
|
21
|
+
ERROR_CODE["INTERNAL_SERVER_ERROR"] = "internal_server_error";
|
|
22
|
+
ERROR_CODE["TXN_STOP_FAILED"] = "txn_stop_failed";
|
|
23
|
+
ERROR_CODE["AUDIO_UPLOAD_FAILED"] = "audio_upload_failed";
|
|
24
|
+
ERROR_CODE["TXN_COMMIT_FAILED"] = "txn_commit_failed";
|
|
25
|
+
ERROR_CODE["INVALID_REQUEST"] = "invalid_request";
|
|
26
|
+
ERROR_CODE["VAD_NOT_INITIALIZED"] = "vad_not_initialized";
|
|
27
|
+
ERROR_CODE["NO_AUDIO_CAPTURE"] = "no_audio_capture";
|
|
28
|
+
ERROR_CODE["SPEECH_DETECTED"] = "speech_detected";
|
|
29
|
+
ERROR_CODE["TXN_STATUS_MISMATCH"] = "txn_status_mismatch";
|
|
30
|
+
ERROR_CODE["LONG_SILENCE"] = "long_silence";
|
|
31
|
+
})(ERROR_CODE || (ERROR_CODE = {}));
|
|
32
|
+
export var PROCESSING_STATUS;
|
|
33
|
+
(function (PROCESSING_STATUS) {
|
|
34
|
+
PROCESSING_STATUS["SUCCESS"] = "success";
|
|
35
|
+
PROCESSING_STATUS["IN_PROGRESS"] = "in-progress";
|
|
36
|
+
PROCESSING_STATUS["FAILED"] = "failed";
|
|
37
|
+
PROCESSING_STATUS["CANCELLED"] = "cancelled";
|
|
38
|
+
})(PROCESSING_STATUS || (PROCESSING_STATUS = {}));
|
|
39
|
+
export var SHARED_WORKER_ACTION;
|
|
40
|
+
(function (SHARED_WORKER_ACTION) {
|
|
41
|
+
SHARED_WORKER_ACTION["UPLOAD_FILE_WITH_WORKER"] = "upload_file_with_worker";
|
|
42
|
+
SHARED_WORKER_ACTION["UPLOAD_FILE_WITH_WORKER_SUCCESS"] = "upload_file_with_worker_success";
|
|
43
|
+
SHARED_WORKER_ACTION["UPLOAD_FILE_WITH_WORKER_ERROR"] = "upload_file_with_worker_error";
|
|
44
|
+
SHARED_WORKER_ACTION["TEST_WORKER"] = "test_worker";
|
|
45
|
+
SHARED_WORKER_ACTION["CONFIGURE_AWS"] = "configure_aws";
|
|
46
|
+
SHARED_WORKER_ACTION["CONFIGURE_AWS_SUCCESS"] = "configure_aws_success";
|
|
47
|
+
SHARED_WORKER_ACTION["CONFIGURE_AWS_ERROR"] = "configure_aws_error";
|
|
48
|
+
SHARED_WORKER_ACTION["WAIT_FOR_ALL_UPLOADS"] = "wait_for_all_uploads";
|
|
49
|
+
SHARED_WORKER_ACTION["WAIT_FOR_ALL_UPLOADS_SUCCESS"] = "wait_for_all_uploads_success";
|
|
50
|
+
SHARED_WORKER_ACTION["WAIT_FOR_ALL_UPLOADS_ERROR"] = "wait_for_all_uploads_error";
|
|
51
|
+
})(SHARED_WORKER_ACTION || (SHARED_WORKER_ACTION = {}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TEMPLATE_ID } from './enums';
|
|
2
|
+
export declare const SUPPORTED_LANGUAGES: {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}[];
|
|
6
|
+
export declare const SUPPORTED_OUTPUT_FORMATS: {
|
|
7
|
+
id: TEMPLATE_ID;
|
|
8
|
+
name: string;
|
|
9
|
+
}[];
|
|
10
|
+
export declare const CONSULTATION_MODES: {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
desc: string;
|
|
14
|
+
}[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TEMPLATE_ID } from './enums';
|
|
2
|
+
export const SUPPORTED_LANGUAGES = [
|
|
3
|
+
{ id: 'en-IN', name: 'English (India)' },
|
|
4
|
+
{ id: 'en-US', name: 'English (United States)' },
|
|
5
|
+
{ id: 'hi', name: 'Hindi' },
|
|
6
|
+
{ id: 'gu', name: 'Gujarati' },
|
|
7
|
+
{ id: 'kn', name: 'Kannada' },
|
|
8
|
+
{ id: 'ml', name: 'Malayalam' },
|
|
9
|
+
{ id: 'ta', name: 'Tamil' },
|
|
10
|
+
{ id: 'te', name: 'Telugu' },
|
|
11
|
+
{ id: 'bn', name: 'Bengali' },
|
|
12
|
+
{ id: 'mr', name: 'Marathi' },
|
|
13
|
+
{ id: 'pa', name: 'Punjabi' },
|
|
14
|
+
];
|
|
15
|
+
export const SUPPORTED_OUTPUT_FORMATS = [
|
|
16
|
+
{ id: TEMPLATE_ID.EKA_EMR_TEMPLATE, name: 'Eka EMR Format' },
|
|
17
|
+
{ id: TEMPLATE_ID.CLINICAL_NOTE_TEMPLATE, name: 'Clinical Notes' },
|
|
18
|
+
{ id: TEMPLATE_ID.TRANSCRIPT_TEMPLATE, name: 'Transcription' },
|
|
19
|
+
];
|
|
20
|
+
export const CONSULTATION_MODES = [
|
|
21
|
+
{
|
|
22
|
+
id: 'consultation',
|
|
23
|
+
name: 'Consultation',
|
|
24
|
+
desc: 'Eka Scribe will listen to your conversation and create clinical notes',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'dictation',
|
|
28
|
+
name: 'Dictation',
|
|
29
|
+
desc: 'Dictate your notes to Eka Scribe and create clinical notes',
|
|
30
|
+
},
|
|
31
|
+
];
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { ERROR_CODE } from './enums';
|
|
2
|
+
export type TGetConfigV2Response = {
|
|
3
|
+
data?: {
|
|
4
|
+
supported_languages: TGetConfigItem[];
|
|
5
|
+
supported_output_formats: TGetConfigItem[];
|
|
6
|
+
consultation_modes: TGetConfigItem[];
|
|
7
|
+
max_selection: {
|
|
8
|
+
supported_languages: number;
|
|
9
|
+
supported_output_formats: number;
|
|
10
|
+
consultation_modes: number;
|
|
11
|
+
};
|
|
12
|
+
selected_preferences?: TSelectedPreferences;
|
|
13
|
+
settings?: TConfigSettings;
|
|
14
|
+
model?: string;
|
|
15
|
+
};
|
|
16
|
+
message?: string;
|
|
17
|
+
code?: number;
|
|
18
|
+
};
|
|
19
|
+
export type TSelectedPreferences = {
|
|
20
|
+
languages?: string[];
|
|
21
|
+
output_formats?: string[];
|
|
22
|
+
consultation_mode?: string;
|
|
23
|
+
use_audio_cues?: boolean;
|
|
24
|
+
auto_download?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type TGetConfigItem = {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
desc?: string;
|
|
30
|
+
};
|
|
31
|
+
export type TConfigSettings = {
|
|
32
|
+
model_training_consent: {
|
|
33
|
+
value: boolean;
|
|
34
|
+
editable: boolean;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export type TStartRecordingRequest = {
|
|
38
|
+
mode: string;
|
|
39
|
+
input_language: string[];
|
|
40
|
+
output_format_template: {
|
|
41
|
+
template_id: string;
|
|
42
|
+
}[];
|
|
43
|
+
txn_id: string;
|
|
44
|
+
auto_download: boolean;
|
|
45
|
+
model_training_consent: boolean;
|
|
46
|
+
transfer: string;
|
|
47
|
+
system_info: TSystemInfo;
|
|
48
|
+
patient_details: TPatientDetails;
|
|
49
|
+
};
|
|
50
|
+
export type TPatientDetails = {
|
|
51
|
+
username: string;
|
|
52
|
+
oid: string;
|
|
53
|
+
age: number;
|
|
54
|
+
biologicalSex: string;
|
|
55
|
+
mobile?: string;
|
|
56
|
+
email?: string;
|
|
57
|
+
};
|
|
58
|
+
export type TSystemInfo = {
|
|
59
|
+
platform: string;
|
|
60
|
+
language: string;
|
|
61
|
+
hardware_concurrency?: number;
|
|
62
|
+
device_memory?: number;
|
|
63
|
+
time_zone: string;
|
|
64
|
+
network_info?: TNetworkInfo;
|
|
65
|
+
};
|
|
66
|
+
export type TNetworkInfo = {
|
|
67
|
+
effective_type: String;
|
|
68
|
+
latency: Number;
|
|
69
|
+
download_speed: Number;
|
|
70
|
+
connection_type: String;
|
|
71
|
+
};
|
|
72
|
+
export type TStartRecordingResponse = {
|
|
73
|
+
error_code?: ERROR_CODE;
|
|
74
|
+
status_code: number;
|
|
75
|
+
message: string;
|
|
76
|
+
business_id?: string;
|
|
77
|
+
txn_id?: string;
|
|
78
|
+
oid?: string;
|
|
79
|
+
uuid?: string;
|
|
80
|
+
};
|
|
81
|
+
export type TPauseRecordingResponse = {
|
|
82
|
+
status_code: number;
|
|
83
|
+
message: string;
|
|
84
|
+
error_code?: ERROR_CODE;
|
|
85
|
+
is_paused?: boolean;
|
|
86
|
+
};
|
|
87
|
+
export type TEndRecordingResponse = {
|
|
88
|
+
error_code?: ERROR_CODE;
|
|
89
|
+
status_code: number;
|
|
90
|
+
message: string;
|
|
91
|
+
failed_files?: string[];
|
|
92
|
+
total_audio_files?: string[];
|
|
93
|
+
};
|
|
94
|
+
export type TPostTransactionInitRequest = {
|
|
95
|
+
mode: string;
|
|
96
|
+
s3Url: string;
|
|
97
|
+
txnId: string;
|
|
98
|
+
input_language: string[];
|
|
99
|
+
output_format_template: {
|
|
100
|
+
template_id: string;
|
|
101
|
+
}[];
|
|
102
|
+
transfer: string;
|
|
103
|
+
auto_download: boolean;
|
|
104
|
+
model_training_consent: boolean;
|
|
105
|
+
system_info: TSystemInfo;
|
|
106
|
+
patient_details: TPatientDetails;
|
|
107
|
+
};
|
|
108
|
+
export type TPostTransactionCommitRequest = {
|
|
109
|
+
audioFiles: string[];
|
|
110
|
+
txnId: string;
|
|
111
|
+
};
|
|
112
|
+
export type TPostTransactionResponse = {
|
|
113
|
+
status: string;
|
|
114
|
+
message: string;
|
|
115
|
+
txn_id: string;
|
|
116
|
+
b_id: string;
|
|
117
|
+
oid: string;
|
|
118
|
+
uuid: string;
|
|
119
|
+
data: unknown;
|
|
120
|
+
code: number;
|
|
121
|
+
error?: {
|
|
122
|
+
code: string;
|
|
123
|
+
message: string;
|
|
124
|
+
display_message: string;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
export type TPatchTransactionError = {
|
|
128
|
+
error: {
|
|
129
|
+
type: string;
|
|
130
|
+
code: string;
|
|
131
|
+
msg: string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
export type TPatchTransactionRequest = {
|
|
135
|
+
sessionId: string;
|
|
136
|
+
processing_status: string;
|
|
137
|
+
processing_error?: TPatchTransactionError;
|
|
138
|
+
};
|
|
139
|
+
export type TPostCogResponse = {
|
|
140
|
+
credentials?: {
|
|
141
|
+
AccessKeyId: string;
|
|
142
|
+
SecretKey: string;
|
|
143
|
+
SessionToken: string;
|
|
144
|
+
Expiration: string;
|
|
145
|
+
};
|
|
146
|
+
message?: string;
|
|
147
|
+
token?: string;
|
|
148
|
+
identity_id?: string;
|
|
149
|
+
is_session_expired?: boolean;
|
|
150
|
+
};
|
|
151
|
+
export type TEndV2RxResponse = {
|
|
152
|
+
error?: string;
|
|
153
|
+
success?: boolean;
|
|
154
|
+
is_upload_failed?: boolean;
|
|
155
|
+
stop_txn_error?: string;
|
|
156
|
+
commit_txn_error?: string;
|
|
157
|
+
};
|
|
158
|
+
export type TGetTransactionHistoryResponse = {
|
|
159
|
+
data?: TSessionHistoryData[];
|
|
160
|
+
status?: string;
|
|
161
|
+
status_code: number;
|
|
162
|
+
message: string;
|
|
163
|
+
retrieved_count?: number;
|
|
164
|
+
};
|
|
165
|
+
export type TSessionHistoryData = {
|
|
166
|
+
created_at: string;
|
|
167
|
+
b_id: string;
|
|
168
|
+
user_status: string;
|
|
169
|
+
processing_status: string;
|
|
170
|
+
txn_id: string;
|
|
171
|
+
mode: string;
|
|
172
|
+
uuid: string;
|
|
173
|
+
oid: string;
|
|
174
|
+
};
|
|
175
|
+
export type TAudioChunksInfo = {
|
|
176
|
+
fileName: string;
|
|
177
|
+
timestamp: {
|
|
178
|
+
st: string;
|
|
179
|
+
et: string;
|
|
180
|
+
};
|
|
181
|
+
response?: string;
|
|
182
|
+
} & ({
|
|
183
|
+
status: 'pending';
|
|
184
|
+
audioFrames: Float32Array;
|
|
185
|
+
fileBlob?: undefined;
|
|
186
|
+
} | {
|
|
187
|
+
status: 'success';
|
|
188
|
+
audioFrames?: undefined;
|
|
189
|
+
fileBlob?: undefined;
|
|
190
|
+
} | {
|
|
191
|
+
status: 'failure';
|
|
192
|
+
fileBlob: Blob;
|
|
193
|
+
audioFrames?: undefined;
|
|
194
|
+
});
|
|
195
|
+
export type UploadProgressCallback = (success: string[], total: number) => void;
|
|
196
|
+
export type TErrorCallback = (args: {
|
|
197
|
+
error_code?: ERROR_CODE;
|
|
198
|
+
status_code: number;
|
|
199
|
+
message: string;
|
|
200
|
+
}) => void;
|
|
201
|
+
export type TSessionStatus = {
|
|
202
|
+
[key: string]: {
|
|
203
|
+
api?: {
|
|
204
|
+
status: 'na' | 'init' | 'stop' | 'commit';
|
|
205
|
+
error?: string;
|
|
206
|
+
response?: string;
|
|
207
|
+
code: number;
|
|
208
|
+
};
|
|
209
|
+
vad?: {
|
|
210
|
+
status: 'start' | 'pause' | 'stop' | 'resume';
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
export type TFileUploadProgressCallback = (args: {
|
|
215
|
+
success: number;
|
|
216
|
+
total: number;
|
|
217
|
+
is_uploaded?: boolean;
|
|
218
|
+
fileName?: string;
|
|
219
|
+
chunkData?: Uint8Array<ArrayBufferLike>[];
|
|
220
|
+
error?: {
|
|
221
|
+
code: number;
|
|
222
|
+
msg: string;
|
|
223
|
+
};
|
|
224
|
+
}) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const setEnv: ({ env, clientId, auth_token, }: {
|
|
2
|
+
env?: "PROD" | "DEV";
|
|
3
|
+
clientId?: string;
|
|
4
|
+
auth_token: string;
|
|
5
|
+
}) => void;
|
|
6
|
+
export declare const GET_EKA_HOST: () => string;
|
|
7
|
+
export declare const GET_CLIENT_ID: () => string;
|
|
8
|
+
export declare const GET_AUTH_TOKEN: () => string;
|
|
9
|
+
export declare const GET_EKA_V2RX_HOST_V2: () => string;
|
|
10
|
+
export declare const GET_EKA_V2RX_HOST_V3: () => string;
|
|
11
|
+
export default setEnv;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const DEV = {
|
|
2
|
+
EKA_HOST: 'https://api.dev.eka.care',
|
|
3
|
+
EKA_V2RX_HOST_V2: 'https://v2rxbe.dev.eka.care/voice/api/v2',
|
|
4
|
+
EKA_V2RX_HOST_V3: 'https://v2rxbe.dev.eka.care/voice/api/v3',
|
|
5
|
+
};
|
|
6
|
+
const PROD = {
|
|
7
|
+
EKA_HOST: 'https://api.eka.care',
|
|
8
|
+
EKA_V2RX_HOST_V2: 'https://api.eka.care/voice/api/v2',
|
|
9
|
+
EKA_V2RX_HOST_V3: 'https://api.eka.care/voice/api/v3',
|
|
10
|
+
};
|
|
11
|
+
let envVar = PROD;
|
|
12
|
+
let client_id = 'doc-web';
|
|
13
|
+
let auth;
|
|
14
|
+
const setEnv = ({ env, clientId, auth_token, }) => {
|
|
15
|
+
if (env) {
|
|
16
|
+
envVar = env === 'PROD' ? PROD : DEV;
|
|
17
|
+
}
|
|
18
|
+
if (clientId) {
|
|
19
|
+
client_id = clientId;
|
|
20
|
+
}
|
|
21
|
+
auth = auth_token;
|
|
22
|
+
};
|
|
23
|
+
export const GET_EKA_HOST = () => envVar.EKA_HOST;
|
|
24
|
+
export const GET_CLIENT_ID = () => client_id;
|
|
25
|
+
export const GET_AUTH_TOKEN = () => auth;
|
|
26
|
+
export const GET_EKA_V2RX_HOST_V2 = () => envVar.EKA_V2RX_HOST_V2;
|
|
27
|
+
export const GET_EKA_V2RX_HOST_V3 = () => envVar.EKA_V2RX_HOST_V3;
|
|
28
|
+
export default setEnv;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function fetchWrapper(url: RequestInfo, options?: RequestInit | undefined, timeoutMs?: number): Promise<Response>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GET_CLIENT_ID, GET_AUTH_TOKEN } from './helper';
|
|
2
|
+
const API_TIMEOUT_MS = 5000;
|
|
3
|
+
export default async function fetchWrapper(url, options = {}, timeoutMs = API_TIMEOUT_MS) {
|
|
4
|
+
const controller = new AbortController();
|
|
5
|
+
let timeoutId = null;
|
|
6
|
+
try {
|
|
7
|
+
// Set up timeout
|
|
8
|
+
timeoutId = setTimeout(() => {
|
|
9
|
+
controller.abort();
|
|
10
|
+
}, timeoutMs);
|
|
11
|
+
const newHeaders = new Headers(options.headers);
|
|
12
|
+
if (!newHeaders.get('client-id')) {
|
|
13
|
+
newHeaders.set('client-id', GET_CLIENT_ID());
|
|
14
|
+
}
|
|
15
|
+
if (!newHeaders.get('auth') && GET_AUTH_TOKEN()) {
|
|
16
|
+
newHeaders.set('auth', GET_AUTH_TOKEN());
|
|
17
|
+
}
|
|
18
|
+
const response = await fetch(url, {
|
|
19
|
+
...options,
|
|
20
|
+
headers: newHeaders,
|
|
21
|
+
signal: controller.signal,
|
|
22
|
+
credentials: 'include',
|
|
23
|
+
});
|
|
24
|
+
return response;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error(error);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
if (timeoutId) {
|
|
32
|
+
clearTimeout(timeoutId);
|
|
33
|
+
timeoutId = null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { TGetStatusResponse } from './api/get-voice-api-v3-status';
|
|
2
|
+
import { TEndRecordingResponse, TErrorCallback, TFileUploadProgressCallback, TGetTransactionHistoryResponse, TPatchTransactionRequest, TPostTransactionResponse, TStartRecordingRequest } from './constants/types';
|
|
3
|
+
declare class EkaScribe {
|
|
4
|
+
private static instance;
|
|
5
|
+
private vadInstance;
|
|
6
|
+
private audioFileManagerInstance;
|
|
7
|
+
private audioBufferInstance;
|
|
8
|
+
private constructor();
|
|
9
|
+
static getInstance({ access_token, env, clientId, }: {
|
|
10
|
+
access_token?: string;
|
|
11
|
+
env?: 'PROD' | 'DEV';
|
|
12
|
+
clientId?: string;
|
|
13
|
+
}): EkaScribe;
|
|
14
|
+
static resetInstance(): void;
|
|
15
|
+
getEkascribeConfig(): Promise<import("./constants/types").TGetConfigV2Response>;
|
|
16
|
+
updateAuthTokens({ access_token }: {
|
|
17
|
+
access_token: string;
|
|
18
|
+
}): void;
|
|
19
|
+
initTransaction(request: TStartRecordingRequest): Promise<import("./constants/types").TStartRecordingResponse>;
|
|
20
|
+
startRecording(): Promise<import("./constants/types").TStartRecordingResponse>;
|
|
21
|
+
reinitializeVad(): void;
|
|
22
|
+
pauseRecording(): import("./constants/types").TPauseRecordingResponse;
|
|
23
|
+
resumeRecording(): import("./constants/types").TPauseRecordingResponse;
|
|
24
|
+
endRecording(): Promise<TEndRecordingResponse>;
|
|
25
|
+
retryUploadRecording({ force_commit }: {
|
|
26
|
+
force_commit: boolean;
|
|
27
|
+
}): Promise<TEndRecordingResponse>;
|
|
28
|
+
patchSessionStatus({ sessionId, processing_status, processing_error, }: TPatchTransactionRequest): Promise<TPostTransactionResponse>;
|
|
29
|
+
commitTransactionCall(): Promise<TEndRecordingResponse>;
|
|
30
|
+
stopTransactionCall(): Promise<TEndRecordingResponse>;
|
|
31
|
+
getTemplateOutput({ txn_id }: {
|
|
32
|
+
txn_id: string;
|
|
33
|
+
}): Promise<TGetStatusResponse>;
|
|
34
|
+
getSessionHistory({ txn_count }: {
|
|
35
|
+
txn_count: number;
|
|
36
|
+
}): Promise<TGetTransactionHistoryResponse>;
|
|
37
|
+
getSuccessFiles(): string[];
|
|
38
|
+
getFailedFiles(): string[];
|
|
39
|
+
getTotalAudioFiles(): import("./constants/types").TAudioChunksInfo[];
|
|
40
|
+
resetEkaScribe(): void;
|
|
41
|
+
onError(callback: TErrorCallback): void;
|
|
42
|
+
onUserSpeechCallback(callback: (isSpeech: boolean) => void): void;
|
|
43
|
+
onFileUploadProgressCallback(callback: TFileUploadProgressCallback): void;
|
|
44
|
+
configureVadConstants({ pref_length, desp_length, max_length, sr, frame_size, pre_speech_pad_frames, short_thsld, long_thsld, }: {
|
|
45
|
+
pref_length: number;
|
|
46
|
+
desp_length: number;
|
|
47
|
+
max_length: number;
|
|
48
|
+
sr: number;
|
|
49
|
+
frame_size: number;
|
|
50
|
+
pre_speech_pad_frames: number;
|
|
51
|
+
short_thsld: number;
|
|
52
|
+
long_thsld: number;
|
|
53
|
+
}): void;
|
|
54
|
+
}
|
|
55
|
+
export declare const getEkaScribeInstance: ({ access_token, env, clientId, }: {
|
|
56
|
+
access_token?: string;
|
|
57
|
+
env?: "PROD" | "DEV";
|
|
58
|
+
clientId?: string;
|
|
59
|
+
}) => EkaScribe;
|
|
60
|
+
export {};
|