med-scribe-alliance-ts-sdk 2.0.24 → 2.0.26
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 +159 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.mjs +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -390,6 +390,165 @@ Register with `client.registerCallback(name, handler)`, remove with `client.remo
|
|
|
390
390
|
| `onError` | `ErrorEvent` | VAD, worker, transport, or validation errors. |
|
|
391
391
|
| `onTokenRequired` | `TokenRequiredEvent` | 401 received — call `event.resolve(newToken)` to retry. |
|
|
392
392
|
|
|
393
|
+
#### Payload Shapes
|
|
394
|
+
|
|
395
|
+
```ts
|
|
396
|
+
// onRecordingStateChange
|
|
397
|
+
interface RecordingStateChangeEvent {
|
|
398
|
+
type: 'started' | 'paused' | 'resumed' | 'ended';
|
|
399
|
+
timestamp: string;
|
|
400
|
+
data?: any;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// onAudioEvent — discriminated union by `type`
|
|
404
|
+
type AudioEvent =
|
|
405
|
+
| { type: 'user_speech'; timestamp: string; data: { isSpeaking: boolean } }
|
|
406
|
+
| { type: 'silence_warning'; timestamp: string; data: { durationMs: number } }
|
|
407
|
+
| { type: 'chunk_ready'; timestamp: string; data: { chunkIndex: number; fileName: string; chunkData: Uint8Array[] } }
|
|
408
|
+
| { type: 'frame_processed'; timestamp: string; data: { isSpeech: number; notSpeech: number; frame: Float32Array; duration: number } };
|
|
409
|
+
|
|
410
|
+
// onUploadEvent
|
|
411
|
+
type UploadEvent =
|
|
412
|
+
| { type: 'progress'; timestamp: string; data: { successCount: number; totalCount: number } }
|
|
413
|
+
| { type: 'failed'; timestamp: string; data: { fileName: string; error: string } }
|
|
414
|
+
| { type: 'retry'; timestamp: string; data: { fileName: string; attempt: number } };
|
|
415
|
+
|
|
416
|
+
// onSessionEvent
|
|
417
|
+
type SessionEvent =
|
|
418
|
+
| { type: 'created'; timestamp: string; data: CreateSessionResponse }
|
|
419
|
+
| { type: 'ended'; timestamp: string; data: EndSessionResponse }
|
|
420
|
+
| { type: 'discarded'; timestamp: string; data: { sessionId: string | null; reason: 'cleared' | 'cancelled' | 'reset' } }
|
|
421
|
+
| { type: 'status_update'; timestamp: string; data: GetSessionStatusResponse }
|
|
422
|
+
| { type: 'partial_result'; timestamp: string; data: any };
|
|
423
|
+
|
|
424
|
+
// onError
|
|
425
|
+
interface ErrorEvent {
|
|
426
|
+
type: 'vad_error' | 'worker_error' | 'transport_error' | 'validation_error';
|
|
427
|
+
timestamp: string;
|
|
428
|
+
error: { code: string; message: string; details?: any };
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// onTokenRequired — call event.resolve(newToken) to retry the failed request
|
|
432
|
+
interface TokenRequiredEvent {
|
|
433
|
+
resolve: (newToken: string) => void;
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
## Request / Response Types
|
|
438
|
+
|
|
439
|
+
#### Session
|
|
440
|
+
|
|
441
|
+
```ts
|
|
442
|
+
interface CreateSessionRequest {
|
|
443
|
+
templates: string[];
|
|
444
|
+
upload_type: string; // 'chunked' | 'single' | 'stream'
|
|
445
|
+
communication_protocol: string; // 'http' | 'websocket'
|
|
446
|
+
model?: string;
|
|
447
|
+
language_hint?: string[];
|
|
448
|
+
transcript_language?: string;
|
|
449
|
+
additional_data?: Record<string, any>;
|
|
450
|
+
session_mode?: string; // 'consultation' | 'dictation'
|
|
451
|
+
patient_details?: PatientDetails;
|
|
452
|
+
session_id?: string; // optional client-supplied ID
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
interface CreateSessionResponse {
|
|
456
|
+
session_id: string;
|
|
457
|
+
status: SessionStatus;
|
|
458
|
+
created_at: string;
|
|
459
|
+
expires_at: string;
|
|
460
|
+
upload_url: string;
|
|
461
|
+
patient_details?: PatientDetails;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
interface PatchSessionRequest {
|
|
465
|
+
user_status?: string;
|
|
466
|
+
processing_status?: string;
|
|
467
|
+
patient_details?: PatientDetails;
|
|
468
|
+
additional_data?: Record<string, any>;
|
|
469
|
+
language_hint?: string[];
|
|
470
|
+
transcript_language?: string;
|
|
471
|
+
templates?: string[];
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
interface PatchSessionResponse {
|
|
475
|
+
session_id: string;
|
|
476
|
+
status: string;
|
|
477
|
+
message: string;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
interface EndSessionResponse {
|
|
481
|
+
session_id: string;
|
|
482
|
+
status: SessionStatus;
|
|
483
|
+
message: string;
|
|
484
|
+
audio_files_received: number;
|
|
485
|
+
audio_files: string[];
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
interface GetSessionStatusResponse {
|
|
489
|
+
session_id: string;
|
|
490
|
+
status: SessionStatus;
|
|
491
|
+
created_at: string;
|
|
492
|
+
expires_at?: string | null;
|
|
493
|
+
expired_at?: string | null;
|
|
494
|
+
completed_at?: string | null;
|
|
495
|
+
model_used?: string | null;
|
|
496
|
+
language_detected?: string | null;
|
|
497
|
+
audio_files_received: number;
|
|
498
|
+
audio_files: string[];
|
|
499
|
+
audio_files_processed?: number;
|
|
500
|
+
additional_data: Record<string, any>;
|
|
501
|
+
templates?: TemplateEntry[]; // { [templateId]: { status, data, fhir, error, ... } }
|
|
502
|
+
transcript?: string;
|
|
503
|
+
processing_errors?: ProcessingError[];
|
|
504
|
+
error?: { code: string; message: string; details?: Record<string, any> };
|
|
505
|
+
patient_details?: PatientDetails;
|
|
506
|
+
message?: string;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
interface ProcessTemplateResponse {
|
|
510
|
+
session_id: string;
|
|
511
|
+
template_id: string;
|
|
512
|
+
status: string;
|
|
513
|
+
message: string;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
interface PatientDetails {
|
|
517
|
+
oid?: string;
|
|
518
|
+
name?: string;
|
|
519
|
+
age?: string;
|
|
520
|
+
gender?: string;
|
|
521
|
+
mobile?: number;
|
|
522
|
+
}
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
#### Recording
|
|
526
|
+
|
|
527
|
+
```ts
|
|
528
|
+
interface StopRecordingResult {
|
|
529
|
+
failedUploads: string[];
|
|
530
|
+
totalFiles: number;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
interface EndRecordingResult extends StopRecordingResult {
|
|
534
|
+
sessionEnded: boolean;
|
|
535
|
+
endSessionResponse?: EndSessionResponse;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
interface RetryUploadResult {
|
|
539
|
+
retried: number;
|
|
540
|
+
succeeded: number;
|
|
541
|
+
stillFailed: string[];
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
interface PollOptions {
|
|
545
|
+
maxAttempts?: number;
|
|
546
|
+
intervalMs?: number;
|
|
547
|
+
onProgress?: (status: GetSessionStatusResponse) => void;
|
|
548
|
+
signal?: AbortSignal;
|
|
549
|
+
}
|
|
550
|
+
```
|
|
551
|
+
|
|
393
552
|
## Error Handling
|
|
394
553
|
|
|
395
554
|
All public async methods return `SDKResult<T>` — errors are returned, not thrown:
|
package/dist/index.d.ts
CHANGED
|
@@ -544,7 +544,7 @@ export interface UploadEventRetry {
|
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
546
|
export type UploadEvent = UploadEventProgress | UploadEventFailed | UploadEventRetry;
|
|
547
|
-
export type SessionEventType = "created" | "ended" | "status_update" | "partial_result";
|
|
547
|
+
export type SessionEventType = "created" | "ended" | "discarded" | "status_update" | "partial_result";
|
|
548
548
|
export interface SessionEventCreated {
|
|
549
549
|
type: "created";
|
|
550
550
|
timestamp: string;
|
|
@@ -555,6 +555,14 @@ export interface SessionEventEnded {
|
|
|
555
555
|
timestamp: string;
|
|
556
556
|
data: EndSessionResponse;
|
|
557
557
|
}
|
|
558
|
+
export interface SessionEventDiscarded {
|
|
559
|
+
type: "discarded";
|
|
560
|
+
timestamp: string;
|
|
561
|
+
data: {
|
|
562
|
+
sessionId: string | null;
|
|
563
|
+
reason: "cleared" | "cancelled" | "reset";
|
|
564
|
+
};
|
|
565
|
+
}
|
|
558
566
|
export interface SessionEventStatusUpdate {
|
|
559
567
|
type: "status_update";
|
|
560
568
|
timestamp: string;
|
|
@@ -565,7 +573,7 @@ export interface SessionEventPartialResult {
|
|
|
565
573
|
timestamp: string;
|
|
566
574
|
data: any;
|
|
567
575
|
}
|
|
568
|
-
export type SessionEvent = SessionEventCreated | SessionEventEnded | SessionEventStatusUpdate | SessionEventPartialResult;
|
|
576
|
+
export type SessionEvent = SessionEventCreated | SessionEventEnded | SessionEventDiscarded | SessionEventStatusUpdate | SessionEventPartialResult;
|
|
569
577
|
export type ErrorEventType = "vad_error" | "worker_error" | "transport_error" | "validation_error";
|
|
570
578
|
interface ErrorEvent$1 {
|
|
571
579
|
type: ErrorEventType;
|
package/dist/index.mjs
CHANGED
|
@@ -1981,7 +1981,14 @@ var ie = class {
|
|
|
1981
1981
|
}
|
|
1982
1982
|
async cancelSession(e) {
|
|
1983
1983
|
let t = e ?? this.recordingManager.getActiveSession()?.session_id ?? this.sessionManager.getCurrentSession()?.session_id;
|
|
1984
|
-
return this.recordingManager.isRecording() && this.recordingManager.forceStop(), this.recordingManager.reset(), this.sessionManager.clearCurrentSession(), this.
|
|
1984
|
+
return this.recordingManager.isRecording() && this.recordingManager.forceStop(), this.recordingManager.reset(), this.sessionManager.clearCurrentSession(), this.callbackRegistry.dispatch("onSessionEvent", {
|
|
1985
|
+
type: "discarded",
|
|
1986
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1987
|
+
data: {
|
|
1988
|
+
sessionId: t ?? null,
|
|
1989
|
+
reason: "cancelled"
|
|
1990
|
+
}
|
|
1991
|
+
}), this.updateSession({
|
|
1985
1992
|
user_status: "cancelled",
|
|
1986
1993
|
processing_status: "cancelled"
|
|
1987
1994
|
}, t);
|