@eka-care/ekascribe-ts-sdk 2.0.44 → 2.0.46

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 CHANGED
@@ -141,7 +141,38 @@ const config = await ekascribe.getEkascribeConfig();
141
141
  }
142
142
  ```
143
143
 
144
- ### 3. Init transaction
144
+ ### 3. Fetch user's favorite templates
145
+
146
+ Get the list of templates marked as favorites by the user (configured via `my_templates` in the config).
147
+
148
+ ```ts
149
+ const myTemplates = await ekascribe.getConfigMyTemplates();
150
+ ```
151
+
152
+ - #### Sample Response:
153
+
154
+ ```ts
155
+ {
156
+ "data": {
157
+ "my_templates": [
158
+ {
159
+ "id": "template_123",
160
+ "name": "General Consultation"
161
+ },
162
+ {
163
+ "id": "template_456",
164
+ "name": "Cardiology Template"
165
+ }
166
+ ],
167
+ },
168
+ "message": "Configuration fetched successfully",
169
+ "code": 200
170
+ }
171
+ ```
172
+
173
+ **Note:** The `my_templates` field contains templates that were previously saved using the `updateConfig()` method (see Templates SDK Methods section).
174
+
175
+ ### 4. Init transaction
145
176
 
146
177
  Initialize a transaction before starting recording. This sets up the session with your configuration.
147
178
 
@@ -215,7 +246,7 @@ ekascribe.updateAuthTokens({ access_token: sdkConfig.access_token });
215
246
  const response = await ekascribe.initTransaction({ ... });
216
247
  ```
217
248
 
218
- ### 4. Start recording
249
+ ### 5. Start recording
219
250
 
220
251
  Start recording audio after initializing the transaction.
221
252
 
@@ -237,7 +268,7 @@ const response = await ekascribe.startRecording();
237
268
  }
238
269
  ```
239
270
 
240
- ### 5. Pause recording
271
+ ### 6. Pause recording
241
272
 
242
273
  Pause the ongoing voice recording.
243
274
 
@@ -256,7 +287,7 @@ const response = await ekascribe.pauseRecording();
256
287
  }
257
288
  ```
258
289
 
259
- ### 6. Resume recording
290
+ ### 7. Resume recording
260
291
 
261
292
  Resume a paused recording.
262
293
 
@@ -275,7 +306,7 @@ const response = await ekascribe.resumeRecording();
275
306
  }
276
307
  ```
277
308
 
278
- ### 7. End recording
309
+ ### 8. End recording
279
310
 
280
311
  End the recording session. This method:
281
312
 
@@ -323,34 +354,31 @@ ekascribe.updateAuthTokens({ access_token: sdkConfig.access_token });
323
354
  const response = await ekascribe.endRecording();
324
355
  ```
325
356
 
326
- ### 8. Get output recorded prescription
327
-
328
- You can fetch output in two ways:
329
-
330
- - `getTemplateOutput({ txn_id })`: polling is your responsibility; call repeatedly until processing finishes.
331
- - `pollSessionOutput({ txn_id, max_polling_time })`: SDK polls for you and resolves when processing finishes (default max wait: 2 minutes; override via `max_polling_time`, pass time in milliseconds).
332
-
333
- Example (manual polling):
334
-
335
- ```ts
336
- const res = await ekascribe.getTemplateOutput({ txn_id: 'transaction-id' });
337
- ```
357
+ ### 9. Get output recorded prescription
338
358
 
339
- Example (SDK-managed polling):
359
+ The SDK polls for you and resolves when processing finishes (default max wait: 2 minutes; override via `max_polling_time`, pass time in milliseconds).
340
360
 
341
361
  ```ts
342
362
  // Waits up to 2 minutes by default; override as needed
343
363
  const res = await ekascribe.pollSessionOutput({
344
364
  txn_id: 'transaction-id',
345
365
  max_polling_time: 2 * 60 * 1000, // optional
366
+ template_id: 'template-id', // optional
346
367
  });
347
368
  ```
348
369
 
370
+ **Note:**
371
+
372
+ 1. On passing `template_id` in request params, the function will return output only for that specific template ID. If `template_id` is not passed, it will return all template responses generated for that `txn_id`.
373
+ 2. Use `onPartialResultCallback` (see Generic Callbacks section) before calling `pollSessionOutput` to receive real-time updates during polling, display partial transcription results, and improve user experience with processing progress indicators.
374
+
349
375
  Status codes to handle:
350
376
 
351
377
  - `200`: Success; all templates processed.
352
378
  - `202`: Templates are still processing; poll again (or let `pollSessionOutput` continue).
353
379
  - `206`: Partial success; some templates not processed fully.
380
+ - `401`: Authentication token expired. Update the token.
381
+ - `403`: Invalid Authentication token. Pass new token.
354
382
  - `500`: All template processing failed, or internal server error; stop and surface error.
355
383
 
356
384
  - #### Response type:
@@ -442,7 +470,7 @@ type TOutputSummary = {
442
470
  }
443
471
  ```
444
472
 
445
- ### 9. Retry upload recording
473
+ ### 10. Retry upload recording
446
474
 
447
475
  Retry uploading failed audio files after `endRecording`.
448
476
 
@@ -482,7 +510,7 @@ ekascribe.updateAuthTokens({ access_token: sdkConfig.access_token });
482
510
  const response = await ekascribe.retryUploadRecording({ force_commit: true });
483
511
  ```
484
512
 
485
- ### 10. Patch recording session status
513
+ ### 11. Patch recording session status
486
514
 
487
515
  Cancel or update the status of a recording session.
488
516
 
@@ -531,7 +559,7 @@ ekascribe.updateAuthTokens({ access_token: sdkConfig.access_token });
531
559
  const response = await ekascribe.patchSessionStatus({ ... });
532
560
  ```
533
561
 
534
- ### 11. Commit transaction
562
+ ### 12. Commit transaction
535
563
 
536
564
  Call this if `endRecording` returns `error_code: 'txn_commit_failed'` or the transaction is not yet committed.
537
565
 
@@ -564,7 +592,7 @@ ekascribe.updateAuthTokens({ access_token: sdkConfig.access_token });
564
592
  const response = await ekascribe.commitTransactionCall();
565
593
  ```
566
594
 
567
- ### 12. Stop transaction
595
+ ### 13. Stop transaction
568
596
 
569
597
  Use this method to stop a transaction that has not yet been stopped or returned a `txn_stop_failed` error in a previous step.
570
598
 
@@ -597,7 +625,7 @@ ekascribe.updateAuthTokens({ access_token: sdkConfig.access_token });
597
625
  const response = await ekascribe.stopTransactionCall();
598
626
  ```
599
627
 
600
- ### 13. Get previous sessions
628
+ ### 14. Get previous sessions
601
629
 
602
630
  Fetch previous sessions. `txn_count` controls how many sessions the API returns.
603
631
 
@@ -635,6 +663,49 @@ const sessions = await ekascribe.getSessionHistory({ txn_count: 10 }); // txn_co
635
663
  }
636
664
  ```
637
665
 
666
+ ### 15. Convert response to other template post session
667
+
668
+ Use this method to convert an existing transcription from a completed transaction into a different template format. This is useful when you want to reformat existing transcription data without re-recording.
669
+
670
+ ```ts
671
+ const response = await ekascribe.postTransactionConvertToTemplate({
672
+ txn_id: 'transaction-id-123',
673
+ template_id: 'new-template-id',
674
+ });
675
+ ```
676
+
677
+ **Key Parameters:**
678
+
679
+ - `txn_id`: The transaction ID of the completed session you want to convert
680
+ - `template_id`: The ID of the template format you want to convert the transcription into
681
+
682
+ - #### Sample Response:
683
+
684
+ ```ts
685
+ {
686
+ status: 'success' | 'failed';
687
+ message: string;
688
+ txn_id: string;
689
+ template_id: string;
690
+ b_id: string;
691
+ code: number;
692
+ msg: string;
693
+ error?: {
694
+ code: string;
695
+ message: string;
696
+ display_message: string;
697
+ };
698
+ }
699
+ ```
700
+
701
+ **When to use:**
702
+
703
+ - When you need to apply a different template to an existing transcription
704
+ - To generate multiple template formats from the same recording session
705
+ - After completing a session, when you want to see the output in a different template structure
706
+
707
+ **Note:** After getting success response from this method, call `pollSessionOutput` (Point 9) to get the output for the new template_id.
708
+
638
709
  ## Templates SDK Methods
639
710
 
640
711
  ### 1. Get All Templates
@@ -1174,6 +1245,57 @@ ekascribe.onUserSpeechCallback((isSpeech) => {
1174
1245
  });
1175
1246
  ```
1176
1247
 
1248
+ ### 3. Partial result callback
1249
+
1250
+ This callback provides real-time partial results while polling for the final output. Use it to display intermediate transcription and template results to users before processing is complete.
1251
+
1252
+ ```ts
1253
+ ekascribe.onPartialResultCallback((partialData) => {
1254
+ console.log('Partial result received:', partialData);
1255
+
1256
+ // Handle different poll statuses
1257
+ switch (partialData.poll_status) {
1258
+ case 'in-progress':
1259
+ // Processing is still ongoing, display partial results
1260
+ console.log('Processing...', partialData.response);
1261
+ break;
1262
+ case 'success':
1263
+ // Final result received
1264
+ console.log('Processing complete:', partialData.response);
1265
+ break;
1266
+ case 'failed':
1267
+ // Processing failed
1268
+ console.error('Processing failed:', partialData.message);
1269
+ break;
1270
+ case 'timeout':
1271
+ // Polling timed out
1272
+ console.warn('Polling timeout:', partialData.message);
1273
+ break;
1274
+ }
1275
+ });
1276
+ ```
1277
+
1278
+ - #### Callback Structure:
1279
+
1280
+ ```ts
1281
+ {
1282
+ txn_id: string; // Transaction ID
1283
+ response: TGetStatusApiResponse | null; // The response structure is the same as returned by `pollSessionOutput` method
1284
+ status_code: number; // HTTP status code
1285
+ message: string; // Status message
1286
+ poll_status: 'in-progress' | 'success' | 'failed' | 'timeout'; // Current polling state
1287
+ }
1288
+ ```
1289
+
1290
+ **When to use:**
1291
+
1292
+ - Set this callback before calling `pollSessionOutput` to receive real-time updates
1293
+ - Display partial transcription results to improve user experience
1294
+ - Show processing progress indicators
1295
+ - Handle intermediate template results
1296
+
1297
+ **Note:** This callback is triggered multiple times during polling - once for each poll attempt until processing completes or times out.
1298
+
1177
1299
  ### Error codes
1178
1300
 
1179
1301
  | Error Code | Description |
package/dist/index.d.ts CHANGED
@@ -55,6 +55,7 @@ declare class EkaScribe {
55
55
  pollSessionOutput(request: {
56
56
  txn_id: string;
57
57
  max_polling_time?: number;
58
+ template_id?: string;
58
59
  }): Promise<TPollingResponse>;
59
60
  getSessionHistory({ txn_count }: {
60
61
  txn_count: number;
package/dist/index.mjs CHANGED
@@ -54203,76 +54203,77 @@ const decodeApiResponse = (i) => {
54203
54203
  }
54204
54204
  }, pollOutputSummary = async ({
54205
54205
  txn_id: i,
54206
- max_polling_time: a = 120 * 1e3
54206
+ max_polling_time: a = 120 * 1e3,
54207
+ template_id: s
54207
54208
  }) => {
54208
- const s = EkaScribeStore$1.partialResultCallback, n = (r, c, u, m) => {
54209
- const y = {
54210
- response: c ?? null,
54211
- status_code: r,
54212
- errorMessage: m === "success" || m === "in-progress" ? void 0 : u
54209
+ const n = EkaScribeStore$1.partialResultCallback, r = (c, u, m, y) => {
54210
+ const l = {
54211
+ response: u ?? null,
54212
+ status_code: c,
54213
+ errorMessage: y === "success" || y === "in-progress" ? void 0 : m
54213
54214
  };
54214
- return s?.({
54215
+ return n?.({
54215
54216
  txn_id: i,
54216
- response: c ?? null,
54217
- status_code: r,
54218
- message: u,
54219
- poll_status: m
54220
- }), y;
54217
+ response: u ?? null,
54218
+ status_code: c,
54219
+ message: m,
54220
+ poll_status: y
54221
+ }), l;
54221
54222
  };
54222
54223
  try {
54223
- const c = (/* @__PURE__ */ new Date()).getTime() + a;
54224
- let u = 0;
54225
- s?.({
54224
+ const u = (/* @__PURE__ */ new Date()).getTime() + a;
54225
+ let m = 0;
54226
+ n?.({
54226
54227
  txn_id: i,
54227
54228
  response: null,
54228
54229
  status_code: 202,
54229
54230
  message: "Polling for session output summary started",
54230
54231
  poll_status: "in-progress"
54231
54232
  });
54232
- const m = async (y) => {
54233
+ const y = async (l) => {
54233
54234
  try {
54234
- const l = await getVoiceApiV3Status({ txnId: i, queryParams: y }), { status_code: p, response: t } = l;
54235
- if ((/* @__PURE__ */ new Date()).getTime() >= c)
54236
- return n(500, null, "We encountered an error while fetching analysis results due to timeout. Please try again.", "timeout");
54237
- if (p === 401 || p === 403)
54238
- return n(p, t, "Unauthorized or Forbidden", "failed");
54239
- if (p === 202 || p === 400 || p >= 500) {
54240
- if (p === 202 && t && s?.({
54235
+ const p = await getVoiceApiV3Status({ txnId: i, queryParams: l }), { status_code: t, response: e } = p;
54236
+ if ((/* @__PURE__ */ new Date()).getTime() >= u)
54237
+ return r(500, null, "We encountered an error while fetching analysis results due to timeout. Please try again.", "timeout");
54238
+ if (t === 401 || t === 403)
54239
+ return r(t, e, "Unauthorized or Forbidden", "failed");
54240
+ if (t === 202 || t === 400 || t >= 500) {
54241
+ if (t === 202 && e && n?.({
54241
54242
  txn_id: i,
54242
- response: t,
54243
- status_code: p,
54243
+ response: e,
54244
+ status_code: t,
54244
54245
  message: "Partial result received",
54245
54246
  poll_status: "in-progress"
54246
- }), p >= 400) {
54247
- if (u++, u >= 3) {
54248
- const o = t?.error?.msg || "We encountered a backend error while fetching results. Please try again.";
54249
- return n(p, null, o, "failed");
54247
+ }), t >= 400) {
54248
+ if (m++, m >= 3) {
54249
+ const d = e?.error?.msg || "We encountered a backend error while fetching results. Please try again.";
54250
+ return r(t, null, d, "failed");
54250
54251
  }
54251
54252
  } else
54252
- u = 0;
54253
- return m();
54253
+ m = 0;
54254
+ return y(s ? `template_id=${s}` : "");
54254
54255
  }
54255
- return n(
54256
- p,
54256
+ return r(
54257
54257
  t,
54258
+ e,
54258
54259
  "Template results generated successfully. Polling for this session is complete.",
54259
54260
  "success"
54260
54261
  );
54261
- } catch (l) {
54262
- return n(
54262
+ } catch (p) {
54263
+ return r(
54263
54264
  -1,
54264
54265
  null,
54265
- `Something went wrong from inside catch block. ${l}`,
54266
+ `Something went wrong from inside catch block. ${p}`,
54266
54267
  "failed"
54267
54268
  );
54268
54269
  }
54269
54270
  };
54270
- return m("template_id=transcript");
54271
- } catch (r) {
54272
- return r instanceof Error && r.name === "AbortError" ? n(-1, null, "Request was aborted due to timeout.", "timeout") : n(
54271
+ return y(s ? `template_id=${s}` : "");
54272
+ } catch (c) {
54273
+ return c instanceof Error && c.name === "AbortError" ? r(-1, null, "Request was aborted due to timeout.", "timeout") : r(
54273
54274
  -1,
54274
54275
  null,
54275
- `Something went wrong from outer catch block, ${r}`,
54276
+ `Something went wrong from outer catch block, ${c}`,
54276
54277
  "failed"
54277
54278
  );
54278
54279
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eka-care/ekascribe-ts-sdk",
3
- "version": "2.0.44",
3
+ "version": "2.0.46",
4
4
  "description": "EkaScribe TypeScript SDK - Modern ES2020 build",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
@@ -28,7 +28,7 @@
28
28
  "clean": "rm -rf dist",
29
29
  "build:main": "vite build",
30
30
  "build:worker": "vite build --config vite.worker.config.ts",
31
- "build": "yarn clean && yarn build:main && yarn build:worker && cp ../../README.md .",
31
+ "build": "yarn clean && yarn build:main && yarn build:worker",
32
32
  "prepublishOnly": "yarn build"
33
33
  },
34
34
  "publishConfig": {