phecda-server 5.2.4 → 5.2.6

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 (77) hide show
  1. package/dist/{chunk-IJNA24EZ.mjs → chunk-5E2AVYP2.mjs} +39 -55
  2. package/dist/{chunk-AWY6FTH4.js → chunk-AUAAKHWS.js} +70 -86
  3. package/dist/{chunk-Q4AGVGVA.mjs → chunk-BZKJ5NBU.mjs} +103 -105
  4. package/dist/{chunk-LGP5AT6W.mjs → chunk-LHLQIQPH.mjs} +51 -70
  5. package/dist/{chunk-VYDBNZJ2.mjs → chunk-MESZCLSS.mjs} +1 -10
  6. package/dist/{chunk-UJAI73O6.js → chunk-N4ULJDEQ.js} +62 -81
  7. package/dist/{chunk-H6NYBVBV.js → chunk-QYX5Q7KO.js} +130 -132
  8. package/dist/{chunk-FNJWO324.js → chunk-RVWBJ6LV.js} +2 -11
  9. package/dist/core-Bc2ENEHX.d.mts +29 -0
  10. package/dist/{core-7f6d2be6.d.ts → core-dx9E5x2N.d.ts} +7 -5
  11. package/dist/helper.d.mts +27 -0
  12. package/dist/helper.d.ts +1 -1
  13. package/dist/helper.js +3 -3
  14. package/dist/helper.mjs +2 -2
  15. package/dist/index.d.mts +244 -0
  16. package/dist/index.d.ts +16 -18
  17. package/dist/index.js +81 -90
  18. package/dist/index.mjs +61 -70
  19. package/dist/rpc/bullmq/index.d.mts +21 -0
  20. package/dist/rpc/bullmq/index.d.ts +4 -4
  21. package/dist/rpc/bullmq/index.js +30 -43
  22. package/dist/rpc/bullmq/index.mjs +20 -33
  23. package/dist/rpc/kafka/index.d.mts +24 -0
  24. package/dist/rpc/kafka/index.d.ts +4 -4
  25. package/dist/rpc/kafka/index.js +25 -34
  26. package/dist/rpc/kafka/index.mjs +17 -26
  27. package/dist/rpc/nats/index.d.mts +15 -0
  28. package/dist/rpc/nats/index.d.ts +4 -4
  29. package/dist/rpc/nats/index.js +33 -46
  30. package/dist/rpc/nats/index.mjs +24 -37
  31. package/dist/rpc/rabbitmq/index.d.mts +16 -0
  32. package/dist/rpc/rabbitmq/index.d.ts +4 -4
  33. package/dist/rpc/rabbitmq/index.js +34 -46
  34. package/dist/rpc/rabbitmq/index.mjs +23 -35
  35. package/dist/rpc/redis/index.d.mts +23 -0
  36. package/dist/rpc/redis/index.d.ts +4 -4
  37. package/dist/rpc/redis/index.js +27 -38
  38. package/dist/rpc/redis/index.mjs +18 -29
  39. package/dist/server/elysia/index.d.mts +18 -0
  40. package/dist/server/elysia/index.d.ts +4 -4
  41. package/dist/server/elysia/index.js +22 -27
  42. package/dist/server/elysia/index.mjs +8 -13
  43. package/dist/server/express/index.d.mts +18 -0
  44. package/dist/server/express/index.d.ts +4 -4
  45. package/dist/server/express/index.js +24 -33
  46. package/dist/server/express/index.mjs +11 -20
  47. package/dist/server/fastify/index.d.mts +20 -0
  48. package/dist/server/fastify/index.d.ts +4 -4
  49. package/dist/server/fastify/index.js +23 -30
  50. package/dist/server/fastify/index.mjs +10 -17
  51. package/dist/server/h3/index.d.mts +16 -0
  52. package/dist/server/h3/index.d.ts +4 -4
  53. package/dist/server/h3/index.js +21 -25
  54. package/dist/server/h3/index.mjs +10 -14
  55. package/dist/server/hono/index.d.mts +16 -0
  56. package/dist/server/hono/index.d.ts +4 -4
  57. package/dist/server/hono/index.js +22 -30
  58. package/dist/server/hono/index.mjs +10 -18
  59. package/dist/server/hyper-express/index.d.mts +18 -0
  60. package/dist/server/hyper-express/index.d.ts +4 -4
  61. package/dist/server/hyper-express/index.js +23 -32
  62. package/dist/server/hyper-express/index.mjs +11 -20
  63. package/dist/server/koa/index.d.mts +18 -0
  64. package/dist/server/koa/index.d.ts +4 -4
  65. package/dist/server/koa/index.js +22 -29
  66. package/dist/server/koa/index.mjs +9 -16
  67. package/dist/test.d.mts +18 -0
  68. package/dist/test.d.ts +4 -4
  69. package/dist/test.js +19 -27
  70. package/dist/test.mjs +16 -24
  71. package/dist/{types-81be0ba3.d.ts → types-BlIBlnVT.d.mts} +1 -2
  72. package/dist/types-BlIBlnVT.d.ts +107 -0
  73. package/dist/{types-f3b79218.d.ts → types-CJSkC9tO.d.ts} +2 -2
  74. package/dist/types-Dp5ixUqW.d.mts +27 -0
  75. package/dist/{types-0a76c4bc.d.ts → types-PY43OKEP.d.ts} +2 -2
  76. package/dist/types-vF4Hvnvo.d.mts +17 -0
  77. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkUJAI73O6js = require('./chunk-UJAI73O6.js');
6
5
 
6
+ var _chunkN4ULJDEQjs = require('./chunk-N4ULJDEQ.js');
7
7
 
8
8
 
9
9
 
@@ -29,8 +29,8 @@ var _chunkUJAI73O6js = require('./chunk-UJAI73O6.js');
29
29
 
30
30
 
31
31
 
32
- var _chunkAWY6FTH4js = require('./chunk-AWY6FTH4.js');
33
32
 
33
+ var _chunkAUAAKHWSjs = require('./chunk-AUAAKHWS.js');
34
34
 
35
35
 
36
36
 
@@ -55,8 +55,8 @@ var _chunkAWY6FTH4js = require('./chunk-AWY6FTH4.js');
55
55
 
56
56
 
57
57
 
58
- var _chunkH6NYBVBVjs = require('./chunk-H6NYBVBV.js');
59
58
 
59
+ var _chunkQYX5Q7KOjs = require('./chunk-QYX5Q7KO.js');
60
60
 
61
61
 
62
62
 
@@ -68,180 +68,174 @@ var _chunkH6NYBVBVjs = require('./chunk-H6NYBVBV.js');
68
68
 
69
69
 
70
70
 
71
- var _chunkFNJWO324js = require('./chunk-FNJWO324.js');
71
+ var _chunkRVWBJ6LVjs = require('./chunk-RVWBJ6LV.js');
72
72
 
73
73
  // src/types.ts
74
74
  var ResponseSymbol = Symbol("response");
75
75
  var CustomResponse = class {
76
+ static {
77
+ _chunkRVWBJ6LVjs.__name.call(void 0, this, "CustomResponse");
78
+ }
76
79
 
77
80
  };
78
- _chunkFNJWO324js.__name.call(void 0, CustomResponse, "CustomResponse");
79
81
 
80
- // src/modules/dev.ts
82
+ // src/modules/base.ts
81
83
  var _phecdacore = require('phecda-core'); _createStarExport(_phecdacore);
82
84
  function _ts_decorate(decorators, target, key, desc) {
83
85
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
84
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
85
- r = Reflect.decorate(decorators, target, key, desc);
86
- else
87
- for (var i = decorators.length - 1; i >= 0; i--)
88
- if (d = decorators[i])
89
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
86
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
87
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
90
88
  return c > 3 && r && Object.defineProperty(target, key, r), r;
91
89
  }
92
- _chunkFNJWO324js.__name.call(void 0, _ts_decorate, "_ts_decorate");
93
- function _ts_metadata(k, v) {
94
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
95
- return Reflect.metadata(k, v);
96
- }
97
- _chunkFNJWO324js.__name.call(void 0, _ts_metadata, "_ts_metadata");
98
- var Dev = (_class = class {constructor() { _class.prototype.__init.call(this); }
99
- __init() {this[_chunkFNJWO324js.UNMOUNT_SYMBOL] = []}
100
-
101
- // work for hmr
102
- // exec callback when module unmount
103
- onUnmount(cb) {
104
- this[_chunkFNJWO324js.UNMOUNT_SYMBOL].push(cb);
105
- }
106
- async unmount() {
107
- for (const cb of this[_chunkFNJWO324js.UNMOUNT_SYMBOL])
108
- await cb();
90
+ _chunkRVWBJ6LVjs.__name.call(void 0, _ts_decorate, "_ts_decorate");
91
+ var ServerBase = (_class = class extends _phecdacore.Base {constructor(...args2) { super(...args2); _class.prototype.__init.call(this); }
92
+ static {
93
+ _chunkRVWBJ6LVjs.__name.call(void 0, this, "ServerBase");
109
94
  }
95
+
96
+ __init() {this.emitter = exports.emitter = _chunkN4ULJDEQjs.emitter}
110
97
  }, _class);
111
- _chunkFNJWO324js.__name.call(void 0, Dev, "Dev");
112
- _ts_decorate([
113
- _phecdacore.Unmount,
114
- _ts_metadata("design:type", Function),
115
- _ts_metadata("design:paramtypes", []),
116
- _ts_metadata("design:returntype", Promise)
117
- ], Dev.prototype, "unmount", null);
118
- Dev = exports.Dev = _ts_decorate([
98
+ ServerBase = exports.ServerBase = _ts_decorate([
119
99
  _phecdacore.Empty
120
- ], Dev);
100
+ ], ServerBase);
121
101
 
122
102
  // src/modules/filter.ts
123
103
 
124
- var PFilter = class extends Dev {
104
+ var PFilter = class extends ServerBase {
105
+ static {
106
+ _chunkRVWBJ6LVjs.__name.call(void 0, this, "PFilter");
107
+ }
125
108
 
126
109
  constructor(tag) {
127
110
  super();
128
111
  this.key = tag || _phecdacore.getTag.call(void 0, this);
129
- _chunkH6NYBVBVjs.addFilter.call(void 0, this.key, this.use.bind(this));
112
+ _chunkQYX5Q7KOjs.addFilter.call(void 0, this.key, this.use.bind(this));
130
113
  this.onUnmount(() => {
131
- delete _chunkH6NYBVBVjs.Context.filterRecord[this.key];
114
+ delete _chunkQYX5Q7KOjs.Context.filterRecord[this.key];
132
115
  });
133
116
  }
134
117
  };
135
- _chunkFNJWO324js.__name.call(void 0, PFilter, "PFilter");
136
118
 
137
119
  // src/modules/guard.ts
138
120
 
139
- var PGuard = class extends Dev {
121
+ var PGuard = class extends ServerBase {
122
+ static {
123
+ _chunkRVWBJ6LVjs.__name.call(void 0, this, "PGuard");
124
+ }
140
125
 
141
126
  constructor(tag) {
142
127
  super();
143
128
  this.key = tag || _phecdacore.getTag.call(void 0, this);
144
- _chunkH6NYBVBVjs.addGuard.call(void 0, this.key, this.use.bind(this));
129
+ _chunkQYX5Q7KOjs.addGuard.call(void 0, this.key, this.use.bind(this));
145
130
  this.onUnmount(() => {
146
- delete _chunkH6NYBVBVjs.Context.guardRecord[this.key];
131
+ delete _chunkQYX5Q7KOjs.Context.guardRecord[this.key];
147
132
  });
148
133
  }
149
134
  };
150
- _chunkFNJWO324js.__name.call(void 0, PGuard, "PGuard");
151
135
 
152
136
  // src/modules/interceptor.ts
153
137
 
154
- var PInterceptor = class extends Dev {
138
+ var PInterceptor = class extends ServerBase {
139
+ static {
140
+ _chunkRVWBJ6LVjs.__name.call(void 0, this, "PInterceptor");
141
+ }
155
142
 
156
143
  constructor(tag) {
157
144
  super();
158
145
  this.key = tag || _phecdacore.getTag.call(void 0, this);
159
146
  this.onUnmount(() => {
160
- delete _chunkH6NYBVBVjs.Context.interceptorRecord[this.key];
147
+ delete _chunkQYX5Q7KOjs.Context.interceptorRecord[this.key];
161
148
  });
162
- _chunkH6NYBVBVjs.addInterceptor.call(void 0, this.key, this.use.bind(this));
149
+ _chunkQYX5Q7KOjs.addInterceptor.call(void 0, this.key, this.use.bind(this));
163
150
  }
164
151
  };
165
- _chunkFNJWO324js.__name.call(void 0, PInterceptor, "PInterceptor");
166
152
 
167
153
  // src/modules/pipe.ts
168
154
 
169
- var PPipe = class extends Dev {
155
+ var PPipe = class extends ServerBase {
156
+ static {
157
+ _chunkRVWBJ6LVjs.__name.call(void 0, this, "PPipe");
158
+ }
170
159
 
171
160
  constructor(tag) {
172
161
  super();
173
162
  this.key = tag || _phecdacore.getTag.call(void 0, this);
174
- _chunkH6NYBVBVjs.addPipe.call(void 0, this.key, this.use.bind(this));
163
+ _chunkQYX5Q7KOjs.addPipe.call(void 0, this.key, this.use.bind(this));
175
164
  this.onUnmount(() => {
176
- delete _chunkH6NYBVBVjs.Context.pipeRecord[this.key];
165
+ delete _chunkQYX5Q7KOjs.Context.pipeRecord[this.key];
177
166
  });
178
167
  }
179
168
  };
180
- _chunkFNJWO324js.__name.call(void 0, PPipe, "PPipe");
181
169
 
182
170
  // src/modules/plugin.ts
183
171
 
184
- var PPlugin = class extends Dev {
172
+ var PPlugin = class extends ServerBase {
173
+ static {
174
+ _chunkRVWBJ6LVjs.__name.call(void 0, this, "PPlugin");
175
+ }
185
176
 
186
177
  constructor(tag) {
187
178
  super();
188
179
  this.key = tag || _phecdacore.getTag.call(void 0, this);
189
- _chunkH6NYBVBVjs.addPlugin.call(void 0, this.key, this.use.bind(this));
180
+ _chunkQYX5Q7KOjs.addPlugin.call(void 0, this.key, this.use.bind(this));
190
181
  this.onUnmount(() => {
191
- delete _chunkH6NYBVBVjs.Context.pluginRecord[this.key];
182
+ delete _chunkQYX5Q7KOjs.Context.pluginRecord[this.key];
192
183
  });
193
184
  }
194
185
  };
195
- _chunkFNJWO324js.__name.call(void 0, PPlugin, "PPlugin");
196
186
 
197
187
  // src/modules/extension.ts
198
188
 
199
- var PExtension = class extends Dev {
189
+ var PExtension = class extends ServerBase {
190
+ static {
191
+ _chunkRVWBJ6LVjs.__name.call(void 0, this, "PExtension");
192
+ }
200
193
 
201
194
  constructor(tag) {
202
195
  super();
203
196
  const key = this.key = tag || _phecdacore.getTag.call(void 0, this);
204
197
  if (this.pipe) {
205
- _chunkH6NYBVBVjs.addPipe.call(void 0, key, this.pipe.bind(this));
198
+ _chunkQYX5Q7KOjs.addPipe.call(void 0, key, this.pipe.bind(this));
206
199
  this.onUnmount(() => {
207
- delete _chunkH6NYBVBVjs.Context.pipeRecord[key];
200
+ delete _chunkQYX5Q7KOjs.Context.pipeRecord[key];
208
201
  });
209
202
  }
210
203
  if (this.plugin) {
211
- _chunkH6NYBVBVjs.addPlugin.call(void 0, key, this.plugin.bind(this));
204
+ _chunkQYX5Q7KOjs.addPlugin.call(void 0, key, this.plugin.bind(this));
212
205
  this.onUnmount(() => {
213
- delete _chunkH6NYBVBVjs.Context.pluginRecord[key];
206
+ delete _chunkQYX5Q7KOjs.Context.pluginRecord[key];
214
207
  });
215
208
  }
216
209
  if (this.intercept) {
217
- _chunkH6NYBVBVjs.addInterceptor.call(void 0, key, this.intercept.bind(this));
210
+ _chunkQYX5Q7KOjs.addInterceptor.call(void 0, key, this.intercept.bind(this));
218
211
  this.onUnmount(() => {
219
- delete _chunkH6NYBVBVjs.Context.interceptorRecord[key];
212
+ delete _chunkQYX5Q7KOjs.Context.interceptorRecord[key];
220
213
  });
221
214
  }
222
215
  if (this.guard) {
223
- _chunkH6NYBVBVjs.addGuard.call(void 0, key, this.guard.bind(this));
216
+ _chunkQYX5Q7KOjs.addGuard.call(void 0, key, this.guard.bind(this));
224
217
  this.onUnmount(() => {
225
- delete _chunkH6NYBVBVjs.Context.guardRecord[key];
218
+ delete _chunkQYX5Q7KOjs.Context.guardRecord[key];
226
219
  });
227
220
  }
228
221
  if (this.filter) {
229
- _chunkH6NYBVBVjs.addFilter.call(void 0, key, this.filter.bind(this));
222
+ _chunkQYX5Q7KOjs.addFilter.call(void 0, key, this.filter.bind(this));
230
223
  this.onUnmount(() => {
231
- delete _chunkH6NYBVBVjs.Context.filterRecord[key];
224
+ delete _chunkQYX5Q7KOjs.Context.filterRecord[key];
232
225
  });
233
226
  }
234
227
  }
235
228
  };
236
- _chunkFNJWO324js.__name.call(void 0, PExtension, "PExtension");
237
229
 
238
230
  // src/generator/utils.ts
239
231
  var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
240
232
  var Generator = class {
233
+ static {
234
+ _chunkRVWBJ6LVjs.__name.call(void 0, this, "Generator");
235
+ }
241
236
 
242
237
  constructor(path) {
243
- if (path)
244
- this._path = path;
238
+ if (path) this._path = path;
245
239
  }
246
240
  get path() {
247
241
  return this._path || `.ps/${this.name.toLowerCase()}.js`;
@@ -250,10 +244,12 @@ var Generator = class {
250
244
  await _fsextra2.default.outputFile(this.path, this.generateCode(meta.map((item) => item.data)));
251
245
  }
252
246
  };
253
- _chunkFNJWO324js.__name.call(void 0, Generator, "Generator");
254
247
 
255
248
  // src/generator/rpc.ts
256
- var RPCGenerator = (_class2 = class extends Generator {constructor(...args2) { super(...args2); _class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this); }
249
+ var RPCGenerator = (_class2 = class extends Generator {constructor(...args3) { super(...args3); _class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this); }
250
+ static {
251
+ _chunkRVWBJ6LVjs.__name.call(void 0, this, "RPCGenerator");
252
+ }
257
253
  __init2() {this.name = "RPC"}
258
254
  __init3() {this.classMap = {}}
259
255
  getContent() {
@@ -268,10 +264,8 @@ var RPCGenerator = (_class2 = class extends Generator {constructor(...args2) { s
268
264
  }
269
265
  addMethod(args) {
270
266
  const { rpc, name, func, tag } = args;
271
- if (!rpc)
272
- return;
273
- if (!this.classMap[name])
274
- this.classMap[name] = {};
267
+ if (!rpc) return;
268
+ if (!this.classMap[name]) this.classMap[name] = {};
275
269
  this.classMap[name][func] = `
276
270
  ${func}(){
277
271
  return {tag:'${tag}',func:"${func}",isEvent:${!!rpc.isEvent},queue:"${rpc.queue || ""}"}
@@ -281,16 +275,17 @@ var RPCGenerator = (_class2 = class extends Generator {constructor(...args2) { s
281
275
  }
282
276
  generateCode(meta) {
283
277
  for (const i of meta) {
284
- if (i.controller === "rpc")
285
- this.addMethod(i);
278
+ if (i.controller === "rpc") this.addMethod(i);
286
279
  }
287
280
  return this.getContent();
288
281
  }
289
282
  }, _class2);
290
- _chunkFNJWO324js.__name.call(void 0, RPCGenerator, "RPCGenerator");
291
283
 
292
284
  // src/generator/http.ts
293
- var HTTPGenerator = (_class3 = class extends Generator {constructor(...args3) { super(...args3); _class3.prototype.__init4.call(this);_class3.prototype.__init5.call(this); }
285
+ var HTTPGenerator = (_class3 = class extends Generator {constructor(...args4) { super(...args4); _class3.prototype.__init4.call(this);_class3.prototype.__init5.call(this); }
286
+ static {
287
+ _chunkRVWBJ6LVjs.__name.call(void 0, this, "HTTPGenerator");
288
+ }
294
289
  __init4() {this.name = "HTTP"}
295
290
  __init5() {this.classMap = {}}
296
291
  getContent() {
@@ -305,11 +300,9 @@ var HTTPGenerator = (_class3 = class extends Generator {constructor(...args3) {
305
300
  }
306
301
  addMethod(args) {
307
302
  const { http, name, func, params, tag } = args;
308
- if (!_optionalChain([http, 'optionalAccess', _2 => _2.type]))
309
- return;
303
+ if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) return;
310
304
  const url = http.prefix + http.route.replace(/\/\:([^\/]*)/g, (_, js) => `/{{${js}}}`);
311
- if (!this.classMap[name])
312
- this.classMap[name] = {};
305
+ if (!this.classMap[name]) this.classMap[name] = {};
313
306
  this.classMap[name][func] = `
314
307
  ${func}(...args){
315
308
  const ret={tag:"${tag}",func:"${func}",body:{},headers:{},query:{},params:{},method:"${http.type}",url:"${url}",args}
@@ -323,13 +316,11 @@ return ret
323
316
  }
324
317
  generateCode(meta) {
325
318
  for (const i of meta) {
326
- if (i.controller === "http")
327
- this.addMethod(i);
319
+ if (i.controller === "http") this.addMethod(i);
328
320
  }
329
321
  return this.getContent();
330
322
  }
331
323
  }, _class3);
332
- _chunkFNJWO324js.__name.call(void 0, HTTPGenerator, "HTTPGenerator");
333
324
 
334
325
  // src/index.ts
335
326
 
@@ -407,4 +398,4 @@ _chunkFNJWO324js.__name.call(void 0, HTTPGenerator, "HTTPGenerator");
407
398
 
408
399
 
409
400
 
410
- exports.Arg = _chunkAWY6FTH4js.Arg; exports.BadGatewayException = _chunkH6NYBVBVjs.BadGatewayException; exports.BadRequestException = _chunkH6NYBVBVjs.BadRequestException; exports.BaseParam = _chunkAWY6FTH4js.BaseParam; exports.Body = _chunkAWY6FTH4js.Body; exports.ConflictException = _chunkH6NYBVBVjs.ConflictException; exports.Context = _chunkH6NYBVBVjs.Context; exports.Controller = _chunkAWY6FTH4js.Controller; exports.Ctx = _chunkAWY6FTH4js.Ctx; exports.CustomResponse = CustomResponse; exports.Define = _chunkAWY6FTH4js.Define; exports.Delete = _chunkAWY6FTH4js.Delete; exports.Dev = Dev; exports.ERROR_SYMBOL = _chunkFNJWO324js.ERROR_SYMBOL; exports.Event = _chunkAWY6FTH4js.Event; exports.Exception = _chunkH6NYBVBVjs.Exception; exports.Factory = _chunkUJAI73O6js.Factory; exports.Filter = _chunkAWY6FTH4js.Filter; exports.ForbiddenException = _chunkH6NYBVBVjs.ForbiddenException; exports.FrameworkException = _chunkH6NYBVBVjs.FrameworkException; exports.Generator = Generator; exports.Get = _chunkAWY6FTH4js.Get; exports.Guard = _chunkAWY6FTH4js.Guard; exports.HTTPGenerator = HTTPGenerator; exports.Head = _chunkAWY6FTH4js.Head; exports.Header = _chunkAWY6FTH4js.Header; exports.IS_HMR = _chunkFNJWO324js.IS_HMR; exports.IS_ONLY_GENERATE = _chunkFNJWO324js.IS_ONLY_GENERATE; exports.IS_STRICT = _chunkFNJWO324js.IS_STRICT; exports.Injectable = _chunkAWY6FTH4js.Injectable; exports.Interceptor = _chunkAWY6FTH4js.Interceptor; exports.InvalidInputException = _chunkH6NYBVBVjs.InvalidInputException; exports.LOG_LEVEL = _chunkFNJWO324js.LOG_LEVEL; exports.Meta = _chunkUJAI73O6js.Meta; exports.Mix = _chunkFNJWO324js.Mix; exports.NotFoundException = _chunkH6NYBVBVjs.NotFoundException; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PPlugin = PPlugin; exports.PS_EXIT_CODE = _chunkFNJWO324js.PS_EXIT_CODE; exports.Param = _chunkAWY6FTH4js.Param; exports.Patch = _chunkAWY6FTH4js.Patch; exports.PayloadLargeException = _chunkH6NYBVBVjs.PayloadLargeException; exports.Pipe = _chunkAWY6FTH4js.Pipe; exports.Plugin = _chunkAWY6FTH4js.Plugin; exports.Post = _chunkAWY6FTH4js.Post; exports.Put = _chunkAWY6FTH4js.Put; exports.Query = _chunkAWY6FTH4js.Query; exports.Queue = _chunkAWY6FTH4js.Queue; exports.RPCGenerator = RPCGenerator; exports.Route = _chunkAWY6FTH4js.Route; exports.Rpc = _chunkAWY6FTH4js.Rpc; exports.ServiceUnavailableException = _chunkH6NYBVBVjs.ServiceUnavailableException; exports.TimeoutException = _chunkH6NYBVBVjs.TimeoutException; exports.TimerException = _chunkH6NYBVBVjs.TimerException; exports.UNMOUNT_SYMBOL = _chunkFNJWO324js.UNMOUNT_SYMBOL; exports.UnauthorizedException = _chunkH6NYBVBVjs.UnauthorizedException; exports.UndefinedException = _chunkH6NYBVBVjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkH6NYBVBVjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkH6NYBVBVjs.ValidateException; exports.WorkerException = _chunkH6NYBVBVjs.WorkerException; exports.addFilter = _chunkH6NYBVBVjs.addFilter; exports.addGuard = _chunkH6NYBVBVjs.addGuard; exports.addInterceptor = _chunkH6NYBVBVjs.addInterceptor; exports.addPipe = _chunkH6NYBVBVjs.addPipe; exports.addPlugin = _chunkH6NYBVBVjs.addPlugin; exports.defaultPipe = _chunkH6NYBVBVjs.defaultPipe; exports.emitter = _chunkUJAI73O6js.emitter; exports.log = _chunkFNJWO324js.log; exports.setLogger = _chunkFNJWO324js.setLogger;
401
+ exports.Arg = _chunkAUAAKHWSjs.Arg; exports.BadGatewayException = _chunkQYX5Q7KOjs.BadGatewayException; exports.BadRequestException = _chunkQYX5Q7KOjs.BadRequestException; exports.BaseParam = _chunkAUAAKHWSjs.BaseParam; exports.Body = _chunkAUAAKHWSjs.Body; exports.ConflictException = _chunkQYX5Q7KOjs.ConflictException; exports.Context = _chunkQYX5Q7KOjs.Context; exports.Controller = _chunkAUAAKHWSjs.Controller; exports.Ctx = _chunkAUAAKHWSjs.Ctx; exports.CustomResponse = CustomResponse; exports.Define = _chunkAUAAKHWSjs.Define; exports.Delete = _chunkAUAAKHWSjs.Delete; exports.ERROR_SYMBOL = _chunkRVWBJ6LVjs.ERROR_SYMBOL; exports.Event = _chunkAUAAKHWSjs.Event; exports.Exception = _chunkQYX5Q7KOjs.Exception; exports.Factory = _chunkN4ULJDEQjs.Factory; exports.Filter = _chunkAUAAKHWSjs.Filter; exports.ForbiddenException = _chunkQYX5Q7KOjs.ForbiddenException; exports.FrameworkException = _chunkQYX5Q7KOjs.FrameworkException; exports.Generator = Generator; exports.Get = _chunkAUAAKHWSjs.Get; exports.Guard = _chunkAUAAKHWSjs.Guard; exports.HTTPGenerator = HTTPGenerator; exports.Head = _chunkAUAAKHWSjs.Head; exports.Header = _chunkAUAAKHWSjs.Header; exports.IS_HMR = _chunkRVWBJ6LVjs.IS_HMR; exports.IS_ONLY_GENERATE = _chunkRVWBJ6LVjs.IS_ONLY_GENERATE; exports.IS_STRICT = _chunkRVWBJ6LVjs.IS_STRICT; exports.Injectable = _chunkAUAAKHWSjs.Injectable; exports.Interceptor = _chunkAUAAKHWSjs.Interceptor; exports.InvalidInputException = _chunkQYX5Q7KOjs.InvalidInputException; exports.LOG_LEVEL = _chunkRVWBJ6LVjs.LOG_LEVEL; exports.Meta = _chunkN4ULJDEQjs.Meta; exports.Mix = _chunkRVWBJ6LVjs.Mix; exports.NotFoundException = _chunkQYX5Q7KOjs.NotFoundException; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PPlugin = PPlugin; exports.PS_EXIT_CODE = _chunkRVWBJ6LVjs.PS_EXIT_CODE; exports.Param = _chunkAUAAKHWSjs.Param; exports.Patch = _chunkAUAAKHWSjs.Patch; exports.PayloadLargeException = _chunkQYX5Q7KOjs.PayloadLargeException; exports.Pipe = _chunkAUAAKHWSjs.Pipe; exports.Plugin = _chunkAUAAKHWSjs.Plugin; exports.Post = _chunkAUAAKHWSjs.Post; exports.Put = _chunkAUAAKHWSjs.Put; exports.Query = _chunkAUAAKHWSjs.Query; exports.Queue = _chunkAUAAKHWSjs.Queue; exports.RPCGenerator = RPCGenerator; exports.Route = _chunkAUAAKHWSjs.Route; exports.Rpc = _chunkAUAAKHWSjs.Rpc; exports.ServerBase = ServerBase; exports.ServiceUnavailableException = _chunkQYX5Q7KOjs.ServiceUnavailableException; exports.TimeoutException = _chunkQYX5Q7KOjs.TimeoutException; exports.TimerException = _chunkQYX5Q7KOjs.TimerException; exports.UnauthorizedException = _chunkQYX5Q7KOjs.UnauthorizedException; exports.UndefinedException = _chunkQYX5Q7KOjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkQYX5Q7KOjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkQYX5Q7KOjs.ValidateException; exports.WorkerException = _chunkQYX5Q7KOjs.WorkerException; exports.addFilter = _chunkQYX5Q7KOjs.addFilter; exports.addGuard = _chunkQYX5Q7KOjs.addGuard; exports.addInterceptor = _chunkQYX5Q7KOjs.addInterceptor; exports.addPipe = _chunkQYX5Q7KOjs.addPipe; exports.addPlugin = _chunkQYX5Q7KOjs.addPlugin; exports.createPhecda = _chunkN4ULJDEQjs.createPhecda; exports.defaultPipe = _chunkQYX5Q7KOjs.defaultPipe; exports.emitter = _chunkN4ULJDEQjs.emitter; exports.log = _chunkRVWBJ6LVjs.log; exports.setLogger = _chunkRVWBJ6LVjs.setLogger;
package/dist/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  Factory,
3
3
  Meta,
4
+ createPhecda,
4
5
  emitter
5
- } from "./chunk-LGP5AT6W.mjs";
6
+ } from "./chunk-LHLQIQPH.mjs";
6
7
  import {
7
8
  Arg,
8
9
  BaseParam,
@@ -29,7 +30,7 @@ import {
29
30
  Queue,
30
31
  Route,
31
32
  Rpc
32
- } from "./chunk-IJNA24EZ.mjs";
33
+ } from "./chunk-5E2AVYP2.mjs";
33
34
  import {
34
35
  BadGatewayException,
35
36
  BadRequestException,
@@ -55,7 +56,7 @@ import {
55
56
  addPipe,
56
57
  addPlugin,
57
58
  defaultPipe
58
- } from "./chunk-Q4AGVGVA.mjs";
59
+ } from "./chunk-BZKJ5NBU.mjs";
59
60
  import {
60
61
  ERROR_SYMBOL,
61
62
  IS_HMR,
@@ -64,64 +65,46 @@ import {
64
65
  LOG_LEVEL,
65
66
  Mix,
66
67
  PS_EXIT_CODE,
67
- UNMOUNT_SYMBOL,
68
68
  __name,
69
69
  log,
70
70
  setLogger
71
- } from "./chunk-VYDBNZJ2.mjs";
71
+ } from "./chunk-MESZCLSS.mjs";
72
72
 
73
73
  // src/types.ts
74
74
  var ResponseSymbol = Symbol("response");
75
75
  var CustomResponse = class {
76
+ static {
77
+ __name(this, "CustomResponse");
78
+ }
76
79
  [ResponseSymbol];
77
80
  };
78
- __name(CustomResponse, "CustomResponse");
79
81
 
80
- // src/modules/dev.ts
81
- import { Empty, Unmount } from "phecda-core";
82
+ // src/modules/base.ts
83
+ import { Base, Empty } from "phecda-core";
82
84
  function _ts_decorate(decorators, target, key, desc) {
83
85
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
84
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
85
- r = Reflect.decorate(decorators, target, key, desc);
86
- else
87
- for (var i = decorators.length - 1; i >= 0; i--)
88
- if (d = decorators[i])
89
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
86
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
87
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
90
88
  return c > 3 && r && Object.defineProperty(target, key, r), r;
91
89
  }
92
90
  __name(_ts_decorate, "_ts_decorate");
93
- function _ts_metadata(k, v) {
94
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
95
- return Reflect.metadata(k, v);
96
- }
97
- __name(_ts_metadata, "_ts_metadata");
98
- var Dev = class {
99
- [UNMOUNT_SYMBOL] = [];
100
- context;
101
- // work for hmr
102
- // exec callback when module unmount
103
- onUnmount(cb) {
104
- this[UNMOUNT_SYMBOL].push(cb);
105
- }
106
- async unmount() {
107
- for (const cb of this[UNMOUNT_SYMBOL])
108
- await cb();
91
+ var ServerBase = class extends Base {
92
+ static {
93
+ __name(this, "ServerBase");
109
94
  }
95
+ context;
96
+ emitter = emitter;
110
97
  };
111
- __name(Dev, "Dev");
112
- _ts_decorate([
113
- Unmount,
114
- _ts_metadata("design:type", Function),
115
- _ts_metadata("design:paramtypes", []),
116
- _ts_metadata("design:returntype", Promise)
117
- ], Dev.prototype, "unmount", null);
118
- Dev = _ts_decorate([
98
+ ServerBase = _ts_decorate([
119
99
  Empty
120
- ], Dev);
100
+ ], ServerBase);
121
101
 
122
102
  // src/modules/filter.ts
123
103
  import { getTag } from "phecda-core";
124
- var PFilter = class extends Dev {
104
+ var PFilter = class extends ServerBase {
105
+ static {
106
+ __name(this, "PFilter");
107
+ }
125
108
  key;
126
109
  constructor(tag) {
127
110
  super();
@@ -132,11 +115,13 @@ var PFilter = class extends Dev {
132
115
  });
133
116
  }
134
117
  };
135
- __name(PFilter, "PFilter");
136
118
 
137
119
  // src/modules/guard.ts
138
120
  import { getTag as getTag2 } from "phecda-core";
139
- var PGuard = class extends Dev {
121
+ var PGuard = class extends ServerBase {
122
+ static {
123
+ __name(this, "PGuard");
124
+ }
140
125
  key;
141
126
  constructor(tag) {
142
127
  super();
@@ -147,11 +132,13 @@ var PGuard = class extends Dev {
147
132
  });
148
133
  }
149
134
  };
150
- __name(PGuard, "PGuard");
151
135
 
152
136
  // src/modules/interceptor.ts
153
137
  import { getTag as getTag3 } from "phecda-core";
154
- var PInterceptor = class extends Dev {
138
+ var PInterceptor = class extends ServerBase {
139
+ static {
140
+ __name(this, "PInterceptor");
141
+ }
155
142
  key;
156
143
  constructor(tag) {
157
144
  super();
@@ -162,11 +149,13 @@ var PInterceptor = class extends Dev {
162
149
  addInterceptor(this.key, this.use.bind(this));
163
150
  }
164
151
  };
165
- __name(PInterceptor, "PInterceptor");
166
152
 
167
153
  // src/modules/pipe.ts
168
154
  import { getTag as getTag4 } from "phecda-core";
169
- var PPipe = class extends Dev {
155
+ var PPipe = class extends ServerBase {
156
+ static {
157
+ __name(this, "PPipe");
158
+ }
170
159
  key;
171
160
  constructor(tag) {
172
161
  super();
@@ -177,11 +166,13 @@ var PPipe = class extends Dev {
177
166
  });
178
167
  }
179
168
  };
180
- __name(PPipe, "PPipe");
181
169
 
182
170
  // src/modules/plugin.ts
183
171
  import { getTag as getTag5 } from "phecda-core";
184
- var PPlugin = class extends Dev {
172
+ var PPlugin = class extends ServerBase {
173
+ static {
174
+ __name(this, "PPlugin");
175
+ }
185
176
  key;
186
177
  constructor(tag) {
187
178
  super();
@@ -192,11 +183,13 @@ var PPlugin = class extends Dev {
192
183
  });
193
184
  }
194
185
  };
195
- __name(PPlugin, "PPlugin");
196
186
 
197
187
  // src/modules/extension.ts
198
188
  import { getTag as getTag6 } from "phecda-core";
199
- var PExtension = class extends Dev {
189
+ var PExtension = class extends ServerBase {
190
+ static {
191
+ __name(this, "PExtension");
192
+ }
200
193
  key;
201
194
  constructor(tag) {
202
195
  super();
@@ -233,15 +226,16 @@ var PExtension = class extends Dev {
233
226
  }
234
227
  }
235
228
  };
236
- __name(PExtension, "PExtension");
237
229
 
238
230
  // src/generator/utils.ts
239
231
  import fse from "fs-extra";
240
232
  var Generator = class {
233
+ static {
234
+ __name(this, "Generator");
235
+ }
241
236
  _path;
242
237
  constructor(path) {
243
- if (path)
244
- this._path = path;
238
+ if (path) this._path = path;
245
239
  }
246
240
  get path() {
247
241
  return this._path || `.ps/${this.name.toLowerCase()}.js`;
@@ -250,10 +244,12 @@ var Generator = class {
250
244
  await fse.outputFile(this.path, this.generateCode(meta.map((item) => item.data)));
251
245
  }
252
246
  };
253
- __name(Generator, "Generator");
254
247
 
255
248
  // src/generator/rpc.ts
256
249
  var RPCGenerator = class extends Generator {
250
+ static {
251
+ __name(this, "RPCGenerator");
252
+ }
257
253
  name = "RPC";
258
254
  classMap = {};
259
255
  getContent() {
@@ -268,10 +264,8 @@ var RPCGenerator = class extends Generator {
268
264
  }
269
265
  addMethod(args) {
270
266
  const { rpc, name, func, tag } = args;
271
- if (!rpc)
272
- return;
273
- if (!this.classMap[name])
274
- this.classMap[name] = {};
267
+ if (!rpc) return;
268
+ if (!this.classMap[name]) this.classMap[name] = {};
275
269
  this.classMap[name][func] = `
276
270
  ${func}(){
277
271
  return {tag:'${tag}',func:"${func}",isEvent:${!!rpc.isEvent},queue:"${rpc.queue || ""}"}
@@ -281,16 +275,17 @@ var RPCGenerator = class extends Generator {
281
275
  }
282
276
  generateCode(meta) {
283
277
  for (const i of meta) {
284
- if (i.controller === "rpc")
285
- this.addMethod(i);
278
+ if (i.controller === "rpc") this.addMethod(i);
286
279
  }
287
280
  return this.getContent();
288
281
  }
289
282
  };
290
- __name(RPCGenerator, "RPCGenerator");
291
283
 
292
284
  // src/generator/http.ts
293
285
  var HTTPGenerator = class extends Generator {
286
+ static {
287
+ __name(this, "HTTPGenerator");
288
+ }
294
289
  name = "HTTP";
295
290
  classMap = {};
296
291
  getContent() {
@@ -305,11 +300,9 @@ var HTTPGenerator = class extends Generator {
305
300
  }
306
301
  addMethod(args) {
307
302
  const { http, name, func, params, tag } = args;
308
- if (!http?.type)
309
- return;
303
+ if (!http?.type) return;
310
304
  const url = http.prefix + http.route.replace(/\/\:([^\/]*)/g, (_, js) => `/{{${js}}}`);
311
- if (!this.classMap[name])
312
- this.classMap[name] = {};
305
+ if (!this.classMap[name]) this.classMap[name] = {};
313
306
  this.classMap[name][func] = `
314
307
  ${func}(...args){
315
308
  const ret={tag:"${tag}",func:"${func}",body:{},headers:{},query:{},params:{},method:"${http.type}",url:"${url}",args}
@@ -323,13 +316,11 @@ return ret
323
316
  }
324
317
  generateCode(meta) {
325
318
  for (const i of meta) {
326
- if (i.controller === "http")
327
- this.addMethod(i);
319
+ if (i.controller === "http") this.addMethod(i);
328
320
  }
329
321
  return this.getContent();
330
322
  }
331
323
  };
332
- __name(HTTPGenerator, "HTTPGenerator");
333
324
 
334
325
  // src/index.ts
335
326
  export * from "phecda-core";
@@ -346,7 +337,6 @@ export {
346
337
  CustomResponse,
347
338
  Define,
348
339
  Delete,
349
- Dev,
350
340
  ERROR_SYMBOL,
351
341
  Event,
352
342
  Exception,
@@ -389,10 +379,10 @@ export {
389
379
  RPCGenerator,
390
380
  Route,
391
381
  Rpc,
382
+ ServerBase,
392
383
  ServiceUnavailableException,
393
384
  TimeoutException,
394
385
  TimerException,
395
- UNMOUNT_SYMBOL,
396
386
  UnauthorizedException,
397
387
  UndefinedException,
398
388
  UnsupportedMediaTypeException,
@@ -403,6 +393,7 @@ export {
403
393
  addInterceptor,
404
394
  addPipe,
405
395
  addPlugin,
396
+ createPhecda,
406
397
  defaultPipe,
407
398
  emitter,
408
399
  log,