@xyo-network/diviner-jsonpath-aggregate-memory 5.3.22 → 5.3.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/diviner-jsonpath-aggregate-memory",
3
- "version": "5.3.22",
3
+ "version": "5.3.25",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,54 +30,50 @@
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "src",
34
33
  "!**/*.bench.*",
35
34
  "!**/*.spec.*",
36
35
  "!**/*.test.*",
37
36
  "README.md"
38
37
  ],
39
38
  "dependencies": {
40
- "@xyo-network/boundwitness-model": "~5.3.22",
41
- "@xyo-network/diviner-abstract": "~5.3.22",
42
- "@xyo-network/diviner-jsonpath-aggregate-model": "~5.3.22",
43
- "@xyo-network/diviner-jsonpath-memory": "~5.3.22",
44
- "@xyo-network/diviner-model": "~5.3.22",
45
- "@xyo-network/payload-builder": "~5.3.22",
46
- "@xyo-network/payload-model": "~5.3.22",
47
- "@xyo-network/payload-utils": "~5.3.22"
39
+ "@xyo-network/diviner-abstract": "~5.3.25",
40
+ "@xyo-network/diviner-jsonpath-memory": "~5.3.25",
41
+ "@xyo-network/boundwitness-model": "~5.3.25",
42
+ "@xyo-network/diviner-model": "~5.3.25",
43
+ "@xyo-network/diviner-jsonpath-aggregate-model": "~5.3.25",
44
+ "@xyo-network/payload-model": "~5.3.25",
45
+ "@xyo-network/payload-builder": "~5.3.25",
46
+ "@xyo-network/payload-utils": "~5.3.25"
48
47
  },
49
48
  "devDependencies": {
50
49
  "@opentelemetry/api": "^1.9.1",
51
50
  "@types/node": "^25.5.0",
52
- "@xylabs/sdk-js": "^5.0.91",
53
- "@xylabs/ts-scripts-common": "~7.6.8",
54
- "@xylabs/ts-scripts-yarn3": "~7.6.8",
55
- "@xylabs/tsconfig": "~7.6.8",
56
- "@xylabs/vitest-extended": "~5.0.91",
57
- "@xyo-network/account": "~5.3.22",
58
- "@xyo-network/account-model": "~5.3.22",
59
- "@xyo-network/boundwitness-builder": "~5.3.22",
60
- "@xyo-network/boundwitness-model": "~5.3.22",
61
- "@xyo-network/diviner-abstract": "~5.3.22",
62
- "@xyo-network/diviner-jsonpath-aggregate-model": "~5.3.22",
63
- "@xyo-network/diviner-jsonpath-memory": "~5.3.22",
64
- "@xyo-network/diviner-jsonpath-model": "~5.3.22",
65
- "@xyo-network/diviner-model": "~5.3.22",
66
- "@xyo-network/payload-builder": "~5.3.22",
67
- "@xyo-network/payload-model": "~5.3.22",
68
- "@xyo-network/payload-utils": "~5.3.22",
51
+ "@xylabs/sdk-js": "^5.0.93",
52
+ "@xylabs/ts-scripts-common": "~7.6.16",
53
+ "@xylabs/ts-scripts-pnpm": "~7.6.16",
54
+ "@xylabs/tsconfig": "~7.6.16",
55
+ "@xylabs/vitest-extended": "~5.0.93",
69
56
  "acorn": "^8.16.0",
70
57
  "axios": "^1.14.0",
71
- "cosmiconfig": "^9.0.1",
72
- "esbuild": "^0.27.4",
73
- "eslint": "^10.1.0",
58
+ "esbuild": "^0.28.0",
74
59
  "ethers": "^6.16.0",
75
- "rollup": "^4.60.1",
76
60
  "tslib": "^2.8.1",
77
61
  "typescript": "~5.9.3",
78
62
  "vite": "^8.0.3",
79
63
  "vitest": "~4.1.2",
80
- "zod": "^4.3.6"
64
+ "zod": "^4.3.6",
65
+ "@xyo-network/account-model": "~5.3.25",
66
+ "@xyo-network/account": "~5.3.25",
67
+ "@xyo-network/diviner-jsonpath-aggregate-model": "~5.3.25",
68
+ "@xyo-network/diviner-model": "~5.3.25",
69
+ "@xyo-network/diviner-abstract": "~5.3.25",
70
+ "@xyo-network/diviner-jsonpath-memory": "~5.3.25",
71
+ "@xyo-network/boundwitness-model": "~5.3.25",
72
+ "@xyo-network/diviner-jsonpath-model": "~5.3.25",
73
+ "@xyo-network/payload-builder": "~5.3.25",
74
+ "@xyo-network/boundwitness-builder": "~5.3.25",
75
+ "@xyo-network/payload-utils": "~5.3.25",
76
+ "@xyo-network/payload-model": "~5.3.25"
81
77
  },
82
78
  "peerDependencies": {
83
79
  "@xylabs/sdk-js": "^5",
@@ -88,4 +84,4 @@
88
84
  "publishConfig": {
89
85
  "access": "public"
90
86
  }
91
- }
87
+ }
package/src/Diviner.ts DELETED
@@ -1,103 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
2
- import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'
3
- import { AbstractDiviner } from '@xyo-network/diviner-abstract'
4
- import type {
5
- JsonPathAggregateDivinerParams,
6
- PayloadTransformer,
7
- SchemaToJsonPathTransformExpressionsDictionary,
8
- SchemaToPayloadTransformersDictionary,
9
- } from '@xyo-network/diviner-jsonpath-aggregate-model'
10
- import { JsonPathAggregateDivinerConfigSchema } from '@xyo-network/diviner-jsonpath-aggregate-model'
11
- import type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'
12
- import { PayloadBuilder } from '@xyo-network/payload-builder'
13
- import type { Payload, Schema } from '@xyo-network/payload-model'
14
- import { PayloadSchema } from '@xyo-network/payload-model'
15
- import { combinationsByBoundwitness, combinationsBySchema } from '@xyo-network/payload-utils'
16
-
17
- import { jsonPathToTransformersDictionary, reducePayloads } from './jsonpath/index.ts'
18
-
19
- const moduleName = 'JsonPathAggregateDiviner'
20
-
21
- export class JsonPathAggregateDiviner<
22
- TParams extends JsonPathAggregateDivinerParams = JsonPathAggregateDivinerParams,
23
- TIn extends Payload = Payload,
24
- TOut extends Payload = Payload,
25
- TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<
26
- DivinerInstance<TParams, TIn, TOut>,
27
- TIn,
28
- TOut
29
- >,
30
- > extends AbstractDiviner<TParams, TIn, TOut, TEventData> {
31
- static override readonly configSchemas: Schema[] = [...super.configSchemas, JsonPathAggregateDivinerConfigSchema]
32
- static override readonly defaultConfigSchema: Schema = JsonPathAggregateDivinerConfigSchema
33
-
34
- protected _transforms: PayloadTransformer[] | undefined
35
-
36
- private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined
37
- private _transformableSchemas: string[] | undefined
38
-
39
- /**
40
- * The schema to use for the destination payloads
41
- */
42
- protected get destinationSchema(): Schema {
43
- return this.config.destinationSchema ?? PayloadSchema
44
- }
45
-
46
- /**
47
- * Dictionary of schemas to payload transformers
48
- */
49
- protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {
50
- if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms)
51
- return this._payloadTransformers
52
- }
53
-
54
- /**
55
- * The dictionary of schemas to JSON Path transform expressions
56
- */
57
- protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {
58
- return assertEx(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`)
59
- }
60
-
61
- /**
62
- * List of transformable schemas for this diviner
63
- */
64
- protected get transformableSchemas(): string[] {
65
- if (!this._transformableSchemas) this._transformableSchemas = Object.keys(this.schemaTransforms)
66
- return this._transformableSchemas
67
- }
68
-
69
- protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {
70
- if (!payloads) return []
71
- const strippedPayloads = payloads.map((payload) => {
72
- const p = { ...payload } as TIn
73
- return PayloadBuilder.omitMeta(p as TIn)
74
- })
75
- const combinations
76
- = this.transformableSchemas.includes(BoundWitnessSchema)
77
- ? await combinationsByBoundwitness(strippedPayloads)
78
- : await combinationsBySchema(strippedPayloads, this.transformableSchemas)
79
- return await Promise.all(
80
- combinations.map((combination) => {
81
- return reducePayloads<TOut>(combination, this.payloadTransformers, this.destinationSchema, this.config.excludeSources ?? false)
82
- }),
83
- )
84
- }
85
-
86
- /**
87
- * Identifies if a payload is one that is transformed by this diviner
88
- * @param x The candidate payload
89
- * @returns True if the payload is one transformed by this diviner, false otherwise
90
- */
91
- protected isTransformablePayload = (x: Payload) => {
92
- return this.transformableSchemas.includes(x?.schema)
93
- }
94
-
95
- /**
96
- * Identifies if a schema is one that is transformed by this diviner
97
- * @param schema The candidate schema
98
- * @returns True if this schema is one transformed by this diviner, false otherwise
99
- */
100
- protected isTransformableSchema = (schema?: string | null) => {
101
- return typeof schema === 'string' ? this.transformableSchemas.includes(schema) : false
102
- }
103
- }
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './Diviner.ts'
2
- export * from './jsonpath/index.ts'
@@ -1,2 +0,0 @@
1
- export * from './jsonPathToTransformersDictionary.ts'
2
- export * from './reducePayloads.ts'
@@ -1,20 +0,0 @@
1
- import type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model'
2
- import { toPayloadTransformer } from '@xyo-network/diviner-jsonpath-memory'
3
-
4
- /**
5
- * Materializes the JSON-path expressions into memoized functions by converting a
6
- * dictionary of schema to JSON Path transform expressions to a dictionary
7
- * of schema to payload transformers
8
- * @param schemaTransforms The schema transforms to convert
9
- * @returns A dictionary of schema to payload transformers
10
- */
11
- export const jsonPathToTransformersDictionary = (
12
- schemaTransforms: SchemaToJsonPathTransformExpressionsDictionary,
13
- ): SchemaToPayloadTransformersDictionary => {
14
- return Object.fromEntries(
15
- Object.entries(schemaTransforms).map(([schema, jsonPathTransformerExpressions]) => {
16
- const transformers = jsonPathTransformerExpressions.map(toPayloadTransformer)
17
- return [schema, transformers]
18
- }),
19
- )
20
- }
@@ -1,53 +0,0 @@
1
- import { exists } from '@xylabs/sdk-js'
2
- import type { SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model'
3
- import { PayloadBuilder } from '@xyo-network/payload-builder'
4
- import type {
5
- Payload, Schema, WithoutSchema,
6
- } from '@xyo-network/payload-model'
7
-
8
- /**
9
- * Reduces the payloads to a single payload using the supplied transformers
10
- * @param payloads The payloads to reduce
11
- * @param payloadTransformers The transformers to use to convert the payloads to the destination payload
12
- * @param destinationSchema The schema of the destination payload
13
- * @param excludeSources Exclude the source hashes from the destination payload
14
- * @returns The reduced payload
15
- */
16
- export const reducePayloads = async <T extends Payload = Payload>(
17
- payloads: Payload[],
18
- payloadTransformers: SchemaToPayloadTransformersDictionary,
19
- destinationSchema: Schema,
20
- excludeSources = false,
21
- ): Promise<T> => {
22
- // Use the payload transformers to convert the fields from the source payloads to the destination fields
23
- const payloadFields = payloads.filter(exists).flatMap<WithoutSchema<Payload>[]>((payload) => {
24
- // Find the transformers for this payload
25
- const transformers = payloadTransformers[payload.schema]
26
- // If transformers exist, apply them to the payload otherwise return an empty array
27
- return transformers ? transformers.map(transform => transform(payload)) : []
28
- })
29
- // Include all the sources for reference
30
- const baseObject = excludeSources ? {} : { sources: await PayloadBuilder.dataHashes(payloads) }
31
- // Build and return the payload
32
- return new PayloadBuilder<T>({ schema: destinationSchema }).fields(Object.assign(baseObject, ...payloadFields)).build()
33
- }
34
-
35
- /**
36
- * Reduces the arrays of payload arrays to an array of payloads using the supplied transformers
37
- * @param payloadsArray The arrays of payloads to reduce
38
- * @param payloadTransformers The transformers to use to convert the payloads to the destination payloads
39
- * @param excludeSources Exclude the source hashes from the destination payload
40
- * @returns The reduced payloads
41
- */
42
- export const reducePayloadsArray = async <T extends Payload = Payload>(
43
- payloadsArray: Payload[][],
44
- payloadTransformers: SchemaToPayloadTransformersDictionary,
45
- destinationSchema: Schema,
46
- excludeSources = false,
47
- ): Promise<T[]> => {
48
- return await Promise.all(
49
- payloadsArray.map(async (payloads) => {
50
- return await reducePayloads<T>(payloads, payloadTransformers, destinationSchema, excludeSources)
51
- }),
52
- )
53
- }