@midwayjs/core 3.9.0 → 3.10.0
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/baseFramework.d.ts +3 -0
- package/dist/baseFramework.js +17 -0
- package/dist/common/applicationManager.d.ts +1 -2
- package/dist/common/applicationManager.js +2 -1
- package/dist/common/webGenerator.js +2 -1
- package/dist/config/config.default.js +2 -1
- package/dist/context/container.d.ts +1 -2
- package/dist/context/container.js +3 -3
- package/dist/context/definitionRegistry.d.ts +1 -5
- package/dist/context/managedResolverFactory.d.ts +1 -2
- package/dist/context/managedResolverFactory.js +2 -3
- package/dist/context/providerWrapper.d.ts +1 -2
- package/dist/decorator/common/aspect.d.ts +0 -18
- package/dist/decorator/common/aspect.js +2 -1
- package/dist/decorator/common/filter.d.ts +1 -1
- package/dist/decorator/common/filter.js +1 -1
- package/dist/decorator/common/framework.d.ts +1 -1
- package/dist/decorator/common/framework.js +2 -1
- package/dist/decorator/common/guard.js +1 -1
- package/dist/decorator/common/inject.d.ts +1 -2
- package/dist/decorator/common/middleware.js +2 -1
- package/dist/decorator/common/mock.d.ts +2 -0
- package/dist/decorator/common/mock.js +14 -0
- package/dist/decorator/common/objectDef.d.ts +2 -1
- package/dist/decorator/common/objectDef.js +10 -1
- package/dist/decorator/common/pipe.d.ts +2 -0
- package/dist/decorator/common/pipe.js +13 -0
- package/dist/decorator/common/pipeline.d.ts +1 -1
- package/dist/decorator/common/provide.d.ts +1 -1
- package/dist/decorator/constant.d.ts +1 -0
- package/dist/decorator/constant.js +3 -2
- package/dist/decorator/decoratorManager.d.ts +6 -10
- package/dist/decorator/decoratorManager.js +20 -8
- package/dist/decorator/faas/serverlessTrigger.d.ts +3 -1
- package/dist/decorator/faas/serverlessTrigger.js +3 -2
- package/dist/decorator/index.d.ts +2 -1
- package/dist/decorator/index.js +2 -1
- package/dist/decorator/microservice/consumer.d.ts +1 -1
- package/dist/decorator/microservice/consumer.js +2 -1
- package/dist/decorator/microservice/kafkaListener.d.ts +3 -3
- package/dist/decorator/microservice/provider.d.ts +1 -1
- package/dist/decorator/microservice/provider.js +2 -1
- package/dist/decorator/rpc/hsf.d.ts +1 -0
- package/dist/decorator/rpc/hsf.js +3 -1
- package/dist/decorator/task/schedule.js +2 -1
- package/dist/decorator/web/controller.d.ts +1 -1
- package/dist/decorator/web/controller.js +2 -1
- package/dist/decorator/web/requestMapping.d.ts +1 -4
- package/dist/decorator/ws/webSocketController.d.ts +1 -1
- package/dist/decorator/ws/webSocketController.js +2 -1
- package/dist/decorator/ws/webSocketEvent.d.ts +1 -1
- package/dist/definitions/functionDefinition.d.ts +1 -2
- package/dist/definitions/functionDefinition.js +4 -4
- package/dist/definitions/objectDefinition.d.ts +1 -2
- package/dist/definitions/objectDefinition.js +4 -4
- package/dist/definitions/properties.d.ts +1 -2
- package/dist/error/base.d.ts +2 -2
- package/dist/error/framework.d.ts +1 -1
- package/dist/error/framework.js +5 -5
- package/dist/interface.d.ts +327 -24
- package/dist/interface.js +64 -1
- package/dist/service/aspectService.d.ts +1 -2
- package/dist/service/aspectService.js +2 -1
- package/dist/service/configService.js +2 -1
- package/dist/service/decoratorService.d.ts +3 -1
- package/dist/service/decoratorService.js +63 -11
- package/dist/service/environmentService.js +2 -1
- package/dist/service/frameworkService.d.ts +1 -2
- package/dist/service/frameworkService.js +6 -1
- package/dist/service/informationService.js +2 -1
- package/dist/service/lifeCycleService.d.ts +2 -0
- package/dist/service/lifeCycleService.js +14 -4
- package/dist/service/loggerService.d.ts +2 -1
- package/dist/service/loggerService.js +22 -5
- package/dist/service/middlewareService.js +2 -1
- package/dist/service/mockService.d.ts +9 -1
- package/dist/service/mockService.js +43 -1
- package/dist/service/pipelineService.d.ts +2 -3
- package/dist/service/slsFunctionService.d.ts +1 -1
- package/dist/service/slsFunctionService.js +3 -2
- package/dist/service/webRouterService.d.ts +1 -1
- package/dist/service/webRouterService.js +3 -2
- package/dist/setup.js +2 -0
- package/dist/util/httpclient.d.ts +2 -2
- package/dist/util/pathToRegexp.d.ts +5 -5
- package/dist/util/webRouterParam.d.ts +2 -4
- package/dist/util/webRouterParam.js +5 -27
- package/package.json +4 -5
- package/dist/decorator/interface.d.ts +0 -242
- package/dist/decorator/interface.js +0 -66
package/dist/decorator/index.js
CHANGED
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./interface"), exports);
|
|
18
17
|
// common
|
|
19
18
|
__exportStar(require("./common/provide"), exports);
|
|
20
19
|
__exportStar(require("./common/inject"), exports);
|
|
@@ -27,6 +26,8 @@ __exportStar(require("./common/framework"), exports);
|
|
|
27
26
|
__exportStar(require("./common/filter"), exports);
|
|
28
27
|
__exportStar(require("./common/middleware"), exports);
|
|
29
28
|
__exportStar(require("./common/guard"), exports);
|
|
29
|
+
__exportStar(require("./common/pipe"), exports);
|
|
30
|
+
__exportStar(require("./common/mock"), exports);
|
|
30
31
|
// faas
|
|
31
32
|
__exportStar(require("./faas/serverlessTrigger"), exports);
|
|
32
33
|
// web
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MSListenerType } from '
|
|
1
|
+
import { MSListenerType } from '../../interface';
|
|
2
2
|
export declare function Consumer(type: MSListenerType.MQTT): ClassDecorator;
|
|
3
3
|
export declare function Consumer(type: MSListenerType.RABBITMQ, options?: any): ClassDecorator;
|
|
4
4
|
export declare function Consumer(type: MSListenerType.KAFKA, options?: any): ClassDecorator;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Consumer = void 0;
|
|
4
4
|
const __1 = require("../");
|
|
5
|
+
const interface_1 = require("../../interface");
|
|
5
6
|
function Consumer(type, options = {}) {
|
|
6
7
|
return (target) => {
|
|
7
8
|
(0, __1.saveModule)(__1.MS_CONSUMER_KEY, target);
|
|
@@ -9,7 +10,7 @@ function Consumer(type, options = {}) {
|
|
|
9
10
|
type,
|
|
10
11
|
metadata: options,
|
|
11
12
|
}, target);
|
|
12
|
-
(0, __1.Scope)(
|
|
13
|
+
(0, __1.Scope)(interface_1.ScopeEnum.Request)(target);
|
|
13
14
|
(0, __1.Provide)()(target);
|
|
14
15
|
};
|
|
15
16
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated Replaced by ConsumerSubscribeTopics
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type ConsumerSubscribeTopic = {
|
|
5
5
|
fromBeginning?: boolean;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type ConsumerSubscribeTopics = {
|
|
8
8
|
fromBeginning?: boolean;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type ConsumerRunConfig = {
|
|
11
11
|
autoCommit?: boolean;
|
|
12
12
|
autoCommitInterval?: number | null;
|
|
13
13
|
autoCommitThreshold?: number | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GRPCMetadata, MSProviderType } from '../../interface';
|
|
2
2
|
export declare function Provider(type: MSProviderType.GRPC, metadata?: GRPCMetadata.ProviderOptions): ClassDecorator;
|
|
3
3
|
export declare function Provider(type: MSProviderType.DUBBO, metadata?: any): ClassDecorator;
|
|
4
4
|
export declare enum GrpcStreamTypeEnum {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DubboMethod = exports.GrpcMethod = exports.GrpcStreamTypeEnum = exports.Provider = void 0;
|
|
4
4
|
const __1 = require("../");
|
|
5
|
+
const interface_1 = require("../../interface");
|
|
5
6
|
function Provider(type, metadata = {}) {
|
|
6
7
|
return (target) => {
|
|
7
8
|
(0, __1.saveModule)(__1.MS_PROVIDER_KEY, target);
|
|
@@ -9,7 +10,7 @@ function Provider(type, metadata = {}) {
|
|
|
9
10
|
type,
|
|
10
11
|
metadata,
|
|
11
12
|
}, target);
|
|
12
|
-
(0, __1.Scope)(
|
|
13
|
+
(0, __1.Scope)(interface_1.ScopeEnum.Request)(target);
|
|
13
14
|
(0, __1.Provide)()(target);
|
|
14
15
|
};
|
|
15
16
|
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HSF = void 0;
|
|
4
4
|
const __1 = require("../");
|
|
5
|
+
const interface_1 = require("../../interface");
|
|
5
6
|
/**
|
|
7
|
+
* @Deprecated
|
|
6
8
|
* @param hsfOption
|
|
7
9
|
* @constructor
|
|
8
10
|
*/
|
|
@@ -10,7 +12,7 @@ function HSF(hsfOption = {}) {
|
|
|
10
12
|
return (target) => {
|
|
11
13
|
(0, __1.saveModule)(__1.HSF_KEY, target);
|
|
12
14
|
(0, __1.saveClassMetadata)(__1.HSF_KEY, hsfOption, target);
|
|
13
|
-
(0, __1.Scope)(
|
|
15
|
+
(0, __1.Scope)(interface_1.ScopeEnum.Request)(target);
|
|
14
16
|
(0, __1.Provide)()(target);
|
|
15
17
|
};
|
|
16
18
|
}
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Schedule = void 0;
|
|
4
4
|
const __1 = require("../");
|
|
5
|
+
const interface_1 = require("../../interface");
|
|
5
6
|
function Schedule(scheduleOpts) {
|
|
6
7
|
return function (target) {
|
|
7
8
|
(0, __1.saveModule)(__1.SCHEDULE_KEY, target);
|
|
8
9
|
(0, __1.saveClassMetadata)(__1.SCHEDULE_KEY, scheduleOpts, target);
|
|
9
|
-
(0, __1.Scope)(
|
|
10
|
+
(0, __1.Scope)(interface_1.ScopeEnum.Request)(target);
|
|
10
11
|
(0, __1.Provide)()(target);
|
|
11
12
|
};
|
|
12
13
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Controller = void 0;
|
|
4
4
|
const __1 = require("../");
|
|
5
|
+
const interface_1 = require("../../interface");
|
|
5
6
|
function Controller(prefix = '/', routerOptions = { middleware: [], sensitive: true }) {
|
|
6
7
|
return (target) => {
|
|
7
8
|
(0, __1.saveModule)(__1.CONTROLLER_KEY, target);
|
|
@@ -10,7 +11,7 @@ function Controller(prefix = '/', routerOptions = { middleware: [], sensitive: t
|
|
|
10
11
|
prefix,
|
|
11
12
|
routerOptions,
|
|
12
13
|
}, target);
|
|
13
|
-
(0, __1.Scope)(
|
|
14
|
+
(0, __1.Scope)(interface_1.ScopeEnum.Request)(target);
|
|
14
15
|
(0, __1.Provide)()(target);
|
|
15
16
|
};
|
|
16
17
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WSController = void 0;
|
|
4
4
|
const __1 = require("../");
|
|
5
|
+
const interface_1 = require("../../interface");
|
|
5
6
|
function WSController(namespace = '/', routerOptions = {
|
|
6
7
|
middleware: [],
|
|
7
8
|
connectionMiddleware: [],
|
|
@@ -12,7 +13,7 @@ function WSController(namespace = '/', routerOptions = {
|
|
|
12
13
|
namespace,
|
|
13
14
|
routerOptions,
|
|
14
15
|
}, target);
|
|
15
|
-
(0, __1.Scope)(
|
|
16
|
+
(0, __1.Scope)(interface_1.ScopeEnum.Request)(target);
|
|
16
17
|
(0, __1.Provide)()(target);
|
|
17
18
|
};
|
|
18
19
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IProperties, IObjectCreator, IObjectDefinition } from '../interface';
|
|
2
|
-
import { IManagedInstance, ObjectIdentifier, ScopeEnum } from '../decorator';
|
|
1
|
+
import { IProperties, IObjectCreator, IObjectDefinition, IManagedInstance, ObjectIdentifier, ScopeEnum } from '../interface';
|
|
3
2
|
export declare class FunctionDefinition implements IObjectDefinition {
|
|
4
3
|
constructor();
|
|
5
4
|
constructMethod: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FunctionDefinition = void 0;
|
|
4
|
-
const
|
|
4
|
+
const interface_1 = require("../interface");
|
|
5
5
|
const objectCreator_1 = require("./objectCreator");
|
|
6
6
|
class FunctionWrapperCreator extends objectCreator_1.ObjectCreator {
|
|
7
7
|
doConstruct(Clzz, args, context) {
|
|
@@ -26,7 +26,7 @@ class FunctionDefinition {
|
|
|
26
26
|
this.allowDowngrade = false;
|
|
27
27
|
// 函数工厂创建的对象默认不需要自动装配
|
|
28
28
|
this.innerAutowire = false;
|
|
29
|
-
this.innerScope =
|
|
29
|
+
this.innerScope = interface_1.ScopeEnum.Singleton;
|
|
30
30
|
this.creator = new FunctionWrapperCreator(this);
|
|
31
31
|
}
|
|
32
32
|
getAttr(key) { }
|
|
@@ -52,10 +52,10 @@ class FunctionDefinition {
|
|
|
52
52
|
this.innerScope = scope;
|
|
53
53
|
}
|
|
54
54
|
isSingletonScope() {
|
|
55
|
-
return this.innerScope ===
|
|
55
|
+
return this.innerScope === interface_1.ScopeEnum.Singleton;
|
|
56
56
|
}
|
|
57
57
|
isRequestScope() {
|
|
58
|
-
return this.innerScope ===
|
|
58
|
+
return this.innerScope === interface_1.ScopeEnum.Request;
|
|
59
59
|
}
|
|
60
60
|
setAttr(key, value) { }
|
|
61
61
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IObjectCreator, IObjectDefinition } from '../interface';
|
|
1
|
+
import { IObjectCreator, IObjectDefinition, ObjectIdentifier, ScopeEnum } from '../interface';
|
|
2
2
|
import { ObjectProperties } from './properties';
|
|
3
|
-
import { ObjectIdentifier, ScopeEnum } from '../decorator';
|
|
4
3
|
export declare class ObjectDefinition implements IObjectDefinition {
|
|
5
4
|
protected _attrs: Map<ObjectIdentifier, any>;
|
|
6
5
|
protected _asynchronous: boolean;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ObjectDefinition = void 0;
|
|
4
|
+
const interface_1 = require("../interface");
|
|
4
5
|
const properties_1 = require("./properties");
|
|
5
6
|
const objectCreator_1 = require("./objectCreator");
|
|
6
|
-
const decorator_1 = require("../decorator");
|
|
7
7
|
/* tslint:disable:variable-name */
|
|
8
8
|
class ObjectDefinition {
|
|
9
9
|
constructor() {
|
|
10
10
|
this._attrs = new Map();
|
|
11
11
|
this._asynchronous = false;
|
|
12
|
-
this.scope =
|
|
12
|
+
this.scope = interface_1.ScopeEnum.Singleton;
|
|
13
13
|
this.creator = null;
|
|
14
14
|
this.id = null;
|
|
15
15
|
this.name = null;
|
|
@@ -33,10 +33,10 @@ class ObjectDefinition {
|
|
|
33
33
|
return this._asynchronous;
|
|
34
34
|
}
|
|
35
35
|
isSingletonScope() {
|
|
36
|
-
return this.scope ===
|
|
36
|
+
return this.scope === interface_1.ScopeEnum.Singleton;
|
|
37
37
|
}
|
|
38
38
|
isRequestScope() {
|
|
39
|
-
return this.scope ===
|
|
39
|
+
return this.scope === interface_1.ScopeEnum.Request;
|
|
40
40
|
}
|
|
41
41
|
hasDependsOn() {
|
|
42
42
|
return this.dependsOn.length > 0;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IProperties } from '../interface';
|
|
2
|
-
import { ObjectIdentifier } from '../decorator';
|
|
1
|
+
import { IProperties, ObjectIdentifier } from '../interface';
|
|
3
2
|
export declare class ObjectProperties extends Map<ObjectIdentifier, any> implements IProperties {
|
|
4
3
|
propertyKeys(): ObjectIdentifier[];
|
|
5
4
|
getProperty(key: ObjectIdentifier, defaultValue?: any): any;
|
package/dist/error/base.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ interface ErrorOption {
|
|
|
5
5
|
interface Convertable {
|
|
6
6
|
[key: string]: string | number;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
type ConvertString<T extends Convertable, Group extends string> = {
|
|
9
9
|
[P in keyof T]: P extends string ? T[P] extends number ? `${Uppercase<Group>}_${T[P]}` : never : never;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
@@ -20,7 +20,7 @@ export declare class MidwayError extends Error {
|
|
|
20
20
|
constructor(message: string, options?: ErrorOption);
|
|
21
21
|
constructor(message: string, code: string, options?: ErrorOption);
|
|
22
22
|
}
|
|
23
|
-
export
|
|
23
|
+
export type ResOrMessage = string | {
|
|
24
24
|
message: string;
|
|
25
25
|
} | undefined;
|
|
26
26
|
export declare class MidwayHttpError extends MidwayError {
|
package/dist/error/framework.js
CHANGED
|
@@ -36,17 +36,17 @@ class MidwayParameterError extends base_1.MidwayError {
|
|
|
36
36
|
}
|
|
37
37
|
exports.MidwayParameterError = MidwayParameterError;
|
|
38
38
|
class MidwayDefinitionNotFoundError extends base_1.MidwayError {
|
|
39
|
-
constructor(identifier) {
|
|
40
|
-
super(`${identifier} is not valid in current context`, exports.FrameworkErrorEnum.DEFINITION_NOT_FOUND);
|
|
41
|
-
this[MidwayDefinitionNotFoundError.type] =
|
|
42
|
-
MidwayDefinitionNotFoundError.type;
|
|
43
|
-
}
|
|
44
39
|
static isClosePrototypeOf(ins) {
|
|
45
40
|
return ins
|
|
46
41
|
? ins[MidwayDefinitionNotFoundError.type] ===
|
|
47
42
|
MidwayDefinitionNotFoundError.type
|
|
48
43
|
: false;
|
|
49
44
|
}
|
|
45
|
+
constructor(identifier) {
|
|
46
|
+
super(`${identifier} is not valid in current context`, exports.FrameworkErrorEnum.DEFINITION_NOT_FOUND);
|
|
47
|
+
this[MidwayDefinitionNotFoundError.type] =
|
|
48
|
+
MidwayDefinitionNotFoundError.type;
|
|
49
|
+
}
|
|
50
50
|
updateErrorMsg(className) {
|
|
51
51
|
const identifier = this.message.split(' is not valid in current context')[0];
|
|
52
52
|
this.message = `${identifier} in class ${className} is not valid in current context`;
|