@midwayjs/core 3.0.0-beta.5 → 3.0.0-beta.6
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 +11 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -4
- package/dist/service/decoratorService.js +21 -21
- package/dist/util/index.js +3 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
# [3.0.0-beta.6](https://github.com/midwayjs/midway/compare/v3.0.0-beta.5...v3.0.0-beta.6) (2021-11-26)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* class transformer method missing ([#1387](https://github.com/midwayjs/midway/issues/1387)) ([074e839](https://github.com/midwayjs/midway/commit/074e8393598dc95e2742f735df75a2191c5fe25d))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [3.0.0-beta.5](https://github.com/midwayjs/midway/compare/v3.0.0-beta.4...v3.0.0-beta.5) (2021-11-25)
|
|
7
18
|
|
|
8
19
|
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export * from './util/pathFileUtil';
|
|
|
9
9
|
export * from './util/webRouterParam';
|
|
10
10
|
export * from './common/webRouterCollector';
|
|
11
11
|
export * from './common/triggerCollector';
|
|
12
|
-
export { plainToClass, classToPlain } from 'class-transformer';
|
|
13
12
|
export { createConfiguration } from './functional/configuration';
|
|
14
13
|
export { MidwayConfigService } from './service/configService';
|
|
15
14
|
export { MidwayEnvironmentService } from './service/environmentService';
|
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.MidwayFrameworkType = exports.MidwayDecoratorService = exports.MidwayMiddlewareService = exports.MidwayLifeCycleService = exports.MidwayAspectService = exports.MidwayFrameworkService = exports.MidwayLoggerService = exports.MidwayInformationService = exports.MidwayEnvironmentService = exports.MidwayConfigService = exports.createConfiguration = exports.
|
|
13
|
+
exports.MidwayFrameworkType = exports.MidwayDecoratorService = exports.MidwayMiddlewareService = exports.MidwayLifeCycleService = exports.MidwayAspectService = exports.MidwayFrameworkService = exports.MidwayLoggerService = exports.MidwayInformationService = exports.MidwayEnvironmentService = exports.MidwayConfigService = exports.createConfiguration = exports.transformRequestObjectByType = exports.deprecatedOutput = exports.delegateTargetProperties = exports.delegateTargetMethod = exports.delegateTargetPrototypeMethod = exports.safeRequire = exports.safelyGet = exports.BaseFramework = exports.MidwayRequestContainer = void 0;
|
|
14
14
|
__exportStar(require("./interface"), exports);
|
|
15
15
|
__exportStar(require("./context/container"), exports);
|
|
16
16
|
var requestContainer_1 = require("./context/requestContainer");
|
|
@@ -31,9 +31,6 @@ __exportStar(require("./util/pathFileUtil"), exports);
|
|
|
31
31
|
__exportStar(require("./util/webRouterParam"), exports);
|
|
32
32
|
__exportStar(require("./common/webRouterCollector"), exports);
|
|
33
33
|
__exportStar(require("./common/triggerCollector"), exports);
|
|
34
|
-
var class_transformer_1 = require("class-transformer");
|
|
35
|
-
Object.defineProperty(exports, "plainToClass", { enumerable: true, get: function () { return class_transformer_1.plainToClass; } });
|
|
36
|
-
Object.defineProperty(exports, "classToPlain", { enumerable: true, get: function () { return class_transformer_1.classToPlain; } });
|
|
37
34
|
var configuration_1 = require("./functional/configuration");
|
|
38
35
|
Object.defineProperty(exports, "createConfiguration", { enumerable: true, get: function () { return configuration_1.createConfiguration; } });
|
|
39
36
|
var configService_1 = require("./service/configService");
|
|
@@ -24,7 +24,27 @@ let MidwayDecoratorService = class MidwayDecoratorService {
|
|
|
24
24
|
}
|
|
25
25
|
async init() {
|
|
26
26
|
// add custom method decorator listener
|
|
27
|
-
this.applicationContext.onBeforeBind(
|
|
27
|
+
this.applicationContext.onBeforeBind(Clzz => {
|
|
28
|
+
// find custom method decorator metadata, include method decorator information array
|
|
29
|
+
const methodDecoratorMetadataList = (0, decorator_1.getClassMetadata)(decorator_1.INJECT_CUSTOM_METHOD, Clzz);
|
|
30
|
+
if (methodDecoratorMetadataList) {
|
|
31
|
+
// loop it, save this order for decorator run
|
|
32
|
+
for (const meta of methodDecoratorMetadataList) {
|
|
33
|
+
const { propertyName, key, metadata } = meta;
|
|
34
|
+
// add aspect implementation first
|
|
35
|
+
this.aspectService.interceptPrototypeMethod(Clzz, propertyName, () => {
|
|
36
|
+
const methodDecoratorHandler = this.methodDecoratorMap.get(key);
|
|
37
|
+
if (!methodDecoratorHandler) {
|
|
38
|
+
throw new error_1.MidwayCommonError(`Method Decorator "${key}" handler not found, please register first.`);
|
|
39
|
+
}
|
|
40
|
+
return this.methodDecoratorMap.get(key)({
|
|
41
|
+
target: Clzz,
|
|
42
|
+
propertyName,
|
|
43
|
+
metadata,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
28
48
|
// find custom param decorator metadata
|
|
29
49
|
const parameterDecoratorMetadata = (0, decorator_1.getClassMetadata)(decorator_1.INJECT_CUSTOM_PARAM, Clzz);
|
|
30
50
|
if (parameterDecoratorMetadata) {
|
|
@@ -58,26 +78,6 @@ let MidwayDecoratorService = class MidwayDecoratorService {
|
|
|
58
78
|
});
|
|
59
79
|
}
|
|
60
80
|
}
|
|
61
|
-
// find custom method decorator metadata, include method decorator information array
|
|
62
|
-
const methodDecoratorMetadataList = (0, decorator_1.getClassMetadata)(decorator_1.INJECT_CUSTOM_METHOD, Clzz);
|
|
63
|
-
if (methodDecoratorMetadataList) {
|
|
64
|
-
// loop it, save this order for decorator run
|
|
65
|
-
for (const meta of methodDecoratorMetadataList) {
|
|
66
|
-
const { propertyName, key, metadata } = meta;
|
|
67
|
-
// add aspect implementation first
|
|
68
|
-
this.aspectService.interceptPrototypeMethod(Clzz, propertyName, () => {
|
|
69
|
-
const methodDecoratorHandler = this.methodDecoratorMap.get(key);
|
|
70
|
-
if (!methodDecoratorHandler) {
|
|
71
|
-
throw new error_1.MidwayCommonError(`Method Decorator "${key}" handler not found, please register first.`);
|
|
72
|
-
}
|
|
73
|
-
return this.methodDecoratorMap.get(key)({
|
|
74
|
-
target: Clzz,
|
|
75
|
-
propertyName,
|
|
76
|
-
metadata,
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
81
|
});
|
|
82
82
|
// add custom property decorator listener
|
|
83
83
|
this.applicationContext.onObjectCreated((instance, options) => {
|
package/dist/util/index.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.toPathMatch = exports.transformRequestObjectByType = exports.deprecatedO
|
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const util_1 = require("util");
|
|
7
|
-
const
|
|
7
|
+
const transformer = require("class-transformer");
|
|
8
8
|
const pathToRegexp_1 = require("./pathToRegexp");
|
|
9
9
|
const error_1 = require("../error");
|
|
10
10
|
const debug = (0, util_1.debuglog)('midway:container:util');
|
|
@@ -205,7 +205,8 @@ const transformRequestObjectByType = (originValue, targetType) => {
|
|
|
205
205
|
return originValue;
|
|
206
206
|
}
|
|
207
207
|
else {
|
|
208
|
-
|
|
208
|
+
const transformToInstance = transformer['plainToClass'] || transformer['plainToInstance'];
|
|
209
|
+
return transformToInstance(targetType, originValue);
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.6",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@midwayjs/decorator": "^3.0.0-beta.
|
|
24
|
+
"@midwayjs/decorator": "^3.0.0-beta.6",
|
|
25
25
|
"midway-test-component": "*",
|
|
26
26
|
"mm": "3",
|
|
27
27
|
"sinon": "^7.2.2"
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@midwayjs/glob": "^1.0.2",
|
|
34
|
-
"@midwayjs/logger": "^3.0.0-beta.
|
|
35
|
-
"class-transformer": "^0.
|
|
34
|
+
"@midwayjs/logger": "^3.0.0-beta.6",
|
|
35
|
+
"class-transformer": "^0.5.1",
|
|
36
36
|
"extend2": "^1.0.0",
|
|
37
37
|
"picomatch": "^2.2.2",
|
|
38
38
|
"reflect-metadata": "^0.1.13"
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=12"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "e4595d30b369e36bef21b36f2b3737d8bc2f802d"
|
|
49
49
|
}
|