phecda-server 5.0.0-alpha.10 → 5.0.0-alpha.12

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 (37) hide show
  1. package/dist/{chunk-CLW7EYYD.js → chunk-27WMBKFH.js} +30 -23
  2. package/dist/{chunk-WB437JJ2.mjs → chunk-DJO45NRZ.mjs} +17 -3
  3. package/dist/{chunk-ALJSRZ4Z.js → chunk-GWLM5DEJ.js} +17 -3
  4. package/dist/{chunk-EP4EN3MM.mjs → chunk-HQ5RLYMA.mjs} +1 -1
  5. package/dist/{chunk-ZV4O77YM.js → chunk-KOWUK5OV.js} +65 -61
  6. package/dist/{chunk-DBYLTVRY.mjs → chunk-L5SFPHG6.mjs} +25 -21
  7. package/dist/{chunk-GY5KXMJJ.js → chunk-SSZS3GSQ.js} +2 -2
  8. package/dist/{chunk-BXJSLR46.mjs → chunk-UXPHQ7OT.mjs} +9 -2
  9. package/dist/{core-fe0991cd.d.ts → core-295348b7.d.ts} +3 -1
  10. package/dist/index.d.ts +14 -12
  11. package/dist/index.js +66 -62
  12. package/dist/index.mjs +20 -16
  13. package/dist/rpc/kafka/index.d.ts +1 -1
  14. package/dist/rpc/kafka/index.js +9 -9
  15. package/dist/rpc/kafka/index.mjs +3 -3
  16. package/dist/rpc/rabbitmq/index.d.ts +1 -1
  17. package/dist/rpc/rabbitmq/index.js +9 -9
  18. package/dist/rpc/rabbitmq/index.mjs +3 -3
  19. package/dist/rpc/redis/index.d.ts +1 -1
  20. package/dist/rpc/redis/index.js +9 -9
  21. package/dist/rpc/redis/index.mjs +3 -3
  22. package/dist/server/express/index.d.ts +1 -1
  23. package/dist/server/express/index.js +24 -24
  24. package/dist/server/express/index.mjs +4 -4
  25. package/dist/server/fastify/index.d.ts +1 -1
  26. package/dist/server/fastify/index.js +22 -22
  27. package/dist/server/fastify/index.mjs +4 -4
  28. package/dist/server/h3/index.d.ts +1 -1
  29. package/dist/server/h3/index.js +21 -21
  30. package/dist/server/h3/index.mjs +4 -4
  31. package/dist/server/koa/index.d.ts +1 -1
  32. package/dist/server/koa/index.js +24 -24
  33. package/dist/server/koa/index.mjs +4 -4
  34. package/dist/test.d.ts +1 -1
  35. package/dist/test.js +5 -5
  36. package/dist/test.mjs +2 -2
  37. package/package.json +2 -2
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkALJSRZ4Zjs = require('./chunk-ALJSRZ4Z.js');
6
+ var _chunkGWLM5DEJjs = require('./chunk-GWLM5DEJ.js');
7
7
 
8
8
  // src/meta.ts
9
9
  var Meta = class {
@@ -16,10 +16,10 @@ var Meta = class {
16
16
  this.paramsType = paramsType;
17
17
  }
18
18
  };
19
- _chunkALJSRZ4Zjs.__name.call(void 0, Meta, "Meta");
19
+ _chunkGWLM5DEJjs.__name.call(void 0, Meta, "Meta");
20
20
 
21
21
  // src/compiler/rpc.ts
22
- var Compiler = /* @__PURE__ */ _chunkALJSRZ4Zjs.__name.call(void 0, (_class =class Compiler2 {
22
+ var Compiler = /* @__PURE__ */ _chunkGWLM5DEJjs.__name.call(void 0, (_class =class Compiler2 {
23
23
  __init() {this.classMap = {}}
24
24
  constructor() {;_class.prototype.__init.call(this);
25
25
  }
@@ -55,10 +55,10 @@ function generateRPCCode(meta) {
55
55
  compiler.addMethod(i);
56
56
  return compiler.getContent();
57
57
  }
58
- _chunkALJSRZ4Zjs.__name.call(void 0, generateRPCCode, "generateRPCCode");
58
+ _chunkGWLM5DEJjs.__name.call(void 0, generateRPCCode, "generateRPCCode");
59
59
 
60
60
  // src/compiler/http.ts
61
- var Compiler3 = /* @__PURE__ */ _chunkALJSRZ4Zjs.__name.call(void 0, (_class2 =class Compiler4 {
61
+ var Compiler3 = /* @__PURE__ */ _chunkGWLM5DEJjs.__name.call(void 0, (_class2 =class Compiler4 {
62
62
  __init2() {this.classMap = {}}
63
63
  constructor() {;_class2.prototype.__init2.call(this);
64
64
  }
@@ -97,7 +97,7 @@ function generateHTTPCode(meta) {
97
97
  compiler.addMethod(i);
98
98
  return compiler.getContent();
99
99
  }
100
- _chunkALJSRZ4Zjs.__name.call(void 0, generateHTTPCode, "generateHTTPCode");
100
+ _chunkGWLM5DEJjs.__name.call(void 0, generateHTTPCode, "generateHTTPCode");
101
101
 
102
102
  // src/core.ts
103
103
  require('reflect-metadata');
@@ -108,7 +108,7 @@ var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
108
108
  function Injectable() {
109
109
  return (target) => _phecdacore.Empty.call(void 0, target);
110
110
  }
111
- _chunkALJSRZ4Zjs.__name.call(void 0, Injectable, "Injectable");
111
+ _chunkGWLM5DEJjs.__name.call(void 0, Injectable, "Injectable");
112
112
  var debug = _debug2.default.call(void 0, "phecda-server");
113
113
  var emitter = new (0, _events2.default)();
114
114
  async function Factory(Modules, opts = {}) {
@@ -121,9 +121,9 @@ async function Factory(Modules, opts = {}) {
121
121
  if (!_phecdacore.getProperty.call(void 0, "watcher")) {
122
122
  _phecdacore.injectProperty.call(void 0, "watcher", ({ eventName, instance, key, options }) => {
123
123
  const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
124
- if (!instance[_chunkALJSRZ4Zjs.UNMOUNT_SYMBOL])
125
- instance[_chunkALJSRZ4Zjs.UNMOUNT_SYMBOL] = [];
126
- instance[_chunkALJSRZ4Zjs.UNMOUNT_SYMBOL].push(() => {
124
+ if (!instance[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL])
125
+ instance[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL] = [];
126
+ instance[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL].push(() => {
127
127
  emitter.off(eventName, fn);
128
128
  });
129
129
  if (_optionalChain([options, 'optionalAccess', _2 => _2.once]))
@@ -137,8 +137,8 @@ async function Factory(Modules, opts = {}) {
137
137
  return;
138
138
  const instance = moduleMap.get(tag);
139
139
  debug(`unmount module "${tag}"`);
140
- if (_optionalChain([instance, 'optionalAccess', _3 => _3[_chunkALJSRZ4Zjs.UNMOUNT_SYMBOL]])) {
141
- for (const cb of instance[_chunkALJSRZ4Zjs.UNMOUNT_SYMBOL])
140
+ if (_optionalChain([instance, 'optionalAccess', _3 => _3[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL]])) {
141
+ for (const cb of instance[_chunkGWLM5DEJjs.UNMOUNT_SYMBOL])
142
142
  await cb();
143
143
  }
144
144
  debug(`del module "${tag}"`);
@@ -150,7 +150,13 @@ async function Factory(Modules, opts = {}) {
150
150
  }
151
151
  return instance;
152
152
  }
153
- _chunkALJSRZ4Zjs.__name.call(void 0, del, "del");
153
+ _chunkGWLM5DEJjs.__name.call(void 0, del, "del");
154
+ async function destroy() {
155
+ debug("destroy all");
156
+ for (const [tag] of moduleMap)
157
+ await del(tag);
158
+ }
159
+ _chunkGWLM5DEJjs.__name.call(void 0, destroy, "destroy");
154
160
  async function add(Module) {
155
161
  const tag = _optionalChain([Module, 'access', _4 => _4.prototype, 'optionalAccess', _5 => _5.__TAG__]) || Module.name;
156
162
  const oldInstance = await del(tag);
@@ -168,7 +174,7 @@ async function Factory(Modules, opts = {}) {
168
174
  });
169
175
  }
170
176
  }
171
- _chunkALJSRZ4Zjs.__name.call(void 0, add, "add");
177
+ _chunkGWLM5DEJjs.__name.call(void 0, add, "add");
172
178
  async function buildNestModule(Module) {
173
179
  const paramtypes = getParamTypes(Module);
174
180
  let instance;
@@ -179,7 +185,7 @@ async function Factory(Modules, opts = {}) {
179
185
  throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${tag}--[module] ${Module}`);
180
186
  if (constructorMap.get(tag) !== Module && !constructorSet.has(Module)) {
181
187
  constructorSet.add(Module);
182
- _chunkALJSRZ4Zjs.log.call(void 0, `Synonym module: Module taged "${tag}" has been loaded before, so phecda-server won't load Module "${Module.name}"`, "warn");
188
+ _chunkGWLM5DEJjs.log.call(void 0, `Synonym module: Module taged "${tag}" has been loaded before, so phecda-server won't load Module "${Module.name}"`, "warn");
183
189
  }
184
190
  return {
185
191
  instance,
@@ -212,7 +218,7 @@ async function Factory(Modules, opts = {}) {
212
218
  tag
213
219
  };
214
220
  }
215
- _chunkALJSRZ4Zjs.__name.call(void 0, buildNestModule, "buildNestModule");
221
+ _chunkGWLM5DEJjs.__name.call(void 0, buildNestModule, "buildNestModule");
216
222
  for (const Module of Modules)
217
223
  await buildNestModule(Module);
218
224
  function writeCode() {
@@ -225,9 +231,9 @@ async function Factory(Modules, opts = {}) {
225
231
  _fs2.default.promises.writeFile(rpc, generateRPCCode(meta.map((item) => item.data)));
226
232
  }
227
233
  }
228
- _chunkALJSRZ4Zjs.__name.call(void 0, writeCode, "writeCode");
234
+ _chunkGWLM5DEJjs.__name.call(void 0, writeCode, "writeCode");
229
235
  writeCode();
230
- if (_chunkALJSRZ4Zjs.IS_DEV) {
236
+ if (_chunkGWLM5DEJjs.IS_DEV) {
231
237
  if (!globalThis.__PS_HMR__)
232
238
  globalThis.__PS_HMR__ = [];
233
239
  _optionalChain([globalThis, 'access', _6 => _6.__PS_HMR__, 'optionalAccess', _7 => _7.push, 'call', _8 => _8(async (files) => {
@@ -247,10 +253,11 @@ async function Factory(Modules, opts = {}) {
247
253
  meta,
248
254
  constructorMap,
249
255
  add,
250
- del
256
+ del,
257
+ destroy
251
258
  };
252
259
  }
253
- _chunkALJSRZ4Zjs.__name.call(void 0, Factory, "Factory");
260
+ _chunkGWLM5DEJjs.__name.call(void 0, Factory, "Factory");
254
261
  function getMetaFromInstance(instance, tag, name) {
255
262
  const vars = _phecdacore.getExposeKey.call(void 0, instance).filter((item) => item !== _phecdacore.SHARE_KEY);
256
263
  const baseState = _phecdacore.getState.call(void 0, instance, _phecdacore.SHARE_KEY) || {};
@@ -313,11 +320,11 @@ function getMetaFromInstance(instance, tag, name) {
313
320
  return new Meta(meta, _phecdacore.getHandler.call(void 0, instance, i), getParamTypes(instance, i) || []);
314
321
  });
315
322
  }
316
- _chunkALJSRZ4Zjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
323
+ _chunkGWLM5DEJjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
317
324
  function getParamTypes(Module, key) {
318
325
  return Reflect.getMetadata("design:paramtypes", Module, key);
319
326
  }
320
- _chunkALJSRZ4Zjs.__name.call(void 0, getParamTypes, "getParamTypes");
327
+ _chunkGWLM5DEJjs.__name.call(void 0, getParamTypes, "getParamTypes");
321
328
  function initState(state) {
322
329
  if (!state.define)
323
330
  state.define = {};
@@ -330,7 +337,7 @@ function initState(state) {
330
337
  if (!state.interceptors)
331
338
  state.interceptors = [];
332
339
  }
333
- _chunkALJSRZ4Zjs.__name.call(void 0, initState, "initState");
340
+ _chunkGWLM5DEJjs.__name.call(void 0, initState, "initState");
334
341
 
335
342
 
336
343
 
@@ -14,15 +14,18 @@ var META_SYMBOL = "__PS_META__";
14
14
  var APP_SYMBOL = "__PS__";
15
15
  var IS_DEV = process.env.NODE_ENV === "development";
16
16
  var IS_STRICT = !!process.env.PS_STRICT;
17
+ var IS_LOG_BAN = !!process.env.PS_LOG_BAN;
17
18
  var ERROR_SYMBOL = "__PS_ERROR__";
18
- var PS_FILE_RE = /\.(controller|service|module|extension|guard|interceptor|plugin|filter|pipe|edge)\.ts$/i;
19
- var PS_IMPORT_RE = /\.(controller|extension|guard|interceptor|plugin|filter|pipe|edge)\.ts$/i;
19
+ var PS_FILE_RE = /\.(controller|service|module|extension|ext|guard|interceptor|addon|filter|pipe|edge)\.ts$/i;
20
+ var PS_IMPORT_RE = /\.(controller|extension|ext|guard|interceptor|addon|filter|pipe|edge)\.ts$/i;
20
21
 
21
22
  // src/utils.ts
22
23
  import pc from "picocolors";
23
24
  import { DataMap } from "phecda-core";
24
25
  var time;
25
26
  function log(msg, level = "info") {
27
+ if (IS_LOG_BAN)
28
+ return;
26
29
  const color = {
27
30
  error: "red",
28
31
  info: "green",
@@ -50,6 +53,15 @@ function setConfig(key, conf, force = true) {
50
53
  DataMap[key] = conf;
51
54
  }
52
55
  __name(setConfig, "setConfig");
56
+ function Mix(InternalClass, ExtendClass) {
57
+ return class extends ExtendClass {
58
+ constructor(...args) {
59
+ super(...args);
60
+ Object.assign(this, new InternalClass());
61
+ }
62
+ };
63
+ }
64
+ __name(Mix, "Mix");
53
65
 
54
66
  export {
55
67
  __name,
@@ -61,10 +73,12 @@ export {
61
73
  APP_SYMBOL,
62
74
  IS_DEV,
63
75
  IS_STRICT,
76
+ IS_LOG_BAN,
64
77
  ERROR_SYMBOL,
65
78
  PS_FILE_RE,
66
79
  PS_IMPORT_RE,
67
80
  log,
68
81
  getConfig,
69
- setConfig
82
+ setConfig,
83
+ Mix
70
84
  };
@@ -14,15 +14,18 @@ var META_SYMBOL = "__PS_META__";
14
14
  var APP_SYMBOL = "__PS__";
15
15
  var IS_DEV = process.env.NODE_ENV === "development";
16
16
  var IS_STRICT = !!process.env.PS_STRICT;
17
+ var IS_LOG_BAN = !!process.env.PS_LOG_BAN;
17
18
  var ERROR_SYMBOL = "__PS_ERROR__";
18
- var PS_FILE_RE = /\.(controller|service|module|extension|guard|interceptor|plugin|filter|pipe|edge)\.ts$/i;
19
- var PS_IMPORT_RE = /\.(controller|extension|guard|interceptor|plugin|filter|pipe|edge)\.ts$/i;
19
+ var PS_FILE_RE = /\.(controller|service|module|extension|ext|guard|interceptor|addon|filter|pipe|edge)\.ts$/i;
20
+ var PS_IMPORT_RE = /\.(controller|extension|ext|guard|interceptor|addon|filter|pipe|edge)\.ts$/i;
20
21
 
21
22
  // src/utils.ts
22
23
  var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
23
24
  var _phecdacore = require('phecda-core');
24
25
  var time;
25
26
  function log(msg, level = "info") {
27
+ if (IS_LOG_BAN)
28
+ return;
26
29
  const color = {
27
30
  error: "red",
28
31
  info: "green",
@@ -50,6 +53,17 @@ function setConfig(key, conf, force = true) {
50
53
  _phecdacore.DataMap[key] = conf;
51
54
  }
52
55
  __name(setConfig, "setConfig");
56
+ function Mix(InternalClass, ExtendClass) {
57
+ return class extends ExtendClass {
58
+ constructor(...args) {
59
+ super(...args);
60
+ Object.assign(this, new InternalClass());
61
+ }
62
+ };
63
+ }
64
+ __name(Mix, "Mix");
65
+
66
+
53
67
 
54
68
 
55
69
 
@@ -67,4 +81,4 @@ __name(setConfig, "setConfig");
67
81
 
68
82
 
69
83
 
70
- exports.__name = __name; exports.__publicField = __publicField; exports.MERGE_SYMBOL = MERGE_SYMBOL; exports.UNMOUNT_SYMBOL = UNMOUNT_SYMBOL; exports.MODULE_SYMBOL = MODULE_SYMBOL; exports.META_SYMBOL = META_SYMBOL; exports.APP_SYMBOL = APP_SYMBOL; exports.IS_DEV = IS_DEV; exports.IS_STRICT = IS_STRICT; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.PS_FILE_RE = PS_FILE_RE; exports.PS_IMPORT_RE = PS_IMPORT_RE; exports.log = log; exports.getConfig = getConfig; exports.setConfig = setConfig;
84
+ exports.__name = __name; exports.__publicField = __publicField; exports.MERGE_SYMBOL = MERGE_SYMBOL; exports.UNMOUNT_SYMBOL = UNMOUNT_SYMBOL; exports.MODULE_SYMBOL = MODULE_SYMBOL; exports.META_SYMBOL = META_SYMBOL; exports.APP_SYMBOL = APP_SYMBOL; exports.IS_DEV = IS_DEV; exports.IS_STRICT = IS_STRICT; exports.IS_LOG_BAN = IS_LOG_BAN; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.PS_FILE_RE = PS_FILE_RE; exports.PS_IMPORT_RE = PS_IMPORT_RE; exports.log = log; exports.getConfig = getConfig; exports.setConfig = setConfig; exports.Mix = Mix;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-WB437JJ2.mjs";
3
+ } from "./chunk-DJO45NRZ.mjs";
4
4
 
5
5
  // src/helper.ts
6
6
  function resolveDep(ret, key) {
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkALJSRZ4Zjs = require('./chunk-ALJSRZ4Z.js');
8
+ var _chunkGWLM5DEJjs = require('./chunk-GWLM5DEJ.js');
9
9
 
10
10
  // src/exception/base.ts
11
11
  var Exception = class extends Error {
@@ -23,11 +23,11 @@ var Exception = class extends Error {
23
23
  message: this.message,
24
24
  description: this.description,
25
25
  status: this.status,
26
- [_chunkALJSRZ4Zjs.ERROR_SYMBOL]: true
26
+ [_chunkGWLM5DEJjs.ERROR_SYMBOL]: true
27
27
  };
28
28
  }
29
29
  };
30
- _chunkALJSRZ4Zjs.__name.call(void 0, Exception, "Exception");
30
+ _chunkGWLM5DEJjs.__name.call(void 0, Exception, "Exception");
31
31
 
32
32
  // src/exception/validate.ts
33
33
  var ValidateException = class extends Exception {
@@ -35,11 +35,11 @@ var ValidateException = class extends Exception {
35
35
  super(message, 400, "Validate exception");
36
36
  }
37
37
  };
38
- _chunkALJSRZ4Zjs.__name.call(void 0, ValidateException, "ValidateException");
38
+ _chunkGWLM5DEJjs.__name.call(void 0, ValidateException, "ValidateException");
39
39
 
40
40
  // src/pipe.ts
41
41
  var _phecdacore = require('phecda-core');
42
- var defaultPipe = /* @__PURE__ */ _chunkALJSRZ4Zjs.__name.call(void 0, async ({ arg, reflect, index }) => {
42
+ var defaultPipe = /* @__PURE__ */ _chunkGWLM5DEJjs.__name.call(void 0, async ({ arg, reflect, index }) => {
43
43
  if (_phecdacore.isPhecda.call(void 0, reflect)) {
44
44
  const instance = _phecdacore.plainToClass.call(void 0, reflect, arg);
45
45
  const err = await _phecdacore.transformClass.call(void 0, instance);
@@ -65,7 +65,7 @@ var UndefinedException = class extends Exception {
65
65
  super(message, 500, "Undefined error");
66
66
  }
67
67
  };
68
- _chunkALJSRZ4Zjs.__name.call(void 0, UndefinedException, "UndefinedException");
68
+ _chunkGWLM5DEJjs.__name.call(void 0, UndefinedException, "UndefinedException");
69
69
 
70
70
  // src/exception/forbidden.ts
71
71
  var ForbiddenException = class extends Exception {
@@ -73,7 +73,7 @@ var ForbiddenException = class extends Exception {
73
73
  super(message, 403, "Forbidden resource");
74
74
  }
75
75
  };
76
- _chunkALJSRZ4Zjs.__name.call(void 0, ForbiddenException, "ForbiddenException");
76
+ _chunkGWLM5DEJjs.__name.call(void 0, ForbiddenException, "ForbiddenException");
77
77
 
78
78
  // src/exception/bad-request.ts
79
79
  var BadRequestException = class extends Exception {
@@ -81,7 +81,7 @@ var BadRequestException = class extends Exception {
81
81
  super(message, 400, "Bad Request");
82
82
  }
83
83
  };
84
- _chunkALJSRZ4Zjs.__name.call(void 0, BadRequestException, "BadRequestException");
84
+ _chunkGWLM5DEJjs.__name.call(void 0, BadRequestException, "BadRequestException");
85
85
 
86
86
  // src/exception/not-found.ts
87
87
  var NotFoundException = class extends Exception {
@@ -89,7 +89,7 @@ var NotFoundException = class extends Exception {
89
89
  super(message, 404, "Not Found");
90
90
  }
91
91
  };
92
- _chunkALJSRZ4Zjs.__name.call(void 0, NotFoundException, "NotFoundException");
92
+ _chunkGWLM5DEJjs.__name.call(void 0, NotFoundException, "NotFoundException");
93
93
 
94
94
  // src/exception/conflict.ts
95
95
  var ConflictException = class extends Exception {
@@ -97,7 +97,7 @@ var ConflictException = class extends Exception {
97
97
  super(message, 409, "Conflict");
98
98
  }
99
99
  };
100
- _chunkALJSRZ4Zjs.__name.call(void 0, ConflictException, "ConflictException");
100
+ _chunkGWLM5DEJjs.__name.call(void 0, ConflictException, "ConflictException");
101
101
 
102
102
  // src/exception/bad-gateway.ts
103
103
  var BadGatewayException = class extends Exception {
@@ -105,7 +105,7 @@ var BadGatewayException = class extends Exception {
105
105
  super(message, 502, "Bad Gatrway");
106
106
  }
107
107
  };
108
- _chunkALJSRZ4Zjs.__name.call(void 0, BadGatewayException, "BadGatewayException");
108
+ _chunkGWLM5DEJjs.__name.call(void 0, BadGatewayException, "BadGatewayException");
109
109
 
110
110
  // src/exception/invalid-input.ts
111
111
  var InvalidInputException = class extends Exception {
@@ -113,7 +113,7 @@ var InvalidInputException = class extends Exception {
113
113
  super(message, 502, "Invalid Input");
114
114
  }
115
115
  };
116
- _chunkALJSRZ4Zjs.__name.call(void 0, InvalidInputException, "InvalidInputException");
116
+ _chunkGWLM5DEJjs.__name.call(void 0, InvalidInputException, "InvalidInputException");
117
117
 
118
118
  // src/exception/media-type.ts
119
119
  var UnsupportedMediaTypeException = class extends Exception {
@@ -121,7 +121,7 @@ var UnsupportedMediaTypeException = class extends Exception {
121
121
  super(message, 415, "Unsupported Media Type");
122
122
  }
123
123
  };
124
- _chunkALJSRZ4Zjs.__name.call(void 0, UnsupportedMediaTypeException, "UnsupportedMediaTypeException");
124
+ _chunkGWLM5DEJjs.__name.call(void 0, UnsupportedMediaTypeException, "UnsupportedMediaTypeException");
125
125
 
126
126
  // src/exception/payload-large.ts
127
127
  var PayloadLargeException = class extends Exception {
@@ -129,7 +129,7 @@ var PayloadLargeException = class extends Exception {
129
129
  super(message, 413, "Payload Too Large");
130
130
  }
131
131
  };
132
- _chunkALJSRZ4Zjs.__name.call(void 0, PayloadLargeException, "PayloadLargeException");
132
+ _chunkGWLM5DEJjs.__name.call(void 0, PayloadLargeException, "PayloadLargeException");
133
133
 
134
134
  // src/exception/timeout.ts
135
135
  var TimeoutException = class extends Exception {
@@ -137,7 +137,7 @@ var TimeoutException = class extends Exception {
137
137
  super(message, 408, "Request Timeout");
138
138
  }
139
139
  };
140
- _chunkALJSRZ4Zjs.__name.call(void 0, TimeoutException, "TimeoutException");
140
+ _chunkGWLM5DEJjs.__name.call(void 0, TimeoutException, "TimeoutException");
141
141
 
142
142
  // src/exception/unauthorized.ts
143
143
  var UnauthorizedException = class extends Exception {
@@ -145,7 +145,7 @@ var UnauthorizedException = class extends Exception {
145
145
  super(message, 401, "Unauthorized");
146
146
  }
147
147
  };
148
- _chunkALJSRZ4Zjs.__name.call(void 0, UnauthorizedException, "UnauthorizedException");
148
+ _chunkGWLM5DEJjs.__name.call(void 0, UnauthorizedException, "UnauthorizedException");
149
149
 
150
150
  // src/exception/unavailable-service.ts
151
151
  var ServiceUnavailableException = class extends Exception {
@@ -153,7 +153,7 @@ var ServiceUnavailableException = class extends Exception {
153
153
  super(message, 503, "Service Unavailable");
154
154
  }
155
155
  };
156
- _chunkALJSRZ4Zjs.__name.call(void 0, ServiceUnavailableException, "ServiceUnavailableException");
156
+ _chunkGWLM5DEJjs.__name.call(void 0, ServiceUnavailableException, "ServiceUnavailableException");
157
157
 
158
158
  // src/exception/framework.ts
159
159
  var FrameworkException = class extends Exception {
@@ -161,24 +161,20 @@ var FrameworkException = class extends Exception {
161
161
  super(`[phecda-server] ${message}`, 500, "Framework Error");
162
162
  }
163
163
  };
164
- _chunkALJSRZ4Zjs.__name.call(void 0, FrameworkException, "FrameworkException");
164
+ _chunkGWLM5DEJjs.__name.call(void 0, FrameworkException, "FrameworkException");
165
165
 
166
166
  // src/context.ts
167
167
  var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
168
168
 
169
169
  // src/filter.ts
170
- var defaultFilter = /* @__PURE__ */ _chunkALJSRZ4Zjs.__name.call(void 0, (e) => {
170
+ var defaultFilter = /* @__PURE__ */ _chunkGWLM5DEJjs.__name.call(void 0, (e) => {
171
171
  if (!(e instanceof Exception)) {
172
- if (_chunkALJSRZ4Zjs.IS_DEV) {
173
- _chunkALJSRZ4Zjs.log.call(void 0, e.message, "error");
174
- console.error(e.stack);
175
- }
172
+ _chunkGWLM5DEJjs.log.call(void 0, e.message, "error");
173
+ console.error(e.stack);
176
174
  e = new UndefinedException(e.message || e);
177
175
  } else {
178
- if (_chunkALJSRZ4Zjs.IS_DEV) {
179
- _chunkALJSRZ4Zjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
180
- console.error(e.stack);
181
- }
176
+ _chunkGWLM5DEJjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
177
+ console.error(e.stack);
182
178
  }
183
179
  return e.data;
184
180
  }, "defaultFilter");
@@ -195,7 +191,7 @@ var Histroy = (_class = class {constructor() { _class.prototype.__init.call(this
195
191
  return false;
196
192
  }
197
193
  }, _class);
198
- _chunkALJSRZ4Zjs.__name.call(void 0, Histroy, "Histroy");
194
+ _chunkGWLM5DEJjs.__name.call(void 0, Histroy, "Histroy");
199
195
 
200
196
  // src/context.ts
201
197
  var guardRecord = {};
@@ -208,13 +204,13 @@ var _Context = class {
208
204
  constructor(data) {
209
205
  this.data = data;
210
206
  this.history = new Histroy();
211
- if (_chunkALJSRZ4Zjs.IS_DEV)
207
+ if (_chunkGWLM5DEJjs.IS_DEV)
212
208
  data._context = this;
213
209
  }
214
210
  usePipe(args) {
215
211
  return Promise.all(args.map((item) => {
216
212
  if (item.pipe && !_Context.pipeRecord[item.pipe]) {
217
- if (_chunkALJSRZ4Zjs.IS_STRICT)
213
+ if (_chunkGWLM5DEJjs.IS_STRICT)
218
214
  throw new FrameworkException(`can't find pipe named '${item.pipe}'`);
219
215
  else
220
216
  return _Context.pipeRecord.default(item, this.data);
@@ -224,7 +220,7 @@ var _Context = class {
224
220
  }
225
221
  useFilter(arg, filter = "default") {
226
222
  if (!_Context.filterRecord[filter]) {
227
- if (_chunkALJSRZ4Zjs.IS_STRICT)
223
+ if (_chunkGWLM5DEJjs.IS_STRICT)
228
224
  throw new FrameworkException(`can't find filter named '${filter}'`);
229
225
  else
230
226
  return _Context.filterRecord.default(arg, this.data);
@@ -235,7 +231,7 @@ var _Context = class {
235
231
  for (const guard of guards) {
236
232
  if (this.history.record(guard, "guard")) {
237
233
  if (!(guard in _Context.guardRecord)) {
238
- if (_chunkALJSRZ4Zjs.IS_STRICT)
234
+ if (_chunkGWLM5DEJjs.IS_STRICT)
239
235
  throw new FrameworkException(`can't find guard named '${guard}'`);
240
236
  continue;
241
237
  }
@@ -254,7 +250,7 @@ var _Context = class {
254
250
  for (const interceptor of interceptors) {
255
251
  if (this.history.record(interceptor, "interceptor")) {
256
252
  if (!(interceptor in _Context.interceptorRecord)) {
257
- if (_chunkALJSRZ4Zjs.IS_STRICT)
253
+ if (_chunkGWLM5DEJjs.IS_STRICT)
258
254
  throw new FrameworkException(`can't find interceptor named '${interceptor}'`);
259
255
  continue;
260
256
  }
@@ -272,50 +268,58 @@ var _Context = class {
272
268
  static usePlugin(plugins) {
273
269
  const ret = [];
274
270
  for (const m of plugins) {
275
- if (!(m in _Context.pluginRecord)) {
276
- if (_chunkALJSRZ4Zjs.IS_STRICT)
271
+ if (!(m in _Context.addonRecord)) {
272
+ if (_chunkGWLM5DEJjs.IS_STRICT)
277
273
  throw new FrameworkException(`can't find middleware named '${m}'`);
278
274
  continue;
279
275
  }
280
- ret.push(_Context.pluginRecord[m]);
276
+ ret.push(_Context.addonRecord[m]);
281
277
  }
282
278
  return ret;
283
279
  }
284
280
  };
285
281
  var Context = _Context;
286
- _chunkALJSRZ4Zjs.__name.call(void 0, Context, "Context");
287
- _chunkALJSRZ4Zjs.__publicField.call(void 0, Context, "filterRecord", {
282
+ _chunkGWLM5DEJjs.__name.call(void 0, Context, "Context");
283
+ _chunkGWLM5DEJjs.__publicField.call(void 0, Context, "filterRecord", {
288
284
  default: defaultFilter
289
285
  });
290
- _chunkALJSRZ4Zjs.__publicField.call(void 0, Context, "pipeRecord", {
286
+ _chunkGWLM5DEJjs.__publicField.call(void 0, Context, "pipeRecord", {
291
287
  default: defaultPipe
292
288
  });
293
- _chunkALJSRZ4Zjs.__publicField.call(void 0, Context, "guardRecord", {});
294
- _chunkALJSRZ4Zjs.__publicField.call(void 0, Context, "interceptorRecord", {});
295
- _chunkALJSRZ4Zjs.__publicField.call(void 0, Context, "pluginRecord", {});
296
- function addPlugin(key, handler) {
297
- Context.pluginRecord[key] = handler;
289
+ _chunkGWLM5DEJjs.__publicField.call(void 0, Context, "guardRecord", {});
290
+ _chunkGWLM5DEJjs.__publicField.call(void 0, Context, "interceptorRecord", {});
291
+ _chunkGWLM5DEJjs.__publicField.call(void 0, Context, "addonRecord", {});
292
+ function addAddon(key, handler) {
293
+ if (Context.addonRecord[key] && Context.addonRecord[key] !== handler)
294
+ _chunkGWLM5DEJjs.log.call(void 0, `overwrite Addon "${key}"`, "warn");
295
+ Context.addonRecord[key] = handler;
298
296
  }
299
- _chunkALJSRZ4Zjs.__name.call(void 0, addPlugin, "addPlugin");
300
- function addPipe(key, pipe) {
301
- Context.pipeRecord[key] = pipe;
297
+ _chunkGWLM5DEJjs.__name.call(void 0, addAddon, "addAddon");
298
+ function addPipe(key, handler) {
299
+ if (Context.pipeRecord[key] && Context.pipeRecord[key] !== handler)
300
+ _chunkGWLM5DEJjs.log.call(void 0, `overwrite Pipe "${key}"`, "warn");
301
+ Context.pipeRecord[key] = handler;
302
302
  }
303
- _chunkALJSRZ4Zjs.__name.call(void 0, addPipe, "addPipe");
303
+ _chunkGWLM5DEJjs.__name.call(void 0, addPipe, "addPipe");
304
304
  function addFilter(key, handler) {
305
+ if (Context.filterRecord[key] && Context.filterRecord[key] !== handler)
306
+ _chunkGWLM5DEJjs.log.call(void 0, `overwrite Filter "${key}"`, "warn");
305
307
  Context.filterRecord[key] = handler;
306
308
  }
307
- _chunkALJSRZ4Zjs.__name.call(void 0, addFilter, "addFilter");
309
+ _chunkGWLM5DEJjs.__name.call(void 0, addFilter, "addFilter");
308
310
  function addGuard(key, handler) {
311
+ if (Context.guardRecord[key] && Context.guardRecord[key] !== handler)
312
+ _chunkGWLM5DEJjs.log.call(void 0, `overwrite Guard "${key}"`, "warn");
309
313
  Context.guardRecord[key] = handler;
310
314
  }
311
- _chunkALJSRZ4Zjs.__name.call(void 0, addGuard, "addGuard");
315
+ _chunkGWLM5DEJjs.__name.call(void 0, addGuard, "addGuard");
312
316
  function addInterceptor(key, handler) {
317
+ if (Context.interceptorRecord[key] && Context.interceptorRecord[key] !== handler)
318
+ _chunkGWLM5DEJjs.log.call(void 0, `overwrite Interceptor "${key}"`, "warn");
313
319
  Context.interceptorRecord[key] = handler;
314
320
  }
315
- _chunkALJSRZ4Zjs.__name.call(void 0, addInterceptor, "addInterceptor");
321
+ _chunkGWLM5DEJjs.__name.call(void 0, addInterceptor, "addInterceptor");
316
322
  function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
317
- if (!_chunkALJSRZ4Zjs.IS_DEV)
318
- return;
319
323
  const pluginSet = new Set(plugins);
320
324
  const guardSet = new Set(guards);
321
325
  const interceptorSet = new Set(interceptors);
@@ -334,7 +338,7 @@ function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
334
338
  });
335
339
  const missPlugins = [
336
340
  ...pluginSet
337
- ].filter((i) => !Context.pluginRecord[i]);
341
+ ].filter((i) => !Context.addonRecord[i]);
338
342
  const missGuards = [
339
343
  ...guardSet
340
344
  ].filter((i) => !Context.guardRecord[i]);
@@ -348,17 +352,17 @@ function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
348
352
  ...filterSet
349
353
  ].filter((i) => !Context.filterRecord[i]);
350
354
  if (missPlugins.length)
351
- _chunkALJSRZ4Zjs.log.call(void 0, `${_picocolors2.default.white(`Plugin [${missPlugins.join(",")}]`)} doesn't exist`, "warn");
355
+ _chunkGWLM5DEJjs.log.call(void 0, `${_picocolors2.default.white(`Plugin [${missPlugins.join(",")}]`)} doesn't exist`, "warn");
352
356
  if (missGuards.length)
353
- _chunkALJSRZ4Zjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
357
+ _chunkGWLM5DEJjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
354
358
  if (missInterceptors.length)
355
- _chunkALJSRZ4Zjs.log.call(void 0, `${_picocolors2.default.cyan(`Interceptor [${missInterceptors.join(",")}]`)} doesn't exist`, "warn");
359
+ _chunkGWLM5DEJjs.log.call(void 0, `${_picocolors2.default.cyan(`Interceptor [${missInterceptors.join(",")}]`)} doesn't exist`, "warn");
356
360
  if (missPipes.length)
357
- _chunkALJSRZ4Zjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
361
+ _chunkGWLM5DEJjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
358
362
  if (missFilters.length)
359
- _chunkALJSRZ4Zjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
363
+ _chunkGWLM5DEJjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
360
364
  }
361
- _chunkALJSRZ4Zjs.__name.call(void 0, isAopDepInject, "isAopDepInject");
365
+ _chunkGWLM5DEJjs.__name.call(void 0, isAopDepInject, "isAopDepInject");
362
366
 
363
367
 
364
368
 
@@ -385,4 +389,4 @@ _chunkALJSRZ4Zjs.__name.call(void 0, isAopDepInject, "isAopDepInject");
385
389
 
386
390
 
387
391
 
388
- exports.Exception = Exception; exports.ValidateException = ValidateException; exports.defaultPipe = defaultPipe; exports.UndefinedException = UndefinedException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.guardRecord = guardRecord; exports.Context = Context; exports.addPlugin = addPlugin; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addInterceptor = addInterceptor; exports.isAopDepInject = isAopDepInject;
392
+ exports.Exception = Exception; exports.ValidateException = ValidateException; exports.defaultPipe = defaultPipe; exports.UndefinedException = UndefinedException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.guardRecord = guardRecord; exports.Context = Context; exports.addAddon = addAddon; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addInterceptor = addInterceptor; exports.isAopDepInject = isAopDepInject;