@midwayjs/core 3.5.4-beta.2 → 3.6.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.
Files changed (145) hide show
  1. package/LICENSE +21 -0
  2. package/dist/baseFramework.d.ts +7 -2
  3. package/dist/baseFramework.js +27 -9
  4. package/dist/common/applicationManager.d.ts +1 -1
  5. package/dist/common/applicationManager.js +1 -1
  6. package/dist/common/dataListener.js +1 -1
  7. package/dist/common/dataSourceManager.js +7 -7
  8. package/dist/common/fileDetector.js +6 -5
  9. package/dist/common/filterManager.js +1 -1
  10. package/dist/common/guardManager.d.ts +6 -0
  11. package/dist/common/guardManager.js +49 -0
  12. package/dist/common/middlewareManager.d.ts +2 -2
  13. package/dist/common/webGenerator.d.ts +2 -1
  14. package/dist/common/webGenerator.js +12 -3
  15. package/dist/config/config.default.d.ts +2 -11
  16. package/dist/config/config.default.js +2 -2
  17. package/dist/{common/constants.d.ts → constants.d.ts} +10 -1
  18. package/dist/{common/constants.js → constants.js} +18 -2
  19. package/dist/context/container.d.ts +1 -1
  20. package/dist/context/container.js +16 -14
  21. package/dist/context/definitionRegistry.d.ts +1 -1
  22. package/dist/context/definitionRegistry.js +1 -1
  23. package/dist/context/managedResolverFactory.d.ts +1 -4
  24. package/dist/context/managedResolverFactory.js +6 -6
  25. package/dist/context/providerWrapper.d.ts +1 -1
  26. package/dist/context/providerWrapper.js +1 -1
  27. package/dist/context/requestContainer.js +3 -3
  28. package/dist/decorator/common/aspect.d.ts +20 -0
  29. package/dist/decorator/common/aspect.js +22 -0
  30. package/dist/decorator/common/autoload.d.ts +2 -0
  31. package/dist/decorator/common/autoload.js +13 -0
  32. package/dist/decorator/common/configuration.d.ts +24 -0
  33. package/dist/decorator/common/configuration.js +11 -0
  34. package/dist/decorator/common/filter.d.ts +6 -0
  35. package/dist/decorator/common/filter.js +31 -0
  36. package/dist/decorator/common/framework.d.ts +8 -0
  37. package/dist/decorator/common/framework.js +41 -0
  38. package/dist/decorator/common/guard.d.ts +4 -0
  39. package/dist/decorator/common/guard.js +30 -0
  40. package/dist/decorator/common/inject.d.ts +3 -0
  41. package/dist/decorator/common/inject.js +11 -0
  42. package/dist/decorator/common/middleware.d.ts +2 -0
  43. package/dist/decorator/common/middleware.js +12 -0
  44. package/dist/decorator/common/objectDef.d.ts +7 -0
  45. package/dist/decorator/common/objectDef.js +25 -0
  46. package/dist/decorator/common/pipeline.d.ts +3 -0
  47. package/dist/decorator/common/pipeline.js +12 -0
  48. package/dist/decorator/common/provide.d.ts +3 -0
  49. package/dist/decorator/common/provide.js +11 -0
  50. package/dist/decorator/constant.d.ts +55 -0
  51. package/dist/decorator/constant.js +86 -0
  52. package/dist/decorator/decoratorManager.d.ts +301 -0
  53. package/dist/decorator/decoratorManager.js +709 -0
  54. package/dist/decorator/faas/serverlessTrigger.d.ts +13 -0
  55. package/dist/decorator/faas/serverlessTrigger.js +29 -0
  56. package/dist/decorator/index.d.ts +31 -0
  57. package/dist/decorator/index.js +55 -0
  58. package/dist/decorator/interface.d.ts +238 -0
  59. package/dist/decorator/interface.js +67 -0
  60. package/dist/decorator/microservice/consumer.d.ts +5 -0
  61. package/dist/decorator/microservice/consumer.js +17 -0
  62. package/dist/decorator/microservice/kafkaListener.d.ts +24 -0
  63. package/dist/decorator/microservice/kafkaListener.js +13 -0
  64. package/dist/decorator/microservice/provider.d.ts +16 -0
  65. package/dist/decorator/microservice/provider.js +47 -0
  66. package/dist/decorator/microservice/rabbitmqListener.d.ts +50 -0
  67. package/dist/decorator/microservice/rabbitmqListener.js +13 -0
  68. package/dist/decorator/rpc/hsf.d.ts +12 -0
  69. package/dist/decorator/rpc/hsf.js +18 -0
  70. package/dist/decorator/task/queue.d.ts +2 -0
  71. package/dist/decorator/task/queue.js +17 -0
  72. package/dist/decorator/task/schedule.d.ts +21 -0
  73. package/dist/decorator/task/schedule.js +14 -0
  74. package/dist/decorator/task/task.d.ts +2 -0
  75. package/dist/decorator/task/task.js +18 -0
  76. package/dist/decorator/task/taskLocal.d.ts +2 -0
  77. package/dist/decorator/task/taskLocal.js +17 -0
  78. package/dist/decorator/web/controller.d.ts +20 -0
  79. package/dist/decorator/web/controller.js +18 -0
  80. package/dist/decorator/web/paramMapping.d.ts +31 -0
  81. package/dist/decorator/web/paramMapping.js +50 -0
  82. package/dist/decorator/web/requestMapping.d.ts +132 -0
  83. package/dist/decorator/web/requestMapping.js +83 -0
  84. package/dist/decorator/web/response.d.ts +9 -0
  85. package/dist/decorator/web/response.js +65 -0
  86. package/dist/decorator/ws/webSocketController.d.ts +10 -0
  87. package/dist/decorator/ws/webSocketController.js +20 -0
  88. package/dist/decorator/ws/webSocketEvent.d.ts +60 -0
  89. package/dist/decorator/ws/webSocketEvent.js +87 -0
  90. package/dist/definitions/functionDefinition.d.ts +1 -1
  91. package/dist/definitions/functionDefinition.js +1 -1
  92. package/dist/definitions/objectCreator.d.ts +1 -1
  93. package/dist/definitions/objectCreator.js +7 -7
  94. package/dist/definitions/objectDefinition.d.ts +1 -1
  95. package/dist/definitions/objectDefinition.js +1 -1
  96. package/dist/definitions/properties.d.ts +1 -1
  97. package/dist/error/framework.d.ts +5 -1
  98. package/dist/error/framework.js +9 -2
  99. package/dist/functional/configuration.d.ts +1 -1
  100. package/dist/index.d.ts +18 -15
  101. package/dist/index.js +40 -27
  102. package/dist/interface.d.ts +52 -18
  103. package/dist/interface.js +1 -17
  104. package/dist/service/aspectService.d.ts +1 -1
  105. package/dist/service/aspectService.js +3 -2
  106. package/dist/service/configService.js +3 -2
  107. package/dist/service/decoratorService.js +1 -1
  108. package/dist/service/environmentService.js +1 -1
  109. package/dist/service/frameworkService.d.ts +1 -1
  110. package/dist/service/frameworkService.js +3 -3
  111. package/dist/service/informationService.js +1 -1
  112. package/dist/service/lifeCycleService.js +1 -1
  113. package/dist/service/loggerService.js +1 -1
  114. package/dist/service/middlewareService.js +3 -2
  115. package/dist/service/mockService.js +1 -1
  116. package/dist/service/pipelineService.d.ts +1 -1
  117. package/dist/service/pipelineService.js +1 -1
  118. package/dist/service/slsFunctionService.d.ts +1 -1
  119. package/dist/service/slsFunctionService.js +1 -1
  120. package/dist/service/webRouterService.d.ts +9 -1
  121. package/dist/service/webRouterService.js +6 -3
  122. package/dist/setup.d.ts +3 -3
  123. package/dist/setup.js +1 -1
  124. package/dist/util/camelCase.d.ts +3 -0
  125. package/dist/util/camelCase.js +88 -0
  126. package/dist/util/contextUtil.js +2 -2
  127. package/dist/util/extend.js +3 -3
  128. package/dist/util/flatted.d.ts +7 -0
  129. package/dist/util/flatted.js +91 -0
  130. package/dist/util/format.d.ts +25 -0
  131. package/dist/util/format.js +38 -0
  132. package/dist/util/fs.d.ts +5 -0
  133. package/dist/util/fs.js +15 -0
  134. package/dist/util/httpclient.d.ts +1 -0
  135. package/dist/util/index.d.ts +26 -0
  136. package/dist/util/index.js +80 -1
  137. package/dist/util/pathFileUtil.d.ts +6 -3
  138. package/dist/util/pathFileUtil.js +28 -22
  139. package/dist/util/retry.js +2 -2
  140. package/dist/util/types.d.ts +35 -0
  141. package/dist/util/types.js +121 -0
  142. package/dist/util/uuid.d.ts +5 -0
  143. package/dist/util/uuid.js +64 -0
  144. package/dist/util/webRouterParam.js +1 -1
  145. package/package.json +8 -11
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Queue = void 0;
4
+ const __1 = require("../");
5
+ const constant_1 = require("../constant");
6
+ function Queue(options) {
7
+ return function (target) {
8
+ (0, __1.saveModule)(constant_1.MODULE_TASK_QUEUE_KEY, target);
9
+ (0, __1.saveClassMetadata)(constant_1.MODULE_TASK_QUEUE_OPTIONS, {
10
+ options,
11
+ name: target.name,
12
+ }, target);
13
+ (0, __1.Provide)()(target);
14
+ };
15
+ }
16
+ exports.Queue = Queue;
17
+ //# sourceMappingURL=queue.js.map
@@ -0,0 +1,21 @@
1
+ export interface CommonSchedule {
2
+ exec(ctx?: any): any;
3
+ }
4
+ export interface ScheduleOpts {
5
+ type: string;
6
+ cron?: string;
7
+ interval?: number | string;
8
+ immediate?: boolean;
9
+ disable?: boolean;
10
+ env?: string[];
11
+ cronOptions?: {
12
+ currentDate?: string | number | Date;
13
+ startDate?: string | number | Date;
14
+ endDate?: string | number | Date;
15
+ iterator?: boolean;
16
+ utc?: boolean;
17
+ tz?: string;
18
+ };
19
+ }
20
+ export declare function Schedule(scheduleOpts: ScheduleOpts | string): (target: any) => void;
21
+ //# sourceMappingURL=schedule.d.ts.map
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Schedule = void 0;
4
+ const __1 = require("../");
5
+ function Schedule(scheduleOpts) {
6
+ return function (target) {
7
+ (0, __1.saveModule)(__1.SCHEDULE_KEY, target);
8
+ (0, __1.saveClassMetadata)(__1.SCHEDULE_KEY, scheduleOpts, target);
9
+ (0, __1.Scope)(__1.ScopeEnum.Request)(target);
10
+ (0, __1.Provide)()(target);
11
+ };
12
+ }
13
+ exports.Schedule = Schedule;
14
+ //# sourceMappingURL=schedule.js.map
@@ -0,0 +1,2 @@
1
+ export declare function Task(options: any): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
2
+ //# sourceMappingURL=task.d.ts.map
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Task = void 0;
4
+ const __1 = require("../");
5
+ const constant_1 = require("../constant");
6
+ function Task(options) {
7
+ return function (target, propertyKey, descriptor) {
8
+ (0, __1.saveModule)(constant_1.MODULE_TASK_KEY, target.constructor);
9
+ (0, __1.attachClassMetadata)(constant_1.MODULE_TASK_METADATA, {
10
+ options,
11
+ propertyKey,
12
+ value: descriptor.value,
13
+ name: target.constructor.name,
14
+ }, target);
15
+ };
16
+ }
17
+ exports.Task = Task;
18
+ //# sourceMappingURL=task.js.map
@@ -0,0 +1,2 @@
1
+ export declare function TaskLocal(options: any): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
2
+ //# sourceMappingURL=taskLocal.d.ts.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaskLocal = void 0;
4
+ const __1 = require("../");
5
+ const constant_1 = require("../constant");
6
+ function TaskLocal(options) {
7
+ return function (target, propertyKey, descriptor) {
8
+ (0, __1.saveModule)(constant_1.MODULE_TASK_TASK_LOCAL_KEY, target.constructor);
9
+ (0, __1.attachClassMetadata)(constant_1.MODULE_TASK_TASK_LOCAL_OPTIONS, {
10
+ options,
11
+ propertyKey,
12
+ value: descriptor.value,
13
+ }, target);
14
+ };
15
+ }
16
+ exports.TaskLocal = TaskLocal;
17
+ //# sourceMappingURL=taskLocal.js.map
@@ -0,0 +1,20 @@
1
+ import { MiddlewareParamArray } from '../';
2
+ export interface ControllerOption {
3
+ prefix: string;
4
+ routerOptions?: {
5
+ sensitive?: boolean;
6
+ middleware?: MiddlewareParamArray;
7
+ alias?: string[];
8
+ description?: string;
9
+ tagName?: string;
10
+ ignoreGlobalPrefix?: boolean;
11
+ };
12
+ }
13
+ export declare function Controller(prefix?: string, routerOptions?: {
14
+ sensitive?: boolean;
15
+ middleware?: MiddlewareParamArray;
16
+ description?: string;
17
+ tagName?: string;
18
+ ignoreGlobalPrefix?: boolean;
19
+ }): ClassDecorator;
20
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Controller = void 0;
4
+ const __1 = require("../");
5
+ function Controller(prefix = '/', routerOptions = { middleware: [], sensitive: true }) {
6
+ return (target) => {
7
+ (0, __1.saveModule)(__1.CONTROLLER_KEY, target);
8
+ if (prefix)
9
+ (0, __1.saveClassMetadata)(__1.CONTROLLER_KEY, {
10
+ prefix,
11
+ routerOptions,
12
+ }, target);
13
+ (0, __1.Scope)(__1.ScopeEnum.Request)(target);
14
+ (0, __1.Provide)()(target);
15
+ };
16
+ }
17
+ exports.Controller = Controller;
18
+ //# sourceMappingURL=controller.js.map
@@ -0,0 +1,31 @@
1
+ export declare enum RouteParamTypes {
2
+ QUERY = 0,
3
+ BODY = 1,
4
+ PARAM = 2,
5
+ HEADERS = 3,
6
+ SESSION = 4,
7
+ FILESTREAM = 5,
8
+ FILESSTREAM = 6,
9
+ NEXT = 7,
10
+ REQUEST_PATH = 8,
11
+ REQUEST_IP = 9,
12
+ QUERIES = 10,
13
+ FIELDS = 11
14
+ }
15
+ export interface RouterParamValue {
16
+ index: number;
17
+ type: RouteParamTypes;
18
+ propertyData?: any;
19
+ }
20
+ export declare const Session: (property?: string) => ParameterDecorator;
21
+ export declare const Body: (property?: string) => ParameterDecorator;
22
+ export declare const Query: (property?: string) => ParameterDecorator;
23
+ export declare const Param: (property?: string) => ParameterDecorator;
24
+ export declare const Headers: (property?: string) => ParameterDecorator;
25
+ export declare const File: (property?: any) => ParameterDecorator;
26
+ export declare const Files: (property?: any) => ParameterDecorator;
27
+ export declare const RequestPath: () => ParameterDecorator;
28
+ export declare const RequestIP: () => ParameterDecorator;
29
+ export declare const Queries: (property?: string) => ParameterDecorator;
30
+ export declare const Fields: (property?: string) => ParameterDecorator;
31
+ //# sourceMappingURL=paramMapping.d.ts.map
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Fields = exports.Queries = exports.RequestIP = exports.RequestPath = exports.Files = exports.File = exports.Headers = exports.Param = exports.Query = exports.Body = exports.Session = exports.RouteParamTypes = void 0;
4
+ const __1 = require("../");
5
+ var RouteParamTypes;
6
+ (function (RouteParamTypes) {
7
+ RouteParamTypes[RouteParamTypes["QUERY"] = 0] = "QUERY";
8
+ RouteParamTypes[RouteParamTypes["BODY"] = 1] = "BODY";
9
+ RouteParamTypes[RouteParamTypes["PARAM"] = 2] = "PARAM";
10
+ RouteParamTypes[RouteParamTypes["HEADERS"] = 3] = "HEADERS";
11
+ RouteParamTypes[RouteParamTypes["SESSION"] = 4] = "SESSION";
12
+ RouteParamTypes[RouteParamTypes["FILESTREAM"] = 5] = "FILESTREAM";
13
+ RouteParamTypes[RouteParamTypes["FILESSTREAM"] = 6] = "FILESSTREAM";
14
+ RouteParamTypes[RouteParamTypes["NEXT"] = 7] = "NEXT";
15
+ RouteParamTypes[RouteParamTypes["REQUEST_PATH"] = 8] = "REQUEST_PATH";
16
+ RouteParamTypes[RouteParamTypes["REQUEST_IP"] = 9] = "REQUEST_IP";
17
+ RouteParamTypes[RouteParamTypes["QUERIES"] = 10] = "QUERIES";
18
+ RouteParamTypes[RouteParamTypes["FIELDS"] = 11] = "FIELDS";
19
+ })(RouteParamTypes = exports.RouteParamTypes || (exports.RouteParamTypes = {}));
20
+ const createParamMapping = function (type) {
21
+ return (propertyData) => {
22
+ return (0, __1.createCustomParamDecorator)(__1.WEB_ROUTER_PARAM_KEY, {
23
+ type,
24
+ propertyData,
25
+ });
26
+ };
27
+ };
28
+ const Session = (property) => createParamMapping(RouteParamTypes.SESSION)(property);
29
+ exports.Session = Session;
30
+ const Body = (property) => createParamMapping(RouteParamTypes.BODY)(property);
31
+ exports.Body = Body;
32
+ const Query = (property) => createParamMapping(RouteParamTypes.QUERY)(property);
33
+ exports.Query = Query;
34
+ const Param = (property) => createParamMapping(RouteParamTypes.PARAM)(property);
35
+ exports.Param = Param;
36
+ const Headers = (property) => createParamMapping(RouteParamTypes.HEADERS)(property);
37
+ exports.Headers = Headers;
38
+ const File = (property) => createParamMapping(RouteParamTypes.FILESTREAM)(property);
39
+ exports.File = File;
40
+ const Files = (property) => createParamMapping(RouteParamTypes.FILESSTREAM)(property);
41
+ exports.Files = Files;
42
+ const RequestPath = () => createParamMapping(RouteParamTypes.REQUEST_PATH)();
43
+ exports.RequestPath = RequestPath;
44
+ const RequestIP = () => createParamMapping(RouteParamTypes.REQUEST_IP)();
45
+ exports.RequestIP = RequestIP;
46
+ const Queries = (property) => createParamMapping(RouteParamTypes.QUERIES)(property);
47
+ exports.Queries = Queries;
48
+ const Fields = (property) => createParamMapping(RouteParamTypes.FIELDS)(property);
49
+ exports.Fields = Fields;
50
+ //# sourceMappingURL=paramMapping.js.map
@@ -0,0 +1,132 @@
1
+ /**
2
+ * 'HEAD', 'OPTIONS', 'GET', 'PUT', 'PATCH', 'POST', 'DELETE' 封装
3
+ */
4
+ import { MiddlewareParamArray } from '../';
5
+ export interface RouterOption {
6
+ /**
7
+ * router path, like "/api"
8
+ */
9
+ path?: string | RegExp;
10
+ /**
11
+ * http method, like "get", "post"
12
+ */
13
+ requestMethod: string;
14
+ /**
15
+ * router alias name
16
+ */
17
+ routerName?: string;
18
+ /**
19
+ * which method decorator attached
20
+ */
21
+ method?: string;
22
+ /**
23
+ * middleware array in router
24
+ */
25
+ middleware?: MiddlewareParamArray;
26
+ /**
27
+ * router summary, for swagger
28
+ * @deprecated
29
+ */
30
+ summary?: string;
31
+ /**
32
+ * router description, for swagger
33
+ * @deprecated
34
+ */
35
+ description?: string;
36
+ /**
37
+ * ignore global prefix
38
+ */
39
+ ignoreGlobalPrefix?: boolean;
40
+ }
41
+ export declare const RequestMethod: {
42
+ GET: string;
43
+ POST: string;
44
+ PUT: string;
45
+ DELETE: string;
46
+ PATCH: string;
47
+ ALL: string;
48
+ OPTIONS: string;
49
+ HEAD: string;
50
+ };
51
+ export declare const RequestMapping: (metadata?: RouterOption) => MethodDecorator;
52
+ /**
53
+ * Routes HTTP POST requests to the specified path.
54
+ */
55
+ export declare const Post: (path?: string | RegExp, routerOptions?: {
56
+ routerName?: string;
57
+ middleware?: MiddlewareParamArray;
58
+ summary?: string;
59
+ description?: string;
60
+ ignoreGlobalPrefix?: boolean;
61
+ }) => MethodDecorator;
62
+ /**
63
+ * Routes HTTP GET requests to the specified path.
64
+ */
65
+ export declare const Get: (path?: string | RegExp, routerOptions?: {
66
+ routerName?: string;
67
+ middleware?: MiddlewareParamArray;
68
+ summary?: string;
69
+ description?: string;
70
+ ignoreGlobalPrefix?: boolean;
71
+ }) => MethodDecorator;
72
+ /**
73
+ * Routes HTTP DELETE requests to the specified path.
74
+ */
75
+ export declare const Del: (path?: string | RegExp, routerOptions?: {
76
+ routerName?: string;
77
+ middleware?: MiddlewareParamArray;
78
+ summary?: string;
79
+ description?: string;
80
+ ignoreGlobalPrefix?: boolean;
81
+ }) => MethodDecorator;
82
+ /**
83
+ * Routes HTTP PUT requests to the specified path.
84
+ */
85
+ export declare const Put: (path?: string | RegExp, routerOptions?: {
86
+ routerName?: string;
87
+ middleware?: MiddlewareParamArray;
88
+ summary?: string;
89
+ description?: string;
90
+ ignoreGlobalPrefix?: boolean;
91
+ }) => MethodDecorator;
92
+ /**
93
+ * Routes HTTP PATCH requests to the specified path.
94
+ */
95
+ export declare const Patch: (path?: string | RegExp, routerOptions?: {
96
+ routerName?: string;
97
+ middleware?: MiddlewareParamArray;
98
+ summary?: string;
99
+ description?: string;
100
+ ignoreGlobalPrefix?: boolean;
101
+ }) => MethodDecorator;
102
+ /**
103
+ * Routes HTTP OPTIONS requests to the specified path.
104
+ */
105
+ export declare const Options: (path?: string | RegExp, routerOptions?: {
106
+ routerName?: string;
107
+ middleware?: MiddlewareParamArray;
108
+ summary?: string;
109
+ description?: string;
110
+ ignoreGlobalPrefix?: boolean;
111
+ }) => MethodDecorator;
112
+ /**
113
+ * Routes HTTP HEAD requests to the specified path.
114
+ */
115
+ export declare const Head: (path?: string | RegExp, routerOptions?: {
116
+ routerName?: string;
117
+ middleware?: MiddlewareParamArray;
118
+ summary?: string;
119
+ description?: string;
120
+ ignoreGlobalPrefix?: boolean;
121
+ }) => MethodDecorator;
122
+ /**
123
+ * Routes all HTTP requests to the specified path.
124
+ */
125
+ export declare const All: (path?: string | RegExp, routerOptions?: {
126
+ routerName?: string;
127
+ middleware?: MiddlewareParamArray;
128
+ summary?: string;
129
+ description?: string;
130
+ ignoreGlobalPrefix?: boolean;
131
+ }) => MethodDecorator;
132
+ //# sourceMappingURL=requestMapping.d.ts.map
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.All = exports.Head = exports.Options = exports.Patch = exports.Put = exports.Del = exports.Get = exports.Post = exports.RequestMapping = exports.RequestMethod = void 0;
4
+ /**
5
+ * 'HEAD', 'OPTIONS', 'GET', 'PUT', 'PATCH', 'POST', 'DELETE' 封装
6
+ */
7
+ const __1 = require("../");
8
+ exports.RequestMethod = {
9
+ GET: 'get',
10
+ POST: 'post',
11
+ PUT: 'put',
12
+ DELETE: 'delete',
13
+ PATCH: 'patch',
14
+ ALL: 'all',
15
+ OPTIONS: 'options',
16
+ HEAD: 'head',
17
+ };
18
+ const defaultMetadata = {
19
+ path: '/',
20
+ requestMethod: exports.RequestMethod.GET,
21
+ routerName: null,
22
+ middleware: [],
23
+ };
24
+ const RequestMapping = (metadata = defaultMetadata) => {
25
+ const path = metadata.path || '/';
26
+ const requestMethod = metadata.requestMethod || exports.RequestMethod.GET;
27
+ const routerName = metadata.routerName;
28
+ const middleware = metadata.middleware;
29
+ return (target, key, descriptor) => {
30
+ var _a;
31
+ (0, __1.attachClassMetadata)(__1.WEB_ROUTER_KEY, {
32
+ path,
33
+ requestMethod,
34
+ routerName,
35
+ method: key,
36
+ middleware,
37
+ summary: (metadata === null || metadata === void 0 ? void 0 : metadata.summary) || '',
38
+ description: (metadata === null || metadata === void 0 ? void 0 : metadata.description) || '',
39
+ ignoreGlobalPrefix: (_a = metadata === null || metadata === void 0 ? void 0 : metadata.ignoreGlobalPrefix) !== null && _a !== void 0 ? _a : false,
40
+ }, target);
41
+ return descriptor;
42
+ };
43
+ };
44
+ exports.RequestMapping = RequestMapping;
45
+ const createMappingDecorator = (method) => (path, routerOptions = { middleware: [] }) => {
46
+ return (0, exports.RequestMapping)(Object.assign(routerOptions, {
47
+ requestMethod: method,
48
+ path,
49
+ }));
50
+ };
51
+ /**
52
+ * Routes HTTP POST requests to the specified path.
53
+ */
54
+ exports.Post = createMappingDecorator(exports.RequestMethod.POST);
55
+ /**
56
+ * Routes HTTP GET requests to the specified path.
57
+ */
58
+ exports.Get = createMappingDecorator(exports.RequestMethod.GET);
59
+ /**
60
+ * Routes HTTP DELETE requests to the specified path.
61
+ */
62
+ exports.Del = createMappingDecorator(exports.RequestMethod.DELETE);
63
+ /**
64
+ * Routes HTTP PUT requests to the specified path.
65
+ */
66
+ exports.Put = createMappingDecorator(exports.RequestMethod.PUT);
67
+ /**
68
+ * Routes HTTP PATCH requests to the specified path.
69
+ */
70
+ exports.Patch = createMappingDecorator(exports.RequestMethod.PATCH);
71
+ /**
72
+ * Routes HTTP OPTIONS requests to the specified path.
73
+ */
74
+ exports.Options = createMappingDecorator(exports.RequestMethod.OPTIONS);
75
+ /**
76
+ * Routes HTTP HEAD requests to the specified path.
77
+ */
78
+ exports.Head = createMappingDecorator(exports.RequestMethod.HEAD);
79
+ /**
80
+ * Routes all HTTP requests to the specified path.
81
+ */
82
+ exports.All = createMappingDecorator(exports.RequestMethod.ALL);
83
+ //# sourceMappingURL=requestMapping.js.map
@@ -0,0 +1,9 @@
1
+ export declare function Redirect(url: string, code?: number): (target: any, key: any, descriptor: PropertyDescriptor) => PropertyDescriptor;
2
+ export declare function HttpCode(code: number): (target: any, key: any, descriptor: PropertyDescriptor) => PropertyDescriptor;
3
+ export declare function SetHeader(headerKey: string | Record<string, any>, value?: string): (target: any, key: any, descriptor: PropertyDescriptor) => PropertyDescriptor;
4
+ export declare function ContentType(contentType: string): (target: any, key: any, descriptor: PropertyDescriptor) => PropertyDescriptor;
5
+ export declare function createRender(RenderEngine: {
6
+ render: () => string;
7
+ renderString: () => string;
8
+ }): (templateName: string) => (target: any, key: any, descriptor: PropertyDescriptor) => PropertyDescriptor;
9
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRender = exports.ContentType = exports.SetHeader = exports.HttpCode = exports.Redirect = void 0;
4
+ const __1 = require("../");
5
+ function Redirect(url, code = 302) {
6
+ return (target, key, descriptor) => {
7
+ (0, __1.attachPropertyMetadata)(__1.WEB_RESPONSE_KEY, {
8
+ type: __1.WEB_RESPONSE_REDIRECT,
9
+ url,
10
+ code,
11
+ }, target, key);
12
+ return descriptor;
13
+ };
14
+ }
15
+ exports.Redirect = Redirect;
16
+ function HttpCode(code) {
17
+ return (target, key, descriptor) => {
18
+ (0, __1.attachPropertyMetadata)(__1.WEB_RESPONSE_KEY, {
19
+ type: __1.WEB_RESPONSE_HTTP_CODE,
20
+ code,
21
+ }, target, key);
22
+ return descriptor;
23
+ };
24
+ }
25
+ exports.HttpCode = HttpCode;
26
+ function SetHeader(headerKey, value) {
27
+ return (target, key, descriptor) => {
28
+ let headerObject = {};
29
+ if (value) {
30
+ headerObject[headerKey] = value;
31
+ }
32
+ else {
33
+ headerObject = headerKey;
34
+ }
35
+ (0, __1.attachPropertyMetadata)(__1.WEB_RESPONSE_KEY, {
36
+ type: __1.WEB_RESPONSE_HEADER,
37
+ setHeaders: headerObject,
38
+ }, target, key);
39
+ return descriptor;
40
+ };
41
+ }
42
+ exports.SetHeader = SetHeader;
43
+ function ContentType(contentType) {
44
+ return (target, key, descriptor) => {
45
+ (0, __1.attachPropertyMetadata)(__1.WEB_RESPONSE_KEY, {
46
+ type: __1.WEB_RESPONSE_CONTENT_TYPE,
47
+ contentType,
48
+ }, target, key);
49
+ return descriptor;
50
+ };
51
+ }
52
+ exports.ContentType = ContentType;
53
+ function createRender(RenderEngine) {
54
+ return (templateName) => {
55
+ return (target, key, descriptor) => {
56
+ (0, __1.attachPropertyMetadata)(__1.WEB_RESPONSE_KEY, {
57
+ type: __1.WEB_RESPONSE_RENDER,
58
+ templateName,
59
+ }, target, key);
60
+ return descriptor;
61
+ };
62
+ };
63
+ }
64
+ exports.createRender = createRender;
65
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1,10 @@
1
+ import { MiddlewareParamArray } from '../';
2
+ export interface WSControllerOption {
3
+ namespace: string;
4
+ routerOptions: {
5
+ connectionMiddleware?: MiddlewareParamArray;
6
+ middleware?: MiddlewareParamArray;
7
+ };
8
+ }
9
+ export declare function WSController(namespace?: string | RegExp, routerOptions?: WSControllerOption['routerOptions']): ClassDecorator;
10
+ //# sourceMappingURL=webSocketController.d.ts.map
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WSController = void 0;
4
+ const __1 = require("../");
5
+ function WSController(namespace = '/', routerOptions = {
6
+ middleware: [],
7
+ connectionMiddleware: [],
8
+ }) {
9
+ return (target) => {
10
+ (0, __1.saveModule)(__1.WS_CONTROLLER_KEY, target);
11
+ (0, __1.saveClassMetadata)(__1.WS_CONTROLLER_KEY, {
12
+ namespace,
13
+ routerOptions,
14
+ }, target);
15
+ (0, __1.Scope)(__1.ScopeEnum.Request)(target);
16
+ (0, __1.Provide)()(target);
17
+ };
18
+ }
19
+ exports.WSController = WSController;
20
+ //# sourceMappingURL=webSocketController.js.map
@@ -0,0 +1,60 @@
1
+ import { MiddlewareParamArray } from '../';
2
+ export declare enum WSEventTypeEnum {
3
+ ON_CONNECTION = "ws:onConnection",
4
+ ON_DISCONNECTION = "ws:onDisconnection",
5
+ ON_MESSAGE = "ws:onMessage",
6
+ ON_SOCKET_ERROR = "ws:onSocketError",
7
+ EMIT = "ws:Emit",
8
+ BROADCAST = "ws:broadcast"
9
+ }
10
+ export interface WSEventInfo {
11
+ /**
12
+ * web socket event name in enum
13
+ */
14
+ eventType: WSEventTypeEnum;
15
+ /**
16
+ * decorator method name
17
+ */
18
+ propertyName: string;
19
+ descriptor: PropertyDescriptor;
20
+ /**
21
+ * the event name by user definition
22
+ */
23
+ messageEventName?: string;
24
+ /**
25
+ * the room name to emit
26
+ */
27
+ roomName?: string[];
28
+ /**
29
+ * event options, like middleware
30
+ */
31
+ eventOptions?: {
32
+ middleware?: MiddlewareParamArray;
33
+ };
34
+ }
35
+ export declare function OnWSConnection(eventOptions?: {
36
+ middleware?: MiddlewareParamArray;
37
+ }): MethodDecorator;
38
+ export declare function OnWSDisConnection(): MethodDecorator;
39
+ export declare function OnWSMessage(eventName: string, eventOptions?: {
40
+ middleware?: MiddlewareParamArray;
41
+ }): MethodDecorator;
42
+ export declare function WSEmit(messageName: string, roomName?: string | string[]): MethodDecorator;
43
+ export declare function WSBroadCast(messageName?: string, roomName?: string | string[]): MethodDecorator;
44
+ /**
45
+ * @deprecated please use @OnWSMessage
46
+ */
47
+ export declare const OnMessage: typeof OnWSMessage;
48
+ /**
49
+ * @deprecated please use @WSEmit
50
+ */
51
+ export declare const Emit: typeof WSEmit;
52
+ /**
53
+ * @deprecated please use @OnWSDisConnection
54
+ */
55
+ export declare const OnDisConnection: typeof OnWSDisConnection;
56
+ /**
57
+ * @deprecated please use @OnWSConnection
58
+ */
59
+ export declare const OnConnection: typeof OnWSConnection;
60
+ //# sourceMappingURL=webSocketEvent.d.ts.map