@powerhousedao/reactor-api 6.0.0-dev.252 → 6.0.0-dev.254
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 +25 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +92 -66
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -13
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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]="def0f6e3-b149-5760-8c0c-611814c2a321")}catch(e){}}();
|
|
3
3
|
import { a as isSubgraphClass, c as loadDocumentModels, d as BaseSubgraph, i as buildGraphqlOperations, l as loadProcessors, n as buildGraphQlDriveDocument, o as debounce, r as buildGraphqlOperation, t as buildGraphQlDocument, u as loadSubgraphs } from "./utils-CHCRSWig.mjs";
|
|
4
4
|
import { AnalyticsQueryEngine } from "@powerhousedao/analytics-engine-core";
|
|
5
5
|
import { AnalyticsModel, AnalyticsResolvers, typedefs } from "@powerhousedao/analytics-engine-graphql";
|
|
@@ -33,7 +33,7 @@ import { typeDefs } from "@powerhousedao/document-engineering/graphql";
|
|
|
33
33
|
import { camelCase, kebabCase, pascalCase } from "change-case";
|
|
34
34
|
import { GraphQLJSONObject } from "graphql-type-json";
|
|
35
35
|
import { setName } from "@powerhousedao/shared/document-model";
|
|
36
|
-
import { PropagationMode as PropagationMode$1, consolidateSyncOperations, driveIdFromUrl, envelopesToSyncOperations, parseDriveUrl } from "@powerhousedao/reactor";
|
|
36
|
+
import { DEFAULT_DRIVE_CONTAINER_TYPES, PropagationMode as PropagationMode$1, consolidateSyncOperations, driveIdFromUrl, envelopesToSyncOperations, parseDriveUrl } from "@powerhousedao/reactor";
|
|
37
37
|
import * as z$1 from "zod";
|
|
38
38
|
import { z } from "zod";
|
|
39
39
|
import { createHandler } from "graphql-sse/lib/use/fetch";
|
|
@@ -41,6 +41,7 @@ import { PubSub, withFilter } from "graphql-subscriptions";
|
|
|
41
41
|
import dotenv from "dotenv";
|
|
42
42
|
import { buildTreeUrl } from "@powerhousedao/shared";
|
|
43
43
|
import { getConfig } from "@powerhousedao/config/node";
|
|
44
|
+
import { reactorDriveDocumentModelModule } from "@powerhousedao/reactor-drive";
|
|
44
45
|
import { driveDocumentModelModule } from "@powerhousedao/shared/document-drive";
|
|
45
46
|
import EventEmitter from "node:events";
|
|
46
47
|
import { PostgresAnalyticsStore } from "@powerhousedao/analytics-engine-pg";
|
|
@@ -2739,11 +2740,29 @@ function matchesJobFilter(payload, args) {
|
|
|
2739
2740
|
//#endregion
|
|
2740
2741
|
//#region src/graphql/reactor/constants.ts
|
|
2741
2742
|
/**
|
|
2742
|
-
*
|
|
2743
|
-
*
|
|
2744
|
-
*
|
|
2743
|
+
* Returns true when the given document type represents a drive container.
|
|
2744
|
+
* Delegates to the reactor's `DEFAULT_DRIVE_CONTAINER_TYPES`, so both the
|
|
2745
|
+
* legacy `powerhouse/document-drive` and the newer `powerhouse/reactor-drive`
|
|
2746
|
+
* count.
|
|
2745
2747
|
*/
|
|
2746
|
-
|
|
2748
|
+
function isDriveContainerType(documentType) {
|
|
2749
|
+
return DEFAULT_DRIVE_CONTAINER_TYPES.has(documentType);
|
|
2750
|
+
}
|
|
2751
|
+
//#endregion
|
|
2752
|
+
//#region src/graphql/reactor/resolvers.ts
|
|
2753
|
+
const REACTOR_DRIVE_DOCUMENT_TYPE = "powerhouse/reactor-drive";
|
|
2754
|
+
/**
|
|
2755
|
+
* Returns the drive client to use for the given drive-container parent type.
|
|
2756
|
+
* Throws when the parent is a reactor-drive container but no
|
|
2757
|
+
* `reactorDriveClient` was provided.
|
|
2758
|
+
*/
|
|
2759
|
+
function pickDriveClient(reactorClient, driveContainerType, reactorDriveClient) {
|
|
2760
|
+
if (driveContainerType === REACTOR_DRIVE_DOCUMENT_TYPE) {
|
|
2761
|
+
if (!reactorDriveClient) throw new GraphQLError("Reactor-drive parent encountered but no reactorDriveClient is configured on this switchboard");
|
|
2762
|
+
return reactorDriveClient;
|
|
2763
|
+
}
|
|
2764
|
+
return reactorClient.drives;
|
|
2765
|
+
}
|
|
2747
2766
|
async function documentModels(reactorClient, args) {
|
|
2748
2767
|
const namespace = fromInputMaybe(args.namespace);
|
|
2749
2768
|
let paging;
|
|
@@ -2932,16 +2951,18 @@ async function documentOperations(reactorClient, args) {
|
|
|
2932
2951
|
throw new GraphQLError(`Failed to convert operations to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2933
2952
|
}
|
|
2934
2953
|
}
|
|
2935
|
-
async function createDocument(reactorClient, args) {
|
|
2954
|
+
async function createDocument(reactorClient, args, reactorDriveClient) {
|
|
2936
2955
|
if (!args.document || typeof args.document !== "object") throw new GraphQLError("Invalid document: must be an object");
|
|
2937
2956
|
const document = args.document;
|
|
2938
2957
|
if (!document.header || typeof document.header !== "object") throw new GraphQLError("Invalid document: missing or invalid header");
|
|
2939
2958
|
const parentIdentifier = fromInputMaybe(args.parentIdentifier);
|
|
2940
2959
|
let result;
|
|
2941
2960
|
try {
|
|
2942
|
-
if (parentIdentifier)
|
|
2943
|
-
|
|
2944
|
-
|
|
2961
|
+
if (parentIdentifier) {
|
|
2962
|
+
const parent = await reactorClient.get(parentIdentifier);
|
|
2963
|
+
if (isDriveContainerType(parent.header.documentType)) result = await pickDriveClient(reactorClient, parent.header.documentType, reactorDriveClient).addFile(parentIdentifier, document);
|
|
2964
|
+
else result = await reactorClient.create(document, parentIdentifier);
|
|
2965
|
+
} else result = await reactorClient.create(document);
|
|
2945
2966
|
} catch (error) {
|
|
2946
2967
|
throw new GraphQLError(`Failed to create document: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2947
2968
|
}
|
|
@@ -2951,17 +2972,19 @@ async function createDocument(reactorClient, args) {
|
|
|
2951
2972
|
throw new GraphQLError(`Failed to convert created document to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2952
2973
|
}
|
|
2953
2974
|
}
|
|
2954
|
-
async function createEmptyDocument(reactorClient, args) {
|
|
2975
|
+
async function createEmptyDocument(reactorClient, args, reactorDriveClient) {
|
|
2955
2976
|
const parentIdentifier = fromInputMaybe(args.parentIdentifier);
|
|
2956
2977
|
const name = fromInputMaybe(args.name);
|
|
2957
2978
|
let result;
|
|
2958
2979
|
try {
|
|
2959
|
-
if (parentIdentifier)
|
|
2960
|
-
const
|
|
2961
|
-
if (
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2980
|
+
if (parentIdentifier) {
|
|
2981
|
+
const parent = await reactorClient.get(parentIdentifier);
|
|
2982
|
+
if (isDriveContainerType(parent.header.documentType)) {
|
|
2983
|
+
const document = (await reactorClient.getDocumentModelModule(args.documentType)).utils.createDocument();
|
|
2984
|
+
if (name) document.header.name = name;
|
|
2985
|
+
result = await pickDriveClient(reactorClient, parent.header.documentType, reactorDriveClient).addFile(parentIdentifier, document);
|
|
2986
|
+
} else result = await reactorClient.createEmpty(args.documentType, { parentIdentifier });
|
|
2987
|
+
} else result = await reactorClient.createEmpty(args.documentType, {});
|
|
2965
2988
|
} catch (error) {
|
|
2966
2989
|
throw new GraphQLError(`Failed to create empty document: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2967
2990
|
}
|
|
@@ -2971,7 +2994,7 @@ async function createEmptyDocument(reactorClient, args) {
|
|
|
2971
2994
|
throw new GraphQLError(`Failed to convert created document to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2972
2995
|
}
|
|
2973
2996
|
}
|
|
2974
|
-
async function createDocumentWithInitialState(reactorClient, args) {
|
|
2997
|
+
async function createDocumentWithInitialState(reactorClient, args, reactorDriveClient) {
|
|
2975
2998
|
const parentIdentifier = fromInputMaybe(args.parentIdentifier);
|
|
2976
2999
|
const name = fromInputMaybe(args.name);
|
|
2977
3000
|
const slug = fromInputMaybe(args.slug);
|
|
@@ -3003,12 +3026,14 @@ async function createDocumentWithInitialState(reactorClient, args) {
|
|
|
3003
3026
|
} catch (error) {
|
|
3004
3027
|
throw new GraphQLError(`Parent document not found: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
3005
3028
|
}
|
|
3006
|
-
if (parent.header.documentType
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3029
|
+
if (isDriveContainerType(parent.header.documentType)) {
|
|
3030
|
+
const driveClient = pickDriveClient(reactorClient, parent.header.documentType, reactorDriveClient);
|
|
3031
|
+
try {
|
|
3032
|
+
result = await driveClient.addFile(parentIdentifier, document);
|
|
3033
|
+
} catch (error) {
|
|
3034
|
+
throw new GraphQLError(`Failed to create document in drive: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
3035
|
+
}
|
|
3036
|
+
} else try {
|
|
3012
3037
|
result = await reactorClient.create(document, parentIdentifier);
|
|
3013
3038
|
} catch (error) {
|
|
3014
3039
|
throw new GraphQLError(`Failed to create document with parent: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
@@ -3136,11 +3161,11 @@ async function moveRelationship(reactorClient, args) {
|
|
|
3136
3161
|
throw new GraphQLError(`Failed to convert documents to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
3137
3162
|
}
|
|
3138
3163
|
}
|
|
3139
|
-
async function deleteDocument(reactorClient, args) {
|
|
3164
|
+
async function deleteDocument(reactorClient, args, reactorDriveClient) {
|
|
3140
3165
|
const propagate = toReactorPropagationMode(args.propagate);
|
|
3141
3166
|
try {
|
|
3142
|
-
const driveParent = (await reactorClient.getIncomingRelationships(args.identifier, "child")).results.find((p) => p.header.documentType
|
|
3143
|
-
if (driveParent) await reactorClient.
|
|
3167
|
+
const driveParent = (await reactorClient.getIncomingRelationships(args.identifier, "child")).results.find((p) => isDriveContainerType(p.header.documentType));
|
|
3168
|
+
if (driveParent) await pickDriveClient(reactorClient, driveParent.header.documentType, reactorDriveClient).removeNode(driveParent.header.id, args.identifier);
|
|
3144
3169
|
else await reactorClient.deleteDocument(args.identifier, propagate);
|
|
3145
3170
|
return true;
|
|
3146
3171
|
} catch (error) {
|
|
@@ -3500,12 +3525,12 @@ var DocumentModelSubgraph = class extends BaseSubgraph {
|
|
|
3500
3525
|
slug,
|
|
3501
3526
|
preferredEditor,
|
|
3502
3527
|
initialState: initialState ?? {}
|
|
3503
|
-
});
|
|
3528
|
+
}, this.graphqlManager.reactorDriveClient);
|
|
3504
3529
|
else createdDoc = await createEmptyDocument(this.reactorClient, {
|
|
3505
3530
|
documentType,
|
|
3506
3531
|
parentIdentifier,
|
|
3507
3532
|
name
|
|
3508
|
-
});
|
|
3533
|
+
}, this.graphqlManager.reactorDriveClient);
|
|
3509
3534
|
if (this.authorizationService && ctx.user?.address && createdDoc?.id) await this.documentPermissionService?.initializeDocumentProtection(createdDoc.id, ctx.user.address, this.authorizationService.config.defaultProtection);
|
|
3510
3535
|
if (!initialState && !preferredEditor && name && createdDoc.name !== name) return toGqlPhDocument(await this.reactorClient.execute(createdDoc.id, "main", [setName(name)]));
|
|
3511
3536
|
return createdDoc;
|
|
@@ -3519,7 +3544,7 @@ var DocumentModelSubgraph = class extends BaseSubgraph {
|
|
|
3519
3544
|
const result = await createEmptyDocument(this.reactorClient, {
|
|
3520
3545
|
documentType,
|
|
3521
3546
|
parentIdentifier
|
|
3522
|
-
});
|
|
3547
|
+
}, this.graphqlManager.reactorDriveClient);
|
|
3523
3548
|
if (this.authorizationService && ctx.user?.address && result?.id) await this.documentPermissionService?.initializeDocumentProtection(result.id, ctx.user.address, this.authorizationService.config.defaultProtection);
|
|
3524
3549
|
return result;
|
|
3525
3550
|
},
|
|
@@ -3627,11 +3652,12 @@ function wrongShardResponse(driveId) {
|
|
|
3627
3652
|
/**
|
|
3628
3653
|
* In-memory record of which drives this switchboard instance owns.
|
|
3629
3654
|
*
|
|
3630
|
-
* Populated at startup by walking the reactor for documents
|
|
3631
|
-
*
|
|
3632
|
-
*
|
|
3633
|
-
* drive
|
|
3634
|
-
* requests with a structured
|
|
3655
|
+
* Populated at startup by walking the reactor for documents whose type is
|
|
3656
|
+
* listed in `DEFAULT_DRIVE_CONTAINER_TYPES` (both legacy `document-drive`
|
|
3657
|
+
* and `reactor-drive`). Mutated explicitly by resolver hooks after
|
|
3658
|
+
* successful drive create / delete operations. Read by the drive-validation
|
|
3659
|
+
* fetch middleware to short-circuit wrong-shard requests with a structured
|
|
3660
|
+
* 421 response.
|
|
3635
3661
|
*/
|
|
3636
3662
|
var DriveOwnershipCache = class {
|
|
3637
3663
|
drives = /* @__PURE__ */ new Set();
|
|
@@ -3640,11 +3666,13 @@ var DriveOwnershipCache = class {
|
|
|
3640
3666
|
}
|
|
3641
3667
|
async init() {
|
|
3642
3668
|
this.drives.clear();
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3669
|
+
for (const driveType of DEFAULT_DRIVE_CONTAINER_TYPES) {
|
|
3670
|
+
let page = await this.reactorClient.find({ type: driveType });
|
|
3671
|
+
while (true) {
|
|
3672
|
+
for (const drive of page.results) this.drives.add(drive.header.id);
|
|
3673
|
+
if (!page.next) break;
|
|
3674
|
+
page = await page.next();
|
|
3675
|
+
}
|
|
3648
3676
|
}
|
|
3649
3677
|
}
|
|
3650
3678
|
has(driveId) {
|
|
@@ -3729,7 +3757,13 @@ var GraphQLManager = class {
|
|
|
3729
3757
|
/** Cached document models for schema generation - updated on init and regenerate */
|
|
3730
3758
|
cachedDocumentModels = [];
|
|
3731
3759
|
subgraphHandlerCache = /* @__PURE__ */ new Map();
|
|
3732
|
-
|
|
3760
|
+
/**
|
|
3761
|
+
* Optional reactor-drive client. When the switchboard is configured with a
|
|
3762
|
+
* reactor-drive container, this is provided and the resolvers dispatch to
|
|
3763
|
+
* it for reactor-drive parents.
|
|
3764
|
+
*/
|
|
3765
|
+
reactorDriveClient;
|
|
3766
|
+
constructor(path, httpServer, wsServer, reactorClient, relationalDb, analyticsStore, syncManager, logger, httpAdapter, gatewayAdapter, authConfig, documentPermissionService, featureFlags = DefaultFeatureFlags, port = 4001, authorizationService, reactorDriveClient) {
|
|
3733
3767
|
this.path = path;
|
|
3734
3768
|
this.httpServer = httpServer;
|
|
3735
3769
|
this.wsServer = wsServer;
|
|
@@ -3745,6 +3779,7 @@ var GraphQLManager = class {
|
|
|
3745
3779
|
this.featureFlags = featureFlags;
|
|
3746
3780
|
this.port = port;
|
|
3747
3781
|
this.authorizationService = authorizationService;
|
|
3782
|
+
this.reactorDriveClient = reactorDriveClient;
|
|
3748
3783
|
if (this.authConfig) this.authService = new AuthService(this.authConfig);
|
|
3749
3784
|
this.driveOwnershipCache = new DriveOwnershipCache(this.reactorClient);
|
|
3750
3785
|
this.wsServer.setMaxListeners(0);
|
|
@@ -4593,7 +4628,7 @@ var ReactorSubgraph = class extends BaseSubgraph {
|
|
|
4593
4628
|
async #resolveDriveId(identifier) {
|
|
4594
4629
|
try {
|
|
4595
4630
|
const doc = await this.reactorClient.get(identifier);
|
|
4596
|
-
if (doc.header.documentType
|
|
4631
|
+
if (isDriveContainerType(doc.header.documentType)) return doc.header.id;
|
|
4597
4632
|
return;
|
|
4598
4633
|
} catch {
|
|
4599
4634
|
return;
|
|
@@ -4738,8 +4773,8 @@ var ReactorSubgraph = class extends BaseSubgraph {
|
|
|
4738
4773
|
} else if (this.authorizationService) {
|
|
4739
4774
|
if (!ctx.user?.address) throw new GraphQLError("Forbidden: authentication required to create documents");
|
|
4740
4775
|
} else if (!this.hasGlobalAdminAccess(ctx)) throw new GraphQLError("Forbidden: insufficient permissions to create documents");
|
|
4741
|
-
const result = await createDocument(this.reactorClient, args);
|
|
4742
|
-
if (result?.id && result.documentType
|
|
4776
|
+
const result = await createDocument(this.reactorClient, args, this.graphqlManager.reactorDriveClient);
|
|
4777
|
+
if (result?.id && isDriveContainerType(result.documentType)) this.graphqlManager.driveOwnershipCache.add(result.id);
|
|
4743
4778
|
if (this.authorizationService && ctx.user?.address && result?.id) await this.documentPermissionService?.initializeDocumentProtection(result.id, ctx.user.address, this.authorizationService.config.defaultProtection);
|
|
4744
4779
|
return result;
|
|
4745
4780
|
} catch (error) {
|
|
@@ -4756,8 +4791,8 @@ var ReactorSubgraph = class extends BaseSubgraph {
|
|
|
4756
4791
|
} else if (this.authorizationService) {
|
|
4757
4792
|
if (!ctx.user?.address) throw new GraphQLError("Forbidden: authentication required to create documents");
|
|
4758
4793
|
} else if (!this.hasGlobalAdminAccess(ctx)) throw new GraphQLError("Forbidden: insufficient permissions to create documents");
|
|
4759
|
-
const result = await createEmptyDocument(this.reactorClient, args);
|
|
4760
|
-
if (result?.id && result.documentType
|
|
4794
|
+
const result = await createEmptyDocument(this.reactorClient, args, this.graphqlManager.reactorDriveClient);
|
|
4795
|
+
if (result?.id && isDriveContainerType(result.documentType)) this.graphqlManager.driveOwnershipCache.add(result.id);
|
|
4761
4796
|
if (this.authorizationService && ctx.user?.address && result?.id) await this.documentPermissionService?.initializeDocumentProtection(result.id, ctx.user.address, this.authorizationService.config.defaultProtection);
|
|
4762
4797
|
return result;
|
|
4763
4798
|
} catch (error) {
|
|
@@ -4843,7 +4878,7 @@ var ReactorSubgraph = class extends BaseSubgraph {
|
|
|
4843
4878
|
try {
|
|
4844
4879
|
await this.assertCanWrite(args.identifier, ctx);
|
|
4845
4880
|
const driveIdToInvalidate = await this.#resolveDriveId(args.identifier);
|
|
4846
|
-
const result = await deleteDocument(this.reactorClient, args);
|
|
4881
|
+
const result = await deleteDocument(this.reactorClient, args, this.graphqlManager.reactorDriveClient);
|
|
4847
4882
|
if (result && driveIdToInvalidate) this.graphqlManager.driveOwnershipCache.remove(driveIdToInvalidate);
|
|
4848
4883
|
return result;
|
|
4849
4884
|
} catch (error) {
|
|
@@ -4951,10 +4986,10 @@ const ADMIN_USERS = getAdminUsers();
|
|
|
4951
4986
|
//#endregion
|
|
4952
4987
|
//#region src/graphql/system/version.ts
|
|
4953
4988
|
function getVersion() {
|
|
4954
|
-
return "6.0.0-dev.
|
|
4989
|
+
return "6.0.0-dev.254";
|
|
4955
4990
|
}
|
|
4956
4991
|
function getGitHash() {
|
|
4957
|
-
return "
|
|
4992
|
+
return "eaf7ea34a9c63dff39a6b51f25ba4ac793ceac4d";
|
|
4958
4993
|
}
|
|
4959
4994
|
function getGitUrl() {
|
|
4960
4995
|
return buildTreeUrl(getGitHash());
|
|
@@ -5244,6 +5279,7 @@ var PackageManager = class {
|
|
|
5244
5279
|
const documentModelModuleMap = /* @__PURE__ */ new Map();
|
|
5245
5280
|
documentModelModuleMap.set("document-drive", [driveDocumentModelModule]);
|
|
5246
5281
|
documentModelModuleMap.set("document-model", [documentModelDocumentModelModule]);
|
|
5282
|
+
documentModelModuleMap.set("reactor-drive", [reactorDriveDocumentModelModule]);
|
|
5247
5283
|
for (const pkg of packages) {
|
|
5248
5284
|
const allDocumentModels = [];
|
|
5249
5285
|
for (const loader of this.loaders) try {
|
|
@@ -6248,11 +6284,11 @@ function makeDbClosers(knexInstance, pglite) {
|
|
|
6248
6284
|
/**
|
|
6249
6285
|
* Sets up the subgraph manager and registers subgraphs
|
|
6250
6286
|
*/
|
|
6251
|
-
async function setupGraphQLManager(httpAdapter, authFetchMiddleware, httpServer, wsServer, client, relationalDb, analyticsStore, syncManager, subgraphs, logger, auth, documentPermissionService, enableDocumentModelSubgraphs, port, authorizationService) {
|
|
6287
|
+
async function setupGraphQLManager(httpAdapter, authFetchMiddleware, httpServer, wsServer, client, relationalDb, analyticsStore, syncManager, subgraphs, logger, auth, documentPermissionService, enableDocumentModelSubgraphs, port, authorizationService, reactorDriveClient) {
|
|
6252
6288
|
const graphqlManager = new GraphQLManager(config.basePath, httpServer, wsServer, client, relationalDb, analyticsStore, syncManager, logger, httpAdapter, createGatewayAdapter("apollo", logger), {
|
|
6253
6289
|
enabled: auth?.enabled ?? false,
|
|
6254
6290
|
admins: auth?.admins ?? []
|
|
6255
|
-
}, documentPermissionService, { enableDocumentModelSubgraphs }, port, authorizationService);
|
|
6291
|
+
}, documentPermissionService, { enableDocumentModelSubgraphs }, port, authorizationService, reactorDriveClient);
|
|
6256
6292
|
await graphqlManager.init(subgraphs.core, authFetchMiddleware);
|
|
6257
6293
|
for (const [, collection] of subgraphs.extended.entries()) for (const subgraph of collection) await graphqlManager.registerSubgraph(subgraph, "graphql");
|
|
6258
6294
|
await graphqlManager.updateRouter();
|
|
@@ -6413,7 +6449,7 @@ async function _setupCommonInfrastructure(options) {
|
|
|
6413
6449
|
/**
|
|
6414
6450
|
* Private helper function containing common setup logic for API initialization
|
|
6415
6451
|
*/
|
|
6416
|
-
async function _setupAPI(reactorClient, syncManager, reactorProcessorManager, httpAdapter, authFetchMiddleware, authService, port, packages, relationalDb, analyticsStore, documentPermissionService, processors, subgraphs, options, auth, processorApp, readModels, attachments, authorizationService, documentModelRegistry, dbClosers = []) {
|
|
6452
|
+
async function _setupAPI(reactorClient, syncManager, reactorProcessorManager, httpAdapter, authFetchMiddleware, authService, port, packages, relationalDb, analyticsStore, documentPermissionService, processors, subgraphs, options, auth, processorApp, readModels, attachments, authorizationService, documentModelRegistry, dbClosers = [], reactorDriveClient) {
|
|
6417
6453
|
const hostModule = {
|
|
6418
6454
|
relationalDb,
|
|
6419
6455
|
analyticsStore,
|
|
@@ -6465,7 +6501,7 @@ async function _setupAPI(reactorClient, syncManager, reactorProcessorManager, ht
|
|
|
6465
6501
|
const graphqlManager = await setupGraphQLManager(httpAdapter, authFetchMiddleware, httpServer, wsServer, reactorClient, relationalDb, analyticsStore, syncManager, {
|
|
6466
6502
|
extended: subgraphs,
|
|
6467
6503
|
core: coreSubgraphs
|
|
6468
|
-
}, logger.child(["graphql-manager"]), auth, documentPermissionService, options.enableDocumentModelSubgraphs, port, authorizationService);
|
|
6504
|
+
}, logger.child(["graphql-manager"]), auth, documentPermissionService, options.enableDocumentModelSubgraphs, port, authorizationService, reactorDriveClient);
|
|
6469
6505
|
setupEventListeners(packages, graphqlManager, reactorProcessorManager, hostModule, documentModelRegistry);
|
|
6470
6506
|
if (mcpServerEnabled) {
|
|
6471
6507
|
await setupMcpServer({
|
|
@@ -6526,20 +6562,10 @@ function buildApiDispose(args) {
|
|
|
6526
6562
|
}
|
|
6527
6563
|
};
|
|
6528
6564
|
}
|
|
6529
|
-
/**
|
|
6530
|
-
* Initializes and starts the API server using an initializer function.
|
|
6531
|
-
* This function first loads packages to get document models, then calls the initializer function
|
|
6532
|
-
* to create the reactor client module with the appropriate dependencies.
|
|
6533
|
-
*
|
|
6534
|
-
* @param clientInitializer - Initializer function that creates the reactor client module with document models.
|
|
6535
|
-
* @param options - Additional options for server configuration.
|
|
6536
|
-
*
|
|
6537
|
-
* @returns The API server components along with the created client instances.
|
|
6538
|
-
*/
|
|
6539
6565
|
async function initializeAndStartAPI(clientInitializer, options, processorApp) {
|
|
6540
6566
|
const { port, httpAdapter, authFetchMiddleware, authService, auth, relationalDb, analyticsStore, documentPermissionService, authorizationService, attachments, packages, dbClosers } = await _setupCommonInfrastructure(options);
|
|
6541
6567
|
const { documentModels, processors, subgraphs } = await packages.init();
|
|
6542
|
-
const reactorClientModule = await clientInitializer(documentModels);
|
|
6568
|
+
const { module: reactorClientModule, reactorDriveClient } = await clientInitializer(documentModels);
|
|
6543
6569
|
const reactorClient = reactorClientModule.client;
|
|
6544
6570
|
const syncManager = reactorClientModule.reactorModule?.syncModule?.syncManager;
|
|
6545
6571
|
if (!syncManager) throw new Error("SyncManager not available from ReactorClientModule");
|
|
@@ -6548,7 +6574,7 @@ async function initializeAndStartAPI(clientInitializer, options, processorApp) {
|
|
|
6548
6574
|
const documentModelRegistry = reactorClientModule.reactorModule?.documentModelRegistry;
|
|
6549
6575
|
if (!documentModelRegistry) throw new Error("DocumentModelRegistry not available from ReactorClientModule");
|
|
6550
6576
|
return {
|
|
6551
|
-
...await _setupAPI(reactorClient, syncManager, reactorProcessorManager, httpAdapter, authFetchMiddleware, authService, port, packages, relationalDb, analyticsStore, documentPermissionService, processors, subgraphs, options, auth, processorApp, (reactorClientModule.reactorModule?.readModelCoordinator)?.readModels ?? [], attachments, authorizationService, documentModelRegistry, dbClosers),
|
|
6577
|
+
...await _setupAPI(reactorClient, syncManager, reactorProcessorManager, httpAdapter, authFetchMiddleware, authService, port, packages, relationalDb, analyticsStore, documentPermissionService, processors, subgraphs, options, auth, processorApp, (reactorClientModule.reactorModule?.readModelCoordinator)?.readModels ?? [], attachments, authorizationService, documentModelRegistry, dbClosers, reactorDriveClient),
|
|
6552
6578
|
client: reactorClient,
|
|
6553
6579
|
syncManager,
|
|
6554
6580
|
documentModelRegistry
|
|
@@ -6657,4 +6683,4 @@ var PackageManagementService = class {
|
|
|
6657
6683
|
export { ADMIN_USERS, ActionContextInputSchema, ActionInputSchema, AddRelationshipDocument, AnalyticsSubgraph, AttachmentInputSchema, AuthService, AuthSubgraph, 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, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, createAuthFetchMiddleware, createGatewayAdapter, createHttpAdapter, createMergedSchema, createReactorGraphQLClient, createSchema, definedNonNullAnySchema, driveIdFromUrl, generateDocumentModelSchema, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelTypeDefs, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getVersion, initAnalyticsStoreSql, initializeAndStartAPI, isDefinedNonNullAny, isSubgraphClass, parseDriveUrl, renderGraphqlPlayground };
|
|
6658
6684
|
|
|
6659
6685
|
//# sourceMappingURL=index.mjs.map
|
|
6660
|
-
//# debugId=
|
|
6686
|
+
//# debugId=def0f6e3-b149-5760-8c0c-611814c2a321
|