phecda-server 7.0.0-alpha.9 → 7.0.0

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 (154) hide show
  1. package/README.md +10 -10
  2. package/assets/schema.json +12 -9
  3. package/bin/cli.mjs +96 -37
  4. package/dist/chunk-5SUY5UVC.js +258 -0
  5. package/dist/chunk-5SUY5UVC.js.map +1 -0
  6. package/dist/{chunk-7ZGYJ5OW.mjs → chunk-6JAHCTOT.mjs} +7 -2
  7. package/dist/chunk-6JAHCTOT.mjs.map +1 -0
  8. package/dist/{chunk-V5EYXVJT.js → chunk-EDAWJVJ4.js} +42 -25
  9. package/dist/chunk-EDAWJVJ4.js.map +1 -0
  10. package/dist/{chunk-FX3LDQII.js → chunk-H7OCHDZT.js} +61 -70
  11. package/dist/chunk-H7OCHDZT.js.map +1 -0
  12. package/dist/chunk-KRUOHWFR.js +306 -0
  13. package/dist/chunk-KRUOHWFR.js.map +1 -0
  14. package/dist/{chunk-KJUD2BKE.js → chunk-KUGU3UGO.js} +23 -18
  15. package/dist/chunk-KUGU3UGO.js.map +1 -0
  16. package/dist/{chunk-CVPZWDXU.mjs → chunk-LBH4RXQQ.mjs} +11 -20
  17. package/dist/chunk-LBH4RXQQ.mjs.map +1 -0
  18. package/dist/{chunk-FXTJ3BJ6.mjs → chunk-MDPW6WGF.mjs} +10 -4
  19. package/dist/chunk-MDPW6WGF.mjs.map +1 -0
  20. package/dist/{chunk-5RBTN33A.js → chunk-RLFCI3RG.js} +11 -5
  21. package/dist/chunk-RLFCI3RG.js.map +1 -0
  22. package/dist/{chunk-ODVWOXVB.mjs → chunk-TTHYUNOT.mjs} +18 -1
  23. package/dist/chunk-TTHYUNOT.mjs.map +1 -0
  24. package/dist/chunk-VDOICQ2U.mjs +258 -0
  25. package/dist/chunk-VDOICQ2U.mjs.map +1 -0
  26. package/dist/chunk-WTJKTICN.mjs +306 -0
  27. package/dist/chunk-WTJKTICN.mjs.map +1 -0
  28. package/dist/{core-D_cz0tKa.d.ts → core-BOo3uGFX.d.ts} +2 -2
  29. package/dist/{core-BDkhrEyf.d.mts → core-CF45G79J.d.mts} +2 -2
  30. package/dist/core-DbqWh47p.d.mts +50 -0
  31. package/dist/core-Rq7BhPHE.d.ts +50 -0
  32. package/dist/helper.d.mts +3 -5
  33. package/dist/helper.d.ts +3 -5
  34. package/dist/helper.js +4 -5
  35. package/dist/helper.js.map +1 -0
  36. package/dist/helper.mjs +3 -4
  37. package/dist/helper.mjs.map +1 -0
  38. package/dist/http/elysia/index.d.mts +4 -4
  39. package/dist/http/elysia/index.d.ts +4 -4
  40. package/dist/http/elysia/index.js +42 -40
  41. package/dist/http/elysia/index.js.map +1 -0
  42. package/dist/http/elysia/index.mjs +5 -3
  43. package/dist/http/elysia/index.mjs.map +1 -0
  44. package/dist/http/express/index.d.mts +3 -3
  45. package/dist/http/express/index.d.ts +3 -3
  46. package/dist/http/express/index.js +39 -37
  47. package/dist/http/express/index.js.map +1 -0
  48. package/dist/http/express/index.mjs +4 -2
  49. package/dist/http/express/index.mjs.map +1 -0
  50. package/dist/http/fastify/index.d.mts +3 -3
  51. package/dist/http/fastify/index.d.ts +3 -3
  52. package/dist/http/fastify/index.js +40 -38
  53. package/dist/http/fastify/index.js.map +1 -0
  54. package/dist/http/fastify/index.mjs +5 -3
  55. package/dist/http/fastify/index.mjs.map +1 -0
  56. package/dist/http/h3/index.d.mts +3 -3
  57. package/dist/http/h3/index.d.ts +3 -3
  58. package/dist/http/h3/index.js +40 -38
  59. package/dist/http/h3/index.js.map +1 -0
  60. package/dist/http/h3/index.mjs +4 -2
  61. package/dist/http/h3/index.mjs.map +1 -0
  62. package/dist/http/hono/index.d.mts +3 -3
  63. package/dist/http/hono/index.d.ts +3 -3
  64. package/dist/http/hono/index.js +36 -34
  65. package/dist/http/hono/index.js.map +1 -0
  66. package/dist/http/hono/index.mjs +4 -2
  67. package/dist/http/hono/index.mjs.map +1 -0
  68. package/dist/http/hyper-express/index.d.mts +3 -3
  69. package/dist/http/hyper-express/index.d.ts +3 -3
  70. package/dist/http/hyper-express/index.js +37 -35
  71. package/dist/http/hyper-express/index.js.map +1 -0
  72. package/dist/http/hyper-express/index.mjs +4 -2
  73. package/dist/http/hyper-express/index.mjs.map +1 -0
  74. package/dist/http/koa/index.d.mts +3 -3
  75. package/dist/http/koa/index.d.ts +3 -3
  76. package/dist/http/koa/index.js +39 -37
  77. package/dist/http/koa/index.js.map +1 -0
  78. package/dist/http/koa/index.mjs +4 -2
  79. package/dist/http/koa/index.mjs.map +1 -0
  80. package/dist/index.d.mts +76 -12
  81. package/dist/index.d.ts +76 -12
  82. package/dist/index.js +105 -49
  83. package/dist/index.js.map +1 -0
  84. package/dist/index.mjs +68 -12
  85. package/dist/index.mjs.map +1 -0
  86. package/dist/{meta-BX5jhe4Z.d.mts → meta-BoS1E-Nz.d.mts} +6 -23
  87. package/dist/{meta-BX5jhe4Z.d.ts → meta-BoS1E-Nz.d.ts} +6 -23
  88. package/dist/rpc/bullmq/index.d.mts +4 -6
  89. package/dist/rpc/bullmq/index.d.ts +4 -6
  90. package/dist/rpc/bullmq/index.js +13 -80
  91. package/dist/rpc/bullmq/index.js.map +1 -0
  92. package/dist/rpc/bullmq/index.mjs +5 -72
  93. package/dist/rpc/bullmq/index.mjs.map +1 -0
  94. package/dist/rpc/electron/index.d.mts +13 -0
  95. package/dist/rpc/electron/index.d.ts +13 -0
  96. package/dist/rpc/electron/index.js +73 -0
  97. package/dist/rpc/electron/index.js.map +1 -0
  98. package/dist/rpc/electron/index.mjs +73 -0
  99. package/dist/rpc/electron/index.mjs.map +1 -0
  100. package/dist/rpc/kafka/index.d.mts +4 -9
  101. package/dist/rpc/kafka/index.d.ts +4 -9
  102. package/dist/rpc/kafka/index.js +12 -90
  103. package/dist/rpc/kafka/index.js.map +1 -0
  104. package/dist/rpc/kafka/index.mjs +5 -83
  105. package/dist/rpc/kafka/index.mjs.map +1 -0
  106. package/dist/rpc/nats/index.d.mts +4 -6
  107. package/dist/rpc/nats/index.d.ts +4 -6
  108. package/dist/rpc/nats/index.js +13 -72
  109. package/dist/rpc/nats/index.js.map +1 -0
  110. package/dist/rpc/nats/index.mjs +4 -63
  111. package/dist/rpc/nats/index.mjs.map +1 -0
  112. package/dist/rpc/rabbitmq/index.d.mts +4 -6
  113. package/dist/rpc/rabbitmq/index.d.ts +4 -6
  114. package/dist/rpc/rabbitmq/index.js +14 -79
  115. package/dist/rpc/rabbitmq/index.js.map +1 -0
  116. package/dist/rpc/rabbitmq/index.mjs +5 -70
  117. package/dist/rpc/rabbitmq/index.mjs.map +1 -0
  118. package/dist/rpc/redis/index.d.mts +4 -9
  119. package/dist/rpc/redis/index.d.ts +4 -9
  120. package/dist/rpc/redis/index.js +12 -78
  121. package/dist/rpc/redis/index.js.map +1 -0
  122. package/dist/rpc/redis/index.mjs +5 -71
  123. package/dist/rpc/redis/index.mjs.map +1 -0
  124. package/dist/rpc/web-ext/index.d.mts +2 -0
  125. package/dist/rpc/web-ext/index.d.ts +2 -0
  126. package/dist/rpc/web-ext/index.js +1 -0
  127. package/dist/rpc/web-ext/index.js.map +1 -0
  128. package/dist/rpc/web-ext/index.mjs +1 -0
  129. package/dist/rpc/web-ext/index.mjs.map +1 -0
  130. package/dist/rpc/ws/index.d.mts +14 -0
  131. package/dist/rpc/ws/index.d.ts +14 -0
  132. package/dist/rpc/ws/index.js +74 -0
  133. package/dist/rpc/ws/index.js.map +1 -0
  134. package/dist/rpc/ws/index.mjs +74 -0
  135. package/dist/rpc/ws/index.mjs.map +1 -0
  136. package/dist/test.d.mts +7 -3
  137. package/dist/test.d.ts +7 -3
  138. package/dist/test.js +7 -6
  139. package/dist/test.js.map +1 -0
  140. package/dist/test.mjs +3 -2
  141. package/dist/test.mjs.map +1 -0
  142. package/dist/types-CInz3bD0.d.ts +14 -0
  143. package/dist/types-E-rqlg3-.d.mts +14 -0
  144. package/dist/{types-DKVhyZk_.d.mts → types-SCJZFCYt.d.mts} +1 -1
  145. package/dist/{types-CMeuFoyd.d.ts → types-xruyYmyu.d.ts} +1 -1
  146. package/package.json +24 -8
  147. package/register/export.mjs +30 -0
  148. package/register/index.mjs +2 -3
  149. package/register/loader.mjs +83 -90
  150. package/register/utils.mjs +36 -6
  151. package/assets/ps.json +0 -24
  152. package/assets/tsconfig.json +0 -21
  153. package/dist/types-B-rUM9Fm.d.mts +0 -19
  154. package/dist/types-MxxtkZXw.d.ts +0 -19
@@ -4,11 +4,11 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkFX3LDQIIjs = require('../../chunk-FX3LDQII.js');
7
+ var _chunkH7OCHDZTjs = require('../../chunk-H7OCHDZT.js');
8
8
 
9
9
 
10
10
 
11
- var _chunk5RBTN33Ajs = require('../../chunk-5RBTN33A.js');
11
+ var _chunkRLFCI3RGjs = require('../../chunk-RLFCI3RG.js');
12
12
 
13
13
  // src/http/koa/bind.ts
14
14
  var _router = require('@koa/router'); var _router2 = _interopRequireDefault(_router);
@@ -18,14 +18,14 @@ function bind(router, data, opts = {}) {
18
18
  const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
19
19
  const { moduleMap, meta } = data;
20
20
  const originStack = router.stack.slice(0, router.stack.length);
21
- const metaMap = _chunkFX3LDQIIjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
+ const metaMap = _chunkH7OCHDZTjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
22
  const { controller, http, func, tag } = meta2.data;
23
23
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
24
24
  debug(`register method "${func}" in module "${tag}"`);
25
25
  return true;
26
26
  }
27
27
  });
28
- _chunkFX3LDQIIjs.detectAopDep.call(void 0, meta, {
28
+ _chunkH7OCHDZTjs.detectAopDep.call(void 0, meta, {
29
29
  addons: [
30
30
  ...globalAddons,
31
31
  ...parallelAddons
@@ -34,28 +34,29 @@ function bind(router, data, opts = {}) {
34
34
  });
35
35
  registerRoute();
36
36
  function registerRoute() {
37
- _chunkFX3LDQIIjs.Context.applyAddons(globalAddons, router, "koa");
37
+ _chunkH7OCHDZTjs.Context.applyAddons(globalAddons, router, "koa");
38
38
  if (parallelRoute) {
39
39
  const subRouter = new (0, _router2.default)();
40
- _chunkFX3LDQIIjs.Context.applyAddons(parallelAddons, subRouter, "koa");
40
+ _chunkH7OCHDZTjs.Context.applyAddons(parallelAddons, subRouter, "koa");
41
41
  subRouter.post(parallelRoute, async (ctx, next) => {
42
42
  const { body } = ctx.request;
43
43
  async function errorHandler(e) {
44
- const error = await _chunkFX3LDQIIjs.Context.filterRecord.default(e);
44
+ const error = await _chunkH7OCHDZTjs.Context.filterRecord.default(e);
45
45
  ctx.status = error.status;
46
46
  ctx.body = error;
47
47
  }
48
- _chunk5RBTN33Ajs.__name.call(void 0, errorHandler, "errorHandler");
49
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkFX3LDQIIjs.BadRequestException)("data format should be an array"));
48
+ _chunkRLFCI3RGjs.__name.call(void 0, errorHandler, "errorHandler");
49
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkH7OCHDZTjs.BadRequestException)("data format should be an array"));
50
50
  try {
51
51
  return Promise.all(body.map((item, i) => {
52
52
  return new Promise(async (resolve) => {
53
+ if (!item) return resolve(null);
53
54
  const { tag, func } = item;
54
55
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
55
- if (!metaMap.has(tag)) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`module "${tag}" doesn't exist`)));
56
+ if (!metaMap.has(tag)) return resolve(await _chunkH7OCHDZTjs.Context.filterRecord.default(new (0, _chunkH7OCHDZTjs.BadRequestException)(`module "${tag}" doesn't exist`)));
56
57
  const meta2 = metaMap.get(tag)[func];
57
- if (!meta2) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
58
- const aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
58
+ if (!meta2) return resolve(await _chunkH7OCHDZTjs.Context.filterRecord.default(new (0, _chunkH7OCHDZTjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
59
+ const aop = _chunkH7OCHDZTjs.Context.getAop(meta2, {
59
60
  globalGuards,
60
61
  globalFilter,
61
62
  globalPipe
@@ -71,18 +72,18 @@ function bind(router, data, opts = {}) {
71
72
  next,
72
73
  app: router,
73
74
  ...item,
74
- getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
75
- setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
76
- delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
75
+ getCookie: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
76
+ setCookie: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
77
+ delCookie: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
77
78
  expires: /* @__PURE__ */ new Date(0)
78
79
  }), "delCookie"),
79
- redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
80
- setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
81
- setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
82
- getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => ctx.req, "getRequest"),
83
- getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => ctx.res, "getResponse")
80
+ redirect: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
81
+ setResHeaders: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
82
+ setResStatus: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
83
+ getRequest: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, () => ctx.req, "getRequest"),
84
+ getResponse: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, () => ctx.res, "getResponse")
84
85
  };
85
- const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
86
+ const context = new (0, _chunkH7OCHDZTjs.Context)(contextData);
86
87
  context.run(aop, resolve, resolve);
87
88
  });
88
89
  })).then((ret) => {
@@ -101,15 +102,15 @@ function bind(router, data, opts = {}) {
101
102
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
102
103
  let aop;
103
104
  if (!dynamic) {
104
- aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
105
+ aop = _chunkH7OCHDZTjs.Context.getAop(meta2, {
105
106
  globalFilter,
106
107
  globalGuards,
107
108
  globalPipe
108
109
  });
109
110
  }
110
111
  const subRouter = new (0, _router2.default)();
111
- _chunkFX3LDQIIjs.Context.applyAddons(addons, subRouter, "koa");
112
- router[http.type](_chunkFX3LDQIIjs.joinUrl.call(void 0, http.prefix, http.route), async (ctx, next) => {
112
+ _chunkH7OCHDZTjs.Context.applyAddons(addons, subRouter, "koa");
113
+ router[http.type](_chunkH7OCHDZTjs.joinUrl.call(void 0, http.prefix, http.route), async (ctx, next) => {
113
114
  debug(`invoke method "${func}" in module "${tag}"`);
114
115
  const contextData = {
115
116
  type: "koa",
@@ -125,21 +126,21 @@ function bind(router, data, opts = {}) {
125
126
  body: ctx.request.body,
126
127
  headers: ctx.headers,
127
128
  next,
128
- getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
129
- setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
130
- delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
129
+ getCookie: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
130
+ setCookie: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
131
+ delCookie: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
131
132
  expires: /* @__PURE__ */ new Date(0)
132
133
  }), "delCookie"),
133
- redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
134
- setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
135
- setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
136
- getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => ctx.req, "getRequest"),
137
- getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => ctx.res, "getResponse")
134
+ redirect: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
135
+ setResHeaders: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
136
+ setResStatus: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
137
+ getRequest: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, () => ctx.req, "getRequest"),
138
+ getResponse: /* @__PURE__ */ _chunkRLFCI3RGjs.__name.call(void 0, () => ctx.res, "getResponse")
138
139
  };
139
- const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
140
+ const context = new (0, _chunkH7OCHDZTjs.Context)(contextData);
140
141
  if (http.headers) ctx.set(http.headers);
141
142
  if (dynamic) {
142
- aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
143
+ aop = _chunkH7OCHDZTjs.Context.getAop(meta2, {
143
144
  globalFilter,
144
145
  globalGuards,
145
146
  globalPipe
@@ -158,13 +159,14 @@ function bind(router, data, opts = {}) {
158
159
  }
159
160
  }
160
161
  }
161
- _chunk5RBTN33Ajs.__name.call(void 0, registerRoute, "registerRoute");
162
- _chunk5RBTN33Ajs.HMR.call(void 0, async () => {
162
+ _chunkRLFCI3RGjs.__name.call(void 0, registerRoute, "registerRoute");
163
+ _chunkRLFCI3RGjs.HMR.call(void 0, async () => {
163
164
  router.stack = originStack;
164
165
  registerRoute();
165
166
  });
166
167
  }
167
- _chunk5RBTN33Ajs.__name.call(void 0, bind, "bind");
168
+ _chunkRLFCI3RGjs.__name.call(void 0, bind, "bind");
168
169
 
169
170
 
170
171
  exports.bind = bind;
172
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["d:\\myproject\\phecda\\packages\\server\\dist\\http\\koa\\index.js"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACF,0DAAgC;AAChC;AACE;AACA;AACF,0DAAgC;AAChC;AACA;AACA,qFAAgC;AAChC,4EAAyB;AACzB,IAAI,MAAM,EAAE,6BAAK,mBAAoB,CAAC;AACtC,SAAS,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE;AACvC,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,aAAa,EAAE,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC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AAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc;AACd,YAAY,CAAC,CAAC;AACd,UAAU;AACV,UAAU,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,GAAG;AACjD,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM;AAC7C,YAAY,GAAG,CAAC,KAAK,EAAE,UAAU;AACjC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG;AACtB,YAAY,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM;AAC7C,YAAY,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM;AACnC,YAAY,GAAG,CAAC,KAAK,EAAE,GAAG;AAC1B,UAAU,CAAC,CAAC;AACZ,QAAQ,CAAC,CAAC;AACV,QAAQ,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC;AACtE,MAAM;AACN,IAAI;AACJ,EAAE;AACF,EAAE,qCAAM,aAAc,EAAE,eAAe,CAAC;AACxC,EAAE,kCAAG,MAAO,CAAC,EAAE,GAAG;AAClB,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW;AAC9B,IAAI,aAAa,CAAC,CAAC;AACnB,EAAE,CAAC,CAAC;AACJ;AACA,qCAAM,IAAK,EAAE,MAAM,CAAC;AACpB;AACE;AACF,oBAAC","file":"D:\\myproject\\phecda\\packages\\server\\dist\\http\\koa\\index.js","sourcesContent":[null]}
@@ -4,11 +4,11 @@ import {
4
4
  createControllerMetaMap,
5
5
  detectAopDep,
6
6
  joinUrl
7
- } from "../../chunk-CVPZWDXU.mjs";
7
+ } from "../../chunk-LBH4RXQQ.mjs";
8
8
  import {
9
9
  HMR,
10
10
  __name
11
- } from "../../chunk-FXTJ3BJ6.mjs";
11
+ } from "../../chunk-MDPW6WGF.mjs";
12
12
 
13
13
  // src/http/koa/bind.ts
14
14
  import Router from "@koa/router";
@@ -50,6 +50,7 @@ function bind(router, data, opts = {}) {
50
50
  try {
51
51
  return Promise.all(body.map((item, i) => {
52
52
  return new Promise(async (resolve) => {
53
+ if (!item) return resolve(null);
53
54
  const { tag, func } = item;
54
55
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
55
56
  if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
@@ -168,3 +169,4 @@ __name(bind, "bind");
168
169
  export {
169
170
  bind
170
171
  };
172
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/http/koa/bind.ts"],"sourcesContent":["import Router from '@koa/router'\r\nimport type { RouterParamContext } from '@koa/router'\r\nimport type { DefaultContext, DefaultState } from 'koa'\r\nimport Debug from 'debug'\r\nimport type { HttpCtx, HttpOptions } from '../types'\r\n\r\nimport type { Factory } from '../../core'\r\nimport { BadRequestException } from '../../exception'\r\nimport { AOP, Context } from '../../context'\r\n\r\nimport { HMR } from '../../hmr'\r\nimport { createControllerMetaMap, detectAopDep, joinUrl } from '../../helper'\r\n\r\nconst debug = Debug('phecda-server/koa')\r\nexport interface KoaCtx extends HttpCtx {\r\n type: 'koa'\r\n ctx: DefaultContext & RouterParamContext<DefaultState, DefaultContext>\r\n next: Function\r\n app: Router\r\n}\r\n\r\nexport type Addon = Router.Middleware\r\n\r\nexport function bind(router: Router, data: Awaited<ReturnType<typeof Factory>>, opts: HttpOptions = {}) {\r\n const { globalGuards, parallelRoute = '/__PHECDA_SERVER__', globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts\r\n\r\n const { moduleMap, meta } = data\r\n const originStack = router.stack.slice(0, router.stack.length)\r\n\r\n const metaMap = createControllerMetaMap(meta, (meta) => {\r\n const { controller, http, func, tag } = meta.data\r\n if (controller === 'http' && http?.type) {\r\n debug(`register method \"${func}\" in module \"${tag}\"`)\r\n return true\r\n }\r\n })\r\n detectAopDep(meta, {\r\n addons: [...globalAddons, ...parallelAddons],\r\n guards: globalGuards,\r\n })\r\n registerRoute()\r\n function registerRoute() {\r\n Context.applyAddons(globalAddons, router, 'koa')\r\n\r\n if (parallelRoute) {\r\n const subRouter = new Router()\r\n Context.applyAddons(parallelAddons, subRouter, 'koa')\r\n\r\n subRouter.post(parallelRoute, async (ctx, next) => {\r\n const { body } = ctx.request as any\r\n\r\n async function errorHandler(e: any) {\r\n const error = await Context.filterRecord.default(e)\r\n ctx.status = error.status\r\n ctx.body = error\r\n }\r\n\r\n if (!Array.isArray(body))\r\n return errorHandler(new BadRequestException('data format should be an array'))\r\n\r\n try {\r\n return Promise.all(body.map((item: any, i) => {\r\n // eslint-disable-next-line no-async-promise-executor\r\n return new Promise(async (resolve) => {\r\n if (!item)\r\n return resolve(null)\r\n const { tag, func } = item\r\n debug(`(parallel)invoke method \"${func}\" in module \"${tag}\"`)\r\n\r\n if (!metaMap.has(tag))\r\n return resolve(await Context.filterRecord.default(new BadRequestException(`module \"${tag}\" doesn't exist`)))\r\n\r\n const meta = metaMap.get(tag)![func]\r\n if (!meta)\r\n return resolve(await Context.filterRecord.default(new BadRequestException(`\"${func}\" in \"${tag}\" doesn't exist`)))\r\n\r\n const aop = Context.getAop(meta, {\r\n globalGuards, globalFilter, globalPipe,\r\n })\r\n const contextData = {\r\n type: 'koa' as const,\r\n category: 'http',\r\n index: i,\r\n ctx,\r\n meta,\r\n moduleMap,\r\n parallel: true,\r\n next,\r\n app: router,\r\n ...item,\r\n getCookie: key => ctx.cookies.get(key),\r\n setCookie: (key, value, opts) => ctx.cookies.set(key, value, opts),\r\n delCookie: key => ctx.cookies.set(key, '', { expires: new Date(0) }),\r\n redirect: url => ctx.redirect(url),\r\n setResHeaders: headers => ctx.set(headers),\r\n setResStatus: status => ctx.status = status,\r\n getRequest: () => ctx.req,\r\n getResponse: () => ctx.res,\r\n\r\n } as KoaCtx\r\n const context = new Context(contextData)\r\n context.run(aop, resolve, resolve)\r\n })\r\n })).then((ret) => {\r\n ctx.body = ret\r\n })\r\n }\r\n catch (e) {\r\n return errorHandler(e)\r\n }\r\n })\r\n router.use(subRouter.routes()).use(subRouter.allowedMethods())\r\n }\r\n\r\n for (const [tag, record] of metaMap) {\r\n for (const func in record) {\r\n const meta = metaMap.get(tag)![func]\r\n\r\n const {\r\n data: {\r\n addons,\r\n http,\r\n },\r\n } = meta\r\n\r\n if (!http?.type)\r\n continue\r\n\r\n let aop: AOP\r\n if (!dynamic) {\r\n aop = Context.getAop(meta, {\r\n globalFilter,\r\n globalGuards,\r\n globalPipe,\r\n })\r\n }\r\n const subRouter = new Router()\r\n Context.applyAddons(addons, subRouter, 'koa')\r\n\r\n router[http.type](joinUrl(http.prefix, http.route), async (ctx, next) => {\r\n debug(`invoke method \"${func}\" in module \"${tag}\"`)\r\n\r\n const contextData = {\r\n type: 'koa' as const,\r\n app: router,\r\n ctx,\r\n meta,\r\n moduleMap,\r\n tag,\r\n func,\r\n query: ctx.query,\r\n params: ctx.params,\r\n category: 'http',\r\n body: (ctx.request as any).body,\r\n headers: ctx.headers,\r\n next,\r\n getCookie: key => ctx.cookies.get(key),\r\n setCookie: (key, value, opts) => ctx.cookies.set(key, value, opts),\r\n delCookie: key => ctx.cookies.set(key, '', { expires: new Date(0) }),\r\n redirect: url => ctx.redirect(url),\r\n setResHeaders: headers => ctx.set(headers),\r\n setResStatus: status => ctx.status = status,\r\n getRequest: () => ctx.req,\r\n getResponse: () => ctx.res,\r\n } as KoaCtx\r\n const context = new Context(contextData)\r\n if (http.headers)\r\n ctx.set(http.headers)\r\n\r\n if (dynamic) {\r\n aop = Context.getAop(meta, {\r\n globalFilter,\r\n globalGuards,\r\n globalPipe,\r\n })\r\n }\r\n await context.run(aop, (\r\n returnData,\r\n ) => {\r\n if (ctx.res.writableEnded)\r\n return\r\n ctx.body = returnData\r\n }, (err) => {\r\n if (ctx.res.writableEnded)\r\n return\r\n ctx.status = err.status\r\n ctx.body = err\r\n })\r\n })\r\n\r\n router.use(subRouter.routes()).use(subRouter.allowedMethods())\r\n }\r\n }\r\n }\r\n\r\n HMR(async () => {\r\n router.stack = originStack\r\n registerRoute()\r\n })\r\n}\r\n"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,YAAY;AAGnB,OAAOC,WAAW;AAUlB,IAAMC,QAAQC,MAAM,mBAAA;AAUb,SAASC,KAAKC,QAAgBC,MAA2CC,OAAoB,CAAC,GAAC;AACpG,QAAM,EAAEC,cAAcC,gBAAgB,sBAAsBC,eAAe,CAAA,GAAIC,iBAAiB,CAAA,GAAIC,cAAcC,YAAYC,UAAU,MAAK,IAAKP;AAElJ,QAAM,EAAEQ,WAAWC,KAAI,IAAKV;AAC5B,QAAMW,cAAcZ,OAAOa,MAAMC,MAAM,GAAGd,OAAOa,MAAME,MAAM;AAE7D,QAAMC,UAAUC,wBAAwBN,MAAM,CAACA,UAAAA;AAC7C,UAAM,EAAEO,YAAYC,MAAMC,MAAMC,IAAG,IAAKV,MAAKV;AAC7C,QAAIiB,eAAe,UAAUC,MAAMG,MAAM;AACvCzB,YAAM,oBAAoBuB,IAAAA,gBAAoBC,GAAAA,GAAM;AACpD,aAAO;IACT;EACF,CAAA;AACAE,eAAaZ,MAAM;IACjBa,QAAQ;SAAInB;SAAiBC;;IAC7BmB,QAAQtB;EACV,CAAA;AACAuB,gBAAAA;AACA,WAASA,gBAAAA;AACPC,YAAQC,YAAYvB,cAAcL,QAAQ,KAAA;AAE1C,QAAII,eAAe;AACjB,YAAMyB,YAAY,IAAIC,OAAAA;AACtBH,cAAQC,YAAYtB,gBAAgBuB,WAAW,KAAA;AAE/CA,gBAAUE,KAAK3B,eAAe,OAAO4B,KAAKC,SAAAA;AACxC,cAAM,EAAEC,KAAI,IAAKF,IAAIG;AAErB,uBAAeC,aAAaC,GAAM;AAChC,gBAAMC,QAAQ,MAAMX,QAAQY,aAAaC,QAAQH,CAAAA;AACjDL,cAAIS,SAASH,MAAM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A,EAAID,IAAIrD,UAAUuD,eAAc,CAAA;MAC7D;IACF;EACF;AAxJS1D;AA0JToE,MAAI,YAAA;AACF9F,WAAOa,QAAQD;AACfc,kBAAAA;EACF,CAAA;AACF;AAhLgB3B;","names":["Router","Debug","debug","Debug","bind","router","data","opts","globalGuards","parallelRoute","globalAddons","parallelAddons","globalFilter","globalPipe","dynamic","moduleMap","meta","originStack","stack","slice","length","metaMap","createControllerMetaMap","controller","http","func","tag","type","detectAopDep","addons","guards","registerRoute","Context","applyAddons","subRouter","Router","post","ctx","next","body","request","errorHandler","e","error","filterRecord","default","status","Array","isArray","BadRequestException","Promise","all","map","item","i","resolve","has","get","aop","getAop","contextData","category","index","parallel","app","getCookie","key","cookies","setCookie","value","set","delCookie","expires","Date","redirect","url","setResHeaders","headers","setResStatus","getRequest","req","getResponse","res","context","run","then","ret","use","routes","allowedMethods","record","joinUrl","prefix","route","query","params","returnData","writableEnded","err","HMR"]}
package/dist/index.d.mts CHANGED
@@ -1,13 +1,13 @@
1
- import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-BX5jhe4Z.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, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, m as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-BX5jhe4Z.mjs';
3
- import { G as Generator } from './core-BDkhrEyf.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-BDkhrEyf.mjs';
1
+ import { B as BaseCtx, a as ControllerMeta, D as DefaultOptions, b as ControllerMetaData, M as Meta, E as Emitter, c as BaseError } from './meta-BoS1E-Nz.mjs';
2
+ export { d as BaseRequestType, C as CustomResponse, g as ERROR_SYMBOL, e as ExtractResponse, I as IS_DEV, h as IS_ONLY_GENERATE, j as IS_PURE, i as IS_STRICT, L as LOG_LEVEL, f as MetaData, P as PS_EXIT_CODE, S as ServiceMetaData } from './meta-BoS1E-Nz.mjs';
3
+ import { G as Generator } from './core-DbqWh47p.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-DbqWh47p.mjs';
5
5
  import { Base } from 'phecda-core';
6
6
  export * from 'phecda-core';
7
- import { H as HttpCtx } from './types-DKVhyZk_.mjs';
8
- export { C as CookieSerializeOptions, a as HttpOptions } from './types-DKVhyZk_.mjs';
9
- import { R as RpcCtx } from './types-B-rUM9Fm.mjs';
10
- export { b as RpcClientOptions, a as RpcServerOptions } from './types-B-rUM9Fm.mjs';
7
+ import { H as HttpCtx } from './types-SCJZFCYt.mjs';
8
+ export { C as CookieSerializeOptions, a as HttpOptions } from './types-SCJZFCYt.mjs';
9
+ import { R as RpcCtx } from './types-E-rqlg3-.mjs';
10
+ export { a as RpcServerOptions } from './types-E-rqlg3-.mjs';
11
11
  export { Mixin } from 'ts-mixer';
12
12
  import 'node:http';
13
13
 
@@ -120,7 +120,6 @@ declare class Context<Ctx extends BaseCtx> {
120
120
  priority: number;
121
121
  }>;
122
122
  ctx: Ctx;
123
- protected canGetCtx: boolean;
124
123
  constructor(data: Ctx);
125
124
  static getAop(meta: ControllerMeta, opts: DefaultOptions): {
126
125
  guards: GuardType<any>[];
@@ -149,7 +148,7 @@ declare class RPCGenerator extends Generator {
149
148
  }>;
150
149
  getContent(): string;
151
150
  addMethod(args: ControllerMetaData): void;
152
- generateCode(meta: MetaData[]): string;
151
+ generateCode(meta: Meta[]): string;
153
152
  }
154
153
 
155
154
  declare class HTTPGenerator extends Generator {
@@ -159,7 +158,15 @@ declare class HTTPGenerator extends Generator {
159
158
  }>;
160
159
  getContent(): string;
161
160
  addMethod(args: ControllerMetaData): void;
162
- generateCode(meta: MetaData[]): string;
161
+ generateCode(meta: Meta[]): string;
162
+ }
163
+
164
+ declare class OpenAPIGenerator extends Generator {
165
+ name: string;
166
+ paths: Record<string, any>;
167
+ getContent(): string;
168
+ addMethod(args: ControllerMetaData): void;
169
+ generateCode(meta: Meta[]): string;
163
170
  }
164
171
 
165
172
  declare function BaseParam(data: Record<string, any>): ParameterDecorator;
@@ -168,6 +175,8 @@ declare function Head(key: string): ParameterDecorator;
168
175
  declare function Query(key?: string): ParameterDecorator;
169
176
  declare function Param(key: string): ParameterDecorator;
170
177
  declare function Arg(target: any, k: string, index: number): void;
178
+ declare function OneFile(key?: string): ParameterDecorator;
179
+ declare function ManyFiles(key?: string): ParameterDecorator;
171
180
 
172
181
  declare function Guard(...guards: string[]): (target: any, property?: PropertyKey) => void;
173
182
  declare function Addon(...addons: string[]): (target: any, property?: PropertyKey) => void;
@@ -190,6 +199,61 @@ declare function Rpc(): ClassDecorator;
190
199
  declare const Ctx: PropertyDecorator;
191
200
  declare function Define(key: string, value: any): any;
192
201
 
202
+ interface OpenAPIBaseConfig {
203
+ summary?: string;
204
+ description?: string;
205
+ tags?: string[];
206
+ deprecated?: boolean;
207
+ }
208
+ interface OpenAPIParameterConfig {
209
+ name: string;
210
+ in: 'query' | 'header' | 'path' | 'cookie';
211
+ description?: string;
212
+ required?: boolean;
213
+ schema: {
214
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
215
+ items?: any;
216
+ properties?: Record<string, any>;
217
+ };
218
+ }
219
+ interface OpenAPIResponseConfig {
220
+ description: string;
221
+ content?: {
222
+ [key: string]: {
223
+ schema: {
224
+ type: string;
225
+ properties?: Record<string, any>;
226
+ items?: any;
227
+ description?: string;
228
+ };
229
+ };
230
+ };
231
+ }
232
+ interface OpenAPIConfig extends OpenAPIBaseConfig {
233
+ parameters?: OpenAPIParameterConfig[];
234
+ requestBody?: {
235
+ required?: boolean;
236
+ content: {
237
+ [key: string]: {
238
+ schema: {
239
+ type: string;
240
+ properties?: Record<string, any>;
241
+ items?: any;
242
+ [key: string]: any;
243
+ };
244
+ };
245
+ };
246
+ };
247
+ responses?: {
248
+ [statusCode: string]: OpenAPIResponseConfig;
249
+ };
250
+ }
251
+ /**
252
+ * OpenAPI 装饰器函数
253
+ * @param config OpenAPI/Swagger 配置
254
+ */
255
+ declare function ApiDoc(config: OpenAPIConfig): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
256
+
193
257
  declare const defaultPipe: PipeType;
194
258
 
195
259
  type LogLevel = 'error' | 'info' | 'warn' | 'log' | 'debug';
@@ -265,4 +329,4 @@ declare class PExtension extends ServerBase {
265
329
  constructor(tag?: string);
266
330
  }
267
331
 
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 };
332
+ export { type AOP, Addon, ApiDoc, 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, ManyFiles, Meta, NotFoundException, OneFile, type OpenAPIConfig, OpenAPIGenerator, 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 BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-BX5jhe4Z.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, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, m as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-BX5jhe4Z.js';
3
- import { G as Generator } from './core-D_cz0tKa.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-D_cz0tKa.js';
1
+ import { B as BaseCtx, a as ControllerMeta, D as DefaultOptions, b as ControllerMetaData, M as Meta, E as Emitter, c as BaseError } from './meta-BoS1E-Nz.js';
2
+ export { d as BaseRequestType, C as CustomResponse, g as ERROR_SYMBOL, e as ExtractResponse, I as IS_DEV, h as IS_ONLY_GENERATE, j as IS_PURE, i as IS_STRICT, L as LOG_LEVEL, f as MetaData, P as PS_EXIT_CODE, S as ServiceMetaData } from './meta-BoS1E-Nz.js';
3
+ import { G as Generator } from './core-Rq7BhPHE.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-Rq7BhPHE.js';
5
5
  import { Base } from 'phecda-core';
6
6
  export * from 'phecda-core';
7
- import { H as HttpCtx } from './types-CMeuFoyd.js';
8
- export { C as CookieSerializeOptions, a as HttpOptions } from './types-CMeuFoyd.js';
9
- import { R as RpcCtx } from './types-MxxtkZXw.js';
10
- export { b as RpcClientOptions, a as RpcServerOptions } from './types-MxxtkZXw.js';
7
+ import { H as HttpCtx } from './types-xruyYmyu.js';
8
+ export { C as CookieSerializeOptions, a as HttpOptions } from './types-xruyYmyu.js';
9
+ import { R as RpcCtx } from './types-CInz3bD0.js';
10
+ export { a as RpcServerOptions } from './types-CInz3bD0.js';
11
11
  export { Mixin } from 'ts-mixer';
12
12
  import 'node:http';
13
13
 
@@ -120,7 +120,6 @@ declare class Context<Ctx extends BaseCtx> {
120
120
  priority: number;
121
121
  }>;
122
122
  ctx: Ctx;
123
- protected canGetCtx: boolean;
124
123
  constructor(data: Ctx);
125
124
  static getAop(meta: ControllerMeta, opts: DefaultOptions): {
126
125
  guards: GuardType<any>[];
@@ -149,7 +148,7 @@ declare class RPCGenerator extends Generator {
149
148
  }>;
150
149
  getContent(): string;
151
150
  addMethod(args: ControllerMetaData): void;
152
- generateCode(meta: MetaData[]): string;
151
+ generateCode(meta: Meta[]): string;
153
152
  }
154
153
 
155
154
  declare class HTTPGenerator extends Generator {
@@ -159,7 +158,15 @@ declare class HTTPGenerator extends Generator {
159
158
  }>;
160
159
  getContent(): string;
161
160
  addMethod(args: ControllerMetaData): void;
162
- generateCode(meta: MetaData[]): string;
161
+ generateCode(meta: Meta[]): string;
162
+ }
163
+
164
+ declare class OpenAPIGenerator extends Generator {
165
+ name: string;
166
+ paths: Record<string, any>;
167
+ getContent(): string;
168
+ addMethod(args: ControllerMetaData): void;
169
+ generateCode(meta: Meta[]): string;
163
170
  }
164
171
 
165
172
  declare function BaseParam(data: Record<string, any>): ParameterDecorator;
@@ -168,6 +175,8 @@ declare function Head(key: string): ParameterDecorator;
168
175
  declare function Query(key?: string): ParameterDecorator;
169
176
  declare function Param(key: string): ParameterDecorator;
170
177
  declare function Arg(target: any, k: string, index: number): void;
178
+ declare function OneFile(key?: string): ParameterDecorator;
179
+ declare function ManyFiles(key?: string): ParameterDecorator;
171
180
 
172
181
  declare function Guard(...guards: string[]): (target: any, property?: PropertyKey) => void;
173
182
  declare function Addon(...addons: string[]): (target: any, property?: PropertyKey) => void;
@@ -190,6 +199,61 @@ declare function Rpc(): ClassDecorator;
190
199
  declare const Ctx: PropertyDecorator;
191
200
  declare function Define(key: string, value: any): any;
192
201
 
202
+ interface OpenAPIBaseConfig {
203
+ summary?: string;
204
+ description?: string;
205
+ tags?: string[];
206
+ deprecated?: boolean;
207
+ }
208
+ interface OpenAPIParameterConfig {
209
+ name: string;
210
+ in: 'query' | 'header' | 'path' | 'cookie';
211
+ description?: string;
212
+ required?: boolean;
213
+ schema: {
214
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
215
+ items?: any;
216
+ properties?: Record<string, any>;
217
+ };
218
+ }
219
+ interface OpenAPIResponseConfig {
220
+ description: string;
221
+ content?: {
222
+ [key: string]: {
223
+ schema: {
224
+ type: string;
225
+ properties?: Record<string, any>;
226
+ items?: any;
227
+ description?: string;
228
+ };
229
+ };
230
+ };
231
+ }
232
+ interface OpenAPIConfig extends OpenAPIBaseConfig {
233
+ parameters?: OpenAPIParameterConfig[];
234
+ requestBody?: {
235
+ required?: boolean;
236
+ content: {
237
+ [key: string]: {
238
+ schema: {
239
+ type: string;
240
+ properties?: Record<string, any>;
241
+ items?: any;
242
+ [key: string]: any;
243
+ };
244
+ };
245
+ };
246
+ };
247
+ responses?: {
248
+ [statusCode: string]: OpenAPIResponseConfig;
249
+ };
250
+ }
251
+ /**
252
+ * OpenAPI 装饰器函数
253
+ * @param config OpenAPI/Swagger 配置
254
+ */
255
+ declare function ApiDoc(config: OpenAPIConfig): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
256
+
193
257
  declare const defaultPipe: PipeType;
194
258
 
195
259
  type LogLevel = 'error' | 'info' | 'warn' | 'log' | 'debug';
@@ -265,4 +329,4 @@ declare class PExtension extends ServerBase {
265
329
  constructor(tag?: string);
266
330
  }
267
331
 
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 };
332
+ export { type AOP, Addon, ApiDoc, 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, ManyFiles, Meta, NotFoundException, OneFile, type OpenAPIConfig, OpenAPIGenerator, 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 };