@midwayjs/core 3.0.4 → 3.0.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.
|
@@ -165,8 +165,6 @@ class ContainerConfiguration {
|
|
|
165
165
|
return this.namespaceList;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
class ObjectCreateEventTarget extends EventEmitter {
|
|
169
|
-
}
|
|
170
168
|
class MidwayContainer {
|
|
171
169
|
constructor(parent) {
|
|
172
170
|
this._resolverFactory = null;
|
|
@@ -189,7 +187,7 @@ class MidwayContainer {
|
|
|
189
187
|
}
|
|
190
188
|
get objectCreateEventTarget() {
|
|
191
189
|
if (!this._objectCreateEventTarget) {
|
|
192
|
-
this._objectCreateEventTarget = new
|
|
190
|
+
this._objectCreateEventTarget = new EventEmitter();
|
|
193
191
|
}
|
|
194
192
|
return this._objectCreateEventTarget;
|
|
195
193
|
}
|
|
@@ -294,6 +292,7 @@ class MidwayContainer {
|
|
|
294
292
|
const refManaged = new managedResolverFactory_1.ManagedReference();
|
|
295
293
|
refManaged.args = propertyMeta.args;
|
|
296
294
|
refManaged.name = propertyMeta.value;
|
|
295
|
+
refManaged.injectMode = propertyMeta['injectMode'];
|
|
297
296
|
definition.properties.set(propertyMeta['targetKey'], refManaged);
|
|
298
297
|
}
|
|
299
298
|
// inject custom properties
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 管理对象解析构建
|
|
3
3
|
*/
|
|
4
|
-
import { IManagedInstance, ObjectIdentifier } from '@midwayjs/decorator';
|
|
4
|
+
import { IManagedInstance, InjectModeEnum, ObjectIdentifier } from '@midwayjs/decorator';
|
|
5
5
|
import { IManagedResolver, IObjectDefinition, IManagedResolverFactoryCreateOptions, IMidwayContainer } from '../interface';
|
|
6
6
|
export declare class ManagedReference implements IManagedInstance {
|
|
7
7
|
type: string;
|
|
8
8
|
name: string;
|
|
9
|
+
injectMode: InjectModeEnum;
|
|
9
10
|
args?: any;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ManagedResolverFactory = exports.ManagedReference = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 管理对象解析构建
|
|
6
|
+
*/
|
|
7
|
+
const decorator_1 = require("@midwayjs/decorator");
|
|
4
8
|
const constants_1 = require("../common/constants");
|
|
5
9
|
const interface_1 = require("../interface");
|
|
6
10
|
const util = require("util");
|
|
@@ -24,13 +28,23 @@ class RefResolver {
|
|
|
24
28
|
return constants_1.KEYS.REF_ELEMENT;
|
|
25
29
|
}
|
|
26
30
|
resolve(managed, originName) {
|
|
31
|
+
var _a;
|
|
27
32
|
const mr = managed;
|
|
33
|
+
if (mr.injectMode === decorator_1.InjectModeEnum.Class &&
|
|
34
|
+
!((_a = this.factory.context.parent) !== null && _a !== void 0 ? _a : this.factory.context).hasDefinition(mr.name)) {
|
|
35
|
+
throw new error_1.MidwayMissingImportComponentError(originName);
|
|
36
|
+
}
|
|
28
37
|
return this.factory.context.get(mr.name, mr.args, {
|
|
29
38
|
originName,
|
|
30
39
|
});
|
|
31
40
|
}
|
|
32
41
|
async resolveAsync(managed, originName) {
|
|
42
|
+
var _a;
|
|
33
43
|
const mr = managed;
|
|
44
|
+
if (mr.injectMode === decorator_1.InjectModeEnum.Class &&
|
|
45
|
+
!((_a = this.factory.context.parent) !== null && _a !== void 0 ? _a : this.factory.context).hasDefinition(mr.name)) {
|
|
46
|
+
throw new error_1.MidwayMissingImportComponentError(originName);
|
|
47
|
+
}
|
|
34
48
|
return this.factory.context.getAsync(mr.name, mr.args, {
|
|
35
49
|
originName,
|
|
36
50
|
});
|
|
@@ -12,6 +12,7 @@ export declare const FrameworkErrorEnum: {
|
|
|
12
12
|
readonly DUPLICATE_ROUTER: "MIDWAY_10008";
|
|
13
13
|
readonly USE_WRONG_METHOD: "MIDWAY_10009";
|
|
14
14
|
readonly SINGLETON_INJECT_REQUEST: "MIDWAY_10010";
|
|
15
|
+
readonly MISSING_IMPORTS: "MIDWAY_10011";
|
|
15
16
|
};
|
|
16
17
|
export declare class MidwayCommonError extends MidwayError {
|
|
17
18
|
constructor(message: string);
|
|
@@ -46,4 +47,7 @@ export declare class MidwayUseWrongMethodError extends MidwayError {
|
|
|
46
47
|
export declare class MidwaySingletonInjectRequestError extends MidwayError {
|
|
47
48
|
constructor(singletonScopeName: string, requestScopeName: string);
|
|
48
49
|
}
|
|
50
|
+
export declare class MidwayMissingImportComponentError extends MidwayError {
|
|
51
|
+
constructor(originName: string);
|
|
52
|
+
}
|
|
49
53
|
//# sourceMappingURL=framework.d.ts.map
|
package/dist/error/framework.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MidwaySingletonInjectRequestError = exports.MidwayUseWrongMethodError = exports.MidwayDuplicateRouteError = exports.MidwayResolverMissingError = exports.MidwayConfigMissingError = exports.MidwayFeatureNotImplementedError = exports.MidwayFeatureNoLongerSupportedError = exports.MidwayDefinitionNotFoundError = exports.MidwayParameterError = exports.MidwayCommonError = exports.FrameworkErrorEnum = void 0;
|
|
3
|
+
exports.MidwayMissingImportComponentError = exports.MidwaySingletonInjectRequestError = exports.MidwayUseWrongMethodError = exports.MidwayDuplicateRouteError = exports.MidwayResolverMissingError = exports.MidwayConfigMissingError = exports.MidwayFeatureNotImplementedError = exports.MidwayFeatureNoLongerSupportedError = exports.MidwayDefinitionNotFoundError = exports.MidwayParameterError = exports.MidwayCommonError = exports.FrameworkErrorEnum = void 0;
|
|
4
4
|
const base_1 = require("./base");
|
|
5
5
|
exports.FrameworkErrorEnum = (0, base_1.registerErrorCode)('midway', {
|
|
6
6
|
UNKNOWN: 10000,
|
|
@@ -14,6 +14,7 @@ exports.FrameworkErrorEnum = (0, base_1.registerErrorCode)('midway', {
|
|
|
14
14
|
DUPLICATE_ROUTER: 10008,
|
|
15
15
|
USE_WRONG_METHOD: 10009,
|
|
16
16
|
SINGLETON_INJECT_REQUEST: 10010,
|
|
17
|
+
MISSING_IMPORTS: 10011,
|
|
17
18
|
});
|
|
18
19
|
class MidwayCommonError extends base_1.MidwayError {
|
|
19
20
|
constructor(message) {
|
|
@@ -92,4 +93,11 @@ class MidwaySingletonInjectRequestError extends base_1.MidwayError {
|
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
exports.MidwaySingletonInjectRequestError = MidwaySingletonInjectRequestError;
|
|
96
|
+
class MidwayMissingImportComponentError extends base_1.MidwayError {
|
|
97
|
+
constructor(originName) {
|
|
98
|
+
const text = `"${originName}" can't inject and maybe forgot add "{imports: [***]}" in @Configuration.`;
|
|
99
|
+
super(text, exports.FrameworkErrorEnum.MISSING_IMPORTS);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.MidwayMissingImportComponentError = MidwayMissingImportComponentError;
|
|
95
103
|
//# sourceMappingURL=framework.js.map
|
package/dist/setup.js
CHANGED
|
@@ -38,14 +38,14 @@ async function initializeGlobalApplicationContext(globalOptions) {
|
|
|
38
38
|
// bind inner service
|
|
39
39
|
applicationContext.bindClass(_1.MidwayEnvironmentService);
|
|
40
40
|
applicationContext.bindClass(_1.MidwayInformationService);
|
|
41
|
+
applicationContext.bindClass(_1.MidwayAspectService);
|
|
41
42
|
applicationContext.bindClass(_1.MidwayDecoratorService);
|
|
42
43
|
applicationContext.bindClass(_1.MidwayConfigService);
|
|
43
|
-
applicationContext.bindClass(_1.MidwayAspectService);
|
|
44
44
|
applicationContext.bindClass(_1.MidwayLoggerService);
|
|
45
|
+
applicationContext.bindClass(_1.MidwayApplicationManager);
|
|
45
46
|
applicationContext.bindClass(_1.MidwayFrameworkService);
|
|
46
47
|
applicationContext.bindClass(_1.MidwayMiddlewareService);
|
|
47
48
|
applicationContext.bindClass(_1.MidwayLifeCycleService);
|
|
48
|
-
applicationContext.bindClass(_1.MidwayApplicationManager);
|
|
49
49
|
// bind preload module
|
|
50
50
|
if (globalOptions.preloadModules && globalOptions.preloadModules.length) {
|
|
51
51
|
for (const preloadModule of globalOptions.preloadModules) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.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.
|
|
24
|
+
"@midwayjs/decorator": "^3.0.6",
|
|
25
25
|
"koa": "2.13.4",
|
|
26
26
|
"midway-test-component": "*",
|
|
27
27
|
"mm": "3.2.0",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=12"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "afaa5b59a2be85e915233a9268c0e05965dd5c61"
|
|
48
48
|
}
|