@midwayjs/core 2.13.0 → 2.13.4
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/CHANGELOG.md +48 -0
- package/dist/context/configuration.js +7 -2
- package/dist/context/managedResolverFactory.js +15 -4
- package/dist/context/requestContainer.js +16 -4
- package/dist/functional/configuration.d.ts +3 -3
- package/dist/functional/configuration.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/dist/util/index.d.ts +17 -0
- package/dist/util/index.js +36 -4
- package/dist/util/serviceFactory.d.ts +6 -6
- package/dist/util/serviceFactory.js +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,54 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.13.4](https://github.com/midwayjs/midway/compare/v2.13.3...v2.13.4) (2021-10-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* load component with enabledEnvironment ([#1329](https://github.com/midwayjs/midway/issues/1329)) ([803cd46](https://github.com/midwayjs/midway/commit/803cd4617502973daf06072f252767309554e272))
|
|
12
|
+
* static prefix ([#1321](https://github.com/midwayjs/midway/issues/1321)) ([e6b4e46](https://github.com/midwayjs/midway/commit/e6b4e4673c1d2480da23d6bd664b613c813ee131))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add mongoose component and support multi-instance for typegoose ([#1334](https://github.com/midwayjs/midway/issues/1334)) ([ec54224](https://github.com/midwayjs/midway/commit/ec54224d775a3cfde3ff280538c8db79bcff4610))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [2.13.3](https://github.com/midwayjs/midway/compare/v2.13.2...v2.13.3) (2021-09-28)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* circular inject for provide uuid ([#1285](https://github.com/midwayjs/midway/issues/1285)) ([29a7ab7](https://github.com/midwayjs/midway/commit/29a7ab742359f7803f5dc562329e887b191a2d63))
|
|
29
|
+
* functional configuration load async code ([#1300](https://github.com/midwayjs/midway/issues/1300)) ([8cb4bd6](https://github.com/midwayjs/midway/commit/8cb4bd679e7e731f8649466cfb7f6a4b35ba2683))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## [2.13.2](https://github.com/midwayjs/midway/compare/v2.13.1...v2.13.2) (2021-09-09)
|
|
36
|
+
|
|
37
|
+
**Note:** Version bump only for package @midwayjs/core
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## [2.13.1](https://github.com/midwayjs/midway/compare/v2.13.0...v2.13.1) (2021-09-08)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Bug Fixes
|
|
47
|
+
|
|
48
|
+
* requestContainer missing ctx inject in component ([#1280](https://github.com/midwayjs/midway/issues/1280)) ([34166fb](https://github.com/midwayjs/midway/commit/34166fb9e5bd1b08c3894de25c8a7a0c3e9a8655))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
6
54
|
# [2.13.0](https://github.com/midwayjs/midway/compare/v2.12.9...v2.13.0) (2021-09-07)
|
|
7
55
|
|
|
8
56
|
|
|
@@ -21,7 +21,7 @@ class ContainerConfiguration {
|
|
|
21
21
|
this.loadDirs.push(dir);
|
|
22
22
|
}
|
|
23
23
|
addImports(imports = [], baseDir) {
|
|
24
|
-
var _a, _b;
|
|
24
|
+
var _a, _b, _c;
|
|
25
25
|
// 处理 imports
|
|
26
26
|
for (const importPackage of imports) {
|
|
27
27
|
if (!importPackage)
|
|
@@ -44,7 +44,12 @@ class ContainerConfiguration {
|
|
|
44
44
|
}
|
|
45
45
|
else if ('component' in importPackage) {
|
|
46
46
|
subContainerConfiguration.newVersion = true;
|
|
47
|
-
if ((
|
|
47
|
+
if ((_a = importPackage) === null || _a === void 0 ? void 0 : _a.enabledEnvironment) {
|
|
48
|
+
if ((_c = (_b = importPackage) === null || _b === void 0 ? void 0 : _b.enabledEnvironment) === null || _c === void 0 ? void 0 : _c.includes(this.container.getCurrentEnv())) {
|
|
49
|
+
subContainerConfiguration.loadComponentObject(importPackage.component);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
48
53
|
subContainerConfiguration.loadComponentObject(importPackage.component);
|
|
49
54
|
}
|
|
50
55
|
}
|
|
@@ -574,6 +574,21 @@ class ManagedResolverFactory {
|
|
|
574
574
|
if (ref && ref.name) {
|
|
575
575
|
iden = ref.name;
|
|
576
576
|
}
|
|
577
|
+
let subDefinition = this.context.registry.getDefinition(iden);
|
|
578
|
+
if (!subDefinition && this.context.parent) {
|
|
579
|
+
subDefinition = this.context.parent.registry.getDefinition(iden);
|
|
580
|
+
}
|
|
581
|
+
// find uuid
|
|
582
|
+
if (!subDefinition && /:/.test(iden)) {
|
|
583
|
+
iden = iden.replace(/^.*?:/, '');
|
|
584
|
+
subDefinition = this.context.registry.getDefinition(iden);
|
|
585
|
+
if (!subDefinition && this.context.parent) {
|
|
586
|
+
subDefinition = this.context.parent.registry.getDefinition(iden);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
if (subDefinition) {
|
|
590
|
+
iden = subDefinition.id;
|
|
591
|
+
}
|
|
577
592
|
if (iden === identifier) {
|
|
578
593
|
debug('dfs exist in properties key %s == %s.', identifier, definition.id);
|
|
579
594
|
return true;
|
|
@@ -586,10 +601,6 @@ class ManagedResolverFactory {
|
|
|
586
601
|
depth.push(iden);
|
|
587
602
|
debug('dfs depth push %s == %s, %j.', identifier, iden, depth);
|
|
588
603
|
}
|
|
589
|
-
let subDefinition = this.context.registry.getDefinition(iden);
|
|
590
|
-
if (!subDefinition && this.context.parent) {
|
|
591
|
-
subDefinition = this.context.parent.registry.getDefinition(iden);
|
|
592
|
-
}
|
|
593
604
|
if (this.depthFirstSearch(identifier, subDefinition, depth)) {
|
|
594
605
|
debug('dfs exist in sub tree %s == %s subId = %s.', identifier, definition.id, subDefinition.id);
|
|
595
606
|
return true;
|
|
@@ -31,6 +31,7 @@ class MidwayRequestContainer extends midwayContainer_1.MidwayContainer {
|
|
|
31
31
|
// do nothing
|
|
32
32
|
}
|
|
33
33
|
get(identifier, args) {
|
|
34
|
+
const originIdentifier = identifier;
|
|
34
35
|
if (typeof identifier !== 'string') {
|
|
35
36
|
identifier = this.getIdentifier(identifier);
|
|
36
37
|
}
|
|
@@ -38,7 +39,12 @@ class MidwayRequestContainer extends midwayContainer_1.MidwayContainer {
|
|
|
38
39
|
const ins = this.registry.getObject(identifier);
|
|
39
40
|
return this.aspectService.wrapperAspectToInstance(ins);
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
let definition = this.applicationContext.registry.getDefinition(identifier);
|
|
43
|
+
// find uuid
|
|
44
|
+
if (!definition && /:/.test(identifier)) {
|
|
45
|
+
identifier = identifier.replace(/^.*?:/, '');
|
|
46
|
+
definition = this.applicationContext.registry.getDefinition(identifier);
|
|
47
|
+
}
|
|
42
48
|
if (definition) {
|
|
43
49
|
if (definition.isRequestScope() ||
|
|
44
50
|
definition.id === decorator_1.PIPELINE_IDENTIFIER) {
|
|
@@ -51,10 +57,11 @@ class MidwayRequestContainer extends midwayContainer_1.MidwayContainer {
|
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
if (this.parent) {
|
|
54
|
-
return this.parent.get(
|
|
60
|
+
return this.parent.get(originIdentifier, args);
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
async getAsync(identifier, args) {
|
|
64
|
+
const originIdentifier = identifier;
|
|
58
65
|
if (typeof identifier !== 'string') {
|
|
59
66
|
identifier = this.getIdentifier(identifier);
|
|
60
67
|
}
|
|
@@ -63,7 +70,12 @@ class MidwayRequestContainer extends midwayContainer_1.MidwayContainer {
|
|
|
63
70
|
const ins = this.registry.getObject(identifier);
|
|
64
71
|
return this.aspectService.wrapperAspectToInstance(ins);
|
|
65
72
|
}
|
|
66
|
-
|
|
73
|
+
let definition = this.applicationContext.registry.getDefinition(identifier);
|
|
74
|
+
// find uuid
|
|
75
|
+
if (!definition && /:/.test(identifier)) {
|
|
76
|
+
identifier = identifier.replace(/^.*?:/, '');
|
|
77
|
+
definition = this.applicationContext.registry.getDefinition(identifier);
|
|
78
|
+
}
|
|
67
79
|
if (definition) {
|
|
68
80
|
if (definition.isRequestScope() ||
|
|
69
81
|
definition.id === decorator_1.PIPELINE_IDENTIFIER) {
|
|
@@ -76,7 +88,7 @@ class MidwayRequestContainer extends midwayContainer_1.MidwayContainer {
|
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
90
|
if (this.parent) {
|
|
79
|
-
return this.parent.getAsync(
|
|
91
|
+
return this.parent.getAsync(originIdentifier, args);
|
|
80
92
|
}
|
|
81
93
|
}
|
|
82
94
|
async ready() {
|
|
@@ -6,9 +6,9 @@ export declare class FunctionalConfiguration {
|
|
|
6
6
|
private configLoadHandler;
|
|
7
7
|
private options;
|
|
8
8
|
constructor(options: InjectionConfigurationOptions);
|
|
9
|
-
onConfigLoad(configLoadHandler: ((container: IMidwayContainer, app: IMidwayApplication) => any) | IMidwayContainer, app?: IMidwayApplication):
|
|
10
|
-
onReady(readyHandler: ((container: IMidwayContainer, app: IMidwayApplication) => void) | IMidwayContainer, app?: IMidwayApplication):
|
|
11
|
-
onStop(stopHandler: ((container: IMidwayContainer, app: IMidwayApplication) => void) | IMidwayContainer, app?: IMidwayApplication):
|
|
9
|
+
onConfigLoad(configLoadHandler: ((container: IMidwayContainer, app: IMidwayApplication) => any) | IMidwayContainer, app?: IMidwayApplication): any;
|
|
10
|
+
onReady(readyHandler: ((container: IMidwayContainer, app: IMidwayApplication) => void) | IMidwayContainer, app?: IMidwayApplication): any;
|
|
11
|
+
onStop(stopHandler: ((container: IMidwayContainer, app: IMidwayApplication) => void) | IMidwayContainer, app?: IMidwayApplication): any;
|
|
12
12
|
getConfigurationOptions(): InjectionConfigurationOptions;
|
|
13
13
|
}
|
|
14
14
|
export declare const createConfiguration: (options: InjectionConfigurationOptions) => FunctionalConfiguration;
|
|
@@ -13,7 +13,7 @@ class FunctionalConfiguration {
|
|
|
13
13
|
this.configLoadHandler = configLoadHandler;
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
|
-
this.configLoadHandler(configLoadHandler, app);
|
|
16
|
+
return this.configLoadHandler(configLoadHandler, app);
|
|
17
17
|
}
|
|
18
18
|
return this;
|
|
19
19
|
}
|
|
@@ -22,7 +22,7 @@ class FunctionalConfiguration {
|
|
|
22
22
|
this.readyHandler = readyHandler;
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
this.readyHandler(readyHandler, app);
|
|
25
|
+
return this.readyHandler(readyHandler, app);
|
|
26
26
|
}
|
|
27
27
|
return this;
|
|
28
28
|
}
|
|
@@ -31,7 +31,7 @@ class FunctionalConfiguration {
|
|
|
31
31
|
this.stopHandler = stopHandler;
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
|
-
this.stopHandler(stopHandler, app);
|
|
34
|
+
return this.stopHandler(stopHandler, app);
|
|
35
35
|
}
|
|
36
36
|
return this;
|
|
37
37
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { MidwayRequestContainer } from './context/requestContainer';
|
|
|
6
6
|
export { BaseFramework } from './baseFramework';
|
|
7
7
|
export * from './context/providerWrapper';
|
|
8
8
|
export * from './common/constants';
|
|
9
|
-
export { safelyGet, safeRequire, delegateTargetPrototypeMethod } from './util/';
|
|
9
|
+
export { safelyGet, safeRequire, delegateTargetPrototypeMethod, delegateTargetMethod, delegateTargetProperties, } from './util/';
|
|
10
10
|
export * from './util/pathFileUtil';
|
|
11
11
|
export * from './features';
|
|
12
12
|
export * from './util/webRouterParam';
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.MidwayContextLogger = exports.MidwayInformationService = exports.MidwayEnvironmentService = exports.MidwayConfigService = exports.createConfiguration = exports.classToPlain = exports.plainToClass = exports.delegateTargetPrototypeMethod = exports.safeRequire = exports.safelyGet = exports.BaseFramework = exports.MidwayRequestContainer = exports.clearContainerCache = exports.MidwayContainer = exports.ContainerLoader = exports.generateProvideId = exports.classNamed = exports.getObjectDefinition = exports.getProviderId = exports.getParamNames = exports.clearAllModule = exports.resetModule = exports.listModule = exports.saveModule = exports.listPreloadModule = exports.savePreloadModule = exports.getPropertyMetadata = exports.attachPropertyMetadata = exports.savePropertyMetadata = exports.listPropertyDataFromClass = exports.getPropertyDataFromClass = exports.attachPropertyDataToClass = exports.savePropertyDataToClass = exports.getMethodMetadata = exports.attachMethodMetadata = exports.saveMethodMetadata = exports.listMethodDataFromClass = exports.getMethodDataFromClass = exports.attachMethodDataToClass = exports.saveMethodDataToClass = exports.getClassMetadata = exports.attachClassMetadata = exports.saveClassMetadata = exports.MidwayFrameworkType = exports.ScopeEnum = void 0;
|
|
13
|
+
exports.MidwayContextLogger = exports.MidwayInformationService = exports.MidwayEnvironmentService = exports.MidwayConfigService = exports.createConfiguration = exports.classToPlain = exports.plainToClass = exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetPrototypeMethod = exports.safeRequire = exports.safelyGet = exports.BaseFramework = exports.MidwayRequestContainer = exports.clearContainerCache = exports.MidwayContainer = exports.ContainerLoader = exports.generateProvideId = exports.classNamed = exports.getObjectDefinition = exports.getProviderId = exports.getParamNames = exports.clearAllModule = exports.resetModule = exports.listModule = exports.saveModule = exports.listPreloadModule = exports.savePreloadModule = exports.getPropertyMetadata = exports.attachPropertyMetadata = exports.savePropertyMetadata = exports.listPropertyDataFromClass = exports.getPropertyDataFromClass = exports.attachPropertyDataToClass = exports.savePropertyDataToClass = exports.getMethodMetadata = exports.attachMethodMetadata = exports.saveMethodMetadata = exports.listMethodDataFromClass = exports.getMethodDataFromClass = exports.attachMethodDataToClass = exports.saveMethodDataToClass = exports.getClassMetadata = exports.attachClassMetadata = exports.saveClassMetadata = exports.MidwayFrameworkType = exports.ScopeEnum = void 0;
|
|
14
14
|
var decorator_1 = require("@midwayjs/decorator");
|
|
15
15
|
Object.defineProperty(exports, "ScopeEnum", { enumerable: true, get: function () { return decorator_1.ScopeEnum; } });
|
|
16
16
|
Object.defineProperty(exports, "MidwayFrameworkType", { enumerable: true, get: function () { return decorator_1.MidwayFrameworkType; } });
|
|
@@ -58,6 +58,8 @@ var util_1 = require("./util/");
|
|
|
58
58
|
Object.defineProperty(exports, "safelyGet", { enumerable: true, get: function () { return util_1.safelyGet; } });
|
|
59
59
|
Object.defineProperty(exports, "safeRequire", { enumerable: true, get: function () { return util_1.safeRequire; } });
|
|
60
60
|
Object.defineProperty(exports, "delegateTargetPrototypeMethod", { enumerable: true, get: function () { return util_1.delegateTargetPrototypeMethod; } });
|
|
61
|
+
Object.defineProperty(exports, "delegateTargetMethod", { enumerable: true, get: function () { return util_1.delegateTargetMethod; } });
|
|
62
|
+
Object.defineProperty(exports, "delegateTargetProperties", { enumerable: true, get: function () { return util_1.delegateTargetProperties; } });
|
|
61
63
|
__exportStar(require("./util/pathFileUtil"), exports);
|
|
62
64
|
__exportStar(require("./features"), exports);
|
|
63
65
|
__exportStar(require("./util/webRouterParam"), exports);
|
package/dist/util/index.d.ts
CHANGED
|
@@ -17,5 +17,22 @@ export declare function safelyGet(list: string | string[], obj?: Record<string,
|
|
|
17
17
|
export declare function parsePrefix(provideId: string): string;
|
|
18
18
|
export declare function getUserHome(): string;
|
|
19
19
|
export declare function joinURLPath(...strArray: any[]): string;
|
|
20
|
+
/**
|
|
21
|
+
* 代理目标所有的原型方法,不包括构造器和内部隐藏方法
|
|
22
|
+
* @param derivedCtor
|
|
23
|
+
* @param constructors
|
|
24
|
+
*/
|
|
20
25
|
export declare function delegateTargetPrototypeMethod(derivedCtor: any, constructors: any[]): void;
|
|
26
|
+
/**
|
|
27
|
+
* 代理目标原型上的特定方法
|
|
28
|
+
* @param derivedCtor
|
|
29
|
+
* @param methods
|
|
30
|
+
*/
|
|
31
|
+
export declare function delegateTargetMethod(derivedCtor: any, methods: string[]): void;
|
|
32
|
+
/**
|
|
33
|
+
* 代理目标原型属性
|
|
34
|
+
* @param derivedCtor
|
|
35
|
+
* @param properties
|
|
36
|
+
*/
|
|
37
|
+
export declare function delegateTargetProperties(derivedCtor: any, properties: string[]): void;
|
|
21
38
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/util/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.delegateTargetPrototypeMethod = exports.joinURLPath = exports.getUserHome = exports.parsePrefix = exports.safelyGet = exports.safeRequire = exports.getCurrentEnvironment = exports.isDevelopmentEnvironment = void 0;
|
|
3
|
+
exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetPrototypeMethod = exports.joinURLPath = exports.getUserHome = exports.parsePrefix = exports.safelyGet = exports.safeRequire = exports.getCurrentEnvironment = exports.isDevelopmentEnvironment = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const util_1 = require("util");
|
|
@@ -29,8 +29,7 @@ const safeRequire = (p, enabledCache = true) => {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
catch (err) {
|
|
32
|
-
debug('SafeRequire Warning');
|
|
33
|
-
debug(err);
|
|
32
|
+
debug('SafeRequire Warning', err.message);
|
|
34
33
|
return undefined;
|
|
35
34
|
}
|
|
36
35
|
};
|
|
@@ -91,11 +90,16 @@ function joinURLPath(...strArray) {
|
|
|
91
90
|
return p;
|
|
92
91
|
}
|
|
93
92
|
exports.joinURLPath = joinURLPath;
|
|
93
|
+
/**
|
|
94
|
+
* 代理目标所有的原型方法,不包括构造器和内部隐藏方法
|
|
95
|
+
* @param derivedCtor
|
|
96
|
+
* @param constructors
|
|
97
|
+
*/
|
|
94
98
|
function delegateTargetPrototypeMethod(derivedCtor, constructors) {
|
|
95
99
|
constructors.forEach(baseCtor => {
|
|
96
100
|
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
|
|
97
101
|
if (name !== 'constructor' && !/^_/.test(name)) {
|
|
98
|
-
derivedCtor.prototype[name] =
|
|
102
|
+
derivedCtor.prototype[name] = function (...args) {
|
|
99
103
|
return this.instance[name](...args);
|
|
100
104
|
};
|
|
101
105
|
}
|
|
@@ -103,4 +107,32 @@ function delegateTargetPrototypeMethod(derivedCtor, constructors) {
|
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
109
|
exports.delegateTargetPrototypeMethod = delegateTargetPrototypeMethod;
|
|
110
|
+
/**
|
|
111
|
+
* 代理目标原型上的特定方法
|
|
112
|
+
* @param derivedCtor
|
|
113
|
+
* @param methods
|
|
114
|
+
*/
|
|
115
|
+
function delegateTargetMethod(derivedCtor, methods) {
|
|
116
|
+
methods.forEach(name => {
|
|
117
|
+
derivedCtor.prototype[name] = function (...args) {
|
|
118
|
+
return this.instance[name](...args);
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
exports.delegateTargetMethod = delegateTargetMethod;
|
|
123
|
+
/**
|
|
124
|
+
* 代理目标原型属性
|
|
125
|
+
* @param derivedCtor
|
|
126
|
+
* @param properties
|
|
127
|
+
*/
|
|
128
|
+
function delegateTargetProperties(derivedCtor, properties) {
|
|
129
|
+
properties.forEach(name => {
|
|
130
|
+
Object.defineProperty(derivedCtor.prototype, name, {
|
|
131
|
+
get() {
|
|
132
|
+
return this.instance[name];
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
exports.delegateTargetProperties = delegateTargetProperties;
|
|
106
138
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 多客户端工厂实现
|
|
3
3
|
*/
|
|
4
|
-
export declare abstract class ServiceFactory<T> {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare abstract class ServiceFactory<T, U = T> {
|
|
5
|
+
protected clients: Map<string, T>;
|
|
6
|
+
protected options: {};
|
|
7
7
|
protected initClients(options: any): Promise<void>;
|
|
8
8
|
get<U = T>(id?: string): U;
|
|
9
|
-
createInstance(config: any, clientName?: any): Promise<
|
|
10
|
-
abstract getName():
|
|
11
|
-
protected abstract createClient(config: any):
|
|
9
|
+
createInstance(config: any, clientName?: any): Promise<T>;
|
|
10
|
+
abstract getName(): string;
|
|
11
|
+
protected abstract createClient(config: any, clientName: any): Promise<T>;
|
|
12
12
|
protected destroyClient(client: T): Promise<void>;
|
|
13
13
|
stop(): Promise<void>;
|
|
14
14
|
}
|
|
@@ -31,7 +31,7 @@ class ServiceFactory {
|
|
|
31
31
|
async createInstance(config, clientName) {
|
|
32
32
|
// options.default will be merge in to options.clients[id]
|
|
33
33
|
config = Object.assign({}, this.options['default'], config);
|
|
34
|
-
const client = await this.createClient(config);
|
|
34
|
+
const client = await this.createClient(config, clientName);
|
|
35
35
|
if (clientName) {
|
|
36
36
|
this.clients.set(clientName, client);
|
|
37
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.4",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -21,8 +21,9 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@midwayjs/decorator": "^2.13.
|
|
24
|
+
"@midwayjs/decorator": "^2.13.2",
|
|
25
25
|
"chai": "^4.2.0",
|
|
26
|
+
"midway-test-component": "*",
|
|
26
27
|
"mm": "3",
|
|
27
28
|
"sinon": "^7.2.2"
|
|
28
29
|
},
|
|
@@ -50,5 +51,5 @@
|
|
|
50
51
|
"engines": {
|
|
51
52
|
"node": ">= 10.0.0"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "9e61ff6e854b5641201e7d3df8aa19a7d6287f3d"
|
|
54
55
|
}
|