@powerhousedao/switchboard 2.4.5-dev.0 → 2.4.5-dev.2
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 +29 -6
- package/Dockerfile +2 -2
- package/dist/src/clients/redis.d.ts +3 -3
- package/dist/src/clients/redis.d.ts.map +1 -1
- package/dist/src/clients/redis.js +19 -8
- package/dist/src/clients/redis.js.map +1 -1
- package/dist/src/index.js +2 -76
- 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,41 @@
|
|
|
1
|
-
## 2.4.5-dev.
|
|
1
|
+
## 2.4.5-dev.2 (2025-05-15)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- enabled switchboard command ([5a9c467bf](https://github.com/powerhouse-inc/powerhouse/commit/5a9c467bf))
|
|
6
|
+
- removed scalars dependencies ([596aedbd5](https://github.com/powerhouse-inc/powerhouse/commit/596aedbd5))
|
|
7
|
+
- **builder-tools:** handle recursive objects in initial state generator ([c9eedcc43](https://github.com/powerhouse-inc/powerhouse/commit/c9eedcc43))
|
|
8
|
+
- **monorepo:** bump graphql lib ([ba9d5d338](https://github.com/powerhouse-inc/powerhouse/commit/ba9d5d338))
|
|
9
|
+
- **monorepo:** handle updating monorepo build deps ([db2ac2316](https://github.com/powerhouse-inc/powerhouse/commit/db2ac2316))
|
|
10
|
+
- **monorepo:** regenerate lockfile ([a6c390b4e](https://github.com/powerhouse-inc/powerhouse/commit/a6c390b4e))
|
|
11
|
+
- **builder-tools:** fix wrong value used for field id ([a6c6142e0](https://github.com/powerhouse-inc/powerhouse/commit/a6c6142e0))
|
|
12
|
+
- **reactor-api,reactor-local:** updated analytics dependencies ([cbeace573](https://github.com/powerhouse-inc/powerhouse/commit/cbeace573))
|
|
13
|
+
- **reactor-api,reactor-local,switchboard:** wait initial timeout before start listening to requests ([409f1e316](https://github.com/powerhouse-inc/powerhouse/commit/409f1e316))
|
|
14
|
+
- added sky-atlas-staging ([ac1658ce9](https://github.com/powerhouse-inc/powerhouse/commit/ac1658ce9))
|
|
2
15
|
|
|
3
16
|
### 🩹 Fixes
|
|
4
17
|
|
|
5
|
-
- **document-drive
|
|
18
|
+
- **document-drive:** fix type issue on browser storage ([240a78b41](https://github.com/powerhouse-inc/powerhouse/commit/240a78b41))
|
|
19
|
+
- **ph-cli:** ph add does not remove installed packages ([aedfbf56e](https://github.com/powerhouse-inc/powerhouse/commit/aedfbf56e))
|
|
20
|
+
- remove .env and add to .gitignore ([0d2d48684](https://github.com/powerhouse-inc/powerhouse/commit/0d2d48684))
|
|
21
|
+
- **switchboard,reactor-local:** latest version of sky atlas was not being installed ([72bf72fd4](https://github.com/powerhouse-inc/powerhouse/commit/72bf72fd4))
|
|
22
|
+
- made ph packages env var ([df93611b7](https://github.com/powerhouse-inc/powerhouse/commit/df93611b7))
|
|
23
|
+
- remove filter ([842a93a75](https://github.com/powerhouse-inc/powerhouse/commit/842a93a75))
|
|
6
24
|
|
|
7
25
|
### 🧱 Updated Dependencies
|
|
8
26
|
|
|
9
|
-
- Updated document-drive to 1.29.12-dev.
|
|
10
|
-
- Updated document-model to 2.28.1-dev.
|
|
11
|
-
- Updated @powerhousedao/reactor-api to 1.29.26-dev.
|
|
27
|
+
- Updated document-drive to 1.29.12-dev.7
|
|
28
|
+
- Updated document-model to 2.28.1-dev.14
|
|
29
|
+
- Updated @powerhousedao/reactor-api to 1.29.26-dev.6
|
|
30
|
+
- Updated @powerhousedao/config to 1.27.0-dev.13
|
|
12
31
|
|
|
13
32
|
### ❤️ Thank You
|
|
14
33
|
|
|
15
|
-
- acaldas
|
|
34
|
+
- acaldas
|
|
35
|
+
- Benjamin Jordan
|
|
36
|
+
- Frank
|
|
37
|
+
- Guillermo Puente
|
|
38
|
+
- ryanwolhuter
|
|
16
39
|
|
|
17
40
|
## 2.3.0 (2025-05-06)
|
|
18
41
|
|
package/Dockerfile
CHANGED
|
@@ -22,7 +22,7 @@ FROM node:22-alpine AS build
|
|
|
22
22
|
RUN apk update && apk add git
|
|
23
23
|
WORKDIR /app
|
|
24
24
|
RUN [ ! -e /lib/libssl.so.3 ] && ln -s /usr/lib/libssl.so.3 /lib/libssl.so.3 || echo "Link already exists"
|
|
25
|
-
RUN npm install --global pnpm@
|
|
25
|
+
RUN npm install --global pnpm@10 husky
|
|
26
26
|
COPY . .
|
|
27
27
|
ARG PH_PACKAGES
|
|
28
28
|
ENV PH_PACKAGES=${PH_PACKAGES}
|
|
@@ -31,7 +31,7 @@ ENV NX_SOCKET_DIR=${NX_SOCKET_DIR}
|
|
|
31
31
|
ENV NX_DAEMON=false
|
|
32
32
|
RUN pnpm install --filter @powerhousedao/switchboard...
|
|
33
33
|
RUN pnpm nx run @powerhousedao/switchboard:build
|
|
34
|
-
RUN pnpm --filter "@powerhousedao/switchboard" deploy --prod pruned
|
|
34
|
+
RUN pnpm --filter "@powerhousedao/switchboard" deploy --prod pruned --legacy
|
|
35
35
|
RUN rm -rf pruned/node_modules/.pnpm/@prisma+client@5.17.0_prisma@5.17.0 && cp -R ./node_modules/.pnpm/@prisma+client@5.17.0_prisma@5.17.0 pruned/node_modules/.pnpm
|
|
36
36
|
|
|
37
37
|
# Final production image
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RedisClientType } from "redis";
|
|
2
|
-
export declare let redisClient: RedisClientType;
|
|
3
|
-
export declare const initRedis: (url: string) => Promise<RedisClientType>;
|
|
4
|
-
export declare const closeRedis: () => void;
|
|
2
|
+
export declare let redisClient: RedisClientType | undefined;
|
|
3
|
+
export declare const initRedis: (url: string) => Promise<RedisClientType | undefined>;
|
|
4
|
+
export declare const closeRedis: () => Promise<void> | undefined;
|
|
5
5
|
//# sourceMappingURL=redis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../../src/clients/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,OAAO,CAAC;AAE3D,eAAO,IAAI,WAAW,EAAE,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../../src/clients/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,OAAO,CAAC;AAE3D,eAAO,IAAI,WAAW,EAAE,eAAe,GAAG,SAAS,CAAC;AACpD,eAAO,MAAM,SAAS,QACf,MAAM,KACV,OAAO,CAAC,eAAe,GAAG,SAAS,CAiCrC,CAAC;AAeF,eAAO,MAAM,UAAU,iCAItB,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createClient } from "redis";
|
|
2
2
|
export let redisClient;
|
|
3
3
|
export const initRedis = async (url) => {
|
|
4
|
-
if (
|
|
4
|
+
if (redisClient) {
|
|
5
|
+
return redisClient;
|
|
6
|
+
}
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
5
8
|
const socket = url.includes("rediss")
|
|
6
9
|
? {
|
|
7
10
|
tls: true,
|
|
@@ -12,13 +15,21 @@ export const initRedis = async (url) => {
|
|
|
12
15
|
url,
|
|
13
16
|
socket,
|
|
14
17
|
});
|
|
15
|
-
redisClient
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
redisClient
|
|
19
|
+
.connect()
|
|
20
|
+
.then((client) => {
|
|
21
|
+
redisClient = client;
|
|
22
|
+
client.on("error", (err) => {
|
|
23
|
+
console.warn("Redis Client Error", err);
|
|
24
|
+
});
|
|
25
|
+
resolve(client);
|
|
26
|
+
})
|
|
27
|
+
.catch(async (e) => {
|
|
28
|
+
reject(e instanceof Error ? e : new Error(JSON.stringify(e)));
|
|
29
|
+
// await redisClient.disconnect();
|
|
30
|
+
// console.warn("Redis Client Error", e);
|
|
18
31
|
});
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
return redisClient;
|
|
32
|
+
});
|
|
22
33
|
};
|
|
23
34
|
const timer = setInterval(async () => {
|
|
24
35
|
try {
|
|
@@ -32,6 +43,6 @@ const timer = setInterval(async () => {
|
|
|
32
43
|
}, 1000 * 60 * 4);
|
|
33
44
|
export const closeRedis = () => {
|
|
34
45
|
clearInterval(timer);
|
|
35
|
-
redisClient
|
|
46
|
+
return redisClient?.disconnect();
|
|
36
47
|
};
|
|
37
48
|
//# sourceMappingURL=redis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../../src/clients/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,OAAO,CAAC;AAE3D,MAAM,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../../src/clients/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,OAAO,CAAC;AAE3D,MAAM,CAAC,IAAI,WAAwC,CAAC;AACpD,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,GAAW,EAC2B,EAAE;IACxC,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACnC,CAAC,CAAC;gBACE,GAAG,EAAE,IAAI;gBACT,kBAAk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,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
|
-
redis = await initRedis(redisUrl);
|
|
41
|
-
}
|
|
42
|
-
const connectionString = process.env.DATABASE_URL ?? "./.ph/drive-storage";
|
|
43
|
-
const dbUrl = connectionString.includes("amazonaws") &&
|
|
44
|
-
!connectionString.includes("sslmode=no-verify")
|
|
45
|
-
? connectionString + "?sslmode=no-verify"
|
|
46
|
-
: connectionString;
|
|
47
|
-
const cache = redis ? new RedisCache(redis) : new InMemoryCache();
|
|
48
|
-
const storageFactory = dbUrl.startsWith("postgresql")
|
|
49
|
-
? new PrismaStorageFactory(dbUrl, cache)
|
|
50
|
-
: undefined;
|
|
51
|
-
const storage = storageFactory
|
|
52
|
-
? storageFactory.build()
|
|
53
|
-
: new FilesystemStorage(path.join(process.cwd(), dbUrl));
|
|
54
|
-
const reactor = new ReactorBuilder([
|
|
55
|
-
documentModelDocumentModelModule,
|
|
56
|
-
driveDocumentModelModule,
|
|
57
|
-
])
|
|
58
|
-
.withStorage(storage)
|
|
59
|
-
.withCache(cache)
|
|
60
|
-
.build();
|
|
61
|
-
// init drive server
|
|
62
|
-
await reactor.initialize();
|
|
63
|
-
// Start the API with the reactor and options
|
|
64
|
-
await startAPI(reactor, {
|
|
65
|
-
express: app,
|
|
66
|
-
port: serverPort,
|
|
67
|
-
dbPath: dbUrl.startsWith("postgresql") ? dbUrl : "./.ph/read-storage",
|
|
68
|
-
configFile: path.join(process.cwd(), "powerhouse.config.json"),
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
catch (e) {
|
|
72
|
-
Sentry.captureException(e);
|
|
73
|
-
console.error("App crashed", e);
|
|
74
|
-
throw e;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
main().catch(console.error);
|
|
2
|
+
import { startSwitchboard } from "./server.js";
|
|
3
|
+
startSwitchboard().catch(console.error);
|
|
78
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":"","sources":["../../src/server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,aAAa,EACb,cAAc,EACd,wBAAwB,GACzB,MAAM,gBA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ACV,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"}
|