@powerhousedao/reactor-api 6.0.2-staging.7 → 6.0.2-staging.9
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 +59 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +143 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -15
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";
|
|
@@ -52,6 +53,7 @@ import { WebSocketServer } from "ws";
|
|
|
52
53
|
import { createRelationalDb } from "@powerhousedao/shared/processors";
|
|
53
54
|
import { Kysely, Migrator, sql } from "kysely";
|
|
54
55
|
import { PGlite } from "@electric-sql/pglite";
|
|
56
|
+
import { AtomicNodeFs } from "@powerhousedao/pglite-fs";
|
|
55
57
|
import knex from "knex";
|
|
56
58
|
import ClientPgLite from "knex-pglite";
|
|
57
59
|
import { KyselyKnexDialect, PGColdDialect } from "kysely-knex";
|
|
@@ -2252,6 +2254,22 @@ const RenameDocumentDocument = gql`
|
|
|
2252
2254
|
}
|
|
2253
2255
|
${PhDocumentFieldsFragmentDoc}
|
|
2254
2256
|
`;
|
|
2257
|
+
const SetPreferredEditorDocument = gql`
|
|
2258
|
+
mutation SetPreferredEditor(
|
|
2259
|
+
$documentIdentifier: String!
|
|
2260
|
+
$preferredEditor: String
|
|
2261
|
+
$branch: String
|
|
2262
|
+
) {
|
|
2263
|
+
setPreferredEditor(
|
|
2264
|
+
documentIdentifier: $documentIdentifier
|
|
2265
|
+
preferredEditor: $preferredEditor
|
|
2266
|
+
branch: $branch
|
|
2267
|
+
) {
|
|
2268
|
+
...PHDocumentFields
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
${PhDocumentFieldsFragmentDoc}
|
|
2272
|
+
`;
|
|
2255
2273
|
const AddRelationshipDocument = gql`
|
|
2256
2274
|
mutation AddRelationship(
|
|
2257
2275
|
$sourceIdentifier: String!
|
|
@@ -2485,6 +2503,9 @@ function getSdk(requester) {
|
|
|
2485
2503
|
RenameDocument(variables, options) {
|
|
2486
2504
|
return requester(RenameDocumentDocument, variables, options);
|
|
2487
2505
|
},
|
|
2506
|
+
SetPreferredEditor(variables, options) {
|
|
2507
|
+
return requester(SetPreferredEditorDocument, variables, options);
|
|
2508
|
+
},
|
|
2488
2509
|
AddRelationship(variables, options) {
|
|
2489
2510
|
return requester(AddRelationshipDocument, variables, options);
|
|
2490
2511
|
},
|
|
@@ -2719,11 +2740,29 @@ function matchesJobFilter(payload, args) {
|
|
|
2719
2740
|
//#endregion
|
|
2720
2741
|
//#region src/graphql/reactor/constants.ts
|
|
2721
2742
|
/**
|
|
2722
|
-
*
|
|
2723
|
-
*
|
|
2724
|
-
*
|
|
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.
|
|
2725
2747
|
*/
|
|
2726
|
-
|
|
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
|
+
}
|
|
2727
2766
|
async function documentModels(reactorClient, args) {
|
|
2728
2767
|
const namespace = fromInputMaybe(args.namespace);
|
|
2729
2768
|
let paging;
|
|
@@ -2912,16 +2951,18 @@ async function documentOperations(reactorClient, args) {
|
|
|
2912
2951
|
throw new GraphQLError(`Failed to convert operations to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2913
2952
|
}
|
|
2914
2953
|
}
|
|
2915
|
-
async function createDocument(reactorClient, args) {
|
|
2954
|
+
async function createDocument(reactorClient, args, reactorDriveClient) {
|
|
2916
2955
|
if (!args.document || typeof args.document !== "object") throw new GraphQLError("Invalid document: must be an object");
|
|
2917
2956
|
const document = args.document;
|
|
2918
2957
|
if (!document.header || typeof document.header !== "object") throw new GraphQLError("Invalid document: missing or invalid header");
|
|
2919
2958
|
const parentIdentifier = fromInputMaybe(args.parentIdentifier);
|
|
2920
2959
|
let result;
|
|
2921
2960
|
try {
|
|
2922
|
-
if (parentIdentifier)
|
|
2923
|
-
|
|
2924
|
-
|
|
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);
|
|
2925
2966
|
} catch (error) {
|
|
2926
2967
|
throw new GraphQLError(`Failed to create document: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2927
2968
|
}
|
|
@@ -2931,17 +2972,19 @@ async function createDocument(reactorClient, args) {
|
|
|
2931
2972
|
throw new GraphQLError(`Failed to convert created document to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2932
2973
|
}
|
|
2933
2974
|
}
|
|
2934
|
-
async function createEmptyDocument(reactorClient, args) {
|
|
2975
|
+
async function createEmptyDocument(reactorClient, args, reactorDriveClient) {
|
|
2935
2976
|
const parentIdentifier = fromInputMaybe(args.parentIdentifier);
|
|
2936
2977
|
const name = fromInputMaybe(args.name);
|
|
2937
2978
|
let result;
|
|
2938
2979
|
try {
|
|
2939
|
-
if (parentIdentifier)
|
|
2940
|
-
const
|
|
2941
|
-
if (
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
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, {});
|
|
2945
2988
|
} catch (error) {
|
|
2946
2989
|
throw new GraphQLError(`Failed to create empty document: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2947
2990
|
}
|
|
@@ -2951,7 +2994,7 @@ async function createEmptyDocument(reactorClient, args) {
|
|
|
2951
2994
|
throw new GraphQLError(`Failed to convert created document to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2952
2995
|
}
|
|
2953
2996
|
}
|
|
2954
|
-
async function createDocumentWithInitialState(reactorClient, args) {
|
|
2997
|
+
async function createDocumentWithInitialState(reactorClient, args, reactorDriveClient) {
|
|
2955
2998
|
const parentIdentifier = fromInputMaybe(args.parentIdentifier);
|
|
2956
2999
|
const name = fromInputMaybe(args.name);
|
|
2957
3000
|
const slug = fromInputMaybe(args.slug);
|
|
@@ -2983,12 +3026,14 @@ async function createDocumentWithInitialState(reactorClient, args) {
|
|
|
2983
3026
|
} catch (error) {
|
|
2984
3027
|
throw new GraphQLError(`Parent document not found: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
2985
3028
|
}
|
|
2986
|
-
if (parent.header.documentType
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
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 {
|
|
2992
3037
|
result = await reactorClient.create(document, parentIdentifier);
|
|
2993
3038
|
} catch (error) {
|
|
2994
3039
|
throw new GraphQLError(`Failed to create document with parent: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
@@ -3056,6 +3101,21 @@ async function renameDocument(reactorClient, args, signal) {
|
|
|
3056
3101
|
throw new GraphQLError(`Failed to convert renamed document to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
3057
3102
|
}
|
|
3058
3103
|
}
|
|
3104
|
+
async function setPreferredEditor(reactorClient, args, signal) {
|
|
3105
|
+
const branch = fromInputMaybe(args.branch);
|
|
3106
|
+
const preferredEditor = fromInputMaybe(args.preferredEditor) ?? null;
|
|
3107
|
+
let result;
|
|
3108
|
+
try {
|
|
3109
|
+
result = await reactorClient.setPreferredEditor(args.documentIdentifier, preferredEditor, branch, signal);
|
|
3110
|
+
} catch (error) {
|
|
3111
|
+
throw new GraphQLError(`Failed to set preferred editor: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
3112
|
+
}
|
|
3113
|
+
try {
|
|
3114
|
+
return toGqlPhDocument(result);
|
|
3115
|
+
} catch (error) {
|
|
3116
|
+
throw new GraphQLError(`Failed to convert updated document to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3059
3119
|
async function addRelationship(reactorClient, args) {
|
|
3060
3120
|
const branch = fromInputMaybe(args.branch);
|
|
3061
3121
|
let result;
|
|
@@ -3101,11 +3161,11 @@ async function moveRelationship(reactorClient, args) {
|
|
|
3101
3161
|
throw new GraphQLError(`Failed to convert documents to GraphQL: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
3102
3162
|
}
|
|
3103
3163
|
}
|
|
3104
|
-
async function deleteDocument(reactorClient, args) {
|
|
3164
|
+
async function deleteDocument(reactorClient, args, reactorDriveClient) {
|
|
3105
3165
|
const propagate = toReactorPropagationMode(args.propagate);
|
|
3106
3166
|
try {
|
|
3107
|
-
const driveParent = (await reactorClient.getIncomingRelationships(args.identifier, "child")).results.find((p) => p.header.documentType
|
|
3108
|
-
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);
|
|
3109
3169
|
else await reactorClient.deleteDocument(args.identifier, propagate);
|
|
3110
3170
|
return true;
|
|
3111
3171
|
} catch (error) {
|
|
@@ -3465,12 +3525,12 @@ var DocumentModelSubgraph = class extends BaseSubgraph {
|
|
|
3465
3525
|
slug,
|
|
3466
3526
|
preferredEditor,
|
|
3467
3527
|
initialState: initialState ?? {}
|
|
3468
|
-
});
|
|
3528
|
+
}, this.graphqlManager.reactorDriveClient);
|
|
3469
3529
|
else createdDoc = await createEmptyDocument(this.reactorClient, {
|
|
3470
3530
|
documentType,
|
|
3471
3531
|
parentIdentifier,
|
|
3472
3532
|
name
|
|
3473
|
-
});
|
|
3533
|
+
}, this.graphqlManager.reactorDriveClient);
|
|
3474
3534
|
if (this.authorizationService && ctx.user?.address && createdDoc?.id) await this.documentPermissionService?.initializeDocumentProtection(createdDoc.id, ctx.user.address, this.authorizationService.config.defaultProtection);
|
|
3475
3535
|
if (!initialState && !preferredEditor && name && createdDoc.name !== name) return toGqlPhDocument(await this.reactorClient.execute(createdDoc.id, "main", [setName(name)]));
|
|
3476
3536
|
return createdDoc;
|
|
@@ -3484,7 +3544,7 @@ var DocumentModelSubgraph = class extends BaseSubgraph {
|
|
|
3484
3544
|
const result = await createEmptyDocument(this.reactorClient, {
|
|
3485
3545
|
documentType,
|
|
3486
3546
|
parentIdentifier
|
|
3487
|
-
});
|
|
3547
|
+
}, this.graphqlManager.reactorDriveClient);
|
|
3488
3548
|
if (this.authorizationService && ctx.user?.address && result?.id) await this.documentPermissionService?.initializeDocumentProtection(result.id, ctx.user.address, this.authorizationService.config.defaultProtection);
|
|
3489
3549
|
return result;
|
|
3490
3550
|
},
|
|
@@ -3592,11 +3652,12 @@ function wrongShardResponse(driveId) {
|
|
|
3592
3652
|
/**
|
|
3593
3653
|
* In-memory record of which drives this switchboard instance owns.
|
|
3594
3654
|
*
|
|
3595
|
-
* Populated at startup by walking the reactor for documents
|
|
3596
|
-
*
|
|
3597
|
-
*
|
|
3598
|
-
* drive
|
|
3599
|
-
* 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.
|
|
3600
3661
|
*/
|
|
3601
3662
|
var DriveOwnershipCache = class {
|
|
3602
3663
|
drives = /* @__PURE__ */ new Set();
|
|
@@ -3605,11 +3666,13 @@ var DriveOwnershipCache = class {
|
|
|
3605
3666
|
}
|
|
3606
3667
|
async init() {
|
|
3607
3668
|
this.drives.clear();
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
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
|
+
}
|
|
3613
3676
|
}
|
|
3614
3677
|
}
|
|
3615
3678
|
has(driveId) {
|
|
@@ -3694,7 +3757,13 @@ var GraphQLManager = class {
|
|
|
3694
3757
|
/** Cached document models for schema generation - updated on init and regenerate */
|
|
3695
3758
|
cachedDocumentModels = [];
|
|
3696
3759
|
subgraphHandlerCache = /* @__PURE__ */ new Map();
|
|
3697
|
-
|
|
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) {
|
|
3698
3767
|
this.path = path;
|
|
3699
3768
|
this.httpServer = httpServer;
|
|
3700
3769
|
this.wsServer = wsServer;
|
|
@@ -3710,6 +3779,7 @@ var GraphQLManager = class {
|
|
|
3710
3779
|
this.featureFlags = featureFlags;
|
|
3711
3780
|
this.port = port;
|
|
3712
3781
|
this.authorizationService = authorizationService;
|
|
3782
|
+
this.reactorDriveClient = reactorDriveClient;
|
|
3713
3783
|
if (this.authConfig) this.authService = new AuthService(this.authConfig);
|
|
3714
3784
|
this.driveOwnershipCache = new DriveOwnershipCache(this.reactorClient);
|
|
3715
3785
|
this.wsServer.setMaxListeners(0);
|
|
@@ -4396,6 +4466,9 @@ const operationValidators = {
|
|
|
4396
4466
|
RenameDocument: (data) => {
|
|
4397
4467
|
if (data.renameDocument) PHDocumentDTO.parse(data.renameDocument);
|
|
4398
4468
|
},
|
|
4469
|
+
SetPreferredEditor: (data) => {
|
|
4470
|
+
if (data.setPreferredEditor) PHDocumentDTO.parse(data.setPreferredEditor);
|
|
4471
|
+
},
|
|
4399
4472
|
AddRelationship: (data) => {
|
|
4400
4473
|
if (data.addRelationship) PHDocumentDTO.parse(data.addRelationship);
|
|
4401
4474
|
},
|
|
@@ -4440,7 +4513,7 @@ function createReactorGraphQLClient(url, fetchImpl = fetch, headers) {
|
|
|
4440
4513
|
}
|
|
4441
4514
|
//#endregion
|
|
4442
4515
|
//#region src/graphql/reactor/schema.graphql
|
|
4443
|
-
var schema_default = "# Scalar types (for codegen - also defined in create-schema.ts)\nscalar JSONObject\nscalar DateTime\n\n# Input types\ninput PagingInput {\n limit: Int\n offset: Int\n cursor: String\n}\n\ninput ViewFilterInput {\n branch: String\n scopes: [String!]\n}\n\ninput SearchFilterInput {\n type: String\n parentId: String\n identifiers: [String!]\n}\n\ninput OperationsFilterInput {\n documentId: String!\n branch: String\n scopes: [String!]\n actionTypes: [String!]\n sinceRevision: Int\n timestampFrom: String\n timestampTo: String\n}\n\ninput DocumentOperationsFilterInput {\n branch: String\n scopes: [String!]\n actionTypes: [String!]\n sinceRevision: Int\n timestampFrom: String\n timestampTo: String\n}\n\n# Enums\nenum PropagationMode {\n CASCADE\n ORPHAN\n}\n\nenum DocumentChangeType {\n CREATED\n DELETED\n UPDATED\n PARENT_ADDED\n PARENT_REMOVED\n CHILD_ADDED\n CHILD_REMOVED\n}\n\n# Object types\ntype DocumentModelGlobalState {\n id: String!\n name: String!\n namespace: String\n version: String\n specification: JSONObject!\n}\n\ntype DocumentModelResultPage {\n items: [DocumentModelGlobalState!]!\n totalCount: Int!\n hasNextPage: Boolean!\n hasPreviousPage: Boolean!\n cursor: String\n}\n\ntype Revision {\n scope: String!\n revision: Int!\n}\n\ntype PHDocument {\n id: String!\n slug: String\n preferredEditor: String\n name: String!\n documentType: String!\n state: JSONObject!\n revisionsList: [Revision!]!\n createdAtUtcIso: DateTime!\n lastModifiedAtUtcIso: DateTime!\n operations(\n filter: DocumentOperationsFilterInput\n paging: PagingInput\n ): ReactorOperationResultPage\n}\n\ntype PHDocumentResultPage {\n items: [PHDocument!]!\n totalCount: Int!\n hasNextPage: Boolean!\n hasPreviousPage: Boolean!\n cursor: String\n}\n\ntype ReactorOperationResultPage {\n items: [ReactorOperation!]!\n totalCount: Int!\n hasNextPage: Boolean!\n hasPreviousPage: Boolean!\n cursor: String\n}\n\ntype DeadLetterInfo {\n documentId: String!\n error: String!\n jobId: String!\n branch: String!\n scopes: [String!]!\n operationCount: Int!\n}\n\ntype PollSyncEnvelopesResult {\n envelopes: [SyncEnvelope!]!\n ackOrdinal: Int!\n deadLetters: [DeadLetterInfo!]!\n hasMore: Boolean!\n}\n\ntype DocumentWithChildren {\n document: PHDocument!\n childIds: [String!]!\n}\n\ntype MoveRelationshipResult {\n source: PHDocument!\n target: PHDocument!\n}\n\ntype JobInfo {\n id: String!\n status: String!\n result: JSONObject!\n error: String\n createdAt: DateTime!\n completedAt: DateTime\n}\n\ntype DocumentChangeEvent {\n type: DocumentChangeType!\n documents: [PHDocument!]!\n context: DocumentChangeContext\n}\n\ntype DocumentChangeContext {\n parentId: String\n childId: String\n}\n\ntype JobChangeEvent {\n jobId: String!\n status: String!\n result: JSONObject!\n error: String\n}\n\ntype ReactorSignerUser {\n address: String!\n networkId: String!\n chainId: Int!\n}\n\ntype ReactorSignerApp {\n name: String!\n key: String!\n}\n\ntype ReactorSigner {\n user: ReactorSignerUser\n app: ReactorSignerApp\n signatures: [String!]!\n}\n\ntype ActionContext {\n signer: ReactorSigner\n}\n\ntype Action {\n id: String!\n type: String!\n timestampUtcMs: String!\n input: JSONObject!\n scope: String!\n attachments: [Attachment!]\n context: ActionContext\n}\n\ntype Attachment {\n data: String!\n mimeType: String!\n hash: String!\n extension: String\n fileName: String\n}\n\n# Input types for sync operations\ninput ActionContextInput {\n signer: ReactorSignerInput\n}\n\ninput ReactorSignerInput {\n user: ReactorSignerUserInput\n app: ReactorSignerAppInput\n signatures: [String!]!\n}\n\ninput ReactorSignerUserInput {\n address: String!\n networkId: String!\n chainId: Int!\n}\n\ninput ReactorSignerAppInput {\n name: String!\n key: String!\n}\n\ninput ActionInput {\n id: String!\n type: String!\n timestampUtcMs: String!\n input: JSONObject!\n scope: String!\n attachments: [AttachmentInput!]\n context: ActionContextInput\n}\n\ninput AttachmentInput {\n data: String!\n mimeType: String!\n hash: String!\n extension: String\n fileName: String\n}\n\n# Synchronization types\ntype ReactorOperation {\n index: Int!\n timestampUtcMs: String!\n hash: String!\n skip: Int!\n error: String\n id: String\n action: Action!\n}\n\ninput OperationInput {\n index: Int!\n timestampUtcMs: String!\n hash: String!\n skip: Int!\n error: String\n id: String\n action: ActionInput!\n}\n\ntype OperationContext {\n documentId: String!\n documentType: String!\n scope: String!\n branch: String!\n ordinal: Int!\n}\n\ninput OperationContextInput {\n documentId: String!\n documentType: String!\n scope: String!\n branch: String!\n ordinal: Int!\n}\n\ntype OperationWithContext {\n operation: ReactorOperation!\n context: OperationContext!\n}\n\ninput OperationWithContextInput {\n operation: OperationInput!\n context: OperationContextInput!\n}\n\ntype ChannelMeta {\n id: String!\n}\n\ninput ChannelMetaInput {\n id: String!\n}\n\ntype RemoteCursor {\n remoteName: String!\n cursorOrdinal: Int!\n lastSyncedAtUtcMs: String\n}\n\ninput RemoteCursorInput {\n remoteName: String!\n cursorOrdinal: Int!\n lastSyncedAtUtcMs: String\n}\n\nenum SyncEnvelopeType {\n OPERATIONS\n ACK\n}\n\ntype SyncEnvelope {\n type: SyncEnvelopeType!\n channelMeta: ChannelMeta!\n operations: [OperationWithContext!]\n cursor: RemoteCursor\n key: String\n dependsOn: [String!]\n}\n\ninput SyncEnvelopeInput {\n type: SyncEnvelopeType!\n channelMeta: ChannelMetaInput!\n operations: [OperationWithContextInput!]\n cursor: RemoteCursorInput\n key: String\n dependsOn: [String!]\n}\n\ninput RemoteFilterInput {\n documentId: [String!]!\n scope: [String!]!\n branch: String!\n}\n\ninput TouchChannelInput {\n id: String!\n name: String!\n collectionId: String!\n filter: RemoteFilterInput!\n sinceTimestampUtcMs: String!\n}\n\ntype TouchChannelResult {\n success: Boolean!\n ackOrdinal: Int!\n}\n\ntype Query {\n # Get document models for a namespace\n documentModels(\n namespace: String\n paging: PagingInput\n ): DocumentModelResultPage!\n\n # Get a specific document by ID or slug\n document(identifier: String!, view: ViewFilterInput): DocumentWithChildren\n\n # Get outgoing relationships of a given type from a source document\n documentOutgoingRelationships(\n sourceIdentifier: String!\n relationshipType: String!\n view: ViewFilterInput\n paging: PagingInput\n ): PHDocumentResultPage!\n\n # Get incoming relationships of a given type to a target document\n documentIncomingRelationships(\n targetIdentifier: String!\n relationshipType: String!\n view: ViewFilterInput\n paging: PagingInput\n ): PHDocumentResultPage!\n\n # Find documents by search criteria\n findDocuments(\n search: SearchFilterInput\n view: ViewFilterInput\n paging: PagingInput\n ): PHDocumentResultPage!\n\n # Get job status\n jobStatus(jobId: String!): JobInfo\n\n # Get operations for a document with filtering and pagination\n documentOperations(\n filter: OperationsFilterInput!\n paging: PagingInput\n ): ReactorOperationResultPage!\n\n # Poll for sync envelopes from a channel\n pollSyncEnvelopes(\n channelId: String!\n outboxAck: Int!\n outboxLatest: Int!\n ): PollSyncEnvelopesResult!\n}\n\ntype Mutation {\n # Create a new document\n createDocument(document: JSONObject!, parentIdentifier: String): PHDocument!\n\n # Create an empty document of specified type\n createEmptyDocument(\n documentType: String!\n parentIdentifier: String\n ): PHDocument!\n\n # Apply actions to a document (synchronous)\n mutateDocument(\n documentIdentifier: String!\n actions: [JSONObject!]!\n view: ViewFilterInput\n ): PHDocument!\n\n # Submit actions to a document (asynchronous)\n mutateDocumentAsync(\n documentIdentifier: String!\n actions: [JSONObject!]!\n view: ViewFilterInput\n ): String!\n\n # Rename a document\n renameDocument(\n documentIdentifier: String!\n name: String!\n branch: String\n ): PHDocument!\n\n # Add a relationship between two documents\n addRelationship(\n sourceIdentifier: String!\n targetIdentifier: String!\n relationshipType: String!\n branch: String\n ): PHDocument!\n\n # Remove a relationship between two documents\n removeRelationship(\n sourceIdentifier: String!\n targetIdentifier: String!\n relationshipType: String!\n branch: String\n ): PHDocument!\n\n # Move a relationship from one source to another\n moveRelationship(\n sourceParentIdentifier: String!\n targetParentIdentifier: String!\n targetIdentifier: String!\n relationshipType: String!\n branch: String\n ): MoveRelationshipResult!\n\n # Delete a single document\n deleteDocument(identifier: String!, propagate: PropagationMode): Boolean!\n\n # Delete multiple documents\n deleteDocuments(identifiers: [String!]!, propagate: PropagationMode): Boolean!\n\n # Touch (create or update) a channel for sync\n touchChannel(input: TouchChannelInput!): TouchChannelResult!\n\n # Push sync envelopes to a channel\n pushSyncEnvelopes(envelopes: [SyncEnvelopeInput!]!): Boolean!\n}\n\ntype Subscription {\n # Subscribe to document changes\n documentChanges(\n search: SearchFilterInput\n view: ViewFilterInput\n ): DocumentChangeEvent!\n\n # Subscribe to job changes\n jobChanges(jobId: String!): JobChangeEvent!\n}\n";
|
|
4516
|
+
var schema_default = "# Scalar types (for codegen - also defined in create-schema.ts)\nscalar JSONObject\nscalar DateTime\n\n# Input types\ninput PagingInput {\n limit: Int\n offset: Int\n cursor: String\n}\n\ninput ViewFilterInput {\n branch: String\n scopes: [String!]\n}\n\ninput SearchFilterInput {\n type: String\n parentId: String\n identifiers: [String!]\n}\n\ninput OperationsFilterInput {\n documentId: String!\n branch: String\n scopes: [String!]\n actionTypes: [String!]\n sinceRevision: Int\n timestampFrom: String\n timestampTo: String\n}\n\ninput DocumentOperationsFilterInput {\n branch: String\n scopes: [String!]\n actionTypes: [String!]\n sinceRevision: Int\n timestampFrom: String\n timestampTo: String\n}\n\n# Enums\nenum PropagationMode {\n CASCADE\n ORPHAN\n}\n\nenum DocumentChangeType {\n CREATED\n DELETED\n UPDATED\n PARENT_ADDED\n PARENT_REMOVED\n CHILD_ADDED\n CHILD_REMOVED\n}\n\n# Object types\ntype DocumentModelGlobalState {\n id: String!\n name: String!\n namespace: String\n version: String\n specification: JSONObject!\n}\n\ntype DocumentModelResultPage {\n items: [DocumentModelGlobalState!]!\n totalCount: Int!\n hasNextPage: Boolean!\n hasPreviousPage: Boolean!\n cursor: String\n}\n\ntype Revision {\n scope: String!\n revision: Int!\n}\n\ntype PHDocument {\n id: String!\n slug: String\n preferredEditor: String\n name: String!\n documentType: String!\n state: JSONObject!\n revisionsList: [Revision!]!\n createdAtUtcIso: DateTime!\n lastModifiedAtUtcIso: DateTime!\n operations(\n filter: DocumentOperationsFilterInput\n paging: PagingInput\n ): ReactorOperationResultPage\n}\n\ntype PHDocumentResultPage {\n items: [PHDocument!]!\n totalCount: Int!\n hasNextPage: Boolean!\n hasPreviousPage: Boolean!\n cursor: String\n}\n\ntype ReactorOperationResultPage {\n items: [ReactorOperation!]!\n totalCount: Int!\n hasNextPage: Boolean!\n hasPreviousPage: Boolean!\n cursor: String\n}\n\ntype DeadLetterInfo {\n documentId: String!\n error: String!\n jobId: String!\n branch: String!\n scopes: [String!]!\n operationCount: Int!\n}\n\ntype PollSyncEnvelopesResult {\n envelopes: [SyncEnvelope!]!\n ackOrdinal: Int!\n deadLetters: [DeadLetterInfo!]!\n hasMore: Boolean!\n}\n\ntype DocumentWithChildren {\n document: PHDocument!\n childIds: [String!]!\n}\n\ntype MoveRelationshipResult {\n source: PHDocument!\n target: PHDocument!\n}\n\ntype JobInfo {\n id: String!\n status: String!\n result: JSONObject!\n error: String\n createdAt: DateTime!\n completedAt: DateTime\n}\n\ntype DocumentChangeEvent {\n type: DocumentChangeType!\n documents: [PHDocument!]!\n context: DocumentChangeContext\n}\n\ntype DocumentChangeContext {\n parentId: String\n childId: String\n}\n\ntype JobChangeEvent {\n jobId: String!\n status: String!\n result: JSONObject!\n error: String\n}\n\ntype ReactorSignerUser {\n address: String!\n networkId: String!\n chainId: Int!\n}\n\ntype ReactorSignerApp {\n name: String!\n key: String!\n}\n\ntype ReactorSigner {\n user: ReactorSignerUser\n app: ReactorSignerApp\n signatures: [String!]!\n}\n\ntype ActionContext {\n signer: ReactorSigner\n}\n\ntype Action {\n id: String!\n type: String!\n timestampUtcMs: String!\n input: JSONObject!\n scope: String!\n attachments: [Attachment!]\n context: ActionContext\n}\n\ntype Attachment {\n data: String!\n mimeType: String!\n hash: String!\n extension: String\n fileName: String\n}\n\n# Input types for sync operations\ninput ActionContextInput {\n signer: ReactorSignerInput\n}\n\ninput ReactorSignerInput {\n user: ReactorSignerUserInput\n app: ReactorSignerAppInput\n signatures: [String!]!\n}\n\ninput ReactorSignerUserInput {\n address: String!\n networkId: String!\n chainId: Int!\n}\n\ninput ReactorSignerAppInput {\n name: String!\n key: String!\n}\n\ninput ActionInput {\n id: String!\n type: String!\n timestampUtcMs: String!\n input: JSONObject!\n scope: String!\n attachments: [AttachmentInput!]\n context: ActionContextInput\n}\n\ninput AttachmentInput {\n data: String!\n mimeType: String!\n hash: String!\n extension: String\n fileName: String\n}\n\n# Synchronization types\ntype ReactorOperation {\n index: Int!\n timestampUtcMs: String!\n hash: String!\n skip: Int!\n error: String\n id: String\n action: Action!\n}\n\ninput OperationInput {\n index: Int!\n timestampUtcMs: String!\n hash: String!\n skip: Int!\n error: String\n id: String\n action: ActionInput!\n}\n\ntype OperationContext {\n documentId: String!\n documentType: String!\n scope: String!\n branch: String!\n ordinal: Int!\n}\n\ninput OperationContextInput {\n documentId: String!\n documentType: String!\n scope: String!\n branch: String!\n ordinal: Int!\n}\n\ntype OperationWithContext {\n operation: ReactorOperation!\n context: OperationContext!\n}\n\ninput OperationWithContextInput {\n operation: OperationInput!\n context: OperationContextInput!\n}\n\ntype ChannelMeta {\n id: String!\n}\n\ninput ChannelMetaInput {\n id: String!\n}\n\ntype RemoteCursor {\n remoteName: String!\n cursorOrdinal: Int!\n lastSyncedAtUtcMs: String\n}\n\ninput RemoteCursorInput {\n remoteName: String!\n cursorOrdinal: Int!\n lastSyncedAtUtcMs: String\n}\n\nenum SyncEnvelopeType {\n OPERATIONS\n ACK\n}\n\ntype SyncEnvelope {\n type: SyncEnvelopeType!\n channelMeta: ChannelMeta!\n operations: [OperationWithContext!]\n cursor: RemoteCursor\n key: String\n dependsOn: [String!]\n}\n\ninput SyncEnvelopeInput {\n type: SyncEnvelopeType!\n channelMeta: ChannelMetaInput!\n operations: [OperationWithContextInput!]\n cursor: RemoteCursorInput\n key: String\n dependsOn: [String!]\n}\n\ninput RemoteFilterInput {\n documentId: [String!]!\n scope: [String!]!\n branch: String!\n}\n\ninput TouchChannelInput {\n id: String!\n name: String!\n collectionId: String!\n filter: RemoteFilterInput!\n sinceTimestampUtcMs: String!\n}\n\ntype TouchChannelResult {\n success: Boolean!\n ackOrdinal: Int!\n}\n\ntype Query {\n # Get document models for a namespace\n documentModels(\n namespace: String\n paging: PagingInput\n ): DocumentModelResultPage!\n\n # Get a specific document by ID or slug\n document(identifier: String!, view: ViewFilterInput): DocumentWithChildren\n\n # Get outgoing relationships of a given type from a source document\n documentOutgoingRelationships(\n sourceIdentifier: String!\n relationshipType: String!\n view: ViewFilterInput\n paging: PagingInput\n ): PHDocumentResultPage!\n\n # Get incoming relationships of a given type to a target document\n documentIncomingRelationships(\n targetIdentifier: String!\n relationshipType: String!\n view: ViewFilterInput\n paging: PagingInput\n ): PHDocumentResultPage!\n\n # Find documents by search criteria\n findDocuments(\n search: SearchFilterInput\n view: ViewFilterInput\n paging: PagingInput\n ): PHDocumentResultPage!\n\n # Get job status\n jobStatus(jobId: String!): JobInfo\n\n # Get operations for a document with filtering and pagination\n documentOperations(\n filter: OperationsFilterInput!\n paging: PagingInput\n ): ReactorOperationResultPage!\n\n # Poll for sync envelopes from a channel\n pollSyncEnvelopes(\n channelId: String!\n outboxAck: Int!\n outboxLatest: Int!\n ): PollSyncEnvelopesResult!\n}\n\ntype Mutation {\n # Create a new document\n createDocument(document: JSONObject!, parentIdentifier: String): PHDocument!\n\n # Create an empty document of specified type\n createEmptyDocument(\n documentType: String!\n parentIdentifier: String\n ): PHDocument!\n\n # Apply actions to a document (synchronous)\n mutateDocument(\n documentIdentifier: String!\n actions: [JSONObject!]!\n view: ViewFilterInput\n ): PHDocument!\n\n # Submit actions to a document (asynchronous)\n mutateDocumentAsync(\n documentIdentifier: String!\n actions: [JSONObject!]!\n view: ViewFilterInput\n ): String!\n\n # Rename a document\n renameDocument(\n documentIdentifier: String!\n name: String!\n branch: String\n ): PHDocument!\n\n # Update the preferred editor recorded in the document header meta.\n # Pass null/omit to clear it.\n setPreferredEditor(\n documentIdentifier: String!\n preferredEditor: String\n branch: String\n ): PHDocument!\n\n # Add a relationship between two documents\n addRelationship(\n sourceIdentifier: String!\n targetIdentifier: String!\n relationshipType: String!\n branch: String\n ): PHDocument!\n\n # Remove a relationship between two documents\n removeRelationship(\n sourceIdentifier: String!\n targetIdentifier: String!\n relationshipType: String!\n branch: String\n ): PHDocument!\n\n # Move a relationship from one source to another\n moveRelationship(\n sourceParentIdentifier: String!\n targetParentIdentifier: String!\n targetIdentifier: String!\n relationshipType: String!\n branch: String\n ): MoveRelationshipResult!\n\n # Delete a single document\n deleteDocument(identifier: String!, propagate: PropagationMode): Boolean!\n\n # Delete multiple documents\n deleteDocuments(identifiers: [String!]!, propagate: PropagationMode): Boolean!\n\n # Touch (create or update) a channel for sync\n touchChannel(input: TouchChannelInput!): TouchChannelResult!\n\n # Push sync envelopes to a channel\n pushSyncEnvelopes(envelopes: [SyncEnvelopeInput!]!): Boolean!\n}\n\ntype Subscription {\n # Subscribe to document changes\n documentChanges(\n search: SearchFilterInput\n view: ViewFilterInput\n ): DocumentChangeEvent!\n\n # Subscribe to job changes\n jobChanges(jobId: String!): JobChangeEvent!\n}\n";
|
|
4444
4517
|
//#endregion
|
|
4445
4518
|
//#region src/graphql/reactor/pubsub.ts
|
|
4446
4519
|
const pubSub = new PubSub();
|
|
@@ -4555,7 +4628,7 @@ var ReactorSubgraph = class extends BaseSubgraph {
|
|
|
4555
4628
|
async #resolveDriveId(identifier) {
|
|
4556
4629
|
try {
|
|
4557
4630
|
const doc = await this.reactorClient.get(identifier);
|
|
4558
|
-
if (doc.header.documentType
|
|
4631
|
+
if (isDriveContainerType(doc.header.documentType)) return doc.header.id;
|
|
4559
4632
|
return;
|
|
4560
4633
|
} catch {
|
|
4561
4634
|
return;
|
|
@@ -4700,8 +4773,8 @@ var ReactorSubgraph = class extends BaseSubgraph {
|
|
|
4700
4773
|
} else if (this.authorizationService) {
|
|
4701
4774
|
if (!ctx.user?.address) throw new GraphQLError("Forbidden: authentication required to create documents");
|
|
4702
4775
|
} else if (!this.hasGlobalAdminAccess(ctx)) throw new GraphQLError("Forbidden: insufficient permissions to create documents");
|
|
4703
|
-
const result = await createDocument(this.reactorClient, args);
|
|
4704
|
-
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);
|
|
4705
4778
|
if (this.authorizationService && ctx.user?.address && result?.id) await this.documentPermissionService?.initializeDocumentProtection(result.id, ctx.user.address, this.authorizationService.config.defaultProtection);
|
|
4706
4779
|
return result;
|
|
4707
4780
|
} catch (error) {
|
|
@@ -4718,8 +4791,8 @@ var ReactorSubgraph = class extends BaseSubgraph {
|
|
|
4718
4791
|
} else if (this.authorizationService) {
|
|
4719
4792
|
if (!ctx.user?.address) throw new GraphQLError("Forbidden: authentication required to create documents");
|
|
4720
4793
|
} else if (!this.hasGlobalAdminAccess(ctx)) throw new GraphQLError("Forbidden: insufficient permissions to create documents");
|
|
4721
|
-
const result = await createEmptyDocument(this.reactorClient, args);
|
|
4722
|
-
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);
|
|
4723
4796
|
if (this.authorizationService && ctx.user?.address && result?.id) await this.documentPermissionService?.initializeDocumentProtection(result.id, ctx.user.address, this.authorizationService.config.defaultProtection);
|
|
4724
4797
|
return result;
|
|
4725
4798
|
} catch (error) {
|
|
@@ -4759,6 +4832,16 @@ var ReactorSubgraph = class extends BaseSubgraph {
|
|
|
4759
4832
|
throw error;
|
|
4760
4833
|
}
|
|
4761
4834
|
},
|
|
4835
|
+
setPreferredEditor: async (_parent, args, ctx) => {
|
|
4836
|
+
this.logger.debug("setPreferredEditor(@args)", args);
|
|
4837
|
+
try {
|
|
4838
|
+
await this.assertCanWrite(args.documentIdentifier, ctx);
|
|
4839
|
+
return await setPreferredEditor(this.reactorClient, args);
|
|
4840
|
+
} catch (error) {
|
|
4841
|
+
this.logger.error("Error in setPreferredEditor(@args): @Error", error);
|
|
4842
|
+
throw error;
|
|
4843
|
+
}
|
|
4844
|
+
},
|
|
4762
4845
|
addRelationship: async (_parent, args, ctx) => {
|
|
4763
4846
|
this.logger.debug("addRelationship(@args)", args);
|
|
4764
4847
|
try {
|
|
@@ -4795,7 +4878,7 @@ var ReactorSubgraph = class extends BaseSubgraph {
|
|
|
4795
4878
|
try {
|
|
4796
4879
|
await this.assertCanWrite(args.identifier, ctx);
|
|
4797
4880
|
const driveIdToInvalidate = await this.#resolveDriveId(args.identifier);
|
|
4798
|
-
const result = await deleteDocument(this.reactorClient, args);
|
|
4881
|
+
const result = await deleteDocument(this.reactorClient, args, this.graphqlManager.reactorDriveClient);
|
|
4799
4882
|
if (result && driveIdToInvalidate) this.graphqlManager.driveOwnershipCache.remove(driveIdToInvalidate);
|
|
4800
4883
|
return result;
|
|
4801
4884
|
} catch (error) {
|
|
@@ -4903,10 +4986,10 @@ const ADMIN_USERS = getAdminUsers();
|
|
|
4903
4986
|
//#endregion
|
|
4904
4987
|
//#region src/graphql/system/version.ts
|
|
4905
4988
|
function getVersion() {
|
|
4906
|
-
return "6.0.2-staging.
|
|
4989
|
+
return "6.0.2-staging.9";
|
|
4907
4990
|
}
|
|
4908
4991
|
function getGitHash() {
|
|
4909
|
-
return "
|
|
4992
|
+
return "409a67a6d3aa6be3f6700dc0ae2045ecd8556e74";
|
|
4910
4993
|
}
|
|
4911
4994
|
function getGitUrl() {
|
|
4912
4995
|
return buildTreeUrl(getGitHash());
|
|
@@ -5196,6 +5279,7 @@ var PackageManager = class {
|
|
|
5196
5279
|
const documentModelModuleMap = /* @__PURE__ */ new Map();
|
|
5197
5280
|
documentModelModuleMap.set("document-drive", [driveDocumentModelModule]);
|
|
5198
5281
|
documentModelModuleMap.set("document-model", [documentModelDocumentModelModule]);
|
|
5282
|
+
documentModelModuleMap.set("reactor-drive", [reactorDriveDocumentModelModule]);
|
|
5199
5283
|
for (const pkg of packages) {
|
|
5200
5284
|
const allDocumentModels = [];
|
|
5201
5285
|
for (const loader of this.loaders) try {
|
|
@@ -6079,7 +6163,7 @@ function isPG(connectionString) {
|
|
|
6079
6163
|
function getDbClient(connectionString = void 0, pgliteFactory) {
|
|
6080
6164
|
const isPg = connectionString && isPG(connectionString);
|
|
6081
6165
|
const client = isPg ? "pg" : ClientPgLite;
|
|
6082
|
-
const pgliteInstance = isPg ? void 0 : pgliteFactory ? pgliteFactory(connectionString) : new PGlite(connectionString);
|
|
6166
|
+
const pgliteInstance = isPg ? void 0 : pgliteFactory ? pgliteFactory(connectionString) : connectionString ? new PGlite({ fs: new AtomicNodeFs(connectionString) }) : new PGlite();
|
|
6083
6167
|
const connection = isPg ? { connectionString } : { pglite: pgliteInstance };
|
|
6084
6168
|
if (connectionString && !isPg) {
|
|
6085
6169
|
const dirPath = path.resolve(connectionString, "..");
|
|
@@ -6200,11 +6284,11 @@ function makeDbClosers(knexInstance, pglite) {
|
|
|
6200
6284
|
/**
|
|
6201
6285
|
* Sets up the subgraph manager and registers subgraphs
|
|
6202
6286
|
*/
|
|
6203
|
-
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) {
|
|
6204
6288
|
const graphqlManager = new GraphQLManager(config.basePath, httpServer, wsServer, client, relationalDb, analyticsStore, syncManager, logger, httpAdapter, createGatewayAdapter("apollo", logger), {
|
|
6205
6289
|
enabled: auth?.enabled ?? false,
|
|
6206
6290
|
admins: auth?.admins ?? []
|
|
6207
|
-
}, documentPermissionService, { enableDocumentModelSubgraphs }, port, authorizationService);
|
|
6291
|
+
}, documentPermissionService, { enableDocumentModelSubgraphs }, port, authorizationService, reactorDriveClient);
|
|
6208
6292
|
await graphqlManager.init(subgraphs.core, authFetchMiddleware);
|
|
6209
6293
|
for (const [, collection] of subgraphs.extended.entries()) for (const subgraph of collection) await graphqlManager.registerSubgraph(subgraph, "graphql");
|
|
6210
6294
|
await graphqlManager.updateRouter();
|
|
@@ -6365,7 +6449,7 @@ async function _setupCommonInfrastructure(options) {
|
|
|
6365
6449
|
/**
|
|
6366
6450
|
* Private helper function containing common setup logic for API initialization
|
|
6367
6451
|
*/
|
|
6368
|
-
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) {
|
|
6369
6453
|
const hostModule = {
|
|
6370
6454
|
relationalDb,
|
|
6371
6455
|
analyticsStore,
|
|
@@ -6417,7 +6501,7 @@ async function _setupAPI(reactorClient, syncManager, reactorProcessorManager, ht
|
|
|
6417
6501
|
const graphqlManager = await setupGraphQLManager(httpAdapter, authFetchMiddleware, httpServer, wsServer, reactorClient, relationalDb, analyticsStore, syncManager, {
|
|
6418
6502
|
extended: subgraphs,
|
|
6419
6503
|
core: coreSubgraphs
|
|
6420
|
-
}, logger.child(["graphql-manager"]), auth, documentPermissionService, options.enableDocumentModelSubgraphs, port, authorizationService);
|
|
6504
|
+
}, logger.child(["graphql-manager"]), auth, documentPermissionService, options.enableDocumentModelSubgraphs, port, authorizationService, reactorDriveClient);
|
|
6421
6505
|
setupEventListeners(packages, graphqlManager, reactorProcessorManager, hostModule, documentModelRegistry);
|
|
6422
6506
|
if (mcpServerEnabled) {
|
|
6423
6507
|
await setupMcpServer({
|
|
@@ -6478,20 +6562,10 @@ function buildApiDispose(args) {
|
|
|
6478
6562
|
}
|
|
6479
6563
|
};
|
|
6480
6564
|
}
|
|
6481
|
-
/**
|
|
6482
|
-
* Initializes and starts the API server using an initializer function.
|
|
6483
|
-
* This function first loads packages to get document models, then calls the initializer function
|
|
6484
|
-
* to create the reactor client module with the appropriate dependencies.
|
|
6485
|
-
*
|
|
6486
|
-
* @param clientInitializer - Initializer function that creates the reactor client module with document models.
|
|
6487
|
-
* @param options - Additional options for server configuration.
|
|
6488
|
-
*
|
|
6489
|
-
* @returns The API server components along with the created client instances.
|
|
6490
|
-
*/
|
|
6491
6565
|
async function initializeAndStartAPI(clientInitializer, options, processorApp) {
|
|
6492
6566
|
const { port, httpAdapter, authFetchMiddleware, authService, auth, relationalDb, analyticsStore, documentPermissionService, authorizationService, attachments, packages, dbClosers } = await _setupCommonInfrastructure(options);
|
|
6493
6567
|
const { documentModels, processors, subgraphs } = await packages.init();
|
|
6494
|
-
const reactorClientModule = await clientInitializer(documentModels);
|
|
6568
|
+
const { module: reactorClientModule, reactorDriveClient } = await clientInitializer(documentModels);
|
|
6495
6569
|
const reactorClient = reactorClientModule.client;
|
|
6496
6570
|
const syncManager = reactorClientModule.reactorModule?.syncModule?.syncManager;
|
|
6497
6571
|
if (!syncManager) throw new Error("SyncManager not available from ReactorClientModule");
|
|
@@ -6500,7 +6574,7 @@ async function initializeAndStartAPI(clientInitializer, options, processorApp) {
|
|
|
6500
6574
|
const documentModelRegistry = reactorClientModule.reactorModule?.documentModelRegistry;
|
|
6501
6575
|
if (!documentModelRegistry) throw new Error("DocumentModelRegistry not available from ReactorClientModule");
|
|
6502
6576
|
return {
|
|
6503
|
-
...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),
|
|
6504
6578
|
client: reactorClient,
|
|
6505
6579
|
syncManager,
|
|
6506
6580
|
documentModelRegistry
|
|
@@ -6606,7 +6680,7 @@ var PackageManagementService = class {
|
|
|
6606
6680
|
}
|
|
6607
6681
|
};
|
|
6608
6682
|
//#endregion
|
|
6609
|
-
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, 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 };
|
|
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 };
|
|
6610
6684
|
|
|
6611
6685
|
//# sourceMappingURL=index.mjs.map
|
|
6612
|
-
//# debugId=
|
|
6686
|
+
//# debugId=def0f6e3-b149-5760-8c0c-611814c2a321
|