@xyo-network/diviner-stateful 3.18.10 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,7 +44,7 @@ var StatefulDiviner = class extends AbstractDiviner {
44
44
  * @returns The archivist for the specified store
45
45
  */
46
46
  async getArchivistForStateStore() {
47
- const name = assertEx(this.config?.stateStore.archivist, () => `${moduleName}: Config for stateStore.archivist not specified`);
47
+ const name = assertEx(this.config?.stateStore?.archivist, () => `${moduleName}: Config for stateStore.archivist not specified`);
48
48
  const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.archivist`);
49
49
  return ArchivistWrapper.wrap(mod, this.account);
50
50
  }
@@ -54,7 +54,7 @@ var StatefulDiviner = class extends AbstractDiviner {
54
54
  * @returns The BoundWitness Diviner for the specified store
55
55
  */
56
56
  async getBoundWitnessDivinerForStateStore() {
57
- const name = assertEx(this.config?.stateStore.boundWitnessDiviner, () => `${moduleName}: Config for stateStore.boundWitnessDiviner not specified`);
57
+ const name = assertEx(this.config?.stateStore?.boundWitnessDiviner, () => `${moduleName}: Config for stateStore.boundWitnessDiviner not specified`);
58
58
  const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.boundWitnessDiviner`);
59
59
  return DivinerWrapper.wrap(mod, this.account);
60
60
  }
@@ -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,OAAO,KAAK,OAAO,EAAE,MAAM;AAC3F,UAAM,UAAU,OAAO,CAAC,IAAI,SAAS,CAAC;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAgB,4BA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A+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 * @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,OAAO,KAAK,OAAO,EAAE,MAAM;AAC3F,UAAM,UAAU,OAAO,CAAC,IAAI,SAAS,CAAC;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA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BAAgD,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"]}
@@ -28,46 +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("@xylabs/base").BaseParamsFields & {
32
- account?: import("@xyo-network/account-model").AccountInstance | "random";
33
- addToResolvers?: boolean;
34
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
35
- allowNameResolution?: boolean;
36
- config: import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/archivist-model").ArchivistConfig>;
37
- ephemeralQueryAccountEnabled?: boolean;
38
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
39
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
40
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/archivist-model").ArchivistModuleEventData>>>;
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>>, import("@xyo-network/archivist-model").ArchivistModuleEventData>>>;
41
32
  /**
42
33
  * Retrieves the BoundWitness Diviner for the specified store
43
34
  * @param store The store to retrieve the BoundWitness Diviner for
44
35
  * @returns The BoundWitness Diviner for the specified store
45
36
  */
46
- protected getBoundWitnessDivinerForStateStore(): Promise<DivinerWrapper<import("@xyo-network/diviner-model").DivinerModule<import("@xylabs/base").BaseParamsFields & {
47
- account?: import("@xyo-network/account-model").AccountInstance | "random";
48
- addToResolvers?: boolean;
49
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
50
- allowNameResolution?: boolean;
51
- config: import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/diviner-model").DivinerConfig>;
52
- ephemeralQueryAccountEnabled?: boolean;
53
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
54
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
55
- } & import("@xyo-network/module-model").ModuleChildrenParams, DivinerModuleEventData>, Payload, Payload>>;
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>>, DivinerModuleEventData>, Payload, Payload>>;
56
38
  /**
57
39
  * Retrieves the Payload Diviner for the specified store
58
40
  * @param store The store to retrieve the Payload Diviner for
59
41
  * @returns The Payload Diviner for the specified store
60
42
  */
61
- protected getPayloadDivinerForStateStore(): Promise<DivinerWrapper<import("@xyo-network/diviner-model").DivinerModule<import("@xylabs/base").BaseParamsFields & {
62
- account?: import("@xyo-network/account-model").AccountInstance | "random";
63
- addToResolvers?: boolean;
64
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
65
- allowNameResolution?: boolean;
66
- config: import("@xyo-network/module-model").AnyConfigSchema<import("@xyo-network/diviner-model").DivinerConfig>;
67
- ephemeralQueryAccountEnabled?: boolean;
68
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
69
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
70
- } & import("@xyo-network/module-model").ModuleChildrenParams, DivinerModuleEventData>, Payload, Payload>>;
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>>, DivinerModuleEventData>, Payload, Payload>>;
71
44
  /**
72
45
  * Retrieves the last state of the Diviner process. Used to recover state after
73
46
  * preemptions, reboots, etc.
@@ -1 +1 @@
1
- {"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../src/Diviner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAG/D,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAG7E,OAAO,KAAK,EACV,OAAO,EAAE,MAAM,EAE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retrieve the archivist for
23
23
  * @returns The archivist for the specified store
24
24
  */
25
- getArchivistForStore(): Promise<import("@xyo-network/archivist-model").ArchivistInstance<any, import("@xyo-network/archivist-model").ArchivistModuleEventData, import("@xyo-network/payload-model").Payload<void, void>>>;
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
26
  /**
27
27
  * Retrieves the BoundWitness Diviner for the specified store
28
28
  * @param store The store to retrieve the BoundWitness Diviner for
29
29
  * @returns The BoundWitness Diviner for the specified store
30
30
  */
31
- getBoundWitnessDivinerForStore(): Promise<import("@xyo-network/diviner-model").DivinerInstance<any, import("@xyo-network/payload-model").Payload<void, void>, import("@xyo-network/payload-model").Payload<void, void>, import("@xyo-network/diviner-model").DivinerModuleEventData<ModuleInstance<import("@xylabs/base").BaseParamsFields & {
32
- account?: import("@xyo-network/account-model").AccountInstance | "random";
33
- addToResolvers?: boolean;
34
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
35
- allowNameResolution?: boolean;
36
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
37
- ephemeralQueryAccountEnabled?: boolean;
38
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
39
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
40
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/module-model").ModuleEventData<object>>, import("@xyo-network/payload-model").Payload, import("@xyo-network/payload-model").Payload>>>;
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>>>;
41
32
  /**
42
33
  * Retrieves the Payload Diviner for the specified store
43
34
  * @param store The store to retrieve the Payload Diviner for
44
35
  * @returns The Payload Diviner for the specified store
45
36
  */
46
- getPayloadDivinerForStateStore(): Promise<import("@xyo-network/diviner-model").DivinerInstance<any, import("@xyo-network/payload-model").Payload<void, void>, import("@xyo-network/payload-model").Payload<void, void>, import("@xyo-network/diviner-model").DivinerModuleEventData<ModuleInstance<import("@xylabs/base").BaseParamsFields & {
47
- account?: import("@xyo-network/account-model").AccountInstance | "random";
48
- addToResolvers?: boolean;
49
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
50
- allowNameResolution?: boolean;
51
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
52
- ephemeralQueryAccountEnabled?: boolean;
53
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
54
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
55
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/module-model").ModuleEventData<object>>, import("@xyo-network/payload-model").Payload, import("@xyo-network/payload-model").Payload>>>;
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>>>;
56
38
  /**
57
39
  * Retrieves the last state of the Diviner process. Used to recover state after
58
40
  * preemptions, reboots, etc.
@@ -82,139 +64,13 @@ export declare const StatefulModuleMixin: <TParams extends StatefulModuleParams
82
64
  onAny(listener: import("@xylabs/events").EventAnyListener): import("@xylabs/events").EventUnsubscribeFunction;
83
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;
84
66
  priority: import("@xyo-network/module-model").ObjectResolverPriority;
85
- resolve<T extends ModuleInstance<import("@xylabs/base").BaseParamsFields & {
86
- account?: import("@xyo-network/account-model").AccountInstance | "random";
87
- addToResolvers?: boolean;
88
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
89
- allowNameResolution?: boolean;
90
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
91
- ephemeralQueryAccountEnabled?: boolean;
92
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
93
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
94
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xylabs/base").BaseParamsFields & {
95
- account?: import("@xyo-network/account-model").AccountInstance | "random";
96
- addToResolvers?: boolean;
97
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
98
- allowNameResolution?: boolean;
99
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
100
- ephemeralQueryAccountEnabled?: boolean;
101
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
102
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
103
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/module-model").ModuleEventData<object>>>(): import("@xylabs/promise").Promisable<T | undefined>;
104
- resolve<T extends ModuleInstance<import("@xylabs/base").BaseParamsFields & {
105
- account?: import("@xyo-network/account-model").AccountInstance | "random";
106
- addToResolvers?: boolean;
107
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
108
- allowNameResolution?: boolean;
109
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
110
- ephemeralQueryAccountEnabled?: boolean;
111
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
112
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
113
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xylabs/base").BaseParamsFields & {
114
- account?: import("@xyo-network/account-model").AccountInstance | "random";
115
- addToResolvers?: boolean;
116
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
117
- allowNameResolution?: boolean;
118
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
119
- ephemeralQueryAccountEnabled?: boolean;
120
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
121
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
122
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/module-model").ModuleEventData<object>>>(all: "*", options?: import("@xyo-network/module-model").ObjectFilterOptions<T> | undefined): import("@xylabs/promise").Promisable<T[]>;
123
- resolve<T extends ModuleInstance<import("@xylabs/base").BaseParamsFields & {
124
- account?: import("@xyo-network/account-model").AccountInstance | "random";
125
- addToResolvers?: boolean;
126
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
127
- allowNameResolution?: boolean;
128
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
129
- ephemeralQueryAccountEnabled?: boolean;
130
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
131
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
132
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xylabs/base").BaseParamsFields & {
133
- account?: import("@xyo-network/account-model").AccountInstance | "random";
134
- addToResolvers?: boolean;
135
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
136
- allowNameResolution?: boolean;
137
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
138
- ephemeralQueryAccountEnabled?: boolean;
139
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
140
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
141
- } & import("@xyo-network/module-model").ModuleChildrenParams, 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>;
142
- resolve<T extends ModuleInstance<import("@xylabs/base").BaseParamsFields & {
143
- account?: import("@xyo-network/account-model").AccountInstance | "random";
144
- addToResolvers?: boolean;
145
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
146
- allowNameResolution?: boolean;
147
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
148
- ephemeralQueryAccountEnabled?: boolean;
149
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
150
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
151
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xylabs/base").BaseParamsFields & {
152
- account?: import("@xyo-network/account-model").AccountInstance | "random";
153
- addToResolvers?: boolean;
154
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
155
- allowNameResolution?: boolean;
156
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
157
- ephemeralQueryAccountEnabled?: boolean;
158
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
159
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
160
- } & import("@xyo-network/module-model").ModuleChildrenParams, 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>;
161
- resolvePrivate<T extends ModuleInstance<import("@xylabs/base").BaseParamsFields & {
162
- account?: import("@xyo-network/account-model").AccountInstance | "random";
163
- addToResolvers?: boolean;
164
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
165
- allowNameResolution?: boolean;
166
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
167
- ephemeralQueryAccountEnabled?: boolean;
168
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
169
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
170
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xylabs/base").BaseParamsFields & {
171
- account?: import("@xyo-network/account-model").AccountInstance | "random";
172
- addToResolvers?: boolean;
173
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
174
- allowNameResolution?: boolean;
175
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
176
- ephemeralQueryAccountEnabled?: boolean;
177
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
178
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
179
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/module-model").ModuleEventData<object>>>(all: "*", options?: import("@xyo-network/module-model").ObjectFilterOptions<T> | undefined): Promise<T[]>;
180
- resolvePrivate<T extends ModuleInstance<import("@xylabs/base").BaseParamsFields & {
181
- account?: import("@xyo-network/account-model").AccountInstance | "random";
182
- addToResolvers?: boolean;
183
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
184
- allowNameResolution?: boolean;
185
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
186
- ephemeralQueryAccountEnabled?: boolean;
187
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
188
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
189
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xylabs/base").BaseParamsFields & {
190
- account?: import("@xyo-network/account-model").AccountInstance | "random";
191
- addToResolvers?: boolean;
192
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
193
- allowNameResolution?: boolean;
194
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
195
- ephemeralQueryAccountEnabled?: boolean;
196
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
197
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
198
- } & import("@xyo-network/module-model").ModuleChildrenParams, 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>;
199
- resolvePrivate<T extends ModuleInstance<import("@xylabs/base").BaseParamsFields & {
200
- account?: import("@xyo-network/account-model").AccountInstance | "random";
201
- addToResolvers?: boolean;
202
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
203
- allowNameResolution?: boolean;
204
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
205
- ephemeralQueryAccountEnabled?: boolean;
206
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
207
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
208
- } & import("@xyo-network/module-model").ModuleChildrenParams, import("@xyo-network/module-model").ModuleEventData<object>> = ModuleInstance<import("@xylabs/base").BaseParamsFields & {
209
- account?: import("@xyo-network/account-model").AccountInstance | "random";
210
- addToResolvers?: boolean;
211
- additionalSigners?: import("@xyo-network/account-model").AccountInstance[];
212
- allowNameResolution?: boolean;
213
- config: AnyConfigSchema<import("@xyo-network/module-model").ModuleConfig>;
214
- ephemeralQueryAccountEnabled?: boolean;
215
- moduleIdentifierTransformers?: import("@xyo-network/module-model").ModuleIdentifierTransformer[];
216
- statusReporter?: import("@xyo-network/module-model").ModuleStatusReporter;
217
- } & import("@xyo-network/module-model").ModuleChildrenParams, 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>;
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>;
218
74
  manifest: (maxDepth?: number, ignoreAddresses?: import("@xylabs/hex").Address[]) => import("@xylabs/promise").Promisable<import("@xyo-network/manifest-model").ModuleManifestPayload>;
219
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>>;
220
76
  moduleAddress: () => import("@xylabs/promise").Promisable<(import("@xyo-network/module-model").AddressPreviousHashPayload | import("@xyo-network/module-model").AddressPayload)[]>;
@@ -1 +1 @@
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/diviner-stateful",
3
- "version": "3.18.10",
3
+ "version": "4.0.1",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -29,35 +29,36 @@
29
29
  "module": "dist/neutral/index.mjs",
30
30
  "types": "dist/types/index.d.ts",
31
31
  "dependencies": {
32
- "@xylabs/assert": "^4.11.21",
33
- "@xylabs/object": "^4.11.21",
34
- "@xyo-network/archivist-model": "^3.18.10",
35
- "@xyo-network/archivist-wrapper": "^3.18.10",
36
- "@xyo-network/boundwitness-builder": "^3.18.10",
37
- "@xyo-network/boundwitness-model": "^3.18.10",
38
- "@xyo-network/diviner-abstract": "^3.18.10",
39
- "@xyo-network/diviner-boundwitness-model": "^3.18.10",
40
- "@xyo-network/diviner-model": "^3.18.10",
41
- "@xyo-network/diviner-wrapper": "^3.18.10",
42
- "@xyo-network/module-model": "^3.18.10",
43
- "@xyo-network/payload-builder": "^3.18.10",
44
- "@xyo-network/payload-model": "^3.18.10"
32
+ "@xylabs/assert": "^4.12.30",
33
+ "@xylabs/object": "^4.12.30",
34
+ "@xyo-network/archivist-model": "^4.0.1",
35
+ "@xyo-network/archivist-wrapper": "^4.0.1",
36
+ "@xyo-network/boundwitness-builder": "^4.0.1",
37
+ "@xyo-network/boundwitness-model": "^4.0.1",
38
+ "@xyo-network/diviner-abstract": "^4.0.1",
39
+ "@xyo-network/diviner-boundwitness-model": "^4.0.1",
40
+ "@xyo-network/diviner-model": "^4.0.1",
41
+ "@xyo-network/diviner-payload-generic": "^4.0.1",
42
+ "@xyo-network/diviner-wrapper": "^4.0.1",
43
+ "@xyo-network/module-model": "^4.0.1",
44
+ "@xyo-network/payload-builder": "^4.0.1",
45
+ "@xyo-network/payload-model": "^4.0.1"
45
46
  },
46
47
  "devDependencies": {
47
- "@xylabs/hex": "^4.11.21",
48
- "@xylabs/ts-scripts-yarn3": "^6.5.8",
49
- "@xylabs/tsconfig": "^6.5.8",
50
- "@xylabs/vitest-extended": "^4.11.21",
51
- "@xyo-network/account": "^3.18.10",
52
- "@xyo-network/archivist-memory": "^3.18.10",
53
- "@xyo-network/diviner-boundwitness-memory": "^3.18.10",
54
- "@xyo-network/diviner-payload-memory": "^3.18.10",
55
- "@xyo-network/manifest": "^3.18.10",
56
- "@xyo-network/module-factory-locator": "^3.18.10",
57
- "@xyo-network/node-memory": "^3.18.10",
58
- "@xyo-network/wallet": "^3.18.10",
48
+ "@xylabs/hex": "^4.12.30",
49
+ "@xylabs/ts-scripts-yarn3": "^6.5.12",
50
+ "@xylabs/tsconfig": "^6.5.12",
51
+ "@xylabs/vitest-extended": "^4.12.30",
52
+ "@xyo-network/account": "^4.0.1",
53
+ "@xyo-network/archivist-memory": "^4.0.1",
54
+ "@xyo-network/diviner-boundwitness-memory": "^4.0.1",
55
+ "@xyo-network/diviner-payload-memory": "^4.0.1",
56
+ "@xyo-network/manifest": "^4.0.1",
57
+ "@xyo-network/module-factory-locator": "^4.0.1",
58
+ "@xyo-network/node-memory": "^4.0.1",
59
+ "@xyo-network/wallet": "^4.0.1",
59
60
  "typescript": "^5.8.3",
60
- "vitest": "^3.2.3"
61
+ "vitest": "^3.2.4"
61
62
  },
62
63
  "publishConfig": {
63
64
  "access": "public"
package/src/Diviner.ts CHANGED
@@ -67,7 +67,7 @@ export abstract class StatefulDiviner<
67
67
  * @returns The archivist for the specified store
68
68
  */
69
69
  protected async getArchivistForStateStore() {
70
- const name = assertEx(this.config?.stateStore.archivist, () => `${moduleName}: Config for stateStore.archivist not specified`)
70
+ const name = assertEx(this.config?.stateStore?.archivist, () => `${moduleName}: Config for stateStore.archivist not specified`)
71
71
  const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.archivist`)
72
72
  return ArchivistWrapper.wrap(mod, this.account)
73
73
  }
@@ -78,7 +78,7 @@ export abstract class StatefulDiviner<
78
78
  * @returns The BoundWitness Diviner for the specified store
79
79
  */
80
80
  protected async getBoundWitnessDivinerForStateStore() {
81
- const name = assertEx(this.config?.stateStore.boundWitnessDiviner, () => `${moduleName}: Config for stateStore.boundWitnessDiviner not specified`)
81
+ const name = assertEx(this.config?.stateStore?.boundWitnessDiviner, () => `${moduleName}: Config for stateStore.boundWitnessDiviner not specified`)
82
82
  const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve stateStore.boundWitnessDiviner`)
83
83
  return DivinerWrapper.wrap(mod, this.account)
84
84
  }