@xyo-network/diviner-temporal-indexing-memory 2.104.0 → 2.104.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.
@@ -63,8 +63,7 @@ var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class extends Abstr
63
63
  * List of indexable schemas for this diviner
64
64
  */
65
65
  get indexableSchemas() {
66
- if (!this._indexableSchemas)
67
- this._indexableSchemas = Object.keys(this.schemaTransforms);
66
+ if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms);
68
67
  return this._indexableSchemas;
69
68
  }
70
69
  /**
@@ -72,8 +71,7 @@ var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class extends Abstr
72
71
  * from the payloads within a Bound Witness
73
72
  */
74
73
  get payloadTransformers() {
75
- if (!this._payloadTransformers)
76
- this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms);
74
+ if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms);
77
75
  return this._payloadTransformers;
78
76
  }
79
77
  /**
@@ -153,8 +151,7 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
153
151
  * List of indexable schemas for this diviner
154
152
  */
155
153
  get indexableSchemas() {
156
- if (!this._indexableSchemas)
157
- this._indexableSchemas = Object.keys(this.schemaTransforms);
154
+ if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms);
158
155
  return this._indexableSchemas;
159
156
  }
160
157
  /**
@@ -162,8 +159,7 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
162
159
  * from the payloads within a Bound Witness
163
160
  */
164
161
  get payloadTransformers() {
165
- if (!this._payloadTransformers)
166
- this._payloadTransformers = jsonPathToTransformersDictionary2(this.schemaTransforms);
162
+ if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary2(this.schemaTransforms);
167
163
  return this._payloadTransformers;
168
164
  }
169
165
  /**
@@ -177,8 +173,7 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
177
173
  const builtPayloads = await Promise.all(payloads.map((payload) => PayloadBuilder2.build(payload)));
178
174
  const indexableBoundWitnesses = builtPayloads.filter(isBoundWitnessWithMeta).filter((bw) => containsAll(bw.payload_schemas, this.indexableSchemas));
179
175
  const indexablePayloads = builtPayloads.filter((p) => this.isIndexablePayload(p));
180
- if (indexableBoundWitnesses.length === 0 || indexablePayloads.length === 0)
181
- return [];
176
+ if (indexableBoundWitnesses.length === 0 || indexablePayloads.length === 0) return [];
182
177
  const [bwDictionary, payloadDictionary] = await Promise.all([
183
178
  PayloadBuilder2.toDataHashMap(indexableBoundWitnesses),
184
179
  PayloadBuilder2.toDataHashMap(indexablePayloads)
@@ -219,17 +214,17 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
219
214
  * @param x The candidate payload
220
215
  * @returns True if the payload is one indexed by this diviner, false otherwise
221
216
  */
222
- isIndexablePayload = (x) => {
217
+ isIndexablePayload = /* @__PURE__ */ __name((x) => {
223
218
  return isAnyPayload(x) && this.indexableSchemas.includes(x?.schema);
224
- };
219
+ }, "isIndexablePayload");
225
220
  /**
226
221
  * Identifies if a schema is one that is indexed by this diviner
227
222
  * @param schema The candidate schema
228
223
  * @returns True if this schema is one indexed by this diviner, false otherwise
229
224
  */
230
- isIndexableSchema = (schema) => {
225
+ isIndexableSchema = /* @__PURE__ */ __name((schema) => {
231
226
  return typeof schema === "string" ? this.indexableSchemas.includes(schema) : false;
232
- };
227
+ }, "isIndexableSchema");
233
228
  };
234
229
 
235
230
  // src/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.ts
@@ -298,21 +293,19 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends Abstract
298
293
  }
299
294
  async divineHandler(payloads = []) {
300
295
  const lastState = payloads.find(isModuleState);
301
- if (!lastState)
302
- return [
303
- {
304
- schema: ModuleStateSchema,
305
- state: {
306
- offset: 0
307
- }
296
+ if (!lastState) return [
297
+ {
298
+ schema: ModuleStateSchema,
299
+ state: {
300
+ offset: 0
308
301
  }
309
- ];
302
+ }
303
+ ];
310
304
  const { offset } = lastState.state;
311
305
  const boundWitnessDiviner = await this.getBoundWitnessDivinerForStore();
312
- if (!boundWitnessDiviner)
313
- return [
314
- lastState
315
- ];
306
+ if (!boundWitnessDiviner) return [
307
+ lastState
308
+ ];
316
309
  const query = await new PayloadBuilder3({
317
310
  schema: BoundWitnessDivinerQuerySchema
318
311
  }).fields({
@@ -324,15 +317,13 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends Abstract
324
317
  const batch = await boundWitnessDiviner.divine([
325
318
  query
326
319
  ]);
327
- if (batch.length === 0)
328
- return [
329
- lastState
330
- ];
320
+ if (batch.length === 0) return [
321
+ lastState
322
+ ];
331
323
  const sourceArchivist = await this.getArchivistForStore();
332
- if (!sourceArchivist)
333
- return [
334
- lastState
335
- ];
324
+ if (!sourceArchivist) return [
325
+ lastState
326
+ ];
336
327
  const bws = batch.filter(isBoundWitnessWithMeta2);
337
328
  const indexCandidates = (await Promise.all(bws.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))).filter(exists2).flat();
338
329
  const nextState = {
@@ -354,8 +345,7 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends Abstract
354
345
  async getArchivistForStore() {
355
346
  const name = assertEx2(this.config?.payloadStore?.archivist, () => `${moduleName2}: Config for payloadStore.archivist not specified`);
356
347
  const mod = await this.resolve(name);
357
- if (!mod)
358
- return void 0;
348
+ if (!mod) return void 0;
359
349
  return ArchivistWrapper.wrap(mod, this.account);
360
350
  }
361
351
  /**
@@ -365,14 +355,12 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends Abstract
365
355
  async getBoundWitnessDivinerForStore() {
366
356
  const name = assertEx2(this.config?.payloadStore?.boundWitnessDiviner, () => `${moduleName2}: Config for payloadStore.boundWitnessDiviner not specified`);
367
357
  const mod = await this.resolve(name);
368
- if (!mod)
369
- return;
358
+ if (!mod) return;
370
359
  return DivinerWrapper.wrap(mod, this.account);
371
360
  }
372
361
  async getPayloadsInBoundWitness(bw, archivist) {
373
362
  const combinations = intraBoundwitnessSchemaCombinations2(bw, this.payload_schemas).flat();
374
- if (combinations.length === 0)
375
- return void 0;
363
+ if (combinations.length === 0) return void 0;
376
364
  const hashes = new Set(combinations);
377
365
  const indexCandidates = await archivist.get([
378
366
  ...hashes
@@ -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 { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { TemporalIndexingDivinerConfigSchema, TemporalIndexingDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { Payload, Schema } 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<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends IndexingDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerConfigSchema\n\n protected override async startHandler(): Promise<boolean> {\n await super.startHandler()\n return true\n }\n}\n","import { Hash } from '@xylabs/hex'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-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 configSchemas = [...super.configSchemas, TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema]\n static override readonly defaultConfigSchema = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n static override labels: Labels = {\n ...super.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?: Hash[] }>(\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 { Hash } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\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 { isAnyPayload, Payload, Schema } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\n\ntype IndexableHashes = [Hash, ...Hash[]]\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 readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n static override labels: Labels = {\n ...super.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 builtPayloads = await Promise.all(payloads.map((payload) => PayloadBuilder.build(payload)))\n // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = builtPayloads\n .filter(isBoundWitnessWithMeta)\n .filter((bw) => containsAll(bw.payload_schemas, this.indexableSchemas))\n // If the Payload is not one of the indexable schemas do not index it\n const indexablePayloads = builtPayloads.filter((p) => this.isIndexablePayload(p))\n // If there is nothing to index, return an empty array\n if (indexableBoundWitnesses.length === 0 || indexablePayloads.length === 0) return []\n // Hash all the indexable data once\n const [bwDictionary, payloadDictionary] = await Promise.all([\n PayloadBuilder.toDataHashMap(indexableBoundWitnesses),\n PayloadBuilder.toDataHashMap(indexablePayloads),\n ])\n\n // Initialize the array for validIndexableTuples outside of the loop\n const validIndexableTuples: IndexableHashes[] = []\n\n // Iterate over each entry in bwDictionary\n for (const [bwHash, bw] of Object.entries(bwDictionary) as [Hash, BoundWitness][]) {\n // Find the combinations of payloads that satisfy the required schemas\n const combinations = intraBoundwitnessSchemaCombinations(bw, this.indexableSchemas)\n\n // Iterate over each combination\n for (const combination of combinations) {\n const indexablePayloads = combination.map((hash) => payloadDictionary[hash]).filter(exists)\n\n // If we found the right amount of indexable payloads (of the correct schema as checked\n // above) in this BW, then index it\n if (indexablePayloads.length === this.indexableSchemas.length) {\n validIndexableTuples.push([bwHash, ...combination])\n }\n }\n }\n\n // Create the indexes from the tuples\n const indexes = await Promise.all(\n validIndexableTuples.map<Promise<TemporalIndexingDivinerResultIndex>>(async ([bwHash, ...sourcePayloadHashes]) => {\n const sourcePayloads = sourcePayloadHashes.map((hash) => payloadDictionary[hash])\n // Use the payload transformers to convert the fields from the source payloads to the destination fields\n const indexFields = sourcePayloads.flatMap((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: string[] = [bwHash, ...sourcePayloadHashes]\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\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: unknown) => {\n return isAnyPayload(x) && 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/diviner-abstract'\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, Schema } 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 configSchemas: Schema[] = [\n ...super.configSchemas,\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema,\n ]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n static override labels: Labels = {\n ...super.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 { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'\nimport {\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema,\n TemporalIndexingDivinerStateToIndexCandidateDivinerParams,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport { isModuleState, Labels, ModuleIdentifier, ModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\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, Payload, ModuleState | IndexCandidate> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n static override labels: Labels = {\n ...super.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 bws = batch.filter(isBoundWitnessWithMeta)\n const indexCandidates: IndexCandidate[] = (await Promise.all(bws.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist))))\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: ModuleIdentifier = assertEx(\n this.config?.payloadStore?.archivist,\n () => `${moduleName}: Config for payloadStore.archivist 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 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() {\n // It should be defined, so we'll error if it's not\n const name: ModuleIdentifier = 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\n // Return the wrapped diviner\n return DivinerWrapper.wrap<\n DivinerWrapper<\n BoundWitnessDiviner<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>,\n BoundWitnessDivinerQueryPayload,\n BoundWitness\n >\n >(mod, this.account)\n }\n\n protected async getPayloadsInBoundWitness(bw: BoundWitness, archivist: ArchivistInstance): Promise<IndexCandidate[] | undefined> {\n const combinations = intraBoundwitnessSchemaCombinations(bw, this.payload_schemas).flat()\n if (combinations.length === 0) return undefined\n const hashes = new Set(combinations)\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ACvB,UAAMpB,kBAAkB,MAAMY,UAAUY,IAAI;SAAIF;KAAO;AACvD,WAAO;MAAClB;SAAOJ;;EACjB;AACF;","names":["IndexingDiviner","TemporalIndexingDivinerConfigSchema","TemporalIndexingDiviner","IndexingDiviner","configSchemas","TemporalIndexingDivinerConfigSchema","defaultConfigSchema","startHandler","AbstractDiviner","jsonPathToTransformersDictionary","reducePayloads","PayloadDivinerQuerySchema","TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema","TemporalIndexingDivinerResultIndexSchema","PayloadBuilder","isPayloadOfSchemaType","TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema","defaultConfigSchema","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","containsAll","assertEx","exists","isBoundWitnessWithMeta","AbstractDiviner","jsonPathToTransformersDictionary","TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema","TemporalIndexingDivinerResultIndexSchema","PayloadBuilder","isAnyPayload","intraBoundwitnessSchemaCombinations","moduleName","TemporalIndexingDivinerIndexCandidateToIndexDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema","defaultConfigSchema","labels","_indexableSchemas","_payloadTransformers","indexableSchemas","Object","keys","schemaTransforms","payloadTransformers","jsonPathToTransformersDictionary","assertEx","config","divineHandler","payloads","builtPayloads","Promise","all","map","payload","PayloadBuilder","build","indexableBoundWitnesses","filter","isBoundWitnessWithMeta","bw","containsAll","payload_schemas","indexablePayloads","p","isIndexablePayload","length","bwDictionary","payloadDictionary","toDataHashMap","validIndexableTuples","bwHash","entries","combinations","intraBoundwitnessSchemaCombinations","combination","hash","exists","push","indexes","sourcePayloadHashes","sourcePayloads","indexFields","flatMap","transformers","schema","transform","sources","TemporalIndexingDivinerResultIndexSchema","fields","assign","flat","x","isAnyPayload","includes","isIndexableSchema","AbstractDiviner","isPayloadDivinerQueryPayload","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","defaultConfigSchema","labels","divineHandler","payloads","responses","filter","p","isPayloadDivinerQueryPayload","Promise","resolve","assertEx","exists","ArchivistWrapper","isBoundWitnessWithMeta","AbstractDiviner","BoundWitnessDivinerQuerySchema","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","DivinerWrapper","isModuleState","ModuleStateSchema","PayloadBuilder","intraBoundwitnessSchemaCombinations","TimestampSchema","order","moduleName","TemporalIndexingDivinerStateToIndexCandidateDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","defaultConfigSchema","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","bws","isBoundWitnessWithMeta","indexCandidates","Promise","all","map","bw","getPayloadsInBoundWitness","exists","flat","nextState","name","assertEx","payloadStore","archivist","mod","resolve","undefined","ArchivistWrapper","wrap","account","DivinerWrapper","combinations","intraBoundwitnessSchemaCombinations","hashes","Set","get"]}
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 { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { TemporalIndexingDivinerConfigSchema, TemporalIndexingDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { Payload, Schema } 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<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends IndexingDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerConfigSchema\n\n protected override async startHandler(): Promise<boolean> {\n await super.startHandler()\n return true\n }\n}\n","import { Hash } from '@xylabs/hex'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-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 configSchemas = [...super.configSchemas, TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema]\n static override readonly defaultConfigSchema = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema\n static override labels: Labels = {\n ...super.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?: Hash[] }>(\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 { Hash } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\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 { isAnyPayload, Payload, Schema } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\n\ntype IndexableHashes = [Hash, ...Hash[]]\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 readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema\n static override labels: Labels = {\n ...super.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 builtPayloads = await Promise.all(payloads.map((payload) => PayloadBuilder.build(payload)))\n // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = builtPayloads\n .filter(isBoundWitnessWithMeta)\n .filter((bw) => containsAll(bw.payload_schemas, this.indexableSchemas))\n // If the Payload is not one of the indexable schemas do not index it\n const indexablePayloads = builtPayloads.filter((p) => this.isIndexablePayload(p))\n // If there is nothing to index, return an empty array\n if (indexableBoundWitnesses.length === 0 || indexablePayloads.length === 0) return []\n // Hash all the indexable data once\n const [bwDictionary, payloadDictionary] = await Promise.all([\n PayloadBuilder.toDataHashMap(indexableBoundWitnesses),\n PayloadBuilder.toDataHashMap(indexablePayloads),\n ])\n\n // Initialize the array for validIndexableTuples outside of the loop\n const validIndexableTuples: IndexableHashes[] = []\n\n // Iterate over each entry in bwDictionary\n for (const [bwHash, bw] of Object.entries(bwDictionary) as [Hash, BoundWitness][]) {\n // Find the combinations of payloads that satisfy the required schemas\n const combinations = intraBoundwitnessSchemaCombinations(bw, this.indexableSchemas)\n\n // Iterate over each combination\n for (const combination of combinations) {\n const indexablePayloads = combination.map((hash) => payloadDictionary[hash]).filter(exists)\n\n // If we found the right amount of indexable payloads (of the correct schema as checked\n // above) in this BW, then index it\n if (indexablePayloads.length === this.indexableSchemas.length) {\n validIndexableTuples.push([bwHash, ...combination])\n }\n }\n }\n\n // Create the indexes from the tuples\n const indexes = await Promise.all(\n validIndexableTuples.map<Promise<TemporalIndexingDivinerResultIndex>>(async ([bwHash, ...sourcePayloadHashes]) => {\n const sourcePayloads = sourcePayloadHashes.map((hash) => payloadDictionary[hash])\n // Use the payload transformers to convert the fields from the source payloads to the destination fields\n const indexFields = sourcePayloads.flatMap((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: string[] = [bwHash, ...sourcePayloadHashes]\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\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: unknown) => {\n return isAnyPayload(x) && 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/diviner-abstract'\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, Schema } 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 configSchemas: Schema[] = [\n ...super.configSchemas,\n TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema,\n ]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema\n static override labels: Labels = {\n ...super.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 { ArchivistInstance } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport { BoundWitness, isBoundWitnessWithMeta } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'\nimport {\n TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema,\n TemporalIndexingDivinerStateToIndexCandidateDivinerParams,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport { isModuleState, Labels, ModuleIdentifier, ModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, Schema } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\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, Payload, ModuleState | IndexCandidate> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema\n static override labels: Labels = {\n ...super.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 bws = batch.filter(isBoundWitnessWithMeta)\n const indexCandidates: IndexCandidate[] = (await Promise.all(bws.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist))))\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: ModuleIdentifier = assertEx(\n this.config?.payloadStore?.archivist,\n () => `${moduleName}: Config for payloadStore.archivist 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 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() {\n // It should be defined, so we'll error if it's not\n const name: ModuleIdentifier = 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\n // Return the wrapped diviner\n return DivinerWrapper.wrap<\n DivinerWrapper<\n BoundWitnessDiviner<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>,\n BoundWitnessDivinerQueryPayload,\n BoundWitness\n >\n >(mod, this.account)\n }\n\n protected async getPayloadsInBoundWitness(bw: BoundWitness, archivist: ArchivistInstance): Promise<IndexCandidate[] | undefined> {\n const combinations = intraBoundwitnessSchemaCombinations(bw, this.payload_schemas).flat()\n if (combinations.length === 0) return undefined\n const hashes = new Set(combinations)\n const indexCandidates = await archivist.get([...hashes])\n return [bw, ...indexCandidates]\n }\n}\n"],"mappings":";;;;AAAA,SAASA,uBAAuB;AAEhC,SAASC,2CAA0E;AAG5E,IAAMC,0BAAN,cASGC,gBAAAA;EAdV,OAcUA;;;EACR,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeC;;EAC5E,OAAyBC,sBAA8BD;EAEvD,MAAyBE,eAAiC;AACxD,UAAM,MAAMA,aAAAA;AACZ,WAAO;EACT;AACF;;;ACrBA,SAASC,uBAAuB;AAChC,SAASC,kCAAkCC,sBAAsB;AAEjE,SAAqCC,iCAAiC;AACtE,SACEC,oEAEAC,g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EACPC,KAAI;AACP,UAAMC,YAAY;MAAE3B,QAAQC;MAAmBC,OAAO;QAAE,GAAGL,UAAUK;QAAOC,QAAQA,SAASS,MAAME;MAAO;IAAE;AAC5G,WAAO;MAACa;SAAcR;;EACxB;;;;;EAKA,MAAgBH,uBAA8D;AAE5E,UAAMY,OAAyBC,UAC7B,KAAKvC,QAAQwC,cAAcC,WAC3B,MAAM,GAAGjD,WAAAA,mDAA6D;AAGxE,UAAMkD,MAAM,MAAM,KAAKC,QAAQL,IAAAA;AAC/B,QAAI,CAACI,IAAK,QAAOE;AAEjB,WAAOC,iBAAiBC,KAAKJ,KAAK,KAAKK,OAAO;EAChD;;;;;EAMA,MAAgBhC,iCAAiC;AAE/C,UAAMuB,OAAyBC,UAC7B,KAAKvC,QAAQwC,cAAc1B,qBAC3B,MAAM,GAAGtB,WAAAA,6DAAuE;AAGlF,UAAMkD,MAAM,MAAM,KAAKC,QAAQL,IAAAA;AAC/B,QAAI,CAACI,IAAK;AAEV,WAAOM,eAAeF,KAMpBJ,KAAK,KAAKK,OAAO;EACrB;EAEA,MAAgBb,0BAA0BD,IAAkBQ,WAAqE;AAC/H,UAAMQ,eAAeC,qCAAoCjB,IAAI,KAAKhC,eAAe,EAAEmC,KAAI;AACvF,QAAIa,aAAazB,WAAW,EAAG,QAAOoB;AACtC,UAAMO,SAAS,IAAIC,IAAIH,YAAAA;AACvB,UAAMpB,kBAAkB,MAAMY,UAAUY,IAAI;SAAIF;KAAO;AACvD,WAAO;MAAClB;SAAOJ;;EACjB;AACF;","names":["IndexingDiviner","TemporalIndexingDivinerConfigSchema","TemporalIndexingDiviner","IndexingDiviner","configSchemas","TemporalIndexingDivinerConfigSchema","defaultConfigSchema","startHandler","AbstractDiviner","jsonPathToTransformersDictionary","reducePayloads","PayloadDivinerQuerySchema","TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema","TemporalIndexingDivinerResultIndexSchema","PayloadBuilder","isPayloadOfSchemaType","TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema","defaultConfigSchema","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","containsAll","assertEx","exists","isBoundWitnessWithMeta","AbstractDiviner","jsonPathToTransformersDictionary","TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema","TemporalIndexingDivinerResultIndexSchema","PayloadBuilder","isAnyPayload","intraBoundwitnessSchemaCombinations","moduleName","TemporalIndexingDivinerIndexCandidateToIndexDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema","defaultConfigSchema","labels","_indexableSchemas","_payloadTransformers","indexableSchemas","Object","keys","schemaTransforms","payloadTransformers","jsonPathToTransformersDictionary","assertEx","config","divineHandler","payloads","builtPayloads","Promise","all","map","payload","PayloadBuilder","build","indexableBoundWitnesses","filter","isBoundWitnessWithMeta","bw","containsAll","payload_schemas","indexablePayloads","p","isIndexablePayload","length","bwDictionary","payloadDictionary","toDataHashMap","validIndexableTuples","bwHash","entries","combinations","intraBoundwitnessSchemaCombinations","combination","hash","exists","push","indexes","sourcePayloadHashes","sourcePayloads","indexFields","flatMap","transformers","schema","transform","sources","TemporalIndexingDivinerResultIndexSchema","fields","assign","flat","x","isAnyPayload","includes","isIndexableSchema","AbstractDiviner","isPayloadDivinerQueryPayload","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","defaultConfigSchema","labels","divineHandler","payloads","responses","filter","p","isPayloadDivinerQueryPayload","Promise","resolve","assertEx","exists","ArchivistWrapper","isBoundWitnessWithMeta","AbstractDiviner","BoundWitnessDivinerQuerySchema","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","DivinerWrapper","isModuleState","ModuleStateSchema","PayloadBuilder","intraBoundwitnessSchemaCombinations","TimestampSchema","order","moduleName","TemporalIndexingDivinerStateToIndexCandidateDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","defaultConfigSchema","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","bws","isBoundWitnessWithMeta","indexCandidates","Promise","all","map","bw","getPayloadsInBoundWitness","exists","flat","nextState","name","assertEx","payloadStore","archivist","mod","resolve","undefined","ArchivistWrapper","wrap","account","DivinerWrapper","combinations","intraBoundwitnessSchemaCombinations","hashes","Set","get"]}
@@ -20,10 +20,7 @@ var __copyProps = (to, from, except, desc) => {
20
20
  return to;
21
21
  };
22
22
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
- var __publicField = (obj, key, value) => {
24
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
25
- return value;
26
- };
23
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
27
24
  var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
28
25
 
29
26
  // src/index.ts
@@ -86,8 +83,7 @@ var _TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class _TemporalInd
86
83
  * List of indexable schemas for this diviner
87
84
  */
88
85
  get indexableSchemas() {
89
- if (!this._indexableSchemas)
90
- this._indexableSchemas = Object.keys(this.schemaTransforms);
86
+ if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms);
91
87
  return this._indexableSchemas;
92
88
  }
93
89
  /**
@@ -95,8 +91,7 @@ var _TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class _TemporalInd
95
91
  * from the payloads within a Bound Witness
96
92
  */
97
93
  get payloadTransformers() {
98
- if (!this._payloadTransformers)
99
- this._payloadTransformers = (0, import_diviner_jsonpath_aggregate_memory.jsonPathToTransformersDictionary)(this.schemaTransforms);
94
+ if (!this._payloadTransformers) this._payloadTransformers = (0, import_diviner_jsonpath_aggregate_memory.jsonPathToTransformersDictionary)(this.schemaTransforms);
100
95
  return this._payloadTransformers;
101
96
  }
102
97
  /**
@@ -176,8 +171,7 @@ var _TemporalIndexingDivinerIndexCandidateToIndexDiviner = class _TemporalIndexi
176
171
  * List of indexable schemas for this diviner
177
172
  */
178
173
  get indexableSchemas() {
179
- if (!this._indexableSchemas)
180
- this._indexableSchemas = Object.keys(this.schemaTransforms);
174
+ if (!this._indexableSchemas) this._indexableSchemas = Object.keys(this.schemaTransforms);
181
175
  return this._indexableSchemas;
182
176
  }
183
177
  /**
@@ -185,8 +179,7 @@ var _TemporalIndexingDivinerIndexCandidateToIndexDiviner = class _TemporalIndexi
185
179
  * from the payloads within a Bound Witness
186
180
  */
187
181
  get payloadTransformers() {
188
- if (!this._payloadTransformers)
189
- this._payloadTransformers = (0, import_diviner_jsonpath_aggregate_memory2.jsonPathToTransformersDictionary)(this.schemaTransforms);
182
+ if (!this._payloadTransformers) this._payloadTransformers = (0, import_diviner_jsonpath_aggregate_memory2.jsonPathToTransformersDictionary)(this.schemaTransforms);
190
183
  return this._payloadTransformers;
191
184
  }
192
185
  /**
@@ -201,8 +194,7 @@ var _TemporalIndexingDivinerIndexCandidateToIndexDiviner = class _TemporalIndexi
201
194
  const builtPayloads = await Promise.all(payloads.map((payload) => import_payload_builder2.PayloadBuilder.build(payload)));
202
195
  const indexableBoundWitnesses = builtPayloads.filter(import_boundwitness_model.isBoundWitnessWithMeta).filter((bw) => (0, import_array.containsAll)(bw.payload_schemas, this.indexableSchemas));
203
196
  const indexablePayloads = builtPayloads.filter((p) => this.isIndexablePayload(p));
204
- if (indexableBoundWitnesses.length === 0 || indexablePayloads.length === 0)
205
- return [];
197
+ if (indexableBoundWitnesses.length === 0 || indexablePayloads.length === 0) return [];
206
198
  const [bwDictionary, payloadDictionary] = await Promise.all([
207
199
  import_payload_builder2.PayloadBuilder.toDataHashMap(indexableBoundWitnesses),
208
200
  import_payload_builder2.PayloadBuilder.toDataHashMap(indexablePayloads)
@@ -243,17 +235,17 @@ var _TemporalIndexingDivinerIndexCandidateToIndexDiviner = class _TemporalIndexi
243
235
  * @param x The candidate payload
244
236
  * @returns True if the payload is one indexed by this diviner, false otherwise
245
237
  */
246
- isIndexablePayload = (x) => {
238
+ isIndexablePayload = /* @__PURE__ */ __name((x) => {
247
239
  return (0, import_payload_model2.isAnyPayload)(x) && this.indexableSchemas.includes(x == null ? void 0 : x.schema);
248
- };
240
+ }, "isIndexablePayload");
249
241
  /**
250
242
  * Identifies if a schema is one that is indexed by this diviner
251
243
  * @param schema The candidate schema
252
244
  * @returns True if this schema is one indexed by this diviner, false otherwise
253
245
  */
254
- isIndexableSchema = (schema) => {
246
+ isIndexableSchema = /* @__PURE__ */ __name((schema) => {
255
247
  return typeof schema === "string" ? this.indexableSchemas.includes(schema) : false;
256
- };
248
+ }, "isIndexableSchema");
257
249
  };
258
250
  __name(_TemporalIndexingDivinerIndexCandidateToIndexDiviner, "TemporalIndexingDivinerIndexCandidateToIndexDiviner");
259
251
  __publicField(_TemporalIndexingDivinerIndexCandidateToIndexDiviner, "configSchemas", [
@@ -321,21 +313,19 @@ var _TemporalIndexingDivinerStateToIndexCandidateDiviner = class _TemporalIndexi
321
313
  }
322
314
  async divineHandler(payloads = []) {
323
315
  const lastState = payloads.find(import_module_model.isModuleState);
324
- if (!lastState)
325
- return [
326
- {
327
- schema: import_module_model.ModuleStateSchema,
328
- state: {
329
- offset: 0
330
- }
316
+ if (!lastState) return [
317
+ {
318
+ schema: import_module_model.ModuleStateSchema,
319
+ state: {
320
+ offset: 0
331
321
  }
332
- ];
322
+ }
323
+ ];
333
324
  const { offset } = lastState.state;
334
325
  const boundWitnessDiviner = await this.getBoundWitnessDivinerForStore();
335
- if (!boundWitnessDiviner)
336
- return [
337
- lastState
338
- ];
326
+ if (!boundWitnessDiviner) return [
327
+ lastState
328
+ ];
339
329
  const query = await new import_payload_builder3.PayloadBuilder({
340
330
  schema: import_diviner_boundwitness_model.BoundWitnessDivinerQuerySchema
341
331
  }).fields({
@@ -347,15 +337,13 @@ var _TemporalIndexingDivinerStateToIndexCandidateDiviner = class _TemporalIndexi
347
337
  const batch = await boundWitnessDiviner.divine([
348
338
  query
349
339
  ]);
350
- if (batch.length === 0)
351
- return [
352
- lastState
353
- ];
340
+ if (batch.length === 0) return [
341
+ lastState
342
+ ];
354
343
  const sourceArchivist = await this.getArchivistForStore();
355
- if (!sourceArchivist)
356
- return [
357
- lastState
358
- ];
344
+ if (!sourceArchivist) return [
345
+ lastState
346
+ ];
359
347
  const bws = batch.filter(import_boundwitness_model2.isBoundWitnessWithMeta);
360
348
  const indexCandidates = (await Promise.all(bws.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))).filter(import_exists2.exists).flat();
361
349
  const nextState = {
@@ -378,8 +366,7 @@ var _TemporalIndexingDivinerStateToIndexCandidateDiviner = class _TemporalIndexi
378
366
  var _a, _b;
379
367
  const name = (0, import_assert2.assertEx)((_b = (_a = this.config) == null ? void 0 : _a.payloadStore) == null ? void 0 : _b.archivist, () => `${moduleName2}: Config for payloadStore.archivist not specified`);
380
368
  const mod = await this.resolve(name);
381
- if (!mod)
382
- return void 0;
369
+ if (!mod) return void 0;
383
370
  return import_archivist_wrapper.ArchivistWrapper.wrap(mod, this.account);
384
371
  }
385
372
  /**
@@ -390,14 +377,12 @@ var _TemporalIndexingDivinerStateToIndexCandidateDiviner = class _TemporalIndexi
390
377
  var _a, _b;
391
378
  const name = (0, import_assert2.assertEx)((_b = (_a = this.config) == null ? void 0 : _a.payloadStore) == null ? void 0 : _b.boundWitnessDiviner, () => `${moduleName2}: Config for payloadStore.boundWitnessDiviner not specified`);
392
379
  const mod = await this.resolve(name);
393
- if (!mod)
394
- return;
380
+ if (!mod) return;
395
381
  return import_diviner_wrapper.DivinerWrapper.wrap(mod, this.account);
396
382
  }
397
383
  async getPayloadsInBoundWitness(bw, archivist) {
398
384
  const combinations = (0, import_payload_utils2.intraBoundwitnessSchemaCombinations)(bw, this.payload_schemas).flat();
399
- if (combinations.length === 0)
400
- return void 0;
385
+ if (combinations.length === 0) return void 0;
401
386
  const hashes = new Set(combinations);
402
387
  const indexCandidates = await archivist.get([
403
388
  ...hashes