@powerhousedao/reactor-local 1.7.0 → 1.8.1

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 CHANGED
@@ -1,26 +1,11 @@
1
- ## 1.7.0 (2024-12-03)
2
-
3
- ### 🚀 Features
4
-
5
- - **design-system:** bump storybook deps ([f21d9539](https://github.com/powerhouse-inc/powerhouse/commit/f21d9539))
6
- - **monorepo:** remove eslint args ([4677e343](https://github.com/powerhouse-inc/powerhouse/commit/4677e343))
7
- - **monorepo:** readd vite for reactor local ([24a9e56b](https://github.com/powerhouse-inc/powerhouse/commit/24a9e56b))
8
- - **monorepo:** add linting for switchboard gui ([dc56c561](https://github.com/powerhouse-inc/powerhouse/commit/dc56c561))
9
- - **monorepo:** gitignore tsbuildinfo files ([d676a703](https://github.com/powerhouse-inc/powerhouse/commit/d676a703))
10
- - **monorepo:** unify typescript and linting ([24b9a205](https://github.com/powerhouse-inc/powerhouse/commit/24b9a205))
1
+ ## 1.8.1 (2024-12-05)
11
2
 
12
3
  ### 🧱 Updated Dependencies
13
4
 
14
- - Updated @powerhousedao/general-document-indexer to 1.5.0
15
- - Updated document-model-libs to 1.117.1
16
- - Updated document-drive to 1.6.0
17
- - Updated document-model to 2.8.0
18
- - Updated @powerhousedao/reactor-api to 1.7.0
19
- - Updated @powerhousedao/scalars to 1.10.0
20
-
21
- ### ❤️ Thank You
22
-
23
- - ryanwolhuter @ryanwolhuter
5
+ - Updated @powerhousedao/general-document-indexer to 1.6.1
6
+ - Updated document-model-libs to 1.118.1
7
+ - Updated document-drive to 1.7.1
8
+ - Updated @powerhousedao/reactor-api to 1.8.1
24
9
 
25
10
  ## 1.1.0 (2024-10-29)
26
11
 
@@ -1,8 +1,5 @@
1
- import path2 from 'node:path';
2
- import { fileURLToPath } from 'node:url';
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 app = await startAPI(driveServer, {
3935
- port: serverPort
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 Promise.all([
3964
- addSubgraph({
3965
- name,
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
@@ -1,5 +1,5 @@
1
1
  #! /usr/bin/env node
2
- import { startServer } from './chunk-JEZMQ4ZA.js';
2
+ import { startServer } from './chunk-WZM6GQ5Q.js';
3
3
  import { Command } from 'commander';
4
4
 
5
5
  var reactorLocalAction = (options) => {
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { startServer } from './chunk-JEZMQ4ZA.js';
2
- export { DefaultStartServerOptions, startServer } from './chunk-JEZMQ4ZA.js';
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: StrandUpdate[]): Promise<ListenerRevision[]>;
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-JEZMQ4ZA.js';
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.7.0",
4
+ "version": "1.8.1",
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
30
  "vite": "^6.0.2",
34
31
  "vite-node": "^2.1.7",
35
- "@powerhousedao/general-document-indexer": "1.5.0",
36
- "@powerhousedao/scalars": "1.10.0",
37
- "document-model": "2.8.0",
38
- "document-model-libs": "1.117.1",
39
- "@powerhousedao/reactor-api": "1.7.0"
32
+ "@powerhousedao/general-document-indexer": "1.6.1",
33
+ "@powerhousedao/scalars": "1.11.0",
34
+ "document-model": "2.9.0",
35
+ "@powerhousedao/reactor-api": "1.8.1",
36
+ "document-model-libs": "1.118.1"
40
37
  },
41
38
  "devDependencies": {
42
39
  "@types/body-parser": "^1.19.5",
@@ -44,21 +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
45
  "tsup": "^8.3.5",
50
- "@powerhousedao/scalars": "1.10.0",
51
- "document-drive": "1.6.0"
46
+ "@powerhousedao/scalars": "1.11.0",
47
+ "document-drive": "1.7.1"
52
48
  },
53
49
  "peerDependencies": {
54
- "@powerhousedao/scalars": "1.10.0"
50
+ "@powerhousedao/scalars": "1.11.0"
55
51
  },
56
52
  "scripts": {
57
53
  "start": "vite-node src/index.ts",
58
54
  "build": "tsup",
59
- "db:migrate": "drizzle-kit migrate",
60
- "db:studio": "drizzle-kit studio",
61
- "db:generate": "drizzle-kit generate",
62
55
  "prestart": "pnpm db:migrate"
63
56
  }
64
57
  }
package/src/server.ts CHANGED
@@ -1,13 +1,5 @@
1
- import path from "node:path";
2
- import { fileURLToPath } from "node:url";
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 { ListenerFilter } from "document-model-libs/document-drive";
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",
@@ -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 app = await startAPI(driveServer, {
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}`);
@@ -149,22 +153,9 @@ const startServer = async (
149
153
  )) as Record<string, any>;
150
154
 
151
155
  for (const [name, processor] of Object.entries(localProcessors)) {
152
- await Promise.all([
153
- addSubgraph({
154
- name,
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) {
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
- }