@powerhousedao/reactor-local 1.6.1 → 1.8.0
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 +19 -2
- package/dist/{chunk-JEZMQ4ZA.js → chunk-WZM6GQ5Q.js} +14 -22
- package/dist/cli.js +1 -1
- package/dist/index.js +2 -2
- package/dist/server.d.ts +3 -1
- package/dist/server.js +1 -1
- package/package.json +12 -20
- package/src/server.ts +26 -35
- package/dist/indexer.d.ts +0 -9
- package/dist/indexer.js +0 -24
- package/drizzle.config.ts +0 -11
- package/src/indexer.ts +0 -38
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
## 1.
|
|
1
|
+
## 1.8.0 (2024-12-05)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- merge dspot-scalars into main ([5ca898fc](https://github.com/powerhouse-inc/powerhouse/commit/5ca898fc))
|
|
6
|
+
|
|
7
|
+
### 🩹 Fixes
|
|
8
|
+
|
|
9
|
+
- **switchboard-gui:** restore prev vite version ([#614](https://github.com/powerhouse-inc/powerhouse/pull/614))
|
|
2
10
|
|
|
3
11
|
### 🧱 Updated Dependencies
|
|
4
12
|
|
|
5
|
-
- Updated @powerhousedao/
|
|
13
|
+
- Updated @powerhousedao/general-document-indexer to 1.6.0
|
|
14
|
+
- Updated document-model-libs to 1.118.0
|
|
15
|
+
- Updated document-drive to 1.7.0
|
|
16
|
+
- Updated document-model to 2.9.0
|
|
17
|
+
- Updated @powerhousedao/reactor-api to 1.8.0
|
|
18
|
+
- Updated @powerhousedao/scalars to 1.11.0
|
|
19
|
+
|
|
20
|
+
### ❤️ Thank You
|
|
21
|
+
|
|
22
|
+
- Guillermo Puente Sandoval @gpuente
|
|
6
23
|
|
|
7
24
|
## 1.1.0 (2024-10-29)
|
|
8
25
|
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import dotenv from 'dotenv';
|
|
4
|
-
import { createServer } from 'vite';
|
|
5
|
-
import { startAPI, addSubgraph, createSchema, registerInternalListener } from '@powerhousedao/reactor-api';
|
|
1
|
+
import { PGlite } from '@electric-sql/pglite';
|
|
2
|
+
import { startAPI } from '@powerhousedao/reactor-api';
|
|
6
3
|
import * as DocumentDrive from 'document-model-libs/document-drive';
|
|
7
4
|
import { isFileNode, utils as utils$1, actions, documentModel } from 'document-model-libs/document-drive';
|
|
8
5
|
import { utils } from 'document-model/document';
|
|
@@ -18,6 +15,10 @@ import path from 'path';
|
|
|
18
15
|
import sanitize from 'sanitize-filename';
|
|
19
16
|
import * as DocumentModelsLibs from 'document-model-libs/document-models';
|
|
20
17
|
import { module } from 'document-model/document-model';
|
|
18
|
+
import dotenv from 'dotenv';
|
|
19
|
+
import path2 from 'node:path';
|
|
20
|
+
import { fileURLToPath } from 'node:url';
|
|
21
|
+
import { createServer } from 'vite';
|
|
21
22
|
|
|
22
23
|
// src/server.ts
|
|
23
24
|
|
|
@@ -3884,6 +3885,7 @@ dotenv.config();
|
|
|
3884
3885
|
var DefaultStartServerOptions = {
|
|
3885
3886
|
port: 4001,
|
|
3886
3887
|
storagePath: path2.join(dirname, "./file-storage"),
|
|
3888
|
+
dbPath: path2.join(dirname, "./dev.db"),
|
|
3887
3889
|
drive: {
|
|
3888
3890
|
global: {
|
|
3889
3891
|
id: "powerhouse",
|
|
@@ -3931,8 +3933,10 @@ var startServer = async (options) => {
|
|
|
3931
3933
|
}
|
|
3932
3934
|
}
|
|
3933
3935
|
try {
|
|
3934
|
-
const
|
|
3935
|
-
|
|
3936
|
+
const client = new PGlite(options?.dbPath ?? process.cwd() + "/dev.db");
|
|
3937
|
+
const { app, reactorRouterManager } = await startAPI(driveServer, {
|
|
3938
|
+
port: serverPort,
|
|
3939
|
+
client
|
|
3936
3940
|
});
|
|
3937
3941
|
driveUrl = `http://localhost:${serverPort}/${driveId ? `d/${drive.global.slug ?? drive.global.id}` : ""}`;
|
|
3938
3942
|
console.log(` \u279C Reactor: ${driveUrl}`);
|
|
@@ -3960,21 +3964,9 @@ var startServer = async (options) => {
|
|
|
3960
3964
|
processorsPath
|
|
3961
3965
|
);
|
|
3962
3966
|
for (const [name, processor] of Object.entries(localProcessors)) {
|
|
3963
|
-
await
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
getSchema: (driveServer2) => createSchema(
|
|
3967
|
-
driveServer2,
|
|
3968
|
-
processor.resolvers,
|
|
3969
|
-
processor.typeDefs
|
|
3970
|
-
)
|
|
3971
|
-
}),
|
|
3972
|
-
registerInternalListener({
|
|
3973
|
-
name,
|
|
3974
|
-
options: processor.options,
|
|
3975
|
-
transmit: processor.transmit
|
|
3976
|
-
})
|
|
3977
|
-
]);
|
|
3967
|
+
await reactorRouterManager.registerProcessor({
|
|
3968
|
+
...processor
|
|
3969
|
+
});
|
|
3978
3970
|
}
|
|
3979
3971
|
}
|
|
3980
3972
|
} catch (e) {
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { startServer } from './chunk-
|
|
2
|
-
export { DefaultStartServerOptions, startServer } from './chunk-
|
|
1
|
+
import { startServer } from './chunk-WZM6GQ5Q.js';
|
|
2
|
+
export { DefaultStartServerOptions, startServer } from './chunk-WZM6GQ5Q.js';
|
|
3
3
|
|
|
4
4
|
// src/index.ts
|
|
5
5
|
startServer().catch((error) => {
|
package/dist/server.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ declare class InternalTransmitter implements ITransmitter {
|
|
|
37
37
|
private listener;
|
|
38
38
|
private receiver;
|
|
39
39
|
constructor(listener: Listener, drive: IBaseDocumentDriveServer);
|
|
40
|
-
transmit(strands:
|
|
40
|
+
transmit(strands: InternalTransmitterUpdate[]): Promise<ListenerRevision[]>;
|
|
41
41
|
setReceiver(receiver: IReceiver): void;
|
|
42
42
|
disconnect(): Promise<void>;
|
|
43
43
|
}
|
|
@@ -235,11 +235,13 @@ type StartServerOptions = {
|
|
|
235
235
|
dev?: boolean;
|
|
236
236
|
port?: string | number;
|
|
237
237
|
storagePath?: string;
|
|
238
|
+
dbPath?: string;
|
|
238
239
|
drive?: DriveInput;
|
|
239
240
|
};
|
|
240
241
|
declare const DefaultStartServerOptions: {
|
|
241
242
|
port: number;
|
|
242
243
|
storagePath: string;
|
|
244
|
+
dbPath: string;
|
|
243
245
|
drive: {
|
|
244
246
|
global: {
|
|
245
247
|
id: string;
|
package/dist/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DefaultStartServerOptions, startServer } from './chunk-
|
|
1
|
+
export { DefaultStartServerOptions, startServer } from './chunk-WZM6GQ5Q.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/reactor-local",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"main": "dist/server.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"reactor-local": "dist/cli.js"
|
|
@@ -19,24 +19,21 @@
|
|
|
19
19
|
"change-case": "^5.4.4",
|
|
20
20
|
"commander": "^12.1.0",
|
|
21
21
|
"dotenv": "^16.4.5",
|
|
22
|
-
"drizzle-kit": "^0.25.0",
|
|
23
|
-
"drizzle-orm": "^0.34.1",
|
|
24
22
|
"express": "^4.21.0",
|
|
25
23
|
"graphql": "^16.8.1",
|
|
26
24
|
"graphql-request": "^6.1.0",
|
|
27
25
|
"json-stringify-deterministic": "^1.0.12",
|
|
28
26
|
"ms": "^2.1.3",
|
|
29
27
|
"nanoevents": "^9.0.0",
|
|
30
|
-
"pg": "^8.13.0",
|
|
31
28
|
"sanitize-filename": "^1.6.3",
|
|
32
29
|
"uuid": "^11.0.2",
|
|
33
|
-
"vite": "^
|
|
34
|
-
"vite-node": "^2.1.
|
|
35
|
-
"@powerhousedao/general-document-indexer": "1.
|
|
36
|
-
"@powerhousedao/
|
|
37
|
-
"
|
|
38
|
-
"document-model
|
|
39
|
-
"
|
|
30
|
+
"vite": "^6.0.2",
|
|
31
|
+
"vite-node": "^2.1.7",
|
|
32
|
+
"@powerhousedao/general-document-indexer": "1.6.0",
|
|
33
|
+
"@powerhousedao/reactor-api": "1.8.0",
|
|
34
|
+
"@powerhousedao/scalars": "1.11.0",
|
|
35
|
+
"document-model": "2.9.0",
|
|
36
|
+
"document-model-libs": "1.118.0"
|
|
40
37
|
},
|
|
41
38
|
"devDependencies": {
|
|
42
39
|
"@types/body-parser": "^1.19.5",
|
|
@@ -44,22 +41,17 @@
|
|
|
44
41
|
"@types/express": "^5.0.0",
|
|
45
42
|
"@types/ms": "^0.7.34",
|
|
46
43
|
"@types/node": "^22.7.5",
|
|
47
|
-
"@types/pg": "^8.11.10",
|
|
48
44
|
"postcss": "^8.4.47",
|
|
49
|
-
"tsup": "^8.3.
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"document-drive": "1.5.0"
|
|
45
|
+
"tsup": "^8.3.5",
|
|
46
|
+
"@powerhousedao/scalars": "1.11.0",
|
|
47
|
+
"document-drive": "1.7.0"
|
|
53
48
|
},
|
|
54
49
|
"peerDependencies": {
|
|
55
|
-
"@powerhousedao/scalars": "1.
|
|
50
|
+
"@powerhousedao/scalars": "1.11.0"
|
|
56
51
|
},
|
|
57
52
|
"scripts": {
|
|
58
53
|
"start": "vite-node src/index.ts",
|
|
59
54
|
"build": "tsup",
|
|
60
|
-
"db:migrate": "drizzle-kit migrate",
|
|
61
|
-
"db:studio": "drizzle-kit studio",
|
|
62
|
-
"db:generate": "drizzle-kit generate",
|
|
63
55
|
"prestart": "pnpm db:migrate"
|
|
64
56
|
}
|
|
65
57
|
}
|
package/src/server.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import dotenv from "dotenv";
|
|
4
|
-
import { createServer as createViteServer } from "vite";
|
|
5
|
-
import {
|
|
6
|
-
startAPI,
|
|
7
|
-
addSubgraph,
|
|
8
|
-
registerInternalListener,
|
|
9
|
-
createSchema,
|
|
10
|
-
} from "@powerhousedao/reactor-api";
|
|
1
|
+
import { PGlite } from "@electric-sql/pglite";
|
|
2
|
+
import { startAPI } from "@powerhousedao/reactor-api";
|
|
11
3
|
import {
|
|
12
4
|
DocumentDriveServer,
|
|
13
5
|
DriveAlreadyExistsError,
|
|
@@ -16,10 +8,17 @@ import {
|
|
|
16
8
|
IReceiver,
|
|
17
9
|
} from "document-drive";
|
|
18
10
|
import { FilesystemStorage } from "document-drive/storage/filesystem";
|
|
11
|
+
import {
|
|
12
|
+
DocumentDriveDocument,
|
|
13
|
+
ListenerFilter,
|
|
14
|
+
} from "document-model-libs/document-drive";
|
|
19
15
|
import * as DocumentModelsLibs from "document-model-libs/document-models";
|
|
20
16
|
import { DocumentModel } from "document-model/document";
|
|
21
17
|
import { module as DocumentModelLib } from "document-model/document-model";
|
|
22
|
-
import
|
|
18
|
+
import dotenv from "dotenv";
|
|
19
|
+
import path from "node:path";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
import { createServer as createViteServer } from "vite";
|
|
23
22
|
|
|
24
23
|
const dirname =
|
|
25
24
|
import.meta.dirname || path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -30,12 +29,14 @@ export type StartServerOptions = {
|
|
|
30
29
|
dev?: boolean;
|
|
31
30
|
port?: string | number;
|
|
32
31
|
storagePath?: string;
|
|
32
|
+
dbPath?: string;
|
|
33
33
|
drive?: DriveInput;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export const DefaultStartServerOptions = {
|
|
37
37
|
port: 4001,
|
|
38
38
|
storagePath: path.join(dirname, "./file-storage"),
|
|
39
|
+
dbPath: path.join(dirname, "./dev.db"),
|
|
39
40
|
drive: {
|
|
40
41
|
global: {
|
|
41
42
|
id: "powerhouse",
|
|
@@ -63,7 +64,7 @@ export type LocalReactor = {
|
|
|
63
64
|
label: string;
|
|
64
65
|
block: boolean;
|
|
65
66
|
filter: ListenerFilter;
|
|
66
|
-
}
|
|
67
|
+
},
|
|
67
68
|
) => Promise<InternalTransmitter>;
|
|
68
69
|
};
|
|
69
70
|
|
|
@@ -73,7 +74,7 @@ const baseDocumentModels = [
|
|
|
73
74
|
] as DocumentModel[];
|
|
74
75
|
|
|
75
76
|
const startServer = async (
|
|
76
|
-
options?: StartServerOptions
|
|
77
|
+
options?: StartServerOptions,
|
|
77
78
|
): Promise<LocalReactor> => {
|
|
78
79
|
const { port, storagePath, drive, dev } = {
|
|
79
80
|
...DefaultStartServerOptions,
|
|
@@ -84,7 +85,7 @@ const startServer = async (
|
|
|
84
85
|
// start document drive server with all available document models & filesystem storage
|
|
85
86
|
const driveServer = new DocumentDriveServer(
|
|
86
87
|
baseDocumentModels,
|
|
87
|
-
new FilesystemStorage(storagePath)
|
|
88
|
+
new FilesystemStorage(storagePath),
|
|
88
89
|
);
|
|
89
90
|
|
|
90
91
|
// init drive server
|
|
@@ -100,9 +101,9 @@ const startServer = async (
|
|
|
100
101
|
if (e instanceof DriveAlreadyExistsError) {
|
|
101
102
|
console.info("Default drive already exists. Skipping...");
|
|
102
103
|
if (driveId) {
|
|
103
|
-
const driveDoc = await (drive.global.slug
|
|
104
|
+
const driveDoc = (await (drive.global.slug
|
|
104
105
|
? driveServer.getDriveBySlug(drive.global.slug)
|
|
105
|
-
: driveServer.getDrive(driveId));
|
|
106
|
+
: driveServer.getDrive(driveId))) as DocumentDriveDocument;
|
|
106
107
|
driveId = driveDoc.state.global.slug ?? driveDoc.state.global.id;
|
|
107
108
|
}
|
|
108
109
|
} else {
|
|
@@ -112,8 +113,11 @@ const startServer = async (
|
|
|
112
113
|
|
|
113
114
|
try {
|
|
114
115
|
// start api
|
|
115
|
-
const
|
|
116
|
+
const client = new PGlite(options?.dbPath ?? process.cwd() + "/dev.db");
|
|
117
|
+
|
|
118
|
+
const { app, reactorRouterManager } = await startAPI(driveServer, {
|
|
116
119
|
port: serverPort,
|
|
120
|
+
client,
|
|
117
121
|
});
|
|
118
122
|
driveUrl = `http://localhost:${serverPort}/${driveId ? `d/${drive.global.slug ?? drive.global.id}` : ""}`;
|
|
119
123
|
console.log(` ➜ Reactor: ${driveUrl}`);
|
|
@@ -145,26 +149,13 @@ const startServer = async (
|
|
|
145
149
|
const processorsPath = path.join(process.cwd(), "./processors");
|
|
146
150
|
console.log("Loading processors from", processorsPath);
|
|
147
151
|
const localProcessors = (await vite.ssrLoadModule(
|
|
148
|
-
processorsPath
|
|
152
|
+
processorsPath,
|
|
149
153
|
)) as Record<string, any>;
|
|
150
154
|
|
|
151
155
|
for (const [name, processor] of Object.entries(localProcessors)) {
|
|
152
|
-
await
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
getSchema: (driveServer) =>
|
|
156
|
-
createSchema(
|
|
157
|
-
driveServer,
|
|
158
|
-
processor.resolvers,
|
|
159
|
-
processor.typeDefs
|
|
160
|
-
),
|
|
161
|
-
}),
|
|
162
|
-
registerInternalListener({
|
|
163
|
-
name,
|
|
164
|
-
options: processor.options,
|
|
165
|
-
transmit: processor.transmit,
|
|
166
|
-
}),
|
|
167
|
-
]);
|
|
156
|
+
await reactorRouterManager.registerProcessor({
|
|
157
|
+
...processor,
|
|
158
|
+
});
|
|
168
159
|
}
|
|
169
160
|
}
|
|
170
161
|
} catch (e) {
|
|
@@ -184,7 +175,7 @@ const startServer = async (
|
|
|
184
175
|
label: string;
|
|
185
176
|
block: boolean;
|
|
186
177
|
filter: ListenerFilter;
|
|
187
|
-
}
|
|
178
|
+
},
|
|
188
179
|
) => driveServer.addInternalListener(driveId, receiver, options),
|
|
189
180
|
};
|
|
190
181
|
};
|
package/dist/indexer.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IDocumentDriveServer } from 'document-drive/server';
|
|
2
|
-
|
|
3
|
-
type DocumentIndexerOptions = {
|
|
4
|
-
reactor: IDocumentDriveServer;
|
|
5
|
-
path: string;
|
|
6
|
-
};
|
|
7
|
-
declare function addDocumentIndexer(options: DocumentIndexerOptions): Promise<void>;
|
|
8
|
-
|
|
9
|
-
export { type DocumentIndexerOptions, addDocumentIndexer };
|
package/dist/indexer.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { drizzle } from 'drizzle-orm/connect';
|
|
2
|
-
import { setAdditionalContextFields, registerInternalListener, addSubgraph, createSchema } from '@powerhousedao/reactor-api';
|
|
3
|
-
import * as searchListener from '@powerhousedao/general-document-indexer';
|
|
4
|
-
|
|
5
|
-
// src/indexer.ts
|
|
6
|
-
async function addDocumentIndexer(options2) {
|
|
7
|
-
const db = await drizzle("pglite", options2.path);
|
|
8
|
-
setAdditionalContextFields({ db });
|
|
9
|
-
await registerInternalListener({
|
|
10
|
-
name: "search",
|
|
11
|
-
options: searchListener.options,
|
|
12
|
-
transmit: (strands) => searchListener.transmit(strands, db)
|
|
13
|
-
});
|
|
14
|
-
await addSubgraph({
|
|
15
|
-
getSchema: () => createSchema(
|
|
16
|
-
options2.reactor,
|
|
17
|
-
searchListener.resolvers,
|
|
18
|
-
searchListener.typeDefs
|
|
19
|
-
),
|
|
20
|
-
name: "search/:drive"
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { addDocumentIndexer };
|
package/drizzle.config.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "drizzle-kit";
|
|
2
|
-
export default defineConfig({
|
|
3
|
-
driver: "pglite",
|
|
4
|
-
dialect: "postgresql",
|
|
5
|
-
schema: [
|
|
6
|
-
"node_modules/@powerhousedao/general-document-indexer/src/schema.ts",
|
|
7
|
-
],
|
|
8
|
-
dbCredentials: {
|
|
9
|
-
url: "./dev.db",
|
|
10
|
-
},
|
|
11
|
-
});
|
package/src/indexer.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { drizzle } from "drizzle-orm/connect";
|
|
2
|
-
import { type GraphQLResolverMap } from "@apollo/subgraph/dist/schema-helper";
|
|
3
|
-
import {
|
|
4
|
-
addSubgraph,
|
|
5
|
-
createSchema,
|
|
6
|
-
registerInternalListener,
|
|
7
|
-
setAdditionalContextFields,
|
|
8
|
-
} from "@powerhousedao/reactor-api";
|
|
9
|
-
import * as searchListener from "@powerhousedao/general-document-indexer";
|
|
10
|
-
import { IDocumentDriveServer } from "document-drive/server";
|
|
11
|
-
|
|
12
|
-
export type DocumentIndexerOptions = {
|
|
13
|
-
reactor: IDocumentDriveServer;
|
|
14
|
-
path: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export async function addDocumentIndexer(options: DocumentIndexerOptions) {
|
|
18
|
-
const db = await drizzle("pglite", options.path);
|
|
19
|
-
setAdditionalContextFields({ db });
|
|
20
|
-
|
|
21
|
-
// register general document indexer listener
|
|
22
|
-
await registerInternalListener({
|
|
23
|
-
name: "search",
|
|
24
|
-
options: searchListener.options,
|
|
25
|
-
transmit: (strands) => searchListener.transmit(strands, db),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// add general document indexer subgraph
|
|
29
|
-
await addSubgraph({
|
|
30
|
-
getSchema: () =>
|
|
31
|
-
createSchema(
|
|
32
|
-
options.reactor,
|
|
33
|
-
searchListener.resolvers as GraphQLResolverMap,
|
|
34
|
-
searchListener.typeDefs,
|
|
35
|
-
),
|
|
36
|
-
name: "search/:drive",
|
|
37
|
-
});
|
|
38
|
-
}
|