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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../../src/IndexCandidateToIndexDiviner/Diviner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAkB,MAAM,iCAAiC,CAAA;AAE9E,OAAO,EAAE,8CAA8C,EAAE,qCAAqC,EAAE,MAAM,qCAAqC,CAAA;AAE3I,OAAO,EAEL,yDAAyD,EAG1D,MAAM,8CAA8C,CAAA;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAElD,OAAO,EAAE,OAAO,EAAiB,MAAM,4BAA4B,CAAA;AAEnE,MAAM,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;AAI5D;;;;GAIG;AACH,qBAAa,mDAAmD,CAC9D,OAAO,SAAS,yDAAyD,GAAG,yDAAyD,CACrI,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,OAAgB,YAAY,oFAAkE;IAC9F,OAAgB,aAAa,WAAyF;IACtH,MAAM,CAAC,MAAM,EAAE,MAAM,CAEpB;IAED,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,oBAAoB,CAAmD;IAE/E;;OAEG;IACH,SAAS,KAAK,gBAAgB,IAAI,MAAM,EAAE,CAGzC;IAED;;;OAGG;IACH,SAAS,KAAK,mBAAmB,IAAI,qCAAqC,CAGzE;IAED;;;OAGG;IACH,SAAS,KAAK,gBAAgB,IAAI,8CAA8C,CAE/E;cAEwB,aAAa,CAAC,QAAQ,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAyCpF;;;;OAIG;IACH,SAAS,CAAC,kBA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= Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -34,8 +35,15 @@ var import_diviner_indexing_model = require("@xyo-network/diviner-indexing-model
34
35
  var import_diviner_model = require("@xyo-network/diviner-model");
35
36
  var import_diviner_temporal_indexing_model = require("@xyo-network/diviner-temporal-indexing-model");
36
37
  var TemporalIndexingDiviner = class extends import_diviner_indexing_memory.IndexingDiviner {
38
+ static {
39
+ __name(this, "TemporalIndexingDiviner");
40
+ }
37
41
  static configSchema = import_diviner_temporal_indexing_model.TemporalIndexingDivinerConfigSchema;
38
- static configSchemas = [import_diviner_temporal_indexing_model.TemporalIndexingDivinerConfigSchema, import_diviner_indexing_model.IndexingDivinerConfigSchema, import_diviner_model.DivinerConfigSchema];
42
+ static configSchemas = [
43
+ import_diviner_temporal_indexing_model.TemporalIndexingDivinerConfigSchema,
44
+ import_diviner_indexing_model.IndexingDivinerConfigSchema,
45
+ import_diviner_model.DivinerConfigSchema
46
+ ];
39
47
  async startHandler() {
40
48
  await super.startHandler();
41
49
  return true;
@@ -51,52 +59,58 @@ var import_diviner_temporal_indexing_model2 = require("@xyo-network/diviner-temp
51
59
  var import_payload_builder = require("@xyo-network/payload-builder");
52
60
  var import_payload_model = require("@xyo-network/payload-model");
53
61
  var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class extends import_abstract_diviner.AbstractDiviner {
62
+ static {
63
+ __name(this, "TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner");
64
+ }
54
65
  static configSchema = import_diviner_temporal_indexing_model2.TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema;
55
- static configSchemas = [import_diviner_model2.DivinerConfigSchema, import_diviner_temporal_indexing_model2.TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema];
66
+ static configSchemas = [
67
+ import_diviner_model2.DivinerConfigSchema,
68
+ import_diviner_temporal_indexing_model2.TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema
69
+ ];
56
70
  static labels = {
57
71
  "network.xyo.diviner.stage": "divinerQueryToIndexQueryDiviner"
58
72
  };
59
73
  _indexableSchemas;
60
74
  _payloadTransformers;
61
75
  /**
62
- * The schema of the diviner query payloads
63
- */
76
+ * The schema of the diviner query payloads
77
+ */
64
78
  get divinerQuerySchema() {
65
79
  return this.config.divinerQuerySchema ?? import_diviner_payload_model.PayloadDivinerQuerySchema;
66
80
  }
67
81
  /**
68
- * The schema of the index query payloads
69
- */
82
+ * The schema of the index query payloads
83
+ */
70
84
  get indexQuerySchema() {
71
85
  return this.config.indexQuerySchema ?? import_diviner_payload_model.PayloadDivinerQuerySchema;
72
86
  }
73
87
  /**
74
- * The schema of the index payloads
75
- */
88
+ * The schema of the index payloads
89
+ */
76
90
  get indexSchema() {
77
91
  return this.config.indexSchema ?? import_diviner_temporal_indexing_model2.TemporalIndexingDivinerResultIndexSchema;
78
92
  }
79
93
  /**
80
- * List of indexable schemas for this diviner
81
- */
94
+ * List of indexable schemas for this diviner
95
+ */
82
96
  get indexableSchemas() {
83
97
  if (!this._indexableSchemas)
84
98
  this._indexableSchemas = Object.keys(this.schemaTransforms);
85
99
  return this._indexableSchemas;
86
100
  }
87
101
  /**
88
- * Dictionary of schemas to payload transformers for creating indexes
89
- * from the payloads within a Bound Witness
90
- */
102
+ * Dictionary of schemas to payload transformers for creating indexes
103
+ * from the payloads within a Bound Witness
104
+ */
91
105
  get payloadTransformers() {
92
106
  if (!this._payloadTransformers)
93
107
  this._payloadTransformers = (0, import_diviner_jsonpath_aggregate_memory.jsonPathToTransformersDictionary)(this.schemaTransforms);
94
108
  return this._payloadTransformers;
95
109
  }
96
110
  /**
97
- * The dictionary of schemas to JSON Path transform expressions for creating indexes
98
- * from the payloads within a Bound Witness
99
- */
111
+ * The dictionary of schemas to JSON Path transform expressions for creating indexes
112
+ * from the payloads within a Bound Witness
113
+ */
100
114
  get schemaTransforms() {
101
115
  return this.config?.schemaTransforms ?? {
102
116
  [this.divinerQuerySchema]: [
@@ -121,18 +135,18 @@ var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class extends impor
121
135
  async divineHandler(payloads = []) {
122
136
  const queries = payloads.filter((0, import_payload_model.isPayloadOfSchemaType)(this.divinerQuerySchema));
123
137
  if (queries.length > 0) {
124
- const results = await Promise.all(
125
- queries.map(async (query) => {
126
- const fields = await (0, import_diviner_jsonpath_aggregate_memory.reducePayloads)(
127
- [query],
128
- this.payloadTransformers,
129
- this.indexQuerySchema
130
- );
131
- fields.schemas = [this.indexSchema];
132
- delete fields.sources;
133
- return await new import_payload_builder.PayloadBuilder({ schema: this.indexQuerySchema }).fields(fields).build();
134
- })
135
- );
138
+ const results = await Promise.all(queries.map(async (query) => {
139
+ const fields = await (0, import_diviner_jsonpath_aggregate_memory.reducePayloads)([
140
+ query
141
+ ], this.payloadTransformers, this.indexQuerySchema);
142
+ fields.schemas = [
143
+ this.indexSchema
144
+ ];
145
+ delete fields.sources;
146
+ return await new import_payload_builder.PayloadBuilder({
147
+ schema: this.indexQuerySchema
148
+ }).fields(fields).build();
149
+ }));
136
150
  return results;
137
151
  }
138
152
  return [];
@@ -150,36 +164,43 @@ var import_diviner_model3 = require("@xyo-network/diviner-model");
150
164
  var import_diviner_temporal_indexing_model3 = require("@xyo-network/diviner-temporal-indexing-model");
151
165
  var import_hash = require("@xyo-network/hash");
152
166
  var import_payload_builder2 = require("@xyo-network/payload-builder");
167
+ var import_payload_utils = require("@xyo-network/payload-utils");
153
168
  var moduleName = "TemporalIndexingDivinerIndexCandidateToIndexDiviner";
154
169
  var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends import_abstract_diviner2.AbstractDiviner {
170
+ static {
171
+ __name(this, "TemporalIndexingDivinerIndexCandidateToIndexDiviner");
172
+ }
155
173
  static configSchema = import_diviner_temporal_indexing_model3.TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema;
156
- static configSchemas = [import_diviner_model3.DivinerConfigSchema, import_diviner_temporal_indexing_model3.TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema];
174
+ static configSchemas = [
175
+ import_diviner_model3.DivinerConfigSchema,
176
+ import_diviner_temporal_indexing_model3.TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema
177
+ ];
157
178
  static labels = {
158
179
  "network.xyo.diviner.stage": "indexCandidateToIndexDiviner"
159
180
  };
160
181
  _indexableSchemas;
161
182
  _payloadTransformers;
162
183
  /**
163
- * List of indexable schemas for this diviner
164
- */
184
+ * List of indexable schemas for this diviner
185
+ */
165
186
  get indexableSchemas() {
166
187
  if (!this._indexableSchemas)
167
188
  this._indexableSchemas = Object.keys(this.schemaTransforms);
168
189
  return this._indexableSchemas;
169
190
  }
170
191
  /**
171
- * Dictionary of schemas to payload transformers for creating indexes
172
- * from the payloads within a Bound Witness
173
- */
192
+ * Dictionary of schemas to payload transformers for creating indexes
193
+ * from the payloads within a Bound Witness
194
+ */
174
195
  get payloadTransformers() {
175
196
  if (!this._payloadTransformers)
176
197
  this._payloadTransformers = (0, import_diviner_jsonpath_aggregate_memory2.jsonPathToTransformersDictionary)(this.schemaTransforms);
177
198
  return this._payloadTransformers;
178
199
  }
179
200
  /**
180
- * The dictionary of schemas to JSON Path transform expressions for creating indexes
181
- * from the payloads within a Bound Witness
182
- */
201
+ * The dictionary of schemas to JSON Path transform expressions for creating indexes
202
+ * from the payloads within a Bound Witness
203
+ */
183
204
  get schemaTransforms() {
184
205
  return (0, import_assert.assertEx)(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`);
185
206
  }
@@ -191,40 +212,48 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends import_a
191
212
  const validIndexableTuples = bws.reduce((indexableTuples, bw) => {
192
213
  if (!(0, import_array.containsAll)(bw.payload_schemas, this.indexableSchemas))
193
214
  return indexableTuples;
194
- const indexablePayloadPositions = this.indexableSchemas.map((schema) => bw.payload_schemas.indexOf(schema));
195
- const indexablePayloadHashes = indexablePayloadPositions.map((index) => bw.payload_hashes?.[index]);
196
- const indexablePayloads2 = indexablePayloadHashes.map((hash) => payloadDictionary[hash]).filter(import_exists.exists);
197
- if (indexablePayloads2.length === this.indexableSchemas.length)
198
- indexableTuples.push([bw, ...indexablePayloads2]);
215
+ (0, import_payload_utils.intraBoundwitnessSchemaCombinations)(bw, this.indexableSchemas).map((combination) => {
216
+ const indexablePayloads2 = combination.map((hash) => payloadDictionary[hash]).filter(import_exists.exists);
217
+ if (indexablePayloads2.length === this.indexableSchemas.length)
218
+ indexableTuples.push([
219
+ bw,
220
+ ...indexablePayloads2
221
+ ]);
222
+ });
199
223
  return indexableTuples;
200
224
  }, []);
201
- const indexes = await Promise.all(
202
- validIndexableTuples.map(async ([bw, ...sourcePayloads]) => {
203
- const indexFields = sourcePayloads.flatMap((payload) => {
204
- const transformers = this.payloadTransformers[payload.schema];
205
- return transformers ? transformers.map((transform) => transform(payload)) : [];
206
- });
207
- const sources = Object.keys(await import_hash.PayloadHasher.toMap([bw, ...sourcePayloads]));
208
- return await new import_payload_builder2.PayloadBuilder({ schema: import_diviner_temporal_indexing_model3.TemporalIndexingDivinerResultIndexSchema }).fields(Object.assign({ sources }, ...indexFields)).build();
209
- })
210
- );
225
+ const indexes = await Promise.all(validIndexableTuples.map(async ([bw, ...sourcePayloads]) => {
226
+ const indexFields = sourcePayloads.flatMap((payload) => {
227
+ const transformers = this.payloadTransformers[payload.schema];
228
+ return transformers ? transformers.map((transform) => transform(payload)) : [];
229
+ });
230
+ const sources = Object.keys(await import_hash.PayloadHasher.toMap([
231
+ bw,
232
+ ...sourcePayloads
233
+ ]));
234
+ return await new import_payload_builder2.PayloadBuilder({
235
+ schema: import_diviner_temporal_indexing_model3.TemporalIndexingDivinerResultIndexSchema
236
+ }).fields(Object.assign({
237
+ sources
238
+ }, ...indexFields)).build();
239
+ }));
211
240
  return indexes.flat();
212
241
  }
213
242
  return [];
214
243
  }
215
244
  /**
216
- * Identifies if a payload is one that is indexed by this diviner
217
- * @param x The candidate payload
218
- * @returns True if the payload is one indexed by this diviner, false otherwise
219
- */
245
+ * Identifies if a payload is one that is indexed by this diviner
246
+ * @param x The candidate payload
247
+ * @returns True if the payload is one indexed by this diviner, false otherwise
248
+ */
220
249
  isIndexablePayload = (x) => {
221
250
  return this.indexableSchemas.includes(x?.schema);
222
251
  };
223
252
  /**
224
- * Identifies if a schema is one that is indexed by this diviner
225
- * @param schema The candidate schema
226
- * @returns True if this schema is one indexed by this diviner, false otherwise
227
- */
253
+ * Identifies if a schema is one that is indexed by this diviner
254
+ * @param schema The candidate schema
255
+ * @returns True if this schema is one indexed by this diviner, false otherwise
256
+ */
228
257
  isIndexableSchema = (schema) => {
229
258
  return typeof schema === "string" ? this.indexableSchemas.includes(schema) : false;
230
259
  };
@@ -236,8 +265,14 @@ var import_diviner_model4 = require("@xyo-network/diviner-model");
236
265
  var import_diviner_payload_model2 = require("@xyo-network/diviner-payload-model");
237
266
  var import_diviner_temporal_indexing_model4 = require("@xyo-network/diviner-temporal-indexing-model");
238
267
  var TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner = class extends import_abstract_diviner3.AbstractDiviner {
268
+ static {
269
+ __name(this, "TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner");
270
+ }
239
271
  static configSchema = import_diviner_temporal_indexing_model4.TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema;
240
- static configSchemas = [import_diviner_model4.DivinerConfigSchema, import_diviner_temporal_indexing_model4.TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema];
272
+ static configSchemas = [
273
+ import_diviner_model4.DivinerConfigSchema,
274
+ import_diviner_temporal_indexing_model4.TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema
275
+ ];
241
276
  static labels = {
242
277
  "network.xyo.diviner.stage": "indexQueryResponseToDivinerQueryResponseDiviner"
243
278
  };
@@ -264,8 +299,14 @@ var import_witness_timestamp = require("@xyo-network/witness-timestamp");
264
299
  var order = "asc";
265
300
  var moduleName2 = "TemporalIndexingDivinerStateToIndexCandidateDiviner";
266
301
  var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends import_abstract_diviner4.AbstractDiviner {
302
+ static {
303
+ __name(this, "TemporalIndexingDivinerStateToIndexCandidateDiviner");
304
+ }
267
305
  static configSchema = import_diviner_temporal_indexing_model5.TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema;
268
- static configSchemas = [import_diviner_model5.DivinerConfigSchema, import_diviner_temporal_indexing_model5.TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema];
306
+ static configSchemas = [
307
+ import_diviner_model5.DivinerConfigSchema,
308
+ import_diviner_temporal_indexing_model5.TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema
309
+ ];
269
310
  static labels = {
270
311
  "network.xyo.diviner.stage": "stateToIndexCandidateDiviner"
271
312
  };
@@ -273,35 +314,69 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends import_a
273
314
  return this.config.payloadDivinerLimit ?? 1e3;
274
315
  }
275
316
  /**
276
- * The required payload_schemas within BoundWitnesses to identify index candidates
277
- */
317
+ * The required payload_schemas within BoundWitnesses to identify index candidates
318
+ */
278
319
  get payload_schemas() {
279
320
  const schemas = this.config.filter?.payload_schemas;
280
- return [import_witness_timestamp.TimestampSchema, ...schemas ?? []];
321
+ return [
322
+ import_witness_timestamp.TimestampSchema,
323
+ ...schemas ?? []
324
+ ];
281
325
  }
282
326
  async divineHandler(payloads = []) {
283
327
  const lastState = payloads.find(import_module_model.isModuleState);
284
328
  if (!lastState)
285
- return [{ schema: import_module_model.ModuleStateSchema, state: { offset: 0 } }];
329
+ return [
330
+ {
331
+ schema: import_module_model.ModuleStateSchema,
332
+ state: {
333
+ offset: 0
334
+ }
335
+ }
336
+ ];
286
337
  const { offset } = lastState.state;
287
338
  const boundWitnessDiviner = await this.getBoundWitnessDivinerForStore();
288
339
  if (!boundWitnessDiviner)
289
- return [lastState];
290
- const query = await new import_payload_builder3.PayloadBuilder({ schema: import_diviner_boundwitness_model.BoundWitnessDivinerQuerySchema }).fields({ limit: this.payloadDivinerLimit, offset, order, payload_schemas: this.payload_schemas }).build();
291
- const batch = await boundWitnessDiviner.divine([query]);
340
+ return [
341
+ lastState
342
+ ];
343
+ const query = await new import_payload_builder3.PayloadBuilder({
344
+ schema: import_diviner_boundwitness_model.BoundWitnessDivinerQuerySchema
345
+ }).fields({
346
+ limit: this.payloadDivinerLimit,
347
+ offset,
348
+ order,
349
+ payload_schemas: this.payload_schemas
350
+ }).build();
351
+ const batch = await boundWitnessDiviner.divine([
352
+ query
353
+ ]);
292
354
  if (batch.length === 0)
293
- return [lastState];
355
+ return [
356
+ lastState
357
+ ];
294
358
  const sourceArchivist = await this.getArchivistForStore();
295
359
  if (!sourceArchivist)
296
- return [lastState];
360
+ return [
361
+ lastState
362
+ ];
297
363
  const indexCandidates = (await Promise.all(batch.filter(import_boundwitness_model2.isBoundWitness).map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))).filter(import_exists2.exists).flat();
298
- const nextState = { schema: import_module_model.ModuleStateSchema, state: { ...lastState.state, offset: offset + batch.length } };
299
- return [nextState, ...indexCandidates];
364
+ const nextState = {
365
+ schema: import_module_model.ModuleStateSchema,
366
+ state: {
367
+ ...lastState.state,
368
+ offset: offset + batch.length
369
+ }
370
+ };
371
+ return [
372
+ nextState,
373
+ ...indexCandidates
374
+ ];
300
375
  }
301
376
  /**
302
- * Retrieves the archivist for the payloadStore
303
- * @returns The archivist for the payloadStore or undefined if not resolvable
304
- */
377
+ * Retrieves the archivist for the payloadStore
378
+ * @returns The archivist for the payloadStore or undefined if not resolvable
379
+ */
305
380
  async getArchivistForStore() {
306
381
  const name = (0, import_assert2.assertEx)(this.config?.payloadStore?.archivist, () => `${moduleName2}: Config for payloadStore.archivist not specified`);
307
382
  const mod = await this.resolve(name);
@@ -310,14 +385,11 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends import_a
310
385
  return import_archivist_wrapper.ArchivistWrapper.wrap(mod, this.account);
311
386
  }
312
387
  /**
313
- * Retrieves the BoundWitness Diviner for the payloadStore
314
- * @returns The BoundWitness Diviner for the payloadStore or undefined if not resolvable
315
- */
388
+ * Retrieves the BoundWitness Diviner for the payloadStore
389
+ * @returns The BoundWitness Diviner for the payloadStore or undefined if not resolvable
390
+ */
316
391
  async getBoundWitnessDivinerForStore() {
317
- const name = (0, import_assert2.assertEx)(
318
- this.config?.payloadStore?.boundWitnessDiviner,
319
- () => `${moduleName2}: Config for payloadStore.boundWitnessDiviner not specified`
320
- );
392
+ const name = (0, import_assert2.assertEx)(this.config?.payloadStore?.boundWitnessDiviner, () => `${moduleName2}: Config for payloadStore.boundWitnessDiviner not specified`);
321
393
  const mod = await this.resolve(name);
322
394
  if (!mod)
323
395
  return void 0;
@@ -332,7 +404,10 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends import_a
332
404
  if (filteredResults.includes(void 0))
333
405
  return void 0;
334
406
  const indexCandidates = filteredResults.filter(import_exists2.exists);
335
- return [bw, ...indexCandidates];
407
+ return [
408
+ bw,
409
+ ...indexCandidates
410
+ ];
336
411
  }
337
412
  };
338
413
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/Diviner.ts","../../src/DivinerQueryToIndexQueryDiviner/Diviner.ts","../../src/IndexCandidateToIndexDiviner/Diviner.ts","../../src/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.ts","../../src/StateToIndexCandidateDiviner/Diviner.ts"],"sourcesContent":["export * from './Diviner'\nexport * from './DivinerQueryToIndexQueryDiviner'\nexport * from './IndexCandidateToIndexDiviner'\nexport * from './IndexQueryResponseToDivinerQueryResponseDiviner'\nexport * from './StateToIndexCandidateDiviner'\n","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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qCAAgC;AAChC,oCAA4C;AAC5C,2BAA2E;AAC3E,6CAAmF;AAG5E,IAAM,0BAAN,cAKG,+CAAgD;AAAA,EACxD,OAAyB,eAAe;AAAA,EACxC,OAAyB,gBAA0B,CAAC,4EAAqC,2DAA6B,wCAAmB;AAAA,EAEzI,MAAyB,eAAiC;AACxD,UAAM,MAAM,aAAa;AACzB,WAAO;AAAA,EACT;AACF;;;ACnBA,8BAAgC;AAChC,+CAAiE;AAEjE,IAAAA,wBAAoC;AACpC,mCAAsE;AACtE,IAAAC,0CAIO;AAEP,6BAA+B;AAC/B,2BAA+C;AAKxC,IAAM,yDAAN,cAEG,wCAAyB;AAAA,EACjC,OAAyB,eAAe;AAAA,EACxC,OAAgB,gBAAgB,CAAC,2CAAqB,0GAAkE;AAAA,EACxH,OAAO,SAAiB;AAAA,IACtB,6BAA6B;AAAA,EAC/B;AAAA,EAEQ;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKR,IAAc,qBAA6B;AACzC,WAAO,KAAK,OAAO,sBAAsB;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA,E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AA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAgB,iCAAsE;AAEpF,UAAM,WAAe;AAAA,MACnB,KAAK,QAAQ,cAAc;AAAA,MAC3B,MAAM,GAAGA,WAAU;AAAA,IACrB;AAEA,UAAM,MAAM,MAAM,KAAK,QAAQ,IAAI;AACnC,QAAI,CAAC;AAAK,aAAO;AAEjB,WAAO,sCAAe,KAAK,KAAK,KAAK,OAAO;AAAA,EAC9C;AAAA,EAEA,MAAgB,0BAA0B,IAAkB,WAAqE;AAC/H,UAAM,UAAU,KAAK,gBAAgB,IAAI,CAAC,WAAW,GAAG,iBAAiB,UAAU,CAAC,MAAM,MAAM,MAAM,CAAC;AACvG,UAAM,SAAS,QAAQ,IAAI,CAAC,UAAU,GAAG,iBAAiB,KAAK,CAAC;AAChE,UAAM,UAAU,MAAM,UAAU,IAAI,MAAM;AAC1C,UAAM,kCAAkC,KAAK,gBAAgB,IAAI,2CAAqB;AACtF,UAAM,kBAAkB,gCAAgC,IAAI,CAAC,OAAO,QAAQ,KAAK,EAAE,CAAC;AACpF,QAAI,gBAAgB,SAAS,MAAS;AAAG,aAAO;AAChD,UAAM,kBAAoC,gBAAgB,OAAO,qBAAM;AACvE,WAAO,CAAC,IAAI,GAAG,eAAe;AAAA,EAChC;AACF;","names":["import_diviner_model","import_diviner_temporal_indexing_model","import_abstract_diviner","import_diviner_jsonpath_aggregate_memory","import_diviner_model","import_diviner_temporal_indexing_model","import_payload_builder","indexablePayloads","import_abstract_diviner","import_diviner_model","import_diviner_payload_model","import_diviner_temporal_indexing_model","import_assert","import_exists","import_abstract_diviner","import_boundwitness_model","import_diviner_model","import_diviner_temporal_indexing_model","import_payload_builder","import_payload_model","moduleName"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/Diviner.ts","../../src/DivinerQueryToIndexQueryDiviner/Diviner.ts","../../src/IndexCandidateToIndexDiviner/Diviner.ts","../../src/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.ts","../../src/StateToIndexCandidateDiviner/Diviner.ts"],"sourcesContent":["export * from './Diviner'\nexport * from './DivinerQueryToIndexQueryDiviner'\nexport * from './IndexCandidateToIndexDiviner'\nexport * from './IndexQueryResponseToDivinerQueryResponseDiviner'\nexport * from './StateToIndexCandidateDiviner'\n","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'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\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 // If it does contain all the required schemas, then find the combinations of payloads\n // that satisfy the required schemas\n intraBoundwitnessSchemaCombinations(bw, this.indexableSchemas).map((combination) => {\n const indexablePayloads = combination.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 })\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;;;;;;;;;;;ACAA,qCAAgC;AAChC,oCAA4C;AAC5C,2BAA2E;AAC3E,6CAAmF;AAG5E,IAAMA,0BAAN,cAKGC,+CAAAA;EAXV,OAWUA;;;EACR,OAAyBC,eAAeC;EACxC,OAAyBC,gBAA0B;IAACD;IAAqCE;IAA6BC;;EAEtH,MAAyBC,eAAiC;AACxD,UAAM,MAAMA,aAAAA;AACZ,WAAO;EACT;AACF;;;ACnBA,8BAAgC;AAChC,+CAAiE;AAEjE,IAAAC,wBAAoC;AACpC,mCAAsE;AACtE,IAAAC,0CAIO;AAEP,6BAA+B;AAC/B,2BAA+C;AAKxC,IAAMC,yDAAN,cAEGC,wCAAAA;EAnBV,OAmBUA;;;EACR,OAAyBC,eAAeC;EACxC,OAAgBC,gBAAgB;IAACC;IAAqBF;;EACtD,OAAOG,SAAiB;IACtB,6BAA6B;EAC/B;EAEQC;EACAC;;;;EAKR,IAAcC,qBAA6B;AACzC,WAAO,KA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D,UAAU,CAACC,MAAMA,MAAMxC,MAAAA,CAAAA;AAChG,UAAMyC,SAASH,QAAQjB,IAAI,CAACqB,UAAUpB,GAAGqB,iBAAiBD,KAAAA,CAAM;AAChE,UAAME,UAAU,MAAMd,UAAUe,IAAIJ,MAAAA;AACpC,UAAMK,kCAAkC,KAAKvD,gBAAgB8B,IAAI0B,2CAAAA;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,qBAAAA;AACjE,WAAO;MAACF;SAAOL;;EACjB;AACF;","names":["TemporalIndexingDiviner","IndexingDiviner","configSchema","TemporalIndexingDivinerConfigSchema","configSchemas","IndexingDivinerConfigSchema","DivinerConfigSchema","startHandler","import_diviner_model","import_diviner_temporal_indexing_model","TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner","AbstractDiviner","configSchema","TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema","configSchemas","DivinerConfigSchema","labels","_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","import_abstract_diviner","import_diviner_jsonpath_aggregate_memory","import_diviner_model","import_diviner_temporal_indexing_model","import_payload_builder","moduleName","TemporalIndexingDivinerIndexCandidateToIndexDiviner","AbstractDiviner","configSchema","TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema","configSchemas","DivinerConfigSchema","labels","_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","intraBoundwitnessSchemaCombinations","map","combination","hash","exists","push","indexes","Promise","all","sourcePayloads","indexFields","flatMap","payload","transformers","schema","transform","sources","PayloadBuilder","TemporalIndexingDivinerResultIndexSchema","fields","assign","build","flat","x","includes","isIndexableSchema","import_abstract_diviner","import_diviner_model","import_diviner_payload_model","import_diviner_temporal_indexing_model","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","AbstractDiviner","configSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","configSchemas","DivinerConfigSchema","labels","divineHandler","payloads","responses","filter","p","isPayloadDivinerQueryPayload","Promise","resolve","import_assert","import_exists","import_abstract_diviner","import_boundwitness_model","import_diviner_model","import_diviner_temporal_indexing_model","import_payload_builder","import_payload_model","order","moduleName","TemporalIndexingDivinerStateToIndexCandidateDiviner","AbstractDiviner","configSchema","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","configSchemas","DivinerConfigSchema","labels","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"]}