@xyo-network/node 2.43.4 → 2.43.5
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/AbstractNode.d.ts +25 -1
- package/dist/cjs/AbstractNode.d.ts.map +1 -1
- package/dist/cjs/AbstractNode.js +43 -1
- package/dist/cjs/AbstractNode.js.map +1 -1
- package/dist/cjs/MemoryNode.d.ts.map +1 -1
- package/dist/cjs/MemoryNode.js +14 -2
- package/dist/cjs/MemoryNode.js.map +1 -1
- package/dist/docs.json +2599 -1581
- package/dist/esm/AbstractNode.d.ts +25 -1
- package/dist/esm/AbstractNode.d.ts.map +1 -1
- package/dist/esm/AbstractNode.js +39 -1
- package/dist/esm/AbstractNode.js.map +1 -1
- package/dist/esm/MemoryNode.d.ts.map +1 -1
- package/dist/esm/MemoryNode.js +14 -2
- package/dist/esm/MemoryNode.js.map +1 -1
- package/package.json +11 -10
- package/src/AbstractNode.ts +48 -2
- package/src/MemoryNode.spec.ts +23 -1
- package/src/MemoryNode.ts +15 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Account } from '@xyo-network/account';
|
|
2
|
-
import { AbstractModule, Module, ModuleDescription, ModuleFilter, ModuleParams, ModuleQueryResult, ModuleRepository, XyoQueryBoundWitness } from '@xyo-network/module';
|
|
2
|
+
import { AbstractModule, Module, ModuleConstructable, ModuleDescription, ModuleFilter, ModuleParams, ModuleQueryResult, ModuleRepository, ModuleWrapper, XyoQueryBoundWitness } from '@xyo-network/module';
|
|
3
3
|
import { XyoPayload } from '@xyo-network/payload-model';
|
|
4
4
|
import { Promisable } from '@xyo-network/promise';
|
|
5
5
|
import { NodeConfig } from './Config';
|
|
@@ -22,7 +22,31 @@ export declare abstract class AbstractNode<TConfig extends NodeConfig = NodeConf
|
|
|
22
22
|
register(_module: TModule): Promisable<void>;
|
|
23
23
|
registered(): Promisable<string[]>;
|
|
24
24
|
registeredModules(): Promisable<TModule[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Resolves the supplied filter into wrapped modules
|
|
27
|
+
* @example <caption>Example using ArchivistWrapper</caption>
|
|
28
|
+
* const filter = { address: [address] }
|
|
29
|
+
* const mods: ArchivistWrapper[] = await node.resolveWrapped(ArchivistWrapper, filter)
|
|
30
|
+
* @param wrapper The ModuleWrapper class (ArchivistWrapper,
|
|
31
|
+
* DivinerWrapper, etc.)
|
|
32
|
+
* @param filter The ModuleFilter
|
|
33
|
+
* @returns An array of ModuleWrapper instances corresponding to
|
|
34
|
+
* the underlying modules matching the supplied filter
|
|
35
|
+
*/
|
|
36
|
+
resolveWrapped<T extends ModuleWrapper<TModule> = ModuleWrapper<TModule>>(wrapper: ModuleConstructable<TModule, T>, filter?: ModuleFilter): Promise<T[]>;
|
|
25
37
|
start(): Promise<this>;
|
|
38
|
+
/**
|
|
39
|
+
* Tries to resolve the supplied filter into wrapped modules
|
|
40
|
+
* @example <caption>Example using ArchivistWrapper</caption>
|
|
41
|
+
* const filter = { address: [address] }
|
|
42
|
+
* const mods: ArchivistWrapper[] = await node.tryResolveWrapped(ArchivistWrapper, filter)
|
|
43
|
+
* @param wrapper The ModuleWrapper class (ArchivistWrapper,
|
|
44
|
+
* DivinerWrapper, etc.)
|
|
45
|
+
* @param filter The ModuleFilter
|
|
46
|
+
* @returns An array of ModuleWrapper instances corresponding to
|
|
47
|
+
* the underlying modules matching the supplied filter
|
|
48
|
+
*/
|
|
49
|
+
tryResolveWrapped<T extends ModuleWrapper<TModule> = ModuleWrapper<TModule>>(wrapper: ModuleConstructable<TModule, T>, filter?: ModuleFilter): Promise<T[]>;
|
|
26
50
|
unregister(_module: TModule): Promisable<void>;
|
|
27
51
|
abstract attach(address: string): Promisable<void>;
|
|
28
52
|
abstract detach(address: string): Promisable<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractNode.d.ts","sourceRoot":"","sources":["../../src/AbstractNode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file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E,YAAY,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;IAC9D,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;CAClE;AAED,2CAA2C;AAC3C,8BAAsB,OAAO,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU,EAAE,OAAO,SAAS,cAAc,GAAG,cAAc,CAAE,SAAQ,YAAY,CAC1I,OAAO,EACP,OAAO,CACR;CAAG"}
|
package/dist/esm/AbstractNode.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert';
|
|
2
|
+
import { exists } from '@xylabs/exists';
|
|
2
3
|
import { Account } from '@xyo-network/account';
|
|
3
4
|
import { AddressSchema } from '@xyo-network/address-payload-plugin';
|
|
4
5
|
import { AbstractModule, QueryBoundWitnessWrapper, SimpleModuleResolver, XyoErrorBuilder, } from '@xyo-network/module';
|
|
@@ -49,7 +50,7 @@ export class AbstractNode extends AbstractModule {
|
|
|
49
50
|
// const [bw, payloads] = result
|
|
50
51
|
// return [bw, ...payloads]
|
|
51
52
|
// })
|
|
52
|
-
// .
|
|
53
|
+
// .flat()
|
|
53
54
|
// return [...parent, ...children]
|
|
54
55
|
return parent;
|
|
55
56
|
}
|
|
@@ -107,10 +108,47 @@ export class AbstractNode extends AbstractModule {
|
|
|
107
108
|
registeredModules() {
|
|
108
109
|
throw new Error('Method not implemented.');
|
|
109
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Resolves the supplied filter into wrapped modules
|
|
113
|
+
* @example <caption>Example using ArchivistWrapper</caption>
|
|
114
|
+
* const filter = { address: [address] }
|
|
115
|
+
* const mods: ArchivistWrapper[] = await node.resolveWrapped(ArchivistWrapper, filter)
|
|
116
|
+
* @param wrapper The ModuleWrapper class (ArchivistWrapper,
|
|
117
|
+
* DivinerWrapper, etc.)
|
|
118
|
+
* @param filter The ModuleFilter
|
|
119
|
+
* @returns An array of ModuleWrapper instances corresponding to
|
|
120
|
+
* the underlying modules matching the supplied filter
|
|
121
|
+
*/
|
|
122
|
+
async resolveWrapped(wrapper, filter) {
|
|
123
|
+
return (await this.resolve(filter)).map((mod) => new wrapper(mod));
|
|
124
|
+
}
|
|
110
125
|
async start() {
|
|
111
126
|
await super.start();
|
|
112
127
|
return this;
|
|
113
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Tries to resolve the supplied filter into wrapped modules
|
|
131
|
+
* @example <caption>Example using ArchivistWrapper</caption>
|
|
132
|
+
* const filter = { address: [address] }
|
|
133
|
+
* const mods: ArchivistWrapper[] = await node.tryResolveWrapped(ArchivistWrapper, filter)
|
|
134
|
+
* @param wrapper The ModuleWrapper class (ArchivistWrapper,
|
|
135
|
+
* DivinerWrapper, etc.)
|
|
136
|
+
* @param filter The ModuleFilter
|
|
137
|
+
* @returns An array of ModuleWrapper instances corresponding to
|
|
138
|
+
* the underlying modules matching the supplied filter
|
|
139
|
+
*/
|
|
140
|
+
async tryResolveWrapped(wrapper, filter) {
|
|
141
|
+
return (await this.tryResolve(filter))
|
|
142
|
+
.map((mod) => {
|
|
143
|
+
try {
|
|
144
|
+
return new wrapper(mod);
|
|
145
|
+
}
|
|
146
|
+
catch (_err) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
.filter(exists);
|
|
151
|
+
}
|
|
114
152
|
unregister(_module) {
|
|
115
153
|
throw new Error('Method not implemented.');
|
|
116
154
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractNode.js","sourceRoot":"","sources":["../../src/AbstractNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EACL,cAAc,
|
|
1
|
+
{"version":3,"file":"Abst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AAU,CAAC,OAAgB;QACzB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;;AAQH,2CAA2C;AAC3C,MAAM,OAAgB,OAAkG,SAAQ,YAG/H;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryNode.d.ts","sourceRoot":"","sources":["../../src/MemoryNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAkB,MAAM,qBAAqB,CAAA;AAE1E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAE,UAAU,EAAoB,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"MemoryNode.d.ts","sourceRoot":"","sources":["../../src/MemoryNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAkB,MAAM,qBAAqB,CAAA;AAE1E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAE,UAAU,EAAoB,MAAM,UAAU,CAAA;AAevD,qBAAa,UAAU,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU,EAAE,OAAO,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC;IACtI,MAAM,CAAC,YAAY,4BAAmB;IACtC,OAAO,CAAC,mBAAmB,CAA6B;WAElC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAI9E,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAKrC,MAAM,CAAC,OAAO,EAAE,MAAM;IAItB,QAAQ,CAAC,MAAM,EAAE,OAAO;IAIxB,UAAU;IAMV,iBAAiB;IAMX,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAOlD,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAO3D,UAAU,CAAC,MAAM,EAAE,OAAO;CAGpC"}
|
package/dist/esm/MemoryNode.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert';
|
|
2
2
|
import { AbstractNode } from './AbstractNode';
|
|
3
3
|
import { NodeConfigSchema } from './Config';
|
|
4
|
+
/**
|
|
5
|
+
* Used to filter duplicates during module resolution since we search
|
|
6
|
+
* internal and external resolvers for modules
|
|
7
|
+
* @param value Current Module
|
|
8
|
+
* @param index Current Module's index
|
|
9
|
+
* @param array Module Array
|
|
10
|
+
* @returns True if the Module's address is the first occurrence of
|
|
11
|
+
* that address in the array, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
const duplicateModules = (value, index, array) => {
|
|
14
|
+
return array.findIndex((v) => v.address === value.address) === index;
|
|
15
|
+
};
|
|
4
16
|
export class MemoryNode extends AbstractNode {
|
|
5
17
|
static configSchema = NodeConfigSchema;
|
|
6
18
|
registeredModuleMap = new Map();
|
|
@@ -31,13 +43,13 @@ export class MemoryNode extends AbstractNode {
|
|
|
31
43
|
const internal = this.internalResolver.resolve(filter);
|
|
32
44
|
const external = this.resolver?.resolve(filter) || [];
|
|
33
45
|
const resolved = await Promise.all([internal, external]);
|
|
34
|
-
return resolved.
|
|
46
|
+
return resolved.flat().filter(duplicateModules);
|
|
35
47
|
}
|
|
36
48
|
async tryResolve(filter) {
|
|
37
49
|
const internal = this.internalResolver.tryResolve(filter);
|
|
38
50
|
const external = this.resolver?.tryResolve(filter) || [];
|
|
39
51
|
const resolved = await Promise.all([internal, external]);
|
|
40
|
-
return resolved.
|
|
52
|
+
return resolved.flat().filter(duplicateModules);
|
|
41
53
|
}
|
|
42
54
|
unregister(module) {
|
|
43
55
|
this.registeredModuleMap.delete(module.address);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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;IACjD,CAAC;IAEQ,KAAK,CAAC,UAAU,CAAC,MAAqB;QAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QACzD,MAAM,QAAQ,GAAI,IAAI,CAAC,QAAgD,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;QACjG,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;QACxD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACjD,CAAC;IAEQ,UAAU,CAAC,MAAe;QACjC,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -11,15 +11,16 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/assert": "^2.6.15",
|
|
14
|
-
"@
|
|
15
|
-
"@xyo-network/
|
|
16
|
-
"@xyo-network/
|
|
17
|
-
"@xyo-network/
|
|
18
|
-
"@xyo-network/module
|
|
19
|
-
"@xyo-network/
|
|
20
|
-
"@xyo-network/payload-
|
|
21
|
-
"@xyo-network/payload-
|
|
22
|
-
"@xyo-network/
|
|
14
|
+
"@xylabs/exists": "^2.6.15",
|
|
15
|
+
"@xyo-network/account": "^2.43.5",
|
|
16
|
+
"@xyo-network/address-payload-plugin": "^2.43.5",
|
|
17
|
+
"@xyo-network/archivist-wrapper": "^2.43.5",
|
|
18
|
+
"@xyo-network/module": "^2.43.5",
|
|
19
|
+
"@xyo-network/module-model": "^2.43.5",
|
|
20
|
+
"@xyo-network/payload-builder": "^2.43.5",
|
|
21
|
+
"@xyo-network/payload-model": "^2.43.5",
|
|
22
|
+
"@xyo-network/payload-wrapper": "^2.43.5",
|
|
23
|
+
"@xyo-network/promise": "^2.43.5"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
26
|
"@xylabs/ts-scripts-yarn3": "^2.12.0"
|
|
@@ -57,5 +58,5 @@
|
|
|
57
58
|
},
|
|
58
59
|
"sideEffects": false,
|
|
59
60
|
"types": "dist/esm/index.d.ts",
|
|
60
|
-
"version": "2.43.
|
|
61
|
+
"version": "2.43.5"
|
|
61
62
|
}
|
package/src/AbstractNode.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
|
+
import { exists } from '@xylabs/exists'
|
|
2
3
|
import { Account } from '@xyo-network/account'
|
|
3
4
|
import { AddressSchema } from '@xyo-network/address-payload-plugin'
|
|
4
5
|
import {
|
|
5
6
|
AbstractModule,
|
|
6
7
|
Module,
|
|
8
|
+
ModuleConstructable,
|
|
7
9
|
ModuleDescription,
|
|
8
10
|
ModuleFilter,
|
|
9
11
|
ModuleParams,
|
|
10
12
|
ModuleQueryResult,
|
|
11
13
|
ModuleRepository,
|
|
14
|
+
ModuleWrapper,
|
|
12
15
|
QueryBoundWitnessWrapper,
|
|
13
16
|
SimpleModuleResolver,
|
|
14
17
|
XyoErrorBuilder,
|
|
@@ -27,7 +30,6 @@ import { XyoNodeAttachedQuerySchema, XyoNodeAttachQuerySchema, XyoNodeDetachQuer
|
|
|
27
30
|
export interface AbstractNodeParams<TConfig extends NodeConfig = NodeConfig, TModule extends Module = Module> extends ModuleParams<TConfig> {
|
|
28
31
|
internalResolver?: ModuleRepository<TModule>
|
|
29
32
|
}
|
|
30
|
-
|
|
31
33
|
export abstract class AbstractNode<TConfig extends NodeConfig = NodeConfig, TModule extends Module = Module>
|
|
32
34
|
extends AbstractModule<TConfig>
|
|
33
35
|
implements NodeModule
|
|
@@ -82,7 +84,7 @@ export abstract class AbstractNode<TConfig extends NodeConfig = NodeConfig, TMod
|
|
|
82
84
|
// const [bw, payloads] = result
|
|
83
85
|
// return [bw, ...payloads]
|
|
84
86
|
// })
|
|
85
|
-
// .
|
|
87
|
+
// .flat()
|
|
86
88
|
// return [...parent, ...children]
|
|
87
89
|
return parent
|
|
88
90
|
}
|
|
@@ -146,11 +148,55 @@ export abstract class AbstractNode<TConfig extends NodeConfig = NodeConfig, TMod
|
|
|
146
148
|
throw new Error('Method not implemented.')
|
|
147
149
|
}
|
|
148
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Resolves the supplied filter into wrapped modules
|
|
153
|
+
* @example <caption>Example using ArchivistWrapper</caption>
|
|
154
|
+
* const filter = { address: [address] }
|
|
155
|
+
* const mods: ArchivistWrapper[] = await node.resolveWrapped(ArchivistWrapper, filter)
|
|
156
|
+
* @param wrapper The ModuleWrapper class (ArchivistWrapper,
|
|
157
|
+
* DivinerWrapper, etc.)
|
|
158
|
+
* @param filter The ModuleFilter
|
|
159
|
+
* @returns An array of ModuleWrapper instances corresponding to
|
|
160
|
+
* the underlying modules matching the supplied filter
|
|
161
|
+
*/
|
|
162
|
+
async resolveWrapped<T extends ModuleWrapper<TModule> = ModuleWrapper<TModule>>(
|
|
163
|
+
wrapper: ModuleConstructable<TModule, T>,
|
|
164
|
+
filter?: ModuleFilter,
|
|
165
|
+
): Promise<T[]> {
|
|
166
|
+
return (await this.resolve(filter)).map((mod) => new wrapper(mod))
|
|
167
|
+
}
|
|
168
|
+
|
|
149
169
|
override async start() {
|
|
150
170
|
await super.start()
|
|
151
171
|
return this
|
|
152
172
|
}
|
|
153
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Tries to resolve the supplied filter into wrapped modules
|
|
176
|
+
* @example <caption>Example using ArchivistWrapper</caption>
|
|
177
|
+
* const filter = { address: [address] }
|
|
178
|
+
* const mods: ArchivistWrapper[] = await node.tryResolveWrapped(ArchivistWrapper, filter)
|
|
179
|
+
* @param wrapper The ModuleWrapper class (ArchivistWrapper,
|
|
180
|
+
* DivinerWrapper, etc.)
|
|
181
|
+
* @param filter The ModuleFilter
|
|
182
|
+
* @returns An array of ModuleWrapper instances corresponding to
|
|
183
|
+
* the underlying modules matching the supplied filter
|
|
184
|
+
*/
|
|
185
|
+
async tryResolveWrapped<T extends ModuleWrapper<TModule> = ModuleWrapper<TModule>>(
|
|
186
|
+
wrapper: ModuleConstructable<TModule, T>,
|
|
187
|
+
filter?: ModuleFilter,
|
|
188
|
+
): Promise<T[]> {
|
|
189
|
+
return (await this.tryResolve(filter))
|
|
190
|
+
.map((mod) => {
|
|
191
|
+
try {
|
|
192
|
+
return new wrapper(mod)
|
|
193
|
+
} catch (_err) {
|
|
194
|
+
return undefined
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
.filter(exists)
|
|
198
|
+
}
|
|
199
|
+
|
|
154
200
|
unregister(_module: TModule): Promisable<void> {
|
|
155
201
|
throw new Error('Method not implemented.')
|
|
156
202
|
}
|
package/src/MemoryNode.spec.ts
CHANGED
|
@@ -21,6 +21,7 @@ describe('MemoryNode', () => {
|
|
|
21
21
|
const testAccount2 = new Account({ phrase: 'testPhrase2' })
|
|
22
22
|
const testAccount3 = new Account({ phrase: 'testPhrase3' })
|
|
23
23
|
const testAccount4 = new Account({ phrase: 'testPhrase4' })
|
|
24
|
+
const archivistConfig = { schema: MemoryArchivistConfigSchema }
|
|
24
25
|
const nodeConfig = { schema: NodeConfigSchema }
|
|
25
26
|
let node: MemoryNode
|
|
26
27
|
beforeEach(async () => {
|
|
@@ -180,7 +181,6 @@ describe('MemoryNode', () => {
|
|
|
180
181
|
})
|
|
181
182
|
})
|
|
182
183
|
describe('description', () => {
|
|
183
|
-
const archivistConfig = { schema: MemoryArchivistConfigSchema }
|
|
184
184
|
const validateModuleDescription = (description: ModuleDescription) => {
|
|
185
185
|
expect(description).toBeObject()
|
|
186
186
|
expect(description.address).toBeString()
|
|
@@ -308,6 +308,28 @@ describe('MemoryNode', () => {
|
|
|
308
308
|
})
|
|
309
309
|
})
|
|
310
310
|
})
|
|
311
|
+
describe('tryResolveWrapped', () => {
|
|
312
|
+
beforeEach(async () => {
|
|
313
|
+
const modules = await Promise.all([
|
|
314
|
+
await MemoryArchivist.create({ account: testAccount2, config: archivistConfig }),
|
|
315
|
+
await MemoryArchivist.create({ account: testAccount3, config: archivistConfig }),
|
|
316
|
+
])
|
|
317
|
+
modules.map((mod) => {
|
|
318
|
+
node.register(mod)
|
|
319
|
+
node.attach(mod.address)
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
it('resolves modules wrapped as the specified type', async () => {
|
|
323
|
+
const filter = { address: [testAccount2.addressValue.hex] }
|
|
324
|
+
const modules = await node.tryResolveWrapped(ArchivistWrapper, filter)
|
|
325
|
+
expect(modules.length).toBeGreaterThan(0)
|
|
326
|
+
modules.map((mod) => {
|
|
327
|
+
expect(mod.get).toBeFunction()
|
|
328
|
+
expect(mod.find).toBeFunction()
|
|
329
|
+
expect(mod.insert).toBeFunction()
|
|
330
|
+
})
|
|
331
|
+
})
|
|
332
|
+
})
|
|
311
333
|
})
|
|
312
334
|
|
|
313
335
|
const prettyPrintDescription = (description: ModuleDescription) => {
|
package/src/MemoryNode.ts
CHANGED
|
@@ -4,6 +4,19 @@ import { Module, ModuleFilter, ModuleResolver } from '@xyo-network/module'
|
|
|
4
4
|
import { AbstractNode, AbstractNodeParams } from './AbstractNode'
|
|
5
5
|
import { NodeConfig, NodeConfigSchema } from './Config'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Used to filter duplicates during module resolution since we search
|
|
9
|
+
* internal and external resolvers for modules
|
|
10
|
+
* @param value Current Module
|
|
11
|
+
* @param index Current Module's index
|
|
12
|
+
* @param array Module Array
|
|
13
|
+
* @returns True if the Module's address is the first occurrence of
|
|
14
|
+
* that address in the array, false otherwise
|
|
15
|
+
*/
|
|
16
|
+
const duplicateModules = (value: Module, index: number, array: Module[]): value is Module => {
|
|
17
|
+
return array.findIndex((v) => v.address === value.address) === index
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
export class MemoryNode<TConfig extends NodeConfig = NodeConfig, TModule extends Module = Module> extends AbstractNode<TConfig, TModule> {
|
|
8
21
|
static configSchema = NodeConfigSchema
|
|
9
22
|
private registeredModuleMap = new Map<string, TModule>()
|
|
@@ -41,14 +54,14 @@ export class MemoryNode<TConfig extends NodeConfig = NodeConfig, TModule extends
|
|
|
41
54
|
const internal = this.internalResolver.resolve(filter)
|
|
42
55
|
const external = (this.resolver as ModuleResolver<TModule> | undefined)?.resolve(filter) || []
|
|
43
56
|
const resolved = await Promise.all([internal, external])
|
|
44
|
-
return resolved.
|
|
57
|
+
return resolved.flat().filter(duplicateModules)
|
|
45
58
|
}
|
|
46
59
|
|
|
47
60
|
override async tryResolve(filter?: ModuleFilter): Promise<TModule[]> {
|
|
48
61
|
const internal = this.internalResolver.tryResolve(filter)
|
|
49
62
|
const external = (this.resolver as ModuleResolver<TModule> | undefined)?.tryResolve(filter) || []
|
|
50
63
|
const resolved = await Promise.all([internal, external])
|
|
51
|
-
return resolved.
|
|
64
|
+
return resolved.flat().filter(duplicateModules)
|
|
52
65
|
}
|
|
53
66
|
|
|
54
67
|
override unregister(module: TModule) {
|