@nabla/connect-protocol 0.0.0-stage → 0.1.0-test1

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/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ Copyright (c) Nabla. All rights reserved.
2
+
3
+ This software is proprietary and confidential. No license is granted to use,
4
+ copy, modify, or distribute it, except to customers who received it from Nabla
5
+ under a written agreement.
@@ -0,0 +1,24 @@
1
+ import type { NablaConnectCommandResultEvent } from "./events.js";
2
+ import type { NablaConnectProtocolVersion } from "./version.js";
3
+ /**
4
+ * Each command gets exactly one result. `ACCEPTED` means the iframe ran the
5
+ * action. Its progress is reported by later state changes, not by another
6
+ * result.
7
+ */
8
+ export type NablaConnectCommandResultStatus = "ACCEPTED" | "REJECTED";
9
+ export type NablaConnectCommandRejectionReason = "STALE_STATE" | "NOT_ALLOWED" | "BUSY" | "INVALID_SESSION" | "MICROPHONE_CUT_CONFIRMATION_REQUIRED" | "EXPORT_FAILED" | "INVALID_MESSAGE" | "UNSUPPORTED_VERSION";
10
+ /**
11
+ * `requestId` is `null` when the rejected message carried no usable one.
12
+ * Consumers must tolerate additional fields.
13
+ */
14
+ export type NablaConnectCommandResult = {
15
+ version: NablaConnectProtocolVersion;
16
+ sessionId: string;
17
+ requestId: string | null;
18
+ status: NablaConnectCommandResultStatus;
19
+ reason: NablaConnectCommandRejectionReason | null;
20
+ };
21
+ export type NablaConnectCommandResultMessage = {
22
+ event: NablaConnectCommandResultEvent;
23
+ data: NablaConnectCommandResult;
24
+ };
@@ -0,0 +1,58 @@
1
+ import type { NablaConnectCommandExportNoteEvent, NablaConnectCommandStartNoteGenerationEvent, NablaConnectCommandStartRecordingEvent, NablaConnectCommandStopRecordingEvent } from "./events.js";
2
+ import type { NablaConnectQueryLifecycleStateMessage } from "./query.js";
3
+ import type { NablaConnectProtocolVersion } from "./version.js";
4
+ /**
5
+ * `sessionId` and `requestId` are non-empty strings of at most
6
+ * `NablaConnectBoundedIdMaxLength` characters. `expectedRevision` is a positive
7
+ * integer: the revision of the snapshot the host acted on.
8
+ */
9
+ export type NablaConnectCommandBase = {
10
+ version: NablaConnectProtocolVersion;
11
+ sessionId: string;
12
+ requestId: string;
13
+ expectedRevision: number;
14
+ };
15
+ export type NablaConnectCommandStartRecordingMessage = {
16
+ event: NablaConnectCommandStartRecordingEvent;
17
+ data: NablaConnectCommandBase;
18
+ };
19
+ export type NablaConnectCommandStopRecordingMessage = {
20
+ event: NablaConnectCommandStopRecordingEvent;
21
+ data: NablaConnectCommandBase;
22
+ };
23
+ export type NablaConnectStartNoteGenerationOptions = {
24
+ microphoneCutConfirmed?: boolean;
25
+ };
26
+ export type NablaConnectCommandStartNoteGenerationMessage = {
27
+ event: NablaConnectCommandStartNoteGenerationEvent;
28
+ data: NablaConnectCommandBase & {
29
+ startNoteGeneration?: NablaConnectStartNoteGenerationOptions;
30
+ };
31
+ };
32
+ export type NablaConnectCommandExportNoteMessage = {
33
+ event: NablaConnectCommandExportNoteEvent;
34
+ data: NablaConnectCommandBase;
35
+ };
36
+ /** The iframe ignores unknown fields on commands. */
37
+ export type NablaConnectInboundCommandMessage = NablaConnectCommandStartRecordingMessage | NablaConnectCommandStopRecordingMessage | NablaConnectCommandStartNoteGenerationMessage | NablaConnectCommandExportNoteMessage;
38
+ export type NablaConnectInboundLifecycleMessage = NablaConnectQueryLifecycleStateMessage | NablaConnectInboundCommandMessage;
39
+ export type NablaConnectLifecycleCommandKind = "startRecording" | "stopRecording" | "startNoteGeneration" | "exportNote";
40
+ /** Each command with the event that carries it and the snapshot action it requires. */
41
+ export type NablaConnectLifecycleCommands = {
42
+ startRecording: {
43
+ event: NablaConnectCommandStartRecordingEvent;
44
+ action: "START_RECORDING";
45
+ };
46
+ stopRecording: {
47
+ event: NablaConnectCommandStopRecordingEvent;
48
+ action: "STOP_RECORDING";
49
+ };
50
+ startNoteGeneration: {
51
+ event: NablaConnectCommandStartNoteGenerationEvent;
52
+ action: "GENERATE_NOTE";
53
+ };
54
+ exportNote: {
55
+ event: NablaConnectCommandExportNoteEvent;
56
+ action: "EXPORT_NOTE";
57
+ };
58
+ };
@@ -0,0 +1,29 @@
1
+ export type NablaConnectLifecycleStateChangedEvent = "com.connect.nabla:lifecycle:stateChanged";
2
+ export type NablaConnectQueryLifecycleStateEvent = "com.connect.nabla:query:lifecycleState";
3
+ export type NablaConnectCommandStartRecordingEvent = "com.connect.nabla:command:startRecording";
4
+ export type NablaConnectCommandStopRecordingEvent = "com.connect.nabla:command:stopRecording";
5
+ export type NablaConnectCommandStartNoteGenerationEvent = "com.connect.nabla:command:startNoteGeneration";
6
+ export type NablaConnectCommandExportNoteEvent = "com.connect.nabla:command:exportNote";
7
+ export type NablaConnectCommandResultEvent = "com.connect.nabla:command:result";
8
+ export type NablaConnectExportNoteEvent = "com.connect.nabla:export:note";
9
+ export type NablaConnectExportPatientInstructionsEvent = "com.connect.nabla:export:patientInstructions";
10
+ /** Events the host page sends to the iframe. */
11
+ export type NablaConnectInboundEvent = NablaConnectQueryLifecycleStateEvent | NablaConnectCommandStartRecordingEvent | NablaConnectCommandStopRecordingEvent | NablaConnectCommandStartNoteGenerationEvent | NablaConnectCommandExportNoteEvent;
12
+ /** Events the iframe sends to the host page. */
13
+ export type NablaConnectOutboundEvent = NablaConnectLifecycleStateChangedEvent | NablaConnectCommandResultEvent | NablaConnectExportNoteEvent | NablaConnectExportPatientInstructionsEvent;
14
+ /**
15
+ * Every event name, by key. Types have no runtime value, so each consumer redeclares the
16
+ * names it uses and pins the declaration to this type:
17
+ * `const EVENTS = { ... } as const satisfies NablaConnectEventNames`.
18
+ */
19
+ export type NablaConnectEventNames = {
20
+ lifecycleStateChanged: NablaConnectLifecycleStateChangedEvent;
21
+ queryLifecycleState: NablaConnectQueryLifecycleStateEvent;
22
+ commandStartRecording: NablaConnectCommandStartRecordingEvent;
23
+ commandStopRecording: NablaConnectCommandStopRecordingEvent;
24
+ commandStartNoteGeneration: NablaConnectCommandStartNoteGenerationEvent;
25
+ commandExportNote: NablaConnectCommandExportNoteEvent;
26
+ commandResult: NablaConnectCommandResultEvent;
27
+ exportNote: NablaConnectExportNoteEvent;
28
+ exportPatientInstructions: NablaConnectExportPatientInstructionsEvent;
29
+ };
@@ -0,0 +1,40 @@
1
+ import type { NablaConnectExportNoteEvent, NablaConnectExportPatientInstructionsEvent } from "./events.js";
2
+ export type NablaConnectExportableNoteSection = {
3
+ category: string | null;
4
+ content: string;
5
+ title: string;
6
+ };
7
+ export type NablaConnectExportableNote = {
8
+ sections: NablaConnectExportableNoteSection[];
9
+ freeText: string | null;
10
+ };
11
+ export type NablaConnectVisitDiagnosisSystem = "http://hl7.org/fhir/sid/icd-10-cm";
12
+ export type NablaConnectVisitDiagnosis = {
13
+ system: NablaConnectVisitDiagnosisSystem;
14
+ code: string;
15
+ display: string;
16
+ isHcc: boolean;
17
+ isMcc: boolean;
18
+ };
19
+ export type NablaConnectExportTranscriptItem = {
20
+ text: string;
21
+ speakerType: string;
22
+ locale?: string | null;
23
+ startOffsetMs: number;
24
+ endOffsetMs: number;
25
+ };
26
+ export type NablaConnectExportNoteMessage = {
27
+ event: NablaConnectExportNoteEvent;
28
+ data: {
29
+ note: NablaConnectExportableNote;
30
+ transcript?: NablaConnectExportTranscriptItem[];
31
+ visitDiagnoses?: NablaConnectVisitDiagnosis[];
32
+ };
33
+ };
34
+ export type NablaConnectExportPatientInstructionsMessage = {
35
+ event: NablaConnectExportPatientInstructionsEvent;
36
+ data: {
37
+ patientInstructions: string;
38
+ };
39
+ };
40
+ export type NablaConnectExportMessage = NablaConnectExportNoteMessage | NablaConnectExportPatientInstructionsMessage;
@@ -0,0 +1,7 @@
1
+ export type * from "./commandResult.js";
2
+ export type * from "./commands.js";
3
+ export type * from "./events.js";
4
+ export type * from "./export.js";
5
+ export type * from "./lifecycle.js";
6
+ export type * from "./query.js";
7
+ export type * from "./version.js";
@@ -0,0 +1,27 @@
1
+ import type { NablaConnectLifecycleStateChangedEvent } from "./events.js";
2
+ import type { NablaConnectProtocolVersion } from "./version.js";
3
+ export type NablaConnectLifecycleState = "NOT_STARTED" | "RECORDING_STARTING" | "RECORDING_STARTED" | "RECORDING_STOPPING" | "NOTE_GENERATING" | "NOTE_READY" | "PAUSED";
4
+ export type NablaConnectLifecycleAction = "START_RECORDING" | "STOP_RECORDING" | "GENERATE_NOTE" | "EXPORT_NOTE";
5
+ export type NablaConnectLifecycleSnapshotReason = "COMMAND" | "NOTE_GENERATION_FAILED";
6
+ export type NablaConnectNoteGenerationFailureReason = "TRANSCRIPT_TOO_SHORT" | "NO_MEDICAL_DATA" | "RATE_LIMITED" | "UNKNOWN";
7
+ /**
8
+ * Consumers must tolerate additional fields: the iframe may ship them before the
9
+ * consumer knows them. `sessionId` is a non-empty string of at most
10
+ * `NablaConnectBoundedIdMaxLength` characters, `revision` a positive integer.
11
+ */
12
+ export type NablaConnectLifecycleSnapshot = {
13
+ version: NablaConnectProtocolVersion;
14
+ sessionId: string;
15
+ revision: number;
16
+ state: NablaConnectLifecycleState;
17
+ availableActions: NablaConnectLifecycleAction[];
18
+ canBecomeInactive: boolean;
19
+ reason: NablaConnectLifecycleSnapshotReason | null;
20
+ failureReason: NablaConnectNoteGenerationFailureReason | null;
21
+ };
22
+ export type NablaConnectLifecycleStateChangedMessage = {
23
+ event: NablaConnectLifecycleStateChangedEvent;
24
+ data: {
25
+ snapshot: NablaConnectLifecycleSnapshot;
26
+ };
27
+ };
@@ -0,0 +1,9 @@
1
+ import type { NablaConnectQueryLifecycleStateEvent } from "./events.js";
2
+ import type { NablaConnectProtocolVersion } from "./version.js";
3
+ /** Asks the iframe to send its current lifecycle snapshot. */
4
+ export type NablaConnectQueryLifecycleStateMessage = {
5
+ event: NablaConnectQueryLifecycleStateEvent;
6
+ data: {
7
+ version: NablaConnectProtocolVersion;
8
+ };
9
+ };
@@ -0,0 +1,7 @@
1
+ /** Version carried by every message of this protocol. Bumped on breaking changes only. */
2
+ export type NablaConnectProtocolVersion = 1;
3
+ /**
4
+ * Ids (`sessionId`, `requestId`) are non-empty strings of at most this many characters.
5
+ * Types cannot express the bound: consumers must enforce it.
6
+ */
7
+ export type NablaConnectBoundedIdMaxLength = 64;
package/package.json CHANGED
@@ -1,6 +1,26 @@
1
1
  {
2
2
  "name": "@nabla/connect-protocol",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-test1",
4
+ "license": "UNLICENSED",
5
+ "description": "Wire-protocol types for the Nabla Connect iframe postMessage API. Types only, no runtime.",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/nabla/connect-sdk.git",
24
+ "directory": "packages/protocol"
25
+ }
26
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.