@midwayjs/core 2.13.3 → 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 +17 -0
- package/dist/context/configuration.js +7 -2
- 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 +4 -4
- package/dist/util/serviceFactory.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
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
|
+
|
|
6
23
|
## [2.13.3](https://github.com/midwayjs/midway/compare/v2.13.2...v2.13.3) (2021-09-28)
|
|
7
24
|
|
|
8
25
|
|
|
@@ -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
|
}
|
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> {
|
|
4
|
+
export declare abstract class ServiceFactory<T, U = T> {
|
|
5
5
|
protected clients: Map<string, T>;
|
|
6
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",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">= 10.0.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "9e61ff6e854b5641201e7d3df8aa19a7d6287f3d"
|
|
55
55
|
}
|