phecda-server 5.0.0-beta.19 → 5.0.0-beta.21

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 (36) hide show
  1. package/dist/{chunk-WNTTAFLC.js → chunk-562XCEUU.js} +9 -11
  2. package/dist/{chunk-PXI5J4LR.mjs → chunk-AL36AJMH.mjs} +8 -10
  3. package/dist/{chunk-VBYDVWRK.js → chunk-FMPVMJLE.js} +38 -32
  4. package/dist/{chunk-LSMNOIFA.mjs → chunk-TCW7B6MG.mjs} +39 -33
  5. package/dist/core-895ed04d.d.ts +112 -0
  6. package/dist/index.d.ts +39 -15
  7. package/dist/index.js +27 -24
  8. package/dist/index.mjs +8 -5
  9. package/dist/rpc/kafka/index.d.ts +2 -2
  10. package/dist/rpc/kafka/index.js +9 -6
  11. package/dist/rpc/kafka/index.mjs +6 -3
  12. package/dist/rpc/rabbitmq/index.d.ts +2 -2
  13. package/dist/rpc/rabbitmq/index.js +9 -6
  14. package/dist/rpc/rabbitmq/index.mjs +6 -3
  15. package/dist/rpc/redis/index.d.ts +2 -2
  16. package/dist/rpc/redis/index.js +9 -6
  17. package/dist/rpc/redis/index.mjs +6 -3
  18. package/dist/server/express/index.d.ts +1 -1
  19. package/dist/server/express/index.js +18 -14
  20. package/dist/server/express/index.mjs +9 -5
  21. package/dist/server/fastify/index.d.ts +1 -1
  22. package/dist/server/fastify/index.js +23 -16
  23. package/dist/server/fastify/index.mjs +13 -6
  24. package/dist/server/h3/index.d.ts +1 -1
  25. package/dist/server/h3/index.js +18 -14
  26. package/dist/server/h3/index.mjs +9 -5
  27. package/dist/server/koa/index.d.ts +1 -1
  28. package/dist/server/koa/index.js +18 -14
  29. package/dist/server/koa/index.mjs +9 -5
  30. package/dist/test.d.ts +1 -1
  31. package/dist/test.js +2 -2
  32. package/dist/test.mjs +1 -1
  33. package/package.json +3 -2
  34. package/register/loader.mjs +3 -5
  35. package/register/utils.mjs +46 -5
  36. package/dist/core-eb2a0799.d.ts +0 -131
@@ -6,7 +6,7 @@ import {
6
6
  BadRequestException,
7
7
  Context,
8
8
  isAopDepInject
9
- } from "../../chunk-PXI5J4LR.mjs";
9
+ } from "../../chunk-AL36AJMH.mjs";
10
10
  import {
11
11
  APP_SYMBOL,
12
12
  IS_DEV,
@@ -69,7 +69,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
69
69
  if (!meta2)
70
70
  return resolve(await Context.filterRecord.default(new BadRequestException(`"${tag}" doesn't exist`)));
71
71
  const [name, method] = tag.split("-");
72
- const { paramsType, data: { params, guards, interceptors, filter } } = meta2;
72
+ const { paramsType, data: { ctx, params, guards, interceptors, filter } } = meta2;
73
73
  const instance = moduleMap.get(name);
74
74
  const contextData = {
75
75
  type: "express",
@@ -80,6 +80,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
80
80
  moduleMap,
81
81
  tag,
82
82
  next,
83
+ data: req.data,
83
84
  ...argToReq(params, item.args, req.headers)
84
85
  };
85
86
  const context = new Context(contextData);
@@ -105,7 +106,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
105
106
  reflect: paramsType[index]
106
107
  };
107
108
  }));
108
- instance.context = contextData;
109
+ if (ctx)
110
+ instance[ctx] = contextData;
109
111
  const funcData = await moduleMap.get(name)[method](...args);
110
112
  resolve(await context.usePostInterceptor(funcData));
111
113
  } catch (e) {
@@ -124,7 +126,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
124
126
  if (!http?.type)
125
127
  continue;
126
128
  const methodTag = `${tag}-${method}`;
127
- const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
129
+ const { paramsType, data: { ctx, interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
128
130
  app[http.type](http.route, (req, _res, next) => {
129
131
  req[MODULE_SYMBOL] = moduleMap;
130
132
  req[META_SYMBOL] = meta;
@@ -143,6 +145,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
143
145
  body: req.body,
144
146
  params: req.params,
145
147
  headers: req.headers,
148
+ data: req.data,
146
149
  next
147
150
  };
148
151
  const context = new Context(contextData);
@@ -175,7 +178,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
175
178
  reflect: paramsType[index]
176
179
  };
177
180
  }));
178
- instance.context = contextData;
181
+ if (ctx)
182
+ instance[ctx] = contextData;
179
183
  const funcData = await instance[method](...args);
180
184
  const ret = await context.usePostInterceptor(funcData);
181
185
  if (res.writableEnded)
@@ -1,5 +1,5 @@
1
1
  import { FastifyRequest, FastifyReply, FastifyInstance, FastifyPluginCallback } from 'fastify';
2
- import { P, F as Factory } from '../../core-eb2a0799.js';
2
+ import { P, F as Factory } from '../../core-895ed04d.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -6,7 +6,7 @@ var _chunkEVF2CXTPjs = require('../../chunk-EVF2CXTP.js');
6
6
 
7
7
 
8
8
 
9
- var _chunkWNTTAFLCjs = require('../../chunk-WNTTAFLC.js');
9
+ var _chunk562XCEUUjs = require('../../chunk-562XCEUU.js');
10
10
 
11
11
 
12
12
 
@@ -28,7 +28,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
28
28
  moduleMap,
29
29
  meta
30
30
  };
31
- _chunkXHKBG2VAjs.IS_DEV && _chunkWNTTAFLCjs.isAopDepInject.call(void 0, meta, {
31
+ _chunkXHKBG2VAjs.IS_DEV && _chunk562XCEUUjs.isAopDepInject.call(void 0, meta, {
32
32
  plugins,
33
33
  guards: globalGuards,
34
34
  interceptors: globalInterceptors
@@ -51,9 +51,12 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
51
51
  moduleMap,
52
52
  meta
53
53
  };
54
+ fastify.decorateRequest("data", {});
55
+ fastify.decorateRequest(_chunkXHKBG2VAjs.MODULE_SYMBOL);
56
+ fastify.decorateRequest(_chunkXHKBG2VAjs.META_SYMBOL);
54
57
  fastify.register((fastify2, _opts, done2) => {
55
58
  plugins.forEach((p) => {
56
- const plugin = _chunkWNTTAFLCjs.Context.usePlugin([
59
+ const plugin = _chunk562XCEUUjs.Context.usePlugin([
57
60
  p
58
61
  ])[0];
59
62
  if (plugin) {
@@ -64,21 +67,21 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
64
67
  fastify2.post(route, async (req, res) => {
65
68
  const { body } = req;
66
69
  async function errorHandler(e) {
67
- const error = await _chunkWNTTAFLCjs.Context.filterRecord.default(e);
70
+ const error = await _chunk562XCEUUjs.Context.filterRecord.default(e);
68
71
  return res.status(error.status).send(error);
69
72
  }
70
73
  _chunkXHKBG2VAjs.__name.call(void 0, errorHandler, "errorHandler");
71
74
  if (!Array.isArray(body))
72
- return errorHandler(new (0, _chunkWNTTAFLCjs.BadRequestException)("data format should be an array"));
75
+ return errorHandler(new (0, _chunk562XCEUUjs.BadRequestException)("data format should be an array"));
73
76
  try {
74
77
  return Promise.all(body.map((item, i) => {
75
78
  return new Promise(async (resolve) => {
76
79
  const { tag } = item;
77
80
  const meta2 = metaMap.get(tag);
78
81
  if (!meta2)
79
- return resolve(await _chunkWNTTAFLCjs.Context.filterRecord.default(new (0, _chunkWNTTAFLCjs.BadRequestException)(`"${tag}" doesn't exist`)));
82
+ return resolve(await _chunk562XCEUUjs.Context.filterRecord.default(new (0, _chunk562XCEUUjs.BadRequestException)(`"${tag}" doesn't exist`)));
80
83
  const [name, method] = tag.split("-");
81
- const { paramsType, data: { params, guards, interceptors, filter } } = meta2;
84
+ const { paramsType, data: { ctx, params, guards, interceptors, filter } } = meta2;
82
85
  const instance = moduleMap.get(name);
83
86
  const contextData = {
84
87
  type: "fastify",
@@ -88,12 +91,13 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
88
91
  response: res,
89
92
  moduleMap,
90
93
  tag,
94
+ data: req.data,
91
95
  ..._chunkEVF2CXTPjs.argToReq.call(void 0, params, item.args, req.headers)
92
96
  };
93
- const context = new (0, _chunkWNTTAFLCjs.Context)(contextData);
97
+ const context = new (0, _chunk562XCEUUjs.Context)(contextData);
94
98
  try {
95
99
  if (!params)
96
- throw new (0, _chunkWNTTAFLCjs.BadRequestException)(`"${tag}" doesn't exist`);
100
+ throw new (0, _chunk562XCEUUjs.BadRequestException)(`"${tag}" doesn't exist`);
97
101
  await context.useGuard([
98
102
  ...globalGuards,
99
103
  ...guards
@@ -115,7 +119,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
115
119
  reflect: paramsType[index]
116
120
  };
117
121
  }));
118
- instance.context = contextData;
122
+ if (ctx)
123
+ instance[ctx] = contextData;
119
124
  const funcData = await moduleMap.get(name)[method](...args);
120
125
  resolve(await context.usePostInterceptor(funcData));
121
126
  } catch (e) {
@@ -136,9 +141,9 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
136
141
  if (!_optionalChain([http, 'optionalAccess', _3 => _3.type]))
137
142
  continue;
138
143
  const methodTag = `${tag}-${method}`;
139
- const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
144
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter, ctx } } = metaMap.get(methodTag);
140
145
  fastify.register((fastify2, _opts, done2) => {
141
- _chunkWNTTAFLCjs.Context.usePlugin(plugins2).forEach((p) => {
146
+ _chunk562XCEUUjs.Context.usePlugin(plugins2).forEach((p) => {
142
147
  p[Symbol.for("skip-override")] = true;
143
148
  fastify2.register(p);
144
149
  });
@@ -156,9 +161,10 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
156
161
  query: req.query,
157
162
  body: req.body,
158
163
  params: req.params,
159
- headers: req.headers
164
+ headers: req.headers,
165
+ data: req.data
160
166
  };
161
- const context = new (0, _chunkWNTTAFLCjs.Context)(contextData);
167
+ const context = new (0, _chunk562XCEUUjs.Context)(contextData);
162
168
  try {
163
169
  for (const name in header)
164
170
  res.header(name, header[name]);
@@ -183,7 +189,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
183
189
  reflect: paramsType[index]
184
190
  };
185
191
  }));
186
- instance.context = contextData;
192
+ if (ctx)
193
+ instance[ctx] = contextData;
187
194
  const funcData = await instance[method](...args);
188
195
  const ret = await context.usePostInterceptor(funcData);
189
196
  if (res.sent)
@@ -202,7 +209,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
202
209
  done();
203
210
  if (_chunkXHKBG2VAjs.IS_DEV) {
204
211
  _optionalChain([globalThis, 'access', _4 => _4.__PS_HMR__, 'optionalAccess', _5 => _5.push, 'call', _6 => _6(async () => {
205
- _chunkWNTTAFLCjs.isAopDepInject.call(void 0, meta, {
212
+ _chunk562XCEUUjs.isAopDepInject.call(void 0, meta, {
206
213
  plugins,
207
214
  guards: globalGuards,
208
215
  interceptors: globalInterceptors
@@ -6,7 +6,7 @@ import {
6
6
  BadRequestException,
7
7
  Context,
8
8
  isAopDepInject
9
- } from "../../chunk-PXI5J4LR.mjs";
9
+ } from "../../chunk-AL36AJMH.mjs";
10
10
  import {
11
11
  APP_SYMBOL,
12
12
  IS_DEV,
@@ -51,6 +51,9 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
51
51
  moduleMap,
52
52
  meta
53
53
  };
54
+ fastify.decorateRequest("data", {});
55
+ fastify.decorateRequest(MODULE_SYMBOL);
56
+ fastify.decorateRequest(META_SYMBOL);
54
57
  fastify.register((fastify2, _opts, done2) => {
55
58
  plugins.forEach((p) => {
56
59
  const plugin = Context.usePlugin([
@@ -78,7 +81,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
78
81
  if (!meta2)
79
82
  return resolve(await Context.filterRecord.default(new BadRequestException(`"${tag}" doesn't exist`)));
80
83
  const [name, method] = tag.split("-");
81
- const { paramsType, data: { params, guards, interceptors, filter } } = meta2;
84
+ const { paramsType, data: { ctx, params, guards, interceptors, filter } } = meta2;
82
85
  const instance = moduleMap.get(name);
83
86
  const contextData = {
84
87
  type: "fastify",
@@ -88,6 +91,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
88
91
  response: res,
89
92
  moduleMap,
90
93
  tag,
94
+ data: req.data,
91
95
  ...argToReq(params, item.args, req.headers)
92
96
  };
93
97
  const context = new Context(contextData);
@@ -115,7 +119,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
115
119
  reflect: paramsType[index]
116
120
  };
117
121
  }));
118
- instance.context = contextData;
122
+ if (ctx)
123
+ instance[ctx] = contextData;
119
124
  const funcData = await moduleMap.get(name)[method](...args);
120
125
  resolve(await context.usePostInterceptor(funcData));
121
126
  } catch (e) {
@@ -136,7 +141,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
136
141
  if (!http?.type)
137
142
  continue;
138
143
  const methodTag = `${tag}-${method}`;
139
- const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
144
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter, ctx } } = metaMap.get(methodTag);
140
145
  fastify.register((fastify2, _opts, done2) => {
141
146
  Context.usePlugin(plugins2).forEach((p) => {
142
147
  p[Symbol.for("skip-override")] = true;
@@ -156,7 +161,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
156
161
  query: req.query,
157
162
  body: req.body,
158
163
  params: req.params,
159
- headers: req.headers
164
+ headers: req.headers,
165
+ data: req.data
160
166
  };
161
167
  const context = new Context(contextData);
162
168
  try {
@@ -183,7 +189,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
183
189
  reflect: paramsType[index]
184
190
  };
185
191
  }));
186
- instance.context = contextData;
192
+ if (ctx)
193
+ instance[ctx] = contextData;
187
194
  const funcData = await instance[method](...args);
188
195
  const ret = await context.usePostInterceptor(funcData);
189
196
  if (res.sent)
@@ -1,5 +1,5 @@
1
1
  import { H3Event, Router } from 'h3';
2
- import { P, F as Factory } from '../../core-eb2a0799.js';
2
+ import { P, F as Factory } from '../../core-895ed04d.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -6,7 +6,7 @@ var _chunkEVF2CXTPjs = require('../../chunk-EVF2CXTP.js');
6
6
 
7
7
 
8
8
 
9
- var _chunkWNTTAFLCjs = require('../../chunk-WNTTAFLC.js');
9
+ var _chunk562XCEUUjs = require('../../chunk-562XCEUU.js');
10
10
 
11
11
 
12
12
 
@@ -25,7 +25,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
25
25
  plugins: [],
26
26
  ...options
27
27
  };
28
- _chunkXHKBG2VAjs.IS_DEV && _chunkWNTTAFLCjs.isAopDepInject.call(void 0, meta, {
28
+ _chunkXHKBG2VAjs.IS_DEV && _chunk562XCEUUjs.isAopDepInject.call(void 0, meta, {
29
29
  plugins,
30
30
  guards: globalGuards,
31
31
  interceptors: globalInterceptors
@@ -54,29 +54,29 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
54
54
  router.post(route, _h3.eventHandler.call(void 0, {
55
55
  onRequest: [
56
56
  prePlugin,
57
- ..._chunkWNTTAFLCjs.Context.usePlugin(plugins).map((p) => _h3.defineRequestMiddleware.call(void 0, p))
57
+ ..._chunk562XCEUUjs.Context.usePlugin(plugins).map((p) => _h3.defineRequestMiddleware.call(void 0, p))
58
58
  ],
59
59
  handler: async (event) => {
60
60
  const body = await _h3.readBody.call(void 0, event, {
61
61
  strict: true
62
62
  });
63
63
  async function errorHandler(e) {
64
- const error = await _chunkWNTTAFLCjs.Context.filterRecord.default(e);
64
+ const error = await _chunk562XCEUUjs.Context.filterRecord.default(e);
65
65
  _h3.setResponseStatus.call(void 0, event, error.status);
66
66
  return error;
67
67
  }
68
68
  _chunkXHKBG2VAjs.__name.call(void 0, errorHandler, "errorHandler");
69
69
  if (!Array.isArray(body))
70
- return errorHandler(new (0, _chunkWNTTAFLCjs.BadRequestException)("data format should be an array"));
70
+ return errorHandler(new (0, _chunk562XCEUUjs.BadRequestException)("data format should be an array"));
71
71
  try {
72
72
  return Promise.all(body.map((item, i) => {
73
73
  return new Promise(async (resolve) => {
74
74
  const { tag } = item;
75
75
  const meta2 = metaMap.get(tag);
76
76
  if (!meta2)
77
- return resolve(await _chunkWNTTAFLCjs.Context.filterRecord.default(new (0, _chunkWNTTAFLCjs.BadRequestException)(`"${tag}" doesn't exist`)));
77
+ return resolve(await _chunk562XCEUUjs.Context.filterRecord.default(new (0, _chunk562XCEUUjs.BadRequestException)(`"${tag}" doesn't exist`)));
78
78
  const [name, method] = tag.split("-");
79
- const { paramsType, data: { params, guards, interceptors, filter } } = metaMap.get(tag);
79
+ const { paramsType, data: { params, guards, interceptors, filter, ctx } } = metaMap.get(tag);
80
80
  const instance = moduleMap.get(name);
81
81
  const contextData = {
82
82
  type: "h3",
@@ -85,9 +85,10 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
85
85
  meta: meta2,
86
86
  moduleMap,
87
87
  tag,
88
+ data: event.data,
88
89
  ..._chunkEVF2CXTPjs.argToReq.call(void 0, params, item.args, _h3.getRequestHeaders.call(void 0, event))
89
90
  };
90
- const context = new (0, _chunkWNTTAFLCjs.Context)(contextData);
91
+ const context = new (0, _chunk562XCEUUjs.Context)(contextData);
91
92
  try {
92
93
  await context.useGuard([
93
94
  ...globalGuards,
@@ -110,7 +111,8 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
110
111
  reflect: paramsType[index]
111
112
  };
112
113
  }));
113
- instance.context = contextData;
114
+ if (ctx)
115
+ instance[ctx] = contextData;
114
116
  const funcData = await moduleMap.get(name)[method](...args);
115
117
  resolve(await context.usePostInterceptor(funcData));
116
118
  } catch (e) {
@@ -128,12 +130,12 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
128
130
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
129
131
  continue;
130
132
  const methodTag = `${tag}-${method}`;
131
- const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
133
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter, ctx } } = metaMap.get(methodTag);
132
134
  const needBody = params.some((item) => item.type === "body");
133
135
  router[http.type](http.route, _h3.eventHandler.call(void 0, {
134
136
  onRequest: [
135
137
  prePlugin,
136
- ..._chunkWNTTAFLCjs.Context.usePlugin(plugins2).map((p) => _h3.defineRequestMiddleware.call(void 0, p))
138
+ ..._chunk562XCEUUjs.Context.usePlugin(plugins2).map((p) => _h3.defineRequestMiddleware.call(void 0, p))
137
139
  ],
138
140
  handler: async (event) => {
139
141
  const instance = moduleMap.get(tag);
@@ -146,11 +148,12 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
146
148
  headers: _h3.getRequestHeaders.call(void 0, event),
147
149
  params: _h3.getRouterParams.call(void 0, event),
148
150
  query: _h3.getQuery.call(void 0, event),
151
+ data: event.data,
149
152
  body: needBody ? await _h3.readBody.call(void 0, event, {
150
153
  strict: true
151
154
  }) : void 0
152
155
  };
153
- const context = new (0, _chunkWNTTAFLCjs.Context)(contextData);
156
+ const context = new (0, _chunk562XCEUUjs.Context)(contextData);
154
157
  try {
155
158
  _h3.setHeaders.call(void 0, event, header);
156
159
  await context.useGuard([
@@ -174,7 +177,8 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
174
177
  reflect: paramsType[index]
175
178
  };
176
179
  }));
177
- instance.context = contextData;
180
+ if (ctx)
181
+ instance[ctx] = contextData;
178
182
  const funcData = await instance[method](...args);
179
183
  const ret = await context.usePostInterceptor(funcData);
180
184
  return ret;
@@ -192,7 +196,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
192
196
  createRoute();
193
197
  if (_chunkXHKBG2VAjs.IS_DEV) {
194
198
  _optionalChain([globalThis, 'access', _3 => _3.__PS_HMR__, 'optionalAccess', _4 => _4.push, 'call', _5 => _5(async () => {
195
- _chunkWNTTAFLCjs.isAopDepInject.call(void 0, meta, {
199
+ _chunk562XCEUUjs.isAopDepInject.call(void 0, meta, {
196
200
  plugins,
197
201
  guards: globalGuards,
198
202
  interceptors: globalInterceptors
@@ -6,7 +6,7 @@ import {
6
6
  BadRequestException,
7
7
  Context,
8
8
  isAopDepInject
9
- } from "../../chunk-PXI5J4LR.mjs";
9
+ } from "../../chunk-AL36AJMH.mjs";
10
10
  import {
11
11
  APP_SYMBOL,
12
12
  IS_DEV,
@@ -76,7 +76,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
76
76
  if (!meta2)
77
77
  return resolve(await Context.filterRecord.default(new BadRequestException(`"${tag}" doesn't exist`)));
78
78
  const [name, method] = tag.split("-");
79
- const { paramsType, data: { params, guards, interceptors, filter } } = metaMap.get(tag);
79
+ const { paramsType, data: { params, guards, interceptors, filter, ctx } } = metaMap.get(tag);
80
80
  const instance = moduleMap.get(name);
81
81
  const contextData = {
82
82
  type: "h3",
@@ -85,6 +85,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
85
85
  meta: meta2,
86
86
  moduleMap,
87
87
  tag,
88
+ data: event.data,
88
89
  ...argToReq(params, item.args, getRequestHeaders(event))
89
90
  };
90
91
  const context = new Context(contextData);
@@ -110,7 +111,8 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
110
111
  reflect: paramsType[index]
111
112
  };
112
113
  }));
113
- instance.context = contextData;
114
+ if (ctx)
115
+ instance[ctx] = contextData;
114
116
  const funcData = await moduleMap.get(name)[method](...args);
115
117
  resolve(await context.usePostInterceptor(funcData));
116
118
  } catch (e) {
@@ -128,7 +130,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
128
130
  if (!http?.type)
129
131
  continue;
130
132
  const methodTag = `${tag}-${method}`;
131
- const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
133
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter, ctx } } = metaMap.get(methodTag);
132
134
  const needBody = params.some((item) => item.type === "body");
133
135
  router[http.type](http.route, eventHandler({
134
136
  onRequest: [
@@ -146,6 +148,7 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
146
148
  headers: getRequestHeaders(event),
147
149
  params: getRouterParams(event),
148
150
  query: getQuery(event),
151
+ data: event.data,
149
152
  body: needBody ? await readBody(event, {
150
153
  strict: true
151
154
  }) : void 0
@@ -174,7 +177,8 @@ function bindApp(router, { moduleMap, meta }, options = {}) {
174
177
  reflect: paramsType[index]
175
178
  };
176
179
  }));
177
- instance.context = contextData;
180
+ if (ctx)
181
+ instance[ctx] = contextData;
178
182
  const funcData = await instance[method](...args);
179
183
  const ret = await context.usePostInterceptor(funcData);
180
184
  return ret;
@@ -1,6 +1,6 @@
1
1
  import Router, { RouterParamContext } from '@koa/router';
2
2
  import { DefaultContext, DefaultState } from 'koa';
3
- import { P, F as Factory } from '../../core-eb2a0799.js';
3
+ import { P, F as Factory } from '../../core-895ed04d.js';
4
4
  import 'phecda-core';
5
5
  import 'node:http';
6
6
 
@@ -6,7 +6,7 @@ var _chunkEVF2CXTPjs = require('../../chunk-EVF2CXTP.js');
6
6
 
7
7
 
8
8
 
9
- var _chunkWNTTAFLCjs = require('../../chunk-WNTTAFLC.js');
9
+ var _chunk562XCEUUjs = require('../../chunk-562XCEUU.js');
10
10
 
11
11
 
12
12
 
@@ -25,7 +25,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
25
25
  plugins: [],
26
26
  ...options
27
27
  };
28
- _chunkXHKBG2VAjs.IS_DEV && _chunkWNTTAFLCjs.isAopDepInject.call(void 0, meta, {
28
+ _chunkXHKBG2VAjs.IS_DEV && _chunk562XCEUUjs.isAopDepInject.call(void 0, meta, {
29
29
  plugins,
30
30
  guards: globalGuards,
31
31
  interceptors: globalInterceptors
@@ -52,25 +52,25 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
52
52
  ctx[_chunkXHKBG2VAjs.MODULE_SYMBOL] = moduleMap;
53
53
  ctx[_chunkXHKBG2VAjs.META_SYMBOL] = meta;
54
54
  await next();
55
- }, ..._chunkWNTTAFLCjs.Context.usePlugin(plugins), async (ctx, next) => {
55
+ }, ..._chunk562XCEUUjs.Context.usePlugin(plugins), async (ctx, next) => {
56
56
  const { body } = ctx.request;
57
57
  async function errorHandler(e) {
58
- const error = await _chunkWNTTAFLCjs.Context.filterRecord.default(e);
58
+ const error = await _chunk562XCEUUjs.Context.filterRecord.default(e);
59
59
  ctx.status = error.status;
60
60
  ctx.body = error;
61
61
  }
62
62
  _chunkXHKBG2VAjs.__name.call(void 0, errorHandler, "errorHandler");
63
63
  if (!Array.isArray(body))
64
- return errorHandler(new (0, _chunkWNTTAFLCjs.BadRequestException)("data format should be an array"));
64
+ return errorHandler(new (0, _chunk562XCEUUjs.BadRequestException)("data format should be an array"));
65
65
  try {
66
66
  return Promise.all(body.map((item, i) => {
67
67
  return new Promise(async (resolve) => {
68
68
  const { tag } = item;
69
69
  const meta2 = metaMap.get(tag);
70
70
  if (!meta2)
71
- return resolve(await _chunkWNTTAFLCjs.Context.filterRecord.default(new (0, _chunkWNTTAFLCjs.BadRequestException)(`"${tag}" doesn't exist`)));
71
+ return resolve(await _chunk562XCEUUjs.Context.filterRecord.default(new (0, _chunk562XCEUUjs.BadRequestException)(`"${tag}" doesn't exist`)));
72
72
  const [name, method] = tag.split("-");
73
- const { paramsType, data: { params, guards, interceptors, filter } } = meta2;
73
+ const { paramsType, data: { params, guards, interceptors, filter, ctx: CTX } } = meta2;
74
74
  const instance = moduleMap.get(name);
75
75
  const contextData = {
76
76
  type: "koa",
@@ -80,10 +80,11 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
80
80
  moduleMap,
81
81
  parallel: true,
82
82
  next,
83
+ data: ctx.data,
83
84
  ..._chunkEVF2CXTPjs.argToReq.call(void 0, params, item.args, ctx.headers),
84
85
  tag
85
86
  };
86
- const context = new (0, _chunkWNTTAFLCjs.Context)(contextData);
87
+ const context = new (0, _chunk562XCEUUjs.Context)(contextData);
87
88
  try {
88
89
  await context.useGuard([
89
90
  ...globalGuards,
@@ -106,7 +107,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
106
107
  reflect: paramsType[index]
107
108
  };
108
109
  }));
109
- instance.context = contextData;
110
+ if (CTX)
111
+ instance[CTX] = contextData;
110
112
  const funcData = await moduleMap.get(name)[method](...args);
111
113
  resolve(await context.usePostInterceptor(funcData));
112
114
  } catch (e) {
@@ -125,12 +127,12 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
125
127
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
126
128
  continue;
127
129
  const methodTag = `${tag}-${method}`;
128
- const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
130
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter, ctx: CTX } } = metaMap.get(methodTag);
129
131
  app[http.type](http.route, async (ctx, next) => {
130
132
  ctx[_chunkXHKBG2VAjs.MODULE_SYMBOL] = moduleMap;
131
133
  ctx[_chunkXHKBG2VAjs.META_SYMBOL] = meta;
132
134
  await next();
133
- }, ..._chunkWNTTAFLCjs.Context.usePlugin(plugins2), async (ctx, next) => {
135
+ }, ..._chunk562XCEUUjs.Context.usePlugin(plugins2), async (ctx, next) => {
134
136
  const instance = moduleMap.get(tag);
135
137
  const contextData = {
136
138
  type: "koa",
@@ -143,9 +145,10 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
143
145
  params: ctx.params,
144
146
  body: ctx.request.body,
145
147
  headers: ctx.headers,
148
+ data: ctx.data,
146
149
  next
147
150
  };
148
- const context = new (0, _chunkWNTTAFLCjs.Context)(contextData);
151
+ const context = new (0, _chunk562XCEUUjs.Context)(contextData);
149
152
  try {
150
153
  for (const name in header)
151
154
  ctx.set(name, header[name]);
@@ -172,7 +175,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
172
175
  reflect: paramsType[index]
173
176
  };
174
177
  }));
175
- instance.context = contextData;
178
+ if (CTX)
179
+ instance[CTX] = contextData;
176
180
  const funcData = await instance[method](...args);
177
181
  const ret = await context.usePostInterceptor(funcData);
178
182
  if (ctx.res.writableEnded)
@@ -193,7 +197,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
193
197
  createRoute();
194
198
  if (_chunkXHKBG2VAjs.IS_DEV) {
195
199
  _optionalChain([globalThis, 'access', _3 => _3.__PS_HMR__, 'optionalAccess', _4 => _4.push, 'call', _5 => _5(async () => {
196
- _chunkWNTTAFLCjs.isAopDepInject.call(void 0, meta, {
200
+ _chunk562XCEUUjs.isAopDepInject.call(void 0, meta, {
197
201
  plugins,
198
202
  guards: globalGuards,
199
203
  interceptors: globalInterceptors
@@ -6,7 +6,7 @@ import {
6
6
  BadRequestException,
7
7
  Context,
8
8
  isAopDepInject
9
- } from "../../chunk-PXI5J4LR.mjs";
9
+ } from "../../chunk-AL36AJMH.mjs";
10
10
  import {
11
11
  APP_SYMBOL,
12
12
  IS_DEV,
@@ -70,7 +70,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
70
70
  if (!meta2)
71
71
  return resolve(await Context.filterRecord.default(new BadRequestException(`"${tag}" doesn't exist`)));
72
72
  const [name, method] = tag.split("-");
73
- const { paramsType, data: { params, guards, interceptors, filter } } = meta2;
73
+ const { paramsType, data: { params, guards, interceptors, filter, ctx: CTX } } = meta2;
74
74
  const instance = moduleMap.get(name);
75
75
  const contextData = {
76
76
  type: "koa",
@@ -80,6 +80,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
80
80
  moduleMap,
81
81
  parallel: true,
82
82
  next,
83
+ data: ctx.data,
83
84
  ...argToReq(params, item.args, ctx.headers),
84
85
  tag
85
86
  };
@@ -106,7 +107,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
106
107
  reflect: paramsType[index]
107
108
  };
108
109
  }));
109
- instance.context = contextData;
110
+ if (CTX)
111
+ instance[CTX] = contextData;
110
112
  const funcData = await moduleMap.get(name)[method](...args);
111
113
  resolve(await context.usePostInterceptor(funcData));
112
114
  } catch (e) {
@@ -125,7 +127,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
125
127
  if (!http?.type)
126
128
  continue;
127
129
  const methodTag = `${tag}-${method}`;
128
- const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
130
+ const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter, ctx: CTX } } = metaMap.get(methodTag);
129
131
  app[http.type](http.route, async (ctx, next) => {
130
132
  ctx[MODULE_SYMBOL] = moduleMap;
131
133
  ctx[META_SYMBOL] = meta;
@@ -143,6 +145,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
143
145
  params: ctx.params,
144
146
  body: ctx.request.body,
145
147
  headers: ctx.headers,
148
+ data: ctx.data,
146
149
  next
147
150
  };
148
151
  const context = new Context(contextData);
@@ -172,7 +175,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
172
175
  reflect: paramsType[index]
173
176
  };
174
177
  }));
175
- instance.context = contextData;
178
+ if (CTX)
179
+ instance[CTX] = contextData;
176
180
  const funcData = await instance[method](...args);
177
181
  const ret = await context.usePostInterceptor(funcData);
178
182
  if (ctx.res.writableEnded)
package/dist/test.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as supertest from 'supertest';
2
2
  import { Test } from 'supertest';
3
3
  import { Server } from 'node:http';
4
4
  import { Construct } from 'phecda-core';
5
- import { F as Factory, c as PickFunc } from './core-eb2a0799.js';
5
+ import { F as Factory, d as PickFunc } from './core-895ed04d.js';
6
6
 
7
7
  declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
8
8
  get<C extends T[number]>(Module: C): InstanceType<C>;