@midwayjs/decorator 3.0.0-beta.2 → 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 CHANGED
@@ -3,6 +3,49 @@
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
+
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)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * [@match](https://github.com/match) empty args ([#1384](https://github.com/midwayjs/midway/issues/1384)) ([6f90fc9](https://github.com/midwayjs/midway/commit/6f90fc993ff01e078288ff664833c61c02dede51))
23
+
24
+
25
+
26
+
27
+
28
+ # [3.0.0-beta.4](https://github.com/midwayjs/midway/compare/v3.0.0-beta.3...v3.0.0-beta.4) (2021-11-24)
29
+
30
+
31
+ ### Features
32
+
33
+ * add i18n ([#1375](https://github.com/midwayjs/midway/issues/1375)) ([bffefe0](https://github.com/midwayjs/midway/commit/bffefe07afe45777d49b5a76b9ab17fc2b9d9a55))
34
+ * auto transform args to type ([#1372](https://github.com/midwayjs/midway/issues/1372)) ([bb3f7d2](https://github.com/midwayjs/midway/commit/bb3f7d2028a034e1926d9df554849332354c3762))
35
+ * support global prefix url ([#1371](https://github.com/midwayjs/midway/issues/1371)) ([cc5fe44](https://github.com/midwayjs/midway/commit/cc5fe44e1d221590562dc71e1f33ae96093e0da7))
36
+
37
+
38
+
39
+
40
+
41
+ # [3.0.0-beta.3](https://github.com/midwayjs/midway/compare/v3.0.0-beta.2...v3.0.0-beta.3) (2021-11-18)
42
+
43
+ **Note:** Version bump only for package @midwayjs/decorator
44
+
45
+
46
+
47
+
48
+
6
49
  # [3.0.0-beta.2](https://github.com/midwayjs/midway/compare/v3.0.0-beta.1...v3.0.0-beta.2) (2021-11-16)
7
50
 
8
51
 
@@ -4,6 +4,7 @@ export declare const CONFIGURATION_KEY = "common:configuration";
4
4
  export declare const FRAMEWORK_KEY = "common:framework";
5
5
  export declare const ASPECT_KEY = "common:aspect";
6
6
  export declare const CATCH_KEY = "common:catch";
7
+ export declare const MATCH_KEY = "common:match";
7
8
  export declare const FUNC_KEY = "faas:func";
8
9
  export declare const SERVERLESS_FUNC_KEY = "faas:serverless:function";
9
10
  export declare const CONTROLLER_KEY = "web:controller";
package/dist/constant.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LIFECYCLE_IDENTIFIER_PREFIX = exports.PIPELINE_IDENTIFIER = exports.OBJ_DEF_CLS = exports.TAGGED_FUN = exports.TAGGED_CLS = exports.INJECT_CUSTOM_PARAM = exports.INJECT_CUSTOM_METHOD = exports.INJECT_CUSTOM_PROPERTY = exports.INJECT_TAG = exports.NAMED_TAG = exports.CLASS_KEY_CONSTRUCTOR = exports.APPLICATION_CONTEXT_KEY = exports.APPLICATION_KEY = exports.LOGGER_KEY = exports.PLUGIN_KEY = exports.CONFIG_KEY = exports.MS_HSF_METHOD_KEY = exports.MS_DUBBO_METHOD_KEY = exports.MS_GRPC_METHOD_KEY = exports.MS_PROVIDER_KEY = exports.MS_PRODUCER_KEY = exports.MS_CONSUMER_KEY = exports.RPC_DUBBO_KEY = exports.RPC_GRPC_KEY = exports.HSF_KEY = exports.WS_EVENT_KEY = exports.WS_CONTROLLER_KEY = exports.MODULE_TASK_QUEUE_OPTIONS = exports.MODULE_TASK_QUEUE_KEY = exports.MODULE_TASK_TASK_LOCAL_OPTIONS = exports.MODULE_TASK_TASK_LOCAL_KEY = exports.MODULE_TASK_METADATA = exports.MODULE_TASK_KEY = exports.WEB_RESPONSE_RENDER = exports.WEB_RESPONSE_CONTENT_TYPE = exports.WEB_RESPONSE_HEADER = exports.WEB_RESPONSE_REDIRECT = exports.WEB_RESPONSE_HTTP_CODE = exports.WEB_RESPONSE_KEY = exports.WEB_ROUTER_PARAM_KEY = exports.WEB_ROUTER_KEY = exports.CONTROLLER_KEY = exports.SERVERLESS_FUNC_KEY = exports.FUNC_KEY = exports.CATCH_KEY = exports.ASPECT_KEY = exports.FRAMEWORK_KEY = exports.CONFIGURATION_KEY = exports.SCHEDULE_KEY = exports.ALL = void 0;
4
- exports.PRIVATE_META_DATA_KEY = exports.MAIN_MODULE_KEY = void 0;
3
+ exports.PIPELINE_IDENTIFIER = exports.OBJ_DEF_CLS = exports.TAGGED_FUN = exports.TAGGED_CLS = exports.INJECT_CUSTOM_PARAM = exports.INJECT_CUSTOM_METHOD = exports.INJECT_CUSTOM_PROPERTY = exports.INJECT_TAG = exports.NAMED_TAG = exports.CLASS_KEY_CONSTRUCTOR = exports.APPLICATION_CONTEXT_KEY = exports.APPLICATION_KEY = exports.LOGGER_KEY = exports.PLUGIN_KEY = exports.CONFIG_KEY = exports.MS_HSF_METHOD_KEY = exports.MS_DUBBO_METHOD_KEY = exports.MS_GRPC_METHOD_KEY = exports.MS_PROVIDER_KEY = exports.MS_PRODUCER_KEY = exports.MS_CONSUMER_KEY = exports.RPC_DUBBO_KEY = exports.RPC_GRPC_KEY = exports.HSF_KEY = exports.WS_EVENT_KEY = exports.WS_CONTROLLER_KEY = exports.MODULE_TASK_QUEUE_OPTIONS = exports.MODULE_TASK_QUEUE_KEY = exports.MODULE_TASK_TASK_LOCAL_OPTIONS = exports.MODULE_TASK_TASK_LOCAL_KEY = exports.MODULE_TASK_METADATA = exports.MODULE_TASK_KEY = exports.WEB_RESPONSE_RENDER = exports.WEB_RESPONSE_CONTENT_TYPE = exports.WEB_RESPONSE_HEADER = exports.WEB_RESPONSE_REDIRECT = exports.WEB_RESPONSE_HTTP_CODE = exports.WEB_RESPONSE_KEY = exports.WEB_ROUTER_PARAM_KEY = exports.WEB_ROUTER_KEY = exports.CONTROLLER_KEY = exports.SERVERLESS_FUNC_KEY = exports.FUNC_KEY = exports.MATCH_KEY = exports.CATCH_KEY = exports.ASPECT_KEY = exports.FRAMEWORK_KEY = exports.CONFIGURATION_KEY = exports.SCHEDULE_KEY = exports.ALL = void 0;
4
+ exports.PRIVATE_META_DATA_KEY = exports.MAIN_MODULE_KEY = exports.LIFECYCLE_IDENTIFIER_PREFIX = void 0;
5
5
  // got all value with no property name
6
6
  exports.ALL = 'common:all_value_key';
7
7
  // common
@@ -10,6 +10,7 @@ exports.CONFIGURATION_KEY = 'common:configuration';
10
10
  exports.FRAMEWORK_KEY = 'common:framework';
11
11
  exports.ASPECT_KEY = 'common:aspect';
12
12
  exports.CATCH_KEY = 'common:catch';
13
+ exports.MATCH_KEY = 'common:match';
13
14
  // faas
14
15
  exports.FUNC_KEY = 'faas:func';
15
16
  exports.SERVERLESS_FUNC_KEY = 'faas:serverless:function';
@@ -0,0 +1,4 @@
1
+ export declare function Catch(catchTarget?: any | any[]): (target: any) => void;
2
+ export declare type MatchPattern<CtxOrReq = any, Res = any> = ((ctxOrReq: CtxOrReq, res: Res) => boolean) | string | string[] | boolean;
3
+ export declare function Match(matchPattern?: MatchPattern): (target: any) => void;
4
+ //# sourceMappingURL=filter.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Catch = void 0;
3
+ exports.Match = exports.Catch = void 0;
4
4
  const decoratorManager_1 = require("../../decoratorManager");
5
5
  const constant_1 = require("../../constant");
6
6
  const objectDef_1 = require("./objectDef");
@@ -8,8 +8,8 @@ const interface_1 = require("../../interface");
8
8
  const provide_1 = require("./provide");
9
9
  function Catch(catchTarget) {
10
10
  return function (target) {
11
- const catchTargets = [].concat(catchTarget);
12
- (0, decoratorManager_1.attachClassMetadata)(constant_1.CATCH_KEY, {
11
+ const catchTargets = catchTarget ? [].concat(catchTarget) : undefined;
12
+ (0, decoratorManager_1.saveClassMetadata)(constant_1.CATCH_KEY, {
13
13
  catchTargets,
14
14
  }, target);
15
15
  (0, objectDef_1.Scope)(interface_1.ScopeEnum.Singleton)(target);
@@ -17,4 +17,14 @@ function Catch(catchTarget) {
17
17
  };
18
18
  }
19
19
  exports.Catch = Catch;
20
- //# sourceMappingURL=catch.js.map
20
+ function Match(matchPattern = true) {
21
+ return function (target) {
22
+ (0, decoratorManager_1.saveClassMetadata)(constant_1.MATCH_KEY, {
23
+ matchPattern,
24
+ }, target);
25
+ (0, objectDef_1.Scope)(interface_1.ScopeEnum.Singleton)(target);
26
+ (0, provide_1.Provide)()(target);
27
+ };
28
+ }
29
+ exports.Match = Match;
30
+ //# sourceMappingURL=filter.js.map
@@ -6,6 +6,6 @@ export * from './autoload';
6
6
  export * from './configuration';
7
7
  export * from './objectDef';
8
8
  export * from './framework';
9
- export * from './catch';
9
+ export * from './filter';
10
10
  export * from './middleware';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -18,6 +18,6 @@ __exportStar(require("./autoload"), exports);
18
18
  __exportStar(require("./configuration"), exports);
19
19
  __exportStar(require("./objectDef"), exports);
20
20
  __exportStar(require("./framework"), exports);
21
- __exportStar(require("./catch"), exports);
21
+ __exportStar(require("./filter"), exports);
22
22
  __exportStar(require("./middleware"), exports);
23
23
  //# sourceMappingURL=index.js.map
@@ -7,6 +7,7 @@ export interface ControllerOption {
7
7
  alias?: string[];
8
8
  description?: string;
9
9
  tagName?: string;
10
+ ignoreGlobalPrefix?: boolean;
10
11
  };
11
12
  }
12
13
  export declare function Controller(prefix?: string, routerOptions?: {
@@ -14,5 +15,6 @@ export declare function Controller(prefix?: string, routerOptions?: {
14
15
  middleware?: MiddlewareParamArray;
15
16
  description?: string;
16
17
  tagName?: string;
18
+ ignoreGlobalPrefix?: boolean;
17
19
  }): ClassDecorator;
18
20
  //# sourceMappingURL=controller.d.ts.map
@@ -1,12 +1,37 @@
1
1
  import { MiddlewareParamArray } from '../../interface';
2
2
  export interface RouterOption {
3
+ /**
4
+ * router path, like "/api"
5
+ */
3
6
  path?: string | RegExp;
7
+ /**
8
+ * http method, like "get", "post"
9
+ */
4
10
  requestMethod: string;
11
+ /**
12
+ * router alias name
13
+ */
5
14
  routerName?: string;
15
+ /**
16
+ * which method decorator attached
17
+ */
6
18
  method?: string;
19
+ /**
20
+ * middleware array in router
21
+ */
7
22
  middleware?: MiddlewareParamArray;
23
+ /**
24
+ * router summary, for swagger
25
+ */
8
26
  summary?: string;
27
+ /**
28
+ * router description, for swagger
29
+ */
9
30
  description?: string;
31
+ /**
32
+ * ignore global prefix
33
+ */
34
+ ignoreGlobalPrefix?: boolean;
10
35
  }
11
36
  export declare const RequestMethod: {
12
37
  GET: string;
@@ -27,6 +52,7 @@ export declare const Post: (path?: string | RegExp, routerOptions?: {
27
52
  middleware?: MiddlewareParamArray;
28
53
  summary?: string;
29
54
  description?: string;
55
+ ignoreGlobalPrefix?: boolean;
30
56
  }) => MethodDecorator;
31
57
  /**
32
58
  * Routes HTTP GET requests to the specified path.
@@ -36,6 +62,7 @@ export declare const Get: (path?: string | RegExp, routerOptions?: {
36
62
  middleware?: MiddlewareParamArray;
37
63
  summary?: string;
38
64
  description?: string;
65
+ ignoreGlobalPrefix?: boolean;
39
66
  }) => MethodDecorator;
40
67
  /**
41
68
  * Routes HTTP DELETE requests to the specified path.
@@ -45,6 +72,7 @@ export declare const Del: (path?: string | RegExp, routerOptions?: {
45
72
  middleware?: MiddlewareParamArray;
46
73
  summary?: string;
47
74
  description?: string;
75
+ ignoreGlobalPrefix?: boolean;
48
76
  }) => MethodDecorator;
49
77
  /**
50
78
  * Routes HTTP PUT requests to the specified path.
@@ -54,6 +82,7 @@ export declare const Put: (path?: string | RegExp, routerOptions?: {
54
82
  middleware?: MiddlewareParamArray;
55
83
  summary?: string;
56
84
  description?: string;
85
+ ignoreGlobalPrefix?: boolean;
57
86
  }) => MethodDecorator;
58
87
  /**
59
88
  * Routes HTTP PATCH requests to the specified path.
@@ -63,6 +92,7 @@ export declare const Patch: (path?: string | RegExp, routerOptions?: {
63
92
  middleware?: MiddlewareParamArray;
64
93
  summary?: string;
65
94
  description?: string;
95
+ ignoreGlobalPrefix?: boolean;
66
96
  }) => MethodDecorator;
67
97
  /**
68
98
  * Routes HTTP OPTIONS requests to the specified path.
@@ -72,6 +102,7 @@ export declare const Options: (path?: string | RegExp, routerOptions?: {
72
102
  middleware?: MiddlewareParamArray;
73
103
  summary?: string;
74
104
  description?: string;
105
+ ignoreGlobalPrefix?: boolean;
75
106
  }) => MethodDecorator;
76
107
  /**
77
108
  * Routes HTTP HEAD requests to the specified path.
@@ -81,6 +112,7 @@ export declare const Head: (path?: string | RegExp, routerOptions?: {
81
112
  middleware?: MiddlewareParamArray;
82
113
  summary?: string;
83
114
  description?: string;
115
+ ignoreGlobalPrefix?: boolean;
84
116
  }) => MethodDecorator;
85
117
  /**
86
118
  * Routes all HTTP requests to the specified path.
@@ -90,5 +122,6 @@ export declare const All: (path?: string | RegExp, routerOptions?: {
90
122
  middleware?: MiddlewareParamArray;
91
123
  summary?: string;
92
124
  description?: string;
125
+ ignoreGlobalPrefix?: boolean;
93
126
  }) => MethodDecorator;
94
127
  //# sourceMappingURL=requestMapping.d.ts.map
@@ -27,6 +27,7 @@ const RequestMapping = (metadata = defaultMetadata) => {
27
27
  const routerName = metadata.routerName;
28
28
  const middleware = metadata.middleware;
29
29
  return (target, key, descriptor) => {
30
+ var _a;
30
31
  (0, __1.attachClassMetadata)(__1.WEB_ROUTER_KEY, {
31
32
  path,
32
33
  requestMethod,
@@ -35,6 +36,7 @@ const RequestMapping = (metadata = defaultMetadata) => {
35
36
  middleware,
36
37
  summary: (metadata === null || metadata === void 0 ? void 0 : metadata.summary) || '',
37
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,
38
40
  }, target);
39
41
  return descriptor;
40
42
  };
@@ -256,6 +256,11 @@ export declare function getProviderUUId(module: any): string;
256
256
  * @param target class
257
257
  */
258
258
  export declare function isProvide(target: any): boolean;
259
+ export declare enum BaseType {
260
+ Boolean = "boolean",
261
+ Number = "number",
262
+ String = "string"
263
+ }
259
264
  /**
260
265
  * get parameters type by reflect-metadata
261
266
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createCustomParamDecorator = exports.createCustomMethodDecorator = exports.createCustomPropertyDecorator = exports.getMethodReturnTypes = exports.getPropertyType = exports.getMethodParamTypes = exports.isProvide = exports.getProviderUUId = exports.getProviderName = exports.getProviderId = exports.saveProviderId = exports.getObjectDefinition = exports.saveObjectDefinition = exports.getPropertyInject = exports.savePropertyInject = exports.clearAllModule = exports.resetModule = exports.listModule = exports.clearBindContainer = exports.bindContainer = exports.saveModule = exports.listPreloadModule = exports.savePreloadModule = exports.getPropertyMetadata = exports.attachPropertyMetadata = exports.savePropertyMetadata = exports.listPropertyDataFromClass = exports.getPropertyDataFromClass = exports.attachPropertyDataToClass = exports.savePropertyDataToClass = exports.getClassMetadata = exports.getClassExtendedMetadata = exports.attachClassMetadata = exports.saveClassMetadata = exports.DecoratorManager = exports.INJECT_CLASS_KEY_PREFIX = exports.PRELOAD_MODULE_KEY = void 0;
3
+ exports.createCustomParamDecorator = exports.createCustomMethodDecorator = exports.createCustomPropertyDecorator = exports.getMethodReturnTypes = exports.getPropertyType = exports.getMethodParamTypes = exports.BaseType = exports.isProvide = exports.getProviderUUId = exports.getProviderName = exports.getProviderId = exports.saveProviderId = exports.getObjectDefinition = exports.saveObjectDefinition = exports.getPropertyInject = exports.savePropertyInject = exports.clearAllModule = exports.resetModule = exports.listModule = exports.clearBindContainer = exports.bindContainer = exports.saveModule = exports.listPreloadModule = exports.savePreloadModule = exports.getPropertyMetadata = exports.attachPropertyMetadata = exports.savePropertyMetadata = exports.listPropertyDataFromClass = exports.getPropertyDataFromClass = exports.attachPropertyDataToClass = exports.savePropertyDataToClass = exports.getClassMetadata = exports.getClassExtendedMetadata = exports.attachClassMetadata = exports.saveClassMetadata = exports.DecoratorManager = exports.INJECT_CLASS_KEY_PREFIX = exports.PRELOAD_MODULE_KEY = void 0;
4
4
  require("reflect-metadata");
5
5
  const constant_1 = require("./constant");
6
6
  const util_1 = require("./util");
@@ -243,12 +243,14 @@ class DecoratorManager extends Map {
243
243
  }
244
244
  exports.DecoratorManager = DecoratorManager;
245
245
  let manager = new DecoratorManager();
246
- if (global['MIDWAY_GLOBAL_DECORATOR_MANAGER']) {
247
- console.warn('DecoratorManager not singleton and please check @midwayjs/decorator version by "npm ls @midwayjs/decorator"');
248
- manager = global['MIDWAY_GLOBAL_DECORATOR_MANAGER'];
249
- }
250
- else {
251
- global['MIDWAY_GLOBAL_DECORATOR_MANAGER'] = manager;
246
+ if (typeof global === 'object') {
247
+ if (global['MIDWAY_GLOBAL_DECORATOR_MANAGER']) {
248
+ console.warn('DecoratorManager not singleton and please check @midwayjs/decorator version by "npm ls @midwayjs/decorator"');
249
+ manager = global['MIDWAY_GLOBAL_DECORATOR_MANAGER'];
250
+ }
251
+ else {
252
+ global['MIDWAY_GLOBAL_DECORATOR_MANAGER'] = manager;
253
+ }
252
254
  }
253
255
  /**
254
256
  * save data to class
@@ -607,6 +609,12 @@ function isProvide(target) {
607
609
  return !!getClassMetadata(constant_1.TAGGED_CLS, target);
608
610
  }
609
611
  exports.isProvide = isProvide;
612
+ var BaseType;
613
+ (function (BaseType) {
614
+ BaseType["Boolean"] = "boolean";
615
+ BaseType["Number"] = "number";
616
+ BaseType["String"] = "string";
617
+ })(BaseType = exports.BaseType || (exports.BaseType = {}));
610
618
  /**
611
619
  * get parameters type by reflect-metadata
612
620
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/decorator",
3
- "version": "3.0.0-beta.2",
3
+ "version": "3.0.0-beta.6",
4
4
  "description": "definition decorator for midway project",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -37,5 +37,5 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "7f07de960da1155a9f7df554e1789c7a97bdd3fe"
40
+ "gitHead": "e4595d30b369e36bef21b36f2b3737d8bc2f802d"
41
41
  }
@@ -1,2 +0,0 @@
1
- export declare function Catch(catchTarget?: any | any[]): (target: any) => void;
2
- //# sourceMappingURL=catch.d.ts.map