@midwayjs/core 3.10.6 → 3.10.7

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,18 +1,18 @@
1
1
  import { IMidwayContext, PipeUnionTransform } from '../../interface';
2
2
  export declare enum RouteParamTypes {
3
- QUERY = 0,
4
- BODY = 1,
5
- PARAM = 2,
6
- HEADERS = 3,
7
- SESSION = 4,
8
- FILESTREAM = 5,
9
- FILESSTREAM = 6,
10
- NEXT = 7,
11
- REQUEST_PATH = 8,
12
- REQUEST_IP = 9,
13
- QUERIES = 10,
14
- FIELDS = 11,
15
- CUSTOM = 12
3
+ QUERY = "query",
4
+ BODY = "body",
5
+ PARAM = "param",
6
+ HEADERS = "headers",
7
+ SESSION = "session",
8
+ FILESTREAM = "file_stream",
9
+ FILESSTREAM = "files_stream",
10
+ NEXT = "next",
11
+ REQUEST_PATH = "request_path",
12
+ REQUEST_IP = "request_ip",
13
+ QUERIES = "queries",
14
+ FIELDS = "fields",
15
+ CUSTOM = "custom"
16
16
  }
17
17
  export interface RouterParamValue {
18
18
  index: number;
@@ -23,15 +23,15 @@ export declare type KoaLikeCustomParamDecorator<T = unknown> = (ctx: IMidwayCont
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
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
- export declare const RequestPath: () => ParameterDecorator;
34
- export declare const RequestIP: () => ParameterDecorator;
35
- export declare const Queries: (property?: string, pipes?: PipeUnionTransform[]) => ParameterDecorator;
36
- export declare const Fields: (property?: string, pipes?: PipeUnionTransform[]) => ParameterDecorator;
26
+ export declare const Session: (propertyOrPipes?: string | PipeUnionTransform[], pipes?: PipeUnionTransform[]) => ParameterDecorator;
27
+ export declare const Body: (propertyOrPipes?: string | PipeUnionTransform[], pipes?: PipeUnionTransform[]) => ParameterDecorator;
28
+ export declare const Query: (propertyOrPipes?: string | PipeUnionTransform[], pipes?: PipeUnionTransform[]) => ParameterDecorator;
29
+ export declare const Param: (propertyOrPipes?: string | PipeUnionTransform[], pipes?: PipeUnionTransform[]) => ParameterDecorator;
30
+ export declare const Headers: (propertyOrPipes?: string | PipeUnionTransform[], pipes?: PipeUnionTransform[]) => ParameterDecorator;
31
+ export declare const File: (propertyOrPipes?: any, pipes?: PipeUnionTransform[]) => ParameterDecorator;
32
+ export declare const Files: (propertyOrPipes?: any, pipes?: PipeUnionTransform[]) => ParameterDecorator;
33
+ export declare const RequestPath: (pipes?: PipeUnionTransform[]) => ParameterDecorator;
34
+ export declare const RequestIP: (pipes?: PipeUnionTransform[]) => ParameterDecorator;
35
+ export declare const Queries: (propertyOrPipes?: string | PipeUnionTransform[], pipes?: PipeUnionTransform[]) => ParameterDecorator;
36
+ export declare const Fields: (propertyOrPipes?: string | PipeUnionTransform[], pipes?: PipeUnionTransform[]) => ParameterDecorator;
37
37
  //# sourceMappingURL=paramMapping.d.ts.map
@@ -4,22 +4,27 @@ exports.Fields = exports.Queries = exports.RequestIP = exports.RequestPath = exp
4
4
  const __1 = require("../");
5
5
  var RouteParamTypes;
6
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[RouteParamTypes["CUSTOM"] = 12] = "CUSTOM";
7
+ RouteParamTypes["QUERY"] = "query";
8
+ RouteParamTypes["BODY"] = "body";
9
+ RouteParamTypes["PARAM"] = "param";
10
+ RouteParamTypes["HEADERS"] = "headers";
11
+ RouteParamTypes["SESSION"] = "session";
12
+ RouteParamTypes["FILESTREAM"] = "file_stream";
13
+ RouteParamTypes["FILESSTREAM"] = "files_stream";
14
+ RouteParamTypes["NEXT"] = "next";
15
+ RouteParamTypes["REQUEST_PATH"] = "request_path";
16
+ RouteParamTypes["REQUEST_IP"] = "request_ip";
17
+ RouteParamTypes["QUERIES"] = "queries";
18
+ RouteParamTypes["FIELDS"] = "fields";
19
+ RouteParamTypes["CUSTOM"] = "custom";
20
20
  })(RouteParamTypes = exports.RouteParamTypes || (exports.RouteParamTypes = {}));
21
21
  const createParamMapping = function (type) {
22
- return (propertyData, pipes) => {
22
+ return (propertyOrPipes, pipes) => {
23
+ let propertyData = propertyOrPipes;
24
+ if (Array.isArray(propertyOrPipes) && pipes === undefined) {
25
+ pipes = propertyOrPipes;
26
+ propertyData = undefined;
27
+ }
23
28
  return (0, __1.createCustomParamDecorator)(__1.WEB_ROUTER_PARAM_KEY, {
24
29
  type,
25
30
  propertyData,
@@ -32,26 +37,26 @@ const createRequestParamDecorator = function (transform, pipes) {
32
37
  return createParamMapping(RouteParamTypes.CUSTOM)(transform, pipes);
33
38
  };
34
39
  exports.createRequestParamDecorator = createRequestParamDecorator;
35
- const Session = (property, pipes) => createParamMapping(RouteParamTypes.SESSION)(property, pipes);
40
+ const Session = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.SESSION)(propertyOrPipes, pipes);
36
41
  exports.Session = Session;
37
- const Body = (property, pipes) => createParamMapping(RouteParamTypes.BODY)(property, pipes);
42
+ const Body = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.BODY)(propertyOrPipes, pipes);
38
43
  exports.Body = Body;
39
- const Query = (property, pipes) => createParamMapping(RouteParamTypes.QUERY)(property, pipes);
44
+ const Query = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.QUERY)(propertyOrPipes, pipes);
40
45
  exports.Query = Query;
41
- const Param = (property, pipes) => createParamMapping(RouteParamTypes.PARAM)(property, pipes);
46
+ const Param = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.PARAM)(propertyOrPipes, pipes);
42
47
  exports.Param = Param;
43
- const Headers = (property, pipes) => createParamMapping(RouteParamTypes.HEADERS)(property, pipes);
48
+ const Headers = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.HEADERS)(propertyOrPipes, pipes);
44
49
  exports.Headers = Headers;
45
- const File = (property, pipes) => createParamMapping(RouteParamTypes.FILESTREAM)(property, pipes);
50
+ const File = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.FILESTREAM)(propertyOrPipes, pipes);
46
51
  exports.File = File;
47
- const Files = (property, pipes) => createParamMapping(RouteParamTypes.FILESSTREAM)(property, pipes);
52
+ const Files = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.FILESSTREAM)(propertyOrPipes, pipes);
48
53
  exports.Files = Files;
49
- const RequestPath = () => createParamMapping(RouteParamTypes.REQUEST_PATH)();
54
+ const RequestPath = (pipes) => createParamMapping(RouteParamTypes.REQUEST_PATH)(undefined, pipes);
50
55
  exports.RequestPath = RequestPath;
51
- const RequestIP = () => createParamMapping(RouteParamTypes.REQUEST_IP)();
56
+ const RequestIP = (pipes) => createParamMapping(RouteParamTypes.REQUEST_IP)(undefined, pipes);
52
57
  exports.RequestIP = RequestIP;
53
- const Queries = (property, pipes) => createParamMapping(RouteParamTypes.QUERIES)(property, pipes);
58
+ const Queries = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.QUERIES)(propertyOrPipes, pipes);
54
59
  exports.Queries = Queries;
55
- const Fields = (property, pipes) => createParamMapping(RouteParamTypes.FIELDS)(property, pipes);
60
+ const Fields = (propertyOrPipes, pipes) => createParamMapping(RouteParamTypes.FIELDS)(propertyOrPipes, pipes);
56
61
  exports.Fields = Fields;
57
62
  //# sourceMappingURL=paramMapping.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.10.6",
3
+ "version": "3.10.7",
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": "9d5babd57efe4c24415fcb3511bc4ca7c1bcb1b2"
45
+ "gitHead": "63bb5a11574dc6cae158c5de51fa5c5d5d482545"
46
46
  }