@midwayjs/decorator 3.1.6 → 3.4.0-beta.10
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/decorator/common/filter.d.ts +3 -1
- package/dist/decorator/common/filter.js +2 -1
- package/dist/decorator/framework/index.d.ts +1 -1
- package/dist/decorator/framework/index.js +2 -2
- package/dist/decorator/index.d.ts +1 -0
- package/dist/decorator/index.js +1 -0
- package/dist/decorator/microservice/consumer.d.ts +1 -0
- package/dist/decorator/microservice/kafkaListener.d.ts +6 -0
- package/dist/decorator/microservice/kafkaListener.js +13 -0
- package/dist/decorator/ws/webSocketController.d.ts +2 -3
- package/dist/decorator/ws/webSocketController.js +4 -1
- package/dist/decorator/ws/webSocketEvent.d.ts +13 -2
- package/dist/decorator/ws/webSocketEvent.js +4 -2
- package/dist/interface.d.ts +8 -1
- package/dist/interface.js +2 -0
- package/package.json +2 -2
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export declare function Catch(catchTarget?: any | any[]
|
|
1
|
+
export declare function Catch(catchTarget?: any | any[], options?: {
|
|
2
|
+
matchPrototype?: boolean;
|
|
3
|
+
}): (target: any) => void;
|
|
2
4
|
export declare type MatchPattern<CtxOrReq = any, Res = any> = ((ctxOrReq: CtxOrReq, res: Res) => boolean) | string | string[] | boolean;
|
|
3
5
|
export declare function Match(matchPattern?: MatchPattern): (target: any) => void;
|
|
4
6
|
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -6,11 +6,12 @@ const constant_1 = require("../../constant");
|
|
|
6
6
|
const objectDef_1 = require("./objectDef");
|
|
7
7
|
const interface_1 = require("../../interface");
|
|
8
8
|
const provide_1 = require("./provide");
|
|
9
|
-
function Catch(catchTarget) {
|
|
9
|
+
function Catch(catchTarget, options = {}) {
|
|
10
10
|
return function (target) {
|
|
11
11
|
const catchTargets = catchTarget ? [].concat(catchTarget) : undefined;
|
|
12
12
|
(0, decoratorManager_1.saveClassMetadata)(constant_1.CATCH_KEY, {
|
|
13
13
|
catchTargets,
|
|
14
|
+
catchOptions: options,
|
|
14
15
|
}, target);
|
|
15
16
|
(0, objectDef_1.Scope)(interface_1.ScopeEnum.Singleton)(target);
|
|
16
17
|
(0, provide_1.Provide)()(target);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FrameworkType } from '../../';
|
|
2
2
|
export declare function Plugin(identifier?: string): PropertyDecorator;
|
|
3
3
|
export declare function Config(identifier?: string): PropertyDecorator;
|
|
4
|
-
export declare function App(
|
|
4
|
+
export declare function App(typeOrNamespace?: FrameworkType | string): PropertyDecorator;
|
|
5
5
|
export declare function Logger(identifier?: string): PropertyDecorator;
|
|
6
6
|
export declare function ApplicationContext(): PropertyDecorator;
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -14,9 +14,9 @@ function Config(identifier) {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
exports.Config = Config;
|
|
17
|
-
function App(
|
|
17
|
+
function App(typeOrNamespace) {
|
|
18
18
|
return (0, __1.createCustomPropertyDecorator)(__1.APPLICATION_KEY, {
|
|
19
|
-
type,
|
|
19
|
+
type: typeOrNamespace,
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
exports.App = App;
|
|
@@ -5,6 +5,7 @@ export * from './framework/schedule';
|
|
|
5
5
|
export * from './microservice/consumer';
|
|
6
6
|
export * from './microservice/provider';
|
|
7
7
|
export * from './microservice/rabbitmqListener';
|
|
8
|
+
export * from './microservice/kafkaListener';
|
|
8
9
|
export * from './rpc/hsf';
|
|
9
10
|
export * from './task/queue';
|
|
10
11
|
export * from './task/task';
|
package/dist/decorator/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __exportStar(require("./framework/schedule"), exports);
|
|
|
25
25
|
__exportStar(require("./microservice/consumer"), exports);
|
|
26
26
|
__exportStar(require("./microservice/provider"), exports);
|
|
27
27
|
__exportStar(require("./microservice/rabbitmqListener"), exports);
|
|
28
|
+
__exportStar(require("./microservice/kafkaListener"), exports);
|
|
28
29
|
// rpc
|
|
29
30
|
__exportStar(require("./rpc/hsf"), exports);
|
|
30
31
|
// task
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MSListenerType } from '../../';
|
|
2
2
|
export declare function Consumer(type: MSListenerType.MQTT): ClassDecorator;
|
|
3
3
|
export declare function Consumer(type: MSListenerType.RABBITMQ, options?: any): ClassDecorator;
|
|
4
|
+
export declare function Consumer(type: MSListenerType.KAFKA, options?: any): ClassDecorator;
|
|
4
5
|
//# sourceMappingURL=consumer.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KafkaListener = void 0;
|
|
4
|
+
const __1 = require("../..");
|
|
5
|
+
function KafkaListener(topic, options = {}) {
|
|
6
|
+
return (target, propertyKey) => {
|
|
7
|
+
options.topic = topic;
|
|
8
|
+
options.propertyKey = propertyKey;
|
|
9
|
+
(0, __1.attachPropertyDataToClass)(__1.MS_CONSUMER_KEY, options, target, propertyKey);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
exports.KafkaListener = KafkaListener;
|
|
13
|
+
//# sourceMappingURL=kafkaListener.js.map
|
|
@@ -2,10 +2,9 @@ import { MiddlewareParamArray } from '../../interface';
|
|
|
2
2
|
export interface WSControllerOption {
|
|
3
3
|
namespace: string;
|
|
4
4
|
routerOptions: {
|
|
5
|
+
connectionMiddleware?: MiddlewareParamArray;
|
|
5
6
|
middleware?: MiddlewareParamArray;
|
|
6
7
|
};
|
|
7
8
|
}
|
|
8
|
-
export declare function WSController(namespace?: string | RegExp, routerOptions?:
|
|
9
|
-
middleware?: MiddlewareParamArray;
|
|
10
|
-
}): ClassDecorator;
|
|
9
|
+
export declare function WSController(namespace?: string | RegExp, routerOptions?: WSControllerOption['routerOptions']): ClassDecorator;
|
|
11
10
|
//# sourceMappingURL=webSocketController.d.ts.map
|
|
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.WSController = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const __1 = require("../../");
|
|
6
|
-
function WSController(namespace = '/', routerOptions = {
|
|
6
|
+
function WSController(namespace = '/', routerOptions = {
|
|
7
|
+
middleware: [],
|
|
8
|
+
connectionMiddleware: [],
|
|
9
|
+
}) {
|
|
7
10
|
return (target) => {
|
|
8
11
|
(0, __1.saveModule)(__1.WS_CONTROLLER_KEY, target);
|
|
9
12
|
(0, __1.saveClassMetadata)(__1.WS_CONTROLLER_KEY, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MiddlewareParamArray } from '../../';
|
|
1
2
|
export declare enum WSEventTypeEnum {
|
|
2
3
|
ON_CONNECTION = "ws:onConnection",
|
|
3
4
|
ON_DISCONNECTION = "ws:onDisconnection",
|
|
@@ -24,10 +25,20 @@ export interface WSEventInfo {
|
|
|
24
25
|
* the room name to emit
|
|
25
26
|
*/
|
|
26
27
|
roomName?: string[];
|
|
28
|
+
/**
|
|
29
|
+
* event options, like middleware
|
|
30
|
+
*/
|
|
31
|
+
eventOptions?: {
|
|
32
|
+
middleware?: MiddlewareParamArray;
|
|
33
|
+
};
|
|
27
34
|
}
|
|
28
|
-
export declare function OnWSConnection(
|
|
35
|
+
export declare function OnWSConnection(eventOptions?: {
|
|
36
|
+
middleware?: MiddlewareParamArray;
|
|
37
|
+
}): MethodDecorator;
|
|
29
38
|
export declare function OnWSDisConnection(): MethodDecorator;
|
|
30
|
-
export declare function OnWSMessage(eventName: string
|
|
39
|
+
export declare function OnWSMessage(eventName: string, eventOptions?: {
|
|
40
|
+
middleware?: MiddlewareParamArray;
|
|
41
|
+
}): MethodDecorator;
|
|
31
42
|
export declare function WSEmit(messageName: string, roomName?: string | string[]): MethodDecorator;
|
|
32
43
|
export declare function WSBroadCast(messageName?: string, roomName?: string | string[]): MethodDecorator;
|
|
33
44
|
/**
|
|
@@ -11,11 +11,12 @@ var WSEventTypeEnum;
|
|
|
11
11
|
WSEventTypeEnum["EMIT"] = "ws:Emit";
|
|
12
12
|
WSEventTypeEnum["BROADCAST"] = "ws:broadcast";
|
|
13
13
|
})(WSEventTypeEnum = exports.WSEventTypeEnum || (exports.WSEventTypeEnum = {}));
|
|
14
|
-
function OnWSConnection() {
|
|
14
|
+
function OnWSConnection(eventOptions = {}) {
|
|
15
15
|
return (target, propertyKey, descriptor) => {
|
|
16
16
|
(0, __1.attachClassMetadata)(__1.WS_EVENT_KEY, {
|
|
17
17
|
eventType: WSEventTypeEnum.ON_CONNECTION,
|
|
18
18
|
propertyName: propertyKey,
|
|
19
|
+
eventOptions,
|
|
19
20
|
descriptor,
|
|
20
21
|
}, target.constructor);
|
|
21
22
|
};
|
|
@@ -31,12 +32,13 @@ function OnWSDisConnection() {
|
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
exports.OnWSDisConnection = OnWSDisConnection;
|
|
34
|
-
function OnWSMessage(eventName) {
|
|
35
|
+
function OnWSMessage(eventName, eventOptions = {}) {
|
|
35
36
|
return (target, propertyKey, descriptor) => {
|
|
36
37
|
(0, __1.attachClassMetadata)(__1.WS_EVENT_KEY, {
|
|
37
38
|
eventType: WSEventTypeEnum.ON_MESSAGE,
|
|
38
39
|
messageEventName: eventName,
|
|
39
40
|
propertyName: propertyKey,
|
|
41
|
+
eventOptions,
|
|
40
42
|
descriptor,
|
|
41
43
|
}, target.constructor);
|
|
42
44
|
};
|
package/dist/interface.d.ts
CHANGED
|
@@ -115,6 +115,10 @@ export declare namespace FaaSMetadata {
|
|
|
115
115
|
* deploy or not
|
|
116
116
|
*/
|
|
117
117
|
isDeploy?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* function handler name, like 'index.handler'
|
|
120
|
+
*/
|
|
121
|
+
handlerName?: string;
|
|
118
122
|
}
|
|
119
123
|
interface TriggerCommonOptions {
|
|
120
124
|
/**
|
|
@@ -187,7 +191,8 @@ export declare namespace FaaSMetadata {
|
|
|
187
191
|
export interface TriggerMetadata {
|
|
188
192
|
type: ServerlessTriggerType;
|
|
189
193
|
functionName?: string;
|
|
190
|
-
|
|
194
|
+
handlerName?: string;
|
|
195
|
+
methodName?: string;
|
|
191
196
|
metadata: EventTriggerUnionOptions;
|
|
192
197
|
}
|
|
193
198
|
export {};
|
|
@@ -203,6 +208,7 @@ export declare class MidwayFrameworkType extends FrameworkType {
|
|
|
203
208
|
static FAAS: MidwayFrameworkType;
|
|
204
209
|
static MS_GRPC: MidwayFrameworkType;
|
|
205
210
|
static MS_RABBITMQ: MidwayFrameworkType;
|
|
211
|
+
static MS_KAFKA: MidwayFrameworkType;
|
|
206
212
|
static WS_IO: MidwayFrameworkType;
|
|
207
213
|
static WS: MidwayFrameworkType;
|
|
208
214
|
static SERVERLESS_APP: MidwayFrameworkType;
|
|
@@ -221,6 +227,7 @@ export declare enum ServerlessTriggerType {
|
|
|
221
227
|
LOG = "log",
|
|
222
228
|
TIMER = "timer",
|
|
223
229
|
MQ = "mq",
|
|
230
|
+
KAFKA = "kafka",
|
|
224
231
|
HSF = "hsf",
|
|
225
232
|
MTOP = "mtop"
|
|
226
233
|
}
|
package/dist/interface.js
CHANGED
|
@@ -43,6 +43,7 @@ MidwayFrameworkType.WEB_EXPRESS = new MidwayFrameworkType('@midwayjs/express');
|
|
|
43
43
|
MidwayFrameworkType.FAAS = new MidwayFrameworkType('@midwayjs/faas');
|
|
44
44
|
MidwayFrameworkType.MS_GRPC = new MidwayFrameworkType('@midwayjs/grpc');
|
|
45
45
|
MidwayFrameworkType.MS_RABBITMQ = new MidwayFrameworkType('@midwayjs/rabbitmq');
|
|
46
|
+
MidwayFrameworkType.MS_KAFKA = new MidwayFrameworkType('@midwayjs/kafka');
|
|
46
47
|
MidwayFrameworkType.WS_IO = new MidwayFrameworkType('@midwayjs/socketio');
|
|
47
48
|
MidwayFrameworkType.WS = new MidwayFrameworkType('@midwayjs/ws');
|
|
48
49
|
MidwayFrameworkType.SERVERLESS_APP = new MidwayFrameworkType('@midwayjs/serverless-app');
|
|
@@ -60,6 +61,7 @@ var ServerlessTriggerType;
|
|
|
60
61
|
ServerlessTriggerType["LOG"] = "log";
|
|
61
62
|
ServerlessTriggerType["TIMER"] = "timer";
|
|
62
63
|
ServerlessTriggerType["MQ"] = "mq";
|
|
64
|
+
ServerlessTriggerType["KAFKA"] = "kafka";
|
|
63
65
|
ServerlessTriggerType["HSF"] = "hsf";
|
|
64
66
|
ServerlessTriggerType["MTOP"] = "mtop";
|
|
65
67
|
})(ServerlessTriggerType = exports.ServerlessTriggerType || (exports.ServerlessTriggerType = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/decorator",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-beta.10",
|
|
4
4
|
"description": "definition decorator for midway project",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "560a5fa311605e4008c55f31c31bc4e12eeff2a5"
|
|
40
40
|
}
|