med-scribe-alliance-ts-sdk 2.0.31 → 2.0.32
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 +1 -0
- package/dist/index.mjs +19 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -431,6 +431,7 @@ export interface ProcessingError {
|
|
|
431
431
|
export interface PollOptions {
|
|
432
432
|
maxAttempts?: number;
|
|
433
433
|
intervalMs?: number;
|
|
434
|
+
timeoutMs?: number;
|
|
434
435
|
onProgress?: (status: GetSessionStatusResponse) => void;
|
|
435
436
|
/** AbortSignal to cancel polling early. */
|
|
436
437
|
signal?: AbortSignal;
|
package/dist/index.mjs
CHANGED
|
@@ -838,21 +838,34 @@ var G = class {
|
|
|
838
838
|
try {
|
|
839
839
|
let r = t ?? this.currentSession?.session_id;
|
|
840
840
|
if (!r) throw new y("No active session. Provide a sessionId or start a session first.");
|
|
841
|
-
let i = n?.maxAttempts ?? 60, a = n?.intervalMs ?? 2e3;
|
|
841
|
+
let i = n?.maxAttempts ?? 60, a = n?.intervalMs ?? 2e3, o = n?.timeoutMs, s = o !== void 0 && o > 0 ? Date.now() + o : void 0;
|
|
842
842
|
this.debug && console.log("[ScribeSDK] Polling for completion:", r, {
|
|
843
843
|
maxAttempts: i,
|
|
844
|
-
intervalMs: a
|
|
844
|
+
intervalMs: a,
|
|
845
|
+
timeoutMs: o
|
|
845
846
|
});
|
|
846
847
|
for (let t = 1; t <= i; t++) {
|
|
847
848
|
if (n?.signal?.aborted) throw new y("Polling was aborted", "polling_aborted", void 0, { session_id: r });
|
|
848
|
-
|
|
849
|
+
if (s !== void 0 && Date.now() >= s) throw new y(`Polling timed out after ${o}ms for session '${r}'`, "polling_timeout", void 0, {
|
|
850
|
+
session_id: r,
|
|
851
|
+
timeout_ms: o
|
|
852
|
+
});
|
|
853
|
+
let c = await this.getSessionStatus(e, r), l = c.data;
|
|
849
854
|
if (n?.onProgress) try {
|
|
850
|
-
n.onProgress(
|
|
855
|
+
n.onProgress(l);
|
|
851
856
|
} catch (e) {
|
|
852
857
|
console.error("[ScribeSDK] Error in poll onProgress callback:", e);
|
|
853
858
|
}
|
|
854
|
-
if (this.isTerminalStatus(
|
|
855
|
-
t < i
|
|
859
|
+
if (this.isTerminalStatus(l.status)) return this.debug && console.log("[ScribeSDK] Poll complete:", r, l.status, `(attempt ${t})`), c;
|
|
860
|
+
if (t < i) {
|
|
861
|
+
let e = a;
|
|
862
|
+
if (s !== void 0) {
|
|
863
|
+
let t = s - Date.now();
|
|
864
|
+
if (t <= 0) continue;
|
|
865
|
+
e = Math.min(a, t);
|
|
866
|
+
}
|
|
867
|
+
await this.sleepWithAbort(e, n?.signal);
|
|
868
|
+
}
|
|
856
869
|
}
|
|
857
870
|
throw new y(`Polling timed out after ${i} attempts for session '${r}'`, "polling_timeout", void 0, {
|
|
858
871
|
session_id: r,
|