@powerhousedao/powerhouse-vetra-packages 6.2.2-dev.84 → 6.2.2-dev.86
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/browser/{connect-CZxjNDFs.js → connect-DqkYyEcC.js} +2 -2
- package/dist/browser/{connect-CZxjNDFs.js.map → connect-DqkYyEcC.js.map} +1 -1
- package/dist/browser/{dist-CnNpgEVe.js → dist-C1pi89al.js} +151 -14
- package/dist/browser/dist-C1pi89al.js.map +1 -0
- package/dist/browser/{editor-TmNqs_3q.js → editor-Bl02Hko1.js} +5 -5
- package/dist/browser/{editor-TmNqs_3q.js.map → editor-Bl02Hko1.js.map} +1 -1
- package/dist/browser/{editor-Dg_2AIoc.js → editor-CbtY05JH.js} +4 -4
- package/dist/browser/{editor-Dg_2AIoc.js.map → editor-CbtY05JH.js.map} +1 -1
- package/dist/browser/editors/document-model-editor/module.js +1 -1
- package/dist/browser/editors/generic-drive-explorer/index.js +3 -3
- package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
- package/dist/browser/{folder-view-B7P3uF6d.js → folder-view-BBm_YnKn.js} +3 -3
- package/dist/browser/{folder-view-B7P3uF6d.js.map → folder-view-BBm_YnKn.js.map} +1 -1
- package/dist/browser/{graphql-editor-tFWpwJhB.js → graphql-editor-LSj3LCtL.js} +2 -2
- package/dist/browser/{graphql-editor-tFWpwJhB.js.map → graphql-editor-LSj3LCtL.js.map} +1 -1
- package/dist/browser/{json-editor-DczBqrwD.js → json-editor-TVSHA4PZ.js} +2 -2
- package/dist/browser/{json-editor-DczBqrwD.js.map → json-editor-TVSHA4PZ.js.map} +1 -1
- package/dist/browser/{state-schemas-inzuDitu.js → state-schemas-Bsryt22c.js} +3 -3
- package/dist/browser/{state-schemas-inzuDitu.js.map → state-schemas-Bsryt22c.js.map} +1 -1
- package/dist/node/{connect-Bfdoq4eL.mjs → connect-B2yHg8VF.mjs} +2 -2
- package/dist/node/{connect-Bfdoq4eL.mjs.map → connect-B2yHg8VF.mjs.map} +1 -1
- package/dist/node/{dist-BDq_3xzc.mjs → dist-BAXIB1_k.mjs} +153 -14
- package/dist/node/dist-BAXIB1_k.mjs.map +1 -0
- package/dist/node/{editor-tTT_T9Fq.mjs → editor--v67sph0.mjs} +5 -5
- package/dist/node/{editor-tTT_T9Fq.mjs.map → editor--v67sph0.mjs.map} +1 -1
- package/dist/node/{editor-DQvgS2LK.mjs → editor-BY22Tx5_.mjs} +4 -4
- package/dist/node/{editor-DQvgS2LK.mjs.map → editor-BY22Tx5_.mjs.map} +1 -1
- package/dist/node/editors/document-model-editor/module.mjs +1 -1
- package/dist/node/editors/generic-drive-explorer/index.mjs +3 -3
- package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
- package/dist/node/{folder-view-Bjnpy_l9.mjs → folder-view-D_99HJFI.mjs} +3 -3
- package/dist/node/{folder-view-Bjnpy_l9.mjs.map → folder-view-D_99HJFI.mjs.map} +1 -1
- package/dist/node/{graphql-editor-DK16Va7B.mjs → graphql-editor-Bzs-PolA.mjs} +2 -2
- package/dist/node/{graphql-editor-DK16Va7B.mjs.map → graphql-editor-Bzs-PolA.mjs.map} +1 -1
- package/dist/node/{json-editor-CUxDXYvs.mjs → json-editor-CCsBXZ6y.mjs} +2 -2
- package/dist/node/{json-editor-CUxDXYvs.mjs.map → json-editor-CCsBXZ6y.mjs.map} +1 -1
- package/dist/node/{state-schemas-CbnYhOyM.mjs → state-schemas-DxJBYOC0.mjs} +3 -3
- package/dist/node/{state-schemas-CbnYhOyM.mjs.map → state-schemas-DxJBYOC0.mjs.map} +1 -1
- package/package.json +7 -7
- package/dist/browser/dist-CnNpgEVe.js.map +0 -1
- package/dist/node/dist-BDq_3xzc.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as __toESM, D as __commonJSMin, t as capitalCase } from "./dist-B4FWbuEM.js";
|
|
1
|
+
import { A as __toESM, D as __commonJSMin, r as pascalCase, t as capitalCase } from "./dist-B4FWbuEM.js";
|
|
2
2
|
import { A as createPresignedHeader, D as buildSignedAction, E as baseSaveToFileHandle, G as replayDocumentVersioned, N as createZip, T as baseLoadFromInputVersioned, _ as UnsupportedDocumentModelVersionError, a as getDescendants, c as isFileNode, ct as validateInitialState, d as moveNode, dt as zipEntries, et as setName, f as updateNode, ft as generateId, i as generateNodesCopy, l as isFolderNode, lt as validateModules, m as logger, n as copyNode, o as getNextCopyNumber, s as handleTargetNameCollisions, t as addFolder, ut as validateStateSchemaName, w as baseLoadFromInput, x as assertAuthPreservedOnDuplicate } from "./document-drive-ZQzPQfEL.js";
|
|
3
3
|
import { a as SyncStatus, o as DriveCollectionId, s as ModuleNotFoundError, t as gql } from "./lib-ewnRj2dJ.js";
|
|
4
|
-
import "./parser-CkF6Qt8V.js";
|
|
4
|
+
import { c as Kind, t as parse } from "./parser-CkF6Qt8V.js";
|
|
5
5
|
import "./printer-CEYr4JOg.js";
|
|
6
6
|
import { createContext, use, useCallback, useContext, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
7
7
|
import "react/jsx-runtime";
|
|
@@ -1029,7 +1029,7 @@ slug.setLocale = function(locale) {
|
|
|
1029
1029
|
defaultLocale = locales[locale] || {};
|
|
1030
1030
|
};
|
|
1031
1031
|
//#endregion
|
|
1032
|
-
//#region ../reactor-browser/dist/document-model-modules-
|
|
1032
|
+
//#region ../reactor-browser/dist/document-model-modules-DfQBNGc-.js
|
|
1033
1033
|
var UnsupportedDocumentTypeError = class extends Error {
|
|
1034
1034
|
constructor(documentType) {
|
|
1035
1035
|
super(`Document type ${documentType} is not supported`);
|
|
@@ -1249,10 +1249,18 @@ function useSelectedNode() {
|
|
|
1249
1249
|
}
|
|
1250
1250
|
const vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
|
|
1251
1251
|
const useVetraPackageManager = vetraPackageManagerFunctions.useValue;
|
|
1252
|
-
|
|
1252
|
+
const EMPTY_VETRA_PACKAGES = [];
|
|
1253
|
+
const noPackageManagerUnsubscribe = () => {};
|
|
1254
|
+
/**
|
|
1255
|
+
* Returns all of the Vetra packages loaded by the Connect instance.
|
|
1256
|
+
*
|
|
1257
|
+
* The snapshot and subscription must keep stable identity while no package
|
|
1258
|
+
* manager is registered: `useSyncExternalStore` loops when the snapshot
|
|
1259
|
+
* changes on every read, which a fresh `[]` does.
|
|
1260
|
+
*/
|
|
1253
1261
|
const useVetraPackages = () => {
|
|
1254
1262
|
const packageManager = useVetraPackageManager();
|
|
1255
|
-
return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) :
|
|
1263
|
+
return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) : noPackageManagerUnsubscribe, () => packageManager?.packages ?? EMPTY_VETRA_PACKAGES);
|
|
1256
1264
|
};
|
|
1257
1265
|
vetraPackageManagerFunctions.addEventHandler;
|
|
1258
1266
|
function useDocumentModelModules() {
|
|
@@ -2057,7 +2065,7 @@ var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
|
2057
2065
|
})(MessageType || {});
|
|
2058
2066
|
Error;
|
|
2059
2067
|
//#endregion
|
|
2060
|
-
//#region ../reactor-browser/dist/document-operations-
|
|
2068
|
+
//#region ../reactor-browser/dist/document-operations-CBExT76y.js
|
|
2061
2069
|
const modalEventFunctions = makePHEventFunctions("modal");
|
|
2062
2070
|
modalEventFunctions.useValue;
|
|
2063
2071
|
/** Sets the current modal */
|
|
@@ -3131,7 +3139,7 @@ const usePHToast = toastEventFunctions.useValue;
|
|
|
3131
3139
|
toastEventFunctions.setValue;
|
|
3132
3140
|
toastEventFunctions.addEventHandler;
|
|
3133
3141
|
//#endregion
|
|
3134
|
-
//#region ../reactor-browser/dist/
|
|
3142
|
+
//#region ../reactor-browser/dist/switchboard-D4-_jwk-.js
|
|
3135
3143
|
/** Returns a document of a specific type, throws an error if the found document has a different type */
|
|
3136
3144
|
function useDocumentOfType(documentId, documentType) {
|
|
3137
3145
|
const [document, dispatch] = useDocumentById(documentId);
|
|
@@ -4375,8 +4383,134 @@ function getDocumentGraphqlQuery() {
|
|
|
4375
4383
|
if (!loc) throw new Error("GetDocumentWithOperationsDocument is misconfigured, loc is missing.");
|
|
4376
4384
|
return loc.source.body;
|
|
4377
4385
|
}
|
|
4378
|
-
|
|
4379
|
-
|
|
4386
|
+
/**
|
|
4387
|
+
* The base URL of the switchboard that serves a drive's GraphQL channel.
|
|
4388
|
+
*
|
|
4389
|
+
* The channel URL is `<origin>[<proxy-prefix>]/graphql/r`, so stripping the
|
|
4390
|
+
* suffix preserves any proxy prefix (e.g. `/api/reactor`). A URL that does
|
|
4391
|
+
* not end with the suffix is unexpected — fall back to its origin.
|
|
4392
|
+
*/
|
|
4393
|
+
function getSwitchboardBaseFromChannelUrl(channelUrl) {
|
|
4394
|
+
if (channelUrl.endsWith("/graphql/r")) return channelUrl.slice(0, -10);
|
|
4395
|
+
return new URL(channelUrl).origin;
|
|
4396
|
+
}
|
|
4397
|
+
/**
|
|
4398
|
+
* The GraphQL name the switchboard exposes a document model under. Mirrors
|
|
4399
|
+
* `getDocumentModelSchemaName` on the server (`create-schema.ts`): the root
|
|
4400
|
+
* query field and the state type names are all derived from the model's
|
|
4401
|
+
* `global.name`.
|
|
4402
|
+
*/
|
|
4403
|
+
function getDocumentModelSchemaName(model) {
|
|
4404
|
+
return pascalCase(model.documentModel.global.name.replaceAll("/", " "));
|
|
4405
|
+
}
|
|
4406
|
+
function buildStateTypeMap(definitions) {
|
|
4407
|
+
const typeMap = /* @__PURE__ */ new Map();
|
|
4408
|
+
for (const def of definitions) if (def.kind === Kind.OBJECT_TYPE_DEFINITION) typeMap.set(def.name.value, def);
|
|
4409
|
+
return typeMap;
|
|
4410
|
+
}
|
|
4411
|
+
/**
|
|
4412
|
+
* Recursively expands the fields of a state object type into a GraphQL
|
|
4413
|
+
* selection. Objects expand their sub-selection (lists expand their item
|
|
4414
|
+
* type); enums, scalars, and built-ins are leaves.
|
|
4415
|
+
*/
|
|
4416
|
+
function expandStateFields(typeDef, typeMap) {
|
|
4417
|
+
return (typeDef.fields ?? []).map((field) => {
|
|
4418
|
+
const fieldName = field.name.value;
|
|
4419
|
+
let typeNode = field.type;
|
|
4420
|
+
if (typeNode.kind === Kind.NON_NULL_TYPE) typeNode = typeNode.type;
|
|
4421
|
+
if (typeNode.kind === Kind.LIST_TYPE) {
|
|
4422
|
+
let itemType = typeNode.type;
|
|
4423
|
+
if (itemType.kind === Kind.NON_NULL_TYPE) itemType = itemType.type;
|
|
4424
|
+
if (itemType.kind === Kind.LIST_TYPE) throw new Error(`Nested lists are not supported in state selections: ${fieldName}`);
|
|
4425
|
+
if (itemType.kind !== Kind.NAMED_TYPE) return fieldName;
|
|
4426
|
+
const itemTypeDef = typeMap.get(itemType.name.value);
|
|
4427
|
+
if (!itemTypeDef) return fieldName;
|
|
4428
|
+
return `${fieldName} { ${expandStateFields(itemTypeDef, typeMap)} }`;
|
|
4429
|
+
}
|
|
4430
|
+
if (typeNode.kind !== Kind.NAMED_TYPE) return fieldName;
|
|
4431
|
+
const typeDef = typeMap.get(typeNode.name.value);
|
|
4432
|
+
if (!typeDef) return fieldName;
|
|
4433
|
+
return `${fieldName} { ${expandStateFields(typeDef, typeMap)} }`;
|
|
4434
|
+
}).join(" ");
|
|
4435
|
+
}
|
|
4436
|
+
/**
|
|
4437
|
+
* Finds the root state object type in a state SDL. Root state types follow
|
|
4438
|
+
* the `<Name>State` / `<Name>GlobalState` conventions, and are defined last
|
|
4439
|
+
* by convention — the same resolution order the server uses
|
|
4440
|
+
* (`extractRootTypeName` in `create-schema.ts`).
|
|
4441
|
+
*/
|
|
4442
|
+
function findRootStateType(definitions, candidates) {
|
|
4443
|
+
let lastObjectType = null;
|
|
4444
|
+
for (const def of definitions) {
|
|
4445
|
+
if (def.kind !== Kind.OBJECT_TYPE_DEFINITION) continue;
|
|
4446
|
+
if (candidates.includes(def.name.value)) return def;
|
|
4447
|
+
lastObjectType = def;
|
|
4448
|
+
}
|
|
4449
|
+
if (!lastObjectType) throw new Error("No root state type found in the document model schema");
|
|
4450
|
+
return lastObjectType;
|
|
4451
|
+
}
|
|
4452
|
+
/**
|
|
4453
|
+
* Derives the subselection for the document's `global` state scope from the
|
|
4454
|
+
* model's state SDL (e.g. `name total`), expanding object fields
|
|
4455
|
+
* recursively. Throws when the schema is missing, unparseable, or has no
|
|
4456
|
+
* root object type — the caller falls back to the generic document query.
|
|
4457
|
+
*/
|
|
4458
|
+
function getDocumentStateSelection(model) {
|
|
4459
|
+
const schema = model.documentModel.global.specifications.at(-1)?.state.global.schema;
|
|
4460
|
+
if (!schema || !schema.trim()) throw new Error("Document model has no global state schema");
|
|
4461
|
+
const ast = parse(schema);
|
|
4462
|
+
const typeMap = buildStateTypeMap(ast.definitions);
|
|
4463
|
+
const documentName = getDocumentModelSchemaName(model);
|
|
4464
|
+
return expandStateFields(findRootStateType(ast.definitions, [`${documentName}State`, `${documentName}GlobalState`]), typeMap);
|
|
4465
|
+
}
|
|
4466
|
+
function getLocalStateSelection(localSchema, documentName) {
|
|
4467
|
+
const ast = parse(localSchema);
|
|
4468
|
+
const typeMap = buildStateTypeMap(ast.definitions);
|
|
4469
|
+
return expandStateFields(findRootStateType(ast.definitions, [`${documentName}LocalState`]), typeMap);
|
|
4470
|
+
}
|
|
4471
|
+
/**
|
|
4472
|
+
* Builds a query scoped to a document type's own subgraph root field,
|
|
4473
|
+
* selecting the document and its full typed state. The shape mirrors what
|
|
4474
|
+
* the switchboard generates per model (`generateNewApiSchema` in
|
|
4475
|
+
* `create-schema.ts`): `<Name> { document(identifier:) { document { ...
|
|
4476
|
+
* state { auth document global local } } } childIds }`.
|
|
4477
|
+
*/
|
|
4478
|
+
function buildModelScopedQuery(model) {
|
|
4479
|
+
const globalState = model.documentModel.global;
|
|
4480
|
+
const documentName = getDocumentModelSchemaName(model);
|
|
4481
|
+
const globalSelection = getDocumentStateSelection(model);
|
|
4482
|
+
const localSchema = globalState.specifications.at(-1)?.state.local.schema ?? "";
|
|
4483
|
+
const localSelection = localSchema.includes(`type ${documentName}LocalState`) ? getLocalStateSelection(localSchema, documentName) : null;
|
|
4484
|
+
return [
|
|
4485
|
+
"query GetDocument($identifier: String!) {",
|
|
4486
|
+
` ${documentName} {`,
|
|
4487
|
+
" document(identifier: $identifier) {",
|
|
4488
|
+
" document {",
|
|
4489
|
+
" id",
|
|
4490
|
+
" name",
|
|
4491
|
+
" documentType",
|
|
4492
|
+
" state {",
|
|
4493
|
+
" auth",
|
|
4494
|
+
" document { version hash { algorithm encoding } isDeleted deletedAtUtcIso deletedBy deletionReason }",
|
|
4495
|
+
` global { ${globalSelection} }`,
|
|
4496
|
+
` ${localSelection ? `local { ${localSelection} }` : "local"}`,
|
|
4497
|
+
" }",
|
|
4498
|
+
" }",
|
|
4499
|
+
" childIds",
|
|
4500
|
+
" }",
|
|
4501
|
+
" }",
|
|
4502
|
+
"}"
|
|
4503
|
+
].join("\n");
|
|
4504
|
+
}
|
|
4505
|
+
function buildDocumentSubgraphQuery(documentType, identifier, model, authToken) {
|
|
4506
|
+
let query;
|
|
4507
|
+
if (model && model.documentModel.global.id === documentType) try {
|
|
4508
|
+
query = buildModelScopedQuery(model);
|
|
4509
|
+
} catch (error) {
|
|
4510
|
+
console.warn("Could not derive a document-scoped query from the document model, falling back to the generic document query:", error);
|
|
4511
|
+
query = getDocumentGraphqlQuery();
|
|
4512
|
+
}
|
|
4513
|
+
else query = getDocumentGraphqlQuery();
|
|
4380
4514
|
const variables = { identifier };
|
|
4381
4515
|
const headers = authToken ? { Authorization: `Bearer ${authToken}` } : void 0;
|
|
4382
4516
|
const payload = {
|
|
@@ -4384,10 +4518,11 @@ function buildDocumentSubgraphQuery(identifier, authToken) {
|
|
|
4384
4518
|
variables: JSON.stringify(variables, null, 2)
|
|
4385
4519
|
};
|
|
4386
4520
|
if (headers) payload.headers = JSON.stringify(headers);
|
|
4387
|
-
return import_lz_string.compressToEncodedURIComponent(JSON.stringify(payload));
|
|
4521
|
+
return import_lz_string.default.compressToEncodedURIComponent(JSON.stringify(payload));
|
|
4388
4522
|
}
|
|
4389
|
-
function buildDocumentSubgraphUrl(
|
|
4390
|
-
|
|
4523
|
+
function buildDocumentSubgraphUrl(channelUrl, documentType, identifier, model, authToken) {
|
|
4524
|
+
const encodedQuery = buildDocumentSubgraphQuery(documentType, identifier, model, authToken);
|
|
4525
|
+
return `${getSwitchboardBaseFromChannelUrl(channelUrl)}/explorer?explorerURLState=${encodedQuery}`;
|
|
4391
4526
|
}
|
|
4392
4527
|
/**
|
|
4393
4528
|
* Hook that returns a function to generate a document's switchboard URL.
|
|
@@ -4403,6 +4538,7 @@ function buildDocumentSubgraphUrl(driveUrl, identifier, authToken) {
|
|
|
4403
4538
|
function useGetSwitchboardLink(document) {
|
|
4404
4539
|
const [drive] = useSelectedDriveSafe();
|
|
4405
4540
|
const remotes = useSyncList();
|
|
4541
|
+
const documentModelModule = useDocumentModelModuleById(document?.header.documentType);
|
|
4406
4542
|
const isRemoteDrive = useMemo(() => {
|
|
4407
4543
|
if (!e$4(drive)) return false;
|
|
4408
4544
|
return remotes.some((remote) => remote.meta.collectionId.equals(DriveCollectionId.forDrive(drive.header.id)));
|
|
@@ -4427,12 +4563,13 @@ function useGetSwitchboardLink(document) {
|
|
|
4427
4563
|
expiresIn: 600,
|
|
4428
4564
|
aud: remoteUrl
|
|
4429
4565
|
}) : void 0;
|
|
4430
|
-
return buildDocumentSubgraphUrl(remoteUrl, document.header.id, token);
|
|
4566
|
+
return buildDocumentSubgraphUrl(remoteUrl, document.header.documentType, document.header.id, documentModelModule, token);
|
|
4431
4567
|
};
|
|
4432
4568
|
}, [
|
|
4433
4569
|
isRemoteDrive,
|
|
4434
4570
|
remoteUrl,
|
|
4435
4571
|
document,
|
|
4572
|
+
documentModelModule,
|
|
4436
4573
|
user,
|
|
4437
4574
|
renown
|
|
4438
4575
|
]);
|
|
@@ -4501,4 +4638,4 @@ createDebouncedRefreshReactorDataClient();
|
|
|
4501
4638
|
//#endregion
|
|
4502
4639
|
export { useDropNode as A, setSelectedNode as B, addDocument as C, showRevisionHistory as D, showPHModal as E, t$2 as F, useSelectedDriveSafe as H, t$5 as I, isFileNodeKind as L, useStudioMode as M, e$1 as N, useDisabledEditors as O, e$4 as P, isFolderNodeKind as R, useSelectedDocumentSafe as S, showDeleteNodeModal as T, useDocumentById as U, useSelectedDriveId as V, useSetPHAppConfig as _, useDownloadDocument as a, useUserPermissions as b, useEditorModulesForDocumentType as c, useNodeById as d, useNodeParentFolderById as f, useSelectedNodePath as g, useSelectedFolder as h, useDocumentVersionStatus as i, usePHToast as j, useDragNode as k, useGetSwitchboardLink as l, useParentFolderForSelectedNode as m, preloadEditorModule as n, useDownloadFolder as o, useNodesInSelectedDriveOrFolder as p, useAllowedDocumentModelModules as r, useEditorModules as s, getSyncStatusSync as t, useNodeActions as u, useSetPHDocumentEditorConfig as v, addFolder$1 as w, useSelectedDocumentOfType as x, useTheme as y, setSelectedDrive as z };
|
|
4503
4640
|
|
|
4504
|
-
//# sourceMappingURL=dist-
|
|
4641
|
+
//# sourceMappingURL=dist-C1pi89al.js.map
|