@eka-care/ekascribe-ts-sdk 2.0.41 → 2.0.43

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 CHANGED
@@ -340,10 +340,10 @@ declare type TOutputSummary = {
340
340
 
341
341
  declare type TPartialResultCallback = (data: {
342
342
  txn_id: string;
343
- response: TGetStatusApiResponse;
343
+ response: TGetStatusApiResponse | null;
344
344
  status_code: number;
345
345
  message: string;
346
- poll_status: 'in-progress' | 'completed' | 'failed' | 'timeout';
346
+ poll_status: 'in-progress' | 'success' | 'failed' | 'timeout';
347
347
  }) => void;
348
348
 
349
349
  declare type TPatchTransactionError = {
package/dist/index.mjs CHANGED
@@ -54204,68 +54204,76 @@ const decodeApiResponse = (i) => {
54204
54204
  txn_id: i,
54205
54205
  max_polling_time: a = 120 * 1e3
54206
54206
  }) => {
54207
+ const s = EkaScribeStore$1.partialResultCallback, n = (r, c, u, m) => {
54208
+ const y = {
54209
+ response: c ?? null,
54210
+ status_code: r,
54211
+ errorMessage: m === "success" || m === "in-progress" ? void 0 : u
54212
+ };
54213
+ return s?.({
54214
+ txn_id: i,
54215
+ response: c ?? null,
54216
+ status_code: r,
54217
+ message: u,
54218
+ poll_status: m
54219
+ }), y;
54220
+ };
54207
54221
  try {
54208
- const n = (/* @__PURE__ */ new Date()).getTime() + a, r = EkaScribeStore$1.partialResultCallback;
54209
- let c = 0;
54210
- const u = async () => {
54222
+ const c = (/* @__PURE__ */ new Date()).getTime() + a;
54223
+ let u = 0;
54224
+ s?.({
54225
+ txn_id: i,
54226
+ response: null,
54227
+ status_code: 202,
54228
+ message: "Polling for session output summary started",
54229
+ poll_status: "in-progress"
54230
+ });
54231
+ const m = async () => {
54211
54232
  try {
54212
- const m = await getVoiceApiV3Status({ txnId: i }), { status_code: y, response: l } = m;
54213
- if ((/* @__PURE__ */ new Date()).getTime() >= n)
54214
- return {
54215
- status_code: 500,
54216
- errorMessage: "We encountered an error while fetching analysis results due to timeout. Please try again."
54217
- };
54218
- if (y === 401 || y === 403)
54219
- return {
54220
- response: l,
54221
- status_code: y,
54222
- errorMessage: "Unauthorized or Forbidden"
54223
- };
54224
- if (y === 202 || y === 400 || y >= 500) {
54225
- if (y === 202 && l && r?.({
54233
+ const y = await getVoiceApiV3Status({ txnId: i }), { status_code: l, response: p } = y;
54234
+ if ((/* @__PURE__ */ new Date()).getTime() >= c)
54235
+ return n(500, null, "We encountered an error while fetching analysis results due to timeout. Please try again.", "timeout");
54236
+ if (l === 401 || l === 403)
54237
+ return n(l, p, "Unauthorized or Forbidden", "failed");
54238
+ if (l === 202 || l === 400 || l >= 500) {
54239
+ if (l === 202 && p && s?.({
54226
54240
  txn_id: i,
54227
- response: l,
54228
- status_code: y,
54241
+ response: p,
54242
+ status_code: l,
54229
54243
  message: "Partial result received",
54230
54244
  poll_status: "in-progress"
54231
- }), y >= 400) {
54232
- if (c++, c >= 3)
54233
- return {
54234
- response: l,
54235
- status_code: y,
54236
- errorMessage: l?.error?.msg || "We encountered a backend error while fetching results. Please try again."
54237
- };
54245
+ }), l >= 400) {
54246
+ if (u++, u >= 3) {
54247
+ const e = p?.error?.msg || "We encountered a backend error while fetching results. Please try again.";
54248
+ return n(l, null, e, "failed");
54249
+ }
54238
54250
  } else
54239
- c = 0;
54240
- return u();
54241
- }
54242
- return l && r?.({
54243
- txn_id: i,
54244
- response: l,
54245
- status_code: y,
54246
- message: "Template results generated successfully. Polling for this session is complete.",
54247
- poll_status: "completed"
54248
- }), {
54249
- response: l,
54250
- status_code: y
54251
- };
54252
- } catch (m) {
54253
- return {
54254
- status_code: -1,
54255
- // -1: non-https status_code to distinguish backend's 500 status_code
54256
- errorMessage: `Something went wrong from inside catch block. ${m}`
54257
- };
54251
+ u = 0;
54252
+ return m();
54253
+ }
54254
+ return n(
54255
+ l,
54256
+ p,
54257
+ "Template results generated successfully. Polling for this session is complete.",
54258
+ "success"
54259
+ );
54260
+ } catch (y) {
54261
+ return n(
54262
+ -1,
54263
+ null,
54264
+ `Something went wrong from inside catch block. ${y}`,
54265
+ "failed"
54266
+ );
54258
54267
  }
54259
54268
  };
54260
- return u();
54261
- } catch (s) {
54262
- return s instanceof Error && s.name === "AbortError" ? {
54263
- status_code: -1,
54264
- errorMessage: "Request was aborted due to timeout."
54265
- } : {
54266
- status_code: -1,
54267
- errorMessage: `Something went wrong from outer catch block, ${s}`
54268
- };
54269
+ return m();
54270
+ } catch (r) {
54271
+ return r instanceof Error && r.name === "AbortError" ? n(-1, null, "Request was aborted due to timeout.", "timeout") : n(
54272
+ -1,
54273
+ null,
54274
+ `Something went wrong from outer catch block, ${r}`,
54275
+ "failed"
54276
+ );
54269
54277
  }
54270
54278
  };
54271
54279
  function getSharedWorkerUrl() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eka-care/ekascribe-ts-sdk",
3
- "version": "2.0.41",
3
+ "version": "2.0.43",
4
4
  "description": "EkaScribe TypeScript SDK - Modern ES2020 build",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",