@nabla/connect-protocol 0.0.0-stage → 0.2.0
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 +5 -0
- package/dist/commandResult.d.ts +27 -0
- package/dist/commands.d.ts +55 -0
- package/dist/events.d.ts +35 -0
- package/dist/export.d.ts +40 -0
- package/dist/index.d.ts +7 -0
- package/dist/lifecycle.d.ts +28 -0
- package/dist/session.d.ts +57 -0
- package/dist/version.d.ts +20 -0
- package/package.json +24 -4
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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" | "EXPORT_FAILED" | "INVALID_MESSAGE"
|
|
10
|
+
/** An unexpected failure while running the command. */
|
|
11
|
+
| "UNKNOWN";
|
|
12
|
+
/**
|
|
13
|
+
* `requestId` is `null` when the rejected message carried no usable one.
|
|
14
|
+
* Consumers must tolerate additional fields.
|
|
15
|
+
*/
|
|
16
|
+
export type NablaConnectCommandResult = {
|
|
17
|
+
/** The version pinned by the session handshake. */
|
|
18
|
+
version: NablaConnectProtocolVersion;
|
|
19
|
+
sessionId: string;
|
|
20
|
+
requestId: string | null;
|
|
21
|
+
status: NablaConnectCommandResultStatus;
|
|
22
|
+
reason: NablaConnectCommandRejectionReason | null;
|
|
23
|
+
};
|
|
24
|
+
export type NablaConnectCommandResultMessage = {
|
|
25
|
+
event: NablaConnectCommandResultEvent;
|
|
26
|
+
data: NablaConnectCommandResult;
|
|
27
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { NablaConnectCommandExportNoteEvent, NablaConnectCommandStartNoteGenerationEvent, NablaConnectCommandStartRecordingEvent, NablaConnectCommandStopRecordingEvent } from "./events.js";
|
|
2
|
+
import type { NablaConnectSessionHelloMessage } from "./session.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
|
+
/** The version pinned by the session handshake. */
|
|
11
|
+
version: NablaConnectProtocolVersion;
|
|
12
|
+
sessionId: string;
|
|
13
|
+
requestId: string;
|
|
14
|
+
expectedRevision: number;
|
|
15
|
+
};
|
|
16
|
+
export type NablaConnectCommandStartRecordingMessage = {
|
|
17
|
+
event: NablaConnectCommandStartRecordingEvent;
|
|
18
|
+
data: NablaConnectCommandBase;
|
|
19
|
+
};
|
|
20
|
+
export type NablaConnectCommandStopRecordingMessage = {
|
|
21
|
+
event: NablaConnectCommandStopRecordingEvent;
|
|
22
|
+
data: NablaConnectCommandBase;
|
|
23
|
+
};
|
|
24
|
+
export type NablaConnectCommandStartNoteGenerationMessage = {
|
|
25
|
+
event: NablaConnectCommandStartNoteGenerationEvent;
|
|
26
|
+
data: NablaConnectCommandBase;
|
|
27
|
+
};
|
|
28
|
+
export type NablaConnectCommandExportNoteMessage = {
|
|
29
|
+
event: NablaConnectCommandExportNoteEvent;
|
|
30
|
+
data: NablaConnectCommandBase;
|
|
31
|
+
};
|
|
32
|
+
/** The iframe ignores unknown fields on commands. */
|
|
33
|
+
export type NablaConnectInboundCommandMessage = NablaConnectCommandStartRecordingMessage | NablaConnectCommandStopRecordingMessage | NablaConnectCommandStartNoteGenerationMessage | NablaConnectCommandExportNoteMessage;
|
|
34
|
+
/** Everything the iframe receives: the handshake, then commands. */
|
|
35
|
+
export type NablaConnectInboundLifecycleMessage = NablaConnectSessionHelloMessage | NablaConnectInboundCommandMessage;
|
|
36
|
+
export type NablaConnectLifecycleCommandKind = "startRecording" | "stopRecording" | "startNoteGeneration" | "exportNote";
|
|
37
|
+
/** Each command with the event that carries it and the snapshot action it requires. */
|
|
38
|
+
export type NablaConnectLifecycleCommands = {
|
|
39
|
+
startRecording: {
|
|
40
|
+
event: NablaConnectCommandStartRecordingEvent;
|
|
41
|
+
action: "START_RECORDING";
|
|
42
|
+
};
|
|
43
|
+
stopRecording: {
|
|
44
|
+
event: NablaConnectCommandStopRecordingEvent;
|
|
45
|
+
action: "STOP_RECORDING";
|
|
46
|
+
};
|
|
47
|
+
startNoteGeneration: {
|
|
48
|
+
event: NablaConnectCommandStartNoteGenerationEvent;
|
|
49
|
+
action: "GENERATE_NOTE";
|
|
50
|
+
};
|
|
51
|
+
exportNote: {
|
|
52
|
+
event: NablaConnectCommandExportNoteEvent;
|
|
53
|
+
action: "EXPORT_NOTE";
|
|
54
|
+
};
|
|
55
|
+
};
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type NablaConnectLifecycleStateChangedEvent = "com.connect.nabla:lifecycle:stateChanged";
|
|
2
|
+
export type NablaConnectSessionAvailableEvent = "com.connect.nabla:session:available";
|
|
3
|
+
export type NablaConnectSessionHelloEvent = "com.connect.nabla:session:hello";
|
|
4
|
+
export type NablaConnectSessionReadyEvent = "com.connect.nabla:session:ready";
|
|
5
|
+
export type NablaConnectSessionRejectedEvent = "com.connect.nabla:session:rejected";
|
|
6
|
+
export type NablaConnectCommandStartRecordingEvent = "com.connect.nabla:command:startRecording";
|
|
7
|
+
export type NablaConnectCommandStopRecordingEvent = "com.connect.nabla:command:stopRecording";
|
|
8
|
+
export type NablaConnectCommandStartNoteGenerationEvent = "com.connect.nabla:command:startNoteGeneration";
|
|
9
|
+
export type NablaConnectCommandExportNoteEvent = "com.connect.nabla:command:exportNote";
|
|
10
|
+
export type NablaConnectCommandResultEvent = "com.connect.nabla:command:result";
|
|
11
|
+
export type NablaConnectExportNoteEvent = "com.connect.nabla:export:note";
|
|
12
|
+
export type NablaConnectExportPatientInstructionsEvent = "com.connect.nabla:export:patientInstructions";
|
|
13
|
+
/** Events the host page sends to the iframe. */
|
|
14
|
+
export type NablaConnectInboundEvent = NablaConnectSessionHelloEvent | NablaConnectCommandStartRecordingEvent | NablaConnectCommandStopRecordingEvent | NablaConnectCommandStartNoteGenerationEvent | NablaConnectCommandExportNoteEvent;
|
|
15
|
+
/** Events the iframe sends to the host page. */
|
|
16
|
+
export type NablaConnectOutboundEvent = NablaConnectSessionAvailableEvent | NablaConnectSessionReadyEvent | NablaConnectSessionRejectedEvent | NablaConnectLifecycleStateChangedEvent | NablaConnectCommandResultEvent | NablaConnectExportNoteEvent | NablaConnectExportPatientInstructionsEvent;
|
|
17
|
+
/**
|
|
18
|
+
* Every event name, by key. Types have no runtime value, so each consumer redeclares the
|
|
19
|
+
* names it uses and pins the declaration to this type:
|
|
20
|
+
* `const EVENTS = { ... } as const satisfies NablaConnectEventNames`.
|
|
21
|
+
*/
|
|
22
|
+
export type NablaConnectEventNames = {
|
|
23
|
+
lifecycleStateChanged: NablaConnectLifecycleStateChangedEvent;
|
|
24
|
+
sessionAvailable: NablaConnectSessionAvailableEvent;
|
|
25
|
+
sessionHello: NablaConnectSessionHelloEvent;
|
|
26
|
+
sessionReady: NablaConnectSessionReadyEvent;
|
|
27
|
+
sessionRejected: NablaConnectSessionRejectedEvent;
|
|
28
|
+
commandStartRecording: NablaConnectCommandStartRecordingEvent;
|
|
29
|
+
commandStopRecording: NablaConnectCommandStopRecordingEvent;
|
|
30
|
+
commandStartNoteGeneration: NablaConnectCommandStartNoteGenerationEvent;
|
|
31
|
+
commandExportNote: NablaConnectCommandExportNoteEvent;
|
|
32
|
+
commandResult: NablaConnectCommandResultEvent;
|
|
33
|
+
exportNote: NablaConnectExportNoteEvent;
|
|
34
|
+
exportPatientInstructions: NablaConnectExportPatientInstructionsEvent;
|
|
35
|
+
};
|
package/dist/export.d.ts
ADDED
|
@@ -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;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
/** The version pinned by the session handshake. */
|
|
14
|
+
version: NablaConnectProtocolVersion;
|
|
15
|
+
sessionId: string;
|
|
16
|
+
revision: number;
|
|
17
|
+
state: NablaConnectLifecycleState;
|
|
18
|
+
availableActions: NablaConnectLifecycleAction[];
|
|
19
|
+
canBeClosed: boolean;
|
|
20
|
+
reason: NablaConnectLifecycleSnapshotReason | null;
|
|
21
|
+
failureReason: NablaConnectNoteGenerationFailureReason | null;
|
|
22
|
+
};
|
|
23
|
+
export type NablaConnectLifecycleStateChangedMessage = {
|
|
24
|
+
event: NablaConnectLifecycleStateChangedEvent;
|
|
25
|
+
data: {
|
|
26
|
+
snapshot: NablaConnectLifecycleSnapshot;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { NablaConnectSessionAvailableEvent, NablaConnectSessionHelloEvent, NablaConnectSessionReadyEvent, NablaConnectSessionRejectedEvent } from "./events.js";
|
|
2
|
+
import type { NablaConnectProtocolVersion } from "./version.js";
|
|
3
|
+
/**
|
|
4
|
+
* The iframe is listening. Sent once per session, before anything else. A new one on the
|
|
5
|
+
* same iframe element means the previous session is gone: the document reloaded, or the
|
|
6
|
+
* iframe opened another encounter.
|
|
7
|
+
*
|
|
8
|
+
* Setup messages are not versioned and only ever gain fields. `supportedVersions` is
|
|
9
|
+
* bounded by `NablaConnectSupportedVersionsMaxLength`.
|
|
10
|
+
*/
|
|
11
|
+
export type NablaConnectSessionAvailableMessage = {
|
|
12
|
+
event: NablaConnectSessionAvailableEvent;
|
|
13
|
+
data: {
|
|
14
|
+
supportedVersions: number[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The host SDK offers the versions it speaks. Sent when the SDK is created and again on
|
|
19
|
+
* every `session:available`. Until the iframe answers with `session:ready`, it ignores
|
|
20
|
+
* every other inbound message.
|
|
21
|
+
*
|
|
22
|
+
* `sdkVersion` is the semver of the SDK, bounded by `NablaConnectSdkVersionMaxLength`.
|
|
23
|
+
* The iframe logs it. It is not clinical data.
|
|
24
|
+
*/
|
|
25
|
+
export type NablaConnectSessionHelloMessage = {
|
|
26
|
+
event: NablaConnectSessionHelloEvent;
|
|
27
|
+
data: {
|
|
28
|
+
supportedVersions: number[];
|
|
29
|
+
sdkVersion: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The iframe pinned the highest version both sides support. Every later message of the
|
|
34
|
+
* session carries and is validated against it, and the first `stateChanged` follows.
|
|
35
|
+
* A repeated `session:hello` in the same session gets the same message back.
|
|
36
|
+
*/
|
|
37
|
+
export type NablaConnectSessionReadyMessage = {
|
|
38
|
+
event: NablaConnectSessionReadyEvent;
|
|
39
|
+
data: {
|
|
40
|
+
version: NablaConnectProtocolVersion;
|
|
41
|
+
sessionId: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export type NablaConnectSessionRejectionReason = "UNSUPPORTED_VERSION";
|
|
45
|
+
/**
|
|
46
|
+
* The two sides share no version, or the session already pinned one the host does not
|
|
47
|
+
* offer. The host gets no session. `supportedVersions` is what the iframe speaks. If they
|
|
48
|
+
* are all newer than the SDK's, the SDK is too old and the integrator upgrades
|
|
49
|
+
* `@nabla/connect-sdk`. If they are all older, the iframe is behind the SDK.
|
|
50
|
+
*/
|
|
51
|
+
export type NablaConnectSessionRejectedMessage = {
|
|
52
|
+
event: NablaConnectSessionRejectedEvent;
|
|
53
|
+
data: {
|
|
54
|
+
reason: NablaConnectSessionRejectionReason;
|
|
55
|
+
supportedVersions: number[];
|
|
56
|
+
};
|
|
57
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A protocol version the session can pin. Bumped on breaking changes only.
|
|
3
|
+
*
|
|
4
|
+
* The `session:*` setup messages are not versioned and only ever gain fields. They
|
|
5
|
+
* negotiate the version that every other message of the session carries:
|
|
6
|
+
* `session:ready` reports the one it pinned.
|
|
7
|
+
*/
|
|
8
|
+
export type NablaConnectProtocolVersion = 1;
|
|
9
|
+
/**
|
|
10
|
+
* Ids (`sessionId`, `requestId`) are non-empty strings of at most this many characters.
|
|
11
|
+
* Types cannot express the bound: consumers must enforce it.
|
|
12
|
+
*/
|
|
13
|
+
export type NablaConnectBoundedIdMaxLength = 64;
|
|
14
|
+
/**
|
|
15
|
+
* `supportedVersions` holds at most this many positive integers. It may list versions the
|
|
16
|
+
* receiver does not know: it ignores them.
|
|
17
|
+
*/
|
|
18
|
+
export type NablaConnectSupportedVersionsMaxLength = 16;
|
|
19
|
+
/** `sdkVersion` is a non-empty string of at most this many characters. */
|
|
20
|
+
export type NablaConnectSdkVersionMaxLength = 64;
|
package/package.json
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nabla/connect-protocol",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
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