phecda-server 7.0.0-alpha.6 → 7.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/bin/cli.mjs +10 -1
  2. package/dist/{chunk-JF4YU32E.js → chunk-7EMAZGYO.js} +86 -56
  3. package/dist/{chunk-ICI5KUDX.mjs → chunk-7NWDKK7D.mjs} +1 -1
  4. package/dist/{chunk-HTY3H33L.mjs → chunk-B45BN7LY.mjs} +4 -4
  5. package/dist/{chunk-UKRQVTEY.js → chunk-BBNJVYVX.js} +24 -24
  6. package/dist/{chunk-WYI2F7LD.js → chunk-QJIAXSLZ.js} +19 -19
  7. package/dist/{chunk-3C7Z3IJN.mjs → chunk-SGMQZRP6.mjs} +39 -9
  8. package/dist/{chunk-62FBZWGW.js → chunk-VSGYTGHY.js} +24 -3
  9. package/dist/{chunk-KSDE5G57.mjs → chunk-YKP4ODZA.mjs} +24 -3
  10. package/dist/{core-CzElxZoF.d.ts → core-BGEsBtTG.d.ts} +1 -1
  11. package/dist/{core-DU7gQKSk.d.mts → core-BcKywWLd.d.mts} +1 -1
  12. package/dist/helper.d.mts +3 -2
  13. package/dist/helper.d.ts +3 -2
  14. package/dist/helper.js +5 -3
  15. package/dist/helper.mjs +4 -2
  16. package/dist/http/elysia/index.d.mts +4 -4
  17. package/dist/http/elysia/index.d.ts +4 -4
  18. package/dist/http/elysia/index.js +42 -41
  19. package/dist/http/elysia/index.mjs +6 -5
  20. package/dist/http/express/index.d.mts +4 -4
  21. package/dist/http/express/index.d.ts +4 -4
  22. package/dist/http/express/index.js +39 -38
  23. package/dist/http/express/index.mjs +5 -4
  24. package/dist/http/fastify/index.d.mts +4 -4
  25. package/dist/http/fastify/index.d.ts +4 -4
  26. package/dist/http/fastify/index.js +40 -39
  27. package/dist/http/fastify/index.mjs +6 -5
  28. package/dist/http/h3/index.d.mts +4 -4
  29. package/dist/http/h3/index.d.ts +4 -4
  30. package/dist/http/h3/index.js +40 -39
  31. package/dist/http/h3/index.mjs +6 -5
  32. package/dist/http/hono/index.d.mts +4 -4
  33. package/dist/http/hono/index.d.ts +4 -4
  34. package/dist/http/hono/index.js +35 -35
  35. package/dist/http/hono/index.mjs +2 -2
  36. package/dist/http/hyper-express/index.d.mts +4 -4
  37. package/dist/http/hyper-express/index.d.ts +4 -4
  38. package/dist/http/hyper-express/index.js +37 -36
  39. package/dist/http/hyper-express/index.mjs +5 -4
  40. package/dist/http/koa/index.d.mts +4 -4
  41. package/dist/http/koa/index.d.ts +4 -4
  42. package/dist/http/koa/index.js +39 -38
  43. package/dist/http/koa/index.mjs +5 -4
  44. package/dist/index.d.mts +38 -36
  45. package/dist/index.d.ts +38 -36
  46. package/dist/index.js +44 -43
  47. package/dist/index.mjs +16 -15
  48. package/dist/{meta-BTnLXuCa.d.ts → meta-B_HW7cWh.d.mts} +3 -3
  49. package/dist/{meta-BTnLXuCa.d.mts → meta-B_HW7cWh.d.ts} +3 -3
  50. package/dist/rpc/bullmq/index.d.mts +5 -5
  51. package/dist/rpc/bullmq/index.d.ts +5 -5
  52. package/dist/rpc/bullmq/index.js +14 -14
  53. package/dist/rpc/bullmq/index.mjs +2 -2
  54. package/dist/rpc/kafka/index.d.mts +4 -4
  55. package/dist/rpc/kafka/index.d.ts +4 -4
  56. package/dist/rpc/kafka/index.js +14 -14
  57. package/dist/rpc/kafka/index.mjs +2 -2
  58. package/dist/rpc/nats/index.d.mts +4 -4
  59. package/dist/rpc/nats/index.d.ts +4 -4
  60. package/dist/rpc/nats/index.js +13 -13
  61. package/dist/rpc/nats/index.mjs +2 -2
  62. package/dist/rpc/rabbitmq/index.d.mts +4 -4
  63. package/dist/rpc/rabbitmq/index.d.ts +4 -4
  64. package/dist/rpc/rabbitmq/index.js +15 -15
  65. package/dist/rpc/rabbitmq/index.mjs +2 -2
  66. package/dist/rpc/redis/index.d.mts +4 -4
  67. package/dist/rpc/redis/index.d.ts +4 -4
  68. package/dist/rpc/redis/index.js +13 -13
  69. package/dist/rpc/redis/index.mjs +2 -2
  70. package/dist/test.d.mts +3 -3
  71. package/dist/test.d.ts +3 -3
  72. package/dist/test.js +6 -6
  73. package/dist/test.mjs +2 -2
  74. package/dist/{types--E-OCZhC.d.ts → types-C2SQ9U9V.d.mts} +3 -3
  75. package/dist/{types-CbfaGkPA.d.ts → types-CYF0vha6.d.ts} +3 -3
  76. package/dist/{types-BYqBeqrs.d.mts → types-DEQb_e59.d.mts} +3 -3
  77. package/dist/{types-BxlzVoRv.d.mts → types-PFPIQWVF.d.ts} +3 -3
  78. package/package.json +3 -2
  79. package/register/loader.mjs +2 -2
package/dist/index.mjs CHANGED
@@ -6,14 +6,14 @@ import {
6
6
  emitter,
7
7
  phecdaNamespace,
8
8
  useS
9
- } from "./chunk-HTY3H33L.mjs";
9
+ } from "./chunk-B45BN7LY.mjs";
10
10
  import {
11
11
  Addon,
12
12
  Arg,
13
13
  BaseParam,
14
14
  Body,
15
15
  Controller,
16
- Ctx,
16
+ Ctx as Ctx2,
17
17
  Define,
18
18
  Delete,
19
19
  Filter,
@@ -31,7 +31,7 @@ import {
31
31
  Route,
32
32
  Rpc,
33
33
  Search
34
- } from "./chunk-ICI5KUDX.mjs";
34
+ } from "./chunk-7NWDKK7D.mjs";
35
35
  import {
36
36
  BadGatewayException,
37
37
  BadRequestException,
@@ -55,11 +55,12 @@ import {
55
55
  addFilter,
56
56
  addGuard,
57
57
  addPipe,
58
- defaultPipe
59
- } from "./chunk-3C7Z3IJN.mjs";
58
+ defaultPipe,
59
+ joinUrl
60
+ } from "./chunk-SGMQZRP6.mjs";
60
61
  import {
61
62
  ERROR_SYMBOL,
62
- IS_HMR,
63
+ IS_DEV,
63
64
  IS_ONLY_GENERATE,
64
65
  IS_READY,
65
66
  IS_STRICT,
@@ -71,7 +72,7 @@ import {
71
72
  log,
72
73
  runMiddleware,
73
74
  setLogger
74
- } from "./chunk-KSDE5G57.mjs";
75
+ } from "./chunk-YKP4ODZA.mjs";
75
76
 
76
77
  // src/types.ts
77
78
  var ResponseSymbol = Symbol("response");
@@ -100,7 +101,7 @@ var ServerBase = class extends Base {
100
101
  __name(this, "ServerBase");
101
102
  }
102
103
  emitter = emitter;
103
- log(msg, level) {
104
+ log(msg, level = "log") {
104
105
  log(msg, level, this.tag);
105
106
  }
106
107
  };
@@ -111,8 +112,8 @@ var HttpBase = class extends ServerBase {
111
112
  context;
112
113
  };
113
114
  _ts_decorate([
114
- Ctx,
115
- _ts_metadata("design:type", typeof HttpContext === "undefined" ? Object : HttpContext)
115
+ Ctx2,
116
+ _ts_metadata("design:type", typeof Ctx === "undefined" ? Object : Ctx)
116
117
  ], HttpBase.prototype, "context", void 0);
117
118
  var RpcBase = class extends ServerBase {
118
119
  static {
@@ -121,8 +122,8 @@ var RpcBase = class extends ServerBase {
121
122
  context;
122
123
  };
123
124
  _ts_decorate([
124
- Ctx,
125
- _ts_metadata("design:type", typeof RpcContext === "undefined" ? Object : RpcContext)
125
+ Ctx2,
126
+ _ts_metadata("design:type", typeof Ctx === "undefined" ? Object : Ctx)
126
127
  ], RpcBase.prototype, "context", void 0);
127
128
 
128
129
  // src/modules/filter.ts
@@ -308,7 +309,7 @@ var HTTPGenerator = class extends Generator {
308
309
  addMethod(args) {
309
310
  const { http, name, func, params, tag } = args;
310
311
  if (!http?.type) return;
311
- const url = http.prefix + http.route.replace(/\/\:([^\/]*)/g, (_, js) => `/{{${js}}}`);
312
+ const url = joinUrl(http.prefix, http.route).replace(/\/\:([^\/]*)/g, (_, js) => `/{{${js}}}`);
312
313
  if (!this.classMap[name]) this.classMap[name] = {};
313
314
  this.classMap[name][func] = `
314
315
  ${func}(...args){
@@ -341,7 +342,7 @@ export {
341
342
  ConflictException,
342
343
  Context,
343
344
  Controller,
344
- Ctx,
345
+ Ctx2 as Ctx,
345
346
  CustomResponse,
346
347
  Define,
347
348
  Delete,
@@ -358,7 +359,7 @@ export {
358
359
  Head,
359
360
  Header,
360
361
  HttpBase,
361
- IS_HMR,
362
+ IS_DEV,
362
363
  IS_ONLY_GENERATE,
363
364
  IS_READY,
364
365
  IS_STRICT,
@@ -1,7 +1,7 @@
1
1
  import { Events, Construct } from 'phecda-core';
2
2
 
3
3
  declare const ERROR_SYMBOL = "__PS_ERROR__";
4
- declare const IS_HMR: boolean;
4
+ declare const IS_DEV: boolean;
5
5
  declare const IS_ONLY_GENERATE: boolean;
6
6
  declare const IS_STRICT: boolean;
7
7
  declare const LOG_LEVEL: number;
@@ -32,7 +32,7 @@ type ToClientInstance<Instance extends Record<string, any>> = ParseInstance<Pick
32
32
  type ToClientFn<Func extends AnyFunction> = (...p: Parameters<Func>) => Promise<BaseReturn<ReturnType<Func>>>;
33
33
  type PickFunc<Instance> = Pick<Instance, PickFuncKeys<Instance>>;
34
34
  type OmitFunction<Instance> = Omit<Instance, PickFuncKeys<Instance>>;
35
- interface BaseContext {
35
+ interface BaseCtx {
36
36
  meta: ControllerMeta;
37
37
  moduleMap: Record<string, any>;
38
38
  type: string;
@@ -105,4 +105,4 @@ interface ControllerMeta extends Meta {
105
105
  data: ControllerMetaData;
106
106
  }
107
107
 
108
- export { type BaseContext as B, type ControllerMetaData as C, type DefaultOptions as D, type Emitter as E, IS_HMR 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 ControllerMeta 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_READY as m, PS_EXIT_CODE as n };
108
+ export { type BaseCtx as B, type ControllerMetaData 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 ControllerMeta 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_READY as m, PS_EXIT_CODE as n };
@@ -1,7 +1,7 @@
1
1
  import { Events, Construct } from 'phecda-core';
2
2
 
3
3
  declare const ERROR_SYMBOL = "__PS_ERROR__";
4
- declare const IS_HMR: boolean;
4
+ declare const IS_DEV: boolean;
5
5
  declare const IS_ONLY_GENERATE: boolean;
6
6
  declare const IS_STRICT: boolean;
7
7
  declare const LOG_LEVEL: number;
@@ -32,7 +32,7 @@ type ToClientInstance<Instance extends Record<string, any>> = ParseInstance<Pick
32
32
  type ToClientFn<Func extends AnyFunction> = (...p: Parameters<Func>) => Promise<BaseReturn<ReturnType<Func>>>;
33
33
  type PickFunc<Instance> = Pick<Instance, PickFuncKeys<Instance>>;
34
34
  type OmitFunction<Instance> = Omit<Instance, PickFuncKeys<Instance>>;
35
- interface BaseContext {
35
+ interface BaseCtx {
36
36
  meta: ControllerMeta;
37
37
  moduleMap: Record<string, any>;
38
38
  type: string;
@@ -105,4 +105,4 @@ interface ControllerMeta extends Meta {
105
105
  data: ControllerMetaData;
106
106
  }
107
107
 
108
- export { type BaseContext as B, type ControllerMetaData as C, type DefaultOptions as D, type Emitter as E, IS_HMR 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 ControllerMeta 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_READY as m, PS_EXIT_CODE as n };
108
+ export { type BaseCtx as B, type ControllerMetaData 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 ControllerMeta 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_READY as m, PS_EXIT_CODE as n };
@@ -1,10 +1,10 @@
1
1
  import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
2
- import { F as Factory } from '../../core-DU7gQKSk.mjs';
3
- import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-BYqBeqrs.mjs';
4
- import { T as ToClientMap } from '../../meta-BTnLXuCa.mjs';
2
+ import { F as Factory } from '../../core-BcKywWLd.mjs';
3
+ import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DEQb_e59.mjs';
4
+ import { T as ToClientMap } from '../../meta-B_HW7cWh.mjs';
5
5
  import 'phecda-core';
6
6
 
7
- interface BullmqCtx extends RpcContext {
7
+ interface BullmqCtx extends RpcCtx {
8
8
  type: 'bullmq';
9
9
  }
10
10
  type BullmqOptions = Omit<RpcServerOptions, 'globalAddons'> & {
@@ -13,7 +13,7 @@ type BullmqOptions = Omit<RpcServerOptions, 'globalAddons'> & {
13
13
  };
14
14
  declare function create({ moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: BullmqOptions): Promise<{
15
15
  workerMap: Record<string, Worker<any, any, string>>;
16
- queueMap: Record<string, Queue<any, any, string>>;
16
+ queueMap: Record<string, Queue<any, any, string, any, any, string>>;
17
17
  }>;
18
18
 
19
19
  declare function createClient<S extends Record<string, any>>(controllers: S, opts?: RpcClientOptions & BullmqOptions): Promise<ToClientMap<S>>;
@@ -1,10 +1,10 @@
1
1
  import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
2
- import { F as Factory } from '../../core-CzElxZoF.js';
3
- import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CbfaGkPA.js';
4
- import { T as ToClientMap } from '../../meta-BTnLXuCa.js';
2
+ import { F as Factory } from '../../core-BGEsBtTG.js';
3
+ import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CYF0vha6.js';
4
+ import { T as ToClientMap } from '../../meta-B_HW7cWh.js';
5
5
  import 'phecda-core';
6
6
 
7
- interface BullmqCtx extends RpcContext {
7
+ interface BullmqCtx extends RpcCtx {
8
8
  type: 'bullmq';
9
9
  }
10
10
  type BullmqOptions = Omit<RpcServerOptions, 'globalAddons'> & {
@@ -13,7 +13,7 @@ type BullmqOptions = Omit<RpcServerOptions, 'globalAddons'> & {
13
13
  };
14
14
  declare function create({ moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: BullmqOptions): Promise<{
15
15
  workerMap: Record<string, Worker<any, any, string>>;
16
- queueMap: Record<string, Queue<any, any, string>>;
16
+ queueMap: Record<string, Queue<any, any, string, any, any, string>>;
17
17
  }>;
18
18
 
19
19
  declare function createClient<S extends Record<string, any>>(controllers: S, opts?: RpcClientOptions & BullmqOptions): Promise<ToClientMap<S>>;
@@ -4,10 +4,10 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkJF4YU32Ejs = require('../../chunk-JF4YU32E.js');
7
+ var _chunk7EMAZGYOjs = require('../../chunk-7EMAZGYO.js');
8
8
 
9
9
 
10
- var _chunk62FBZWGWjs = require('../../chunk-62FBZWGW.js');
10
+ var _chunkVSGYTGHYjs = require('../../chunk-VSGYTGHY.js');
11
11
 
12
12
  // src/rpc/bullmq/create.ts
13
13
  var _bullmq = require('bullmq');
@@ -18,14 +18,14 @@ async function create({ moduleMap, meta }, opts = {}) {
18
18
  const workerMap = {};
19
19
  const queueMap = {};
20
20
  const existQueue = /* @__PURE__ */ new Set();
21
- const metaMap = _chunkJF4YU32Ejs.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
+ const metaMap = _chunk7EMAZGYOjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
22
  const { controller, rpc, func, tag } = meta2.data;
23
23
  if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
24
24
  debug(`register method "${func}" in module "${tag}"`);
25
25
  return true;
26
26
  }
27
27
  });
28
- _chunkJF4YU32Ejs.detectAopDep.call(void 0, meta, {
28
+ _chunk7EMAZGYOjs.detectAopDep.call(void 0, meta, {
29
29
  guards: globalGuards
30
30
  }, "rpc");
31
31
  async function subscribeQueues() {
@@ -39,12 +39,12 @@ async function create({ moduleMap, meta }, opts = {}) {
39
39
  if (existQueue.has(queue)) continue;
40
40
  existQueue.add(queue);
41
41
  workerMap[queue] = new (0, _bullmq.Worker)(queue, handleRequest, workerOpts);
42
- _chunkJF4YU32Ejs.Context.applyAddons(addons, workerMap[queue], "bullmq");
42
+ _chunk7EMAZGYOjs.Context.applyAddons(addons, workerMap[queue], "bullmq");
43
43
  }
44
44
  }
45
45
  }
46
46
  }
47
- _chunk62FBZWGWjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
47
+ _chunkVSGYTGHYjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
48
48
  async function handleRequest(job) {
49
49
  const { data } = job;
50
50
  const { tag, func, args, id, queue: clientQueue, _ps } = data;
@@ -53,12 +53,12 @@ async function create({ moduleMap, meta }, opts = {}) {
53
53
  const meta2 = metaMap.get(tag)[func];
54
54
  const { data: { rpc: { isEvent } = {} } } = meta2;
55
55
  if (!isEvent && !(clientQueue in queueMap)) queueMap[clientQueue] = new (0, _bullmq.Queue)(clientQueue, queueOpts);
56
- const aop = _chunkJF4YU32Ejs.Context.getAop(meta2, {
56
+ const aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
57
57
  globalFilter,
58
58
  globalGuards,
59
59
  globalPipe
60
60
  });
61
- const context = new (0, _chunkJF4YU32Ejs.Context)({
61
+ const context = new (0, _chunk7EMAZGYOjs.Context)({
62
62
  type: "bullmq",
63
63
  category: "rpc",
64
64
  moduleMap,
@@ -86,9 +86,9 @@ async function create({ moduleMap, meta }, opts = {}) {
86
86
  }
87
87
  });
88
88
  }
89
- _chunk62FBZWGWjs.__name.call(void 0, handleRequest, "handleRequest");
89
+ _chunkVSGYTGHYjs.__name.call(void 0, handleRequest, "handleRequest");
90
90
  subscribeQueues();
91
- _chunkJF4YU32Ejs.HMR.call(void 0, async () => {
91
+ _chunk7EMAZGYOjs.HMR.call(void 0, async () => {
92
92
  for (const i in workerMap) await workerMap[i].close(true);
93
93
  for (const i in queueMap) await queueMap[i].close();
94
94
  await subscribeQueues();
@@ -98,7 +98,7 @@ async function create({ moduleMap, meta }, opts = {}) {
98
98
  queueMap
99
99
  };
100
100
  }
101
- _chunk62FBZWGWjs.__name.call(void 0, create, "create");
101
+ _chunkVSGYTGHYjs.__name.call(void 0, create, "create");
102
102
 
103
103
  // src/rpc/bullmq/client.ts
104
104
  var _events = require('events');
@@ -109,7 +109,7 @@ async function createClient(controllers, opts = {}) {
109
109
  const { max, workerOpts, queueOpts, timeout, key } = opts;
110
110
  const ret = {};
111
111
  const emitter = new (0, _events.EventEmitter)();
112
- const clientQueue = _chunkJF4YU32Ejs.genClientQueue.call(void 0, key);
112
+ const clientQueue = _chunk7EMAZGYOjs.genClientQueue.call(void 0, key);
113
113
  const queueMap = {};
114
114
  new (0, _bullmq.Worker)(clientQueue, async (job) => {
115
115
  const { data, id, error } = job.data;
@@ -154,7 +154,7 @@ async function createClient(controllers, opts = {}) {
154
154
  if (error) reject(data);
155
155
  else resolve(data);
156
156
  }
157
- _chunk62FBZWGWjs.__name.call(void 0, listener, "listener");
157
+ _chunkVSGYTGHYjs.__name.call(void 0, listener, "listener");
158
158
  eventCount++;
159
159
  emitter.once(id, listener);
160
160
  });
@@ -164,7 +164,7 @@ async function createClient(controllers, opts = {}) {
164
164
  }
165
165
  return ret;
166
166
  }
167
- _chunk62FBZWGWjs.__name.call(void 0, createClient, "createClient");
167
+ _chunkVSGYTGHYjs.__name.call(void 0, createClient, "createClient");
168
168
 
169
169
 
170
170
 
@@ -4,10 +4,10 @@ import {
4
4
  createControllerMetaMap,
5
5
  detectAopDep,
6
6
  genClientQueue
7
- } from "../../chunk-3C7Z3IJN.mjs";
7
+ } from "../../chunk-SGMQZRP6.mjs";
8
8
  import {
9
9
  __name
10
- } from "../../chunk-KSDE5G57.mjs";
10
+ } from "../../chunk-YKP4ODZA.mjs";
11
11
 
12
12
  // src/rpc/bullmq/create.ts
13
13
  import { Queue, Worker } from "bullmq";
@@ -1,10 +1,10 @@
1
1
  import { Consumer, Producer } from 'kafkajs';
2
- import { F as Factory } from '../../core-DU7gQKSk.mjs';
3
- import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-BYqBeqrs.mjs';
4
- import { T as ToClientMap } from '../../meta-BTnLXuCa.mjs';
2
+ import { F as Factory } from '../../core-BcKywWLd.mjs';
3
+ import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DEQb_e59.mjs';
4
+ import { T as ToClientMap } from '../../meta-B_HW7cWh.mjs';
5
5
  import 'phecda-core';
6
6
 
7
- interface KafkaCtx extends RpcContext {
7
+ interface KafkaCtx extends RpcCtx {
8
8
  type: 'kafka';
9
9
  topic: string;
10
10
  partition: number;
@@ -1,10 +1,10 @@
1
1
  import { Consumer, Producer } from 'kafkajs';
2
- import { F as Factory } from '../../core-CzElxZoF.js';
3
- import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CbfaGkPA.js';
4
- import { T as ToClientMap } from '../../meta-BTnLXuCa.js';
2
+ import { F as Factory } from '../../core-BGEsBtTG.js';
3
+ import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CYF0vha6.js';
4
+ import { T as ToClientMap } from '../../meta-B_HW7cWh.js';
5
5
  import 'phecda-core';
6
6
 
7
- interface KafkaCtx extends RpcContext {
7
+ interface KafkaCtx extends RpcCtx {
8
8
  type: 'kafka';
9
9
  topic: string;
10
10
  partition: number;
@@ -3,10 +3,10 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkJF4YU32Ejs = require('../../chunk-JF4YU32E.js');
6
+ var _chunk7EMAZGYOjs = require('../../chunk-7EMAZGYO.js');
7
7
 
8
8
 
9
- var _chunk62FBZWGWjs = require('../../chunk-62FBZWGW.js');
9
+ var _chunkVSGYTGHYjs = require('../../chunk-VSGYTGHY.js');
10
10
 
11
11
  // src/rpc/kafka/bind.ts
12
12
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
@@ -14,18 +14,18 @@ var debug = _debug2.default.call(void 0, "phecda-server/kafka");
14
14
  async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
15
15
  const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
16
16
  const existQueue = /* @__PURE__ */ new Set();
17
- const metaMap = _chunkJF4YU32Ejs.createControllerMetaMap.call(void 0, meta, (meta2) => {
17
+ const metaMap = _chunk7EMAZGYOjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
18
18
  const { controller, rpc, func, tag } = meta2.data;
19
19
  if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
20
20
  debug(`register method "${func}" in module "${tag}"`);
21
21
  return true;
22
22
  }
23
23
  });
24
- _chunkJF4YU32Ejs.detectAopDep.call(void 0, meta, {
24
+ _chunk7EMAZGYOjs.detectAopDep.call(void 0, meta, {
25
25
  guards: globalGuards,
26
26
  addons: globalAddons
27
27
  }, "rpc");
28
- _chunkJF4YU32Ejs.Context.applyAddons(globalAddons, {
28
+ _chunk7EMAZGYOjs.Context.applyAddons(globalAddons, {
29
29
  consumer,
30
30
  producer
31
31
  }, "kafka");
@@ -47,10 +47,10 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
47
47
  }
48
48
  }
49
49
  }
50
- _chunk62FBZWGWjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
50
+ _chunkVSGYTGHYjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
51
51
  await subscribeQueues();
52
52
  await consumer.run({
53
- eachMessage: /* @__PURE__ */ _chunk62FBZWGWjs.__name.call(void 0, async ({ message, partition, topic, heartbeat, pause }) => {
53
+ eachMessage: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, async ({ message, partition, topic, heartbeat, pause }) => {
54
54
  if (!existQueue.has(topic)) return;
55
55
  const data = JSON.parse(message.value.toString());
56
56
  const { tag, func, id, queue: clientQueue, _ps, args } = data;
@@ -59,12 +59,12 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
59
59
  const meta2 = metaMap.get(tag)[func];
60
60
  const { data: { rpc } } = meta2;
61
61
  const isEvent = rpc.isEvent;
62
- const aop = _chunkJF4YU32Ejs.Context.getAop(meta2, {
62
+ const aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
63
63
  globalFilter,
64
64
  globalGuards,
65
65
  globalPipe
66
66
  });
67
- const context = new (0, _chunkJF4YU32Ejs.Context)({
67
+ const context = new (0, _chunk7EMAZGYOjs.Context)({
68
68
  type: "kafka",
69
69
  category: "rpc",
70
70
  moduleMap,
@@ -113,7 +113,7 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
113
113
  }, "eachMessage")
114
114
  });
115
115
  }
116
- _chunk62FBZWGWjs.__name.call(void 0, bind, "bind");
116
+ _chunkVSGYTGHYjs.__name.call(void 0, bind, "bind");
117
117
 
118
118
  // src/rpc/kafka/client.ts
119
119
  var _events = require('events');
@@ -122,7 +122,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
122
122
  let eventCount = 1;
123
123
  const ret = {};
124
124
  const emitter = new (0, _events.EventEmitter)();
125
- const clientQueue = _chunkJF4YU32Ejs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
125
+ const clientQueue = _chunk7EMAZGYOjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
126
126
  await consumer.subscribe({
127
127
  topic: clientQueue,
128
128
  fromBeginning: true
@@ -172,7 +172,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
172
172
  if (error) reject(data);
173
173
  else resolve(data);
174
174
  }
175
- _chunk62FBZWGWjs.__name.call(void 0, listener, "listener");
175
+ _chunkVSGYTGHYjs.__name.call(void 0, listener, "listener");
176
176
  eventCount++;
177
177
  emitter.once(id, listener);
178
178
  });
@@ -181,7 +181,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
181
181
  });
182
182
  }
183
183
  await consumer.run({
184
- eachMessage: /* @__PURE__ */ _chunk62FBZWGWjs.__name.call(void 0, async ({ message, topic }) => {
184
+ eachMessage: /* @__PURE__ */ _chunkVSGYTGHYjs.__name.call(void 0, async ({ message, topic }) => {
185
185
  if (clientQueue === topic && message.value) {
186
186
  const { data, id, error } = JSON.parse(message.value.toString());
187
187
  emitter.emit(id, data, error);
@@ -190,7 +190,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
190
190
  });
191
191
  return ret;
192
192
  }
193
- _chunk62FBZWGWjs.__name.call(void 0, createClient, "createClient");
193
+ _chunkVSGYTGHYjs.__name.call(void 0, createClient, "createClient");
194
194
 
195
195
 
196
196
 
@@ -3,10 +3,10 @@ import {
3
3
  createControllerMetaMap,
4
4
  detectAopDep,
5
5
  genClientQueue
6
- } from "../../chunk-3C7Z3IJN.mjs";
6
+ } from "../../chunk-SGMQZRP6.mjs";
7
7
  import {
8
8
  __name
9
- } from "../../chunk-KSDE5G57.mjs";
9
+ } from "../../chunk-YKP4ODZA.mjs";
10
10
 
11
11
  // src/rpc/kafka/bind.ts
12
12
  import Debug from "debug";
@@ -1,10 +1,10 @@
1
1
  import { NatsConnection } from 'nats';
2
- import { F as Factory } from '../../core-DU7gQKSk.mjs';
3
- import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-BYqBeqrs.mjs';
4
- import { T as ToClientMap } from '../../meta-BTnLXuCa.mjs';
2
+ import { F as Factory } from '../../core-BcKywWLd.mjs';
3
+ import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DEQb_e59.mjs';
4
+ import { T as ToClientMap } from '../../meta-B_HW7cWh.mjs';
5
5
  import 'phecda-core';
6
6
 
7
- interface NatsCtx extends RpcContext {
7
+ interface NatsCtx extends RpcCtx {
8
8
  type: 'nats';
9
9
  msg: any;
10
10
  }
@@ -1,10 +1,10 @@
1
1
  import { NatsConnection } from 'nats';
2
- import { F as Factory } from '../../core-CzElxZoF.js';
3
- import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CbfaGkPA.js';
4
- import { T as ToClientMap } from '../../meta-BTnLXuCa.js';
2
+ import { F as Factory } from '../../core-BGEsBtTG.js';
3
+ import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CYF0vha6.js';
4
+ import { T as ToClientMap } from '../../meta-B_HW7cWh.js';
5
5
  import 'phecda-core';
6
6
 
7
- interface NatsCtx extends RpcContext {
7
+ interface NatsCtx extends RpcCtx {
8
8
  type: 'nats';
9
9
  msg: any;
10
10
  }
@@ -3,10 +3,10 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkJF4YU32Ejs = require('../../chunk-JF4YU32E.js');
6
+ var _chunk7EMAZGYOjs = require('../../chunk-7EMAZGYO.js');
7
7
 
8
8
 
9
- var _chunk62FBZWGWjs = require('../../chunk-62FBZWGW.js');
9
+ var _chunkVSGYTGHYjs = require('../../chunk-VSGYTGHY.js');
10
10
 
11
11
  // src/rpc/nats/bind.ts
12
12
  var _nats = require('nats');
@@ -17,18 +17,18 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
17
17
  const sc = _nats.StringCodec.call(void 0, );
18
18
  const subscriptionMap = {};
19
19
  const existQueue = /* @__PURE__ */ new Set();
20
- const metaMap = _chunkJF4YU32Ejs.createControllerMetaMap.call(void 0, meta, (meta2) => {
20
+ const metaMap = _chunk7EMAZGYOjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
21
  const { controller, rpc, func, tag } = meta2.data;
22
22
  if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _2 => _2.queue]) !== void 0) {
23
23
  debug(`register method "${func}" in module "${tag}"`);
24
24
  return true;
25
25
  }
26
26
  });
27
- _chunkJF4YU32Ejs.detectAopDep.call(void 0, meta, {
27
+ _chunk7EMAZGYOjs.detectAopDep.call(void 0, meta, {
28
28
  addons: globalAddons,
29
29
  guards: globalGuards
30
30
  }, "rpc");
31
- _chunkJF4YU32Ejs.Context.applyAddons(globalAddons, nc, "nats");
31
+ _chunk7EMAZGYOjs.Context.applyAddons(globalAddons, nc, "nats");
32
32
  async function subscribeQueues() {
33
33
  existQueue.clear();
34
34
  for (const [tag, record] of metaMap) {
@@ -47,7 +47,7 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
47
47
  }
48
48
  }
49
49
  }
50
- _chunk62FBZWGWjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
50
+ _chunkVSGYTGHYjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
51
51
  async function handleRequest(_, msg) {
52
52
  const data = JSON.parse(sc.decode(msg.data));
53
53
  const { tag, func, id, _ps, args } = data;
@@ -56,12 +56,12 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
56
56
  const meta2 = metaMap.get(tag)[func];
57
57
  const { data: { rpc: { isEvent } = {} } } = meta2;
58
58
  if (isEvent) msg.respond("{}");
59
- const aop = _chunkJF4YU32Ejs.Context.getAop(meta2, {
59
+ const aop = _chunk7EMAZGYOjs.Context.getAop(meta2, {
60
60
  globalFilter,
61
61
  globalGuards,
62
62
  globalPipe
63
63
  });
64
- const context = new (0, _chunkJF4YU32Ejs.Context)({
64
+ const context = new (0, _chunk7EMAZGYOjs.Context)({
65
65
  type: "nats",
66
66
  category: "rpc",
67
67
  moduleMap,
@@ -88,14 +88,14 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
88
88
  })));
89
89
  });
90
90
  }
91
- _chunk62FBZWGWjs.__name.call(void 0, handleRequest, "handleRequest");
91
+ _chunkVSGYTGHYjs.__name.call(void 0, handleRequest, "handleRequest");
92
92
  subscribeQueues();
93
- _chunkJF4YU32Ejs.HMR.call(void 0, async () => {
93
+ _chunk7EMAZGYOjs.HMR.call(void 0, async () => {
94
94
  for (const i in subscriptionMap) subscriptionMap[i].unsubscribe();
95
95
  await subscribeQueues();
96
96
  });
97
97
  }
98
- _chunk62FBZWGWjs.__name.call(void 0, bind, "bind");
98
+ _chunkVSGYTGHYjs.__name.call(void 0, bind, "bind");
99
99
 
100
100
  // src/rpc/nats/client.ts
101
101
 
@@ -145,7 +145,7 @@ async function createClient(nc, controllers, opts) {
145
145
  if (error) reject(data);
146
146
  else resolve(data);
147
147
  }
148
- _chunk62FBZWGWjs.__name.call(void 0, handler, "handler");
148
+ _chunkVSGYTGHYjs.__name.call(void 0, handler, "handler");
149
149
  eventCount++;
150
150
  });
151
151
  };
@@ -154,7 +154,7 @@ async function createClient(nc, controllers, opts) {
154
154
  }
155
155
  return ret;
156
156
  }
157
- _chunk62FBZWGWjs.__name.call(void 0, createClient, "createClient");
157
+ _chunkVSGYTGHYjs.__name.call(void 0, createClient, "createClient");
158
158
 
159
159
 
160
160
 
@@ -3,10 +3,10 @@ import {
3
3
  HMR,
4
4
  createControllerMetaMap,
5
5
  detectAopDep
6
- } from "../../chunk-3C7Z3IJN.mjs";
6
+ } from "../../chunk-SGMQZRP6.mjs";
7
7
  import {
8
8
  __name
9
- } from "../../chunk-KSDE5G57.mjs";
9
+ } from "../../chunk-YKP4ODZA.mjs";
10
10
 
11
11
  // src/rpc/nats/bind.ts
12
12
  import { StringCodec } from "nats";
@@ -1,10 +1,10 @@
1
1
  import amqplib from 'amqplib';
2
- import { F as Factory } from '../../core-DU7gQKSk.mjs';
3
- import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-BYqBeqrs.mjs';
4
- import { T as ToClientMap } from '../../meta-BTnLXuCa.mjs';
2
+ import { F as Factory } from '../../core-BcKywWLd.mjs';
3
+ import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DEQb_e59.mjs';
4
+ import { T as ToClientMap } from '../../meta-B_HW7cWh.mjs';
5
5
  import 'phecda-core';
6
6
 
7
- interface RabbitmqCtx extends RpcContext {
7
+ interface RabbitmqCtx extends RpcCtx {
8
8
  type: 'rabbitmq';
9
9
  ch: amqplib.Channel;
10
10
  msg: amqplib.ConsumeMessage;
@@ -1,10 +1,10 @@
1
1
  import amqplib from 'amqplib';
2
- import { F as Factory } from '../../core-CzElxZoF.js';
3
- import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CbfaGkPA.js';
4
- import { T as ToClientMap } from '../../meta-BTnLXuCa.js';
2
+ import { F as Factory } from '../../core-BGEsBtTG.js';
3
+ import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CYF0vha6.js';
4
+ import { T as ToClientMap } from '../../meta-B_HW7cWh.js';
5
5
  import 'phecda-core';
6
6
 
7
- interface RabbitmqCtx extends RpcContext {
7
+ interface RabbitmqCtx extends RpcCtx {
8
8
  type: 'rabbitmq';
9
9
  ch: amqplib.Channel;
10
10
  msg: amqplib.ConsumeMessage;