@eka-care/ekascribe-ts-sdk 2.0.45 → 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 +145 -23
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -141,7 +141,38 @@ const config = await ekascribe.getEkascribeConfig();
|
|
|
141
141
|
}
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
-
### 3.
|
|
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
|
-
###
|
|
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
|
-
###
|
|
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
|
-
###
|
|
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
|
-
###
|
|
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
|
-
###
|
|
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
|
-
|
|
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
|
-
###
|
|
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
|
-
###
|
|
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
|
-
###
|
|
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
|
-
###
|
|
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
|
-
###
|
|
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
package/dist/index.mjs
CHANGED
|
@@ -54204,7 +54204,7 @@ const decodeApiResponse = (i) => {
|
|
|
54204
54204
|
}, pollOutputSummary = async ({
|
|
54205
54205
|
txn_id: i,
|
|
54206
54206
|
max_polling_time: a = 120 * 1e3,
|
|
54207
|
-
|
|
54207
|
+
template_id: s
|
|
54208
54208
|
}) => {
|
|
54209
54209
|
const n = EkaScribeStore$1.partialResultCallback, r = (c, u, m, y) => {
|
|
54210
54210
|
const l = {
|
|
@@ -54251,7 +54251,7 @@ const decodeApiResponse = (i) => {
|
|
|
54251
54251
|
}
|
|
54252
54252
|
} else
|
|
54253
54253
|
m = 0;
|
|
54254
|
-
return y();
|
|
54254
|
+
return y(s ? `template_id=${s}` : "");
|
|
54255
54255
|
}
|
|
54256
54256
|
return r(
|
|
54257
54257
|
t,
|
|
@@ -54268,7 +54268,7 @@ const decodeApiResponse = (i) => {
|
|
|
54268
54268
|
);
|
|
54269
54269
|
}
|
|
54270
54270
|
};
|
|
54271
|
-
return y(s ?
|
|
54271
|
+
return y(s ? `template_id=${s}` : "");
|
|
54272
54272
|
} catch (c) {
|
|
54273
54273
|
return c instanceof Error && c.name === "AbortError" ? r(-1, null, "Request was aborted due to timeout.", "timeout") : r(
|
|
54274
54274
|
-1,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eka-care/ekascribe-ts-sdk",
|
|
3
|
-
"version": "2.0.
|
|
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
|
|
31
|
+
"build": "yarn clean && yarn build:main && yarn build:worker",
|
|
32
32
|
"prepublishOnly": "yarn build"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|