@eka-care/ekascribe-ts-sdk 2.1.23 → 2.1.24
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/index.mjs +37 -10
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -150,6 +150,16 @@ class EkaScribeStore {
|
|
|
150
150
|
const EkaScribeStore$1 = EkaScribeStore.getInstance();
|
|
151
151
|
var API_STATUS = /* @__PURE__ */ ((s) => (s.NOT_INITIALIZED = "na", s.INIT = "init", s.STOP = "stop", s.COMMIT = "commit", s))(API_STATUS || {}), VAD_STATUS = /* @__PURE__ */ ((s) => (s.START = "start", s.PAUSE = "pause", s.RESUME = "resume", s.STOP = "stop", s))(VAD_STATUS || {}), TEMPLATE_ID = /* @__PURE__ */ ((s) => (s.EKA_EMR_TEMPLATE = "eka_emr_template", s.CLINICAL_NOTE_TEMPLATE = "clinical_notes_template", s.TRANSCRIPT_TEMPLATE = "transcript_template", s.EKA_EMR_TO_FHIR_TEMPLATE = "eka_emr_to_fhir_template", s.NIC_TEMPLATE = "nic_template", s))(TEMPLATE_ID || {}), RESULT_STATUS = /* @__PURE__ */ ((s) => (s.SUCCESS = "success", s.FAILURE = "failure", s.PARTIAL_COMPLETE = "partial_complete", s.IN_PROGRESS = "in-progress", s))(RESULT_STATUS || {}), ERROR_CODE = /* @__PURE__ */ ((s) => (s.MICROPHONE = "microphone", s.TXN_INIT_FAILED = "txn_init_failed", s.TXN_LIMIT_EXCEEDED = "txn_limit_exceeded", s.INTERNAL_SERVER_ERROR = "internal_server_error", s.TXN_STOP_FAILED = "txn_stop_failed", s.AUDIO_UPLOAD_FAILED = "audio_upload_failed", s.TXN_COMMIT_FAILED = "txn_commit_failed", s.INVALID_REQUEST = "invalid_request", s.VAD_NOT_INITIALIZED = "vad_not_initialized", s.NO_AUDIO_CAPTURE = "no_audio_capture", s.SPEECH_DETECTED = "speech_detected", s.TXN_STATUS_MISMATCH = "txn_status_mismatch", s.LONG_SILENCE = "long_silence", s.GET_PRESIGNED_URL_FAILED = "get_presigned_url_failed", s.UPLOAD_FULL_AUDIO = "upload_full_audio", s.FETCH_WRAPPER_RESPONSE = "fetch_wrapper_response", s.FETCH_WRAPPER_ERROR = "fetch_wrapper_error", s))(ERROR_CODE || {}), PROCESSING_STATUS = /* @__PURE__ */ ((s) => (s.SUCCESS = "success", s.IN_PROGRESS = "in-progress", s.FAILED = "failed", s.CANCELLED = "cancelled", s))(PROCESSING_STATUS || {}), SHARED_WORKER_ACTION = /* @__PURE__ */ ((s) => (s.UPLOAD_FILE_WITH_WORKER = "upload_file_with_worker", s.UPLOAD_FILE_WITH_WORKER_SUCCESS = "upload_file_with_worker_success", s.UPLOAD_FILE_WITH_WORKER_ERROR = "upload_file_with_worker_error", s.TEST_WORKER = "test_worker", s.CONFIGURE_AWS = "configure_aws", s.CONFIGURE_AWS_SUCCESS = "configure_aws_success", s.CONFIGURE_AWS_ERROR = "configure_aws_error", s.WAIT_FOR_ALL_UPLOADS = "wait_for_all_uploads", s.WAIT_FOR_ALL_UPLOADS_SUCCESS = "wait_for_all_uploads_success", s.WAIT_FOR_ALL_UPLOADS_ERROR = "wait_for_all_uploads_error", s.REQUEST_TOKEN_REFRESH = "request_token_refresh", s.TOKEN_REFRESH_SUCCESS = "token_refresh_success", s.TOKEN_REFRESH_ERROR = "token_refresh_error", s.RESET_UPLOAD_COUNTERS = "reset_upload_counters", s.TERMINATE_WORKER = "terminate_worker", s))(SHARED_WORKER_ACTION || {}), CALLBACK_TYPE = /* @__PURE__ */ ((s) => (s.AWS_CONFIGURE_STATUS = "aws_configure_status", s.FILE_UPLOAD_STATUS = "file_upload_status", s.TRANSACTION_STATUS = "transaction_status", s.TEMPLATE_OPERATION_STATUS = "template_operation_status", s.AUTHENTICATION_STATUS = "authentication_status", s.NETWORK_STATUS = "network_status", s.STORAGE_STATUS = "storage_status", s))(CALLBACK_TYPE || {}), TEMPLATE_TYPE = /* @__PURE__ */ ((s) => (s.JSON = "json", s.TRANSCRIPT = "transcript", s.MARKDOWN = "markdown", s))(TEMPLATE_TYPE || {}), COMPATIBILITY_TEST_TYPE = /* @__PURE__ */ ((s) => (s.INTERNET_CONNECTIVITY = "INTERNET_CONNECTIVITY", s.SYSTEM_INFO = "SYSTEM_INFO", s.MICROPHONE = "MICROPHONE", s.SHARED_WORKER = "SHARED_WORKER", s.NETWORK_API = "NETWORK_API", s))(COMPATIBILITY_TEST_TYPE || {}), COMPATIBILITY_TEST_STATUS = /* @__PURE__ */ ((s) => (s.SUCCESS = "success", s.ERROR = "error", s.WARNING = "warning", s))(COMPATIBILITY_TEST_STATUS || {});
|
|
152
152
|
const API_TIMEOUT_MS = 1e4;
|
|
153
|
+
function getNetworkBridge() {
|
|
154
|
+
if (!(typeof window > "u"))
|
|
155
|
+
return window.networkApi;
|
|
156
|
+
}
|
|
157
|
+
function headersToRecord(s) {
|
|
158
|
+
const n = {};
|
|
159
|
+
return s.forEach((i, c) => {
|
|
160
|
+
n[c] = i;
|
|
161
|
+
}), n;
|
|
162
|
+
}
|
|
153
163
|
async function fetchWrapper(s, n = {}, i = API_TIMEOUT_MS) {
|
|
154
164
|
const c = EkaScribeStore$1.eventCallback, l = new AbortController();
|
|
155
165
|
let f = null;
|
|
@@ -159,22 +169,39 @@ async function fetchWrapper(s, n = {}, i = API_TIMEOUT_MS) {
|
|
|
159
169
|
}, i);
|
|
160
170
|
const u = new Headers(n.headers);
|
|
161
171
|
u.get("client-id") || u.set("client-id", GET_CLIENT_ID()), u.get("flavour") || u.set("flavour", GET_FLAVOUR()), !u.get("auth") && GET_AUTH_TOKEN() && u.set("auth", GET_AUTH_TOKEN());
|
|
162
|
-
const d =
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
const d = getNetworkBridge();
|
|
173
|
+
let _;
|
|
174
|
+
if (d) {
|
|
175
|
+
const p = {
|
|
176
|
+
url: typeof s == "string" ? s : s.url,
|
|
177
|
+
method: n.method || "GET",
|
|
178
|
+
headers: headersToRecord(u),
|
|
179
|
+
body: n.body ?? null,
|
|
180
|
+
retry: !0,
|
|
181
|
+
ekaHost: GET_EKA_HOST()
|
|
182
|
+
}, a = await d.request(p);
|
|
183
|
+
_ = new Response(a.body, {
|
|
184
|
+
status: a.status,
|
|
185
|
+
statusText: a.statusText,
|
|
186
|
+
headers: a.headers
|
|
187
|
+
});
|
|
188
|
+
} else
|
|
189
|
+
_ = await fetch(s, {
|
|
190
|
+
...n,
|
|
191
|
+
headers: u,
|
|
192
|
+
signal: l.signal,
|
|
193
|
+
credentials: "include"
|
|
194
|
+
});
|
|
195
|
+
return _.ok || c && c({
|
|
169
196
|
callback_type: CALLBACK_TYPE.AUTHENTICATION_STATUS,
|
|
170
197
|
status: "error",
|
|
171
|
-
message: "Fetch wrapper error: " +
|
|
198
|
+
message: "Fetch wrapper error: " + _.ok + _.status,
|
|
172
199
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
173
200
|
data: {
|
|
174
201
|
request: "Request body: " + JSON.stringify(n.body),
|
|
175
|
-
response: "Response body: " + JSON.stringify(
|
|
202
|
+
response: "Response body: " + JSON.stringify(_)
|
|
176
203
|
}
|
|
177
|
-
}),
|
|
204
|
+
}), _;
|
|
178
205
|
} catch (u) {
|
|
179
206
|
throw console.error(u, "error in fetch wrapper - SDK"), c && c({
|
|
180
207
|
callback_type: CALLBACK_TYPE.AUTHENTICATION_STATUS,
|