@eka-care/ekascribe-ts-sdk 2.0.0 → 2.0.3
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.d.ts +3 -1
- package/dist/index.mjs +71 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -346,7 +346,7 @@ declare type TNetworkInfo = {
|
|
|
346
346
|
|
|
347
347
|
declare type TOutputSummary = {
|
|
348
348
|
template_id: string;
|
|
349
|
-
value?:
|
|
349
|
+
value?: TTemplateValue;
|
|
350
350
|
type: string;
|
|
351
351
|
name: string;
|
|
352
352
|
lang?: string;
|
|
@@ -642,6 +642,8 @@ declare type TTemplateMessage = {
|
|
|
642
642
|
|
|
643
643
|
declare type TTemplateStatus = 'success' | 'partial_success' | 'failure';
|
|
644
644
|
|
|
645
|
+
declare type TTemplateValue = string | Record<string, unknown> | Array<unknown> | null;
|
|
646
|
+
|
|
645
647
|
declare type TVadFrameProcessedCallback = (args: {
|
|
646
648
|
probabilities: {
|
|
647
649
|
notSpeech: number;
|
package/dist/index.mjs
CHANGED
|
@@ -11211,7 +11211,7 @@ class EkaScribeStore {
|
|
|
11211
11211
|
}
|
|
11212
11212
|
}
|
|
11213
11213
|
const EkaScribeStore$1 = EkaScribeStore.getInstance();
|
|
11214
|
-
var ERROR_CODE = /* @__PURE__ */ ((i) => (i.MICROPHONE = "microphone", i.TXN_INIT_FAILED = "txn_init_failed", i.TXN_LIMIT_EXCEEDED = "txn_limit_exceeded", i.INTERNAL_SERVER_ERROR = "internal_server_error", i.TXN_STOP_FAILED = "txn_stop_failed", i.AUDIO_UPLOAD_FAILED = "audio_upload_failed", i.TXN_COMMIT_FAILED = "txn_commit_failed", i.INVALID_REQUEST = "invalid_request", i.VAD_NOT_INITIALIZED = "vad_not_initialized", i.NO_AUDIO_CAPTURE = "no_audio_capture", i.SPEECH_DETECTED = "speech_detected", i.TXN_STATUS_MISMATCH = "txn_status_mismatch", i.LONG_SILENCE = "long_silence", i.GET_PRESIGNED_URL_FAILED = "get_presigned_url_failed", i.UPLOAD_FULL_AUDIO = "upload_full_audio", i.FETCH_WRAPPER_RESPONSE = "fetch_wrapper_response", i.FETCH_WRAPPER_ERROR = "fetch_wrapper_error", i))(ERROR_CODE || {}), SHARED_WORKER_ACTION = /* @__PURE__ */ ((i) => (i.UPLOAD_FILE_WITH_WORKER = "upload_file_with_worker", i.UPLOAD_FILE_WITH_WORKER_SUCCESS = "upload_file_with_worker_success", i.UPLOAD_FILE_WITH_WORKER_ERROR = "upload_file_with_worker_error", i.TEST_WORKER = "test_worker", i.CONFIGURE_AWS = "configure_aws", i.CONFIGURE_AWS_SUCCESS = "configure_aws_success", i.CONFIGURE_AWS_ERROR = "configure_aws_error", i.WAIT_FOR_ALL_UPLOADS = "wait_for_all_uploads", i.WAIT_FOR_ALL_UPLOADS_SUCCESS = "wait_for_all_uploads_success", i.WAIT_FOR_ALL_UPLOADS_ERROR = "wait_for_all_uploads_error", i))(SHARED_WORKER_ACTION || {}), CALLBACK_TYPE = /* @__PURE__ */ ((i) => (i.AWS_CONFIGURE_STATUS = "aws_configure_status", i.FILE_UPLOAD_STATUS = "file_upload_status", i.TRANSACTION_STATUS = "transaction_status", i.TEMPLATE_OPERATION_STATUS = "template_operation_status", i.AUTHENTICATION_STATUS = "authentication_status", i.NETWORK_STATUS = "network_status", i.STORAGE_STATUS = "storage_status", i))(CALLBACK_TYPE || {});
|
|
11214
|
+
var ERROR_CODE = /* @__PURE__ */ ((i) => (i.MICROPHONE = "microphone", i.TXN_INIT_FAILED = "txn_init_failed", i.TXN_LIMIT_EXCEEDED = "txn_limit_exceeded", i.INTERNAL_SERVER_ERROR = "internal_server_error", i.TXN_STOP_FAILED = "txn_stop_failed", i.AUDIO_UPLOAD_FAILED = "audio_upload_failed", i.TXN_COMMIT_FAILED = "txn_commit_failed", i.INVALID_REQUEST = "invalid_request", i.VAD_NOT_INITIALIZED = "vad_not_initialized", i.NO_AUDIO_CAPTURE = "no_audio_capture", i.SPEECH_DETECTED = "speech_detected", i.TXN_STATUS_MISMATCH = "txn_status_mismatch", i.LONG_SILENCE = "long_silence", i.GET_PRESIGNED_URL_FAILED = "get_presigned_url_failed", i.UPLOAD_FULL_AUDIO = "upload_full_audio", i.FETCH_WRAPPER_RESPONSE = "fetch_wrapper_response", i.FETCH_WRAPPER_ERROR = "fetch_wrapper_error", i))(ERROR_CODE || {}), SHARED_WORKER_ACTION = /* @__PURE__ */ ((i) => (i.UPLOAD_FILE_WITH_WORKER = "upload_file_with_worker", i.UPLOAD_FILE_WITH_WORKER_SUCCESS = "upload_file_with_worker_success", i.UPLOAD_FILE_WITH_WORKER_ERROR = "upload_file_with_worker_error", i.TEST_WORKER = "test_worker", i.CONFIGURE_AWS = "configure_aws", i.CONFIGURE_AWS_SUCCESS = "configure_aws_success", i.CONFIGURE_AWS_ERROR = "configure_aws_error", i.WAIT_FOR_ALL_UPLOADS = "wait_for_all_uploads", i.WAIT_FOR_ALL_UPLOADS_SUCCESS = "wait_for_all_uploads_success", i.WAIT_FOR_ALL_UPLOADS_ERROR = "wait_for_all_uploads_error", i))(SHARED_WORKER_ACTION || {}), CALLBACK_TYPE = /* @__PURE__ */ ((i) => (i.AWS_CONFIGURE_STATUS = "aws_configure_status", i.FILE_UPLOAD_STATUS = "file_upload_status", i.TRANSACTION_STATUS = "transaction_status", i.TEMPLATE_OPERATION_STATUS = "template_operation_status", i.AUTHENTICATION_STATUS = "authentication_status", i.NETWORK_STATUS = "network_status", i.STORAGE_STATUS = "storage_status", i))(CALLBACK_TYPE || {}), TEMPLATE_TYPE = /* @__PURE__ */ ((i) => (i.JSON = "json", i.TRANSCRIPT = "transcript", i.MARKDOWN = "markdown", i))(TEMPLATE_TYPE || {});
|
|
11215
11215
|
const API_TIMEOUT_MS = 1e4;
|
|
11216
11216
|
async function fetchWrapper(i, a = {}, s = API_TIMEOUT_MS) {
|
|
11217
11217
|
const n = EkaScribeStore$1.eventCallback, r = new AbortController();
|
|
@@ -11271,6 +11271,55 @@ const getConfigV2 = async () => {
|
|
|
11271
11271
|
message: `Failed to fetch initial configurations, ${i}`
|
|
11272
11272
|
};
|
|
11273
11273
|
}
|
|
11274
|
+
}, safeJsonParse = (i) => {
|
|
11275
|
+
try {
|
|
11276
|
+
return JSON.parse(i);
|
|
11277
|
+
} catch {
|
|
11278
|
+
return i;
|
|
11279
|
+
}
|
|
11280
|
+
}, decodeUnicodeBase64 = (i) => {
|
|
11281
|
+
try {
|
|
11282
|
+
const a = atob(i), s = new Uint8Array(a.length);
|
|
11283
|
+
for (let r = 0; r < a.length; r++)
|
|
11284
|
+
s[r] = a.charCodeAt(r);
|
|
11285
|
+
return new TextDecoder("utf-8").decode(s);
|
|
11286
|
+
} catch (a) {
|
|
11287
|
+
return console.error("Error decoding base64 string:", a), "";
|
|
11288
|
+
}
|
|
11289
|
+
}, processStructuredSummaryData = (i, a) => {
|
|
11290
|
+
if (!a || a.trim() === "") return null;
|
|
11291
|
+
const s = decodeUnicodeBase64(a);
|
|
11292
|
+
switch (i) {
|
|
11293
|
+
case TEMPLATE_TYPE.JSON:
|
|
11294
|
+
return safeJsonParse(s);
|
|
11295
|
+
case TEMPLATE_TYPE.TRANSCRIPT:
|
|
11296
|
+
case TEMPLATE_TYPE.MARKDOWN:
|
|
11297
|
+
return s;
|
|
11298
|
+
default:
|
|
11299
|
+
return safeJsonParse(s);
|
|
11300
|
+
}
|
|
11301
|
+
}, decodeOutputSummaries = (i) => i?.length ? i.map((a) => {
|
|
11302
|
+
const { value: s } = a;
|
|
11303
|
+
return typeof s != "string" ? { ...a, value: s ?? null } : {
|
|
11304
|
+
...a,
|
|
11305
|
+
value: processStructuredSummaryData(a.type, s)
|
|
11306
|
+
};
|
|
11307
|
+
}) : [], decodeApiResponse$1 = (i) => {
|
|
11308
|
+
if (!i?.data) return i;
|
|
11309
|
+
const { data: a } = i;
|
|
11310
|
+
return {
|
|
11311
|
+
...i,
|
|
11312
|
+
data: {
|
|
11313
|
+
...a,
|
|
11314
|
+
output: decodeOutputSummaries(a.output),
|
|
11315
|
+
template_results: {
|
|
11316
|
+
...a.template_results,
|
|
11317
|
+
integration: decodeOutputSummaries(a.template_results?.integration),
|
|
11318
|
+
custom: decodeOutputSummaries(a.template_results?.custom),
|
|
11319
|
+
transcript: decodeOutputSummaries(a.template_results?.transcript)
|
|
11320
|
+
}
|
|
11321
|
+
}
|
|
11322
|
+
};
|
|
11274
11323
|
}, getVoiceApiV3Status = async ({
|
|
11275
11324
|
txnId: i
|
|
11276
11325
|
}) => {
|
|
@@ -11284,9 +11333,9 @@ const getConfigV2 = async () => {
|
|
|
11284
11333
|
`${GET_EKA_VOICE_HOST_V3()}/status/${i}`,
|
|
11285
11334
|
s,
|
|
11286
11335
|
16e3
|
|
11287
|
-
);
|
|
11336
|
+
), r = await n.json();
|
|
11288
11337
|
return {
|
|
11289
|
-
response:
|
|
11338
|
+
response: decodeApiResponse$1(r),
|
|
11290
11339
|
status_code: n.status
|
|
11291
11340
|
};
|
|
11292
11341
|
} catch (a) {
|
|
@@ -54092,7 +54141,23 @@ async function postConvertTranscriptionToTemplate({
|
|
|
54092
54141
|
};
|
|
54093
54142
|
}
|
|
54094
54143
|
}
|
|
54095
|
-
const
|
|
54144
|
+
const decodeApiResponse = (i) => {
|
|
54145
|
+
if (!i?.data) return i;
|
|
54146
|
+
const { data: a } = i;
|
|
54147
|
+
return {
|
|
54148
|
+
...i,
|
|
54149
|
+
data: {
|
|
54150
|
+
...a,
|
|
54151
|
+
output: decodeOutputSummaries(a.output),
|
|
54152
|
+
template_results: {
|
|
54153
|
+
...a.template_results,
|
|
54154
|
+
integration: decodeOutputSummaries(a.template_results?.integration),
|
|
54155
|
+
custom: decodeOutputSummaries(a.template_results?.custom),
|
|
54156
|
+
transcript: decodeOutputSummaries(a.template_results?.transcript)
|
|
54157
|
+
}
|
|
54158
|
+
}
|
|
54159
|
+
};
|
|
54160
|
+
}, getVoiceApiV3StatusTranscript = async ({
|
|
54096
54161
|
txnId: i
|
|
54097
54162
|
}) => {
|
|
54098
54163
|
try {
|
|
@@ -54105,9 +54170,9 @@ const getVoiceApiV3StatusTranscript = async ({
|
|
|
54105
54170
|
`${GET_EKA_VOICE_HOST_V3()}/status/transcript/${i}`,
|
|
54106
54171
|
s,
|
|
54107
54172
|
16e3
|
|
54108
|
-
);
|
|
54173
|
+
), r = await n.json();
|
|
54109
54174
|
return {
|
|
54110
|
-
response:
|
|
54175
|
+
response: decodeApiResponse(r),
|
|
54111
54176
|
status_code: n.status
|
|
54112
54177
|
};
|
|
54113
54178
|
} catch (a) {
|