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

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
@@ -291,7 +291,7 @@ if (!session.success) return;
291
291
  // 2. Upload the file to storage using the session's upload_url
292
292
  const upload = await client.uploadAudioFile(
293
293
  myAudioFile,
294
- 'audio_0.mp3', // storage object name
294
+ '1.mp3', // storage object name
295
295
  session.data.upload_url
296
296
  );
297
297
  if (!upload.success) {
package/dist/index.d.ts CHANGED
@@ -799,9 +799,8 @@ export declare class ScribeClient {
799
799
  /**
800
800
  * Upload a single pre-recorded audio file to storage.
801
801
  * @param file - The audio file/blob to upload.
802
+ * @param fileName - Storage object name, e.g. "1.mp3".
802
803
  * @param upload - The `upload_url` payload from the create-session response.
803
- * @param options.fileName - Storage object name. Defaults to the File's name,
804
- * else `audio_0.<ext>` derived from the MIME type.
805
804
  */
806
805
  uploadAudioFile(file: Blob, fileName: string, upload: SessionUploadInfo): Promise<SDKResult<UploadAudioFileResult>>;
807
806
  /**
@@ -1082,8 +1081,9 @@ export declare class SessionManager {
1082
1081
  * Poll for session completion.
1083
1082
  * Keeps checking getSessionStatus until the session reaches a terminal state
1084
1083
  * (completed, partial, or failed) or the max attempts are exhausted.
1084
+ * Pass templateId to filter the returned status for a specific template.
1085
1085
  */
1086
- pollForCompletion(baseUrl: string, sessionId?: string, options?: PollOptions): Promise<ApiCallResult<GetSessionStatusResponse>>;
1086
+ pollForCompletion(baseUrl: string, sessionId?: string, options?: PollOptions, templateId?: string): Promise<ApiCallResult<GetSessionStatusResponse>>;
1087
1087
  /**
1088
1088
  * Get the current active session, if any.
1089
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"}`);
@@ -1121,7 +1121,7 @@ var pe = {
1121
1121
  };
1122
1122
  }
1123
1123
  getNextFileName() {
1124
- return `audio_${this.chunks.length + 1}.mp3`;
1124
+ return `${this.chunks.length + 1}.mp3`;
1125
1125
  }
1126
1126
  addChunk(e) {
1127
1127
  return this.chunks.push(e), this.chunks.length - 1;
@@ -1603,7 +1603,7 @@ var Se = class {
1603
1603
  totalFiles: 0
1604
1604
  };
1605
1605
  try {
1606
- let e = await this.stopMediaRecorder(), t = `audio_0.${this.getFileExtension()}`;
1606
+ let e = await this.stopMediaRecorder(), t = `1.${this.getFileExtension()}`;
1607
1607
  try {
1608
1608
  return await Y(this.transport, {
1609
1609
  fileName: t,
@@ -2193,7 +2193,7 @@ var Se = class {
2193
2193
  }
2194
2194
  async getSessionStatus(e, t) {
2195
2195
  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));
2196
+ return t?.poll ? this.wrapResult(() => this.sessionManager.pollForCompletion(n, e, t.poll, t.templateId)) : this.wrapResult(() => this.sessionManager.getSessionStatus(n, e, t?.templateId));
2197
2197
  }
2198
2198
  getCurrentSession() {
2199
2199
  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.34",
3
+ "version": "2.0.36",
4
4
  "description": "TypeScript SDK for the MedScribe Alliance Protocol",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",