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 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 r = t ?? this.currentSession?.session_id;
851
- if (!r) throw new v("No active session. Provide a sessionId or start a session first.");
852
- let i = n?.maxAttempts ?? 60, a = n?.intervalMs ?? 2e3, o = n?.timeoutMs, s = o !== void 0 && o > 0 ? Date.now() + o : void 0;
853
- this.debug && console.log("[ScribeSDK] Polling for completion:", r, {
854
- maxAttempts: i,
855
- intervalMs: a,
856
- timeoutMs: o
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 <= i; t++) {
859
- if (n?.signal?.aborted) throw new v("Polling was aborted", "polling_aborted", void 0, { session_id: r });
860
- if (s !== void 0 && Date.now() >= s) throw new v(`Polling timed out after ${o}ms for session '${r}'`, "polling_timeout", void 0, {
861
- session_id: r,
862
- timeout_ms: o
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 c = await this.getSessionStatus(e, r), l = c.data;
864
+ let l = await this.getSessionStatus(e, i, r), u = l.data;
865
865
  if (n?.onProgress) try {
866
- n.onProgress(l);
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(l.status)) return this.debug && console.log("[ScribeSDK] Poll complete:", r, l.status, `(attempt ${t})`), c;
871
- if (t < i) {
872
- let e = a;
873
- if (s !== void 0) {
874
- let t = s - Date.now();
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(a, t);
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 ${i} attempts for session '${r}'`, "polling_timeout", void 0, {
882
- session_id: r,
883
- max_attempts: i
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
- let t = this.discoveryManager.getResolvedConfig();
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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "med-scribe-alliance-ts-sdk",
3
- "version": "2.0.35",
3
+ "version": "2.0.37",
4
4
  "description": "TypeScript SDK for the MedScribe Alliance Protocol",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",