koatty_router 1.7.2 → 1.7.3

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
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.7.3](https://github.com/koatty/koatty_router/compare/v1.7.2...v1.7.3) (2022-03-09)
6
+
5
7
  ### [1.7.2](https://github.com/koatty/koatty_router/compare/v1.7.1...v1.7.2) (2022-02-25)
6
8
 
7
9
  ### [1.7.1](https://github.com/koatty/koatty_router/compare/v1.7.0...v1.7.1) (2022-02-23)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-02-25 11:29:27
3
+ * @Date: 2022-03-09 18:48:02
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-02-25 11:29:11
3
+ * @Date: 2022-03-09 18:47:35
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -46,7 +46,7 @@ var KoaRouter__default = /*#__PURE__*/_interopDefaultLegacy(KoaRouter);
46
46
  * @Usage:
47
47
  * @Author: richen
48
48
  * @Date: 2021-11-24 23:21:26
49
- * @LastEditTime: 2022-02-25 11:24:12
49
+ * @LastEditTime: 2022-03-09 18:14:25
50
50
  */
51
51
  /**
52
52
  * Parameter binding assignment.
@@ -69,7 +69,8 @@ async function getParamter(app, ctx, params) {
69
69
  index: k,
70
70
  isDto: v.isDto,
71
71
  type: v.type,
72
- validRules: v.rule,
72
+ validRule: v.rule,
73
+ validOpt: v.options,
73
74
  dtoCheck: v.dtoCheck,
74
75
  dtoRule: v.dtoRule,
75
76
  clazz: v.clazz,
@@ -104,10 +105,10 @@ async function checkParams(app, value, opt) {
104
105
  else {
105
106
  value = koatty_validation.convertParamsType(value, opt.type);
106
107
  //@Valid()
107
- if (opt.validRules[opt.index]) {
108
- const { type, rule, options } = opt.validRules[opt.index];
109
- if (type && rule) {
110
- validatorFuncs(`${opt.index}`, value, type, rule, options, false);
108
+ if (opt) {
109
+ const { type, validRule, validOpt } = opt;
110
+ if (type && validRule) {
111
+ validatorFuncs(`${opt.index}`, value, type, validRule, validOpt, false);
111
112
  }
112
113
  }
113
114
  }
@@ -298,7 +299,7 @@ const HeadMapping = (path = "/", routerOptions = {}) => {
298
299
  * @Usage:
299
300
  * @Author: richen
300
301
  * @Date: 2021-11-10 16:58:57
301
- * @LastEditTime: 2022-02-22 14:35:08
302
+ * @LastEditTime: 2022-03-09 18:14:12
302
303
  */
303
304
  /**
304
305
  * controller handler
@@ -375,6 +376,7 @@ function injectParam(app, target, instance) {
375
376
  const validatedMetaDatas = koatty_container.RecursiveGetMetadata(koatty_validation.PARAM_CHECK_KEY, target);
376
377
  const argsMetaObj = {};
377
378
  for (const meta in metaDatas) {
379
+ // 实例方法带规则形参必须小于等于原型形参(如果不存在验证规则,则小于)
378
380
  if (instance[meta] && instance[meta].length <= metaDatas[meta].length) {
379
381
  koatty_logger.DefaultLogger.Debug(`Register inject param key ${koatty_container.IOCContainer.getIdentifier(target)}: ${Helper__namespace.toString(meta)} => value: ${JSON.stringify(metaDatas[meta])}`);
380
382
  // cover to obj
@@ -382,10 +384,10 @@ function injectParam(app, target, instance) {
382
384
  const validData = (_b = validMetaDatas[meta]) !== null && _b !== void 0 ? _b : [];
383
385
  data.forEach((v) => {
384
386
  var _a;
385
- v.rule = {};
386
387
  validData.forEach((it) => {
387
- if (v.index === it.index) {
388
- v.rule = it;
388
+ if (v.index === it.index && it.name === v.name) {
389
+ v.rule = it.rule;
390
+ v.options = it.options;
389
391
  }
390
392
  });
391
393
  if (v.type) {
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-02-25 11:29:11
3
+ * @Date: 2022-03-09 18:47:35
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -19,7 +19,7 @@ import KoaRouter from '@koa/router';
19
19
  * @Usage:
20
20
  * @Author: richen
21
21
  * @Date: 2021-11-24 23:21:26
22
- * @LastEditTime: 2022-02-25 11:24:12
22
+ * @LastEditTime: 2022-03-09 18:14:25
23
23
  */
24
24
  /**
25
25
  * Parameter binding assignment.
@@ -42,7 +42,8 @@ async function getParamter(app, ctx, params) {
42
42
  index: k,
43
43
  isDto: v.isDto,
44
44
  type: v.type,
45
- validRules: v.rule,
45
+ validRule: v.rule,
46
+ validOpt: v.options,
46
47
  dtoCheck: v.dtoCheck,
47
48
  dtoRule: v.dtoRule,
48
49
  clazz: v.clazz,
@@ -77,10 +78,10 @@ async function checkParams(app, value, opt) {
77
78
  else {
78
79
  value = convertParamsType(value, opt.type);
79
80
  //@Valid()
80
- if (opt.validRules[opt.index]) {
81
- const { type, rule, options } = opt.validRules[opt.index];
82
- if (type && rule) {
83
- validatorFuncs(`${opt.index}`, value, type, rule, options, false);
81
+ if (opt) {
82
+ const { type, validRule, validOpt } = opt;
83
+ if (type && validRule) {
84
+ validatorFuncs(`${opt.index}`, value, type, validRule, validOpt, false);
84
85
  }
85
86
  }
86
87
  }
@@ -271,7 +272,7 @@ const HeadMapping = (path = "/", routerOptions = {}) => {
271
272
  * @Usage:
272
273
  * @Author: richen
273
274
  * @Date: 2021-11-10 16:58:57
274
- * @LastEditTime: 2022-02-22 14:35:08
275
+ * @LastEditTime: 2022-03-09 18:14:12
275
276
  */
276
277
  /**
277
278
  * controller handler
@@ -348,6 +349,7 @@ function injectParam(app, target, instance) {
348
349
  const validatedMetaDatas = RecursiveGetMetadata(PARAM_CHECK_KEY, target);
349
350
  const argsMetaObj = {};
350
351
  for (const meta in metaDatas) {
352
+ // 实例方法带规则形参必须小于等于原型形参(如果不存在验证规则,则小于)
351
353
  if (instance[meta] && instance[meta].length <= metaDatas[meta].length) {
352
354
  DefaultLogger.Debug(`Register inject param key ${IOCContainer.getIdentifier(target)}: ${Helper.toString(meta)} => value: ${JSON.stringify(metaDatas[meta])}`);
353
355
  // cover to obj
@@ -355,10 +357,10 @@ function injectParam(app, target, instance) {
355
357
  const validData = (_b = validMetaDatas[meta]) !== null && _b !== void 0 ? _b : [];
356
358
  data.forEach((v) => {
357
359
  var _a;
358
- v.rule = {};
359
360
  validData.forEach((it) => {
360
- if (v.index === it.index) {
361
- v.rule = it;
361
+ if (v.index === it.index && it.name === v.name) {
362
+ v.rule = it.rule;
363
+ v.options = it.options;
362
364
  }
363
365
  });
364
366
  if (v.type) {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty_router",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "Koatty routing component, adapt to http1/2, websocket, gRPC.",
5
5
  "scripts": {
6
6
  "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty_router",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "Koatty routing component, adapt to http1/2, websocket, gRPC.",
5
5
  "scripts": {
6
6
  "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",