phecda-server 5.0.0-beta.31 → 5.0.0-beta.33
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.
- package/bin/cli.mjs +189 -0
- package/bin/schema.json +48 -0
- package/dist/{chunk-XCOZROAD.mjs → chunk-73I24DQB.mjs} +10 -5
- package/dist/{chunk-3BNP77AS.mjs → chunk-CMPQPS47.mjs} +1 -1
- package/dist/chunk-F5YWXY5W.js +252 -0
- package/dist/{chunk-76A2C5MK.js → chunk-INIUC4CX.js} +2 -2
- package/dist/{chunk-77NDBQUP.mjs → chunk-ITTD2GBR.mjs} +2 -4
- package/dist/{chunk-D43Y5B7X.js → chunk-MAXJYJDI.js} +3 -3
- package/dist/{chunk-DWVJG3GB.mjs → chunk-N3H5Q64U.mjs} +1 -1
- package/dist/{chunk-MNFNPNPN.js → chunk-PPWMPM3L.js} +61 -56
- package/dist/chunk-QA2ACJXC.js +304 -0
- package/dist/{chunk-JHNFTTTI.mjs → chunk-RCTOVYZY.mjs} +68 -169
- package/dist/{chunk-2F5GI3TP.js → chunk-SKQSX262.js} +3 -3
- package/dist/chunk-UKGE77X6.mjs +304 -0
- package/dist/{chunk-JI4JFZJ6.mjs → chunk-WCX6N5VH.mjs} +1 -1
- package/dist/{chunk-ZD3QIREU.js → chunk-YR5Q5F2K.js} +2 -4
- package/dist/{core-5b4022e6.d.ts → core-eb319626.d.ts} +26 -12
- package/dist/{helper-338f2427.d.ts → helper-1ec9374b.d.ts} +2 -2
- package/dist/index.d.ts +40 -21
- package/dist/index.js +132 -41
- package/dist/index.mjs +108 -17
- package/dist/rpc/bullmq/index.d.ts +1 -1
- package/dist/rpc/bullmq/index.js +98 -90
- package/dist/rpc/bullmq/index.mjs +88 -80
- package/dist/rpc/kafka/index.d.ts +1 -1
- package/dist/rpc/kafka/index.js +38 -32
- package/dist/rpc/kafka/index.mjs +26 -20
- package/dist/rpc/nats/index.d.ts +1 -1
- package/dist/rpc/nats/index.js +97 -89
- package/dist/rpc/nats/index.mjs +87 -79
- package/dist/rpc/rabbitmq/index.d.ts +1 -1
- package/dist/rpc/rabbitmq/index.js +38 -32
- package/dist/rpc/rabbitmq/index.mjs +24 -18
- package/dist/rpc/redis/index.d.ts +1 -1
- package/dist/rpc/redis/index.js +33 -27
- package/dist/rpc/redis/index.mjs +21 -15
- package/dist/server/elysia/index.d.ts +3 -3
- package/dist/server/elysia/index.js +83 -80
- package/dist/server/elysia/index.mjs +67 -64
- package/dist/server/express/index.d.ts +2 -2
- package/dist/server/express/index.js +87 -83
- package/dist/server/express/index.mjs +73 -69
- package/dist/server/fastify/index.d.ts +3 -3
- package/dist/server/fastify/index.js +92 -88
- package/dist/server/fastify/index.mjs +76 -72
- package/dist/server/h3/index.d.ts +1 -1
- package/dist/server/h3/index.js +83 -81
- package/dist/server/h3/index.mjs +69 -67
- package/dist/server/hono/index.d.ts +2 -2
- package/dist/server/hono/index.js +83 -79
- package/dist/server/hono/index.mjs +69 -65
- package/dist/server/hyper-express/index.d.ts +2 -2
- package/dist/server/hyper-express/index.js +91 -87
- package/dist/server/hyper-express/index.mjs +77 -73
- package/dist/server/koa/index.d.ts +2 -2
- package/dist/server/koa/index.js +84 -80
- package/dist/server/koa/index.mjs +70 -66
- package/dist/test.d.ts +1 -1
- package/dist/test.js +7 -7
- package/dist/test.mjs +3 -3
- package/package.json +4 -4
- package/register/loader.mjs +64 -44
- package/register/utils.mjs +28 -29
- package/bin/cli.js +0 -132
- package/dist/chunk-2YCQAPMD.js +0 -245
- package/dist/chunk-BE5ZBJ2W.js +0 -353
- package/dist/chunk-QVXVOOUG.mjs +0 -245
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkYR5Q5F2Kjs = require('./chunk-YR5Q5F2K.js');
|
|
10
10
|
|
|
11
11
|
// src/exception/base.ts
|
|
12
12
|
var Exception = class extends Error {
|
|
@@ -24,11 +24,11 @@ var Exception = class extends Error {
|
|
|
24
24
|
message: this.message,
|
|
25
25
|
description: this.description,
|
|
26
26
|
status: this.status,
|
|
27
|
-
[
|
|
27
|
+
[_chunkYR5Q5F2Kjs.ERROR_SYMBOL]: true
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Exception, "Exception");
|
|
32
32
|
|
|
33
33
|
// src/exception/validate.ts
|
|
34
34
|
var ValidateException = class extends Exception {
|
|
@@ -36,11 +36,11 @@ var ValidateException = class extends Exception {
|
|
|
36
36
|
super(message, 400, "Validate exception");
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, ValidateException, "ValidateException");
|
|
40
40
|
|
|
41
41
|
// src/pipe.ts
|
|
42
42
|
var _phecdacore = require('phecda-core');
|
|
43
|
-
var defaultPipe = /* @__PURE__ */
|
|
43
|
+
var defaultPipe = /* @__PURE__ */ _chunkYR5Q5F2Kjs.__name.call(void 0, ({ arg, reflect, index }) => {
|
|
44
44
|
if (_phecdacore.isPhecda.call(void 0, reflect)) {
|
|
45
45
|
const instance = _phecdacore.plainToClass.call(void 0, reflect, arg);
|
|
46
46
|
const err = _phecdacore.transformInstance.call(void 0, instance);
|
|
@@ -68,7 +68,7 @@ var UndefinedException = class extends Exception {
|
|
|
68
68
|
super(message, 500, "Undefined error");
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
|
|
71
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, UndefinedException, "UndefinedException");
|
|
72
72
|
|
|
73
73
|
// src/exception/forbidden.ts
|
|
74
74
|
var ForbiddenException = class extends Exception {
|
|
@@ -76,7 +76,7 @@ var ForbiddenException = class extends Exception {
|
|
|
76
76
|
super(message, 403, "Forbidden resource");
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
|
|
79
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, ForbiddenException, "ForbiddenException");
|
|
80
80
|
|
|
81
81
|
// src/exception/bad-request.ts
|
|
82
82
|
var BadRequestException = class extends Exception {
|
|
@@ -84,7 +84,7 @@ var BadRequestException = class extends Exception {
|
|
|
84
84
|
super(message, 400, "Bad Request");
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
|
|
87
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, BadRequestException, "BadRequestException");
|
|
88
88
|
|
|
89
89
|
// src/exception/not-found.ts
|
|
90
90
|
var NotFoundException = class extends Exception {
|
|
@@ -92,7 +92,7 @@ var NotFoundException = class extends Exception {
|
|
|
92
92
|
super(message, 404, "Not Found");
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
|
-
|
|
95
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, NotFoundException, "NotFoundException");
|
|
96
96
|
|
|
97
97
|
// src/exception/conflict.ts
|
|
98
98
|
var ConflictException = class extends Exception {
|
|
@@ -100,7 +100,7 @@ var ConflictException = class extends Exception {
|
|
|
100
100
|
super(message, 409, "Conflict");
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
|
|
103
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, ConflictException, "ConflictException");
|
|
104
104
|
|
|
105
105
|
// src/exception/bad-gateway.ts
|
|
106
106
|
var BadGatewayException = class extends Exception {
|
|
@@ -108,7 +108,7 @@ var BadGatewayException = class extends Exception {
|
|
|
108
108
|
super(message, 502, "Bad Gatrway");
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
|
-
|
|
111
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, BadGatewayException, "BadGatewayException");
|
|
112
112
|
|
|
113
113
|
// src/exception/invalid-input.ts
|
|
114
114
|
var InvalidInputException = class extends Exception {
|
|
@@ -116,7 +116,7 @@ var InvalidInputException = class extends Exception {
|
|
|
116
116
|
super(message, 502, "Invalid Input");
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
|
-
|
|
119
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, InvalidInputException, "InvalidInputException");
|
|
120
120
|
|
|
121
121
|
// src/exception/media-type.ts
|
|
122
122
|
var UnsupportedMediaTypeException = class extends Exception {
|
|
@@ -124,7 +124,7 @@ var UnsupportedMediaTypeException = class extends Exception {
|
|
|
124
124
|
super(message, 415, "Unsupported Media Type");
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
|
-
|
|
127
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, UnsupportedMediaTypeException, "UnsupportedMediaTypeException");
|
|
128
128
|
|
|
129
129
|
// src/exception/payload-large.ts
|
|
130
130
|
var PayloadLargeException = class extends Exception {
|
|
@@ -132,7 +132,7 @@ var PayloadLargeException = class extends Exception {
|
|
|
132
132
|
super(message, 413, "Payload Too Large");
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
|
-
|
|
135
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, PayloadLargeException, "PayloadLargeException");
|
|
136
136
|
|
|
137
137
|
// src/exception/timeout.ts
|
|
138
138
|
var TimeoutException = class extends Exception {
|
|
@@ -140,7 +140,7 @@ var TimeoutException = class extends Exception {
|
|
|
140
140
|
super(message, 408, "Request Timeout");
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
|
|
143
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, TimeoutException, "TimeoutException");
|
|
144
144
|
|
|
145
145
|
// src/exception/unauthorized.ts
|
|
146
146
|
var UnauthorizedException = class extends Exception {
|
|
@@ -148,7 +148,7 @@ var UnauthorizedException = class extends Exception {
|
|
|
148
148
|
super(message, 401, "Unauthorized");
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
|
-
|
|
151
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, UnauthorizedException, "UnauthorizedException");
|
|
152
152
|
|
|
153
153
|
// src/exception/unavailable-service.ts
|
|
154
154
|
var ServiceUnavailableException = class extends Exception {
|
|
@@ -156,7 +156,7 @@ var ServiceUnavailableException = class extends Exception {
|
|
|
156
156
|
super(message, 503, "Service Unavailable");
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
|
-
|
|
159
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, ServiceUnavailableException, "ServiceUnavailableException");
|
|
160
160
|
|
|
161
161
|
// src/exception/framework.ts
|
|
162
162
|
var FrameworkException = class extends Exception {
|
|
@@ -164,7 +164,7 @@ var FrameworkException = class extends Exception {
|
|
|
164
164
|
super(`[phecda-server] ${message}`, 500, "Framework Error");
|
|
165
165
|
}
|
|
166
166
|
};
|
|
167
|
-
|
|
167
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, FrameworkException, "FrameworkException");
|
|
168
168
|
|
|
169
169
|
// src/exception/timer.ts
|
|
170
170
|
var TimerException = class extends Exception {
|
|
@@ -172,7 +172,7 @@ var TimerException = class extends Exception {
|
|
|
172
172
|
super(message, 0, "Timer Error");
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
|
-
|
|
175
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, TimerException, "TimerException");
|
|
176
176
|
|
|
177
177
|
// src/exception/worker.ts
|
|
178
178
|
var WorkerException = class extends Exception {
|
|
@@ -180,22 +180,22 @@ var WorkerException = class extends Exception {
|
|
|
180
180
|
super(message, 0, "Worker Error");
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
-
|
|
183
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, WorkerException, "WorkerException");
|
|
184
184
|
|
|
185
185
|
// src/context.ts
|
|
186
186
|
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
187
187
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
188
188
|
|
|
189
189
|
// src/filter.ts
|
|
190
|
-
var defaultFilter = /* @__PURE__ */
|
|
190
|
+
var defaultFilter = /* @__PURE__ */ _chunkYR5Q5F2Kjs.__name.call(void 0, (e) => {
|
|
191
191
|
if (!(e instanceof Exception)) {
|
|
192
|
-
|
|
193
|
-
if (
|
|
192
|
+
_chunkYR5Q5F2Kjs.log.call(void 0, e.message, "error");
|
|
193
|
+
if (_chunkYR5Q5F2Kjs.LOG_LEVEL <= 0)
|
|
194
194
|
console.error(e.stack);
|
|
195
195
|
e = new UndefinedException(e.message || e);
|
|
196
196
|
} else {
|
|
197
|
-
|
|
198
|
-
if (
|
|
197
|
+
_chunkYR5Q5F2Kjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
|
|
198
|
+
if (_chunkYR5Q5F2Kjs.LOG_LEVEL <= 0)
|
|
199
199
|
console.error(e.stack);
|
|
200
200
|
}
|
|
201
201
|
return e.data;
|
|
@@ -213,7 +213,7 @@ var Histroy = (_class = class {constructor() { _class.prototype.__init.call(this
|
|
|
213
213
|
return false;
|
|
214
214
|
}
|
|
215
215
|
}, _class);
|
|
216
|
-
|
|
216
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Histroy, "Histroy");
|
|
217
217
|
|
|
218
218
|
// src/context.ts
|
|
219
219
|
var debug = _debug2.default.call(void 0, "phecda-server(Context)");
|
|
@@ -226,13 +226,13 @@ var _Context = class {
|
|
|
226
226
|
constructor(data) {
|
|
227
227
|
this.data = data;
|
|
228
228
|
this.history = new Histroy();
|
|
229
|
-
if (
|
|
229
|
+
if (_chunkYR5Q5F2Kjs.IS_HMR)
|
|
230
230
|
data._context = this;
|
|
231
231
|
}
|
|
232
232
|
usePipe(args) {
|
|
233
233
|
return Promise.all(args.map((item) => {
|
|
234
234
|
if (item.pipe && !_Context.pipeRecord[item.pipe]) {
|
|
235
|
-
if (
|
|
235
|
+
if (_chunkYR5Q5F2Kjs.IS_STRICT) {
|
|
236
236
|
throw new FrameworkException(`can't find pipe named '${item.pipe}'`);
|
|
237
237
|
} else {
|
|
238
238
|
debug(`Can't find pipe named "${item.pipe}" when handling the ${item.index + 1}th argument of the func "${this.data.func}" on module "${this.data.tag}",use default pipe instead`);
|
|
@@ -244,7 +244,7 @@ var _Context = class {
|
|
|
244
244
|
}
|
|
245
245
|
useFilter(arg, filter = "default") {
|
|
246
246
|
if (!_Context.filterRecord[filter]) {
|
|
247
|
-
if (
|
|
247
|
+
if (_chunkYR5Q5F2Kjs.IS_STRICT) {
|
|
248
248
|
throw new FrameworkException(`can't find filter named "${filter}"`);
|
|
249
249
|
} else {
|
|
250
250
|
debug(`Can't find filter named "${filter}" when handling func "${this.data.func}" on module "${this.data.tag}",use default filter instead`);
|
|
@@ -257,7 +257,7 @@ var _Context = class {
|
|
|
257
257
|
for (const guard of guards) {
|
|
258
258
|
if (this.history.record(guard, "guard")) {
|
|
259
259
|
if (!(guard in _Context.guardRecord)) {
|
|
260
|
-
if (
|
|
260
|
+
if (_chunkYR5Q5F2Kjs.IS_STRICT)
|
|
261
261
|
throw new FrameworkException(`Can't find guard named "${guard}"`);
|
|
262
262
|
else
|
|
263
263
|
debug(`Can't find guard named "${guard}" when handling func "${this.data.func}" on module "${this.data.tag}",skip it`);
|
|
@@ -280,7 +280,7 @@ var _Context = class {
|
|
|
280
280
|
for (const interceptor of interceptors) {
|
|
281
281
|
if (this.history.record(interceptor, "interceptor")) {
|
|
282
282
|
if (!(interceptor in _Context.interceptorRecord)) {
|
|
283
|
-
if (
|
|
283
|
+
if (_chunkYR5Q5F2Kjs.IS_STRICT)
|
|
284
284
|
throw new FrameworkException(`can't find interceptor named "${interceptor}"`);
|
|
285
285
|
else
|
|
286
286
|
debug(`Can't find interceptor named "${interceptor}" when handling func "${this.data.func}" on module "${this.data.tag}",skip it`);
|
|
@@ -301,7 +301,7 @@ var _Context = class {
|
|
|
301
301
|
const ret = [];
|
|
302
302
|
for (const m of plugins) {
|
|
303
303
|
if (!(m in _Context.pluginRecord)) {
|
|
304
|
-
if (
|
|
304
|
+
if (_chunkYR5Q5F2Kjs.IS_STRICT)
|
|
305
305
|
throw new FrameworkException(`can't find middleware named '${m}'`);
|
|
306
306
|
continue;
|
|
307
307
|
}
|
|
@@ -311,55 +311,59 @@ var _Context = class {
|
|
|
311
311
|
}
|
|
312
312
|
};
|
|
313
313
|
var Context = _Context;
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Context, "Context");
|
|
315
|
+
_chunkYR5Q5F2Kjs.__publicField.call(void 0, Context, "filterRecord", {
|
|
316
316
|
default: defaultFilter
|
|
317
317
|
});
|
|
318
|
-
|
|
318
|
+
_chunkYR5Q5F2Kjs.__publicField.call(void 0, Context, "pipeRecord", {
|
|
319
319
|
default: defaultPipe
|
|
320
320
|
});
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
321
|
+
_chunkYR5Q5F2Kjs.__publicField.call(void 0, Context, "guardRecord", {});
|
|
322
|
+
_chunkYR5Q5F2Kjs.__publicField.call(void 0, Context, "interceptorRecord", {});
|
|
323
|
+
_chunkYR5Q5F2Kjs.__publicField.call(void 0, Context, "pluginRecord", {});
|
|
324
324
|
function addPlugin(key, handler) {
|
|
325
325
|
if (Context.pluginRecord[key] && Context.pluginRecord[key] !== handler)
|
|
326
|
-
|
|
326
|
+
_chunkYR5Q5F2Kjs.log.call(void 0, `overwrite Plugin "${String(key)}"`, "warn");
|
|
327
327
|
Context.pluginRecord[key] = handler;
|
|
328
328
|
}
|
|
329
|
-
|
|
329
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, addPlugin, "addPlugin");
|
|
330
330
|
function addPipe(key, handler) {
|
|
331
331
|
if (Context.pipeRecord[key] && Context.pipeRecord[key] !== handler)
|
|
332
|
-
|
|
332
|
+
_chunkYR5Q5F2Kjs.log.call(void 0, `overwrite Pipe "${String(key)}"`, "warn");
|
|
333
333
|
Context.pipeRecord[key] = handler;
|
|
334
334
|
}
|
|
335
|
-
|
|
335
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, addPipe, "addPipe");
|
|
336
336
|
function addFilter(key, handler) {
|
|
337
337
|
if (Context.filterRecord[key] && Context.filterRecord[key] !== handler)
|
|
338
|
-
|
|
338
|
+
_chunkYR5Q5F2Kjs.log.call(void 0, `overwrite Filter "${String(key)}"`, "warn");
|
|
339
339
|
Context.filterRecord[key] = handler;
|
|
340
340
|
}
|
|
341
|
-
|
|
341
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, addFilter, "addFilter");
|
|
342
342
|
function addGuard(key, handler) {
|
|
343
343
|
if (Context.guardRecord[key] && Context.guardRecord[key] !== handler)
|
|
344
|
-
|
|
344
|
+
_chunkYR5Q5F2Kjs.log.call(void 0, `overwrite Guard "${String(key)}"`, "warn");
|
|
345
345
|
Context.guardRecord[key] = handler;
|
|
346
346
|
}
|
|
347
|
-
|
|
347
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, addGuard, "addGuard");
|
|
348
348
|
function addInterceptor(key, handler) {
|
|
349
349
|
if (Context.interceptorRecord[key] && Context.interceptorRecord[key] !== handler)
|
|
350
|
-
|
|
350
|
+
_chunkYR5Q5F2Kjs.log.call(void 0, `overwrite Interceptor "${String(key)}"`, "warn");
|
|
351
351
|
Context.interceptorRecord[key] = handler;
|
|
352
352
|
}
|
|
353
|
-
|
|
354
|
-
function detectAopDep(meta, { guards, interceptors, plugins } = {},
|
|
353
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, addInterceptor, "addInterceptor");
|
|
354
|
+
function detectAopDep(meta, { guards, interceptors, plugins } = {}, controller = "http") {
|
|
355
355
|
const pluginSet = new Set(plugins);
|
|
356
356
|
const guardSet = new Set(guards);
|
|
357
357
|
const interceptorSet = new Set(interceptors);
|
|
358
358
|
const pipeSet = /* @__PURE__ */ new Set();
|
|
359
359
|
const filterSet = /* @__PURE__ */ new Set();
|
|
360
|
+
const warningSet = /* @__PURE__ */ new Set();
|
|
360
361
|
meta.forEach(({ data }) => {
|
|
361
|
-
if (
|
|
362
|
+
if (data.controller !== controller) {
|
|
363
|
+
if (data[controller])
|
|
364
|
+
warningSet.add(`Module "${data.tag === data.name ? data.name : `${data.name}(${data.tag})`}" should use ${controller} controller to decorate class or remove ${controller} decorator on method "${data.func}"`);
|
|
362
365
|
return;
|
|
366
|
+
}
|
|
363
367
|
if (data.filter)
|
|
364
368
|
filterSet.add(data.filter);
|
|
365
369
|
data.interceptors.forEach((i) => interceptorSet.add(i));
|
|
@@ -386,15 +390,16 @@ function detectAopDep(meta, { guards, interceptors, plugins } = {}, type = "http
|
|
|
386
390
|
...filterSet
|
|
387
391
|
].filter((i) => !Context.filterRecord[i]);
|
|
388
392
|
if (missPlugins.length)
|
|
389
|
-
|
|
393
|
+
_chunkYR5Q5F2Kjs.log.call(void 0, `${_picocolors2.default.white(`Plugin [${missPlugins.join(",")}]`)} doesn't exist`, "warn");
|
|
390
394
|
if (missGuards.length)
|
|
391
|
-
|
|
395
|
+
_chunkYR5Q5F2Kjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
|
|
392
396
|
if (missInterceptors.length)
|
|
393
|
-
|
|
397
|
+
_chunkYR5Q5F2Kjs.log.call(void 0, `${_picocolors2.default.cyan(`Interceptor [${missInterceptors.join(",")}]`)} doesn't exist`, "warn");
|
|
394
398
|
if (missPipes.length)
|
|
395
|
-
|
|
399
|
+
_chunkYR5Q5F2Kjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
|
|
396
400
|
if (missFilters.length)
|
|
397
|
-
|
|
401
|
+
_chunkYR5Q5F2Kjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
|
|
402
|
+
warningSet.forEach((warn) => _chunkYR5Q5F2Kjs.log.call(void 0, warn, "warn"));
|
|
398
403
|
return {
|
|
399
404
|
missPlugins,
|
|
400
405
|
missGuards,
|
|
@@ -403,7 +408,7 @@ function detectAopDep(meta, { guards, interceptors, plugins } = {}, type = "http
|
|
|
403
408
|
missFilters
|
|
404
409
|
};
|
|
405
410
|
}
|
|
406
|
-
|
|
411
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
407
412
|
|
|
408
413
|
|
|
409
414
|
|
|
@@ -0,0 +1,304 @@
|
|
|
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
|
+
|
|
3
|
+
var _chunkYR5Q5F2Kjs = require('./chunk-YR5Q5F2K.js');
|
|
4
|
+
|
|
5
|
+
// src/decorators/param.ts
|
|
6
|
+
var _phecdacore = require('phecda-core');
|
|
7
|
+
|
|
8
|
+
// src/decorators/utils.ts
|
|
9
|
+
function shallowClone(obj) {
|
|
10
|
+
return {
|
|
11
|
+
...obj
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, shallowClone, "shallowClone");
|
|
15
|
+
function mergeObject(...args) {
|
|
16
|
+
return Object.assign({}, ...args);
|
|
17
|
+
}
|
|
18
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, mergeObject, "mergeObject");
|
|
19
|
+
|
|
20
|
+
// src/decorators/param.ts
|
|
21
|
+
function BaseParam(data) {
|
|
22
|
+
return (target, k, index) => {
|
|
23
|
+
if (!k)
|
|
24
|
+
return;
|
|
25
|
+
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
26
|
+
if (!state.params)
|
|
27
|
+
state.params = [
|
|
28
|
+
..._optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _ => _.params]) || []
|
|
29
|
+
].map(shallowClone);
|
|
30
|
+
const existItem = state.params.find((item) => item.index === index);
|
|
31
|
+
if (existItem)
|
|
32
|
+
Object.assign(existItem, data);
|
|
33
|
+
else
|
|
34
|
+
state.params.push({
|
|
35
|
+
...data,
|
|
36
|
+
index
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, BaseParam, "BaseParam");
|
|
42
|
+
function Body(key = "") {
|
|
43
|
+
return BaseParam({
|
|
44
|
+
type: "body",
|
|
45
|
+
key
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Body, "Body");
|
|
49
|
+
function Head(key) {
|
|
50
|
+
return BaseParam({
|
|
51
|
+
type: "headers",
|
|
52
|
+
key: key.toLowerCase()
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Head, "Head");
|
|
56
|
+
function Query(key = "") {
|
|
57
|
+
return BaseParam({
|
|
58
|
+
type: "query",
|
|
59
|
+
key
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Query, "Query");
|
|
63
|
+
function Param(key) {
|
|
64
|
+
return BaseParam({
|
|
65
|
+
type: "params",
|
|
66
|
+
key
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Param, "Param");
|
|
70
|
+
function Arg() {
|
|
71
|
+
return BaseParam({
|
|
72
|
+
type: "params",
|
|
73
|
+
key: ""
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Arg, "Arg");
|
|
77
|
+
|
|
78
|
+
// src/decorators/aop.ts
|
|
79
|
+
|
|
80
|
+
function Guard(...guards) {
|
|
81
|
+
return (target, k) => {
|
|
82
|
+
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
83
|
+
if (!state.guards)
|
|
84
|
+
state.guards = /* @__PURE__ */ new Set([
|
|
85
|
+
..._optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _2 => _2.guards]) || []
|
|
86
|
+
]);
|
|
87
|
+
guards.forEach((guard) => {
|
|
88
|
+
if (state.guards.has(guard))
|
|
89
|
+
state.guards.delete(guard);
|
|
90
|
+
state.guards.add(guard);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Guard, "Guard");
|
|
96
|
+
function Plugin(...plugins) {
|
|
97
|
+
return (target, k) => {
|
|
98
|
+
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
99
|
+
if (!state.plugins)
|
|
100
|
+
state.plugins = /* @__PURE__ */ new Set([
|
|
101
|
+
..._optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _3 => _3.plugins]) || []
|
|
102
|
+
]);
|
|
103
|
+
plugins.forEach((plugin) => {
|
|
104
|
+
if (state.plugins.has(plugin))
|
|
105
|
+
state.plugins.delete(plugin);
|
|
106
|
+
state.plugins.add(plugin);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Plugin, "Plugin");
|
|
112
|
+
function Interceptor(...interceptors) {
|
|
113
|
+
return (target, k) => {
|
|
114
|
+
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
115
|
+
if (!state.interceptors)
|
|
116
|
+
state.interceptors = /* @__PURE__ */ new Set([
|
|
117
|
+
..._optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _4 => _4.interceptors]) || []
|
|
118
|
+
]);
|
|
119
|
+
interceptors.forEach((interceptor) => {
|
|
120
|
+
if (state.interceptors.has(interceptor))
|
|
121
|
+
state.interceptors.delete(interceptor);
|
|
122
|
+
state.interceptors.add(interceptor);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Interceptor, "Interceptor");
|
|
128
|
+
function Filter(filter) {
|
|
129
|
+
return (target, k) => {
|
|
130
|
+
_phecdacore.setPropertyState.call(void 0, target, k, (state) => state.filter = filter);
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Filter, "Filter");
|
|
134
|
+
function Pipe(pipe) {
|
|
135
|
+
return (target, k, index) => {
|
|
136
|
+
if (typeof index === "number") {
|
|
137
|
+
BaseParam({
|
|
138
|
+
pipe
|
|
139
|
+
})(target, k, index);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
_phecdacore.setPropertyState.call(void 0, target, k, (state) => state.pipe = pipe);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Pipe, "Pipe");
|
|
146
|
+
|
|
147
|
+
// src/decorators/http.ts
|
|
148
|
+
|
|
149
|
+
function Route(route, type) {
|
|
150
|
+
return (target, k) => {
|
|
151
|
+
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
152
|
+
state.http = mergeObject(state.http || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _5 => _5.http]), {
|
|
153
|
+
route,
|
|
154
|
+
type
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Route, "Route");
|
|
160
|
+
function Header(headers) {
|
|
161
|
+
return (target, k) => {
|
|
162
|
+
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
163
|
+
if (!state.http)
|
|
164
|
+
state.http = mergeObject(_optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _6 => _6.http]));
|
|
165
|
+
state.http = mergeObject(state.http, {
|
|
166
|
+
headers: mergeObject(_optionalChain([state, 'access', _7 => _7.http, 'optionalAccess', _8 => _8.headers]), headers)
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Header, "Header");
|
|
172
|
+
function Get(route = "") {
|
|
173
|
+
return Route(route, "get");
|
|
174
|
+
}
|
|
175
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Get, "Get");
|
|
176
|
+
function Post(route = "") {
|
|
177
|
+
return Route(route, "post");
|
|
178
|
+
}
|
|
179
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Post, "Post");
|
|
180
|
+
function Put(route = "") {
|
|
181
|
+
return Route(route, "put");
|
|
182
|
+
}
|
|
183
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Put, "Put");
|
|
184
|
+
function Patch(route = "") {
|
|
185
|
+
return Route(route, "patch");
|
|
186
|
+
}
|
|
187
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Patch, "Patch");
|
|
188
|
+
function Delete(route = "") {
|
|
189
|
+
return Route(route, "delete");
|
|
190
|
+
}
|
|
191
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Delete, "Delete");
|
|
192
|
+
function Controller(prefix = "") {
|
|
193
|
+
return (target) => {
|
|
194
|
+
_phecdacore.setPropertyState.call(void 0, target, void 0, (state) => {
|
|
195
|
+
state.controller = "http";
|
|
196
|
+
state.http = mergeObject(state.http || _optionalChain([_phecdacore.getState.call(void 0, target), 'optionalAccess', _9 => _9.http]), {
|
|
197
|
+
prefix
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Controller, "Controller");
|
|
203
|
+
|
|
204
|
+
// src/decorators/rpc.ts
|
|
205
|
+
|
|
206
|
+
function Event(isEvent = true) {
|
|
207
|
+
return (target, k) => {
|
|
208
|
+
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
209
|
+
state.rpc = mergeObject(state.rpc || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _10 => _10.rpc]), {
|
|
210
|
+
isEvent
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Event, "Event");
|
|
216
|
+
function Queue(queue = "") {
|
|
217
|
+
return (target, k) => {
|
|
218
|
+
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
219
|
+
state.rpc = mergeObject(state.rpc || _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _11 => _11.rpc]), {
|
|
220
|
+
queue
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Queue, "Queue");
|
|
226
|
+
function Rpc() {
|
|
227
|
+
return (target) => {
|
|
228
|
+
_phecdacore.setPropertyState.call(void 0, target, void 0, (state) => {
|
|
229
|
+
state.controller = "rpc";
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Rpc, "Rpc");
|
|
234
|
+
|
|
235
|
+
// src/decorators/index.ts
|
|
236
|
+
|
|
237
|
+
function Injectable() {
|
|
238
|
+
return (target) => _phecdacore.Empty.call(void 0, target);
|
|
239
|
+
}
|
|
240
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Injectable, "Injectable");
|
|
241
|
+
var Ctx = /* @__PURE__ */ _chunkYR5Q5F2Kjs.__name.call(void 0, (target, key) => {
|
|
242
|
+
_phecdacore.set.call(void 0, target, "context", key);
|
|
243
|
+
}, "Ctx");
|
|
244
|
+
function Define(key, value) {
|
|
245
|
+
return (target, k, index) => {
|
|
246
|
+
if (typeof index === "number") {
|
|
247
|
+
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
248
|
+
const parentState = _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _12 => _12.params]) || [];
|
|
249
|
+
if (!state.params)
|
|
250
|
+
state.params = [
|
|
251
|
+
...parentState
|
|
252
|
+
].map(shallowClone);
|
|
253
|
+
const existItem = state.params.find((item) => item.index === index);
|
|
254
|
+
if (existItem)
|
|
255
|
+
existItem.define = mergeObject(existItem.define, {
|
|
256
|
+
[key]: value
|
|
257
|
+
});
|
|
258
|
+
else
|
|
259
|
+
state.params.push({
|
|
260
|
+
define: {
|
|
261
|
+
[key]: value
|
|
262
|
+
},
|
|
263
|
+
index
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
_phecdacore.setPropertyState.call(void 0, target, k, (state) => {
|
|
269
|
+
const parentState = _optionalChain([_phecdacore.getState.call(void 0, target, k), 'optionalAccess', _13 => _13.define]);
|
|
270
|
+
if (!state.define)
|
|
271
|
+
state.define = mergeObject(parentState);
|
|
272
|
+
state.define[key] = value;
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
_chunkYR5Q5F2Kjs.__name.call(void 0, Define, "Define");
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
exports.BaseParam = BaseParam; exports.Body = Body; exports.Head = Head; exports.Query = Query; exports.Param = Param; exports.Arg = Arg; exports.Guard = Guard; exports.Plugin = Plugin; exports.Interceptor = Interceptor; exports.Filter = Filter; exports.Pipe = Pipe; exports.Route = Route; exports.Header = Header; exports.Get = Get; exports.Post = Post; exports.Put = Put; exports.Patch = Patch; exports.Delete = Delete; exports.Controller = Controller; exports.Event = Event; exports.Queue = Queue; exports.Rpc = Rpc; exports.Injectable = Injectable; exports.Ctx = Ctx; exports.Define = Define;
|