med-scribe-alliance-ts-sdk 2.0.38 → 2.0.39

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
@@ -395,8 +395,8 @@ interface RecordingOptions {
395
395
 
396
396
  | Method | Returns | Description |
397
397
  |---|---|---|
398
- | `createSession(request)` | `SDKResult<CreateSessionResponse>` | Create a session without starting a recording. |
399
- | `getSessionStatus(sessionId?, options?)` | `SDKResult<GetSessionStatusResponse>` | Get status. Supports `poll` and `templateId` options. |
398
+ | `createSession(request, version?)` | `SDKResult<CreateSessionResponse>` | Create a session without starting a recording. Optional `version` is sent as a `version` query param. |
399
+ | `getSessionStatus(sessionId?, options?)` | `SDKResult<GetSessionStatusResponse>` | Get status. Supports `poll`, `templateId`, and `version` options (`version` sent as a query param). |
400
400
  | `getCurrentSession()` | `CreateSessionResponse \| null` | Get the active session if any. |
401
401
  | `updateSession(request, sessionId?)` | `SDKResult<PatchSessionResponse>` | Patch session (patient details, status, etc.). |
402
402
  | `processTemplate(templateId, sessionId?)` | `SDKResult<ProcessTemplateResponse>` | Trigger processing for a specific template. |
package/dist/index.d.ts CHANGED
@@ -807,7 +807,7 @@ export declare class ScribeClient {
807
807
  /**
808
808
  * Create a session directly (without starting a recording).
809
809
  */
810
- createSession(sessionRequest: CreateSessionRequest): Promise<SDKResult<CreateSessionResponse>>;
810
+ createSession(sessionRequest: CreateSessionRequest, version?: string): Promise<SDKResult<CreateSessionResponse>>;
811
811
  /**
812
812
  * End a session directly.
813
813
  */
@@ -820,10 +820,12 @@ export declare class ScribeClient {
820
820
  * terminal state (completed, partial, failed, expired) or times out.
821
821
  *
822
822
  * Pass `templateId` to filter status for a specific template.
823
+ * Pass `version` to target a specific API version (attached as a query param).
823
824
  */
824
825
  getSessionStatus(sessionId?: string, options?: {
825
826
  poll?: PollOptions;
826
827
  templateId?: string;
828
+ version?: string;
827
829
  }): Promise<SDKResult<GetSessionStatusResponse>>;
828
830
  /**
829
831
  * Get the current active session, if any.
@@ -1058,7 +1060,7 @@ export declare class SessionManager {
1058
1060
  * Create a new scribe session.
1059
1061
  * Validates the request structure, sends to server, validates response.
1060
1062
  */
1061
- createSession(baseUrl: string, request: CreateSessionRequest): Promise<ApiCallResult<CreateSessionResponse>>;
1063
+ createSession(baseUrl: string, request: CreateSessionRequest, version?: string): Promise<ApiCallResult<CreateSessionResponse>>;
1062
1064
  /**
1063
1065
  * End an active session.
1064
1066
  * If no sessionId is provided, ends the current session.
@@ -1069,7 +1071,7 @@ export declare class SessionManager {
1069
1071
  * If no sessionId is provided, queries the current session.
1070
1072
  * Pass templateId to filter status for a specific template.
1071
1073
  */
1072
- getSessionStatus(baseUrl: string, sessionId?: string, templateId?: string): Promise<ApiCallResult<GetSessionStatusResponse>>;
1074
+ getSessionStatus(baseUrl: string, sessionId?: string, templateId?: string, version?: string): Promise<ApiCallResult<GetSessionStatusResponse>>;
1073
1075
  /**
1074
1076
  * Patch an existing session (e.g., update user_status or processing_status).
1075
1077
  */
@@ -1084,7 +1086,7 @@ export declare class SessionManager {
1084
1086
  * (completed, partial, or failed) or the max attempts are exhausted.
1085
1087
  * Pass templateId to filter the returned status for a specific template.
1086
1088
  */
1087
- pollForCompletion(baseUrl: string, sessionId?: string, options?: PollOptions, templateId?: string): Promise<ApiCallResult<GetSessionStatusResponse>>;
1089
+ pollForCompletion(baseUrl: string, sessionId?: string, options?: PollOptions, templateId?: string, version?: string): Promise<ApiCallResult<GetSessionStatusResponse>>;
1088
1090
  /**
1089
1091
  * Get the current active session, if any.
1090
1092
  */
package/dist/index.mjs CHANGED
@@ -748,19 +748,19 @@ var z = class {
748
748
  constructor(e, t, n = !1) {
749
749
  this.currentSession = null, this.transport = e, this.validator = t, this.debug = n;
750
750
  }
751
- async createSession(e, t) {
751
+ async createSession(e, t, n) {
752
752
  try {
753
753
  this.validator.validateCreateSessionRequest(t);
754
- let n = `${e}/sessions`;
755
- this.debug && console.log("[ScribeSDK] Creating session:", n);
756
- let r = await this.transport.request({
754
+ let r = `${e}/sessions`;
755
+ n && (r += `?version=${encodeURIComponent(n)}`), this.debug && console.log("[ScribeSDK] Creating session:", r);
756
+ let i = await this.transport.request({
757
757
  method: "POST",
758
- url: n,
758
+ url: r,
759
759
  body: t
760
760
  });
761
- return this.validator.validateCreateSessionResponse(r.data), this.currentSession = r.data, this.debug && console.log("[ScribeSDK] Session created:", r.data.session_id), {
762
- data: r.data,
763
- httpStatus: r.status
761
+ return this.validator.validateCreateSessionResponse(i.data), this.currentSession = i.data, this.debug && console.log("[ScribeSDK] Session created:", i.data.session_id), {
762
+ data: i.data,
763
+ httpStatus: i.status
764
764
  };
765
765
  } catch (e) {
766
766
  throw e instanceof v ? e : new v(`Failed to create session: ${e instanceof Error ? e.message : "Unknown error"}`);
@@ -786,21 +786,23 @@ var z = class {
786
786
  throw e instanceof v ? e : new v(`Failed to end session: ${e instanceof Error ? e.message : "Unknown error"}`);
787
787
  }
788
788
  }
789
- async getSessionStatus(e, t, n) {
789
+ async getSessionStatus(e, t, n, r) {
790
790
  try {
791
- let r = t ?? this.currentSession?.session_id;
792
- if (!r) throw new v("No active session. Provide a sessionId or start a session first.");
793
- this.validator.validateSessionId(r);
794
- let i = `${e}/sessions/${r}`;
795
- n && (i += `?template_id=${encodeURIComponent(n)}`), this.debug && console.log("[ScribeSDK] Getting session status:", r);
796
- let a = await this.transport.request({
791
+ let i = t ?? this.currentSession?.session_id;
792
+ if (!i) throw new v("No active session. Provide a sessionId or start a session first.");
793
+ this.validator.validateSessionId(i);
794
+ let a = new URLSearchParams();
795
+ n && a.set("template_id", n), r && a.set("version", r);
796
+ let o = a.toString(), s = o ? `${e}/sessions/${i}?${o}` : `${e}/sessions/${i}`;
797
+ this.debug && console.log("[ScribeSDK] Getting session status:", i);
798
+ let c = await this.transport.request({
797
799
  method: "GET",
798
- url: i,
800
+ url: s,
799
801
  acceptStatuses: [410]
800
802
  });
801
- return this.validator.validateGetSessionStatusResponse(a.data), this.debug && console.log("[ScribeSDK] Session status:", r, a.data.status), {
802
- data: a.data,
803
- httpStatus: a.status
803
+ return this.validator.validateGetSessionStatusResponse(c.data), this.debug && console.log("[ScribeSDK] Session status:", i, c.data.status), {
804
+ data: c.data,
805
+ httpStatus: c.status
804
806
  };
805
807
  } catch (e) {
806
808
  throw e instanceof v ? e : new v(`Failed to get session status: ${e instanceof Error ? e.message : "Unknown error"}`);
@@ -845,42 +847,42 @@ var z = class {
845
847
  throw e instanceof v ? e : new v(`Failed to process template: ${e instanceof Error ? e.message : "Unknown error"}`);
846
848
  }
847
849
  }
848
- async pollForCompletion(e, t, n, r) {
850
+ async pollForCompletion(e, t, n, r, i) {
849
851
  try {
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
852
+ let a = t ?? this.currentSession?.session_id;
853
+ if (!a) throw new v("No active session. Provide a sessionId or start a session first.");
854
+ let o = n?.maxAttempts ?? 60, s = n?.intervalMs ?? 2e3, c = n?.timeoutMs, l = c !== void 0 && c > 0 ? Date.now() + c : void 0;
855
+ this.debug && console.log("[ScribeSDK] Polling for completion:", a, {
856
+ maxAttempts: o,
857
+ intervalMs: s,
858
+ timeoutMs: c
857
859
  });
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
860
+ for (let t = 1; t <= o; t++) {
861
+ if (n?.signal?.aborted) throw new v("Polling was aborted", "polling_aborted", void 0, { session_id: a });
862
+ if (l !== void 0 && Date.now() >= l) throw new v(`Polling timed out after ${c}ms for session '${a}'`, "polling_timeout", void 0, {
863
+ session_id: a,
864
+ timeout_ms: c
863
865
  });
864
- let l = await this.getSessionStatus(e, i, r), u = l.data;
866
+ let u = await this.getSessionStatus(e, a, r, i), d = u.data;
865
867
  if (n?.onProgress) try {
866
- n.onProgress(u);
868
+ n.onProgress(d);
867
869
  } catch (e) {
868
870
  console.error("[ScribeSDK] Error in poll onProgress callback:", e);
869
871
  }
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();
872
+ if (this.isTerminalStatus(d.status)) return this.debug && console.log("[ScribeSDK] Poll complete:", a, d.status, `(attempt ${t})`), u;
873
+ if (t < o) {
874
+ let e = s;
875
+ if (l !== void 0) {
876
+ let t = l - Date.now();
875
877
  if (t <= 0) continue;
876
- e = Math.min(o, t);
878
+ e = Math.min(s, t);
877
879
  }
878
880
  await this.sleepWithAbort(e, n?.signal);
879
881
  }
880
882
  }
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
883
+ throw new v(`Polling timed out after ${o} attempts for session '${a}'`, "polling_timeout", void 0, {
884
+ session_id: a,
885
+ max_attempts: o
884
886
  });
885
887
  } catch (e) {
886
888
  throw e instanceof v ? e : new v(`Failed to poll session: ${e instanceof Error ? e.message : "Unknown error"}`);
@@ -2193,9 +2195,9 @@ var Se = class {
2193
2195
  };
2194
2196
  });
2195
2197
  }
2196
- async createSession(e) {
2197
- let t = this.getEffectiveBaseUrl();
2198
- return this.wrapResult(() => this.sessionManager.createSession(t, e));
2198
+ async createSession(e, t) {
2199
+ let n = this.getEffectiveBaseUrl();
2200
+ return this.wrapResult(() => this.sessionManager.createSession(n, e, t));
2199
2201
  }
2200
2202
  async endSession(e, t) {
2201
2203
  let n = this.getEffectiveBaseUrl();
@@ -2210,7 +2212,7 @@ var Se = class {
2210
2212
  }
2211
2213
  async getSessionStatus(e, t) {
2212
2214
  let n = this.getEffectiveBaseUrl();
2213
- return t?.poll ? this.wrapResult(() => this.sessionManager.pollForCompletion(n, e, t.poll, t.templateId)) : this.wrapResult(() => this.sessionManager.getSessionStatus(n, e, t?.templateId));
2215
+ return t?.poll ? this.wrapResult(() => this.sessionManager.pollForCompletion(n, e, t.poll, t.templateId, t.version)) : this.wrapResult(() => this.sessionManager.getSessionStatus(n, e, t?.templateId, t?.version));
2214
2216
  }
2215
2217
  getCurrentSession() {
2216
2218
  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.38",
3
+ "version": "2.0.39",
4
4
  "description": "TypeScript SDK for the MedScribe Alliance Protocol",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",