@xyo-network/diviner-stateful 2.84.18 → 2.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/DivinerMixin.d.cts +20 -28
- package/dist/browser/DivinerMixin.d.cts.map +1 -1
- package/dist/browser/DivinerMixin.d.mts +20 -28
- package/dist/browser/DivinerMixin.d.mts.map +1 -1
- package/dist/browser/DivinerMixin.d.ts +20 -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 +20 -28
- package/dist/node/DivinerMixin.d.cts.map +1 -1
- package/dist/node/DivinerMixin.d.mts +20 -28
- package/dist/node/DivinerMixin.d.mts.map +1 -1
- package/dist/node/DivinerMixin.d.ts +20 -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,7 @@ 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
|
-
|
|
13
|
+
accountPath?: string | undefined;
|
|
14
14
|
readonly archivist?: string | undefined;
|
|
15
15
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
16
16
|
readonly name?: string | undefined;
|
|
@@ -27,7 +27,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
27
27
|
readonly storeQueries?: boolean | undefined;
|
|
28
28
|
readonly timestamp?: boolean | undefined;
|
|
29
29
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
30
|
-
|
|
30
|
+
accountPath?: string | undefined;
|
|
31
31
|
readonly archivist?: string | undefined;
|
|
32
32
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
33
33
|
readonly name?: string | undefined;
|
|
@@ -56,11 +56,10 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
56
56
|
schema: string;
|
|
57
57
|
};
|
|
58
58
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
59
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
60
59
|
} = import("@xyo-network/object").BaseParamsFields & {
|
|
61
60
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
62
61
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
63
|
-
|
|
62
|
+
accountPath?: string | undefined;
|
|
64
63
|
readonly archivist?: string | undefined;
|
|
65
64
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
66
65
|
readonly name?: string | undefined;
|
|
@@ -77,7 +76,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
77
76
|
readonly storeQueries?: boolean | undefined;
|
|
78
77
|
readonly timestamp?: boolean | undefined;
|
|
79
78
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
80
|
-
|
|
79
|
+
accountPath?: string | undefined;
|
|
81
80
|
readonly archivist?: string | undefined;
|
|
82
81
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
83
82
|
readonly name?: string | undefined;
|
|
@@ -106,7 +105,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
106
105
|
schema: string;
|
|
107
106
|
};
|
|
108
107
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
109
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
110
108
|
}, TModule extends AnyModule<TParams> = AnyModule<TParams>, TState extends StateDictionary = StateDictionary>(ModuleBase: TModule) => (abstract new (...args: any[]) => {
|
|
111
109
|
_lastState?: ModuleState<TState> | undefined;
|
|
112
110
|
/**
|
|
@@ -158,7 +156,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
158
156
|
}, "schema"> & {
|
|
159
157
|
schema: "network.xyo.boundwitness";
|
|
160
158
|
}, TConf extends import("@xyo-network/payload-model").SchemaFields & object & {
|
|
161
|
-
|
|
159
|
+
accountPath?: string | undefined;
|
|
162
160
|
readonly archivist?: string | undefined;
|
|
163
161
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
164
162
|
readonly name?: string | undefined;
|
|
@@ -175,7 +173,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
175
173
|
readonly storeQueries?: boolean | undefined;
|
|
176
174
|
readonly timestamp?: boolean | undefined;
|
|
177
175
|
} & import("@xyo-network/module-model").ArchivingModuleConfig = import("@xyo-network/payload-model").SchemaFields & object & {
|
|
178
|
-
|
|
176
|
+
accountPath?: string | undefined;
|
|
179
177
|
readonly archivist?: string | undefined;
|
|
180
178
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
181
179
|
readonly name?: string | undefined;
|
|
@@ -207,7 +205,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
207
205
|
}, "schema"> & {
|
|
208
206
|
schema: "network.xyo.boundwitness";
|
|
209
207
|
}, TConf_1 extends import("@xyo-network/payload-model").SchemaFields & object & {
|
|
210
|
-
|
|
208
|
+
accountPath?: string | undefined;
|
|
211
209
|
readonly archivist?: string | undefined;
|
|
212
210
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
213
211
|
readonly name?: string | undefined;
|
|
@@ -224,7 +222,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
224
222
|
readonly storeQueries?: boolean | undefined;
|
|
225
223
|
readonly timestamp?: boolean | undefined;
|
|
226
224
|
} & import("@xyo-network/module-model").ArchivingModuleConfig = import("@xyo-network/payload-model").SchemaFields & object & {
|
|
227
|
-
|
|
225
|
+
accountPath?: string | undefined;
|
|
228
226
|
readonly archivist?: string | undefined;
|
|
229
227
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
230
228
|
readonly name?: string | undefined;
|
|
@@ -258,7 +256,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
258
256
|
resolve<T_2 extends ModuleInstance<import("@xyo-network/object").BaseParamsFields & {
|
|
259
257
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
260
258
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
261
|
-
|
|
259
|
+
accountPath?: string | undefined;
|
|
262
260
|
readonly archivist?: string | undefined;
|
|
263
261
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
264
262
|
readonly name?: string | undefined;
|
|
@@ -275,7 +273,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
275
273
|
readonly storeQueries?: boolean | undefined;
|
|
276
274
|
readonly timestamp?: boolean | undefined;
|
|
277
275
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
278
|
-
|
|
276
|
+
accountPath?: string | undefined;
|
|
279
277
|
readonly archivist?: string | undefined;
|
|
280
278
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
281
279
|
readonly name?: string | undefined;
|
|
@@ -295,11 +293,10 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
295
293
|
schema: string;
|
|
296
294
|
};
|
|
297
295
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
298
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
299
296
|
}, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xyo-network/object").BaseParamsFields & {
|
|
300
297
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
301
298
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
302
|
-
|
|
299
|
+
accountPath?: string | undefined;
|
|
303
300
|
readonly archivist?: string | undefined;
|
|
304
301
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
305
302
|
readonly name?: string | undefined;
|
|
@@ -316,7 +313,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
316
313
|
readonly storeQueries?: boolean | undefined;
|
|
317
314
|
readonly timestamp?: boolean | undefined;
|
|
318
315
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
319
|
-
|
|
316
|
+
accountPath?: string | undefined;
|
|
320
317
|
readonly archivist?: string | undefined;
|
|
321
318
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
322
319
|
readonly name?: string | undefined;
|
|
@@ -336,12 +333,11 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
336
333
|
schema: string;
|
|
337
334
|
};
|
|
338
335
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
339
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
340
336
|
}, 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
337
|
resolve<T_3 extends ModuleInstance<import("@xyo-network/object").BaseParamsFields & {
|
|
342
338
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
343
339
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
344
|
-
|
|
340
|
+
accountPath?: string | undefined;
|
|
345
341
|
readonly archivist?: string | undefined;
|
|
346
342
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
347
343
|
readonly name?: string | undefined;
|
|
@@ -358,7 +354,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
358
354
|
readonly storeQueries?: boolean | undefined;
|
|
359
355
|
readonly timestamp?: boolean | undefined;
|
|
360
356
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
361
|
-
|
|
357
|
+
accountPath?: string | undefined;
|
|
362
358
|
readonly archivist?: string | undefined;
|
|
363
359
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
364
360
|
readonly name?: string | undefined;
|
|
@@ -378,11 +374,10 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
378
374
|
schema: string;
|
|
379
375
|
};
|
|
380
376
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
381
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
382
377
|
}, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xyo-network/object").BaseParamsFields & {
|
|
383
378
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
384
379
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
385
|
-
|
|
380
|
+
accountPath?: string | undefined;
|
|
386
381
|
readonly archivist?: string | undefined;
|
|
387
382
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
388
383
|
readonly name?: string | undefined;
|
|
@@ -399,7 +394,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
399
394
|
readonly storeQueries?: boolean | undefined;
|
|
400
395
|
readonly timestamp?: boolean | undefined;
|
|
401
396
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
402
|
-
|
|
397
|
+
accountPath?: string | undefined;
|
|
403
398
|
readonly archivist?: string | undefined;
|
|
404
399
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
405
400
|
readonly name?: string | undefined;
|
|
@@ -419,12 +414,11 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
419
414
|
schema: string;
|
|
420
415
|
};
|
|
421
416
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
422
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
423
417
|
}, 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
418
|
resolve<T_4 extends ModuleInstance<import("@xyo-network/object").BaseParamsFields & {
|
|
425
419
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
426
420
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
427
|
-
|
|
421
|
+
accountPath?: string | undefined;
|
|
428
422
|
readonly archivist?: string | undefined;
|
|
429
423
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
430
424
|
readonly name?: string | undefined;
|
|
@@ -441,7 +435,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
441
435
|
readonly storeQueries?: boolean | undefined;
|
|
442
436
|
readonly timestamp?: boolean | undefined;
|
|
443
437
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
444
|
-
|
|
438
|
+
accountPath?: string | undefined;
|
|
445
439
|
readonly archivist?: string | undefined;
|
|
446
440
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
447
441
|
readonly name?: string | undefined;
|
|
@@ -461,11 +455,10 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
461
455
|
schema: string;
|
|
462
456
|
};
|
|
463
457
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
464
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
465
458
|
}, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xyo-network/object").BaseParamsFields & {
|
|
466
459
|
account?: import("@xyo-network/account-model").AccountInstance | "random" | undefined;
|
|
467
460
|
config: import("@xyo-network/payload-model").SchemaFields & object & Omit<{
|
|
468
|
-
|
|
461
|
+
accountPath?: string | undefined;
|
|
469
462
|
readonly archivist?: string | undefined;
|
|
470
463
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
471
464
|
readonly name?: string | undefined;
|
|
@@ -482,7 +475,7 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
482
475
|
readonly storeQueries?: boolean | undefined;
|
|
483
476
|
readonly timestamp?: boolean | undefined;
|
|
484
477
|
} & import("@xyo-network/module-model").ArchivingModuleConfig & import("@xyo-network/payload-model").SchemaFields & object & {
|
|
485
|
-
|
|
478
|
+
accountPath?: string | undefined;
|
|
486
479
|
readonly archivist?: string | undefined;
|
|
487
480
|
readonly labels?: import("@xyo-network/module-model").Labels | undefined;
|
|
488
481
|
readonly name?: string | undefined;
|
|
@@ -502,7 +495,6 @@ export declare const StatefulModuleMixin: <TParams extends import("@xyo-network/
|
|
|
502
495
|
schema: string;
|
|
503
496
|
};
|
|
504
497
|
ephemeralQueryAccountEnabled?: boolean | undefined;
|
|
505
|
-
wallet?: import("@xyo-network/wallet-model").WalletInstance | undefined;
|
|
506
498
|
}, 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
499
|
describe: () => Promise<import("@xyo-network/module-model").ModuleDescription>;
|
|
508
500
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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