phecda-server 7.0.0-alpha.7 → 7.0.0-alpha.8

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 (79) hide show
  1. package/bin/cli.mjs +10 -1
  2. package/dist/{chunk-MENRZSGW.js → chunk-7EMAZGYO.js} +86 -56
  3. package/dist/{chunk-JPSXNDXP.mjs → chunk-7NWDKK7D.mjs} +1 -1
  4. package/dist/{chunk-RGSKKTHD.mjs → chunk-B45BN7LY.mjs} +4 -4
  5. package/dist/{chunk-VYMSCWXC.js → chunk-BBNJVYVX.js} +24 -24
  6. package/dist/{chunk-XSMUJ77A.js → chunk-QJIAXSLZ.js} +19 -19
  7. package/dist/{chunk-IRXNF6ZE.mjs → chunk-SGMQZRP6.mjs} +39 -9
  8. package/dist/{chunk-M5HGFUCV.js → chunk-VSGYTGHY.js} +2 -2
  9. package/dist/{chunk-C5BVKEGW.mjs → chunk-YKP4ODZA.mjs} +2 -2
  10. package/dist/{core-CzElxZoF.d.ts → core-BGEsBtTG.d.ts} +1 -1
  11. package/dist/{core-DU7gQKSk.d.mts → core-BcKywWLd.d.mts} +1 -1
  12. package/dist/helper.d.mts +3 -2
  13. package/dist/helper.d.ts +3 -2
  14. package/dist/helper.js +5 -3
  15. package/dist/helper.mjs +4 -2
  16. package/dist/http/elysia/index.d.mts +4 -4
  17. package/dist/http/elysia/index.d.ts +4 -4
  18. package/dist/http/elysia/index.js +42 -41
  19. package/dist/http/elysia/index.mjs +6 -5
  20. package/dist/http/express/index.d.mts +4 -4
  21. package/dist/http/express/index.d.ts +4 -4
  22. package/dist/http/express/index.js +39 -38
  23. package/dist/http/express/index.mjs +5 -4
  24. package/dist/http/fastify/index.d.mts +4 -4
  25. package/dist/http/fastify/index.d.ts +4 -4
  26. package/dist/http/fastify/index.js +40 -39
  27. package/dist/http/fastify/index.mjs +6 -5
  28. package/dist/http/h3/index.d.mts +4 -4
  29. package/dist/http/h3/index.d.ts +4 -4
  30. package/dist/http/h3/index.js +40 -39
  31. package/dist/http/h3/index.mjs +6 -5
  32. package/dist/http/hono/index.d.mts +4 -4
  33. package/dist/http/hono/index.d.ts +4 -4
  34. package/dist/http/hono/index.js +35 -35
  35. package/dist/http/hono/index.mjs +2 -2
  36. package/dist/http/hyper-express/index.d.mts +4 -4
  37. package/dist/http/hyper-express/index.d.ts +4 -4
  38. package/dist/http/hyper-express/index.js +37 -36
  39. package/dist/http/hyper-express/index.mjs +5 -4
  40. package/dist/http/koa/index.d.mts +4 -4
  41. package/dist/http/koa/index.d.ts +4 -4
  42. package/dist/http/koa/index.js +39 -38
  43. package/dist/http/koa/index.mjs +5 -4
  44. package/dist/index.d.mts +35 -33
  45. package/dist/index.d.ts +35 -33
  46. package/dist/index.js +43 -42
  47. package/dist/index.mjs +15 -14
  48. package/dist/{meta-BTnLXuCa.d.ts → meta-B_HW7cWh.d.mts} +3 -3
  49. package/dist/{meta-BTnLXuCa.d.mts → meta-B_HW7cWh.d.ts} +3 -3
  50. package/dist/rpc/bullmq/index.d.mts +4 -4
  51. package/dist/rpc/bullmq/index.d.ts +4 -4
  52. package/dist/rpc/bullmq/index.js +14 -14
  53. package/dist/rpc/bullmq/index.mjs +2 -2
  54. package/dist/rpc/kafka/index.d.mts +4 -4
  55. package/dist/rpc/kafka/index.d.ts +4 -4
  56. package/dist/rpc/kafka/index.js +14 -14
  57. package/dist/rpc/kafka/index.mjs +2 -2
  58. package/dist/rpc/nats/index.d.mts +4 -4
  59. package/dist/rpc/nats/index.d.ts +4 -4
  60. package/dist/rpc/nats/index.js +13 -13
  61. package/dist/rpc/nats/index.mjs +2 -2
  62. package/dist/rpc/rabbitmq/index.d.mts +4 -4
  63. package/dist/rpc/rabbitmq/index.d.ts +4 -4
  64. package/dist/rpc/rabbitmq/index.js +15 -15
  65. package/dist/rpc/rabbitmq/index.mjs +2 -2
  66. package/dist/rpc/redis/index.d.mts +4 -4
  67. package/dist/rpc/redis/index.d.ts +4 -4
  68. package/dist/rpc/redis/index.js +13 -13
  69. package/dist/rpc/redis/index.mjs +2 -2
  70. package/dist/test.d.mts +2 -2
  71. package/dist/test.d.ts +2 -2
  72. package/dist/test.js +6 -6
  73. package/dist/test.mjs +2 -2
  74. package/dist/{types--E-OCZhC.d.ts → types-C2SQ9U9V.d.mts} +3 -3
  75. package/dist/{types-CbfaGkPA.d.ts → types-CYF0vha6.d.ts} +3 -3
  76. package/dist/{types-BYqBeqrs.d.mts → types-DEQb_e59.d.mts} +3 -3
  77. package/dist/{types-BxlzVoRv.d.mts → types-PFPIQWVF.d.ts} +3 -3
  78. package/package.json +3 -2
  79. package/register/loader.mjs +2 -2
@@ -1,12 +1,12 @@
1
1
  import Router, { RouterParamContext } from '@koa/router';
2
2
  import { DefaultContext, DefaultState } from 'koa';
3
- import { H as HttpContext, a as HttpOptions } from '../../types-BxlzVoRv.mjs';
4
- import { F as Factory } from '../../core-DU7gQKSk.mjs';
3
+ import { H as HttpCtx, a as HttpOptions } from '../../types-C2SQ9U9V.mjs';
4
+ import { F as Factory } from '../../core-BcKywWLd.mjs';
5
5
  import 'node:http';
6
- import '../../meta-BTnLXuCa.mjs';
6
+ import '../../meta-B_HW7cWh.mjs';
7
7
  import 'phecda-core';
8
8
 
9
- interface KoaCtx extends HttpContext {
9
+ interface KoaCtx extends HttpCtx {
10
10
  type: 'koa';
11
11
  ctx: DefaultContext & RouterParamContext<DefaultState, DefaultContext>;
12
12
  next: Function;
@@ -1,12 +1,12 @@
1
1
  import Router, { RouterParamContext } from '@koa/router';
2
2
  import { DefaultContext, DefaultState } from 'koa';
3
- import { H as HttpContext, a as HttpOptions } from '../../types--E-OCZhC.js';
4
- import { F as Factory } from '../../core-CzElxZoF.js';
3
+ import { H as HttpCtx, a as HttpOptions } from '../../types-PFPIQWVF.js';
4
+ import { F as Factory } from '../../core-BGEsBtTG.js';
5
5
  import 'node:http';
6
- import '../../meta-BTnLXuCa.js';
6
+ import '../../meta-B_HW7cWh.js';
7
7
  import 'phecda-core';
8
8
 
9
- interface KoaCtx extends HttpContext {
9
+ interface KoaCtx extends HttpCtx {
10
10
  type: 'koa';
11
11
  ctx: DefaultContext & RouterParamContext<DefaultState, DefaultContext>;
12
12
  next: Function;
@@ -5,10 +5,11 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkMENRZSGWjs = require('../../chunk-MENRZSGW.js');
9
8
 
9
+ var _chunk7EMAZGYOjs = require('../../chunk-7EMAZGYO.js');
10
10
 
11
- var _chunkM5HGFUCVjs = require('../../chunk-M5HGFUCV.js');
11
+
12
+ var _chunkVSGYTGHYjs = require('../../chunk-VSGYTGHY.js');
12
13
 
13
14
  // src/http/koa/bind.ts
14
15
  var _router = require('@koa/router'); var _router2 = _interopRequireDefault(_router);
@@ -18,14 +19,14 @@ function bind(router, data, opts = {}) {
18
19
  const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
19
20
  const { moduleMap, meta } = data;
20
21
  const originStack = router.stack.slice(0, router.stack.length);
21
- const metaMap = _chunkMENRZSGWjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
+ const metaMap = _chunk7EMAZGYOjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
23
  const { controller, http, func, tag } = meta2.data;
23
24
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
24
25
  debug(`register method "${func}" in module "${tag}"`);
25
26
  return true;
26
27
  }
27
28
  });
28
- _chunkMENRZSGWjs.detectAopDep.call(void 0, meta, {
29
+ _chunk7EMAZGYOjs.detectAopDep.call(void 0, meta, {
29
30
  addons: [
30
31
  ...globalAddons,
31
32
  ...parallelAddons
@@ -34,29 +35,29 @@ function bind(router, data, opts = {}) {
34
35
  });
35
36
  registerRoute();
36
37
  function registerRoute() {
37
- _chunkMENRZSGWjs.Context.applyAddons(globalAddons, router, "koa");
38
+ _chunk7EMAZGYOjs.Context.applyAddons(globalAddons, router, "koa");
38
39
  if (parallelRoute) {
39
40
  const subRouter = new (0, _router2.default)();
40
- _chunkMENRZSGWjs.Context.applyAddons(parallelAddons, subRouter, "koa");
41
+ _chunk7EMAZGYOjs.Context.applyAddons(parallelAddons, subRouter, "koa");
41
42
  subRouter.post(parallelRoute, async (ctx, next) => {
42
43
  const { body } = ctx.request;
43
44
  async function errorHandler(e) {
44
- const error = await _chunkMENRZSGWjs.Context.filterRecord.default(e);
45
+ const error = await _chunk7EMAZGYOjs.Context.filterRecord.default(e);
45
46
  ctx.status = error.status;
46
47
  ctx.body = error;
47
48
  }
48
- _chunkM5HGFUCVjs.__name.call(void 0, errorHandler, "errorHandler");
49
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkMENRZSGWjs.BadRequestException)("data format should be an array"));
49
+ _chunkVSGYTGHYjs.__name.call(void 0, errorHandler, "errorHandler");
50
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunk7EMAZGYOjs.BadRequestException)("data format should be an array"));
50
51
  try {
51
52
  return Promise.all(body.map((item, i) => {
52
53
  return new Promise(async (resolve) => {
53
54
  const { tag, func } = item;
54
55
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
55
- if (!metaMap.has(tag)) return resolve(await _chunkMENRZSGWjs.Context.filterRecord.default(new (0, _chunkMENRZSGWjs.BadRequestException)(`module "${tag}" doesn't exist`)));
56
+ if (!metaMap.has(tag)) return resolve(await _chunk7EMAZGYOjs.Context.filterRecord.default(new (0, _chunk7EMAZGYOjs.BadRequestException)(`module "${tag}" doesn't exist`)));
56
57
  const meta2 = metaMap.get(tag)[func];
57
- if (!meta2) return resolve(await _chunkMENRZSGWjs.Context.filterRecord.default(new (0, _chunkMENRZSGWjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
58
+ if (!meta2) return resolve(await _chunk7EMAZGYOjs.Context.filterRecord.default(new (0, _chunk7EMAZGYOjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
58
59
  const { data: { params } } = meta2;
59
- const aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
60
+ const aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
60
61
  globalGuards,
61
62
  globalFilter,
62
63
  globalPipe
@@ -71,21 +72,21 @@ function bind(router, data, opts = {}) {
71
72
  parallel: true,
72
73
  next,
73
74
  app: router,
74
- ..._chunkMENRZSGWjs.argToReq.call(void 0, params, item.args, ctx.headers),
75
+ ..._chunk7EMAZGYOjs.argToReq.call(void 0, params, item.args, ctx.headers),
75
76
  tag,
76
77
  func,
77
- getCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
78
- setCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
79
- delCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
78
+ getCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
79
+ setCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
80
+ delCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
80
81
  expires: /* @__PURE__ */ new Date(0)
81
82
  }), "delCookie"),
82
- redirect: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
83
- setResHeaders: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
84
- setResStatus: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
85
- getRequest: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => ctx.req, "getRequest"),
86
- getResponse: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => ctx.res, "getResponse")
83
+ redirect: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
84
+ setResHeaders: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
85
+ setResStatus: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
86
+ getRequest: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => ctx.req, "getRequest"),
87
+ getResponse: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => ctx.res, "getResponse")
87
88
  };
88
- const context = new (0, _chunkMENRZSGWjs.Context)(contextData);
89
+ const context = new (0, _chunk7EMAZGYOjs.Context)(contextData);
89
90
  context.run(aop, resolve, resolve);
90
91
  });
91
92
  })).then((ret) => {
@@ -104,15 +105,15 @@ function bind(router, data, opts = {}) {
104
105
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
105
106
  let aop;
106
107
  if (!dynamic) {
107
- aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
108
+ aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
108
109
  globalFilter,
109
110
  globalGuards,
110
111
  globalPipe
111
112
  });
112
113
  }
113
114
  const subRouter = new (0, _router2.default)();
114
- _chunkMENRZSGWjs.Context.applyAddons(addons, subRouter, "koa");
115
- router[http.type](http.prefix + http.route, async (ctx, next) => {
115
+ _chunk7EMAZGYOjs.Context.applyAddons(addons, subRouter, "koa");
116
+ router[http.type](_chunk7EMAZGYOjs.joinUrl.call(void 0, http.prefix, http.route), async (ctx, next) => {
116
117
  debug(`invoke method "${func}" in module "${tag}"`);
117
118
  const contextData = {
118
119
  type: "koa",
@@ -128,21 +129,21 @@ function bind(router, data, opts = {}) {
128
129
  body: ctx.request.body,
129
130
  headers: ctx.headers,
130
131
  next,
131
- getCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
132
- setCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
133
- delCookie: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
132
+ getCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
133
+ setCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
134
+ delCookie: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
134
135
  expires: /* @__PURE__ */ new Date(0)
135
136
  }), "delCookie"),
136
- redirect: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
137
- setResHeaders: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
138
- setResStatus: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
139
- getRequest: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => ctx.req, "getRequest"),
140
- getResponse: /* @__PURE__ */ _chunkM5HGFUCVjs.__name.call(void 0, () => ctx.res, "getResponse")
137
+ redirect: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
138
+ setResHeaders: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
139
+ setResStatus: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
140
+ getRequest: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => ctx.req, "getRequest"),
141
+ getResponse: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, () => ctx.res, "getResponse")
141
142
  };
142
- const context = new (0, _chunkMENRZSGWjs.Context)(contextData);
143
+ const context = new (0, _chunk7EMAZGYOjs.Context)(contextData);
143
144
  if (http.headers) ctx.set(http.headers);
144
145
  if (dynamic) {
145
- aop = _chunkMENRZSGWjs.Context.getAop(meta2, {
146
+ aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
146
147
  globalFilter,
147
148
  globalGuards,
148
149
  globalPipe
@@ -161,13 +162,13 @@ function bind(router, data, opts = {}) {
161
162
  }
162
163
  }
163
164
  }
164
- _chunkM5HGFUCVjs.__name.call(void 0, registerRoute, "registerRoute");
165
- _chunkMENRZSGWjs.HMR.call(void 0, async () => {
165
+ _chunkVSGYTGHYjs.__name.call(void 0, registerRoute, "registerRoute");
166
+ _chunk7EMAZGYOjs.HMR.call(void 0, async () => {
166
167
  router.stack = originStack;
167
168
  registerRoute();
168
169
  });
169
170
  }
170
- _chunkM5HGFUCVjs.__name.call(void 0, bind, "bind");
171
+ _chunkVSGYTGHYjs.__name.call(void 0, bind, "bind");
171
172
 
172
173
 
173
174
  exports.bind = bind;
@@ -4,11 +4,12 @@ import {
4
4
  HMR,
5
5
  argToReq,
6
6
  createControllerMetaMap,
7
- detectAopDep
8
- } from "../../chunk-IRXNF6ZE.mjs";
7
+ detectAopDep,
8
+ joinUrl
9
+ } from "../../chunk-SGMQZRP6.mjs";
9
10
  import {
10
11
  __name
11
- } from "../../chunk-C5BVKEGW.mjs";
12
+ } from "../../chunk-YKP4ODZA.mjs";
12
13
 
13
14
  // src/http/koa/bind.ts
14
15
  import Router from "@koa/router";
@@ -112,7 +113,7 @@ function bind(router, data, opts = {}) {
112
113
  }
113
114
  const subRouter = new Router();
114
115
  Context.applyAddons(addons, subRouter, "koa");
115
- router[http.type](http.prefix + http.route, async (ctx, next) => {
116
+ router[http.type](joinUrl(http.prefix, http.route), async (ctx, next) => {
116
117
  debug(`invoke method "${func}" in module "${tag}"`);
117
118
  const contextData = {
118
119
  type: "koa",
package/dist/index.d.mts CHANGED
@@ -1,13 +1,13 @@
1
- import { B as BaseContext, a as ControllerMeta, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-BTnLXuCa.mjs';
2
- export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_HMR, k as IS_ONLY_GENERATE, m as IS_READY, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, n as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-BTnLXuCa.mjs';
3
- import { G as Generator } from './core-DU7gQKSk.mjs';
4
- export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-DU7gQKSk.mjs';
1
+ import { B as BaseCtx, a as ControllerMeta, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-B_HW7cWh.mjs';
2
+ export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_DEV, k as IS_ONLY_GENERATE, m as IS_READY, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, n as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-B_HW7cWh.mjs';
3
+ import { G as Generator } from './core-BcKywWLd.mjs';
4
+ export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-BcKywWLd.mjs';
5
5
  import { Base } from 'phecda-core';
6
6
  export * from 'phecda-core';
7
- import { H as HttpContext } from './types-BxlzVoRv.mjs';
8
- export { C as CookieSerializeOptions, a as HttpOptions } from './types-BxlzVoRv.mjs';
9
- import { R as RpcContext } from './types-BYqBeqrs.mjs';
10
- export { b as RpcClientOptions, a as RpcServerOptions } from './types-BYqBeqrs.mjs';
7
+ import { H as HttpCtx } from './types-C2SQ9U9V.mjs';
8
+ export { C as CookieSerializeOptions, a as HttpOptions } from './types-C2SQ9U9V.mjs';
9
+ import { R as RpcCtx } from './types-DEQb_e59.mjs';
10
+ export { b as RpcClientOptions, a as RpcServerOptions } from './types-DEQb_e59.mjs';
11
11
  export { Mixin } from 'ts-mixer';
12
12
  import 'node:http';
13
13
 
@@ -102,11 +102,11 @@ interface PipeArg {
102
102
  reflect: any;
103
103
  define: Record<string, any>;
104
104
  }
105
- type GuardType<C extends BaseContext = any> = (ctx: C, next: () => Promise<any>) => any;
106
- type PipeType<C extends BaseContext = any> = (arg: PipeArg, ctx: C) => Promise<any>;
107
- type FilterType<C extends BaseContext = any, E extends Exception = any> = (err: E | Error, ctx?: C) => Error | any;
108
- declare class Context<Data extends BaseContext> {
109
- data: Data;
105
+ type GuardType<Ctx extends BaseCtx = any> = (ctx: Ctx, next: () => Promise<any>) => any;
106
+ type PipeType<Ctx extends BaseCtx = any> = (arg: PipeArg, ctx: Ctx) => Promise<any>;
107
+ type FilterType<Ctx extends BaseCtx = any, E extends Exception = any> = (err: E | Error, ctx?: Ctx) => Error | any;
108
+ declare class Context<Ctx extends BaseCtx> {
109
+ data: Ctx;
110
110
  method: string;
111
111
  params: string[];
112
112
  static filterRecord: Record<PropertyKey, FilterType>;
@@ -119,7 +119,9 @@ declare class Context<Data extends BaseContext> {
119
119
  value: (router: any, framework: string) => any;
120
120
  priority: number;
121
121
  }>;
122
- constructor(data: Data);
122
+ ctx: Ctx;
123
+ protected canGetCtx: boolean;
124
+ constructor(data: Ctx);
123
125
  static getAop(meta: ControllerMeta, opts: DefaultOptions): {
124
126
  guards: GuardType<any>[];
125
127
  pipe: PipeType<any>[];
@@ -135,9 +137,9 @@ declare class Context<Data extends BaseContext> {
135
137
  static getGuards(guards: string[]): GuardType<any>[];
136
138
  static applyAddons(addons: string[], router: any, framework: string): void;
137
139
  }
138
- declare function addPipe<C extends BaseContext>(key: PropertyKey, pipe: PipeType<C>): void;
139
- declare function addFilter<C extends BaseContext>(key: PropertyKey, filter: FilterType<C>): void;
140
- declare function addGuard<C extends BaseContext>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
140
+ declare function addPipe<C extends BaseCtx>(key: PropertyKey, pipe: PipeType<C>): void;
141
+ declare function addFilter<C extends BaseCtx>(key: PropertyKey, filter: FilterType<C>): void;
142
+ declare function addGuard<C extends BaseCtx>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
141
143
  declare function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority?: number): void;
142
144
 
143
145
  declare class RPCGenerator extends Generator {
@@ -197,33 +199,33 @@ interface Logger {
197
199
  declare function setLogger(logger: Logger): void;
198
200
  declare function getLogger(): Logger;
199
201
  declare function log(msg: unknown, level?: LogLevel, ctx?: any): void;
200
- declare function runMiddleware(ctx: HttpContext, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
202
+ declare function runMiddleware(ctx: HttpCtx, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
201
203
 
202
204
  declare class ServerBase extends Base {
203
205
  emitter: Emitter;
204
206
  log(msg: unknown, level?: LogLevel): void;
205
207
  }
206
- declare class HttpBase extends ServerBase {
207
- context: HttpContext;
208
+ declare class HttpBase<Ctx extends HttpCtx = HttpCtx> extends ServerBase {
209
+ context: Ctx;
208
210
  }
209
- declare class RpcBase extends ServerBase {
210
- context: RpcContext;
211
+ declare class RpcBase<Ctx extends RpcCtx = RpcCtx> extends ServerBase {
212
+ context: Ctx;
211
213
  }
212
214
 
213
- declare abstract class PFilter<C extends BaseContext = any, E extends Exception = Exception> extends ServerBase {
215
+ declare abstract class PFilter<Ctx extends BaseCtx = any, E extends Exception = Exception> extends ServerBase {
214
216
  readonly key: PropertyKey;
215
217
  constructor(tag?: string);
216
- abstract use(error: Error | E, ctx?: C): BaseError;
218
+ abstract use(error: Error | E, ctx?: Ctx): BaseError;
217
219
  }
218
220
 
219
- declare abstract class PGuard<C extends BaseContext = any> extends ServerBase {
220
- abstract use(ctx: C, next: () => Promise<any>): any;
221
+ declare abstract class PGuard<Ctx extends BaseCtx = any> extends ServerBase {
222
+ abstract use(ctx: Ctx, next: () => Promise<any>): any;
221
223
  readonly key: PropertyKey;
222
224
  priority: number;
223
225
  constructor(tag?: string);
224
226
  }
225
227
 
226
- declare abstract class PPipe<C extends BaseContext = any> extends ServerBase {
228
+ declare abstract class PPipe<Ctx extends BaseCtx = any> extends ServerBase {
227
229
  readonly key: PropertyKey;
228
230
  constructor(tag?: string);
229
231
  abstract use(param: {
@@ -233,7 +235,7 @@ declare abstract class PPipe<C extends BaseContext = any> extends ServerBase {
233
235
  type: string;
234
236
  index: number;
235
237
  reflect: any;
236
- }, ctx: C): any;
238
+ }, ctx: Ctx): any;
237
239
  }
238
240
 
239
241
  declare abstract class PAddon extends ServerBase {
@@ -243,8 +245,8 @@ declare abstract class PAddon extends ServerBase {
243
245
  abstract use(router: any, framework: string): undefined;
244
246
  }
245
247
 
246
- interface PExtension<C extends BaseContext = any, E extends Exception = Exception> {
247
- guard(ctx: C): Promise<boolean> | boolean;
248
+ interface PExtension<Ctx extends BaseCtx = any, E extends Exception = Exception> {
249
+ guard(ctx: Ctx): Promise<boolean> | boolean;
248
250
  pipe(param: {
249
251
  arg: any;
250
252
  option?: any;
@@ -252,8 +254,8 @@ interface PExtension<C extends BaseContext = any, E extends Exception = Exceptio
252
254
  type: string;
253
255
  index: number;
254
256
  reflect: any;
255
- }, ctx: C): any;
256
- filter(error: Error | E, ctx?: C): BaseError;
257
+ }, ctx: Ctx): any;
258
+ filter(error: Error | E, ctx?: Ctx): BaseError;
257
259
  addon<Addon = any>(framework: string): Addon;
258
260
  }
259
261
  declare class PExtension extends ServerBase {
@@ -263,4 +265,4 @@ declare class PExtension extends ServerBase {
263
265
  constructor(tag?: string);
264
266
  }
265
267
 
266
- export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseContext, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpContext, InvalidInputException, type LogLevel, type Logger, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcContext, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };
268
+ export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseCtx, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpCtx, InvalidInputException, type LogLevel, type Logger, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcCtx, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { B as BaseContext, a as ControllerMeta, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-BTnLXuCa.js';
2
- export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_HMR, k as IS_ONLY_GENERATE, m as IS_READY, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, n as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-BTnLXuCa.js';
3
- import { G as Generator } from './core-CzElxZoF.js';
4
- export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-CzElxZoF.js';
1
+ import { B as BaseCtx, a as ControllerMeta, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-B_HW7cWh.js';
2
+ export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_DEV, k as IS_ONLY_GENERATE, m as IS_READY, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, n as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-B_HW7cWh.js';
3
+ import { G as Generator } from './core-BGEsBtTG.js';
4
+ export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-BGEsBtTG.js';
5
5
  import { Base } from 'phecda-core';
6
6
  export * from 'phecda-core';
7
- import { H as HttpContext } from './types--E-OCZhC.js';
8
- export { C as CookieSerializeOptions, a as HttpOptions } from './types--E-OCZhC.js';
9
- import { R as RpcContext } from './types-CbfaGkPA.js';
10
- export { b as RpcClientOptions, a as RpcServerOptions } from './types-CbfaGkPA.js';
7
+ import { H as HttpCtx } from './types-PFPIQWVF.js';
8
+ export { C as CookieSerializeOptions, a as HttpOptions } from './types-PFPIQWVF.js';
9
+ import { R as RpcCtx } from './types-CYF0vha6.js';
10
+ export { b as RpcClientOptions, a as RpcServerOptions } from './types-CYF0vha6.js';
11
11
  export { Mixin } from 'ts-mixer';
12
12
  import 'node:http';
13
13
 
@@ -102,11 +102,11 @@ interface PipeArg {
102
102
  reflect: any;
103
103
  define: Record<string, any>;
104
104
  }
105
- type GuardType<C extends BaseContext = any> = (ctx: C, next: () => Promise<any>) => any;
106
- type PipeType<C extends BaseContext = any> = (arg: PipeArg, ctx: C) => Promise<any>;
107
- type FilterType<C extends BaseContext = any, E extends Exception = any> = (err: E | Error, ctx?: C) => Error | any;
108
- declare class Context<Data extends BaseContext> {
109
- data: Data;
105
+ type GuardType<Ctx extends BaseCtx = any> = (ctx: Ctx, next: () => Promise<any>) => any;
106
+ type PipeType<Ctx extends BaseCtx = any> = (arg: PipeArg, ctx: Ctx) => Promise<any>;
107
+ type FilterType<Ctx extends BaseCtx = any, E extends Exception = any> = (err: E | Error, ctx?: Ctx) => Error | any;
108
+ declare class Context<Ctx extends BaseCtx> {
109
+ data: Ctx;
110
110
  method: string;
111
111
  params: string[];
112
112
  static filterRecord: Record<PropertyKey, FilterType>;
@@ -119,7 +119,9 @@ declare class Context<Data extends BaseContext> {
119
119
  value: (router: any, framework: string) => any;
120
120
  priority: number;
121
121
  }>;
122
- constructor(data: Data);
122
+ ctx: Ctx;
123
+ protected canGetCtx: boolean;
124
+ constructor(data: Ctx);
123
125
  static getAop(meta: ControllerMeta, opts: DefaultOptions): {
124
126
  guards: GuardType<any>[];
125
127
  pipe: PipeType<any>[];
@@ -135,9 +137,9 @@ declare class Context<Data extends BaseContext> {
135
137
  static getGuards(guards: string[]): GuardType<any>[];
136
138
  static applyAddons(addons: string[], router: any, framework: string): void;
137
139
  }
138
- declare function addPipe<C extends BaseContext>(key: PropertyKey, pipe: PipeType<C>): void;
139
- declare function addFilter<C extends BaseContext>(key: PropertyKey, filter: FilterType<C>): void;
140
- declare function addGuard<C extends BaseContext>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
140
+ declare function addPipe<C extends BaseCtx>(key: PropertyKey, pipe: PipeType<C>): void;
141
+ declare function addFilter<C extends BaseCtx>(key: PropertyKey, filter: FilterType<C>): void;
142
+ declare function addGuard<C extends BaseCtx>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
141
143
  declare function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority?: number): void;
142
144
 
143
145
  declare class RPCGenerator extends Generator {
@@ -197,33 +199,33 @@ interface Logger {
197
199
  declare function setLogger(logger: Logger): void;
198
200
  declare function getLogger(): Logger;
199
201
  declare function log(msg: unknown, level?: LogLevel, ctx?: any): void;
200
- declare function runMiddleware(ctx: HttpContext, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
202
+ declare function runMiddleware(ctx: HttpCtx, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
201
203
 
202
204
  declare class ServerBase extends Base {
203
205
  emitter: Emitter;
204
206
  log(msg: unknown, level?: LogLevel): void;
205
207
  }
206
- declare class HttpBase extends ServerBase {
207
- context: HttpContext;
208
+ declare class HttpBase<Ctx extends HttpCtx = HttpCtx> extends ServerBase {
209
+ context: Ctx;
208
210
  }
209
- declare class RpcBase extends ServerBase {
210
- context: RpcContext;
211
+ declare class RpcBase<Ctx extends RpcCtx = RpcCtx> extends ServerBase {
212
+ context: Ctx;
211
213
  }
212
214
 
213
- declare abstract class PFilter<C extends BaseContext = any, E extends Exception = Exception> extends ServerBase {
215
+ declare abstract class PFilter<Ctx extends BaseCtx = any, E extends Exception = Exception> extends ServerBase {
214
216
  readonly key: PropertyKey;
215
217
  constructor(tag?: string);
216
- abstract use(error: Error | E, ctx?: C): BaseError;
218
+ abstract use(error: Error | E, ctx?: Ctx): BaseError;
217
219
  }
218
220
 
219
- declare abstract class PGuard<C extends BaseContext = any> extends ServerBase {
220
- abstract use(ctx: C, next: () => Promise<any>): any;
221
+ declare abstract class PGuard<Ctx extends BaseCtx = any> extends ServerBase {
222
+ abstract use(ctx: Ctx, next: () => Promise<any>): any;
221
223
  readonly key: PropertyKey;
222
224
  priority: number;
223
225
  constructor(tag?: string);
224
226
  }
225
227
 
226
- declare abstract class PPipe<C extends BaseContext = any> extends ServerBase {
228
+ declare abstract class PPipe<Ctx extends BaseCtx = any> extends ServerBase {
227
229
  readonly key: PropertyKey;
228
230
  constructor(tag?: string);
229
231
  abstract use(param: {
@@ -233,7 +235,7 @@ declare abstract class PPipe<C extends BaseContext = any> extends ServerBase {
233
235
  type: string;
234
236
  index: number;
235
237
  reflect: any;
236
- }, ctx: C): any;
238
+ }, ctx: Ctx): any;
237
239
  }
238
240
 
239
241
  declare abstract class PAddon extends ServerBase {
@@ -243,8 +245,8 @@ declare abstract class PAddon extends ServerBase {
243
245
  abstract use(router: any, framework: string): undefined;
244
246
  }
245
247
 
246
- interface PExtension<C extends BaseContext = any, E extends Exception = Exception> {
247
- guard(ctx: C): Promise<boolean> | boolean;
248
+ interface PExtension<Ctx extends BaseCtx = any, E extends Exception = Exception> {
249
+ guard(ctx: Ctx): Promise<boolean> | boolean;
248
250
  pipe(param: {
249
251
  arg: any;
250
252
  option?: any;
@@ -252,8 +254,8 @@ interface PExtension<C extends BaseContext = any, E extends Exception = Exceptio
252
254
  type: string;
253
255
  index: number;
254
256
  reflect: any;
255
- }, ctx: C): any;
256
- filter(error: Error | E, ctx?: C): BaseError;
257
+ }, ctx: Ctx): any;
258
+ filter(error: Error | E, ctx?: Ctx): BaseError;
257
259
  addon<Addon = any>(framework: string): Addon;
258
260
  }
259
261
  declare class PExtension extends ServerBase {
@@ -263,4 +265,4 @@ declare class PExtension extends ServerBase {
263
265
  constructor(tag?: string);
264
266
  }
265
267
 
266
- export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseContext, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpContext, InvalidInputException, type LogLevel, type Logger, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcContext, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };
268
+ export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseCtx, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpCtx, InvalidInputException, type LogLevel, type Logger, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcCtx, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };