phecda-server 5.2.1 → 5.2.3

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 (42) hide show
  1. package/bin/cli.mjs +25 -17
  2. package/dist/{chunk-VMLHTEW3.js → chunk-AWY6FTH4.js} +38 -38
  3. package/dist/{chunk-ZP7HNASU.js → chunk-FNJWO324.js} +1 -1
  4. package/dist/{chunk-BSE2DSDK.js → chunk-H6NYBVBV.js} +64 -64
  5. package/dist/{chunk-V3WIKOP3.mjs → chunk-IJNA24EZ.mjs} +2 -2
  6. package/dist/{chunk-5BVUCNMA.js → chunk-J5SL4QLN.js} +24 -21
  7. package/dist/{chunk-JE6BBDXW.mjs → chunk-Q4AGVGVA.mjs} +1 -1
  8. package/dist/{chunk-VLV3AO3H.mjs → chunk-VYDBNZJ2.mjs} +1 -1
  9. package/dist/{chunk-CKQW3FDK.mjs → chunk-YAVIRFUE.mjs} +7 -4
  10. package/dist/helper.js +3 -3
  11. package/dist/helper.mjs +2 -2
  12. package/dist/index.js +54 -48
  13. package/dist/index.mjs +20 -14
  14. package/dist/rpc/bullmq/index.js +12 -12
  15. package/dist/rpc/bullmq/index.mjs +2 -2
  16. package/dist/rpc/kafka/index.js +10 -10
  17. package/dist/rpc/kafka/index.mjs +2 -2
  18. package/dist/rpc/nats/index.js +12 -11
  19. package/dist/rpc/nats/index.mjs +3 -2
  20. package/dist/rpc/rabbitmq/index.js +13 -13
  21. package/dist/rpc/rabbitmq/index.mjs +2 -2
  22. package/dist/rpc/redis/index.js +11 -11
  23. package/dist/rpc/redis/index.mjs +2 -2
  24. package/dist/server/elysia/index.js +20 -20
  25. package/dist/server/elysia/index.mjs +3 -3
  26. package/dist/server/express/index.js +18 -18
  27. package/dist/server/express/index.mjs +2 -2
  28. package/dist/server/fastify/index.js +19 -19
  29. package/dist/server/fastify/index.mjs +3 -3
  30. package/dist/server/h3/index.js +16 -16
  31. package/dist/server/h3/index.mjs +2 -2
  32. package/dist/server/hono/index.js +17 -17
  33. package/dist/server/hono/index.mjs +2 -2
  34. package/dist/server/hyper-express/index.js +17 -17
  35. package/dist/server/hyper-express/index.mjs +2 -2
  36. package/dist/server/koa/index.js +18 -18
  37. package/dist/server/koa/index.mjs +2 -2
  38. package/dist/test.d.ts +1 -1
  39. package/dist/test.js +8 -8
  40. package/dist/test.mjs +2 -2
  41. package/package.json +1 -1
  42. package/register/loader.mjs +1 -1
package/bin/cli.mjs CHANGED
@@ -9,10 +9,9 @@ import cac from 'cac'
9
9
  import fse from 'fs-extra'
10
10
  import { log } from '../dist/index.mjs'
11
11
 
12
- const cli = cac('phecda')
13
- .option('-c,--config <config>', 'config file', {
14
- default: 'ps.json',
15
- })
12
+ const cli = cac('phecda').option('-c,--config <config>', 'config file', {
13
+ default: 'ps.json',
14
+ })
16
15
 
17
16
  const __dirname = dirname(fileURLToPath(import.meta.url))
18
17
 
@@ -75,19 +74,25 @@ process.on('SIGINT', () => {
75
74
  })
76
75
 
77
76
  cli
78
- .command('init [workdir]', 'init config file')
77
+ .command('init [root]', 'init config file')
79
78
  .allowUnknownOptions()
80
79
  .option('-t,--tsconfig <tsconfig>', 'init tsconfig file', {
81
80
  default: 'tsconfig.json',
82
81
  })
83
- .action(async (workdir, options) => {
84
- const tsconfigPath = join(workdir, options.tsconfig)
85
- const psconfigPath = join(workdir, options.config)
82
+ .action(async (root, options) => {
83
+ if (!root)
84
+ root = ''
85
+
86
+ const tsconfigPath = join(root, options.tsconfig)
87
+ const psconfigPath = join(root, options.config)
86
88
 
87
89
  if (!fse.existsSync(tsconfigPath)) {
88
90
  log(`create ${tsconfigPath}`)
89
91
 
90
- await fse.copyFile(resolve(__dirname, '../assets/tsconfig.json'), tsconfigPath)
92
+ await fse.copyFile(
93
+ resolve(__dirname, '../assets/tsconfig.json'),
94
+ tsconfigPath,
95
+ )
91
96
  }
92
97
 
93
98
  if (!fse.existsSync(psconfigPath)) {
@@ -95,15 +100,18 @@ cli
95
100
 
96
101
  await fse.copyFile(resolve(__dirname, '../assets/ps.json'), psconfigPath)
97
102
  }
103
+
104
+ log('init finish')
98
105
  })
99
106
 
100
107
  cli
101
- .command('<file> [workdir]', 'run file')
108
+ .command('<file> [root]', 'run file')
109
+ .alias('run')
102
110
  .allowUnknownOptions()
103
111
  .alias('run')
104
- .action((file, workdir, options) => {
105
- if (workdir)
106
- process.env.PS_WORKDIR = workdir
112
+ .action((file, root, options) => {
113
+ if (root)
114
+ process.env.PS_WORKDIR = root
107
115
  process.env.PS_CONFIG_FILE = options.config
108
116
 
109
117
  log('process start!')
@@ -134,11 +142,11 @@ cli
134
142
  })
135
143
 
136
144
  cli
137
- .command('generate <file> [workdir]', 'generate code(mainly for ci)')
145
+ .command('generate <file> [root]', 'generate code(mainly for ci)')
138
146
  .allowUnknownOptions()
139
- .action((file, workdir, options) => {
140
- if (workdir)
141
- process.env.PS_WORKDIR = workdir
147
+ .action((file, root, options) => {
148
+ if (root)
149
+ process.env.PS_WORKDIR = root
142
150
  process.env.PS_GENERATE = 'true'
143
151
  process.env.PS_CONFIG_FILE = options.config
144
152
  startChild(file, options['--'])
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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
3
 
4
- var _chunkBSE2DSDKjs = require('./chunk-BSE2DSDK.js');
4
+ var _chunkH6NYBVBVjs = require('./chunk-H6NYBVBV.js');
5
5
 
6
6
 
7
- var _chunkZP7HNASUjs = require('./chunk-ZP7HNASU.js');
7
+ var _chunkFNJWO324js = require('./chunk-FNJWO324.js');
8
8
 
9
9
  // src/decorators/param.ts
10
10
  var _phecdacore = require('phecda-core');
@@ -16,7 +16,7 @@ function BaseParam(data) {
16
16
  if (!state.params)
17
17
  state.params = [
18
18
  ..._optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _ => _.params]) || []
19
- ].map(_chunkBSE2DSDKjs.shallowClone);
19
+ ].map(_chunkH6NYBVBVjs.shallowClone);
20
20
  const existItem = state.params.find((item) => item.index === index);
21
21
  if (existItem)
22
22
  Object.assign(existItem, data);
@@ -28,42 +28,42 @@ function BaseParam(data) {
28
28
  });
29
29
  };
30
30
  }
31
- _chunkZP7HNASUjs.__name.call(void 0, BaseParam, "BaseParam");
31
+ _chunkFNJWO324js.__name.call(void 0, BaseParam, "BaseParam");
32
32
  function Body(key = "") {
33
33
  return BaseParam({
34
34
  type: "body",
35
35
  key
36
36
  });
37
37
  }
38
- _chunkZP7HNASUjs.__name.call(void 0, Body, "Body");
38
+ _chunkFNJWO324js.__name.call(void 0, Body, "Body");
39
39
  function Head(key) {
40
40
  return BaseParam({
41
41
  type: "headers",
42
42
  key: key.toLowerCase()
43
43
  });
44
44
  }
45
- _chunkZP7HNASUjs.__name.call(void 0, Head, "Head");
45
+ _chunkFNJWO324js.__name.call(void 0, Head, "Head");
46
46
  function Query(key = "") {
47
47
  return BaseParam({
48
48
  type: "query",
49
49
  key
50
50
  });
51
51
  }
52
- _chunkZP7HNASUjs.__name.call(void 0, Query, "Query");
52
+ _chunkFNJWO324js.__name.call(void 0, Query, "Query");
53
53
  function Param(key) {
54
54
  return BaseParam({
55
55
  type: "params",
56
56
  key
57
57
  });
58
58
  }
59
- _chunkZP7HNASUjs.__name.call(void 0, Param, "Param");
59
+ _chunkFNJWO324js.__name.call(void 0, Param, "Param");
60
60
  function Arg(target, k, index) {
61
61
  BaseParam({
62
62
  type: "args",
63
63
  key: `${index}`
64
64
  })(target, k, index);
65
65
  }
66
- _chunkZP7HNASUjs.__name.call(void 0, Arg, "Arg");
66
+ _chunkFNJWO324js.__name.call(void 0, Arg, "Arg");
67
67
 
68
68
  // src/decorators/aop.ts
69
69
 
@@ -82,7 +82,7 @@ function Guard(...guards) {
82
82
  });
83
83
  };
84
84
  }
85
- _chunkZP7HNASUjs.__name.call(void 0, Guard, "Guard");
85
+ _chunkFNJWO324js.__name.call(void 0, Guard, "Guard");
86
86
  function Plugin(...plugins) {
87
87
  return (target, k) => {
88
88
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
@@ -98,7 +98,7 @@ function Plugin(...plugins) {
98
98
  });
99
99
  };
100
100
  }
101
- _chunkZP7HNASUjs.__name.call(void 0, Plugin, "Plugin");
101
+ _chunkFNJWO324js.__name.call(void 0, Plugin, "Plugin");
102
102
  function Interceptor(...interceptors) {
103
103
  return (target, k) => {
104
104
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
@@ -114,13 +114,13 @@ function Interceptor(...interceptors) {
114
114
  });
115
115
  };
116
116
  }
117
- _chunkZP7HNASUjs.__name.call(void 0, Interceptor, "Interceptor");
117
+ _chunkFNJWO324js.__name.call(void 0, Interceptor, "Interceptor");
118
118
  function Filter(filter) {
119
119
  return (target, k) => {
120
120
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => state.filter = filter);
121
121
  };
122
122
  }
123
- _chunkZP7HNASUjs.__name.call(void 0, Filter, "Filter");
123
+ _chunkFNJWO324js.__name.call(void 0, Filter, "Filter");
124
124
  function Pipe(pipe) {
125
125
  return (target, k, index) => {
126
126
  if (typeof index === "number") {
@@ -132,87 +132,87 @@ function Pipe(pipe) {
132
132
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => state.pipe = pipe);
133
133
  };
134
134
  }
135
- _chunkZP7HNASUjs.__name.call(void 0, Pipe, "Pipe");
135
+ _chunkFNJWO324js.__name.call(void 0, Pipe, "Pipe");
136
136
 
137
137
  // src/decorators/http.ts
138
138
 
139
139
  function Route(route, type) {
140
140
  return (target, k) => {
141
141
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
142
- state.http = _chunkBSE2DSDKjs.mergeObject.call(void 0, state.http || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _5 => _5.http]), {
142
+ state.http = _chunkH6NYBVBVjs.mergeObject.call(void 0, state.http || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _5 => _5.http]), {
143
143
  route,
144
144
  type
145
145
  });
146
146
  });
147
147
  };
148
148
  }
149
- _chunkZP7HNASUjs.__name.call(void 0, Route, "Route");
149
+ _chunkFNJWO324js.__name.call(void 0, Route, "Route");
150
150
  function Header(headers) {
151
151
  return (target, k) => {
152
152
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
153
153
  if (!state.http)
154
- state.http = _chunkBSE2DSDKjs.mergeObject.call(void 0, _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _6 => _6.http]));
155
- state.http = _chunkBSE2DSDKjs.mergeObject.call(void 0, state.http, {
156
- headers: _chunkBSE2DSDKjs.mergeObject.call(void 0, _optionalChain([state, 'access', _7 => _7.http, 'optionalAccess', _8 => _8.headers]), headers)
154
+ state.http = _chunkH6NYBVBVjs.mergeObject.call(void 0, _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _6 => _6.http]));
155
+ state.http = _chunkH6NYBVBVjs.mergeObject.call(void 0, state.http, {
156
+ headers: _chunkH6NYBVBVjs.mergeObject.call(void 0, _optionalChain([state, 'access', _7 => _7.http, 'optionalAccess', _8 => _8.headers]), headers)
157
157
  });
158
158
  });
159
159
  };
160
160
  }
161
- _chunkZP7HNASUjs.__name.call(void 0, Header, "Header");
161
+ _chunkFNJWO324js.__name.call(void 0, Header, "Header");
162
162
  function Get(route = "") {
163
163
  return Route(route, "get");
164
164
  }
165
- _chunkZP7HNASUjs.__name.call(void 0, Get, "Get");
165
+ _chunkFNJWO324js.__name.call(void 0, Get, "Get");
166
166
  function Post(route = "") {
167
167
  return Route(route, "post");
168
168
  }
169
- _chunkZP7HNASUjs.__name.call(void 0, Post, "Post");
169
+ _chunkFNJWO324js.__name.call(void 0, Post, "Post");
170
170
  function Put(route = "") {
171
171
  return Route(route, "put");
172
172
  }
173
- _chunkZP7HNASUjs.__name.call(void 0, Put, "Put");
173
+ _chunkFNJWO324js.__name.call(void 0, Put, "Put");
174
174
  function Patch(route = "") {
175
175
  return Route(route, "patch");
176
176
  }
177
- _chunkZP7HNASUjs.__name.call(void 0, Patch, "Patch");
177
+ _chunkFNJWO324js.__name.call(void 0, Patch, "Patch");
178
178
  function Delete(route = "") {
179
179
  return Route(route, "delete");
180
180
  }
181
- _chunkZP7HNASUjs.__name.call(void 0, Delete, "Delete");
181
+ _chunkFNJWO324js.__name.call(void 0, Delete, "Delete");
182
182
  function Controller(prefix = "") {
183
183
  return (target) => {
184
184
  _phecdacore.setPropertyState.call(void 0, target, void 0, (state) => {
185
185
  state.controller = "http";
186
- state.http = _chunkBSE2DSDKjs.mergeObject.call(void 0, state.http || _optionalChain([_phecdacore.getState.call(void 0, target), 'optionalAccess', _9 => _9.http]), {
186
+ state.http = _chunkH6NYBVBVjs.mergeObject.call(void 0, state.http || _optionalChain([_phecdacore.getState.call(void 0, target), 'optionalAccess', _9 => _9.http]), {
187
187
  prefix
188
188
  });
189
189
  });
190
190
  };
191
191
  }
192
- _chunkZP7HNASUjs.__name.call(void 0, Controller, "Controller");
192
+ _chunkFNJWO324js.__name.call(void 0, Controller, "Controller");
193
193
 
194
194
  // src/decorators/rpc.ts
195
195
 
196
196
  function Event(isEvent = true) {
197
197
  return (target, k) => {
198
198
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
199
- state.rpc = _chunkBSE2DSDKjs.mergeObject.call(void 0, state.rpc || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _10 => _10.rpc]), {
199
+ state.rpc = _chunkH6NYBVBVjs.mergeObject.call(void 0, state.rpc || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _10 => _10.rpc]), {
200
200
  isEvent
201
201
  });
202
202
  });
203
203
  };
204
204
  }
205
- _chunkZP7HNASUjs.__name.call(void 0, Event, "Event");
205
+ _chunkFNJWO324js.__name.call(void 0, Event, "Event");
206
206
  function Queue(queue = "") {
207
207
  return (target, k) => {
208
208
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
209
- state.rpc = _chunkBSE2DSDKjs.mergeObject.call(void 0, state.rpc || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _11 => _11.rpc]), {
209
+ state.rpc = _chunkH6NYBVBVjs.mergeObject.call(void 0, state.rpc || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _11 => _11.rpc]), {
210
210
  queue
211
211
  });
212
212
  });
213
213
  };
214
214
  }
215
- _chunkZP7HNASUjs.__name.call(void 0, Queue, "Queue");
215
+ _chunkFNJWO324js.__name.call(void 0, Queue, "Queue");
216
216
  function Rpc() {
217
217
  return (target) => {
218
218
  _phecdacore.setPropertyState.call(void 0, target, void 0, (state) => {
@@ -220,15 +220,15 @@ function Rpc() {
220
220
  });
221
221
  };
222
222
  }
223
- _chunkZP7HNASUjs.__name.call(void 0, Rpc, "Rpc");
223
+ _chunkFNJWO324js.__name.call(void 0, Rpc, "Rpc");
224
224
 
225
225
  // src/decorators/ctx.ts
226
226
 
227
227
  function Injectable() {
228
228
  return (target) => _phecdacore.Empty.call(void 0, target);
229
229
  }
230
- _chunkZP7HNASUjs.__name.call(void 0, Injectable, "Injectable");
231
- var Ctx = /* @__PURE__ */ _chunkZP7HNASUjs.__name.call(void 0, (target, key) => {
230
+ _chunkFNJWO324js.__name.call(void 0, Injectable, "Injectable");
231
+ var Ctx = /* @__PURE__ */ _chunkFNJWO324js.__name.call(void 0, (target, key) => {
232
232
  _phecdacore.setPropertyState.call(void 0, target, _phecdacore.SHARE_KEY, (state) => {
233
233
  if (!state.ctxs)
234
234
  state.ctxs = /* @__PURE__ */ new Set([
@@ -245,10 +245,10 @@ function Define(key, value) {
245
245
  if (!state.params)
246
246
  state.params = [
247
247
  ...parentState
248
- ].map(_chunkBSE2DSDKjs.shallowClone);
248
+ ].map(_chunkH6NYBVBVjs.shallowClone);
249
249
  const existItem = state.params.find((item) => item.index === index);
250
250
  if (existItem)
251
- existItem.define = _chunkBSE2DSDKjs.mergeObject.call(void 0, existItem.define, {
251
+ existItem.define = _chunkH6NYBVBVjs.mergeObject.call(void 0, existItem.define, {
252
252
  [key]: value
253
253
  });
254
254
  else
@@ -264,12 +264,12 @@ function Define(key, value) {
264
264
  _phecdacore.setPropertyState.call(void 0, target, k, (state) => {
265
265
  const parentState = _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _14 => _14.define]);
266
266
  if (!state.define)
267
- state.define = _chunkBSE2DSDKjs.mergeObject.call(void 0, parentState);
267
+ state.define = _chunkH6NYBVBVjs.mergeObject.call(void 0, parentState);
268
268
  state.define[key] = value;
269
269
  });
270
270
  };
271
271
  }
272
- _chunkZP7HNASUjs.__name.call(void 0, Define, "Define");
272
+ _chunkFNJWO324js.__name.call(void 0, Define, "Define");
273
273
 
274
274
 
275
275
 
@@ -42,7 +42,7 @@ function log(msg, level = "log") {
42
42
  warn: "yellow",
43
43
  log: "green"
44
44
  }[level];
45
- const date = new Date();
45
+ const date = /* @__PURE__ */ new Date();
46
46
  const current = Date.now();
47
47
  const interval = time && current - time ? `+${current - time}` : "";
48
48
  time = current;