@xyo-network/module-factory-locator 2.98.5 → 2.99.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/ModuleFactoryLocator.d.cts +6 -10
- package/dist/browser/ModuleFactoryLocator.d.cts.map +1 -1
- package/dist/browser/ModuleFactoryLocator.d.mts +6 -10
- package/dist/browser/ModuleFactoryLocator.d.mts.map +1 -1
- package/dist/browser/ModuleFactoryLocator.d.ts +6 -10
- package/dist/browser/ModuleFactoryLocator.d.ts.map +1 -1
- package/dist/browser/index.cjs +22 -53
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +1 -0
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +1 -0
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +24 -55
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/standardCreatableFactories.d.cts.map +1 -1
- package/dist/browser/standardCreatableFactories.d.mts.map +1 -1
- package/dist/browser/standardCreatableFactories.d.ts.map +1 -1
- package/dist/node/ModuleFactoryLocator.d.cts +6 -10
- package/dist/node/ModuleFactoryLocator.d.cts.map +1 -1
- package/dist/node/ModuleFactoryLocator.d.mts +6 -10
- package/dist/node/ModuleFactoryLocator.d.mts.map +1 -1
- package/dist/node/ModuleFactoryLocator.d.ts +6 -10
- package/dist/node/ModuleFactoryLocator.d.ts.map +1 -1
- package/dist/node/index.cjs +25 -54
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +1 -0
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +1 -0
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +24 -55
- package/dist/node/index.js.map +1 -1
- package/dist/node/standardCreatableFactories.d.cts.map +1 -1
- package/dist/node/standardCreatableFactories.d.mts.map +1 -1
- package/dist/node/standardCreatableFactories.d.ts.map +1 -1
- package/package.json +15 -18
- package/src/ModuleFactoryLocator.ts +9 -34
- package/src/index.ts +1 -0
- package/src/standardCreatableFactories.ts +12 -24
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreatableModuleFactory, CreatableModuleRegistry, LabeledCreatableModuleFactory, Labels } from '@xyo-network/module-model';
|
|
2
2
|
import { Schema } from '@xyo-network/payload-model';
|
|
3
3
|
/**
|
|
4
4
|
* A class which encapsulates the Service Locator Pattern for Module Factories
|
|
@@ -19,19 +19,15 @@ export declare class ModuleFactoryLocator {
|
|
|
19
19
|
locate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory;
|
|
20
20
|
/**
|
|
21
21
|
* Registers a single module factory (with optional tags) with the locator
|
|
22
|
-
* @param
|
|
22
|
+
* @param factory The factory to register
|
|
23
|
+
* @param labels The labels for the module factory
|
|
23
24
|
*/
|
|
24
|
-
register(
|
|
25
|
+
register(factory: CreatableModuleFactory, labels?: Labels, primary?: boolean | Schema | Schema[]): this;
|
|
25
26
|
/**
|
|
26
27
|
* Registers multiple module factories with the locator
|
|
27
|
-
* @param
|
|
28
|
-
*/
|
|
29
|
-
registerMany(mods: CreatableModuleFactory[]): this;
|
|
30
|
-
/**
|
|
31
|
-
* Registers a single module factory (with optional tags) with the locator & a specific schema
|
|
32
|
-
* @param additional Additional module factories to register
|
|
28
|
+
* @param factories The factories to register
|
|
33
29
|
*/
|
|
34
|
-
|
|
30
|
+
registerMany(factories: CreatableModuleFactory[]): this;
|
|
35
31
|
/**
|
|
36
32
|
* Tries to locate a module factory that matches the supplied schema and labels
|
|
37
33
|
* @param schema The config schema for the module
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleFactoryLocator.d.ts","sourceRoot":"","sources":["../../src/ModuleFactoryLocator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"ModuleFactoryLocator.d.ts","sourceRoot":"","sources":["../../src/ModuleFactoryLocator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EAGvB,6BAA6B,EAC7B,MAAM,EAEP,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAInD;;GAEG;AACH,qBAAa,oBAAoB;IACnB,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,uBAAuB;gBAAlC,SAAS,GAAE,uBAAsD;IAEhG;;OAEG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAAC,uBAAuB,CAAC,CAEhD;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,sBAAsB,GAAG,6BAA6B;IAO/F;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,GAAG,MAAM,GAAG,MAAM,EAAU,GAAG,IAAI;IAK9G;;;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;CAQ/G"}
|
package/dist/node/index.cjs
CHANGED
|
@@ -21,7 +21,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
var src_exports = {};
|
|
23
23
|
__export(src_exports, {
|
|
24
|
-
ModuleFactoryLocator: () => ModuleFactoryLocator
|
|
24
|
+
ModuleFactoryLocator: () => ModuleFactoryLocator,
|
|
25
|
+
standardCreatableFactories: () => standardCreatableFactories,
|
|
26
|
+
standardCreatableFactoriesList: () => standardCreatableFactoriesList
|
|
25
27
|
});
|
|
26
28
|
module.exports = __toCommonJS(src_exports);
|
|
27
29
|
|
|
@@ -31,39 +33,31 @@ var import_module_model2 = require("@xyo-network/module-model");
|
|
|
31
33
|
|
|
32
34
|
// src/standardCreatableFactories.ts
|
|
33
35
|
var import_archivist_memory = require("@xyo-network/archivist-memory");
|
|
34
|
-
var import_archivist_model = require("@xyo-network/archivist-model");
|
|
35
36
|
var import_archivist_view = require("@xyo-network/archivist-view");
|
|
36
|
-
var
|
|
37
|
+
var import_diviner_boundwitness_memory = require("@xyo-network/diviner-boundwitness-memory");
|
|
37
38
|
var import_diviner_identity = require("@xyo-network/diviner-identity");
|
|
38
|
-
var
|
|
39
|
+
var import_diviner_payload_memory = require("@xyo-network/diviner-payload-memory");
|
|
39
40
|
var import_http_bridge = require("@xyo-network/http-bridge");
|
|
40
41
|
var import_module_model = require("@xyo-network/module-model");
|
|
41
42
|
var import_node_memory = require("@xyo-network/node-memory");
|
|
42
|
-
var import_node_model = require("@xyo-network/node-model");
|
|
43
43
|
var import_node_view = require("@xyo-network/node-view");
|
|
44
44
|
var import_sentinel_memory = require("@xyo-network/sentinel-memory");
|
|
45
|
-
var import_sentinel_model = require("@xyo-network/sentinel-model");
|
|
46
45
|
var import_witness_adhoc = require("@xyo-network/witness-adhoc");
|
|
47
|
-
var import_witness_model = require("@xyo-network/witness-model");
|
|
48
46
|
var standardCreatableFactoriesList = [
|
|
49
|
-
import_archivist_memory.MemoryArchivist,
|
|
50
47
|
import_http_bridge.HttpBridge,
|
|
51
|
-
import_archivist_memory.MemoryArchivist,
|
|
52
|
-
import_node_memory.MemoryNode,
|
|
53
|
-
import_sentinel_memory.MemorySentinel,
|
|
54
48
|
import_archivist_view.ViewArchivist,
|
|
55
49
|
import_node_view.ViewNode,
|
|
56
|
-
import_witness_adhoc.AdhocWitness
|
|
50
|
+
import_witness_adhoc.AdhocWitness,
|
|
51
|
+
import_diviner_payload_memory.MemoryPayloadDiviner,
|
|
52
|
+
import_diviner_boundwitness_memory.MemoryBoundWitnessDiviner,
|
|
53
|
+
import_diviner_identity.IdentityDiviner,
|
|
54
|
+
import_archivist_memory.MemoryArchivist,
|
|
55
|
+
import_archivist_memory.MemoryArchivist,
|
|
56
|
+
import_node_memory.MemoryNode,
|
|
57
|
+
import_sentinel_memory.MemorySentinel
|
|
57
58
|
];
|
|
58
59
|
var standardCreatableFactories = /* @__PURE__ */ __name(() => {
|
|
59
|
-
|
|
60
|
-
(0, import_module_model.registerPrimaryCreatableModuleFactory)(registry, import_node_memory.MemoryNode, import_node_model.NodeConfigSchema);
|
|
61
|
-
(0, import_module_model.registerPrimaryCreatableModuleFactory)(registry, import_archivist_memory.MemoryArchivist, import_archivist_model.ArchivistConfigSchema);
|
|
62
|
-
(0, import_module_model.registerPrimaryCreatableModuleFactory)(registry, import_sentinel_memory.MemorySentinel, import_sentinel_model.SentinelConfigSchema);
|
|
63
|
-
(0, import_module_model.registerPrimaryCreatableModuleFactory)(registry, import_witness_adhoc.AdhocWitness, import_witness_model.WitnessConfigSchema);
|
|
64
|
-
(0, import_module_model.registerPrimaryCreatableModuleFactory)(registry, import_diviner_identity.IdentityDiviner, import_diviner_model.DivinerConfigSchema);
|
|
65
|
-
(0, import_module_model.registerPrimaryCreatableModuleFactory)(registry, import_http_bridge.HttpBridge, import_bridge_model.BridgeConfigSchema);
|
|
66
|
-
return registry;
|
|
60
|
+
return (0, import_module_model.registerCreatableModuleFactories)(standardCreatableFactoriesList, {}, true);
|
|
67
61
|
}, "standardCreatableFactories");
|
|
68
62
|
|
|
69
63
|
// src/ModuleFactoryLocator.ts
|
|
@@ -89,49 +83,24 @@ var _ModuleFactoryLocator = class _ModuleFactoryLocator {
|
|
|
89
83
|
}
|
|
90
84
|
/**
|
|
91
85
|
* Registers a single module factory (with optional tags) with the locator
|
|
92
|
-
* @param
|
|
86
|
+
* @param factory The factory to register
|
|
87
|
+
* @param labels The labels for the module factory
|
|
93
88
|
*/
|
|
94
|
-
register(
|
|
95
|
-
|
|
96
|
-
mod.configSchemas.map((schema) => {
|
|
97
|
-
this.registerOne(mod, schema, labels, false);
|
|
98
|
-
});
|
|
89
|
+
register(factory, labels, primary = false) {
|
|
90
|
+
(0, import_module_model2.registerCreatableModuleFactory)(this._registry, factory, labels, primary);
|
|
99
91
|
return this;
|
|
100
92
|
}
|
|
101
93
|
/**
|
|
102
94
|
* Registers multiple module factories with the locator
|
|
103
|
-
* @param
|
|
95
|
+
* @param factories The factories to register
|
|
104
96
|
*/
|
|
105
|
-
registerMany(
|
|
106
|
-
for (const
|
|
107
|
-
this.register(
|
|
97
|
+
registerMany(factories) {
|
|
98
|
+
for (const factory of factories) {
|
|
99
|
+
this.register(factory);
|
|
108
100
|
}
|
|
109
101
|
return this;
|
|
110
102
|
}
|
|
111
103
|
/**
|
|
112
|
-
* Registers a single module factory (with optional tags) with the locator & a specific schema
|
|
113
|
-
* @param additional Additional module factories to register
|
|
114
|
-
*/
|
|
115
|
-
registerOne(mod, schema, labels, primary = false) {
|
|
116
|
-
const existingFactories = this._registry[schema];
|
|
117
|
-
const factory = {
|
|
118
|
-
// Destructure instance properties
|
|
119
|
-
...mod,
|
|
120
|
-
// Copy static methods
|
|
121
|
-
create: mod.create.bind(mod),
|
|
122
|
-
// Merge module & supplied labels
|
|
123
|
-
labels: Object.assign({}, mod.labels ?? {}, labels ?? {})
|
|
124
|
-
};
|
|
125
|
-
this._registry[schema] = primary ? [
|
|
126
|
-
factory,
|
|
127
|
-
...existingFactories ?? []
|
|
128
|
-
] : [
|
|
129
|
-
...existingFactories ?? [],
|
|
130
|
-
factory
|
|
131
|
-
];
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
104
|
* Tries to locate a module factory that matches the supplied schema and labels
|
|
136
105
|
* @param schema The config schema for the module
|
|
137
106
|
* @param labels The labels for the module factory
|
|
@@ -149,6 +118,8 @@ __name(_ModuleFactoryLocator, "ModuleFactoryLocator");
|
|
|
149
118
|
var ModuleFactoryLocator = _ModuleFactoryLocator;
|
|
150
119
|
// Annotate the CommonJS export names for ESM import in node:
|
|
151
120
|
0 && (module.exports = {
|
|
152
|
-
ModuleFactoryLocator
|
|
121
|
+
ModuleFactoryLocator,
|
|
122
|
+
standardCreatableFactories,
|
|
123
|
+
standardCreatableFactoriesList
|
|
153
124
|
});
|
|
154
125
|
//# sourceMappingURL=index.cjs.map
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/ModuleFactoryLocator.ts","../../src/standardCreatableFactories.ts"],"sourcesContent":["export * from './ModuleFactoryLocator'\n","import { assertEx } from '@xylabs/assert'\nimport {\n
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/ModuleFactoryLocator.ts","../../src/standardCreatableFactories.ts"],"sourcesContent":["export * from './ModuleFactoryLocator'\nexport * from './standardCreatableFactories'\n","import { assertEx } from '@xylabs/assert'\nimport {\n CreatableModuleFactory,\n CreatableModuleRegistry,\n hasAllLabels,\n hasLabels,\n LabeledCreatableModuleFactory,\n Labels,\n registerCreatableModuleFactory,\n} from '@xyo-network/module-model'\nimport { Schema } from '@xyo-network/payload-model'\n\nimport { standardCreatableFactories } from './standardCreatableFactories'\n\n/**\n * A class which encapsulates the Service Locator Pattern for Module Factories\n */\nexport class ModuleFactoryLocator {\n constructor(protected readonly _registry: CreatableModuleRegistry = standardCreatableFactories()) {}\n\n /**\n * The current registry for the module factory\n */\n get registry(): Readonly<CreatableModuleRegistry> {\n return this._registry\n }\n\n /**\n * Locates a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or throws if one is not found\n */\n locate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory {\n return assertEx(\n this.tryLocate(schema, labels),\n () => `No module factory for the supplied ${`config schema [${schema}]`}${labels ? ` & labels [${JSON.stringify(labels)}]` : ''} registered`,\n )\n }\n\n /**\n * Registers a single module factory (with optional tags) with the locator\n * @param factory The factory to register\n * @param labels The labels for the module factory\n */\n register(factory: CreatableModuleFactory, labels?: Labels, primary: boolean | Schema | Schema[] = false): this {\n registerCreatableModuleFactory(this._registry, factory, labels, primary)\n return this\n }\n\n /**\n * Registers multiple module factories with the locator\n * @param factories The factories to register\n */\n registerMany(factories: CreatableModuleFactory[]): this {\n for (const factory of factories) {\n this.register(factory)\n }\n return this\n }\n\n /**\n * Tries to locate a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or undefined\n */\n tryLocate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory | undefined {\n // If labels were provided\n return labels ?\n // Find the first factory that has labels and has all the labels provided\n this._registry[schema]?.filter(hasLabels).find((factory) => hasAllLabels(factory?.labels, labels))\n : // Otherwise, return the first factory\n this._registry[schema]?.[0]\n }\n}\n","import { MemoryArchivist } from '@xyo-network/archivist-memory'\nimport { ViewArchivist } from '@xyo-network/archivist-view'\nimport { MemoryBoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-memory'\nimport { IdentityDiviner } from '@xyo-network/diviner-identity'\nimport { MemoryPayloadDiviner } from '@xyo-network/diviner-payload-memory'\nimport { HttpBridge } from '@xyo-network/http-bridge'\nimport { CreatableModuleFactory, LabeledCreatableModuleFactory, registerCreatableModuleFactories } from '@xyo-network/module-model'\nimport { MemoryNode } from '@xyo-network/node-memory'\nimport { ViewNode } from '@xyo-network/node-view'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { AdhocWitness } from '@xyo-network/witness-adhoc'\n\n//order matters in this array. later items will register themselves as primary for schemas shared with earlier items\nexport const standardCreatableFactoriesList: (CreatableModuleFactory | LabeledCreatableModuleFactory)[] = [\n HttpBridge,\n ViewArchivist,\n ViewNode,\n AdhocWitness,\n MemoryPayloadDiviner,\n MemoryBoundWitnessDiviner,\n IdentityDiviner,\n MemoryArchivist,\n MemoryArchivist,\n MemoryNode,\n MemorySentinel,\n]\n\nexport const standardCreatableFactories = () => {\n return registerCreatableModuleFactories(standardCreatableFactoriesList, {}, true)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;ACAA,oBAAyB;AACzB,IAAAA,uBAQO;;;ACTP,8BAAgC;AAChC,4BAA8B;AAC9B,yCAA0C;AAC1C,8BAAgC;AAChC,oCAAqC;AACrC,yBAA2B;AAC3B,0BAAwG;AACxG,yBAA2B;AAC3B,uBAAyB;AACzB,6BAA+B;AAC/B,2BAA6B;AAGtB,IAAMC,iCAA6F;EACxGC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAA;EACAC;EACAC;;AAGK,IAAMC,6BAA6B,6BAAA;AACxC,aAAOC,sDAAiCZ,gCAAgC,CAAC,GAAG,IAAA;AAC9E,GAF0C;;;ADVnC,IAAMa,wBAAN,MAAMA,sBAAAA;;EACXC,YAA+BC,YAAqCC,2BAAAA,GAA8B;SAAnED,YAAAA;EAAoE;;;;EAKnG,IAAIE,WAA8C;AAChD,WAAO,KAAKF;EACd;;;;;;;EAQAG,OAAOC,QAAgBC,QAAyE;AAC9F,eAAOC,wBACL,KAAKC,UAAUH,QAAQC,MAAAA,GACvB,MAAM,sCAAsC,kBAAkBD,MAAAA,GAAS,GAAGC,SAAS,cAAcG,KAAKC,UAAUJ,MAAAA,CAAAA,MAAa,EAAA,aAAe;EAEhJ;;;;;;EAOAK,SAASC,SAAiCN,QAAiBO,UAAuC,OAAa;AAC7GC,6DAA+B,KAAKb,WAAWW,SAASN,QAAQO,OAAAA;AAChE,WAAO;EACT;;;;;EAMAE,aAAaC,WAA2C;AACtD,eAAWJ,WAAWI,WAAW;AAC/B,WAAKL,SAASC,OAAAA;IAChB;AACA,WAAO;EACT;;;;;;;EAQAJ,UAAUH,QAAgBC,QAAqF;AAnEjH;AAqEI,WAAOA;;OAEH,UAAKL,UAAUI,MAAAA,MAAf,mBAAwBY,OAAOC,gCAAWC,KAAK,CAACP,gBAAYQ,mCAAaR,mCAASN,QAAQA,MAAAA;SAE1F,UAAKL,UAAUI,MAAAA,MAAf,mBAAyB;EAC/B;AACF;AA1DaN;AAAN,IAAMA,uBAAN;","names":["import_module_model","standardCreatableFactoriesList","HttpBridge","ViewArchivist","ViewNode","AdhocWitness","MemoryPayloadDiviner","MemoryBoundWitnessDiviner","IdentityDiviner","MemoryArchivist","MemoryNode","MemorySentinel","standardCreatableFactories","registerCreatableModuleFactories","ModuleFactoryLocator","constructor","_registry","standardCreatableFactories","registry","locate","schema","labels","assertEx","tryLocate","JSON","stringify","register","factory","primary","registerCreatableModuleFactory","registerMany","factories","filter","hasLabels","find","hasAllLabels"]}
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA"}
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA"}
|
package/dist/node/index.d.ts
CHANGED
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA"}
|
package/dist/node/index.js
CHANGED
|
@@ -3,43 +3,35 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/ModuleFactoryLocator.ts
|
|
5
5
|
import { assertEx } from "@xylabs/assert";
|
|
6
|
-
import { hasAllLabels, hasLabels } from "@xyo-network/module-model";
|
|
6
|
+
import { hasAllLabels, hasLabels, registerCreatableModuleFactory } from "@xyo-network/module-model";
|
|
7
7
|
|
|
8
8
|
// src/standardCreatableFactories.ts
|
|
9
9
|
import { MemoryArchivist } from "@xyo-network/archivist-memory";
|
|
10
|
-
import { ArchivistConfigSchema } from "@xyo-network/archivist-model";
|
|
11
10
|
import { ViewArchivist } from "@xyo-network/archivist-view";
|
|
12
|
-
import {
|
|
11
|
+
import { MemoryBoundWitnessDiviner } from "@xyo-network/diviner-boundwitness-memory";
|
|
13
12
|
import { IdentityDiviner } from "@xyo-network/diviner-identity";
|
|
14
|
-
import {
|
|
13
|
+
import { MemoryPayloadDiviner } from "@xyo-network/diviner-payload-memory";
|
|
15
14
|
import { HttpBridge } from "@xyo-network/http-bridge";
|
|
16
|
-
import { registerCreatableModuleFactories
|
|
15
|
+
import { registerCreatableModuleFactories } from "@xyo-network/module-model";
|
|
17
16
|
import { MemoryNode } from "@xyo-network/node-memory";
|
|
18
|
-
import { NodeConfigSchema } from "@xyo-network/node-model";
|
|
19
17
|
import { ViewNode } from "@xyo-network/node-view";
|
|
20
18
|
import { MemorySentinel } from "@xyo-network/sentinel-memory";
|
|
21
|
-
import { SentinelConfigSchema } from "@xyo-network/sentinel-model";
|
|
22
19
|
import { AdhocWitness } from "@xyo-network/witness-adhoc";
|
|
23
|
-
import { WitnessConfigSchema } from "@xyo-network/witness-model";
|
|
24
20
|
var standardCreatableFactoriesList = [
|
|
25
|
-
MemoryArchivist,
|
|
26
21
|
HttpBridge,
|
|
27
|
-
MemoryArchivist,
|
|
28
|
-
MemoryNode,
|
|
29
|
-
MemorySentinel,
|
|
30
22
|
ViewArchivist,
|
|
31
23
|
ViewNode,
|
|
32
|
-
AdhocWitness
|
|
24
|
+
AdhocWitness,
|
|
25
|
+
MemoryPayloadDiviner,
|
|
26
|
+
MemoryBoundWitnessDiviner,
|
|
27
|
+
IdentityDiviner,
|
|
28
|
+
MemoryArchivist,
|
|
29
|
+
MemoryArchivist,
|
|
30
|
+
MemoryNode,
|
|
31
|
+
MemorySentinel
|
|
33
32
|
];
|
|
34
33
|
var standardCreatableFactories = /* @__PURE__ */ __name(() => {
|
|
35
|
-
|
|
36
|
-
registerPrimaryCreatableModuleFactory(registry, MemoryNode, NodeConfigSchema);
|
|
37
|
-
registerPrimaryCreatableModuleFactory(registry, MemoryArchivist, ArchivistConfigSchema);
|
|
38
|
-
registerPrimaryCreatableModuleFactory(registry, MemorySentinel, SentinelConfigSchema);
|
|
39
|
-
registerPrimaryCreatableModuleFactory(registry, AdhocWitness, WitnessConfigSchema);
|
|
40
|
-
registerPrimaryCreatableModuleFactory(registry, IdentityDiviner, DivinerConfigSchema);
|
|
41
|
-
registerPrimaryCreatableModuleFactory(registry, HttpBridge, BridgeConfigSchema);
|
|
42
|
-
return registry;
|
|
34
|
+
return registerCreatableModuleFactories(standardCreatableFactoriesList, {}, true);
|
|
43
35
|
}, "standardCreatableFactories");
|
|
44
36
|
|
|
45
37
|
// src/ModuleFactoryLocator.ts
|
|
@@ -65,49 +57,24 @@ var _ModuleFactoryLocator = class _ModuleFactoryLocator {
|
|
|
65
57
|
}
|
|
66
58
|
/**
|
|
67
59
|
* Registers a single module factory (with optional tags) with the locator
|
|
68
|
-
* @param
|
|
60
|
+
* @param factory The factory to register
|
|
61
|
+
* @param labels The labels for the module factory
|
|
69
62
|
*/
|
|
70
|
-
register(
|
|
71
|
-
this.
|
|
72
|
-
mod.configSchemas.map((schema) => {
|
|
73
|
-
this.registerOne(mod, schema, labels, false);
|
|
74
|
-
});
|
|
63
|
+
register(factory, labels, primary = false) {
|
|
64
|
+
registerCreatableModuleFactory(this._registry, factory, labels, primary);
|
|
75
65
|
return this;
|
|
76
66
|
}
|
|
77
67
|
/**
|
|
78
68
|
* Registers multiple module factories with the locator
|
|
79
|
-
* @param
|
|
69
|
+
* @param factories The factories to register
|
|
80
70
|
*/
|
|
81
|
-
registerMany(
|
|
82
|
-
for (const
|
|
83
|
-
this.register(
|
|
71
|
+
registerMany(factories) {
|
|
72
|
+
for (const factory of factories) {
|
|
73
|
+
this.register(factory);
|
|
84
74
|
}
|
|
85
75
|
return this;
|
|
86
76
|
}
|
|
87
77
|
/**
|
|
88
|
-
* Registers a single module factory (with optional tags) with the locator & a specific schema
|
|
89
|
-
* @param additional Additional module factories to register
|
|
90
|
-
*/
|
|
91
|
-
registerOne(mod, schema, labels, primary = false) {
|
|
92
|
-
const existingFactories = this._registry[schema];
|
|
93
|
-
const factory = {
|
|
94
|
-
// Destructure instance properties
|
|
95
|
-
...mod,
|
|
96
|
-
// Copy static methods
|
|
97
|
-
create: mod.create.bind(mod),
|
|
98
|
-
// Merge module & supplied labels
|
|
99
|
-
labels: Object.assign({}, mod.labels ?? {}, labels ?? {})
|
|
100
|
-
};
|
|
101
|
-
this._registry[schema] = primary ? [
|
|
102
|
-
factory,
|
|
103
|
-
...existingFactories ?? []
|
|
104
|
-
] : [
|
|
105
|
-
...existingFactories ?? [],
|
|
106
|
-
factory
|
|
107
|
-
];
|
|
108
|
-
return this;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
78
|
* Tries to locate a module factory that matches the supplied schema and labels
|
|
112
79
|
* @param schema The config schema for the module
|
|
113
80
|
* @param labels The labels for the module factory
|
|
@@ -124,6 +91,8 @@ var _ModuleFactoryLocator = class _ModuleFactoryLocator {
|
|
|
124
91
|
__name(_ModuleFactoryLocator, "ModuleFactoryLocator");
|
|
125
92
|
var ModuleFactoryLocator = _ModuleFactoryLocator;
|
|
126
93
|
export {
|
|
127
|
-
ModuleFactoryLocator
|
|
94
|
+
ModuleFactoryLocator,
|
|
95
|
+
standardCreatableFactories,
|
|
96
|
+
standardCreatableFactoriesList
|
|
128
97
|
};
|
|
129
98
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ModuleFactoryLocator.ts","../../src/standardCreatableFactories.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport {\n
|
|
1
|
+
{"version":3,"sources":["../../src/ModuleFactoryLocator.ts","../../src/standardCreatableFactories.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport {\n CreatableModuleFactory,\n CreatableModuleRegistry,\n hasAllLabels,\n hasLabels,\n LabeledCreatableModuleFactory,\n Labels,\n registerCreatableModuleFactory,\n} from '@xyo-network/module-model'\nimport { Schema } from '@xyo-network/payload-model'\n\nimport { standardCreatableFactories } from './standardCreatableFactories'\n\n/**\n * A class which encapsulates the Service Locator Pattern for Module Factories\n */\nexport class ModuleFactoryLocator {\n constructor(protected readonly _registry: CreatableModuleRegistry = standardCreatableFactories()) {}\n\n /**\n * The current registry for the module factory\n */\n get registry(): Readonly<CreatableModuleRegistry> {\n return this._registry\n }\n\n /**\n * Locates a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or throws if one is not found\n */\n locate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory {\n return assertEx(\n this.tryLocate(schema, labels),\n () => `No module factory for the supplied ${`config schema [${schema}]`}${labels ? ` & labels [${JSON.stringify(labels)}]` : ''} registered`,\n )\n }\n\n /**\n * Registers a single module factory (with optional tags) with the locator\n * @param factory The factory to register\n * @param labels The labels for the module factory\n */\n register(factory: CreatableModuleFactory, labels?: Labels, primary: boolean | Schema | Schema[] = false): this {\n registerCreatableModuleFactory(this._registry, factory, labels, primary)\n return this\n }\n\n /**\n * Registers multiple module factories with the locator\n * @param factories The factories to register\n */\n registerMany(factories: CreatableModuleFactory[]): this {\n for (const factory of factories) {\n this.register(factory)\n }\n return this\n }\n\n /**\n * Tries to locate a module factory that matches the supplied schema and labels\n * @param schema The config schema for the module\n * @param labels The labels for the module factory\n * @returns A module factory that matches the supplied schema and labels or undefined\n */\n tryLocate(schema: string, labels?: Labels): CreatableModuleFactory | LabeledCreatableModuleFactory | undefined {\n // If labels were provided\n return labels ?\n // Find the first factory that has labels and has all the labels provided\n this._registry[schema]?.filter(hasLabels).find((factory) => hasAllLabels(factory?.labels, labels))\n : // Otherwise, return the first factory\n this._registry[schema]?.[0]\n }\n}\n","import { MemoryArchivist } from '@xyo-network/archivist-memory'\nimport { ViewArchivist } from '@xyo-network/archivist-view'\nimport { MemoryBoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-memory'\nimport { IdentityDiviner } from '@xyo-network/diviner-identity'\nimport { MemoryPayloadDiviner } from '@xyo-network/diviner-payload-memory'\nimport { HttpBridge } from '@xyo-network/http-bridge'\nimport { CreatableModuleFactory, LabeledCreatableModuleFactory, registerCreatableModuleFactories } from '@xyo-network/module-model'\nimport { MemoryNode } from '@xyo-network/node-memory'\nimport { ViewNode } from '@xyo-network/node-view'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { AdhocWitness } from '@xyo-network/witness-adhoc'\n\n//order matters in this array. later items will register themselves as primary for schemas shared with earlier items\nexport const standardCreatableFactoriesList: (CreatableModuleFactory | LabeledCreatableModuleFactory)[] = [\n HttpBridge,\n ViewArchivist,\n ViewNode,\n AdhocWitness,\n MemoryPayloadDiviner,\n MemoryBoundWitnessDiviner,\n IdentityDiviner,\n MemoryArchivist,\n MemoryArchivist,\n MemoryNode,\n MemorySentinel,\n]\n\nexport const standardCreatableFactories = () => {\n return registerCreatableModuleFactories(standardCreatableFactoriesList, {}, true)\n}\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AACzB,SAGEC,cACAC,WAGAC,sCACK;;;ACTP,SAASC,uBAAuB;AAChC,SAASC,qBAAqB;AAC9B,SAASC,iCAAiC;AAC1C,SAASC,uBAAuB;AAChC,SAASC,4BAA4B;AACrC,SAASC,kBAAkB;AAC3B,SAAgEC,wCAAwC;AACxG,SAASC,kBAAkB;AAC3B,SAASC,gBAAgB;AACzB,SAASC,sBAAsB;AAC/B,SAASC,oBAAoB;AAGtB,IAAMC,iCAA6F;EACxGC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAA;EACAC;EACAC;;AAGK,IAAMC,6BAA6B,6BAAA;AACxC,SAAOC,iCAAiCZ,gCAAgC,CAAC,GAAG,IAAA;AAC9E,GAF0C;;;ADVnC,IAAMa,wBAAN,MAAMA,sBAAAA;;EACXC,YAA+BC,YAAqCC,2BAAAA,GAA8B;SAAnED,YAAAA;EAAoE;;;;EAKnG,IAAIE,WAA8C;AAChD,WAAO,KAAKF;EACd;;;;;;;EAQAG,OAAOC,QAAgBC,QAAyE;AAC9F,WAAOC,SACL,KAAKC,UAAUH,QAAQC,MAAAA,GACvB,MAAM,sCAAsC,kBAAkBD,MAAAA,GAAS,GAAGC,SAAS,cAAcG,KAAKC,UAAUJ,MAAAA,CAAAA,MAAa,EAAA,aAAe;EAEhJ;;;;;;EAOAK,SAASC,SAAiCN,QAAiBO,UAAuC,OAAa;AAC7GC,mCAA+B,KAAKb,WAAWW,SAASN,QAAQO,OAAAA;AAChE,WAAO;EACT;;;;;EAMAE,aAAaC,WAA2C;AACtD,eAAWJ,WAAWI,WAAW;AAC/B,WAAKL,SAASC,OAAAA;IAChB;AACA,WAAO;EACT;;;;;;;EAQAJ,UAAUH,QAAgBC,QAAqF;AAnEjH;AAqEI,WAAOA;;OAEH,UAAKL,UAAUI,MAAAA,MAAf,mBAAwBY,OAAOC,WAAWC,KAAK,CAACP,YAAYQ,aAAaR,mCAASN,QAAQA,MAAAA;SAE1F,UAAKL,UAAUI,MAAAA,MAAf,mBAAyB;EAC/B;AACF;AA1DaN;AAAN,IAAMA,uBAAN;","names":["assertEx","hasAllLabels","hasLabels","registerCreatableModuleFactory","MemoryArchivist","ViewArchivist","MemoryBoundWitnessDiviner","IdentityDiviner","MemoryPayloadDiviner","HttpBridge","registerCreatableModuleFactories","MemoryNode","ViewNode","MemorySentinel","AdhocWitness","standardCreatableFactoriesList","HttpBridge","ViewArchivist","ViewNode","AdhocWitness","MemoryPayloadDiviner","MemoryBoundWitnessDiviner","IdentityDiviner","MemoryArchivist","MemoryNode","MemorySentinel","standardCreatableFactories","registerCreatableModuleFactories","ModuleFactoryLocator","constructor","_registry","standardCreatableFactories","registry","locate","schema","labels","assertEx","tryLocate","JSON","stringify","register","factory","primary","registerCreatableModuleFactory","registerMany","factories","filter","hasLabels","find","hasAllLabels"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standardCreatableFactories.d.ts","sourceRoot":"","sources":["../../src/standardCreatableFactories.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"standardCreatableFactories.d.ts","sourceRoot":"","sources":["../../src/standardCreatableFactories.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAoC,MAAM,2BAA2B,CAAA;AAOnI,eAAO,MAAM,8BAA8B,EAAE,CAAC,sBAAsB,GAAG,6BAA6B,CAAC,EAYpG,CAAA;AAED,eAAO,MAAM,0BAA0B,mEAEtC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standardCreatableFactories.d.ts","sourceRoot":"","sources":["../../src/standardCreatableFactories.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"standardCreatableFactories.d.ts","sourceRoot":"","sources":["../../src/standardCreatableFactories.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAoC,MAAM,2BAA2B,CAAA;AAOnI,eAAO,MAAM,8BAA8B,EAAE,CAAC,sBAAsB,GAAG,6BAA6B,CAAC,EAYpG,CAAA;AAED,eAAO,MAAM,0BAA0B,mEAEtC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standardCreatableFactories.d.ts","sourceRoot":"","sources":["../../src/standardCreatableFactories.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"standardCreatableFactories.d.ts","sourceRoot":"","sources":["../../src/standardCreatableFactories.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAoC,MAAM,2BAA2B,CAAA;AAOnI,eAAO,MAAM,8BAA8B,EAAE,CAAC,sBAAsB,GAAG,6BAA6B,CAAC,EAYpG,CAAA;AAED,eAAO,MAAM,0BAA0B,mEAEtC,CAAA"}
|
package/package.json
CHANGED
|
@@ -10,23 +10,20 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^3.1.
|
|
14
|
-
"@xyo-network/archivist-memory": "~2.
|
|
15
|
-
"@xyo-network/archivist-
|
|
16
|
-
"@xyo-network/
|
|
17
|
-
"@xyo-network/
|
|
18
|
-
"@xyo-network/diviner-identity": "~2.
|
|
19
|
-
"@xyo-network/diviner-
|
|
20
|
-
"@xyo-network/http-bridge": "~2.
|
|
21
|
-
"@xyo-network/module-model": "~2.
|
|
22
|
-
"@xyo-network/node-memory": "~2.
|
|
23
|
-
"@xyo-network/node-
|
|
24
|
-
"@xyo-network/
|
|
25
|
-
"@xyo-network/
|
|
26
|
-
"@xyo-network/
|
|
27
|
-
"@xyo-network/sentinel-model": "~2.98.5",
|
|
28
|
-
"@xyo-network/witness-adhoc": "~2.98.5",
|
|
29
|
-
"@xyo-network/witness-model": "~2.98.5"
|
|
13
|
+
"@xylabs/assert": "^3.1.11",
|
|
14
|
+
"@xyo-network/archivist-memory": "~2.99.1",
|
|
15
|
+
"@xyo-network/archivist-view": "~2.99.1",
|
|
16
|
+
"@xyo-network/bridge-model": "~2.99.1",
|
|
17
|
+
"@xyo-network/diviner-boundwitness-memory": "~2.99.1",
|
|
18
|
+
"@xyo-network/diviner-identity": "~2.99.1",
|
|
19
|
+
"@xyo-network/diviner-payload-memory": "~2.99.1",
|
|
20
|
+
"@xyo-network/http-bridge": "~2.99.1",
|
|
21
|
+
"@xyo-network/module-model": "~2.99.1",
|
|
22
|
+
"@xyo-network/node-memory": "~2.99.1",
|
|
23
|
+
"@xyo-network/node-view": "~2.99.1",
|
|
24
|
+
"@xyo-network/payload-model": "~2.99.1",
|
|
25
|
+
"@xyo-network/sentinel-memory": "~2.99.1",
|
|
26
|
+
"@xyo-network/witness-adhoc": "~2.99.1"
|
|
30
27
|
},
|
|
31
28
|
"devDependencies": {
|
|
32
29
|
"@xylabs/ts-scripts-yarn3": "^3.9.1",
|
|
@@ -72,6 +69,6 @@
|
|
|
72
69
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
73
70
|
},
|
|
74
71
|
"sideEffects": false,
|
|
75
|
-
"version": "2.
|
|
72
|
+
"version": "2.99.1",
|
|
76
73
|
"type": "module"
|
|
77
74
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import {
|
|
3
|
-
AttachableModuleInstance,
|
|
4
3
|
CreatableModuleFactory,
|
|
5
4
|
CreatableModuleRegistry,
|
|
6
5
|
hasAllLabels,
|
|
7
6
|
hasLabels,
|
|
8
7
|
LabeledCreatableModuleFactory,
|
|
9
8
|
Labels,
|
|
9
|
+
registerCreatableModuleFactory,
|
|
10
10
|
} from '@xyo-network/module-model'
|
|
11
11
|
import { Schema } from '@xyo-network/payload-model'
|
|
12
12
|
|
|
@@ -40,47 +40,22 @@ export class ModuleFactoryLocator {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Registers a single module factory (with optional tags) with the locator
|
|
43
|
-
* @param
|
|
43
|
+
* @param factory The factory to register
|
|
44
|
+
* @param labels The labels for the module factory
|
|
44
45
|
*/
|
|
45
|
-
register(
|
|
46
|
-
this.
|
|
47
|
-
mod.configSchemas.map((schema) => {
|
|
48
|
-
this.registerOne(mod, schema, labels, false)
|
|
49
|
-
})
|
|
46
|
+
register(factory: CreatableModuleFactory, labels?: Labels, primary: boolean | Schema | Schema[] = false): this {
|
|
47
|
+
registerCreatableModuleFactory(this._registry, factory, labels, primary)
|
|
50
48
|
return this
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
/**
|
|
54
52
|
* Registers multiple module factories with the locator
|
|
55
|
-
* @param
|
|
56
|
-
*/
|
|
57
|
-
registerMany(mods: CreatableModuleFactory[]): this {
|
|
58
|
-
for (const mod of mods) {
|
|
59
|
-
this.register(mod)
|
|
60
|
-
}
|
|
61
|
-
return this
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Registers a single module factory (with optional tags) with the locator & a specific schema
|
|
66
|
-
* @param additional Additional module factories to register
|
|
53
|
+
* @param factories The factories to register
|
|
67
54
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
labels?: Labels,
|
|
72
|
-
primary = false,
|
|
73
|
-
): this {
|
|
74
|
-
const existingFactories = this._registry[schema]
|
|
75
|
-
const factory: LabeledCreatableModuleFactory<TModule> = {
|
|
76
|
-
// Destructure instance properties
|
|
77
|
-
...mod,
|
|
78
|
-
// Copy static methods
|
|
79
|
-
create: mod.create.bind(mod) as LabeledCreatableModuleFactory<TModule>['create'],
|
|
80
|
-
// Merge module & supplied labels
|
|
81
|
-
labels: Object.assign({}, (mod as LabeledCreatableModuleFactory).labels ?? {}, labels ?? {}),
|
|
55
|
+
registerMany(factories: CreatableModuleFactory[]): this {
|
|
56
|
+
for (const factory of factories) {
|
|
57
|
+
this.register(factory)
|
|
82
58
|
}
|
|
83
|
-
this._registry[schema] = primary ? [factory, ...(existingFactories ?? [])] : [...(existingFactories ?? []), factory]
|
|
84
59
|
return this
|
|
85
60
|
}
|
|
86
61
|
|
package/src/index.ts
CHANGED
|
@@ -1,42 +1,30 @@
|
|
|
1
1
|
import { MemoryArchivist } from '@xyo-network/archivist-memory'
|
|
2
|
-
import { ArchivistConfigSchema } from '@xyo-network/archivist-model'
|
|
3
2
|
import { ViewArchivist } from '@xyo-network/archivist-view'
|
|
4
|
-
import {
|
|
3
|
+
import { MemoryBoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-memory'
|
|
5
4
|
import { IdentityDiviner } from '@xyo-network/diviner-identity'
|
|
6
|
-
import {
|
|
5
|
+
import { MemoryPayloadDiviner } from '@xyo-network/diviner-payload-memory'
|
|
7
6
|
import { HttpBridge } from '@xyo-network/http-bridge'
|
|
8
|
-
import {
|
|
9
|
-
CreatableModuleFactory,
|
|
10
|
-
LabeledCreatableModuleFactory,
|
|
11
|
-
registerCreatableModuleFactories,
|
|
12
|
-
registerPrimaryCreatableModuleFactory,
|
|
13
|
-
} from '@xyo-network/module-model'
|
|
7
|
+
import { CreatableModuleFactory, LabeledCreatableModuleFactory, registerCreatableModuleFactories } from '@xyo-network/module-model'
|
|
14
8
|
import { MemoryNode } from '@xyo-network/node-memory'
|
|
15
|
-
import { NodeConfigSchema } from '@xyo-network/node-model'
|
|
16
9
|
import { ViewNode } from '@xyo-network/node-view'
|
|
17
10
|
import { MemorySentinel } from '@xyo-network/sentinel-memory'
|
|
18
|
-
import { SentinelConfigSchema } from '@xyo-network/sentinel-model'
|
|
19
11
|
import { AdhocWitness } from '@xyo-network/witness-adhoc'
|
|
20
|
-
import { WitnessConfigSchema } from '@xyo-network/witness-model'
|
|
21
12
|
|
|
13
|
+
//order matters in this array. later items will register themselves as primary for schemas shared with earlier items
|
|
22
14
|
export const standardCreatableFactoriesList: (CreatableModuleFactory | LabeledCreatableModuleFactory)[] = [
|
|
23
|
-
MemoryArchivist,
|
|
24
15
|
HttpBridge,
|
|
25
|
-
MemoryArchivist,
|
|
26
|
-
MemoryNode,
|
|
27
|
-
MemorySentinel,
|
|
28
16
|
ViewArchivist,
|
|
29
17
|
ViewNode,
|
|
30
18
|
AdhocWitness,
|
|
19
|
+
MemoryPayloadDiviner,
|
|
20
|
+
MemoryBoundWitnessDiviner,
|
|
21
|
+
IdentityDiviner,
|
|
22
|
+
MemoryArchivist,
|
|
23
|
+
MemoryArchivist,
|
|
24
|
+
MemoryNode,
|
|
25
|
+
MemorySentinel,
|
|
31
26
|
]
|
|
32
27
|
|
|
33
28
|
export const standardCreatableFactories = () => {
|
|
34
|
-
|
|
35
|
-
registerPrimaryCreatableModuleFactory(registry, MemoryNode, NodeConfigSchema)
|
|
36
|
-
registerPrimaryCreatableModuleFactory(registry, MemoryArchivist, ArchivistConfigSchema)
|
|
37
|
-
registerPrimaryCreatableModuleFactory(registry, MemorySentinel, SentinelConfigSchema)
|
|
38
|
-
registerPrimaryCreatableModuleFactory(registry, AdhocWitness, WitnessConfigSchema)
|
|
39
|
-
registerPrimaryCreatableModuleFactory(registry, IdentityDiviner, DivinerConfigSchema)
|
|
40
|
-
registerPrimaryCreatableModuleFactory(registry, HttpBridge, BridgeConfigSchema)
|
|
41
|
-
return registry
|
|
29
|
+
return registerCreatableModuleFactories(standardCreatableFactoriesList, {}, true)
|
|
42
30
|
}
|