egg 3.13.0 → 3.14.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.
Files changed (2) hide show
  1. package/index.d.ts +23 -8
  2. package/package.json +3 -3
package/index.d.ts CHANGED
@@ -14,10 +14,14 @@ import {
14
14
  EggLoggerOptions,
15
15
  EggContextLogger,
16
16
  } from 'egg-logger';
17
- import { RequestOptions2 as RequestOptions, HttpClientResponse } from 'urllib';
18
17
  import {
19
- RequestURL, RequestOptions as RequestOptionsNext,
20
- HttpClientResponse as HttpClientResponseNext,
18
+ RequestOptions2 as RequestOptionsOld,
19
+ HttpClientResponse as HttpClientResponseOld,
20
+ } from 'urllib';
21
+ import {
22
+ RequestURL as HttpClientRequestURL,
23
+ RequestOptions as HttpClientRequestOptions,
24
+ HttpClientResponse,
21
25
  } from 'urllib-next';
22
26
  import {
23
27
  EggCoreBase,
@@ -49,13 +53,24 @@ declare module 'egg' {
49
53
  // Remove specific property from the specific class
50
54
  type RemoveSpecProp<T, P> = Pick<T, Exclude<keyof T, P>>;
51
55
 
56
+ // Usage:
57
+ // ```ts
58
+ // import { HttpClientRequestURL, HttpClientRequestOptions, HttpClientResponse } from 'egg';
59
+ // async function request(url: HttpClientRequestURL, options: HttpClientRequestOptions): Promise<HttpClientResponse> {
60
+ // return await app.httpclient.request(url, options);
61
+ // }
62
+ // ```
63
+ export { HttpClientRequestURL, HttpClientRequestOptions, HttpClientResponse };
52
64
  // Compatible with both urllib@2 and urllib@3 RequestOptions to request
53
65
  export interface EggHttpClient extends EventEmitter {
54
- request<T = any>(url: RequestURL): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
55
- request<T = any>(url: RequestURL, options: RequestOptions | RequestOptionsNext): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
56
- curl<T = any>(url: RequestURL): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
57
- curl<T = any>(url: RequestURL, options: RequestOptions | RequestOptionsNext): Promise<HttpClientResponse<T> | HttpClientResponseNext>;
66
+ request<T = any>(url: HttpClientRequestURL): Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
67
+ request<T = any>(url: HttpClientRequestURL, options: RequestOptionsOld | HttpClientRequestOptions):
68
+ Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
69
+ curl<T = any>(url: HttpClientRequestURL): Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
70
+ curl<T = any>(url: HttpClientRequestURL, options: RequestOptionsOld | HttpClientRequestOptions):
71
+ Promise<HttpClientResponseOld<T> | HttpClientResponse<T>>;
58
72
  }
73
+
59
74
  interface EggHttpConstructor {
60
75
  new(app: Application): EggHttpClient;
61
76
  }
@@ -278,7 +293,7 @@ declare module 'egg' {
278
293
  /** https.Agent */
279
294
  httpsAgent?: HttpClientBaseConfig;
280
295
  /** Default request args for httpclient */
281
- request?: RequestOptions;
296
+ request?: HttpClientRequestOptions | RequestOptionsOld;
282
297
  /** Whether enable dns cache */
283
298
  enableDNSCache?: boolean;
284
299
  /** Enable proxy request, default is false. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "3.13.0",
3
+ "version": "3.14.1",
4
4
  "publishConfig": {
5
5
  "tag": "latest"
6
6
  },
@@ -69,9 +69,9 @@
69
69
  "dumi": "^1.1.47",
70
70
  "dumi-theme-egg": "^1.2.2",
71
71
  "egg-bin": "^5",
72
- "egg-mock": "^5.4.0",
72
+ "egg-mock": "^5.9.2",
73
73
  "egg-plugin-puml": "^2.4.0",
74
- "egg-tracer": "^1.1.0",
74
+ "egg-tracer": "^2.0.0",
75
75
  "egg-view-nunjucks": "^2.3.0",
76
76
  "eslint": "^8.23.1",
77
77
  "eslint-config-egg": "^12.0.0",