med-scribe-alliance-ts-sdk 2.0.44 → 2.0.47

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
@@ -198,7 +198,7 @@ await client.reset(); // stops recording if active, clears all state and caches
198
198
  - **`cancelSession()` does NOT trigger processing.** It stops the recorder locally, cleans up state, and tells the server the session is cancelled. No `endSession` call is made to the backend.
199
199
  - **All async methods return `SDKResult<T>`, never throw.** Always check `result.success` before accessing `result.data`. Errors are in `result.error`.
200
200
  - **The SDK validates inputs against the discovery document.** If the server doesn't support an upload type, language, or model you requested, you'll get a `ValidationError` before the API call is made.
201
- - **Audio uploads go to a server-selected storage backend.** Discovery's `capabilities.storage_provider` (default `aws`) decides the backend; uploads go directly to it (e.g. S3 presigned POST).
201
+ - **Audio uploads go to a server-selected storage backend.** The create-session response decides it: `storage_provider: "aws"` with an `upload_url` object means a direct S3 presigned POST; an `upload_url` string means the audio is posted to the backend endpoint instead. Discovery's `capabilities.storage_providers` only advertises which backends the deployment can mint URLs for.
202
202
 
203
203
  - **SharedWorker is optional.** If you provide `workerScriptUrl`, the SDK offloads MP3 compression and upload to a SharedWorker. If the worker fails to load, it silently falls back to main-thread processing.
204
204
  - **Microphone permission is requested on `startRecording()`.** The browser will prompt the user for mic access. If denied, you'll get an error via `onError` callback.
@@ -390,7 +390,7 @@ interface RecordingOptions {
390
390
  | `isRecordingPaused()` | `boolean` | Whether the active recording is paused. |
391
391
  | `retryFailedUploads()` | `SDKResult<RetryUploadResult>` | Retry uploads that failed during the last recording. |
392
392
  | `hasFailedUploads()` | `boolean` | Whether there are retryable failed uploads. |
393
- | `uploadAudioFile(file, fileName, upload)` | `SDKResult<UploadAudioFileResult>` | Upload one pre-recorded audio file to storage using a session's `upload_url`. No mic/recorder. |
393
+ | `uploadAudioFile(file, fileName, upload, options?)` | `SDKResult<UploadAudioFileResult>` | Upload one pre-recorded audio file using a session's `upload_url` (string or presigned object). No mic/recorder. The provider is taken from the session's `storage_provider`, or inferred from the payload shape; `options.storageProvider` overrides both. |
394
394
 
395
395
  ### Session
396
396
 
@@ -628,7 +628,7 @@ console.log(result.data.session_id);
628
628
  | `TransportError` | — | Network / IPC failure |
629
629
  | `WorkerError` | — | SharedWorker failure |
630
630
  | `UploadError` | — | Audio upload failure (failed transfer, or malformed `upload_url` payload). Has `failedFiles: string[]`. |
631
- | `UnsupportedStorageProviderError` | — | Discovery advertised a `storage_provider` this SDK build has no wrapper for. Thrown at `startRecording`. Has `provider: string`. |
631
+ | `UnsupportedStorageProviderError` | — | The session's `storage_provider` names a backend this SDK build has no wrapper for. Thrown at `startRecording`. Has `provider: string`. |
632
632
 
633
633
  ## SharedWorker Support
634
634
 
package/dist/index.d.ts CHANGED
@@ -323,7 +323,7 @@ export interface CapabilitiesInfo {
323
323
  upload_methods?: string[];
324
324
  webhook_delivery?: boolean;
325
325
  client_sdk_delivery?: boolean;
326
- storage_provider?: string;
326
+ storage_providers?: string[];
327
327
  }
328
328
  export interface ModelConfig {
329
329
  id: string;
@@ -352,7 +352,7 @@ export interface ResolvedConfig {
352
352
  autoDetectLanguage: boolean;
353
353
  supportedAudioFormats: string[];
354
354
  supportedUploadMethods: string[];
355
- storageProvider: string;
355
+ storageProviders: string[];
356
356
  maxChunkDurationSeconds: number;
357
357
  /** modelId -> max session duration in seconds */
358
358
  maxSessionDurationSeconds: Map<string, number>;
@@ -381,14 +381,14 @@ export interface CreateSessionRequest {
381
381
  patient_details?: PatientDetails;
382
382
  session_id?: string;
383
383
  }
384
- /** Provider-specific upload payload; validated/interpreted by the StorageProvider, not the session schema. */
385
- export type SessionUploadInfo = Record<string, unknown>;
384
+ export type SessionUploadInfo = string | Record<string, unknown>;
386
385
  export interface CreateSessionResponse {
387
386
  session_id: string;
388
387
  status: SessionStatus;
389
388
  created_at: string;
390
389
  expires_at: string;
391
390
  upload_url: SessionUploadInfo;
391
+ storage_provider?: string | null;
392
392
  patient_details?: PatientDetails;
393
393
  }
394
394
  export interface EndSessionRequest {
@@ -818,7 +818,9 @@ export declare class ScribeClient {
818
818
  * @param fileName - Storage object name, e.g. "1.mp3".
819
819
  * @param upload - The `upload_url` payload from the create-session response.
820
820
  */
821
- uploadAudioFile(file: Blob, fileName: string, upload: SessionUploadInfo): Promise<SDKResult<UploadAudioFileResult>>;
821
+ uploadAudioFile(file: Blob, fileName: string, upload: SessionUploadInfo, options?: {
822
+ storageProvider?: string | null;
823
+ }): Promise<SDKResult<UploadAudioFileResult>>;
822
824
  /**
823
825
  * Create a session directly (without starting a recording).
824
826
  */
@@ -934,8 +936,7 @@ export declare class ScribeClient {
934
936
  */
935
937
  private createTransport;
936
938
  private resolveWorkerConfig;
937
- /** Storage provider name from discovery; defaults to 'aws'. */
938
- private getStorageProviderName;
939
+ private providerForUpload;
939
940
  /**
940
941
  * Get the effective base URL — prefer discovery's base_url, fall back to config.
941
942
  */
@@ -965,7 +966,6 @@ export interface PreparedUpload {
965
966
  attachAuth: boolean;
966
967
  }
967
968
  export interface StorageProvider {
968
- /** Matches discovery's `capabilities.storage_provider`. */
969
969
  readonly name: string;
970
970
  /** @throws UploadError if the upload payload is malformed. */
971
971
  prepareUpload(ctx: UploadContext): PreparedUpload;
@@ -974,6 +974,14 @@ export declare class AwsS3StorageProvider implements StorageProvider {
974
974
  readonly name = "aws";
975
975
  prepareUpload({ fileName, blob, upload }: UploadContext): PreparedUpload;
976
976
  }
977
+ export declare class BackendStorageProvider implements StorageProvider {
978
+ readonly name = "backend";
979
+ prepareUpload({ fileName, blob, upload }: UploadContext): PreparedUpload;
980
+ }
981
+ export declare const AWS_STORAGE_PROVIDER = "aws";
982
+ export declare const BACKEND_STORAGE_PROVIDER = "backend";
983
+ export declare function hasUploadPayload(upload: unknown): upload is SessionUploadInfo;
984
+ export declare function resolveStorageProvider(sessionProvider: string | null | undefined, upload: SessionUploadInfo | undefined): string;
977
985
  export declare function isStorageProviderSupported(name: string): boolean;
978
986
  /** @throws UnsupportedStorageProviderError if no wrapper is registered. */
979
987
  export declare function getStorageProvider(name: string): StorageProvider;
@@ -1245,9 +1253,7 @@ export declare class RecordingManager {
1245
1253
  * Create the appropriate recorder based on upload type.
1246
1254
  */
1247
1255
  private createRecorder;
1248
- /** Storage provider name from discovery; defaults to 'aws'. */
1249
1256
  private getStorageProviderName;
1250
- /** Validate the provider has a wrapper (throws UnsupportedStorageProviderError) and return its name. */
1251
1257
  private resolveStorageProviderName;
1252
1258
  /**
1253
1259
  * Build upload headers from the current auth state.