@xyo-network/diviner-temporal-indexing-memory 3.6.0-rc.9 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/IndexCandidateToIndexDiviner/Diviner.d.ts.map +1 -1
- package/dist/browser/StateToIndexCandidateDiviner/Diviner.d.ts +4 -8
- package/dist/browser/StateToIndexCandidateDiviner/Diviner.d.ts.map +1 -1
- package/dist/browser/index.mjs +9 -10
- package/dist/browser/index.mjs.map +1 -1
- package/dist/neutral/IndexCandidateToIndexDiviner/Diviner.d.ts.map +1 -1
- package/dist/neutral/StateToIndexCandidateDiviner/Diviner.d.ts +4 -8
- package/dist/neutral/StateToIndexCandidateDiviner/Diviner.d.ts.map +1 -1
- package/dist/neutral/index.mjs +9 -10
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.ts.map +1 -1
- package/dist/node/StateToIndexCandidateDiviner/Diviner.d.ts +4 -8
- package/dist/node/StateToIndexCandidateDiviner/Diviner.d.ts.map +1 -1
- package/dist/node/index.mjs +9 -10
- package/dist/node/index.mjs.map +1 -1
- package/package.json +36 -37
- package/src/DivinerQueryToIndexQueryDiviner/Diviner.ts +4 -4
- package/src/IndexCandidateToIndexDiviner/Diviner.ts +16 -18
- package/src/StateToIndexCandidateDiviner/Diviner.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../../src/IndexCandidateToIndexDiviner/Diviner.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D,OAAO,KAAK,EAAE,8CAA8C,EAAE,qCAAqC,EAAE,MAAM,qCAAqC,CAAA;AAChJ,OAAO,KAAK,EACV,yDAAyD,EAE1D,MAAM,8CAA8C,CAAA;AAKrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAEv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yB,mBAAmB,EAAE,MAAM,CAAkE;IACtH,OAAgB,MAAM,EAAE,MAAM,CAG7B;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;IAuDpF;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,MAAO,OAAO,aAEzC;IAED;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,YAAa,MAAM,GAAG,IAAI,aAEpD;CACF"}
|
|
@@ -101,10 +101,9 @@ export declare class TemporalIndexingDivinerStateToIndexCandidateDiviner<TParams
|
|
|
101
101
|
payload_schemas?: string[] | undefined;
|
|
102
102
|
previous_hashes?: import("@xylabs/object").DeepRestrictToStringKeys<Lowercase<string> | null>[] | undefined;
|
|
103
103
|
limit?: number | undefined;
|
|
104
|
+
cursor?: Lowercase<string> | undefined;
|
|
104
105
|
order?: import("@xyo-network/diviner-payload-model").Order | undefined;
|
|
105
106
|
address?: Lowercase<string> | Lowercase<string>[] | undefined;
|
|
106
|
-
cursor?: Lowercase<string> | undefined;
|
|
107
|
-
hash?: Lowercase<string> | undefined;
|
|
108
107
|
budget?: number | undefined;
|
|
109
108
|
maxFrequency?: "once" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year" | undefined;
|
|
110
109
|
minBid?: number | undefined;
|
|
@@ -163,10 +162,9 @@ export declare class TemporalIndexingDivinerStateToIndexCandidateDiviner<TParams
|
|
|
163
162
|
payload_schemas?: string[] | undefined;
|
|
164
163
|
previous_hashes?: import("@xylabs/object").DeepRestrictToStringKeys<Lowercase<string> | null>[] | undefined;
|
|
165
164
|
limit?: number | undefined;
|
|
165
|
+
cursor?: Lowercase<string> | undefined;
|
|
166
166
|
order?: import("@xyo-network/diviner-payload-model").Order | undefined;
|
|
167
167
|
address?: Lowercase<string> | Lowercase<string>[] | undefined;
|
|
168
|
-
cursor?: Lowercase<string> | undefined;
|
|
169
|
-
hash?: Lowercase<string> | undefined;
|
|
170
168
|
budget?: number | undefined;
|
|
171
169
|
maxFrequency?: "once" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year" | undefined;
|
|
172
170
|
minBid?: number | undefined;
|
|
@@ -182,10 +180,9 @@ export declare class TemporalIndexingDivinerStateToIndexCandidateDiviner<TParams
|
|
|
182
180
|
payload_schemas?: string[] | undefined;
|
|
183
181
|
previous_hashes?: import("@xylabs/object").DeepRestrictToStringKeys<Lowercase<string> | null>[] | undefined;
|
|
184
182
|
limit?: number | undefined;
|
|
183
|
+
cursor?: Lowercase<string> | undefined;
|
|
185
184
|
order?: import("@xyo-network/diviner-payload-model").Order | undefined;
|
|
186
185
|
address?: Lowercase<string> | Lowercase<string>[] | undefined;
|
|
187
|
-
cursor?: Lowercase<string> | undefined;
|
|
188
|
-
hash?: Lowercase<string> | undefined;
|
|
189
186
|
budget?: number | undefined;
|
|
190
187
|
maxFrequency?: "once" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year" | undefined;
|
|
191
188
|
minBid?: number | undefined;
|
|
@@ -201,10 +198,9 @@ export declare class TemporalIndexingDivinerStateToIndexCandidateDiviner<TParams
|
|
|
201
198
|
payload_schemas?: string[] | undefined;
|
|
202
199
|
previous_hashes?: import("@xylabs/object").DeepRestrictToStringKeys<Lowercase<string> | null>[] | undefined;
|
|
203
200
|
limit?: number | undefined;
|
|
201
|
+
cursor?: Lowercase<string> | undefined;
|
|
204
202
|
order?: import("@xyo-network/diviner-payload-model").Order | undefined;
|
|
205
203
|
address?: Lowercase<string> | Lowercase<string>[] | undefined;
|
|
206
|
-
cursor?: Lowercase<string> | undefined;
|
|
207
|
-
hash?: Lowercase<string> | undefined;
|
|
208
204
|
budget?: number | undefined;
|
|
209
205
|
maxFrequency?: "once" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year" | undefined;
|
|
210
206
|
minBid?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../../src/StateToIndexCandidateDiviner/Diviner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAwB,MAAM,8BAA8B,CAAA;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAGnE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAA;AAErF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC/E,OAAO,KAAK,EAAE,yDAAyD,EAAE,MAAM,8CAA8C,CAAA;AAE7H,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,KAAK,EACV,MAAM,EAAE,gBAAgB,EAAE,WAAW,EACtC,MAAM,2BAA2B,CAAA;AAElC,OAAO,KAAK,EACV,OAAO,EAAE,MAAM,EACf,eAAe,EAChB,MAAM,4BAA4B,CAAA;AAGnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAG/D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,OAAO,GAAG,SAAS,CAAA;AAE/D;;GAEG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD;;OAEG;IACH,SAAS,EAAE,WAAW,CAAC,oBAAoB,CAAC;IAC5C;;OAEG;IACH,GAAG,cAAc,EAAE;CACpB,CAAA;AAYD;;GAEG;AACH,qBAAa,mDAAmD,CAC9D,OAAO,SAAS,yDAAyD,G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: "$.limit"
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
|
-
defaultValue: 0,
|
|
91
|
-
destinationField: "
|
|
92
|
-
sourcePathExpression: "$.
|
|
90
|
+
// defaultValue: 0,
|
|
91
|
+
destinationField: "cursor",
|
|
92
|
+
sourcePathExpression: "$.cursor"
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
defaultValue: "desc",
|
|
@@ -110,7 +110,7 @@ var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class extends Abstr
|
|
|
110
110
|
this.indexSchema
|
|
111
111
|
];
|
|
112
112
|
delete fields.sources;
|
|
113
|
-
return
|
|
113
|
+
return new PayloadBuilder({
|
|
114
114
|
schema: this.indexQuerySchema
|
|
115
115
|
}).fields(fields).build();
|
|
116
116
|
}));
|
|
@@ -189,7 +189,7 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
const indexes =
|
|
192
|
+
const indexes = validIndexableTuples.map(([bwHash, ...sourcePayloadHashes]) => {
|
|
193
193
|
const sourcePayloads = sourcePayloadHashes.map((hash) => payloadDictionary[hash]);
|
|
194
194
|
const indexFields = sourcePayloads.flatMap((payload) => {
|
|
195
195
|
const transformers = this.payloadTransformers[payload.schema];
|
|
@@ -199,12 +199,12 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
|
|
|
199
199
|
bwHash,
|
|
200
200
|
...sourcePayloadHashes
|
|
201
201
|
];
|
|
202
|
-
return
|
|
202
|
+
return new PayloadBuilder2({
|
|
203
203
|
schema: TemporalIndexingDivinerResultIndexSchema2
|
|
204
204
|
}).fields(Object.assign({
|
|
205
205
|
sources
|
|
206
206
|
}, ...indexFields)).build();
|
|
207
|
-
})
|
|
207
|
+
});
|
|
208
208
|
return indexes.flat();
|
|
209
209
|
}
|
|
210
210
|
/**
|
|
@@ -253,7 +253,7 @@ import { filterAs } from "@xylabs/array";
|
|
|
253
253
|
import { assertEx as assertEx2 } from "@xylabs/assert";
|
|
254
254
|
import { exists as exists2 } from "@xylabs/exists";
|
|
255
255
|
import { ArchivistWrapper } from "@xyo-network/archivist-wrapper";
|
|
256
|
-
import { asBoundWitness
|
|
256
|
+
import { asBoundWitness } from "@xyo-network/boundwitness-model";
|
|
257
257
|
import { payloadSchemasContainsAll } from "@xyo-network/boundwitness-validator";
|
|
258
258
|
import { AbstractDiviner as AbstractDiviner4 } from "@xyo-network/diviner-abstract";
|
|
259
259
|
import { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from "@xyo-network/diviner-temporal-indexing-model";
|
|
@@ -312,8 +312,7 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends Abstract
|
|
|
312
312
|
lastState
|
|
313
313
|
];
|
|
314
314
|
const batch = filterAs(next, asBoundWitness).filter(exists2).filter((bw) => payloadSchemasContainsAll(bw, this.payload_schemas));
|
|
315
|
-
const
|
|
316
|
-
const indexCandidates = (await Promise.all(bws.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))).filter(exists2).flat();
|
|
315
|
+
const indexCandidates = (await Promise.all(batch.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))).filter(exists2).flat();
|
|
317
316
|
const nextCursor = assertEx2(next.at(-1)?._sequence, () => `${moduleName2}: Expected next to have a sequence`);
|
|
318
317
|
const nextState = {
|
|
319
318
|
schema: ModuleStateSchema,
|
|
@@ -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 type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport type { TemporalIndexingDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { TemporalIndexingDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport type { 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 type { Hash } from '@xylabs/hex'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport type { PayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'\nimport { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport type { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } 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 return 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 }\n return []\n }\n}\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport type {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport type { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isAnyPayload } 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 // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = payloads\n .filter(isBoundWitness)\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 = payloads.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 type { Labels } from '@xyo-network/module-model'\nimport type { 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\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 { filterAs } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport type { ArchivistInstance, ArchivistNextOptions } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { asBoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { payloadSchemasContainsAll } from '@xyo-network/boundwitness-validator'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'\nimport type { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport type {\n Labels, ModuleIdentifier, ModuleState,\n} from '@xyo-network/module-model'\nimport { isModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport type {\n Payload, Schema,\n WithStorageMeta,\n} from '@xyo-network/payload-model'\nimport { SequenceConstants } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\nimport type { TimeStamp } from '@xyo-network/witness-timestamp'\nimport { 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<TemporalStateToIndexCandidateDivinerResponse> {\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 ?? { schema: ModuleStateSchema, state: { cursor: SequenceConstants.minLocalSequence } }\n\n // Get the last cursor\n const cursor = lastState?.state?.cursor\n // Get the archivist for the store\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n\n // Get the next batch of results\n const nextOffset: ArchivistNextOptions = { limit: this.payloadDivinerLimit, order }\n // Only use the cursor if it's a valid offset\n if (cursor !== SequenceConstants.minLocalSequence) nextOffset.cursor = cursor\n // Get next batch of results starting from the offset\n const next = await sourceArchivist.next(nextOffset)\n if (next.length === 0) return [lastState]\n const batch = filterAs(next, asBoundWitness)\n .filter(exists)\n .filter(bw => payloadSchemasContainsAll(bw, this.payload_schemas))\n // Get source data\n const bws = batch.filter(isBoundWitness)\n const indexCandidates: IndexCandidate[] = (await Promise.all(bws.map(bw => this.getPayloadsInBoundWitness(bw, sourceArchivist))))\n .filter(exists)\n .flat()\n const nextCursor = assertEx(next.at(-1)?._sequence, () => `${moduleName}: Expected next to have a sequence`)\n const nextState: ModuleState<IndexingDivinerState> = { schema: ModuleStateSchema, state: { ...lastState.state, cursor: nextCursor } }\n return [nextState, ...indexCandidates]\n }\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 WithStorageMeta<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;AAGhC,SAASC,2CAA2C;AAG7C,IAAMC,0BAAN,cASGC,gBAAAA;EAfV,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chema","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","Promise","all","map","query","fields","reducePayloads","schemas","sources","PayloadBuilder","schema","build","containsAll","assertEx","exists","isBoundWitness","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","indexableBoundWitnesses","filter","isBoundWitness","bw","containsAll","payload_schemas","indexablePayloads","p","isIndexablePayload","length","bwDictionary","payloadDictionary","Promise","all","PayloadBuilder","toDataHashMap","validIndexableTuples","bwHash","entries","combinations","intraBoundwitnessSchemaCombinations","combination","map","hash","exists","push","indexes","sourcePayloadHashes","sourcePayloads","indexFields","flatMap","payload","transformers","schema","transform","sources","TemporalIndexingDivinerResultIndexSchema","fields","assign","build","flat","x","isAnyPayload","includes","isIndexableSchema","AbstractDiviner","isPayloadDivinerQueryPayload","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","defaultConfigSchema","labels","divineHandler","payloads","responses","filter","p","isPayloadDivinerQueryPayload","Promise","resolve","filterAs","assertEx","exists","ArchivistWrapper","asBoundWitness","isBoundWitness","payloadSchemasContainsAll","AbstractDiviner","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","DivinerWrapper","isModuleState","ModuleStateSchema","SequenceConstants","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","cursor","SequenceConstants","minLocalSequence","sourceArchivist","getArchivistForStore","nextOffset","limit","next","length","batch","filterAs","asBoundWitness","exists","bw","payloadSchemasContainsAll","bws","isBoundWitness","indexCandidates","Promise","all","map","getPayloadsInBoundWitness","flat","nextCursor","assertEx","at","_sequence","nextState","name","payloadStore","archivist","mod","resolve","undefined","ArchivistWrapper","wrap","account","getBoundWitnessDivinerForStore","boundWitnessDiviner","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 type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport type { TemporalIndexingDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { TemporalIndexingDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport type { 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 type { Hash } from '@xylabs/hex'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport type { PayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'\nimport { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport type { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } 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: 'cursor',\n sourcePathExpression: '$.cursor',\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 return 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 new PayloadBuilder<Payload>({ schema: this.indexQuerySchema }).fields(fields).build()\n }),\n )\n }\n return []\n }\n}\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport type {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport type { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isAnyPayload } 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 // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = payloads\n .filter(isBoundWitness)\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 = payloads.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 = validIndexableTuples.map<TemporalIndexingDivinerResultIndex>(([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: Hash[] = [bwHash, ...sourcePayloadHashes]\n // Build and return the index\n return new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })\n .fields(Object.assign({ sources }, ...indexFields))\n .build()\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 type { Labels } from '@xyo-network/module-model'\nimport type { 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\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 { filterAs } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport type { ArchivistInstance, ArchivistNextOptions } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { asBoundWitness } from '@xyo-network/boundwitness-model'\nimport { payloadSchemasContainsAll } from '@xyo-network/boundwitness-validator'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'\nimport type { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport type {\n Labels, ModuleIdentifier, ModuleState,\n} from '@xyo-network/module-model'\nimport { isModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport type {\n Payload, Schema,\n WithStorageMeta,\n} from '@xyo-network/payload-model'\nimport { SequenceConstants } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\nimport type { TimeStamp } from '@xyo-network/witness-timestamp'\nimport { 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<TemporalStateToIndexCandidateDivinerResponse> {\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 ?? { schema: ModuleStateSchema, state: { cursor: SequenceConstants.minLocalSequence } }\n\n // Get the last cursor\n const cursor = lastState?.state?.cursor\n // Get the archivist for the store\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n\n // Get the next batch of results\n const nextOffset: ArchivistNextOptions = { limit: this.payloadDivinerLimit, order }\n // Only use the cursor if it's a valid offset\n if (cursor !== SequenceConstants.minLocalSequence) nextOffset.cursor = cursor\n // Get next batch of results starting from the offset\n const next = await sourceArchivist.next(nextOffset)\n if (next.length === 0) return [lastState]\n\n const batch = filterAs(next, asBoundWitness)\n .filter(exists)\n .filter(bw => payloadSchemasContainsAll(bw, this.payload_schemas))\n // Get source data\n const indexCandidates: IndexCandidate[] = (await Promise.all(batch.map(bw => this.getPayloadsInBoundWitness(bw, sourceArchivist))))\n .filter(exists)\n .flat()\n const nextCursor = assertEx(next.at(-1)?._sequence, () => `${moduleName}: Expected next to have a sequence`)\n const nextState: ModuleState<IndexingDivinerState> = { schema: ModuleStateSchema, state: { ...lastState.state, cursor: nextCursor } }\n return [nextState, ...indexCandidates]\n }\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 WithStorageMeta<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;AAGhC,SAASC,2CAA2C;AAG7C,IAAMC,0BAAN,cASGC,gBAAAA;EAfV,OAeUA;;;EACR,OAAyBC,gBAA0B;OAAI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C,WAAW,MAAM,GAAG7C,WAAAA,oCAA8C;AAC3G,UAAM8C,YAA+C;MAAE5B,QAAQC;MAAmBC,OAAO;QAAE,GAAGL,UAAUK;QAAOC,QAAQqB;MAAW;IAAE;AACpI,WAAO;MAACI;SAAcV;;EACxB;;;;;EAMA,MAAgBX,uBAA8D;AAE5E,UAAMsB,OAAyBJ,UAC7B,KAAKnC,QAAQwC,cAAcC,WAC3B,MAAM,GAAGjD,WAAAA,mDAA6D;AAGxE,UAAMkD,MAAM,MAAM,KAAKC,QAAQJ,IAAAA;AAC/B,QAAI,CAACG,IAAK,QAAOE;AAEjB,WAAOC,iBAAiBC,KAAKJ,KAAK,KAAKK,OAAO;EAChD;;;;;EAMA,MAAgBC,iCAAiC;AAE/C,UAAMT,OAAyBJ,UAC7B,KAAKnC,QAAQwC,cAAcS,qBAC3B,MAAM,GAAGzD,WAAAA,6DAAuE;AAGlF,UAAMkD,MAAM,MAAM,KAAKC,QAAQJ,IAAAA;AAC/B,QAAI,CAACG,IAAK;AAEV,WAAOQ,eAAeJ,KAMpBJ,KAAK,KAAKK,OAAO;EACrB;EAEA,MAAgBf,0BAA0BN,IAAkBe,WAAqE;AAC/H,UAAMU,eAAeC,qCAAoC1B,IAAI,KAAKzB,eAAe,EAAEgC,KAAI;AACvF,QAAIkB,aAAa9B,WAAW,EAAG,QAAOuB;AACtC,UAAMS,SAAS,IAAIC,IAAIH,YAAAA;AACvB,UAAMvB,kBAAkB,MAAMa,UAAUc,IAAI;SAAIF;KAAO;AACvD,WAAO;MAAC3B;SAAOE;;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","Promise","all","map","query","fields","reducePayloads","schemas","sources","PayloadBuilder","schema","build","containsAll","assertEx","exists","isBoundWitness","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","indexableBoundWitnesses","filter","isBoundWitness","bw","containsAll","payload_schemas","indexablePayloads","p","isIndexablePayload","length","bwDictionary","payloadDictionary","Promise","all","PayloadBuilder","toDataHashMap","validIndexableTuples","bwHash","entries","combinations","intraBoundwitnessSchemaCombinations","combination","map","hash","exists","push","indexes","sourcePayloadHashes","sourcePayloads","indexFields","flatMap","payload","transformers","schema","transform","sources","TemporalIndexingDivinerResultIndexSchema","fields","assign","build","flat","x","isAnyPayload","includes","isIndexableSchema","AbstractDiviner","isPayloadDivinerQueryPayload","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","defaultConfigSchema","labels","divineHandler","payloads","responses","filter","p","isPayloadDivinerQueryPayload","Promise","resolve","filterAs","assertEx","exists","ArchivistWrapper","asBoundWitness","payloadSchemasContainsAll","AbstractDiviner","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","DivinerWrapper","isModuleState","ModuleStateSchema","SequenceConstants","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","cursor","SequenceConstants","minLocalSequence","sourceArchivist","getArchivistForStore","nextOffset","limit","next","length","batch","filterAs","asBoundWitness","exists","bw","payloadSchemasContainsAll","indexCandidates","Promise","all","map","getPayloadsInBoundWitness","flat","nextCursor","assertEx","at","_sequence","nextState","name","payloadStore","archivist","mod","resolve","undefined","ArchivistWrapper","wrap","account","getBoundWitnessDivinerForStore","boundWitnessDiviner","DivinerWrapper","combinations","intraBoundwitnessSchemaCombinations","hashes","Set","get"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../../src/IndexCandidateToIndexDiviner/Diviner.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D,OAAO,KAAK,EAAE,8CAA8C,EAAE,qCAAqC,EAAE,MAAM,qCAAqC,CAAA;AAChJ,OAAO,KAAK,EACV,yDAAyD,EAE1D,MAAM,8CAA8C,CAAA;AAKrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAEvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAQjE;;;;GAIG;AACH,qBAAa,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,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;IAuDpF;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,MAAO,OAAO,aAEzC;IAED;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,YAAa,MAAM,GAAG,IAAI,aAEpD;CACF"}
|
|
@@ -101,10 +101,9 @@ export declare class TemporalIndexingDivinerStateToIndexCandidateDiviner<TParams
|
|
|
101
101
|
payload_schemas?: string[] | undefined;
|
|
102
102
|
previous_hashes?: import("@xylabs/object").DeepRestrictToStringKeys<Lowercase<string> | null>[] | undefined;
|
|
103
103
|
limit?: number | undefined;
|
|
104
|
+
cursor?: Lowercase<string> | undefined;
|
|
104
105
|
order?: import("@xyo-network/diviner-payload-model").Order | undefined;
|
|
105
106
|
address?: Lowercase<string> | Lowercase<string>[] | undefined;
|
|
106
|
-
cursor?: Lowercase<string> | undefined;
|
|
107
|
-
hash?: Lowercase<string> | undefined;
|
|
108
107
|
budget?: number | undefined;
|
|
109
108
|
maxFrequency?: "once" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year" | undefined;
|
|
110
109
|
minBid?: number | undefined;
|
|
@@ -163,10 +162,9 @@ export declare class TemporalIndexingDivinerStateToIndexCandidateDiviner<TParams
|
|
|
163
162
|
payload_schemas?: string[] | undefined;
|
|
164
163
|
previous_hashes?: import("@xylabs/object").DeepRestrictToStringKeys<Lowercase<string> | null>[] | undefined;
|
|
165
164
|
limit?: number | undefined;
|
|
165
|
+
cursor?: Lowercase<string> | undefined;
|
|
166
166
|
order?: import("@xyo-network/diviner-payload-model").Order | undefined;
|
|
167
167
|
address?: Lowercase<string> | Lowercase<string>[] | undefined;
|
|
168
|
-
cursor?: Lowercase<string> | undefined;
|
|
169
|
-
hash?: Lowercase<string> | undefined;
|
|
170
168
|
budget?: number | undefined;
|
|
171
169
|
maxFrequency?: "once" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year" | undefined;
|
|
172
170
|
minBid?: number | undefined;
|
|
@@ -182,10 +180,9 @@ export declare class TemporalIndexingDivinerStateToIndexCandidateDiviner<TParams
|
|
|
182
180
|
payload_schemas?: string[] | undefined;
|
|
183
181
|
previous_hashes?: import("@xylabs/object").DeepRestrictToStringKeys<Lowercase<string> | null>[] | undefined;
|
|
184
182
|
limit?: number | undefined;
|
|
183
|
+
cursor?: Lowercase<string> | undefined;
|
|
185
184
|
order?: import("@xyo-network/diviner-payload-model").Order | undefined;
|
|
186
185
|
address?: Lowercase<string> | Lowercase<string>[] | undefined;
|
|
187
|
-
cursor?: Lowercase<string> | undefined;
|
|
188
|
-
hash?: Lowercase<string> | undefined;
|
|
189
186
|
budget?: number | undefined;
|
|
190
187
|
maxFrequency?: "once" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year" | undefined;
|
|
191
188
|
minBid?: number | undefined;
|
|
@@ -201,10 +198,9 @@ export declare class TemporalIndexingDivinerStateToIndexCandidateDiviner<TParams
|
|
|
201
198
|
payload_schemas?: string[] | undefined;
|
|
202
199
|
previous_hashes?: import("@xylabs/object").DeepRestrictToStringKeys<Lowercase<string> | null>[] | undefined;
|
|
203
200
|
limit?: number | undefined;
|
|
201
|
+
cursor?: Lowercase<string> | undefined;
|
|
204
202
|
order?: import("@xyo-network/diviner-payload-model").Order | undefined;
|
|
205
203
|
address?: Lowercase<string> | Lowercase<string>[] | undefined;
|
|
206
|
-
cursor?: Lowercase<string> | undefined;
|
|
207
|
-
hash?: Lowercase<string> | undefined;
|
|
208
204
|
budget?: number | undefined;
|
|
209
205
|
maxFrequency?: "once" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year" | undefined;
|
|
210
206
|
minBid?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../../src/StateToIndexCandidateDiviner/Diviner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAwB,MAAM,8BAA8B,CAAA;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAGnE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAA;AAErF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC/E,OAAO,KAAK,EAAE,yDAAyD,EAAE,MAAM,8CAA8C,CAAA;AAE7H,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,KAAK,EACV,MAAM,EAAE,gBAAgB,EAAE,WAAW,EACtC,MAAM,2BAA2B,CAAA;AAElC,OAAO,KAAK,EACV,OAAO,EAAE,MAAM,EACf,eAAe,EAChB,MAAM,4BAA4B,CAAA;AAGnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAG/D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,OAAO,GAAG,SAAS,CAAA;AAE/D;;GAEG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD;;OAEG;IACH,SAAS,EAAE,WAAW,CAAC,oBAAoB,CAAC;IAC5C;;OAEG;IACH,GAAG,cAAc,EAAE;CACpB,CAAA;AAYD;;GAEG;AACH,qBAAa,mDAAmD,CAC9D,OAAO,SAAS,yDAAyD,GAAG,yDAAyD,CACrI,SAAQ,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC;IACvE,g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,CAAA;AAE/D;;GAEG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD;;OAEG;IACH,SAAS,EAAE,WAAW,CAAC,oBAAoB,CAAC;IAC5C;;OAEG;IACH,GAAG,cAAc,EAAE;CACpB,CAAA;AAYD;;GAEG;AACH,qBAAa,mDAAmD,CAC9D,OAAO,SAAS,yDAAyD,GAAG,yDAAyD,CACrI,SAAQ,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC;IACvE,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA4F;IAC5I,gBAAyB,mBAAmB,EAAE,MAAM,CAAkE;IACtH,OAAgB,MAAM,EAAE,MAAM,CAG7B;IAED,IAAI,mBAAmB,WAEtB;IAED;;OAEG;IACH,SAAS,KAAK,eAAe,IAAI,MAAM,EAAE,CAGxC;cAEwB,aAAa,CAAC,QAAQ,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,4CAA4C,CAAC;IAgCvH;;;OAGG;cACa,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAa7E;;;OAGG;cACa,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmB9B,yBAAyB,CAAC,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,EAAE,GAAG,SAAS,CAAC;CAOjI"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -87,9 +87,9 @@ var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class extends Abstr
|
|
|
87
87
|
sourcePathExpression: "$.limit"
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
|
-
defaultValue: 0,
|
|
91
|
-
destinationField: "
|
|
92
|
-
sourcePathExpression: "$.
|
|
90
|
+
// defaultValue: 0,
|
|
91
|
+
destinationField: "cursor",
|
|
92
|
+
sourcePathExpression: "$.cursor"
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
defaultValue: "desc",
|
|
@@ -110,7 +110,7 @@ var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class extends Abstr
|
|
|
110
110
|
this.indexSchema
|
|
111
111
|
];
|
|
112
112
|
delete fields.sources;
|
|
113
|
-
return
|
|
113
|
+
return new PayloadBuilder({
|
|
114
114
|
schema: this.indexQuerySchema
|
|
115
115
|
}).fields(fields).build();
|
|
116
116
|
}));
|
|
@@ -189,7 +189,7 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
const indexes =
|
|
192
|
+
const indexes = validIndexableTuples.map(([bwHash, ...sourcePayloadHashes]) => {
|
|
193
193
|
const sourcePayloads = sourcePayloadHashes.map((hash) => payloadDictionary[hash]);
|
|
194
194
|
const indexFields = sourcePayloads.flatMap((payload) => {
|
|
195
195
|
const transformers = this.payloadTransformers[payload.schema];
|
|
@@ -199,12 +199,12 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
|
|
|
199
199
|
bwHash,
|
|
200
200
|
...sourcePayloadHashes
|
|
201
201
|
];
|
|
202
|
-
return
|
|
202
|
+
return new PayloadBuilder2({
|
|
203
203
|
schema: TemporalIndexingDivinerResultIndexSchema2
|
|
204
204
|
}).fields(Object.assign({
|
|
205
205
|
sources
|
|
206
206
|
}, ...indexFields)).build();
|
|
207
|
-
})
|
|
207
|
+
});
|
|
208
208
|
return indexes.flat();
|
|
209
209
|
}
|
|
210
210
|
/**
|
|
@@ -253,7 +253,7 @@ import { filterAs } from "@xylabs/array";
|
|
|
253
253
|
import { assertEx as assertEx2 } from "@xylabs/assert";
|
|
254
254
|
import { exists as exists2 } from "@xylabs/exists";
|
|
255
255
|
import { ArchivistWrapper } from "@xyo-network/archivist-wrapper";
|
|
256
|
-
import { asBoundWitness
|
|
256
|
+
import { asBoundWitness } from "@xyo-network/boundwitness-model";
|
|
257
257
|
import { payloadSchemasContainsAll } from "@xyo-network/boundwitness-validator";
|
|
258
258
|
import { AbstractDiviner as AbstractDiviner4 } from "@xyo-network/diviner-abstract";
|
|
259
259
|
import { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from "@xyo-network/diviner-temporal-indexing-model";
|
|
@@ -312,8 +312,7 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends Abstract
|
|
|
312
312
|
lastState
|
|
313
313
|
];
|
|
314
314
|
const batch = filterAs(next, asBoundWitness).filter(exists2).filter((bw) => payloadSchemasContainsAll(bw, this.payload_schemas));
|
|
315
|
-
const
|
|
316
|
-
const indexCandidates = (await Promise.all(bws.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))).filter(exists2).flat();
|
|
315
|
+
const indexCandidates = (await Promise.all(batch.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))).filter(exists2).flat();
|
|
317
316
|
const nextCursor = assertEx2(next.at(-1)?._sequence, () => `${moduleName2}: Expected next to have a sequence`);
|
|
318
317
|
const nextState = {
|
|
319
318
|
schema: ModuleStateSchema,
|
|
@@ -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 type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport type { TemporalIndexingDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { TemporalIndexingDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport type { 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 type { Hash } from '@xylabs/hex'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport type { PayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'\nimport { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport type { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } 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 return 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 }\n return []\n }\n}\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport type {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport type { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isAnyPayload } 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 // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = payloads\n .filter(isBoundWitness)\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 = payloads.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 type { Labels } from '@xyo-network/module-model'\nimport type { 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\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 { filterAs } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport type { ArchivistInstance, ArchivistNextOptions } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { asBoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { payloadSchemasContainsAll } from '@xyo-network/boundwitness-validator'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'\nimport type { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport type {\n Labels, ModuleIdentifier, ModuleState,\n} from '@xyo-network/module-model'\nimport { isModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport type {\n Payload, Schema,\n WithStorageMeta,\n} from '@xyo-network/payload-model'\nimport { SequenceConstants } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\nimport type { TimeStamp } from '@xyo-network/witness-timestamp'\nimport { 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<TemporalStateToIndexCandidateDivinerResponse> {\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 ?? { schema: ModuleStateSchema, state: { cursor: SequenceConstants.minLocalSequence } }\n\n // Get the last cursor\n const cursor = lastState?.state?.cursor\n // Get the archivist for the store\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n\n // Get the next batch of results\n const nextOffset: ArchivistNextOptions = { limit: this.payloadDivinerLimit, order }\n // Only use the cursor if it's a valid offset\n if (cursor !== SequenceConstants.minLocalSequence) nextOffset.cursor = cursor\n // Get next batch of results starting from the offset\n const next = await sourceArchivist.next(nextOffset)\n if (next.length === 0) return [lastState]\n const batch = filterAs(next, asBoundWitness)\n .filter(exists)\n .filter(bw => payloadSchemasContainsAll(bw, this.payload_schemas))\n // Get source data\n const bws = batch.filter(isBoundWitness)\n const indexCandidates: IndexCandidate[] = (await Promise.all(bws.map(bw => this.getPayloadsInBoundWitness(bw, sourceArchivist))))\n .filter(exists)\n .flat()\n const nextCursor = assertEx(next.at(-1)?._sequence, () => `${moduleName}: Expected next to have a sequence`)\n const nextState: ModuleState<IndexingDivinerState> = { schema: ModuleStateSchema, state: { ...lastState.state, cursor: nextCursor } }\n return [nextState, ...indexCandidates]\n }\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 WithStorageMeta<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;AAGhC,SAASC,2CAA2C;AAG7C,IAAMC,0BAAN,cASGC,gBAAAA;EAfV,OAeUA;;;EACR,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeC;;EAC5E,OAAyBC,sBAA8BD;EAEvD,MAAyBE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AAI;AACP,UAAMC,aAAaC,UAASjB,KAAKkB,GAAG,EAAC,GAAIC,WAAW,MAAM,GAAG/C,WAAAA,oCAA8C;AAC3G,UAAMgD,YAA+C;MAAE9B,QAAQC;MAAmBC,OAAO;QAAE,GAAGL,UAAUK;QAAOC,QAAQuB;MAAW;IAAE;AACpI,WAAO;MAACI;SAAcV;;EACxB;;;;;EAMA,MAAgBb,uBAA8D;AAE5E,UAAMwB,OAAyBJ,UAC7B,KAAKrC,QAAQ0C,cAAcC,WAC3B,MAAM,GAAGnD,WAAAA,mDAA6D;AAGxE,UAAMoD,MAAM,MAAM,KAAKC,QAAQJ,IAAAA;AAC/B,QAAI,CAACG,IAAK,QAAOE;AAEjB,WAAOC,iBAAiBC,KAAKJ,KAAK,KAAKK,OAAO;EAChD;;;;;EAMA,MAAgBC,iCAAiC;AAE/C,UAAMT,OAAyBJ,UAC7B,KAAKrC,QAAQ0C,cAAcS,qBAC3B,MAAM,GAAG3D,WAAAA,6DAAuE;AAGlF,UAAMoD,MAAM,MAAM,KAAKC,QAAQJ,IAAAA;AAC/B,QAAI,CAACG,IAAK;AAEV,WAAOQ,eAAeJ,KAMpBJ,KAAK,KAAKK,OAAO;EACrB;EAEA,MAAgBf,0BAA0BR,IAAkBiB,WAAqE;AAC/H,UAAMU,eAAeC,qCAAoC5B,IAAI,KAAKzB,eAAe,EAAEkC,KAAI;AACvF,QAAIkB,aAAahC,WAAW,EAAG,QAAOyB;AACtC,UAAMS,SAAS,IAAIC,IAAIH,YAAAA;AACvB,UAAMvB,kBAAkB,MAAMa,UAAUc,IAAI;SAAIF;KAAO;AACvD,WAAO;MAAC7B;SAAOI;;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","Promise","all","map","query","fields","reducePayloads","schemas","sources","PayloadBuilder","schema","build","containsAll","assertEx","exists","isBoundWitness","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","indexableBoundWitnesses","filter","isBoundWitness","bw","containsAll","payload_schemas","indexablePayloads","p","isIndexablePayload","length","bwDictionary","payloadDictionary","Promise","all","PayloadBuilder","toDataHashMap","validIndexableTuples","bwHash","entries","combinations","intraBoundwitnessSchemaCombinations","combination","map","hash","exists","push","indexes","sourcePayloadHashes","sourcePayloads","indexFields","flatMap","payload","transformers","schema","transform","sources","TemporalIndexingDivinerResultIndexSchema","fields","assign","build","flat","x","isAnyPayload","includes","isIndexableSchema","AbstractDiviner","isPayloadDivinerQueryPayload","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","defaultConfigSchema","labels","divineHandler","payloads","responses","filter","p","isPayloadDivinerQueryPayload","Promise","resolve","filterAs","assertEx","exists","ArchivistWrapper","asBoundWitness","isBoundWitness","payloadSchemasContainsAll","AbstractDiviner","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","DivinerWrapper","isModuleState","ModuleStateSchema","SequenceConstants","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","cursor","SequenceConstants","minLocalSequence","sourceArchivist","getArchivistForStore","nextOffset","limit","next","length","batch","filterAs","asBoundWitness","exists","bw","payloadSchemasContainsAll","bws","isBoundWitness","indexCandidates","Promise","all","map","getPayloadsInBoundWitness","flat","nextCursor","assertEx","at","_sequence","nextState","name","payloadStore","archivist","mod","resolve","undefined","ArchivistWrapper","wrap","account","getBoundWitnessDivinerForStore","boundWitnessDiviner","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 type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport type { TemporalIndexingDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { TemporalIndexingDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport type { 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 type { Hash } from '@xylabs/hex'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport type { PayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'\nimport { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport type { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } 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: 'cursor',\n sourcePathExpression: '$.cursor',\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 return 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 new PayloadBuilder<Payload>({ schema: this.indexQuerySchema }).fields(fields).build()\n }),\n )\n }\n return []\n }\n}\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport type {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport type { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isAnyPayload } 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 // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = payloads\n .filter(isBoundWitness)\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 = payloads.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 = validIndexableTuples.map<TemporalIndexingDivinerResultIndex>(([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: Hash[] = [bwHash, ...sourcePayloadHashes]\n // Build and return the index\n return new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })\n .fields(Object.assign({ sources }, ...indexFields))\n .build()\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 type { Labels } from '@xyo-network/module-model'\nimport type { 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\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 { filterAs } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport type { ArchivistInstance, ArchivistNextOptions } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { asBoundWitness } from '@xyo-network/boundwitness-model'\nimport { payloadSchemasContainsAll } from '@xyo-network/boundwitness-validator'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'\nimport type { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport type {\n Labels, ModuleIdentifier, ModuleState,\n} from '@xyo-network/module-model'\nimport { isModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport type {\n Payload, Schema,\n WithStorageMeta,\n} from '@xyo-network/payload-model'\nimport { SequenceConstants } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\nimport type { TimeStamp } from '@xyo-network/witness-timestamp'\nimport { 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<TemporalStateToIndexCandidateDivinerResponse> {\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 ?? { schema: ModuleStateSchema, state: { cursor: SequenceConstants.minLocalSequence } }\n\n // Get the last cursor\n const cursor = lastState?.state?.cursor\n // Get the archivist for the store\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n\n // Get the next batch of results\n const nextOffset: ArchivistNextOptions = { limit: this.payloadDivinerLimit, order }\n // Only use the cursor if it's a valid offset\n if (cursor !== SequenceConstants.minLocalSequence) nextOffset.cursor = cursor\n // Get next batch of results starting from the offset\n const next = await sourceArchivist.next(nextOffset)\n if (next.length === 0) return [lastState]\n\n const batch = filterAs(next, asBoundWitness)\n .filter(exists)\n .filter(bw => payloadSchemasContainsAll(bw, this.payload_schemas))\n // Get source data\n const indexCandidates: IndexCandidate[] = (await Promise.all(batch.map(bw => this.getPayloadsInBoundWitness(bw, sourceArchivist))))\n .filter(exists)\n .flat()\n const nextCursor = assertEx(next.at(-1)?._sequence, () => `${moduleName}: Expected next to have a sequence`)\n const nextState: ModuleState<IndexingDivinerState> = { schema: ModuleStateSchema, state: { ...lastState.state, cursor: nextCursor } }\n return [nextState, ...indexCandidates]\n }\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 WithStorageMeta<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;AAGhC,SAASC,2CAA2C;AAG7C,IAAMC,0BAAN,cASGC,gBAAAA;EAfV,OAeUA;;;EACR,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeC;;EAC5E,OAAyBC,sBAA8BD;EAEvD,MAAyBE,eAAiC;AACxD,UAAM,MAAMA,aAAAA;A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AAE,GAAGL,UAAUK;QAAOC,QAAQqB;MAAW;IAAE;AACpI,WAAO;MAACI;SAAcV;;EACxB;;;;;EAMA,MAAgBX,uBAA8D;AAE5E,UAAMsB,OAAyBJ,UAC7B,KAAKnC,QAAQwC,cAAcC,WAC3B,MAAM,GAAGjD,WAAAA,mDAA6D;AAGxE,UAAMkD,MAAM,MAAM,KAAKC,QAAQJ,IAAAA;AAC/B,QAAI,CAACG,IAAK,QAAOE;AAEjB,WAAOC,iBAAiBC,KAAKJ,KAAK,KAAKK,OAAO;EAChD;;;;;EAMA,MAAgBC,iCAAiC;AAE/C,UAAMT,OAAyBJ,UAC7B,KAAKnC,QAAQwC,cAAcS,qBAC3B,MAAM,GAAGzD,WAAAA,6DAAuE;AAGlF,UAAMkD,MAAM,MAAM,KAAKC,QAAQJ,IAAAA;AAC/B,QAAI,CAACG,IAAK;AAEV,WAAOQ,eAAeJ,KAMpBJ,KAAK,KAAKK,OAAO;EACrB;EAEA,MAAgBf,0BAA0BN,IAAkBe,WAAqE;AAC/H,UAAMU,eAAeC,qCAAoC1B,IAAI,KAAKzB,eAAe,EAAEgC,KAAI;AACvF,QAAIkB,aAAa9B,WAAW,EAAG,QAAOuB;AACtC,UAAMS,SAAS,IAAIC,IAAIH,YAAAA;AACvB,UAAMvB,kBAAkB,MAAMa,UAAUc,IAAI;SAAIF;KAAO;AACvD,WAAO;MAAC3B;SAAOE;;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","Promise","all","map","query","fields","reducePayloads","schemas","sources","PayloadBuilder","schema","build","containsAll","assertEx","exists","isBoundWitness","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","indexableBoundWitnesses","filter","isBoundWitness","bw","containsAll","payload_schemas","indexablePayloads","p","isIndexablePayload","length","bwDictionary","payloadDictionary","Promise","all","PayloadBuilder","toDataHashMap","validIndexableTuples","bwHash","entries","combinations","intraBoundwitnessSchemaCombinations","combination","map","hash","exists","push","indexes","sourcePayloadHashes","sourcePayloads","indexFields","flatMap","payload","transformers","schema","transform","sources","TemporalIndexingDivinerResultIndexSchema","fields","assign","build","flat","x","isAnyPayload","includes","isIndexableSchema","AbstractDiviner","isPayloadDivinerQueryPayload","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","defaultConfigSchema","labels","divineHandler","payloads","responses","filter","p","isPayloadDivinerQueryPayload","Promise","resolve","filterAs","assertEx","exists","ArchivistWrapper","asBoundWitness","payloadSchemasContainsAll","AbstractDiviner","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","DivinerWrapper","isModuleState","ModuleStateSchema","SequenceConstants","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","cursor","SequenceConstants","minLocalSequence","sourceArchivist","getArchivistForStore","nextOffset","limit","next","length","batch","filterAs","asBoundWitness","exists","bw","payloadSchemasContainsAll","indexCandidates","Promise","all","map","getPayloadsInBoundWitness","flat","nextCursor","assertEx","at","_sequence","nextState","name","payloadStore","archivist","mod","resolve","undefined","ArchivistWrapper","wrap","account","getBoundWitnessDivinerForStore","boundWitnessDiviner","DivinerWrapper","combinations","intraBoundwitnessSchemaCombinations","hashes","Set","get"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../../src/IndexCandidateToIndexDiviner/Diviner.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAE/D,OAAO,KAAK,EAAE,8CAA8C,EAAE,qCAAqC,EAAE,MAAM,qCAAqC,CAAA;AAChJ,OAAO,KAAK,EACV,yDAAyD,EAE1D,MAAM,8CAA8C,CAAA;AAKrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAEvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAQjE;;;;GAIG;AACH,qBAAa,mDAAmD,CAC9D,OAAO,SAAS,yDAAyD,GAAG,yDAAyD,CACrI,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC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M,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;IAuDpF;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,MAAO,OAAO,aAEzC;IAED;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,YAAa,MAAM,GAAG,IAAI,aAEpD;CACF"}
|
|
@@ -101,10 +101,9 @@ export declare class TemporalIndexingDivinerStateToIndexCandidateDiviner<TParams
|
|
|
101
101
|
payload_schemas?: string[] | undefined;
|
|
102
102
|
previous_hashes?: import("@xylabs/object").DeepRestrictToStringKeys<Lowercase<string> | null>[] | undefined;
|
|
103
103
|
limit?: number | undefined;
|
|
104
|
+
cursor?: Lowercase<string> | undefined;
|
|
104
105
|
order?: import("@xyo-network/diviner-payload-model").Order | undefined;
|
|
105
106
|
address?: Lowercase<string> | Lowercase<string>[] | undefined;
|
|
106
|
-
cursor?: Lowercase<string> | undefined;
|
|
107
|
-
hash?: Lowercase<string> | undefined;
|
|
108
107
|
budget?: number | undefined;
|
|
109
108
|
maxFrequency?: "once" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year" | undefined;
|
|
110
109
|
minBid?: number | undefined;
|
|
@@ -163,10 +162,9 @@ export declare class TemporalIndexingDivinerStateToIndexCandidateDiviner<TParams
|
|
|
163
162
|
payload_schemas?: string[] | undefined;
|
|
164
163
|
previous_hashes?: import("@xylabs/object").DeepRestrictToStringKeys<Lowercase<string> | null>[] | undefined;
|
|
165
164
|
limit?: number | undefined;
|
|
165
|
+
cursor?: Lowercase<string> | undefined;
|
|
166
166
|
order?: import("@xyo-network/diviner-payload-model").Order | undefined;
|
|
167
167
|
address?: Lowercase<string> | Lowercase<string>[] | undefined;
|
|
168
|
-
cursor?: Lowercase<string> | undefined;
|
|
169
|
-
hash?: Lowercase<string> | undefined;
|
|
170
168
|
budget?: number | undefined;
|
|
171
169
|
maxFrequency?: "once" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year" | undefined;
|
|
172
170
|
minBid?: number | undefined;
|
|
@@ -182,10 +180,9 @@ export declare class TemporalIndexingDivinerStateToIndexCandidateDiviner<TParams
|
|
|
182
180
|
payload_schemas?: string[] | undefined;
|
|
183
181
|
previous_hashes?: import("@xylabs/object").DeepRestrictToStringKeys<Lowercase<string> | null>[] | undefined;
|
|
184
182
|
limit?: number | undefined;
|
|
183
|
+
cursor?: Lowercase<string> | undefined;
|
|
185
184
|
order?: import("@xyo-network/diviner-payload-model").Order | undefined;
|
|
186
185
|
address?: Lowercase<string> | Lowercase<string>[] | undefined;
|
|
187
|
-
cursor?: Lowercase<string> | undefined;
|
|
188
|
-
hash?: Lowercase<string> | undefined;
|
|
189
186
|
budget?: number | undefined;
|
|
190
187
|
maxFrequency?: "once" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year" | undefined;
|
|
191
188
|
minBid?: number | undefined;
|
|
@@ -201,10 +198,9 @@ export declare class TemporalIndexingDivinerStateToIndexCandidateDiviner<TParams
|
|
|
201
198
|
payload_schemas?: string[] | undefined;
|
|
202
199
|
previous_hashes?: import("@xylabs/object").DeepRestrictToStringKeys<Lowercase<string> | null>[] | undefined;
|
|
203
200
|
limit?: number | undefined;
|
|
201
|
+
cursor?: Lowercase<string> | undefined;
|
|
204
202
|
order?: import("@xyo-network/diviner-payload-model").Order | undefined;
|
|
205
203
|
address?: Lowercase<string> | Lowercase<string>[] | undefined;
|
|
206
|
-
cursor?: Lowercase<string> | undefined;
|
|
207
|
-
hash?: Lowercase<string> | undefined;
|
|
208
204
|
budget?: number | undefined;
|
|
209
205
|
maxFrequency?: "once" | "second" | "minute" | "hour" | "day" | "week" | "month" | "year" | undefined;
|
|
210
206
|
minBid?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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C,oBAAoB,CAAC;IAC5C;;OAEG;IACH,GAAG,cAAc,EAAE;CACpB,CAAA;AAYD;;GAEG;AACH,qBAAa,mDAAmD,CAC9D,OAAO,SAAS,yDAAyD,GAAG,yDAAyD,CACrI,SAAQ,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC;IACvE,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA4F;IAC5I,gBAAyB,mBAAmB,EAAE,MAAM,CAAkE;IACtH,OAAgB,MAAM,EAAE,MAAM,CAG7B;IAED,IAAI,mBAAmB,WAEtB;IAED;;OAEG;IACH,SAAS,KAAK,eAAe,IAAI,MAAM,EAAE,CAGxC;cAEwB,aAAa,CAAC,QAAQ,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,4CAA4C,CAAC;IAgCvH;;;OAGG;cACa,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAa7E;;;OAGG;cACa,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmB9B,yBAAyB,CAAC,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,EAAE,GAAG,SAAS,CAAC;CAOjI"}
|
package/dist/node/index.mjs
CHANGED
|
@@ -87,9 +87,9 @@ var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class extends Abstr
|
|
|
87
87
|
sourcePathExpression: "$.limit"
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
|
-
defaultValue: 0,
|
|
91
|
-
destinationField: "
|
|
92
|
-
sourcePathExpression: "$.
|
|
90
|
+
// defaultValue: 0,
|
|
91
|
+
destinationField: "cursor",
|
|
92
|
+
sourcePathExpression: "$.cursor"
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
defaultValue: "desc",
|
|
@@ -110,7 +110,7 @@ var TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner = class extends Abstr
|
|
|
110
110
|
this.indexSchema
|
|
111
111
|
];
|
|
112
112
|
delete fields.sources;
|
|
113
|
-
return
|
|
113
|
+
return new PayloadBuilder({
|
|
114
114
|
schema: this.indexQuerySchema
|
|
115
115
|
}).fields(fields).build();
|
|
116
116
|
}));
|
|
@@ -189,7 +189,7 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
const indexes =
|
|
192
|
+
const indexes = validIndexableTuples.map(([bwHash, ...sourcePayloadHashes]) => {
|
|
193
193
|
const sourcePayloads = sourcePayloadHashes.map((hash) => payloadDictionary[hash]);
|
|
194
194
|
const indexFields = sourcePayloads.flatMap((payload) => {
|
|
195
195
|
const transformers = this.payloadTransformers[payload.schema];
|
|
@@ -199,12 +199,12 @@ var TemporalIndexingDivinerIndexCandidateToIndexDiviner = class extends Abstract
|
|
|
199
199
|
bwHash,
|
|
200
200
|
...sourcePayloadHashes
|
|
201
201
|
];
|
|
202
|
-
return
|
|
202
|
+
return new PayloadBuilder2({
|
|
203
203
|
schema: TemporalIndexingDivinerResultIndexSchema2
|
|
204
204
|
}).fields(Object.assign({
|
|
205
205
|
sources
|
|
206
206
|
}, ...indexFields)).build();
|
|
207
|
-
})
|
|
207
|
+
});
|
|
208
208
|
return indexes.flat();
|
|
209
209
|
}
|
|
210
210
|
/**
|
|
@@ -253,7 +253,7 @@ import { filterAs } from "@xylabs/array";
|
|
|
253
253
|
import { assertEx as assertEx2 } from "@xylabs/assert";
|
|
254
254
|
import { exists as exists2 } from "@xylabs/exists";
|
|
255
255
|
import { ArchivistWrapper } from "@xyo-network/archivist-wrapper";
|
|
256
|
-
import { asBoundWitness
|
|
256
|
+
import { asBoundWitness } from "@xyo-network/boundwitness-model";
|
|
257
257
|
import { payloadSchemasContainsAll } from "@xyo-network/boundwitness-validator";
|
|
258
258
|
import { AbstractDiviner as AbstractDiviner4 } from "@xyo-network/diviner-abstract";
|
|
259
259
|
import { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from "@xyo-network/diviner-temporal-indexing-model";
|
|
@@ -312,8 +312,7 @@ var TemporalIndexingDivinerStateToIndexCandidateDiviner = class extends Abstract
|
|
|
312
312
|
lastState
|
|
313
313
|
];
|
|
314
314
|
const batch = filterAs(next, asBoundWitness).filter(exists2).filter((bw) => payloadSchemasContainsAll(bw, this.payload_schemas));
|
|
315
|
-
const
|
|
316
|
-
const indexCandidates = (await Promise.all(bws.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))).filter(exists2).flat();
|
|
315
|
+
const indexCandidates = (await Promise.all(batch.map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))).filter(exists2).flat();
|
|
317
316
|
const nextCursor = assertEx2(next.at(-1)?._sequence, () => `${moduleName2}: Expected next to have a sequence`);
|
|
318
317
|
const nextState = {
|
|
319
318
|
schema: ModuleStateSchema,
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -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 type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport type { TemporalIndexingDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { TemporalIndexingDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport type { 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 type { Hash } from '@xylabs/hex'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport type { PayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'\nimport { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport type { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } 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 return 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 }\n return []\n }\n}\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport type {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport type { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isAnyPayload } 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 // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = payloads\n .filter(isBoundWitness)\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 = payloads.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 type { Labels } from '@xyo-network/module-model'\nimport type { 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\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 { filterAs } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport type { ArchivistInstance, ArchivistNextOptions } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { asBoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { payloadSchemasContainsAll } from '@xyo-network/boundwitness-validator'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'\nimport type { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport type {\n Labels, ModuleIdentifier, ModuleState,\n} from '@xyo-network/module-model'\nimport { isModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport type {\n Payload, Schema,\n WithStorageMeta,\n} from '@xyo-network/payload-model'\nimport { SequenceConstants } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\nimport type { TimeStamp } from '@xyo-network/witness-timestamp'\nimport { 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<TemporalStateToIndexCandidateDivinerResponse> {\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 ?? { schema: ModuleStateSchema, state: { cursor: SequenceConstants.minLocalSequence } }\n\n // Get the last cursor\n const cursor = lastState?.state?.cursor\n // Get the archivist for the store\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n\n // Get the next batch of results\n const nextOffset: ArchivistNextOptions = { limit: this.payloadDivinerLimit, order }\n // Only use the cursor if it's a valid offset\n if (cursor !== SequenceConstants.minLocalSequence) nextOffset.cursor = cursor\n // Get next batch of results starting from the offset\n const next = await sourceArchivist.next(nextOffset)\n if (next.length === 0) return [lastState]\n const batch = filterAs(next, asBoundWitness)\n .filter(exists)\n .filter(bw => payloadSchemasContainsAll(bw, this.payload_schemas))\n // Get source data\n const bws = batch.filter(isBoundWitness)\n const indexCandidates: IndexCandidate[] = (await Promise.all(bws.map(bw => this.getPayloadsInBoundWitness(bw, sourceArchivist))))\n .filter(exists)\n .flat()\n const nextCursor = assertEx(next.at(-1)?._sequence, () => `${moduleName}: Expected next to have a sequence`)\n const nextState: ModuleState<IndexingDivinerState> = { schema: ModuleStateSchema, state: { ...lastState.state, cursor: nextCursor } }\n return [nextState, ...indexCandidates]\n }\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 WithStorageMeta<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;AAGhC,SAASC,2CAA2C;AAG7C,IAAMC,0BAAN,cASGC,gBAAAA;EAfV,OAeUA;;;EACR,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeC;;EAC5E,OAAyBC,sBAA8BD;EAEvD,MAAyBE,eAAiC;AACxD,UAAM,MAAMA,aAAAA;AACZ,WAAO;EACT;AACF;;;ACtBA,SAAS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,GAAG/C,WAAAA,oCAA8C;AAC3G,UAAMgD,YAA+C;MAAE9B,QAAQC;MAAmBC,OAAO;QAAE,GAAGL,UAAUK;QAAOC,QAAQuB;MAAW;IAAE;AACpI,WAAO;MAACI;SAAcV;;EACxB;;;;;EAMA,MAAgBb,uBAA8D;AAE5E,UAAMwB,OAAyBJ,UAC7B,KAAKrC,QAAQ0C,cAAcC,WAC3B,MAAM,GAAGnD,WAAAA,mDAA6D;AAGxE,UAAMoD,MAAM,MAAM,KAAKC,QAAQJ,IAAAA;AAC/B,QAAI,CAACG,IAAK,QAAOE;AAEjB,WAAOC,iBAAiBC,KAAKJ,KAAK,KAAKK,OAAO;EAChD;;;;;EAMA,MAAgBC,iCAAiC;AAE/C,UAAMT,OAAyBJ,UAC7B,KAAKrC,QAAQ0C,cAAcS,qBAC3B,MAAM,GAAG3D,WAAAA,6DAAuE;AAGlF,UAAMoD,MAAM,MAAM,KAAKC,QAAQJ,IAAAA;AAC/B,QAAI,CAACG,IAAK;AAEV,WAAOQ,eAAeJ,KAMpBJ,KAAK,KAAKK,OAAO;EACrB;EAEA,MAAgBf,0BAA0BR,IAAkBiB,WAAqE;AAC/H,UAAMU,eAAeC,qCAAoC5B,IAAI,KAAKzB,eAAe,EAAEkC,KAAI;AACvF,QAAIkB,aAAahC,WAAW,EAAG,QAAOyB;AACtC,UAAMS,SAAS,IAAIC,IAAIH,YAAAA;AACvB,UAAMvB,kBAAkB,MAAMa,UAAUc,IAAI;SAAIF;KAAO;AACvD,WAAO;MAAC7B;SAAOI;;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","Promise","all","map","query","fields","reducePayloads","schemas","sources","PayloadBuilder","schema","build","containsAll","assertEx","exists","isBoundWitness","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","indexableBoundWitnesses","filter","isBoundWitness","bw","containsAll","payload_schemas","indexablePayloads","p","isIndexablePayload","length","bwDictionary","payloadDictionary","Promise","all","PayloadBuilder","toDataHashMap","validIndexableTuples","bwHash","entries","combinations","intraBoundwitnessSchemaCombinations","combination","map","hash","exists","push","indexes","sourcePayloadHashes","sourcePayloads","indexFields","flatMap","payload","transformers","schema","transform","sources","TemporalIndexingDivinerResultIndexSchema","fields","assign","build","flat","x","isAnyPayload","includes","isIndexableSchema","AbstractDiviner","isPayloadDivinerQueryPayload","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","defaultConfigSchema","labels","divineHandler","payloads","responses","filter","p","isPayloadDivinerQueryPayload","Promise","resolve","filterAs","assertEx","exists","ArchivistWrapper","asBoundWitness","isBoundWitness","payloadSchemasContainsAll","AbstractDiviner","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","DivinerWrapper","isModuleState","ModuleStateSchema","SequenceConstants","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","cursor","SequenceConstants","minLocalSequence","sourceArchivist","getArchivistForStore","nextOffset","limit","next","length","batch","filterAs","asBoundWitness","exists","bw","payloadSchemasContainsAll","bws","isBoundWitness","indexCandidates","Promise","all","map","getPayloadsInBoundWitness","flat","nextCursor","assertEx","at","_sequence","nextState","name","payloadStore","archivist","mod","resolve","undefined","ArchivistWrapper","wrap","account","getBoundWitnessDivinerForStore","boundWitnessDiviner","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 type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport type { TemporalIndexingDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { TemporalIndexingDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport type { 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 type { Hash } from '@xylabs/hex'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary, reducePayloads } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport type { PayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'\nimport { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'\nimport type { TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport {\n TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport type { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } 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: 'cursor',\n sourcePathExpression: '$.cursor',\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 return 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 new PayloadBuilder<Payload>({ schema: this.indexQuerySchema }).fields(fields).build()\n }),\n )\n }\n return []\n }\n}\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport type { Hash } from '@xylabs/hex'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport { jsonPathToTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-memory'\nimport type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-model'\nimport type {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,\n TemporalIndexingDivinerResultIndex,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport {\n TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,\n TemporalIndexingDivinerResultIndexSchema,\n} from '@xyo-network/diviner-temporal-indexing-model'\nimport type { Labels } from '@xyo-network/module-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { isAnyPayload } 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 // If the Bound Witness does not contain all the required schemas do not index it\n const indexableBoundWitnesses = payloads\n .filter(isBoundWitness)\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 = payloads.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 = validIndexableTuples.map<TemporalIndexingDivinerResultIndex>(([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: Hash[] = [bwHash, ...sourcePayloadHashes]\n // Build and return the index\n return new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })\n .fields(Object.assign({ sources }, ...indexFields))\n .build()\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 type { Labels } from '@xyo-network/module-model'\nimport type { 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\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 { filterAs } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport type { ArchivistInstance, ArchivistNextOptions } from '@xyo-network/archivist-model'\nimport { ArchivistWrapper } from '@xyo-network/archivist-wrapper'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { asBoundWitness } from '@xyo-network/boundwitness-model'\nimport { payloadSchemasContainsAll } from '@xyo-network/boundwitness-validator'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'\nimport type { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'\nimport type { TemporalIndexingDivinerStateToIndexCandidateDivinerParams } from '@xyo-network/diviner-temporal-indexing-model'\nimport { TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'\nimport { DivinerWrapper } from '@xyo-network/diviner-wrapper'\nimport type {\n Labels, ModuleIdentifier, ModuleState,\n} from '@xyo-network/module-model'\nimport { isModuleState, ModuleStateSchema } from '@xyo-network/module-model'\nimport type {\n Payload, Schema,\n WithStorageMeta,\n} from '@xyo-network/payload-model'\nimport { SequenceConstants } from '@xyo-network/payload-model'\nimport { intraBoundwitnessSchemaCombinations } from '@xyo-network/payload-utils'\nimport type { TimeStamp } from '@xyo-network/witness-timestamp'\nimport { 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<TemporalStateToIndexCandidateDivinerResponse> {\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 ?? { schema: ModuleStateSchema, state: { cursor: SequenceConstants.minLocalSequence } }\n\n // Get the last cursor\n const cursor = lastState?.state?.cursor\n // Get the archivist for the store\n const sourceArchivist = await this.getArchivistForStore()\n if (!sourceArchivist) return [lastState]\n\n // Get the next batch of results\n const nextOffset: ArchivistNextOptions = { limit: this.payloadDivinerLimit, order }\n // Only use the cursor if it's a valid offset\n if (cursor !== SequenceConstants.minLocalSequence) nextOffset.cursor = cursor\n // Get next batch of results starting from the offset\n const next = await sourceArchivist.next(nextOffset)\n if (next.length === 0) return [lastState]\n\n const batch = filterAs(next, asBoundWitness)\n .filter(exists)\n .filter(bw => payloadSchemasContainsAll(bw, this.payload_schemas))\n // Get source data\n const indexCandidates: IndexCandidate[] = (await Promise.all(batch.map(bw => this.getPayloadsInBoundWitness(bw, sourceArchivist))))\n .filter(exists)\n .flat()\n const nextCursor = assertEx(next.at(-1)?._sequence, () => `${moduleName}: Expected next to have a sequence`)\n const nextState: ModuleState<IndexingDivinerState> = { schema: ModuleStateSchema, state: { ...lastState.state, cursor: nextCursor } }\n return [nextState, ...indexCandidates]\n }\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 WithStorageMeta<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;AAGhC,SAASC,2CAA2C;AAG7C,IAAMC,0BAAN,cASGC,gBAAAA;EAfV,OAeUA;;;EACR,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeC;;EAC5E,OAAyBC,sBAA8BD;EAEvD,MAAyBE,eAAiC;AACxD,UAAM,MAAMA,aAAAA;AACZ,WAAO;EACT;AACF;;;ACtBA,SAASC,uBAAuB;AAChC,SAASC,kCAAkCC,sBA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V;;EACxB;;;;;EAMA,MAAgBX,uBAA8D;AAE5E,UAAMsB,OAAyBJ,UAC7B,KAAKnC,QAAQwC,cAAcC,WAC3B,MAAM,GAAGjD,WAAAA,mDAA6D;AAGxE,UAAMkD,MAAM,MAAM,KAAKC,QAAQJ,IAAAA;AAC/B,QAAI,CAACG,IAAK,QAAOE;AAEjB,WAAOC,iBAAiBC,KAAKJ,KAAK,KAAKK,OAAO;EAChD;;;;;EAMA,MAAgBC,iCAAiC;AAE/C,UAAMT,OAAyBJ,UAC7B,KAAKnC,QAAQwC,cAAcS,qBAC3B,MAAM,GAAGzD,WAAAA,6DAAuE;AAGlF,UAAMkD,MAAM,MAAM,KAAKC,QAAQJ,IAAAA;AAC/B,QAAI,CAACG,IAAK;AAEV,WAAOQ,eAAeJ,KAMpBJ,KAAK,KAAKK,OAAO;EACrB;EAEA,MAAgBf,0BAA0BN,IAAkBe,WAAqE;AAC/H,UAAMU,eAAeC,qCAAoC1B,IAAI,KAAKzB,eAAe,EAAEgC,KAAI;AACvF,QAAIkB,aAAa9B,WAAW,EAAG,QAAOuB;AACtC,UAAMS,SAAS,IAAIC,IAAIH,YAAAA;AACvB,UAAMvB,kBAAkB,MAAMa,UAAUc,IAAI;SAAIF;KAAO;AACvD,WAAO;MAAC3B;SAAOE;;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","Promise","all","map","query","fields","reducePayloads","schemas","sources","PayloadBuilder","schema","build","containsAll","assertEx","exists","isBoundWitness","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","indexableBoundWitnesses","filter","isBoundWitness","bw","containsAll","payload_schemas","indexablePayloads","p","isIndexablePayload","length","bwDictionary","payloadDictionary","Promise","all","PayloadBuilder","toDataHashMap","validIndexableTuples","bwHash","entries","combinations","intraBoundwitnessSchemaCombinations","combination","map","hash","exists","push","indexes","sourcePayloadHashes","sourcePayloads","indexFields","flatMap","payload","transformers","schema","transform","sources","TemporalIndexingDivinerResultIndexSchema","fields","assign","build","flat","x","isAnyPayload","includes","isIndexableSchema","AbstractDiviner","isPayloadDivinerQueryPayload","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner","AbstractDiviner","configSchemas","TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema","defaultConfigSchema","labels","divineHandler","payloads","responses","filter","p","isPayloadDivinerQueryPayload","Promise","resolve","filterAs","assertEx","exists","ArchivistWrapper","asBoundWitness","payloadSchemasContainsAll","AbstractDiviner","TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema","DivinerWrapper","isModuleState","ModuleStateSchema","SequenceConstants","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","cursor","SequenceConstants","minLocalSequence","sourceArchivist","getArchivistForStore","nextOffset","limit","next","length","batch","filterAs","asBoundWitness","exists","bw","payloadSchemasContainsAll","indexCandidates","Promise","all","map","getPayloadsInBoundWitness","flat","nextCursor","assertEx","at","_sequence","nextState","name","payloadStore","archivist","mod","resolve","undefined","ArchivistWrapper","wrap","account","getBoundWitnessDivinerForStore","boundWitnessDiviner","DivinerWrapper","combinations","intraBoundwitnessSchemaCombinations","hashes","Set","get"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/diviner-temporal-indexing-memory",
|
|
3
|
-
"version": "3.6.0
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -29,47 +29,46 @@
|
|
|
29
29
|
"module": "dist/neutral/index.mjs",
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@xylabs/array": "^4.4.
|
|
33
|
-
"@xylabs/assert": "^4.4.
|
|
34
|
-
"@xylabs/exists": "^4.4.
|
|
35
|
-
"@xylabs/hex": "^4.4.
|
|
36
|
-
"@xyo-network/archivist-model": "^3.6.0
|
|
37
|
-
"@xyo-network/archivist-wrapper": "^3.6.0
|
|
38
|
-
"@xyo-network/boundwitness-model": "^3.6.0
|
|
39
|
-
"@xyo-network/boundwitness-validator": "^3.6.0
|
|
40
|
-
"@xyo-network/diviner-abstract": "^3.6.0
|
|
41
|
-
"@xyo-network/diviner-boundwitness-abstract": "^3.6.0
|
|
42
|
-
"@xyo-network/diviner-boundwitness-model": "^3.6.0
|
|
43
|
-
"@xyo-network/diviner-indexing-memory": "^3.6.0
|
|
44
|
-
"@xyo-network/diviner-indexing-model": "^3.6.0
|
|
45
|
-
"@xyo-network/diviner-jsonpath-aggregate-memory": "^3.6.0
|
|
46
|
-
"@xyo-network/diviner-jsonpath-model": "^3.6.0
|
|
47
|
-
"@xyo-network/diviner-model": "^3.6.0
|
|
48
|
-
"@xyo-network/diviner-payload-model": "^3.6.0
|
|
49
|
-
"@xyo-network/diviner-temporal-indexing-model": "^3.6.0
|
|
50
|
-
"@xyo-network/diviner-wrapper": "^3.6.0
|
|
51
|
-
"@xyo-network/module-model": "^3.6.0
|
|
52
|
-
"@xyo-network/payload-builder": "^3.6.0
|
|
53
|
-
"@xyo-network/payload-model": "^3.6.0
|
|
54
|
-
"@xyo-network/payload-utils": "^3.6.0
|
|
55
|
-
"@xyo-network/witness-timestamp": "^3.6.0
|
|
32
|
+
"@xylabs/array": "^4.4.26",
|
|
33
|
+
"@xylabs/assert": "^4.4.26",
|
|
34
|
+
"@xylabs/exists": "^4.4.26",
|
|
35
|
+
"@xylabs/hex": "^4.4.26",
|
|
36
|
+
"@xyo-network/archivist-model": "^3.6.0",
|
|
37
|
+
"@xyo-network/archivist-wrapper": "^3.6.0",
|
|
38
|
+
"@xyo-network/boundwitness-model": "^3.6.0",
|
|
39
|
+
"@xyo-network/boundwitness-validator": "^3.6.0",
|
|
40
|
+
"@xyo-network/diviner-abstract": "^3.6.0",
|
|
41
|
+
"@xyo-network/diviner-boundwitness-abstract": "^3.6.0",
|
|
42
|
+
"@xyo-network/diviner-boundwitness-model": "^3.6.0",
|
|
43
|
+
"@xyo-network/diviner-indexing-memory": "^3.6.0",
|
|
44
|
+
"@xyo-network/diviner-indexing-model": "^3.6.0",
|
|
45
|
+
"@xyo-network/diviner-jsonpath-aggregate-memory": "^3.6.0",
|
|
46
|
+
"@xyo-network/diviner-jsonpath-model": "^3.6.0",
|
|
47
|
+
"@xyo-network/diviner-model": "^3.6.0",
|
|
48
|
+
"@xyo-network/diviner-payload-model": "^3.6.0",
|
|
49
|
+
"@xyo-network/diviner-temporal-indexing-model": "^3.6.0",
|
|
50
|
+
"@xyo-network/diviner-wrapper": "^3.6.0",
|
|
51
|
+
"@xyo-network/module-model": "^3.6.0",
|
|
52
|
+
"@xyo-network/payload-builder": "^3.6.0",
|
|
53
|
+
"@xyo-network/payload-model": "^3.6.0",
|
|
54
|
+
"@xyo-network/payload-utils": "^3.6.0",
|
|
55
|
+
"@xyo-network/witness-timestamp": "^3.6.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@xylabs/delay": "^4.4.
|
|
59
|
-
"@xylabs/ts-scripts-yarn3": "^4.2.
|
|
60
|
-
"@xylabs/tsconfig": "^4.2.
|
|
61
|
-
"@xylabs/vitest-extended": "^4.4.
|
|
62
|
-
"@xyo-network/account": "^3.6.0
|
|
63
|
-
"@xyo-network/archivist-memory": "^3.6.0
|
|
64
|
-
"@xyo-network/boundwitness-builder": "^3.6.0
|
|
65
|
-
"@xyo-network/manifest": "^3.6.0
|
|
66
|
-
"@xyo-network/module-factory-locator": "^3.6.0
|
|
67
|
-
"@xyo-network/node-memory": "^3.6.0
|
|
58
|
+
"@xylabs/delay": "^4.4.26",
|
|
59
|
+
"@xylabs/ts-scripts-yarn3": "^4.2.6",
|
|
60
|
+
"@xylabs/tsconfig": "^4.2.6",
|
|
61
|
+
"@xylabs/vitest-extended": "^4.4.26",
|
|
62
|
+
"@xyo-network/account": "^3.6.0",
|
|
63
|
+
"@xyo-network/archivist-memory": "^3.6.0",
|
|
64
|
+
"@xyo-network/boundwitness-builder": "^3.6.0",
|
|
65
|
+
"@xyo-network/manifest": "^3.6.0",
|
|
66
|
+
"@xyo-network/module-factory-locator": "^3.6.0",
|
|
67
|
+
"@xyo-network/node-memory": "^3.6.0",
|
|
68
68
|
"typescript": "^5.7.2",
|
|
69
69
|
"vitest": "^2.1.8"
|
|
70
70
|
},
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
|
-
}
|
|
74
|
-
"stableVersion": "3.5.2"
|
|
73
|
+
}
|
|
75
74
|
}
|
|
@@ -82,9 +82,9 @@ export class TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner<
|
|
|
82
82
|
sourcePathExpression: '$.limit',
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
|
-
defaultValue: 0,
|
|
86
|
-
destinationField: '
|
|
87
|
-
sourcePathExpression: '$.
|
|
85
|
+
// defaultValue: 0,
|
|
86
|
+
destinationField: 'cursor',
|
|
87
|
+
sourcePathExpression: '$.cursor',
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
defaultValue: 'desc',
|
|
@@ -111,7 +111,7 @@ export class TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner<
|
|
|
111
111
|
// TODO: Make sources not need to be deleted
|
|
112
112
|
delete fields.sources
|
|
113
113
|
// TODO: Add support for additional filters
|
|
114
|
-
return
|
|
114
|
+
return new PayloadBuilder<Payload>({ schema: this.indexQuerySchema }).fields(fields).build()
|
|
115
115
|
}),
|
|
116
116
|
)
|
|
117
117
|
}
|
|
@@ -104,24 +104,22 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
// Create the indexes from the tuples
|
|
107
|
-
const indexes =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}),
|
|
124
|
-
)
|
|
107
|
+
const indexes = validIndexableTuples.map<TemporalIndexingDivinerResultIndex>(([bwHash, ...sourcePayloadHashes]) => {
|
|
108
|
+
const sourcePayloads = sourcePayloadHashes.map(hash => payloadDictionary[hash])
|
|
109
|
+
// Use the payload transformers to convert the fields from the source payloads to the destination fields
|
|
110
|
+
const indexFields = sourcePayloads.flatMap((payload) => {
|
|
111
|
+
// Find the transformers for this payload
|
|
112
|
+
const transformers = this.payloadTransformers[payload.schema]
|
|
113
|
+
// If transformers exist, apply them to the payload otherwise return an empty array
|
|
114
|
+
return transformers ? transformers.map(transform => transform(payload)) : []
|
|
115
|
+
})
|
|
116
|
+
// Include all the sources for reference
|
|
117
|
+
const sources: Hash[] = [bwHash, ...sourcePayloadHashes]
|
|
118
|
+
// Build and return the index
|
|
119
|
+
return new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })
|
|
120
|
+
.fields(Object.assign({ sources }, ...indexFields))
|
|
121
|
+
.build()
|
|
122
|
+
})
|
|
125
123
|
return indexes.flat()
|
|
126
124
|
}
|
|
127
125
|
|
|
@@ -4,7 +4,7 @@ import { exists } from '@xylabs/exists'
|
|
|
4
4
|
import type { ArchivistInstance, ArchivistNextOptions } from '@xyo-network/archivist-model'
|
|
5
5
|
import { ArchivistWrapper } from '@xyo-network/archivist-wrapper'
|
|
6
6
|
import type { BoundWitness } from '@xyo-network/boundwitness-model'
|
|
7
|
-
import { asBoundWitness
|
|
7
|
+
import { asBoundWitness } from '@xyo-network/boundwitness-model'
|
|
8
8
|
import { payloadSchemasContainsAll } from '@xyo-network/boundwitness-validator'
|
|
9
9
|
import { AbstractDiviner } from '@xyo-network/diviner-abstract'
|
|
10
10
|
import type { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'
|
|
@@ -99,12 +99,12 @@ export class TemporalIndexingDivinerStateToIndexCandidateDiviner<
|
|
|
99
99
|
// Get next batch of results starting from the offset
|
|
100
100
|
const next = await sourceArchivist.next(nextOffset)
|
|
101
101
|
if (next.length === 0) return [lastState]
|
|
102
|
+
|
|
102
103
|
const batch = filterAs(next, asBoundWitness)
|
|
103
104
|
.filter(exists)
|
|
104
105
|
.filter(bw => payloadSchemasContainsAll(bw, this.payload_schemas))
|
|
105
106
|
// Get source data
|
|
106
|
-
const
|
|
107
|
-
const indexCandidates: IndexCandidate[] = (await Promise.all(bws.map(bw => this.getPayloadsInBoundWitness(bw, sourceArchivist))))
|
|
107
|
+
const indexCandidates: IndexCandidate[] = (await Promise.all(batch.map(bw => this.getPayloadsInBoundWitness(bw, sourceArchivist))))
|
|
108
108
|
.filter(exists)
|
|
109
109
|
.flat()
|
|
110
110
|
const nextCursor = assertEx(next.at(-1)?._sequence, () => `${moduleName}: Expected next to have a sequence`)
|