phecda-server 7.0.0-alpha.11 → 7.0.0-alpha.13

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 (86) hide show
  1. package/assets/schema.json +11 -2
  2. package/bin/cli.mjs +62 -9
  3. package/dist/{chunk-G7JFKM2M.js → chunk-IJFIY6QN.js} +1 -9
  4. package/dist/{chunk-Z7NAAE4M.mjs → chunk-VX4BZEL7.mjs} +0 -8
  5. package/dist/{core-CUTbX_IS.d.ts → core-CDzIy2g0.d.ts} +1 -1
  6. package/dist/{core-DIfgUKIU.d.mts → core-jUg1HvYT.d.mts} +1 -1
  7. package/dist/helper.d.mts +2 -4
  8. package/dist/helper.d.ts +2 -4
  9. package/dist/helper.js +2 -4
  10. package/dist/helper.mjs +1 -3
  11. package/dist/http/elysia/index.d.mts +3 -3
  12. package/dist/http/elysia/index.d.ts +3 -3
  13. package/dist/http/elysia/index.js +18 -17
  14. package/dist/http/elysia/index.mjs +2 -1
  15. package/dist/http/express/index.d.mts +3 -3
  16. package/dist/http/express/index.d.ts +3 -3
  17. package/dist/http/express/index.js +17 -16
  18. package/dist/http/express/index.mjs +2 -1
  19. package/dist/http/fastify/index.d.mts +3 -3
  20. package/dist/http/fastify/index.d.ts +3 -3
  21. package/dist/http/fastify/index.js +17 -16
  22. package/dist/http/fastify/index.mjs +2 -1
  23. package/dist/http/h3/index.d.mts +3 -3
  24. package/dist/http/h3/index.d.ts +3 -3
  25. package/dist/http/h3/index.js +18 -17
  26. package/dist/http/h3/index.mjs +2 -1
  27. package/dist/http/hono/index.d.mts +3 -3
  28. package/dist/http/hono/index.d.ts +3 -3
  29. package/dist/http/hono/index.js +15 -14
  30. package/dist/http/hono/index.mjs +2 -1
  31. package/dist/http/hyper-express/index.d.mts +3 -3
  32. package/dist/http/hyper-express/index.d.ts +3 -3
  33. package/dist/http/hyper-express/index.js +16 -15
  34. package/dist/http/hyper-express/index.mjs +2 -1
  35. package/dist/http/koa/index.d.mts +3 -3
  36. package/dist/http/koa/index.d.ts +3 -3
  37. package/dist/http/koa/index.js +17 -16
  38. package/dist/http/koa/index.mjs +2 -1
  39. package/dist/index.d.mts +8 -8
  40. package/dist/index.d.ts +8 -8
  41. package/dist/index.js +19 -19
  42. package/dist/index.mjs +1 -1
  43. package/dist/{meta-CR-D39hQ.d.mts → meta-xvg6V7pH.d.mts} +2 -19
  44. package/dist/{meta-CR-D39hQ.d.ts → meta-xvg6V7pH.d.ts} +2 -19
  45. package/dist/rpc/bullmq/index.d.mts +4 -6
  46. package/dist/rpc/bullmq/index.d.ts +4 -6
  47. package/dist/rpc/bullmq/index.js +7 -75
  48. package/dist/rpc/bullmq/index.mjs +3 -71
  49. package/dist/rpc/electron/index.d.mts +13 -0
  50. package/dist/rpc/electron/index.d.ts +13 -0
  51. package/dist/rpc/electron/index.js +72 -0
  52. package/dist/rpc/electron/index.mjs +72 -0
  53. package/dist/rpc/kafka/index.d.mts +4 -9
  54. package/dist/rpc/kafka/index.d.ts +4 -9
  55. package/dist/rpc/kafka/index.js +7 -86
  56. package/dist/rpc/kafka/index.mjs +3 -82
  57. package/dist/rpc/nats/index.d.mts +4 -6
  58. package/dist/rpc/nats/index.d.ts +4 -6
  59. package/dist/rpc/nats/index.js +7 -67
  60. package/dist/rpc/nats/index.mjs +2 -62
  61. package/dist/rpc/rabbitmq/index.d.mts +4 -6
  62. package/dist/rpc/rabbitmq/index.d.ts +4 -6
  63. package/dist/rpc/rabbitmq/index.js +7 -73
  64. package/dist/rpc/rabbitmq/index.mjs +3 -69
  65. package/dist/rpc/redis/index.d.mts +4 -9
  66. package/dist/rpc/redis/index.d.ts +4 -9
  67. package/dist/rpc/redis/index.js +7 -74
  68. package/dist/rpc/redis/index.mjs +3 -70
  69. package/dist/rpc/ws/index.d.mts +14 -0
  70. package/dist/rpc/ws/index.d.ts +14 -0
  71. package/dist/rpc/ws/index.js +73 -0
  72. package/dist/rpc/ws/index.mjs +73 -0
  73. package/dist/test.d.mts +7 -3
  74. package/dist/test.d.ts +7 -3
  75. package/dist/types-6qaaUIKZ.d.mts +14 -0
  76. package/dist/{types-BF1TDbFV.d.ts → types-B-1OL-3P.d.ts} +1 -1
  77. package/dist/types-BtXOT5rI.d.ts +14 -0
  78. package/dist/{types-DYviSl5B.d.mts → types-Ctd6pLNE.d.mts} +1 -1
  79. package/package.json +13 -2
  80. package/register/index.mjs +0 -1
  81. package/register/loader.mjs +12 -52
  82. package/register/utils.mjs +7 -7
  83. package/assets/ps.json +0 -24
  84. package/assets/tsconfig.json +0 -21
  85. package/dist/types-DYRu0vic.d.ts +0 -19
  86. package/dist/types-DqH1qA-q.d.mts +0 -19
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkG7JFKM2Mjs = require('../../chunk-G7JFKM2M.js');
7
+ var _chunkIJFIY6QNjs = require('../../chunk-IJFIY6QN.js');
8
8
 
9
9
 
10
10
 
@@ -18,14 +18,14 @@ function bind(router, data, opts = {}) {
18
18
  const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
19
19
  const { moduleMap, meta } = data;
20
20
  const originStack = router.stack.slice(0, router.stack.length);
21
- const metaMap = _chunkG7JFKM2Mjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
21
+ const metaMap = _chunkIJFIY6QNjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
22
  const { controller, http, func, tag } = meta2.data;
23
23
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
24
24
  debug(`register method "${func}" in module "${tag}"`);
25
25
  return true;
26
26
  }
27
27
  });
28
- _chunkG7JFKM2Mjs.detectAopDep.call(void 0, meta, {
28
+ _chunkIJFIY6QNjs.detectAopDep.call(void 0, meta, {
29
29
  addons: [
30
30
  ...globalAddons,
31
31
  ...parallelAddons
@@ -34,28 +34,29 @@ function bind(router, data, opts = {}) {
34
34
  });
35
35
  registerRoute();
36
36
  function registerRoute() {
37
- _chunkG7JFKM2Mjs.Context.applyAddons(globalAddons, router, "koa");
37
+ _chunkIJFIY6QNjs.Context.applyAddons(globalAddons, router, "koa");
38
38
  if (parallelRoute) {
39
39
  const subRouter = new (0, _router2.default)();
40
- _chunkG7JFKM2Mjs.Context.applyAddons(parallelAddons, subRouter, "koa");
40
+ _chunkIJFIY6QNjs.Context.applyAddons(parallelAddons, subRouter, "koa");
41
41
  subRouter.post(parallelRoute, async (ctx, next) => {
42
42
  const { body } = ctx.request;
43
43
  async function errorHandler(e) {
44
- const error = await _chunkG7JFKM2Mjs.Context.filterRecord.default(e);
44
+ const error = await _chunkIJFIY6QNjs.Context.filterRecord.default(e);
45
45
  ctx.status = error.status;
46
46
  ctx.body = error;
47
47
  }
48
48
  _chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
49
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkG7JFKM2Mjs.BadRequestException)("data format should be an array"));
49
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkIJFIY6QNjs.BadRequestException)("data format should be an array"));
50
50
  try {
51
51
  return Promise.all(body.map((item, i) => {
52
52
  return new Promise(async (resolve) => {
53
+ if (!item) return resolve(null);
53
54
  const { tag, func } = item;
54
55
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
55
- if (!metaMap.has(tag)) return resolve(await _chunkG7JFKM2Mjs.Context.filterRecord.default(new (0, _chunkG7JFKM2Mjs.BadRequestException)(`module "${tag}" doesn't exist`)));
56
+ if (!metaMap.has(tag)) return resolve(await _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`module "${tag}" doesn't exist`)));
56
57
  const meta2 = metaMap.get(tag)[func];
57
- if (!meta2) return resolve(await _chunkG7JFKM2Mjs.Context.filterRecord.default(new (0, _chunkG7JFKM2Mjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
58
- const aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
58
+ if (!meta2) return resolve(await _chunkIJFIY6QNjs.Context.filterRecord.default(new (0, _chunkIJFIY6QNjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
59
+ const aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
59
60
  globalGuards,
60
61
  globalFilter,
61
62
  globalPipe
@@ -82,7 +83,7 @@ function bind(router, data, opts = {}) {
82
83
  getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => ctx.req, "getRequest"),
83
84
  getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => ctx.res, "getResponse")
84
85
  };
85
- const context = new (0, _chunkG7JFKM2Mjs.Context)(contextData);
86
+ const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
86
87
  context.run(aop, resolve, resolve);
87
88
  });
88
89
  })).then((ret) => {
@@ -101,15 +102,15 @@ function bind(router, data, opts = {}) {
101
102
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
102
103
  let aop;
103
104
  if (!dynamic) {
104
- aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
105
+ aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
105
106
  globalFilter,
106
107
  globalGuards,
107
108
  globalPipe
108
109
  });
109
110
  }
110
111
  const subRouter = new (0, _router2.default)();
111
- _chunkG7JFKM2Mjs.Context.applyAddons(addons, subRouter, "koa");
112
- router[http.type](_chunkG7JFKM2Mjs.joinUrl.call(void 0, http.prefix, http.route), async (ctx, next) => {
112
+ _chunkIJFIY6QNjs.Context.applyAddons(addons, subRouter, "koa");
113
+ router[http.type](_chunkIJFIY6QNjs.joinUrl.call(void 0, http.prefix, http.route), async (ctx, next) => {
113
114
  debug(`invoke method "${func}" in module "${tag}"`);
114
115
  const contextData = {
115
116
  type: "koa",
@@ -136,10 +137,10 @@ function bind(router, data, opts = {}) {
136
137
  getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => ctx.req, "getRequest"),
137
138
  getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => ctx.res, "getResponse")
138
139
  };
139
- const context = new (0, _chunkG7JFKM2Mjs.Context)(contextData);
140
+ const context = new (0, _chunkIJFIY6QNjs.Context)(contextData);
140
141
  if (http.headers) ctx.set(http.headers);
141
142
  if (dynamic) {
142
- aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
143
+ aop = _chunkIJFIY6QNjs.Context.getAop(meta2, {
143
144
  globalFilter,
144
145
  globalGuards,
145
146
  globalPipe
@@ -4,7 +4,7 @@ import {
4
4
  createControllerMetaMap,
5
5
  detectAopDep,
6
6
  joinUrl
7
- } from "../../chunk-Z7NAAE4M.mjs";
7
+ } from "../../chunk-VX4BZEL7.mjs";
8
8
  import {
9
9
  HMR,
10
10
  __name
@@ -50,6 +50,7 @@ function bind(router, data, opts = {}) {
50
50
  try {
51
51
  return Promise.all(body.map((item, i) => {
52
52
  return new Promise(async (resolve) => {
53
+ if (!item) return resolve(null);
53
54
  const { tag, func } = item;
54
55
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
55
56
  if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
package/dist/index.d.mts CHANGED
@@ -1,13 +1,13 @@
1
- import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-CR-D39hQ.mjs';
2
- export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_DEV, k as IS_ONLY_GENERATE, m as IS_PURE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, n as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-CR-D39hQ.mjs';
3
- import { G as Generator } from './core-DIfgUKIU.mjs';
4
- export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-DIfgUKIU.mjs';
1
+ import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-xvg6V7pH.mjs';
2
+ export { d as BaseRequestType, e as CustomResponse, g as ERROR_SYMBOL, f as ExtractResponse, I as IS_DEV, h as IS_ONLY_GENERATE, j as IS_PURE, i as IS_STRICT, L as LOG_LEVEL, M as Meta, P as PS_EXIT_CODE, S as ServiceMetaData } from './meta-xvg6V7pH.mjs';
3
+ import { G as Generator } from './core-jUg1HvYT.mjs';
4
+ export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-jUg1HvYT.mjs';
5
5
  import { Base } from 'phecda-core';
6
6
  export * from 'phecda-core';
7
- import { H as HttpCtx } from './types-DYviSl5B.mjs';
8
- export { C as CookieSerializeOptions, a as HttpOptions } from './types-DYviSl5B.mjs';
9
- import { R as RpcCtx } from './types-DqH1qA-q.mjs';
10
- export { b as RpcClientOptions, a as RpcServerOptions } from './types-DqH1qA-q.mjs';
7
+ import { H as HttpCtx } from './types-Ctd6pLNE.mjs';
8
+ export { C as CookieSerializeOptions, a as HttpOptions } from './types-Ctd6pLNE.mjs';
9
+ import { R as RpcCtx } from './types-6qaaUIKZ.mjs';
10
+ export { a as RpcServerOptions } from './types-6qaaUIKZ.mjs';
11
11
  export { Mixin } from 'ts-mixer';
12
12
  import 'node:http';
13
13
 
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-CR-D39hQ.js';
2
- export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_DEV, k as IS_ONLY_GENERATE, m as IS_PURE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, n as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-CR-D39hQ.js';
3
- import { G as Generator } from './core-CUTbX_IS.js';
4
- export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-CUTbX_IS.js';
1
+ import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-xvg6V7pH.js';
2
+ export { d as BaseRequestType, e as CustomResponse, g as ERROR_SYMBOL, f as ExtractResponse, I as IS_DEV, h as IS_ONLY_GENERATE, j as IS_PURE, i as IS_STRICT, L as LOG_LEVEL, M as Meta, P as PS_EXIT_CODE, S as ServiceMetaData } from './meta-xvg6V7pH.js';
3
+ import { G as Generator } from './core-CDzIy2g0.js';
4
+ export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-CDzIy2g0.js';
5
5
  import { Base } from 'phecda-core';
6
6
  export * from 'phecda-core';
7
- import { H as HttpCtx } from './types-BF1TDbFV.js';
8
- export { C as CookieSerializeOptions, a as HttpOptions } from './types-BF1TDbFV.js';
9
- import { R as RpcCtx } from './types-DYRu0vic.js';
10
- export { b as RpcClientOptions, a as RpcServerOptions } from './types-DYRu0vic.js';
7
+ import { H as HttpCtx } from './types-B-1OL-3P.js';
8
+ export { C as CookieSerializeOptions, a as HttpOptions } from './types-B-1OL-3P.js';
9
+ import { R as RpcCtx } from './types-BtXOT5rI.js';
10
+ export { a as RpcServerOptions } from './types-BtXOT5rI.js';
11
11
  export { Mixin } from 'ts-mixer';
12
12
  import 'node:http';
13
13
 
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
  };
@@ -0,0 +1,13 @@
1
+ import Electron from 'electron';
2
+ import { F as Factory } from '../../core-jUg1HvYT.mjs';
3
+ import { R as RpcCtx, a as RpcServerOptions } from '../../types-6qaaUIKZ.mjs';
4
+ import 'phecda-core';
5
+ import '../../meta-xvg6V7pH.mjs';
6
+
7
+ interface ElectronCtx extends RpcCtx {
8
+ type: 'electron';
9
+ event: Electron.IpcMainEvent | Electron.IpcMainInvokeEvent;
10
+ }
11
+ declare function bind(IPC: Electron.IpcMain, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: RpcServerOptions): void;
12
+
13
+ export { type ElectronCtx, bind };