@powerhousedao/reactor-browser 6.2.3-dev.95 → 6.2.3-dev.96

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.
Files changed (45) hide show
  1. package/dist/{attachment-service-10Qn5nIw.d.ts → attachment-service-DXfpfp98.d.ts} +4 -3
  2. package/dist/attachment-service-DXfpfp98.d.ts.map +1 -0
  3. package/dist/client-1n_ZUXeu.js +135 -0
  4. package/dist/client-1n_ZUXeu.js.map +1 -0
  5. package/dist/{client-C-NgSjoc.d.ts → client-BFk0MY6A.d.ts} +2 -2
  6. package/dist/client-BFk0MY6A.d.ts.map +1 -0
  7. package/dist/{document-model-modules-ChmfyIxT.js → document-model-modules-BG-61uke.js} +68 -2
  8. package/dist/document-model-modules-BG-61uke.js.map +1 -0
  9. package/dist/{document-operations-QtU34A52.js → document-operations-D5QXcJbV.js} +6 -61
  10. package/dist/document-operations-D5QXcJbV.js.map +1 -0
  11. package/dist/{global-bbfp3_1x.d.ts → global-DAAmZGCO.d.ts} +7 -44
  12. package/dist/global-DAAmZGCO.d.ts.map +1 -0
  13. package/dist/{index-Bfr_cWdi.d.ts → index-Bj1poVfa.d.ts} +2 -2
  14. package/dist/{index-Bfr_cWdi.d.ts.map → index-Bj1poVfa.d.ts.map} +1 -1
  15. package/dist/index.d.ts +78 -8
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +10 -187
  18. package/dist/index.js.map +1 -1
  19. package/dist/{client-BNMyQ_Z2.js → schema-D0G1oAo9.js} +2 -133
  20. package/dist/schema-D0G1oAo9.js.map +1 -0
  21. package/dist/src/ai/index.d.ts +41 -8
  22. package/dist/src/ai/index.d.ts.map +1 -1
  23. package/dist/src/ai/index.js +302 -6
  24. package/dist/src/ai/index.js.map +1 -1
  25. package/dist/src/graphql/client.d.ts +2 -2
  26. package/dist/src/graphql/client.js +1 -1
  27. package/dist/src/graphql-client/entry.d.ts +3 -2
  28. package/dist/src/graphql-client/entry.js +2 -2
  29. package/dist/src/renown/index.d.ts +1 -1
  30. package/dist/switchboard-directory-CWf5SRo7.js +435 -0
  31. package/dist/switchboard-directory-CWf5SRo7.js.map +1 -0
  32. package/dist/switchboards-D-_JBUbF.d.ts +75 -0
  33. package/dist/switchboards-D-_JBUbF.d.ts.map +1 -0
  34. package/dist/{types-CT44EMmw.d.ts → types-CyPDurGV.d.ts} +5 -1
  35. package/dist/types-CyPDurGV.d.ts.map +1 -0
  36. package/package.json +10 -10
  37. package/dist/attachment-service-10Qn5nIw.d.ts.map +0 -1
  38. package/dist/client-BNMyQ_Z2.js.map +0 -1
  39. package/dist/client-C-NgSjoc.d.ts.map +0 -1
  40. package/dist/document-model-modules-ChmfyIxT.js.map +0 -1
  41. package/dist/document-operations-QtU34A52.js.map +0 -1
  42. package/dist/global-bbfp3_1x.d.ts.map +0 -1
  43. package/dist/switchboard-B640iT1L.js +0 -321
  44. package/dist/switchboard-B640iT1L.js.map +0 -1
  45. package/dist/types-CT44EMmw.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { c as ReactorGraphQLClient, l as RunDocumentOptions } from "../../types-CT44EMmw.js";
2
- import { t as createClient } from "../../client-C-NgSjoc.js";
1
+ import { c as ReactorGraphQLClient, l as RunDocumentOptions } from "../../types-CyPDurGV.js";
2
+ import { t as createClient } from "../../client-BFk0MY6A.js";
3
3
  export { type ReactorGraphQLClient, type RunDocumentOptions, createClient };
4
4
  export {};
@@ -1,2 +1,2 @@
1
- import { t as createClient } from "../../client-BNMyQ_Z2.js";
1
+ import { t as createClient } from "../../client-1n_ZUXeu.js";
2
2
  export { createClient };
@@ -1,6 +1,7 @@
1
- import { $ as createJobChangesSocket, $t as GetDocumentQueryFields, At as GraphQLRequestOptions, B as DEFAULT_BREAKER, Bt as switchboardFetch, Ct as GraphQLReactorClientOptions, Dn as IDLE_OPERATIONS_ENTRY, Dt as findIsServableOverGraphQL, Et as createGraphQLDriveNodeSource, F as useDocuments, Ft as subgraphUrlFromGraphqlUrl, G as SwitchboardUnreachableError, Gt as GraphQLWrongBackendError, H as SwitchboardBackend, Ht as withStreamedBodies, I as useGetDocument, It as GraphQLFetch, J as DocumentChangesEventPayload, Jt as queriesUnknownField, K as createSwitchboardBackend, Kt as JobFailedError, L as useGetDocumentAsync, Lt as globalFetch, M as useDocument, Mn as readPromiseState, Mt as SubgraphSdkRegistry, N as useDocumentCache, Nt as TypedGraphQLDocument, Ot as isGraphQLReactorClient, P as useDocumentSafe, Pt as describeGraphQLDocument, Q as JobChangesSocketOptions, Qt as toLegacyNode, R as useGetDocuments, Rt as isDeadlineError, St as GraphQLReactorClient, T as useReactorClient, Tt as ambientRenownSigner, U as SwitchboardBackendDescriptor, Ut as BatchJobFailedError, V as DEFAULT_REQUEST_TIMEOUT_MS, Vt as withRequestDeadline, W as SwitchboardBreaker, Wt as GraphQLOperationNotSupportedError, X as IJobChangesSocket, Xt as GraphQLDriveNodeSource, Y as DocumentChangesSubscriptionOptions, Yt as DriveNodeQueries, Z as JobChangesEventPayload, Zt as GraphQLDriveReadClient, _t as GraphQLReactorProvider, a as DocumentOperationsState, an as revisionMapFromRevisionsList, at as packageFromDocumentModels, b as setReactorClient, bt as useSwitchboardClient, c as useDocumentModelModuleById, ct as signStampedAction, d as UseDispatchResult, dt as GetDocumentAtConsistencyResult, en as GetDocumentQueryResult, et as isAuthRefusalClose, ft as GetDocumentAtConsistencyVariables, gt as ReactorOperationFieldsFragmentDoc, ht as MutateDocumentWithOperationsVariables, i as DocumentOperationsResult, in as phDocumentFromMutation, it as StaticPackageManager, j as setDocumentCache, jn as isOperationCache, jt as SubgraphSdkFactory, kn as addPromiseState, kt as viewFilterInputFromViewFilter, l as useDocumentModelModules, lt as stampAction, mt as MutateDocumentWithOperationsResult, nn as isoStringFromDateTime, nt as startDocumentChangesSubscription, o as UseDocumentOperationsOptions, ot as resolveDocumentModelModule, p as useDispatch, pt as MutateDocumentWithOperationsDocument, q as ConnectionParams, qt as queriesUnknownArgument, r as useAttachmentService, rn as phDocumentFromGetDocument, rt as subscriptionsUrlFromGraphqlUrl, s as useDocumentOperations, st as prepareSignedActions, tn as RevisionsListSelection, tt as makeAuthConnectionParams, u as DispatchFn, ut as GetDocumentAtConsistencyDocument, vt as GraphQLReactorProviderProps, wn as DocumentCache, wt as GraphQLReactorReadClient, xt as DriveIdCall, yt as ensurePHEventHandlers, z as DEFAULT_BATCH_REQUEST_TIMEOUT_MS, zt as isNodeFetch } from "../../attachment-service-10Qn5nIw.js";
1
+ import { $ as createJobChangesSocket, $t as GetDocumentQueryFields, At as GraphQLRequestOptions, B as DEFAULT_BREAKER, Bt as switchboardFetch, Ct as GraphQLReactorClientOptions, Dn as IDLE_OPERATIONS_ENTRY, Dt as findIsServableOverGraphQL, Et as createGraphQLDriveNodeSource, F as useDocuments, Ft as subgraphUrlFromGraphqlUrl, G as SwitchboardUnreachableError, Gt as GraphQLWrongBackendError, H as SwitchboardBackend, Ht as withStreamedBodies, I as useGetDocument, It as GraphQLFetch, J as DocumentChangesEventPayload, Jt as queriesUnknownField, K as createSwitchboardBackend, Kt as JobFailedError, L as useGetDocumentAsync, Lt as globalFetch, M as useDocument, Mn as readPromiseState, Mt as SubgraphSdkRegistry, N as useDocumentCache, Nt as TypedGraphQLDocument, Ot as isGraphQLReactorClient, P as useDocumentSafe, Pt as describeGraphQLDocument, Q as JobChangesSocketOptions, Qt as toLegacyNode, R as useGetDocuments, Rt as isDeadlineError, St as GraphQLReactorClient, T as useReactorClient, Tt as ambientRenownSigner, U as SwitchboardBackendDescriptor, Ut as BatchJobFailedError, V as DEFAULT_REQUEST_TIMEOUT_MS, Vt as withRequestDeadline, W as SwitchboardBreaker, Wt as GraphQLOperationNotSupportedError, X as IJobChangesSocket, Xt as GraphQLDriveNodeSource, Y as DocumentChangesSubscriptionOptions, Yt as DriveNodeQueries, Z as JobChangesEventPayload, Zt as GraphQLDriveReadClient, _t as GraphQLReactorProvider, a as DocumentOperationsState, an as revisionMapFromRevisionsList, at as packageFromDocumentModels, b as setReactorClient, bt as useSwitchboardClient, c as useDocumentModelModuleById, ct as signStampedAction, d as UseDispatchResult, dt as GetDocumentAtConsistencyResult, en as GetDocumentQueryResult, et as isAuthRefusalClose, ft as GetDocumentAtConsistencyVariables, gt as ReactorOperationFieldsFragmentDoc, ht as MutateDocumentWithOperationsVariables, i as DocumentOperationsResult, in as phDocumentFromMutation, it as StaticPackageManager, j as setDocumentCache, jn as isOperationCache, jt as SubgraphSdkFactory, kn as addPromiseState, kt as viewFilterInputFromViewFilter, l as useDocumentModelModules, lt as stampAction, mt as MutateDocumentWithOperationsResult, nn as isoStringFromDateTime, nt as startDocumentChangesSubscription, o as UseDocumentOperationsOptions, ot as resolveDocumentModelModule, p as useDispatch, pt as MutateDocumentWithOperationsDocument, q as ConnectionParams, qt as queriesUnknownArgument, r as useAttachmentService, rn as phDocumentFromGetDocument, rt as subscriptionsUrlFromGraphqlUrl, s as useDocumentOperations, st as prepareSignedActions, tn as RevisionsListSelection, tt as makeAuthConnectionParams, u as DispatchFn, ut as GetDocumentAtConsistencyDocument, vt as GraphQLReactorProviderProps, wn as DocumentCache, wt as GraphQLReactorReadClient, xt as DriveIdCall, yt as ensurePHEventHandlers, z as DEFAULT_BATCH_REQUEST_TIMEOUT_MS, zt as isNodeFetch } from "../../attachment-service-DXfpfp98.js";
2
2
  import { v as SdkFunctionWrapper } from "../../schema-Bn6L3QR1.js";
3
3
  import { n as ambientRenownTokenProvider, r as makeAuthMiddleware, t as BearerTokenProvider } from "../../auth-DzIYxeEJ.js";
4
- import { Jt as OperationsCacheEntry, Lt as IReactorBrowserClient, qt as IOperationCache } from "../../global-bbfp3_1x.js";
4
+ import { Ut as IOperationCache, Wt as OperationsCacheEntry } from "../../global-DAAmZGCO.js";
5
+ import { i as IReactorBrowserClient } from "../../switchboards-D-_JBUbF.js";
5
6
  export { BatchJobFailedError, BearerTokenProvider, ConnectionParams, DEFAULT_BATCH_REQUEST_TIMEOUT_MS, DEFAULT_BREAKER, DEFAULT_REQUEST_TIMEOUT_MS, type DispatchFn, DocumentCache, DocumentChangesEventPayload, DocumentChangesSubscriptionOptions, type DocumentOperationsResult, type DocumentOperationsState, DriveIdCall, DriveNodeQueries, GetDocumentAtConsistencyDocument, GetDocumentAtConsistencyResult, GetDocumentAtConsistencyVariables, GetDocumentQueryFields, GetDocumentQueryResult, GraphQLDriveNodeSource, GraphQLDriveReadClient, GraphQLFetch, GraphQLOperationNotSupportedError, GraphQLReactorClient, GraphQLReactorClientOptions, GraphQLReactorProvider, GraphQLReactorProviderProps, GraphQLReactorReadClient, GraphQLRequestOptions, GraphQLWrongBackendError, IDLE_OPERATIONS_ENTRY, IJobChangesSocket, type IOperationCache, type IReactorBrowserClient, JobChangesEventPayload, JobChangesSocketOptions, JobFailedError, MutateDocumentWithOperationsDocument, MutateDocumentWithOperationsResult, MutateDocumentWithOperationsVariables, type OperationsCacheEntry, ReactorOperationFieldsFragmentDoc, RevisionsListSelection, type SdkFunctionWrapper, StaticPackageManager, SubgraphSdkFactory, SubgraphSdkRegistry, SwitchboardBackend, SwitchboardBackendDescriptor, SwitchboardBreaker, SwitchboardUnreachableError, TypedGraphQLDocument, type UseDispatchResult, type UseDocumentOperationsOptions, addPromiseState, ambientRenownSigner, ambientRenownTokenProvider, createGraphQLDriveNodeSource, createJobChangesSocket, createSwitchboardBackend, describeGraphQLDocument, ensurePHEventHandlers, findIsServableOverGraphQL, globalFetch, isAuthRefusalClose, isDeadlineError, isGraphQLReactorClient, isNodeFetch, isOperationCache, isoStringFromDateTime, makeAuthConnectionParams, makeAuthMiddleware, packageFromDocumentModels, phDocumentFromGetDocument, phDocumentFromMutation, prepareSignedActions, queriesUnknownArgument, queriesUnknownField, readPromiseState, resolveDocumentModelModule, revisionMapFromRevisionsList, setDocumentCache, setReactorClient, signStampedAction, stampAction, startDocumentChangesSubscription, subgraphUrlFromGraphqlUrl, subscriptionsUrlFromGraphqlUrl, switchboardFetch, toLegacyNode, useAttachmentService, useDispatch, useDocument, useDocumentCache, useDocumentModelModuleById, useDocumentModelModules, useDocumentOperations, useDocumentSafe, useDocuments, useGetDocument, useGetDocumentAsync, useGetDocuments, useReactorClient, useSwitchboardClient, viewFilterInputFromViewFilter, withRequestDeadline, withStreamedBodies };
6
7
  export {};
@@ -1,4 +1,4 @@
1
1
  import { a as useDocument, c as useDocuments, d as useGetDocuments, f as DocumentCache, g as addPromiseState, h as IDLE_OPERATIONS_ENTRY, i as setDocumentCache, l as useGetDocument, n as useDispatch, o as useDocumentCache, s as useDocumentSafe, u as useGetDocumentAsync, v as isOperationCache, y as readPromiseState } from "../../dispatch-Cylwl2Dk.js";
2
- import { $ as makeAuthMiddleware, Q as ambientRenownTokenProvider, n as useDocumentModelModules, t as useDocumentModelModuleById } from "../../document-model-modules-ChmfyIxT.js";
3
- import { $r as isGraphQLReactorClient, Ai as phDocumentFromGetDocument, Ci as switchboardFetch, Di as GraphQLDriveReadClient, Ei as GraphQLDriveNodeSource, Gi as GraphQLOperationNotSupportedError, Ji as queriesUnknownArgument, Ki as GraphQLWrongBackendError, Mi as revisionMapFromRevisionsList, Oi as toLegacyNode, Qr as findIsServableOverGraphQL, Si as isNodeFetch, Ti as withStreamedBodies, V as useAttachmentService, Wi as BatchJobFailedError, Xr as ambientRenownSigner, Yi as queriesUnknownField, Yr as GraphQLReactorClient, Zr as createGraphQLDriveNodeSource, _i as ReactorOperationFieldsFragmentDoc, a as SwitchboardUnreachableError, ai as subscriptionsUrlFromGraphqlUrl, bi as globalFetch, c as ensurePHEventHandlers, ci as subgraphUrlFromGraphqlUrl, di as resolveDocumentModelModule, ei as viewFilterInputFromViewFilter, fi as prepareSignedActions, gi as MutateDocumentWithOperationsDocument, hi as GetDocumentAtConsistencyDocument, i as DEFAULT_REQUEST_TIMEOUT_MS, ii as startDocumentChangesSubscription, ji as phDocumentFromMutation, ki as isoStringFromDateTime, l as useSwitchboardClient, li as StaticPackageManager, mi as stampAction, n as DEFAULT_BATCH_REQUEST_TIMEOUT_MS, ni as isAuthRefusalClose, o as createSwitchboardBackend, oi as SubgraphSdkRegistry, pi as signStampedAction, qi as JobFailedError, r as DEFAULT_BREAKER, ri as makeAuthConnectionParams, s as GraphQLReactorProvider, si as describeGraphQLDocument, t as useDocumentOperations, ti as createJobChangesSocket, ui as packageFromDocumentModels, wa as useReactorClient, wi as withRequestDeadline, xi as isDeadlineError, ya as setReactorClient } from "../../document-operations-QtU34A52.js";
2
+ import { K as setReactorClient, Z as useReactorClient, _t as ambientRenownTokenProvider, n as useDocumentModelModules, t as useDocumentModelModuleById, vt as makeAuthMiddleware } from "../../document-model-modules-BG-61uke.js";
3
+ import { $r as isGraphQLReactorClient, Ai as phDocumentFromGetDocument, Ci as switchboardFetch, Di as GraphQLDriveReadClient, Ei as GraphQLDriveNodeSource, Gi as GraphQLOperationNotSupportedError, Ji as queriesUnknownArgument, Ki as GraphQLWrongBackendError, Mi as revisionMapFromRevisionsList, Oi as toLegacyNode, Qr as findIsServableOverGraphQL, Si as isNodeFetch, Ti as withStreamedBodies, V as useAttachmentService, Wi as BatchJobFailedError, Xr as ambientRenownSigner, Yi as queriesUnknownField, Yr as GraphQLReactorClient, Zr as createGraphQLDriveNodeSource, _i as ReactorOperationFieldsFragmentDoc, a as SwitchboardUnreachableError, ai as subscriptionsUrlFromGraphqlUrl, bi as globalFetch, c as ensurePHEventHandlers, ci as subgraphUrlFromGraphqlUrl, di as resolveDocumentModelModule, ei as viewFilterInputFromViewFilter, fi as prepareSignedActions, gi as MutateDocumentWithOperationsDocument, hi as GetDocumentAtConsistencyDocument, i as DEFAULT_REQUEST_TIMEOUT_MS, ii as startDocumentChangesSubscription, ji as phDocumentFromMutation, ki as isoStringFromDateTime, l as useSwitchboardClient, li as StaticPackageManager, mi as stampAction, n as DEFAULT_BATCH_REQUEST_TIMEOUT_MS, ni as isAuthRefusalClose, o as createSwitchboardBackend, oi as SubgraphSdkRegistry, pi as signStampedAction, qi as JobFailedError, r as DEFAULT_BREAKER, ri as makeAuthConnectionParams, s as GraphQLReactorProvider, si as describeGraphQLDocument, t as useDocumentOperations, ti as createJobChangesSocket, ui as packageFromDocumentModels, wi as withRequestDeadline, xi as isDeadlineError } from "../../document-operations-D5QXcJbV.js";
4
4
  export { BatchJobFailedError, DEFAULT_BATCH_REQUEST_TIMEOUT_MS, DEFAULT_BREAKER, DEFAULT_REQUEST_TIMEOUT_MS, DocumentCache, GetDocumentAtConsistencyDocument, GraphQLDriveNodeSource, GraphQLDriveReadClient, GraphQLOperationNotSupportedError, GraphQLReactorClient, GraphQLReactorProvider, GraphQLWrongBackendError, IDLE_OPERATIONS_ENTRY, JobFailedError, MutateDocumentWithOperationsDocument, ReactorOperationFieldsFragmentDoc, StaticPackageManager, SubgraphSdkRegistry, SwitchboardUnreachableError, addPromiseState, ambientRenownSigner, ambientRenownTokenProvider, createGraphQLDriveNodeSource, createJobChangesSocket, createSwitchboardBackend, describeGraphQLDocument, ensurePHEventHandlers, findIsServableOverGraphQL, globalFetch, isAuthRefusalClose, isDeadlineError, isGraphQLReactorClient, isNodeFetch, isOperationCache, isoStringFromDateTime, makeAuthConnectionParams, makeAuthMiddleware, packageFromDocumentModels, phDocumentFromGetDocument, phDocumentFromMutation, prepareSignedActions, queriesUnknownArgument, queriesUnknownField, readPromiseState, resolveDocumentModelModule, revisionMapFromRevisionsList, setDocumentCache, setReactorClient, signStampedAction, stampAction, startDocumentChangesSubscription, subgraphUrlFromGraphqlUrl, subscriptionsUrlFromGraphqlUrl, switchboardFetch, toLegacyNode, useAttachmentService, useDispatch, useDocument, useDocumentCache, useDocumentModelModuleById, useDocumentModelModules, useDocumentOperations, useDocumentSafe, useDocuments, useGetDocument, useGetDocumentAsync, useGetDocuments, useReactorClient, useSwitchboardClient, viewFilterInputFromViewFilter, withRequestDeadline, withStreamedBodies };
@@ -1,3 +1,3 @@
1
- import { A as DOMAIN_TYPE, B as CopyIcon, C as RenownInitialUserProvider, D as CREDENTIAL_SCHEMA_EIP712_TYPE, E as useRenownInitialUser, F as RENOWN_URL, G as RenownUserButton, H as RenownLogo, I as VERIFIABLE_CREDENTIAL_EIP712_TYPE, J as RenownLoginButton, K as RenownUserButtonMenuItem, L as initConnectCrypto, M as RENOWN_CHAIN_ID, N as RENOWN_NETWORK_ID, O as CREDENTIAL_SUBJECT_TYPE, P as RENOWN_RETURN_URL_STRIPPED_PARAMS, R as initRenownCrypto, S as RenownInitialAuth, T as useRenownInitialAuth, U as SpinnerIcon, V as DisconnectIcon, W as UserIcon, X as RenownAuthButton, Y as RenownLoginButtonProps, Z as RenownAuthButtonProps, _ as RenownSessionCookieState, a as useRenownWalletAdapter, at as desktopShell, b as RENOWN_INITIAL_ANONYMOUS, c as RenownWalletProvider, ct as openRenown, d as RenownProviderProps, dt as RenownAuthResolution, f as Renown, ft as RenownAuthStatus, g as RenownSessionCookieOptions, h as useRenownInit, i as decodeDelegation, it as DesktopShell, j as ISSUER_TYPE, k as CREDENTIAL_TYPES, l as RenownWalletProviderProps, lt as RenownAuth, m as RenownInitOptions, mt as useRenownAuthAsync, n as DelegationScope, nt as useRenown, o as RenownLoginMethod, p as RenownProps, pt as useRenownAuth, q as RenownUserButtonProps, r as createDelegation, s as useRenownLoginMethods, t as DelegationClaims, u as RenownProvider, ut as RenownAuthAsync, v as useRenownSessionCookie, w as RenownInitialUserProviderProps, x as RENOWN_INITIAL_UNKNOWN, y as useRenownSessionSynced, z as ChevronDownIcon } from "../../index-Bfr_cWdi.js";
1
+ import { A as DOMAIN_TYPE, B as CopyIcon, C as RenownInitialUserProvider, D as CREDENTIAL_SCHEMA_EIP712_TYPE, E as useRenownInitialUser, F as RENOWN_URL, G as RenownUserButton, H as RenownLogo, I as VERIFIABLE_CREDENTIAL_EIP712_TYPE, J as RenownLoginButton, K as RenownUserButtonMenuItem, L as initConnectCrypto, M as RENOWN_CHAIN_ID, N as RENOWN_NETWORK_ID, O as CREDENTIAL_SUBJECT_TYPE, P as RENOWN_RETURN_URL_STRIPPED_PARAMS, R as initRenownCrypto, S as RenownInitialAuth, T as useRenownInitialAuth, U as SpinnerIcon, V as DisconnectIcon, W as UserIcon, X as RenownAuthButton, Y as RenownLoginButtonProps, Z as RenownAuthButtonProps, _ as RenownSessionCookieState, a as useRenownWalletAdapter, at as desktopShell, b as RENOWN_INITIAL_ANONYMOUS, c as RenownWalletProvider, ct as openRenown, d as RenownProviderProps, dt as RenownAuthResolution, f as Renown, ft as RenownAuthStatus, g as RenownSessionCookieOptions, h as useRenownInit, i as decodeDelegation, it as DesktopShell, j as ISSUER_TYPE, k as CREDENTIAL_TYPES, l as RenownWalletProviderProps, lt as RenownAuth, m as RenownInitOptions, mt as useRenownAuthAsync, n as DelegationScope, nt as useRenown, o as RenownLoginMethod, p as RenownProps, pt as useRenownAuth, q as RenownUserButtonProps, r as createDelegation, s as useRenownLoginMethods, t as DelegationClaims, u as RenownProvider, ut as RenownAuthAsync, v as useRenownSessionCookie, w as RenownInitialUserProviderProps, x as RENOWN_INITIAL_UNKNOWN, y as useRenownSessionSynced, z as ChevronDownIcon } from "../../index-Bj1poVfa.js";
2
2
  export { CREDENTIAL_SCHEMA_EIP712_TYPE, CREDENTIAL_SUBJECT_TYPE, CREDENTIAL_TYPES, ChevronDownIcon, CopyIcon, DOMAIN_TYPE, type DelegationClaims, type DelegationScope, type DesktopShell, DisconnectIcon, ISSUER_TYPE, RENOWN_CHAIN_ID, RENOWN_INITIAL_ANONYMOUS, RENOWN_INITIAL_UNKNOWN, RENOWN_NETWORK_ID, RENOWN_RETURN_URL_STRIPPED_PARAMS, RENOWN_URL, Renown, type RenownAuth, type RenownAuthAsync, RenownAuthButton, type RenownAuthButtonProps, type RenownAuthResolution, type RenownAuthStatus, type RenownInitOptions, type RenownInitialAuth, RenownInitialUserProvider, type RenownInitialUserProviderProps, RenownLoginButton, type RenownLoginButtonProps, type RenownLoginMethod, RenownLogo, type RenownProps, RenownProvider, type RenownProviderProps, type RenownSessionCookieOptions, type RenownSessionCookieState, RenownUserButton, type RenownUserButtonMenuItem, type RenownUserButtonProps, RenownWalletProvider, type RenownWalletProviderProps, SpinnerIcon, UserIcon, VERIFIABLE_CREDENTIAL_EIP712_TYPE, createDelegation, decodeDelegation, desktopShell, initConnectCrypto, initRenownCrypto, openRenown, useRenown, useRenownAuth, useRenownAuthAsync, useRenownInit, useRenownInitialAuth, useRenownInitialUser, useRenownLoginMethods, useRenownSessionCookie, useRenownSessionSynced, useRenownWalletAdapter };
3
3
  export {};
@@ -0,0 +1,435 @@
1
+ import { M as NoSelectedDocumentError, j as DocumentTypeMismatchError } from "./dispatch-Cylwl2Dk.js";
2
+ import { L as useDriveContext, j as useSelectedNodeId, t as useDocumentModelModuleById, ut as useDriveNode, v as useSelectedDriveId } from "./document-model-modules-BG-61uke.js";
3
+ import { i as GetDocumentWithOperationsDocument } from "./schema-D0G1oAo9.js";
4
+ import { t as useDocumentById } from "./document-by-id-DdvqanGR.js";
5
+ import { createContext, useContext, useMemo } from "react";
6
+ import { jsx } from "react/jsx-runtime";
7
+ import { DriveCollectionId, ModuleNotFoundError } from "@powerhousedao/reactor";
8
+ import { pascalCase } from "change-case";
9
+ import { isFileNode } from "@powerhousedao/shared/document-drive";
10
+ import { Kind, parse } from "graphql";
11
+ import lzString from "lz-string";
12
+ import { ORIGIN_PLACEHOLDER } from "@powerhousedao/shared/connect/origin-placeholder";
13
+ import { switchboardOfDrive } from "@powerhousedao/shared/host-tokens";
14
+ //#region src/hooks/node-by-id.ts
15
+ /** Returns a node in the selected drive by id. */
16
+ function useNodeById(id) {
17
+ return useDriveNode(useSelectedDriveId(), id);
18
+ }
19
+ //#endregion
20
+ //#region src/hooks/selected-node.ts
21
+ /** Returns the selected node. */
22
+ function useSelectedNode() {
23
+ return useNodeById(useSelectedNodeId());
24
+ }
25
+ //#endregion
26
+ //#region src/hooks/document-of-type.ts
27
+ /** Returns a document of a specific type, throws an error if the found document has a different type */
28
+ function useDocumentOfType(documentId, documentType) {
29
+ const [document, dispatch] = useDocumentById(documentId);
30
+ const documentModelModule = useDocumentModelModuleById(documentType);
31
+ if (!documentId || !documentType) return [];
32
+ if (!document) throw new Error(`Document not found: ${documentId}`);
33
+ if (!documentModelModule) throw new ModuleNotFoundError(documentType);
34
+ if (document.header.documentType !== documentType) throw new DocumentTypeMismatchError(documentId, documentType, document.header.documentType);
35
+ return [document, dispatch];
36
+ }
37
+ //#endregion
38
+ //#region src/hooks/editor-context.tsx
39
+ const EditorDocumentContext = createContext(void 0);
40
+ /** Hosts render an editor inside this, with the same `document` and `dispatch`
41
+ * as its props; `useSelected*Document` hooks below read them. */
42
+ function EditorDocumentProvider(props) {
43
+ const { document, dispatch } = props;
44
+ const value = useMemo(() => [document, dispatch], [document, dispatch]);
45
+ return /* @__PURE__ */ jsx(EditorDocumentContext.Provider, {
46
+ value,
47
+ children: props.children
48
+ });
49
+ }
50
+ /** The nearest editor's document and dispatch, or undefined outside one. */
51
+ function useEditorDocumentContext() {
52
+ return useContext(EditorDocumentContext);
53
+ }
54
+ //#endregion
55
+ //#region src/hooks/selected-document.ts
56
+ /** Returns the selected document id: the editor's document, else the drive
57
+ * app's open document, else the app's selection. */
58
+ function useSelectedDocumentId() {
59
+ const editor = useEditorDocumentContext();
60
+ const drive = useDriveContext();
61
+ const selectedNode = useSelectedNode();
62
+ if (editor) return editor[0].header.id;
63
+ if (drive?.nodeId && !drive.folder) return selectedNode && !isFileNode(selectedNode) ? void 0 : drive.nodeId;
64
+ return selectedNode && isFileNode(selectedNode) ? selectedNode.id : void 0;
65
+ }
66
+ /** Returns the selected document. */
67
+ function useSelectedDocument() {
68
+ const [document, dispatch] = useSelectedDocumentSafe();
69
+ if (!document) throw new NoSelectedDocumentError();
70
+ return [document, dispatch];
71
+ }
72
+ /** Returns the selected document: the editor's, else the app's selection. */
73
+ function useSelectedDocumentSafe() {
74
+ const editor = useEditorDocumentContext();
75
+ const selectedDocumentId = useSelectedDocumentId();
76
+ const selected = useDocumentById(editor ? null : selectedDocumentId);
77
+ return editor ?? selected;
78
+ }
79
+ function useSelectedDocumentOfType(documentType) {
80
+ const editor = useEditorDocumentContext();
81
+ const documentId = useSelectedDocumentId();
82
+ const result = useDocumentOfType(documentType && !editor ? documentId : null, documentType);
83
+ const documentModelModule = useDocumentModelModuleById(documentType);
84
+ if (!documentType) return [];
85
+ if (editor) {
86
+ const [document, dispatch] = editor;
87
+ if (!documentModelModule) throw new ModuleNotFoundError(documentType);
88
+ if (document.header.documentType !== documentType) throw new DocumentTypeMismatchError(document.header.id, documentType, document.header.documentType);
89
+ return [document, dispatch];
90
+ }
91
+ if (!documentId) throw new NoSelectedDocumentError();
92
+ return result;
93
+ }
94
+ //#endregion
95
+ //#region src/utils/gql-channel.ts
96
+ /** Suffix of the per-drive GraphQL channel endpoint the switchboard serves. */
97
+ const GQL_CHANNEL_SUFFIX = "/graphql/r";
98
+ //#endregion
99
+ //#region src/utils/switchboard.ts
100
+ async function getDriveIdBySlug(driveUrl, slug) {
101
+ if (!driveUrl) return;
102
+ const urlParts = driveUrl.split("/");
103
+ urlParts.pop();
104
+ urlParts.pop();
105
+ urlParts.push("drives");
106
+ const drivesUrl = urlParts.join("/");
107
+ return (await (await fetch(drivesUrl, {
108
+ method: "POST",
109
+ headers: { "Content-Type": "application/json" },
110
+ body: JSON.stringify({
111
+ query: `
112
+ query getDriveIdBySlug($slug: String!) {
113
+ driveIdBySlug(slug: $slug)
114
+ }
115
+ `,
116
+ variables: { slug }
117
+ })
118
+ })).json()).data.driveIdBySlug;
119
+ }
120
+ function getSlugFromDriveUrl(driveUrl) {
121
+ return driveUrl.split("/").pop();
122
+ }
123
+ function getSwitchboardGatewayUrlFromDriveUrl(driveUrl) {
124
+ const urlParts = driveUrl.split("/");
125
+ urlParts.pop();
126
+ urlParts.pop();
127
+ urlParts.push("graphql");
128
+ return urlParts.join("/");
129
+ }
130
+ function getDocumentGraphqlQuery() {
131
+ const loc = GetDocumentWithOperationsDocument.loc;
132
+ if (!loc) throw new Error("GetDocumentWithOperationsDocument is misconfigured, loc is missing.");
133
+ return loc.source.body;
134
+ }
135
+ /**
136
+ * The base URL of the switchboard that serves a drive's GraphQL channel.
137
+ *
138
+ * The channel URL is `<origin>[<proxy-prefix>]/graphql/r`, so stripping the
139
+ * suffix preserves any proxy prefix (e.g. `/api/reactor`). A URL that does
140
+ * not end with the suffix is unexpected — fall back to its origin.
141
+ */
142
+ function getSwitchboardBaseFromChannelUrl(channelUrl) {
143
+ if (channelUrl.endsWith("/graphql/r")) return channelUrl.slice(0, -10);
144
+ return new URL(channelUrl).origin;
145
+ }
146
+ /**
147
+ * The GraphQL name the switchboard exposes a document model under. Mirrors
148
+ * `getDocumentModelSchemaName` on the server (`model-schema-templates.ts`): the root
149
+ * query field and the state type names are all derived from the model's
150
+ * `global.name`.
151
+ */
152
+ function getDocumentModelSchemaName(model) {
153
+ return pascalCase(model.documentModel.global.name.replaceAll("/", " "));
154
+ }
155
+ function buildStateTypeMap(definitions) {
156
+ const typeMap = /* @__PURE__ */ new Map();
157
+ for (const def of definitions) if (def.kind === Kind.OBJECT_TYPE_DEFINITION || def.kind === Kind.INTERFACE_TYPE_DEFINITION || def.kind === Kind.UNION_TYPE_DEFINITION) typeMap.set(def.name.value, def);
158
+ return typeMap;
159
+ }
160
+ /**
161
+ * Recursively expands the fields of a state object type into a GraphQL
162
+ * selection. Objects expand their sub-selection (lists expand their item
163
+ * type); enums, scalars, and built-ins are leaves.
164
+ */
165
+ function expandStateFields(typeDef, typeMap) {
166
+ if (typeDef.kind !== Kind.OBJECT_TYPE_DEFINITION) throw new Error(`Abstract state type requires the generic document query: ${typeDef.name.value}`);
167
+ return (typeDef.fields ?? []).map((field) => {
168
+ const fieldName = field.name.value;
169
+ let typeNode = field.type;
170
+ if (typeNode.kind === Kind.NON_NULL_TYPE) typeNode = typeNode.type;
171
+ if (typeNode.kind === Kind.LIST_TYPE) {
172
+ let itemType = typeNode.type;
173
+ if (itemType.kind === Kind.NON_NULL_TYPE) itemType = itemType.type;
174
+ if (itemType.kind === Kind.LIST_TYPE) throw new Error(`Nested lists are not supported in state selections: ${fieldName}`);
175
+ if (itemType.kind !== Kind.NAMED_TYPE) return fieldName;
176
+ const itemTypeDef = typeMap.get(itemType.name.value);
177
+ if (!itemTypeDef) return fieldName;
178
+ return `${fieldName} { ${expandStateFields(itemTypeDef, typeMap)} }`;
179
+ }
180
+ if (typeNode.kind !== Kind.NAMED_TYPE) return fieldName;
181
+ const typeDef = typeMap.get(typeNode.name.value);
182
+ if (!typeDef) return fieldName;
183
+ return `${fieldName} { ${expandStateFields(typeDef, typeMap)} }`;
184
+ }).join(" ");
185
+ }
186
+ /**
187
+ * Finds the root state object type in a state SDL. Root state types follow
188
+ * the `<Name>State` / `<Name>GlobalState` conventions, and are defined last
189
+ * by convention — the same resolution order the server uses
190
+ * (`extractRootTypeName` in `create-schema.ts`).
191
+ */
192
+ function findRootStateType(definitions, candidates) {
193
+ let lastObjectType = null;
194
+ for (const def of definitions) {
195
+ if (def.kind !== Kind.OBJECT_TYPE_DEFINITION) continue;
196
+ if (candidates.includes(def.name.value)) return def;
197
+ lastObjectType = def;
198
+ }
199
+ if (!lastObjectType) throw new Error("No root state type found in the document model schema");
200
+ return lastObjectType;
201
+ }
202
+ /**
203
+ * Derives the subselection for the document's `global` state scope from the
204
+ * model's state SDL (e.g. `name total`), expanding object fields
205
+ * recursively. Throws when the schema is missing, unparseable, or has no
206
+ * root object type — the caller falls back to the generic document query.
207
+ */
208
+ function getDocumentStateSelection(model) {
209
+ const schema = model.documentModel.global.specifications.at(-1)?.state.global.schema;
210
+ if (!schema || !schema.trim()) throw new Error("Document model has no global state schema");
211
+ const ast = parse(schema);
212
+ const typeMap = buildStateTypeMap(ast.definitions);
213
+ const documentName = getDocumentModelSchemaName(model);
214
+ return expandStateFields(findRootStateType(ast.definitions, [`${documentName}State`, `${documentName}GlobalState`]), typeMap);
215
+ }
216
+ function getLocalStateSelection(localSchema, documentName) {
217
+ const ast = parse(localSchema);
218
+ const typeMap = buildStateTypeMap(ast.definitions);
219
+ return expandStateFields(findRootStateType(ast.definitions, [`${documentName}LocalState`]), typeMap);
220
+ }
221
+ /**
222
+ * Builds a query scoped to a document type's own subgraph root field,
223
+ * selecting the document and its full typed state. The shape mirrors what
224
+ * the switchboard generates per model (`generateNewApiSchema` in
225
+ * `model-schema-templates.ts`): `<Name> { document(identifier:) { document { ...
226
+ * state { auth document global local } } } childIds }`.
227
+ */
228
+ function buildModelScopedQuery(model) {
229
+ const globalState = model.documentModel.global;
230
+ const documentName = getDocumentModelSchemaName(model);
231
+ const globalSelection = getDocumentStateSelection(model);
232
+ const localSchema = globalState.specifications.at(-1)?.state.local.schema ?? "";
233
+ const localSelection = localSchema.includes(`type ${documentName}LocalState`) ? getLocalStateSelection(localSchema, documentName) : null;
234
+ return [
235
+ "query GetDocument($identifier: String!) {",
236
+ ` ${documentName} {`,
237
+ " document(identifier: $identifier) {",
238
+ " document {",
239
+ " id",
240
+ " name",
241
+ " documentType",
242
+ " state {",
243
+ " auth",
244
+ " document { version hash { algorithm encoding } isDeleted deletedAtUtcIso deletedBy deletionReason }",
245
+ ` global { ${globalSelection} }`,
246
+ ` ${localSelection ? `local { ${localSelection} }` : "local"}`,
247
+ " }",
248
+ " }",
249
+ " childIds",
250
+ " }",
251
+ " }",
252
+ "}"
253
+ ].join("\n");
254
+ }
255
+ function buildDocumentSubgraphQuery(documentType, identifier, model, authToken) {
256
+ let query;
257
+ if (model && model.documentModel.global.id === documentType) try {
258
+ query = buildModelScopedQuery(model);
259
+ } catch (error) {
260
+ console.warn("Could not derive a document-scoped query from the document model, falling back to the generic document query:", error);
261
+ query = getDocumentGraphqlQuery();
262
+ }
263
+ else query = getDocumentGraphqlQuery();
264
+ const variables = { identifier };
265
+ const headers = authToken ? { Authorization: `Bearer ${authToken}` } : void 0;
266
+ const payload = {
267
+ document: query.trim(),
268
+ variables: JSON.stringify(variables, null, 2)
269
+ };
270
+ if (headers) payload.headers = JSON.stringify(headers);
271
+ return lzString.compressToEncodedURIComponent(JSON.stringify(payload));
272
+ }
273
+ function buildDocumentSubgraphUrl(channelUrl, documentType, identifier, model, authToken) {
274
+ const encodedQuery = buildDocumentSubgraphQuery(documentType, identifier, model, authToken);
275
+ return `${getSwitchboardBaseFromChannelUrl(channelUrl)}/explorer?explorerURLState=${encodedQuery}`;
276
+ }
277
+ //#endregion
278
+ //#region src/utils/switchboard-directory.ts
279
+ /** `${origin}` resolved against the page; a base stays as it is otherwise. */
280
+ function resolveOrigin(base, origin) {
281
+ if (!base.startsWith(ORIGIN_PLACEHOLDER)) return base;
282
+ const page = origin ?? (typeof location === "undefined" ? void 0 : location.origin);
283
+ return page ? page + base.slice(ORIGIN_PLACEHOLDER.length) : base;
284
+ }
285
+ function trimSlash(url) {
286
+ return url.replace(/\/+$/, "");
287
+ }
288
+ /** A synced drive's switchboard, named by its host and path. */
289
+ function syncName(base) {
290
+ return base.replace(/^[a-z]+:\/\//i, "");
291
+ }
292
+ /**
293
+ * Builds the directory from the host's remote backends and the tab's synced
294
+ * drives. A backend's facts are read on each `list`, so a refresh shows.
295
+ */
296
+ function createSwitchboardDirectory(options) {
297
+ const backends = (options.remoteBackends ?? []).flatMap(({ name, url }) => {
298
+ const drive = switchboardOfDrive(url);
299
+ if (!drive) return [];
300
+ return [{
301
+ name,
302
+ base: trimSlash(resolveOrigin(drive.base, options.origin))
303
+ }];
304
+ });
305
+ const workflowsOf = (name) => {
306
+ const backend = options.router?.backends.find((b) => b.name === name);
307
+ if (!backend?.facts.known) return "unknown";
308
+ return backend.facts.reactor.workflows;
309
+ };
310
+ const remotes = () => {
311
+ try {
312
+ return options.syncManager?.()?.list() ?? [];
313
+ } catch {
314
+ return [];
315
+ }
316
+ };
317
+ const syncBase = (remote) => {
318
+ const { channelConfig } = remote.meta;
319
+ const url = channelConfig.type === "gql" ? channelConfig.parameters.url : "";
320
+ if (typeof url !== "string" || !url) return void 0;
321
+ try {
322
+ return trimSlash(getSwitchboardBaseFromChannelUrl(url));
323
+ } catch {
324
+ return;
325
+ }
326
+ };
327
+ const list = () => {
328
+ const entries = backends.map(({ name, base }) => ({
329
+ name,
330
+ base,
331
+ graphqlUrl: `${base}/graphql`,
332
+ via: "backend",
333
+ workflows: workflowsOf(name)
334
+ }));
335
+ const seen = new Set(entries.map((entry) => entry.base));
336
+ for (const remote of remotes()) {
337
+ const base = syncBase(remote);
338
+ if (!base || seen.has(base)) continue;
339
+ seen.add(base);
340
+ entries.push({
341
+ name: syncName(base),
342
+ base,
343
+ graphqlUrl: `${base}/graphql`,
344
+ via: "sync",
345
+ workflows: "unknown"
346
+ });
347
+ }
348
+ return entries;
349
+ };
350
+ const locate = async (documentId, signal) => {
351
+ const entries = list();
352
+ const collectionId = DriveCollectionId.forDrive(documentId);
353
+ const remote = remotes().find((r) => r.meta.collectionId.equals(collectionId));
354
+ const synced = remote && syncBase(remote);
355
+ if (synced) return entries.find((entry) => entry.base === synced);
356
+ if (!options.router || backends.length === 0) return void 0;
357
+ let name;
358
+ try {
359
+ name = await options.router.locate(documentId, signal);
360
+ } catch (error) {
361
+ if (signal?.aborted) throw error;
362
+ return;
363
+ }
364
+ return entries.find((entry) => entry.via === "backend" && entry.name === name);
365
+ };
366
+ return {
367
+ list,
368
+ locate
369
+ };
370
+ }
371
+ /** Why no switchboard could be picked, with the ones there are. */
372
+ var SwitchboardLookupError = class extends Error {
373
+ code;
374
+ switchboards;
375
+ constructor(message, code, switchboards = []) {
376
+ super(message);
377
+ this.code = code;
378
+ this.switchboards = switchboards;
379
+ this.name = "SwitchboardLookupError";
380
+ }
381
+ };
382
+ function describe(entry) {
383
+ const workflows = entry.workflows === "unknown" ? "workflows unknown" : entry.workflows ? "runs workflows" : "no workflows";
384
+ return `${entry.name} (${entry.base}, ${workflows})`;
385
+ }
386
+ function describeAll(entries) {
387
+ return entries.map(describe).join("; ");
388
+ }
389
+ /** The entry `switchboard` names: by name, then by the longest base it lies under. */
390
+ function byNameOrUrl(entries, switchboard) {
391
+ const named = entries.find((entry) => entry.name === switchboard);
392
+ if (named) return named;
393
+ const url = trimSlash(switchboard);
394
+ return entries.filter((entry) => url === entry.base || url.startsWith(`${entry.base}/`)).sort((a, b) => b.base.length - a.base.length)[0];
395
+ }
396
+ function checkNeed(entry, need, entries) {
397
+ if (need === "workflows" && entry.workflows === false) throw new SwitchboardLookupError(`Switchboard ${entry.name} (${entry.base}) runs no workflow runtime.`, "NO_WORKFLOW_RUNTIME", entries);
398
+ return entry;
399
+ }
400
+ /**
401
+ * The switchboard a call goes to: the one named, else the one serving the
402
+ * document, else the only one there is (or the only one running what `need`
403
+ * asks for). Throws a {@link SwitchboardLookupError} that lists the
404
+ * switchboards whenever it can't pick one; there is no default URL.
405
+ */
406
+ async function resolveSwitchboard(directory, request = {}) {
407
+ if (!directory) throw new SwitchboardLookupError("This app provides no switchboard directory, so no switchboard can be picked.", "NO_DIRECTORY");
408
+ const entries = directory.list();
409
+ const { need } = request;
410
+ if (request.switchboard) {
411
+ const named = byNameOrUrl(entries, request.switchboard);
412
+ if (!named) throw new SwitchboardLookupError(entries.length > 0 ? `No switchboard "${request.switchboard}". This app reaches: ${describeAll(entries)}.` : `No switchboard "${request.switchboard}": this app reaches no switchboard.`, "UNKNOWN_SWITCHBOARD", entries);
413
+ return checkNeed(named, need, entries);
414
+ }
415
+ if (request.documentId && entries.length > 1) {
416
+ const located = await directory.locate(request.documentId, request.signal);
417
+ if (located) return checkNeed(located, need, entries);
418
+ }
419
+ if (entries.length === 0) throw new SwitchboardLookupError("This app reaches no switchboard; it is connected to none.", "NO_SWITCHBOARD");
420
+ if (entries.length === 1) return checkNeed(entries[0], need, entries);
421
+ if (need === "workflows") {
422
+ const running = entries.filter((entry) => entry.workflows === true);
423
+ if (running.length === 1) return running[0];
424
+ if (running.length === 0) {
425
+ const maybe = entries.filter((entry) => entry.workflows === "unknown");
426
+ if (maybe.length === 1) return maybe[0];
427
+ if (maybe.length === 0) throw new SwitchboardLookupError(`None of the switchboards runs a workflow runtime: ${describeAll(entries)}.`, "NO_WORKFLOW_RUNTIME", entries);
428
+ }
429
+ }
430
+ throw new SwitchboardLookupError(`This app reaches several switchboards (${describeAll(entries)}); name one with "switchboard".`, "AMBIGUOUS_SWITCHBOARD", entries);
431
+ }
432
+ //#endregion
433
+ export { EditorDocumentProvider as _, buildDocumentSubgraphUrl as a, useSelectedNode as b, getDriveIdBySlug as c, getSwitchboardGatewayUrlFromDriveUrl as d, GQL_CHANNEL_SUFFIX as f, useSelectedDocumentSafe as g, useSelectedDocumentOfType as h, buildDocumentSubgraphQuery as i, getSlugFromDriveUrl as l, useSelectedDocumentId as m, createSwitchboardDirectory as n, getDocumentGraphqlQuery as o, useSelectedDocument as p, resolveSwitchboard as r, getDocumentStateSelection as s, SwitchboardLookupError as t, getSwitchboardBaseFromChannelUrl as u, useEditorDocumentContext as v, useNodeById as x, useDocumentOfType as y };
434
+
435
+ //# sourceMappingURL=switchboard-directory-CWf5SRo7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchboard-directory-CWf5SRo7.js","names":[],"sources":["../src/hooks/node-by-id.ts","../src/hooks/selected-node.ts","../src/hooks/document-of-type.ts","../src/hooks/editor-context.tsx","../src/hooks/selected-document.ts","../src/utils/gql-channel.ts","../src/utils/switchboard.ts","../src/utils/switchboard-directory.ts"],"sourcesContent":["import type { Node } from \"@powerhousedao/shared/document-drive\";\nimport { useDriveNode } from \"./drive-nodes.js\";\nimport { useSelectedDriveId } from \"./selected-drive.js\";\n\n/** Returns a node in the selected drive by id. */\nexport function useNodeById(id: string | null | undefined): Node | undefined {\n return useDriveNode(useSelectedDriveId(), id);\n}\n","import type { Node } from \"@powerhousedao/shared/document-drive\";\nimport { useNodeById } from \"./node-by-id.js\";\nimport { useSelectedNodeId } from \"./set-selected-node.js\";\n\nexport {\n addResetSelectedNodeEventHandler,\n addSelectedNodeIdEventHandler,\n getNodeTarget,\n useNodeTarget,\n preloadNode,\n setSelectedNode,\n setSelectedNodeId,\n useOpenNode,\n usePreloadNode,\n useSetSelectedNode,\n} from \"./set-selected-node.js\";\nexport { addSetSelectedNodeOnPopStateEventHandler } from \"./sync-selection.js\";\n\n/** Returns the selected node. */\nexport function useSelectedNode(): Node | undefined {\n return useNodeById(useSelectedNodeId());\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 {\n DocumentDispatch,\n PHDocument,\n} from \"@powerhousedao/shared/document-model\";\nimport type { ReactNode } from \"react\";\nimport { createContext, useContext, useMemo } from \"react\";\n\n/** The document an editor is rendered with, and a dispatch bound to it. */\nexport type EditorDocumentContextValue = readonly [\n PHDocument,\n DocumentDispatch,\n];\n\nconst EditorDocumentContext = createContext<\n EditorDocumentContextValue | undefined\n>(undefined);\n\n/** Hosts render an editor inside this, with the same `document` and `dispatch`\n * as its props; `useSelected*Document` hooks below read them. */\nexport function EditorDocumentProvider(props: {\n document: PHDocument;\n dispatch: DocumentDispatch;\n children: ReactNode;\n}) {\n const { document, dispatch } = props;\n const value = useMemo(\n () => [document, dispatch] as const,\n [document, dispatch],\n );\n return (\n <EditorDocumentContext.Provider value={value}>\n {props.children}\n </EditorDocumentContext.Provider>\n );\n}\n\n/** The nearest editor's document and dispatch, or undefined outside one. */\nexport function useEditorDocumentContext() {\n return useContext(EditorDocumentContext);\n}\n","import { ModuleNotFoundError } from \"@powerhousedao/reactor\";\nimport type { DocumentDispatch } from \"@powerhousedao/reactor-browser\";\nimport { isFileNode } from \"@powerhousedao/shared/document-drive\";\nimport type { Action, PHDocument } from \"@powerhousedao/shared/document-model\";\nimport {\n DocumentTypeMismatchError,\n NoSelectedDocumentError,\n} from \"../errors.js\";\nimport type { DispatchFn, UseDispatchResult } from \"./dispatch.js\";\nimport { useDocumentById } from \"./document-by-id.js\";\nimport { useDocumentModelModuleById } from \"./document-model-modules.js\";\nimport { useDocumentOfType } from \"./document-of-type.js\";\nimport { useDriveContext } from \"./drive-context.js\";\nimport { useEditorDocumentContext } from \"./editor-context.js\";\nimport { useSelectedNode } from \"./selected-node.js\";\n\n/** Returns the selected document id: the editor's document, else the drive\n * app's open document, else the app's selection. */\nexport function useSelectedDocumentId(): string | undefined {\n const editor = useEditorDocumentContext();\n const drive = useDriveContext();\n const selectedNode = useSelectedNode();\n if (editor) return editor[0].header.id;\n // The drive may not list a document the route opened yet.\n if (drive?.nodeId && !drive.folder) {\n return selectedNode && !isFileNode(selectedNode) ? undefined : drive.nodeId;\n }\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 [document, dispatch] = useSelectedDocumentSafe();\n if (!document) {\n throw new NoSelectedDocumentError();\n }\n return [document, dispatch] as const;\n}\n\n/** Returns the selected document: the editor's, else the app's selection. */\nexport function useSelectedDocumentSafe(): UseDispatchResult<\n PHDocument,\n Action\n> {\n const editor = useEditorDocumentContext();\n const selectedDocumentId = useSelectedDocumentId();\n const selected = useDocumentById(editor ? null : selectedDocumentId);\n return editor ?? selected;\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 editor = useEditorDocumentContext();\n const documentId = useSelectedDocumentId();\n // Called on every render; without a type, or in an editor, it reads no document.\n const result = useDocumentOfType<TDocument, TAction>(\n documentType && !editor ? documentId : null,\n documentType,\n );\n const documentModelModule = useDocumentModelModuleById(documentType);\n\n if (!documentType) {\n return [];\n }\n if (editor) {\n const [document, dispatch] = editor;\n if (!documentModelModule) {\n throw new ModuleNotFoundError(documentType);\n }\n if (document.header.documentType !== documentType) {\n throw new DocumentTypeMismatchError(\n document.header.id,\n documentType,\n document.header.documentType,\n );\n }\n return [document as TDocument, dispatch];\n }\n if (!documentId) {\n throw new NoSelectedDocumentError();\n }\n return result;\n}\n","/** Suffix of the per-drive GraphQL channel endpoint the switchboard serves. */\nexport const GQL_CHANNEL_SUFFIX = \"/graphql/r\";\n","import { pascalCase } from \"change-case\";\nimport type { DocumentModelModule } from \"document-model\";\nimport {\n Kind,\n parse,\n type DefinitionNode,\n type InterfaceTypeDefinitionNode,\n type ObjectTypeDefinitionNode,\n type TypeNode,\n type UnionTypeDefinitionNode,\n} from \"graphql\";\nimport lzString from \"lz-string\";\nimport { GQL_CHANNEL_SUFFIX } from \"./gql-channel.js\";\nimport { GetDocumentWithOperationsDocument } from \"../graphql/gen/schema.js\";\n\nexport async function getDriveIdBySlug(driveUrl: string, slug: string) {\n if (!driveUrl) {\n return;\n }\n\n const urlParts = driveUrl.split(\"/\");\n urlParts.pop(); // remove id\n urlParts.pop(); // remove /d\n urlParts.push(\"drives\"); // add /drives\n const drivesUrl = urlParts.join(\"/\");\n const result = await fetch(drivesUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n query: `\n query getDriveIdBySlug($slug: String!) {\n driveIdBySlug(slug: $slug)\n }\n `,\n variables: {\n slug,\n },\n }),\n });\n\n const data = (await result.json()) as {\n data: { driveIdBySlug: string };\n };\n\n return data.data.driveIdBySlug;\n}\n\nexport function getSlugFromDriveUrl(driveUrl: string) {\n const urlParts = driveUrl.split(\"/\");\n return urlParts.pop();\n}\n\nexport function getSwitchboardGatewayUrlFromDriveUrl(driveUrl: string) {\n const urlParts = driveUrl.split(\"/\");\n urlParts.pop(); // remove id\n urlParts.pop(); // remove /d\n urlParts.push(\"graphql\"); // add /graphql\n return urlParts.join(\"/\");\n}\n\nexport function getDocumentGraphqlQuery() {\n const loc = GetDocumentWithOperationsDocument.loc;\n if (!loc) {\n throw new Error(\n \"GetDocumentWithOperationsDocument is misconfigured, loc is missing.\",\n );\n }\n return loc.source.body;\n}\n\n/**\n * The base URL of the switchboard that serves a drive's GraphQL channel.\n *\n * The channel URL is `<origin>[<proxy-prefix>]/graphql/r`, so stripping the\n * suffix preserves any proxy prefix (e.g. `/api/reactor`). A URL that does\n * not end with the suffix is unexpected — fall back to its origin.\n */\nexport function getSwitchboardBaseFromChannelUrl(channelUrl: string): string {\n if (channelUrl.endsWith(GQL_CHANNEL_SUFFIX)) {\n return channelUrl.slice(0, -GQL_CHANNEL_SUFFIX.length);\n }\n return new URL(channelUrl).origin;\n}\n\n/**\n * The GraphQL name the switchboard exposes a document model under. Mirrors\n * `getDocumentModelSchemaName` on the server (`model-schema-templates.ts`): the root\n * query field and the state type names are all derived from the model's\n * `global.name`.\n */\nfunction getDocumentModelSchemaName(model: DocumentModelModule): string {\n return pascalCase(model.documentModel.global.name.replaceAll(\"/\", \" \"));\n}\n\ntype StateType =\n | ObjectTypeDefinitionNode\n | InterfaceTypeDefinitionNode\n | UnionTypeDefinitionNode;\n\nfunction buildStateTypeMap(definitions: ReadonlyArray<DefinitionNode>) {\n const typeMap = new Map<string, StateType>();\n for (const def of definitions) {\n if (\n def.kind === Kind.OBJECT_TYPE_DEFINITION ||\n def.kind === Kind.INTERFACE_TYPE_DEFINITION ||\n def.kind === Kind.UNION_TYPE_DEFINITION\n ) {\n typeMap.set(def.name.value, def);\n }\n }\n return typeMap;\n}\n\n/**\n * Recursively expands the fields of a state object type into a GraphQL\n * selection. Objects expand their sub-selection (lists expand their item\n * type); enums, scalars, and built-ins are leaves.\n */\nfunction expandStateFields(\n typeDef: StateType,\n typeMap: Map<string, StateType>,\n): string {\n if (typeDef.kind !== Kind.OBJECT_TYPE_DEFINITION) {\n throw new Error(\n `Abstract state type requires the generic document query: ${typeDef.name.value}`,\n );\n }\n return (typeDef.fields ?? [])\n .map((field) => {\n const fieldName = field.name.value;\n let typeNode: TypeNode = field.type;\n if (typeNode.kind === Kind.NON_NULL_TYPE) {\n typeNode = typeNode.type;\n }\n\n if (typeNode.kind === Kind.LIST_TYPE) {\n let itemType: TypeNode = typeNode.type;\n if (itemType.kind === Kind.NON_NULL_TYPE) {\n itemType = itemType.type;\n }\n if (itemType.kind === Kind.LIST_TYPE) {\n throw new Error(\n `Nested lists are not supported in state selections: ${fieldName}`,\n );\n }\n if (itemType.kind !== Kind.NAMED_TYPE) {\n return fieldName;\n }\n const itemTypeDef = typeMap.get(itemType.name.value);\n if (!itemTypeDef) {\n // Scalar, enum, or built-in item — a leaf.\n return fieldName;\n }\n return `${fieldName} { ${expandStateFields(itemTypeDef, typeMap)} }`;\n }\n\n if (typeNode.kind !== Kind.NAMED_TYPE) {\n return fieldName;\n }\n const typeDef = typeMap.get(typeNode.name.value);\n if (!typeDef) {\n // Scalar, enum, or a type from another schema — a leaf.\n return fieldName;\n }\n return `${fieldName} { ${expandStateFields(typeDef, typeMap)} }`;\n })\n .join(\" \");\n}\n\n/**\n * Finds the root state object type in a state SDL. Root state types follow\n * the `<Name>State` / `<Name>GlobalState` conventions, and are defined last\n * by convention — the same resolution order the server uses\n * (`extractRootTypeName` in `create-schema.ts`).\n */\nfunction findRootStateType(\n definitions: ReadonlyArray<DefinitionNode>,\n candidates: string[],\n): ObjectTypeDefinitionNode {\n let lastObjectType: ObjectTypeDefinitionNode | null = null;\n for (const def of definitions) {\n if (def.kind !== Kind.OBJECT_TYPE_DEFINITION) {\n continue;\n }\n if (candidates.includes(def.name.value)) {\n return def;\n }\n lastObjectType = def;\n }\n if (!lastObjectType) {\n throw new Error(\"No root state type found in the document model schema\");\n }\n return lastObjectType;\n}\n\n/**\n * Derives the subselection for the document's `global` state scope from the\n * model's state SDL (e.g. `name total`), expanding object fields\n * recursively. Throws when the schema is missing, unparseable, or has no\n * root object type — the caller falls back to the generic document query.\n */\nexport function getDocumentStateSelection(model: DocumentModelModule): string {\n const spec = model.documentModel.global.specifications.at(-1);\n const schema = spec?.state.global.schema;\n if (!schema || !schema.trim()) {\n throw new Error(\"Document model has no global state schema\");\n }\n const ast = parse(schema);\n const typeMap = buildStateTypeMap(ast.definitions);\n const documentName = getDocumentModelSchemaName(model);\n const rootType = findRootStateType(ast.definitions, [\n `${documentName}State`,\n `${documentName}GlobalState`,\n ]);\n return expandStateFields(rootType, typeMap);\n}\n\nfunction getLocalStateSelection(\n localSchema: string,\n documentName: string,\n): string {\n const ast = parse(localSchema);\n const typeMap = buildStateTypeMap(ast.definitions);\n const rootType = findRootStateType(ast.definitions, [\n `${documentName}LocalState`,\n ]);\n return expandStateFields(rootType, typeMap);\n}\n\n/**\n * Builds a query scoped to a document type's own subgraph root field,\n * selecting the document and its full typed state. The shape mirrors what\n * the switchboard generates per model (`generateNewApiSchema` in\n * `model-schema-templates.ts`): `<Name> { document(identifier:) { document { ...\n * state { auth document global local } } } childIds }`.\n */\nfunction buildModelScopedQuery(model: DocumentModelModule): string {\n const globalState = model.documentModel.global;\n const documentName = getDocumentModelSchemaName(model);\n const globalSelection = getDocumentStateSelection(model);\n\n const spec = globalState.specifications.at(-1);\n const localSchema = spec?.state.local.schema ?? \"\";\n const hasLocalStateType = localSchema.includes(\n `type ${documentName}LocalState`,\n );\n const localSelection = hasLocalStateType\n ? getLocalStateSelection(localSchema, documentName)\n : null;\n\n return [\n \"query GetDocument($identifier: String!) {\",\n ` ${documentName} {`,\n \" document(identifier: $identifier) {\",\n \" document {\",\n \" id\",\n \" name\",\n \" documentType\",\n \" state {\",\n \" auth\",\n \" document { version hash { algorithm encoding } isDeleted deletedAtUtcIso deletedBy deletionReason }\",\n ` global { ${globalSelection} }`,\n ` ${localSelection ? `local { ${localSelection} }` : \"local\"}`,\n \" }\",\n \" }\",\n \" childIds\",\n \" }\",\n \" }\",\n \"}\",\n ].join(\"\\n\");\n}\n\nexport function buildDocumentSubgraphQuery(\n documentType: string,\n identifier: string,\n model?: DocumentModelModule,\n authToken?: string,\n): string {\n let query: string;\n // Only trust a model that actually matches the document's type; a model\n // with a different root field would produce a query the supergraph cannot\n // resolve.\n if (model && model.documentModel.global.id === documentType) {\n try {\n query = buildModelScopedQuery(model);\n } catch (error) {\n console.warn(\n \"Could not derive a document-scoped query from the document model, \" +\n \"falling back to the generic document query:\",\n error,\n );\n query = getDocumentGraphqlQuery();\n }\n } else {\n query = getDocumentGraphqlQuery();\n }\n const variables = { identifier };\n const headers = authToken\n ? {\n Authorization: `Bearer ${authToken}`,\n }\n : undefined;\n\n const payload: Record<string, string> = {\n document: query.trim(),\n variables: JSON.stringify(variables, null, 2),\n };\n if (headers) {\n payload.headers = JSON.stringify(headers);\n }\n return lzString.compressToEncodedURIComponent(JSON.stringify(payload));\n}\n\nexport function buildDocumentSubgraphUrl(\n channelUrl: string,\n documentType: string,\n identifier: string,\n model?: DocumentModelModule,\n authToken?: string,\n): string {\n const encodedQuery = buildDocumentSubgraphQuery(\n documentType,\n identifier,\n model,\n authToken,\n );\n const base = getSwitchboardBaseFromChannelUrl(channelUrl);\n return `${base}/explorer?explorerURLState=${encodedQuery}`;\n}\n","// The switchboards an app reaches, and the one a call should go to. Hosts\n// build the directory once at boot (createSwitchboardDirectory) and set it on\n// their store; callers ask resolveSwitchboard, which never guesses a URL.\nimport { DriveCollectionId, type ISyncManager } from \"@powerhousedao/reactor\";\nimport { ORIGIN_PLACEHOLDER } from \"@powerhousedao/shared/connect/origin-placeholder\";\nimport { switchboardOfDrive } from \"@powerhousedao/shared/host-tokens\";\nimport type {\n SwitchboardDirectory,\n SwitchboardEntry,\n SwitchboardWorkflows,\n} from \"../types/switchboards.js\";\nimport { getSwitchboardBaseFromChannelUrl } from \"./switchboard.js\";\n\n/** What a router says about its backends; structural, so hosts pass their own. */\nexport interface SwitchboardRouter {\n readonly backends: readonly {\n readonly name: string;\n readonly facts: {\n readonly known: boolean;\n readonly reactor: { readonly workflows: boolean };\n };\n }[];\n /** The name of the backend that serves `identifier`. */\n locate(identifier: string, signal?: AbortSignal): Promise<string>;\n}\n\nexport interface SwitchboardDirectoryOptions {\n /**\n * The host's remote backends, as the served config lists them\n * (`instance.remoteBackends`): a name and one of the switchboard's drive\n * addresses, `<base>/d/<slug>`.\n */\n remoteBackends?: readonly { readonly name: string; readonly url: string }[];\n /** The router over those backends, for their facts and for `locate`. */\n router?: SwitchboardRouter;\n /** The tab's sync manager, read on each call: every gql remote's switchboard. */\n syncManager?: () => Pick<ISyncManager, \"list\"> | undefined;\n /** What `${origin}` stands for; defaults to the page's origin. */\n origin?: string;\n}\n\n/** `${origin}` resolved against the page; a base stays as it is otherwise. */\nfunction resolveOrigin(base: string, origin: string | undefined): string {\n if (!base.startsWith(ORIGIN_PLACEHOLDER)) return base;\n const page =\n origin ?? (typeof location === \"undefined\" ? undefined : location.origin);\n return page ? page + base.slice(ORIGIN_PLACEHOLDER.length) : base;\n}\n\nfunction trimSlash(url: string): string {\n return url.replace(/\\/+$/, \"\");\n}\n\n/** A synced drive's switchboard, named by its host and path. */\nfunction syncName(base: string): string {\n return base.replace(/^[a-z]+:\\/\\//i, \"\");\n}\n\n/**\n * Builds the directory from the host's remote backends and the tab's synced\n * drives. A backend's facts are read on each `list`, so a refresh shows.\n */\nexport function createSwitchboardDirectory(\n options: SwitchboardDirectoryOptions,\n): SwitchboardDirectory {\n const backends = (options.remoteBackends ?? []).flatMap(({ name, url }) => {\n const drive = switchboardOfDrive(url);\n if (!drive) return [];\n const base = trimSlash(resolveOrigin(drive.base, options.origin));\n return [{ name, base }];\n });\n\n const workflowsOf = (name: string): SwitchboardWorkflows => {\n const backend = options.router?.backends.find((b) => b.name === name);\n if (!backend?.facts.known) return \"unknown\";\n return backend.facts.reactor.workflows;\n };\n\n const remotes = () => {\n try {\n return options.syncManager?.()?.list() ?? [];\n } catch {\n return [];\n }\n };\n\n const syncBase = (remote: ReturnType<typeof remotes>[number]) => {\n const { channelConfig } = remote.meta;\n const url =\n channelConfig.type === \"gql\" ? channelConfig.parameters.url : \"\";\n if (typeof url !== \"string\" || !url) return undefined;\n try {\n return trimSlash(getSwitchboardBaseFromChannelUrl(url));\n } catch {\n return undefined;\n }\n };\n\n const list = (): SwitchboardEntry[] => {\n const entries: SwitchboardEntry[] = backends.map(({ name, base }) => ({\n name,\n base,\n graphqlUrl: `${base}/graphql`,\n via: \"backend\",\n workflows: workflowsOf(name),\n }));\n const seen = new Set(entries.map((entry) => entry.base));\n for (const remote of remotes()) {\n const base = syncBase(remote);\n if (!base || seen.has(base)) continue;\n seen.add(base);\n entries.push({\n name: syncName(base),\n base,\n graphqlUrl: `${base}/graphql`,\n via: \"sync\",\n workflows: \"unknown\",\n });\n }\n return entries;\n };\n\n const locate = async (\n documentId: string,\n signal?: AbortSignal,\n ): Promise<SwitchboardEntry | undefined> => {\n const entries = list();\n const collectionId = DriveCollectionId.forDrive(documentId);\n const remote = remotes().find((r) =>\n r.meta.collectionId.equals(collectionId),\n );\n const synced = remote && syncBase(remote);\n if (synced) return entries.find((entry) => entry.base === synced);\n if (!options.router || backends.length === 0) return undefined;\n let name: string;\n try {\n name = await options.router.locate(documentId, signal);\n } catch (error) {\n if (signal?.aborted) throw error;\n return undefined;\n }\n return entries.find(\n (entry) => entry.via === \"backend\" && entry.name === name,\n );\n };\n\n return { list, locate };\n}\n\nexport type SwitchboardLookupErrorCode =\n | \"NO_DIRECTORY\"\n | \"NO_SWITCHBOARD\"\n | \"UNKNOWN_SWITCHBOARD\"\n | \"AMBIGUOUS_SWITCHBOARD\"\n | \"NO_WORKFLOW_RUNTIME\";\n\n/** Why no switchboard could be picked, with the ones there are. */\nexport class SwitchboardLookupError extends Error {\n constructor(\n message: string,\n readonly code: SwitchboardLookupErrorCode,\n readonly switchboards: readonly SwitchboardEntry[] = [],\n ) {\n super(message);\n this.name = \"SwitchboardLookupError\";\n }\n}\n\nexport interface SwitchboardRequest {\n /** A name from the directory, or a URL on the switchboard (its base, GraphQL or any path under it). */\n switchboard?: string;\n /** The document or drive the call is about: its switchboard, when the directory can place it. */\n documentId?: string;\n /** What the switchboard must run. */\n need?: \"workflows\";\n signal?: AbortSignal;\n}\n\nfunction describe(entry: SwitchboardEntry): string {\n const workflows =\n entry.workflows === \"unknown\"\n ? \"workflows unknown\"\n : entry.workflows\n ? \"runs workflows\"\n : \"no workflows\";\n return `${entry.name} (${entry.base}, ${workflows})`;\n}\n\nfunction describeAll(entries: readonly SwitchboardEntry[]): string {\n return entries.map(describe).join(\"; \");\n}\n\n/** The entry `switchboard` names: by name, then by the longest base it lies under. */\nfunction byNameOrUrl(\n entries: readonly SwitchboardEntry[],\n switchboard: string,\n): SwitchboardEntry | undefined {\n const named = entries.find((entry) => entry.name === switchboard);\n if (named) return named;\n const url = trimSlash(switchboard);\n return entries\n .filter((entry) => url === entry.base || url.startsWith(`${entry.base}/`))\n .sort((a, b) => b.base.length - a.base.length)[0];\n}\n\nfunction checkNeed(\n entry: SwitchboardEntry,\n need: SwitchboardRequest[\"need\"],\n entries: readonly SwitchboardEntry[],\n): SwitchboardEntry {\n if (need === \"workflows\" && entry.workflows === false) {\n throw new SwitchboardLookupError(\n `Switchboard ${entry.name} (${entry.base}) runs no workflow runtime.`,\n \"NO_WORKFLOW_RUNTIME\",\n entries,\n );\n }\n return entry;\n}\n\n/**\n * The switchboard a call goes to: the one named, else the one serving the\n * document, else the only one there is (or the only one running what `need`\n * asks for). Throws a {@link SwitchboardLookupError} that lists the\n * switchboards whenever it can't pick one; there is no default URL.\n */\nexport async function resolveSwitchboard(\n directory: SwitchboardDirectory | undefined,\n request: SwitchboardRequest = {},\n): Promise<SwitchboardEntry> {\n if (!directory) {\n throw new SwitchboardLookupError(\n \"This app provides no switchboard directory, so no switchboard can be picked.\",\n \"NO_DIRECTORY\",\n );\n }\n const entries = directory.list();\n const { need } = request;\n\n if (request.switchboard) {\n const named = byNameOrUrl(entries, request.switchboard);\n if (!named) {\n throw new SwitchboardLookupError(\n entries.length > 0\n ? `No switchboard \"${request.switchboard}\". This app reaches: ${describeAll(entries)}.`\n : `No switchboard \"${request.switchboard}\": this app reaches no switchboard.`,\n \"UNKNOWN_SWITCHBOARD\",\n entries,\n );\n }\n return checkNeed(named, need, entries);\n }\n\n // With one switchboard, placing the document could only name that one.\n if (request.documentId && entries.length > 1) {\n const located = await directory.locate(request.documentId, request.signal);\n if (located) return checkNeed(located, need, entries);\n }\n\n if (entries.length === 0) {\n throw new SwitchboardLookupError(\n \"This app reaches no switchboard; it is connected to none.\",\n \"NO_SWITCHBOARD\",\n );\n }\n if (entries.length === 1) return checkNeed(entries[0], need, entries);\n\n if (need === \"workflows\") {\n const running = entries.filter((entry) => entry.workflows === true);\n if (running.length === 1) return running[0];\n if (running.length === 0) {\n const maybe = entries.filter((entry) => entry.workflows === \"unknown\");\n if (maybe.length === 1) return maybe[0];\n if (maybe.length === 0) {\n throw new SwitchboardLookupError(\n `None of the switchboards runs a workflow runtime: ${describeAll(entries)}.`,\n \"NO_WORKFLOW_RUNTIME\",\n entries,\n );\n }\n }\n }\n throw new SwitchboardLookupError(\n `This app reaches several switchboards (${describeAll(entries)}); name one with \"switchboard\".`,\n \"AMBIGUOUS_SWITCHBOARD\",\n entries,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAKA,SAAgB,YAAY,IAAiD;CAC3E,OAAO,aAAa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