@powerhousedao/reactor-local 1.5.3 → 1.6.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,12 +1,8 @@
1
- ## 1.5.3 (2024-11-21)
1
+ ## 1.6.1 (2024-11-30)
2
2
 
3
3
  ### 🧱 Updated Dependencies
4
4
 
5
- - Updated @powerhousedao/general-document-indexer to 1.3.11
6
- - Updated document-model-libs to 1.116.0
7
- - Updated document-drive to 1.4.6
8
- - Updated document-model to 2.7.1
9
- - Updated @powerhousedao/reactor-api to 1.5.3
5
+ - Updated @powerhousedao/reactor-api to 1.6.1
10
6
 
11
7
  ## 1.1.0 (2024-10-29)
12
8
 
@@ -2,7 +2,7 @@ import path2 from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import dotenv from 'dotenv';
4
4
  import { createServer } from 'vite';
5
- import { startAPI } from '@powerhousedao/reactor-api';
5
+ import { startAPI, addSubgraph, createSchema, registerInternalListener } from '@powerhousedao/reactor-api';
6
6
  import * as DocumentDrive from 'document-model-libs/document-drive';
7
7
  import { isFileNode, utils as utils$1, actions, documentModel } from 'document-model-libs/document-drive';
8
8
  import { utils } from 'document-model/document';
@@ -3954,6 +3954,28 @@ var startServer = async (options) => {
3954
3954
  ...baseDocumentModels,
3955
3955
  ...Object.values(localDMs)
3956
3956
  ]);
3957
+ const processorsPath = path2.join(process.cwd(), "./processors");
3958
+ console.log("Loading processors from", processorsPath);
3959
+ const localProcessors = await vite.ssrLoadModule(
3960
+ processorsPath
3961
+ );
3962
+ 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
+ ]);
3978
+ }
3957
3979
  }
3958
3980
  } catch (e) {
3959
3981
  console.error("App crashed", e);
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #! /usr/bin/env node
2
- import { startServer } from './chunk-WZVFZSEC.js';
2
+ import { startServer } from './chunk-JEZMQ4ZA.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-WZVFZSEC.js';
2
- export { DefaultStartServerOptions, startServer } from './chunk-WZVFZSEC.js';
1
+ import { startServer } from './chunk-JEZMQ4ZA.js';
2
+ export { DefaultStartServerOptions, startServer } from './chunk-JEZMQ4ZA.js';
3
3
 
4
4
  // src/index.ts
5
5
  startServer().catch((error) => {
package/dist/server.js CHANGED
@@ -1 +1 @@
1
- export { DefaultStartServerOptions, startServer } from './chunk-WZVFZSEC.js';
1
+ export { DefaultStartServerOptions, startServer } from './chunk-JEZMQ4ZA.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powerhousedao/reactor-local",
3
3
  "type": "module",
4
- "version": "1.5.3",
4
+ "version": "1.6.1",
5
5
  "main": "dist/server.js",
6
6
  "bin": {
7
7
  "reactor-local": "dist/cli.js"
@@ -16,13 +16,8 @@
16
16
  "@apollo/subgraph": "^2.9.2",
17
17
  "@electric-sql/pglite": "^0.2.12",
18
18
  "@libsql/client": "^0.14.0",
19
- "@powerhousedao/general-document-indexer": "^1.3.11",
20
- "@powerhousedao/reactor-api": "^1.5.3",
21
- "@powerhousedao/scalars": "^1.9.0",
22
19
  "change-case": "^5.4.4",
23
20
  "commander": "^12.1.0",
24
- "document-model": "^2.7.1",
25
- "document-model-libs": "^1.116.0",
26
21
  "dotenv": "^16.4.5",
27
22
  "drizzle-kit": "^0.25.0",
28
23
  "drizzle-orm": "^0.34.1",
@@ -36,7 +31,12 @@
36
31
  "sanitize-filename": "^1.6.3",
37
32
  "uuid": "^11.0.2",
38
33
  "vite": "^5.4.11",
39
- "vite-node": "^2.1.2"
34
+ "vite-node": "^2.1.2",
35
+ "@powerhousedao/general-document-indexer": "1.4.0",
36
+ "@powerhousedao/scalars": "1.9.0",
37
+ "document-model": "2.7.1",
38
+ "document-model-libs": "1.117.0",
39
+ "@powerhousedao/reactor-api": "1.6.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/body-parser": "^1.19.5",
@@ -45,14 +45,14 @@
45
45
  "@types/ms": "^0.7.34",
46
46
  "@types/node": "^22.7.5",
47
47
  "@types/pg": "^8.11.10",
48
- "document-drive": "^1.4.6",
49
48
  "postcss": "^8.4.47",
50
49
  "tsup": "^8.3.0",
51
50
  "typescript": "^5.6.2",
52
- "@powerhousedao/scalars": "^1.9.0"
51
+ "@powerhousedao/scalars": "1.9.0",
52
+ "document-drive": "1.5.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@powerhousedao/scalars": "^1.9.0"
55
+ "@powerhousedao/scalars": "1.9.0"
56
56
  },
57
57
  "scripts": {
58
58
  "start": "vite-node src/index.ts",
package/src/server.ts CHANGED
@@ -2,7 +2,12 @@ import path from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import dotenv from "dotenv";
4
4
  import { createServer as createViteServer } from "vite";
5
- import { startAPI } from "@powerhousedao/reactor-api";
5
+ import {
6
+ startAPI,
7
+ addSubgraph,
8
+ registerInternalListener,
9
+ createSchema,
10
+ } from "@powerhousedao/reactor-api";
6
11
  import {
7
12
  DocumentDriveServer,
8
13
  DriveAlreadyExistsError,
@@ -58,7 +63,7 @@ export type LocalReactor = {
58
63
  label: string;
59
64
  block: boolean;
60
65
  filter: ListenerFilter;
61
- },
66
+ }
62
67
  ) => Promise<InternalTransmitter>;
63
68
  };
64
69
 
@@ -68,7 +73,7 @@ const baseDocumentModels = [
68
73
  ] as DocumentModel[];
69
74
 
70
75
  const startServer = async (
71
- options?: StartServerOptions,
76
+ options?: StartServerOptions
72
77
  ): Promise<LocalReactor> => {
73
78
  const { port, storagePath, drive, dev } = {
74
79
  ...DefaultStartServerOptions,
@@ -79,7 +84,7 @@ const startServer = async (
79
84
  // start document drive server with all available document models & filesystem storage
80
85
  const driveServer = new DocumentDriveServer(
81
86
  baseDocumentModels,
82
- new FilesystemStorage(storagePath),
87
+ new FilesystemStorage(storagePath)
83
88
  );
84
89
 
85
90
  // init drive server
@@ -135,6 +140,32 @@ const startServer = async (
135
140
  ...baseDocumentModels,
136
141
  ...Object.values(localDMs),
137
142
  ]);
143
+
144
+ // load processors
145
+ const processorsPath = path.join(process.cwd(), "./processors");
146
+ console.log("Loading processors from", processorsPath);
147
+ const localProcessors = (await vite.ssrLoadModule(
148
+ processorsPath
149
+ )) as Record<string, any>;
150
+
151
+ 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
+ ]);
168
+ }
138
169
  }
139
170
  } catch (e) {
140
171
  console.error("App crashed", e);
@@ -153,7 +184,7 @@ const startServer = async (
153
184
  label: string;
154
185
  block: boolean;
155
186
  filter: ListenerFilter;
156
- },
187
+ }
157
188
  ) => driveServer.addInternalListener(driveId, receiver, options),
158
189
  };
159
190
  };