@xyo-network/node 2.41.8 → 2.41.10
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/NodeWrapper.d.ts +2 -2
- package/dist/cjs/NodeWrapper.d.ts.map +1 -1
- package/dist/cjs/NodeWrapper.js +1 -1
- package/dist/cjs/NodeWrapper.js.map +1 -1
- package/dist/docs.json +137 -137
- package/dist/esm/NodeWrapper.d.ts +2 -2
- package/dist/esm/NodeWrapper.d.ts.map +1 -1
- package/dist/esm/NodeWrapper.js +2 -2
- package/dist/esm/NodeWrapper.js.map +1 -1
- package/package.json +6 -6
- package/src/MemoryNode.spec.ts +20 -20
- package/src/NodeWrapper.ts +3 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArchivistWrapper } from '@xyo-network/archivist';
|
|
2
2
|
import { Module, ModuleFilter, ModuleWrapper, XyoModule } from '@xyo-network/module';
|
|
3
3
|
import { Promisable } from '@xyo-network/promise';
|
|
4
4
|
import { NodeModule } from './NodeModule';
|
|
5
5
|
export declare class NodeWrapper extends ModuleWrapper implements NodeModule {
|
|
6
6
|
isModuleResolver: boolean;
|
|
7
7
|
private _archivist?;
|
|
8
|
-
get archivist():
|
|
8
|
+
get archivist(): ArchivistWrapper;
|
|
9
9
|
attach(address: string, name?: string): Promise<void>;
|
|
10
10
|
attached(): Promise<string[]>;
|
|
11
11
|
attachedModules(): Promise<XyoModule[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeWrapper.d.ts","sourceRoot":"","sources":["../../src/NodeWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"NodeWrapper.d.ts","sourceRoot":"","sources":["../../src/NodeWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAEpF,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAYzC,qBAAa,WAAY,SAAQ,aAAc,YAAW,UAAU;IAC3D,gBAAgB,UAAO;IAE9B,OAAO,CAAC,UAAU,CAAC,CAAkB;IAErC,IAAW,SAAS,qBAGnB;IAEK,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOrD,QAAQ,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAQ7B,eAAe,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAKvC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5C,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;IAIpD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIzB,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAM/B,iBAAiB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAK/C,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;IAIvD,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;IAI1D,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAGlC;AAED,0CAA0C;AAC1C,qBAAa,cAAe,SAAQ,WAAW;CAAG"}
|
package/dist/esm/NodeWrapper.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArchivistWrapper } from '@xyo-network/archivist';
|
|
2
2
|
import { ModuleWrapper } from '@xyo-network/module';
|
|
3
3
|
import { PayloadWrapper } from '@xyo-network/payload';
|
|
4
4
|
import compact from 'lodash/compact';
|
|
@@ -7,7 +7,7 @@ export class NodeWrapper extends ModuleWrapper {
|
|
|
7
7
|
isModuleResolver = true;
|
|
8
8
|
_archivist;
|
|
9
9
|
get archivist() {
|
|
10
|
-
this._archivist = this._archivist ?? new
|
|
10
|
+
this._archivist = this._archivist ?? new ArchivistWrapper(this.module);
|
|
11
11
|
return this._archivist;
|
|
12
12
|
}
|
|
13
13
|
async attach(address, name) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeWrapper.js","sourceRoot":"","sources":["../../src/NodeWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"NodeWrapper.js","sourceRoot":"","sources":["../../src/NodeWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAwB,aAAa,EAAa,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,OAAO,MAAM,gBAAgB,CAAA;AAGpC,OAAO,EAEL,0BAA0B,EAE1B,wBAAwB,EAExB,wBAAwB,EAExB,4BAA4B,GAC7B,MAAM,WAAW,CAAA;AAElB,MAAM,OAAO,WAAY,SAAQ,aAAa;IACrC,gBAAgB,GAAG,IAAI,CAAA;IAEtB,UAAU,CAAmB;IAErC,IAAW,SAAS;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACtE,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,IAAa;QACzC,MAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAqB,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,wBAAwB,EAAE,CAAC,CAAA;QAClH,MAAM,KAAK,GAAG,MAAM,I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C,iBAAiB,CAAC,CAAA;IAChC,CAAC;IAED,QAAQ,CAAC,OAAe;QACtB,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAChC,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAyB,EAAE,MAAM,EAAE,4BAA4B,EAAE,CAAC,CAAA;QAC3G,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA;QACjD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAA;QACzC,OAAO,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;IAC5D,CAAC;IAED,OAAO,CAAC,OAAqB;QAC3B,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAChC,CAAC;IAED,UAAU,CAAC,OAAqB;QAC9B,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAChC,CAAC;IAED,UAAU,CAAC,OAAe;QACxB,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAChC,CAAC;CACF;AAED,0CAA0C;AAC1C,MAAM,OAAO,cAAe,SAAQ,WAAW;CAAG"}
|
package/package.json
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/assert": "^2.6.9",
|
|
14
|
-
"@xyo-network/account": "^2.41.
|
|
15
|
-
"@xyo-network/archivist": "^2.41.
|
|
16
|
-
"@xyo-network/module": "^2.41.
|
|
17
|
-
"@xyo-network/payload": "^2.41.
|
|
18
|
-
"@xyo-network/promise": "^2.41.
|
|
14
|
+
"@xyo-network/account": "^2.41.10",
|
|
15
|
+
"@xyo-network/archivist": "^2.41.10",
|
|
16
|
+
"@xyo-network/module": "^2.41.10",
|
|
17
|
+
"@xyo-network/payload": "^2.41.10",
|
|
18
|
+
"@xyo-network/promise": "^2.41.10",
|
|
19
19
|
"lodash": "^4.17.21",
|
|
20
20
|
"tslib": "^2.4.1"
|
|
21
21
|
},
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
},
|
|
61
61
|
"sideEffects": false,
|
|
62
62
|
"types": "dist/esm/index.d.ts",
|
|
63
|
-
"version": "2.41.
|
|
63
|
+
"version": "2.41.10"
|
|
64
64
|
}
|
package/src/MemoryNode.spec.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable max-statements */
|
|
2
|
-
import {
|
|
2
|
+
import { ArchivistWrapper, MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist'
|
|
3
3
|
import {
|
|
4
|
+
ArchivistPayloadDiviner,
|
|
4
5
|
DivinerModule,
|
|
5
|
-
|
|
6
|
+
DivinerWrapper,
|
|
6
7
|
XyoArchivistPayloadDivinerConfigSchema,
|
|
7
|
-
XyoDivinerWrapper,
|
|
8
8
|
XyoHuriPayload,
|
|
9
9
|
XyoHuriSchema,
|
|
10
10
|
} from '@xyo-network/diviner'
|
|
@@ -27,10 +27,10 @@ describe('MemoryNode', () => {
|
|
|
27
27
|
})
|
|
28
28
|
describe('create', () => {
|
|
29
29
|
it('Creates MemoryNode', async () => {
|
|
30
|
-
const XyoMemoryArchivist = (await import('@xyo-network/archivist')).
|
|
30
|
+
const XyoMemoryArchivist = (await import('@xyo-network/archivist')).MemoryArchivist
|
|
31
31
|
const node: NodeModule = await MemoryNode.create()
|
|
32
32
|
const archivist = await XyoMemoryArchivist.create()
|
|
33
|
-
const diviner: XyoModule = await
|
|
33
|
+
const diviner: XyoModule = await ArchivistPayloadDiviner.create({
|
|
34
34
|
config: { archivist: archivist.address, schema: XyoArchivistPayloadDivinerConfigSchema },
|
|
35
35
|
resolver: new XyoModuleResolver().add(archivist),
|
|
36
36
|
})
|
|
@@ -47,7 +47,7 @@ describe('MemoryNode', () => {
|
|
|
47
47
|
.fields({ test: true })
|
|
48
48
|
.build()
|
|
49
49
|
|
|
50
|
-
const foundArchivistWrapper = foundArchivist ? new
|
|
50
|
+
const foundArchivistWrapper = foundArchivist ? new ArchivistWrapper(foundArchivist) : undefined
|
|
51
51
|
await foundArchivistWrapper?.insert([testPayload])
|
|
52
52
|
|
|
53
53
|
/*const subscribeQuery: XyoModuleSubscribeQuery = { payloads: [testPayload], schema: XyoModuleSubscribeQuerySchema }
|
|
@@ -60,10 +60,10 @@ describe('MemoryNode', () => {
|
|
|
60
60
|
const huri = new PayloadWrapper(payloads[0]).hash
|
|
61
61
|
const huriPayload: XyoHuriPayload = { huri: [huri], schema: XyoHuriSchema }
|
|
62
62
|
const module = (await node.resolve({ address: [diviner.address] })).shift() as DivinerModule
|
|
63
|
-
const foundDiviner = module ? new
|
|
63
|
+
const foundDiviner = module ? new DivinerWrapper(module) : null
|
|
64
64
|
expect(foundDiviner).toBeDefined()
|
|
65
65
|
if (foundDiviner) {
|
|
66
|
-
const foundDivinerWrapper = new
|
|
66
|
+
const foundDivinerWrapper = new DivinerWrapper(foundDiviner)
|
|
67
67
|
const payloads = await foundDivinerWrapper.divine([huriPayload])
|
|
68
68
|
// console.log(`payloads: ${JSON.stringify(payloads, null, 2)}`)
|
|
69
69
|
expect(payloads?.length).toBe(1)
|
|
@@ -77,7 +77,7 @@ describe('MemoryNode', () => {
|
|
|
77
77
|
})
|
|
78
78
|
describe('register', () => {
|
|
79
79
|
it('registers module', async () => {
|
|
80
|
-
const module = await
|
|
80
|
+
const module = await MemoryArchivist.create()
|
|
81
81
|
node.register(module)
|
|
82
82
|
})
|
|
83
83
|
})
|
|
@@ -91,7 +91,7 @@ describe('MemoryNode', () => {
|
|
|
91
91
|
describe('with modules registered', () => {
|
|
92
92
|
let module: XyoModule
|
|
93
93
|
beforeEach(async () => {
|
|
94
|
-
module = await
|
|
94
|
+
module = await MemoryArchivist.create()
|
|
95
95
|
node.register(module)
|
|
96
96
|
})
|
|
97
97
|
it('lists addresses of registered modules', () => {
|
|
@@ -104,7 +104,7 @@ describe('MemoryNode', () => {
|
|
|
104
104
|
describe('attach', () => {
|
|
105
105
|
let module: XyoModule
|
|
106
106
|
beforeEach(async () => {
|
|
107
|
-
module = await
|
|
107
|
+
module = await MemoryArchivist.create()
|
|
108
108
|
node.register(module)
|
|
109
109
|
})
|
|
110
110
|
it('attaches module', () => {
|
|
@@ -114,7 +114,7 @@ describe('MemoryNode', () => {
|
|
|
114
114
|
describe('attached', () => {
|
|
115
115
|
let module: XyoModule
|
|
116
116
|
beforeEach(async () => {
|
|
117
|
-
module = await
|
|
117
|
+
module = await MemoryArchivist.create()
|
|
118
118
|
node.register(module)
|
|
119
119
|
})
|
|
120
120
|
describe('with no modules attached', () => {
|
|
@@ -138,7 +138,7 @@ describe('MemoryNode', () => {
|
|
|
138
138
|
describe('detach', () => {
|
|
139
139
|
let module: XyoModule
|
|
140
140
|
beforeEach(async () => {
|
|
141
|
-
module = await
|
|
141
|
+
module = await MemoryArchivist.create()
|
|
142
142
|
node.register(module)
|
|
143
143
|
node.attach(module.address)
|
|
144
144
|
})
|
|
@@ -152,7 +152,7 @@ describe('MemoryNode', () => {
|
|
|
152
152
|
describe('registeredModules', () => {
|
|
153
153
|
let module: XyoModule
|
|
154
154
|
beforeEach(async () => {
|
|
155
|
-
module = await
|
|
155
|
+
module = await MemoryArchivist.create()
|
|
156
156
|
})
|
|
157
157
|
describe('with no modules registered', () => {
|
|
158
158
|
it('returns empty array', () => {
|
|
@@ -171,7 +171,7 @@ describe('MemoryNode', () => {
|
|
|
171
171
|
})
|
|
172
172
|
describe('unregister', () => {
|
|
173
173
|
it('un-registers module', async () => {
|
|
174
|
-
const module = await
|
|
174
|
+
const module = await MemoryArchivist.create()
|
|
175
175
|
node.register(module)
|
|
176
176
|
expect(node.registeredModules()).toContain(module)
|
|
177
177
|
node.unregister(module)
|
|
@@ -179,7 +179,7 @@ describe('MemoryNode', () => {
|
|
|
179
179
|
})
|
|
180
180
|
})
|
|
181
181
|
describe('description', () => {
|
|
182
|
-
const archivistConfig = { schema:
|
|
182
|
+
const archivistConfig = { schema: MemoryArchivistConfigSchema }
|
|
183
183
|
const validateModuleDescription = (description: ModuleDescription) => {
|
|
184
184
|
expect(description).toBeObject()
|
|
185
185
|
expect(description.address).toBeString()
|
|
@@ -202,8 +202,8 @@ describe('MemoryNode', () => {
|
|
|
202
202
|
describe('node with child modules', () => {
|
|
203
203
|
beforeEach(async () => {
|
|
204
204
|
const modules = await Promise.all([
|
|
205
|
-
await
|
|
206
|
-
await
|
|
205
|
+
await MemoryArchivist.create({ account: testAccount2, config: archivistConfig }),
|
|
206
|
+
await MemoryArchivist.create({ account: testAccount3, config: archivistConfig }),
|
|
207
207
|
])
|
|
208
208
|
modules.map((mod) => {
|
|
209
209
|
node.register(mod)
|
|
@@ -224,12 +224,12 @@ describe('MemoryNode', () => {
|
|
|
224
224
|
describe('node with nested nodes and modules', () => {
|
|
225
225
|
beforeEach(async () => {
|
|
226
226
|
const nestedNode = await MemoryNode.create({ account: testAccount2, config: nodeConfig })
|
|
227
|
-
const nestedModules = await Promise.all([await
|
|
227
|
+
const nestedModules = await Promise.all([await MemoryArchivist.create({ account: testAccount3, config: archivistConfig })])
|
|
228
228
|
nestedModules.map((mod) => {
|
|
229
229
|
nestedNode.register(mod)
|
|
230
230
|
nestedNode.attach(mod.address)
|
|
231
231
|
})
|
|
232
|
-
const rootModules: XyoModule[] = await Promise.all([await
|
|
232
|
+
const rootModules: XyoModule[] = await Promise.all([await MemoryArchivist.create({ account: testAccount4, config: archivistConfig })])
|
|
233
233
|
rootModules.push(nestedNode)
|
|
234
234
|
rootModules.map((mod) => {
|
|
235
235
|
node.register(mod)
|
package/src/NodeWrapper.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArchivistWrapper } from '@xyo-network/archivist'
|
|
2
2
|
import { Module, ModuleFilter, ModuleWrapper, XyoModule } from '@xyo-network/module'
|
|
3
3
|
import { PayloadWrapper } from '@xyo-network/payload'
|
|
4
4
|
import { Promisable } from '@xyo-network/promise'
|
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
export class NodeWrapper extends ModuleWrapper implements NodeModule {
|
|
20
20
|
public isModuleResolver = true
|
|
21
21
|
|
|
22
|
-
private _archivist?:
|
|
22
|
+
private _archivist?: ArchivistWrapper
|
|
23
23
|
|
|
24
24
|
public get archivist() {
|
|
25
|
-
this._archivist = this._archivist ?? new
|
|
25
|
+
this._archivist = this._archivist ?? new ArchivistWrapper(this.module)
|
|
26
26
|
return this._archivist
|
|
27
27
|
}
|
|
28
28
|
|