med-scribe-alliance-ts-sdk 2.0.32 → 2.0.33
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 +72 -6
- package/dist/index.mjs +311 -198
- package/dist/worker.bundle.js +67 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -98,7 +98,8 @@ export declare enum ErrorCode {
|
|
|
98
98
|
VAD_START_FAILED = "vad_start_failed",
|
|
99
99
|
STOP_FAILED = "stop_failed",
|
|
100
100
|
INTERNAL_RETRY_FAILED = "internal_retry_failed",
|
|
101
|
-
SESSION_END_FAILED = "session_end_failed"
|
|
101
|
+
SESSION_END_FAILED = "session_end_failed",
|
|
102
|
+
UNSUPPORTED_STORAGE_PROVIDER = "unsupported_storage_provider"
|
|
102
103
|
}
|
|
103
104
|
export declare enum HttpStatus {
|
|
104
105
|
OK = 200,
|
|
@@ -155,6 +156,11 @@ export declare class UploadError extends ScribeError {
|
|
|
155
156
|
constructor(message: string, failedFiles: string[], details?: Record<string, any>);
|
|
156
157
|
toJSON(): Record<string, any>;
|
|
157
158
|
}
|
|
159
|
+
/** Thrown when discovery advertises a storage provider the SDK has no wrapper for. */
|
|
160
|
+
export declare class UnsupportedStorageProviderError extends ScribeError {
|
|
161
|
+
readonly provider: string;
|
|
162
|
+
constructor(provider: string);
|
|
163
|
+
}
|
|
158
164
|
export interface ApiError {
|
|
159
165
|
code: ErrorCode | string;
|
|
160
166
|
message: string;
|
|
@@ -201,6 +207,13 @@ export interface TransportRequest {
|
|
|
201
207
|
body?: any;
|
|
202
208
|
isUpload?: boolean;
|
|
203
209
|
uploadBlob?: Blob;
|
|
210
|
+
uploadFileName?: string;
|
|
211
|
+
/** Multipart form fields; when set, the request is multipart/form-data with uploadBlob as the file. */
|
|
212
|
+
uploadFormFields?: Record<string, string>;
|
|
213
|
+
/** Multipart field name for the file part. Defaults to 'file'. */
|
|
214
|
+
uploadFileFieldName?: string;
|
|
215
|
+
/** Attach the service Bearer + flavour header. Defaults to true; false for presigned uploads. */
|
|
216
|
+
attachAuth?: boolean;
|
|
204
217
|
/** Additional HTTP status codes to treat as success (not throw). */
|
|
205
218
|
acceptStatuses?: number[];
|
|
206
219
|
maxRetries?: number;
|
|
@@ -229,8 +242,14 @@ export interface IpcRequest {
|
|
|
229
242
|
url: string;
|
|
230
243
|
headers?: Record<string, string>;
|
|
231
244
|
body?: any;
|
|
232
|
-
/** Base64-encoded
|
|
245
|
+
/** Base64-encoded file bytes for uploads. */
|
|
233
246
|
blobData?: string;
|
|
247
|
+
/** Multipart fields for presigned uploads — host builds multipart from these + blobData (no auth header). */
|
|
248
|
+
uploadFormFields?: Record<string, string>;
|
|
249
|
+
/** Multipart field name for the file part. Defaults to 'file'. */
|
|
250
|
+
uploadFileFieldName?: string;
|
|
251
|
+
/** File name for the multipart file part. */
|
|
252
|
+
uploadFileName?: string;
|
|
234
253
|
}
|
|
235
254
|
export interface IpcResponse {
|
|
236
255
|
correlationId: string;
|
|
@@ -304,6 +323,7 @@ export interface CapabilitiesInfo {
|
|
|
304
323
|
upload_methods?: string[];
|
|
305
324
|
webhook_delivery?: boolean;
|
|
306
325
|
client_sdk_delivery?: boolean;
|
|
326
|
+
storage_provider?: string;
|
|
307
327
|
}
|
|
308
328
|
export interface ModelConfig {
|
|
309
329
|
id: string;
|
|
@@ -332,6 +352,7 @@ export interface ResolvedConfig {
|
|
|
332
352
|
autoDetectLanguage: boolean;
|
|
333
353
|
supportedAudioFormats: string[];
|
|
334
354
|
supportedUploadMethods: string[];
|
|
355
|
+
storageProvider: string;
|
|
335
356
|
maxChunkDurationSeconds: number;
|
|
336
357
|
/** modelId -> max session duration in seconds */
|
|
337
358
|
maxSessionDurationSeconds: Map<string, number>;
|
|
@@ -360,12 +381,14 @@ export interface CreateSessionRequest {
|
|
|
360
381
|
patient_details?: PatientDetails;
|
|
361
382
|
session_id?: string;
|
|
362
383
|
}
|
|
384
|
+
/** Provider-specific upload payload; validated/interpreted by the StorageProvider, not the session schema. */
|
|
385
|
+
export type SessionUploadInfo = Record<string, unknown>;
|
|
363
386
|
export interface CreateSessionResponse {
|
|
364
387
|
session_id: string;
|
|
365
388
|
status: SessionStatus;
|
|
366
389
|
created_at: string;
|
|
367
390
|
expires_at: string;
|
|
368
|
-
upload_url:
|
|
391
|
+
upload_url: SessionUploadInfo;
|
|
369
392
|
patient_details?: PatientDetails;
|
|
370
393
|
}
|
|
371
394
|
export interface EndSessionRequest {
|
|
@@ -472,7 +495,9 @@ export interface RecordingOptions {
|
|
|
472
495
|
}
|
|
473
496
|
export interface RecorderConfig {
|
|
474
497
|
accessToken?: string;
|
|
475
|
-
|
|
498
|
+
/** Provider-specific upload payload from the create-session response. */
|
|
499
|
+
upload: SessionUploadInfo;
|
|
500
|
+
storageProvider: string;
|
|
476
501
|
uploadHeaders: Record<string, string>;
|
|
477
502
|
sessionId: string;
|
|
478
503
|
}
|
|
@@ -648,7 +673,9 @@ export interface WorkerCompressAndUploadMessage {
|
|
|
648
673
|
type: "compress_and_upload";
|
|
649
674
|
audioFrames: Float32Array;
|
|
650
675
|
fileName: string;
|
|
651
|
-
|
|
676
|
+
storageProvider: string;
|
|
677
|
+
/** Provider-specific upload payload from the create-session response. */
|
|
678
|
+
upload: unknown;
|
|
652
679
|
headers: Record<string, string>;
|
|
653
680
|
}
|
|
654
681
|
export interface WorkerWaitForUploadsMessage {
|
|
@@ -877,6 +904,41 @@ export declare class ScribeClient {
|
|
|
877
904
|
private getEffectiveBaseUrl;
|
|
878
905
|
private validateConfig;
|
|
879
906
|
}
|
|
907
|
+
/**
|
|
908
|
+
* Storage provider abstraction — the only part of the upload flow that varies
|
|
909
|
+
* between backends (AWS S3, GCP, ...). A provider is a pure, DOM-free request
|
|
910
|
+
* builder so it runs on the main thread, in the SharedWorker, and over IPC.
|
|
911
|
+
*
|
|
912
|
+
* To add a provider: implement StorageProvider in `<name>-provider.ts` and
|
|
913
|
+
* register it in `storage-provider-factory.ts`. No other changes needed.
|
|
914
|
+
*/
|
|
915
|
+
export interface UploadContext {
|
|
916
|
+
fileName: string;
|
|
917
|
+
blob: Blob;
|
|
918
|
+
upload: unknown;
|
|
919
|
+
}
|
|
920
|
+
export interface PreparedUpload {
|
|
921
|
+
url: string;
|
|
922
|
+
method: "POST" | "PUT";
|
|
923
|
+
bodyMode: "multipart" | "binary";
|
|
924
|
+
formFields?: Record<string, string>;
|
|
925
|
+
fileFieldName?: string;
|
|
926
|
+
headers: Record<string, string>;
|
|
927
|
+
attachAuth: boolean;
|
|
928
|
+
}
|
|
929
|
+
export interface StorageProvider {
|
|
930
|
+
/** Matches discovery's `capabilities.storage_provider`. */
|
|
931
|
+
readonly name: string;
|
|
932
|
+
/** @throws UploadError if the upload payload is malformed. */
|
|
933
|
+
prepareUpload(ctx: UploadContext): PreparedUpload;
|
|
934
|
+
}
|
|
935
|
+
export declare class AwsS3StorageProvider implements StorageProvider {
|
|
936
|
+
readonly name = "aws";
|
|
937
|
+
prepareUpload({ fileName, blob, upload }: UploadContext): PreparedUpload;
|
|
938
|
+
}
|
|
939
|
+
export declare function isStorageProviderSupported(name: string): boolean;
|
|
940
|
+
/** @throws UnsupportedStorageProviderError if no wrapper is registered. */
|
|
941
|
+
export declare function getStorageProvider(name: string): StorageProvider;
|
|
880
942
|
export declare class CallbackRegistry {
|
|
881
943
|
private handlers;
|
|
882
944
|
/**
|
|
@@ -1132,7 +1194,7 @@ export declare class RecordingManager {
|
|
|
1132
1194
|
finalizeAfterExternalEndSession(sessionId: string): void;
|
|
1133
1195
|
/**
|
|
1134
1196
|
* Retry uploading audio files that failed during the last recording.
|
|
1135
|
-
* Uses the stored MP3 blobs and the
|
|
1197
|
+
* Uses the stored MP3 blobs and the same storage provider as the recording.
|
|
1136
1198
|
*
|
|
1137
1199
|
* Each file is re-uploaded via transport.request() with retry logic.
|
|
1138
1200
|
* Successfully retried files are removed from the retry context.
|
|
@@ -1142,6 +1204,10 @@ export declare class RecordingManager {
|
|
|
1142
1204
|
* Create the appropriate recorder based on upload type.
|
|
1143
1205
|
*/
|
|
1144
1206
|
private createRecorder;
|
|
1207
|
+
/** Storage provider name from discovery; defaults to 'aws'. */
|
|
1208
|
+
private getStorageProviderName;
|
|
1209
|
+
/** Validate the provider has a wrapper (throws UnsupportedStorageProviderError) and return its name. */
|
|
1210
|
+
private resolveStorageProviderName;
|
|
1145
1211
|
/**
|
|
1146
1212
|
* Build upload headers from the current auth state.
|
|
1147
1213
|
*/
|