@powerhousedao/reactor-browser 6.2.3-dev.50 → 6.2.3-dev.52
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-B-nLR114.d.ts → attachment-service-DG6UkyMv.d.ts} +74 -16
- package/dist/attachment-service-DG6UkyMv.d.ts.map +1 -0
- package/dist/{client-C-tRLfRN.d.ts → client-BnGewICj.d.ts} +2 -2
- package/dist/client-BnGewICj.d.ts.map +1 -0
- package/dist/{client-CZyHv02L.js → client-CXDpILj6.js} +36 -1
- package/dist/client-CXDpILj6.js.map +1 -0
- package/dist/{document-operations-CpzMebZ3.js → document-operations-BSzcF0mu.js} +225 -56
- package/dist/document-operations-BSzcF0mu.js.map +1 -0
- package/dist/{global-BvawOKrQ.d.ts → global-BuSwbbY0.d.ts} +5 -3
- package/dist/{global-BvawOKrQ.d.ts.map → global-BuSwbbY0.d.ts.map} +1 -1
- package/dist/{index-Cjf5TGen.d.ts → index-ewIc3pEO.d.ts} +2 -2
- package/dist/{index-Cjf5TGen.d.ts.map → index-ewIc3pEO.d.ts.map} +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -13
- package/dist/index.js.map +1 -1
- package/dist/{inspector-proxy-DKOjxSGE.d.ts → inspector-proxy-DODqs15F.d.ts} +6 -13
- package/dist/inspector-proxy-DODqs15F.d.ts.map +1 -0
- package/dist/src/graphql/client.d.ts +2 -2
- package/dist/src/graphql/client.js +1 -1
- package/dist/src/graphql-client/entry.d.ts +4 -4
- package/dist/src/graphql-client/entry.js +2 -2
- package/dist/src/renown/index.d.ts +1 -1
- package/dist/src/rpc/index.d.ts +99 -47
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +141 -16
- package/dist/src/rpc/index.js.map +1 -1
- package/dist/{types-D0ugg0E1.d.ts → types-0Fh1tNjy.d.ts} +19 -1
- package/dist/types-0Fh1tNjy.d.ts.map +1 -0
- package/package.json +9 -9
- package/dist/attachment-service-B-nLR114.d.ts.map +0 -1
- package/dist/client-C-tRLfRN.d.ts.map +0 -1
- package/dist/client-CZyHv02L.js.map +0 -1
- package/dist/document-operations-CpzMebZ3.js.map +0 -1
- package/dist/inspector-proxy-DKOjxSGE.d.ts.map +0 -1
- package/dist/types-D0ugg0E1.d.ts.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
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
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
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-
|
|
4
|
+
import { i as PhDocumentFieldsFragmentDoc, n as DocumentChangesDocument, t as createClient$1 } from "./client-CXDpILj6.js";
|
|
5
5
|
import { f as addLoadingEventHandler, t as addRenownEventHandler } from "./renown-D05wkobG.js";
|
|
6
6
|
import { logger } from "document-model";
|
|
7
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, normalizeDocumentModelVersion, replayDocumentVersioned, setName, setPreferredEditor, signaturePolicyOf, toTransportAction, withSignaturePolicy } from "@powerhousedao/shared/document-model";
|
|
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
10
|
import { useCallback, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
11
11
|
import { GraphQLClient } from "graphql-request";
|
|
@@ -46,6 +46,44 @@ function showDeleteNodeModal(nodeOrId) {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
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
|
|
49
87
|
//#region src/utils/documents.ts
|
|
50
88
|
function isDocumentTypeSupported(documentType, supportedDocuments) {
|
|
51
89
|
if (!supportedDocuments?.length) return true;
|
|
@@ -132,7 +170,7 @@ async function getDocumentExtension(document) {
|
|
|
132
170
|
let rawExtension;
|
|
133
171
|
if (documentType === documentModelDocumentType) rawExtension = document.state.global?.extension;
|
|
134
172
|
else {
|
|
135
|
-
const reactorClient =
|
|
173
|
+
const reactorClient = getFullReactorClient();
|
|
136
174
|
if (reactorClient) {
|
|
137
175
|
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
138
176
|
rawExtension = documentModelModules.find((m) => m.documentModel.global.id === documentType)?.utils.fileExtension;
|
|
@@ -264,7 +302,7 @@ async function exportFile(document, suggestedName) {
|
|
|
264
302
|
*/
|
|
265
303
|
async function loadFile(path) {
|
|
266
304
|
const baseDocument = await baseLoadFromInput(path, (state) => state, { checkHashes: true });
|
|
267
|
-
const reactorClient =
|
|
305
|
+
const reactorClient = getFullReactorClient();
|
|
268
306
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
269
307
|
const documentType = baseDocument.header.documentType;
|
|
270
308
|
const { results: documentModelModules } = await reactorClient.getDocumentModelModules();
|
|
@@ -285,7 +323,7 @@ async function loadFile(path) {
|
|
|
285
323
|
async function addDocument(driveId, name, documentType, parentFolder, document, id, preferredEditor, documentModelVersion) {
|
|
286
324
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
287
325
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create documents");
|
|
288
|
-
const reactorClient =
|
|
326
|
+
const reactorClient = getFullReactorClient();
|
|
289
327
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
290
328
|
let documentModelModule;
|
|
291
329
|
if (documentModelVersion !== void 0) {
|
|
@@ -388,7 +426,7 @@ async function createImportedDocument(reactor, document, driveId, name, parentFo
|
|
|
388
426
|
}
|
|
389
427
|
async function addFileWithProgress(file, driveId, name, parentFolder, onProgress, documentTypes, resolveConflict) {
|
|
390
428
|
logger.verbose(`addFileWithProgress(drive: ${driveId}, name: ${name}, folder: ${parentFolder})`);
|
|
391
|
-
const reactor =
|
|
429
|
+
const reactor = getFullReactorClient();
|
|
392
430
|
if (!reactor) {
|
|
393
431
|
onProgress?.({
|
|
394
432
|
stage: "failed",
|
|
@@ -545,7 +583,7 @@ async function addFolder$1(driveId, name, parentFolder) {
|
|
|
545
583
|
async function deleteNode(driveId, nodeId) {
|
|
546
584
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
547
585
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to delete documents");
|
|
548
|
-
const reactorClient =
|
|
586
|
+
const reactorClient = getFullReactorClient();
|
|
549
587
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
550
588
|
await reactorClient.drives.removeNode(driveId, nodeId);
|
|
551
589
|
}
|
|
@@ -638,7 +676,7 @@ async function _duplicateDocument(reactor, document, newId = generateId(), drive
|
|
|
638
676
|
return duplicated;
|
|
639
677
|
}
|
|
640
678
|
async function copyNode$1(driveId, src, target) {
|
|
641
|
-
const reactor =
|
|
679
|
+
const reactor = getFullReactorClient();
|
|
642
680
|
if (!reactor) return;
|
|
643
681
|
const { isAllowedToCreateDocuments } = getUserPermissions();
|
|
644
682
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to copy documents");
|
|
@@ -682,11 +720,17 @@ async function copyNode$1(driveId, src, target) {
|
|
|
682
720
|
* latest registered version for the document's type.
|
|
683
721
|
*/
|
|
684
722
|
async function upgradeDocument(documentId, toVersion) {
|
|
685
|
-
const reactorClient =
|
|
723
|
+
const reactorClient = getFullReactorClient();
|
|
686
724
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
687
725
|
return reactorClient.upgradeDocument(documentId, toVersion);
|
|
688
726
|
}
|
|
689
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
|
|
690
734
|
//#region src/remote-controller/utils.ts
|
|
691
735
|
/** Convert SCREAMING_SNAKE_CASE to camelCase (e.g. "SET_MODEL_NAME" → "setModelName"). */
|
|
692
736
|
function screamingSnakeToCamel(s) {
|
|
@@ -867,6 +911,26 @@ var GraphQLOperationNotSupportedError = class extends Error {
|
|
|
867
911
|
}
|
|
868
912
|
};
|
|
869
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
|
+
/**
|
|
870
934
|
* The reactor's `BatchJobFailedError`, rebuilt from a batch result; this entry
|
|
871
935
|
* imports the reactor for types only. The shared name lets either `isError`
|
|
872
936
|
* recognise it.
|
|
@@ -1465,6 +1529,7 @@ var GraphQLReactorClient = class {
|
|
|
1465
1529
|
subscriptionsUrl;
|
|
1466
1530
|
documentModels;
|
|
1467
1531
|
signer;
|
|
1532
|
+
driveIdFor;
|
|
1468
1533
|
stopRealtime;
|
|
1469
1534
|
realtimeStarted = false;
|
|
1470
1535
|
realtimeGeneration = 0;
|
|
@@ -1473,10 +1538,16 @@ var GraphQLReactorClient = class {
|
|
|
1473
1538
|
realtimeRefusedCredentials = false;
|
|
1474
1539
|
constructor(options) {
|
|
1475
1540
|
this.tokenProvider = options.tokenProvider ?? ambientRenownTokenProvider;
|
|
1476
|
-
|
|
1541
|
+
const models = options.documentModels;
|
|
1542
|
+
if (typeof models === "function") this.documentModels = models;
|
|
1543
|
+
else {
|
|
1544
|
+
const copied = [...models ?? []];
|
|
1545
|
+
this.documentModels = () => copied;
|
|
1546
|
+
}
|
|
1477
1547
|
this.signer = options.signer;
|
|
1548
|
+
this.driveIdFor = options.driveIdFor;
|
|
1478
1549
|
this.subscriptionsUrl = options.realtime === false ? void 0 : options.subscriptionsUrl ?? subscriptionsUrlFromGraphqlUrl(options.url);
|
|
1479
|
-
const middleware = makeAuthMiddleware(this.tokenProvider);
|
|
1550
|
+
const middleware = withWrongBackendErrors(makeAuthMiddleware(this.tokenProvider));
|
|
1480
1551
|
this.sdk = options.graphqlClient ?? createClient$1(options.url, middleware);
|
|
1481
1552
|
this.subgraphs = new SubgraphSdkRegistry(options.url, middleware);
|
|
1482
1553
|
}
|
|
@@ -1489,6 +1560,26 @@ var GraphQLReactorClient = class {
|
|
|
1489
1560
|
if (!document) throw new Error(`Document not found: ${identifier}`);
|
|
1490
1561
|
return phDocumentFromGetDocument(document.document, view?.branch);
|
|
1491
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
|
+
}
|
|
1492
1583
|
async getOperations(documentIdentifier, view, filter, paging, signal) {
|
|
1493
1584
|
const viewInput = viewFilterInputFromViewFilter(view);
|
|
1494
1585
|
const operationsFilter = {
|
|
@@ -1539,7 +1630,10 @@ var GraphQLReactorClient = class {
|
|
|
1539
1630
|
},
|
|
1540
1631
|
view: viewInput,
|
|
1541
1632
|
paging: pagingInputFromPaging(effectivePaging)
|
|
1542
|
-
}, void 0
|
|
1633
|
+
}, search.parentId === void 0 ? void 0 : this.driveIdHeaders({
|
|
1634
|
+
method: "find",
|
|
1635
|
+
parentId: search.parentId
|
|
1636
|
+
}), signal);
|
|
1543
1637
|
return this.toDocumentResults(result.findDocuments, effectivePaging, view?.branch, (cursor, limit) => this.find(search, view, {
|
|
1544
1638
|
cursor,
|
|
1545
1639
|
limit
|
|
@@ -1601,7 +1695,11 @@ var GraphQLReactorClient = class {
|
|
|
1601
1695
|
const created = phDocumentFromGetDocument((await this.sdk.CreateDocument({
|
|
1602
1696
|
document,
|
|
1603
1697
|
parentIdentifier
|
|
1604
|
-
},
|
|
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);
|
|
1605
1703
|
this.emitChange({
|
|
1606
1704
|
type: DOCUMENT_CHANGE_TYPE.Created,
|
|
1607
1705
|
documents: [created]
|
|
@@ -1629,7 +1727,7 @@ var GraphQLReactorClient = class {
|
|
|
1629
1727
|
const document = await this.get(documentIdentifier, { branch }, signal);
|
|
1630
1728
|
const variables = {
|
|
1631
1729
|
documentIdentifier,
|
|
1632
|
-
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),
|
|
1633
1731
|
sinceRevision: sinceRevisionForActions(document, actions),
|
|
1634
1732
|
scopes: scopesForActions(actions),
|
|
1635
1733
|
branch
|
|
@@ -1639,6 +1737,10 @@ var GraphQLReactorClient = class {
|
|
|
1639
1737
|
operationType: "mutation",
|
|
1640
1738
|
document: MutateDocumentWithOperationsDocument,
|
|
1641
1739
|
variables,
|
|
1740
|
+
requestHeaders: this.driveIdHeaders({
|
|
1741
|
+
method: "execute",
|
|
1742
|
+
documentId: documentIdentifier
|
|
1743
|
+
}, isDrive(document) ? document.header.id : void 0),
|
|
1642
1744
|
signal
|
|
1643
1745
|
})).mutateDocument;
|
|
1644
1746
|
const updated = phDocumentFromMutation(mutated, mutated.operations?.items ?? [], branch);
|
|
@@ -1687,7 +1789,10 @@ var GraphQLReactorClient = class {
|
|
|
1687
1789
|
dependsOn: job.dependsOn
|
|
1688
1790
|
};
|
|
1689
1791
|
}));
|
|
1690
|
-
const result = await this.sdk.ExecuteBatch({ jobs: jobInputs },
|
|
1792
|
+
const result = await this.sdk.ExecuteBatch({ jobs: jobInputs }, this.driveIdHeaders({
|
|
1793
|
+
method: "executeBatch",
|
|
1794
|
+
jobs: jobInputs.map((job) => ({ documentId: job.documentIdOrSlug }))
|
|
1795
|
+
}), signal);
|
|
1691
1796
|
const jobs = {};
|
|
1692
1797
|
for (const entry of result.executeBatch.jobs) jobs[entry.key] = jobInfoFromGql(entry.job);
|
|
1693
1798
|
await this.announceBatch(request, jobs, signal);
|
|
@@ -1695,6 +1800,11 @@ var GraphQLReactorClient = class {
|
|
|
1695
1800
|
if (failed) throw new BatchJobFailedError(failed.key, jobs);
|
|
1696
1801
|
return { jobs };
|
|
1697
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
|
+
}
|
|
1698
1808
|
/** Polls `jobStatus` until the job is READ_READY or FAILED. */
|
|
1699
1809
|
async waitForJob(jobOrId, signal) {
|
|
1700
1810
|
if (typeof jobOrId !== "string" && isSettled(jobOrId)) return jobOrId;
|
|
@@ -1708,19 +1818,38 @@ var GraphQLReactorClient = class {
|
|
|
1708
1818
|
}
|
|
1709
1819
|
}
|
|
1710
1820
|
/**
|
|
1711
|
-
*
|
|
1712
|
-
*
|
|
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.
|
|
1713
1825
|
*/
|
|
1714
|
-
getCreateSignaturePolicy() {
|
|
1715
|
-
return
|
|
1826
|
+
async getCreateSignaturePolicy() {
|
|
1827
|
+
return (await this.createDefaults("getCreateSignaturePolicy")).signaturePolicy;
|
|
1716
1828
|
}
|
|
1717
1829
|
/**
|
|
1718
|
-
*
|
|
1719
|
-
*
|
|
1720
|
-
*
|
|
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}.
|
|
1721
1835
|
*/
|
|
1722
|
-
getCreateProtocolVersions(
|
|
1723
|
-
return
|
|
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
|
+
};
|
|
1724
1853
|
}
|
|
1725
1854
|
/**
|
|
1726
1855
|
* Sets or, with `null`, clears the preferred editor as a client-signed
|
|
@@ -1729,6 +1858,15 @@ var GraphQLReactorClient = class {
|
|
|
1729
1858
|
setPreferredEditor(documentIdentifier, preferredEditor, branch = "main", signal) {
|
|
1730
1859
|
return this.execute(documentIdentifier, branch, [actions.setPreferredEditor(preferredEditor)], signal);
|
|
1731
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
|
+
}
|
|
1732
1870
|
/**
|
|
1733
1871
|
* Emits the changes the batch's settled jobs made, as `create` and `execute`
|
|
1734
1872
|
* do, so a cache is invalidated without a realtime socket. The documents a
|
|
@@ -1829,7 +1967,10 @@ var GraphQLReactorClient = class {
|
|
|
1829
1967
|
await this.sdk.DeleteDocument({
|
|
1830
1968
|
identifier,
|
|
1831
1969
|
propagate: propagationModeInput(propagate)
|
|
1832
|
-
},
|
|
1970
|
+
}, this.driveIdHeaders({
|
|
1971
|
+
method: "deleteDocument",
|
|
1972
|
+
documentId: identifier
|
|
1973
|
+
}), signal);
|
|
1833
1974
|
this.emitChange({
|
|
1834
1975
|
type: DOCUMENT_CHANGE_TYPE.Deleted,
|
|
1835
1976
|
documents: [],
|
|
@@ -2278,6 +2419,62 @@ function jobInfoFromGql(job) {
|
|
|
2278
2419
|
};
|
|
2279
2420
|
return info;
|
|
2280
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
|
+
}
|
|
2281
2478
|
function isSettled(job) {
|
|
2282
2479
|
const status = job.status;
|
|
2283
2480
|
return status === "READ_READY" || status === "FAILED";
|
|
@@ -2732,35 +2929,6 @@ const usePackageDiscoveryService = packageDiscoveryFunctions.useValue;
|
|
|
2732
2929
|
const setPackageDiscoveryService = packageDiscoveryFunctions.setValue;
|
|
2733
2930
|
const addPackageDiscoveryServiceEventHandler = packageDiscoveryFunctions.addEventHandler;
|
|
2734
2931
|
//#endregion
|
|
2735
|
-
//#region src/hooks/reactor.ts
|
|
2736
|
-
const reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
|
|
2737
|
-
const reactorClientEventFunctions = makePHEventFunctions("reactorClient");
|
|
2738
|
-
/** Returns the reactor client module (in-process or worker-backed) */
|
|
2739
|
-
const useReactorClientModule = reactorClientModuleEventFunctions.useValue;
|
|
2740
|
-
/** Sets the reactor client module */
|
|
2741
|
-
const setReactorClientModule = reactorClientModuleEventFunctions.setValue;
|
|
2742
|
-
/** Adds an event handler for the reactor client module */
|
|
2743
|
-
const addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
|
|
2744
|
-
/** Returns the reactor client */
|
|
2745
|
-
const useReactorClient = reactorClientEventFunctions.useValue;
|
|
2746
|
-
/** Sets the reactor client */
|
|
2747
|
-
const setReactorClient = reactorClientEventFunctions.setValue;
|
|
2748
|
-
/** Adds an event handler for the reactor client */
|
|
2749
|
-
const addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
|
|
2750
|
-
const useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager;
|
|
2751
|
-
const useSyncList = () => {
|
|
2752
|
-
return useSync()?.list() ?? [];
|
|
2753
|
-
};
|
|
2754
|
-
const useModelRegistry = () => useReactorClientModule()?.reactorModule?.documentModelRegistry;
|
|
2755
|
-
const useDatabase = () => {
|
|
2756
|
-
const module = useReactorClientModule();
|
|
2757
|
-
return module?.kind === "browser" ? module.reactorModule?.database : void 0;
|
|
2758
|
-
};
|
|
2759
|
-
const usePGlite = () => {
|
|
2760
|
-
const module = useReactorClientModule();
|
|
2761
|
-
return module?.kind === "browser" ? module.reactorModule?.pg : void 0;
|
|
2762
|
-
};
|
|
2763
|
-
//#endregion
|
|
2764
2932
|
//#region src/hooks/revision-history.ts
|
|
2765
2933
|
const revisionHistoryEventFunctions = makePHEventFunctions("revisionHistoryVisible");
|
|
2766
2934
|
/** Returns whether revision history is visible */
|
|
@@ -2826,6 +2994,7 @@ const phGlobalEventHandlerRegisterFunctions = {
|
|
|
2826
2994
|
...commonGlobalEventHandlerFunctions,
|
|
2827
2995
|
reactorClientModule: addReactorClientModuleEventHandler,
|
|
2828
2996
|
reactorClient: addReactorClientEventHandler,
|
|
2997
|
+
fullReactorClient: addFullReactorClientEventHandler,
|
|
2829
2998
|
attachmentService: addAttachmentServiceEventHandler,
|
|
2830
2999
|
features: addFeaturesEventHandler,
|
|
2831
3000
|
modal: addModalEventHandler,
|
|
@@ -3067,6 +3236,6 @@ function useDocumentOperations(documentId, scope, options = {}) {
|
|
|
3067
3236
|
return legacy ? legacyResult : primary;
|
|
3068
3237
|
}
|
|
3069
3238
|
//#endregion
|
|
3070
|
-
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 };
|
|
3071
3240
|
|
|
3072
|
-
//# sourceMappingURL=document-operations-
|
|
3241
|
+
//# sourceMappingURL=document-operations-BSzcF0mu.js.map
|