@xyo-network/manifest 2.84.7 → 2.84.8
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/index.cjs +1 -123
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +1 -2
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +1 -2
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +1 -2
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +1 -121
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +3 -129
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +1 -2
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +1 -2
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +1 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +1 -124
- package/dist/node/index.js.map +1 -1
- package/package.json +3 -13
- package/src/index.ts +1 -2
- package/dist/browser/ManifestWrapper.d.cts +0 -36
- package/dist/browser/ManifestWrapper.d.cts.map +0 -1
- package/dist/browser/ManifestWrapper.d.mts +0 -36
- package/dist/browser/ManifestWrapper.d.mts.map +0 -1
- package/dist/browser/ManifestWrapper.d.ts +0 -36
- package/dist/browser/ManifestWrapper.d.ts.map +0 -1
- package/dist/browser/standardCreatableModules.d.cts +0 -3
- package/dist/browser/standardCreatableModules.d.cts.map +0 -1
- package/dist/browser/standardCreatableModules.d.mts +0 -3
- package/dist/browser/standardCreatableModules.d.mts.map +0 -1
- package/dist/browser/standardCreatableModules.d.ts +0 -3
- package/dist/browser/standardCreatableModules.d.ts.map +0 -1
- package/dist/node/ManifestWrapper.d.cts +0 -36
- package/dist/node/ManifestWrapper.d.cts.map +0 -1
- package/dist/node/ManifestWrapper.d.mts +0 -36
- package/dist/node/ManifestWrapper.d.mts.map +0 -1
- package/dist/node/ManifestWrapper.d.ts +0 -36
- package/dist/node/ManifestWrapper.d.ts.map +0 -1
- package/dist/node/standardCreatableModules.d.cts +0 -3
- package/dist/node/standardCreatableModules.d.cts.map +0 -1
- package/dist/node/standardCreatableModules.d.mts +0 -3
- package/dist/node/standardCreatableModules.d.mts.map +0 -1
- package/dist/node/standardCreatableModules.d.ts +0 -3
- package/dist/node/standardCreatableModules.d.ts.map +0 -1
- package/src/ManifestWrapper.ts +0 -171
- package/src/spec/simple-node-child.json +0 -49
- package/src/spec/simple-node-inline-lazy-manifest.json +0 -54
- package/src/spec/simple-node-inline-manifest.json +0 -49
- package/src/spec/simple-node-parent.json +0 -49
- package/src/standardCreatableModules.ts +0 -12
package/src/ManifestWrapper.ts
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import { Account } from '@xyo-network/account'
|
|
3
|
-
import { ModuleManifest, NodeManifest, PackageManifestPayload } from '@xyo-network/manifest-model'
|
|
4
|
-
import {
|
|
5
|
-
assignCreatableModuleRegistry,
|
|
6
|
-
CreatableModuleDictionary,
|
|
7
|
-
CreatableModuleRegistry,
|
|
8
|
-
ModuleFactoryLocator,
|
|
9
|
-
ModuleInstance,
|
|
10
|
-
toCreatableModuleRegistry,
|
|
11
|
-
} from '@xyo-network/module-model'
|
|
12
|
-
import { MemoryNode } from '@xyo-network/node-memory'
|
|
13
|
-
import { NodeInstance } from '@xyo-network/node-model'
|
|
14
|
-
import { PayloadWrapper } from '@xyo-network/payload-wrapper'
|
|
15
|
-
import { WalletInstance } from '@xyo-network/wallet-model'
|
|
16
|
-
|
|
17
|
-
import { standardCreatableModules } from './standardCreatableModules'
|
|
18
|
-
|
|
19
|
-
/** Provides functionality that can be performed on a PackageManifest */
|
|
20
|
-
export class ManifestWrapper extends PayloadWrapper<PackageManifestPayload> {
|
|
21
|
-
constructor(
|
|
22
|
-
payload: PackageManifestPayload,
|
|
23
|
-
protected readonly wallet: WalletInstance,
|
|
24
|
-
protected readonly locator: ModuleFactoryLocator = new ModuleFactoryLocator({}),
|
|
25
|
-
protected readonly publicChildren: PackageManifestPayload[] = [],
|
|
26
|
-
protected readonly privateChildren: PackageManifestPayload[] = [],
|
|
27
|
-
) {
|
|
28
|
-
super(payload)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async loadModule(node: MemoryNode, manifest: ModuleManifest, external: boolean, additionalCreatableModules?: CreatableModuleRegistry): Promise<void>
|
|
32
|
-
async loadModule(
|
|
33
|
-
node: MemoryNode,
|
|
34
|
-
manifest: ModuleManifest,
|
|
35
|
-
external: boolean,
|
|
36
|
-
additionalCreatableModules?: CreatableModuleDictionary,
|
|
37
|
-
): Promise<void>
|
|
38
|
-
async loadModule(
|
|
39
|
-
node: MemoryNode,
|
|
40
|
-
manifest: ModuleManifest,
|
|
41
|
-
external = true,
|
|
42
|
-
additionalCreatableModules?: CreatableModuleDictionary | CreatableModuleRegistry,
|
|
43
|
-
): Promise<void> {
|
|
44
|
-
const collision = async (node: NodeInstance, name: string, external: boolean) => {
|
|
45
|
-
const externalConflict = external ? (await node.resolve({ name: [name] }, { direction: external ? 'all' : 'down' })).length > 0 : false
|
|
46
|
-
return externalConflict || (await node.resolve({ name: [name] }, { direction: 'down' })).length > 0
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const creatableModules = assignCreatableModuleRegistry(
|
|
50
|
-
{},
|
|
51
|
-
toCreatableModuleRegistry(standardCreatableModules),
|
|
52
|
-
toCreatableModuleRegistry(additionalCreatableModules ?? {}),
|
|
53
|
-
)
|
|
54
|
-
if (!(await collision(node, manifest.config.name, external)) && manifest.config.language && manifest.config.language === 'javascript') {
|
|
55
|
-
assertEx(
|
|
56
|
-
(manifest.config.name && (await node.attach(manifest.config.name, external))) ??
|
|
57
|
-
(await node.attach((await this.registerModule(node, manifest, creatableModules)).address, external)),
|
|
58
|
-
`No module with config schema [${manifest.config.name}] registered`,
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async loadNodeFromIndex(index: number, additionalCreatableModules?: CreatableModuleRegistry): Promise<MemoryNode>
|
|
64
|
-
async loadNodeFromIndex(index: number, additionalCreatableModules?: CreatableModuleDictionary): Promise<MemoryNode>
|
|
65
|
-
async loadNodeFromIndex(index: number, additionalCreatableModules?: CreatableModuleDictionary | CreatableModuleRegistry): Promise<MemoryNode> {
|
|
66
|
-
const manifest = assertEx(this.nodeManifest(index), 'Failed to find Node Manifest')
|
|
67
|
-
const registry = toCreatableModuleRegistry(additionalCreatableModules ?? {})
|
|
68
|
-
return await this.loadNodeFromManifest(manifest, manifest.config.accountPath ?? `${index}'`, registry)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async loadNodeFromManifest(manifest: NodeManifest, path: string, additionalCreatableModules?: CreatableModuleRegistry): Promise<MemoryNode>
|
|
72
|
-
async loadNodeFromManifest(manifest: NodeManifest, path: string, additionalCreatableModules?: CreatableModuleDictionary): Promise<MemoryNode>
|
|
73
|
-
async loadNodeFromManifest(
|
|
74
|
-
manifest: NodeManifest,
|
|
75
|
-
path?: string,
|
|
76
|
-
additionalCreatableModules?: CreatableModuleDictionary | CreatableModuleRegistry,
|
|
77
|
-
): Promise<MemoryNode> {
|
|
78
|
-
const wallet = path ? await this.wallet.derivePath(path) : undefined
|
|
79
|
-
const account = path ? undefined : Account.randomSync()
|
|
80
|
-
const node = await MemoryNode.create({ account, config: manifest.config, wallet })
|
|
81
|
-
const registry = toCreatableModuleRegistry(additionalCreatableModules ?? {})
|
|
82
|
-
// Load Private Modules
|
|
83
|
-
const privateModules =
|
|
84
|
-
manifest.modules?.private?.map(async (moduleManifest) => {
|
|
85
|
-
await this.loadModule(node, moduleManifest, false, registry)
|
|
86
|
-
}) ?? []
|
|
87
|
-
// Load Public Modules
|
|
88
|
-
const publicModules =
|
|
89
|
-
manifest.modules?.public?.map(async (moduleManifest) => {
|
|
90
|
-
await this.loadModule(node, moduleManifest, true, registry)
|
|
91
|
-
}) ?? []
|
|
92
|
-
await Promise.all([...privateModules, ...publicModules])
|
|
93
|
-
|
|
94
|
-
await Promise.all(
|
|
95
|
-
this.privateChildren.map(async (child) => {
|
|
96
|
-
const wrapper = new ManifestWrapper(child, this.wallet, this.locator)
|
|
97
|
-
const subNodes = await wrapper.loadNodes(node)
|
|
98
|
-
for (const subNode of subNodes) {
|
|
99
|
-
node.attach(subNode.address, false)
|
|
100
|
-
}
|
|
101
|
-
}),
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
await Promise.all(
|
|
105
|
-
this.publicChildren.map(async (child) => {
|
|
106
|
-
const wrapper = new ManifestWrapper(child, this.wallet, this.locator)
|
|
107
|
-
const subNodes = await wrapper.loadNodes(node)
|
|
108
|
-
for (const subNode of subNodes) {
|
|
109
|
-
node.attach(subNode.address, true)
|
|
110
|
-
}
|
|
111
|
-
}),
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
return node
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Load the nodes that are defined in the wrapped manifest and optionally attach them to a node
|
|
119
|
-
*/
|
|
120
|
-
async loadNodes(
|
|
121
|
-
/** Node to optionally attach the loaded nodes to */
|
|
122
|
-
node?: MemoryNode,
|
|
123
|
-
/** Additional creatable modules */
|
|
124
|
-
additionalCreatableModules?: CreatableModuleRegistry,
|
|
125
|
-
): Promise<MemoryNode[]>
|
|
126
|
-
async loadNodes(
|
|
127
|
-
/** Node to optionally attach the loaded nodes to */
|
|
128
|
-
node?: MemoryNode,
|
|
129
|
-
/** Additional creatable modules */
|
|
130
|
-
additionalCreatableModules?: CreatableModuleDictionary,
|
|
131
|
-
): Promise<MemoryNode[]>
|
|
132
|
-
async loadNodes(node?: MemoryNode, additionalCreatableModules?: CreatableModuleDictionary | CreatableModuleRegistry): Promise<MemoryNode[]> {
|
|
133
|
-
const registry = toCreatableModuleRegistry(additionalCreatableModules ?? {})
|
|
134
|
-
const result = await Promise.all(
|
|
135
|
-
this.jsonPayload().nodes?.map(async (nodeManifest, index) => {
|
|
136
|
-
const subNode = await this.loadNodeFromManifest(nodeManifest, nodeManifest.config.accountPath ?? `${index}'`, registry)
|
|
137
|
-
await node?.register(subNode)
|
|
138
|
-
return subNode
|
|
139
|
-
}),
|
|
140
|
-
)
|
|
141
|
-
return result
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
nodeManifest(index: number) {
|
|
145
|
-
return this.jsonPayload().nodes?.[index]
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/** Register a module on a node based on a manifest */
|
|
149
|
-
private async registerModule(node: MemoryNode, manifest: ModuleManifest, creatableModules?: CreatableModuleRegistry): Promise<ModuleInstance>
|
|
150
|
-
private async registerModule(node: MemoryNode, manifest: ModuleManifest, creatableModules?: CreatableModuleDictionary): Promise<ModuleInstance>
|
|
151
|
-
private async registerModule(
|
|
152
|
-
node: MemoryNode,
|
|
153
|
-
manifest: ModuleManifest,
|
|
154
|
-
creatableModules?: CreatableModuleDictionary | CreatableModuleRegistry,
|
|
155
|
-
): Promise<ModuleInstance> {
|
|
156
|
-
const registry = toCreatableModuleRegistry(creatableModules ?? {})
|
|
157
|
-
const creatableModule = new ModuleFactoryLocator(this.locator.registry)
|
|
158
|
-
.registerMany(registry)
|
|
159
|
-
.locate(manifest.config.schema, manifest.config.labels)
|
|
160
|
-
const path = manifest.config.accountPath
|
|
161
|
-
const wallet = path ? await this.wallet.derivePath(path) : undefined
|
|
162
|
-
const account = path ? undefined : Account.randomSync()
|
|
163
|
-
const module = await creatableModule.create({
|
|
164
|
-
account,
|
|
165
|
-
config: assertEx(manifest.config, 'Missing config'),
|
|
166
|
-
wallet,
|
|
167
|
-
})
|
|
168
|
-
await node.register(module)
|
|
169
|
-
return module
|
|
170
|
-
}
|
|
171
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "../schema.json",
|
|
3
|
-
"nodes": [
|
|
4
|
-
{
|
|
5
|
-
"config": {
|
|
6
|
-
"accountPath": "1'",
|
|
7
|
-
"name": "SimpleMemoryDapp",
|
|
8
|
-
"schema": "network.xyo.node.config"
|
|
9
|
-
},
|
|
10
|
-
"modules": {
|
|
11
|
-
"private": [
|
|
12
|
-
{
|
|
13
|
-
"config": {
|
|
14
|
-
"language": "javascript",
|
|
15
|
-
"name": "ScratchArchivistChild",
|
|
16
|
-
"schema": "network.xyo.archivist.config"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"public": [
|
|
21
|
-
{
|
|
22
|
-
"config": {
|
|
23
|
-
"language": "javascript",
|
|
24
|
-
"name": "SimpleArchivistChild",
|
|
25
|
-
"schema": "network.xyo.archivist.config"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"config": {
|
|
30
|
-
"language": "javascript",
|
|
31
|
-
"name": "SimpleSentinelChild",
|
|
32
|
-
"schema": "network.xyo.sentinel.config",
|
|
33
|
-
"synchronous": true
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"config": {
|
|
38
|
-
"language": "javascript",
|
|
39
|
-
"name": "SimpleHttpBridgeChild",
|
|
40
|
-
"nodeUrl": "https://beta.api.archivist.xyo.network",
|
|
41
|
-
"schema": "network.xyo.bridge.http.config"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
"schema": "network.xyo.manifest"
|
|
49
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "../schema.json",
|
|
3
|
-
"nodes": [
|
|
4
|
-
{
|
|
5
|
-
"config": {
|
|
6
|
-
"accountPath": "0'",
|
|
7
|
-
"name": "SimpleMemoryDapp",
|
|
8
|
-
"schema": "network.xyo.node.config"
|
|
9
|
-
},
|
|
10
|
-
"modules": {
|
|
11
|
-
"private": [
|
|
12
|
-
{
|
|
13
|
-
"config": {
|
|
14
|
-
"accountPath": "1'",
|
|
15
|
-
"language": "javascript",
|
|
16
|
-
"name": "ScratchArchivist",
|
|
17
|
-
"schema": "network.xyo.archivist.config"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"public": [
|
|
22
|
-
{
|
|
23
|
-
"config": {
|
|
24
|
-
"accountPath": "2'",
|
|
25
|
-
"language": "javascript",
|
|
26
|
-
"name": "SimpleArchivist",
|
|
27
|
-
"schema": "network.xyo.archivist.config"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"config": {
|
|
32
|
-
"accountPath": "3'",
|
|
33
|
-
"language": "javascript",
|
|
34
|
-
"name": "SimpleSentinel",
|
|
35
|
-
"schema": "network.xyo.sentinel.config",
|
|
36
|
-
"synchronous": true
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"config": {
|
|
41
|
-
"accountPath": "4'",
|
|
42
|
-
"language": "javascript",
|
|
43
|
-
"lazyStart": true,
|
|
44
|
-
"name": "SimpleHttpBridge",
|
|
45
|
-
"nodeUrl": "https://beta.api.archivist.xyo.network",
|
|
46
|
-
"schema": "network.xyo.bridge.http.config"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
|
-
"schema": "network.xyo.manifest"
|
|
54
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "../schema.json",
|
|
3
|
-
"nodes": [
|
|
4
|
-
{
|
|
5
|
-
"config": {
|
|
6
|
-
"accountPath": "0'",
|
|
7
|
-
"name": "SimpleMemoryDapp",
|
|
8
|
-
"schema": "network.xyo.node.config"
|
|
9
|
-
},
|
|
10
|
-
"modules": {
|
|
11
|
-
"private": [
|
|
12
|
-
{
|
|
13
|
-
"config": {
|
|
14
|
-
"language": "javascript",
|
|
15
|
-
"name": "ScratchArchivist",
|
|
16
|
-
"schema": "network.xyo.archivist.config"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"public": [
|
|
21
|
-
{
|
|
22
|
-
"config": {
|
|
23
|
-
"language": "javascript",
|
|
24
|
-
"name": "SimpleArchivist",
|
|
25
|
-
"schema": "network.xyo.archivist.config"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"config": {
|
|
30
|
-
"language": "javascript",
|
|
31
|
-
"name": "SimpleSentinel",
|
|
32
|
-
"schema": "network.xyo.sentinel.config",
|
|
33
|
-
"synchronous": true
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"config": {
|
|
38
|
-
"language": "javascript",
|
|
39
|
-
"name": "SimpleHttpBridge",
|
|
40
|
-
"nodeUrl": "https://beta.api.archivist.xyo.network",
|
|
41
|
-
"schema": "network.xyo.bridge.http.config"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
"schema": "network.xyo.manifest"
|
|
49
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "../schema.json",
|
|
3
|
-
"nodes": [
|
|
4
|
-
{
|
|
5
|
-
"config": {
|
|
6
|
-
"accountPath": "0'",
|
|
7
|
-
"name": "SimpleMemoryDapp",
|
|
8
|
-
"schema": "network.xyo.node.config"
|
|
9
|
-
},
|
|
10
|
-
"modules": {
|
|
11
|
-
"private": [
|
|
12
|
-
{
|
|
13
|
-
"config": {
|
|
14
|
-
"language": "javascript",
|
|
15
|
-
"name": "ScratchArchivistChild",
|
|
16
|
-
"schema": "network.xyo.archivist.config"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"public": [
|
|
21
|
-
{
|
|
22
|
-
"config": {
|
|
23
|
-
"language": "javascript",
|
|
24
|
-
"name": "SimpleArchivistChild",
|
|
25
|
-
"schema": "network.xyo.archivist.config"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"config": {
|
|
30
|
-
"language": "javascript",
|
|
31
|
-
"name": "SimpleSentinelChild",
|
|
32
|
-
"schema": "network.xyo.sentinel.config",
|
|
33
|
-
"synchronous": true
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"config": {
|
|
38
|
-
"language": "javascript",
|
|
39
|
-
"name": "SimpleHttpBridgeChild",
|
|
40
|
-
"nodeUrl": "https://beta.api.archivist.xyo.network",
|
|
41
|
-
"schema": "network.xyo.bridge.http.config"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
"schema": "network.xyo.manifest"
|
|
49
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { HttpBridge } from '@xyo-network/http-bridge'
|
|
2
|
-
import { MemoryArchivist } from '@xyo-network/memory-archivist'
|
|
3
|
-
import { CreatableModuleDictionary, ModuleFactory } from '@xyo-network/module-model'
|
|
4
|
-
import { MemoryNode } from '@xyo-network/node-memory'
|
|
5
|
-
import { MemorySentinel } from '@xyo-network/sentinel'
|
|
6
|
-
|
|
7
|
-
export const standardCreatableModules: CreatableModuleDictionary = {
|
|
8
|
-
'network.xyo.archivist.config': MemoryArchivist,
|
|
9
|
-
'network.xyo.bridge.http.config': ModuleFactory.withParams(HttpBridge, { config: { schema: HttpBridge.configSchema } }),
|
|
10
|
-
'network.xyo.node.config': MemoryNode,
|
|
11
|
-
'network.xyo.sentinel.config': MemorySentinel,
|
|
12
|
-
}
|