@xyo-network/diviner-stateful 2.84.19 → 2.85.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/DivinerMixin.d.cts +0 -28
- package/dist/browser/DivinerMixin.d.cts.map +1 -1
- package/dist/browser/DivinerMixin.d.mts +0 -28
- package/dist/browser/DivinerMixin.d.mts.map +1 -1
- package/dist/browser/DivinerMixin.d.ts +0 -28
- package/dist/browser/DivinerMixin.d.ts.map +1 -1
- package/dist/browser/index.cjs +100 -71
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +103 -75
- package/dist/browser/index.js.map +1 -1
- package/dist/node/DivinerMixin.d.cts +0 -28
- package/dist/node/DivinerMixin.d.cts.map +1 -1
- package/dist/node/DivinerMixin.d.mts +0 -28
- package/dist/node/DivinerMixin.d.mts.map +1 -1
- package/dist/node/DivinerMixin.d.ts +0 -28
- package/dist/node/DivinerMixin.d.ts.map +1 -1
- package/dist/node/index.cjs +116 -85
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +119 -89
- package/dist/node/index.js.map +1 -1
- package/package.json +18 -18
package/dist/browser/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/Schema.ts
|
|
2
5
|
var StatefulDivinerSchema = "network.xyo.diviner.stateful";
|
|
3
6
|
|
|
@@ -17,85 +20,102 @@ import { isModuleState, ModuleStateSchema } from "@xyo-network/module-model";
|
|
|
17
20
|
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
18
21
|
var moduleName = "StatefulDiviner";
|
|
19
22
|
var StatefulDiviner = class extends AbstractDiviner {
|
|
20
|
-
static
|
|
23
|
+
static {
|
|
24
|
+
__name(this, "StatefulDiviner");
|
|
25
|
+
}
|
|
26
|
+
static configSchemas = [
|
|
27
|
+
DivinerConfigSchema,
|
|
28
|
+
StatefulDivinerConfigSchema
|
|
29
|
+
];
|
|
21
30
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
* The last state
|
|
32
|
+
*/
|
|
24
33
|
_lastState;
|
|
25
34
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
* Commit the internal state of the Diviner process. This is similar
|
|
36
|
+
* to a transaction completion in a database and should only be called
|
|
37
|
+
* when results have been successfully persisted to the appropriate
|
|
38
|
+
* external stores.
|
|
39
|
+
* @param nextState The state to commit
|
|
40
|
+
*/
|
|
32
41
|
async commitState(nextState) {
|
|
33
42
|
if (nextState.state.offset === this._lastState?.state.offset)
|
|
34
43
|
return;
|
|
35
44
|
this._lastState = nextState;
|
|
36
45
|
const archivist = await this.getArchivistForStateStore();
|
|
37
46
|
const [bw] = await new BoundWitnessBuilder().payload(nextState).witness(this.account).build();
|
|
38
|
-
await archivist.insert([
|
|
47
|
+
await archivist.insert([
|
|
48
|
+
bw,
|
|
49
|
+
nextState
|
|
50
|
+
]);
|
|
39
51
|
}
|
|
40
52
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
* Retrieves the archivist for the specified store
|
|
54
|
+
* @param store The store to retrieve the archivist for
|
|
55
|
+
* @returns The archivist for the specified store
|
|
56
|
+
*/
|
|
45
57
|
async getArchivistForStateStore() {
|
|
46
58
|
const name = assertEx(this.config?.stateStore.archivist, () => `${moduleName}: Config for stateStore.archivist not specified`);
|
|
47
59
|
const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.archivist`);
|
|
48
60
|
return ArchivistWrapper.wrap(mod, this.account);
|
|
49
61
|
}
|
|
50
62
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
* Retrieves the BoundWitness Diviner for the specified store
|
|
64
|
+
* @param store The store to retrieve the BoundWitness Diviner for
|
|
65
|
+
* @returns The BoundWitness Diviner for the specified store
|
|
66
|
+
*/
|
|
55
67
|
async getBoundWitnessDivinerForStateStore() {
|
|
56
68
|
const name = assertEx(this.config?.stateStore.boundWitnessDiviner, () => `${moduleName}: Config for stateStore.boundWitnessDiviner not specified`);
|
|
57
69
|
const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.boundWitnessDiviner`);
|
|
58
70
|
return DivinerWrapper.wrap(mod, this.account);
|
|
59
71
|
}
|
|
60
72
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
* Retrieves the Payload Diviner for the specified store
|
|
74
|
+
* @param store The store to retrieve the Payload Diviner for
|
|
75
|
+
* @returns The Payload Diviner for the specified store
|
|
76
|
+
*/
|
|
65
77
|
async getPayloadDivinerForStateStore() {
|
|
66
78
|
const name = assertEx(this.config?.stateStore?.payloadDiviner, () => `${moduleName}: Config for stateStore.payloadDiviner not specified`);
|
|
67
79
|
const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.payloadDiviner`);
|
|
68
80
|
return DivinerWrapper.wrap(mod, this.account);
|
|
69
81
|
}
|
|
70
82
|
/**
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
* Retrieves the last state of the Diviner process. Used to recover state after
|
|
84
|
+
* preemptions, reboots, etc.
|
|
85
|
+
*/
|
|
74
86
|
async retrieveState() {
|
|
75
87
|
if (this._lastState)
|
|
76
88
|
return this._lastState;
|
|
77
89
|
let hash = "";
|
|
78
90
|
const diviner = await this.getBoundWitnessDivinerForStateStore();
|
|
79
|
-
const query = await new PayloadBuilder({
|
|
91
|
+
const query = await new PayloadBuilder({
|
|
92
|
+
schema: BoundWitnessDivinerQuerySchema
|
|
93
|
+
}).fields({
|
|
80
94
|
address: this.account.address,
|
|
81
95
|
limit: 1,
|
|
82
96
|
offset: 0,
|
|
83
97
|
order: "desc",
|
|
84
|
-
payload_schemas: [
|
|
98
|
+
payload_schemas: [
|
|
99
|
+
ModuleStateSchema
|
|
100
|
+
]
|
|
85
101
|
}).build();
|
|
86
|
-
const boundWitnesses = await diviner.divine([
|
|
102
|
+
const boundWitnesses = await diviner.divine([
|
|
103
|
+
query
|
|
104
|
+
]);
|
|
87
105
|
if (boundWitnesses.length > 0) {
|
|
88
106
|
const boundWitness = boundWitnesses[0];
|
|
89
107
|
if (isBoundWitness(boundWitness)) {
|
|
90
|
-
hash = boundWitness.addresses.map((address, index) => ({
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
);
|
|
108
|
+
hash = boundWitness.addresses.map((address, index) => ({
|
|
109
|
+
address,
|
|
110
|
+
index
|
|
111
|
+
})).filter(({ address }) => address === this.account.address).reduce((prev, curr) => boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev, "");
|
|
94
112
|
}
|
|
95
113
|
}
|
|
96
114
|
if (hash) {
|
|
97
115
|
const archivist = await this.getArchivistForStateStore();
|
|
98
|
-
const payload = (await archivist.get([
|
|
116
|
+
const payload = (await archivist.get([
|
|
117
|
+
hash
|
|
118
|
+
])).find(isModuleState);
|
|
99
119
|
if (payload) {
|
|
100
120
|
return payload;
|
|
101
121
|
}
|
|
@@ -111,35 +131,38 @@ import { BoundWitnessBuilder as BoundWitnessBuilder2 } from "@xyo-network/boundw
|
|
|
111
131
|
import { isBoundWitness as isBoundWitness2 } from "@xyo-network/boundwitness-model";
|
|
112
132
|
import { BoundWitnessDivinerQuerySchema as BoundWitnessDivinerQuerySchema2 } from "@xyo-network/diviner-boundwitness-model";
|
|
113
133
|
import { asDivinerInstance } from "@xyo-network/diviner-model";
|
|
114
|
-
import {
|
|
115
|
-
isModuleState as isModuleState2,
|
|
116
|
-
ModuleStateSchema as ModuleStateSchema2
|
|
117
|
-
} from "@xyo-network/module-model";
|
|
134
|
+
import { isModuleState as isModuleState2, ModuleStateSchema as ModuleStateSchema2 } from "@xyo-network/module-model";
|
|
118
135
|
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
119
136
|
var moduleName2 = "StatefulModuleMixin";
|
|
120
|
-
var StatefulModuleMixin = (ModuleBase) => {
|
|
121
|
-
class StatefulModuleBase extends ModuleBase {
|
|
137
|
+
var StatefulModuleMixin = /* @__PURE__ */ __name((ModuleBase) => {
|
|
138
|
+
let StatefulModuleBase = class StatefulModuleBase extends ModuleBase {
|
|
139
|
+
static {
|
|
140
|
+
__name(this, "StatefulModuleBase");
|
|
141
|
+
}
|
|
122
142
|
_lastState;
|
|
123
143
|
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
144
|
+
* Commit the internal state of the Diviner process. This is similar
|
|
145
|
+
* to a transaction completion in a database and should only be called
|
|
146
|
+
* when results have been successfully persisted to the appropriate
|
|
147
|
+
* external stores.
|
|
148
|
+
* @param nextState The state to commit
|
|
149
|
+
*/
|
|
130
150
|
async commitState(nextState) {
|
|
131
151
|
if (nextState.state.offset === this._lastState?.state.offset)
|
|
132
152
|
return;
|
|
133
153
|
this._lastState = nextState;
|
|
134
154
|
const archivist = await this.getArchivistForStore();
|
|
135
155
|
const [bw] = await new BoundWitnessBuilder2().payload(nextState).build();
|
|
136
|
-
await archivist.insert([
|
|
156
|
+
await archivist.insert([
|
|
157
|
+
bw,
|
|
158
|
+
nextState
|
|
159
|
+
]);
|
|
137
160
|
}
|
|
138
161
|
/**
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
162
|
+
* Retrieves the archivist for the specified store
|
|
163
|
+
* @param store The store to retrieve the archivist for
|
|
164
|
+
* @returns The archivist for the specified store
|
|
165
|
+
*/
|
|
143
166
|
async getArchivistForStore() {
|
|
144
167
|
const name = assertEx2(this.config?.stateStore?.archivist, () => `${moduleName2}: Config for stateStore.archivist not specified`);
|
|
145
168
|
const mod = assertEx2(await this.resolve(name), () => `${moduleName2}: Failed to resolve stateStore.archivist`);
|
|
@@ -147,24 +170,21 @@ var StatefulModuleMixin = (ModuleBase) => {
|
|
|
147
170
|
return assertEx2(instance, () => `${moduleName2}: Failed to wrap archivist instance`);
|
|
148
171
|
}
|
|
149
172
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
173
|
+
* Retrieves the BoundWitness Diviner for the specified store
|
|
174
|
+
* @param store The store to retrieve the BoundWitness Diviner for
|
|
175
|
+
* @returns The BoundWitness Diviner for the specified store
|
|
176
|
+
*/
|
|
154
177
|
async getBoundWitnessDivinerForStore() {
|
|
155
|
-
const name = assertEx2(
|
|
156
|
-
this.config?.stateStore?.boundWitnessDiviner,
|
|
157
|
-
() => `${moduleName2}: Config for stateStore.boundWitnessDiviner not specified`
|
|
158
|
-
);
|
|
178
|
+
const name = assertEx2(this.config?.stateStore?.boundWitnessDiviner, () => `${moduleName2}: Config for stateStore.boundWitnessDiviner not specified`);
|
|
159
179
|
const mod = assertEx2(await this.resolve(name), () => `${moduleName2}: Failed to resolve stateStore.boundWitnessDiviner`);
|
|
160
180
|
const instance = asDivinerInstance(mod);
|
|
161
181
|
return assertEx2(instance, () => `${moduleName2}: Failed to wrap diviner instance`);
|
|
162
182
|
}
|
|
163
183
|
/**
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
184
|
+
* Retrieves the Payload Diviner for the specified store
|
|
185
|
+
* @param store The store to retrieve the Payload Diviner for
|
|
186
|
+
* @returns The Payload Diviner for the specified store
|
|
187
|
+
*/
|
|
168
188
|
async getPayloadDivinerForStateStore() {
|
|
169
189
|
const name = assertEx2(this.config?.stateStore?.payloadDiviner, () => `${moduleName2}: Config for stateStore.payloadDiviner not specified`);
|
|
170
190
|
const mod = assertEx2(await this.resolve(name), () => `${moduleName2}: Failed to resolve stateStore.payloadDiviner`);
|
|
@@ -172,43 +192,51 @@ var StatefulModuleMixin = (ModuleBase) => {
|
|
|
172
192
|
return assertEx2(instance, () => `${moduleName2}: Failed to wrap diviner instance`);
|
|
173
193
|
}
|
|
174
194
|
/**
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
195
|
+
* Retrieves the last state of the Diviner process. Used to recover state after
|
|
196
|
+
* preemptions, reboots, etc.
|
|
197
|
+
*/
|
|
178
198
|
async retrieveState() {
|
|
179
199
|
if (this._lastState)
|
|
180
200
|
return this._lastState;
|
|
181
201
|
let hash = "";
|
|
182
202
|
const diviner = await this.getBoundWitnessDivinerForStore();
|
|
183
|
-
const query = await new PayloadBuilder2({
|
|
203
|
+
const query = await new PayloadBuilder2({
|
|
204
|
+
schema: BoundWitnessDivinerQuerySchema2
|
|
205
|
+
}).fields({
|
|
184
206
|
// address: this.account.address,
|
|
185
207
|
limit: 1,
|
|
186
208
|
offset: 0,
|
|
187
209
|
order: "desc",
|
|
188
|
-
payload_schemas: [
|
|
210
|
+
payload_schemas: [
|
|
211
|
+
ModuleStateSchema2
|
|
212
|
+
]
|
|
189
213
|
}).build();
|
|
190
|
-
const boundWitnesses = await diviner.divine([
|
|
214
|
+
const boundWitnesses = await diviner.divine([
|
|
215
|
+
query
|
|
216
|
+
]);
|
|
191
217
|
if (boundWitnesses.length > 0) {
|
|
192
218
|
const boundWitness = boundWitnesses[0];
|
|
193
219
|
if (isBoundWitness2(boundWitness)) {
|
|
194
|
-
hash = boundWitness.addresses.map((address, index) => ({
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
);
|
|
220
|
+
hash = boundWitness.addresses.map((address, index) => ({
|
|
221
|
+
address,
|
|
222
|
+
index
|
|
223
|
+
})).reduce((prev, curr) => boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema2 ? boundWitness.payload_hashes[curr?.index] : prev, "");
|
|
198
224
|
}
|
|
199
225
|
}
|
|
200
226
|
if (hash) {
|
|
201
227
|
const archivist = await this.getArchivistForStore();
|
|
202
|
-
const payload = (await archivist.get([
|
|
228
|
+
const payload = (await archivist.get([
|
|
229
|
+
hash
|
|
230
|
+
])).find(isModuleState2);
|
|
203
231
|
if (payload) {
|
|
204
232
|
return payload;
|
|
205
233
|
}
|
|
206
234
|
}
|
|
207
235
|
return void 0;
|
|
208
236
|
}
|
|
209
|
-
}
|
|
237
|
+
};
|
|
210
238
|
return StatefulModuleBase;
|
|
211
|
-
};
|
|
239
|
+
}, "StatefulModuleMixin");
|
|
212
240
|
export {
|
|
213
241
|
StatefulDiviner,
|
|
214
242
|
StatefulDivinerConfigSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Schema.ts","../../src/Config.ts","../../src/Diviner.ts","../../src/DivinerMixin.ts"],"sourcesContent":["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 { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\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 } 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?: 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: 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 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<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\n }\n }\n return undefined\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { asArchivistInstance } from '@xyo-network/archivist'\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'\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?: 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: 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 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<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\n }\n }\n return undefined\n }\n }\n return StatefulModuleBase\n}\n"],"mappings":";AAAO,IAAM,wBAAwB;;;ACO9B,IAAM,8BAA8B,GAAG,qBAAqB;;;ACPnE,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAA0C,sCAAsC;AAChF,SAAS,2BAAkE;AAC3E,SAAS,sBAAsB;AAC/B,SAAS,eAA4B,yBAA0C;AAC/E,SAAS,sBAAsB;AAM/B,IAAM,aAAa;AAKZ,IAAe,kBAAf,cAMG,gBAAgD;AAAA,EACxD,OAAyB,gBAA0B,CAAC,qBAAqB,2BAA2B;AAAA;AAAA;AAAA;AAAA,EAK1F;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASV,MAAgB,YAAY,WAAgC;AAE1D,QAAI,UAAU,MAAM,WAAW,KAAK,YAAY,MAAM;AAAQ;AAC9D,SAAK,aAAa;AAClB,UAAM,YAAY,MAAM,KAAK,0BAA0B;AACvD,UAAM,CAAC,EAAE,IAAI,MAAM,IAAI,oBAAoB,EAAE,QAAQ,SAAS,EAAE,QAAQ,KAAK,OAAO,EAAE,MAAM;AAC5F,UAAM,UAAU,OAAO,CAAC,IAAI,SAAS,CAAC;AAAA,E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AAC,EAC/G,OAAO;AAAA;AAAA,QAEN,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,iBAAiB,CAACE,kBAAiB;AAAA,MACrC,CAAC,EACA,MAAM;AACT,YAAM,iBAAiB,MAAM,QAAQ,OAAO,CAAC,KAAK,CAAC;AACnD,UAAI,eAAe,SAAS,GAAG;AAC7B,cAAM,eAAe,eAAe,CAAC;AACrC,YAAIH,gBAAe,YAAY,GAAG;AAEhC,iBAAO,aAAa,UACjB,IAAI,CAAC,SAAS,WAAW,EAAE,SAAS,MAAM,EAAE,EAG5C;AAAA,YACC,CAAC,MAAM,SAAU,aAAa,kBAAkB,MAAM,KAAK,MAAMG,qBAAoB,aAAa,eAAe,MAAM,KAAK,IAAI;AAAA,YAChI;AAAA,UACF;AAAA,QACJ;AAAA,MACF;AAGA,UAAI,MAAM;AAER,cAAM,YAAY,MAAM,KAAK,qBAAqB;AAClD,cAAM,WAAW,MAAM,UAAU,IAAI,CAAC,IAAI,CAAC,GAAG,KAAKD,cAAqB;AACxE,YAAI,SAAS;AACX,iBAAO;AAAA,QACT;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":["assertEx","BoundWitnessBuilder","isBoundWitness","BoundWitnessDivinerQuerySchema","isModuleState","ModuleStateSchema","PayloadBuilder","moduleName"]}
|
|
1
|
+
{"version":3,"sources":["../../src/Schema.ts","../../src/Config.ts","../../src/Diviner.ts","../../src/DivinerMixin.ts"],"sourcesContent":["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 { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\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 } 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?: 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: 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 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<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\n }\n }\n return undefined\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { asArchivistInstance } from '@xyo-network/archivist'\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'\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?: 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: 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 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<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\n }\n }\n return undefined\n }\n }\n return StatefulModuleBase\n}\n"],"mappings":";;;;AAAO,IAAMA,wBAAwB;;;ACO9B,IAAMC,8BAA8B,GAAGC,qBAAAA;;;ACP9C,SAASC,gBAAgB;AACzB,SAASC,uBAAuB;AAChC,SAASC,wBAAwB;AACjC,SAASC,2BAA2B;AACpC,SAASC,sBAAsB;AAC/B,SAA0CC,sCAAsC;AAChF,SAASC,2BAAkE;AAC3E,SAASC,sBAAsB;AAC/B,SAASC,e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UAAS,MAAM,KAAKI,QAAQL,IAAAA,GAAO,MAAM,GAAGhB,WAAAA,+CAAyD;AAEjH,YAAMsB,WAAWI,kBAAkBN,GAAAA;AACnC,aAAOH,UAASK,UAAU,MAAM,GAAGtB,WAAAA,mCAA6C;IAClF;;;;;IAKA,MAAM6B,gBAA0D;AAC9D,UAAI,KAAKzB;AAAY,eAAO,KAAKA;AACjC,UAAI0B,OAAe;AACnB,YAAMC,UAAU,MAAM,KAAKP,+BAA8B;AACzD,YAAMQ,QAAQ,MAAM,IAAIC,gBAAgD;QAAEC,QAAQC;MAA+B,CAAA,EAC9GC,OAAO;;QAENC,OAAO;QACP7B,QAAQ;QACR8B,OAAO;QACPC,iBAAiB;UAACC;;MACpB,CAAA,EACC1B,MAAK;AACR,YAAM2B,iBAAiB,MAAMV,QAAQW,OAAO;QAACV;OAAM;AACnD,UAAIS,eAAeE,SAAS,GAAG;AAC7B,cAAMC,eAAeH,eAAe,CAAA;AACpC,YAAII,gBAAeD,YAAAA,GAAe;AAEhCd,iBAAOc,aAAaE,UACjBC,IAAI,CAACC,SAASC,WAAW;YAAED;YAASC;UAAM,EAAA,EAG1CC,OACC,CAACC,MAAMC,SAAUR,aAAaL,kBAAkBa,MAAMH,KAAAA,MAAWT,qBAAoBI,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,cAAAA;AACnD,YAAI3C,SAAS;AACX,iBAAOA;QACT;MACF;AACA,aAAO4C;IACT;EACF;AACA,SAAOtD;AACT,GAjHmC;","names":["StatefulDivinerSchema","StatefulDivinerConfigSchema","StatefulDivinerSchema","assertEx","AbstractDiviner","ArchivistWrapper","BoundWitnessBuilder","isBoundWitness","BoundWitnessDivinerQuerySchema","DivinerConfigSchema","DivinerWrapper","isModuleState","ModuleStateSchema","PayloadBuilder","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","assertEx","asArchivistInstance","BoundWitnessBuilder","isBoundWitness","BoundWitnessDivinerQuerySchema","asDivinerInstance","isModuleState","ModuleStateSchema","PayloadBuilder","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"]}
|
|
@@ -10,7 +10,6 @@ export type AnyModule<TParams extends StatefulModuleParams = StatefulModuleParam
|
|
|
10
10
|
export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/object").BaseParamsFields & {
|
|
11
11
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
12
12
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
13
|
-
accountDerivationPath?: string | undefined;
|
|
14
13
|
readonly archivist?: string | undefined;
|
|
15
14
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
16
15
|
readonly name?: string | undefined;
|
|
@@ -27,7 +26,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
27
26
|
readonly storeQueries?: boolean | undefined;
|
|
28
27
|
readonly timestamp?: boolean | undefined;
|
|
29
28
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
30
|
-
accountDerivationPath?: string | undefined;
|
|
31
29
|
readonly archivist?: string | undefined;
|
|
32
30
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
33
31
|
readonly name?: string | undefined;
|
|
@@ -56,11 +54,9 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
56
54
|
schema: string;
|
|
57
55
|
};
|
|
58
56
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
59
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
60
57
|
} = import("@xyo-network/object").BaseParamsFields & {
|
|
61
58
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
62
59
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
63
|
-
accountDerivationPath?: string | undefined;
|
|
64
60
|
readonly archivist?: string | undefined;
|
|
65
61
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
66
62
|
readonly name?: string | undefined;
|
|
@@ -77,7 +73,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
77
73
|
readonly storeQueries?: boolean | undefined;
|
|
78
74
|
readonly timestamp?: boolean | undefined;
|
|
79
75
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
80
|
-
accountDerivationPath?: string | undefined;
|
|
81
76
|
readonly archivist?: string | undefined;
|
|
82
77
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
83
78
|
readonly name?: string | undefined;
|
|
@@ -106,7 +101,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
106
101
|
schema: string;
|
|
107
102
|
};
|
|
108
103
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
109
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
110
104
|
}, TModule extends AnyModule<TParams> = AnyModule<TParams>, TState extends StateDictionary = StateDictionary>(ModuleBase: TModule) => (abstract new (...args: any[]) => {
|
|
111
105
|
_lastState?: ModuleState<TState> | undefined;
|
|
112
106
|
/**
|
|
@@ -158,7 +152,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
158
152
|
}, "schema"> & {
|
|
159
153
|
schema: "network.xyo.boundwitness";
|
|
160
154
|
}, TConf extends import("@xyo-network/payload-model").SchemaFields & object & {
|
|
161
|
-
accountDerivationPath?: string | undefined;
|
|
162
155
|
readonly archivist?: string | undefined;
|
|
163
156
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
164
157
|
readonly name?: string | undefined;
|
|
@@ -175,7 +168,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
175
168
|
readonly storeQueries?: boolean | undefined;
|
|
176
169
|
readonly timestamp?: boolean | undefined;
|
|
177
170
|
} & import("@xyo-network/module-model").ArchivingModuleConfig = import("@xyo-network/payload-model").SchemaFields & object & {
|
|
178
|
-
accountDerivationPath?: string | undefined;
|
|
179
171
|
readonly archivist?: string | undefined;
|
|
180
172
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
181
173
|
readonly name?: string | undefined;
|
|
@@ -207,7 +199,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
207
199
|
}, "schema"> & {
|
|
208
200
|
schema: "network.xyo.boundwitness";
|
|
209
201
|
}, TConf_1 extends import("@xyo-network/payload-model").SchemaFields & object & {
|
|
210
|
-
accountDerivationPath?: string | undefined;
|
|
211
202
|
readonly archivist?: string | undefined;
|
|
212
203
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
213
204
|
readonly name?: string | undefined;
|
|
@@ -224,7 +215,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
224
215
|
readonly storeQueries?: boolean | undefined;
|
|
225
216
|
readonly timestamp?: boolean | undefined;
|
|
226
217
|
} & import("@xyo-network/module-model").ArchivingModuleConfig = import("@xyo-network/payload-model").SchemaFields & object & {
|
|
227
|
-
accountDerivationPath?: string | undefined;
|
|
228
218
|
readonly archivist?: string | undefined;
|
|
229
219
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
230
220
|
readonly name?: string | undefined;
|
|
@@ -258,7 +248,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
258
248
|
resolve<T_2 extends ModuleInstance<import("@xyo-network/object").BaseParamsFields & {
|
|
259
249
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
260
250
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
261
|
-
accountDerivationPath?: string | undefined;
|
|
262
251
|
readonly archivist?: string | undefined;
|
|
263
252
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
264
253
|
readonly name?: string | undefined;
|
|
@@ -275,7 +264,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
275
264
|
readonly storeQueries?: boolean | undefined;
|
|
276
265
|
readonly timestamp?: boolean | undefined;
|
|
277
266
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
278
|
-
accountDerivationPath?: string | undefined;
|
|
279
267
|
readonly archivist?: string | undefined;
|
|
280
268
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
281
269
|
readonly name?: string | undefined;
|
|
@@ -295,11 +283,9 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
295
283
|
schema: string;
|
|
296
284
|
};
|
|
297
285
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
298
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
299
286
|
}, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xyo-network/object").BaseParamsFields & {
|
|
300
287
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
301
288
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
302
|
-
accountDerivationPath?: string | undefined;
|
|
303
289
|
readonly archivist?: string | undefined;
|
|
304
290
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
305
291
|
readonly name?: string | undefined;
|
|
@@ -316,7 +302,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
316
302
|
readonly storeQueries?: boolean | undefined;
|
|
317
303
|
readonly timestamp?: boolean | undefined;
|
|
318
304
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
319
|
-
accountDerivationPath?: string | undefined;
|
|
320
305
|
readonly archivist?: string | undefined;
|
|
321
306
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
322
307
|
readonly name?: string | undefined;
|
|
@@ -336,12 +321,10 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
336
321
|
schema: string;
|
|
337
322
|
};
|
|
338
323
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
339
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
340
324
|
}, import("@xyo-network/module-model").ModuleEventData<object>>>(filter?: import("@xyo-network/module-model").ModuleFilter<T_2> | undefined, options?: import("@xyo-network/module-model").ModuleFilterOptions<T_2> | undefined): import("@xylabs/promise").Promisable<T_2[]>;
|
|
341
325
|
resolve<T_3 extends ModuleInstance<import("@xyo-network/object").BaseParamsFields & {
|
|
342
326
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
343
327
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
344
|
-
accountDerivationPath?: string | undefined;
|
|
345
328
|
readonly archivist?: string | undefined;
|
|
346
329
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
347
330
|
readonly name?: string | undefined;
|
|
@@ -358,7 +341,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
358
341
|
readonly storeQueries?: boolean | undefined;
|
|
359
342
|
readonly timestamp?: boolean | undefined;
|
|
360
343
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
361
|
-
accountDerivationPath?: string | undefined;
|
|
362
344
|
readonly archivist?: string | undefined;
|
|
363
345
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
364
346
|
readonly name?: string | undefined;
|
|
@@ -378,11 +360,9 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
378
360
|
schema: string;
|
|
379
361
|
};
|
|
380
362
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
381
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
382
363
|
}, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xyo-network/object").BaseParamsFields & {
|
|
383
364
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
384
365
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
385
|
-
accountDerivationPath?: string | undefined;
|
|
386
366
|
readonly archivist?: string | undefined;
|
|
387
367
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
388
368
|
readonly name?: string | undefined;
|
|
@@ -399,7 +379,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
399
379
|
readonly storeQueries?: boolean | undefined;
|
|
400
380
|
readonly timestamp?: boolean | undefined;
|
|
401
381
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
402
|
-
accountDerivationPath?: string | undefined;
|
|
403
382
|
readonly archivist?: string | undefined;
|
|
404
383
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
405
384
|
readonly name?: string | undefined;
|
|
@@ -419,12 +398,10 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
419
398
|
schema: string;
|
|
420
399
|
};
|
|
421
400
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
422
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
423
401
|
}, import("@xyo-network/module-model").ModuleEventData<object>>>(nameOrAddress: string, options?: import("@xyo-network/module-model").ModuleFilterOptions<T_3> | undefined): import("@xylabs/promise").Promisable<T_3 | undefined>;
|
|
424
402
|
resolve<T_4 extends ModuleInstance<import("@xyo-network/object").BaseParamsFields & {
|
|
425
403
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
426
404
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
427
|
-
accountDerivationPath?: string | undefined;
|
|
428
405
|
readonly archivist?: string | undefined;
|
|
429
406
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
430
407
|
readonly name?: string | undefined;
|
|
@@ -441,7 +418,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
441
418
|
readonly storeQueries?: boolean | undefined;
|
|
442
419
|
readonly timestamp?: boolean | undefined;
|
|
443
420
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
444
|
-
accountDerivationPath?: string | undefined;
|
|
445
421
|
readonly archivist?: string | undefined;
|
|
446
422
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
447
423
|
readonly name?: string | undefined;
|
|
@@ -461,11 +437,9 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
461
437
|
schema: string;
|
|
462
438
|
};
|
|
463
439
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
464
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
465
440
|
}, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xyo-network/object").BaseParamsFields & {
|
|
466
441
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
467
442
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
468
|
-
accountDerivationPath?: string | undefined;
|
|
469
443
|
readonly archivist?: string | undefined;
|
|
470
444
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
471
445
|
readonly name?: string | undefined;
|
|
@@ -482,7 +456,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
482
456
|
readonly storeQueries?: boolean | undefined;
|
|
483
457
|
readonly timestamp?: boolean | undefined;
|
|
484
458
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
485
|
-
accountDerivationPath?: string | undefined;
|
|
486
459
|
readonly archivist?: string | undefined;
|
|
487
460
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
488
461
|
readonly name?: string | undefined;
|
|
@@ -502,7 +475,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
502
475
|
schema: string;
|
|
503
476
|
};
|
|
504
477
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
505
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
506
478
|
}, import("@xyo-network/module-model").ModuleEventData<object>>>(nameOrAddressOrFilter?: string | import("@xyo-network/module-model").ModuleFilter<T_4> | undefined, options?: import("@xyo-network/module-model").ModuleFilterOptions<T_4> | undefined): import("@xylabs/promise").Promisable<T_4 | T_4[] | undefined>;
|
|
507
479
|
describe: () => Promise<import("@xyo-network/module-model").ModuleDescription>;
|
|
508
480
|
discover: () => import("@xylabs/promise").Promisable<({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DivinerMixin.d.ts","sourceRoot":"","sources":["../../src/DivinerMixin.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,eAAe,EAEf,cAAc,EACd,YAAY,EACZ,WAAW,EAEX,eAAe,EAChB,MAAM,2BAA2B,CAAA;AAGlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAEhD,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAAA;AAGvF,MAAM,MAAM,SAAS,CAAC,OAAO,SAAS,oBAAoB,GAAG,oBAAoB,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,cAAc,CAAC,OAAO,CAAC,CAAA;AAIpI;;;;GAIG;AACH,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"DivinerMixin.d.ts","sourceRoot":"","sources":["../../src/DivinerMixin.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,eAAe,EAEf,cAAc,EACd,YAAY,EACZ,WAAW,EAEX,eAAe,EAChB,MAAM,2BAA2B,CAAA;AAGlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAEhD,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAAA;AAGvF,MAAM,MAAM,SAAS,CAAC,OAAO,SAAS,oBAAoB,GAAG,oBAAoB,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,cAAc,CAAC,OAAO,CAAC,CAAA;AAIpI;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8JATmE,GAAG,EAAE;;IAmBpG;;;;;;OAMG;;IAWH;;;;OAIG;;IASH;;;;OAIG;;IAWH;;;;OAIG;;IAQH;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;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