@xyo-network/diviner-boundwitness-memory 5.3.20 → 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-boundwitness-memory",
3
- "version": "5.3.20",
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,37 +30,52 @@
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "src",
34
33
  "!**/*.bench.*",
35
34
  "!**/*.spec.*",
36
- "!**/*.test.*"
35
+ "!**/*.test.*",
36
+ "README.md"
37
37
  ],
38
38
  "dependencies": {
39
- "@xyo-network/boundwitness-model": "~5.3.20",
40
- "@xyo-network/diviner-boundwitness-abstract": "~5.3.20",
41
- "@xyo-network/diviner-boundwitness-model": "~5.3.20",
42
- "@xyo-network/payload-builder": "~5.3.20",
43
- "@xyo-network/payload-model": "~5.3.20"
39
+ "@xyo-network/diviner-boundwitness-abstract": "~5.3.24",
40
+ "@xyo-network/boundwitness-model": "~5.3.24",
41
+ "@xyo-network/diviner-boundwitness-model": "~5.3.24",
42
+ "@xyo-network/payload-builder": "~5.3.24",
43
+ "@xyo-network/payload-model": "~5.3.24"
44
44
  },
45
45
  "devDependencies": {
46
- "@xylabs/sdk-js": "^5.0.90",
47
- "@xylabs/ts-scripts-common": "~7.5.6",
48
- "@xylabs/ts-scripts-yarn3": "~7.5.6",
49
- "@xylabs/tsconfig": "~7.5.6",
50
- "@xylabs/vitest-extended": "~5.0.90",
51
- "@xyo-network/account": "~5.3.20",
52
- "@xyo-network/archivist-memory": "~5.3.20",
53
- "@xyo-network/boundwitness-builder": "~5.3.20",
54
- "@xyo-network/node-memory": "~5.3.20",
46
+ "@opentelemetry/api": "^1.9.1",
47
+ "@types/node": "^25.5.0",
48
+ "@xylabs/sdk-js": "^5.0.93",
49
+ "@xylabs/ts-scripts-common": "~7.6.16",
50
+ "@xylabs/ts-scripts-pnpm": "~7.6.16",
51
+ "@xylabs/tsconfig": "~7.6.16",
52
+ "@xylabs/vitest-extended": "~5.0.93",
53
+ "acorn": "^8.16.0",
54
+ "axios": "^1.14.0",
55
+ "esbuild": "^0.28.0",
56
+ "ethers": "^6.16.0",
57
+ "tslib": "^2.8.1",
55
58
  "typescript": "~5.9.3",
59
+ "vite": "^8.0.3",
56
60
  "vitest": "~4.1.2",
57
- "zod": "^4.3.6"
61
+ "zod": "^4.3.6",
62
+ "@xyo-network/archivist-memory": "~5.3.24",
63
+ "@xyo-network/account": "~5.3.24",
64
+ "@xyo-network/diviner-boundwitness-abstract": "~5.3.24",
65
+ "@xyo-network/diviner-boundwitness-model": "~5.3.24",
66
+ "@xyo-network/boundwitness-model": "~5.3.24",
67
+ "@xyo-network/boundwitness-builder": "~5.3.24",
68
+ "@xyo-network/payload-builder": "~5.3.24",
69
+ "@xyo-network/payload-model": "~5.3.24",
70
+ "@xyo-network/node-memory": "~5.3.24"
58
71
  },
59
72
  "peerDependencies": {
60
73
  "@xylabs/sdk-js": "^5",
74
+ "ethers": "^6",
75
+ "tslib": "^2.8.1",
61
76
  "zod": "^4"
62
77
  },
63
78
  "publishConfig": {
64
79
  "access": "public"
65
80
  }
66
- }
81
+ }
@@ -1,75 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
2
- import { type BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'
3
- import { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'
4
- import type {
5
- BoundWitnessDivinerParams,
6
- BoundWitnessDivinerQueryPayload,
7
- } from '@xyo-network/diviner-boundwitness-model'
8
- import { isBoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'
9
- import { isStorageMeta } from '@xyo-network/payload-model'
10
-
11
- import { applyBoundWitnessDivinerQueryPayload } from './applyBoundWitnessDivinerQueryPayload.ts'
12
-
13
- export interface EqualityComparisonOperators {
14
- /**
15
- * 'Not Equal To' comparison operator.
16
- * Compares the field with the specified string value,
17
- * selecting records where the field value does not match the provided string.
18
- * Example: field != 'value'
19
- */
20
- '!=': string
21
-
22
- /**
23
- * 'Less Than' comparison operator.
24
- * Compares the field with the specified string value,
25
- * selecting records where the field value is lexicographically less than the provided string.
26
- * Example: field < 'value'
27
- */
28
- '<': string
29
-
30
- /**
31
- * 'Less Than or Equal To' comparison operator.
32
- * Compares the field with the specified string value,
33
- * selecting records where the field value is lexicographically less than or equal to the provided string.
34
- * Example: field <= 'value'
35
- */
36
- '<=': string
37
-
38
- /**
39
- * 'Equal To' comparison operator.
40
- * Compares the field with the specified string value,
41
- * selecting records where the field value matches the provided string exactly.
42
- * Example: field = 'value'
43
- */
44
- '=': string
45
-
46
- /**
47
- * 'Greater Than' comparison operator.
48
- * Compares the field with the specified string value,
49
- * selecting records where the field value is lexicographically greater than the provided string.
50
- * Example: field > 'value'
51
- */
52
- '>': string
53
-
54
- /**
55
- * 'Greater Than or Equal To' comparison operator.
56
- * Compares the field with the specified string value,
57
- * selecting records where the field value is lexicographically greater than or equal to the provided string.
58
- * Example: field >= 'value'
59
- */
60
- '>=': string
61
- }
62
-
63
- export class MemoryBoundWitnessDiviner<
64
- TParams extends BoundWitnessDivinerParams = BoundWitnessDivinerParams,
65
- TIn extends BoundWitnessDivinerQueryPayload = BoundWitnessDivinerQueryPayload,
66
- TOut extends BoundWitness = BoundWitness,
67
- > extends BoundWitnessDiviner<TParams, TIn, TOut> {
68
- protected override async divineHandler(payloads?: TIn[]) {
69
- const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')
70
- if (!filter) return []
71
- const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')
72
- let bws = ((await archivist?.next({ limit: 10_000 })) ?? []).filter(x => isBoundWitness(x) && isStorageMeta(x))
73
- return applyBoundWitnessDivinerQueryPayload(filter, bws) as TOut[]
74
- }
75
- }
@@ -1,51 +0,0 @@
1
- import {
2
- assertEx, containsAll,
3
- exists, hexFromHexString,
4
- } from '@xylabs/sdk-js'
5
- import { type BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'
6
- import type { BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'
7
- import { PayloadBuilder } from '@xyo-network/payload-builder'
8
- import type {
9
- Payload,
10
- WithStorageMeta,
11
- } from '@xyo-network/payload-model'
12
- import { SequenceConstants } from '@xyo-network/payload-model'
13
-
14
- // eslint-disable-next-line complexity
15
- export const applyBoundWitnessDivinerQueryPayload = (filter?: BoundWitnessDivinerQueryPayload, payloads: WithStorageMeta<Payload>[] = []): BoundWitness[] => {
16
- if (!filter) return []
17
- const {
18
- addresses, cursor, destination, limit, order = 'desc', payload_hashes, payload_schemas, sourceQuery,
19
- } = filter
20
-
21
- const sortedPayloads = PayloadBuilder.sortByStorageMeta(payloads, order === 'desc' ? -1 : 1)
22
- const parsedCursor = cursor === undefined ? (order === 'desc') ? SequenceConstants.maxLocalSequence : SequenceConstants.minLocalSequence : cursor
23
- const parsedOffset = (order === 'desc')
24
- ? sortedPayloads.findIndex(bw => bw._sequence < parsedCursor)
25
- : sortedPayloads.findIndex(bw => bw._sequence > parsedCursor)
26
- if (parsedOffset === -1) return []
27
- const payloadSubset = sortedPayloads.slice(parsedOffset)
28
-
29
- let bws = payloadSubset.filter(isBoundWitness)
30
- const allAddresses = addresses?.map(address => hexFromHexString(address)).filter(exists)
31
- if (allAddresses?.length) bws = bws.filter(bw => containsAll(bw.addresses, allAddresses))
32
- if (payload_hashes?.length) bws = bws.filter(bw => containsAll(bw.payload_hashes, payload_hashes))
33
- if (payload_schemas?.length) bws = bws.filter(bw => containsAll(bw.payload_schemas, payload_schemas))
34
- if (sourceQuery) bws = bws.filter(bw => bw?.$sourceQuery === sourceQuery)
35
- // If there's a destination filter of the right kind
36
- if (destination && Array.isArray(destination) && destination?.length > 0) {
37
- const targetFilter = assertEx(destination, () => 'Missing destination')
38
- // Find all BWs that satisfy the destination constraint
39
- bws = bws.filter((bw) => {
40
- const targetDestinationField = (bw as { $destination?: string | string[] })?.$destination
41
- // If the destination field is an array and contains at least one element
42
- return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0
43
- // Check that the targetDestinationField contains all the elements in the targetFilter
44
- ? containsAll(targetFilter, targetDestinationField ?? [])
45
- // Otherwise, filter it out
46
- : false
47
- })
48
- }
49
- const parsedLimit = limit ?? bws.length
50
- return bws.slice(0, parsedLimit)
51
- }
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './applyBoundWitnessDivinerQueryPayload.ts'
2
- export * from './MemoryBoundWitnessDiviner.ts'