@dotbase/safe-frame-sync 1.14.0 → 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.
Files changed (2) hide show
  1. package/dist/index.d.ts +92 -2
  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" | "patientLoaded" | "createDraftFailed";
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;
@@ -93,6 +93,11 @@ export interface CreateDraftFailedType {
93
93
  export interface DraftSavedType {
94
94
  type: "draftSaved";
95
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
+ */
96
101
  export interface OpenDocumentCaptureType {
97
102
  type: "openDocumentCapture";
98
103
  procedureId: string;
@@ -110,7 +115,86 @@ export interface OpenDoctorsLetterExportType {
110
115
  procedureId: string;
111
116
  documentTemplateId: string;
112
117
  }
113
- export type MesssageDataType = EditResourceType | CreateResourceType | CloseBuilderType | CloseDocumentType | SetBreadcrumbsType | GoToPatientType | IframeRouteChangeType | SessionExpiredType | IframeReadyType | PatientLoadedType | CreateDraftType | CreatedDraftType | CreateDraftFailedType | DraftSavedType | OpenDocumentCaptureType | DocumentLoadErrorType | ReloadDocumentType | OpenDoctorsLetterExportType;
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;
114
198
  export interface MessageDataMapType {
115
199
  editResource: EditResourceType;
116
200
  createResource: CreateResourceType;
@@ -130,6 +214,12 @@ export interface MessageDataMapType {
130
214
  documentLoadError: DocumentLoadErrorType;
131
215
  reloadDocument: ReloadDocumentType;
132
216
  openDoctorsLetterExport: OpenDoctorsLetterExportType;
217
+ lockDocument: LockDocumentType;
218
+ documentLocked: DocumentLockedType;
219
+ unlockDocument: UnlockDocumentType;
220
+ draftUpdated: DraftUpdatedType;
221
+ leaveEditingRequested: LeaveEditingRequestedType;
222
+ leaveEditingDecided: LeaveEditingDecidedType;
133
223
  }
134
224
  export declare const publishMessage: (data: MesssageDataType, target?: Window) => void;
135
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.14.0",
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",