egg 4.1.0-beta.35 → 4.1.0-beta.36

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 (101) hide show
  1. package/dist/agent.d.ts +7 -3
  2. package/dist/agent.js +10 -6
  3. package/dist/ajv.d.ts +1 -1
  4. package/dist/ajv.js +3 -2
  5. package/dist/aop.d.ts +1 -1
  6. package/dist/aop.js +3 -2
  7. package/dist/app/extend/context.d.ts +181 -178
  8. package/dist/app/extend/context.js +244 -259
  9. package/dist/app/extend/helper.d.ts +40 -35
  10. package/dist/app/extend/helper.js +45 -41
  11. package/dist/app/extend/request.d.ts +135 -131
  12. package/dist/app/extend/request.js +219 -258
  13. package/dist/app/extend/response.d.ts +28 -24
  14. package/dist/app/extend/response.js +36 -34
  15. package/dist/app/middleware/body_parser.d.ts +2 -2
  16. package/dist/app/middleware/body_parser.js +7 -3
  17. package/dist/app/middleware/meta.d.ts +8 -8
  18. package/dist/app/middleware/meta.js +15 -18
  19. package/dist/app/middleware/notfound.d.ts +8 -5
  20. package/dist/app/middleware/notfound.js +25 -28
  21. package/dist/app/middleware/override_method.d.ts +2 -2
  22. package/dist/app/middleware/override_method.js +7 -3
  23. package/dist/app/middleware/site_file.d.ts +11 -7
  24. package/dist/app/middleware/site_file.js +37 -52
  25. package/dist/config/config.default.d.ts +11 -6
  26. package/dist/config/config.default.js +258 -375
  27. package/dist/config/config.local.d.ts +6 -3
  28. package/dist/config/config.local.js +7 -8
  29. package/dist/config/config.unittest.d.ts +6 -3
  30. package/dist/config/config.unittest.js +10 -8
  31. package/dist/config/plugin.d.ts +6 -2
  32. package/dist/config/plugin.js +67 -131
  33. package/dist/dal.d.ts +1 -1
  34. package/dist/dal.js +3 -2
  35. package/dist/errors.d.ts +1 -1
  36. package/dist/errors.js +3 -2
  37. package/dist/helper.d.ts +1 -1
  38. package/dist/helper.js +3 -2
  39. package/dist/index.d.ts +24 -106
  40. package/dist/index.js +23 -89
  41. package/dist/lib/agent.d.ts +21 -15
  42. package/dist/lib/agent.js +53 -45
  43. package/dist/lib/application.d.ts +60 -54
  44. package/dist/lib/application.js +199 -249
  45. package/dist/lib/core/base_context_class.d.ts +23 -17
  46. package/dist/lib/core/base_context_class.js +17 -15
  47. package/dist/lib/core/base_context_logger.d.ts +39 -35
  48. package/dist/lib/core/base_context_logger.js +58 -60
  49. package/dist/lib/core/base_hook_class.d.ts +18 -11
  50. package/dist/lib/core/base_hook_class.js +26 -22
  51. package/dist/lib/core/context_httpclient.d.ts +21 -16
  52. package/dist/lib/core/context_httpclient.js +29 -26
  53. package/dist/lib/core/httpclient.d.ts +14 -12
  54. package/dist/lib/core/httpclient.js +34 -37
  55. package/dist/lib/core/logger.d.ts +7 -3
  56. package/dist/lib/core/logger.js +30 -36
  57. package/dist/lib/core/messenger/IMessenger.d.ts +53 -49
  58. package/dist/lib/core/messenger/IMessenger.js +1 -2
  59. package/dist/lib/core/messenger/base.d.ts +11 -7
  60. package/dist/lib/core/messenger/base.js +30 -29
  61. package/dist/lib/core/messenger/index.d.ts +10 -6
  62. package/dist/lib/core/messenger/index.js +11 -8
  63. package/dist/lib/core/messenger/ipc.d.ts +62 -57
  64. package/dist/lib/core/messenger/ipc.js +126 -138
  65. package/dist/lib/core/messenger/local.d.ts +63 -58
  66. package/dist/lib/core/messenger/local.js +126 -131
  67. package/dist/lib/core/utils.d.ts +5 -2
  68. package/dist/lib/core/utils.js +44 -66
  69. package/dist/lib/define.d.ts +72 -67
  70. package/dist/lib/define.js +54 -53
  71. package/dist/lib/egg.d.ts +283 -281
  72. package/dist/lib/egg.js +512 -573
  73. package/dist/lib/error/CookieLimitExceedError.d.ts +7 -4
  74. package/dist/lib/error/CookieLimitExceedError.js +15 -12
  75. package/dist/lib/error/MessageUnhandledRejectionError.d.ts +7 -4
  76. package/dist/lib/error/MessageUnhandledRejectionError.js +15 -12
  77. package/dist/lib/error/index.d.ts +3 -2
  78. package/dist/lib/error/index.js +4 -3
  79. package/dist/lib/loader/AgentWorkerLoader.d.ts +15 -10
  80. package/dist/lib/loader/AgentWorkerLoader.js +22 -18
  81. package/dist/lib/loader/AppWorkerLoader.d.ts +20 -15
  82. package/dist/lib/loader/AppWorkerLoader.js +35 -37
  83. package/dist/lib/loader/EggApplicationLoader.d.ts +7 -3
  84. package/dist/lib/loader/EggApplicationLoader.js +7 -4
  85. package/dist/lib/loader/index.d.ts +4 -3
  86. package/dist/lib/loader/index.js +5 -4
  87. package/dist/lib/start.d.ts +24 -20
  88. package/dist/lib/start.js +32 -42
  89. package/dist/lib/types.d.ts +288 -286
  90. package/dist/lib/types.js +2 -2
  91. package/dist/lib/types.plugin.d.ts +21 -21
  92. package/dist/lib/types.plugin.js +23 -24
  93. package/dist/orm.d.ts +1 -1
  94. package/dist/orm.js +3 -2
  95. package/dist/schedule.d.ts +2 -2
  96. package/dist/schedule.js +5 -5
  97. package/dist/transaction.d.ts +1 -1
  98. package/dist/transaction.js +3 -2
  99. package/dist/urllib.d.ts +1 -1
  100. package/dist/urllib.js +3 -2
  101. package/package.json +60 -64
package/dist/agent.d.ts CHANGED
@@ -1,4 +1,8 @@
1
- import { BaseHookClass } from './lib/core/base_hook_class.ts';
2
- export default class EggAgentHook extends BaseHookClass {
3
- configDidLoad(): void;
1
+ import { BaseHookClass } from "./lib/core/base_hook_class.js";
2
+
3
+ //#region src/agent.d.ts
4
+ declare class EggAgentHook extends BaseHookClass {
5
+ configDidLoad(): void;
4
6
  }
7
+ //#endregion
8
+ export { EggAgentHook as default };
package/dist/agent.js CHANGED
@@ -1,7 +1,11 @@
1
1
  import { BaseHookClass } from "./lib/core/base_hook_class.js";
2
- export default class EggAgentHook extends BaseHookClass {
3
- configDidLoad() {
4
- this.agent._wrapMessenger();
5
- }
6
- }
7
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWdlbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvYWdlbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRTlELE1BQU0sQ0FBQyxPQUFPLE9BQU8sWUFBYSxTQUFRLGFBQWE7SUFDckQsYUFBYTtRQUNYLElBQUksQ0FBQyxLQUFLLENBQUMsY0FBYyxFQUFFLENBQUM7SUFDOUIsQ0FBQztDQUNGIn0=
2
+
3
+ //#region src/agent.ts
4
+ var EggAgentHook = class extends BaseHookClass {
5
+ configDidLoad() {
6
+ this.agent._wrapMessenger();
7
+ }
8
+ };
9
+
10
+ //#endregion
11
+ export { EggAgentHook as default };
package/dist/ajv.d.ts CHANGED
@@ -1 +1 @@
1
- export * from '@eggjs/tegg/ajv';
1
+ export * from "@eggjs/tegg/ajv";
package/dist/ajv.js CHANGED
@@ -1,2 +1,3 @@
1
- export * from '@eggjs/tegg/ajv';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWp2LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2Fqdi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGlCQUFpQixDQUFDIn0=
1
+ export * from "@eggjs/tegg/ajv"
2
+
3
+ export { };
package/dist/aop.d.ts CHANGED
@@ -1 +1 @@
1
- export * from '@eggjs/tegg/aop';
1
+ export * from "@eggjs/tegg/aop";
package/dist/aop.js CHANGED
@@ -1,2 +1,3 @@
1
- export * from '@eggjs/tegg/aop';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW9wLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2FvcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGlCQUFpQixDQUFDIn0=
1
+ export * from "@eggjs/tegg/aop"
2
+
3
+ export { };
@@ -1,180 +1,183 @@
1
- import type { Cookies as ContextCookies } from '@eggjs/cookies';
2
- import { Context as EggCoreContext, Router } from '@eggjs/core';
3
- import type { EggLogger } from 'egg-logger';
4
- import type { Application } from '../../lib/application.ts';
5
- import type { HttpClientRequestURL, HttpClientRequestOptions, HttpClient } from '../../lib/core/httpclient.ts';
6
- import type { IService } from '../../lib/types.ts';
7
- import type Helper from './helper.ts';
8
- import type Request from './request.ts';
9
- import type Response from './response.ts';
10
- interface Cookies extends ContextCookies {
11
- request: any;
12
- response: any;
1
+ import { EggContextHttpClient as HttpClient, HttpClientRequestOptions, HttpClientRequestURL } from "../../lib/core/httpclient.js";
2
+ import { IService } from "../../lib/types.js";
3
+ import Response$1 from "./response.js";
4
+ import Request$1 from "./request.js";
5
+ import { Application } from "../../lib/application.js";
6
+ import Helper from "./helper.js";
7
+ import { Context as Context$1, Router } from "@eggjs/core";
8
+ import { Cookies } from "@eggjs/cookies";
9
+ import { EggLogger } from "egg-logger";
10
+
11
+ //#region src/app/extend/context.d.ts
12
+ interface Cookies$1 extends Cookies {
13
+ request: any;
14
+ response: any;
13
15
  }
14
- export default class Context extends EggCoreContext {
15
- app: Application;
16
- request: Request;
17
- response: Response;
18
- service: IService;
19
- proxy: any;
20
- /**
21
- * Request start time
22
- * @member {Number} Context#starttime
23
- */
24
- starttime: number;
25
- /**
26
- * Request start timer using `performance.now()`
27
- * @member {Number} Context#performanceStarttime
28
- */
29
- performanceStarttime: number;
30
- /**
31
- * Get the current visitor's cookies.
32
- */
33
- get cookies(): Cookies;
34
- /**
35
- * Get a wrapper httpclient instance contain ctx in the hold request process
36
- *
37
- * @return {HttpClient} the wrapper httpclient instance
38
- */
39
- get httpclient(): HttpClient;
40
- /**
41
- * Alias to {@link Context#httpclient}
42
- */
43
- get httpClient(): HttpClient;
44
- /**
45
- * Shortcut for httpclient.curl
46
- *
47
- * @function Context#curl
48
- * @param {String|Object} url - request url address.
49
- * @param {Object} [options] - options for request.
50
- * @return {Object} see {@link ContextHttpClient#curl}
51
- */
52
- curl(url: HttpClientRequestURL, options?: HttpClientRequestOptions): ReturnType<HttpClient['request']>;
53
- /**
54
- * Alias to {@link Application#router}
55
- *
56
- * @member {Router} Context#router
57
- * @since 1.0.0
58
- * @example
59
- * ```js
60
- * this.router.pathFor('post', { id: 12 });
61
- * ```
62
- */
63
- get router(): Router;
64
- /**
65
- * Set router to Context, only use on EggRouter
66
- * @param {Router} val router instance
67
- */
68
- set router(val: Router);
69
- /**
70
- * Get helper instance from {@link Application#Helper}
71
- *
72
- * @member {Helper} Context#helper
73
- * @since 1.0.0
74
- */
75
- get helper(): Helper;
76
- /**
77
- * Wrap app.loggers with context information,
78
- * if a custom logger is defined by naming aLogger, then you can `ctx.getLogger('aLogger')`
79
- *
80
- * @param {String} name - logger name
81
- */
82
- getLogger(name: string): EggLogger;
83
- /**
84
- * Logger for Application
85
- *
86
- * @member {Logger} Context#logger
87
- * @since 1.0.0
88
- * @example
89
- * ```js
90
- * this.logger.info('some request data: %j', this.request.body);
91
- * this.logger.warn('WARNING!!!!');
92
- * ```
93
- */
94
- get logger(): EggLogger;
95
- /**
96
- * Logger for frameworks and plugins
97
- *
98
- * @member {Logger} Context#coreLogger
99
- * @since 1.0.0
100
- */
101
- get coreLogger(): EggLogger;
102
- /**
103
- * locals is an object for view, you can use `app.locals` and `ctx.locals` to set variables,
104
- * which will be used as data when view is rendering.
105
- * The difference between `app.locals` and `ctx.locals` is the context level, `app.locals` is global level, and `ctx.locals` is request level. when you get `ctx.locals`, it will merge `app.locals`.
106
- *
107
- * when you set locals, only object is available
108
- *
109
- * ```js
110
- * this.locals = {
111
- * a: 1
112
- * };
113
- * this.locals = {
114
- * b: 1
115
- * };
116
- * this.locals.c = 1;
117
- * console.log(this.locals);
118
- * {
119
- * a: 1,
120
- * b: 1,
121
- * c: 1,
122
- * };
123
- * ```
124
- *
125
- * `ctx.locals` has cache, it only merges `app.locals` once in one request.
126
- *
127
- * @member {Object} Context#locals
128
- */
129
- get locals(): Record<string, any>;
130
- set locals(val: Record<string, any>);
131
- /**
132
- * alias to {@link Context#locals}, compatible with koa that use this variable
133
- * @member {Object} state
134
- * @see Context#locals
135
- */
136
- get state(): Record<string, any>;
137
- set state(val: Record<string, any>);
138
- /**
139
- * Run async function in the background
140
- * @param {Function} scope - the first args is ctx
141
- * ```js
142
- * this.body = 'hi';
143
- *
144
- * this.runInBackground(async ctx => {
145
- * await ctx.mysql.query(sql);
146
- * await ctx.curl(url);
147
- * });
148
- * ```
149
- */
150
- runInBackground(scope: (ctx: Context) => Promise<void>, taskName?: string): void;
151
- _runInBackground(scope: (ctx: Context) => Promise<void>, taskName: string): Promise<void>;
152
- /**
153
- * @member {Boolean} Context#acceptJSON
154
- * @see Request#acceptJSON
155
- * @since 1.0.0
156
- */
157
- get acceptJSON(): boolean;
158
- get query(): Record<string, string>;
159
- /**
160
- * @member {Array} Context#queries
161
- * @see Request#queries
162
- * @since 1.0.0
163
- */
164
- get queries(): Record<string, string[]>;
165
- /**
166
- * @member {string} Context#ip
167
- * @see Request#ip
168
- * @since 1.0.0
169
- */
170
- get ip(): string;
171
- set ip(val: string);
172
- /**
173
- * @member {Number} Context#realStatus
174
- * @see Response#realStatus
175
- * @since 1.0.0
176
- */
177
- get realStatus(): number;
178
- set realStatus(val: number);
16
+ declare class Context extends Context$1 {
17
+ app: Application;
18
+ request: Request$1;
19
+ response: Response$1;
20
+ service: IService;
21
+ proxy: any;
22
+ /**
23
+ * Request start time
24
+ * @member {Number} Context#starttime
25
+ */
26
+ starttime: number;
27
+ /**
28
+ * Request start timer using `performance.now()`
29
+ * @member {Number} Context#performanceStarttime
30
+ */
31
+ performanceStarttime: number;
32
+ /**
33
+ * Get the current visitor's cookies.
34
+ */
35
+ get cookies(): Cookies$1;
36
+ /**
37
+ * Get a wrapper httpclient instance contain ctx in the hold request process
38
+ *
39
+ * @return {HttpClient} the wrapper httpclient instance
40
+ */
41
+ get httpclient(): HttpClient;
42
+ /**
43
+ * Alias to {@link Context#httpclient}
44
+ */
45
+ get httpClient(): HttpClient;
46
+ /**
47
+ * Shortcut for httpclient.curl
48
+ *
49
+ * @function Context#curl
50
+ * @param {String|Object} url - request url address.
51
+ * @param {Object} [options] - options for request.
52
+ * @return {Object} see {@link ContextHttpClient#curl}
53
+ */
54
+ curl(url: HttpClientRequestURL, options?: HttpClientRequestOptions): ReturnType<HttpClient["request"]>;
55
+ /**
56
+ * Alias to {@link Application#router}
57
+ *
58
+ * @member {Router} Context#router
59
+ * @since 1.0.0
60
+ * @example
61
+ * ```js
62
+ * this.router.pathFor('post', { id: 12 });
63
+ * ```
64
+ */
65
+ get router(): Router;
66
+ /**
67
+ * Set router to Context, only use on EggRouter
68
+ * @param {Router} val router instance
69
+ */
70
+ set router(val: Router);
71
+ /**
72
+ * Get helper instance from {@link Application#Helper}
73
+ *
74
+ * @member {Helper} Context#helper
75
+ * @since 1.0.0
76
+ */
77
+ get helper(): Helper;
78
+ /**
79
+ * Wrap app.loggers with context information,
80
+ * if a custom logger is defined by naming aLogger, then you can `ctx.getLogger('aLogger')`
81
+ *
82
+ * @param {String} name - logger name
83
+ */
84
+ getLogger(name: string): EggLogger;
85
+ /**
86
+ * Logger for Application
87
+ *
88
+ * @member {Logger} Context#logger
89
+ * @since 1.0.0
90
+ * @example
91
+ * ```js
92
+ * this.logger.info('some request data: %j', this.request.body);
93
+ * this.logger.warn('WARNING!!!!');
94
+ * ```
95
+ */
96
+ get logger(): EggLogger;
97
+ /**
98
+ * Logger for frameworks and plugins
99
+ *
100
+ * @member {Logger} Context#coreLogger
101
+ * @since 1.0.0
102
+ */
103
+ get coreLogger(): EggLogger;
104
+ /**
105
+ * locals is an object for view, you can use `app.locals` and `ctx.locals` to set variables,
106
+ * which will be used as data when view is rendering.
107
+ * The difference between `app.locals` and `ctx.locals` is the context level, `app.locals` is global level, and `ctx.locals` is request level. when you get `ctx.locals`, it will merge `app.locals`.
108
+ *
109
+ * when you set locals, only object is available
110
+ *
111
+ * ```js
112
+ * this.locals = {
113
+ * a: 1
114
+ * };
115
+ * this.locals = {
116
+ * b: 1
117
+ * };
118
+ * this.locals.c = 1;
119
+ * console.log(this.locals);
120
+ * {
121
+ * a: 1,
122
+ * b: 1,
123
+ * c: 1,
124
+ * };
125
+ * ```
126
+ *
127
+ * `ctx.locals` has cache, it only merges `app.locals` once in one request.
128
+ *
129
+ * @member {Object} Context#locals
130
+ */
131
+ get locals(): Record<string, any>;
132
+ set locals(val: Record<string, any>);
133
+ /**
134
+ * alias to {@link Context#locals}, compatible with koa that use this variable
135
+ * @member {Object} state
136
+ * @see Context#locals
137
+ */
138
+ get state(): Record<string, any>;
139
+ set state(val: Record<string, any>);
140
+ /**
141
+ * Run async function in the background
142
+ * @param {Function} scope - the first args is ctx
143
+ * ```js
144
+ * this.body = 'hi';
145
+ *
146
+ * this.runInBackground(async ctx => {
147
+ * await ctx.mysql.query(sql);
148
+ * await ctx.curl(url);
149
+ * });
150
+ * ```
151
+ */
152
+ runInBackground(scope: (ctx: Context) => Promise<void>, taskName?: string): void;
153
+ _runInBackground(scope: (ctx: Context) => Promise<void>, taskName: string): Promise<void>;
154
+ /**
155
+ * @member {Boolean} Context#acceptJSON
156
+ * @see Request#acceptJSON
157
+ * @since 1.0.0
158
+ */
159
+ get acceptJSON(): boolean;
160
+ get query(): Record<string, string>;
161
+ /**
162
+ * @member {Array} Context#queries
163
+ * @see Request#queries
164
+ * @since 1.0.0
165
+ */
166
+ get queries(): Record<string, string[]>;
167
+ /**
168
+ * @member {string} Context#ip
169
+ * @see Request#ip
170
+ * @since 1.0.0
171
+ */
172
+ get ip(): string;
173
+ set ip(val: string);
174
+ /**
175
+ * @member {Number} Context#realStatus
176
+ * @see Response#realStatus
177
+ * @since 1.0.0
178
+ */
179
+ get realStatus(): number;
180
+ set realStatus(val: number);
179
181
  }
180
- export {};
182
+ //#endregion
183
+ export { Context as default };