@xyo-network/os-runtime 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/neutral/index.d.ts +2 -2
  2. package/dist/neutral/index.mjs +264 -102
  3. package/dist/neutral/index.mjs.map +1 -1
  4. package/package.json +28 -28
  5. package/src/Caller.ts +5 -2
  6. package/src/DefaultsQueries.ts +6 -2
  7. package/src/XyOs.ts +20 -9
  8. package/src/XyOsBase.ts +10 -3
  9. package/src/XyOsDapp.ts +9 -3
  10. package/src/access-interfaces/ValidDappAccessInterfaces.ts +4 -4
  11. package/src/access-interfaces/registered-names/helpers/AccessNodeQueries.ts +6 -2
  12. package/src/access-interfaces/registered-names/helpers/resource/RegistrationsResource.ts +8 -8
  13. package/src/adapter/Base.ts +11 -3
  14. package/src/adapters/OsPubSubBridgeNetwork.ts +3 -1
  15. package/src/classes/cache/RunningDappCache.ts +16 -4
  16. package/src/classes/dapp/DefaultsResource.ts +9 -3
  17. package/src/classes/dapp/access/Caller.ts +5 -4
  18. package/src/classes/dapp/access/Queries.ts +6 -2
  19. package/src/classes/dapp/access/Resource.ts +9 -3
  20. package/src/classes/lib/DappCreatorParams.ts +3 -1
  21. package/src/classes/lib/Insertable.ts +5 -7
  22. package/src/classes/menu/Caller.ts +5 -2
  23. package/src/classes/menu/Queries.ts +5 -2
  24. package/src/classes/menu/Resource.ts +12 -4
  25. package/src/classes/node/Creator.ts +19 -7
  26. package/src/classes/node/DefaultPayloads/DappAccessPayloads.ts +3 -1
  27. package/src/classes/node/DefaultPayloads/DefaultPayloads.ts +3 -1
  28. package/src/classes/node/DefaultPayloads/NodeInfoPayload.ts +3 -1
  29. package/src/classes/node/DefaultPayloads/SigningKeyPayloads.ts +9 -10
  30. package/src/classes/node/ExternalModulePermissions/ExternalModulePermissions.ts +6 -2
  31. package/src/classes/node/createDappContext.ts +16 -4
  32. package/src/classes/registration/DappRegistrationService.ts +25 -7
  33. package/src/classes/registration/DappRegistry.ts +16 -8
  34. package/src/classes/registration/ValidateDappAccessDiviner/Config.ts +10 -3
  35. package/src/classes/registration/ValidateDappAccessDiviner/Diviner.ts +14 -8
  36. package/src/classes/settings/Caller.ts +3 -1
  37. package/src/classes/settings/Resource.ts +9 -3
  38. package/src/classes/settings/SettingsQueries.ts +6 -2
  39. package/src/classes/settings/badge/Resource.ts +5 -7
  40. package/src/classes/system/ManageSystemDapps.ts +7 -2
  41. package/src/classes/system/Queries.ts +2 -1
  42. package/src/event/bus/Connection.ts +3 -1
  43. package/src/event/bus/EventBus.ts +13 -4
  44. package/src/helpers/monitor/XyOsMonitor.ts +9 -7
  45. package/src/helpers/monitor/types.ts +4 -1
  46. package/src/intent/Caller.ts +6 -2
  47. package/src/intent/Resource.ts +6 -2
  48. package/src/lib/ModuleAccountPaths.ts +6 -10
  49. package/src/lib/PayloadStore.ts +9 -3
  50. package/src/lib/isPayload.ts +3 -1
  51. package/src/manifest/ManifestReplaceableTokens.ts +4 -3
  52. package/src/profileModuleEvents.ts +6 -2
  53. package/src/stack/Base.ts +18 -6
  54. package/src/stack/Manager.ts +8 -8
  55. package/src/stack/Map.ts +3 -1
  56. package/src/stack/OsPubSubNetworkStack.ts +12 -4
  57. package/src/stack/OsSettingsStack.ts +6 -2
  58. package/src/stack/XyoPublicNetworkStack.ts +6 -2
  59. package/src/utils/buildWalletSeedPhrasePayload.ts +22 -6
  60. package/src/wallet/DappSeedPhraseRepository.ts +6 -2
@@ -1,8 +1,12 @@
1
1
  import { assertEx } from '@xylabs/assert'
2
2
  import { hexFrom } from '@xylabs/hex'
3
3
  import { HDWallet } from '@xyo-network/account'
4
- import type { DappName, XyOsContext } from '@xyo-network/os-model'
5
- import { mnemonicArrayToString, SigningKeySchema } from '@xyo-network/os-model'
4
+ import type {
5
+ DappName, XyOsContext,
6
+ } from '@xyo-network/os-model'
7
+ import {
8
+ mnemonicArrayToString, SigningKeySchema,
9
+ } from '@xyo-network/os-model'
6
10
  import type { Payload } from '@xyo-network/payload-model'
7
11
  import { isAnyPayload } from '@xyo-network/payload-model'
8
12
  import type { WalletInstance } from '@xyo-network/wallet-model'
@@ -14,17 +18,12 @@ const DappsWithAdditionalPayloads = new Set(['Profile'])
14
18
 
15
19
  const DefaultName: DappName = 'Name Service' as const
16
20
 
17
- const DEFAULT_DAPP_ACCOUNT_PATHS: Record<string, string> = {
18
- [DefaultName]: "1'/1",
19
- } as const
21
+ const DEFAULT_DAPP_ACCOUNT_PATHS: Record<string, string> = { [DefaultName]: "1'/1" } as const
20
22
 
21
23
  // WIP - for now, dApps listed here can gain access to the signing key for other dapps
22
24
  // In the future, this will be controlled by the user
23
- const ADDITIONAL_DAPP_ACCOUNT_PATHS: Record<string, Record<string, string>> = {
24
- ['Profile']: {
25
- [DefaultName]: DEFAULT_DAPP_ACCOUNT_PATHS[DefaultName],
26
- },
27
- } as const
25
+ const ADDITIONAL_DAPP_ACCOUNT_PATHS: Record<string, Record<string, string>>
26
+ = { ['Profile']: { [DefaultName]: DEFAULT_DAPP_ACCOUNT_PATHS[DefaultName] } } as const
28
27
 
29
28
  export class SigningKeyPayloads implements DefaultPayloadsInsertable {
30
29
  constructor(
@@ -1,6 +1,10 @@
1
- import type { AttachableModuleInstance, ModuleIdentifier } from '@xyo-network/module-model'
1
+ import type {
2
+ AttachableModuleInstance, ModuleIdentifier,
3
+ } from '@xyo-network/module-model'
2
4
  import type { NodeInstance } from '@xyo-network/node-model'
3
- import type { DappName, ExternalModule, XyOsContext } from '@xyo-network/os-model'
5
+ import type {
6
+ DappName, ExternalModule, XyOsContext,
7
+ } from '@xyo-network/os-model'
4
8
 
5
9
  // Dapps can only request specific modules from the parent node
6
10
  const ALLOWED_MODULES_FROM_PARENT = ['IntentArchivist', 'OsSettingsNode', 'OsPubSubNetworkStackNode', 'OsXyoPublicNetworkStackNode'] as const
@@ -1,7 +1,9 @@
1
1
  import { HDWallet } from '@xyo-network/account'
2
2
  import { GenericPayloadDiviner } from '@xyo-network/diviner-payload-generic'
3
3
  import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
4
- import type { RegisteredDapp, WindowDappNodeSet, XyOsContext } from '@xyo-network/os-model'
4
+ import type {
5
+ RegisteredDapp, WindowDappNodeSet, XyOsContext,
6
+ } from '@xyo-network/os-model'
5
7
 
6
8
  import { DappSeedPhraseRepository } from '../../wallet/index.ts'
7
9
  import type { DappNodesCreatorParams } from '../lib/index.ts'
@@ -15,7 +17,13 @@ const resolveLocator = (existingLocator?: ModuleFactoryLocator) => {
15
17
  return locator
16
18
  }
17
19
 
18
- export const createDappContext = async (dapp: RegisteredDapp, context: XyOsContext, allowedNames: string[], xnsNodeUrl: string | undefined, xnsNetwork: string | undefined): Promise<WindowDappNodeSet> => {
20
+ export const createDappContext = async (
21
+ dapp: RegisteredDapp,
22
+ context: XyOsContext,
23
+ allowedNames: string[],
24
+ xnsNodeUrl: string | undefined,
25
+ xnsNetwork: string | undefined,
26
+ ): Promise<WindowDappNodeSet> => {
19
27
  console.log('createNodes')
20
28
  try {
21
29
  const dappSeedPhraseRepository = new DappSeedPhraseRepository(context, allowedNames)
@@ -25,12 +33,16 @@ export const createDappContext = async (dapp: RegisteredDapp, context: XyOsConte
25
33
  }
26
34
  const wallet = await HDWallet.fromPhrase(seedPhrase)
27
35
  const dappName = dapp.config.name
28
- const { config: dappConfig, params: dappParams } = dapp
36
+ const {
37
+ config: dappConfig, params: dappParams,
38
+ } = dapp
29
39
 
30
40
  const locator = resolveLocator((dappParams.locator ?? new ModuleFactoryLocator()).merge(context.platformLocator))
31
41
 
32
42
  const params: DappNodesCreatorParams = {
33
- config: { dappName, payload: dappConfig.manifest },
43
+ config: {
44
+ dappName, payload: dappConfig.manifest,
45
+ },
34
46
  context,
35
47
  locator,
36
48
  wallet,
@@ -1,6 +1,8 @@
1
1
  import { forget } from '@xylabs/forget'
2
2
  import type { Promisable } from '@xylabs/promise'
3
- import { fulfilled, rejected } from '@xylabs/promise'
3
+ import {
4
+ fulfilled, rejected,
5
+ } from '@xylabs/promise'
4
6
  import { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
5
7
  import type {
6
8
  DappPackageManifestPayload,
@@ -9,7 +11,8 @@ import type {
9
11
  PayloadWithVersion,
10
12
  RegisteredDappSetResult,
11
13
  XyOsContext,
12
- XyOsDappContext } from '@xyo-network/os-model'
14
+ XyOsDappContext,
15
+ } from '@xyo-network/os-model'
13
16
  import {
14
17
  DappIntentTypes,
15
18
  DappMode,
@@ -17,7 +20,9 @@ import {
17
20
  isRegisteredDappExposedDappSet,
18
21
  } from '@xyo-network/os-model'
19
22
 
20
- import { dappAccessRequestConnection, DappAccessRequestEvent, exposeDappRequestConnection, ExposeDappRequestEvent } from '../../event/index.ts'
23
+ import {
24
+ dappAccessRequestConnection, DappAccessRequestEvent, exposeDappRequestConnection, ExposeDappRequestEvent,
25
+ } from '../../event/index.ts'
21
26
  import { DappIntentCaller } from '../../intent/index.ts'
22
27
  import { NameTransforms } from '../../lib/index.ts'
23
28
  import { DappSeedPhraseRepository } from '../../wallet/index.ts'
@@ -53,7 +58,9 @@ export class DappRegistrationService {
53
58
 
54
59
  constructor(
55
60
  private context: XyOsContext,
56
- private params: DappRegistrationServiceParams = { dappNames: [], dappParams: {}, dappPayloads: [] },
61
+ private params: DappRegistrationServiceParams = {
62
+ dappNames: [], dappParams: {}, dappPayloads: [],
63
+ },
57
64
  private locator = new ModuleFactoryLocator(),
58
65
  private developmentMode?: boolean,
59
66
  ) {
@@ -76,7 +83,14 @@ export class DappRegistrationService {
76
83
  dappId = NameTransforms.slug(manifest.nodes[0]?.config.name),
77
84
  name = NameTransforms.moduleName(manifest.nodes[0]?.config.name),
78
85
  ): Promisable<XyOsDappContext> {
79
- const dapp = new XyOsDapp({ dapp: { id: dappId, name }, locator: this.locator, manifest, parent: this.context }) as XyOsDappContext
86
+ const dapp = new XyOsDapp({
87
+ dapp: {
88
+ id: dappId, name,
89
+ },
90
+ locator: this.locator,
91
+ manifest,
92
+ parent: this.context,
93
+ }) as XyOsDappContext
80
94
  this.builtDapps[dappId] = dapp
81
95
  return dapp
82
96
  }
@@ -92,7 +106,9 @@ export class DappRegistrationService {
92
106
  activeDapps.map(async (dappSet) => {
93
107
  const { dapp } = dappSet
94
108
  const registeredDapp = await this.dappRegistry.registerDapp(dapp)
95
- const result: RegisteredDappSetResult = { dapp: registeredDapp, dappIcon: dapp.icon }
109
+ const result: RegisteredDappSetResult = {
110
+ dapp: registeredDapp, dappIcon: dapp.icon,
111
+ }
96
112
 
97
113
  // Start post registration process in the background
98
114
  const forgetHandlers = async () => {
@@ -112,7 +128,9 @@ export class DappRegistrationService {
112
128
 
113
129
  for (const registeredDapp of succeeded) this.registeredDappSets.add(registeredDapp)
114
130
 
115
- return { failed, succeeded }
131
+ return {
132
+ failed, succeeded,
133
+ }
116
134
  }
117
135
 
118
136
  private addConnectionRequests() {
@@ -6,7 +6,8 @@ import type {
6
6
  RegisteredDapp,
7
7
  RegisteredDappAccess,
8
8
  UnregisteredDapp,
9
- UnregisteredDappAccess } from '@xyo-network/os-model'
9
+ UnregisteredDappAccess,
10
+ } from '@xyo-network/os-model'
10
11
  import {
11
12
  DappRegisteredSchema,
12
13
  DappRegisteredState,
@@ -15,8 +16,7 @@ import {
15
16
  import type { WithMeta } from '@xyo-network/payload-model'
16
17
 
17
18
  import type { DappSeedPhraseRepository } from '../../wallet/index.ts'
18
- import type {
19
- FailedAccessor } from './ValidateDappAccessDiviner/index.ts'
19
+ import type { FailedAccessor } from './ValidateDappAccessDiviner/index.ts'
20
20
  import {
21
21
  isFailedAccessor,
22
22
  ValidateDappAccessDiviner,
@@ -41,7 +41,9 @@ export class DappRegistry {
41
41
  **/
42
42
  async registerDapp(dapp?: UnregisteredDapp): Promise<RegisteredDapp | null> {
43
43
  if (dapp) {
44
- const { exposedModuleIds, manifest, modes, name, version, params, widgetConfigs } = this.extractDappProperties(dapp)
44
+ const {
45
+ exposedModuleIds, manifest, modes, name, version, params, widgetConfigs,
46
+ } = this.extractDappProperties(dapp)
45
47
 
46
48
  try {
47
49
  /**
@@ -96,10 +98,16 @@ export class DappRegistry {
96
98
  }
97
99
 
98
100
  private extractDappProperties(dapp: UnregisteredDapp) {
99
- const { params, config, widgetConfigs } = dapp
100
- const { exposedModuleIds, manifest, modes, name, sources, version } = config
101
-
102
- return { exposedModuleIds, manifest, modes, name, params, sources, version, widgetConfigs }
101
+ const {
102
+ params, config, widgetConfigs,
103
+ } = dapp
104
+ const {
105
+ exposedModuleIds, manifest, modes, name, sources, version,
106
+ } = config
107
+
108
+ return {
109
+ exposedModuleIds, manifest, modes, name, params, sources, version, widgetConfigs,
110
+ }
103
111
  }
104
112
 
105
113
  private async validateDappAccessPayloads(manifest: DappPackageManifestPayload, accessors: UnregisteredDappAccess[] = [], params: DappParams) {
@@ -1,13 +1,20 @@
1
1
  import type { DivinerParams } from '@xyo-network/diviner-model'
2
2
  import type { PackageManifestPayload } from '@xyo-network/manifest'
3
- import type { DappPackageManifestPayload, DappParams, RegisteredDappAccess, UnregisteredDappAccess } from '@xyo-network/os-model'
4
- import type { Payload, WithMeta } from '@xyo-network/payload-model'
3
+ import type {
4
+ DappPackageManifestPayload, DappParams, RegisteredDappAccess, UnregisteredDappAccess,
5
+ } from '@xyo-network/os-model'
6
+ import type {
7
+ Payload, WithMeta,
8
+ } from '@xyo-network/payload-model'
5
9
  import { isPayloadOfSchemaTypeWithMeta } from '@xyo-network/payload-model'
6
10
 
7
11
  export const FailedAccessorSchema = 'network.xyo.os.failed.accessor.registration' as const
8
12
  export type FailedAccessorSchema = typeof FailedAccessorSchema
9
13
 
10
- export type FailedAccessor = Payload<{ accessor: UnregisteredDappAccess; errorMessage: string }, FailedAccessorSchema>
14
+ export type FailedAccessor = Payload<{
15
+ accessor: UnregisteredDappAccess
16
+ errorMessage: string
17
+ }, FailedAccessorSchema>
11
18
 
12
19
  export const isFailedAccessor = isPayloadOfSchemaTypeWithMeta<FailedAccessor>(FailedAccessorSchema)
13
20
 
@@ -1,14 +1,19 @@
1
1
  import type { Address } from '@xylabs/hex'
2
2
  import { HDWallet } from '@xyo-network/account'
3
3
  import { AbstractDiviner } from '@xyo-network/diviner-abstract'
4
- import type { NodeManifestPayload, PackageManifestPayload } from '@xyo-network/manifest'
5
- import { ManifestWrapper, PackageManifestPayloadSchema } from '@xyo-network/manifest'
4
+ import type {
5
+ NodeManifestPayload, PackageManifestPayload,
6
+ } from '@xyo-network/manifest'
7
+ import {
8
+ ManifestWrapper, PackageManifestPayloadSchema,
9
+ } from '@xyo-network/manifest'
6
10
  import type { NodeInstance } from '@xyo-network/node-model'
7
11
  import type {
8
12
  DappPackageManifestPayload,
9
13
  DappParams,
10
14
  RegisteredDappAccess,
11
- UnregisteredDappAccess } from '@xyo-network/os-model'
15
+ UnregisteredDappAccess,
16
+ } from '@xyo-network/os-model'
12
17
  import {
13
18
  isDappPackageManifestPayload,
14
19
  isUnregisteredDappAccess,
@@ -22,7 +27,8 @@ import type {
22
27
  FailedAccessor,
23
28
  ValidateDappAccessDivinerIn,
24
29
  ValidateDappAccessDivinerOut,
25
- ValidateDappAccessDivinerParams } from './Config.ts'
30
+ ValidateDappAccessDivinerParams,
31
+ } from './Config.ts'
26
32
  import {
27
33
  FailedAccessorSchema,
28
34
  ValidateDappAccessDivinerConfigSchema,
@@ -83,7 +89,9 @@ export class ValidateDappAccessDiviner<TParams extends ValidateDappAccessDiviner
83
89
  }
84
90
  } catch (e) {
85
91
  failedAccessors.push(
86
- await PayloadBuilder.build<FailedAccessor>({ accessor: access, errorMessage: (e as Error).message, schema: FailedAccessorSchema }),
92
+ await PayloadBuilder.build<FailedAccessor>({
93
+ accessor: access, errorMessage: (e as Error).message, schema: FailedAccessorSchema,
94
+ }),
87
95
  )
88
96
  }
89
97
  }
@@ -95,9 +103,7 @@ export class ValidateDappAccessDiviner<TParams extends ValidateDappAccessDiviner
95
103
  const compareChildren = (interfaceChildren: Record<Address, string | null>[], dappChildren: Record<Address, string | null>[]) => {
96
104
  return interfaceChildren.every(interfaceChild =>
97
105
  Object.values(interfaceChild).every(interfaceChildName =>
98
- dappChildren.some(dappChild => Object.values(dappChild).includes(interfaceChildName)),
99
- ),
100
- )
106
+ dappChildren.some(dappChild => Object.values(dappChild).includes(interfaceChildName))))
101
107
  }
102
108
 
103
109
  const dappPackageManifestToPackageManifest = (dappPackageManifest: DappPackageManifestPayload): PackageManifestPayload => {
@@ -1,6 +1,8 @@
1
1
  import { assertEx } from '@xylabs/assert'
2
2
  import { isEqual } from '@xylabs/lodash'
3
- import type { NodeBackground, WalletSeedPhrase, XyOsContext } from '@xyo-network/os-model'
3
+ import type {
4
+ NodeBackground, WalletSeedPhrase, XyOsContext,
5
+ } from '@xyo-network/os-model'
4
6
  import type { WithMeta } from '@xyo-network/payload-model'
5
7
 
6
8
  import { buildUserWalletSeedPhrasePayload } from '../../utils/index.ts'
@@ -1,8 +1,14 @@
1
1
  import { assertEx } from '@xylabs/assert'
2
- import type { NodeBackground, WalletSeedPhrase, XyOsContext } from '@xyo-network/os-model'
3
- import { isNodeBackground, isWalletSeedPhrase } from '@xyo-network/os-model'
2
+ import type {
3
+ NodeBackground, WalletSeedPhrase, XyOsContext,
4
+ } from '@xyo-network/os-model'
5
+ import {
6
+ isNodeBackground, isWalletSeedPhrase,
7
+ } from '@xyo-network/os-model'
4
8
 
5
- import type { Listener, ResourceStore } from '../../lib/index.ts'
9
+ import type {
10
+ Listener, ResourceStore,
11
+ } from '../../lib/index.ts'
6
12
  import { PayloadStore } from '../../lib/index.ts'
7
13
  import { OsSettingsCallerBase } from './CallerBase.ts'
8
14
  import { OsSettingsQueries } from './SettingsQueries.ts'
@@ -1,7 +1,11 @@
1
1
  import type { DivinerInstance } from '@xyo-network/diviner-model'
2
2
  import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
3
- import type { NodeBackground, WalletSeedPhrase } from '@xyo-network/os-model'
4
- import { NodeBackgroundSchema, WalletSeedPhraseSchema } from '@xyo-network/os-model'
3
+ import type {
4
+ NodeBackground, WalletSeedPhrase,
5
+ } from '@xyo-network/os-model'
6
+ import {
7
+ NodeBackgroundSchema, WalletSeedPhraseSchema,
8
+ } from '@xyo-network/os-model'
5
9
  import type { WithMeta } from '@xyo-network/payload-model'
6
10
 
7
11
  const NO_RESULTS: WithMeta<WalletSeedPhrase>[] = []
@@ -1,5 +1,7 @@
1
1
  import { assertEx } from '@xylabs/assert'
2
- import type { OsBadge, XyOsContext } from '@xyo-network/os-model'
2
+ import type {
3
+ OsBadge, XyOsContext,
4
+ } from '@xyo-network/os-model'
3
5
  import { isBadgeWithMeta } from '@xyo-network/os-model'
4
6
 
5
7
  import type { ResourceStore } from '../../../lib/index.ts'
@@ -23,15 +25,11 @@ export class OsBadgeResource extends OsSettingsCallerBase implements ResourceSto
23
25
  }
24
26
 
25
27
  get subscriptions() {
26
- return {
27
- savedSeedPhrase: (cb: () => void) => this.savedSeedPhrase.subscribe(cb),
28
- }
28
+ return { savedSeedPhrase: (cb: () => void) => this.savedSeedPhrase.subscribe(cb) }
29
29
  }
30
30
 
31
31
  get views() {
32
- return {
33
- savedSeedPhrase: () => this.savedSeedPhrase.latest,
34
- }
32
+ return { savedSeedPhrase: () => this.savedSeedPhrase.latest }
35
33
  }
36
34
 
37
35
  cleanupListeners() {
@@ -1,6 +1,8 @@
1
1
  import type { ArchivistInstance } from '@xyo-network/archivist-model'
2
2
  import type { ModuleFactoryLocator } from '@xyo-network/module-factory-locator'
3
- import type { DappConfig, DappIcon, DappParams, DappSet, PayloadWithVersion, XyOsContext } from '@xyo-network/os-model'
3
+ import type {
4
+ DappConfig, DappIcon, DappParams, DappSet, PayloadWithVersion, XyOsContext,
5
+ } from '@xyo-network/os-model'
4
6
  import { PayloadBuilder } from '@xyo-network/payload-builder'
5
7
  import type { WithMeta } from '@xyo-network/payload-model'
6
8
  import semver from 'semver'
@@ -9,7 +11,10 @@ import { OsCallerBase } from '../../OsCallerBase.ts'
9
11
  import { SystemDappQueries } from './Queries.ts'
10
12
 
11
13
  export type ErrorListener = (failedPayloads: DappConfig[]) => void
12
- export type DappSetsAndPayloads = { dappPayloads: (DappConfig | DappIcon)[]; dappSets: DappSet[] }
14
+ export type DappSetsAndPayloads = {
15
+ dappPayloads: (DappConfig | DappIcon)[]
16
+ dappSets: DappSet[]
17
+ }
13
18
 
14
19
  /**
15
20
  * Manage the installation of system dapps from payloads and return the built sets
@@ -5,7 +5,8 @@ import type {
5
5
  DappIcon,
6
6
  DappId,
7
7
  DappWidgetConfig,
8
- UnregisteredDappAccess } from '@xyo-network/os-model'
8
+ UnregisteredDappAccess,
9
+ } from '@xyo-network/os-model'
9
10
  import {
10
11
  DappConfigSchema,
11
12
  DappIconSchema,
@@ -2,7 +2,9 @@ import { assertEx } from '@xylabs/assert'
2
2
  import type { BaseParams } from '@xylabs/object'
3
3
  import { BaseEmitter } from '@xyo-network/module-abstract'
4
4
  import type { EventData } from '@xyo-network/module-events'
5
- import type { EventBusConnectionInterface, EventBusConnectionRequest, EventBusConnectionType } from '@xyo-network/os-model'
5
+ import type {
6
+ EventBusConnectionInterface, EventBusConnectionRequest, EventBusConnectionType,
7
+ } from '@xyo-network/os-model'
6
8
 
7
9
  /**
8
10
  * A Generic Connection to add to an EventBus
@@ -1,13 +1,16 @@
1
1
  import { assertEx } from '@xylabs/assert'
2
2
  import { forget } from '@xylabs/forget'
3
3
  import type { ArchivistModuleEventData } from '@xyo-network/archivist'
4
- import { asArchivistInstance, MemoryArchivist, MemoryArchivistConfigSchema } from '@xyo-network/archivist'
4
+ import {
5
+ asArchivistInstance, MemoryArchivist, MemoryArchivistConfigSchema,
6
+ } from '@xyo-network/archivist'
5
7
  import type {
6
8
  EventBusConnectionInterface,
7
9
  EventBusEvent,
8
10
  EventBusInterface,
9
11
  EventBusPubSubConnectionInterface,
10
- PublisherEventListener } from '@xyo-network/os-model'
12
+ PublisherEventListener,
13
+ } from '@xyo-network/os-model'
11
14
  import {
12
15
  isEventBusEvent,
13
16
  isPubSubConnections,
@@ -76,7 +79,11 @@ export class EventBus implements EventBusInterface {
76
79
 
77
80
  async start(storeName = 'EventBusArchivist') {
78
81
  // Later versions could include a node that has a payload diviner to query past events
79
- this._archivist = await MemoryArchivist.create({ config: { name: storeName, schema: MemoryArchivistConfigSchema } })
82
+ this._archivist = await MemoryArchivist.create({
83
+ config: {
84
+ name: storeName, schema: MemoryArchivistConfigSchema,
85
+ },
86
+ })
80
87
 
81
88
  // start listening to inserted events from publishers
82
89
  // NOTE: This is a very basic implementation and could be optimized by indexing on connection, eventName, and callback
@@ -112,7 +119,9 @@ export class EventBus implements EventBusInterface {
112
119
  // Create publisher callback
113
120
  const connectionPublisherCallback: PublisherEventListener = async ({ payloads }) => {
114
121
  // build the event payload
115
- const event: EventBusEvent = { name: eventName, schema: 'network.xyo.event.bus.event' }
122
+ const event: EventBusEvent = {
123
+ name: eventName, schema: 'network.xyo.event.bus.event',
124
+ }
116
125
  const eventPayloads = payloads ?? []
117
126
  event.sources = await PayloadBuilder.dataHashes(eventPayloads)
118
127
  // Sync events to archivist
@@ -3,18 +3,18 @@ import type { XyOsGlobal } from '@xyo-network/os-model'
3
3
  import type { MonitorEventConfig } from './types.ts'
4
4
 
5
5
  // See - https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation
6
- export type Connection = { downlink: number; effectiveType: string; rtt: number }
6
+ export type Connection = {
7
+ downlink: number
8
+ effectiveType: string
9
+ rtt: number
10
+ }
7
11
 
8
12
  const DEFAULT_MONITORING_EVENT_NAME = 'System Task Duration'
9
13
 
10
14
  globalThis.getXyOsGlobal
11
15
  = globalThis.getXyOsGlobal
12
16
  ?? ((): XyOsGlobal => {
13
- return {
14
- tracking: {
15
- trackEvent: (_event: string, _properties?: Record<string, unknown>) => void {},
16
- },
17
- }
17
+ return { tracking: { trackEvent: (_event: string, _properties?: Record<string, unknown>) => void {} } }
18
18
  })
19
19
 
20
20
  // TODO: Make this node compatible
@@ -30,7 +30,9 @@ export abstract class XyOsMonitor {
30
30
  }
31
31
 
32
32
  stopTimer(eventConfig: MonitorEventConfig): void {
33
- const { additionalProperties, name } = eventConfig
33
+ const {
34
+ additionalProperties, name,
35
+ } = eventConfig
34
36
  const start = this.performanceTimers.get(name)
35
37
  if (start) {
36
38
  const end = performance.now()
@@ -2,4 +2,7 @@ import type { JsonObject } from '@xylabs/object'
2
2
 
3
3
  export type MonitorEventNames = 'Load XyOs' | 'Install System dApps' | 'Expose dApps' | 'Loading dApp'
4
4
 
5
- export type MonitorEventConfig = { additionalProperties?: JsonObject; name: MonitorEventNames }
5
+ export type MonitorEventConfig = {
6
+ additionalProperties?: JsonObject
7
+ name: MonitorEventNames
8
+ }
@@ -1,6 +1,10 @@
1
1
  import { PayloadDivinerQuerySchema } from '@xyo-network/diviner-payload-model'
2
- import type { DappId, DappIntent, DappIntentTypes, XyOsContext } from '@xyo-network/os-model'
3
- import { DappIntentSchema, DappMode } from '@xyo-network/os-model'
2
+ import type {
3
+ DappId, DappIntent, DappIntentTypes, XyOsContext,
4
+ } from '@xyo-network/os-model'
5
+ import {
6
+ DappIntentSchema, DappMode,
7
+ } from '@xyo-network/os-model'
4
8
  import type { WithMeta } from '@xyo-network/payload-model'
5
9
 
6
10
  import { DappCallerBase } from '../DappCallerBase.ts'
@@ -1,10 +1,14 @@
1
1
  import { assertEx } from '@xylabs/assert'
2
- import type { DappIntent, XyOsContext } from '@xyo-network/os-model'
2
+ import type {
3
+ DappIntent, XyOsContext,
4
+ } from '@xyo-network/os-model'
3
5
  import { isDappIntent } from '@xyo-network/os-model'
4
6
  import type { WithMeta } from '@xyo-network/payload-model'
5
7
 
6
8
  import { DappCallerBase } from '../DappCallerBase.ts'
7
- import type { Listener, ResourceStore } from '../lib/index.ts'
9
+ import type {
10
+ Listener, ResourceStore,
11
+ } from '../lib/index.ts'
8
12
  import { PayloadStore } from '../lib/index.ts'
9
13
 
10
14
  export type DappIntentViews = 'latestDappIntent' | 'allDappIntents'
@@ -1,15 +1,11 @@
1
- import { DevelopArchivist, NodeSentinel } from './ModuleNames.ts'
1
+ import {
2
+ DevelopArchivist, NodeSentinel,
3
+ } from './ModuleNames.ts'
2
4
 
3
5
  export const RemoteNodeArchivistOffsetPaths: Record<string, Record<string, string>> = {
4
- Kerplunk: {
5
- [DevelopArchivist]: '118',
6
- },
7
- Local: {
8
- [DevelopArchivist]: '115',
9
- },
10
- Main: {
11
- [DevelopArchivist]: '121',
12
- },
6
+ Kerplunk: { [DevelopArchivist]: '118' },
7
+ Local: { [DevelopArchivist]: '115' },
8
+ Main: { [DevelopArchivist]: '121' },
13
9
  }
14
10
 
15
11
  export const ModuleOffsetPaths: Record<string, string> = {
@@ -1,5 +1,9 @@
1
- import type { ArchivistInstance, ArchivistModuleEventData } from '@xyo-network/archivist'
2
- import type { Payload, WithMeta, WithSources } from '@xyo-network/payload-model'
1
+ import type {
2
+ ArchivistInstance, ArchivistModuleEventData,
3
+ } from '@xyo-network/archivist'
4
+ import type {
5
+ Payload, WithMeta, WithSources,
6
+ } from '@xyo-network/payload-model'
3
7
 
4
8
  import type { ExternalStore } from './ExternalStore.ts'
5
9
  import type { Listener } from './Listener.ts'
@@ -21,7 +25,9 @@ export class PayloadStore<T extends Payload = Payload> implements ExternalStore
21
25
  /**
22
26
  * Initialize listeners on the archivist that update class member variables when new payloads are inserted
23
27
  */
24
- static async create<T extends Payload = Payload>({ archivist, getLatest, idFunction }: PayloadStoreConfig<T>) {
28
+ static async create<T extends Payload = Payload>({
29
+ archivist, getLatest, idFunction,
30
+ }: PayloadStoreConfig<T>) {
25
31
  const instance = new this<T>(archivist)
26
32
 
27
33
  const insertListener = async ({ payloads }: ArchivistModuleEventData['inserted']) => {
@@ -1,5 +1,7 @@
1
1
  import { AsObjectFactory } from '@xylabs/object'
2
- import type { Payload, Schema } from '@xyo-network/payload-model'
2
+ import type {
3
+ Payload, Schema,
4
+ } from '@xyo-network/payload-model'
3
5
 
4
6
  export const isObject = (x: unknown): x is Record<string | symbol | number, unknown> => {
5
7
  return typeof x === 'object' && !Array.isArray(x)
@@ -1,9 +1,10 @@
1
1
  import { getXnsDomain } from '@xyo-network/kernel'
2
2
  import type { Payload } from '@xyo-network/payload-model'
3
3
 
4
- export const ManifestReplaceableTokens = (xnsNodeUrl: string | undefined, xnsNetwork: string | undefined) => ({
5
- '[REPLACE_WITH_NS_NODE_URL]': getXnsDomain(xnsNodeUrl, xnsNetwork),
6
- })
4
+ export const ManifestReplaceableTokens = (
5
+ xnsNodeUrl: string | undefined,
6
+ xnsNetwork: string | undefined,
7
+ ) => ({ '[REPLACE_WITH_NS_NODE_URL]': getXnsDomain(xnsNodeUrl, xnsNetwork) })
7
8
 
8
9
  export const ReplaceManifestTokens = (manifest: Payload, xnsNodeUrl: string | undefined, xnsNetwork: string | undefined) => {
9
10
  // Replace ReplaceableTokens in the manifest
@@ -17,12 +17,16 @@ export const profileModuleEvents = (mod: ModuleInstance) => {
17
17
  mod.onAny(async (eventName, args) => {
18
18
  const mod = modRef.deref()
19
19
  if (mod) {
20
- const data = profileData[mod.address] ?? { allEventCount: 0, eventCounts: {} }
20
+ const data = profileData[mod.address] ?? {
21
+ allEventCount: 0, eventCounts: {},
22
+ }
21
23
  profileData[mod.address] = data
22
24
  data.allEventCount += 1
23
25
  data.eventCounts[eventName] = (data.eventCounts[eventName] ?? 0) + 1
24
26
  if (eventName === 'querySendStarted') {
25
- const { query, payloads = [] } = args as QuerySendStartedEventArgs
27
+ const {
28
+ query, payloads = [],
29
+ } = args as QuerySendStartedEventArgs
26
30
  const pairs = await PayloadBuilder.dataHashPairs(payloads)
27
31
  const foundPair = pairs.find(([, hash]) => hash === query.query)
28
32
  if (foundPair) {