@powerhousedao/reactor-browser 6.2.3-dev.81 → 6.2.3-dev.83
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-DPWkKp3y.d.ts → attachment-service-BuPjCTlF.d.ts} +126 -36
- package/dist/attachment-service-BuPjCTlF.d.ts.map +1 -0
- package/dist/{dispatch-C8J9jQ-o.js → dispatch-Cylwl2Dk.js} +4 -2
- package/dist/dispatch-Cylwl2Dk.js.map +1 -0
- package/dist/{document-by-id-Dpp76ZNE.js → document-by-id-DdvqanGR.js} +2 -2
- package/dist/{document-by-id-Dpp76ZNE.js.map → document-by-id-DdvqanGR.js.map} +1 -1
- package/dist/{document-model-modules-XrYfGXt8.js → document-model-modules-D-VXC3ET.js} +2 -2
- package/dist/{document-model-modules-XrYfGXt8.js.map → document-model-modules-D-VXC3ET.js.map} +1 -1
- package/dist/{document-operations-CdfiLNQN.js → document-operations-CsiIPsx9.js} +321 -16
- package/dist/document-operations-CsiIPsx9.js.map +1 -0
- package/dist/{global-BSyOOTvL.d.ts → global-DY6FeQYj.d.ts} +2 -2
- package/dist/{global-BSyOOTvL.d.ts.map → global-DY6FeQYj.d.ts.map} +1 -1
- package/dist/{index-Bjm0bSzf.d.ts → index-C5yCJAVE.d.ts} +2 -2
- package/dist/{index-Bjm0bSzf.d.ts.map → index-C5yCJAVE.d.ts.map} +1 -1
- package/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -12
- 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/entry.d.ts +3 -3
- package/dist/src/graphql-client/entry.js +4 -4
- package/dist/src/renown/index.d.ts +1 -1
- package/dist/src/rpc/index.d.ts +3 -0
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +14 -2
- package/dist/src/rpc/index.js.map +1 -1
- package/dist/{switchboard-CYTCYt4Z.js → switchboard-DnvOmOx5.js} +4 -4
- package/dist/{switchboard-CYTCYt4Z.js.map → switchboard-DnvOmOx5.js.map} +1 -1
- package/package.json +10 -9
- package/dist/attachment-service-DPWkKp3y.d.ts.map +0 -1
- package/dist/dispatch-C8J9jQ-o.js.map +0 -1
- package/dist/document-operations-CdfiLNQN.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as getPHStore, f as usePHStore, t as makePHEventFunctions } from "./make-ph-event-functions-B5GU5xcR.js";
|
|
2
|
-
import {
|
|
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 { A as DocumentModelNotFoundError, D as queueActions, O as queueOperations, P as UnsupportedDocumentTypeError, b as DOCUMENT_CHANGE_TYPE, f as DocumentCache, h as IDLE_OPERATIONS_ENTRY, i as setDocumentCache, k as uploadOperations, o as useDocumentCache, r as addDocumentCacheEventHandler, v as isOperationCache } from "./dispatch-Cylwl2Dk.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-D-VXC3ET.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
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";
|
|
@@ -1335,6 +1335,58 @@ function startCursor(cursor) {
|
|
|
1335
1335
|
return cursor === void 0 || cursor === "0" ? "" : cursor;
|
|
1336
1336
|
}
|
|
1337
1337
|
//#endregion
|
|
1338
|
+
//#region src/graphql-client/transport.ts
|
|
1339
|
+
/** The global `fetch`, read per call so a later replacement is honoured. */
|
|
1340
|
+
const globalFetch = (input, init) => globalThis.fetch(input, init);
|
|
1341
|
+
/**
|
|
1342
|
+
* Whether `fetch` here is Node's (undici), which resends a request answered
|
|
1343
|
+
* 421 and can fail the resend of a buffered body. A page, Electron's renderer
|
|
1344
|
+
* included, has a `document`.
|
|
1345
|
+
*/
|
|
1346
|
+
function isNodeFetch() {
|
|
1347
|
+
const scope = globalThis;
|
|
1348
|
+
return typeof scope.process?.versions?.node === "string" && scope.document === void 0;
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* Sends a string body as a stream, which fetch never resends, so a 421 comes
|
|
1352
|
+
* back as itself. Browsers keep buffered bodies: Chrome streams an upload only
|
|
1353
|
+
* over HTTP/2.
|
|
1354
|
+
*/
|
|
1355
|
+
function withStreamedBodies(inner = globalFetch) {
|
|
1356
|
+
return (input, init) => {
|
|
1357
|
+
const body = init?.body;
|
|
1358
|
+
if (typeof body !== "string") return inner(input, init);
|
|
1359
|
+
return inner(input, {
|
|
1360
|
+
...init,
|
|
1361
|
+
body: new Blob([body]).stream(),
|
|
1362
|
+
duplex: "half"
|
|
1363
|
+
});
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
const streamedGlobalFetch = withStreamedBodies(globalFetch);
|
|
1367
|
+
/** A Switchboard backend's default transport: streamed bodies under Node only. */
|
|
1368
|
+
const switchboardFetch = (input, init) => isNodeFetch() ? streamedGlobalFetch(input, init) : globalFetch(input, init);
|
|
1369
|
+
/** Bounds each request, headers through body; rejects with a `TimeoutError`. */
|
|
1370
|
+
function withRequestDeadline(timeoutMs, inner = globalFetch) {
|
|
1371
|
+
return (input, init) => {
|
|
1372
|
+
const deadline = AbortSignal.timeout(timeoutMs);
|
|
1373
|
+
const signal = init?.signal ? AbortSignal.any([init.signal, deadline]) : deadline;
|
|
1374
|
+
return inner(input, {
|
|
1375
|
+
...init,
|
|
1376
|
+
signal
|
|
1377
|
+
});
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
/**
|
|
1381
|
+
* Whether a request failed at a deadline rather than by its caller's abort:
|
|
1382
|
+
* this transport's own (`TimeoutError`, a DOMException) or the router's probe
|
|
1383
|
+
* deadline (`ProbeTimeoutError`, reactor-router's dispatcher.ts).
|
|
1384
|
+
*/
|
|
1385
|
+
function isDeadlineError(error) {
|
|
1386
|
+
const name = error?.name;
|
|
1387
|
+
return name === "TimeoutError" || name === "ProbeTimeoutError";
|
|
1388
|
+
}
|
|
1389
|
+
//#endregion
|
|
1338
1390
|
//#region src/graphql-client/create-defaults.ts
|
|
1339
1391
|
/** The host's policy for a new document; a host without `createDefaults` is refused, as a guess could under-sign. */
|
|
1340
1392
|
async function readCreateSignaturePolicy(sdk, signal) {
|
|
@@ -1827,10 +1879,12 @@ function describeGraphQLDocument(document) {
|
|
|
1827
1879
|
var SubgraphSdkRegistry = class {
|
|
1828
1880
|
url;
|
|
1829
1881
|
middleware;
|
|
1882
|
+
fetch;
|
|
1830
1883
|
bindings = /* @__PURE__ */ new Map();
|
|
1831
|
-
constructor(url, middleware) {
|
|
1884
|
+
constructor(url, middleware, fetch) {
|
|
1832
1885
|
this.url = url;
|
|
1833
1886
|
this.middleware = middleware;
|
|
1887
|
+
this.fetch = fetch;
|
|
1834
1888
|
}
|
|
1835
1889
|
/**
|
|
1836
1890
|
* Returns the subgraph's SDK, building it on first use.
|
|
@@ -1855,7 +1909,7 @@ var SubgraphSdkRegistry = class {
|
|
|
1855
1909
|
binding(name) {
|
|
1856
1910
|
const existing = this.bindings.get(name);
|
|
1857
1911
|
if (existing) return existing;
|
|
1858
|
-
const binding = { transport: new GraphQLClient(this.urlFor(name)) };
|
|
1912
|
+
const binding = { transport: new GraphQLClient(this.urlFor(name), { fetch: this.fetch }) };
|
|
1859
1913
|
this.bindings.set(name, binding);
|
|
1860
1914
|
return binding;
|
|
1861
1915
|
}
|
|
@@ -2162,7 +2216,7 @@ var GraphQLReactorClient = class {
|
|
|
2162
2216
|
tokenProvider;
|
|
2163
2217
|
subscriptionsUrl;
|
|
2164
2218
|
documentModels;
|
|
2165
|
-
|
|
2219
|
+
resolveSigner;
|
|
2166
2220
|
driveIdFor;
|
|
2167
2221
|
stopRealtime;
|
|
2168
2222
|
realtimeStarted = false;
|
|
@@ -2199,12 +2253,14 @@ var GraphQLReactorClient = class {
|
|
|
2199
2253
|
const copied = [...models ?? []];
|
|
2200
2254
|
this.documentModels = () => copied;
|
|
2201
2255
|
}
|
|
2202
|
-
|
|
2256
|
+
const signer = options.signer;
|
|
2257
|
+
this.resolveSigner = typeof signer === "function" ? signer : signer ? () => signer : ambientRenownSigner;
|
|
2203
2258
|
this.driveIdFor = options.driveIdFor;
|
|
2204
2259
|
this.subscriptionsUrl = options.realtime === false ? void 0 : options.subscriptionsUrl ?? subscriptionsUrlFromGraphqlUrl(options.url);
|
|
2205
2260
|
const middleware = withWrongBackendErrors(makeAuthMiddleware(this.tokenProvider));
|
|
2206
|
-
|
|
2207
|
-
this.
|
|
2261
|
+
const fetch = options.requestTimeoutMs === void 0 ? options.fetch : withRequestDeadline(options.requestTimeoutMs, options.fetch);
|
|
2262
|
+
this.sdk = options.graphqlClient ?? createClient$1(new GraphQLClient(options.url, { fetch }), middleware);
|
|
2263
|
+
this.subgraphs = new SubgraphSdkRegistry(options.url, middleware, fetch);
|
|
2208
2264
|
this.driveNodes = new GraphQLDriveNodeSource(this.sdk, driveIdHeaders);
|
|
2209
2265
|
this.read = new GraphQLReadHalf(this, this.driveNodes);
|
|
2210
2266
|
this.write = {
|
|
@@ -2457,7 +2513,7 @@ var GraphQLReactorClient = class {
|
|
|
2457
2513
|
const document = await this.get(documentIdentifier, { branch }, signal);
|
|
2458
2514
|
const variables = {
|
|
2459
2515
|
documentIdentifier,
|
|
2460
|
-
actions: (await prepareActionsForPush(actions, document, this.documentModels(), this.
|
|
2516
|
+
actions: (await prepareActionsForPush(actions, document, this.documentModels(), this.resolveSigner(), signal)).map(toTransportAction),
|
|
2461
2517
|
sinceRevision: sinceRevisionForActions(document, actions),
|
|
2462
2518
|
scopes: scopesForActions(actions),
|
|
2463
2519
|
branch
|
|
@@ -2503,7 +2559,7 @@ var GraphQLReactorClient = class {
|
|
|
2503
2559
|
* settled, so {@link waitForJob} resolves from it without polling.
|
|
2504
2560
|
*/
|
|
2505
2561
|
async executeBatch(request, signal) {
|
|
2506
|
-
const signer = this.
|
|
2562
|
+
const signer = this.resolveSigner();
|
|
2507
2563
|
const jobInputs = await Promise.all(request.jobs.map(async (job, index) => {
|
|
2508
2564
|
const documentId = await this.batchWriteTarget(job, request.jobs.slice(0, index), signer, signal);
|
|
2509
2565
|
const actions = await this.signBatchJobActions({
|
|
@@ -2824,7 +2880,7 @@ var GraphQLReactorClient = class {
|
|
|
2824
2880
|
*/
|
|
2825
2881
|
async submitExecute(documentIdentifier, branch, actions, signal) {
|
|
2826
2882
|
const document = await this.get(documentIdentifier, { branch }, signal);
|
|
2827
|
-
const preparedActions = await prepareActionsForPush(actions, document, this.documentModels(), this.
|
|
2883
|
+
const preparedActions = await prepareActionsForPush(actions, document, this.documentModels(), this.resolveSigner(), signal);
|
|
2828
2884
|
const handle = new GraphQLJobWriteHandle(jobInfoFromGql((await this.sdk.MutateDocumentAsync({
|
|
2829
2885
|
documentIdentifier,
|
|
2830
2886
|
actions: preparedActions.map(toTransportAction),
|
|
@@ -3305,8 +3361,7 @@ function propagationModeInput(propagate) {
|
|
|
3305
3361
|
* action needing history - throws here, before the mutation. Sending it
|
|
3306
3362
|
* unsigned instead would silently drop the signatures the caller asked for.
|
|
3307
3363
|
*/
|
|
3308
|
-
async function prepareActionsForPush(actions, document, documentModels,
|
|
3309
|
-
const signer = explicitSigner ?? resolveAmbientSigner();
|
|
3364
|
+
async function prepareActionsForPush(actions, document, documentModels, signer, signal) {
|
|
3310
3365
|
if (!signer || actions.length === 0) return actions;
|
|
3311
3366
|
return prepareSignedActions(actions, document, signer, actions.length > 1 ? resolveDocumentModelModule(documentModels, document.header.documentType, documentModelVersion(document)) : void 0, signal);
|
|
3312
3367
|
}
|
|
@@ -3420,7 +3475,8 @@ function isActionSigned(action) {
|
|
|
3420
3475
|
return Boolean(signer?.app?.key && signer.signatures.at(-1)?.[1]);
|
|
3421
3476
|
}
|
|
3422
3477
|
/** Resolves the signer of the logged-in user, if there is one. */
|
|
3423
|
-
|
|
3478
|
+
/** The logged-in Renown user's signer, read per call; none when nobody is. */
|
|
3479
|
+
function ambientRenownSigner() {
|
|
3424
3480
|
if (typeof window === "undefined") return;
|
|
3425
3481
|
const renown = getPHStore()?.renown;
|
|
3426
3482
|
return renown?.user ? renown.signer : void 0;
|
|
@@ -4152,6 +4208,255 @@ function useSwitchboardClient() {
|
|
|
4152
4208
|
return isGraphQLReactorClient(client) ? client : void 0;
|
|
4153
4209
|
}
|
|
4154
4210
|
//#endregion
|
|
4211
|
+
//#region src/graphql-client/switchboard-backend.ts
|
|
4212
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
4213
|
+
const DEFAULT_BREAKER = Object.freeze({
|
|
4214
|
+
failures: 3,
|
|
4215
|
+
openMs: 3e4
|
|
4216
|
+
});
|
|
4217
|
+
const FACTS_QUERY = `
|
|
4218
|
+
query SwitchboardFacts {
|
|
4219
|
+
inspection {
|
|
4220
|
+
info {
|
|
4221
|
+
storage {
|
|
4222
|
+
engine
|
|
4223
|
+
persistence
|
|
4224
|
+
durable
|
|
4225
|
+
selfHeal
|
|
4226
|
+
}
|
|
4227
|
+
workflows
|
|
4228
|
+
syncChannels
|
|
4229
|
+
access {
|
|
4230
|
+
admin
|
|
4231
|
+
sql
|
|
4232
|
+
}
|
|
4233
|
+
}
|
|
4234
|
+
documentModels {
|
|
4235
|
+
documentType
|
|
4236
|
+
}
|
|
4237
|
+
}
|
|
4238
|
+
queries: __type(name: "Query") {
|
|
4239
|
+
fields {
|
|
4240
|
+
name
|
|
4241
|
+
}
|
|
4242
|
+
}
|
|
4243
|
+
inspectionFields: __type(name: "ReactorInspection") {
|
|
4244
|
+
fields {
|
|
4245
|
+
name
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
`;
|
|
4250
|
+
const MODEL_LOADING_QUERY = `
|
|
4251
|
+
query SwitchboardModelLoading {
|
|
4252
|
+
inspection {
|
|
4253
|
+
loadsModelsOnDemand
|
|
4254
|
+
}
|
|
4255
|
+
}
|
|
4256
|
+
`;
|
|
4257
|
+
/** Queries this backend sends that a Switchboard serves only from some version. */
|
|
4258
|
+
const REQUIRED_QUERIES = [
|
|
4259
|
+
"documentServed",
|
|
4260
|
+
"createDefaults",
|
|
4261
|
+
"inspection"
|
|
4262
|
+
];
|
|
4263
|
+
/** The Switchboard's circuit is open: nothing was sent. */
|
|
4264
|
+
var SwitchboardUnreachableError = class extends Error {
|
|
4265
|
+
backend;
|
|
4266
|
+
retryAt;
|
|
4267
|
+
name = "SwitchboardUnreachableError";
|
|
4268
|
+
constructor(backend, retryAt) {
|
|
4269
|
+
super(`Switchboard backend ${JSON.stringify(backend)} is unreachable; nothing is sent until ${new Date(retryAt).toISOString()}`);
|
|
4270
|
+
this.backend = backend;
|
|
4271
|
+
this.retryAt = retryAt;
|
|
4272
|
+
}
|
|
4273
|
+
};
|
|
4274
|
+
/**
|
|
4275
|
+
* Opens after `failures` transport failures in a row (a network error, a
|
|
4276
|
+
* deadline or a 5xx) and sends nothing for `openMs`. Any other answer, a
|
|
4277
|
+
* GraphQL error included, closes it. The first request after `openMs` goes
|
|
4278
|
+
* through; one more failure opens it again.
|
|
4279
|
+
*/
|
|
4280
|
+
var Breaker = class {
|
|
4281
|
+
backend;
|
|
4282
|
+
settings;
|
|
4283
|
+
consecutive = 0;
|
|
4284
|
+
openUntil;
|
|
4285
|
+
constructor(backend, settings) {
|
|
4286
|
+
this.backend = backend;
|
|
4287
|
+
this.settings = settings;
|
|
4288
|
+
}
|
|
4289
|
+
health() {
|
|
4290
|
+
return this.isOpen() ? "down" : "up";
|
|
4291
|
+
}
|
|
4292
|
+
wrap(inner) {
|
|
4293
|
+
return async (input, init) => {
|
|
4294
|
+
const openUntil = this.openUntil;
|
|
4295
|
+
if (openUntil !== void 0 && Date.now() < openUntil) throw new SwitchboardUnreachableError(this.backend, openUntil);
|
|
4296
|
+
let response;
|
|
4297
|
+
try {
|
|
4298
|
+
response = await inner(input, init);
|
|
4299
|
+
} catch (error) {
|
|
4300
|
+
if (!abortedByCaller(init?.signal)) this.fail();
|
|
4301
|
+
throw error;
|
|
4302
|
+
}
|
|
4303
|
+
if (response.status >= 500) this.fail();
|
|
4304
|
+
else {
|
|
4305
|
+
this.consecutive = 0;
|
|
4306
|
+
this.openUntil = void 0;
|
|
4307
|
+
}
|
|
4308
|
+
return response;
|
|
4309
|
+
};
|
|
4310
|
+
}
|
|
4311
|
+
isOpen() {
|
|
4312
|
+
return this.openUntil !== void 0 && Date.now() < this.openUntil;
|
|
4313
|
+
}
|
|
4314
|
+
fail() {
|
|
4315
|
+
this.consecutive += 1;
|
|
4316
|
+
if (this.consecutive >= this.settings.failures) this.openUntil = Date.now() + this.settings.openMs;
|
|
4317
|
+
}
|
|
4318
|
+
};
|
|
4319
|
+
function abortedByCaller(signal) {
|
|
4320
|
+
return Boolean(signal?.aborted) && !isDeadlineError(signal?.reason);
|
|
4321
|
+
}
|
|
4322
|
+
const NO_ACCESS = Object.freeze({
|
|
4323
|
+
admin: false,
|
|
4324
|
+
sql: false
|
|
4325
|
+
});
|
|
4326
|
+
/** Ids and slugs of documents this backend answered as drives, by drive id. */
|
|
4327
|
+
var KnownDrives = class {
|
|
4328
|
+
ids = /* @__PURE__ */ new Map();
|
|
4329
|
+
learn(document) {
|
|
4330
|
+
const { id, slug, documentType } = document.header;
|
|
4331
|
+
if (DRIVE_DOCUMENT_TYPES.includes(documentType)) {
|
|
4332
|
+
this.ids.set(id, id);
|
|
4333
|
+
if (slug) this.ids.set(slug, id);
|
|
4334
|
+
}
|
|
4335
|
+
return document;
|
|
4336
|
+
}
|
|
4337
|
+
learnPage(page) {
|
|
4338
|
+
for (const document of page.results) this.learn(document);
|
|
4339
|
+
return page;
|
|
4340
|
+
}
|
|
4341
|
+
/** Drops a drive the Switchboard refused, by id and by slug. */
|
|
4342
|
+
forget(driveId) {
|
|
4343
|
+
for (const [identifier, id] of this.ids) if (id === driveId) this.ids.delete(identifier);
|
|
4344
|
+
}
|
|
4345
|
+
driveOf(identifier) {
|
|
4346
|
+
return identifier === void 0 ? void 0 : this.ids.get(identifier);
|
|
4347
|
+
}
|
|
4348
|
+
/** Names a drive only when this backend proved it is one. */
|
|
4349
|
+
driveIdFor = (call) => {
|
|
4350
|
+
switch (call.method) {
|
|
4351
|
+
case "create":
|
|
4352
|
+
case "find": return this.driveOf(call.parentId);
|
|
4353
|
+
case "execute":
|
|
4354
|
+
case "deleteDocument": return this.driveOf(call.documentId);
|
|
4355
|
+
case "executeBatch":
|
|
4356
|
+
for (const job of call.jobs ?? []) {
|
|
4357
|
+
const drive = this.driveOf(job.documentId);
|
|
4358
|
+
if (drive !== void 0) return drive;
|
|
4359
|
+
}
|
|
4360
|
+
return;
|
|
4361
|
+
}
|
|
4362
|
+
};
|
|
4363
|
+
/** Runs a call that may carry `Drive-Id`; a 421 forgets the drive it named. */
|
|
4364
|
+
async refusable(call) {
|
|
4365
|
+
try {
|
|
4366
|
+
return await call;
|
|
4367
|
+
} catch (error) {
|
|
4368
|
+
if (GraphQLWrongBackendError.isError(error)) this.forget(error.driveId);
|
|
4369
|
+
throw error;
|
|
4370
|
+
}
|
|
4371
|
+
}
|
|
4372
|
+
};
|
|
4373
|
+
function isUnknownJob(job) {
|
|
4374
|
+
return job.status === "FAILED" && job.error?.name === "JobNotFoundError";
|
|
4375
|
+
}
|
|
4376
|
+
/** A Switchboard as a router backend; members GraphQL cannot serve are absent. */
|
|
4377
|
+
function createSwitchboardBackend(descriptor) {
|
|
4378
|
+
const drives = new KnownDrives();
|
|
4379
|
+
const breaker = new Breaker(descriptor.name, descriptor.breaker ?? DEFAULT_BREAKER);
|
|
4380
|
+
const signer = descriptor.signer;
|
|
4381
|
+
const gql = new GraphQLReactorClient({
|
|
4382
|
+
url: descriptor.url,
|
|
4383
|
+
tokenProvider: descriptor.tokenProvider,
|
|
4384
|
+
signer: typeof signer === "function" ? signer : () => signer,
|
|
4385
|
+
documentModels: descriptor.documentModels,
|
|
4386
|
+
realtime: descriptor.realtime,
|
|
4387
|
+
driveIdFor: drives.driveIdFor,
|
|
4388
|
+
requestTimeoutMs: descriptor.requestTimeoutMs ?? 3e4,
|
|
4389
|
+
fetch: breaker.wrap(descriptor.fetch ?? switchboardFetch)
|
|
4390
|
+
});
|
|
4391
|
+
const backend = {
|
|
4392
|
+
supports: {
|
|
4393
|
+
find: findIsServableOverGraphQL,
|
|
4394
|
+
pointInTimeViews: false
|
|
4395
|
+
},
|
|
4396
|
+
health: () => breaker.health(),
|
|
4397
|
+
drives: gql.read.drives,
|
|
4398
|
+
get: async (identifier, view, signal) => drives.learn(await gql.get(identifier, view, signal)),
|
|
4399
|
+
getMany: async (ids, view, signal) => (await gql.getMany(ids, view, signal)).map((document) => drives.learn(document)),
|
|
4400
|
+
getOperations: (identifier, view, filter, paging, signal) => gql.getOperations(identifier, view, filter, paging, signal),
|
|
4401
|
+
find: async (search, view, paging, signal) => drives.learnPage(await drives.refusable(gql.find(search, view, paging, signal))),
|
|
4402
|
+
isServed: (identifier, view, signal) => gql.isServed(identifier, view, signal),
|
|
4403
|
+
getOutgoingRelationships: (source, type, view, paging, signal) => gql.getOutgoingRelationships(source, type, view, paging, signal),
|
|
4404
|
+
getIncomingRelationships: (target, type, view, paging, signal) => gql.getIncomingRelationships(target, type, view, paging, signal),
|
|
4405
|
+
getOutgoingRelationshipEdges: (source, type, view, paging, signal) => gql.getOutgoingRelationshipEdges(source, type, view, paging, signal),
|
|
4406
|
+
getIncomingRelationshipEdges: (target, type, view, paging, signal) => gql.getIncomingRelationshipEdges(target, type, view, paging, signal),
|
|
4407
|
+
subscribe: (search, callback, view) => gql.subscribe(search, callback, view),
|
|
4408
|
+
getCreateSignaturePolicy: () => gql.getCreateSignaturePolicy(),
|
|
4409
|
+
getCreateProtocolVersions: (options, signal) => gql.getCreateProtocolVersions(options, signal),
|
|
4410
|
+
create: async (document, parent, signal) => drives.learn(await drives.refusable(gql.create(document, parent, signal))),
|
|
4411
|
+
execute: async (identifier, branch, actions, signal) => drives.learn(await drives.refusable(gql.execute(identifier, branch, actions, signal))),
|
|
4412
|
+
executeBatch: (request, signal) => drives.refusable(gql.executeBatch(request, signal)),
|
|
4413
|
+
deleteDocument: (identifier, propagate, signal) => drives.refusable(gql.deleteDocument(identifier, propagate, signal)),
|
|
4414
|
+
setPreferredEditor: (identifier, editor, branch, signal) => gql.setPreferredEditor(identifier, editor, branch, signal),
|
|
4415
|
+
getJob: async (jobId, signal) => {
|
|
4416
|
+
const job = await gql.getJob(jobId, signal);
|
|
4417
|
+
return job && isUnknownJob(job) ? void 0 : job;
|
|
4418
|
+
},
|
|
4419
|
+
waitForJob: (job, signal) => gql.waitForJob(job, signal)
|
|
4420
|
+
};
|
|
4421
|
+
let reading;
|
|
4422
|
+
const read = () => reading ??= readFacts(gql, descriptor.url).finally(() => {
|
|
4423
|
+
reading = void 0;
|
|
4424
|
+
});
|
|
4425
|
+
return {
|
|
4426
|
+
config: {
|
|
4427
|
+
name: descriptor.name,
|
|
4428
|
+
backend,
|
|
4429
|
+
facts: async () => (await read()).info,
|
|
4430
|
+
documentTypes: async () => (await read()).documentTypes,
|
|
4431
|
+
reach: {
|
|
4432
|
+
hosting: "remote",
|
|
4433
|
+
inspection: descriptor.inspection ?? "rpc"
|
|
4434
|
+
},
|
|
4435
|
+
refusesMisroutes: false
|
|
4436
|
+
},
|
|
4437
|
+
notifyCredentialsChanged: () => gql.notifyCredentialsChanged(),
|
|
4438
|
+
dispose: () => gql.dispose()
|
|
4439
|
+
};
|
|
4440
|
+
}
|
|
4441
|
+
function fieldNames(type) {
|
|
4442
|
+
return new Set(type?.fields?.map((field) => field.name));
|
|
4443
|
+
}
|
|
4444
|
+
async function readFacts(gql, url) {
|
|
4445
|
+
const answer = await gql.request(FACTS_QUERY);
|
|
4446
|
+
const served = fieldNames(answer.queries);
|
|
4447
|
+
const missing = REQUIRED_QUERIES.filter((query) => !served.has(query));
|
|
4448
|
+
if (missing.length > 0) throw new Error(`The Switchboard at ${url} does not serve ${missing.join(", ")}; it is older than this client`);
|
|
4449
|
+
const { info, documentModels } = answer.inspection;
|
|
4450
|
+
const closed = fieldNames(answer.inspectionFields).has("loadsModelsOnDemand") && !(await gql.request(MODEL_LOADING_QUERY)).inspection.loadsModelsOnDemand;
|
|
4451
|
+
return {
|
|
4452
|
+
info: {
|
|
4453
|
+
...info,
|
|
4454
|
+
access: info.access ?? NO_ACCESS
|
|
4455
|
+
},
|
|
4456
|
+
documentTypes: closed ? documentModels.map((model) => model.documentType) : void 0
|
|
4457
|
+
};
|
|
4458
|
+
}
|
|
4459
|
+
//#endregion
|
|
4155
4460
|
//#region src/hooks/document-operations.ts
|
|
4156
4461
|
const DEFAULT_LIMIT = 100;
|
|
4157
4462
|
function toError(reason) {
|
|
@@ -4239,6 +4544,6 @@ function useDocumentOperations(documentId, scope, options = {}) {
|
|
|
4239
4544
|
return legacy ? legacyResult : primary;
|
|
4240
4545
|
}
|
|
4241
4546
|
//#endregion
|
|
4242
|
-
export {
|
|
4547
|
+
export { addIsAddLocalDrivesEnabledEventHandler as $, deleteNode as $i, useIsDeletePublicDrivesEnabled as $n, viewFilterInputFromViewFilter as $r, setIsAnalyticsEnabled as $t, useGraphQLReactorClient as A, closePHModal as Aa, phDocumentFromMutation as Ai, setVersion as An, addIsExternalControlsEnabledEventHandler as Ar, addSentryReleaseEventHandler as At, useAttachmentService as B, usePHModal as Ba, COMMON_PACKAGE_ID as Bi, useEnabledEditors as Bn, useIsDragAndDropEnabled as Br, setBasePath as Bt, addSyncSelectionOnPopStateEventHandler as C, useReactorClient as Ca, withRequestDeadline as Ci, setRequiresHardRefresh as Cn, useStudioMode as Cr, addRenownChainIdEventHandler as Ct, usePackageDiscoveryService as D, useSyncList as Da, toLegacyNode as Di, setSentryRelease as Dn, useWarnOutdatedApp as Dr, addRouterBasenameEventHandler as Dt, setPackageDiscoveryService as E, useSync as Ea, GraphQLDriveReadClient as Ei, setSentryEnv as En, useVersionCheckInterval as Er, addRequiresHardRefreshEventHandler as Et, addFeaturesEventHandler as F, setPHModal as Fa, extractRevisionMap as Fi, useBasePath as Fn, phDocumentEditorConfigSetters as Fr, addWarnOutdatedAppEventHandler as Ft, addDefaultDrivesUrlEventHandler as G, useSearchParams as Ga, GraphQLWrongBackendError as Gi, useIsAddLocalDrivesEnabled as Gn, recordBackendAuthError as Gr, setEnabledEditors as Gt, addAnalyticsDatabaseNameEventHandler as H, isPlainClick as Ha, DRIVE_DOCUMENT_TYPES as Hi, useGaTrackingId as Hn, addBackendAuthEventHandler as Hr, setDefaultDrivesUrl as Ht, setFeatures as I, showCreateDocumentModal as Ia, hasRevisionConflict as Ii, useCliVersion as In, setAllowedDocumentTypes as Ir, phGlobalConfigHooks as It, addEnabledEditorsEventHandler as J, queriesUnknownField as Ji, useIsAnalyticsEnabled as Jn, GraphQLReactorClient as Jr, setIsAddCloudDrivesEnabled as Jt, addDisabledEditorsEventHandler as K, useSetSearchParams as Ka, JobFailedError as Ki, useIsAddPublicDrivesEnabled as Kn, setBackendAuth as Kr, setFileUploadOperationsChunkSize as Kt, useFeatures as L, showDeleteNodeModal as La, screamingSnakeToCamel as Li, useDefaultDrivesUrl as Ln, setIsDragAndDropEnabled as Lr, phGlobalConfigSetters as Lt, useDragNode as M, modalFromSearch as Ma, ConflictError as Mi, setWarnOutdatedApp as Mn, phAppConfigHooks as Mr, addSwitchboardUrlEventHandler as Mt, useDropNode as N, modalHref as Na, buildPulledDocument as Ni, useAllowList as Nn, phAppConfigSetters as Nr, addVersionCheckIntervalEventHandler as Nt, addGraphQLReactorClientEventHandler as O, MODAL_SEARCH_PARAM as Oa, isoStringFromDateTime as Oi, setStudioMode as On, addAllowedDocumentTypesEventHandler as Or, addSentryDsnEventHandler as Ot, useDropTarget as P, modalSearch as Pa, convertRemoteOperations as Pi, useAnalyticsDatabaseName as Pn, phDocumentEditorConfigHooks as Pr, addVersionEventHandler as Pt, addIsAddDriveEnabledEventHandler as Q, copyNode$1 as Qi, useIsDeleteLocalDrivesEnabled as Qn, isGraphQLReactorClient as Qr, setIsAnalyticsDatabaseWorkerEnabled as Qt, addAttachmentServiceEventHandler as R, showPHModal as Ra, uncreatedDocument as Ri, useDisabledEditors as Rn, setIsExternalControlsEnabled as Rr, setAllowList as Rt, addSetSelectedNodeOnPopStateEventHandler as S, usePGlite as Sa, switchboardFetch as Si, setRenownUrl as Sn, useSentryRelease as Sr, addRenownAdaptersEventHandler as St, addPackageDiscoveryServiceEventHandler as T, useReactorHalves as Ta, GraphQLDriveNodeSource as Ti, setSentryDsn as Tn, useVersion as Tr, addRenownUrlEventHandler as Tt, addBasePathEventHandler as U, useLinkProps as Ua, BatchJobFailedError as Ui, useIsAddCloudDrivesEnabled as Un, backendAuthStatusOf as Ur, setDisabledEditors as Ut, addAllowListEventHandler as V, withoutModalSearch as Va, DEFAULT_DRIVE_EDITOR_ID as Vi, useFileUploadOperationsChunkSize as Vn, useIsExternalControlsEnabled as Vr, setCliVersion as Vt, addCliVersionEventHandler as W, usePHNavigation as Wa, GraphQLOperationNotSupportedError as Wi, useIsAddDriveEnabled as Wn, isBackendAuthError as Wr, setDrivesPreserveStrategy as Wt, addGaTrackingIdEventHandler as X, addFileWithProgress as Xi, useIsCloudDrivesEnabled as Xn, createGraphQLDriveNodeSource as Xr, setIsAddLocalDrivesEnabled as Xt, addFileUploadOperationsChunkSizeEventHandler as Y, addDocument as Yi, useIsAnalyticsExternalProcessorsEnabled as Yn, ambientRenownSigner as Yr, setIsAddDriveEnabled as Yt, addIsAddCloudDrivesEnabledEventHandler as Z, addFolder$1 as Zi, useIsDeleteCloudDrivesEnabled as Zn, findIsServableOverGraphQL as Zr, setIsAddPublicDrivesEnabled as Zt, useSelectedTimelineRevision as _, setFullReactorClient as _a, readCreateProtocolVersions as _i, setLocalDrivesEnabled as _n, useRenownUrl as _r, addIsPublicDrivesEnabledEventHandler as _t, createSwitchboardBackend as a, moveNode$1 as aa, SubgraphSdkRegistry as ai, setIsDiffAnalyticsEnabled as an, useIsExternalPackagesEnabled as ar, addIsDeleteCloudDrivesEnabledEventHandler as at, useSelectedTimelineItem as b, useDatabase as ba, isDeadlineError as bi, setRenownChainId as bn, useSentryDsn as br, addLocalDrivesEnabledEventHandler as bt, useSwitchboardClient as c, setPreferredEditorOnNode as ca, StaticPackageManager as ci, setIsEditorDebugModeEnabled as cn, useIsLocalDrivesEnabled as cr, addIsDiffAnalyticsEnabledEventHandler as ct, commonGlobalEventHandlerFunctions as d, isDocumentTypeSupported as da, prepareSignedActions as di, setIsExternalProcessorsEnabled as dn, useIsSentryTracingEnabled as dr, addIsEditorDebugModeEnabledEventHandler as dt, exportFile as ea, createJobChangesSocket as ei, setIsAnalyticsExternalProcessorsEnabled as en, useIsDiffAnalyticsEnabled as er, addIsAddPublicDrivesEnabledEventHandler as et, addToastEventHandler as f, addFullReactorClientEventHandler as fa, signStampedAction as fi, setIsExternalRelationalProcessorsEnabled as fn, useLocalDrivesEnabled as fr, addIsEditorReadModeEnabledEventHandler as ft, setSelectedTimelineRevision as g, getFullReactorClient as ga, ReactorOperationFieldsFragmentDoc as gi, setIsSentryTracingEnabled as gn, useRenownNetworkId as gr, addIsLocalDrivesEnabledEventHandler as gt, addSelectedTimelineRevisionEventHandler as h, addReactorHalvesEventHandler as ha, MutateDocumentWithOperationsDocument as hi, setIsRelationalProcessorsEnabled as hn, useRenownChainId as hr, addIsExternalRelationalProcessorsEnabledEventHandler as ht, SwitchboardUnreachableError as i, loadFile as ia, subscriptionsUrlFromGraphqlUrl as ii, setIsDeletePublicDrivesEnabled as in, useIsEditorReadModeEnabled as ir, addIsCloudDrivesEnabledEventHandler as it, addDraggingNodeEventHandler as j, isRoutedModal as ja, revisionMapFromRevisionsList as ji, setVersionCheckInterval as jn, isExternalControlsEnabledEventFunctions as jr, addStudioModeEventHandler as jt, setGraphQLReactorClient as k, addModalEventHandler as ka, phDocumentFromGetDocument as ki, setSwitchboardUrl as kn, addIsDragAndDropEnabledEventHandler as kr, addSentryEnvEventHandler as kt, addPHEventHandlers as l, upgradeDocument as la, packageFromDocumentModels as li, setIsEditorReadModeEnabled as ln, useIsPublicDrivesEnabled as lr, addIsDocumentModelSelectionSettingsEnabledEventHandler as lt, usePHToast as m, addReactorClientModuleEventHandler as ma, GetDocumentAtConsistencyDocument as mi, setIsPublicDrivesEnabled as mn, useRenownAdapters as mr, addIsExternalProcessorsEnabledEventHandler as mt, DEFAULT_BREAKER as n, fetchDocumentOperations as na, makeAuthConnectionParams as ni, setIsDeleteCloudDrivesEnabled as nn, useIsDriveAnalyticsEnabled as nr, addIsAnalyticsEnabledEventHandler as nt, GraphQLReactorProvider as o, renameDriveNode as oa, describeGraphQLDocument as oi, setIsDocumentModelSelectionSettingsEnabled as on, useIsExternalProcessorsEnabled as or, addIsDeleteLocalDrivesEnabledEventHandler as ot, setPHToast as p, addReactorClientEventHandler as pa, stampAction as pi, setIsLocalDrivesEnabled as pn, useLogLevel as pr, addIsExternalPackagesEnabledEventHandler as pt, addDrivesPreserveStrategyEventHandler as q, queriesUnknownArgument as qi, useIsAnalyticsDatabaseWorkerEnabled as qn, useBackendAuth as qr, setGaTrackingId as qt, DEFAULT_REQUEST_TIMEOUT_MS as r, getDocumentExtension as ra, startDocumentChangesSubscription as ri, setIsDeleteLocalDrivesEnabled as rn, useIsEditorDebugModeEnabled as rr, addIsAnalyticsExternalProcessorsEnabledEventHandler as rt, ensurePHEventHandlers as s, renameNode as sa, subgraphUrlFromGraphqlUrl as si, setIsDriveAnalyticsEnabled as sn, useIsExternalRelationalProcessorsEnabled as sr, addIsDeletePublicDrivesEnabledEventHandler as st, useDocumentOperations as t, extractInitialState as ta, isAuthRefusalClose as ti, setIsCloudDrivesEnabled as tn, useIsDocumentModelSelectionSettingsEnabled as tr, addIsAnalyticsDatabaseWorkerEnabledEventHandler as tt, callEventHandlerRegisterFunctions as u, getUserPermissions as ua, resolveDocumentModelModule as ui, setIsExternalPackagesEnabled as un, useIsRelationalProcessorsEnabled as ur, addIsDriveAnalyticsEnabledEventHandler as ut, addSelectedTimelineItemEventHandler as v, setReactorClient as va, readCreateSignaturePolicy as vi, setLogLevel as vn, useRequiresHardRefresh as vr, addIsRelationalProcessorsEnabledEventHandler as vt, syncSelectionFromPath as w, useReactorClientModule as wa, withStreamedBodies as wi, setRouterBasename as wn, useSwitchboardUrl as wr, addRenownNetworkIdEventHandler as wt, addSetSelectedDriveOnPopStateEventHandler as x, useModelRegistry as xa, isNodeFetch as xi, setRenownNetworkId as xn, useSentryEnv as xr, addLogLevelEventHandler as xt, setSelectedTimelineItem as y, setReactorClientModule as ya, globalFetch as yi, setRenownAdapters as yn, useRouterBasename as yr, addIsSentryTracingEnabledEventHandler as yt, setAttachmentService as z, useModalLinkProps as za, underSignaturePolicy as zi, useDrivesPreserveStrategy as zn, useAllowedDocumentTypes as zr, setAnalyticsDatabaseName as zt };
|
|
4243
4548
|
|
|
4244
|
-
//# sourceMappingURL=document-operations-
|
|
4549
|
+
//# sourceMappingURL=document-operations-CsiIPsx9.js.map
|