med-scribe-alliance-ts-sdk 2.0.18 → 2.0.20
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 +33 -13
- package/dist/index.mjs +100 -51
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -120,14 +120,31 @@ export interface ErrorResponse {
|
|
|
120
120
|
/**
|
|
121
121
|
* Result type for all public SDK methods.
|
|
122
122
|
* Expected errors (API failures, auth, validation) are returned — not thrown.
|
|
123
|
+
*
|
|
124
|
+
* `httpStatus` is set when the result was produced by an HTTP call (success or error).
|
|
125
|
+
* It will be undefined for purely local operations (e.g. cached discovery, no-op init).
|
|
123
126
|
*/
|
|
124
127
|
export type SDKResult<T = void> = {
|
|
125
128
|
success: true;
|
|
126
129
|
data: T;
|
|
130
|
+
httpStatus?: number;
|
|
127
131
|
} | {
|
|
128
132
|
success: false;
|
|
129
133
|
error: ScribeError;
|
|
130
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
* Internal return shape for manager methods that wrap an HTTP call.
|
|
137
|
+
* Carries the HTTP status alongside the parsed response data so the
|
|
138
|
+
* ScribeClient boundary can surface it on SDKResult.
|
|
139
|
+
*
|
|
140
|
+
* For composed operations (e.g. recording start = createSession + recorder init),
|
|
141
|
+
* httpStatus reflects the most relevant HTTP call. It is optional because some
|
|
142
|
+
* code paths (cache hits, no-op flows) don't make a request.
|
|
143
|
+
*/
|
|
144
|
+
export type ApiCallResult<T> = {
|
|
145
|
+
data: T;
|
|
146
|
+
httpStatus?: number;
|
|
147
|
+
};
|
|
131
148
|
/**
|
|
132
149
|
* Transport layer types
|
|
133
150
|
*/
|
|
@@ -752,8 +769,11 @@ export declare class ScribeClient {
|
|
|
752
769
|
*/
|
|
753
770
|
reset(): Promise<void>;
|
|
754
771
|
/**
|
|
755
|
-
* Wraps an async operation into SDKResult.
|
|
756
|
-
* Internal
|
|
772
|
+
* Wraps an async manager operation into SDKResult.
|
|
773
|
+
* Internal manager methods always return `ApiCallResult<T>` so the HTTP
|
|
774
|
+
* status from the underlying call (when present) is propagated to the
|
|
775
|
+
* SDKResult success variant. On error, status is preserved via
|
|
776
|
+
* `error.httpStatus`.
|
|
757
777
|
*/
|
|
758
778
|
private wrapResult;
|
|
759
779
|
/**
|
|
@@ -851,7 +871,7 @@ export declare class DiscoveryManager {
|
|
|
851
871
|
* Fetch and validate the discovery document from the well-known endpoint.
|
|
852
872
|
* Caches the result for 1 hour (configurable).
|
|
853
873
|
*/
|
|
854
|
-
fetchDiscovery(baseUrl: string, forceRefresh?: boolean): Promise<ResolvedConfig
|
|
874
|
+
fetchDiscovery(baseUrl: string, forceRefresh?: boolean): Promise<ApiCallResult<ResolvedConfig>>;
|
|
855
875
|
/**
|
|
856
876
|
* Get the resolved runtime config. Throws if discovery hasn't been fetched.
|
|
857
877
|
*/
|
|
@@ -882,32 +902,32 @@ export declare class SessionManager {
|
|
|
882
902
|
* Create a new scribe session.
|
|
883
903
|
* Validates the request structure, sends to server, validates response.
|
|
884
904
|
*/
|
|
885
|
-
createSession(baseUrl: string, request: CreateSessionRequest): Promise<CreateSessionResponse
|
|
905
|
+
createSession(baseUrl: string, request: CreateSessionRequest): Promise<ApiCallResult<CreateSessionResponse>>;
|
|
886
906
|
/**
|
|
887
907
|
* End an active session.
|
|
888
908
|
* If no sessionId is provided, ends the current session.
|
|
889
909
|
*/
|
|
890
|
-
endSession(baseUrl: string, request: EndSessionRequest, sessionId?: string): Promise<EndSessionResponse
|
|
910
|
+
endSession(baseUrl: string, request: EndSessionRequest, sessionId?: string): Promise<ApiCallResult<EndSessionResponse>>;
|
|
891
911
|
/**
|
|
892
912
|
* Get the status of a session.
|
|
893
913
|
* If no sessionId is provided, queries the current session.
|
|
894
914
|
* Pass templateId to filter status for a specific template.
|
|
895
915
|
*/
|
|
896
|
-
getSessionStatus(baseUrl: string, sessionId?: string, templateId?: string): Promise<GetSessionStatusResponse
|
|
916
|
+
getSessionStatus(baseUrl: string, sessionId?: string, templateId?: string): Promise<ApiCallResult<GetSessionStatusResponse>>;
|
|
897
917
|
/**
|
|
898
918
|
* Patch an existing session (e.g., update user_status or processing_status).
|
|
899
919
|
*/
|
|
900
|
-
patchSession(baseUrl: string, request: PatchSessionRequest, sessionId?: string): Promise<PatchSessionResponse
|
|
920
|
+
patchSession(baseUrl: string, request: PatchSessionRequest, sessionId?: string): Promise<ApiCallResult<PatchSessionResponse>>;
|
|
901
921
|
/**
|
|
902
922
|
* Trigger processing for a specific template in a session.
|
|
903
923
|
*/
|
|
904
|
-
processTemplate(baseUrl: string, templateId: string, sessionId?: string): Promise<ProcessTemplateResponse
|
|
924
|
+
processTemplate(baseUrl: string, templateId: string, sessionId?: string): Promise<ApiCallResult<ProcessTemplateResponse>>;
|
|
905
925
|
/**
|
|
906
926
|
* Poll for session completion.
|
|
907
927
|
* Keeps checking getSessionStatus until the session reaches a terminal state
|
|
908
928
|
* (completed, partial, or failed) or the max attempts are exhausted.
|
|
909
929
|
*/
|
|
910
|
-
pollForCompletion(baseUrl: string, sessionId?: string, options?: PollOptions): Promise<GetSessionStatusResponse
|
|
930
|
+
pollForCompletion(baseUrl: string, sessionId?: string, options?: PollOptions): Promise<ApiCallResult<GetSessionStatusResponse>>;
|
|
911
931
|
/**
|
|
912
932
|
* Get the current active session, if any.
|
|
913
933
|
*/
|
|
@@ -963,7 +983,7 @@ export declare class RecordingManager {
|
|
|
963
983
|
* @param accessToken - Current Bearer token for upload auth headers
|
|
964
984
|
* @returns The created session response
|
|
965
985
|
*/
|
|
966
|
-
start(baseUrl: string, options: RecordingOptions, accessToken?: string): Promise<CreateSessionResponse
|
|
986
|
+
start(baseUrl: string, options: RecordingOptions, accessToken?: string): Promise<ApiCallResult<CreateSessionResponse>>;
|
|
967
987
|
/**
|
|
968
988
|
* Start recording for an already-created session.
|
|
969
989
|
* Use this when the session was created externally (e.g. via createSession())
|
|
@@ -977,7 +997,7 @@ export declare class RecordingManager {
|
|
|
977
997
|
startWithExistingSession(baseUrl: string, session: CreateSessionResponse, options?: {
|
|
978
998
|
uploadType?: string;
|
|
979
999
|
deviceId?: string;
|
|
980
|
-
}, accessToken?: string): Promise<void
|
|
1000
|
+
}, accessToken?: string): Promise<ApiCallResult<void>>;
|
|
981
1001
|
/**
|
|
982
1002
|
* Pause the active recording.
|
|
983
1003
|
*/
|
|
@@ -986,7 +1006,7 @@ export declare class RecordingManager {
|
|
|
986
1006
|
* Resume a paused recording.
|
|
987
1007
|
*/
|
|
988
1008
|
resume(): void;
|
|
989
|
-
stop(): Promise<EndRecordingResult
|
|
1009
|
+
stop(): Promise<ApiCallResult<EndRecordingResult>>;
|
|
990
1010
|
/**
|
|
991
1011
|
* End the session, dispatch onSessionEvent, and return the response.
|
|
992
1012
|
* Called from stop() (auto-finalize) and finalizeAfterExternalEndSession()
|
|
@@ -1031,7 +1051,7 @@ export declare class RecordingManager {
|
|
|
1031
1051
|
* Each file is re-uploaded via transport.request() with retry logic.
|
|
1032
1052
|
* Successfully retried files are removed from the retry context.
|
|
1033
1053
|
*/
|
|
1034
|
-
retryFailedUploads(): Promise<RetryUploadResult
|
|
1054
|
+
retryFailedUploads(): Promise<ApiCallResult<RetryUploadResult>>;
|
|
1035
1055
|
/**
|
|
1036
1056
|
* Create the appropriate recorder based on upload type.
|
|
1037
1057
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -159,7 +159,7 @@ var r = "/.well-known/medscribealliance", i = 3600 * 1e3, a = /* @__PURE__ */ fu
|
|
|
159
159
|
upload_type: e.string().min(1, "upload_type is required"),
|
|
160
160
|
communication_protocol: e.string().min(1, "communication_protocol is required"),
|
|
161
161
|
model: e.string().optional(),
|
|
162
|
-
language_hint: e.array(e.string()
|
|
162
|
+
language_hint: e.array(e.string()).optional(),
|
|
163
163
|
transcript_language: e.string().optional(),
|
|
164
164
|
additional_data: e.record(e.string(), e.any()).optional(),
|
|
165
165
|
session_mode: e.string().optional(),
|
|
@@ -250,7 +250,7 @@ var r = "/.well-known/medscribealliance", i = 3600 * 1e3, a = /* @__PURE__ */ fu
|
|
|
250
250
|
uploadType: e.string().optional(),
|
|
251
251
|
communicationProtocol: e.string().optional(),
|
|
252
252
|
model: e.string().optional(),
|
|
253
|
-
languageHint: e.array(e.string()
|
|
253
|
+
languageHint: e.array(e.string()).optional(),
|
|
254
254
|
transcriptLanguage: e.string().optional(),
|
|
255
255
|
deviceId: e.string().optional(),
|
|
256
256
|
additionalData: e.record(e.string(), e.any()).optional(),
|
|
@@ -652,7 +652,10 @@ var V = class {
|
|
|
652
652
|
}
|
|
653
653
|
async fetchDiscovery(e, t = !1) {
|
|
654
654
|
try {
|
|
655
|
-
if (!t && this.resolvedConfig && this.isCacheValid()) return this.debug && console.log("[ScribeSDK] Using cached discovery document"),
|
|
655
|
+
if (!t && this.resolvedConfig && this.isCacheValid()) return this.debug && console.log("[ScribeSDK] Using cached discovery document"), {
|
|
656
|
+
data: this.resolvedConfig,
|
|
657
|
+
httpStatus: void 0
|
|
658
|
+
};
|
|
656
659
|
let n = e + r;
|
|
657
660
|
this.debug && console.log("[ScribeSDK] Fetching discovery from:", n);
|
|
658
661
|
let i = await this.transport.request({
|
|
@@ -661,7 +664,10 @@ var V = class {
|
|
|
661
664
|
});
|
|
662
665
|
this.validator.validateDiscoveryResponse(i.data);
|
|
663
666
|
let a = i.data, o = B(a);
|
|
664
|
-
return this.cachedDocument = a, this.resolvedConfig = o, this.cacheTimestamp = Date.now(), this.debug && console.log("[ScribeSDK] Discovery complete:", a.service?.name ?? a.protocol),
|
|
667
|
+
return this.cachedDocument = a, this.resolvedConfig = o, this.cacheTimestamp = Date.now(), this.debug && console.log("[ScribeSDK] Discovery complete:", a.service?.name ?? a.protocol), {
|
|
668
|
+
data: o,
|
|
669
|
+
httpStatus: i.status
|
|
670
|
+
};
|
|
665
671
|
} catch (t) {
|
|
666
672
|
throw t instanceof h ? t : new h(`Failed to fetch discovery document: ${t instanceof Error ? t.message : "Unknown error"}`, { baseUrl: e });
|
|
667
673
|
}
|
|
@@ -724,7 +730,10 @@ var V = class {
|
|
|
724
730
|
url: n,
|
|
725
731
|
body: t
|
|
726
732
|
});
|
|
727
|
-
return this.validator.validateCreateSessionResponse(r.data), this.currentSession = r.data, this.debug && console.log("[ScribeSDK] Session created:", r.data.session_id),
|
|
733
|
+
return this.validator.validateCreateSessionResponse(r.data), this.currentSession = r.data, this.debug && console.log("[ScribeSDK] Session created:", r.data.session_id), {
|
|
734
|
+
data: r.data,
|
|
735
|
+
httpStatus: r.status
|
|
736
|
+
};
|
|
728
737
|
} catch (e) {
|
|
729
738
|
throw e instanceof p ? e : new p(`Failed to create session: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
730
739
|
}
|
|
@@ -741,7 +750,10 @@ var V = class {
|
|
|
741
750
|
url: i,
|
|
742
751
|
body: t
|
|
743
752
|
});
|
|
744
|
-
return this.validator.validateEndSessionResponse(a.data), this.currentSession?.session_id === r && (this.currentSession = null), this.debug && console.log("[ScribeSDK] Session ended:", r, a.data.status),
|
|
753
|
+
return this.validator.validateEndSessionResponse(a.data), this.currentSession?.session_id === r && (this.currentSession = null), this.debug && console.log("[ScribeSDK] Session ended:", r, a.data.status), {
|
|
754
|
+
data: a.data,
|
|
755
|
+
httpStatus: a.status
|
|
756
|
+
};
|
|
745
757
|
} catch (e) {
|
|
746
758
|
throw e instanceof p ? e : new p(`Failed to end session: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
747
759
|
}
|
|
@@ -758,7 +770,10 @@ var V = class {
|
|
|
758
770
|
url: i,
|
|
759
771
|
acceptStatuses: [410]
|
|
760
772
|
});
|
|
761
|
-
return this.validator.validateGetSessionStatusResponse(a.data), this.debug && console.log("[ScribeSDK] Session status:", r, a.data.status),
|
|
773
|
+
return this.validator.validateGetSessionStatusResponse(a.data), this.debug && console.log("[ScribeSDK] Session status:", r, a.data.status), {
|
|
774
|
+
data: a.data,
|
|
775
|
+
httpStatus: a.status
|
|
776
|
+
};
|
|
762
777
|
} catch (e) {
|
|
763
778
|
throw e instanceof p ? e : new p(`Failed to get session status: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
764
779
|
}
|
|
@@ -775,7 +790,10 @@ var V = class {
|
|
|
775
790
|
url: i,
|
|
776
791
|
body: t
|
|
777
792
|
});
|
|
778
|
-
return this.validator.validatePatchSessionResponse(a.data), this.debug && console.log("[ScribeSDK] Session patched:", r, a.data.status),
|
|
793
|
+
return this.validator.validatePatchSessionResponse(a.data), this.debug && console.log("[ScribeSDK] Session patched:", r, a.data.status), {
|
|
794
|
+
data: a.data,
|
|
795
|
+
httpStatus: a.status
|
|
796
|
+
};
|
|
779
797
|
} catch (e) {
|
|
780
798
|
throw e instanceof p ? e : new p(`Failed to patch session: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
781
799
|
}
|
|
@@ -791,7 +809,10 @@ var V = class {
|
|
|
791
809
|
method: "POST",
|
|
792
810
|
url: i
|
|
793
811
|
});
|
|
794
|
-
return this.validator.validateProcessTemplateResponse(a.data), this.debug && console.log("[ScribeSDK] Template processing triggered:", t, a.data.status),
|
|
812
|
+
return this.validator.validateProcessTemplateResponse(a.data), this.debug && console.log("[ScribeSDK] Template processing triggered:", t, a.data.status), {
|
|
813
|
+
data: a.data,
|
|
814
|
+
httpStatus: a.status
|
|
815
|
+
};
|
|
795
816
|
} catch (e) {
|
|
796
817
|
throw e instanceof p ? e : new p(`Failed to process template: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
797
818
|
}
|
|
@@ -807,13 +828,13 @@ var V = class {
|
|
|
807
828
|
});
|
|
808
829
|
for (let t = 1; t <= i; t++) {
|
|
809
830
|
if (n?.signal?.aborted) throw new p("Polling was aborted", "polling_aborted", void 0, { session_id: r });
|
|
810
|
-
let o = await this.getSessionStatus(e, r);
|
|
831
|
+
let o = await this.getSessionStatus(e, r), s = o.data;
|
|
811
832
|
if (n?.onProgress) try {
|
|
812
|
-
n.onProgress(
|
|
833
|
+
n.onProgress(s);
|
|
813
834
|
} catch (e) {
|
|
814
835
|
console.error("[ScribeSDK] Error in poll onProgress callback:", e);
|
|
815
836
|
}
|
|
816
|
-
if (this.isTerminalStatus(
|
|
837
|
+
if (this.isTerminalStatus(s.status)) return this.debug && console.log("[ScribeSDK] Poll complete:", r, s.status, `(attempt ${t})`), o;
|
|
817
838
|
t < i && await this.sleepWithAbort(a, n?.signal);
|
|
818
839
|
}
|
|
819
840
|
throw new p(`Polling timed out after ${i} attempts for session '${r}'`, "polling_timeout", void 0, {
|
|
@@ -1554,9 +1575,10 @@ var ie = class {
|
|
|
1554
1575
|
session_id: t.sessionId
|
|
1555
1576
|
};
|
|
1556
1577
|
try {
|
|
1557
|
-
let i;
|
|
1578
|
+
let i, o;
|
|
1558
1579
|
try {
|
|
1559
|
-
|
|
1580
|
+
let t = await this.sessionManager.createSession(e, a);
|
|
1581
|
+
i = t.data, o = t.httpStatus;
|
|
1560
1582
|
} catch (e) {
|
|
1561
1583
|
throw this.dispatchStartError("transport_error", "session_creation_failed", e), e;
|
|
1562
1584
|
}
|
|
@@ -1565,14 +1587,14 @@ var ie = class {
|
|
|
1565
1587
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1566
1588
|
data: i
|
|
1567
1589
|
}), this.recorder = this.createRecorder(r);
|
|
1568
|
-
let
|
|
1590
|
+
let s = {
|
|
1569
1591
|
accessToken: n,
|
|
1570
1592
|
uploadUrl: i.upload_url,
|
|
1571
1593
|
uploadHeaders: this.buildUploadHeaders(n),
|
|
1572
1594
|
sessionId: i.session_id
|
|
1573
1595
|
};
|
|
1574
1596
|
try {
|
|
1575
|
-
this.recorder.initialize(i,
|
|
1597
|
+
this.recorder.initialize(i, s);
|
|
1576
1598
|
} catch (e) {
|
|
1577
1599
|
throw this.cleanupRecordingState(), this.dispatchStartError("validation_error", "recorder_init_failed", e), e;
|
|
1578
1600
|
}
|
|
@@ -1585,7 +1607,10 @@ var ie = class {
|
|
|
1585
1607
|
return this._isRecording = !0, this.callbackRegistry.dispatch("onRecordingStateChange", {
|
|
1586
1608
|
type: "started",
|
|
1587
1609
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1588
|
-
}), this.config.debug && console.log("[ScribeSDK] Recording started:", i.session_id),
|
|
1610
|
+
}), this.config.debug && console.log("[ScribeSDK] Recording started:", i.session_id), {
|
|
1611
|
+
data: i,
|
|
1612
|
+
httpStatus: o
|
|
1613
|
+
};
|
|
1589
1614
|
} finally {
|
|
1590
1615
|
this._isStarting = !1;
|
|
1591
1616
|
}
|
|
@@ -1614,10 +1639,13 @@ var ie = class {
|
|
|
1614
1639
|
} catch (e) {
|
|
1615
1640
|
throw this.cleanupRecordingState(), this.dispatchStartError("vad_error", "vad_start_failed", e), e;
|
|
1616
1641
|
}
|
|
1617
|
-
this._isRecording = !0, this.callbackRegistry.dispatch("onRecordingStateChange", {
|
|
1642
|
+
return this._isRecording = !0, this.callbackRegistry.dispatch("onRecordingStateChange", {
|
|
1618
1643
|
type: "started",
|
|
1619
1644
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1620
|
-
}), this.config.debug && console.log("[ScribeSDK] Recording started with existing session:", t.session_id)
|
|
1645
|
+
}), this.config.debug && console.log("[ScribeSDK] Recording started with existing session:", t.session_id), {
|
|
1646
|
+
data: void 0,
|
|
1647
|
+
httpStatus: void 0
|
|
1648
|
+
};
|
|
1621
1649
|
} finally {
|
|
1622
1650
|
this._isStarting = !1;
|
|
1623
1651
|
}
|
|
@@ -1636,17 +1664,20 @@ var ie = class {
|
|
|
1636
1664
|
}
|
|
1637
1665
|
async stop() {
|
|
1638
1666
|
if (!this.recorder || !this._isRecording) return {
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1667
|
+
data: {
|
|
1668
|
+
failedUploads: [],
|
|
1669
|
+
totalFiles: 0,
|
|
1670
|
+
sessionEnded: !1
|
|
1671
|
+
},
|
|
1672
|
+
httpStatus: void 0
|
|
1642
1673
|
};
|
|
1643
|
-
let e = !1;
|
|
1674
|
+
let e = !1, t;
|
|
1644
1675
|
try {
|
|
1645
|
-
let
|
|
1676
|
+
let n = await this.recorder.stop();
|
|
1646
1677
|
this.preserveRetryContext(), this._isRecording = !1;
|
|
1647
|
-
let
|
|
1648
|
-
if (
|
|
1649
|
-
|
|
1678
|
+
let r = n.failedUploads;
|
|
1679
|
+
if (r.length > 0) try {
|
|
1680
|
+
r = (await this.retryFailedUploads()).data.stillFailed;
|
|
1650
1681
|
} catch (e) {
|
|
1651
1682
|
console.error("[ScribeSDK] Internal retry pass failed:", e), this.callbackRegistry.dispatch("onError", {
|
|
1652
1683
|
type: "transport_error",
|
|
@@ -1657,24 +1688,27 @@ var ie = class {
|
|
|
1657
1688
|
}
|
|
1658
1689
|
});
|
|
1659
1690
|
}
|
|
1660
|
-
let
|
|
1661
|
-
failedUploads:
|
|
1662
|
-
totalFiles:
|
|
1691
|
+
let i = {
|
|
1692
|
+
failedUploads: r,
|
|
1693
|
+
totalFiles: n.totalFiles,
|
|
1663
1694
|
sessionEnded: !1
|
|
1664
1695
|
};
|
|
1665
|
-
if (
|
|
1666
|
-
let
|
|
1667
|
-
|
|
1696
|
+
if (r.length === 0 && this.activeSession) {
|
|
1697
|
+
let r = await this.finalizeSession(n.totalFiles, n.totalFiles);
|
|
1698
|
+
r && (i.sessionEnded = !0, i.endSessionResponse = r.data, t = r.httpStatus, e = !0);
|
|
1668
1699
|
}
|
|
1669
1700
|
return this.callbackRegistry.dispatch("onRecordingStateChange", {
|
|
1670
1701
|
type: "ended",
|
|
1671
1702
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1672
|
-
data:
|
|
1703
|
+
data: i
|
|
1673
1704
|
}), this.config.debug && console.log("[ScribeSDK] Recording stopped:", {
|
|
1674
|
-
totalFiles:
|
|
1675
|
-
failedUploads:
|
|
1676
|
-
sessionEnded:
|
|
1677
|
-
}),
|
|
1705
|
+
totalFiles: i.totalFiles,
|
|
1706
|
+
failedUploads: i.failedUploads.length,
|
|
1707
|
+
sessionEnded: i.sessionEnded
|
|
1708
|
+
}), {
|
|
1709
|
+
data: i,
|
|
1710
|
+
httpStatus: t
|
|
1711
|
+
};
|
|
1678
1712
|
} catch (e) {
|
|
1679
1713
|
return console.error("[ScribeSDK] Error stopping recording:", e), this.callbackRegistry.dispatch("onError", {
|
|
1680
1714
|
type: "transport_error",
|
|
@@ -1684,9 +1718,12 @@ var ie = class {
|
|
|
1684
1718
|
message: e instanceof Error ? e.message : "Failed to stop recording"
|
|
1685
1719
|
}
|
|
1686
1720
|
}), {
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1721
|
+
data: {
|
|
1722
|
+
failedUploads: [],
|
|
1723
|
+
totalFiles: 0,
|
|
1724
|
+
sessionEnded: !1
|
|
1725
|
+
},
|
|
1726
|
+
httpStatus: void 0
|
|
1690
1727
|
};
|
|
1691
1728
|
} finally {
|
|
1692
1729
|
e ? this.cleanupRecordingState() : this.partialCleanupAfterFailedFinalize();
|
|
@@ -1701,7 +1738,7 @@ var ie = class {
|
|
|
1701
1738
|
return this.callbackRegistry.dispatch("onSessionEvent", {
|
|
1702
1739
|
type: "ended",
|
|
1703
1740
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1704
|
-
data: n
|
|
1741
|
+
data: n.data
|
|
1705
1742
|
}), n;
|
|
1706
1743
|
} catch (e) {
|
|
1707
1744
|
console.error("[ScribeSDK] Failed to end session:", e), this.callbackRegistry.dispatch("onError", {
|
|
@@ -1753,9 +1790,12 @@ var ie = class {
|
|
|
1753
1790
|
async retryFailedUploads() {
|
|
1754
1791
|
if (this._isRecording) throw new p("Cannot retry uploads while recording is active.");
|
|
1755
1792
|
if (!this.retryContext || this.retryContext.failedChunks.length === 0) return {
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1793
|
+
data: {
|
|
1794
|
+
retried: 0,
|
|
1795
|
+
succeeded: 0,
|
|
1796
|
+
stillFailed: []
|
|
1797
|
+
},
|
|
1798
|
+
httpStatus: void 0
|
|
1759
1799
|
};
|
|
1760
1800
|
let { uploadUrl: e, failedChunks: t } = this.retryContext, n = t.length, r = [], i = 0;
|
|
1761
1801
|
this.config.debug && console.log(`[ScribeSDK] Retrying ${n} failed uploads`);
|
|
@@ -1785,9 +1825,12 @@ var ie = class {
|
|
|
1785
1825
|
}), this.config.debug && console.log(`[ScribeSDK] Retry failed: ${a.fileName}`, e);
|
|
1786
1826
|
}
|
|
1787
1827
|
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`), {
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1828
|
+
data: {
|
|
1829
|
+
retried: n,
|
|
1830
|
+
succeeded: i,
|
|
1831
|
+
stillFailed: r
|
|
1832
|
+
},
|
|
1833
|
+
httpStatus: void 0
|
|
1791
1834
|
};
|
|
1792
1835
|
}
|
|
1793
1836
|
createRecorder(e) {
|
|
@@ -1854,7 +1897,11 @@ var ie = class {
|
|
|
1854
1897
|
success: !0,
|
|
1855
1898
|
data: void 0
|
|
1856
1899
|
} : this.wrapResult(async () => {
|
|
1857
|
-
|
|
1900
|
+
let e;
|
|
1901
|
+
return this.config.autoDiscovery !== !1 && (e = (await this.discoveryManager.fetchDiscovery(this.config.baseUrl)).httpStatus), this.isInitialized = !0, {
|
|
1902
|
+
data: void 0,
|
|
1903
|
+
httpStatus: e
|
|
1904
|
+
};
|
|
1858
1905
|
});
|
|
1859
1906
|
}
|
|
1860
1907
|
async startRecording(e) {
|
|
@@ -1913,7 +1960,7 @@ var ie = class {
|
|
|
1913
1960
|
return r && this.recordingManager.finalizeAfterExternalEndSession(r), this.callbackRegistry.dispatch("onSessionEvent", {
|
|
1914
1961
|
type: "ended",
|
|
1915
1962
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1916
|
-
data: i
|
|
1963
|
+
data: i.data
|
|
1917
1964
|
}), i;
|
|
1918
1965
|
});
|
|
1919
1966
|
}
|
|
@@ -1975,9 +2022,11 @@ var ie = class {
|
|
|
1975
2022
|
}
|
|
1976
2023
|
async wrapResult(e) {
|
|
1977
2024
|
try {
|
|
2025
|
+
let t = await e();
|
|
1978
2026
|
return {
|
|
1979
2027
|
success: !0,
|
|
1980
|
-
data:
|
|
2028
|
+
data: t.data,
|
|
2029
|
+
httpStatus: t.httpStatus
|
|
1981
2030
|
};
|
|
1982
2031
|
} catch (e) {
|
|
1983
2032
|
return {
|