@xyo-network/diviner-jsonpath-aggregate-memory 7.2.2 → 7.3.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/neutral/index.d.ts +1 -2
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +2 -112
- package/dist/neutral/index.mjs.map +4 -4
- package/package.json +10 -19
- package/dist/neutral/Diviner.d.ts +0 -41
- package/dist/neutral/Diviner.d.ts.map +0 -1
- package/dist/neutral/jsonpath/index.d.ts +0 -3
- package/dist/neutral/jsonpath/index.d.ts.map +0 -1
- package/dist/neutral/jsonpath/jsonPathToTransformersDictionary.d.ts +0 -10
- package/dist/neutral/jsonpath/jsonPathToTransformersDictionary.d.ts.map +0 -1
- package/dist/neutral/jsonpath/reducePayloads.d.ts +0 -20
- package/dist/neutral/jsonpath/reducePayloads.d.ts.map +0 -1
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gDAAgD,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,113 +1,3 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
import { JsonPathAggregateDivinerConfigSchema } from "@xyo-network/diviner-jsonpath-aggregate-model";
|
|
4
|
-
import { AbstractDiviner } from "@xyo-network/sdk/diviner-abstract";
|
|
5
|
-
import {
|
|
6
|
-
BoundWitnessSchema,
|
|
7
|
-
combinationsByBoundwitness,
|
|
8
|
-
PayloadBuilder as PayloadBuilder2,
|
|
9
|
-
PayloadSchema
|
|
10
|
-
} from "@xyo-network/sdk-protocol";
|
|
11
|
-
import { combinationsBySchema } from "@xyo-network/sdk-protocol/payload-utils";
|
|
12
|
-
|
|
13
|
-
// src/jsonpath/jsonPathToTransformersDictionary.ts
|
|
14
|
-
import { toPayloadTransformer } from "@xyo-network/diviner-jsonpath-memory";
|
|
15
|
-
var jsonPathToTransformersDictionary = (schemaTransforms) => {
|
|
16
|
-
return Object.fromEntries(
|
|
17
|
-
Object.entries(schemaTransforms).map(([schema, jsonPathTransformerExpressions]) => {
|
|
18
|
-
const transformers = jsonPathTransformerExpressions.map(toPayloadTransformer);
|
|
19
|
-
return [schema, transformers];
|
|
20
|
-
})
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// src/jsonpath/reducePayloads.ts
|
|
25
|
-
import { exists } from "@ariestools/sdk";
|
|
26
|
-
import { PayloadBuilder } from "@xyo-network/sdk-protocol";
|
|
27
|
-
var reducePayloads = async (payloads, payloadTransformers, destinationSchema, excludeSources = false) => {
|
|
28
|
-
const payloadFields = payloads.filter(exists).flatMap((payload) => {
|
|
29
|
-
const transformers = payloadTransformers[payload.schema];
|
|
30
|
-
return transformers ? transformers.map((transform) => transform(payload)) : [];
|
|
31
|
-
});
|
|
32
|
-
const baseObject = excludeSources ? {} : { sources: await PayloadBuilder.dataHashes(payloads) };
|
|
33
|
-
return new PayloadBuilder({ schema: destinationSchema }).fields(Object.assign(baseObject, ...payloadFields)).build();
|
|
34
|
-
};
|
|
35
|
-
var reducePayloadsArray = async (payloadsArray, payloadTransformers, destinationSchema, excludeSources = false) => {
|
|
36
|
-
return await Promise.all(
|
|
37
|
-
payloadsArray.map(async (payloads) => {
|
|
38
|
-
return await reducePayloads(payloads, payloadTransformers, destinationSchema, excludeSources);
|
|
39
|
-
})
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// src/Diviner.ts
|
|
44
|
-
var moduleName = "JsonPathAggregateDiviner";
|
|
45
|
-
var JsonPathAggregateDiviner = class extends AbstractDiviner {
|
|
46
|
-
static configSchemas = [...super.configSchemas, JsonPathAggregateDivinerConfigSchema];
|
|
47
|
-
static defaultConfigSchema = JsonPathAggregateDivinerConfigSchema;
|
|
48
|
-
_transforms;
|
|
49
|
-
_payloadTransformers;
|
|
50
|
-
_transformableSchemas;
|
|
51
|
-
/**
|
|
52
|
-
* The schema to use for the destination payloads
|
|
53
|
-
*/
|
|
54
|
-
get destinationSchema() {
|
|
55
|
-
return this.config.destinationSchema ?? PayloadSchema;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Dictionary of schemas to payload transformers
|
|
59
|
-
*/
|
|
60
|
-
get payloadTransformers() {
|
|
61
|
-
this._payloadTransformers ??= jsonPathToTransformersDictionary(this.schemaTransforms);
|
|
62
|
-
return this._payloadTransformers;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* The dictionary of schemas to JSON Path transform expressions
|
|
66
|
-
*/
|
|
67
|
-
get schemaTransforms() {
|
|
68
|
-
return assertEx(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* List of transformable schemas for this diviner
|
|
72
|
-
*/
|
|
73
|
-
get transformableSchemas() {
|
|
74
|
-
this._transformableSchemas ??= Object.keys(this.schemaTransforms);
|
|
75
|
-
return this._transformableSchemas;
|
|
76
|
-
}
|
|
77
|
-
async divineHandler(payloads) {
|
|
78
|
-
if (!payloads) return [];
|
|
79
|
-
const strippedPayloads = payloads.map((payload) => {
|
|
80
|
-
const p = { ...payload };
|
|
81
|
-
return PayloadBuilder2.omitStorageMeta(p);
|
|
82
|
-
});
|
|
83
|
-
const combinations = this.transformableSchemas.includes(BoundWitnessSchema) ? await combinationsByBoundwitness(strippedPayloads) : await combinationsBySchema(strippedPayloads, this.transformableSchemas);
|
|
84
|
-
return await Promise.all(
|
|
85
|
-
combinations.map((combination) => {
|
|
86
|
-
return reducePayloads(combination, this.payloadTransformers, this.destinationSchema, this.config.excludeSources ?? false);
|
|
87
|
-
})
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Identifies if a payload is one that is transformed by this diviner
|
|
92
|
-
* @param x The candidate payload
|
|
93
|
-
* @returns True if the payload is one transformed by this diviner, false otherwise
|
|
94
|
-
*/
|
|
95
|
-
isTransformablePayload = (x) => {
|
|
96
|
-
return this.transformableSchemas.includes(x?.schema);
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Identifies if a schema is one that is transformed by this diviner
|
|
100
|
-
* @param schema The candidate schema
|
|
101
|
-
* @returns True if this schema is one transformed by this diviner, false otherwise
|
|
102
|
-
*/
|
|
103
|
-
isTransformableSchema = (schema) => {
|
|
104
|
-
return typeof schema === "string" ? this.transformableSchemas.includes(schema) : false;
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
export {
|
|
108
|
-
JsonPathAggregateDiviner,
|
|
109
|
-
jsonPathToTransformersDictionary,
|
|
110
|
-
reducePayloads,
|
|
111
|
-
reducePayloadsArray
|
|
112
|
-
};
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@xyo-network/diviner-jsonpath-aggregate/memory";
|
|
113
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
6
|
-
"names": [
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Compatibility shim: this package re-exports from @xyo-network/diviner-jsonpath-aggregate/memory.\nexport * from '@xyo-network/diviner-jsonpath-aggregate/memory'\n"],
|
|
5
|
+
"mappings": ";AACA,cAAc;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/diviner-jsonpath-aggregate-memory",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -34,33 +34,24 @@
|
|
|
34
34
|
"README.md"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@xyo-network/diviner-jsonpath-aggregate
|
|
38
|
-
"@xyo-network/diviner-jsonpath-memory": "~7.2.2",
|
|
39
|
-
"@xyo-network/sdk": "~7.2.2"
|
|
37
|
+
"@xyo-network/diviner-jsonpath-aggregate": "~7.3.0"
|
|
40
38
|
},
|
|
41
39
|
"devDependencies": {
|
|
42
|
-
"@ariestools/sdk": "~8.1.
|
|
43
|
-
"@ariestools/toolchain": "~
|
|
44
|
-
"@ariestools/tsconfig": "~
|
|
45
|
-
"@ariestools/vitest-extended": "~8.0.3",
|
|
40
|
+
"@ariestools/sdk": "~8.1.9",
|
|
41
|
+
"@ariestools/toolchain": "~9.1.1",
|
|
42
|
+
"@ariestools/tsconfig": "~9.1.1",
|
|
46
43
|
"@opentelemetry/api": "~1.9.1",
|
|
47
|
-
"@xyo-network/sdk-protocol": "~7.
|
|
48
|
-
"eslint": "~10.
|
|
44
|
+
"@xyo-network/sdk-protocol": "~7.3.1",
|
|
45
|
+
"eslint": "~10.9.0",
|
|
49
46
|
"eslint-import-resolver-typescript": "~4.4.5",
|
|
50
47
|
"typescript": "~6.0.3",
|
|
51
|
-
"
|
|
52
|
-
"vitest": "~4.1.10",
|
|
53
|
-
"zod": "~4.4.3",
|
|
54
|
-
"@xyo-network/diviner-jsonpath-model": "~7.2.2"
|
|
55
|
-
},
|
|
56
|
-
"peerDependencies": {
|
|
57
|
-
"@ariestools/sdk": "^8.1",
|
|
58
|
-
"@xyo-network/sdk-protocol": "^7.2"
|
|
48
|
+
"zod": "~4.4.3"
|
|
59
49
|
},
|
|
60
50
|
"engines": {
|
|
61
51
|
"node": "^24"
|
|
62
52
|
},
|
|
63
53
|
"publishConfig": {
|
|
64
54
|
"access": "public"
|
|
65
|
-
}
|
|
55
|
+
},
|
|
56
|
+
"deprecated": "Use @xyo-network/diviner-jsonpath-aggregate/memory instead. This package is a compatibility shim only and will not receive further updates."
|
|
66
57
|
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { JsonPathAggregateDivinerParams, PayloadTransformer, SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model';
|
|
2
|
-
import { AbstractDiviner } from '@xyo-network/sdk/diviner-abstract';
|
|
3
|
-
import type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/sdk/diviner-model';
|
|
4
|
-
import type { Payload, Schema } from '@xyo-network/sdk-protocol';
|
|
5
|
-
export declare class JsonPathAggregateDiviner<TParams extends JsonPathAggregateDivinerParams = JsonPathAggregateDivinerParams, TIn extends Payload = Payload, TOut extends Payload = Payload, TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut>> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {
|
|
6
|
-
static readonly configSchemas: Schema[];
|
|
7
|
-
static readonly defaultConfigSchema: Schema;
|
|
8
|
-
protected _transforms: PayloadTransformer[] | undefined;
|
|
9
|
-
private _payloadTransformers;
|
|
10
|
-
private _transformableSchemas;
|
|
11
|
-
/**
|
|
12
|
-
* The schema to use for the destination payloads
|
|
13
|
-
*/
|
|
14
|
-
protected get destinationSchema(): Schema;
|
|
15
|
-
/**
|
|
16
|
-
* Dictionary of schemas to payload transformers
|
|
17
|
-
*/
|
|
18
|
-
protected get payloadTransformers(): SchemaToPayloadTransformersDictionary;
|
|
19
|
-
/**
|
|
20
|
-
* The dictionary of schemas to JSON Path transform expressions
|
|
21
|
-
*/
|
|
22
|
-
protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary;
|
|
23
|
-
/**
|
|
24
|
-
* List of transformable schemas for this diviner
|
|
25
|
-
*/
|
|
26
|
-
protected get transformableSchemas(): string[];
|
|
27
|
-
protected divineHandler(payloads?: TIn[]): Promise<TOut[]>;
|
|
28
|
-
/**
|
|
29
|
-
* Identifies if a payload is one that is transformed by this diviner
|
|
30
|
-
* @param x The candidate payload
|
|
31
|
-
* @returns True if the payload is one transformed by this diviner, false otherwise
|
|
32
|
-
*/
|
|
33
|
-
protected isTransformablePayload: (x: Payload) => boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Identifies if a schema is one that is transformed by this diviner
|
|
36
|
-
* @param schema The candidate schema
|
|
37
|
-
* @returns True if this schema is one transformed by this diviner, false otherwise
|
|
38
|
-
*/
|
|
39
|
-
protected isTransformableSchema: (schema?: string | null) => boolean;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=Diviner.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../src/Diviner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,8BAA8B,EAC9B,kBAAkB,EAClB,8CAA8C,EAC9C,qCAAqC,EACtC,MAAM,+CAA+C,CAAA;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAC7F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAUhE,qBAAa,wBAAwB,CACnC,OAAO,SAAS,8BAA8B,GAAG,8BAA8B,EAC/E,GAAG,SAAS,OAAO,GAAG,OAAO,EAC7B,IAAI,SAAS,OAAO,GAAG,OAAO,EAC9B,UAAU,SAAS,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,sBAAsB,CAChH,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EACnC,GAAG,EACH,IAAI,CACL,CACD,SAAQ,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC;IACvD,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAAiE;IACjH,gBAAyB,mBAAmB,EAAE,MAAM,CAAuC;IAE3F,SAAS,CAAC,WAAW,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAAA;IAEvD,OAAO,CAAC,oBAAoB,CAAmD;IAC/E,OAAO,CAAC,qBAAqB,CAAsB;IAEnD;;OAEG;IACH,SAAS,KAAK,iBAAiB,IAAI,MAAM,CAExC;IAED;;OAEG;IACH,SAAS,KAAK,mBAAmB,IAAI,qCAAqC,CAGzE;IAED;;OAEG;IACH,SAAS,KAAK,gBAAgB,IAAI,8CAA8C,CAE/E;IAED;;OAEG;IACH,SAAS,KAAK,oBAAoB,IAAI,MAAM,EAAE,CAG7C;cAEwB,aAAa,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAiBzE;;;;OAIG;IACH,SAAS,CAAC,sBAAsB,GAAI,GAAG,OAAO,KAAG,OAAO,CAEvD;IAED;;;;OAIG;IACH,SAAS,CAAC,qBAAqB,GAAI,SAAS,MAAM,GAAG,IAAI,KAAG,OAAO,CAElE;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jsonpath/index.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAA;AACrD,cAAc,qBAAqB,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model';
|
|
2
|
-
/**
|
|
3
|
-
* Materializes the JSON-path expressions into memoized functions by converting a
|
|
4
|
-
* dictionary of schema to JSON Path transform expressions to a dictionary
|
|
5
|
-
* of schema to payload transformers
|
|
6
|
-
* @param schemaTransforms The schema transforms to convert
|
|
7
|
-
* @returns A dictionary of schema to payload transformers
|
|
8
|
-
*/
|
|
9
|
-
export declare const jsonPathToTransformersDictionary: (schemaTransforms: SchemaToJsonPathTransformExpressionsDictionary) => SchemaToPayloadTransformersDictionary;
|
|
10
|
-
//# sourceMappingURL=jsonPathToTransformersDictionary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonPathToTransformersDictionary.d.ts","sourceRoot":"","sources":["../../../src/jsonpath/jsonPathToTransformersDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8CAA8C,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAAA;AAG1J;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,GAC3C,kBAAkB,8CAA8C,KAC/D,qCAOF,CAAA"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model';
|
|
2
|
-
import type { Payload, Schema } from '@xyo-network/sdk-protocol';
|
|
3
|
-
/**
|
|
4
|
-
* Reduces the payloads to a single payload using the supplied transformers
|
|
5
|
-
* @param payloads The payloads to reduce
|
|
6
|
-
* @param payloadTransformers The transformers to use to convert the payloads to the destination payload
|
|
7
|
-
* @param destinationSchema The schema of the destination payload
|
|
8
|
-
* @param excludeSources Exclude the source hashes from the destination payload
|
|
9
|
-
* @returns The reduced payload
|
|
10
|
-
*/
|
|
11
|
-
export declare const reducePayloads: <T extends Payload = Payload>(payloads: Payload[], payloadTransformers: SchemaToPayloadTransformersDictionary, destinationSchema: Schema, excludeSources?: boolean) => Promise<T>;
|
|
12
|
-
/**
|
|
13
|
-
* Reduces the arrays of payload arrays to an array of payloads using the supplied transformers
|
|
14
|
-
* @param payloadsArray The arrays of payloads to reduce
|
|
15
|
-
* @param payloadTransformers The transformers to use to convert the payloads to the destination payloads
|
|
16
|
-
* @param excludeSources Exclude the source hashes from the destination payload
|
|
17
|
-
* @returns The reduced payloads
|
|
18
|
-
*/
|
|
19
|
-
export declare const reducePayloadsArray: <T extends Payload = Payload>(payloadsArray: Payload[][], payloadTransformers: SchemaToPayloadTransformersDictionary, destinationSchema: Schema, excludeSources?: boolean) => Promise<T[]>;
|
|
20
|
-
//# sourceMappingURL=reducePayloads.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reducePayloads.d.ts","sourceRoot":"","sources":["../../../src/jsonpath/reducePayloads.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAAA;AAC1G,OAAO,KAAK,EACV,OAAO,EAAE,MAAM,EAChB,MAAM,2BAA2B,CAAA;AAGlC;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAU,CAAC,SAAS,OAAO,GAAG,OAAO,EAC9D,UAAU,OAAO,EAAE,EACnB,qBAAqB,qCAAqC,EAC1D,mBAAmB,MAAM,EACzB,wBAAsB,KACrB,OAAO,CAAC,CAAC,CAcX,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAU,CAAC,SAAS,OAAO,GAAG,OAAO,EACnE,eAAe,OAAO,EAAE,EAAE,EAC1B,qBAAqB,qCAAqC,EAC1D,mBAAmB,MAAM,EACzB,wBAAsB,KACrB,OAAO,CAAC,CAAC,EAAE,CAMb,CAAA"}
|