@omniloy/sofia-sdk 1.0.9 → 1.0.11

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.
@@ -1,5 +1,8 @@
1
1
  import * as React_2 from 'react';
2
2
 
3
+ /** Where audio stopped flowing, as reported by the recording pipeline. */
4
+ declare type AudioLossCause = 'mic' | 'network' | 'server';
5
+
3
6
  declare interface CuratedReport {
4
7
  [key: string]: unknown;
5
8
  }
@@ -42,6 +45,11 @@ declare interface InsertionPreviewClassNames {
42
45
  cancelButton?: string;
43
46
  }
44
47
 
48
+ /** Coarse area of the widget the clinician touched. */
49
+ declare type InteractionKind = 'recording' | 'chat' | 'settings' | 'report' | 'transcript' | 'history' | 'widget';
50
+
51
+ declare type KnownSdkEventName = 'recording.started' | 'recording.stopped' | 'recording.audio_lost' | 'recording.microphone_disconnected' | 'recording.heartbeat' | 'activity.interaction' | 'activity.typing' | 'report.generation_started' | 'report.settled' | 'lifecycle.ready' | 'lifecycle.closed';
52
+
45
53
  declare enum LanguageCode {
46
54
  ar = "ar",
47
55
  ca = "ca",
@@ -218,8 +226,152 @@ export declare interface OmniscribeProps {
218
226
  * the appropriate action. To change the delivered shape, change templateExtras.
219
227
  */
220
228
  handleExtras?: (extras: Extra[]) => void;
229
+ /**
230
+ * Subscribe to the SDK's activity stream.
231
+ *
232
+ * Called with a typed, PHI-free event whenever something the host asked
233
+ * for happens inside the widget. Payloads carry only enums, booleans and
234
+ * numbers — never clinical content, message text or patient identifiers.
235
+ * Clinical content has its own explicitly scoped channels (`handleReport`,
236
+ * `onReportApply`, `handleExtras`).
237
+ *
238
+ * The primary use case is knowing whether the clinician is working, so the
239
+ * host can run an inactivity timeout:
240
+ * ```
241
+ * onEvent={e => {
242
+ * if (e.name === 'recording.started') idleTimer.cancel();
243
+ * if (e.name === 'recording.stopped') idleTimer.start();
244
+ * if (e.family === 'activity') idleTimer.reset();
245
+ * }}
246
+ * ```
247
+ * Suppress the timer between `report.generation_started` and
248
+ * `report.settled` — generation runs for tens of seconds with no user
249
+ * input, and closing the widget there loses the note.
250
+ *
251
+ * If the host must keep an *external* session alive (an auto-logout on
252
+ * inactivity), key off `recording.heartbeat` instead of the
253
+ * `started`/`stopped` pair. It beats every ~30s while audio is actually
254
+ * flowing to the transcriber, needs no host-side state, and stops by
255
+ * itself the moment a recording silently breaks:
256
+ * ```
257
+ * onEvent={e => {
258
+ * if (e.name === 'recording.heartbeat') session.keepAlive();
259
+ * }}
260
+ * ```
261
+ *
262
+ * Delivered asynchronously on a microtask, so a slow handler cannot block
263
+ * recording. Requires `eventSubscriptions`; without it nothing is sent.
264
+ */
265
+ onEvent?: SdkEventHandler;
266
+ /**
267
+ * Which events `onEvent` should receive. Exact names
268
+ * (`'recording.started'`), family wildcards (`'recording.*'`), or `'*'`.
269
+ *
270
+ * Omitted or empty means no events are delivered — subscription is
271
+ * explicit so the SDK never does work for a listener that does not exist.
272
+ */
273
+ eventSubscriptions?: SdkEventSubscription[];
221
274
  }
222
275
 
276
+ declare type RecordingMode = 'consultation' | 'dictation';
277
+
278
+ declare interface SdkEvent<N extends SdkEventName = SdkEventName> {
279
+ /** Fully qualified name, e.g. `'recording.started'`. */
280
+ name: N;
281
+ /** The part of `name` before the dot. */
282
+ family: SdkEventFamily;
283
+ level: 'info' | 'warn' | 'error';
284
+ /** ISO-8601. */
285
+ ts: string;
286
+ /**
287
+ * Monotonic per page load. Restores ordering that the fire-and-forget
288
+ * analytics POSTs cannot guarantee.
289
+ */
290
+ seq: number;
291
+ sdkVersion: string;
292
+ /** Random per-session UUID. Not an identifier for a person. */
293
+ sessionId: string | null;
294
+ payload: SdkEventPayload<N>;
295
+ }
296
+
297
+ /**
298
+ * Public, host-facing SDK event vocabulary.
299
+ *
300
+ * PRIVACY INVARIANT — read before adding an event.
301
+ * No payload field may carry user-, patient-, or clinician-derived text.
302
+ * Every field is a string-literal union, a boolean, or a number. Errors
303
+ * travel as codes, never as messages; reports as counts, never as content.
304
+ * A host that needs clinical content already has purpose-built, explicitly
305
+ * scoped channels for it (`handleReport`, `onReportApply`, `handleExtras`).
306
+ * `sdk-events.types.test.ts` fails the build if an unconstrained `string`
307
+ * appears in `SdkEventPayloadMap`.
308
+ *
309
+ * This vocabulary is deliberately separate from the internal analytics
310
+ * `AppEventName`. Merging them would make every internal telemetry addition
311
+ * a public breaking change.
312
+ */
313
+ declare type SdkEventFamily = 'recording' | 'activity' | 'report' | 'lifecycle';
314
+
315
+ /** Handler shape for the `onEvent` prop. */
316
+ declare type SdkEventHandler = (event: SdkEvent) => void;
317
+
318
+ /**
319
+ * Widened on purpose. New event names ship in minor releases, and a closed
320
+ * union would make every addition a type-level break for hosts that switch
321
+ * exhaustively. Hosts wanting exhaustiveness narrow to `KnownSdkEventName`.
322
+ */
323
+ declare type SdkEventName = KnownSdkEventName | (string & {});
324
+
325
+ declare type SdkEventPayload<N extends SdkEventName> = N extends KnownSdkEventName ? SdkEventPayloadMap[N] : Record<string, unknown>;
326
+
327
+ declare interface SdkEventPayloadMap {
328
+ 'recording.started': {
329
+ mode: RecordingMode;
330
+ };
331
+ 'recording.stopped': {
332
+ mode: RecordingMode;
333
+ durationSeconds: number;
334
+ };
335
+ 'recording.audio_lost': {
336
+ cause: AudioLossCause;
337
+ /**
338
+ * For `mic` / `network`: length of the gap, reported once audio
339
+ * recovers. For `server`: the recording position at which the socket
340
+ * closed — capture is torn down on the spot, so there is no gap to
341
+ * measure.
342
+ */
343
+ durationSeconds: number;
344
+ };
345
+ 'recording.microphone_disconnected': Record<string, never>;
346
+ /**
347
+ * Audio is actually flowing to the transcriber. Emitted from the
348
+ * audio-chunk send path, throttled — see `recording-heartbeat.ts`.
349
+ * A host that must keep an external session alive while the clinician
350
+ * records should key off this, not off `started`/`stopped`: it needs no
351
+ * host-side state and stops by itself the moment a recording silently
352
+ * breaks.
353
+ */
354
+ 'recording.heartbeat': Record<string, never>;
355
+ 'activity.interaction': {
356
+ kind: InteractionKind;
357
+ };
358
+ 'activity.typing': {
359
+ surface: TypingSurface;
360
+ };
361
+ 'report.generation_started': Record<string, never>;
362
+ 'report.settled': {
363
+ ok: boolean;
364
+ };
365
+ 'lifecycle.ready': Record<string, never>;
366
+ 'lifecycle.closed': Record<string, never>;
367
+ }
368
+
369
+ /**
370
+ * What a host asks for: an exact name, a family wildcard (`'recording.*'`),
371
+ * or everything (`'*'`).
372
+ */
373
+ declare type SdkEventSubscription = KnownSdkEventName | `${SdkEventFamily}.*` | '*';
374
+
223
375
  export declare const SofiaSDK: CustomElementConstructor;
224
376
 
225
377
  declare enum ToastVariation {
@@ -242,6 +394,9 @@ declare type TTranscriptorSelect = {
242
394
  label: string;
243
395
  }[];
244
396
 
397
+ /** Which free-text surface received keystrokes. Never the text itself. */
398
+ declare type TypingSurface = 'chat' | 'note';
399
+
245
400
  /**
246
401
  * Host-provided callback that returns whatever the doctor has already written
247
402
  * in SINA/HIS, keyed by template property id (e.g. `{ chief_complaint: '...',