@xyo-network/diviner-stateful 4.0.2 → 4.1.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/types → build/neutral}/Diviner.d.ts +3 -3
- package/build/neutral/DivinerMixin.d.ts +5 -0
- package/build/neutral/DivinerMixin.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +86 -0
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +29 -29
- package/src/DivinerMixin.ts +1 -0
- package/dist/types/DivinerMixin.d.ts +0 -88
- package/dist/types/DivinerMixin.d.ts.map +0 -1
- /package/{dist/types → build/neutral}/Config.d.ts +0 -0
- /package/{dist/types → build/neutral}/Config.d.ts.map +0 -0
- /package/{dist/types → build/neutral}/Diviner.d.ts.map +0 -0
- /package/{dist/types → build/neutral}/Params.d.ts +0 -0
- /package/{dist/types → build/neutral}/Params.d.ts.map +0 -0
- /package/{dist/types → build/neutral}/Schema.d.ts +0 -0
- /package/{dist/types → build/neutral}/Schema.d.ts.map +0 -0
- /package/{dist/types → build/neutral}/index.d.ts +0 -0
- /package/{dist/types → build/neutral}/index.d.ts.map +0 -0
|
@@ -28,19 +28,19 @@ export declare abstract class StatefulDiviner<TParams extends StatefulDivinerPar
|
|
|
28
28
|
* @param store The store to retrieve the archivist for
|
|
29
29
|
* @returns The archivist for the specified store
|
|
30
30
|
*/
|
|
31
|
-
protected getArchivistForStateStore(): Promise<ArchivistWrapper<import("@xyo-network/archivist-model").ArchivistModuleInstance<import("@xyo-network/module-model").ModuleParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/archivist-model").ArchivistConfig
|
|
31
|
+
protected getArchivistForStateStore(): Promise<ArchivistWrapper<import("@xyo-network/archivist-model").ArchivistModuleInstance<import("@xyo-network/module-model").ModuleParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/archivist-model").ArchivistConfig<void, void>>>, import("@xyo-network/archivist-model").ArchivistModuleEventData>>>;
|
|
32
32
|
/**
|
|
33
33
|
* Retrieves the BoundWitness Diviner for the specified store
|
|
34
34
|
* @param store The store to retrieve the BoundWitness Diviner for
|
|
35
35
|
* @returns The BoundWitness Diviner for the specified store
|
|
36
36
|
*/
|
|
37
|
-
protected getBoundWitnessDivinerForStateStore(): Promise<DivinerWrapper<import("@xyo-network/diviner-model").DivinerModule<import("@xyo-network/diviner-model").DivinerParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/diviner-model").DivinerConfig
|
|
37
|
+
protected getBoundWitnessDivinerForStateStore(): Promise<DivinerWrapper<import("@xyo-network/diviner-model").DivinerModule<import("@xyo-network/diviner-model").DivinerParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/diviner-model").DivinerConfig<void, void>>>, DivinerModuleEventData<import("@xyo-network/module-model").ModuleInstance<import("@xyo-network/module-model").ModuleParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig<object, void>>>, import("@xyo-network/module-model").ModuleEventData<object>>, Payload, Payload>>, Payload, Payload>>;
|
|
38
38
|
/**
|
|
39
39
|
* Retrieves the Payload Diviner for the specified store
|
|
40
40
|
* @param store The store to retrieve the Payload Diviner for
|
|
41
41
|
* @returns The Payload Diviner for the specified store
|
|
42
42
|
*/
|
|
43
|
-
protected getPayloadDivinerForStateStore(): Promise<DivinerWrapper<import("@xyo-network/diviner-model").DivinerModule<import("@xyo-network/diviner-model").DivinerParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/diviner-model").DivinerConfig
|
|
43
|
+
protected getPayloadDivinerForStateStore(): Promise<DivinerWrapper<import("@xyo-network/diviner-model").DivinerModule<import("@xyo-network/diviner-model").DivinerParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/diviner-model").DivinerConfig<void, void>>>, DivinerModuleEventData<import("@xyo-network/module-model").ModuleInstance<import("@xyo-network/module-model").ModuleParams<import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig<object, void>>>, import("@xyo-network/module-model").ModuleEventData<object>>, Payload, Payload>>, Payload, Payload>>;
|
|
44
44
|
/**
|
|
45
45
|
* Retrieves the last state of the Diviner process. Used to recover state after
|
|
46
46
|
* preemptions, reboots, etc.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AnyConfigSchema, ModuleInstance, ModuleParams } from '@xyo-network/module-model';
|
|
2
|
+
import type { StatefulDivinerConfig } from './Config.ts';
|
|
3
|
+
export type StatefulModuleParams = ModuleParams<AnyConfigSchema<StatefulDivinerConfig>>;
|
|
4
|
+
export type AnyModule<TParams extends StatefulModuleParams = StatefulModuleParams> = new (...args: any[]) => ModuleInstance<TParams>;
|
|
5
|
+
//# sourceMappingURL=DivinerMixin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DivinerMixin.d.ts","sourceRoot":"","sources":["../../src/DivinerMixin.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,YAAY,EAGb,MAAM,2BAA2B,CAAA;AASlC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD,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"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as _xyo_network_diviner_model from '@xyo-network/diviner-model';
|
|
2
|
+
import { DivinerConfig, DivinerParams, DivinerModuleEventData, DivinerInstance } from '@xyo-network/diviner-model';
|
|
3
|
+
import * as _xyo_network_module_model from '@xyo-network/module-model';
|
|
4
|
+
import { ModuleIdentifier, AnyConfigSchema, StateDictionary, ModuleState, ModuleParams, ModuleInstance } from '@xyo-network/module-model';
|
|
5
|
+
import * as _xyo_network_archivist_model from '@xyo-network/archivist-model';
|
|
6
|
+
import { ArchivistWrapper } from '@xyo-network/archivist-wrapper';
|
|
7
|
+
import { AbstractDiviner } from '@xyo-network/diviner-abstract';
|
|
8
|
+
import { DivinerWrapper } from '@xyo-network/diviner-wrapper';
|
|
9
|
+
import { Payload, Schema } from '@xyo-network/payload-model';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The schema for a Stateful Diviner config
|
|
13
|
+
*/
|
|
14
|
+
declare const StatefulDivinerConfigSchema: "network.xyo.diviner.stateful.config";
|
|
15
|
+
/**
|
|
16
|
+
* The schema for a Stateful Diviner config
|
|
17
|
+
*/
|
|
18
|
+
type StatefulDivinerConfigSchema = typeof StatefulDivinerConfigSchema;
|
|
19
|
+
/**
|
|
20
|
+
* The config for a Stateful Diviner
|
|
21
|
+
*/
|
|
22
|
+
type StatefulDivinerConfig = DivinerConfig<{
|
|
23
|
+
schema: StatefulDivinerConfigSchema;
|
|
24
|
+
stateStore: {
|
|
25
|
+
archivist: ModuleIdentifier;
|
|
26
|
+
boundWitnessDiviner: ModuleIdentifier;
|
|
27
|
+
payloadDiviner: ModuleIdentifier;
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The parameters for a Stateful Diviner
|
|
33
|
+
*/
|
|
34
|
+
type StatefulDivinerParams = DivinerParams<AnyConfigSchema<StatefulDivinerConfig>>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A Diviner that maintains state
|
|
38
|
+
*/
|
|
39
|
+
declare abstract class StatefulDiviner<TParams extends StatefulDivinerParams = StatefulDivinerParams, TIn extends Payload = Payload, TOut extends Payload = Payload, TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut>, TState extends StateDictionary = StateDictionary> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {
|
|
40
|
+
static readonly configSchemas: Schema[];
|
|
41
|
+
static readonly defaultConfigSchema: Schema;
|
|
42
|
+
/**
|
|
43
|
+
* The last state
|
|
44
|
+
*/
|
|
45
|
+
protected _lastState?: ModuleState<TState>;
|
|
46
|
+
/**
|
|
47
|
+
* Commit the internal state of the Diviner process. This is similar
|
|
48
|
+
* to a transaction completion in a database and should only be called
|
|
49
|
+
* when results have been successfully persisted to the appropriate
|
|
50
|
+
* external stores.
|
|
51
|
+
* @param nextState The state to commit
|
|
52
|
+
*/
|
|
53
|
+
protected commitState(nextState: ModuleState<TState>): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves the archivist for the specified store
|
|
56
|
+
* @param store The store to retrieve the archivist for
|
|
57
|
+
* @returns The archivist for the specified store
|
|
58
|
+
*/
|
|
59
|
+
protected getArchivistForStateStore(): Promise<ArchivistWrapper<_xyo_network_archivist_model.ArchivistModuleInstance<_xyo_network_module_model.ModuleParams<_xyo_network_module_model.AnyConfigSchema<_xyo_network_archivist_model.ArchivistConfig<void, void>>>, _xyo_network_archivist_model.ArchivistModuleEventData>>>;
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves the BoundWitness Diviner for the specified store
|
|
62
|
+
* @param store The store to retrieve the BoundWitness Diviner for
|
|
63
|
+
* @returns The BoundWitness Diviner for the specified store
|
|
64
|
+
*/
|
|
65
|
+
protected getBoundWitnessDivinerForStateStore(): Promise<DivinerWrapper<_xyo_network_diviner_model.DivinerModule<_xyo_network_diviner_model.DivinerParams<_xyo_network_module_model.AnyConfigSchema<_xyo_network_diviner_model.DivinerConfig<void, void>>>, DivinerModuleEventData<_xyo_network_module_model.ModuleInstance<_xyo_network_module_model.ModuleParams<_xyo_network_module_model.AnyConfigSchema<_xyo_network_module_model.ModuleConfig<object, void>>>, _xyo_network_module_model.ModuleEventData<object>>, Payload, Payload>>, Payload, Payload>>;
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves the Payload Diviner for the specified store
|
|
68
|
+
* @param store The store to retrieve the Payload Diviner for
|
|
69
|
+
* @returns The Payload Diviner for the specified store
|
|
70
|
+
*/
|
|
71
|
+
protected getPayloadDivinerForStateStore(): Promise<DivinerWrapper<_xyo_network_diviner_model.DivinerModule<_xyo_network_diviner_model.DivinerParams<_xyo_network_module_model.AnyConfigSchema<_xyo_network_diviner_model.DivinerConfig<void, void>>>, DivinerModuleEventData<_xyo_network_module_model.ModuleInstance<_xyo_network_module_model.ModuleParams<_xyo_network_module_model.AnyConfigSchema<_xyo_network_module_model.ModuleConfig<object, void>>>, _xyo_network_module_model.ModuleEventData<object>>, Payload, Payload>>, Payload, Payload>>;
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves the last state of the Diviner process. Used to recover state after
|
|
74
|
+
* preemptions, reboots, etc.
|
|
75
|
+
*/
|
|
76
|
+
protected retrieveState(): Promise<ModuleState<TState> | undefined>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type StatefulModuleParams = ModuleParams<AnyConfigSchema<StatefulDivinerConfig>>;
|
|
80
|
+
type AnyModule<TParams extends StatefulModuleParams = StatefulModuleParams> = new (...args: any[]) => ModuleInstance<TParams>;
|
|
81
|
+
|
|
82
|
+
declare const StatefulDivinerSchema: "network.xyo.diviner.stateful";
|
|
83
|
+
type StatefulDivinerSchema = typeof StatefulDivinerSchema;
|
|
84
|
+
|
|
85
|
+
export { StatefulDiviner, StatefulDivinerConfigSchema, StatefulDivinerSchema };
|
|
86
|
+
export type { AnyModule, StatefulDivinerConfig, StatefulDivinerParams, StatefulModuleParams };
|
|
@@ -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 type { DivinerConfig } from '@xyo-network/diviner-model'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { StatefulDivinerSchema } from './Schema.ts'\n\n/**\n * The schema for a Stateful Diviner config\n */\nexport const StatefulDivinerConfigSchema = `${StatefulDivinerSchema}.config` as const\n/**\n * The schema for a Stateful Diviner config\n */\nexport type StatefulDivinerConfigSchema = typeof StatefulDivinerConfigSchema\n\n/**\n * The config for a Stateful Diviner\n */\nexport type StatefulDivinerConfig = DivinerConfig<{\n schema: StatefulDivinerConfigSchema\n stateStore: {\n archivist: ModuleIdentifier\n boundWitnessDiviner: ModuleIdentifier\n payloadDiviner: ModuleIdentifier\n }\n}>\n","import { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport { toJson } from '@xylabs/object'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'\nimport { BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport type { ModuleState, StateDictionary } from '@xyo-network/module-model'\nimport { isModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type {\n Payload, Schema,\n WithStorageMeta,\n} from '@xyo-network/payload-model'\nimport { SequenceConstants } from '@xyo-network/payload-model'\n\nimport { StatefulDivinerConfigSchema } from './Config.ts'\nimport type { StatefulDivinerParams } from './Params.ts'\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<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n TState extends StateDictionary = StateDictionary,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, StatefulDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 (toJson(nextState.state) === toJson(this._lastState?.state)) return\n this._lastState = nextState\n const archivist = await this.getArchivistForStateStore()\n const [bw] = await new BoundWitnessBuilder().payload(nextState).signer(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: Hash = ''\n const diviner = await this.getBoundWitnessDivinerForStateStore()\n const query = new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({\n address: this.account.address,\n limit: 1,\n cursor: SequenceConstants.minLocalSequence,\n order: 'desc',\n payload_schemas: [ModuleStateSchema],\n })\n .build()\n const boundWitnesses = await diviner.divine([query])\n if (boundWitnesses.length > 0) {\n const boundWitness = boundWitnesses[0]\n if (isBoundWitness(boundWitness)) {\n // Find the index for this address in the BoundWitness that is a ModuleState\n hash = boundWitness.addresses\n .map((address, index) => ({ address, index }))\n .filter(({ address }) => address === this.account.address)\n // eslint-disable-next-line unicorn/no-array-reduce\n .reduce(\n (prev, curr) => (boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev),\n '' as Hash,\n )\n }\n }\n\n // If we able to located the last state\n if (hash) {\n // Get last state\n const archivist = await this.getArchivistForStateStore()\n const payload = (await archivist.get([hash])).find(isModuleState<TState>)\n if (payload) {\n return payload as WithStorageMeta<ModuleState<TState>>\n }\n }\n return undefined\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport { toJson } from '@xylabs/object'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'\nimport { BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport type {\n AnyConfigSchema,\n ModuleInstance,\n ModuleParams,\n ModuleState,\n StateDictionary,\n} from '@xyo-network/module-model'\nimport {\n isModuleState,\n ModuleStateSchema,\n} from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { SequenceConstants } from '@xyo-network/payload-model'\n\nimport type { StatefulDivinerConfig } from './Config.ts'\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 (toJson(nextState.state) === toJson(this._lastState?.state)) return\n this._lastState = nextState\n const archivist = await this.getArchivistForStore()\n // const [bw] = await new BoundWitnessBuilder().payload(nextState).signer(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 /**\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 /**\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: Hash = ''\n const diviner = await this.getBoundWitnessDivinerForStore()\n const query = new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({\n // address: this.account.address,\n limit: 1,\n cursor: SequenceConstants.minLocalSequence,\n order: 'desc',\n payload_schemas: [ModuleStateSchema],\n })\n .build()\n const boundWitnesses = await diviner.divine([query])\n if (boundWitnesses.length > 0) {\n const boundWitness = boundWitnesses[0]\n if (isBoundWitness(boundWitness)) {\n // Find the index for this address in the BoundWitness that is a ModuleState\n hash = boundWitness.addresses\n .map((address, index) => ({ address, index }))\n // .filter(({ address }) => address === this.account.address)\n // eslint-disable-next-line unicorn/no-array-reduce\n .reduce(\n (prev, curr) => (boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev),\n '' as Hash,\n )\n }\n }\n\n // If we able to located the last state\n if (hash) {\n // Get last state\n const archivist = await this.getArchivistForStore()\n const payload = (await archivist.get([hash])).find(isModuleState<TState>)\n if (payload) {\n return payload as WithStorageMeta<ModuleState<TState>>\n }\n }\n return undefined\n }\n }\n return StatefulModuleBase\n}\n"],"mappings":";AAAO,IAAM,wBAAwB;;;ACQ9B,IAAM,8BAA8B,GAAG,qBAAqB;;;ACRnE,SAAS,gBAAgB;AAEzB,SAAS,cAAc;AACvB,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAEhC,SAAS,sCAAsC;AAE/C,SAAS,sBAAsB;AAE/B,SAAS,eAAe,yBAAyB;AACjD,SAAS,sBAAsB;AAK/B,SAAS,yBAAyB;AAKlC,IAAM,aAAa;AAKZ,IAAe,kBAAf,cAUG,gBAAgD;AAAA,EACxD,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,2BAA2B;AAAA,EACvG,OAAyB,sBAA8B;AAAA;AAAA;AAAA;AAAA,EAK7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASV,MAAgB,YAAY,WAAgC;AAE1D,QAAI,OAAO,UAAU,KAAK,MAAM,OAAO,KAAK,YAAY,KAAK,EAAG;AAChE,SAAK,aAAa;AAClB,UAAM,YAAY,MAAM,KAAK,0BAA0B;AACvD,UAAM,CAAC,EAAE,IAAI,MAAM,IAAI,oBAAoB,EAAE,QAAQ,SAAS,EAAE,OAA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,UAAI,KAAK,WAAY,QAAO,KAAK;AACjC,UAAI,OAAa;AACjB,YAAM,UAAU,MAAM,KAAK,+BAA+B;AAC1D,YAAM,QAAQ,IAAIF,gBAAgD,EAAE,QAAQH,gCAA+B,CAAC,EACzG,OAAO;AAAA;AAAA,QAEN,OAAO;AAAA,QACP,QAAQI,mBAAkB;AAAA,QAC1B,OAAO;AAAA,QACP,iBAAiB,CAACF,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","toJson","BoundWitnessBuilder","isBoundWitness","BoundWitnessDivinerQuerySchema","isModuleState","ModuleStateSchema","PayloadBuilder","SequenceConstants","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 type { DivinerConfig } from '@xyo-network/diviner-model'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\n\nimport { StatefulDivinerSchema } from './Schema.ts'\n\n/**\n * The schema for a Stateful Diviner config\n */\nexport const StatefulDivinerConfigSchema = `${StatefulDivinerSchema}.config` as const\n/**\n * The schema for a Stateful Diviner config\n */\nexport type StatefulDivinerConfigSchema = typeof StatefulDivinerConfigSchema\n\n/**\n * The config for a Stateful Diviner\n */\nexport type StatefulDivinerConfig = DivinerConfig<{\n schema: StatefulDivinerConfigSchema\n stateStore: {\n archivist: ModuleIdentifier\n boundWitnessDiviner: ModuleIdentifier\n payloadDiviner: ModuleIdentifier\n }\n}>\n","import { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport { toJson } from '@xylabs/object'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'\nimport { BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport type { ModuleState, StateDictionary } from '@xyo-network/module-model'\nimport { isModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type {\n Payload, Schema,\n WithStorageMeta,\n} from '@xyo-network/payload-model'\nimport { SequenceConstants } from '@xyo-network/payload-model'\n\nimport { StatefulDivinerConfigSchema } from './Config.ts'\nimport type { StatefulDivinerParams } from './Params.ts'\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<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n TState extends StateDictionary = StateDictionary,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, StatefulDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = 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 (toJson(nextState.state) === toJson(this._lastState?.state)) return\n this._lastState = nextState\n const archivist = await this.getArchivistForStateStore()\n const [bw] = await new BoundWitnessBuilder().payload(nextState).signer(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: Hash = ''\n const diviner = await this.getBoundWitnessDivinerForStateStore()\n const query = new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({\n address: this.account.address,\n limit: 1,\n cursor: SequenceConstants.minLocalSequence,\n order: 'desc',\n payload_schemas: [ModuleStateSchema],\n })\n .build()\n const boundWitnesses = await diviner.divine([query])\n if (boundWitnesses.length > 0) {\n const boundWitness = boundWitnesses[0]\n if (isBoundWitness(boundWitness)) {\n // Find the index for this address in the BoundWitness that is a ModuleState\n hash = boundWitness.addresses\n .map((address, index) => ({ address, index }))\n .filter(({ address }) => address === this.account.address)\n // eslint-disable-next-line unicorn/no-array-reduce\n .reduce(\n (prev, curr) => (boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev),\n '' as Hash,\n )\n }\n }\n\n // If we able to located the last state\n if (hash) {\n // Get last state\n const archivist = await this.getArchivistForStateStore()\n const payload = (await archivist.get([hash])).find(isModuleState<TState>)\n if (payload) {\n return payload as WithStorageMeta<ModuleState<TState>>\n }\n }\n return undefined\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport { toJson } from '@xylabs/object'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport type { BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'\nimport { BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport type {\n AnyConfigSchema,\n ModuleInstance,\n ModuleParams,\n ModuleState,\n StateDictionary,\n} from '@xyo-network/module-model'\nimport {\n isModuleState,\n ModuleStateSchema,\n} from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { SequenceConstants } from '@xyo-network/payload-model'\n\nimport type { StatefulDivinerConfig } from './Config.ts'\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 * @internal\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 (toJson(nextState.state) === toJson(this._lastState?.state)) return\n this._lastState = nextState\n const archivist = await this.getArchivistForStore()\n // const [bw] = await new BoundWitnessBuilder().payload(nextState).signer(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 /**\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 /**\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: Hash = ''\n const diviner = await this.getBoundWitnessDivinerForStore()\n const query = new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({\n // address: this.account.address,\n limit: 1,\n cursor: SequenceConstants.minLocalSequence,\n order: 'desc',\n payload_schemas: [ModuleStateSchema],\n })\n .build()\n const boundWitnesses = await diviner.divine([query])\n if (boundWitnesses.length > 0) {\n const boundWitness = boundWitnesses[0]\n if (isBoundWitness(boundWitness)) {\n // Find the index for this address in the BoundWitness that is a ModuleState\n hash = boundWitness.addresses\n .map((address, index) => ({ address, index }))\n // .filter(({ address }) => address === this.account.address)\n // eslint-disable-next-line unicorn/no-array-reduce\n .reduce(\n (prev, curr) => (boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev),\n '' as Hash,\n )\n }\n }\n\n // If we able to located the last state\n if (hash) {\n // Get last state\n const archivist = await this.getArchivistForStore()\n const payload = (await archivist.get([hash])).find(isModuleState<TState>)\n if (payload) {\n return payload as WithStorageMeta<ModuleState<TState>>\n }\n }\n return undefined\n }\n }\n return StatefulModuleBase\n}\n"],"mappings":";AAAO,IAAM,wBAAwB;;;ACQ9B,IAAM,8BAA8B,GAAG,qBAAqB;;;ACRnE,SAAS,gBAAgB;AAEzB,SAAS,cAAc;AACvB,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAEhC,SAAS,sCAAsC;AAE/C,SAAS,sBAAsB;AAE/B,SAAS,eAAe,yBAAyB;AACjD,SAAS,sBAAsB;AAK/B,SAAS,yBAAyB;AAKlC,IAAM,aAAa;AAKZ,IAAe,kBAAf,cAUG,gBAAgD;AAAA,EACxD,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,2BAA2B;AAAA,EACvG,OAAyB,sBAA8B;AAAA;AAAA;AAAA;AAAA,EAK7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASV,MAAgB,YAAY,WAAgC;AAE1D,QAAI,OAAO,UAAU,KAAK,MAAM,OAAO,KAAK,YAAY,KAAK,EAAG;AAChE,SAAK,aAAa;AAClB,UAAM,YAAY,MAAM,KAAK,0BAA0B;AACvD,UAAM,CAAC,EAAE,IAAI,MAAM,IAAI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AAAA;AAAA,IAMA,MAAM,gBAA0D;AAC9D,UAAI,KAAK,WAAY,QAAO,KAAK;AACjC,UAAI,OAAa;AACjB,YAAM,UAAU,MAAM,KAAK,+BAA+B;AAC1D,YAAM,QAAQ,IAAIF,gBAAgD,EAAE,QAAQH,gCAA+B,CAAC,EACzG,OAAO;AAAA;AAAA,QAEN,OAAO;AAAA,QACP,QAAQI,mBAAkB;AAAA,QAC1B,OAAO;AAAA,QACP,iBAAiB,CAACF,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","toJson","BoundWitnessBuilder","isBoundWitness","BoundWitnessDivinerQuerySchema","isModuleState","ModuleStateSchema","PayloadBuilder","SequenceConstants","moduleName"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/diviner-stateful",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -21,42 +21,42 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
|
-
"types": "./dist/
|
|
24
|
+
"types": "./dist/neutral/index.d.ts",
|
|
25
25
|
"default": "./dist/neutral/index.mjs"
|
|
26
26
|
},
|
|
27
27
|
"./package.json": "./package.json"
|
|
28
28
|
},
|
|
29
29
|
"module": "dist/neutral/index.mjs",
|
|
30
|
-
"types": "dist/
|
|
30
|
+
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@xylabs/assert": "^4.
|
|
33
|
-
"@xylabs/object": "^4.
|
|
34
|
-
"@xyo-network/archivist-model": "^4.0
|
|
35
|
-
"@xyo-network/archivist-wrapper": "^4.0
|
|
36
|
-
"@xyo-network/boundwitness-builder": "^4.0
|
|
37
|
-
"@xyo-network/boundwitness-model": "^4.0
|
|
38
|
-
"@xyo-network/diviner-abstract": "^4.0
|
|
39
|
-
"@xyo-network/diviner-boundwitness-model": "^4.0
|
|
40
|
-
"@xyo-network/diviner-model": "^4.0
|
|
41
|
-
"@xyo-network/diviner-
|
|
42
|
-
"@xyo-network/
|
|
43
|
-
"@xyo-network/
|
|
44
|
-
"@xyo-network/payload-
|
|
45
|
-
"@xyo-network/payload-model": "^4.0.2"
|
|
32
|
+
"@xylabs/assert": "^4.13.15",
|
|
33
|
+
"@xylabs/object": "^4.13.15",
|
|
34
|
+
"@xyo-network/archivist-model": "^4.1.0",
|
|
35
|
+
"@xyo-network/archivist-wrapper": "^4.1.0",
|
|
36
|
+
"@xyo-network/boundwitness-builder": "^4.1.0",
|
|
37
|
+
"@xyo-network/boundwitness-model": "^4.1.0",
|
|
38
|
+
"@xyo-network/diviner-abstract": "^4.1.0",
|
|
39
|
+
"@xyo-network/diviner-boundwitness-model": "^4.1.0",
|
|
40
|
+
"@xyo-network/diviner-model": "^4.1.0",
|
|
41
|
+
"@xyo-network/diviner-wrapper": "^4.1.0",
|
|
42
|
+
"@xyo-network/module-model": "^4.1.0",
|
|
43
|
+
"@xyo-network/payload-builder": "^4.1.0",
|
|
44
|
+
"@xyo-network/payload-model": "^4.1.0"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
|
-
"@xylabs/hex": "^4.
|
|
49
|
-
"@xylabs/ts-scripts-yarn3": "^
|
|
50
|
-
"@xylabs/tsconfig": "^
|
|
51
|
-
"@xylabs/vitest-extended": "^4.
|
|
52
|
-
"@xyo-network/account": "^4.0
|
|
53
|
-
"@xyo-network/archivist-memory": "^4.0
|
|
54
|
-
"@xyo-network/diviner-boundwitness-memory": "^4.0
|
|
55
|
-
"@xyo-network/diviner-payload-
|
|
56
|
-
"@xyo-network/
|
|
57
|
-
"@xyo-network/
|
|
58
|
-
"@xyo-network/
|
|
59
|
-
"@xyo-network/
|
|
47
|
+
"@xylabs/hex": "^4.13.15",
|
|
48
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.0-rc.20",
|
|
49
|
+
"@xylabs/tsconfig": "^7.0.0-rc.20",
|
|
50
|
+
"@xylabs/vitest-extended": "^4.13.15",
|
|
51
|
+
"@xyo-network/account": "^4.1.0",
|
|
52
|
+
"@xyo-network/archivist-memory": "^4.1.0",
|
|
53
|
+
"@xyo-network/diviner-boundwitness-memory": "^4.1.0",
|
|
54
|
+
"@xyo-network/diviner-payload-generic": "^4.1.0",
|
|
55
|
+
"@xyo-network/diviner-payload-memory": "^4.1.0",
|
|
56
|
+
"@xyo-network/manifest": "^4.1.0",
|
|
57
|
+
"@xyo-network/module-factory-locator": "^4.1.0",
|
|
58
|
+
"@xyo-network/node-memory": "^4.1.0",
|
|
59
|
+
"@xyo-network/wallet": "^4.1.0",
|
|
60
60
|
"typescript": "^5.8.3",
|
|
61
61
|
"vitest": "^3.2.4"
|
|
62
62
|
},
|
package/src/DivinerMixin.ts
CHANGED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import type { AnyConfigSchema, ModuleInstance, ModuleParams, ModuleState, StateDictionary } from '@xyo-network/module-model';
|
|
2
|
-
import type { StatefulDivinerConfig } from './Config.ts';
|
|
3
|
-
export type StatefulModuleParams = ModuleParams<AnyConfigSchema<StatefulDivinerConfig>>;
|
|
4
|
-
export type AnyModule<TParams extends StatefulModuleParams = StatefulModuleParams> = new (...args: any[]) => ModuleInstance<TParams>;
|
|
5
|
-
/**
|
|
6
|
-
* @ignore Inherit from StatefulDiviner instead
|
|
7
|
-
* @param ModuleBase
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export declare const StatefulModuleMixin: <TParams extends StatefulModuleParams = StatefulModuleParams, TModule extends AnyModule<TParams> = AnyModule<TParams>, TState extends StateDictionary = StateDictionary>(ModuleBase: TModule) => (abstract new (...args: any[]) => {
|
|
11
|
-
_lastState?: ModuleState<TState>;
|
|
12
|
-
/**
|
|
13
|
-
* Commit the internal state of the Diviner process. This is similar
|
|
14
|
-
* to a transaction completion in a database and should only be called
|
|
15
|
-
* when results have been successfully persisted to the appropriate
|
|
16
|
-
* external stores.
|
|
17
|
-
* @param nextState The state to commit
|
|
18
|
-
*/
|
|
19
|
-
commitState(nextState: ModuleState<TState>): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Retrieves the archivist for the specified store
|
|
22
|
-
* @param store The store to retrieve the archivist for
|
|
23
|
-
* @returns The archivist for the specified store
|
|
24
|
-
*/
|
|
25
|
-
getArchivistForStore(): Promise<import("@xyo-network/archivist-model").ArchivistInstance<import("@xyo-network/archivist-model").ArchivistParams<AnyConfigSchema<import("@xyo-network/archivist-model").ArchivistConfig<void, void>>>, import("@xyo-network/archivist-model").ArchivistModuleEventData, import("@xyo-network/payload-model").Payload<void, void>>>;
|
|
26
|
-
/**
|
|
27
|
-
* Retrieves the BoundWitness Diviner for the specified store
|
|
28
|
-
* @param store The store to retrieve the BoundWitness Diviner for
|
|
29
|
-
* @returns The BoundWitness Diviner for the specified store
|
|
30
|
-
*/
|
|
31
|
-
getBoundWitnessDivinerForStore(): Promise<import("@xyo-network/diviner-model").DivinerInstance<import("@xyo-network/diviner-model").DivinerParams<AnyConfigSchema<import("@xyo-network/diviner-model").DivinerConfig<void, void>>>, import("@xyo-network/payload-model").Payload<void, void>, import("@xyo-network/payload-model").Payload<void, void>, import("@xyo-network/diviner-model").DivinerModuleEventData<ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>, import("@xyo-network/payload-model").Payload, import("@xyo-network/payload-model").Payload>>>;
|
|
32
|
-
/**
|
|
33
|
-
* Retrieves the Payload Diviner for the specified store
|
|
34
|
-
* @param store The store to retrieve the Payload Diviner for
|
|
35
|
-
* @returns The Payload Diviner for the specified store
|
|
36
|
-
*/
|
|
37
|
-
getPayloadDivinerForStateStore(): Promise<import("@xyo-network/diviner-model").DivinerInstance<import("@xyo-network/diviner-model").DivinerParams<AnyConfigSchema<import("@xyo-network/diviner-model").DivinerConfig<void, void>>>, import("@xyo-network/payload-model").Payload<void, void>, import("@xyo-network/payload-model").Payload<void, void>, import("@xyo-network/diviner-model").DivinerModuleEventData<ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>, import("@xyo-network/payload-model").Payload, import("@xyo-network/payload-model").Payload>>>;
|
|
38
|
-
/**
|
|
39
|
-
* Retrieves the last state of the Diviner process. Used to recover state after
|
|
40
|
-
* preemptions, reboots, etc.
|
|
41
|
-
*/
|
|
42
|
-
retrieveState(): Promise<ModuleState<TState> | undefined>;
|
|
43
|
-
readonly pipeline?: import("@xyo-network/module-model").ModulePipeLine;
|
|
44
|
-
readonly status: import("@xyo-network/module-model").ModuleStatus;
|
|
45
|
-
address: import("@xylabs/hex").Address;
|
|
46
|
-
config: TParams["config"];
|
|
47
|
-
id: string;
|
|
48
|
-
modName?: import("@xyo-network/module-model").ModuleName;
|
|
49
|
-
params: TParams;
|
|
50
|
-
previousHash: () => import("@xylabs/promise").Promisable<string | undefined>;
|
|
51
|
-
queries: string[];
|
|
52
|
-
query: <T extends import("@xyo-network/boundwitness-model").QueryBoundWitness = import("@xyo-network/boundwitness-model").QueryBoundWitness, TConf extends import("@xyo-network/module-model").ModuleConfig = import("@xyo-network/module-model").ModuleConfig>(query: T, payloads?: import("@xyo-network/payload-model").Payload[], queryConfig?: TConf) => import("@xylabs/promise").Promisable<import("@xyo-network/module-model").ModuleQueryResult>;
|
|
53
|
-
queryable: <T extends import("@xyo-network/boundwitness-model").QueryBoundWitness = import("@xyo-network/boundwitness-model").QueryBoundWitness, TConf_1 extends import("@xyo-network/module-model").ModuleConfig = import("@xyo-network/module-model").ModuleConfig>(query: T, payloads?: import("@xyo-network/payload-model").Payload[], queryConfig?: TConf_1) => import("@xylabs/promise").Promisable<boolean>;
|
|
54
|
-
start?: () => import("@xylabs/promise").Promisable<boolean>;
|
|
55
|
-
stop?: () => import("@xylabs/promise").Promisable<boolean>;
|
|
56
|
-
eventData: import("@xyo-network/module-model").ModuleEventData<object>;
|
|
57
|
-
clearListeners(eventNames: keyof import("@xyo-network/module-model").ModuleEventData<object> | (keyof import("@xyo-network/module-model").ModuleEventData<object>)[]): void;
|
|
58
|
-
emit<TEventName extends keyof import("@xyo-network/module-model").ModuleEventData<object>>(eventName: TEventName, eventArgs: import("@xyo-network/module-model").ModuleEventData<object>[TEventName]): Promise<void>;
|
|
59
|
-
emitSerial<TEventName extends keyof import("@xyo-network/module-model").ModuleEventData<object>>(eventName: TEventName, eventArgs: import("@xyo-network/module-model").ModuleEventData<object>[TEventName]): Promise<void>;
|
|
60
|
-
listenerCount(eventNames: keyof import("@xyo-network/module-model").ModuleEventData<object> | (keyof import("@xyo-network/module-model").ModuleEventData<object>)[]): number;
|
|
61
|
-
off<TEventName extends keyof import("@xyo-network/module-model").ModuleEventData<object>>(eventNames: TEventName | TEventName[], listener: import("@xylabs/events").EventListener<import("@xyo-network/module-model").ModuleEventData<object>[TEventName]>): void;
|
|
62
|
-
offAny(listener: import("@xylabs/events").EventAnyListener | Promise<void>): void;
|
|
63
|
-
on<TEventName extends keyof import("@xyo-network/module-model").ModuleEventData<object>>(eventNames: TEventName | TEventName[], listener: import("@xylabs/events").EventListener<import("@xyo-network/module-model").ModuleEventData<object>[TEventName]>): import("@xylabs/events").EventUnsubscribeFunction;
|
|
64
|
-
onAny(listener: import("@xylabs/events").EventAnyListener): import("@xylabs/events").EventUnsubscribeFunction;
|
|
65
|
-
once<TEventName extends keyof import("@xyo-network/module-model").ModuleEventData<object>>(eventName: TEventName, listener: import("@xylabs/events").EventListener<import("@xyo-network/module-model").ModuleEventData<object>[TEventName]>): import("@xylabs/events").EventUnsubscribeFunction;
|
|
66
|
-
priority: import("@xyo-network/module-model").ObjectResolverPriority;
|
|
67
|
-
resolve<T extends ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>>(): import("@xylabs/promise").Promisable<T | undefined>;
|
|
68
|
-
resolve<T extends ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>>(all: "*", options?: import("@xyo-network/module-model").ObjectFilterOptions<T> | undefined): import("@xylabs/promise").Promisable<T[]>;
|
|
69
|
-
resolve<T extends ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>>(id: import("@xyo-network/module-model").ModuleIdentifier, options?: import("@xyo-network/module-model").ObjectFilterOptions<T> | undefined): import("@xylabs/promise").Promisable<T | undefined>;
|
|
70
|
-
resolve<T extends ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>>(id?: import("@xyo-network/module-model").ModuleIdentifier, options?: import("@xyo-network/module-model").ObjectFilterOptions<T> | undefined): import("@xylabs/promise").Promisable<T | T[] | undefined>;
|
|
71
|
-
resolvePrivate<T extends ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>>(all: "*", options?: import("@xyo-network/module-model").ObjectFilterOptions<T> | undefined): Promise<T[]>;
|
|
72
|
-
resolvePrivate<T extends ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>>(id: import("@xyo-network/module-model").ModuleIdentifier, options?: import("@xyo-network/module-model").ObjectFilterOptions<T> | undefined): Promise<T | undefined>;
|
|
73
|
-
resolvePrivate<T extends ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<ModuleParams<AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>>, import("@xyo-network/module-model").ModuleEventData<object>>>(id: import("@xyo-network/module-model").ModuleIdentifier, options?: import("@xyo-network/module-model").ObjectFilterOptions<T> | undefined): Promise<T | T[] | undefined>;
|
|
74
|
-
manifest: (maxDepth?: number, ignoreAddresses?: import("@xylabs/hex").Address[]) => import("@xylabs/promise").Promisable<import("@xyo-network/manifest-model").ModuleManifestPayload>;
|
|
75
|
-
manifestQuery: (account: import("@xyo-network/account-model").AccountInstance, maxDepth?: number, ignoreAddresses?: import("@xylabs/hex").Address[]) => import("@xylabs/promise").Promisable<import("@xyo-network/module-model").ModuleQueryResult<import("@xyo-network/manifest-model").ModuleManifestPayload>>;
|
|
76
|
-
moduleAddress: () => import("@xylabs/promise").Promisable<(import("@xyo-network/module-model").AddressPreviousHashPayload | import("@xyo-network/module-model").AddressPayload)[]>;
|
|
77
|
-
state: () => import("@xylabs/promise").Promisable<import("@xyo-network/payload-model").Payload[]>;
|
|
78
|
-
stateQuery: (account: import("@xyo-network/account-model").AccountInstance) => import("@xylabs/promise").Promisable<import("@xyo-network/module-model").ModuleQueryResult>;
|
|
79
|
-
account?: import("@xyo-network/account-model").AccountInstance;
|
|
80
|
-
addParent: (mod: ModuleInstance) => void;
|
|
81
|
-
addressCache?: (direction: import("@xyo-network/module-model").Direction, includePrivate: boolean) => import("@xyo-network/module-model").AddressToWeakInstanceCache | undefined;
|
|
82
|
-
parents: () => import("@xylabs/promise").Promisable<ModuleInstance[]>;
|
|
83
|
-
privateChildren: () => import("@xylabs/promise").Promisable<ModuleInstance[]>;
|
|
84
|
-
publicChildren: () => import("@xylabs/promise").Promisable<ModuleInstance[]>;
|
|
85
|
-
removeParent: (address: import("@xylabs/hex").Address) => void;
|
|
86
|
-
siblings: () => import("@xylabs/promise").Promisable<ModuleInstance[]>;
|
|
87
|
-
}) & TModule;
|
|
88
|
-
//# sourceMappingURL=DivinerMixin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DivinerMixin.d.ts","sourceRoot":"","sources":["../../src/DivinerMixin.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,YAAY,EACZ,WAAW,EACX,eAAe,EAChB,MAAM,2BAA2B,CAAA;AASlC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD,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,GAC9B,OAAO,SAAS,oBAAoB,GAAG,oBAAoB,EAC3D,OAAO,SAAS,SAAS,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,EACvD,MAAM,SAAS,eAAe,GAAG,eAAe,EAEhD,YAAY,OAAO,6BAd8E,GAAG,EAAE;iBAiBvF,WAAW,CAAC,MAAM,CAAC;IAEhC;;;;;;OAMG;2BAC0B,WAAW,CAAC,MAAM,CAAC;IAUhD;;;;OAIG;;IASH;;;;OAIG;;IAYH;;;;OAIG;;IASH;;;OAGG;qBACoB,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;;;;;;;;;;sRAzFnE,CAAA,6DAAwB,CAAC;4RAI+C,CAAC,6DAEjE,CAAC;;;;;;;;;;;;;;;;;;;;;uBApBR,CAAC,yBAAyB,CAAC;2FAKzB,CAAC,yBACU,CAAC;;;;;;;;;;;;YA2Id,CAAA"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|