@xyo-network/module-resolver 2.72.9 → 2.73.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/docs.json +161 -161
- package/dist/index.d.mts +49 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +253 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +226 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +33 -20
- package/src/SimpleModuleResolver.ts +1 -2
- package/tsup.config.ts +16 -0
- package/dist/cjs/CompositeModuleResolver.js +0 -85
- package/dist/cjs/CompositeModuleResolver.js.map +0 -1
- package/dist/cjs/ResolverEventEmitter.js +0 -38
- package/dist/cjs/ResolverEventEmitter.js.map +0 -1
- package/dist/cjs/SimpleModuleResolver.js +0 -110
- package/dist/cjs/SimpleModuleResolver.js.map +0 -1
- package/dist/cjs/index.js +0 -7
- package/dist/cjs/index.js.map +0 -1
- package/dist/esm/CompositeModuleResolver.js +0 -78
- package/dist/esm/CompositeModuleResolver.js.map +0 -1
- package/dist/esm/ResolverEventEmitter.js +0 -33
- package/dist/esm/ResolverEventEmitter.js.map +0 -1
- package/dist/esm/SimpleModuleResolver.js +0 -103
- package/dist/esm/SimpleModuleResolver.js.map +0 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/types/CompositeModuleResolver.d.ts +0 -19
- package/dist/types/CompositeModuleResolver.d.ts.map +0 -1
- package/dist/types/ResolverEventEmitter.d.ts +0 -10
- package/dist/types/ResolverEventEmitter.d.ts.map +0 -1
- package/dist/types/SimpleModuleResolver.d.ts +0 -20
- package/dist/types/SimpleModuleResolver.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -10,41 +10,55 @@
|
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/exists": "^2.
|
|
14
|
-
"@
|
|
15
|
-
"@xyo-network/
|
|
16
|
-
"@xyo-network/
|
|
17
|
-
"
|
|
13
|
+
"@xylabs/exists": "^2.10.7",
|
|
14
|
+
"@xylabs/lodash": "^2.10.7",
|
|
15
|
+
"@xyo-network/core": "~2.73.1",
|
|
16
|
+
"@xyo-network/module-model": "~2.73.1",
|
|
17
|
+
"@xyo-network/promise": "~2.73.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@xylabs/ts-scripts-yarn3": "^2.19.
|
|
21
|
-
"@xylabs/tsconfig": "^2.19.
|
|
20
|
+
"@xylabs/ts-scripts-yarn3": "^2.19.5",
|
|
21
|
+
"@xylabs/tsconfig": "^2.19.5",
|
|
22
22
|
"jest": "^29.6.4",
|
|
23
23
|
"jest-mock-extended": "^3.0.5",
|
|
24
|
+
"publint": "^0.2.2",
|
|
25
|
+
"tsup": "^7.2.0",
|
|
24
26
|
"typescript": "^5.2.2"
|
|
25
27
|
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"package-compile": "tsup && publint",
|
|
30
|
+
"package-recompile": "tsup && publint"
|
|
31
|
+
},
|
|
26
32
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
27
|
-
"browser": "dist/esm/index.js",
|
|
28
33
|
"docs": "dist/docs.json",
|
|
34
|
+
"types": "dist/index.d.ts",
|
|
29
35
|
"exports": {
|
|
30
36
|
".": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
},
|
|
35
|
-
"browser": {
|
|
36
|
-
"import": "./dist/esm/index.js",
|
|
37
|
-
"require": "./dist/cjs/index.js"
|
|
37
|
+
"require": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"default": "./dist/index.js"
|
|
38
40
|
},
|
|
39
|
-
"
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/index.d.mts",
|
|
43
|
+
"default": "./dist/index.mjs"
|
|
44
|
+
}
|
|
40
45
|
},
|
|
41
46
|
"./dist/docs.json": {
|
|
42
47
|
"default": "./dist/docs.json"
|
|
43
48
|
},
|
|
49
|
+
"./cjs": {
|
|
50
|
+
"default": "./dist/index.js"
|
|
51
|
+
},
|
|
52
|
+
"./docs": {
|
|
53
|
+
"default": "./dist/docs.json"
|
|
54
|
+
},
|
|
55
|
+
"./esm": {
|
|
56
|
+
"default": "./dist/index.mjs"
|
|
57
|
+
},
|
|
44
58
|
"./package.json": "./package.json"
|
|
45
59
|
},
|
|
46
|
-
"main": "dist/
|
|
47
|
-
"module": "dist/
|
|
60
|
+
"main": "dist/index.js",
|
|
61
|
+
"module": "dist/index.mjs",
|
|
48
62
|
"homepage": "https://xyo.network",
|
|
49
63
|
"license": "LGPL-3.0",
|
|
50
64
|
"publishConfig": {
|
|
@@ -55,6 +69,5 @@
|
|
|
55
69
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
56
70
|
},
|
|
57
71
|
"sideEffects": false,
|
|
58
|
-
"
|
|
59
|
-
"version": "2.72.9"
|
|
72
|
+
"version": "2.73.1"
|
|
60
73
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { compact, flatten } from '@xylabs/lodash'
|
|
1
2
|
import {
|
|
2
3
|
AddressModuleFilter,
|
|
3
4
|
ModuleFilter,
|
|
@@ -9,8 +10,6 @@ import {
|
|
|
9
10
|
QueryModuleFilter,
|
|
10
11
|
} from '@xyo-network/module-model'
|
|
11
12
|
import { Promisable } from '@xyo-network/promise'
|
|
12
|
-
import compact from 'lodash/compact'
|
|
13
|
-
import flatten from 'lodash/flatten'
|
|
14
13
|
|
|
15
14
|
//This class is now package private (not exported from index.ts)
|
|
16
15
|
export class SimpleModuleResolver implements ModuleRepository {
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup'
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line import/no-default-export
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
bundle: true,
|
|
6
|
+
cjsInterop: true,
|
|
7
|
+
clean: true,
|
|
8
|
+
dts: {
|
|
9
|
+
entry: ['src/index.ts'],
|
|
10
|
+
},
|
|
11
|
+
entry: ['src/index.ts'],
|
|
12
|
+
format: ['cjs', 'esm'],
|
|
13
|
+
sourcemap: true,
|
|
14
|
+
splitting: false,
|
|
15
|
+
tsconfig: 'tsconfig.json',
|
|
16
|
+
})
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CompositeModuleResolver = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const exists_1 = require("@xylabs/exists");
|
|
6
|
-
const core_1 = require("@xyo-network/core");
|
|
7
|
-
const module_model_1 = require("@xyo-network/module-model");
|
|
8
|
-
const SimpleModuleResolver_1 = require("./SimpleModuleResolver");
|
|
9
|
-
class CompositeModuleResolver extends core_1.Base {
|
|
10
|
-
constructor(params = {}) {
|
|
11
|
-
super(params);
|
|
12
|
-
this.resolvers = [];
|
|
13
|
-
const localResolver = new SimpleModuleResolver_1.SimpleModuleResolver();
|
|
14
|
-
this.addResolver(localResolver);
|
|
15
|
-
this.localResolver = localResolver;
|
|
16
|
-
}
|
|
17
|
-
get isModuleResolver() {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
add(module) {
|
|
21
|
-
if (Array.isArray(module)) {
|
|
22
|
-
module.forEach((module) => this.addSingleModule(module));
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
this.addSingleModule(module);
|
|
26
|
-
}
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
addResolver(resolver) {
|
|
30
|
-
this.resolvers.push(resolver);
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
remove(addressOrName) {
|
|
34
|
-
if (Array.isArray(addressOrName)) {
|
|
35
|
-
addressOrName.forEach((address) => this.removeSingleModule(address));
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
this.removeSingleModule(addressOrName);
|
|
39
|
-
}
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
removeResolver(resolver) {
|
|
43
|
-
this.resolvers = this.resolvers.filter((item) => item !== resolver);
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
resolve(nameOrAddressOrFilter, options) {
|
|
47
|
-
var _a;
|
|
48
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const mutatedOptions = Object.assign(Object.assign({}, options), { maxDepth: ((_a = options === null || options === void 0 ? void 0 : options.maxDepth) !== null && _a !== void 0 ? _a : CompositeModuleResolver.defaultMaxDepth) - 1 });
|
|
50
|
-
if (typeof nameOrAddressOrFilter === 'string') {
|
|
51
|
-
if (mutatedOptions.maxDepth < 0) {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
const results = yield Promise.all(this.resolvers.map((resolver) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const result = yield resolver.resolve(nameOrAddressOrFilter, mutatedOptions);
|
|
56
|
-
return result;
|
|
57
|
-
})));
|
|
58
|
-
const result = results.filter(exists_1.exists).filter(module_model_1.duplicateModules).pop();
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
if (mutatedOptions.maxDepth < 0) {
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
const result = yield Promise.all(this.resolvers.map((resolver) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const result = yield resolver.resolve(nameOrAddressOrFilter, mutatedOptions);
|
|
67
|
-
return result;
|
|
68
|
-
})));
|
|
69
|
-
const flatResult = result.flat();
|
|
70
|
-
return flatResult.filter(module_model_1.duplicateModules);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
addSingleModule(module) {
|
|
75
|
-
if (module) {
|
|
76
|
-
this.localResolver.add(module);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
removeSingleModule(addressOrName) {
|
|
80
|
-
this.localResolver.remove(addressOrName);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.CompositeModuleResolver = CompositeModuleResolver;
|
|
84
|
-
CompositeModuleResolver.defaultMaxDepth = 5;
|
|
85
|
-
//# sourceMappingURL=CompositeModuleResolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeModuleResolver.js","sourceRoot":"","sources":["../../src/CompositeModuleResolver.ts"],"names":[],"mappings":";;;;AAAA,2CAAuC;AACvC,4CAAoD;AACpD,4DAAiJ;AAEjJ,iEAA6D;AAE7D,MAAa,uBAAwB,SAAQ,WAAI;IAK/C,YAAY,SAAqB,EAAE;QACjC,KAAK,CAAC,MAAM,CAAC,CAAA;QAJL,cAAS,GAAqB,EAAE,CAAA;QAKxC,MAAM,aAAa,GAAG,IAAI,2CAAoB,EAAE,CAAA;QAChD,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAA;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;IAED,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAID,GAAG,CAAC,MAAyC;QAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzB,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;SACzD;aAAM;YACL,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;SAC7B;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,WAAW,CAAC,QAAwB;QAClC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC7B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,CAAC,a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,cAAc,CAAC,QAAQ,GAAG,CAAC,EAAE;oBAC/B,OAAO,EAAE,CAAA;iBACV;gBACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC9B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAO,QAAQ,EAAE,EAAE;oBACpC,MAAM,MAAM,GAAQ,MAAM,QAAQ,CAAC,OAAO,CAAI,qBAAqB,EAAE,cAAc,CAAC,CAAA;oBACpF,OAAO,MAAM,CAAA;gBACf,CAAC,CAAA,CAAC,CACH,CAAA;gBACD,MAAM,UAAU,GAAQ,MAAM,CAAC,IAAI,EAAE,CAAA;gBACrC,OAAO,UAAU,CAAC,MAAM,CAAC,+BAAgB,CAAC,CAAA;aAC3C;;KACF;IAEO,eAAe,CAAC,MAAuB;QAC7C,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;SAC/B;IACH,CAAC;IACO,kBAAkB,CAAC,aAAqB;QAC9C,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;IAC1C,CAAC;;AAvFH,0DAwFC;AAvFQ,uCAAe,GAAG,CAAC,AAAJ,CAAI"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mixinResolverEventEmitter = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const getMixin = (resolver) => {
|
|
6
|
-
const listeners = [];
|
|
7
|
-
const emit = (event, args) => {
|
|
8
|
-
if (listeners.length < 1)
|
|
9
|
-
return false;
|
|
10
|
-
listeners.map((listener) => listener(args));
|
|
11
|
-
return true;
|
|
12
|
-
};
|
|
13
|
-
const onModuleResolved = (module, filter) => {
|
|
14
|
-
const args = { filter, module };
|
|
15
|
-
emit('moduleResolved', args);
|
|
16
|
-
};
|
|
17
|
-
const { resolve } = resolver;
|
|
18
|
-
function originalResolve(filter) {
|
|
19
|
-
return resolve.bind(resolver)(filter);
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
on: (event, listener) => {
|
|
23
|
-
listeners.push(listener);
|
|
24
|
-
},
|
|
25
|
-
resolve: (filter) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
const modules = yield originalResolve(filter);
|
|
27
|
-
yield Promise.allSettled(modules.map((mod) => onModuleResolved(mod, filter)));
|
|
28
|
-
return modules;
|
|
29
|
-
}),
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
const mixinResolverEventEmitter = (resolver) => {
|
|
33
|
-
const mixin = getMixin(resolver);
|
|
34
|
-
const ret = Object.assign(resolver, mixin);
|
|
35
|
-
return ret;
|
|
36
|
-
};
|
|
37
|
-
exports.mixinResolverEventEmitter = mixinResolverEventEmitter;
|
|
38
|
-
//# sourceMappingURL=ResolverEventEmitter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResolverEventEmitter.js","sourceRoot":"","sources":["../../src/ResolverEventEmitter.ts"],"names":[],"mappings":";;;;AAaA,MAAM,QAAQ,GAAG,CAA4C,QAAW,EAAE,EAAE;IAC1E,MAAM,SAAS,GAAuB,EAAE,CAAA;IACxC,MAAM,IAAI,GAAG,CAAC,KAAuB,EAAE,IAA6B,EAAW,EAAE;QAC/E,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,KAAK,CAAA;QACtC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;QAC3C,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IACD,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAE,MAAqB,EAAE,EAAE;QACjE,MAAM,IAAI,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;QAC/B,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAA;IAC9B,CAAC,CAAA;IACD,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAA;IAC5B,SAAS,eAAe,CAAC,MAAqB;QAC5C,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAA;IACvC,CAAC;IAED,OAAO;QACL,EAAE,EAAE,CAAC,KAAuB,EAAE,QAAiD,EAAE,EAAE;YACjF,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC1B,CAAC;QACD,OAAO,EAAE,CAAO,MAAqB,EAAqB,EAAE;YAC1D,MAAM,OAAO,GAAa,MAAM,eAAe,CAAC,MAAM,CAAC,CAAA;YACvD,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;YAC7E,OAAO,OAAO,CAAA;QAChB,CAAC,CAAA;KACF,CAAA;AACH,CAAC,CAAA;AAEM,MAAM,yBAAyB,GAAG,CAA4C,QAAW,EAA4B,EAAE;IAC5H,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAChC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IAC1C,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAJY,QAAA,yBAAyB,6BAIrC"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SimpleModuleResolver = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const compact_1 = tslib_1.__importDefault(require("lodash/compact"));
|
|
6
|
-
const flatten_1 = tslib_1.__importDefault(require("lodash/flatten"));
|
|
7
|
-
//This class is now package private (not exported from index.ts)
|
|
8
|
-
class SimpleModuleResolver {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.addressToName = {};
|
|
11
|
-
this.modules = {};
|
|
12
|
-
}
|
|
13
|
-
get isModuleResolver() {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
add(module) {
|
|
17
|
-
if (Array.isArray(module)) {
|
|
18
|
-
module.forEach((module) => this.addSingleModule(module));
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
this.addSingleModule(module);
|
|
22
|
-
}
|
|
23
|
-
return this;
|
|
24
|
-
}
|
|
25
|
-
addResolver(_resolver) {
|
|
26
|
-
throw 'Adding resolvers not supported';
|
|
27
|
-
}
|
|
28
|
-
remove(address) {
|
|
29
|
-
if (Array.isArray(address)) {
|
|
30
|
-
address.forEach((address) => this.removeSingleModule(address));
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
this.removeSingleModule(address);
|
|
34
|
-
}
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
removeResolver(_resolver) {
|
|
38
|
-
throw 'Removing resolvers not supported';
|
|
39
|
-
}
|
|
40
|
-
resolve(nameOrAddressOrFilter, options) {
|
|
41
|
-
const unfiltered = (() => {
|
|
42
|
-
var _a;
|
|
43
|
-
if (nameOrAddressOrFilter) {
|
|
44
|
-
if (typeof nameOrAddressOrFilter === 'string') {
|
|
45
|
-
return ((_a = this.resolveByName(Object.values(this.modules), [nameOrAddressOrFilter]).pop()) !== null && _a !== void 0 ? _a : this.resolveByAddress(Object.values(this.modules), [nameOrAddressOrFilter]).pop());
|
|
46
|
-
}
|
|
47
|
-
else if (nameOrAddressOrFilter.address) {
|
|
48
|
-
return this.resolveByAddress(Object.values(this.modules), nameOrAddressOrFilter.address);
|
|
49
|
-
}
|
|
50
|
-
else if (nameOrAddressOrFilter.name) {
|
|
51
|
-
return this.resolveByName(Object.values(this.modules), nameOrAddressOrFilter.name);
|
|
52
|
-
}
|
|
53
|
-
else if (nameOrAddressOrFilter.query) {
|
|
54
|
-
return this.resolveByQuery(Object.values(this.modules), nameOrAddressOrFilter.query);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return Object.values(this.modules);
|
|
59
|
-
}
|
|
60
|
-
})();
|
|
61
|
-
const identity = options === null || options === void 0 ? void 0 : options.identity;
|
|
62
|
-
if (identity) {
|
|
63
|
-
return Array.isArray(unfiltered) ? unfiltered === null || unfiltered === void 0 ? void 0 : unfiltered.filter((module) => identity(module)) : identity(unfiltered) ? unfiltered : undefined;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
return unfiltered;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
addSingleModule(module) {
|
|
70
|
-
if (module) {
|
|
71
|
-
this.modules[module.address] = module;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
removeSingleModule(address) {
|
|
75
|
-
if (address) {
|
|
76
|
-
if (this.modules[address]) {
|
|
77
|
-
delete this.modules[address];
|
|
78
|
-
const name = this.addressToName[address];
|
|
79
|
-
if (name) {
|
|
80
|
-
delete this.addressToName[address];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
resolveByAddress(modules, address) {
|
|
86
|
-
return (address
|
|
87
|
-
? (0, compact_1.default)((0, flatten_1.default)(address === null || address === void 0 ? void 0 : address.map((address) => {
|
|
88
|
-
return modules.filter((module) => module.address === address);
|
|
89
|
-
})))
|
|
90
|
-
: modules);
|
|
91
|
-
}
|
|
92
|
-
resolveByName(modules, name) {
|
|
93
|
-
if (name) {
|
|
94
|
-
return (0, compact_1.default)(name.map((name) => modules.filter((module) => { var _a; return ((_a = module.config) === null || _a === void 0 ? void 0 : _a.name) === name; })).flat());
|
|
95
|
-
}
|
|
96
|
-
return modules;
|
|
97
|
-
}
|
|
98
|
-
resolveByQuery(modules, query) {
|
|
99
|
-
return (query
|
|
100
|
-
? (0, compact_1.default)(modules.filter((module) => query === null || query === void 0 ? void 0 : query.reduce((supported, queryList) => {
|
|
101
|
-
return (queryList.reduce((supported, query) => {
|
|
102
|
-
const queryable = module.queries.includes(query);
|
|
103
|
-
return supported && queryable;
|
|
104
|
-
}, true) || supported);
|
|
105
|
-
}, false)))
|
|
106
|
-
: modules);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.SimpleModuleResolver = SimpleModuleResolver;
|
|
110
|
-
//# sourceMappingURL=SimpleModuleResolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleModuleResolver.js","sourceRoot":"","sources":["../../src/SimpleModuleResolver.ts"],"names":[],"mappings":";;;;AAWA,qEAAoC;AACpC,qEAAoC;AAEpC,gEAAgE;AAChE,MAAa,oBAAoB;IAAjC;QACU,kBAAa,GAA2B,EAAE,CAAA;QAC1C,YAAO,GAAmC,EAAE,CAAA;IA4HtD,CAAC;IA1HC,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAID,GAAG,CAAC,MAAyC;QAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzB,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;SACzD;aAAM;YACL,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;SAC7B;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,WAAW,CAAC,SAAyB;QACnC,MAAM,gCAAgC,CAAA;IACxC,CAAC;IAED,MAAM,CAAC,OAA0B;QAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC1B,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAA;SAC/D;aAAM;YACL,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;SACjC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,cAAc,CAAC,SA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,EAAE;YACR,OAAO,IAAA,iBAAO,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,WAAC,OAAA,CAAA,MAAA,MAAM,CAAC,MAAM,0CAAE,IAAI,MAAK,IAAI,CAAA,EAAA,CAAC,CAAC,CAAC,IAAI,EAAE,CAAQ,CAAA;SAC3G;QACD,OAAO,OAAc,CAAA;IACvB,CAAC;IAEO,cAAc,CAA4C,OAAyB,EAAE,KAAkB;QAC7G,OAAO,CACL,KAAK;YACH,CAAC,CAAC,IAAA,iBAAO,EACL,OAAO,CAAC,MAAM,CACZ,CAAC,MAAM,EAAE,EAAE,CACT,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;gBACrC,OAAO,CACL,SAAS,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE;oBACpC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;oBAChD,OAAO,SAAS,IAAI,SAAS,CAAA;gBAC/B,CAAC,EAAE,IAAI,CAAC,IAAI,SAAS,CACtB,CAAA;YACH,CAAC,EAAE,KAAK,CAAC,CACZ,CACF;YACH,CAAC,CAAC,OAAO,CACL,CAAA;IACV,CAAC;CACF;AA9HD,oDA8HC"}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./CompositeModuleResolver"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./ResolverEventEmitter"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./SimpleModuleResolver"), exports);
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyC;AACzC,iEAAsC;AACtC,iEAAsC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { exists } from '@xylabs/exists';
|
|
2
|
-
import { Base } from '@xyo-network/core';
|
|
3
|
-
import { duplicateModules } from '@xyo-network/module-model';
|
|
4
|
-
import { SimpleModuleResolver } from './SimpleModuleResolver';
|
|
5
|
-
export class CompositeModuleResolver extends Base {
|
|
6
|
-
static defaultMaxDepth = 5;
|
|
7
|
-
resolvers = [];
|
|
8
|
-
localResolver;
|
|
9
|
-
constructor(params = {}) {
|
|
10
|
-
super(params);
|
|
11
|
-
const localResolver = new SimpleModuleResolver();
|
|
12
|
-
this.addResolver(localResolver);
|
|
13
|
-
this.localResolver = localResolver;
|
|
14
|
-
}
|
|
15
|
-
get isModuleResolver() {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
add(module) {
|
|
19
|
-
if (Array.isArray(module)) {
|
|
20
|
-
module.forEach((module) => this.addSingleModule(module));
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
this.addSingleModule(module);
|
|
24
|
-
}
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
addResolver(resolver) {
|
|
28
|
-
this.resolvers.push(resolver);
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
remove(addressOrName) {
|
|
32
|
-
if (Array.isArray(addressOrName)) {
|
|
33
|
-
addressOrName.forEach((address) => this.removeSingleModule(address));
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
this.removeSingleModule(addressOrName);
|
|
37
|
-
}
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
removeResolver(resolver) {
|
|
41
|
-
this.resolvers = this.resolvers.filter((item) => item !== resolver);
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
async resolve(nameOrAddressOrFilter, options) {
|
|
45
|
-
const mutatedOptions = { ...options, maxDepth: (options?.maxDepth ?? CompositeModuleResolver.defaultMaxDepth) - 1 };
|
|
46
|
-
if (typeof nameOrAddressOrFilter === 'string') {
|
|
47
|
-
if (mutatedOptions.maxDepth < 0) {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
const results = await Promise.all(this.resolvers.map(async (resolver) => {
|
|
51
|
-
const result = await resolver.resolve(nameOrAddressOrFilter, mutatedOptions);
|
|
52
|
-
return result;
|
|
53
|
-
}));
|
|
54
|
-
const result = results.filter(exists).filter(duplicateModules).pop();
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
if (mutatedOptions.maxDepth < 0) {
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
const result = await Promise.all(this.resolvers.map(async (resolver) => {
|
|
62
|
-
const result = await resolver.resolve(nameOrAddressOrFilter, mutatedOptions);
|
|
63
|
-
return result;
|
|
64
|
-
}));
|
|
65
|
-
const flatResult = result.flat();
|
|
66
|
-
return flatResult.filter(duplicateModules);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
addSingleModule(module) {
|
|
70
|
-
if (module) {
|
|
71
|
-
this.localResolver.add(module);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
removeSingleModule(addressOrName) {
|
|
75
|
-
this.localResolver.remove(addressOrName);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=CompositeModuleResolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeModuleResolver.js","sourceRoot":"","sources":["../../src/CompositeModuleResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,IAAI,EAAc,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAuF,MAAM,2BAA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AAM,CAAC,IAAI,EAAE,CAAA;YACrC,OAAO,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;SAC3C;IACH,CAAC;IAEO,eAAe,CAAC,MAAuB;QAC7C,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;SAC/B;IACH,CAAC;IACO,kBAAkB,CAAC,aAAqB;QAC9C,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;IAC1C,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const getMixin = (resolver) => {
|
|
2
|
-
const listeners = [];
|
|
3
|
-
const emit = (event, args) => {
|
|
4
|
-
if (listeners.length < 1)
|
|
5
|
-
return false;
|
|
6
|
-
listeners.map((listener) => listener(args));
|
|
7
|
-
return true;
|
|
8
|
-
};
|
|
9
|
-
const onModuleResolved = (module, filter) => {
|
|
10
|
-
const args = { filter, module };
|
|
11
|
-
emit('moduleResolved', args);
|
|
12
|
-
};
|
|
13
|
-
const { resolve } = resolver;
|
|
14
|
-
function originalResolve(filter) {
|
|
15
|
-
return resolve.bind(resolver)(filter);
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
on: (event, listener) => {
|
|
19
|
-
listeners.push(listener);
|
|
20
|
-
},
|
|
21
|
-
resolve: async (filter) => {
|
|
22
|
-
const modules = await originalResolve(filter);
|
|
23
|
-
await Promise.allSettled(modules.map((mod) => onModuleResolved(mod, filter)));
|
|
24
|
-
return modules;
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export const mixinResolverEventEmitter = (resolver) => {
|
|
29
|
-
const mixin = getMixin(resolver);
|
|
30
|
-
const ret = Object.assign(resolver, mixin);
|
|
31
|
-
return ret;
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=ResolverEventEmitter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResolverEventE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AED,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAA4C,QAAW,EAA4B,EAAE;IAC5H,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAChC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IAC1C,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import compact from 'lodash/compact';
|
|
2
|
-
import flatten from 'lodash/flatten';
|
|
3
|
-
//This class is now package private (not exported from index.ts)
|
|
4
|
-
export class SimpleModuleResolver {
|
|
5
|
-
addressToName = {};
|
|
6
|
-
modules = {};
|
|
7
|
-
get isModuleResolver() {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
add(module) {
|
|
11
|
-
if (Array.isArray(module)) {
|
|
12
|
-
module.forEach((module) => this.addSingleModule(module));
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
this.addSingleModule(module);
|
|
16
|
-
}
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
addResolver(_resolver) {
|
|
20
|
-
throw 'Adding resolvers not supported';
|
|
21
|
-
}
|
|
22
|
-
remove(address) {
|
|
23
|
-
if (Array.isArray(address)) {
|
|
24
|
-
address.forEach((address) => this.removeSingleModule(address));
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
this.removeSingleModule(address);
|
|
28
|
-
}
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
removeResolver(_resolver) {
|
|
32
|
-
throw 'Removing resolvers not supported';
|
|
33
|
-
}
|
|
34
|
-
resolve(nameOrAddressOrFilter, options) {
|
|
35
|
-
const unfiltered = (() => {
|
|
36
|
-
if (nameOrAddressOrFilter) {
|
|
37
|
-
if (typeof nameOrAddressOrFilter === 'string') {
|
|
38
|
-
return (this.resolveByName(Object.values(this.modules), [nameOrAddressOrFilter]).pop() ??
|
|
39
|
-
this.resolveByAddress(Object.values(this.modules), [nameOrAddressOrFilter]).pop());
|
|
40
|
-
}
|
|
41
|
-
else if (nameOrAddressOrFilter.address) {
|
|
42
|
-
return this.resolveByAddress(Object.values(this.modules), nameOrAddressOrFilter.address);
|
|
43
|
-
}
|
|
44
|
-
else if (nameOrAddressOrFilter.name) {
|
|
45
|
-
return this.resolveByName(Object.values(this.modules), nameOrAddressOrFilter.name);
|
|
46
|
-
}
|
|
47
|
-
else if (nameOrAddressOrFilter.query) {
|
|
48
|
-
return this.resolveByQuery(Object.values(this.modules), nameOrAddressOrFilter.query);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
return Object.values(this.modules);
|
|
53
|
-
}
|
|
54
|
-
})();
|
|
55
|
-
const identity = options?.identity;
|
|
56
|
-
if (identity) {
|
|
57
|
-
return Array.isArray(unfiltered) ? unfiltered?.filter((module) => identity(module)) : identity(unfiltered) ? unfiltered : undefined;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
return unfiltered;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
addSingleModule(module) {
|
|
64
|
-
if (module) {
|
|
65
|
-
this.modules[module.address] = module;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
removeSingleModule(address) {
|
|
69
|
-
if (address) {
|
|
70
|
-
if (this.modules[address]) {
|
|
71
|
-
delete this.modules[address];
|
|
72
|
-
const name = this.addressToName[address];
|
|
73
|
-
if (name) {
|
|
74
|
-
delete this.addressToName[address];
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
resolveByAddress(modules, address) {
|
|
80
|
-
return (address
|
|
81
|
-
? compact(flatten(address?.map((address) => {
|
|
82
|
-
return modules.filter((module) => module.address === address);
|
|
83
|
-
})))
|
|
84
|
-
: modules);
|
|
85
|
-
}
|
|
86
|
-
resolveByName(modules, name) {
|
|
87
|
-
if (name) {
|
|
88
|
-
return compact(name.map((name) => modules.filter((module) => module.config?.name === name)).flat());
|
|
89
|
-
}
|
|
90
|
-
return modules;
|
|
91
|
-
}
|
|
92
|
-
resolveByQuery(modules, query) {
|
|
93
|
-
return (query
|
|
94
|
-
? compact(modules.filter((module) => query?.reduce((supported, queryList) => {
|
|
95
|
-
return (queryList.reduce((supported, query) => {
|
|
96
|
-
const queryable = module.queries.includes(query);
|
|
97
|
-
return supported && queryable;
|
|
98
|
-
}, true) || supported);
|
|
99
|
-
}, false)))
|
|
100
|
-
: modules);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=SimpleModuleResolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleModuleResolver.js","sourceRoot":"","sources":["../../src/SimpleModuleResolver.ts"],"names":[],"mappings":"AAWA,OAAO,OAAO,MAAM,gBAAgB,CAAA;AACpC,OAAO,OAAO,MAAM,gBAAgB,CAAA;AAEpC,gEAAgE;AAChE,MAAM,OAAO,oBAAoB;IACvB,aAAa,GAA2B,EAAE,CAAA;IAC1C,OAAO,GAAmC,EAAE,CAAA;IAEpD,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAID,GAAG,CAAC,MAAyC;QAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzB,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;SACzD;aAAM;YACL,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;SAC7B;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,WAAW,CAAC,SAAyB;QACnC,MAAM,gCAAgC,CAAA;IACxC,CAAC;IAED,MAAM,CAAC,OAA0B;QAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC1B,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CA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,CACL,CAAA;IACV,CAAC;IAEO,aAAa,CAA4C,OAAyB,EAAE,IAAe;QACzG,IAAI,IAAI,EAAE;YACR,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAQ,CAAA;SAC3G;QACD,OAAO,OAAc,CAAA;IACvB,CAAC;IAEO,cAAc,CAA4C,OAAyB,EAAE,KAAkB;QAC7G,OAAO,CACL,KAAK;YACH,CAAC,CAAC,OAAO,CACL,OAAO,CAAC,MAAM,CACZ,CAAC,MAAM,EAAE,EAAE,CACT,KAAK,EAAE,MAAM,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;gBACrC,OAAO,CACL,SAAS,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE;oBACpC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;oBAChD,OAAO,SAAS,IAAI,SAAS,CAAA;gBAC/B,CAAC,EAAE,IAAI,CAAC,IAAI,SAAS,CACtB,CAAA;YACH,CAAC,EAAE,KAAK,CAAC,CACZ,CACF;YACH,CAAC,CAAC,OAAO,CACL,CAAA;IACV,CAAC;CACF"}
|
package/dist/esm/index.js
DELETED
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Base, BaseParams } from '@xyo-network/core';
|
|
2
|
-
import { ModuleFilter, ModuleFilterOptions, ModuleInstance, ModuleRepository, ModuleResolver } from '@xyo-network/module-model';
|
|
3
|
-
export declare class CompositeModuleResolver extends Base implements ModuleRepository, ModuleResolver {
|
|
4
|
-
static defaultMaxDepth: number;
|
|
5
|
-
protected resolvers: ModuleResolver[];
|
|
6
|
-
private localResolver;
|
|
7
|
-
constructor(params?: BaseParams);
|
|
8
|
-
get isModuleResolver(): boolean;
|
|
9
|
-
add(module: ModuleInstance): this;
|
|
10
|
-
add(module: ModuleInstance[]): this;
|
|
11
|
-
addResolver(resolver: ModuleResolver): this;
|
|
12
|
-
remove(addressOrName: string | string[]): this;
|
|
13
|
-
removeResolver(resolver: ModuleResolver): this;
|
|
14
|
-
resolve<T extends ModuleInstance = ModuleInstance>(filter?: ModuleFilter<T>, options?: ModuleFilterOptions<T>): Promise<T[]>;
|
|
15
|
-
resolve<T extends ModuleInstance = ModuleInstance>(nameOrAddress: string, options?: ModuleFilterOptions<T>): Promise<T | undefined>;
|
|
16
|
-
private addSingleModule;
|
|
17
|
-
private removeSingleModule;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=CompositeModuleResolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeModuleResolver.d.ts","sourceRoot":"","sources":["../../src/CompositeModuleResolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAoB,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAIjJ,qBAAa,uBAAwB,SAAQ,IAAK,YAAW,gBAAgB,EAAE,cAAc;IAC3F,MAAM,CAAC,eAAe,SAAI;IAC1B,SAAS,CAAC,SAAS,EAAE,cAAc,EAAE,CAAK;IAC1C,OAAO,CAAC,aAAa,CAAsB;gBAE/B,MAAM,GAAE,UAAe;IAOnC,IAAI,gBAAgB,YAEnB;IAED,GAAG,CAAC,MAAM,EAAE,cA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