@powerhousedao/reactor-browser 6.2.3-staging.0 → 6.3.0-dev.1
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-But1Xljo.d.ts → attachment-service-B-AmTrs2.d.ts} +605 -56
- package/dist/attachment-service-B-AmTrs2.d.ts.map +1 -0
- package/dist/auth-DRbzRdeC.d.ts +32 -0
- package/dist/auth-DRbzRdeC.d.ts.map +1 -0
- package/dist/{client-BiJAJ9dW.js → client-BFnMV-EO.js} +39 -22
- package/dist/client-BFnMV-EO.js.map +1 -0
- package/dist/{client-CngU4mtn.d.ts → client-BP0hXjqq.d.ts} +3 -2
- package/dist/client-BP0hXjqq.d.ts.map +1 -0
- package/dist/client-wwavHFfs.js +135 -0
- package/dist/client-wwavHFfs.js.map +1 -0
- package/dist/{dispatch-qRXS70fh.js → dispatch-Cylwl2Dk.js} +363 -44
- package/dist/dispatch-Cylwl2Dk.js.map +1 -0
- package/dist/{document-by-id-B_8DA4yZ.js → document-by-id-DdvqanGR.js} +2 -2
- package/dist/{document-by-id-B_8DA4yZ.js.map → document-by-id-DdvqanGR.js.map} +1 -1
- package/dist/document-model-modules-BG-61uke.js +710 -0
- package/dist/document-model-modules-BG-61uke.js.map +1 -0
- package/dist/{document-operations-Bt-1-ThH.js → document-operations-DRMMwmGZ.js} +2160 -181
- package/dist/document-operations-DRMMwmGZ.js.map +1 -0
- package/dist/global-iARBhxNI.d.ts +612 -0
- package/dist/global-iARBhxNI.d.ts.map +1 -0
- package/dist/{index-BABMK8cO.d.ts → index-CNS_9THu.d.ts} +14 -4
- package/dist/index-CNS_9THu.d.ts.map +1 -0
- package/dist/index.d.ts +560 -79
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +790 -317
- package/dist/index.js.map +1 -1
- package/dist/inspector-proxy-DODqs15F.d.ts +25 -0
- package/dist/inspector-proxy-DODqs15F.d.ts.map +1 -0
- package/dist/make-ph-event-functions-B5GU5xcR.js +180 -0
- package/dist/make-ph-event-functions-B5GU5xcR.js.map +1 -0
- package/dist/{relational-ChC_AWAK.js → relational-DZuyKp2y.js} +65 -5
- package/dist/relational-DZuyKp2y.js.map +1 -0
- package/dist/{renown-C9pYZRqf.js → renown-B3MUaiq7.js} +56 -25
- package/dist/renown-B3MUaiq7.js.map +1 -0
- package/dist/renown-CBoTdGrg.js +394 -0
- package/dist/renown-CBoTdGrg.js.map +1 -0
- package/dist/{client-VV9M73s_.js → schema-B5lftDPf.js} +295 -195
- package/dist/schema-B5lftDPf.js.map +1 -0
- package/dist/{types-B7-_l_wE.d.ts → schema-C6ECceaN.d.ts} +272 -82
- package/dist/schema-C6ECceaN.d.ts.map +1 -0
- package/dist/src/ai/index.d.ts +269 -24
- package/dist/src/ai/index.d.ts.map +1 -1
- package/dist/src/ai/index.js +1028 -168
- package/dist/src/ai/index.js.map +1 -1
- package/dist/src/analytics/index.js +3 -3
- 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 +6 -4
- package/dist/src/graphql-client/entry.js +4 -4
- package/dist/src/relational/index.d.ts +8 -1
- package/dist/src/relational/index.d.ts.map +1 -1
- package/dist/src/relational/index.js +1 -1
- package/dist/src/renown/index.d.ts +2 -2
- package/dist/src/renown/index.js +3 -3
- package/dist/src/rpc/index.d.ts +201 -144
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/index.js +562 -634
- package/dist/src/rpc/index.js.map +1 -1
- package/dist/switchboard-directory-vH6qtkh-.js +435 -0
- package/dist/switchboard-directory-vH6qtkh-.js.map +1 -0
- package/dist/switchboards-D-_JBUbF.d.ts +75 -0
- package/dist/switchboards-D-_JBUbF.d.ts.map +1 -0
- package/dist/types-BWx6FPO4.d.ts +63 -0
- package/dist/types-BWx6FPO4.d.ts.map +1 -0
- package/package.json +19 -17
- package/dist/attachment-service-But1Xljo.d.ts.map +0 -1
- package/dist/client-BiJAJ9dW.js.map +0 -1
- package/dist/client-CngU4mtn.d.ts.map +0 -1
- package/dist/client-VV9M73s_.js.map +0 -1
- package/dist/dispatch-qRXS70fh.js.map +0 -1
- package/dist/document-model-modules-D6I-UUXq.js +0 -386
- package/dist/document-model-modules-D6I-UUXq.js.map +0 -1
- package/dist/document-operations-Bt-1-ThH.js.map +0 -1
- package/dist/global-fql2bmb0.d.ts +0 -438
- package/dist/global-fql2bmb0.d.ts.map +0 -1
- package/dist/index-BABMK8cO.d.ts.map +0 -1
- package/dist/inspector-proxy-DCowaeeH.d.ts +0 -264
- package/dist/inspector-proxy-DCowaeeH.d.ts.map +0 -1
- package/dist/make-ph-event-functions-FzpvQtj6.js +0 -53
- package/dist/make-ph-event-functions-FzpvQtj6.js.map +0 -1
- package/dist/relational-ChC_AWAK.js.map +0 -1
- package/dist/renown-C9pYZRqf.js.map +0 -1
- package/dist/renown-Def5iO8k.js +0 -97
- package/dist/renown-Def5iO8k.js.map +0 -1
- package/dist/switchboard-CFyD_5_e.js +0 -323
- package/dist/switchboard-CFyD_5_e.js.map +0 -1
- package/dist/types-B7-_l_wE.d.ts.map +0 -1
package/dist/renown-Def5iO8k.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { t as makePHEventFunctions } from "./make-ph-event-functions-FzpvQtj6.js";
|
|
2
|
-
import { createContext, useContext, useEffect, useState, useSyncExternalStore } from "react";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
//#region src/hooks/loading.ts
|
|
5
|
-
const { useValue: useLoading, setValue: setLoading, addEventHandler: addLoadingEventHandler } = makePHEventFunctions("loading");
|
|
6
|
-
const loading = null;
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/renown/initial-user.tsx
|
|
9
|
-
const RENOWN_INITIAL_UNKNOWN = { state: "unknown" };
|
|
10
|
-
const RENOWN_INITIAL_ANONYMOUS = { state: "anonymous" };
|
|
11
|
-
const RenownInitialUserContext = createContext(RENOWN_INITIAL_UNKNOWN);
|
|
12
|
-
function RenownInitialUserProvider({ initialAuth, initialUser, children }) {
|
|
13
|
-
const value = initialAuth ?? (initialUser ? {
|
|
14
|
-
state: "authenticated",
|
|
15
|
-
user: initialUser
|
|
16
|
-
} : RENOWN_INITIAL_UNKNOWN);
|
|
17
|
-
return /* @__PURE__ */ jsx(RenownInitialUserContext.Provider, {
|
|
18
|
-
value,
|
|
19
|
-
children
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
/** First-render auth as a three-state value; use this to skip a spinner when anonymous. */
|
|
23
|
-
function useRenownInitialAuth() {
|
|
24
|
-
return useContext(RenownInitialUserContext);
|
|
25
|
-
}
|
|
26
|
-
function useRenownInitialUser() {
|
|
27
|
-
const initial = useRenownInitialAuth();
|
|
28
|
-
return initial.state === "authenticated" ? initial.user : void 0;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/hooks/renown.ts
|
|
32
|
-
const renownEventFunctions = makePHEventFunctions("renown");
|
|
33
|
-
/** Adds an event handler for the renown instance */
|
|
34
|
-
const addRenownEventHandler = renownEventFunctions.addEventHandler;
|
|
35
|
-
/** Returns the renown instance */
|
|
36
|
-
const useRenown = renownEventFunctions.useValue;
|
|
37
|
-
/** Sets the renown instance */
|
|
38
|
-
const setRenown = renownEventFunctions.setValue;
|
|
39
|
-
/** Returns the DID from the renown instance */
|
|
40
|
-
function useDid() {
|
|
41
|
-
return useRenown()?.did;
|
|
42
|
-
}
|
|
43
|
-
function jsonEqual(a, b) {
|
|
44
|
-
if (a === b) return true;
|
|
45
|
-
if (typeof a !== "object" || typeof b !== "object" || !a || !b) return false;
|
|
46
|
-
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
47
|
-
const ra = a;
|
|
48
|
-
const rb = b;
|
|
49
|
-
const keys = Object.keys(ra).filter((k) => ra[k] !== void 0);
|
|
50
|
-
if (keys.length !== Object.keys(rb).filter((k) => rb[k] !== void 0).length) return false;
|
|
51
|
-
return keys.every((k) => jsonEqual(ra[k], rb[k]));
|
|
52
|
-
}
|
|
53
|
-
function sameUser(a, b) {
|
|
54
|
-
return jsonEqual(a, b);
|
|
55
|
-
}
|
|
56
|
-
function resolveInstanceUser(instance, seed) {
|
|
57
|
-
const restored = instance.user;
|
|
58
|
-
if (restored) return sameUser(seed, restored) ? seed : restored;
|
|
59
|
-
return instance.status === "initial" ? void 0 : seed;
|
|
60
|
-
}
|
|
61
|
-
/** Returns the current user from the renown instance, subscribing to user events */
|
|
62
|
-
function useUser() {
|
|
63
|
-
const renown = useRenown();
|
|
64
|
-
const initialUser = useRenownInitialUser();
|
|
65
|
-
const instance = renown ? renown : void 0;
|
|
66
|
-
const [tracked, setTracked] = useState(() => ({
|
|
67
|
-
instance,
|
|
68
|
-
user: instance ? resolveInstanceUser(instance, initialUser) : initialUser
|
|
69
|
-
}));
|
|
70
|
-
const current = tracked.instance === instance ? tracked : {
|
|
71
|
-
instance,
|
|
72
|
-
user: instance ? resolveInstanceUser(instance, tracked.user ?? initialUser) : tracked.user
|
|
73
|
-
};
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (current !== tracked) setTracked(current);
|
|
76
|
-
}, [current, tracked]);
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
if (!instance) return;
|
|
79
|
-
return instance.on("user", (user) => setTracked((prev) => ({
|
|
80
|
-
instance,
|
|
81
|
-
user: sameUser(prev.user, user) ? prev.user : user
|
|
82
|
-
})));
|
|
83
|
-
}, [instance]);
|
|
84
|
-
return instance ? current.user : initialUser ?? current.user;
|
|
85
|
-
}
|
|
86
|
-
/** Returns the login status, subscribing to renown status events */
|
|
87
|
-
function useLoginStatus() {
|
|
88
|
-
const renown = useRenown();
|
|
89
|
-
return useSyncExternalStore((cb) => {
|
|
90
|
-
if (!renown) return () => {};
|
|
91
|
-
return renown.on("status", cb);
|
|
92
|
-
}, () => renown === null ? "loading" : renown?.status, () => void 0);
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
export { useRenown as a, RENOWN_INITIAL_UNKNOWN as c, useRenownInitialUser as d, addLoadingEventHandler as f, useLoading as h, useLoginStatus as i, RenownInitialUserProvider as l, setLoading as m, setRenown as n, useUser as o, loading as p, useDid as r, RENOWN_INITIAL_ANONYMOUS as s, addRenownEventHandler as t, useRenownInitialAuth as u };
|
|
96
|
-
|
|
97
|
-
//# sourceMappingURL=renown-Def5iO8k.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renown-Def5iO8k.js","names":[],"sources":["../src/hooks/loading.ts","../src/renown/initial-user.tsx","../src/hooks/renown.ts"],"sourcesContent":["import type { LOADING } from \"../types/global.js\";\nimport { makePHEventFunctions } from \"./make-ph-event-functions.js\";\n\nexport const {\n useValue: useLoading,\n setValue: setLoading,\n addEventHandler: addLoadingEventHandler,\n} = makePHEventFunctions(\"loading\");\n\nexport const loading: LOADING = null;\n","\"use client\";\n\nimport type { User } from \"@renown/sdk\";\nimport { createContext, useContext, type ReactNode } from \"react\";\n\n/** Whether the first render already knows who (if anyone) is signed in. */\n// \"anonymous\" is load-bearing: it separates a signed-out visitor from an\n// unresolved one, which otherwise both have to render a spinner.\nexport type RenownInitialAuth =\n | { state: \"authenticated\"; user: User }\n | { state: \"anonymous\" }\n | { state: \"unknown\" };\n\nexport const RENOWN_INITIAL_UNKNOWN: RenownInitialAuth = { state: \"unknown\" };\nexport const RENOWN_INITIAL_ANONYMOUS: RenownInitialAuth = {\n state: \"anonymous\",\n};\n\n// Seeds the auth store's first render (server + hydration) from a session\n// cookie or localStorage, enabling authenticated SSR without a flash.\nconst RenownInitialUserContext = createContext<RenownInitialAuth>(\n RENOWN_INITIAL_UNKNOWN,\n);\n\nexport interface RenownInitialUserProviderProps {\n /** Resolved first-render auth (see `RenownProvider`). Takes precedence over `initialUser`. */\n initialAuth?: RenownInitialAuth;\n /** User resolved from a verified session cookie (see `verifyRenownSession`). */\n initialUser?: User;\n children: ReactNode;\n}\n\nexport function RenownInitialUserProvider({\n initialAuth,\n initialUser,\n children,\n}: RenownInitialUserProviderProps) {\n // `initialUser` alone cannot express \"anonymous\" — absence stays \"unknown\".\n const value =\n initialAuth ??\n (initialUser\n ? { state: \"authenticated\" as const, user: initialUser }\n : RENOWN_INITIAL_UNKNOWN);\n return (\n <RenownInitialUserContext.Provider value={value}>\n {children}\n </RenownInitialUserContext.Provider>\n );\n}\n\n/** First-render auth as a three-state value; use this to skip a spinner when anonymous. */\nexport function useRenownInitialAuth(): RenownInitialAuth {\n return useContext(RenownInitialUserContext);\n}\n\nexport function useRenownInitialUser(): User | undefined {\n const initial = useRenownInitialAuth();\n return initial.state === \"authenticated\" ? initial.user : undefined;\n}\n","import type { IRenown, LoginStatus, User } from \"@renown/sdk\";\nimport { useEffect, useState, useSyncExternalStore } from \"react\";\nimport { useRenownInitialUser } from \"../renown/initial-user.js\";\nimport type { LOADING } from \"../types/global.js\";\nimport { loading } from \"./loading.js\";\nimport { makePHEventFunctions } from \"./make-ph-event-functions.js\";\n\nconst renownEventFunctions = makePHEventFunctions(\"renown\");\n\n/** Adds an event handler for the renown instance */\nexport const addRenownEventHandler: () => void =\n renownEventFunctions.addEventHandler;\n\n/** Returns the renown instance */\nexport const useRenown: () => IRenown | LOADING | undefined =\n renownEventFunctions.useValue;\n\n/** Sets the renown instance */\nexport const setRenown: (value: IRenown | LOADING | undefined) => void =\n renownEventFunctions.setValue;\n\n/** Returns the DID from the renown instance */\nexport function useDid() {\n const renown = useRenown();\n return renown?.did;\n}\n\n// Order-insensitive structural equality for plain JSON (what a persisted user\n// is): the cookie and localStorage paths build the same user with different key\n// order, and both must keep one object identity for did-keyed consumers.\nfunction jsonEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (typeof a !== \"object\" || typeof b !== \"object\" || !a || !b) return false;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n const ra = a as Record<string, unknown>;\n const rb = b as Record<string, unknown>;\n const keys = Object.keys(ra).filter((k) => ra[k] !== undefined);\n if (keys.length !== Object.keys(rb).filter((k) => rb[k] !== undefined).length)\n return false;\n return keys.every((k) => jsonEqual(ra[k], rb[k]));\n}\n\nfunction sameUser(a: User | undefined, b: User | undefined): boolean {\n return jsonEqual(a, b);\n}\n\n// What the SDK says once it exists. Its `user` is a synchronous storage read,\n// so undefined with status \"initial\" means nothing was restored and a stale seed\n// (e.g. a cookie outliving localStorage) must go; during \"checking\"/\"authorized\"\n// the SDK owns a session it has not published yet, so the seed stands.\nfunction resolveInstanceUser(\n instance: IRenown,\n seed: User | undefined,\n): User | undefined {\n const restored = instance.user;\n if (restored) return sameUser(seed, restored) ? seed : restored;\n return instance.status === \"initial\" ? undefined : seed;\n}\n\ninterface TrackedUser {\n instance: IRenown | undefined;\n user: User | undefined;\n}\n\n/** Returns the current user from the renown instance, subscribing to user events */\nexport function useUser(): User | undefined {\n const renown = useRenown();\n // Seed (cookie on the server, localStorage once mounted) covers the first\n // paint; the SDK is authoritative after, so a logout/revoke clears it.\n const initialUser = useRenownInitialUser();\n const instance = renown ? renown : undefined;\n // Tagged with the instance it came from. On a swap the value for this render\n // is derived here (state alone would be one frame stale) and persisted after\n // commit; the derivation is pure, so re-renders before that agree.\n const [tracked, setTracked] = useState<TrackedUser>(() => ({\n instance,\n user: instance ? resolveInstanceUser(instance, initialUser) : initialUser,\n }));\n const current: TrackedUser =\n tracked.instance === instance\n ? tracked\n : {\n instance,\n user: instance\n ? resolveInstanceUser(instance, tracked.user ?? initialUser)\n : tracked.user,\n };\n\n useEffect(() => {\n if (current !== tracked) setTracked(current);\n }, [current, tracked]);\n\n useEffect(() => {\n if (!instance) return;\n return instance.on(\"user\", (user) =>\n setTracked((prev) => ({\n instance,\n user: sameUser(prev.user, user) ? prev.user : user,\n })),\n );\n }, [instance]);\n\n // Until the SDK exists the seed wins, which is what lands the post-mount\n // localStorage read.\n return instance ? current.user : (initialUser ?? current.user);\n}\n\n/** Returns the login status, subscribing to renown status events */\nexport function useLoginStatus(): LoginStatus | \"loading\" | undefined {\n const renown = useRenown();\n return useSyncExternalStore(\n (cb) => {\n if (!renown) {\n return () => {};\n }\n return renown.on(\"status\", cb);\n },\n () => (renown === loading ? \"loading\" : renown?.status),\n () => undefined,\n );\n}\n"],"mappings":";;;;AAGA,MAAa,EACX,UAAU,YACV,UAAU,YACV,iBAAiB,2BACf,qBAAqB,SAAS;AAElC,MAAa,UAAmB;;;ACIhC,MAAa,yBAA4C,EAAE,OAAO,UAAU;AAC5E,MAAa,2BAA8C,EACzD,OAAO,YACT;AAIA,MAAM,2BAA2B,cAC/B,sBACF;AAUA,SAAgB,0BAA0B,EACxC,aACA,aACA,YACiC;CAEjC,MAAM,QACJ,gBACC,cACG;EAAE,OAAO;EAA0B,MAAM;CAAY,IACrD;CACN,OACE,oBAAC,yBAAyB,UAA1B;EAA0C;EACvC;CACgC,CAAA;AAEvC;;AAGA,SAAgB,uBAA0C;CACxD,OAAO,WAAW,wBAAwB;AAC5C;AAEA,SAAgB,uBAAyC;CACvD,MAAM,UAAU,qBAAqB;CACrC,OAAO,QAAQ,UAAU,kBAAkB,QAAQ,OAAO,KAAA;AAC5D;;;ACnDA,MAAM,uBAAuB,qBAAqB,QAAQ;;AAG1D,MAAa,wBACX,qBAAqB;;AAGvB,MAAa,YACX,qBAAqB;;AAGvB,MAAa,YACX,qBAAqB;;AAGvB,SAAgB,SAAS;CAEvB,OADe,UACH,CAAC,EAAE;AACjB;AAKA,SAAS,UAAU,GAAY,GAAqB;CAClD,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,OAAO,MAAM,YAAY,OAAO,MAAM,YAAY,CAAC,KAAK,CAAC,GAAG,OAAO;CACvE,IAAI,MAAM,QAAQ,CAAC,MAAM,MAAM,QAAQ,CAAC,GAAG,OAAO;CAClD,MAAM,KAAK;CACX,MAAM,KAAK;CACX,MAAM,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,QAAQ,MAAM,GAAG,OAAO,KAAA,CAAS;CAC9D,IAAI,KAAK,WAAW,OAAO,KAAK,EAAE,C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
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import { I as DocumentTypeMismatchError, L as NoSelectedDocumentError, p as useSelectedDriveSafe, t as useDocumentModelModuleById, v as useSelectedNodeId, z as ambientRenownTokenProvider } from "./document-model-modules-D6I-UUXq.js";
|
|
2
|
-
import { n as useDocumentsByIds, t as useDocumentById } from "./document-by-id-B_8DA4yZ.js";
|
|
3
|
-
import { DriveCollectionId, ModuleNotFoundError } from "@powerhousedao/reactor";
|
|
4
|
-
import { isFileNode } from "@powerhousedao/shared/document-drive";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
//#region src/utils/nodes.ts
|
|
7
|
-
/** Sorts nodes by name. */
|
|
8
|
-
function sortNodesByName(nodes) {
|
|
9
|
-
return nodes.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
10
|
-
}
|
|
11
|
-
/** Returns whether a node is a file. */
|
|
12
|
-
function isFileNodeKind(node) {
|
|
13
|
-
if (!node) return false;
|
|
14
|
-
return node.kind.toUpperCase() === "FILE";
|
|
15
|
-
}
|
|
16
|
-
/** Returns whether a node is a folder. */
|
|
17
|
-
function isFolderNodeKind(node) {
|
|
18
|
-
if (!node) return false;
|
|
19
|
-
return node.kind.toUpperCase() === "FOLDER";
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/hooks/items-in-selected-drive.ts
|
|
23
|
-
/** Returns the nodes in the selected drive. */
|
|
24
|
-
function useNodesInSelectedDrive() {
|
|
25
|
-
const [selectedDrive] = useSelectedDriveSafe();
|
|
26
|
-
return selectedDrive?.state.global.nodes;
|
|
27
|
-
}
|
|
28
|
-
/** Returns the file nodes in the selected drive. */
|
|
29
|
-
function useFileNodesInSelectedDrive() {
|
|
30
|
-
return useNodesInSelectedDrive()?.filter((n) => isFileNodeKind(n));
|
|
31
|
-
}
|
|
32
|
-
/** Returns the folder nodes in the selected drive. */
|
|
33
|
-
function useFolderNodesInSelectedDrive() {
|
|
34
|
-
return useNodesInSelectedDrive()?.filter((n) => isFolderNodeKind(n));
|
|
35
|
-
}
|
|
36
|
-
/** Returns the documents in the selected drive. */
|
|
37
|
-
function useDocumentsInSelectedDrive() {
|
|
38
|
-
const fileNodeIds = useFileNodesInSelectedDrive()?.map((node) => node.id);
|
|
39
|
-
return useDocumentsByIds(fileNodeIds);
|
|
40
|
-
}
|
|
41
|
-
/** Returns the document types supported by the selected drive, as defined by the document model documents present in the drive */
|
|
42
|
-
function useDocumentTypesInSelectedDrive() {
|
|
43
|
-
return (useDocumentsInSelectedDrive()?.filter(isDocumentModelDocument))?.map((doc) => doc.state.global.id);
|
|
44
|
-
}
|
|
45
|
-
function isDocumentModelDocument(document) {
|
|
46
|
-
return document.header.documentType === "powerhouse/document-model";
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/hooks/selected-node.ts
|
|
50
|
-
/** Returns the selected node. */
|
|
51
|
-
function useSelectedNode() {
|
|
52
|
-
const selectedNodeId = useSelectedNodeId();
|
|
53
|
-
return useNodesInSelectedDrive()?.find((n) => n.id === selectedNodeId);
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region src/hooks/document-of-type.ts
|
|
57
|
-
/** Returns a document of a specific type, throws an error if the found document has a different type */
|
|
58
|
-
function useDocumentOfType(documentId, documentType) {
|
|
59
|
-
const [document, dispatch] = useDocumentById(documentId);
|
|
60
|
-
const documentModelModule = useDocumentModelModuleById(documentType);
|
|
61
|
-
if (!documentId || !documentType) return [];
|
|
62
|
-
if (!document) throw new Error(`Document not found: ${documentId}`);
|
|
63
|
-
if (!documentModelModule) throw new ModuleNotFoundError(documentType);
|
|
64
|
-
if (document.header.documentType !== documentType) throw new DocumentTypeMismatchError(documentId, documentType, document.header.documentType);
|
|
65
|
-
return [document, dispatch];
|
|
66
|
-
}
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/hooks/selected-document.ts
|
|
69
|
-
/** Returns the selected document id */
|
|
70
|
-
function useSelectedDocumentId() {
|
|
71
|
-
const selectedNode = useSelectedNode();
|
|
72
|
-
return selectedNode && isFileNode(selectedNode) ? selectedNode.id : void 0;
|
|
73
|
-
}
|
|
74
|
-
/** Returns the selected document. */
|
|
75
|
-
function useSelectedDocument() {
|
|
76
|
-
const selectedDocumentId = useSelectedDocumentId();
|
|
77
|
-
const [document, dispatch] = useDocumentById(selectedDocumentId);
|
|
78
|
-
if (!document) throw new NoSelectedDocumentError();
|
|
79
|
-
return [document, dispatch];
|
|
80
|
-
}
|
|
81
|
-
/** Returns the selected document. */
|
|
82
|
-
function useSelectedDocumentSafe() {
|
|
83
|
-
const selectedDocumentId = useSelectedDocumentId();
|
|
84
|
-
return useDocumentById(selectedDocumentId);
|
|
85
|
-
}
|
|
86
|
-
function useSelectedDocumentOfType(documentType) {
|
|
87
|
-
const documentId = useSelectedDocumentId();
|
|
88
|
-
if (!documentType) return [];
|
|
89
|
-
if (!documentId) throw new NoSelectedDocumentError();
|
|
90
|
-
return useDocumentOfType(documentId, documentType);
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/ai/switchboard.ts
|
|
94
|
-
/**
|
|
95
|
-
* Reads the tab-side sync manager from the browser global. Returns
|
|
96
|
-
* `undefined` in non-browser environments or before the reactor client
|
|
97
|
-
* module is initialized.
|
|
98
|
-
*/
|
|
99
|
-
function getBrowserSyncManager() {
|
|
100
|
-
if (typeof window === "undefined") return;
|
|
101
|
-
return window.ph?.reactorClientModule?.reactorModule?.syncModule?.syncManager;
|
|
102
|
-
}
|
|
103
|
-
/** Suffix of the per-drive GraphQL channel endpoint the switchboard serves. */
|
|
104
|
-
const GQL_CHANNEL_SUFFIX = "/graphql/r";
|
|
105
|
-
/**
|
|
106
|
-
* Resolves the switchboard that serves a drive, if any.
|
|
107
|
-
*
|
|
108
|
-
* Every remote drive stores its switchboard's exact GraphQL channel
|
|
109
|
-
* endpoint in its sync remote — `channelConfig = { type: "gql",
|
|
110
|
-
* parameters: { url: "<origin>/graphql/r" } }` — and the switchboard base
|
|
111
|
-
* is that URL minus the `/graphql/r` suffix. Deriving it per drive (rather
|
|
112
|
-
* than from a global setting) is what keeps multi-switchboard deployments
|
|
113
|
-
* correct. Drives that are not synced to a remote switchboard (local
|
|
114
|
-
* drives, other channel types, unexpected shapes) return `undefined`.
|
|
115
|
-
*/
|
|
116
|
-
function resolveDriveSwitchboard(driveId, syncManager) {
|
|
117
|
-
const manager = syncManager ?? getBrowserSyncManager();
|
|
118
|
-
if (!driveId || !manager) return;
|
|
119
|
-
const collectionId = DriveCollectionId.forDrive(driveId);
|
|
120
|
-
const remote = manager.list().find((r) => r.meta.collectionId.equals(collectionId));
|
|
121
|
-
if (!remote) return;
|
|
122
|
-
const { channelConfig } = remote.meta;
|
|
123
|
-
if (channelConfig.type !== "gql") return;
|
|
124
|
-
const url = channelConfig.parameters.url;
|
|
125
|
-
if (typeof url !== "string" || !url.endsWith("/graphql/r")) return;
|
|
126
|
-
const switchboardUrl = url.slice(0, -10);
|
|
127
|
-
return {
|
|
128
|
-
switchboardUrl,
|
|
129
|
-
graphqlUrl: `${switchboardUrl}/graphql`
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Introspection over the switchboard supergraph's root query and mutation
|
|
134
|
-
* fields. Types are requested with three levels of `ofType` nesting so
|
|
135
|
-
* that common shapes like `[X!]!` (LIST(NON_NULL(LIST(X)))) render fully.
|
|
136
|
-
*/
|
|
137
|
-
const SWITCHBOARD_INTROSPECTION_QUERY = `
|
|
138
|
-
query SwitchboardIntrospection {
|
|
139
|
-
__schema {
|
|
140
|
-
queryType {
|
|
141
|
-
fields {
|
|
142
|
-
name
|
|
143
|
-
description
|
|
144
|
-
args {
|
|
145
|
-
name
|
|
146
|
-
type {
|
|
147
|
-
kind
|
|
148
|
-
name
|
|
149
|
-
ofType {
|
|
150
|
-
kind
|
|
151
|
-
name
|
|
152
|
-
ofType {
|
|
153
|
-
kind
|
|
154
|
-
name
|
|
155
|
-
ofType {
|
|
156
|
-
kind
|
|
157
|
-
name
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
type {
|
|
164
|
-
kind
|
|
165
|
-
name
|
|
166
|
-
ofType {
|
|
167
|
-
kind
|
|
168
|
-
name
|
|
169
|
-
ofType {
|
|
170
|
-
kind
|
|
171
|
-
name
|
|
172
|
-
ofType {
|
|
173
|
-
kind
|
|
174
|
-
name
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
mutationType {
|
|
182
|
-
fields {
|
|
183
|
-
name
|
|
184
|
-
description
|
|
185
|
-
args {
|
|
186
|
-
name
|
|
187
|
-
type {
|
|
188
|
-
kind
|
|
189
|
-
name
|
|
190
|
-
ofType {
|
|
191
|
-
kind
|
|
192
|
-
name
|
|
193
|
-
ofType {
|
|
194
|
-
kind
|
|
195
|
-
name
|
|
196
|
-
ofType {
|
|
197
|
-
kind
|
|
198
|
-
name
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
type {
|
|
205
|
-
kind
|
|
206
|
-
name
|
|
207
|
-
ofType {
|
|
208
|
-
kind
|
|
209
|
-
name
|
|
210
|
-
ofType {
|
|
211
|
-
kind
|
|
212
|
-
name
|
|
213
|
-
ofType {
|
|
214
|
-
kind
|
|
215
|
-
name
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
`;
|
|
225
|
-
/**
|
|
226
|
-
* Renders an introspected type reference as a GraphQL type string.
|
|
227
|
-
* Recursion is bounded by the `ofType` nesting of the query, so it always
|
|
228
|
-
* terminates.
|
|
229
|
-
*/
|
|
230
|
-
function renderTypeRef(type) {
|
|
231
|
-
if (!type) return "Unknown";
|
|
232
|
-
switch (type.kind) {
|
|
233
|
-
case "NON_NULL": return `${renderTypeRef(type.ofType)}!`;
|
|
234
|
-
case "LIST": return `[${renderTypeRef(type.ofType)}]`;
|
|
235
|
-
default: return type.name ?? "Unknown";
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
/** Cap on the number of fields reported per root type. */
|
|
239
|
-
const MAX_FIELDS_PER_ROOT = 200;
|
|
240
|
-
function summarizeFields(fields) {
|
|
241
|
-
const list = fields ?? [];
|
|
242
|
-
return {
|
|
243
|
-
fields: list.slice(0, MAX_FIELDS_PER_ROOT).map((field) => ({
|
|
244
|
-
name: field.name,
|
|
245
|
-
...field.description ? { description: field.description } : {},
|
|
246
|
-
args: field.args.map((arg) => `${arg.name}: ${renderTypeRef(arg.type)}`).join(", "),
|
|
247
|
-
returns: renderTypeRef(field.type)
|
|
248
|
-
})),
|
|
249
|
-
truncated: list.length > MAX_FIELDS_PER_ROOT
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Reduces a GraphQL `__schema` introspection payload (the `data.__schema`
|
|
254
|
-
* object) to a compact summary of its root query and mutation fields.
|
|
255
|
-
* Accepts `unknown` because the payload arrives over the wire.
|
|
256
|
-
*/
|
|
257
|
-
function summarizeIntrospectionSchema(schema) {
|
|
258
|
-
const introspection = schema ?? {};
|
|
259
|
-
const queries = summarizeFields(introspection.queryType?.fields);
|
|
260
|
-
const mutations = summarizeFields(introspection.mutationType?.fields);
|
|
261
|
-
return {
|
|
262
|
-
queries: queries.fields,
|
|
263
|
-
mutations: mutations.fields,
|
|
264
|
-
truncated: queries.truncated || mutations.truncated
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
const SWITCHBOARD_SCHEMA_TOOL_NAME = "getSwitchboardSchema";
|
|
268
|
-
/**
|
|
269
|
-
* Creates the read-only `getSwitchboardSchema` tool: it introspects the
|
|
270
|
-
* GraphQL supergraph of the switchboard serving a drive and returns a
|
|
271
|
-
* summary of its root queries and mutations. It reads the schema only and
|
|
272
|
-
* never modifies data.
|
|
273
|
-
*/
|
|
274
|
-
function createSwitchboardSchemaTool(deps) {
|
|
275
|
-
const getSyncManager = deps?.getSyncManager ?? getBrowserSyncManager;
|
|
276
|
-
const getSelectedDriveId = deps?.getSelectedDriveId ?? (() => typeof window === "undefined" ? void 0 : window.ph?.selectedDriveId);
|
|
277
|
-
const tokenProvider = deps?.tokenProvider ?? ambientRenownTokenProvider;
|
|
278
|
-
const fetchImpl = deps?.fetchImpl ?? fetch;
|
|
279
|
-
const timeoutMs = deps?.timeoutMs ?? 1e4;
|
|
280
|
-
return {
|
|
281
|
-
name: SWITCHBOARD_SCHEMA_TOOL_NAME,
|
|
282
|
-
description: "Introspect the GraphQL endpoint of the switchboard serving a drive and list the queries and mutations it exposes (reactor operations, document-model read models, package subgraphs). Read-only: it reads the schema only and never modifies data. Omit driveId to introspect the currently selected drive.",
|
|
283
|
-
inputSchema: { driveId: z.string().describe("Drive to introspect. Omit to use the currently selected drive.").optional() },
|
|
284
|
-
annotations: { readOnlyHint: true },
|
|
285
|
-
callback: async (input) => {
|
|
286
|
-
const driveId = input?.driveId ?? getSelectedDriveId();
|
|
287
|
-
const sb = resolveDriveSwitchboard(driveId, getSyncManager());
|
|
288
|
-
if (!sb) throw new Error(driveId ? `Drive "${driveId}" has no switchboard: it is not synced to a remote switchboard.` : "No drive is currently selected and no driveId was given.");
|
|
289
|
-
const token = await tokenProvider();
|
|
290
|
-
let response;
|
|
291
|
-
try {
|
|
292
|
-
response = await fetchImpl(sb.graphqlUrl, {
|
|
293
|
-
method: "POST",
|
|
294
|
-
headers: {
|
|
295
|
-
"content-type": "application/json",
|
|
296
|
-
...token ? { authorization: `Bearer ${token}` } : {}
|
|
297
|
-
},
|
|
298
|
-
body: JSON.stringify({ query: SWITCHBOARD_INTROSPECTION_QUERY }),
|
|
299
|
-
signal: AbortSignal.timeout(timeoutMs)
|
|
300
|
-
});
|
|
301
|
-
} catch (error) {
|
|
302
|
-
throw new Error(`Switchboard at ${sb.graphqlUrl} is not reachable: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
303
|
-
}
|
|
304
|
-
if (response.status === 401 || response.status === 403) throw new Error(`Switchboard at ${sb.graphqlUrl} refused the request (HTTP ${response.status}). Sign in to the switchboard (Renown) and try again.`);
|
|
305
|
-
if (!response.ok) throw new Error(`Switchboard introspection failed: HTTP ${response.status} ${response.statusText} from ${sb.graphqlUrl}`);
|
|
306
|
-
const body = await response.json();
|
|
307
|
-
const schemaErrors = body?.errors;
|
|
308
|
-
if (schemaErrors && schemaErrors.length > 0) throw new Error(schemaErrors.map((e) => e.message ?? "unknown error").join("; "));
|
|
309
|
-
const schema = body?.data?.__schema;
|
|
310
|
-
if (!schema?.queryType) throw new Error(`Switchboard at ${sb.graphqlUrl} did not return a GraphQL schema.`);
|
|
311
|
-
const summary = summarizeIntrospectionSchema(schema);
|
|
312
|
-
return {
|
|
313
|
-
switchboardUrl: sb.switchboardUrl,
|
|
314
|
-
graphqlUrl: sb.graphqlUrl,
|
|
315
|
-
...summary
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
//#endregion
|
|
321
|
-
export { useFolderNodesInSelectedDrive as _, getBrowserSyncManager as a, isFolderNodeKind as b, useSelectedDocument as c, useSelectedDocumentSafe as d, useDocumentOfType as f, useFileNodesInSelectedDrive as g, useDocumentsInSelectedDrive as h, createSwitchboardSchemaTool as i, useSelectedDocumentId as l, useDocumentTypesInSelectedDrive as m, SWITCHBOARD_INTROSPECTION_QUERY as n, resolveDriveSwitchboard as o, useSelectedNode as p, SWITCHBOARD_SCHEMA_TOOL_NAME as r, summarizeIntrospectionSchema as s, GQL_CHANNEL_SUFFIX as t, useSelectedDocumentOfType as u, useNodesInSelectedDrive as v, sortNodesByName as x, isFileNodeKind as y };
|
|
322
|
-
|
|
323
|
-
//# sourceMappingURL=switchboard-CFyD_5_e.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"switchboard-CFyD_5_e.js","names":[],"sources":["../src/utils/nodes.ts","../src/hooks/items-in-selected-drive.ts","../src/hooks/selected-node.ts","../src/hooks/document-of-type.ts","../src/hooks/selected-document.ts","../src/ai/switchboard.ts"],"sourcesContent":["import type {\n FileNode,\n FolderNode,\n Node,\n} from \"@powerhousedao/shared/document-drive\";\n\n/** Sorts nodes by name. */\nexport function sortNodesByName<T extends Node>(nodes: T[]) {\n return nodes.toSorted((a, b) => a.name.localeCompare(b.name));\n}\n\n/** Returns whether a node is a file. */\nexport function isFileNodeKind(\n node: Node | null | undefined,\n): node is FileNode {\n if (!node) return false;\n return node.kind.toUpperCase() === \"FILE\";\n}\n\n/** Returns whether a node is a folder. */\nexport function isFolderNodeKind(\n node: Node | null | undefined,\n): node is FolderNode {\n if (!node) return false;\n return node.kind.toUpperCase() === \"FOLDER\";\n}\n","import type {\n FileNode,\n FolderNode,\n} from \"@powerhousedao/shared/document-drive\";\nimport type {\n DocumentModelDocument,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport { isFileNodeKind, isFolderNodeKind } from \"../utils/nodes.js\";\nimport { useDocumentsByIds } from \"./document-by-id.js\";\nimport { useSelectedDriveSafe } from \"./selected-drive.js\";\n\n/** Returns the nodes in the selected drive. */\nexport function useNodesInSelectedDrive() {\n const [selectedDrive] = useSelectedDriveSafe();\n return selectedDrive?.state.global.nodes;\n}\n\n/** Returns the file nodes in the selected drive. */\nexport function useFileNodesInSelectedDrive(): FileNode[] | undefined {\n const nodes = useNodesInSelectedDrive();\n return nodes?.filter((n) => isFileNodeKind(n));\n}\n\n/** Returns the folder nodes in the selected drive. */\nexport function useFolderNodesInSelectedDrive(): FolderNode[] | undefined {\n const nodes = useNodesInSelectedDrive();\n return nodes?.filter((n) => isFolderNodeKind(n));\n}\n\n/** Returns the documents in the selected drive. */\nexport function useDocumentsInSelectedDrive(): PHDocument[] | undefined {\n const fileNodes = useFileNodesInSelectedDrive();\n const fileNodeIds = fileNodes?.map((node) => node.id);\n return useDocumentsByIds(fileNodeIds);\n}\n\n/** Returns the document types supported by the selected drive, as defined by the document model documents present in the drive */\nexport function useDocumentTypesInSelectedDrive() {\n const documentsInSelectedDrive = useDocumentsInSelectedDrive();\n const documentModelDocumentsInSelectedDrive =\n documentsInSelectedDrive?.filter(isDocumentModelDocument);\n const documentTypesFromDocumentModelDocuments =\n documentModelDocumentsInSelectedDrive?.map((doc) => doc.state.global.id);\n return documentTypesFromDocumentModelDocuments;\n}\n\nfunction isDocumentModelDocument(\n document: PHDocument,\n): document is DocumentModelDocument {\n return document.header.documentType === \"powerhouse/document-model\";\n}\n","import type { Node } from \"@powerhousedao/shared/document-drive\";\nimport { useNodesInSelectedDrive } from \"./items-in-selected-drive.js\";\nimport { useSelectedNodeId } from \"./set-selected-node.js\";\n\nexport {\n addResetSelectedNodeEventHandler,\n addSelectedNodeIdEventHandler,\n addSetSelectedNodeOnPopStateEventHandler,\n setSelectedNode,\n} from \"./set-selected-node.js\";\n\n/** Returns the selected node. */\nexport function useSelectedNode(): Node | undefined {\n const selectedNodeId = useSelectedNodeId();\n const nodes = useNodesInSelectedDrive();\n return nodes?.find((n) => n.id === selectedNodeId);\n}\n","import { ModuleNotFoundError } from \"@powerhousedao/reactor\";\nimport type { DocumentDispatch } from \"@powerhousedao/reactor-browser\";\nimport type { Action, PHDocument } from \"@powerhousedao/shared/document-model\";\nimport { DocumentTypeMismatchError } from \"../errors.js\";\nimport { useDocumentById } from \"./document-by-id.js\";\nimport { useDocumentModelModuleById } from \"./document-model-modules.js\";\n\n/** Returns a document of a specific type, throws an error if the found document has a different type */\nexport function useDocumentOfType<\n TDocument extends PHDocument,\n TAction extends Action,\n>(\n documentId: string | null | undefined,\n documentType: string | null | undefined,\n) {\n const [document, dispatch] = useDocumentById(documentId);\n const documentModelModule = useDocumentModelModuleById(documentType);\n\n if (!documentId || !documentType) return [];\n\n if (!document) {\n throw new Error(`Document not found: ${documentId}`);\n }\n if (!documentModelModule) {\n throw new ModuleNotFoundError(documentType);\n }\n\n if (document.header.documentType !== documentType) {\n throw new DocumentTypeMismatchError(\n documentId,\n documentType,\n document.header.documentType,\n );\n }\n\n return [document, dispatch] as [TDocument, DocumentDispatch<TAction>];\n}\n","import type { DocumentDispatch } from \"@powerhousedao/reactor-browser\";\nimport { isFileNode } from \"@powerhousedao/shared/document-drive\";\nimport type { Action, PHDocument } from \"@powerhousedao/shared/document-model\";\nimport { NoSelectedDocumentError } from \"../errors.js\";\nimport type { DispatchFn, UseDispatchResult } from \"./dispatch.js\";\nimport { useDocumentById } from \"./document-by-id.js\";\nimport { useDocumentOfType } from \"./document-of-type.js\";\nimport { useSelectedNode } from \"./selected-node.js\";\n\n/** Returns the selected document id */\nexport function useSelectedDocumentId(): string | undefined {\n const selectedNode = useSelectedNode();\n return selectedNode && isFileNode(selectedNode) ? selectedNode.id : undefined;\n}\n\n/** Returns the selected document. */\nexport function useSelectedDocument(): readonly [\n PHDocument,\n DispatchFn<Action>,\n] {\n const selectedDocumentId = useSelectedDocumentId();\n const [document, dispatch] = useDocumentById(selectedDocumentId);\n if (!document) {\n throw new NoSelectedDocumentError();\n }\n return [document, dispatch] as const;\n}\n\n/** Returns the selected document. */\nexport function useSelectedDocumentSafe(): UseDispatchResult<\n PHDocument,\n Action\n> {\n const selectedDocumentId = useSelectedDocumentId();\n return useDocumentById(selectedDocumentId);\n}\n\n/** Returns the selected document of a specific type, throws an error if the found document has a different type */\nexport function useSelectedDocumentOfType(\n documentType: null | undefined,\n): never[];\nexport function useSelectedDocumentOfType<\n TDocument extends PHDocument,\n TAction extends Action,\n>(documentType: string): [TDocument, DocumentDispatch<TAction>];\nexport function useSelectedDocumentOfType<\n TDocument extends PHDocument,\n TAction extends Action,\n>(\n documentType: string | null | undefined,\n): never[] | [TDocument, DocumentDispatch<TAction>] {\n const documentId = useSelectedDocumentId();\n\n if (!documentType) {\n return [];\n }\n if (!documentId) {\n throw new NoSelectedDocumentError();\n }\n return useDocumentOfType<TDocument, TAction>(documentId, documentType);\n}\n","import { DriveCollectionId, type ISyncManager } from \"@powerhousedao/reactor\";\nimport { z } from \"zod\";\nimport { ambientRenownTokenProvider } from \"../graphql-client/auth.js\";\nimport type { AiToolDescriptor } from \"./types.js\";\n\n/**\n * The switchboard serving a remote drive: the base URL the browser talks to\n * and its GraphQL supergraph endpoint.\n */\nexport interface DriveSwitchboard {\n /** Switchboard base URL (e.g. `http://localhost:4001`). */\n switchboardUrl: string;\n /** GraphQL supergraph endpoint (`<base>/graphql`). */\n graphqlUrl: string;\n}\n\n/**\n * Reads the tab-side sync manager from the browser global. Returns\n * `undefined` in non-browser environments or before the reactor client\n * module is initialized.\n */\nexport function getBrowserSyncManager(): ISyncManager | undefined {\n if (typeof window === \"undefined\") {\n return undefined;\n }\n return window.ph?.reactorClientModule?.reactorModule?.syncModule?.syncManager;\n}\n\n/** Suffix of the per-drive GraphQL channel endpoint the switchboard serves. */\nexport const GQL_CHANNEL_SUFFIX = \"/graphql/r\";\n\n/**\n * Resolves the switchboard that serves a drive, if any.\n *\n * Every remote drive stores its switchboard's exact GraphQL channel\n * endpoint in its sync remote — `channelConfig = { type: \"gql\",\n * parameters: { url: \"<origin>/graphql/r\" } }` — and the switchboard base\n * is that URL minus the `/graphql/r` suffix. Deriving it per drive (rather\n * than from a global setting) is what keeps multi-switchboard deployments\n * correct. Drives that are not synced to a remote switchboard (local\n * drives, other channel types, unexpected shapes) return `undefined`.\n */\nexport function resolveDriveSwitchboard(\n driveId: string | undefined,\n syncManager?: ISyncManager,\n): DriveSwitchboard | undefined {\n const manager = syncManager ?? getBrowserSyncManager();\n if (!driveId || !manager) {\n return undefined;\n }\n const collectionId = DriveCollectionId.forDrive(driveId);\n const remote = manager\n .list()\n .find((r) => r.meta.collectionId.equals(collectionId));\n if (!remote) {\n return undefined;\n }\n const { channelConfig } = remote.meta;\n if (channelConfig.type !== \"gql\") {\n return undefined;\n }\n const url = channelConfig.parameters.url;\n if (typeof url !== \"string\" || !url.endsWith(GQL_CHANNEL_SUFFIX)) {\n return undefined;\n }\n const switchboardUrl = url.slice(0, -GQL_CHANNEL_SUFFIX.length);\n return { switchboardUrl, graphqlUrl: `${switchboardUrl}/graphql` };\n}\n\n/** A bounded introspected GraphQL type reference (see the query below). */\ntype IntrospectedTypeRef = {\n kind: string;\n name: string | null;\n ofType?: IntrospectedTypeRef | null;\n};\n\ntype IntrospectedField = {\n name: string;\n description: string | null;\n args: Array<{ name: string; type: IntrospectedTypeRef }>;\n type: IntrospectedTypeRef;\n};\n\ntype IntrospectedRootType = {\n fields: IntrospectedField[] | null;\n} | null;\n\ntype IntrospectedSchema = {\n queryType?: IntrospectedRootType;\n mutationType?: IntrospectedRootType;\n};\n\n/**\n * Introspection over the switchboard supergraph's root query and mutation\n * fields. Types are requested with three levels of `ofType` nesting so\n * that common shapes like `[X!]!` (LIST(NON_NULL(LIST(X)))) render fully.\n */\nexport const SWITCHBOARD_INTROSPECTION_QUERY: string = /* GraphQL */ `\n query SwitchboardIntrospection {\n __schema {\n queryType {\n fields {\n name\n description\n args {\n name\n type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n mutationType {\n fields {\n name\n description\n args {\n name\n type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n`;\n\n/**\n * Renders an introspected type reference as a GraphQL type string.\n * Recursion is bounded by the `ofType` nesting of the query, so it always\n * terminates.\n */\nfunction renderTypeRef(type: IntrospectedTypeRef | null | undefined): string {\n if (!type) {\n return \"Unknown\";\n }\n switch (type.kind) {\n case \"NON_NULL\":\n return `${renderTypeRef(type.ofType)}!`;\n case \"LIST\":\n return `[${renderTypeRef(type.ofType)}]`;\n default:\n return type.name ?? \"Unknown\";\n }\n}\n\n/** One root query or mutation field, reduced to a prompt-friendly line. */\nexport type SchemaFieldSummary = {\n name: string;\n description?: string;\n args: string;\n returns: string;\n};\n\n/** Cap on the number of fields reported per root type. */\nconst MAX_FIELDS_PER_ROOT = 200;\n\nfunction summarizeFields(fields: IntrospectedField[] | null | undefined): {\n fields: SchemaFieldSummary[];\n truncated: boolean;\n} {\n const list = fields ?? [];\n return {\n fields: list.slice(0, MAX_FIELDS_PER_ROOT).map((field) => ({\n name: field.name,\n ...(field.description ? { description: field.description } : {}),\n args: field.args\n .map((arg) => `${arg.name}: ${renderTypeRef(arg.type)}`)\n .join(\", \"),\n returns: renderTypeRef(field.type),\n })),\n truncated: list.length > MAX_FIELDS_PER_ROOT,\n };\n}\n\n/**\n * Reduces a GraphQL `__schema` introspection payload (the `data.__schema`\n * object) to a compact summary of its root query and mutation fields.\n * Accepts `unknown` because the payload arrives over the wire.\n */\nexport function summarizeIntrospectionSchema(schema: unknown): {\n queries: SchemaFieldSummary[];\n mutations: SchemaFieldSummary[];\n truncated: boolean;\n} {\n const introspection = (schema ?? {}) as IntrospectedSchema;\n const queries = summarizeFields(introspection.queryType?.fields);\n const mutations = summarizeFields(introspection.mutationType?.fields);\n return {\n queries: queries.fields,\n mutations: mutations.fields,\n truncated: queries.truncated || mutations.truncated,\n };\n}\n\nexport const SWITCHBOARD_SCHEMA_TOOL_NAME = \"getSwitchboardSchema\";\n\n/** Test seams for {@link createSwitchboardSchemaTool}. */\nexport interface SwitchboardToolDeps {\n getSyncManager?: () => ISyncManager | undefined;\n getSelectedDriveId?: () => string | undefined;\n tokenProvider?: () => Promise<string | undefined>;\n fetchImpl?: typeof fetch;\n timeoutMs?: number;\n}\n\n/**\n * Creates the read-only `getSwitchboardSchema` tool: it introspects the\n * GraphQL supergraph of the switchboard serving a drive and returns a\n * summary of its root queries and mutations. It reads the schema only and\n * never modifies data.\n */\nexport function createSwitchboardSchemaTool(\n deps?: SwitchboardToolDeps,\n): AiToolDescriptor {\n const getSyncManager = deps?.getSyncManager ?? getBrowserSyncManager;\n const getSelectedDriveId =\n deps?.getSelectedDriveId ??\n ((): string | undefined =>\n typeof window === \"undefined\" ? undefined : window.ph?.selectedDriveId);\n const tokenProvider = deps?.tokenProvider ?? ambientRenownTokenProvider;\n const fetchImpl = deps?.fetchImpl ?? fetch;\n const timeoutMs = deps?.timeoutMs ?? 10_000;\n\n return {\n name: SWITCHBOARD_SCHEMA_TOOL_NAME,\n description:\n \"Introspect the GraphQL endpoint of the switchboard serving a drive and list the queries and mutations it exposes (reactor operations, document-model read models, package subgraphs). Read-only: it reads the schema only and never modifies data. Omit driveId to introspect the currently selected drive.\",\n inputSchema: {\n driveId: z\n .string()\n .describe(\n \"Drive to introspect. Omit to use the currently selected drive.\",\n )\n .optional(),\n },\n annotations: { readOnlyHint: true },\n callback: async (input: { driveId?: string } | undefined) => {\n const driveId = input?.driveId ?? getSelectedDriveId();\n const sb = resolveDriveSwitchboard(driveId, getSyncManager());\n if (!sb) {\n throw new Error(\n driveId\n ? `Drive \"${driveId}\" has no switchboard: it is not synced to a remote switchboard.`\n : \"No drive is currently selected and no driveId was given.\",\n );\n }\n\n const token = await tokenProvider();\n let response: Response;\n try {\n response = await fetchImpl(sb.graphqlUrl, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(token ? { authorization: `Bearer ${token}` } : {}),\n },\n body: JSON.stringify({ query: SWITCHBOARD_INTROSPECTION_QUERY }),\n signal: AbortSignal.timeout(timeoutMs),\n });\n } catch (error) {\n throw new Error(\n `Switchboard at ${sb.graphqlUrl} is not reachable: ${\n error instanceof Error ? error.message : String(error)\n }`,\n { cause: error },\n );\n }\n\n if (response.status === 401 || response.status === 403) {\n throw new Error(\n `Switchboard at ${sb.graphqlUrl} refused the request (HTTP ${response.status}). Sign in to the switchboard (Renown) and try again.`,\n );\n }\n if (!response.ok) {\n throw new Error(\n `Switchboard introspection failed: HTTP ${response.status} ${response.statusText} from ${sb.graphqlUrl}`,\n );\n }\n\n const body = (await response.json()) as {\n errors?: Array<{ message?: string }>;\n data?: { __schema?: unknown } | null;\n } | null;\n const schemaErrors = body?.errors;\n if (schemaErrors && schemaErrors.length > 0) {\n throw new Error(\n schemaErrors.map((e) => e.message ?? \"unknown error\").join(\"; \"),\n );\n }\n const schema = body?.data?.__schema as\n | IntrospectedSchema\n | null\n | undefined;\n if (!schema?.queryType) {\n throw new Error(\n `Switchboard at ${sb.graphqlUrl} did not return a GraphQL schema.`,\n );\n }\n\n const summary = summarizeIntrospectionSchema(schema);\n return {\n switchboardUrl: sb.switchboardUrl,\n graphqlUrl: sb.graphqlUrl,\n ...summary,\n };\n },\n };\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,gBAAgC,OAAY;CAC1D,OAAO,MAAM,UAAU,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAC9D;;AAGA,SAAgB,eACd,MACkB;CAClB,IAAI,CAAC,MAAM,OAAO;CAClB,OAAO,KAAK,KAAK,YAAY,MAAM;AACrC;;AAGA,SAAgB,iBACd,MACoB;CACpB,IAAI,CAAC,MAAM,OAAO;CAClB,OAAO,KAAK,KAAK,YAAY,MAAM;AACrC;;;;ACZA,SAAgB,0BAA0B;CACxC,MAAM,CAAC,iBAAiB,qBAAqB;CAC7C,OAAO,eAAe,MAAM,OAAO;AACrC;;AAGA,SAAgB,8BAAsD;CAEpE,OADc,wBACH,CAAC,EAAE,QAAQ,MAAM,eAAe,CAAC,CAAC;AAC/C;;AAGA,SAAgB,gCAA0D;CAExE,OADc,wBACH,CAAC,EAAE,QAAQ,MAAM,iBAAiB,CAAC,CAAC;AACjD;;AAGA,SAAgB,8BAAwD;CAEtE,MAAM,cADY,4BACU,CAAC,EAAE,KAAK,SAAS,KAAK,EAAE;CACpD,OAAO,kBAAkB,WAAW;A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,QAAQ,IAAI,CAAC;KACtD;KACA,MAAM,KAAK,UAAU,EAAE,OAAO,gCAAgC,CAAC;KAC/D,QAAQ,YAAY,QAAQ,SAAS;IACvC,CAAC;GACH,SAAS,OAAO;IACd,MAAM,IAAI,MACR,kBAAkB,GAAG,WAAW,qBAC9B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,KAEvD,EAAE,OAAO,MAAM,CACjB;GACF;GAEA,IAAI,SAAS,WAAW,OAAO,SAAS,WAAW,KACjD,MAAM,IAAI,MACR,kBAAkB,GAAG,WAAW,6BAA6B,SAAS,OAAO,sDAC/E;GAEF,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MACR,0CAA0C,SAAS,OAAO,GAAG,SAAS,WAAW,QAAQ,GAAG,YAC9F;GAGF,MAAM,OAAQ,MAAM,SAAS,KAAK;GAIlC,MAAM,eAAe,MAAM;GAC3B,IAAI,gBAAgB,aAAa,SAAS,GACxC,MAAM,IAAI,MACR,aAAa,KAAK,MAAM,EAAE,WAAW,eAAe,CAAC,CAAC,KAAK,IAAI,CACjE;GAEF,MAAM,SAAS,MAAM,MAAM;GAI3B,IAAI,CAAC,QAAQ,WACX,MAAM,IAAI,MACR,kBAAkB,GAAG,WAAW,kCAClC;GAGF,MAAM,UAAU,6BAA6B,MAAM;GACnD,OAAO;IACL,gBAAgB,GAAG;IACnB,YAAY,GAAG;IACf,GAAG;GACL;EACF;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-B7-_l_wE.d.ts","names":[],"sources":["../src/graphql/gen/schema.ts","../src/graphql/constants.ts","../src/graphql/types.ts"],"mappings":";;;KAGY,WAAW,KAAK;KAChB,MAAM;GAAa;QAC5B,WAAW,IAAI,EAAE;KAiBf,8BAA8B;;KAEvB;EACV;IAAM;IAAe;;EACrB;IAAU;IAAe;;EACzB;IAAW;IAAgB;;EAC3B;IAAO;IAAe;;EACtB;IAAS;IAAe;;EACxB;IAAY,gBAAgB;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