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 +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +27 -27
- package/package.json +1 -1
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
|
-
'
|
|
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
|
|
851
|
-
if (!
|
|
852
|
-
let
|
|
853
|
-
this.debug && console.log("[ScribeSDK] Polling for completion:",
|
|
854
|
-
maxAttempts:
|
|
855
|
-
intervalMs:
|
|
856
|
-
timeoutMs:
|
|
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 <=
|
|
859
|
-
if (n?.signal?.aborted) throw new v("Polling was aborted", "polling_aborted", void 0, { session_id:
|
|
860
|
-
if (
|
|
861
|
-
session_id:
|
|
862
|
-
timeout_ms:
|
|
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
|
|
864
|
+
let l = await this.getSessionStatus(e, i, r), u = l.data;
|
|
865
865
|
if (n?.onProgress) try {
|
|
866
|
-
n.onProgress(
|
|
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(
|
|
871
|
-
if (t <
|
|
872
|
-
let e =
|
|
873
|
-
if (
|
|
874
|
-
let t =
|
|
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(
|
|
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 ${
|
|
882
|
-
session_id:
|
|
883
|
-
max_attempts:
|
|
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
|
|
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 = `
|
|
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();
|