@xyo-network/module-abstract 2.93.8 → 2.94.0
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/AbstractModule.d.cts +2 -2
- package/dist/browser/AbstractModule.d.cts.map +1 -1
- package/dist/browser/AbstractModule.d.mts +2 -2
- package/dist/browser/AbstractModule.d.mts.map +1 -1
- package/dist/browser/AbstractModule.d.ts +2 -2
- package/dist/browser/AbstractModule.d.ts.map +1 -1
- package/dist/browser/AbstractModuleInstance.d.cts +1 -3
- package/dist/browser/AbstractModuleInstance.d.cts.map +1 -1
- package/dist/browser/AbstractModuleInstance.d.mts +1 -3
- package/dist/browser/AbstractModuleInstance.d.mts.map +1 -1
- package/dist/browser/AbstractModuleInstance.d.ts +1 -3
- package/dist/browser/AbstractModuleInstance.d.ts.map +1 -1
- package/dist/browser/index.cjs +19 -46
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +20 -47
- package/dist/browser/index.js.map +1 -1
- package/dist/node/AbstractModule.d.cts +2 -2
- package/dist/node/AbstractModule.d.cts.map +1 -1
- package/dist/node/AbstractModule.d.mts +2 -2
- package/dist/node/AbstractModule.d.mts.map +1 -1
- package/dist/node/AbstractModule.d.ts +2 -2
- package/dist/node/AbstractModule.d.ts.map +1 -1
- package/dist/node/AbstractModuleInstance.d.cts +1 -3
- package/dist/node/AbstractModuleInstance.d.cts.map +1 -1
- package/dist/node/AbstractModuleInstance.d.mts +1 -3
- package/dist/node/AbstractModuleInstance.d.mts.map +1 -1
- package/dist/node/AbstractModuleInstance.d.ts +1 -3
- package/dist/node/AbstractModuleInstance.d.ts.map +1 -1
- package/dist/node/index.cjs +20 -47
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +21 -48
- package/dist/node/index.js.map +1 -1
- package/package.json +17 -17
- package/src/AbstractModule.ts +21 -43
- package/src/AbstractModuleInstance.ts +0 -15
package/src/AbstractModule.ts
CHANGED
|
@@ -30,10 +30,8 @@ import {
|
|
|
30
30
|
ModuleAddressQuerySchema,
|
|
31
31
|
ModuleBusyEventArgs,
|
|
32
32
|
ModuleConfig,
|
|
33
|
-
ModuleDescribeQuerySchema,
|
|
34
33
|
ModuleDescriptionPayload,
|
|
35
34
|
ModuleDescriptionSchema,
|
|
36
|
-
ModuleDiscoverQuerySchema,
|
|
37
35
|
ModuleEventData,
|
|
38
36
|
ModuleFactory,
|
|
39
37
|
ModuleManifestQuerySchema,
|
|
@@ -73,8 +71,6 @@ export abstract class AbstractModule<TParams extends ModuleParams = ModuleParams
|
|
|
73
71
|
protected _account: AccountInstance | undefined = undefined
|
|
74
72
|
protected readonly _baseModuleQueryAccountPaths: Record<ModuleQueries['schema'], string> = {
|
|
75
73
|
[ModuleAddressQuerySchema]: '1',
|
|
76
|
-
[ModuleDescribeQuerySchema]: '4',
|
|
77
|
-
[ModuleDiscoverQuerySchema]: '2',
|
|
78
74
|
[ModuleManifestQuerySchema]: '5',
|
|
79
75
|
[ModuleStateQuerySchema]: '6',
|
|
80
76
|
[ModuleSubscribeQuerySchema]: '3',
|
|
@@ -82,8 +78,6 @@ export abstract class AbstractModule<TParams extends ModuleParams = ModuleParams
|
|
|
82
78
|
protected _lastError?: Error
|
|
83
79
|
protected readonly _queryAccounts: Record<ModuleQueries['schema'], AccountInstance | undefined> = {
|
|
84
80
|
[ModuleAddressQuerySchema]: undefined,
|
|
85
|
-
[ModuleDescribeQuerySchema]: undefined,
|
|
86
|
-
[ModuleDiscoverQuerySchema]: undefined,
|
|
87
81
|
[ModuleManifestQuerySchema]: undefined,
|
|
88
82
|
[ModuleStateQuerySchema]: undefined,
|
|
89
83
|
[ModuleSubscribeQuerySchema]: undefined,
|
|
@@ -153,14 +147,7 @@ export abstract class AbstractModule<TParams extends ModuleParams = ModuleParams
|
|
|
153
147
|
}
|
|
154
148
|
|
|
155
149
|
get queries(): string[] {
|
|
156
|
-
return [
|
|
157
|
-
ModuleDiscoverQuerySchema,
|
|
158
|
-
ModuleAddressQuerySchema,
|
|
159
|
-
ModuleSubscribeQuerySchema,
|
|
160
|
-
ModuleDescribeQuerySchema,
|
|
161
|
-
ModuleManifestQuerySchema,
|
|
162
|
-
ModuleStateQuerySchema,
|
|
163
|
-
]
|
|
150
|
+
return [ModuleAddressQuerySchema, ModuleSubscribeQuerySchema, ModuleManifestQuerySchema, ModuleStateQuerySchema]
|
|
164
151
|
}
|
|
165
152
|
|
|
166
153
|
get queryAccountPaths(): Readonly<Record<Query['schema'], string | undefined>> {
|
|
@@ -510,7 +497,24 @@ export abstract class AbstractModule<TParams extends ModuleParams = ModuleParams
|
|
|
510
497
|
return result
|
|
511
498
|
}
|
|
512
499
|
|
|
513
|
-
protected async
|
|
500
|
+
protected async generateConfigAndAddress(_maxDepth?: number): Promise<Payload[]> {
|
|
501
|
+
const config = await PayloadBuilder.build(this.config)
|
|
502
|
+
const address = await new PayloadBuilder<AddressPayload>({ schema: AddressSchema })
|
|
503
|
+
.fields({ address: this.address, name: this.config?.name })
|
|
504
|
+
.build()
|
|
505
|
+
const queries = await Promise.all(
|
|
506
|
+
this.queries.map(async (query) => {
|
|
507
|
+
return await new PayloadBuilder<QueryPayload>({ schema: QuerySchema }).fields({ query }).build()
|
|
508
|
+
}),
|
|
509
|
+
)
|
|
510
|
+
const configSchema = await PayloadBuilder.build<ConfigPayload>({
|
|
511
|
+
config: config.schema,
|
|
512
|
+
schema: ConfigSchema,
|
|
513
|
+
})
|
|
514
|
+
return compact([config, configSchema, address, ...queries])
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
protected async generateDescribe(): Promise<ModuleDescriptionPayload> {
|
|
514
518
|
const description: ModuleDescriptionPayload = {
|
|
515
519
|
address: this.address,
|
|
516
520
|
queries: this.queries,
|
|
@@ -520,7 +524,7 @@ export abstract class AbstractModule<TParams extends ModuleParams = ModuleParams
|
|
|
520
524
|
description.name = this.config.name
|
|
521
525
|
}
|
|
522
526
|
|
|
523
|
-
const discover = await this.
|
|
527
|
+
const discover = await this.generateConfigAndAddress()
|
|
524
528
|
|
|
525
529
|
description.children = compact(
|
|
526
530
|
discover?.map((payload) => {
|
|
@@ -532,23 +536,6 @@ export abstract class AbstractModule<TParams extends ModuleParams = ModuleParams
|
|
|
532
536
|
return description
|
|
533
537
|
}
|
|
534
538
|
|
|
535
|
-
protected async discoverHandler(_maxDepth?: number): Promise<Payload[]> {
|
|
536
|
-
const config = await PayloadBuilder.build(this.config)
|
|
537
|
-
const address = await new PayloadBuilder<AddressPayload>({ schema: AddressSchema })
|
|
538
|
-
.fields({ address: this.address, name: this.config?.name })
|
|
539
|
-
.build()
|
|
540
|
-
const queries = await Promise.all(
|
|
541
|
-
this.queries.map(async (query) => {
|
|
542
|
-
return await new PayloadBuilder<QueryPayload>({ schema: QuerySchema }).fields({ query }).build()
|
|
543
|
-
}),
|
|
544
|
-
)
|
|
545
|
-
const configSchema = await PayloadBuilder.build<ConfigPayload>({
|
|
546
|
-
config: config.schema,
|
|
547
|
-
schema: ConfigSchema,
|
|
548
|
-
})
|
|
549
|
-
return compact([config, configSchema, address, ...queries])
|
|
550
|
-
}
|
|
551
|
-
|
|
552
539
|
protected async getArchivist(): Promise<ArchivistInstance | undefined> {
|
|
553
540
|
if (!this.config.archivist) return undefined
|
|
554
541
|
const resolved = await this.upResolver.resolve(this.config.archivist)
|
|
@@ -629,15 +616,6 @@ export abstract class AbstractModule<TParams extends ModuleParams = ModuleParams
|
|
|
629
616
|
resultPayloads.push(await this.manifestHandler(queryPayload.maxDepth))
|
|
630
617
|
break
|
|
631
618
|
}
|
|
632
|
-
case ModuleDiscoverQuerySchema: {
|
|
633
|
-
const { maxDepth } = queryPayload
|
|
634
|
-
resultPayloads.push(...(await this.discoverHandler(maxDepth)))
|
|
635
|
-
break
|
|
636
|
-
}
|
|
637
|
-
case ModuleDescribeQuerySchema: {
|
|
638
|
-
resultPayloads.push(await this.describeHandler())
|
|
639
|
-
break
|
|
640
|
-
}
|
|
641
619
|
case ModuleAddressQuerySchema: {
|
|
642
620
|
resultPayloads.push(...(await this.moduleAddressHandler()))
|
|
643
621
|
break
|
|
@@ -665,7 +643,7 @@ export abstract class AbstractModule<TParams extends ModuleParams = ModuleParams
|
|
|
665
643
|
}
|
|
666
644
|
|
|
667
645
|
protected async stateHandler(): Promise<Payload[]> {
|
|
668
|
-
return [await this.manifestHandler(), ...(await this.
|
|
646
|
+
return [await this.manifestHandler(), ...(await this.generateConfigAndAddress()), await this.generateDescribe()]
|
|
669
647
|
}
|
|
670
648
|
|
|
671
649
|
protected stopHandler(_timeout?: number): Promisable<boolean> {
|
|
@@ -6,7 +6,6 @@ import { ArchivistInstance, asArchivistInstance } from '@xyo-network/archivist-m
|
|
|
6
6
|
import { ModuleManifestPayload } from '@xyo-network/manifest-model'
|
|
7
7
|
import {
|
|
8
8
|
AddressPreviousHashPayload,
|
|
9
|
-
ModuleDescriptionPayload,
|
|
10
9
|
ModuleEventData,
|
|
11
10
|
ModuleFilter,
|
|
12
11
|
ModuleFilterOptions,
|
|
@@ -37,20 +36,6 @@ export abstract class AbstractModuleInstance<TParams extends ModuleParams = Modu
|
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
describe(): Promise<ModuleDescriptionPayload> {
|
|
41
|
-
this._checkDead()
|
|
42
|
-
return this.busy(async () => {
|
|
43
|
-
return await this.describeHandler()
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
discover(maxDepth = 5): Promise<Payload[]> {
|
|
48
|
-
this._checkDead()
|
|
49
|
-
return this.busy(async () => {
|
|
50
|
-
return await this.discoverHandler(maxDepth)
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
|
|
54
39
|
manifest(maxDepth?: number, ignoreAddresses?: Address[]): Promise<ModuleManifestPayload> {
|
|
55
40
|
this._checkDead()
|
|
56
41
|
return this.busy(async () => {
|