@powerhousedao/reactor-api 6.2.2-dev.9 → 6.2.2

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 (28) hide show
  1. package/dist/{adapter-gateway-apollo-CxV_hMTv.mjs → adapter-gateway-apollo-DdamNLPT.mjs} +10 -4
  2. package/dist/adapter-gateway-apollo-DdamNLPT.mjs.map +1 -0
  3. package/dist/adapter-http-express-CgVPgEMm.mjs +225 -0
  4. package/dist/adapter-http-express-CgVPgEMm.mjs.map +1 -0
  5. package/dist/{adapter-http-fastify-B248RJtm.mjs → adapter-http-fastify-D98iRljY.mjs} +38 -26
  6. package/dist/adapter-http-fastify-D98iRljY.mjs.map +1 -0
  7. package/dist/index.d.mts +584 -50
  8. package/dist/index.d.mts.map +1 -1
  9. package/dist/index.mjs +1258 -174
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/path-normalize-DWWFLiy6.mjs +23 -0
  12. package/dist/path-normalize-DWWFLiy6.mjs.map +1 -0
  13. package/dist/src/packages/https-hooks.mjs +1 -1
  14. package/dist/src/packages/vite-loader.d.mts +3 -2
  15. package/dist/src/packages/vite-loader.d.mts.map +1 -1
  16. package/dist/src/packages/vite-loader.mjs +33 -8
  17. package/dist/src/packages/vite-loader.mjs.map +1 -1
  18. package/dist/{types-DnHgkahK.d.mts → types-Bz2niABC.d.mts} +13 -2
  19. package/dist/types-Bz2niABC.d.mts.map +1 -0
  20. package/dist/{utils-iibOQ50e.mjs → utils-lHoPB-ft.mjs} +130 -23
  21. package/dist/utils-lHoPB-ft.mjs.map +1 -0
  22. package/package.json +22 -19
  23. package/dist/adapter-gateway-apollo-CxV_hMTv.mjs.map +0 -1
  24. package/dist/adapter-http-express-D5OpUIbV.mjs +0 -137
  25. package/dist/adapter-http-express-D5OpUIbV.mjs.map +0 -1
  26. package/dist/adapter-http-fastify-B248RJtm.mjs.map +0 -1
  27. package/dist/types-DnHgkahK.d.mts.map +0 -1
  28. package/dist/utils-iibOQ50e.mjs.map +0 -1
package/dist/index.d.mts CHANGED
@@ -1,26 +1,27 @@
1
- import { i as IPackageManagerOptions, n as IPackageLoaderOptions, r as IPackageManager, s as PackageManagerResult, t as IPackageLoader } from "./types-DnHgkahK.mjs";
1
+ import { i as IPackageManagerOptions, n as IPackageLoaderOptions, r as IPackageManager, s as PackageManagerResult, t as IPackageLoader } from "./types-Bz2niABC.mjs";
2
2
  import { IAnalyticsStore } from "@powerhousedao/analytics-engine-core";
3
3
  import { AnalyticsModel } from "@powerhousedao/analytics-engine-graphql";
4
4
  import * as graphql from "graphql";
5
5
  import { DocumentNode, GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig, GraphQLSchema } from "graphql";
6
- import { IDocumentModelLoader, IDocumentModelRegistry, IDriveClient, IReactorClient, IRelationalDb, ISyncManager, InProcessReactorClientModule, ParsedDriveUrl, driveIdFromUrl, parseDriveUrl } from "@powerhousedao/reactor";
6
+ import { AttachmentRef, IDocumentModelLoader, IDocumentModelRegistry, IDriveClient, IReactorClient, IReactorProcessorHostModuleBase, IRelationalDb, ISyncManager, InProcessReactorClientModule, ParsedDriveUrl, ProcessorFactoryBuilder as ProcessorFactoryBuilder$1, SyncScopeGate, driveIdFromUrl, parseDriveUrl } from "@powerhousedao/reactor";
7
7
  import { ILogger } from "document-model";
8
- import { DocumentModelGlobalState as DocumentModelGlobalState$1, DocumentModelModule, Operation, PHDocument, PHDocumentHeader } from "@powerhousedao/shared/document-model";
8
+ import { GraphQLResolverMap, GraphQLSchemaModule } from "@apollo/subgraph";
9
+ import { AuthSubject, DocumentModelGlobalState as DocumentModelGlobalState$1, DocumentModelModule, Operation, PHDocument, UpgradeManifest } from "@powerhousedao/shared/document-model";
9
10
  import * as z$1 from "zod";
10
11
  import { DocumentDriveDocument, DocumentDriveGlobalState } from "@powerhousedao/shared/document-drive";
11
- import { AttachmentBuildResult } from "@powerhousedao/reactor-attachments";
12
+ import { AttachmentBuildResult, AttachmentReferenceIndexBuildResult, IAttachmentReferenceReader, IAttachmentReferenceWriter } from "@powerhousedao/reactor-attachments";
12
13
  import { IAttachmentClient } from "@powerhousedao/reactor-attachments/client";
13
14
  import { WebSocketServer } from "ws";
14
- import { IProcessorHostModule, IRelationalDb as IRelationalDb$1, ProcessorApp, ProcessorRecord } from "@powerhousedao/shared/processors";
15
+ import { IRelationalDb as IRelationalDb$1, ProcessorApp, ProcessorFactory } from "@powerhousedao/shared/processors";
15
16
  import { Generated, Kysely } from "kysely";
16
17
  import { PGlite } from "@electric-sql/pglite";
17
18
  import { Knex } from "knex";
18
19
  import http from "node:http";
19
20
  import { CorsOptions } from "cors";
20
- import { GraphQLResolverMap, GraphQLSchemaModule } from "@apollo/subgraph/dist/schema-helper/resolverMap.js";
21
21
  import { Context as Context$1, GqlDocument as GqlDocument$1, GqlDriveDocument as GqlDriveDocument$1, GqlOperation as GqlOperation$1, GraphQLManager as GraphQLManager$1, ISubgraph as ISubgraph$1, Processor as Processor$1, SubgraphArgs as SubgraphArgs$1, SubgraphClass as SubgraphClass$1 } from "@powerhousedao/reactor-api";
22
22
  import { IncomingHttpHeaders } from "http";
23
23
  import { Pool } from "pg";
24
+ import { PHReactorRenown } from "@powerhousedao/shared/clis";
24
25
 
25
26
  //#region src/utils/db.d.ts
26
27
  /**
@@ -63,6 +64,9 @@ interface OperationUserPermissionTable {
63
64
  createdAt: Date;
64
65
  }
65
66
  type Db = Kysely<any>;
67
+ declare const PGLITE_UTC_PARSERS: {
68
+ readonly 1114: (value: string) => Date;
69
+ };
66
70
  /**
67
71
  * Optional factory used by callers (e.g. Switchboard) to inject a
68
72
  * version-specific PGLite instance — e.g. `pglite-legacy-02` when an existing
@@ -215,7 +219,7 @@ declare class DocumentPermissionService {
215
219
  * must key on the canonical id, so branding it forces every caller to resolve a
216
220
  * slug to its id before consulting this service, closing the slug-aliasing
217
221
  * bypass (S-C1). The only sanctioned cast from string to CanonicalDocumentId
218
- * lives in the BaseSubgraph resolution helpers, immediately after the shared
222
+ * lives in createCanonicalDocumentIdResolver, immediately after the shared
219
223
  * resolveIdOrSlug lookup returns.
220
224
  */
221
225
  type CanonicalDocumentId = string & {
@@ -293,11 +297,19 @@ type Context = {
293
297
  user?: {
294
298
  address: string;
295
299
  chainId: number;
296
- networkId: string;
300
+ networkId: string; /** The did:key of the app instance that issued this request's token. */
301
+ appKey: string;
297
302
  };
298
303
  };
299
304
  type ISubgraph = {
300
305
  name: string;
306
+ /**
307
+ * @deprecated The GraphQL manager mounts every subgraph under its own base
308
+ * path and does not consult this field for routing, so the value a
309
+ * subgraph holds (including one overwritten by a field initializer after
310
+ * `super()`) has no effect on where it is mounted. Retained for source
311
+ * compatibility.
312
+ */
301
313
  path?: string;
302
314
  resolvers: Record<string, any>;
303
315
  typeDefs: DocumentNode;
@@ -305,6 +317,7 @@ type ISubgraph = {
305
317
  relationalDb: IRelationalDb;
306
318
  hasSubscriptions?: boolean;
307
319
  onSetup?: () => Promise<void>;
320
+ onDisconnect?: () => Promise<void>;
308
321
  };
309
322
  type SubgraphArgs = {
310
323
  reactorClient: IReactorClient;
@@ -314,6 +327,17 @@ type SubgraphArgs = {
314
327
  syncManager: ISyncManager;
315
328
  documentPermissionService?: DocumentPermissionService;
316
329
  authorizationService: IAuthorizationService;
330
+ /**
331
+ * Evaluates a document's own policy when serving sync. Absent below
332
+ * `authEnforcement`, where there is no model to enforce and serving falls back
333
+ * to the host's permission tables alone.
334
+ */
335
+ syncServingGate?: SyncScopeGate;
336
+ /**
337
+ * The host's base path, injected by the GraphQL manager when it constructs
338
+ * a subgraph. Subgraph code may read it, but routing ignores it: every
339
+ * subgraph is mounted under the manager's own base path.
340
+ */
317
341
  path?: string;
318
342
  };
319
343
  type GqlSigner = {
@@ -386,8 +410,10 @@ declare class BaseSubgraph implements ISubgraph$1 {
386
410
  syncManager: ISyncManager;
387
411
  documentPermissionService?: DocumentPermissionService;
388
412
  authorizationService: IAuthorizationService;
413
+ syncServingGate?: SyncScopeGate;
389
414
  constructor(args: SubgraphArgs$1);
390
415
  onSetup(): Promise<void>;
416
+ onDisconnect(): Promise<void>;
391
417
  /**
392
418
  * Resolves a caller-supplied identifier (id or slug) to its canonical
393
419
  * document id, memoized per request. Both the decision layer and the data
@@ -411,6 +437,17 @@ declare class BaseSubgraph implements ISubgraph$1 {
411
437
  * layer, such as a fetched document's id). Performs no slug resolution.
412
438
  */
413
439
  canReadDocument(documentId: CanonicalDocumentId, ctx: Context): Promise<boolean>;
440
+ /**
441
+ * The principal a request decides as: the authenticated caller's address, and
442
+ * the did:key of the app instance whose token authenticated it.
443
+ *
444
+ * Both, because a policy can name either. The key is what a document records
445
+ * as its creator, so a subject built without one cannot match the creator's
446
+ * standing permission over the auth scope -- the document's own creator would
447
+ * be refused an operation the write path accepts, since a signed action
448
+ * carries the same key. Anonymous callers supply neither.
449
+ */
450
+ protected viewSubject(ctx: Context): AuthSubject;
414
451
  /**
415
452
  * Asserts read access, resolving a slug first. Returns a handle whose
416
453
  * `fetchIdentifier` the caller reuses for the data fetch; a denial throws.
@@ -594,16 +631,56 @@ declare class AuthSubgraph extends BaseSubgraph {
594
631
  }
595
632
  //#endregion
596
633
  //#region src/services/auth.service.d.ts
634
+ type CredentialVerifier = (params: {
635
+ address: string;
636
+ chainId: number;
637
+ appId: string;
638
+ }) => Promise<boolean>;
597
639
  interface AuthConfig {
640
+ /**
641
+ * Whether the authorization policy enforces anything: it selects `ADMIN_ONLY`
642
+ * over `OPEN`, and it is what `AuthContext.auth_enabled` reports to callers
643
+ * that gate on "is authentication being enforced" (the attachment routes do).
644
+ *
645
+ * It does NOT decide whether the bearer is read — see {@link resolveIdentity}.
646
+ */
598
647
  enabled: boolean;
648
+ /**
649
+ * Whether the bearer is verified and `AuthContext.user` populated at all.
650
+ *
651
+ * Defaults to {@link enabled}, which is the behaviour every deployment had
652
+ * before this option existed. Setting it independently is what lets a server
653
+ * know who is calling while leaving the policy `OPEN` — resolving an identity
654
+ * and enforcing one are different concerns, and welding them together left
655
+ * consumers choosing between an unauthenticated caller and locking every
656
+ * non-admin out.
657
+ *
658
+ * It resolves an identity and enforces nothing: a request with no token is
659
+ * still admitted, with no user.
660
+ */
661
+ resolveIdentity?: boolean;
599
662
  admins: string[];
600
663
  skipCredentialVerification?: boolean;
601
664
  credentialVerificationCacheTtlMs?: number;
665
+ verifyCredential?: CredentialVerifier;
602
666
  }
603
667
  interface User {
604
668
  address: string;
605
669
  chainId: number;
606
670
  networkId: string;
671
+ /**
672
+ * The did:key of the app instance that issued this request's token, taken
673
+ * from the verified credential's issuer.
674
+ *
675
+ * It is the same value a signer presents as its app key when it signs an
676
+ * action, which is what a document records as its creator. Carrying it here
677
+ * is what lets a request decide as the same principal the write path
678
+ * presents, rather than as an address with no key.
679
+ *
680
+ * Authenticated, not asserted: the token is verified by resolving this very
681
+ * DID, so a caller cannot name someone else's.
682
+ */
683
+ appKey: string;
607
684
  }
608
685
  interface AuthContext {
609
686
  user?: User;
@@ -614,6 +691,13 @@ declare class AuthService {
614
691
  private readonly config;
615
692
  private readonly credentialCache;
616
693
  constructor(config: AuthConfig);
694
+ /**
695
+ * Whether this service reads the bearer at all. Defaults to `enabled`, so a
696
+ * config written before `resolveIdentity` existed behaves exactly as it did.
697
+ */
698
+ private get resolvesIdentity();
699
+ /** The context an unresolved request gets: no user, and no admin list to match against. */
700
+ private anonymousContext;
617
701
  authenticateRequest(request: globalThis.Request): Promise<AuthContext | globalThis.Response>;
618
702
  /**
619
703
  * Verify a Bearer token regardless of HTTP method. Use this from non-GraphQL
@@ -626,7 +710,12 @@ declare class AuthService {
626
710
  */
627
711
  private verifyToken;
628
712
  /**
629
- * Extract user information from verification result
713
+ * Extract user information from verification result.
714
+ *
715
+ * The issuer is required along with the credential subject. A credential that
716
+ * verified must carry one -- resolving it is how the signature was checked --
717
+ * so this rejects a shape that cannot have come from verification rather than
718
+ * admitting a keyless principal.
630
719
  */
631
720
  private extractUserFromVerification;
632
721
  /**
@@ -663,6 +752,12 @@ type WsDisposer = {
663
752
  dispose: () => void | Promise<void>;
664
753
  };
665
754
  type FetchHandler = (request: Request) => Promise<Response>;
755
+ /**
756
+ * Opaque identifier for a registered route. Returned by `mount()`,
757
+ * `getRoute()`, and `mountNodeRoute()`; pass it to `unmount()` to remove
758
+ * the route.
759
+ */
760
+ type RouteHandle = number;
666
761
  /**
667
762
  * A framework-agnostic description of a federated subgraph service.
668
763
  * Used by IGatewayAdapter.createSupergraphHandler() to compose the supergraph SDL.
@@ -702,19 +797,21 @@ interface IHttpAdapter {
702
797
  bodyLimit?: string;
703
798
  }): void;
704
799
  /**
705
- * Mount a Fetch API handler.
706
- * - exact = false (default): exact path match via internal dispatch map.
707
- * - exact = true: prefix match - handler also receives all sub-paths
708
- * (uses framework router.use() semantics).
800
+ * Mount a Fetch API handler. Returns a handle for {@link unmount}.
801
+ * - exact = false (default): exact path match.
802
+ * - exact = true: prefix match - handler also receives all sub-paths.
803
+ *
804
+ * Mounting a path that already holds a fetch mount of the same kind
805
+ * replaces the previous one (last write wins).
709
806
  */
710
807
  mount(path: string, handler: FetchHandler, options?: {
711
808
  exact?: boolean;
712
- }): void;
809
+ }): RouteHandle;
713
810
  /**
714
- * Register a GET route that returns a Fetch Response (for health, explorer, etc.).
715
- * Registered directly on the underlying framework app, bypassing the sub-router.
811
+ * Register a GET-only route that returns a Fetch Response (for health,
812
+ * explorer, etc.). Returns a handle for {@link unmount}.
716
813
  */
717
- getRoute(path: string, handler: (request: Request) => Response | Promise<Response>): void;
814
+ getRoute(path: string, handler: (request: Request) => Response | Promise<Response>): RouteHandle;
718
815
  /**
719
816
  * Start listening on the given port. Returns the underlying http.Server
720
817
  * so callers can attach WebSocket servers.
@@ -732,9 +829,19 @@ interface IHttpAdapter {
732
829
  * protocols that require direct access to IncomingMessage/ServerResponse).
733
830
  *
734
831
  * The req/res objects are `http.IncomingMessage`/`http.ServerResponse`
735
- * (Express Request/Response are compatible subtypes).
832
+ * (Express Request/Response are compatible subtypes). Returns a handle
833
+ * for {@link unmount}.
736
834
  */
737
- mountNodeRoute(method: "DELETE" | "GET" | "HEAD" | "POST" | "PUT", path: string, handler: (req: http.IncomingMessage, res: http.ServerResponse, body?: unknown) => void | Promise<void>): void;
835
+ mountNodeRoute(method: "DELETE" | "GET" | "HEAD" | "POST" | "PUT", path: string, handler: (req: http.IncomingMessage, res: http.ServerResponse, body?: unknown) => void | Promise<void>): RouteHandle;
836
+ /**
837
+ * Remove a route registered by `mount()`, `getRoute()`, or
838
+ * `mountNodeRoute()`, identified by the handle that call returned.
839
+ * No-op for unknown or already-removed handles.
840
+ *
841
+ * `mountRawMiddleware` is intentionally not removable: raw framework
842
+ * middleware (e.g. a Vite dev server) is not a single route.
843
+ */
844
+ unmount(handle: RouteHandle): void;
738
845
  /**
739
846
  * Register framework-specific Sentry error-capturing middleware after all routes
740
847
  * are mounted. Each adapter calls the Sentry setup function appropriate for its
@@ -783,6 +890,9 @@ declare class DriveOwnershipCache {
783
890
  size(): number;
784
891
  }
785
892
  //#endregion
893
+ //#region src/graphql/gateway/require-auth-middleware.d.ts
894
+ type RequireAuthFetchMiddleware = (handler: FetchHandler) => FetchHandler;
895
+ //#endregion
786
896
  //#region src/graphql/graphql-manager.d.ts
787
897
  type GraphqlManagerFeatureFlags = {
788
898
  enableDocumentModelSubgraphs?: boolean;
@@ -803,6 +913,7 @@ declare class GraphQLManager {
803
913
  private readonly documentPermissionService?;
804
914
  private readonly featureFlags;
805
915
  private readonly port;
916
+ private readonly syncServingGate?;
806
917
  private initialized;
807
918
  private coreSubgraphsMap;
808
919
  private contextFields;
@@ -812,6 +923,16 @@ declare class GraphQLManager {
812
923
  /** Cached document models for schema generation - updated on init and regenerate */
813
924
  private cachedDocumentModels;
814
925
  private readonly subgraphHandlerCache;
926
+ /** subgraphPath → the http adapter handle of its mounted route. */
927
+ private readonly subgraphRouteHandles;
928
+ /** Handle of the currently mounted supergraph SSE route, if any. */
929
+ private sseRouteHandle;
930
+ /**
931
+ * Package name → the subgraph instances registered from it, keyed by
932
+ * subgraph name. Tracks the package association so that removed packages
933
+ * can be torn down (see unregisterPackage / prunePackageSubgraphs).
934
+ */
935
+ private readonly packageSubgraphs;
815
936
  /**
816
937
  * Optional reactor-drive client. When the switchboard is configured with a
817
938
  * reactor-drive container, this is provided and the resolvers dispatch to
@@ -819,8 +940,8 @@ declare class GraphQLManager {
819
940
  */
820
941
  readonly reactorDriveClient?: IDriveClient;
821
942
  private readonly authorizationService;
822
- constructor(path: string, httpServer: http.Server, wsServer: WebSocketServer, reactorClient: IReactorClient, relationalDb: IRelationalDb, analyticsStore: IAnalyticsStore, syncManager: ISyncManager, logger: ILogger, httpAdapter: IHttpAdapter, gatewayAdapter: IGatewayAdapter<Context$1>, authService?: AuthService | undefined, documentPermissionService?: DocumentPermissionService | undefined, featureFlags?: GraphqlManagerFeatureFlags, port?: number, authorizationService?: IAuthorizationService, reactorDriveClient?: IDriveClient);
823
- init(coreSubgraphs: SubgraphClass$1[], authMiddleware?: AuthFetchMiddleware): Promise<void>;
943
+ constructor(path: string, httpServer: http.Server, wsServer: WebSocketServer, reactorClient: IReactorClient, relationalDb: IRelationalDb, analyticsStore: IAnalyticsStore, syncManager: ISyncManager, logger: ILogger, httpAdapter: IHttpAdapter, gatewayAdapter: IGatewayAdapter<Context$1>, authService?: AuthService | undefined, documentPermissionService?: DocumentPermissionService | undefined, featureFlags?: GraphqlManagerFeatureFlags, port?: number, authorizationService?: IAuthorizationService, reactorDriveClient?: IDriveClient, syncServingGate?: SyncScopeGate | undefined);
944
+ init(coreSubgraphs: SubgraphClass$1[], authMiddleware?: AuthFetchMiddleware, requireAuthMiddleware?: RequireAuthFetchMiddleware): Promise<void>;
824
945
  /**
825
946
  * Regenerate document model subgraphs when models are dynamically loaded.
826
947
  * Fetches current modules from reactor client (source of truth).
@@ -830,7 +951,7 @@ declare class GraphQLManager {
830
951
  * Register a pre-constructed subgraph instance.
831
952
  * Use this when you need to pass custom dependencies to a subgraph.
832
953
  */
833
- registerSubgraphInstance(subgraphInstance: ISubgraph$1, supergraph?: string, core?: boolean): Promise<ISubgraph$1>;
954
+ registerSubgraphInstance(subgraphInstance: ISubgraph$1, supergraph?: string, core?: boolean): Promise<ISubgraph$1 | undefined>;
834
955
  /**
835
956
  * Get the base path used for subgraph registration.
836
957
  */
@@ -841,7 +962,35 @@ declare class GraphQLManager {
841
962
  * {@link registerSubgraphInstance}.
842
963
  */
843
964
  getAuthorizationService(): IAuthorizationService;
844
- registerSubgraph(subgraph: SubgraphClass$1, supergraph?: string, core?: boolean): Promise<ISubgraph$1>;
965
+ /**
966
+ * Register a subgraph class. `packageName` labels the resulting instance
967
+ * with its contributing package so the instance can be torn down when the
968
+ * package is removed or drops the subgraph (see unregisterPackage and
969
+ * prunePackageSubgraphs).
970
+ */
971
+ registerSubgraph(subgraph: SubgraphClass$1, supergraph?: string, core?: boolean, packageName?: string): Promise<ISubgraph$1 | undefined>;
972
+ /**
973
+ * Tear down every subgraph instance registered from `packageName`:
974
+ * disconnects the instances, unmounts their routes, disposes their
975
+ * WebSocket handlers, then refreshes the router so the supergraph SDL and
976
+ * the supergraph SSE handler no longer reference them. No-op if the
977
+ * package has no registered subgraphs.
978
+ */
979
+ unregisterPackage(packageName: string): Promise<void>;
980
+ /**
981
+ * Remove this package's registered subgraphs whose names are not in
982
+ * `keepNames` — the package is still loaded but dropped some of its
983
+ * subgraphs. Refreshes the router if anything was removed.
984
+ */
985
+ prunePackageSubgraphs(packageName: string, keepNames: ReadonlySet<string>): Promise<void>;
986
+ /** Find a registered subgraph by name, core or package-contributed. */
987
+ getSubgraphByName(name: string): ISubgraph$1 | undefined;
988
+ /** Whether a registered subgraph has a live handler, i.e. whether
989
+ * {@link executeSubgraphQuery} can reach it right now. */
990
+ hasSubgraphHandler(name: string): boolean;
991
+ /** Run a query against one registered subgraph in-process: the subgraph's own
992
+ * handler, without a socket or the auth/drive middleware. Trusted callers. */
993
+ executeSubgraphQuery<T>(subgraphName: string, query: string, variables: Record<string, unknown>): Promise<T>;
845
994
  updateRouter: (immediate?: boolean) => Promise<void>;
846
995
  private _updateRouter;
847
996
  getAdditionalContextFields: () => Record<string, any>;
@@ -874,11 +1023,88 @@ declare class InMemoryPackageStorage implements IPackageStorage {
874
1023
  has(name: string): Promise<boolean>;
875
1024
  }
876
1025
  //#endregion
1026
+ //#region src/services/canonical-document-id.d.ts
1027
+ /**
1028
+ * Raised when a caller-supplied identifier cannot be resolved to a canonical
1029
+ * document id. Carries no detail on purpose: resolution failures must not act
1030
+ * as a document-existence oracle, so consumers map this to their generic
1031
+ * fail-closed response.
1032
+ */
1033
+ declare class CanonicalDocumentIdResolutionError extends Error {
1034
+ constructor();
1035
+ }
1036
+ type CanonicalDocumentIdResolver = (identifier: string) => Promise<CanonicalDocumentId>;
1037
+ /**
1038
+ * The sanctioned string-to-CanonicalDocumentId cast: both the GraphQL layer
1039
+ * and server routes must resolve caller identifiers through this helper so
1040
+ * decision and data layers always agree on the subject document.
1041
+ */
1042
+ declare function createCanonicalDocumentIdResolver(client: Pick<IReactorClient, "resolveIdOrSlug">): CanonicalDocumentIdResolver;
1043
+ //#endregion
1044
+ //#region src/services/attachment-access.service.d.ts
1045
+ /**
1046
+ * Whether the active Reactor composition hosts the attachment-reference
1047
+ * projection. Reported by the client initializer: the built-in stack always
1048
+ * registers it, while a caller-provided Reactor may lack the live
1049
+ * registration capability. Consumers of reference evidence must fail closed
1050
+ * when it is unavailable.
1051
+ */
1052
+ type AttachmentReferenceProjectionCapability = {
1053
+ status: "available";
1054
+ } | {
1055
+ status: "unavailable";
1056
+ reason: "live-read-model-registration-unsupported" | "in-process-reactor-module-unavailable" | "initializer-did-not-report";
1057
+ };
1058
+ /**
1059
+ * Outcome of an attachment read authorization. `denied` intentionally covers
1060
+ * both an unreadable document and an absent document/ref relationship so the
1061
+ * route layer cannot leak which check failed. `projection-unavailable` means
1062
+ * the reference index is not being maintained in this composition; it is
1063
+ * returned before any document-authorization or reference lookup runs.
1064
+ */
1065
+ type AttachmentAccessResult = {
1066
+ kind: "allowed";
1067
+ documentId: CanonicalDocumentId;
1068
+ ref: AttachmentRef;
1069
+ } | {
1070
+ kind: "denied";
1071
+ } | {
1072
+ kind: "projection-unavailable";
1073
+ };
1074
+ interface AttachmentAccessRequest {
1075
+ documentId: string;
1076
+ attachmentRef: string;
1077
+ userAddress?: string;
1078
+ }
1079
+ interface IAttachmentAccessService {
1080
+ canReadAttachment(request: AttachmentAccessRequest): Promise<AttachmentAccessResult>;
1081
+ }
1082
+ /**
1083
+ * Composes document authorization with the projected document/ref
1084
+ * relationship. Order is fixed: validate ref, resolve the canonical document
1085
+ * id, check `canRead`, then check the reference index. A denied document
1086
+ * never reaches the reference reader, and the facade never touches
1087
+ * attachment metadata, storage backends, or presigners.
1088
+ */
1089
+ declare class AttachmentAccessService implements IAttachmentAccessService {
1090
+ private readonly resolveCanonicalId;
1091
+ private readonly authorization;
1092
+ private readonly references;
1093
+ private readonly projection;
1094
+ constructor(resolveCanonicalId: CanonicalDocumentIdResolver, authorization: IAuthorizationService, references: IAttachmentReferenceReader, projection: AttachmentReferenceProjectionCapability);
1095
+ canReadAttachment(request: AttachmentAccessRequest): Promise<AttachmentAccessResult>;
1096
+ }
1097
+ //#endregion
877
1098
  //#region src/types.d.ts
878
- interface IReactorProcessorHostModule extends IProcessorHostModule {
879
- client: IReactorClient;
1099
+ /**
1100
+ * Module hosts pass to processor factories: the reactor-level module plus the
1101
+ * attachment client, which shared and reactor cannot name.
1102
+ */
1103
+ interface IProcessorHostModule extends IReactorProcessorHostModuleBase {
880
1104
  attachments: IAttachmentClient;
881
1105
  }
1106
+ /** @deprecated Use `IProcessorHostModule`. */
1107
+ type IReactorProcessorHostModule = IProcessorHostModule;
882
1108
  type ReadinessGate = {
883
1109
  isReady: () => boolean;
884
1110
  markReady: () => void;
@@ -888,6 +1114,8 @@ type API = {
888
1114
  graphqlManager: GraphQLManager$1;
889
1115
  packages: IPackageManager;
890
1116
  attachments: AttachmentBuildResult;
1117
+ attachmentReferenceIndex: AttachmentReferenceIndexBuildResult; /** Document-authorized attachment read decisions; see AttachmentAccessService. */
1118
+ attachmentAccess: IAttachmentAccessService;
891
1119
  authService: AuthService | undefined;
892
1120
  /**
893
1121
  * Releases resources owned by the API: shuts down the GraphQL gateway,
@@ -902,13 +1130,10 @@ type ReactorModule = {
902
1130
  analyticsStore: IAnalyticsStore;
903
1131
  relationalDb: IRelationalDb$1;
904
1132
  };
905
- /** Per-drive factory after the host `module` has been applied once. */
906
- type ProcessorDriveFactory = (driveHeader: PHDocumentHeader) => ProcessorRecord[] | Promise<ProcessorRecord[]>;
907
- /**
908
- * Builds a per-drive factory from the host module (e.g. vetra `processorFactory`).
909
- * Shape: `(module) => (driveHeader) => ...`
910
- */
911
- type ProcessorFactoryBuilder = (module: IProcessorHostModule) => ProcessorDriveFactory | Promise<ProcessorDriveFactory>;
1133
+ /** @deprecated Use `ProcessorFactory`. */
1134
+ type ProcessorDriveFactory = ProcessorFactory;
1135
+ /** Builds a per-drive factory from the host module (e.g. vetra `processorFactory`). */
1136
+ type ProcessorFactoryBuilder = ProcessorFactoryBuilder$1<IProcessorHostModule>;
912
1137
  /** Multiple initializers per package name (e.g. Switchboard `processors` option). */
913
1138
  type Processor = ProcessorFactoryBuilder[];
914
1139
  //#endregion
@@ -955,6 +1180,7 @@ declare class HttpPackageLoader implements IPackageLoader {
955
1180
  */
956
1181
  private parsePackageSpec;
957
1182
  loadDocumentModels(packageSpec: string): Promise<DocumentModelModule[]>;
1183
+ loadUpgradeManifests(packageSpec: string): Promise<UpgradeManifest<readonly number[]>[]>;
958
1184
  loadSubgraphs(packageSpec: string): Promise<SubgraphClass$1[]>;
959
1185
  loadProcessors(packageSpec: string): Promise<ProcessorFactoryBuilder | null>;
960
1186
  /**
@@ -996,12 +1222,14 @@ interface PackageManagementServiceOptions {
996
1222
  defaultRegistryUrl?: string;
997
1223
  httpLoader?: HttpPackageLoader;
998
1224
  documentModelRegistry?: IDocumentModelRegistry;
1225
+ packageManager?: IPackageManager;
999
1226
  }
1000
1227
  declare class PackageManagementService {
1001
1228
  private readonly storage;
1002
1229
  private readonly defaultRegistryUrl?;
1003
1230
  private readonly httpLoader?;
1004
1231
  private readonly documentModelRegistry?;
1232
+ private readonly packageManager?;
1005
1233
  private readonly logger;
1006
1234
  private onModelsChanged?;
1007
1235
  private loadedModulesCache;
@@ -1074,7 +1302,27 @@ declare class PackagesSubgraph extends BaseSubgraph {
1074
1302
  }
1075
1303
  //#endregion
1076
1304
  //#region src/graphql/playground.d.ts
1077
- declare function renderGraphqlPlayground(url: string, query?: string, headers?: Record<string, string>): string;
1305
+ /**
1306
+ * The lz-compressed `explorerURLState` parameter carried by switchboard
1307
+ * explorer URLs: the JSON payload produced by
1308
+ * `buildDocumentSubgraphQuery` in `@powerhousedao/reactor-browser`,
1309
+ * `{ document, variables, headers? }` with `variables` and `headers`
1310
+ * already JSON-stringified.
1311
+ */
1312
+ interface ExplorerUrlState {
1313
+ /** The GraphQL query to prefill in GraphiQL. */
1314
+ query: string;
1315
+ /** JSON-stringified variables, as stored in the payload. */
1316
+ variables?: string;
1317
+ /** Request headers for the GraphiQL fetcher (e.g. Authorization). */
1318
+ headers?: Record<string, string>;
1319
+ }
1320
+ /**
1321
+ * Decodes an `explorerURLState` URL parameter. Returns `null` for anything
1322
+ * that is not a valid lz-compressed payload with a non-empty `document`.
1323
+ */
1324
+ declare function decodeExplorerUrlState(encoded: string): ExplorerUrlState | null;
1325
+ declare function renderGraphqlPlayground(url: string, query?: string, headers?: Record<string, string>, variables?: string): string;
1078
1326
  //#endregion
1079
1327
  //#region src/graphql/reactor/gen/graphql.d.ts
1080
1328
  type Maybe<T> = T | null | undefined;
@@ -1128,12 +1376,63 @@ type Action = {
1128
1376
  readonly timestampUtcMs: Scalars["String"]["output"];
1129
1377
  readonly type: Scalars["String"]["output"];
1130
1378
  };
1379
+ /**
1380
+ * One operation an authorization preflight predicts a verdict for.
1381
+ *
1382
+ * `input` is what a conditional grant reads, so a candidate standing for a
1383
+ * filled-in form carries that form's input. Omitting it predicts the verdict an
1384
+ * empty input earns, not the verdict the filled-in form will get.
1385
+ */
1386
+ type ActionCandidateInput = {
1387
+ readonly input?: InputMaybe<Scalars["JSONObject"]["input"]>;
1388
+ readonly scope: Scalars["String"]["input"];
1389
+ readonly type: Scalars["String"]["input"];
1390
+ };
1131
1391
  type ActionContext = {
1132
1392
  readonly signer?: Maybe<ReactorSigner>;
1133
1393
  };
1394
+ /**
1395
+ * An action's context, as a caller submits it.
1396
+ *
1397
+ * Declares every field `ActionContext` carries, because an input object rejects a
1398
+ * field it does not declare: an action stamped with the head it applies to - which
1399
+ * is what a signing client sends - is refused outright if these are missing, and
1400
+ * that refusal is a whole-request one, not a per-field one.
1401
+ *
1402
+ * `prevOpHash` and `prevOpIndex` are the scope head the action was composed
1403
+ * against. They are recorded rather than enforced; a signature is verified from
1404
+ * the params carried in its own tuple, which do not include them.
1405
+ */
1134
1406
  type ActionContextInput = {
1407
+ /** Covers replay of an operation that would otherwise be a no-op. */readonly nonce?: InputMaybe<Scalars["String"]["input"]>; /** The hash of the state the action applies to. */
1408
+ readonly prevOpHash?: InputMaybe<Scalars["String"]["input"]>; /** The index of the last operation in the scope the action applies to. */
1409
+ readonly prevOpIndex?: InputMaybe<Scalars["Int"]["input"]>;
1135
1410
  readonly signer?: InputMaybe<ReactorSignerInput>;
1136
1411
  };
1412
+ /**
1413
+ * One candidate's predicted verdict. `reason` carries the refusal a DENY is
1414
+ * recorded with, and is null on an ALLOW.
1415
+ */
1416
+ type ActionEvaluation = {
1417
+ readonly decision: AuthDecision;
1418
+ readonly reason?: Maybe<Scalars["String"]["output"]>;
1419
+ };
1420
+ /**
1421
+ * The predicted verdicts for a set of candidates, in the order they were given,
1422
+ * with the aggregates a caller branches on.
1423
+ *
1424
+ * The aggregates are redundant -- a verdict is binary -- and all four are returned
1425
+ * so a caller reads the one its question is phrased in rather than negating
1426
+ * another. Over no candidates every aggregate is false: nothing is allowed and
1427
+ * nothing is denied.
1428
+ */
1429
+ type ActionEvaluations = {
1430
+ readonly allAllowed: Scalars["Boolean"]["output"];
1431
+ readonly allDenied: Scalars["Boolean"]["output"];
1432
+ readonly anyAllowed: Scalars["Boolean"]["output"];
1433
+ readonly anyDenied: Scalars["Boolean"]["output"];
1434
+ readonly evaluations: ReadonlyArray<ActionEvaluation>;
1435
+ };
1137
1436
  type ActionInput = {
1138
1437
  readonly context?: InputMaybe<ActionContextInput>;
1139
1438
  readonly id: Scalars["String"]["input"];
@@ -1142,6 +1441,10 @@ type ActionInput = {
1142
1441
  readonly timestampUtcMs: Scalars["String"]["input"];
1143
1442
  readonly type: Scalars["String"]["input"];
1144
1443
  };
1444
+ declare enum AuthDecision {
1445
+ Allow = "ALLOW",
1446
+ Deny = "DENY"
1447
+ }
1145
1448
  type ChannelMeta = {
1146
1449
  readonly id: Scalars["String"]["output"];
1147
1450
  };
@@ -1152,6 +1455,12 @@ type DeadLetterInfo = {
1152
1455
  readonly branch: Scalars["String"]["output"];
1153
1456
  readonly documentId: Scalars["String"]["output"];
1154
1457
  readonly error: Scalars["String"]["output"];
1458
+ /**
1459
+ * How the origin classified the failure. A peer needs this to mirror the origin's
1460
+ * quarantine decision; without it a held auth operation would freeze the document
1461
+ * on the peer side while the origin kept syncing.
1462
+ */
1463
+ readonly errorType?: Maybe<Scalars["String"]["output"]>;
1155
1464
  readonly jobId: Scalars["String"]["output"];
1156
1465
  readonly operationCount: Scalars["Int"]["output"];
1157
1466
  readonly scopes: ReadonlyArray<Scalars["String"]["output"]>;
@@ -1211,7 +1520,11 @@ type JobInfo = {
1211
1520
  readonly createdAt: Scalars["DateTime"]["output"];
1212
1521
  readonly error?: Maybe<Scalars["String"]["output"]>;
1213
1522
  readonly id: Scalars["String"]["output"];
1214
- readonly result: Scalars["JSONObject"]["output"];
1523
+ /**
1524
+ * What the job produced, once it has produced anything. Null until then, which
1525
+ * is the state every job is in when it is handed back from a submission.
1526
+ */
1527
+ readonly result?: Maybe<Scalars["JSONObject"]["output"]>;
1215
1528
  readonly status: Scalars["String"]["output"];
1216
1529
  };
1217
1530
  type MoveRelationshipResult = {
@@ -1224,8 +1537,30 @@ type Mutation = {
1224
1537
  readonly createEmptyDocument: PhDocument;
1225
1538
  readonly deleteDocument: Scalars["Boolean"]["output"];
1226
1539
  readonly deleteDocuments: Scalars["Boolean"]["output"];
1227
- readonly moveRelationship: MoveRelationshipResult;
1228
- readonly mutateDocument: PhDocument;
1540
+ /**
1541
+ * Applies actions to a document and waits for the result.
1542
+ *
1543
+ * Each action is coerced against `ActionInput`, so one missing a field the wire
1544
+ * declares is refused before any work starts. The id in particular: it is hashed
1545
+ * into the operation id and replay dedupes by it, so an action without one is
1546
+ * stored under an operation id shared by every id-less operation on the same
1547
+ * document, scope and branch.
1548
+ *
1549
+ * Named for `IReactorClient.execute`, which this is the wire form of. `branch`
1550
+ * defaults to `main`.
1551
+ */
1552
+ readonly execute: PhDocument;
1553
+ /**
1554
+ * Submits actions to a document and returns the job that will apply them.
1555
+ *
1556
+ * Coerced exactly as `execute` is, so a malformed action is refused here rather
1557
+ * than surfacing later as a failed job. Returns the job rather than only its id,
1558
+ * so a caller has the status and the creation time it would otherwise have to
1559
+ * ask for; `result` is null until the job produces one.
1560
+ */
1561
+ readonly executeAsync: JobInfo;
1562
+ readonly moveRelationship: MoveRelationshipResult; /** @deprecated Use execute. Actions here are untyped, so a malformed one is refused by a hand-written check rather than by the schema, and `view.scopes` is accepted but ignored. */
1563
+ readonly mutateDocument: PhDocument; /** @deprecated Use executeAsync, which is typed and returns the job rather than only its id. */
1229
1564
  readonly mutateDocumentAsync: Scalars["String"]["output"];
1230
1565
  readonly pushSyncEnvelopes: Scalars["Boolean"]["output"];
1231
1566
  readonly removeRelationship: PhDocument;
@@ -1255,6 +1590,16 @@ type MutationDeleteDocumentsArgs = {
1255
1590
  identifiers: ReadonlyArray<Scalars["String"]["input"]>;
1256
1591
  propagate?: InputMaybe<PropagationMode>;
1257
1592
  };
1593
+ type MutationExecuteArgs = {
1594
+ actions: ReadonlyArray<ActionInput>;
1595
+ branch?: InputMaybe<Scalars["String"]["input"]>;
1596
+ documentIdentifier: Scalars["String"]["input"];
1597
+ };
1598
+ type MutationExecuteAsyncArgs = {
1599
+ actions: ReadonlyArray<ActionInput>;
1600
+ branch?: InputMaybe<Scalars["String"]["input"]>;
1601
+ documentIdentifier: Scalars["String"]["input"];
1602
+ };
1258
1603
  type MutationMoveRelationshipArgs = {
1259
1604
  branch?: InputMaybe<Scalars["String"]["input"]>;
1260
1605
  relationshipType: Scalars["String"]["input"];
@@ -1310,6 +1655,7 @@ type OperationContextInput = {
1310
1655
  };
1311
1656
  type OperationInput = {
1312
1657
  readonly action: ActionInput;
1658
+ readonly deniedReason?: InputMaybe<Scalars["String"]["input"]>;
1313
1659
  readonly error?: InputMaybe<Scalars["String"]["input"]>;
1314
1660
  readonly hash: Scalars["String"]["input"];
1315
1661
  readonly id?: InputMaybe<Scalars["String"]["input"]>;
@@ -1378,8 +1724,47 @@ type Query = {
1378
1724
  readonly documentModels: DocumentModelResultPage;
1379
1725
  readonly documentOperations: ReactorOperationResultPage;
1380
1726
  readonly documentOutgoingRelationships: PhDocumentResultPage;
1727
+ /**
1728
+ * Predicts whether the calling subject would be admitted to execute each of a
1729
+ * set of candidate operations, without submitting any of them. A UI asks this to
1730
+ * disable a control rather than offer an action that fails on submit.
1731
+ *
1732
+ * The answer is a prediction, not a promise:
1733
+ *
1734
+ * - Real admission compiles an append condition over everything it read and the
1735
+ * store enforces it at write time. A preflight reads no future, so a policy
1736
+ * change landing between this answer and the submit changes the verdict. The
1737
+ * submit path stays the only authority.
1738
+ * - The verdict is evaluated at the stream heads, so it is correct for a
1739
+ * candidate about to be submitted. A backdated submission is out of contract;
1740
+ * the reactor decides that one by position.
1741
+ * - A candidate whose verdict depends on its input has to carry that input, since
1742
+ * a conditional grant reads it.
1743
+ *
1744
+ * The subject is the authenticated caller and cannot be named in the request:
1745
+ * answering for an arbitrary subject would disclose what a policy grants
1746
+ * somebody else. It carries both the caller's address and the did:key of the app
1747
+ * instance whose token authenticated the request, so a policy naming either
1748
+ * matches the same principal the write path presents.
1749
+ *
1750
+ * Requires the reactor's authEnforcement feature flag. Without it the reactor
1751
+ * holds no decision model, so this fails with extensions.code
1752
+ * AUTH_EVALUATION_UNSUPPORTED rather than guessing.
1753
+ */
1754
+ readonly evaluateActions: ActionEvaluations;
1381
1755
  readonly findDocuments: PhDocumentResultPage;
1382
1756
  readonly jobStatus?: Maybe<JobInfo>;
1757
+ /**
1758
+ * Polls for sync envelopes from a channel.
1759
+ *
1760
+ * An operation stored before the API required an action id cannot be
1761
+ * represented by this schema, and rather than serving a partial response beside
1762
+ * a bare non-null violation, this fails with extensions.code
1763
+ * MALFORMED_STORED_OPERATION naming the operation. That code means the failure
1764
+ * is worth polling through: the document holding the operation needs repairing,
1765
+ * but the channel serves every other document, and a peer that stopped polling
1766
+ * would stop receiving those too.
1767
+ */
1383
1768
  readonly pollSyncEnvelopes: PollSyncEnvelopesResult;
1384
1769
  };
1385
1770
  type QueryDocumentArgs = {
@@ -1406,6 +1791,11 @@ type QueryDocumentOutgoingRelationshipsArgs = {
1406
1791
  sourceIdentifier: Scalars["String"]["input"];
1407
1792
  view?: InputMaybe<ViewFilterInput>;
1408
1793
  };
1794
+ type QueryEvaluateActionsArgs = {
1795
+ branch?: InputMaybe<Scalars["String"]["input"]>;
1796
+ candidates: ReadonlyArray<ActionCandidateInput>;
1797
+ documentIdentifier: Scalars["String"]["input"];
1798
+ };
1409
1799
  type QueryFindDocumentsArgs = {
1410
1800
  paging?: InputMaybe<PagingInput>;
1411
1801
  search?: InputMaybe<SearchFilterInput>;
@@ -1421,6 +1811,7 @@ type QueryPollSyncEnvelopesArgs = {
1421
1811
  };
1422
1812
  type ReactorOperation = {
1423
1813
  readonly action: Action;
1814
+ readonly deniedReason?: Maybe<Scalars["String"]["output"]>;
1424
1815
  readonly error?: Maybe<Scalars["String"]["output"]>;
1425
1816
  readonly hash: Scalars["String"]["output"];
1426
1817
  readonly id?: Maybe<Scalars["String"]["output"]>;
@@ -1615,6 +2006,7 @@ type GetDocumentWithOperationsQuery = {
1615
2006
  readonly hash: string;
1616
2007
  readonly skip: number;
1617
2008
  readonly error?: string | null | undefined;
2009
+ readonly deniedReason?: string | null | undefined;
1618
2010
  readonly id?: string | null | undefined;
1619
2011
  readonly action: {
1620
2012
  readonly id: string;
@@ -1742,6 +2134,7 @@ type GetDocumentOperationsQuery = {
1742
2134
  readonly hash: string;
1743
2135
  readonly skip: number;
1744
2136
  readonly error?: string | null | undefined;
2137
+ readonly deniedReason?: string | null | undefined;
1745
2138
  readonly id?: string | null | undefined;
1746
2139
  readonly action: {
1747
2140
  readonly id: string;
@@ -1774,12 +2167,29 @@ type GetJobStatusQuery = {
1774
2167
  readonly jobStatus?: {
1775
2168
  readonly id: string;
1776
2169
  readonly status: string;
1777
- readonly result: NonNullable<unknown>;
2170
+ readonly result?: NonNullable<unknown> | null | undefined;
1778
2171
  readonly error?: string | null | undefined;
1779
2172
  readonly createdAt: string | Date;
1780
2173
  readonly completedAt?: string | Date | null | undefined;
1781
2174
  } | null | undefined;
1782
2175
  };
2176
+ type EvaluateActionsQueryVariables = Exact<{
2177
+ documentIdentifier: Scalars["String"]["input"];
2178
+ branch?: InputMaybe<Scalars["String"]["input"]>;
2179
+ candidates: ReadonlyArray<ActionCandidateInput>;
2180
+ }>;
2181
+ type EvaluateActionsQuery = {
2182
+ readonly evaluateActions: {
2183
+ readonly allAllowed: boolean;
2184
+ readonly anyAllowed: boolean;
2185
+ readonly allDenied: boolean;
2186
+ readonly anyDenied: boolean;
2187
+ readonly evaluations: ReadonlyArray<{
2188
+ readonly decision: AuthDecision;
2189
+ readonly reason?: string | null | undefined;
2190
+ }>;
2191
+ };
2192
+ };
1783
2193
  type CreateDocumentMutationVariables = Exact<{
1784
2194
  document: Scalars["JSONObject"]["input"];
1785
2195
  parentIdentifier?: InputMaybe<Scalars["String"]["input"]>;
@@ -1820,8 +2230,8 @@ type CreateEmptyDocumentMutation = {
1820
2230
  };
1821
2231
  type MutateDocumentMutationVariables = Exact<{
1822
2232
  documentIdentifier: Scalars["String"]["input"];
1823
- actions: ReadonlyArray<Scalars["JSONObject"]["input"]>;
1824
- view?: InputMaybe<ViewFilterInput>;
2233
+ actions: ReadonlyArray<ActionInput>;
2234
+ branch?: InputMaybe<Scalars["String"]["input"]>;
1825
2235
  }>;
1826
2236
  type MutateDocumentMutation = {
1827
2237
  readonly mutateDocument: {
@@ -1840,11 +2250,18 @@ type MutateDocumentMutation = {
1840
2250
  };
1841
2251
  type MutateDocumentAsyncMutationVariables = Exact<{
1842
2252
  documentIdentifier: Scalars["String"]["input"];
1843
- actions: ReadonlyArray<Scalars["JSONObject"]["input"]>;
1844
- view?: InputMaybe<ViewFilterInput>;
2253
+ actions: ReadonlyArray<ActionInput>;
2254
+ branch?: InputMaybe<Scalars["String"]["input"]>;
1845
2255
  }>;
1846
2256
  type MutateDocumentAsyncMutation = {
1847
- readonly mutateDocumentAsync: string;
2257
+ readonly mutateDocumentAsync: {
2258
+ readonly id: string;
2259
+ readonly status: string;
2260
+ readonly result?: NonNullable<unknown> | null | undefined;
2261
+ readonly error?: string | null | undefined;
2262
+ readonly createdAt: string | Date;
2263
+ readonly completedAt?: string | Date | null | undefined;
2264
+ };
1848
2265
  };
1849
2266
  type RenameDocumentMutationVariables = Exact<{
1850
2267
  documentIdentifier: Scalars["String"]["input"];
@@ -2039,6 +2456,7 @@ type PollSyncEnvelopesQuery = {
2039
2456
  readonly hash: string;
2040
2457
  readonly skip: number;
2041
2458
  readonly error?: string | null | undefined;
2459
+ readonly deniedReason?: string | null | undefined;
2042
2460
  readonly id?: string | null | undefined;
2043
2461
  readonly action: {
2044
2462
  readonly id: string;
@@ -2078,6 +2496,7 @@ type PollSyncEnvelopesQuery = {
2078
2496
  readonly deadLetters: ReadonlyArray<{
2079
2497
  readonly documentId: string;
2080
2498
  readonly error: string;
2499
+ readonly errorType?: string | null | undefined;
2081
2500
  }>;
2082
2501
  };
2083
2502
  };
@@ -2123,9 +2542,13 @@ type DirectiveResolverFn<TResult = Record<PropertyKey, never>, TParent = Record<
2123
2542
  /** Mapping between all available schema types and the resolvers types */
2124
2543
  type ResolversTypes = ResolversObject<{
2125
2544
  Action: ResolverTypeWrapper<Action>;
2545
+ ActionCandidateInput: ActionCandidateInput;
2126
2546
  ActionContext: ResolverTypeWrapper<ActionContext>;
2127
2547
  ActionContextInput: ActionContextInput;
2548
+ ActionEvaluation: ResolverTypeWrapper<ActionEvaluation>;
2549
+ ActionEvaluations: ResolverTypeWrapper<ActionEvaluations>;
2128
2550
  ActionInput: ActionInput;
2551
+ AuthDecision: AuthDecision;
2129
2552
  Boolean: ResolverTypeWrapper<Scalars["Boolean"]["output"]>;
2130
2553
  ChannelMeta: ResolverTypeWrapper<ChannelMeta>;
2131
2554
  ChannelMetaInput: ChannelMetaInput;
@@ -2181,8 +2604,11 @@ type ResolversTypes = ResolversObject<{
2181
2604
  /** Mapping between all available schema types and the resolvers parents */
2182
2605
  type ResolversParentTypes = ResolversObject<{
2183
2606
  Action: Action;
2607
+ ActionCandidateInput: ActionCandidateInput;
2184
2608
  ActionContext: ActionContext;
2185
2609
  ActionContextInput: ActionContextInput;
2610
+ ActionEvaluation: ActionEvaluation;
2611
+ ActionEvaluations: ActionEvaluations;
2186
2612
  ActionInput: ActionInput;
2187
2613
  Boolean: Scalars["Boolean"]["output"];
2188
2614
  ChannelMeta: ChannelMeta;
@@ -2244,6 +2670,17 @@ type ActionResolvers<ContextType = Context, ParentType extends ResolversParentTy
2244
2670
  type ActionContextResolvers<ContextType = Context, ParentType extends ResolversParentTypes["ActionContext"] = ResolversParentTypes["ActionContext"]> = ResolversObject<{
2245
2671
  signer?: Resolver<Maybe<ResolversTypes["ReactorSigner"]>, ParentType, ContextType>;
2246
2672
  }>;
2673
+ type ActionEvaluationResolvers<ContextType = Context, ParentType extends ResolversParentTypes["ActionEvaluation"] = ResolversParentTypes["ActionEvaluation"]> = ResolversObject<{
2674
+ decision?: Resolver<ResolversTypes["AuthDecision"], ParentType, ContextType>;
2675
+ reason?: Resolver<Maybe<ResolversTypes["String"]>, ParentType, ContextType>;
2676
+ }>;
2677
+ type ActionEvaluationsResolvers<ContextType = Context, ParentType extends ResolversParentTypes["ActionEvaluations"] = ResolversParentTypes["ActionEvaluations"]> = ResolversObject<{
2678
+ allAllowed?: Resolver<ResolversTypes["Boolean"], ParentType, ContextType>;
2679
+ allDenied?: Resolver<ResolversTypes["Boolean"], ParentType, ContextType>;
2680
+ anyAllowed?: Resolver<ResolversTypes["Boolean"], ParentType, ContextType>;
2681
+ anyDenied?: Resolver<ResolversTypes["Boolean"], ParentType, ContextType>;
2682
+ evaluations?: Resolver<ReadonlyArray<ResolversTypes["ActionEvaluation"]>, ParentType, ContextType>;
2683
+ }>;
2247
2684
  type ChannelMetaResolvers<ContextType = Context, ParentType extends ResolversParentTypes["ChannelMeta"] = ResolversParentTypes["ChannelMeta"]> = ResolversObject<{
2248
2685
  id?: Resolver<ResolversTypes["String"], ParentType, ContextType>;
2249
2686
  }>;
@@ -2254,6 +2691,7 @@ type DeadLetterInfoResolvers<ContextType = Context, ParentType extends Resolvers
2254
2691
  branch?: Resolver<ResolversTypes["String"], ParentType, ContextType>;
2255
2692
  documentId?: Resolver<ResolversTypes["String"], ParentType, ContextType>;
2256
2693
  error?: Resolver<ResolversTypes["String"], ParentType, ContextType>;
2694
+ errorType?: Resolver<Maybe<ResolversTypes["String"]>, ParentType, ContextType>;
2257
2695
  jobId?: Resolver<ResolversTypes["String"], ParentType, ContextType>;
2258
2696
  operationCount?: Resolver<ResolversTypes["Int"], ParentType, ContextType>;
2259
2697
  scopes?: Resolver<ReadonlyArray<ResolversTypes["String"]>, ParentType, ContextType>;
@@ -2299,7 +2737,7 @@ type JobInfoResolvers<ContextType = Context, ParentType extends ResolversParentT
2299
2737
  createdAt?: Resolver<ResolversTypes["DateTime"], ParentType, ContextType>;
2300
2738
  error?: Resolver<Maybe<ResolversTypes["String"]>, ParentType, ContextType>;
2301
2739
  id?: Resolver<ResolversTypes["String"], ParentType, ContextType>;
2302
- result?: Resolver<ResolversTypes["JSONObject"], ParentType, ContextType>;
2740
+ result?: Resolver<Maybe<ResolversTypes["JSONObject"]>, ParentType, ContextType>;
2303
2741
  status?: Resolver<ResolversTypes["String"], ParentType, ContextType>;
2304
2742
  }>;
2305
2743
  type MoveRelationshipResultResolvers<ContextType = Context, ParentType extends ResolversParentTypes["MoveRelationshipResult"] = ResolversParentTypes["MoveRelationshipResult"]> = ResolversObject<{
@@ -2312,6 +2750,8 @@ type MutationResolvers<ContextType = Context, ParentType extends ResolversParent
2312
2750
  createEmptyDocument?: Resolver<ResolversTypes["PHDocument"], ParentType, ContextType, RequireFields<MutationCreateEmptyDocumentArgs, "documentType">>;
2313
2751
  deleteDocument?: Resolver<ResolversTypes["Boolean"], ParentType, ContextType, RequireFields<MutationDeleteDocumentArgs, "identifier">>;
2314
2752
  deleteDocuments?: Resolver<ResolversTypes["Boolean"], ParentType, ContextType, RequireFields<MutationDeleteDocumentsArgs, "identifiers">>;
2753
+ execute?: Resolver<ResolversTypes["PHDocument"], ParentType, ContextType, RequireFields<MutationExecuteArgs, "actions" | "documentIdentifier">>;
2754
+ executeAsync?: Resolver<ResolversTypes["JobInfo"], ParentType, ContextType, RequireFields<MutationExecuteAsyncArgs, "actions" | "documentIdentifier">>;
2315
2755
  moveRelationship?: Resolver<ResolversTypes["MoveRelationshipResult"], ParentType, ContextType, RequireFields<MutationMoveRelationshipArgs, "relationshipType" | "sourceParentIdentifier" | "targetIdentifier" | "targetParentIdentifier">>;
2316
2756
  mutateDocument?: Resolver<ResolversTypes["PHDocument"], ParentType, ContextType, RequireFields<MutationMutateDocumentArgs, "actions" | "documentIdentifier">>;
2317
2757
  mutateDocumentAsync?: Resolver<ResolversTypes["String"], ParentType, ContextType, RequireFields<MutationMutateDocumentAsyncArgs, "actions" | "documentIdentifier">>;
@@ -2363,12 +2803,14 @@ type QueryResolvers<ContextType = Context, ParentType extends ResolversParentTyp
2363
2803
  documentModels?: Resolver<ResolversTypes["DocumentModelResultPage"], ParentType, ContextType, Partial<QueryDocumentModelsArgs>>;
2364
2804
  documentOperations?: Resolver<ResolversTypes["ReactorOperationResultPage"], ParentType, ContextType, RequireFields<QueryDocumentOperationsArgs, "filter">>;
2365
2805
  documentOutgoingRelationships?: Resolver<ResolversTypes["PHDocumentResultPage"], ParentType, ContextType, RequireFields<QueryDocumentOutgoingRelationshipsArgs, "relationshipType" | "sourceIdentifier">>;
2806
+ evaluateActions?: Resolver<ResolversTypes["ActionEvaluations"], ParentType, ContextType, RequireFields<QueryEvaluateActionsArgs, "candidates" | "documentIdentifier">>;
2366
2807
  findDocuments?: Resolver<ResolversTypes["PHDocumentResultPage"], ParentType, ContextType, Partial<QueryFindDocumentsArgs>>;
2367
2808
  jobStatus?: Resolver<Maybe<ResolversTypes["JobInfo"]>, ParentType, ContextType, RequireFields<QueryJobStatusArgs, "jobId">>;
2368
2809
  pollSyncEnvelopes?: Resolver<ResolversTypes["PollSyncEnvelopesResult"], ParentType, ContextType, RequireFields<QueryPollSyncEnvelopesArgs, "channelId" | "outboxAck" | "outboxLatest">>;
2369
2810
  }>;
2370
2811
  type ReactorOperationResolvers<ContextType = Context, ParentType extends ResolversParentTypes["ReactorOperation"] = ResolversParentTypes["ReactorOperation"]> = ResolversObject<{
2371
2812
  action?: Resolver<ResolversTypes["Action"], ParentType, ContextType>;
2813
+ deniedReason?: Resolver<Maybe<ResolversTypes["String"]>, ParentType, ContextType>;
2372
2814
  error?: Resolver<Maybe<ResolversTypes["String"]>, ParentType, ContextType>;
2373
2815
  hash?: Resolver<ResolversTypes["String"], ParentType, ContextType>;
2374
2816
  id?: Resolver<Maybe<ResolversTypes["String"]>, ParentType, ContextType>;
@@ -2425,6 +2867,8 @@ type TouchChannelResultResolvers<ContextType = Context, ParentType extends Resol
2425
2867
  type Resolvers<ContextType = Context> = ResolversObject<{
2426
2868
  Action?: ActionResolvers<ContextType>;
2427
2869
  ActionContext?: ActionContextResolvers<ContextType>;
2870
+ ActionEvaluation?: ActionEvaluationResolvers<ContextType>;
2871
+ ActionEvaluations?: ActionEvaluationsResolvers<ContextType>;
2428
2872
  ChannelMeta?: ChannelMetaResolvers<ContextType>;
2429
2873
  DateTime?: GraphQLScalarType;
2430
2874
  DeadLetterInfo?: DeadLetterInfoResolvers<ContextType>;
@@ -2459,9 +2903,11 @@ type Properties<T> = Required<{ [K in keyof T]: z$1.ZodType<T[K]> }>;
2459
2903
  type definedNonNullAny = {};
2460
2904
  declare const isDefinedNonNullAny: (v: any) => v is definedNonNullAny;
2461
2905
  declare const definedNonNullAnySchema: z$1.ZodAny & z$1.ZodType<definedNonNullAny, any, z$1.core.$ZodTypeInternals<definedNonNullAny, any>>;
2906
+ declare const AuthDecisionSchema: z$1.ZodEnum<typeof AuthDecision>;
2462
2907
  declare const DocumentChangeTypeSchema: z$1.ZodEnum<typeof DocumentChangeType>;
2463
2908
  declare const PropagationModeSchema: z$1.ZodEnum<typeof PropagationMode>;
2464
2909
  declare const SyncEnvelopeTypeSchema: z$1.ZodEnum<typeof SyncEnvelopeType>;
2910
+ declare function ActionCandidateInputSchema(): z$1.ZodObject<Properties<ActionCandidateInput>>;
2465
2911
  declare function ActionContextInputSchema(): z$1.ZodObject<Properties<ActionContextInput>>;
2466
2912
  declare function ActionInputSchema(): z$1.ZodObject<Properties<ActionInput>>;
2467
2913
  declare function ChannelMetaInputSchema(): z$1.ZodObject<Properties<ChannelMetaInput>>;
@@ -2489,6 +2935,7 @@ declare const GetDocumentIncomingRelationshipsDocument: DocumentNode;
2489
2935
  declare const FindDocumentsDocument: DocumentNode;
2490
2936
  declare const GetDocumentOperationsDocument: DocumentNode;
2491
2937
  declare const GetJobStatusDocument: DocumentNode;
2938
+ declare const EvaluateActionsDocument: DocumentNode;
2492
2939
  declare const CreateDocumentDocument: DocumentNode;
2493
2940
  declare const CreateEmptyDocumentDocument: DocumentNode;
2494
2941
  declare const MutateDocumentDocument: DocumentNode;
@@ -2515,6 +2962,7 @@ declare function getSdk<C>(requester: Requester<C>): {
2515
2962
  FindDocuments(variables?: FindDocumentsQueryVariables, options?: C): Promise<FindDocumentsQuery>;
2516
2963
  GetDocumentOperations(variables: GetDocumentOperationsQueryVariables, options?: C): Promise<GetDocumentOperationsQuery>;
2517
2964
  GetJobStatus(variables: GetJobStatusQueryVariables, options?: C): Promise<GetJobStatusQuery>;
2965
+ EvaluateActions(variables: EvaluateActionsQueryVariables, options?: C): Promise<EvaluateActionsQuery>;
2518
2966
  CreateDocument(variables: CreateDocumentMutationVariables, options?: C): Promise<CreateDocumentMutation>;
2519
2967
  CreateEmptyDocument(variables: CreateEmptyDocumentMutationVariables, options?: C): Promise<CreateEmptyDocumentMutation>;
2520
2968
  MutateDocument(variables: MutateDocumentMutationVariables, options?: C): Promise<MutateDocumentMutation>;
@@ -2577,6 +3025,11 @@ declare function createReactorGraphQLClient(url: string, fetchImpl?: FetchLike,
2577
3025
  GetJobStatus(variables: Exact<{
2578
3026
  jobId: Scalars["String"]["input"];
2579
3027
  }>, options?: {} | undefined): Promise<GetJobStatusQuery>;
3028
+ EvaluateActions(variables: Exact<{
3029
+ documentIdentifier: Scalars["String"]["input"];
3030
+ branch?: InputMaybe<Scalars["String"]["input"]>;
3031
+ candidates: ReadonlyArray<ActionCandidateInput>;
3032
+ }>, options?: {} | undefined): Promise<EvaluateActionsQuery>;
2580
3033
  CreateDocument(variables: Exact<{
2581
3034
  document: Scalars["JSONObject"]["input"];
2582
3035
  parentIdentifier?: InputMaybe<Scalars["String"]["input"]>;
@@ -2587,13 +3040,13 @@ declare function createReactorGraphQLClient(url: string, fetchImpl?: FetchLike,
2587
3040
  }>, options?: {} | undefined): Promise<CreateEmptyDocumentMutation>;
2588
3041
  MutateDocument(variables: Exact<{
2589
3042
  documentIdentifier: Scalars["String"]["input"];
2590
- actions: ReadonlyArray<Scalars["JSONObject"]["input"]>;
2591
- view?: InputMaybe<ViewFilterInput>;
3043
+ actions: ReadonlyArray<ActionInput>;
3044
+ branch?: InputMaybe<Scalars["String"]["input"]>;
2592
3045
  }>, options?: {} | undefined): Promise<MutateDocumentMutation>;
2593
3046
  MutateDocumentAsync(variables: Exact<{
2594
3047
  documentIdentifier: Scalars["String"]["input"];
2595
- actions: ReadonlyArray<Scalars["JSONObject"]["input"]>;
2596
- view?: InputMaybe<ViewFilterInput>;
3048
+ actions: ReadonlyArray<ActionInput>;
3049
+ branch?: InputMaybe<Scalars["String"]["input"]>;
2597
3050
  }>, options?: {} | undefined): Promise<MutateDocumentAsyncMutation>;
2598
3051
  RenameDocument(variables: Exact<{
2599
3052
  documentIdentifier: Scalars["String"]["input"];
@@ -2708,6 +3161,7 @@ declare class ImportPackageLoader implements IPackageLoader {
2708
3161
  private readonly logger;
2709
3162
  readonly name = "ImportPackageLoader";
2710
3163
  loadDocumentModels(identifier: string): Promise<DocumentModelModule[]>;
3164
+ loadUpgradeManifests(identifier: string): Promise<UpgradeManifest<readonly number[]>[]>;
2711
3165
  loadSubgraphs(identifier: string): Promise<SubgraphClass$1[]>;
2712
3166
  loadProcessors(identifier: string): Promise<ProcessorFactoryBuilder | null>;
2713
3167
  }
@@ -2727,11 +3181,13 @@ declare class ImportPackageLoader implements IPackageLoader {
2727
3181
  */
2728
3182
  declare function isExpectedLoaderMiss(error: unknown, pkg: string): boolean;
2729
3183
  declare function getUniqueDocumentModels(...documentModels: readonly (readonly DocumentModelModule<any>[])[]): DocumentModelModule[];
3184
+ declare function getUniqueUpgradeManifests(...upgradeManifests: readonly (readonly UpgradeManifest<readonly number[]>[])[]): UpgradeManifest<readonly number[]>[];
2730
3185
  declare class PackageManager implements IPackageManager {
2731
3186
  protected options: IPackageManagerOptions;
2732
3187
  private readonly logger;
2733
3188
  private loaders;
2734
3189
  private docModelsMap;
3190
+ private upgradeManifestsMap;
2735
3191
  private subgraphsMap;
2736
3192
  private processorMap;
2737
3193
  private configWatcher;
@@ -2741,10 +3197,17 @@ declare class PackageManager implements IPackageManager {
2741
3197
  init(): Promise<PackageManagerResult>;
2742
3198
  private loadPackages;
2743
3199
  private loadDocumentModels;
3200
+ /** Upgrade manifests currently loaded across all packages, one per type. */
3201
+ getUniqueUpgradeManifests(): UpgradeManifest<readonly number[]>[];
3202
+ private loadUpgradeManifests;
2744
3203
  private loadSubgraphs;
2745
3204
  private loadProcessors;
2746
3205
  private maybeWarnAllLoadersFailed;
2747
3206
  private updateDocumentModelsForPackage;
3207
+ private updateSubgraphsForPackage;
3208
+ private updateProcessorsForPackage;
3209
+ /** Debounced per key so repeated subscribePackages calls reuse one timer. */
3210
+ private getDebouncedUpdateCallback;
2748
3211
  private subscribePackages;
2749
3212
  private getAllPackageNames;
2750
3213
  private getPackageNamesFromConfigFile;
@@ -2752,11 +3215,39 @@ declare class PackageManager implements IPackageManager {
2752
3215
  private updatePackagesMap;
2753
3216
  private updateSubgraphsMap;
2754
3217
  private updateProcessorsMap;
3218
+ /**
3219
+ * Remove `pkg` from all package maps and emit the change events, tearing
3220
+ * down everything the package registered (subgraphs, processors, document
3221
+ * models). For an uninstalled package no loader can serve it again, so
3222
+ * nothing can re-add it.
3223
+ */
3224
+ removePackage(pkg: string): void;
2755
3225
  onDocumentModelsChange(handler: (documentModels: Record<string, DocumentModelModule[]>) => void): void;
2756
3226
  onSubgraphsChange(handler: (subgraphs: Map<string, SubgraphClass$1[]>) => void): void;
2757
3227
  onProcessorsChange(handler: (processors: Map<string, Processor$1>) => void): void;
2758
3228
  }
2759
3229
  //#endregion
3230
+ //#region src/services/renown-config.d.ts
3231
+ /** Where the credential check reads from: a remote Renown or Switchboard
3232
+ * instance, or this switchboard's own renown read model. */
3233
+ type RenownSource = NonNullable<PHReactorRenown["source"]>;
3234
+ /** The `auth.renown` config block: which Renown instance to authenticate
3235
+ * against, before env overrides are applied. */
3236
+ type RenownConfig = PHReactorRenown;
3237
+ /** Resolved renown coordinates. `url` also drives this reactor's own identity,
3238
+ * so it stays meaningful when `source` is "self". */
3239
+ type ResolvedRenownConfig = {
3240
+ source: RenownSource;
3241
+ url: string | undefined;
3242
+ switchboardUrl: string | undefined;
3243
+ };
3244
+ /** Reading credentials from this reactor's own read model needs a host-supplied
3245
+ * verifier: core has no idea which subgraph serves that read model. */
3246
+ declare function assertCredentialVerifierForSource(source: RenownSource, hasVerifier: boolean): void;
3247
+ /** Resolve `auth.renown`; RENOWN_SOURCE / RENOWN_URL / SWITCHBOARD_URL win
3248
+ * over the config file, which wins over the SDK defaults. */
3249
+ declare function resolveRenownConfig(configured: RenownConfig | undefined, env: NodeJS.ProcessEnv, logger: ILogger): ResolvedRenownConfig;
3250
+ //#endregion
2760
3251
  //#region src/server.d.ts
2761
3252
  type Options = {
2762
3253
  port?: number;
@@ -2774,7 +3265,20 @@ type Options = {
2774
3265
  auth?: {
2775
3266
  enabled: boolean;
2776
3267
  admins: string[];
3268
+ /** Read the bearer and populate `ctx.user` independently of `enabled`.
3269
+ * Defaults to `enabled`; `RESOLVE_CALLER_IDENTITY` overrides either. */
3270
+ resolveIdentity?: boolean;
3271
+ /** Reject anonymous callers with a 401 before any subgraph sees the
3272
+ * request. Off by default; `REQUIRE_AUTHENTICATED_CALLER` overrides.
3273
+ * Requires identity resolution to be on — refused at boot without it. */
3274
+ requireAuthenticatedCaller?: boolean;
2777
3275
  };
3276
+ /** Renown coordinates the host already resolved, used verbatim instead of
3277
+ * resolving `auth.renown` and the env again (which would warn twice). */
3278
+ renown?: ResolvedRenownConfig;
3279
+ /** Credential check replacing the built-in remote Renown one; required when
3280
+ * the resolved source is "self" (see assertCredentialVerifierForSource). */
3281
+ verifyCredential?: CredentialVerifier;
2778
3282
  https?: {
2779
3283
  keyPath: string;
2780
3284
  certPath: string;
@@ -2811,7 +3315,22 @@ declare function assertAuthRequiredForDocumentPermissions(authEnabled: boolean,
2811
3315
  * opt-in: it removes the only binding between a token's claimed address and its
2812
3316
  * signing key. Fail-closed — unset NODE_ENV counts as production.
2813
3317
  */
2814
- declare function assertSkipCredentialVerificationAllowed(authEnabled: boolean, skipCredentialVerification: boolean, env: NodeJS.ProcessEnv): void;
3318
+ declare function assertSkipCredentialVerificationAllowed(resolvesCallerIdentity: boolean, skipCredentialVerification: boolean, env: NodeJS.ProcessEnv): void;
3319
+ /**
3320
+ * Requiring an authenticated caller requires identity resolution to exist at
3321
+ * all: with neither AUTH_ENABLED nor RESOLVE_CALLER_IDENTITY the middleware
3322
+ * never reads a bearer, no `user` is ever resolved, and the
3323
+ * require-authenticated-caller middleware would reject every caller —
3324
+ * authenticated ones included. Refuse to boot rather than run broken.
3325
+ */
3326
+ declare function assertRequireAuthenticatedCallerAllowed(requireAuthenticatedCaller: boolean, resolvesCallerIdentity: boolean): void;
3327
+ /**
3328
+ * The GraphiQL explorer page's mount prefix. `path.posix.join` normalizes the
3329
+ * join with `basePath` — a naive template literal would produce `//explorer`
3330
+ * for the default `/` basePath, which express compiles into a route that only
3331
+ * matches `//explorer`, leaving `GET /explorer` a 404.
3332
+ */
3333
+ declare function getExplorerPrefix(basePath: string): string;
2815
3334
  /**
2816
3335
  * Initializes and starts the API server using an initializer function.
2817
3336
  * This function first loads packages to get document models, then calls the initializer function
@@ -2830,14 +3349,29 @@ declare function assertSkipCredentialVerificationAllowed(authEnabled: boolean, s
2830
3349
  interface ClientInitializerResult {
2831
3350
  module: InProcessReactorClientModule;
2832
3351
  reactorDriveClient?: IDriveClient;
3352
+ attachmentReferenceProjection?: AttachmentReferenceProjectionCapability;
3353
+ }
3354
+ interface ClientInitializerDependencies {
3355
+ attachmentReferenceWriter: IAttachmentReferenceWriter;
3356
+ /** Upgrade manifests exported by the loaded packages, one per type. */
3357
+ upgradeManifests: UpgradeManifest<readonly number[]>[];
2833
3358
  }
2834
- declare function initializeAndStartAPI(clientInitializer: (documentModels: DocumentModelModule[]) => Promise<ClientInitializerResult>, options: Options, processorApp: ProcessorApp): Promise<API & {
3359
+ declare function initializeAndStartAPI(clientInitializer: (documentModels: DocumentModelModule[], dependencies: ClientInitializerDependencies) => Promise<ClientInitializerResult>, options: Options, processorApp: ProcessorApp): Promise<API & {
2835
3360
  client: IReactorClient;
2836
3361
  syncManager: ISyncManager;
2837
3362
  documentModelRegistry: IDocumentModelRegistry;
2838
3363
  readiness: ReadinessGate;
3364
+ attachmentReferenceProjection: AttachmentReferenceProjectionCapability;
3365
+ packageManager: PackageManager;
2839
3366
  }>;
2840
3367
  //#endregion
3368
+ //#region src/services/renown-credential-verifier.d.ts
3369
+ interface RenownCredentialVerifierConfig {
3370
+ renownUrl?: string;
3371
+ switchboardUrl?: string;
3372
+ }
3373
+ declare function createRenownCredentialVerifier(config?: RenownCredentialVerifierConfig): Promise<CredentialVerifier>;
3374
+ //#endregion
2841
3375
  //#region src/utils/create-schema.d.ts
2842
3376
  declare const buildSubgraphSchemaModule: (documentModels: DocumentModelModule[], resolvers: GraphQLResolverMap<Context$1>, typeDefs: DocumentNode) => GraphQLSchemaModule;
2843
3377
  declare const createSchema: (documentModels: DocumentModelModule[], resolvers: GraphQLResolverMap<Context$1>, typeDefs: DocumentNode) => graphql.GraphQLSchema;
@@ -2871,5 +3405,5 @@ interface DocumentModelSchemaOptions {
2871
3405
  */
2872
3406
  declare function generateDocumentModelSchema(documentModel: DocumentModelGlobalState$1, options?: DocumentModelSchemaOptions): DocumentNode;
2873
3407
  //#endregion
2874
- export { ADMIN_USERS, API, Action, ActionContext, ActionContextInput, ActionContextInputSchema, ActionContextResolvers, ActionInput, ActionInputSchema, ActionResolvers, AddRelationshipDocument, AddRelationshipMutation, AddRelationshipMutationVariables, AnalyticsSubgraph, AuthConfig, AuthContext, AuthFetchMiddleware, AuthService, AuthSubgraph, type AuthorizationConfig, AuthorizationPolicy, AuthorizedDocumentHandle, BaseSubgraph, type CanonicalDocumentId, ChannelMeta, ChannelMetaInput, ChannelMetaInputSchema, ChannelMetaResolvers, ClientInitializerResult, Context, CreateDocumentDocument, CreateDocumentMutation, CreateDocumentMutationVariables, CreateEmptyDocumentDocument, CreateEmptyDocumentMutation, CreateEmptyDocumentMutationVariables, DateTimeScalarConfig, DbClient, DeadLetterInfo, DeadLetterInfoResolvers, DeleteDocumentDocument, DeleteDocumentMutation, DeleteDocumentMutationVariables, DeleteDocumentsDocument, DeleteDocumentsMutation, DeleteDocumentsMutationVariables, DirectiveResolverFn, DocumentChangeContext, DocumentChangeContextResolvers, DocumentChangeEvent, DocumentChangeEventResolvers, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentChangesSubscription, DocumentChangesSubscriptionVariables, DocumentModelGlobalState, DocumentModelGlobalStateResolvers, DocumentModelResultPage, DocumentModelResultPageResolvers, DocumentModelSchemaOptions, DocumentOperationsFilterInput, DocumentOperationsFilterInputSchema, DocumentPermissionConfig, DocumentPermissionDatabase, DocumentPermissionEntry, DocumentPermissionLevel, DocumentPermissionService, DocumentPermissionTable, DocumentProtectionTable, DocumentWithChildren, DocumentWithChildrenResolvers, Exact, FetchHandler, FindDocumentsDocument, FindDocumentsQuery, FindDocumentsQueryVariables, GatewayAdapterType, GatewayContextFactory, GetDocumentDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentIncomingRelationshipsQuery, GetDocumentIncomingRelationshipsQueryVariables, GetDocumentModelsDocument, GetDocumentModelsQuery, GetDocumentModelsQueryVariables, GetDocumentOperationsDocument, GetDocumentOperationsQuery, GetDocumentOperationsQueryVariables, GetDocumentOutgoingRelationshipsDocument, GetDocumentOutgoingRelationshipsQuery, GetDocumentOutgoingRelationshipsQueryVariables, GetDocumentQuery, GetDocumentQueryVariables, GetDocumentWithOperationsDocument, GetDocumentWithOperationsQuery, GetDocumentWithOperationsQueryVariables, GetJobStatusDocument, GetJobStatusQuery, GetJobStatusQueryVariables, GetParentIdsFn, GqlDocument, GqlDriveDocument, GqlOperation, GqlOperationContext, GqlSigner, GqlSignerApp, GqlSignerUser, GraphQLManager, GraphqlManagerFeatureFlags, HttpAdapterSetup, HttpAdapterType, HttpDocumentModelLoader, HttpPackageLoader, HttpPackageLoaderLogger, HttpPackageLoaderOptions, type IAuthorizationService, IGatewayAdapter, IHttpAdapter, type IPackageLoader, type IPackageLoaderOptions, IPackageStorage, IReactorProcessorHostModule, ISubgraph, ImportPackageLoader, InMemoryPackageStorage, Incremental, InputMaybe, InstallPackageResult, InstalledPackageInfo, IsTypeOfResolverFn, JobChangeEvent, JobChangeEventResolvers, JobChangesDocument, JobChangesSubscription, JobChangesSubscriptionVariables, JobInfo, JobInfoResolvers, JsonObjectScalarConfig, MakeEmpty, MakeMaybe, MakeOptional, Maybe, MoveRelationshipDocument, MoveRelationshipMutation, MoveRelationshipMutationVariables, MoveRelationshipResult, MoveRelationshipResultResolvers, MutateDocumentAsyncDocument, MutateDocumentAsyncMutation, MutateDocumentAsyncMutationVariables, MutateDocumentDocument, MutateDocumentMutation, MutateDocumentMutationVariables, Mutation, MutationAddRelationshipArgs, MutationCreateDocumentArgs, MutationCreateEmptyDocumentArgs, MutationDeleteDocumentArgs, MutationDeleteDocumentsArgs, MutationMoveRelationshipArgs, MutationMutateDocumentArgs, MutationMutateDocumentAsyncArgs, MutationPushSyncEnvelopesArgs, MutationRemoveRelationshipArgs, MutationRenameDocumentArgs, MutationResolvers, MutationSetPreferredEditorArgs, MutationTouchChannelArgs, NextResolverFn, OperationContext, OperationContextInput, OperationContextInputSchema, OperationContextResolvers, OperationInput, OperationInputSchema, OperationUserPermissionEntry, OperationUserPermissionTable, OperationWithContext, OperationWithContextInput, OperationWithContextInputSchema, OperationWithContextResolvers, OperationsFilterInput, OperationsFilterInputSchema, PackageManagementService, PackageManagementServiceOptions, PackageManager, PackagesSubgraph, type PackagesSubgraphArgs, PagingInput, PagingInputSchema, type ParsedDriveUrl, PgliteFactory, PhDocument, PhDocumentFieldsFragment, PhDocumentFieldsFragmentDoc, PhDocumentOperationsArgs, PhDocumentResolvers, PhDocumentResultPage, PhDocumentResultPageResolvers, PollSyncEnvelopesDocument, PollSyncEnvelopesQuery, PollSyncEnvelopesQueryVariables, PollSyncEnvelopesResult, PollSyncEnvelopesResultResolvers, Processor, ProcessorDriveFactory, ProcessorFactoryBuilder, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, PushSyncEnvelopesMutation, PushSyncEnvelopesMutationVariables, Query, QueryDocumentArgs, QueryDocumentIncomingRelationshipsArgs, QueryDocumentModelsArgs, QueryDocumentOperationsArgs, QueryDocumentOutgoingRelationshipsArgs, QueryFindDocumentsArgs, QueryJobStatusArgs, QueryPollSyncEnvelopesArgs, QueryResolvers, ReactorModule, ReactorOperation, ReactorOperationResolvers, ReactorOperationResultPage, ReactorOperationResultPageResolvers, ReactorSigner, ReactorSignerApp, ReactorSignerAppInput, ReactorSignerAppInputSchema, ReactorSignerAppResolvers, ReactorSignerInput, ReactorSignerInputSchema, ReactorSignerResolvers, ReactorSignerUser, ReactorSignerUserInput, ReactorSignerUserInputSchema, ReactorSignerUserResolvers, ReactorSubgraph, ReadinessGate, RemoteCursor, RemoteCursorInput, RemoteCursorInputSchema, RemoteCursorResolvers, RemoteFilterInput, RemoteFilterInputSchema, RemoveRelationshipDocument, RemoveRelationshipMutation, RemoveRelationshipMutationVariables, RenameDocumentDocument, RenameDocumentMutation, RenameDocumentMutationVariables, Requester, RequireFields, Resolver, ResolverFn, ResolverTypeWrapper, ResolverWithResolve, Resolvers, ResolversObject, ResolversParentTypes, ResolversTypes, Revision, RevisionResolvers, Scalars, Sdk, SearchFilterInput, SearchFilterInputSchema, SetPreferredEditorDocument, SetPreferredEditorMutation, SetPreferredEditorMutationVariables, SubgraphArgs, SubgraphClass, SubgraphDefinition, Subscription, SubscriptionDocumentChangesArgs, SubscriptionJobChangesArgs, SubscriptionObject, SubscriptionResolveFn, SubscriptionResolver, SubscriptionResolverObject, SubscriptionResolvers, SubscriptionSubscribeFn, SubscriptionSubscriberObject, SyncEnvelope, SyncEnvelopeInput, SyncEnvelopeInputSchema, SyncEnvelopeResolvers, SyncEnvelopeType, SyncEnvelopeTypeSchema, SystemSubgraph, TlsOptions, TouchChannelDocument, TouchChannelInput, TouchChannelInputSchema, TouchChannelMutation, TouchChannelMutationVariables, TouchChannelResult, TouchChannelResultResolvers, TypeResolveFn, User, ViewFilterInput, ViewFilterInputSchema, WithIndex, WsContextFactory, WsDisposer, assertAuthRequiredForDocumentPermissions, assertSkipCredentialVerificationAllowed, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, createAuthFetchMiddleware, createGatewayAdapter, createHttpAdapter, createMergedSchema, createReactorGraphQLClient, createSchema, definedNonNullAnySchema, driveIdFromUrl, extractSubgraphsFromModule, generateDocumentModelSchema, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelTypeDefs, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getVersion, initAnalyticsStoreSql, initializeAndStartAPI, isDefinedNonNullAny, isExpectedLoaderMiss, isSubgraphClass, parseDriveUrl, renderGraphqlPlayground };
3408
+ export { ADMIN_USERS, API, Action, ActionCandidateInput, ActionCandidateInputSchema, ActionContext, ActionContextInput, ActionContextInputSchema, ActionContextResolvers, ActionEvaluation, ActionEvaluationResolvers, ActionEvaluations, ActionEvaluationsResolvers, ActionInput, ActionInputSchema, ActionResolvers, AddRelationshipDocument, AddRelationshipMutation, AddRelationshipMutationVariables, AnalyticsSubgraph, AttachmentAccessRequest, AttachmentAccessResult, AttachmentAccessService, type AttachmentReferenceProjectionCapability, AuthConfig, AuthContext, AuthDecision, AuthDecisionSchema, AuthFetchMiddleware, AuthService, AuthSubgraph, type AuthorizationConfig, AuthorizationPolicy, AuthorizedDocumentHandle, BaseSubgraph, type CanonicalDocumentId, CanonicalDocumentIdResolutionError, CanonicalDocumentIdResolver, ChannelMeta, ChannelMetaInput, ChannelMetaInputSchema, ChannelMetaResolvers, ClientInitializerDependencies, ClientInitializerResult, Context, CreateDocumentDocument, CreateDocumentMutation, CreateDocumentMutationVariables, CreateEmptyDocumentDocument, CreateEmptyDocumentMutation, CreateEmptyDocumentMutationVariables, CredentialVerifier, DateTimeScalarConfig, DbClient, DeadLetterInfo, DeadLetterInfoResolvers, DeleteDocumentDocument, DeleteDocumentMutation, DeleteDocumentMutationVariables, DeleteDocumentsDocument, DeleteDocumentsMutation, DeleteDocumentsMutationVariables, DirectiveResolverFn, DocumentChangeContext, DocumentChangeContextResolvers, DocumentChangeEvent, DocumentChangeEventResolvers, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentChangesSubscription, DocumentChangesSubscriptionVariables, DocumentModelGlobalState, DocumentModelGlobalStateResolvers, DocumentModelResultPage, DocumentModelResultPageResolvers, DocumentModelSchemaOptions, DocumentOperationsFilterInput, DocumentOperationsFilterInputSchema, DocumentPermissionConfig, DocumentPermissionDatabase, DocumentPermissionEntry, DocumentPermissionLevel, DocumentPermissionService, DocumentPermissionTable, DocumentProtectionTable, DocumentWithChildren, DocumentWithChildrenResolvers, EvaluateActionsDocument, EvaluateActionsQuery, EvaluateActionsQueryVariables, Exact, ExplorerUrlState, FetchHandler, FindDocumentsDocument, FindDocumentsQuery, FindDocumentsQueryVariables, GatewayAdapterType, GatewayContextFactory, GetDocumentDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentIncomingRelationshipsQuery, GetDocumentIncomingRelationshipsQueryVariables, GetDocumentModelsDocument, GetDocumentModelsQuery, GetDocumentModelsQueryVariables, GetDocumentOperationsDocument, GetDocumentOperationsQuery, GetDocumentOperationsQueryVariables, GetDocumentOutgoingRelationshipsDocument, GetDocumentOutgoingRelationshipsQuery, GetDocumentOutgoingRelationshipsQueryVariables, GetDocumentQuery, GetDocumentQueryVariables, GetDocumentWithOperationsDocument, GetDocumentWithOperationsQuery, GetDocumentWithOperationsQueryVariables, GetJobStatusDocument, GetJobStatusQuery, GetJobStatusQueryVariables, GetParentIdsFn, GqlDocument, GqlDriveDocument, GqlOperation, GqlOperationContext, GqlSigner, GqlSignerApp, GqlSignerUser, GraphQLManager, GraphqlManagerFeatureFlags, HttpAdapterSetup, HttpAdapterType, HttpDocumentModelLoader, HttpPackageLoader, HttpPackageLoaderLogger, HttpPackageLoaderOptions, IAttachmentAccessService, type IAuthorizationService, IGatewayAdapter, IHttpAdapter, type IPackageLoader, type IPackageLoaderOptions, IPackageStorage, IProcessorHostModule, IReactorProcessorHostModule, ISubgraph, ImportPackageLoader, InMemoryPackageStorage, Incremental, InputMaybe, InstallPackageResult, InstalledPackageInfo, IsTypeOfResolverFn, JobChangeEvent, JobChangeEventResolvers, JobChangesDocument, JobChangesSubscription, JobChangesSubscriptionVariables, JobInfo, JobInfoResolvers, JsonObjectScalarConfig, MakeEmpty, MakeMaybe, MakeOptional, Maybe, MoveRelationshipDocument, MoveRelationshipMutation, MoveRelationshipMutationVariables, MoveRelationshipResult, MoveRelationshipResultResolvers, MutateDocumentAsyncDocument, MutateDocumentAsyncMutation, MutateDocumentAsyncMutationVariables, MutateDocumentDocument, MutateDocumentMutation, MutateDocumentMutationVariables, Mutation, MutationAddRelationshipArgs, MutationCreateDocumentArgs, MutationCreateEmptyDocumentArgs, MutationDeleteDocumentArgs, MutationDeleteDocumentsArgs, MutationExecuteArgs, MutationExecuteAsyncArgs, MutationMoveRelationshipArgs, MutationMutateDocumentArgs, MutationMutateDocumentAsyncArgs, MutationPushSyncEnvelopesArgs, MutationRemoveRelationshipArgs, MutationRenameDocumentArgs, MutationResolvers, MutationSetPreferredEditorArgs, MutationTouchChannelArgs, NextResolverFn, OperationContext, OperationContextInput, OperationContextInputSchema, OperationContextResolvers, OperationInput, OperationInputSchema, OperationUserPermissionEntry, OperationUserPermissionTable, OperationWithContext, OperationWithContextInput, OperationWithContextInputSchema, OperationWithContextResolvers, OperationsFilterInput, OperationsFilterInputSchema, PGLITE_UTC_PARSERS, PackageManagementService, PackageManagementServiceOptions, PackageManager, PackagesSubgraph, type PackagesSubgraphArgs, PagingInput, PagingInputSchema, type ParsedDriveUrl, PgliteFactory, PhDocument, PhDocumentFieldsFragment, PhDocumentFieldsFragmentDoc, PhDocumentOperationsArgs, PhDocumentResolvers, PhDocumentResultPage, PhDocumentResultPageResolvers, PollSyncEnvelopesDocument, PollSyncEnvelopesQuery, PollSyncEnvelopesQueryVariables, PollSyncEnvelopesResult, PollSyncEnvelopesResultResolvers, Processor, ProcessorDriveFactory, ProcessorFactoryBuilder, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, PushSyncEnvelopesMutation, PushSyncEnvelopesMutationVariables, Query, QueryDocumentArgs, QueryDocumentIncomingRelationshipsArgs, QueryDocumentModelsArgs, QueryDocumentOperationsArgs, QueryDocumentOutgoingRelationshipsArgs, QueryEvaluateActionsArgs, QueryFindDocumentsArgs, QueryJobStatusArgs, QueryPollSyncEnvelopesArgs, QueryResolvers, ReactorModule, ReactorOperation, ReactorOperationResolvers, ReactorOperationResultPage, ReactorOperationResultPageResolvers, ReactorSigner, ReactorSignerApp, ReactorSignerAppInput, ReactorSignerAppInputSchema, ReactorSignerAppResolvers, ReactorSignerInput, ReactorSignerInputSchema, ReactorSignerResolvers, ReactorSignerUser, ReactorSignerUserInput, ReactorSignerUserInputSchema, ReactorSignerUserResolvers, ReactorSubgraph, ReadinessGate, RemoteCursor, RemoteCursorInput, RemoteCursorInputSchema, RemoteCursorResolvers, RemoteFilterInput, RemoteFilterInputSchema, RemoveRelationshipDocument, RemoveRelationshipMutation, RemoveRelationshipMutationVariables, RenameDocumentDocument, RenameDocumentMutation, RenameDocumentMutationVariables, RenownConfig, RenownCredentialVerifierConfig, RenownSource, Requester, RequireFields, ResolvedRenownConfig, Resolver, ResolverFn, ResolverTypeWrapper, ResolverWithResolve, Resolvers, ResolversObject, ResolversParentTypes, ResolversTypes, Revision, RevisionResolvers, RouteHandle, Scalars, Sdk, SearchFilterInput, SearchFilterInputSchema, SetPreferredEditorDocument, SetPreferredEditorMutation, SetPreferredEditorMutationVariables, SubgraphArgs, SubgraphClass, SubgraphDefinition, Subscription, SubscriptionDocumentChangesArgs, SubscriptionJobChangesArgs, SubscriptionObject, SubscriptionResolveFn, SubscriptionResolver, SubscriptionResolverObject, SubscriptionResolvers, SubscriptionSubscribeFn, SubscriptionSubscriberObject, SyncEnvelope, SyncEnvelopeInput, SyncEnvelopeInputSchema, SyncEnvelopeResolvers, SyncEnvelopeType, SyncEnvelopeTypeSchema, SystemSubgraph, TlsOptions, TouchChannelDocument, TouchChannelInput, TouchChannelInputSchema, TouchChannelMutation, TouchChannelMutationVariables, TouchChannelResult, TouchChannelResultResolvers, TypeResolveFn, User, ViewFilterInput, ViewFilterInputSchema, WithIndex, WsContextFactory, WsDisposer, assertAuthRequiredForDocumentPermissions, assertCredentialVerifierForSource, assertRequireAuthenticatedCallerAllowed, assertSkipCredentialVerificationAllowed, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, createAuthFetchMiddleware, createCanonicalDocumentIdResolver, createGatewayAdapter, createHttpAdapter, createMergedSchema, createReactorGraphQLClient, createRenownCredentialVerifier, createSchema, decodeExplorerUrlState, definedNonNullAnySchema, driveIdFromUrl, extractSubgraphsFromModule, generateDocumentModelSchema, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelTypeDefs, getExplorerPrefix, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getUniqueUpgradeManifests, getVersion, initAnalyticsStoreSql, initializeAndStartAPI, isDefinedNonNullAny, isExpectedLoaderMiss, isSubgraphClass, parseDriveUrl, renderGraphqlPlayground, resolveRenownConfig };
2875
3409
  //# sourceMappingURL=index.d.mts.map