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

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
@@ -363,6 +363,7 @@ interface RecordingOptions {
363
363
  deviceId?: string; // Specific microphone device ID
364
364
  sessionMode?: string; // 'consultation' | 'dictation'
365
365
  patientDetails?: PatientDetails; // Patient info
366
+ version?: string; // Optional API version (sent as a `version` query param on create-session)
366
367
  txnId?: string; // External transaction ID
367
368
  }
368
369
  ```
package/dist/index.d.ts CHANGED
@@ -493,6 +493,8 @@ export interface RecordingOptions {
493
493
  sessionMode?: string;
494
494
  patientDetails?: PatientDetails;
495
495
  sessionId?: string;
496
+ /** Optional API version; sent as a `version` query param on the create-session request. */
497
+ version?: string;
496
498
  }
497
499
  export interface RecorderConfig {
498
500
  accessToken?: string;
@@ -771,7 +773,7 @@ export declare class ScribeClient {
771
773
  * the SDK runs one internal retry pass; if files still fail, the session
772
774
  * is NOT ended and the result reports `sessionEnded: false`.
773
775
  */
774
- endRecording(): Promise<SDKResult<EndRecordingResult>>;
776
+ endRecording(version?: string): Promise<SDKResult<EndRecordingResult>>;
775
777
  /**
776
778
  * Retry uploading audio files that failed during the last recording.
777
779
  *
@@ -779,7 +781,7 @@ export declare class ScribeClient {
779
781
  * `hasFailedUploads()` is true). After retrying, call `endSession()` to
780
782
  * finalize. Retry context is cleared on `reset()` or the next `startRecording()`.
781
783
  */
782
- retryFailedUploads(): Promise<SDKResult<RetryUploadResult>>;
784
+ retryFailedUploads(version?: string): Promise<SDKResult<RetryUploadResult>>;
783
785
  /**
784
786
  * Check if there are failed uploads from the last recording that can be retried.
785
787
  */
@@ -1173,7 +1175,7 @@ export declare class RecordingManager {
1173
1175
  * Resume a paused recording.
1174
1176
  */
1175
1177
  resume(): void;
1176
- stop(): Promise<ApiCallResult<EndRecordingResult>>;
1178
+ stop(version?: string): Promise<ApiCallResult<EndRecordingResult>>;
1177
1179
  /**
1178
1180
  * End the session, dispatch onSessionEvent, and return the response.
1179
1181
  * Called from stop() (auto-finalize) and finalizeAfterExternalEndSession()
@@ -1223,7 +1225,7 @@ export declare class RecordingManager {
1223
1225
  * Each file is re-uploaded via transport.request() with retry logic.
1224
1226
  * Successfully retried files are removed from the retry context.
1225
1227
  */
1226
- retryFailedUploads(): Promise<ApiCallResult<RetryUploadResult>>;
1228
+ retryFailedUploads(version?: string): Promise<ApiCallResult<RetryUploadResult>>;
1227
1229
  /**
1228
1230
  * Create the appropriate recorder based on upload type.
1229
1231
  */
package/dist/index.mjs CHANGED
@@ -277,7 +277,8 @@ var r = "/.well-known/medscribealliance", i = 3600 * 1e3, a = /* @__PURE__ */ fu
277
277
  gender: e.string().optional(),
278
278
  mobile: e.number().optional()
279
279
  }).optional(),
280
- sessionId: e.string().optional()
280
+ sessionId: e.string().optional(),
281
+ version: e.string().optional()
281
282
  }), N = class {
282
283
  validateDiscoveryResponse(e) {
283
284
  this.parseWithValidationError(ae, e, "Invalid discovery response");
@@ -1727,8 +1728,8 @@ var Se = class {
1727
1728
  try {
1728
1729
  let a, s;
1729
1730
  try {
1730
- let t = await this.sessionManager.createSession(e, o);
1731
- a = t.data, s = t.httpStatus;
1731
+ let n = await this.sessionManager.createSession(e, o, t.version);
1732
+ a = n.data, s = n.httpStatus;
1732
1733
  } catch (e) {
1733
1734
  throw r === this._startGeneration && this.dispatchStartError(m.TRANSPORT_ERROR, g.SESSION_CREATION_FAILED, e), e;
1734
1735
  }
@@ -1857,7 +1858,7 @@ var Se = class {
1857
1858
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
1858
1859
  }), this.config.debug && console.log("[ScribeSDK] Recording resumed"));
1859
1860
  }
1860
- async stop() {
1861
+ async stop(e) {
1861
1862
  if (!this.recorder || !this._isRecording) return {
1862
1863
  data: {
1863
1864
  failedUploads: [],
@@ -1866,13 +1867,13 @@ var Se = class {
1866
1867
  },
1867
1868
  httpStatus: void 0
1868
1869
  };
1869
- let e = !1, t;
1870
+ let t = !1, n;
1870
1871
  try {
1871
- let n = await this.recorder.stop();
1872
+ let r = await this.recorder.stop();
1872
1873
  this.preserveRetryContext(), this._isRecording = !1;
1873
- let r = n.failedUploads;
1874
- if (r.length > 0) try {
1875
- r = (await this.retryFailedUploads()).data.stillFailed;
1874
+ let i = r.failedUploads;
1875
+ if (i.length > 0) try {
1876
+ i = (await this.retryFailedUploads(e)).data.stillFailed;
1876
1877
  } catch (e) {
1877
1878
  console.error("[ScribeSDK] Internal retry pass failed:", e), this.callbackRegistry.dispatch("onError", {
1878
1879
  type: m.TRANSPORT_ERROR,
@@ -1883,26 +1884,26 @@ var Se = class {
1883
1884
  }
1884
1885
  });
1885
1886
  }
1886
- let i = {
1887
- failedUploads: r,
1888
- totalFiles: n.totalFiles,
1887
+ let a = {
1888
+ failedUploads: i,
1889
+ totalFiles: r.totalFiles,
1889
1890
  sessionEnded: !1
1890
1891
  };
1891
- if (r.length === 0 && this.activeSession) {
1892
- let r = await this.finalizeSession(n.totalFiles, n.totalFiles);
1893
- r && (i.sessionEnded = !0, i.endSessionResponse = r.data, t = r.httpStatus, e = !0);
1892
+ if (i.length === 0 && this.activeSession) {
1893
+ let e = await this.finalizeSession(r.totalFiles, r.totalFiles);
1894
+ e && (a.sessionEnded = !0, a.endSessionResponse = e.data, n = e.httpStatus, t = !0);
1894
1895
  }
1895
1896
  return this.callbackRegistry.dispatch("onRecordingStateChange", {
1896
1897
  type: u.ENDED,
1897
1898
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1898
- data: i
1899
+ data: a
1899
1900
  }), this.config.debug && console.log("[ScribeSDK] Recording stopped:", {
1900
- totalFiles: i.totalFiles,
1901
- failedUploads: i.failedUploads.length,
1902
- sessionEnded: i.sessionEnded
1901
+ totalFiles: a.totalFiles,
1902
+ failedUploads: a.failedUploads.length,
1903
+ sessionEnded: a.sessionEnded
1903
1904
  }), {
1904
- data: i,
1905
- httpStatus: t
1905
+ data: a,
1906
+ httpStatus: n
1906
1907
  };
1907
1908
  } catch (e) {
1908
1909
  return console.error("[ScribeSDK] Error stopping recording:", e), this.callbackRegistry.dispatch("onError", {
@@ -1921,7 +1922,7 @@ var Se = class {
1921
1922
  httpStatus: void 0
1922
1923
  };
1923
1924
  } finally {
1924
- e ? this.cleanupRecordingState() : this.partialCleanupAfterFailedFinalize();
1925
+ t ? this.cleanupRecordingState() : this.partialCleanupAfterFailedFinalize();
1925
1926
  }
1926
1927
  }
1927
1928
  async finalizeSession(e, t) {
@@ -1987,7 +1988,7 @@ var Se = class {
1987
1988
  finalizeAfterExternalEndSession(e) {
1988
1989
  this.activeSession && this.activeSession.session_id === e && (this.activeSession = null, this.activeBaseUrl = "", this.retryContext = null);
1989
1990
  }
1990
- async retryFailedUploads() {
1991
+ async retryFailedUploads(e) {
1991
1992
  if (this._isRecording) throw new v("Cannot retry uploads while recording is active.");
1992
1993
  if (!this.retryContext || this.retryContext.failedChunks.length === 0) return {
1993
1994
  data: {
@@ -1997,47 +1998,47 @@ var Se = class {
1997
1998
  },
1998
1999
  httpStatus: void 0
1999
2000
  };
2000
- let { storageProvider: e, failedChunks: t } = this.retryContext, n = t.length, r = [], i = 0, a = this.retryContext.upload;
2001
+ let { storageProvider: t, failedChunks: n } = this.retryContext, r = n.length, i = [], a = 0, o = this.retryContext.upload;
2001
2002
  try {
2002
- let e = this.activeSession?.session_id;
2003
- if (e) {
2004
- let t = await this.sessionManager.getSessionStatus(this.activeBaseUrl, e);
2005
- t.data.upload_url && (a = t.data.upload_url, this.retryContext.upload = a);
2003
+ let t = this.activeSession?.session_id;
2004
+ if (t) {
2005
+ let n = await this.sessionManager.getSessionStatus(this.activeBaseUrl, t, void 0, e);
2006
+ n.data.upload_url && (o = n.data.upload_url, this.retryContext.upload = o);
2006
2007
  }
2007
2008
  } catch (e) {
2008
2009
  this.config.debug && console.log("[ScribeSDK] Failed to refresh upload_url, using existing:", e);
2009
2010
  }
2010
- this.config.debug && console.log(`[ScribeSDK] Retrying ${n} failed uploads`);
2011
- for (let o of t) try {
2011
+ this.config.debug && console.log(`[ScribeSDK] Retrying ${r} failed uploads`);
2012
+ for (let e of n) try {
2012
2013
  await Y(this.transport, {
2013
- fileName: o.fileName,
2014
- blob: o.blob,
2015
- upload: a,
2016
- storageProvider: e,
2014
+ fileName: e.fileName,
2015
+ blob: e.blob,
2016
+ upload: o,
2017
+ storageProvider: t,
2017
2018
  maxRetries: 0
2018
- }), i++, this.callbackRegistry.dispatch("onUploadEvent", {
2019
+ }), a++, this.callbackRegistry.dispatch("onUploadEvent", {
2019
2020
  type: f.PROGRESS,
2020
2021
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2021
2022
  data: {
2022
- successCount: i,
2023
- totalCount: n
2023
+ successCount: a,
2024
+ totalCount: r
2024
2025
  }
2025
- }), this.config.debug && console.log(`[ScribeSDK] Retry succeeded: ${o.fileName}`);
2026
- } catch (e) {
2027
- r.push(o.fileName), this.callbackRegistry.dispatch("onUploadEvent", {
2026
+ }), this.config.debug && console.log(`[ScribeSDK] Retry succeeded: ${e.fileName}`);
2027
+ } catch (t) {
2028
+ i.push(e.fileName), this.callbackRegistry.dispatch("onUploadEvent", {
2028
2029
  type: f.FAILED,
2029
2030
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2030
2031
  data: {
2031
- fileName: o.fileName,
2032
- error: e instanceof Error ? e.message : "Retry failed"
2032
+ fileName: e.fileName,
2033
+ error: t instanceof Error ? t.message : "Retry failed"
2033
2034
  }
2034
- }), this.config.debug && console.log(`[ScribeSDK] Retry failed: ${o.fileName}`, e);
2035
+ }), this.config.debug && console.log(`[ScribeSDK] Retry failed: ${e.fileName}`, t);
2035
2036
  }
2036
- return r.length === 0 ? this.retryContext = null : this.retryContext.failedChunks = t.filter((e) => r.includes(e.fileName)), this.config.debug && console.log(`[ScribeSDK] Retry complete: ${i}/${n} succeeded`), {
2037
+ return i.length === 0 ? this.retryContext = null : this.retryContext.failedChunks = n.filter((e) => i.includes(e.fileName)), this.config.debug && console.log(`[ScribeSDK] Retry complete: ${a}/${r} succeeded`), {
2037
2038
  data: {
2038
- retried: n,
2039
- succeeded: i,
2040
- stillFailed: r
2039
+ retried: r,
2040
+ succeeded: a,
2041
+ stillFailed: i
2041
2042
  },
2042
2043
  httpStatus: void 0
2043
2044
  };
@@ -2155,11 +2156,11 @@ var Se = class {
2155
2156
  resumeRecording() {
2156
2157
  this.recordingManager.resume();
2157
2158
  }
2158
- async endRecording() {
2159
- return this.wrapResult(() => this.recordingManager.stop());
2159
+ async endRecording(e) {
2160
+ return this.wrapResult(() => this.recordingManager.stop(e));
2160
2161
  }
2161
- async retryFailedUploads() {
2162
- return this.wrapResult(() => this.recordingManager.retryFailedUploads());
2162
+ async retryFailedUploads(e) {
2163
+ return this.wrapResult(() => this.recordingManager.retryFailedUploads(e));
2163
2164
  }
2164
2165
  hasFailedUploads() {
2165
2166
  return this.recordingManager.hasFailedUploads();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "med-scribe-alliance-ts-sdk",
3
- "version": "2.0.39",
3
+ "version": "2.0.40",
4
4
  "description": "TypeScript SDK for the MedScribe Alliance Protocol",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",