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

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-GY5KXMJJ.js → chunk-2AI7ID6X.js} +2 -2
  2. package/dist/{chunk-CLW7EYYD.js → chunk-ANH53I6B.js} +30 -23
  3. package/dist/{chunk-ALJSRZ4Z.js → chunk-C36XJ7D3.js} +11 -1
  4. package/dist/{chunk-DBYLTVRY.mjs → chunk-JJG37LHY.mjs} +1 -1
  5. package/dist/{chunk-WB437JJ2.mjs → chunk-KGMDCF26.mjs} +11 -1
  6. package/dist/{chunk-BXJSLR46.mjs → chunk-KKTRNKCF.mjs} +9 -2
  7. package/dist/{chunk-EP4EN3MM.mjs → chunk-MZBE4NIO.mjs} +1 -1
  8. package/dist/{chunk-ZV4O77YM.js → chunk-P5LJBZPN.js} +48 -48
  9. package/dist/{core-fe0991cd.d.ts → core-39d78b79.d.ts} +1 -0
  10. package/dist/index.d.ts +5 -3
  11. package/dist/index.js +58 -56
  12. package/dist/index.mjs +6 -4
  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 +2 -2
  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 +2 -2
  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 +2 -2
  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 +3 -3
  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 +3 -3
  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 +3 -3
  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 +3 -3
  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
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkALJSRZ4Zjs = require('./chunk-ALJSRZ4Z.js');
3
+ var _chunkC36XJ7D3js = require('./chunk-C36XJ7D3.js');
4
4
 
5
5
  // src/helper.ts
6
6
  function resolveDep(ret, key) {
@@ -8,7 +8,7 @@ function resolveDep(ret, key) {
8
8
  return _optionalChain([ret, 'optionalAccess', _ => _[key]]);
9
9
  return ret;
10
10
  }
11
- _chunkALJSRZ4Zjs.__name.call(void 0, resolveDep, "resolveDep");
11
+ _chunkC36XJ7D3js.__name.call(void 0, resolveDep, "resolveDep");
12
12
 
13
13
 
14
14
 
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkALJSRZ4Zjs = require('./chunk-ALJSRZ4Z.js');
6
+ var _chunkC36XJ7D3js = require('./chunk-C36XJ7D3.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
+ _chunkC36XJ7D3js.__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__ */ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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__ */ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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[_chunkC36XJ7D3js.UNMOUNT_SYMBOL])
125
+ instance[_chunkC36XJ7D3js.UNMOUNT_SYMBOL] = [];
126
+ instance[_chunkC36XJ7D3js.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[_chunkC36XJ7D3js.UNMOUNT_SYMBOL]])) {
141
+ for (const cb of instance[_chunkC36XJ7D3js.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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__name.call(void 0, writeCode, "writeCode");
229
235
  writeCode();
230
- if (_chunkALJSRZ4Zjs.IS_DEV) {
236
+ if (_chunkC36XJ7D3js.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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__name.call(void 0, initState, "initState");
334
341
 
335
342
 
336
343
 
@@ -50,6 +50,16 @@ function setConfig(key, conf, force = true) {
50
50
  _phecdacore.DataMap[key] = conf;
51
51
  }
52
52
  __name(setConfig, "setConfig");
53
+ function Mix(InternalClass, ExtendClass) {
54
+ return class extends ExtendClass {
55
+ constructor(...args) {
56
+ super(...args);
57
+ Object.assign(this, new InternalClass());
58
+ }
59
+ };
60
+ }
61
+ __name(Mix, "Mix");
62
+
53
63
 
54
64
 
55
65
 
@@ -67,4 +77,4 @@ __name(setConfig, "setConfig");
67
77
 
68
78
 
69
79
 
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;
80
+ 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; exports.Mix = Mix;
@@ -5,7 +5,7 @@ import {
5
5
  __name,
6
6
  __publicField,
7
7
  log
8
- } from "./chunk-WB437JJ2.mjs";
8
+ } from "./chunk-KGMDCF26.mjs";
9
9
 
10
10
  // src/exception/base.ts
11
11
  var Exception = class extends Error {
@@ -50,6 +50,15 @@ function setConfig(key, conf, force = true) {
50
50
  DataMap[key] = conf;
51
51
  }
52
52
  __name(setConfig, "setConfig");
53
+ function Mix(InternalClass, ExtendClass) {
54
+ return class extends ExtendClass {
55
+ constructor(...args) {
56
+ super(...args);
57
+ Object.assign(this, new InternalClass());
58
+ }
59
+ };
60
+ }
61
+ __name(Mix, "Mix");
53
62
 
54
63
  export {
55
64
  __name,
@@ -66,5 +75,6 @@ export {
66
75
  PS_IMPORT_RE,
67
76
  log,
68
77
  getConfig,
69
- setConfig
78
+ setConfig,
79
+ Mix
70
80
  };
@@ -3,7 +3,7 @@ import {
3
3
  UNMOUNT_SYMBOL,
4
4
  __name,
5
5
  log
6
- } from "./chunk-WB437JJ2.mjs";
6
+ } from "./chunk-KGMDCF26.mjs";
7
7
 
8
8
  // src/meta.ts
9
9
  var Meta = class {
@@ -151,6 +151,12 @@ async function Factory(Modules, opts = {}) {
151
151
  return instance;
152
152
  }
153
153
  __name(del, "del");
154
+ async function destroy() {
155
+ debug("destroy all");
156
+ for (const [tag] of moduleMap)
157
+ await del(tag);
158
+ }
159
+ __name(destroy, "destroy");
154
160
  async function add(Module) {
155
161
  const tag = Module.prototype?.__TAG__ || Module.name;
156
162
  const oldInstance = await del(tag);
@@ -247,7 +253,8 @@ 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
260
  __name(Factory, "Factory");
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-WB437JJ2.mjs";
3
+ } from "./chunk-KGMDCF26.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 _chunkC36XJ7D3js = require('./chunk-C36XJ7D3.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
+ [_chunkC36XJ7D3js.ERROR_SYMBOL]: true
27
27
  };
28
28
  }
29
29
  };
30
- _chunkALJSRZ4Zjs.__name.call(void 0, Exception, "Exception");
30
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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__ */ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__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
+ _chunkC36XJ7D3js.__name.call(void 0, ServiceUnavailableException, "ServiceUnavailableException");
157
157
 
158
158
  // src/exception/framework.ts
159
159
  var FrameworkException = class extends Exception {
@@ -161,22 +161,22 @@ 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
+ _chunkC36XJ7D3js.__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__ */ _chunkC36XJ7D3js.__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");
172
+ if (_chunkC36XJ7D3js.IS_DEV) {
173
+ _chunkC36XJ7D3js.log.call(void 0, e.message, "error");
174
174
  console.error(e.stack);
175
175
  }
176
176
  e = new UndefinedException(e.message || e);
177
177
  } else {
178
- if (_chunkALJSRZ4Zjs.IS_DEV) {
179
- _chunkALJSRZ4Zjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
178
+ if (_chunkC36XJ7D3js.IS_DEV) {
179
+ _chunkC36XJ7D3js.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
180
180
  console.error(e.stack);
181
181
  }
182
182
  }
@@ -195,7 +195,7 @@ var Histroy = (_class = class {constructor() { _class.prototype.__init.call(this
195
195
  return false;
196
196
  }
197
197
  }, _class);
198
- _chunkALJSRZ4Zjs.__name.call(void 0, Histroy, "Histroy");
198
+ _chunkC36XJ7D3js.__name.call(void 0, Histroy, "Histroy");
199
199
 
200
200
  // src/context.ts
201
201
  var guardRecord = {};
@@ -208,13 +208,13 @@ var _Context = class {
208
208
  constructor(data) {
209
209
  this.data = data;
210
210
  this.history = new Histroy();
211
- if (_chunkALJSRZ4Zjs.IS_DEV)
211
+ if (_chunkC36XJ7D3js.IS_DEV)
212
212
  data._context = this;
213
213
  }
214
214
  usePipe(args) {
215
215
  return Promise.all(args.map((item) => {
216
216
  if (item.pipe && !_Context.pipeRecord[item.pipe]) {
217
- if (_chunkALJSRZ4Zjs.IS_STRICT)
217
+ if (_chunkC36XJ7D3js.IS_STRICT)
218
218
  throw new FrameworkException(`can't find pipe named '${item.pipe}'`);
219
219
  else
220
220
  return _Context.pipeRecord.default(item, this.data);
@@ -224,7 +224,7 @@ var _Context = class {
224
224
  }
225
225
  useFilter(arg, filter = "default") {
226
226
  if (!_Context.filterRecord[filter]) {
227
- if (_chunkALJSRZ4Zjs.IS_STRICT)
227
+ if (_chunkC36XJ7D3js.IS_STRICT)
228
228
  throw new FrameworkException(`can't find filter named '${filter}'`);
229
229
  else
230
230
  return _Context.filterRecord.default(arg, this.data);
@@ -235,7 +235,7 @@ var _Context = class {
235
235
  for (const guard of guards) {
236
236
  if (this.history.record(guard, "guard")) {
237
237
  if (!(guard in _Context.guardRecord)) {
238
- if (_chunkALJSRZ4Zjs.IS_STRICT)
238
+ if (_chunkC36XJ7D3js.IS_STRICT)
239
239
  throw new FrameworkException(`can't find guard named '${guard}'`);
240
240
  continue;
241
241
  }
@@ -254,7 +254,7 @@ var _Context = class {
254
254
  for (const interceptor of interceptors) {
255
255
  if (this.history.record(interceptor, "interceptor")) {
256
256
  if (!(interceptor in _Context.interceptorRecord)) {
257
- if (_chunkALJSRZ4Zjs.IS_STRICT)
257
+ if (_chunkC36XJ7D3js.IS_STRICT)
258
258
  throw new FrameworkException(`can't find interceptor named '${interceptor}'`);
259
259
  continue;
260
260
  }
@@ -273,7 +273,7 @@ var _Context = class {
273
273
  const ret = [];
274
274
  for (const m of plugins) {
275
275
  if (!(m in _Context.pluginRecord)) {
276
- if (_chunkALJSRZ4Zjs.IS_STRICT)
276
+ if (_chunkC36XJ7D3js.IS_STRICT)
277
277
  throw new FrameworkException(`can't find middleware named '${m}'`);
278
278
  continue;
279
279
  }
@@ -283,38 +283,38 @@ var _Context = class {
283
283
  }
284
284
  };
285
285
  var Context = _Context;
286
- _chunkALJSRZ4Zjs.__name.call(void 0, Context, "Context");
287
- _chunkALJSRZ4Zjs.__publicField.call(void 0, Context, "filterRecord", {
286
+ _chunkC36XJ7D3js.__name.call(void 0, Context, "Context");
287
+ _chunkC36XJ7D3js.__publicField.call(void 0, Context, "filterRecord", {
288
288
  default: defaultFilter
289
289
  });
290
- _chunkALJSRZ4Zjs.__publicField.call(void 0, Context, "pipeRecord", {
290
+ _chunkC36XJ7D3js.__publicField.call(void 0, Context, "pipeRecord", {
291
291
  default: defaultPipe
292
292
  });
293
- _chunkALJSRZ4Zjs.__publicField.call(void 0, Context, "guardRecord", {});
294
- _chunkALJSRZ4Zjs.__publicField.call(void 0, Context, "interceptorRecord", {});
295
- _chunkALJSRZ4Zjs.__publicField.call(void 0, Context, "pluginRecord", {});
293
+ _chunkC36XJ7D3js.__publicField.call(void 0, Context, "guardRecord", {});
294
+ _chunkC36XJ7D3js.__publicField.call(void 0, Context, "interceptorRecord", {});
295
+ _chunkC36XJ7D3js.__publicField.call(void 0, Context, "pluginRecord", {});
296
296
  function addPlugin(key, handler) {
297
297
  Context.pluginRecord[key] = handler;
298
298
  }
299
- _chunkALJSRZ4Zjs.__name.call(void 0, addPlugin, "addPlugin");
299
+ _chunkC36XJ7D3js.__name.call(void 0, addPlugin, "addPlugin");
300
300
  function addPipe(key, pipe) {
301
301
  Context.pipeRecord[key] = pipe;
302
302
  }
303
- _chunkALJSRZ4Zjs.__name.call(void 0, addPipe, "addPipe");
303
+ _chunkC36XJ7D3js.__name.call(void 0, addPipe, "addPipe");
304
304
  function addFilter(key, handler) {
305
305
  Context.filterRecord[key] = handler;
306
306
  }
307
- _chunkALJSRZ4Zjs.__name.call(void 0, addFilter, "addFilter");
307
+ _chunkC36XJ7D3js.__name.call(void 0, addFilter, "addFilter");
308
308
  function addGuard(key, handler) {
309
309
  Context.guardRecord[key] = handler;
310
310
  }
311
- _chunkALJSRZ4Zjs.__name.call(void 0, addGuard, "addGuard");
311
+ _chunkC36XJ7D3js.__name.call(void 0, addGuard, "addGuard");
312
312
  function addInterceptor(key, handler) {
313
313
  Context.interceptorRecord[key] = handler;
314
314
  }
315
- _chunkALJSRZ4Zjs.__name.call(void 0, addInterceptor, "addInterceptor");
315
+ _chunkC36XJ7D3js.__name.call(void 0, addInterceptor, "addInterceptor");
316
316
  function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
317
- if (!_chunkALJSRZ4Zjs.IS_DEV)
317
+ if (!_chunkC36XJ7D3js.IS_DEV)
318
318
  return;
319
319
  const pluginSet = new Set(plugins);
320
320
  const guardSet = new Set(guards);
@@ -348,17 +348,17 @@ function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
348
348
  ...filterSet
349
349
  ].filter((i) => !Context.filterRecord[i]);
350
350
  if (missPlugins.length)
351
- _chunkALJSRZ4Zjs.log.call(void 0, `${_picocolors2.default.white(`Plugin [${missPlugins.join(",")}]`)} doesn't exist`, "warn");
351
+ _chunkC36XJ7D3js.log.call(void 0, `${_picocolors2.default.white(`Plugin [${missPlugins.join(",")}]`)} doesn't exist`, "warn");
352
352
  if (missGuards.length)
353
- _chunkALJSRZ4Zjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
353
+ _chunkC36XJ7D3js.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
354
354
  if (missInterceptors.length)
355
- _chunkALJSRZ4Zjs.log.call(void 0, `${_picocolors2.default.cyan(`Interceptor [${missInterceptors.join(",")}]`)} doesn't exist`, "warn");
355
+ _chunkC36XJ7D3js.log.call(void 0, `${_picocolors2.default.cyan(`Interceptor [${missInterceptors.join(",")}]`)} doesn't exist`, "warn");
356
356
  if (missPipes.length)
357
- _chunkALJSRZ4Zjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
357
+ _chunkC36XJ7D3js.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
358
358
  if (missFilters.length)
359
- _chunkALJSRZ4Zjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
359
+ _chunkC36XJ7D3js.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
360
360
  }
361
- _chunkALJSRZ4Zjs.__name.call(void 0, isAopDepInject, "isAopDepInject");
361
+ _chunkC36XJ7D3js.__name.call(void 0, isAopDepInject, "isAopDepInject");
362
362
 
363
363
 
364
364
 
@@ -118,6 +118,7 @@ declare function Factory(Modules: (new (...args: any) => any)[], opts?: {
118
118
  constructorMap: Map<any, any>;
119
119
  add: (Module: Construct) => Promise<void>;
120
120
  del: (tag: string) => Promise<any>;
121
+ destroy: () => Promise<void>;
121
122
  }>;
122
123
 
123
124
  export { APP_SYMBOL as A, Exception as E, Factory as F, Injectable as I, Meta as M, P, RequestType as R, ToControllerMap as T, UNMOUNT_SYMBOL as U, Emitter as a, PickKeysByValue as b, PickFunc as c, MERGE_SYMBOL as d, emitter as e, MODULE_SYMBOL as f, META_SYMBOL as g, IS_DEV as h, IS_STRICT as i, ERROR_SYMBOL as j, PS_FILE_RE as k, PS_IMPORT_RE as l };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { E as Exception, P, M as Meta, U as UNMOUNT_SYMBOL } from './core-fe0991cd.js';
2
- export { A as APP_SYMBOL, j as ERROR_SYMBOL, a as Emitter, F as Factory, h as IS_DEV, i as IS_STRICT, I as Injectable, d as MERGE_SYMBOL, g as META_SYMBOL, f as MODULE_SYMBOL, k as PS_FILE_RE, l as PS_IMPORT_RE, c as PickFunc, b as PickKeysByValue, R as RequestType, T as ToControllerMap, e as emitter } from './core-fe0991cd.js';
1
+ import { E as Exception, P, M as Meta, U as UNMOUNT_SYMBOL } from './core-39d78b79.js';
2
+ export { A as APP_SYMBOL, j as ERROR_SYMBOL, a as Emitter, F as Factory, h as IS_DEV, i as IS_STRICT, I as Injectable, d as MERGE_SYMBOL, g as META_SYMBOL, f as MODULE_SYMBOL, k as PS_FILE_RE, l as PS_IMPORT_RE, c as PickFunc, b as PickKeysByValue, R as RequestType, T as ToControllerMap, e as emitter } from './core-39d78b79.js';
3
+ import { Construct } from 'phecda-core';
3
4
  export * from 'phecda-core';
4
5
 
5
6
  declare class Histroy {
@@ -201,5 +202,6 @@ declare function generateHTTPCode(meta: P.MetaData[]): string;
201
202
  declare function log(msg: string, level?: 'error' | 'info' | 'warn'): void;
202
203
  declare function getConfig<C = any>(key: string, defaultConf?: C): C;
203
204
  declare function setConfig<C = any>(key: string, conf: C, force?: boolean): void;
205
+ declare function Mix<C1 extends Construct, C2 extends Construct>(InternalClass: C1, ExtendClass: C2): new (...args: ConstructorParameters<C2>) => InstanceType<C1> & InstanceType<C2>;
204
206
 
205
- export { Arg, BadGatewayException, BadRequestException, BaseParam, Body, ConflictException, Context, Controller, Define, Delete, Dev, Event, Exception, Filter, ForbiddenException, FrameworkException, Get, Guard, Head, Header, Interceptor, InvalidInputException, Meta, NotFoundException, P, PAddon, PExtension, PFilter, PGuard, PInterceptor, PPipe, Param, Patch, PayloadLargeException, Pipe, Plugin, Post, Put, Query, Route, Rpc, ServiceUnavailableException, TimeoutException, UNMOUNT_SYMBOL, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, addFilter, addGuard, addInterceptor, addPipe, addPlugin, defaultPipe, generateHTTPCode, generateRPCCode, getConfig, guardRecord, isAopDepInject, log, resolveDep, setConfig };
207
+ export { Arg, BadGatewayException, BadRequestException, BaseParam, Body, ConflictException, Context, Controller, Define, Delete, Dev, Event, Exception, Filter, ForbiddenException, FrameworkException, Get, Guard, Head, Header, Interceptor, InvalidInputException, Meta, Mix, NotFoundException, P, PAddon, PExtension, PFilter, PGuard, PInterceptor, PPipe, Param, Patch, PayloadLargeException, Pipe, Plugin, Post, Put, Query, Route, Rpc, ServiceUnavailableException, TimeoutException, UNMOUNT_SYMBOL, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, addFilter, addGuard, addInterceptor, addPipe, addPlugin, defaultPipe, generateHTTPCode, generateRPCCode, getConfig, guardRecord, isAopDepInject, log, resolveDep, setConfig };