@powerhousedao/reactor-api 1.21.2 → 1.22.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.
Files changed (134) hide show
  1. package/dist/index.d.ts +8 -503
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +7 -27020
  4. package/dist/src/processors/analytics-processor.d.ts +9 -0
  5. package/dist/src/processors/analytics-processor.d.ts.map +1 -0
  6. package/dist/src/processors/analytics-processor.js +9 -0
  7. package/dist/src/processors/index.d.ts +5 -0
  8. package/dist/src/processors/index.d.ts.map +1 -0
  9. package/dist/src/processors/index.js +4 -0
  10. package/dist/src/processors/manager.d.ts +14 -0
  11. package/dist/src/processors/manager.d.ts.map +1 -0
  12. package/dist/src/processors/manager.js +40 -0
  13. package/dist/src/processors/operational-processor.d.ts +8 -0
  14. package/dist/src/processors/operational-processor.d.ts.map +1 -0
  15. package/dist/src/processors/operational-processor.js +12 -0
  16. package/dist/src/processors/processor.d.ts +20 -0
  17. package/dist/src/processors/processor.d.ts.map +1 -0
  18. package/dist/src/processors/processor.js +45 -0
  19. package/dist/src/server.d.ts +18 -0
  20. package/dist/src/server.d.ts.map +1 -0
  21. package/dist/src/server.js +51 -0
  22. package/dist/src/subgraphs/analytics/index.d.ts +16 -0
  23. package/dist/src/subgraphs/analytics/index.d.ts.map +1 -0
  24. package/dist/src/subgraphs/analytics/index.js +85 -0
  25. package/dist/src/subgraphs/auth/env/getters.d.ts +3 -0
  26. package/dist/src/subgraphs/auth/env/getters.d.ts.map +1 -0
  27. package/dist/src/subgraphs/auth/env/getters.js +26 -0
  28. package/dist/src/subgraphs/auth/env/index.d.ts +8 -0
  29. package/dist/src/subgraphs/auth/env/index.d.ts.map +1 -0
  30. package/{src/subgraphs/auth/env/index.ts → dist/src/subgraphs/auth/env/index.js} +4 -6
  31. package/dist/src/subgraphs/auth/index.d.ts +11 -0
  32. package/dist/src/subgraphs/auth/index.d.ts.map +1 -0
  33. package/dist/src/subgraphs/auth/index.js +259 -0
  34. package/dist/src/subgraphs/auth/types.d.ts +35 -0
  35. package/dist/src/subgraphs/auth/types.d.ts.map +1 -0
  36. package/dist/src/subgraphs/auth/types.js +1 -0
  37. package/dist/src/subgraphs/auth/utils/helpers.d.ts +12 -0
  38. package/dist/src/subgraphs/auth/utils/helpers.d.ts.map +1 -0
  39. package/dist/src/subgraphs/auth/utils/helpers.js +100 -0
  40. package/dist/src/subgraphs/auth/utils/session.d.ts +22 -0
  41. package/dist/src/subgraphs/auth/utils/session.d.ts.map +1 -0
  42. package/dist/src/subgraphs/auth/utils/session.js +100 -0
  43. package/dist/src/subgraphs/auth/utils/user.d.ts +12 -0
  44. package/dist/src/subgraphs/auth/utils/user.d.ts.map +1 -0
  45. package/dist/src/subgraphs/auth/utils/user.js +26 -0
  46. package/dist/src/subgraphs/base/index.d.ts +16 -0
  47. package/dist/src/subgraphs/base/index.d.ts.map +1 -0
  48. package/dist/src/subgraphs/base/index.js +25 -0
  49. package/dist/src/subgraphs/drive/index.d.ts +11 -0
  50. package/dist/src/subgraphs/drive/index.d.ts.map +1 -0
  51. package/dist/src/subgraphs/drive/index.js +341 -0
  52. package/dist/src/subgraphs/drive/temp-hack-rwa-type-defs.d.ts +57 -0
  53. package/dist/src/subgraphs/drive/temp-hack-rwa-type-defs.d.ts.map +1 -0
  54. package/dist/src/subgraphs/drive/temp-hack-rwa-type-defs.js +1 -0
  55. package/dist/src/subgraphs/index.d.ts +10 -0
  56. package/dist/src/subgraphs/index.d.ts.map +1 -0
  57. package/dist/src/subgraphs/index.js +20 -0
  58. package/dist/src/subgraphs/manager.d.ts +23 -0
  59. package/dist/src/subgraphs/manager.d.ts.map +1 -0
  60. package/dist/src/subgraphs/manager.js +102 -0
  61. package/dist/src/subgraphs/system/env/getters.d.ts +2 -0
  62. package/dist/src/subgraphs/system/env/getters.d.ts.map +1 -0
  63. package/dist/src/subgraphs/system/env/getters.js +3 -0
  64. package/dist/src/subgraphs/system/env/index.d.ts +2 -0
  65. package/dist/src/subgraphs/system/env/index.d.ts.map +1 -0
  66. package/{src/subgraphs/system/env/index.ts → dist/src/subgraphs/system/env/index.js} +1 -3
  67. package/dist/src/subgraphs/system/index.d.ts +19 -0
  68. package/dist/src/subgraphs/system/index.d.ts.map +1 -0
  69. package/dist/src/subgraphs/system/index.js +63 -0
  70. package/dist/src/subgraphs/system/types.d.ts +5 -0
  71. package/dist/src/subgraphs/system/types.d.ts.map +1 -0
  72. package/dist/src/subgraphs/system/types.js +1 -0
  73. package/dist/src/subgraphs/types.d.ts +27 -0
  74. package/dist/src/subgraphs/types.d.ts.map +1 -0
  75. package/dist/src/subgraphs/types.js +1 -0
  76. package/dist/src/sync/utils.d.ts +13 -0
  77. package/dist/src/sync/utils.d.ts.map +1 -0
  78. package/dist/src/sync/utils.js +37 -0
  79. package/dist/src/types.d.ts +29 -0
  80. package/dist/src/types.d.ts.map +1 -0
  81. package/dist/src/types.js +1 -0
  82. package/dist/src/utils/create-schema.d.ts +7 -0
  83. package/dist/src/utils/create-schema.d.ts.map +1 -0
  84. package/dist/src/utils/create-schema.js +122 -0
  85. package/dist/src/utils/db.d.ts +4 -0
  86. package/dist/src/utils/db.d.ts.map +1 -0
  87. package/dist/src/utils/db.js +20 -0
  88. package/dist/src/utils/index.d.ts +3 -0
  89. package/dist/src/utils/index.d.ts.map +1 -0
  90. package/dist/src/utils/index.js +2 -0
  91. package/dist/tsconfig.tsbuildinfo +1 -0
  92. package/dist/vitest.config.d.ts +3 -0
  93. package/dist/vitest.config.d.ts.map +1 -0
  94. package/dist/vitest.config.js +24 -0
  95. package/package.json +18 -9
  96. package/CHANGELOG.md +0 -39
  97. package/dist/index.js.map +0 -1
  98. package/src/index.ts +0 -7
  99. package/src/processors/analytics-processor.ts +0 -18
  100. package/src/processors/index.ts +0 -4
  101. package/src/processors/manager.ts +0 -75
  102. package/src/processors/operational-processor.ts +0 -20
  103. package/src/processors/processor.ts +0 -75
  104. package/src/server.ts +0 -65
  105. package/src/subgraphs/analytics/index.ts +0 -119
  106. package/src/subgraphs/auth/env/getters.ts +0 -30
  107. package/src/subgraphs/auth/index.ts +0 -321
  108. package/src/subgraphs/auth/types.ts +0 -39
  109. package/src/subgraphs/auth/utils/helpers.ts +0 -132
  110. package/src/subgraphs/auth/utils/session.ts +0 -144
  111. package/src/subgraphs/auth/utils/user.ts +0 -40
  112. package/src/subgraphs/base/index.ts +0 -34
  113. package/src/subgraphs/drive/index.ts +0 -434
  114. package/src/subgraphs/drive/temp-hack-rwa-type-defs.ts +0 -39
  115. package/src/subgraphs/index.ts +0 -24
  116. package/src/subgraphs/manager.ts +0 -128
  117. package/src/subgraphs/system/env/getters.ts +0 -7
  118. package/src/subgraphs/system/index.ts +0 -73
  119. package/src/subgraphs/system/types.ts +0 -5
  120. package/src/subgraphs/types.ts +0 -29
  121. package/src/sync/utils.ts +0 -85
  122. package/src/types.ts +0 -43
  123. package/src/utils/create-schema.ts +0 -160
  124. package/src/utils/db.ts +0 -26
  125. package/src/utils/index.ts +0 -2
  126. package/test/benchmarks/load.bench.ts +0 -78
  127. package/test/benchmarks/sync.bench.ts +0 -151
  128. package/test/data/BlocktowerAndromeda.zip +0 -0
  129. package/test/router.test.ts +0 -48
  130. package/tsconfig.json +0 -21
  131. package/tsdoc.json +0 -3
  132. package/tsup.config.ts +0 -17
  133. package/types.d.ts +0 -5
  134. package/vitest.config.ts +0 -28
package/dist/index.d.ts CHANGED
@@ -1,503 +1,8 @@
1
- import { PGlite } from '@electric-sql/pglite';
2
- import * as document_model_libs_document_drive from 'document-model-libs/document-drive';
3
- import { DocumentDriveDocument, ListenerFilter, Trigger, PullResponderTriggerData, DocumentDriveState, DocumentDriveLocalState, ListenerCallInfo, DocumentDriveAction } from 'document-model-libs/document-drive';
4
- import { Operation, Document, DocumentModel, Action, OperationScope, State, BaseAction, ActionContext, ReducerOptions, Signal } from 'document-model/document';
5
- import { Unsubscribe } from 'nanoevents';
6
- import express, { Express } from 'express';
7
- import { Pool } from 'pg';
8
- import { IAnalyticsStore } from '@powerhousedao/analytics-engine-core';
9
- export * from '@powerhousedao/analytics-engine-core';
10
- import { IncomingHttpHeaders } from 'http';
11
- import * as graphql from 'graphql';
12
- import { DocumentNode } from 'graphql';
13
- import { Knex } from 'knex';
14
- import { GraphQLResolverMap as GraphQLResolverMap$1 } from '@apollo/subgraph/dist/schema-helper';
15
- import { AnalyticsModel } from '@powerhousedao/analytics-engine-graphql';
16
- import { GraphQLResolverMap } from '@apollo/subgraph/dist/schema-helper/resolverMap.js';
17
-
18
- declare class DocumentModelNotFoundError extends Error {
19
- id: string;
20
- constructor(id: string, cause?: unknown);
21
- }
22
- declare class OperationError extends Error {
23
- status: ErrorStatus;
24
- operation: Operation | undefined;
25
- constructor(status: ErrorStatus, operation?: Operation, message?: string, cause?: unknown);
26
- }
27
- declare class SynchronizationUnitNotFoundError extends Error {
28
- syncUnitId: string;
29
- constructor(message: string, syncUnitId: string);
30
- }
31
-
32
- type DriveInfo = {
33
- id: string;
34
- name: string;
35
- slug: string;
36
- icon?: string;
37
- };
38
-
39
- declare abstract class ReadDriveError extends Error {
40
- }
41
- declare class ReadDriveNotFoundError extends ReadDriveError {
42
- constructor(driveId: string);
43
- }
44
- declare class ReadDriveSlugNotFoundError extends ReadDriveError {
45
- constructor(slug: string);
46
- }
47
- declare class ReadDocumentNotFoundError extends ReadDriveError {
48
- constructor(drive: string, id: string);
49
- }
50
-
51
- type InferDocumentState<D extends Document> = D extends Document<infer S> ? S : never;
52
- type InferDocumentOperation<D extends Document> = D extends Document<unknown, infer A> ? A : never;
53
- type InferDocumentLocalState<D extends Document> = D extends Document<unknown, Action, infer L> ? L : never;
54
- type ReadDrivesListener = (drives: ReadDrive[], operation: "add" | "delete") => void;
55
- type ReadDrivesListenerUnsubscribe = () => void;
56
- interface IReadModeDriveServer extends IReadModeDriveService {
57
- migrateReadDrive(id: string, options: RemoteDriveOptions): Promise<DocumentDriveDocument | ReadDriveNotFoundError>;
58
- onReadDrivesUpdate(listener: ReadDrivesListener): Promise<ReadDrivesListenerUnsubscribe>;
59
- }
60
- type ReadDriveOptions = {
61
- expectedDriveInfo?: DriveInfo;
62
- filter?: ListenerFilter;
63
- };
64
- type ReadDriveContext = {
65
- url: string;
66
- } & ReadDriveOptions;
67
- type ReadDrive = DocumentDriveDocument & {
68
- readContext: ReadDriveContext;
69
- };
70
- interface IReadModeDriveService {
71
- addReadDrive(url: string, options?: ReadDriveOptions): Promise<void>;
72
- getReadDrives(): Promise<string[]>;
73
- getReadDriveBySlug(slug: string): Promise<ReadDrive | ReadDriveSlugNotFoundError>;
74
- getReadDrive(id: string): Promise<ReadDrive | ReadDriveNotFoundError>;
75
- getReadDriveContext(id: string): Promise<ReadDriveContext | ReadDriveNotFoundError>;
76
- fetchDrive(id: string): Promise<ReadDrive | ReadDriveNotFoundError>;
77
- fetchDocument<D extends Document>(driveId: string, documentId: string, documentType: DocumentModel<InferDocumentState<D>, InferDocumentOperation<D>, InferDocumentLocalState<D>>["documentModel"]["id"]): Promise<Document<InferDocumentState<D>, InferDocumentOperation<D>, InferDocumentLocalState<D>> | DocumentModelNotFoundError | ReadDriveNotFoundError | ReadDocumentNotFoundError>;
78
- deleteReadDrive(id: string): Promise<ReadDriveNotFoundError | undefined>;
79
- }
80
-
81
- interface IDefaultDrivesManager {
82
- initializeDefaultRemoteDrives(): Promise<void>;
83
- getDefaultRemoteDrives(): Map<string, DefaultRemoteDriveInfo>;
84
- setDefaultDriveAccessLevel(url: string, level: RemoteDriveAccessLevel): Promise<void>;
85
- setAllDefaultDrivesAccessLevel(level: RemoteDriveAccessLevel): Promise<void>;
86
- }
87
-
88
- type StrandUpdateSource = {
89
- type: "local";
90
- } | {
91
- type: "trigger";
92
- trigger: Trigger;
93
- };
94
- interface ITransmitter {
95
- transmit?(strands: StrandUpdate[], source: StrandUpdateSource): Promise<ListenerRevision[]>;
96
- disconnect?(): Promise<void>;
97
- }
98
- type PullResponderTrigger = Omit<Trigger, "data" | "type"> & {
99
- data: PullResponderTriggerData;
100
- type: "PullResponder";
101
- };
102
-
103
- interface IReceiver<T extends Document = Document, S extends OperationScope = OperationScope> {
104
- onStrands: (strands: InternalTransmitterUpdate<T, S>[]) => Promise<void>;
105
- onDisconnect: () => Promise<void>;
106
- }
107
- type InternalOperationUpdate<D extends Document = Document, S extends OperationScope = OperationScope> = Omit<Operation<InferDocumentOperation<D>>, "scope"> & {
108
- state: D["state"][S];
109
- previousState: D["state"][S];
110
- };
111
- type InternalTransmitterUpdate<D extends Document = Document, S extends OperationScope = OperationScope> = {
112
- driveId: string;
113
- documentId: string;
114
- scope: S;
115
- branch: string;
116
- operations: InternalOperationUpdate<D, S>[];
117
- state: D["state"][S];
118
- };
119
- interface IInternalTransmitter extends ITransmitter {
120
- setReceiver(receiver: IReceiver): void;
121
- }
122
-
123
- type DriveInput = State<Omit<DocumentDriveState, "__typename" | "id" | "nodes"> & {
124
- id?: string;
125
- }, DocumentDriveLocalState>;
126
- type RemoteDriveAccessLevel = "READ" | "WRITE";
127
- type RemoteDriveOptions = DocumentDriveLocalState & {
128
- pullFilter?: ListenerFilter;
129
- pullInterval?: number;
130
- expectedDriveInfo?: DriveInfo;
131
- accessLevel?: RemoteDriveAccessLevel;
132
- };
133
- type SignalResult = {
134
- signal: Signal;
135
- result: unknown;
136
- };
137
- type IOperationResult<T extends Document = Document> = {
138
- status: UpdateStatus;
139
- error?: OperationError;
140
- operations: Operation[];
141
- document: T | undefined;
142
- signals: SignalResult[];
143
- };
144
- type SynchronizationUnit = {
145
- syncId: string;
146
- driveId: string;
147
- documentId: string;
148
- documentType: string;
149
- scope: string;
150
- branch: string;
151
- lastUpdated: string;
152
- revision: number;
153
- };
154
- type SynchronizationUnitQuery = Omit<SynchronizationUnit, "revision" | "lastUpdated">;
155
- type Listener = {
156
- driveId: string;
157
- listenerId: string;
158
- label?: string;
159
- block: boolean;
160
- system: boolean;
161
- filter: ListenerFilter;
162
- callInfo?: ListenerCallInfo;
163
- transmitter?: ITransmitter;
164
- };
165
- type ListenerRevision = {
166
- driveId: string;
167
- documentId: string;
168
- scope: string;
169
- branch: string;
170
- status: UpdateStatus;
171
- revision: number;
172
- error?: string;
173
- };
174
- type UpdateStatus = "SUCCESS" | "CONFLICT" | "MISSING" | "ERROR";
175
- type ErrorStatus = Exclude<UpdateStatus, "SUCCESS">;
176
- type OperationUpdate = {
177
- timestamp: string;
178
- index: number;
179
- skip: number;
180
- type: string;
181
- input: object;
182
- hash: string;
183
- context?: ActionContext;
184
- id?: string;
185
- };
186
- type StrandUpdate = {
187
- driveId: string;
188
- documentId: string;
189
- scope: OperationScope;
190
- branch: string;
191
- operations: OperationUpdate[];
192
- };
193
- type SyncStatus = "INITIAL_SYNC" | "SYNCING" | UpdateStatus;
194
- type PullSyncStatus = SyncStatus;
195
- type PushSyncStatus = SyncStatus;
196
- type SyncUnitStatusObject = {
197
- push?: PushSyncStatus;
198
- pull?: PullSyncStatus;
199
- };
200
- type AddRemoteDriveStatus = "SUCCESS" | "ERROR" | "PENDING" | "ADDING" | "ALREADY_ADDED";
201
- interface DriveEvents {
202
- syncStatus: (driveId: string, status: SyncStatus, error?: Error, syncUnitStatus?: SyncUnitStatusObject) => void;
203
- defaultRemoteDrive: (status: AddRemoteDriveStatus, defaultDrives: Map<string, DefaultRemoteDriveInfo>, driveInput: DefaultRemoteDriveInput, driveId?: string, driveName?: string, error?: Error) => void;
204
- strandUpdate: (update: StrandUpdate) => void;
205
- clientStrandsError: (driveId: string, trigger: Trigger, status: number, errorMessage: string) => void;
206
- documentModels: (documentModels: DocumentModel[]) => void;
207
- driveAdded: (drive: DocumentDriveDocument) => void;
208
- driveDeleted: (driveId: string) => void;
209
- }
210
- type PartialRecord<K extends keyof any, T> = {
211
- [P in K]?: T;
212
- };
213
- type RevisionsFilter = PartialRecord<OperationScope, number>;
214
- type GetDocumentOptions = ReducerOptions & {
215
- revisions?: RevisionsFilter;
216
- checkHashes?: boolean;
217
- };
218
- type AddOperationOptions = {
219
- forceSync?: boolean;
220
- source: StrandUpdateSource;
221
- };
222
- type DefaultRemoteDriveInput = {
223
- url: string;
224
- options: RemoteDriveOptions;
225
- };
226
- type DefaultRemoteDriveInfo = DefaultRemoteDriveInput & {
227
- status: AddRemoteDriveStatus;
228
- metadata?: DriveInfo;
229
- };
230
- type GetStrandsOptions = {
231
- limit?: number;
232
- since?: string;
233
- fromRevision?: number;
234
- };
235
- interface IBaseDocumentDriveServer {
236
- initialize(): Promise<Error[] | null>;
237
- setDocumentModels(models: DocumentModel[]): void;
238
- getDrives(): Promise<string[]>;
239
- addDrive(input: DriveInput): Promise<DocumentDriveDocument>;
240
- addRemoteDrive(url: string, options: RemoteDriveOptions): Promise<DocumentDriveDocument>;
241
- deleteDrive(driveId: string): Promise<void>;
242
- getDrive(driveId: string, options?: GetDocumentOptions): Promise<DocumentDriveDocument>;
243
- getDriveBySlug(slug: string): Promise<DocumentDriveDocument>;
244
- getDocuments(driveId: string): Promise<string[]>;
245
- getDocument(driveId: string, documentId: string, options?: GetDocumentOptions): Promise<Document>;
246
- addOperation(driveId: string, documentId: string, operation: Operation, options?: AddOperationOptions): Promise<IOperationResult>;
247
- addOperations(driveId: string, documentId: string, operations: Operation[], options?: AddOperationOptions): Promise<IOperationResult>;
248
- queueOperation(driveId: string, documentId: string, operation: Operation, options?: AddOperationOptions): Promise<IOperationResult>;
249
- queueOperations(driveId: string, documentId: string, operations: Operation[], options?: AddOperationOptions): Promise<IOperationResult>;
250
- queueAction(driveId: string, documentId: string, action: Action, options?: AddOperationOptions): Promise<IOperationResult>;
251
- queueActions(driveId: string, documentId: string, actions: Action[], options?: AddOperationOptions): Promise<IOperationResult>;
252
- addDriveOperation(driveId: string, operation: Operation<DocumentDriveAction | BaseAction>, options?: AddOperationOptions): Promise<IOperationResult<DocumentDriveDocument>>;
253
- addDriveOperations(driveId: string, operations: Operation<DocumentDriveAction | BaseAction>[], options?: AddOperationOptions): Promise<IOperationResult<DocumentDriveDocument>>;
254
- queueDriveOperation(driveId: string, operation: Operation<DocumentDriveAction | BaseAction>, options?: AddOperationOptions): Promise<IOperationResult<DocumentDriveDocument>>;
255
- queueDriveOperations(driveId: string, operations: Operation<DocumentDriveAction | BaseAction>[], options?: AddOperationOptions): Promise<IOperationResult<DocumentDriveDocument>>;
256
- queueDriveAction(driveId: string, action: DocumentDriveAction | BaseAction, options?: AddOperationOptions): Promise<IOperationResult<DocumentDriveDocument>>;
257
- queueDriveActions(driveId: string, actions: Array<DocumentDriveAction | BaseAction>, options?: AddOperationOptions): Promise<IOperationResult<DocumentDriveDocument>>;
258
- addAction(driveId: string, documentId: string, action: Action, options?: AddOperationOptions): Promise<IOperationResult>;
259
- addActions(driveId: string, documentId: string, actions: Action[], options?: AddOperationOptions): Promise<IOperationResult>;
260
- addDriveAction(driveId: string, action: DocumentDriveAction | BaseAction, options?: AddOperationOptions): Promise<IOperationResult<DocumentDriveDocument>>;
261
- addDriveActions(driveId: string, actions: (DocumentDriveAction | BaseAction)[], options?: AddOperationOptions): Promise<IOperationResult<DocumentDriveDocument>>;
262
- getSyncStatus(syncUnitId: string): SyncStatus | SynchronizationUnitNotFoundError;
263
- addInternalListener(driveId: string, receiver: IReceiver, options: {
264
- listenerId: string;
265
- label: string;
266
- block: boolean;
267
- filter: ListenerFilter;
268
- }): Promise<IInternalTransmitter>;
269
- /** Synchronization methods */
270
- getSynchronizationUnits(driveId: string, documentId?: string[], scope?: string[], branch?: string[], documentType?: string[], loadedDrive?: DocumentDriveDocument): Promise<SynchronizationUnit[]>;
271
- getSynchronizationUnit(driveId: string, syncId: string, loadedDrive?: DocumentDriveDocument): Promise<SynchronizationUnit | undefined>;
272
- getSynchronizationUnitsIds(driveId: string, documentId?: string[], scope?: string[], branch?: string[], documentType?: string[]): Promise<SynchronizationUnitQuery[]>;
273
- getOperationData(driveId: string, syncId: string, filter: GetStrandsOptions, loadedDrive?: DocumentDriveDocument): Promise<OperationUpdate[]>;
274
- /** Internal methods **/
275
- getDocumentModels(): DocumentModel[];
276
- getTransmitter(driveId: string, listenerId: string): Promise<ITransmitter | undefined>;
277
- clearStorage(): Promise<void>;
278
- registerPullResponderTrigger(id: string, url: string, options: Pick<RemoteDriveOptions, "pullFilter" | "pullInterval">): Promise<PullResponderTrigger>;
279
- on<K extends keyof DriveEvents>(event: K, cb: DriveEvents[K]): Unsubscribe;
280
- }
281
- type IDocumentDriveServer = IBaseDocumentDriveServer & IDefaultDrivesManager & IReadModeDriveServer;
282
-
283
- type ProcessorUpdate<D extends Document = Document, S extends OperationScope = OperationScope> = InternalTransmitterUpdate<D, S>;
284
- declare abstract class Processor<D extends Document = Document, S extends OperationScope = OperationScope> implements IProcessor<D, S> {
285
- protected reactor: IDocumentDriveServer;
286
- protected processorOptions: ProcessorOptions;
287
- constructor(args: ProcessorSetupArgs, options?: ProcessorOptions);
288
- onSetup(args: ProcessorSetupArgs): void;
289
- abstract onStrands(strands: ProcessorUpdate<D, S>[]): Promise<void>;
290
- abstract onDisconnect(): Promise<void>;
291
- getOptions(): ProcessorOptions;
292
- }
293
- declare class BaseProcessor extends Processor {
294
- onStrands(strands: ProcessorUpdate[]): Promise<void>;
295
- onDisconnect(): Promise<void>;
296
- }
297
- type ProcessorClass = typeof BaseProcessor;
298
- declare function isProcessorClass(candidate: unknown): candidate is ProcessorClass;
299
-
300
- type Context = {
301
- driveServer: IDocumentDriveServer;
302
- driveId?: string;
303
- headers: IncomingHttpHeaders;
304
- db: unknown;
305
- };
306
- type ISubgraph = {
307
- name: string;
308
- resolvers: Record<string, any>;
309
- typeDefs: DocumentNode;
310
- reactor: IDocumentDriveServer;
311
- operationalStore: Db;
312
- onSetup?: () => Promise<void>;
313
- };
314
- type SubgraphArgs = {
315
- reactor: IDocumentDriveServer;
316
- operationalStore: Db;
317
- analyticsStore: IAnalyticsStore;
318
- subgraphManager: SubgraphManager;
319
- };
320
-
321
- declare class Subgraph implements ISubgraph {
322
- name: string;
323
- resolvers: Record<string, any>;
324
- typeDefs: DocumentNode;
325
- reactor: IDocumentDriveServer;
326
- subgraphManager: SubgraphManager;
327
- operationalStore: Db;
328
- constructor(args: SubgraphArgs);
329
- onSetup(): Promise<void>;
330
- }
331
-
332
- declare class AnalyticsSubgraph extends Subgraph {
333
- #private;
334
- analyticsStore: IAnalyticsStore;
335
- analyticsModel: AnalyticsModel;
336
- name: string;
337
- typeDefs: graphql.DocumentNode;
338
- resolvers: GraphQLResolverMap<Context>;
339
- constructor(args: SubgraphArgs);
340
- onSetup(): Promise<void>;
341
- }
342
-
343
- type index$3_AnalyticsSubgraph = AnalyticsSubgraph;
344
- declare const index$3_AnalyticsSubgraph: typeof AnalyticsSubgraph;
345
- declare namespace index$3 {
346
- export { index$3_AnalyticsSubgraph as AnalyticsSubgraph };
347
- }
348
-
349
- declare class DriveSubgraph extends Subgraph {
350
- private debugID;
351
- constructor(args: SubgraphArgs);
352
- private debugLog;
353
- name: string;
354
- typeDefs: graphql.DocumentNode;
355
- resolvers: GraphQLResolverMap$1<Context>;
356
- }
357
-
358
- type index$2_DriveSubgraph = DriveSubgraph;
359
- declare const index$2_DriveSubgraph: typeof DriveSubgraph;
360
- declare namespace index$2 {
361
- export { index$2_DriveSubgraph as DriveSubgraph };
362
- }
363
-
364
- interface Session {
365
- id: string;
366
- userId: string;
367
- address: string;
368
- name?: string;
369
- expiresAt: string;
370
- createdAt: string;
371
- updatedAt: string;
372
- revokedAt: string | null;
373
- allowedOrigins: string;
374
- referenceExpiryDate: string;
375
- referenceTokenId: string;
376
- isUserCreated: boolean;
377
- createdBy: string;
378
- }
379
- type AuthContext = Context & {
380
- session: Session;
381
- };
382
-
383
- type SystemContext = AuthContext & {
384
- isAdmin: (ctx: AuthContext) => boolean;
385
- };
386
-
387
- declare class SystemSubgraph extends Subgraph {
388
- name: string;
389
- typeDefs: graphql.DocumentNode;
390
- resolvers: {
391
- Query: {
392
- drives: () => Promise<string[]>;
393
- };
394
- Mutation: {
395
- addDrive: (parent: unknown, args: DriveInput, ctx: SystemContext) => Promise<document_model_libs_document_drive.DocumentDriveState>;
396
- };
397
- };
398
- onSetup(): Promise<void>;
399
- }
400
-
401
- type index$1_SystemSubgraph = SystemSubgraph;
402
- declare const index$1_SystemSubgraph: typeof SystemSubgraph;
403
- declare namespace index$1 {
404
- export { index$1_SystemSubgraph as SystemSubgraph };
405
- }
406
-
407
- declare class AuthSubgraph extends Subgraph {
408
- #private;
409
- name: string;
410
- typeDefs: graphql.DocumentNode;
411
- resolvers: GraphQLResolverMap$1<AuthContext>;
412
- onSetup(): Promise<void>;
413
- }
414
-
415
- type index_AuthSubgraph = AuthSubgraph;
416
- declare const index_AuthSubgraph: typeof AuthSubgraph;
417
- declare namespace index {
418
- export { index_AuthSubgraph as AuthSubgraph };
419
- }
420
-
421
- type SubgraphClass = typeof Subgraph;
422
- declare function isSubgraphClass(candidate: unknown): candidate is SubgraphClass;
423
-
424
- declare class SubgraphManager {
425
- #private;
426
- private readonly path;
427
- private readonly app;
428
- private readonly reactor;
429
- private readonly operationalStore;
430
- private readonly analyticsStore;
431
- private reactorRouter;
432
- private contextFields;
433
- private subgraphs;
434
- constructor(path: string, app: express.Express, reactor: IDocumentDriveServer, operationalStore: Db, analyticsStore: IAnalyticsStore);
435
- init(): Promise<void>;
436
- updateRouter(): Promise<void>;
437
- registerSubgraph(subgraph: SubgraphClass): Promise<void>;
438
- getAdditionalContextFields: () => Record<string, any>;
439
- setAdditionalContextFields(fields: Record<string, any>): void;
440
- }
441
-
442
- type Db = Knex;
443
- declare function getDbClient(connectionString?: string | undefined): Db;
444
-
445
- declare abstract class AnalyticsProcessor<D extends Document = Document, S extends OperationScope = OperationScope> extends Processor<D, S> {
446
- protected analyticsStore: IAnalyticsStore;
447
- constructor(args: ProcessorSetupArgs, options?: ProcessorOptions);
448
- }
449
-
450
- type IProcessorManager = {
451
- registerProcessor(module: IProcessor | ProcessorClass): Promise<IProcessor>;
452
- };
453
- type API = {
454
- app: Express;
455
- subgraphManager: SubgraphManager;
456
- processorManager: IProcessorManager;
457
- };
458
- type ProcessorType = "analytics" | "operational";
459
- type ProcessorSetupArgs = {
460
- reactor: IDocumentDriveServer;
461
- operationalStore: Db;
462
- analyticsStore: IAnalyticsStore;
463
- };
464
- type IProcessor<D extends Document = Document, S extends OperationScope = OperationScope> = IReceiver<D, S> & {
465
- onSetup?: (args: ProcessorSetupArgs) => void;
466
- getOptions: () => ProcessorOptions;
467
- };
468
- type ProcessorOptions = Omit<Listener, "driveId"> & {
469
- label: string;
470
- };
471
-
472
- type Options = {
473
- express?: Express;
474
- port?: number;
475
- dbPath: string | undefined;
476
- client?: PGlite | typeof Pool | undefined;
477
- https?: {
478
- keyPath: string;
479
- certPath: string;
480
- };
481
- };
482
- declare function startAPI(reactor: IDocumentDriveServer, options: Options): Promise<API>;
483
-
484
- declare const createSchema: (documentDriveServer: IDocumentDriveServer, resolvers: GraphQLResolverMap$1<Context>, typeDefs: DocumentNode) => graphql.GraphQLSchema;
485
- declare const getDocumentModelTypeDefs: (documentDriveServer: IDocumentDriveServer, typeDefs: DocumentNode) => DocumentNode;
486
-
487
- declare abstract class OperationalProcessor<D extends Document = Document, S extends OperationScope = OperationScope> extends Processor<D, S> {
488
- protected operationalStore: Db;
489
- constructor(args: ProcessorSetupArgs, options?: ProcessorOptions);
490
- onSetup(args: ProcessorSetupArgs): void;
491
- }
492
-
493
- declare class ProcessorManager implements IProcessorManager {
494
- #private;
495
- private operationalStore;
496
- private analyticsStore;
497
- private reactor;
498
- private processors;
499
- constructor(driveServer: IDocumentDriveServer, operationalStore: Db, analyticsStore: IAnalyticsStore);
500
- registerProcessor(module: IProcessor | ProcessorClass): Promise<IProcessor>;
501
- }
502
-
503
- export { type API, AnalyticsProcessor, BaseProcessor, type Context, type Db, type IProcessor, type IProcessorManager, type ISubgraph, OperationalProcessor, Processor, type ProcessorClass, ProcessorManager, type ProcessorOptions, type ProcessorSetupArgs, type ProcessorType, type ProcessorUpdate, Subgraph, type SubgraphArgs, type SubgraphClass, SubgraphManager, index$3 as analyticsSubgraph, index as authSubgraph, createSchema, index$2 as driveSubgraph, getDbClient, getDocumentModelTypeDefs, isProcessorClass, isSubgraphClass, startAPI, index$1 as systemSubgraph };
1
+ export * from "./src/server.js";
2
+ export * from "./src/subgraphs/manager.js";
3
+ export * from "./src/utils/index.js";
4
+ export * from "./src/processors/index.js";
5
+ export * from "./src/types.js";
6
+ export * from "./src/subgraphs/index.js";
7
+ export * from "@powerhousedao/analytics-engine-core";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,sCAAsC,CAAC"}