@xyo-network/os-runtime 3.0.1 → 3.0.2
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/neutral/index.d.ts +1 -1
- package/dist/neutral/index.mjs +263 -97
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/Caller.ts +5 -2
- package/src/DefaultsQueries.ts +6 -2
- package/src/XyOs.ts +19 -9
- package/src/XyOsBase.ts +10 -3
- package/src/XyOsDapp.ts +9 -3
- package/src/access-interfaces/ValidDappAccessInterfaces.ts +4 -4
- package/src/access-interfaces/registered-names/helpers/AccessNodeQueries.ts +6 -2
- package/src/access-interfaces/registered-names/helpers/resource/RegistrationsResource.ts +8 -8
- package/src/adapter/Base.ts +11 -3
- package/src/adapters/OsPubSubBridgeNetwork.ts +3 -1
- package/src/classes/cache/RunningDappCache.ts +9 -3
- package/src/classes/dapp/DefaultsResource.ts +9 -3
- package/src/classes/dapp/access/Caller.ts +5 -4
- package/src/classes/dapp/access/Queries.ts +6 -2
- package/src/classes/dapp/access/Resource.ts +9 -3
- package/src/classes/lib/DappCreatorParams.ts +3 -1
- package/src/classes/lib/Insertable.ts +5 -7
- package/src/classes/menu/Caller.ts +5 -2
- package/src/classes/menu/Queries.ts +5 -2
- package/src/classes/menu/Resource.ts +12 -4
- package/src/classes/node/Creator.ts +19 -7
- package/src/classes/node/DefaultPayloads/DappAccessPayloads.ts +3 -1
- package/src/classes/node/DefaultPayloads/DefaultPayloads.ts +3 -1
- package/src/classes/node/DefaultPayloads/NodeInfoPayload.ts +3 -1
- package/src/classes/node/DefaultPayloads/SigningKeyPayloads.ts +9 -10
- package/src/classes/node/ExternalModulePermissions/ExternalModulePermissions.ts +6 -2
- package/src/classes/node/createDappContext.ts +9 -3
- package/src/classes/registration/DappRegistrationService.ts +25 -7
- package/src/classes/registration/DappRegistry.ts +16 -8
- package/src/classes/registration/ValidateDappAccessDiviner/Config.ts +10 -3
- package/src/classes/registration/ValidateDappAccessDiviner/Diviner.ts +13 -5
- package/src/classes/settings/Caller.ts +3 -1
- package/src/classes/settings/Resource.ts +9 -3
- package/src/classes/settings/SettingsQueries.ts +6 -2
- package/src/classes/settings/badge/Resource.ts +5 -7
- package/src/classes/system/ManageSystemDapps.ts +7 -2
- package/src/classes/system/Queries.ts +2 -1
- package/src/event/bus/Connection.ts +3 -1
- package/src/event/bus/EventBus.ts +13 -4
- package/src/helpers/monitor/XyOsMonitor.ts +9 -7
- package/src/helpers/monitor/types.ts +4 -1
- package/src/intent/Caller.ts +6 -2
- package/src/intent/Resource.ts +6 -2
- package/src/lib/ModuleAccountPaths.ts +6 -10
- package/src/lib/PayloadStore.ts +9 -3
- package/src/lib/isPayload.ts +3 -1
- package/src/manifest/ManifestReplaceableTokens.ts +4 -3
- package/src/profileModuleEvents.ts +6 -2
- package/src/stack/Base.ts +18 -6
- package/src/stack/Manager.ts +8 -8
- package/src/stack/Map.ts +3 -1
- package/src/stack/OsPubSubNetworkStack.ts +12 -4
- package/src/stack/OsSettingsStack.ts +6 -2
- package/src/stack/XyoPublicNetworkStack.ts +6 -2
- package/src/utils/buildWalletSeedPhrasePayload.ts +22 -6
- package/src/wallet/DappSeedPhraseRepository.ts +6 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { HDWallet } from '@xyo-network/account'
|
|
2
2
|
import { GenericPayloadDiviner } from '@xyo-network/diviner-payload-generic'
|
|
3
3
|
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
RegisteredDapp, WindowDappNodeSet, XyOsContext,
|
|
6
|
+
} from '@xyo-network/os-model'
|
|
5
7
|
|
|
6
8
|
import { DappSeedPhraseRepository } from '../../wallet/index.ts'
|
|
7
9
|
import type { DappNodesCreatorParams } from '../lib/index.ts'
|
|
@@ -31,12 +33,16 @@ export const createDappContext = async (
|
|
|
31
33
|
}
|
|
32
34
|
const wallet = await HDWallet.fromPhrase(seedPhrase)
|
|
33
35
|
const dappName = dapp.config.name
|
|
34
|
-
const {
|
|
36
|
+
const {
|
|
37
|
+
config: dappConfig, params: dappParams,
|
|
38
|
+
} = dapp
|
|
35
39
|
|
|
36
40
|
const locator = resolveLocator((dappParams.locator ?? new ModuleFactoryLocator()).merge(context.platformLocator))
|
|
37
41
|
|
|
38
42
|
const params: DappNodesCreatorParams = {
|
|
39
|
-
config: {
|
|
43
|
+
config: {
|
|
44
|
+
dappName, payload: dappConfig.manifest,
|
|
45
|
+
},
|
|
40
46
|
context,
|
|
41
47
|
locator,
|
|
42
48
|
wallet,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { forget } from '@xylabs/forget'
|
|
2
2
|
import type { Promisable } from '@xylabs/promise'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
fulfilled, rejected,
|
|
5
|
+
} from '@xylabs/promise'
|
|
4
6
|
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
5
7
|
import type {
|
|
6
8
|
DappPackageManifestPayload,
|
|
@@ -9,7 +11,8 @@ import type {
|
|
|
9
11
|
PayloadWithVersion,
|
|
10
12
|
RegisteredDappSetResult,
|
|
11
13
|
XyOsContext,
|
|
12
|
-
XyOsDappContext
|
|
14
|
+
XyOsDappContext,
|
|
15
|
+
} from '@xyo-network/os-model'
|
|
13
16
|
import {
|
|
14
17
|
DappIntentTypes,
|
|
15
18
|
DappMode,
|
|
@@ -17,7 +20,9 @@ import {
|
|
|
17
20
|
isRegisteredDappExposedDappSet,
|
|
18
21
|
} from '@xyo-network/os-model'
|
|
19
22
|
|
|
20
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
dappAccessRequestConnection, DappAccessRequestEvent, exposeDappRequestConnection, ExposeDappRequestEvent,
|
|
25
|
+
} from '../../event/index.ts'
|
|
21
26
|
import { DappIntentCaller } from '../../intent/index.ts'
|
|
22
27
|
import { NameTransforms } from '../../lib/index.ts'
|
|
23
28
|
import { DappSeedPhraseRepository } from '../../wallet/index.ts'
|
|
@@ -53,7 +58,9 @@ export class DappRegistrationService {
|
|
|
53
58
|
|
|
54
59
|
constructor(
|
|
55
60
|
private context: XyOsContext,
|
|
56
|
-
private params: DappRegistrationServiceParams = {
|
|
61
|
+
private params: DappRegistrationServiceParams = {
|
|
62
|
+
dappNames: [], dappParams: {}, dappPayloads: [],
|
|
63
|
+
},
|
|
57
64
|
private locator = new ModuleFactoryLocator(),
|
|
58
65
|
private developmentMode?: boolean,
|
|
59
66
|
) {
|
|
@@ -76,7 +83,14 @@ export class DappRegistrationService {
|
|
|
76
83
|
dappId = NameTransforms.slug(manifest.nodes[0]?.config.name),
|
|
77
84
|
name = NameTransforms.moduleName(manifest.nodes[0]?.config.name),
|
|
78
85
|
): Promisable<XyOsDappContext> {
|
|
79
|
-
const dapp = new XyOsDapp({
|
|
86
|
+
const dapp = new XyOsDapp({
|
|
87
|
+
dapp: {
|
|
88
|
+
id: dappId, name,
|
|
89
|
+
},
|
|
90
|
+
locator: this.locator,
|
|
91
|
+
manifest,
|
|
92
|
+
parent: this.context,
|
|
93
|
+
}) as XyOsDappContext
|
|
80
94
|
this.builtDapps[dappId] = dapp
|
|
81
95
|
return dapp
|
|
82
96
|
}
|
|
@@ -92,7 +106,9 @@ export class DappRegistrationService {
|
|
|
92
106
|
activeDapps.map(async (dappSet) => {
|
|
93
107
|
const { dapp } = dappSet
|
|
94
108
|
const registeredDapp = await this.dappRegistry.registerDapp(dapp)
|
|
95
|
-
const result: RegisteredDappSetResult = {
|
|
109
|
+
const result: RegisteredDappSetResult = {
|
|
110
|
+
dapp: registeredDapp, dappIcon: dapp.icon,
|
|
111
|
+
}
|
|
96
112
|
|
|
97
113
|
// Start post registration process in the background
|
|
98
114
|
const forgetHandlers = async () => {
|
|
@@ -112,7 +128,9 @@ export class DappRegistrationService {
|
|
|
112
128
|
|
|
113
129
|
for (const registeredDapp of succeeded) this.registeredDappSets.add(registeredDapp)
|
|
114
130
|
|
|
115
|
-
return {
|
|
131
|
+
return {
|
|
132
|
+
failed, succeeded,
|
|
133
|
+
}
|
|
116
134
|
}
|
|
117
135
|
|
|
118
136
|
private addConnectionRequests() {
|
|
@@ -6,7 +6,8 @@ import type {
|
|
|
6
6
|
RegisteredDapp,
|
|
7
7
|
RegisteredDappAccess,
|
|
8
8
|
UnregisteredDapp,
|
|
9
|
-
UnregisteredDappAccess
|
|
9
|
+
UnregisteredDappAccess,
|
|
10
|
+
} from '@xyo-network/os-model'
|
|
10
11
|
import {
|
|
11
12
|
DappRegisteredSchema,
|
|
12
13
|
DappRegisteredState,
|
|
@@ -15,8 +16,7 @@ import {
|
|
|
15
16
|
import type { WithMeta } from '@xyo-network/payload-model'
|
|
16
17
|
|
|
17
18
|
import type { DappSeedPhraseRepository } from '../../wallet/index.ts'
|
|
18
|
-
import type {
|
|
19
|
-
FailedAccessor } from './ValidateDappAccessDiviner/index.ts'
|
|
19
|
+
import type { FailedAccessor } from './ValidateDappAccessDiviner/index.ts'
|
|
20
20
|
import {
|
|
21
21
|
isFailedAccessor,
|
|
22
22
|
ValidateDappAccessDiviner,
|
|
@@ -41,7 +41,9 @@ export class DappRegistry {
|
|
|
41
41
|
**/
|
|
42
42
|
async registerDapp(dapp?: UnregisteredDapp): Promise<RegisteredDapp | null> {
|
|
43
43
|
if (dapp) {
|
|
44
|
-
const {
|
|
44
|
+
const {
|
|
45
|
+
exposedModuleIds, manifest, modes, name, version, params, widgetConfigs,
|
|
46
|
+
} = this.extractDappProperties(dapp)
|
|
45
47
|
|
|
46
48
|
try {
|
|
47
49
|
/**
|
|
@@ -96,10 +98,16 @@ export class DappRegistry {
|
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
private extractDappProperties(dapp: UnregisteredDapp) {
|
|
99
|
-
const {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
const {
|
|
102
|
+
params, config, widgetConfigs,
|
|
103
|
+
} = dapp
|
|
104
|
+
const {
|
|
105
|
+
exposedModuleIds, manifest, modes, name, sources, version,
|
|
106
|
+
} = config
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
exposedModuleIds, manifest, modes, name, params, sources, version, widgetConfigs,
|
|
110
|
+
}
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
private async validateDappAccessPayloads(manifest: DappPackageManifestPayload, accessors: UnregisteredDappAccess[] = [], params: DappParams) {
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { DivinerParams } from '@xyo-network/diviner-model'
|
|
2
2
|
import type { PackageManifestPayload } from '@xyo-network/manifest'
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DappPackageManifestPayload, DappParams, RegisteredDappAccess, UnregisteredDappAccess,
|
|
5
|
+
} from '@xyo-network/os-model'
|
|
6
|
+
import type {
|
|
7
|
+
Payload, WithMeta,
|
|
8
|
+
} from '@xyo-network/payload-model'
|
|
5
9
|
import { isPayloadOfSchemaTypeWithMeta } from '@xyo-network/payload-model'
|
|
6
10
|
|
|
7
11
|
export const FailedAccessorSchema = 'network.xyo.os.failed.accessor.registration' as const
|
|
8
12
|
export type FailedAccessorSchema = typeof FailedAccessorSchema
|
|
9
13
|
|
|
10
|
-
export type FailedAccessor = Payload<{
|
|
14
|
+
export type FailedAccessor = Payload<{
|
|
15
|
+
accessor: UnregisteredDappAccess
|
|
16
|
+
errorMessage: string
|
|
17
|
+
}, FailedAccessorSchema>
|
|
11
18
|
|
|
12
19
|
export const isFailedAccessor = isPayloadOfSchemaTypeWithMeta<FailedAccessor>(FailedAccessorSchema)
|
|
13
20
|
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/hex'
|
|
2
2
|
import { HDWallet } from '@xyo-network/account'
|
|
3
3
|
import { AbstractDiviner } from '@xyo-network/diviner-abstract'
|
|
4
|
-
import type {
|
|
5
|
-
|
|
4
|
+
import type {
|
|
5
|
+
NodeManifestPayload, PackageManifestPayload,
|
|
6
|
+
} from '@xyo-network/manifest'
|
|
7
|
+
import {
|
|
8
|
+
ManifestWrapper, PackageManifestPayloadSchema,
|
|
9
|
+
} from '@xyo-network/manifest'
|
|
6
10
|
import type { NodeInstance } from '@xyo-network/node-model'
|
|
7
11
|
import type {
|
|
8
12
|
DappPackageManifestPayload,
|
|
9
13
|
DappParams,
|
|
10
14
|
RegisteredDappAccess,
|
|
11
|
-
UnregisteredDappAccess
|
|
15
|
+
UnregisteredDappAccess,
|
|
16
|
+
} from '@xyo-network/os-model'
|
|
12
17
|
import {
|
|
13
18
|
isDappPackageManifestPayload,
|
|
14
19
|
isUnregisteredDappAccess,
|
|
@@ -22,7 +27,8 @@ import type {
|
|
|
22
27
|
FailedAccessor,
|
|
23
28
|
ValidateDappAccessDivinerIn,
|
|
24
29
|
ValidateDappAccessDivinerOut,
|
|
25
|
-
ValidateDappAccessDivinerParams
|
|
30
|
+
ValidateDappAccessDivinerParams,
|
|
31
|
+
} from './Config.ts'
|
|
26
32
|
import {
|
|
27
33
|
FailedAccessorSchema,
|
|
28
34
|
ValidateDappAccessDivinerConfigSchema,
|
|
@@ -83,7 +89,9 @@ export class ValidateDappAccessDiviner<TParams extends ValidateDappAccessDiviner
|
|
|
83
89
|
}
|
|
84
90
|
} catch (e) {
|
|
85
91
|
failedAccessors.push(
|
|
86
|
-
await PayloadBuilder.build<FailedAccessor>({
|
|
92
|
+
await PayloadBuilder.build<FailedAccessor>({
|
|
93
|
+
accessor: access, errorMessage: (e as Error).message, schema: FailedAccessorSchema,
|
|
94
|
+
}),
|
|
87
95
|
)
|
|
88
96
|
}
|
|
89
97
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import { isEqual } from '@xylabs/lodash'
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
NodeBackground, WalletSeedPhrase, XyOsContext,
|
|
5
|
+
} from '@xyo-network/os-model'
|
|
4
6
|
import type { WithMeta } from '@xyo-network/payload-model'
|
|
5
7
|
|
|
6
8
|
import { buildUserWalletSeedPhrasePayload } from '../../utils/index.ts'
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
NodeBackground, WalletSeedPhrase, XyOsContext,
|
|
4
|
+
} from '@xyo-network/os-model'
|
|
5
|
+
import {
|
|
6
|
+
isNodeBackground, isWalletSeedPhrase,
|
|
7
|
+
} from '@xyo-network/os-model'
|
|
4
8
|
|
|
5
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
Listener, ResourceStore,
|
|
11
|
+
} from '../../lib/index.ts'
|
|
6
12
|
import { PayloadStore } from '../../lib/index.ts'
|
|
7
13
|
import { OsSettingsCallerBase } from './CallerBase.ts'
|
|
8
14
|
import { OsSettingsQueries } from './SettingsQueries.ts'
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { DivinerInstance } from '@xyo-network/diviner-model'
|
|
2
2
|
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type {
|
|
4
|
+
NodeBackground, WalletSeedPhrase,
|
|
5
|
+
} from '@xyo-network/os-model'
|
|
6
|
+
import {
|
|
7
|
+
NodeBackgroundSchema, WalletSeedPhraseSchema,
|
|
8
|
+
} from '@xyo-network/os-model'
|
|
5
9
|
import type { WithMeta } from '@xyo-network/payload-model'
|
|
6
10
|
|
|
7
11
|
const NO_RESULTS: WithMeta<WalletSeedPhrase>[] = []
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
OsBadge, XyOsContext,
|
|
4
|
+
} from '@xyo-network/os-model'
|
|
3
5
|
import { isBadgeWithMeta } from '@xyo-network/os-model'
|
|
4
6
|
|
|
5
7
|
import type { ResourceStore } from '../../../lib/index.ts'
|
|
@@ -23,15 +25,11 @@ export class OsBadgeResource extends OsSettingsCallerBase implements ResourceSto
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
get subscriptions() {
|
|
26
|
-
return {
|
|
27
|
-
savedSeedPhrase: (cb: () => void) => this.savedSeedPhrase.subscribe(cb),
|
|
28
|
-
}
|
|
28
|
+
return { savedSeedPhrase: (cb: () => void) => this.savedSeedPhrase.subscribe(cb) }
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
get views() {
|
|
32
|
-
return {
|
|
33
|
-
savedSeedPhrase: () => this.savedSeedPhrase.latest,
|
|
34
|
-
}
|
|
32
|
+
return { savedSeedPhrase: () => this.savedSeedPhrase.latest }
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
cleanupListeners() {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
2
2
|
import type { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
DappConfig, DappIcon, DappParams, DappSet, PayloadWithVersion, XyOsContext,
|
|
5
|
+
} from '@xyo-network/os-model'
|
|
4
6
|
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
5
7
|
import type { WithMeta } from '@xyo-network/payload-model'
|
|
6
8
|
import semver from 'semver'
|
|
@@ -9,7 +11,10 @@ import { OsCallerBase } from '../../OsCallerBase.ts'
|
|
|
9
11
|
import { SystemDappQueries } from './Queries.ts'
|
|
10
12
|
|
|
11
13
|
export type ErrorListener = (failedPayloads: DappConfig[]) => void
|
|
12
|
-
export type DappSetsAndPayloads = {
|
|
14
|
+
export type DappSetsAndPayloads = {
|
|
15
|
+
dappPayloads: (DappConfig | DappIcon)[]
|
|
16
|
+
dappSets: DappSet[]
|
|
17
|
+
}
|
|
13
18
|
|
|
14
19
|
/**
|
|
15
20
|
* Manage the installation of system dapps from payloads and return the built sets
|
|
@@ -2,7 +2,9 @@ import { assertEx } from '@xylabs/assert'
|
|
|
2
2
|
import type { BaseParams } from '@xylabs/object'
|
|
3
3
|
import { BaseEmitter } from '@xyo-network/module-abstract'
|
|
4
4
|
import type { EventData } from '@xyo-network/module-events'
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
EventBusConnectionInterface, EventBusConnectionRequest, EventBusConnectionType,
|
|
7
|
+
} from '@xyo-network/os-model'
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* A Generic Connection to add to an EventBus
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import { forget } from '@xylabs/forget'
|
|
3
3
|
import type { ArchivistModuleEventData } from '@xyo-network/archivist'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
asArchivistInstance, MemoryArchivist, MemoryArchivistConfigSchema,
|
|
6
|
+
} from '@xyo-network/archivist'
|
|
5
7
|
import type {
|
|
6
8
|
EventBusConnectionInterface,
|
|
7
9
|
EventBusEvent,
|
|
8
10
|
EventBusInterface,
|
|
9
11
|
EventBusPubSubConnectionInterface,
|
|
10
|
-
PublisherEventListener
|
|
12
|
+
PublisherEventListener,
|
|
13
|
+
} from '@xyo-network/os-model'
|
|
11
14
|
import {
|
|
12
15
|
isEventBusEvent,
|
|
13
16
|
isPubSubConnections,
|
|
@@ -76,7 +79,11 @@ export class EventBus implements EventBusInterface {
|
|
|
76
79
|
|
|
77
80
|
async start(storeName = 'EventBusArchivist') {
|
|
78
81
|
// Later versions could include a node that has a payload diviner to query past events
|
|
79
|
-
this._archivist = await MemoryArchivist.create({
|
|
82
|
+
this._archivist = await MemoryArchivist.create({
|
|
83
|
+
config: {
|
|
84
|
+
name: storeName, schema: MemoryArchivistConfigSchema,
|
|
85
|
+
},
|
|
86
|
+
})
|
|
80
87
|
|
|
81
88
|
// start listening to inserted events from publishers
|
|
82
89
|
// NOTE: This is a very basic implementation and could be optimized by indexing on connection, eventName, and callback
|
|
@@ -112,7 +119,9 @@ export class EventBus implements EventBusInterface {
|
|
|
112
119
|
// Create publisher callback
|
|
113
120
|
const connectionPublisherCallback: PublisherEventListener = async ({ payloads }) => {
|
|
114
121
|
// build the event payload
|
|
115
|
-
const event: EventBusEvent = {
|
|
122
|
+
const event: EventBusEvent = {
|
|
123
|
+
name: eventName, schema: 'network.xyo.event.bus.event',
|
|
124
|
+
}
|
|
116
125
|
const eventPayloads = payloads ?? []
|
|
117
126
|
event.sources = await PayloadBuilder.dataHashes(eventPayloads)
|
|
118
127
|
// Sync events to archivist
|
|
@@ -3,18 +3,18 @@ import type { XyOsGlobal } from '@xyo-network/os-model'
|
|
|
3
3
|
import type { MonitorEventConfig } from './types.ts'
|
|
4
4
|
|
|
5
5
|
// See - https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation
|
|
6
|
-
export type Connection = {
|
|
6
|
+
export type Connection = {
|
|
7
|
+
downlink: number
|
|
8
|
+
effectiveType: string
|
|
9
|
+
rtt: number
|
|
10
|
+
}
|
|
7
11
|
|
|
8
12
|
const DEFAULT_MONITORING_EVENT_NAME = 'System Task Duration'
|
|
9
13
|
|
|
10
14
|
globalThis.getXyOsGlobal
|
|
11
15
|
= globalThis.getXyOsGlobal
|
|
12
16
|
?? ((): XyOsGlobal => {
|
|
13
|
-
return {
|
|
14
|
-
tracking: {
|
|
15
|
-
trackEvent: (_event: string, _properties?: Record<string, unknown>) => void {},
|
|
16
|
-
},
|
|
17
|
-
}
|
|
17
|
+
return { tracking: { trackEvent: (_event: string, _properties?: Record<string, unknown>) => void {} } }
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
// TODO: Make this node compatible
|
|
@@ -30,7 +30,9 @@ export abstract class XyOsMonitor {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
stopTimer(eventConfig: MonitorEventConfig): void {
|
|
33
|
-
const {
|
|
33
|
+
const {
|
|
34
|
+
additionalProperties, name,
|
|
35
|
+
} = eventConfig
|
|
34
36
|
const start = this.performanceTimers.get(name)
|
|
35
37
|
if (start) {
|
|
36
38
|
const end = performance.now()
|
|
@@ -2,4 +2,7 @@ import type { JsonObject } from '@xylabs/object'
|
|
|
2
2
|
|
|
3
3
|
export type MonitorEventNames = 'Load XyOs' | 'Install System dApps' | 'Expose dApps' | 'Loading dApp'
|
|
4
4
|
|
|
5
|
-
export type MonitorEventConfig = {
|
|
5
|
+
export type MonitorEventConfig = {
|
|
6
|
+
additionalProperties?: JsonObject
|
|
7
|
+
name: MonitorEventNames
|
|
8
|
+
}
|
package/src/intent/Caller.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
DappId, DappIntent, DappIntentTypes, XyOsContext,
|
|
4
|
+
} from '@xyo-network/os-model'
|
|
5
|
+
import {
|
|
6
|
+
DappIntentSchema, DappMode,
|
|
7
|
+
} from '@xyo-network/os-model'
|
|
4
8
|
import type { WithMeta } from '@xyo-network/payload-model'
|
|
5
9
|
|
|
6
10
|
import { DappCallerBase } from '../DappCallerBase.ts'
|
package/src/intent/Resource.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
DappIntent, XyOsContext,
|
|
4
|
+
} from '@xyo-network/os-model'
|
|
3
5
|
import { isDappIntent } from '@xyo-network/os-model'
|
|
4
6
|
import type { WithMeta } from '@xyo-network/payload-model'
|
|
5
7
|
|
|
6
8
|
import { DappCallerBase } from '../DappCallerBase.ts'
|
|
7
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
Listener, ResourceStore,
|
|
11
|
+
} from '../lib/index.ts'
|
|
8
12
|
import { PayloadStore } from '../lib/index.ts'
|
|
9
13
|
|
|
10
14
|
export type DappIntentViews = 'latestDappIntent' | 'allDappIntents'
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DevelopArchivist, NodeSentinel,
|
|
3
|
+
} from './ModuleNames.ts'
|
|
2
4
|
|
|
3
5
|
export const RemoteNodeArchivistOffsetPaths: Record<string, Record<string, string>> = {
|
|
4
|
-
Kerplunk: {
|
|
5
|
-
|
|
6
|
-
},
|
|
7
|
-
Local: {
|
|
8
|
-
[DevelopArchivist]: '115',
|
|
9
|
-
},
|
|
10
|
-
Main: {
|
|
11
|
-
[DevelopArchivist]: '121',
|
|
12
|
-
},
|
|
6
|
+
Kerplunk: { [DevelopArchivist]: '118' },
|
|
7
|
+
Local: { [DevelopArchivist]: '115' },
|
|
8
|
+
Main: { [DevelopArchivist]: '121' },
|
|
13
9
|
}
|
|
14
10
|
|
|
15
11
|
export const ModuleOffsetPaths: Record<string, string> = {
|
package/src/lib/PayloadStore.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ArchivistInstance, ArchivistModuleEventData,
|
|
3
|
+
} from '@xyo-network/archivist'
|
|
4
|
+
import type {
|
|
5
|
+
Payload, WithMeta, WithSources,
|
|
6
|
+
} from '@xyo-network/payload-model'
|
|
3
7
|
|
|
4
8
|
import type { ExternalStore } from './ExternalStore.ts'
|
|
5
9
|
import type { Listener } from './Listener.ts'
|
|
@@ -21,7 +25,9 @@ export class PayloadStore<T extends Payload = Payload> implements ExternalStore
|
|
|
21
25
|
/**
|
|
22
26
|
* Initialize listeners on the archivist that update class member variables when new payloads are inserted
|
|
23
27
|
*/
|
|
24
|
-
static async create<T extends Payload = Payload>({
|
|
28
|
+
static async create<T extends Payload = Payload>({
|
|
29
|
+
archivist, getLatest, idFunction,
|
|
30
|
+
}: PayloadStoreConfig<T>) {
|
|
25
31
|
const instance = new this<T>(archivist)
|
|
26
32
|
|
|
27
33
|
const insertListener = async ({ payloads }: ArchivistModuleEventData['inserted']) => {
|
package/src/lib/isPayload.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AsObjectFactory } from '@xylabs/object'
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
Payload, Schema,
|
|
4
|
+
} from '@xyo-network/payload-model'
|
|
3
5
|
|
|
4
6
|
export const isObject = (x: unknown): x is Record<string | symbol | number, unknown> => {
|
|
5
7
|
return typeof x === 'object' && !Array.isArray(x)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { getXnsDomain } from '@xyo-network/kernel'
|
|
2
2
|
import type { Payload } from '@xyo-network/payload-model'
|
|
3
3
|
|
|
4
|
-
export const ManifestReplaceableTokens = (
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export const ManifestReplaceableTokens = (
|
|
5
|
+
xnsNodeUrl: string | undefined,
|
|
6
|
+
xnsNetwork: string | undefined,
|
|
7
|
+
) => ({ '[REPLACE_WITH_NS_NODE_URL]': getXnsDomain(xnsNodeUrl, xnsNetwork) })
|
|
7
8
|
|
|
8
9
|
export const ReplaceManifestTokens = (manifest: Payload, xnsNodeUrl: string | undefined, xnsNetwork: string | undefined) => {
|
|
9
10
|
// Replace ReplaceableTokens in the manifest
|
|
@@ -17,12 +17,16 @@ export const profileModuleEvents = (mod: ModuleInstance) => {
|
|
|
17
17
|
mod.onAny(async (eventName, args) => {
|
|
18
18
|
const mod = modRef.deref()
|
|
19
19
|
if (mod) {
|
|
20
|
-
const data = profileData[mod.address] ?? {
|
|
20
|
+
const data = profileData[mod.address] ?? {
|
|
21
|
+
allEventCount: 0, eventCounts: {},
|
|
22
|
+
}
|
|
21
23
|
profileData[mod.address] = data
|
|
22
24
|
data.allEventCount += 1
|
|
23
25
|
data.eventCounts[eventName] = (data.eventCounts[eventName] ?? 0) + 1
|
|
24
26
|
if (eventName === 'querySendStarted') {
|
|
25
|
-
const {
|
|
27
|
+
const {
|
|
28
|
+
query, payloads = [],
|
|
29
|
+
} = args as QuerySendStartedEventArgs
|
|
26
30
|
const pairs = await PayloadBuilder.dataHashPairs(payloads)
|
|
27
31
|
const foundPair = pairs.find(([, hash]) => hash === query.query)
|
|
28
32
|
if (foundPair) {
|
package/src/stack/Base.ts
CHANGED
|
@@ -6,7 +6,9 @@ import type { ModuleIdentifier } from '@xyo-network/module-model'
|
|
|
6
6
|
import { isModuleInstance } from '@xyo-network/module-model'
|
|
7
7
|
import type { AttachableNodeInstance } from '@xyo-network/node-model'
|
|
8
8
|
import { asAttachableNodeInstance } from '@xyo-network/node-model'
|
|
9
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
AdapterSetCreator, NodeAdapter, NodeAdapterBaseEvents, StackBaseEvents, StackInitializer, XyOsContext,
|
|
11
|
+
} from '@xyo-network/os-model'
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Stack Base Class
|
|
@@ -33,8 +35,12 @@ export class StackBase extends BaseEmitter<BaseParams, StackBaseEvents> implemen
|
|
|
33
35
|
|
|
34
36
|
// list of listeners - lister type not important since its only recalled to stop listening
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
private listeners: {
|
|
39
|
+
adapter: NodeAdapter
|
|
40
|
+
eventName: string
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
listener: (args: any) => void
|
|
43
|
+
}[] = []
|
|
38
44
|
|
|
39
45
|
constructor(context: XyOsContext, adapterSet: AdapterSetCreator, stackNodeModuleId: ModuleIdentifier) {
|
|
40
46
|
super({})
|
|
@@ -66,7 +72,9 @@ export class StackBase extends BaseEmitter<BaseParams, StackBaseEvents> implemen
|
|
|
66
72
|
// listen for driver ready events
|
|
67
73
|
const driverReadyListener = async ({ node }: NodeAdapterBaseEvents['driverReady']) => await this.handleDriverReady(node)
|
|
68
74
|
adapter.on('driverReady', driverReadyListener)
|
|
69
|
-
this.listeners.push({
|
|
75
|
+
this.listeners.push({
|
|
76
|
+
adapter: adapter, eventName: 'driverReady', listener: driverReadyListener,
|
|
77
|
+
})
|
|
70
78
|
|
|
71
79
|
// listen for driver error events
|
|
72
80
|
const driverErrorListener = async ({ error }: NodeAdapterBaseEvents['driverError']) => {
|
|
@@ -74,7 +82,9 @@ export class StackBase extends BaseEmitter<BaseParams, StackBaseEvents> implemen
|
|
|
74
82
|
await this.emit('driverError', { error })
|
|
75
83
|
}
|
|
76
84
|
adapter.on('driverError', driverErrorListener)
|
|
77
|
-
this.listeners.push({
|
|
85
|
+
this.listeners.push({
|
|
86
|
+
adapter: adapter, eventName: 'driverError', listener: driverErrorListener,
|
|
87
|
+
})
|
|
78
88
|
|
|
79
89
|
// start the adapter
|
|
80
90
|
const startAdapter = async () => await adapter.start()
|
|
@@ -86,7 +96,9 @@ export class StackBase extends BaseEmitter<BaseParams, StackBaseEvents> implemen
|
|
|
86
96
|
* Stops the stack
|
|
87
97
|
*/
|
|
88
98
|
stop() {
|
|
89
|
-
for (const {
|
|
99
|
+
for (const {
|
|
100
|
+
eventName, listener, adapter,
|
|
101
|
+
} of this.listeners) {
|
|
90
102
|
// stop the adapter
|
|
91
103
|
adapter.off(eventName, listener)
|
|
92
104
|
}
|
package/src/stack/Manager.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
AdapterSetCreator, StackInitializer, XyOsContext,
|
|
3
|
+
} from '@xyo-network/os-model'
|
|
2
4
|
|
|
3
5
|
import type { StackBase } from './Base.ts'
|
|
4
6
|
|
|
5
|
-
export interface StackConstructor {
|
|
6
|
-
new (context: XyOsContext, adapters: AdapterSetCreator): StackBase
|
|
7
|
-
}
|
|
7
|
+
export interface StackConstructor { new (context: XyOsContext, adapters: AdapterSetCreator): StackBase }
|
|
8
8
|
|
|
9
9
|
export interface UninitializedStackSet {
|
|
10
10
|
adapters: AdapterSetCreator
|
|
11
11
|
stack: StackConstructor
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export interface UninitializedStackMap {
|
|
15
|
-
[key: string]: UninitializedStackSet
|
|
16
|
-
}
|
|
14
|
+
export interface UninitializedStackMap { [key: string]: UninitializedStackSet }
|
|
17
15
|
|
|
18
16
|
export class StackManager {
|
|
19
17
|
private initializedStacksMap: Map<string, StackInitializer> = new Map()
|
|
@@ -33,7 +31,9 @@ export class StackManager {
|
|
|
33
31
|
|
|
34
32
|
initialize(context: XyOsContext) {
|
|
35
33
|
for (const [key, stackSet] of Object.entries(this.stackMap)) {
|
|
36
|
-
const {
|
|
34
|
+
const {
|
|
35
|
+
stack: Stack, adapters: stackNodeModuleId,
|
|
36
|
+
} = stackSet
|
|
37
37
|
const initializedStack = new Stack(context, stackNodeModuleId)
|
|
38
38
|
initializedStack.initialize()
|
|
39
39
|
this.stacks.set(key, initializedStack)
|