@xyo-network/diviner-jsonpath-memory 5.3.22 → 5.3.24

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-memory",
3
- "version": "5.3.22",
3
+ "version": "5.3.24",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,49 +30,45 @@
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/diviner-abstract": "~5.3.22",
41
- "@xyo-network/diviner-jsonpath-model": "~5.3.22",
42
- "@xyo-network/diviner-model": "~5.3.22",
43
- "@xyo-network/payload-builder": "~5.3.22",
44
- "@xyo-network/payload-model": "~5.3.22",
45
- "jsonpath": "~1.3.0"
39
+ "jsonpath": "~1.3.0",
40
+ "@xyo-network/diviner-abstract": "~5.3.24",
41
+ "@xyo-network/diviner-jsonpath-model": "~5.3.24",
42
+ "@xyo-network/diviner-model": "~5.3.24",
43
+ "@xyo-network/payload-builder": "~5.3.24",
44
+ "@xyo-network/payload-model": "~5.3.24"
46
45
  },
47
46
  "devDependencies": {
48
47
  "@opentelemetry/api": "^1.9.1",
49
48
  "@types/jsonpath": "~0.2.4",
50
49
  "@types/node": "^25.5.0",
51
- "@xylabs/sdk-js": "^5.0.91",
52
- "@xylabs/ts-scripts-common": "~7.6.8",
53
- "@xylabs/ts-scripts-yarn3": "~7.6.8",
54
- "@xylabs/tsconfig": "~7.6.8",
55
- "@xylabs/vitest-extended": "~5.0.91",
56
- "@xyo-network/diviner-abstract": "~5.3.22",
57
- "@xyo-network/diviner-jsonpath-model": "~5.3.22",
58
- "@xyo-network/diviner-model": "~5.3.22",
59
- "@xyo-network/payload-builder": "~5.3.22",
60
- "@xyo-network/payload-model": "~5.3.22",
61
- "@xyo-network/wallet": "~5.3.22",
62
- "@xyo-network/wallet-model": "~5.3.22",
50
+ "@xylabs/sdk-js": "^5.0.93",
51
+ "@xylabs/ts-scripts-common": "~7.6.16",
52
+ "@xylabs/ts-scripts-pnpm": "~7.6.16",
53
+ "@xylabs/tsconfig": "~7.6.16",
54
+ "@xylabs/vitest-extended": "~5.0.93",
63
55
  "acorn": "^8.16.0",
64
56
  "axios": "^1.14.0",
65
- "cosmiconfig": "^9.0.1",
66
- "esbuild": "^0.27.4",
67
- "eslint": "^10.1.0",
57
+ "esbuild": "^0.28.0",
68
58
  "ethers": "^6.16.0",
69
59
  "jsonpath": "~1.3.0",
70
- "rollup": "^4.60.1",
71
60
  "tslib": "^2.8.1",
72
61
  "typescript": "~5.9.3",
73
62
  "vite": "^8.0.3",
74
63
  "vitest": "~4.1.2",
75
- "zod": "^4.3.6"
64
+ "zod": "^4.3.6",
65
+ "@xyo-network/diviner-abstract": "~5.3.24",
66
+ "@xyo-network/diviner-jsonpath-model": "~5.3.24",
67
+ "@xyo-network/diviner-model": "~5.3.24",
68
+ "@xyo-network/payload-builder": "~5.3.24",
69
+ "@xyo-network/payload-model": "~5.3.24",
70
+ "@xyo-network/wallet-model": "~5.3.24",
71
+ "@xyo-network/wallet": "~5.3.24"
76
72
  },
77
73
  "peerDependencies": {
78
74
  "@xylabs/sdk-js": "^5",
@@ -83,4 +79,4 @@
83
79
  "publishConfig": {
84
80
  "access": "public"
85
81
  }
86
- }
82
+ }
package/src/Diviner.ts DELETED
@@ -1,63 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
2
- import { AbstractDiviner } from '@xyo-network/diviner-abstract'
3
- import type { JsonPathDivinerParams, PayloadTransformer } from '@xyo-network/diviner-jsonpath-model'
4
- import { JsonPathDivinerConfigSchema } from '@xyo-network/diviner-jsonpath-model'
5
- import type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'
6
- import { PayloadBuilder } from '@xyo-network/payload-builder'
7
- import type {
8
- Payload,
9
- Schema, WithoutSchema,
10
- } from '@xyo-network/payload-model'
11
- import { PayloadSchema } from '@xyo-network/payload-model'
12
-
13
- import { toPayloadTransformer } from './jsonpath/index.ts'
14
-
15
- export class JsonPathDiviner<
16
- TParams extends JsonPathDivinerParams = JsonPathDivinerParams,
17
- TIn extends Payload = Payload,
18
- TOut extends Payload = Payload,
19
- TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<
20
- DivinerInstance<TParams, TIn, TOut>,
21
- TIn,
22
- TOut
23
- >,
24
- > extends AbstractDiviner<TParams, TIn, TOut, TEventData> {
25
- static override readonly configSchemas: Schema[] = [...super.configSchemas, JsonPathDivinerConfigSchema]
26
- static override readonly defaultConfigSchema: Schema = JsonPathDivinerConfigSchema
27
-
28
- protected _transforms: PayloadTransformer[] | undefined
29
-
30
- /**
31
- * The schema to use for the destination payloads
32
- */
33
- protected get destinationSchema(): Schema {
34
- return this.config.destinationSchema ?? PayloadSchema
35
- }
36
-
37
- /**
38
- * Dictionary of schemas to payload transformers for creating indexes
39
- * from the payloads within a Bound Witness
40
- */
41
- protected get transforms(): PayloadTransformer[] {
42
- if (!this._transforms) {
43
- const transforms = assertEx(this.config.transforms, () => 'config.transforms is not defined')
44
- this._transforms = transforms.map(toPayloadTransformer)
45
- }
46
- return this._transforms
47
- }
48
-
49
- protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {
50
- if (!payloads) return []
51
- // Create the indexes from the tuples
52
- return await Promise.all(
53
- payloads.map<Promise<TOut>>(async (payload) => {
54
- // Use the payload transformers to convert the fields from the source payloads to the destination fields
55
- const fields = this.transforms.map(transform => transform(payload)) as WithoutSchema<TOut>[]
56
- // Include all the sources for reference
57
- const sources = await PayloadBuilder.dataHashes([payload])
58
- // Build and return the index
59
- return new PayloadBuilder<TOut>({ schema: this.destinationSchema }).fields(Object.assign({ sources }, ...fields)).build()
60
- }),
61
- )
62
- }
63
- }
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './Diviner.ts'
2
- export * from './jsonpath/index.ts'
@@ -1 +0,0 @@
1
- export * from './toPayloadTransformer.ts'
@@ -1,15 +0,0 @@
1
- /**
2
- * Determines if a JSON path expression is a scalar expression (targeting
3
- * a single property in the JSON object) or a multiple value expression
4
- * @param jsonPath The JSON path expression to check
5
- * @returns
6
- */
7
- export const isScalarJsonPathExpression = (jsonPath: string) => {
8
- const multipleValueIndicators = ['*', '..', ',', ':']
9
- for (const indicator of multipleValueIndicators) {
10
- if (jsonPath.includes(indicator)) {
11
- return false
12
- }
13
- }
14
- return true
15
- }
@@ -1,29 +0,0 @@
1
- import type { JsonPathTransformExpression, PayloadTransformer } from '@xyo-network/diviner-jsonpath-model'
2
- import type { Payload } from '@xyo-network/payload-model'
3
- import jsonpath from 'jsonpath'
4
-
5
- /**
6
- * Converts a JSON Path transform expression to a payload transformer
7
- * @param transformExpression The transform expression to convert
8
- * @returns The payload transformer for the JSON Path transform expression
9
- */
10
- export const toPayloadTransformer = (transformExpression: JsonPathTransformExpression) => {
11
- const {
12
- defaultValue, destinationField, sourcePathExpression,
13
- } = transformExpression
14
- const transformer: PayloadTransformer = (x: Payload) => {
15
- const source = jsonpath.value(x, sourcePathExpression)
16
- // TODO: If the expression should return multiple values, use jsonpath.query
17
- // instead of jsonpath.value
18
- // const source =
19
- // isScalarJsonPathExpression(transformExpression.sourcePathExpression) ?
20
- // jsonpath.value(x, sourcePathExpression)
21
- // : jsonpath.query(x, sourcePathExpression)
22
- const transformed: Record<string, unknown> = {}
23
- // Assign the source value to the destination field or the default value if the source is undefined
24
- const destinationValue = source === undefined ? defaultValue : source
25
- if (destinationValue !== undefined) transformed[destinationField] = destinationValue
26
- return transformed
27
- }
28
- return transformer
29
- }