@midwayjs/core 3.10.6 → 3.10.9

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
@@ -52,7 +52,7 @@ let MidwayServerlessFunctionService = class MidwayServerlessFunctionService exte
52
52
  }
53
53
  }
54
54
  collectFunctionRoute(module) {
55
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
55
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
56
56
  // serverlessTrigger metadata
57
57
  const webRouterInfo = (0, decorator_1.getClassMetadata)(decorator_1.FUNC_KEY, module);
58
58
  const controllerId = (0, decorator_1.getProviderName)(module);
@@ -93,19 +93,19 @@ let MidwayServerlessFunctionService = class MidwayServerlessFunctionService exte
93
93
  responseMetadata: routerResponseData,
94
94
  };
95
95
  const functionMeta = (0, decorator_1.getPropertyMetadata)(decorator_1.SERVERLESS_FUNC_KEY, module, webRouter['methodName']) || {};
96
- const functionName = (_f = (_e = functionMeta['functionName']) !== null && _e !== void 0 ? _e : webRouter['functionName']) !== null && _f !== void 0 ? _f : createFunctionName(module, webRouter['methodName']);
96
+ const functionName = (_g = (_e = functionMeta['functionName']) !== null && _e !== void 0 ? _e : (_f = webRouter === null || webRouter === void 0 ? void 0 : webRouter['metadata']) === null || _f === void 0 ? void 0 : _f['functionName']) !== null && _g !== void 0 ? _g : createFunctionName(module, webRouter['methodName']);
97
97
  data.functionName = functionName;
98
98
  data.functionTriggerName = webRouter['type'];
99
99
  data.functionTriggerMetadata = webRouter['metadata'];
100
100
  data.functionMetadata = {
101
- ...functionMeta,
102
101
  functionName,
102
+ ...functionMeta,
103
103
  };
104
104
  this.checkDuplicateAndPush(prefix, data);
105
105
  }
106
106
  else {
107
107
  const functionMeta = (0, decorator_1.getPropertyMetadata)(decorator_1.SERVERLESS_FUNC_KEY, module, webRouter['methodName']) || {};
108
- const functionName = (_h = (_g = functionMeta['functionName']) !== null && _g !== void 0 ? _g : webRouter['functionName']) !== null && _h !== void 0 ? _h : createFunctionName(module, webRouter['methodName']);
108
+ const functionName = (_j = (_h = functionMeta['functionName']) !== null && _h !== void 0 ? _h : webRouter['functionName']) !== null && _j !== void 0 ? _j : createFunctionName(module, webRouter['methodName']);
109
109
  // 其他类型的函数
110
110
  this.checkDuplicateAndPush(prefix, {
111
111
  id,
@@ -119,7 +119,7 @@ let MidwayServerlessFunctionService = class MidwayServerlessFunctionService exte
119
119
  handlerName: `${controllerId}.${webRouter['methodName']}`,
120
120
  funcHandlerName: `${controllerId}.${webRouter['methodName']}`,
121
121
  controllerId,
122
- middleware: ((_j = webRouter['metadata']) === null || _j === void 0 ? void 0 : _j['middleware']) || [],
122
+ middleware: ((_k = webRouter['metadata']) === null || _k === void 0 ? void 0 : _k['middleware']) || [],
123
123
  controllerMiddleware: [],
124
124
  requestMetadata: [],
125
125
  responseMetadata: [],
@@ -11,11 +11,11 @@ interface IOptions {
11
11
  data?: any;
12
12
  timeout?: number;
13
13
  }
14
- export interface IResponse extends http.IncomingMessage {
14
+ export interface IResponse<ResType = any> extends http.IncomingMessage {
15
15
  status: number;
16
- data: Buffer | string | any;
16
+ data: Buffer | string | ResType;
17
17
  }
18
- export declare function makeHttpRequest(url: string, options?: IOptions): Promise<IResponse>;
18
+ export declare function makeHttpRequest<ResType>(url: string, options?: IOptions): Promise<IResponse<ResType>>;
19
19
  /**
20
20
  * A simple http client
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.10.6",
3
+ "version": "3.10.9",
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": "4c8368283bd5ff3c14c23080838e2567c3e9a749"
46
46
  }