@powerhousedao/powerhouse-vetra-packages 6.2.2-dev.84 → 6.2.2-dev.85
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,4 +1,4 @@
|
|
|
1
|
-
import { D as __commonJSMin, M as __toESM, t as capitalCase } from "./dist-DT7jI9ol.mjs";
|
|
1
|
+
import { D as __commonJSMin, M as __toESM, r as pascalCase, t as capitalCase } from "./dist-DT7jI9ol.mjs";
|
|
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-D1NMjQQc.mjs";
|
|
3
3
|
import { a as DriveCollectionId, i as SyncStatus, o as ModuleNotFoundError, t as require_main } from "./main-B1tRsYOp.mjs";
|
|
4
4
|
import { t as require_graphql } from "./graphql-BfAoPeWM.mjs";
|
|
@@ -1028,7 +1028,7 @@ slug.setLocale = function(locale) {
|
|
|
1028
1028
|
defaultLocale = locales[locale] || {};
|
|
1029
1029
|
};
|
|
1030
1030
|
//#endregion
|
|
1031
|
-
//#region ../reactor-browser/dist/document-model-modules-
|
|
1031
|
+
//#region ../reactor-browser/dist/document-model-modules-DfQBNGc-.js
|
|
1032
1032
|
var UnsupportedDocumentTypeError = class extends Error {
|
|
1033
1033
|
constructor(documentType) {
|
|
1034
1034
|
super(`Document type ${documentType} is not supported`);
|
|
@@ -1248,10 +1248,18 @@ function useSelectedNode() {
|
|
|
1248
1248
|
}
|
|
1249
1249
|
const vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
|
|
1250
1250
|
const useVetraPackageManager = vetraPackageManagerFunctions.useValue;
|
|
1251
|
-
|
|
1251
|
+
const EMPTY_VETRA_PACKAGES = [];
|
|
1252
|
+
const noPackageManagerUnsubscribe = () => {};
|
|
1253
|
+
/**
|
|
1254
|
+
* Returns all of the Vetra packages loaded by the Connect instance.
|
|
1255
|
+
*
|
|
1256
|
+
* The snapshot and subscription must keep stable identity while no package
|
|
1257
|
+
* manager is registered: `useSyncExternalStore` loops when the snapshot
|
|
1258
|
+
* changes on every read, which a fresh `[]` does.
|
|
1259
|
+
*/
|
|
1252
1260
|
const useVetraPackages = () => {
|
|
1253
1261
|
const packageManager = useVetraPackageManager();
|
|
1254
|
-
return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) :
|
|
1262
|
+
return useSyncExternalStore((cb) => packageManager ? packageManager.subscribe(cb) : noPackageManagerUnsubscribe, () => packageManager?.packages ?? EMPTY_VETRA_PACKAGES);
|
|
1255
1263
|
};
|
|
1256
1264
|
vetraPackageManagerFunctions.addEventHandler;
|
|
1257
1265
|
function useDocumentModelModules() {
|
|
@@ -1285,7 +1293,9 @@ function useDocumentModelModuleById(id, version) {
|
|
|
1285
1293
|
return latestModule;
|
|
1286
1294
|
}
|
|
1287
1295
|
Error;
|
|
1288
|
-
|
|
1296
|
+
//#endregion
|
|
1297
|
+
//#region ../../node_modules/.pnpm/graphql-request@7.4.0_graphql@16.12.0/node_modules/graphql-request/build/legacy/lib/graphql.js
|
|
1298
|
+
var import_graphql = require_graphql();
|
|
1289
1299
|
JSON;
|
|
1290
1300
|
//#endregion
|
|
1291
1301
|
//#region ../reactor-browser/dist/client-D66jVnot.js
|
|
@@ -2058,7 +2068,7 @@ var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
|
2058
2068
|
})(MessageType || {});
|
|
2059
2069
|
Error;
|
|
2060
2070
|
//#endregion
|
|
2061
|
-
//#region ../reactor-browser/dist/document-operations-
|
|
2071
|
+
//#region ../reactor-browser/dist/document-operations-CBExT76y.js
|
|
2062
2072
|
const modalEventFunctions = makePHEventFunctions("modal");
|
|
2063
2073
|
modalEventFunctions.useValue;
|
|
2064
2074
|
/** Sets the current modal */
|
|
@@ -3137,7 +3147,7 @@ const usePHToast = toastEventFunctions.useValue;
|
|
|
3137
3147
|
toastEventFunctions.setValue;
|
|
3138
3148
|
toastEventFunctions.addEventHandler;
|
|
3139
3149
|
//#endregion
|
|
3140
|
-
//#region ../reactor-browser/dist/
|
|
3150
|
+
//#region ../reactor-browser/dist/switchboard-D4-_jwk-.js
|
|
3141
3151
|
/** Returns a document of a specific type, throws an error if the found document has a different type */
|
|
3142
3152
|
function useDocumentOfType(documentId, documentType) {
|
|
3143
3153
|
const [document, dispatch] = useDocumentById(documentId);
|
|
@@ -4381,8 +4391,134 @@ function getDocumentGraphqlQuery() {
|
|
|
4381
4391
|
if (!loc) throw new Error("GetDocumentWithOperationsDocument is misconfigured, loc is missing.");
|
|
4382
4392
|
return loc.source.body;
|
|
4383
4393
|
}
|
|
4384
|
-
|
|
4385
|
-
|
|
4394
|
+
/**
|
|
4395
|
+
* The base URL of the switchboard that serves a drive's GraphQL channel.
|
|
4396
|
+
*
|
|
4397
|
+
* The channel URL is `<origin>[<proxy-prefix>]/graphql/r`, so stripping the
|
|
4398
|
+
* suffix preserves any proxy prefix (e.g. `/api/reactor`). A URL that does
|
|
4399
|
+
* not end with the suffix is unexpected — fall back to its origin.
|
|
4400
|
+
*/
|
|
4401
|
+
function getSwitchboardBaseFromChannelUrl(channelUrl) {
|
|
4402
|
+
if (channelUrl.endsWith("/graphql/r")) return channelUrl.slice(0, -10);
|
|
4403
|
+
return new URL(channelUrl).origin;
|
|
4404
|
+
}
|
|
4405
|
+
/**
|
|
4406
|
+
* The GraphQL name the switchboard exposes a document model under. Mirrors
|
|
4407
|
+
* `getDocumentModelSchemaName` on the server (`create-schema.ts`): the root
|
|
4408
|
+
* query field and the state type names are all derived from the model's
|
|
4409
|
+
* `global.name`.
|
|
4410
|
+
*/
|
|
4411
|
+
function getDocumentModelSchemaName(model) {
|
|
4412
|
+
return pascalCase(model.documentModel.global.name.replaceAll("/", " "));
|
|
4413
|
+
}
|
|
4414
|
+
function buildStateTypeMap(definitions) {
|
|
4415
|
+
const typeMap = /* @__PURE__ */ new Map();
|
|
4416
|
+
for (const def of definitions) if (def.kind === import_graphql.Kind.OBJECT_TYPE_DEFINITION) typeMap.set(def.name.value, def);
|
|
4417
|
+
return typeMap;
|
|
4418
|
+
}
|
|
4419
|
+
/**
|
|
4420
|
+
* Recursively expands the fields of a state object type into a GraphQL
|
|
4421
|
+
* selection. Objects expand their sub-selection (lists expand their item
|
|
4422
|
+
* type); enums, scalars, and built-ins are leaves.
|
|
4423
|
+
*/
|
|
4424
|
+
function expandStateFields(typeDef, typeMap) {
|
|
4425
|
+
return (typeDef.fields ?? []).map((field) => {
|
|
4426
|
+
const fieldName = field.name.value;
|
|
4427
|
+
let typeNode = field.type;
|
|
4428
|
+
if (typeNode.kind === import_graphql.Kind.NON_NULL_TYPE) typeNode = typeNode.type;
|
|
4429
|
+
if (typeNode.kind === import_graphql.Kind.LIST_TYPE) {
|
|
4430
|
+
let itemType = typeNode.type;
|
|
4431
|
+
if (itemType.kind === import_graphql.Kind.NON_NULL_TYPE) itemType = itemType.type;
|
|
4432
|
+
if (itemType.kind === import_graphql.Kind.LIST_TYPE) throw new Error(`Nested lists are not supported in state selections: ${fieldName}`);
|
|
4433
|
+
if (itemType.kind !== import_graphql.Kind.NAMED_TYPE) return fieldName;
|
|
4434
|
+
const itemTypeDef = typeMap.get(itemType.name.value);
|
|
4435
|
+
if (!itemTypeDef) return fieldName;
|
|
4436
|
+
return `${fieldName} { ${expandStateFields(itemTypeDef, typeMap)} }`;
|
|
4437
|
+
}
|
|
4438
|
+
if (typeNode.kind !== import_graphql.Kind.NAMED_TYPE) return fieldName;
|
|
4439
|
+
const typeDef = typeMap.get(typeNode.name.value);
|
|
4440
|
+
if (!typeDef) return fieldName;
|
|
4441
|
+
return `${fieldName} { ${expandStateFields(typeDef, typeMap)} }`;
|
|
4442
|
+
}).join(" ");
|
|
4443
|
+
}
|
|
4444
|
+
/**
|
|
4445
|
+
* Finds the root state object type in a state SDL. Root state types follow
|
|
4446
|
+
* the `<Name>State` / `<Name>GlobalState` conventions, and are defined last
|
|
4447
|
+
* by convention — the same resolution order the server uses
|
|
4448
|
+
* (`extractRootTypeName` in `create-schema.ts`).
|
|
4449
|
+
*/
|
|
4450
|
+
function findRootStateType(definitions, candidates) {
|
|
4451
|
+
let lastObjectType = null;
|
|
4452
|
+
for (const def of definitions) {
|
|
4453
|
+
if (def.kind !== import_graphql.Kind.OBJECT_TYPE_DEFINITION) continue;
|
|
4454
|
+
if (candidates.includes(def.name.value)) return def;
|
|
4455
|
+
lastObjectType = def;
|
|
4456
|
+
}
|
|
4457
|
+
if (!lastObjectType) throw new Error("No root state type found in the document model schema");
|
|
4458
|
+
return lastObjectType;
|
|
4459
|
+
}
|
|
4460
|
+
/**
|
|
4461
|
+
* Derives the subselection for the document's `global` state scope from the
|
|
4462
|
+
* model's state SDL (e.g. `name total`), expanding object fields
|
|
4463
|
+
* recursively. Throws when the schema is missing, unparseable, or has no
|
|
4464
|
+
* root object type — the caller falls back to the generic document query.
|
|
4465
|
+
*/
|
|
4466
|
+
function getDocumentStateSelection(model) {
|
|
4467
|
+
const schema = model.documentModel.global.specifications.at(-1)?.state.global.schema;
|
|
4468
|
+
if (!schema || !schema.trim()) throw new Error("Document model has no global state schema");
|
|
4469
|
+
const ast = (0, import_graphql.parse)(schema);
|
|
4470
|
+
const typeMap = buildStateTypeMap(ast.definitions);
|
|
4471
|
+
const documentName = getDocumentModelSchemaName(model);
|
|
4472
|
+
return expandStateFields(findRootStateType(ast.definitions, [`${documentName}State`, `${documentName}GlobalState`]), typeMap);
|
|
4473
|
+
}
|
|
4474
|
+
function getLocalStateSelection(localSchema, documentName) {
|
|
4475
|
+
const ast = (0, import_graphql.parse)(localSchema);
|
|
4476
|
+
const typeMap = buildStateTypeMap(ast.definitions);
|
|
4477
|
+
return expandStateFields(findRootStateType(ast.definitions, [`${documentName}LocalState`]), typeMap);
|
|
4478
|
+
}
|
|
4479
|
+
/**
|
|
4480
|
+
* Builds a query scoped to a document type's own subgraph root field,
|
|
4481
|
+
* selecting the document and its full typed state. The shape mirrors what
|
|
4482
|
+
* the switchboard generates per model (`generateNewApiSchema` in
|
|
4483
|
+
* `create-schema.ts`): `<Name> { document(identifier:) { document { ...
|
|
4484
|
+
* state { auth document global local } } } childIds }`.
|
|
4485
|
+
*/
|
|
4486
|
+
function buildModelScopedQuery(model) {
|
|
4487
|
+
const globalState = model.documentModel.global;
|
|
4488
|
+
const documentName = getDocumentModelSchemaName(model);
|
|
4489
|
+
const globalSelection = getDocumentStateSelection(model);
|
|
4490
|
+
const localSchema = globalState.specifications.at(-1)?.state.local.schema ?? "";
|
|
4491
|
+
const localSelection = localSchema.includes(`type ${documentName}LocalState`) ? getLocalStateSelection(localSchema, documentName) : null;
|
|
4492
|
+
return [
|
|
4493
|
+
"query GetDocument($identifier: String!) {",
|
|
4494
|
+
` ${documentName} {`,
|
|
4495
|
+
" document(identifier: $identifier) {",
|
|
4496
|
+
" document {",
|
|
4497
|
+
" id",
|
|
4498
|
+
" name",
|
|
4499
|
+
" documentType",
|
|
4500
|
+
" state {",
|
|
4501
|
+
" auth",
|
|
4502
|
+
" document { version hash { algorithm encoding } isDeleted deletedAtUtcIso deletedBy deletionReason }",
|
|
4503
|
+
` global { ${globalSelection} }`,
|
|
4504
|
+
` ${localSelection ? `local { ${localSelection} }` : "local"}`,
|
|
4505
|
+
" }",
|
|
4506
|
+
" }",
|
|
4507
|
+
" childIds",
|
|
4508
|
+
" }",
|
|
4509
|
+
" }",
|
|
4510
|
+
"}"
|
|
4511
|
+
].join("\n");
|
|
4512
|
+
}
|
|
4513
|
+
function buildDocumentSubgraphQuery(documentType, identifier, model, authToken) {
|
|
4514
|
+
let query;
|
|
4515
|
+
if (model && model.documentModel.global.id === documentType) try {
|
|
4516
|
+
query = buildModelScopedQuery(model);
|
|
4517
|
+
} catch (error) {
|
|
4518
|
+
console.warn("Could not derive a document-scoped query from the document model, falling back to the generic document query:", error);
|
|
4519
|
+
query = getDocumentGraphqlQuery();
|
|
4520
|
+
}
|
|
4521
|
+
else query = getDocumentGraphqlQuery();
|
|
4386
4522
|
const variables = { identifier };
|
|
4387
4523
|
const headers = authToken ? { Authorization: `Bearer ${authToken}` } : void 0;
|
|
4388
4524
|
const payload = {
|
|
@@ -4390,10 +4526,11 @@ function buildDocumentSubgraphQuery(identifier, authToken) {
|
|
|
4390
4526
|
variables: JSON.stringify(variables, null, 2)
|
|
4391
4527
|
};
|
|
4392
4528
|
if (headers) payload.headers = JSON.stringify(headers);
|
|
4393
|
-
return import_lz_string.compressToEncodedURIComponent(JSON.stringify(payload));
|
|
4529
|
+
return import_lz_string.default.compressToEncodedURIComponent(JSON.stringify(payload));
|
|
4394
4530
|
}
|
|
4395
|
-
function buildDocumentSubgraphUrl(
|
|
4396
|
-
|
|
4531
|
+
function buildDocumentSubgraphUrl(channelUrl, documentType, identifier, model, authToken) {
|
|
4532
|
+
const encodedQuery = buildDocumentSubgraphQuery(documentType, identifier, model, authToken);
|
|
4533
|
+
return `${getSwitchboardBaseFromChannelUrl(channelUrl)}/explorer?explorerURLState=${encodedQuery}`;
|
|
4397
4534
|
}
|
|
4398
4535
|
/**
|
|
4399
4536
|
* Hook that returns a function to generate a document's switchboard URL.
|
|
@@ -4409,6 +4546,7 @@ function buildDocumentSubgraphUrl(driveUrl, identifier, authToken) {
|
|
|
4409
4546
|
function useGetSwitchboardLink(document) {
|
|
4410
4547
|
const [drive] = useSelectedDriveSafe();
|
|
4411
4548
|
const remotes = useSyncList();
|
|
4549
|
+
const documentModelModule = useDocumentModelModuleById(document?.header.documentType);
|
|
4412
4550
|
const isRemoteDrive = useMemo(() => {
|
|
4413
4551
|
if (!e$4(drive)) return false;
|
|
4414
4552
|
return remotes.some((remote) => remote.meta.collectionId.equals(DriveCollectionId.forDrive(drive.header.id)));
|
|
@@ -4433,12 +4571,13 @@ function useGetSwitchboardLink(document) {
|
|
|
4433
4571
|
expiresIn: 600,
|
|
4434
4572
|
aud: remoteUrl
|
|
4435
4573
|
}) : void 0;
|
|
4436
|
-
return buildDocumentSubgraphUrl(remoteUrl, document.header.id, token);
|
|
4574
|
+
return buildDocumentSubgraphUrl(remoteUrl, document.header.documentType, document.header.id, documentModelModule, token);
|
|
4437
4575
|
};
|
|
4438
4576
|
}, [
|
|
4439
4577
|
isRemoteDrive,
|
|
4440
4578
|
remoteUrl,
|
|
4441
4579
|
document,
|
|
4580
|
+
documentModelModule,
|
|
4442
4581
|
user,
|
|
4443
4582
|
renown
|
|
4444
4583
|
]);
|
|
@@ -4507,4 +4646,4 @@ createDebouncedRefreshReactorDataClient();
|
|
|
4507
4646
|
//#endregion
|
|
4508
4647
|
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 };
|
|
4509
4648
|
|
|
4510
|
-
//# sourceMappingURL=dist-
|
|
4649
|
+
//# sourceMappingURL=dist-BAXIB1_k.mjs.map
|