phecda-server 7.0.0-alpha.4 → 7.0.0-alpha.5

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/dist/{chunk-MMG73S64.mjs → chunk-2ESEXJQM.mjs} +1 -1
  2. package/dist/{chunk-A53KNKY4.mjs → chunk-3ISYBU3P.mjs} +33 -3
  3. package/dist/{chunk-6EBEME3I.js → chunk-K54JYYXK.js} +51 -51
  4. package/dist/{chunk-RQSQRZL4.js → chunk-KFFS2P7I.js} +3 -1
  5. package/dist/{chunk-KUGFI6SC.mjs → chunk-PXLG75ED.mjs} +1 -1
  6. package/dist/{chunk-PKSWGQLW.js → chunk-TR5Z4SDI.js} +50 -20
  7. package/dist/{chunk-QD3QR3NW.mjs → chunk-UXGJD2PK.mjs} +2 -0
  8. package/dist/{chunk-QCOBXM7F.js → chunk-Y2OLA5OJ.js} +24 -24
  9. package/dist/{core-C1kHRqU9.d.ts → core-CzElxZoF.d.ts} +2 -1
  10. package/dist/{core-CSiaRU7r.d.mts → core-DU7gQKSk.d.mts} +2 -1
  11. package/dist/helper.d.mts +1 -1
  12. package/dist/helper.d.ts +1 -1
  13. package/dist/helper.js +3 -3
  14. package/dist/helper.mjs +2 -2
  15. package/dist/http/elysia/index.d.mts +3 -3
  16. package/dist/http/elysia/index.d.ts +3 -3
  17. package/dist/http/elysia/index.js +40 -40
  18. package/dist/http/elysia/index.mjs +3 -3
  19. package/dist/http/express/index.d.mts +3 -3
  20. package/dist/http/express/index.d.ts +3 -3
  21. package/dist/http/express/index.js +37 -37
  22. package/dist/http/express/index.mjs +2 -2
  23. package/dist/http/fastify/index.d.mts +3 -3
  24. package/dist/http/fastify/index.d.ts +3 -3
  25. package/dist/http/fastify/index.js +38 -38
  26. package/dist/http/fastify/index.mjs +3 -3
  27. package/dist/http/h3/index.d.mts +3 -3
  28. package/dist/http/h3/index.d.ts +3 -3
  29. package/dist/http/h3/index.js +37 -37
  30. package/dist/http/h3/index.mjs +2 -2
  31. package/dist/http/hono/index.d.mts +3 -3
  32. package/dist/http/hono/index.d.ts +3 -3
  33. package/dist/http/hono/index.js +35 -35
  34. package/dist/http/hono/index.mjs +2 -2
  35. package/dist/http/hyper-express/index.d.mts +3 -3
  36. package/dist/http/hyper-express/index.d.ts +3 -3
  37. package/dist/http/hyper-express/index.js +35 -35
  38. package/dist/http/hyper-express/index.mjs +2 -2
  39. package/dist/http/koa/index.d.mts +3 -3
  40. package/dist/http/koa/index.d.ts +3 -3
  41. package/dist/http/koa/index.js +37 -37
  42. package/dist/http/koa/index.mjs +2 -2
  43. package/dist/index.d.mts +8 -8
  44. package/dist/index.d.ts +8 -8
  45. package/dist/index.js +40 -38
  46. package/dist/index.mjs +6 -4
  47. package/dist/{meta-D1M85Hef.d.ts → meta-BTnLXuCa.d.mts} +2 -1
  48. package/dist/{meta-D1M85Hef.d.mts → meta-BTnLXuCa.d.ts} +2 -1
  49. package/dist/rpc/bullmq/index.d.mts +3 -3
  50. package/dist/rpc/bullmq/index.d.ts +3 -3
  51. package/dist/rpc/bullmq/index.js +14 -14
  52. package/dist/rpc/bullmq/index.mjs +2 -2
  53. package/dist/rpc/kafka/index.d.mts +3 -3
  54. package/dist/rpc/kafka/index.d.ts +3 -3
  55. package/dist/rpc/kafka/index.js +14 -14
  56. package/dist/rpc/kafka/index.mjs +2 -2
  57. package/dist/rpc/nats/index.d.mts +3 -3
  58. package/dist/rpc/nats/index.d.ts +3 -3
  59. package/dist/rpc/nats/index.js +13 -13
  60. package/dist/rpc/nats/index.mjs +2 -2
  61. package/dist/rpc/rabbitmq/index.d.mts +3 -3
  62. package/dist/rpc/rabbitmq/index.d.ts +3 -3
  63. package/dist/rpc/rabbitmq/index.js +15 -15
  64. package/dist/rpc/rabbitmq/index.mjs +2 -2
  65. package/dist/rpc/redis/index.d.mts +3 -3
  66. package/dist/rpc/redis/index.d.ts +3 -3
  67. package/dist/rpc/redis/index.js +13 -13
  68. package/dist/rpc/redis/index.mjs +2 -2
  69. package/dist/test.d.mts +2 -2
  70. package/dist/test.d.ts +2 -2
  71. package/dist/test.js +6 -6
  72. package/dist/test.mjs +2 -2
  73. package/dist/{types-ee1FBodH.d.ts → types--E-OCZhC.d.ts} +1 -1
  74. package/dist/{types-JMhFVp-Z.d.mts → types-BYqBeqrs.d.mts} +1 -1
  75. package/dist/{types-wbHHC93P.d.mts → types-BxlzVoRv.d.mts} +1 -1
  76. package/dist/{types-C9Remkup.d.ts → types-CbfaGkPA.d.ts} +1 -1
  77. package/package.json +1 -1
  78. package/register/loader.mjs +2 -1
  79. package/register/utils.mjs +56 -56
@@ -5,7 +5,7 @@ import {
5
5
  LOG_LEVEL,
6
6
  __name,
7
7
  log
8
- } from "./chunk-QD3QR3NW.mjs";
8
+ } from "./chunk-UXGJD2PK.mjs";
9
9
 
10
10
  // src/helper.ts
11
11
  import pc2 from "picocolors";
@@ -3,7 +3,7 @@ import {
3
3
  IS_ONLY_GENERATE,
4
4
  __name,
5
5
  log
6
- } from "./chunk-QD3QR3NW.mjs";
6
+ } from "./chunk-UXGJD2PK.mjs";
7
7
 
8
8
  // src/meta.ts
9
9
  var Meta = class {
@@ -119,13 +119,41 @@ var ServerPhecda = class {
119
119
  debug("destroy all");
120
120
  for (const [tag] of this.moduleMap) await this.del(tag);
121
121
  }
122
+ createProxyModule(tag) {
123
+ const that = this;
124
+ return new Proxy({}, {
125
+ get(_target, prop) {
126
+ const module = that.moduleMap.get(tag);
127
+ return Reflect.get(module, prop, module);
128
+ },
129
+ set(_target, prop, newValue) {
130
+ const module = that.moduleMap.get(tag);
131
+ return Reflect.set(module, prop, newValue, module);
132
+ },
133
+ has(_target, prop) {
134
+ return Reflect.has(that.moduleMap.get(tag), prop);
135
+ },
136
+ getPrototypeOf() {
137
+ return Reflect.getPrototypeOf(that.moduleMap.get(tag));
138
+ },
139
+ getOwnPropertyDescriptor(_target, prop) {
140
+ return Reflect.getOwnPropertyDescriptor(that.moduleMap.get(tag), prop);
141
+ }
142
+ });
143
+ }
122
144
  async buildDepModule(Model) {
123
145
  const paramtypes = getParamTypes(Model);
124
146
  let module;
125
147
  const tag = getTag(Model);
126
148
  if (this.moduleMap.has(tag)) {
127
149
  module = this.moduleMap.get(tag);
128
- if (!module) throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${String(tag)}--[module] ${Model}`);
150
+ if (!module) {
151
+ log(`Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
152
+ return {
153
+ module: this.createProxyModule(tag),
154
+ tag
155
+ };
156
+ }
129
157
  if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {
130
158
  this.modelSet.add(Model);
131
159
  if (module instanceof Model) log(`Module taged ${String(tag)} has been overridden`);
@@ -250,7 +278,9 @@ function deepFreeze(object) {
250
278
  }
251
279
  __name(deepFreeze, "deepFreeze");
252
280
  function getParamTypes(Model, key) {
253
- return Reflect.getMetadata("design:paramtypes", Model, key);
281
+ const paramTypes = Reflect.getMetadata("design:paramtypes", Model, key);
282
+ if (typeof paramTypes === "function") return paramTypes();
283
+ else return paramTypes;
254
284
  }
255
285
  __name(getParamTypes, "getParamTypes");
256
286
 
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkRQSQRZL4js = require('./chunk-RQSQRZL4.js');
8
+ var _chunkKFFS2P7Ijs = require('./chunk-KFFS2P7I.js');
9
9
 
10
10
  // src/helper.ts
11
11
  var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
@@ -15,14 +15,14 @@ var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
15
15
 
16
16
 
17
17
  // src/pipe.ts
18
- var defaultPipe = /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, ({ arg }) => {
18
+ var defaultPipe = /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, ({ arg }) => {
19
19
  return arg;
20
20
  }, "defaultPipe");
21
21
 
22
22
  // src/exception/base.ts
23
23
  var Exception = class extends Error {
24
24
  static {
25
- _chunkRQSQRZL4js.__name.call(void 0, this, "Exception");
25
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "Exception");
26
26
  }
27
27
 
28
28
 
@@ -35,7 +35,7 @@ var Exception = class extends Error {
35
35
  message: this.message,
36
36
  description: this.description,
37
37
  status: this.status,
38
- [_chunkRQSQRZL4js.ERROR_SYMBOL]: true
38
+ [_chunkKFFS2P7Ijs.ERROR_SYMBOL]: true
39
39
  };
40
40
  }
41
41
  };
@@ -43,7 +43,7 @@ var Exception = class extends Error {
43
43
  // src/exception/undefine.ts
44
44
  var UndefinedException = class extends Exception {
45
45
  static {
46
- _chunkRQSQRZL4js.__name.call(void 0, this, "UndefinedException");
46
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "UndefinedException");
47
47
  }
48
48
  constructor(message) {
49
49
  super(message, 500, "Undefined error");
@@ -53,7 +53,7 @@ var UndefinedException = class extends Exception {
53
53
  // src/exception/validate.ts
54
54
  var ValidateException = class extends Exception {
55
55
  static {
56
- _chunkRQSQRZL4js.__name.call(void 0, this, "ValidateException");
56
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "ValidateException");
57
57
  }
58
58
  constructor(message) {
59
59
  super(message, 400, "Validate exception");
@@ -63,7 +63,7 @@ var ValidateException = class extends Exception {
63
63
  // src/exception/forbidden.ts
64
64
  var ForbiddenException = class extends Exception {
65
65
  static {
66
- _chunkRQSQRZL4js.__name.call(void 0, this, "ForbiddenException");
66
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "ForbiddenException");
67
67
  }
68
68
  constructor(message) {
69
69
  super(message, 403, "Forbidden resource");
@@ -73,7 +73,7 @@ var ForbiddenException = class extends Exception {
73
73
  // src/exception/bad-request.ts
74
74
  var BadRequestException = class extends Exception {
75
75
  static {
76
- _chunkRQSQRZL4js.__name.call(void 0, this, "BadRequestException");
76
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "BadRequestException");
77
77
  }
78
78
  constructor(message) {
79
79
  super(message, 400, "Bad Request");
@@ -83,7 +83,7 @@ var BadRequestException = class extends Exception {
83
83
  // src/exception/not-found.ts
84
84
  var NotFoundException = class extends Exception {
85
85
  static {
86
- _chunkRQSQRZL4js.__name.call(void 0, this, "NotFoundException");
86
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "NotFoundException");
87
87
  }
88
88
  constructor(message) {
89
89
  super(message, 404, "Not Found");
@@ -93,7 +93,7 @@ var NotFoundException = class extends Exception {
93
93
  // src/exception/conflict.ts
94
94
  var ConflictException = class extends Exception {
95
95
  static {
96
- _chunkRQSQRZL4js.__name.call(void 0, this, "ConflictException");
96
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "ConflictException");
97
97
  }
98
98
  constructor(message) {
99
99
  super(message, 409, "Conflict");
@@ -103,7 +103,7 @@ var ConflictException = class extends Exception {
103
103
  // src/exception/bad-gateway.ts
104
104
  var BadGatewayException = class extends Exception {
105
105
  static {
106
- _chunkRQSQRZL4js.__name.call(void 0, this, "BadGatewayException");
106
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "BadGatewayException");
107
107
  }
108
108
  constructor(message) {
109
109
  super(message, 502, "Bad Gatrway");
@@ -113,7 +113,7 @@ var BadGatewayException = class extends Exception {
113
113
  // src/exception/invalid-input.ts
114
114
  var InvalidInputException = class extends Exception {
115
115
  static {
116
- _chunkRQSQRZL4js.__name.call(void 0, this, "InvalidInputException");
116
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "InvalidInputException");
117
117
  }
118
118
  constructor(message) {
119
119
  super(message, 502, "Invalid Input");
@@ -123,7 +123,7 @@ var InvalidInputException = class extends Exception {
123
123
  // src/exception/media-type.ts
124
124
  var UnsupportedMediaTypeException = class extends Exception {
125
125
  static {
126
- _chunkRQSQRZL4js.__name.call(void 0, this, "UnsupportedMediaTypeException");
126
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "UnsupportedMediaTypeException");
127
127
  }
128
128
  constructor(message) {
129
129
  super(message, 415, "Unsupported Media Type");
@@ -133,7 +133,7 @@ var UnsupportedMediaTypeException = class extends Exception {
133
133
  // src/exception/payload-large.ts
134
134
  var PayloadLargeException = class extends Exception {
135
135
  static {
136
- _chunkRQSQRZL4js.__name.call(void 0, this, "PayloadLargeException");
136
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "PayloadLargeException");
137
137
  }
138
138
  constructor(message) {
139
139
  super(message, 413, "Payload Too Large");
@@ -143,7 +143,7 @@ var PayloadLargeException = class extends Exception {
143
143
  // src/exception/timeout.ts
144
144
  var TimeoutException = class extends Exception {
145
145
  static {
146
- _chunkRQSQRZL4js.__name.call(void 0, this, "TimeoutException");
146
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "TimeoutException");
147
147
  }
148
148
  constructor(message) {
149
149
  super(message, 408, "Request Timeout");
@@ -153,7 +153,7 @@ var TimeoutException = class extends Exception {
153
153
  // src/exception/unauthorized.ts
154
154
  var UnauthorizedException = class extends Exception {
155
155
  static {
156
- _chunkRQSQRZL4js.__name.call(void 0, this, "UnauthorizedException");
156
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "UnauthorizedException");
157
157
  }
158
158
  constructor(message) {
159
159
  super(message, 401, "Unauthorized");
@@ -163,7 +163,7 @@ var UnauthorizedException = class extends Exception {
163
163
  // src/exception/unavailable-service.ts
164
164
  var ServiceUnavailableException = class extends Exception {
165
165
  static {
166
- _chunkRQSQRZL4js.__name.call(void 0, this, "ServiceUnavailableException");
166
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "ServiceUnavailableException");
167
167
  }
168
168
  constructor(message) {
169
169
  super(message, 503, "Service Unavailable");
@@ -173,7 +173,7 @@ var ServiceUnavailableException = class extends Exception {
173
173
  // src/exception/framework.ts
174
174
  var FrameworkException = class extends Exception {
175
175
  static {
176
- _chunkRQSQRZL4js.__name.call(void 0, this, "FrameworkException");
176
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "FrameworkException");
177
177
  }
178
178
  constructor(message) {
179
179
  super(`[phecda-server] ${message}`, 500, "Framework Error");
@@ -183,7 +183,7 @@ var FrameworkException = class extends Exception {
183
183
  // src/exception/timer.ts
184
184
  var TimerException = class extends Exception {
185
185
  static {
186
- _chunkRQSQRZL4js.__name.call(void 0, this, "TimerException");
186
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "TimerException");
187
187
  }
188
188
  constructor(message) {
189
189
  super(message, 0, "Timer Error");
@@ -193,7 +193,7 @@ var TimerException = class extends Exception {
193
193
  // src/exception/worker.ts
194
194
  var WorkerException = class extends Exception {
195
195
  static {
196
- _chunkRQSQRZL4js.__name.call(void 0, this, "WorkerException");
196
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "WorkerException");
197
197
  }
198
198
  constructor(message) {
199
199
  super(message, 0, "Worker Error");
@@ -201,14 +201,14 @@ var WorkerException = class extends Exception {
201
201
  };
202
202
 
203
203
  // src/filter.ts
204
- var defaultFilter = /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (e) => {
204
+ var defaultFilter = /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (e) => {
205
205
  if (!(e instanceof Exception)) {
206
- _chunkRQSQRZL4js.log.call(void 0, e.message, "error");
207
- if (_chunkRQSQRZL4js.LOG_LEVEL <= 0) console.error(e.stack);
206
+ _chunkKFFS2P7Ijs.log.call(void 0, e.message, "error");
207
+ if (_chunkKFFS2P7Ijs.LOG_LEVEL <= 0) console.error(e.stack);
208
208
  e = new UndefinedException(e.message || e);
209
209
  } else {
210
- _chunkRQSQRZL4js.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
211
- if (_chunkRQSQRZL4js.LOG_LEVEL <= 0) console.error(e.stack);
210
+ _chunkKFFS2P7Ijs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
211
+ if (_chunkKFFS2P7Ijs.LOG_LEVEL <= 0) console.error(e.stack);
212
212
  }
213
213
  return e.data;
214
214
  }, "defaultFilter");
@@ -217,7 +217,7 @@ var defaultFilter = /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (e) =>
217
217
  var debug = _debug2.default.call(void 0, "phecda-server(Context)");
218
218
  var Context = (_class = class _Context {
219
219
  static {
220
- _chunkRQSQRZL4js.__name.call(void 0, this, "Context");
220
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "Context");
221
221
  }
222
222
 
223
223
 
@@ -232,7 +232,7 @@ var Context = (_class = class _Context {
232
232
  static __initStatic4() {this.addonRecord = {}}
233
233
  constructor(data) {
234
234
  this.data = data;
235
- if (_chunkRQSQRZL4js.IS_HMR)
235
+ if (_chunkKFFS2P7Ijs.IS_HMR)
236
236
  data._context = this;
237
237
  }
238
238
  static getAop(meta, opts) {
@@ -264,7 +264,7 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
264
264
  const { paramsType, data: { ctxs, tag, params, func } } = meta;
265
265
  try {
266
266
  let res;
267
- const nextHandler = /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (index) => {
267
+ const nextHandler = /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (index) => {
268
268
  return async () => {
269
269
  if (index === guards.length) {
270
270
  const instance = moduleMap.get(tag);
@@ -288,7 +288,7 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
288
288
  return res;
289
289
  });
290
290
  }
291
- _chunkRQSQRZL4js.__name.call(void 0, next, "next");
291
+ _chunkKFFS2P7Ijs.__name.call(void 0, next, "next");
292
292
  const ret = await guards[index](this.data, next);
293
293
  if (ret !== void 0) {
294
294
  res = ret;
@@ -333,12 +333,12 @@ function addPipe(key, pipe) {
333
333
  if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) debug(`overwrite Pipe "${String(key)}"`, "warn");
334
334
  Context.pipeRecord[key] = pipe;
335
335
  }
336
- _chunkRQSQRZL4js.__name.call(void 0, addPipe, "addPipe");
336
+ _chunkKFFS2P7Ijs.__name.call(void 0, addPipe, "addPipe");
337
337
  function addFilter(key, filter) {
338
338
  if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) debug(`overwrite Filter "${String(key)}"`, "warn");
339
339
  Context.filterRecord[key] = filter;
340
340
  }
341
- _chunkRQSQRZL4js.__name.call(void 0, addFilter, "addFilter");
341
+ _chunkKFFS2P7Ijs.__name.call(void 0, addFilter, "addFilter");
342
342
  function addGuard(key, guard, priority = 0) {
343
343
  if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) debug(`overwrite Guard "${String(key)}"`, "warn");
344
344
  Context.guardRecord[key] = {
@@ -346,7 +346,7 @@ function addGuard(key, guard, priority = 0) {
346
346
  priority
347
347
  };
348
348
  }
349
- _chunkRQSQRZL4js.__name.call(void 0, addGuard, "addGuard");
349
+ _chunkKFFS2P7Ijs.__name.call(void 0, addGuard, "addGuard");
350
350
  function addAddon(key, addon, priority = 0) {
351
351
  if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) debug(`overwrite Addon "${String(key)}"`, "warn");
352
352
  Context.addonRecord[key] = {
@@ -354,20 +354,20 @@ function addAddon(key, addon, priority = 0) {
354
354
  priority
355
355
  };
356
356
  }
357
- _chunkRQSQRZL4js.__name.call(void 0, addAddon, "addAddon");
357
+ _chunkKFFS2P7Ijs.__name.call(void 0, addAddon, "addAddon");
358
358
 
359
359
  // src/hmr.ts
360
360
  function HMR(cb) {
361
- if (_chunkRQSQRZL4js.IS_HMR) _optionalChain([globalThis, 'access', _ => _.__PS_HMR__, 'optionalAccess', _2 => _2.push, 'call', _3 => _3(cb)]);
361
+ if (_chunkKFFS2P7Ijs.IS_HMR) _optionalChain([globalThis, 'access', _ => _.__PS_HMR__, 'optionalAccess', _2 => _2.push, 'call', _3 => _3(cb)]);
362
362
  }
363
- _chunkRQSQRZL4js.__name.call(void 0, HMR, "HMR");
363
+ _chunkKFFS2P7Ijs.__name.call(void 0, HMR, "HMR");
364
364
 
365
365
  // src/http/helper.ts
366
366
  function resolveDep(ret, key) {
367
367
  if (key) return _optionalChain([ret, 'optionalAccess', _4 => _4[key]]);
368
368
  return ret;
369
369
  }
370
- _chunkRQSQRZL4js.__name.call(void 0, resolveDep, "resolveDep");
370
+ _chunkKFFS2P7Ijs.__name.call(void 0, resolveDep, "resolveDep");
371
371
  function argToReq(params, args, headers) {
372
372
  const req = {
373
373
  body: {},
@@ -381,14 +381,14 @@ function argToReq(params, args, headers) {
381
381
  });
382
382
  return req;
383
383
  }
384
- _chunkRQSQRZL4js.__name.call(void 0, argToReq, "argToReq");
384
+ _chunkKFFS2P7Ijs.__name.call(void 0, argToReq, "argToReq");
385
385
 
386
386
  // src/rpc/helper.ts
387
387
  var _os = require('os');
388
388
  function genClientQueue(key) {
389
389
  return `PS-${key ? `${key}-` : ""}${_os.hostname.call(void 0, )}-${process.pid}`;
390
390
  }
391
- _chunkRQSQRZL4js.__name.call(void 0, genClientQueue, "genClientQueue");
391
+ _chunkKFFS2P7Ijs.__name.call(void 0, genClientQueue, "genClientQueue");
392
392
 
393
393
  // src/decorators/helper.ts
394
394
  function shallowClone(obj) {
@@ -396,11 +396,11 @@ function shallowClone(obj) {
396
396
  ...obj
397
397
  };
398
398
  }
399
- _chunkRQSQRZL4js.__name.call(void 0, shallowClone, "shallowClone");
399
+ _chunkKFFS2P7Ijs.__name.call(void 0, shallowClone, "shallowClone");
400
400
  function mergeObject(...args) {
401
401
  return Object.assign({}, ...args);
402
402
  }
403
- _chunkRQSQRZL4js.__name.call(void 0, mergeObject, "mergeObject");
403
+ _chunkKFFS2P7Ijs.__name.call(void 0, mergeObject, "mergeObject");
404
404
 
405
405
  // src/helper.ts
406
406
  function createControllerMetaMap(meta, filter) {
@@ -416,12 +416,12 @@ function createControllerMetaMap(meta, filter) {
416
416
  });
417
417
  }
418
418
  }
419
- _chunkRQSQRZL4js.__name.call(void 0, handleMeta, "handleMeta");
419
+ _chunkKFFS2P7Ijs.__name.call(void 0, handleMeta, "handleMeta");
420
420
  handleMeta();
421
421
  HMR(handleMeta);
422
422
  return metaMap;
423
423
  }
424
- _chunkRQSQRZL4js.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
424
+ _chunkKFFS2P7Ijs.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
425
425
  function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
426
426
  const addonSet = /* @__PURE__ */ new Set();
427
427
  const guardSet = /* @__PURE__ */ new Set();
@@ -465,29 +465,29 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
465
465
  ...filterSet
466
466
  ].filter((i) => !Context.filterRecord[i]);
467
467
  function exit() {
468
- if (_chunkRQSQRZL4js.IS_STRICT) process.exit(5);
468
+ if (_chunkKFFS2P7Ijs.IS_STRICT) process.exit(5);
469
469
  }
470
- _chunkRQSQRZL4js.__name.call(void 0, exit, "exit");
470
+ _chunkKFFS2P7Ijs.__name.call(void 0, exit, "exit");
471
471
  if (missAddons.length) {
472
- _chunkRQSQRZL4js.log.call(void 0, `${_picocolors2.default.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
472
+ _chunkKFFS2P7Ijs.log.call(void 0, `${_picocolors2.default.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
473
473
  exit();
474
474
  }
475
475
  if (missGuards.length) {
476
- _chunkRQSQRZL4js.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
476
+ _chunkKFFS2P7Ijs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
477
477
  exit();
478
478
  }
479
479
  if (missPipes.length) {
480
- _chunkRQSQRZL4js.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
480
+ _chunkKFFS2P7Ijs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
481
481
  exit();
482
482
  }
483
483
  if (missFilters.length) {
484
- _chunkRQSQRZL4js.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
484
+ _chunkKFFS2P7Ijs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
485
485
  exit();
486
486
  }
487
- warningSet.forEach((warn) => _chunkRQSQRZL4js.log.call(void 0, warn, "warn"));
487
+ warningSet.forEach((warn) => _chunkKFFS2P7Ijs.log.call(void 0, warn, "warn"));
488
488
  if (warningSet.size) exit();
489
489
  }
490
- _chunkRQSQRZL4js.__name.call(void 0, handleMeta, "handleMeta");
490
+ _chunkKFFS2P7Ijs.__name.call(void 0, handleMeta, "handleMeta");
491
491
  handleMeta();
492
492
  HMR(handleMeta);
493
493
  return {
@@ -497,7 +497,7 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
497
497
  filterSet
498
498
  };
499
499
  }
500
- _chunkRQSQRZL4js.__name.call(void 0, detectAopDep, "detectAopDep");
500
+ _chunkKFFS2P7Ijs.__name.call(void 0, detectAopDep, "detectAopDep");
501
501
 
502
502
 
503
503
 
@@ -7,6 +7,7 @@ var IS_HMR = process.env.NODE_ENV === "development";
7
7
  var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
8
8
  var IS_STRICT = !!process.env.PS_STRICT;
9
9
  var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
10
+ var IS_READY = Symbol("IS_READY");
10
11
  var PS_EXIT_CODE = /* @__PURE__ */ function(PS_EXIT_CODE2) {
11
12
  PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 2] = "RELAUNCH";
12
13
  PS_EXIT_CODE2[PS_EXIT_CODE2["CODE"] = 4] = "CODE";
@@ -70,4 +71,5 @@ __name(runMiddleware, "runMiddleware");
70
71
 
71
72
 
72
73
 
73
- exports.__name = __name; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.IS_HMR = IS_HMR; exports.IS_ONLY_GENERATE = IS_ONLY_GENERATE; exports.IS_STRICT = IS_STRICT; exports.LOG_LEVEL = LOG_LEVEL; exports.PS_EXIT_CODE = PS_EXIT_CODE; exports.setLogger = setLogger; exports.getLogger = getLogger; exports.log = log; exports.runMiddleware = runMiddleware; exports.Mixin = _tsmixer.Mixin;
74
+
75
+ exports.__name = __name; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.IS_HMR = IS_HMR; exports.IS_ONLY_GENERATE = IS_ONLY_GENERATE; exports.IS_STRICT = IS_STRICT; exports.LOG_LEVEL = LOG_LEVEL; exports.IS_READY = IS_READY; exports.PS_EXIT_CODE = PS_EXIT_CODE; exports.setLogger = setLogger; exports.getLogger = getLogger; exports.log = log; exports.runMiddleware = runMiddleware; exports.Mixin = _tsmixer.Mixin;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-QD3QR3NW.mjs";
3
+ } from "./chunk-UXGJD2PK.mjs";
4
4
 
5
5
  // src/decorators/param.ts
6
6
  import { setMeta } from "phecda-core";
@@ -3,12 +3,12 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkRQSQRZL4js = require('./chunk-RQSQRZL4.js');
6
+ var _chunkKFFS2P7Ijs = require('./chunk-KFFS2P7I.js');
7
7
 
8
8
  // src/meta.ts
9
9
  var Meta = class {
10
10
  static {
11
- _chunkRQSQRZL4js.__name.call(void 0, this, "Meta");
11
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "Meta");
12
12
  }
13
13
 
14
14
 
@@ -37,11 +37,11 @@ function defaultServerInject() {
37
37
  });
38
38
  }
39
39
  }
40
- _chunkRQSQRZL4js.__name.call(void 0, defaultServerInject, "defaultServerInject");
40
+ _chunkKFFS2P7Ijs.__name.call(void 0, defaultServerInject, "defaultServerInject");
41
41
  var phecdaNamespace = /* @__PURE__ */ new Map();
42
42
  var ServerPhecda = (_class = class {
43
43
  static {
44
- _chunkRQSQRZL4js.__name.call(void 0, this, "ServerPhecda");
44
+ _chunkKFFS2P7Ijs.__name.call(void 0, this, "ServerPhecda");
45
45
  }
46
46
  __init() {this.moduleMap = /* @__PURE__ */ new Map()}
47
47
  __init2() {this.meta = []}
@@ -53,7 +53,7 @@ var ServerPhecda = (_class = class {
53
53
 
54
54
  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);
55
55
  defaultServerInject();
56
- const { namespace = "default", parseModule = /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
56
+ const { namespace = "default", parseModule = /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
57
57
  phecdaNamespace.set(namespace, this);
58
58
  this.parseMeta = parseMeta;
59
59
  this.parseModule = parseModule;
@@ -61,8 +61,8 @@ var ServerPhecda = (_class = class {
61
61
  }
62
62
  async start(models) {
63
63
  for (const model of models) await this.buildDepModule(model);
64
- const generateCode = /* @__PURE__ */ _chunkRQSQRZL4js.__name.call(void 0, async () => {
65
- if (_chunkRQSQRZL4js.IS_HMR) {
64
+ const generateCode = /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, async () => {
65
+ if (_chunkKFFS2P7Ijs.IS_HMR) {
66
66
  return Promise.all(this.generators.map((generator) => {
67
67
  debug(`generate "${generator.name}" code to ${generator.path}`);
68
68
  return generator.output(this.meta);
@@ -70,9 +70,9 @@ var ServerPhecda = (_class = class {
70
70
  }
71
71
  }, "generateCode");
72
72
  generateCode().then(() => {
73
- if (_chunkRQSQRZL4js.IS_ONLY_GENERATE) process.exit(4);
73
+ if (_chunkKFFS2P7Ijs.IS_ONLY_GENERATE) process.exit(4);
74
74
  });
75
- if (_chunkRQSQRZL4js.IS_HMR) {
75
+ if (_chunkKFFS2P7Ijs.IS_HMR) {
76
76
  if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
77
77
  _optionalChain([globalThis, 'access', _2 => _2.__PS_HMR__, 'optionalAccess', _3 => _3.push, 'call', _4 => _4(async (files) => {
78
78
  debug("reload files ");
@@ -119,17 +119,45 @@ var ServerPhecda = (_class = class {
119
119
  debug("destroy all");
120
120
  for (const [tag] of this.moduleMap) await this.del(tag);
121
121
  }
122
+ createProxyModule(tag) {
123
+ const that = this;
124
+ return new Proxy({}, {
125
+ get(_target, prop) {
126
+ const module = that.moduleMap.get(tag);
127
+ return Reflect.get(module, prop, module);
128
+ },
129
+ set(_target, prop, newValue) {
130
+ const module = that.moduleMap.get(tag);
131
+ return Reflect.set(module, prop, newValue, module);
132
+ },
133
+ has(_target, prop) {
134
+ return Reflect.has(that.moduleMap.get(tag), prop);
135
+ },
136
+ getPrototypeOf() {
137
+ return Reflect.getPrototypeOf(that.moduleMap.get(tag));
138
+ },
139
+ getOwnPropertyDescriptor(_target, prop) {
140
+ return Reflect.getOwnPropertyDescriptor(that.moduleMap.get(tag), prop);
141
+ }
142
+ });
143
+ }
122
144
  async buildDepModule(Model) {
123
145
  const paramtypes = getParamTypes(Model);
124
146
  let module;
125
147
  const tag = _phecdacore.getTag.call(void 0, Model);
126
148
  if (this.moduleMap.has(tag)) {
127
149
  module = this.moduleMap.get(tag);
128
- if (!module) throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${String(tag)}--[module] ${Model}`);
150
+ if (!module) {
151
+ _chunkKFFS2P7Ijs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
152
+ return {
153
+ module: this.createProxyModule(tag),
154
+ tag
155
+ };
156
+ }
129
157
  if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {
130
158
  this.modelSet.add(Model);
131
- if (module instanceof Model) _chunkRQSQRZL4js.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
132
- else _chunkRQSQRZL4js.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
159
+ if (module instanceof Model) _chunkKFFS2P7Ijs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
160
+ else _chunkKFFS2P7Ijs.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
161
  }
134
162
  return {
135
163
  module,
@@ -152,7 +180,7 @@ var ServerPhecda = (_class = class {
152
180
  }
153
181
  this.meta.push(...getMetaFromInstance(module, tag, Model.name).map(this.parseMeta).filter((item) => !!item));
154
182
  debug(`init module "${String(tag)}"`);
155
- if (!_chunkRQSQRZL4js.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
183
+ if (!_chunkKFFS2P7Ijs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
156
184
  debug(`add module "${String(tag)}"`);
157
185
  this.moduleMap.set(tag, module);
158
186
  this.modelMap.set(module, Model);
@@ -175,7 +203,7 @@ async function Factory(models, opts = {}) {
175
203
  await phecda.start(models);
176
204
  return phecda;
177
205
  }
178
- _chunkRQSQRZL4js.__name.call(void 0, Factory, "Factory");
206
+ _chunkKFFS2P7Ijs.__name.call(void 0, Factory, "Factory");
179
207
  function useS(nsOrModel, namespace) {
180
208
  if (!nsOrModel) {
181
209
  namespace = "default";
@@ -188,7 +216,7 @@ function useS(nsOrModel, namespace) {
188
216
  if (nsOrModel && typeof nsOrModel !== "string") return serverPhecda.get(nsOrModel);
189
217
  else return serverPhecda;
190
218
  }
191
- _chunkRQSQRZL4js.__name.call(void 0, useS, "useS");
219
+ _chunkKFFS2P7Ijs.__name.call(void 0, useS, "useS");
192
220
  function getMetaFromInstance(instance, tag, name) {
193
221
  const propertyKeys = _phecdacore.getMetaKey.call(void 0, instance).filter((item) => typeof item === "string");
194
222
  const baseMeta = _phecdacore.getMergedMeta.call(void 0, instance, void 0);
@@ -202,7 +230,7 @@ function getMetaFromInstance(instance, tag, name) {
202
230
  func: i
203
231
  };
204
232
  if (baseMeta.controller) {
205
- if (typeof tag !== "string") _chunkRQSQRZL4js.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
233
+ if (typeof tag !== "string") _chunkKFFS2P7Ijs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
206
234
  metaData.controller = baseMeta.controller;
207
235
  metaData[baseMeta.controller] = {
208
236
  ...baseMeta[baseMeta.controller],
@@ -240,7 +268,7 @@ function getMetaFromInstance(instance, tag, name) {
240
268
  return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || []);
241
269
  });
242
270
  }
243
- _chunkRQSQRZL4js.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
271
+ _chunkKFFS2P7Ijs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
244
272
  function deepFreeze(object) {
245
273
  Object.freeze(object);
246
274
  Object.getOwnPropertyNames(object).forEach((prop) => {
@@ -248,11 +276,13 @@ function deepFreeze(object) {
248
276
  });
249
277
  return object;
250
278
  }
251
- _chunkRQSQRZL4js.__name.call(void 0, deepFreeze, "deepFreeze");
279
+ _chunkKFFS2P7Ijs.__name.call(void 0, deepFreeze, "deepFreeze");
252
280
  function getParamTypes(Model, key) {
253
- return Reflect.getMetadata("design:paramtypes", Model, key);
281
+ const paramTypes = Reflect.getMetadata("design:paramtypes", Model, key);
282
+ if (typeof paramTypes === "function") return paramTypes();
283
+ else return paramTypes;
254
284
  }
255
- _chunkRQSQRZL4js.__name.call(void 0, getParamTypes, "getParamTypes");
285
+ _chunkKFFS2P7Ijs.__name.call(void 0, getParamTypes, "getParamTypes");
256
286
 
257
287
 
258
288
 
@@ -7,6 +7,7 @@ var IS_HMR = process.env.NODE_ENV === "development";
7
7
  var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
8
8
  var IS_STRICT = !!process.env.PS_STRICT;
9
9
  var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
10
+ var IS_READY = Symbol("IS_READY");
10
11
  var PS_EXIT_CODE = /* @__PURE__ */ function(PS_EXIT_CODE2) {
11
12
  PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 2] = "RELAUNCH";
12
13
  PS_EXIT_CODE2[PS_EXIT_CODE2["CODE"] = 4] = "CODE";
@@ -64,6 +65,7 @@ export {
64
65
  IS_ONLY_GENERATE,
65
66
  IS_STRICT,
66
67
  LOG_LEVEL,
68
+ IS_READY,
67
69
  PS_EXIT_CODE,
68
70
  setLogger,
69
71
  getLogger,