@powerhousedao/reactor-api 6.2.3-dev.43 → 6.2.3-dev.45
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-CWqziB1p.mjs → adapter-http-express-P0t-mdMV.mjs} +6 -6
- package/dist/{adapter-http-express-CWqziB1p.mjs.map → adapter-http-express-P0t-mdMV.mjs.map} +1 -1
- package/dist/{adapter-http-fastify-CYZQ6FFv.mjs → adapter-http-fastify-D0OP5q9K.mjs} +6 -6
- package/dist/{adapter-http-fastify-CYZQ6FFv.mjs.map → adapter-http-fastify-D0OP5q9K.mjs.map} +1 -1
- package/dist/index.d.mts +33 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +62 -66
- package/dist/index.mjs.map +1 -1
- package/dist/pglite-node-Ow9i5Rb4.mjs +573 -0
- package/dist/pglite-node-Ow9i5Rb4.mjs.map +1 -0
- package/dist/src/packages/vite-loader.d.mts.map +1 -1
- package/dist/src/packages/vite-loader.mjs +5 -9
- package/dist/src/packages/vite-loader.mjs.map +1 -1
- package/dist/src/pglite/pglite-node.d.mts +130 -0
- package/dist/src/pglite/pglite-node.d.mts.map +1 -0
- package/dist/src/pglite/pglite-node.mjs +4 -0
- package/dist/{pieces-DRY6haAO.mjs → subgraph-extraction-DTFoN_bS.mjs} +93 -6
- package/dist/subgraph-extraction-DTFoN_bS.mjs.map +1 -0
- package/package.json +18 -14
- package/dist/pieces-DRY6haAO.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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]="e3951045-d29d-5cf1-b068-0ee1e9b26631")}catch(e){}}();
|
|
3
3
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
4
|
-
import { A as
|
|
4
|
+
import { A as AuthenticationRequiredError, C as callerSubject, D as AuthorizedDocumentHandle, E as AuthorizationPolicy, M as MalformedStoredOperationError, N as RefusalNotRecordedError, O as createAuthorizationService, S as BaseSubgraph, T as createCanonicalDocumentIdResolver, b as loadSubgraphs, c as piecesFromListModule, d as buildGraphQlDriveDocument, f as buildGraphqlOperation, g as extractUpgradeManifests, h as debounce, i as PIECE_SOURCE_LIST, j as ForbiddenError, k as AuthEvaluationUnsupportedError, l as extractDocumentModels, m as isSubgraphClass, o as pieceListLocation, p as buildGraphqlOperations, s as piecesFromCdnList, t as extractSubgraphs, u as buildGraphQlDocument, v as loadDocumentModels, w as CanonicalDocumentIdResolutionError, x as manifestDeclaredSubgraphs, y as loadProcessors } from "./subgraph-extraction-DTFoN_bS.mjs";
|
|
5
|
+
import { l as createDurableNodeFs, n as openCurrentPgliteForVerify, r as preparePgliteDataDir, u as resolvePgliteFsync } from "./pglite-node-Ow9i5Rb4.mjs";
|
|
5
6
|
import { findPackageJSON, isBuiltin } from "node:module";
|
|
6
7
|
import { AnalyticsQueryEngine } from "@powerhousedao/analytics-engine-core";
|
|
7
8
|
import { AnalyticsModel, AnalyticsResolvers, typedefs } from "@powerhousedao/analytics-engine-graphql";
|
|
@@ -14,7 +15,7 @@ import path, { isAbsolute, join } from "node:path";
|
|
|
14
15
|
import { match } from "path-to-regexp";
|
|
15
16
|
import posix from "node:path/posix";
|
|
16
17
|
import { Readable } from "node:stream";
|
|
17
|
-
import
|
|
18
|
+
import nodeFs, { existsSync, readFileSync, watchFile } from "node:fs";
|
|
18
19
|
import { pipeline } from "node:stream/promises";
|
|
19
20
|
import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
20
21
|
import { pathToFileURL } from "node:url";
|
|
@@ -46,7 +47,7 @@ import { createRelationalDb } from "@powerhousedao/shared/processors";
|
|
|
46
47
|
import { Kysely, Migrator, sql } from "kysely";
|
|
47
48
|
import { fetchDelegationCredential, resolveSwitchboardEndpoint, verifyAuthBearerToken } from "@renown/sdk";
|
|
48
49
|
import { PGlite } from "@electric-sql/pglite";
|
|
49
|
-
import {
|
|
50
|
+
import { NodeFS } from "@electric-sql/pglite/nodefs";
|
|
50
51
|
import knex from "knex";
|
|
51
52
|
import ClientPgLite from "knex-pglite";
|
|
52
53
|
import { KyselyKnexDialect, PGColdDialect } from "kysely-knex";
|
|
@@ -373,11 +374,11 @@ async function createGatewayAdapter(type, logger) {
|
|
|
373
374
|
async function createHttpAdapter(type) {
|
|
374
375
|
switch (type) {
|
|
375
376
|
case "express": {
|
|
376
|
-
const { createExpressHttpAdapter } = await import("./adapter-http-express-
|
|
377
|
+
const { createExpressHttpAdapter } = await import("./adapter-http-express-P0t-mdMV.mjs");
|
|
377
378
|
return createExpressHttpAdapter();
|
|
378
379
|
}
|
|
379
380
|
case "fastify": {
|
|
380
|
-
const { createFastifyHttpAdapter } = await import("./adapter-http-fastify-
|
|
381
|
+
const { createFastifyHttpAdapter } = await import("./adapter-http-fastify-D0OP5q9K.mjs");
|
|
381
382
|
return createFastifyHttpAdapter();
|
|
382
383
|
}
|
|
383
384
|
}
|
|
@@ -622,7 +623,7 @@ function writeError(res, status, message) {
|
|
|
622
623
|
}
|
|
623
624
|
//#endregion
|
|
624
625
|
//#region src/http/route-service.ts
|
|
625
|
-
const logger$
|
|
626
|
+
const logger$3 = childLogger(["reactor-api", "http-routes"]);
|
|
626
627
|
/** The segment package routes live under, inside the host's base path. */
|
|
627
628
|
const PACKAGE_ROUTE_SEGMENT = "api";
|
|
628
629
|
/** The namespace core's own subgraphs and services register under. */
|
|
@@ -717,7 +718,7 @@ var HttpRouteService = class {
|
|
|
717
718
|
return this.scopeFor(packageKey);
|
|
718
719
|
} catch (error) {
|
|
719
720
|
if (!(error instanceof InvalidNamespaceError)) throw error;
|
|
720
|
-
logger$
|
|
721
|
+
logger$3.warn("Package \"@package\" cannot host HTTP routes: @reason", packageKey, error.message);
|
|
721
722
|
return new UnroutableScope(packageKey, error.message);
|
|
722
723
|
}
|
|
723
724
|
}
|
|
@@ -824,7 +825,7 @@ var HttpScope = class {
|
|
|
824
825
|
path: routePath,
|
|
825
826
|
handles
|
|
826
827
|
});
|
|
827
|
-
logger$
|
|
828
|
+
logger$3.debug("Registered @route for @package", key, this.owner);
|
|
828
829
|
return {
|
|
829
830
|
url: `${this.#publicUrl}${routePath}`,
|
|
830
831
|
dispose: () => {
|
|
@@ -847,7 +848,7 @@ var HttpScope = class {
|
|
|
847
848
|
transport: resolveTransport(req, this.#trustProxy)
|
|
848
849
|
});
|
|
849
850
|
} catch (error) {
|
|
850
|
-
logger$
|
|
851
|
+
logger$3.error("Route handler failed for @package", this.owner, error);
|
|
851
852
|
writeError(res, 500, "Internal server error");
|
|
852
853
|
}
|
|
853
854
|
}
|
|
@@ -1127,7 +1128,7 @@ function parseWebhookBody(raw, contentType) {
|
|
|
1127
1128
|
}
|
|
1128
1129
|
//#endregion
|
|
1129
1130
|
//#region src/http/webhook-service.ts
|
|
1130
|
-
const logger$
|
|
1131
|
+
const logger$2 = childLogger(["reactor-api", "webhooks"]);
|
|
1131
1132
|
/** The flat, token-addressed path family. */
|
|
1132
1133
|
const WEBHOOK_SEGMENT = "webhooks";
|
|
1133
1134
|
const DEFAULT_MAX_BODY_BYTES = 1048576;
|
|
@@ -1272,7 +1273,7 @@ var WebhookService = class {
|
|
|
1272
1273
|
raw
|
|
1273
1274
|
});
|
|
1274
1275
|
if (!result.ok) {
|
|
1275
|
-
logger$
|
|
1276
|
+
logger$2.warn("Rejected webhook delivery for @package/@endpoint: @reason", row.namespace, row.endpoint, result.reason);
|
|
1276
1277
|
writeError(res, 401, "Signature verification failed");
|
|
1277
1278
|
return;
|
|
1278
1279
|
}
|
|
@@ -1312,7 +1313,7 @@ var WebhookService = class {
|
|
|
1312
1313
|
res.end(reply.body);
|
|
1313
1314
|
} else res.end();
|
|
1314
1315
|
} catch (error) {
|
|
1315
|
-
logger$
|
|
1316
|
+
logger$2.error("Webhook delivery failed for @method", req.method, error);
|
|
1316
1317
|
writeError(res, 500, "Internal server error");
|
|
1317
1318
|
}
|
|
1318
1319
|
}
|
|
@@ -1491,7 +1492,7 @@ var MemoryWebhookStore = class {
|
|
|
1491
1492
|
};
|
|
1492
1493
|
//#endregion
|
|
1493
1494
|
//#region src/utils/create-schema.ts
|
|
1494
|
-
const logger = childLogger(["reactor-api", "create-schema"]);
|
|
1495
|
+
const logger$1 = childLogger(["reactor-api", "create-schema"]);
|
|
1495
1496
|
/**
|
|
1496
1497
|
* Revision type - matches the definition in reactor/schema.graphql.
|
|
1497
1498
|
* Used by PHDocument and document mutation results.
|
|
@@ -1545,7 +1546,7 @@ const dedupeTypeDefinitions = (doc) => {
|
|
|
1545
1546
|
const name = def.name?.value;
|
|
1546
1547
|
if (!name) return true;
|
|
1547
1548
|
if (seen.has(name)) {
|
|
1548
|
-
logger.debug(`Dropping duplicate type definition: ${name}`);
|
|
1549
|
+
logger$1.debug(`Dropping duplicate type definition: ${name}`);
|
|
1549
1550
|
return false;
|
|
1550
1551
|
}
|
|
1551
1552
|
seen.add(name);
|
|
@@ -1679,7 +1680,7 @@ const getDocumentModelTypeDefs = (documentModels, typeDefs$1) => {
|
|
|
1679
1680
|
documentModels.forEach(({ documentModel }) => {
|
|
1680
1681
|
const dmSchemaName = getDocumentModelSchemaName(documentModel.global);
|
|
1681
1682
|
if (addedDocumentModels.has(dmSchemaName)) {
|
|
1682
|
-
logger.debug(`Skipping document model with duplicate name: ${dmSchemaName}`);
|
|
1683
|
+
logger$1.debug(`Skipping document model with duplicate name: ${dmSchemaName}`);
|
|
1683
1684
|
return;
|
|
1684
1685
|
}
|
|
1685
1686
|
addedDocumentModels.add(dmSchemaName);
|
|
@@ -1794,7 +1795,7 @@ function extractTypeNames(schema) {
|
|
|
1794
1795
|
try {
|
|
1795
1796
|
return definedTypeNames(parseSdl(schema), ALL_PREFIX_KINDS);
|
|
1796
1797
|
} catch (error) {
|
|
1797
|
-
logger.debug(`Skipping unparseable schema: ${String(error)}`);
|
|
1798
|
+
logger$1.debug(`Skipping unparseable schema: ${String(error)}`);
|
|
1798
1799
|
return [];
|
|
1799
1800
|
}
|
|
1800
1801
|
}
|
|
@@ -6826,10 +6827,10 @@ const ADMIN_USERS = getAdminUsers();
|
|
|
6826
6827
|
//#endregion
|
|
6827
6828
|
//#region src/graphql/system/version.ts
|
|
6828
6829
|
function getVersion() {
|
|
6829
|
-
return "6.2.3-dev.
|
|
6830
|
+
return "6.2.3-dev.45";
|
|
6830
6831
|
}
|
|
6831
6832
|
function getGitHash() {
|
|
6832
|
-
return "
|
|
6833
|
+
return "3c5c126a624df85976c11f2773d85226b4e2432b";
|
|
6833
6834
|
}
|
|
6834
6835
|
function getGitUrl() {
|
|
6835
6836
|
return buildTreeUrl(getGitHash());
|
|
@@ -7294,21 +7295,20 @@ async function removeLink(link) {
|
|
|
7294
7295
|
function piecesBaseUrl(registryUrl, packageName, version) {
|
|
7295
7296
|
return `${registryUrl.endsWith("/") ? registryUrl : `${registryUrl}/`}-/cdn/${packageName}@${version}/node/pieces/`;
|
|
7296
7297
|
}
|
|
7297
|
-
function documentModelsOf(module) {
|
|
7298
|
-
return Object.values(module).filter((m) => m !== null && typeof m === "object" && "documentModel" in m && m.documentModel !== null);
|
|
7299
|
-
}
|
|
7300
7298
|
/**
|
|
7301
7299
|
* Extract subgraph classes from the imported subgraphs/index.mjs module shape.
|
|
7302
7300
|
*
|
|
7303
7301
|
* The published bundle uses `export * as Foo from "./file"`, which Node turns
|
|
7304
7302
|
* into `{ Foo: <namespace>, … }`. The inner namespace's keys come from the
|
|
7305
7303
|
* source file's named exports — typically `Subgraph` / `default` / the class
|
|
7306
|
-
* name itself — so the shape varies.
|
|
7304
|
+
* name itself — so the shape varies.
|
|
7307
7305
|
*
|
|
7308
|
-
*
|
|
7306
|
+
* Delegates to the unified acceptance rule every package loader shares
|
|
7307
|
+
* (`extractSubgraphs`), kept as an export because it is part of the package's
|
|
7308
|
+
* public API and is unit-tested directly against synthetic module shapes.
|
|
7309
7309
|
*/
|
|
7310
7310
|
function extractSubgraphsFromModule(module) {
|
|
7311
|
-
return
|
|
7311
|
+
return extractSubgraphs(module);
|
|
7312
7312
|
}
|
|
7313
7313
|
/**
|
|
7314
7314
|
* Loads document models, subgraphs, and processors from an HTTP registry.
|
|
@@ -7429,7 +7429,7 @@ var HttpPackageLoader = class {
|
|
|
7429
7429
|
async loadDocumentModels(packageSpec) {
|
|
7430
7430
|
const { name: packageName } = this.parsePackageSpec(packageSpec);
|
|
7431
7431
|
const { module } = await this.importDocumentModels(packageSpec);
|
|
7432
|
-
const models =
|
|
7432
|
+
const models = extractDocumentModels(module);
|
|
7433
7433
|
this.logger.verbose(`Loaded ${models.length} document models from ${packageName}`);
|
|
7434
7434
|
return models;
|
|
7435
7435
|
}
|
|
@@ -7536,7 +7536,7 @@ var HttpDocumentModelLoader = class {
|
|
|
7536
7536
|
let models = this.packageModulesCache.get(packageName);
|
|
7537
7537
|
if (!models) {
|
|
7538
7538
|
const { module, filePath } = await this.loader.importDocumentModels(packageName);
|
|
7539
|
-
models =
|
|
7539
|
+
models = extractDocumentModels(module);
|
|
7540
7540
|
this.packageModulesCache.set(packageName, models);
|
|
7541
7541
|
if (filePath) this.packageFileCache.set(packageName, filePath);
|
|
7542
7542
|
}
|
|
@@ -7592,7 +7592,7 @@ var ImportPackageLoader = class {
|
|
|
7592
7592
|
this.logger.verbose(`Loading document models from package: ${identifier}`);
|
|
7593
7593
|
const pkgModule = await loadDocumentModels(identifier);
|
|
7594
7594
|
if (pkgModule) {
|
|
7595
|
-
const models =
|
|
7595
|
+
const models = extractDocumentModels(pkgModule);
|
|
7596
7596
|
this.logger.verbose(` ➜ Loaded ${models.length} Document Models from: ${identifier}`);
|
|
7597
7597
|
return models;
|
|
7598
7598
|
} else {
|
|
@@ -7614,11 +7614,9 @@ var ImportPackageLoader = class {
|
|
|
7614
7614
|
this.logger.verbose(` ➜ No Subgraphs found: ${identifier}`);
|
|
7615
7615
|
return [];
|
|
7616
7616
|
}
|
|
7617
|
-
const subgraphs =
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
this.logger.verbose(` ➜ Loaded Subgraphs from: ${identifier}`);
|
|
7621
|
-
return subgraphs.flat();
|
|
7617
|
+
const subgraphs = extractSubgraphs(pkgModule);
|
|
7618
|
+
this.logger.verbose(` ➜ Loaded ${subgraphs.length} Subgraphs from: ${identifier}`);
|
|
7619
|
+
return subgraphs;
|
|
7622
7620
|
}
|
|
7623
7621
|
async loadProcessors(identifier) {
|
|
7624
7622
|
this.logger.verbose(`Loading processors from package: ${identifier}`);
|
|
@@ -7806,6 +7804,10 @@ var PackageManager = class {
|
|
|
7806
7804
|
this.logger.debug("[@loader] Failed to load subgraphs from package @package: @error", loader.name, pkg, error);
|
|
7807
7805
|
}
|
|
7808
7806
|
this.maybeWarnAllLoadersFailed("subgraphs", pkg, succeeded, failures);
|
|
7807
|
+
if (allSubgraphs.length === 0) {
|
|
7808
|
+
const declared = manifestDeclaredSubgraphs(pkg);
|
|
7809
|
+
if (declared.length > 0) this.logger.warn("Package @pkg declares subgraphs in powerhouse.manifest.json (@declared) but none was loaded; check the exports of subgraphs/index.ts", pkg, declared.join(", "));
|
|
7810
|
+
}
|
|
7809
7811
|
subgraphsMap.set(pkg, allSubgraphs);
|
|
7810
7812
|
}
|
|
7811
7813
|
return subgraphsMap;
|
|
@@ -9163,45 +9165,30 @@ function resolveRenownSource(value, logger) {
|
|
|
9163
9165
|
}
|
|
9164
9166
|
//#endregion
|
|
9165
9167
|
//#region src/utils/db.ts
|
|
9168
|
+
const logger = childLogger(["reactor-api", "db"]);
|
|
9166
9169
|
const PGLITE_UTC_PARSERS = { 1114: (value) => /* @__PURE__ */ new Date(`${value.replace(" ", "T")}Z`) };
|
|
9167
|
-
function
|
|
9168
|
-
|
|
9169
|
-
return false;
|
|
9170
|
+
function isPostgresConnectionString(connectionString) {
|
|
9171
|
+
return connectionString.startsWith("postgresql://") || connectionString.startsWith("postgres://");
|
|
9170
9172
|
}
|
|
9171
|
-
/**
|
|
9172
|
-
* Cache of DB clients keyed by connection string. Reactor-api's read-model
|
|
9173
|
-
* layer wires analytics, attachments, and document-permissions as separate
|
|
9174
|
-
* consumers but they all target the same logical database (one postgres
|
|
9175
|
-
* instance, many schemas). Without caching:
|
|
9176
|
-
* - PGlite: two `new PGlite(samePath)` calls mean two embedded postgres
|
|
9177
|
-
* processes contending for the same data dir, racing shutdown syncs
|
|
9178
|
-
* and silently losing writes — a correctness bug.
|
|
9179
|
-
* - Postgres: each consumer opens an independent pool against the same
|
|
9180
|
-
* backend — wasteful but correct.
|
|
9181
|
-
* Caching by connection string returns the same knex/PGlite pair to every
|
|
9182
|
-
* consumer so writes coexist in one MemoryFS and one atomic snapshot, and
|
|
9183
|
-
* postgres callers get connection-pool dedup for free.
|
|
9184
|
-
*
|
|
9185
|
-
* Entries are evicted from inside the wrapped `knex.destroy()` below, so a
|
|
9186
|
-
* teardown + re-init in the same process (tests, hot-reloads) constructs
|
|
9187
|
-
* a fresh client instead of returning a closed pool.
|
|
9188
|
-
*/
|
|
9189
9173
|
const IN_MEMORY_CACHE_KEY = Symbol("getDbClient:in-memory");
|
|
9190
9174
|
const dbClientCache = /* @__PURE__ */ new Map();
|
|
9191
9175
|
function getDbClient(connectionString = void 0, pgliteFactory) {
|
|
9192
9176
|
const cacheKey = connectionString ?? IN_MEMORY_CACHE_KEY;
|
|
9193
9177
|
const cached = dbClientCache.get(cacheKey);
|
|
9194
9178
|
if (cached) return cached;
|
|
9195
|
-
const isPg = connectionString &&
|
|
9179
|
+
const isPg = connectionString && isPostgresConnectionString(connectionString);
|
|
9196
9180
|
const client = isPg ? "pg" : ClientPgLite;
|
|
9197
9181
|
const pgliteInstance = isPg ? void 0 : pgliteFactory ? pgliteFactory(connectionString) : connectionString ? new PGlite({
|
|
9198
|
-
fs:
|
|
9182
|
+
fs: createDurableNodeFs(NodeFS, connectionString, {
|
|
9183
|
+
fsync: resolvePgliteFsync(process.env),
|
|
9184
|
+
logger
|
|
9185
|
+
}),
|
|
9199
9186
|
parsers: PGLITE_UTC_PARSERS
|
|
9200
9187
|
}) : new PGlite({ parsers: PGLITE_UTC_PARSERS });
|
|
9201
9188
|
const connection = isPg ? { connectionString } : { pglite: pgliteInstance };
|
|
9202
9189
|
if (connectionString && !isPg) {
|
|
9203
9190
|
const dirPath = path.resolve(connectionString, "..");
|
|
9204
|
-
if (!
|
|
9191
|
+
if (!nodeFs.existsSync(dirPath)) nodeFs.mkdirSync(dirPath, { recursive: true });
|
|
9205
9192
|
}
|
|
9206
9193
|
const knexInstance = knex({
|
|
9207
9194
|
client,
|
|
@@ -9375,7 +9362,11 @@ function resolveAttachmentStoragePath(options) {
|
|
|
9375
9362
|
* (when on-disk PGlite is in use); callers are expected to run them as part
|
|
9376
9363
|
* of API teardown so PGlite WAL is flushed and the data-dir lock is released.
|
|
9377
9364
|
*/
|
|
9378
|
-
async function initializeDatabaseAndAnalytics(dbPath, pgliteFactory) {
|
|
9365
|
+
async function initializeDatabaseAndAnalytics(dbPath, pgliteFactory, logger) {
|
|
9366
|
+
if (!pgliteFactory && dbPath && !isPostgresConnectionString(dbPath)) await preparePgliteDataDir(dbPath, {
|
|
9367
|
+
openForVerify: openCurrentPgliteForVerify,
|
|
9368
|
+
logger
|
|
9369
|
+
});
|
|
9379
9370
|
const { db, knex, pglite } = getDbClient(dbPath, pgliteFactory);
|
|
9380
9371
|
const relationalDb = createRelationalDb(db);
|
|
9381
9372
|
const analyticsStore = new PostgresAnalyticsStore({ knex });
|
|
@@ -9383,7 +9374,7 @@ async function initializeDatabaseAndAnalytics(dbPath, pgliteFactory) {
|
|
|
9383
9374
|
return {
|
|
9384
9375
|
relationalDb,
|
|
9385
9376
|
analyticsStore,
|
|
9386
|
-
closers: makeDbClosers(knex, pglite)
|
|
9377
|
+
closers: makeDbClosers(knex, pglite, logger)
|
|
9387
9378
|
};
|
|
9388
9379
|
}
|
|
9389
9380
|
/**
|
|
@@ -9392,10 +9383,15 @@ async function initializeDatabaseAndAnalytics(dbPath, pgliteFactory) {
|
|
|
9392
9383
|
* (which is what the application talks to), then PGlite flushes WAL and
|
|
9393
9384
|
* unlocks the data dir.
|
|
9394
9385
|
*/
|
|
9395
|
-
function makeDbClosers(knexInstance, pglite) {
|
|
9386
|
+
function makeDbClosers(knexInstance, pglite, logger) {
|
|
9396
9387
|
const closers = [() => knexInstance.destroy()];
|
|
9397
9388
|
if (pglite) closers.push(async () => {
|
|
9398
|
-
if (
|
|
9389
|
+
if (pglite.closed) return;
|
|
9390
|
+
try {
|
|
9391
|
+
await pglite.close();
|
|
9392
|
+
} catch (err) {
|
|
9393
|
+
logger.warn(`PGlite close failed: ${String(err)}`);
|
|
9394
|
+
}
|
|
9399
9395
|
});
|
|
9400
9396
|
return closers;
|
|
9401
9397
|
}
|
|
@@ -9660,12 +9656,12 @@ async function _setupCommonInfrastructure(options) {
|
|
|
9660
9656
|
} else logger.warn("Anonymous callers are admitted on every transport, including WebSocket subscriptions: REQUIRE_AUTHENTICATED_CALLER is not set. The authorization policy gates the reactor's own documents, but a package-provided subgraph authorizes nothing on its own. Set REQUIRE_AUTHENTICATED_CALLER=true to refuse anonymous callers before any subgraph sees them.");
|
|
9661
9657
|
}
|
|
9662
9658
|
const dbClosers = [];
|
|
9663
|
-
const { relationalDb, analyticsStore, closers: analyticsClosers } = await initializeDatabaseAndAnalytics(options.dbPath, options.pgliteFactory);
|
|
9659
|
+
const { relationalDb, analyticsStore, closers: analyticsClosers } = await initializeDatabaseAndAnalytics(options.dbPath, options.pgliteFactory, logger);
|
|
9664
9660
|
dbClosers.push(...analyticsClosers);
|
|
9665
9661
|
let documentPermissionService = options.documentPermissionService;
|
|
9666
9662
|
if (!documentPermissionService && DOCUMENT_PERMISSIONS_ENABLED === "true") {
|
|
9667
9663
|
const { db, knex, pglite } = getDbClient(options.dbPath, options.pgliteFactory);
|
|
9668
|
-
dbClosers.push(...makeDbClosers(knex, pglite));
|
|
9664
|
+
dbClosers.push(...makeDbClosers(knex, pglite, logger));
|
|
9669
9665
|
await runMigrations(db);
|
|
9670
9666
|
logger.info("Document permission migrations completed");
|
|
9671
9667
|
documentPermissionService = new DocumentPermissionService(db, { defaultProtection });
|
|
@@ -9680,7 +9676,7 @@ async function _setupCommonInfrastructure(options) {
|
|
|
9680
9676
|
const attachmentStoragePath = resolveAttachmentStoragePath(options);
|
|
9681
9677
|
await mkdir(attachmentStoragePath, { recursive: true });
|
|
9682
9678
|
const { db: attachmentDb, knex: attachmentKnex, pglite: attachmentPglite } = getDbClient(options.dbPath, options.pgliteFactory);
|
|
9683
|
-
dbClosers.push(...makeDbClosers(attachmentKnex, attachmentPglite));
|
|
9679
|
+
dbClosers.push(...makeDbClosers(attachmentKnex, attachmentPglite, logger));
|
|
9684
9680
|
const ATTACHMENT_SWEEP_INTERVAL_MS = 36e5;
|
|
9685
9681
|
const attachmentBackend = await createStartupAttachmentBackend({ db: attachmentDb });
|
|
9686
9682
|
const attachmentBuilder = new AttachmentBuilder(attachmentDb, attachmentStoragePath).withReservationSweepMs(ATTACHMENT_SWEEP_INTERVAL_MS);
|
|
@@ -10090,7 +10086,7 @@ var PackageManagementService = class {
|
|
|
10090
10086
|
}
|
|
10091
10087
|
};
|
|
10092
10088
|
//#endregion
|
|
10093
|
-
export { ADMIN_USERS, ActionCandidateInputSchema, ActionContextInputSchema, ActionInputSchema, AddRelationshipDocument, AnalyticsSubgraph, AttachmentAccessFailed, AttachmentAccessService, AttachmentAccessUnavailable, AttachmentClientProvider, AuthDecision, AuthDecisionSchema, AuthEvaluationUnsupportedError, AuthService, AuthSubgraph, AuthenticationRequiredError, AuthorizationPolicy, AuthorizedAttachmentService, AuthorizedDocumentHandle, BaseSubgraph, CORE_PACKAGE_NAME, CanonicalDocumentIdResolutionError, ChannelMetaInputSchema, CreateDocumentDocument, CreateEmptyDocumentDocument, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentOperationsFilterInputSchema, DocumentPermissionService, DocumentRelationshipFieldsFragmentDoc, EvaluateActionsDocument, FindDocumentsDocument, ForbiddenError, GetDocumentDocument, GetDocumentIncomingRelationshipEdgesDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentModelsDocument, GetDocumentOperationsDocument, GetDocumentOutgoingRelationshipEdgesDocument, GetDocumentOutgoingRelationshipsDocument, GetDocumentWithOperationsDocument, GetJobStatusDocument, GraphQLManager, HttpDocumentModelLoader, HttpPackageLoader, HttpRouteService, ImportPackageLoader, InMemoryPackageStorage, InvalidNamespaceError, JobChangesDocument, MalformedStoredOperationError, MemoryWebhookStore, MoveRelationshipDocument, MutateDocumentAsyncDocument, MutateDocumentDocument, OperationContextInputSchema, OperationInputSchema, OperationWithContextInputSchema, OperationsFilterInputSchema, PACKAGE_ROUTE_SEGMENT, PGLITE_UTC_PARSERS, PackageManagementService, PackageManager, PackagesSubgraph, PagingInputSchema, PhDocumentFieldsFragmentDoc, PollSyncEnvelopesDocument, PrivacyPermissionAdapter, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, ReactorSignerAppInputSchema, ReactorSignerInputSchema, ReactorSignerUserInputSchema, ReactorSubgraph, RefusalNotRecordedError, RelationalWebhookStore, RemoteCursorInputSchema, RemoteFilterInputSchema, RemoveRelationshipDocument, RenameDocumentDocument, SearchFilterInputSchema, SetPreferredEditorDocument, SyncEnvelopeInputSchema, SyncEnvelopeType, SyncEnvelopeTypeSchema, SyncRefusalInputSchema, SystemSubgraph, TouchChannelDocument, TouchChannelInputSchema, UpdateRelationshipDocument, ViewFilterInputSchema, WEBHOOK_SEGMENT, WS_AUTH_CLOSE_REASONS, WS_CLOSE_REASON_AUTHENTICATION_REQUIRED, WS_CLOSE_REASON_BEARER_REJECTED, WebhookService, assertAttachmentPolicyReadsAllowed, assertAuthRequiredForDocumentPermissions, assertCredentialVerifierForSource, assertHostMountPath, assertRequireAuthenticatedCallerAllowed, assertSkipCredentialVerificationAllowed, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, callerSubject, createAuthFetchMiddleware, createCanonicalDocumentIdResolver, createGatewayAdapter, createHttpAdapter, createMergedSchema, createReactorGraphQLClient, createRenownCredentialVerifier, createSchema, createWsAuthHandlers, decodeExplorerUrlState, definedNonNullAnySchema, driveIdFromUrl, extractSubgraphsFromModule, generateDocumentModelSchema, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelTypeDefs, getExplorerPrefix, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getUniqueUpgradeManifests, getVersion, initAnalyticsStoreSql, initializeAndStartAPI, isDefinedNonNullAny, isExpectedLoaderMiss, isSubgraphClass, namespacePath, namespaceSegments, newWebhookToken, parseDriveUrl, parseWebhookBody, piecesBaseUrl, redactHeaders, renderGraphqlPlayground, resolvePackageName, resolveRenownConfig, verifyWebhook };
|
|
10089
|
+
export { ADMIN_USERS, ActionCandidateInputSchema, ActionContextInputSchema, ActionInputSchema, AddRelationshipDocument, AnalyticsSubgraph, AttachmentAccessFailed, AttachmentAccessService, AttachmentAccessUnavailable, AttachmentClientProvider, AuthDecision, AuthDecisionSchema, AuthEvaluationUnsupportedError, AuthService, AuthSubgraph, AuthenticationRequiredError, AuthorizationPolicy, AuthorizedAttachmentService, AuthorizedDocumentHandle, BaseSubgraph, CORE_PACKAGE_NAME, CanonicalDocumentIdResolutionError, ChannelMetaInputSchema, CreateDocumentDocument, CreateEmptyDocumentDocument, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentOperationsFilterInputSchema, DocumentPermissionService, DocumentRelationshipFieldsFragmentDoc, EvaluateActionsDocument, FindDocumentsDocument, ForbiddenError, GetDocumentDocument, GetDocumentIncomingRelationshipEdgesDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentModelsDocument, GetDocumentOperationsDocument, GetDocumentOutgoingRelationshipEdgesDocument, GetDocumentOutgoingRelationshipsDocument, GetDocumentWithOperationsDocument, GetJobStatusDocument, GraphQLManager, HttpDocumentModelLoader, HttpPackageLoader, HttpRouteService, ImportPackageLoader, InMemoryPackageStorage, InvalidNamespaceError, JobChangesDocument, MalformedStoredOperationError, MemoryWebhookStore, MoveRelationshipDocument, MutateDocumentAsyncDocument, MutateDocumentDocument, OperationContextInputSchema, OperationInputSchema, OperationWithContextInputSchema, OperationsFilterInputSchema, PACKAGE_ROUTE_SEGMENT, PGLITE_UTC_PARSERS, PackageManagementService, PackageManager, PackagesSubgraph, PagingInputSchema, PhDocumentFieldsFragmentDoc, PollSyncEnvelopesDocument, PrivacyPermissionAdapter, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, ReactorSignerAppInputSchema, ReactorSignerInputSchema, ReactorSignerUserInputSchema, ReactorSubgraph, RefusalNotRecordedError, RelationalWebhookStore, RemoteCursorInputSchema, RemoteFilterInputSchema, RemoveRelationshipDocument, RenameDocumentDocument, SearchFilterInputSchema, SetPreferredEditorDocument, SyncEnvelopeInputSchema, SyncEnvelopeType, SyncEnvelopeTypeSchema, SyncRefusalInputSchema, SystemSubgraph, TouchChannelDocument, TouchChannelInputSchema, UpdateRelationshipDocument, ViewFilterInputSchema, WEBHOOK_SEGMENT, WS_AUTH_CLOSE_REASONS, WS_CLOSE_REASON_AUTHENTICATION_REQUIRED, WS_CLOSE_REASON_BEARER_REJECTED, WebhookService, assertAttachmentPolicyReadsAllowed, assertAuthRequiredForDocumentPermissions, assertCredentialVerifierForSource, assertHostMountPath, assertRequireAuthenticatedCallerAllowed, assertSkipCredentialVerificationAllowed, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, callerSubject, createAuthFetchMiddleware, createCanonicalDocumentIdResolver, createGatewayAdapter, createHttpAdapter, createMergedSchema, createReactorGraphQLClient, createRenownCredentialVerifier, createSchema, createWsAuthHandlers, decodeExplorerUrlState, definedNonNullAnySchema, driveIdFromUrl, extractSubgraphs, extractSubgraphsFromModule, generateDocumentModelSchema, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelTypeDefs, getExplorerPrefix, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getUniqueUpgradeManifests, getVersion, initAnalyticsStoreSql, initializeAndStartAPI, isDefinedNonNullAny, isExpectedLoaderMiss, isPostgresConnectionString, isSubgraphClass, namespacePath, namespaceSegments, newWebhookToken, parseDriveUrl, parseWebhookBody, piecesBaseUrl, redactHeaders, renderGraphqlPlayground, resolvePackageName, resolveRenownConfig, verifyWebhook };
|
|
10094
10090
|
|
|
10095
10091
|
//# sourceMappingURL=index.mjs.map
|
|
10096
|
-
//# debugId=
|
|
10092
|
+
//# debugId=e3951045-d29d-5cf1-b068-0ee1e9b26631
|