@powerhousedao/reactor-browser 6.2.3-dev.78 → 6.2.3-dev.79
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-C_8_poEv.d.ts → attachment-service-BoLudaH0.d.ts} +53 -25
- package/dist/attachment-service-BoLudaH0.d.ts.map +1 -0
- package/dist/{client-D_cBN8L-.js → client-BUpynoY6.js} +25 -1
- package/dist/client-BUpynoY6.js.map +1 -0
- package/dist/{client-Cx43uuSO.d.ts → client-XPGQrO4a.d.ts} +2 -2
- package/dist/client-XPGQrO4a.d.ts.map +1 -0
- package/dist/{dispatch-DLD1E-9L.js → dispatch-C8J9jQ-o.js} +10 -8
- package/dist/dispatch-C8J9jQ-o.js.map +1 -0
- package/dist/{document-by-id-BGTnMWiG.js → document-by-id-Dpp76ZNE.js} +2 -2
- package/dist/{document-by-id-BGTnMWiG.js.map → document-by-id-Dpp76ZNE.js.map} +1 -1
- package/dist/{document-model-modules-D_kT09sv.js → document-model-modules-XrYfGXt8.js} +2 -2
- package/dist/{document-model-modules-D_kT09sv.js.map → document-model-modules-XrYfGXt8.js.map} +1 -1
- package/dist/{document-operations-BdCl99y6.js → document-operations-B0GZilXW.js} +190 -148
- package/dist/document-operations-B0GZilXW.js.map +1 -0
- package/dist/{global-C4kaLEPb.d.ts → global-BlOVLagj.d.ts} +3 -3
- package/dist/{global-C4kaLEPb.d.ts.map → global-BlOVLagj.d.ts.map} +1 -1
- package/dist/{index-CROGY3XV.d.ts → index-Ck5Q0beA.d.ts} +2 -2
- package/dist/{index-CROGY3XV.d.ts.map → index-Ck5Q0beA.d.ts.map} +1 -1
- package/dist/index.d.ts +25 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +106 -51
- package/dist/index.js.map +1 -1
- package/dist/src/ai/index.js +2 -2
- package/dist/src/analytics/index.js +1 -1
- 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 +4 -4
- package/dist/src/renown/index.d.ts +1 -1
- package/dist/{switchboard-CqUq5pIZ.js → switchboard-CYTCYt4Z.js} +4 -4
- package/dist/{switchboard-CqUq5pIZ.js.map → switchboard-CYTCYt4Z.js.map} +1 -1
- package/dist/{types-Vb8q55oM.d.ts → types-BNVqRNli.d.ts} +11 -1
- package/dist/types-BNVqRNli.d.ts.map +1 -0
- package/package.json +9 -9
- package/dist/attachment-service-C_8_poEv.d.ts.map +0 -1
- package/dist/client-Cx43uuSO.d.ts.map +0 -1
- package/dist/client-D_cBN8L-.js.map +0 -1
- package/dist/dispatch-DLD1E-9L.js.map +0 -1
- package/dist/document-operations-BdCl99y6.js.map +0 -1
- package/dist/types-Vb8q55oM.d.ts.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { c as getPHStore, f as usePHStore, t as makePHEventFunctions } from "./make-ph-event-functions-B5GU5xcR.js";
|
|
2
|
-
import { D as queueOperations, E as queueActions, N as UnsupportedDocumentTypeError, O as uploadOperations, b as DOCUMENT_CHANGE_TYPE, f as DocumentCache, h as IDLE_OPERATIONS_ENTRY, i as setDocumentCache, k as DocumentModelNotFoundError, o as useDocumentCache, r as addDocumentCacheEventHandler, v as isOperationCache } from "./dispatch-
|
|
3
|
-
import { $ as makeAuthMiddleware, A as addDrivesEventHandler, B as invalidateDriveNodes, H as markLocalDriveWrite, L as addDriveNodesEventHandler, Q as ambientRenownTokenProvider, R as dropDriveNode, X as listAllDriveNodes, a as setVetraPackageManager, c as addSelectedDriveIdEventHandler, f as setSelectedDriveId, h as useSelectedDriveId, r as addVetraPackageManagerEventHandler, u as selectDrive, v as addResetSelectedNodeEventHandler, w as setSelectedNodeId, y as addSelectedNodeIdEventHandler, z as getDriveNode } from "./document-model-modules-
|
|
2
|
+
import { D as queueOperations, E as queueActions, N as UnsupportedDocumentTypeError, O as uploadOperations, b as DOCUMENT_CHANGE_TYPE, f as DocumentCache, h as IDLE_OPERATIONS_ENTRY, i as setDocumentCache, k as DocumentModelNotFoundError, o as useDocumentCache, r as addDocumentCacheEventHandler, v as isOperationCache } from "./dispatch-C8J9jQ-o.js";
|
|
3
|
+
import { $ as makeAuthMiddleware, A as addDrivesEventHandler, B as invalidateDriveNodes, H as markLocalDriveWrite, L as addDriveNodesEventHandler, Q as ambientRenownTokenProvider, R as dropDriveNode, X as listAllDriveNodes, a as setVetraPackageManager, c as addSelectedDriveIdEventHandler, f as setSelectedDriveId, h as useSelectedDriveId, r as addVetraPackageManagerEventHandler, u as selectDrive, v as addResetSelectedNodeEventHandler, w as setSelectedNodeId, y as addSelectedNodeIdEventHandler, z as getDriveNode } from "./document-model-modules-XrYfGXt8.js";
|
|
4
4
|
import { A as extractNodeIdFromSlug, N as findDriveBySlug, O as extractDriveSlugFromPath, S as setBrowserOpenSync, c as getCurrentPathname, d as hasHostNavigation, h as openTargetWith, j as extractNodeSlugFromPath, l as getPHNavigation, m as openTarget, v as recordToSearch, w as targetPathname, x as searchToRecord } from "./navigation-BqphkrOB.js";
|
|
5
|
-
import { a as PhDocumentFieldsFragmentDoc, i as JobChangesDocument, n as DocumentChangesDocument, t as createClient$1 } from "./client-
|
|
5
|
+
import { a as PhDocumentFieldsFragmentDoc, i as JobChangesDocument, n as DocumentChangesDocument, t as createClient$1 } from "./client-BUpynoY6.js";
|
|
6
6
|
import { f as addLoadingEventHandler, t as addRenownEventHandler } from "./renown-BxkZYzbQ.js";
|
|
7
7
|
import { useCallback, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
8
8
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
9
9
|
import { logger } from "document-model";
|
|
10
|
-
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";
|
|
11
|
-
import { addFolder, copyNode, generateNodesCopy, handleTargetNameCollisions, isFileNode, isFolderNode, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
|
|
10
|
+
import { PEER_CAPABILITIES, UnsupportedDocumentModelVersionError, actionSignerIdentity, actionSigningTarget, actions, assertAuthPreservedOnDuplicate, baseLoadFromInput, baseLoadFromInputVersioned, baseSaveToFileHandle, capSelection, createCopyHeader, createPresignedHeader, createZip, creationState, deserializeSignature, documentModelDocumentType, generateId, hasDerivedDocumentId, hashDocumentStateForScope, headNewDocument, isSignaturePolicy, localSupports, normalizeDocumentModelVersion, replayDocumentVersioned, selectDocumentModelModule, setName, setPreferredEditor, signaturePolicyOf, toTransportAction, withSignaturePolicy } from "@powerhousedao/shared/document-model";
|
|
11
|
+
import { addFolder, copyNode, driveDocumentModelModule, generateNodesCopy, handleTargetNameCollisions, isFileNode, isFolderNode, moveNode, updateNode } from "@powerhousedao/shared/document-drive";
|
|
12
12
|
import { allPass, conditional, constant, forEachObj, funnel, isDefined, isNot, isStrictEqual, isString, isTruthy, once } from "remeda";
|
|
13
13
|
import { gql } from "graphql-tag";
|
|
14
14
|
import { Kind, print } from "graphql";
|
|
@@ -379,12 +379,9 @@ async function fetchDocumentOperations(reactorClient, document, pageSize = 100)
|
|
|
379
379
|
return operations;
|
|
380
380
|
}
|
|
381
381
|
function extractInitialState(documentScopeOps) {
|
|
382
|
-
const
|
|
383
|
-
if (
|
|
384
|
-
|
|
385
|
-
const initialState = input.initialState ?? input.state;
|
|
386
|
-
if (!initialState) throw new Error("UPGRADE_DOCUMENT operation has no initialState — document is invalid");
|
|
387
|
-
return initialState;
|
|
382
|
+
const initialState = creationState(documentScopeOps);
|
|
383
|
+
if (initialState) return initialState;
|
|
384
|
+
throw new Error(documentScopeOps.some((op) => op.action.type === "UPGRADE_DOCUMENT") ? "UPGRADE_DOCUMENT operation has no initialState — document is invalid" : "No UPGRADE_DOCUMENT operation found — document is invalid");
|
|
388
385
|
}
|
|
389
386
|
function filterDomainOperations(operations) {
|
|
390
387
|
return Object.fromEntries(Object.entries(operations).filter(([scope]) => !NON_DOMAIN_SCOPES.has(scope)));
|
|
@@ -502,15 +499,10 @@ async function addDocument(driveId, name, documentType, parentFolder, document,
|
|
|
502
499
|
if (!isAllowedToCreateDocuments) throw new Error("User is not allowed to create documents");
|
|
503
500
|
const reactorClient = getFullReactorClient();
|
|
504
501
|
if (!reactorClient) throw new Error("ReactorClient not initialized");
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
if (!module) throw new Error(`Document model not found for type: ${documentType} with version: ${documentModelVersion}`);
|
|
510
|
-
documentModelModule = module;
|
|
511
|
-
} else documentModelModule = await reactorClient.read.getDocumentModelModule(documentType);
|
|
512
|
-
const newDocument = document ?? withSignaturePolicy(documentModelModule.utils.createDocument(), await reactorClient.read.getCreateSignaturePolicy());
|
|
513
|
-
if (!document) newDocument.state.document.version = documentModelModule.version ?? 1;
|
|
502
|
+
const newDocument = document ?? await reactorClient.read.newDocument(documentType, {
|
|
503
|
+
parentIdentifier: driveId,
|
|
504
|
+
documentModelVersion
|
|
505
|
+
});
|
|
514
506
|
newDocument.header.name = name;
|
|
515
507
|
if (preferredEditor) newDocument.header.meta = {
|
|
516
508
|
...newDocument.header.meta,
|
|
@@ -565,7 +557,7 @@ async function createImportedDocument(write, document, driveId, name, parentFold
|
|
|
565
557
|
let documentId = keepsId ? document.header.id : generateId();
|
|
566
558
|
for (let attempt = 1;; attempt++) {
|
|
567
559
|
let header;
|
|
568
|
-
if (!v2Required) header = createPresignedHeader(documentId, document.header.documentType);
|
|
560
|
+
if (!v2Required) header = createPresignedHeader(documentId, document.header.documentType, document.header.protocolVersions);
|
|
569
561
|
else if (keepsId && attempt === 1) {
|
|
570
562
|
header = createPresignedHeader(documentId, document.header.documentType);
|
|
571
563
|
header.createdAtUtcIso = document.header.createdAtUtcIso;
|
|
@@ -858,7 +850,10 @@ async function _duplicateDocument(reactor, document, newId = generateId(), drive
|
|
|
858
850
|
reducers,
|
|
859
851
|
upgradeManifest
|
|
860
852
|
};
|
|
861
|
-
const selected = await reactor.getCreateProtocolVersions(
|
|
853
|
+
const selected = await reactor.getCreateProtocolVersions({
|
|
854
|
+
documentType: document.header.documentType,
|
|
855
|
+
parentIdentifier: driveId
|
|
856
|
+
});
|
|
862
857
|
const header = createCopyHeader({
|
|
863
858
|
documentType: document.header.documentType,
|
|
864
859
|
protocolVersions: document.header.protocolVersions ? {
|
|
@@ -926,6 +921,91 @@ async function upgradeDocument(documentId, toVersion) {
|
|
|
926
921
|
return (await reactorClient.write.upgradeDocument(documentId, toVersion)).document();
|
|
927
922
|
}
|
|
928
923
|
//#endregion
|
|
924
|
+
//#region src/graphql-client/errors.ts
|
|
925
|
+
/** A call the Switchboard GraphQL surface cannot express. */
|
|
926
|
+
var GraphQLOperationNotSupportedError = class extends Error {
|
|
927
|
+
name = "GraphQLOperationNotSupportedError";
|
|
928
|
+
operation;
|
|
929
|
+
constructor(operation, reason) {
|
|
930
|
+
super(`GraphQLReactorClient.${operation} is not supported: ${reason}`);
|
|
931
|
+
this.operation = operation;
|
|
932
|
+
}
|
|
933
|
+
static isError(error) {
|
|
934
|
+
return Error.isError(error) && error.name === "GraphQLOperationNotSupportedError";
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
/**
|
|
938
|
+
* The Switchboard refused a request with 421 Misdirected Request: the
|
|
939
|
+
* `Drive-Id` it carried names a drive that Switchboard does not own.
|
|
940
|
+
*/
|
|
941
|
+
var GraphQLWrongBackendError = class extends Error {
|
|
942
|
+
name = "GraphQLWrongBackendError";
|
|
943
|
+
status = 421;
|
|
944
|
+
/** The drive the Switchboard refused, or `""` when its answer names none. */
|
|
945
|
+
driveId;
|
|
946
|
+
/** The response body, parsed when it is JSON. */
|
|
947
|
+
payload;
|
|
948
|
+
constructor(driveId, payload, options) {
|
|
949
|
+
super(`The Switchboard does not serve drive ${driveId === "" ? "(unnamed)" : driveId}: 421 Misdirected Request`, options);
|
|
950
|
+
this.driveId = driveId;
|
|
951
|
+
this.payload = payload;
|
|
952
|
+
}
|
|
953
|
+
static isError(error) {
|
|
954
|
+
return Error.isError(error) && error.name === "GraphQLWrongBackendError" && typeof error.driveId === "string";
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
/**
|
|
958
|
+
* The reactor's `BatchJobFailedError`, rebuilt from a batch result; this entry
|
|
959
|
+
* imports the reactor for types only. The shared name lets either `isError`
|
|
960
|
+
* recognise it.
|
|
961
|
+
*/
|
|
962
|
+
var BatchJobFailedError = class extends Error {
|
|
963
|
+
name = "BatchJobFailedError";
|
|
964
|
+
key;
|
|
965
|
+
jobs;
|
|
966
|
+
constructor(key, jobs) {
|
|
967
|
+
const failure = jobs[key].error;
|
|
968
|
+
const cause = new Error(failure?.message ?? "Job failed");
|
|
969
|
+
cause.name = failure?.name ?? "Error";
|
|
970
|
+
super(failure?.message ?? "Job failed", { cause });
|
|
971
|
+
this.key = key;
|
|
972
|
+
this.jobs = jobs;
|
|
973
|
+
}
|
|
974
|
+
static isError(error) {
|
|
975
|
+
return Error.isError(error) && error.name === "BatchJobFailedError" && typeof error.key === "string" && typeof error.jobs === "object";
|
|
976
|
+
}
|
|
977
|
+
};
|
|
978
|
+
/** A validation error naming root field `field` unknown: a host from before it. */
|
|
979
|
+
function queriesUnknownField(error, field) {
|
|
980
|
+
return hasErrorStarting(error, `Cannot query field "${field}" on type "`);
|
|
981
|
+
}
|
|
982
|
+
/** A validation error naming `argument` unknown: a host from before it. */
|
|
983
|
+
function queriesUnknownArgument(error, argument) {
|
|
984
|
+
return hasErrorStarting(error, `Unknown argument "${argument}" on field "`);
|
|
985
|
+
}
|
|
986
|
+
function hasErrorStarting(error, prefix) {
|
|
987
|
+
const errors = error?.response?.errors;
|
|
988
|
+
if (!Array.isArray(errors)) return false;
|
|
989
|
+
return errors.some((entry) => typeof entry?.message === "string" && entry.message.startsWith(prefix));
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* The reactor's `JobFailedError`, rebuilt from a job the Switchboard reported
|
|
993
|
+
* FAILED; this entry imports the reactor for types only. A write handle's
|
|
994
|
+
* stage rejects with it. The message is the job error's message, as the
|
|
995
|
+
* reactor's is.
|
|
996
|
+
*/
|
|
997
|
+
var JobFailedError = class extends Error {
|
|
998
|
+
name = "JobFailedError";
|
|
999
|
+
job;
|
|
1000
|
+
constructor(job) {
|
|
1001
|
+
super(job.error?.message);
|
|
1002
|
+
this.job = job;
|
|
1003
|
+
}
|
|
1004
|
+
static isError(error) {
|
|
1005
|
+
return Error.isError(error) && error.name === "JobFailedError" && typeof error.job === "object";
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
//#endregion
|
|
929
1009
|
//#region src/constants.ts
|
|
930
1010
|
const DEFAULT_DRIVE_EDITOR_ID = "powerhouse/generic-drive-explorer";
|
|
931
1011
|
const COMMON_PACKAGE_ID = "powerhouse/common";
|
|
@@ -983,7 +1063,11 @@ function convertRemoteOperations(operationsByScope) {
|
|
|
983
1063
|
for (const [scope, remoteOps] of Object.entries(operationsByScope)) operations[scope] = remoteOps.map((op) => remoteOperationToLocal(op));
|
|
984
1064
|
return operations;
|
|
985
1065
|
}
|
|
986
|
-
/**
|
|
1066
|
+
/**
|
|
1067
|
+
* Reconstruct a PHDocument from remote document data and operations; the
|
|
1068
|
+
* header carries the remote protocol versions. `initialDoc` supplies the rest
|
|
1069
|
+
* of the header, and the initial state when the operations do not record one.
|
|
1070
|
+
*/
|
|
987
1071
|
function buildPulledDocument(remoteDoc, operations, initialDoc, branch) {
|
|
988
1072
|
return {
|
|
989
1073
|
header: {
|
|
@@ -995,14 +1079,34 @@ function buildPulledDocument(remoteDoc, operations, initialDoc, branch) {
|
|
|
995
1079
|
createdAtUtcIso: typeof remoteDoc.createdAtUtcIso === "string" ? remoteDoc.createdAtUtcIso : remoteDoc.createdAtUtcIso.toISOString(),
|
|
996
1080
|
lastModifiedAtUtcIso: typeof remoteDoc.lastModifiedAtUtcIso === "string" ? remoteDoc.lastModifiedAtUtcIso : remoteDoc.lastModifiedAtUtcIso.toISOString(),
|
|
997
1081
|
revision: Object.fromEntries(remoteDoc.revisionsList.map((r) => [r.scope, r.revision])),
|
|
998
|
-
branch
|
|
1082
|
+
branch,
|
|
1083
|
+
...remoteDoc.protocolVersions != null ? { protocolVersions: remoteDoc.protocolVersions } : {}
|
|
999
1084
|
},
|
|
1000
1085
|
state: remoteDoc.state,
|
|
1001
|
-
initialState: initialDoc.initialState,
|
|
1086
|
+
initialState: creationState(operations.document ?? []) ?? initialDoc.initialState,
|
|
1002
1087
|
operations,
|
|
1003
1088
|
clipboard: []
|
|
1004
1089
|
};
|
|
1005
1090
|
}
|
|
1091
|
+
/** `document` as created: its header and initial state, without scope operations. */
|
|
1092
|
+
function uncreatedDocument(document) {
|
|
1093
|
+
const { header, initialState } = structuredClone({
|
|
1094
|
+
header: document.header,
|
|
1095
|
+
initialState: document.initialState
|
|
1096
|
+
});
|
|
1097
|
+
return {
|
|
1098
|
+
header,
|
|
1099
|
+
state: initialState,
|
|
1100
|
+
initialState,
|
|
1101
|
+
operations: {},
|
|
1102
|
+
clipboard: []
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
/** An uncreated `document` under `policy`; a legacy one keeps its id. */
|
|
1106
|
+
function underSignaturePolicy(document, policy) {
|
|
1107
|
+
if (signaturePolicyOf(document.header) === policy) return document;
|
|
1108
|
+
return withSignaturePolicy(document, policy, { id: document.header.id });
|
|
1109
|
+
}
|
|
1006
1110
|
/** Extract revision map from a remote document's revisionsList. */
|
|
1007
1111
|
function extractRevisionMap(revisionsList) {
|
|
1008
1112
|
return Object.fromEntries(revisionsList.map((r) => [r.scope, r.revision]));
|
|
@@ -1231,77 +1335,52 @@ function startCursor(cursor) {
|
|
|
1231
1335
|
return cursor === void 0 || cursor === "0" ? "" : cursor;
|
|
1232
1336
|
}
|
|
1233
1337
|
//#endregion
|
|
1234
|
-
//#region src/graphql-client/
|
|
1235
|
-
/**
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
};
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
constructor(driveId, payload, options) {
|
|
1259
|
-
super(`The Switchboard does not serve drive ${driveId === "" ? "(unnamed)" : driveId}: 421 Misdirected Request`, options);
|
|
1260
|
-
this.driveId = driveId;
|
|
1261
|
-
this.payload = payload;
|
|
1262
|
-
}
|
|
1263
|
-
static isError(error) {
|
|
1264
|
-
return Error.isError(error) && error.name === "GraphQLWrongBackendError" && typeof error.driveId === "string";
|
|
1265
|
-
}
|
|
1266
|
-
};
|
|
1267
|
-
/**
|
|
1268
|
-
* The reactor's `BatchJobFailedError`, rebuilt from a batch result; this entry
|
|
1269
|
-
* imports the reactor for types only. The shared name lets either `isError`
|
|
1270
|
-
* recognise it.
|
|
1271
|
-
*/
|
|
1272
|
-
var BatchJobFailedError = class extends Error {
|
|
1273
|
-
name = "BatchJobFailedError";
|
|
1274
|
-
key;
|
|
1275
|
-
jobs;
|
|
1276
|
-
constructor(key, jobs) {
|
|
1277
|
-
const failure = jobs[key].error;
|
|
1278
|
-
const cause = new Error(failure?.message ?? "Job failed");
|
|
1279
|
-
cause.name = failure?.name ?? "Error";
|
|
1280
|
-
super(failure?.message ?? "Job failed", { cause });
|
|
1281
|
-
this.key = key;
|
|
1282
|
-
this.jobs = jobs;
|
|
1283
|
-
}
|
|
1284
|
-
static isError(error) {
|
|
1285
|
-
return Error.isError(error) && error.name === "BatchJobFailedError" && typeof error.key === "string" && typeof error.jobs === "object";
|
|
1338
|
+
//#region src/graphql-client/create-defaults.ts
|
|
1339
|
+
/** The host's policy for a new document; a host without `createDefaults` is refused, as a guess could under-sign. */
|
|
1340
|
+
async function readCreateSignaturePolicy(sdk, signal) {
|
|
1341
|
+
const defaults = await readCreateDefaults(sdk, void 0, signal);
|
|
1342
|
+
if (defaults === void 0) throw new GraphQLOperationNotSupportedError("getCreateSignaturePolicy", "the Switchboard predates the createDefaults query");
|
|
1343
|
+
const { signaturePolicy } = defaults;
|
|
1344
|
+
if (!isSignaturePolicy(signaturePolicy)) throw new Error(`The Switchboard answered an unknown create signature policy: ${signaturePolicy}`);
|
|
1345
|
+
return signaturePolicy;
|
|
1346
|
+
}
|
|
1347
|
+
/** The host's per-type selection, capped at what this build runs and fitted to `modules`; baseline from an old host. */
|
|
1348
|
+
async function readCreateProtocolVersions(sdk, { documentType, parentIdentifier }, modules, signal) {
|
|
1349
|
+
const host = await hostCreateProtocolVersions(sdk, documentType, parentIdentifier, signal);
|
|
1350
|
+
return capSelection(host, PEER_CAPABILITIES, localSupports(PEER_CAPABILITIES, {}));
|
|
1351
|
+
}
|
|
1352
|
+
/** The Switchboard's selection; undefined from a host without `createDefaults`. */
|
|
1353
|
+
async function hostCreateProtocolVersions(sdk, documentType, parentIdentifier, signal) {
|
|
1354
|
+
if (documentType !== void 0) try {
|
|
1355
|
+
return protocolVersionsFrom((await sdk.GetCreateProtocolVersions({
|
|
1356
|
+
documentType,
|
|
1357
|
+
parentIdOrSlug: parentIdentifier
|
|
1358
|
+
}, void 0, signal)).createDefaults.protocolVersions);
|
|
1359
|
+
} catch (error) {
|
|
1360
|
+
if (queriesUnknownField(error, "createDefaults")) return void 0;
|
|
1361
|
+
if (!queriesUnknownArgument(error, "documentType")) throw error;
|
|
1286
1362
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
constructor(job) {
|
|
1298
|
-
super(job.error?.message);
|
|
1299
|
-
this.job = job;
|
|
1363
|
+
const defaults = await readCreateDefaults(sdk, parentIdentifier, signal);
|
|
1364
|
+
return defaults && protocolVersionsFrom(defaults.protocolVersions);
|
|
1365
|
+
}
|
|
1366
|
+
/** The reactor-wide `createDefaults`; undefined from a host without the query. */
|
|
1367
|
+
async function readCreateDefaults(sdk, parentIdentifier, signal) {
|
|
1368
|
+
try {
|
|
1369
|
+
return (await sdk.GetCreateDefaults({ parentIdOrSlug: parentIdentifier }, void 0, signal)).createDefaults;
|
|
1370
|
+
} catch (error) {
|
|
1371
|
+
if (queriesUnknownField(error, "createDefaults")) return;
|
|
1372
|
+
throw error;
|
|
1300
1373
|
}
|
|
1301
|
-
|
|
1302
|
-
|
|
1374
|
+
}
|
|
1375
|
+
function protocolVersionsFrom(value) {
|
|
1376
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("The Switchboard answered malformed create protocol versions");
|
|
1377
|
+
const versions = {};
|
|
1378
|
+
for (const [protocol, version] of Object.entries(value)) {
|
|
1379
|
+
if (typeof version !== "number" || !Number.isInteger(version)) throw new Error(`The Switchboard answered a malformed version for protocol ${protocol}`);
|
|
1380
|
+
versions[protocol] = version;
|
|
1303
1381
|
}
|
|
1304
|
-
|
|
1382
|
+
return versions;
|
|
1383
|
+
}
|
|
1305
1384
|
//#endregion
|
|
1306
1385
|
//#region src/graphql-client/operations.ts
|
|
1307
1386
|
/**
|
|
@@ -2043,6 +2122,7 @@ var GraphQLSettledWriteHandle = class {
|
|
|
2043
2122
|
};
|
|
2044
2123
|
//#endregion
|
|
2045
2124
|
//#region src/graphql-client/graphql-reactor-client.ts
|
|
2125
|
+
const BUILT_IN_MODELS = [driveDocumentModelModule];
|
|
2046
2126
|
/** Paging defaults, matching the reactor's own client. */
|
|
2047
2127
|
const defaultPaging = {
|
|
2048
2128
|
cursor: "0",
|
|
@@ -2473,39 +2553,22 @@ var GraphQLReactorClient = class {
|
|
|
2473
2553
|
await delay(JOB_POLL_INTERVAL_MS, signal);
|
|
2474
2554
|
}
|
|
2475
2555
|
}
|
|
2476
|
-
/**
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
* {@link GraphQLOperationNotSupportedError}: a guessed default would
|
|
2480
|
-
* under-sign on a stricter host.
|
|
2481
|
-
*/
|
|
2482
|
-
async getCreateSignaturePolicy() {
|
|
2483
|
-
return (await this.createDefaults("getCreateSignaturePolicy")).signaturePolicy;
|
|
2556
|
+
/** See {@link readCreateSignaturePolicy}. */
|
|
2557
|
+
getCreateSignaturePolicy() {
|
|
2558
|
+
return readCreateSignaturePolicy(this.sdk);
|
|
2484
2559
|
}
|
|
2485
|
-
/**
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
* caller may not read is refused by the server, never answered as if none
|
|
2489
|
-
* was named; a Switchboard without the query is refused with
|
|
2490
|
-
* {@link GraphQLOperationNotSupportedError}.
|
|
2491
|
-
*/
|
|
2492
|
-
async getCreateProtocolVersions(parentIdentifier, signal) {
|
|
2493
|
-
return (await this.createDefaults("getCreateProtocolVersions", parentIdentifier, signal)).protocolVersions;
|
|
2560
|
+
/** See {@link readCreateProtocolVersions}; fitted to `documentModels`. */
|
|
2561
|
+
getCreateProtocolVersions(options, signal) {
|
|
2562
|
+
return readCreateProtocolVersions(this.sdk, options, this.documentModels(), signal);
|
|
2494
2563
|
}
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
const { signaturePolicy, protocolVersions } = result.createDefaults;
|
|
2504
|
-
if (!isSignaturePolicy(signaturePolicy)) throw new Error(`The Switchboard answered an unknown create signature policy: ${signaturePolicy}`);
|
|
2505
|
-
return {
|
|
2506
|
-
signaturePolicy,
|
|
2507
|
-
protocolVersions: protocolVersionsFrom(protocolVersions)
|
|
2508
|
-
};
|
|
2564
|
+
/** See {@link IReactorClient.newDocument}; the module comes from `documentModels`. */
|
|
2565
|
+
async newDocument(documentType, options, signal) {
|
|
2566
|
+
const module = selectDocumentModelModule([...this.documentModels(), ...BUILT_IN_MODELS], documentType, options?.documentModelVersion);
|
|
2567
|
+
const [policy, versions] = await Promise.all([options?.signaturePolicy ?? this.getCreateSignaturePolicy(), this.getCreateProtocolVersions({
|
|
2568
|
+
documentType,
|
|
2569
|
+
parentIdentifier: options?.parentIdentifier
|
|
2570
|
+
}, signal)]);
|
|
2571
|
+
return headNewDocument(module, options, policy, versions);
|
|
2509
2572
|
}
|
|
2510
2573
|
/**
|
|
2511
2574
|
* Sets or, with `null`, clears the preferred editor as a client-signed
|
|
@@ -3292,17 +3355,6 @@ function jobInfoFromGql(job) {
|
|
|
3292
3355
|
return info;
|
|
3293
3356
|
}
|
|
3294
3357
|
/**
|
|
3295
|
-
* Whether a request failed because the server's schema has no such root field:
|
|
3296
|
-
* a Switchboard older than the field. graphql-js validation words this the same
|
|
3297
|
-
* under every gateway the Switchboard can run.
|
|
3298
|
-
*/
|
|
3299
|
-
function queriesUnknownField(error, field) {
|
|
3300
|
-
const errors = error?.response?.errors;
|
|
3301
|
-
if (!Array.isArray(errors)) return false;
|
|
3302
|
-
const prefix = `Cannot query field "${field}" on type "`;
|
|
3303
|
-
return errors.some((entry) => typeof entry?.message === "string" && entry.message.startsWith(prefix));
|
|
3304
|
-
}
|
|
3305
|
-
/**
|
|
3306
3358
|
* The header a Switchboard's drive middleware and load balancer key on. A
|
|
3307
3359
|
* request carries it only when it is known to belong to that one drive: the
|
|
3308
3360
|
* server answers any drive it does not own with 421.
|
|
@@ -3337,16 +3389,6 @@ function wrongBackendErrorOf(error) {
|
|
|
3337
3389
|
const driveId = payload?.driveId;
|
|
3338
3390
|
return new GraphQLWrongBackendError(typeof driveId === "string" ? driveId : "", payload, { cause: error });
|
|
3339
3391
|
}
|
|
3340
|
-
/** Protocol versions as the server sent them; anything but a version map throws. */
|
|
3341
|
-
function protocolVersionsFrom(value) {
|
|
3342
|
-
if (!isPlainObject(value)) throw new Error("The Switchboard answered malformed create protocol versions");
|
|
3343
|
-
const versions = {};
|
|
3344
|
-
for (const [protocol, version] of Object.entries(value)) {
|
|
3345
|
-
if (typeof version !== "number" || !Number.isInteger(version)) throw new Error(`The Switchboard answered a malformed version for protocol ${protocol}`);
|
|
3346
|
-
versions[protocol] = version;
|
|
3347
|
-
}
|
|
3348
|
-
return versions;
|
|
3349
|
-
}
|
|
3350
3392
|
function isSettled(job) {
|
|
3351
3393
|
const status = job.status;
|
|
3352
3394
|
return status === "READ_READY" || status === "FAILED";
|
|
@@ -3421,7 +3463,7 @@ const allowedDocumentTypesEventFunctions = makePHEventFunctions("allowedDocument
|
|
|
3421
3463
|
const setAllowedDocumentTypes = allowedDocumentTypesEventFunctions.setValue;
|
|
3422
3464
|
/** Defines the document types a drive supports.
|
|
3423
3465
|
*
|
|
3424
|
-
*
|
|
3466
|
+
* Unset or empty, it means every document type registered in the reactor.
|
|
3425
3467
|
*/
|
|
3426
3468
|
function useAllowedDocumentTypes() {
|
|
3427
3469
|
return allowedDocumentTypesEventFunctions.useValue();
|
|
@@ -4134,6 +4176,6 @@ function useDocumentOperations(documentId, scope, options = {}) {
|
|
|
4134
4176
|
return legacy ? legacyResult : primary;
|
|
4135
4177
|
}
|
|
4136
4178
|
//#endregion
|
|
4137
|
-
export { addIsAnalyticsExternalProcessorsEnabledEventHandler as $,
|
|
4179
|
+
export { addIsAnalyticsExternalProcessorsEnabledEventHandler as $, getFullReactorClient as $i, useIsEditorDebugModeEnabled as $n, resolveDocumentModelModule as $r, setIsDeleteLocalDrivesEnabled as $t, useDropTarget as A, queriesUnknownArgument as Ai, useAnalyticsDatabaseName as An, phDocumentEditorConfigHooks as Ar, addVersionEventHandler as At, addCliVersionEventHandler as B, getDocumentExtension as Bi, useIsAddDriveEnabled as Bn, findIsServableOverGraphQL as Br, setDrivesPreserveStrategy as Bt, usePackageDiscoveryService as C, usePHModal as Ca, COMMON_PACKAGE_ID as Ci, setSentryRelease as Cn, useWarnOutdatedApp as Cr, addRouterBasenameEventHandler as Ct, addDraggingNodeEventHandler as D, usePHNavigation as Da, GraphQLOperationNotSupportedError as Di, setVersionCheckInterval as Dn, isExternalControlsEnabledEventFunctions as Dr, addStudioModeEventHandler as Dt, useGraphQLReactorClient as E, useLinkProps as Ea, BatchJobFailedError as Ei, setVersion as En, addIsExternalControlsEnabledEventHandler as Er, addSentryReleaseEventHandler as Et, setAttachmentService as F, copyNode$1 as Fi, useDrivesPreserveStrategy as Fn, useAllowedDocumentTypes as Fr, setAnalyticsDatabaseName as Ft, addFileUploadOperationsChunkSizeEventHandler as G, setPreferredEditorOnNode as Gi, useIsAnalyticsExternalProcessorsEnabled as Gn, makeAuthConnectionParams as Gr, setIsAddDriveEnabled as Gt, addDisabledEditorsEventHandler as H, moveNode$1 as Hi, useIsAddPublicDrivesEnabled as Hn, viewFilterInputFromViewFilter as Hr, setFileUploadOperationsChunkSize as Ht, useAttachmentService as I, deleteNode as Ii, useEnabledEditors as In, useIsDragAndDropEnabled as Ir, setBasePath as It, addIsAddDriveEnabledEventHandler as J, isDocumentTypeSupported as Ji, useIsDeleteLocalDrivesEnabled as Jn, SubgraphSdkRegistry as Jr, setIsAnalyticsDatabaseWorkerEnabled as Jt, addGaTrackingIdEventHandler as K, upgradeDocument as Ki, useIsCloudDrivesEnabled as Kn, startDocumentChangesSubscription as Kr, setIsAddLocalDrivesEnabled as Kt, addAllowListEventHandler as L, exportFile as Li, useFileUploadOperationsChunkSize as Ln, useIsExternalControlsEnabled as Lr, setCliVersion as Lt, setFeatures as M, addDocument as Mi, useCliVersion as Mn, setAllowedDocumentTypes as Mr, phGlobalConfigHooks as Mt, useFeatures as N, addFileWithProgress as Ni, useDefaultDrivesUrl as Nn, setIsDragAndDropEnabled as Nr, phGlobalConfigSetters as Nt, useDragNode as O, useSearchParams as Oa, GraphQLWrongBackendError as Oi, setWarnOutdatedApp as On, phAppConfigHooks as Or, addSwitchboardUrlEventHandler as Ot, addAttachmentServiceEventHandler as P, addFolder$1 as Pi, useDisabledEditors as Pn, setIsExternalControlsEnabled as Pr, setAllowList as Pt, addIsAnalyticsEnabledEventHandler as Q, addReactorHalvesEventHandler as Qi, useIsDriveAnalyticsEnabled as Qn, packageFromDocumentModels as Qr, setIsDeleteCloudDrivesEnabled as Qt, addAnalyticsDatabaseNameEventHandler as R, extractInitialState as Ri, useGaTrackingId as Rn, GraphQLReactorClient as Rr, setDefaultDrivesUrl as Rt, setPackageDiscoveryService as S, useModalLinkProps as Sa, underSignaturePolicy as Si, setSentryEnv as Sn, useVersionCheckInterval as Sr, addRequiresHardRefreshEventHandler as St, setGraphQLReactorClient as T, isPlainClick as Ta, DRIVE_DOCUMENT_TYPES as Ti, setSwitchboardUrl as Tn, addIsDragAndDropEnabledEventHandler as Tr, addSentryEnvEventHandler as Tt, addDrivesPreserveStrategyEventHandler as U, renameDriveNode as Ui, useIsAnalyticsDatabaseWorkerEnabled as Un, createJobChangesSocket as Ur, setGaTrackingId as Ut, addDefaultDrivesUrlEventHandler as V, loadFile as Vi, useIsAddLocalDrivesEnabled as Vn, isGraphQLReactorClient as Vr, setEnabledEditors as Vt, addEnabledEditorsEventHandler as W, renameNode as Wi, useIsAnalyticsEnabled as Wn, isAuthRefusalClose as Wr, setIsAddCloudDrivesEnabled as Wt, addIsAddPublicDrivesEnabledEventHandler as X, addReactorClientEventHandler as Xi, useIsDiffAnalyticsEnabled as Xn, subgraphUrlFromGraphqlUrl as Xr, setIsAnalyticsExternalProcessorsEnabled as Xt, addIsAddLocalDrivesEnabledEventHandler as Y, addFullReactorClientEventHandler as Yi, useIsDeletePublicDrivesEnabled as Yn, describeGraphQLDocument as Yr, setIsAnalyticsEnabled as Yt, addIsAnalyticsDatabaseWorkerEnabledEventHandler as Z, addReactorClientModuleEventHandler as Zi, useIsDocumentModelSelectionSettingsEnabled as Zn, StaticPackageManager as Zr, setIsCloudDrivesEnabled as Zt, addSetSelectedDriveOnPopStateEventHandler as _, modalSearch as _a, convertRemoteOperations as _i, setRenownNetworkId as _n, useSentryEnv as _r, addLogLevelEventHandler as _t, addPHEventHandlers as a, usePGlite as aa, ReactorOperationFieldsFragmentDoc as ai, setIsEditorReadModeEnabled as an, useIsPublicDrivesEnabled as ar, addIsDocumentModelSelectionSettingsEnabledEventHandler as at, syncSelectionFromPath as b, showDeleteNodeModal as ba, screamingSnakeToCamel as bi, setRouterBasename as bn, useSwitchboardUrl as br, addRenownNetworkIdEventHandler as bt, addToastEventHandler as c, useReactorHalves as ca, GraphQLDriveNodeSource as ci, setIsExternalRelationalProcessorsEnabled as cn, useLocalDrivesEnabled as cr, addIsEditorReadModeEnabledEventHandler as ct, addSelectedTimelineRevisionEventHandler as d, MODAL_SEARCH_PARAM as da, isoStringFromDateTime as di, setIsRelationalProcessorsEnabled as dn, useRenownChainId as dr, addIsExternalRelationalProcessorsEnabledEventHandler as dt, setFullReactorClient as ea, prepareSignedActions as ei, setIsDeletePublicDrivesEnabled as en, useIsEditorReadModeEnabled as er, addIsCloudDrivesEnabledEventHandler as et, setSelectedTimelineRevision as f, addModalEventHandler as fa, phDocumentFromGetDocument as fi, setIsSentryTracingEnabled as fn, useRenownNetworkId as fr, addIsLocalDrivesEnabledEventHandler as ft, useSelectedTimelineItem as g, modalHref as ga, buildPulledDocument as gi, setRenownChainId as gn, useSentryDsn as gr, addLocalDrivesEnabledEventHandler as gt, setSelectedTimelineItem as h, modalFromSearch as ha, ConflictError as hi, setRenownAdapters as hn, useRouterBasename as hr, addIsSentryTracingEnabledEventHandler as ht, useSwitchboardClient as i, useModelRegistry as ia, MutateDocumentWithOperationsDocument as ii, setIsEditorDebugModeEnabled as in, useIsLocalDrivesEnabled as ir, addIsDiffAnalyticsEnabledEventHandler as it, addFeaturesEventHandler as j, queriesUnknownField as ji, useBasePath as jn, phDocumentEditorConfigSetters as jr, addWarnOutdatedAppEventHandler as jt, useDropNode as k, useSetSearchParams as ka, JobFailedError as ki, useAllowList as kn, phAppConfigSetters as kr, addVersionCheckIntervalEventHandler as kt, setPHToast as l, useSync as la, GraphQLDriveReadClient as li, setIsLocalDrivesEnabled as ln, useLogLevel as lr, addIsExternalPackagesEnabledEventHandler as lt, addSelectedTimelineItemEventHandler as m, isRoutedModal as ma, revisionMapFromRevisionsList as mi, setLogLevel as mn, useRequiresHardRefresh as mr, addIsRelationalProcessorsEnabledEventHandler as mt, GraphQLReactorProvider as n, setReactorClientModule as na, stampAction as ni, setIsDocumentModelSelectionSettingsEnabled as nn, useIsExternalProcessorsEnabled as nr, addIsDeleteLocalDrivesEnabledEventHandler as nt, callEventHandlerRegisterFunctions as o, useReactorClient as oa, readCreateProtocolVersions as oi, setIsExternalPackagesEnabled as on, useIsRelationalProcessorsEnabled as or, addIsDriveAnalyticsEnabledEventHandler as ot, useSelectedTimelineRevision as p, closePHModal as pa, phDocumentFromMutation as pi, setLocalDrivesEnabled as pn, useRenownUrl as pr, addIsPublicDrivesEnabledEventHandler as pt, addIsAddCloudDrivesEnabledEventHandler as q, getUserPermissions as qi, useIsDeleteCloudDrivesEnabled as qn, subscriptionsUrlFromGraphqlUrl as qr, setIsAddPublicDrivesEnabled as qt, ensurePHEventHandlers as r, useDatabase as ra, GetDocumentAtConsistencyDocument as ri, setIsDriveAnalyticsEnabled as rn, useIsExternalRelationalProcessorsEnabled as rr, addIsDeletePublicDrivesEnabledEventHandler as rt, commonGlobalEventHandlerFunctions as s, useReactorClientModule as sa, readCreateSignaturePolicy as si, setIsExternalProcessorsEnabled as sn, useIsSentryTracingEnabled as sr, addIsEditorDebugModeEnabledEventHandler as st, useDocumentOperations as t, setReactorClient as ta, signStampedAction as ti, setIsDiffAnalyticsEnabled as tn, useIsExternalPackagesEnabled as tr, addIsDeleteCloudDrivesEnabledEventHandler as tt, usePHToast as u, useSyncList as ua, toLegacyNode as ui, setIsPublicDrivesEnabled as un, useRenownAdapters as ur, addIsExternalProcessorsEnabledEventHandler as ut, addSetSelectedNodeOnPopStateEventHandler as v, setPHModal as va, extractRevisionMap as vi, setRenownUrl as vn, useSentryRelease as vr, addRenownAdaptersEventHandler as vt, addGraphQLReactorClientEventHandler as w, withoutModalSearch as wa, DEFAULT_DRIVE_EDITOR_ID as wi, setStudioMode as wn, addAllowedDocumentTypesEventHandler as wr, addSentryDsnEventHandler as wt, addPackageDiscoveryServiceEventHandler as x, showPHModal as xa, uncreatedDocument as xi, setSentryDsn as xn, useVersion as xr, addRenownUrlEventHandler as xt, addSyncSelectionOnPopStateEventHandler as y, showCreateDocumentModal as ya, hasRevisionConflict as yi, setRequiresHardRefresh as yn, useStudioMode as yr, addRenownChainIdEventHandler as yt, addBasePathEventHandler as z, fetchDocumentOperations as zi, useIsAddCloudDrivesEnabled as zn, createGraphQLDriveNodeSource as zr, setDisabledEditors as zt };
|
|
4138
4180
|
|
|
4139
|
-
//# sourceMappingURL=document-operations-
|
|
4181
|
+
//# sourceMappingURL=document-operations-B0GZilXW.js.map
|