@powerhousedao/reactor-api 1.12.0 → 1.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/reactor-api",
3
- "version": "1.12.0",
3
+ "version": "1.13.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,16 +13,16 @@
13
13
  "author": "",
14
14
  "license": "AGPL-3.0-only",
15
15
  "devDependencies": {
16
- "@powerhousedao/analytics-engine-graphql": "^0.2.0",
16
+ "@powerhousedao/analytics-engine-graphql": "^0.2.1",
17
17
  "@types/body-parser": "^1.19.5",
18
18
  "@types/cors": "^2.8.17",
19
19
  "@types/express": "^5.0.0",
20
20
  "@types/pg": "^8.11.10",
21
21
  "esbuild": "^0.24.0",
22
22
  "graphql-tag": "^2.12.6",
23
- "@powerhousedao/scalars": "1.14.0",
24
- "document-model": "2.14.0",
25
- "document-drive": "1.12.0"
23
+ "@powerhousedao/scalars": "1.15.0",
24
+ "document-drive": "1.12.1",
25
+ "document-model": "2.14.0"
26
26
  },
27
27
  "dependencies": {
28
28
  "@apollo/server": "^4.11.0",
@@ -42,7 +42,7 @@
42
42
  "nanoevents": "^9.0.0",
43
43
  "pg": "^8.13.0",
44
44
  "uuid": "^9.0.1",
45
- "document-model-libs": "1.123.0"
45
+ "document-model-libs": "1.124.0"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsup",
@@ -1,3 +1,4 @@
1
1
  export * from "./analytics-processor";
2
+ export * from "./operational-processor";
2
3
  export * from "./processor";
3
4
  export * from "./manager";
@@ -0,0 +1,20 @@
1
+ import { Document, OperationScope } from "document-model/document";
2
+ import { Db, ProcessorOptions, ProcessorSetupArgs } from "src/types";
3
+ import { Processor } from "./processor";
4
+
5
+ export abstract class OperationalProcessor<
6
+ D extends Document = Document,
7
+ S extends OperationScope = OperationScope,
8
+ > extends Processor<D, S> {
9
+ protected operationalStore: Db;
10
+
11
+ constructor(args: ProcessorSetupArgs, options?: ProcessorOptions) {
12
+ super(args, options);
13
+ this.operationalStore = args.operationalStore;
14
+ }
15
+
16
+ onSetup(args: ProcessorSetupArgs) {
17
+ super.onSetup(args);
18
+ this.operationalStore = args.operationalStore;
19
+ }
20
+ }
package/src/server.ts CHANGED
@@ -5,7 +5,7 @@ import { Pool } from "pg";
5
5
  import { ProcessorManager } from "./processors";
6
6
  import { SubgraphManager } from "./subgraphs/manager";
7
7
  import { API } from "./types";
8
- import { getDbClient } from "./utils/get-db-client";
8
+ import { getDbClient } from "./utils/db";
9
9
  import {
10
10
  KnexAnalyticsStore,
11
11
  KnexQueryExecutor,
@@ -26,13 +26,6 @@ export class SubgraphManager {
26
26
  private readonly operationalStore: Db,
27
27
  private readonly analyticsStore: IAnalyticsStore,
28
28
  ) {
29
- const args: SubgraphArgs = {
30
- reactor: this.reactor,
31
- operationalStore: this.operationalStore,
32
- analyticsStore: this.analyticsStore,
33
- subgraphManager: this,
34
- };
35
-
36
29
  // Setup Default subgraphs
37
30
  this.registerSubgraph(SystemSubgraph);
38
31
  this.registerSubgraph(DriveSubgraph);
@@ -40,9 +33,7 @@ export class SubgraphManager {
40
33
  }
41
34
 
42
35
  async init() {
43
- console.log(
44
- `Initializing ReactorRouterManager with subgraphs: [${this.subgraphs.map((e) => e.name).join(", ")}]`,
45
- );
36
+ console.log(`Initializing ReactorRouterManager...`);
46
37
  const models = this.reactor.getDocumentModels();
47
38
  const driveModel = models.find(
48
39
  (it) => it.documentModel.name === "DocumentDrive",
package/src/types.ts CHANGED
@@ -3,10 +3,10 @@ import { Document, OperationScope } from "document-model/document";
3
3
  import { Express } from "express";
4
4
  import { ProcessorClass } from "./processors/processor";
5
5
  import { SubgraphManager } from "./subgraphs/manager";
6
- import { Db } from "./utils/get-db-client";
6
+ import { Db } from "./utils/db";
7
7
  import { IAnalyticsStore } from "./processors/analytics-processor";
8
8
 
9
- export type { Db } from "./utils/get-db-client";
9
+ export type { Db } from "./utils/db";
10
10
 
11
11
  export type IProcessorManager = {
12
12
  registerProcessor(module: IProcessor | ProcessorClass): Promise<IProcessor>;
@@ -1,2 +1,2 @@
1
1
  export * from "./create-schema";
2
- export * from "./get-db-client";
2
+ export * from "./db";
@@ -4,7 +4,7 @@ import { DocumentModel } from "document-model/document";
4
4
  import { module as DocumentModelLib } from "document-model/document-model";
5
5
  import express from "express";
6
6
  import { SubgraphManager } from "src";
7
- import { getDbClient } from "src/utils/get-db-client";
7
+ import { getDbClient } from "src/utils/db";
8
8
  import { describe, expect, it } from "vitest";
9
9
 
10
10
  const documentModels = [
File without changes