@xyo-network/diviner-jsonpatch-memory 4.3.0 → 5.0.1

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-jsonpatch-memory",
3
- "version": "4.3.0",
3
+ "version": "5.0.1",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -28,24 +28,28 @@
28
28
  },
29
29
  "module": "dist/neutral/index.mjs",
30
30
  "types": "dist/neutral/index.d.ts",
31
+ "files": [
32
+ "dist",
33
+ "src"
34
+ ],
31
35
  "dependencies": {
32
- "@xylabs/assert": "^4.15.0",
33
- "@xylabs/exists": "^4.15.0",
34
- "@xyo-network/diviner-abstract": "^4.3.0",
35
- "@xyo-network/diviner-jsonpatch-model": "^4.3.0",
36
- "@xyo-network/diviner-model": "^4.3.0",
37
- "@xyo-network/module-model": "^4.3.0",
38
- "@xyo-network/payload-model": "^4.3.0",
39
- "fast-json-patch": "^3.1.1"
36
+ "@xylabs/assert": "~5.0.3",
37
+ "@xylabs/exists": "~5.0.3",
38
+ "@xyo-network/diviner-abstract": "~5.0.1",
39
+ "@xyo-network/diviner-jsonpatch-model": "~5.0.1",
40
+ "@xyo-network/diviner-model": "~5.0.1",
41
+ "@xyo-network/module-model": "~5.0.1",
42
+ "@xyo-network/payload-model": "~5.0.1",
43
+ "fast-json-patch": "~3.1.1"
40
44
  },
41
45
  "devDependencies": {
42
- "@xylabs/ts-scripts-yarn3": "^7.0.1",
43
- "@xylabs/tsconfig": "^7.0.1",
44
- "@xylabs/vitest-extended": "^4.15.0",
45
- "@xyo-network/wallet": "^4.3.0",
46
- "@xyo-network/wallet-model": "^4.3.0",
47
- "typescript": "^5.8.3",
48
- "vitest": "^3.2.4"
46
+ "@xylabs/ts-scripts-yarn3": "~7.1.0",
47
+ "@xylabs/tsconfig": "~7.1.0",
48
+ "@xylabs/vitest-extended": "~5.0.3",
49
+ "@xyo-network/wallet": "~5.0.1",
50
+ "@xyo-network/wallet-model": "~5.0.1",
51
+ "typescript": "~5.9.2",
52
+ "vitest": "~3.2.4"
49
53
  },
50
54
  "publishConfig": {
51
55
  "access": "public"
@@ -0,0 +1,204 @@
1
+ import '@xylabs/vitest-extended'
2
+
3
+ import type { JsonPatchDivinerConfig } from '@xyo-network/diviner-jsonpatch-model'
4
+ import { JsonPatchDivinerConfigSchema } from '@xyo-network/diviner-jsonpatch-model'
5
+ import type { AnyPayload } from '@xyo-network/payload-model'
6
+ import { HDWallet } from '@xyo-network/wallet'
7
+ import type { WalletInstance } from '@xyo-network/wallet-model'
8
+ import {
9
+ beforeAll,
10
+ describe, expect, it,
11
+ } from 'vitest'
12
+
13
+ import { JsonPatchDiviner } from '../Diviner.ts'
14
+
15
+ const cases: [string, JsonPatchDivinerConfig, AnyPayload[], AnyPayload[]][] = [
16
+ [
17
+ 'Adds a value',
18
+ {
19
+ operations: [{
20
+ op: 'add', path: '/value', value: 'foo',
21
+ }],
22
+ schema: JsonPatchDivinerConfigSchema,
23
+ },
24
+ [{ schema: 'network.xyo.test' }],
25
+ [{ schema: 'network.xyo.test', value: 'foo' }],
26
+ ],
27
+ [
28
+ 'Removes a value',
29
+ {
30
+ operations: [{ op: 'remove', path: '/value' }],
31
+ schema: JsonPatchDivinerConfigSchema,
32
+ },
33
+ [{ schema: 'network.xyo.test', value: 'foo' }],
34
+ [{ schema: 'network.xyo.test' }],
35
+ ],
36
+ [
37
+ 'Replaces a schema',
38
+ {
39
+ operations: [{
40
+ op: 'replace', path: '/schema', value: 'network.xyo.debug',
41
+ }],
42
+ schema: JsonPatchDivinerConfigSchema,
43
+ },
44
+ [{ schema: 'network.xyo.test' }],
45
+ [{ schema: 'network.xyo.debug' }],
46
+ ],
47
+ [
48
+ 'Replaces a value',
49
+ {
50
+ operations: [{
51
+ op: 'replace', path: '/value', value: 'bar',
52
+ }],
53
+ schema: JsonPatchDivinerConfigSchema,
54
+ },
55
+ [{ schema: 'network.xyo.test', value: 'foo' }],
56
+ [{ schema: 'network.xyo.test', value: 'bar' }],
57
+ ],
58
+ [
59
+ 'Moves a value',
60
+ {
61
+ operations: [{
62
+ from: '/value', op: 'move', path: '/target',
63
+ }],
64
+ schema: JsonPatchDivinerConfigSchema,
65
+ },
66
+ [{ schema: 'network.xyo.test', value: 'foo' }],
67
+ [{ schema: 'network.xyo.test', target: 'foo' }],
68
+ ],
69
+ [
70
+ 'Copies a value',
71
+ {
72
+ operations: [{
73
+ from: '/value', op: 'copy', path: '/target',
74
+ }],
75
+ schema: JsonPatchDivinerConfigSchema,
76
+ },
77
+ [{ schema: 'network.xyo.test', value: 'foo' }],
78
+ [{
79
+ schema: 'network.xyo.test', target: 'foo', value: 'foo',
80
+ }],
81
+ ],
82
+ [
83
+ 'Filters by schema',
84
+ {
85
+ operations: [{
86
+ op: 'test', path: '/schema', value: 'network.xyo.test',
87
+ }],
88
+ schema: JsonPatchDivinerConfigSchema,
89
+ },
90
+ [
91
+ { schema: 'network.xyo.test', value: 'foo' },
92
+ { schema: 'network.xyo.debug', value: 'bar' },
93
+ ],
94
+ [{ schema: 'network.xyo.test', value: 'foo' }],
95
+ ],
96
+ [
97
+ 'Filters by value',
98
+ {
99
+ operations: [{
100
+ op: 'test', path: '/value', value: 'foo',
101
+ }],
102
+ schema: JsonPatchDivinerConfigSchema,
103
+ },
104
+ [
105
+ { schema: 'network.xyo.test', value: 'foo' },
106
+ { schema: 'network.xyo.test', value: 'bar' },
107
+ ],
108
+ [{ schema: 'network.xyo.test', value: 'foo' }],
109
+ ],
110
+ [
111
+ 'Handles multiple operations',
112
+ {
113
+ operations: [
114
+ {
115
+ op: 'test', path: '/schema', value: 'network.xyo.test',
116
+ },
117
+ {
118
+ op: 'add', path: '/value', value: 'foo',
119
+ },
120
+ {
121
+ from: '/value', op: 'copy', path: '/target',
122
+ },
123
+ {
124
+ op: 'replace', path: '/target', value: 'bar',
125
+ },
126
+ ],
127
+ schema: JsonPatchDivinerConfigSchema,
128
+ },
129
+ [{ schema: 'network.xyo.test' }, { schema: 'network.xyo.debug' }],
130
+ [{
131
+ schema: 'network.xyo.test', target: 'bar', value: 'foo',
132
+ }],
133
+ ],
134
+ [
135
+ 'Filters multiple by schema',
136
+ {
137
+ operations: [{
138
+ op: 'test', path: '/schema', value: 'network.xyo.test',
139
+ }],
140
+ schema: JsonPatchDivinerConfigSchema,
141
+ },
142
+ [
143
+ { schema: 'network.xyo.test', value: 'foo' },
144
+ { schema: 'network.xyo.test', value: 'bar' },
145
+ ],
146
+ [
147
+ { schema: 'network.xyo.test', value: 'foo' },
148
+ { schema: 'network.xyo.test', value: 'bar' },
149
+ ],
150
+ ],
151
+ [
152
+ 'Filters if property defined',
153
+ {
154
+ operations: [{
155
+ op: 'test', path: '/value', value: 'foo',
156
+ }],
157
+ schema: JsonPatchDivinerConfigSchema,
158
+ },
159
+ [{ schema: 'network.xyo.test', value: 'foo' }],
160
+ [{ schema: 'network.xyo.test', value: 'foo' }],
161
+ ],
162
+ [
163
+ 'Filters if property null',
164
+ {
165
+ operations: [{
166
+ op: 'test', path: '/value', value: null,
167
+ }],
168
+ schema: JsonPatchDivinerConfigSchema,
169
+ },
170
+ [{ schema: 'network.xyo.test', value: null }],
171
+ [{ schema: 'network.xyo.test', value: null }],
172
+ ],
173
+ /* [
174
+ 'Filters if property not null',
175
+ {
176
+ operations: [{
177
+ not: true, op: 'test', path: '/value', value: null,
178
+ }],
179
+ schema: JsonPatchDivinerConfigSchema,
180
+ },
181
+ [{ schema: 'network.xyo.test', value: 'foo' }],
182
+ [{ schema: 'network.xyo.test', value: 'foo' }],
183
+ ], */
184
+ ]
185
+
186
+ /**
187
+ * @group module
188
+ * @group diviner
189
+ */
190
+
191
+ describe('JsonPatchDiviner', () => {
192
+ let wallet: WalletInstance
193
+ beforeAll(async () => {
194
+ wallet = await HDWallet.random()
195
+ })
196
+ describe('divine', () => {
197
+ it.each(cases)('%s', async (_title, config, input, expected) => {
198
+ const sut = await JsonPatchDiviner.create({ account: wallet, config })
199
+ const result = await sut.divine(input)
200
+ expect(result).toBeArrayOfSize(expected.length)
201
+ expect(result).toMatchObject(expected)
202
+ })
203
+ })
204
+ })
package/xy.config.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
2
- const config: XyTsupConfig = {
3
- compile: {
4
- browser: {},
5
- neutral: { src: true },
6
- node: {},
7
- },
8
- }
9
-
10
- export default config