med-scribe-alliance-ts-sdk 2.0.35 → 2.0.37
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 +2 -1
- package/dist/index.mjs +26 -27
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1081,8 +1081,9 @@ export declare class SessionManager {
|
|
|
1081
1081
|
* Poll for session completion.
|
|
1082
1082
|
* Keeps checking getSessionStatus until the session reaches a terminal state
|
|
1083
1083
|
* (completed, partial, or failed) or the max attempts are exhausted.
|
|
1084
|
+
* Pass templateId to filter the returned status for a specific template.
|
|
1084
1085
|
*/
|
|
1085
|
-
pollForCompletion(baseUrl: string, sessionId?: string, options?: PollOptions): Promise<ApiCallResult<GetSessionStatusResponse>>;
|
|
1086
|
+
pollForCompletion(baseUrl: string, sessionId?: string, options?: PollOptions, templateId?: string): Promise<ApiCallResult<GetSessionStatusResponse>>;
|
|
1086
1087
|
/**
|
|
1087
1088
|
* Get the current active session, if any.
|
|
1088
1089
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -845,42 +845,42 @@ var z = class {
|
|
|
845
845
|
throw e instanceof v ? e : new v(`Failed to process template: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
|
-
async pollForCompletion(e, t, n) {
|
|
848
|
+
async pollForCompletion(e, t, n, r) {
|
|
849
849
|
try {
|
|
850
|
-
let
|
|
851
|
-
if (!
|
|
852
|
-
let
|
|
853
|
-
this.debug && console.log("[ScribeSDK] Polling for completion:",
|
|
854
|
-
maxAttempts:
|
|
855
|
-
intervalMs:
|
|
856
|
-
timeoutMs:
|
|
850
|
+
let i = t ?? this.currentSession?.session_id;
|
|
851
|
+
if (!i) throw new v("No active session. Provide a sessionId or start a session first.");
|
|
852
|
+
let a = n?.maxAttempts ?? 60, o = n?.intervalMs ?? 2e3, s = n?.timeoutMs, c = s !== void 0 && s > 0 ? Date.now() + s : void 0;
|
|
853
|
+
this.debug && console.log("[ScribeSDK] Polling for completion:", i, {
|
|
854
|
+
maxAttempts: a,
|
|
855
|
+
intervalMs: o,
|
|
856
|
+
timeoutMs: s
|
|
857
857
|
});
|
|
858
|
-
for (let t = 1; t <=
|
|
859
|
-
if (n?.signal?.aborted) throw new v("Polling was aborted", "polling_aborted", void 0, { session_id:
|
|
860
|
-
if (
|
|
861
|
-
session_id:
|
|
862
|
-
timeout_ms:
|
|
858
|
+
for (let t = 1; t <= a; t++) {
|
|
859
|
+
if (n?.signal?.aborted) throw new v("Polling was aborted", "polling_aborted", void 0, { session_id: i });
|
|
860
|
+
if (c !== void 0 && Date.now() >= c) throw new v(`Polling timed out after ${s}ms for session '${i}'`, "polling_timeout", void 0, {
|
|
861
|
+
session_id: i,
|
|
862
|
+
timeout_ms: s
|
|
863
863
|
});
|
|
864
|
-
let
|
|
864
|
+
let l = await this.getSessionStatus(e, i, r), u = l.data;
|
|
865
865
|
if (n?.onProgress) try {
|
|
866
|
-
n.onProgress(
|
|
866
|
+
n.onProgress(u);
|
|
867
867
|
} catch (e) {
|
|
868
868
|
console.error("[ScribeSDK] Error in poll onProgress callback:", e);
|
|
869
869
|
}
|
|
870
|
-
if (this.isTerminalStatus(
|
|
871
|
-
if (t <
|
|
872
|
-
let e =
|
|
873
|
-
if (
|
|
874
|
-
let t =
|
|
870
|
+
if (this.isTerminalStatus(u.status)) return this.debug && console.log("[ScribeSDK] Poll complete:", i, u.status, `(attempt ${t})`), l;
|
|
871
|
+
if (t < a) {
|
|
872
|
+
let e = o;
|
|
873
|
+
if (c !== void 0) {
|
|
874
|
+
let t = c - Date.now();
|
|
875
875
|
if (t <= 0) continue;
|
|
876
|
-
e = Math.min(
|
|
876
|
+
e = Math.min(o, t);
|
|
877
877
|
}
|
|
878
878
|
await this.sleepWithAbort(e, n?.signal);
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
|
-
throw new v(`Polling timed out after ${
|
|
882
|
-
session_id:
|
|
883
|
-
max_attempts:
|
|
881
|
+
throw new v(`Polling timed out after ${a} attempts for session '${i}'`, "polling_timeout", void 0, {
|
|
882
|
+
session_id: i,
|
|
883
|
+
max_attempts: a
|
|
884
884
|
});
|
|
885
885
|
} catch (e) {
|
|
886
886
|
throw e instanceof v ? e : new v(`Failed to poll session: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
@@ -2114,8 +2114,7 @@ var Se = class {
|
|
|
2114
2114
|
let t = this.getEffectiveBaseUrl();
|
|
2115
2115
|
return this.wrapResult(() => {
|
|
2116
2116
|
try {
|
|
2117
|
-
|
|
2118
|
-
this.validator.validateAgainstDiscovery(e, t);
|
|
2117
|
+
this.discoveryManager.getResolvedConfig();
|
|
2119
2118
|
} catch (e) {
|
|
2120
2119
|
if (e instanceof y) throw e;
|
|
2121
2120
|
}
|
|
@@ -2193,7 +2192,7 @@ var Se = class {
|
|
|
2193
2192
|
}
|
|
2194
2193
|
async getSessionStatus(e, t) {
|
|
2195
2194
|
let n = this.getEffectiveBaseUrl();
|
|
2196
|
-
return t?.poll ? this.wrapResult(() => this.sessionManager.pollForCompletion(n, e, t.poll)) : this.wrapResult(() => this.sessionManager.getSessionStatus(n, e, t?.templateId));
|
|
2195
|
+
return t?.poll ? this.wrapResult(() => this.sessionManager.pollForCompletion(n, e, t.poll, t.templateId)) : this.wrapResult(() => this.sessionManager.getSessionStatus(n, e, t?.templateId));
|
|
2197
2196
|
}
|
|
2198
2197
|
getCurrentSession() {
|
|
2199
2198
|
return this.recordingManager.getActiveSession() ?? this.sessionManager.getCurrentSession();
|