phecda-server 8.6.0 → 8.7.0
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 +1 -9
- package/dist/{chunk-XOWAQGBO.js → chunk-CCK6KDM3.js} +59 -65
- package/dist/{chunk-LLF55NZP.js → chunk-IBVPZSZJ.js} +6 -6
- package/dist/{chunk-URKOYTBU.mjs → chunk-ITDH2YDL.mjs} +6 -6
- package/dist/{chunk-5ZZAOOKE.js → chunk-KVWT2QTL.js} +26 -26
- package/dist/{chunk-LQFHZGVJ.mjs → chunk-LNL3MVTR.mjs} +2 -8
- package/dist/{chunk-ZHNYWZRL.mjs → chunk-T5F6Q2CZ.mjs} +1 -1
- package/dist/{chunk-MUUKKO67.mjs → chunk-UK3RDUEP.mjs} +1 -1
- package/dist/{chunk-SKGOTR4T.js → chunk-UP64TNWR.js} +20 -20
- package/dist/{core-BiS3xJKx.d.ts → core-Bd2ynlyb.d.ts} +1 -1
- package/dist/{core-BYxcQ8kf.d.mts → core-nqk9d66O.d.mts} +1 -1
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +40 -40
- package/dist/http/elysia/index.mjs +3 -3
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +37 -37
- package/dist/http/express/index.mjs +2 -2
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +38 -38
- package/dist/http/fastify/index.mjs +3 -3
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +38 -38
- package/dist/http/h3/index.mjs +2 -2
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +34 -34
- package/dist/http/hono/index.mjs +2 -2
- package/dist/http/hyper-express/index.d.mts +3 -3
- package/dist/http/hyper-express/index.d.ts +3 -3
- package/dist/http/hyper-express/index.js +35 -35
- package/dist/http/hyper-express/index.mjs +2 -2
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +37 -37
- package/dist/http/koa/index.mjs +2 -2
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +54 -54
- package/dist/index.mjs +14 -14
- package/dist/{meta-Csp1xcSR.d.mts → meta-ZbvaS7xK.d.mts} +2 -2
- package/dist/{meta-Csp1xcSR.d.ts → meta-ZbvaS7xK.d.ts} +2 -2
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +11 -11
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/electron/index.d.mts +3 -3
- package/dist/rpc/electron/index.d.ts +3 -3
- package/dist/rpc/electron/index.js +8 -8
- package/dist/rpc/electron/index.mjs +2 -2
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +10 -10
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +11 -11
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +12 -12
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +10 -10
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/rpc/web-ext/index.d.mts +3 -3
- package/dist/rpc/web-ext/index.d.ts +3 -3
- package/dist/rpc/web-ext/index.js +8 -8
- package/dist/rpc/web-ext/index.mjs +2 -2
- package/dist/rpc/ws/index.d.mts +3 -3
- package/dist/rpc/ws/index.d.ts +3 -3
- package/dist/rpc/ws/index.js +7 -7
- package/dist/rpc/ws/index.mjs +2 -2
- package/dist/test.d.mts +2 -2
- package/dist/test.d.ts +2 -2
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types-Bs64nYvd.d.ts → types-B4zY7i87.d.ts} +1 -1
- package/dist/{types-CjVwVyJT.d.mts → types-BfcBZVua.d.mts} +1 -1
- package/dist/{types-DExQe0qk.d.ts → types-CHWgzilt.d.ts} +1 -1
- package/dist/{types-DSlyrmns.d.mts → types-f_hV_rCD.d.mts} +1 -1
- package/package.json +1 -1
- package/register/index.mjs +2 -0
- package/register/loader.mjs +3 -3
package/bin/cli.mjs
CHANGED
|
@@ -39,7 +39,7 @@ if (nodeVersion < 18.19) {
|
|
|
39
39
|
|
|
40
40
|
function startChild(file, args) {
|
|
41
41
|
child = fork(file, {
|
|
42
|
-
env: { ...process.env },
|
|
42
|
+
env: { ...process.env, PS_RUNTIME: 'true' },
|
|
43
43
|
stdio: 'inherit',
|
|
44
44
|
execArgv: [
|
|
45
45
|
...args,
|
|
@@ -188,20 +188,12 @@ cli
|
|
|
188
188
|
.command('<file> [root]', 'run file')
|
|
189
189
|
.alias('run')
|
|
190
190
|
// .allowUnknownOptions()
|
|
191
|
-
.option('-p,--prod', 'prod mode', {
|
|
192
|
-
default: false,
|
|
193
|
-
})
|
|
194
191
|
.action((file, root, options) => {
|
|
195
192
|
const nodeArgs = options.nodeArgs.split(' ').filter(Boolean)
|
|
196
193
|
|
|
197
194
|
if (root)
|
|
198
195
|
process.chdir(root)
|
|
199
196
|
|
|
200
|
-
if (options.prod)
|
|
201
|
-
process.env.NODE_ENV = 'production'
|
|
202
|
-
else
|
|
203
|
-
process.env.NODE_ENV = 'development'
|
|
204
|
-
|
|
205
197
|
process.env.PS_CONFIG_FILE = process.env.PS_CONFIG_FILE || options.config
|
|
206
198
|
|
|
207
199
|
log('process start!')
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
var _chunkLLF55NZPjs = require('./chunk-LLF55NZP.js');
|
|
9
|
+
var _chunkIBVPZSZJjs = require('./chunk-IBVPZSZJ.js');
|
|
11
10
|
|
|
12
11
|
// src/helper.ts
|
|
13
12
|
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
@@ -22,7 +21,7 @@ var _phecdacore = require('phecda-core');
|
|
|
22
21
|
// src/exception/base.ts
|
|
23
22
|
var Exception = class extends Error {
|
|
24
23
|
static {
|
|
25
|
-
|
|
24
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "Exception");
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
|
|
@@ -36,7 +35,7 @@ var Exception = class extends Error {
|
|
|
36
35
|
message: this.message,
|
|
37
36
|
description: this.description,
|
|
38
37
|
status: this.status,
|
|
39
|
-
[
|
|
38
|
+
[_chunkIBVPZSZJjs.ERROR_SYMBOL]: true
|
|
40
39
|
};
|
|
41
40
|
}
|
|
42
41
|
};
|
|
@@ -44,7 +43,7 @@ var Exception = class extends Error {
|
|
|
44
43
|
// src/exception/undefine.ts
|
|
45
44
|
var UndefinedException = class extends Exception {
|
|
46
45
|
static {
|
|
47
|
-
|
|
46
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "UndefinedException");
|
|
48
47
|
}
|
|
49
48
|
constructor(message, metadata) {
|
|
50
49
|
super(message, metadata, 500, "Undefined error");
|
|
@@ -54,7 +53,7 @@ var UndefinedException = class extends Exception {
|
|
|
54
53
|
// src/exception/validate.ts
|
|
55
54
|
var ValidateException = class extends Exception {
|
|
56
55
|
static {
|
|
57
|
-
|
|
56
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "ValidateException");
|
|
58
57
|
}
|
|
59
58
|
constructor(message, metadata) {
|
|
60
59
|
super(message, metadata, 400, "Validate exception");
|
|
@@ -64,7 +63,7 @@ var ValidateException = class extends Exception {
|
|
|
64
63
|
// src/exception/forbidden.ts
|
|
65
64
|
var ForbiddenException = class extends Exception {
|
|
66
65
|
static {
|
|
67
|
-
|
|
66
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "ForbiddenException");
|
|
68
67
|
}
|
|
69
68
|
constructor(message, metadata) {
|
|
70
69
|
super(message, metadata, 403, "Forbidden resource");
|
|
@@ -74,7 +73,7 @@ var ForbiddenException = class extends Exception {
|
|
|
74
73
|
// src/exception/bad-request.ts
|
|
75
74
|
var BadRequestException = class extends Exception {
|
|
76
75
|
static {
|
|
77
|
-
|
|
76
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "BadRequestException");
|
|
78
77
|
}
|
|
79
78
|
constructor(message, metadata) {
|
|
80
79
|
super(message, metadata, 400, "Bad Request");
|
|
@@ -84,7 +83,7 @@ var BadRequestException = class extends Exception {
|
|
|
84
83
|
// src/exception/not-found.ts
|
|
85
84
|
var NotFoundException = class extends Exception {
|
|
86
85
|
static {
|
|
87
|
-
|
|
86
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "NotFoundException");
|
|
88
87
|
}
|
|
89
88
|
constructor(message, metadata) {
|
|
90
89
|
super(message, metadata, 404, "Not Found");
|
|
@@ -94,7 +93,7 @@ var NotFoundException = class extends Exception {
|
|
|
94
93
|
// src/exception/conflict.ts
|
|
95
94
|
var ConflictException = class extends Exception {
|
|
96
95
|
static {
|
|
97
|
-
|
|
96
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "ConflictException");
|
|
98
97
|
}
|
|
99
98
|
constructor(message, metadata) {
|
|
100
99
|
super(message, metadata, 409, "Conflict");
|
|
@@ -104,7 +103,7 @@ var ConflictException = class extends Exception {
|
|
|
104
103
|
// src/exception/bad-gateway.ts
|
|
105
104
|
var BadGatewayException = class extends Exception {
|
|
106
105
|
static {
|
|
107
|
-
|
|
106
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "BadGatewayException");
|
|
108
107
|
}
|
|
109
108
|
constructor(message, metadata) {
|
|
110
109
|
super(message, metadata, 502, "Bad Gatrway");
|
|
@@ -114,7 +113,7 @@ var BadGatewayException = class extends Exception {
|
|
|
114
113
|
// src/exception/invalid-input.ts
|
|
115
114
|
var InvalidInputException = class extends Exception {
|
|
116
115
|
static {
|
|
117
|
-
|
|
116
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "InvalidInputException");
|
|
118
117
|
}
|
|
119
118
|
constructor(message, metadata) {
|
|
120
119
|
super(message, metadata, 502, "Invalid Input");
|
|
@@ -124,7 +123,7 @@ var InvalidInputException = class extends Exception {
|
|
|
124
123
|
// src/exception/media-type.ts
|
|
125
124
|
var UnsupportedMediaTypeException = class extends Exception {
|
|
126
125
|
static {
|
|
127
|
-
|
|
126
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "UnsupportedMediaTypeException");
|
|
128
127
|
}
|
|
129
128
|
constructor(message, metadata) {
|
|
130
129
|
super(message, metadata, 415, "Unsupported Media Type");
|
|
@@ -134,7 +133,7 @@ var UnsupportedMediaTypeException = class extends Exception {
|
|
|
134
133
|
// src/exception/payload-large.ts
|
|
135
134
|
var PayloadLargeException = class extends Exception {
|
|
136
135
|
static {
|
|
137
|
-
|
|
136
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "PayloadLargeException");
|
|
138
137
|
}
|
|
139
138
|
constructor(message, metadata) {
|
|
140
139
|
super(message, metadata, 413, "Payload Too Large");
|
|
@@ -144,7 +143,7 @@ var PayloadLargeException = class extends Exception {
|
|
|
144
143
|
// src/exception/timeout.ts
|
|
145
144
|
var TimeoutException = class extends Exception {
|
|
146
145
|
static {
|
|
147
|
-
|
|
146
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "TimeoutException");
|
|
148
147
|
}
|
|
149
148
|
constructor(message, metadata) {
|
|
150
149
|
super(message, metadata, 408, "Request Timeout");
|
|
@@ -154,7 +153,7 @@ var TimeoutException = class extends Exception {
|
|
|
154
153
|
// src/exception/unauthorized.ts
|
|
155
154
|
var UnauthorizedException = class extends Exception {
|
|
156
155
|
static {
|
|
157
|
-
|
|
156
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "UnauthorizedException");
|
|
158
157
|
}
|
|
159
158
|
constructor(message, metadata) {
|
|
160
159
|
super(message, metadata, 401, "Unauthorized");
|
|
@@ -164,7 +163,7 @@ var UnauthorizedException = class extends Exception {
|
|
|
164
163
|
// src/exception/unavailable-service.ts
|
|
165
164
|
var ServiceUnavailableException = class extends Exception {
|
|
166
165
|
static {
|
|
167
|
-
|
|
166
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "ServiceUnavailableException");
|
|
168
167
|
}
|
|
169
168
|
constructor(message, metadata) {
|
|
170
169
|
super(message, metadata, 503, "Service Unavailable");
|
|
@@ -174,7 +173,7 @@ var ServiceUnavailableException = class extends Exception {
|
|
|
174
173
|
// src/exception/framework.ts
|
|
175
174
|
var FrameworkException = class extends Exception {
|
|
176
175
|
static {
|
|
177
|
-
|
|
176
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "FrameworkException");
|
|
178
177
|
}
|
|
179
178
|
constructor(message, metadata) {
|
|
180
179
|
super(`[phecda-server] ${message}`, metadata, 500, "Framework Error");
|
|
@@ -184,7 +183,7 @@ var FrameworkException = class extends Exception {
|
|
|
184
183
|
// src/exception/timer.ts
|
|
185
184
|
var TimerException = class extends Exception {
|
|
186
185
|
static {
|
|
187
|
-
|
|
186
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "TimerException");
|
|
188
187
|
}
|
|
189
188
|
constructor(message, metadata) {
|
|
190
189
|
super(message, metadata, 0, "Timer Error");
|
|
@@ -194,7 +193,7 @@ var TimerException = class extends Exception {
|
|
|
194
193
|
// src/exception/worker.ts
|
|
195
194
|
var WorkerException = class extends Exception {
|
|
196
195
|
static {
|
|
197
|
-
|
|
196
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "WorkerException");
|
|
198
197
|
}
|
|
199
198
|
constructor(message, metadata) {
|
|
200
199
|
super(message, metadata, 0, "Worker Error");
|
|
@@ -206,7 +205,7 @@ var modelRulesCache = /* @__PURE__ */ new WeakMap();
|
|
|
206
205
|
function isPlainObject(value) {
|
|
207
206
|
return Object.prototype.toString.call(value) === "[object Object]";
|
|
208
207
|
}
|
|
209
|
-
|
|
208
|
+
_chunkIBVPZSZJjs.__name.call(void 0, isPlainObject, "isPlainObject");
|
|
210
209
|
function convertForRequestInput(value, type, index) {
|
|
211
210
|
if (value === void 0) return value;
|
|
212
211
|
if (type === Number && typeof value === "string") {
|
|
@@ -221,7 +220,7 @@ function convertForRequestInput(value, type, index) {
|
|
|
221
220
|
}
|
|
222
221
|
return value;
|
|
223
222
|
}
|
|
224
|
-
|
|
223
|
+
_chunkIBVPZSZJjs.__name.call(void 0, convertForRequestInput, "convertForRequestInput");
|
|
225
224
|
function isStrTypeParam(type) {
|
|
226
225
|
return [
|
|
227
226
|
"params",
|
|
@@ -229,7 +228,7 @@ function isStrTypeParam(type) {
|
|
|
229
228
|
"headers"
|
|
230
229
|
].includes(type);
|
|
231
230
|
}
|
|
232
|
-
|
|
231
|
+
_chunkIBVPZSZJjs.__name.call(void 0, isStrTypeParam, "isStrTypeParam");
|
|
233
232
|
function convertExtractedDataByRules(data, rules, index) {
|
|
234
233
|
if (!data || typeof data !== "object") return data;
|
|
235
234
|
for (const rule of rules) {
|
|
@@ -239,7 +238,7 @@ function convertExtractedDataByRules(data, rules, index) {
|
|
|
239
238
|
}
|
|
240
239
|
return data;
|
|
241
240
|
}
|
|
242
|
-
|
|
241
|
+
_chunkIBVPZSZJjs.__name.call(void 0, convertExtractedDataByRules, "convertExtractedDataByRules");
|
|
243
242
|
function getModelRules(model) {
|
|
244
243
|
const cached = modelRulesCache.get(model);
|
|
245
244
|
if (cached) return cached;
|
|
@@ -247,7 +246,7 @@ function getModelRules(model) {
|
|
|
247
246
|
modelRulesCache.set(model, rules);
|
|
248
247
|
return rules;
|
|
249
248
|
}
|
|
250
|
-
|
|
249
|
+
_chunkIBVPZSZJjs.__name.call(void 0, getModelRules, "getModelRules");
|
|
251
250
|
async function validatePhecdaByRules(model, input, shouldConvert, index) {
|
|
252
251
|
if (!isPlainObject(input)) throw new ValidateException("data must be an object");
|
|
253
252
|
const rules = getModelRules(model);
|
|
@@ -257,8 +256,8 @@ async function validatePhecdaByRules(model, input, shouldConvert, index) {
|
|
|
257
256
|
if (errs.length) throw new ValidateException(errs[0]);
|
|
258
257
|
return data;
|
|
259
258
|
}
|
|
260
|
-
|
|
261
|
-
var defaultPipe = /* @__PURE__ */
|
|
259
|
+
_chunkIBVPZSZJjs.__name.call(void 0, validatePhecdaByRules, "validatePhecdaByRules");
|
|
260
|
+
var defaultPipe = /* @__PURE__ */ _chunkIBVPZSZJjs.__name.call(void 0, async ({ arg, reflect, meta, index, type, key }, { method }) => {
|
|
262
261
|
if (meta.const) {
|
|
263
262
|
if (arg !== meta.const) throw new ValidateException(`param ${index + 1} must be ${meta.const}`);
|
|
264
263
|
}
|
|
@@ -269,9 +268,7 @@ var defaultPipe = /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, async ({
|
|
|
269
268
|
const isModel = _phecdacore.isPhecda.call(void 0, reflect);
|
|
270
269
|
const isStrType = isStrTypeParam(type);
|
|
271
270
|
const canUseShallowModelConvert = isStrType && !key;
|
|
272
|
-
if (isModel && isStrType && key)
|
|
273
|
-
throw new ValidateException("phecda class cannot be used with specified field in query/params/headers in default pipe");
|
|
274
|
-
}
|
|
271
|
+
if (isModel && isStrType && key) throw new ValidateException("phecda class cannot be used with specified field in query/params/headers in default pipe");
|
|
275
272
|
if (!isModel && isStrType) {
|
|
276
273
|
arg = convertForRequestInput(arg, reflect, index);
|
|
277
274
|
} else if (!isModel) {
|
|
@@ -336,14 +333,14 @@ var defaultPipe = /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, async ({
|
|
|
336
333
|
}, "defaultPipe");
|
|
337
334
|
|
|
338
335
|
// src/filter.ts
|
|
339
|
-
var defaultFilter = /* @__PURE__ */
|
|
336
|
+
var defaultFilter = /* @__PURE__ */ _chunkIBVPZSZJjs.__name.call(void 0, (e) => {
|
|
340
337
|
if (!(e instanceof Exception)) {
|
|
341
|
-
|
|
342
|
-
if (
|
|
338
|
+
_chunkIBVPZSZJjs.log.call(void 0, e.message, "error");
|
|
339
|
+
if (_chunkIBVPZSZJjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
343
340
|
e = new UndefinedException(e.message || e);
|
|
344
341
|
} else {
|
|
345
|
-
|
|
346
|
-
if (
|
|
342
|
+
_chunkIBVPZSZJjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
|
|
343
|
+
if (_chunkIBVPZSZJjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
347
344
|
}
|
|
348
345
|
return e.data;
|
|
349
346
|
}, "defaultFilter");
|
|
@@ -352,7 +349,7 @@ var defaultFilter = /* @__PURE__ */ _chunkLLF55NZPjs.__name.call(void 0, (e) =>
|
|
|
352
349
|
var debug = _debug2.default.call(void 0, "phecda-server(Context)");
|
|
353
350
|
var Context = (_class = class _Context {
|
|
354
351
|
static {
|
|
355
|
-
|
|
352
|
+
_chunkIBVPZSZJjs.__name.call(void 0, this, "Context");
|
|
356
353
|
}
|
|
357
354
|
|
|
358
355
|
|
|
@@ -366,14 +363,11 @@ var Context = (_class = class _Context {
|
|
|
366
363
|
static __initStatic3() {this.guardRecord = {}}
|
|
367
364
|
static __initStatic4() {this.addonRecord = {}}
|
|
368
365
|
|
|
369
|
-
// protected canGetCtx = true
|
|
370
366
|
constructor(data) {
|
|
371
367
|
this.data = data;
|
|
372
|
-
if (_chunkLLF55NZPjs.IS_DEV)
|
|
373
|
-
data._context = this;
|
|
374
368
|
this.ctx = new Proxy(data, {
|
|
375
369
|
get(target, p) {
|
|
376
|
-
if (!(p in target))
|
|
370
|
+
if (!(p in target)) _chunkIBVPZSZJjs.log.call(void 0, `attribute "${p}" does not exist on ctx, which might be due to a missing AOP role (such as a guard).`, "warn", data.tag);
|
|
377
371
|
return target[p];
|
|
378
372
|
},
|
|
379
373
|
set(target, p, newValue) {
|
|
@@ -411,7 +405,7 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
411
405
|
const { paramsType, data: { ctxs, tag, params, method } } = meta;
|
|
412
406
|
try {
|
|
413
407
|
let res;
|
|
414
|
-
const nextHandler = /* @__PURE__ */
|
|
408
|
+
const nextHandler = /* @__PURE__ */ _chunkIBVPZSZJjs.__name.call(void 0, (index) => {
|
|
415
409
|
return async () => {
|
|
416
410
|
if (index === guards.length) {
|
|
417
411
|
const instance = moduleMap.get(tag);
|
|
@@ -435,7 +429,7 @@ ${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
|
435
429
|
return res;
|
|
436
430
|
});
|
|
437
431
|
}
|
|
438
|
-
|
|
432
|
+
_chunkIBVPZSZJjs.__name.call(void 0, next, "next");
|
|
439
433
|
const ret = await guards[index](this.ctx, next);
|
|
440
434
|
if (ret !== void 0) {
|
|
441
435
|
res = ret;
|
|
@@ -480,12 +474,12 @@ function addPipe(key, pipe) {
|
|
|
480
474
|
if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) debug(`overwrite Pipe "${String(key)}"`, "warn");
|
|
481
475
|
Context.pipeRecord[key] = pipe;
|
|
482
476
|
}
|
|
483
|
-
|
|
477
|
+
_chunkIBVPZSZJjs.__name.call(void 0, addPipe, "addPipe");
|
|
484
478
|
function addFilter(key, filter) {
|
|
485
479
|
if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) debug(`overwrite Filter "${String(key)}"`, "warn");
|
|
486
480
|
Context.filterRecord[key] = filter;
|
|
487
481
|
}
|
|
488
|
-
|
|
482
|
+
_chunkIBVPZSZJjs.__name.call(void 0, addFilter, "addFilter");
|
|
489
483
|
function addGuard(key, guard, priority = 0) {
|
|
490
484
|
if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) debug(`overwrite Guard "${String(key)}"`, "warn");
|
|
491
485
|
Context.guardRecord[key] = {
|
|
@@ -493,7 +487,7 @@ function addGuard(key, guard, priority = 0) {
|
|
|
493
487
|
priority
|
|
494
488
|
};
|
|
495
489
|
}
|
|
496
|
-
|
|
490
|
+
_chunkIBVPZSZJjs.__name.call(void 0, addGuard, "addGuard");
|
|
497
491
|
function addAddon(key, addon, priority = 0) {
|
|
498
492
|
if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) debug(`overwrite Addon "${String(key)}"`, "warn");
|
|
499
493
|
Context.addonRecord[key] = {
|
|
@@ -501,14 +495,14 @@ function addAddon(key, addon, priority = 0) {
|
|
|
501
495
|
priority
|
|
502
496
|
};
|
|
503
497
|
}
|
|
504
|
-
|
|
498
|
+
_chunkIBVPZSZJjs.__name.call(void 0, addAddon, "addAddon");
|
|
505
499
|
|
|
506
500
|
// src/http/helper.ts
|
|
507
501
|
function resolveDep(ret, key) {
|
|
508
502
|
if (key) return _optionalChain([ret, 'optionalAccess', _ => _[key]]);
|
|
509
503
|
return ret;
|
|
510
504
|
}
|
|
511
|
-
|
|
505
|
+
_chunkIBVPZSZJjs.__name.call(void 0, resolveDep, "resolveDep");
|
|
512
506
|
|
|
513
507
|
// src/decorators/helper.ts
|
|
514
508
|
function shallowClone(obj) {
|
|
@@ -516,11 +510,11 @@ function shallowClone(obj) {
|
|
|
516
510
|
...obj
|
|
517
511
|
};
|
|
518
512
|
}
|
|
519
|
-
|
|
513
|
+
_chunkIBVPZSZJjs.__name.call(void 0, shallowClone, "shallowClone");
|
|
520
514
|
function mergeObject(...args) {
|
|
521
515
|
return Object.assign({}, ...args);
|
|
522
516
|
}
|
|
523
|
-
|
|
517
|
+
_chunkIBVPZSZJjs.__name.call(void 0, mergeObject, "mergeObject");
|
|
524
518
|
|
|
525
519
|
// src/helper.ts
|
|
526
520
|
function createControllerMetaMap(meta, filter) {
|
|
@@ -536,14 +530,14 @@ function createControllerMetaMap(meta, filter) {
|
|
|
536
530
|
});
|
|
537
531
|
}
|
|
538
532
|
}
|
|
539
|
-
|
|
533
|
+
_chunkIBVPZSZJjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
540
534
|
handleMeta();
|
|
541
|
-
|
|
535
|
+
_chunkIBVPZSZJjs.HMR.call(void 0, handleMeta);
|
|
542
536
|
return metaMap;
|
|
543
537
|
}
|
|
544
|
-
|
|
538
|
+
_chunkIBVPZSZJjs.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
|
|
545
539
|
function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
546
|
-
if (
|
|
540
|
+
if (_chunkIBVPZSZJjs.IS_PURE) return;
|
|
547
541
|
const addonSet = /* @__PURE__ */ new Set();
|
|
548
542
|
const guardSet = /* @__PURE__ */ new Set();
|
|
549
543
|
const pipeSet = /* @__PURE__ */ new Set();
|
|
@@ -588,34 +582,34 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
|
588
582
|
...filterSet
|
|
589
583
|
].filter((i) => !Context.filterRecord[i]);
|
|
590
584
|
function exit() {
|
|
591
|
-
if (
|
|
592
|
-
|
|
585
|
+
if (_chunkIBVPZSZJjs.IS_STRICT) {
|
|
586
|
+
_chunkIBVPZSZJjs.log.call(void 0, "Does not meet strict mode requirements", "error");
|
|
593
587
|
process.exit(1);
|
|
594
588
|
}
|
|
595
589
|
}
|
|
596
|
-
|
|
590
|
+
_chunkIBVPZSZJjs.__name.call(void 0, exit, "exit");
|
|
597
591
|
if (missAddons.length) {
|
|
598
|
-
|
|
592
|
+
_chunkIBVPZSZJjs.log.call(void 0, `${_picocolors2.default.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
|
|
599
593
|
exit();
|
|
600
594
|
}
|
|
601
595
|
if (missGuards.length) {
|
|
602
|
-
|
|
596
|
+
_chunkIBVPZSZJjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
|
|
603
597
|
exit();
|
|
604
598
|
}
|
|
605
599
|
if (missPipes.length) {
|
|
606
|
-
|
|
600
|
+
_chunkIBVPZSZJjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
|
|
607
601
|
exit();
|
|
608
602
|
}
|
|
609
603
|
if (missFilters.length) {
|
|
610
|
-
|
|
604
|
+
_chunkIBVPZSZJjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
|
|
611
605
|
exit();
|
|
612
606
|
}
|
|
613
|
-
warningSet.forEach((warn) =>
|
|
607
|
+
warningSet.forEach((warn) => _chunkIBVPZSZJjs.log.call(void 0, warn, "warn"));
|
|
614
608
|
if (warningSet.size) exit();
|
|
615
609
|
}
|
|
616
|
-
|
|
610
|
+
_chunkIBVPZSZJjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
617
611
|
handleMeta();
|
|
618
|
-
|
|
612
|
+
_chunkIBVPZSZJjs.HMR.call(void 0, handleMeta);
|
|
619
613
|
return {
|
|
620
614
|
addonSet,
|
|
621
615
|
guardSet,
|
|
@@ -623,7 +617,7 @@ function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
|
623
617
|
filterSet
|
|
624
618
|
};
|
|
625
619
|
}
|
|
626
|
-
|
|
620
|
+
_chunkIBVPZSZJjs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
627
621
|
function joinUrl(base, ...paths) {
|
|
628
622
|
const joinedPath = [
|
|
629
623
|
base,
|
|
@@ -631,7 +625,7 @@ function joinUrl(base, ...paths) {
|
|
|
631
625
|
].filter((p) => p).map((path) => path.replace(/(^\/)/g, "")).join("/");
|
|
632
626
|
return `/${joinedPath}`;
|
|
633
627
|
}
|
|
634
|
-
|
|
628
|
+
_chunkIBVPZSZJjs.__name.call(void 0, joinUrl, "joinUrl");
|
|
635
629
|
|
|
636
630
|
|
|
637
631
|
|
|
@@ -3,7 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/common.ts
|
|
5
5
|
var ERROR_SYMBOL = "__PS_ERROR__";
|
|
6
|
-
var
|
|
6
|
+
var IS_RUNTIME = !!process.env.PS_RUNTIME;
|
|
7
7
|
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
8
|
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
9
|
var IS_PURE = !!process.env.PS_PURE;
|
|
@@ -112,14 +112,14 @@ __name(runMiddleware, "runMiddleware");
|
|
|
112
112
|
|
|
113
113
|
// src/hmr.ts
|
|
114
114
|
function HMR(cb) {
|
|
115
|
-
if (
|
|
115
|
+
if (IS_RUNTIME) {
|
|
116
116
|
if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
|
|
117
117
|
globalThis.__PS_HMR__.push(cb);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
__name(HMR, "HMR");
|
|
121
121
|
async function RELOAD(oldModels, newModels) {
|
|
122
|
-
if (
|
|
122
|
+
if (IS_RUNTIME) {
|
|
123
123
|
log("reload module...");
|
|
124
124
|
for (const cb of globalThis.__PS_HMR__) await cb(oldModels, newModels);
|
|
125
125
|
log("reload done");
|
|
@@ -127,14 +127,14 @@ async function RELOAD(oldModels, newModels) {
|
|
|
127
127
|
}
|
|
128
128
|
__name(RELOAD, "RELOAD");
|
|
129
129
|
function RELAUNCH() {
|
|
130
|
-
if (
|
|
130
|
+
if (IS_RUNTIME) {
|
|
131
131
|
log("relaunch...");
|
|
132
132
|
process.exit(PS_EXIT_CODE.RELAUNCH);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
__name(RELAUNCH, "RELAUNCH");
|
|
136
136
|
function EXIT() {
|
|
137
|
-
if (
|
|
137
|
+
if (IS_RUNTIME) {
|
|
138
138
|
log("exit...");
|
|
139
139
|
process.exit(PS_EXIT_CODE.EXIT);
|
|
140
140
|
}
|
|
@@ -159,4 +159,4 @@ __name(EXIT, "EXIT");
|
|
|
159
159
|
|
|
160
160
|
|
|
161
161
|
|
|
162
|
-
exports.__name = __name; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.
|
|
162
|
+
exports.__name = __name; exports.ERROR_SYMBOL = ERROR_SYMBOL; exports.IS_RUNTIME = IS_RUNTIME; exports.IS_ONLY_GENERATE = IS_ONLY_GENERATE; exports.IS_STRICT = IS_STRICT; exports.IS_PURE = IS_PURE; exports.LOG_LEVEL = LOG_LEVEL; exports.PS_EXIT_CODE = PS_EXIT_CODE; exports.setLogger = setLogger; exports.getLogger = getLogger; exports.log = log; exports.runMiddleware = runMiddleware; exports.Mixin = _tsmixer.Mixin; exports.HMR = HMR; exports.RELOAD = RELOAD; exports.RELAUNCH = RELAUNCH; exports.EXIT = EXIT;
|
|
@@ -3,7 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/common.ts
|
|
5
5
|
var ERROR_SYMBOL = "__PS_ERROR__";
|
|
6
|
-
var
|
|
6
|
+
var IS_RUNTIME = !!process.env.PS_RUNTIME;
|
|
7
7
|
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
8
|
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
9
|
var IS_PURE = !!process.env.PS_PURE;
|
|
@@ -112,14 +112,14 @@ __name(runMiddleware, "runMiddleware");
|
|
|
112
112
|
|
|
113
113
|
// src/hmr.ts
|
|
114
114
|
function HMR(cb) {
|
|
115
|
-
if (
|
|
115
|
+
if (IS_RUNTIME) {
|
|
116
116
|
if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
|
|
117
117
|
globalThis.__PS_HMR__.push(cb);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
__name(HMR, "HMR");
|
|
121
121
|
async function RELOAD(oldModels, newModels) {
|
|
122
|
-
if (
|
|
122
|
+
if (IS_RUNTIME) {
|
|
123
123
|
log("reload module...");
|
|
124
124
|
for (const cb of globalThis.__PS_HMR__) await cb(oldModels, newModels);
|
|
125
125
|
log("reload done");
|
|
@@ -127,14 +127,14 @@ async function RELOAD(oldModels, newModels) {
|
|
|
127
127
|
}
|
|
128
128
|
__name(RELOAD, "RELOAD");
|
|
129
129
|
function RELAUNCH() {
|
|
130
|
-
if (
|
|
130
|
+
if (IS_RUNTIME) {
|
|
131
131
|
log("relaunch...");
|
|
132
132
|
process.exit(PS_EXIT_CODE.RELAUNCH);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
__name(RELAUNCH, "RELAUNCH");
|
|
136
136
|
function EXIT() {
|
|
137
|
-
if (
|
|
137
|
+
if (IS_RUNTIME) {
|
|
138
138
|
log("exit...");
|
|
139
139
|
process.exit(PS_EXIT_CODE.EXIT);
|
|
140
140
|
}
|
|
@@ -144,7 +144,7 @@ __name(EXIT, "EXIT");
|
|
|
144
144
|
export {
|
|
145
145
|
__name,
|
|
146
146
|
ERROR_SYMBOL,
|
|
147
|
-
|
|
147
|
+
IS_RUNTIME,
|
|
148
148
|
IS_ONLY_GENERATE,
|
|
149
149
|
IS_STRICT,
|
|
150
150
|
IS_PURE,
|