@powerhousedao/reactor-api 1.10.8 → 1.11.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 +18 -3
- package/dist/index.d.ts +131 -42
- package/dist/index.js +18433 -18235
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +4 -2
- package/src/processors/analytics-processor.ts +2 -7
- package/src/processors/index.ts +1 -0
- package/src/{processor-manager.ts → processors/manager.ts} +12 -6
- package/src/processors/processor.ts +1 -1
- package/src/server.ts +19 -26
- package/src/subgraphs/analytics/index.ts +114 -7
- package/src/subgraphs/base/index.ts +31 -0
- package/src/subgraphs/drive/index.ts +391 -3
- package/src/subgraphs/index.ts +21 -2
- package/src/{router.ts → subgraphs/manager.ts} +40 -33
- package/src/subgraphs/system/index.ts +45 -3
- package/src/subgraphs/types.ts +20 -0
- package/src/types.ts +9 -30
- package/src/utils/create-schema.ts +25 -26
- package/src/utils/{get-knex-client.ts → get-db-client.ts} +6 -3
- package/src/utils/index.ts +2 -0
- package/test/router.test.ts +7 -10
- package/src/subgraphs/analytics/db.ts +0 -58
- package/src/subgraphs/drive/resolvers.ts +0 -234
- package/src/subgraphs/drive/type-defs.ts +0 -136
- package/src/subgraphs/system/resolvers.ts +0 -23
- package/src/subgraphs/system/type-defs.ts +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
## 1.
|
|
1
|
+
## 1.11.0 (2024-12-16)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **reactor-api:** refactor knex and analytics store initialization ([2c19a7aa](https://github.com/powerhouse-inc/powerhouse/commit/2c19a7aa))
|
|
6
|
+
|
|
7
|
+
### 🩹 Fixes
|
|
8
|
+
|
|
9
|
+
- **switchboard:** subgraph manager and db instantiation ([874bdc4b](https://github.com/powerhouse-inc/powerhouse/commit/874bdc4b))
|
|
10
|
+
- **reactor-api:** datasource for analytics resolvers ([b015437e](https://github.com/powerhouse-inc/powerhouse/commit/b015437e))
|
|
11
|
+
- **reactor-api:** build issues ([d0182d5d](https://github.com/powerhouse-inc/powerhouse/commit/d0182d5d))
|
|
2
12
|
|
|
3
13
|
### 🧱 Updated Dependencies
|
|
4
14
|
|
|
5
|
-
- Updated document-model-libs to 1.122.
|
|
6
|
-
- Updated document-drive to 1.11.
|
|
15
|
+
- Updated document-model-libs to 1.122.6
|
|
16
|
+
- Updated document-drive to 1.11.6
|
|
17
|
+
|
|
18
|
+
### ❤️ Thank You
|
|
19
|
+
|
|
20
|
+
- acaldas @acaldas
|
|
21
|
+
- Frank
|
|
7
22
|
|
|
8
23
|
## 1.2.0 (2024-10-29)
|
|
9
24
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { PGlite } from '@electric-sql/pglite';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import * as document_model_libs_document_drive from 'document-model-libs/document-drive';
|
|
3
|
+
import { Trigger, PullResponderTriggerData, DocumentDriveDocument, ListenerFilter, DocumentDriveState, DocumentDriveLocalState, ListenerCallInfo, DocumentDriveAction } from 'document-model-libs/document-drive';
|
|
4
|
+
import { Operation, Document, DocumentModel, Action, OperationScope, State, BaseAction, CreateChildDocumentInput, ActionContext, ReducerOptions, Signal } from 'document-model/document';
|
|
4
5
|
import { Unsubscribe } from 'nanoevents';
|
|
5
6
|
import express, { Express } from 'express';
|
|
6
7
|
import { Pool } from 'pg';
|
|
7
8
|
import { IncomingHttpHeaders } from 'http';
|
|
9
|
+
import * as graphql from 'graphql';
|
|
10
|
+
import { DocumentNode } from 'graphql';
|
|
11
|
+
import { Knex } from 'knex';
|
|
8
12
|
import { IAnalyticsStore } from '@powerhousedao/analytics-engine-core';
|
|
9
13
|
export * from '@powerhousedao/analytics-engine-core';
|
|
10
|
-
import * as graphql from 'graphql';
|
|
11
14
|
import { GraphQLResolverMap } from '@apollo/subgraph/dist/schema-helper';
|
|
15
|
+
import { AnalyticsModel } from '@powerhousedao/analytics-engine-graphql';
|
|
16
|
+
import { GraphQLResolverMap as GraphQLResolverMap$1 } from '@apollo/subgraph/dist/schema-helper/resolverMap.js';
|
|
12
17
|
|
|
13
18
|
type StrandUpdateSource = {
|
|
14
19
|
type: "local";
|
|
@@ -288,22 +293,6 @@ type PublicPart<T> = Pick<T, PublicKeys<T>>;
|
|
|
288
293
|
type IBaseDocumentDriveServer = PublicPart<AbstractDocumentDriveServer>;
|
|
289
294
|
type IDocumentDriveServer = IBaseDocumentDriveServer & IDefaultDrivesManager & IReadModeDriveServer;
|
|
290
295
|
|
|
291
|
-
declare class ReactorRouterManager {
|
|
292
|
-
#private;
|
|
293
|
-
private readonly path;
|
|
294
|
-
private readonly app;
|
|
295
|
-
private readonly reactor;
|
|
296
|
-
private reactorRouter;
|
|
297
|
-
private contextFields;
|
|
298
|
-
private subgraphs;
|
|
299
|
-
constructor(path: string, app: express.Express, reactor: IDocumentDriveServer);
|
|
300
|
-
init(): Promise<void>;
|
|
301
|
-
updateRouter(): Promise<void>;
|
|
302
|
-
registerSubgraph(subgraph: Subgraph): Promise<void>;
|
|
303
|
-
getAdditionalContextFields: () => Record<string, any>;
|
|
304
|
-
setAdditionalContextFields(fields: Record<string, any>): void;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
296
|
type ProcessorUpdate<D extends Document = Document, S extends OperationScope = OperationScope> = InternalTransmitterUpdate<D, S>;
|
|
308
297
|
declare abstract class Processor<D extends Document = Document, S extends OperationScope = OperationScope> implements IProcessor<D, S> {
|
|
309
298
|
protected reactor: IDocumentDriveServer;
|
|
@@ -321,32 +310,128 @@ declare class BaseProcessor extends Processor {
|
|
|
321
310
|
type ProcessorClass = typeof BaseProcessor;
|
|
322
311
|
declare function isProcessorClass(candidate: unknown): candidate is ProcessorClass;
|
|
323
312
|
|
|
313
|
+
type Context = {
|
|
314
|
+
driveServer: IDocumentDriveServer;
|
|
315
|
+
driveId?: string;
|
|
316
|
+
headers: IncomingHttpHeaders;
|
|
317
|
+
db: unknown;
|
|
318
|
+
};
|
|
319
|
+
type ISubgraph = {
|
|
320
|
+
name: string;
|
|
321
|
+
resolvers: Record<string, any>;
|
|
322
|
+
typeDefs: DocumentNode;
|
|
323
|
+
reactor: IDocumentDriveServer;
|
|
324
|
+
operationalStore: Db;
|
|
325
|
+
onSetup?: () => Promise<void>;
|
|
326
|
+
};
|
|
327
|
+
type SubgraphArgs = {
|
|
328
|
+
reactor: IDocumentDriveServer;
|
|
329
|
+
operationalStore: Db;
|
|
330
|
+
analyticsStore: IAnalyticsStore;
|
|
331
|
+
subgraphManager: SubgraphManager;
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
declare class Subgraph implements ISubgraph {
|
|
335
|
+
name: string;
|
|
336
|
+
resolvers: GraphQLResolverMap<Context>;
|
|
337
|
+
typeDefs: DocumentNode;
|
|
338
|
+
reactor: IDocumentDriveServer;
|
|
339
|
+
operationalStore: Db;
|
|
340
|
+
constructor(args: SubgraphArgs);
|
|
341
|
+
onSetup(): Promise<void>;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
declare class AnalyticsSubgraph extends Subgraph {
|
|
345
|
+
#private;
|
|
346
|
+
analyticsStore: IAnalyticsStore;
|
|
347
|
+
analyticsModel: AnalyticsModel;
|
|
348
|
+
name: string;
|
|
349
|
+
typeDefs: graphql.DocumentNode;
|
|
350
|
+
resolvers: GraphQLResolverMap$1<Context>;
|
|
351
|
+
constructor(args: SubgraphArgs);
|
|
352
|
+
onSetup(): Promise<void>;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
type index$2_AnalyticsSubgraph = AnalyticsSubgraph;
|
|
356
|
+
declare const index$2_AnalyticsSubgraph: typeof AnalyticsSubgraph;
|
|
357
|
+
declare namespace index$2 {
|
|
358
|
+
export { index$2_AnalyticsSubgraph as AnalyticsSubgraph };
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
declare class DriveSubgraph extends Subgraph {
|
|
362
|
+
#private;
|
|
363
|
+
name: string;
|
|
364
|
+
typeDefs: graphql.DocumentNode;
|
|
365
|
+
onSetup(): Promise<void>;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
type index$1_DriveSubgraph = DriveSubgraph;
|
|
369
|
+
declare const index$1_DriveSubgraph: typeof DriveSubgraph;
|
|
370
|
+
declare namespace index$1 {
|
|
371
|
+
export { index$1_DriveSubgraph as DriveSubgraph };
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
declare class SystemSubgraph extends Subgraph {
|
|
375
|
+
name: string;
|
|
376
|
+
typeDefs: graphql.DocumentNode;
|
|
377
|
+
resolvers: {
|
|
378
|
+
Query: {
|
|
379
|
+
drives: () => Promise<string[]>;
|
|
380
|
+
};
|
|
381
|
+
Mutation: {
|
|
382
|
+
addDrive: (parent: unknown, args: DriveInput) => Promise<document_model_libs_document_drive.DocumentDriveState>;
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
type index_SystemSubgraph = SystemSubgraph;
|
|
388
|
+
declare const index_SystemSubgraph: typeof SystemSubgraph;
|
|
389
|
+
declare namespace index {
|
|
390
|
+
export { index_SystemSubgraph as SystemSubgraph };
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
type SubgraphClass = typeof Subgraph;
|
|
394
|
+
declare function isSubgraphClass(candidate: unknown): candidate is SubgraphClass;
|
|
395
|
+
|
|
396
|
+
declare class SubgraphManager {
|
|
397
|
+
#private;
|
|
398
|
+
private readonly path;
|
|
399
|
+
private readonly app;
|
|
400
|
+
private readonly reactor;
|
|
401
|
+
private readonly operationalStore;
|
|
402
|
+
private readonly analyticsStore;
|
|
403
|
+
private reactorRouter;
|
|
404
|
+
private contextFields;
|
|
405
|
+
private subgraphs;
|
|
406
|
+
constructor(path: string, app: express.Express, reactor: IDocumentDriveServer, operationalStore: Db, analyticsStore: IAnalyticsStore);
|
|
407
|
+
init(): Promise<void>;
|
|
408
|
+
updateRouter(): Promise<void>;
|
|
409
|
+
registerSubgraph(subgraph: SubgraphClass): Promise<void>;
|
|
410
|
+
getAdditionalContextFields: () => Record<string, any>;
|
|
411
|
+
setAdditionalContextFields(fields: Record<string, any>): void;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
type Db = Knex;
|
|
415
|
+
declare function getDbClient(connectionString?: string | undefined): Db;
|
|
416
|
+
|
|
417
|
+
declare abstract class AnalyticsProcessor<D extends Document = Document, S extends OperationScope = OperationScope> extends Processor<D, S> {
|
|
418
|
+
protected analyticsStore: IAnalyticsStore;
|
|
419
|
+
constructor(args: ProcessorSetupArgs, options?: ProcessorOptions);
|
|
420
|
+
}
|
|
421
|
+
|
|
324
422
|
type IProcessorManager = {
|
|
325
423
|
registerProcessor(module: IProcessor | ProcessorClass): Promise<IProcessor>;
|
|
326
424
|
};
|
|
327
425
|
type API = {
|
|
328
426
|
app: Express;
|
|
329
|
-
|
|
427
|
+
subgraphManager: SubgraphManager;
|
|
330
428
|
processorManager: IProcessorManager;
|
|
331
429
|
};
|
|
332
|
-
interface Context {
|
|
333
|
-
headers: IncomingHttpHeaders;
|
|
334
|
-
driveId: string | undefined;
|
|
335
|
-
driveServer: IDocumentDriveServer;
|
|
336
|
-
}
|
|
337
|
-
type Subgraph = {
|
|
338
|
-
name: string;
|
|
339
|
-
resolvers: any;
|
|
340
|
-
typeDefs: string;
|
|
341
|
-
options?: Omit<Listener, "driveId">;
|
|
342
|
-
transmit?: (strands: InternalTransmitterUpdate[]) => Promise<ListenerRevision[]>;
|
|
343
|
-
};
|
|
344
430
|
type ProcessorType = "analytics" | "operational";
|
|
345
431
|
type ProcessorSetupArgs = {
|
|
346
432
|
reactor: IDocumentDriveServer;
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
};
|
|
433
|
+
operationalStore: Db;
|
|
434
|
+
analyticsStore: IAnalyticsStore;
|
|
350
435
|
};
|
|
351
436
|
type IProcessor<D extends Document = Document, S extends OperationScope = OperationScope> = IReceiver<D, S> & {
|
|
352
437
|
onSetup?: (args: ProcessorSetupArgs) => void;
|
|
@@ -364,13 +449,17 @@ type Options = {
|
|
|
364
449
|
};
|
|
365
450
|
declare function startAPI(reactor: IDocumentDriveServer, options: Options): Promise<API>;
|
|
366
451
|
|
|
367
|
-
declare const createSchema: (documentDriveServer: IDocumentDriveServer, resolvers: GraphQLResolverMap<Context>, typeDefs:
|
|
368
|
-
declare const getDocumentModelTypeDefs: (documentDriveServer: IDocumentDriveServer, typeDefs:
|
|
452
|
+
declare const createSchema: (documentDriveServer: IDocumentDriveServer, resolvers: GraphQLResolverMap<Context>, typeDefs: DocumentNode) => graphql.GraphQLSchema;
|
|
453
|
+
declare const getDocumentModelTypeDefs: (documentDriveServer: IDocumentDriveServer, typeDefs: DocumentNode) => DocumentNode;
|
|
369
454
|
|
|
370
|
-
declare
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
455
|
+
declare class ProcessorManager implements IProcessorManager {
|
|
456
|
+
#private;
|
|
457
|
+
private operationalStore;
|
|
458
|
+
private analyticsStore;
|
|
459
|
+
private reactor;
|
|
460
|
+
private processors;
|
|
461
|
+
constructor(driveServer: IDocumentDriveServer, operationalStore: Db, analyticsStore: IAnalyticsStore);
|
|
462
|
+
registerProcessor(module: IProcessor | ProcessorClass): Promise<IProcessor>;
|
|
374
463
|
}
|
|
375
464
|
|
|
376
|
-
export { type API, AnalyticsProcessor, BaseProcessor, type Context, type IProcessor, type IProcessorManager, Processor, type ProcessorClass, type ProcessorOptions, type ProcessorSetupArgs, type ProcessorType, type ProcessorUpdate,
|
|
465
|
+
export { type API, AnalyticsProcessor, BaseProcessor, type Context, type Db, type IProcessor, type IProcessorManager, type ISubgraph, Processor, type ProcessorClass, ProcessorManager, type ProcessorOptions, type ProcessorSetupArgs, type ProcessorType, type ProcessorUpdate, Subgraph, type SubgraphArgs, type SubgraphClass, SubgraphManager, index$2 as analyticsSubgraph, createSchema, index$1 as driveSubgraph, getDbClient, getDocumentModelTypeDefs, isProcessorClass, isSubgraphClass, startAPI, index as systemSubgraph };
|