phecda-server 8.5.4 → 8.7.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 (92) hide show
  1. package/bin/cli.mjs +1 -9
  2. package/dist/{chunk-76UDKZOJ.js → chunk-CCK6KDM3.js} +120 -76
  3. package/dist/{chunk-LLF55NZP.js → chunk-IBVPZSZJ.js} +6 -6
  4. package/dist/{chunk-URKOYTBU.mjs → chunk-ITDH2YDL.mjs} +6 -6
  5. package/dist/{chunk-5ZZAOOKE.js → chunk-KVWT2QTL.js} +26 -26
  6. package/dist/{chunk-WST6E6MQ.mjs → chunk-LNL3MVTR.mjs} +71 -27
  7. package/dist/{chunk-ZHNYWZRL.mjs → chunk-T5F6Q2CZ.mjs} +1 -1
  8. package/dist/{chunk-MUUKKO67.mjs → chunk-UK3RDUEP.mjs} +1 -1
  9. package/dist/{chunk-SKGOTR4T.js → chunk-UP64TNWR.js} +20 -20
  10. package/dist/{core-BiS3xJKx.d.ts → core-Bd2ynlyb.d.ts} +1 -1
  11. package/dist/{core-BYxcQ8kf.d.mts → core-nqk9d66O.d.mts} +1 -1
  12. package/dist/helper.d.mts +1 -1
  13. package/dist/helper.d.ts +1 -1
  14. package/dist/helper.js +3 -3
  15. package/dist/helper.mjs +2 -2
  16. package/dist/http/elysia/index.d.mts +3 -3
  17. package/dist/http/elysia/index.d.ts +3 -3
  18. package/dist/http/elysia/index.js +40 -40
  19. package/dist/http/elysia/index.mjs +3 -3
  20. package/dist/http/express/index.d.mts +3 -3
  21. package/dist/http/express/index.d.ts +3 -3
  22. package/dist/http/express/index.js +37 -37
  23. package/dist/http/express/index.mjs +2 -2
  24. package/dist/http/fastify/index.d.mts +3 -3
  25. package/dist/http/fastify/index.d.ts +3 -3
  26. package/dist/http/fastify/index.js +38 -38
  27. package/dist/http/fastify/index.mjs +3 -3
  28. package/dist/http/h3/index.d.mts +3 -3
  29. package/dist/http/h3/index.d.ts +3 -3
  30. package/dist/http/h3/index.js +38 -38
  31. package/dist/http/h3/index.mjs +2 -2
  32. package/dist/http/hono/index.d.mts +3 -3
  33. package/dist/http/hono/index.d.ts +3 -3
  34. package/dist/http/hono/index.js +34 -34
  35. package/dist/http/hono/index.mjs +2 -2
  36. package/dist/http/hyper-express/index.d.mts +3 -3
  37. package/dist/http/hyper-express/index.d.ts +3 -3
  38. package/dist/http/hyper-express/index.js +35 -35
  39. package/dist/http/hyper-express/index.mjs +2 -2
  40. package/dist/http/koa/index.d.mts +3 -3
  41. package/dist/http/koa/index.d.ts +3 -3
  42. package/dist/http/koa/index.js +37 -37
  43. package/dist/http/koa/index.mjs +2 -2
  44. package/dist/index.d.mts +8 -8
  45. package/dist/index.d.ts +8 -8
  46. package/dist/index.js +54 -54
  47. package/dist/index.mjs +19 -19
  48. package/dist/{meta-Csp1xcSR.d.mts → meta-ZbvaS7xK.d.mts} +2 -2
  49. package/dist/{meta-Csp1xcSR.d.ts → meta-ZbvaS7xK.d.ts} +2 -2
  50. package/dist/rpc/bullmq/index.d.mts +3 -3
  51. package/dist/rpc/bullmq/index.d.ts +3 -3
  52. package/dist/rpc/bullmq/index.js +11 -11
  53. package/dist/rpc/bullmq/index.mjs +2 -2
  54. package/dist/rpc/electron/index.d.mts +3 -3
  55. package/dist/rpc/electron/index.d.ts +3 -3
  56. package/dist/rpc/electron/index.js +8 -8
  57. package/dist/rpc/electron/index.mjs +2 -2
  58. package/dist/rpc/kafka/index.d.mts +3 -3
  59. package/dist/rpc/kafka/index.d.ts +3 -3
  60. package/dist/rpc/kafka/index.js +10 -10
  61. package/dist/rpc/kafka/index.mjs +2 -2
  62. package/dist/rpc/nats/index.d.mts +3 -3
  63. package/dist/rpc/nats/index.d.ts +3 -3
  64. package/dist/rpc/nats/index.js +11 -11
  65. package/dist/rpc/nats/index.mjs +2 -2
  66. package/dist/rpc/rabbitmq/index.d.mts +3 -3
  67. package/dist/rpc/rabbitmq/index.d.ts +3 -3
  68. package/dist/rpc/rabbitmq/index.js +12 -12
  69. package/dist/rpc/rabbitmq/index.mjs +2 -2
  70. package/dist/rpc/redis/index.d.mts +3 -3
  71. package/dist/rpc/redis/index.d.ts +3 -3
  72. package/dist/rpc/redis/index.js +10 -10
  73. package/dist/rpc/redis/index.mjs +2 -2
  74. package/dist/rpc/web-ext/index.d.mts +3 -3
  75. package/dist/rpc/web-ext/index.d.ts +3 -3
  76. package/dist/rpc/web-ext/index.js +8 -8
  77. package/dist/rpc/web-ext/index.mjs +2 -2
  78. package/dist/rpc/ws/index.d.mts +3 -3
  79. package/dist/rpc/ws/index.d.ts +3 -3
  80. package/dist/rpc/ws/index.js +7 -7
  81. package/dist/rpc/ws/index.mjs +2 -2
  82. package/dist/test.d.mts +2 -2
  83. package/dist/test.d.ts +2 -2
  84. package/dist/test.js +6 -6
  85. package/dist/test.mjs +2 -2
  86. package/dist/{types-Bs64nYvd.d.ts → types-B4zY7i87.d.ts} +1 -1
  87. package/dist/{types-CjVwVyJT.d.mts → types-BfcBZVua.d.mts} +1 -1
  88. package/dist/{types-DExQe0qk.d.ts → types-CHWgzilt.d.ts} +1 -1
  89. package/dist/{types-DSlyrmns.d.mts → types-f_hV_rCD.d.mts} +1 -1
  90. package/package.json +2 -2
  91. package/register/index.mjs +2 -0
  92. package/register/loader.mjs +3 -3
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkLLF55NZPjs = require('./chunk-LLF55NZP.js');
3
+ var _chunkIBVPZSZJjs = require('./chunk-IBVPZSZJ.js');
4
4
 
5
5
  // src/decorators/param.ts
6
6
  var _phecdacore = require('phecda-core');
@@ -10,49 +10,49 @@ function BaseParam(data) {
10
10
  _phecdacore.setMeta.call(void 0, target, property, index, data);
11
11
  };
12
12
  }
13
- _chunkLLF55NZPjs.__name.call(void 0, BaseParam, "BaseParam");
13
+ _chunkIBVPZSZJjs.__name.call(void 0, BaseParam, "BaseParam");
14
14
  function Body(key = "") {
15
15
  return BaseParam({
16
16
  type: "body",
17
17
  key
18
18
  });
19
19
  }
20
- _chunkLLF55NZPjs.__name.call(void 0, Body, "Body");
20
+ _chunkIBVPZSZJjs.__name.call(void 0, Body, "Body");
21
21
  function Head(key) {
22
22
  return BaseParam({
23
23
  type: "headers",
24
24
  key: key.toLowerCase()
25
25
  });
26
26
  }
27
- _chunkLLF55NZPjs.__name.call(void 0, Head, "Head");
27
+ _chunkIBVPZSZJjs.__name.call(void 0, Head, "Head");
28
28
  function Query(key = "") {
29
29
  return BaseParam({
30
30
  type: "query",
31
31
  key
32
32
  });
33
33
  }
34
- _chunkLLF55NZPjs.__name.call(void 0, Query, "Query");
34
+ _chunkIBVPZSZJjs.__name.call(void 0, Query, "Query");
35
35
  function Param(key) {
36
36
  return BaseParam({
37
37
  type: "params",
38
38
  key
39
39
  });
40
40
  }
41
- _chunkLLF55NZPjs.__name.call(void 0, Param, "Param");
41
+ _chunkIBVPZSZJjs.__name.call(void 0, Param, "Param");
42
42
  function Arg(target, k, index) {
43
43
  BaseParam({
44
44
  type: "args",
45
45
  key: `${index}`
46
46
  })(target, k, index);
47
47
  }
48
- _chunkLLF55NZPjs.__name.call(void 0, Arg, "Arg");
48
+ _chunkIBVPZSZJjs.__name.call(void 0, Arg, "Arg");
49
49
  function UploadFile(key = "") {
50
50
  return BaseParam({
51
51
  type: "file",
52
52
  key
53
53
  });
54
54
  }
55
- _chunkLLF55NZPjs.__name.call(void 0, UploadFile, "UploadFile");
55
+ _chunkIBVPZSZJjs.__name.call(void 0, UploadFile, "UploadFile");
56
56
 
57
57
  // src/decorators/aop.ts
58
58
 
@@ -63,7 +63,7 @@ function Guard(...guards) {
63
63
  });
64
64
  };
65
65
  }
66
- _chunkLLF55NZPjs.__name.call(void 0, Guard, "Guard");
66
+ _chunkIBVPZSZJjs.__name.call(void 0, Guard, "Guard");
67
67
  function Addon(...addons) {
68
68
  return (target, property) => {
69
69
  _phecdacore.setMeta.call(void 0, target, property, void 0, {
@@ -71,7 +71,7 @@ function Addon(...addons) {
71
71
  });
72
72
  };
73
73
  }
74
- _chunkLLF55NZPjs.__name.call(void 0, Addon, "Addon");
74
+ _chunkIBVPZSZJjs.__name.call(void 0, Addon, "Addon");
75
75
  function Filter(filter) {
76
76
  return (target, property) => {
77
77
  _phecdacore.setMeta.call(void 0, target, property, void 0, {
@@ -79,7 +79,7 @@ function Filter(filter) {
79
79
  });
80
80
  };
81
81
  }
82
- _chunkLLF55NZPjs.__name.call(void 0, Filter, "Filter");
82
+ _chunkIBVPZSZJjs.__name.call(void 0, Filter, "Filter");
83
83
  function Pipe(pipe) {
84
84
  return (target, property, index) => {
85
85
  if (typeof index === "number") {
@@ -93,7 +93,7 @@ function Pipe(pipe) {
93
93
  });
94
94
  };
95
95
  }
96
- _chunkLLF55NZPjs.__name.call(void 0, Pipe, "Pipe");
96
+ _chunkIBVPZSZJjs.__name.call(void 0, Pipe, "Pipe");
97
97
 
98
98
  // src/decorators/http.ts
99
99
 
@@ -107,7 +107,7 @@ function Route(route, method) {
107
107
  });
108
108
  };
109
109
  }
110
- _chunkLLF55NZPjs.__name.call(void 0, Route, "Route");
110
+ _chunkIBVPZSZJjs.__name.call(void 0, Route, "Route");
111
111
  function Header(headers) {
112
112
  return (target, property) => {
113
113
  _phecdacore.setMeta.call(void 0, target, property, void 0, {
@@ -117,31 +117,31 @@ function Header(headers) {
117
117
  });
118
118
  };
119
119
  }
120
- _chunkLLF55NZPjs.__name.call(void 0, Header, "Header");
120
+ _chunkIBVPZSZJjs.__name.call(void 0, Header, "Header");
121
121
  function Get(route = "") {
122
122
  return Route(route, "get");
123
123
  }
124
- _chunkLLF55NZPjs.__name.call(void 0, Get, "Get");
124
+ _chunkIBVPZSZJjs.__name.call(void 0, Get, "Get");
125
125
  function Post(route = "") {
126
126
  return Route(route, "post");
127
127
  }
128
- _chunkLLF55NZPjs.__name.call(void 0, Post, "Post");
128
+ _chunkIBVPZSZJjs.__name.call(void 0, Post, "Post");
129
129
  function Put(route = "") {
130
130
  return Route(route, "put");
131
131
  }
132
- _chunkLLF55NZPjs.__name.call(void 0, Put, "Put");
132
+ _chunkIBVPZSZJjs.__name.call(void 0, Put, "Put");
133
133
  function Search(route = "") {
134
134
  return Route(route, "search");
135
135
  }
136
- _chunkLLF55NZPjs.__name.call(void 0, Search, "Search");
136
+ _chunkIBVPZSZJjs.__name.call(void 0, Search, "Search");
137
137
  function Patch(route = "") {
138
138
  return Route(route, "patch");
139
139
  }
140
- _chunkLLF55NZPjs.__name.call(void 0, Patch, "Patch");
140
+ _chunkIBVPZSZJjs.__name.call(void 0, Patch, "Patch");
141
141
  function Delete(route = "") {
142
142
  return Route(route, "delete");
143
143
  }
144
- _chunkLLF55NZPjs.__name.call(void 0, Delete, "Delete");
144
+ _chunkIBVPZSZJjs.__name.call(void 0, Delete, "Delete");
145
145
  function Controller(prefix = "") {
146
146
  return (target) => {
147
147
  _phecdacore.setMeta.call(void 0, target, void 0, void 0, {
@@ -152,7 +152,7 @@ function Controller(prefix = "") {
152
152
  });
153
153
  };
154
154
  }
155
- _chunkLLF55NZPjs.__name.call(void 0, Controller, "Controller");
155
+ _chunkIBVPZSZJjs.__name.call(void 0, Controller, "Controller");
156
156
 
157
157
  // src/decorators/rpc.ts
158
158
 
@@ -166,7 +166,7 @@ function Queue(queue = "", isEvent) {
166
166
  });
167
167
  };
168
168
  }
169
- _chunkLLF55NZPjs.__name.call(void 0, Queue, "Queue");
169
+ _chunkIBVPZSZJjs.__name.call(void 0, Queue, "Queue");
170
170
  function Rpc() {
171
171
  return (target) => {
172
172
  _phecdacore.setMeta.call(void 0, target, void 0, void 0, {
@@ -174,11 +174,11 @@ function Rpc() {
174
174
  });
175
175
  };
176
176
  }
177
- _chunkLLF55NZPjs.__name.call(void 0, Rpc, "Rpc");
177
+ _chunkIBVPZSZJjs.__name.call(void 0, Rpc, "Rpc");
178
178
 
179
179
  // src/decorators/ctx.ts
180
180
 
181
- var Ctx = /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (target, property) => {
181
+ var Ctx = /* @__PURE__ */ _chunkIBVPZSZJjs.__name.call(void 0, (target, property) => {
182
182
  _phecdacore.setMeta.call(void 0, target, _phecdacore.SHARE_KEY, void 0, {
183
183
  ctxs: [
184
184
  property
@@ -207,7 +207,7 @@ function Define(key, value) {
207
207
  }
208
208
  };
209
209
  }
210
- _chunkLLF55NZPjs.__name.call(void 0, Define, "Define");
210
+ _chunkIBVPZSZJjs.__name.call(void 0, Define, "Define");
211
211
 
212
212
  // src/decorators/openapi.ts
213
213
 
@@ -218,7 +218,7 @@ function ApiDoc(config) {
218
218
  });
219
219
  };
220
220
  }
221
- _chunkLLF55NZPjs.__name.call(void 0, ApiDoc, "ApiDoc");
221
+ _chunkIBVPZSZJjs.__name.call(void 0, ApiDoc, "ApiDoc");
222
222
 
223
223
 
224
224
 
@@ -1,13 +1,12 @@
1
1
  import {
2
2
  ERROR_SYMBOL,
3
3
  HMR,
4
- IS_DEV,
5
4
  IS_PURE,
6
5
  IS_STRICT,
7
6
  LOG_LEVEL,
8
7
  __name,
9
8
  log
10
- } from "./chunk-URKOYTBU.mjs";
9
+ } from "./chunk-ITDH2YDL.mjs";
11
10
 
12
11
  // src/helper.ts
13
12
  import pc2 from "picocolors";
@@ -17,7 +16,7 @@ import Debug from "debug";
17
16
  import pc from "picocolors";
18
17
 
19
18
  // src/pipe.ts
20
- import { isPhecda, validate } from "phecda-core";
19
+ import { extractDataByRules, extractRules, isPhecda, validateWithRules } from "phecda-core";
21
20
 
22
21
  // src/exception/base.ts
23
22
  var Exception = class extends Error {
@@ -202,7 +201,63 @@ var WorkerException = class extends Exception {
202
201
  };
203
202
 
204
203
  // src/pipe.ts
205
- var defaultPipe = /* @__PURE__ */ __name(async ({ arg, reflect, meta, index, type }, { method }) => {
204
+ var modelRulesCache = /* @__PURE__ */ new WeakMap();
205
+ function isPlainObject(value) {
206
+ return Object.prototype.toString.call(value) === "[object Object]";
207
+ }
208
+ __name(isPlainObject, "isPlainObject");
209
+ function convertForRequestInput(value, type, index) {
210
+ if (value === void 0) return value;
211
+ if (type === Number && typeof value === "string") {
212
+ const num = Number(value);
213
+ if (Number.isNaN(num)) throw new ValidateException(`param ${index + 1} is not a number`);
214
+ return num;
215
+ }
216
+ if (type === Boolean && typeof value === "string") {
217
+ if (value === "true") return true;
218
+ if (value === "false") return false;
219
+ throw new ValidateException(`param ${index + 1} is not a boolean`);
220
+ }
221
+ return value;
222
+ }
223
+ __name(convertForRequestInput, "convertForRequestInput");
224
+ function isStrTypeParam(type) {
225
+ return [
226
+ "params",
227
+ "query",
228
+ "headers"
229
+ ].includes(type);
230
+ }
231
+ __name(isStrTypeParam, "isStrTypeParam");
232
+ function convertExtractedDataByRules(data, rules, index) {
233
+ if (!data || typeof data !== "object") return data;
234
+ for (const rule of rules) {
235
+ if (!rule.property) continue;
236
+ if (rule.property.includes(".") || rule.property.includes("[]")) throw new ValidateException("default pipe only supports simple shallow phecda class for query/params/headers; please use custom pipe for nested data");
237
+ data[rule.property] = convertForRequestInput(data[rule.property], rule.designType, index);
238
+ }
239
+ return data;
240
+ }
241
+ __name(convertExtractedDataByRules, "convertExtractedDataByRules");
242
+ function getModelRules(model) {
243
+ const cached = modelRulesCache.get(model);
244
+ if (cached) return cached;
245
+ const rules = extractRules(model);
246
+ modelRulesCache.set(model, rules);
247
+ return rules;
248
+ }
249
+ __name(getModelRules, "getModelRules");
250
+ async function validatePhecdaByRules(model, input, shouldConvert, index) {
251
+ if (!isPlainObject(input)) throw new ValidateException("data must be an object");
252
+ const rules = getModelRules(model);
253
+ let data = extractDataByRules(input, rules);
254
+ if (shouldConvert) data = convertExtractedDataByRules(data, rules, index);
255
+ const errs = await validateWithRules(data, rules);
256
+ if (errs.length) throw new ValidateException(errs[0]);
257
+ return data;
258
+ }
259
+ __name(validatePhecdaByRules, "validatePhecdaByRules");
260
+ var defaultPipe = /* @__PURE__ */ __name(async ({ arg, reflect, meta, index, type, key }, { method }) => {
206
261
  if (meta.const) {
207
262
  if (arg !== meta.const) throw new ValidateException(`param ${index + 1} must be ${meta.const}`);
208
263
  }
@@ -210,19 +265,13 @@ var defaultPipe = /* @__PURE__ */ __name(async ({ arg, reflect, meta, index, typ
210
265
  if (meta.required === false) return arg;
211
266
  else throw new ValidateException(`param ${index + 1} is required`);
212
267
  }
213
- if ([
214
- "params",
215
- "query"
216
- ].includes(type)) {
217
- if (reflect === Number) {
218
- arg = reflect(arg);
219
- if (isNaN(arg)) throw new ValidateException(`param ${index + 1} is not a number`);
220
- } else if (reflect === Boolean) {
221
- if (arg === "false") arg = false;
222
- else if (arg === "true") arg = true;
223
- else throw new ValidateException(`param ${index + 1} is not a boolean`);
224
- }
225
- } else {
268
+ const isModel = isPhecda(reflect);
269
+ const isStrType = isStrTypeParam(type);
270
+ const canUseShallowModelConvert = isStrType && !key;
271
+ if (isModel && isStrType && key) throw new ValidateException("phecda class cannot be used with specified field in query/params/headers in default pipe");
272
+ if (!isModel && isStrType) {
273
+ arg = convertForRequestInput(arg, reflect, index);
274
+ } else if (!isModel) {
226
275
  if (reflect === Number && typeof arg !== "number") throw new ValidateException(`param ${index + 1} is not a number`);
227
276
  if (reflect === Boolean && typeof arg !== "boolean") throw new ValidateException(`param ${index + 1} is not a boolean`);
228
277
  if (reflect === String && typeof arg !== "string") throw new ValidateException(`param ${index + 1} is not a string`);
@@ -245,11 +294,12 @@ var defaultPipe = /* @__PURE__ */ __name(async ({ arg, reflect, meta, index, typ
245
294
  break;
246
295
  default:
247
296
  if (isPhecda(item)) {
248
- const errs = await validate(item, arg);
249
- if (!errs.length) {
297
+ try {
298
+ await validatePhecdaByRules(item, arg, canUseShallowModelConvert, index);
250
299
  isCorrect = true;
251
- break;
300
+ } catch {
252
301
  }
302
+ if (isCorrect) break;
253
303
  } else if (typeof item === "function") {
254
304
  const ret = await item(arg);
255
305
  if (ret) {
@@ -278,10 +328,7 @@ var defaultPipe = /* @__PURE__ */ __name(async ({ arg, reflect, meta, index, typ
278
328
  if (err.length > 0) throw new ValidateException(err[0]);
279
329
  }
280
330
  }
281
- if (isPhecda(reflect)) {
282
- const errs = await validate(reflect, arg);
283
- if (errs.length) throw new ValidateException(errs[0]);
284
- }
331
+ if (isModel) arg = await validatePhecdaByRules(reflect, arg, canUseShallowModelConvert, index);
285
332
  return arg;
286
333
  }, "defaultPipe");
287
334
 
@@ -316,11 +363,8 @@ var Context = class _Context {
316
363
  static guardRecord = {};
317
364
  static addonRecord = {};
318
365
  ctx;
319
- // protected canGetCtx = true
320
366
  constructor(data) {
321
367
  this.data = data;
322
- if (IS_DEV)
323
- data._context = this;
324
368
  this.ctx = new Proxy(data, {
325
369
  get(target, p) {
326
370
  if (!(p in target)) log(`attribute "${p}" does not exist on ctx, which might be due to a missing AOP role (such as a guard).`, "warn", data.tag);
@@ -4,7 +4,7 @@ import {
4
4
  PS_EXIT_CODE,
5
5
  __name,
6
6
  log
7
- } from "./chunk-URKOYTBU.mjs";
7
+ } from "./chunk-ITDH2YDL.mjs";
8
8
 
9
9
  // src/meta.ts
10
10
  var Meta = class {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-URKOYTBU.mjs";
3
+ } from "./chunk-ITDH2YDL.mjs";
4
4
 
5
5
  // src/decorators/param.ts
6
6
  import { setMeta } from "phecda-core";
@@ -4,12 +4,12 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkLLF55NZPjs = require('./chunk-LLF55NZP.js');
7
+ var _chunkIBVPZSZJjs = require('./chunk-IBVPZSZJ.js');
8
8
 
9
9
  // src/meta.ts
10
10
  var Meta = class {
11
11
  static {
12
- _chunkLLF55NZPjs.__name.call(void 0, this, "Meta");
12
+ _chunkIBVPZSZJjs.__name.call(void 0, this, "Meta");
13
13
  }
14
14
 
15
15
 
@@ -41,11 +41,11 @@ function defaultServerInject() {
41
41
  });
42
42
  }
43
43
  }
44
- _chunkLLF55NZPjs.__name.call(void 0, defaultServerInject, "defaultServerInject");
44
+ _chunkIBVPZSZJjs.__name.call(void 0, defaultServerInject, "defaultServerInject");
45
45
  var phecdaNamespace = /* @__PURE__ */ new Map();
46
46
  var ServerPhecda = (_class = class {
47
47
  static {
48
- _chunkLLF55NZPjs.__name.call(void 0, this, "ServerPhecda");
48
+ _chunkIBVPZSZJjs.__name.call(void 0, this, "ServerPhecda");
49
49
  }
50
50
  __init() {this.moduleMap = /* @__PURE__ */ new Map()}
51
51
  __init2() {this.meta = []}
@@ -57,7 +57,7 @@ var ServerPhecda = (_class = class {
57
57
 
58
58
  constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);
59
59
  defaultServerInject();
60
- const { namespace = "default", parseModule = /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
60
+ const { namespace = "default", parseModule = /* @__PURE__ */ _chunkIBVPZSZJjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkIBVPZSZJjs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
61
61
  phecdaNamespace.set(namespace, this);
62
62
  this.parseMeta = parseMeta;
63
63
  this.parseModule = parseModule;
@@ -67,20 +67,20 @@ var ServerPhecda = (_class = class {
67
67
  for (const model of models) await this.buildDepModule(model);
68
68
  this.hmr();
69
69
  this.generateCode().then(() => {
70
- if (_chunkLLF55NZPjs.IS_ONLY_GENERATE) {
71
- _chunkLLF55NZPjs.log.call(void 0, "Only generate code");
72
- process.exit(_chunkLLF55NZPjs.PS_EXIT_CODE.EXIT);
70
+ if (_chunkIBVPZSZJjs.IS_ONLY_GENERATE) {
71
+ _chunkIBVPZSZJjs.log.call(void 0, "Only generate code");
72
+ process.exit(_chunkIBVPZSZJjs.PS_EXIT_CODE.EXIT);
73
73
  }
74
74
  });
75
75
  }
76
- __init6() {this.generateCode = /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, async () => {
76
+ __init6() {this.generateCode = /* @__PURE__ */ _chunkIBVPZSZJjs.__name.call(void 0, async () => {
77
77
  return Promise.all(this.generators.map((generator) => {
78
78
  debug(`generate "${generator.name}" code to ${generator.path}`);
79
79
  return generator.output(this.meta);
80
80
  }));
81
81
  }, "generateCode")}
82
82
  hmr() {
83
- _chunkLLF55NZPjs.HMR.call(void 0, async (oldModels, newModels) => {
83
+ _chunkIBVPZSZJjs.HMR.call(void 0, async (oldModels, newModels) => {
84
84
  debug("reload models ");
85
85
  await this.replace(oldModels, newModels);
86
86
  this.generateCode();
@@ -122,7 +122,7 @@ var ServerPhecda = (_class = class {
122
122
  if (this.moduleMap.has(tag)) {
123
123
  module = this.moduleMap.get(tag);
124
124
  if (!module) {
125
- _chunkLLF55NZPjs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
125
+ _chunkIBVPZSZJjs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
126
126
  return {
127
127
  module: this.createProxyModule(tag),
128
128
  tag
@@ -130,8 +130,8 @@ var ServerPhecda = (_class = class {
130
130
  }
131
131
  if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {
132
132
  this.modelSet.add(Model);
133
- if (module instanceof Model) _chunkLLF55NZPjs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
134
- else _chunkLLF55NZPjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
133
+ if (module instanceof Model) _chunkIBVPZSZJjs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
134
+ else _chunkIBVPZSZJjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
135
135
  }
136
136
  return {
137
137
  module,
@@ -154,7 +154,7 @@ var ServerPhecda = (_class = class {
154
154
  }
155
155
  this.meta.push(...getMetaFromInstance(module, tag, Model).map(this.parseMeta).filter((item) => !!item));
156
156
  debug(`init module "${String(tag)}"`);
157
- if (!_chunkLLF55NZPjs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
157
+ if (!_chunkIBVPZSZJjs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
158
158
  debug(`add module "${String(tag)}"`);
159
159
  this.moduleMap.set(tag, module);
160
160
  this.modelMap.set(module, Model);
@@ -216,7 +216,7 @@ async function Factory(models, opts = {}) {
216
216
  await phecda.start(models);
217
217
  return phecda;
218
218
  }
219
- _chunkLLF55NZPjs.__name.call(void 0, Factory, "Factory");
219
+ _chunkIBVPZSZJjs.__name.call(void 0, Factory, "Factory");
220
220
  function useS(nsOrModel, namespace) {
221
221
  if (!nsOrModel) {
222
222
  namespace = "default";
@@ -229,7 +229,7 @@ function useS(nsOrModel, namespace) {
229
229
  if (nsOrModel && typeof nsOrModel !== "string") return serverPhecda.get(nsOrModel);
230
230
  else return serverPhecda;
231
231
  }
232
- _chunkLLF55NZPjs.__name.call(void 0, useS, "useS");
232
+ _chunkIBVPZSZJjs.__name.call(void 0, useS, "useS");
233
233
  function getMetaFromInstance(instance, tag, model) {
234
234
  const name = model.name;
235
235
  const propertyKeys = _phecdacore.getMetaKey.call(void 0, instance).filter((item) => typeof item === "string");
@@ -244,7 +244,7 @@ function getMetaFromInstance(instance, tag, model) {
244
244
  method: i
245
245
  };
246
246
  if (baseMeta.controller) {
247
- if (typeof tag !== "string") _chunkLLF55NZPjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
247
+ if (typeof tag !== "string") _chunkIBVPZSZJjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
248
248
  metaData.controller = baseMeta.controller;
249
249
  metaData[baseMeta.controller] = {
250
250
  ...baseMeta[baseMeta.controller],
@@ -286,7 +286,7 @@ function getMetaFromInstance(instance, tag, model) {
286
286
  return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || [], instance, model);
287
287
  });
288
288
  }
289
- _chunkLLF55NZPjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
289
+ _chunkIBVPZSZJjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
290
290
  function deepFreeze(object) {
291
291
  Object.freeze(object);
292
292
  Object.getOwnPropertyNames(object).forEach((prop) => {
@@ -294,11 +294,11 @@ function deepFreeze(object) {
294
294
  });
295
295
  return object;
296
296
  }
297
- _chunkLLF55NZPjs.__name.call(void 0, deepFreeze, "deepFreeze");
297
+ _chunkIBVPZSZJjs.__name.call(void 0, deepFreeze, "deepFreeze");
298
298
  function getParamTypes(Model, key) {
299
299
  return Reflect.getMetadata("design:paramtypes", Model, key);
300
300
  }
301
- _chunkLLF55NZPjs.__name.call(void 0, getParamTypes, "getParamTypes");
301
+ _chunkIBVPZSZJjs.__name.call(void 0, getParamTypes, "getParamTypes");
302
302
 
303
303
 
304
304
 
@@ -1,5 +1,5 @@
1
1
  import { Construct } from 'phecda-core';
2
- import { M as Meta, E as Emitter } from './meta-Csp1xcSR.js';
2
+ import { M as Meta, E as Emitter } from './meta-ZbvaS7xK.js';
3
3
 
4
4
  declare abstract class Generator {
5
5
  private _path;
@@ -1,5 +1,5 @@
1
1
  import { Construct } from 'phecda-core';
2
- import { M as Meta, E as Emitter } from './meta-Csp1xcSR.mjs';
2
+ import { M as Meta, E as Emitter } from './meta-ZbvaS7xK.mjs';
3
3
 
4
4
  declare abstract class Generator {
5
5
  private _path;
package/dist/helper.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as Meta, C as ControllerMeta } from './meta-Csp1xcSR.mjs';
1
+ import { M as Meta, C as ControllerMeta } from './meta-ZbvaS7xK.mjs';
2
2
  import { Construct } from 'phecda-core';
3
3
 
4
4
  declare function HMR(cb: (oldModels: Construct[], newModels: Construct[]) => any): void;
package/dist/helper.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as Meta, C as ControllerMeta } from './meta-Csp1xcSR.js';
1
+ import { M as Meta, C as ControllerMeta } from './meta-ZbvaS7xK.js';
2
2
  import { Construct } from 'phecda-core';
3
3
 
4
4
  declare function HMR(cb: (oldModels: Construct[], newModels: Construct[]) => any): void;
package/dist/helper.js CHANGED
@@ -5,13 +5,13 @@
5
5
 
6
6
 
7
7
 
8
- var _chunk76UDKZOJjs = require('./chunk-76UDKZOJ.js');
8
+ var _chunkCCK6KDM3js = require('./chunk-CCK6KDM3.js');
9
9
 
10
10
 
11
11
 
12
12
 
13
13
 
14
- var _chunkLLF55NZPjs = require('./chunk-LLF55NZP.js');
14
+ var _chunkIBVPZSZJjs = require('./chunk-IBVPZSZJ.js');
15
15
 
16
16
 
17
17
 
@@ -23,4 +23,4 @@ var _chunkLLF55NZPjs = require('./chunk-LLF55NZP.js');
23
23
 
24
24
 
25
25
 
26
- exports.EXIT = _chunkLLF55NZPjs.EXIT; exports.HMR = _chunkLLF55NZPjs.HMR; exports.RELAUNCH = _chunkLLF55NZPjs.RELAUNCH; exports.RELOAD = _chunkLLF55NZPjs.RELOAD; exports.createControllerMetaMap = _chunk76UDKZOJjs.createControllerMetaMap; exports.detectAopDep = _chunk76UDKZOJjs.detectAopDep; exports.joinUrl = _chunk76UDKZOJjs.joinUrl; exports.mergeObject = _chunk76UDKZOJjs.mergeObject; exports.resolveDep = _chunk76UDKZOJjs.resolveDep; exports.shallowClone = _chunk76UDKZOJjs.shallowClone;
26
+ exports.EXIT = _chunkIBVPZSZJjs.EXIT; exports.HMR = _chunkIBVPZSZJjs.HMR; exports.RELAUNCH = _chunkIBVPZSZJjs.RELAUNCH; exports.RELOAD = _chunkIBVPZSZJjs.RELOAD; exports.createControllerMetaMap = _chunkCCK6KDM3js.createControllerMetaMap; exports.detectAopDep = _chunkCCK6KDM3js.detectAopDep; exports.joinUrl = _chunkCCK6KDM3js.joinUrl; exports.mergeObject = _chunkCCK6KDM3js.mergeObject; exports.resolveDep = _chunkCCK6KDM3js.resolveDep; exports.shallowClone = _chunkCCK6KDM3js.shallowClone;
package/dist/helper.mjs CHANGED
@@ -5,13 +5,13 @@ import {
5
5
  mergeObject,
6
6
  resolveDep,
7
7
  shallowClone
8
- } from "./chunk-WST6E6MQ.mjs";
8
+ } from "./chunk-LNL3MVTR.mjs";
9
9
  import {
10
10
  EXIT,
11
11
  HMR,
12
12
  RELAUNCH,
13
13
  RELOAD
14
- } from "./chunk-URKOYTBU.mjs";
14
+ } from "./chunk-ITDH2YDL.mjs";
15
15
  export {
16
16
  EXIT,
17
17
  HMR,
@@ -1,9 +1,9 @@
1
1
  import { Elysia as Elysia$1, Context } from 'elysia';
2
2
  import { AnyLocalHook } from 'elysia/dist/types';
3
- import { H as HttpCtx, a as HttpOptions } from '../../types-CjVwVyJT.mjs';
4
- import { F as Factory } from '../../core-BYxcQ8kf.mjs';
3
+ import { H as HttpCtx, a as HttpOptions } from '../../types-BfcBZVua.mjs';
4
+ import { F as Factory } from '../../core-nqk9d66O.mjs';
5
5
  import 'node:http';
6
- import '../../meta-Csp1xcSR.mjs';
6
+ import '../../meta-ZbvaS7xK.mjs';
7
7
  import 'phecda-core';
8
8
 
9
9
  interface ElysiaCtx extends HttpCtx {
@@ -1,9 +1,9 @@
1
1
  import { Elysia as Elysia$1, Context } from 'elysia';
2
2
  import { AnyLocalHook } from 'elysia/dist/types';
3
- import { H as HttpCtx, a as HttpOptions } from '../../types-Bs64nYvd.js';
4
- import { F as Factory } from '../../core-BiS3xJKx.js';
3
+ import { H as HttpCtx, a as HttpOptions } from '../../types-B4zY7i87.js';
4
+ import { F as Factory } from '../../core-Bd2ynlyb.js';
5
5
  import 'node:http';
6
- import '../../meta-Csp1xcSR.js';
6
+ import '../../meta-ZbvaS7xK.js';
7
7
  import 'phecda-core';
8
8
 
9
9
  interface ElysiaCtx extends HttpCtx {