@xyo-network/node-abstract 2.93.1 → 2.93.3
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/browser/AbstractNode.d.cts +2 -3
- package/dist/browser/AbstractNode.d.cts.map +1 -1
- package/dist/browser/AbstractNode.d.mts +2 -3
- package/dist/browser/AbstractNode.d.mts.map +1 -1
- package/dist/browser/AbstractNode.d.ts +2 -3
- package/dist/browser/AbstractNode.d.ts.map +1 -1
- package/dist/browser/index.cjs +37 -19
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +37 -19
- package/dist/browser/index.js.map +1 -1
- package/dist/node/AbstractNode.d.cts +2 -3
- package/dist/node/AbstractNode.d.cts.map +1 -1
- package/dist/node/AbstractNode.d.mts +2 -3
- package/dist/node/AbstractNode.d.mts.map +1 -1
- package/dist/node/AbstractNode.d.ts +2 -3
- package/dist/node/AbstractNode.d.ts.map +1 -1
- package/dist/node/index.cjs +37 -19
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +37 -19
- package/dist/node/index.js.map +1 -1
- package/package.json +10 -11
- package/src/AbstractNode.ts +26 -19
package/src/AbstractNode.ts
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
ModuleInstance,
|
|
17
17
|
ModuleQueryHandlerResult,
|
|
18
18
|
} from '@xyo-network/module-model'
|
|
19
|
-
import { CompositeModuleResolver } from '@xyo-network/module-resolver'
|
|
20
19
|
import {
|
|
21
20
|
NodeAttachedQuerySchema,
|
|
22
21
|
NodeAttachQuerySchema,
|
|
@@ -37,8 +36,6 @@ export abstract class AbstractNode<TParams extends NodeParams = NodeParams, TEve
|
|
|
37
36
|
{
|
|
38
37
|
static override readonly configSchemas: string[] = [NodeConfigSchema]
|
|
39
38
|
|
|
40
|
-
protected readonly privateResolver = new CompositeModuleResolver()
|
|
41
|
-
|
|
42
39
|
private readonly isNode = true
|
|
43
40
|
|
|
44
41
|
override get queries(): string[] {
|
|
@@ -59,11 +56,10 @@ export abstract class AbstractNode<TParams extends NodeParams = NodeParams, TEve
|
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
async attached(): Promise<Address[]> {
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return (await (this.downResolver.resolve('*', { maxDepth }) ?? [])).filter((module) => module.address !== this.address)
|
|
59
|
+
return [
|
|
60
|
+
...(await this.attachedPublicModules()).map((module) => module.address),
|
|
61
|
+
...(await this.attachedPrivateModules()).map((module) => module.address),
|
|
62
|
+
]
|
|
67
63
|
}
|
|
68
64
|
|
|
69
65
|
override async manifest(maxDepth = 5, ignoreAddresses: Address[] = []): Promise<ModuleManifestPayload> {
|
|
@@ -81,50 +77,60 @@ export abstract class AbstractNode<TParams extends NodeParams = NodeParams, TEve
|
|
|
81
77
|
idOrFilter: ModuleFilter | ModuleIdentifier = '*',
|
|
82
78
|
options?: ModuleFilterOptions,
|
|
83
79
|
): Promise<ModuleInstance | ModuleInstance[] | undefined> {
|
|
80
|
+
const { visibility = 'all' } = options ?? {}
|
|
81
|
+
const mutatedOptions = { ...options, visibility }
|
|
84
82
|
//checking type of nameOrAddressOrFilter before calling other functions since TS seems
|
|
85
83
|
//to need help here narrowing before the call
|
|
86
84
|
if (idOrFilter === '*') {
|
|
87
85
|
switch (options?.visibility) {
|
|
88
86
|
case 'private': {
|
|
89
|
-
return await this.resolvePrivate('*',
|
|
87
|
+
return (await this.resolvePrivate('*', mutatedOptions)).filter((mod) => mod.address !== this.address)
|
|
90
88
|
}
|
|
91
89
|
case 'all': {
|
|
92
|
-
return await this.resolveAll('*',
|
|
90
|
+
return (await this.resolveAll('*', mutatedOptions)).filter((mod) => mod.address !== this.address)
|
|
93
91
|
}
|
|
94
92
|
default: {
|
|
95
|
-
return await super.resolve('*',
|
|
93
|
+
return (await super.resolve('*', mutatedOptions)).filter((mod) => mod.address !== this.address)
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
97
|
if (typeof idOrFilter === 'string') {
|
|
100
98
|
switch (options?.visibility) {
|
|
101
99
|
case 'private': {
|
|
102
|
-
return await this.resolvePrivate(idOrFilter,
|
|
100
|
+
return await this.resolvePrivate(idOrFilter, mutatedOptions)
|
|
103
101
|
}
|
|
104
102
|
case 'all': {
|
|
105
|
-
return await this.resolveAll(idOrFilter,
|
|
103
|
+
return await this.resolveAll(idOrFilter, mutatedOptions)
|
|
106
104
|
}
|
|
107
105
|
default: {
|
|
108
|
-
return await super.resolve(idOrFilter,
|
|
106
|
+
return await super.resolve(idOrFilter, mutatedOptions)
|
|
109
107
|
}
|
|
110
108
|
}
|
|
111
109
|
} else {
|
|
112
110
|
switch (options?.visibility) {
|
|
113
111
|
case 'all': {
|
|
114
|
-
return await this.resolveAll(idOrFilter,
|
|
112
|
+
return await this.resolveAll(idOrFilter, mutatedOptions)
|
|
115
113
|
}
|
|
116
114
|
case 'private': {
|
|
117
|
-
return await this.resolvePrivate(idOrFilter,
|
|
115
|
+
return await this.resolvePrivate(idOrFilter, mutatedOptions)
|
|
118
116
|
}
|
|
119
117
|
default: {
|
|
120
|
-
return await super.resolve(idOrFilter,
|
|
118
|
+
return await super.resolve(idOrFilter, mutatedOptions)
|
|
121
119
|
}
|
|
122
120
|
}
|
|
123
121
|
}
|
|
124
122
|
}
|
|
125
123
|
|
|
124
|
+
protected async attachedPrivateModules(maxDepth = 1): Promise<ModuleInstance[]> {
|
|
125
|
+
return (await (this.privateResolver.resolve('*', { maxDepth, visibility: 'public' }) ?? [])).filter((module) => module.address !== this.address)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
protected async attachedPublicModules(maxDepth = 1): Promise<ModuleInstance[]> {
|
|
129
|
+
return (await (this.downResolver.resolve('*', { maxDepth, visibility: 'public' }) ?? [])).filter((module) => module.address !== this.address)
|
|
130
|
+
}
|
|
131
|
+
|
|
126
132
|
protected override async discoverHandler(maxDepth = 5): Promise<Payload[]> {
|
|
127
|
-
const childMods = await this.
|
|
133
|
+
const childMods = await this.attachedPublicModules(maxDepth)
|
|
128
134
|
//console.log(`childMods: ${toJsonString(childMods)}`)
|
|
129
135
|
const childModAddresses = await Promise.all(
|
|
130
136
|
childMods.map((mod) =>
|
|
@@ -148,7 +154,8 @@ export abstract class AbstractNode<TParams extends NodeParams = NodeParams, TEve
|
|
|
148
154
|
manifest.modules.private = privateModules
|
|
149
155
|
}*/
|
|
150
156
|
|
|
151
|
-
const
|
|
157
|
+
const publicChildren = await this.resolve('*', { direction: 'down', maxDepth: 1, visibility: 'public' })
|
|
158
|
+
const publicModules = await Promise.all(publicChildren.filter(notThisModule).map(toManifest))
|
|
152
159
|
if (publicModules.length > 0) {
|
|
153
160
|
manifest.modules = manifest.modules ?? {}
|
|
154
161
|
manifest.modules.public = publicModules
|