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

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
@@ -425,6 +425,7 @@ export interface GetSessionStatusResponse {
425
425
  };
426
426
  patient_details?: PatientDetails;
427
427
  message?: string;
428
+ upload_url?: SessionUploadInfo;
428
429
  }
429
430
  export interface TemplateEntry {
430
431
  [templateId: string]: TemplateEntryData;
@@ -533,8 +534,8 @@ export type AudioChunkInfo = {
533
534
  response?: string;
534
535
  } & ({
535
536
  status: "pending";
536
- audioFrames: Float32Array;
537
- fileBlob?: undefined;
537
+ audioFrames?: Float32Array;
538
+ fileBlob?: Blob;
538
539
  } | {
539
540
  status: "success";
540
541
  audioFrames?: undefined;
package/dist/index.mjs CHANGED
@@ -1177,13 +1177,18 @@ var pe = {
1177
1177
  });
1178
1178
  }), e;
1179
1179
  }
1180
+ storeEncodedBlob(e, t) {
1181
+ if (e < 0 || e >= this.chunks.length) return;
1182
+ let n = this.chunks[e];
1183
+ n.status === "pending" && (n.fileBlob = t, n.audioFrames = void 0);
1184
+ }
1180
1185
  markPendingAsFailed() {
1181
1186
  for (let e = 0; e < this.chunks.length; e++) this.chunks[e].status === "pending" && (this.chunks[e] = {
1182
1187
  fileName: this.chunks[e].fileName,
1183
1188
  timestamp: this.chunks[e].timestamp,
1184
1189
  response: "Upload did not complete (timed out or worker unresponsive)",
1185
1190
  status: "failure",
1186
- fileBlob: new Blob()
1191
+ fileBlob: this.chunks[e].fileBlob ?? new Blob()
1187
1192
  });
1188
1193
  }
1189
1194
  resetInstance() {
@@ -1308,8 +1313,8 @@ var Se = class {
1308
1313
  waitForAllUploads() {
1309
1314
  return this.useWorker && this.port ? new Promise((e) => {
1310
1315
  this.allUploadsResolver = e, this.postToWorker({ type: "wait_for_all_uploads" }), setTimeout(() => {
1311
- this.allUploadsResolver &&= (console.warn("[ScribeSDK] waitForAllUploads timed out after 15s"), this.allUploadsResolver(), null);
1312
- }, 15e3);
1316
+ this.allUploadsResolver &&= (console.warn("[ScribeSDK] waitForAllUploads timed out after 30s"), this.allUploadsResolver(), null);
1317
+ }, 3e4);
1313
1318
  }) : Promise.all(this.pendingUploads).then(() => {});
1314
1319
  }
1315
1320
  updateAuthToken(e) {
@@ -1354,6 +1359,10 @@ var Se = class {
1354
1359
  switch (e.type) {
1355
1360
  case "chunk_encoded": {
1356
1361
  let t = this.findChunkIndex(e.fileName);
1362
+ if (t >= 0 && e.chunkData && e.chunkData.length > 0) {
1363
+ let n = new Blob(e.chunkData, { type: "audio/mp3" });
1364
+ this.fileManager.storeEncodedBlob(t, n);
1365
+ }
1357
1366
  this.callbackRegistry.dispatch("onAudioEvent", {
1358
1367
  type: d.CHUNK_READY,
1359
1368
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1373,7 +1382,7 @@ var Se = class {
1373
1382
  case "upload_failed": {
1374
1383
  let t = this.findChunkIndex(e.fileName);
1375
1384
  if (t >= 0) {
1376
- let n = e.chunkData && e.chunkData.length > 0 ? new Blob(e.chunkData, { type: "audio/mp3" }) : new Blob();
1385
+ let n = e.chunkData && e.chunkData.length > 0 ? new Blob(e.chunkData, { type: "audio/mp3" }) : this.fileManager.getChunks()[t]?.fileBlob ?? new Blob();
1377
1386
  this.fileManager.markFailure(t, n, e.error);
1378
1387
  }
1379
1388
  this.callbackRegistry.dispatch("onUploadEvent", {
@@ -1986,25 +1995,34 @@ var Se = class {
1986
1995
  },
1987
1996
  httpStatus: void 0
1988
1997
  };
1989
- let { upload: e, storageProvider: t, failedChunks: n } = this.retryContext, r = n.length, i = [], a = 0;
1990
- this.config.debug && console.log(`[ScribeSDK] Retrying ${r} failed uploads`);
1991
- for (let o of n) try {
1998
+ let { storageProvider: e, failedChunks: t } = this.retryContext, n = t.length, r = [], i = 0, a = this.retryContext.upload;
1999
+ try {
2000
+ let e = this.activeSession?.session_id;
2001
+ if (e) {
2002
+ let t = await this.sessionManager.getSessionStatus(this.activeBaseUrl, e);
2003
+ t.data.upload_url && (a = t.data.upload_url, this.retryContext.upload = a);
2004
+ }
2005
+ } catch (e) {
2006
+ this.config.debug && console.log("[ScribeSDK] Failed to refresh upload_url, using existing:", e);
2007
+ }
2008
+ this.config.debug && console.log(`[ScribeSDK] Retrying ${n} failed uploads`);
2009
+ for (let o of t) try {
1992
2010
  await Y(this.transport, {
1993
2011
  fileName: o.fileName,
1994
2012
  blob: o.blob,
1995
- upload: e,
1996
- storageProvider: t,
2013
+ upload: a,
2014
+ storageProvider: e,
1997
2015
  maxRetries: 0
1998
- }), a++, this.callbackRegistry.dispatch("onUploadEvent", {
2016
+ }), i++, this.callbackRegistry.dispatch("onUploadEvent", {
1999
2017
  type: f.PROGRESS,
2000
2018
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2001
2019
  data: {
2002
- successCount: a,
2003
- totalCount: r
2020
+ successCount: i,
2021
+ totalCount: n
2004
2022
  }
2005
2023
  }), this.config.debug && console.log(`[ScribeSDK] Retry succeeded: ${o.fileName}`);
2006
2024
  } catch (e) {
2007
- i.push(o.fileName), this.callbackRegistry.dispatch("onUploadEvent", {
2025
+ r.push(o.fileName), this.callbackRegistry.dispatch("onUploadEvent", {
2008
2026
  type: f.FAILED,
2009
2027
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2010
2028
  data: {
@@ -2013,11 +2031,11 @@ var Se = class {
2013
2031
  }
2014
2032
  }), this.config.debug && console.log(`[ScribeSDK] Retry failed: ${o.fileName}`, e);
2015
2033
  }
2016
- 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`), {
2034
+ 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`), {
2017
2035
  data: {
2018
- retried: r,
2019
- succeeded: a,
2020
- stillFailed: i
2036
+ retried: n,
2037
+ succeeded: i,
2038
+ stillFailed: r
2021
2039
  },
2022
2040
  httpStatus: void 0
2023
2041
  };
@@ -2114,8 +2132,7 @@ var Se = class {
2114
2132
  let t = this.getEffectiveBaseUrl();
2115
2133
  return this.wrapResult(() => {
2116
2134
  try {
2117
- let t = this.discoveryManager.getResolvedConfig();
2118
- this.validator.validateAgainstDiscovery(e, t);
2135
+ this.discoveryManager.getResolvedConfig();
2119
2136
  } catch (e) {
2120
2137
  if (e instanceof y) throw e;
2121
2138
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "med-scribe-alliance-ts-sdk",
3
- "version": "2.0.36",
3
+ "version": "2.0.38",
4
4
  "description": "TypeScript SDK for the MedScribe Alliance Protocol",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",