@powerhousedao/reactor-api 6.2.2-dev.83 → 6.2.2-dev.84
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/adapter-http-express-Cf918YME.mjs +225 -0
- package/dist/adapter-http-express-Cf918YME.mjs.map +1 -0
- package/dist/{adapter-http-fastify-B248RJtm.mjs → adapter-http-fastify-DVBSR7C6.mjs} +38 -26
- package/dist/adapter-http-fastify-DVBSR7C6.mjs.map +1 -0
- package/dist/index.d.mts +84 -14
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +188 -32
- package/dist/index.mjs.map +1 -1
- package/dist/path-normalize-Cucs71I2.mjs +19 -0
- package/dist/path-normalize-Cucs71I2.mjs.map +1 -0
- package/dist/src/packages/vite-loader.d.mts +1 -1
- package/dist/src/packages/vite-loader.d.mts.map +1 -1
- package/dist/src/packages/vite-loader.mjs +14 -2
- package/dist/src/packages/vite-loader.mjs.map +1 -1
- package/dist/{types-D2ZrjmCk.d.mts → types-Bz2niABC.d.mts} +6 -1
- package/dist/{types-D2ZrjmCk.d.mts.map → types-Bz2niABC.d.mts.map} +1 -1
- package/dist/utils-lHoPB-ft.mjs +2 -2
- package/dist/utils-lHoPB-ft.mjs.map +1 -1
- package/package.json +14 -14
- package/dist/adapter-http-express-D5OpUIbV.mjs +0 -137
- package/dist/adapter-http-express-D5OpUIbV.mjs.map +0 -1
- package/dist/adapter-http-fastify-B248RJtm.mjs.map +0 -1
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]="1ef5d33d-849a-5b1b-8d6e-74296692d4e4")}catch(e){}}();
|
|
3
3
|
import { _ as createAuthorizationService, a as isSubgraphClass, b as MalformedStoredOperationError, d as loadSubgraphs, f as BaseSubgraph, g as AuthorizedDocumentHandle, h as AuthorizationPolicy, i as buildGraphqlOperations, l as loadDocumentModels, m as createCanonicalDocumentIdResolver, n as buildGraphQlDriveDocument, o as debounce, p as CanonicalDocumentIdResolutionError, r as buildGraphqlOperation, s as extractUpgradeManifests, t as buildGraphQlDocument, u as loadProcessors, v as AuthEvaluationUnsupportedError, y as ForbiddenError } from "./utils-lHoPB-ft.mjs";
|
|
4
4
|
import { AnalyticsQueryEngine } from "@powerhousedao/analytics-engine-core";
|
|
5
5
|
import { AnalyticsModel, AnalyticsResolvers, typedefs } from "@powerhousedao/analytics-engine-graphql";
|
|
@@ -318,11 +318,11 @@ async function createGatewayAdapter(type, logger) {
|
|
|
318
318
|
async function createHttpAdapter(type) {
|
|
319
319
|
switch (type) {
|
|
320
320
|
case "express": {
|
|
321
|
-
const { createExpressHttpAdapter } = await import("./adapter-http-express-
|
|
321
|
+
const { createExpressHttpAdapter } = await import("./adapter-http-express-Cf918YME.mjs");
|
|
322
322
|
return createExpressHttpAdapter();
|
|
323
323
|
}
|
|
324
324
|
case "fastify": {
|
|
325
|
-
const { createFastifyHttpAdapter } = await import("./adapter-http-fastify-
|
|
325
|
+
const { createFastifyHttpAdapter } = await import("./adapter-http-fastify-DVBSR7C6.mjs");
|
|
326
326
|
return createFastifyHttpAdapter();
|
|
327
327
|
}
|
|
328
328
|
}
|
|
@@ -3212,6 +3212,12 @@ function filterLatestDocumentModelVersions(documentModels) {
|
|
|
3212
3212
|
return Array.from(latestByName.values());
|
|
3213
3213
|
}
|
|
3214
3214
|
const DefaultFeatureFlags = { enableDocumentModelSubgraphs: true };
|
|
3215
|
+
/**
|
|
3216
|
+
* The registration-source label for document-model-generated subgraphs, so
|
|
3217
|
+
* they can be pruned like package-contributed ones (see
|
|
3218
|
+
* regenerateDocumentModelSubgraphs).
|
|
3219
|
+
*/
|
|
3220
|
+
const DOCUMENT_MODEL_SUBGRAPH_SOURCE = "document-models";
|
|
3215
3221
|
var GraphQLManager = class {
|
|
3216
3222
|
initialized = false;
|
|
3217
3223
|
coreSubgraphsMap = /* @__PURE__ */ new Map();
|
|
@@ -3225,6 +3231,16 @@ var GraphQLManager = class {
|
|
|
3225
3231
|
/** Cached document models for schema generation - updated on init and regenerate */
|
|
3226
3232
|
cachedDocumentModels = [];
|
|
3227
3233
|
subgraphHandlerCache = /* @__PURE__ */ new Map();
|
|
3234
|
+
/** subgraphPath → the http adapter handle of its mounted route. */
|
|
3235
|
+
subgraphRouteHandles = /* @__PURE__ */ new Map();
|
|
3236
|
+
/** Handle of the currently mounted supergraph SSE route, if any. */
|
|
3237
|
+
sseRouteHandle;
|
|
3238
|
+
/**
|
|
3239
|
+
* Package name → the subgraph instances registered from it, keyed by
|
|
3240
|
+
* subgraph name. Tracks the package association so that removed packages
|
|
3241
|
+
* can be torn down (see unregisterPackage / prunePackageSubgraphs).
|
|
3242
|
+
*/
|
|
3243
|
+
packageSubgraphs = /* @__PURE__ */ new Map();
|
|
3228
3244
|
/** Per-subgraph handlers by name, before auth/drive middleware is applied,
|
|
3229
3245
|
* for in-process queries by trusted internals. */
|
|
3230
3246
|
#internalSubgraphHandlers = /* @__PURE__ */ new Map();
|
|
@@ -3307,7 +3323,8 @@ var GraphQLManager = class {
|
|
|
3307
3323
|
try {
|
|
3308
3324
|
const models = (await this.reactorClient.getDocumentModelModules()).results;
|
|
3309
3325
|
this.cachedDocumentModels = models;
|
|
3310
|
-
await this.#setupDocumentModelSubgraphs("graphql", models);
|
|
3326
|
+
const registeredNames = await this.#setupDocumentModelSubgraphs("graphql", models);
|
|
3327
|
+
await this.prunePackageSubgraphs(DOCUMENT_MODEL_SUBGRAPH_SOURCE, registeredNames);
|
|
3311
3328
|
await this.updateRouter();
|
|
3312
3329
|
this.logger.info("Regenerated document model subgraphs with @count models", models.length);
|
|
3313
3330
|
} catch (error) {
|
|
@@ -3325,6 +3342,7 @@ var GraphQLManager = class {
|
|
|
3325
3342
|
}
|
|
3326
3343
|
async #setupDocumentModelSubgraphs(supergraph, documentModels) {
|
|
3327
3344
|
const latestDocumentModels = filterLatestDocumentModelVersions(documentModels);
|
|
3345
|
+
const registeredNames = /* @__PURE__ */ new Set();
|
|
3328
3346
|
for (const documentModel of latestDocumentModels) {
|
|
3329
3347
|
if (DOCUMENT_MODELS_TO_EXCLUDE.includes(documentModel.documentModel.global.id)) continue;
|
|
3330
3348
|
if (!hasOperationSchemas(documentModel)) continue;
|
|
@@ -3340,42 +3358,71 @@ var GraphQLManager = class {
|
|
|
3340
3358
|
authorizationService: this.authorizationService,
|
|
3341
3359
|
syncServingGate: this.syncServingGate
|
|
3342
3360
|
});
|
|
3343
|
-
await this.#addSubgraphInstance(subgraphInstance, supergraph, false);
|
|
3361
|
+
await this.#addSubgraphInstance(subgraphInstance, supergraph, false, DOCUMENT_MODEL_SUBGRAPH_SOURCE);
|
|
3362
|
+
registeredNames.add(subgraphInstance.name);
|
|
3344
3363
|
} catch (error) {
|
|
3345
3364
|
this.logger.error(`Failed to setup document model subgraph for ${documentModel.documentModel.global.id}`, error instanceof Error ? error.message : error);
|
|
3346
3365
|
this.logger.debug("@error", error);
|
|
3347
3366
|
}
|
|
3348
3367
|
}
|
|
3368
|
+
return registeredNames;
|
|
3369
|
+
}
|
|
3370
|
+
/** Core subgraph names are reserved: they register with core=true during
|
|
3371
|
+
* init() and no package subgraph may take one of their names. */
|
|
3372
|
+
#isCoreNameReserved(name) {
|
|
3373
|
+
for (const subgraphs of this.coreSubgraphsMap.values()) if (subgraphs.some((it) => it.name === name)) return true;
|
|
3374
|
+
return false;
|
|
3349
3375
|
}
|
|
3350
|
-
async #addSubgraphInstance(subgraphInstance, supergraph = "", core = false) {
|
|
3376
|
+
async #addSubgraphInstance(subgraphInstance, supergraph = "", core = false, packageName) {
|
|
3377
|
+
if (!core && this.#isCoreNameReserved(subgraphInstance.name)) {
|
|
3378
|
+
this.logger.error("Rejecting subgraph @name: name is reserved by a registered core subgraph", subgraphInstance.name);
|
|
3379
|
+
return;
|
|
3380
|
+
}
|
|
3351
3381
|
const subgraphsMap = core ? this.coreSubgraphsMap : this.subgraphs;
|
|
3352
3382
|
const existingSubgraph = subgraphsMap.get(supergraph)?.find((it) => it.name === subgraphInstance.name);
|
|
3353
3383
|
if (existingSubgraph === subgraphInstance) {
|
|
3354
3384
|
this.logger.debug(`Skipping duplicate subgraph: ${subgraphInstance.name}`);
|
|
3355
3385
|
return existingSubgraph;
|
|
3356
3386
|
}
|
|
3357
|
-
if (existingSubgraph) await this.#removeSubgraphInstance(existingSubgraph
|
|
3387
|
+
if (existingSubgraph) await this.#removeSubgraphInstance(existingSubgraph);
|
|
3358
3388
|
await subgraphInstance.onSetup?.();
|
|
3359
3389
|
const subgraphs = subgraphsMap.get(supergraph) ?? [];
|
|
3360
3390
|
subgraphs.push(subgraphInstance);
|
|
3361
3391
|
subgraphsMap.set(supergraph, subgraphs);
|
|
3362
3392
|
if (supergraph !== "" && supergraph !== "graphql") subgraphsMap.get("graphql")?.push(subgraphInstance);
|
|
3393
|
+
if (packageName !== void 0) {
|
|
3394
|
+
let byName = this.packageSubgraphs.get(packageName);
|
|
3395
|
+
if (!byName) {
|
|
3396
|
+
byName = /* @__PURE__ */ new Map();
|
|
3397
|
+
this.packageSubgraphs.set(packageName, byName);
|
|
3398
|
+
}
|
|
3399
|
+
byName.set(subgraphInstance.name, subgraphInstance);
|
|
3400
|
+
}
|
|
3363
3401
|
this.logger.info(`${existingSubgraph ? "Replaced" : "Registered"} ${this.path.endsWith("/") ? this.path : this.path + "/"}${supergraph ? supergraph + "/" : ""}${subgraphInstance.name} subgraph.`);
|
|
3364
3402
|
return subgraphInstance;
|
|
3365
3403
|
}
|
|
3366
|
-
/**
|
|
3367
|
-
*
|
|
3368
|
-
|
|
3404
|
+
/**
|
|
3405
|
+
* Tear down a subgraph instance: disconnect it, drop it from every
|
|
3406
|
+
* bucket, unmount its route, dispose its WebSocket handler, and remove
|
|
3407
|
+
* its internal handler. Used when a subgraph is replaced or its package
|
|
3408
|
+
* is removed; #setupSubgraphs then never re-mounts it.
|
|
3409
|
+
*/
|
|
3410
|
+
async #removeSubgraphInstance(instance) {
|
|
3369
3411
|
try {
|
|
3370
3412
|
await instance.onDisconnect?.();
|
|
3371
3413
|
} catch (error) {
|
|
3372
3414
|
this.logger.error("Error disconnecting subgraph @name: @error", instance.name, error);
|
|
3373
3415
|
}
|
|
3374
|
-
for (const [bucket, subgraphs] of subgraphsMap.entries()) {
|
|
3416
|
+
for (const subgraphsMap of [this.coreSubgraphsMap, this.subgraphs]) for (const [bucket, subgraphs] of subgraphsMap.entries()) {
|
|
3375
3417
|
if (!subgraphs.includes(instance)) continue;
|
|
3376
3418
|
subgraphsMap.set(bucket, subgraphs.filter((it) => it !== instance));
|
|
3377
3419
|
const subgraphPath = this.#getSubgraphPath(instance, bucket);
|
|
3378
3420
|
this.subgraphHandlerCache.delete(subgraphPath);
|
|
3421
|
+
const routeHandle = this.subgraphRouteHandles.get(subgraphPath);
|
|
3422
|
+
if (routeHandle !== void 0) {
|
|
3423
|
+
this.httpAdapter.unmount(routeHandle);
|
|
3424
|
+
this.subgraphRouteHandles.delete(subgraphPath);
|
|
3425
|
+
}
|
|
3379
3426
|
const wsDisposer = this.subgraphWsDisposers.get(subgraphPath);
|
|
3380
3427
|
if (wsDisposer) {
|
|
3381
3428
|
this.subgraphWsDisposers.delete(subgraphPath);
|
|
@@ -3387,6 +3434,11 @@ var GraphQLManager = class {
|
|
|
3387
3434
|
}
|
|
3388
3435
|
}
|
|
3389
3436
|
if (this.#internalSubgraphHandlers.get(instance.name)?.subgraph === instance) this.#internalSubgraphHandlers.delete(instance.name);
|
|
3437
|
+
for (const [packageName, byName] of this.packageSubgraphs) {
|
|
3438
|
+
if (byName.get(instance.name) !== instance) continue;
|
|
3439
|
+
byName.delete(instance.name);
|
|
3440
|
+
if (byName.size === 0) this.packageSubgraphs.delete(packageName);
|
|
3441
|
+
}
|
|
3390
3442
|
}
|
|
3391
3443
|
/**
|
|
3392
3444
|
* Register a pre-constructed subgraph instance.
|
|
@@ -3409,7 +3461,13 @@ var GraphQLManager = class {
|
|
|
3409
3461
|
getAuthorizationService() {
|
|
3410
3462
|
return this.authorizationService;
|
|
3411
3463
|
}
|
|
3412
|
-
|
|
3464
|
+
/**
|
|
3465
|
+
* Register a subgraph class. `packageName` labels the resulting instance
|
|
3466
|
+
* with its contributing package so the instance can be torn down when the
|
|
3467
|
+
* package is removed or drops the subgraph (see unregisterPackage and
|
|
3468
|
+
* prunePackageSubgraphs).
|
|
3469
|
+
*/
|
|
3470
|
+
async registerSubgraph(subgraph, supergraph = "", core = false, packageName) {
|
|
3413
3471
|
const subgraphInstance = new subgraph({
|
|
3414
3472
|
relationalDb: this.relationalDb,
|
|
3415
3473
|
analyticsStore: this.analyticsStore,
|
|
@@ -3421,7 +3479,35 @@ var GraphQLManager = class {
|
|
|
3421
3479
|
authorizationService: this.authorizationService,
|
|
3422
3480
|
syncServingGate: this.syncServingGate
|
|
3423
3481
|
});
|
|
3424
|
-
return this.#addSubgraphInstance(subgraphInstance, supergraph, core);
|
|
3482
|
+
return this.#addSubgraphInstance(subgraphInstance, supergraph, core, packageName);
|
|
3483
|
+
}
|
|
3484
|
+
/**
|
|
3485
|
+
* Tear down every subgraph instance registered from `packageName`:
|
|
3486
|
+
* disconnects the instances, unmounts their routes, disposes their
|
|
3487
|
+
* WebSocket handlers, then refreshes the router so the supergraph SDL and
|
|
3488
|
+
* the supergraph SSE handler no longer reference them. No-op if the
|
|
3489
|
+
* package has no registered subgraphs.
|
|
3490
|
+
*/
|
|
3491
|
+
async unregisterPackage(packageName) {
|
|
3492
|
+
const byName = this.packageSubgraphs.get(packageName);
|
|
3493
|
+
if (!byName || byName.size === 0) return;
|
|
3494
|
+
for (const instance of Array.from(byName.values())) await this.#removeSubgraphInstance(instance);
|
|
3495
|
+
await this.updateRouter();
|
|
3496
|
+
}
|
|
3497
|
+
/**
|
|
3498
|
+
* Remove this package's registered subgraphs whose names are not in
|
|
3499
|
+
* `keepNames` — the package is still loaded but dropped some of its
|
|
3500
|
+
* subgraphs. Refreshes the router if anything was removed.
|
|
3501
|
+
*/
|
|
3502
|
+
async prunePackageSubgraphs(packageName, keepNames) {
|
|
3503
|
+
const byName = this.packageSubgraphs.get(packageName);
|
|
3504
|
+
if (!byName) return;
|
|
3505
|
+
let removed = 0;
|
|
3506
|
+
for (const [name, instance] of Array.from(byName.entries())) if (!keepNames.has(name)) {
|
|
3507
|
+
await this.#removeSubgraphInstance(instance);
|
|
3508
|
+
removed++;
|
|
3509
|
+
}
|
|
3510
|
+
if (removed > 0) await this.updateRouter();
|
|
3425
3511
|
}
|
|
3426
3512
|
/** Find a registered subgraph by name, core or package-contributed. */
|
|
3427
3513
|
getSubgraphByName(name) {
|
|
@@ -3515,10 +3601,18 @@ var GraphQLManager = class {
|
|
|
3515
3601
|
return (connectionParams) => this.#createWebSocketContext(connectionParams);
|
|
3516
3602
|
}
|
|
3517
3603
|
setSupergraph(supergraph, subgraphs) {
|
|
3518
|
-
|
|
3604
|
+
const accepted = [];
|
|
3605
|
+
for (const subgraph of subgraphs) {
|
|
3606
|
+
if (this.#isCoreNameReserved(subgraph.name)) {
|
|
3607
|
+
this.logger.error("Rejecting subgraph @name: name is reserved by a registered core subgraph", subgraph.name);
|
|
3608
|
+
continue;
|
|
3609
|
+
}
|
|
3610
|
+
accepted.push(subgraph);
|
|
3611
|
+
}
|
|
3612
|
+
this.subgraphs.set(supergraph, accepted);
|
|
3519
3613
|
const globalSubgraphs = this.subgraphs.get("graphql");
|
|
3520
|
-
if (globalSubgraphs) this.subgraphs.set("graphql", [...globalSubgraphs, ...
|
|
3521
|
-
else this.subgraphs.set("graphql",
|
|
3614
|
+
if (globalSubgraphs) this.subgraphs.set("graphql", [...globalSubgraphs, ...accepted]);
|
|
3615
|
+
else this.subgraphs.set("graphql", accepted);
|
|
3522
3616
|
return this.updateRouter();
|
|
3523
3617
|
}
|
|
3524
3618
|
async shutdown() {
|
|
@@ -3534,7 +3628,7 @@ var GraphQLManager = class {
|
|
|
3534
3628
|
});
|
|
3535
3629
|
}
|
|
3536
3630
|
#getSubgraphPath(subgraph, supergraph) {
|
|
3537
|
-
return path.posix.join(
|
|
3631
|
+
return path.posix.join(this.path, supergraph, subgraph.name);
|
|
3538
3632
|
}
|
|
3539
3633
|
/** The in-process handler map is keyed by bare name, so two distinct
|
|
3540
3634
|
* subgraphs sharing one name would shadow each other: keep the first. */
|
|
@@ -3555,13 +3649,20 @@ var GraphQLManager = class {
|
|
|
3555
3649
|
this.logger.debug(`Setting up subgraph ${subgraph.name}`);
|
|
3556
3650
|
const subgraphPath = this.#getSubgraphPath(subgraph, supergraph);
|
|
3557
3651
|
try {
|
|
3558
|
-
|
|
3652
|
+
const cached = this.subgraphHandlerCache.get(subgraphPath);
|
|
3653
|
+
if (cached) {
|
|
3654
|
+
if (cached.subgraph !== subgraph) this.logger.warn("Subgraph path @path already mounted by @kept; @name is shadowed and will not be mounted", subgraphPath, cached.subgraph.name, subgraph.name);
|
|
3655
|
+
continue;
|
|
3656
|
+
}
|
|
3559
3657
|
const schema = createSchema(this.cachedDocumentModels, subgraph.resolvers, subgraph.typeDefs);
|
|
3560
3658
|
const rawHandler = await this.gatewayAdapter.createHandler(schema, this.#makeContextFactory());
|
|
3561
3659
|
const fetchHandler = this.#composeFetchMiddleware(rawHandler);
|
|
3562
|
-
this.subgraphHandlerCache.set(subgraphPath,
|
|
3660
|
+
this.subgraphHandlerCache.set(subgraphPath, {
|
|
3661
|
+
handler: fetchHandler,
|
|
3662
|
+
subgraph
|
|
3663
|
+
});
|
|
3563
3664
|
this.#setInternalSubgraphHandler(subgraph, subgraphPath, rawHandler);
|
|
3564
|
-
this.httpAdapter.mount(subgraphPath, fetchHandler);
|
|
3665
|
+
this.subgraphRouteHandles.set(subgraphPath, this.httpAdapter.mount(subgraphPath, fetchHandler));
|
|
3565
3666
|
if (subgraph.hasSubscriptions) {
|
|
3566
3667
|
try {
|
|
3567
3668
|
if (this.subgraphWsDisposers.get(subgraphPath)) this.logger.warn("Overwriting existing WebSocket disposer for subgraph at path @path", subgraphPath);
|
|
@@ -3626,7 +3727,13 @@ var GraphQLManager = class {
|
|
|
3626
3727
|
#setupSupergraphSSE(superGraphPath) {
|
|
3627
3728
|
const allSubgraphs = this.#getAllSubgraphs();
|
|
3628
3729
|
const modules = Array.from(allSubgraphs.values()).filter((subgraph) => subgraph.hasSubscriptions).map((subgraph) => this.#buildSubgraphSchemaModule(subgraph));
|
|
3629
|
-
if (modules.length === 0)
|
|
3730
|
+
if (modules.length === 0) {
|
|
3731
|
+
if (this.sseRouteHandle !== void 0) {
|
|
3732
|
+
this.httpAdapter.unmount(this.sseRouteHandle);
|
|
3733
|
+
this.sseRouteHandle = void 0;
|
|
3734
|
+
}
|
|
3735
|
+
return;
|
|
3736
|
+
}
|
|
3630
3737
|
try {
|
|
3631
3738
|
const mergedSchema = createMergedSchema(modules);
|
|
3632
3739
|
this.#setupSSEHandler(mergedSchema, superGraphPath);
|
|
@@ -3650,7 +3757,8 @@ var GraphQLManager = class {
|
|
|
3650
3757
|
contextFactory: this.#makeContextFactory()
|
|
3651
3758
|
});
|
|
3652
3759
|
const handler = this.#composeFetchMiddleware(rawHandler);
|
|
3653
|
-
this.
|
|
3760
|
+
if (this.sseRouteHandle !== void 0) this.httpAdapter.unmount(this.sseRouteHandle);
|
|
3761
|
+
this.sseRouteHandle = this.httpAdapter.mount(ssePath, handler, { exact: true });
|
|
3654
3762
|
}
|
|
3655
3763
|
/**
|
|
3656
3764
|
* Compose the request-level fetch middleware chain. Auth runs first
|
|
@@ -4740,10 +4848,10 @@ const ADMIN_USERS = getAdminUsers();
|
|
|
4740
4848
|
//#endregion
|
|
4741
4849
|
//#region src/graphql/system/version.ts
|
|
4742
4850
|
function getVersion() {
|
|
4743
|
-
return "6.2.2-dev.
|
|
4851
|
+
return "6.2.2-dev.84";
|
|
4744
4852
|
}
|
|
4745
4853
|
function getGitHash() {
|
|
4746
|
-
return "
|
|
4854
|
+
return "61e064863083d9933ca46160f31bac814e119e18";
|
|
4747
4855
|
}
|
|
4748
4856
|
function getGitUrl() {
|
|
4749
4857
|
return buildTreeUrl(getGitHash());
|
|
@@ -5196,24 +5304,32 @@ var PackageManager = class {
|
|
|
5196
5304
|
const documentModels = await this.loadDocumentModels([pkg]);
|
|
5197
5305
|
const upgradeManifests = await this.loadUpgradeManifests([pkg]);
|
|
5198
5306
|
const upgradeManifestsMap = new Map(this.upgradeManifestsMap);
|
|
5199
|
-
|
|
5307
|
+
const pkgManifests = upgradeManifests.get(pkg) ?? [];
|
|
5308
|
+
if (pkgManifests.length === 0) upgradeManifestsMap.delete(pkg);
|
|
5309
|
+
else upgradeManifestsMap.set(pkg, pkgManifests);
|
|
5200
5310
|
this.upgradeManifestsMap = upgradeManifestsMap;
|
|
5201
5311
|
const documentModelsMap = new Map(this.docModelsMap);
|
|
5202
|
-
|
|
5312
|
+
const pkgModels = documentModels.get(pkg) ?? [];
|
|
5313
|
+
if (pkgModels.length === 0) documentModelsMap.delete(pkg);
|
|
5314
|
+
else documentModelsMap.set(pkg, pkgModels);
|
|
5203
5315
|
this.updatePackagesMap(documentModelsMap);
|
|
5204
5316
|
}
|
|
5205
5317
|
async updateSubgraphsForPackage(pkg) {
|
|
5206
5318
|
this.logger.debug(`Updating subgraphs for package: ${pkg}`);
|
|
5207
5319
|
const subgraphs = await this.loadSubgraphs([pkg]);
|
|
5208
5320
|
const subgraphsMap = new Map(this.subgraphsMap);
|
|
5209
|
-
|
|
5321
|
+
const pkgSubgraphs = subgraphs.get(pkg) ?? [];
|
|
5322
|
+
if (pkgSubgraphs.length === 0) subgraphsMap.delete(pkg);
|
|
5323
|
+
else subgraphsMap.set(pkg, pkgSubgraphs);
|
|
5210
5324
|
this.updateSubgraphsMap(subgraphsMap);
|
|
5211
5325
|
}
|
|
5212
5326
|
async updateProcessorsForPackage(pkg) {
|
|
5213
5327
|
this.logger.debug(`Updating processors for package: ${pkg}`);
|
|
5214
5328
|
const processors = await this.loadProcessors([pkg]);
|
|
5215
5329
|
const processorsMap = new Map(this.processorMap);
|
|
5216
|
-
|
|
5330
|
+
const pkgProcessors = processors.get(pkg) ?? [];
|
|
5331
|
+
if (pkgProcessors.length === 0) processorsMap.delete(pkg);
|
|
5332
|
+
else processorsMap.set(pkg, pkgProcessors);
|
|
5217
5333
|
this.updateProcessorsMap(processorsMap);
|
|
5218
5334
|
}
|
|
5219
5335
|
/** Debounced per key so repeated subscribePackages calls reuse one timer. */
|
|
@@ -5285,6 +5401,28 @@ var PackageManager = class {
|
|
|
5285
5401
|
this.processorMap = processorsMap;
|
|
5286
5402
|
this.eventEmitter.emit("processorsChange", processorsMap);
|
|
5287
5403
|
}
|
|
5404
|
+
/**
|
|
5405
|
+
* Remove `pkg` from all package maps and emit the change events, tearing
|
|
5406
|
+
* down everything the package registered (subgraphs, processors, document
|
|
5407
|
+
* models). For an uninstalled package no loader can serve it again, so
|
|
5408
|
+
* nothing can re-add it.
|
|
5409
|
+
*/
|
|
5410
|
+
removePackage(pkg) {
|
|
5411
|
+
this.logger.info(`Removing package: ${pkg}`);
|
|
5412
|
+
const dropKey = (map) => {
|
|
5413
|
+
if (!map.has(pkg)) return map;
|
|
5414
|
+
const next = new Map(map);
|
|
5415
|
+
next.delete(pkg);
|
|
5416
|
+
return next;
|
|
5417
|
+
};
|
|
5418
|
+
this.docModelsMap = dropKey(this.docModelsMap);
|
|
5419
|
+
this.upgradeManifestsMap = dropKey(this.upgradeManifestsMap);
|
|
5420
|
+
this.subgraphsMap = dropKey(this.subgraphsMap);
|
|
5421
|
+
this.processorMap = dropKey(this.processorMap);
|
|
5422
|
+
this.updatePackagesMap(this.docModelsMap);
|
|
5423
|
+
this.updateSubgraphsMap(this.subgraphsMap);
|
|
5424
|
+
this.updateProcessorsMap(this.processorMap);
|
|
5425
|
+
}
|
|
5288
5426
|
onDocumentModelsChange(handler) {
|
|
5289
5427
|
this.eventEmitter.on("documentModelsChange", handler);
|
|
5290
5428
|
}
|
|
@@ -6359,7 +6497,7 @@ function buildSyncServingGate(reactorModule, authorizationConfig, logger) {
|
|
|
6359
6497
|
async function setupGraphQLManager(httpAdapter, authFetchMiddleware, requireAuthFetchMiddleware, httpServer, wsServer, client, relationalDb, analyticsStore, syncManager, subgraphs, logger, authorizationService, authService, documentPermissionService, enableDocumentModelSubgraphs, port, reactorDriveClient, syncServingGate) {
|
|
6360
6498
|
const graphqlManager = new GraphQLManager(config.basePath, httpServer, wsServer, client, relationalDb, analyticsStore, syncManager, logger, httpAdapter, await createGatewayAdapter("apollo", logger), authService, documentPermissionService, { enableDocumentModelSubgraphs }, port, authorizationService, reactorDriveClient, syncServingGate);
|
|
6361
6499
|
await graphqlManager.init(subgraphs.core, authFetchMiddleware, requireAuthFetchMiddleware);
|
|
6362
|
-
for (const [, collection] of subgraphs.extended.entries()) for (const subgraph of collection) await graphqlManager.registerSubgraph(subgraph, "graphql");
|
|
6500
|
+
for (const [packageName, collection] of subgraphs.extended.entries()) for (const subgraph of collection) await graphqlManager.registerSubgraph(subgraph, "graphql", false, packageName);
|
|
6363
6501
|
await graphqlManager.updateRouter();
|
|
6364
6502
|
return graphqlManager;
|
|
6365
6503
|
}
|
|
@@ -6386,14 +6524,28 @@ function setupEventListeners(pkgManager, graphqlManager, reactorProcessorManager
|
|
|
6386
6524
|
}
|
|
6387
6525
|
graphqlManager.regenerateDocumentModelSubgraphs();
|
|
6388
6526
|
});
|
|
6527
|
+
let knownSubgraphPackages = /* @__PURE__ */ new Set();
|
|
6389
6528
|
pkgManager.onSubgraphsChange((packagedSubgraphs) => {
|
|
6390
6529
|
(async () => {
|
|
6391
|
-
for (const [, subgraphs] of packagedSubgraphs)
|
|
6530
|
+
for (const [packageName, subgraphs] of packagedSubgraphs) {
|
|
6531
|
+
const incomingNames = /* @__PURE__ */ new Set();
|
|
6532
|
+
for (const subgraph of subgraphs) {
|
|
6533
|
+
const instance = await graphqlManager.registerSubgraph(subgraph, "graphql", false, packageName);
|
|
6534
|
+
if (!instance) continue;
|
|
6535
|
+
incomingNames.add(instance.name);
|
|
6536
|
+
}
|
|
6537
|
+
await graphqlManager.prunePackageSubgraphs(packageName, incomingNames);
|
|
6538
|
+
}
|
|
6539
|
+
for (const packageName of knownSubgraphPackages) if (!packagedSubgraphs.has(packageName)) await graphqlManager.unregisterPackage(packageName);
|
|
6540
|
+
knownSubgraphPackages = new Set(packagedSubgraphs.keys());
|
|
6392
6541
|
await graphqlManager.updateRouter();
|
|
6393
6542
|
})();
|
|
6394
6543
|
});
|
|
6544
|
+
let knownProcessorPackages = /* @__PURE__ */ new Set();
|
|
6395
6545
|
pkgManager.onProcessorsChange((processors) => {
|
|
6396
6546
|
(async () => {
|
|
6547
|
+
for (const packageName of knownProcessorPackages) if (!processors.has(packageName)) await reactorProcessorManager.unregisterFactory(packageName);
|
|
6548
|
+
knownProcessorPackages = new Set(processors.keys());
|
|
6397
6549
|
for (const [packageName, fns] of processors) {
|
|
6398
6550
|
await reactorProcessorManager.unregisterFactory(packageName);
|
|
6399
6551
|
const validBuilders = fns.map((fn) => fn(module)).filter((factory) => typeof factory === "function");
|
|
@@ -6729,7 +6881,8 @@ async function initializeAndStartAPI(clientInitializer, options, processorApp) {
|
|
|
6729
6881
|
syncManager,
|
|
6730
6882
|
documentModelRegistry,
|
|
6731
6883
|
readiness,
|
|
6732
|
-
attachmentReferenceProjection
|
|
6884
|
+
attachmentReferenceProjection,
|
|
6885
|
+
packageManager: packages
|
|
6733
6886
|
};
|
|
6734
6887
|
}
|
|
6735
6888
|
//#endregion
|
|
@@ -6760,6 +6913,7 @@ var PackageManagementService = class {
|
|
|
6760
6913
|
defaultRegistryUrl;
|
|
6761
6914
|
httpLoader;
|
|
6762
6915
|
documentModelRegistry;
|
|
6916
|
+
packageManager;
|
|
6763
6917
|
logger = childLogger(["reactor-api", "package-management-service"]);
|
|
6764
6918
|
onModelsChanged;
|
|
6765
6919
|
loadedModulesCache = /* @__PURE__ */ new Map();
|
|
@@ -6768,6 +6922,7 @@ var PackageManagementService = class {
|
|
|
6768
6922
|
this.defaultRegistryUrl = options.defaultRegistryUrl;
|
|
6769
6923
|
this.httpLoader = options.httpLoader;
|
|
6770
6924
|
this.documentModelRegistry = options.documentModelRegistry;
|
|
6925
|
+
this.packageManager = options.packageManager;
|
|
6771
6926
|
}
|
|
6772
6927
|
setOnModelsChanged(callback) {
|
|
6773
6928
|
this.onModelsChanged = callback;
|
|
@@ -6810,6 +6965,7 @@ var PackageManagementService = class {
|
|
|
6810
6965
|
this.loadedModulesCache.delete(name);
|
|
6811
6966
|
if (this.httpLoader) this.httpLoader.documentModelLoader.removeFromCache(name);
|
|
6812
6967
|
if (this.documentModelRegistry) this.documentModelRegistry.unregisterModules(...existing.documentTypes);
|
|
6968
|
+
if (this.packageManager) this.packageManager.removePackage(name);
|
|
6813
6969
|
this.triggerModelsChanged();
|
|
6814
6970
|
this.logger.info("Uninstalled package @name", name);
|
|
6815
6971
|
return true;
|
|
@@ -6836,4 +6992,4 @@ var PackageManagementService = class {
|
|
|
6836
6992
|
export { ADMIN_USERS, ActionCandidateInputSchema, ActionContextInputSchema, ActionInputSchema, AddRelationshipDocument, AnalyticsSubgraph, AttachmentAccessService, AuthDecision, AuthDecisionSchema, AuthService, AuthSubgraph, AuthorizationPolicy, AuthorizedDocumentHandle, BaseSubgraph, CanonicalDocumentIdResolutionError, ChannelMetaInputSchema, CreateDocumentDocument, CreateEmptyDocumentDocument, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentOperationsFilterInputSchema, DocumentPermissionService, EvaluateActionsDocument, FindDocumentsDocument, GetDocumentDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentModelsDocument, GetDocumentOperationsDocument, GetDocumentOutgoingRelationshipsDocument, GetDocumentWithOperationsDocument, GetJobStatusDocument, GraphQLManager, HttpDocumentModelLoader, HttpPackageLoader, ImportPackageLoader, InMemoryPackageStorage, JobChangesDocument, MoveRelationshipDocument, MutateDocumentAsyncDocument, MutateDocumentDocument, OperationContextInputSchema, OperationInputSchema, OperationWithContextInputSchema, OperationsFilterInputSchema, PGLITE_UTC_PARSERS, PackageManagementService, PackageManager, PackagesSubgraph, PagingInputSchema, PhDocumentFieldsFragmentDoc, PollSyncEnvelopesDocument, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, ReactorSignerAppInputSchema, ReactorSignerInputSchema, ReactorSignerUserInputSchema, ReactorSubgraph, RemoteCursorInputSchema, RemoteFilterInputSchema, RemoveRelationshipDocument, RenameDocumentDocument, SearchFilterInputSchema, SetPreferredEditorDocument, SyncEnvelopeInputSchema, SyncEnvelopeType, SyncEnvelopeTypeSchema, SystemSubgraph, TouchChannelDocument, TouchChannelInputSchema, ViewFilterInputSchema, assertAuthRequiredForDocumentPermissions, assertCredentialVerifierForSource, assertRequireAuthenticatedCallerAllowed, assertSkipCredentialVerificationAllowed, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, createAuthFetchMiddleware, createCanonicalDocumentIdResolver, createGatewayAdapter, createHttpAdapter, createMergedSchema, createReactorGraphQLClient, createRenownCredentialVerifier, createSchema, definedNonNullAnySchema, driveIdFromUrl, extractSubgraphsFromModule, generateDocumentModelSchema, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelTypeDefs, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getUniqueUpgradeManifests, getVersion, initAnalyticsStoreSql, initializeAndStartAPI, isDefinedNonNullAny, isExpectedLoaderMiss, isSubgraphClass, parseDriveUrl, renderGraphqlPlayground, resolveRenownConfig };
|
|
6837
6993
|
|
|
6838
6994
|
//# sourceMappingURL=index.mjs.map
|
|
6839
|
-
//# debugId=
|
|
6995
|
+
//# debugId=1ef5d33d-849a-5b1b-8d6e-74296692d4e4
|