@powerhousedao/switchboard 6.2.3-dev.75 → 6.2.3-dev.77
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/.tsbuild/test/permissions-backfill.test.d.ts +2 -0
- package/.tsbuild/test/permissions-backfill.test.d.ts.map +1 -0
- package/.tsbuild/tsconfig.tsbuildinfo +1 -1
- package/CHANGELOG.md +29 -0
- package/dist/index.mjs +1 -1
- package/dist/{plugin-host-CGO4XZzK.d.mts → plugin-host-BBqojyyY.d.mts} +6 -1
- package/dist/plugin-host-BBqojyyY.d.mts.map +1 -0
- package/dist/plugins/attachments.d.mts +1 -1
- package/dist/plugins/attachments.mjs +3 -3
- package/dist/plugins/mcp.d.mts +1 -1
- package/dist/plugins/privacy.d.mts +1 -1
- package/dist/plugins/workflows.d.mts +1 -1
- package/dist/{server-CJjK7WpR.mjs → server-BkL_NyGG.mjs} +174 -8
- package/dist/server-BkL_NyGG.mjs.map +1 -0
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +3 -3
- package/package.json +16 -16
- package/test/permissions-backfill.test.ts +486 -0
- package/vitest.config.ts +53 -0
- package/dist/plugin-host-CGO4XZzK.d.mts.map +0 -1
- package/dist/server-CJjK7WpR.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## 6.2.3-dev.77 (2026-10-26)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **switchboard:** wire the reactor client halves ([73e52624a2](https://github.com/powerhouse-inc/powerhouse/commit/73e52624a2))
|
|
6
|
+
- **switchboard:** move permission rows to the reactor store at boot ([5fd8f83190](https://github.com/powerhouse-inc/powerhouse/commit/5fd8f83190))
|
|
7
|
+
|
|
8
|
+
### ❤️ Thank You
|
|
9
|
+
|
|
10
|
+
- Claude Fable 5.1
|
|
11
|
+
- Wouter Kampmann
|
|
12
|
+
|
|
13
|
+
## 6.2.3-dev.76 (2026-10-25)
|
|
14
|
+
|
|
15
|
+
### 🚀 Features
|
|
16
|
+
|
|
17
|
+
- **switchboard:** pace catch-up by PH_CATCH_UP_PRIORITY and request load ([278d0ec3cd](https://github.com/powerhouse-inc/powerhouse/commit/278d0ec3cd))
|
|
18
|
+
- **switchboard:** run PGlite stores in worker threads by default ([ee8a84ff4d](https://github.com/powerhouse-inc/powerhouse/commit/ee8a84ff4d))
|
|
19
|
+
- **reactor-api,switchboard:** a deferred VACUUM FULL runs once overdue, and both timings are configurable ([0d083c8745](https://github.com/powerhouse-inc/powerhouse/commit/0d083c8745))
|
|
20
|
+
- **switchboard:** open reactor-storage in a PGlite worker thread behind PH_PGLITE_WORKERS ([06a1916860](https://github.com/powerhouse-inc/powerhouse/commit/06a1916860))
|
|
21
|
+
- **switchboard:** open read-storage in a PGlite worker thread behind PH_PGLITE_WORKERS ([0e0917a3d8](https://github.com/powerhouse-inc/powerhouse/commit/0e0917a3d8))
|
|
22
|
+
- **reactor-api,switchboard:** accept a PGlite stand-in wherever the stores take a PGlite ([f1c7754d57](https://github.com/powerhouse-inc/powerhouse/commit/f1c7754d57))
|
|
23
|
+
- **ph-cli,switchboard:** a catch-up progress display, and the inspector on the switchboard handle ([96ca0d3c29](https://github.com/powerhouse-inc/powerhouse/commit/96ca0d3c29))
|
|
24
|
+
|
|
25
|
+
### ❤️ Thank You
|
|
26
|
+
|
|
27
|
+
- Claude Opus 5.5
|
|
28
|
+
- Wouter Kampmann
|
|
29
|
+
|
|
1
30
|
## 6.2.3-dev.75 (2026-10-24)
|
|
2
31
|
|
|
3
32
|
### 🚀 Features
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
!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]="970d13d2-8fb1-53c8-819e-786cc25376f0")}catch(e){}}();
|
|
4
|
-
import { a as startSwitchboard, d as initProfilerFromEnv, f as parseForcePgVersion, o as StoredDocumentsRefusedError } from "./server-
|
|
4
|
+
import { a as startSwitchboard, d as initProfilerFromEnv, f as parseForcePgVersion, o as StoredDocumentsRefusedError } from "./server-BkL_NyGG.mjs";
|
|
5
5
|
import { metrics } from "@opentelemetry/api";
|
|
6
6
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
7
7
|
import { ExpressInstrumentation } from "@opentelemetry/instrumentation-express";
|
|
@@ -25,7 +25,12 @@ interface SwitchboardHostContext {
|
|
|
25
25
|
workflows?: unknown;
|
|
26
26
|
workflowsRetry?: unknown;
|
|
27
27
|
api?: unknown;
|
|
28
|
+
/** @deprecated The facade; plugins that have moved take `read` and `write`. */
|
|
28
29
|
client?: unknown;
|
|
30
|
+
/** The reactor's read half (IReactorReadClient), set at onReactorReady. */
|
|
31
|
+
read?: unknown;
|
|
32
|
+
/** The reactor's write half (IReactorWriteClient), set at onReactorReady. */
|
|
33
|
+
write?: unknown;
|
|
29
34
|
graphqlManager?: unknown;
|
|
30
35
|
reactorClientModule?: unknown;
|
|
31
36
|
/** Late subgraph registrations drain before the readiness router update. */
|
|
@@ -35,4 +40,4 @@ interface SwitchboardHostContext {
|
|
|
35
40
|
//#endregion
|
|
36
41
|
export { SwitchboardHostContext as t };
|
|
37
42
|
export {};
|
|
38
|
-
//# sourceMappingURL=plugin-host-
|
|
43
|
+
//# sourceMappingURL=plugin-host-BBqojyyY.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-host-BBqojyyY.d.mts","names":[],"sources":["../src/plugin-host.mts"],"mappings":";;;;;;;UAgDiB;;;EAGf;EACA,SAAS;EACT;EACA;;;EAGA;;;EAGA;EACA;;;EAGA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;EACA;EACA;;EAEA,gBAAgB;EAChB,eAAe,eAAe"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SwitchboardHostContext } from "../plugin-host-
|
|
1
|
+
import { t as SwitchboardHostContext } from "../plugin-host-BBqojyyY.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { HostPlugin } from "@powerhousedao/host-core";
|
|
4
4
|
//#region src/plugins/attachments.d.mts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as attachmentsPlugin, l as attachmentsPluginConfigSchema } from "../server-
|
|
1
|
+
import { c as attachmentsPlugin, l as attachmentsPluginConfigSchema } from "../server-BkL_NyGG.mjs";
|
|
2
2
|
export { attachmentsPlugin, attachmentsPlugin as default, attachmentsPluginConfigSchema };
|
|
3
|
-
!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]="
|
|
4
|
-
//# debugId=
|
|
3
|
+
!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]="0fc22757-862b-5bdd-856b-52378289a680")}catch(e){}}();
|
|
4
|
+
//# debugId=0fc22757-862b-5bdd-856b-52378289a680
|
package/dist/plugins/mcp.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SwitchboardHostContext } from "../plugin-host-
|
|
1
|
+
import { t as SwitchboardHostContext } from "../plugin-host-BBqojyyY.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { HostPlugin } from "@powerhousedao/host-core";
|
|
4
4
|
//#region src/plugins/privacy.d.mts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SwitchboardHostContext } from "../plugin-host-
|
|
1
|
+
import { t as SwitchboardHostContext } from "../plugin-host-BBqojyyY.mjs";
|
|
2
2
|
import { t as ComposedWorkflowRuntime } from "../workflow-runtime-7GaJ13c9.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { HostPlugin } from "@powerhousedao/host-core";
|
|
@@ -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]="71696ff5-99ce-5369-9bed-524565c3481d")}catch(e){}}();
|
|
3
3
|
import { _ as triggerFatalShutdown, a as workflowsPlugin, c as WORKFLOW_TELEMETRY_SCOPE, d as isWorkflowSingletonConflict, f as modelManifestSource, g as installFatalErrorShutdown, h as workflowSingletonLossHandler, l as assertWorkflowPackageLoadable, m as retryWorkflowSingleton, p as resolveWorkflowsEnabled, s as WORKFLOW_PACKAGE_NAME, u as composeWorkflowRuntime } from "./workflows-fsBcElEi.mjs";
|
|
4
4
|
import { i as startPrivacy, r as resolvePrivacy, t as privacyPlugin } from "./privacy-BsFl7GzK.mjs";
|
|
5
5
|
import { t as mcpPlugin } from "./mcp-SsBK14Jm.mjs";
|
|
@@ -26,7 +26,7 @@ import { createAttachmentClient } from "@powerhousedao/reactor-attachments/clien
|
|
|
26
26
|
import { DriveNodeView, NodeProcessor, ReactorDriveClient } from "@powerhousedao/reactor-drive";
|
|
27
27
|
import { REACTOR_DRIVE_SUBGRAPH_NAME, createReactorDriveResolvers, reactorDriveSubgraphTypeDefs } from "@powerhousedao/reactor-drive/subgraph";
|
|
28
28
|
import { DEFAULT_KEYPAIR_PATH, DEFAULT_RENOWN_URL, NodeKeyStorage, RENOWN_READ_MODEL_SUBGRAPH, RenownBuilder, RenownCryptoBuilder, createLocalCredentialVerifier, createRenownTrustPolicy, resolveSwitchboardEndpoint } from "@renown/sdk/node";
|
|
29
|
-
import { Kysely, PostgresDialect } from "kysely";
|
|
29
|
+
import { Kysely, PostgresDialect, sql } from "kysely";
|
|
30
30
|
import net from "node:net";
|
|
31
31
|
import path$1 from "path";
|
|
32
32
|
import { Pool } from "pg";
|
|
@@ -144,6 +144,153 @@ async function initProfiler(options, flags = {
|
|
|
144
144
|
if (flags.heapEnabled) Pyroscope.startHeapProfiling();
|
|
145
145
|
}
|
|
146
146
|
//#endregion
|
|
147
|
+
//#region src/permissions-backfill.mts
|
|
148
|
+
/** The permission tables, as reactor-api once kept them on the read-model store. */
|
|
149
|
+
const PERMISSION_TABLES = [
|
|
150
|
+
"DocumentPermission",
|
|
151
|
+
"OperationUserPermission",
|
|
152
|
+
"DocumentProtection"
|
|
153
|
+
];
|
|
154
|
+
/** What a read-model table is renamed to once its rows live in the reactor store. */
|
|
155
|
+
const MIGRATED_TABLE_SUFFIX = "_migrated_2026_10_25";
|
|
156
|
+
const INSERT_BATCH_SIZE = 500;
|
|
157
|
+
/**
|
|
158
|
+
* Moves the document permission rows from the read-model store into the
|
|
159
|
+
* reactor store, once.
|
|
160
|
+
*
|
|
161
|
+
* Runs at boot after the reactor's migrations (029 creates the target tables)
|
|
162
|
+
* and before the permission service serves a check. When the read-model
|
|
163
|
+
* store still has the legacy tables and the reactor store's are empty, every
|
|
164
|
+
* row is copied in one reactor-store transaction (ids are not carried: no
|
|
165
|
+
* table references them, and the target's serial assigns fresh ones), then
|
|
166
|
+
* the legacy tables are renamed to `<name>_migrated_2026_10_25` so the copy
|
|
167
|
+
* cannot run again. The renamed tables are kept for a release.
|
|
168
|
+
*
|
|
169
|
+
* Idempotent across crashes: when the copy committed but the rename did not,
|
|
170
|
+
* the next boot finds equal row counts on both sides and only renames. Any
|
|
171
|
+
* other mix of rows on both sides is refused with a warning and both stores
|
|
172
|
+
* are left as they are. Plain SQL throughout, so a PGlite or Postgres read
|
|
173
|
+
* store behaves the same.
|
|
174
|
+
*/
|
|
175
|
+
async function backfillPermissionTables(readModelDb, reactorDb, logger) {
|
|
176
|
+
const source = readModelDb;
|
|
177
|
+
const target = reactorDb;
|
|
178
|
+
const present = await existingTables(source);
|
|
179
|
+
const legacy = PERMISSION_TABLES.filter((table) => present.has(table));
|
|
180
|
+
if (legacy.length === 0) {
|
|
181
|
+
if (PERMISSION_TABLES.some((table) => present.has(migratedName(table)))) {
|
|
182
|
+
logger.debug("Permission tables backfill: already done; the read-model tables carry the _migrated_2026_10_25 suffix");
|
|
183
|
+
return { status: "already-backfilled" };
|
|
184
|
+
}
|
|
185
|
+
logger.debug("Permission tables backfill: the read-model store has no permission tables; nothing to copy");
|
|
186
|
+
return { status: "fresh-install" };
|
|
187
|
+
}
|
|
188
|
+
const blocked = legacy.filter((table) => present.has(migratedName(table)));
|
|
189
|
+
if (blocked.length > 0) return refuse(logger, `the read-model store has both ${blocked.join(", ")} and ${blocked.map(migratedName).join(", ")}; drop or rename one of each pair`);
|
|
190
|
+
const legacyCounts = await countRows(source, present);
|
|
191
|
+
const reactorCounts = await countRows(target, new Set(PERMISSION_TABLES));
|
|
192
|
+
if (PERMISSION_TABLES.reduce((sum, table) => sum + reactorCounts[table], 0) > 0) {
|
|
193
|
+
if (!countsEqual(legacyCounts, reactorCounts)) return refuse(logger, `the reactor store already has permission rows (${formatCounts(reactorCounts)}) that differ from the read-model store's (${formatCounts(legacyCounts)})`);
|
|
194
|
+
await renameLegacyTables(source, legacy);
|
|
195
|
+
logger.info(`Permission tables backfill: rows were copied by an earlier boot (${formatCounts(legacyCounts)}); renamed the read-model tables to *${MIGRATED_TABLE_SUFFIX}`);
|
|
196
|
+
return {
|
|
197
|
+
status: "rename-completed",
|
|
198
|
+
counts: legacyCounts
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
await target.transaction().execute(async (trx) => {
|
|
202
|
+
if (present.has("DocumentPermission")) await copyDocumentPermissions(source, trx);
|
|
203
|
+
if (present.has("OperationUserPermission")) await copyOperationUserPermissions(source, trx);
|
|
204
|
+
if (present.has("DocumentProtection")) await copyDocumentProtections(source, trx);
|
|
205
|
+
const copied = await countRows(trx, new Set(PERMISSION_TABLES));
|
|
206
|
+
if (!countsEqual(copied, legacyCounts)) throw new Error(`Permission tables backfill copied ${formatCounts(copied)} but the read-model store has ${formatCounts(legacyCounts)}; rolled back`);
|
|
207
|
+
});
|
|
208
|
+
await renameLegacyTables(source, legacy);
|
|
209
|
+
logger.info(`Permission tables backfill: copied ${formatCounts(legacyCounts)} from the read-model store to the reactor store; renamed the read-model tables to *${MIGRATED_TABLE_SUFFIX}`);
|
|
210
|
+
return {
|
|
211
|
+
status: "copied",
|
|
212
|
+
counts: legacyCounts
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function migratedName(table) {
|
|
216
|
+
return `${table}${MIGRATED_TABLE_SUFFIX}`;
|
|
217
|
+
}
|
|
218
|
+
function refuse(logger, reason) {
|
|
219
|
+
logger.warn(`Permission tables backfill refused: ${reason}. Permission checks read the reactor store; both stores were left unchanged.`);
|
|
220
|
+
return {
|
|
221
|
+
status: "refused",
|
|
222
|
+
reason
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/** The permission tables, legacy or renamed, in the read-model store's own schema. */
|
|
226
|
+
async function existingTables(db) {
|
|
227
|
+
const names = PERMISSION_TABLES.flatMap((table) => [table, migratedName(table)]);
|
|
228
|
+
const result = await sql`
|
|
229
|
+
select table_name from information_schema.tables
|
|
230
|
+
where table_schema = current_schema()
|
|
231
|
+
and table_name in (${sql.join(names)})
|
|
232
|
+
`.execute(db);
|
|
233
|
+
return new Set(result.rows.map((row) => row.table_name));
|
|
234
|
+
}
|
|
235
|
+
async function countRows(db, tables) {
|
|
236
|
+
const counts = {
|
|
237
|
+
DocumentPermission: 0,
|
|
238
|
+
OperationUserPermission: 0,
|
|
239
|
+
DocumentProtection: 0
|
|
240
|
+
};
|
|
241
|
+
for (const table of PERMISSION_TABLES) {
|
|
242
|
+
if (!tables.has(table)) continue;
|
|
243
|
+
const row = await db.selectFrom(table).select((eb) => eb.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
244
|
+
counts[table] = Number(row.count);
|
|
245
|
+
}
|
|
246
|
+
return counts;
|
|
247
|
+
}
|
|
248
|
+
function countsEqual(a, b) {
|
|
249
|
+
return PERMISSION_TABLES.every((table) => a[table] === b[table]);
|
|
250
|
+
}
|
|
251
|
+
function formatCounts(counts) {
|
|
252
|
+
return PERMISSION_TABLES.map((table) => `${table}=${counts[table]}`).join(", ");
|
|
253
|
+
}
|
|
254
|
+
async function copyDocumentPermissions(source, trx) {
|
|
255
|
+
const rows = await source.selectFrom("DocumentPermission").select([
|
|
256
|
+
"documentId",
|
|
257
|
+
"userAddress",
|
|
258
|
+
"permission",
|
|
259
|
+
"grantedBy",
|
|
260
|
+
"createdAt",
|
|
261
|
+
"updatedAt"
|
|
262
|
+
]).orderBy("id").execute();
|
|
263
|
+
for (const batch of batches(rows)) await trx.insertInto("DocumentPermission").values(batch).execute();
|
|
264
|
+
}
|
|
265
|
+
async function copyOperationUserPermissions(source, trx) {
|
|
266
|
+
const rows = await source.selectFrom("OperationUserPermission").select([
|
|
267
|
+
"documentId",
|
|
268
|
+
"operationType",
|
|
269
|
+
"userAddress",
|
|
270
|
+
"grantedBy",
|
|
271
|
+
"createdAt"
|
|
272
|
+
]).orderBy("id").execute();
|
|
273
|
+
for (const batch of batches(rows)) await trx.insertInto("OperationUserPermission").values(batch).execute();
|
|
274
|
+
}
|
|
275
|
+
async function copyDocumentProtections(source, trx) {
|
|
276
|
+
const rows = await source.selectFrom("DocumentProtection").select([
|
|
277
|
+
"documentId",
|
|
278
|
+
"protected",
|
|
279
|
+
"ownerAddress",
|
|
280
|
+
"createdAt",
|
|
281
|
+
"updatedAt"
|
|
282
|
+
]).orderBy("documentId").execute();
|
|
283
|
+
for (const batch of batches(rows)) await trx.insertInto("DocumentProtection").values(batch).execute();
|
|
284
|
+
}
|
|
285
|
+
function* batches(rows) {
|
|
286
|
+
for (let start = 0; start < rows.length; start += INSERT_BATCH_SIZE) yield rows.slice(start, start + INSERT_BATCH_SIZE);
|
|
287
|
+
}
|
|
288
|
+
async function renameLegacyTables(db, tables) {
|
|
289
|
+
await db.transaction().execute(async (trx) => {
|
|
290
|
+
for (const table of tables) await sql`ALTER TABLE ${sql.id(table)} RENAME TO ${sql.id(migratedName(table))}`.execute(trx);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
//#endregion
|
|
147
294
|
//#region src/attachments/auth.ts
|
|
148
295
|
const ANONYMOUS_ACTOR = {
|
|
149
296
|
user: void 0,
|
|
@@ -1879,7 +2026,7 @@ async function initServer(serverPort, options, renown, renownConfig) {
|
|
|
1879
2026
|
const catchUpPriority = new CatchUpPriority(catchUpPrioritySettingFromEnv(process.env.PH_CATCH_UP_PRIORITY, logger));
|
|
1880
2027
|
let workerModels;
|
|
1881
2028
|
let localRenownRequest;
|
|
1882
|
-
const initializeClient = async (documentModels, { attachmentReferenceWriter, upgradeManifests }) => {
|
|
2029
|
+
const initializeClient = async (documentModels, { attachmentReferenceWriter, upgradeManifests, readModelDb }) => {
|
|
1883
2030
|
if (options.reactor) {
|
|
1884
2031
|
const attachmentReferenceProjection = await registerAttachmentReferenceReadModelOnModule(options.reactor, attachmentReferenceWriter);
|
|
1885
2032
|
if (options.reactor.reactorModule) {
|
|
@@ -1994,15 +2141,29 @@ async function initServer(serverPort, options, renown, renownConfig) {
|
|
|
1994
2141
|
const reactorDriveSchemaDb = baseKysely.withSchema(REACTOR_SCHEMA);
|
|
1995
2142
|
driveNodeView = new DriveNodeView(reactorDriveSchemaDb);
|
|
1996
2143
|
const reactorDriveClient = new ReactorDriveClient({
|
|
1997
|
-
|
|
2144
|
+
read: module.read,
|
|
2145
|
+
write: module.write,
|
|
1998
2146
|
readModel: driveNodeView
|
|
1999
2147
|
});
|
|
2000
2148
|
ownedReactorModule = module;
|
|
2001
2149
|
if (options.fatalErrorShutdown) installFatalErrorShutdown(logger);
|
|
2150
|
+
const permissionsDb = baseKysely.withSchema(REACTOR_SCHEMA);
|
|
2151
|
+
try {
|
|
2152
|
+
if (readModelDb) await backfillPermissionTables(readModelDb, permissionsDb, logger);
|
|
2153
|
+
} catch (error) {
|
|
2154
|
+
logger.error("Aborting boot: permission tables backfill failed: @error", error);
|
|
2155
|
+
try {
|
|
2156
|
+
await module.reactorModule?.shutdown();
|
|
2157
|
+
} catch (shutdownError) {
|
|
2158
|
+
logger.error("Aborting boot: reactor shutdown failed: @error", shutdownError);
|
|
2159
|
+
}
|
|
2160
|
+
throw error;
|
|
2161
|
+
}
|
|
2002
2162
|
return {
|
|
2003
2163
|
module,
|
|
2004
2164
|
reactorDriveClient,
|
|
2005
|
-
attachmentReferenceProjection: { status: "available" }
|
|
2165
|
+
attachmentReferenceProjection: { status: "available" },
|
|
2166
|
+
permissionsDb
|
|
2006
2167
|
};
|
|
2007
2168
|
};
|
|
2008
2169
|
const abortBoot = async (api) => {
|
|
@@ -2112,10 +2273,12 @@ async function initServer(serverPort, options, renown, renownConfig) {
|
|
|
2112
2273
|
attachmentService = createRemoteAttachmentService(deriveAttachmentServiceConfig(options, serverPort, renown));
|
|
2113
2274
|
}
|
|
2114
2275
|
if (process.env.SENTRY_DSN) api.httpAdapter.setupSentryErrorHandler(Sentry);
|
|
2115
|
-
const { client, graphqlManager, documentModelRegistry } = api;
|
|
2276
|
+
const { client, read, write, graphqlManager, documentModelRegistry } = api;
|
|
2116
2277
|
const lateSubgraphs = [];
|
|
2117
2278
|
if (pluginHost) {
|
|
2118
2279
|
pluginHost.ctx.client = client;
|
|
2280
|
+
pluginHost.ctx.read = read;
|
|
2281
|
+
pluginHost.ctx.write = write;
|
|
2119
2282
|
pluginHost.ctx.graphqlManager = graphqlManager;
|
|
2120
2283
|
pluginHost.ctx.lateSubgraphs = lateSubgraphs;
|
|
2121
2284
|
pluginHost.ctx.reactorClientModule = options.reactor ?? ownedReactorModule;
|
|
@@ -2149,6 +2312,7 @@ async function initServer(serverPort, options, renown, renownConfig) {
|
|
|
2149
2312
|
const registerWorkflowSubgraph = (composed) => {
|
|
2150
2313
|
const WorkflowRuntimeSubgraph = composed.subgraph;
|
|
2151
2314
|
const workflowSubgraph = new WorkflowRuntimeSubgraph({
|
|
2315
|
+
readClient: read,
|
|
2152
2316
|
reactorClient: client,
|
|
2153
2317
|
http: graphqlManager.scopeForPackage(WORKFLOW_PACKAGE_NAME),
|
|
2154
2318
|
relationalDb: api.relationalDb,
|
|
@@ -2266,6 +2430,7 @@ async function initServer(serverPort, options, renown, renownConfig) {
|
|
|
2266
2430
|
const packagesSubgraph = new PackagesSubgraph({
|
|
2267
2431
|
relationalDb: void 0,
|
|
2268
2432
|
analyticsStore: void 0,
|
|
2433
|
+
readClient: read,
|
|
2269
2434
|
reactorClient: client,
|
|
2270
2435
|
graphqlManager,
|
|
2271
2436
|
syncManager: api.syncManager,
|
|
@@ -2291,6 +2456,7 @@ async function initServer(serverPort, options, renown, renownConfig) {
|
|
|
2291
2456
|
hostCanRead: (documentId, address) => authorizationService.canRead(documentId, address)
|
|
2292
2457
|
}),
|
|
2293
2458
|
typeDefs: reactorDriveSubgraphTypeDefs,
|
|
2459
|
+
readClient: read,
|
|
2294
2460
|
reactorClient: client,
|
|
2295
2461
|
relationalDb: void 0
|
|
2296
2462
|
};
|
|
@@ -2459,5 +2625,5 @@ function feedCatchUpPriority(priority, server) {
|
|
|
2459
2625
|
//#endregion
|
|
2460
2626
|
export { startSwitchboard as a, attachmentsPlugin as c, initProfilerFromEnv as d, parseForcePgVersion as f, resolvePgliteStorageDirs as i, attachmentsPluginConfigSchema as l, deriveAttachmentServiceConfig as n, StoredDocumentsRefusedError as o, isPortAvailable as r, resolveUnsupportedStoredDocuments as s, createReactorKysely as t, applySwitchboardReactorDefaults as u };
|
|
2461
2627
|
|
|
2462
|
-
//# sourceMappingURL=server-
|
|
2463
|
-
//# debugId=
|
|
2628
|
+
//# sourceMappingURL=server-BkL_NyGG.mjs.map
|
|
2629
|
+
//# debugId=71696ff5-99ce-5369-9bed-524565c3481d
|