@powerhousedao/switchboard 6.0.0-dev.21 → 6.0.0-dev.211

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.
Files changed (78) hide show
  1. package/Auth.md +45 -27
  2. package/CHANGELOG.md +1642 -5
  3. package/README.md +13 -12
  4. package/dist/index.d.mts +1 -0
  5. package/dist/index.mjs +129 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/dist/install-packages.d.mts +1 -0
  8. package/dist/install-packages.mjs +31 -0
  9. package/dist/install-packages.mjs.map +1 -0
  10. package/dist/migrate.d.mts +1 -0
  11. package/dist/migrate.mjs +55 -0
  12. package/dist/migrate.mjs.map +1 -0
  13. package/dist/server-8U7q7B7r.mjs +493 -0
  14. package/dist/server-8U7q7B7r.mjs.map +1 -0
  15. package/dist/server.d.mts +93 -0
  16. package/dist/server.d.mts.map +1 -0
  17. package/dist/server.mjs +4 -0
  18. package/dist/utils-DFl0ezBT.mjs +44 -0
  19. package/dist/utils-DFl0ezBT.mjs.map +1 -0
  20. package/dist/utils.d.mts +9 -0
  21. package/dist/utils.d.mts.map +1 -0
  22. package/dist/utils.mjs +2 -0
  23. package/package.json +54 -39
  24. package/test/attachments/auth.test.ts +219 -0
  25. package/test/attachments/index.test.ts +119 -0
  26. package/test/attachments/routes-integration.test.ts +103 -0
  27. package/test/attachments/routes.test.ts +501 -0
  28. package/test/metrics.test.ts +202 -0
  29. package/tsconfig.json +12 -3
  30. package/tsdown.config.ts +16 -0
  31. package/vitest.config.ts +11 -0
  32. package/Dockerfile +0 -86
  33. package/dist/src/clients/redis.d.ts +0 -5
  34. package/dist/src/clients/redis.d.ts.map +0 -1
  35. package/dist/src/clients/redis.js +0 -48
  36. package/dist/src/clients/redis.js.map +0 -1
  37. package/dist/src/config.d.ts +0 -12
  38. package/dist/src/config.d.ts.map +0 -1
  39. package/dist/src/config.js +0 -33
  40. package/dist/src/config.js.map +0 -1
  41. package/dist/src/connect-crypto.d.ts +0 -41
  42. package/dist/src/connect-crypto.d.ts.map +0 -1
  43. package/dist/src/connect-crypto.js +0 -127
  44. package/dist/src/connect-crypto.js.map +0 -1
  45. package/dist/src/feature-flags.d.ts +0 -2
  46. package/dist/src/feature-flags.d.ts.map +0 -1
  47. package/dist/src/feature-flags.js +0 -9
  48. package/dist/src/feature-flags.js.map +0 -1
  49. package/dist/src/index.d.ts +0 -3
  50. package/dist/src/index.d.ts.map +0 -1
  51. package/dist/src/index.js +0 -21
  52. package/dist/src/index.js.map +0 -1
  53. package/dist/src/install-packages.d.ts +0 -2
  54. package/dist/src/install-packages.d.ts.map +0 -1
  55. package/dist/src/install-packages.js +0 -36
  56. package/dist/src/install-packages.js.map +0 -1
  57. package/dist/src/migrate.d.ts +0 -3
  58. package/dist/src/migrate.d.ts.map +0 -1
  59. package/dist/src/migrate.js +0 -65
  60. package/dist/src/migrate.js.map +0 -1
  61. package/dist/src/profiler.d.ts +0 -4
  62. package/dist/src/profiler.d.ts.map +0 -1
  63. package/dist/src/profiler.js +0 -17
  64. package/dist/src/profiler.js.map +0 -1
  65. package/dist/src/server.d.ts +0 -6
  66. package/dist/src/server.d.ts.map +0 -1
  67. package/dist/src/server.js +0 -304
  68. package/dist/src/server.js.map +0 -1
  69. package/dist/src/types.d.ts +0 -64
  70. package/dist/src/types.d.ts.map +0 -1
  71. package/dist/src/types.js +0 -2
  72. package/dist/src/types.js.map +0 -1
  73. package/dist/src/utils.d.ts +0 -6
  74. package/dist/src/utils.d.ts.map +0 -1
  75. package/dist/src/utils.js +0 -92
  76. package/dist/src/utils.js.map +0 -1
  77. package/dist/tsconfig.tsbuildinfo +0 -1
  78. package/entrypoint.sh +0 -17
@@ -1 +0,0 @@
1
- {"version":3,"file":"feature-flags.js","sourceRoot":"","sources":["../../src/feature-flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,uDAAuD;IACvD,MAAM,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;IAEtC,MAAM,WAAW,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAE/C,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC;AACjC,CAAC"}
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
package/dist/src/index.js DELETED
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env node
2
- import { config } from "./config.js";
3
- import { startSwitchboard } from "./server.js";
4
- function ensureNodeVersion(minVersion = "22") {
5
- const version = process.versions.node;
6
- if (!version) {
7
- return;
8
- }
9
- if (version < minVersion) {
10
- console.error(`Node version ${minVersion} or higher is required. Current version: ${version}`);
11
- process.exit(1);
12
- }
13
- }
14
- // Ensure minimum Node.js version
15
- ensureNodeVersion("22");
16
- process.on("SIGINT", () => {
17
- console.log("\nShutting down...");
18
- process.exit(0);
19
- });
20
- startSwitchboard(config).catch(console.error);
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,SAAS,iBAAiB,CAAC,UAAU,GAAG,IAAI;IAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IACtC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IAED,IAAI,OAAO,GAAG,UAAU,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CACX,gBAAgB,UAAU,4CAA4C,OAAO,EAAE,CAChF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AACD,iCAAiC;AACjC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AAExB,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=install-packages.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"install-packages.d.ts","sourceRoot":"","sources":["../../src/install-packages.ts"],"names":[],"mappings":""}
@@ -1,36 +0,0 @@
1
- import { execSync } from "child_process";
2
- import fs from "fs";
3
- import path from "path";
4
- // Get the list of packages to install from the environment variable
5
- const pkgs = process.env.PH_PACKAGES?.split(",") || [];
6
- // Skip if no packages to install
7
- if (pkgs.length === 0 || (pkgs.length === 1 && pkgs[0] === "")) {
8
- process.exit(0);
9
- }
10
- try {
11
- // Read the package.json file to check existing dependencies
12
- const packageJsonPath = path.join(process.cwd(), "package.json");
13
- const packageJsonContent = fs.readFileSync(packageJsonPath, "utf-8");
14
- const packageJson = JSON.parse(packageJsonContent);
15
- // Get all installed dependencies
16
- const installedDependencies = {
17
- ...(packageJson.dependencies || {}),
18
- ...(packageJson.devDependencies || {}),
19
- };
20
- for (const pkg of pkgs) {
21
- if (pkg === "")
22
- continue;
23
- // Check if the package is already installed
24
- if (installedDependencies[pkg]) {
25
- console.log(`> Package ${pkg} is already installed, skipping`);
26
- continue;
27
- }
28
- console.log(`> Installing ${pkg}`);
29
- execSync(`pnpm add ${pkg}@latest`, { stdio: "inherit" });
30
- }
31
- }
32
- catch (error) {
33
- console.error("Error in package installation:", error);
34
- process.exit(1);
35
- }
36
- //# sourceMappingURL=install-packages.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"install-packages.js","sourceRoot":"","sources":["../../src/install-packages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAQxB,oEAAoE;AACpE,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;AAEvD,iCAAiC;AACjC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC;IAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,CAAC;IACH,4DAA4D;IAC5D,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IACjE,MAAM,kBAAkB,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IACrE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAgB,CAAC;IAElE,iCAAiC;IACjC,MAAM,qBAAqB,GAA2B;QACpD,GAAG,CAAC,WAAW,CAAC,YAAY,IAAI,EAAE,CAAC;QACnC,GAAG,CAAC,WAAW,CAAC,eAAe,IAAI,EAAE,CAAC;KACvC,CAAC;IAEF,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,GAAG,KAAK,EAAE;YAAE,SAAS;QAEzB,4CAA4C;QAC5C,IAAI,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,iCAAiC,CAAC,CAAC;YAC/D,SAAS;QACX,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC;QACnC,QAAQ,CAAC,YAAY,GAAG,SAAS,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;IACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=migrate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/migrate.ts"],"names":[],"mappings":""}
@@ -1,65 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Kysely, PostgresDialect } from "kysely";
3
- import { Pool } from "pg";
4
- import { runMigrations, getMigrationStatus, REACTOR_SCHEMA, } from "@powerhousedao/reactor";
5
- import { getConfig } from "@powerhousedao/config/node";
6
- function isPostgresUrl(url) {
7
- return url.startsWith("postgresql://") || url.startsWith("postgres://");
8
- }
9
- async function main() {
10
- const command = process.argv[2];
11
- const config = getConfig();
12
- const dbPath = process.env.PH_REACTOR_DATABASE_URL ??
13
- process.env.DATABASE_URL ??
14
- config.switchboard?.database?.url;
15
- if (!dbPath || !isPostgresUrl(dbPath)) {
16
- console.log("No PostgreSQL URL configured. Skipping migrations.");
17
- console.log("(PGlite migrations are handled automatically on startup)");
18
- return;
19
- }
20
- console.log(`Database: ${dbPath}`);
21
- const pool = new Pool({ connectionString: dbPath });
22
- const db = new Kysely({
23
- dialect: new PostgresDialect({ pool }),
24
- });
25
- try {
26
- if (command === "status") {
27
- console.log("\nChecking migration status...");
28
- const migrations = await getMigrationStatus(db, REACTOR_SCHEMA);
29
- console.log("\nMigration Status:");
30
- console.log("=================");
31
- for (const migration of migrations) {
32
- const status = migration.executedAt
33
- ? `[OK] Executed at ${migration.executedAt.toISOString()}`
34
- : "[--] Pending";
35
- console.log(`${status} - ${migration.name}`);
36
- }
37
- }
38
- else {
39
- console.log("\nRunning migrations...");
40
- const result = await runMigrations(db, REACTOR_SCHEMA);
41
- if (!result.success) {
42
- console.error("Migration failed:", result.error?.message);
43
- process.exit(1);
44
- }
45
- if (result.migrationsExecuted.length === 0) {
46
- console.log("No migrations to run - database is up to date");
47
- }
48
- else {
49
- console.log(`Successfully executed ${result.migrationsExecuted.length} migration(s):`);
50
- for (const name of result.migrationsExecuted) {
51
- console.log(` - ${name}`);
52
- }
53
- }
54
- }
55
- }
56
- catch (error) {
57
- console.error("Error:", error instanceof Error ? error.message : String(error));
58
- process.exit(1);
59
- }
60
- finally {
61
- await db.destroy();
62
- }
63
- }
64
- void main();
65
- //# sourceMappingURL=migrate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/migrate.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAC1E,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAE3B,MAAM,MAAM,GACV,OAAO,CAAC,GAAG,CAAC,uBAAuB;QACnC,OAAO,CAAC,GAAG,C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E,EAAE,cAAc,CAAC,CAAC;YAEvD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;gBAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YAED,IAAI,MAAM,CAAC,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC3C,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CACT,yBAAyB,MAAM,CAAC,kBAAkB,CAAC,MAAM,gBAAgB,CAC1E,CAAC;gBACF,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,kBAAkB,EAAE,CAAC;oBAC7C,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;gBAC7B,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,QAAQ,EACR,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC;AACH,CAAC;AAED,KAAK,IAAI,EAAE,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { PyroscopeConfig } from "@pyroscope/nodejs";
2
- export declare function initProfilerFromEnv(env: typeof process.env): Promise<void>;
3
- export declare function initProfiler(options?: PyroscopeConfig): Promise<void>;
4
- //# sourceMappingURL=profiler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"profiler.d.ts","sourceRoot":"","sources":["../../src/profiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,OAAO,OAAO,CAAC,GAAG,iBAehE;AAED,wBAAsB,YAAY,CAAC,OAAO,CAAC,EAAE,eAAe,iBAK3D"}
@@ -1,17 +0,0 @@
1
- export async function initProfilerFromEnv(env) {
2
- const { PYROSCOPE_SERVER_ADDRESS: serverAddress, PYROSCOPE_APPLICATION_NAME: appName, PYROSCOPE_USER: basicAuthUser, PYROSCOPE_PASSWORD: basicAuthPassword, } = env;
3
- const options = {
4
- serverAddress,
5
- appName,
6
- basicAuthUser,
7
- basicAuthPassword,
8
- };
9
- return initProfiler(options);
10
- }
11
- export async function initProfiler(options) {
12
- console.log("Initializing Pyroscope profiler at:", options?.serverAddress);
13
- const Pyroscope = await import("@pyroscope/nodejs");
14
- Pyroscope.init(options);
15
- Pyroscope.start();
16
- }
17
- //# sourceMappingURL=profiler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"profiler.js","sourceRoot":"","sources":["../../src/profiler.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,GAAuB;IAC/D,MAAM,EACJ,wBAAwB,EAAE,aAAa,EACvC,0BAA0B,EAAE,OAAO,EACnC,cAAc,EAAE,aAAa,EAC7B,kBAAkB,EAAE,iBAAiB,GACtC,GAAG,GAAG,CAAC;IAER,MAAM,OAAO,GAAoB;QAC/B,aAAa;QACb,OAAO;QACP,aAAa;QACb,iBAAiB;KAClB,CAAC;IACF,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAyB;IAC1D,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;IAC3E,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;IACpD,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxB,SAAS,CAAC,KAAK,EAAE,CAAC;AACpB,CAAC"}
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import type { StartServerOptions, SwitchboardReactor } from "./types.js";
3
- export declare const startSwitchboard: (options?: StartServerOptions) => Promise<SwitchboardReactor>;
4
- export { getBearerToken, getConnectCrypto, getConnectDid, } from "./connect-crypto.js";
5
- export * from "./types.js";
6
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":";AA6CA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAkTzE,eAAO,MAAM,gBAAgB,GAC3B,UAAS,kBAAuB,KAC/B,OAAO,CAAC,kBAAkB,CAiE5B,CAAC;AAEF,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -1,304 +0,0 @@
1
- #!/usr/bin/env node
2
- import { PGlite } from "@electric-sql/pglite";
3
- import { CompositeChannelFactory, ConsoleLogger, driveCollectionId, EventBus, parseDriveUrl, ReactorBuilder, ReactorClientBuilder, SyncBuilder, } from "@powerhousedao/reactor";
4
- import { VitePackageLoader, getUniqueDocumentModels, initializeAndStartAPI, startViteServer, } from "@powerhousedao/reactor-api";
5
- import { ConnectCryptoSigner } from "@renown/sdk";
6
- import * as Sentry from "@sentry/node";
7
- import { DocumentAlreadyExistsError, InMemoryCache, ReactorBuilder as LegacyReactorBuilder, childLogger, driveDocumentModelModule, } from "document-drive";
8
- import { RedisCache } from "document-drive/cache/redis";
9
- import { FilesystemStorage } from "document-drive/storage/filesystem";
10
- import { PrismaStorageFactory } from "document-drive/storage/prisma";
11
- import { documentModelDocumentModelModule } from "document-model";
12
- import dotenv from "dotenv";
13
- import express from "express";
14
- import { Kysely, PostgresDialect } from "kysely";
15
- import { PGliteDialect } from "kysely-pglite-dialect";
16
- import path from "path";
17
- import { Pool } from "pg";
18
- import { initRedis } from "./clients/redis.js";
19
- import { initConnectCrypto } from "./connect-crypto.js";
20
- import { initFeatureFlags } from "./feature-flags.js";
21
- import { initProfilerFromEnv } from "./profiler.js";
22
- import { addDefaultDrive, addRemoteDrive, isPostgresUrl } from "./utils.js";
23
- const logger = childLogger(["switchboard"]);
24
- dotenv.config();
25
- // Feature flag constants
26
- const DOCUMENT_MODEL_SUBGRAPHS_ENABLED = "DOCUMENT_MODEL_SUBGRAPHS_ENABLED";
27
- const DOCUMENT_MODEL_SUBGRAPHS_ENABLED_DEFAULT = true;
28
- const REACTOR_STORAGE_V2 = "REACTOR_STORAGE_V2";
29
- const REACTOR_STORAGE_V2_DEFAULT = true;
30
- const ENABLE_DUAL_ACTION_CREATE = "ENABLE_DUAL_ACTION_CREATE";
31
- const ENABLE_DUAL_ACTION_CREATE_DEFAULT = true;
32
- // Create a monolith express app for all subgraphs
33
- const app = express();
34
- if (process.env.SENTRY_DSN) {
35
- logger.info("Initialized Sentry with env:", process.env.SENTRY_ENV);
36
- Sentry.init({
37
- dsn: process.env.SENTRY_DSN,
38
- environment: process.env.SENTRY_ENV,
39
- });
40
- Sentry.setupExpressErrorHandler(app);
41
- }
42
- const DEFAULT_PORT = process.env.PORT ? Number(process.env.PORT) : 4001;
43
- async function initPrismaStorage(connectionString, cache) {
44
- try {
45
- const prismaFactory = new PrismaStorageFactory(connectionString, cache);
46
- await prismaFactory.checkConnection();
47
- return prismaFactory.build();
48
- }
49
- catch (e) {
50
- const prismaConnectError = "Can't reach database server at";
51
- if (e instanceof Error && e.message.includes(prismaConnectError)) {
52
- const dbUrl = connectionString;
53
- const safeUrl = `${dbUrl.slice(0, dbUrl.indexOf(":") + 1)}{...}${dbUrl.slice(dbUrl.indexOf("@"), dbUrl.lastIndexOf("?"))}`;
54
- logger.warn(`Can't reach database server at '${safeUrl}'`);
55
- }
56
- else {
57
- logger.error(e);
58
- }
59
- throw e;
60
- }
61
- }
62
- async function initReactorStorage(cache, dbPath = "./.ph/drive-storage") {
63
- const isPostgres = isPostgresUrl(dbPath);
64
- try {
65
- if (isPostgres) {
66
- const connectionString = dbPath.includes("amazonaws") && !dbPath.includes("sslmode=no-verify")
67
- ? dbPath + "?sslmode=no-verify"
68
- : dbPath;
69
- const storage = await initPrismaStorage(connectionString, cache);
70
- return { storage, storagePath: dbPath };
71
- }
72
- }
73
- catch {
74
- logger.warn("Falling back to filesystem storage");
75
- }
76
- // if url was postgres and connection failed, fallback to filesystem on default path
77
- const filesystemPath = isPostgres ? "./.ph/drive-storage" : dbPath;
78
- return {
79
- storage: new FilesystemStorage(path.join(process.cwd(), filesystemPath)),
80
- storagePath: filesystemPath,
81
- };
82
- }
83
- async function initServer(serverPort, options, connectCrypto) {
84
- const { dev, packages = [], remoteDrives = [] } = options;
85
- const dbPath = options.dbPath ?? process.env.DATABASE_URL;
86
- // start redis if configured
87
- const redisUrl = process.env.REDIS_TLS_URL ?? process.env.REDIS_URL;
88
- let redis;
89
- if (redisUrl) {
90
- try {
91
- redis = await initRedis(redisUrl);
92
- }
93
- catch (e) {
94
- logger.error(e);
95
- }
96
- }
97
- const cache = redis ? new RedisCache(redis) : new InMemoryCache();
98
- const { storage, storagePath } = await initReactorStorage(cache, dbPath);
99
- // if dbPath is not configured, or it was a postgres url but the connection failed,
100
- // use default path for read model storage
101
- const readModelPath = !dbPath || (isPostgresUrl(dbPath) && dbPath !== storagePath)
102
- ? ".ph/read-storage"
103
- : dbPath;
104
- const initializeDriveServer = async (documentModels) => {
105
- const driveServer = new LegacyReactorBuilder(getUniqueDocumentModels([
106
- documentModelDocumentModelModule,
107
- driveDocumentModelModule,
108
- ...documentModels,
109
- ]))
110
- .withStorage(storage)
111
- .withCache(cache)
112
- .withOptions({
113
- featureFlags: {
114
- enableDualActionCreate: options.reactorOptions?.enableDualActionCreate ?? false,
115
- },
116
- })
117
- .build();
118
- // init drive server
119
- await driveServer.initialize();
120
- return driveServer;
121
- };
122
- const initializeClient = async (driveServer, documentModels) => {
123
- const eventBus = new EventBus();
124
- const builder = new ReactorBuilder()
125
- .withEventBus(eventBus)
126
- .withDocumentModels(getUniqueDocumentModels([
127
- documentModelDocumentModelModule,
128
- driveDocumentModelModule,
129
- ...documentModels,
130
- ]))
131
- .withLegacyStorage(storage)
132
- .withSync(new SyncBuilder().withChannelFactory(new CompositeChannelFactory(new ConsoleLogger(["switchboard"]))))
133
- .withFeatures({
134
- legacyStorageEnabled: !options.reactorOptions?.storageV2,
135
- });
136
- const reactorDbUrl = process.env.PH_REACTOR_DATABASE_URL;
137
- if (reactorDbUrl && isPostgresUrl(reactorDbUrl)) {
138
- const connectionString = reactorDbUrl.includes("?")
139
- ? reactorDbUrl
140
- : `${reactorDbUrl}?sslmode=disable`;
141
- const pool = new Pool({ connectionString });
142
- const kysely = new Kysely({
143
- dialect: new PostgresDialect({ pool }),
144
- });
145
- builder.withKysely(kysely);
146
- logger.info("Using PostgreSQL for reactor storage");
147
- }
148
- else {
149
- const pglitePath = "./.ph/reactor-storage";
150
- const pglite = new PGlite(pglitePath);
151
- const kysely = new Kysely({
152
- dialect: new PGliteDialect(pglite),
153
- });
154
- builder.withKysely(kysely);
155
- logger.info("Using PGlite for reactor storage");
156
- }
157
- const clientBuilder = new ReactorClientBuilder().withReactorBuilder(builder);
158
- if (connectCrypto) {
159
- clientBuilder.withSigner(new ConnectCryptoSigner(connectCrypto));
160
- }
161
- const module = await clientBuilder.buildModule();
162
- // Return the full ReactorClientModule
163
- return module;
164
- };
165
- let defaultDriveUrl = undefined;
166
- // TODO get path from powerhouse config
167
- // start vite server if dev mode is enabled
168
- const basePath = process.cwd();
169
- const vite = dev ? await startViteServer(process.cwd()) : undefined;
170
- // get paths to local document models
171
- if (!options.disableLocalPackages) {
172
- packages.push(basePath);
173
- }
174
- // storageV2=true means use new reactor (NOT legacy)
175
- const legacyReactor = !options.reactorOptions?.storageV2;
176
- // create loader with legacyReactor option
177
- const packageLoader = vite
178
- ? VitePackageLoader.build(vite, { legacyReactor })
179
- : undefined;
180
- const api = await initializeAndStartAPI(initializeDriveServer, initializeClient, {
181
- express: app,
182
- port: serverPort,
183
- dbPath: readModelPath,
184
- https: options.https,
185
- packageLoader,
186
- packages: packages,
187
- processorConfig: options.processorConfig,
188
- configFile: options.configFile ??
189
- path.join(process.cwd(), "powerhouse.config.json"),
190
- mcp: options.mcp ?? true,
191
- enableDocumentModelSubgraphs: options.enableDocumentModelSubgraphs,
192
- legacyReactor,
193
- });
194
- const { client, driveServer } = api;
195
- // Create default drive if provided
196
- if (options.drive) {
197
- if (!connectCrypto) {
198
- throw new Error("Cannot create default drive without ConnectCrypto identity");
199
- }
200
- defaultDriveUrl = await addDefaultDrive(driveServer, client, options.drive, serverPort);
201
- }
202
- // add vite middleware after express app is initialized if applicable
203
- if (vite) {
204
- api.app.use(vite.middlewares);
205
- }
206
- // Connect to remote drives AFTER packages are loaded
207
- if (remoteDrives.length > 0) {
208
- for (const remoteDriveUrl of remoteDrives) {
209
- let driveId;
210
- try {
211
- if (legacyReactor) {
212
- // Use legacy reactor's addRemoteDrive
213
- const remoteDrive = await addRemoteDrive(driveServer, remoteDriveUrl);
214
- driveId = remoteDrive.header.id;
215
- }
216
- else {
217
- // Use new reactor's sync manager
218
- const { syncManager } = api;
219
- const parsed = parseDriveUrl(remoteDriveUrl);
220
- driveId = parsed.driveId;
221
- const remoteName = `remote-drive-${driveId}-${crypto.randomUUID()}`;
222
- await syncManager.add(remoteName, driveCollectionId("main", driveId), {
223
- type: "gql",
224
- parameters: { url: parsed.graphqlEndpoint },
225
- });
226
- }
227
- logger.debug(`Remote drive ${remoteDriveUrl} synced`);
228
- }
229
- catch (error) {
230
- if (error instanceof DocumentAlreadyExistsError) {
231
- logger.debug(`Remote drive already added: ${remoteDriveUrl}`);
232
- driveId = remoteDriveUrl.split("/").pop();
233
- }
234
- else {
235
- logger.error(`Failed to connect to remote drive ${remoteDriveUrl}:`, error);
236
- }
237
- }
238
- finally {
239
- // Construct local URL once in finally block
240
- if (!defaultDriveUrl && driveId) {
241
- const protocol = options.https ? "https" : "http";
242
- defaultDriveUrl = `${protocol}://localhost:${serverPort}/d/${driveId}`;
243
- }
244
- }
245
- }
246
- }
247
- return {
248
- defaultDriveUrl,
249
- api,
250
- reactor: driveServer,
251
- connectCrypto,
252
- };
253
- }
254
- export const startSwitchboard = async (options = {}) => {
255
- const serverPort = options.port ?? DEFAULT_PORT;
256
- // Initialize feature flags
257
- const featureFlags = await initFeatureFlags();
258
- const enableDocumentModelSubgraphs = await featureFlags.getBooleanValue(DOCUMENT_MODEL_SUBGRAPHS_ENABLED, options.enableDocumentModelSubgraphs ??
259
- DOCUMENT_MODEL_SUBGRAPHS_ENABLED_DEFAULT);
260
- options.enableDocumentModelSubgraphs = enableDocumentModelSubgraphs;
261
- const storageV2 = await featureFlags.getBooleanValue(REACTOR_STORAGE_V2, options.reactorOptions?.storageV2 ?? REACTOR_STORAGE_V2_DEFAULT);
262
- const enableDualActionCreate = await featureFlags.getBooleanValue(ENABLE_DUAL_ACTION_CREATE, options.reactorOptions?.enableDualActionCreate ??
263
- ENABLE_DUAL_ACTION_CREATE_DEFAULT);
264
- options.reactorOptions = {
265
- enableDualActionCreate,
266
- storageV2,
267
- };
268
- logger.info("Feature flags:", {
269
- DOCUMENT_MODEL_SUBGRAPHS_ENABLED: enableDocumentModelSubgraphs,
270
- REACTOR_STORAGE_V2: storageV2,
271
- ENABLE_DUAL_ACTION_CREATE: enableDualActionCreate,
272
- });
273
- if (process.env.PYROSCOPE_SERVER_ADDRESS) {
274
- try {
275
- await initProfilerFromEnv(process.env);
276
- }
277
- catch (e) {
278
- Sentry.captureException(e);
279
- logger.error("Error starting profiler", e);
280
- }
281
- }
282
- // Initialize ConnectCrypto if identity options are provided or keypair exists
283
- let connectCrypto = null;
284
- try {
285
- connectCrypto = await initConnectCrypto(options.identity);
286
- }
287
- catch (e) {
288
- logger.warn("Failed to initialize ConnectCrypto:", e);
289
- if (options.identity?.requireExisting) {
290
- throw new Error('Identity required but failed to initialize. Run "ph login" first.');
291
- }
292
- }
293
- try {
294
- return await initServer(serverPort, options, connectCrypto);
295
- }
296
- catch (e) {
297
- Sentry.captureException(e);
298
- logger.error("App crashed", e);
299
- throw e;
300
- }
301
- };
302
- export { getBearerToken, getConnectCrypto, getConnectDid, } from "./connect-crypto.js";
303
- export * from "./types.js";
304
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EAEjB,QAAQ,EACR,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,GAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAuB,MAAM,aAAa,CAAC;AACvE,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AAEvC,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,cAAc,IAAI,oBAAoB,EACtC,WAAW,EACX,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,gCAAgC,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,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AO,EAAE,aAAa,CAAC,CAAC;IAC9D,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC,CAAC;AAEF,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -1,64 +0,0 @@
1
- import type { IConnectCrypto } from "@renown/sdk";
2
- import type { DriveInput, IDocumentDriveServer } from "document-drive";
3
- export type StorageOptions = {
4
- type: "filesystem" | "memory" | "postgres" | "browser";
5
- filesystemPath?: string;
6
- postgresUrl?: string;
7
- };
8
- export type IdentityOptions = {
9
- /** Path to the keypair file. Defaults to ~/.ph/keypair.json */
10
- keypairPath?: string;
11
- /**
12
- * If true, won't start without an existing keypair.
13
- * Use this to ensure the switchboard only runs with an authenticated identity.
14
- */
15
- requireExisting?: boolean;
16
- };
17
- export type StartServerOptions = {
18
- configFile?: string;
19
- port?: number;
20
- dev?: boolean;
21
- dbPath?: string;
22
- drive?: DriveInput;
23
- packages?: string[];
24
- remoteDrives?: string[];
25
- https?: {
26
- keyPath: string;
27
- certPath: string;
28
- } | boolean | undefined;
29
- auth?: {
30
- enabled: boolean;
31
- guests: string[];
32
- users: string[];
33
- admins: string[];
34
- };
35
- /**
36
- * Identity options for ConnectCrypto.
37
- * When configured, the switchboard will load the keypair from `ph login`
38
- * and can authenticate with remote services on behalf of the user.
39
- */
40
- identity?: IdentityOptions;
41
- mcp?: boolean;
42
- processorConfig?: Map<string, unknown>;
43
- disableLocalPackages?: boolean;
44
- reactorOptions?: {
45
- /**
46
- * When true, both legacy and new reactors will use CREATE/UPDATE operation
47
- * flow for new documents.
48
- */
49
- enableDualActionCreate?: boolean;
50
- /**
51
- * When true, the new Reactor uses only the new Kysely-based storage
52
- * instead of the legacy document-drive storage.
53
- */
54
- storageV2?: boolean;
55
- };
56
- enableDocumentModelSubgraphs?: boolean;
57
- };
58
- export type SwitchboardReactor = {
59
- defaultDriveUrl: string | undefined;
60
- reactor: IDocumentDriveServer;
61
- /** The ConnectCrypto instance if identity was initialized */
62
- connectCrypto: IConnectCrypto | null;
63
- };
64
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EACF;QACE,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,GACD,OAAO,GACP,SAAS,CAAC;IACd,IAAI,CAAC,EAAE;QACL,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,MAAM,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;IACF;;;;OAIG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE;QACf;;;WAGG;QACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;QAEjC;;;WAGG;QACH,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,6DAA6D;IAC7D,aAAa,EAAE,cAAc,GAAG,IAAI,CAAC;CACtC,CAAC"}
package/dist/src/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- import type { IReactorClient } from "@powerhousedao/reactor";
2
- import type { DocumentDriveDocument, DriveInput, IDocumentDriveServer } from "document-drive";
3
- export declare function addDefaultDrive(driveServer: IDocumentDriveServer, client: IReactorClient, drive: DriveInput, serverPort: number): Promise<string>;
4
- export declare function isPostgresUrl(url: string): boolean;
5
- export declare function addRemoteDrive(driveServer: IDocumentDriveServer, remoteDriveUrl: string): Promise<DocumentDriveDocument>;
6
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAEV,qBAAqB,EACrB,UAAU,EACV,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAIxB,wBAAsB,eAAe,CACnC,WAAW,EAAE,oBAAoB,EACjC,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,MAAM,mBAqEnB;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,WAExC;AAED,wBAAsB,cAAc,CAClC,WAAW,EAAE,oBAAoB,EACjC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,qBAAqB,CAAC,CAyBhC"}