@powerhousedao/reactor-browser 6.2.3-dev.6 → 6.2.3-dev.60
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-DG6UkyMv.d.ts} +362 -65
- package/dist/attachment-service-DG6UkyMv.d.ts.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/{client-DjK30EQ-.js → client-Cq5avLW5.js} +35 -22
- package/dist/client-Cq5avLW5.js.map +1 -0
- package/dist/{document-by-id-B4FIzG1w.js → dispatch-C1VVTn5S.js} +393 -54
- package/dist/dispatch-C1VVTn5S.js.map +1 -0
- package/dist/document-by-id-BRDkvmpn.js +16 -0
- package/dist/document-by-id-BRDkvmpn.js.map +1 -0
- package/dist/{document-model-modules-bTP87nyr.js → document-model-modules-Gsh1Xr7j.js} +60 -68
- package/dist/document-model-modules-Gsh1Xr7j.js.map +1 -0
- package/dist/{document-operations-WeE6wIDt.js → document-operations-BSzcF0mu.js} +805 -167
- package/dist/document-operations-BSzcF0mu.js.map +1 -0
- package/dist/{global-OuINvEGT.d.ts → global-BuSwbbY0.d.ts} +59 -13
- package/dist/global-BuSwbbY0.d.ts.map +1 -0
- package/dist/{index-B33TKEqp.d.ts → index-ewIc3pEO.d.ts} +19 -98
- package/dist/index-ewIc3pEO.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 +395 -371
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +116 -47
- 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-DBq3iWYn.js → make-ph-event-functions-CdsvEl5t.js} +4 -2
- package/dist/{make-ph-event-functions-DBq3iWYn.js.map → make-ph-event-functions-CdsvEl5t.js.map} +1 -1
- 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-DxHuX41f.js} +66 -5
- package/dist/relational-DxHuX41f.js.map +1 -0
- package/dist/{renown-rqK8sokh.js → renown-CPAeJt5L.js} +7 -8
- package/dist/{renown-rqK8sokh.js.map → renown-CPAeJt5L.js.map} +1 -1
- package/dist/{renown-BHxwP7xU.js → renown-D05wkobG.js} +2 -2
- package/dist/{renown-BHxwP7xU.js.map → renown-D05wkobG.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 +5 -8
- 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 +2 -2
- 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 +176 -138
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +421 -618
- 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-3vHbIV5W.js} +58 -6
- package/dist/switchboard-3vHbIV5W.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 +19 -20
- 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.map +0 -1
- 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/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,13 +1,13 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
import {
|
|
3
|
-
import { t as makePHEventFunctions } from "./make-ph-event-functions-
|
|
4
|
-
import {
|
|
5
|
-
import { f as addLoadingEventHandler, t as addRenownEventHandler } from "./renown-
|
|
1
|
+
import { C as queueOperations, S as queueActions, a as useDocumentCache, d as DocumentCache, f as IDLE_OPERATIONS_ENTRY, g as DOCUMENT_CHANGE_TYPE, m as isOperationCache, n as addDocumentCacheEventHandler, r as setDocumentCache, w as uploadOperations } from "./dispatch-C1VVTn5S.js";
|
|
2
|
+
import { B as ambientRenownTokenProvider, I as DocumentModelNotFoundError, V as makeAuthMiddleware, _ as addSetSelectedNodeOnPopStateEventHandler, a as setVetraPackageManager, b as addDrivesEventHandler, c as addSelectedDriveIdEventHandler, g as addSelectedNodeIdEventHandler, h as addResetSelectedNodeEventHandler, l as addSetSelectedDriveOnPopStateEventHandler, p as useSelectedDriveId, r as addVetraPackageManagerEventHandler, z as UnsupportedDocumentTypeError } from "./document-model-modules-Gsh1Xr7j.js";
|
|
3
|
+
import { t as makePHEventFunctions } from "./make-ph-event-functions-CdsvEl5t.js";
|
|
4
|
+
import { i as PhDocumentFieldsFragmentDoc, n as DocumentChangesDocument, t as createClient$1 } from "./client-CXDpILj6.js";
|
|
5
|
+
import { f as addLoadingEventHandler, t as addRenownEventHandler } from "./renown-D05wkobG.js";
|
|
6
6
|
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
7
|
import { addFolder, copyNode, generateNodesCopy, handleTargetNameCollisions, isFileNode, isFolderNode, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
|
|
8
|
+
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
9
|
import { allPass, conditional, constant, forEachObj, funnel, isDefined, isNot, isStrictEqual, isString, isTruthy, once } from "remeda";
|
|
10
|
-
import { useCallback, useEffect,
|
|
10
|
+
import { useCallback, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
11
11
|
import { GraphQLClient } from "graphql-request";
|
|
12
12
|
import { gql } from "graphql-tag";
|
|
13
13
|
import { Kind, print } from "graphql";
|
|
@@ -39,12 +39,51 @@ function showCreateDocumentModal(documentType, documentModelVersion) {
|
|
|
39
39
|
}
|
|
40
40
|
/** Shows the delete node modal */
|
|
41
41
|
function showDeleteNodeModal(nodeOrId) {
|
|
42
|
+
const id = typeof nodeOrId === "string" ? nodeOrId : nodeOrId.id;
|
|
42
43
|
setPHModal({
|
|
43
44
|
type: "deleteItem",
|
|
44
|
-
id
|
|
45
|
+
id
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
//#endregion
|
|
49
|
+
//#region src/hooks/reactor.ts
|
|
50
|
+
const reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
|
|
51
|
+
const reactorClientEventFunctions = makePHEventFunctions("reactorClient");
|
|
52
|
+
const fullReactorClientEventFunctions = makePHEventFunctions("fullReactorClient");
|
|
53
|
+
/** Returns the reactor client module (in-process or worker-backed) */
|
|
54
|
+
const useReactorClientModule = reactorClientModuleEventFunctions.useValue;
|
|
55
|
+
/** Sets the reactor client module */
|
|
56
|
+
const setReactorClientModule = reactorClientModuleEventFunctions.setValue;
|
|
57
|
+
/** Adds an event handler for the reactor client module */
|
|
58
|
+
const addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
|
|
59
|
+
/** Returns the reactor client */
|
|
60
|
+
const useReactorClient = reactorClientEventFunctions.useValue;
|
|
61
|
+
/** Sets the reactor client */
|
|
62
|
+
const setReactorClient = reactorClientEventFunctions.setValue;
|
|
63
|
+
/** Adds an event handler for the reactor client */
|
|
64
|
+
const addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
|
|
65
|
+
/** Sets the client full-client actions use instead of the module's */
|
|
66
|
+
const setFullReactorClient = fullReactorClientEventFunctions.setValue;
|
|
67
|
+
/** Adds an event handler for the full reactor client */
|
|
68
|
+
const addFullReactorClientEventHandler = fullReactorClientEventFunctions.addEventHandler;
|
|
69
|
+
/** The client full-client actions use: the one set, else the module's. */
|
|
70
|
+
function getFullReactorClient() {
|
|
71
|
+
return window.ph?.fullReactorClient ?? window.ph?.reactorClientModule?.client;
|
|
72
|
+
}
|
|
73
|
+
const useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
|
|
74
|
+
const useSyncList = () => {
|
|
75
|
+
return useSync()?.list() ?? [];
|
|
76
|
+
};
|
|
77
|
+
const useModelRegistry = () => useReactorClientModule()?.reactorModule?.documentModelRegistry;
|
|
78
|
+
const useDatabase = () => {
|
|
79
|
+
const module = useReactorClientModule();
|
|
80
|
+
return module?.kind === "browser" ? module.reactorModule?.database : void 0;
|
|
81
|
+
};
|
|
82
|
+
const usePGlite = () => {
|
|
83
|
+
const module = useReactorClientModule();
|
|
84
|
+
return module?.kind === "browser" ? module.reactorModule?.pg : void 0;
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
48
87
|
//#region src/utils/documents.ts
|
|
49
88
|
function isDocumentTypeSupported(documentType, supportedDocuments) {
|
|
50
89
|
if (!supportedDocuments?.length) return true;
|
|
@@ -76,7 +115,7 @@ function getUserPermissions() {
|
|
|
76
115
|
}
|
|
77
116
|
//#endregion
|
|
78
117
|
//#region src/actions/document.ts
|
|
79
|
-
const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
|
|
118
|
+
const NON_DOMAIN_SCOPES = /* @__PURE__ */ new Set(["auth", "document"]);
|
|
80
119
|
/** An unreadable drive cannot be shown to hold no duplicate, so reads throw. */
|
|
81
120
|
async function isDocumentInLocation(reactorClient, document, driveId, parentFolder) {
|
|
82
121
|
const drive = await reactorClient.get(driveId);
|
|
@@ -131,7 +170,7 @@ async function getDocumentExtension(document) {
|
|
|
131
170
|
let rawExtension;
|
|
132
171
|
if (documentType === documentModelDocumentType) rawExtension = document.state.global?.extension;
|
|
133
172
|
else {
|
|
134
|
-
const reactorClient =
|
|
173
|
+
const reactorClient = getFullReactorClient();
|
|
135
174
|
if (reactorClient) {
|
|
136
175
|
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
137
176
|
rawExtension = documentModelModules.find((m) => m.documentModel.global.id === documentType)?.utils.fileExtension;
|
|
@@ -263,7 +302,7 @@ async function exportFile(document, suggestedName) {
|
|
|
263
302
|
*/
|
|
264
303
|
async function loadFile(path) {
|
|
265
304
|
const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
|
|
266
|
-
const reactorClient =
|
|
305
|
+
const reactorClient = getFullReactorClient();
|
|
267
306
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
268
307
|
const documentType = baseDocument.header.documentType;
|
|
269
308
|
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
@@ -284,7 +323,7 @@ async function loadFile(path) {
|
|
|
284
323
|
async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor, documentModelVersion) {
|
|
285
324
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
286
325
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create documents");
|
|
287
|
-
const reactorClient =
|
|
326
|
+
const reactorClient = getFullReactorClient();
|
|
288
327
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
289
328
|
let documentModelModule;
|
|
290
329
|
if (documentModelVersion !== void 0) {
|
|
@@ -293,7 +332,7 @@ async function addDocument(driveId, name, documentType, parentFolder, document,
|
|
|
293
332
|
if (!module) throw new Error(`Document model not found for type: ${documentType} with version: ${documentModelVersion}`);
|
|
294
333
|
documentModelModule = module;
|
|
295
334
|
} else documentModelModule = await reactorClient.getDocumentModelModule(documentType);
|
|
296
|
-
const newDocument = document ?? documentModelModule.utils.createDocument();
|
|
335
|
+
const newDocument = document ?? withSignaturePolicy(documentModelModule.utils.createDocument(), await reactorClient.getCreateSignaturePolicy());
|
|
297
336
|
if (!document) newDocument.state.document.version = documentModelModule.version ?? 1;
|
|
298
337
|
newDocument.header.name = name;
|
|
299
338
|
if (preferredEditor) newDocument.header.meta = {
|
|
@@ -341,9 +380,24 @@ function isDocumentAlreadyExists(error) {
|
|
|
341
380
|
* fails leaves the drive untouched, so a retry has nothing to clean up.
|
|
342
381
|
*/
|
|
343
382
|
async function createImportedDocument(reactor, document, driveId, name, parentFolder) {
|
|
344
|
-
|
|
383
|
+
const v2Required = signaturePolicyOf(document.header) === "v2-required";
|
|
384
|
+
const keepsId = (!v2Required || hasDerivedDocumentId(document.header)) && !await reactor.isDocumentIdTaken(document.header.id);
|
|
385
|
+
let documentId = keepsId ? document.header.id : generateId();
|
|
345
386
|
for (let attempt = 1;; attempt++) {
|
|
346
|
-
|
|
387
|
+
let header;
|
|
388
|
+
if (!v2Required) header = createPresignedHeader(documentId, document.header.documentType);
|
|
389
|
+
else if (keepsId && attempt === 1) {
|
|
390
|
+
header = createPresignedHeader(documentId, document.header.documentType);
|
|
391
|
+
header.createdAtUtcIso = document.header.createdAtUtcIso;
|
|
392
|
+
header.sig = {
|
|
393
|
+
...header.sig,
|
|
394
|
+
nonce: document.header.sig.nonce
|
|
395
|
+
};
|
|
396
|
+
header.protocolVersions = { ...document.header.protocolVersions };
|
|
397
|
+
} else {
|
|
398
|
+
header = createCopyHeader(document.header);
|
|
399
|
+
documentId = header.id;
|
|
400
|
+
}
|
|
347
401
|
header.lastModifiedAtUtcIso = document.header.createdAtUtcIso;
|
|
348
402
|
header.meta = document.header.meta;
|
|
349
403
|
header.name = name || document.header.name;
|
|
@@ -372,7 +426,7 @@ async function createImportedDocument(reactor, document, driveId, name, parentFo
|
|
|
372
426
|
}
|
|
373
427
|
async function addFileWithProgress(file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict) {
|
|
374
428
|
logger.verbose(`addFileWithProgress(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
|
|
375
|
-
const reactor =
|
|
429
|
+
const reactor = getFullReactorClient();
|
|
376
430
|
if (!reactor) {
|
|
377
431
|
onProgress?.({
|
|
378
432
|
stage: "failed",
|
|
@@ -529,7 +583,7 @@ async function addFolder$1(driveId, name, parentFolder) {
|
|
|
529
583
|
async function deleteNode(driveId, nodeId) {
|
|
530
584
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
531
585
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to delete documents");
|
|
532
|
-
const reactorClient =
|
|
586
|
+
const reactorClient = getFullReactorClient();
|
|
533
587
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
534
588
|
await reactorClient.drives.removeNode(driveId, nodeId);
|
|
535
589
|
}
|
|
@@ -593,7 +647,7 @@ async function moveNode$1(driveId, src, target) {
|
|
|
593
647
|
* Duplicates a document under a new id using version-aware replay.
|
|
594
648
|
* Falls back gracefully when no upgrade manifest is registered for the document type.
|
|
595
649
|
*/
|
|
596
|
-
async function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
650
|
+
async function _duplicateDocument(reactor, document, newId = generateId(), driveId) {
|
|
597
651
|
const documentType = document.header.documentType;
|
|
598
652
|
const { results: allModules } = await reactor.getDocumentModelModules();
|
|
599
653
|
const modulesForType = allModules.filter((m) => m.documentModel.global.id === documentType);
|
|
@@ -609,13 +663,20 @@ async function _duplicateDocument(reactor, document, newId = generateId()) {
|
|
|
609
663
|
reducers,
|
|
610
664
|
upgradeManifest
|
|
611
665
|
};
|
|
612
|
-
const
|
|
666
|
+
const selected = await reactor.getCreateProtocolVersions(driveId);
|
|
667
|
+
const header = createCopyHeader({
|
|
668
|
+
documentType: document.header.documentType,
|
|
669
|
+
protocolVersions: document.header.protocolVersions ? {
|
|
670
|
+
...selected,
|
|
671
|
+
...document.header.protocolVersions
|
|
672
|
+
} : void 0
|
|
673
|
+
}, newId, await reactor.getCreateSignaturePolicy());
|
|
613
674
|
const duplicated = replayDocumentVersioned(document.initialState, document.operations, config, header);
|
|
614
675
|
assertAuthPreservedOnDuplicate(document.header.id, document.state.auth, duplicated.state.auth);
|
|
615
676
|
return duplicated;
|
|
616
677
|
}
|
|
617
678
|
async function copyNode$1(driveId, src, target) {
|
|
618
|
-
const reactor =
|
|
679
|
+
const reactor = getFullReactorClient();
|
|
619
680
|
if (!reactor) return;
|
|
620
681
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
621
682
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to copy documents");
|
|
@@ -643,25 +704,33 @@ async function copyNode$1(driveId, src, target) {
|
|
|
643
704
|
return node !== void 0 && isFileNode(node);
|
|
644
705
|
});
|
|
645
706
|
for (const fileNodeToCopy of fileNodesToCopy) try {
|
|
646
|
-
const duplicatedDocument = await _duplicateDocument(reactor, await reactor.get(fileNodeToCopy.srcId), fileNodeToCopy.targetId);
|
|
707
|
+
const duplicatedDocument = await _duplicateDocument(reactor, await reactor.get(fileNodeToCopy.srcId), fileNodeToCopy.targetId, driveId);
|
|
647
708
|
const resolvedName = resolvedNamesMap.get(fileNodeToCopy.targetId);
|
|
648
709
|
if (resolvedName) duplicatedDocument.header.name = resolvedName;
|
|
710
|
+
fileNodeToCopy.targetId = duplicatedDocument.header.id;
|
|
649
711
|
await reactor.drives.addFile(driveId, duplicatedDocument, target?.id);
|
|
650
712
|
} catch (e) {
|
|
651
713
|
logger.error(`Error copying document ${fileNodeToCopy.srcId}: ${String(e)}`);
|
|
652
714
|
}
|
|
653
|
-
|
|
715
|
+
const copyActions = copyNodesInput.map((copyNodeInput) => copyNode(copyNodeInput));
|
|
716
|
+
return await queueActions(drive, copyActions);
|
|
654
717
|
}
|
|
655
718
|
/**
|
|
656
719
|
* Upgrades a document to a newer document model version. Defaults to the
|
|
657
720
|
* latest registered version for the document's type.
|
|
658
721
|
*/
|
|
659
722
|
async function upgradeDocument(documentId, toVersion) {
|
|
660
|
-
const reactorClient =
|
|
723
|
+
const reactorClient = getFullReactorClient();
|
|
661
724
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
662
725
|
return reactorClient.upgradeDocument(documentId, toVersion);
|
|
663
726
|
}
|
|
664
727
|
//#endregion
|
|
728
|
+
//#region src/constants.ts
|
|
729
|
+
const DEFAULT_DRIVE_EDITOR_ID = "powerhouse/generic-drive-explorer";
|
|
730
|
+
const COMMON_PACKAGE_ID = "powerhouse/common";
|
|
731
|
+
/** Document types that represent a "drive": a container of nodes. */
|
|
732
|
+
const DRIVE_DOCUMENT_TYPES = ["powerhouse/document-drive", "powerhouse/reactor-drive"];
|
|
733
|
+
//#endregion
|
|
665
734
|
//#region src/remote-controller/utils.ts
|
|
666
735
|
/** Convert SCREAMING_SNAKE_CASE to camelCase (e.g. "SET_MODEL_NAME" → "setModelName"). */
|
|
667
736
|
function screamingSnakeToCamel(s) {
|
|
@@ -669,6 +738,7 @@ function screamingSnakeToCamel(s) {
|
|
|
669
738
|
}
|
|
670
739
|
/** Error thrown when a push conflict is detected with the "reject" strategy. */
|
|
671
740
|
var ConflictError = class extends Error {
|
|
741
|
+
conflict;
|
|
672
742
|
constructor(conflict) {
|
|
673
743
|
super("Push conflict: remote has new operations since last pull");
|
|
674
744
|
this.conflict = conflict;
|
|
@@ -814,7 +884,9 @@ function phDocumentHeaderFromGetDocument(document, branch) {
|
|
|
814
884
|
name: document.name,
|
|
815
885
|
branch: branch ?? defaultBranch,
|
|
816
886
|
revision: revisionMapFromRevisionsList(document.revisionsList),
|
|
817
|
-
lastModifiedAtUtcIso: isoStringFromDateTime(document.lastModifiedAtUtcIso)
|
|
887
|
+
lastModifiedAtUtcIso: isoStringFromDateTime(document.lastModifiedAtUtcIso),
|
|
888
|
+
...document.meta != null ? { meta: document.meta } : {},
|
|
889
|
+
...document.protocolVersions != null ? { protocolVersions: document.protocolVersions } : {}
|
|
818
890
|
};
|
|
819
891
|
}
|
|
820
892
|
function emptyOperationsForScopes(revisionsList) {
|
|
@@ -825,6 +897,61 @@ function isoStringFromDateTime(value) {
|
|
|
825
897
|
return value instanceof Date ? value.toISOString() : value;
|
|
826
898
|
}
|
|
827
899
|
//#endregion
|
|
900
|
+
//#region src/graphql-client/errors.ts
|
|
901
|
+
/** A call the Switchboard GraphQL surface cannot express. */
|
|
902
|
+
var GraphQLOperationNotSupportedError = class extends Error {
|
|
903
|
+
name = "GraphQLOperationNotSupportedError";
|
|
904
|
+
operation;
|
|
905
|
+
constructor(operation, reason) {
|
|
906
|
+
super(`GraphQLReactorClient.${operation} is not supported: ${reason}`);
|
|
907
|
+
this.operation = operation;
|
|
908
|
+
}
|
|
909
|
+
static isError(error) {
|
|
910
|
+
return Error.isError(error) && error.name === "GraphQLOperationNotSupportedError";
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
/**
|
|
914
|
+
* The Switchboard refused a request with 421 Misdirected Request: the
|
|
915
|
+
* `Drive-Id` it carried names a drive that Switchboard does not own.
|
|
916
|
+
*/
|
|
917
|
+
var GraphQLWrongBackendError = class extends Error {
|
|
918
|
+
name = "GraphQLWrongBackendError";
|
|
919
|
+
status = 421;
|
|
920
|
+
/** The drive the Switchboard refused, or `""` when its answer names none. */
|
|
921
|
+
driveId;
|
|
922
|
+
/** The response body, parsed when it is JSON. */
|
|
923
|
+
payload;
|
|
924
|
+
constructor(driveId, payload, options) {
|
|
925
|
+
super(`The Switchboard does not serve drive ${driveId === "" ? "(unnamed)" : driveId}: 421 Misdirected Request`, options);
|
|
926
|
+
this.driveId = driveId;
|
|
927
|
+
this.payload = payload;
|
|
928
|
+
}
|
|
929
|
+
static isError(error) {
|
|
930
|
+
return Error.isError(error) && error.name === "GraphQLWrongBackendError" && typeof error.driveId === "string";
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
/**
|
|
934
|
+
* The reactor's `BatchJobFailedError`, rebuilt from a batch result; this entry
|
|
935
|
+
* imports the reactor for types only. The shared name lets either `isError`
|
|
936
|
+
* recognise it.
|
|
937
|
+
*/
|
|
938
|
+
var BatchJobFailedError = class extends Error {
|
|
939
|
+
name = "BatchJobFailedError";
|
|
940
|
+
key;
|
|
941
|
+
jobs;
|
|
942
|
+
constructor(key, jobs) {
|
|
943
|
+
const failure = jobs[key].error;
|
|
944
|
+
const cause = new Error(failure?.message ?? "Job failed");
|
|
945
|
+
cause.name = failure?.name ?? "Error";
|
|
946
|
+
super(failure?.message ?? "Job failed", { cause });
|
|
947
|
+
this.key = key;
|
|
948
|
+
this.jobs = jobs;
|
|
949
|
+
}
|
|
950
|
+
static isError(error) {
|
|
951
|
+
return Error.isError(error) && error.name === "BatchJobFailedError" && typeof error.key === "string" && typeof error.jobs === "object";
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
//#endregion
|
|
828
955
|
//#region src/graphql-client/operations.ts
|
|
829
956
|
/**
|
|
830
957
|
* The operation selection of `GetDocumentOperations`, lifted into a fragment so
|
|
@@ -941,43 +1068,42 @@ function stampAction(action, document, revision = document.header.revision[actio
|
|
|
941
1068
|
};
|
|
942
1069
|
}
|
|
943
1070
|
/**
|
|
944
|
-
* Signs a stamped action
|
|
945
|
-
*
|
|
946
|
-
*
|
|
947
|
-
*
|
|
1071
|
+
* Signs a stamped action for `target`, keeping any signatures it already
|
|
1072
|
+
* carries. The signer reads `context.prevOpHash`, so this runs after
|
|
1073
|
+
* {@link stampAction}. A v2 tuple covers the signer's identity, so the context
|
|
1074
|
+
* takes the signer's user and app even when the action named others.
|
|
948
1075
|
*/
|
|
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);
|
|
1076
|
+
async function signStampedAction(action, signer, target, signal) {
|
|
1077
|
+
if (!signer.user || !signer.app) throw new Error("cannot sign an action: the signer has no user or app identity");
|
|
1078
|
+
const signature = await signer.signAction(action, target, signal);
|
|
955
1079
|
return {
|
|
956
1080
|
...action,
|
|
957
1081
|
context: {
|
|
958
1082
|
...action.context,
|
|
959
1083
|
signer: {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
signatures: [...actionSigner?.signatures ?? [], signature]
|
|
1084
|
+
...actionSignerIdentity(signer),
|
|
1085
|
+
signatures: [...action.context?.signer?.signatures ?? [], signature]
|
|
963
1086
|
}
|
|
964
1087
|
}
|
|
965
1088
|
};
|
|
966
1089
|
}
|
|
1090
|
+
/** The log a snapshot's action is written to; the snapshot names the branch read. */
|
|
1091
|
+
function snapshotTarget(action, snapshot) {
|
|
1092
|
+
return actionSigningTarget(action, snapshot.header.id, snapshot.header.branch || "main");
|
|
1093
|
+
}
|
|
967
1094
|
/**
|
|
968
1095
|
* Actions a snapshot batch cannot predict the next state for.
|
|
969
1096
|
*
|
|
970
|
-
* `UNDO
|
|
971
|
-
*
|
|
1097
|
+
* `UNDO` and `REDO` rewrite history the light read path never fetched (and
|
|
1098
|
+
* the reducer appends no operation for them); `NOOP` is only ever produced
|
|
972
1099
|
* by an undo chain; the document-scope actions run through the reactor's
|
|
973
1100
|
* document-action handler rather than a document-model reducer
|
|
974
1101
|
* (`DOCUMENT_SCOPE_ACTIONS` in packages/reactor/src/executor/util.ts) and
|
|
975
1102
|
* `UPGRADE_DOCUMENT` changes which reducer applies mid-batch.
|
|
976
1103
|
*/
|
|
977
|
-
const unsupportedBatchActions = new Set([
|
|
1104
|
+
const unsupportedBatchActions = /* @__PURE__ */ new Set([
|
|
978
1105
|
"UNDO",
|
|
979
1106
|
"REDO",
|
|
980
|
-
"PRUNE",
|
|
981
1107
|
"NOOP",
|
|
982
1108
|
"CREATE_DOCUMENT",
|
|
983
1109
|
"DELETE_DOCUMENT",
|
|
@@ -991,9 +1117,9 @@ const unsupportedBatchActions = new Set([
|
|
|
991
1117
|
* carries none.
|
|
992
1118
|
*
|
|
993
1119
|
* `baseReducer` reads `baseReducerVersion(document.header)` for every action and
|
|
994
|
-
* throws when the header has no `protocolVersions
|
|
995
|
-
* {@link phDocumentFromGetDocument}
|
|
996
|
-
*
|
|
1120
|
+
* throws when the header has no `protocolVersions`, which a header built by
|
|
1121
|
+
* {@link phDocumentFromGetDocument} lacks when the server sends none. The
|
|
1122
|
+
* version only selects between the v1
|
|
997
1123
|
* and v2 UNDO/NOOP branches, and every action reaching the prediction loop is an
|
|
998
1124
|
* ordinary append-only one, so it cannot change the predicted state here; it is
|
|
999
1125
|
* passed purely so the lookup does not throw.
|
|
@@ -1020,7 +1146,7 @@ const predictionProtocolVersion = 2;
|
|
|
1020
1146
|
*/
|
|
1021
1147
|
async function prepareSignedActions(actions, snapshot, signer, module, signal) {
|
|
1022
1148
|
if (actions.length === 0) return [];
|
|
1023
|
-
if (actions.length === 1) return [await signStampedAction(stampAction(actions[0], snapshot), signer, signal)];
|
|
1149
|
+
if (actions.length === 1) return [await signStampedAction(stampAction(actions[0], snapshot), signer, snapshotTarget(actions[0], snapshot), signal)];
|
|
1024
1150
|
const scope = sharedScope(actions);
|
|
1025
1151
|
assertSupportedBatch(actions);
|
|
1026
1152
|
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 +1161,8 @@ async function prepareSignedActions(actions, snapshot, signer, module, signal) {
|
|
|
1035
1161
|
const signed = [];
|
|
1036
1162
|
for (const [index, action] of actions.entries()) {
|
|
1037
1163
|
throwIfAborted(signal, index);
|
|
1038
|
-
const
|
|
1164
|
+
const stamped = stampAction(action, working, revision);
|
|
1165
|
+
const signedAction = await signStampedAction(stamped, signer, snapshotTarget(stamped, snapshot), signal);
|
|
1039
1166
|
signed.push(signedAction);
|
|
1040
1167
|
const before = scopeOperationCount(working, scope);
|
|
1041
1168
|
let next;
|
|
@@ -1375,6 +1502,7 @@ const defaultPaging = {
|
|
|
1375
1502
|
cursor: "0",
|
|
1376
1503
|
limit: 100
|
|
1377
1504
|
};
|
|
1505
|
+
const JOB_POLL_INTERVAL_MS = 250;
|
|
1378
1506
|
/**
|
|
1379
1507
|
* The marker {@link isGraphQLReactorClient} looks for.
|
|
1380
1508
|
*
|
|
@@ -1401,6 +1529,7 @@ var GraphQLReactorClient = class {
|
|
|
1401
1529
|
subscriptionsUrl;
|
|
1402
1530
|
documentModels;
|
|
1403
1531
|
signer;
|
|
1532
|
+
driveIdFor;
|
|
1404
1533
|
stopRealtime;
|
|
1405
1534
|
realtimeStarted = false;
|
|
1406
1535
|
realtimeGeneration = 0;
|
|
@@ -1409,10 +1538,16 @@ var GraphQLReactorClient = class {
|
|
|
1409
1538
|
realtimeRefusedCredentials = false;
|
|
1410
1539
|
constructor(options) {
|
|
1411
1540
|
this.tokenProvider = options.tokenProvider ?? ambientRenownTokenProvider;
|
|
1412
|
-
|
|
1541
|
+
const models = options.documentModels;
|
|
1542
|
+
if (typeof models === "function") this.documentModels = models;
|
|
1543
|
+
else {
|
|
1544
|
+
const copied = [...models ?? []];
|
|
1545
|
+
this.documentModels = () => copied;
|
|
1546
|
+
}
|
|
1413
1547
|
this.signer = options.signer;
|
|
1548
|
+
this.driveIdFor = options.driveIdFor;
|
|
1414
1549
|
this.subscriptionsUrl = options.realtime === false ? void 0 : options.subscriptionsUrl ?? subscriptionsUrlFromGraphqlUrl(options.url);
|
|
1415
|
-
const middleware = makeAuthMiddleware(this.tokenProvider);
|
|
1550
|
+
const middleware = withWrongBackendErrors(makeAuthMiddleware(this.tokenProvider));
|
|
1416
1551
|
this.sdk = options.graphqlClient ?? createClient$1(options.url, middleware);
|
|
1417
1552
|
this.subgraphs = new SubgraphSdkRegistry(options.url, middleware);
|
|
1418
1553
|
}
|
|
@@ -1425,6 +1560,26 @@ var GraphQLReactorClient = class {
|
|
|
1425
1560
|
if (!document) throw new Error(`Document not found: ${identifier}`);
|
|
1426
1561
|
return phDocumentFromGetDocument(document.document, view?.branch);
|
|
1427
1562
|
}
|
|
1563
|
+
/**
|
|
1564
|
+
* Whether the Switchboard would serve the document to this client's caller,
|
|
1565
|
+
* from its `documentServed` query: the same read gate `find` passes. Absent
|
|
1566
|
+
* or withheld is `false`; a failure to decide throws.
|
|
1567
|
+
*
|
|
1568
|
+
* A point-in-time view throws {@link GraphQLOperationNotSupportedError}, as
|
|
1569
|
+
* does a Switchboard without the query.
|
|
1570
|
+
*/
|
|
1571
|
+
async isServed(identifier, view, signal) {
|
|
1572
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1573
|
+
try {
|
|
1574
|
+
return (await this.sdk.GetDocumentServed({
|
|
1575
|
+
idOrSlug: identifier,
|
|
1576
|
+
view: viewInput
|
|
1577
|
+
}, void 0, signal)).documentServed;
|
|
1578
|
+
} catch (error) {
|
|
1579
|
+
if (queriesUnknownField(error, "documentServed")) throw new GraphQLOperationNotSupportedError("isServed", "the Switchboard predates the documentServed query");
|
|
1580
|
+
throw error;
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1428
1583
|
async getOperations(documentIdentifier, view, filter, paging, signal) {
|
|
1429
1584
|
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1430
1585
|
const operationsFilter = {
|
|
@@ -1446,18 +1601,105 @@ var GraphQLReactorClient = class {
|
|
|
1446
1601
|
results: page.items.map((item) => remoteOperationToLocal(item)),
|
|
1447
1602
|
options: effectivePaging,
|
|
1448
1603
|
nextCursor,
|
|
1449
|
-
totalCount: page.totalCount,
|
|
1450
1604
|
next: nextCursor ? () => this.getOperations(documentIdentifier, view, filter, {
|
|
1451
1605
|
cursor: nextCursor,
|
|
1452
1606
|
limit: effectivePaging.limit
|
|
1453
1607
|
}, signal) : void 0
|
|
1454
1608
|
};
|
|
1455
1609
|
}
|
|
1610
|
+
/**
|
|
1611
|
+
* Filters documents by criteria over the Switchboard's `findDocuments` query.
|
|
1612
|
+
*
|
|
1613
|
+
* The query filters by `type` and `parentId` only, at head. A search naming
|
|
1614
|
+
* `ids` or `slugs` (present, whatever its length) and a point-in-time view are
|
|
1615
|
+
* each by-contract limitations the query cannot express -- running it anyway
|
|
1616
|
+
* would return every document instead of the named ones, or head instead of
|
|
1617
|
+
* the asked-for revision, a silently wrong answer. {@link findIsServableOverGraphQL}
|
|
1618
|
+
* is the single predicate that decides this, and an unservable `find` throws
|
|
1619
|
+
* {@link GraphQLOperationNotSupportedError}. Drive enumeration itself filters
|
|
1620
|
+
* by `type` at head, which is served.
|
|
1621
|
+
*/
|
|
1622
|
+
async find(search, view, paging, signal) {
|
|
1623
|
+
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");
|
|
1624
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1625
|
+
const effectivePaging = paging ?? defaultPaging;
|
|
1626
|
+
const result = await this.sdk.FindDocuments({
|
|
1627
|
+
search: {
|
|
1628
|
+
type: search.type,
|
|
1629
|
+
parentId: search.parentId
|
|
1630
|
+
},
|
|
1631
|
+
view: viewInput,
|
|
1632
|
+
paging: pagingInputFromPaging(effectivePaging)
|
|
1633
|
+
}, search.parentId === void 0 ? void 0 : this.driveIdHeaders({
|
|
1634
|
+
method: "find",
|
|
1635
|
+
parentId: search.parentId
|
|
1636
|
+
}), signal);
|
|
1637
|
+
return this.toDocumentResults(result.findDocuments, effectivePaging, view?.branch, (cursor, limit) => this.find(search, view, {
|
|
1638
|
+
cursor,
|
|
1639
|
+
limit
|
|
1640
|
+
}, signal));
|
|
1641
|
+
}
|
|
1642
|
+
async getOutgoingRelationships(sourceIdentifier, relationshipType, view, paging, signal) {
|
|
1643
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1644
|
+
const result = await this.sdk.GetDocumentOutgoingRelationships({
|
|
1645
|
+
sourceIdentifier,
|
|
1646
|
+
relationshipType,
|
|
1647
|
+
view: viewInput,
|
|
1648
|
+
paging: pagingInputFromPaging(paging)
|
|
1649
|
+
}, void 0, signal);
|
|
1650
|
+
return this.toDocumentResults(result.documentOutgoingRelationships, paging ?? defaultPaging, view?.branch, (cursor, limit) => this.getOutgoingRelationships(sourceIdentifier, relationshipType, view, {
|
|
1651
|
+
cursor,
|
|
1652
|
+
limit
|
|
1653
|
+
}, signal));
|
|
1654
|
+
}
|
|
1655
|
+
async getIncomingRelationships(targetIdentifier, relationshipType, view, paging, signal) {
|
|
1656
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1657
|
+
const result = await this.sdk.GetDocumentIncomingRelationships({
|
|
1658
|
+
targetIdentifier,
|
|
1659
|
+
relationshipType,
|
|
1660
|
+
view: viewInput,
|
|
1661
|
+
paging: pagingInputFromPaging(paging)
|
|
1662
|
+
}, void 0, signal);
|
|
1663
|
+
return this.toDocumentResults(result.documentIncomingRelationships, paging ?? defaultPaging, view?.branch, (cursor, limit) => this.getIncomingRelationships(targetIdentifier, relationshipType, view, {
|
|
1664
|
+
cursor,
|
|
1665
|
+
limit
|
|
1666
|
+
}, signal));
|
|
1667
|
+
}
|
|
1668
|
+
async getOutgoingRelationshipEdges(sourceIdentifier, relationshipType, view, paging, signal) {
|
|
1669
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1670
|
+
const result = await this.sdk.GetDocumentOutgoingRelationshipEdges({
|
|
1671
|
+
sourceIdentifier,
|
|
1672
|
+
relationshipType,
|
|
1673
|
+
view: viewInput,
|
|
1674
|
+
paging: pagingInputFromPaging(paging)
|
|
1675
|
+
}, void 0, signal);
|
|
1676
|
+
return this.toRelationshipResults(result.documentOutgoingRelationshipEdges, paging ?? defaultPaging, (cursor, limit) => this.getOutgoingRelationshipEdges(sourceIdentifier, relationshipType, view, {
|
|
1677
|
+
cursor,
|
|
1678
|
+
limit
|
|
1679
|
+
}, signal));
|
|
1680
|
+
}
|
|
1681
|
+
async getIncomingRelationshipEdges(targetIdentifier, relationshipType, view, paging, signal) {
|
|
1682
|
+
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1683
|
+
const result = await this.sdk.GetDocumentIncomingRelationshipEdges({
|
|
1684
|
+
targetIdentifier,
|
|
1685
|
+
relationshipType,
|
|
1686
|
+
view: viewInput,
|
|
1687
|
+
paging: pagingInputFromPaging(paging)
|
|
1688
|
+
}, void 0, signal);
|
|
1689
|
+
return this.toRelationshipResults(result.documentIncomingRelationshipEdges, paging ?? defaultPaging, (cursor, limit) => this.getIncomingRelationshipEdges(targetIdentifier, relationshipType, view, {
|
|
1690
|
+
cursor,
|
|
1691
|
+
limit
|
|
1692
|
+
}, signal));
|
|
1693
|
+
}
|
|
1456
1694
|
async create(document, parentIdentifier, signal) {
|
|
1457
1695
|
const created = phDocumentFromGetDocument((await this.sdk.CreateDocument({
|
|
1458
1696
|
document,
|
|
1459
1697
|
parentIdentifier
|
|
1460
|
-
},
|
|
1698
|
+
}, this.driveIdHeaders({
|
|
1699
|
+
method: "create",
|
|
1700
|
+
documentId: document.header.id || void 0,
|
|
1701
|
+
parentId: parentIdentifier
|
|
1702
|
+
}, isDrive(document) && parentIdentifier === void 0 ? document.header.id : void 0), signal)).createDocument);
|
|
1461
1703
|
this.emitChange({
|
|
1462
1704
|
type: DOCUMENT_CHANGE_TYPE.Created,
|
|
1463
1705
|
documents: [created]
|
|
@@ -1485,7 +1727,7 @@ var GraphQLReactorClient = class {
|
|
|
1485
1727
|
const document = await this.get(documentIdentifier, { branch }, signal);
|
|
1486
1728
|
const variables = {
|
|
1487
1729
|
documentIdentifier,
|
|
1488
|
-
actions: (await prepareActionsForPush(actions, document, this.documentModels, this.signer, signal)).map(toTransportAction),
|
|
1730
|
+
actions: (await prepareActionsForPush(actions, document, this.documentModels(), this.signer, signal)).map(toTransportAction),
|
|
1489
1731
|
sinceRevision: sinceRevisionForActions(document, actions),
|
|
1490
1732
|
scopes: scopesForActions(actions),
|
|
1491
1733
|
branch
|
|
@@ -1495,6 +1737,10 @@ var GraphQLReactorClient = class {
|
|
|
1495
1737
|
operationType: "mutation",
|
|
1496
1738
|
document: MutateDocumentWithOperationsDocument,
|
|
1497
1739
|
variables,
|
|
1740
|
+
requestHeaders: this.driveIdHeaders({
|
|
1741
|
+
method: "execute",
|
|
1742
|
+
documentId: documentIdentifier
|
|
1743
|
+
}, isDrive(document) ? document.header.id : void 0),
|
|
1498
1744
|
signal
|
|
1499
1745
|
})).mutateDocument;
|
|
1500
1746
|
const updated = phDocumentFromMutation(mutated, mutated.operations?.items ?? [], branch);
|
|
@@ -1505,6 +1751,210 @@ var GraphQLReactorClient = class {
|
|
|
1505
1751
|
return updated;
|
|
1506
1752
|
}
|
|
1507
1753
|
/**
|
|
1754
|
+
* Runs multiple mutation jobs in dependency order over the Switchboard's
|
|
1755
|
+
* `executeBatch` mutation and waits for all to settle, returning the result
|
|
1756
|
+
* shaped like `IReactor.executeBatch`'s so the reference `DriveClient`
|
|
1757
|
+
* consumes it unchanged.
|
|
1758
|
+
*
|
|
1759
|
+
* Not atomic: each job commits on its own and a failed job still releases
|
|
1760
|
+
* its dependents. A FAILED job throws {@link BatchJobFailedError}, naming the
|
|
1761
|
+
* first failed plan key and carrying every job's final state.
|
|
1762
|
+
*
|
|
1763
|
+
* Each job's actions are signed independently for the job's own
|
|
1764
|
+
* `(documentId, branch)` target -- the per-action signing the reactor's own
|
|
1765
|
+
* `signActions` does, not the batch state-prediction `execute` uses for a
|
|
1766
|
+
* multi-action push. A drive job such as `addFile`'s is `CREATE_DOCUMENT` +
|
|
1767
|
+
* `UPGRADE_DOCUMENT` + `ADD_RELATIONSHIP`, which the prediction path rejects
|
|
1768
|
+
* outright and which has no fetchable baseline to stamp against. The reactor
|
|
1769
|
+
* records but does not verify the stamped previous-state head, so signing
|
|
1770
|
+
* each action bare is exactly what the in-process `DriveClient` relies on.
|
|
1771
|
+
*
|
|
1772
|
+
* The mutation is synchronous server-side: a job it returns is already
|
|
1773
|
+
* settled, so {@link waitForJob} resolves from it without polling.
|
|
1774
|
+
*/
|
|
1775
|
+
async executeBatch(request, signal) {
|
|
1776
|
+
const signer = this.signer ?? resolveAmbientSigner();
|
|
1777
|
+
const jobInputs = await Promise.all(request.jobs.map(async (job, index) => {
|
|
1778
|
+
const documentId = await this.batchWriteTarget(job, request.jobs.slice(0, index), signer, signal);
|
|
1779
|
+
const actions = await this.signBatchJobActions({
|
|
1780
|
+
...job,
|
|
1781
|
+
documentId
|
|
1782
|
+
}, signer, signal);
|
|
1783
|
+
return {
|
|
1784
|
+
key: job.key,
|
|
1785
|
+
documentIdOrSlug: documentId,
|
|
1786
|
+
scope: job.scope,
|
|
1787
|
+
branch: job.branch,
|
|
1788
|
+
actions: actions.map(toTransportAction),
|
|
1789
|
+
dependsOn: job.dependsOn
|
|
1790
|
+
};
|
|
1791
|
+
}));
|
|
1792
|
+
const result = await this.sdk.ExecuteBatch({ jobs: jobInputs }, this.driveIdHeaders({
|
|
1793
|
+
method: "executeBatch",
|
|
1794
|
+
jobs: jobInputs.map((job) => ({ documentId: job.documentIdOrSlug }))
|
|
1795
|
+
}), signal);
|
|
1796
|
+
const jobs = {};
|
|
1797
|
+
for (const entry of result.executeBatch.jobs) jobs[entry.key] = jobInfoFromGql(entry.job);
|
|
1798
|
+
await this.announceBatch(request, jobs, signal);
|
|
1799
|
+
const failed = request.jobs.find((job) => jobs[job.key]?.status === "FAILED");
|
|
1800
|
+
if (failed) throw new BatchJobFailedError(failed.key, jobs);
|
|
1801
|
+
return { jobs };
|
|
1802
|
+
}
|
|
1803
|
+
/** The job as `jobStatus` reports it now; `undefined` when it reports none. */
|
|
1804
|
+
async getJob(jobId, signal) {
|
|
1805
|
+
const result = await this.sdk.GetJobStatus({ jobId }, void 0, signal);
|
|
1806
|
+
return result.jobStatus ? jobInfoFromGql(result.jobStatus) : void 0;
|
|
1807
|
+
}
|
|
1808
|
+
/** Polls `jobStatus` until the job is READ_READY or FAILED. */
|
|
1809
|
+
async waitForJob(jobOrId, signal) {
|
|
1810
|
+
if (typeof jobOrId !== "string" && isSettled(jobOrId)) return jobOrId;
|
|
1811
|
+
const jobId = typeof jobOrId === "string" ? jobOrId : jobOrId.id;
|
|
1812
|
+
for (;;) {
|
|
1813
|
+
const result = await this.sdk.GetJobStatus({ jobId }, void 0, signal);
|
|
1814
|
+
if (!result.jobStatus) throw new Error(`Job not found: ${jobId}`);
|
|
1815
|
+
const job = jobInfoFromGql(result.jobStatus);
|
|
1816
|
+
if (isSettled(job)) return job;
|
|
1817
|
+
await delay(JOB_POLL_INTERVAL_MS, signal);
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
/**
|
|
1821
|
+
* The policy the Switchboard gives a new document, read from its
|
|
1822
|
+
* `createDefaults` query. A Switchboard without that query is refused with
|
|
1823
|
+
* {@link GraphQLOperationNotSupportedError}: a guessed default would
|
|
1824
|
+
* under-sign on a stricter host.
|
|
1825
|
+
*/
|
|
1826
|
+
async getCreateSignaturePolicy() {
|
|
1827
|
+
return (await this.createDefaults("getCreateSignaturePolicy")).signaturePolicy;
|
|
1828
|
+
}
|
|
1829
|
+
/**
|
|
1830
|
+
* The protocol versions the Switchboard selects for a new document under
|
|
1831
|
+
* `parentIdentifier`, read from its `createDefaults` query. A parent the
|
|
1832
|
+
* caller may not read is refused by the server, never answered as if none
|
|
1833
|
+
* was named; a Switchboard without the query is refused with
|
|
1834
|
+
* {@link GraphQLOperationNotSupportedError}.
|
|
1835
|
+
*/
|
|
1836
|
+
async getCreateProtocolVersions(parentIdentifier, signal) {
|
|
1837
|
+
return (await this.createDefaults("getCreateProtocolVersions", parentIdentifier, signal)).protocolVersions;
|
|
1838
|
+
}
|
|
1839
|
+
async createDefaults(operation, parentIdOrSlug, signal) {
|
|
1840
|
+
let result;
|
|
1841
|
+
try {
|
|
1842
|
+
result = await this.sdk.GetCreateDefaults({ parentIdOrSlug }, void 0, signal);
|
|
1843
|
+
} catch (error) {
|
|
1844
|
+
if (queriesUnknownField(error, "createDefaults")) throw new GraphQLOperationNotSupportedError(operation, "the Switchboard predates the createDefaults query");
|
|
1845
|
+
throw error;
|
|
1846
|
+
}
|
|
1847
|
+
const { signaturePolicy, protocolVersions } = result.createDefaults;
|
|
1848
|
+
if (!isSignaturePolicy(signaturePolicy)) throw new Error(`The Switchboard answered an unknown create signature policy: ${signaturePolicy}`);
|
|
1849
|
+
return {
|
|
1850
|
+
signaturePolicy,
|
|
1851
|
+
protocolVersions: protocolVersionsFrom(protocolVersions)
|
|
1852
|
+
};
|
|
1853
|
+
}
|
|
1854
|
+
/**
|
|
1855
|
+
* Sets or, with `null`, clears the preferred editor as a client-signed
|
|
1856
|
+
* action, as the in-process client does.
|
|
1857
|
+
*/
|
|
1858
|
+
setPreferredEditor(documentIdentifier, preferredEditor, branch = "main", signal) {
|
|
1859
|
+
return this.execute(documentIdentifier, branch, [actions.setPreferredEditor(preferredEditor)], signal);
|
|
1860
|
+
}
|
|
1861
|
+
/** The `Drive-Id` header for a call: the client's own proof, else the hook's. */
|
|
1862
|
+
driveIdHeaders(call, proven) {
|
|
1863
|
+
const hinted = this.driveIdFor?.(call);
|
|
1864
|
+
if (proven) {
|
|
1865
|
+
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);
|
|
1866
|
+
return driveIdHeaders(proven);
|
|
1867
|
+
}
|
|
1868
|
+
return hinted ? driveIdHeaders(hinted) : void 0;
|
|
1869
|
+
}
|
|
1870
|
+
/**
|
|
1871
|
+
* Emits the changes the batch's settled jobs made, as `create` and `execute`
|
|
1872
|
+
* do, so a cache is invalidated without a realtime socket. The documents a
|
|
1873
|
+
* job wrote to are its own and those its consistency token names.
|
|
1874
|
+
*/
|
|
1875
|
+
async announceBatch(request, jobs, signal) {
|
|
1876
|
+
if (this.listeners.length === 0) return;
|
|
1877
|
+
const deleted = /* @__PURE__ */ new Set();
|
|
1878
|
+
const created = /* @__PURE__ */ new Map();
|
|
1879
|
+
const touched = /* @__PURE__ */ new Map();
|
|
1880
|
+
const keyOf = (written) => `${written.branch}\u0000${written.documentId}`;
|
|
1881
|
+
for (const job of request.jobs) {
|
|
1882
|
+
const info = jobs[job.key];
|
|
1883
|
+
if (!info || info.status !== "READ_READY") continue;
|
|
1884
|
+
const types = new Set(job.actions.map((action) => action.type));
|
|
1885
|
+
if (types.has("DELETE_DOCUMENT")) {
|
|
1886
|
+
deleted.add(info.documentId);
|
|
1887
|
+
continue;
|
|
1888
|
+
}
|
|
1889
|
+
const own = {
|
|
1890
|
+
documentId: info.documentId,
|
|
1891
|
+
branch: job.branch
|
|
1892
|
+
};
|
|
1893
|
+
if (types.has("CREATE_DOCUMENT")) created.set(keyOf(own), own);
|
|
1894
|
+
touched.set(keyOf(own), own);
|
|
1895
|
+
for (const { documentId, branch } of info.consistencyToken.coordinates) touched.set(keyOf({
|
|
1896
|
+
documentId,
|
|
1897
|
+
branch
|
|
1898
|
+
}), {
|
|
1899
|
+
documentId,
|
|
1900
|
+
branch
|
|
1901
|
+
});
|
|
1902
|
+
}
|
|
1903
|
+
for (const documentId of deleted) this.emitChange({
|
|
1904
|
+
type: DOCUMENT_CHANGE_TYPE.Deleted,
|
|
1905
|
+
documents: [],
|
|
1906
|
+
context: { childId: documentId }
|
|
1907
|
+
});
|
|
1908
|
+
const read = async ({ documentId, branch }) => {
|
|
1909
|
+
try {
|
|
1910
|
+
return await this.get(documentId, { branch }, signal);
|
|
1911
|
+
} catch (error) {
|
|
1912
|
+
logger.warn("GraphQLReactorClient: could not read @documentId on @branch to announce a batch change: @error", documentId, branch, error);
|
|
1913
|
+
return;
|
|
1914
|
+
}
|
|
1915
|
+
};
|
|
1916
|
+
const readAll = async (written) => (await Promise.all(written.map(read))).filter((document) => document !== void 0);
|
|
1917
|
+
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))]);
|
|
1918
|
+
if (createdDocuments.length > 0) this.emitChange({
|
|
1919
|
+
type: DOCUMENT_CHANGE_TYPE.Created,
|
|
1920
|
+
documents: createdDocuments
|
|
1921
|
+
});
|
|
1922
|
+
if (updatedDocuments.length > 0) this.emitChange({
|
|
1923
|
+
type: DOCUMENT_CHANGE_TYPE.Updated,
|
|
1924
|
+
documents: updatedDocuments
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
/**
|
|
1928
|
+
* The id a job's actions are signed for: a signature covers the document id,
|
|
1929
|
+
* and the server resolves a slug before verifying. A document created by this
|
|
1930
|
+
* job or an earlier one is named by its id. When the server has no such
|
|
1931
|
+
* document the identifier is used as given, and the server decides; any
|
|
1932
|
+
* other failure to read it throws, so nothing is signed for a slug.
|
|
1933
|
+
*/
|
|
1934
|
+
async batchWriteTarget(job, earlier, signer, signal) {
|
|
1935
|
+
const creates = (plan) => plan.documentId === job.documentId && plan.actions.some((action) => action.type === "CREATE_DOCUMENT");
|
|
1936
|
+
if (!signer || job.actions.every(isActionSigned) || creates(job) || earlier.some(creates)) return job.documentId;
|
|
1937
|
+
return (await this.sdk.GetDocument({
|
|
1938
|
+
identifier: job.documentId,
|
|
1939
|
+
view: viewFilterInputFromViewFilter({ branch: job.branch })
|
|
1940
|
+
}, void 0, signal)).document?.document.id ?? job.documentId;
|
|
1941
|
+
}
|
|
1942
|
+
/**
|
|
1943
|
+
* Signs one batch job's actions for the job's own log.
|
|
1944
|
+
*
|
|
1945
|
+
* Each action is signed on its own for `(documentId, branch)`, the same
|
|
1946
|
+
* per-action signing the reactor's `signActions` does: no state prediction
|
|
1947
|
+
* across the job, so a job carrying a `CREATE_DOCUMENT` the push-prediction
|
|
1948
|
+
* path rejects still signs. An action already signed under a key is left
|
|
1949
|
+
* as it is: the reference `DriveClient` signs its jobs before handing them
|
|
1950
|
+
* here. With no signer the actions pass through unsigned, matching
|
|
1951
|
+
* {@link execute}.
|
|
1952
|
+
*/
|
|
1953
|
+
async signBatchJobActions(job, signer, signal) {
|
|
1954
|
+
if (!signer) return job.actions;
|
|
1955
|
+
return Promise.all(job.actions.map((action) => isActionSigned(action) ? Promise.resolve(action) : signStampedAction(action, signer, actionSigningTarget(action, job.documentId, job.branch), signal)));
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1508
1958
|
* Deletes a document and announces it as a `Deleted` event.
|
|
1509
1959
|
*
|
|
1510
1960
|
* Pass a document id. The server resolves a slug just as happily, but
|
|
@@ -1517,7 +1967,10 @@ var GraphQLReactorClient = class {
|
|
|
1517
1967
|
await this.sdk.DeleteDocument({
|
|
1518
1968
|
identifier,
|
|
1519
1969
|
propagate: propagationModeInput(propagate)
|
|
1520
|
-
},
|
|
1970
|
+
}, this.driveIdHeaders({
|
|
1971
|
+
method: "deleteDocument",
|
|
1972
|
+
documentId: identifier
|
|
1973
|
+
}), signal);
|
|
1521
1974
|
this.emitChange({
|
|
1522
1975
|
type: DOCUMENT_CHANGE_TYPE.Deleted,
|
|
1523
1976
|
documents: [],
|
|
@@ -1613,6 +2066,35 @@ var GraphQLReactorClient = class {
|
|
|
1613
2066
|
});
|
|
1614
2067
|
}
|
|
1615
2068
|
/**
|
|
2069
|
+
* Shapes a document result page into the reactor's {@link PagedResults}.
|
|
2070
|
+
*
|
|
2071
|
+
* The items carry the same `PHDocumentFields` fragment as `get`, so the same
|
|
2072
|
+
* adapter rebuilds each one. `hasNextPage` gates the cursor exactly as
|
|
2073
|
+
* `getOperations` does: no cursor means no `next`.
|
|
2074
|
+
*/
|
|
2075
|
+
toDocumentResults(page, effectivePaging, branch, next) {
|
|
2076
|
+
const nextCursor = page.hasNextPage ? page.cursor ?? void 0 : void 0;
|
|
2077
|
+
return {
|
|
2078
|
+
results: page.items.map((item) => phDocumentFromGetDocument(item, branch)),
|
|
2079
|
+
options: effectivePaging,
|
|
2080
|
+
nextCursor,
|
|
2081
|
+
next: nextCursor ? () => next(nextCursor, effectivePaging.limit) : void 0
|
|
2082
|
+
};
|
|
2083
|
+
}
|
|
2084
|
+
/**
|
|
2085
|
+
* Shapes a relationship-edge result page into the reactor's
|
|
2086
|
+
* {@link PagedResults}, restoring each edge's `Date` fields.
|
|
2087
|
+
*/
|
|
2088
|
+
toRelationshipResults(page, effectivePaging, next) {
|
|
2089
|
+
const nextCursor = page.hasNextPage ? page.cursor ?? void 0 : void 0;
|
|
2090
|
+
return {
|
|
2091
|
+
results: page.items.map((edge) => documentRelationshipFromEdge(edge)),
|
|
2092
|
+
options: effectivePaging,
|
|
2093
|
+
nextCursor,
|
|
2094
|
+
next: nextCursor ? () => next(nextCursor, effectivePaging.limit) : void 0
|
|
2095
|
+
};
|
|
2096
|
+
}
|
|
2097
|
+
/**
|
|
1616
2098
|
* Opens the realtime socket on the first subscriber.
|
|
1617
2099
|
*
|
|
1618
2100
|
* The subscription is a firehose - no `search` argument - and this client
|
|
@@ -1743,13 +2225,13 @@ function isGraphQLReactorClient(client) {
|
|
|
1743
2225
|
}
|
|
1744
2226
|
/** The schema's change types, mapped onto the reactor's. */
|
|
1745
2227
|
const documentChangeTypes = {
|
|
1746
|
-
[
|
|
1747
|
-
[
|
|
1748
|
-
[
|
|
1749
|
-
[
|
|
1750
|
-
[
|
|
1751
|
-
[
|
|
1752
|
-
[
|
|
2228
|
+
["CREATED"]: DOCUMENT_CHANGE_TYPE.Created,
|
|
2229
|
+
["DELETED"]: DOCUMENT_CHANGE_TYPE.Deleted,
|
|
2230
|
+
["UPDATED"]: DOCUMENT_CHANGE_TYPE.Updated,
|
|
2231
|
+
["PARENT_ADDED"]: DOCUMENT_CHANGE_TYPE.ParentAdded,
|
|
2232
|
+
["PARENT_REMOVED"]: DOCUMENT_CHANGE_TYPE.ParentRemoved,
|
|
2233
|
+
["CHILD_ADDED"]: DOCUMENT_CHANGE_TYPE.ChildAdded,
|
|
2234
|
+
["CHILD_REMOVED"]: DOCUMENT_CHANGE_TYPE.ChildRemoved
|
|
1753
2235
|
};
|
|
1754
2236
|
/**
|
|
1755
2237
|
* Decides whether an event reaches a subscriber.
|
|
@@ -1784,7 +2266,7 @@ function eventMatchesSearch(event, search) {
|
|
|
1784
2266
|
*/
|
|
1785
2267
|
function viewFilterInputFromViewFilter(view) {
|
|
1786
2268
|
if (!view) return;
|
|
1787
|
-
if (view
|
|
2269
|
+
if (viewIsPointInTime(view)) throw new GraphQLOperationNotSupportedError("view", "point-in-time views are not supported by GraphQLReactorClient");
|
|
1788
2270
|
if (view.branch === void 0 && view.scopes === void 0) return;
|
|
1789
2271
|
return {
|
|
1790
2272
|
branch: view.branch,
|
|
@@ -1799,13 +2281,78 @@ function pagingInputFromPaging(paging) {
|
|
|
1799
2281
|
};
|
|
1800
2282
|
}
|
|
1801
2283
|
/**
|
|
2284
|
+
* Whether a search names `ids` or `slugs`, which the Switchboard `findDocuments`
|
|
2285
|
+
* query cannot honour (it filters by `type` and `parentId`).
|
|
2286
|
+
*
|
|
2287
|
+
* The test is PRESENCE, not length: the reactor `find` contract
|
|
2288
|
+
* (`packages/reactor/src/core/reactor.ts`) dispatches on `search.ids` /
|
|
2289
|
+
* `search.slugs` being present, so `find({ ids: [] })` is an identifier search
|
|
2290
|
+
* that must yield the empty set -- not a plain type query over every document.
|
|
2291
|
+
* The GraphQL surface cannot express an identifier search at all, so a present
|
|
2292
|
+
* (even empty) `ids`/`slugs` is refused rather than served as the wrong query.
|
|
2293
|
+
*/
|
|
2294
|
+
function searchNamesIdentifiers(search) {
|
|
2295
|
+
return search.ids !== void 0 || search.slugs !== void 0;
|
|
2296
|
+
}
|
|
2297
|
+
/** Whether a view asks for a point-in-time read the GraphQL surface cannot express. */
|
|
2298
|
+
function viewIsPointInTime(view) {
|
|
2299
|
+
return view?.revision !== void 0;
|
|
2300
|
+
}
|
|
2301
|
+
/**
|
|
2302
|
+
* The single source of truth for whether the Switchboard `findDocuments` query
|
|
2303
|
+
* can serve a `find`. It is servable iff the search names neither `ids` nor
|
|
2304
|
+
* `slugs` (present, regardless of length) AND the view is not point-in-time:
|
|
2305
|
+
* each is a by-contract limitation of a surface that filters only by
|
|
2306
|
+
* `type`/`parentId` at head. Exported so a caller can route around an
|
|
2307
|
+
* unservable search instead of catching the error `find` throws for it.
|
|
2308
|
+
*/
|
|
2309
|
+
function findIsServableOverGraphQL(search, view) {
|
|
2310
|
+
return !searchNamesIdentifiers(search) && !viewIsPointInTime(view);
|
|
2311
|
+
}
|
|
2312
|
+
/** Rebuilds a relationship edge from its GraphQL fields. */
|
|
2313
|
+
function documentRelationshipFromEdge(edge) {
|
|
2314
|
+
const relationship = {
|
|
2315
|
+
sourceId: edge.sourceId,
|
|
2316
|
+
targetId: edge.targetId,
|
|
2317
|
+
relationshipType: edge.relationshipType,
|
|
2318
|
+
createdAt: dateFromDateTime(edge.createdAt),
|
|
2319
|
+
updatedAt: dateFromDateTime(edge.updatedAt)
|
|
2320
|
+
};
|
|
2321
|
+
const metadata = edge.metadata;
|
|
2322
|
+
if (isPlainObject(metadata)) relationship.metadata = metadata;
|
|
2323
|
+
return relationship;
|
|
2324
|
+
}
|
|
2325
|
+
/**
|
|
2326
|
+
* Restores a `Date` from the `DateTime` scalar, which deserializes as either an
|
|
2327
|
+
* ISO string or a `Date`, reusing the get-path's {@link isoStringFromDateTime}.
|
|
2328
|
+
*
|
|
2329
|
+
* A null, absent or unparseable value is a malformed timestamp from the server,
|
|
2330
|
+
* not something to coerce to the epoch or an `Invalid Date`: it throws, so the
|
|
2331
|
+
* malformed edge surfaces as a genuine failure rather than a silently-wrong
|
|
2332
|
+
* `DocumentRelationship`.
|
|
2333
|
+
*/
|
|
2334
|
+
function dateFromDateTime(value) {
|
|
2335
|
+
if (value === null || value === void 0) throw new Error("relationship edge is missing a required DateTime timestamp");
|
|
2336
|
+
const date = new Date(isoStringFromDateTime(value));
|
|
2337
|
+
if (Number.isNaN(date.getTime())) throw new Error(`relationship edge carries an unparseable DateTime timestamp: ${String(value)}`);
|
|
2338
|
+
return date;
|
|
2339
|
+
}
|
|
2340
|
+
/**
|
|
2341
|
+
* Whether a JSON value is a plain object, so relationship `metadata` is assigned
|
|
2342
|
+
* only when it is one. A non-object JSON scalar (string, number, array, null)
|
|
2343
|
+
* is dropped exactly as a null is, rather than cast to `Record` and trusted.
|
|
2344
|
+
*/
|
|
2345
|
+
function isPlainObject(value) {
|
|
2346
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2347
|
+
}
|
|
2348
|
+
/**
|
|
1802
2349
|
* The reactor and the GraphQL schema disagree on the enum: the reactor's
|
|
1803
2350
|
* `None` is the schema's `ORPHAN`. This is the inverse of the server's
|
|
1804
2351
|
* `toReactorPropagationMode`.
|
|
1805
2352
|
*/
|
|
1806
2353
|
const propagationModeInputs = {
|
|
1807
|
-
cascade:
|
|
1808
|
-
none:
|
|
2354
|
+
cascade: "CASCADE",
|
|
2355
|
+
none: "ORPHAN"
|
|
1809
2356
|
};
|
|
1810
2357
|
function propagationModeInput(propagate) {
|
|
1811
2358
|
return propagate === void 0 ? void 0 : propagationModeInputs[propagate];
|
|
@@ -1841,6 +2388,123 @@ function documentModelVersion(document) {
|
|
|
1841
2388
|
const documentScope = document.state.document;
|
|
1842
2389
|
return normalizeDocumentModelVersion(documentScope?.version);
|
|
1843
2390
|
}
|
|
2391
|
+
/**
|
|
2392
|
+
* Rebuilds a reactor {@link JobInfo} from what the server reported. An unknown
|
|
2393
|
+
* job arrives as the reactor's own: FAILED with an empty `documentId`.
|
|
2394
|
+
*/
|
|
2395
|
+
function jobInfoFromGql(job) {
|
|
2396
|
+
const token = job.consistencyToken;
|
|
2397
|
+
if (token.version !== 1) throw new Error(`Job ${job.id} carries consistency token version ${token.version}, which this client cannot read`);
|
|
2398
|
+
const info = {
|
|
2399
|
+
id: job.id,
|
|
2400
|
+
documentId: job.documentId,
|
|
2401
|
+
status: job.status,
|
|
2402
|
+
createdAtUtcIso: isoStringFromDateTime(job.createdAt),
|
|
2403
|
+
consistencyToken: {
|
|
2404
|
+
version: 1,
|
|
2405
|
+
createdAtUtcIso: token.createdAtUtcIso,
|
|
2406
|
+
coordinates: token.coordinates.map((coordinate) => ({ ...coordinate }))
|
|
2407
|
+
},
|
|
2408
|
+
meta: {
|
|
2409
|
+
batchId: job.meta.batchId,
|
|
2410
|
+
batchJobIds: [...job.meta.batchJobIds]
|
|
2411
|
+
}
|
|
2412
|
+
};
|
|
2413
|
+
if (job.completedAt != null) info.completedAtUtcIso = isoStringFromDateTime(job.completedAt);
|
|
2414
|
+
if (job.result != null) info.result = job.result;
|
|
2415
|
+
if (job.error != null) info.error = {
|
|
2416
|
+
name: job.errorName ?? "Error",
|
|
2417
|
+
message: job.error,
|
|
2418
|
+
stack: ""
|
|
2419
|
+
};
|
|
2420
|
+
return info;
|
|
2421
|
+
}
|
|
2422
|
+
/**
|
|
2423
|
+
* Whether a request failed because the server's schema has no such root field:
|
|
2424
|
+
* a Switchboard older than the field. graphql-js validation words this the same
|
|
2425
|
+
* under every gateway the Switchboard can run.
|
|
2426
|
+
*/
|
|
2427
|
+
function queriesUnknownField(error, field) {
|
|
2428
|
+
const errors = error?.response?.errors;
|
|
2429
|
+
if (!Array.isArray(errors)) return false;
|
|
2430
|
+
const prefix = `Cannot query field "${field}" on type "`;
|
|
2431
|
+
return errors.some((entry) => typeof entry?.message === "string" && entry.message.startsWith(prefix));
|
|
2432
|
+
}
|
|
2433
|
+
/**
|
|
2434
|
+
* The header a Switchboard's drive middleware and load balancer key on. A
|
|
2435
|
+
* request carries it only when it is known to belong to that one drive: the
|
|
2436
|
+
* server answers any drive it does not own with 421.
|
|
2437
|
+
*/
|
|
2438
|
+
const DRIVE_ID_HEADER = "Drive-Id";
|
|
2439
|
+
function driveIdHeaders(driveId) {
|
|
2440
|
+
return driveId === "" ? void 0 : { [DRIVE_ID_HEADER]: driveId };
|
|
2441
|
+
}
|
|
2442
|
+
function isDrive(document) {
|
|
2443
|
+
return DRIVE_DOCUMENT_TYPES.includes(document.header.documentType);
|
|
2444
|
+
}
|
|
2445
|
+
/**
|
|
2446
|
+
* Surfaces a 421 from the Switchboard's drive middleware, which graphql-request
|
|
2447
|
+
* reports as a `ClientError`, as {@link GraphQLWrongBackendError}.
|
|
2448
|
+
*/
|
|
2449
|
+
function withWrongBackendErrors(middleware) {
|
|
2450
|
+
return async (action, ...rest) => {
|
|
2451
|
+
try {
|
|
2452
|
+
return await middleware(action, ...rest);
|
|
2453
|
+
} catch (error) {
|
|
2454
|
+
throw wrongBackendErrorOf(error) ?? error;
|
|
2455
|
+
}
|
|
2456
|
+
};
|
|
2457
|
+
}
|
|
2458
|
+
function wrongBackendErrorOf(error) {
|
|
2459
|
+
const response = error?.response;
|
|
2460
|
+
if (response?.status !== 421) return;
|
|
2461
|
+
let payload = response.body;
|
|
2462
|
+
if (typeof payload === "string") try {
|
|
2463
|
+
payload = JSON.parse(payload);
|
|
2464
|
+
} catch {}
|
|
2465
|
+
const driveId = payload?.driveId;
|
|
2466
|
+
return new GraphQLWrongBackendError(typeof driveId === "string" ? driveId : "", payload, { cause: error });
|
|
2467
|
+
}
|
|
2468
|
+
/** Protocol versions as the server sent them; anything but a version map throws. */
|
|
2469
|
+
function protocolVersionsFrom(value) {
|
|
2470
|
+
if (!isPlainObject(value)) throw new Error("The Switchboard answered malformed create protocol versions");
|
|
2471
|
+
const versions = {};
|
|
2472
|
+
for (const [protocol, version] of Object.entries(value)) {
|
|
2473
|
+
if (typeof version !== "number" || !Number.isInteger(version)) throw new Error(`The Switchboard answered a malformed version for protocol ${protocol}`);
|
|
2474
|
+
versions[protocol] = version;
|
|
2475
|
+
}
|
|
2476
|
+
return versions;
|
|
2477
|
+
}
|
|
2478
|
+
function isSettled(job) {
|
|
2479
|
+
const status = job.status;
|
|
2480
|
+
return status === "READ_READY" || status === "FAILED";
|
|
2481
|
+
}
|
|
2482
|
+
function abortReason(signal) {
|
|
2483
|
+
const reason = signal.reason;
|
|
2484
|
+
return reason instanceof Error ? reason : new Error(String(reason));
|
|
2485
|
+
}
|
|
2486
|
+
function delay(ms, signal) {
|
|
2487
|
+
return new Promise((resolve, reject) => {
|
|
2488
|
+
if (signal?.aborted) {
|
|
2489
|
+
reject(abortReason(signal));
|
|
2490
|
+
return;
|
|
2491
|
+
}
|
|
2492
|
+
const onAbort = () => {
|
|
2493
|
+
clearTimeout(timer);
|
|
2494
|
+
if (signal) reject(abortReason(signal));
|
|
2495
|
+
};
|
|
2496
|
+
const timer = setTimeout(() => {
|
|
2497
|
+
signal?.removeEventListener("abort", onAbort);
|
|
2498
|
+
resolve();
|
|
2499
|
+
}, ms);
|
|
2500
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
2501
|
+
});
|
|
2502
|
+
}
|
|
2503
|
+
/** As the reactor's `signAction` reads it: the last tuple names a key. */
|
|
2504
|
+
function isActionSigned(action) {
|
|
2505
|
+
const signer = action.context?.signer;
|
|
2506
|
+
return Boolean(signer?.app?.key && signer.signatures.at(-1)?.[1]);
|
|
2507
|
+
}
|
|
1844
2508
|
/** Resolves the signer of the logged-in user, if there is one. */
|
|
1845
2509
|
function resolveAmbientSigner() {
|
|
1846
2510
|
if (typeof window === "undefined") return;
|
|
@@ -2265,35 +2929,6 @@ const usePackageDiscoveryService = packageDiscoveryFunctions.useValue;
|
|
|
2265
2929
|
const setPackageDiscoveryService = packageDiscoveryFunctions.setValue;
|
|
2266
2930
|
const addPackageDiscoveryServiceEventHandler = packageDiscoveryFunctions.addEventHandler;
|
|
2267
2931
|
//#endregion
|
|
2268
|
-
//#region src/hooks/reactor.ts
|
|
2269
|
-
const reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
|
|
2270
|
-
const reactorClientEventFunctions = makePHEventFunctions("reactorClient");
|
|
2271
|
-
/** Returns the reactor client module (in-process or worker-backed) */
|
|
2272
|
-
const useReactorClientModule = reactorClientModuleEventFunctions.useValue;
|
|
2273
|
-
/** Sets the reactor client module */
|
|
2274
|
-
const setReactorClientModule = reactorClientModuleEventFunctions.setValue;
|
|
2275
|
-
/** Adds an event handler for the reactor client module */
|
|
2276
|
-
const addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
|
|
2277
|
-
/** Returns the reactor client */
|
|
2278
|
-
const useReactorClient = reactorClientEventFunctions.useValue;
|
|
2279
|
-
/** Sets the reactor client */
|
|
2280
|
-
const setReactorClient = reactorClientEventFunctions.setValue;
|
|
2281
|
-
/** Adds an event handler for the reactor client */
|
|
2282
|
-
const addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
|
|
2283
|
-
const useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
|
|
2284
|
-
const useSyncList = () => {
|
|
2285
|
-
return useSync()?.list() ?? [];
|
|
2286
|
-
};
|
|
2287
|
-
const useModelRegistry = () => useReactorClientModule()?.reactorModule?.documentModelRegistry;
|
|
2288
|
-
const useDatabase = () => {
|
|
2289
|
-
const module = useReactorClientModule();
|
|
2290
|
-
return module?.kind === "browser" ? module.reactorModule?.database : void 0;
|
|
2291
|
-
};
|
|
2292
|
-
const usePGlite = () => {
|
|
2293
|
-
const module = useReactorClientModule();
|
|
2294
|
-
return module?.kind === "browser" ? module.reactorModule?.pg : void 0;
|
|
2295
|
-
};
|
|
2296
|
-
//#endregion
|
|
2297
2932
|
//#region src/hooks/revision-history.ts
|
|
2298
2933
|
const revisionHistoryEventFunctions = makePHEventFunctions("revisionHistoryVisible");
|
|
2299
2934
|
/** Returns whether revision history is visible */
|
|
@@ -2359,6 +2994,7 @@ const phGlobalEventHandlerRegisterFunctions = {
|
|
|
2359
2994
|
...commonGlobalEventHandlerFunctions,
|
|
2360
2995
|
reactorClientModule: addReactorClientModuleEventHandler,
|
|
2361
2996
|
reactorClient: addReactorClientEventHandler,
|
|
2997
|
+
fullReactorClient: addFullReactorClientEventHandler,
|
|
2362
2998
|
attachmentService: addAttachmentServiceEventHandler,
|
|
2363
2999
|
features: addFeaturesEventHandler,
|
|
2364
3000
|
modal: addModalEventHandler,
|
|
@@ -2515,89 +3151,91 @@ function useSwitchboardClient() {
|
|
|
2515
3151
|
}
|
|
2516
3152
|
//#endregion
|
|
2517
3153
|
//#region src/hooks/document-operations.ts
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
const
|
|
2527
|
-
const
|
|
2528
|
-
const
|
|
2529
|
-
globalOperations: [],
|
|
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]);
|
|
3154
|
+
const DEFAULT_LIMIT = 100;
|
|
3155
|
+
function toError(reason) {
|
|
3156
|
+
return reason instanceof Error ? reason : new Error(String(reason));
|
|
3157
|
+
}
|
|
3158
|
+
const EMPTY_OPERATIONS = [];
|
|
3159
|
+
function useScopeOperations(documentId, scope, options = {}) {
|
|
3160
|
+
const { limit = DEFAULT_LIMIT, enabled = true } = options;
|
|
3161
|
+
const documentCache = useDocumentCache();
|
|
3162
|
+
const cache = documentCache && isOperationCache(documentCache) ? documentCache : void 0;
|
|
3163
|
+
const activeId = enabled && cache && documentId ? documentId : void 0;
|
|
3164
|
+
const entry = useSyncExternalStore((onChange) => activeId && cache ? cache.subscribeOperations(activeId, onChange) : () => {}, () => activeId && cache ? cache.getOperationsState(activeId, scope) : IDLE_OPERATIONS_ENTRY);
|
|
2576
3165
|
useEffect(() => {
|
|
2577
|
-
if (
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
3166
|
+
if (activeId && cache && entry.status === "idle") cache.loadOperations(activeId, scope, limit);
|
|
3167
|
+
}, [
|
|
3168
|
+
activeId,
|
|
3169
|
+
cache,
|
|
3170
|
+
scope,
|
|
3171
|
+
limit,
|
|
3172
|
+
entry.status
|
|
3173
|
+
]);
|
|
3174
|
+
const fetchNextPage = useCallback(() => {
|
|
3175
|
+
if (activeId && cache) cache.loadMoreOperations(activeId, scope);
|
|
2587
3176
|
}, [
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
3177
|
+
activeId,
|
|
3178
|
+
cache,
|
|
3179
|
+
scope
|
|
2591
3180
|
]);
|
|
2592
3181
|
const refetch = useCallback(() => {
|
|
2593
|
-
|
|
2594
|
-
}, [
|
|
3182
|
+
if (activeId && cache) cache.invalidateOperations(activeId);
|
|
3183
|
+
}, [activeId, cache]);
|
|
3184
|
+
const error = useMemo(() => entry.status === "error" ? toError(entry.error) : void 0, [entry.status, entry.error]);
|
|
2595
3185
|
return {
|
|
2596
|
-
|
|
3186
|
+
operations: entry.operations,
|
|
3187
|
+
isLoading: entry.status === "pending" || !!activeId && entry.status === "idle",
|
|
3188
|
+
error,
|
|
3189
|
+
hasNextPage: entry.hasNextPage,
|
|
3190
|
+
fetchNextPage,
|
|
2597
3191
|
refetch
|
|
2598
3192
|
};
|
|
2599
3193
|
}
|
|
3194
|
+
/** Keeps paging `result` to completion while `enabled` is true. */
|
|
3195
|
+
function useLoadAllPages(result, enabled) {
|
|
3196
|
+
useEffect(() => {
|
|
3197
|
+
if (!enabled || !result.hasNextPage || result.isLoading) return;
|
|
3198
|
+
const handle = window.setTimeout(result.fetchNextPage, 0);
|
|
3199
|
+
return () => window.clearTimeout(handle);
|
|
3200
|
+
}, [
|
|
3201
|
+
enabled,
|
|
3202
|
+
result.hasNextPage,
|
|
3203
|
+
result.isLoading,
|
|
3204
|
+
result.fetchNextPage
|
|
3205
|
+
]);
|
|
3206
|
+
}
|
|
3207
|
+
function useDocumentOperations(documentId, scope, options = {}) {
|
|
3208
|
+
const legacy = scope === void 0;
|
|
3209
|
+
const primary = useScopeOperations(documentId, legacy ? "global" : scope, legacy ? {} : options);
|
|
3210
|
+
const local = useScopeOperations(documentId, "local", { enabled: legacy });
|
|
3211
|
+
useLoadAllPages(primary, legacy);
|
|
3212
|
+
useLoadAllPages(local, legacy);
|
|
3213
|
+
const globalOperations = useMemo(() => legacy ? [...primary.operations] : EMPTY_OPERATIONS, [legacy, primary.operations]);
|
|
3214
|
+
const localOperations = useMemo(() => legacy ? [...local.operations] : EMPTY_OPERATIONS, [legacy, local.operations]);
|
|
3215
|
+
const refetch = useCallback(() => {
|
|
3216
|
+
primary.refetch();
|
|
3217
|
+
local.refetch();
|
|
3218
|
+
}, [primary.refetch, local.refetch]);
|
|
3219
|
+
const error = primary.error ?? local.error;
|
|
3220
|
+
const legacyResult = useMemo(() => ({
|
|
3221
|
+
globalOperations,
|
|
3222
|
+
localOperations,
|
|
3223
|
+
isLoading: !error && (primary.isLoading || local.isLoading || primary.hasNextPage || local.hasNextPage),
|
|
3224
|
+
error,
|
|
3225
|
+
refetch
|
|
3226
|
+
}), [
|
|
3227
|
+
globalOperations,
|
|
3228
|
+
localOperations,
|
|
3229
|
+
error,
|
|
3230
|
+
primary.isLoading,
|
|
3231
|
+
local.isLoading,
|
|
3232
|
+
primary.hasNextPage,
|
|
3233
|
+
local.hasNextPage,
|
|
3234
|
+
refetch
|
|
3235
|
+
]);
|
|
3236
|
+
return legacy ? legacyResult : primary;
|
|
3237
|
+
}
|
|
2600
3238
|
//#endregion
|
|
2601
|
-
export {
|
|
3239
|
+
export { addIsAnalyticsEnabledEventHandler as $, setPHModal as $i, useIsDriveAnalyticsEnabled as $n, prepareSignedActions as $r, setIsDeleteCloudDrivesEnabled as $t, useDropNode as A, moveNode$1 as Ai, useAllowList as An, phAppConfigSetters as Ar, addVersionCheckIntervalEventHandler as At, addBasePathEventHandler as B, getFullReactorClient as Bi, useIsAddCloudDrivesEnabled as Bn, findIsServableOverGraphQL as Br, setDisabledEditors as Bt, setPackageDiscoveryService as C, copyNode$1 as Ci, setSentryEnv as Cn, useVersionCheckInterval as Cr, addRequiresHardRefreshEventHandler as Ct, useGraphQLReactorClient as D, fetchDocumentOperations as Di, setVersion as Dn, addIsExternalControlsEnabledEventHandler as Dr, addSentryReleaseEventHandler as Dt, setGraphQLReactorClient as E, extractInitialState as Ei, setSwitchboardUrl as En, addIsDragAndDropEnabledEventHandler as Er, addSentryEnvEventHandler as Et, addAttachmentServiceEventHandler as F, getUserPermissions as Fi, useDisabledEditors as Fn, setIsExternalControlsEnabled as Fr, setAllowList as Ft, addEnabledEditorsEventHandler as G, useModelRegistry as Gi, useIsAnalyticsEnabled as Gn, startDocumentChangesSubscription as Gr, setIsAddCloudDrivesEnabled as Gt, addDefaultDrivesUrlEventHandler as H, setReactorClient as Hi, useIsAddLocalDrivesEnabled as Hn, viewFilterInputFromViewFilter as Hr, setEnabledEditors as Ht, setAttachmentService as I, isDocumentTypeSupported as Ii, useDrivesPreserveStrategy as In, useAllowedDocumentTypes as Ir, setAnalyticsDatabaseName as It, addIsAddCloudDrivesEnabledEventHandler as J, useReactorClientModule as Ji, useIsDeleteCloudDrivesEnabled as Jn, describeGraphQLDocument as Jr, setIsAddPublicDrivesEnabled as Jt, addFileUploadOperationsChunkSizeEventHandler as K, usePGlite as Ki, useIsAnalyticsExternalProcessorsEnabled as Kn, subscriptionsUrlFromGraphqlUrl as Kr, setIsAddDriveEnabled as Kt, useAttachmentService as L, addFullReactorClientEventHandler as Li, useEnabledEditors as Ln, useIsDragAndDropEnabled as Lr, setBasePath as Lt, addFeaturesEventHandler as M, renameNode as Mi, useBasePath as Mn, phDocumentEditorConfigSetters as Mr, addWarnOutdatedAppEventHandler as Mt, setFeatures as N, setPreferredEditorOnNode as Ni, useCliVersion as Nn, setAllowedDocumentTypes as Nr, phGlobalConfigHooks as Nt, addDraggingNodeEventHandler as O, getDocumentExtension as Oi, setVersionCheckInterval as On, isExternalControlsEnabledEventFunctions as Or, addStudioModeEventHandler as Ot, useFeatures as P, upgradeDocument as Pi, useDefaultDrivesUrl as Pn, setIsDragAndDropEnabled as Pr, phGlobalConfigSetters as Pt, addIsAnalyticsDatabaseWorkerEnabledEventHandler as Q, closePHModal as Qi, useIsDocumentModelSelectionSettingsEnabled as Qn, resolveDocumentModelModule as Qr, setIsCloudDrivesEnabled as Qt, addAllowListEventHandler as R, addReactorClientEventHandler as Ri, useFileUploadOperationsChunkSize as Rn, useIsExternalControlsEnabled as Rr, setCliVersion as Rt, addPackageDiscoveryServiceEventHandler as S, addFolder$1 as Si, setSentryDsn as Sn, useVersion as Sr, addRenownUrlEventHandler as St, addGraphQLReactorClientEventHandler as T, exportFile as Ti, setStudioMode as Tn, addAllowedDocumentTypesEventHandler as Tr, addSentryDsnEventHandler as Tt, addDisabledEditorsEventHandler as U, setReactorClientModule as Ui, useIsAddPublicDrivesEnabled as Un, isAuthRefusalClose as Ur, setFileUploadOperationsChunkSize as Ut, addCliVersionEventHandler as V, setFullReactorClient as Vi, useIsAddDriveEnabled as Vn, isGraphQLReactorClient as Vr, setDrivesPreserveStrategy as Vt, addDrivesPreserveStrategyEventHandler as W, useDatabase as Wi, useIsAnalyticsDatabaseWorkerEnabled as Wn, makeAuthConnectionParams as Wr, setGaTrackingId as Wt, addIsAddLocalDrivesEnabledEventHandler as X, useSyncList as Xi, useIsDeletePublicDrivesEnabled as Xn, StaticPackageManager as Xr, setIsAnalyticsEnabled as Xt, addIsAddDriveEnabledEventHandler as Y, useSync as Yi, useIsDeleteLocalDrivesEnabled as Yn, subgraphUrlFromGraphqlUrl as Yr, setIsAnalyticsDatabaseWorkerEnabled as Yt, addIsAddPublicDrivesEnabledEventHandler as Z, addModalEventHandler as Zi, useIsDiffAnalyticsEnabled as Zn, packageFromDocumentModels as Zr, setIsAnalyticsExternalProcessorsEnabled as Zt, addRevisionHistoryVisibleEventHandler as _, COMMON_PACKAGE_ID as _i, setRenownChainId as _n, useSentryDsn as _r, addLocalDrivesEnabledEventHandler as _t, addPHEventHandlers as a, GraphQLOperationNotSupportedError as ai, setIsEditorDebugModeEnabled as an, useIsLocalDrivesEnabled as ar, addIsDiffAnalyticsEnabledEventHandler as at, showRevisionHistory as b, addDocument as bi, setRequiresHardRefresh as bn, useStudioMode as br, addRenownChainIdEventHandler as bt, addToastEventHandler as c, phDocumentFromGetDocument as ci, setIsExternalProcessorsEnabled as cn, useIsSentryTracingEnabled as cr, addIsEditorDebugModeEnabledEventHandler as ct, addSelectedTimelineRevisionEventHandler as d, ConflictError as di, setIsPublicDrivesEnabled as dn, useRenownAdapters as dr, addIsExternalProcessorsEnabledEventHandler as dt, showCreateDocumentModal as ea, signStampedAction as ei, setIsDeleteLocalDrivesEnabled as en, useIsEditorDebugModeEnabled as er, addIsAnalyticsExternalProcessorsEnabledEventHandler as et, setSelectedTimelineRevision as f, buildPulledDocument as fi, setIsRelationalProcessorsEnabled as fn, useRenownChainId as fr, addIsExternalRelationalProcessorsEnabledEventHandler as ft, useSelectedTimelineItem as g, screamingSnakeToCamel as gi, setRenownAdapters as gn, useRouterBasename as gr, addIsSentryTracingEnabledEventHandler as gt, setSelectedTimelineItem as h, hasRevisionConflict as hi, setLogLevel as hn, useRequiresHardRefresh as hr, addIsRelationalProcessorsEnabledEventHandler as ht, useSwitchboardClient as i, BatchJobFailedError as ii, setIsDriveAnalyticsEnabled as in, useIsExternalRelationalProcessorsEnabled as ir, addIsDeletePublicDrivesEnabledEventHandler as it, useDropTarget as j, renameDriveNode as ji, useAnalyticsDatabaseName as jn, phDocumentEditorConfigHooks as jr, addVersionEventHandler as jt, useDragNode as k, loadFile as ki, setWarnOutdatedApp as kn, phAppConfigHooks as kr, addSwitchboardUrlEventHandler as kt, setPHToast as l, phDocumentFromMutation as li, setIsExternalRelationalProcessorsEnabled as ln, useLocalDrivesEnabled as lr, addIsEditorReadModeEnabledEventHandler as lt, addSelectedTimelineItemEventHandler as m, extractRevisionMap as mi, setLocalDrivesEnabled as mn, useRenownUrl as mr, addIsPublicDrivesEnabledEventHandler as mt, GraphQLReactorProvider as n, showPHModal as na, MutateDocumentWithOperationsDocument as ni, setIsDiffAnalyticsEnabled as nn, useIsExternalPackagesEnabled as nr, addIsDeleteCloudDrivesEnabledEventHandler as nt, callEventHandlerRegisterFunctions as o, GraphQLWrongBackendError as oi, setIsEditorReadModeEnabled as on, useIsPublicDrivesEnabled as or, addIsDocumentModelSelectionSettingsEnabledEventHandler as ot, useSelectedTimelineRevision as p, convertRemoteOperations as pi, setIsSentryTracingEnabled as pn, useRenownNetworkId as pr, addIsLocalDrivesEnabledEventHandler as pt, addGaTrackingIdEventHandler as q, useReactorClient as qi, useIsCloudDrivesEnabled as qn, SubgraphSdkRegistry as qr, setIsAddLocalDrivesEnabled as qt, ensurePHEventHandlers as r, usePHModal as ra, ReactorOperationFieldsFragmentDoc as ri, setIsDocumentModelSelectionSettingsEnabled as rn, useIsExternalProcessorsEnabled as rr, addIsDeleteLocalDrivesEnabledEventHandler as rt, commonGlobalEventHandlerFunctions as s, isoStringFromDateTime as si, setIsExternalPackagesEnabled as sn, useIsRelationalProcessorsEnabled as sr, addIsDriveAnalyticsEnabledEventHandler as st, useDocumentOperations as t, showDeleteNodeModal as ta, stampAction as ti, setIsDeletePublicDrivesEnabled as tn, useIsEditorReadModeEnabled as tr, addIsCloudDrivesEnabledEventHandler as tt, usePHToast as u, revisionMapFromRevisionsList as ui, setIsLocalDrivesEnabled as un, useLogLevel as ur, addIsExternalPackagesEnabledEventHandler as ut, hideRevisionHistory as v, DEFAULT_DRIVE_EDITOR_ID as vi, setRenownNetworkId as vn, useSentryEnv as vr, addLogLevelEventHandler as vt, usePackageDiscoveryService as w, deleteNode as wi, setSentryRelease as wn, useWarnOutdatedApp as wr, addRouterBasenameEventHandler as wt, useRevisionHistoryVisible as x, addFileWithProgress as xi, setRouterBasename as xn, useSwitchboardUrl as xr, addRenownNetworkIdEventHandler as xt, setRevisionHistoryVisible as y, DRIVE_DOCUMENT_TYPES as yi, setRenownUrl as yn, useSentryRelease as yr, addRenownAdaptersEventHandler as yt, addAnalyticsDatabaseNameEventHandler as z, addReactorClientModuleEventHandler as zi, useGaTrackingId as zn, GraphQLReactorClient as zr, setDefaultDrivesUrl as zt };
|
|
2602
3240
|
|
|
2603
|
-
//# sourceMappingURL=document-operations-
|
|
3241
|
+
//# sourceMappingURL=document-operations-BSzcF0mu.js.map
|