@midwayjs/core 3.10.1 → 3.10.4
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMidwayContext } from '../../interface';
|
|
1
|
+
import { IMidwayContext, PipeUnionTransform } from '../../interface';
|
|
2
2
|
export declare enum RouteParamTypes {
|
|
3
3
|
QUERY = 0,
|
|
4
4
|
BODY = 1,
|
|
@@ -22,16 +22,16 @@ export interface RouterParamValue {
|
|
|
22
22
|
export declare type KoaLikeCustomParamDecorator<T = unknown> = (ctx: IMidwayContext) => T | Promise<T>;
|
|
23
23
|
export declare type ExpressLikeCustomParamDecorator<T = unknown> = (req: any, res: any) => T | Promise<T>;
|
|
24
24
|
export declare type CustomParamDecorator<T = unknown> = KoaLikeCustomParamDecorator<T> | ExpressLikeCustomParamDecorator<T>;
|
|
25
|
-
export declare const createRequestParamDecorator: (transform: CustomParamDecorator) => ParameterDecorator;
|
|
26
|
-
export declare const Session: (property?: string) => ParameterDecorator;
|
|
27
|
-
export declare const Body: (property?: string) => ParameterDecorator;
|
|
28
|
-
export declare const Query: (property?: string) => ParameterDecorator;
|
|
29
|
-
export declare const Param: (property?: string) => ParameterDecorator;
|
|
30
|
-
export declare const Headers: (property?: string) => ParameterDecorator;
|
|
31
|
-
export declare const File: (property?: any) => ParameterDecorator;
|
|
32
|
-
export declare const Files: (property?: any) => ParameterDecorator;
|
|
25
|
+
export declare const createRequestParamDecorator: (transform: CustomParamDecorator, pipes?: Array<PipeUnionTransform>) => ParameterDecorator;
|
|
26
|
+
export declare const Session: (property?: string, pipes?: PipeUnionTransform[]) => ParameterDecorator;
|
|
27
|
+
export declare const Body: (property?: string, pipes?: PipeUnionTransform[]) => ParameterDecorator;
|
|
28
|
+
export declare const Query: (property?: string, pipes?: PipeUnionTransform[]) => ParameterDecorator;
|
|
29
|
+
export declare const Param: (property?: string, pipes?: PipeUnionTransform[]) => ParameterDecorator;
|
|
30
|
+
export declare const Headers: (property?: string, pipes?: PipeUnionTransform[]) => ParameterDecorator;
|
|
31
|
+
export declare const File: (property?: any, pipes?: PipeUnionTransform[]) => ParameterDecorator;
|
|
32
|
+
export declare const Files: (property?: any, pipes?: PipeUnionTransform[]) => ParameterDecorator;
|
|
33
33
|
export declare const RequestPath: () => ParameterDecorator;
|
|
34
34
|
export declare const RequestIP: () => ParameterDecorator;
|
|
35
|
-
export declare const Queries: (property?: string) => ParameterDecorator;
|
|
36
|
-
export declare const Fields: (property?: string) => ParameterDecorator;
|
|
35
|
+
export declare const Queries: (property?: string, pipes?: PipeUnionTransform[]) => ParameterDecorator;
|
|
36
|
+
export declare const Fields: (property?: string, pipes?: PipeUnionTransform[]) => ParameterDecorator;
|
|
37
37
|
//# sourceMappingURL=paramMapping.d.ts.map
|
|
@@ -27,30 +27,30 @@ const createParamMapping = function (type) {
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
const createRequestParamDecorator = function (transform) {
|
|
31
|
-
return createParamMapping(RouteParamTypes.CUSTOM)(transform);
|
|
30
|
+
const createRequestParamDecorator = function (transform, pipes) {
|
|
31
|
+
return createParamMapping(RouteParamTypes.CUSTOM)(transform, pipes);
|
|
32
32
|
};
|
|
33
33
|
exports.createRequestParamDecorator = createRequestParamDecorator;
|
|
34
|
-
const Session = (property) => createParamMapping(RouteParamTypes.SESSION)(property);
|
|
34
|
+
const Session = (property, pipes) => createParamMapping(RouteParamTypes.SESSION)(property, pipes);
|
|
35
35
|
exports.Session = Session;
|
|
36
|
-
const Body = (property) => createParamMapping(RouteParamTypes.BODY)(property);
|
|
36
|
+
const Body = (property, pipes) => createParamMapping(RouteParamTypes.BODY)(property, pipes);
|
|
37
37
|
exports.Body = Body;
|
|
38
|
-
const Query = (property) => createParamMapping(RouteParamTypes.QUERY)(property);
|
|
38
|
+
const Query = (property, pipes) => createParamMapping(RouteParamTypes.QUERY)(property, pipes);
|
|
39
39
|
exports.Query = Query;
|
|
40
|
-
const Param = (property) => createParamMapping(RouteParamTypes.PARAM)(property);
|
|
40
|
+
const Param = (property, pipes) => createParamMapping(RouteParamTypes.PARAM)(property, pipes);
|
|
41
41
|
exports.Param = Param;
|
|
42
|
-
const Headers = (property) => createParamMapping(RouteParamTypes.HEADERS)(property);
|
|
42
|
+
const Headers = (property, pipes) => createParamMapping(RouteParamTypes.HEADERS)(property, pipes);
|
|
43
43
|
exports.Headers = Headers;
|
|
44
|
-
const File = (property) => createParamMapping(RouteParamTypes.FILESTREAM)(property);
|
|
44
|
+
const File = (property, pipes) => createParamMapping(RouteParamTypes.FILESTREAM)(property, pipes);
|
|
45
45
|
exports.File = File;
|
|
46
|
-
const Files = (property) => createParamMapping(RouteParamTypes.FILESSTREAM)(property);
|
|
46
|
+
const Files = (property, pipes) => createParamMapping(RouteParamTypes.FILESSTREAM)(property, pipes);
|
|
47
47
|
exports.Files = Files;
|
|
48
48
|
const RequestPath = () => createParamMapping(RouteParamTypes.REQUEST_PATH)();
|
|
49
49
|
exports.RequestPath = RequestPath;
|
|
50
50
|
const RequestIP = () => createParamMapping(RouteParamTypes.REQUEST_IP)();
|
|
51
51
|
exports.RequestIP = RequestIP;
|
|
52
|
-
const Queries = (property) => createParamMapping(RouteParamTypes.QUERIES)(property);
|
|
52
|
+
const Queries = (property, pipes) => createParamMapping(RouteParamTypes.QUERIES)(property, pipes);
|
|
53
53
|
exports.Queries = Queries;
|
|
54
|
-
const Fields = (property) => createParamMapping(RouteParamTypes.FIELDS)(property);
|
|
54
|
+
const Fields = (property, pipes) => createParamMapping(RouteParamTypes.FIELDS)(property, pipes);
|
|
55
55
|
exports.Fields = Fields;
|
|
56
56
|
//# sourceMappingURL=paramMapping.js.map
|
package/dist/interface.d.ts
CHANGED
|
@@ -283,9 +283,23 @@ export interface PipeTransform<T = unknown, R = unknown> {
|
|
|
283
283
|
}
|
|
284
284
|
export type PipeTransformFunction<T = any, R = any> = (value: T) => R;
|
|
285
285
|
export type PipeUnionTransform<T = any, R = any> = PipeTransform<T, R> | (new (...args: any[]) => PipeTransform<T, R>) | PipeTransformFunction<T, R>;
|
|
286
|
+
export interface MethodDecoratorMetaData<Metadata = any> {
|
|
287
|
+
propertyName: string;
|
|
288
|
+
/** decorator key */
|
|
289
|
+
key: string;
|
|
290
|
+
metadata: Metadata;
|
|
291
|
+
options: MethodDecoratorOptions | undefined;
|
|
292
|
+
}
|
|
286
293
|
export interface MethodDecoratorOptions {
|
|
287
294
|
impl?: boolean;
|
|
288
295
|
}
|
|
296
|
+
export interface ParameterDecoratorMetaData<Metadata = any> {
|
|
297
|
+
key: string;
|
|
298
|
+
parameterIndex: number;
|
|
299
|
+
propertyName: string;
|
|
300
|
+
metadata: Metadata;
|
|
301
|
+
options: ParamDecoratorOptions | undefined;
|
|
302
|
+
}
|
|
289
303
|
export interface ParamDecoratorOptions {
|
|
290
304
|
impl?: boolean;
|
|
291
305
|
throwError?: boolean;
|
|
@@ -34,7 +34,7 @@ let MidwayDecoratorService = class MidwayDecoratorService {
|
|
|
34
34
|
// loop it, save this order for decorator run
|
|
35
35
|
for (const meta of methodDecoratorMetadataList) {
|
|
36
36
|
const { propertyName, key, metadata, options } = meta;
|
|
37
|
-
if (!options.impl) {
|
|
37
|
+
if (!options || !options.impl) {
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
40
|
// add aspect implementation first
|
|
@@ -65,7 +65,7 @@ let MidwayDecoratorService = class MidwayDecoratorService {
|
|
|
65
65
|
for (const meta of parameterDecoratorMetadata[methodName]) {
|
|
66
66
|
const { propertyName, key, metadata, parameterIndex, options, } = meta;
|
|
67
67
|
let parameterDecoratorHandler;
|
|
68
|
-
if (options.impl) {
|
|
68
|
+
if (options && options.impl) {
|
|
69
69
|
parameterDecoratorHandler =
|
|
70
70
|
this.parameterDecoratorMap.get(key);
|
|
71
71
|
if (!parameterDecoratorHandler) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/core",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.4",
|
|
4
4
|
"description": "midway core",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=12"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "fb3b02bfe884e3477f81d34fc9941f2701e826f3"
|
|
46
46
|
}
|