@xyo-network/os-runtime 7.2.0 → 7.3.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/neutral/Caller.d.ts +18 -20
- package/dist/neutral/Caller.d.ts.map +1 -1
- package/dist/neutral/DappCallerBase.d.ts +2 -2
- package/dist/neutral/DappCallerBase.d.ts.map +1 -1
- package/dist/neutral/OsCallerBase.d.ts +2 -2
- package/dist/neutral/PubSubBridgeCaller.d.ts +1 -1
- package/dist/neutral/PubSubBridgeCaller.d.ts.map +1 -1
- package/dist/neutral/RunningDappCache.d.ts.map +1 -1
- package/dist/neutral/XyOs.d.ts +5 -6
- package/dist/neutral/XyOs.d.ts.map +1 -1
- package/dist/neutral/XyOsBase.d.ts +124 -7
- package/dist/neutral/XyOsBase.d.ts.map +1 -1
- package/dist/neutral/XyOsDapp.d.ts +3 -3
- package/dist/neutral/XyOsDapp.d.ts.map +1 -1
- package/dist/neutral/access/Caller.d.ts +2 -2
- package/dist/neutral/access/Caller.d.ts.map +1 -1
- package/dist/neutral/access/RunningAccessDappCache.d.ts.map +1 -1
- package/dist/neutral/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
- package/dist/neutral/adapter/Base.d.ts +2 -2
- package/dist/neutral/adapter/Base.d.ts.map +1 -1
- package/dist/neutral/classes/lib/DappCreatorParams.d.ts +3 -3
- package/dist/neutral/classes/lib/DappCreatorParams.d.ts.map +1 -1
- package/dist/neutral/classes/lib/Insertable.d.ts +1 -3
- package/dist/neutral/classes/lib/Insertable.d.ts.map +1 -1
- package/dist/neutral/classes/menu/Caller.d.ts +1 -2
- package/dist/neutral/classes/menu/Caller.d.ts.map +1 -1
- package/dist/neutral/classes/settings/Caller.d.ts +2 -2
- package/dist/neutral/classes/settings/CallerBase.d.ts +1 -1
- package/dist/neutral/classes/settings/SettingsQueries.d.ts.map +1 -1
- package/dist/neutral/classes/settings/badge/Caller.d.ts +2 -2
- package/dist/neutral/classes/settings/badge/Resource.d.ts +1 -1
- package/dist/neutral/classes/settings/badge/Resource.d.ts.map +1 -1
- package/dist/neutral/dapp/context/creator/Creator.d.ts +1 -1
- package/dist/neutral/dapp/context/creator/Creator.d.ts.map +1 -1
- package/dist/neutral/dapp/context/creator/createDappContext.d.ts.map +1 -1
- package/dist/neutral/event/bus/Connection.d.ts +3 -4
- package/dist/neutral/event/bus/Connection.d.ts.map +1 -1
- package/dist/neutral/event/bus/EventBus.d.ts +1 -1
- package/dist/neutral/event/bus/EventBus.d.ts.map +1 -1
- package/dist/neutral/event/bus/PubSubConnection.d.ts +1 -1
- package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts +2 -2
- package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
- package/dist/neutral/helpers/monitor/types.d.ts +3 -3
- package/dist/neutral/helpers/monitor/types.d.ts.map +1 -1
- package/dist/neutral/index.mjs +1042 -694
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/intent/Caller.d.ts +5 -5
- package/dist/neutral/lib/Listener.d.ts +1 -1
- package/dist/neutral/lib/Listener.d.ts.map +1 -1
- package/dist/neutral/lib/PayloadStore.d.ts +1 -2
- package/dist/neutral/lib/PayloadStore.d.ts.map +1 -1
- package/dist/neutral/lib/isPayload.d.ts +1 -1
- package/dist/neutral/loadOsNode.d.ts.map +1 -1
- package/dist/neutral/profileModuleEvents.d.ts +2 -4
- package/dist/neutral/profileModuleEvents.d.ts.map +1 -1
- package/dist/neutral/registration/DappRegistrationService.d.ts +3 -3
- package/dist/neutral/registration/DappRegistrationService.d.ts.map +1 -1
- package/dist/neutral/registration/DappRegistry.d.ts +4 -6
- package/dist/neutral/registration/DappRegistry.d.ts.map +1 -1
- package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts +7 -3
- package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -1
- package/dist/neutral/registration/ValidateDappAccessDiviner/Diviner.d.ts +3 -1
- package/dist/neutral/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +1 -1
- package/dist/neutral/scripts/xyos/lib/headless.d.ts.map +1 -1
- package/dist/neutral/signer/Signers.d.ts.map +1 -1
- package/dist/neutral/stack/Base.d.ts +2 -2
- package/dist/neutral/stack/Base.d.ts.map +1 -1
- package/dist/neutral/stack/Manager.d.ts +2 -6
- package/dist/neutral/stack/Manager.d.ts.map +1 -1
- package/dist/neutral/system/ManageSystemDapps.d.ts +3 -3
- package/dist/neutral/system/ManageSystemDapps.d.ts.map +1 -1
- package/dist/neutral/utils/buildWalletSeedPhrasePayload.d.ts +1 -1
- package/dist/neutral/utils/buildWalletSeedPhrasePayload.d.ts.map +1 -1
- package/dist/neutral/wallet/SeedPhraseRepository.d.ts +3 -4
- package/dist/neutral/wallet/SeedPhraseRepository.d.ts.map +1 -1
- package/dist/node/Caller.d.ts +18 -20
- package/dist/node/Caller.d.ts.map +1 -1
- package/dist/node/DappCallerBase.d.ts +2 -2
- package/dist/node/DappCallerBase.d.ts.map +1 -1
- package/dist/node/OsCallerBase.d.ts +2 -2
- package/dist/node/PubSubBridgeCaller.d.ts +1 -1
- package/dist/node/PubSubBridgeCaller.d.ts.map +1 -1
- package/dist/node/RunningDappCache.d.ts.map +1 -1
- package/dist/node/XyOs.d.ts +5 -6
- package/dist/node/XyOs.d.ts.map +1 -1
- package/dist/node/XyOsBase.d.ts +124 -7
- package/dist/node/XyOsBase.d.ts.map +1 -1
- package/dist/node/XyOsDapp.d.ts +3 -3
- package/dist/node/XyOsDapp.d.ts.map +1 -1
- package/dist/node/access/Caller.d.ts +2 -2
- package/dist/node/access/Caller.d.ts.map +1 -1
- package/dist/node/access/RunningAccessDappCache.d.ts.map +1 -1
- package/dist/node/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
- package/dist/node/adapter/Base.d.ts +2 -2
- package/dist/node/adapter/Base.d.ts.map +1 -1
- package/dist/node/classes/lib/DappCreatorParams.d.ts +3 -3
- package/dist/node/classes/lib/DappCreatorParams.d.ts.map +1 -1
- package/dist/node/classes/lib/Insertable.d.ts +1 -3
- package/dist/node/classes/lib/Insertable.d.ts.map +1 -1
- package/dist/node/classes/menu/Caller.d.ts +1 -2
- package/dist/node/classes/menu/Caller.d.ts.map +1 -1
- package/dist/node/classes/settings/Caller.d.ts +2 -2
- package/dist/node/classes/settings/CallerBase.d.ts +1 -1
- package/dist/node/classes/settings/SettingsQueries.d.ts.map +1 -1
- package/dist/node/classes/settings/badge/Caller.d.ts +2 -2
- package/dist/node/classes/settings/badge/Resource.d.ts +1 -1
- package/dist/node/classes/settings/badge/Resource.d.ts.map +1 -1
- package/dist/node/dapp/context/creator/Creator.d.ts +1 -1
- package/dist/node/dapp/context/creator/Creator.d.ts.map +1 -1
- package/dist/node/dapp/context/creator/createDappContext.d.ts.map +1 -1
- package/dist/node/event/bus/Connection.d.ts +3 -4
- package/dist/node/event/bus/Connection.d.ts.map +1 -1
- package/dist/node/event/bus/EventBus.d.ts +1 -1
- package/dist/node/event/bus/EventBus.d.ts.map +1 -1
- package/dist/node/event/bus/PubSubConnection.d.ts +1 -1
- package/dist/node/helpers/monitor/XyOsMonitor.d.ts +2 -2
- package/dist/node/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
- package/dist/node/helpers/monitor/types.d.ts +3 -3
- package/dist/node/helpers/monitor/types.d.ts.map +1 -1
- package/dist/node/index.mjs +1042 -694
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/intent/Caller.d.ts +5 -5
- package/dist/node/lib/Listener.d.ts +1 -1
- package/dist/node/lib/Listener.d.ts.map +1 -1
- package/dist/node/lib/PayloadStore.d.ts +1 -2
- package/dist/node/lib/PayloadStore.d.ts.map +1 -1
- package/dist/node/lib/isPayload.d.ts +1 -1
- package/dist/node/loadOsNode.d.ts.map +1 -1
- package/dist/node/profileModuleEvents.d.ts +2 -4
- package/dist/node/profileModuleEvents.d.ts.map +1 -1
- package/dist/node/registration/DappRegistrationService.d.ts +3 -3
- package/dist/node/registration/DappRegistrationService.d.ts.map +1 -1
- package/dist/node/registration/DappRegistry.d.ts +4 -6
- package/dist/node/registration/DappRegistry.d.ts.map +1 -1
- package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts +7 -3
- package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -1
- package/dist/node/registration/ValidateDappAccessDiviner/Diviner.d.ts +3 -1
- package/dist/node/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +1 -1
- package/dist/node/scripts/xyos/index.mjs +520 -384
- package/dist/node/scripts/xyos/index.mjs.map +1 -1
- package/dist/node/scripts/xyos/lib/headless.d.ts.map +1 -1
- package/dist/node/signer/Signers.d.ts.map +1 -1
- package/dist/node/stack/Base.d.ts +2 -2
- package/dist/node/stack/Base.d.ts.map +1 -1
- package/dist/node/stack/Manager.d.ts +2 -6
- package/dist/node/stack/Manager.d.ts.map +1 -1
- package/dist/node/system/ManageSystemDapps.d.ts +3 -3
- package/dist/node/system/ManageSystemDapps.d.ts.map +1 -1
- package/dist/node/utils/buildWalletSeedPhrasePayload.d.ts +1 -1
- package/dist/node/utils/buildWalletSeedPhrasePayload.d.ts.map +1 -1
- package/dist/node/wallet/SeedPhraseRepository.d.ts +3 -4
- package/dist/node/wallet/SeedPhraseRepository.d.ts.map +1 -1
- package/package.json +165 -55
- package/dist/neutral/signer/Signer.spec.d.ts +0 -2
- package/dist/neutral/signer/Signer.spec.d.ts.map +0 -1
- package/dist/neutral/spec/boot.spec.d.ts +0 -2
- package/dist/neutral/spec/boot.spec.d.ts.map +0 -1
- package/dist/node/signer/Signer.spec.d.ts +0 -2
- package/dist/node/signer/Signer.spec.d.ts.map +0 -1
- package/dist/node/spec/boot.spec.d.ts +0 -2
- package/dist/node/spec/boot.spec.d.ts.map +0 -1
- package/src/Caller.ts +0 -202
- package/src/DappCallerBase.ts +0 -56
- package/src/DefaultsQueries.ts +0 -27
- package/src/OsCallerBase.ts +0 -59
- package/src/PubSubBridgeCaller.ts +0 -33
- package/src/RunningDappCache.ts +0 -58
- package/src/XyOs.ts +0 -166
- package/src/XyOsBase.ts +0 -136
- package/src/XyOsDapp.ts +0 -103
- package/src/access/Caller.ts +0 -85
- package/src/access/Queries.ts +0 -38
- package/src/access/Resource.ts +0 -65
- package/src/access/RunningAccessDappCache.ts +0 -21
- package/src/access/index.ts +0 -4
- package/src/access/interfaces/index.ts +0 -1
- package/src/access/interfaces/registered-names/helpers/AccessNodeQueries.ts +0 -68
- package/src/access/interfaces/registered-names/helpers/index.ts +0 -2
- package/src/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.ts +0 -42
- package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResource.ts +0 -52
- package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.ts +0 -23
- package/src/access/interfaces/registered-names/helpers/resource/index.ts +0 -3
- package/src/access/interfaces/registered-names/index.ts +0 -1
- package/src/adapter/Base.ts +0 -104
- package/src/adapter/Network.ts +0 -31
- package/src/adapter/Settings.ts +0 -30
- package/src/adapter/index.ts +0 -2
- package/src/adapters/OsPubSubBridgeNetwork.ts +0 -10
- package/src/adapters/OsSettings.ts +0 -7
- package/src/adapters/OsXyoPublicNetwork.ts +0 -9
- package/src/adapters/index.ts +0 -3
- package/src/classes/dapp/DefaultsResource.ts +0 -67
- package/src/classes/dapp/index.ts +0 -1
- package/src/classes/index.ts +0 -4
- package/src/classes/lib/DappCreatorParams.ts +0 -18
- package/src/classes/lib/Insertable.ts +0 -10
- package/src/classes/lib/index.ts +0 -2
- package/src/classes/menu/Caller.ts +0 -77
- package/src/classes/menu/Queries.ts +0 -60
- package/src/classes/menu/Resource.ts +0 -105
- package/src/classes/menu/index.ts +0 -2
- package/src/classes/settings/Caller.ts +0 -78
- package/src/classes/settings/CallerBase.ts +0 -27
- package/src/classes/settings/Resource.ts +0 -81
- package/src/classes/settings/SettingsQueries.ts +0 -56
- package/src/classes/settings/badge/Caller.ts +0 -30
- package/src/classes/settings/badge/Queries.ts +0 -19
- package/src/classes/settings/badge/Resource.ts +0 -50
- package/src/classes/settings/badge/index.ts +0 -2
- package/src/classes/settings/index.ts +0 -5
- package/src/dapp/context/creator/Creator.ts +0 -122
- package/src/dapp/context/creator/DefaultPayloads/DappAccessPayloads.ts +0 -20
- package/src/dapp/context/creator/DefaultPayloads/DefaultPayloads.ts +0 -40
- package/src/dapp/context/creator/DefaultPayloads/NodeInfoPayload.ts +0 -33
- package/src/dapp/context/creator/DefaultPayloads/index.ts +0 -1
- package/src/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.ts +0 -59
- package/src/dapp/context/creator/ExternalModulePermissions/index.ts +0 -1
- package/src/dapp/context/creator/createDappContext.ts +0 -61
- package/src/dapp/context/creator/index.ts +0 -3
- package/src/dapp/context/index.ts +0 -1
- package/src/dapp/index.ts +0 -1
- package/src/event/bus/Connection.ts +0 -33
- package/src/event/bus/EventBus.ts +0 -159
- package/src/event/bus/PubSubConnection.ts +0 -28
- package/src/event/bus/index.ts +0 -3
- package/src/event/connections/DappAccessRequest.ts +0 -11
- package/src/event/connections/DappsReady.ts +0 -9
- package/src/event/connections/ExposeDappRequest.ts +0 -11
- package/src/event/connections/OsPubSubNetworkReady.ts +0 -12
- package/src/event/connections/OsSettingsReady.ts +0 -12
- package/src/event/connections/OsXyoPublicReady.ts +0 -12
- package/src/event/connections/index.ts +0 -6
- package/src/event/index.ts +0 -2
- package/src/helpers/index.ts +0 -1
- package/src/helpers/monitor/XyOsMonitor.ts +0 -52
- package/src/helpers/monitor/index.ts +0 -2
- package/src/helpers/monitor/types.ts +0 -8
- package/src/index.ts +0 -29
- package/src/initializer/DappInitializer.ts +0 -57
- package/src/initializer/index.ts +0 -1
- package/src/intent/Caller.ts +0 -74
- package/src/intent/Resource.ts +0 -66
- package/src/intent/index.ts +0 -2
- package/src/lib/ExternalStore.ts +0 -7
- package/src/lib/Listener.ts +0 -1
- package/src/lib/ModuleAccountPaths.ts +0 -23
- package/src/lib/ModuleNames.ts +0 -3
- package/src/lib/NameTransforms.ts +0 -34
- package/src/lib/PayloadStore.ts +0 -106
- package/src/lib/ResourceStores.ts +0 -7
- package/src/lib/index.ts +0 -11
- package/src/lib/initializeXns.ts +0 -16
- package/src/lib/isEqual.ts +0 -42
- package/src/lib/isPayload.ts +0 -24
- package/src/lib/tokenPlacesSplit.ts +0 -17
- package/src/loadOsNode.ts +0 -44
- package/src/manifest/index.ts +0 -2
- package/src/manifest/manifestReplacementTokens.ts +0 -6
- package/src/manifest/os-node.manifest.json +0 -132
- package/src/manifests/dapp-window.manifest.json +0 -36
- package/src/manifests/index.ts +0 -1
- package/src/models/access/ValidDappAccessInterfaces.ts +0 -6
- package/src/models/access/index.ts +0 -1
- package/src/models/index.ts +0 -1
- package/src/profileModuleEvents.ts +0 -43
- package/src/registration/DappRegistrationService.ts +0 -179
- package/src/registration/DappRegistry.ts +0 -131
- package/src/registration/ValidateDappAccessDiviner/Config.ts +0 -24
- package/src/registration/ValidateDappAccessDiviner/Diviner.ts +0 -133
- package/src/registration/ValidateDappAccessDiviner/index.ts +0 -2
- package/src/registration/index.ts +0 -2
- package/src/scripts/xyos/command/config.ts +0 -19
- package/src/scripts/xyos/command/create.ts +0 -22
- package/src/scripts/xyos/command/index.ts +0 -7
- package/src/scripts/xyos/command/manifest.ts +0 -19
- package/src/scripts/xyos/command/start.ts +0 -35
- package/src/scripts/xyos/index.ts +0 -32
- package/src/scripts/xyos/lib/createFromTemplate.ts +0 -11
- package/src/scripts/xyos/lib/headless.ts +0 -68
- package/src/scripts/xyos/lib/index.ts +0 -2
- package/src/signer/Signer.spec.ts +0 -65
- package/src/signer/Signers.ts +0 -74
- package/src/signer/index.ts +0 -1
- package/src/spec/boot.spec.ts +0 -89
- package/src/stack/Base.ts +0 -166
- package/src/stack/Manager.ts +0 -51
- package/src/stack/Map.ts +0 -22
- package/src/stack/OsPubSubNetworkStack.ts +0 -70
- package/src/stack/OsSettingsStack.ts +0 -24
- package/src/stack/XyoPublicNetworkStack.ts +0 -32
- package/src/stack/index.ts +0 -6
- package/src/system/ManageSystemDapps.ts +0 -148
- package/src/system/Queries.ts +0 -69
- package/src/system/index.ts +0 -1
- package/src/types/global.d.ts +0 -9
- package/src/types/images.d.ts +0 -5
- package/src/utils/buildWalletSeedPhrasePayload.ts +0 -51
- package/src/utils/getApiDomain.ts +0 -14
- package/src/utils/index.ts +0 -3
- package/src/utils/renameObjKey.ts +0 -22
- package/src/wallet/DappSeedPhraseRepository.ts +0 -99
- package/src/wallet/SeedPhraseRepository.ts +0 -32
- package/src/wallet/index.ts +0 -2
package/src/access/Caller.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
|
|
3
|
-
import type { ModuleFactoryLocatorInstance } from '@xyo-network/module-model'
|
|
4
|
-
import { asNodeInstance } from '@xyo-network/node-model'
|
|
5
|
-
import type {
|
|
6
|
-
PostRegistrationHandler,
|
|
7
|
-
RegisteredDappAccess,
|
|
8
|
-
RegisteredDappSet,
|
|
9
|
-
RegisteredDappSetResult,
|
|
10
|
-
XyOsContext,
|
|
11
|
-
} from '@xyo-network/os-model'
|
|
12
|
-
import { isRegisteredDappAccessDappSet } from '@xyo-network/os-model'
|
|
13
|
-
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
14
|
-
|
|
15
|
-
import { OsCallerBase } from '../OsCallerBase.ts'
|
|
16
|
-
import { RunningDappCache } from '../RunningDappCache.ts'
|
|
17
|
-
import { RunningDappAccessCache } from './RunningAccessDappCache.ts'
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Caller for managing Dapp Access Nodes
|
|
21
|
-
* Start nodes that have been registered as accessible
|
|
22
|
-
* Grab their Access Node(s)
|
|
23
|
-
* Put RegisteredDappAccess payloads in RegisteredDappInterfacesArchivist
|
|
24
|
-
* Keep Service running that can service requests for Access Nodes
|
|
25
|
-
**/
|
|
26
|
-
export class DappAccessCaller extends OsCallerBase implements PostRegistrationHandler {
|
|
27
|
-
private allowedNames: string[]
|
|
28
|
-
private platformLocator: ModuleFactoryLocatorInstance
|
|
29
|
-
private registeredDapps: RegisteredDappSetResult[]
|
|
30
|
-
private xnsNetwork: string | undefined
|
|
31
|
-
private xnsNodeUrl: string | undefined
|
|
32
|
-
|
|
33
|
-
constructor(
|
|
34
|
-
context: XyOsContext,
|
|
35
|
-
registeredDapps: RegisteredDappSetResult[],
|
|
36
|
-
allowedNames: string[],
|
|
37
|
-
xnsNodeUrl: string | undefined,
|
|
38
|
-
xnsNetwork: string | undefined,
|
|
39
|
-
platformLocator = new ModuleFactoryLocator(),
|
|
40
|
-
) {
|
|
41
|
-
super(context)
|
|
42
|
-
this.registeredDapps = registeredDapps
|
|
43
|
-
this.allowedNames = allowedNames
|
|
44
|
-
this.xnsNodeUrl = xnsNodeUrl
|
|
45
|
-
this.xnsNetwork = xnsNetwork
|
|
46
|
-
this.platformLocator = platformLocator
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async start() {
|
|
50
|
-
const registeredDappAccessDappSets = this.registeredDapps.filter(isRegisteredDappAccessDappSet)
|
|
51
|
-
for (const registeredDappSet of registeredDappAccessDappSets) {
|
|
52
|
-
const context = await this.buildRunningDappCache(registeredDappSet, this.allowedNames)
|
|
53
|
-
|
|
54
|
-
for (const dappAccessor of registeredDappSet.dapp.accessors) {
|
|
55
|
-
await this.cacheAccessNode(dappAccessor, context)
|
|
56
|
-
await this.saveRegisteredDappInterfaces(dappAccessor)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private async buildRunningDappCache(registeredDappSet: RegisteredDappSet, allowedNames: string[]) {
|
|
62
|
-
const { context } = await RunningDappCache.findOrCreate(registeredDappSet.dapp, this.context, allowedNames, this.xnsNodeUrl, this.xnsNetwork)
|
|
63
|
-
if (!context) throw new Error('Dapp context not found')
|
|
64
|
-
return context
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private async cacheAccessNode(dappAccessor: RegisteredDappAccess, context: XyOsContext) {
|
|
68
|
-
const accessNodeId = dappAccessor.rootModuleId
|
|
69
|
-
const accessNodeModule = assertEx(await context.root.resolve(accessNodeId), () => 'Access Node Module not found')
|
|
70
|
-
const accessNode = asNodeInstance(accessNodeModule, () => 'Access Node Module is not a NodeInstance', { required: true })
|
|
71
|
-
|
|
72
|
-
RunningDappAccessCache.set(dappAccessor.registeringDappId, accessNode)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
private async saveRegisteredDappInterfaces(registeredDappAccess: RegisteredDappAccess) {
|
|
76
|
-
const archivist = await this.getRegisteredDappInterfacesArchivist()
|
|
77
|
-
|
|
78
|
-
const hash = await PayloadBuilder.dataHash(registeredDappAccess)
|
|
79
|
-
const [existing] = await archivist.get([hash])
|
|
80
|
-
if (existing) return
|
|
81
|
-
|
|
82
|
-
await archivist.insert([registeredDappAccess])
|
|
83
|
-
console.debug('[DEBUG] -', `Registered ${registeredDappAccess.registeringDappId} with ${registeredDappAccess.name} interface`)
|
|
84
|
-
}
|
|
85
|
-
}
|
package/src/access/Queries.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { DivinerInstance } from '@xyo-network/diviner-model'
|
|
2
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
3
|
-
import type { DappAccessRequest, RegisteredDappAccess } from '@xyo-network/os-model'
|
|
4
|
-
import { DappAccessRequestSchema, RegisteredDappAccessSchema } from '@xyo-network/os-model'
|
|
5
|
-
import type { WithSources } from '@xyo-network/payload-model'
|
|
6
|
-
|
|
7
|
-
const noResults: unknown[] = []
|
|
8
|
-
|
|
9
|
-
export const DappAccessRequestQueries = {
|
|
10
|
-
async getAccessRequests(diviner: DivinerInstance) {
|
|
11
|
-
const query = {
|
|
12
|
-
limit: 1,
|
|
13
|
-
schema: PayloadDivinerQuerySchema,
|
|
14
|
-
schemas: [DappAccessRequestSchema],
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const results = (await diviner.divine([query])) as WithSources<DappAccessRequest>[]
|
|
18
|
-
|
|
19
|
-
if (results.length === 0) {
|
|
20
|
-
return noResults as WithSources<DappAccessRequest>[]
|
|
21
|
-
}
|
|
22
|
-
return results
|
|
23
|
-
},
|
|
24
|
-
async getRegisteredInterfaces(diviner: DivinerInstance) {
|
|
25
|
-
const query = {
|
|
26
|
-
limit: 1,
|
|
27
|
-
schema: PayloadDivinerQuerySchema,
|
|
28
|
-
schemas: [RegisteredDappAccessSchema],
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const results = (await diviner.divine([query])) as WithSources<RegisteredDappAccess>[]
|
|
32
|
-
|
|
33
|
-
if (results.length === 0) {
|
|
34
|
-
return noResults as WithSources<RegisteredDappAccess>[]
|
|
35
|
-
}
|
|
36
|
-
return results
|
|
37
|
-
},
|
|
38
|
-
}
|
package/src/access/Resource.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import type {
|
|
3
|
-
DappAccessRequest, RegisteredDappAccess, XyOsContext,
|
|
4
|
-
} from '@xyo-network/os-model'
|
|
5
|
-
import { isDappAccessRequestWithMeta, isRegisteredDappAccess } from '@xyo-network/os-model'
|
|
6
|
-
|
|
7
|
-
import { DappCallerBase } from '../DappCallerBase.ts'
|
|
8
|
-
import type { Listener, ResourceStore } from '../lib/index.ts'
|
|
9
|
-
import { PayloadStore } from '../lib/index.ts'
|
|
10
|
-
import { DappAccessRequestQueries } from './Queries.ts'
|
|
11
|
-
|
|
12
|
-
export type DappAccessRequestViews = 'accessRequests' | 'registeredInterfaces'
|
|
13
|
-
|
|
14
|
-
export class DappAccessRequestResource extends DappCallerBase implements ResourceStore<DappAccessRequestViews> {
|
|
15
|
-
private _accessRequestListener: PayloadStore<DappAccessRequest> | undefined
|
|
16
|
-
private _registeredInterfacesListener: PayloadStore<RegisteredDappAccess> | undefined
|
|
17
|
-
|
|
18
|
-
constructor(context: XyOsContext) {
|
|
19
|
-
super(context)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get accessRequestListener() {
|
|
23
|
-
return assertEx(this._accessRequestListener, () => 'accessRequests note found')
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get registeredInterfacesListener() {
|
|
27
|
-
return assertEx(this._registeredInterfacesListener, () => 'registeredInterfaces note found')
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get subscriptions() {
|
|
31
|
-
return {
|
|
32
|
-
accessRequests: (cb: Listener) => this.accessRequestListener.subscribe(cb),
|
|
33
|
-
registeredInterfaces: (cb: Listener) => this.registeredInterfacesListener.subscribe(cb),
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
get views() {
|
|
38
|
-
return {
|
|
39
|
-
accessRequests: () => this.accessRequestListener.getSnapshot(),
|
|
40
|
-
registeredInterfaces: () => this.registeredInterfacesListener.getSnapshot(),
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
cleanupListeners(): void {
|
|
45
|
-
this.accessRequestListener.cleanupListeners()
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Start the resource
|
|
49
|
-
async start() {
|
|
50
|
-
const archivist = await this.getDappArchivist()
|
|
51
|
-
const diviner = await this.getDappArchivistPayloadDiviner()
|
|
52
|
-
|
|
53
|
-
this._accessRequestListener = await PayloadStore.create<DappAccessRequest>({
|
|
54
|
-
archivist,
|
|
55
|
-
getLatest: async () => await DappAccessRequestQueries.getAccessRequests(diviner),
|
|
56
|
-
idFunction: isDappAccessRequestWithMeta,
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
this._registeredInterfacesListener = await PayloadStore.create<RegisteredDappAccess>({
|
|
60
|
-
archivist,
|
|
61
|
-
getLatest: async () => await DappAccessRequestQueries.getRegisteredInterfaces(diviner),
|
|
62
|
-
idFunction: isRegisteredDappAccess,
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { NodeInstance } from '@xyo-network/node-model'
|
|
2
|
-
import type { DappId } from '@xyo-network/os-model'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A cache for running access node instances
|
|
6
|
-
*/
|
|
7
|
-
export class RunningDappAccessCache {
|
|
8
|
-
private static _cache: { [key: DappId]: NodeInstance } = {}
|
|
9
|
-
|
|
10
|
-
static get(key: DappId) {
|
|
11
|
-
return this._cache[key]
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static has(key?: DappId) {
|
|
15
|
-
return key ? !!this._cache[key] : false
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static set(key: DappId, value: NodeInstance) {
|
|
19
|
-
this._cache[key] = value
|
|
20
|
-
}
|
|
21
|
-
}
|
package/src/access/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './registered-names/index.ts'
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import { asArchivistInstance } from '@xyo-network/archivist-model'
|
|
3
|
-
import type {
|
|
4
|
-
DappAccessRequest, RegisteredDappAccess, XyOsContext,
|
|
5
|
-
} from '@xyo-network/os-model'
|
|
6
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
7
|
-
|
|
8
|
-
import { RunningDappAccessCache } from '../../../RunningAccessDappCache.ts'
|
|
9
|
-
|
|
10
|
-
export class AccessNodeQueries {
|
|
11
|
-
protected xyOsContext: XyOsContext
|
|
12
|
-
private accessRequest: DappAccessRequest
|
|
13
|
-
private registeredDappAccess: RegisteredDappAccess
|
|
14
|
-
|
|
15
|
-
constructor(
|
|
16
|
-
xyOsContext: XyOsContext,
|
|
17
|
-
accessRequest: DappAccessRequest,
|
|
18
|
-
registeredDappAccess: RegisteredDappAccess,
|
|
19
|
-
) {
|
|
20
|
-
this.xyOsContext = xyOsContext
|
|
21
|
-
this.accessRequest = accessRequest
|
|
22
|
-
this.registeredDappAccess = registeredDappAccess
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get nameServiceNamesAccessNode() {
|
|
26
|
-
return assertEx(RunningDappAccessCache.get(this.registeredDappAccess.registeringDappId), () => 'No access node found')
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Refresh the archivist in the dapp
|
|
30
|
-
async refresh() {
|
|
31
|
-
const archivist = await this.getArchivistFromDappNode()
|
|
32
|
-
await archivist.clear()
|
|
33
|
-
await this.run()
|
|
34
|
-
console.log('refreshed')
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Run the access node queries
|
|
38
|
-
async run() {
|
|
39
|
-
const payloads = await this.getPayloadsFromAccessNode()
|
|
40
|
-
await this.insertAccessNodePayloadsIntoDappNodeArchivist(payloads)
|
|
41
|
-
return payloads
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private async getArchivistFromDappNode() {
|
|
45
|
-
const archivistPath = this.accessRequest?.destinationArchivist || 'DappArchivist'
|
|
46
|
-
const mod = assertEx(await this.xyOsContext.root.resolve(archivistPath), () => `Unable to find archivist at ${archivistPath}`)
|
|
47
|
-
return asArchivistInstance(mod, () => `Module at ${archivistPath} is not an archivist`, { required: true })
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
private async getPayloadsFromAccessNode() {
|
|
51
|
-
const archivistFromAccessNode = await this.resolveArchivistFromAccessNode()
|
|
52
|
-
return await archivistFromAccessNode.all()
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private async insertAccessNodePayloadsIntoDappNodeArchivist(payloads: Payload[]) {
|
|
56
|
-
const archivist = await this.getArchivistFromDappNode()
|
|
57
|
-
await archivist.clear()
|
|
58
|
-
await archivist.insert(payloads)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private async resolveArchivistFromAccessNode() {
|
|
62
|
-
const archivist = assertEx(
|
|
63
|
-
await this.nameServiceNamesAccessNode.resolve('PublicXnsArchivist'),
|
|
64
|
-
() => 'Unable to find archivist at PublicXnsArchivist',
|
|
65
|
-
)
|
|
66
|
-
return asArchivistInstance(archivist, () => 'PublicXnsArchivist is not an archivist', { required: true })
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import { asArchivistInstance } from '@xyo-network/archivist-model'
|
|
3
|
-
import { asDivinerInstance } from '@xyo-network/diviner-model'
|
|
4
|
-
import type { XyOsContext } from '@xyo-network/os-model'
|
|
5
|
-
|
|
6
|
-
export const XnsArchivistPayloadDivinerModuleName = 'XnsArchivistPayloadDiviner'
|
|
7
|
-
export const XnsArchivistModuleName = 'XnsArchivist'
|
|
8
|
-
export const XnsRegistrationsArchivistModuleName = 'XnsRegistrationsArchivist'
|
|
9
|
-
|
|
10
|
-
export abstract class AbstractXnsCaller {
|
|
11
|
-
protected context: XyOsContext
|
|
12
|
-
constructor(context: XyOsContext) {
|
|
13
|
-
this.context = context
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Get the XnsArchivist
|
|
18
|
-
*/
|
|
19
|
-
async getXnsArchivist(pathPrefix?: string) {
|
|
20
|
-
const fullyQualifiedPath = pathPrefix ? `${pathPrefix}:${XnsArchivistModuleName}` : XnsArchivistModuleName
|
|
21
|
-
const mod = assertEx(await this.context.root.resolve(fullyQualifiedPath), () => `${fullyQualifiedPath} not found`)
|
|
22
|
-
return asArchivistInstance(mod, () => `${fullyQualifiedPath} is not an archivist`, { required: true })
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get the XnsArchivistPayloadDiviner
|
|
27
|
-
*/
|
|
28
|
-
async getXnsArchivistPayloadDiviner(pathPrefix?: string) {
|
|
29
|
-
const fullyQualifiedPath = pathPrefix ? `${pathPrefix}:${XnsArchivistPayloadDivinerModuleName}` : XnsArchivistPayloadDivinerModuleName
|
|
30
|
-
const mod = assertEx(await this.context.root.resolve(fullyQualifiedPath), () => `${fullyQualifiedPath} not found`)
|
|
31
|
-
return asDivinerInstance(mod, () => `${fullyQualifiedPath} is not an diviner`, { required: true })
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Get the XnsRegistrationsArchivist
|
|
36
|
-
*/
|
|
37
|
-
async getXnsRegistrationsArchivist(pathPrefix?: string) {
|
|
38
|
-
const fullyQualifiedPath = pathPrefix ? `${pathPrefix}:${XnsRegistrationsArchivistModuleName}` : XnsRegistrationsArchivistModuleName
|
|
39
|
-
const mod = assertEx(await this.context.root.resolve(fullyQualifiedPath), () => `${fullyQualifiedPath} not found`)
|
|
40
|
-
return asArchivistInstance(mod, () => `${fullyQualifiedPath} is not an archivist`, { required: true })
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import { isTemporalIndexingDivinerResultIndex } from '@xyo-network/diviner-temporal-indexing-model'
|
|
3
|
-
import type { TemporalIndexRegistrationResults, XyOsContext } from '@xyo-network/os-model'
|
|
4
|
-
import type { WithSources } from '@xyo-network/payload-model'
|
|
5
|
-
import type { Listener } from 'ethers'
|
|
6
|
-
|
|
7
|
-
import type { ResourceStore } from '../../../../../lib/index.ts'
|
|
8
|
-
import { PayloadStore } from '../../../../../lib/index.ts'
|
|
9
|
-
import { AbstractXnsCaller } from './AbstractXnsCaller.ts'
|
|
10
|
-
import { XnsRegistrationsResourceQueries } from './RegistrationsResourceQueries.ts'
|
|
11
|
-
|
|
12
|
-
export type XnsRegistrationsViews = 'allRegistrations'
|
|
13
|
-
|
|
14
|
-
export class XnsRegistrationsResource extends AbstractXnsCaller implements ResourceStore<XnsRegistrationsViews> {
|
|
15
|
-
protected _allRegistrations: PayloadStore<WithSources<TemporalIndexRegistrationResults>> | undefined
|
|
16
|
-
private pathPrefix?: string
|
|
17
|
-
|
|
18
|
-
constructor(
|
|
19
|
-
context: XyOsContext,
|
|
20
|
-
pathPrefix?: string,
|
|
21
|
-
) {
|
|
22
|
-
super(context)
|
|
23
|
-
this.pathPrefix = pathPrefix
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get allRegistrations() {
|
|
27
|
-
return assertEx(this._allRegistrations)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get subscriptions() {
|
|
31
|
-
return { allRegistrations: (cb: Listener) => this.allRegistrations.subscribe(cb) }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get views() {
|
|
35
|
-
return { allRegistrations: () => this.allRegistrations.getSnapshot() }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
cleanupListeners() {
|
|
39
|
-
this.allRegistrations.cleanupListeners()
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async start() {
|
|
43
|
-
const xnsArchivistPayloadDiviner = await this.getXnsArchivistPayloadDiviner(this.pathPrefix)
|
|
44
|
-
const xnsArchivist = await this.getXnsArchivist(this.pathPrefix)
|
|
45
|
-
|
|
46
|
-
this._allRegistrations = await PayloadStore.create<WithSources<TemporalIndexRegistrationResults>>({
|
|
47
|
-
archivist: xnsArchivist,
|
|
48
|
-
getLatest: async () => await XnsRegistrationsResourceQueries.getAllRegistrations(xnsArchivistPayloadDiviner),
|
|
49
|
-
idFunction: isTemporalIndexingDivinerResultIndex,
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
}
|
package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ArchivistInstance } from '@xyo-network/archivist-model'
|
|
2
|
-
import type { DivinerInstance } from '@xyo-network/diviner-model'
|
|
3
|
-
import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
|
|
4
|
-
import { TemporalIndexingDivinerResultIndexSchema } from '@xyo-network/diviner-temporal-indexing-model'
|
|
5
|
-
import type { TemporalIndexRegistrationResults } from '@xyo-network/os-model'
|
|
6
|
-
import type { WithSources, WithStorageMeta } from '@xyo-network/payload-model'
|
|
7
|
-
|
|
8
|
-
export const XnsRegistrationsResourceQueries = {
|
|
9
|
-
getAllRegistrations: async (diviner: DivinerInstance) => {
|
|
10
|
-
const query = {
|
|
11
|
-
limit: 100,
|
|
12
|
-
order: 'desc',
|
|
13
|
-
schema: PayloadDivinerQuerySchema,
|
|
14
|
-
schemas: [TemporalIndexingDivinerResultIndexSchema],
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return (await diviner.divine([query])) as WithSources<TemporalIndexRegistrationResults>[]
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
getRecentRegistrations: async (archivist: ArchivistInstance) => {
|
|
21
|
-
return (await archivist.all()).toReversed() as WithStorageMeta<TemporalIndexRegistrationResults>[]
|
|
22
|
-
},
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './helpers/index.ts'
|
package/src/adapter/Base.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import type { BaseParams } from '@xylabs/base'
|
|
3
|
-
import { BaseEmitter } from '@xylabs/events'
|
|
4
|
-
import { forget } from '@xylabs/forget'
|
|
5
|
-
import type { ArchivistModuleEventData } from '@xyo-network/archivist'
|
|
6
|
-
import { asArchivistInstance } from '@xyo-network/archivist'
|
|
7
|
-
import type { KernelExternal } from '@xyo-network/kernel-model'
|
|
8
|
-
import { asAttachableNodeInstance } from '@xyo-network/node-model'
|
|
9
|
-
import type { NodeAdapter, NodeAdapterBaseEvents } from '@xyo-network/os-model'
|
|
10
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
11
|
-
import { v4 as uuid } from 'uuid'
|
|
12
|
-
|
|
13
|
-
type ModuleEventPayload = {
|
|
14
|
-
event: string
|
|
15
|
-
name: string | undefined
|
|
16
|
-
schema: 'network.xyo.kernel.module.event'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class NodeAdapterBase extends BaseEmitter<BaseParams, NodeAdapterBaseEvents> implements NodeAdapter {
|
|
20
|
-
initialized = false
|
|
21
|
-
|
|
22
|
-
private _id: string = ''
|
|
23
|
-
private driverName: string
|
|
24
|
-
private kernel: KernelExternal
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
kernel: KernelExternal,
|
|
28
|
-
driverName: string,
|
|
29
|
-
) {
|
|
30
|
-
super({})
|
|
31
|
-
this._id = uuid()
|
|
32
|
-
this.kernel = kernel
|
|
33
|
-
this.driverName = driverName
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get id() {
|
|
37
|
-
return assertEx(this._id, () => 'NodeAdapterBase id not initialized')
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async start() {
|
|
41
|
-
try {
|
|
42
|
-
// listen to events inserted into the kernel events archivist
|
|
43
|
-
const moduleAttachedInsertListener = ({ payloads }: ArchivistModuleEventData['inserted']) => {
|
|
44
|
-
const moduleAttachedEvent = this.findModuleEventPayloads(payloads)
|
|
45
|
-
|
|
46
|
-
// loop through the event payloads
|
|
47
|
-
for (const payload of moduleAttachedEvent) {
|
|
48
|
-
// check if the event is for the driver
|
|
49
|
-
if (payload.name === this.driverName) {
|
|
50
|
-
this.validateAndReturnDriver()
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// get the events archivist
|
|
55
|
-
const eventsArchivist = await this.getEventsArchivist()
|
|
56
|
-
|
|
57
|
-
// prepare the listener
|
|
58
|
-
const weakRefInsertListener = new WeakRef(moduleAttachedInsertListener)
|
|
59
|
-
const insertListenerRef = weakRefInsertListener.deref()
|
|
60
|
-
|
|
61
|
-
// attach the listener
|
|
62
|
-
if (insertListenerRef) eventsArchivist.on('inserted', insertListenerRef)
|
|
63
|
-
|
|
64
|
-
// check if the driver is already attached
|
|
65
|
-
const node = this.validateAndReturnDriver()
|
|
66
|
-
if (node) return node
|
|
67
|
-
|
|
68
|
-
// reset the initialized flag
|
|
69
|
-
this.initialized = false
|
|
70
|
-
} catch (error) {
|
|
71
|
-
// call the onError callbacks
|
|
72
|
-
await this.emit('driverError', { error: error as Error })
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private findModuleEventPayloads(payloads: Payload[]) {
|
|
77
|
-
return payloads.filter((payload) => {
|
|
78
|
-
const payloadToTest = payload as ModuleEventPayload
|
|
79
|
-
return payloadToTest.event === 'driverReady' && payloadToTest.schema === 'network.xyo.kernel.module.event'
|
|
80
|
-
}) as ModuleEventPayload[]
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private async getEventsArchivist() {
|
|
84
|
-
const mod = assertEx(await (await this.kernel.getNode()).resolve('KernelNode:ModuleEvents'), () => 'KernelNode:ModuleEvents not found')
|
|
85
|
-
return asArchivistInstance(mod, () => `${mod.id} is not an archivist`, { required: true })
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private validateAndReturnDriver() {
|
|
89
|
-
const mod = this.kernel.initialized[this.driverName]
|
|
90
|
-
if (mod) {
|
|
91
|
-
// confirm expected shape
|
|
92
|
-
const node = asAttachableNodeInstance(mod, () => `${mod.id} is not a node`, { required: true })
|
|
93
|
-
|
|
94
|
-
// set the initialized flag
|
|
95
|
-
this.initialized = true
|
|
96
|
-
|
|
97
|
-
// call the next callbacks
|
|
98
|
-
const emit = async () => await this.emit('driverReady', { node })
|
|
99
|
-
forget(emit())
|
|
100
|
-
|
|
101
|
-
return node
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
package/src/adapter/Network.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { KernelExternal } from '@xyo-network/kernel-model'
|
|
2
|
-
import type { AttachableNodeInstance } from '@xyo-network/node-model'
|
|
3
|
-
import type { NetworkAdapterBase } from '@xyo-network/os-model'
|
|
4
|
-
|
|
5
|
-
import { NodeAdapterBase } from './Base.ts'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Adapts Network Driver to the Operating System
|
|
9
|
-
*/
|
|
10
|
-
export class NetworkAdapter extends NodeAdapterBase implements NetworkAdapterBase {
|
|
11
|
-
_connection: AttachableNodeInstance | undefined
|
|
12
|
-
|
|
13
|
-
constructor(kernel: KernelExternal, driverName: string) {
|
|
14
|
-
super(kernel, driverName)
|
|
15
|
-
this.on('driverReady', ({ node }) => {
|
|
16
|
-
this._connection = node
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get connection() {
|
|
21
|
-
return this._connection
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
get hasConnection() {
|
|
25
|
-
return !!this.connection
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
removeConnection() {
|
|
29
|
-
this._connection = undefined
|
|
30
|
-
}
|
|
31
|
-
}
|
package/src/adapter/Settings.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { KernelExternal } from '@xyo-network/kernel-model'
|
|
2
|
-
import type { AttachableNodeInstance } from '@xyo-network/node-model'
|
|
3
|
-
|
|
4
|
-
import { NodeAdapterBase } from './Base.ts'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Adapts Settings Driver to the Operating System
|
|
8
|
-
*/
|
|
9
|
-
export class SettingsAdapter extends NodeAdapterBase {
|
|
10
|
-
private _settings: AttachableNodeInstance | undefined = undefined
|
|
11
|
-
|
|
12
|
-
constructor(kernel: KernelExternal, driverName: string) {
|
|
13
|
-
super(kernel, driverName)
|
|
14
|
-
this.on('driverReady', ({ node }) => {
|
|
15
|
-
this._settings = node
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get hasSettings() {
|
|
20
|
-
return !!this.settings
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get settings() {
|
|
24
|
-
return this._settings
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
removeSettings() {
|
|
28
|
-
this._settings = undefined
|
|
29
|
-
}
|
|
30
|
-
}
|
package/src/adapter/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { KernelExternal } from '@xyo-network/kernel-model'
|
|
2
|
-
import type { AdapterSetCreator } from '@xyo-network/os-model'
|
|
3
|
-
import { ExposedNodeOuterNodeName, PubSubBridgeNodeNodeName } from '@xyo-network/os-model'
|
|
4
|
-
|
|
5
|
-
import { NetworkAdapter } from '../adapter/index.ts'
|
|
6
|
-
|
|
7
|
-
export const OsPubSubBridgeNetworkAdapters: AdapterSetCreator = (kernel: KernelExternal) => [
|
|
8
|
-
new NetworkAdapter(kernel, PubSubBridgeNodeNodeName),
|
|
9
|
-
new NetworkAdapter(kernel, ExposedNodeOuterNodeName),
|
|
10
|
-
]
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { KernelExternal } from '@xyo-network/kernel-model'
|
|
2
|
-
import type { AdapterSetCreator } from '@xyo-network/os-model'
|
|
3
|
-
import { OsSettingsNodeName } from '@xyo-network/os-model'
|
|
4
|
-
|
|
5
|
-
import { SettingsAdapter } from '../adapter/index.ts'
|
|
6
|
-
|
|
7
|
-
export const OsSettingsAdapters: AdapterSetCreator = (kernel: KernelExternal) => [new SettingsAdapter(kernel, OsSettingsNodeName)]
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { KernelExternal } from '@xyo-network/kernel-model'
|
|
2
|
-
import type { AdapterSetCreator } from '@xyo-network/os-model'
|
|
3
|
-
import { XyoPublicNodeName } from '@xyo-network/os-model'
|
|
4
|
-
|
|
5
|
-
import { NetworkAdapter } from '../adapter/index.ts'
|
|
6
|
-
|
|
7
|
-
export const OsXyoPublicNetworkAdapters: AdapterSetCreator = (kernel: KernelExternal) => [
|
|
8
|
-
new NetworkAdapter(kernel, XyoPublicNodeName),
|
|
9
|
-
]
|
package/src/adapters/index.ts
DELETED