@powerhousedao/reactor-api 6.2.2-dev.2 → 6.2.2-dev.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="87b4bf50-e018-5626-94a7-7a994ca58761")}catch(e){}}();
3
- import { a as isSubgraphClass, c as loadDocumentModels, d as BaseSubgraph, f as AuthorizationPolicy, i as buildGraphqlOperations, l as loadProcessors, m as createAuthorizationService, n as buildGraphQlDriveDocument, o as debounce, p as AuthorizedDocumentHandle, r as buildGraphqlOperation, t as buildGraphQlDocument, u as loadSubgraphs } from "./utils-iibOQ50e.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cb4acb17-dffb-5545-a8f2-04134029dcb8")}catch(e){}}();
3
+ import { a as isSubgraphClass, c as loadDocumentModels, d as BaseSubgraph, f as CanonicalDocumentIdResolutionError, g as createAuthorizationService, h as AuthorizedDocumentHandle, i as buildGraphqlOperations, l as loadProcessors, m as AuthorizationPolicy, n as buildGraphQlDriveDocument, o as debounce, p as createCanonicalDocumentIdResolver, r as buildGraphqlOperation, t as buildGraphQlDocument, u as loadSubgraphs } from "./utils-BdPg2whY.mjs";
4
4
  import { AnalyticsQueryEngine } from "@powerhousedao/analytics-engine-core";
5
5
  import { AnalyticsModel, AnalyticsResolvers, typedefs } from "@powerhousedao/analytics-engine-graphql";
6
6
  import { gql } from "graphql-tag";
@@ -26,7 +26,7 @@ import { driveDocumentModelModule } from "@powerhousedao/shared/document-drive";
26
26
  import EventEmitter from "node:events";
27
27
  import fs, { watchFile } from "node:fs";
28
28
  import { PostgresAnalyticsStore } from "@powerhousedao/analytics-engine-pg";
29
- import { AttachmentBuilder } from "@powerhousedao/reactor-attachments";
29
+ import { AttachmentBuilder, AttachmentReferenceIndexBuilder, createRef, createS3AttachmentBackend, parseAttachmentStorageConfig, parseRef } from "@powerhousedao/reactor-attachments";
30
30
  import { createAttachmentClient } from "@powerhousedao/reactor-attachments/client";
31
31
  import { setupMcpServer } from "@powerhousedao/reactor-mcp";
32
32
  import { mkdir } from "node:fs/promises";
@@ -34,7 +34,7 @@ import { tmpdir } from "node:os";
34
34
  import { WebSocketServer } from "ws";
35
35
  import { createRelationalDb } from "@powerhousedao/shared/processors";
36
36
  import { Kysely, Migrator, sql } from "kysely";
37
- import { verifyAuthBearerToken } from "@renown/sdk";
37
+ import { fetchDelegationCredential, resolveSwitchboardEndpoint, verifyAuthBearerToken } from "@renown/sdk";
38
38
  import { PGlite } from "@electric-sql/pglite";
39
39
  import { AtomicNodeFs } from "@powerhousedao/pglite-fs";
40
40
  import knex from "knex";
@@ -460,6 +460,7 @@ const getDocumentModelTypeDefs = (documentModels, typeDefs$1) => {
460
460
  });
461
461
  return dedupeTypeDefinitions(gql`
462
462
  scalar JSONObject
463
+ scalar AttachmentRef
463
464
  ${typeDefs.join("\n").replaceAll(";", "")}
464
465
 
465
466
  type PHOperationContext {
@@ -878,6 +879,7 @@ function generateNewApiSchema(documentName, specification, _stateSchemaTypes, pr
878
879
  return gql`
879
880
  scalar DateTime
880
881
  scalar JSONObject
882
+ scalar AttachmentRef
881
883
 
882
884
  ${revisionType}
883
885
 
@@ -1904,9 +1906,10 @@ async function documentModels(reactorClient, args) {
1904
1906
  throw new GraphQLError(`Failed to convert document models to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
1905
1907
  }
1906
1908
  }
1907
- async function document(reactorClient, args) {
1908
- let view;
1909
+ async function document(reactorClient, args, subject) {
1910
+ let view = subject ? { subject } : void 0;
1909
1911
  if (args.view) view = {
1912
+ subject,
1910
1913
  branch: fromInputMaybe(args.view.branch),
1911
1914
  scopes: toMutableArray(fromInputMaybe(args.view.scopes))
1912
1915
  };
@@ -1931,9 +1934,10 @@ async function document(reactorClient, args) {
1931
1934
  throw new GraphQLError(`Failed to convert document to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
1932
1935
  }
1933
1936
  }
1934
- async function documentOutgoingRelationships(reactorClient, args) {
1935
- let view;
1937
+ async function documentOutgoingRelationships(reactorClient, args, subject) {
1938
+ let view = subject ? { subject } : void 0;
1936
1939
  if (args.view) view = {
1940
+ subject,
1937
1941
  branch: fromInputMaybe(args.view.branch),
1938
1942
  scopes: toMutableArray(fromInputMaybe(args.view.scopes))
1939
1943
  };
@@ -1958,9 +1962,10 @@ async function documentOutgoingRelationships(reactorClient, args) {
1958
1962
  throw new GraphQLError(`Failed to convert outgoing relationships to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
1959
1963
  }
1960
1964
  }
1961
- async function documentIncomingRelationships(reactorClient, args) {
1962
- let view;
1965
+ async function documentIncomingRelationships(reactorClient, args, subject) {
1966
+ let view = subject ? { subject } : void 0;
1963
1967
  if (args.view) view = {
1968
+ subject,
1964
1969
  branch: fromInputMaybe(args.view.branch),
1965
1970
  scopes: toMutableArray(fromInputMaybe(args.view.scopes))
1966
1971
  };
@@ -1985,9 +1990,10 @@ async function documentIncomingRelationships(reactorClient, args) {
1985
1990
  throw new GraphQLError(`Failed to convert incoming relationships to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
1986
1991
  }
1987
1992
  }
1988
- async function findDocuments(reactorClient, args) {
1989
- let view;
1993
+ async function findDocuments(reactorClient, args, subject) {
1994
+ let view = subject ? { subject } : void 0;
1990
1995
  if (args.view) view = {
1996
+ subject,
1991
1997
  branch: fromInputMaybe(args.view.branch),
1992
1998
  scopes: toMutableArray(fromInputMaybe(args.view.scopes))
1993
1999
  };
@@ -2029,11 +2035,12 @@ async function jobStatus(reactorClient, args) {
2029
2035
  throw new GraphQLError(`Failed to convert job status to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
2030
2036
  }
2031
2037
  }
2032
- async function documentOperations(reactorClient, args) {
2033
- let view;
2038
+ async function documentOperations(reactorClient, args, subject) {
2039
+ let view = subject ? { subject } : void 0;
2034
2040
  const branch = fromInputMaybe(args.filter.branch);
2035
2041
  const scopes = toMutableArray(fromInputMaybe(args.filter.scopes));
2036
2042
  if (branch || scopes) view = {
2043
+ subject,
2037
2044
  branch,
2038
2045
  scopes
2039
2046
  };
@@ -3787,7 +3794,7 @@ var ReactorSubgraph = class extends BaseSubgraph {
3787
3794
  return await documentOperations(this.reactorClient, {
3788
3795
  filter,
3789
3796
  paging: args.paging
3790
- });
3797
+ }, this.viewSubject(ctx));
3791
3798
  } catch (error) {
3792
3799
  this.logger.error("Error in PHDocument.operations: @Error", error);
3793
3800
  throw error;
@@ -3810,7 +3817,7 @@ var ReactorSubgraph = class extends BaseSubgraph {
3810
3817
  return await document(this.reactorClient, {
3811
3818
  ...args,
3812
3819
  identifier: handle.fetchIdentifier
3813
- });
3820
+ }, this.viewSubject(ctx));
3814
3821
  } catch (error) {
3815
3822
  this.logger.error("Error in document: @Error", error);
3816
3823
  throw error;
@@ -3823,7 +3830,7 @@ var ReactorSubgraph = class extends BaseSubgraph {
3823
3830
  return await documentOutgoingRelationships(this.reactorClient, {
3824
3831
  ...args,
3825
3832
  sourceIdentifier: handle.fetchIdentifier
3826
- });
3833
+ }, this.viewSubject(ctx));
3827
3834
  } catch (error) {
3828
3835
  this.logger.error("Error in documentOutgoingRelationships: @Error", error);
3829
3836
  throw error;
@@ -3836,7 +3843,7 @@ var ReactorSubgraph = class extends BaseSubgraph {
3836
3843
  const result = await documentIncomingRelationships(this.reactorClient, {
3837
3844
  ...args,
3838
3845
  targetIdentifier: handle.fetchIdentifier
3839
- });
3846
+ }, this.viewSubject(ctx));
3840
3847
  if (!this.authorizationService.isSupremeAdmin(ctx.user?.address)) {
3841
3848
  const filteredItems = [];
3842
3849
  for (const item of result.items) if (await this.canReadDocument(item.id, ctx)) filteredItems.push(item);
@@ -3857,7 +3864,7 @@ var ReactorSubgraph = class extends BaseSubgraph {
3857
3864
  const result = await findDocuments(this.reactorClient, {
3858
3865
  ...args,
3859
3866
  search: args.search ?? {}
3860
- });
3867
+ }, this.viewSubject(ctx));
3861
3868
  if (!this.authorizationService.isSupremeAdmin(ctx.user?.address)) {
3862
3869
  const filteredItems = [];
3863
3870
  for (const item of result.items) if (await this.canReadDocument(item.id, ctx)) filteredItems.push(item);
@@ -3891,7 +3898,7 @@ var ReactorSubgraph = class extends BaseSubgraph {
3891
3898
  ...args.filter,
3892
3899
  documentId: handle.fetchIdentifier
3893
3900
  }
3894
- });
3901
+ }, this.viewSubject(ctx));
3895
3902
  } catch (error) {
3896
3903
  this.logger.error("Error in documentOperations: @Error", error);
3897
3904
  throw error;
@@ -4205,10 +4212,10 @@ const ADMIN_USERS = getAdminUsers();
4205
4212
  //#endregion
4206
4213
  //#region src/graphql/system/version.ts
4207
4214
  function getVersion() {
4208
- return "6.2.2-dev.2";
4215
+ return "6.2.2-dev.20";
4209
4216
  }
4210
4217
  function getGitHash() {
4211
- return "eb1ca600dda00740b6dd30b9ee817dd7202aa1fe";
4218
+ return "decd6c971dd957dbbef96978da5ec9aa3c8f4fb3";
4212
4219
  }
4213
4220
  function getGitUrl() {
4214
4221
  return buildTreeUrl(getGitHash());
@@ -4355,6 +4362,12 @@ var HttpPackageLoader = class {
4355
4362
  return /^(@[a-z0-9][-a-z0-9._]*\/)?[a-z0-9][-a-z0-9._]*$/i.test(name) && !name.includes("..") && name.length <= 214;
4356
4363
  }
4357
4364
  };
4365
+ /**
4366
+ * Returns live modules (host-only sources): dynamically loaded models are
4367
+ * registered on the host registry but never reach executor worker threads.
4368
+ * Making them worker-executable means returning an importable source here
4369
+ * (the CDN URL as a package specifier, given process-wide https hooks).
4370
+ */
4358
4371
  var HttpDocumentModelLoader = class {
4359
4372
  loader;
4360
4373
  logger = childLogger(["reactor-api", "http-document-model-loader"]);
@@ -4689,6 +4702,70 @@ var PackageManager = class {
4689
4702
  const config = { basePath: process.env.BASE_PATH || "/" };
4690
4703
  const DefaultCoreSubgraphs = [AnalyticsSubgraph, SystemSubgraph];
4691
4704
  //#endregion
4705
+ //#region src/attachment-backend.ts
4706
+ /** Filesystem is the default; explicit S3 is readiness-gated without fallback. */
4707
+ async function createStartupAttachmentBackend({ db, env = process.env, s3Dependencies }) {
4708
+ const storage = parseAttachmentStorageConfig(env);
4709
+ if (storage.kind === "filesystem") return void 0;
4710
+ const backend = createS3AttachmentBackend(db.withSchema("attachments"), storage.s3, s3Dependencies);
4711
+ if (!(await backend.health()).ready) throw new Error("S3 attachment backend readiness check failed");
4712
+ return backend;
4713
+ }
4714
+ //#endregion
4715
+ //#region src/services/attachment-access.service.ts
4716
+ const HASH_PATTERN = /^[a-f0-9]{64}$/;
4717
+ /**
4718
+ * Composes document authorization with the projected document/ref
4719
+ * relationship. Order is fixed: validate ref, resolve the canonical document
4720
+ * id, check `canRead`, then check the reference index. A denied document
4721
+ * never reaches the reference reader, and the facade never touches
4722
+ * attachment metadata, storage backends, or presigners.
4723
+ */
4724
+ var AttachmentAccessService = class {
4725
+ constructor(resolveCanonicalId, authorization, references, projection) {
4726
+ this.resolveCanonicalId = resolveCanonicalId;
4727
+ this.authorization = authorization;
4728
+ this.references = references;
4729
+ this.projection = projection;
4730
+ }
4731
+ async canReadAttachment(request) {
4732
+ if (this.projection.status !== "available") return { kind: "projection-unavailable" };
4733
+ const ref = normalizeAttachmentRef(request.attachmentRef);
4734
+ if (ref === null) return { kind: "denied" };
4735
+ let documentId;
4736
+ try {
4737
+ documentId = await this.resolveCanonicalId(request.documentId);
4738
+ } catch {
4739
+ return { kind: "denied" };
4740
+ }
4741
+ if (!await this.authorization.canRead(documentId, request.userAddress)) return { kind: "denied" };
4742
+ if (!await this.references.hasReference(documentId, ref)) return { kind: "denied" };
4743
+ return {
4744
+ kind: "allowed",
4745
+ documentId,
4746
+ ref
4747
+ };
4748
+ }
4749
+ };
4750
+ /**
4751
+ * Parses and canonicalizes a caller-supplied ref through the shared parser.
4752
+ * Returns null for anything that is not a v1 ref over a 64-char SHA-256 hex
4753
+ * hash; hex case is normalized so index lookups use the canonical form.
4754
+ */
4755
+ function normalizeAttachmentRef(value) {
4756
+ let hash;
4757
+ let version;
4758
+ try {
4759
+ const parsed = parseRef(value);
4760
+ hash = parsed.hash.toLowerCase();
4761
+ version = parsed.version;
4762
+ } catch {
4763
+ return null;
4764
+ }
4765
+ if (version !== 1 || !HASH_PATTERN.test(hash)) return null;
4766
+ return createRef(hash, version);
4767
+ }
4768
+ //#endregion
4692
4769
  //#region src/migrations/001_create_document_permissions.ts
4693
4770
  var _001_create_document_permissions_exports = /* @__PURE__ */ __exportAll({
4694
4771
  down: () => down$2,
@@ -5035,27 +5112,34 @@ var AuthService = class {
5035
5112
  this.credentialCache.delete(oldestKey);
5036
5113
  }
5037
5114
  }
5038
- /**
5039
- * Fetch the credential from the Renown API and validate it against the
5040
- * expected address, chainId and issuer. Never throws; returns false on any
5041
- * network or validation failure.
5042
- */
5043
5115
  async fetchCredentialExists(address, chainId, appId) {
5044
- const url = `https://www.renown.id/api/auth/credential?address=${address}&chainId=${chainId}&connectId=${appId}&appId=${appId}`;
5045
- try {
5046
- const response = await fetch(url, { method: "GET" });
5047
- if (response.status !== 200) return false;
5048
- const credential = (await response.json()).credential;
5049
- const appIdVerfied = credential.credentialSubject.id;
5050
- const addressVerfied = credential.issuer.id.split(":")[4];
5051
- const chainIdVerfied = credential.issuer.id.split(":")[3];
5052
- return appIdVerfied === appId && addressVerfied.toLocaleLowerCase() === address.toLocaleLowerCase() && chainIdVerfied === chainId.toString();
5053
- } catch {
5054
- return false;
5055
- }
5116
+ if (!this.config.verifyCredential) throw new Error("AuthService: credential verification is enabled but no verifyCredential was provided");
5117
+ return this.config.verifyCredential({
5118
+ address,
5119
+ chainId,
5120
+ appId
5121
+ });
5056
5122
  }
5057
5123
  };
5058
5124
  //#endregion
5125
+ //#region src/services/renown-credential-verifier.ts
5126
+ async function createRenownCredentialVerifier(config = {}) {
5127
+ const switchboardUrl = await resolveSwitchboardEndpoint({
5128
+ switchboardUrl: config.switchboardUrl,
5129
+ baseUrl: config.renownUrl
5130
+ });
5131
+ return async ({ address, chainId, appId }) => {
5132
+ return await fetchDelegationCredential({
5133
+ address,
5134
+ chainId,
5135
+ appDid: appId,
5136
+ switchboardUrl,
5137
+ baseUrl: switchboardUrl ? void 0 : config.renownUrl,
5138
+ discover: false
5139
+ }) !== void 0;
5140
+ };
5141
+ }
5142
+ //#endregion
5059
5143
  //#region src/services/document-permission.service.ts
5060
5144
  /**
5061
5145
  * Service for managing document-level permissions.
@@ -5647,7 +5731,7 @@ async function _setupCommonInfrastructure(options) {
5647
5731
  admins = options.auth.admins.map((a) => a.toLowerCase());
5648
5732
  authEnabled = options.auth.enabled;
5649
5733
  }
5650
- const { AUTH_ENABLED, ADMINS, DEFAULT_PROTECTION, DOCUMENT_PERMISSIONS_ENABLED, SKIP_CREDENTIAL_VERIFICATION, CREDENTIAL_VERIFICATION_CACHE_TTL_MS } = process.env;
5734
+ const { AUTH_ENABLED, ADMINS, DEFAULT_PROTECTION, DOCUMENT_PERMISSIONS_ENABLED, SKIP_CREDENTIAL_VERIFICATION, CREDENTIAL_VERIFICATION_CACHE_TTL_MS, RENOWN_URL, SWITCHBOARD_URL } = process.env;
5651
5735
  if (AUTH_ENABLED !== void 0) authEnabled = AUTH_ENABLED === "true";
5652
5736
  if (ADMINS !== void 0) admins = ADMINS.split(",").map((a) => a.toLowerCase());
5653
5737
  let defaultProtection = false;
@@ -5683,7 +5767,11 @@ async function _setupCommonInfrastructure(options) {
5683
5767
  enabled: authEnabled,
5684
5768
  admins,
5685
5769
  skipCredentialVerification,
5686
- credentialVerificationCacheTtlMs
5770
+ credentialVerificationCacheTtlMs,
5771
+ verifyCredential: await createRenownCredentialVerifier({
5772
+ renownUrl: RENOWN_URL,
5773
+ switchboardUrl: SWITCHBOARD_URL
5774
+ })
5687
5775
  });
5688
5776
  authFetchMiddleware = createAuthFetchMiddleware(authService);
5689
5777
  }
@@ -5709,7 +5797,12 @@ async function _setupCommonInfrastructure(options) {
5709
5797
  await mkdir(attachmentStoragePath, { recursive: true });
5710
5798
  const { db: attachmentDb, knex: attachmentKnex, pglite: attachmentPglite } = getDbClient(options.dbPath, options.pgliteFactory);
5711
5799
  dbClosers.push(...makeDbClosers(attachmentKnex, attachmentPglite));
5712
- const attachments = await new AttachmentBuilder(attachmentDb, attachmentStoragePath).withReservationSweepMs(3600 * 1e3).build();
5800
+ const ATTACHMENT_SWEEP_INTERVAL_MS = 3600 * 1e3;
5801
+ const attachmentBackend = await createStartupAttachmentBackend({ db: attachmentDb });
5802
+ const attachmentBuilder = new AttachmentBuilder(attachmentDb, attachmentStoragePath).withReservationSweepMs(ATTACHMENT_SWEEP_INTERVAL_MS);
5803
+ if (attachmentBackend) attachmentBuilder.withBackend(attachmentBackend);
5804
+ const attachments = await attachmentBuilder.build();
5805
+ const attachmentReferenceIndex = await new AttachmentReferenceIndexBuilder(attachmentDb).build();
5713
5806
  dbClosers.push(() => {
5714
5807
  attachments.destroy();
5715
5808
  return Promise.resolve();
@@ -5729,6 +5822,7 @@ async function _setupCommonInfrastructure(options) {
5729
5822
  documentPermissionService,
5730
5823
  authorizationConfig,
5731
5824
  attachments,
5825
+ attachmentReferenceIndex,
5732
5826
  packages,
5733
5827
  dbClosers,
5734
5828
  readiness
@@ -5737,7 +5831,7 @@ async function _setupCommonInfrastructure(options) {
5737
5831
  /**
5738
5832
  * Private helper function containing common setup logic for API initialization
5739
5833
  */
5740
- async function _setupAPI(reactorClient, syncManager, reactorProcessorManager, httpAdapter, authFetchMiddleware, authService, port, packages, relationalDb, analyticsStore, documentPermissionService, processors, subgraphs, options, processorApp, readModels, attachments, authorizationConfig, documentModelRegistry, dbClosers = [], reactorDriveClient) {
5834
+ async function _setupAPI(reactorClient, syncManager, reactorProcessorManager, httpAdapter, authFetchMiddleware, authService, port, packages, relationalDb, analyticsStore, documentPermissionService, processors, subgraphs, options, processorApp, readModels, attachments, attachmentReferenceIndex, attachmentReferenceProjection, authorizationConfig, documentModelRegistry, dbClosers = [], reactorDriveClient) {
5741
5835
  const hostModule = {
5742
5836
  relationalDb,
5743
5837
  analyticsStore,
@@ -5784,6 +5878,7 @@ async function _setupAPI(reactorClient, syncManager, reactorProcessorManager, ht
5784
5878
  const { httpServer, wsServer } = await startServer(httpAdapter, port, options.https, logger);
5785
5879
  const authorizationService = createAuthorizationService(authorizationConfig, documentPermissionService, createGetParentIdsFn(reactorClient));
5786
5880
  logger.info(`Authorization service initialized (policy: ${authorizationConfig.policy})`);
5881
+ const attachmentAccess = new AttachmentAccessService(createCanonicalDocumentIdResolver(reactorClient), authorizationService, attachmentReferenceIndex.store, attachmentReferenceProjection);
5787
5882
  const coreSubgraphs = DefaultCoreSubgraphs.slice();
5788
5883
  coreSubgraphs.push(ReactorSubgraph);
5789
5884
  if (documentPermissionService) {
@@ -5808,6 +5903,8 @@ async function _setupAPI(reactorClient, syncManager, reactorProcessorManager, ht
5808
5903
  graphqlManager,
5809
5904
  packages,
5810
5905
  attachments,
5906
+ attachmentReferenceIndex,
5907
+ attachmentAccess,
5811
5908
  authService,
5812
5909
  dispose: buildApiDispose({
5813
5910
  graphqlManager,
@@ -5856,9 +5953,12 @@ function buildApiDispose(args) {
5856
5953
  };
5857
5954
  }
5858
5955
  async function initializeAndStartAPI(clientInitializer, options, processorApp) {
5859
- const { port, httpAdapter, authFetchMiddleware, authService, relationalDb, analyticsStore, documentPermissionService, authorizationConfig, attachments, packages, dbClosers, readiness } = await _setupCommonInfrastructure(options);
5956
+ const { port, httpAdapter, authFetchMiddleware, authService, relationalDb, analyticsStore, documentPermissionService, authorizationConfig, attachments, attachmentReferenceIndex, packages, dbClosers, readiness } = await _setupCommonInfrastructure(options);
5860
5957
  const { documentModels, processors, subgraphs } = await packages.init();
5861
- const { module: reactorClientModule, reactorDriveClient } = await clientInitializer(documentModels);
5958
+ const { module: reactorClientModule, reactorDriveClient, attachmentReferenceProjection = {
5959
+ status: "unavailable",
5960
+ reason: "initializer-did-not-report"
5961
+ } } = await clientInitializer(documentModels, { attachmentReferenceWriter: attachmentReferenceIndex.store });
5862
5962
  const reactorClient = reactorClientModule.client;
5863
5963
  const syncManager = reactorClientModule.reactorModule?.syncModule?.syncManager;
5864
5964
  if (!syncManager) throw new Error("SyncManager not available from InProcessReactorClientModule");
@@ -5867,11 +5967,12 @@ async function initializeAndStartAPI(clientInitializer, options, processorApp) {
5867
5967
  const documentModelRegistry = reactorClientModule.reactorModule?.documentModelRegistry;
5868
5968
  if (!documentModelRegistry) throw new Error("DocumentModelRegistry not available from InProcessReactorClientModule");
5869
5969
  return {
5870
- ...await _setupAPI(reactorClient, syncManager, reactorProcessorManager, httpAdapter, authFetchMiddleware, authService, port, packages, relationalDb, analyticsStore, documentPermissionService, processors, subgraphs, options, processorApp, (reactorClientModule.reactorModule?.readModelCoordinator)?.readModels ?? [], attachments, authorizationConfig, documentModelRegistry, dbClosers, reactorDriveClient),
5970
+ ...await _setupAPI(reactorClient, syncManager, reactorProcessorManager, httpAdapter, authFetchMiddleware, authService, port, packages, relationalDb, analyticsStore, documentPermissionService, processors, subgraphs, options, processorApp, (reactorClientModule.reactorModule?.readModelCoordinator)?.readModels ?? [], attachments, attachmentReferenceIndex, attachmentReferenceProjection, authorizationConfig, documentModelRegistry, dbClosers, reactorDriveClient),
5871
5971
  client: reactorClient,
5872
5972
  syncManager,
5873
5973
  documentModelRegistry,
5874
- readiness
5974
+ readiness,
5975
+ attachmentReferenceProjection
5875
5976
  };
5876
5977
  }
5877
5978
  //#endregion
@@ -5975,7 +6076,7 @@ var PackageManagementService = class {
5975
6076
  }
5976
6077
  };
5977
6078
  //#endregion
5978
- export { ADMIN_USERS, ActionContextInputSchema, ActionInputSchema, AddRelationshipDocument, AnalyticsSubgraph, AuthService, AuthSubgraph, AuthorizationPolicy, AuthorizedDocumentHandle, BaseSubgraph, ChannelMetaInputSchema, CreateDocumentDocument, CreateEmptyDocumentDocument, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentOperationsFilterInputSchema, DocumentPermissionService, FindDocumentsDocument, GetDocumentDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentModelsDocument, GetDocumentOperationsDocument, GetDocumentOutgoingRelationshipsDocument, GetDocumentWithOperationsDocument, GetJobStatusDocument, GraphQLManager, HttpDocumentModelLoader, HttpPackageLoader, ImportPackageLoader, InMemoryPackageStorage, JobChangesDocument, MoveRelationshipDocument, MutateDocumentAsyncDocument, MutateDocumentDocument, OperationContextInputSchema, OperationInputSchema, OperationWithContextInputSchema, OperationsFilterInputSchema, PackageManagementService, PackageManager, PackagesSubgraph, PagingInputSchema, PhDocumentFieldsFragmentDoc, PollSyncEnvelopesDocument, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, ReactorSignerAppInputSchema, ReactorSignerInputSchema, ReactorSignerUserInputSchema, ReactorSubgraph, RemoteCursorInputSchema, RemoteFilterInputSchema, RemoveRelationshipDocument, RenameDocumentDocument, SearchFilterInputSchema, SetPreferredEditorDocument, SyncEnvelopeInputSchema, SyncEnvelopeType, SyncEnvelopeTypeSchema, SystemSubgraph, TouchChannelDocument, TouchChannelInputSchema, ViewFilterInputSchema, 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 };
6079
+ export { ADMIN_USERS, ActionContextInputSchema, ActionInputSchema, AddRelationshipDocument, AnalyticsSubgraph, AttachmentAccessService, AuthService, AuthSubgraph, AuthorizationPolicy, AuthorizedDocumentHandle, BaseSubgraph, CanonicalDocumentIdResolutionError, ChannelMetaInputSchema, CreateDocumentDocument, CreateEmptyDocumentDocument, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentOperationsFilterInputSchema, DocumentPermissionService, FindDocumentsDocument, GetDocumentDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentModelsDocument, GetDocumentOperationsDocument, GetDocumentOutgoingRelationshipsDocument, GetDocumentWithOperationsDocument, GetJobStatusDocument, GraphQLManager, HttpDocumentModelLoader, HttpPackageLoader, ImportPackageLoader, InMemoryPackageStorage, JobChangesDocument, MoveRelationshipDocument, MutateDocumentAsyncDocument, MutateDocumentDocument, OperationContextInputSchema, OperationInputSchema, OperationWithContextInputSchema, OperationsFilterInputSchema, PackageManagementService, PackageManager, PackagesSubgraph, PagingInputSchema, PhDocumentFieldsFragmentDoc, PollSyncEnvelopesDocument, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, ReactorSignerAppInputSchema, ReactorSignerInputSchema, ReactorSignerUserInputSchema, ReactorSubgraph, RemoteCursorInputSchema, RemoteFilterInputSchema, RemoveRelationshipDocument, RenameDocumentDocument, SearchFilterInputSchema, SetPreferredEditorDocument, SyncEnvelopeInputSchema, SyncEnvelopeType, SyncEnvelopeTypeSchema, SystemSubgraph, TouchChannelDocument, TouchChannelInputSchema, ViewFilterInputSchema, assertAuthRequiredForDocumentPermissions, assertSkipCredentialVerificationAllowed, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, createAuthFetchMiddleware, createCanonicalDocumentIdResolver, createGatewayAdapter, createHttpAdapter, createMergedSchema, createReactorGraphQLClient, createRenownCredentialVerifier, createSchema, definedNonNullAnySchema, driveIdFromUrl, extractSubgraphsFromModule, generateDocumentModelSchema, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelTypeDefs, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getVersion, initAnalyticsStoreSql, initializeAndStartAPI, isDefinedNonNullAny, isExpectedLoaderMiss, isSubgraphClass, parseDriveUrl, renderGraphqlPlayground };
5979
6080
 
5980
6081
  //# sourceMappingURL=index.mjs.map
5981
- //# debugId=87b4bf50-e018-5626-94a7-7a994ca58761
6082
+ //# debugId=cb4acb17-dffb-5545-a8f2-04134029dcb8