@powerhousedao/reactor-api 1.10.9 → 1.11.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 +11 -3
- package/dist/index.d.ts +130 -42
- package/dist/index.js +18416 -18221
- 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} +14 -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 +384 -3
- package/src/subgraphs/index.ts +21 -2
- package/src/{router.ts → subgraphs/manager.ts} +41 -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 +11 -14
- 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,17 @@
|
|
|
1
|
-
## 1.
|
|
1
|
+
## 1.11.1 (2024-12-16)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- **reactor-api:** known issues ([#707](https://github.com/powerhouse-inc/powerhouse/pull/707))
|
|
2
6
|
|
|
3
7
|
### 🧱 Updated Dependencies
|
|
4
8
|
|
|
5
|
-
- Updated document-model-libs to 1.122.
|
|
6
|
-
- Updated document-drive to 1.11.
|
|
9
|
+
- Updated document-model-libs to 1.122.7
|
|
10
|
+
- Updated document-drive to 1.11.7
|
|
11
|
+
|
|
12
|
+
### ❤️ Thank You
|
|
13
|
+
|
|
14
|
+
- Frank @froid1911
|
|
7
15
|
|
|
8
16
|
## 1.2.0 (2024-10-29)
|
|
9
17
|
|
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,127 @@ 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
|
+
name: string;
|
|
363
|
+
typeDefs: graphql.DocumentNode;
|
|
364
|
+
resolvers: GraphQLResolverMap<Context>;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
type index$1_DriveSubgraph = DriveSubgraph;
|
|
368
|
+
declare const index$1_DriveSubgraph: typeof DriveSubgraph;
|
|
369
|
+
declare namespace index$1 {
|
|
370
|
+
export { index$1_DriveSubgraph as DriveSubgraph };
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
declare class SystemSubgraph extends Subgraph {
|
|
374
|
+
name: string;
|
|
375
|
+
typeDefs: graphql.DocumentNode;
|
|
376
|
+
resolvers: {
|
|
377
|
+
Query: {
|
|
378
|
+
drives: () => Promise<string[]>;
|
|
379
|
+
};
|
|
380
|
+
Mutation: {
|
|
381
|
+
addDrive: (parent: unknown, args: DriveInput) => Promise<document_model_libs_document_drive.DocumentDriveState>;
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
type index_SystemSubgraph = SystemSubgraph;
|
|
387
|
+
declare const index_SystemSubgraph: typeof SystemSubgraph;
|
|
388
|
+
declare namespace index {
|
|
389
|
+
export { index_SystemSubgraph as SystemSubgraph };
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
type SubgraphClass = typeof Subgraph;
|
|
393
|
+
declare function isSubgraphClass(candidate: unknown): candidate is SubgraphClass;
|
|
394
|
+
|
|
395
|
+
declare class SubgraphManager {
|
|
396
|
+
#private;
|
|
397
|
+
private readonly path;
|
|
398
|
+
private readonly app;
|
|
399
|
+
private readonly reactor;
|
|
400
|
+
private readonly operationalStore;
|
|
401
|
+
private readonly analyticsStore;
|
|
402
|
+
private reactorRouter;
|
|
403
|
+
private contextFields;
|
|
404
|
+
private subgraphs;
|
|
405
|
+
constructor(path: string, app: express.Express, reactor: IDocumentDriveServer, operationalStore: Db, analyticsStore: IAnalyticsStore);
|
|
406
|
+
init(): Promise<void>;
|
|
407
|
+
updateRouter(): Promise<void>;
|
|
408
|
+
registerSubgraph(subgraph: SubgraphClass): Promise<void>;
|
|
409
|
+
getAdditionalContextFields: () => Record<string, any>;
|
|
410
|
+
setAdditionalContextFields(fields: Record<string, any>): void;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
type Db = Knex;
|
|
414
|
+
declare function getDbClient(connectionString?: string | undefined): Db;
|
|
415
|
+
|
|
416
|
+
declare abstract class AnalyticsProcessor<D extends Document = Document, S extends OperationScope = OperationScope> extends Processor<D, S> {
|
|
417
|
+
protected analyticsStore: IAnalyticsStore;
|
|
418
|
+
constructor(args: ProcessorSetupArgs, options?: ProcessorOptions);
|
|
419
|
+
}
|
|
420
|
+
|
|
324
421
|
type IProcessorManager = {
|
|
325
422
|
registerProcessor(module: IProcessor | ProcessorClass): Promise<IProcessor>;
|
|
326
423
|
};
|
|
327
424
|
type API = {
|
|
328
425
|
app: Express;
|
|
329
|
-
|
|
426
|
+
subgraphManager: SubgraphManager;
|
|
330
427
|
processorManager: IProcessorManager;
|
|
331
428
|
};
|
|
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
429
|
type ProcessorType = "analytics" | "operational";
|
|
345
430
|
type ProcessorSetupArgs = {
|
|
346
431
|
reactor: IDocumentDriveServer;
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
};
|
|
432
|
+
operationalStore: Db;
|
|
433
|
+
analyticsStore: IAnalyticsStore;
|
|
350
434
|
};
|
|
351
435
|
type IProcessor<D extends Document = Document, S extends OperationScope = OperationScope> = IReceiver<D, S> & {
|
|
352
436
|
onSetup?: (args: ProcessorSetupArgs) => void;
|
|
@@ -364,13 +448,17 @@ type Options = {
|
|
|
364
448
|
};
|
|
365
449
|
declare function startAPI(reactor: IDocumentDriveServer, options: Options): Promise<API>;
|
|
366
450
|
|
|
367
|
-
declare const createSchema: (documentDriveServer: IDocumentDriveServer, resolvers: GraphQLResolverMap<Context>, typeDefs:
|
|
368
|
-
declare const getDocumentModelTypeDefs: (documentDriveServer: IDocumentDriveServer, typeDefs:
|
|
451
|
+
declare const createSchema: (documentDriveServer: IDocumentDriveServer, resolvers: GraphQLResolverMap<Context>, typeDefs: DocumentNode) => graphql.GraphQLSchema;
|
|
452
|
+
declare const getDocumentModelTypeDefs: (documentDriveServer: IDocumentDriveServer, typeDefs: DocumentNode) => DocumentNode;
|
|
369
453
|
|
|
370
|
-
declare
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
454
|
+
declare class ProcessorManager implements IProcessorManager {
|
|
455
|
+
#private;
|
|
456
|
+
private operationalStore;
|
|
457
|
+
private analyticsStore;
|
|
458
|
+
private reactor;
|
|
459
|
+
private processors;
|
|
460
|
+
constructor(driveServer: IDocumentDriveServer, operationalStore: Db, analyticsStore: IAnalyticsStore);
|
|
461
|
+
registerProcessor(module: IProcessor | ProcessorClass): Promise<IProcessor>;
|
|
374
462
|
}
|
|
375
463
|
|
|
376
|
-
export { type API, AnalyticsProcessor, BaseProcessor, type Context, type IProcessor, type IProcessorManager, Processor, type ProcessorClass, type ProcessorOptions, type ProcessorSetupArgs, type ProcessorType, type ProcessorUpdate,
|
|
464
|
+
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 };
|