@xyo-network/diviner-indexing 2.79.5 → 2.79.8

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.
Files changed (126) hide show
  1. package/dist/browser/index.cjs +3 -200
  2. package/dist/browser/index.cjs.map +1 -1
  3. package/dist/browser/index.d.cts +2 -7
  4. package/dist/browser/index.d.cts.map +1 -1
  5. package/dist/browser/index.d.mts +2 -7
  6. package/dist/browser/index.d.mts.map +1 -1
  7. package/dist/browser/index.d.ts +2 -7
  8. package/dist/browser/index.d.ts.map +1 -1
  9. package/dist/browser/index.js +3 -195
  10. package/dist/browser/index.js.map +1 -1
  11. package/dist/node/index.d.cts +2 -7
  12. package/dist/node/index.d.cts.map +1 -1
  13. package/dist/node/index.d.mts +2 -7
  14. package/dist/node/index.d.mts.map +1 -1
  15. package/dist/node/index.d.ts +2 -7
  16. package/dist/node/index.d.ts.map +1 -1
  17. package/dist/node/index.js +5 -212
  18. package/dist/node/index.js.map +1 -1
  19. package/dist/node/index.mjs +3 -203
  20. package/dist/node/index.mjs.map +1 -1
  21. package/package.json +3 -12
  22. package/src/index.ts +2 -7
  23. package/dist/browser/Config.d.cts +0 -32
  24. package/dist/browser/Config.d.cts.map +0 -1
  25. package/dist/browser/Config.d.mts +0 -32
  26. package/dist/browser/Config.d.mts.map +0 -1
  27. package/dist/browser/Config.d.ts +0 -32
  28. package/dist/browser/Config.d.ts.map +0 -1
  29. package/dist/browser/Diviner.d.cts +0 -71
  30. package/dist/browser/Diviner.d.cts.map +0 -1
  31. package/dist/browser/Diviner.d.mts +0 -71
  32. package/dist/browser/Diviner.d.mts.map +0 -1
  33. package/dist/browser/Diviner.d.ts +0 -71
  34. package/dist/browser/Diviner.d.ts.map +0 -1
  35. package/dist/browser/Labels.d.cts +0 -9
  36. package/dist/browser/Labels.d.cts.map +0 -1
  37. package/dist/browser/Labels.d.mts +0 -9
  38. package/dist/browser/Labels.d.mts.map +0 -1
  39. package/dist/browser/Labels.d.ts +0 -9
  40. package/dist/browser/Labels.d.ts.map +0 -1
  41. package/dist/browser/Params.d.cts +0 -5
  42. package/dist/browser/Params.d.cts.map +0 -1
  43. package/dist/browser/Params.d.mts +0 -5
  44. package/dist/browser/Params.d.mts.map +0 -1
  45. package/dist/browser/Params.d.ts +0 -5
  46. package/dist/browser/Params.d.ts.map +0 -1
  47. package/dist/browser/Schema.d.cts +0 -3
  48. package/dist/browser/Schema.d.cts.map +0 -1
  49. package/dist/browser/Schema.d.mts +0 -3
  50. package/dist/browser/Schema.d.mts.map +0 -1
  51. package/dist/browser/Schema.d.ts +0 -3
  52. package/dist/browser/Schema.d.ts.map +0 -1
  53. package/dist/browser/SearchableStorage.d.cts +0 -10
  54. package/dist/browser/SearchableStorage.d.cts.map +0 -1
  55. package/dist/browser/SearchableStorage.d.mts +0 -10
  56. package/dist/browser/SearchableStorage.d.mts.map +0 -1
  57. package/dist/browser/SearchableStorage.d.ts +0 -10
  58. package/dist/browser/SearchableStorage.d.ts.map +0 -1
  59. package/dist/browser/Stage.d.cts +0 -29
  60. package/dist/browser/Stage.d.cts.map +0 -1
  61. package/dist/browser/Stage.d.mts +0 -29
  62. package/dist/browser/Stage.d.mts.map +0 -1
  63. package/dist/browser/Stage.d.ts +0 -29
  64. package/dist/browser/Stage.d.ts.map +0 -1
  65. package/dist/browser/State.d.cts +0 -5
  66. package/dist/browser/State.d.cts.map +0 -1
  67. package/dist/browser/State.d.mts +0 -5
  68. package/dist/browser/State.d.mts.map +0 -1
  69. package/dist/browser/State.d.ts +0 -5
  70. package/dist/browser/State.d.ts.map +0 -1
  71. package/dist/node/Config.d.cts +0 -32
  72. package/dist/node/Config.d.cts.map +0 -1
  73. package/dist/node/Config.d.mts +0 -32
  74. package/dist/node/Config.d.mts.map +0 -1
  75. package/dist/node/Config.d.ts +0 -32
  76. package/dist/node/Config.d.ts.map +0 -1
  77. package/dist/node/Diviner.d.cts +0 -71
  78. package/dist/node/Diviner.d.cts.map +0 -1
  79. package/dist/node/Diviner.d.mts +0 -71
  80. package/dist/node/Diviner.d.mts.map +0 -1
  81. package/dist/node/Diviner.d.ts +0 -71
  82. package/dist/node/Diviner.d.ts.map +0 -1
  83. package/dist/node/Labels.d.cts +0 -9
  84. package/dist/node/Labels.d.cts.map +0 -1
  85. package/dist/node/Labels.d.mts +0 -9
  86. package/dist/node/Labels.d.mts.map +0 -1
  87. package/dist/node/Labels.d.ts +0 -9
  88. package/dist/node/Labels.d.ts.map +0 -1
  89. package/dist/node/Params.d.cts +0 -5
  90. package/dist/node/Params.d.cts.map +0 -1
  91. package/dist/node/Params.d.mts +0 -5
  92. package/dist/node/Params.d.mts.map +0 -1
  93. package/dist/node/Params.d.ts +0 -5
  94. package/dist/node/Params.d.ts.map +0 -1
  95. package/dist/node/Schema.d.cts +0 -3
  96. package/dist/node/Schema.d.cts.map +0 -1
  97. package/dist/node/Schema.d.mts +0 -3
  98. package/dist/node/Schema.d.mts.map +0 -1
  99. package/dist/node/Schema.d.ts +0 -3
  100. package/dist/node/Schema.d.ts.map +0 -1
  101. package/dist/node/SearchableStorage.d.cts +0 -10
  102. package/dist/node/SearchableStorage.d.cts.map +0 -1
  103. package/dist/node/SearchableStorage.d.mts +0 -10
  104. package/dist/node/SearchableStorage.d.mts.map +0 -1
  105. package/dist/node/SearchableStorage.d.ts +0 -10
  106. package/dist/node/SearchableStorage.d.ts.map +0 -1
  107. package/dist/node/Stage.d.cts +0 -29
  108. package/dist/node/Stage.d.cts.map +0 -1
  109. package/dist/node/Stage.d.mts +0 -29
  110. package/dist/node/Stage.d.mts.map +0 -1
  111. package/dist/node/Stage.d.ts +0 -29
  112. package/dist/node/Stage.d.ts.map +0 -1
  113. package/dist/node/State.d.cts +0 -5
  114. package/dist/node/State.d.cts.map +0 -1
  115. package/dist/node/State.d.mts +0 -5
  116. package/dist/node/State.d.mts.map +0 -1
  117. package/dist/node/State.d.ts +0 -5
  118. package/dist/node/State.d.ts.map +0 -1
  119. package/src/Config.ts +0 -35
  120. package/src/Diviner.ts +0 -228
  121. package/src/Labels.ts +0 -13
  122. package/src/Params.ts +0 -6
  123. package/src/Schema.ts +0 -2
  124. package/src/SearchableStorage.ts +0 -9
  125. package/src/Stage.ts +0 -30
  126. package/src/State.ts +0 -5
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
6
  var __copyProps = (to, from, except, desc) => {
11
7
  if (from && typeof from === "object" || typeof from === "function") {
12
8
  for (let key of __getOwnPropNames(from))
@@ -15,205 +11,12 @@ var __copyProps = (to, from, except, desc) => {
15
11
  }
16
12
  return to;
17
13
  };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
16
 
20
17
  // src/index.ts
21
18
  var src_exports = {};
22
- __export(src_exports, {
23
- DivinerStageSchema: () => DivinerStageSchema,
24
- IndexingDiviner: () => IndexingDiviner,
25
- IndexingDivinerConfigSchema: () => IndexingDivinerConfigSchema,
26
- IndexingDivinerSchema: () => IndexingDivinerSchema
27
- });
28
19
  module.exports = __toCommonJS(src_exports);
29
-
30
- // src/Schema.ts
31
- var IndexingDivinerSchema = "network.xyo.diviner.indexing";
32
-
33
- // src/Config.ts
34
- var IndexingDivinerConfigSchema = `${IndexingDivinerSchema}.config`;
35
-
36
- // src/Diviner.ts
37
- var import_assert = require("@xylabs/assert");
38
- var import_abstract_diviner = require("@xyo-network/abstract-diviner");
39
- var import_archivist_wrapper = require("@xyo-network/archivist-wrapper");
40
- var import_boundwitness_builder = require("@xyo-network/boundwitness-builder");
41
- var import_boundwitness_model = require("@xyo-network/boundwitness-model");
42
- var import_diviner_boundwitness_model = require("@xyo-network/diviner-boundwitness-model");
43
- var import_diviner_model = require("@xyo-network/diviner-model");
44
- var import_diviner_wrapper = require("@xyo-network/diviner-wrapper");
45
- var import_module_model = require("@xyo-network/module-model");
46
- var import_payload_builder = require("@xyo-network/payload-builder");
47
- var moduleName = "IndexingDiviner";
48
- var IndexingDiviner = class extends import_abstract_diviner.AbstractDiviner {
49
- static configSchemas = [IndexingDivinerConfigSchema, import_diviner_model.DivinerConfigSchema];
50
- _lastState;
51
- _pollId;
52
- get payloadDivinerLimit() {
53
- return this.config.payloadDivinerLimit ?? 1e3;
54
- }
55
- get pollFrequency() {
56
- return this.config.pollFrequency ?? 1e4;
57
- }
58
- /**
59
- * Works via batched iteration of the source archivist to populate the index.
60
- * @returns A promise that resolves when the background process is complete
61
- */
62
- backgroundDivine = async () => {
63
- const lastState = await this.retrieveState();
64
- const indexCandidateDiviner = await this.getIndexingDivinerStage("stateToIndexCandidateDiviner");
65
- const results = lastState ? await indexCandidateDiviner.divine([lastState]) : await indexCandidateDiviner.divine();
66
- const nextState = results.find(import_module_model.isModuleState);
67
- const indexCandidates = results.filter((x) => !(0, import_module_model.isModuleState)(x));
68
- const toIndexTransformDiviner = await this.getIndexingDivinerStage("indexCandidateToIndexDiviner");
69
- const indexes = await toIndexTransformDiviner.divine(indexCandidates);
70
- const indexArchivist = await this.getArchivistForStore("indexStore");
71
- await indexArchivist.insert(indexes);
72
- if (nextState) {
73
- await this.commitState(nextState);
74
- }
75
- };
76
- /**
77
- * Commit the internal state of the Diviner process. This is similar
78
- * to a transaction completion in a database and should only be called
79
- * when results have been successfully persisted to the appropriate
80
- * external stores.
81
- * @param nextState The state to commit
82
- */
83
- async commitState(nextState) {
84
- if (nextState.state.offset === this._lastState?.state.offset)
85
- return;
86
- this._lastState = nextState;
87
- const archivist = await this.getArchivistForStore("stateStore");
88
- const [bw] = await new import_boundwitness_builder.BoundWitnessBuilder().payload(nextState).witness(this.account).build();
89
- await archivist.insert([bw, nextState]);
90
- }
91
- async divineHandler(payloads = []) {
92
- const indexPayloadDiviner = await this.getPayloadDivinerForStore("indexStore");
93
- const divinerQueryToIndexQueryDiviner = await this.getIndexingDivinerStage("divinerQueryToIndexQueryDiviner");
94
- const indexQueryResponseToDivinerQueryResponseDiviner = await this.getIndexingDivinerStage("indexQueryResponseToDivinerQueryResponseDiviner");
95
- const results = (await Promise.all(
96
- payloads.map(async (payload) => {
97
- const indexQuery = await divinerQueryToIndexQueryDiviner.divine([payload]);
98
- const indexedResults = await indexPayloadDiviner.divine(indexQuery);
99
- const response = await Promise.all(
100
- indexedResults.flat().map((indexedResult) => indexQueryResponseToDivinerQueryResponseDiviner.divine([payload, indexedResult]))
101
- );
102
- return response.flat();
103
- })
104
- )).flat();
105
- return results;
106
- }
107
- /**
108
- * Retrieves the archivist for the specified store
109
- * @param store The store to retrieve the archivist for
110
- * @returns The archivist for the specified store
111
- */
112
- async getArchivistForStore(store) {
113
- const name = (0, import_assert.assertEx)(this.config?.[store]?.archivist, () => `${moduleName}: Config for ${store}.archivist not specified`);
114
- const mod = (0, import_assert.assertEx)(await this.resolve(name), () => `${moduleName}: Failed to resolve ${store}.archivist`);
115
- return import_archivist_wrapper.ArchivistWrapper.wrap(mod, this.account);
116
- }
117
- /**
118
- * Retrieves the BoundWitness Diviner for the specified store
119
- * @param store The store to retrieve the BoundWitness Diviner for
120
- * @returns The BoundWitness Diviner for the specified store
121
- */
122
- async getBoundWitnessDivinerForStore(store) {
123
- const name = (0, import_assert.assertEx)(this.config?.[store]?.boundWitnessDiviner, () => `${moduleName}: Config for ${store}.boundWitnessDiviner not specified`);
124
- const mod = (0, import_assert.assertEx)(await this.resolve(name), () => `${moduleName}: Failed to resolve ${store}.boundWitnessDiviner`);
125
- return import_diviner_wrapper.DivinerWrapper.wrap(mod, this.account);
126
- }
127
- /**
128
- * Gets the Diviner for the supplied Indexing Diviner stage
129
- * @param transform The Indexing Diviner stage
130
- * @returns The diviner corresponding to the Indexing Diviner stage
131
- */
132
- async getIndexingDivinerStage(transform) {
133
- const nameOrAddress = (0, import_assert.assertEx)(
134
- this.config?.indexingDivinerStages?.[transform],
135
- () => `${moduleName}: Config for indexingDivinerStages.${transform} not specified`
136
- );
137
- const mod = await this.resolve(nameOrAddress);
138
- return (0, import_assert.assertEx)((0, import_diviner_model.asDivinerInstance)(mod), () => `${moduleName}: Failed to resolve indexing diviner stage for ${transform}`);
139
- }
140
- /**
141
- * Retrieves the Payload Diviner for the specified store
142
- * @param store The store to retrieve the Payload Diviner for
143
- * @returns The Payload Diviner for the specified store
144
- */
145
- async getPayloadDivinerForStore(store) {
146
- const name = (0, import_assert.assertEx)(this.config?.[store]?.payloadDiviner, () => `${moduleName}: Config for ${store}.payloadDiviner not specified`);
147
- const mod = (0, import_assert.assertEx)(await this.resolve(name), () => `${moduleName}: Failed to resolve ${store}.payloadDiviner`);
148
- return import_diviner_wrapper.DivinerWrapper.wrap(mod, this.account);
149
- }
150
- /**
151
- * Retrieves the last state of the Diviner process. Used to recover state after
152
- * preemptions, reboots, etc.
153
- */
154
- async retrieveState() {
155
- if (this._lastState)
156
- return this._lastState;
157
- let hash = "";
158
- const diviner = await this.getBoundWitnessDivinerForStore("stateStore");
159
- const query = new import_payload_builder.PayloadBuilder({ schema: import_diviner_boundwitness_model.BoundWitnessDivinerQuerySchema }).fields({
160
- address: this.account.address,
161
- limit: 1,
162
- offset: 0,
163
- order: "desc",
164
- payload_schemas: [import_module_model.ModuleStateSchema]
165
- }).build();
166
- const boundWitnesses = await diviner.divine([query]);
167
- if (boundWitnesses.length > 0) {
168
- const boundWitness = boundWitnesses[0];
169
- if ((0, import_boundwitness_model.isBoundWitness)(boundWitness)) {
170
- hash = boundWitness.addresses.map((address, index) => ({ address, index })).filter(({ address }) => address === this.account.address).reduce(
171
- (prev, curr) => boundWitness.payload_schemas?.[curr?.index] === import_module_model.ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev,
172
- ""
173
- );
174
- }
175
- }
176
- if (hash) {
177
- const archivist = await this.getArchivistForStore("stateStore");
178
- const payload = (await archivist.get([hash])).find(import_module_model.isModuleState);
179
- if (payload) {
180
- return payload;
181
- }
182
- }
183
- return void 0;
184
- }
185
- async startHandler() {
186
- await super.startHandler();
187
- this.poll();
188
- return true;
189
- }
190
- async stopHandler(_timeout) {
191
- if (this._pollId) {
192
- clearTimeout(this._pollId);
193
- this._pollId = void 0;
194
- }
195
- return await super.stopHandler();
196
- }
197
- /**
198
- * Runs the background divine process on a loop with a delay
199
- * specified by the `config.pollFrequency`
200
- */
201
- poll() {
202
- this._pollId = setTimeout(async () => {
203
- try {
204
- await this.backgroundDivine();
205
- } catch (e) {
206
- console.log(e);
207
- } finally {
208
- if (this._pollId)
209
- clearTimeout(this._pollId);
210
- this._pollId = void 0;
211
- this.poll();
212
- }
213
- }, this.pollFrequency);
214
- }
215
- };
216
-
217
- // src/Stage.ts
218
- var DivinerStageSchema = "network.xyo.diviner.stage";
20
+ __reExport(src_exports, require("@xyo-network/diviner-indexing-memory"), module.exports);
21
+ __reExport(src_exports, require("@xyo-network/diviner-indexing-model"), module.exports);
219
22
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/Schema.ts","../../src/Config.ts","../../src/Diviner.ts","../../src/Stage.ts"],"sourcesContent":["export * from './Config'\nexport * from './Diviner'\nexport * from './Labels'\nexport * from './Params'\nexport * from './Schema'\nexport * from './SearchableStorage'\nexport * from './Stage'\n","export const IndexingDivinerSchema = 'network.xyo.diviner.indexing' as const\nexport type ImageThumbnailDivinerSchema = typeof IndexingDivinerSchema\n","import { DivinerConfig } from '@xyo-network/diviner-model'\n\nimport { IndexingDivinerSchema } from './Schema'\nimport { SearchableStorage } from './SearchableStorage'\nimport { IndexingDivinerStageConfig } from './Stage'\n\nexport const IndexingDivinerConfigSchema = `${IndexingDivinerSchema}.config` as const\nexport type IndexingDivinerConfigSchema = typeof IndexingDivinerConfigSchema\n\nexport type IndexingDivinerConfig = DivinerConfig<{\n /**\n * Where the diviner should store it's index\n */\n indexStore?: SearchableStorage\n /**\n * Config section for individual indexing diviner stages\n */\n indexingDivinerStages: IndexingDivinerStageConfig\n /**\n * The maximum number of payloads to index at a time\n */\n payloadDivinerLimit?: number\n /**\n * How often to poll for new payloads to index\n */\n pollFrequency?: number\n /**\n * The schema for the Diviner config\n */\n schema: IndexingDivinerConfigSchema\n /**\n * Where the diviner should persist its internal state\n */\n stateStore?: SearchableStorage\n}>\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { asDivinerInstance, DivinerConfigSchema, DivinerModule, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport { isModuleState, ModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { IndexingDivinerConfig, IndexingDivinerConfigSchema } from './Config'\nimport { IndexingDivinerParams } from './Params'\nimport { IndexingDivinerStage } from './Stage'\nimport { IndexingDivinerState } from './State'\n\ntype ConfigStoreKey = 'indexStore' | 'stateStore'\n\ntype ConfigStore = Extract<keyof IndexingDivinerConfig, ConfigStoreKey>\n\nconst moduleName = 'IndexingDiviner'\n\nexport class IndexingDiviner<\n TParams extends IndexingDivinerParams = IndexingDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\n TEventData extends DivinerModuleEventData<DivinerModule<TParams>, TIn, TOut> = DivinerModuleEventData<DivinerModule<TParams>, TIn, TOut>,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas = [IndexingDivinerConfigSchema, DivinerConfigSchema]\n\n private _lastState?: ModuleState<IndexingDivinerState>\n private _pollId?: string | number | NodeJS.Timeout\n\n get payloadDivinerLimit() {\n return this.config.payloadDivinerLimit ?? 1_000\n }\n\n get pollFrequency() {\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>) {\n // Don't commit state if no state has changed\n if (nextState.state.offset === this._lastState?.state.offset) return\n this._lastState = nextState\n const archivist = await this.getArchivistForStore('stateStore')\n const [bw] = await new BoundWitnessBuilder().payload(nextState).witness(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) {\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`)\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) {\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`)\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) {\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) {\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`)\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 if (this._lastState) return this._lastState\n let hash: string = ''\n const diviner = await this.getBoundWitnessDivinerForStore('stateStore')\n const query = new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({\n address: this.account.address,\n limit: 1,\n offset: 0,\n order: 'desc',\n payload_schemas: [ModuleStateSchema],\n })\n .build()\n const boundWitnesses = await diviner.divine([query])\n if (boundWitnesses.length > 0) {\n const boundWitness = boundWitnesses[0]\n if (isBoundWitness(boundWitness)) {\n // Find the index for this address in the BoundWitness that is a ModuleState\n hash = boundWitness.addresses\n .map((address, index) => ({ address, index }))\n .filter(({ address }) => address === this.account.address)\n .reduce(\n (prev, curr) => (boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev),\n '',\n )\n }\n }\n\n // If we able to located the last state\n if (hash) {\n // Get last state\n const archivist = await this.getArchivistForStore('stateStore')\n const payload = (await archivist.get([hash])).find(isModuleState<IndexingDivinerState>)\n if (payload) {\n return payload\n }\n }\n return undefined\n }\n\n protected override async startHandler(): Promise<boolean> {\n await super.startHandler()\n this.poll()\n return true\n }\n\n protected override async stopHandler(_timeout?: number | undefined): Promise<boolean> {\n if (this._pollId) {\n clearTimeout(this._pollId)\n this._pollId = undefined\n }\n return 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 this._pollId = setTimeout(async () => {\n try {\n await this.backgroundDivine()\n } catch (e) {\n console.log(e)\n } finally {\n if (this._pollId) clearTimeout(this._pollId)\n this._pollId = undefined\n this.poll()\n }\n }, this.pollFrequency)\n }\n}\n","export type DivinerStageSchema = 'network.xyo.diviner.stage'\nexport const DivinerStageSchema: DivinerStageSchema = 'network.xyo.diviner.stage'\n\n/**\n * The diviners for each stage of an indexing diviner\n */\nexport type IndexingDivinerStage =\n /**\n * Transforms a diviner query into an index query\n */\n | 'divinerQueryToIndexQueryDiviner'\n /**\n * Transforms the index candidates into indexes\n */\n | 'indexCandidateToIndexDiviner'\n /**\n * Transforms an index query response into a diviner divine query response\n */\n | 'indexQueryResponseToDivinerQueryResponseDiviner'\n /**\n * Uses the current state to determine the next batch of index candidates\n */\n | 'stateToIndexCandidateDiviner'\n\n/**\n * Config section for declaring each indexing diviner stage\n */\nexport type IndexingDivinerStageConfig = {\n [key in IndexingDivinerStage]: string\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,wBAAwB;;;ACM9B,IAAM,8BAA8B,GAAG,qBAAqB;;;ACNnE,oBAAyB;AACzB,8BAAgC;AAChC,+BAAiC;AACjC,kCAAoC;AACpC,gCAA+B;AAC/B,wCAAgF;AAChF,2BAA8F;AAC9F,6BAA+B;AAC/B,0BAA8D;AAC9D,6BAA+B;AAY/B,IAAM,aAAa;AAEZ,IAAM,kBAAN,cAKG,wCAAgD;AAAA,EACxD,OAAyB,gBAAgB,CAAC,6BAA6B,wCAAmB;AAAA,EAElF;AAAA,EACA;AAAA,EAER,IAAI,sBAAsB;AACxB,WAAO,KAAK,OAAO,uBAAuB;AAAA,EAC5C;AAAA,EAEA,IAAI,gBAAgB;AAClB,WAAO,KAAK,OAAO,iBAAiB;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,mBAAmB,YAA2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AAK,iCAAmC;AACtF,UAAI,SAAS;AACX,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAyB,eAAiC;AACxD,UAAM,MAAM,aAAa;AACzB,SAAK,KAAK;AACV,WAAO;AAAA,EACT;AAAA,EAEA,MAAyB,YAAY,UAAiD;AACpF,QAAI,KAAK,SAAS;AAChB,mBAAa,KAAK,OAAO;AACzB,WAAK,UAAU;AAAA,IACjB;AACA,WAAO,MAAM,MAAM,YAAY;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,OAAO;AACb,SAAK,UAAU,WAAW,YAAY;AACpC,UAAI;AACF,cAAM,KAAK,iBAAiB;AAAA,MAC9B,SAAS,GAAG;AACV,gBAAQ,IAAI,CAAC;AAAA,MACf,UAAE;AACA,YAAI,KAAK;AAAS,uBAAa,KAAK,OAAO;AAC3C,aAAK,UAAU;AACf,aAAK,KAAK;AAAA,MACZ;AAAA,IACF,GAAG,KAAK,aAAa;AAAA,EACvB;AACF;;;AClOO,IAAM,qBAAyC;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from '@xyo-network/diviner-indexing-memory'\nexport * from '@xyo-network/diviner-indexing-model'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,iDAAd;AACA,wBAAc,gDADd;","names":[]}
@@ -1,8 +1,3 @@
1
- export * from './Config';
2
- export * from './Diviner';
3
- export * from './Labels';
4
- export * from './Params';
5
- export * from './Schema';
6
- export * from './SearchableStorage';
7
- export * from './Stage';
1
+ export * from '@xyo-network/diviner-indexing-memory';
2
+ export * from '@xyo-network/diviner-indexing-model';
8
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA;AACpD,cAAc,qCAAqC,CAAA"}
@@ -1,8 +1,3 @@
1
- export * from './Config';
2
- export * from './Diviner';
3
- export * from './Labels';
4
- export * from './Params';
5
- export * from './Schema';
6
- export * from './SearchableStorage';
7
- export * from './Stage';
1
+ export * from '@xyo-network/diviner-indexing-memory';
2
+ export * from '@xyo-network/diviner-indexing-model';
8
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA;AACpD,cAAc,qCAAqC,CAAA"}
@@ -1,8 +1,3 @@
1
- export * from './Config';
2
- export * from './Diviner';
3
- export * from './Labels';
4
- export * from './Params';
5
- export * from './Schema';
6
- export * from './SearchableStorage';
7
- export * from './Stage';
1
+ export * from '@xyo-network/diviner-indexing-memory';
2
+ export * from '@xyo-network/diviner-indexing-model';
8
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA;AACpD,cAAc,qCAAqC,CAAA"}
@@ -1,196 +1,4 @@
1
- // src/Schema.ts
2
- var IndexingDivinerSchema = "network.xyo.diviner.indexing";
3
-
4
- // src/Config.ts
5
- var IndexingDivinerConfigSchema = `${IndexingDivinerSchema}.config`;
6
-
7
- // src/Diviner.ts
8
- import { assertEx } from "@xylabs/assert";
9
- import { AbstractDiviner } from "@xyo-network/abstract-diviner";
10
- import { ArchivistWrapper } from "@xyo-network/archivist-wrapper";
11
- import { BoundWitnessBuilder } from "@xyo-network/boundwitness-builder";
12
- import { isBoundWitness } from "@xyo-network/boundwitness-model";
13
- import { BoundWitnessDivinerQuerySchema } from "@xyo-network/diviner-boundwitness-model";
14
- import { asDivinerInstance, DivinerConfigSchema } from "@xyo-network/diviner-model";
15
- import { DivinerWrapper } from "@xyo-network/diviner-wrapper";
16
- import { isModuleState, ModuleStateSchema } from "@xyo-network/module-model";
17
- import { PayloadBuilder } from "@xyo-network/payload-builder";
18
- var moduleName = "IndexingDiviner";
19
- var IndexingDiviner = class extends AbstractDiviner {
20
- static configSchemas = [IndexingDivinerConfigSchema, DivinerConfigSchema];
21
- _lastState;
22
- _pollId;
23
- get payloadDivinerLimit() {
24
- return this.config.payloadDivinerLimit ?? 1e3;
25
- }
26
- get pollFrequency() {
27
- return this.config.pollFrequency ?? 1e4;
28
- }
29
- /**
30
- * Works via batched iteration of the source archivist to populate the index.
31
- * @returns A promise that resolves when the background process is complete
32
- */
33
- backgroundDivine = async () => {
34
- const lastState = await this.retrieveState();
35
- const indexCandidateDiviner = await this.getIndexingDivinerStage("stateToIndexCandidateDiviner");
36
- const results = lastState ? await indexCandidateDiviner.divine([lastState]) : await indexCandidateDiviner.divine();
37
- const nextState = results.find(isModuleState);
38
- const indexCandidates = results.filter((x) => !isModuleState(x));
39
- const toIndexTransformDiviner = await this.getIndexingDivinerStage("indexCandidateToIndexDiviner");
40
- const indexes = await toIndexTransformDiviner.divine(indexCandidates);
41
- const indexArchivist = await this.getArchivistForStore("indexStore");
42
- await indexArchivist.insert(indexes);
43
- if (nextState) {
44
- await this.commitState(nextState);
45
- }
46
- };
47
- /**
48
- * Commit the internal state of the Diviner process. This is similar
49
- * to a transaction completion in a database and should only be called
50
- * when results have been successfully persisted to the appropriate
51
- * external stores.
52
- * @param nextState The state to commit
53
- */
54
- async commitState(nextState) {
55
- if (nextState.state.offset === this._lastState?.state.offset)
56
- return;
57
- this._lastState = nextState;
58
- const archivist = await this.getArchivistForStore("stateStore");
59
- const [bw] = await new BoundWitnessBuilder().payload(nextState).witness(this.account).build();
60
- await archivist.insert([bw, nextState]);
61
- }
62
- async divineHandler(payloads = []) {
63
- const indexPayloadDiviner = await this.getPayloadDivinerForStore("indexStore");
64
- const divinerQueryToIndexQueryDiviner = await this.getIndexingDivinerStage("divinerQueryToIndexQueryDiviner");
65
- const indexQueryResponseToDivinerQueryResponseDiviner = await this.getIndexingDivinerStage("indexQueryResponseToDivinerQueryResponseDiviner");
66
- const results = (await Promise.all(
67
- payloads.map(async (payload) => {
68
- const indexQuery = await divinerQueryToIndexQueryDiviner.divine([payload]);
69
- const indexedResults = await indexPayloadDiviner.divine(indexQuery);
70
- const response = await Promise.all(
71
- indexedResults.flat().map((indexedResult) => indexQueryResponseToDivinerQueryResponseDiviner.divine([payload, indexedResult]))
72
- );
73
- return response.flat();
74
- })
75
- )).flat();
76
- return results;
77
- }
78
- /**
79
- * Retrieves the archivist for the specified store
80
- * @param store The store to retrieve the archivist for
81
- * @returns The archivist for the specified store
82
- */
83
- async getArchivistForStore(store) {
84
- const name = assertEx(this.config?.[store]?.archivist, () => `${moduleName}: Config for ${store}.archivist not specified`);
85
- const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve ${store}.archivist`);
86
- return ArchivistWrapper.wrap(mod, this.account);
87
- }
88
- /**
89
- * Retrieves the BoundWitness Diviner for the specified store
90
- * @param store The store to retrieve the BoundWitness Diviner for
91
- * @returns The BoundWitness Diviner for the specified store
92
- */
93
- async getBoundWitnessDivinerForStore(store) {
94
- const name = assertEx(this.config?.[store]?.boundWitnessDiviner, () => `${moduleName}: Config for ${store}.boundWitnessDiviner not specified`);
95
- const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve ${store}.boundWitnessDiviner`);
96
- return DivinerWrapper.wrap(mod, this.account);
97
- }
98
- /**
99
- * Gets the Diviner for the supplied Indexing Diviner stage
100
- * @param transform The Indexing Diviner stage
101
- * @returns The diviner corresponding to the Indexing Diviner stage
102
- */
103
- async getIndexingDivinerStage(transform) {
104
- const nameOrAddress = assertEx(
105
- this.config?.indexingDivinerStages?.[transform],
106
- () => `${moduleName}: Config for indexingDivinerStages.${transform} not specified`
107
- );
108
- const mod = await this.resolve(nameOrAddress);
109
- return assertEx(asDivinerInstance(mod), () => `${moduleName}: Failed to resolve indexing diviner stage for ${transform}`);
110
- }
111
- /**
112
- * Retrieves the Payload Diviner for the specified store
113
- * @param store The store to retrieve the Payload Diviner for
114
- * @returns The Payload Diviner for the specified store
115
- */
116
- async getPayloadDivinerForStore(store) {
117
- const name = assertEx(this.config?.[store]?.payloadDiviner, () => `${moduleName}: Config for ${store}.payloadDiviner not specified`);
118
- const mod = assertEx(await this.resolve(name), () => `${moduleName}: Failed to resolve ${store}.payloadDiviner`);
119
- return DivinerWrapper.wrap(mod, this.account);
120
- }
121
- /**
122
- * Retrieves the last state of the Diviner process. Used to recover state after
123
- * preemptions, reboots, etc.
124
- */
125
- async retrieveState() {
126
- if (this._lastState)
127
- return this._lastState;
128
- let hash = "";
129
- const diviner = await this.getBoundWitnessDivinerForStore("stateStore");
130
- const query = new PayloadBuilder({ schema: BoundWitnessDivinerQuerySchema }).fields({
131
- address: this.account.address,
132
- limit: 1,
133
- offset: 0,
134
- order: "desc",
135
- payload_schemas: [ModuleStateSchema]
136
- }).build();
137
- const boundWitnesses = await diviner.divine([query]);
138
- if (boundWitnesses.length > 0) {
139
- const boundWitness = boundWitnesses[0];
140
- if (isBoundWitness(boundWitness)) {
141
- hash = boundWitness.addresses.map((address, index) => ({ address, index })).filter(({ address }) => address === this.account.address).reduce(
142
- (prev, curr) => boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev,
143
- ""
144
- );
145
- }
146
- }
147
- if (hash) {
148
- const archivist = await this.getArchivistForStore("stateStore");
149
- const payload = (await archivist.get([hash])).find(isModuleState);
150
- if (payload) {
151
- return payload;
152
- }
153
- }
154
- return void 0;
155
- }
156
- async startHandler() {
157
- await super.startHandler();
158
- this.poll();
159
- return true;
160
- }
161
- async stopHandler(_timeout) {
162
- if (this._pollId) {
163
- clearTimeout(this._pollId);
164
- this._pollId = void 0;
165
- }
166
- return await super.stopHandler();
167
- }
168
- /**
169
- * Runs the background divine process on a loop with a delay
170
- * specified by the `config.pollFrequency`
171
- */
172
- poll() {
173
- this._pollId = setTimeout(async () => {
174
- try {
175
- await this.backgroundDivine();
176
- } catch (e) {
177
- console.log(e);
178
- } finally {
179
- if (this._pollId)
180
- clearTimeout(this._pollId);
181
- this._pollId = void 0;
182
- this.poll();
183
- }
184
- }, this.pollFrequency);
185
- }
186
- };
187
-
188
- // src/Stage.ts
189
- var DivinerStageSchema = "network.xyo.diviner.stage";
190
- export {
191
- DivinerStageSchema,
192
- IndexingDiviner,
193
- IndexingDivinerConfigSchema,
194
- IndexingDivinerSchema
195
- };
1
+ // src/index.ts
2
+ export * from "@xyo-network/diviner-indexing-memory";
3
+ export * from "@xyo-network/diviner-indexing-model";
196
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Schema.ts","../../src/Config.ts","../../src/Diviner.ts","../../src/Stage.ts"],"sourcesContent":["export const IndexingDivinerSchema = 'network.xyo.diviner.indexing' as const\nexport type ImageThumbnailDivinerSchema = typeof IndexingDivinerSchema\n","import { DivinerConfig } from '@xyo-network/diviner-model'\n\nimport { IndexingDivinerSchema } from './Schema'\nimport { SearchableStorage } from './SearchableStorage'\nimport { IndexingDivinerStageConfig } from './Stage'\n\nexport const IndexingDivinerConfigSchema = `${IndexingDivinerSchema}.config` as const\nexport type IndexingDivinerConfigSchema = typeof IndexingDivinerConfigSchema\n\nexport type IndexingDivinerConfig = DivinerConfig<{\n /**\n * Where the diviner should store it's index\n */\n indexStore?: SearchableStorage\n /**\n * Config section for individual indexing diviner stages\n */\n indexingDivinerStages: IndexingDivinerStageConfig\n /**\n * The maximum number of payloads to index at a time\n */\n payloadDivinerLimit?: number\n /**\n * How often to poll for new payloads to index\n */\n pollFrequency?: number\n /**\n * The schema for the Diviner config\n */\n schema: IndexingDivinerConfigSchema\n /**\n * Where the diviner should persist its internal state\n */\n stateStore?: SearchableStorage\n}>\n","import { assertEx } from '@xylabs/assert'\nimport { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { asDivinerInstance, DivinerConfigSchema, DivinerModule, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport { isModuleState, ModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { IndexingDivinerConfig, IndexingDivinerConfigSchema } from './Config'\nimport { IndexingDivinerParams } from './Params'\nimport { IndexingDivinerStage } from './Stage'\nimport { IndexingDivinerState } from './State'\n\ntype ConfigStoreKey = 'indexStore' | 'stateStore'\n\ntype ConfigStore = Extract<keyof IndexingDivinerConfig, ConfigStoreKey>\n\nconst moduleName = 'IndexingDiviner'\n\nexport class IndexingDiviner<\n TParams extends IndexingDivinerParams = IndexingDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\n TEventData extends DivinerModuleEventData<DivinerModule<TParams>, TIn, TOut> = DivinerModuleEventData<DivinerModule<TParams>, TIn, TOut>,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas = [IndexingDivinerConfigSchema, DivinerConfigSchema]\n\n private _lastState?: ModuleState<IndexingDivinerState>\n private _pollId?: string | number | NodeJS.Timeout\n\n get payloadDivinerLimit() {\n return this.config.payloadDivinerLimit ?? 1_000\n }\n\n get pollFrequency() {\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>) {\n // Don't commit state if no state has changed\n if (nextState.state.offset === this._lastState?.state.offset) return\n this._lastState = nextState\n const archivist = await this.getArchivistForStore('stateStore')\n const [bw] = await new BoundWitnessBuilder().payload(nextState).witness(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) {\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`)\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) {\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`)\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) {\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) {\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`)\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 if (this._lastState) return this._lastState\n let hash: string = ''\n const diviner = await this.getBoundWitnessDivinerForStore('stateStore')\n const query = new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({\n address: this.account.address,\n limit: 1,\n offset: 0,\n order: 'desc',\n payload_schemas: [ModuleStateSchema],\n })\n .build()\n const boundWitnesses = await diviner.divine([query])\n if (boundWitnesses.length > 0) {\n const boundWitness = boundWitnesses[0]\n if (isBoundWitness(boundWitness)) {\n // Find the index for this address in the BoundWitness that is a ModuleState\n hash = boundWitness.addresses\n .map((address, index) => ({ address, index }))\n .filter(({ address }) => address === this.account.address)\n .reduce(\n (prev, curr) => (boundWitness.payload_schemas?.[curr?.index] === ModuleStateSchema ? boundWitness.payload_hashes[curr?.index] : prev),\n '',\n )\n }\n }\n\n // If we able to located the last state\n if (hash) {\n // Get last state\n const archivist = await this.getArchivistForStore('stateStore')\n const payload = (await archivist.get([hash])).find(isModuleState<IndexingDivinerState>)\n if (payload) {\n return payload\n }\n }\n return undefined\n }\n\n protected override async startHandler(): Promise<boolean> {\n await super.startHandler()\n this.poll()\n return true\n }\n\n protected override async stopHandler(_timeout?: number | undefined): Promise<boolean> {\n if (this._pollId) {\n clearTimeout(this._pollId)\n this._pollId = undefined\n }\n return 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 this._pollId = setTimeout(async () => {\n try {\n await this.backgroundDivine()\n } catch (e) {\n console.log(e)\n } finally {\n if (this._pollId) clearTimeout(this._pollId)\n this._pollId = undefined\n this.poll()\n }\n }, this.pollFrequency)\n }\n}\n","export type DivinerStageSchema = 'network.xyo.diviner.stage'\nexport const DivinerStageSchema: DivinerStageSchema = 'network.xyo.diviner.stage'\n\n/**\n * The diviners for each stage of an indexing diviner\n */\nexport type IndexingDivinerStage =\n /**\n * Transforms a diviner query into an index query\n */\n | 'divinerQueryToIndexQueryDiviner'\n /**\n * Transforms the index candidates into indexes\n */\n | 'indexCandidateToIndexDiviner'\n /**\n * Transforms an index query response into a diviner divine query response\n */\n | 'indexQueryResponseToDivinerQueryResponseDiviner'\n /**\n * Uses the current state to determine the next batch of index candidates\n */\n | 'stateToIndexCandidateDiviner'\n\n/**\n * Config section for declaring each indexing diviner stage\n */\nexport type IndexingDivinerStageConfig = {\n [key in IndexingDivinerStage]: string\n}\n"],"mappings":";AAAO,IAAM,wBAAwB;;;ACM9B,IAAM,8BAA8B,GAAG,qBAAqB;;;ACNnE,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAA0C,sCAAsC;AAChF,SAAS,mBAAmB,2BAAkE;AAC9F,SAAS,sBAAsB;AAC/B,SAAS,eAA4B,yBAAyB;AAC9D,SAAS,sBAAsB;AAY/B,IAAM,aAAa;AAEZ,IAAM,kBAAN,cAKG,gBAAgD;AAAA,EACxD,OAAyB,gB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,MAAM,KAAK,MAAM,oBAAoB,aAAa,eAAe,MAAM,KAAK,IAAI;AAAA,UAChI;AAAA,QACF;AAAA,MACJ;AAAA,IACF;AAGA,QAAI,MAAM;AAER,YAAM,YAAY,MAAM,KAAK,qBAAqB,YAAY;AAC9D,YAAM,WAAW,MAAM,UAAU,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,aAAmC;AACtF,UAAI,SAAS;AACX,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAyB,eAAiC;AACxD,UAAM,MAAM,aAAa;AACzB,SAAK,KAAK;AACV,WAAO;AAAA,EACT;AAAA,EAEA,MAAyB,YAAY,UAAiD;AACpF,QAAI,KAAK,SAAS;AAChB,mBAAa,KAAK,OAAO;AACzB,WAAK,UAAU;AAAA,IACjB;AACA,WAAO,MAAM,MAAM,YAAY;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,OAAO;AACb,SAAK,UAAU,WAAW,YAAY;AACpC,UAAI;AACF,cAAM,KAAK,iBAAiB;AAAA,MAC9B,SAAS,GAAG;AACV,gBAAQ,IAAI,CAAC;AAAA,MACf,UAAE;AACA,YAAI,KAAK;AAAS,uBAAa,KAAK,OAAO;AAC3C,aAAK,UAAU;AACf,aAAK,KAAK;AAAA,MACZ;AAAA,IACF,GAAG,KAAK,aAAa;AAAA,EACvB;AACF;;;AClOO,IAAM,qBAAyC;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from '@xyo-network/diviner-indexing-memory'\nexport * from '@xyo-network/diviner-indexing-model'\n"],"mappings":";AAAA,cAAc;AACd,cAAc;","names":[]}
@@ -1,8 +1,3 @@
1
- export * from './Config';
2
- export * from './Diviner';
3
- export * from './Labels';
4
- export * from './Params';
5
- export * from './Schema';
6
- export * from './SearchableStorage';
7
- export * from './Stage';
1
+ export * from '@xyo-network/diviner-indexing-memory';
2
+ export * from '@xyo-network/diviner-indexing-model';
8
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA;AACpD,cAAc,qCAAqC,CAAA"}
@@ -1,8 +1,3 @@
1
- export * from './Config';
2
- export * from './Diviner';
3
- export * from './Labels';
4
- export * from './Params';
5
- export * from './Schema';
6
- export * from './SearchableStorage';
7
- export * from './Stage';
1
+ export * from '@xyo-network/diviner-indexing-memory';
2
+ export * from '@xyo-network/diviner-indexing-model';
8
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA;AACpD,cAAc,qCAAqC,CAAA"}
@@ -1,8 +1,3 @@
1
- export * from './Config';
2
- export * from './Diviner';
3
- export * from './Labels';
4
- export * from './Params';
5
- export * from './Schema';
6
- export * from './SearchableStorage';
7
- export * from './Stage';
1
+ export * from '@xyo-network/diviner-indexing-memory';
2
+ export * from '@xyo-network/diviner-indexing-model';
8
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,qBAAqB,CAAA;AACnC,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA;AACpD,cAAc,qCAAqC,CAAA"}