phecda-server 7.0.0-alpha.9 → 7.0.1

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 (99) hide show
  1. package/assets/schema.json +12 -9
  2. package/bin/cli.mjs +95 -36
  3. package/dist/{chunk-5RBTN33A.js → chunk-4LLLQOMF.js} +10 -5
  4. package/dist/{chunk-7ZGYJ5OW.mjs → chunk-AIAO6SV6.mjs} +10 -34
  5. package/dist/{chunk-V5EYXVJT.js → chunk-DPPDWBYO.js} +53 -25
  6. package/dist/{chunk-CVPZWDXU.mjs → chunk-E7EAPAGM.mjs} +10 -20
  7. package/dist/{chunk-ODVWOXVB.mjs → chunk-MKRHYZCL.mjs} +30 -2
  8. package/dist/{chunk-FXTJ3BJ6.mjs → chunk-NQ55PA2X.mjs} +9 -4
  9. package/dist/{chunk-FX3LDQII.js → chunk-XKK2SQ7W.js} +60 -70
  10. package/dist/{chunk-KJUD2BKE.js → chunk-ZWPOWMZP.js} +25 -49
  11. package/dist/{core-D_cz0tKa.d.ts → core-DbqWh47p.d.mts} +3 -2
  12. package/dist/{core-BDkhrEyf.d.mts → core-Rq7BhPHE.d.ts} +3 -2
  13. package/dist/helper.d.mts +3 -5
  14. package/dist/helper.d.ts +3 -5
  15. package/dist/helper.js +3 -5
  16. package/dist/helper.mjs +2 -4
  17. package/dist/http/elysia/index.d.mts +4 -4
  18. package/dist/http/elysia/index.d.ts +4 -4
  19. package/dist/http/elysia/index.js +41 -40
  20. package/dist/http/elysia/index.mjs +4 -3
  21. package/dist/http/express/index.d.mts +3 -3
  22. package/dist/http/express/index.d.ts +3 -3
  23. package/dist/http/express/index.js +38 -37
  24. package/dist/http/express/index.mjs +3 -2
  25. package/dist/http/fastify/index.d.mts +3 -3
  26. package/dist/http/fastify/index.d.ts +3 -3
  27. package/dist/http/fastify/index.js +39 -38
  28. package/dist/http/fastify/index.mjs +4 -3
  29. package/dist/http/h3/index.d.mts +3 -3
  30. package/dist/http/h3/index.d.ts +3 -3
  31. package/dist/http/h3/index.js +39 -38
  32. package/dist/http/h3/index.mjs +3 -2
  33. package/dist/http/hono/index.d.mts +3 -3
  34. package/dist/http/hono/index.d.ts +3 -3
  35. package/dist/http/hono/index.js +35 -34
  36. package/dist/http/hono/index.mjs +3 -2
  37. package/dist/http/hyper-express/index.d.mts +3 -3
  38. package/dist/http/hyper-express/index.d.ts +3 -3
  39. package/dist/http/hyper-express/index.js +36 -35
  40. package/dist/http/hyper-express/index.mjs +3 -2
  41. package/dist/http/koa/index.d.mts +3 -3
  42. package/dist/http/koa/index.d.ts +3 -3
  43. package/dist/http/koa/index.js +38 -37
  44. package/dist/http/koa/index.mjs +3 -2
  45. package/dist/index.d.mts +76 -12
  46. package/dist/index.d.ts +76 -12
  47. package/dist/index.js +102 -49
  48. package/dist/index.mjs +66 -13
  49. package/dist/{meta-BX5jhe4Z.d.mts → meta-BoS1E-Nz.d.mts} +6 -23
  50. package/dist/{meta-BX5jhe4Z.d.ts → meta-BoS1E-Nz.d.ts} +6 -23
  51. package/dist/rpc/bullmq/index.d.mts +4 -6
  52. package/dist/rpc/bullmq/index.d.ts +4 -6
  53. package/dist/rpc/bullmq/index.js +12 -80
  54. package/dist/rpc/bullmq/index.mjs +4 -72
  55. package/dist/rpc/electron/index.d.mts +13 -0
  56. package/dist/rpc/electron/index.d.ts +13 -0
  57. package/dist/rpc/electron/index.js +72 -0
  58. package/dist/rpc/electron/index.mjs +72 -0
  59. package/dist/rpc/kafka/index.d.mts +4 -9
  60. package/dist/rpc/kafka/index.d.ts +4 -9
  61. package/dist/rpc/kafka/index.js +11 -90
  62. package/dist/rpc/kafka/index.mjs +4 -83
  63. package/dist/rpc/nats/index.d.mts +4 -6
  64. package/dist/rpc/nats/index.d.ts +4 -6
  65. package/dist/rpc/nats/index.js +12 -72
  66. package/dist/rpc/nats/index.mjs +3 -63
  67. package/dist/rpc/rabbitmq/index.d.mts +4 -6
  68. package/dist/rpc/rabbitmq/index.d.ts +4 -6
  69. package/dist/rpc/rabbitmq/index.js +13 -79
  70. package/dist/rpc/rabbitmq/index.mjs +4 -70
  71. package/dist/rpc/redis/index.d.mts +4 -9
  72. package/dist/rpc/redis/index.d.ts +4 -9
  73. package/dist/rpc/redis/index.js +11 -78
  74. package/dist/rpc/redis/index.mjs +4 -71
  75. package/dist/rpc/web-ext/index.d.mts +2 -0
  76. package/dist/rpc/web-ext/index.d.ts +2 -0
  77. package/dist/rpc/web-ext/index.js +1 -0
  78. package/dist/rpc/web-ext/index.mjs +0 -0
  79. package/dist/rpc/ws/index.d.mts +14 -0
  80. package/dist/rpc/ws/index.d.ts +14 -0
  81. package/dist/rpc/ws/index.js +73 -0
  82. package/dist/rpc/ws/index.mjs +73 -0
  83. package/dist/test.d.mts +7 -3
  84. package/dist/test.d.ts +7 -3
  85. package/dist/test.js +6 -6
  86. package/dist/test.mjs +2 -2
  87. package/dist/types-CInz3bD0.d.ts +14 -0
  88. package/dist/types-E-rqlg3-.d.mts +14 -0
  89. package/dist/{types-DKVhyZk_.d.mts → types-SCJZFCYt.d.mts} +1 -1
  90. package/dist/{types-CMeuFoyd.d.ts → types-xruyYmyu.d.ts} +1 -1
  91. package/package.json +24 -8
  92. package/register/export.mjs +30 -0
  93. package/register/index.mjs +2 -3
  94. package/register/loader.mjs +83 -90
  95. package/register/utils.mjs +36 -6
  96. package/assets/ps.json +0 -24
  97. package/assets/tsconfig.json +0 -21
  98. package/dist/types-B-rUM9Fm.d.mts +0 -19
  99. package/dist/types-MxxtkZXw.d.ts +0 -19
@@ -3,12 +3,13 @@
3
3
 
4
4
 
5
5
 
6
- var _chunk5RBTN33Ajs = require('./chunk-5RBTN33A.js');
6
+
7
+ var _chunk4LLLQOMFjs = require('./chunk-4LLLQOMF.js');
7
8
 
8
9
  // src/meta.ts
9
10
  var Meta = class {
10
11
  static {
11
- _chunk5RBTN33Ajs.__name.call(void 0, this, "Meta");
12
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "Meta");
12
13
  }
13
14
 
14
15
 
@@ -37,11 +38,11 @@ function defaultServerInject() {
37
38
  });
38
39
  }
39
40
  }
40
- _chunk5RBTN33Ajs.__name.call(void 0, defaultServerInject, "defaultServerInject");
41
+ _chunk4LLLQOMFjs.__name.call(void 0, defaultServerInject, "defaultServerInject");
41
42
  var phecdaNamespace = /* @__PURE__ */ new Map();
42
43
  var ServerPhecda = (_class = class {
43
44
  static {
44
- _chunk5RBTN33Ajs.__name.call(void 0, this, "ServerPhecda");
45
+ _chunk4LLLQOMFjs.__name.call(void 0, this, "ServerPhecda");
45
46
  }
46
47
  __init() {this.moduleMap = /* @__PURE__ */ new Map()}
47
48
  __init2() {this.meta = []}
@@ -53,7 +54,7 @@ var ServerPhecda = (_class = class {
53
54
 
54
55
  constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);
55
56
  defaultServerInject();
56
- const { namespace = "default", parseModule = /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
57
+ const { namespace = "default", parseModule = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
57
58
  phecdaNamespace.set(namespace, this);
58
59
  this.parseMeta = parseMeta;
59
60
  this.parseModule = parseModule;
@@ -63,53 +64,25 @@ var ServerPhecda = (_class = class {
63
64
  for (const model of models) await this.buildDepModule(model);
64
65
  this.hmr();
65
66
  this.generateCode().then(() => {
66
- if (_chunk5RBTN33Ajs.IS_ONLY_GENERATE) process.exit(4);
67
+ if (_chunk4LLLQOMFjs.IS_ONLY_GENERATE) {
68
+ _chunk4LLLQOMFjs.log.call(void 0, "Only generate code");
69
+ process.exit(_chunk4LLLQOMFjs.PS_EXIT_CODE.EXIT);
70
+ }
67
71
  });
68
72
  }
69
- __init6() {this.generateCode = /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, async () => {
73
+ __init6() {this.generateCode = /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, async () => {
70
74
  return Promise.all(this.generators.map((generator) => {
71
75
  debug(`generate "${generator.name}" code to ${generator.path}`);
72
76
  return generator.output(this.meta);
73
77
  }));
74
78
  }, "generateCode")}
75
79
  hmr() {
76
- _chunk5RBTN33Ajs.HMR.call(void 0, async (oldModels, newModels) => {
80
+ _chunk4LLLQOMFjs.HMR.call(void 0, async (oldModels, newModels) => {
77
81
  debug("reload models ");
78
82
  await this.replace(oldModels, newModels);
79
83
  this.generateCode();
80
84
  });
81
85
  }
82
- // async add(Model: Construct) {
83
- // const tag = getTag(Model)
84
- // const oldInstance = await this.del(tag)
85
- // const { module: newModule } = await this.buildDepModule(Model)
86
- // if (oldInstance && this.dependenceGraph.has(tag)) {
87
- // debug(`replace module "${String(tag)}"`);
88
- // [...this.dependenceGraph.get(tag)!].forEach((tag) => {
89
- // const module = this.moduleMap.get(tag)
90
- // for (const key in module) {
91
- // if (module[key] === oldInstance)
92
- // module[key] = newModule
93
- // }
94
- // })
95
- // }
96
- // }
97
- // async del(modelOrTag: Construct | PropertyKey) {
98
- // const tag = typeof modelOrTag === 'function' ? getTag(modelOrTag) : modelOrTag
99
- // if (!this.moduleMap.has(tag))
100
- // return
101
- // const module = this.moduleMap.get(tag)
102
- // debug(`unmount module "${String(tag)}"`)
103
- // await invokeUnmount(module)
104
- // debug(`del module "${String(tag)}"`)
105
- // this.moduleMap.delete(tag)
106
- // this.modelMap.delete(module)
107
- // for (let i = this.meta.length - 1; i >= 0; i--) {
108
- // if (this.meta[i].data.tag === tag)
109
- // this.meta.splice(i, 1)
110
- // }
111
- // return module
112
- // }
113
86
  async destroy() {
114
87
  debug("destroy all");
115
88
  this.replace(Object.values(this.modelMap), []);
@@ -146,7 +119,7 @@ var ServerPhecda = (_class = class {
146
119
  if (this.moduleMap.has(tag)) {
147
120
  module = this.moduleMap.get(tag);
148
121
  if (!module) {
149
- _chunk5RBTN33Ajs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
122
+ _chunk4LLLQOMFjs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
150
123
  return {
151
124
  module: this.createProxyModule(tag),
152
125
  tag
@@ -154,8 +127,8 @@ var ServerPhecda = (_class = class {
154
127
  }
155
128
  if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {
156
129
  this.modelSet.add(Model);
157
- if (module instanceof Model) _chunk5RBTN33Ajs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
158
- else _chunk5RBTN33Ajs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
130
+ if (module instanceof Model) _chunk4LLLQOMFjs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
131
+ else _chunk4LLLQOMFjs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
159
132
  }
160
133
  return {
161
134
  module,
@@ -178,7 +151,7 @@ var ServerPhecda = (_class = class {
178
151
  }
179
152
  this.meta.push(...getMetaFromInstance(module, tag, Model.name).map(this.parseMeta).filter((item) => !!item));
180
153
  debug(`init module "${String(tag)}"`);
181
- if (!_chunk5RBTN33Ajs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
154
+ if (!_chunk4LLLQOMFjs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
182
155
  debug(`add module "${String(tag)}"`);
183
156
  this.moduleMap.set(tag, module);
184
157
  this.modelMap.set(module, Model);
@@ -231,13 +204,16 @@ var ServerPhecda = (_class = class {
231
204
  if (!this.has(tag)) throw new Error(`module "${tag.toString()}" doesn't exist`);
232
205
  return this.moduleMap.get(tag);
233
206
  }
207
+ getModel(tag) {
208
+ return this.modelMap.get(this.get(tag));
209
+ }
234
210
  }, _class);
235
211
  async function Factory(models, opts = {}) {
236
212
  const phecda = new ServerPhecda(opts);
237
213
  await phecda.start(models);
238
214
  return phecda;
239
215
  }
240
- _chunk5RBTN33Ajs.__name.call(void 0, Factory, "Factory");
216
+ _chunk4LLLQOMFjs.__name.call(void 0, Factory, "Factory");
241
217
  function useS(nsOrModel, namespace) {
242
218
  if (!nsOrModel) {
243
219
  namespace = "default";
@@ -250,7 +226,7 @@ function useS(nsOrModel, namespace) {
250
226
  if (nsOrModel && typeof nsOrModel !== "string") return serverPhecda.get(nsOrModel);
251
227
  else return serverPhecda;
252
228
  }
253
- _chunk5RBTN33Ajs.__name.call(void 0, useS, "useS");
229
+ _chunk4LLLQOMFjs.__name.call(void 0, useS, "useS");
254
230
  function getMetaFromInstance(instance, tag, name) {
255
231
  const propertyKeys = _phecdacore.getMetaKey.call(void 0, instance).filter((item) => typeof item === "string");
256
232
  const baseMeta = _phecdacore.getMergedMeta.call(void 0, instance, void 0);
@@ -264,7 +240,7 @@ function getMetaFromInstance(instance, tag, name) {
264
240
  func: i
265
241
  };
266
242
  if (baseMeta.controller) {
267
- if (typeof tag !== "string") _chunk5RBTN33Ajs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
243
+ if (typeof tag !== "string") _chunk4LLLQOMFjs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
268
244
  metaData.controller = baseMeta.controller;
269
245
  metaData[baseMeta.controller] = {
270
246
  ...baseMeta[baseMeta.controller],
@@ -302,7 +278,7 @@ function getMetaFromInstance(instance, tag, name) {
302
278
  return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || []);
303
279
  });
304
280
  }
305
- _chunk5RBTN33Ajs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
281
+ _chunk4LLLQOMFjs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
306
282
  function deepFreeze(object) {
307
283
  Object.freeze(object);
308
284
  Object.getOwnPropertyNames(object).forEach((prop) => {
@@ -310,13 +286,13 @@ function deepFreeze(object) {
310
286
  });
311
287
  return object;
312
288
  }
313
- _chunk5RBTN33Ajs.__name.call(void 0, deepFreeze, "deepFreeze");
289
+ _chunk4LLLQOMFjs.__name.call(void 0, deepFreeze, "deepFreeze");
314
290
  function getParamTypes(Model, key) {
315
291
  const paramTypes = Reflect.getMetadata("design:paramtypes", Model, key);
316
292
  if (typeof paramTypes === "function") return paramTypes();
317
293
  else return paramTypes;
318
294
  }
319
- _chunk5RBTN33Ajs.__name.call(void 0, getParamTypes, "getParamTypes");
295
+ _chunk4LLLQOMFjs.__name.call(void 0, getParamTypes, "getParamTypes");
320
296
 
321
297
 
322
298
 
@@ -1,12 +1,12 @@
1
1
  import { Construct } from 'phecda-core';
2
- import { b as MetaData, M as Meta, E as Emitter } from './meta-BX5jhe4Z.js';
2
+ import { M as Meta, E as Emitter } from './meta-BoS1E-Nz.mjs';
3
3
 
4
4
  declare abstract class Generator {
5
5
  private _path;
6
6
  constructor(path?: string);
7
7
  abstract name: string;
8
8
  get path(): string;
9
- abstract generateCode(meta: MetaData[]): string;
9
+ abstract generateCode(meta: Meta[]): string;
10
10
  output(meta: Meta[]): Promise<void>;
11
11
  }
12
12
 
@@ -41,6 +41,7 @@ declare class ServerPhecda {
41
41
  replace(oldModels: Construct[], newModels: Construct[]): Promise<void>;
42
42
  has(modelOrTag: Construct | PropertyKey): boolean;
43
43
  get<Model extends Construct>(modelOrTag: Model | PropertyKey): InstanceType<Model>;
44
+ getModel(tag: PropertyKey): Construct | undefined;
44
45
  }
45
46
  declare function Factory(models: Construct[], opts?: Options): Promise<ServerPhecda>;
46
47
  declare function useS<Model extends Construct>(model: Model, namespace?: string): InstanceType<Model>;
@@ -1,12 +1,12 @@
1
1
  import { Construct } from 'phecda-core';
2
- import { b as MetaData, M as Meta, E as Emitter } from './meta-BX5jhe4Z.mjs';
2
+ import { M as Meta, E as Emitter } from './meta-BoS1E-Nz.js';
3
3
 
4
4
  declare abstract class Generator {
5
5
  private _path;
6
6
  constructor(path?: string);
7
7
  abstract name: string;
8
8
  get path(): string;
9
- abstract generateCode(meta: MetaData[]): string;
9
+ abstract generateCode(meta: Meta[]): string;
10
10
  output(meta: Meta[]): Promise<void>;
11
11
  }
12
12
 
@@ -41,6 +41,7 @@ declare class ServerPhecda {
41
41
  replace(oldModels: Construct[], newModels: Construct[]): Promise<void>;
42
42
  has(modelOrTag: Construct | PropertyKey): boolean;
43
43
  get<Model extends Construct>(modelOrTag: Model | PropertyKey): InstanceType<Model>;
44
+ getModel(tag: PropertyKey): Construct | undefined;
44
45
  }
45
46
  declare function Factory(models: Construct[], opts?: Options): Promise<ServerPhecda>;
46
47
  declare function useS<Model extends Construct>(model: Model, namespace?: string): InstanceType<Model>;
package/dist/helper.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as Meta, C as ControllerMeta } from './meta-BX5jhe4Z.mjs';
1
+ import { M as Meta, a as ControllerMeta } from './meta-BoS1E-Nz.mjs';
2
2
  import { Construct } from 'phecda-core';
3
3
 
4
4
  declare function HMR(cb: (oldModels: Construct[], newModels: Construct[]) => any): void;
@@ -7,8 +7,6 @@ declare function RELAUNCH(): void;
7
7
 
8
8
  declare function resolveDep(ret: any, key: string): any;
9
9
 
10
- declare function genClientQueue(key?: string): string;
11
-
12
10
  declare function shallowClone(obj: any): any;
13
11
  declare function mergeObject(...args: any[]): any;
14
12
 
@@ -21,7 +19,7 @@ declare function detectAopDep(meta: Meta[], { guards, addons }?: {
21
19
  guardSet: Set<string>;
22
20
  pipeSet: Set<string>;
23
21
  filterSet: Set<string>;
24
- };
22
+ } | undefined;
25
23
  declare function joinUrl(base: string, ...paths: string[]): string;
26
24
 
27
- export { HMR, RELAUNCH, RELOAD, createControllerMetaMap, detectAopDep, genClientQueue, joinUrl, mergeObject, resolveDep, shallowClone };
25
+ export { HMR, RELAUNCH, RELOAD, createControllerMetaMap, detectAopDep, joinUrl, mergeObject, resolveDep, shallowClone };
package/dist/helper.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as Meta, C as ControllerMeta } from './meta-BX5jhe4Z.js';
1
+ import { M as Meta, a as ControllerMeta } from './meta-BoS1E-Nz.js';
2
2
  import { Construct } from 'phecda-core';
3
3
 
4
4
  declare function HMR(cb: (oldModels: Construct[], newModels: Construct[]) => any): void;
@@ -7,8 +7,6 @@ declare function RELAUNCH(): void;
7
7
 
8
8
  declare function resolveDep(ret: any, key: string): any;
9
9
 
10
- declare function genClientQueue(key?: string): string;
11
-
12
10
  declare function shallowClone(obj: any): any;
13
11
  declare function mergeObject(...args: any[]): any;
14
12
 
@@ -21,7 +19,7 @@ declare function detectAopDep(meta: Meta[], { guards, addons }?: {
21
19
  guardSet: Set<string>;
22
20
  pipeSet: Set<string>;
23
21
  filterSet: Set<string>;
24
- };
22
+ } | undefined;
25
23
  declare function joinUrl(base: string, ...paths: string[]): string;
26
24
 
27
- export { HMR, RELAUNCH, RELOAD, createControllerMetaMap, detectAopDep, genClientQueue, joinUrl, mergeObject, resolveDep, shallowClone };
25
+ export { HMR, RELAUNCH, RELOAD, createControllerMetaMap, detectAopDep, joinUrl, mergeObject, resolveDep, shallowClone };
package/dist/helper.js CHANGED
@@ -5,13 +5,13 @@
5
5
 
6
6
 
7
7
 
8
+ var _chunkXKK2SQ7Wjs = require('./chunk-XKK2SQ7W.js');
8
9
 
9
- var _chunkFX3LDQIIjs = require('./chunk-FX3LDQII.js');
10
10
 
11
11
 
12
12
 
13
+ var _chunk4LLLQOMFjs = require('./chunk-4LLLQOMF.js');
13
14
 
14
- var _chunk5RBTN33Ajs = require('./chunk-5RBTN33A.js');
15
15
 
16
16
 
17
17
 
@@ -21,6 +21,4 @@ var _chunk5RBTN33Ajs = require('./chunk-5RBTN33A.js');
21
21
 
22
22
 
23
23
 
24
-
25
-
26
- exports.HMR = _chunk5RBTN33Ajs.HMR; exports.RELAUNCH = _chunk5RBTN33Ajs.RELAUNCH; exports.RELOAD = _chunk5RBTN33Ajs.RELOAD; exports.createControllerMetaMap = _chunkFX3LDQIIjs.createControllerMetaMap; exports.detectAopDep = _chunkFX3LDQIIjs.detectAopDep; exports.genClientQueue = _chunkFX3LDQIIjs.genClientQueue; exports.joinUrl = _chunkFX3LDQIIjs.joinUrl; exports.mergeObject = _chunkFX3LDQIIjs.mergeObject; exports.resolveDep = _chunkFX3LDQIIjs.resolveDep; exports.shallowClone = _chunkFX3LDQIIjs.shallowClone;
24
+ exports.HMR = _chunk4LLLQOMFjs.HMR; exports.RELAUNCH = _chunk4LLLQOMFjs.RELAUNCH; exports.RELOAD = _chunk4LLLQOMFjs.RELOAD; exports.createControllerMetaMap = _chunkXKK2SQ7Wjs.createControllerMetaMap; exports.detectAopDep = _chunkXKK2SQ7Wjs.detectAopDep; exports.joinUrl = _chunkXKK2SQ7Wjs.joinUrl; exports.mergeObject = _chunkXKK2SQ7Wjs.mergeObject; exports.resolveDep = _chunkXKK2SQ7Wjs.resolveDep; exports.shallowClone = _chunkXKK2SQ7Wjs.shallowClone;
package/dist/helper.mjs CHANGED
@@ -1,24 +1,22 @@
1
1
  import {
2
2
  createControllerMetaMap,
3
3
  detectAopDep,
4
- genClientQueue,
5
4
  joinUrl,
6
5
  mergeObject,
7
6
  resolveDep,
8
7
  shallowClone
9
- } from "./chunk-CVPZWDXU.mjs";
8
+ } from "./chunk-E7EAPAGM.mjs";
10
9
  import {
11
10
  HMR,
12
11
  RELAUNCH,
13
12
  RELOAD
14
- } from "./chunk-FXTJ3BJ6.mjs";
13
+ } from "./chunk-NQ55PA2X.mjs";
15
14
  export {
16
15
  HMR,
17
16
  RELAUNCH,
18
17
  RELOAD,
19
18
  createControllerMetaMap,
20
19
  detectAopDep,
21
- genClientQueue,
22
20
  joinUrl,
23
21
  mergeObject,
24
22
  resolveDep,
@@ -1,9 +1,9 @@
1
1
  import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
2
2
  import { BaseMacro } from 'elysia/dist/types';
3
- import { H as HttpCtx, a as HttpOptions } from '../../types-DKVhyZk_.mjs';
4
- import { F as Factory } from '../../core-BDkhrEyf.mjs';
3
+ import { H as HttpCtx, a as HttpOptions } from '../../types-SCJZFCYt.mjs';
4
+ import { F as Factory } from '../../core-DbqWh47p.mjs';
5
5
  import 'node:http';
6
- import '../../meta-BX5jhe4Z.mjs';
6
+ import '../../meta-BoS1E-Nz.mjs';
7
7
  import 'phecda-core';
8
8
 
9
9
  interface ElysiaCtx extends HttpCtx {
@@ -13,6 +13,6 @@ interface ElysiaCtx extends HttpCtx {
13
13
  }
14
14
  type Addon = (app: Elysia$1<any>) => void;
15
15
  declare function bind(app: Elysia$1<any>, data: Awaited<ReturnType<typeof Factory>>, opts?: HttpOptions): void;
16
- declare function Elysia(opts: LocalHook<InputSchema, RouteSchema, SingletonBase, Record<string, Error>, BaseMacro>): any;
16
+ declare function Elysia(opts: LocalHook<InputSchema, RouteSchema, SingletonBase, Record<string, Error>, BaseMacro, any>): any;
17
17
 
18
18
  export { type Addon, Elysia, type ElysiaCtx, bind };
@@ -1,9 +1,9 @@
1
1
  import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
2
2
  import { BaseMacro } from 'elysia/dist/types';
3
- import { H as HttpCtx, a as HttpOptions } from '../../types-CMeuFoyd.js';
4
- import { F as Factory } from '../../core-D_cz0tKa.js';
3
+ import { H as HttpCtx, a as HttpOptions } from '../../types-xruyYmyu.js';
4
+ import { F as Factory } from '../../core-Rq7BhPHE.js';
5
5
  import 'node:http';
6
- import '../../meta-BX5jhe4Z.js';
6
+ import '../../meta-BoS1E-Nz.js';
7
7
  import 'phecda-core';
8
8
 
9
9
  interface ElysiaCtx extends HttpCtx {
@@ -13,6 +13,6 @@ interface ElysiaCtx extends HttpCtx {
13
13
  }
14
14
  type Addon = (app: Elysia$1<any>) => void;
15
15
  declare function bind(app: Elysia$1<any>, data: Awaited<ReturnType<typeof Factory>>, opts?: HttpOptions): void;
16
- declare function Elysia(opts: LocalHook<InputSchema, RouteSchema, SingletonBase, Record<string, Error>, BaseMacro>): any;
16
+ declare function Elysia(opts: LocalHook<InputSchema, RouteSchema, SingletonBase, Record<string, Error>, BaseMacro, any>): any;
17
17
 
18
18
  export { type Addon, Elysia, type ElysiaCtx, bind };
@@ -1,16 +1,16 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkV5EYXVJTjs = require('../../chunk-V5EYXVJT.js');
3
+ var _chunkDPPDWBYOjs = require('../../chunk-DPPDWBYO.js');
4
4
 
5
5
 
6
6
 
7
7
 
8
8
 
9
9
 
10
- var _chunkFX3LDQIIjs = require('../../chunk-FX3LDQII.js');
10
+ var _chunkXKK2SQ7Wjs = require('../../chunk-XKK2SQ7W.js');
11
11
 
12
12
 
13
- var _chunk5RBTN33Ajs = require('../../chunk-5RBTN33A.js');
13
+ var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
14
14
 
15
15
  // src/http/elysia/bind.ts
16
16
  var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
@@ -19,14 +19,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/elysia");
19
19
  function bind(app, data, opts = {}) {
20
20
  const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
21
21
  const { moduleMap, meta } = data;
22
- const metaMap = _chunkFX3LDQIIjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
22
+ const metaMap = _chunkXKK2SQ7Wjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
23
23
  const { controller, http, func, tag } = meta2.data;
24
24
  if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
25
25
  debug(`register method "${func}" in module "${tag}"`);
26
26
  return true;
27
27
  }
28
28
  });
29
- _chunkFX3LDQIIjs.detectAopDep.call(void 0, meta, {
29
+ _chunkXKK2SQ7Wjs.detectAopDep.call(void 0, meta, {
30
30
  addons: [
31
31
  ...globalAddons,
32
32
  ...parallelAddons
@@ -35,28 +35,29 @@ function bind(app, data, opts = {}) {
35
35
  });
36
36
  registerRoute();
37
37
  function registerRoute() {
38
- _chunkFX3LDQIIjs.Context.applyAddons(globalAddons, app, "elysia");
38
+ _chunkXKK2SQ7Wjs.Context.applyAddons(globalAddons, app, "elysia");
39
39
  if (parallelRoute) {
40
40
  const parallelRouter = new (0, _elysia.Elysia)();
41
- _chunkFX3LDQIIjs.Context.applyAddons(parallelAddons, app, "elysia");
41
+ _chunkXKK2SQ7Wjs.Context.applyAddons(parallelAddons, app, "elysia");
42
42
  parallelRouter.post(parallelRoute, async (c) => {
43
43
  const { body } = c;
44
44
  async function errorHandler(e) {
45
- const error = await _chunkFX3LDQIIjs.Context.filterRecord.default(e);
45
+ const error = await _chunkXKK2SQ7Wjs.Context.filterRecord.default(e);
46
46
  c.set.status = error.status;
47
47
  return error;
48
48
  }
49
- _chunk5RBTN33Ajs.__name.call(void 0, errorHandler, "errorHandler");
50
- if (!Array.isArray(body)) return errorHandler(new (0, _chunkFX3LDQIIjs.BadRequestException)("data format should be an array"));
49
+ _chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
50
+ if (!Array.isArray(body)) return errorHandler(new (0, _chunkXKK2SQ7Wjs.BadRequestException)("data format should be an array"));
51
51
  try {
52
52
  return Promise.all(body.map((item, i) => {
53
53
  return new Promise(async (resolve) => {
54
+ if (!item) return resolve(null);
54
55
  const { tag, func } = item;
55
56
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
56
- if (!metaMap.has(tag)) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`module "${tag}" doesn't exist`)));
57
+ if (!metaMap.has(tag)) return resolve(await _chunkXKK2SQ7Wjs.Context.filterRecord.default(new (0, _chunkXKK2SQ7Wjs.BadRequestException)(`module "${tag}" doesn't exist`)));
57
58
  const meta2 = metaMap.get(tag)[func];
58
- if (!meta2) return resolve(await _chunkFX3LDQIIjs.Context.filterRecord.default(new (0, _chunkFX3LDQIIjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
59
- const aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
59
+ if (!meta2) return resolve(await _chunkXKK2SQ7Wjs.Context.filterRecord.default(new (0, _chunkXKK2SQ7Wjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
60
+ const aop = _chunkXKK2SQ7Wjs.Context.getAop(meta2, {
60
61
  globalGuards,
61
62
  globalFilter,
62
63
  globalPipe
@@ -71,23 +72,23 @@ function bind(app, data, opts = {}) {
71
72
  moduleMap,
72
73
  app,
73
74
  ...item,
74
- getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
75
- setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
75
+ getCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
76
+ setCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
76
77
  ...opts2,
77
78
  value
78
79
  }), "setCookie"),
79
- delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
80
- redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
81
- setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
82
- setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (status) => c.set.status = status, "setResStatus"),
83
- getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => {
80
+ delCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
81
+ redirect: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
82
+ setResHeaders: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
83
+ setResStatus: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (status) => c.set.status = status, "setResStatus"),
84
+ getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => {
84
85
  throw new Error("elysia can't support getRequest");
85
86
  }, "getRequest"),
86
- getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => {
87
+ getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => {
87
88
  throw new Error("elysia can't support getResponse");
88
89
  }, "getResponse")
89
90
  };
90
- const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
91
+ const context = new (0, _chunkXKK2SQ7Wjs.Context)(contextData);
91
92
  context.run(aop, resolve, resolve);
92
93
  });
93
94
  })).then((ret) => {
@@ -109,14 +110,14 @@ function bind(app, data, opts = {}) {
109
110
  if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
110
111
  let aop;
111
112
  if (!dynamic) {
112
- aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
113
+ aop = _chunkXKK2SQ7Wjs.Context.getAop(meta2, {
113
114
  globalFilter,
114
115
  globalGuards,
115
116
  globalPipe
116
117
  });
117
118
  }
118
- _chunkFX3LDQIIjs.Context.applyAddons(addons, subApp, "elysia");
119
- subApp[http.type](_chunkFX3LDQIIjs.joinUrl.call(void 0, http.prefix, http.route), async (c) => {
119
+ _chunkXKK2SQ7Wjs.Context.applyAddons(addons, subApp, "elysia");
120
+ subApp[http.type](_chunkXKK2SQ7Wjs.joinUrl.call(void 0, http.prefix, http.route), async (c) => {
120
121
  debug(`invoke method "${func}" in module "${tag}"`);
121
122
  const contextData = {
122
123
  type: "elysia",
@@ -131,33 +132,33 @@ function bind(app, data, opts = {}) {
131
132
  params: c.params,
132
133
  headers: c.headers,
133
134
  app,
134
- getCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
135
- setCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
135
+ getCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
136
+ setCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
136
137
  ...opts2,
137
138
  value
138
139
  }), "setCookie"),
139
- delCookie: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
140
- redirect: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
141
- setResHeaders: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
142
- setResStatus: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, (status) => c.set.status = status, "setResStatus"),
143
- getRequest: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => {
140
+ delCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
141
+ redirect: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
142
+ setResHeaders: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
143
+ setResStatus: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (status) => c.set.status = status, "setResStatus"),
144
+ getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => {
144
145
  throw new Error("elysia can't support getRequest");
145
146
  }, "getRequest"),
146
- getResponse: /* @__PURE__ */ _chunk5RBTN33Ajs.__name.call(void 0, () => {
147
+ getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => {
147
148
  throw new Error("elysia can't support getResponse");
148
149
  }, "getResponse")
149
150
  };
150
151
  if (dynamic) {
151
- aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
152
+ aop = _chunkXKK2SQ7Wjs.Context.getAop(meta2, {
152
153
  globalFilter,
153
154
  globalGuards,
154
155
  globalPipe
155
156
  });
156
157
  }
157
- const context = new (0, _chunkFX3LDQIIjs.Context)(contextData);
158
+ const context = new (0, _chunkXKK2SQ7Wjs.Context)(contextData);
158
159
  if (http.headers) c.set.headers = http.headers;
159
160
  if (dynamic) {
160
- aop = _chunkFX3LDQIIjs.Context.getAop(meta2, {
161
+ aop = _chunkXKK2SQ7Wjs.Context.getAop(meta2, {
161
162
  globalFilter,
162
163
  globalGuards,
163
164
  globalPipe
@@ -172,13 +173,13 @@ function bind(app, data, opts = {}) {
172
173
  }
173
174
  }
174
175
  }
175
- _chunk5RBTN33Ajs.__name.call(void 0, registerRoute, "registerRoute");
176
+ _chunk4LLLQOMFjs.__name.call(void 0, registerRoute, "registerRoute");
176
177
  }
177
- _chunk5RBTN33Ajs.__name.call(void 0, bind, "bind");
178
+ _chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
178
179
  function Elysia(opts) {
179
- return _chunkV5EYXVJTjs.Define.call(void 0, "elysia", opts);
180
+ return _chunkDPPDWBYOjs.Define.call(void 0, "elysia", opts);
180
181
  }
181
- _chunk5RBTN33Ajs.__name.call(void 0, Elysia, "Elysia");
182
+ _chunk4LLLQOMFjs.__name.call(void 0, Elysia, "Elysia");
182
183
 
183
184
 
184
185
 
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  Define
3
- } from "../../chunk-ODVWOXVB.mjs";
3
+ } from "../../chunk-MKRHYZCL.mjs";
4
4
  import {
5
5
  BadRequestException,
6
6
  Context,
7
7
  createControllerMetaMap,
8
8
  detectAopDep,
9
9
  joinUrl
10
- } from "../../chunk-CVPZWDXU.mjs";
10
+ } from "../../chunk-E7EAPAGM.mjs";
11
11
  import {
12
12
  __name
13
- } from "../../chunk-FXTJ3BJ6.mjs";
13
+ } from "../../chunk-NQ55PA2X.mjs";
14
14
 
15
15
  // src/http/elysia/bind.ts
16
16
  import Debug from "debug";
@@ -51,6 +51,7 @@ function bind(app, data, opts = {}) {
51
51
  try {
52
52
  return Promise.all(body.map((item, i) => {
53
53
  return new Promise(async (resolve) => {
54
+ if (!item) return resolve(null);
54
55
  const { tag, func } = item;
55
56
  debug(`(parallel)invoke method "${func}" in module "${tag}"`);
56
57
  if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
@@ -1,8 +1,8 @@
1
1
  import { Request, Response, Router, RequestHandler } from 'express';
2
- import { H as HttpCtx, a as HttpOptions } from '../../types-DKVhyZk_.mjs';
3
- import { F as Factory } from '../../core-BDkhrEyf.mjs';
2
+ import { H as HttpCtx, a as HttpOptions } from '../../types-SCJZFCYt.mjs';
3
+ import { F as Factory } from '../../core-DbqWh47p.mjs';
4
4
  import 'node:http';
5
- import '../../meta-BX5jhe4Z.mjs';
5
+ import '../../meta-BoS1E-Nz.mjs';
6
6
  import 'phecda-core';
7
7
 
8
8
  interface ExpressCtx extends HttpCtx {
@@ -1,8 +1,8 @@
1
1
  import { Request, Response, Router, RequestHandler } from 'express';
2
- import { H as HttpCtx, a as HttpOptions } from '../../types-CMeuFoyd.js';
3
- import { F as Factory } from '../../core-D_cz0tKa.js';
2
+ import { H as HttpCtx, a as HttpOptions } from '../../types-xruyYmyu.js';
3
+ import { F as Factory } from '../../core-Rq7BhPHE.js';
4
4
  import 'node:http';
5
- import '../../meta-BX5jhe4Z.js';
5
+ import '../../meta-BoS1E-Nz.js';
6
6
  import 'phecda-core';
7
7
 
8
8
  interface ExpressCtx extends HttpCtx {