@xyo-network/os-runtime 7.2.1 → 7.3.1

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.
Files changed (249) hide show
  1. package/dist/neutral/Caller.d.ts.map +1 -1
  2. package/dist/neutral/DappCallerBase.d.ts +2 -2
  3. package/dist/neutral/OsCallerBase.d.ts +2 -2
  4. package/dist/neutral/RunningDappCache.d.ts.map +1 -1
  5. package/dist/neutral/XyOs.d.ts +4 -5
  6. package/dist/neutral/XyOs.d.ts.map +1 -1
  7. package/dist/neutral/XyOsBase.d.ts +122 -3
  8. package/dist/neutral/XyOsBase.d.ts.map +1 -1
  9. package/dist/neutral/XyOsDapp.d.ts +3 -3
  10. package/dist/neutral/XyOsDapp.d.ts.map +1 -1
  11. package/dist/neutral/access/Caller.d.ts +1 -1
  12. package/dist/neutral/access/Caller.d.ts.map +1 -1
  13. package/dist/neutral/access/RunningAccessDappCache.d.ts.map +1 -1
  14. package/dist/neutral/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
  15. package/dist/neutral/adapter/Base.d.ts.map +1 -1
  16. package/dist/neutral/classes/lib/DappCreatorParams.d.ts +3 -3
  17. package/dist/neutral/classes/lib/DappCreatorParams.d.ts.map +1 -1
  18. package/dist/neutral/classes/lib/Insertable.d.ts +1 -3
  19. package/dist/neutral/classes/lib/Insertable.d.ts.map +1 -1
  20. package/dist/neutral/classes/settings/CallerBase.d.ts +1 -1
  21. package/dist/neutral/classes/settings/SettingsQueries.d.ts.map +1 -1
  22. package/dist/neutral/dapp/context/creator/Creator.d.ts +1 -1
  23. package/dist/neutral/dapp/context/creator/Creator.d.ts.map +1 -1
  24. package/dist/neutral/dapp/context/creator/createDappContext.d.ts.map +1 -1
  25. package/dist/neutral/event/bus/EventBus.d.ts +1 -1
  26. package/dist/neutral/event/bus/EventBus.d.ts.map +1 -1
  27. package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts +2 -2
  28. package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
  29. package/dist/neutral/helpers/monitor/types.d.ts +2 -2
  30. package/dist/neutral/helpers/monitor/types.d.ts.map +1 -1
  31. package/dist/neutral/index.mjs +42 -36
  32. package/dist/neutral/index.mjs.map +1 -1
  33. package/dist/neutral/lib/Listener.d.ts +1 -1
  34. package/dist/neutral/lib/Listener.d.ts.map +1 -1
  35. package/dist/neutral/loadOsNode.d.ts.map +1 -1
  36. package/dist/neutral/profileModuleEvents.d.ts +1 -3
  37. package/dist/neutral/profileModuleEvents.d.ts.map +1 -1
  38. package/dist/neutral/registration/DappRegistrationService.d.ts +3 -3
  39. package/dist/neutral/registration/DappRegistrationService.d.ts.map +1 -1
  40. package/dist/neutral/registration/DappRegistry.d.ts.map +1 -1
  41. package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts +1 -1
  42. package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -1
  43. package/dist/neutral/scripts/xyos/lib/headless.d.ts.map +1 -1
  44. package/dist/neutral/signer/Signers.d.ts.map +1 -1
  45. package/dist/neutral/stack/Manager.d.ts +2 -6
  46. package/dist/neutral/stack/Manager.d.ts.map +1 -1
  47. package/dist/neutral/system/ManageSystemDapps.d.ts +2 -2
  48. package/dist/neutral/system/ManageSystemDapps.d.ts.map +1 -1
  49. package/dist/node/Caller.d.ts.map +1 -1
  50. package/dist/node/DappCallerBase.d.ts +2 -2
  51. package/dist/node/OsCallerBase.d.ts +2 -2
  52. package/dist/node/RunningDappCache.d.ts.map +1 -1
  53. package/dist/node/XyOs.d.ts +4 -5
  54. package/dist/node/XyOs.d.ts.map +1 -1
  55. package/dist/node/XyOsBase.d.ts +122 -3
  56. package/dist/node/XyOsBase.d.ts.map +1 -1
  57. package/dist/node/XyOsDapp.d.ts +3 -3
  58. package/dist/node/XyOsDapp.d.ts.map +1 -1
  59. package/dist/node/access/Caller.d.ts +1 -1
  60. package/dist/node/access/Caller.d.ts.map +1 -1
  61. package/dist/node/access/RunningAccessDappCache.d.ts.map +1 -1
  62. package/dist/node/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
  63. package/dist/node/adapter/Base.d.ts.map +1 -1
  64. package/dist/node/classes/lib/DappCreatorParams.d.ts +3 -3
  65. package/dist/node/classes/lib/DappCreatorParams.d.ts.map +1 -1
  66. package/dist/node/classes/lib/Insertable.d.ts +1 -3
  67. package/dist/node/classes/lib/Insertable.d.ts.map +1 -1
  68. package/dist/node/classes/settings/CallerBase.d.ts +1 -1
  69. package/dist/node/classes/settings/SettingsQueries.d.ts.map +1 -1
  70. package/dist/node/dapp/context/creator/Creator.d.ts +1 -1
  71. package/dist/node/dapp/context/creator/Creator.d.ts.map +1 -1
  72. package/dist/node/dapp/context/creator/createDappContext.d.ts.map +1 -1
  73. package/dist/node/event/bus/EventBus.d.ts +1 -1
  74. package/dist/node/event/bus/EventBus.d.ts.map +1 -1
  75. package/dist/node/helpers/monitor/XyOsMonitor.d.ts +2 -2
  76. package/dist/node/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
  77. package/dist/node/helpers/monitor/types.d.ts +2 -2
  78. package/dist/node/helpers/monitor/types.d.ts.map +1 -1
  79. package/dist/node/index.mjs +42 -36
  80. package/dist/node/index.mjs.map +1 -1
  81. package/dist/node/lib/Listener.d.ts +1 -1
  82. package/dist/node/lib/Listener.d.ts.map +1 -1
  83. package/dist/node/loadOsNode.d.ts.map +1 -1
  84. package/dist/node/profileModuleEvents.d.ts +1 -3
  85. package/dist/node/profileModuleEvents.d.ts.map +1 -1
  86. package/dist/node/registration/DappRegistrationService.d.ts +3 -3
  87. package/dist/node/registration/DappRegistrationService.d.ts.map +1 -1
  88. package/dist/node/registration/DappRegistry.d.ts.map +1 -1
  89. package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts +1 -1
  90. package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -1
  91. package/dist/node/scripts/xyos/index.mjs +27 -24
  92. package/dist/node/scripts/xyos/index.mjs.map +1 -1
  93. package/dist/node/scripts/xyos/lib/headless.d.ts.map +1 -1
  94. package/dist/node/signer/Signers.d.ts.map +1 -1
  95. package/dist/node/stack/Manager.d.ts +2 -6
  96. package/dist/node/stack/Manager.d.ts.map +1 -1
  97. package/dist/node/system/ManageSystemDapps.d.ts +2 -2
  98. package/dist/node/system/ManageSystemDapps.d.ts.map +1 -1
  99. package/package.json +134 -49
  100. package/dist/neutral/signer/Signer.spec.d.ts +0 -2
  101. package/dist/neutral/signer/Signer.spec.d.ts.map +0 -1
  102. package/dist/neutral/spec/boot.spec.d.ts +0 -2
  103. package/dist/neutral/spec/boot.spec.d.ts.map +0 -1
  104. package/dist/node/signer/Signer.spec.d.ts +0 -2
  105. package/dist/node/signer/Signer.spec.d.ts.map +0 -1
  106. package/dist/node/spec/boot.spec.d.ts +0 -2
  107. package/dist/node/spec/boot.spec.d.ts.map +0 -1
  108. package/src/Caller.ts +0 -200
  109. package/src/DappCallerBase.ts +0 -55
  110. package/src/DefaultsQueries.ts +0 -27
  111. package/src/OsCallerBase.ts +0 -59
  112. package/src/PubSubBridgeCaller.ts +0 -33
  113. package/src/RunningDappCache.ts +0 -58
  114. package/src/XyOs.ts +0 -166
  115. package/src/XyOsBase.ts +0 -135
  116. package/src/XyOsDapp.ts +0 -106
  117. package/src/access/Caller.ts +0 -85
  118. package/src/access/Queries.ts +0 -38
  119. package/src/access/Resource.ts +0 -65
  120. package/src/access/RunningAccessDappCache.ts +0 -21
  121. package/src/access/index.ts +0 -4
  122. package/src/access/interfaces/index.ts +0 -1
  123. package/src/access/interfaces/registered-names/helpers/AccessNodeQueries.ts +0 -68
  124. package/src/access/interfaces/registered-names/helpers/index.ts +0 -2
  125. package/src/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.ts +0 -42
  126. package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResource.ts +0 -52
  127. package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.ts +0 -23
  128. package/src/access/interfaces/registered-names/helpers/resource/index.ts +0 -3
  129. package/src/access/interfaces/registered-names/index.ts +0 -1
  130. package/src/adapter/Base.ts +0 -106
  131. package/src/adapter/Network.ts +0 -31
  132. package/src/adapter/Settings.ts +0 -30
  133. package/src/adapter/index.ts +0 -2
  134. package/src/adapters/OsPubSubBridgeNetwork.ts +0 -10
  135. package/src/adapters/OsSettings.ts +0 -7
  136. package/src/adapters/OsXyoPublicNetwork.ts +0 -9
  137. package/src/adapters/index.ts +0 -3
  138. package/src/classes/dapp/DefaultsResource.ts +0 -67
  139. package/src/classes/dapp/index.ts +0 -1
  140. package/src/classes/index.ts +0 -4
  141. package/src/classes/lib/DappCreatorParams.ts +0 -18
  142. package/src/classes/lib/Insertable.ts +0 -10
  143. package/src/classes/lib/index.ts +0 -2
  144. package/src/classes/menu/Caller.ts +0 -76
  145. package/src/classes/menu/Queries.ts +0 -60
  146. package/src/classes/menu/Resource.ts +0 -105
  147. package/src/classes/menu/index.ts +0 -2
  148. package/src/classes/settings/Caller.ts +0 -78
  149. package/src/classes/settings/CallerBase.ts +0 -27
  150. package/src/classes/settings/Resource.ts +0 -81
  151. package/src/classes/settings/SettingsQueries.ts +0 -56
  152. package/src/classes/settings/badge/Caller.ts +0 -30
  153. package/src/classes/settings/badge/Queries.ts +0 -19
  154. package/src/classes/settings/badge/Resource.ts +0 -50
  155. package/src/classes/settings/badge/index.ts +0 -2
  156. package/src/classes/settings/index.ts +0 -5
  157. package/src/dapp/context/creator/Creator.ts +0 -122
  158. package/src/dapp/context/creator/DefaultPayloads/DappAccessPayloads.ts +0 -20
  159. package/src/dapp/context/creator/DefaultPayloads/DefaultPayloads.ts +0 -40
  160. package/src/dapp/context/creator/DefaultPayloads/NodeInfoPayload.ts +0 -33
  161. package/src/dapp/context/creator/DefaultPayloads/index.ts +0 -1
  162. package/src/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.ts +0 -59
  163. package/src/dapp/context/creator/ExternalModulePermissions/index.ts +0 -1
  164. package/src/dapp/context/creator/createDappContext.ts +0 -61
  165. package/src/dapp/context/creator/index.ts +0 -3
  166. package/src/dapp/context/index.ts +0 -1
  167. package/src/dapp/index.ts +0 -1
  168. package/src/event/bus/Connection.ts +0 -31
  169. package/src/event/bus/EventBus.ts +0 -160
  170. package/src/event/bus/PubSubConnection.ts +0 -28
  171. package/src/event/bus/index.ts +0 -3
  172. package/src/event/connections/DappAccessRequest.ts +0 -11
  173. package/src/event/connections/DappsReady.ts +0 -9
  174. package/src/event/connections/ExposeDappRequest.ts +0 -11
  175. package/src/event/connections/OsPubSubNetworkReady.ts +0 -12
  176. package/src/event/connections/OsSettingsReady.ts +0 -12
  177. package/src/event/connections/OsXyoPublicReady.ts +0 -12
  178. package/src/event/connections/index.ts +0 -6
  179. package/src/event/index.ts +0 -2
  180. package/src/helpers/index.ts +0 -1
  181. package/src/helpers/monitor/XyOsMonitor.ts +0 -52
  182. package/src/helpers/monitor/index.ts +0 -2
  183. package/src/helpers/monitor/types.ts +0 -8
  184. package/src/index.ts +0 -29
  185. package/src/initializer/DappInitializer.ts +0 -57
  186. package/src/initializer/index.ts +0 -1
  187. package/src/intent/Caller.ts +0 -74
  188. package/src/intent/Resource.ts +0 -66
  189. package/src/intent/index.ts +0 -2
  190. package/src/lib/ExternalStore.ts +0 -7
  191. package/src/lib/Listener.ts +0 -1
  192. package/src/lib/ModuleAccountPaths.ts +0 -23
  193. package/src/lib/ModuleNames.ts +0 -3
  194. package/src/lib/NameTransforms.ts +0 -34
  195. package/src/lib/PayloadStore.ts +0 -105
  196. package/src/lib/ResourceStores.ts +0 -7
  197. package/src/lib/index.ts +0 -11
  198. package/src/lib/initializeXns.ts +0 -16
  199. package/src/lib/isEqual.ts +0 -42
  200. package/src/lib/isPayload.ts +0 -24
  201. package/src/lib/tokenPlacesSplit.ts +0 -17
  202. package/src/loadOsNode.ts +0 -44
  203. package/src/manifest/index.ts +0 -2
  204. package/src/manifest/manifestReplacementTokens.ts +0 -6
  205. package/src/manifest/os-node.manifest.json +0 -132
  206. package/src/manifests/dapp-window.manifest.json +0 -36
  207. package/src/manifests/index.ts +0 -1
  208. package/src/models/access/ValidDappAccessInterfaces.ts +0 -6
  209. package/src/models/access/index.ts +0 -1
  210. package/src/models/index.ts +0 -1
  211. package/src/profileModuleEvents.ts +0 -43
  212. package/src/registration/DappRegistrationService.ts +0 -180
  213. package/src/registration/DappRegistry.ts +0 -129
  214. package/src/registration/ValidateDappAccessDiviner/Config.ts +0 -24
  215. package/src/registration/ValidateDappAccessDiviner/Diviner.ts +0 -133
  216. package/src/registration/ValidateDappAccessDiviner/index.ts +0 -2
  217. package/src/registration/index.ts +0 -2
  218. package/src/scripts/xyos/command/config.ts +0 -19
  219. package/src/scripts/xyos/command/create.ts +0 -22
  220. package/src/scripts/xyos/command/index.ts +0 -7
  221. package/src/scripts/xyos/command/manifest.ts +0 -19
  222. package/src/scripts/xyos/command/start.ts +0 -35
  223. package/src/scripts/xyos/index.ts +0 -31
  224. package/src/scripts/xyos/lib/createFromTemplate.ts +0 -11
  225. package/src/scripts/xyos/lib/headless.ts +0 -68
  226. package/src/scripts/xyos/lib/index.ts +0 -2
  227. package/src/signer/Signer.spec.ts +0 -65
  228. package/src/signer/Signers.ts +0 -74
  229. package/src/signer/index.ts +0 -1
  230. package/src/spec/boot.spec.ts +0 -89
  231. package/src/stack/Base.ts +0 -165
  232. package/src/stack/Manager.ts +0 -51
  233. package/src/stack/Map.ts +0 -22
  234. package/src/stack/OsPubSubNetworkStack.ts +0 -70
  235. package/src/stack/OsSettingsStack.ts +0 -24
  236. package/src/stack/XyoPublicNetworkStack.ts +0 -32
  237. package/src/stack/index.ts +0 -6
  238. package/src/system/ManageSystemDapps.ts +0 -148
  239. package/src/system/Queries.ts +0 -69
  240. package/src/system/index.ts +0 -1
  241. package/src/types/global.d.ts +0 -9
  242. package/src/types/images.d.ts +0 -5
  243. package/src/utils/buildWalletSeedPhrasePayload.ts +0 -51
  244. package/src/utils/getApiDomain.ts +0 -14
  245. package/src/utils/index.ts +0 -3
  246. package/src/utils/renameObjKey.ts +0 -22
  247. package/src/wallet/DappSeedPhraseRepository.ts +0 -99
  248. package/src/wallet/SeedPhraseRepository.ts +0 -31
  249. package/src/wallet/index.ts +0 -2
@@ -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
- }
@@ -1,4 +0,0 @@
1
- export * from './Caller.ts'
2
- export * from './interfaces/index.ts'
3
- export * from './Queries.ts'
4
- export * from './Resource.ts'
@@ -1 +0,0 @@
1
- export * from './registered-names/index.ts'
@@ -1,68 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
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,2 +0,0 @@
1
- export * from './AccessNodeQueries.ts'
2
- export * from './resource/index.ts'
@@ -1,42 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
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/sdk-js'
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
- }
@@ -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,3 +0,0 @@
1
- export * from './AbstractXnsCaller.ts'
2
- export * from './RegistrationsResource.ts'
3
- export * from './RegistrationsResourceQueries.ts'
@@ -1 +0,0 @@
1
- export * from './helpers/index.ts'
@@ -1,106 +0,0 @@
1
- import type { BaseParams } from '@xylabs/sdk-js'
2
- import {
3
- assertEx, BaseEmitter, forget,
4
- } from '@xylabs/sdk-js'
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 {
11
- asSchema, type Payload, type Schema,
12
- } from '@xyo-network/payload-model'
13
- import { v4 as uuid } from 'uuid'
14
-
15
- type ModuleEventPayload = {
16
- event: string
17
- name: string | undefined
18
- schema: Schema<'network.xyo.kernel.module.event'>
19
- }
20
-
21
- export class NodeAdapterBase extends BaseEmitter<BaseParams, NodeAdapterBaseEvents> implements NodeAdapter {
22
- initialized = false
23
-
24
- private _id: string = ''
25
- private driverName: string
26
- private kernel: KernelExternal
27
-
28
- constructor(
29
- kernel: KernelExternal,
30
- driverName: string,
31
- ) {
32
- super({})
33
- this._id = uuid()
34
- this.kernel = kernel
35
- this.driverName = driverName
36
- }
37
-
38
- get id() {
39
- return assertEx(this._id, () => 'NodeAdapterBase id not initialized')
40
- }
41
-
42
- async start() {
43
- try {
44
- // listen to events inserted into the kernel events archivist
45
- const moduleAttachedInsertListener = ({ payloads }: ArchivistModuleEventData['inserted']) => {
46
- const moduleAttachedEvent = this.findModuleEventPayloads(payloads)
47
-
48
- // loop through the event payloads
49
- for (const payload of moduleAttachedEvent) {
50
- // check if the event is for the driver
51
- if (payload.name === this.driverName) {
52
- this.validateAndReturnDriver()
53
- }
54
- }
55
- }
56
- // get the events archivist
57
- const eventsArchivist = await this.getEventsArchivist()
58
-
59
- // prepare the listener
60
- const weakRefInsertListener = new WeakRef(moduleAttachedInsertListener)
61
- const insertListenerRef = weakRefInsertListener.deref()
62
-
63
- // attach the listener
64
- if (insertListenerRef) eventsArchivist.on('inserted', insertListenerRef)
65
-
66
- // check if the driver is already attached
67
- const node = this.validateAndReturnDriver()
68
- if (node) return node
69
-
70
- // reset the initialized flag
71
- this.initialized = false
72
- } catch (error) {
73
- // call the onError callbacks
74
- await this.emit('driverError', { error: error as Error })
75
- }
76
- }
77
-
78
- private findModuleEventPayloads(payloads: Payload[]) {
79
- return payloads.filter((payload): payload is ModuleEventPayload => {
80
- const payloadToTest = payload as ModuleEventPayload
81
- return payloadToTest.event === 'driverReady' && payloadToTest.schema === asSchema('network.xyo.kernel.module.event', true)
82
- })
83
- }
84
-
85
- private async getEventsArchivist() {
86
- const mod = assertEx(await (await this.kernel.getNode()).resolve('KernelNode:ModuleEvents'), () => 'KernelNode:ModuleEvents not found')
87
- return asArchivistInstance(mod, () => `${mod.id} is not an archivist`, { required: true })
88
- }
89
-
90
- private validateAndReturnDriver() {
91
- const mod = this.kernel.initialized[this.driverName]
92
- if (mod) {
93
- // confirm expected shape
94
- const node = asAttachableNodeInstance(mod, () => `${mod.id} is not a node`, { required: true })
95
-
96
- // set the initialized flag
97
- this.initialized = true
98
-
99
- // call the next callbacks
100
- const emit = async () => await this.emit('driverReady', { node })
101
- forget(emit())
102
-
103
- return node
104
- }
105
- }
106
- }
@@ -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
- }
@@ -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
- }
@@ -1,2 +0,0 @@
1
- export * from './Network.ts'
2
- export * from './Settings.ts'
@@ -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
- ]
@@ -1,3 +0,0 @@
1
- export * from './OsPubSubBridgeNetwork.ts'
2
- export * from './OsSettings.ts'
3
- export * from './OsXyoPublicNetwork.ts'
@@ -1,67 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
2
- import type {
3
- DappInjectableParams, NodeOsInfo, XyOsContext,
4
- } from '@xyo-network/os-model'
5
- import { isDappInjectableParams, isNodeOsInfo } from '@xyo-network/os-model'
6
-
7
- import { DappCallerBase } from '../../DappCallerBase.ts'
8
- import { DappDefaultsResourceQueries } from '../../DefaultsQueries.ts'
9
- import type { Listener, ResourceStore } from '../../lib/index.ts'
10
- import { PayloadStore } from '../../lib/index.ts'
11
-
12
- export type DappDefaultsResourceViews = 'nodeOsInfo' | 'dappInjectableParamsFromRoute'
13
-
14
- /**
15
- * A resource for interacting with Dapp Defaults
16
- */
17
- export class DappDefaultsResource extends DappCallerBase implements ResourceStore<DappDefaultsResourceViews> {
18
- private _dappInjectableParamsFromRouteListener: PayloadStore<DappInjectableParams> | undefined
19
- private _nodeOsInfoListener: PayloadStore<NodeOsInfo> | undefined
20
-
21
- constructor(context: XyOsContext) {
22
- super(context)
23
- }
24
-
25
- get dappInjectableParamsFromRouteListener() {
26
- return assertEx(this._dappInjectableParamsFromRouteListener, () => 'DappInjectableParams not found')
27
- }
28
-
29
- get nodeOsInfoListener() {
30
- return assertEx(this._nodeOsInfoListener, () => 'NodeOsInfo not found')
31
- }
32
-
33
- get subscriptions() {
34
- return {
35
- dappInjectableParamsFromRoute: (cb: Listener) => this.dappInjectableParamsFromRouteListener.subscribe(cb),
36
- nodeOsInfo: (cb: Listener) => this.nodeOsInfoListener.subscribe(cb),
37
- }
38
- }
39
-
40
- get views() {
41
- return {
42
- dappInjectableParamsFromRoute: () => this.dappInjectableParamsFromRouteListener.getSnapshot(),
43
- nodeOsInfo: () => this.nodeOsInfoListener.getSnapshot(),
44
- }
45
- }
46
-
47
- cleanupListeners() {
48
- this.nodeOsInfoListener.cleanupListeners()
49
- }
50
-
51
- async start() {
52
- const archivist = await this.getDappArchivist()
53
- const diviner = await this.getDappArchivistPayloadDiviner()
54
-
55
- this._nodeOsInfoListener = await PayloadStore.create<NodeOsInfo>({
56
- archivist,
57
- getLatest: async () => await DappDefaultsResourceQueries.getNodeOsInfo(diviner),
58
- idFunction: isNodeOsInfo,
59
- })
60
-
61
- this._dappInjectableParamsFromRouteListener = await PayloadStore.create<DappInjectableParams>({
62
- archivist,
63
- getLatest: async () => await DappDefaultsResourceQueries.getDappInjectableParamsFromRoute(diviner),
64
- idFunction: isDappInjectableParams,
65
- })
66
- }
67
- }
@@ -1 +0,0 @@
1
- export * from './DefaultsResource.ts'
@@ -1,4 +0,0 @@
1
- export * from './dapp/index.ts'
2
- export * from './lib/index.ts'
3
- export * from './menu/index.ts'
4
- export * from './settings/index.ts'
@@ -1,18 +0,0 @@
1
- import type { ModuleManifest } from '@xyo-network/manifest'
2
- import type { ModuleFactoryLocatorInstance } from '@xyo-network/module-model'
3
- import type {
4
- DappName, DappPackageManifestPayload, XyOsContext,
5
- } from '@xyo-network/os-model'
6
- import type { WalletInstance } from '@xyo-network/wallet-model'
7
-
8
- export type DappNodesCreatorParams = {
9
- config: {
10
- dappName: DappName
11
- payload: DappPackageManifestPayload
12
- privateChildren?: ModuleManifest[]
13
- publicChildren?: ModuleManifest[]
14
- }
15
- context: XyOsContext
16
- locator?: ModuleFactoryLocatorInstance
17
- wallet: WalletInstance
18
- }
@@ -1,10 +0,0 @@
1
- import type { DappName, XyOsContext } from '@xyo-network/os-model'
2
- import type { Payload } from '@xyo-network/payload-model'
3
-
4
- export interface InsertableConstructor { new (_xyOs: XyOsContext, dappName: DappName): DefaultPayloadsInsertable }
5
-
6
- type InsertableConstructorParams = ConstructorParameters<InsertableConstructor>
7
-
8
- export interface DefaultPayloadsInsertable { payloads(): Promise<Payload[]> }
9
-
10
- export const createInsertable = (insertable: InsertableConstructor, ...params: InsertableConstructorParams) => new insertable(...params)
@@ -1,2 +0,0 @@
1
- export * from './DappCreatorParams.ts'
2
- export * from './Insertable.ts'
@@ -1,76 +0,0 @@
1
- import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
2
- import type {
3
- DappInjectableParams,
4
- DappNavItemSelection,
5
- XyOsContext,
6
- } from '@xyo-network/os-model'
7
- import {
8
- DappInjectableParamsSchema,
9
- DappNavItemSelectionSchema,
10
- } from '@xyo-network/os-model'
11
- import { PayloadBuilder } from '@xyo-network/payload-builder'
12
- import type { Payload } from '@xyo-network/payload-model'
13
-
14
- import { DappCaller } from '../../Caller.ts'
15
-
16
- export class DappMenuCaller extends DappCaller {
17
- constructor(context: XyOsContext) {
18
- super(context)
19
- }
20
-
21
- /**
22
- * Add new Payloads to the dappArchivist if they haven't already
23
- * @param payloads
24
- */
25
- async add(payloads: Payload[], force = false) {
26
- const dappArchivist = await this.getDappArchivist()
27
-
28
- for (const payload of payloads) {
29
- const hash = await PayloadBuilder.dataHash(payload)
30
- const [existing] = await dappArchivist.get([hash])
31
- if (!existing || force) {
32
- await dappArchivist.insert(payloads)
33
- }
34
- }
35
- }
36
-
37
- async currentNavSelection(): Promise<DappNavItemSelection[] | undefined> {
38
- const diviner = await this.getDappArchivistPayloadDiviner()
39
- const query = {
40
- limit: 1,
41
- order: 'desc',
42
- schema: PayloadDivinerQuerySchema,
43
- schemas: [DappNavItemSelectionSchema],
44
- }
45
-
46
- return (await diviner.divine([query])) as DappNavItemSelection[]
47
- }
48
-
49
- /*
50
- * Indicate to the system that a nav item was selected
51
- *
52
- * @param {string} path
53
- * @params {string} injectableParamsPath
54
- * @returns Promise
55
- */
56
- async makeNavItemSelection(path: string, injectableParamsPath?: string): Promise<void> {
57
- const dappArchivist = await this.getDappArchivist()
58
- const payload: DappNavItemSelection = {
59
- path,
60
- schema: DappNavItemSelectionSchema,
61
- timestamp: Date.now(),
62
- }
63
- await dappArchivist.insert([payload])
64
-
65
- if (injectableParamsPath) {
66
- const injectableParams: DappInjectableParams = {
67
- params: {},
68
- path: injectableParamsPath,
69
- schema: DappInjectableParamsSchema,
70
- source: 'route',
71
- timestamp: Date.now(),
72
- }
73
- await dappArchivist.insert([injectableParams])
74
- }
75
- }
76
- }