phecda-server 7.0.0-alpha.1 → 7.0.0-alpha.10
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/assets/ps.json +1 -1
- package/assets/schema.json +55 -55
- package/bin/cli.mjs +31 -23
- package/dist/chunk-4LLLQOMF.js +152 -0
- package/dist/{chunk-7YQ57BQS.js → chunk-6OQ2SB5W.js} +137 -69
- package/dist/{chunk-GSPBHZBH.js → chunk-G7JFKM2M.js} +96 -80
- package/dist/{chunk-MBCHNDAY.js → chunk-KCPBITYZ.js} +24 -24
- package/dist/{chunk-HMVLXNV3.mjs → chunk-MUI6MTUO.mjs} +1 -1
- package/dist/chunk-NQ55PA2X.mjs +152 -0
- package/dist/{chunk-XYVMNY2X.mjs → chunk-YCES6ABN.mjs} +124 -56
- package/dist/{chunk-V7EI76QQ.mjs → chunk-Z7NAAE4M.mjs} +48 -32
- package/dist/{core-BIcUwV18.d.mts → core-CUTbX_IS.d.ts} +5 -3
- package/dist/{core-CYwEPfN4.d.ts → core-DIfgUKIU.d.mts} +5 -3
- package/dist/helper.d.mts +8 -6
- package/dist/helper.d.ts +8 -6
- package/dist/helper.js +8 -3
- package/dist/helper.mjs +10 -5
- package/dist/http/elysia/index.d.mts +4 -4
- package/dist/http/elysia/index.d.ts +4 -4
- package/dist/http/elysia/index.js +43 -44
- package/dist/http/elysia/index.mjs +9 -10
- package/dist/http/express/index.d.mts +4 -4
- package/dist/http/express/index.d.ts +4 -4
- package/dist/http/express/index.js +40 -41
- package/dist/http/express/index.mjs +9 -10
- package/dist/http/fastify/index.d.mts +4 -4
- package/dist/http/fastify/index.d.ts +4 -4
- package/dist/http/fastify/index.js +41 -42
- package/dist/http/fastify/index.mjs +9 -10
- package/dist/http/h3/index.d.mts +4 -4
- package/dist/http/h3/index.d.ts +4 -4
- package/dist/http/h3/index.js +41 -42
- package/dist/http/h3/index.mjs +9 -10
- package/dist/http/hono/index.d.mts +4 -4
- package/dist/http/hono/index.d.ts +4 -4
- package/dist/http/hono/index.js +37 -39
- package/dist/http/hono/index.mjs +5 -7
- package/dist/http/hyper-express/index.d.mts +4 -4
- package/dist/http/hyper-express/index.d.ts +4 -4
- package/dist/http/hyper-express/index.js +38 -39
- package/dist/http/hyper-express/index.mjs +8 -9
- package/dist/http/koa/index.d.mts +4 -4
- package/dist/http/koa/index.d.ts +4 -4
- package/dist/http/koa/index.js +40 -41
- package/dist/http/koa/index.mjs +9 -10
- package/dist/index.d.mts +44 -38
- package/dist/index.d.ts +44 -38
- package/dist/index.js +48 -42
- package/dist/index.mjs +21 -15
- package/dist/{meta-BXKLFTgG.d.mts → meta-CR-D39hQ.d.mts} +7 -5
- package/dist/{meta-BXKLFTgG.d.ts → meta-CR-D39hQ.d.ts} +7 -5
- package/dist/rpc/bullmq/index.d.mts +5 -5
- package/dist/rpc/bullmq/index.d.ts +5 -5
- package/dist/rpc/bullmq/index.js +15 -14
- package/dist/rpc/bullmq/index.mjs +4 -3
- package/dist/rpc/kafka/index.d.mts +4 -4
- package/dist/rpc/kafka/index.d.ts +4 -4
- package/dist/rpc/kafka/index.js +15 -14
- package/dist/rpc/kafka/index.mjs +3 -2
- package/dist/rpc/nats/index.d.mts +4 -4
- package/dist/rpc/nats/index.d.ts +4 -4
- package/dist/rpc/nats/index.js +14 -13
- package/dist/rpc/nats/index.mjs +4 -3
- package/dist/rpc/rabbitmq/index.d.mts +4 -4
- package/dist/rpc/rabbitmq/index.d.ts +4 -4
- package/dist/rpc/rabbitmq/index.js +16 -15
- package/dist/rpc/rabbitmq/index.mjs +4 -3
- package/dist/rpc/redis/index.d.mts +4 -4
- package/dist/rpc/redis/index.d.ts +4 -4
- package/dist/rpc/redis/index.js +14 -13
- package/dist/rpc/redis/index.mjs +4 -3
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types-h40T3cRG.d.mts → types-BF1TDbFV.d.ts} +4 -3
- package/dist/{types-BtbL49Zs.d.mts → types-DYRu0vic.d.ts} +4 -3
- package/dist/{types-VFzEM7LL.d.ts → types-DYviSl5B.d.mts} +4 -3
- package/dist/{types-m3IEDKjP.d.ts → types-DqH1qA-q.d.mts} +4 -3
- package/package.json +8 -5
- package/register/export.mjs +30 -0
- package/register/index.mjs +50 -40
- package/register/loader.mjs +84 -66
- package/register/utils.mjs +60 -56
- package/dist/chunk-J5CFUN4V.js +0 -73
- package/dist/chunk-WHJ5FALK.mjs +0 -73
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk6OQ2SB5Wjs = require('./chunk-6OQ2SB5W.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -31,7 +31,7 @@ var _chunk7YQ57BQSjs = require('./chunk-7YQ57BQS.js');
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _chunkKCPBITYZjs = require('./chunk-KCPBITYZ.js');
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
@@ -56,8 +56,8 @@ var _chunkMBCHNDAYjs = require('./chunk-MBCHNDAY.js');
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
var _chunkGSPBHZBHjs = require('./chunk-GSPBHZBH.js');
|
|
60
59
|
|
|
60
|
+
var _chunkG7JFKM2Mjs = require('./chunk-G7JFKM2M.js');
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
@@ -70,13 +70,15 @@ var _chunkGSPBHZBHjs = require('./chunk-GSPBHZBH.js');
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
var _chunk4LLLQOMFjs = require('./chunk-4LLLQOMF.js');
|
|
74
76
|
|
|
75
77
|
// src/types.ts
|
|
76
78
|
var ResponseSymbol = Symbol("response");
|
|
77
79
|
var CustomResponse = class {
|
|
78
80
|
static {
|
|
79
|
-
|
|
81
|
+
_chunk4LLLQOMFjs.__name.call(void 0, this, "CustomResponse");
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
};
|
|
@@ -89,51 +91,54 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
89
91
|
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
92
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
91
93
|
}
|
|
92
|
-
|
|
94
|
+
_chunk4LLLQOMFjs.__name.call(void 0, _ts_decorate, "_ts_decorate");
|
|
93
95
|
function _ts_metadata(k, v) {
|
|
94
96
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
95
97
|
}
|
|
96
|
-
|
|
98
|
+
_chunk4LLLQOMFjs.__name.call(void 0, _ts_metadata, "_ts_metadata");
|
|
97
99
|
var ServerBase = (_class = class extends _phecdacore.Base {constructor(...args2) { super(...args2); _class.prototype.__init.call(this); }
|
|
98
100
|
static {
|
|
99
|
-
|
|
101
|
+
_chunk4LLLQOMFjs.__name.call(void 0, this, "ServerBase");
|
|
102
|
+
}
|
|
103
|
+
__init() {this.emitter = exports.emitter = _chunk6OQ2SB5Wjs.emitter}
|
|
104
|
+
log(msg, level = "log") {
|
|
105
|
+
_chunk4LLLQOMFjs.log.call(void 0, msg, level, this.tag);
|
|
100
106
|
}
|
|
101
|
-
__init() {this.emitter = exports.emitter = _chunk7YQ57BQSjs.emitter}
|
|
102
107
|
}, _class);
|
|
103
108
|
var HttpBase = class extends ServerBase {
|
|
104
109
|
static {
|
|
105
|
-
|
|
110
|
+
_chunk4LLLQOMFjs.__name.call(void 0, this, "HttpBase");
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
};
|
|
109
114
|
_ts_decorate([
|
|
110
|
-
|
|
111
|
-
_ts_metadata("design:type", typeof
|
|
115
|
+
_chunkKCPBITYZjs.Ctx,
|
|
116
|
+
_ts_metadata("design:type", typeof Ctx === "undefined" ? Object : Ctx)
|
|
112
117
|
], HttpBase.prototype, "context", void 0);
|
|
113
118
|
var RpcBase = class extends ServerBase {
|
|
114
119
|
static {
|
|
115
|
-
|
|
120
|
+
_chunk4LLLQOMFjs.__name.call(void 0, this, "RpcBase");
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
};
|
|
119
124
|
_ts_decorate([
|
|
120
|
-
|
|
121
|
-
_ts_metadata("design:type", typeof
|
|
125
|
+
_chunkKCPBITYZjs.Ctx,
|
|
126
|
+
_ts_metadata("design:type", typeof Ctx === "undefined" ? Object : Ctx)
|
|
122
127
|
], RpcBase.prototype, "context", void 0);
|
|
123
128
|
|
|
124
129
|
// src/modules/filter.ts
|
|
125
130
|
|
|
126
131
|
var PFilter = class extends ServerBase {
|
|
127
132
|
static {
|
|
128
|
-
|
|
133
|
+
_chunk4LLLQOMFjs.__name.call(void 0, this, "PFilter");
|
|
129
134
|
}
|
|
130
135
|
|
|
131
136
|
constructor(tag) {
|
|
132
137
|
super();
|
|
133
138
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
134
|
-
|
|
139
|
+
_chunkG7JFKM2Mjs.addFilter.call(void 0, this.key, this.use.bind(this));
|
|
135
140
|
this.onUnmount(() => {
|
|
136
|
-
delete
|
|
141
|
+
delete _chunkG7JFKM2Mjs.Context.filterRecord[this.key];
|
|
137
142
|
});
|
|
138
143
|
}
|
|
139
144
|
};
|
|
@@ -142,16 +147,16 @@ var PFilter = class extends ServerBase {
|
|
|
142
147
|
|
|
143
148
|
var PGuard = (_class2 = class extends ServerBase {
|
|
144
149
|
static {
|
|
145
|
-
|
|
150
|
+
_chunk4LLLQOMFjs.__name.call(void 0, this, "PGuard");
|
|
146
151
|
}
|
|
147
152
|
|
|
148
153
|
__init2() {this.priority = 0}
|
|
149
154
|
constructor(tag) {
|
|
150
155
|
super();_class2.prototype.__init2.call(this);;
|
|
151
156
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
152
|
-
|
|
157
|
+
_chunkG7JFKM2Mjs.addGuard.call(void 0, this.key, this.use.bind(this), this.priority);
|
|
153
158
|
this.onUnmount(() => {
|
|
154
|
-
delete
|
|
159
|
+
delete _chunkG7JFKM2Mjs.Context.guardRecord[this.key];
|
|
155
160
|
});
|
|
156
161
|
}
|
|
157
162
|
}, _class2);
|
|
@@ -160,15 +165,15 @@ var PGuard = (_class2 = class extends ServerBase {
|
|
|
160
165
|
|
|
161
166
|
var PPipe = class extends ServerBase {
|
|
162
167
|
static {
|
|
163
|
-
|
|
168
|
+
_chunk4LLLQOMFjs.__name.call(void 0, this, "PPipe");
|
|
164
169
|
}
|
|
165
170
|
|
|
166
171
|
constructor(tag) {
|
|
167
172
|
super();
|
|
168
173
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
169
|
-
|
|
174
|
+
_chunkG7JFKM2Mjs.addPipe.call(void 0, this.key, this.use.bind(this));
|
|
170
175
|
this.onUnmount(() => {
|
|
171
|
-
delete
|
|
176
|
+
delete _chunkG7JFKM2Mjs.Context.pipeRecord[this.key];
|
|
172
177
|
});
|
|
173
178
|
}
|
|
174
179
|
};
|
|
@@ -177,16 +182,16 @@ var PPipe = class extends ServerBase {
|
|
|
177
182
|
|
|
178
183
|
var PAddon = (_class3 = class extends ServerBase {
|
|
179
184
|
static {
|
|
180
|
-
|
|
185
|
+
_chunk4LLLQOMFjs.__name.call(void 0, this, "PAddon");
|
|
181
186
|
}
|
|
182
187
|
|
|
183
188
|
__init3() {this.priority = 0}
|
|
184
189
|
constructor(tag) {
|
|
185
190
|
super();_class3.prototype.__init3.call(this);;
|
|
186
191
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
187
|
-
|
|
192
|
+
_chunkG7JFKM2Mjs.addAddon.call(void 0, this.key, this.use.bind(this), this.priority);
|
|
188
193
|
this.onUnmount(() => {
|
|
189
|
-
delete
|
|
194
|
+
delete _chunkG7JFKM2Mjs.Context.addonRecord[this.key];
|
|
190
195
|
});
|
|
191
196
|
}
|
|
192
197
|
}, _class3);
|
|
@@ -195,7 +200,7 @@ var PAddon = (_class3 = class extends ServerBase {
|
|
|
195
200
|
|
|
196
201
|
var PExtension = class extends ServerBase {
|
|
197
202
|
static {
|
|
198
|
-
|
|
203
|
+
_chunk4LLLQOMFjs.__name.call(void 0, this, "PExtension");
|
|
199
204
|
}
|
|
200
205
|
|
|
201
206
|
|
|
@@ -204,27 +209,27 @@ var PExtension = class extends ServerBase {
|
|
|
204
209
|
super();
|
|
205
210
|
const key = this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
206
211
|
if (this.pipe) {
|
|
207
|
-
|
|
212
|
+
_chunkG7JFKM2Mjs.addPipe.call(void 0, key, this.pipe.bind(this));
|
|
208
213
|
this.onUnmount(() => {
|
|
209
|
-
delete
|
|
214
|
+
delete _chunkG7JFKM2Mjs.Context.pipeRecord[key];
|
|
210
215
|
});
|
|
211
216
|
}
|
|
212
217
|
if (this.addon) {
|
|
213
|
-
|
|
218
|
+
_chunkG7JFKM2Mjs.addAddon.call(void 0, key, this.addon.bind(this), this.addonPriority);
|
|
214
219
|
this.onUnmount(() => {
|
|
215
|
-
delete
|
|
220
|
+
delete _chunkG7JFKM2Mjs.Context.addonRecord[key];
|
|
216
221
|
});
|
|
217
222
|
}
|
|
218
223
|
if (this.guard) {
|
|
219
|
-
|
|
224
|
+
_chunkG7JFKM2Mjs.addGuard.call(void 0, key, this.guard.bind(this), this.guardPriority);
|
|
220
225
|
this.onUnmount(() => {
|
|
221
|
-
delete
|
|
226
|
+
delete _chunkG7JFKM2Mjs.Context.guardRecord[key];
|
|
222
227
|
});
|
|
223
228
|
}
|
|
224
229
|
if (this.filter) {
|
|
225
|
-
|
|
230
|
+
_chunkG7JFKM2Mjs.addFilter.call(void 0, key, this.filter.bind(this));
|
|
226
231
|
this.onUnmount(() => {
|
|
227
|
-
delete
|
|
232
|
+
delete _chunkG7JFKM2Mjs.Context.filterRecord[key];
|
|
228
233
|
});
|
|
229
234
|
}
|
|
230
235
|
}
|
|
@@ -234,7 +239,7 @@ var PExtension = class extends ServerBase {
|
|
|
234
239
|
var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
|
|
235
240
|
var Generator = class {
|
|
236
241
|
static {
|
|
237
|
-
|
|
242
|
+
_chunk4LLLQOMFjs.__name.call(void 0, this, "Generator");
|
|
238
243
|
}
|
|
239
244
|
|
|
240
245
|
constructor(path) {
|
|
@@ -251,7 +256,7 @@ var Generator = class {
|
|
|
251
256
|
// src/generator/rpc.ts
|
|
252
257
|
var RPCGenerator = (_class4 = class extends Generator {constructor(...args3) { super(...args3); _class4.prototype.__init4.call(this);_class4.prototype.__init5.call(this); }
|
|
253
258
|
static {
|
|
254
|
-
|
|
259
|
+
_chunk4LLLQOMFjs.__name.call(void 0, this, "RPCGenerator");
|
|
255
260
|
}
|
|
256
261
|
__init4() {this.name = "RPC"}
|
|
257
262
|
__init5() {this.classMap = {}}
|
|
@@ -287,7 +292,7 @@ var RPCGenerator = (_class4 = class extends Generator {constructor(...args3) { s
|
|
|
287
292
|
// src/generator/http.ts
|
|
288
293
|
var HTTPGenerator = (_class5 = class extends Generator {constructor(...args4) { super(...args4); _class5.prototype.__init6.call(this);_class5.prototype.__init7.call(this); }
|
|
289
294
|
static {
|
|
290
|
-
|
|
295
|
+
_chunk4LLLQOMFjs.__name.call(void 0, this, "HTTPGenerator");
|
|
291
296
|
}
|
|
292
297
|
__init6() {this.name = "HTTP"}
|
|
293
298
|
__init7() {this.classMap = {}}
|
|
@@ -304,11 +309,11 @@ var HTTPGenerator = (_class5 = class extends Generator {constructor(...args4) {
|
|
|
304
309
|
addMethod(args) {
|
|
305
310
|
const { http, name, func, params, tag } = args;
|
|
306
311
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) return;
|
|
307
|
-
const url = http.prefix
|
|
312
|
+
const url = _chunkG7JFKM2Mjs.joinUrl.call(void 0, http.prefix, http.route).replace(/\/\:([^\/]*)/g, (_, js) => `/{{${js}}}`);
|
|
308
313
|
if (!this.classMap[name]) this.classMap[name] = {};
|
|
309
314
|
this.classMap[name][func] = `
|
|
310
315
|
${func}(...args){
|
|
311
|
-
const ret={tag:"${tag}",func:"${func}",body:{},headers:{},query:{},params:{},method:"${http.type}",url:"${url}"
|
|
316
|
+
const ret={tag:"${tag}",func:"${func}",body:{},headers:{},query:{},params:{},method:"${http.type}",url:"${url}"}
|
|
312
317
|
|
|
313
318
|
${params.reduce((p, c, i) => `${p}ret.${c.type}${c.key ? `['${c.key}']` : ""}=args[${i}]
|
|
314
319
|
${c.type === "params" ? `ret.url=ret.url.replace('{{${c.key}}}',args[${i}])` : ""}
|
|
@@ -404,4 +409,5 @@ return ret
|
|
|
404
409
|
|
|
405
410
|
|
|
406
411
|
|
|
407
|
-
|
|
412
|
+
|
|
413
|
+
exports.Addon = _chunkKCPBITYZjs.Addon; exports.Arg = _chunkKCPBITYZjs.Arg; exports.BadGatewayException = _chunkG7JFKM2Mjs.BadGatewayException; exports.BadRequestException = _chunkG7JFKM2Mjs.BadRequestException; exports.BaseParam = _chunkKCPBITYZjs.BaseParam; exports.Body = _chunkKCPBITYZjs.Body; exports.ConflictException = _chunkG7JFKM2Mjs.ConflictException; exports.Context = _chunkG7JFKM2Mjs.Context; exports.Controller = _chunkKCPBITYZjs.Controller; exports.Ctx = _chunkKCPBITYZjs.Ctx; exports.CustomResponse = CustomResponse; exports.Define = _chunkKCPBITYZjs.Define; exports.Delete = _chunkKCPBITYZjs.Delete; exports.ERROR_SYMBOL = _chunk4LLLQOMFjs.ERROR_SYMBOL; exports.Exception = _chunkG7JFKM2Mjs.Exception; exports.Factory = _chunk6OQ2SB5Wjs.Factory; exports.Filter = _chunkKCPBITYZjs.Filter; exports.ForbiddenException = _chunkG7JFKM2Mjs.ForbiddenException; exports.FrameworkException = _chunkG7JFKM2Mjs.FrameworkException; exports.Generator = Generator; exports.Get = _chunkKCPBITYZjs.Get; exports.Guard = _chunkKCPBITYZjs.Guard; exports.HTTPGenerator = HTTPGenerator; exports.Head = _chunkKCPBITYZjs.Head; exports.Header = _chunkKCPBITYZjs.Header; exports.HttpBase = HttpBase; exports.IS_DEV = _chunk4LLLQOMFjs.IS_DEV; exports.IS_ONLY_GENERATE = _chunk4LLLQOMFjs.IS_ONLY_GENERATE; exports.IS_PURE = _chunk4LLLQOMFjs.IS_PURE; exports.IS_STRICT = _chunk4LLLQOMFjs.IS_STRICT; exports.InvalidInputException = _chunkG7JFKM2Mjs.InvalidInputException; exports.LOG_LEVEL = _chunk4LLLQOMFjs.LOG_LEVEL; exports.Meta = _chunk6OQ2SB5Wjs.Meta; exports.Mixin = _chunk4LLLQOMFjs.Mixin; exports.NotFoundException = _chunkG7JFKM2Mjs.NotFoundException; exports.PAddon = PAddon; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PPipe = PPipe; exports.PS_EXIT_CODE = _chunk4LLLQOMFjs.PS_EXIT_CODE; exports.Param = _chunkKCPBITYZjs.Param; exports.Patch = _chunkKCPBITYZjs.Patch; exports.PayloadLargeException = _chunkG7JFKM2Mjs.PayloadLargeException; exports.Pipe = _chunkKCPBITYZjs.Pipe; exports.Post = _chunkKCPBITYZjs.Post; exports.Put = _chunkKCPBITYZjs.Put; exports.Query = _chunkKCPBITYZjs.Query; exports.Queue = _chunkKCPBITYZjs.Queue; exports.RPCGenerator = RPCGenerator; exports.Route = _chunkKCPBITYZjs.Route; exports.Rpc = _chunkKCPBITYZjs.Rpc; exports.RpcBase = RpcBase; exports.Search = _chunkKCPBITYZjs.Search; exports.ServerBase = ServerBase; exports.ServerPhecda = _chunk6OQ2SB5Wjs.ServerPhecda; exports.ServiceUnavailableException = _chunkG7JFKM2Mjs.ServiceUnavailableException; exports.TimeoutException = _chunkG7JFKM2Mjs.TimeoutException; exports.TimerException = _chunkG7JFKM2Mjs.TimerException; exports.UnauthorizedException = _chunkG7JFKM2Mjs.UnauthorizedException; exports.UndefinedException = _chunkG7JFKM2Mjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkG7JFKM2Mjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkG7JFKM2Mjs.ValidateException; exports.WorkerException = _chunkG7JFKM2Mjs.WorkerException; exports.addAddon = _chunkG7JFKM2Mjs.addAddon; exports.addFilter = _chunkG7JFKM2Mjs.addFilter; exports.addGuard = _chunkG7JFKM2Mjs.addGuard; exports.addPipe = _chunkG7JFKM2Mjs.addPipe; exports.defaultPipe = _chunkG7JFKM2Mjs.defaultPipe; exports.defaultServerInject = _chunk6OQ2SB5Wjs.defaultServerInject; exports.emitter = _chunk6OQ2SB5Wjs.emitter; exports.getLogger = _chunk4LLLQOMFjs.getLogger; exports.log = _chunk4LLLQOMFjs.log; exports.phecdaNamespace = _chunk6OQ2SB5Wjs.phecdaNamespace; exports.runMiddleware = _chunk4LLLQOMFjs.runMiddleware; exports.setLogger = _chunk4LLLQOMFjs.setLogger; exports.useS = _chunk6OQ2SB5Wjs.useS;
|
package/dist/index.mjs
CHANGED
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
emitter,
|
|
7
7
|
phecdaNamespace,
|
|
8
8
|
useS
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YCES6ABN.mjs";
|
|
10
10
|
import {
|
|
11
11
|
Addon,
|
|
12
12
|
Arg,
|
|
13
13
|
BaseParam,
|
|
14
14
|
Body,
|
|
15
15
|
Controller,
|
|
16
|
-
Ctx,
|
|
16
|
+
Ctx as Ctx2,
|
|
17
17
|
Define,
|
|
18
18
|
Delete,
|
|
19
19
|
Filter,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
Route,
|
|
32
32
|
Rpc,
|
|
33
33
|
Search
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-MUI6MTUO.mjs";
|
|
35
35
|
import {
|
|
36
36
|
BadGatewayException,
|
|
37
37
|
BadRequestException,
|
|
@@ -55,12 +55,14 @@ import {
|
|
|
55
55
|
addFilter,
|
|
56
56
|
addGuard,
|
|
57
57
|
addPipe,
|
|
58
|
-
defaultPipe
|
|
59
|
-
|
|
58
|
+
defaultPipe,
|
|
59
|
+
joinUrl
|
|
60
|
+
} from "./chunk-Z7NAAE4M.mjs";
|
|
60
61
|
import {
|
|
61
62
|
ERROR_SYMBOL,
|
|
62
|
-
|
|
63
|
+
IS_DEV,
|
|
63
64
|
IS_ONLY_GENERATE,
|
|
65
|
+
IS_PURE,
|
|
64
66
|
IS_STRICT,
|
|
65
67
|
LOG_LEVEL,
|
|
66
68
|
Mixin,
|
|
@@ -70,7 +72,7 @@ import {
|
|
|
70
72
|
log,
|
|
71
73
|
runMiddleware,
|
|
72
74
|
setLogger
|
|
73
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-NQ55PA2X.mjs";
|
|
74
76
|
|
|
75
77
|
// src/types.ts
|
|
76
78
|
var ResponseSymbol = Symbol("response");
|
|
@@ -99,6 +101,9 @@ var ServerBase = class extends Base {
|
|
|
99
101
|
__name(this, "ServerBase");
|
|
100
102
|
}
|
|
101
103
|
emitter = emitter;
|
|
104
|
+
log(msg, level = "log") {
|
|
105
|
+
log(msg, level, this.tag);
|
|
106
|
+
}
|
|
102
107
|
};
|
|
103
108
|
var HttpBase = class extends ServerBase {
|
|
104
109
|
static {
|
|
@@ -107,8 +112,8 @@ var HttpBase = class extends ServerBase {
|
|
|
107
112
|
context;
|
|
108
113
|
};
|
|
109
114
|
_ts_decorate([
|
|
110
|
-
|
|
111
|
-
_ts_metadata("design:type", typeof
|
|
115
|
+
Ctx2,
|
|
116
|
+
_ts_metadata("design:type", typeof Ctx === "undefined" ? Object : Ctx)
|
|
112
117
|
], HttpBase.prototype, "context", void 0);
|
|
113
118
|
var RpcBase = class extends ServerBase {
|
|
114
119
|
static {
|
|
@@ -117,8 +122,8 @@ var RpcBase = class extends ServerBase {
|
|
|
117
122
|
context;
|
|
118
123
|
};
|
|
119
124
|
_ts_decorate([
|
|
120
|
-
|
|
121
|
-
_ts_metadata("design:type", typeof
|
|
125
|
+
Ctx2,
|
|
126
|
+
_ts_metadata("design:type", typeof Ctx === "undefined" ? Object : Ctx)
|
|
122
127
|
], RpcBase.prototype, "context", void 0);
|
|
123
128
|
|
|
124
129
|
// src/modules/filter.ts
|
|
@@ -304,11 +309,11 @@ var HTTPGenerator = class extends Generator {
|
|
|
304
309
|
addMethod(args) {
|
|
305
310
|
const { http, name, func, params, tag } = args;
|
|
306
311
|
if (!http?.type) return;
|
|
307
|
-
const url = http.prefix
|
|
312
|
+
const url = joinUrl(http.prefix, http.route).replace(/\/\:([^\/]*)/g, (_, js) => `/{{${js}}}`);
|
|
308
313
|
if (!this.classMap[name]) this.classMap[name] = {};
|
|
309
314
|
this.classMap[name][func] = `
|
|
310
315
|
${func}(...args){
|
|
311
|
-
const ret={tag:"${tag}",func:"${func}",body:{},headers:{},query:{},params:{},method:"${http.type}",url:"${url}"
|
|
316
|
+
const ret={tag:"${tag}",func:"${func}",body:{},headers:{},query:{},params:{},method:"${http.type}",url:"${url}"}
|
|
312
317
|
|
|
313
318
|
${params.reduce((p, c, i) => `${p}ret.${c.type}${c.key ? `['${c.key}']` : ""}=args[${i}]
|
|
314
319
|
${c.type === "params" ? `ret.url=ret.url.replace('{{${c.key}}}',args[${i}])` : ""}
|
|
@@ -337,7 +342,7 @@ export {
|
|
|
337
342
|
ConflictException,
|
|
338
343
|
Context,
|
|
339
344
|
Controller,
|
|
340
|
-
Ctx,
|
|
345
|
+
Ctx2 as Ctx,
|
|
341
346
|
CustomResponse,
|
|
342
347
|
Define,
|
|
343
348
|
Delete,
|
|
@@ -354,8 +359,9 @@ export {
|
|
|
354
359
|
Head,
|
|
355
360
|
Header,
|
|
356
361
|
HttpBase,
|
|
357
|
-
|
|
362
|
+
IS_DEV,
|
|
358
363
|
IS_ONLY_GENERATE,
|
|
364
|
+
IS_PURE,
|
|
359
365
|
IS_STRICT,
|
|
360
366
|
InvalidInputException,
|
|
361
367
|
LOG_LEVEL,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Events, Construct } from 'phecda-core';
|
|
2
2
|
|
|
3
3
|
declare const ERROR_SYMBOL = "__PS_ERROR__";
|
|
4
|
-
declare const
|
|
4
|
+
declare const IS_DEV: boolean;
|
|
5
5
|
declare const IS_ONLY_GENERATE: boolean;
|
|
6
6
|
declare const IS_STRICT: boolean;
|
|
7
|
+
declare const IS_PURE: boolean;
|
|
7
8
|
declare const LOG_LEVEL: number;
|
|
8
9
|
declare enum PS_EXIT_CODE {
|
|
9
|
-
RELAUNCH =
|
|
10
|
-
|
|
10
|
+
RELAUNCH = 4171,
|
|
11
|
+
EXIT = 4172
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
interface Emitter {
|
|
@@ -31,12 +32,13 @@ type ToClientInstance<Instance extends Record<string, any>> = ParseInstance<Pick
|
|
|
31
32
|
type ToClientFn<Func extends AnyFunction> = (...p: Parameters<Func>) => Promise<BaseReturn<ReturnType<Func>>>;
|
|
32
33
|
type PickFunc<Instance> = Pick<Instance, PickFuncKeys<Instance>>;
|
|
33
34
|
type OmitFunction<Instance> = Omit<Instance, PickFuncKeys<Instance>>;
|
|
34
|
-
interface
|
|
35
|
+
interface BaseCtx {
|
|
35
36
|
meta: ControllerMeta;
|
|
36
37
|
moduleMap: Record<string, any>;
|
|
37
38
|
type: string;
|
|
38
39
|
tag: string;
|
|
39
40
|
func: string;
|
|
41
|
+
category: string;
|
|
40
42
|
[key: string]: any;
|
|
41
43
|
}
|
|
42
44
|
interface DefaultOptions {
|
|
@@ -103,4 +105,4 @@ interface ControllerMeta extends Meta {
|
|
|
103
105
|
data: ControllerMetaData;
|
|
104
106
|
}
|
|
105
107
|
|
|
106
|
-
export { type
|
|
108
|
+
export { type BaseCtx as B, type ControllerMeta as C, type DefaultOptions as D, type Emitter as E, IS_DEV as I, LOG_LEVEL as L, Meta as M, type OmitFunction as O, type PickFunc as P, type ServiceMetaData as S, type ToClientMap as T, type ControllerMetaData as a, type MetaData as b, type BaseError as c, type ToClientInstance as d, type ToClientFn as e, type BaseReturn as f, type BaseRequestType as g, CustomResponse as h, type ExtractResponse as i, ERROR_SYMBOL as j, IS_ONLY_GENERATE as k, IS_STRICT as l, IS_PURE as m, PS_EXIT_CODE as n };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Events, Construct } from 'phecda-core';
|
|
2
2
|
|
|
3
3
|
declare const ERROR_SYMBOL = "__PS_ERROR__";
|
|
4
|
-
declare const
|
|
4
|
+
declare const IS_DEV: boolean;
|
|
5
5
|
declare const IS_ONLY_GENERATE: boolean;
|
|
6
6
|
declare const IS_STRICT: boolean;
|
|
7
|
+
declare const IS_PURE: boolean;
|
|
7
8
|
declare const LOG_LEVEL: number;
|
|
8
9
|
declare enum PS_EXIT_CODE {
|
|
9
|
-
RELAUNCH =
|
|
10
|
-
|
|
10
|
+
RELAUNCH = 4171,
|
|
11
|
+
EXIT = 4172
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
interface Emitter {
|
|
@@ -31,12 +32,13 @@ type ToClientInstance<Instance extends Record<string, any>> = ParseInstance<Pick
|
|
|
31
32
|
type ToClientFn<Func extends AnyFunction> = (...p: Parameters<Func>) => Promise<BaseReturn<ReturnType<Func>>>;
|
|
32
33
|
type PickFunc<Instance> = Pick<Instance, PickFuncKeys<Instance>>;
|
|
33
34
|
type OmitFunction<Instance> = Omit<Instance, PickFuncKeys<Instance>>;
|
|
34
|
-
interface
|
|
35
|
+
interface BaseCtx {
|
|
35
36
|
meta: ControllerMeta;
|
|
36
37
|
moduleMap: Record<string, any>;
|
|
37
38
|
type: string;
|
|
38
39
|
tag: string;
|
|
39
40
|
func: string;
|
|
41
|
+
category: string;
|
|
40
42
|
[key: string]: any;
|
|
41
43
|
}
|
|
42
44
|
interface DefaultOptions {
|
|
@@ -103,4 +105,4 @@ interface ControllerMeta extends Meta {
|
|
|
103
105
|
data: ControllerMetaData;
|
|
104
106
|
}
|
|
105
107
|
|
|
106
|
-
export { type
|
|
108
|
+
export { type BaseCtx as B, type ControllerMeta as C, type DefaultOptions as D, type Emitter as E, IS_DEV as I, LOG_LEVEL as L, Meta as M, type OmitFunction as O, type PickFunc as P, type ServiceMetaData as S, type ToClientMap as T, type ControllerMetaData as a, type MetaData as b, type BaseError as c, type ToClientInstance as d, type ToClientFn as e, type BaseReturn as f, type BaseRequestType as g, CustomResponse as h, type ExtractResponse as i, ERROR_SYMBOL as j, IS_ONLY_GENERATE as k, IS_STRICT as l, IS_PURE as m, PS_EXIT_CODE as n };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-DIfgUKIU.mjs';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DqH1qA-q.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-CR-D39hQ.mjs';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
|
-
interface BullmqCtx extends
|
|
7
|
+
interface BullmqCtx extends RpcCtx {
|
|
8
8
|
type: 'bullmq';
|
|
9
9
|
}
|
|
10
10
|
type BullmqOptions = Omit<RpcServerOptions, 'globalAddons'> & {
|
|
@@ -13,7 +13,7 @@ type BullmqOptions = Omit<RpcServerOptions, 'globalAddons'> & {
|
|
|
13
13
|
};
|
|
14
14
|
declare function create({ moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: BullmqOptions): Promise<{
|
|
15
15
|
workerMap: Record<string, Worker<any, any, string>>;
|
|
16
|
-
queueMap: Record<string, Queue<any, any, string>>;
|
|
16
|
+
queueMap: Record<string, Queue<any, any, string, any, any, string>>;
|
|
17
17
|
}>;
|
|
18
18
|
|
|
19
19
|
declare function createClient<S extends Record<string, any>>(controllers: S, opts?: RpcClientOptions & BullmqOptions): Promise<ToClientMap<S>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-CUTbX_IS.js';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DYRu0vic.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-CR-D39hQ.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
|
-
interface BullmqCtx extends
|
|
7
|
+
interface BullmqCtx extends RpcCtx {
|
|
8
8
|
type: 'bullmq';
|
|
9
9
|
}
|
|
10
10
|
type BullmqOptions = Omit<RpcServerOptions, 'globalAddons'> & {
|
|
@@ -13,7 +13,7 @@ type BullmqOptions = Omit<RpcServerOptions, 'globalAddons'> & {
|
|
|
13
13
|
};
|
|
14
14
|
declare function create({ moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: BullmqOptions): Promise<{
|
|
15
15
|
workerMap: Record<string, Worker<any, any, string>>;
|
|
16
|
-
queueMap: Record<string, Queue<any, any, string>>;
|
|
16
|
+
queueMap: Record<string, Queue<any, any, string, any, any, string>>;
|
|
17
17
|
}>;
|
|
18
18
|
|
|
19
19
|
declare function createClient<S extends Record<string, any>>(controllers: S, opts?: RpcClientOptions & BullmqOptions): Promise<ToClientMap<S>>;
|
package/dist/rpc/bullmq/index.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunkG7JFKM2Mjs = require('../../chunk-G7JFKM2M.js');
|
|
6
7
|
|
|
7
|
-
var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
11
11
|
|
|
12
12
|
// src/rpc/bullmq/create.ts
|
|
13
13
|
var _bullmq = require('bullmq');
|
|
@@ -18,14 +18,14 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
18
18
|
const workerMap = {};
|
|
19
19
|
const queueMap = {};
|
|
20
20
|
const existQueue = /* @__PURE__ */ new Set();
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkG7JFKM2Mjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
22
|
const { controller, rpc, func, tag } = meta2.data;
|
|
23
23
|
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
|
|
24
24
|
debug(`register method "${func}" in module "${tag}"`);
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
_chunkG7JFKM2Mjs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
guards: globalGuards
|
|
30
30
|
}, "rpc");
|
|
31
31
|
async function subscribeQueues() {
|
|
@@ -39,12 +39,12 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
39
39
|
if (existQueue.has(queue)) continue;
|
|
40
40
|
existQueue.add(queue);
|
|
41
41
|
workerMap[queue] = new (0, _bullmq.Worker)(queue, handleRequest, workerOpts);
|
|
42
|
-
|
|
42
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(addons, workerMap[queue], "bullmq");
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
_chunk4LLLQOMFjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
48
48
|
async function handleRequest(job) {
|
|
49
49
|
const { data } = job;
|
|
50
50
|
const { tag, func, args, id, queue: clientQueue, _ps } = data;
|
|
@@ -53,13 +53,14 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
53
53
|
const meta2 = metaMap.get(tag)[func];
|
|
54
54
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
55
55
|
if (!isEvent && !(clientQueue in queueMap)) queueMap[clientQueue] = new (0, _bullmq.Queue)(clientQueue, queueOpts);
|
|
56
|
-
const aop =
|
|
56
|
+
const aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
57
57
|
globalFilter,
|
|
58
58
|
globalGuards,
|
|
59
59
|
globalPipe
|
|
60
60
|
});
|
|
61
|
-
const context = new (0,
|
|
61
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)({
|
|
62
62
|
type: "bullmq",
|
|
63
|
+
category: "rpc",
|
|
63
64
|
moduleMap,
|
|
64
65
|
meta: meta2,
|
|
65
66
|
tag,
|
|
@@ -85,9 +86,9 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
85
86
|
}
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
+
_chunk4LLLQOMFjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
89
90
|
subscribeQueues();
|
|
90
|
-
|
|
91
|
+
_chunk4LLLQOMFjs.HMR.call(void 0, async () => {
|
|
91
92
|
for (const i in workerMap) await workerMap[i].close(true);
|
|
92
93
|
for (const i in queueMap) await queueMap[i].close();
|
|
93
94
|
await subscribeQueues();
|
|
@@ -97,7 +98,7 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
97
98
|
queueMap
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
|
-
|
|
101
|
+
_chunk4LLLQOMFjs.__name.call(void 0, create, "create");
|
|
101
102
|
|
|
102
103
|
// src/rpc/bullmq/client.ts
|
|
103
104
|
var _events = require('events');
|
|
@@ -108,7 +109,7 @@ async function createClient(controllers, opts = {}) {
|
|
|
108
109
|
const { max, workerOpts, queueOpts, timeout, key } = opts;
|
|
109
110
|
const ret = {};
|
|
110
111
|
const emitter = new (0, _events.EventEmitter)();
|
|
111
|
-
const clientQueue =
|
|
112
|
+
const clientQueue = _chunkG7JFKM2Mjs.genClientQueue.call(void 0, key);
|
|
112
113
|
const queueMap = {};
|
|
113
114
|
new (0, _bullmq.Worker)(clientQueue, async (job) => {
|
|
114
115
|
const { data, id, error } = job.data;
|
|
@@ -153,7 +154,7 @@ async function createClient(controllers, opts = {}) {
|
|
|
153
154
|
if (error) reject(data);
|
|
154
155
|
else resolve(data);
|
|
155
156
|
}
|
|
156
|
-
|
|
157
|
+
_chunk4LLLQOMFjs.__name.call(void 0, listener, "listener");
|
|
157
158
|
eventCount++;
|
|
158
159
|
emitter.once(id, listener);
|
|
159
160
|
});
|
|
@@ -163,7 +164,7 @@ async function createClient(controllers, opts = {}) {
|
|
|
163
164
|
}
|
|
164
165
|
return ret;
|
|
165
166
|
}
|
|
166
|
-
|
|
167
|
+
_chunk4LLLQOMFjs.__name.call(void 0, createClient, "createClient");
|
|
167
168
|
|
|
168
169
|
|
|
169
170
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Context,
|
|
3
|
-
HMR,
|
|
4
3
|
createControllerMetaMap,
|
|
5
4
|
detectAopDep,
|
|
6
5
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-Z7NAAE4M.mjs";
|
|
8
7
|
import {
|
|
8
|
+
HMR,
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-NQ55PA2X.mjs";
|
|
11
11
|
|
|
12
12
|
// src/rpc/bullmq/create.ts
|
|
13
13
|
import { Queue, Worker } from "bullmq";
|
|
@@ -60,6 +60,7 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
60
60
|
});
|
|
61
61
|
const context = new Context({
|
|
62
62
|
type: "bullmq",
|
|
63
|
+
category: "rpc",
|
|
63
64
|
moduleMap,
|
|
64
65
|
meta: meta2,
|
|
65
66
|
tag,
|