@xyo-network/diviner-temporal-indexing-memory 2.80.12 → 2.80.14
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/Diviner.d.cts +12 -5
- package/dist/browser/Diviner.d.cts.map +1 -1
- package/dist/browser/Diviner.d.mts +12 -5
- package/dist/browser/Diviner.d.mts.map +1 -1
- package/dist/browser/Diviner.d.ts +12 -5
- package/dist/browser/Diviner.d.ts.map +1 -1
- package/dist/browser/DivinerQueryToIndexQueryDiviner/Diviner.d.cts +42 -0
- package/dist/browser/DivinerQueryToIndexQueryDiviner/Diviner.d.cts.map +1 -0
- package/dist/browser/DivinerQueryToIndexQueryDiviner/Diviner.d.mts +42 -0
- package/dist/browser/DivinerQueryToIndexQueryDiviner/Diviner.d.mts.map +1 -0
- package/dist/browser/DivinerQueryToIndexQueryDiviner/Diviner.d.ts +42 -0
- package/dist/browser/DivinerQueryToIndexQueryDiviner/Diviner.d.ts.map +1 -0
- package/dist/browser/DivinerQueryToIndexQueryDiviner/index.d.cts +2 -0
- package/dist/browser/DivinerQueryToIndexQueryDiviner/index.d.cts.map +1 -0
- package/dist/browser/DivinerQueryToIndexQueryDiviner/index.d.mts +2 -0
- package/dist/browser/DivinerQueryToIndexQueryDiviner/index.d.mts.map +1 -0
- package/dist/browser/DivinerQueryToIndexQueryDiviner/index.d.ts +2 -0
- package/dist/browser/DivinerQueryToIndexQueryDiviner/index.d.ts.map +1 -0
- package/dist/browser/IndexCandidateToIndexDiviner/Diviner.d.cts +9 -9
- package/dist/browser/IndexCandidateToIndexDiviner/Diviner.d.cts.map +1 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Diviner.d.mts +9 -9
- package/dist/browser/IndexCandidateToIndexDiviner/Diviner.d.mts.map +1 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Diviner.d.ts +9 -9
- package/dist/browser/IndexCandidateToIndexDiviner/Diviner.d.ts.map +1 -1
- package/dist/browser/IndexCandidateToIndexDiviner/_Diviner.d.cts +47 -0
- package/dist/browser/IndexCandidateToIndexDiviner/_Diviner.d.cts.map +1 -0
- package/dist/browser/IndexCandidateToIndexDiviner/_Diviner.d.mts +47 -0
- package/dist/browser/IndexCandidateToIndexDiviner/_Diviner.d.mts.map +1 -0
- package/dist/browser/IndexCandidateToIndexDiviner/_Diviner.d.ts +47 -0
- package/dist/browser/IndexCandidateToIndexDiviner/_Diviner.d.ts.map +1 -0
- package/dist/browser/IndexCandidateToIndexDiviner/index.d.cts +0 -3
- package/dist/browser/IndexCandidateToIndexDiviner/index.d.cts.map +1 -1
- package/dist/browser/IndexCandidateToIndexDiviner/index.d.mts +0 -3
- package/dist/browser/IndexCandidateToIndexDiviner/index.d.mts.map +1 -1
- package/dist/browser/IndexCandidateToIndexDiviner/index.d.ts +0 -3
- package/dist/browser/IndexCandidateToIndexDiviner/index.d.ts.map +1 -1
- package/dist/browser/{IndexQueryResponseToDivinerQueryResponseDiviner.d.mts → IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.d.cts} +3 -2
- package/dist/browser/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.d.cts.map +1 -0
- package/dist/browser/{IndexQueryResponseToDivinerQueryResponseDiviner.d.ts → IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.d.mts} +3 -2
- package/dist/browser/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.d.mts.map +1 -0
- package/dist/{node/IndexQueryResponseToDivinerQueryResponseDiviner.d.cts → browser/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.d.ts} +3 -2
- package/dist/browser/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.d.ts.map +1 -0
- package/dist/browser/IndexQueryResponseToDivinerQueryResponseDiviner/index.d.cts +2 -0
- package/dist/browser/IndexQueryResponseToDivinerQueryResponseDiviner/index.d.cts.map +1 -0
- package/dist/browser/IndexQueryResponseToDivinerQueryResponseDiviner/index.d.mts +2 -0
- package/dist/browser/IndexQueryResponseToDivinerQueryResponseDiviner/index.d.mts.map +1 -0
- package/dist/browser/IndexQueryResponseToDivinerQueryResponseDiviner/index.d.ts +2 -0
- package/dist/browser/IndexQueryResponseToDivinerQueryResponseDiviner/index.d.ts.map +1 -0
- package/dist/browser/StateToIndexCandidateDiviner/Diviner.d.cts +7 -6
- package/dist/browser/StateToIndexCandidateDiviner/Diviner.d.cts.map +1 -1
- package/dist/browser/StateToIndexCandidateDiviner/Diviner.d.mts +7 -6
- package/dist/browser/StateToIndexCandidateDiviner/Diviner.d.mts.map +1 -1
- package/dist/browser/StateToIndexCandidateDiviner/Diviner.d.ts +7 -6
- package/dist/browser/StateToIndexCandidateDiviner/Diviner.d.ts.map +1 -1
- package/dist/browser/index.cjs +453 -26
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +4 -0
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +4 -0
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +457 -26
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/jsonpath/index.d.cts +4 -0
- package/dist/browser/jsonpath/index.d.cts.map +1 -0
- package/dist/browser/jsonpath/index.d.mts +4 -0
- package/dist/browser/jsonpath/index.d.mts.map +1 -0
- package/dist/browser/jsonpath/index.d.ts +4 -0
- package/dist/browser/jsonpath/index.d.ts.map +1 -0
- package/dist/browser/jsonpath/jsonPathToTransformersDictionary.d.cts +10 -0
- package/dist/browser/jsonpath/jsonPathToTransformersDictionary.d.cts.map +1 -0
- package/dist/browser/jsonpath/jsonPathToTransformersDictionary.d.mts +10 -0
- package/dist/browser/jsonpath/jsonPathToTransformersDictionary.d.mts.map +1 -0
- package/dist/browser/jsonpath/jsonPathToTransformersDictionary.d.ts +10 -0
- package/dist/browser/jsonpath/jsonPathToTransformersDictionary.d.ts.map +1 -0
- package/dist/browser/jsonpath/reducePayloads.d.cts +27 -0
- package/dist/browser/jsonpath/reducePayloads.d.cts.map +1 -0
- package/dist/browser/jsonpath/reducePayloads.d.mts +27 -0
- package/dist/browser/jsonpath/reducePayloads.d.mts.map +1 -0
- package/dist/browser/jsonpath/reducePayloads.d.ts +27 -0
- package/dist/browser/jsonpath/reducePayloads.d.ts.map +1 -0
- package/dist/browser/jsonpath/toPayloadTransformer.d.cts +8 -0
- package/dist/browser/jsonpath/toPayloadTransformer.d.cts.map +1 -0
- package/dist/browser/jsonpath/toPayloadTransformer.d.mts +8 -0
- package/dist/browser/jsonpath/toPayloadTransformer.d.mts.map +1 -0
- package/dist/browser/jsonpath/toPayloadTransformer.d.ts +8 -0
- package/dist/browser/jsonpath/toPayloadTransformer.d.ts.map +1 -0
- package/dist/node/Diviner.d.cts +12 -5
- package/dist/node/Diviner.d.cts.map +1 -1
- package/dist/node/Diviner.d.mts +12 -5
- package/dist/node/Diviner.d.mts.map +1 -1
- package/dist/node/Diviner.d.ts +12 -5
- package/dist/node/Diviner.d.ts.map +1 -1
- package/dist/node/DivinerQueryToIndexQueryDiviner/Diviner.d.cts +42 -0
- package/dist/node/DivinerQueryToIndexQueryDiviner/Diviner.d.cts.map +1 -0
- package/dist/node/DivinerQueryToIndexQueryDiviner/Diviner.d.mts +42 -0
- package/dist/node/DivinerQueryToIndexQueryDiviner/Diviner.d.mts.map +1 -0
- package/dist/node/DivinerQueryToIndexQueryDiviner/Diviner.d.ts +42 -0
- package/dist/node/DivinerQueryToIndexQueryDiviner/Diviner.d.ts.map +1 -0
- package/dist/node/DivinerQueryToIndexQueryDiviner/index.d.cts +2 -0
- package/dist/node/DivinerQueryToIndexQueryDiviner/index.d.cts.map +1 -0
- package/dist/node/DivinerQueryToIndexQueryDiviner/index.d.mts +2 -0
- package/dist/node/DivinerQueryToIndexQueryDiviner/index.d.mts.map +1 -0
- package/dist/node/DivinerQueryToIndexQueryDiviner/index.d.ts +2 -0
- package/dist/node/DivinerQueryToIndexQueryDiviner/index.d.ts.map +1 -0
- package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.cts +9 -9
- package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.cts.map +1 -1
- package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.mts +9 -9
- package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.mts.map +1 -1
- package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.ts +9 -9
- package/dist/node/IndexCandidateToIndexDiviner/Diviner.d.ts.map +1 -1
- package/dist/node/IndexCandidateToIndexDiviner/_Diviner.d.cts +47 -0
- package/dist/node/IndexCandidateToIndexDiviner/_Diviner.d.cts.map +1 -0
- package/dist/node/IndexCandidateToIndexDiviner/_Diviner.d.mts +47 -0
- package/dist/node/IndexCandidateToIndexDiviner/_Diviner.d.mts.map +1 -0
- package/dist/node/IndexCandidateToIndexDiviner/_Diviner.d.ts +47 -0
- package/dist/node/IndexCandidateToIndexDiviner/_Diviner.d.ts.map +1 -0
- package/dist/node/IndexCandidateToIndexDiviner/index.d.cts +0 -3
- package/dist/node/IndexCandidateToIndexDiviner/index.d.cts.map +1 -1
- package/dist/node/IndexCandidateToIndexDiviner/index.d.mts +0 -3
- package/dist/node/IndexCandidateToIndexDiviner/index.d.mts.map +1 -1
- package/dist/node/IndexCandidateToIndexDiviner/index.d.ts +0 -3
- package/dist/node/IndexCandidateToIndexDiviner/index.d.ts.map +1 -1
- package/dist/{browser/IndexQueryResponseToDivinerQueryResponseDiviner.d.cts → node/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.d.cts} +3 -2
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.d.cts.map +1 -0
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.d.mts +13 -0
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.d.mts.map +1 -0
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.d.ts +13 -0
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.d.ts.map +1 -0
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner/index.d.cts +2 -0
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner/index.d.cts.map +1 -0
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner/index.d.mts +2 -0
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner/index.d.mts.map +1 -0
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner/index.d.ts +2 -0
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner/index.d.ts.map +1 -0
- package/dist/node/StateToIndexCandidateDiviner/Diviner.d.cts +7 -6
- package/dist/node/StateToIndexCandidateDiviner/Diviner.d.cts.map +1 -1
- package/dist/node/StateToIndexCandidateDiviner/Diviner.d.mts +7 -6
- package/dist/node/StateToIndexCandidateDiviner/Diviner.d.mts.map +1 -1
- package/dist/node/StateToIndexCandidateDiviner/Diviner.d.ts +7 -6
- package/dist/node/StateToIndexCandidateDiviner/Diviner.d.ts.map +1 -1
- package/dist/node/index.d.cts +4 -0
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +4 -0
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +476 -27
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +475 -26
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/jsonpath/index.d.cts +4 -0
- package/dist/node/jsonpath/index.d.cts.map +1 -0
- package/dist/node/jsonpath/index.d.mts +4 -0
- package/dist/node/jsonpath/index.d.mts.map +1 -0
- package/dist/node/jsonpath/index.d.ts +4 -0
- package/dist/node/jsonpath/index.d.ts.map +1 -0
- package/dist/node/jsonpath/jsonPathToTransformersDictionary.d.cts +10 -0
- package/dist/node/jsonpath/jsonPathToTransformersDictionary.d.cts.map +1 -0
- package/dist/node/jsonpath/jsonPathToTransformersDictionary.d.mts +10 -0
- package/dist/node/jsonpath/jsonPathToTransformersDictionary.d.mts.map +1 -0
- package/dist/node/jsonpath/jsonPathToTransformersDictionary.d.ts +10 -0
- package/dist/node/jsonpath/jsonPathToTransformersDictionary.d.ts.map +1 -0
- package/dist/node/jsonpath/reducePayloads.d.cts +27 -0
- package/dist/node/jsonpath/reducePayloads.d.cts.map +1 -0
- package/dist/node/jsonpath/reducePayloads.d.mts +27 -0
- package/dist/node/jsonpath/reducePayloads.d.mts.map +1 -0
- package/dist/node/jsonpath/reducePayloads.d.ts +27 -0
- package/dist/node/jsonpath/reducePayloads.d.ts.map +1 -0
- package/dist/node/jsonpath/toPayloadTransformer.d.cts +8 -0
- package/dist/node/jsonpath/toPayloadTransformer.d.cts.map +1 -0
- package/dist/node/jsonpath/toPayloadTransformer.d.mts +8 -0
- package/dist/node/jsonpath/toPayloadTransformer.d.mts.map +1 -0
- package/dist/node/jsonpath/toPayloadTransformer.d.ts +8 -0
- package/dist/node/jsonpath/toPayloadTransformer.d.ts.map +1 -0
- package/package.json +29 -28
- package/src/Diviner.ts +119 -27
- package/src/DivinerQueryToIndexQueryDiviner/Diviner.ts +120 -0
- package/src/DivinerQueryToIndexQueryDiviner/index.ts +1 -0
- package/src/IndexCandidateToIndexDiviner/Diviner.ts +40 -57
- package/src/IndexCandidateToIndexDiviner/_Diviner.ts +135 -0
- package/src/IndexCandidateToIndexDiviner/index.ts +0 -3
- package/src/IndexQueryResponseToDivinerQueryResponseDiviner/Diviner.ts +26 -0
- package/src/IndexQueryResponseToDivinerQueryResponseDiviner/index.ts +1 -0
- package/src/StateToIndexCandidateDiviner/Diviner.ts +25 -13
- package/src/index.ts +4 -0
- package/src/jsonpath/index.ts +3 -0
- package/src/jsonpath/jsonPathToTransformersDictionary.ts +21 -0
- package/src/jsonpath/reducePayloads.ts +50 -0
- package/src/jsonpath/toPayloadTransformer.ts +23 -0
- package/src/spec/{ImageThumbnailDivinerManifest.json → TemporalDiviner.json} +70 -7
- package/dist/browser/DivinerQueryToIndexQueryDiviner.d.cts +0 -12
- package/dist/browser/DivinerQueryToIndexQueryDiviner.d.cts.map +0 -1
- package/dist/browser/DivinerQueryToIndexQueryDiviner.d.mts +0 -12
- package/dist/browser/DivinerQueryToIndexQueryDiviner.d.mts.map +0 -1
- package/dist/browser/DivinerQueryToIndexQueryDiviner.d.ts +0 -12
- package/dist/browser/DivinerQueryToIndexQueryDiviner.d.ts.map +0 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Config.d.cts +0 -10
- package/dist/browser/IndexCandidateToIndexDiviner/Config.d.cts.map +0 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Config.d.mts +0 -10
- package/dist/browser/IndexCandidateToIndexDiviner/Config.d.mts.map +0 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Config.d.ts +0 -10
- package/dist/browser/IndexCandidateToIndexDiviner/Config.d.ts.map +0 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Params.d.cts +0 -5
- package/dist/browser/IndexCandidateToIndexDiviner/Params.d.cts.map +0 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Params.d.mts +0 -5
- package/dist/browser/IndexCandidateToIndexDiviner/Params.d.mts.map +0 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Params.d.ts +0 -5
- package/dist/browser/IndexCandidateToIndexDiviner/Params.d.ts.map +0 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Schema.d.cts +0 -4
- package/dist/browser/IndexCandidateToIndexDiviner/Schema.d.cts.map +0 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Schema.d.mts +0 -4
- package/dist/browser/IndexCandidateToIndexDiviner/Schema.d.mts.map +0 -1
- package/dist/browser/IndexCandidateToIndexDiviner/Schema.d.ts +0 -4
- package/dist/browser/IndexCandidateToIndexDiviner/Schema.d.ts.map +0 -1
- package/dist/browser/IndexQueryResponseToDivinerQueryResponseDiviner.d.cts.map +0 -1
- package/dist/browser/IndexQueryResponseToDivinerQueryResponseDiviner.d.mts.map +0 -1
- package/dist/browser/IndexQueryResponseToDivinerQueryResponseDiviner.d.ts.map +0 -1
- package/dist/browser/StateToIndexCandidateDiviner/Config.d.cts +0 -19
- package/dist/browser/StateToIndexCandidateDiviner/Config.d.cts.map +0 -1
- package/dist/browser/StateToIndexCandidateDiviner/Config.d.mts +0 -19
- package/dist/browser/StateToIndexCandidateDiviner/Config.d.mts.map +0 -1
- package/dist/browser/StateToIndexCandidateDiviner/Config.d.ts +0 -19
- package/dist/browser/StateToIndexCandidateDiviner/Config.d.ts.map +0 -1
- package/dist/browser/StateToIndexCandidateDiviner/Params.d.cts +0 -5
- package/dist/browser/StateToIndexCandidateDiviner/Params.d.cts.map +0 -1
- package/dist/browser/StateToIndexCandidateDiviner/Params.d.mts +0 -5
- package/dist/browser/StateToIndexCandidateDiviner/Params.d.mts.map +0 -1
- package/dist/browser/StateToIndexCandidateDiviner/Params.d.ts +0 -5
- package/dist/browser/StateToIndexCandidateDiviner/Params.d.ts.map +0 -1
- package/dist/browser/StateToIndexCandidateDiviner/Schema.d.cts +0 -4
- package/dist/browser/StateToIndexCandidateDiviner/Schema.d.cts.map +0 -1
- package/dist/browser/StateToIndexCandidateDiviner/Schema.d.mts +0 -4
- package/dist/browser/StateToIndexCandidateDiviner/Schema.d.mts.map +0 -1
- package/dist/browser/StateToIndexCandidateDiviner/Schema.d.ts +0 -4
- package/dist/browser/StateToIndexCandidateDiviner/Schema.d.ts.map +0 -1
- package/dist/browser/lib/index.d.cts +0 -2
- package/dist/browser/lib/index.d.cts.map +0 -1
- package/dist/browser/lib/index.d.mts +0 -2
- package/dist/browser/lib/index.d.mts.map +0 -1
- package/dist/browser/lib/index.d.ts +0 -2
- package/dist/browser/lib/index.d.ts.map +0 -1
- package/dist/browser/lib/jsonpath/JsonPathTransformExpression.d.cts +0 -15
- package/dist/browser/lib/jsonpath/JsonPathTransformExpression.d.cts.map +0 -1
- package/dist/browser/lib/jsonpath/JsonPathTransformExpression.d.mts +0 -15
- package/dist/browser/lib/jsonpath/JsonPathTransformExpression.d.mts.map +0 -1
- package/dist/browser/lib/jsonpath/JsonPathTransformExpression.d.ts +0 -15
- package/dist/browser/lib/jsonpath/JsonPathTransformExpression.d.ts.map +0 -1
- package/dist/browser/lib/jsonpath/PayloadTransformer.d.cts +0 -3
- package/dist/browser/lib/jsonpath/PayloadTransformer.d.cts.map +0 -1
- package/dist/browser/lib/jsonpath/PayloadTransformer.d.mts +0 -3
- package/dist/browser/lib/jsonpath/PayloadTransformer.d.mts.map +0 -1
- package/dist/browser/lib/jsonpath/PayloadTransformer.d.ts +0 -3
- package/dist/browser/lib/jsonpath/PayloadTransformer.d.ts.map +0 -1
- package/dist/browser/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.d.cts +0 -12
- package/dist/browser/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.d.cts.map +0 -1
- package/dist/browser/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.d.mts +0 -12
- package/dist/browser/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.d.mts.map +0 -1
- package/dist/browser/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.d.ts +0 -12
- package/dist/browser/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.d.ts.map +0 -1
- package/dist/browser/lib/jsonpath/StringToPayloadTransformersDictionary.d.cts +0 -5
- package/dist/browser/lib/jsonpath/StringToPayloadTransformersDictionary.d.cts.map +0 -1
- package/dist/browser/lib/jsonpath/StringToPayloadTransformersDictionary.d.mts +0 -5
- package/dist/browser/lib/jsonpath/StringToPayloadTransformersDictionary.d.mts.map +0 -1
- package/dist/browser/lib/jsonpath/StringToPayloadTransformersDictionary.d.ts +0 -5
- package/dist/browser/lib/jsonpath/StringToPayloadTransformersDictionary.d.ts.map +0 -1
- package/dist/browser/lib/jsonpath/index.d.cts +0 -5
- package/dist/browser/lib/jsonpath/index.d.cts.map +0 -1
- package/dist/browser/lib/jsonpath/index.d.mts +0 -5
- package/dist/browser/lib/jsonpath/index.d.mts.map +0 -1
- package/dist/browser/lib/jsonpath/index.d.ts +0 -5
- package/dist/browser/lib/jsonpath/index.d.ts.map +0 -1
- package/dist/node/DivinerQueryToIndexQueryDiviner.d.cts +0 -12
- package/dist/node/DivinerQueryToIndexQueryDiviner.d.cts.map +0 -1
- package/dist/node/DivinerQueryToIndexQueryDiviner.d.mts +0 -12
- package/dist/node/DivinerQueryToIndexQueryDiviner.d.mts.map +0 -1
- package/dist/node/DivinerQueryToIndexQueryDiviner.d.ts +0 -12
- package/dist/node/DivinerQueryToIndexQueryDiviner.d.ts.map +0 -1
- package/dist/node/IndexCandidateToIndexDiviner/Config.d.cts +0 -10
- package/dist/node/IndexCandidateToIndexDiviner/Config.d.cts.map +0 -1
- package/dist/node/IndexCandidateToIndexDiviner/Config.d.mts +0 -10
- package/dist/node/IndexCandidateToIndexDiviner/Config.d.mts.map +0 -1
- package/dist/node/IndexCandidateToIndexDiviner/Config.d.ts +0 -10
- package/dist/node/IndexCandidateToIndexDiviner/Config.d.ts.map +0 -1
- package/dist/node/IndexCandidateToIndexDiviner/Params.d.cts +0 -5
- package/dist/node/IndexCandidateToIndexDiviner/Params.d.cts.map +0 -1
- package/dist/node/IndexCandidateToIndexDiviner/Params.d.mts +0 -5
- package/dist/node/IndexCandidateToIndexDiviner/Params.d.mts.map +0 -1
- package/dist/node/IndexCandidateToIndexDiviner/Params.d.ts +0 -5
- package/dist/node/IndexCandidateToIndexDiviner/Params.d.ts.map +0 -1
- package/dist/node/IndexCandidateToIndexDiviner/Schema.d.cts +0 -4
- package/dist/node/IndexCandidateToIndexDiviner/Schema.d.cts.map +0 -1
- package/dist/node/IndexCandidateToIndexDiviner/Schema.d.mts +0 -4
- package/dist/node/IndexCandidateToIndexDiviner/Schema.d.mts.map +0 -1
- package/dist/node/IndexCandidateToIndexDiviner/Schema.d.ts +0 -4
- package/dist/node/IndexCandidateToIndexDiviner/Schema.d.ts.map +0 -1
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner.d.cts.map +0 -1
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner.d.mts +0 -12
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner.d.mts.map +0 -1
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner.d.ts +0 -12
- package/dist/node/IndexQueryResponseToDivinerQueryResponseDiviner.d.ts.map +0 -1
- package/dist/node/StateToIndexCandidateDiviner/Config.d.cts +0 -19
- package/dist/node/StateToIndexCandidateDiviner/Config.d.cts.map +0 -1
- package/dist/node/StateToIndexCandidateDiviner/Config.d.mts +0 -19
- package/dist/node/StateToIndexCandidateDiviner/Config.d.mts.map +0 -1
- package/dist/node/StateToIndexCandidateDiviner/Config.d.ts +0 -19
- package/dist/node/StateToIndexCandidateDiviner/Config.d.ts.map +0 -1
- package/dist/node/StateToIndexCandidateDiviner/Params.d.cts +0 -5
- package/dist/node/StateToIndexCandidateDiviner/Params.d.cts.map +0 -1
- package/dist/node/StateToIndexCandidateDiviner/Params.d.mts +0 -5
- package/dist/node/StateToIndexCandidateDiviner/Params.d.mts.map +0 -1
- package/dist/node/StateToIndexCandidateDiviner/Params.d.ts +0 -5
- package/dist/node/StateToIndexCandidateDiviner/Params.d.ts.map +0 -1
- package/dist/node/StateToIndexCandidateDiviner/Schema.d.cts +0 -4
- package/dist/node/StateToIndexCandidateDiviner/Schema.d.cts.map +0 -1
- package/dist/node/StateToIndexCandidateDiviner/Schema.d.mts +0 -4
- package/dist/node/StateToIndexCandidateDiviner/Schema.d.mts.map +0 -1
- package/dist/node/StateToIndexCandidateDiviner/Schema.d.ts +0 -4
- package/dist/node/StateToIndexCandidateDiviner/Schema.d.ts.map +0 -1
- package/dist/node/lib/index.d.cts +0 -2
- package/dist/node/lib/index.d.cts.map +0 -1
- package/dist/node/lib/index.d.mts +0 -2
- package/dist/node/lib/index.d.mts.map +0 -1
- package/dist/node/lib/index.d.ts +0 -2
- package/dist/node/lib/index.d.ts.map +0 -1
- package/dist/node/lib/jsonpath/JsonPathTransformExpression.d.cts +0 -15
- package/dist/node/lib/jsonpath/JsonPathTransformExpression.d.cts.map +0 -1
- package/dist/node/lib/jsonpath/JsonPathTransformExpression.d.mts +0 -15
- package/dist/node/lib/jsonpath/JsonPathTransformExpression.d.mts.map +0 -1
- package/dist/node/lib/jsonpath/JsonPathTransformExpression.d.ts +0 -15
- package/dist/node/lib/jsonpath/JsonPathTransformExpression.d.ts.map +0 -1
- package/dist/node/lib/jsonpath/PayloadTransformer.d.cts +0 -3
- package/dist/node/lib/jsonpath/PayloadTransformer.d.cts.map +0 -1
- package/dist/node/lib/jsonpath/PayloadTransformer.d.mts +0 -3
- package/dist/node/lib/jsonpath/PayloadTransformer.d.mts.map +0 -1
- package/dist/node/lib/jsonpath/PayloadTransformer.d.ts +0 -3
- package/dist/node/lib/jsonpath/PayloadTransformer.d.ts.map +0 -1
- package/dist/node/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.d.cts +0 -12
- package/dist/node/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.d.cts.map +0 -1
- package/dist/node/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.d.mts +0 -12
- package/dist/node/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.d.mts.map +0 -1
- package/dist/node/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.d.ts +0 -12
- package/dist/node/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.d.ts.map +0 -1
- package/dist/node/lib/jsonpath/StringToPayloadTransformersDictionary.d.cts +0 -5
- package/dist/node/lib/jsonpath/StringToPayloadTransformersDictionary.d.cts.map +0 -1
- package/dist/node/lib/jsonpath/StringToPayloadTransformersDictionary.d.mts +0 -5
- package/dist/node/lib/jsonpath/StringToPayloadTransformersDictionary.d.mts.map +0 -1
- package/dist/node/lib/jsonpath/StringToPayloadTransformersDictionary.d.ts +0 -5
- package/dist/node/lib/jsonpath/StringToPayloadTransformersDictionary.d.ts.map +0 -1
- package/dist/node/lib/jsonpath/index.d.cts +0 -5
- package/dist/node/lib/jsonpath/index.d.cts.map +0 -1
- package/dist/node/lib/jsonpath/index.d.mts +0 -5
- package/dist/node/lib/jsonpath/index.d.mts.map +0 -1
- package/dist/node/lib/jsonpath/index.d.ts +0 -5
- package/dist/node/lib/jsonpath/index.d.ts.map +0 -1
- package/src/DivinerQueryToIndexQueryDiviner.ts +0 -34
- package/src/IndexCandidateToIndexDiviner/Config.ts +0 -12
- package/src/IndexCandidateToIndexDiviner/Params.ts +0 -6
- package/src/IndexCandidateToIndexDiviner/Schema.ts +0 -4
- package/src/IndexQueryResponseToDivinerQueryResponseDiviner.ts +0 -21
- package/src/StateToIndexCandidateDiviner/Config.ts +0 -21
- package/src/StateToIndexCandidateDiviner/Params.ts +0 -6
- package/src/StateToIndexCandidateDiviner/Schema.ts +0 -4
- package/src/lib/index.ts +0 -1
- package/src/lib/jsonpath/JsonPathTransformExpression.ts +0 -14
- package/src/lib/jsonpath/PayloadTransformer.ts +0 -3
- package/src/lib/jsonpath/StringToJsonPathTransformExpressionDictionary.ts +0 -8
- package/src/lib/jsonpath/StringToPayloadTransformersDictionary.ts +0 -3
- package/src/lib/jsonpath/index.ts +0 -4
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { AbstractDiviner } from '@xyo-network/abstract-diviner'
|
|
2
|
+
import { DivinerConfigSchema } from '@xyo-network/diviner-model'
|
|
3
|
+
import { PayloadDivinerQueryPayload, PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
4
|
+
import {
|
|
5
|
+
SchemaToJsonPathTransformExpressionsDictionary,
|
|
6
|
+
SchemaToPayloadTransformersDictionary,
|
|
7
|
+
TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema,
|
|
8
|
+
TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams,
|
|
9
|
+
TemporalIndexingDivinerResultIndexSchema,
|
|
10
|
+
} from '@xyo-network/diviner-temporal-indexing-model'
|
|
11
|
+
import { Labels } from '@xyo-network/module-model'
|
|
12
|
+
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
13
|
+
import { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'
|
|
14
|
+
|
|
15
|
+
import { jsonPathToTransformersDictionary, reducePayloads } from '../jsonpath'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A diviner that converts diviner query to index query
|
|
19
|
+
*/
|
|
20
|
+
export class TemporalIndexingDivinerDivinerQueryToIndexQueryDiviner<
|
|
21
|
+
TParams extends TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerParams,
|
|
22
|
+
> extends AbstractDiviner<TParams> {
|
|
23
|
+
static override readonly configSchema = TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema
|
|
24
|
+
static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerDivinerQueryToIndexQueryDivinerConfigSchema]
|
|
25
|
+
static labels: Labels = {
|
|
26
|
+
'network.xyo.diviner.stage': 'divinerQueryToIndexQueryDiviner',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private _indexableSchemas: string[] | undefined
|
|
30
|
+
private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The schema of the diviner query payloads
|
|
34
|
+
*/
|
|
35
|
+
protected get divinerQuerySchema(): string {
|
|
36
|
+
return this.config.divinerQuerySchema ?? PayloadDivinerQuerySchema
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The schema of the index query payloads
|
|
41
|
+
*/
|
|
42
|
+
protected get indexQuerySchema(): string {
|
|
43
|
+
return this.config.indexQuerySchema ?? PayloadDivinerQuerySchema
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The schema of the index payloads
|
|
48
|
+
*/
|
|
49
|
+
protected get indexSchema(): string {
|
|
50
|
+
return this.config.indexSchema ?? TemporalIndexingDivinerResultIndexSchema
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* List of indexable schemas for this diviner
|
|
55
|
+
*/
|
|
56
|
+
protected get indexableSchemas(): string[] {
|
|
57
|
+
if (!this._indexableSchemas) this._indexableSchemas = [...Object.keys(this.schemaTransforms)]
|
|
58
|
+
return this._indexableSchemas
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Dictionary of schemas to payload transformers for creating indexes
|
|
63
|
+
* from the payloads within a Bound Witness
|
|
64
|
+
*/
|
|
65
|
+
protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {
|
|
66
|
+
if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms)
|
|
67
|
+
return this._payloadTransformers
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The dictionary of schemas to JSON Path transform expressions for creating indexes
|
|
72
|
+
* from the payloads within a Bound Witness
|
|
73
|
+
*/
|
|
74
|
+
protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {
|
|
75
|
+
return (
|
|
76
|
+
this.config?.schemaTransforms ?? {
|
|
77
|
+
[this.divinerQuerySchema]: [
|
|
78
|
+
{
|
|
79
|
+
defaultValue: 1,
|
|
80
|
+
destinationField: 'limit',
|
|
81
|
+
sourcePathExpression: '$.limit',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
defaultValue: 0,
|
|
85
|
+
destinationField: 'offset',
|
|
86
|
+
sourcePathExpression: '$.offset',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
defaultValue: 'desc',
|
|
90
|
+
destinationField: 'order',
|
|
91
|
+
sourcePathExpression: '$.order',
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {
|
|
99
|
+
const queries = payloads.filter(isPayloadOfSchemaType<PayloadDivinerQueryPayload>(this.divinerQuerySchema))
|
|
100
|
+
if (queries.length) {
|
|
101
|
+
const results = await Promise.all(
|
|
102
|
+
queries.map(async (query) => {
|
|
103
|
+
const fields = await reducePayloads<PayloadDivinerQueryPayload & { sources?: string[] }>(
|
|
104
|
+
[query],
|
|
105
|
+
this.payloadTransformers,
|
|
106
|
+
this.indexQuerySchema,
|
|
107
|
+
)
|
|
108
|
+
// TODO: Make index schema configurable
|
|
109
|
+
fields.schemas = [this.indexSchema]
|
|
110
|
+
// TODO: Make sources not need to be deleted
|
|
111
|
+
delete fields.sources
|
|
112
|
+
// TODO: Add support for additional filters
|
|
113
|
+
return new PayloadBuilder({ schema: this.indexQuerySchema }).fields(fields).build()
|
|
114
|
+
}),
|
|
115
|
+
)
|
|
116
|
+
return results
|
|
117
|
+
}
|
|
118
|
+
return Promise.resolve([])
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Diviner'
|
|
@@ -5,26 +5,32 @@ import { AbstractDiviner } from '@xyo-network/abstract-diviner'
|
|
|
5
5
|
import { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'
|
|
6
6
|
import { PayloadHasher } from '@xyo-network/core'
|
|
7
7
|
import { DivinerConfigSchema } from '@xyo-network/diviner-model'
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
SchemaToJsonPathTransformExpressionsDictionary,
|
|
10
|
+
SchemaToPayloadTransformersDictionary,
|
|
11
|
+
TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,
|
|
12
|
+
TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,
|
|
13
|
+
TemporalIndexingDivinerResultIndex,
|
|
14
|
+
TemporalIndexingDivinerResultIndexSchema,
|
|
15
|
+
} from '@xyo-network/diviner-temporal-indexing-model'
|
|
9
16
|
import { Labels } from '@xyo-network/module-model'
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import jsonpath from 'jsonpath'
|
|
17
|
+
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
18
|
+
import { Payload, PayloadFields } from '@xyo-network/payload-model'
|
|
13
19
|
|
|
14
|
-
import {
|
|
15
|
-
import { TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema } from './Config'
|
|
16
|
-
import { TemporalIndexCandidateToIndexDivinerParams } from './Params'
|
|
20
|
+
import { jsonPathToTransformersDictionary } from '../jsonpath'
|
|
17
21
|
|
|
18
|
-
export type IndexablePayloads = [BoundWitness,
|
|
22
|
+
export type IndexablePayloads = [BoundWitness, ...Payload[]]
|
|
19
23
|
|
|
20
24
|
const moduleName = 'TemporalIndexingDivinerIndexCandidateToIndexDiviner'
|
|
21
25
|
|
|
22
26
|
/**
|
|
23
|
-
*
|
|
27
|
+
* Diviner which transforms index candidates to indexes using JSON Path to map
|
|
28
|
+
* source properties in the supplied payloads to destination fields in the
|
|
29
|
+
* resultant index
|
|
24
30
|
*/
|
|
25
31
|
export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
26
|
-
TParams extends
|
|
27
|
-
> extends AbstractDiviner<TParams
|
|
32
|
+
TParams extends TemporalIndexingDivinerIndexCandidateToIndexDivinerParams = TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,
|
|
33
|
+
> extends AbstractDiviner<TParams> {
|
|
28
34
|
static override configSchema = TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema
|
|
29
35
|
static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema]
|
|
30
36
|
static labels: Labels = {
|
|
@@ -32,16 +38,13 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
private _indexableSchemas: string[] | undefined
|
|
35
|
-
private
|
|
41
|
+
private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined
|
|
36
42
|
|
|
37
43
|
/**
|
|
38
44
|
* List of indexable schemas for this diviner
|
|
39
45
|
*/
|
|
40
|
-
protected get indexableSchemas() {
|
|
41
|
-
|
|
42
|
-
// shouldn't change after initialization
|
|
43
|
-
if (this._indexableSchemas) return this._indexableSchemas
|
|
44
|
-
this._indexableSchemas = [...Object.keys(this.schemaTransforms)]
|
|
46
|
+
protected get indexableSchemas(): string[] {
|
|
47
|
+
if (!this._indexableSchemas) this._indexableSchemas = [...Object.keys(this.schemaTransforms)]
|
|
45
48
|
return this._indexableSchemas
|
|
46
49
|
}
|
|
47
50
|
|
|
@@ -49,74 +52,54 @@ export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
|
49
52
|
* Dictionary of schemas to payload transformers for creating indexes
|
|
50
53
|
* from the payloads within a Bound Witness
|
|
51
54
|
*/
|
|
52
|
-
protected get
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (this._schemaToPayloadTransformersDictionary) return this._schemaToPayloadTransformersDictionary
|
|
56
|
-
this._schemaToPayloadTransformersDictionary = Object.fromEntries(
|
|
57
|
-
Object.entries(this.schemaTransforms).map(([schema, jsonPathTransformerExpressions]) => {
|
|
58
|
-
const transformers = jsonPathTransformerExpressions.map((transformExpression) => {
|
|
59
|
-
const { sourcePathExpression, destinationField } = transformExpression
|
|
60
|
-
const transformer: PayloadTransformer = (x: Payload) => {
|
|
61
|
-
// eslint-disable-next-line import/no-named-as-default-member
|
|
62
|
-
const source = jsonpath.value(x, sourcePathExpression)
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
-
const transformed = {} as { [key: string]: any }
|
|
65
|
-
transformed[destinationField] = source
|
|
66
|
-
return transformed
|
|
67
|
-
}
|
|
68
|
-
return transformer
|
|
69
|
-
})
|
|
70
|
-
return [schema, transformers]
|
|
71
|
-
}),
|
|
72
|
-
)
|
|
73
|
-
return this._schemaToPayloadTransformersDictionary
|
|
55
|
+
protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {
|
|
56
|
+
if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms)
|
|
57
|
+
return this._payloadTransformers
|
|
74
58
|
}
|
|
75
59
|
|
|
76
60
|
/**
|
|
77
61
|
* The dictionary of schemas to JSON Path transform expressions for creating indexes
|
|
78
62
|
* from the payloads within a Bound Witness
|
|
79
63
|
*/
|
|
80
|
-
protected get schemaTransforms():
|
|
64
|
+
protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {
|
|
81
65
|
return assertEx(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`)
|
|
82
66
|
}
|
|
83
67
|
|
|
84
68
|
protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {
|
|
85
69
|
const bws: BoundWitness[] = payloads.filter(isBoundWitness)
|
|
86
|
-
const timestampPayloads: TimeStamp[] = payloads.filter(isTimestamp)
|
|
87
70
|
const indexablePayloads: Payload[] = payloads.filter((p) => this.isIndexablePayload(p))
|
|
88
|
-
if (bws.length &&
|
|
71
|
+
if (bws.length && indexablePayloads.length) {
|
|
89
72
|
const payloadDictionary = await PayloadHasher.toMap(payloads)
|
|
90
73
|
const validIndexableTuples: IndexablePayloads[] = bws.reduce<IndexablePayloads[]>((indexableTuples, bw) => {
|
|
91
74
|
// If this Bound Witness doesn't contain all the required schemas don't index it
|
|
92
75
|
if (!containsAll(bw.payload_schemas, this.indexableSchemas)) return indexableTuples
|
|
93
|
-
// Find the timestamp
|
|
94
|
-
const timestampPosition = bw.payload_schemas?.findIndex((schema) => schema === TimestampSchema)
|
|
95
|
-
const timestampHash = bw.payload_hashes?.[timestampPosition]
|
|
96
|
-
const timestamp = [payloadDictionary[timestampHash]].find(isTimestamp)
|
|
97
76
|
// Find the remaining indexable payloads
|
|
98
77
|
const indexablePayloadPositions = this.indexableSchemas.map((schema) => bw.payload_schemas.indexOf(schema))
|
|
99
78
|
const indexablePayloadHashes = indexablePayloadPositions.map((index) => bw.payload_hashes?.[index])
|
|
100
79
|
const indexablePayloads = indexablePayloadHashes.map((hash) => payloadDictionary[hash]).filter(exists)
|
|
101
80
|
// If we found a timestamp and the right amount of indexable payloads (of the
|
|
102
81
|
// correct schema as checked above) in this BW, then index it
|
|
103
|
-
if (
|
|
82
|
+
if (indexablePayloads.length === this.indexableSchemas.length) indexableTuples.push([bw, ...indexablePayloads])
|
|
104
83
|
return indexableTuples
|
|
105
84
|
}, [])
|
|
106
85
|
// Create the indexes from the tuples
|
|
107
86
|
const indexes = await Promise.all(
|
|
108
|
-
validIndexableTuples.map(async ([bw,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
87
|
+
validIndexableTuples.map<Promise<TemporalIndexingDivinerResultIndex>>(async ([bw, ...sourcePayloads]) => {
|
|
88
|
+
// Use the payload transformers to convert the fields from the source payloads to the destination fields
|
|
89
|
+
const indexFields = sourcePayloads
|
|
90
|
+
.map<PayloadFields[]>((payload) => {
|
|
91
|
+
// Find the transformers for this payload
|
|
92
|
+
const transformers = this.payloadTransformers[payload.schema]
|
|
93
|
+
// If transformers exist, apply them to the payload otherwise return an empty array
|
|
94
|
+
return transformers ? transformers.map((transform) => transform(payload)) : []
|
|
114
95
|
})
|
|
115
96
|
.flat()
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
return
|
|
97
|
+
// Include all the sources for reference
|
|
98
|
+
const sources = Object.keys(await PayloadHasher.toMap([bw, ...sourcePayloads]))
|
|
99
|
+
// Build and return the index
|
|
100
|
+
return new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })
|
|
101
|
+
.fields(Object.assign({ sources }, ...indexFields))
|
|
102
|
+
.build()
|
|
120
103
|
}),
|
|
121
104
|
)
|
|
122
105
|
return indexes.flat()
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { containsAll } from '@xylabs/array'
|
|
2
|
+
import { assertEx } from '@xylabs/assert'
|
|
3
|
+
import { exists } from '@xylabs/exists'
|
|
4
|
+
import { AbstractDiviner } from '@xyo-network/abstract-diviner'
|
|
5
|
+
import { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'
|
|
6
|
+
import { PayloadHasher } from '@xyo-network/core'
|
|
7
|
+
import { DivinerConfigSchema } from '@xyo-network/diviner-model'
|
|
8
|
+
import {
|
|
9
|
+
SchemaToJsonPathTransformExpressionsDictionary,
|
|
10
|
+
SchemaToPayloadTransformersDictionary,
|
|
11
|
+
TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema,
|
|
12
|
+
TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,
|
|
13
|
+
TemporalIndexingDivinerResultIndex,
|
|
14
|
+
TemporalIndexingDivinerResultIndexSchema,
|
|
15
|
+
} from '@xyo-network/diviner-temporal-indexing-model'
|
|
16
|
+
import { Labels } from '@xyo-network/module-model'
|
|
17
|
+
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
18
|
+
import { Payload, PayloadFields } from '@xyo-network/payload-model'
|
|
19
|
+
import { isTimestamp, TimeStamp, TimestampSchema } from '@xyo-network/witness-timestamp'
|
|
20
|
+
|
|
21
|
+
import { jsonPathToTransformersDictionary } from '../jsonpath'
|
|
22
|
+
|
|
23
|
+
export type IndexablePayloads = [BoundWitness, TimeStamp, ...Payload[]]
|
|
24
|
+
|
|
25
|
+
const moduleName = 'TemporalIndexingDivinerIndexCandidateToIndexDiviner'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Diviner which transforms index candidates to indexes using JSON Path to map
|
|
29
|
+
* source properties in the supplied payloads to destination fields in the
|
|
30
|
+
* resultant index
|
|
31
|
+
*/
|
|
32
|
+
export class TemporalIndexingDivinerIndexCandidateToIndexDiviner<
|
|
33
|
+
TParams extends TemporalIndexingDivinerIndexCandidateToIndexDivinerParams = TemporalIndexingDivinerIndexCandidateToIndexDivinerParams,
|
|
34
|
+
> extends AbstractDiviner<TParams> {
|
|
35
|
+
static override configSchema = TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema
|
|
36
|
+
static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerIndexCandidateToIndexDivinerConfigSchema]
|
|
37
|
+
static labels: Labels = {
|
|
38
|
+
'network.xyo.diviner.stage': 'indexCandidateToIndexDiviner',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private _indexableSchemas: string[] | undefined
|
|
42
|
+
private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* List of indexable schemas for this diviner
|
|
46
|
+
*/
|
|
47
|
+
protected get indexableSchemas(): string[] {
|
|
48
|
+
if (!this._indexableSchemas) this._indexableSchemas = [...Object.keys(this.schemaTransforms)]
|
|
49
|
+
return this._indexableSchemas
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Dictionary of schemas to payload transformers for creating indexes
|
|
54
|
+
* from the payloads within a Bound Witness
|
|
55
|
+
*/
|
|
56
|
+
protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {
|
|
57
|
+
if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms)
|
|
58
|
+
return this._payloadTransformers
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The dictionary of schemas to JSON Path transform expressions for creating indexes
|
|
63
|
+
* from the payloads within a Bound Witness
|
|
64
|
+
*/
|
|
65
|
+
protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {
|
|
66
|
+
return assertEx(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {
|
|
70
|
+
const bws: BoundWitness[] = payloads.filter(isBoundWitness)
|
|
71
|
+
const timestampPayloads: TimeStamp[] = payloads.filter(isTimestamp)
|
|
72
|
+
const indexablePayloads: Payload[] = payloads.filter((p) => this.isIndexablePayload(p))
|
|
73
|
+
if (bws.length && timestampPayloads.length && indexablePayloads.length) {
|
|
74
|
+
const payloadDictionary = await PayloadHasher.toMap(payloads)
|
|
75
|
+
const validIndexableTuples: IndexablePayloads[] = bws.reduce<IndexablePayloads[]>((indexableTuples, bw) => {
|
|
76
|
+
// If this Bound Witness doesn't contain all the required schemas don't index it
|
|
77
|
+
if (!containsAll(bw.payload_schemas, this.indexableSchemas)) return indexableTuples
|
|
78
|
+
// Find the timestamp
|
|
79
|
+
const timestampPosition = bw.payload_schemas?.findIndex((schema) => schema === TimestampSchema)
|
|
80
|
+
const timestampHash = bw.payload_hashes?.[timestampPosition]
|
|
81
|
+
const timestamp = [payloadDictionary[timestampHash]].find(isTimestamp)
|
|
82
|
+
// Find the remaining indexable payloads
|
|
83
|
+
const indexablePayloadPositions = this.indexableSchemas.map((schema) => bw.payload_schemas.indexOf(schema))
|
|
84
|
+
const indexablePayloadHashes = indexablePayloadPositions.map((index) => bw.payload_hashes?.[index])
|
|
85
|
+
const indexablePayloads = indexablePayloadHashes.map((hash) => payloadDictionary[hash]).filter(exists)
|
|
86
|
+
// If we found a timestamp and the right amount of indexable payloads (of the
|
|
87
|
+
// correct schema as checked above) in this BW, then index it
|
|
88
|
+
if (timestamp && indexablePayloads.length === this.indexableSchemas.length) indexableTuples.push([bw, timestamp, ...indexablePayloads])
|
|
89
|
+
return indexableTuples
|
|
90
|
+
}, [])
|
|
91
|
+
// Create the indexes from the tuples
|
|
92
|
+
const indexes = await Promise.all(
|
|
93
|
+
validIndexableTuples.map<Promise<TemporalIndexingDivinerResultIndex>>(async ([bw, timestampPayload, ...sourcePayloads]) => {
|
|
94
|
+
// Use the payload transformers to convert the fields from the source payloads to the destination fields
|
|
95
|
+
const indexFields = sourcePayloads
|
|
96
|
+
.map<PayloadFields[]>((payload) => {
|
|
97
|
+
// Find the transformers for this payload
|
|
98
|
+
const transformers = this.payloadTransformers[payload.schema]
|
|
99
|
+
// If transformers exist, apply them to the payload otherwise return an empty array
|
|
100
|
+
return transformers ? transformers.map((transform) => transform(payload)) : []
|
|
101
|
+
})
|
|
102
|
+
.flat()
|
|
103
|
+
// Extract the timestamp from the timestamp payload
|
|
104
|
+
const { timestamp } = timestampPayload
|
|
105
|
+
// Include all the sources for reference
|
|
106
|
+
const sources = Object.keys(await PayloadHasher.toMap([bw, timestampPayload, ...sourcePayloads]))
|
|
107
|
+
// Build and return the index
|
|
108
|
+
return new PayloadBuilder<TemporalIndexingDivinerResultIndex>({ schema: TemporalIndexingDivinerResultIndexSchema })
|
|
109
|
+
.fields(Object.assign({ sources, timestamp }, ...indexFields))
|
|
110
|
+
.build()
|
|
111
|
+
}),
|
|
112
|
+
)
|
|
113
|
+
return indexes.flat()
|
|
114
|
+
}
|
|
115
|
+
return Promise.resolve([])
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Identifies if a payload is one that is indexed by this diviner
|
|
120
|
+
* @param x The candidate payload
|
|
121
|
+
* @returns True if the payload is one indexed by this diviner, false otherwise
|
|
122
|
+
*/
|
|
123
|
+
protected isIndexablePayload = (x: Payload) => {
|
|
124
|
+
return this.indexableSchemas.includes(x?.schema)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Identifies if a schema is one that is indexed by this diviner
|
|
129
|
+
* @param schema The candidate schema
|
|
130
|
+
* @returns True if this schema is one indexed by this diviner, false otherwise
|
|
131
|
+
*/
|
|
132
|
+
protected isIndexableSchema = (schema?: string | null) => {
|
|
133
|
+
return this.indexableSchemas.some((s) => s === schema)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AbstractDiviner } from '@xyo-network/abstract-diviner'
|
|
2
|
+
import { DivinerConfigSchema } from '@xyo-network/diviner-model'
|
|
3
|
+
import { isPayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'
|
|
4
|
+
import { TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema } from '@xyo-network/diviner-temporal-indexing-model'
|
|
5
|
+
import { Labels } from '@xyo-network/module-model'
|
|
6
|
+
import { Payload } from '@xyo-network/payload-model'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Transforms an ImageThumbnailIndex response into an ImageThumbnailResponse response
|
|
10
|
+
*/
|
|
11
|
+
export class TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDiviner extends AbstractDiviner {
|
|
12
|
+
static override readonly configSchema = TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema
|
|
13
|
+
static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerIndexQueryResponseToDivinerQueryResponseDivinerConfigSchema]
|
|
14
|
+
static labels: Labels = {
|
|
15
|
+
'network.xyo.diviner.stage': 'indexQueryResponseToDivinerQueryResponseDiviner',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
protected override async divineHandler(payloads: Payload[] = []): Promise<Payload[]> {
|
|
19
|
+
// NOTE: We're not doing anything with the query payloads but some diviners
|
|
20
|
+
// might want to use this to transform from the query to the response (for example
|
|
21
|
+
// if we use a plaintext value in the query to generate a hash key in the index)
|
|
22
|
+
// const queries = payloads.filter(isPayloadDivinerQueryPayload)
|
|
23
|
+
const responses = payloads.filter((p) => !isPayloadDivinerQueryPayload(p))
|
|
24
|
+
return await Promise.resolve(responses)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Diviner'
|
|
@@ -7,15 +7,16 @@ import { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'
|
|
|
7
7
|
import { BoundWitnessDivinerQueryPayload, BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'
|
|
8
8
|
import { IndexingDivinerState } from '@xyo-network/diviner-indexing-model'
|
|
9
9
|
import { DivinerConfigSchema } from '@xyo-network/diviner-model'
|
|
10
|
+
import {
|
|
11
|
+
TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema,
|
|
12
|
+
TemporalIndexingDivinerStateToIndexCandidateDivinerParams,
|
|
13
|
+
} from '@xyo-network/diviner-temporal-indexing-model'
|
|
10
14
|
import { DivinerWrapper } from '@xyo-network/diviner-wrapper'
|
|
11
15
|
import { isModuleState, Labels, ModuleState, ModuleStateSchema } from '@xyo-network/module-model'
|
|
12
16
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
13
17
|
import { isPayloadOfSchemaType, Payload } from '@xyo-network/payload-model'
|
|
14
18
|
import { TimeStamp, TimestampSchema } from '@xyo-network/witness-timestamp'
|
|
15
19
|
|
|
16
|
-
import { TemporalStateToIndexCandidateDivinerConfigSchema } from './Config'
|
|
17
|
-
import { TemporalStateToIndexCandidateDivinerParams as TemporalIndexingDivinerStateToIndexCandidateDiviner } from './Params'
|
|
18
|
-
|
|
19
20
|
/**
|
|
20
21
|
* All Payload types involved in index candidates for indexing
|
|
21
22
|
*/
|
|
@@ -43,15 +44,16 @@ const order = 'asc'
|
|
|
43
44
|
/**
|
|
44
45
|
* The name of the module (for logging purposes)
|
|
45
46
|
*/
|
|
46
|
-
const moduleName = '
|
|
47
|
+
const moduleName = 'TemporalIndexingDivinerStateToIndexCandidateDiviner'
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
50
|
* Transforms candidates for image thumbnail indexing into their indexed representation
|
|
50
51
|
*/
|
|
51
|
-
export class
|
|
52
|
-
TParams extends
|
|
52
|
+
export class TemporalIndexingDivinerStateToIndexCandidateDiviner<
|
|
53
|
+
TParams extends TemporalIndexingDivinerStateToIndexCandidateDivinerParams = TemporalIndexingDivinerStateToIndexCandidateDivinerParams,
|
|
53
54
|
> extends AbstractDiviner<TParams> {
|
|
54
|
-
static override
|
|
55
|
+
static override readonly configSchema = TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema
|
|
56
|
+
static override configSchemas = [DivinerConfigSchema, TemporalIndexingDivinerStateToIndexCandidateDivinerConfigSchema]
|
|
55
57
|
static labels: Labels = {
|
|
56
58
|
'network.xyo.diviner.stage': 'stateToIndexCandidateDiviner',
|
|
57
59
|
}
|
|
@@ -77,6 +79,7 @@ export class TemporalStateToIndexCandidateDiviner<
|
|
|
77
79
|
const { offset } = lastState.state
|
|
78
80
|
// Get next batch of results starting from the offset
|
|
79
81
|
const boundWitnessDiviner = await this.getBoundWitnessDivinerForStore()
|
|
82
|
+
if (!boundWitnessDiviner) return [lastState]
|
|
80
83
|
const query = new PayloadBuilder<BoundWitnessDivinerQueryPayload>({ schema: BoundWitnessDivinerQuerySchema })
|
|
81
84
|
.fields({ limit: this.payloadDivinerLimit, offset, order, payload_schemas: this.payload_schemas })
|
|
82
85
|
.build()
|
|
@@ -84,6 +87,7 @@ export class TemporalStateToIndexCandidateDiviner<
|
|
|
84
87
|
if (batch.length === 0) return [lastState]
|
|
85
88
|
// Get source data
|
|
86
89
|
const sourceArchivist = await this.getArchivistForStore()
|
|
90
|
+
if (!sourceArchivist) return [lastState]
|
|
87
91
|
const indexCandidates: IndexCandidate[] = (
|
|
88
92
|
await Promise.all(batch.filter(isBoundWitness).map((bw) => this.getPayloadsInBoundWitness(bw, sourceArchivist)))
|
|
89
93
|
)
|
|
@@ -94,24 +98,32 @@ export class TemporalStateToIndexCandidateDiviner<
|
|
|
94
98
|
}
|
|
95
99
|
/**
|
|
96
100
|
* Retrieves the archivist for the payloadStore
|
|
97
|
-
* @returns The archivist for the payloadStore
|
|
101
|
+
* @returns The archivist for the payloadStore or undefined if not resolvable
|
|
98
102
|
*/
|
|
99
|
-
protected async getArchivistForStore() {
|
|
103
|
+
protected async getArchivistForStore(): Promise<ArchivistWrapper | undefined> {
|
|
104
|
+
// It should be defined, so we'll error if it's not
|
|
100
105
|
const name: string = assertEx(this.config?.payloadStore?.archivist, () => `${moduleName}: Config for payloadStore.archivist not specified`)
|
|
101
|
-
|
|
106
|
+
// It might not be resolvable (yet), so we'll return undefined if it's not
|
|
107
|
+
const mod = await this.resolve(name)
|
|
108
|
+
if (!mod) return undefined
|
|
109
|
+
// Return the wrapped archivist
|
|
102
110
|
return ArchivistWrapper.wrap(mod, this.account)
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
/**
|
|
106
114
|
* Retrieves the BoundWitness Diviner for the payloadStore
|
|
107
|
-
* @returns The BoundWitness Diviner for the payloadStore
|
|
115
|
+
* @returns The BoundWitness Diviner for the payloadStore or undefined if not resolvable
|
|
108
116
|
*/
|
|
109
|
-
protected async getBoundWitnessDivinerForStore() {
|
|
117
|
+
protected async getBoundWitnessDivinerForStore(): Promise<DivinerWrapper | undefined> {
|
|
118
|
+
// It should be defined, so we'll error if it's not
|
|
110
119
|
const name: string = assertEx(
|
|
111
120
|
this.config?.payloadStore?.boundWitnessDiviner,
|
|
112
121
|
() => `${moduleName}: Config for payloadStore.boundWitnessDiviner not specified`,
|
|
113
122
|
)
|
|
114
|
-
|
|
123
|
+
// It might not be resolvable (yet), so we'll return undefined if it's not
|
|
124
|
+
const mod = await this.resolve(name)
|
|
125
|
+
if (!mod) return undefined
|
|
126
|
+
// Return the wrapped diviner
|
|
115
127
|
return DivinerWrapper.wrap(mod, this.account)
|
|
116
128
|
}
|
|
117
129
|
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-temporal-indexing-model'
|
|
2
|
+
|
|
3
|
+
import { toPayloadTransformer } from './toPayloadTransformer'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Materializes the JSON-path expressions into memoized functions by converting a
|
|
7
|
+
* dictionary of schema to JSON Path transform expressions to a dictionary
|
|
8
|
+
* of schema to payload transformers
|
|
9
|
+
* @param schemaTransforms The schema transforms to convert
|
|
10
|
+
* @returns A dictionary of schema to payload transformers
|
|
11
|
+
*/
|
|
12
|
+
export const jsonPathToTransformersDictionary = (
|
|
13
|
+
schemaTransforms: SchemaToJsonPathTransformExpressionsDictionary,
|
|
14
|
+
): SchemaToPayloadTransformersDictionary => {
|
|
15
|
+
return Object.fromEntries(
|
|
16
|
+
Object.entries(schemaTransforms).map(([schema, jsonPathTransformerExpressions]) => {
|
|
17
|
+
const transformers = jsonPathTransformerExpressions.map(toPayloadTransformer)
|
|
18
|
+
return [schema, transformers]
|
|
19
|
+
}),
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PayloadHasher } from '@xyo-network/core'
|
|
2
|
+
import { SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-temporal-indexing-model'
|
|
3
|
+
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
4
|
+
import { Payload, PayloadFields } from '@xyo-network/payload-model'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reduces the payloads to a single payload using the supplied transformers
|
|
8
|
+
* @param payloads The payloads to reduce
|
|
9
|
+
* @param payloadTransformers The transformers to use to convert the payloads to the destination payload
|
|
10
|
+
* @param destinationSchema The schema of the destination payload
|
|
11
|
+
* @returns The reduced payload
|
|
12
|
+
*/
|
|
13
|
+
export const reducePayloads = async <T extends Payload = Payload>(
|
|
14
|
+
payloads: Payload[],
|
|
15
|
+
payloadTransformers: SchemaToPayloadTransformersDictionary,
|
|
16
|
+
destinationSchema: string,
|
|
17
|
+
): Promise<T> => {
|
|
18
|
+
// Use the payload transformers to convert the fields from the source payloads to the destination fields
|
|
19
|
+
const indexFields = payloads
|
|
20
|
+
.map<PayloadFields[]>((payload) => {
|
|
21
|
+
// Find the transformers for this payload
|
|
22
|
+
const transformers = payloadTransformers[payload.schema]
|
|
23
|
+
// If transformers exist, apply them to the payload otherwise return an empty array
|
|
24
|
+
return transformers ? transformers.map((transform) => transform(payload)) : []
|
|
25
|
+
})
|
|
26
|
+
.flat()
|
|
27
|
+
// Include all the sources for reference
|
|
28
|
+
const sources = (await PayloadHasher.hashPairs([...payloads])).map(([, hash]) => hash)
|
|
29
|
+
// Build and return the index
|
|
30
|
+
return new PayloadBuilder<T>({ schema: destinationSchema }).fields(Object.assign({ sources }, ...indexFields)).build()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Reduces the arrays of payload arrays to an array of payloads using the supplied transformers
|
|
35
|
+
* @param payloadsArray The arrays of payloads to reduce
|
|
36
|
+
* @param payloadTransformers The transformers to use to convert the payloads to the destination payloads
|
|
37
|
+
* @param destinationSchema The schema of the destination payloads
|
|
38
|
+
* @returns The reduced payloads
|
|
39
|
+
*/
|
|
40
|
+
export const reducePayloadsArray = async <T extends Payload = Payload>(
|
|
41
|
+
payloadsArray: Payload[][],
|
|
42
|
+
payloadTransformers: SchemaToPayloadTransformersDictionary,
|
|
43
|
+
destinationSchema: string,
|
|
44
|
+
): Promise<T[]> => {
|
|
45
|
+
return await Promise.all(
|
|
46
|
+
payloadsArray.map(async (payloads) => {
|
|
47
|
+
return await reducePayloads<T>(payloads, payloadTransformers, destinationSchema)
|
|
48
|
+
}),
|
|
49
|
+
)
|
|
50
|
+
}
|