@powerhousedao/switchboard 2.4.5-dev.1 → 2.4.5-dev.3
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/CHANGELOG.md +8 -7
- package/dist/src/index.js +2 -81
- package/dist/src/index.js.map +1 -1
- package/dist/src/server.d.ts +5 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +97 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/types.d.ts +22 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +3 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +21 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
## 2.4.5-dev.
|
|
1
|
+
## 2.4.5-dev.3 (2025-05-15)
|
|
2
2
|
|
|
3
|
-
###
|
|
3
|
+
### 🚀 Features
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
- **switchboard:** fallback to memory cache if redis connection fails ([9d06b24de](https://github.com/powerhouse-inc/powerhouse/commit/9d06b24de))
|
|
5
|
+
- removed scalars package ([d6f7059a7](https://github.com/powerhouse-inc/powerhouse/commit/d6f7059a7))
|
|
7
6
|
|
|
8
7
|
### 🧱 Updated Dependencies
|
|
9
8
|
|
|
10
|
-
- Updated document-drive to 1.29.12-dev.
|
|
11
|
-
- Updated
|
|
9
|
+
- Updated document-drive to 1.29.12-dev.8
|
|
10
|
+
- Updated document-model to 2.28.1-dev.15
|
|
11
|
+
- Updated @powerhousedao/reactor-api to 1.29.26-dev.7
|
|
12
|
+
- Updated @powerhousedao/config to 1.27.0-dev.14
|
|
12
13
|
|
|
13
14
|
### ❤️ Thank You
|
|
14
15
|
|
|
15
|
-
-
|
|
16
|
+
- Guillermo Puente @gpuente
|
|
16
17
|
|
|
17
18
|
## 2.3.0 (2025-05-06)
|
|
18
19
|
|
package/dist/src/index.js
CHANGED
|
@@ -1,83 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { InMemoryCache, ReactorBuilder, driveDocumentModelModule, } from "document-drive";
|
|
5
|
-
import RedisCache from "document-drive/cache/redis";
|
|
6
|
-
import { FilesystemStorage } from "document-drive/storage/filesystem";
|
|
7
|
-
import { PrismaStorageFactory } from "document-drive/storage/prisma";
|
|
8
|
-
import { documentModelDocumentModelModule, } from "document-model";
|
|
9
|
-
import dotenv from "dotenv";
|
|
10
|
-
import express from "express";
|
|
11
|
-
import path from "path";
|
|
12
|
-
import { initRedis } from "./clients/redis.js";
|
|
13
|
-
import { initProfilerFromEnv } from "./profiler.js";
|
|
14
|
-
dotenv.config();
|
|
15
|
-
// Create a monolith express app for all subgraphs
|
|
16
|
-
const app = express();
|
|
17
|
-
if (process.env.SENTRY_DSN) {
|
|
18
|
-
console.log("Initialized Sentry with env:", process.env.SENTRY_ENV);
|
|
19
|
-
Sentry.init({
|
|
20
|
-
dsn: process.env.SENTRY_DSN,
|
|
21
|
-
environment: process.env.SENTRY_ENV,
|
|
22
|
-
});
|
|
23
|
-
Sentry.setupExpressErrorHandler(app);
|
|
24
|
-
}
|
|
25
|
-
const serverPort = process.env.PORT ? Number(process.env.PORT) : 4001;
|
|
26
|
-
const main = async () => {
|
|
27
|
-
if (process.env.PYROSCOPE_SERVER_ADDRESS) {
|
|
28
|
-
try {
|
|
29
|
-
await initProfilerFromEnv(process.env);
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
Sentry.captureException(e);
|
|
33
|
-
console.error("Error starting profiler", e);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
const redisUrl = process.env.REDIS_TLS_URL ?? process.env.REDIS_URL;
|
|
38
|
-
let redis;
|
|
39
|
-
if (redisUrl) {
|
|
40
|
-
try {
|
|
41
|
-
redis = await initRedis(redisUrl);
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
console.error(e);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const connectionString = process.env.DATABASE_URL ?? "./.ph/drive-storage";
|
|
48
|
-
const dbUrl = connectionString.includes("amazonaws") &&
|
|
49
|
-
!connectionString.includes("sslmode=no-verify")
|
|
50
|
-
? connectionString + "?sslmode=no-verify"
|
|
51
|
-
: connectionString;
|
|
52
|
-
const cache = redis ? new RedisCache(redis) : new InMemoryCache();
|
|
53
|
-
const storageFactory = dbUrl.startsWith("postgresql")
|
|
54
|
-
? new PrismaStorageFactory(dbUrl, cache)
|
|
55
|
-
: undefined;
|
|
56
|
-
const storage = storageFactory
|
|
57
|
-
? storageFactory.build()
|
|
58
|
-
: new FilesystemStorage(path.join(process.cwd(), dbUrl));
|
|
59
|
-
const reactor = new ReactorBuilder([
|
|
60
|
-
documentModelDocumentModelModule,
|
|
61
|
-
driveDocumentModelModule,
|
|
62
|
-
])
|
|
63
|
-
.withStorage(storage)
|
|
64
|
-
.withCache(cache)
|
|
65
|
-
.build();
|
|
66
|
-
// init drive server
|
|
67
|
-
await reactor.initialize();
|
|
68
|
-
// Start the API with the reactor and options
|
|
69
|
-
await startAPI(reactor, {
|
|
70
|
-
express: app,
|
|
71
|
-
port: serverPort,
|
|
72
|
-
dbPath: dbUrl.startsWith("postgresql") ? dbUrl : ".ph/read-storage",
|
|
73
|
-
configFile: path.join(process.cwd(), "powerhouse.config.json"),
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
Sentry.captureException(e);
|
|
78
|
-
console.error("App crashed", e);
|
|
79
|
-
throw e;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
main().catch(console.error);
|
|
2
|
+
import { startSwitchboard } from "./server.js";
|
|
3
|
+
startSwitchboard().catch(console.error);
|
|
83
4
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,gBAAgB,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type StartServerOptions, type SwitchboardReactor } from "./types.js";
|
|
3
|
+
export declare const startSwitchboard: (options?: StartServerOptions) => Promise<SwitchboardReactor>;
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":";AAqBA,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAoB9E,eAAO,MAAM,gBAAgB,aAClB,kBAAkB,KAC1B,OAAO,CAAC,kBAAkB,CAiF5B,CAAC;AAEF,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { startAPI } from "@powerhousedao/reactor-api";
|
|
3
|
+
import * as Sentry from "@sentry/node";
|
|
4
|
+
import { InMemoryCache, ReactorBuilder, driveDocumentModelModule, } from "document-drive";
|
|
5
|
+
import RedisCache from "document-drive/cache/redis";
|
|
6
|
+
import { FilesystemStorage } from "document-drive/storage/filesystem";
|
|
7
|
+
import { PrismaStorageFactory } from "document-drive/storage/prisma";
|
|
8
|
+
import { documentModelDocumentModelModule, } from "document-model";
|
|
9
|
+
import dotenv from "dotenv";
|
|
10
|
+
import express from "express";
|
|
11
|
+
import path from "path";
|
|
12
|
+
import { initRedis } from "./clients/redis.js";
|
|
13
|
+
import { initProfilerFromEnv } from "./profiler.js";
|
|
14
|
+
import { addDefaultDrive } from "./utils.js";
|
|
15
|
+
dotenv.config();
|
|
16
|
+
// Create a monolith express app for all subgraphs
|
|
17
|
+
const app = express();
|
|
18
|
+
if (process.env.SENTRY_DSN) {
|
|
19
|
+
console.log("Initialized Sentry with env:", process.env.SENTRY_ENV);
|
|
20
|
+
Sentry.init({
|
|
21
|
+
dsn: process.env.SENTRY_DSN,
|
|
22
|
+
environment: process.env.SENTRY_ENV,
|
|
23
|
+
});
|
|
24
|
+
Sentry.setupExpressErrorHandler(app);
|
|
25
|
+
}
|
|
26
|
+
const DEFAULT_PORT = process.env.PORT ? Number(process.env.PORT) : 4001;
|
|
27
|
+
export const startSwitchboard = async (options = {}) => {
|
|
28
|
+
const serverPort = options.port ?? DEFAULT_PORT;
|
|
29
|
+
if (process.env.PYROSCOPE_SERVER_ADDRESS) {
|
|
30
|
+
try {
|
|
31
|
+
await initProfilerFromEnv(process.env);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
Sentry.captureException(e);
|
|
35
|
+
console.error("Error starting profiler", e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const redisUrl = process.env.REDIS_TLS_URL ?? process.env.REDIS_URL;
|
|
40
|
+
let redis;
|
|
41
|
+
if (redisUrl) {
|
|
42
|
+
try {
|
|
43
|
+
redis = await initRedis(redisUrl);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
console.error(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const connectionString = process.env.DATABASE_URL ?? "./.ph/drive-storage";
|
|
50
|
+
const dbUrl = connectionString.includes("amazonaws") &&
|
|
51
|
+
!connectionString.includes("sslmode=no-verify")
|
|
52
|
+
? connectionString + "?sslmode=no-verify"
|
|
53
|
+
: connectionString;
|
|
54
|
+
const cache = redis ? new RedisCache(redis) : new InMemoryCache();
|
|
55
|
+
const storageFactory = dbUrl.startsWith("postgresql")
|
|
56
|
+
? new PrismaStorageFactory(dbUrl, cache)
|
|
57
|
+
: undefined;
|
|
58
|
+
const storage = storageFactory
|
|
59
|
+
? storageFactory.build()
|
|
60
|
+
: new FilesystemStorage(path.join(process.cwd(), dbUrl));
|
|
61
|
+
const reactor = new ReactorBuilder([
|
|
62
|
+
documentModelDocumentModelModule,
|
|
63
|
+
driveDocumentModelModule,
|
|
64
|
+
])
|
|
65
|
+
.withStorage(storage)
|
|
66
|
+
.withCache(cache)
|
|
67
|
+
.build();
|
|
68
|
+
// init drive server
|
|
69
|
+
await reactor.initialize();
|
|
70
|
+
const dbPath = dbUrl.startsWith("postgresql") ? dbUrl : ".ph/read-storage";
|
|
71
|
+
let defaultDriveUrl = undefined;
|
|
72
|
+
if (options.drive) {
|
|
73
|
+
defaultDriveUrl = await addDefaultDrive(reactor, options.drive, serverPort);
|
|
74
|
+
}
|
|
75
|
+
// Start the API with the reactor and options
|
|
76
|
+
await startAPI(reactor, {
|
|
77
|
+
express: app,
|
|
78
|
+
port: serverPort,
|
|
79
|
+
dbPath: options.dbPath ?? dbPath,
|
|
80
|
+
https: options.https,
|
|
81
|
+
packages: options.packages,
|
|
82
|
+
configFile: options.configFile ??
|
|
83
|
+
path.join(process.cwd(), "powerhouse.config.json"),
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
defaultDriveUrl,
|
|
87
|
+
reactor,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
Sentry.captureException(e);
|
|
92
|
+
console.error("App crashed", e);
|
|
93
|
+
throw e;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
export * from "./types.js";
|
|
97
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","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,CAAC;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAC3B,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QAChC,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC,CAAC;AAEF,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type DriveInput, type IDocumentDriveServer } from "document-drive";
|
|
2
|
+
export type StorageOptions = {
|
|
3
|
+
type: "filesystem" | "memory" | "postgres" | "browser";
|
|
4
|
+
filesystemPath?: string;
|
|
5
|
+
postgresUrl?: string;
|
|
6
|
+
};
|
|
7
|
+
export type StartServerOptions = {
|
|
8
|
+
configFile?: string;
|
|
9
|
+
port?: number;
|
|
10
|
+
dbPath?: string;
|
|
11
|
+
drive?: DriveInput;
|
|
12
|
+
packages?: string[];
|
|
13
|
+
https?: {
|
|
14
|
+
keyPath: string;
|
|
15
|
+
certPath: string;
|
|
16
|
+
} | boolean | undefined;
|
|
17
|
+
};
|
|
18
|
+
export type SwitchboardReactor = {
|
|
19
|
+
defaultDriveUrl: string | undefined;
|
|
20
|
+
reactor: IDocumentDriveServer;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE5E,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,kBAAkB,GAAG;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EACF;QACE,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,GACD,OAAO,GACP,SAAS,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,oBAAoB,CAAC;CAC/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AAExB,wBAAsB,eAAe,CACnC,WAAW,EAAE,oBAAoB,EACjC,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,MAAM,mBAqBnB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DocumentAlreadyExistsError, } from "document-drive";
|
|
2
|
+
export async function addDefaultDrive(driveServer, drive, serverPort) {
|
|
3
|
+
let driveId = drive.id;
|
|
4
|
+
if (!driveId || driveId.length === 0) {
|
|
5
|
+
driveId = drive.slug;
|
|
6
|
+
}
|
|
7
|
+
if (!driveId || driveId.length === 0) {
|
|
8
|
+
throw new Error("Invalid Drive Id");
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
// add default drive
|
|
12
|
+
await driveServer.addDrive(drive);
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
if (!(e instanceof DocumentAlreadyExistsError)) {
|
|
16
|
+
throw e;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return `http://localhost:${serverPort}/d/${driveId}`;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,GAG3B,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,WAAiC,EACjC,KAAiB,EACjB,UAAkB;IAElB,IAAI,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC;IACvB,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,CAAC;QACH,oBAAoB;QACpB,MAAM,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,CAAC,CAAC,YAAY,0BAA0B,CAAC,EAAE,CAAC;YAC/C,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IAED,OAAO,oBAAoB,UAAU,MAAM,OAAO,EAAE,CAAC;AACvD,CAAC"}
|