@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.
Files changed (303) hide show
  1. package/dist/neutral/Caller.d.ts +18 -20
  2. package/dist/neutral/Caller.d.ts.map +1 -1
  3. package/dist/neutral/DappCallerBase.d.ts +2 -2
  4. package/dist/neutral/DappCallerBase.d.ts.map +1 -1
  5. package/dist/neutral/OsCallerBase.d.ts +2 -2
  6. package/dist/neutral/PubSubBridgeCaller.d.ts +1 -1
  7. package/dist/neutral/PubSubBridgeCaller.d.ts.map +1 -1
  8. package/dist/neutral/RunningDappCache.d.ts.map +1 -1
  9. package/dist/neutral/XyOs.d.ts +5 -6
  10. package/dist/neutral/XyOs.d.ts.map +1 -1
  11. package/dist/neutral/XyOsBase.d.ts +124 -7
  12. package/dist/neutral/XyOsBase.d.ts.map +1 -1
  13. package/dist/neutral/XyOsDapp.d.ts +3 -3
  14. package/dist/neutral/XyOsDapp.d.ts.map +1 -1
  15. package/dist/neutral/access/Caller.d.ts +2 -2
  16. package/dist/neutral/access/Caller.d.ts.map +1 -1
  17. package/dist/neutral/access/RunningAccessDappCache.d.ts.map +1 -1
  18. package/dist/neutral/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
  19. package/dist/neutral/adapter/Base.d.ts +2 -2
  20. package/dist/neutral/adapter/Base.d.ts.map +1 -1
  21. package/dist/neutral/classes/lib/DappCreatorParams.d.ts +3 -3
  22. package/dist/neutral/classes/lib/DappCreatorParams.d.ts.map +1 -1
  23. package/dist/neutral/classes/lib/Insertable.d.ts +1 -3
  24. package/dist/neutral/classes/lib/Insertable.d.ts.map +1 -1
  25. package/dist/neutral/classes/menu/Caller.d.ts +1 -2
  26. package/dist/neutral/classes/menu/Caller.d.ts.map +1 -1
  27. package/dist/neutral/classes/settings/Caller.d.ts +2 -2
  28. package/dist/neutral/classes/settings/CallerBase.d.ts +1 -1
  29. package/dist/neutral/classes/settings/SettingsQueries.d.ts.map +1 -1
  30. package/dist/neutral/classes/settings/badge/Caller.d.ts +2 -2
  31. package/dist/neutral/classes/settings/badge/Resource.d.ts +1 -1
  32. package/dist/neutral/classes/settings/badge/Resource.d.ts.map +1 -1
  33. package/dist/neutral/dapp/context/creator/Creator.d.ts +1 -1
  34. package/dist/neutral/dapp/context/creator/Creator.d.ts.map +1 -1
  35. package/dist/neutral/dapp/context/creator/createDappContext.d.ts.map +1 -1
  36. package/dist/neutral/event/bus/Connection.d.ts +3 -4
  37. package/dist/neutral/event/bus/Connection.d.ts.map +1 -1
  38. package/dist/neutral/event/bus/EventBus.d.ts +1 -1
  39. package/dist/neutral/event/bus/EventBus.d.ts.map +1 -1
  40. package/dist/neutral/event/bus/PubSubConnection.d.ts +1 -1
  41. package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts +2 -2
  42. package/dist/neutral/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
  43. package/dist/neutral/helpers/monitor/types.d.ts +3 -3
  44. package/dist/neutral/helpers/monitor/types.d.ts.map +1 -1
  45. package/dist/neutral/index.mjs +1042 -694
  46. package/dist/neutral/index.mjs.map +1 -1
  47. package/dist/neutral/intent/Caller.d.ts +5 -5
  48. package/dist/neutral/lib/Listener.d.ts +1 -1
  49. package/dist/neutral/lib/Listener.d.ts.map +1 -1
  50. package/dist/neutral/lib/PayloadStore.d.ts +1 -2
  51. package/dist/neutral/lib/PayloadStore.d.ts.map +1 -1
  52. package/dist/neutral/lib/isPayload.d.ts +1 -1
  53. package/dist/neutral/loadOsNode.d.ts.map +1 -1
  54. package/dist/neutral/profileModuleEvents.d.ts +2 -4
  55. package/dist/neutral/profileModuleEvents.d.ts.map +1 -1
  56. package/dist/neutral/registration/DappRegistrationService.d.ts +3 -3
  57. package/dist/neutral/registration/DappRegistrationService.d.ts.map +1 -1
  58. package/dist/neutral/registration/DappRegistry.d.ts +4 -6
  59. package/dist/neutral/registration/DappRegistry.d.ts.map +1 -1
  60. package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts +7 -3
  61. package/dist/neutral/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -1
  62. package/dist/neutral/registration/ValidateDappAccessDiviner/Diviner.d.ts +3 -1
  63. package/dist/neutral/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +1 -1
  64. package/dist/neutral/scripts/xyos/lib/headless.d.ts.map +1 -1
  65. package/dist/neutral/signer/Signers.d.ts.map +1 -1
  66. package/dist/neutral/stack/Base.d.ts +2 -2
  67. package/dist/neutral/stack/Base.d.ts.map +1 -1
  68. package/dist/neutral/stack/Manager.d.ts +2 -6
  69. package/dist/neutral/stack/Manager.d.ts.map +1 -1
  70. package/dist/neutral/system/ManageSystemDapps.d.ts +3 -3
  71. package/dist/neutral/system/ManageSystemDapps.d.ts.map +1 -1
  72. package/dist/neutral/utils/buildWalletSeedPhrasePayload.d.ts +1 -1
  73. package/dist/neutral/utils/buildWalletSeedPhrasePayload.d.ts.map +1 -1
  74. package/dist/neutral/wallet/SeedPhraseRepository.d.ts +3 -4
  75. package/dist/neutral/wallet/SeedPhraseRepository.d.ts.map +1 -1
  76. package/dist/node/Caller.d.ts +18 -20
  77. package/dist/node/Caller.d.ts.map +1 -1
  78. package/dist/node/DappCallerBase.d.ts +2 -2
  79. package/dist/node/DappCallerBase.d.ts.map +1 -1
  80. package/dist/node/OsCallerBase.d.ts +2 -2
  81. package/dist/node/PubSubBridgeCaller.d.ts +1 -1
  82. package/dist/node/PubSubBridgeCaller.d.ts.map +1 -1
  83. package/dist/node/RunningDappCache.d.ts.map +1 -1
  84. package/dist/node/XyOs.d.ts +5 -6
  85. package/dist/node/XyOs.d.ts.map +1 -1
  86. package/dist/node/XyOsBase.d.ts +124 -7
  87. package/dist/node/XyOsBase.d.ts.map +1 -1
  88. package/dist/node/XyOsDapp.d.ts +3 -3
  89. package/dist/node/XyOsDapp.d.ts.map +1 -1
  90. package/dist/node/access/Caller.d.ts +2 -2
  91. package/dist/node/access/Caller.d.ts.map +1 -1
  92. package/dist/node/access/RunningAccessDappCache.d.ts.map +1 -1
  93. package/dist/node/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.d.ts +1 -1
  94. package/dist/node/adapter/Base.d.ts +2 -2
  95. package/dist/node/adapter/Base.d.ts.map +1 -1
  96. package/dist/node/classes/lib/DappCreatorParams.d.ts +3 -3
  97. package/dist/node/classes/lib/DappCreatorParams.d.ts.map +1 -1
  98. package/dist/node/classes/lib/Insertable.d.ts +1 -3
  99. package/dist/node/classes/lib/Insertable.d.ts.map +1 -1
  100. package/dist/node/classes/menu/Caller.d.ts +1 -2
  101. package/dist/node/classes/menu/Caller.d.ts.map +1 -1
  102. package/dist/node/classes/settings/Caller.d.ts +2 -2
  103. package/dist/node/classes/settings/CallerBase.d.ts +1 -1
  104. package/dist/node/classes/settings/SettingsQueries.d.ts.map +1 -1
  105. package/dist/node/classes/settings/badge/Caller.d.ts +2 -2
  106. package/dist/node/classes/settings/badge/Resource.d.ts +1 -1
  107. package/dist/node/classes/settings/badge/Resource.d.ts.map +1 -1
  108. package/dist/node/dapp/context/creator/Creator.d.ts +1 -1
  109. package/dist/node/dapp/context/creator/Creator.d.ts.map +1 -1
  110. package/dist/node/dapp/context/creator/createDappContext.d.ts.map +1 -1
  111. package/dist/node/event/bus/Connection.d.ts +3 -4
  112. package/dist/node/event/bus/Connection.d.ts.map +1 -1
  113. package/dist/node/event/bus/EventBus.d.ts +1 -1
  114. package/dist/node/event/bus/EventBus.d.ts.map +1 -1
  115. package/dist/node/event/bus/PubSubConnection.d.ts +1 -1
  116. package/dist/node/helpers/monitor/XyOsMonitor.d.ts +2 -2
  117. package/dist/node/helpers/monitor/XyOsMonitor.d.ts.map +1 -1
  118. package/dist/node/helpers/monitor/types.d.ts +3 -3
  119. package/dist/node/helpers/monitor/types.d.ts.map +1 -1
  120. package/dist/node/index.mjs +1042 -694
  121. package/dist/node/index.mjs.map +1 -1
  122. package/dist/node/intent/Caller.d.ts +5 -5
  123. package/dist/node/lib/Listener.d.ts +1 -1
  124. package/dist/node/lib/Listener.d.ts.map +1 -1
  125. package/dist/node/lib/PayloadStore.d.ts +1 -2
  126. package/dist/node/lib/PayloadStore.d.ts.map +1 -1
  127. package/dist/node/lib/isPayload.d.ts +1 -1
  128. package/dist/node/loadOsNode.d.ts.map +1 -1
  129. package/dist/node/profileModuleEvents.d.ts +2 -4
  130. package/dist/node/profileModuleEvents.d.ts.map +1 -1
  131. package/dist/node/registration/DappRegistrationService.d.ts +3 -3
  132. package/dist/node/registration/DappRegistrationService.d.ts.map +1 -1
  133. package/dist/node/registration/DappRegistry.d.ts +4 -6
  134. package/dist/node/registration/DappRegistry.d.ts.map +1 -1
  135. package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts +7 -3
  136. package/dist/node/registration/ValidateDappAccessDiviner/Config.d.ts.map +1 -1
  137. package/dist/node/registration/ValidateDappAccessDiviner/Diviner.d.ts +3 -1
  138. package/dist/node/registration/ValidateDappAccessDiviner/Diviner.d.ts.map +1 -1
  139. package/dist/node/scripts/xyos/index.mjs +520 -384
  140. package/dist/node/scripts/xyos/index.mjs.map +1 -1
  141. package/dist/node/scripts/xyos/lib/headless.d.ts.map +1 -1
  142. package/dist/node/signer/Signers.d.ts.map +1 -1
  143. package/dist/node/stack/Base.d.ts +2 -2
  144. package/dist/node/stack/Base.d.ts.map +1 -1
  145. package/dist/node/stack/Manager.d.ts +2 -6
  146. package/dist/node/stack/Manager.d.ts.map +1 -1
  147. package/dist/node/system/ManageSystemDapps.d.ts +3 -3
  148. package/dist/node/system/ManageSystemDapps.d.ts.map +1 -1
  149. package/dist/node/utils/buildWalletSeedPhrasePayload.d.ts +1 -1
  150. package/dist/node/utils/buildWalletSeedPhrasePayload.d.ts.map +1 -1
  151. package/dist/node/wallet/SeedPhraseRepository.d.ts +3 -4
  152. package/dist/node/wallet/SeedPhraseRepository.d.ts.map +1 -1
  153. package/package.json +165 -55
  154. package/dist/neutral/signer/Signer.spec.d.ts +0 -2
  155. package/dist/neutral/signer/Signer.spec.d.ts.map +0 -1
  156. package/dist/neutral/spec/boot.spec.d.ts +0 -2
  157. package/dist/neutral/spec/boot.spec.d.ts.map +0 -1
  158. package/dist/node/signer/Signer.spec.d.ts +0 -2
  159. package/dist/node/signer/Signer.spec.d.ts.map +0 -1
  160. package/dist/node/spec/boot.spec.d.ts +0 -2
  161. package/dist/node/spec/boot.spec.d.ts.map +0 -1
  162. package/src/Caller.ts +0 -202
  163. package/src/DappCallerBase.ts +0 -56
  164. package/src/DefaultsQueries.ts +0 -27
  165. package/src/OsCallerBase.ts +0 -59
  166. package/src/PubSubBridgeCaller.ts +0 -33
  167. package/src/RunningDappCache.ts +0 -58
  168. package/src/XyOs.ts +0 -166
  169. package/src/XyOsBase.ts +0 -136
  170. package/src/XyOsDapp.ts +0 -103
  171. package/src/access/Caller.ts +0 -85
  172. package/src/access/Queries.ts +0 -38
  173. package/src/access/Resource.ts +0 -65
  174. package/src/access/RunningAccessDappCache.ts +0 -21
  175. package/src/access/index.ts +0 -4
  176. package/src/access/interfaces/index.ts +0 -1
  177. package/src/access/interfaces/registered-names/helpers/AccessNodeQueries.ts +0 -68
  178. package/src/access/interfaces/registered-names/helpers/index.ts +0 -2
  179. package/src/access/interfaces/registered-names/helpers/resource/AbstractXnsCaller.ts +0 -42
  180. package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResource.ts +0 -52
  181. package/src/access/interfaces/registered-names/helpers/resource/RegistrationsResourceQueries.ts +0 -23
  182. package/src/access/interfaces/registered-names/helpers/resource/index.ts +0 -3
  183. package/src/access/interfaces/registered-names/index.ts +0 -1
  184. package/src/adapter/Base.ts +0 -104
  185. package/src/adapter/Network.ts +0 -31
  186. package/src/adapter/Settings.ts +0 -30
  187. package/src/adapter/index.ts +0 -2
  188. package/src/adapters/OsPubSubBridgeNetwork.ts +0 -10
  189. package/src/adapters/OsSettings.ts +0 -7
  190. package/src/adapters/OsXyoPublicNetwork.ts +0 -9
  191. package/src/adapters/index.ts +0 -3
  192. package/src/classes/dapp/DefaultsResource.ts +0 -67
  193. package/src/classes/dapp/index.ts +0 -1
  194. package/src/classes/index.ts +0 -4
  195. package/src/classes/lib/DappCreatorParams.ts +0 -18
  196. package/src/classes/lib/Insertable.ts +0 -10
  197. package/src/classes/lib/index.ts +0 -2
  198. package/src/classes/menu/Caller.ts +0 -77
  199. package/src/classes/menu/Queries.ts +0 -60
  200. package/src/classes/menu/Resource.ts +0 -105
  201. package/src/classes/menu/index.ts +0 -2
  202. package/src/classes/settings/Caller.ts +0 -78
  203. package/src/classes/settings/CallerBase.ts +0 -27
  204. package/src/classes/settings/Resource.ts +0 -81
  205. package/src/classes/settings/SettingsQueries.ts +0 -56
  206. package/src/classes/settings/badge/Caller.ts +0 -30
  207. package/src/classes/settings/badge/Queries.ts +0 -19
  208. package/src/classes/settings/badge/Resource.ts +0 -50
  209. package/src/classes/settings/badge/index.ts +0 -2
  210. package/src/classes/settings/index.ts +0 -5
  211. package/src/dapp/context/creator/Creator.ts +0 -122
  212. package/src/dapp/context/creator/DefaultPayloads/DappAccessPayloads.ts +0 -20
  213. package/src/dapp/context/creator/DefaultPayloads/DefaultPayloads.ts +0 -40
  214. package/src/dapp/context/creator/DefaultPayloads/NodeInfoPayload.ts +0 -33
  215. package/src/dapp/context/creator/DefaultPayloads/index.ts +0 -1
  216. package/src/dapp/context/creator/ExternalModulePermissions/ExternalModulePermissions.ts +0 -59
  217. package/src/dapp/context/creator/ExternalModulePermissions/index.ts +0 -1
  218. package/src/dapp/context/creator/createDappContext.ts +0 -61
  219. package/src/dapp/context/creator/index.ts +0 -3
  220. package/src/dapp/context/index.ts +0 -1
  221. package/src/dapp/index.ts +0 -1
  222. package/src/event/bus/Connection.ts +0 -33
  223. package/src/event/bus/EventBus.ts +0 -159
  224. package/src/event/bus/PubSubConnection.ts +0 -28
  225. package/src/event/bus/index.ts +0 -3
  226. package/src/event/connections/DappAccessRequest.ts +0 -11
  227. package/src/event/connections/DappsReady.ts +0 -9
  228. package/src/event/connections/ExposeDappRequest.ts +0 -11
  229. package/src/event/connections/OsPubSubNetworkReady.ts +0 -12
  230. package/src/event/connections/OsSettingsReady.ts +0 -12
  231. package/src/event/connections/OsXyoPublicReady.ts +0 -12
  232. package/src/event/connections/index.ts +0 -6
  233. package/src/event/index.ts +0 -2
  234. package/src/helpers/index.ts +0 -1
  235. package/src/helpers/monitor/XyOsMonitor.ts +0 -52
  236. package/src/helpers/monitor/index.ts +0 -2
  237. package/src/helpers/monitor/types.ts +0 -8
  238. package/src/index.ts +0 -29
  239. package/src/initializer/DappInitializer.ts +0 -57
  240. package/src/initializer/index.ts +0 -1
  241. package/src/intent/Caller.ts +0 -74
  242. package/src/intent/Resource.ts +0 -66
  243. package/src/intent/index.ts +0 -2
  244. package/src/lib/ExternalStore.ts +0 -7
  245. package/src/lib/Listener.ts +0 -1
  246. package/src/lib/ModuleAccountPaths.ts +0 -23
  247. package/src/lib/ModuleNames.ts +0 -3
  248. package/src/lib/NameTransforms.ts +0 -34
  249. package/src/lib/PayloadStore.ts +0 -106
  250. package/src/lib/ResourceStores.ts +0 -7
  251. package/src/lib/index.ts +0 -11
  252. package/src/lib/initializeXns.ts +0 -16
  253. package/src/lib/isEqual.ts +0 -42
  254. package/src/lib/isPayload.ts +0 -24
  255. package/src/lib/tokenPlacesSplit.ts +0 -17
  256. package/src/loadOsNode.ts +0 -44
  257. package/src/manifest/index.ts +0 -2
  258. package/src/manifest/manifestReplacementTokens.ts +0 -6
  259. package/src/manifest/os-node.manifest.json +0 -132
  260. package/src/manifests/dapp-window.manifest.json +0 -36
  261. package/src/manifests/index.ts +0 -1
  262. package/src/models/access/ValidDappAccessInterfaces.ts +0 -6
  263. package/src/models/access/index.ts +0 -1
  264. package/src/models/index.ts +0 -1
  265. package/src/profileModuleEvents.ts +0 -43
  266. package/src/registration/DappRegistrationService.ts +0 -179
  267. package/src/registration/DappRegistry.ts +0 -131
  268. package/src/registration/ValidateDappAccessDiviner/Config.ts +0 -24
  269. package/src/registration/ValidateDappAccessDiviner/Diviner.ts +0 -133
  270. package/src/registration/ValidateDappAccessDiviner/index.ts +0 -2
  271. package/src/registration/index.ts +0 -2
  272. package/src/scripts/xyos/command/config.ts +0 -19
  273. package/src/scripts/xyos/command/create.ts +0 -22
  274. package/src/scripts/xyos/command/index.ts +0 -7
  275. package/src/scripts/xyos/command/manifest.ts +0 -19
  276. package/src/scripts/xyos/command/start.ts +0 -35
  277. package/src/scripts/xyos/index.ts +0 -32
  278. package/src/scripts/xyos/lib/createFromTemplate.ts +0 -11
  279. package/src/scripts/xyos/lib/headless.ts +0 -68
  280. package/src/scripts/xyos/lib/index.ts +0 -2
  281. package/src/signer/Signer.spec.ts +0 -65
  282. package/src/signer/Signers.ts +0 -74
  283. package/src/signer/index.ts +0 -1
  284. package/src/spec/boot.spec.ts +0 -89
  285. package/src/stack/Base.ts +0 -166
  286. package/src/stack/Manager.ts +0 -51
  287. package/src/stack/Map.ts +0 -22
  288. package/src/stack/OsPubSubNetworkStack.ts +0 -70
  289. package/src/stack/OsSettingsStack.ts +0 -24
  290. package/src/stack/XyoPublicNetworkStack.ts +0 -32
  291. package/src/stack/index.ts +0 -6
  292. package/src/system/ManageSystemDapps.ts +0 -148
  293. package/src/system/Queries.ts +0 -69
  294. package/src/system/index.ts +0 -1
  295. package/src/types/global.d.ts +0 -9
  296. package/src/types/images.d.ts +0 -5
  297. package/src/utils/buildWalletSeedPhrasePayload.ts +0 -51
  298. package/src/utils/getApiDomain.ts +0 -14
  299. package/src/utils/index.ts +0 -3
  300. package/src/utils/renameObjKey.ts +0 -22
  301. package/src/wallet/DappSeedPhraseRepository.ts +0 -99
  302. package/src/wallet/SeedPhraseRepository.ts +0 -32
  303. package/src/wallet/index.ts +0 -2
@@ -1,67 +0,0 @@
1
- import { assertEx } from '@xylabs/assert'
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,77 +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
- *
24
- * @param {Payload[]} payloads
25
- */
26
- async add(payloads: Payload[], force = false) {
27
- const dappArchivist = await this.getDappArchivist()
28
-
29
- for (const payload of payloads) {
30
- const hash = await PayloadBuilder.dataHash(payload)
31
- const [existing] = await dappArchivist.get([hash])
32
- if (!existing || force) {
33
- await dappArchivist.insert(payloads)
34
- }
35
- }
36
- }
37
-
38
- async currentNavSelection(): Promise<DappNavItemSelection[] | undefined> {
39
- const diviner = await this.getDappArchivistPayloadDiviner()
40
- const query = {
41
- limit: 1,
42
- order: 'desc',
43
- schema: PayloadDivinerQuerySchema,
44
- schemas: [DappNavItemSelectionSchema],
45
- }
46
-
47
- return (await diviner.divine([query])) as DappNavItemSelection[]
48
- }
49
-
50
- /*
51
- * Indicate to the system that a nav item was selected
52
- *
53
- * @param {string} path
54
- * @params {string} injectableParamsPath
55
- * @returns Promise
56
- */
57
- async makeNavItemSelection(path: string, injectableParamsPath?: string): Promise<void> {
58
- const dappArchivist = await this.getDappArchivist()
59
- const payload: DappNavItemSelection = {
60
- path,
61
- schema: DappNavItemSelectionSchema,
62
- timestamp: Date.now(),
63
- }
64
- await dappArchivist.insert([payload])
65
-
66
- if (injectableParamsPath) {
67
- const injectableParams: DappInjectableParams = {
68
- params: {},
69
- path: injectableParamsPath,
70
- schema: DappInjectableParamsSchema,
71
- source: 'route',
72
- timestamp: Date.now(),
73
- }
74
- await dappArchivist.insert([injectableParams])
75
- }
76
- }
77
- }
@@ -1,60 +0,0 @@
1
- import type { DivinerInstance } from '@xyo-network/diviner-model'
2
- import type { PayloadDivinerQueryPayload } from '@xyo-network/diviner-payload-model'
3
- import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
4
- import type {
5
- DappNavItem,
6
- DappNavItemSelection,
7
- DappNavMenuConfig,
8
- } from '@xyo-network/os-model'
9
- import {
10
- DappNavItemSchema,
11
- DappNavItemSelectionSchema,
12
- DappNavMenuConfigSchema,
13
- } from '@xyo-network/os-model'
14
- import type { WithSources } from '@xyo-network/payload-model'
15
-
16
- const NO_ITEMS: unknown[] = []
17
-
18
- export const DappMenuQueries = {
19
- async getMenuConfigs(diviner: DivinerInstance): Promise<WithSources<DappNavMenuConfig>[]> {
20
- const query: PayloadDivinerQueryPayload = {
21
- limit: 1,
22
- order: 'desc',
23
- schema: PayloadDivinerQuerySchema,
24
- schemas: [DappNavMenuConfigSchema],
25
- }
26
- return (await diviner.divine([query])) as WithSources<DappNavMenuConfig>[]
27
- },
28
-
29
- async getMenuItems(diviner: DivinerInstance) {
30
- const query: PayloadDivinerQueryPayload = {
31
- order: 'desc',
32
- schema: PayloadDivinerQuerySchema,
33
- schemas: [DappNavItemSchema],
34
- }
35
-
36
- const results = (await diviner.divine([query])) as WithSources<DappNavItem>[]
37
- return results.length > 0 ? results : (NO_ITEMS as WithSources<DappNavItem>[])
38
- },
39
-
40
- async getNavItemSelections(diviner: DivinerInstance) {
41
- const query: PayloadDivinerQueryPayload = {
42
- limit: 1,
43
- order: 'desc',
44
- schema: PayloadDivinerQuerySchema,
45
- schemas: [DappNavItemSelectionSchema],
46
- }
47
- const results = (await diviner.divine([query])) as WithSources<DappNavItemSelection>[]
48
- return results.length > 0 ? results : (NO_ITEMS as WithSources<DappNavItemSelection>[])
49
- },
50
-
51
- async getVisibleMenuItems(diviner: DivinerInstance) {
52
- const query: PayloadDivinerQueryPayload = {
53
- order: 'desc',
54
- schema: PayloadDivinerQuerySchema,
55
- schemas: [DappNavItemSchema],
56
- }
57
- const results = (await diviner.divine([query])) as WithSources<DappNavItem>[]
58
- return results.filter(menuItem => menuItem.hidden !== true).toSorted((a, b) => ((a.weight ?? 0) > (b.weight ?? 0) ? 1 : -1))
59
- },
60
- }
@@ -1,105 +0,0 @@
1
- import { assertEx } from '@xylabs/assert'
2
- import type {
3
- DappNavItem, DappNavItemSelection, DappNavMenuConfig, XyOsContext,
4
- } from '@xyo-network/os-model'
5
- import { isDappNavItemSelection, isDappNavMenuConfig } from '@xyo-network/os-model'
6
- import type { Payload, WithSources } from '@xyo-network/payload-model'
7
-
8
- import { DappCaller } from '../../Caller.ts'
9
- import type { Listener, ResourceStore } from '../../lib/index.ts'
10
- import { PayloadStore } from '../../lib/index.ts'
11
- import { DappMenuQueries } from './Queries.ts'
12
-
13
- export type DappMenuResourceViews = 'menuConfigs' | 'menuItems' | 'menuItemsVisible' | 'menuItemSelections'
14
-
15
- export type NavPayloadType<T extends Payload = Payload> = WithSources<T>[]
16
-
17
- /**
18
- * A Repository for interacting with dapp menu items and config
19
- */
20
- export class DappMenuResource extends DappCaller implements ResourceStore<DappMenuResourceViews> {
21
- private _menuConfigListener: PayloadStore<DappNavMenuConfig> | undefined
22
- private _menuItemListener: PayloadStore<DappNavItem> | undefined
23
- private _menuItemSelectionListener: PayloadStore<DappNavItemSelection> | undefined
24
- private _menuItemVisibleListener: PayloadStore<DappNavItem> | undefined
25
-
26
- constructor(xyOsContext: XyOsContext) {
27
- super(xyOsContext)
28
- }
29
-
30
- get menuConfigListener() {
31
- return assertEx(this._menuConfigListener, () => 'menuConfigListener note found')
32
- }
33
-
34
- get menuItemListener() {
35
- return assertEx(this._menuItemListener, () => 'menuItemListener note found')
36
- }
37
-
38
- get menuItemSelectionListener() {
39
- return assertEx(this._menuItemSelectionListener, () => 'menuItemSelectionListener note found')
40
- }
41
-
42
- get menuItemVisibleListener() {
43
- return assertEx(this._menuItemVisibleListener, () => 'menuItemVisibleListener note found')
44
- }
45
-
46
- /** subscribe to latest set of payloads */
47
- get subscriptions() {
48
- return {
49
- menuConfigs: (cb: Listener) => this.menuConfigListener.subscribe(cb),
50
- menuItemSelections: (cb: Listener) => this.menuItemSelectionListener.subscribe(cb),
51
- menuItems: (cb: Listener) => this.menuItemListener.subscribe(cb),
52
- menuItemsVisible: (cb: Listener) => this.menuItemVisibleListener.subscribe(cb),
53
- }
54
- }
55
-
56
- /**
57
- * Return the latest menu payloads from the repository
58
- */
59
- get views() {
60
- return {
61
- menuConfigs: () => this.menuConfigListener.getSnapshot(),
62
- menuItemSelections: () => this.menuItemSelectionListener.getSnapshot(),
63
- menuItems: () => this.menuItemListener.getSnapshot(),
64
- menuItemsVisible: () => this.menuItemVisibleListener.getSnapshot(),
65
- }
66
- }
67
-
68
- /**
69
- * Remove all listeners and reset their class members
70
- */
71
- cleanupListeners() {
72
- this.menuConfigListener.cleanupListeners()
73
- this.menuItemListener.cleanupListeners()
74
- this.menuItemSelectionListener.cleanupListeners()
75
- }
76
-
77
- /**
78
- * Start the resource
79
- */
80
- async start(): Promise<void> {
81
- const dappArchivist = await this.getDappArchivist()
82
- const dappArchivistPayloadDiviner = await this.getDappArchivistPayloadDiviner()
83
-
84
- this._menuConfigListener = await PayloadStore.create<DappNavMenuConfig>({
85
- archivist: dappArchivist,
86
- getLatest: async () => await DappMenuQueries.getMenuConfigs(dappArchivistPayloadDiviner),
87
- idFunction: isDappNavMenuConfig,
88
- })
89
- this._menuItemListener = await PayloadStore.create<DappNavItem>({
90
- archivist: dappArchivist,
91
- getLatest: async () => await DappMenuQueries.getMenuItems(dappArchivistPayloadDiviner),
92
- idFunction: isDappNavMenuConfig,
93
- })
94
- this._menuItemVisibleListener = await PayloadStore.create<DappNavItem>({
95
- archivist: dappArchivist,
96
- getLatest: async () => await DappMenuQueries.getVisibleMenuItems(dappArchivistPayloadDiviner),
97
- idFunction: isDappNavMenuConfig,
98
- })
99
- this._menuItemSelectionListener = await PayloadStore.create<DappNavItemSelection>({
100
- archivist: dappArchivist,
101
- getLatest: async () => await DappMenuQueries.getNavItemSelections(dappArchivistPayloadDiviner),
102
- idFunction: isDappNavItemSelection,
103
- })
104
- }
105
- }
@@ -1,2 +0,0 @@
1
- export * from './Caller.ts'
2
- export * from './Resource.ts'
@@ -1,78 +0,0 @@
1
- import { assertEx } from '@xylabs/assert'
2
- import type {
3
- NodeBackground, WalletSeedPhrase, XyOsContext,
4
- } from '@xyo-network/os-model'
5
-
6
- import { isEqual } from '../../lib/index.ts'
7
- import { buildUserWalletSeedPhrasePayload } from '../../utils/index.ts'
8
- import { OsSettingsCallerBase } from './CallerBase.ts'
9
- import { OsSettingsQueries } from './SettingsQueries.ts'
10
-
11
- export class OsSettingsCaller extends OsSettingsCallerBase {
12
- constructor(context: XyOsContext) {
13
- super(context)
14
- }
15
-
16
- /**
17
- * Add a node background to the settings
18
- * @param {NodeBackground} payload
19
- */
20
- async addNodeBackground(payload: NodeBackground) {
21
- const archivist = await this.getOsSettingsArchivist()
22
- await archivist.insert([payload])
23
- }
24
-
25
- /**
26
- * Add a wallet seed phrase to the settings
27
- * @param {WalletSeedPhrase} payload
28
- */
29
- async addWalletSeedPhrase(payload: WalletSeedPhrase) {
30
- // NOTE: Since setting the seed phrase in OS takes precedence
31
- // over the BIOS when the two phrases differ, we'll set the seed
32
- // phrase in the OS first. That way if the latter saves fail we can
33
- // still recover on next boot.
34
-
35
- // Save seed phrase to OS settings
36
- const archivist = await this.getOsSettingsArchivist()
37
- await archivist.insert([payload])
38
-
39
- // Save seed phrase to BIOS
40
- const phrase = payload.mnemonic.mnemonic.join(' ')
41
- await this.context.kernel?.bios?.seedPhraseStore.set('user', phrase)
42
- }
43
-
44
- /**
45
- * Get the latest node background
46
- */
47
- async getLatestNodeBackground(): Promise<NodeBackground | null> {
48
- const diviner = await this.getOsSettingsPayloadDiviner()
49
- const [result] = (await OsSettingsQueries.getNodeBackground(diviner)) as NodeBackground[]
50
- return result ?? null
51
- }
52
-
53
- async getLatestUserWallet(): Promise<WalletSeedPhrase> {
54
- // Get the seed phrase from the OS settings
55
- const diviner = await this.getOsSettingsPayloadDiviner()
56
- const archivist = await this.getOsSettingsArchivist()
57
- const storedSeedPhrasePayload = (await OsSettingsQueries.getLatestUserWallet(diviner, archivist)).pop()
58
- // Get the seed phrase from the BIOS
59
- const biosWalletSeedPhrase = assertEx(await this.context.kernel?.bios?.seedPhraseStore.get('user'), () => 'No user seed phrase found from BIOS')
60
- const biosWalletSeedPhraseParts = biosWalletSeedPhrase.split(' ')
61
- // If there is no stored seed phrase in the OS, use the seed phrase from the BIOS
62
- if (!storedSeedPhrasePayload?.mnemonic?.mnemonic) {
63
- // Create new wallet payload from BIOS seed phrase
64
- const { payload: biosSeedPhrasePayload } = await buildUserWalletSeedPhrasePayload(biosWalletSeedPhrase)
65
- // Store the BIOS seed phrase in the OS settings
66
- await this.addWalletSeedPhrase(biosSeedPhrasePayload)
67
- // Return BIOS seed phrase payload
68
- return biosSeedPhrasePayload
69
- } else if (!isEqual(storedSeedPhrasePayload.mnemonic.mnemonic, biosWalletSeedPhraseParts)) {
70
- // If there is a seed phrase in the OS settings that does not match the BIOS seed phrase
71
- // Update bios with existing user seed phrase
72
- const updatedBiosSeedPhrase = storedSeedPhrasePayload.mnemonic.mnemonic.join(' ')
73
- await this.context.kernel?.bios?.seedPhraseStore.set('user', updatedBiosSeedPhrase)
74
- }
75
- // Return stored seed phrase
76
- return storedSeedPhrasePayload
77
- }
78
- }
@@ -1,27 +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
- const OsSettingsArchivistModuleName = 'OsSettingsNode:OsSettingsArchivist'
7
- const OsSettingsArchivistPayloadDivinerModuleName = 'OsSettingsNode:OsSettingsArchivistPayloadDiviner'
8
-
9
- export class OsSettingsCallerBase {
10
- protected context: XyOsContext
11
- constructor(context: XyOsContext) {
12
- this.context = context
13
- }
14
-
15
- async getOsSettingsArchivist() {
16
- const mod = assertEx(await this.context.root.resolve(OsSettingsArchivistModuleName), () => `${OsSettingsArchivistModuleName} not found`)
17
- return asArchivistInstance(mod, () => `${OsSettingsArchivistModuleName} is not an archivist`, { required: true })
18
- }
19
-
20
- async getOsSettingsPayloadDiviner() {
21
- const mod = assertEx(
22
- await this.context.root.resolve(OsSettingsArchivistPayloadDivinerModuleName),
23
- () => `${OsSettingsArchivistPayloadDivinerModuleName} not found`,
24
- )
25
- return asDivinerInstance(mod, () => `${OsSettingsArchivistPayloadDivinerModuleName} is not a diviner`, { required: true })
26
- }
27
- }
@@ -1,81 +0,0 @@
1
- import { assertEx } from '@xylabs/assert'
2
- import type {
3
- NodeBackground, WalletSeedPhrase, XyOsContext,
4
- } from '@xyo-network/os-model'
5
- import { isNodeBackground, isWalletSeedPhrase } from '@xyo-network/os-model'
6
-
7
- import type { Listener, ResourceStore } from '../../lib/index.ts'
8
- import { PayloadStore } from '../../lib/index.ts'
9
- import { OsSettingsCallerBase } from './CallerBase.ts'
10
- import { OsSettingsQueries } from './SettingsQueries.ts'
11
-
12
- export type OsSettingsResourceViews = 'wallets' | 'latestUserWallet' | 'nodeBackground'
13
-
14
- export class OsSettingsResource extends OsSettingsCallerBase implements ResourceStore<OsSettingsResourceViews> {
15
- private _latestUserWalletListener: PayloadStore<WalletSeedPhrase> | undefined
16
- private _nodeBackgroundListener: PayloadStore<NodeBackground> | undefined
17
- private _walletsListener: PayloadStore<WalletSeedPhrase> | undefined
18
-
19
- constructor(context: XyOsContext) {
20
- super(context)
21
- }
22
-
23
- get latestUserWalletListener() {
24
- return assertEx(this._latestUserWalletListener, () => 'Latest user wallet listener not set')
25
- }
26
-
27
- get nodeBackgroundListener() {
28
- return assertEx(this._nodeBackgroundListener, () => 'Node background listener not set')
29
- }
30
-
31
- get subscriptions() {
32
- return {
33
- latestUserWallet: (cb: Listener) => this.walletsListener.subscribe(cb),
34
- nodeBackground: (cb: Listener) => this.nodeBackgroundListener.subscribe(cb),
35
- wallets: (cb: Listener) => this.walletsListener.subscribe(cb),
36
- }
37
- }
38
-
39
- get views() {
40
- return {
41
- latestUserWallet: () => this.latestUserWalletListener.latest,
42
- nodeBackground: () => this.nodeBackgroundListener.latest,
43
- wallets: () => this.walletsListener.latest,
44
- }
45
- }
46
-
47
- get walletsListener() {
48
- return assertEx(this._walletsListener, () => 'Wallets listener not set')
49
- }
50
-
51
- cleanupListeners() {
52
- this.walletsListener.cleanupListeners()
53
- this.latestUserWalletListener.cleanupListeners()
54
- }
55
-
56
- /**
57
- * start listeners
58
- */
59
- async start() {
60
- const archivist = await this.getOsSettingsArchivist()
61
- const diviner = await this.getOsSettingsPayloadDiviner()
62
-
63
- this._walletsListener = await PayloadStore.create<WalletSeedPhrase>({
64
- archivist,
65
- getLatest: async () => await OsSettingsQueries.getWallets(diviner),
66
- idFunction: isWalletSeedPhrase,
67
- })
68
-
69
- this._latestUserWalletListener = await PayloadStore.create<WalletSeedPhrase>({
70
- archivist,
71
- getLatest: async () => await OsSettingsQueries.getLatestUserWallet(diviner),
72
- idFunction: isWalletSeedPhrase,
73
- })
74
-
75
- this._nodeBackgroundListener = await PayloadStore.create<NodeBackground>({
76
- archivist,
77
- getLatest: async () => await OsSettingsQueries.getNodeBackground(diviner),
78
- idFunction: isNodeBackground,
79
- })
80
- }
81
- }
@@ -1,56 +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 type { NodeBackground, WalletSeedPhrase } from '@xyo-network/os-model'
5
- import { NodeBackgroundSchema, WalletSeedPhraseSchema } from '@xyo-network/os-model'
6
- import { PayloadBuilder } from '@xyo-network/payload-builder'
7
- import type { WithSources } from '@xyo-network/payload-model'
8
-
9
- const NO_RESULTS: WithSources<WalletSeedPhrase>[] = []
10
-
11
- export const OsSettingsQueries = {
12
- async getLatestUserWallet(diviner: DivinerInstance, archivist?: ArchivistInstance): Promise<WalletSeedPhrase[]> {
13
- const query = {
14
- limit: 1,
15
- order: 'desc',
16
- schema: PayloadDivinerQuerySchema,
17
- schemas: [WalletSeedPhraseSchema],
18
- }
19
- const results = (await diviner.divine([query])) as WalletSeedPhrase[]
20
- const wallet = results.find(payload => payload.$label === 'userWallet')
21
- if (wallet) return [wallet]
22
- // Check for legacy payload and optionally migrate by re-minting it in the updates format.
23
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
- const legacyWallet = results.find(payload => (payload as any).$meta.label === 'userWallet')
25
- if (legacyWallet && archivist) {
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
- const legacyMeta = (legacyWallet as any).$meta
28
- const newWalletPayloadFields = {
29
- mnemonic: legacyWallet.mnemonic,
30
- $label: legacyMeta.label,
31
- $timestamp: legacyMeta.$timestamp,
32
- }
33
- const payload = new PayloadBuilder<WalletSeedPhrase>({ schema: WalletSeedPhraseSchema }).fields(newWalletPayloadFields).build()
34
- await archivist.insert([payload])
35
- return [payload]
36
- }
37
- return NO_RESULTS
38
- },
39
- async getNodeBackground(diviner: DivinerInstance) {
40
- const query = {
41
- limit: 1,
42
- order: 'desc',
43
- schema: PayloadDivinerQuerySchema,
44
- schemas: [NodeBackgroundSchema],
45
- }
46
- return (await diviner.divine([query])) as WithSources<NodeBackground>[]
47
- },
48
- async getWallets(diviner: DivinerInstance) {
49
- const query = {
50
- order: 'desc',
51
- schema: PayloadDivinerQuerySchema,
52
- schemas: [WalletSeedPhraseSchema],
53
- }
54
- return (await diviner.divine([query])) as WithSources<WalletSeedPhrase>[]
55
- },
56
- }
@@ -1,30 +0,0 @@
1
- import type { ValidOsAchievements } from '@xyo-network/os-model'
2
- import { OsBadgeSchema } from '@xyo-network/os-model'
3
-
4
- import { OsSettingsCallerBase } from '../CallerBase.ts'
5
- import { OsBadgeQueries } from './Queries.ts'
6
-
7
- export class OsBadgeCaller extends OsSettingsCallerBase {
8
- /**
9
- * @param {ValidOsAchievements} achievement
10
- */
11
- async getBadge(achievement: ValidOsAchievements) {
12
- const diviner = await this.getOsSettingsPayloadDiviner()
13
- const results = await OsBadgeQueries.getBadge(achievement, diviner)
14
- return results[0] ?? null
15
- }
16
-
17
- /**
18
- * @param {ValidOsAchievements} achievement
19
- */
20
- async saveBadge(achievement: ValidOsAchievements) {
21
- const badge = {
22
- achievement,
23
- schema: OsBadgeSchema,
24
- timestamp: Date.now(),
25
- }
26
-
27
- const archivist = await this.getOsSettingsArchivist()
28
- return await archivist.insert([badge])
29
- }
30
- }
@@ -1,19 +0,0 @@
1
- import type { DivinerInstance } from '@xyo-network/diviner-model'
2
- import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
3
- import type { OsBadge } from '@xyo-network/os-model'
4
- import { OsBadgeSchema } from '@xyo-network/os-model'
5
- import type { WithSources } from '@xyo-network/payload-model'
6
-
7
- export const OsBadgeQueries = {
8
- getBadge: async (achievement: string, diviner: DivinerInstance) => {
9
- const query = {
10
- achievement,
11
- limit: 1,
12
- order: 'desc',
13
- schema: PayloadDivinerQuerySchema,
14
- schemas: [OsBadgeSchema],
15
- }
16
-
17
- return (await diviner.divine([query])) as WithSources<OsBadge>[]
18
- },
19
- }