@xyo-network/archivist 2.36.8 → 2.36.9
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/cjs/XyoArchivist.d.ts +2 -2
- package/dist/cjs/XyoArchivist.d.ts.map +1 -1
- package/dist/cjs/XyoArchivist.js +3 -10
- package/dist/cjs/XyoArchivist.js.map +1 -1
- package/dist/cjs/XyoCookieArchivist.d.ts.map +1 -1
- package/dist/cjs/XyoCookieArchivist.js +7 -12
- package/dist/cjs/XyoCookieArchivist.js.map +1 -1
- package/dist/cjs/XyoMemoryArchivist.d.ts.map +1 -1
- package/dist/cjs/XyoMemoryArchivist.js +7 -12
- package/dist/cjs/XyoMemoryArchivist.js.map +1 -1
- package/dist/cjs/XyoStorageArchivist.d.ts.map +1 -1
- package/dist/cjs/XyoStorageArchivist.js +7 -12
- package/dist/cjs/XyoStorageArchivist.js.map +1 -1
- package/dist/docs.json +641 -629
- package/dist/esm/XyoArchivist.d.ts +2 -2
- package/dist/esm/XyoArchivist.d.ts.map +1 -1
- package/dist/esm/XyoArchivist.js +3 -9
- package/dist/esm/XyoArchivist.js.map +1 -1
- package/dist/esm/XyoCookieArchivist.d.ts.map +1 -1
- package/dist/esm/XyoCookieArchivist.js +7 -12
- package/dist/esm/XyoCookieArchivist.js.map +1 -1
- package/dist/esm/XyoMemoryArchivist.d.ts.map +1 -1
- package/dist/esm/XyoMemoryArchivist.js +7 -12
- package/dist/esm/XyoMemoryArchivist.js.map +1 -1
- package/dist/esm/XyoStorageArchivist.d.ts.map +1 -1
- package/dist/esm/XyoStorageArchivist.js +7 -12
- package/dist/esm/XyoStorageArchivist.js.map +1 -1
- package/package.json +6 -6
- package/src/XyoArchivist.ts +3 -10
- package/src/XyoCookieArchivist.ts +7 -13
- package/src/XyoMemoryArchivist.ts +7 -13
- package/src/XyoStorageArchivist.spec.ts +24 -0
- package/src/XyoStorageArchivist.ts +7 -13
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* @jest-environment jsdom
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { PayloadWrapper } from '@xyo-network/payload'
|
|
6
|
+
|
|
5
7
|
import { testArchivistAll, testArchivistRoundTrip } from './test.spec.test'
|
|
8
|
+
import { XyoMemoryArchivist } from './XyoMemoryArchivist'
|
|
6
9
|
import { XyoStorageArchivist } from './XyoStorageArchivist'
|
|
7
10
|
|
|
8
11
|
testArchivistRoundTrip(new XyoStorageArchivist({ namespace: 'test', type: 'local' }), 'local')
|
|
@@ -19,3 +22,24 @@ test('XyoArchivist Private Key Save', () => {
|
|
|
19
22
|
const storage2 = new XyoStorageArchivist({ namespace: 'test', persistAccount: true, type: 'local' })
|
|
20
23
|
expect(storage2.address).toBe(address)
|
|
21
24
|
})
|
|
25
|
+
|
|
26
|
+
test('XyoArchivist Parent Write Through', async () => {
|
|
27
|
+
const memory = new XyoMemoryArchivist()
|
|
28
|
+
|
|
29
|
+
const resolver = (address: string) => {
|
|
30
|
+
return address === memory.address ? memory : null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const storage = new XyoStorageArchivist(
|
|
34
|
+
{ namespace: 'test', parents: { write: [memory.address] }, persistAccount: true, type: 'local' },
|
|
35
|
+
undefined,
|
|
36
|
+
resolver,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
const wrapper = new PayloadWrapper({ schema: 'network.xyo.test' })
|
|
40
|
+
|
|
41
|
+
await storage.insert([wrapper.payload])
|
|
42
|
+
|
|
43
|
+
expect((await storage.get([wrapper.hash])).length).toBe(1)
|
|
44
|
+
expect((await memory.get([wrapper.hash])).length).toBe(1)
|
|
45
|
+
})
|
|
@@ -33,12 +33,6 @@ export type XyoStorageArchivistConfig = XyoArchivistConfig<{
|
|
|
33
33
|
persistAccount?: boolean
|
|
34
34
|
}>
|
|
35
35
|
|
|
36
|
-
class StorageArchivistError extends Error {
|
|
37
|
-
constructor(action: string, error: Error['cause'], message?: string) {
|
|
38
|
-
super(`Storage Archivist [${action}] failed${message ? ` (${message})` : ''}`, { cause: error })
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
36
|
export class XyoStorageArchivist extends XyoArchivist<XyoStorageArchivistConfig> {
|
|
43
37
|
public get type() {
|
|
44
38
|
return this.config?.type ?? 'local'
|
|
@@ -122,7 +116,7 @@ export class XyoStorageArchivist extends XyoArchivist<XyoStorageArchivistConfig>
|
|
|
122
116
|
})
|
|
123
117
|
} catch (ex) {
|
|
124
118
|
console.error(`Error: ${JSON.stringify(ex, null, 2)}`)
|
|
125
|
-
throw
|
|
119
|
+
throw ex
|
|
126
120
|
}
|
|
127
121
|
}
|
|
128
122
|
|
|
@@ -131,7 +125,7 @@ export class XyoStorageArchivist extends XyoArchivist<XyoStorageArchivistConfig>
|
|
|
131
125
|
this.storage.clear()
|
|
132
126
|
} catch (ex) {
|
|
133
127
|
console.error(`Error: ${JSON.stringify(ex, null, 2)}`)
|
|
134
|
-
throw
|
|
128
|
+
throw ex
|
|
135
129
|
}
|
|
136
130
|
}
|
|
137
131
|
|
|
@@ -145,7 +139,7 @@ export class XyoStorageArchivist extends XyoArchivist<XyoStorageArchivistConfig>
|
|
|
145
139
|
)
|
|
146
140
|
} catch (ex) {
|
|
147
141
|
console.error(`Error: ${JSON.stringify(ex, null, 2)}`)
|
|
148
|
-
throw
|
|
142
|
+
throw ex
|
|
149
143
|
}
|
|
150
144
|
}
|
|
151
145
|
|
|
@@ -168,7 +162,7 @@ export class XyoStorageArchivist extends XyoArchivist<XyoStorageArchivistConfig>
|
|
|
168
162
|
return [result[0], ...parentBoundWitnesses]
|
|
169
163
|
} catch (ex) {
|
|
170
164
|
console.error(`Error: ${ex}`)
|
|
171
|
-
throw
|
|
165
|
+
throw ex
|
|
172
166
|
}
|
|
173
167
|
}
|
|
174
168
|
|
|
@@ -183,7 +177,7 @@ export class XyoStorageArchivist extends XyoArchivist<XyoStorageArchivistConfig>
|
|
|
183
177
|
return x
|
|
184
178
|
} catch (ex) {
|
|
185
179
|
console.error(`Error: ${JSON.stringify(ex, null, 2)}`)
|
|
186
|
-
throw
|
|
180
|
+
throw ex
|
|
187
181
|
}
|
|
188
182
|
}
|
|
189
183
|
|
|
@@ -192,7 +186,7 @@ export class XyoStorageArchivist extends XyoArchivist<XyoStorageArchivistConfig>
|
|
|
192
186
|
return Object.entries(this.storage.getAll()).map(([, value]) => value)
|
|
193
187
|
} catch (ex) {
|
|
194
188
|
console.error(`Error: ${JSON.stringify(ex, null, 2)}`)
|
|
195
|
-
throw
|
|
189
|
+
throw ex
|
|
196
190
|
}
|
|
197
191
|
}
|
|
198
192
|
|
|
@@ -220,7 +214,7 @@ export class XyoStorageArchivist extends XyoArchivist<XyoStorageArchivistConfig>
|
|
|
220
214
|
)
|
|
221
215
|
} catch (ex) {
|
|
222
216
|
console.error(`Error: ${JSON.stringify(ex, null, 2)}`)
|
|
223
|
-
throw
|
|
217
|
+
throw ex
|
|
224
218
|
}
|
|
225
219
|
}
|
|
226
220
|
}
|