@powerhousedao/reactor-api 6.2.3-dev.35 → 6.2.3-dev.37
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.d.mts +243 -147
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +256 -67
- package/dist/index.mjs.map +1 -1
- package/dist/{pieces-Bi5qxpi5.mjs → pieces-DRY6haAO.mjs} +20 -3
- package/dist/pieces-DRY6haAO.mjs.map +1 -0
- package/dist/src/packages/vite-loader.mjs +1 -1
- package/package.json +14 -14
- package/dist/pieces-Bi5qxpi5.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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]="
|
|
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]="ae77d1e5-904a-549c-a5d4-37e03fc0801e")}catch(e){}}();
|
|
3
3
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
4
|
-
import { A as RefusalNotRecordedError, C as AuthorizationPolicy, D as AuthenticationRequiredError, E as AuthEvaluationUnsupportedError, O as ForbiddenError, S as createCanonicalDocumentIdResolver, T as createAuthorizationService, _ as loadProcessors, a as pieceListLocation, b as callerSubject, c as buildGraphQlDocument, d as buildGraphqlOperations, f as isSubgraphClass, g as loadDocumentModels, k as MalformedStoredOperationError, l as buildGraphQlDriveDocument, m as extractUpgradeManifests, o as piecesFromCdnList, p as debounce, r as PIECE_SOURCE_LIST, s as piecesFromListModule, u as buildGraphqlOperation, v as loadSubgraphs, w as AuthorizedDocumentHandle, x as CanonicalDocumentIdResolutionError, y as BaseSubgraph } from "./pieces-
|
|
4
|
+
import { A as RefusalNotRecordedError, C as AuthorizationPolicy, D as AuthenticationRequiredError, E as AuthEvaluationUnsupportedError, O as ForbiddenError, S as createCanonicalDocumentIdResolver, T as createAuthorizationService, _ as loadProcessors, a as pieceListLocation, b as callerSubject, c as buildGraphQlDocument, d as buildGraphqlOperations, f as isSubgraphClass, g as loadDocumentModels, k as MalformedStoredOperationError, l as buildGraphQlDriveDocument, m as extractUpgradeManifests, o as piecesFromCdnList, p as debounce, r as PIECE_SOURCE_LIST, s as piecesFromListModule, u as buildGraphqlOperation, v as loadSubgraphs, w as AuthorizedDocumentHandle, x as CanonicalDocumentIdResolutionError, y as BaseSubgraph } from "./pieces-DRY6haAO.mjs";
|
|
5
5
|
import { AnalyticsQueryEngine } from "@powerhousedao/analytics-engine-core";
|
|
6
6
|
import { AnalyticsModel, AnalyticsResolvers, typedefs } from "@powerhousedao/analytics-engine-graphql";
|
|
7
7
|
import { gql } from "graphql-tag";
|
|
@@ -34,7 +34,7 @@ import { ReactorGroupV1 } from "@powerhousedao/reactor-group";
|
|
|
34
34
|
import { driveDocumentModelModule } from "@powerhousedao/shared/document-drive";
|
|
35
35
|
import EventEmitter from "node:events";
|
|
36
36
|
import { PostgresAnalyticsStore } from "@powerhousedao/analytics-engine-pg";
|
|
37
|
-
import { AttachmentBuilder, AttachmentReferenceIndexBuilder, createRef, createS3AttachmentBackend, parseAttachmentStorageConfig, parseRef } from "@powerhousedao/reactor-attachments";
|
|
37
|
+
import { AttachmentBuilder, AttachmentNotFound, AttachmentReferenceIndexBuilder, createRef, createS3AttachmentBackend, parseAttachmentStorageConfig, parseRef, validateReserveMetadata } from "@powerhousedao/reactor-attachments";
|
|
38
38
|
import { createAttachmentClient } from "@powerhousedao/reactor-attachments/client";
|
|
39
39
|
import { setupMcpServer } from "@powerhousedao/reactor-mcp";
|
|
40
40
|
import { mkdir } from "node:fs/promises";
|
|
@@ -4834,22 +4834,6 @@ function createWsAuthHandlers(opts) {
|
|
|
4834
4834
|
};
|
|
4835
4835
|
}
|
|
4836
4836
|
var GraphQLManager = class {
|
|
4837
|
-
path;
|
|
4838
|
-
httpServer;
|
|
4839
|
-
wsServer;
|
|
4840
|
-
reactorClient;
|
|
4841
|
-
relationalDb;
|
|
4842
|
-
analyticsStore;
|
|
4843
|
-
syncManager;
|
|
4844
|
-
logger;
|
|
4845
|
-
httpAdapter;
|
|
4846
|
-
gatewayAdapter;
|
|
4847
|
-
authService;
|
|
4848
|
-
documentPermissionService;
|
|
4849
|
-
featureFlags;
|
|
4850
|
-
port;
|
|
4851
|
-
syncServingGate;
|
|
4852
|
-
httpRoutes;
|
|
4853
4837
|
initialized = false;
|
|
4854
4838
|
coreSubgraphsMap = /* @__PURE__ */ new Map();
|
|
4855
4839
|
contextFields = {};
|
|
@@ -4884,26 +4868,43 @@ var GraphQLManager = class {
|
|
|
4884
4868
|
authorizationService;
|
|
4885
4869
|
/** Route service in use: the injected one, or one built on first need. */
|
|
4886
4870
|
#fallbackRoutes;
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
this.
|
|
4906
|
-
this.
|
|
4871
|
+
path;
|
|
4872
|
+
httpServer;
|
|
4873
|
+
wsServer;
|
|
4874
|
+
reactorClient;
|
|
4875
|
+
relationalDb;
|
|
4876
|
+
analyticsStore;
|
|
4877
|
+
syncManager;
|
|
4878
|
+
logger;
|
|
4879
|
+
httpAdapter;
|
|
4880
|
+
gatewayAdapter;
|
|
4881
|
+
authService;
|
|
4882
|
+
documentPermissionService;
|
|
4883
|
+
featureFlags;
|
|
4884
|
+
port;
|
|
4885
|
+
syncServingGate;
|
|
4886
|
+
httpRoutes;
|
|
4887
|
+
attachments;
|
|
4888
|
+
constructor(options) {
|
|
4889
|
+
this.path = options.path;
|
|
4890
|
+
this.httpServer = options.httpServer;
|
|
4891
|
+
this.wsServer = options.wsServer;
|
|
4892
|
+
this.reactorClient = options.reactorClient;
|
|
4893
|
+
this.relationalDb = options.relationalDb;
|
|
4894
|
+
this.analyticsStore = options.analyticsStore;
|
|
4895
|
+
this.syncManager = options.syncManager;
|
|
4896
|
+
this.logger = options.logger;
|
|
4897
|
+
this.httpAdapter = options.httpAdapter;
|
|
4898
|
+
this.gatewayAdapter = options.gatewayAdapter;
|
|
4899
|
+
this.authService = options.authService;
|
|
4900
|
+
this.documentPermissionService = options.documentPermissionService;
|
|
4901
|
+
this.featureFlags = options.featureFlags ?? DefaultFeatureFlags;
|
|
4902
|
+
this.port = options.port ?? 4001;
|
|
4903
|
+
this.authorizationService = options.authorizationService;
|
|
4904
|
+
this.reactorDriveClient = options.reactorDriveClient;
|
|
4905
|
+
this.syncServingGate = options.syncServingGate;
|
|
4906
|
+
this.httpRoutes = options.httpRoutes;
|
|
4907
|
+
this.attachments = options.attachments;
|
|
4907
4908
|
this.driveOwnershipCache = new DriveOwnershipCache(this.reactorClient);
|
|
4908
4909
|
this.wsServer.setMaxListeners(0);
|
|
4909
4910
|
}
|
|
@@ -4998,7 +4999,8 @@ var GraphQLManager = class {
|
|
|
4998
4999
|
path: this.path,
|
|
4999
5000
|
documentPermissionService: this.documentPermissionService,
|
|
5000
5001
|
authorizationService: this.authorizationService,
|
|
5001
|
-
syncServingGate: this.syncServingGate
|
|
5002
|
+
syncServingGate: this.syncServingGate,
|
|
5003
|
+
attachments: this.attachments
|
|
5002
5004
|
});
|
|
5003
5005
|
await this.#addSubgraphInstance(subgraphInstance, supergraph, false, DOCUMENT_MODEL_SUBGRAPH_SOURCE);
|
|
5004
5006
|
registeredNames.add(subgraphInstance.name);
|
|
@@ -5135,7 +5137,8 @@ var GraphQLManager = class {
|
|
|
5135
5137
|
path: this.path,
|
|
5136
5138
|
documentPermissionService: this.documentPermissionService,
|
|
5137
5139
|
authorizationService: this.authorizationService,
|
|
5138
|
-
syncServingGate: this.syncServingGate
|
|
5140
|
+
syncServingGate: this.syncServingGate,
|
|
5141
|
+
attachments: this.attachments
|
|
5139
5142
|
});
|
|
5140
5143
|
return this.#addSubgraphInstance(subgraphInstance, supergraph, core, packageName);
|
|
5141
5144
|
}
|
|
@@ -5262,15 +5265,12 @@ var GraphQLManager = class {
|
|
|
5262
5265
|
authService: this.authService,
|
|
5263
5266
|
requireAuthenticatedCaller: () => this.#requireAuthMiddleware !== void 0,
|
|
5264
5267
|
logger: this.logger,
|
|
5265
|
-
buildContext: (connectionParams, user) => {
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
if (user) context.user = user;
|
|
5272
|
-
return context;
|
|
5273
|
-
}
|
|
5268
|
+
buildContext: (connectionParams, user) => ({
|
|
5269
|
+
headers: connectionParams,
|
|
5270
|
+
db: this.relationalDb,
|
|
5271
|
+
...this.getAdditionalContextFields(),
|
|
5272
|
+
user
|
|
5273
|
+
})
|
|
5274
5274
|
});
|
|
5275
5275
|
}
|
|
5276
5276
|
setSupergraph(supergraph, subgraphs) {
|
|
@@ -6824,10 +6824,10 @@ const ADMIN_USERS = getAdminUsers();
|
|
|
6824
6824
|
//#endregion
|
|
6825
6825
|
//#region src/graphql/system/version.ts
|
|
6826
6826
|
function getVersion() {
|
|
6827
|
-
return "6.2.3-dev.
|
|
6827
|
+
return "6.2.3-dev.37";
|
|
6828
6828
|
}
|
|
6829
6829
|
function getGitHash() {
|
|
6830
|
-
return "
|
|
6830
|
+
return "5fc581be624d6dfa355f3a82383cbb96a42fb4d8";
|
|
6831
6831
|
}
|
|
6832
6832
|
function getGitUrl() {
|
|
6833
6833
|
return buildTreeUrl(getGitHash());
|
|
@@ -7579,7 +7579,8 @@ const HASH_PATTERN = /^[a-f0-9]{64}$/;
|
|
|
7579
7579
|
* anyone who learns its hash, which the document's own state may well have told
|
|
7580
7580
|
* them. Both are kept because they are the two halves of one rule: an
|
|
7581
7581
|
* attachment is readable by whoever may read the document that references it,
|
|
7582
|
-
* and each composition can only express that in its own terms.
|
|
7582
|
+
* and each composition can only express that in its own terms. The caller
|
|
7583
|
+
* decision mirrors the routes' `requireAuth`.
|
|
7583
7584
|
*/
|
|
7584
7585
|
var AttachmentAccessService = class {
|
|
7585
7586
|
resolveCanonicalId;
|
|
@@ -7588,13 +7589,19 @@ var AttachmentAccessService = class {
|
|
|
7588
7589
|
projection;
|
|
7589
7590
|
readGate;
|
|
7590
7591
|
scopeGate;
|
|
7591
|
-
|
|
7592
|
+
options;
|
|
7593
|
+
constructor(resolveCanonicalId, authorization, references, projection, readGate, scopeGate, options = {}) {
|
|
7592
7594
|
this.resolveCanonicalId = resolveCanonicalId;
|
|
7593
7595
|
this.authorization = authorization;
|
|
7594
7596
|
this.references = references;
|
|
7595
7597
|
this.projection = projection;
|
|
7596
7598
|
this.readGate = readGate;
|
|
7597
7599
|
this.scopeGate = scopeGate;
|
|
7600
|
+
this.options = options;
|
|
7601
|
+
}
|
|
7602
|
+
admitCaller(request) {
|
|
7603
|
+
if ((request.intent === "read" ? this.options.refuseAnonymousReads ?? false : this.options.refuseAnonymousWrites ?? true) && !request.userAddress) return Promise.resolve({ kind: "unauthenticated" });
|
|
7604
|
+
return Promise.resolve({ kind: "admitted" });
|
|
7598
7605
|
}
|
|
7599
7606
|
async canReadAttachment(request) {
|
|
7600
7607
|
if (this.projection.status !== "available") return { kind: "projection-unavailable" };
|
|
@@ -7671,6 +7678,140 @@ function normalizeAttachmentRef(value) {
|
|
|
7671
7678
|
return createRef(hash, version);
|
|
7672
7679
|
}
|
|
7673
7680
|
//#endregion
|
|
7681
|
+
//#region src/services/authorized-attachment.service.ts
|
|
7682
|
+
/** Matches the attachment routes' `documentId` bound. */
|
|
7683
|
+
const MAX_DOCUMENT_ID_LEN = 512;
|
|
7684
|
+
/** The reference index is not maintained in this composition. */
|
|
7685
|
+
var AttachmentAccessUnavailable = class extends Error {
|
|
7686
|
+
constructor() {
|
|
7687
|
+
super("Attachment access is unavailable");
|
|
7688
|
+
this.name = "AttachmentAccessUnavailable";
|
|
7689
|
+
}
|
|
7690
|
+
};
|
|
7691
|
+
/** The access decision itself failed; the cause is logged, not surfaced. */
|
|
7692
|
+
var AttachmentAccessFailed = class extends Error {
|
|
7693
|
+
constructor(cause) {
|
|
7694
|
+
super("Attachment access decision failed", { cause });
|
|
7695
|
+
this.name = "AttachmentAccessFailed";
|
|
7696
|
+
}
|
|
7697
|
+
};
|
|
7698
|
+
/** An `IAttachmentService` whose reads and writes are decided for one subject. */
|
|
7699
|
+
var AuthorizedAttachmentService = class {
|
|
7700
|
+
inner;
|
|
7701
|
+
access;
|
|
7702
|
+
subject;
|
|
7703
|
+
logger;
|
|
7704
|
+
constructor(inner, access, subject, logger) {
|
|
7705
|
+
this.inner = inner;
|
|
7706
|
+
this.access = access;
|
|
7707
|
+
this.subject = subject;
|
|
7708
|
+
this.logger = logger;
|
|
7709
|
+
}
|
|
7710
|
+
/** Hash-first only: an upload-first handle can send after it expires. */
|
|
7711
|
+
async reserve(options) {
|
|
7712
|
+
const { mimeType, fileName, extension, clientHash, sizeBytes } = options;
|
|
7713
|
+
if (clientHash === void 0) throw new Error("Attachment reservations require a client hash");
|
|
7714
|
+
const copy = {
|
|
7715
|
+
mimeType,
|
|
7716
|
+
fileName,
|
|
7717
|
+
extension,
|
|
7718
|
+
clientHash,
|
|
7719
|
+
sizeBytes
|
|
7720
|
+
};
|
|
7721
|
+
await this.admit("write");
|
|
7722
|
+
validateReserveMetadata(copy);
|
|
7723
|
+
return this.inner.reserve(copy);
|
|
7724
|
+
}
|
|
7725
|
+
async stat(ref, options) {
|
|
7726
|
+
const decision = await this.decideRead(ref, options);
|
|
7727
|
+
return this.inner.stat(decision.ref, {
|
|
7728
|
+
...options,
|
|
7729
|
+
documentId: decision.documentId
|
|
7730
|
+
});
|
|
7731
|
+
}
|
|
7732
|
+
async get(ref, options) {
|
|
7733
|
+
const decision = await this.decideRead(ref, options);
|
|
7734
|
+
return this.inner.get(decision.ref, {
|
|
7735
|
+
...options,
|
|
7736
|
+
documentId: decision.documentId
|
|
7737
|
+
});
|
|
7738
|
+
}
|
|
7739
|
+
async getDownloadTarget(ref, options) {
|
|
7740
|
+
const decision = await this.decideRead(ref, options);
|
|
7741
|
+
return this.inner.getDownloadTarget(decision.ref, {
|
|
7742
|
+
...options,
|
|
7743
|
+
documentId: decision.documentId
|
|
7744
|
+
});
|
|
7745
|
+
}
|
|
7746
|
+
async decideRead(ref, options) {
|
|
7747
|
+
const documentId = readDocumentId(options);
|
|
7748
|
+
if (documentId === null) throw new AttachmentNotFound(ref);
|
|
7749
|
+
await this.admit("read");
|
|
7750
|
+
let decision;
|
|
7751
|
+
try {
|
|
7752
|
+
decision = await this.access.canReadAttachment({
|
|
7753
|
+
documentId,
|
|
7754
|
+
attachmentRef: ref,
|
|
7755
|
+
userAddress: this.subject.address,
|
|
7756
|
+
appKey: this.subject.key
|
|
7757
|
+
});
|
|
7758
|
+
} catch (err) {
|
|
7759
|
+
throw this.accessFailed(err);
|
|
7760
|
+
}
|
|
7761
|
+
if (decision.kind === "allowed") return {
|
|
7762
|
+
documentId: decision.documentId,
|
|
7763
|
+
ref: decision.ref
|
|
7764
|
+
};
|
|
7765
|
+
if (decision.kind === "projection-unavailable") throw new AttachmentAccessUnavailable();
|
|
7766
|
+
throw new AttachmentNotFound(ref);
|
|
7767
|
+
}
|
|
7768
|
+
async admit(intent) {
|
|
7769
|
+
let result;
|
|
7770
|
+
try {
|
|
7771
|
+
result = await this.access.admitCaller({
|
|
7772
|
+
intent,
|
|
7773
|
+
userAddress: this.subject.address,
|
|
7774
|
+
appKey: this.subject.key
|
|
7775
|
+
});
|
|
7776
|
+
} catch (err) {
|
|
7777
|
+
throw this.accessFailed(err);
|
|
7778
|
+
}
|
|
7779
|
+
if (result.kind !== "admitted") throw new AuthenticationRequiredError();
|
|
7780
|
+
}
|
|
7781
|
+
accessFailed(err) {
|
|
7782
|
+
this.logger.error("Attachment access decision failed: @error", err);
|
|
7783
|
+
return new AttachmentAccessFailed(err);
|
|
7784
|
+
}
|
|
7785
|
+
};
|
|
7786
|
+
/** The options' `documentId` when it is one the routes would accept, else null. */
|
|
7787
|
+
function readDocumentId(options) {
|
|
7788
|
+
if (typeof options !== "object" || options === null) return null;
|
|
7789
|
+
if (isAbortSignal(options)) return null;
|
|
7790
|
+
const value = options.documentId;
|
|
7791
|
+
if (typeof value !== "string") return null;
|
|
7792
|
+
if (value.trim().length === 0 || value.length > MAX_DOCUMENT_ID_LEN) return null;
|
|
7793
|
+
return value;
|
|
7794
|
+
}
|
|
7795
|
+
/** Duck-checked too, so a signal from another realm is still a signal. */
|
|
7796
|
+
function isAbortSignal(value) {
|
|
7797
|
+
if (value instanceof AbortSignal) return true;
|
|
7798
|
+
const candidate = value;
|
|
7799
|
+
return typeof candidate.aborted === "boolean" && typeof candidate.addEventListener === "function";
|
|
7800
|
+
}
|
|
7801
|
+
var AttachmentClientProvider = class {
|
|
7802
|
+
service;
|
|
7803
|
+
access;
|
|
7804
|
+
logger;
|
|
7805
|
+
constructor(service, access, logger) {
|
|
7806
|
+
this.service = service;
|
|
7807
|
+
this.access = access;
|
|
7808
|
+
this.logger = logger;
|
|
7809
|
+
}
|
|
7810
|
+
forSubject(subject) {
|
|
7811
|
+
return createAttachmentClient(new AuthorizedAttachmentService(this.service, this.access, subject, this.logger));
|
|
7812
|
+
}
|
|
7813
|
+
};
|
|
7814
|
+
//#endregion
|
|
7674
7815
|
//#region src/graphql/gateway/require-auth-middleware.ts
|
|
7675
7816
|
/**
|
|
7676
7817
|
* Returns a fetch middleware that rejects anonymous callers with a 401.
|
|
@@ -8780,8 +8921,28 @@ function resolveGatewayAdapterType(logger) {
|
|
|
8780
8921
|
/**
|
|
8781
8922
|
* Sets up the subgraph manager and registers subgraphs
|
|
8782
8923
|
*/
|
|
8783
|
-
async function setupGraphQLManager(httpAdapter, authFetchMiddleware, requireAuthFetchMiddleware, httpServer, wsServer, client, relationalDb, analyticsStore, syncManager, subgraphs, logger, authorizationService, authService, documentPermissionService, enableDocumentModelSubgraphs, port, reactorDriveClient, syncServingGate, httpRoutes) {
|
|
8784
|
-
const graphqlManager = new GraphQLManager(
|
|
8924
|
+
async function setupGraphQLManager({ httpAdapter, authFetchMiddleware, requireAuthFetchMiddleware, httpServer, wsServer, client, relationalDb, analyticsStore, syncManager, subgraphs, logger, authorizationService, authService, documentPermissionService, enableDocumentModelSubgraphs, port, reactorDriveClient, syncServingGate, httpRoutes, attachments }) {
|
|
8925
|
+
const graphqlManager = new GraphQLManager({
|
|
8926
|
+
path: config.basePath,
|
|
8927
|
+
httpServer,
|
|
8928
|
+
wsServer,
|
|
8929
|
+
reactorClient: client,
|
|
8930
|
+
relationalDb,
|
|
8931
|
+
analyticsStore,
|
|
8932
|
+
syncManager,
|
|
8933
|
+
logger,
|
|
8934
|
+
httpAdapter,
|
|
8935
|
+
gatewayAdapter: await createGatewayAdapter(resolveGatewayAdapterType(logger), logger),
|
|
8936
|
+
authService,
|
|
8937
|
+
documentPermissionService,
|
|
8938
|
+
featureFlags: { enableDocumentModelSubgraphs },
|
|
8939
|
+
port,
|
|
8940
|
+
authorizationService,
|
|
8941
|
+
reactorDriveClient,
|
|
8942
|
+
syncServingGate,
|
|
8943
|
+
httpRoutes,
|
|
8944
|
+
attachments
|
|
8945
|
+
});
|
|
8785
8946
|
await graphqlManager.init(subgraphs.core, authFetchMiddleware, requireAuthFetchMiddleware);
|
|
8786
8947
|
for (const [packageName, collection] of subgraphs.extended.entries()) for (const subgraph of collection) await graphqlManager.registerSubgraph(subgraph, "graphql", false, packageName);
|
|
8787
8948
|
await graphqlManager.updateRouter();
|
|
@@ -9062,6 +9223,7 @@ async function _setupCommonInfrastructure(options) {
|
|
|
9062
9223
|
httpRoutes,
|
|
9063
9224
|
authFetchMiddleware,
|
|
9064
9225
|
requireAuthFetchMiddleware,
|
|
9226
|
+
authEnabled,
|
|
9065
9227
|
authService,
|
|
9066
9228
|
relationalDb,
|
|
9067
9229
|
analyticsStore,
|
|
@@ -9078,7 +9240,7 @@ async function _setupCommonInfrastructure(options) {
|
|
|
9078
9240
|
/**
|
|
9079
9241
|
* Private helper function containing common setup logic for API initialization
|
|
9080
9242
|
*/
|
|
9081
|
-
async function _setupAPI(reactorClient, syncManager, reactorProcessorManager, httpAdapter, authFetchMiddleware, requireAuthFetchMiddleware, authService, port, packages, relationalDb, analyticsStore, documentPermissionService, processors, subgraphs, options, processorApp, readModels, attachments, attachmentReferenceIndex, attachmentReferenceProjection, authorizationConfig, documentModelRegistry, dbClosers = [], reactorDriveClient, syncServingGate, httpRoutes, attachmentReadsFollowDocumentPolicy = false) {
|
|
9243
|
+
async function _setupAPI(reactorClient, syncManager, reactorProcessorManager, httpAdapter, authFetchMiddleware, requireAuthFetchMiddleware, authEnabled, authService, port, packages, relationalDb, analyticsStore, documentPermissionService, processors, subgraphs, options, processorApp, readModels, attachments, attachmentReferenceIndex, attachmentReferenceProjection, authorizationConfig, documentModelRegistry, dbClosers = [], reactorDriveClient, syncServingGate, httpRoutes, attachmentReadsFollowDocumentPolicy = false) {
|
|
9082
9244
|
const hostModuleBase = {
|
|
9083
9245
|
...createReactorHostModuleBase({
|
|
9084
9246
|
client: reactorClient,
|
|
@@ -9121,17 +9283,43 @@ async function _setupAPI(reactorClient, syncManager, reactorProcessorManager, ht
|
|
|
9121
9283
|
const authorizationService = createAuthorizationService(authorizationConfig, documentPermissionService, createGetParentIdsFn(reactorClient));
|
|
9122
9284
|
logger.info(`Authorization service initialized (policy: ${authorizationConfig.policy})`);
|
|
9123
9285
|
assertAttachmentPolicyReadsAllowed(attachmentReadsFollowDocumentPolicy, syncServingGate !== void 0);
|
|
9124
|
-
const
|
|
9286
|
+
const floor = requireAuthFetchMiddleware !== void 0;
|
|
9287
|
+
const attachmentAccess = new AttachmentAccessService(createCanonicalDocumentIdResolver(reactorClient), authorizationService, attachmentReferenceIndex.store, attachmentReferenceProjection, reactorClient, attachmentReadsFollowDocumentPolicy ? syncServingGate : void 0, {
|
|
9288
|
+
refuseAnonymousWrites: authEnabled || floor,
|
|
9289
|
+
refuseAnonymousReads: floor
|
|
9290
|
+
});
|
|
9291
|
+
const attachmentClientProvider = new AttachmentClientProvider(attachments.service, attachmentAccess, logger);
|
|
9125
9292
|
const coreSubgraphs = DefaultCoreSubgraphs.slice();
|
|
9126
9293
|
coreSubgraphs.push(ReactorSubgraph);
|
|
9127
9294
|
if (documentPermissionService) {
|
|
9128
9295
|
coreSubgraphs.push(AuthSubgraph);
|
|
9129
9296
|
logger.info("Auth subgraph registered (document permissions enabled)");
|
|
9130
9297
|
}
|
|
9131
|
-
const graphqlManager = await setupGraphQLManager(
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
|
|
9298
|
+
const graphqlManager = await setupGraphQLManager({
|
|
9299
|
+
httpAdapter,
|
|
9300
|
+
authFetchMiddleware,
|
|
9301
|
+
requireAuthFetchMiddleware,
|
|
9302
|
+
httpServer,
|
|
9303
|
+
wsServer,
|
|
9304
|
+
client: reactorClient,
|
|
9305
|
+
relationalDb,
|
|
9306
|
+
analyticsStore,
|
|
9307
|
+
syncManager,
|
|
9308
|
+
subgraphs: {
|
|
9309
|
+
extended: subgraphs,
|
|
9310
|
+
core: coreSubgraphs
|
|
9311
|
+
},
|
|
9312
|
+
logger: logger.child(["graphql-manager"]),
|
|
9313
|
+
authorizationService,
|
|
9314
|
+
authService,
|
|
9315
|
+
documentPermissionService,
|
|
9316
|
+
enableDocumentModelSubgraphs: options.enableDocumentModelSubgraphs,
|
|
9317
|
+
port,
|
|
9318
|
+
reactorDriveClient,
|
|
9319
|
+
syncServingGate,
|
|
9320
|
+
httpRoutes,
|
|
9321
|
+
attachments: attachmentClientProvider
|
|
9322
|
+
});
|
|
9135
9323
|
setupEventListeners(packages, graphqlManager, reactorProcessorManager, moduleFor, documentModelRegistry);
|
|
9136
9324
|
if (mcpServerEnabled) {
|
|
9137
9325
|
await setupMcpServer({
|
|
@@ -9157,8 +9345,9 @@ async function _setupAPI(reactorClient, syncManager, reactorProcessorManager, ht
|
|
|
9157
9345
|
attachments,
|
|
9158
9346
|
attachmentReferenceIndex,
|
|
9159
9347
|
attachmentAccess,
|
|
9348
|
+
attachmentClientProvider,
|
|
9160
9349
|
authService,
|
|
9161
|
-
requireAuthenticatedCaller:
|
|
9350
|
+
requireAuthenticatedCaller: floor,
|
|
9162
9351
|
authorizationService,
|
|
9163
9352
|
relationalDb,
|
|
9164
9353
|
dispose
|
|
@@ -9207,7 +9396,7 @@ function buildApiDispose(args) {
|
|
|
9207
9396
|
};
|
|
9208
9397
|
}
|
|
9209
9398
|
async function initializeAndStartAPI(clientInitializer, options, processorApp) {
|
|
9210
|
-
const { port, httpAdapter, httpRoutes, authFetchMiddleware, requireAuthFetchMiddleware, authService, relationalDb, analyticsStore, documentPermissionService, authorizationConfig, attachments, attachmentReferenceIndex, packages, dbClosers, readiness, attachmentReadsFollowDocumentPolicy } = await _setupCommonInfrastructure(options);
|
|
9399
|
+
const { port, httpAdapter, httpRoutes, authFetchMiddleware, requireAuthFetchMiddleware, authEnabled, authService, relationalDb, analyticsStore, documentPermissionService, authorizationConfig, attachments, attachmentReferenceIndex, packages, dbClosers, readiness, attachmentReadsFollowDocumentPolicy } = await _setupCommonInfrastructure(options);
|
|
9211
9400
|
const { documentModels, upgradeManifests, processors, subgraphs } = await packages.init();
|
|
9212
9401
|
const { module: reactorClientModule, reactorDriveClient, attachmentReferenceProjection = {
|
|
9213
9402
|
status: "unavailable",
|
|
@@ -9224,7 +9413,7 @@ async function initializeAndStartAPI(clientInitializer, options, processorApp) {
|
|
|
9224
9413
|
const documentModelRegistry = reactorClientModule.reactorModule?.documentModelRegistry;
|
|
9225
9414
|
if (!documentModelRegistry) throw new Error("DocumentModelRegistry not available from InProcessReactorClientModule");
|
|
9226
9415
|
return {
|
|
9227
|
-
...await _setupAPI(reactorClient, syncManager, reactorProcessorManager, httpAdapter, authFetchMiddleware, requireAuthFetchMiddleware, authService, port, packages, relationalDb, analyticsStore, documentPermissionService, processors, subgraphs, options, processorApp, (reactorClientModule.reactorModule?.readModelCoordinator)?.readModels ?? [], attachments, attachmentReferenceIndex, attachmentReferenceProjection, authorizationConfig, documentModelRegistry, dbClosers, reactorDriveClient, buildSyncServingGate(reactorClientModule.reactorModule, authorizationConfig, options.logger ?? defaultLogger), httpRoutes, attachmentReadsFollowDocumentPolicy),
|
|
9416
|
+
...await _setupAPI(reactorClient, syncManager, reactorProcessorManager, httpAdapter, authFetchMiddleware, requireAuthFetchMiddleware, authEnabled, authService, port, packages, relationalDb, analyticsStore, documentPermissionService, processors, subgraphs, options, processorApp, (reactorClientModule.reactorModule?.readModelCoordinator)?.readModels ?? [], attachments, attachmentReferenceIndex, attachmentReferenceProjection, authorizationConfig, documentModelRegistry, dbClosers, reactorDriveClient, buildSyncServingGate(reactorClientModule.reactorModule, authorizationConfig, options.logger ?? defaultLogger), httpRoutes, attachmentReadsFollowDocumentPolicy),
|
|
9228
9417
|
client: reactorClient,
|
|
9229
9418
|
syncManager,
|
|
9230
9419
|
documentModelRegistry,
|
|
@@ -9407,7 +9596,7 @@ var PackageManagementService = class {
|
|
|
9407
9596
|
}
|
|
9408
9597
|
};
|
|
9409
9598
|
//#endregion
|
|
9410
|
-
export { ADMIN_USERS, ActionCandidateInputSchema, ActionContextInputSchema, ActionInputSchema, AddRelationshipDocument, AnalyticsSubgraph, AttachmentAccessService, AuthDecision, AuthDecisionSchema, AuthEvaluationUnsupportedError, AuthService, AuthSubgraph, AuthenticationRequiredError, AuthorizationPolicy, AuthorizedDocumentHandle, BaseSubgraph, CORE_PACKAGE_NAME, CanonicalDocumentIdResolutionError, ChannelMetaInputSchema, CreateDocumentDocument, CreateEmptyDocumentDocument, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentOperationsFilterInputSchema, DocumentPermissionService, DocumentRelationshipFieldsFragmentDoc, EvaluateActionsDocument, FindDocumentsDocument, ForbiddenError, GetDocumentDocument, GetDocumentIncomingRelationshipEdgesDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentModelsDocument, GetDocumentOperationsDocument, GetDocumentOutgoingRelationshipEdgesDocument, GetDocumentOutgoingRelationshipsDocument, GetDocumentWithOperationsDocument, GetJobStatusDocument, GraphQLManager, HttpDocumentModelLoader, HttpPackageLoader, HttpRouteService, ImportPackageLoader, InMemoryPackageStorage, InvalidNamespaceError, JobChangesDocument, MalformedStoredOperationError, MemoryWebhookStore, MoveRelationshipDocument, MutateDocumentAsyncDocument, MutateDocumentDocument, OperationContextInputSchema, OperationInputSchema, OperationWithContextInputSchema, OperationsFilterInputSchema, PACKAGE_ROUTE_SEGMENT, PGLITE_UTC_PARSERS, PackageManagementService, PackageManager, PackagesSubgraph, PagingInputSchema, PhDocumentFieldsFragmentDoc, PollSyncEnvelopesDocument, PrivacyPermissionAdapter, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, ReactorSignerAppInputSchema, ReactorSignerInputSchema, ReactorSignerUserInputSchema, ReactorSubgraph, RefusalNotRecordedError, RelationalWebhookStore, RemoteCursorInputSchema, RemoteFilterInputSchema, RemoveRelationshipDocument, RenameDocumentDocument, SearchFilterInputSchema, SetPreferredEditorDocument, SyncEnvelopeInputSchema, SyncEnvelopeType, SyncEnvelopeTypeSchema, SyncRefusalInputSchema, SystemSubgraph, TouchChannelDocument, TouchChannelInputSchema, UpdateRelationshipDocument, ViewFilterInputSchema, WEBHOOK_SEGMENT, WS_AUTH_CLOSE_REASONS, WS_CLOSE_REASON_AUTHENTICATION_REQUIRED, WS_CLOSE_REASON_BEARER_REJECTED, WebhookService, assertAttachmentPolicyReadsAllowed, assertAuthRequiredForDocumentPermissions, assertCredentialVerifierForSource, assertHostMountPath, assertRequireAuthenticatedCallerAllowed, assertSkipCredentialVerificationAllowed, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, callerSubject, createAuthFetchMiddleware, createCanonicalDocumentIdResolver, createGatewayAdapter, createHttpAdapter, createMergedSchema, createReactorGraphQLClient, createRenownCredentialVerifier, createSchema, createWsAuthHandlers, decodeExplorerUrlState, definedNonNullAnySchema, driveIdFromUrl, extractSubgraphsFromModule, generateDocumentModelSchema, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelTypeDefs, getExplorerPrefix, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getUniqueUpgradeManifests, getVersion, initAnalyticsStoreSql, initializeAndStartAPI, isDefinedNonNullAny, isExpectedLoaderMiss, isSubgraphClass, namespacePath, namespaceSegments, newWebhookToken, parseDriveUrl, parseWebhookBody, piecesBaseUrl, redactHeaders, renderGraphqlPlayground, resolvePackageName, resolveRenownConfig, verifyWebhook };
|
|
9599
|
+
export { ADMIN_USERS, ActionCandidateInputSchema, ActionContextInputSchema, ActionInputSchema, AddRelationshipDocument, AnalyticsSubgraph, AttachmentAccessFailed, AttachmentAccessService, AttachmentAccessUnavailable, AttachmentClientProvider, AuthDecision, AuthDecisionSchema, AuthEvaluationUnsupportedError, AuthService, AuthSubgraph, AuthenticationRequiredError, AuthorizationPolicy, AuthorizedAttachmentService, AuthorizedDocumentHandle, BaseSubgraph, CORE_PACKAGE_NAME, CanonicalDocumentIdResolutionError, ChannelMetaInputSchema, CreateDocumentDocument, CreateEmptyDocumentDocument, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentOperationsFilterInputSchema, DocumentPermissionService, DocumentRelationshipFieldsFragmentDoc, EvaluateActionsDocument, FindDocumentsDocument, ForbiddenError, GetDocumentDocument, GetDocumentIncomingRelationshipEdgesDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentModelsDocument, GetDocumentOperationsDocument, GetDocumentOutgoingRelationshipEdgesDocument, GetDocumentOutgoingRelationshipsDocument, GetDocumentWithOperationsDocument, GetJobStatusDocument, GraphQLManager, HttpDocumentModelLoader, HttpPackageLoader, HttpRouteService, ImportPackageLoader, InMemoryPackageStorage, InvalidNamespaceError, JobChangesDocument, MalformedStoredOperationError, MemoryWebhookStore, MoveRelationshipDocument, MutateDocumentAsyncDocument, MutateDocumentDocument, OperationContextInputSchema, OperationInputSchema, OperationWithContextInputSchema, OperationsFilterInputSchema, PACKAGE_ROUTE_SEGMENT, PGLITE_UTC_PARSERS, PackageManagementService, PackageManager, PackagesSubgraph, PagingInputSchema, PhDocumentFieldsFragmentDoc, PollSyncEnvelopesDocument, PrivacyPermissionAdapter, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, ReactorSignerAppInputSchema, ReactorSignerInputSchema, ReactorSignerUserInputSchema, ReactorSubgraph, RefusalNotRecordedError, RelationalWebhookStore, RemoteCursorInputSchema, RemoteFilterInputSchema, RemoveRelationshipDocument, RenameDocumentDocument, SearchFilterInputSchema, SetPreferredEditorDocument, SyncEnvelopeInputSchema, SyncEnvelopeType, SyncEnvelopeTypeSchema, SyncRefusalInputSchema, SystemSubgraph, TouchChannelDocument, TouchChannelInputSchema, UpdateRelationshipDocument, ViewFilterInputSchema, WEBHOOK_SEGMENT, WS_AUTH_CLOSE_REASONS, WS_CLOSE_REASON_AUTHENTICATION_REQUIRED, WS_CLOSE_REASON_BEARER_REJECTED, WebhookService, assertAttachmentPolicyReadsAllowed, assertAuthRequiredForDocumentPermissions, assertCredentialVerifierForSource, assertHostMountPath, assertRequireAuthenticatedCallerAllowed, assertSkipCredentialVerificationAllowed, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, callerSubject, createAuthFetchMiddleware, createCanonicalDocumentIdResolver, createGatewayAdapter, createHttpAdapter, createMergedSchema, createReactorGraphQLClient, createRenownCredentialVerifier, createSchema, createWsAuthHandlers, decodeExplorerUrlState, definedNonNullAnySchema, driveIdFromUrl, extractSubgraphsFromModule, generateDocumentModelSchema, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelTypeDefs, getExplorerPrefix, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getUniqueUpgradeManifests, getVersion, initAnalyticsStoreSql, initializeAndStartAPI, isDefinedNonNullAny, isExpectedLoaderMiss, isSubgraphClass, namespacePath, namespaceSegments, newWebhookToken, parseDriveUrl, parseWebhookBody, piecesBaseUrl, redactHeaders, renderGraphqlPlayground, resolvePackageName, resolveRenownConfig, verifyWebhook };
|
|
9411
9600
|
|
|
9412
9601
|
//# sourceMappingURL=index.mjs.map
|
|
9413
|
-
//# debugId=
|
|
9602
|
+
//# debugId=ae77d1e5-904a-549c-a5d4-37e03fc0801e
|