@powerhousedao/reactor-browser 6.2.3-dev.7 → 6.2.3-dev.70
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/{attachment-service-D3EhiAJ7.d.ts → attachment-service-CAf9N-15.d.ts} +365 -66
- package/dist/attachment-service-CAf9N-15.d.ts.map +1 -0
- package/dist/{client-DjK30EQ-.js → client-BFnMV-EO.js} +39 -22
- package/dist/client-BFnMV-EO.js.map +1 -0
- package/dist/{client-BIHN_UyR.d.ts → client-BnGewICj.d.ts} +3 -3
- package/dist/client-BnGewICj.d.ts.map +1 -0
- package/dist/{client-D66jVnot.js → client-CXDpILj6.js} +232 -32
- package/dist/client-CXDpILj6.js.map +1 -0
- package/dist/dispatch-Dd_WEz35.js +870 -0
- package/dist/dispatch-Dd_WEz35.js.map +1 -0
- package/dist/document-by-id-DqAyjr9P.js +16 -0
- package/dist/document-by-id-DqAyjr9P.js.map +1 -0
- package/dist/document-model-modules-DROQT_yu.js +431 -0
- package/dist/document-model-modules-DROQT_yu.js.map +1 -0
- package/dist/{document-operations-WeE6wIDt.js → document-operations-C6khz2If.js} +958 -204
- package/dist/document-operations-C6khz2If.js.map +1 -0
- package/dist/{global-OuINvEGT.d.ts → global-D-VZTZRz.d.ts} +113 -20
- package/dist/global-D-VZTZRz.d.ts.map +1 -0
- package/dist/{index-B33TKEqp.d.ts → index-XfcUiODQ.d.ts} +19 -98
- package/dist/index-XfcUiODQ.d.ts.map +1 -0
- package/dist/{index-BIVDXw3K.d.ts → index-rtDmzViP.d.ts} +3 -3
- package/dist/index-rtDmzViP.d.ts.map +1 -0
- package/dist/index.d.ts +693 -391
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +469 -72
- package/dist/index.js.map +1 -1
- package/dist/inspector-proxy-DODqs15F.d.ts +25 -0
- package/dist/inspector-proxy-DODqs15F.d.ts.map +1 -0
- package/dist/make-ph-event-functions-B5GU5xcR.js +180 -0
- package/dist/make-ph-event-functions-B5GU5xcR.js.map +1 -0
- package/dist/navigation-BqphkrOB.js +302 -0
- package/dist/navigation-BqphkrOB.js.map +1 -0
- package/dist/{pglite-CntadC_p-9NDG14dS.d.ts → pglite-CntadC_p-DTkdF8sr.d.ts} +11 -33
- package/dist/pglite-CntadC_p-DTkdF8sr.d.ts.map +1 -0
- package/dist/{relational-D1RB45sA.js → relational-DZuyKp2y.js} +66 -5
- package/dist/relational-DZuyKp2y.js.map +1 -0
- package/dist/{renown-rqK8sokh.js → renown-BtjgHBjH.js} +33 -28
- package/dist/{renown-rqK8sokh.js.map → renown-BtjgHBjH.js.map} +1 -1
- package/dist/{renown-BHxwP7xU.js → renown-BxkZYzbQ.js} +2 -2
- package/dist/{renown-BHxwP7xU.js.map → renown-BxkZYzbQ.js.map} +1 -1
- package/dist/src/ai/index.d.ts +51 -62
- package/dist/src/ai/index.d.ts.map +1 -1
- package/dist/src/ai/index.js +6 -9
- package/dist/src/ai/index.js.map +1 -1
- package/dist/src/analytics/index.d.ts +36 -44
- package/dist/src/analytics/index.d.ts.map +1 -1
- package/dist/src/analytics/index.js +4 -4
- package/dist/src/analytics/index.js.map +1 -1
- package/dist/src/document-model.d.ts +3 -4
- package/dist/src/document-model.d.ts.map +1 -1
- package/dist/src/document-model.js.map +1 -1
- package/dist/src/graphql/client.d.ts +4 -3
- package/dist/src/graphql/client.js +1 -1
- package/dist/src/graphql-client/entry.d.ts +5 -4
- package/dist/src/graphql-client/entry.js +4 -4
- package/dist/src/relational/index.d.ts +15 -9
- package/dist/src/relational/index.d.ts.map +1 -1
- package/dist/src/relational/index.js +1 -1
- package/dist/src/renown/index.d.ts +3 -2
- package/dist/src/renown/index.js +2 -2
- package/dist/src/rpc/index.d.ts +178 -138
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +420 -619
- package/dist/src/rpc/index.js.map +1 -1
- package/dist/{store-BJYcr_FL.js → store-DInXcjal.js} +1 -1
- package/dist/{store-BJYcr_FL.js.map → store-DInXcjal.js.map} +1 -1
- package/dist/{switchboard-CaXQ4-5Q.js → switchboard-cwUp3FxP.js} +98 -11
- package/dist/switchboard-cwUp3FxP.js.map +1 -0
- package/dist/{types-Dcv1ZLoW.d.ts → types-0Fh1tNjy.d.ts} +242 -17
- package/dist/types-0Fh1tNjy.d.ts.map +1 -0
- package/dist/{types-6vDzbRRS.d.ts → types-520nWrB3.d.ts} +2 -2
- package/dist/types-520nWrB3.d.ts.map +1 -0
- package/package.json +20 -21
- package/dist/attachment-service-D3EhiAJ7.d.ts.map +0 -1
- package/dist/client-BIHN_UyR.d.ts.map +0 -1
- package/dist/client-D66jVnot.js.map +0 -1
- package/dist/client-DjK30EQ-.js.map +0 -1
- package/dist/document-by-id-B4FIzG1w.js +0 -519
- package/dist/document-by-id-B4FIzG1w.js.map +0 -1
- package/dist/document-model-modules-bTP87nyr.js +0 -419
- package/dist/document-model-modules-bTP87nyr.js.map +0 -1
- package/dist/document-operations-WeE6wIDt.js.map +0 -1
- package/dist/global-OuINvEGT.d.ts.map +0 -1
- package/dist/index-B33TKEqp.d.ts.map +0 -1
- package/dist/index-BIVDXw3K.d.ts.map +0 -1
- package/dist/inspector-proxy-6h5VKAwt.d.ts +0 -257
- package/dist/inspector-proxy-6h5VKAwt.d.ts.map +0 -1
- package/dist/make-ph-event-functions-DBq3iWYn.js +0 -53
- package/dist/make-ph-event-functions-DBq3iWYn.js.map +0 -1
- package/dist/pglite-CntadC_p-9NDG14dS.d.ts.map +0 -1
- package/dist/relational-D1RB45sA.js.map +0 -1
- package/dist/switchboard-CaXQ4-5Q.js.map +0 -1
- package/dist/types-6vDzbRRS.d.ts.map +0 -1
- package/dist/types-Dcv1ZLoW.d.ts.map +0 -1
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { c as getPHStore, t as makePHEventFunctions } from "./make-ph-event-functions-B5GU5xcR.js";
|
|
2
|
+
import { C as queueActions, T as uploadOperations, _ as DOCUMENT_CHANGE_TYPE, f as DocumentCache, h as isOperationCache, i as setDocumentCache, o as useDocumentCache, p as IDLE_OPERATIONS_ENTRY, r as addDocumentCacheEventHandler, w as queueOperations } from "./dispatch-Dd_WEz35.js";
|
|
3
|
+
import { A as addDrivesEventHandler, B as UnsupportedDocumentTypeError, H as makeAuthMiddleware, L as DocumentModelNotFoundError, V as ambientRenownTokenProvider, a as setVetraPackageManager, c as addSelectedDriveIdEventHandler, f as setSelectedDriveId, h as useSelectedDriveId, r as addVetraPackageManagerEventHandler, u as selectDrive, v as addResetSelectedNodeEventHandler, w as setSelectedNodeId, y as addSelectedNodeIdEventHandler } from "./document-model-modules-DROQT_yu.js";
|
|
4
|
+
import { A as extractNodeIdFromSlug, N as findDriveBySlug, O as extractDriveSlugFromPath, S as setBrowserOpenSync, c as getCurrentPathname, d as hasHostNavigation, j as extractNodeSlugFromPath, l as getPHNavigation, m as openTarget, v as recordToSearch, x as searchToRecord } from "./navigation-BqphkrOB.js";
|
|
5
|
+
import { i as PhDocumentFieldsFragmentDoc, n as DocumentChangesDocument, t as createClient$1 } from "./client-CXDpILj6.js";
|
|
6
|
+
import { f as addLoadingEventHandler, t as addRenownEventHandler } from "./renown-BxkZYzbQ.js";
|
|
7
|
+
import { useCallback, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
8
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
6
9
|
import { logger } from "document-model";
|
|
7
|
-
import { UnsupportedDocumentModelVersionError, assertAuthPreservedOnDuplicate, baseLoadFromInput, baseLoadFromInputVersioned, baseSaveToFileHandle, createPresignedHeader, createZip, deserializeSignature, documentModelDocumentType, generateId, hashDocumentStateForScope, normalizeDocumentModelVersion, replayDocumentVersioned, setName, setPreferredEditor, toTransportAction } from "@powerhousedao/shared/document-model";
|
|
8
10
|
import { addFolder, copyNode, generateNodesCopy, handleTargetNameCollisions, isFileNode, isFolderNode, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
|
|
11
|
+
import { UnsupportedDocumentModelVersionError, actionSignerIdentity, actionSigningTarget, actions, assertAuthPreservedOnDuplicate, baseLoadFromInput, baseLoadFromInputVersioned, baseSaveToFileHandle, createCopyHeader, createPresignedHeader, createZip, deserializeSignature, documentModelDocumentType, generateId, hasDerivedDocumentId, hashDocumentStateForScope, isSignaturePolicy, normalizeDocumentModelVersion, replayDocumentVersioned, setName, setPreferredEditor, signaturePolicyOf, toTransportAction, withSignaturePolicy } from "@powerhousedao/shared/document-model";
|
|
9
12
|
import { allPass, conditional, constant, forEachObj, funnel, isDefined, isNot, isStrictEqual, isString, isTruthy, once } from "remeda";
|
|
10
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
11
13
|
import { GraphQLClient } from "graphql-request";
|
|
12
14
|
import { gql } from "graphql-tag";
|
|
13
15
|
import { Kind, print } from "graphql";
|
|
14
16
|
import { createClient } from "graphql-ws/client";
|
|
15
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
16
17
|
//#region src/hooks/modals.ts
|
|
17
18
|
const modalEventFunctions = makePHEventFunctions("modal");
|
|
18
19
|
/** Returns the current modal */
|
|
@@ -21,17 +22,108 @@ const usePHModal = modalEventFunctions.useValue;
|
|
|
21
22
|
const setPHModal = modalEventFunctions.setValue;
|
|
22
23
|
/** Adds an event handler for the modal */
|
|
23
24
|
const addModalEventHandler = modalEventFunctions.addEventHandler;
|
|
24
|
-
/**
|
|
25
|
+
/** The query param that names a routed modal. */
|
|
26
|
+
const MODAL_SEARCH_PARAM = "modal";
|
|
27
|
+
const MODAL_ROUTES = {
|
|
28
|
+
createDocument: {
|
|
29
|
+
id: "create-document",
|
|
30
|
+
toSearch: ({ documentType, documentModelVersion }) => ({
|
|
31
|
+
documentType,
|
|
32
|
+
...documentModelVersion !== void 0 && { documentModelVersion: String(documentModelVersion) }
|
|
33
|
+
}),
|
|
34
|
+
fromSearch: (search) => ({
|
|
35
|
+
documentType: search.documentType ?? "",
|
|
36
|
+
...search.documentModelVersion && { documentModelVersion: Number(search.documentModelVersion) }
|
|
37
|
+
})
|
|
38
|
+
},
|
|
39
|
+
login: { id: "login" },
|
|
40
|
+
addDrive: { id: "add-drive" },
|
|
41
|
+
driveSettings: {
|
|
42
|
+
id: "drive-settings",
|
|
43
|
+
toSearch: ({ driveId }) => ({ driveId }),
|
|
44
|
+
fromSearch: (search) => ({ driveId: search.driveId ?? "" })
|
|
45
|
+
},
|
|
46
|
+
debugSettings: { id: "debug-settings" },
|
|
47
|
+
inspector: { id: "inspector" },
|
|
48
|
+
disclaimer: { id: "disclaimer" },
|
|
49
|
+
cookiesPolicy: { id: "cookies-policy" }
|
|
50
|
+
};
|
|
51
|
+
const routeOf = (type) => MODAL_ROUTES[type];
|
|
52
|
+
/** Whether `modal` lives in the URL rather than the store. */
|
|
53
|
+
function isRoutedModal(modal) {
|
|
54
|
+
return !!modal && !!routeOf(modal.type);
|
|
55
|
+
}
|
|
56
|
+
/** The query params that open `modal`; undefined for one the store holds. */
|
|
57
|
+
function modalSearch(modal) {
|
|
58
|
+
const route = routeOf(modal.type);
|
|
59
|
+
if (!route) return void 0;
|
|
60
|
+
return {
|
|
61
|
+
[MODAL_SEARCH_PARAM]: route.id,
|
|
62
|
+
...route.toSearch?.(modal)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** The routed modal `search` opens, if any. */
|
|
66
|
+
function modalFromSearch(search) {
|
|
67
|
+
const id = search[MODAL_SEARCH_PARAM];
|
|
68
|
+
if (typeof id !== "string") return void 0;
|
|
69
|
+
const strings = Object.fromEntries(Object.entries(search).map(([key, value]) => [key, String(value)]));
|
|
70
|
+
for (const [type, route] of Object.entries(MODAL_ROUTES)) {
|
|
71
|
+
if (route.id !== id) continue;
|
|
72
|
+
return {
|
|
73
|
+
type,
|
|
74
|
+
...route.fromSearch?.(strings)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** `search` without a routed modal's params. */
|
|
79
|
+
function withoutModalSearch(search) {
|
|
80
|
+
const modal = modalFromSearch(search);
|
|
81
|
+
const own = modal ? Object.keys(modalSearch(modal) ?? {}) : [];
|
|
82
|
+
return Object.fromEntries(Object.entries(search).filter(([key]) => !own.includes(key)));
|
|
83
|
+
}
|
|
84
|
+
/** Shows a modal. With a host navigation, a routed one opens in the URL, in
|
|
85
|
+
* place of the current entry, and "settings" opens the settings page. */
|
|
25
86
|
function showPHModal(modal) {
|
|
87
|
+
if (modal.type === "settings" && hasHostNavigation()) {
|
|
88
|
+
openTarget({ settings: true });
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const search = modalSearch(modal);
|
|
92
|
+
if (search && hasHostNavigation()) {
|
|
93
|
+
if (!isRoutedModal(modalEventFunctions.getSnapshot())) setPHModal(void 0);
|
|
94
|
+
getPHNavigation().setSearch((prev) => ({
|
|
95
|
+
...withoutModalSearch(prev),
|
|
96
|
+
...search
|
|
97
|
+
}), { replace: true });
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
26
100
|
setPHModal(modal);
|
|
27
101
|
}
|
|
28
|
-
/** Closes the current modal
|
|
102
|
+
/** Closes the current modal; a routed one leaves the URL in place of the entry,
|
|
103
|
+
* and a confirmation opened over it closes with it. */
|
|
29
104
|
function closePHModal() {
|
|
105
|
+
if (hasHostNavigation()) {
|
|
106
|
+
const navigation = getPHNavigation();
|
|
107
|
+
if (modalFromSearch(searchToRecord(navigation.location().search))) {
|
|
108
|
+
navigation.setSearch((prev) => withoutModalSearch(prev), { replace: true });
|
|
109
|
+
if (!isRoutedModal(modalEventFunctions.getSnapshot())) setPHModal(void 0);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
30
113
|
setPHModal(void 0);
|
|
31
114
|
}
|
|
115
|
+
/** The href that opens `modal` over the current page. */
|
|
116
|
+
function modalHref(modal) {
|
|
117
|
+
const { pathname, search } = getPHNavigation().location();
|
|
118
|
+
const next = {
|
|
119
|
+
...withoutModalSearch(searchToRecord(search)),
|
|
120
|
+
...modalSearch(modal)
|
|
121
|
+
};
|
|
122
|
+
return `${pathname}${recordToSearch(next)}`;
|
|
123
|
+
}
|
|
32
124
|
/** Shows the create document modal */
|
|
33
125
|
function showCreateDocumentModal(documentType, documentModelVersion) {
|
|
34
|
-
|
|
126
|
+
showPHModal({
|
|
35
127
|
type: "createDocument",
|
|
36
128
|
documentType,
|
|
37
129
|
...documentModelVersion !== void 0 && { documentModelVersion }
|
|
@@ -39,12 +131,51 @@ function showCreateDocumentModal(documentType, documentModelVersion) {
|
|
|
39
131
|
}
|
|
40
132
|
/** Shows the delete node modal */
|
|
41
133
|
function showDeleteNodeModal(nodeOrId) {
|
|
134
|
+
const id = typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id;
|
|
42
135
|
setPHModal({
|
|
43
136
|
type: "deleteItem",
|
|
44
|
-
id
|
|
137
|
+
id
|
|
45
138
|
});
|
|
46
139
|
}
|
|
47
140
|
//#endregion
|
|
141
|
+
//#region src/hooks/reactor.ts
|
|
142
|
+
const reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
|
|
143
|
+
const reactorClientEventFunctions = makePHEventFunctions("reactorClient");
|
|
144
|
+
const fullReactorClientEventFunctions = makePHEventFunctions("fullReactorClient");
|
|
145
|
+
/** Returns the reactor client module (in-process or worker-backed) */
|
|
146
|
+
const useReactorClientModule = reactorClientModuleEventFunctions.useValue;
|
|
147
|
+
/** Sets the reactor client module */
|
|
148
|
+
const setReactorClientModule = reactorClientModuleEventFunctions.setValue;
|
|
149
|
+
/** Adds an event handler for the reactor client module */
|
|
150
|
+
const addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
|
|
151
|
+
/** Returns the reactor client */
|
|
152
|
+
const useReactorClient = reactorClientEventFunctions.useValue;
|
|
153
|
+
/** Sets the reactor client */
|
|
154
|
+
const setReactorClient = reactorClientEventFunctions.setValue;
|
|
155
|
+
/** Adds an event handler for the reactor client */
|
|
156
|
+
const addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
|
|
157
|
+
/** Sets the client full-client actions use instead of the module's */
|
|
158
|
+
const setFullReactorClient = fullReactorClientEventFunctions.setValue;
|
|
159
|
+
/** Adds an event handler for the full reactor client */
|
|
160
|
+
const addFullReactorClientEventHandler = fullReactorClientEventFunctions.addEventHandler;
|
|
161
|
+
/** The client full-client actions use: the one set, else the module's. */
|
|
162
|
+
function getFullReactorClient() {
|
|
163
|
+
return getPHStore()?.fullReactorClient ?? getPHStore()?.reactorClientModule?.client;
|
|
164
|
+
}
|
|
165
|
+
const useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
|
|
166
|
+
const useSyncList = () => {
|
|
167
|
+
return useSync()?.list() ?? [];
|
|
168
|
+
};
|
|
169
|
+
const useModelRegistry = () => useReactorClientModule()?.reactorModule?.documentModelRegistry;
|
|
170
|
+
const useDatabase = () => {
|
|
171
|
+
const module = useReactorClientModule();
|
|
172
|
+
return module?.kind === "browser" ? module.reactorModule?.database : void 0;
|
|
173
|
+
};
|
|
174
|
+
const usePGlite = () => {
|
|
175
|
+
const module = useReactorClientModule();
|
|
176
|
+
return module?.kind === "browser" ? module.reactorModule?.pg : void 0;
|
|
177
|
+
};
|
|
178
|
+
//#endregion
|
|
48
179
|
//#region src/utils/documents.ts
|
|
49
180
|
function isDocumentTypeSupported(documentType, supportedDocuments) {
|
|
50
181
|
if (!supportedDocuments?.length) return true;
|
|
@@ -63,8 +194,8 @@ function isDocumentTypeSupported(documentType, supportedDocuments) {
|
|
|
63
194
|
//#endregion
|
|
64
195
|
//#region src/utils/user.ts
|
|
65
196
|
function getUserPermissions() {
|
|
66
|
-
const user =
|
|
67
|
-
const allowList =
|
|
197
|
+
const user = getPHStore()?.renown?.user;
|
|
198
|
+
const allowList = getPHStore()?.allowList;
|
|
68
199
|
if (!allowList) return {
|
|
69
200
|
isAllowedToCreateDocuments: true,
|
|
70
201
|
isAllowedToEditDocuments: true
|
|
@@ -76,7 +207,7 @@ function getUserPermissions() {
|
|
|
76
207
|
}
|
|
77
208
|
//#endregion
|
|
78
209
|
//#region src/actions/document.ts
|
|
79
|
-
const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
|
|
210
|
+
const NON_DOMAIN_SCOPES = /* @__PURE__ */ new Set(["auth", "document"]);
|
|
80
211
|
/** An unreadable drive cannot be shown to hold no duplicate, so reads throw. */
|
|
81
212
|
async function isDocumentInLocation(reactorClient, document, driveId, parentFolder) {
|
|
82
213
|
const drive = await reactorClient.get(driveId);
|
|
@@ -131,7 +262,7 @@ async function getDocumentExtension(document) {
|
|
|
131
262
|
let rawExtension;
|
|
132
263
|
if (documentType === documentModelDocumentType) rawExtension = document.state.global?.extension;
|
|
133
264
|
else {
|
|
134
|
-
const reactorClient =
|
|
265
|
+
const reactorClient = getFullReactorClient();
|
|
135
266
|
if (reactorClient) {
|
|
136
267
|
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
137
268
|
rawExtension = documentModelModules.find((m) => m.documentModel.global.id === documentType)?.utils.fileExtension;
|
|
@@ -235,7 +366,7 @@ function boundary(upgrade, scope, ops) {
|
|
|
235
366
|
return ops.length;
|
|
236
367
|
}
|
|
237
368
|
async function exportFile(document, suggestedName) {
|
|
238
|
-
const reactorClient =
|
|
369
|
+
const reactorClient = getPHStore()?.reactorClient;
|
|
239
370
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
240
371
|
const operations = await fetchDocumentOperations(reactorClient, document);
|
|
241
372
|
const initialState = extractInitialState(operations["document"] ?? []);
|
|
@@ -263,7 +394,7 @@ async function exportFile(document, suggestedName) {
|
|
|
263
394
|
*/
|
|
264
395
|
async function loadFile(path) {
|
|
265
396
|
const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
|
|
266
|
-
const reactorClient =
|
|
397
|
+
const reactorClient = getFullReactorClient();
|
|
267
398
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
268
399
|
const documentType = baseDocument.header.documentType;
|
|
269
400
|
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
@@ -271,7 +402,7 @@ async function loadFile(path) {
|
|
|
271
402
|
if (modulesForType.length === 0) throw new DocumentModelNotFoundError(documentType);
|
|
272
403
|
const reducers = {};
|
|
273
404
|
for (const module of modulesForType) reducers[module.version ?? 1] = module.reducer;
|
|
274
|
-
const registry =
|
|
405
|
+
const registry = getPHStore()?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
275
406
|
let upgradeManifest;
|
|
276
407
|
if (registry) try {
|
|
277
408
|
upgradeManifest = registry.getUpgradeManifest(documentType);
|
|
@@ -284,7 +415,7 @@ async function loadFile(path) {
|
|
|
284
415
|
async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor, documentModelVersion) {
|
|
285
416
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
286
417
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create documents");
|
|
287
|
-
const reactorClient =
|
|
418
|
+
const reactorClient = getFullReactorClient();
|
|
288
419
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
289
420
|
let documentModelModule;
|
|
290
421
|
if (documentModelVersion !== void 0) {
|
|
@@ -293,7 +424,7 @@ async function addDocument(driveId, name, documentType, parentFolder, document,
|
|
|
293
424
|
if (!module) throw new Error(`Document model not found for type: ${documentType} with version: ${documentModelVersion}`);
|
|
294
425
|
documentModelModule = module;
|
|
295
426
|
} else documentModelModule = await reactorClient.getDocumentModelModule(documentType);
|
|
296
|
-
const newDocument = document ?? documentModelModule.utils.createDocument();
|
|
427
|
+
const newDocument = document ?? withSignaturePolicy(documentModelModule.utils.createDocument(), await reactorClient.getCreateSignaturePolicy());
|
|
297
428
|
if (!document) newDocument.state.document.version = documentModelModule.version ?? 1;
|
|
298
429
|
newDocument.header.name = name;
|
|
299
430
|
if (preferredEditor) newDocument.header.meta = {
|
|
@@ -341,9 +472,24 @@ function isDocumentAlreadyExists(error) {
|
|
|
341
472
|
* fails leaves the drive untouched, so a retry has nothing to clean up.
|
|
342
473
|
*/
|
|
343
474
|
async function createImportedDocument(reactor, document, driveId, name, parentFolder) {
|
|
344
|
-
|
|
475
|
+
const v2Required = signaturePolicyOf(document.header) === "v2-required";
|
|
476
|
+
const keepsId = (!v2Required || hasDerivedDocumentId(document.header)) && !await reactor.isDocumentIdTaken(document.header.id);
|
|
477
|
+
let documentId = keepsId ? document.header.id : generateId();
|
|
345
478
|
for (let attempt = 1;; attempt++) {
|
|
346
|
-
|
|
479
|
+
let header;
|
|
480
|
+
if (!v2Required) header = createPresignedHeader(documentId, document.header.documentType);
|
|
481
|
+
else if (keepsId && attempt === 1) {
|
|
482
|
+
header = createPresignedHeader(documentId, document.header.documentType);
|
|
483
|
+
header.createdAtUtcIso = document.header.createdAtUtcIso;
|
|
484
|
+
header.sig = {
|
|
485
|
+
...header.sig,
|
|
486
|
+
nonce: document.header.sig.nonce
|
|
487
|
+
};
|
|
488
|
+
header.protocolVersions = { ...document.header.protocolVersions };
|
|
489
|
+
} else {
|
|
490
|
+
header = createCopyHeader(document.header);
|
|
491
|
+
documentId = header.id;
|
|
492
|
+
}
|
|
347
493
|
header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
|
|
348
494
|
header.meta = document.header.meta;
|
|
349
495
|
header.name = name || document.header.name;
|
|
@@ -372,7 +518,7 @@ async function createImportedDocument(reactor, document, driveId, name, parentFo
|
|
|
372
518
|
}
|
|
373
519
|
async function addFileWithProgress(file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict) {
|
|
374
520
|
logger.verbose(`addFileWithProgress(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
|
|
375
|
-
const reactor =
|
|
521
|
+
const reactor = getFullReactorClient();
|
|
376
522
|
if (!reactor) {
|
|
377
523
|
onProgress?.({
|
|
378
524
|
stage: "failed",
|
|
@@ -406,7 +552,7 @@ async function addFileWithProgress(file, driveId, name, parentFolder, onProgress
|
|
|
406
552
|
});
|
|
407
553
|
return;
|
|
408
554
|
}
|
|
409
|
-
const discoveryService =
|
|
555
|
+
const discoveryService = getPHStore()?.packageDiscoveryService;
|
|
410
556
|
if (discoveryService && DocumentModelNotFoundError.isError(loadError)) {
|
|
411
557
|
retryAfterDiscovery(discoveryService, loadError.documentType, file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict).catch((retryError) => {
|
|
412
558
|
logger.error("Import retry after discovery failed: @error", retryError);
|
|
@@ -514,7 +660,7 @@ async function retryAfterDiscovery(discoveryService, documentType, file, driveId
|
|
|
514
660
|
async function addFolder$1(driveId, name, parentFolder) {
|
|
515
661
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
516
662
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create folders");
|
|
517
|
-
const reactorClient =
|
|
663
|
+
const reactorClient = getPHStore()?.reactorClient;
|
|
518
664
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
519
665
|
await reactorClient.get(driveId);
|
|
520
666
|
const folderId = generateId();
|
|
@@ -529,14 +675,14 @@ async function addFolder$1(driveId, name, parentFolder) {
|
|
|
529
675
|
async function deleteNode(driveId, nodeId) {
|
|
530
676
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
531
677
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to delete documents");
|
|
532
|
-
const reactorClient =
|
|
678
|
+
const reactorClient = getFullReactorClient();
|
|
533
679
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
534
680
|
await reactorClient.drives.removeNode(driveId, nodeId);
|
|
535
681
|
}
|
|
536
682
|
async function renameNode(driveId, nodeId, name) {
|
|
537
683
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
538
684
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
|
|
539
|
-
const reactorClient =
|
|
685
|
+
const reactorClient = getPHStore()?.reactorClient;
|
|
540
686
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
541
687
|
if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
|
|
542
688
|
const node = (await reactorClient.execute(driveId, "main", [updateNode({
|
|
@@ -549,7 +695,7 @@ async function renameNode(driveId, nodeId, name) {
|
|
|
549
695
|
async function renameDriveNode(driveId, nodeId, name) {
|
|
550
696
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
551
697
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to rename documents");
|
|
552
|
-
const reactorClient =
|
|
698
|
+
const reactorClient = getPHStore()?.reactorClient;
|
|
553
699
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
554
700
|
if ((await reactorClient.execute(nodeId, "main", [setName({ name })])).header.name !== name) throw new Error("There was an error renaming the node");
|
|
555
701
|
await reactorClient.execute(driveId, "main", [updateNode({
|
|
@@ -561,7 +707,7 @@ async function renameDriveNode(driveId, nodeId, name) {
|
|
|
561
707
|
async function setPreferredEditorOnNode(nodeId, preferredEditor) {
|
|
562
708
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
563
709
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to modify documents");
|
|
564
|
-
const reactorClient =
|
|
710
|
+
const reactorClient = getPHStore()?.reactorClient;
|
|
565
711
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
566
712
|
return reactorClient.execute(nodeId, "main", [setPreferredEditor(preferredEditor)]);
|
|
567
713
|
}
|
|
@@ -570,7 +716,7 @@ async function moveNodeById(args) {
|
|
|
570
716
|
if (!driveId || !srcId) return;
|
|
571
717
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
572
718
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
|
|
573
|
-
const reactorClient =
|
|
719
|
+
const reactorClient = getPHStore()?.reactorClient;
|
|
574
720
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
575
721
|
const targetParentFolder = conditional(targetId, [isNot(isDefined), constant(void 0)], [isStrictEqual(driveId), constant(void 0)], constant(targetId));
|
|
576
722
|
if (isStrictEqual(targetParentFolder, srcId)) return;
|
|
@@ -582,7 +728,7 @@ async function moveNodeById(args) {
|
|
|
582
728
|
async function moveNode$1(driveId, src, target) {
|
|
583
729
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
584
730
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to move documents");
|
|
585
|
-
const reactorClient =
|
|
731
|
+
const reactorClient = getPHStore()?.reactorClient;
|
|
586
732
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
587
733
|
return await reactorClient.execute(driveId, "main", [moveNode({
|
|
588
734
|
srcFolder: src.id,
|
|
@@ -593,14 +739,14 @@ async function moveNode$1(driveId, src, target) {
|
|
|
593
739
|
* Duplicates a document under a new id using version-aware replay.
|
|
594
740
|
* Falls back gracefully when no upgrade manifest is registered for the document type.
|
|
595
741
|
*/
|
|
596
|
-
async function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
742
|
+
async function _duplicateDocument(reactor, document, newId = generateId(), driveId) {
|
|
597
743
|
const documentType = document.header.documentType;
|
|
598
744
|
const { results: allModules } = await reactor.getDocumentModelModules();
|
|
599
745
|
const modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);
|
|
600
746
|
const reducers = {};
|
|
601
747
|
for (const m of modulesForType) reducers[m.version ?? 1] = m.reducer;
|
|
602
748
|
if (Object.keys(reducers).length === 0) throw new Error(`Document model module not found for type: ${documentType}`);
|
|
603
|
-
const registry =
|
|
749
|
+
const registry = getPHStore()?.reactorClientModule?.reactorModule?.documentModelRegistry;
|
|
604
750
|
let upgradeManifest;
|
|
605
751
|
if (registry) try {
|
|
606
752
|
upgradeManifest = registry.getUpgradeManifest(documentType);
|
|
@@ -609,13 +755,20 @@ async function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
|
609
755
|
reducers,
|
|
610
756
|
upgradeManifest
|
|
611
757
|
};
|
|
612
|
-
const
|
|
758
|
+
const selected = await reactor.getCreateProtocolVersions(driveId);
|
|
759
|
+
const header = createCopyHeader({
|
|
760
|
+
documentType: document.header.documentType,
|
|
761
|
+
protocolVersions: document.header.protocolVersions ? {
|
|
762
|
+
...selected,
|
|
763
|
+
...document.header.protocolVersions
|
|
764
|
+
} : void 0
|
|
765
|
+
}, newId, await reactor.getCreateSignaturePolicy());
|
|
613
766
|
const duplicated = replayDocumentVersioned(document.initialState, document.operations, config, header);
|
|
614
767
|
assertAuthPreservedOnDuplicate(document.header.id, document.state.auth, duplicated.state.auth);
|
|
615
768
|
return duplicated;
|
|
616
769
|
}
|
|
617
770
|
async function copyNode$1(driveId, src, target) {
|
|
618
|
-
const reactor =
|
|
771
|
+
const reactor = getFullReactorClient();
|
|
619
772
|
if (!reactor) return;
|
|
620
773
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
621
774
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to copy documents");
|
|
@@ -643,25 +796,33 @@ async function copyNode$1(driveId, src, target) {
|
|
|
643
796
|
return node !== void 0 && isFileNode(node);
|
|
644
797
|
});
|
|
645
798
|
for (const fileNodeToCopy of fileNodesToCopy) try {
|
|
646
|
-
const duplicatedDocument = await _duplicateDocument(reactor, await reactor.get(fileNodeToCopy.srcId), fileNodeToCopy.targetId);
|
|
799
|
+
const duplicatedDocument = await _duplicateDocument(reactor, await reactor.get(fileNodeToCopy.srcId), fileNodeToCopy.targetId, driveId);
|
|
647
800
|
const resolvedName = resolvedNamesMap.get(fileNodeToCopy.targetId);
|
|
648
801
|
if (resolvedName) duplicatedDocument.header.name = resolvedName;
|
|
802
|
+
fileNodeToCopy.targetId = duplicatedDocument.header.id;
|
|
649
803
|
await reactor.drives.addFile(driveId, duplicatedDocument, target?.id);
|
|
650
804
|
} catch (e) {
|
|
651
805
|
logger.error(`Error copying document ${fileNodeToCopy.srcId}: ${String(e)}`);
|
|
652
806
|
}
|
|
653
|
-
|
|
807
|
+
const copyActions = copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput));
|
|
808
|
+
return await queueActions(drive, copyActions);
|
|
654
809
|
}
|
|
655
810
|
/**
|
|
656
811
|
* Upgrades a document to a newer document model version. Defaults to the
|
|
657
812
|
* latest registered version for the document's type.
|
|
658
813
|
*/
|
|
659
814
|
async function upgradeDocument(documentId, toVersion) {
|
|
660
|
-
const reactorClient =
|
|
815
|
+
const reactorClient = getFullReactorClient();
|
|
661
816
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
662
817
|
return reactorClient.upgradeDocument(documentId, toVersion);
|
|
663
818
|
}
|
|
664
819
|
//#endregion
|
|
820
|
+
//#region src/constants.ts
|
|
821
|
+
const DEFAULT_DRIVE_EDITOR_ID = "powerhouse/generic-drive-explorer";
|
|
822
|
+
const COMMON_PACKAGE_ID = "powerhouse/common";
|
|
823
|
+
/** Document types that represent a "drive": a container of nodes. */
|
|
824
|
+
const DRIVE_DOCUMENT_TYPES = ["powerhouse/document-drive", "powerhouse/reactor-drive"];
|
|
825
|
+
//#endregion
|
|
665
826
|
//#region src/remote-controller/utils.ts
|
|
666
827
|
/** Convert SCREAMING_SNAKE_CASE to camelCase (e.g. "SET_MODEL_NAME" → "setModelName"). */
|
|
667
828
|
function screamingSnakeToCamel(s) {
|
|
@@ -669,6 +830,7 @@ function screamingSnakeToCamel(s) {
|
|
|
669
830
|
}
|
|
670
831
|
/** Error thrown when a push conflict is detected with the "reject" strategy. */
|
|
671
832
|
var ConflictError = class extends Error {
|
|
833
|
+
conflict;
|
|
672
834
|
constructor(conflict) {
|
|
673
835
|
super("Push conflict: remote has new operations since last pull");
|
|
674
836
|
this.conflict = conflict;
|
|
@@ -814,7 +976,9 @@ function phDocumentHeaderFromGetDocument(document, branch) {
|
|
|
814
976
|
name: document.name,
|
|
815
977
|
branch: branch ?? defaultBranch,
|
|
816
978
|
revision: revisionMapFromRevisionsList(document.revisionsList),
|
|
817
|
-
lastModifiedAtUtcIso: isoStringFromDateTime(document.lastModifiedAtUtcIso)
|
|
979
|
+
lastModifiedAtUtcIso: isoStringFromDateTime(document.lastModifiedAtUtcIso),
|
|
980
|
+
...document.meta != null ? { meta: document.meta } : {},
|
|
981
|
+
...document.protocolVersions != null ? { protocolVersions: document.protocolVersions } : {}
|
|
818
982
|
};
|
|
819
983
|
}
|
|
820
984
|
function emptyOperationsForScopes(revisionsList) {
|
|
@@ -825,6 +989,61 @@ function isoStringFromDateTime(value) {
|
|
|
825
989
|
return value instanceof Date ? value.toISOString() : value;
|
|
826
990
|
}
|
|
827
991
|
//#endregion
|
|
992
|
+
//#region src/graphql-client/errors.ts
|
|
993
|
+
/** A call the Switchboard GraphQL surface cannot express. */
|
|
994
|
+
var GraphQLOperationNotSupportedError = class extends Error {
|
|
995
|
+
name = "GraphQLOperationNotSupportedError";
|
|
996
|
+
operation;
|
|
997
|
+
constructor(operation, reason) {
|
|
998
|
+
super(`GraphQLReactorClient.${operation} is not supported: ${reason}`);
|
|
999
|
+
this.operation = operation;
|
|
1000
|
+
}
|
|
1001
|
+
static isError(error) {
|
|
1002
|
+
return Error.isError(error) && error.name === "GraphQLOperationNotSupportedError";
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
/**
|
|
1006
|
+
* The Switchboard refused a request with 421 Misdirected Request: the
|
|
1007
|
+
* `Drive-Id` it carried names a drive that Switchboard does not own.
|
|
1008
|
+
*/
|
|
1009
|
+
var GraphQLWrongBackendError = class extends Error {
|
|
1010
|
+
name = "GraphQLWrongBackendError";
|
|
1011
|
+
status = 421;
|
|
1012
|
+
/** The drive the Switchboard refused, or `""` when its answer names none. */
|
|
1013
|
+
driveId;
|
|
1014
|
+
/** The response body, parsed when it is JSON. */
|
|
1015
|
+
payload;
|
|
1016
|
+
constructor(driveId, payload, options) {
|
|
1017
|
+
super(`The Switchboard does not serve drive ${driveId === "" ? "(unnamed)" : driveId}: 421 Misdirected Request`, options);
|
|
1018
|
+
this.driveId = driveId;
|
|
1019
|
+
this.payload = payload;
|
|
1020
|
+
}
|
|
1021
|
+
static isError(error) {
|
|
1022
|
+
return Error.isError(error) && error.name === "GraphQLWrongBackendError" && typeof error.driveId === "string";
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
/**
|
|
1026
|
+
* The reactor's `BatchJobFailedError`, rebuilt from a batch result; this entry
|
|
1027
|
+
* imports the reactor for types only. The shared name lets either `isError`
|
|
1028
|
+
* recognise it.
|
|
1029
|
+
*/
|
|
1030
|
+
var BatchJobFailedError = class extends Error {
|
|
1031
|
+
name = "BatchJobFailedError";
|
|
1032
|
+
key;
|
|
1033
|
+
jobs;
|
|
1034
|
+
constructor(key, jobs) {
|
|
1035
|
+
const failure = jobs[key].error;
|
|
1036
|
+
const cause = new Error(failure?.message ?? "Job failed");
|
|
1037
|
+
cause.name = failure?.name ?? "Error";
|
|
1038
|
+
super(failure?.message ?? "Job failed", { cause });
|
|
1039
|
+
this.key = key;
|
|
1040
|
+
this.jobs = jobs;
|
|
1041
|
+
}
|
|
1042
|
+
static isError(error) {
|
|
1043
|
+
return Error.isError(error) && error.name === "BatchJobFailedError" && typeof error.key === "string" && typeof error.jobs === "object";
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
//#endregion
|
|
828
1047
|
//#region src/graphql-client/operations.ts
|
|
829
1048
|
/**
|
|
830
1049
|
* The operation selection of `GetDocumentOperations`, lifted into a fragment so
|
|
@@ -941,43 +1160,42 @@ function stampAction(action, document, revision = document.header.revision[actio
|
|
|
941
1160
|
};
|
|
942
1161
|
}
|
|
943
1162
|
/**
|
|
944
|
-
* Signs a stamped action
|
|
945
|
-
*
|
|
946
|
-
*
|
|
947
|
-
*
|
|
1163
|
+
* Signs a stamped action for `target`, keeping any signatures it already
|
|
1164
|
+
* carries. The signer reads `context.prevOpHash`, so this runs after
|
|
1165
|
+
* {@link stampAction}. A v2 tuple covers the signer's identity, so the context
|
|
1166
|
+
* takes the signer's user and app even when the action named others.
|
|
948
1167
|
*/
|
|
949
|
-
async function signStampedAction(action, signer, signal) {
|
|
950
|
-
|
|
951
|
-
const
|
|
952
|
-
const app = actionSigner?.app ?? signer.app;
|
|
953
|
-
if (!user || !app) throw new Error("cannot sign an action: the signer has no user or app identity");
|
|
954
|
-
const signature = await signer.signAction(action, signal);
|
|
1168
|
+
async function signStampedAction(action, signer, target, signal) {
|
|
1169
|
+
if (!signer.user || !signer.app) throw new Error("cannot sign an action: the signer has no user or app identity");
|
|
1170
|
+
const signature = await signer.signAction(action, target, signal);
|
|
955
1171
|
return {
|
|
956
1172
|
...action,
|
|
957
1173
|
context: {
|
|
958
1174
|
...action.context,
|
|
959
1175
|
signer: {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
signatures: [...actionSigner?.signatures ?? [], signature]
|
|
1176
|
+
...actionSignerIdentity(signer),
|
|
1177
|
+
signatures: [...action.context?.signer?.signatures ?? [], signature]
|
|
963
1178
|
}
|
|
964
1179
|
}
|
|
965
1180
|
};
|
|
966
1181
|
}
|
|
1182
|
+
/** The log a snapshot's action is written to; the snapshot names the branch read. */
|
|
1183
|
+
function snapshotTarget(action, snapshot) {
|
|
1184
|
+
return actionSigningTarget(action, snapshot.header.id, snapshot.header.branch || "main");
|
|
1185
|
+
}
|
|
967
1186
|
/**
|
|
968
1187
|
* Actions a snapshot batch cannot predict the next state for.
|
|
969
1188
|
*
|
|
970
|
-
* `UNDO
|
|
971
|
-
*
|
|
1189
|
+
* `UNDO` and `REDO` rewrite history the light read path never fetched (and
|
|
1190
|
+
* the reducer appends no operation for them); `NOOP` is only ever produced
|
|
972
1191
|
* by an undo chain; the document-scope actions run through the reactor's
|
|
973
1192
|
* document-action handler rather than a document-model reducer
|
|
974
1193
|
* (`DOCUMENT_SCOPE_ACTIONS` in packages/reactor/src/executor/util.ts) and
|
|
975
1194
|
* `UPGRADE_DOCUMENT` changes which reducer applies mid-batch.
|
|
976
1195
|
*/
|
|
977
|
-
const unsupportedBatchActions = new Set([
|
|
1196
|
+
const unsupportedBatchActions = /* @__PURE__ */ new Set([
|
|
978
1197
|
"UNDO",
|
|
979
1198
|
"REDO",
|
|
980
|
-
"PRUNE",
|
|
981
1199
|
"NOOP",
|
|
982
1200
|
"CREATE_DOCUMENT",
|
|
983
1201
|
"DELETE_DOCUMENT",
|
|
@@ -991,9 +1209,9 @@ const unsupportedBatchActions = new Set([
|
|
|
991
1209
|
* carries none.
|
|
992
1210
|
*
|
|
993
1211
|
* `baseReducer` reads `baseReducerVersion(document.header)` for every action and
|
|
994
|
-
* throws when the header has no `protocolVersions
|
|
995
|
-
* {@link phDocumentFromGetDocument}
|
|
996
|
-
*
|
|
1212
|
+
* throws when the header has no `protocolVersions`, which a header built by
|
|
1213
|
+
* {@link phDocumentFromGetDocument} lacks when the server sends none. The
|
|
1214
|
+
* version only selects between the v1
|
|
997
1215
|
* and v2 UNDO/NOOP branches, and every action reaching the prediction loop is an
|
|
998
1216
|
* ordinary append-only one, so it cannot change the predicted state here; it is
|
|
999
1217
|
* passed purely so the lookup does not throw.
|
|
@@ -1020,7 +1238,7 @@ const predictionProtocolVersion = 2;
|
|
|
1020
1238
|
*/
|
|
1021
1239
|
async function prepareSignedActions(actions, snapshot, signer, module, signal) {
|
|
1022
1240
|
if (actions.length === 0) return [];
|
|
1023
|
-
if (actions.length === 1) return [await signStampedAction(stampAction(actions[0], snapshot), signer, signal)];
|
|
1241
|
+
if (actions.length === 1) return [await signStampedAction(stampAction(actions[0], snapshot), signer, snapshotTarget(actions[0], snapshot), signal)];
|
|
1024
1242
|
const scope = sharedScope(actions);
|
|
1025
1243
|
assertSupportedBatch(actions);
|
|
1026
1244
|
if (!module) throw new Error(`cannot sign ${actions.length} actions: no document model module for ${snapshot.header.documentType} was supplied, so the batch state cannot be predicted`);
|
|
@@ -1035,7 +1253,8 @@ async function prepareSignedActions(actions, snapshot, signer, module, signal) {
|
|
|
1035
1253
|
const signed = [];
|
|
1036
1254
|
for (const [index, action] of actions.entries()) {
|
|
1037
1255
|
throwIfAborted(signal, index);
|
|
1038
|
-
const
|
|
1256
|
+
const stamped = stampAction(action, working, revision);
|
|
1257
|
+
const signedAction = await signStampedAction(stamped, signer, snapshotTarget(stamped, snapshot), signal);
|
|
1039
1258
|
signed.push(signedAction);
|
|
1040
1259
|
const before = scopeOperationCount(working, scope);
|
|
1041
1260
|
let next;
|
|
@@ -1375,6 +1594,7 @@ const defaultPaging = {
|
|
|
1375
1594
|
cursor: "0",
|
|
1376
1595
|
limit: 100
|
|
1377
1596
|
};
|
|
1597
|
+
const JOB_POLL_INTERVAL_MS = 250;
|
|
1378
1598
|
/**
|
|
1379
1599
|
* The marker {@link isGraphQLReactorClient} looks for.
|
|
1380
1600
|
*
|
|
@@ -1401,6 +1621,7 @@ var GraphQLReactorClient = class {
|
|
|
1401
1621
|
subscriptionsUrl;
|
|
1402
1622
|
documentModels;
|
|
1403
1623
|
signer;
|
|
1624
|
+
driveIdFor;
|
|
1404
1625
|
stopRealtime;
|
|
1405
1626
|
realtimeStarted = false;
|
|
1406
1627
|
realtimeGeneration = 0;
|
|
@@ -1409,10 +1630,16 @@ var GraphQLReactorClient = class {
|
|
|
1409
1630
|
realtimeRefusedCredentials = false;
|
|
1410
1631
|
constructor(options) {
|
|
1411
1632
|
this.tokenProvider = options.tokenProvider ?? ambientRenownTokenProvider;
|
|
1412
|
-
|
|
1633
|
+
const models = options.documentModels;
|
|
1634
|
+
if (typeof models === "function") this.documentModels = models;
|
|
1635
|
+
else {
|
|
1636
|
+
const copied = [...models ?? []];
|
|
1637
|
+
this.documentModels = () => copied;
|
|
1638
|
+
}
|
|
1413
1639
|
this.signer = options.signer;
|
|
1640
|
+
this.driveIdFor = options.driveIdFor;
|
|
1414
1641
|
this.subscriptionsUrl = options.realtime === false ? void 0 : options.subscriptionsUrl ?? subscriptionsUrlFromGraphqlUrl(options.url);
|
|
1415
|
-
const middleware = makeAuthMiddleware(this.tokenProvider);
|
|
1642
|
+
const middleware = withWrongBackendErrors(makeAuthMiddleware(this.tokenProvider));
|
|
1416
1643
|
this.sdk = options.graphqlClient ?? createClient$1(options.url, middleware);
|
|
1417
1644
|
this.subgraphs = new SubgraphSdkRegistry(options.url, middleware);
|
|
1418
1645
|
}
|
|
@@ -1425,6 +1652,26 @@ var GraphQLReactorClient = class {
|
|
|
1425
1652
|
if (!document) throw new Error(`Document not found: ${identifier}`);
|
|
1426
1653
|
return phDocumentFromGetDocument(document.document, view?.branch);
|
|
1427
1654
|
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Whether the Switchboard would serve the document to this client's caller,
|
|
1657
|
+
* from its `documentServed` query: the same read gate `find` passes. Absent
|
|
1658
|
+
* or withheld is `false`; a failure to decide throws.
|
|
1659
|
+
*
|
|
1660
|
+
* A point-in-time view throws {@link GraphQLOperationNotSupportedError}, as
|
|
1661
|
+
* does a Switchboard without the query.
|
|
1662
|
+
*/
|
|
1663
|
+
async isServed(identifier, view, signal) {
|
|
1664
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1665
|
+
try {
|
|
1666
|
+
return (await this.sdk.GetDocumentServed({
|
|
1667
|
+
idOrSlug: identifier,
|
|
1668
|
+
view: viewInput
|
|
1669
|
+
}, void 0, signal)).documentServed;
|
|
1670
|
+
} catch (error) {
|
|
1671
|
+
if (queriesUnknownField(error, "documentServed")) throw new GraphQLOperationNotSupportedError("isServed", "the Switchboard predates the documentServed query");
|
|
1672
|
+
throw error;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1428
1675
|
async getOperations(documentIdentifier, view, filter, paging, signal) {
|
|
1429
1676
|
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1430
1677
|
const operationsFilter = {
|
|
@@ -1446,18 +1693,105 @@ var GraphQLReactorClient = class {
|
|
|
1446
1693
|
results: page.items.map((item) => remoteOperationToLocal(item)),
|
|
1447
1694
|
options: effectivePaging,
|
|
1448
1695
|
nextCursor,
|
|
1449
|
-
totalCount: page.totalCount,
|
|
1450
1696
|
next: nextCursor ? () => this.getOperations(documentIdentifier, view, filter, {
|
|
1451
1697
|
cursor: nextCursor,
|
|
1452
1698
|
limit: effectivePaging.limit
|
|
1453
1699
|
}, signal) : void 0
|
|
1454
1700
|
};
|
|
1455
1701
|
}
|
|
1702
|
+
/**
|
|
1703
|
+
* Filters documents by criteria over the Switchboard's `findDocuments` query.
|
|
1704
|
+
*
|
|
1705
|
+
* The query filters by `type` and `parentId` only, at head. A search naming
|
|
1706
|
+
* `ids` or `slugs` (present, whatever its length) and a point-in-time view are
|
|
1707
|
+
* each by-contract limitations the query cannot express -- running it anyway
|
|
1708
|
+
* would return every document instead of the named ones, or head instead of
|
|
1709
|
+
* the asked-for revision, a silently wrong answer. {@link findIsServableOverGraphQL}
|
|
1710
|
+
* is the single predicate that decides this, and an unservable `find` throws
|
|
1711
|
+
* {@link GraphQLOperationNotSupportedError}. Drive enumeration itself filters
|
|
1712
|
+
* by `type` at head, which is served.
|
|
1713
|
+
*/
|
|
1714
|
+
async find(search, view, paging, signal) {
|
|
1715
|
+
if (!findIsServableOverGraphQL(search, view)) throw new GraphQLOperationNotSupportedError("find", searchNamesIdentifiers(search) ? "it cannot filter by ids or slugs: the Switchboard findDocuments query filters only by type and parentId" : "point-in-time views are not supported by GraphQLReactorClient");
|
|
1716
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1717
|
+
const effectivePaging = paging ?? defaultPaging;
|
|
1718
|
+
const result = await this.sdk.FindDocuments({
|
|
1719
|
+
search: {
|
|
1720
|
+
type: search.type,
|
|
1721
|
+
parentId: search.parentId
|
|
1722
|
+
},
|
|
1723
|
+
view: viewInput,
|
|
1724
|
+
paging: pagingInputFromPaging(effectivePaging)
|
|
1725
|
+
}, search.parentId === void 0 ? void 0 : this.driveIdHeaders({
|
|
1726
|
+
method: "find",
|
|
1727
|
+
parentId: search.parentId
|
|
1728
|
+
}), signal);
|
|
1729
|
+
return this.toDocumentResults(result.findDocuments, effectivePaging, view?.branch, (cursor, limit) => this.find(search, view, {
|
|
1730
|
+
cursor,
|
|
1731
|
+
limit
|
|
1732
|
+
}, signal));
|
|
1733
|
+
}
|
|
1734
|
+
async getOutgoingRelationships(sourceIdentifier, relationshipType, view, paging, signal) {
|
|
1735
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1736
|
+
const result = await this.sdk.GetDocumentOutgoingRelationships({
|
|
1737
|
+
sourceIdentifier,
|
|
1738
|
+
relationshipType,
|
|
1739
|
+
view: viewInput,
|
|
1740
|
+
paging: pagingInputFromPaging(paging)
|
|
1741
|
+
}, void 0, signal);
|
|
1742
|
+
return this.toDocumentResults(result.documentOutgoingRelationships, paging ?? defaultPaging, view?.branch, (cursor, limit) => this.getOutgoingRelationships(sourceIdentifier, relationshipType, view, {
|
|
1743
|
+
cursor,
|
|
1744
|
+
limit
|
|
1745
|
+
}, signal));
|
|
1746
|
+
}
|
|
1747
|
+
async getIncomingRelationships(targetIdentifier, relationshipType, view, paging, signal) {
|
|
1748
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1749
|
+
const result = await this.sdk.GetDocumentIncomingRelationships({
|
|
1750
|
+
targetIdentifier,
|
|
1751
|
+
relationshipType,
|
|
1752
|
+
view: viewInput,
|
|
1753
|
+
paging: pagingInputFromPaging(paging)
|
|
1754
|
+
}, void 0, signal);
|
|
1755
|
+
return this.toDocumentResults(result.documentIncomingRelationships, paging ?? defaultPaging, view?.branch, (cursor, limit) => this.getIncomingRelationships(targetIdentifier, relationshipType, view, {
|
|
1756
|
+
cursor,
|
|
1757
|
+
limit
|
|
1758
|
+
}, signal));
|
|
1759
|
+
}
|
|
1760
|
+
async getOutgoingRelationshipEdges(sourceIdentifier, relationshipType, view, paging, signal) {
|
|
1761
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1762
|
+
const result = await this.sdk.GetDocumentOutgoingRelationshipEdges({
|
|
1763
|
+
sourceIdentifier,
|
|
1764
|
+
relationshipType,
|
|
1765
|
+
view: viewInput,
|
|
1766
|
+
paging: pagingInputFromPaging(paging)
|
|
1767
|
+
}, void 0, signal);
|
|
1768
|
+
return this.toRelationshipResults(result.documentOutgoingRelationshipEdges, paging ?? defaultPaging, (cursor, limit) => this.getOutgoingRelationshipEdges(sourceIdentifier, relationshipType, view, {
|
|
1769
|
+
cursor,
|
|
1770
|
+
limit
|
|
1771
|
+
}, signal));
|
|
1772
|
+
}
|
|
1773
|
+
async getIncomingRelationshipEdges(targetIdentifier, relationshipType, view, paging, signal) {
|
|
1774
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1775
|
+
const result = await this.sdk.GetDocumentIncomingRelationshipEdges({
|
|
1776
|
+
targetIdentifier,
|
|
1777
|
+
relationshipType,
|
|
1778
|
+
view: viewInput,
|
|
1779
|
+
paging: pagingInputFromPaging(paging)
|
|
1780
|
+
}, void 0, signal);
|
|
1781
|
+
return this.toRelationshipResults(result.documentIncomingRelationshipEdges, paging ?? defaultPaging, (cursor, limit) => this.getIncomingRelationshipEdges(targetIdentifier, relationshipType, view, {
|
|
1782
|
+
cursor,
|
|
1783
|
+
limit
|
|
1784
|
+
}, signal));
|
|
1785
|
+
}
|
|
1456
1786
|
async create(document, parentIdentifier, signal) {
|
|
1457
1787
|
const created = phDocumentFromGetDocument((await this.sdk.CreateDocument({
|
|
1458
1788
|
document,
|
|
1459
1789
|
parentIdentifier
|
|
1460
|
-
},
|
|
1790
|
+
}, this.driveIdHeaders({
|
|
1791
|
+
method: "create",
|
|
1792
|
+
documentId: document.header.id || void 0,
|
|
1793
|
+
parentId: parentIdentifier
|
|
1794
|
+
}, isDrive(document) && parentIdentifier === void 0 ? document.header.id : void 0), signal)).createDocument);
|
|
1461
1795
|
this.emitChange({
|
|
1462
1796
|
type: DOCUMENT_CHANGE_TYPE.Created,
|
|
1463
1797
|
documents: [created]
|
|
@@ -1485,7 +1819,7 @@ var GraphQLReactorClient = class {
|
|
|
1485
1819
|
const document = await this.get(documentIdentifier, { branch }, signal);
|
|
1486
1820
|
const variables = {
|
|
1487
1821
|
documentIdentifier,
|
|
1488
|
-
actions: (await prepareActionsForPush(actions, document, this.documentModels, this.signer, signal)).map(toTransportAction),
|
|
1822
|
+
actions: (await prepareActionsForPush(actions, document, this.documentModels(), this.signer, signal)).map(toTransportAction),
|
|
1489
1823
|
sinceRevision: sinceRevisionForActions(document, actions),
|
|
1490
1824
|
scopes: scopesForActions(actions),
|
|
1491
1825
|
branch
|
|
@@ -1495,6 +1829,10 @@ var GraphQLReactorClient = class {
|
|
|
1495
1829
|
operationType: "mutation",
|
|
1496
1830
|
document: MutateDocumentWithOperationsDocument,
|
|
1497
1831
|
variables,
|
|
1832
|
+
requestHeaders: this.driveIdHeaders({
|
|
1833
|
+
method: "execute",
|
|
1834
|
+
documentId: documentIdentifier
|
|
1835
|
+
}, isDrive(document) ? document.header.id : void 0),
|
|
1498
1836
|
signal
|
|
1499
1837
|
})).mutateDocument;
|
|
1500
1838
|
const updated = phDocumentFromMutation(mutated, mutated.operations?.items ?? [], branch);
|
|
@@ -1505,6 +1843,210 @@ var GraphQLReactorClient = class {
|
|
|
1505
1843
|
return updated;
|
|
1506
1844
|
}
|
|
1507
1845
|
/**
|
|
1846
|
+
* Runs multiple mutation jobs in dependency order over the Switchboard's
|
|
1847
|
+
* `executeBatch` mutation and waits for all to settle, returning the result
|
|
1848
|
+
* shaped like `IReactor.executeBatch`'s so the reference `DriveClient`
|
|
1849
|
+
* consumes it unchanged.
|
|
1850
|
+
*
|
|
1851
|
+
* Not atomic: each job commits on its own and a failed job still releases
|
|
1852
|
+
* its dependents. A FAILED job throws {@link BatchJobFailedError}, naming the
|
|
1853
|
+
* first failed plan key and carrying every job's final state.
|
|
1854
|
+
*
|
|
1855
|
+
* Each job's actions are signed independently for the job's own
|
|
1856
|
+
* `(documentId, branch)` target -- the per-action signing the reactor's own
|
|
1857
|
+
* `signActions` does, not the batch state-prediction `execute` uses for a
|
|
1858
|
+
* multi-action push. A drive job such as `addFile`'s is `CREATE_DOCUMENT` +
|
|
1859
|
+
* `UPGRADE_DOCUMENT` + `ADD_RELATIONSHIP`, which the prediction path rejects
|
|
1860
|
+
* outright and which has no fetchable baseline to stamp against. The reactor
|
|
1861
|
+
* records but does not verify the stamped previous-state head, so signing
|
|
1862
|
+
* each action bare is exactly what the in-process `DriveClient` relies on.
|
|
1863
|
+
*
|
|
1864
|
+
* The mutation is synchronous server-side: a job it returns is already
|
|
1865
|
+
* settled, so {@link waitForJob} resolves from it without polling.
|
|
1866
|
+
*/
|
|
1867
|
+
async executeBatch(request, signal) {
|
|
1868
|
+
const signer = this.signer ?? resolveAmbientSigner();
|
|
1869
|
+
const jobInputs = await Promise.all(request.jobs.map(async (job, index) => {
|
|
1870
|
+
const documentId = await this.batchWriteTarget(job, request.jobs.slice(0, index), signer, signal);
|
|
1871
|
+
const actions = await this.signBatchJobActions({
|
|
1872
|
+
...job,
|
|
1873
|
+
documentId
|
|
1874
|
+
}, signer, signal);
|
|
1875
|
+
return {
|
|
1876
|
+
key: job.key,
|
|
1877
|
+
documentIdOrSlug: documentId,
|
|
1878
|
+
scope: job.scope,
|
|
1879
|
+
branch: job.branch,
|
|
1880
|
+
actions: actions.map(toTransportAction),
|
|
1881
|
+
dependsOn: job.dependsOn
|
|
1882
|
+
};
|
|
1883
|
+
}));
|
|
1884
|
+
const result = await this.sdk.ExecuteBatch({ jobs: jobInputs }, this.driveIdHeaders({
|
|
1885
|
+
method: "executeBatch",
|
|
1886
|
+
jobs: jobInputs.map((job) => ({ documentId: job.documentIdOrSlug }))
|
|
1887
|
+
}), signal);
|
|
1888
|
+
const jobs = {};
|
|
1889
|
+
for (const entry of result.executeBatch.jobs) jobs[entry.key] = jobInfoFromGql(entry.job);
|
|
1890
|
+
await this.announceBatch(request, jobs, signal);
|
|
1891
|
+
const failed = request.jobs.find((job) => jobs[job.key]?.status === "FAILED");
|
|
1892
|
+
if (failed) throw new BatchJobFailedError(failed.key, jobs);
|
|
1893
|
+
return { jobs };
|
|
1894
|
+
}
|
|
1895
|
+
/** The job as `jobStatus` reports it now; `undefined` when it reports none. */
|
|
1896
|
+
async getJob(jobId, signal) {
|
|
1897
|
+
const result = await this.sdk.GetJobStatus({ jobId }, void 0, signal);
|
|
1898
|
+
return result.jobStatus ? jobInfoFromGql(result.jobStatus) : void 0;
|
|
1899
|
+
}
|
|
1900
|
+
/** Polls `jobStatus` until the job is READ_READY or FAILED. */
|
|
1901
|
+
async waitForJob(jobOrId, signal) {
|
|
1902
|
+
if (typeof jobOrId !== "string" && isSettled(jobOrId)) return jobOrId;
|
|
1903
|
+
const jobId = typeof jobOrId === "string" ? jobOrId : jobOrId.id;
|
|
1904
|
+
for (;;) {
|
|
1905
|
+
const result = await this.sdk.GetJobStatus({ jobId }, void 0, signal);
|
|
1906
|
+
if (!result.jobStatus) throw new Error(`Job not found: ${jobId}`);
|
|
1907
|
+
const job = jobInfoFromGql(result.jobStatus);
|
|
1908
|
+
if (isSettled(job)) return job;
|
|
1909
|
+
await delay(JOB_POLL_INTERVAL_MS, signal);
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* The policy the Switchboard gives a new document, read from its
|
|
1914
|
+
* `createDefaults` query. A Switchboard without that query is refused with
|
|
1915
|
+
* {@link GraphQLOperationNotSupportedError}: a guessed default would
|
|
1916
|
+
* under-sign on a stricter host.
|
|
1917
|
+
*/
|
|
1918
|
+
async getCreateSignaturePolicy() {
|
|
1919
|
+
return (await this.createDefaults("getCreateSignaturePolicy")).signaturePolicy;
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* The protocol versions the Switchboard selects for a new document under
|
|
1923
|
+
* `parentIdentifier`, read from its `createDefaults` query. A parent the
|
|
1924
|
+
* caller may not read is refused by the server, never answered as if none
|
|
1925
|
+
* was named; a Switchboard without the query is refused with
|
|
1926
|
+
* {@link GraphQLOperationNotSupportedError}.
|
|
1927
|
+
*/
|
|
1928
|
+
async getCreateProtocolVersions(parentIdentifier, signal) {
|
|
1929
|
+
return (await this.createDefaults("getCreateProtocolVersions", parentIdentifier, signal)).protocolVersions;
|
|
1930
|
+
}
|
|
1931
|
+
async createDefaults(operation, parentIdOrSlug, signal) {
|
|
1932
|
+
let result;
|
|
1933
|
+
try {
|
|
1934
|
+
result = await this.sdk.GetCreateDefaults({ parentIdOrSlug }, void 0, signal);
|
|
1935
|
+
} catch (error) {
|
|
1936
|
+
if (queriesUnknownField(error, "createDefaults")) throw new GraphQLOperationNotSupportedError(operation, "the Switchboard predates the createDefaults query");
|
|
1937
|
+
throw error;
|
|
1938
|
+
}
|
|
1939
|
+
const { signaturePolicy, protocolVersions } = result.createDefaults;
|
|
1940
|
+
if (!isSignaturePolicy(signaturePolicy)) throw new Error(`The Switchboard answered an unknown create signature policy: ${signaturePolicy}`);
|
|
1941
|
+
return {
|
|
1942
|
+
signaturePolicy,
|
|
1943
|
+
protocolVersions: protocolVersionsFrom(protocolVersions)
|
|
1944
|
+
};
|
|
1945
|
+
}
|
|
1946
|
+
/**
|
|
1947
|
+
* Sets or, with `null`, clears the preferred editor as a client-signed
|
|
1948
|
+
* action, as the in-process client does.
|
|
1949
|
+
*/
|
|
1950
|
+
setPreferredEditor(documentIdentifier, preferredEditor, branch = "main", signal) {
|
|
1951
|
+
return this.execute(documentIdentifier, branch, [actions.setPreferredEditor(preferredEditor)], signal);
|
|
1952
|
+
}
|
|
1953
|
+
/** The `Drive-Id` header for a call: the client's own proof, else the hook's. */
|
|
1954
|
+
driveIdHeaders(call, proven) {
|
|
1955
|
+
const hinted = this.driveIdFor?.(call);
|
|
1956
|
+
if (proven) {
|
|
1957
|
+
if (hinted && hinted !== proven) logger.warn("GraphQLReactorClient: driveIdFor named @hinted for @method, which belongs to drive @proven; sending the proven drive", hinted, call.method, proven);
|
|
1958
|
+
return driveIdHeaders(proven);
|
|
1959
|
+
}
|
|
1960
|
+
return hinted ? driveIdHeaders(hinted) : void 0;
|
|
1961
|
+
}
|
|
1962
|
+
/**
|
|
1963
|
+
* Emits the changes the batch's settled jobs made, as `create` and `execute`
|
|
1964
|
+
* do, so a cache is invalidated without a realtime socket. The documents a
|
|
1965
|
+
* job wrote to are its own and those its consistency token names.
|
|
1966
|
+
*/
|
|
1967
|
+
async announceBatch(request, jobs, signal) {
|
|
1968
|
+
if (this.listeners.length === 0) return;
|
|
1969
|
+
const deleted = /* @__PURE__ */ new Set();
|
|
1970
|
+
const created = /* @__PURE__ */ new Map();
|
|
1971
|
+
const touched = /* @__PURE__ */ new Map();
|
|
1972
|
+
const keyOf = (written) => `${written.branch}\u0000${written.documentId}`;
|
|
1973
|
+
for (const job of request.jobs) {
|
|
1974
|
+
const info = jobs[job.key];
|
|
1975
|
+
if (!info || info.status !== "READ_READY") continue;
|
|
1976
|
+
const types = new Set(job.actions.map((action) => action.type));
|
|
1977
|
+
if (types.has("DELETE_DOCUMENT")) {
|
|
1978
|
+
deleted.add(info.documentId);
|
|
1979
|
+
continue;
|
|
1980
|
+
}
|
|
1981
|
+
const own = {
|
|
1982
|
+
documentId: info.documentId,
|
|
1983
|
+
branch: job.branch
|
|
1984
|
+
};
|
|
1985
|
+
if (types.has("CREATE_DOCUMENT")) created.set(keyOf(own), own);
|
|
1986
|
+
touched.set(keyOf(own), own);
|
|
1987
|
+
for (const { documentId, branch } of info.consistencyToken.coordinates) touched.set(keyOf({
|
|
1988
|
+
documentId,
|
|
1989
|
+
branch
|
|
1990
|
+
}), {
|
|
1991
|
+
documentId,
|
|
1992
|
+
branch
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
for (const documentId of deleted) this.emitChange({
|
|
1996
|
+
type: DOCUMENT_CHANGE_TYPE.Deleted,
|
|
1997
|
+
documents: [],
|
|
1998
|
+
context: { childId: documentId }
|
|
1999
|
+
});
|
|
2000
|
+
const read = async ({ documentId, branch }) => {
|
|
2001
|
+
try {
|
|
2002
|
+
return await this.get(documentId, { branch }, signal);
|
|
2003
|
+
} catch (error) {
|
|
2004
|
+
logger.warn("GraphQLReactorClient: could not read @documentId on @branch to announce a batch change: @error", documentId, branch, error);
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
2007
|
+
};
|
|
2008
|
+
const readAll = async (written) => (await Promise.all(written.map(read))).filter((document) => document !== void 0);
|
|
2009
|
+
const [createdDocuments, updatedDocuments] = await Promise.all([readAll([...created.values()].filter((w) => !deleted.has(w.documentId))), readAll([...touched.entries()].filter(([key, w]) => !deleted.has(w.documentId) && !created.has(key)).map(([, w]) => w))]);
|
|
2010
|
+
if (createdDocuments.length > 0) this.emitChange({
|
|
2011
|
+
type: DOCUMENT_CHANGE_TYPE.Created,
|
|
2012
|
+
documents: createdDocuments
|
|
2013
|
+
});
|
|
2014
|
+
if (updatedDocuments.length > 0) this.emitChange({
|
|
2015
|
+
type: DOCUMENT_CHANGE_TYPE.Updated,
|
|
2016
|
+
documents: updatedDocuments
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
2019
|
+
/**
|
|
2020
|
+
* The id a job's actions are signed for: a signature covers the document id,
|
|
2021
|
+
* and the server resolves a slug before verifying. A document created by this
|
|
2022
|
+
* job or an earlier one is named by its id. When the server has no such
|
|
2023
|
+
* document the identifier is used as given, and the server decides; any
|
|
2024
|
+
* other failure to read it throws, so nothing is signed for a slug.
|
|
2025
|
+
*/
|
|
2026
|
+
async batchWriteTarget(job, earlier, signer, signal) {
|
|
2027
|
+
const creates = (plan) => plan.documentId === job.documentId && plan.actions.some((action) => action.type === "CREATE_DOCUMENT");
|
|
2028
|
+
if (!signer || job.actions.every(isActionSigned) || creates(job) || earlier.some(creates)) return job.documentId;
|
|
2029
|
+
return (await this.sdk.GetDocument({
|
|
2030
|
+
identifier: job.documentId,
|
|
2031
|
+
view: viewFilterInputFromViewFilter({ branch: job.branch })
|
|
2032
|
+
}, void 0, signal)).document?.document.id ?? job.documentId;
|
|
2033
|
+
}
|
|
2034
|
+
/**
|
|
2035
|
+
* Signs one batch job's actions for the job's own log.
|
|
2036
|
+
*
|
|
2037
|
+
* Each action is signed on its own for `(documentId, branch)`, the same
|
|
2038
|
+
* per-action signing the reactor's `signActions` does: no state prediction
|
|
2039
|
+
* across the job, so a job carrying a `CREATE_DOCUMENT` the push-prediction
|
|
2040
|
+
* path rejects still signs. An action already signed under a key is left
|
|
2041
|
+
* as it is: the reference `DriveClient` signs its jobs before handing them
|
|
2042
|
+
* here. With no signer the actions pass through unsigned, matching
|
|
2043
|
+
* {@link execute}.
|
|
2044
|
+
*/
|
|
2045
|
+
async signBatchJobActions(job, signer, signal) {
|
|
2046
|
+
if (!signer) return job.actions;
|
|
2047
|
+
return Promise.all(job.actions.map((action) => isActionSigned(action) ? Promise.resolve(action) : signStampedAction(action, signer, actionSigningTarget(action, job.documentId, job.branch), signal)));
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
1508
2050
|
* Deletes a document and announces it as a `Deleted` event.
|
|
1509
2051
|
*
|
|
1510
2052
|
* Pass a document id. The server resolves a slug just as happily, but
|
|
@@ -1517,7 +2059,10 @@ var GraphQLReactorClient = class {
|
|
|
1517
2059
|
await this.sdk.DeleteDocument({
|
|
1518
2060
|
identifier,
|
|
1519
2061
|
propagate: propagationModeInput(propagate)
|
|
1520
|
-
},
|
|
2062
|
+
}, this.driveIdHeaders({
|
|
2063
|
+
method: "deleteDocument",
|
|
2064
|
+
documentId: identifier
|
|
2065
|
+
}), signal);
|
|
1521
2066
|
this.emitChange({
|
|
1522
2067
|
type: DOCUMENT_CHANGE_TYPE.Deleted,
|
|
1523
2068
|
documents: [],
|
|
@@ -1613,6 +2158,35 @@ var GraphQLReactorClient = class {
|
|
|
1613
2158
|
});
|
|
1614
2159
|
}
|
|
1615
2160
|
/**
|
|
2161
|
+
* Shapes a document result page into the reactor's {@link PagedResults}.
|
|
2162
|
+
*
|
|
2163
|
+
* The items carry the same `PHDocumentFields` fragment as `get`, so the same
|
|
2164
|
+
* adapter rebuilds each one. `hasNextPage` gates the cursor exactly as
|
|
2165
|
+
* `getOperations` does: no cursor means no `next`.
|
|
2166
|
+
*/
|
|
2167
|
+
toDocumentResults(page, effectivePaging, branch, next) {
|
|
2168
|
+
const nextCursor = page.hasNextPage ? page.cursor ?? void 0 : void 0;
|
|
2169
|
+
return {
|
|
2170
|
+
results: page.items.map((item) => phDocumentFromGetDocument(item, branch)),
|
|
2171
|
+
options: effectivePaging,
|
|
2172
|
+
nextCursor,
|
|
2173
|
+
next: nextCursor ? () => next(nextCursor, effectivePaging.limit) : void 0
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
/**
|
|
2177
|
+
* Shapes a relationship-edge result page into the reactor's
|
|
2178
|
+
* {@link PagedResults}, restoring each edge's `Date` fields.
|
|
2179
|
+
*/
|
|
2180
|
+
toRelationshipResults(page, effectivePaging, next) {
|
|
2181
|
+
const nextCursor = page.hasNextPage ? page.cursor ?? void 0 : void 0;
|
|
2182
|
+
return {
|
|
2183
|
+
results: page.items.map((edge) => documentRelationshipFromEdge(edge)),
|
|
2184
|
+
options: effectivePaging,
|
|
2185
|
+
nextCursor,
|
|
2186
|
+
next: nextCursor ? () => next(nextCursor, effectivePaging.limit) : void 0
|
|
2187
|
+
};
|
|
2188
|
+
}
|
|
2189
|
+
/**
|
|
1616
2190
|
* Opens the realtime socket on the first subscriber.
|
|
1617
2191
|
*
|
|
1618
2192
|
* The subscription is a firehose - no `search` argument - and this client
|
|
@@ -1743,13 +2317,13 @@ function isGraphQLReactorClient(client) {
|
|
|
1743
2317
|
}
|
|
1744
2318
|
/** The schema's change types, mapped onto the reactor's. */
|
|
1745
2319
|
const documentChangeTypes = {
|
|
1746
|
-
[
|
|
1747
|
-
[
|
|
1748
|
-
[
|
|
1749
|
-
[
|
|
1750
|
-
[
|
|
1751
|
-
[
|
|
1752
|
-
[
|
|
2320
|
+
["CREATED"]: DOCUMENT_CHANGE_TYPE.Created,
|
|
2321
|
+
["DELETED"]: DOCUMENT_CHANGE_TYPE.Deleted,
|
|
2322
|
+
["UPDATED"]: DOCUMENT_CHANGE_TYPE.Updated,
|
|
2323
|
+
["PARENT_ADDED"]: DOCUMENT_CHANGE_TYPE.ParentAdded,
|
|
2324
|
+
["PARENT_REMOVED"]: DOCUMENT_CHANGE_TYPE.ParentRemoved,
|
|
2325
|
+
["CHILD_ADDED"]: DOCUMENT_CHANGE_TYPE.ChildAdded,
|
|
2326
|
+
["CHILD_REMOVED"]: DOCUMENT_CHANGE_TYPE.ChildRemoved
|
|
1753
2327
|
};
|
|
1754
2328
|
/**
|
|
1755
2329
|
* Decides whether an event reaches a subscriber.
|
|
@@ -1784,7 +2358,7 @@ function eventMatchesSearch(event, search) {
|
|
|
1784
2358
|
*/
|
|
1785
2359
|
function viewFilterInputFromViewFilter(view) {
|
|
1786
2360
|
if (!view) return;
|
|
1787
|
-
if (view
|
|
2361
|
+
if (viewIsPointInTime(view)) throw new GraphQLOperationNotSupportedError("view", "point-in-time views are not supported by GraphQLReactorClient");
|
|
1788
2362
|
if (view.branch === void 0 && view.scopes === void 0) return;
|
|
1789
2363
|
return {
|
|
1790
2364
|
branch: view.branch,
|
|
@@ -1799,13 +2373,78 @@ function pagingInputFromPaging(paging) {
|
|
|
1799
2373
|
};
|
|
1800
2374
|
}
|
|
1801
2375
|
/**
|
|
2376
|
+
* Whether a search names `ids` or `slugs`, which the Switchboard `findDocuments`
|
|
2377
|
+
* query cannot honour (it filters by `type` and `parentId`).
|
|
2378
|
+
*
|
|
2379
|
+
* The test is PRESENCE, not length: the reactor `find` contract
|
|
2380
|
+
* (`packages/reactor/src/core/reactor.ts`) dispatches on `search.ids` /
|
|
2381
|
+
* `search.slugs` being present, so `find({ ids: [] })` is an identifier search
|
|
2382
|
+
* that must yield the empty set -- not a plain type query over every document.
|
|
2383
|
+
* The GraphQL surface cannot express an identifier search at all, so a present
|
|
2384
|
+
* (even empty) `ids`/`slugs` is refused rather than served as the wrong query.
|
|
2385
|
+
*/
|
|
2386
|
+
function searchNamesIdentifiers(search) {
|
|
2387
|
+
return search.ids !== void 0 || search.slugs !== void 0;
|
|
2388
|
+
}
|
|
2389
|
+
/** Whether a view asks for a point-in-time read the GraphQL surface cannot express. */
|
|
2390
|
+
function viewIsPointInTime(view) {
|
|
2391
|
+
return view?.revision !== void 0;
|
|
2392
|
+
}
|
|
2393
|
+
/**
|
|
2394
|
+
* The single source of truth for whether the Switchboard `findDocuments` query
|
|
2395
|
+
* can serve a `find`. It is servable iff the search names neither `ids` nor
|
|
2396
|
+
* `slugs` (present, regardless of length) AND the view is not point-in-time:
|
|
2397
|
+
* each is a by-contract limitation of a surface that filters only by
|
|
2398
|
+
* `type`/`parentId` at head. Exported so a caller can route around an
|
|
2399
|
+
* unservable search instead of catching the error `find` throws for it.
|
|
2400
|
+
*/
|
|
2401
|
+
function findIsServableOverGraphQL(search, view) {
|
|
2402
|
+
return !searchNamesIdentifiers(search) && !viewIsPointInTime(view);
|
|
2403
|
+
}
|
|
2404
|
+
/** Rebuilds a relationship edge from its GraphQL fields. */
|
|
2405
|
+
function documentRelationshipFromEdge(edge) {
|
|
2406
|
+
const relationship = {
|
|
2407
|
+
sourceId: edge.sourceId,
|
|
2408
|
+
targetId: edge.targetId,
|
|
2409
|
+
relationshipType: edge.relationshipType,
|
|
2410
|
+
createdAt: dateFromDateTime(edge.createdAt),
|
|
2411
|
+
updatedAt: dateFromDateTime(edge.updatedAt)
|
|
2412
|
+
};
|
|
2413
|
+
const metadata = edge.metadata;
|
|
2414
|
+
if (isPlainObject(metadata)) relationship.metadata = metadata;
|
|
2415
|
+
return relationship;
|
|
2416
|
+
}
|
|
2417
|
+
/**
|
|
2418
|
+
* Restores a `Date` from the `DateTime` scalar, which deserializes as either an
|
|
2419
|
+
* ISO string or a `Date`, reusing the get-path's {@link isoStringFromDateTime}.
|
|
2420
|
+
*
|
|
2421
|
+
* A null, absent or unparseable value is a malformed timestamp from the server,
|
|
2422
|
+
* not something to coerce to the epoch or an `Invalid Date`: it throws, so the
|
|
2423
|
+
* malformed edge surfaces as a genuine failure rather than a silently-wrong
|
|
2424
|
+
* `DocumentRelationship`.
|
|
2425
|
+
*/
|
|
2426
|
+
function dateFromDateTime(value) {
|
|
2427
|
+
if (value === null || value === void 0) throw new Error("relationship edge is missing a required DateTime timestamp");
|
|
2428
|
+
const date = new Date(isoStringFromDateTime(value));
|
|
2429
|
+
if (Number.isNaN(date.getTime())) throw new Error(`relationship edge carries an unparseable DateTime timestamp: ${String(value)}`);
|
|
2430
|
+
return date;
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Whether a JSON value is a plain object, so relationship `metadata` is assigned
|
|
2434
|
+
* only when it is one. A non-object JSON scalar (string, number, array, null)
|
|
2435
|
+
* is dropped exactly as a null is, rather than cast to `Record` and trusted.
|
|
2436
|
+
*/
|
|
2437
|
+
function isPlainObject(value) {
|
|
2438
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2439
|
+
}
|
|
2440
|
+
/**
|
|
1802
2441
|
* The reactor and the GraphQL schema disagree on the enum: the reactor's
|
|
1803
2442
|
* `None` is the schema's `ORPHAN`. This is the inverse of the server's
|
|
1804
2443
|
* `toReactorPropagationMode`.
|
|
1805
2444
|
*/
|
|
1806
2445
|
const propagationModeInputs = {
|
|
1807
|
-
cascade:
|
|
1808
|
-
none:
|
|
2446
|
+
cascade: "CASCADE",
|
|
2447
|
+
none: "ORPHAN"
|
|
1809
2448
|
};
|
|
1810
2449
|
function propagationModeInput(propagate) {
|
|
1811
2450
|
return propagate === void 0 ? void 0 : propagationModeInputs[propagate];
|
|
@@ -1841,10 +2480,127 @@ function documentModelVersion(document) {
|
|
|
1841
2480
|
const documentScope = document.state.document;
|
|
1842
2481
|
return normalizeDocumentModelVersion(documentScope?.version);
|
|
1843
2482
|
}
|
|
2483
|
+
/**
|
|
2484
|
+
* Rebuilds a reactor {@link JobInfo} from what the server reported. An unknown
|
|
2485
|
+
* job arrives as the reactor's own: FAILED with an empty `documentId`.
|
|
2486
|
+
*/
|
|
2487
|
+
function jobInfoFromGql(job) {
|
|
2488
|
+
const token = job.consistencyToken;
|
|
2489
|
+
if (token.version !== 1) throw new Error(`Job ${job.id} carries consistency token version ${token.version}, which this client cannot read`);
|
|
2490
|
+
const info = {
|
|
2491
|
+
id: job.id,
|
|
2492
|
+
documentId: job.documentId,
|
|
2493
|
+
status: job.status,
|
|
2494
|
+
createdAtUtcIso: isoStringFromDateTime(job.createdAt),
|
|
2495
|
+
consistencyToken: {
|
|
2496
|
+
version: 1,
|
|
2497
|
+
createdAtUtcIso: token.createdAtUtcIso,
|
|
2498
|
+
coordinates: token.coordinates.map((coordinate) => ({ ...coordinate }))
|
|
2499
|
+
},
|
|
2500
|
+
meta: {
|
|
2501
|
+
batchId: job.meta.batchId,
|
|
2502
|
+
batchJobIds: [...job.meta.batchJobIds]
|
|
2503
|
+
}
|
|
2504
|
+
};
|
|
2505
|
+
if (job.completedAt != null) info.completedAtUtcIso = isoStringFromDateTime(job.completedAt);
|
|
2506
|
+
if (job.result != null) info.result = job.result;
|
|
2507
|
+
if (job.error != null) info.error = {
|
|
2508
|
+
name: job.errorName ?? "Error",
|
|
2509
|
+
message: job.error,
|
|
2510
|
+
stack: ""
|
|
2511
|
+
};
|
|
2512
|
+
return info;
|
|
2513
|
+
}
|
|
2514
|
+
/**
|
|
2515
|
+
* Whether a request failed because the server's schema has no such root field:
|
|
2516
|
+
* a Switchboard older than the field. graphql-js validation words this the same
|
|
2517
|
+
* under every gateway the Switchboard can run.
|
|
2518
|
+
*/
|
|
2519
|
+
function queriesUnknownField(error, field) {
|
|
2520
|
+
const errors = error?.response?.errors;
|
|
2521
|
+
if (!Array.isArray(errors)) return false;
|
|
2522
|
+
const prefix = `Cannot query field "${field}" on type "`;
|
|
2523
|
+
return errors.some((entry) => typeof entry?.message === "string" && entry.message.startsWith(prefix));
|
|
2524
|
+
}
|
|
2525
|
+
/**
|
|
2526
|
+
* The header a Switchboard's drive middleware and load balancer key on. A
|
|
2527
|
+
* request carries it only when it is known to belong to that one drive: the
|
|
2528
|
+
* server answers any drive it does not own with 421.
|
|
2529
|
+
*/
|
|
2530
|
+
const DRIVE_ID_HEADER = "Drive-Id";
|
|
2531
|
+
function driveIdHeaders(driveId) {
|
|
2532
|
+
return driveId === "" ? void 0 : { [DRIVE_ID_HEADER]: driveId };
|
|
2533
|
+
}
|
|
2534
|
+
function isDrive(document) {
|
|
2535
|
+
return DRIVE_DOCUMENT_TYPES.includes(document.header.documentType);
|
|
2536
|
+
}
|
|
2537
|
+
/**
|
|
2538
|
+
* Surfaces a 421 from the Switchboard's drive middleware, which graphql-request
|
|
2539
|
+
* reports as a `ClientError`, as {@link GraphQLWrongBackendError}.
|
|
2540
|
+
*/
|
|
2541
|
+
function withWrongBackendErrors(middleware) {
|
|
2542
|
+
return async (action, ...rest) => {
|
|
2543
|
+
try {
|
|
2544
|
+
return await middleware(action, ...rest);
|
|
2545
|
+
} catch (error) {
|
|
2546
|
+
throw wrongBackendErrorOf(error) ?? error;
|
|
2547
|
+
}
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
function wrongBackendErrorOf(error) {
|
|
2551
|
+
const response = error?.response;
|
|
2552
|
+
if (response?.status !== 421) return;
|
|
2553
|
+
let payload = response.body;
|
|
2554
|
+
if (typeof payload === "string") try {
|
|
2555
|
+
payload = JSON.parse(payload);
|
|
2556
|
+
} catch {}
|
|
2557
|
+
const driveId = payload?.driveId;
|
|
2558
|
+
return new GraphQLWrongBackendError(typeof driveId === "string" ? driveId : "", payload, { cause: error });
|
|
2559
|
+
}
|
|
2560
|
+
/** Protocol versions as the server sent them; anything but a version map throws. */
|
|
2561
|
+
function protocolVersionsFrom(value) {
|
|
2562
|
+
if (!isPlainObject(value)) throw new Error("The Switchboard answered malformed create protocol versions");
|
|
2563
|
+
const versions = {};
|
|
2564
|
+
for (const [protocol, version] of Object.entries(value)) {
|
|
2565
|
+
if (typeof version !== "number" || !Number.isInteger(version)) throw new Error(`The Switchboard answered a malformed version for protocol ${protocol}`);
|
|
2566
|
+
versions[protocol] = version;
|
|
2567
|
+
}
|
|
2568
|
+
return versions;
|
|
2569
|
+
}
|
|
2570
|
+
function isSettled(job) {
|
|
2571
|
+
const status = job.status;
|
|
2572
|
+
return status === "READ_READY" || status === "FAILED";
|
|
2573
|
+
}
|
|
2574
|
+
function abortReason(signal) {
|
|
2575
|
+
const reason = signal.reason;
|
|
2576
|
+
return reason instanceof Error ? reason : new Error(String(reason));
|
|
2577
|
+
}
|
|
2578
|
+
function delay(ms, signal) {
|
|
2579
|
+
return new Promise((resolve, reject) => {
|
|
2580
|
+
if (signal?.aborted) {
|
|
2581
|
+
reject(abortReason(signal));
|
|
2582
|
+
return;
|
|
2583
|
+
}
|
|
2584
|
+
const onAbort = () => {
|
|
2585
|
+
clearTimeout(timer);
|
|
2586
|
+
if (signal) reject(abortReason(signal));
|
|
2587
|
+
};
|
|
2588
|
+
const timer = setTimeout(() => {
|
|
2589
|
+
signal?.removeEventListener("abort", onAbort);
|
|
2590
|
+
resolve();
|
|
2591
|
+
}, ms);
|
|
2592
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
2593
|
+
});
|
|
2594
|
+
}
|
|
2595
|
+
/** As the reactor's `signAction` reads it: the last tuple names a key. */
|
|
2596
|
+
function isActionSigned(action) {
|
|
2597
|
+
const signer = action.context?.signer;
|
|
2598
|
+
return Boolean(signer?.app?.key && signer.signatures.at(-1)?.[1]);
|
|
2599
|
+
}
|
|
1844
2600
|
/** Resolves the signer of the logged-in user, if there is one. */
|
|
1845
2601
|
function resolveAmbientSigner() {
|
|
1846
2602
|
if (typeof window === "undefined") return;
|
|
1847
|
-
const renown =
|
|
2603
|
+
const renown = getPHStore()?.renown;
|
|
1848
2604
|
return renown?.user ? renown.signer : void 0;
|
|
1849
2605
|
}
|
|
1850
2606
|
/**
|
|
@@ -2265,51 +3021,46 @@ const usePackageDiscoveryService = packageDiscoveryFunctions.useValue;
|
|
|
2265
3021
|
const setPackageDiscoveryService = packageDiscoveryFunctions.setValue;
|
|
2266
3022
|
const addPackageDiscoveryServiceEventHandler = packageDiscoveryFunctions.addEventHandler;
|
|
2267
3023
|
//#endregion
|
|
2268
|
-
//#region src/hooks/
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
const
|
|
2273
|
-
|
|
2274
|
-
const
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
const
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
const
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
}
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
}
|
|
2309
|
-
/** Hides the revision history */
|
|
2310
|
-
function hideRevisionHistory() {
|
|
2311
|
-
setRevisionHistoryVisible(false);
|
|
2312
|
-
}
|
|
3024
|
+
//#region src/hooks/sync-selection.ts
|
|
3025
|
+
/** Applies a path's selection without writing the URL; idempotent.
|
|
3026
|
+
* @deprecated Set the store's `navigation`; its route loaders write the selection. */
|
|
3027
|
+
function syncSelectionFromPath(pathname = getCurrentPathname()) {
|
|
3028
|
+
const drives = getPHStore()?.drives;
|
|
3029
|
+
if (!drives) return;
|
|
3030
|
+
const driveSlug = extractDriveSlugFromPath(pathname);
|
|
3031
|
+
const selectedDriveId = getPHStore()?.selectedDriveId;
|
|
3032
|
+
if (!driveSlug) {
|
|
3033
|
+
if (selectedDriveId) selectDrive(void 0);
|
|
3034
|
+
return;
|
|
3035
|
+
}
|
|
3036
|
+
const drive = findDriveBySlug(drives, driveSlug);
|
|
3037
|
+
const selectedIsUnlisted = !!selectedDriveId && !drives.some((d) => d.header.id === selectedDriveId);
|
|
3038
|
+
if (drive) {
|
|
3039
|
+
if (drive.header.id !== selectedDriveId) setSelectedDriveId(drive.header.id);
|
|
3040
|
+
} else if (!selectedIsUnlisted) {
|
|
3041
|
+
selectDrive(driveSlug);
|
|
3042
|
+
return;
|
|
3043
|
+
}
|
|
3044
|
+
const nodeId = extractNodeIdFromSlug(extractNodeSlugFromPath(pathname));
|
|
3045
|
+
if (nodeId !== getPHStore()?.selectedNodeId) setSelectedNodeId(nodeId);
|
|
3046
|
+
}
|
|
3047
|
+
setBrowserOpenSync(() => syncSelectionFromPath());
|
|
3048
|
+
function syncOnPopState() {
|
|
3049
|
+
if (hasHostNavigation()) return;
|
|
3050
|
+
syncSelectionFromPath(window.location.pathname);
|
|
3051
|
+
}
|
|
3052
|
+
let popStateHandlerAdded = false;
|
|
3053
|
+
/** Syncs the selection on back/forward when no host navigation is set.
|
|
3054
|
+
* @deprecated Set the store's `navigation`; its router handles back/forward. */
|
|
3055
|
+
function addSyncSelectionOnPopStateEventHandler() {
|
|
3056
|
+
if (popStateHandlerAdded) return;
|
|
3057
|
+
popStateHandlerAdded = true;
|
|
3058
|
+
window.addEventListener("popstate", syncOnPopState);
|
|
3059
|
+
}
|
|
3060
|
+
/** @deprecated Set the store's `navigation`; its router handles back/forward. */
|
|
3061
|
+
const addSetSelectedDriveOnPopStateEventHandler = addSyncSelectionOnPopStateEventHandler;
|
|
3062
|
+
/** @deprecated Set the store's `navigation`; its router handles back/forward. */
|
|
3063
|
+
const addSetSelectedNodeOnPopStateEventHandler = addSyncSelectionOnPopStateEventHandler;
|
|
2313
3064
|
//#endregion
|
|
2314
3065
|
//#region src/hooks/selected-timeline-item.ts
|
|
2315
3066
|
const selectedTimelineItemEventFunctions = makePHEventFunctions("selectedTimelineItem");
|
|
@@ -2344,12 +3095,11 @@ const commonGlobalEventHandlerFunctions = {
|
|
|
2344
3095
|
drives: addDrivesEventHandler,
|
|
2345
3096
|
selectedDriveId: () => {
|
|
2346
3097
|
addSelectedDriveIdEventHandler();
|
|
2347
|
-
|
|
3098
|
+
addSyncSelectionOnPopStateEventHandler();
|
|
2348
3099
|
addResetSelectedNodeEventHandler();
|
|
2349
3100
|
},
|
|
2350
3101
|
selectedNodeId: () => {
|
|
2351
3102
|
addSelectedNodeIdEventHandler();
|
|
2352
|
-
addSetSelectedNodeOnPopStateEventHandler();
|
|
2353
3103
|
},
|
|
2354
3104
|
documentCache: addDocumentCacheEventHandler,
|
|
2355
3105
|
reactorGraphQLClient: addGraphQLReactorClientEventHandler,
|
|
@@ -2359,6 +3109,7 @@ const phGlobalEventHandlerRegisterFunctions = {
|
|
|
2359
3109
|
...commonGlobalEventHandlerFunctions,
|
|
2360
3110
|
reactorClientModule: addReactorClientModuleEventHandler,
|
|
2361
3111
|
reactorClient: addReactorClientEventHandler,
|
|
3112
|
+
fullReactorClient: addFullReactorClientEventHandler,
|
|
2362
3113
|
attachmentService: addAttachmentServiceEventHandler,
|
|
2363
3114
|
features: addFeaturesEventHandler,
|
|
2364
3115
|
modal: addModalEventHandler,
|
|
@@ -2366,7 +3117,6 @@ const phGlobalEventHandlerRegisterFunctions = {
|
|
|
2366
3117
|
vetraPackageManager: addVetraPackageManagerEventHandler,
|
|
2367
3118
|
packageDiscoveryService: addPackageDiscoveryServiceEventHandler,
|
|
2368
3119
|
selectedTimelineRevision: addSelectedTimelineRevisionEventHandler,
|
|
2369
|
-
revisionHistoryVisible: addRevisionHistoryVisibleEventHandler,
|
|
2370
3120
|
selectedTimelineItem: addSelectedTimelineItemEventHandler,
|
|
2371
3121
|
routerBasename: addRouterBasenameEventHandler,
|
|
2372
3122
|
version: addVersionEventHandler,
|
|
@@ -2419,7 +3169,8 @@ const phGlobalEventHandlerRegisterFunctions = {
|
|
|
2419
3169
|
isSentryTracingEnabled: addIsSentryTracingEnabledEventHandler,
|
|
2420
3170
|
isExternalProcessorsEnabled: addIsExternalProcessorsEnabledEventHandler,
|
|
2421
3171
|
isExternalPackagesEnabled: addIsExternalPackagesEnabledEventHandler,
|
|
2422
|
-
toast: addToastEventHandler
|
|
3172
|
+
toast: addToastEventHandler,
|
|
3173
|
+
navigation: () => {}
|
|
2423
3174
|
};
|
|
2424
3175
|
function addPHEventHandlers() {
|
|
2425
3176
|
callEventHandlerRegisterFunctions(phGlobalEventHandlerRegisterFunctions);
|
|
@@ -2515,89 +3266,92 @@ function useSwitchboardClient() {
|
|
|
2515
3266
|
}
|
|
2516
3267
|
//#endregion
|
|
2517
3268
|
//#region src/hooks/document-operations.ts
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
const
|
|
2527
|
-
const
|
|
2528
|
-
const
|
|
2529
|
-
|
|
2530
|
-
localOperations: [],
|
|
2531
|
-
isLoading: !!documentId,
|
|
2532
|
-
error: void 0
|
|
2533
|
-
}));
|
|
2534
|
-
const fetchOperations = useCallback(async (retryCount = 0) => {
|
|
2535
|
-
const MAX_RETRIES = 5;
|
|
2536
|
-
const RETRY_DELAY_MS = 500;
|
|
2537
|
-
if (!documentId || !reactorClient) {
|
|
2538
|
-
setState({
|
|
2539
|
-
globalOperations: [],
|
|
2540
|
-
localOperations: [],
|
|
2541
|
-
isLoading: false,
|
|
2542
|
-
error: void 0
|
|
2543
|
-
});
|
|
2544
|
-
return;
|
|
2545
|
-
}
|
|
2546
|
-
setState((prev) => ({
|
|
2547
|
-
...prev,
|
|
2548
|
-
isLoading: true,
|
|
2549
|
-
error: void 0
|
|
2550
|
-
}));
|
|
2551
|
-
let globalOps = [];
|
|
2552
|
-
let localOps = [];
|
|
2553
|
-
let fetchError;
|
|
2554
|
-
try {
|
|
2555
|
-
globalOps = (await reactorClient.getOperations(documentId, { scopes: ["global"] })).results;
|
|
2556
|
-
} catch (err) {
|
|
2557
|
-
fetchError = err instanceof Error ? err : new Error(String(err));
|
|
2558
|
-
}
|
|
2559
|
-
if (!fetchError) try {
|
|
2560
|
-
localOps = (await reactorClient.getOperations(documentId, { scopes: ["local"] })).results;
|
|
2561
|
-
} catch (err) {
|
|
2562
|
-
fetchError = err instanceof Error ? err : new Error(String(err));
|
|
2563
|
-
}
|
|
2564
|
-
if (!fetchError && globalOps.length === 0 && localOps.length === 0 && retryCount < MAX_RETRIES) {
|
|
2565
|
-
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
|
|
2566
|
-
return fetchOperations(retryCount + 1);
|
|
2567
|
-
}
|
|
2568
|
-
setState({
|
|
2569
|
-
globalOperations: globalOps,
|
|
2570
|
-
localOperations: localOps,
|
|
2571
|
-
isLoading: false,
|
|
2572
|
-
error: fetchError
|
|
2573
|
-
});
|
|
2574
|
-
hasFetchedRef.current = true;
|
|
2575
|
-
}, [documentId, reactorClient]);
|
|
3269
|
+
const DEFAULT_LIMIT = 100;
|
|
3270
|
+
function toError(reason) {
|
|
3271
|
+
return reason instanceof Error ? reason : new Error(String(reason));
|
|
3272
|
+
}
|
|
3273
|
+
const EMPTY_OPERATIONS = [];
|
|
3274
|
+
function useScopeOperations(documentId, scope, options = {}) {
|
|
3275
|
+
const { limit = DEFAULT_LIMIT, enabled = true } = options;
|
|
3276
|
+
const documentCache = useDocumentCache();
|
|
3277
|
+
const cache = documentCache && isOperationCache(documentCache) ? documentCache : void 0;
|
|
3278
|
+
const activeId = enabled && cache && documentId ? documentId : void 0;
|
|
3279
|
+
const getEntry = () => activeId && cache ? cache.getOperationsState(activeId, scope) : IDLE_OPERATIONS_ENTRY;
|
|
3280
|
+
const entry = useSyncExternalStore((onChange) => activeId && cache ? cache.subscribeOperations(activeId, onChange) : () => {}, getEntry, getEntry);
|
|
2576
3281
|
useEffect(() => {
|
|
2577
|
-
if (
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
3282
|
+
if (activeId && cache && entry.status === "idle") cache.loadOperations(activeId, scope, limit);
|
|
3283
|
+
}, [
|
|
3284
|
+
activeId,
|
|
3285
|
+
cache,
|
|
3286
|
+
scope,
|
|
3287
|
+
limit,
|
|
3288
|
+
entry.status
|
|
3289
|
+
]);
|
|
3290
|
+
const fetchNextPage = useCallback(() => {
|
|
3291
|
+
if (activeId && cache) cache.loadMoreOperations(activeId, scope);
|
|
2587
3292
|
}, [
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
3293
|
+
activeId,
|
|
3294
|
+
cache,
|
|
3295
|
+
scope
|
|
2591
3296
|
]);
|
|
2592
3297
|
const refetch = useCallback(() => {
|
|
2593
|
-
|
|
2594
|
-
}, [
|
|
3298
|
+
if (activeId && cache) cache.invalidateOperations(activeId);
|
|
3299
|
+
}, [activeId, cache]);
|
|
3300
|
+
const error = useMemo(() => entry.status === "error" ? toError(entry.error) : void 0, [entry.status, entry.error]);
|
|
2595
3301
|
return {
|
|
2596
|
-
|
|
3302
|
+
operations: entry.operations,
|
|
3303
|
+
isLoading: entry.status === "pending" || !!activeId && entry.status === "idle",
|
|
3304
|
+
error,
|
|
3305
|
+
hasNextPage: entry.hasNextPage,
|
|
3306
|
+
fetchNextPage,
|
|
2597
3307
|
refetch
|
|
2598
3308
|
};
|
|
2599
3309
|
}
|
|
3310
|
+
/** Keeps paging `result` to completion while `enabled` is true. */
|
|
3311
|
+
function useLoadAllPages(result, enabled) {
|
|
3312
|
+
useEffect(() => {
|
|
3313
|
+
if (!enabled || !result.hasNextPage || result.isLoading) return;
|
|
3314
|
+
const handle = window.setTimeout(result.fetchNextPage, 0);
|
|
3315
|
+
return () => window.clearTimeout(handle);
|
|
3316
|
+
}, [
|
|
3317
|
+
enabled,
|
|
3318
|
+
result.hasNextPage,
|
|
3319
|
+
result.isLoading,
|
|
3320
|
+
result.fetchNextPage
|
|
3321
|
+
]);
|
|
3322
|
+
}
|
|
3323
|
+
function useDocumentOperations(documentId, scope, options = {}) {
|
|
3324
|
+
const legacy = scope === void 0;
|
|
3325
|
+
const primary = useScopeOperations(documentId, legacy ? "global" : scope, legacy ? {} : options);
|
|
3326
|
+
const local = useScopeOperations(documentId, "local", { enabled: legacy });
|
|
3327
|
+
useLoadAllPages(primary, legacy);
|
|
3328
|
+
useLoadAllPages(local, legacy);
|
|
3329
|
+
const globalOperations = useMemo(() => legacy ? [...primary.operations] : EMPTY_OPERATIONS, [legacy, primary.operations]);
|
|
3330
|
+
const localOperations = useMemo(() => legacy ? [...local.operations] : EMPTY_OPERATIONS, [legacy, local.operations]);
|
|
3331
|
+
const refetch = useCallback(() => {
|
|
3332
|
+
primary.refetch();
|
|
3333
|
+
local.refetch();
|
|
3334
|
+
}, [primary.refetch, local.refetch]);
|
|
3335
|
+
const error = primary.error ?? local.error;
|
|
3336
|
+
const legacyResult = useMemo(() => ({
|
|
3337
|
+
globalOperations,
|
|
3338
|
+
localOperations,
|
|
3339
|
+
isLoading: !error && (primary.isLoading || local.isLoading || primary.hasNextPage || local.hasNextPage),
|
|
3340
|
+
error,
|
|
3341
|
+
refetch
|
|
3342
|
+
}), [
|
|
3343
|
+
globalOperations,
|
|
3344
|
+
localOperations,
|
|
3345
|
+
error,
|
|
3346
|
+
primary.isLoading,
|
|
3347
|
+
local.isLoading,
|
|
3348
|
+
primary.hasNextPage,
|
|
3349
|
+
local.hasNextPage,
|
|
3350
|
+
refetch
|
|
3351
|
+
]);
|
|
3352
|
+
return legacy ? legacyResult : primary;
|
|
3353
|
+
}
|
|
2600
3354
|
//#endregion
|
|
2601
|
-
export {
|
|
3355
|
+
export { addIsAnalyticsExternalProcessorsEnabledEventHandler as $, isRoutedModal as $i, useIsEditorDebugModeEnabled as $n, signStampedAction as $r, setIsDeleteLocalDrivesEnabled as $t, useDropTarget as A, renameDriveNode as Ai, useAnalyticsDatabaseName as An, phDocumentEditorConfigHooks as Ar, addVersionEventHandler as At, addCliVersionEventHandler as B, setFullReactorClient as Bi, useIsAddDriveEnabled as Bn, isGraphQLReactorClient as Br, setDrivesPreserveStrategy as Bt, usePackageDiscoveryService as C, deleteNode as Ci, setSentryRelease as Cn, useWarnOutdatedApp as Cr, addRouterBasenameEventHandler as Ct, addDraggingNodeEventHandler as D, getDocumentExtension as Di, setVersionCheckInterval as Dn, isExternalControlsEnabledEventFunctions as Dr, addStudioModeEventHandler as Dt, useGraphQLReactorClient as E, fetchDocumentOperations as Ei, setVersion as En, addIsExternalControlsEnabledEventHandler as Er, addSentryReleaseEventHandler as Et, setAttachmentService as F, isDocumentTypeSupported as Fi, useDrivesPreserveStrategy as Fn, useAllowedDocumentTypes as Fr, setAnalyticsDatabaseName as Ft, addFileUploadOperationsChunkSizeEventHandler as G, usePGlite as Gi, useIsAnalyticsExternalProcessorsEnabled as Gn, subscriptionsUrlFromGraphqlUrl as Gr, setIsAddDriveEnabled as Gt, addDisabledEditorsEventHandler as H, setReactorClientModule as Hi, useIsAddPublicDrivesEnabled as Hn, isAuthRefusalClose as Hr, setFileUploadOperationsChunkSize as Ht, useAttachmentService as I, addFullReactorClientEventHandler as Ii, useEnabledEditors as In, useIsDragAndDropEnabled as Ir, setBasePath as It, addIsAddDriveEnabledEventHandler as J, useSync as Ji, useIsDeleteLocalDrivesEnabled as Jn, subgraphUrlFromGraphqlUrl as Jr, setIsAnalyticsDatabaseWorkerEnabled as Jt, addGaTrackingIdEventHandler as K, useReactorClient as Ki, useIsCloudDrivesEnabled as Kn, SubgraphSdkRegistry as Kr, setIsAddLocalDrivesEnabled as Kt, addAllowListEventHandler as L, addReactorClientEventHandler as Li, useFileUploadOperationsChunkSize as Ln, useIsExternalControlsEnabled as Lr, setCliVersion as Lt, setFeatures as M, setPreferredEditorOnNode as Mi, useCliVersion as Mn, setAllowedDocumentTypes as Mr, phGlobalConfigHooks as Mt, useFeatures as N, upgradeDocument as Ni, useDefaultDrivesUrl as Nn, setIsDragAndDropEnabled as Nr, phGlobalConfigSetters as Nt, useDragNode as O, loadFile as Oi, setWarnOutdatedApp as On, phAppConfigHooks as Or, addSwitchboardUrlEventHandler as Ot, addAttachmentServiceEventHandler as P, getUserPermissions as Pi, useDisabledEditors as Pn, setIsExternalControlsEnabled as Pr, setAllowList as Pt, addIsAnalyticsEnabledEventHandler as Q, closePHModal as Qi, useIsDriveAnalyticsEnabled as Qn, prepareSignedActions as Qr, setIsDeleteCloudDrivesEnabled as Qt, addAnalyticsDatabaseNameEventHandler as R, addReactorClientModuleEventHandler as Ri, useGaTrackingId as Rn, GraphQLReactorClient as Rr, setDefaultDrivesUrl as Rt, setPackageDiscoveryService as S, copyNode$1 as Si, setSentryEnv as Sn, useVersionCheckInterval as Sr, addRequiresHardRefreshEventHandler as St, setGraphQLReactorClient as T, extractInitialState as Ti, setSwitchboardUrl as Tn, addIsDragAndDropEnabledEventHandler as Tr, addSentryEnvEventHandler as Tt, addDrivesPreserveStrategyEventHandler as U, useDatabase as Ui, useIsAnalyticsDatabaseWorkerEnabled as Un, makeAuthConnectionParams as Ur, setGaTrackingId as Ut, addDefaultDrivesUrlEventHandler as V, setReactorClient as Vi, useIsAddLocalDrivesEnabled as Vn, viewFilterInputFromViewFilter as Vr, setEnabledEditors as Vt, addEnabledEditorsEventHandler as W, useModelRegistry as Wi, useIsAnalyticsEnabled as Wn, startDocumentChangesSubscription as Wr, setIsAddCloudDrivesEnabled as Wt, addIsAddPublicDrivesEnabledEventHandler as X, MODAL_SEARCH_PARAM as Xi, useIsDiffAnalyticsEnabled as Xn, packageFromDocumentModels as Xr, setIsAnalyticsExternalProcessorsEnabled as Xt, addIsAddLocalDrivesEnabledEventHandler as Y, useSyncList as Yi, useIsDeletePublicDrivesEnabled as Yn, StaticPackageManager as Yr, setIsAnalyticsEnabled as Yt, addIsAnalyticsDatabaseWorkerEnabledEventHandler as Z, addModalEventHandler as Zi, useIsDocumentModelSelectionSettingsEnabled as Zn, resolveDocumentModelModule as Zr, setIsCloudDrivesEnabled as Zt, addSetSelectedDriveOnPopStateEventHandler as _, DEFAULT_DRIVE_EDITOR_ID as _i, setRenownNetworkId as _n, useSentryEnv as _r, addLogLevelEventHandler as _t, addPHEventHandlers as a, showDeleteNodeModal as aa, GraphQLWrongBackendError as ai, setIsEditorReadModeEnabled as an, useIsPublicDrivesEnabled as ar, addIsDocumentModelSelectionSettingsEnabledEventHandler as at, syncSelectionFromPath as b, addFileWithProgress as bi, setRouterBasename as bn, useSwitchboardUrl as br, addRenownNetworkIdEventHandler as bt, addToastEventHandler as c, withoutModalSearch as ca, phDocumentFromMutation as ci, setIsExternalRelationalProcessorsEnabled as cn, useLocalDrivesEnabled as cr, addIsEditorReadModeEnabledEventHandler as ct, addSelectedTimelineRevisionEventHandler as d, buildPulledDocument as di, setIsRelationalProcessorsEnabled as dn, useRenownChainId as dr, addIsExternalRelationalProcessorsEnabledEventHandler as dt, modalFromSearch as ea, stampAction as ei, setIsDeletePublicDrivesEnabled as en, useIsEditorReadModeEnabled as er, addIsCloudDrivesEnabledEventHandler as et, setSelectedTimelineRevision as f, convertRemoteOperations as fi, setIsSentryTracingEnabled as fn, useRenownNetworkId as fr, addIsLocalDrivesEnabledEventHandler as ft, useSelectedTimelineItem as g, COMMON_PACKAGE_ID as gi, setRenownChainId as gn, useSentryDsn as gr, addLocalDrivesEnabledEventHandler as gt, setSelectedTimelineItem as h, screamingSnakeToCamel as hi, setRenownAdapters as hn, useRouterBasename as hr, addIsSentryTracingEnabledEventHandler as ht, useSwitchboardClient as i, showCreateDocumentModal as ia, GraphQLOperationNotSupportedError as ii, setIsEditorDebugModeEnabled as in, useIsLocalDrivesEnabled as ir, addIsDiffAnalyticsEnabledEventHandler as it, addFeaturesEventHandler as j, renameNode as ji, useBasePath as jn, phDocumentEditorConfigSetters as jr, addWarnOutdatedAppEventHandler as jt, useDropNode as k, moveNode$1 as ki, useAllowList as kn, phAppConfigSetters as kr, addVersionCheckIntervalEventHandler as kt, setPHToast as l, revisionMapFromRevisionsList as li, setIsLocalDrivesEnabled as ln, useLogLevel as lr, addIsExternalPackagesEnabledEventHandler as lt, addSelectedTimelineItemEventHandler as m, hasRevisionConflict as mi, setLogLevel as mn, useRequiresHardRefresh as mr, addIsRelationalProcessorsEnabledEventHandler as mt, GraphQLReactorProvider as n, modalSearch as na, ReactorOperationFieldsFragmentDoc as ni, setIsDocumentModelSelectionSettingsEnabled as nn, useIsExternalProcessorsEnabled as nr, addIsDeleteLocalDrivesEnabledEventHandler as nt, callEventHandlerRegisterFunctions as o, showPHModal as oa, isoStringFromDateTime as oi, setIsExternalPackagesEnabled as on, useIsRelationalProcessorsEnabled as or, addIsDriveAnalyticsEnabledEventHandler as ot, useSelectedTimelineRevision as p, extractRevisionMap as pi, setLocalDrivesEnabled as pn, useRenownUrl as pr, addIsPublicDrivesEnabledEventHandler as pt, addIsAddCloudDrivesEnabledEventHandler as q, useReactorClientModule as qi, useIsDeleteCloudDrivesEnabled as qn, describeGraphQLDocument as qr, setIsAddPublicDrivesEnabled as qt, ensurePHEventHandlers as r, setPHModal as ra, BatchJobFailedError as ri, setIsDriveAnalyticsEnabled as rn, useIsExternalRelationalProcessorsEnabled as rr, addIsDeletePublicDrivesEnabledEventHandler as rt, commonGlobalEventHandlerFunctions as s, usePHModal as sa, phDocumentFromGetDocument as si, setIsExternalProcessorsEnabled as sn, useIsSentryTracingEnabled as sr, addIsEditorDebugModeEnabledEventHandler as st, useDocumentOperations as t, modalHref as ta, MutateDocumentWithOperationsDocument as ti, setIsDiffAnalyticsEnabled as tn, useIsExternalPackagesEnabled as tr, addIsDeleteCloudDrivesEnabledEventHandler as tt, usePHToast as u, ConflictError as ui, setIsPublicDrivesEnabled as un, useRenownAdapters as ur, addIsExternalProcessorsEnabledEventHandler as ut, addSetSelectedNodeOnPopStateEventHandler as v, DRIVE_DOCUMENT_TYPES as vi, setRenownUrl as vn, useSentryRelease as vr, addRenownAdaptersEventHandler as vt, addGraphQLReactorClientEventHandler as w, exportFile as wi, setStudioMode as wn, addAllowedDocumentTypesEventHandler as wr, addSentryDsnEventHandler as wt, addPackageDiscoveryServiceEventHandler as x, addFolder$1 as xi, setSentryDsn as xn, useVersion as xr, addRenownUrlEventHandler as xt, addSyncSelectionOnPopStateEventHandler as y, addDocument as yi, setRequiresHardRefresh as yn, useStudioMode as yr, addRenownChainIdEventHandler as yt, addBasePathEventHandler as z, getFullReactorClient as zi, useIsAddCloudDrivesEnabled as zn, findIsServableOverGraphQL as zr, setDisabledEditors as zt };
|
|
2602
3356
|
|
|
2603
|
-
//# sourceMappingURL=document-operations-
|
|
3357
|
+
//# sourceMappingURL=document-operations-C6khz2If.js.map
|