@xyo-network/diviner-stateful 2.90.23 → 2.91.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/dist/browser/Config.d.cts +4 -3
- package/dist/browser/Config.d.cts.map +1 -1
- package/dist/browser/Config.d.mts +4 -3
- package/dist/browser/Config.d.mts.map +1 -1
- package/dist/browser/Config.d.ts +4 -3
- package/dist/browser/Config.d.ts.map +1 -1
- package/dist/browser/Diviner.d.cts +12 -12
- package/dist/browser/Diviner.d.cts.map +1 -1
- package/dist/browser/Diviner.d.mts +12 -12
- package/dist/browser/Diviner.d.mts.map +1 -1
- package/dist/browser/Diviner.d.ts +12 -12
- package/dist/browser/Diviner.d.ts.map +1 -1
- package/dist/browser/DivinerMixin.d.cts +147 -64
- package/dist/browser/DivinerMixin.d.cts.map +1 -1
- package/dist/browser/DivinerMixin.d.mts +147 -64
- package/dist/browser/DivinerMixin.d.mts.map +1 -1
- package/dist/browser/DivinerMixin.d.ts +147 -64
- package/dist/browser/DivinerMixin.d.ts.map +1 -1
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/node/Config.d.cts +4 -3
- package/dist/node/Config.d.cts.map +1 -1
- package/dist/node/Config.d.mts +4 -3
- package/dist/node/Config.d.mts.map +1 -1
- package/dist/node/Config.d.ts +4 -3
- package/dist/node/Config.d.ts.map +1 -1
- package/dist/node/Diviner.d.cts +12 -12
- package/dist/node/Diviner.d.cts.map +1 -1
- package/dist/node/Diviner.d.mts +12 -12
- package/dist/node/Diviner.d.mts.map +1 -1
- package/dist/node/Diviner.d.ts +12 -12
- package/dist/node/Diviner.d.ts.map +1 -1
- package/dist/node/DivinerMixin.d.cts +147 -64
- package/dist/node/DivinerMixin.d.cts.map +1 -1
- package/dist/node/DivinerMixin.d.mts +147 -64
- package/dist/node/DivinerMixin.d.mts.map +1 -1
- package/dist/node/DivinerMixin.d.ts +147 -64
- package/dist/node/DivinerMixin.d.ts.map +1 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +22 -21
- package/src/Config.ts +4 -3
- package/src/Diviner.ts +3 -2
- package/src/DivinerMixin.ts +3 -2
|
@@ -21,8 +21,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
21
21
|
schema: "network.xyo.diviner.stateful.config";
|
|
22
22
|
readonly security?: {
|
|
23
23
|
readonly allowAnonymous?: boolean | undefined;
|
|
24
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
25
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
24
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
25
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
26
26
|
} | undefined;
|
|
27
27
|
readonly sign?: boolean | undefined;
|
|
28
28
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -38,8 +38,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
38
38
|
schema: "network.xyo.diviner.stateful.config";
|
|
39
39
|
readonly security?: {
|
|
40
40
|
readonly allowAnonymous?: boolean | undefined;
|
|
41
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
42
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
41
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
42
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
43
43
|
} | undefined;
|
|
44
44
|
readonly sign?: boolean | undefined;
|
|
45
45
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -70,8 +70,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
70
70
|
schema: "network.xyo.diviner.stateful.config";
|
|
71
71
|
readonly security?: {
|
|
72
72
|
readonly allowAnonymous?: boolean | undefined;
|
|
73
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
74
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
73
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
74
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
75
75
|
} | undefined;
|
|
76
76
|
readonly sign?: boolean | undefined;
|
|
77
77
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -87,8 +87,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
87
87
|
schema: "network.xyo.diviner.stateful.config";
|
|
88
88
|
readonly security?: {
|
|
89
89
|
readonly allowAnonymous?: boolean | undefined;
|
|
90
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
91
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
90
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
91
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
92
92
|
} | undefined;
|
|
93
93
|
readonly sign?: boolean | undefined;
|
|
94
94
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -134,8 +134,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
134
134
|
schema: "network.xyo.archivist.config";
|
|
135
135
|
readonly security?: {
|
|
136
136
|
readonly allowAnonymous?: boolean | undefined;
|
|
137
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
138
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
137
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
138
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
139
139
|
} | undefined;
|
|
140
140
|
readonly sign?: boolean | undefined;
|
|
141
141
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -151,8 +151,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
151
151
|
schema: "network.xyo.archivist.config";
|
|
152
152
|
readonly security?: {
|
|
153
153
|
readonly allowAnonymous?: boolean | undefined;
|
|
154
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
155
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
154
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
155
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
156
156
|
} | undefined;
|
|
157
157
|
readonly sign?: boolean | undefined;
|
|
158
158
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -187,8 +187,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
187
187
|
schema: "network.xyo.diviner.config";
|
|
188
188
|
readonly security?: {
|
|
189
189
|
readonly allowAnonymous?: boolean | undefined;
|
|
190
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
191
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
190
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
191
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
192
192
|
} | undefined;
|
|
193
193
|
readonly sign?: boolean | undefined;
|
|
194
194
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -204,8 +204,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
204
204
|
schema: "network.xyo.diviner.config";
|
|
205
205
|
readonly security?: {
|
|
206
206
|
readonly allowAnonymous?: boolean | undefined;
|
|
207
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
208
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
207
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
208
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
209
209
|
} | undefined;
|
|
210
210
|
readonly sign?: boolean | undefined;
|
|
211
211
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -239,8 +239,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
239
239
|
schema: "network.xyo.diviner.config";
|
|
240
240
|
readonly security?: {
|
|
241
241
|
readonly allowAnonymous?: boolean | undefined;
|
|
242
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
243
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
242
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
243
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
244
244
|
} | undefined;
|
|
245
245
|
readonly sign?: boolean | undefined;
|
|
246
246
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -256,8 +256,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
256
256
|
schema: "network.xyo.diviner.config";
|
|
257
257
|
readonly security?: {
|
|
258
258
|
readonly allowAnonymous?: boolean | undefined;
|
|
259
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
260
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
259
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
260
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
261
261
|
} | undefined;
|
|
262
262
|
readonly sign?: boolean | undefined;
|
|
263
263
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -278,23 +278,103 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
278
278
|
* preemptions, reboots, etc.
|
|
279
279
|
*/
|
|
280
280
|
retrieveState(): Promise<WithMeta<ModuleState<TState>> | undefined>;
|
|
281
|
-
readonly downResolver: Omit<import("@xyo-network/module-model").
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
readonly downResolver: Omit<import("@xyo-network/module-model").ObjectResolverInstance<ModuleInstance<import("@xylabs/object").BaseParamsFields & {
|
|
282
|
+
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
283
|
+
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
284
|
+
readonly archivist?: string | undefined;
|
|
285
|
+
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
286
|
+
readonly name?: string | undefined;
|
|
287
|
+
readonly paging?: Record<string, {
|
|
288
|
+
size?: number | undefined;
|
|
289
|
+
}> | undefined;
|
|
290
|
+
readonly retry?: import("@xylabs/retry").RetryConfig | undefined;
|
|
291
|
+
schema: "network.xyo.module.config";
|
|
292
|
+
readonly security?: {
|
|
293
|
+
readonly allowAnonymous?: boolean | undefined;
|
|
294
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
295
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
296
|
+
} | undefined;
|
|
297
|
+
readonly sign?: boolean | undefined;
|
|
298
|
+
readonly storeQueries?: boolean | undefined;
|
|
299
|
+
readonly timestamp?: boolean | undefined;
|
|
300
|
+
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
301
|
+
readonly archivist?: string | undefined;
|
|
302
|
+
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
303
|
+
readonly name?: string | undefined;
|
|
304
|
+
readonly paging?: Record<string, {
|
|
305
|
+
size?: number | undefined;
|
|
306
|
+
}> | undefined;
|
|
307
|
+
readonly retry?: import("@xylabs/retry").RetryConfig | undefined;
|
|
308
|
+
schema: "network.xyo.module.config";
|
|
309
|
+
readonly security?: {
|
|
310
|
+
readonly allowAnonymous?: boolean | undefined;
|
|
311
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
312
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
313
|
+
} | undefined;
|
|
314
|
+
readonly sign?: boolean | undefined;
|
|
315
|
+
readonly storeQueries?: boolean | undefined;
|
|
316
|
+
readonly timestamp?: boolean | undefined;
|
|
317
|
+
}, "schema"> & {
|
|
318
|
+
schema: string;
|
|
319
|
+
};
|
|
320
|
+
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
321
|
+
}, import("@xyo-network/module-model").ModuleEventData<object>>>, "resolve">;
|
|
322
|
+
readonly pipeline?: "one-to-one" | "one-to-many" | "many-to-one" | "many-to-many" | undefined;
|
|
323
|
+
readonly upResolver: Omit<import("@xyo-network/module-model").ObjectResolverInstance<ModuleInstance<import("@xylabs/object").BaseParamsFields & {
|
|
324
|
+
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
325
|
+
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
326
|
+
readonly archivist?: string | undefined;
|
|
327
|
+
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
328
|
+
readonly name?: string | undefined;
|
|
329
|
+
readonly paging?: Record<string, {
|
|
330
|
+
size?: number | undefined;
|
|
331
|
+
}> | undefined;
|
|
332
|
+
readonly retry?: import("@xylabs/retry").RetryConfig | undefined;
|
|
333
|
+
schema: "network.xyo.module.config";
|
|
334
|
+
readonly security?: {
|
|
335
|
+
readonly allowAnonymous?: boolean | undefined;
|
|
336
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
337
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
338
|
+
} | undefined;
|
|
339
|
+
readonly sign?: boolean | undefined;
|
|
340
|
+
readonly storeQueries?: boolean | undefined;
|
|
341
|
+
readonly timestamp?: boolean | undefined;
|
|
342
|
+
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
343
|
+
readonly archivist?: string | undefined;
|
|
344
|
+
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
345
|
+
readonly name?: string | undefined;
|
|
346
|
+
readonly paging?: Record<string, {
|
|
347
|
+
size?: number | undefined;
|
|
348
|
+
}> | undefined;
|
|
349
|
+
readonly retry?: import("@xylabs/retry").RetryConfig | undefined;
|
|
350
|
+
schema: "network.xyo.module.config";
|
|
351
|
+
readonly security?: {
|
|
352
|
+
readonly allowAnonymous?: boolean | undefined;
|
|
353
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
354
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
355
|
+
} | undefined;
|
|
356
|
+
readonly sign?: boolean | undefined;
|
|
357
|
+
readonly storeQueries?: boolean | undefined;
|
|
358
|
+
readonly timestamp?: boolean | undefined;
|
|
359
|
+
}, "schema"> & {
|
|
360
|
+
schema: string;
|
|
361
|
+
};
|
|
362
|
+
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
363
|
+
}, import("@xyo-network/module-model").ModuleEventData<object>>>, "resolve">;
|
|
364
|
+
address: Lowercase<string>;
|
|
285
365
|
config: TParams["config"];
|
|
286
366
|
id: string;
|
|
287
367
|
params: TParams;
|
|
288
368
|
previousHash: () => import("@xylabs/promise").Promisable<string | undefined>;
|
|
289
369
|
queries: string[];
|
|
290
370
|
query: <T extends import("@xyo-network/payload-model").SchemaFields & object & Omit<import("@xyo-network/boundwitness-model").BoundWitnessFields & {
|
|
291
|
-
query: string
|
|
371
|
+
query: Lowercase<string>;
|
|
292
372
|
resultSet?: string | undefined;
|
|
293
373
|
schema: "network.xyo.boundwitness";
|
|
294
374
|
}, "schema"> & {
|
|
295
375
|
schema: "network.xyo.boundwitness";
|
|
296
376
|
} = import("@xyo-network/payload-model").SchemaFields & object & Omit<import("@xyo-network/boundwitness-model").BoundWitnessFields & {
|
|
297
|
-
query: string
|
|
377
|
+
query: Lowercase<string>;
|
|
298
378
|
resultSet?: string | undefined;
|
|
299
379
|
schema: "network.xyo.boundwitness";
|
|
300
380
|
}, "schema"> & {
|
|
@@ -310,8 +390,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
310
390
|
schema: "network.xyo.module.config";
|
|
311
391
|
readonly security?: {
|
|
312
392
|
readonly allowAnonymous?: boolean | undefined;
|
|
313
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
314
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
393
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
394
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
315
395
|
} | undefined;
|
|
316
396
|
readonly sign?: boolean | undefined;
|
|
317
397
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -327,8 +407,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
327
407
|
schema: "network.xyo.module.config";
|
|
328
408
|
readonly security?: {
|
|
329
409
|
readonly allowAnonymous?: boolean | undefined;
|
|
330
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
331
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
410
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
411
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
332
412
|
} | undefined;
|
|
333
413
|
readonly sign?: boolean | undefined;
|
|
334
414
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -337,13 +417,13 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
337
417
|
schema: string;
|
|
338
418
|
} & object)[] | undefined, queryConfig?: TConf | undefined) => import("@xylabs/promise").Promisable<import("@xyo-network/module-model").ModuleQueryResult>;
|
|
339
419
|
queryable: <T_1 extends import("@xyo-network/payload-model").SchemaFields & object & Omit<import("@xyo-network/boundwitness-model").BoundWitnessFields & {
|
|
340
|
-
query: string
|
|
420
|
+
query: Lowercase<string>;
|
|
341
421
|
resultSet?: string | undefined;
|
|
342
422
|
schema: "network.xyo.boundwitness";
|
|
343
423
|
}, "schema"> & {
|
|
344
424
|
schema: "network.xyo.boundwitness";
|
|
345
425
|
} = import("@xyo-network/payload-model").SchemaFields & object & Omit<import("@xyo-network/boundwitness-model").BoundWitnessFields & {
|
|
346
|
-
query: string
|
|
426
|
+
query: Lowercase<string>;
|
|
347
427
|
resultSet?: string | undefined;
|
|
348
428
|
schema: "network.xyo.boundwitness";
|
|
349
429
|
}, "schema"> & {
|
|
@@ -359,8 +439,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
359
439
|
schema: "network.xyo.module.config";
|
|
360
440
|
readonly security?: {
|
|
361
441
|
readonly allowAnonymous?: boolean | undefined;
|
|
362
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
363
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
442
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
443
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
364
444
|
} | undefined;
|
|
365
445
|
readonly sign?: boolean | undefined;
|
|
366
446
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -376,8 +456,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
376
456
|
schema: "network.xyo.module.config";
|
|
377
457
|
readonly security?: {
|
|
378
458
|
readonly allowAnonymous?: boolean | undefined;
|
|
379
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
380
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
459
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
460
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
381
461
|
} | undefined;
|
|
382
462
|
readonly sign?: boolean | undefined;
|
|
383
463
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -410,8 +490,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
410
490
|
schema: "network.xyo.module.config";
|
|
411
491
|
readonly security?: {
|
|
412
492
|
readonly allowAnonymous?: boolean | undefined;
|
|
413
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
414
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
493
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
494
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
415
495
|
} | undefined;
|
|
416
496
|
readonly sign?: boolean | undefined;
|
|
417
497
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -427,8 +507,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
427
507
|
schema: "network.xyo.module.config";
|
|
428
508
|
readonly security?: {
|
|
429
509
|
readonly allowAnonymous?: boolean | undefined;
|
|
430
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
431
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
510
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
511
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
432
512
|
} | undefined;
|
|
433
513
|
readonly sign?: boolean | undefined;
|
|
434
514
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -450,8 +530,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
450
530
|
schema: "network.xyo.module.config";
|
|
451
531
|
readonly security?: {
|
|
452
532
|
readonly allowAnonymous?: boolean | undefined;
|
|
453
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
454
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
533
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
534
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
455
535
|
} | undefined;
|
|
456
536
|
readonly sign?: boolean | undefined;
|
|
457
537
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -467,8 +547,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
467
547
|
schema: "network.xyo.module.config";
|
|
468
548
|
readonly security?: {
|
|
469
549
|
readonly allowAnonymous?: boolean | undefined;
|
|
470
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
471
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
550
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
551
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
472
552
|
} | undefined;
|
|
473
553
|
readonly sign?: boolean | undefined;
|
|
474
554
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -477,7 +557,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
477
557
|
schema: string;
|
|
478
558
|
};
|
|
479
559
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
480
|
-
}, import("@xyo-network/module-model").ModuleEventData<object>>>(filter?: import("@xyo-network/module-model").
|
|
560
|
+
}, import("@xyo-network/module-model").ModuleEventData<object>>>(filter?: import("@xyo-network/module-model").ObjectFilter<T_2> | undefined, options?: import("@xyo-network/module-model").ObjectFilterOptions<T_2> | undefined): import("@xylabs/promise").Promisable<T_2[]>;
|
|
481
561
|
resolve<T_3 extends ModuleInstance<import("@xylabs/object").BaseParamsFields & {
|
|
482
562
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
483
563
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
@@ -491,8 +571,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
491
571
|
schema: "network.xyo.module.config";
|
|
492
572
|
readonly security?: {
|
|
493
573
|
readonly allowAnonymous?: boolean | undefined;
|
|
494
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
495
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
574
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
575
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
496
576
|
} | undefined;
|
|
497
577
|
readonly sign?: boolean | undefined;
|
|
498
578
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -508,8 +588,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
508
588
|
schema: "network.xyo.module.config";
|
|
509
589
|
readonly security?: {
|
|
510
590
|
readonly allowAnonymous?: boolean | undefined;
|
|
511
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
512
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
591
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
592
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
513
593
|
} | undefined;
|
|
514
594
|
readonly sign?: boolean | undefined;
|
|
515
595
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -531,8 +611,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
531
611
|
schema: "network.xyo.module.config";
|
|
532
612
|
readonly security?: {
|
|
533
613
|
readonly allowAnonymous?: boolean | undefined;
|
|
534
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
535
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
614
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
615
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
536
616
|
} | undefined;
|
|
537
617
|
readonly sign?: boolean | undefined;
|
|
538
618
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -548,8 +628,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
548
628
|
schema: "network.xyo.module.config";
|
|
549
629
|
readonly security?: {
|
|
550
630
|
readonly allowAnonymous?: boolean | undefined;
|
|
551
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
552
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
631
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
632
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
553
633
|
} | undefined;
|
|
554
634
|
readonly sign?: boolean | undefined;
|
|
555
635
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -558,7 +638,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
558
638
|
schema: string;
|
|
559
639
|
};
|
|
560
640
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
561
|
-
}, import("@xyo-network/module-model").ModuleEventData<object>>>(nameOrAddress: string, options?: import("@xyo-network/module-model").
|
|
641
|
+
}, import("@xyo-network/module-model").ModuleEventData<object>>>(nameOrAddress: string, options?: import("@xyo-network/module-model").ObjectFilterOptions<T_3> | undefined): import("@xylabs/promise").Promisable<T_3 | undefined>;
|
|
562
642
|
resolve<T_4 extends ModuleInstance<import("@xylabs/object").BaseParamsFields & {
|
|
563
643
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
564
644
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
@@ -572,8 +652,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
572
652
|
schema: "network.xyo.module.config";
|
|
573
653
|
readonly security?: {
|
|
574
654
|
readonly allowAnonymous?: boolean | undefined;
|
|
575
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
576
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
655
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
656
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
577
657
|
} | undefined;
|
|
578
658
|
readonly sign?: boolean | undefined;
|
|
579
659
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -589,8 +669,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
589
669
|
schema: "network.xyo.module.config";
|
|
590
670
|
readonly security?: {
|
|
591
671
|
readonly allowAnonymous?: boolean | undefined;
|
|
592
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
593
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
672
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
673
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
594
674
|
} | undefined;
|
|
595
675
|
readonly sign?: boolean | undefined;
|
|
596
676
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -612,8 +692,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
612
692
|
schema: "network.xyo.module.config";
|
|
613
693
|
readonly security?: {
|
|
614
694
|
readonly allowAnonymous?: boolean | undefined;
|
|
615
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
616
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
695
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
696
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
617
697
|
} | undefined;
|
|
618
698
|
readonly sign?: boolean | undefined;
|
|
619
699
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -629,8 +709,8 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
629
709
|
schema: "network.xyo.module.config";
|
|
630
710
|
readonly security?: {
|
|
631
711
|
readonly allowAnonymous?: boolean | undefined;
|
|
632
|
-
readonly allowed?: Record<string, (string | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
633
|
-
readonly disallowed?: Record<string, string[]> | undefined;
|
|
712
|
+
readonly allowed?: Record<string, (Lowercase<string> | import("@xyo-network/module-model").CosigningAddressSet)[]> | undefined;
|
|
713
|
+
readonly disallowed?: Record<string, Lowercase<string>[]> | undefined;
|
|
634
714
|
} | undefined;
|
|
635
715
|
readonly sign?: boolean | undefined;
|
|
636
716
|
readonly storeQueries?: boolean | undefined;
|
|
@@ -639,7 +719,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
639
719
|
schema: string;
|
|
640
720
|
};
|
|
641
721
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
642
|
-
}, import("@xyo-network/module-model").ModuleEventData<object>>>(nameOrAddressOrFilter?: string | import("@xyo-network/module-model").
|
|
722
|
+
}, import("@xyo-network/module-model").ModuleEventData<object>>>(nameOrAddressOrFilter?: string | import("@xyo-network/module-model").ObjectFilter<T_4> | undefined, options?: import("@xyo-network/module-model").ObjectFilterOptions<T_4> | undefined): import("@xylabs/promise").Promisable<T_4 | T_4[] | undefined>;
|
|
643
723
|
describe: () => Promise<import("@xyo-network/module-model").ModuleDescription>;
|
|
644
724
|
discover: () => import("@xylabs/promise").Promisable<({
|
|
645
725
|
schema: string;
|
|
@@ -650,9 +730,12 @@ export declare const StatefulModuleMixin: <TParams extends import("@xylabs/objec
|
|
|
650
730
|
schema: "network.xyo.node.manifest";
|
|
651
731
|
})>;
|
|
652
732
|
moduleAddress: () => import("@xylabs/promise").Promisable<(import("@xyo-network/payload-model").SchemaFields & object & {
|
|
653
|
-
address: string
|
|
733
|
+
address: Lowercase<string>;
|
|
654
734
|
previousHash?: string | undefined;
|
|
655
735
|
schema: string;
|
|
656
736
|
})[]>;
|
|
737
|
+
state: () => import("@xylabs/promise").Promisable<({
|
|
738
|
+
schema: string;
|
|
739
|
+
} & object)[]>;
|
|
657
740
|
}) & TModule;
|
|
658
741
|
//# sourceMappingURL=DivinerMixin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DivinerMixin.d.ts","sourceRoot":"","sources":["../../src/DivinerMixin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DivinerMixin.d.ts","sourceRoot":"","sources":["../../src/DivinerMixin.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,eAAe,EAEf,cAAc,EACd,YAAY,EACZ,WAAW,EAEX,eAAe,EAChB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAEhD,MAAM,MAAM,oBA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
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/Schema.ts","../../src/Config.ts","../../src/Diviner.ts","../../src/DivinerMixin.ts"],"sourcesContent":["export * from './Config'\nexport * from './Diviner'\nexport * from './DivinerMixin'\nexport * from './Params'\nexport * from './Schema'\n","export const StatefulDivinerSchema = 'network.xyo.diviner.stateful' as const\nexport type StatefulDivinerSchema = typeof StatefulDivinerSchema\n","import { DivinerConfig } from '@xyo-network/diviner-model'\n\nimport { StatefulDivinerSchema } from './Schema'\n\n/**\n * The schema for a Stateful Diviner config\n */\nexport const StatefulDivinerConfigSchema = `${StatefulDivinerSchema}.config` as const\n/**\n * The schema for a Stateful Diviner config\n */\nexport type StatefulDivinerConfigSchema = typeof StatefulDivinerConfigSchema\n\n/**\n * The config for a Stateful Diviner\n */\nexport type StatefulDivinerConfig = DivinerConfig<{\n schema: StatefulDivinerConfigSchema\n stateStore: {\n archivist: string\n boundWitnessDiviner: string\n payloadDiviner: string\n }\n}>\n","import { assertEx } from '@xylabs/assert'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { DivinerConfigSchema, DivinerModule, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport { isModuleState, ModuleState, ModuleStateSchema, StateDictionary } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { StatefulDivinerConfigSchema } from './Config'\nimport { StatefulDivinerParams } from './Params'\n\nconst moduleName = 'StatefulDiviner'\n\n/**\n * A Diviner that maintains state\n */\nexport abstract class StatefulDiviner<\n TParams extends StatefulDivinerParams = StatefulDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\n TEventData extends DivinerModuleEventData<DivinerModule<TParams>, TIn, TOut> = DivinerModuleEventData<DivinerModule<TParams>, TIn, TOut>,\n TState extends StateDictionary = StateDictionary,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: string[] = [DivinerConfigSchema, StatefulDivinerConfigSchema]\n\n /**\n * The last state\n */\n protected _lastState?: WithMeta<ModuleState<TState>>\n\n /**\n * Commit the internal state of the Diviner process. This is similar\n * to a transaction completion in a database and should only be called\n * when results have been successfully persisted to the appropriate\n * external stores.\n * @param nextState The state to commit\n */\n protected async commitState(nextState: WithMeta<ModuleState<TState>>) {\n // Don't commit state if no state has changed\n if (nextState.state.offset === this._lastState?.state.offset) return\n this._lastState = nextState\n const archivist = await this.getArchivistForStateStore()\n const [bw] = await (await new BoundWitnessBuilder().payload(nextState)).witness(this.account).build()\n await archivist.insert([bw, nextState])\n }\n\n /**\n * Retrieves the archivist for the specified store\n * @param store The store to retrieve the archivist for\n * @returns The archivist for the specified store\n */\n protected async getArchivistForStateStore() {\n const name = assertEx(this.config?.stateStore.archivist, () => `${moduleName}: Config for stateStore.archivist not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.archivist`)\n return ArchivistWrapper.wrap(mod, this.account)\n }\n\n /**\n * Retrieves the BoundWitness Diviner for the specified store\n * @param store The store to retrieve the BoundWitness Diviner for\n * @returns The BoundWitness Diviner for the specified store\n */\n protected async getBoundWitnessDivinerForStateStore() {\n const name = assertEx(this.config?.stateStore.boundWitnessDiviner, () => `${moduleName}: Config for stateStore.boundWitnessDiviner not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.boundWitnessDiviner`)\n return DivinerWrapper.wrap(mod, this.account)\n }\n\n /**\n * Retrieves the Payload Diviner for the specified store\n * @param store The store to retrieve the Payload Diviner for\n * @returns The Payload Diviner for the specified store\n */\n protected async getPayloadDivinerForStateStore() {\n const name = assertEx(this.config?.stateStore?.payloadDiviner, () => `${moduleName}: Config for stateStore.payloadDiviner not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.payloadDiviner`)\n return DivinerWrapper.wrap(mod, this.account)\n }\n\n /**\n * Retrieves the last state of the Diviner process. Used to recover state after\n * preemptions, reboots, etc.\n */\n protected async retrieveState(): Promise<WithMeta<ModuleState<TState>> | undefined> {\n if (this._lastState) return this._lastState\n let hash: string = ''\n const diviner = await this.getBoundWitnessDivinerForStateStore()\n const query = await new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({\n address: this.account.address,\n limit: 1,\n offset: 0,\n order: 'desc',\n payload_schemas: [ModuleStateSchema],\n })\n .build()\n const boundWitnesses = await diviner.divine([query])\n if (boundWitnesses.length > 0) {\n const boundWitness = boundWitnesses[0]\n if (isBoundWitness(boundWitness)) {\n // Find the index for this address in the BoundWitness that is a ModuleState\n hash = boundWitness.addresses\n .map((address, index) => ({ address, index }))\n .filter(({ address }) => address === this.account.address)\n // eslint-disable-next-line unicorn/no-array-reduce\n .reduce(\n (prev, curr) => (boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev),\n '',\n )\n }\n }\n\n // If we able to located the last state\n if (hash) {\n // Get last state\n const archivist = await this.getArchivistForStateStore()\n const payload = (await archivist.get([hash])).find(isModuleState<TState>)\n if (payload) {\n return payload as WithMeta<ModuleState<TState>>\n }\n }\n return undefined\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport {\n AnyConfigSchema,\n isModuleState,\n ModuleInstance,\n ModuleParams,\n ModuleState,\n ModuleStateSchema,\n StateDictionary,\n} from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { WithMeta } from '@xyo-network/payload-model'\n\nimport { StatefulDivinerConfig } from './Config'\n\nexport type StatefulModuleParams = ModuleParams<AnyConfigSchema<StatefulDivinerConfig>>\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyModule<TParams extends StatefulModuleParams = StatefulModuleParams> = new (...args: any[]) => ModuleInstance<TParams>\n\nconst moduleName = 'StatefulModuleMixin'\n\n/**\n * @ignore Inherit from StatefulDiviner instead\n * @param ModuleBase\n * @returns\n */\nexport const StatefulModuleMixin = <\n TParams extends StatefulModuleParams = StatefulModuleParams,\n TModule extends AnyModule<TParams> = AnyModule<TParams>,\n TState extends StateDictionary = StateDictionary,\n>(\n ModuleBase: TModule,\n) => {\n abstract class StatefulModuleBase extends ModuleBase {\n _lastState?: WithMeta<ModuleState<TState>>\n\n /**\n * Commit the internal state of the Diviner process. This is similar\n * to a transaction completion in a database and should only be called\n * when results have been successfully persisted to the appropriate\n * external stores.\n * @param nextState The state to commit\n */\n async commitState(nextState: WithMeta<ModuleState<TState>>) {\n // Don't commit state if no state has changed\n if (nextState.state.offset === this._lastState?.state.offset) return\n this._lastState = nextState\n const archivist = await this.getArchivistForStore()\n // const [bw] = await new BoundWitnessBuilder().payload(nextState).witness(this.account).build()\n const [bw] = await (await new BoundWitnessBuilder().payload(nextState)).build()\n await archivist.insert([bw, nextState])\n }\n\n /**\n * Retrieves the archivist for the specified store\n * @param store The store to retrieve the archivist for\n * @returns The archivist for the specified store\n */\n async getArchivistForStore() {\n const name = assertEx(this.config?.stateStore?.archivist, () => `${moduleName}: Config for stateStore.archivist not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.archivist`)\n // return ArchivistWrapper.wrap(mod, this.account)\n const instance = asArchivistInstance(mod)\n return assertEx(instance, () => `${moduleName}: Failed to wrap archivist instance`)\n }\n\n /**\n * Retrieves the BoundWitness Diviner for the specified store\n * @param store The store to retrieve the BoundWitness Diviner for\n * @returns The BoundWitness Diviner for the specified store\n */\n async getBoundWitnessDivinerForStore() {\n const name = assertEx(\n this.config?.stateStore?.boundWitnessDiviner,\n () => `${moduleName}: Config for stateStore.boundWitnessDiviner not specified`,\n )\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.boundWitnessDiviner`)\n // return DivinerWrapper.wrap(mod, this.account)\n const instance = asDivinerInstance(mod)\n return assertEx(instance, () => `${moduleName}: Failed to wrap diviner instance`)\n }\n /**\n * Retrieves the Payload Diviner for the specified store\n * @param store The store to retrieve the Payload Diviner for\n * @returns The Payload Diviner for the specified store\n */\n async getPayloadDivinerForStateStore() {\n const name = assertEx(this.config?.stateStore?.payloadDiviner, () => `${moduleName}: Config for stateStore.payloadDiviner not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.payloadDiviner`)\n // return DivinerWrapper.wrap(mod, this.account)\n const instance = asDivinerInstance(mod)\n return assertEx(instance, () => `${moduleName}: Failed to wrap diviner instance`)\n }\n /**\n * Retrieves the last state of the Diviner process. Used to recover state after\n * preemptions, reboots, etc.\n */\n async retrieveState(): Promise<WithMeta<ModuleState<TState>> | undefined> {\n if (this._lastState) return this._lastState\n let hash: string = ''\n const diviner = await this.getBoundWitnessDivinerForStore()\n const query = await new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({\n // address: this.account.address,\n limit: 1,\n offset: 0,\n order: 'desc',\n payload_schemas: [ModuleStateSchema],\n })\n .build()\n const boundWitnesses = await diviner.divine([query])\n if (boundWitnesses.length > 0) {\n const boundWitness = boundWitnesses[0]\n if (isBoundWitness(boundWitness)) {\n // Find the index for this address in the BoundWitness that is a ModuleState\n hash = boundWitness.addresses\n .map((address, index) => ({ address, index }))\n // .filter(({ address }) => address === this.account.address)\n // eslint-disable-next-line unicorn/no-array-reduce\n .reduce(\n (prev, curr) => (boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev),\n '',\n )\n }\n }\n\n // If we able to located the last state\n if (hash) {\n // Get last state\n const archivist = await this.getArchivistForStore()\n const payload = (await archivist.get([hash])).find(isModuleState<TState>)\n if (payload) {\n return payload as WithMeta<ModuleState<TState>>\n }\n }\n return undefined\n }\n }\n return StatefulModuleBase\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAO,IAAMA,wBAAwB;;;ACO9B,IAAMC,8BAA8B,GAAGC,qBAAAA;;;ACP9C,oBAAyB;AACzB,+BAAiC;AACjC,kCAAoC;AACpC,gCAA+B;AAC/B,8BAAgC;AAChC,wCAAgF;AAChF,2BAA2E;AAC3E,6BAA+B;AAC/B,0BAA+E;AAC/E,6BAA+B;AAM/B,IAAMC,aAAa;AAKZ,IAAeC,kBAAf,cAMGC,wCAAAA;EA1BV,OA0BUA;;;EACR,OAAyBC,gBAA0B;IAACC;IAAqBC;;;;;EAK/DC;;;;;;;;EASV,MAAgBC,YAAYC,WAA0C;AAEpE,QAAIA,UAAUC,MAAMC,WAAW,KAAKJ,YAAYG,MAAMC;AAAQ;AAC9D,SAAKJ,aAAaE;AAClB,UAAMG,YAAY,MAAM,KAAKC,0BAAyB;AACtD,UAAM,CAACC,EAAAA,IAAM,OAAO,MAAM,IAAIC,gDAAAA,EAAsBC,QAAQP,SAAAA,GAAYQ,QAAQ,KAAKC,OAAO,EAAEC,MAAK;AACnG,UAAMP,UAAUQ,OAAO;MAACN;MAAIL;KAAU;EACxC;;;;;;EAOA,MAAgBI,4BAA4B;AAC1C,UAAMQ,WAAOC,wBAAS,KAAKC,QAAQC,WAAWZ,WAAW,MAAM,GAAGX,UAAAA,iDAA2D;AAC7H,UAAMwB,UAAMH,wBAAS,MAAM,KAAKI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AASC;UAAM,EAAA,EAG1CC,OACC,CAACC,MAAMC,SAAUR,aAAaL,kBAAkBa,MAAMH,KAAAA,MAAWT,yCAAoBI,aAAaS,eAAeD,MAAMH,KAAAA,IAASE,MAChI,EAAA;QAEN;MACF;AAGA,UAAIrB,MAAM;AAER,cAAMrB,YAAY,MAAM,KAAKC,qBAAoB;AACjD,cAAMG,WAAW,MAAMJ,UAAU6C,IAAI;UAACxB;SAAK,GAAGyB,KAAKC,kCAAAA;AACnD,YAAI3C,SAAS;AACX,iBAAOA;QACT;MACF;AACA,aAAO4C;IACT;EACF;AACA,SAAOtD;AACT,GAjHmC;","names":["StatefulDivinerSchema","StatefulDivinerConfigSchema","StatefulDivinerSchema","moduleName","StatefulDiviner","AbstractDiviner","configSchemas","DivinerConfigSchema","StatefulDivinerConfigSchema","_lastState","commitState","nextState","state","offset","archivist","getArchivistForStateStore","bw","BoundWitnessBuilder","payload","witness","account","build","insert","name","assertEx","config","stateStore","mod","resolve","ArchivistWrapper","wrap","getBoundWitnessDivinerForStateStore","boundWitnessDiviner","DivinerWrapper","getPayloadDivinerForStateStore","payloadDiviner","retrieveState","hash","diviner","query","PayloadBuilder","schema","BoundWitnessDivinerQuerySchema","fields","address","limit","order","payload_schemas","ModuleStateSchema","boundWitnesses","divine","length","boundWitness","isBoundWitness","addresses","map","index","filter","reduce","prev","curr","payload_hashes","get","find","isModuleState","undefined","import_assert","import_boundwitness_builder","import_boundwitness_model","import_diviner_boundwitness_model","import_diviner_model","import_module_model","import_payload_builder","moduleName","StatefulModuleMixin","ModuleBase","StatefulModuleBase","_lastState","commitState","nextState","state","offset","archivist","getArchivistForStore","bw","BoundWitnessBuilder","payload","build","insert","name","assertEx","config","stateStore","mod","resolve","instance","asArchivistInstance","getBoundWitnessDivinerForStore","boundWitnessDiviner","asDivinerInstance","getPayloadDivinerForStateStore","payloadDiviner","retrieveState","hash","diviner","query","PayloadBuilder","schema","BoundWitnessDivinerQuerySchema","fields","limit","order","payload_schemas","ModuleStateSchema","boundWitnesses","divine","length","boundWitness","isBoundWitness","addresses","map","address","index","reduce","prev","curr","payload_hashes","get","find","isModuleState","undefined"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/Schema.ts","../../src/Config.ts","../../src/Diviner.ts","../../src/DivinerMixin.ts"],"sourcesContent":["export * from './Config'\nexport * from './Diviner'\nexport * from './DivinerMixin'\nexport * from './Params'\nexport * from './Schema'\n","export const StatefulDivinerSchema = 'network.xyo.diviner.stateful' as const\nexport type StatefulDivinerSchema = typeof StatefulDivinerSchema\n","import { DivinerConfig } from '@xyo-network/diviner-model'\nimport { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { StatefulDivinerSchema } from './Schema'\n\n/**\n * The schema for a Stateful Diviner config\n */\nexport const StatefulDivinerConfigSchema = `${StatefulDivinerSchema}.config` as const\n/**\n * The schema for a Stateful Diviner config\n */\nexport type StatefulDivinerConfigSchema = typeof StatefulDivinerConfigSchema\n\n/**\n * The config for a Stateful Diviner\n */\nexport type StatefulDivinerConfig = DivinerConfig<{\n schema: StatefulDivinerConfigSchema\n stateStore: {\n archivist: ModuleIdentifier\n boundWitnessDiviner: ModuleIdentifier\n payloadDiviner: ModuleIdentifier\n }\n}>\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { DivinerConfigSchema, DivinerModule, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport { isModuleState, ModuleState, ModuleStateSchema, StateDictionary } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, WithMeta } from '@xyo-network/payload-model'\n\nimport { StatefulDivinerConfigSchema } from './Config'\nimport { StatefulDivinerParams } from './Params'\n\nconst moduleName = 'StatefulDiviner'\n\n/**\n * A Diviner that maintains state\n */\nexport abstract class StatefulDiviner<\n TParams extends StatefulDivinerParams = StatefulDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\n TEventData extends DivinerModuleEventData<DivinerModule<TParams>, TIn, TOut> = DivinerModuleEventData<DivinerModule<TParams>, TIn, TOut>,\n TState extends StateDictionary = StateDictionary,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: string[] = [DivinerConfigSchema, StatefulDivinerConfigSchema]\n\n /**\n * The last state\n */\n protected _lastState?: WithMeta<ModuleState<TState>>\n\n /**\n * Commit the internal state of the Diviner process. This is similar\n * to a transaction completion in a database and should only be called\n * when results have been successfully persisted to the appropriate\n * external stores.\n * @param nextState The state to commit\n */\n protected async commitState(nextState: WithMeta<ModuleState<TState>>) {\n // Don't commit state if no state has changed\n if (nextState.state.offset === this._lastState?.state.offset) return\n this._lastState = nextState\n const archivist = await this.getArchivistForStateStore()\n const [bw] = await (await new BoundWitnessBuilder().payload(nextState)).witness(this.account).build()\n await archivist.insert([bw, nextState])\n }\n\n /**\n * Retrieves the archivist for the specified store\n * @param store The store to retrieve the archivist for\n * @returns The archivist for the specified store\n */\n protected async getArchivistForStateStore() {\n const name = assertEx(this.config?.stateStore.archivist, () => `${moduleName}: Config for stateStore.archivist not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.archivist`)\n return ArchivistWrapper.wrap(mod, this.account)\n }\n\n /**\n * Retrieves the BoundWitness Diviner for the specified store\n * @param store The store to retrieve the BoundWitness Diviner for\n * @returns The BoundWitness Diviner for the specified store\n */\n protected async getBoundWitnessDivinerForStateStore() {\n const name = assertEx(this.config?.stateStore.boundWitnessDiviner, () => `${moduleName}: Config for stateStore.boundWitnessDiviner not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.boundWitnessDiviner`)\n return DivinerWrapper.wrap(mod, this.account)\n }\n\n /**\n * Retrieves the Payload Diviner for the specified store\n * @param store The store to retrieve the Payload Diviner for\n * @returns The Payload Diviner for the specified store\n */\n protected async getPayloadDivinerForStateStore() {\n const name = assertEx(this.config?.stateStore?.payloadDiviner, () => `${moduleName}: Config for stateStore.payloadDiviner not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.payloadDiviner`)\n return DivinerWrapper.wrap(mod, this.account)\n }\n\n /**\n * Retrieves the last state of the Diviner process. Used to recover state after\n * preemptions, reboots, etc.\n */\n protected async retrieveState(): Promise<WithMeta<ModuleState<TState>> | undefined> {\n if (this._lastState) return this._lastState\n let hash: Hash = ''\n const diviner = await this.getBoundWitnessDivinerForStateStore()\n const query = await new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({\n address: this.account.address,\n limit: 1,\n offset: 0,\n order: 'desc',\n payload_schemas: [ModuleStateSchema],\n })\n .build()\n const boundWitnesses = await diviner.divine([query])\n if (boundWitnesses.length > 0) {\n const boundWitness = boundWitnesses[0]\n if (isBoundWitness(boundWitness)) {\n // Find the index for this address in the BoundWitness that is a ModuleState\n hash = boundWitness.addresses\n .map((address, index) => ({ address, index }))\n .filter(({ address }) => address === this.account.address)\n // eslint-disable-next-line unicorn/no-array-reduce\n .reduce(\n (prev, curr) => (boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev),\n '' as Hash,\n )\n }\n }\n\n // If we able to located the last state\n if (hash) {\n // Get last state\n const archivist = await this.getArchivistForStateStore()\n const payload = (await archivist.get([hash])).find(isModuleState<TState>)\n if (payload) {\n return payload as WithMeta<ModuleState<TState>>\n }\n }\n return undefined\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { Hash } from '@xylabs/hex'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport {\n AnyConfigSchema,\n isModuleState,\n ModuleInstance,\n ModuleParams,\n ModuleState,\n ModuleStateSchema,\n StateDictionary,\n} from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { WithMeta } from '@xyo-network/payload-model'\n\nimport { StatefulDivinerConfig } from './Config'\n\nexport type StatefulModuleParams = ModuleParams<AnyConfigSchema<StatefulDivinerConfig>>\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyModule<TParams extends StatefulModuleParams = StatefulModuleParams> = new (...args: any[]) => ModuleInstance<TParams>\n\nconst moduleName = 'StatefulModuleMixin'\n\n/**\n * @ignore Inherit from StatefulDiviner instead\n * @param ModuleBase\n * @returns\n */\nexport const StatefulModuleMixin = <\n TParams extends StatefulModuleParams = StatefulModuleParams,\n TModule extends AnyModule<TParams> = AnyModule<TParams>,\n TState extends StateDictionary = StateDictionary,\n>(\n ModuleBase: TModule,\n) => {\n abstract class StatefulModuleBase extends ModuleBase {\n _lastState?: WithMeta<ModuleState<TState>>\n\n /**\n * Commit the internal state of the Diviner process. This is similar\n * to a transaction completion in a database and should only be called\n * when results have been successfully persisted to the appropriate\n * external stores.\n * @param nextState The state to commit\n */\n async commitState(nextState: WithMeta<ModuleState<TState>>) {\n // Don't commit state if no state has changed\n if (nextState.state.offset === this._lastState?.state.offset) return\n this._lastState = nextState\n const archivist = await this.getArchivistForStore()\n // const [bw] = await new BoundWitnessBuilder().payload(nextState).witness(this.account).build()\n const [bw] = await (await new BoundWitnessBuilder().payload(nextState)).build()\n await archivist.insert([bw, nextState])\n }\n\n /**\n * Retrieves the archivist for the specified store\n * @param store The store to retrieve the archivist for\n * @returns The archivist for the specified store\n */\n async getArchivistForStore() {\n const name = assertEx(this.config?.stateStore?.archivist, () => `${moduleName}: Config for stateStore.archivist not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.archivist`)\n // return ArchivistWrapper.wrap(mod, this.account)\n const instance = asArchivistInstance(mod)\n return assertEx(instance, () => `${moduleName}: Failed to wrap archivist instance`)\n }\n\n /**\n * Retrieves the BoundWitness Diviner for the specified store\n * @param store The store to retrieve the BoundWitness Diviner for\n * @returns The BoundWitness Diviner for the specified store\n */\n async getBoundWitnessDivinerForStore() {\n const name = assertEx(\n this.config?.stateStore?.boundWitnessDiviner,\n () => `${moduleName}: Config for stateStore.boundWitnessDiviner not specified`,\n )\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.boundWitnessDiviner`)\n // return DivinerWrapper.wrap(mod, this.account)\n const instance = asDivinerInstance(mod)\n return assertEx(instance, () => `${moduleName}: Failed to wrap diviner instance`)\n }\n /**\n * Retrieves the Payload Diviner for the specified store\n * @param store The store to retrieve the Payload Diviner for\n * @returns The Payload Diviner for the specified store\n */\n async getPayloadDivinerForStateStore() {\n const name = assertEx(this.config?.stateStore?.payloadDiviner, () => `${moduleName}: Config for stateStore.payloadDiviner not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.payloadDiviner`)\n // return DivinerWrapper.wrap(mod, this.account)\n const instance = asDivinerInstance(mod)\n return assertEx(instance, () => `${moduleName}: Failed to wrap diviner instance`)\n }\n /**\n * Retrieves the last state of the Diviner process. Used to recover state after\n * preemptions, reboots, etc.\n */\n async retrieveState(): Promise<WithMeta<ModuleState<TState>> | undefined> {\n if (this._lastState) return this._lastState\n let hash: Hash = ''\n const diviner = await this.getBoundWitnessDivinerForStore()\n const query = await new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({\n // address: this.account.address,\n limit: 1,\n offset: 0,\n order: 'desc',\n payload_schemas: [ModuleStateSchema],\n })\n .build()\n const boundWitnesses = await diviner.divine([query])\n if (boundWitnesses.length > 0) {\n const boundWitness = boundWitnesses[0]\n if (isBoundWitness(boundWitness)) {\n // Find the index for this address in the BoundWitness that is a ModuleState\n hash = boundWitness.addresses\n .map((address, index) => ({ address, index }))\n // .filter(({ address }) => address === this.account.address)\n // eslint-disable-next-line unicorn/no-array-reduce\n .reduce(\n (prev, curr) => (boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev),\n '' as Hash,\n )\n }\n }\n\n // If we able to located the last state\n if (hash) {\n // Get last state\n const archivist = await this.getArchivistForStore()\n const payload = (await archivist.get([hash])).find(isModuleState<TState>)\n if (payload) {\n return payload as WithMeta<ModuleState<TState>>\n }\n }\n return undefined\n }\n }\n return StatefulModuleBase\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAO,IAAMA,wBAAwB;;;ACQ9B,IAAMC,8BAA8B,GAAGC,qBAAAA;;;ACR9C,oBAAyB;AAEzB,+BAAiC;AACjC,kCAAoC;AACpC,gCAA+B;AAC/B,8BAAgC;AAChC,wCAAgF;AAChF,2BAA2E;AAC3E,6BAA+B;AAC/B,0BAA+E;AAC/E,6BAA+B;AAM/B,IAAMC,aAAa;AAKZ,IAAeC,kBAAf,cAMGC,wCAAAA;EA3BV,OA2BUA;;;EACR,OAAyBC,gBAA0B;IAACC;IAAqBC;;;;;EAK/DC;;;;;;;;EASV,MAAgBC,YAAYC,WAA0C;AAEpE,QAAIA,UAAUC,MAAMC,WAAW,KAAKJ,YAAYG,MAAMC;AAAQ;AAC9D,SAAKJ,aAAaE;AAClB,UAAMG,YAAY,MAAM,KAAKC,0BAAyB;AACtD,UAAM,CAACC,EAAAA,IAAM,OAAO,MAAM,IAAIC,gDAAAA,EAAsBC,QAAQP,SAAAA,GAAYQ,QAAQ,KAAKC,OAA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1B,MAAK;AACR,YAAM2B,iBAAiB,MAAMV,QAAQW,OAAO;QAACV;OAAM;AACnD,UAAIS,eAAeE,SAAS,GAAG;AAC7B,cAAMC,eAAeH,eAAe,CAAA;AACpC,gBAAII,2CAAeD,YAAAA,GAAe;AAEhCd,iBAAOc,aAAaE,UACjBC,IAAI,CAACC,SAASC,WAAW;YAAED;YAASC;UAAM,EAAA,EAG1CC,OACC,CAACC,MAAMC,SAAUR,aAAaL,kBAAkBa,MAAMH,KAAAA,MAAWT,yCAAoBI,aAAaS,eAAeD,MAAMH,KAAAA,IAASE,MAChI,EAAA;QAEN;MACF;AAGA,UAAIrB,MAAM;AAER,cAAMrB,YAAY,MAAM,KAAKC,qBAAoB;AACjD,cAAMG,WAAW,MAAMJ,UAAU6C,IAAI;UAACxB;SAAK,GAAGyB,KAAKC,kCAAAA;AACnD,YAAI3C,SAAS;AACX,iBAAOA;QACT;MACF;AACA,aAAO4C;IACT;EACF;AACA,SAAOtD;AACT,GAjHmC;","names":["StatefulDivinerSchema","StatefulDivinerConfigSchema","StatefulDivinerSchema","moduleName","StatefulDiviner","AbstractDiviner","configSchemas","DivinerConfigSchema","StatefulDivinerConfigSchema","_lastState","commitState","nextState","state","offset","archivist","getArchivistForStateStore","bw","BoundWitnessBuilder","payload","witness","account","build","insert","name","assertEx","config","stateStore","mod","resolve","ArchivistWrapper","wrap","getBoundWitnessDivinerForStateStore","boundWitnessDiviner","DivinerWrapper","getPayloadDivinerForStateStore","payloadDiviner","retrieveState","hash","diviner","query","PayloadBuilder","schema","BoundWitnessDivinerQuerySchema","fields","address","limit","order","payload_schemas","ModuleStateSchema","boundWitnesses","divine","length","boundWitness","isBoundWitness","addresses","map","index","filter","reduce","prev","curr","payload_hashes","get","find","isModuleState","undefined","import_assert","import_boundwitness_builder","import_boundwitness_model","import_diviner_boundwitness_model","import_diviner_model","import_module_model","import_payload_builder","moduleName","StatefulModuleMixin","ModuleBase","StatefulModuleBase","_lastState","commitState","nextState","state","offset","archivist","getArchivistForStore","bw","BoundWitnessBuilder","payload","build","insert","name","assertEx","config","stateStore","mod","resolve","instance","asArchivistInstance","getBoundWitnessDivinerForStore","boundWitnessDiviner","asDivinerInstance","getPayloadDivinerForStateStore","payloadDiviner","retrieveState","hash","diviner","query","PayloadBuilder","schema","BoundWitnessDivinerQuerySchema","fields","limit","order","payload_schemas","ModuleStateSchema","boundWitnesses","divine","length","boundWitness","isBoundWitness","addresses","map","address","index","reduce","prev","curr","payload_hashes","get","find","isModuleState","undefined"]}
|