@xyo-network/diviner-indexing-memory 7.2.2 → 7.3.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.
@@ -1,2 +1,2 @@
1
- export * from './Diviner.ts';
1
+ export * from '@xyo-network/diviner-indexing/memory';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,sCAAsC,CAAA"}
@@ -1,216 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __reflectGet = Reflect.get;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __decorateClass = (decorators, target, key, kind) => {
7
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
8
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
9
- if (decorator = decorators[i])
10
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
11
- if (kind && result) __defProp(target, key, result);
12
- return result;
13
- };
14
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
15
- var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
16
-
17
- // src/Diviner.ts
18
- import {
19
- assertEx,
20
- clearTimeoutEx,
21
- isString,
22
- setTimeoutEx
23
- } from "@ariestools/sdk";
24
- import { IndexingDivinerConfigSchema } from "@xyo-network/diviner-indexing-model";
25
- import { ArchivistWrapper } from "@xyo-network/sdk/archivist-wrapper";
26
- import { AbstractDiviner } from "@xyo-network/sdk/diviner-abstract";
27
- import { BoundWitnessDivinerQuerySchema } from "@xyo-network/sdk/diviner-boundwitness/model";
28
- import { asDivinerInstance } from "@xyo-network/sdk/diviner-model";
29
- import { DivinerWrapper } from "@xyo-network/sdk/diviner-wrapper";
30
- import {
31
- creatableModule,
32
- isModuleState,
33
- ModuleStateSchema
34
- } from "@xyo-network/sdk/module-model";
35
- import {
36
- BoundWitnessBuilder,
37
- isBoundWitness,
38
- PayloadBuilder,
39
- SequenceConstants
40
- } from "@xyo-network/sdk-protocol";
41
- var moduleName = "IndexingDiviner";
42
- var IndexingDiviner = class extends AbstractDiviner {
43
- _lastState;
44
- _pollId;
45
- get payloadDivinerLimit() {
46
- return this.config.payloadDivinerLimit ?? 1e3;
47
- }
48
- get pollFrequency() {
49
- return this.config.pollFrequency ?? 1e4;
50
- }
51
- /**
52
- * Works via batched iteration of the source archivist to populate the index.
53
- * @returns A promise that resolves when the background process is complete
54
- */
55
- backgroundDivine = async () => {
56
- const lastState = await this.retrieveState();
57
- const indexCandidateDiviner = await this.getIndexingDivinerStage("stateToIndexCandidateDiviner");
58
- const results = lastState ? await indexCandidateDiviner.divine([lastState]) : await indexCandidateDiviner.divine();
59
- const nextState = results.find(isModuleState);
60
- const indexCandidates = results.filter((x) => !isModuleState(x));
61
- const toIndexTransformDiviner = await this.getIndexingDivinerStage("indexCandidateToIndexDiviner");
62
- const indexes = await toIndexTransformDiviner.divine(indexCandidates);
63
- const indexArchivist = await this.getArchivistForStore("indexStore");
64
- await indexArchivist.insert(indexes);
65
- if (nextState) {
66
- await this.commitState(nextState);
67
- }
68
- };
69
- /**
70
- * Commit the internal state of the Diviner process. This is similar
71
- * to a transaction completion in a database and should only be called
72
- * when results have been successfully persisted to the appropriate
73
- * external stores.
74
- * @param nextState The state to commit
75
- */
76
- async commitState(nextState) {
77
- if (nextState.state.cursor === this._lastState?.state.cursor) return;
78
- this._lastState = nextState;
79
- const archivist = await this.getArchivistForStore("stateStore");
80
- const [bw] = await new BoundWitnessBuilder().payload(nextState).signer(this.account).build();
81
- await archivist.insert([bw, nextState]);
82
- }
83
- async divineHandler(payloads = []) {
84
- const indexPayloadDiviner = await this.getPayloadDivinerForStore("indexStore");
85
- const divinerQueryToIndexQueryDiviner = await this.getIndexingDivinerStage("divinerQueryToIndexQueryDiviner");
86
- const indexQueryResponseToDivinerQueryResponseDiviner = await this.getIndexingDivinerStage("indexQueryResponseToDivinerQueryResponseDiviner");
87
- const results = (await Promise.all(
88
- payloads.map(async (payload) => {
89
- const indexQuery = await divinerQueryToIndexQueryDiviner.divine([payload]);
90
- const indexedResults = await indexPayloadDiviner.divine(indexQuery);
91
- const response = await Promise.all(
92
- indexedResults.flat().map((indexedResult) => indexQueryResponseToDivinerQueryResponseDiviner.divine([payload, indexedResult]))
93
- );
94
- return response.flat();
95
- })
96
- )).flat();
97
- return results;
98
- }
99
- /**
100
- * Retrieves the archivist for the specified store
101
- * @param store The store to retrieve the archivist for
102
- * @returns The archivist for the specified store
103
- */
104
- async getArchivistForStore(store) {
105
- const name = assertEx(this.config?.[store]?.archivist, () => `${moduleName}: Config for ${store}.archivist not specified`);
106
- const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve ${store}.archivist [${name}]`);
107
- return ArchivistWrapper.wrap(mod, this.account);
108
- }
109
- /**
110
- * Retrieves the BoundWitness Diviner for the specified store
111
- * @param store The store to retrieve the BoundWitness Diviner for
112
- * @returns The BoundWitness Diviner for the specified store
113
- */
114
- async getBoundWitnessDivinerForStore(store) {
115
- const name = assertEx(this.config?.[store]?.boundWitnessDiviner, () => `${moduleName}: Config for ${store}.boundWitnessDiviner not specified`);
116
- const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve ${store}.boundWitnessDiviner [${name}]`);
117
- return DivinerWrapper.wrap(mod, this.account);
118
- }
119
- /**
120
- * Gets the Diviner for the supplied Indexing Diviner stage
121
- * @param transform The Indexing Diviner stage
122
- * @returns The diviner corresponding to the Indexing Diviner stage
123
- */
124
- async getIndexingDivinerStage(transform) {
125
- const nameOrAddress = assertEx(
126
- this.config?.indexingDivinerStages?.[transform],
127
- () => `${moduleName}: Config for indexingDivinerStages.${transform} not specified`
128
- );
129
- const mod = await this.resolve(nameOrAddress);
130
- return assertEx(asDivinerInstance(mod), () => `${moduleName}: Failed to resolve indexing diviner stage for ${transform}`);
131
- }
132
- /**
133
- * Retrieves the Payload Diviner for the specified store
134
- * @param store The store to retrieve the Payload Diviner for
135
- * @returns The Payload Diviner for the specified store
136
- */
137
- async getPayloadDivinerForStore(store) {
138
- const name = assertEx(this.config?.[store]?.payloadDiviner, () => `${moduleName}: Config for ${store}.payloadDiviner not specified`);
139
- const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve ${store}.payloadDiviner [${name}]`);
140
- return DivinerWrapper.wrap(mod, this.account);
141
- }
142
- /**
143
- * Retrieves the last state of the Diviner process. Used to recover state after
144
- * preemptions, reboots, etc.
145
- */
146
- async retrieveState() {
147
- const accountAddress = this.account.address;
148
- if (this._lastState) return this._lastState;
149
- let hash = "";
150
- const diviner = await this.getBoundWitnessDivinerForStore("stateStore");
151
- const query = new PayloadBuilder({ schema: BoundWitnessDivinerQuerySchema }).fields({
152
- address: accountAddress,
153
- limit: 1,
154
- cursor: SequenceConstants.minLocalSequence,
155
- order: "desc",
156
- payload_schemas: [ModuleStateSchema]
157
- }).build();
158
- const boundWitnesses = await diviner.divine([query]);
159
- if (boundWitnesses.length > 0) {
160
- const boundWitness = boundWitnesses[0];
161
- if (isBoundWitness(boundWitness)) {
162
- hash = boundWitness.addresses.map((address, index) => ({ address, index })).filter(({ address }) => address === accountAddress).reduce(
163
- (prev, curr) => boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev,
164
- ""
165
- );
166
- }
167
- }
168
- if (hash !== "") {
169
- const archivist = await this.getArchivistForStore("stateStore");
170
- const payload = (await archivist.get([hash])).find(isModuleState);
171
- if (payload) {
172
- return payload;
173
- }
174
- }
175
- return void 0;
176
- }
177
- async startHandler() {
178
- await super.startHandler();
179
- this.poll();
180
- }
181
- async stopHandler(_timeout) {
182
- if (isString(this._pollId)) {
183
- clearTimeout(this._pollId);
184
- this._pollId = void 0;
185
- }
186
- await super.stopHandler();
187
- }
188
- /**
189
- * Runs the background divine process on a loop with a delay
190
- * specified by the `config.pollFrequency`
191
- */
192
- poll() {
193
- this._pollId = setTimeoutEx(async () => {
194
- try {
195
- await Promise.resolve();
196
- await this.backgroundDivine();
197
- } catch (e) {
198
- console.log(e);
199
- } finally {
200
- if (this._pollId) clearTimeoutEx(this._pollId);
201
- this._pollId = void 0;
202
- this.poll();
203
- }
204
- }, this.pollFrequency);
205
- }
206
- };
207
- __publicField(IndexingDiviner, "allowRandomAccount", true);
208
- __publicField(IndexingDiviner, "configSchemas", [...__superGet(IndexingDiviner, IndexingDiviner, "configSchemas"), IndexingDivinerConfigSchema]);
209
- __publicField(IndexingDiviner, "defaultConfigSchema", IndexingDivinerConfigSchema);
210
- IndexingDiviner = __decorateClass([
211
- creatableModule()
212
- ], IndexingDiviner);
213
- export {
214
- IndexingDiviner
215
- };
1
+ // src/index.ts
2
+ export * from "@xyo-network/diviner-indexing/memory";
216
3
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/Diviner.ts"],
4
- "sourcesContent": ["import type { Hash } from '@ariestools/sdk'\nimport {\n assertEx, clearTimeoutEx, isString, setTimeoutEx,\n} from '@ariestools/sdk'\nimport type {\n IndexingDivinerConfig,\n IndexingDivinerParams,\n IndexingDivinerStage,\n IndexingDivinerState,\n} from '@xyo-network/diviner-indexing-model'\nimport { IndexingDivinerConfigSchema } from '@xyo-network/diviner-indexing-model'\nimport { ArchivistWrapper } from '@xyo-network/sdk/archivist-wrapper'\nimport { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract'\nimport type { BoundWitnessDivinerQueryPayload } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport { BoundWitnessDivinerQuerySchema } from '@xyo-network/sdk/diviner-boundwitness/model'\nimport type {\n DivinerConfig, DivinerInstance, DivinerModule, DivinerModuleEventData, DivinerParams,\n} from '@xyo-network/sdk/diviner-model'\nimport { asDivinerInstance } from '@xyo-network/sdk/diviner-model'\nimport { DivinerWrapper } from '@xyo-network/sdk/diviner-wrapper'\nimport type { AnyConfigSchema, ModuleState } from '@xyo-network/sdk/module-model'\nimport {\n creatableModule, isModuleState, ModuleStateSchema,\n} from '@xyo-network/sdk/module-model'\nimport type {\n Payload, Schema, WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport {\n BoundWitnessBuilder, isBoundWitness, PayloadBuilder, SequenceConstants,\n} from '@xyo-network/sdk-protocol'\n\nexport type ConfigStoreKey = 'indexStore' | 'stateStore'\n\nexport type ConfigStore = Extract<keyof IndexingDivinerConfig, ConfigStoreKey>\n\nconst moduleName = 'IndexingDiviner'\n\n@creatableModule<IndexingDiviner>()\nexport class IndexingDiviner<\n TParams extends IndexingDivinerParams = IndexingDivinerParams,\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> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly allowRandomAccount = true\n static override readonly configSchemas: Schema[] = [...super.configSchemas, IndexingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = IndexingDivinerConfigSchema\n\n private _lastState?: ModuleState<IndexingDivinerState>\n private _pollId?: string\n\n get payloadDivinerLimit(): number {\n return this.config.payloadDivinerLimit ?? 1000\n }\n\n get pollFrequency(): number {\n return this.config.pollFrequency ?? 10_000\n }\n\n /**\n * Works via batched iteration of the source archivist to populate the index.\n * @returns A promise that resolves when the background process is complete\n */\n protected backgroundDivine = async (): Promise<void> => {\n // Load last state\n const lastState = await this.retrieveState()\n // Get next batch of results\n const indexCandidateDiviner = await this.getIndexingDivinerStage('stateToIndexCandidateDiviner')\n const results = lastState ? await indexCandidateDiviner.divine([lastState]) : await indexCandidateDiviner.divine()\n // Filter next state out from results\n const nextState = results.find(isModuleState<IndexingDivinerState>)\n const indexCandidates = results.filter(x => !isModuleState(x))\n // Transform candidates to indexes\n const toIndexTransformDiviner = await this.getIndexingDivinerStage('indexCandidateToIndexDiviner')\n const indexes = await toIndexTransformDiviner.divine(indexCandidates)\n // Insert index results\n const indexArchivist = await this.getArchivistForStore('indexStore')\n await indexArchivist.insert(indexes)\n // Update state\n if (nextState) {\n await this.commitState(nextState)\n }\n }\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<IndexingDivinerState>): Promise<void> {\n // Don't commit state if no state has changed\n if (nextState.state.cursor === this._lastState?.state.cursor) return\n this._lastState = nextState\n const archivist = await this.getArchivistForStore('stateStore')\n const [bw] = await new BoundWitnessBuilder().payload(nextState).signer(this.account).build()\n await archivist.insert([bw, nextState])\n }\n\n protected override async divineHandler(payloads: TIn[] = []): Promise<TOut[]> {\n const indexPayloadDiviner = await this.getPayloadDivinerForStore('indexStore')\n const divinerQueryToIndexQueryDiviner = await this.getIndexingDivinerStage('divinerQueryToIndexQueryDiviner')\n const indexQueryResponseToDivinerQueryResponseDiviner = await this.getIndexingDivinerStage('indexQueryResponseToDivinerQueryResponseDiviner')\n const results = (\n await Promise.all(\n payloads.map(async (payload) => {\n const indexQuery = await divinerQueryToIndexQueryDiviner.divine([payload])\n // Divine the results\n const indexedResults = await indexPayloadDiviner.divine(indexQuery)\n // Transform the results to the response shape\n const response = await Promise.all(\n indexedResults.flat().map(indexedResult => indexQueryResponseToDivinerQueryResponseDiviner.divine([payload, indexedResult])),\n )\n return response.flat()\n }),\n )\n ).flat()\n // TODO: Infer this type over casting to this type\n return results as TOut[]\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 getArchivistForStore(store: ConfigStore): Promise<ArchivistWrapper> {\n const name = assertEx(this.config?.[store]?.archivist, () => `${moduleName}: Config for ${store}.archivist not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve ${store}.archivist [${name}]`)\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 getBoundWitnessDivinerForStore(store: ConfigStore): Promise<DivinerWrapper<DivinerModule<DivinerParams<AnyConfigSchema<DivinerConfig>>, DivinerModuleEventData>, Payload, Payload>> {\n const name = assertEx(this.config?.[store]?.boundWitnessDiviner, () => `${moduleName}: Config for ${store}.boundWitnessDiviner not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve ${store}.boundWitnessDiviner [${name}]`)\n return DivinerWrapper.wrap(mod, this.account)\n }\n\n /**\n * Gets the Diviner for the supplied Indexing Diviner stage\n * @param transform The Indexing Diviner stage\n * @returns The diviner corresponding to the Indexing Diviner stage\n */\n protected async getIndexingDivinerStage(transform: IndexingDivinerStage): Promise<DivinerInstance> {\n const nameOrAddress = assertEx(\n this.config?.indexingDivinerStages?.[transform],\n () => `${moduleName}: Config for indexingDivinerStages.${transform} not specified`,\n )\n const mod = await this.resolve(nameOrAddress)\n return assertEx(asDivinerInstance(mod), () => `${moduleName}: Failed to resolve indexing diviner stage for ${transform}`)\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 getPayloadDivinerForStore(store: ConfigStore): Promise<DivinerWrapper<DivinerModule<DivinerParams<AnyConfigSchema<DivinerConfig>>, DivinerModuleEventData>, Payload, Payload>> {\n const name = assertEx(this.config?.[store]?.payloadDiviner, () => `${moduleName}: Config for ${store}.payloadDiviner not specified`)\n const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve ${store}.payloadDiviner [${name}]`)\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<IndexingDivinerState> | undefined> {\n const accountAddress = this.account.address\n if (this._lastState) return this._lastState\n let hash = '' as Hash\n const diviner = await this.getBoundWitnessDivinerForStore('stateStore')\n const query = new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({\n address: accountAddress,\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 === accountAddress)\n\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('stateStore')\n const payload = (await archivist.get([hash])).find(isModuleState<IndexingDivinerState>)\n if (payload) {\n return payload as WithStorageMeta<ModuleState<IndexingDivinerState>>\n }\n }\n return undefined\n }\n\n protected override async startHandler(): Promise<void> {\n await super.startHandler()\n this.poll()\n }\n\n protected override async stopHandler(_timeout?: number): Promise<void> {\n if (isString(this._pollId)) {\n clearTimeout(this._pollId)\n this._pollId = undefined\n }\n await super.stopHandler()\n }\n\n /**\n * Runs the background divine process on a loop with a delay\n * specified by the `config.pollFrequency`\n */\n private poll() {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this._pollId = setTimeoutEx(async () => {\n try {\n await Promise.resolve()\n await this.backgroundDivine()\n } catch (e) {\n console.log(e)\n } finally {\n if (this._pollId) clearTimeoutEx(this._pollId)\n this._pollId = undefined\n this.poll()\n }\n }, this.pollFrequency)\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EAAU;AAAA,EAAgB;AAAA,EAAU;AAAA,OAC/B;AAOP,SAAS,mCAAmC;AAC5C,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAEhC,SAAS,sCAAsC;AAI/C,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAE/B;AAAA,EACE;AAAA,EAAiB;AAAA,EAAe;AAAA,OAC3B;AAIP;AAAA,EACE;AAAA,EAAqB;AAAA,EAAgB;AAAA,EAAgB;AAAA,OAChD;AAMP,IAAM,aAAa;AAGZ,IAAM,kBAAN,cASG,gBAAgD;AAAA,EAKhD;AAAA,EACA;AAAA,EAER,IAAI,sBAA8B;AAChC,WAAO,KAAK,OAAO,uBAAuB;AAAA,EAC5C;AAAA,EAEA,IAAI,gBAAwB;AAC1B,WAAO,KAAK,OAAO,iBAAiB;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,mBAAmB,YAA2B;AAEtD,UAAM,YAAY,MAAM,KAAK,cAAc;AAE3C,UAAM,wBAAwB,MAAM,KAAK,wBAAwB,8BAA8B;AAC/F,UAAM,UAAU,YAAY,MAAM,sBAAsB,OAAO,CAAC,SAAS,CAAC,IAAI,MAAM,sBAAsB,OAAO;AAEjH,UAAM,YAAY,QAAQ,KAAK,aAAmC;AAClE,UAAM,kBAAkB,QAAQ,OAAO,OAAK,CAAC,cAAc,CAAC,CAAC;AAE7D,UAAM,0BAA0B,MAAM,KAAK,wBAAwB,8BAA8B;AACjG,UAAM,UAAU,MAAM,wBAAwB,OAAO,eAAe;AAEpE,UAAM,iBAAiB,MAAM,KAAK,qBAAqB,YAAY;AACnE,UAAM,eAAe,OAAO,OAAO;AAEnC,QAAI,WAAW;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AAM,KAAK,iBAAiB;AAAA,MAC9B,SAAS,GAAG;AACV,gBAAQ,IAAI,CAAC;AAAA,MACf,UAAE;AACA,YAAI,KAAK,QAAS,gBAAe,KAAK,OAAO;AAC7C,aAAK,UAAU;AACf,aAAK,KAAK;AAAA,MACZ;AAAA,IACF,GAAG,KAAK,aAAa;AAAA,EACvB;AACF;AA3ME,cAVW,iBAUc,sBAAqB;AAC9C,cAXW,iBAWc,iBAA0B,CAAC,GAAG,6CAAM,kBAAe,2BAA2B;AACvG,cAZW,iBAYc,uBAA8B;AAZ5C,kBAAN;AAAA,EADN,gBAAiC;AAAA,GACrB;",
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["// Compatibility shim: this package re-exports from @xyo-network/diviner-indexing/memory.\nexport * from '@xyo-network/diviner-indexing/memory'\n"],
5
+ "mappings": ";AACA,cAAc;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/diviner-indexing-memory",
3
- "version": "7.2.2",
3
+ "version": "7.3.0",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -34,29 +34,24 @@
34
34
  "README.md"
35
35
  ],
36
36
  "dependencies": {
37
- "@xyo-network/diviner-indexing-model": "~7.2.2",
38
- "@xyo-network/sdk": "~7.2.2"
37
+ "@xyo-network/diviner-indexing": "~7.3.0"
39
38
  },
40
39
  "devDependencies": {
41
- "@ariestools/sdk": "~8.1.6",
42
- "@ariestools/toolchain": "~8.7.26",
43
- "@ariestools/tsconfig": "~8.7.26",
40
+ "@ariestools/sdk": "~8.1.9",
41
+ "@ariestools/toolchain": "~9.1.1",
42
+ "@ariestools/tsconfig": "~9.1.1",
44
43
  "@opentelemetry/api": "~1.9.1",
45
- "@xyo-network/sdk-protocol": "~7.2.2",
46
- "eslint": "~10.8.0",
44
+ "@xyo-network/sdk-protocol": "~7.3.1",
45
+ "eslint": "~10.9.0",
47
46
  "eslint-import-resolver-typescript": "~4.4.5",
48
- "tslib": "~2.8.1",
49
47
  "typescript": "~6.0.3",
50
48
  "zod": "~4.4.3"
51
49
  },
52
- "peerDependencies": {
53
- "@ariestools/sdk": "^8.1",
54
- "@xyo-network/sdk-protocol": "^7.2"
55
- },
56
50
  "engines": {
57
51
  "node": "^24"
58
52
  },
59
53
  "publishConfig": {
60
54
  "access": "public"
61
- }
55
+ },
56
+ "deprecated": "Use @xyo-network/diviner-indexing/memory instead. This package is a compatibility shim only and will not receive further updates."
62
57
  }
@@ -1,69 +0,0 @@
1
- import type { IndexingDivinerConfig, IndexingDivinerParams, IndexingDivinerStage, IndexingDivinerState } from '@xyo-network/diviner-indexing-model';
2
- import { ArchivistWrapper } from '@xyo-network/sdk/archivist-wrapper';
3
- import { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract';
4
- import type { DivinerConfig, DivinerInstance, DivinerModule, DivinerModuleEventData, DivinerParams } from '@xyo-network/sdk/diviner-model';
5
- import { DivinerWrapper } from '@xyo-network/sdk/diviner-wrapper';
6
- import type { AnyConfigSchema, ModuleState } from '@xyo-network/sdk/module-model';
7
- import type { Payload, Schema } from '@xyo-network/sdk-protocol';
8
- export type ConfigStoreKey = 'indexStore' | 'stateStore';
9
- export type ConfigStore = Extract<keyof IndexingDivinerConfig, ConfigStoreKey>;
10
- export declare class IndexingDiviner<TParams extends IndexingDivinerParams = IndexingDivinerParams, TIn extends Payload = Payload, TOut extends Payload = Payload, TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut>> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {
11
- static readonly allowRandomAccount = true;
12
- static readonly configSchemas: Schema[];
13
- static readonly defaultConfigSchema: Schema;
14
- private _lastState?;
15
- private _pollId?;
16
- get payloadDivinerLimit(): number;
17
- get pollFrequency(): number;
18
- /**
19
- * Works via batched iteration of the source archivist to populate the index.
20
- * @returns A promise that resolves when the background process is complete
21
- */
22
- protected backgroundDivine: () => Promise<void>;
23
- /**
24
- * Commit the internal state of the Diviner process. This is similar
25
- * to a transaction completion in a database and should only be called
26
- * when results have been successfully persisted to the appropriate
27
- * external stores.
28
- * @param nextState The state to commit
29
- */
30
- protected commitState(nextState: ModuleState<IndexingDivinerState>): Promise<void>;
31
- protected divineHandler(payloads?: TIn[]): Promise<TOut[]>;
32
- /**
33
- * Retrieves the archivist for the specified store
34
- * @param store The store to retrieve the archivist for
35
- * @returns The archivist for the specified store
36
- */
37
- protected getArchivistForStore(store: ConfigStore): Promise<ArchivistWrapper>;
38
- /**
39
- * Retrieves the BoundWitness Diviner for the specified store
40
- * @param store The store to retrieve the BoundWitness Diviner for
41
- * @returns The BoundWitness Diviner for the specified store
42
- */
43
- protected getBoundWitnessDivinerForStore(store: ConfigStore): Promise<DivinerWrapper<DivinerModule<DivinerParams<AnyConfigSchema<DivinerConfig>>, DivinerModuleEventData>, Payload, Payload>>;
44
- /**
45
- * Gets the Diviner for the supplied Indexing Diviner stage
46
- * @param transform The Indexing Diviner stage
47
- * @returns The diviner corresponding to the Indexing Diviner stage
48
- */
49
- protected getIndexingDivinerStage(transform: IndexingDivinerStage): Promise<DivinerInstance>;
50
- /**
51
- * Retrieves the Payload Diviner for the specified store
52
- * @param store The store to retrieve the Payload Diviner for
53
- * @returns The Payload Diviner for the specified store
54
- */
55
- protected getPayloadDivinerForStore(store: ConfigStore): Promise<DivinerWrapper<DivinerModule<DivinerParams<AnyConfigSchema<DivinerConfig>>, DivinerModuleEventData>, Payload, Payload>>;
56
- /**
57
- * Retrieves the last state of the Diviner process. Used to recover state after
58
- * preemptions, reboots, etc.
59
- */
60
- protected retrieveState(): Promise<ModuleState<IndexingDivinerState> | undefined>;
61
- protected startHandler(): Promise<void>;
62
- protected stopHandler(_timeout?: number): Promise<void>;
63
- /**
64
- * Runs the background divine process on a loop with a delay
65
- * specified by the `config.pollFrequency`
66
- */
67
- private poll;
68
- }
69
- //# sourceMappingURL=Diviner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../src/Diviner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AAGnE,OAAO,KAAK,EACV,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,sBAAsB,EAAE,aAAa,EACrF,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAIjF,OAAO,KAAK,EACV,OAAO,EAAE,MAAM,EAChB,MAAM,2BAA2B,CAAA;AAKlC,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,YAAY,CAAA;AAExD,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,qBAAqB,EAAE,cAAc,CAAC,CAAA;AAI9E,qBACa,eAAe,CAC1B,OAAO,SAAS,qBAAqB,GAAG,qBAAqB,EAC7D,GAAG,SAAS,OAAO,GAAG,OAAO,EAC7B,IAAI,SAAS,OAAO,GAAG,OAAO,EAC9B,UAAU,SAAS,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,sBAAsB,CAChH,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EACnC,GAAG,EACH,IAAI,CACL,CACD,SAAQ,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC;IACvD,gBAAyB,kBAAkB,QAAO;IAClD,g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