koatty_router 1.9.0 → 1.9.1
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 +7 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -40
- package/dist/index.mjs +40 -40
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.9.1](https://github.com/koatty/koatty_router/compare/v1.9.0...v1.9.1) (2024-03-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* injectParamMetaData参数传递错误 ([c2f91c4](https://github.com/koatty/koatty_router/commit/c2f91c4d825c5ba573f56360f3113636d58a3dd3))
|
|
11
|
+
|
|
5
12
|
## [1.9.0](https://github.com/koatty/koatty_router/compare/v1.9.0-2...v1.9.0) (2024-01-16)
|
|
6
13
|
|
|
7
14
|
## [1.9.0-2](https://github.com/koatty/koatty_router/compare/v1.9.0-1...v1.9.0-2) (2024-01-15)
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @Author: richen
|
|
3
|
-
* @Date: 2024-
|
|
3
|
+
* @Date: 2024-03-15 10:25:41
|
|
4
4
|
* @License: BSD (3-Clause)
|
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
6
6
|
* @HomePage: https://koatty.org/
|
|
@@ -212,7 +212,7 @@ const HeadMapping = (path = "/", routerOptions = {}) => {
|
|
|
212
212
|
* @Usage:
|
|
213
213
|
* @Author: richen
|
|
214
214
|
* @Date: 2023-12-09 12:02:29
|
|
215
|
-
* @LastEditTime: 2024-
|
|
215
|
+
* @LastEditTime: 2024-03-15 10:21:27
|
|
216
216
|
* @License: BSD (3-Clause)
|
|
217
217
|
* @Copyright (c): <richenlin(at)gmail.com>
|
|
218
218
|
*/
|
|
@@ -282,55 +282,55 @@ function injectRouter(app, target, instance) {
|
|
|
282
282
|
*
|
|
283
283
|
* @param {Koatty} app
|
|
284
284
|
* @param {*} target
|
|
285
|
-
* @param {*} [
|
|
285
|
+
* @param {*} [options]
|
|
286
286
|
* @returns {*}
|
|
287
287
|
*/
|
|
288
|
-
function injectParamMetaData(app, target,
|
|
288
|
+
function injectParamMetaData(app, target, options) {
|
|
289
289
|
var _a, _b;
|
|
290
|
-
|
|
290
|
+
// const instance = target.prototype;
|
|
291
291
|
const metaDatas = koatty_container.RecursiveGetMetadata(koatty_container.TAGGED_PARAM, target);
|
|
292
292
|
const validMetaDatas = koatty_container.RecursiveGetMetadata(koatty_validation.PARAM_RULE_KEY, target);
|
|
293
293
|
const validatedMetaDatas = koatty_container.RecursiveGetMetadata(koatty_validation.PARAM_CHECK_KEY, target);
|
|
294
294
|
const argsMetaObj = {};
|
|
295
295
|
for (const meta in metaDatas) {
|
|
296
296
|
// 实例方法带规则形参必须小于等于原型形参(如果不存在验证规则,则小于)
|
|
297
|
-
if (instance[meta] && instance[meta].length <= metaDatas[meta].length) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
if (v.type) {
|
|
311
|
-
v.type = v.isDto ? v.type : (v.type).toLowerCase();
|
|
297
|
+
// if (instance[meta] && instance[meta].length <= metaDatas[meta].length) {
|
|
298
|
+
koatty_logger.DefaultLogger.Debug(`Register inject param key ${koatty_container.IOCContainer.getIdentifier(target)}: ${Helper.Helper.toString(meta)} => value: ${JSON.stringify(metaDatas[meta])}`);
|
|
299
|
+
// cover to obj
|
|
300
|
+
const data = ((_a = metaDatas[meta]) !== null && _a !== void 0 ? _a : []).sort((a, b) => a.index - b.index);
|
|
301
|
+
const validData = (_b = validMetaDatas[meta]) !== null && _b !== void 0 ? _b : [];
|
|
302
|
+
data.forEach((v) => {
|
|
303
|
+
var _a;
|
|
304
|
+
validData.forEach((it) => {
|
|
305
|
+
if (v.index === it.index && it.name === v.name) {
|
|
306
|
+
v.validRule = it.rule;
|
|
307
|
+
v.validOpt = it.options;
|
|
312
308
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
309
|
+
});
|
|
310
|
+
if (v.type) {
|
|
311
|
+
v.type = v.isDto ? v.type : (v.type).toLowerCase();
|
|
312
|
+
}
|
|
313
|
+
v.dtoCheck = !!(((_a = validatedMetaDatas[meta]) === null || _a === void 0 ? void 0 : _a.dtoCheck));
|
|
314
|
+
if (v.isDto) {
|
|
315
|
+
v.clazz = koatty_container.IOCContainer.getClass(v.type, "COMPONENT");
|
|
316
|
+
if (!v.clazz) {
|
|
317
|
+
throw Error(`Failed to obtain the class ${v.type},
|
|
318
318
|
because the class is not registered in the container.`);
|
|
319
|
-
}
|
|
320
|
-
if (v.dtoCheck) {
|
|
321
|
-
v.dtoRule = koatty_container.getOriginMetadata(koatty_validation.PARAM_TYPE_KEY, v.clazz);
|
|
322
|
-
Reflect.defineProperty(v.clazz.prototype, "_typeDef", {
|
|
323
|
-
enumerable: true,
|
|
324
|
-
configurable: false,
|
|
325
|
-
writable: false,
|
|
326
|
-
value: v.dtoRule,
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
319
|
}
|
|
330
|
-
v.
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
320
|
+
if (v.dtoCheck) {
|
|
321
|
+
v.dtoRule = koatty_container.getOriginMetadata(koatty_validation.PARAM_TYPE_KEY, v.clazz);
|
|
322
|
+
Reflect.defineProperty(v.clazz.prototype, "_typeDef", {
|
|
323
|
+
enumerable: true,
|
|
324
|
+
configurable: false,
|
|
325
|
+
writable: false,
|
|
326
|
+
value: v.dtoRule,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
v.options = options;
|
|
331
|
+
});
|
|
332
|
+
argsMetaObj[meta] = data;
|
|
333
|
+
// }
|
|
334
334
|
}
|
|
335
335
|
return argsMetaObj;
|
|
336
336
|
}
|
|
@@ -711,7 +711,7 @@ async function parseXml(ctx, opts) {
|
|
|
711
711
|
* @Usage:
|
|
712
712
|
* @Author: richen
|
|
713
713
|
* @Date: 2021-06-29 14:10:30
|
|
714
|
-
* @LastEditTime: 2024-01-16
|
|
714
|
+
* @LastEditTime: 2024-01-16 22:49:46
|
|
715
715
|
*/
|
|
716
716
|
class GrpcRouter {
|
|
717
717
|
constructor(app, options) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @Author: richen
|
|
3
|
-
* @Date: 2024-
|
|
3
|
+
* @Date: 2024-03-15 10:25:41
|
|
4
4
|
* @License: BSD (3-Clause)
|
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
6
6
|
* @HomePage: https://koatty.org/
|
|
@@ -192,7 +192,7 @@ const HeadMapping = (path = "/", routerOptions = {}) => {
|
|
|
192
192
|
* @Usage:
|
|
193
193
|
* @Author: richen
|
|
194
194
|
* @Date: 2023-12-09 12:02:29
|
|
195
|
-
* @LastEditTime: 2024-
|
|
195
|
+
* @LastEditTime: 2024-03-15 10:21:27
|
|
196
196
|
* @License: BSD (3-Clause)
|
|
197
197
|
* @Copyright (c): <richenlin(at)gmail.com>
|
|
198
198
|
*/
|
|
@@ -262,55 +262,55 @@ function injectRouter(app, target, instance) {
|
|
|
262
262
|
*
|
|
263
263
|
* @param {Koatty} app
|
|
264
264
|
* @param {*} target
|
|
265
|
-
* @param {*} [
|
|
265
|
+
* @param {*} [options]
|
|
266
266
|
* @returns {*}
|
|
267
267
|
*/
|
|
268
|
-
function injectParamMetaData(app, target,
|
|
268
|
+
function injectParamMetaData(app, target, options) {
|
|
269
269
|
var _a, _b;
|
|
270
|
-
|
|
270
|
+
// const instance = target.prototype;
|
|
271
271
|
const metaDatas = RecursiveGetMetadata(TAGGED_PARAM, target);
|
|
272
272
|
const validMetaDatas = RecursiveGetMetadata(PARAM_RULE_KEY, target);
|
|
273
273
|
const validatedMetaDatas = RecursiveGetMetadata(PARAM_CHECK_KEY, target);
|
|
274
274
|
const argsMetaObj = {};
|
|
275
275
|
for (const meta in metaDatas) {
|
|
276
276
|
// 实例方法带规则形参必须小于等于原型形参(如果不存在验证规则,则小于)
|
|
277
|
-
if (instance[meta] && instance[meta].length <= metaDatas[meta].length) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
if (v.type) {
|
|
291
|
-
v.type = v.isDto ? v.type : (v.type).toLowerCase();
|
|
277
|
+
// if (instance[meta] && instance[meta].length <= metaDatas[meta].length) {
|
|
278
|
+
DefaultLogger.Debug(`Register inject param key ${IOCContainer.getIdentifier(target)}: ${Helper$1.toString(meta)} => value: ${JSON.stringify(metaDatas[meta])}`);
|
|
279
|
+
// cover to obj
|
|
280
|
+
const data = ((_a = metaDatas[meta]) !== null && _a !== void 0 ? _a : []).sort((a, b) => a.index - b.index);
|
|
281
|
+
const validData = (_b = validMetaDatas[meta]) !== null && _b !== void 0 ? _b : [];
|
|
282
|
+
data.forEach((v) => {
|
|
283
|
+
var _a;
|
|
284
|
+
validData.forEach((it) => {
|
|
285
|
+
if (v.index === it.index && it.name === v.name) {
|
|
286
|
+
v.validRule = it.rule;
|
|
287
|
+
v.validOpt = it.options;
|
|
292
288
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
289
|
+
});
|
|
290
|
+
if (v.type) {
|
|
291
|
+
v.type = v.isDto ? v.type : (v.type).toLowerCase();
|
|
292
|
+
}
|
|
293
|
+
v.dtoCheck = !!(((_a = validatedMetaDatas[meta]) === null || _a === void 0 ? void 0 : _a.dtoCheck));
|
|
294
|
+
if (v.isDto) {
|
|
295
|
+
v.clazz = IOCContainer.getClass(v.type, "COMPONENT");
|
|
296
|
+
if (!v.clazz) {
|
|
297
|
+
throw Error(`Failed to obtain the class ${v.type},
|
|
298
298
|
because the class is not registered in the container.`);
|
|
299
|
-
}
|
|
300
|
-
if (v.dtoCheck) {
|
|
301
|
-
v.dtoRule = getOriginMetadata(PARAM_TYPE_KEY, v.clazz);
|
|
302
|
-
Reflect.defineProperty(v.clazz.prototype, "_typeDef", {
|
|
303
|
-
enumerable: true,
|
|
304
|
-
configurable: false,
|
|
305
|
-
writable: false,
|
|
306
|
-
value: v.dtoRule,
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
299
|
}
|
|
310
|
-
v.
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
300
|
+
if (v.dtoCheck) {
|
|
301
|
+
v.dtoRule = getOriginMetadata(PARAM_TYPE_KEY, v.clazz);
|
|
302
|
+
Reflect.defineProperty(v.clazz.prototype, "_typeDef", {
|
|
303
|
+
enumerable: true,
|
|
304
|
+
configurable: false,
|
|
305
|
+
writable: false,
|
|
306
|
+
value: v.dtoRule,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
v.options = options;
|
|
311
|
+
});
|
|
312
|
+
argsMetaObj[meta] = data;
|
|
313
|
+
// }
|
|
314
314
|
}
|
|
315
315
|
return argsMetaObj;
|
|
316
316
|
}
|
|
@@ -691,7 +691,7 @@ async function parseXml(ctx, opts) {
|
|
|
691
691
|
* @Usage:
|
|
692
692
|
* @Author: richen
|
|
693
693
|
* @Date: 2021-06-29 14:10:30
|
|
694
|
-
* @LastEditTime: 2024-01-16
|
|
694
|
+
* @LastEditTime: 2024-01-16 22:49:46
|
|
695
695
|
*/
|
|
696
696
|
class GrpcRouter {
|
|
697
697
|
constructor(app, options) {
|
package/dist/package.json
CHANGED
package/package.json
CHANGED