phecda-server 7.0.0-alpha.10 → 7.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 (74) hide show
  1. package/bin/cli.mjs +3 -3
  2. package/dist/{chunk-G7JFKM2M.js → chunk-IJFIY6QN.js} +1 -9
  3. package/dist/{chunk-Z7NAAE4M.mjs → chunk-VX4BZEL7.mjs} +0 -8
  4. package/dist/{core-CUTbX_IS.d.ts → core-CDzIy2g0.d.ts} +1 -1
  5. package/dist/{core-DIfgUKIU.d.mts → core-jUg1HvYT.d.mts} +1 -1
  6. package/dist/helper.d.mts +2 -4
  7. package/dist/helper.d.ts +2 -4
  8. package/dist/helper.js +2 -4
  9. package/dist/helper.mjs +1 -3
  10. package/dist/http/elysia/index.d.mts +3 -3
  11. package/dist/http/elysia/index.d.ts +3 -3
  12. package/dist/http/elysia/index.js +18 -17
  13. package/dist/http/elysia/index.mjs +2 -1
  14. package/dist/http/express/index.d.mts +3 -3
  15. package/dist/http/express/index.d.ts +3 -3
  16. package/dist/http/express/index.js +17 -16
  17. package/dist/http/express/index.mjs +2 -1
  18. package/dist/http/fastify/index.d.mts +3 -3
  19. package/dist/http/fastify/index.d.ts +3 -3
  20. package/dist/http/fastify/index.js +17 -16
  21. package/dist/http/fastify/index.mjs +2 -1
  22. package/dist/http/h3/index.d.mts +3 -3
  23. package/dist/http/h3/index.d.ts +3 -3
  24. package/dist/http/h3/index.js +18 -17
  25. package/dist/http/h3/index.mjs +2 -1
  26. package/dist/http/hono/index.d.mts +3 -3
  27. package/dist/http/hono/index.d.ts +3 -3
  28. package/dist/http/hono/index.js +15 -14
  29. package/dist/http/hono/index.mjs +2 -1
  30. package/dist/http/hyper-express/index.d.mts +3 -3
  31. package/dist/http/hyper-express/index.d.ts +3 -3
  32. package/dist/http/hyper-express/index.js +16 -15
  33. package/dist/http/hyper-express/index.mjs +2 -1
  34. package/dist/http/koa/index.d.mts +3 -3
  35. package/dist/http/koa/index.d.ts +3 -3
  36. package/dist/http/koa/index.js +17 -16
  37. package/dist/http/koa/index.mjs +2 -1
  38. package/dist/index.d.mts +8 -8
  39. package/dist/index.d.ts +8 -8
  40. package/dist/index.js +19 -19
  41. package/dist/index.mjs +1 -1
  42. package/dist/{meta-CR-D39hQ.d.mts → meta-xvg6V7pH.d.mts} +2 -19
  43. package/dist/{meta-CR-D39hQ.d.ts → meta-xvg6V7pH.d.ts} +2 -19
  44. package/dist/rpc/bullmq/index.d.mts +4 -6
  45. package/dist/rpc/bullmq/index.d.ts +4 -6
  46. package/dist/rpc/bullmq/index.js +7 -75
  47. package/dist/rpc/bullmq/index.mjs +3 -71
  48. package/dist/rpc/kafka/index.d.mts +4 -9
  49. package/dist/rpc/kafka/index.d.ts +4 -9
  50. package/dist/rpc/kafka/index.js +7 -86
  51. package/dist/rpc/kafka/index.mjs +3 -82
  52. package/dist/rpc/nats/index.d.mts +4 -6
  53. package/dist/rpc/nats/index.d.ts +4 -6
  54. package/dist/rpc/nats/index.js +7 -67
  55. package/dist/rpc/nats/index.mjs +2 -62
  56. package/dist/rpc/rabbitmq/index.d.mts +4 -6
  57. package/dist/rpc/rabbitmq/index.d.ts +4 -6
  58. package/dist/rpc/rabbitmq/index.js +7 -73
  59. package/dist/rpc/rabbitmq/index.mjs +3 -69
  60. package/dist/rpc/redis/index.d.mts +4 -9
  61. package/dist/rpc/redis/index.d.ts +4 -9
  62. package/dist/rpc/redis/index.js +7 -74
  63. package/dist/rpc/redis/index.mjs +3 -70
  64. package/dist/test.d.mts +8 -4
  65. package/dist/test.d.ts +8 -4
  66. package/dist/types-6qaaUIKZ.d.mts +14 -0
  67. package/dist/{types-BF1TDbFV.d.ts → types-B-1OL-3P.d.ts} +1 -1
  68. package/dist/types-BtXOT5rI.d.ts +14 -0
  69. package/dist/{types-DYviSl5B.d.mts → types-Ctd6pLNE.d.mts} +1 -1
  70. package/package.json +2 -3
  71. package/register/loader.mjs +31 -22
  72. package/register/utils.mjs +26 -0
  73. package/dist/types-DYRu0vic.d.ts +0 -19
  74. package/dist/types-DqH1qA-q.d.mts +0 -19
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ var _chunkKCPBITYZjs = require('./chunk-KCPBITYZ.js');
57
57
 
58
58
 
59
59
 
60
- var _chunkG7JFKM2Mjs = require('./chunk-G7JFKM2M.js');
60
+ var _chunkIJFIY6QNjs = require('./chunk-IJFIY6QN.js');
61
61
 
62
62
 
63
63
 
@@ -136,9 +136,9 @@ var PFilter = class extends ServerBase {
136
136
  constructor(tag) {
137
137
  super();
138
138
  this.key = tag || _phecdacore.getTag.call(void 0, this);
139
- _chunkG7JFKM2Mjs.addFilter.call(void 0, this.key, this.use.bind(this));
139
+ _chunkIJFIY6QNjs.addFilter.call(void 0, this.key, this.use.bind(this));
140
140
  this.onUnmount(() => {
141
- delete _chunkG7JFKM2Mjs.Context.filterRecord[this.key];
141
+ delete _chunkIJFIY6QNjs.Context.filterRecord[this.key];
142
142
  });
143
143
  }
144
144
  };
@@ -154,9 +154,9 @@ var PGuard = (_class2 = class extends ServerBase {
154
154
  constructor(tag) {
155
155
  super();_class2.prototype.__init2.call(this);;
156
156
  this.key = tag || _phecdacore.getTag.call(void 0, this);
157
- _chunkG7JFKM2Mjs.addGuard.call(void 0, this.key, this.use.bind(this), this.priority);
157
+ _chunkIJFIY6QNjs.addGuard.call(void 0, this.key, this.use.bind(this), this.priority);
158
158
  this.onUnmount(() => {
159
- delete _chunkG7JFKM2Mjs.Context.guardRecord[this.key];
159
+ delete _chunkIJFIY6QNjs.Context.guardRecord[this.key];
160
160
  });
161
161
  }
162
162
  }, _class2);
@@ -171,9 +171,9 @@ var PPipe = class extends ServerBase {
171
171
  constructor(tag) {
172
172
  super();
173
173
  this.key = tag || _phecdacore.getTag.call(void 0, this);
174
- _chunkG7JFKM2Mjs.addPipe.call(void 0, this.key, this.use.bind(this));
174
+ _chunkIJFIY6QNjs.addPipe.call(void 0, this.key, this.use.bind(this));
175
175
  this.onUnmount(() => {
176
- delete _chunkG7JFKM2Mjs.Context.pipeRecord[this.key];
176
+ delete _chunkIJFIY6QNjs.Context.pipeRecord[this.key];
177
177
  });
178
178
  }
179
179
  };
@@ -189,9 +189,9 @@ var PAddon = (_class3 = class extends ServerBase {
189
189
  constructor(tag) {
190
190
  super();_class3.prototype.__init3.call(this);;
191
191
  this.key = tag || _phecdacore.getTag.call(void 0, this);
192
- _chunkG7JFKM2Mjs.addAddon.call(void 0, this.key, this.use.bind(this), this.priority);
192
+ _chunkIJFIY6QNjs.addAddon.call(void 0, this.key, this.use.bind(this), this.priority);
193
193
  this.onUnmount(() => {
194
- delete _chunkG7JFKM2Mjs.Context.addonRecord[this.key];
194
+ delete _chunkIJFIY6QNjs.Context.addonRecord[this.key];
195
195
  });
196
196
  }
197
197
  }, _class3);
@@ -209,27 +209,27 @@ var PExtension = class extends ServerBase {
209
209
  super();
210
210
  const key = this.key = tag || _phecdacore.getTag.call(void 0, this);
211
211
  if (this.pipe) {
212
- _chunkG7JFKM2Mjs.addPipe.call(void 0, key, this.pipe.bind(this));
212
+ _chunkIJFIY6QNjs.addPipe.call(void 0, key, this.pipe.bind(this));
213
213
  this.onUnmount(() => {
214
- delete _chunkG7JFKM2Mjs.Context.pipeRecord[key];
214
+ delete _chunkIJFIY6QNjs.Context.pipeRecord[key];
215
215
  });
216
216
  }
217
217
  if (this.addon) {
218
- _chunkG7JFKM2Mjs.addAddon.call(void 0, key, this.addon.bind(this), this.addonPriority);
218
+ _chunkIJFIY6QNjs.addAddon.call(void 0, key, this.addon.bind(this), this.addonPriority);
219
219
  this.onUnmount(() => {
220
- delete _chunkG7JFKM2Mjs.Context.addonRecord[key];
220
+ delete _chunkIJFIY6QNjs.Context.addonRecord[key];
221
221
  });
222
222
  }
223
223
  if (this.guard) {
224
- _chunkG7JFKM2Mjs.addGuard.call(void 0, key, this.guard.bind(this), this.guardPriority);
224
+ _chunkIJFIY6QNjs.addGuard.call(void 0, key, this.guard.bind(this), this.guardPriority);
225
225
  this.onUnmount(() => {
226
- delete _chunkG7JFKM2Mjs.Context.guardRecord[key];
226
+ delete _chunkIJFIY6QNjs.Context.guardRecord[key];
227
227
  });
228
228
  }
229
229
  if (this.filter) {
230
- _chunkG7JFKM2Mjs.addFilter.call(void 0, key, this.filter.bind(this));
230
+ _chunkIJFIY6QNjs.addFilter.call(void 0, key, this.filter.bind(this));
231
231
  this.onUnmount(() => {
232
- delete _chunkG7JFKM2Mjs.Context.filterRecord[key];
232
+ delete _chunkIJFIY6QNjs.Context.filterRecord[key];
233
233
  });
234
234
  }
235
235
  }
@@ -309,7 +309,7 @@ var HTTPGenerator = (_class5 = class extends Generator {constructor(...args4) {
309
309
  addMethod(args) {
310
310
  const { http, name, func, params, tag } = args;
311
311
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) return;
312
- const url = _chunkG7JFKM2Mjs.joinUrl.call(void 0, http.prefix, http.route).replace(/\/\:([^\/]*)/g, (_, js) => `/{{${js}}}`);
312
+ const url = _chunkIJFIY6QNjs.joinUrl.call(void 0, http.prefix, http.route).replace(/\/\:([^\/]*)/g, (_, js) => `/{{${js}}}`);
313
313
  if (!this.classMap[name]) this.classMap[name] = {};
314
314
  this.classMap[name][func] = `
315
315
  ${func}(...args){
@@ -410,4 +410,4 @@ return ret
410
410
 
411
411
 
412
412
 
413
- exports.Addon = _chunkKCPBITYZjs.Addon; exports.Arg = _chunkKCPBITYZjs.Arg; exports.BadGatewayException = _chunkG7JFKM2Mjs.BadGatewayException; exports.BadRequestException = _chunkG7JFKM2Mjs.BadRequestException; exports.BaseParam = _chunkKCPBITYZjs.BaseParam; exports.Body = _chunkKCPBITYZjs.Body; exports.ConflictException = _chunkG7JFKM2Mjs.ConflictException; exports.Context = _chunkG7JFKM2Mjs.Context; exports.Controller = _chunkKCPBITYZjs.Controller; exports.Ctx = _chunkKCPBITYZjs.Ctx; exports.CustomResponse = CustomResponse; exports.Define = _chunkKCPBITYZjs.Define; exports.Delete = _chunkKCPBITYZjs.Delete; exports.ERROR_SYMBOL = _chunk4LLLQOMFjs.ERROR_SYMBOL; exports.Exception = _chunkG7JFKM2Mjs.Exception; exports.Factory = _chunk6OQ2SB5Wjs.Factory; exports.Filter = _chunkKCPBITYZjs.Filter; exports.ForbiddenException = _chunkG7JFKM2Mjs.ForbiddenException; exports.FrameworkException = _chunkG7JFKM2Mjs.FrameworkException; exports.Generator = Generator; exports.Get = _chunkKCPBITYZjs.Get; exports.Guard = _chunkKCPBITYZjs.Guard; exports.HTTPGenerator = HTTPGenerator; exports.Head = _chunkKCPBITYZjs.Head; exports.Header = _chunkKCPBITYZjs.Header; exports.HttpBase = HttpBase; exports.IS_DEV = _chunk4LLLQOMFjs.IS_DEV; exports.IS_ONLY_GENERATE = _chunk4LLLQOMFjs.IS_ONLY_GENERATE; exports.IS_PURE = _chunk4LLLQOMFjs.IS_PURE; exports.IS_STRICT = _chunk4LLLQOMFjs.IS_STRICT; exports.InvalidInputException = _chunkG7JFKM2Mjs.InvalidInputException; exports.LOG_LEVEL = _chunk4LLLQOMFjs.LOG_LEVEL; exports.Meta = _chunk6OQ2SB5Wjs.Meta; exports.Mixin = _chunk4LLLQOMFjs.Mixin; exports.NotFoundException = _chunkG7JFKM2Mjs.NotFoundException; exports.PAddon = PAddon; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PPipe = PPipe; exports.PS_EXIT_CODE = _chunk4LLLQOMFjs.PS_EXIT_CODE; exports.Param = _chunkKCPBITYZjs.Param; exports.Patch = _chunkKCPBITYZjs.Patch; exports.PayloadLargeException = _chunkG7JFKM2Mjs.PayloadLargeException; exports.Pipe = _chunkKCPBITYZjs.Pipe; exports.Post = _chunkKCPBITYZjs.Post; exports.Put = _chunkKCPBITYZjs.Put; exports.Query = _chunkKCPBITYZjs.Query; exports.Queue = _chunkKCPBITYZjs.Queue; exports.RPCGenerator = RPCGenerator; exports.Route = _chunkKCPBITYZjs.Route; exports.Rpc = _chunkKCPBITYZjs.Rpc; exports.RpcBase = RpcBase; exports.Search = _chunkKCPBITYZjs.Search; exports.ServerBase = ServerBase; exports.ServerPhecda = _chunk6OQ2SB5Wjs.ServerPhecda; exports.ServiceUnavailableException = _chunkG7JFKM2Mjs.ServiceUnavailableException; exports.TimeoutException = _chunkG7JFKM2Mjs.TimeoutException; exports.TimerException = _chunkG7JFKM2Mjs.TimerException; exports.UnauthorizedException = _chunkG7JFKM2Mjs.UnauthorizedException; exports.UndefinedException = _chunkG7JFKM2Mjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkG7JFKM2Mjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkG7JFKM2Mjs.ValidateException; exports.WorkerException = _chunkG7JFKM2Mjs.WorkerException; exports.addAddon = _chunkG7JFKM2Mjs.addAddon; exports.addFilter = _chunkG7JFKM2Mjs.addFilter; exports.addGuard = _chunkG7JFKM2Mjs.addGuard; exports.addPipe = _chunkG7JFKM2Mjs.addPipe; exports.defaultPipe = _chunkG7JFKM2Mjs.defaultPipe; exports.defaultServerInject = _chunk6OQ2SB5Wjs.defaultServerInject; exports.emitter = _chunk6OQ2SB5Wjs.emitter; exports.getLogger = _chunk4LLLQOMFjs.getLogger; exports.log = _chunk4LLLQOMFjs.log; exports.phecdaNamespace = _chunk6OQ2SB5Wjs.phecdaNamespace; exports.runMiddleware = _chunk4LLLQOMFjs.runMiddleware; exports.setLogger = _chunk4LLLQOMFjs.setLogger; exports.useS = _chunk6OQ2SB5Wjs.useS;
413
+ exports.Addon = _chunkKCPBITYZjs.Addon; exports.Arg = _chunkKCPBITYZjs.Arg; exports.BadGatewayException = _chunkIJFIY6QNjs.BadGatewayException; exports.BadRequestException = _chunkIJFIY6QNjs.BadRequestException; exports.BaseParam = _chunkKCPBITYZjs.BaseParam; exports.Body = _chunkKCPBITYZjs.Body; exports.ConflictException = _chunkIJFIY6QNjs.ConflictException; exports.Context = _chunkIJFIY6QNjs.Context; exports.Controller = _chunkKCPBITYZjs.Controller; exports.Ctx = _chunkKCPBITYZjs.Ctx; exports.CustomResponse = CustomResponse; exports.Define = _chunkKCPBITYZjs.Define; exports.Delete = _chunkKCPBITYZjs.Delete; exports.ERROR_SYMBOL = _chunk4LLLQOMFjs.ERROR_SYMBOL; exports.Exception = _chunkIJFIY6QNjs.Exception; exports.Factory = _chunk6OQ2SB5Wjs.Factory; exports.Filter = _chunkKCPBITYZjs.Filter; exports.ForbiddenException = _chunkIJFIY6QNjs.ForbiddenException; exports.FrameworkException = _chunkIJFIY6QNjs.FrameworkException; exports.Generator = Generator; exports.Get = _chunkKCPBITYZjs.Get; exports.Guard = _chunkKCPBITYZjs.Guard; exports.HTTPGenerator = HTTPGenerator; exports.Head = _chunkKCPBITYZjs.Head; exports.Header = _chunkKCPBITYZjs.Header; exports.HttpBase = HttpBase; exports.IS_DEV = _chunk4LLLQOMFjs.IS_DEV; exports.IS_ONLY_GENERATE = _chunk4LLLQOMFjs.IS_ONLY_GENERATE; exports.IS_PURE = _chunk4LLLQOMFjs.IS_PURE; exports.IS_STRICT = _chunk4LLLQOMFjs.IS_STRICT; exports.InvalidInputException = _chunkIJFIY6QNjs.InvalidInputException; exports.LOG_LEVEL = _chunk4LLLQOMFjs.LOG_LEVEL; exports.Meta = _chunk6OQ2SB5Wjs.Meta; exports.Mixin = _chunk4LLLQOMFjs.Mixin; exports.NotFoundException = _chunkIJFIY6QNjs.NotFoundException; exports.PAddon = PAddon; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PPipe = PPipe; exports.PS_EXIT_CODE = _chunk4LLLQOMFjs.PS_EXIT_CODE; exports.Param = _chunkKCPBITYZjs.Param; exports.Patch = _chunkKCPBITYZjs.Patch; exports.PayloadLargeException = _chunkIJFIY6QNjs.PayloadLargeException; exports.Pipe = _chunkKCPBITYZjs.Pipe; exports.Post = _chunkKCPBITYZjs.Post; exports.Put = _chunkKCPBITYZjs.Put; exports.Query = _chunkKCPBITYZjs.Query; exports.Queue = _chunkKCPBITYZjs.Queue; exports.RPCGenerator = RPCGenerator; exports.Route = _chunkKCPBITYZjs.Route; exports.Rpc = _chunkKCPBITYZjs.Rpc; exports.RpcBase = RpcBase; exports.Search = _chunkKCPBITYZjs.Search; exports.ServerBase = ServerBase; exports.ServerPhecda = _chunk6OQ2SB5Wjs.ServerPhecda; exports.ServiceUnavailableException = _chunkIJFIY6QNjs.ServiceUnavailableException; exports.TimeoutException = _chunkIJFIY6QNjs.TimeoutException; exports.TimerException = _chunkIJFIY6QNjs.TimerException; exports.UnauthorizedException = _chunkIJFIY6QNjs.UnauthorizedException; exports.UndefinedException = _chunkIJFIY6QNjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkIJFIY6QNjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkIJFIY6QNjs.ValidateException; exports.WorkerException = _chunkIJFIY6QNjs.WorkerException; exports.addAddon = _chunkIJFIY6QNjs.addAddon; exports.addFilter = _chunkIJFIY6QNjs.addFilter; exports.addGuard = _chunkIJFIY6QNjs.addGuard; exports.addPipe = _chunkIJFIY6QNjs.addPipe; exports.defaultPipe = _chunkIJFIY6QNjs.defaultPipe; exports.defaultServerInject = _chunk6OQ2SB5Wjs.defaultServerInject; exports.emitter = _chunk6OQ2SB5Wjs.emitter; exports.getLogger = _chunk4LLLQOMFjs.getLogger; exports.log = _chunk4LLLQOMFjs.log; exports.phecdaNamespace = _chunk6OQ2SB5Wjs.phecdaNamespace; exports.runMiddleware = _chunk4LLLQOMFjs.runMiddleware; exports.setLogger = _chunk4LLLQOMFjs.setLogger; exports.useS = _chunk6OQ2SB5Wjs.useS;
package/dist/index.mjs CHANGED
@@ -57,7 +57,7 @@ import {
57
57
  addPipe,
58
58
  defaultPipe,
59
59
  joinUrl
60
- } from "./chunk-Z7NAAE4M.mjs";
60
+ } from "./chunk-VX4BZEL7.mjs";
61
61
  import {
62
62
  ERROR_SYMBOL,
63
63
  IS_DEV,
@@ -1,4 +1,4 @@
1
- import { Events, Construct } from 'phecda-core';
1
+ import { Events } from 'phecda-core';
2
2
 
3
3
  declare const ERROR_SYMBOL = "__PS_ERROR__";
4
4
  declare const IS_DEV: boolean;
@@ -18,20 +18,6 @@ interface Emitter {
18
18
  removeAllListeners<N extends keyof Events>(eventName: N): void;
19
19
  emit<N extends keyof Events>(eventName: N, param: Events[N]): void;
20
20
  }
21
- type AnyFunction = (...args: any) => any;
22
- type ParseInstance<Instance extends Record<string, AnyFunction>> = {
23
- [Key in keyof Instance]: ToClientFn<Instance[Key]>;
24
- };
25
- type PickFuncKeys<Type> = {
26
- [Key in keyof Type]: Type[Key] extends (...args: any) => any ? (ReturnType<Type[Key]> extends CustomResponse<any> ? never : Key) : never;
27
- }[keyof Type];
28
- type ToClientMap<ControllerMap extends Record<string, Construct>> = {
29
- [Key in keyof ControllerMap]: ToClientInstance<InstanceType<ControllerMap[Key]>>;
30
- };
31
- type ToClientInstance<Instance extends Record<string, any>> = ParseInstance<PickFunc<Instance>>;
32
- type ToClientFn<Func extends AnyFunction> = (...p: Parameters<Func>) => Promise<BaseReturn<ReturnType<Func>>>;
33
- type PickFunc<Instance> = Pick<Instance, PickFuncKeys<Instance>>;
34
- type OmitFunction<Instance> = Omit<Instance, PickFuncKeys<Instance>>;
35
21
  interface BaseCtx {
36
22
  meta: ControllerMeta;
37
23
  moduleMap: Record<string, any>;
@@ -53,9 +39,6 @@ interface BaseError {
53
39
  message: string;
54
40
  description: string;
55
41
  }
56
- type BaseReturn<T> = Awaited<T> extends {
57
- toJSON(): infer R;
58
- } ? R : Awaited<T>;
59
42
  type BaseRequestType = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
60
43
  declare const ResponseSymbol: unique symbol;
61
44
  declare class CustomResponse<Value> {
@@ -105,4 +88,4 @@ interface ControllerMeta extends Meta {
105
88
  data: ControllerMetaData;
106
89
  }
107
90
 
108
- export { type BaseCtx as B, type ControllerMeta as C, type DefaultOptions as D, type Emitter as E, IS_DEV as I, LOG_LEVEL as L, Meta as M, type OmitFunction as O, type PickFunc as P, type ServiceMetaData as S, type ToClientMap as T, type ControllerMetaData as a, type MetaData as b, type BaseError as c, type ToClientInstance as d, type ToClientFn as e, type BaseReturn as f, type BaseRequestType as g, CustomResponse as h, type ExtractResponse as i, ERROR_SYMBOL as j, IS_ONLY_GENERATE as k, IS_STRICT as l, IS_PURE as m, PS_EXIT_CODE as n };
91
+ export { type BaseCtx as B, type ControllerMeta as C, type DefaultOptions as D, type Emitter as E, IS_DEV as I, LOG_LEVEL as L, Meta as M, PS_EXIT_CODE as P, type ServiceMetaData as S, type ControllerMetaData as a, type MetaData as b, type BaseError as c, type BaseRequestType as d, CustomResponse as e, type ExtractResponse as f, ERROR_SYMBOL as g, IS_ONLY_GENERATE as h, IS_STRICT as i, IS_PURE as j };
@@ -1,4 +1,4 @@
1
- import { Events, Construct } from 'phecda-core';
1
+ import { Events } from 'phecda-core';
2
2
 
3
3
  declare const ERROR_SYMBOL = "__PS_ERROR__";
4
4
  declare const IS_DEV: boolean;
@@ -18,20 +18,6 @@ interface Emitter {
18
18
  removeAllListeners<N extends keyof Events>(eventName: N): void;
19
19
  emit<N extends keyof Events>(eventName: N, param: Events[N]): void;
20
20
  }
21
- type AnyFunction = (...args: any) => any;
22
- type ParseInstance<Instance extends Record<string, AnyFunction>> = {
23
- [Key in keyof Instance]: ToClientFn<Instance[Key]>;
24
- };
25
- type PickFuncKeys<Type> = {
26
- [Key in keyof Type]: Type[Key] extends (...args: any) => any ? (ReturnType<Type[Key]> extends CustomResponse<any> ? never : Key) : never;
27
- }[keyof Type];
28
- type ToClientMap<ControllerMap extends Record<string, Construct>> = {
29
- [Key in keyof ControllerMap]: ToClientInstance<InstanceType<ControllerMap[Key]>>;
30
- };
31
- type ToClientInstance<Instance extends Record<string, any>> = ParseInstance<PickFunc<Instance>>;
32
- type ToClientFn<Func extends AnyFunction> = (...p: Parameters<Func>) => Promise<BaseReturn<ReturnType<Func>>>;
33
- type PickFunc<Instance> = Pick<Instance, PickFuncKeys<Instance>>;
34
- type OmitFunction<Instance> = Omit<Instance, PickFuncKeys<Instance>>;
35
21
  interface BaseCtx {
36
22
  meta: ControllerMeta;
37
23
  moduleMap: Record<string, any>;
@@ -53,9 +39,6 @@ interface BaseError {
53
39
  message: string;
54
40
  description: string;
55
41
  }
56
- type BaseReturn<T> = Awaited<T> extends {
57
- toJSON(): infer R;
58
- } ? R : Awaited<T>;
59
42
  type BaseRequestType = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
60
43
  declare const ResponseSymbol: unique symbol;
61
44
  declare class CustomResponse<Value> {
@@ -105,4 +88,4 @@ interface ControllerMeta extends Meta {
105
88
  data: ControllerMetaData;
106
89
  }
107
90
 
108
- export { type BaseCtx as B, type ControllerMeta as C, type DefaultOptions as D, type Emitter as E, IS_DEV as I, LOG_LEVEL as L, Meta as M, type OmitFunction as O, type PickFunc as P, type ServiceMetaData as S, type ToClientMap as T, type ControllerMetaData as a, type MetaData as b, type BaseError as c, type ToClientInstance as d, type ToClientFn as e, type BaseReturn as f, type BaseRequestType as g, CustomResponse as h, type ExtractResponse as i, ERROR_SYMBOL as j, IS_ONLY_GENERATE as k, IS_STRICT as l, IS_PURE as m, PS_EXIT_CODE as n };
91
+ export { type BaseCtx as B, type ControllerMeta as C, type DefaultOptions as D, type Emitter as E, IS_DEV as I, LOG_LEVEL as L, Meta as M, PS_EXIT_CODE as P, type ServiceMetaData as S, type ControllerMetaData as a, type MetaData as b, type BaseError as c, type BaseRequestType as d, CustomResponse as e, type ExtractResponse as f, ERROR_SYMBOL as g, IS_ONLY_GENERATE as h, IS_STRICT as i, IS_PURE as j };
@@ -1,8 +1,8 @@
1
1
  import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
2
- import { F as Factory } from '../../core-DIfgUKIU.mjs';
3
- import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DqH1qA-q.mjs';
4
- import { T as ToClientMap } from '../../meta-CR-D39hQ.mjs';
2
+ import { F as Factory } from '../../core-jUg1HvYT.mjs';
3
+ import { R as RpcCtx, a as RpcServerOptions } from '../../types-6qaaUIKZ.mjs';
5
4
  import 'phecda-core';
5
+ import '../../meta-xvg6V7pH.mjs';
6
6
 
7
7
  interface BullmqCtx extends RpcCtx {
8
8
  type: 'bullmq';
@@ -16,6 +16,4 @@ declare function create({ moduleMap, meta }: Awaited<ReturnType<typeof Factory>>
16
16
  queueMap: Record<string, Queue<any, any, string, any, any, string>>;
17
17
  }>;
18
18
 
19
- declare function createClient<S extends Record<string, any>>(controllers: S, opts?: RpcClientOptions & BullmqOptions): Promise<ToClientMap<S>>;
20
-
21
- export { type BullmqCtx, type BullmqOptions, create, createClient };
19
+ export { type BullmqCtx, type BullmqOptions, create };
@@ -1,8 +1,8 @@
1
1
  import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
2
- import { F as Factory } from '../../core-CUTbX_IS.js';
3
- import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DYRu0vic.js';
4
- import { T as ToClientMap } from '../../meta-CR-D39hQ.js';
2
+ import { F as Factory } from '../../core-CDzIy2g0.js';
3
+ import { R as RpcCtx, a as RpcServerOptions } from '../../types-BtXOT5rI.js';
5
4
  import 'phecda-core';
5
+ import '../../meta-xvg6V7pH.js';
6
6
 
7
7
  interface BullmqCtx extends RpcCtx {
8
8
  type: 'bullmq';
@@ -16,6 +16,4 @@ declare function create({ moduleMap, meta }: Awaited<ReturnType<typeof Factory>>
16
16
  queueMap: Record<string, Queue<any, any, string, any, any, string>>;
17
17
  }>;
18
18
 
19
- declare function createClient<S extends Record<string, any>>(controllers: S, opts?: RpcClientOptions & BullmqOptions): Promise<ToClientMap<S>>;
20
-
21
- export { type BullmqCtx, type BullmqOptions, create, createClient };
19
+ export { type BullmqCtx, type BullmqOptions, create };
@@ -2,8 +2,7 @@
2
2
 
3
3
 
4
4
 
5
-
6
- var _chunkG7JFKM2Mjs = require('../../chunk-G7JFKM2M.js');
5
+ var _chunkIJFIY6QNjs = require('../../chunk-IJFIY6QN.js');
7
6
 
8
7
 
9
8
 
@@ -18,14 +17,14 @@ async function create({ moduleMap, meta }, opts = {}) {
18
17
  const workerMap = {};
19
18
  const queueMap = {};
20
19
  const existQueue = /* @__PURE__ */ new Set();
21
- const metaMap = _chunkG7JFKM2Mjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
20
+ const metaMap = _chunkIJFIY6QNjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
21
  const { controller, rpc, func, tag } = meta2.data;
23
22
  if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
24
23
  debug(`register method "${func}" in module "${tag}"`);
25
24
  return true;
26
25
  }
27
26
  });
28
- _chunkG7JFKM2Mjs.detectAopDep.call(void 0, meta, {
27
+ _chunkIJFIY6QNjs.detectAopDep.call(void 0, meta, {
29
28
  guards: globalGuards
30
29
  }, "rpc");
31
30
  async function subscribeQueues() {
@@ -39,7 +38,7 @@ async function create({ moduleMap, meta }, opts = {}) {
39
38
  if (existQueue.has(queue)) continue;
40
39
  existQueue.add(queue);
41
40
  workerMap[queue] = new (0, _bullmq.Worker)(queue, handleRequest, workerOpts);
42
- _chunkG7JFKM2Mjs.Context.applyAddons(addons, workerMap[queue], "bullmq");
41
+ _chunkIJFIY6QNjs.Context.applyAddons(addons, workerMap[queue], "bullmq");
43
42
  }
44
43
  }
45
44
  }
@@ -53,12 +52,12 @@ async function create({ moduleMap, meta }, opts = {}) {
53
52
  const meta2 = metaMap.get(tag)[func];
54
53
  const { data: { rpc: { isEvent } = {} } } = meta2;
55
54
  if (!isEvent && !(clientQueue in queueMap)) queueMap[clientQueue] = new (0, _bullmq.Queue)(clientQueue, queueOpts);
56
- const aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
55
+ const aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
57
56
  globalFilter,
58
57
  globalGuards,
59
58
  globalPipe
60
59
  });
61
- const context = new (0, _chunkG7JFKM2Mjs.Context)({
60
+ const context = new (0, _chunkIJFIY6QNjs.Context)({
62
61
  type: "bullmq",
63
62
  category: "rpc",
64
63
  moduleMap,
@@ -100,72 +99,5 @@ async function create({ moduleMap, meta }, opts = {}) {
100
99
  }
101
100
  _chunk4LLLQOMFjs.__name.call(void 0, create, "create");
102
101
 
103
- // src/rpc/bullmq/client.ts
104
- var _events = require('events');
105
-
106
- async function createClient(controllers, opts = {}) {
107
- let eventId = 1;
108
- let eventCount = 0;
109
- const { max, workerOpts, queueOpts, timeout, key } = opts;
110
- const ret = {};
111
- const emitter = new (0, _events.EventEmitter)();
112
- const clientQueue = _chunkG7JFKM2Mjs.genClientQueue.call(void 0, key);
113
- const queueMap = {};
114
- new (0, _bullmq.Worker)(clientQueue, async (job) => {
115
- const { data, id, error } = job.data;
116
- emitter.emit(id, data, error);
117
- }, workerOpts);
118
- for (const i in controllers) {
119
- ret[i] = new Proxy(new controllers[i](), {
120
- get(target, p) {
121
- if (typeof target[p] !== "function") throw new Error(`"${p}" in "${i}" is not an exposed rpc `);
122
- let { tag, queue, isEvent } = target[p]();
123
- return async (...args) => {
124
- if (!queue) queue = tag;
125
- if (!(queue in queueMap)) queueMap[queue] = new (0, _bullmq.Queue)(queue, queueOpts);
126
- const id = `${eventId++}`;
127
- queueMap[queue].add(`${tag}-${p}`, {
128
- _ps: 1,
129
- id,
130
- args,
131
- tag,
132
- queue: clientQueue,
133
- func: p
134
- });
135
- if (isEvent) return null;
136
- return new Promise((resolve, reject) => {
137
- if (max && eventCount >= max) reject({
138
- type: "exceeded"
139
- });
140
- let isEnd = false;
141
- const timer = setTimeout(() => {
142
- if (!isEnd) {
143
- eventCount--;
144
- emitter.off(id, listener);
145
- reject({
146
- type: "timeout"
147
- });
148
- }
149
- }, timeout || 5e3);
150
- function listener(data, error) {
151
- eventCount--;
152
- isEnd = true;
153
- clearTimeout(timer);
154
- if (error) reject(data);
155
- else resolve(data);
156
- }
157
- _chunk4LLLQOMFjs.__name.call(void 0, listener, "listener");
158
- eventCount++;
159
- emitter.once(id, listener);
160
- });
161
- };
162
- }
163
- });
164
- }
165
- return ret;
166
- }
167
- _chunk4LLLQOMFjs.__name.call(void 0, createClient, "createClient");
168
-
169
-
170
102
 
171
- exports.create = create; exports.createClient = createClient;
103
+ exports.create = create;
@@ -1,9 +1,8 @@
1
1
  import {
2
2
  Context,
3
3
  createControllerMetaMap,
4
- detectAopDep,
5
- genClientQueue
6
- } from "../../chunk-Z7NAAE4M.mjs";
4
+ detectAopDep
5
+ } from "../../chunk-VX4BZEL7.mjs";
7
6
  import {
8
7
  HMR,
9
8
  __name
@@ -99,73 +98,6 @@ async function create({ moduleMap, meta }, opts = {}) {
99
98
  };
100
99
  }
101
100
  __name(create, "create");
102
-
103
- // src/rpc/bullmq/client.ts
104
- import { EventEmitter } from "events";
105
- import { Queue as Queue2, Worker as Worker2 } from "bullmq";
106
- async function createClient(controllers, opts = {}) {
107
- let eventId = 1;
108
- let eventCount = 0;
109
- const { max, workerOpts, queueOpts, timeout, key } = opts;
110
- const ret = {};
111
- const emitter = new EventEmitter();
112
- const clientQueue = genClientQueue(key);
113
- const queueMap = {};
114
- new Worker2(clientQueue, async (job) => {
115
- const { data, id, error } = job.data;
116
- emitter.emit(id, data, error);
117
- }, workerOpts);
118
- for (const i in controllers) {
119
- ret[i] = new Proxy(new controllers[i](), {
120
- get(target, p) {
121
- if (typeof target[p] !== "function") throw new Error(`"${p}" in "${i}" is not an exposed rpc `);
122
- let { tag, queue, isEvent } = target[p]();
123
- return async (...args) => {
124
- if (!queue) queue = tag;
125
- if (!(queue in queueMap)) queueMap[queue] = new Queue2(queue, queueOpts);
126
- const id = `${eventId++}`;
127
- queueMap[queue].add(`${tag}-${p}`, {
128
- _ps: 1,
129
- id,
130
- args,
131
- tag,
132
- queue: clientQueue,
133
- func: p
134
- });
135
- if (isEvent) return null;
136
- return new Promise((resolve, reject) => {
137
- if (max && eventCount >= max) reject({
138
- type: "exceeded"
139
- });
140
- let isEnd = false;
141
- const timer = setTimeout(() => {
142
- if (!isEnd) {
143
- eventCount--;
144
- emitter.off(id, listener);
145
- reject({
146
- type: "timeout"
147
- });
148
- }
149
- }, timeout || 5e3);
150
- function listener(data, error) {
151
- eventCount--;
152
- isEnd = true;
153
- clearTimeout(timer);
154
- if (error) reject(data);
155
- else resolve(data);
156
- }
157
- __name(listener, "listener");
158
- eventCount++;
159
- emitter.once(id, listener);
160
- });
161
- };
162
- }
163
- });
164
- }
165
- return ret;
166
- }
167
- __name(createClient, "createClient");
168
101
  export {
169
- create,
170
- createClient
102
+ create
171
103
  };
@@ -1,8 +1,8 @@
1
1
  import { Consumer, Producer } from 'kafkajs';
2
- import { F as Factory } from '../../core-DIfgUKIU.mjs';
3
- import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DqH1qA-q.mjs';
4
- import { T as ToClientMap } from '../../meta-CR-D39hQ.mjs';
2
+ import { F as Factory } from '../../core-jUg1HvYT.mjs';
3
+ import { R as RpcCtx, a as RpcServerOptions } from '../../types-6qaaUIKZ.mjs';
5
4
  import 'phecda-core';
5
+ import '../../meta-xvg6V7pH.mjs';
6
6
 
7
7
  interface KafkaCtx extends RpcCtx {
8
8
  type: 'kafka';
@@ -16,9 +16,4 @@ declare function bind({ consumer, producer }: {
16
16
  producer: Producer;
17
17
  }, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: RpcServerOptions): Promise<void>;
18
18
 
19
- declare function createClient<S extends Record<string, any>>({ producer, consumer }: {
20
- producer: Producer;
21
- consumer: Consumer;
22
- }, controllers: S, opts?: RpcClientOptions): Promise<ToClientMap<S>>;
23
-
24
- export { type KafkaCtx, bind, createClient };
19
+ export { type KafkaCtx, bind };
@@ -1,8 +1,8 @@
1
1
  import { Consumer, Producer } from 'kafkajs';
2
- import { F as Factory } from '../../core-CUTbX_IS.js';
3
- import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DYRu0vic.js';
4
- import { T as ToClientMap } from '../../meta-CR-D39hQ.js';
2
+ import { F as Factory } from '../../core-CDzIy2g0.js';
3
+ import { R as RpcCtx, a as RpcServerOptions } from '../../types-BtXOT5rI.js';
5
4
  import 'phecda-core';
5
+ import '../../meta-xvg6V7pH.js';
6
6
 
7
7
  interface KafkaCtx extends RpcCtx {
8
8
  type: 'kafka';
@@ -16,9 +16,4 @@ declare function bind({ consumer, producer }: {
16
16
  producer: Producer;
17
17
  }, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: RpcServerOptions): Promise<void>;
18
18
 
19
- declare function createClient<S extends Record<string, any>>({ producer, consumer }: {
20
- producer: Producer;
21
- consumer: Consumer;
22
- }, controllers: S, opts?: RpcClientOptions): Promise<ToClientMap<S>>;
23
-
24
- export { type KafkaCtx, bind, createClient };
19
+ export { type KafkaCtx, bind };
@@ -2,8 +2,7 @@
2
2
 
3
3
 
4
4
 
5
-
6
- var _chunkG7JFKM2Mjs = require('../../chunk-G7JFKM2M.js');
5
+ var _chunkIJFIY6QNjs = require('../../chunk-IJFIY6QN.js');
7
6
 
8
7
 
9
8
  var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
@@ -14,18 +13,18 @@ var debug = _debug2.default.call(void 0, "phecda-server/kafka");
14
13
  async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
15
14
  const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
16
15
  const existQueue = /* @__PURE__ */ new Set();
17
- const metaMap = _chunkG7JFKM2Mjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
16
+ const metaMap = _chunkIJFIY6QNjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
18
17
  const { controller, rpc, func, tag } = meta2.data;
19
18
  if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
20
19
  debug(`register method "${func}" in module "${tag}"`);
21
20
  return true;
22
21
  }
23
22
  });
24
- _chunkG7JFKM2Mjs.detectAopDep.call(void 0, meta, {
23
+ _chunkIJFIY6QNjs.detectAopDep.call(void 0, meta, {
25
24
  guards: globalGuards,
26
25
  addons: globalAddons
27
26
  }, "rpc");
28
- _chunkG7JFKM2Mjs.Context.applyAddons(globalAddons, {
27
+ _chunkIJFIY6QNjs.Context.applyAddons(globalAddons, {
29
28
  consumer,
30
29
  producer
31
30
  }, "kafka");
@@ -59,12 +58,12 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
59
58
  const meta2 = metaMap.get(tag)[func];
60
59
  const { data: { rpc } } = meta2;
61
60
  const isEvent = rpc.isEvent;
62
- const aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
61
+ const aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
63
62
  globalFilter,
64
63
  globalGuards,
65
64
  globalPipe
66
65
  });
67
- const context = new (0, _chunkG7JFKM2Mjs.Context)({
66
+ const context = new (0, _chunkIJFIY6QNjs.Context)({
68
67
  type: "kafka",
69
68
  category: "rpc",
70
69
  moduleMap,
@@ -115,83 +114,5 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
115
114
  }
116
115
  _chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
117
116
 
118
- // src/rpc/kafka/client.ts
119
- var _events = require('events');
120
- async function createClient({ producer, consumer }, controllers, opts) {
121
- let eventId = 1;
122
- let eventCount = 1;
123
- const ret = {};
124
- const emitter = new (0, _events.EventEmitter)();
125
- const clientQueue = _chunkG7JFKM2Mjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
126
- await consumer.subscribe({
127
- topic: clientQueue,
128
- fromBeginning: true
129
- });
130
- for (const i in controllers) {
131
- ret[i] = new Proxy(new controllers[i](), {
132
- get(target, p) {
133
- if (typeof target[p] !== "function") throw new Error(`"${p}" in "${i}" is not an exposed rpc `);
134
- let { tag, queue, isEvent } = target[p]();
135
- return async (...args) => {
136
- if (!queue) queue = tag;
137
- const id = `${eventId++}`;
138
- producer.send({
139
- topic: queue,
140
- messages: [
141
- {
142
- value: JSON.stringify({
143
- _ps: 1,
144
- id,
145
- tag,
146
- queue: clientQueue,
147
- func: p,
148
- args
149
- })
150
- }
151
- ]
152
- });
153
- if (isEvent) return null;
154
- return new Promise((resolve, reject) => {
155
- if (_optionalChain([opts, 'optionalAccess', _3 => _3.max]) && eventCount >= opts.max) reject({
156
- type: "exceeded"
157
- });
158
- let isEnd = false;
159
- const timer = setTimeout(() => {
160
- if (!isEnd) {
161
- eventCount--;
162
- emitter.off(id, listener);
163
- reject({
164
- type: "timeout"
165
- });
166
- }
167
- }, _optionalChain([opts, 'optionalAccess', _4 => _4.timeout]) || 5e3);
168
- function listener(data, error) {
169
- eventCount--;
170
- isEnd = true;
171
- clearTimeout(timer);
172
- if (error) reject(data);
173
- else resolve(data);
174
- }
175
- _chunk4LLLQOMFjs.__name.call(void 0, listener, "listener");
176
- eventCount++;
177
- emitter.once(id, listener);
178
- });
179
- };
180
- }
181
- });
182
- }
183
- await consumer.run({
184
- eachMessage: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, async ({ message, topic }) => {
185
- if (clientQueue === topic && message.value) {
186
- const { data, id, error } = JSON.parse(message.value.toString());
187
- emitter.emit(id, data, error);
188
- }
189
- }, "eachMessage")
190
- });
191
- return ret;
192
- }
193
- _chunk4LLLQOMFjs.__name.call(void 0, createClient, "createClient");
194
-
195
-
196
117
 
197
- exports.bind = bind; exports.createClient = createClient;
118
+ exports.bind = bind;