@xyo-network/module-factory-locator 5.3.20 → 5.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/module-factory-locator",
3
- "version": "5.3.20",
3
+ "version": "5.3.24",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,38 +30,60 @@
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "src",
34
33
  "!**/*.bench.*",
35
34
  "!**/*.spec.*",
36
- "!**/*.test.*"
35
+ "!**/*.test.*",
36
+ "README.md"
37
37
  ],
38
38
  "dependencies": {
39
- "@xyo-network/archivist-memory": "~5.3.20",
40
- "@xyo-network/archivist-view": "~5.3.20",
41
- "@xyo-network/bridge-http": "~5.3.20",
42
- "@xyo-network/diviner-boundwitness-memory": "~5.3.20",
43
- "@xyo-network/diviner-identity": "~5.3.20",
44
- "@xyo-network/diviner-payload-generic": "~5.3.20",
45
- "@xyo-network/module-model": "~5.3.20",
46
- "@xyo-network/node-memory": "~5.3.20",
47
- "@xyo-network/node-view": "~5.3.20",
48
- "@xyo-network/payload-model": "~5.3.20",
49
- "@xyo-network/sentinel-memory": "~5.3.20",
50
- "@xyo-network/witness-adhoc": "~5.3.20"
39
+ "@xyo-network/archivist-view": "~5.3.24",
40
+ "@xyo-network/diviner-identity": "~5.3.24",
41
+ "@xyo-network/diviner-payload-generic": "~5.3.24",
42
+ "@xyo-network/bridge-http": "~5.3.24",
43
+ "@xyo-network/module-model": "~5.3.24",
44
+ "@xyo-network/archivist-memory": "~5.3.24",
45
+ "@xyo-network/payload-model": "~5.3.24",
46
+ "@xyo-network/node-memory": "~5.3.24",
47
+ "@xyo-network/node-view": "~5.3.24",
48
+ "@xyo-network/diviner-boundwitness-memory": "~5.3.24",
49
+ "@xyo-network/sentinel-memory": "~5.3.24",
50
+ "@xyo-network/witness-adhoc": "~5.3.24"
51
51
  },
52
52
  "devDependencies": {
53
- "@xylabs/sdk-js": "^5.0.90",
54
- "@xylabs/ts-scripts-common": "~7.5.6",
55
- "@xylabs/ts-scripts-yarn3": "~7.5.6",
56
- "@xylabs/tsconfig": "~7.5.6",
53
+ "@opentelemetry/api": "^1.9.1",
54
+ "@types/node": "^25.5.0",
55
+ "@xylabs/sdk-js": "^5.0.93",
56
+ "@xylabs/ts-scripts-common": "~7.6.16",
57
+ "@xylabs/ts-scripts-pnpm": "~7.6.16",
58
+ "@xylabs/tsconfig": "~7.6.16",
59
+ "acorn": "^8.16.0",
60
+ "axios": "^1.14.0",
61
+ "esbuild": "^0.28.0",
62
+ "ethers": "^6.16.0",
63
+ "tslib": "^2.8.1",
57
64
  "typescript": "~5.9.3",
58
- "zod": "^4.3.6"
65
+ "zod": "^4.3.6",
66
+ "@xyo-network/archivist-view": "~5.3.24",
67
+ "@xyo-network/archivist-memory": "~5.3.24",
68
+ "@xyo-network/bridge-http": "~5.3.24",
69
+ "@xyo-network/diviner-payload-generic": "~5.3.24",
70
+ "@xyo-network/diviner-boundwitness-memory": "~5.3.24",
71
+ "@xyo-network/diviner-identity": "~5.3.24",
72
+ "@xyo-network/module-model": "~5.3.24",
73
+ "@xyo-network/node-view": "~5.3.24",
74
+ "@xyo-network/node-memory": "~5.3.24",
75
+ "@xyo-network/payload-model": "~5.3.24",
76
+ "@xyo-network/sentinel-memory": "~5.3.24",
77
+ "@xyo-network/witness-adhoc": "~5.3.24"
59
78
  },
60
79
  "peerDependencies": {
61
80
  "@xylabs/sdk-js": "^5",
81
+ "axios": "^1",
82
+ "ethers": "^6",
83
+ "tslib": "^2.8.1",
62
84
  "zod": "^4"
63
85
  },
64
86
  "publishConfig": {
65
87
  "access": "public"
66
88
  }
67
- }
89
+ }
@@ -1,111 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
2
- import type {
3
- CreatableModuleFactory,
4
- CreatableModuleRegistry,
5
- LabeledCreatableModuleFactory,
6
- Labels,
7
- ModuleFactoryLocatorInstance,
8
- } from '@xyo-network/module-model'
9
- import {
10
- hasAllLabels,
11
- hasLabels,
12
- registerCreatableModuleFactory,
13
- } from '@xyo-network/module-model'
14
- import { asSchema, type Schema } from '@xyo-network/payload-model'
15
-
16
- import { standardCreatableFactories } from './standardCreatableFactories.ts'
17
-
18
- /**
19
- * A class which encapsulates the Service Locator Pattern for Module Factories
20
- */
21
- export class ModuleFactoryLocator implements ModuleFactoryLocatorInstance {
22
- protected readonly _registry: CreatableModuleRegistry
23
-
24
- private _frozen = false
25
-
26
- constructor(_registry: CreatableModuleRegistry = standardCreatableFactories()) {
27
- this._registry = _registry
28
- }
29
-
30
- /**
31
- * The current registry for the module factory
32
- */
33
- get registry(): Readonly<CreatableModuleRegistry> {
34
- return this._registry
35
- }
36
-
37
- static empty() {
38
- return new ModuleFactoryLocator({})
39
- }
40
-
41
- static standard() {
42
- return new ModuleFactoryLocator(standardCreatableFactories())
43
- }
44
-
45
- freeze() {
46
- this._frozen = true
47
- }
48
-
49
- /**
50
- * Locates a module factory that matches the supplied schema and labels
51
- * @param schema The config schema for the module
52
- * @param labels The labels for the module factory
53
- * @returns A module factory that matches the supplied schema and labels or throws if one is not found
54
- */
55
- locate(schema: Schema, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory {
56
- return assertEx(
57
- this.tryLocate(schema, labels),
58
-
59
- () => `No module factory for the supplied config schema [${schema}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ''} registered`,
60
- )
61
- }
62
-
63
- merge(locator: ModuleFactoryLocatorInstance): ModuleFactoryLocatorInstance {
64
- const registry = { ...this.registry }
65
- for (const schema in locator.registry) {
66
- const typedSchema = asSchema(schema, true)
67
- if (registry[typedSchema]) {
68
- registry[typedSchema].push(...(locator.registry[typedSchema] ?? []))
69
- } else {
70
- registry[typedSchema] = locator.registry[typedSchema]
71
- }
72
- }
73
- return new ModuleFactoryLocator(registry)
74
- }
75
-
76
- /**
77
- * Registers a single module factory (with optional tags) with the locator
78
- * @param factory The factory to register
79
- * @param labels The labels for the module factory
80
- */
81
- register(factory: CreatableModuleFactory, labels?: Labels, primary: boolean | Schema | Schema[] = false): this {
82
- assertEx(!this._frozen, () => 'Cannot register a module factory after the locator has been frozen')
83
- registerCreatableModuleFactory(this._registry, factory, labels, primary)
84
- return this
85
- }
86
-
87
- /**
88
- * Registers multiple module factories with the locator
89
- * @param factories The factories to register
90
- */
91
- registerMany(factories: CreatableModuleFactory[]): this {
92
- for (const factory of factories) {
93
- this.register(factory)
94
- }
95
- return this
96
- }
97
-
98
- /**
99
- * Tries to locate a module factory that matches the supplied schema and labels
100
- * @param schema The config schema for the module
101
- * @param labels The labels for the module factory
102
- * @returns A module factory that matches the supplied schema and labels or undefined
103
- */
104
- tryLocate(schema: Schema, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory | undefined {
105
- return labels
106
- // Find the first factory that has labels and has all the labels provided
107
- ? (this._registry[schema]?.filter(hasLabels).find(factory => hasAllLabels(factory?.labels, labels)) ?? this._registry[schema]?.[0])
108
- // Otherwise, return the first factory
109
- : this._registry[schema]?.[0]
110
- }
111
- }
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './ModuleFactoryLocator.ts'
2
- export * from './standardCreatableFactories.ts'
@@ -1,32 +0,0 @@
1
- import { MemoryArchivist } from '@xyo-network/archivist-memory'
2
- import { ViewArchivist } from '@xyo-network/archivist-view'
3
- import { HttpBridge } from '@xyo-network/bridge-http'
4
- import { MemoryBoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-memory'
5
- import { IdentityDiviner } from '@xyo-network/diviner-identity'
6
- import { GenericPayloadDiviner } from '@xyo-network/diviner-payload-generic'
7
- import type { CreatableModuleFactory, LabeledCreatableModuleFactory } from '@xyo-network/module-model'
8
- import { registerCreatableModuleFactories } from '@xyo-network/module-model'
9
- import { MemoryNode } from '@xyo-network/node-memory'
10
- import { ViewNode } from '@xyo-network/node-view'
11
- import { MemorySentinel } from '@xyo-network/sentinel-memory'
12
- import { AdhocWitness } from '@xyo-network/witness-adhoc'
13
-
14
- // order matters in this array. later items will register themselves as primary for schemas shared with earlier items
15
- export const standardCreatableModulesList: (CreatableModuleFactory | LabeledCreatableModuleFactory)[] = [
16
- HttpBridge.factory(),
17
- ViewArchivist.factory(),
18
- ViewNode.factory(),
19
- AdhocWitness.factory(),
20
- GenericPayloadDiviner.factory(),
21
- MemoryBoundWitnessDiviner.factory(),
22
- IdentityDiviner.factory(),
23
- MemoryArchivist.factory(),
24
- MemoryArchivist.factory(),
25
- MemoryNode.factory(),
26
- MemorySentinel.factory(),
27
- GenericPayloadDiviner.factory(),
28
- ]
29
-
30
- export const standardCreatableFactories = () => {
31
- return registerCreatableModuleFactories(standardCreatableModulesList, {}, true)
32
- }