@powerhousedao/switchboard 6.2.3-dev.64 → 6.2.3-dev.65
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/pglite-storage-dirs.test.d.ts +2 -0
- package/.tsbuild/test/pglite-storage-dirs.test.d.ts.map +1 -0
- package/.tsbuild/tsconfig.tsbuildinfo +1 -1
- package/CHANGELOG.md +24 -1
- package/dist/index.mjs +1 -1
- package/dist/plugins/attachments.mjs +3 -3
- package/dist/{server-C9RQTWTA.mjs → server-CYkOmpxa.mjs} +41 -10
- package/dist/{server-C9RQTWTA.mjs.map → server-CYkOmpxa.mjs.map} +1 -1
- package/dist/server.d.mts +32 -0
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +4 -4
- package/package.json +17 -17
- package/test/pglite-storage-dirs.test.ts +103 -0
package/dist/server.d.mts
CHANGED
|
@@ -331,6 +331,38 @@ export declare function createReactorKysely(opts: {
|
|
|
331
331
|
hostPoolSize: () => number;
|
|
332
332
|
logger: ILogger;
|
|
333
333
|
}): Promise<ReactorStorage>;
|
|
334
|
+
export interface PgliteStorageDirs {
|
|
335
|
+
/** Read-model store: a Postgres URL or a PGlite dir. */
|
|
336
|
+
readModelPath: string;
|
|
337
|
+
/** Reactor store: a Postgres URL or a PGlite dir. */
|
|
338
|
+
reactorPath: string;
|
|
339
|
+
/** PGlite dir for the reactor, null for Postgres or a caller-owned reactor. */
|
|
340
|
+
reactorPgliteDir: string | null;
|
|
341
|
+
/** PGlite dir for the read model, null for Postgres. */
|
|
342
|
+
readModelPgliteDir: string | null;
|
|
343
|
+
/** The PGlite dirs for the pre-flight, as before (not deduplicated). */
|
|
344
|
+
pgliteDirs: string[];
|
|
345
|
+
/** Set when BOTH stores are PGlite on one dir (see resolvePgliteStorageDirs). */
|
|
346
|
+
sharedPgliteDir: string | null;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Where the two stores live — the classic resolution, relocated verbatim.
|
|
350
|
+
* Classic layout: `./.ph/reactor-storage` for the reactor and
|
|
351
|
+
* `.ph/read-storage` for the read model (the same names inside
|
|
352
|
+
* `${userData}/.ph` under a shell's PH_USER_DATA_DIR). `dbPath` also names
|
|
353
|
+
* the reactor store unless PH_REACTOR_DATABASE_URL does: with `dbPath` alone
|
|
354
|
+
* both stores share one location. That is the long-standing contract of
|
|
355
|
+
* `--db-path` and fine for one Postgres database, but for PGlite it is two
|
|
356
|
+
* postmasters on one data dir — reported via `sharedPgliteDir` so the caller
|
|
357
|
+
* warns. Not refused: changing that contract is a separate decision.
|
|
358
|
+
*/
|
|
359
|
+
export declare function resolvePgliteStorageDirs(opts: {
|
|
360
|
+
dbPath: string | undefined;
|
|
361
|
+
reactorDbUrl: string | undefined;
|
|
362
|
+
/** The caller passed its own reactor — the reactor-side dir is unused. */
|
|
363
|
+
callerReactor: boolean;
|
|
364
|
+
phDir?: string;
|
|
365
|
+
}): PgliteStorageDirs;
|
|
334
366
|
/** Derive the remote attachment service config for switchboard's own `/attachments/*` API. */
|
|
335
367
|
export declare function deriveAttachmentServiceConfig(options: Pick<StartServerOptions, "attachmentServiceUrl" | "https">, serverPort: number, renown: IRenown | null): {
|
|
336
368
|
remoteUrl: string;
|
package/dist/server.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.mts","names":[],"sources":["../src/pglite-version.ts","../src/privacy.mts","../src/types.ts","../src/builder-defaults.mts","../src/unsupported-stored-documents.mts","../src/server.mts"],"mappings":";;;;;;;;;;;;;;;cASa;KACD,2BAA2B;;;KCe3B;;EAEV;;EAEA;;EAEA,SAAS;;;;;;;;;;YCRC;;YAKA,wBAAwB;EAClC,eAAe;;YAGL;EACV;EACA;EACA;;YAGU;;EAEV;;;;;EAKA;;EAGA;;YAGU;;;;;;;;;;;;;;;;;;;;;EAqBV,UAAU;;;;;;;;EAQV;;;;;;;EAOA;EACA;EACA;;;;;;EAMA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;IAEM;IACA;;;;;;;EASN,WAAW;;EAEX;;;EAGA;;;;;;EAMA,oBAAoB;;;EAGpB;;;EAGA;IACE;;;EAGF,UAAU;EACV,kBAAkB;EAClB;EACA;;;;;;EAMA;EACA,SAAS;;;;;;;;;;EAUT;;;;;;;;;;EAUA;;;;;;;;;EASA;IACE;IACA;IACA;;;;;;;;;;;EAWF;IACE;IACA;;;;;;;;;EASF,6BAA6B;;YAGnB;EACV;EACA,SAAS;;;;EAIT,mBAAmB;;EAEnB,+BAA+B;;;EAG/B,mBAAmB;;EAEnB;;EAEA,iBAAiB;;EAEjB;IAAY,SAAS;;;EAErB;;EAEA;;EAEA,QAAQ;;;;;EAKR;;;;;;;;;;;;;EAaA,gBAAgB;;;;KC7NN;EAIV,iBAAiB;;EAEjB,mBAAmB;;EAEnB;;;;;;;EAOA,gBAAgB;;EAEhB;;EAEA;IACE;IACA,eAAe,QAAQ;;;EAGzB,sBAAsB;EACtB,SAAS;;;;;;EAMT,SAAS;;;;;EAKT,cAAc,KAAK;;EAEnB,wBAAwB;;wBAiBV,gCACd,gBAAgB,gBAChB,eAAe,sBACf,UAAS;;;;wBCvEK,kCACd,OAAO,wCACP,KAAK,OAAO,aACX;;qBAaU,oCAAoC;WACtC;IAAqB;IAAkB;;WACvC;EAET,YAAY,OAAO;SAcZ,QAAQ,iBAAiB,SAAS;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"server.d.mts","names":[],"sources":["../src/pglite-version.ts","../src/privacy.mts","../src/types.ts","../src/builder-defaults.mts","../src/unsupported-stored-documents.mts","../src/server.mts"],"mappings":";;;;;;;;;;;;;;;cASa;KACD,2BAA2B;;;KCe3B;;EAEV;;EAEA;;EAEA,SAAS;;;;;;;;;;YCRC;;YAKA,wBAAwB;EAClC,eAAe;;YAGL;EACV;EACA;EACA;;YAGU;;EAEV;;;;;EAKA;;EAGA;;YAGU;;;;;;;;;;;;;;;;;;;;;EAqBV,UAAU;;;;;;;;EAQV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ACA,QAAQ;EACL;EAAmB,YAAY;;;;;;;;;;;;;;;;;;;qBAynCvB,mBAAgB,UAClB,uBACR,QAAQ"}
|
package/dist/server.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as
|
|
3
|
-
export { StoredDocumentsRefusedError, applySwitchboardReactorDefaults, createReactorKysely, deriveAttachmentServiceConfig, isPortAvailable, resolveUnsupportedStoredDocuments, startSwitchboard };
|
|
4
|
-
!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]="
|
|
5
|
-
//# debugId=
|
|
2
|
+
import { a as startSwitchboard, i as resolvePgliteStorageDirs, l as applySwitchboardReactorDefaults, n as deriveAttachmentServiceConfig, o as StoredDocumentsRefusedError, r as isPortAvailable, s as resolveUnsupportedStoredDocuments, t as createReactorKysely } from "./server-CYkOmpxa.mjs";
|
|
3
|
+
export { StoredDocumentsRefusedError, applySwitchboardReactorDefaults, createReactorKysely, deriveAttachmentServiceConfig, isPortAvailable, resolvePgliteStorageDirs, resolveUnsupportedStoredDocuments, startSwitchboard };
|
|
4
|
+
!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]="53370e72-5f4e-5016-9064-7a96e7ad5911")}catch(e){}}();
|
|
5
|
+
//# debugId=53370e72-5f4e-5016-9064-7a96e7ad5911
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/switchboard",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.2.3-dev.
|
|
4
|
+
"version": "6.2.3-dev.65",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -76,24 +76,24 @@
|
|
|
76
76
|
"@opentelemetry/sdk-node": "^0.218.0",
|
|
77
77
|
"@opentelemetry/sdk-trace-base": "^2.7.1",
|
|
78
78
|
"@opentelemetry/semantic-conventions": "^1.41.1",
|
|
79
|
-
"@powerhousedao/config": "6.2.3-dev.
|
|
80
|
-
"@powerhousedao/host-core": "6.2.3-dev.
|
|
81
|
-
"@powerhousedao/opentelemetry-instrumentation-reactor": "6.2.3-dev.
|
|
82
|
-
"@powerhousedao/reactor": "6.2.3-dev.
|
|
83
|
-
"@powerhousedao/reactor-api": "6.2.3-dev.
|
|
84
|
-
"@powerhousedao/reactor-attachments": "6.2.3-dev.
|
|
85
|
-
"@powerhousedao/reactor-drive": "6.2.3-dev.
|
|
86
|
-
"@powerhousedao/reactor-group": "6.2.3-dev.
|
|
87
|
-
"@powerhousedao/reactor-privacy": "6.2.3-dev.
|
|
88
|
-
"@powerhousedao/reactor-workflow": "6.2.3-dev.
|
|
89
|
-
"@powerhousedao/shared": "6.2.3-dev.
|
|
90
|
-
"@powerhousedao/vetra": "6.2.3-dev.
|
|
91
|
-
"@powerhousedao/workflow": "6.2.3-dev.
|
|
79
|
+
"@powerhousedao/config": "6.2.3-dev.65",
|
|
80
|
+
"@powerhousedao/host-core": "6.2.3-dev.65",
|
|
81
|
+
"@powerhousedao/opentelemetry-instrumentation-reactor": "6.2.3-dev.65",
|
|
82
|
+
"@powerhousedao/reactor": "6.2.3-dev.65",
|
|
83
|
+
"@powerhousedao/reactor-api": "6.2.3-dev.65",
|
|
84
|
+
"@powerhousedao/reactor-attachments": "6.2.3-dev.65",
|
|
85
|
+
"@powerhousedao/reactor-drive": "6.2.3-dev.65",
|
|
86
|
+
"@powerhousedao/reactor-group": "6.2.3-dev.65",
|
|
87
|
+
"@powerhousedao/reactor-privacy": "6.2.3-dev.65",
|
|
88
|
+
"@powerhousedao/reactor-workflow": "6.2.3-dev.65",
|
|
89
|
+
"@powerhousedao/shared": "6.2.3-dev.65",
|
|
90
|
+
"@powerhousedao/vetra": "6.2.3-dev.65",
|
|
91
|
+
"@powerhousedao/workflow": "6.2.3-dev.65",
|
|
92
92
|
"@pyroscope/nodejs": "^0.4.5",
|
|
93
|
-
"@renown/sdk": "6.2.3-dev.
|
|
93
|
+
"@renown/sdk": "6.2.3-dev.65",
|
|
94
94
|
"@sentry/node": "^10.53.1",
|
|
95
95
|
"@sentry/opentelemetry": "^10.53.1",
|
|
96
|
-
"document-model": "6.2.3-dev.
|
|
96
|
+
"document-model": "6.2.3-dev.65",
|
|
97
97
|
"dotenv": "^16.4.7",
|
|
98
98
|
"express": "^4.22.1",
|
|
99
99
|
"graphql": "^16",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"pg": "8.18.0",
|
|
104
104
|
"pglite-legacy-02": "npm:@electric-sql/pglite@0.2.17",
|
|
105
105
|
"pglite-tools-legacy-02": "npm:@electric-sql/pglite-tools@0.2.4",
|
|
106
|
-
"vite": "8.3.
|
|
106
|
+
"vite": "8.3.4"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@types/express": "^4.17.25",
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { resolvePgliteStorageDirs } from "../src/server.mjs";
|
|
4
|
+
|
|
5
|
+
/** The classic layout, and the one-dir report (uniform-runners legacy parity). */
|
|
6
|
+
describe("resolvePgliteStorageDirs", () => {
|
|
7
|
+
const phDir = path.join("/proj", ".ph");
|
|
8
|
+
|
|
9
|
+
it("keeps the classic literals verbatim without a user-data root", () => {
|
|
10
|
+
const saved = process.env.PH_USER_DATA_DIR;
|
|
11
|
+
delete process.env.PH_USER_DATA_DIR;
|
|
12
|
+
try {
|
|
13
|
+
const dirs = resolvePgliteStorageDirs({
|
|
14
|
+
dbPath: undefined,
|
|
15
|
+
reactorDbUrl: undefined,
|
|
16
|
+
callerReactor: false,
|
|
17
|
+
});
|
|
18
|
+
expect(dirs.reactorPgliteDir).toBe("./.ph/reactor-storage");
|
|
19
|
+
expect(dirs.readModelPgliteDir).toBe(".ph/read-storage");
|
|
20
|
+
expect(dirs.sharedPgliteDir).toBeNull();
|
|
21
|
+
} finally {
|
|
22
|
+
if (saved !== undefined) process.env.PH_USER_DATA_DIR = saved;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("defaults to the classic split under the .ph tree", () => {
|
|
27
|
+
const dirs = resolvePgliteStorageDirs({
|
|
28
|
+
dbPath: undefined,
|
|
29
|
+
reactorDbUrl: undefined,
|
|
30
|
+
callerReactor: false,
|
|
31
|
+
phDir,
|
|
32
|
+
});
|
|
33
|
+
expect(dirs.reactorPgliteDir).toBe(path.join(phDir, "reactor-storage"));
|
|
34
|
+
expect(dirs.readModelPgliteDir).toBe(path.join(phDir, "read-storage"));
|
|
35
|
+
expect(dirs.pgliteDirs).toEqual([
|
|
36
|
+
path.join(phDir, "reactor-storage"),
|
|
37
|
+
path.join(phDir, "read-storage"),
|
|
38
|
+
]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("reports — but keeps — the classic dbPath-only layout: both stores in one dir", () => {
|
|
42
|
+
const store = path.join("/proj", ".ph", "read-model.db");
|
|
43
|
+
const dirs = resolvePgliteStorageDirs({
|
|
44
|
+
dbPath: store,
|
|
45
|
+
reactorDbUrl: store,
|
|
46
|
+
callerReactor: false,
|
|
47
|
+
phDir,
|
|
48
|
+
});
|
|
49
|
+
expect(dirs.reactorPgliteDir).toBe(store);
|
|
50
|
+
expect(dirs.readModelPgliteDir).toBe(store);
|
|
51
|
+
// pre-flight list unchanged from the classic code (not deduplicated)
|
|
52
|
+
expect(dirs.pgliteDirs).toEqual([store, store]);
|
|
53
|
+
expect(dirs.sharedPgliteDir).toBe(path.resolve(store));
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("detects the same dir spelled differently", () => {
|
|
57
|
+
const dirs = resolvePgliteStorageDirs({
|
|
58
|
+
dbPath: "/proj/.ph/store/",
|
|
59
|
+
reactorDbUrl: "/proj/.ph/../.ph/store",
|
|
60
|
+
callerReactor: false,
|
|
61
|
+
phDir,
|
|
62
|
+
});
|
|
63
|
+
expect(dirs.sharedPgliteDir).toBe(path.resolve("/proj/.ph/store"));
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("allows one Postgres database for both stores", () => {
|
|
67
|
+
const dirs = resolvePgliteStorageDirs({
|
|
68
|
+
dbPath: "postgres://db/ph",
|
|
69
|
+
reactorDbUrl: "postgres://db/ph",
|
|
70
|
+
callerReactor: false,
|
|
71
|
+
phDir,
|
|
72
|
+
});
|
|
73
|
+
expect(dirs.reactorPgliteDir).toBeNull();
|
|
74
|
+
expect(dirs.readModelPgliteDir).toBeNull();
|
|
75
|
+
expect(dirs.pgliteDirs).toEqual([]);
|
|
76
|
+
expect(dirs.sharedPgliteDir).toBeNull();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("allows dbPath to name the read model only when the caller owns the reactor", () => {
|
|
80
|
+
const store = path.join("/proj", ".ph", "read-model.db");
|
|
81
|
+
const dirs = resolvePgliteStorageDirs({
|
|
82
|
+
dbPath: store,
|
|
83
|
+
reactorDbUrl: store,
|
|
84
|
+
callerReactor: true,
|
|
85
|
+
phDir,
|
|
86
|
+
});
|
|
87
|
+
expect(dirs.reactorPgliteDir).toBeNull();
|
|
88
|
+
expect(dirs.readModelPgliteDir).toBe(store);
|
|
89
|
+
expect(dirs.pgliteDirs).toEqual([store]);
|
|
90
|
+
expect(dirs.sharedPgliteDir).toBeNull();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("keeps a distinct reactor dir from PH_REACTOR_DATABASE_URL beside a dbPath", () => {
|
|
94
|
+
const dirs = resolvePgliteStorageDirs({
|
|
95
|
+
dbPath: path.join(phDir, "read-storage"),
|
|
96
|
+
reactorDbUrl: path.join(phDir, "reactor-storage"),
|
|
97
|
+
callerReactor: false,
|
|
98
|
+
phDir,
|
|
99
|
+
});
|
|
100
|
+
expect(dirs.pgliteDirs).toHaveLength(2);
|
|
101
|
+
expect(dirs.sharedPgliteDir).toBeNull();
|
|
102
|
+
});
|
|
103
|
+
});
|