@xyo-network/diviner-temporal-indexing-memory 2.84.19 → 2.85.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,75 +1,81 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+ var __publicField = (obj, key, value) => {
5
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
+ return value;
7
+ };
8
+
1
9
  // src/Diviner.ts
2
10
  import { IndexingDiviner } from "@xyo-network/diviner-indexing-memory";
3
11
  import { IndexingDivinerConfigSchema } from "@xyo-network/diviner-indexing-model";
4
12
  import { DivinerConfigSchema } from "@xyo-network/diviner-model";
5
13
  import { TemporalIndexingDivinerConfigSchema } from "@xyo-network/diviner-temporal-indexing-model";
6
- var TemporalIndexingDiviner = class extends IndexingDiviner {
7
- static configSchema = TemporalIndexingDivinerConfigSchema;
8
- static configSchemas = [TemporalIndexingDivinerConfigSchema, IndexingDivinerConfigSchema, DivinerConfigSchema];
14
+ var _TemporalIndexingDiviner = class _TemporalIndexingDiviner extends IndexingDiviner {
9
15
  async startHandler() {
10
16
  await super.startHandler();
11
17
  return true;
12
18
  }
13
19
  };
20
+ __name(_TemporalIndexingDiviner, "TemporalIndexingDiviner");
21
+ __publicField(_TemporalIndexingDiviner, "configSchema", TemporalIndexingDivinerConfigSchema);
22
+ __publicField(_TemporalIndexingDiviner, "configSchemas", [
23
+ TemporalIndexingDivinerConfigSchema,
24
+ IndexingDivinerConfigSchema,
25
+ DivinerConfigSchema
26
+ ]);
27
+ var TemporalIndexingDiviner = _TemporalIndexingDiviner;
14
28
 
15
29
  // src/DivinerQueryToIndexQueryDiviner/Diviner.ts
16
30
  import { AbstractDiviner } from "@xyo-network/abstract-diviner";
17
31
  import { jsonPathToTransformersDictionary, reducePayloads } from "@xyo-network/diviner-jsonpath-aggregate-memory";
18
32
  import { DivinerConfigSchema as DivinerConfigSchema2 } from "@xyo-network/diviner-model";
19
33
  import { PayloadDivinerQuerySchema } from "@xyo-network/diviner-payload-model";
20
- import {
21
- TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,
22
- TemporalIndexingDivinerResultIndexSchema
23
- } from "@xyo-network/diviner-temporal-indexing-model";
34
+ import { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema, TemporalIndexingDivinerResultIndexSchema } from "@xyo-network/diviner-temporal-indexing-model";
24
35
  import { PayloadBuilder } from "@xyo-network/payload-builder";
25
36
  import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
26
- var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class extends AbstractDiviner {
27
- static configSchema = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema;
28
- static configSchemas = [DivinerConfigSchema2, TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema];
29
- static labels = {
30
- "network.xyo.diviner.stage": "divinerQueryToIndexQueryDiviner"
31
- };
37
+ var _TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class _TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner extends AbstractDiviner {
32
38
  _indexableSchemas;
33
39
  _payloadTransformers;
34
40
  /**
35
- * The schema of the diviner query payloads
36
- */
41
+ * The schema of the diviner query payloads
42
+ */
37
43
  get divinerQuerySchema() {
38
44
  return this.config.divinerQuerySchema ?? PayloadDivinerQuerySchema;
39
45
  }
40
46
  /**
41
- * The schema of the index query payloads
42
- */
47
+ * The schema of the index query payloads
48
+ */
43
49
  get indexQuerySchema() {
44
50
  return this.config.indexQuerySchema ?? PayloadDivinerQuerySchema;
45
51
  }
46
52
  /**
47
- * The schema of the index payloads
48
- */
53
+ * The schema of the index payloads
54
+ */
49
55
  get indexSchema() {
50
56
  return this.config.indexSchema ?? TemporalIndexingDivinerResultIndexSchema;
51
57
  }
52
58
  /**
53
- * List of indexable schemas for this diviner
54
- */
59
+ * List of indexable schemas for this diviner
60
+ */
55
61
  get indexableSchemas() {
56
62
  if (!this._indexableSchemas)
57
63
  this._indexableSchemas = Object.keys(this.schemaTransforms);
58
64
  return this._indexableSchemas;
59
65
  }
60
66
  /**
61
- * Dictionary of schemas to payload transformers for creating indexes
62
- * from the payloads within a Bound Witness
63
- */
67
+ * Dictionary of schemas to payload transformers for creating indexes
68
+ * from the payloads within a Bound Witness
69
+ */
64
70
  get payloadTransformers() {
65
71
  if (!this._payloadTransformers)
66
72
  this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms);
67
73
  return this._payloadTransformers;
68
74
  }
69
75
  /**
70
- * The dictionary of schemas to JSON Path transform expressions for creating indexes
71
- * from the payloads within a Bound Witness
72
- */
76
+ * The dictionary of schemas to JSON Path transform expressions for creating indexes
77
+ * from the payloads within a Bound Witness
78
+ */
73
79
  get schemaTransforms() {
74
80
  var _a;
75
81
  return ((_a = this.config) == null ? void 0 : _a.schemaTransforms) ?? {
@@ -95,23 +101,33 @@ var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class extends Abstr
95
101
  async divineHandler(payloads = []) {
96
102
  const queries = payloads.filter(isPayloadOfSchemaType(this.divinerQuerySchema));
97
103
  if (queries.length > 0) {
98
- const results = await Promise.all(
99
- queries.map(async (query) => {
100
- const fields = await reducePayloads(
101
- [query],
102
- this.payloadTransformers,
103
- this.indexQuerySchema
104
- );
105
- fields.schemas = [this.indexSchema];
106
- delete fields.sources;
107
- return await new PayloadBuilder({ schema: this.indexQuerySchema }).fields(fields).build();
108
- })
109
- );
104
+ const results = await Promise.all(queries.map(async (query) => {
105
+ const fields = await reducePayloads([
106
+ query
107
+ ], this.payloadTransformers, this.indexQuerySchema);
108
+ fields.schemas = [
109
+ this.indexSchema
110
+ ];
111
+ delete fields.sources;
112
+ return await new PayloadBuilder({
113
+ schema: this.indexQuerySchema
114
+ }).fields(fields).build();
115
+ }));
110
116
  return results;
111
117
  }
112
118
  return [];
113
119
  }
114
120
  };
121
+ __name(_TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner, "TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner");
122
+ __publicField(_TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner, "configSchema", TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema);
123
+ __publicField(_TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner, "configSchemas", [
124
+ DivinerConfigSchema2,
125
+ TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema
126
+ ]);
127
+ __publicField(_TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner, "labels", {
128
+ "network.xyo.diviner.stage": "divinerQueryToIndexQueryDiviner"
129
+ });
130
+ var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = _TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner;
115
131
 
116
132
  // src/IndexCandidateToIndexDiviner/Diviner.ts
117
133
  import { containsAll } from "@xylabs/array";
@@ -121,42 +137,34 @@ import { AbstractDiviner as AbstractDiviner2 } from "@xyo-network/abstract-divin
121
137
  import { isBoundWitness } from "@xyo-network/boundwitness-model";
122
138
  import { jsonPathToTransformersDictionary as jsonPathToTransformersDictionary2 } from "@xyo-network/diviner-jsonpath-aggregate-memory";
123
139
  import { DivinerConfigSchema as DivinerConfigSchema3 } from "@xyo-network/diviner-model";
124
- import {
125
- TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,
126
- TemporalIndexingDivinerResultIndexSchema as TemporalIndexingDivinerResultIndexSchema2
127
- } from "@xyo-network/diviner-temporal-indexing-model";
140
+ import { TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema, TemporalIndexingDivinerResultIndexSchema as TemporalIndexingDivinerResultIndexSchema2 } from "@xyo-network/diviner-temporal-indexing-model";
128
141
  import { PayloadHasher } from "@xyo-network/hash";
129
142
  import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
130
143
  var moduleName = "TemporalIndexingDivinerIndexCandidateToIndexDiviner";
131
- var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends AbstractDiviner2 {
132
- static configSchema = TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema;
133
- static configSchemas = [DivinerConfigSchema3, TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema];
134
- static labels = {
135
- "network.xyo.diviner.stage": "indexCandidateToIndexDiviner"
136
- };
144
+ var _TemporalIndexingDivinerIndexCandidateToIndexDiviner = class _TemporalIndexingDivinerIndexCandidateToIndexDiviner extends AbstractDiviner2 {
137
145
  _indexableSchemas;
138
146
  _payloadTransformers;
139
147
  /**
140
- * List of indexable schemas for this diviner
141
- */
148
+ * List of indexable schemas for this diviner
149
+ */
142
150
  get indexableSchemas() {
143
151
  if (!this._indexableSchemas)
144
152
  this._indexableSchemas = Object.keys(this.schemaTransforms);
145
153
  return this._indexableSchemas;
146
154
  }
147
155
  /**
148
- * Dictionary of schemas to payload transformers for creating indexes
149
- * from the payloads within a Bound Witness
150
- */
156
+ * Dictionary of schemas to payload transformers for creating indexes
157
+ * from the payloads within a Bound Witness
158
+ */
151
159
  get payloadTransformers() {
152
160
  if (!this._payloadTransformers)
153
161
  this._payloadTransformers = jsonPathToTransformersDictionary2(this.schemaTransforms);
154
162
  return this._payloadTransformers;
155
163
  }
156
164
  /**
157
- * The dictionary of schemas to JSON Path transform expressions for creating indexes
158
- * from the payloads within a Bound Witness
159
- */
165
+ * The dictionary of schemas to JSON Path transform expressions for creating indexes
166
+ * from the payloads within a Bound Witness
167
+ */
160
168
  get schemaTransforms() {
161
169
  var _a;
162
170
  return assertEx((_a = this.config) == null ? void 0 : _a.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`);
@@ -176,57 +184,80 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
176
184
  });
177
185
  const indexablePayloads2 = indexablePayloadHashes.map((hash) => payloadDictionary[hash]).filter(exists);
178
186
  if (indexablePayloads2.length === this.indexableSchemas.length)
179
- indexableTuples.push([bw, ...indexablePayloads2]);
187
+ indexableTuples.push([
188
+ bw,
189
+ ...indexablePayloads2
190
+ ]);
180
191
  return indexableTuples;
181
192
  }, []);
182
- const indexes = await Promise.all(
183
- validIndexableTuples.map(async ([bw, ...sourcePayloads]) => {
184
- const indexFields = sourcePayloads.flatMap((payload) => {
185
- const transformers = this.payloadTransformers[payload.schema];
186
- return transformers ? transformers.map((transform) => transform(payload)) : [];
187
- });
188
- const sources = Object.keys(await PayloadHasher.toMap([bw, ...sourcePayloads]));
189
- return await new PayloadBuilder2({ schema: TemporalIndexingDivinerResultIndexSchema2 }).fields(Object.assign({ sources }, ...indexFields)).build();
190
- })
191
- );
193
+ const indexes = await Promise.all(validIndexableTuples.map(async ([bw, ...sourcePayloads]) => {
194
+ const indexFields = sourcePayloads.flatMap((payload) => {
195
+ const transformers = this.payloadTransformers[payload.schema];
196
+ return transformers ? transformers.map((transform) => transform(payload)) : [];
197
+ });
198
+ const sources = Object.keys(await PayloadHasher.toMap([
199
+ bw,
200
+ ...sourcePayloads
201
+ ]));
202
+ return await new PayloadBuilder2({
203
+ schema: TemporalIndexingDivinerResultIndexSchema2
204
+ }).fields(Object.assign({
205
+ sources
206
+ }, ...indexFields)).build();
207
+ }));
192
208
  return indexes.flat();
193
209
  }
194
210
  return [];
195
211
  }
196
212
  /**
197
- * Identifies if a payload is one that is indexed by this diviner
198
- * @param x The candidate payload
199
- * @returns True if the payload is one indexed by this diviner, false otherwise
200
- */
213
+ * Identifies if a payload is one that is indexed by this diviner
214
+ * @param x The candidate payload
215
+ * @returns True if the payload is one indexed by this diviner, false otherwise
216
+ */
201
217
  isIndexablePayload = (x) => {
202
218
  return this.indexableSchemas.includes(x == null ? void 0 : x.schema);
203
219
  };
204
220
  /**
205
- * Identifies if a schema is one that is indexed by this diviner
206
- * @param schema The candidate schema
207
- * @returns True if this schema is one indexed by this diviner, false otherwise
208
- */
221
+ * Identifies if a schema is one that is indexed by this diviner
222
+ * @param schema The candidate schema
223
+ * @returns True if this schema is one indexed by this diviner, false otherwise
224
+ */
209
225
  isIndexableSchema = (schema) => {
210
226
  return typeof schema === "string" ? this.indexableSchemas.includes(schema) : false;
211
227
  };
212
228
  };
229
+ __name(_TemporalIndexingDivinerIndexCandidateToIndexDiviner, "TemporalIndexingDivinerIndexCandidateToIndexDiviner");
230
+ __publicField(_TemporalIndexingDivinerIndexCandidateToIndexDiviner, "configSchema", TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema);
231
+ __publicField(_TemporalIndexingDivinerIndexCandidateToIndexDiviner, "configSchemas", [
232
+ DivinerConfigSchema3,
233
+ TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema
234
+ ]);
235
+ __publicField(_TemporalIndexingDivinerIndexCandidateToIndexDiviner, "labels", {
236
+ "network.xyo.diviner.stage": "indexCandidateToIndexDiviner"
237
+ });
238
+ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = _TemporalIndexingDivinerIndexCandidateToIndexDiviner;
213
239
 
214
240
  // src/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.ts
215
241
  import { AbstractDiviner as AbstractDiviner3 } from "@xyo-network/abstract-diviner";
216
242
  import { DivinerConfigSchema as DivinerConfigSchema4 } from "@xyo-network/diviner-model";
217
243
  import { isPayloadDivinerQueryPayload } from "@xyo-network/diviner-payload-model";
218
244
  import { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema } from "@xyo-network/diviner-temporal-indexing-model";
219
- var TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner = class extends AbstractDiviner3 {
220
- static configSchema = TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema;
221
- static configSchemas = [DivinerConfigSchema4, TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema];
222
- static labels = {
223
- "network.xyo.diviner.stage": "indexQueryResponseToDivinerQueryResponseDiviner"
224
- };
245
+ var _TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner = class _TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner extends AbstractDiviner3 {
225
246
  async divineHandler(payloads = []) {
226
247
  const responses = payloads.filter((p) => !isPayloadDivinerQueryPayload(p));
227
248
  return await Promise.resolve(responses);
228
249
  }
229
250
  };
251
+ __name(_TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner, "TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner");
252
+ __publicField(_TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner, "configSchema", TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema);
253
+ __publicField(_TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner, "configSchemas", [
254
+ DivinerConfigSchema4,
255
+ TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema
256
+ ]);
257
+ __publicField(_TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner, "labels", {
258
+ "network.xyo.diviner.stage": "indexQueryResponseToDivinerQueryResponseDiviner"
259
+ });
260
+ var TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner = _TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner;
230
261
 
231
262
  // src/StateToIndexCandidateDiviner/Diviner.ts
232
263
  import { assertEx as assertEx2 } from "@xylabs/assert";
@@ -236,9 +267,7 @@ import { ArchivistWrapper } from "@xyo-network/archivist-wrapper";
236
267
  import { isBoundWitness as isBoundWitness2 } from "@xyo-network/boundwitness-model";
237
268
  import { BoundWitnessDivinerQuerySchema } from "@xyo-network/diviner-boundwitness-model";
238
269
  import { DivinerConfigSchema as DivinerConfigSchema5 } from "@xyo-network/diviner-model";
239
- import {
240
- TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema
241
- } from "@xyo-network/diviner-temporal-indexing-model";
270
+ import { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from "@xyo-network/diviner-temporal-indexing-model";
242
271
  import { DivinerWrapper } from "@xyo-network/diviner-wrapper";
243
272
  import { isModuleState, ModuleStateSchema } from "@xyo-network/module-model";
244
273
  import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder";
@@ -246,46 +275,75 @@ import { isPayloadOfSchemaType as isPayloadOfSchemaType2 } from "@xyo-network/pa
246
275
  import { TimestampSchema } from "@xyo-network/witness-timestamp";
247
276
  var order = "asc";
248
277
  var moduleName2 = "TemporalIndexingDivinerStateToIndexCandidateDiviner";
249
- var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends AbstractDiviner4 {
250
- static configSchema = TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema;
251
- static configSchemas = [DivinerConfigSchema5, TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema];
252
- static labels = {
253
- "network.xyo.diviner.stage": "stateToIndexCandidateDiviner"
254
- };
278
+ var _TemporalIndexingDivinerStateToIndexCandidateDiviner = class _TemporalIndexingDivinerStateToIndexCandidateDiviner extends AbstractDiviner4 {
255
279
  get payloadDivinerLimit() {
256
280
  return this.config.payloadDivinerLimit ?? 1e3;
257
281
  }
258
282
  /**
259
- * The required payload_schemas within BoundWitnesses to identify index candidates
260
- */
283
+ * The required payload_schemas within BoundWitnesses to identify index candidates
284
+ */
261
285
  get payload_schemas() {
262
286
  var _a;
263
287
  const schemas = (_a = this.config.filter) == null ? void 0 : _a.payload_schemas;
264
- return [TimestampSchema, ...schemas ?? []];
288
+ return [
289
+ TimestampSchema,
290
+ ...schemas ?? []
291
+ ];
265
292
  }
266
293
  async divineHandler(payloads = []) {
267
294
  const lastState = payloads.find(isModuleState);
268
295
  if (!lastState)
269
- return [{ schema: ModuleStateSchema, state: { offset: 0 } }];
296
+ return [
297
+ {
298
+ schema: ModuleStateSchema,
299
+ state: {
300
+ offset: 0
301
+ }
302
+ }
303
+ ];
270
304
  const { offset } = lastState.state;
271
305
  const boundWitnessDiviner = await this.getBoundWitnessDivinerForStore();
272
306
  if (!boundWitnessDiviner)
273
- return [lastState];
274
- const query = await new PayloadBuilder3({ schema: BoundWitnessDivinerQuerySchema }).fields({ limit: this.payloadDivinerLimit, offset, order, payload_schemas: this.payload_schemas }).build();
275
- const batch = await boundWitnessDiviner.divine([query]);
307
+ return [
308
+ lastState
309
+ ];
310
+ const query = await new PayloadBuilder3({
311
+ schema: BoundWitnessDivinerQuerySchema
312
+ }).fields({
313
+ limit: this.payloadDivinerLimit,
314
+ offset,
315
+ order,
316
+ payload_schemas: this.payload_schemas
317
+ }).build();
318
+ const batch = await boundWitnessDiviner.divine([
319
+ query
320
+ ]);
276
321
  if (batch.length === 0)
277
- return [lastState];
322
+ return [
323
+ lastState
324
+ ];
278
325
  const sourceArchivist = await this.getArchivistForStore();
279
326
  if (!sourceArchivist)
280
- return [lastState];
327
+ return [
328
+ lastState
329
+ ];
281
330
  const indexCandidates = (await Promise.all(batch.filter(isBoundWitness2).map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))).filter(exists2).flat();
282
- const nextState = { schema: ModuleStateSchema, state: { ...lastState.state, offset: offset + batch.length } };
283
- return [nextState, ...indexCandidates];
331
+ const nextState = {
332
+ schema: ModuleStateSchema,
333
+ state: {
334
+ ...lastState.state,
335
+ offset: offset + batch.length
336
+ }
337
+ };
338
+ return [
339
+ nextState,
340
+ ...indexCandidates
341
+ ];
284
342
  }
285
343
  /**
286
- * Retrieves the archivist for the payloadStore
287
- * @returns The archivist for the payloadStore or undefined if not resolvable
288
- */
344
+ * Retrieves the archivist for the payloadStore
345
+ * @returns The archivist for the payloadStore or undefined if not resolvable
346
+ */
289
347
  async getArchivistForStore() {
290
348
  var _a, _b;
291
349
  const name = assertEx2((_b = (_a = this.config) == null ? void 0 : _a.payloadStore) == null ? void 0 : _b.archivist, () => `${moduleName2}: Config for payloadStore.archivist not specified`);
@@ -295,15 +353,12 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends Abstract
295
353
  return ArchivistWrapper.wrap(mod, this.account);
296
354
  }
297
355
  /**
298
- * Retrieves the BoundWitness Diviner for the payloadStore
299
- * @returns The BoundWitness Diviner for the payloadStore or undefined if not resolvable
300
- */
356
+ * Retrieves the BoundWitness Diviner for the payloadStore
357
+ * @returns The BoundWitness Diviner for the payloadStore or undefined if not resolvable
358
+ */
301
359
  async getBoundWitnessDivinerForStore() {
302
360
  var _a, _b;
303
- const name = assertEx2(
304
- (_b = (_a = this.config) == null ? void 0 : _a.payloadStore) == null ? void 0 : _b.boundWitnessDiviner,
305
- () => `${moduleName2}: Config for payloadStore.boundWitnessDiviner not specified`
306
- );
361
+ const name = assertEx2((_b = (_a = this.config) == null ? void 0 : _a.payloadStore) == null ? void 0 : _b.boundWitnessDiviner, () => `${moduleName2}: Config for payloadStore.boundWitnessDiviner not specified`);
307
362
  const mod = await this.resolve(name);
308
363
  if (!mod)
309
364
  return void 0;
@@ -324,9 +379,22 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends Abstract
324
379
  if (filteredResults.includes(void 0))
325
380
  return void 0;
326
381
  const indexCandidates = filteredResults.filter(exists2);
327
- return [bw, ...indexCandidates];
382
+ return [
383
+ bw,
384
+ ...indexCandidates
385
+ ];
328
386
  }
329
387
  };
388
+ __name(_TemporalIndexingDivinerStateToIndexCandidateDiviner, "TemporalIndexingDivinerStateToIndexCandidateDiviner");
389
+ __publicField(_TemporalIndexingDivinerStateToIndexCandidateDiviner, "configSchema", TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema);
390
+ __publicField(_TemporalIndexingDivinerStateToIndexCandidateDiviner, "configSchemas", [
391
+ DivinerConfigSchema5,
392
+ TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema
393
+ ]);
394
+ __publicField(_TemporalIndexingDivinerStateToIndexCandidateDiviner, "labels", {
395
+ "network.xyo.diviner.stage": "stateToIndexCandidateDiviner"
396
+ });
397
+ var TemporalIndexingDivinerStateToIndexCandidateDiviner = _TemporalIndexingDivinerStateToIndexCandidateDiviner;
330
398
  export {
331
399
  TemporalIndexingDiviner,
332
400
  TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Diviner.ts","../../src/DivinerQueryToIndexQueryDiviner/Diviner.ts","../../src/IndexCandidateToIndexDiviner/Diviner.ts","../../src/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.ts","../../src/StateToIndexCandidateDiviner/Diviner.ts"],"sourcesContent":["import { IndexingDiviner } from '@xyo-network/diviner-indexing-memory'\nimport { IndexingDivinerConfigSchema } from '@xyo-network/diviner-indexing-model'\nimport { DivinerConfigSchema, DivinerModule, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { TemporalIndexingDivinerConfigSchema, TemporalIndexingDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport class TemporalIndexingDiviner<\n TParams extends TemporalIndexingDivinerParams = TemporalIndexingDivinerParams,\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 IndexingDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchema = TemporalIndexingDivinerConfigSchema\n static override readonly configSchemas: string[] = [TemporalIndexingDivinerConfigSchema, IndexingDivinerConfigSchema, DivinerConfigSchema]\n\n protected override async startHandler(): Promise<boolean> {\n await super.startHandler()\n return true\n }\n}\n","import { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport { DivinerConfigSchema } from '@xyo-network/diviner-model'\nimport { PayloadDivinerQueryPayload, PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n// TODO: Inherit from JsonPathAggregateDiviner\n/**\n * A diviner that converts diviner query to index query\n */\nexport class TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner<\n TParams extends TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchema = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema]\n static labels: Labels = {\n 'network.xyo.diviner.stage': 'divinerQueryToIndexQueryDiviner',\n }\n\n private _indexableSchemas: string[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * The schema of the diviner query payloads\n */\n protected get divinerQuerySchema(): string {\n return this.config.divinerQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index query payloads\n */\n protected get indexQuerySchema(): string {\n return this.config.indexQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index payloads\n */\n protected get indexSchema(): string {\n return this.config.indexSchema ?? TemporalIndexingDivinerResultIndexSchema\n }\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): string[] {\n if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms)\n return this._indexableSchemas\n }\n\n /**\n * Dictionary of schemas to payload transformers for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return (\n this.config?.schemaTransforms ?? {\n [this.divinerQuerySchema]: [\n {\n defaultValue: 1,\n destinationField: 'limit',\n sourcePathExpression: '$.limit',\n },\n {\n defaultValue: 0,\n destinationField: 'offset',\n sourcePathExpression: '$.offset',\n },\n {\n defaultValue: 'desc',\n destinationField: 'order',\n sourcePathExpression: '$.order',\n },\n ],\n }\n )\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n const queries = payloads.filter(isPayloadOfSchemaType<PayloadDivinerQueryPayload>(this.divinerQuerySchema))\n if (queries.length > 0) {\n const results = await Promise.all(\n queries.map(async (query) => {\n const fields = await reducePayloads<PayloadDivinerQueryPayload & { sources?: string[] }>(\n [query],\n this.payloadTransformers,\n this.indexQuerySchema,\n )\n // TODO: Make index schema configurable\n fields.schemas = [this.indexSchema]\n // TODO: Make sources not need to be deleted\n delete fields.sources\n // TODO: Add support for additional filters\n return await new PayloadBuilder<Payload>({ schema: this.indexQuerySchema }).fields(fields).build()\n }),\n )\n return results\n }\n return []\n }\n}\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport { DivinerConfigSchema } from '@xyo-network/diviner-model'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, PayloadFields } from '@xyo-network/payload-model'\n\nexport type IndexablePayloads = [BoundWitness, ...Payload[]]\n\nconst moduleName = 'TemporalIndexingDivinerIndexCandidateToIndexDiviner'\n\n/**\n * Diviner which transforms index candidates to indexes using JSON Path to map\n * source properties in the supplied payloads to destination fields in the\n * resultant index\n */\nexport class TemporalIndexingDivinerIndexCandidateToIndexDiviner<\n TParams extends TemporalIndexingDivinerIndexCandidateToIndexDivinerParams = TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override configSchema = TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema]\n static labels: Labels = {\n 'network.xyo.diviner.stage': 'indexCandidateToIndexDiviner',\n }\n\n private _indexableSchemas: string[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): string[] {\n if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms)\n return this._indexableSchemas\n }\n\n /**\n * Dictionary of schemas to payload transformers for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return assertEx(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`)\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n const bws: BoundWitness[] = payloads.filter(isBoundWitness)\n const indexablePayloads: Payload[] = payloads.filter((p) => this.isIndexablePayload(p))\n if (bws.length > 0 && indexablePayloads.length > 0) {\n const payloadDictionary = await PayloadHasher.toMap(payloads)\n // eslint-disable-next-line unicorn/no-array-reduce\n const validIndexableTuples: IndexablePayloads[] = bws.reduce<IndexablePayloads[]>((indexableTuples, bw) => {\n // If this Bound Witness doesn't contain all the required schemas don't index it\n if (!containsAll(bw.payload_schemas, this.indexableSchemas)) return indexableTuples\n // Find the remaining indexable payloads\n const indexablePayloadPositions = this.indexableSchemas.map((schema) => bw.payload_schemas.indexOf(schema))\n const indexablePayloadHashes = indexablePayloadPositions.map((index) => bw.payload_hashes?.[index])\n const indexablePayloads = indexablePayloadHashes.map((hash) => payloadDictionary[hash]).filter(exists)\n // If we found a timestamp and the right amount of indexable payloads (of the\n // correct schema as checked above) in this BW, then index it\n if (indexablePayloads.length === this.indexableSchemas.length) indexableTuples.push([bw, ...indexablePayloads])\n return indexableTuples\n }, [])\n // Create the indexes from the tuples\n const indexes = await Promise.all(\n validIndexableTuples.map<Promise<TemporalIndexingDivinerResultIndex>>(async ([bw, ...sourcePayloads]) => {\n // Use the payload transformers to convert the fields from the source payloads to the destination fields\n const indexFields = sourcePayloads.flatMap<PayloadFields[]>((payload) => {\n // Find the transformers for this payload\n const transformers = this.payloadTransformers[payload.schema]\n // If transformers exist, apply them to the payload otherwise return an empty array\n return transformers ? transformers.map((transform) => transform(payload)) : []\n })\n // Include all the sources for reference\n const sources = Object.keys(await PayloadHasher.toMap([bw, ...sourcePayloads]))\n // Build and return the index\n return await new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })\n .fields(Object.assign({ sources }, ...indexFields))\n .build()\n }),\n )\n return indexes.flat()\n }\n return []\n }\n\n /**\n * Identifies if a payload is one that is indexed by this diviner\n * @param x The candidate payload\n * @returns True if the payload is one indexed by this diviner, false otherwise\n */\n protected isIndexablePayload = (x: Payload) => {\n return this.indexableSchemas.includes(x?.schema)\n }\n\n /**\n * Identifies if a schema is one that is indexed by this diviner\n * @param schema The candidate schema\n * @returns True if this schema is one indexed by this diviner, false otherwise\n */\n protected isIndexableSchema = (schema?: string | null) => {\n return typeof schema === 'string' ? this.indexableSchemas.includes(schema) : false\n }\n}\n","import { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { DivinerConfigSchema } from '@xyo-network/diviner-model'\nimport { isPayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'\nimport { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport { Labels } from '@xyo-network/module-model'\nimport { Payload } from '@xyo-network/payload-model'\n\n/**\n * Transforms an ImageThumbnailIndex response into an ImageThumbnailResponse response\n */\nexport class TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner extends AbstractDiviner {\n static override readonly configSchema = TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema]\n static labels: Labels = {\n 'network.xyo.diviner.stage': 'indexQueryResponseToDivinerQueryResponseDiviner',\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // NOTE: We're not doing anything with the query payloads but some diviners\n // might want to use this to transform from the query to the response (for example\n // if we use a plaintext value in the query to generate a hash key in the index)\n // const queries = payloads.filter(isPayloadDivinerQueryPayload)\n const responses = payloads.filter((p) => !isPayloadDivinerQueryPayload(p))\n return await Promise.resolve(responses)\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'\nimport { DivinerConfigSchema } from '@xyo-network/diviner-model'\nimport {\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema,\n TemporalIndexingDivinerStateToIndexCandidateDivinerParams,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport { isModuleState, Labels, ModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\nimport { TimeStamp, TimestampSchema } from '@xyo-network/witness-timestamp'\n\n/**\n * All Payload types involved in index candidates for indexing\n */\nexport type IndexCandidate = BoundWitness | Payload | TimeStamp\n\n/**\n * The response from the TemporalStateToIndexCandidateDiviner\n */\nexport type TemporalStateToIndexCandidateDivinerResponse = [\n /**\n * The next state of the diviner\n */\n nextState: ModuleState<IndexingDivinerState>,\n /**\n * The index candidates\n */\n ...IndexCandidate[],\n]\n\n/**\n * The default order to search Bound Witnesses to identify index candidates\n */\nconst order = 'asc'\n\n/**\n * The name of the module (for logging purposes)\n */\nconst moduleName = 'TemporalIndexingDivinerStateToIndexCandidateDiviner'\n\n/**\n * Transforms candidates for image thumbnail indexing into their indexed representation\n */\nexport class TemporalIndexingDivinerStateToIndexCandidateDiviner<\n TParams extends TemporalIndexingDivinerStateToIndexCandidateDivinerParams = TemporalIndexingDivinerStateToIndexCandidateDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchema = TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema]\n static labels: Labels = {\n 'network.xyo.diviner.stage': 'stateToIndexCandidateDiviner',\n }\n\n get payloadDivinerLimit() {\n return this.config.payloadDivinerLimit ?? 1000\n }\n\n /**\n * The required payload_schemas within BoundWitnesses to identify index candidates\n */\n protected get payload_schemas(): string[] {\n const schemas = this.config.filter?.payload_schemas\n return [TimestampSchema, ...(schemas ?? [])]\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<[ModuleState, ...IndexCandidate[]]> {\n // Retrieve the last state from what was passed in\n const lastState = payloads.find(isModuleState<IndexingDivinerState>)\n // If there is no last state, start from the beginning\n if (!lastState) return [{ schema: ModuleStateSchema, state: { offset: 0 } }]\n // Otherwise, get the last offset\n const { offset } = lastState.state\n // Get next batch of results starting from the offset\n const boundWitnessDiviner = await this.getBoundWitnessDivinerForStore()\n if (!boundWitnessDiviner) return [lastState]\n const query = await new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({ limit: this.payloadDivinerLimit, offset, order, payload_schemas: this.payload_schemas })\n .build()\n const batch = await boundWitnessDiviner.divine([query])\n if (batch.length === 0) return [lastState]\n // Get source data\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n const indexCandidates: IndexCandidate[] = (\n await Promise.all(batch.filter(isBoundWitness).map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))\n )\n .filter(exists)\n .flat()\n const nextState = { schema: ModuleStateSchema, state: { ...lastState.state, offset: offset + batch.length } }\n return [nextState, ...indexCandidates]\n }\n /**\n * Retrieves the archivist for the payloadStore\n * @returns The archivist for the payloadStore or undefined if not resolvable\n */\n protected async getArchivistForStore(): Promise<ArchivistWrapper | undefined> {\n // It should be defined, so we'll error if it's not\n const name: string = assertEx(this.config?.payloadStore?.archivist, () => `${moduleName}: Config for payloadStore.archivist not specified`)\n // It might not be resolvable (yet), so we'll return undefined if it's not\n const mod = await this.resolve(name)\n if (!mod) return undefined\n // Return the wrapped archivist\n return ArchivistWrapper.wrap(mod, this.account)\n }\n\n /**\n * Retrieves the BoundWitness Diviner for the payloadStore\n * @returns The BoundWitness Diviner for the payloadStore or undefined if not resolvable\n */\n protected async getBoundWitnessDivinerForStore(): Promise<DivinerWrapper | undefined> {\n // It should be defined, so we'll error if it's not\n const name: string = assertEx(\n this.config?.payloadStore?.boundWitnessDiviner,\n () => `${moduleName}: Config for payloadStore.boundWitnessDiviner not specified`,\n )\n // It might not be resolvable (yet), so we'll return undefined if it's not\n const mod = await this.resolve(name)\n if (!mod) return undefined\n // Return the wrapped diviner\n return DivinerWrapper.wrap(mod, this.account)\n }\n\n protected async getPayloadsInBoundWitness(bw: BoundWitness, archivist: ArchivistInstance): Promise<IndexCandidate[] | undefined> {\n const indexes = this.payload_schemas.map((schema) => bw.payload_schemas?.findIndex((s) => s === schema))\n const hashes = indexes.map((index) => bw.payload_hashes?.[index])\n const results = await archivist.get(hashes)\n const indexCandidateIdentityFunctions = this.payload_schemas.map(isPayloadOfSchemaType)\n const filteredResults = indexCandidateIdentityFunctions.map((is) => results.find(is))\n if (filteredResults.includes(undefined)) return undefined\n const indexCandidates: IndexCandidate[] = filteredResults.filter(exists) as IndexCandidate[]\n return [bw, ...indexCandidates]\n }\n}\n"],"mappings":";AAAA,SAAS,uBAAuB;AAChC,SAAS,mCAAmC;AAC5C,SAAS,2BAAkE;AAC3E,SAAS,2CAA0E;AAG5E,IAAM,0BAAN,cAKG,gBAAgD;AAAA,EACxD,OAAyB,eAAe;AAAA,EACxC,OAAyB,gBAA0B,CAAC,qCAAqC,6BAA6B,mBAAmB;AAAA,EAEzI,MAAyB,eAAiC;AACxD,UAAM,MAAM,aAAa;AACzB,WAAO;AAAA,EACT;AACF;;;ACnBA,SAAS,uBAAuB;AAChC,SAAS,kCAAkC,sBAAsB;AAEjE,SAAS,uBAAAA,4BAA2B;AACpC,SAAqC,iCAAiC;AACtE;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AAEP,SAAS,sBAAsB;AAC/B,S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C1C,UAAM,kCAAkC,KAAK,gBAAgB,IAAID,sBAAqB;AACtF,UAAM,kBAAkB,gCAAgC,IAAI,CAAC,OAAO,QAAQ,KAAK,EAAE,CAAC;AACpF,QAAI,gBAAgB,SAAS,MAAS;AAAG,aAAO;AAChD,UAAM,kBAAoC,gBAAgB,OAAOL,OAAM;AACvE,WAAO,CAAC,IAAI,GAAG,eAAe;AAAA,EAChC;AACF;","names":["DivinerConfigSchema","AbstractDiviner","jsonPathToTransformersDictionary","DivinerConfigSchema","TemporalIndexingDivinerResultIndexSchema","PayloadBuilder","indexablePayloads","AbstractDiviner","DivinerConfigSchema","assertEx","exists","AbstractDiviner","isBoundWitness","DivinerConfigSchema","PayloadBuilder","isPayloadOfSchemaType","moduleName"]}
1
+ {"version":3,"sources":["../../src/Diviner.ts","../../src/DivinerQueryToIndexQueryDiviner/Diviner.ts","../../src/IndexCandidateToIndexDiviner/Diviner.ts","../../src/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.ts","../../src/StateToIndexCandidateDiviner/Diviner.ts"],"sourcesContent":["import { IndexingDiviner } from '@xyo-network/diviner-indexing-memory'\nimport { IndexingDivinerConfigSchema } from '@xyo-network/diviner-indexing-model'\nimport { DivinerConfigSchema, DivinerModule, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { TemporalIndexingDivinerConfigSchema, TemporalIndexingDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { Payload } from '@xyo-network/payload-model'\n\nexport class TemporalIndexingDiviner<\n TParams extends TemporalIndexingDivinerParams = TemporalIndexingDivinerParams,\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 IndexingDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchema = TemporalIndexingDivinerConfigSchema\n static override readonly configSchemas: string[] = [TemporalIndexingDivinerConfigSchema, IndexingDivinerConfigSchema, DivinerConfigSchema]\n\n protected override async startHandler(): Promise<boolean> {\n await super.startHandler()\n return true\n }\n}\n","import { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport { DivinerConfigSchema } from '@xyo-network/diviner-model'\nimport { PayloadDivinerQueryPayload, PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\n// TODO: Inherit from JsonPathAggregateDiviner\n/**\n * A diviner that converts diviner query to index query\n */\nexport class TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner<\n TParams extends TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchema = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema]\n static labels: Labels = {\n 'network.xyo.diviner.stage': 'divinerQueryToIndexQueryDiviner',\n }\n\n private _indexableSchemas: string[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * The schema of the diviner query payloads\n */\n protected get divinerQuerySchema(): string {\n return this.config.divinerQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index query payloads\n */\n protected get indexQuerySchema(): string {\n return this.config.indexQuerySchema ?? PayloadDivinerQuerySchema\n }\n\n /**\n * The schema of the index payloads\n */\n protected get indexSchema(): string {\n return this.config.indexSchema ?? TemporalIndexingDivinerResultIndexSchema\n }\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): string[] {\n if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms)\n return this._indexableSchemas\n }\n\n /**\n * Dictionary of schemas to payload transformers for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return (\n this.config?.schemaTransforms ?? {\n [this.divinerQuerySchema]: [\n {\n defaultValue: 1,\n destinationField: 'limit',\n sourcePathExpression: '$.limit',\n },\n {\n defaultValue: 0,\n destinationField: 'offset',\n sourcePathExpression: '$.offset',\n },\n {\n defaultValue: 'desc',\n destinationField: 'order',\n sourcePathExpression: '$.order',\n },\n ],\n }\n )\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n const queries = payloads.filter(isPayloadOfSchemaType<PayloadDivinerQueryPayload>(this.divinerQuerySchema))\n if (queries.length > 0) {\n const results = await Promise.all(\n queries.map(async (query) => {\n const fields = await reducePayloads<PayloadDivinerQueryPayload & { sources?: string[] }>(\n [query],\n this.payloadTransformers,\n this.indexQuerySchema,\n )\n // TODO: Make index schema configurable\n fields.schemas = [this.indexSchema]\n // TODO: Make sources not need to be deleted\n delete fields.sources\n // TODO: Add support for additional filters\n return await new PayloadBuilder<Payload>({ schema: this.indexQuerySchema }).fields(fields).build()\n }),\n )\n return results\n }\n return []\n }\n}\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport { DivinerConfigSchema } from '@xyo-network/diviner-model'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { PayloadHasher } from '@xyo-network/hash'\nimport { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, PayloadFields } from '@xyo-network/payload-model'\n\nexport type IndexablePayloads = [BoundWitness, ...Payload[]]\n\nconst moduleName = 'TemporalIndexingDivinerIndexCandidateToIndexDiviner'\n\n/**\n * Diviner which transforms index candidates to indexes using JSON Path to map\n * source properties in the supplied payloads to destination fields in the\n * resultant index\n */\nexport class TemporalIndexingDivinerIndexCandidateToIndexDiviner<\n TParams extends TemporalIndexingDivinerIndexCandidateToIndexDivinerParams = TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override configSchema = TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema]\n static labels: Labels = {\n 'network.xyo.diviner.stage': 'indexCandidateToIndexDiviner',\n }\n\n private _indexableSchemas: string[] | undefined\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n\n /**\n * List of indexable schemas for this diviner\n */\n protected get indexableSchemas(): string[] {\n if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms)\n return this._indexableSchemas\n }\n\n /**\n * Dictionary of schemas to payload transformers for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions for creating indexes\n * from the payloads within a Bound Witness\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return assertEx(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`)\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n const bws: BoundWitness[] = payloads.filter(isBoundWitness)\n const indexablePayloads: Payload[] = payloads.filter((p) => this.isIndexablePayload(p))\n if (bws.length > 0 && indexablePayloads.length > 0) {\n const payloadDictionary = await PayloadHasher.toMap(payloads)\n // eslint-disable-next-line unicorn/no-array-reduce\n const validIndexableTuples: IndexablePayloads[] = bws.reduce<IndexablePayloads[]>((indexableTuples, bw) => {\n // If this Bound Witness doesn't contain all the required schemas don't index it\n if (!containsAll(bw.payload_schemas, this.indexableSchemas)) return indexableTuples\n // Find the remaining indexable payloads\n const indexablePayloadPositions = this.indexableSchemas.map((schema) => bw.payload_schemas.indexOf(schema))\n const indexablePayloadHashes = indexablePayloadPositions.map((index) => bw.payload_hashes?.[index])\n const indexablePayloads = indexablePayloadHashes.map((hash) => payloadDictionary[hash]).filter(exists)\n // If we found a timestamp and the right amount of indexable payloads (of the\n // correct schema as checked above) in this BW, then index it\n if (indexablePayloads.length === this.indexableSchemas.length) indexableTuples.push([bw, ...indexablePayloads])\n return indexableTuples\n }, [])\n // Create the indexes from the tuples\n const indexes = await Promise.all(\n validIndexableTuples.map<Promise<TemporalIndexingDivinerResultIndex>>(async ([bw, ...sourcePayloads]) => {\n // Use the payload transformers to convert the fields from the source payloads to the destination fields\n const indexFields = sourcePayloads.flatMap<PayloadFields[]>((payload) => {\n // Find the transformers for this payload\n const transformers = this.payloadTransformers[payload.schema]\n // If transformers exist, apply them to the payload otherwise return an empty array\n return transformers ? transformers.map((transform) => transform(payload)) : []\n })\n // Include all the sources for reference\n const sources = Object.keys(await PayloadHasher.toMap([bw, ...sourcePayloads]))\n // Build and return the index\n return await new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })\n .fields(Object.assign({ sources }, ...indexFields))\n .build()\n }),\n )\n return indexes.flat()\n }\n return []\n }\n\n /**\n * Identifies if a payload is one that is indexed by this diviner\n * @param x The candidate payload\n * @returns True if the payload is one indexed by this diviner, false otherwise\n */\n protected isIndexablePayload = (x: Payload) => {\n return this.indexableSchemas.includes(x?.schema)\n }\n\n /**\n * Identifies if a schema is one that is indexed by this diviner\n * @param schema The candidate schema\n * @returns True if this schema is one indexed by this diviner, false otherwise\n */\n protected isIndexableSchema = (schema?: string | null) => {\n return typeof schema === 'string' ? this.indexableSchemas.includes(schema) : false\n }\n}\n","import { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { DivinerConfigSchema } from '@xyo-network/diviner-model'\nimport { isPayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'\nimport { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport { Labels } from '@xyo-network/module-model'\nimport { Payload } from '@xyo-network/payload-model'\n\n/**\n * Transforms an ImageThumbnailIndex response into an ImageThumbnailResponse response\n */\nexport class TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner extends AbstractDiviner {\n static override readonly configSchema = TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema]\n static labels: Labels = {\n 'network.xyo.diviner.stage': 'indexQueryResponseToDivinerQueryResponseDiviner',\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {\n // NOTE: We're not doing anything with the query payloads but some diviners\n // might want to use this to transform from the query to the response (for example\n // if we use a plaintext value in the query to generate a hash key in the index)\n // const queries = payloads.filter(isPayloadDivinerQueryPayload)\n const responses = payloads.filter((p) => !isPayloadDivinerQueryPayload(p))\n return await Promise.resolve(responses)\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { AbstractDiviner } from '@xyo-network/abstract-diviner'\nimport { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'\nimport { DivinerConfigSchema } from '@xyo-network/diviner-model'\nimport {\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema,\n TemporalIndexingDivinerStateToIndexCandidateDivinerParams,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport { isModuleState, Labels, ModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'\nimport { TimeStamp, TimestampSchema } from '@xyo-network/witness-timestamp'\n\n/**\n * All Payload types involved in index candidates for indexing\n */\nexport type IndexCandidate = BoundWitness | Payload | TimeStamp\n\n/**\n * The response from the TemporalStateToIndexCandidateDiviner\n */\nexport type TemporalStateToIndexCandidateDivinerResponse = [\n /**\n * The next state of the diviner\n */\n nextState: ModuleState<IndexingDivinerState>,\n /**\n * The index candidates\n */\n ...IndexCandidate[],\n]\n\n/**\n * The default order to search Bound Witnesses to identify index candidates\n */\nconst order = 'asc'\n\n/**\n * The name of the module (for logging purposes)\n */\nconst moduleName = 'TemporalIndexingDivinerStateToIndexCandidateDiviner'\n\n/**\n * Transforms candidates for image thumbnail indexing into their indexed representation\n */\nexport class TemporalIndexingDivinerStateToIndexCandidateDiviner<\n TParams extends TemporalIndexingDivinerStateToIndexCandidateDivinerParams = TemporalIndexingDivinerStateToIndexCandidateDivinerParams,\n> extends AbstractDiviner<TParams> {\n static override readonly configSchema = TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema]\n static labels: Labels = {\n 'network.xyo.diviner.stage': 'stateToIndexCandidateDiviner',\n }\n\n get payloadDivinerLimit() {\n return this.config.payloadDivinerLimit ?? 1000\n }\n\n /**\n * The required payload_schemas within BoundWitnesses to identify index candidates\n */\n protected get payload_schemas(): string[] {\n const schemas = this.config.filter?.payload_schemas\n return [TimestampSchema, ...(schemas ?? [])]\n }\n\n protected override async divineHandler(payloads: Payload[] = []): Promise<[ModuleState, ...IndexCandidate[]]> {\n // Retrieve the last state from what was passed in\n const lastState = payloads.find(isModuleState<IndexingDivinerState>)\n // If there is no last state, start from the beginning\n if (!lastState) return [{ schema: ModuleStateSchema, state: { offset: 0 } }]\n // Otherwise, get the last offset\n const { offset } = lastState.state\n // Get next batch of results starting from the offset\n const boundWitnessDiviner = await this.getBoundWitnessDivinerForStore()\n if (!boundWitnessDiviner) return [lastState]\n const query = await new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })\n .fields({ limit: this.payloadDivinerLimit, offset, order, payload_schemas: this.payload_schemas })\n .build()\n const batch = await boundWitnessDiviner.divine([query])\n if (batch.length === 0) return [lastState]\n // Get source data\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n const indexCandidates: IndexCandidate[] = (\n await Promise.all(batch.filter(isBoundWitness).map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))\n )\n .filter(exists)\n .flat()\n const nextState = { schema: ModuleStateSchema, state: { ...lastState.state, offset: offset + batch.length } }\n return [nextState, ...indexCandidates]\n }\n /**\n * Retrieves the archivist for the payloadStore\n * @returns The archivist for the payloadStore or undefined if not resolvable\n */\n protected async getArchivistForStore(): Promise<ArchivistWrapper | undefined> {\n // It should be defined, so we'll error if it's not\n const name: string = assertEx(this.config?.payloadStore?.archivist, () => `${moduleName}: Config for payloadStore.archivist not specified`)\n // It might not be resolvable (yet), so we'll return undefined if it's not\n const mod = await this.resolve(name)\n if (!mod) return undefined\n // Return the wrapped archivist\n return ArchivistWrapper.wrap(mod, this.account)\n }\n\n /**\n * Retrieves the BoundWitness Diviner for the payloadStore\n * @returns The BoundWitness Diviner for the payloadStore or undefined if not resolvable\n */\n protected async getBoundWitnessDivinerForStore(): Promise<DivinerWrapper | undefined> {\n // It should be defined, so we'll error if it's not\n const name: string = assertEx(\n this.config?.payloadStore?.boundWitnessDiviner,\n () => `${moduleName}: Config for payloadStore.boundWitnessDiviner not specified`,\n )\n // It might not be resolvable (yet), so we'll return undefined if it's not\n const mod = await this.resolve(name)\n if (!mod) return undefined\n // Return the wrapped diviner\n return DivinerWrapper.wrap(mod, this.account)\n }\n\n protected async getPayloadsInBoundWitness(bw: BoundWitness, archivist: ArchivistInstance): Promise<IndexCandidate[] | undefined> {\n const indexes = this.payload_schemas.map((schema) => bw.payload_schemas?.findIndex((s) => s === schema))\n const hashes = indexes.map((index) => bw.payload_hashes?.[index])\n const results = await archivist.get(hashes)\n const indexCandidateIdentityFunctions = this.payload_schemas.map(isPayloadOfSchemaType)\n const filteredResults = indexCandidateIdentityFunctions.map((is) => results.find(is))\n if (filteredResults.includes(undefined)) return undefined\n const indexCandidates: IndexCandidate[] = filteredResults.filter(exists) as IndexCandidate[]\n return [bw, ...indexCandidates]\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAASA,uBAAuB;AAChC,SAASC,mCAAmC;AAC5C,SAASC,2BAAkE;AAC3E,SAASC,2CAA0E;AAG5E,IAAMC,2BAAN,MAAMA,iCAKHC,gBAAAA;EAIR,M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B,IAAI0B,sBAAAA;AACjE,UAAMC,kBAAkBF,gCAAgCzB,IAAI,CAAC4B,OAAOL,QAAQ9C,KAAKmD,EAAAA,CAAAA;AACjF,QAAID,gBAAgBE,SAASjB,MAAAA;AAAY,aAAOA;AAChD,UAAMhB,kBAAoC+B,gBAAgBvD,OAAO+B,OAAAA;AACjE,WAAO;MAACF;SAAOL;;EACjB;AACF;AAtFU7B;AACR,cAHWD,sDAGcgE,gBAAeC;AACxC,cAJWjE,sDAIKkE,iBAAgB;EAACC;EAAqBF;;AACtD,cALWjE,sDAKJoE,UAAiB;EACtB,6BAA6B;AAC/B;AAPK,IAAMpE,sDAAN;","names":["IndexingDiviner","IndexingDivinerConfigSchema","DivinerConfigSchema","TemporalIndexingDivinerConfigSchema","TemporalIndexingDiviner","IndexingDiviner","startHandler","configSchema","TemporalIndexingDivinerConfigSchema","configSchemas","IndexingDivinerConfigSchema","DivinerConfigSchema","AbstractDiviner","jsonPathToTransformersDictionary","reducePayloads","DivinerConfigSchema","PayloadDivinerQuerySchema","TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema","TemporalIndexingDivinerResultIndexSchema","PayloadBuilder","isPayloadOfSchemaType","TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner","AbstractDiviner","_indexableSchemas","_payloadTransformers","divinerQuerySchema","config","PayloadDivinerQuerySchema","indexQuerySchema","indexSchema","TemporalIndexingDivinerResultIndexSchema","indexableSchemas","Object","keys","schemaTransforms","payloadTransformers","jsonPathToTransformersDictionary","defaultValue","destinationField","sourcePathExpression","divineHandler","payloads","queries","filter","isPayloadOfSchemaType","length","results","Promise","all","map","query","fields","reducePayloads","schemas","sources","PayloadBuilder","schema","build","configSchema","TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema","configSchemas","DivinerConfigSchema","labels","containsAll","assertEx","exists","AbstractDiviner","isBoundWitness","jsonPathToTransformersDictionary","DivinerConfigSchema","TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema","TemporalIndexingDivinerResultIndexSchema","PayloadHasher","PayloadBuilder","moduleName","TemporalIndexingDivinerIndexCandidateToIndexDiviner","AbstractDiviner","_indexableSchemas","_payloadTransformers","indexableSchemas","Object","keys","schemaTransforms","payloadTransformers","jsonPathToTransformersDictionary","assertEx","config","divineHandler","payloads","bws","filter","isBoundWitness","indexablePayloads","p","isIndexablePayload","length","payloadDictionary","PayloadHasher","toMap","validIndexableTuples","reduce","indexableTuples","bw","containsAll","payload_schemas","indexablePayloadPositions","map","schema","indexOf","indexablePayloadHashes","index","payload_hashes","hash","exists","push","indexes","Promise","all","sourcePayloads","indexFields","flatMap","payload","transformers","transform","sources","PayloadBuilder","TemporalIndexingDivinerResultIndexSchema","fields","assign","build","flat","x","includes","isIndexableSchema","configSchema","TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema","configSchemas","DivinerConfigSchema","labels","AbstractDiviner","DivinerConfigSchema","isPayloadDivinerQueryPayload","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","AbstractDiviner","divineHandler","payloads","responses","filter","p","isPayloadDivinerQueryPayload","Promise","resolve","configSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","configSchemas","DivinerConfigSchema","labels","assertEx","exists","AbstractDiviner","ArchivistWrapper","isBoundWitness","BoundWitnessDivinerQuerySchema","DivinerConfigSchema","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","DivinerWrapper","isModuleState","ModuleStateSchema","PayloadBuilder","isPayloadOfSchemaType","TimestampSchema","order","moduleName","TemporalIndexingDivinerStateToIndexCandidateDiviner","AbstractDiviner","payloadDivinerLimit","config","payload_schemas","schemas","filter","TimestampSchema","divineHandler","payloads","lastState","find","isModuleState","schema","ModuleStateSchema","state","offset","boundWitnessDiviner","getBoundWitnessDivinerForStore","query","PayloadBuilder","BoundWitnessDivinerQuerySchema","fields","limit","build","batch","divine","length","sourceArchivist","getArchivistForStore","indexCandidates","Promise","all","isBoundWitness","map","bw","getPayloadsInBoundWitness","exists","flat","nextState","name","assertEx","payloadStore","archivist","mod","resolve","undefined","ArchivistWrapper","wrap","account","DivinerWrapper","indexes","findIndex","s","hashes","index","payload_hashes","results","get","indexCandidateIdentityFunctions","isPayloadOfSchemaType","filteredResults","is","includes","configSchema","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","configSchemas","DivinerConfigSchema","labels"]}