@xyo-network/module-factory-locator 7.0.9 → 7.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/index.d.ts +1 -2
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +2 -120
- package/dist/neutral/index.mjs.map +3 -3
- package/package.json +8 -17
- package/dist/neutral/ModuleFactoryLocator.d.ts +0 -44
- package/dist/neutral/ModuleFactoryLocator.d.ts.map +0 -1
- package/dist/neutral/standardCreatableFactories.d.ts +0 -4
- package/dist/neutral/standardCreatableFactories.d.ts.map +0 -1
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,yCAAyC,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,121 +1,3 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
hasAllLabels,
|
|
5
|
-
hasLabels,
|
|
6
|
-
registerCreatableModuleFactory
|
|
7
|
-
} from "@xyo-network/module-model";
|
|
8
|
-
import { asSchema } from "@xyo-network/sdk-protocol";
|
|
9
|
-
|
|
10
|
-
// src/standardCreatableFactories.ts
|
|
11
|
-
import { MemoryArchivist } from "@xyo-network/archivist-memory";
|
|
12
|
-
import { ViewArchivist } from "@xyo-network/archivist-view";
|
|
13
|
-
import { HttpBridge } from "@xyo-network/bridge-http";
|
|
14
|
-
import { MemoryBoundWitnessDiviner } from "@xyo-network/diviner-boundwitness/memory";
|
|
15
|
-
import { IdentityDiviner } from "@xyo-network/diviner-identity";
|
|
16
|
-
import { GenericPayloadDiviner } from "@xyo-network/diviner-payload-generic";
|
|
17
|
-
import { registerCreatableModuleFactories } from "@xyo-network/module-model";
|
|
18
|
-
import { MemoryNode } from "@xyo-network/node-memory";
|
|
19
|
-
import { ViewNode } from "@xyo-network/node-view";
|
|
20
|
-
import { MemorySentinel } from "@xyo-network/sentinel-memory";
|
|
21
|
-
import { AdhocWitness } from "@xyo-network/witness-adhoc";
|
|
22
|
-
var standardCreatableModulesList = [
|
|
23
|
-
HttpBridge.factory(),
|
|
24
|
-
ViewArchivist.factory(),
|
|
25
|
-
ViewNode.factory(),
|
|
26
|
-
AdhocWitness.factory(),
|
|
27
|
-
GenericPayloadDiviner.factory(),
|
|
28
|
-
MemoryBoundWitnessDiviner.factory(),
|
|
29
|
-
IdentityDiviner.factory(),
|
|
30
|
-
MemoryArchivist.factory(),
|
|
31
|
-
MemoryArchivist.factory(),
|
|
32
|
-
MemoryNode.factory(),
|
|
33
|
-
MemorySentinel.factory(),
|
|
34
|
-
GenericPayloadDiviner.factory()
|
|
35
|
-
];
|
|
36
|
-
var standardCreatableFactories = () => {
|
|
37
|
-
return registerCreatableModuleFactories(standardCreatableModulesList, {}, true);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// src/ModuleFactoryLocator.ts
|
|
41
|
-
var ModuleFactoryLocator = class _ModuleFactoryLocator {
|
|
42
|
-
_registry;
|
|
43
|
-
_frozen = false;
|
|
44
|
-
constructor(_registry = standardCreatableFactories()) {
|
|
45
|
-
this._registry = _registry;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The current registry for the module factory
|
|
49
|
-
*/
|
|
50
|
-
get registry() {
|
|
51
|
-
return this._registry;
|
|
52
|
-
}
|
|
53
|
-
static empty() {
|
|
54
|
-
return new _ModuleFactoryLocator({});
|
|
55
|
-
}
|
|
56
|
-
static standard() {
|
|
57
|
-
return new _ModuleFactoryLocator(standardCreatableFactories());
|
|
58
|
-
}
|
|
59
|
-
freeze() {
|
|
60
|
-
this._frozen = true;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Locates a module factory that matches the supplied schema and labels
|
|
64
|
-
* @param schema The config schema for the module
|
|
65
|
-
* @param labels The labels for the module factory
|
|
66
|
-
* @returns A module factory that matches the supplied schema and labels or throws if one is not found
|
|
67
|
-
*/
|
|
68
|
-
locate(schema, labels) {
|
|
69
|
-
return assertEx(
|
|
70
|
-
this.tryLocate(schema, labels),
|
|
71
|
-
() => `No module factory for the supplied config schema [${schema}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} registered`
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
merge(locator) {
|
|
75
|
-
const registry = { ...this.registry };
|
|
76
|
-
for (const schema in locator.registry) {
|
|
77
|
-
const typedSchema = asSchema(schema, true);
|
|
78
|
-
if (registry[typedSchema]) {
|
|
79
|
-
registry[typedSchema].push(...locator.registry[typedSchema] ?? []);
|
|
80
|
-
} else {
|
|
81
|
-
registry[typedSchema] = locator.registry[typedSchema];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return new _ModuleFactoryLocator(registry);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Registers a single module factory (with optional tags) with the locator
|
|
88
|
-
* @param factory The factory to register
|
|
89
|
-
* @param labels The labels for the module factory
|
|
90
|
-
*/
|
|
91
|
-
register(factory, labels, primary = false) {
|
|
92
|
-
assertEx(!this._frozen, () => "Cannot register a module factory after the locator has been frozen");
|
|
93
|
-
registerCreatableModuleFactory(this._registry, factory, labels, primary);
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Registers multiple module factories with the locator
|
|
98
|
-
* @param factories The factories to register
|
|
99
|
-
*/
|
|
100
|
-
registerMany(factories) {
|
|
101
|
-
for (const factory of factories) {
|
|
102
|
-
this.register(factory);
|
|
103
|
-
}
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Tries to locate a module factory that matches the supplied schema and labels
|
|
108
|
-
* @param schema The config schema for the module
|
|
109
|
-
* @param labels The labels for the module factory
|
|
110
|
-
* @returns A module factory that matches the supplied schema and labels or undefined
|
|
111
|
-
*/
|
|
112
|
-
tryLocate(schema, labels) {
|
|
113
|
-
return labels ? this._registry[schema]?.filter(hasLabels).find((factory) => hasAllLabels(factory?.labels, labels)) ?? this._registry[schema]?.[0] : this._registry[schema]?.[0];
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
export {
|
|
117
|
-
ModuleFactoryLocator,
|
|
118
|
-
standardCreatableFactories,
|
|
119
|
-
standardCreatableModulesList
|
|
120
|
-
};
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@xyo-network/sdk/module-factory-locator";
|
|
121
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Compatibility shim: this package re-exports from @xyo-network/sdk.\nexport * from '@xyo-network/sdk/module-factory-locator'\n"],
|
|
5
|
+
"mappings": ";AACA,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/module-factory-locator",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.10",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -34,17 +34,7 @@
|
|
|
34
34
|
"README.md"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@xyo-network/
|
|
38
|
-
"@xyo-network/archivist-view": "~7.0.9",
|
|
39
|
-
"@xyo-network/diviner-boundwitness": "~7.0.9",
|
|
40
|
-
"@xyo-network/module-model": "~7.0.9",
|
|
41
|
-
"@xyo-network/node-memory": "~7.0.9",
|
|
42
|
-
"@xyo-network/node-view": "~7.0.9",
|
|
43
|
-
"@xyo-network/sentinel-memory": "~7.0.9",
|
|
44
|
-
"@xyo-network/witness-adhoc": "~7.0.9",
|
|
45
|
-
"@xyo-network/diviner-identity": "~7.0.9",
|
|
46
|
-
"@xyo-network/bridge-http": "~7.0.9",
|
|
47
|
-
"@xyo-network/diviner-payload-generic": "~7.0.9"
|
|
37
|
+
"@xyo-network/sdk": "~7.0.10"
|
|
48
38
|
},
|
|
49
39
|
"devDependencies": {
|
|
50
40
|
"@ariestools/sdk": "~8.0.2",
|
|
@@ -56,9 +46,9 @@
|
|
|
56
46
|
"@opentelemetry/sdk-trace-base": "~2.9.0",
|
|
57
47
|
"@scure/base": "~2.2.0",
|
|
58
48
|
"@scure/bip39": "~2.2.0",
|
|
59
|
-
"@xylabs/toolchain": "~8.6.
|
|
60
|
-
"@xylabs/tsconfig": "~8.6.
|
|
61
|
-
"@xyo-network/sdk-protocol": "~7.0.
|
|
49
|
+
"@xylabs/toolchain": "~8.6.8",
|
|
50
|
+
"@xylabs/tsconfig": "~8.6.8",
|
|
51
|
+
"@xyo-network/sdk-protocol": "~7.0.15",
|
|
62
52
|
"ajv": "~8.20.0",
|
|
63
53
|
"async-mutex": "~0.5.0",
|
|
64
54
|
"debug": "~4.4.3",
|
|
@@ -83,7 +73,7 @@
|
|
|
83
73
|
"@opentelemetry/sdk-trace-base": "^2.9.0",
|
|
84
74
|
"@scure/base": "^2.2.0",
|
|
85
75
|
"@scure/bip39": "^2.2.0",
|
|
86
|
-
"@xyo-network/sdk-protocol": "^7.0.
|
|
76
|
+
"@xyo-network/sdk-protocol": "^7.0.15",
|
|
87
77
|
"ajv": "^8.20.0",
|
|
88
78
|
"async-mutex": "^0.5.0",
|
|
89
79
|
"debug": "^4.4.3",
|
|
@@ -100,5 +90,6 @@
|
|
|
100
90
|
},
|
|
101
91
|
"publishConfig": {
|
|
102
92
|
"access": "public"
|
|
103
|
-
}
|
|
93
|
+
},
|
|
94
|
+
"deprecated": "Use @xyo-network/sdk/module-factory-locator instead. Replace @xyo-network/module-factory-locator with @xyo-network/sdk/module-factory-locator. This package is a compatibility shim only and will not receive further updates."
|
|
104
95
|
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { CreatableModuleFactory, CreatableModuleRegistry, LabeledCreatableModuleFactory, Labels, ModuleFactoryLocatorInstance } from '@xyo-network/module-model';
|
|
2
|
-
import { type Schema } from '@xyo-network/sdk-protocol';
|
|
3
|
-
/**
|
|
4
|
-
* A class which encapsulates the Service Locator Pattern for Module Factories
|
|
5
|
-
*/
|
|
6
|
-
export declare class ModuleFactoryLocator implements ModuleFactoryLocatorInstance {
|
|
7
|
-
protected readonly _registry: CreatableModuleRegistry;
|
|
8
|
-
private _frozen;
|
|
9
|
-
constructor(_registry?: CreatableModuleRegistry);
|
|
10
|
-
/**
|
|
11
|
-
* The current registry for the module factory
|
|
12
|
-
*/
|
|
13
|
-
get registry(): Readonly<CreatableModuleRegistry>;
|
|
14
|
-
static empty(): ModuleFactoryLocator;
|
|
15
|
-
static standard(): ModuleFactoryLocator;
|
|
16
|
-
freeze(): void;
|
|
17
|
-
/**
|
|
18
|
-
* Locates a module factory that matches the supplied schema and labels
|
|
19
|
-
* @param schema The config schema for the module
|
|
20
|
-
* @param labels The labels for the module factory
|
|
21
|
-
* @returns A module factory that matches the supplied schema and labels or throws if one is not found
|
|
22
|
-
*/
|
|
23
|
-
locate(schema: Schema, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory;
|
|
24
|
-
merge(locator: ModuleFactoryLocatorInstance): ModuleFactoryLocatorInstance;
|
|
25
|
-
/**
|
|
26
|
-
* Registers a single module factory (with optional tags) with the locator
|
|
27
|
-
* @param factory The factory to register
|
|
28
|
-
* @param labels The labels for the module factory
|
|
29
|
-
*/
|
|
30
|
-
register(factory: CreatableModuleFactory, labels?: Labels, primary?: boolean | Schema | Schema[]): this;
|
|
31
|
-
/**
|
|
32
|
-
* Registers multiple module factories with the locator
|
|
33
|
-
* @param factories The factories to register
|
|
34
|
-
*/
|
|
35
|
-
registerMany(factories: CreatableModuleFactory[]): this;
|
|
36
|
-
/**
|
|
37
|
-
* Tries to locate a module factory that matches the supplied schema and labels
|
|
38
|
-
* @param schema The config schema for the module
|
|
39
|
-
* @param labels The labels for the module factory
|
|
40
|
-
* @returns A module factory that matches the supplied schema and labels or undefined
|
|
41
|
-
*/
|
|
42
|
-
tryLocate(schema: Schema, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory | undefined;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=ModuleFactoryLocator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleFactoryLocator.d.ts","sourceRoot":"","sources":["../../src/ModuleFactoryLocator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,6BAA6B,EAC7B,MAAM,EACN,4BAA4B,EAC7B,MAAM,2BAA2B,CAAA;AAMlC,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAIjE;;GAEG;AACH,qBAAa,oBAAqB,YAAW,4BAA4B;IACvE,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,uBAAuB,CAAA;IAErD,OAAO,CAAC,OAAO,CAAQ;gBAEX,SAAS,GAAE,uBAAsD;IAI7E;;OAEG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAAC,uBAAuB,CAAC,CAEhD;IAED,MAAM,CAAC,KAAK,IAAI,oBAAoB;IAIpC,MAAM,CAAC,QAAQ,IAAI,oBAAoB;IAIvC,MAAM,IAAI,IAAI;IAId;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,sBAAsB,GAAG,6BAA6B;IAQ/F,KAAK,CAAC,OAAO,EAAE,4BAA4B,GAAG,4BAA4B;IAa1E;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,GAAG,MAAM,GAAG,MAAM,EAAU,GAAG,IAAI;IAM9G;;;OAGG;IACH,YAAY,CAAC,SAAS,EAAE,sBAAsB,EAAE,GAAG,IAAI;IAOvD;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,sBAAsB,GAAG,6BAA6B,GAAG,SAAS;CAO/G"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { CreatableModuleFactory, CreatableModuleRegistry, LabeledCreatableModuleFactory } from '@xyo-network/module-model';
|
|
2
|
-
export declare const standardCreatableModulesList: (CreatableModuleFactory | LabeledCreatableModuleFactory)[];
|
|
3
|
-
export declare const standardCreatableFactories: () => CreatableModuleRegistry;
|
|
4
|
-
//# sourceMappingURL=standardCreatableFactories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standardCreatableFactories.d.ts","sourceRoot":"","sources":["../../src/standardCreatableFactories.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,sBAAsB,EAAE,uBAAuB,EAAE,6BAA6B,EAC/E,MAAM,2BAA2B,CAAA;AAQlC,eAAO,MAAM,4BAA4B,EAAE,CAAC,sBAAsB,GAAG,6BAA6B,CAAC,EAalG,CAAA;AAED,eAAO,MAAM,0BAA0B,QAAO,uBAE7C,CAAA"}
|