phecda-server 5.0.0-beta.19 → 5.0.0-beta.21

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 (36) hide show
  1. package/dist/{chunk-WNTTAFLC.js → chunk-562XCEUU.js} +9 -11
  2. package/dist/{chunk-PXI5J4LR.mjs → chunk-AL36AJMH.mjs} +8 -10
  3. package/dist/{chunk-VBYDVWRK.js → chunk-FMPVMJLE.js} +38 -32
  4. package/dist/{chunk-LSMNOIFA.mjs → chunk-TCW7B6MG.mjs} +39 -33
  5. package/dist/core-895ed04d.d.ts +112 -0
  6. package/dist/index.d.ts +39 -15
  7. package/dist/index.js +27 -24
  8. package/dist/index.mjs +8 -5
  9. package/dist/rpc/kafka/index.d.ts +2 -2
  10. package/dist/rpc/kafka/index.js +9 -6
  11. package/dist/rpc/kafka/index.mjs +6 -3
  12. package/dist/rpc/rabbitmq/index.d.ts +2 -2
  13. package/dist/rpc/rabbitmq/index.js +9 -6
  14. package/dist/rpc/rabbitmq/index.mjs +6 -3
  15. package/dist/rpc/redis/index.d.ts +2 -2
  16. package/dist/rpc/redis/index.js +9 -6
  17. package/dist/rpc/redis/index.mjs +6 -3
  18. package/dist/server/express/index.d.ts +1 -1
  19. package/dist/server/express/index.js +18 -14
  20. package/dist/server/express/index.mjs +9 -5
  21. package/dist/server/fastify/index.d.ts +1 -1
  22. package/dist/server/fastify/index.js +23 -16
  23. package/dist/server/fastify/index.mjs +13 -6
  24. package/dist/server/h3/index.d.ts +1 -1
  25. package/dist/server/h3/index.js +18 -14
  26. package/dist/server/h3/index.mjs +9 -5
  27. package/dist/server/koa/index.d.ts +1 -1
  28. package/dist/server/koa/index.js +18 -14
  29. package/dist/server/koa/index.mjs +9 -5
  30. package/dist/test.d.ts +1 -1
  31. package/dist/test.js +2 -2
  32. package/dist/test.mjs +1 -1
  33. package/package.json +3 -2
  34. package/register/loader.mjs +3 -5
  35. package/register/utils.mjs +46 -5
  36. package/dist/core-eb2a0799.d.ts +0 -131
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkVBYDVWRKjs = require('./chunk-VBYDVWRK.js');
8
+ var _chunkFMPVMJLEjs = require('./chunk-FMPVMJLE.js');
9
9
 
10
10
 
11
11
 
@@ -34,8 +34,7 @@ var _chunkEVF2CXTPjs = require('./chunk-EVF2CXTP.js');
34
34
 
35
35
 
36
36
 
37
-
38
- var _chunkWNTTAFLCjs = require('./chunk-WNTTAFLC.js');
37
+ var _chunk562XCEUUjs = require('./chunk-562XCEUU.js');
39
38
 
40
39
 
41
40
 
@@ -264,6 +263,10 @@ function Header(name, value) {
264
263
  };
265
264
  }
266
265
  _chunkXHKBG2VAjs.__name.call(void 0, Header, "Header");
266
+ function Ctx(target, key) {
267
+ _phecdacore.set.call(void 0, target, "context", key);
268
+ }
269
+ _chunkXHKBG2VAjs.__name.call(void 0, Ctx, "Ctx");
267
270
  function Define(key, value) {
268
271
  return (target, k) => {
269
272
  if (!k) {
@@ -326,9 +329,9 @@ var PFilter = class extends Dev {
326
329
  constructor(tag) {
327
330
  super();
328
331
  this.key = tag || _phecdacore.getTag.call(void 0, this);
329
- _chunkWNTTAFLCjs.addFilter.call(void 0, this.key, this.use.bind(this));
332
+ _chunk562XCEUUjs.addFilter.call(void 0, this.key, this.use.bind(this));
330
333
  this.onUnmount(() => {
331
- delete _chunkWNTTAFLCjs.Context.filterRecord[this.key];
334
+ delete _chunk562XCEUUjs.Context.filterRecord[this.key];
332
335
  });
333
336
  }
334
337
  };
@@ -341,9 +344,9 @@ var PGuard = class extends Dev {
341
344
  constructor(tag) {
342
345
  super();
343
346
  this.key = tag || _phecdacore.getTag.call(void 0, this);
344
- _chunkWNTTAFLCjs.addGuard.call(void 0, this.key, this.use.bind(this));
347
+ _chunk562XCEUUjs.addGuard.call(void 0, this.key, this.use.bind(this));
345
348
  this.onUnmount(() => {
346
- delete _chunkWNTTAFLCjs.Context.guardRecord[this.key];
349
+ delete _chunk562XCEUUjs.Context.guardRecord[this.key];
347
350
  });
348
351
  }
349
352
  };
@@ -357,9 +360,9 @@ var PInterceptor = class extends Dev {
357
360
  super();
358
361
  this.key = tag || _phecdacore.getTag.call(void 0, this);
359
362
  this.onUnmount(() => {
360
- delete _chunkWNTTAFLCjs.Context.interceptorRecord[this.key];
363
+ delete _chunk562XCEUUjs.Context.interceptorRecord[this.key];
361
364
  });
362
- _chunkWNTTAFLCjs.addInterceptor.call(void 0, this.key, this.use.bind(this));
365
+ _chunk562XCEUUjs.addInterceptor.call(void 0, this.key, this.use.bind(this));
363
366
  }
364
367
  };
365
368
  _chunkXHKBG2VAjs.__name.call(void 0, PInterceptor, "PInterceptor");
@@ -371,9 +374,9 @@ var PPipe = class extends Dev {
371
374
  constructor(tag) {
372
375
  super();
373
376
  this.key = tag || _phecdacore.getTag.call(void 0, this);
374
- _chunkWNTTAFLCjs.addPipe.call(void 0, this.key, this.use.bind(this));
377
+ _chunk562XCEUUjs.addPipe.call(void 0, this.key, this.use.bind(this));
375
378
  this.onUnmount(() => {
376
- delete _chunkWNTTAFLCjs.Context.pipeRecord[this.key];
379
+ delete _chunk562XCEUUjs.Context.pipeRecord[this.key];
377
380
  });
378
381
  }
379
382
  };
@@ -386,9 +389,9 @@ var PPlugin = class extends Dev {
386
389
  constructor(tag) {
387
390
  super();
388
391
  this.key = tag || _phecdacore.getTag.call(void 0, this);
389
- _chunkWNTTAFLCjs.addPlugin.call(void 0, this.key, this.use.bind(this));
392
+ _chunk562XCEUUjs.addPlugin.call(void 0, this.key, this.use.bind(this));
390
393
  this.onUnmount(() => {
391
- delete _chunkWNTTAFLCjs.Context.pluginRecord[this.key];
394
+ delete _chunk562XCEUUjs.Context.pluginRecord[this.key];
392
395
  });
393
396
  }
394
397
  };
@@ -402,33 +405,33 @@ var PExtension = class extends Dev {
402
405
  super();
403
406
  const key = this.key = tag || _phecdacore.getTag.call(void 0, this);
404
407
  if (this.pipe) {
405
- _chunkWNTTAFLCjs.addPipe.call(void 0, key, this.pipe.bind(this));
408
+ _chunk562XCEUUjs.addPipe.call(void 0, key, this.pipe.bind(this));
406
409
  this.onUnmount(() => {
407
- delete _chunkWNTTAFLCjs.Context.pipeRecord[key];
410
+ delete _chunk562XCEUUjs.Context.pipeRecord[key];
408
411
  });
409
412
  }
410
413
  if (this.plugin) {
411
- _chunkWNTTAFLCjs.addPlugin.call(void 0, key, this.plugin.bind(this));
414
+ _chunk562XCEUUjs.addPlugin.call(void 0, key, this.plugin.bind(this));
412
415
  this.onUnmount(() => {
413
- delete _chunkWNTTAFLCjs.Context.pluginRecord[key];
416
+ delete _chunk562XCEUUjs.Context.pluginRecord[key];
414
417
  });
415
418
  }
416
419
  if (this.intercept) {
417
- _chunkWNTTAFLCjs.addInterceptor.call(void 0, key, this.intercept.bind(this));
420
+ _chunk562XCEUUjs.addInterceptor.call(void 0, key, this.intercept.bind(this));
418
421
  this.onUnmount(() => {
419
- delete _chunkWNTTAFLCjs.Context.interceptorRecord[key];
422
+ delete _chunk562XCEUUjs.Context.interceptorRecord[key];
420
423
  });
421
424
  }
422
425
  if (this.guard) {
423
- _chunkWNTTAFLCjs.addGuard.call(void 0, key, this.guard.bind(this));
426
+ _chunk562XCEUUjs.addGuard.call(void 0, key, this.guard.bind(this));
424
427
  this.onUnmount(() => {
425
- delete _chunkWNTTAFLCjs.Context.guardRecord[key];
428
+ delete _chunk562XCEUUjs.Context.guardRecord[key];
426
429
  });
427
430
  }
428
431
  if (this.filter) {
429
- _chunkWNTTAFLCjs.addFilter.call(void 0, key, this.filter.bind(this));
432
+ _chunk562XCEUUjs.addFilter.call(void 0, key, this.filter.bind(this));
430
433
  this.onUnmount(() => {
431
- delete _chunkWNTTAFLCjs.Context.filterRecord[key];
434
+ delete _chunk562XCEUUjs.Context.filterRecord[key];
432
435
  });
433
436
  }
434
437
  }
@@ -511,4 +514,4 @@ _chunkXHKBG2VAjs.__name.call(void 0, PExtension, "PExtension");
511
514
 
512
515
 
513
516
 
514
- exports.APP_SYMBOL = _chunkXHKBG2VAjs.APP_SYMBOL; exports.Arg = Arg; exports.BadGatewayException = _chunkWNTTAFLCjs.BadGatewayException; exports.BadRequestException = _chunkWNTTAFLCjs.BadRequestException; exports.BaseParam = BaseParam; exports.Body = Body; exports.ConflictException = _chunkWNTTAFLCjs.ConflictException; exports.Context = _chunkWNTTAFLCjs.Context; exports.Controller = Controller; exports.Define = Define; exports.Delete = Delete; exports.Dev = Dev; exports.ERROR_SYMBOL = _chunkXHKBG2VAjs.ERROR_SYMBOL; exports.Event = Event; exports.Exception = _chunkWNTTAFLCjs.Exception; exports.Factory = _chunkVBYDVWRKjs.Factory; exports.Filter = Filter; exports.ForbiddenException = _chunkWNTTAFLCjs.ForbiddenException; exports.FrameworkException = _chunkWNTTAFLCjs.FrameworkException; exports.Get = Get; exports.Guard = Guard; exports.Head = Head; exports.Header = Header; exports.IS_DEV = _chunkXHKBG2VAjs.IS_DEV; exports.IS_LOG_BAN = _chunkXHKBG2VAjs.IS_LOG_BAN; exports.IS_STRICT = _chunkXHKBG2VAjs.IS_STRICT; exports.Injectable = _chunkVBYDVWRKjs.Injectable; exports.Interceptor = Interceptor; exports.InvalidInputException = _chunkWNTTAFLCjs.InvalidInputException; exports.MERGE_SYMBOL = _chunkXHKBG2VAjs.MERGE_SYMBOL; exports.META_SYMBOL = _chunkXHKBG2VAjs.META_SYMBOL; exports.MODULE_SYMBOL = _chunkXHKBG2VAjs.MODULE_SYMBOL; exports.Meta = _chunkVBYDVWRKjs.Meta; exports.Mix = _chunkXHKBG2VAjs.Mix; exports.NotFoundException = _chunkWNTTAFLCjs.NotFoundException; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PPlugin = PPlugin; exports.PS_FILE_RE = _chunkXHKBG2VAjs.PS_FILE_RE; exports.PS_IMPORT_RE = _chunkXHKBG2VAjs.PS_IMPORT_RE; exports.Param = Param; exports.Patch = Patch; exports.PayloadLargeException = _chunkWNTTAFLCjs.PayloadLargeException; exports.Pipe = Pipe; exports.Plugin = Plugin; exports.Post = Post; exports.Put = Put; exports.Query = Query; exports.Route = Route; exports.Rpc = Rpc; exports.ServiceUnavailableException = _chunkWNTTAFLCjs.ServiceUnavailableException; exports.TimeoutException = _chunkWNTTAFLCjs.TimeoutException; exports.UNMOUNT_SYMBOL = _chunkXHKBG2VAjs.UNMOUNT_SYMBOL; exports.UnauthorizedException = _chunkWNTTAFLCjs.UnauthorizedException; exports.UndefinedException = _chunkWNTTAFLCjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkWNTTAFLCjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkWNTTAFLCjs.ValidateException; exports.addFilter = _chunkWNTTAFLCjs.addFilter; exports.addGuard = _chunkWNTTAFLCjs.addGuard; exports.addInterceptor = _chunkWNTTAFLCjs.addInterceptor; exports.addPipe = _chunkWNTTAFLCjs.addPipe; exports.addPlugin = _chunkWNTTAFLCjs.addPlugin; exports.argToReq = _chunkEVF2CXTPjs.argToReq; exports.defaultPipe = _chunkWNTTAFLCjs.defaultPipe; exports.emitter = _chunkVBYDVWRKjs.emitter; exports.generateHTTPCode = _chunkVBYDVWRKjs.generateHTTPCode; exports.generateRPCCode = _chunkVBYDVWRKjs.generateRPCCode; exports.getConfig = _chunkXHKBG2VAjs.getConfig; exports.guardRecord = _chunkWNTTAFLCjs.guardRecord; exports.isAopDepInject = _chunkWNTTAFLCjs.isAopDepInject; exports.log = _chunkXHKBG2VAjs.log; exports.resolveDep = _chunkEVF2CXTPjs.resolveDep; exports.setConfig = _chunkXHKBG2VAjs.setConfig;
517
+ exports.APP_SYMBOL = _chunkXHKBG2VAjs.APP_SYMBOL; exports.Arg = Arg; exports.BadGatewayException = _chunk562XCEUUjs.BadGatewayException; exports.BadRequestException = _chunk562XCEUUjs.BadRequestException; exports.BaseParam = BaseParam; exports.Body = Body; exports.ConflictException = _chunk562XCEUUjs.ConflictException; exports.Context = _chunk562XCEUUjs.Context; exports.Controller = Controller; exports.Ctx = Ctx; exports.Define = Define; exports.Delete = Delete; exports.Dev = Dev; exports.ERROR_SYMBOL = _chunkXHKBG2VAjs.ERROR_SYMBOL; exports.Event = Event; exports.Exception = _chunk562XCEUUjs.Exception; exports.Factory = _chunkFMPVMJLEjs.Factory; exports.Filter = Filter; exports.ForbiddenException = _chunk562XCEUUjs.ForbiddenException; exports.FrameworkException = _chunk562XCEUUjs.FrameworkException; exports.Get = Get; exports.Guard = Guard; exports.Head = Head; exports.Header = Header; exports.IS_DEV = _chunkXHKBG2VAjs.IS_DEV; exports.IS_LOG_BAN = _chunkXHKBG2VAjs.IS_LOG_BAN; exports.IS_STRICT = _chunkXHKBG2VAjs.IS_STRICT; exports.Injectable = _chunkFMPVMJLEjs.Injectable; exports.Interceptor = Interceptor; exports.InvalidInputException = _chunk562XCEUUjs.InvalidInputException; exports.MERGE_SYMBOL = _chunkXHKBG2VAjs.MERGE_SYMBOL; exports.META_SYMBOL = _chunkXHKBG2VAjs.META_SYMBOL; exports.MODULE_SYMBOL = _chunkXHKBG2VAjs.MODULE_SYMBOL; exports.Meta = _chunkFMPVMJLEjs.Meta; exports.Mix = _chunkXHKBG2VAjs.Mix; exports.NotFoundException = _chunk562XCEUUjs.NotFoundException; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PPlugin = PPlugin; exports.PS_FILE_RE = _chunkXHKBG2VAjs.PS_FILE_RE; exports.PS_IMPORT_RE = _chunkXHKBG2VAjs.PS_IMPORT_RE; exports.Param = Param; exports.Patch = Patch; exports.PayloadLargeException = _chunk562XCEUUjs.PayloadLargeException; exports.Pipe = Pipe; exports.Plugin = Plugin; exports.Post = Post; exports.Put = Put; exports.Query = Query; exports.Route = Route; exports.Rpc = Rpc; exports.ServiceUnavailableException = _chunk562XCEUUjs.ServiceUnavailableException; exports.TimeoutException = _chunk562XCEUUjs.TimeoutException; exports.UNMOUNT_SYMBOL = _chunkXHKBG2VAjs.UNMOUNT_SYMBOL; exports.UnauthorizedException = _chunk562XCEUUjs.UnauthorizedException; exports.UndefinedException = _chunk562XCEUUjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunk562XCEUUjs.UnsupportedMediaTypeException; exports.ValidateException = _chunk562XCEUUjs.ValidateException; exports.addFilter = _chunk562XCEUUjs.addFilter; exports.addGuard = _chunk562XCEUUjs.addGuard; exports.addInterceptor = _chunk562XCEUUjs.addInterceptor; exports.addPipe = _chunk562XCEUUjs.addPipe; exports.addPlugin = _chunk562XCEUUjs.addPlugin; exports.argToReq = _chunkEVF2CXTPjs.argToReq; exports.defaultPipe = _chunk562XCEUUjs.defaultPipe; exports.emitter = _chunkFMPVMJLEjs.emitter; exports.generateHTTPCode = _chunkFMPVMJLEjs.generateHTTPCode; exports.generateRPCCode = _chunkFMPVMJLEjs.generateRPCCode; exports.getConfig = _chunkXHKBG2VAjs.getConfig; exports.isAopDepInject = _chunk562XCEUUjs.isAopDepInject; exports.log = _chunkXHKBG2VAjs.log; exports.resolveDep = _chunkEVF2CXTPjs.resolveDep; exports.setConfig = _chunkXHKBG2VAjs.setConfig;
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  emitter,
6
6
  generateHTTPCode,
7
7
  generateRPCCode
8
- } from "./chunk-LSMNOIFA.mjs";
8
+ } from "./chunk-TCW7B6MG.mjs";
9
9
  import {
10
10
  argToReq,
11
11
  resolveDep
@@ -33,9 +33,8 @@ import {
33
33
  addPipe,
34
34
  addPlugin,
35
35
  defaultPipe,
36
- guardRecord,
37
36
  isAopDepInject
38
- } from "./chunk-PXI5J4LR.mjs";
37
+ } from "./chunk-AL36AJMH.mjs";
39
38
  import {
40
39
  APP_SYMBOL,
41
40
  ERROR_SYMBOL,
@@ -56,7 +55,7 @@ import {
56
55
  } from "./chunk-UFSW7A6B.mjs";
57
56
 
58
57
  // src/decorators/index.ts
59
- import { SHARE_KEY as SHARE_KEY3, getOwnState as getOwnState4, setState as setState4, setStateVar as setStateVar4 } from "phecda-core";
58
+ import { SHARE_KEY as SHARE_KEY3, getOwnState as getOwnState4, set, setState as setState4, setStateVar as setStateVar4 } from "phecda-core";
60
59
 
61
60
  // src/decorators/param.ts
62
61
  import { getOwnState, setState, setStateVar } from "phecda-core";
@@ -264,6 +263,10 @@ function Header(name, value) {
264
263
  };
265
264
  }
266
265
  __name(Header, "Header");
266
+ function Ctx(target, key) {
267
+ set(target, "context", key);
268
+ }
269
+ __name(Ctx, "Ctx");
267
270
  function Define(key, value) {
268
271
  return (target, k) => {
269
272
  if (!k) {
@@ -444,6 +447,7 @@ export {
444
447
  ConflictException,
445
448
  Context,
446
449
  Controller,
450
+ Ctx,
447
451
  Define,
448
452
  Delete,
449
453
  Dev,
@@ -506,7 +510,6 @@ export {
506
510
  generateHTTPCode,
507
511
  generateRPCCode,
508
512
  getConfig,
509
- guardRecord,
510
513
  isAopDepInject,
511
514
  log,
512
515
  resolveDep,
@@ -1,5 +1,5 @@
1
1
  import { Kafka } from 'kafkajs';
2
- import { P, F as Factory, T as ToControllerMap } from '../../core-eb2a0799.js';
2
+ import { P, F as Factory, T as ToClientMap } from '../../core-895ed04d.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -17,6 +17,6 @@ interface KafkaCtx extends P.BaseContext {
17
17
  }
18
18
  declare function bind(kafka: Kafka, topic: string, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: Options): Promise<void>;
19
19
 
20
- declare function createClient<S extends Record<string, any>>(kafka: Kafka, topic: string, controllers: S): Promise<ToControllerMap<S>>;
20
+ declare function createClient<S extends Record<string, any>>(kafka: Kafka, topic: string, controllers: S): Promise<ToClientMap<S>>;
21
21
 
22
22
  export { KafkaCtx, Options, bind, createClient };
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkWNTTAFLCjs = require('../../chunk-WNTTAFLC.js');
5
+ var _chunk562XCEUUjs = require('../../chunk-562XCEUU.js');
6
6
 
7
7
 
8
8
 
@@ -23,7 +23,7 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
23
23
  fromBeginning: true
24
24
  });
25
25
  function handleMeta() {
26
- _chunkXHKBG2VAjs.IS_DEV && _chunkWNTTAFLCjs.isAopDepInject.call(void 0, meta, {
26
+ _chunkXHKBG2VAjs.IS_DEV && _chunk562XCEUUjs.isAopDepInject.call(void 0, meta, {
27
27
  guards: globalGuards,
28
28
  interceptors: globalInterceptors
29
29
  });
@@ -46,7 +46,7 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
46
46
  messages: [
47
47
  {
48
48
  value: JSON.stringify({
49
- data: new (0, _chunkWNTTAFLCjs.BadRequestException)(`service "${tag}" doesn't exist`).data,
49
+ data: new (0, _chunk562XCEUUjs.BadRequestException)(`service "${tag}" doesn't exist`).data,
50
50
  error: true,
51
51
  id
52
52
  })
@@ -57,7 +57,7 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
57
57
  return;
58
58
  }
59
59
  const meta2 = metaMap.get(tag);
60
- const context = new (0, _chunkWNTTAFLCjs.Context)({
60
+ const context = new (0, _chunk562XCEUUjs.Context)({
61
61
  type: "kafka",
62
62
  moduleMap,
63
63
  meta: meta2,
@@ -68,7 +68,7 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
68
68
  pause,
69
69
  data
70
70
  });
71
- const { data: { guards, interceptors, params, name, method, filter }, paramsType } = meta2;
71
+ const { data: { guards, interceptors, params, name, method, filter, ctx }, paramsType } = meta2;
72
72
  try {
73
73
  await context.useGuard([
74
74
  ...globalGuards,
@@ -105,7 +105,10 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
105
105
  reflect: paramsType[index]
106
106
  };
107
107
  }));
108
- const funcData = await moduleMap.get(name)[method](...handleArgs);
108
+ const instance = moduleMap.get(name);
109
+ if (ctx)
110
+ instance[ctx] = context.data;
111
+ const funcData = await instance[method](...handleArgs);
109
112
  const ret = await context.usePostInterceptor(funcData);
110
113
  if (queue) {
111
114
  producer.send({
@@ -2,7 +2,7 @@ import {
2
2
  BadRequestException,
3
3
  Context,
4
4
  isAopDepInject
5
- } from "../../chunk-PXI5J4LR.mjs";
5
+ } from "../../chunk-AL36AJMH.mjs";
6
6
  import {
7
7
  IS_DEV,
8
8
  __name
@@ -68,7 +68,7 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
68
68
  pause,
69
69
  data
70
70
  });
71
- const { data: { guards, interceptors, params, name, method, filter }, paramsType } = meta2;
71
+ const { data: { guards, interceptors, params, name, method, filter, ctx }, paramsType } = meta2;
72
72
  try {
73
73
  await context.useGuard([
74
74
  ...globalGuards,
@@ -105,7 +105,10 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
105
105
  reflect: paramsType[index]
106
106
  };
107
107
  }));
108
- const funcData = await moduleMap.get(name)[method](...handleArgs);
108
+ const instance = moduleMap.get(name);
109
+ if (ctx)
110
+ instance[ctx] = context.data;
111
+ const funcData = await instance[method](...handleArgs);
109
112
  const ret = await context.usePostInterceptor(funcData);
110
113
  if (queue) {
111
114
  producer.send({
@@ -1,5 +1,5 @@
1
1
  import amqplib from 'amqplib';
2
- import { P, F as Factory, T as ToControllerMap } from '../../core-eb2a0799.js';
2
+ import { P, F as Factory, T as ToClientMap } from '../../core-895ed04d.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -15,6 +15,6 @@ interface RabbitmqCtx extends P.BaseContext {
15
15
  }
16
16
  declare function bind(ch: amqplib.Channel, queue: string, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: Options): Promise<void>;
17
17
 
18
- declare function createClient<S extends Record<string, any>>(ch: amqplib.Channel, queue: string, controllers: S): Promise<ToControllerMap<S>>;
18
+ declare function createClient<S extends Record<string, any>>(ch: amqplib.Channel, queue: string, controllers: S): Promise<ToClientMap<S>>;
19
19
 
20
20
  export { Options, RabbitmqCtx, bind, createClient };
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkWNTTAFLCjs = require('../../chunk-WNTTAFLC.js');
5
+ var _chunk562XCEUUjs = require('../../chunk-562XCEUU.js');
6
6
 
7
7
 
8
8
 
@@ -14,7 +14,7 @@ async function bind(ch, queue, { moduleMap, meta }, opts) {
14
14
  const existQueue = /* @__PURE__ */ new Set();
15
15
  const { globalGuards = [], globalInterceptors = [] } = opts || {};
16
16
  function handleMeta() {
17
- _chunkXHKBG2VAjs.IS_DEV && _chunkWNTTAFLCjs.isAopDepInject.call(void 0, meta, {
17
+ _chunkXHKBG2VAjs.IS_DEV && _chunk562XCEUUjs.isAopDepInject.call(void 0, meta, {
18
18
  guards: globalGuards,
19
19
  interceptors: globalInterceptors
20
20
  });
@@ -35,14 +35,14 @@ async function bind(ch, queue, { moduleMap, meta }, opts) {
35
35
  await ch.assertQueue(queue2);
36
36
  if (!metaMap.has(tag)) {
37
37
  queue2 && ch.sendToQueue(queue2, Buffer.from(JSON.stringify({
38
- data: new (0, _chunkWNTTAFLCjs.BadRequestException)(`service "${tag}" doesn't exist`).data,
38
+ data: new (0, _chunk562XCEUUjs.BadRequestException)(`service "${tag}" doesn't exist`).data,
39
39
  error: true,
40
40
  id
41
41
  })));
42
42
  return;
43
43
  }
44
44
  const meta2 = metaMap.get(tag);
45
- const context = new (0, _chunkWNTTAFLCjs.Context)({
45
+ const context = new (0, _chunk562XCEUUjs.Context)({
46
46
  type: "rabbitmq",
47
47
  moduleMap,
48
48
  meta: meta2,
@@ -51,7 +51,7 @@ async function bind(ch, queue, { moduleMap, meta }, opts) {
51
51
  ch,
52
52
  msg
53
53
  });
54
- const { data: { guards, interceptors, params, name, method, filter }, paramsType } = meta2;
54
+ const { data: { guards, interceptors, params, name, method, filter, ctx }, paramsType } = meta2;
55
55
  try {
56
56
  await context.useGuard([
57
57
  ...globalGuards,
@@ -80,7 +80,10 @@ async function bind(ch, queue, { moduleMap, meta }, opts) {
80
80
  reflect: paramsType[index]
81
81
  };
82
82
  }));
83
- const funcData = await moduleMap.get(name)[method](...handleArgs);
83
+ const instance = moduleMap.get(name);
84
+ if (ctx)
85
+ instance[ctx] = context.data;
86
+ const funcData = await instance[method](...handleArgs);
84
87
  const ret = await context.usePostInterceptor(funcData);
85
88
  if (queue2)
86
89
  ch.sendToQueue(queue2, Buffer.from(JSON.stringify({
@@ -2,7 +2,7 @@ import {
2
2
  BadRequestException,
3
3
  Context,
4
4
  isAopDepInject
5
- } from "../../chunk-PXI5J4LR.mjs";
5
+ } from "../../chunk-AL36AJMH.mjs";
6
6
  import {
7
7
  IS_DEV,
8
8
  __name
@@ -51,7 +51,7 @@ async function bind(ch, queue, { moduleMap, meta }, opts) {
51
51
  ch,
52
52
  msg
53
53
  });
54
- const { data: { guards, interceptors, params, name, method, filter }, paramsType } = meta2;
54
+ const { data: { guards, interceptors, params, name, method, filter, ctx }, paramsType } = meta2;
55
55
  try {
56
56
  await context.useGuard([
57
57
  ...globalGuards,
@@ -80,7 +80,10 @@ async function bind(ch, queue, { moduleMap, meta }, opts) {
80
80
  reflect: paramsType[index]
81
81
  };
82
82
  }));
83
- const funcData = await moduleMap.get(name)[method](...handleArgs);
83
+ const instance = moduleMap.get(name);
84
+ if (ctx)
85
+ instance[ctx] = context.data;
86
+ const funcData = await instance[method](...handleArgs);
84
87
  const ret = await context.usePostInterceptor(funcData);
85
88
  if (queue2)
86
89
  ch.sendToQueue(queue2, Buffer.from(JSON.stringify({
@@ -1,5 +1,5 @@
1
1
  import Redis from 'ioredis';
2
- import { P, F as Factory, T as ToControllerMap } from '../../core-eb2a0799.js';
2
+ import { P, F as Factory, T as ToClientMap } from '../../core-895ed04d.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -16,6 +16,6 @@ interface RedisCtx extends P.BaseContext {
16
16
  }
17
17
  declare function bind(redis: Redis, channel: string, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: Options): void;
18
18
 
19
- declare function createClient<S extends Record<string, any>>(redis: Redis, queue: string, controllers: S): ToControllerMap<S>;
19
+ declare function createClient<S extends Record<string, any>>(redis: Redis, queue: string, controllers: S): ToClientMap<S>;
20
20
 
21
21
  export { Options, RedisCtx, bind, createClient };
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkWNTTAFLCjs = require('../../chunk-WNTTAFLC.js');
5
+ var _chunk562XCEUUjs = require('../../chunk-562XCEUU.js');
6
6
 
7
7
 
8
8
 
@@ -15,7 +15,7 @@ function bind(redis, channel, { moduleMap, meta }, opts) {
15
15
  const pub = new (0, _ioredis2.default)(redis.options);
16
16
  const { globalGuards = [], globalInterceptors = [] } = opts || {};
17
17
  function handleMeta() {
18
- _chunkXHKBG2VAjs.IS_DEV && _chunkWNTTAFLCjs.isAopDepInject.call(void 0, meta, {
18
+ _chunkXHKBG2VAjs.IS_DEV && _chunk562XCEUUjs.isAopDepInject.call(void 0, meta, {
19
19
  guards: globalGuards,
20
20
  interceptors: globalInterceptors
21
21
  });
@@ -34,14 +34,14 @@ function bind(redis, channel, { moduleMap, meta }, opts) {
34
34
  const { tag, args, id, queue } = data;
35
35
  if (!metaMap.has(tag)) {
36
36
  queue && pub.publish(queue, JSON.stringify({
37
- data: new (0, _chunkWNTTAFLCjs.BadRequestException)(`service "${tag}" doesn't exist`).data,
37
+ data: new (0, _chunk562XCEUUjs.BadRequestException)(`service "${tag}" doesn't exist`).data,
38
38
  error: true,
39
39
  id
40
40
  }));
41
41
  return;
42
42
  }
43
43
  const meta2 = metaMap.get(tag);
44
- const context = new (0, _chunkWNTTAFLCjs.Context)({
44
+ const context = new (0, _chunk562XCEUUjs.Context)({
45
45
  type: "redis",
46
46
  moduleMap,
47
47
  redis,
@@ -51,7 +51,7 @@ function bind(redis, channel, { moduleMap, meta }, opts) {
51
51
  tag,
52
52
  data
53
53
  });
54
- const { data: { guards, interceptors, params, name, method, filter }, paramsType } = meta2;
54
+ const { data: { guards, interceptors, params, name, method, filter, ctx }, paramsType } = meta2;
55
55
  try {
56
56
  await context.useGuard([
57
57
  ...globalGuards,
@@ -80,7 +80,10 @@ function bind(redis, channel, { moduleMap, meta }, opts) {
80
80
  reflect: paramsType[index]
81
81
  };
82
82
  }));
83
- const funcData = await moduleMap.get(name)[method](...handleArgs);
83
+ const instance = moduleMap.get(name);
84
+ if (ctx)
85
+ instance[ctx] = context.data;
86
+ const funcData = await instance[method](...handleArgs);
84
87
  const res = await context.usePostInterceptor(funcData);
85
88
  queue && pub.publish(queue, JSON.stringify({
86
89
  data: res,
@@ -2,7 +2,7 @@ import {
2
2
  BadRequestException,
3
3
  Context,
4
4
  isAopDepInject
5
- } from "../../chunk-PXI5J4LR.mjs";
5
+ } from "../../chunk-AL36AJMH.mjs";
6
6
  import {
7
7
  IS_DEV,
8
8
  __name
@@ -51,7 +51,7 @@ function bind(redis, channel, { moduleMap, meta }, opts) {
51
51
  tag,
52
52
  data
53
53
  });
54
- const { data: { guards, interceptors, params, name, method, filter }, paramsType } = meta2;
54
+ const { data: { guards, interceptors, params, name, method, filter, ctx }, paramsType } = meta2;
55
55
  try {
56
56
  await context.useGuard([
57
57
  ...globalGuards,
@@ -80,7 +80,10 @@ function bind(redis, channel, { moduleMap, meta }, opts) {
80
80
  reflect: paramsType[index]
81
81
  };
82
82
  }));
83
- const funcData = await moduleMap.get(name)[method](...handleArgs);
83
+ const instance = moduleMap.get(name);
84
+ if (ctx)
85
+ instance[ctx] = context.data;
86
+ const funcData = await instance[method](...handleArgs);
84
87
  const res = await context.usePostInterceptor(funcData);
85
88
  queue && pub.publish(queue, JSON.stringify({
86
89
  data: res,
@@ -1,5 +1,5 @@
1
1
  import { Request, Response, Router } from 'express';
2
- import { P, F as Factory } from '../../core-eb2a0799.js';
2
+ import { P, F as Factory } from '../../core-895ed04d.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -6,7 +6,7 @@ var _chunkEVF2CXTPjs = require('../../chunk-EVF2CXTP.js');
6
6
 
7
7
 
8
8
 
9
- var _chunkWNTTAFLCjs = require('../../chunk-WNTTAFLC.js');
9
+ var _chunk562XCEUUjs = require('../../chunk-562XCEUU.js');
10
10
 
11
11
 
12
12
 
@@ -25,7 +25,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
25
25
  plugins: [],
26
26
  ...options
27
27
  };
28
- _chunkXHKBG2VAjs.IS_DEV && _chunkWNTTAFLCjs.isAopDepInject.call(void 0, meta, {
28
+ _chunkXHKBG2VAjs.IS_DEV && _chunk562XCEUUjs.isAopDepInject.call(void 0, meta, {
29
29
  plugins,
30
30
  guards: globalGuards,
31
31
  interceptors: globalInterceptors
@@ -52,24 +52,24 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
52
52
  req[_chunkXHKBG2VAjs.MODULE_SYMBOL] = moduleMap;
53
53
  req[_chunkXHKBG2VAjs.META_SYMBOL] = meta;
54
54
  next();
55
- }, ..._chunkWNTTAFLCjs.Context.usePlugin(plugins), async (req, res, next) => {
55
+ }, ..._chunk562XCEUUjs.Context.usePlugin(plugins), async (req, res, next) => {
56
56
  const { body } = req;
57
57
  async function errorHandler(e) {
58
- const error = await _chunkWNTTAFLCjs.Context.filterRecord.default(e);
58
+ const error = await _chunk562XCEUUjs.Context.filterRecord.default(e);
59
59
  return res.status(error.status).json(error);
60
60
  }
61
61
  _chunkXHKBG2VAjs.__name.call(void 0, errorHandler, "errorHandler");
62
62
  if (!Array.isArray(body))
63
- return errorHandler(new (0, _chunkWNTTAFLCjs.BadRequestException)("data format should be an array"));
63
+ return errorHandler(new (0, _chunk562XCEUUjs.BadRequestException)("data format should be an array"));
64
64
  try {
65
65
  return Promise.all(body.map((item, i) => {
66
66
  return new Promise(async (resolve) => {
67
67
  const { tag } = item;
68
68
  const meta2 = metaMap.get(tag);
69
69
  if (!meta2)
70
- return resolve(await _chunkWNTTAFLCjs.Context.filterRecord.default(new (0, _chunkWNTTAFLCjs.BadRequestException)(`"${tag}" doesn't exist`)));
70
+ return resolve(await _chunk562XCEUUjs.Context.filterRecord.default(new (0, _chunk562XCEUUjs.BadRequestException)(`"${tag}" doesn't exist`)));
71
71
  const [name, method] = tag.split("-");
72
- const { paramsType, data: { params, guards, interceptors, filter } } = meta2;
72
+ const { paramsType, data: { ctx, params, guards, interceptors, filter } } = meta2;
73
73
  const instance = moduleMap.get(name);
74
74
  const contextData = {
75
75
  type: "express",
@@ -80,9 +80,10 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
80
80
  moduleMap,
81
81
  tag,
82
82
  next,
83
+ data: req.data,
83
84
  ..._chunkEVF2CXTPjs.argToReq.call(void 0, params, item.args, req.headers)
84
85
  };
85
- const context = new (0, _chunkWNTTAFLCjs.Context)(contextData);
86
+ const context = new (0, _chunk562XCEUUjs.Context)(contextData);
86
87
  try {
87
88
  await context.useGuard([
88
89
  ...globalGuards,
@@ -105,7 +106,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
105
106
  reflect: paramsType[index]
106
107
  };
107
108
  }));
108
- instance.context = contextData;
109
+ if (ctx)
110
+ instance[ctx] = contextData;
109
111
  const funcData = await moduleMap.get(name)[method](...args);
110
112
  resolve(await context.usePostInterceptor(funcData));
111
113
  } catch (e) {
@@ -124,12 +126,12 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
124
126
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
125
127
  continue;
126
128
  const methodTag = `${tag}-${method}`;
127
- const { paramsType, data: { interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
129
+ const { paramsType, data: { ctx, interceptors, guards, params, plugins: plugins2, filter } } = metaMap.get(methodTag);
128
130
  app[http.type](http.route, (req, _res, next) => {
129
131
  req[_chunkXHKBG2VAjs.MODULE_SYMBOL] = moduleMap;
130
132
  req[_chunkXHKBG2VAjs.META_SYMBOL] = meta;
131
133
  next();
132
- }, ..._chunkWNTTAFLCjs.Context.usePlugin(plugins2), async (req, res, next) => {
134
+ }, ..._chunk562XCEUUjs.Context.usePlugin(plugins2), async (req, res, next) => {
133
135
  const instance = moduleMap.get(tag);
134
136
  const contextData = {
135
137
  type: "express",
@@ -143,9 +145,10 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
143
145
  body: req.body,
144
146
  params: req.params,
145
147
  headers: req.headers,
148
+ data: req.data,
146
149
  next
147
150
  };
148
- const context = new (0, _chunkWNTTAFLCjs.Context)(contextData);
151
+ const context = new (0, _chunk562XCEUUjs.Context)(contextData);
149
152
  try {
150
153
  for (const name in header)
151
154
  res.set(name, header[name]);
@@ -175,7 +178,8 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
175
178
  reflect: paramsType[index]
176
179
  };
177
180
  }));
178
- instance.context = contextData;
181
+ if (ctx)
182
+ instance[ctx] = contextData;
179
183
  const funcData = await instance[method](...args);
180
184
  const ret = await context.usePostInterceptor(funcData);
181
185
  if (res.writableEnded)
@@ -198,7 +202,7 @@ function bindApp(app, { moduleMap, meta }, options = {}) {
198
202
  createRoute();
199
203
  if (_chunkXHKBG2VAjs.IS_DEV) {
200
204
  _optionalChain([globalThis, 'access', _3 => _3.__PS_HMR__, 'optionalAccess', _4 => _4.push, 'call', _5 => _5(async () => {
201
- _chunkWNTTAFLCjs.isAopDepInject.call(void 0, meta, {
205
+ _chunk562XCEUUjs.isAopDepInject.call(void 0, meta, {
202
206
  plugins,
203
207
  guards: globalGuards,
204
208
  interceptors: globalInterceptors