@dotbase/safe-frame-sync 1.13.2 → 1.15.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/dist/index.d.ts +129 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type MessageType = "editResource" | "createResource" | "closeBuilder" | "closeDocument" | "setBreadcrumbs" | "goToPatient" | "iframeRouteChange" | "sessionExpired" | "iframeReady" | "createDraft" | "createdDraft" | "draftSaved" | "openDocumentCapture" | "documentLoadError" | "reloadDocument" | "openDoctorsLetterExport";
|
|
1
|
+
export type MessageType = "editResource" | "createResource" | "closeBuilder" | "closeDocument" | "setBreadcrumbs" | "goToPatient" | "iframeRouteChange" | "sessionExpired" | "iframeReady" | "createDraft" | "createdDraft" | "draftSaved" | "openDocumentCapture" | "documentLoadError" | "reloadDocument" | "openDoctorsLetterExport" | "patientLoaded" | "createDraftFailed" | "lockDocument" | "documentLocked" | "unlockDocument" | "draftUpdated" | "leaveEditingRequested" | "leaveEditingDecided";
|
|
2
2
|
export type WorkflowType = "document" | "patient-report";
|
|
3
3
|
export interface BreadcrumbItemType {
|
|
4
4
|
to: string;
|
|
@@ -45,19 +45,59 @@ export interface SessionExpiredType {
|
|
|
45
45
|
export interface IframeReadyType {
|
|
46
46
|
type: "iframeReady";
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* The embedded app has a patient open and is able to answer messages about it.
|
|
50
|
+
*
|
|
51
|
+
* `iframeReady` only says the shell mounted; the handlers for patient-scoped messages live in the
|
|
52
|
+
* lazily loaded patient view and do not exist yet at that point, so a message sent in between is
|
|
53
|
+
* delivered to a window with no listener and lost. This carries the patient id because readiness is
|
|
54
|
+
* per patient: a patient switch makes the frame un-ready until the next one arrives.
|
|
55
|
+
*/
|
|
56
|
+
export interface PatientLoadedType {
|
|
57
|
+
type: "patientLoaded";
|
|
58
|
+
patientId: string;
|
|
59
|
+
}
|
|
48
60
|
export interface CreateDraftType {
|
|
49
61
|
type: "createDraft";
|
|
50
62
|
templateId: string;
|
|
51
63
|
patientId: string;
|
|
64
|
+
/**
|
|
65
|
+
* Correlates the reply with this request, so an answer to a superseded or already abandoned
|
|
66
|
+
* request is not mistaken for the answer to the current one.
|
|
67
|
+
*/
|
|
68
|
+
requestId: string;
|
|
52
69
|
}
|
|
53
70
|
export interface CreatedDraftType {
|
|
54
71
|
type: "createdDraft";
|
|
55
72
|
documentId: string;
|
|
56
73
|
patientId: string;
|
|
74
|
+
/** Echoes `CreateDraftType.requestId`. */
|
|
75
|
+
requestId: string;
|
|
76
|
+
}
|
|
77
|
+
/** Why a `createDraft` request produced no draft, at the granularity the sender can act on. */
|
|
78
|
+
export type CreateDraftFailureReason =
|
|
79
|
+
/** The template could not be resolved or could not be assembled into a draft. */
|
|
80
|
+
"template-unavailable"
|
|
81
|
+
/** The patient could not be loaded, or is no longer the one the request named. */
|
|
82
|
+
| "patient-unavailable"
|
|
83
|
+
/** The draft was built but could not be stored locally. */
|
|
84
|
+
| "save-failed";
|
|
85
|
+
export interface CreateDraftFailedType {
|
|
86
|
+
type: "createDraftFailed";
|
|
87
|
+
templateId: string;
|
|
88
|
+
patientId: string;
|
|
89
|
+
reason: CreateDraftFailureReason;
|
|
90
|
+
/** Echoes `CreateDraftType.requestId`. */
|
|
91
|
+
requestId: string;
|
|
57
92
|
}
|
|
58
93
|
export interface DraftSavedType {
|
|
59
94
|
type: "draftSaved";
|
|
60
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated Iframe to shell. Sent by dotclinic's former capture button; the
|
|
98
|
+
* assistant now opens on its own from the document mode. Kept so an older
|
|
99
|
+
* dotclinic keeps working against a newer shell. Removed in the next major.
|
|
100
|
+
*/
|
|
61
101
|
export interface OpenDocumentCaptureType {
|
|
62
102
|
type: "openDocumentCapture";
|
|
63
103
|
procedureId: string;
|
|
@@ -75,7 +115,86 @@ export interface OpenDoctorsLetterExportType {
|
|
|
75
115
|
procedureId: string;
|
|
76
116
|
documentTemplateId: string;
|
|
77
117
|
}
|
|
78
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Shell to iframe. The assistant is about to read the draft, send it to the
|
|
120
|
+
* model and write the result back, and every keystroke in between would be
|
|
121
|
+
* overwritten by that write-back. The iframe blocks input on the document,
|
|
122
|
+
* shows it as locked, and answers with `documentLocked` once no write of its
|
|
123
|
+
* own is pending any more; scrolling stays possible.
|
|
124
|
+
*
|
|
125
|
+
* Carries the document id because the lock belongs to one document: the user
|
|
126
|
+
* may have navigated on while the fill was running, and a lock must not land
|
|
127
|
+
* on the document they are looking at now.
|
|
128
|
+
*/
|
|
129
|
+
export interface LockDocumentType {
|
|
130
|
+
type: "lockDocument";
|
|
131
|
+
patientId: string;
|
|
132
|
+
documentId: string;
|
|
133
|
+
/** Correlates the `documentLocked` reply with this request. */
|
|
134
|
+
requestId: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Iframe to shell. The document is locked and the iframe's own pending writes
|
|
138
|
+
* to the draft have been flushed or dropped, so the draft in IndexedDB is the
|
|
139
|
+
* one the user sees. The shell reads it only after this arrives: reading
|
|
140
|
+
* earlier could miss the last keystroke, and the iframe's debounced write would
|
|
141
|
+
* later overwrite the filled draft. A shell that receives no reply in time
|
|
142
|
+
* treats the fill as failed rather than running it unlocked.
|
|
143
|
+
*/
|
|
144
|
+
export interface DocumentLockedType {
|
|
145
|
+
type: "documentLocked";
|
|
146
|
+
patientId: string;
|
|
147
|
+
documentId: string;
|
|
148
|
+
/** Echoes `LockDocumentType.requestId`. */
|
|
149
|
+
requestId: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Shell to iframe. Releases `lockDocument`. Sent on every exit path of a fill,
|
|
153
|
+
* success and failure alike, so a failed fill never leaves a dead document.
|
|
154
|
+
* A `draftUpdated` for the same document also releases the lock.
|
|
155
|
+
*/
|
|
156
|
+
export interface UnlockDocumentType {
|
|
157
|
+
type: "unlockDocument";
|
|
158
|
+
patientId: string;
|
|
159
|
+
documentId: string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Shell to iframe. The draft in the shared IndexedDB changed underneath the
|
|
163
|
+
* open document, so the iframe re-reads and re-renders it. Replaces reloading
|
|
164
|
+
* the whole frame. Implies `unlockDocument` for the same document.
|
|
165
|
+
*/
|
|
166
|
+
export interface DraftUpdatedType {
|
|
167
|
+
type: "draftUpdated";
|
|
168
|
+
patientId: string;
|
|
169
|
+
documentId: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Iframe to shell. The user wants to leave editing mode for the open document.
|
|
173
|
+
* The shell may hold unsubmitted assistant input for it and gets to ask first.
|
|
174
|
+
* The iframe waits for `leaveEditingDecided` with the same request id and
|
|
175
|
+
* proceeds on its own if none arrives in time, so a shell that does not know
|
|
176
|
+
* this message cannot trap the user in editing mode.
|
|
177
|
+
*/
|
|
178
|
+
export interface LeaveEditingRequestedType {
|
|
179
|
+
type: "leaveEditingRequested";
|
|
180
|
+
patientId: string;
|
|
181
|
+
documentId: string;
|
|
182
|
+
/** Correlates the decision with this request. */
|
|
183
|
+
requestId: string;
|
|
184
|
+
}
|
|
185
|
+
/** What the shell decided for a `leaveEditingRequested`. */
|
|
186
|
+
export type LeaveEditingDecision =
|
|
187
|
+
/** Continue the transition the user asked for. */
|
|
188
|
+
"proceed"
|
|
189
|
+
/** Remain in editing mode; the user chose to keep working or to submit first. */
|
|
190
|
+
| "stay";
|
|
191
|
+
export interface LeaveEditingDecidedType {
|
|
192
|
+
type: "leaveEditingDecided";
|
|
193
|
+
decision: LeaveEditingDecision;
|
|
194
|
+
/** Echoes `LeaveEditingRequestedType.requestId`. */
|
|
195
|
+
requestId: string;
|
|
196
|
+
}
|
|
197
|
+
export type MesssageDataType = EditResourceType | CreateResourceType | CloseBuilderType | CloseDocumentType | SetBreadcrumbsType | GoToPatientType | IframeRouteChangeType | SessionExpiredType | IframeReadyType | PatientLoadedType | CreateDraftType | CreatedDraftType | CreateDraftFailedType | DraftSavedType | OpenDocumentCaptureType | DocumentLoadErrorType | ReloadDocumentType | OpenDoctorsLetterExportType | LockDocumentType | DocumentLockedType | UnlockDocumentType | DraftUpdatedType | LeaveEditingRequestedType | LeaveEditingDecidedType;
|
|
79
198
|
export interface MessageDataMapType {
|
|
80
199
|
editResource: EditResourceType;
|
|
81
200
|
createResource: CreateResourceType;
|
|
@@ -86,13 +205,21 @@ export interface MessageDataMapType {
|
|
|
86
205
|
iframeRouteChange: IframeRouteChangeType;
|
|
87
206
|
sessionExpired: SessionExpiredType;
|
|
88
207
|
iframeReady: IframeReadyType;
|
|
208
|
+
patientLoaded: PatientLoadedType;
|
|
89
209
|
createDraft: CreateDraftType;
|
|
90
210
|
createdDraft: CreatedDraftType;
|
|
211
|
+
createDraftFailed: CreateDraftFailedType;
|
|
91
212
|
draftSaved: DraftSavedType;
|
|
92
213
|
openDocumentCapture: OpenDocumentCaptureType;
|
|
93
214
|
documentLoadError: DocumentLoadErrorType;
|
|
94
215
|
reloadDocument: ReloadDocumentType;
|
|
95
216
|
openDoctorsLetterExport: OpenDoctorsLetterExportType;
|
|
217
|
+
lockDocument: LockDocumentType;
|
|
218
|
+
documentLocked: DocumentLockedType;
|
|
219
|
+
unlockDocument: UnlockDocumentType;
|
|
220
|
+
draftUpdated: DraftUpdatedType;
|
|
221
|
+
leaveEditingRequested: LeaveEditingRequestedType;
|
|
222
|
+
leaveEditingDecided: LeaveEditingDecidedType;
|
|
96
223
|
}
|
|
97
224
|
export declare const publishMessage: (data: MesssageDataType, target?: Window) => void;
|
|
98
225
|
declare function subscribeMessage<T extends MessageType>(type: T, callback: (data: MessageDataMapType[T]) => void): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotbase/safe-frame-sync",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "Typesafe iframe and parent communication between Dotstudio and Dotclinic",
|
|
5
5
|
"homepage": "https://github.com/dot-base/safe-frame-sync",
|
|
6
6
|
"types": "dist/index.d.ts",
|