phecda-server 7.0.0-alpha.3 → 7.0.0-alpha.5
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/schema.json +55 -55
- package/dist/{chunk-MMG73S64.mjs → chunk-2ESEXJQM.mjs} +1 -1
- package/dist/{chunk-A53KNKY4.mjs → chunk-3ISYBU3P.mjs} +33 -3
- package/dist/{chunk-6EBEME3I.js → chunk-K54JYYXK.js} +51 -51
- package/dist/{chunk-RQSQRZL4.js → chunk-KFFS2P7I.js} +3 -1
- package/dist/{chunk-KUGFI6SC.mjs → chunk-PXLG75ED.mjs} +1 -1
- package/dist/{chunk-PKSWGQLW.js → chunk-TR5Z4SDI.js} +50 -20
- package/dist/{chunk-QD3QR3NW.mjs → chunk-UXGJD2PK.mjs} +2 -0
- package/dist/{chunk-QCOBXM7F.js → chunk-Y2OLA5OJ.js} +24 -24
- package/dist/{core-C1kHRqU9.d.ts → core-CzElxZoF.d.ts} +2 -1
- package/dist/{core-CSiaRU7r.d.mts → core-DU7gQKSk.d.mts} +2 -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 +37 -37
- 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 +35 -35
- 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 +40 -38
- package/dist/index.mjs +6 -4
- package/dist/{meta-D1M85Hef.d.ts → meta-BTnLXuCa.d.mts} +2 -1
- package/dist/{meta-D1M85Hef.d.mts → meta-BTnLXuCa.d.ts} +2 -1
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/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 +14 -14
- 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 +13 -13
- 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 +15 -15
- 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 +13 -13
- package/dist/rpc/redis/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-ee1FBodH.d.ts → types--E-OCZhC.d.ts} +1 -1
- package/dist/{types-JMhFVp-Z.d.mts → types-BYqBeqrs.d.mts} +1 -1
- package/dist/{types-wbHHC93P.d.mts → types-BxlzVoRv.d.mts} +1 -1
- package/dist/{types-C9Remkup.d.ts → types-CbfaGkPA.d.ts} +1 -1
- package/package.json +2 -2
- package/register/index.mjs +41 -40
- package/register/loader.mjs +37 -11
- package/register/utils.mjs +56 -56
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkKFFS2P7Ijs = require('./chunk-KFFS2P7I.js');
|
|
7
7
|
|
|
8
8
|
// src/meta.ts
|
|
9
9
|
var Meta = class {
|
|
10
10
|
static {
|
|
11
|
-
|
|
11
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, this, "Meta");
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
|
|
@@ -37,11 +37,11 @@ function defaultServerInject() {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, defaultServerInject, "defaultServerInject");
|
|
41
41
|
var phecdaNamespace = /* @__PURE__ */ new Map();
|
|
42
42
|
var ServerPhecda = (_class = class {
|
|
43
43
|
static {
|
|
44
|
-
|
|
44
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, this, "ServerPhecda");
|
|
45
45
|
}
|
|
46
46
|
__init() {this.moduleMap = /* @__PURE__ */ new Map()}
|
|
47
47
|
__init2() {this.meta = []}
|
|
@@ -53,7 +53,7 @@ var ServerPhecda = (_class = class {
|
|
|
53
53
|
|
|
54
54
|
constructor(options) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);
|
|
55
55
|
defaultServerInject();
|
|
56
|
-
const { namespace = "default", parseModule = /* @__PURE__ */
|
|
56
|
+
const { namespace = "default", parseModule = /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (module) => module, "parseModule"), parseMeta = /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (meta) => meta, "parseMeta"), generators = [] } = options;
|
|
57
57
|
phecdaNamespace.set(namespace, this);
|
|
58
58
|
this.parseMeta = parseMeta;
|
|
59
59
|
this.parseModule = parseModule;
|
|
@@ -61,8 +61,8 @@ var ServerPhecda = (_class = class {
|
|
|
61
61
|
}
|
|
62
62
|
async start(models) {
|
|
63
63
|
for (const model of models) await this.buildDepModule(model);
|
|
64
|
-
const generateCode = /* @__PURE__ */
|
|
65
|
-
if (
|
|
64
|
+
const generateCode = /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, async () => {
|
|
65
|
+
if (_chunkKFFS2P7Ijs.IS_HMR) {
|
|
66
66
|
return Promise.all(this.generators.map((generator) => {
|
|
67
67
|
debug(`generate "${generator.name}" code to ${generator.path}`);
|
|
68
68
|
return generator.output(this.meta);
|
|
@@ -70,9 +70,9 @@ var ServerPhecda = (_class = class {
|
|
|
70
70
|
}
|
|
71
71
|
}, "generateCode");
|
|
72
72
|
generateCode().then(() => {
|
|
73
|
-
if (
|
|
73
|
+
if (_chunkKFFS2P7Ijs.IS_ONLY_GENERATE) process.exit(4);
|
|
74
74
|
});
|
|
75
|
-
if (
|
|
75
|
+
if (_chunkKFFS2P7Ijs.IS_HMR) {
|
|
76
76
|
if (!globalThis.__PS_HMR__) globalThis.__PS_HMR__ = [];
|
|
77
77
|
_optionalChain([globalThis, 'access', _2 => _2.__PS_HMR__, 'optionalAccess', _3 => _3.push, 'call', _4 => _4(async (files) => {
|
|
78
78
|
debug("reload files ");
|
|
@@ -119,17 +119,45 @@ var ServerPhecda = (_class = class {
|
|
|
119
119
|
debug("destroy all");
|
|
120
120
|
for (const [tag] of this.moduleMap) await this.del(tag);
|
|
121
121
|
}
|
|
122
|
+
createProxyModule(tag) {
|
|
123
|
+
const that = this;
|
|
124
|
+
return new Proxy({}, {
|
|
125
|
+
get(_target, prop) {
|
|
126
|
+
const module = that.moduleMap.get(tag);
|
|
127
|
+
return Reflect.get(module, prop, module);
|
|
128
|
+
},
|
|
129
|
+
set(_target, prop, newValue) {
|
|
130
|
+
const module = that.moduleMap.get(tag);
|
|
131
|
+
return Reflect.set(module, prop, newValue, module);
|
|
132
|
+
},
|
|
133
|
+
has(_target, prop) {
|
|
134
|
+
return Reflect.has(that.moduleMap.get(tag), prop);
|
|
135
|
+
},
|
|
136
|
+
getPrototypeOf() {
|
|
137
|
+
return Reflect.getPrototypeOf(that.moduleMap.get(tag));
|
|
138
|
+
},
|
|
139
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
140
|
+
return Reflect.getOwnPropertyDescriptor(that.moduleMap.get(tag), prop);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
122
144
|
async buildDepModule(Model) {
|
|
123
145
|
const paramtypes = getParamTypes(Model);
|
|
124
146
|
let module;
|
|
125
147
|
const tag = _phecdacore.getTag.call(void 0, Model);
|
|
126
148
|
if (this.moduleMap.has(tag)) {
|
|
127
149
|
module = this.moduleMap.get(tag);
|
|
128
|
-
if (!module)
|
|
150
|
+
if (!module) {
|
|
151
|
+
_chunkKFFS2P7Ijs.log.call(void 0, `Exist Circular-Dependency or Multiple modules with the same tag [${String(tag)}]`, "warn");
|
|
152
|
+
return {
|
|
153
|
+
module: this.createProxyModule(tag),
|
|
154
|
+
tag
|
|
155
|
+
};
|
|
156
|
+
}
|
|
129
157
|
if (this.modelMap.get(module) !== Model && !this.modelSet.has(Model)) {
|
|
130
158
|
this.modelSet.add(Model);
|
|
131
|
-
if (module instanceof Model)
|
|
132
|
-
else
|
|
159
|
+
if (module instanceof Model) _chunkKFFS2P7Ijs.log.call(void 0, `Module taged ${String(tag)} has been overridden`);
|
|
160
|
+
else _chunkKFFS2P7Ijs.log.call(void 0, `Synonym module: Module taged "${String(tag)}" has been loaded before, so phecda-server won't load Module "${Model.name}"`, "warn");
|
|
133
161
|
}
|
|
134
162
|
return {
|
|
135
163
|
module,
|
|
@@ -152,7 +180,7 @@ var ServerPhecda = (_class = class {
|
|
|
152
180
|
}
|
|
153
181
|
this.meta.push(...getMetaFromInstance(module, tag, Model.name).map(this.parseMeta).filter((item) => !!item));
|
|
154
182
|
debug(`init module "${String(tag)}"`);
|
|
155
|
-
if (!
|
|
183
|
+
if (!_chunkKFFS2P7Ijs.IS_ONLY_GENERATE) await _phecdacore.invokeInit.call(void 0, module);
|
|
156
184
|
debug(`add module "${String(tag)}"`);
|
|
157
185
|
this.moduleMap.set(tag, module);
|
|
158
186
|
this.modelMap.set(module, Model);
|
|
@@ -175,7 +203,7 @@ async function Factory(models, opts = {}) {
|
|
|
175
203
|
await phecda.start(models);
|
|
176
204
|
return phecda;
|
|
177
205
|
}
|
|
178
|
-
|
|
206
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Factory, "Factory");
|
|
179
207
|
function useS(nsOrModel, namespace) {
|
|
180
208
|
if (!nsOrModel) {
|
|
181
209
|
namespace = "default";
|
|
@@ -188,7 +216,7 @@ function useS(nsOrModel, namespace) {
|
|
|
188
216
|
if (nsOrModel && typeof nsOrModel !== "string") return serverPhecda.get(nsOrModel);
|
|
189
217
|
else return serverPhecda;
|
|
190
218
|
}
|
|
191
|
-
|
|
219
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, useS, "useS");
|
|
192
220
|
function getMetaFromInstance(instance, tag, name) {
|
|
193
221
|
const propertyKeys = _phecdacore.getMetaKey.call(void 0, instance).filter((item) => typeof item === "string");
|
|
194
222
|
const baseMeta = _phecdacore.getMergedMeta.call(void 0, instance, void 0);
|
|
@@ -202,7 +230,7 @@ function getMetaFromInstance(instance, tag, name) {
|
|
|
202
230
|
func: i
|
|
203
231
|
};
|
|
204
232
|
if (baseMeta.controller) {
|
|
205
|
-
if (typeof tag !== "string")
|
|
233
|
+
if (typeof tag !== "string") _chunkKFFS2P7Ijs.log.call(void 0, `can't use Tag with ${typeof tag} on controller "${instance.constructor.name}",instead with "${tag = String(tag)}"`, "error");
|
|
206
234
|
metaData.controller = baseMeta.controller;
|
|
207
235
|
metaData[baseMeta.controller] = {
|
|
208
236
|
...baseMeta[baseMeta.controller],
|
|
@@ -240,7 +268,7 @@ function getMetaFromInstance(instance, tag, name) {
|
|
|
240
268
|
return new Meta(deepFreeze(metaData), getParamTypes(instance, i) || []);
|
|
241
269
|
});
|
|
242
270
|
}
|
|
243
|
-
|
|
271
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, getMetaFromInstance, "getMetaFromInstance");
|
|
244
272
|
function deepFreeze(object) {
|
|
245
273
|
Object.freeze(object);
|
|
246
274
|
Object.getOwnPropertyNames(object).forEach((prop) => {
|
|
@@ -248,11 +276,13 @@ function deepFreeze(object) {
|
|
|
248
276
|
});
|
|
249
277
|
return object;
|
|
250
278
|
}
|
|
251
|
-
|
|
279
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, deepFreeze, "deepFreeze");
|
|
252
280
|
function getParamTypes(Model, key) {
|
|
253
|
-
|
|
281
|
+
const paramTypes = Reflect.getMetadata("design:paramtypes", Model, key);
|
|
282
|
+
if (typeof paramTypes === "function") return paramTypes();
|
|
283
|
+
else return paramTypes;
|
|
254
284
|
}
|
|
255
|
-
|
|
285
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, getParamTypes, "getParamTypes");
|
|
256
286
|
|
|
257
287
|
|
|
258
288
|
|
|
@@ -7,6 +7,7 @@ var IS_HMR = process.env.NODE_ENV === "development";
|
|
|
7
7
|
var IS_ONLY_GENERATE = !!process.env.PS_GENERATE;
|
|
8
8
|
var IS_STRICT = !!process.env.PS_STRICT;
|
|
9
9
|
var LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0);
|
|
10
|
+
var IS_READY = Symbol("IS_READY");
|
|
10
11
|
var PS_EXIT_CODE = /* @__PURE__ */ function(PS_EXIT_CODE2) {
|
|
11
12
|
PS_EXIT_CODE2[PS_EXIT_CODE2["RELAUNCH"] = 2] = "RELAUNCH";
|
|
12
13
|
PS_EXIT_CODE2[PS_EXIT_CODE2["CODE"] = 4] = "CODE";
|
|
@@ -64,6 +65,7 @@ export {
|
|
|
64
65
|
IS_ONLY_GENERATE,
|
|
65
66
|
IS_STRICT,
|
|
66
67
|
LOG_LEVEL,
|
|
68
|
+
IS_READY,
|
|
67
69
|
PS_EXIT_CODE,
|
|
68
70
|
setLogger,
|
|
69
71
|
getLogger,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkKFFS2P7Ijs = require('./chunk-KFFS2P7I.js');
|
|
4
4
|
|
|
5
5
|
// src/decorators/param.ts
|
|
6
6
|
var _phecdacore = require('phecda-core');
|
|
@@ -10,42 +10,42 @@ function BaseParam(data) {
|
|
|
10
10
|
_phecdacore.setMeta.call(void 0, target, property, index, data);
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, BaseParam, "BaseParam");
|
|
14
14
|
function Body(key = "") {
|
|
15
15
|
return BaseParam({
|
|
16
16
|
type: "body",
|
|
17
17
|
key
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Body, "Body");
|
|
21
21
|
function Head(key) {
|
|
22
22
|
return BaseParam({
|
|
23
23
|
type: "headers",
|
|
24
24
|
key: key.toLowerCase()
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Head, "Head");
|
|
28
28
|
function Query(key = "") {
|
|
29
29
|
return BaseParam({
|
|
30
30
|
type: "query",
|
|
31
31
|
key
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Query, "Query");
|
|
35
35
|
function Param(key) {
|
|
36
36
|
return BaseParam({
|
|
37
37
|
type: "params",
|
|
38
38
|
key
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Param, "Param");
|
|
42
42
|
function Arg(target, k, index) {
|
|
43
43
|
BaseParam({
|
|
44
44
|
type: "args",
|
|
45
45
|
key: `${index}`
|
|
46
46
|
})(target, k, index);
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Arg, "Arg");
|
|
49
49
|
|
|
50
50
|
// src/decorators/aop.ts
|
|
51
51
|
|
|
@@ -56,7 +56,7 @@ function Guard(...guards) {
|
|
|
56
56
|
});
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Guard, "Guard");
|
|
60
60
|
function Addon(...addons) {
|
|
61
61
|
return (target, property) => {
|
|
62
62
|
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
@@ -64,7 +64,7 @@ function Addon(...addons) {
|
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Addon, "Addon");
|
|
68
68
|
function Filter(filter) {
|
|
69
69
|
return (target, property) => {
|
|
70
70
|
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
@@ -72,7 +72,7 @@ function Filter(filter) {
|
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Filter, "Filter");
|
|
76
76
|
function Pipe(pipe) {
|
|
77
77
|
return (target, property, index) => {
|
|
78
78
|
if (typeof index === "number") {
|
|
@@ -86,7 +86,7 @@ function Pipe(pipe) {
|
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Pipe, "Pipe");
|
|
90
90
|
|
|
91
91
|
// src/decorators/http.ts
|
|
92
92
|
|
|
@@ -100,7 +100,7 @@ function Route(route, type) {
|
|
|
100
100
|
});
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
|
|
103
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Route, "Route");
|
|
104
104
|
function Header(headers) {
|
|
105
105
|
return (target, property) => {
|
|
106
106
|
_phecdacore.setMeta.call(void 0, target, property, void 0, {
|
|
@@ -110,31 +110,31 @@ function Header(headers) {
|
|
|
110
110
|
});
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Header, "Header");
|
|
114
114
|
function Get(route = "") {
|
|
115
115
|
return Route(route, "get");
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Get, "Get");
|
|
118
118
|
function Post(route = "") {
|
|
119
119
|
return Route(route, "post");
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Post, "Post");
|
|
122
122
|
function Put(route = "") {
|
|
123
123
|
return Route(route, "put");
|
|
124
124
|
}
|
|
125
|
-
|
|
125
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Put, "Put");
|
|
126
126
|
function Search(route = "") {
|
|
127
127
|
return Route(route, "search");
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Search, "Search");
|
|
130
130
|
function Patch(route = "") {
|
|
131
131
|
return Route(route, "patch");
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Patch, "Patch");
|
|
134
134
|
function Delete(route = "") {
|
|
135
135
|
return Route(route, "delete");
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Delete, "Delete");
|
|
138
138
|
function Controller(prefix = "") {
|
|
139
139
|
return (target) => {
|
|
140
140
|
_phecdacore.setMeta.call(void 0, target, void 0, void 0, {
|
|
@@ -145,7 +145,7 @@ function Controller(prefix = "") {
|
|
|
145
145
|
});
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Controller, "Controller");
|
|
149
149
|
|
|
150
150
|
// src/decorators/rpc.ts
|
|
151
151
|
|
|
@@ -159,7 +159,7 @@ function Queue(queue = "", isEvent) {
|
|
|
159
159
|
});
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Queue, "Queue");
|
|
163
163
|
function Rpc() {
|
|
164
164
|
return (target) => {
|
|
165
165
|
_phecdacore.setMeta.call(void 0, target, void 0, void 0, {
|
|
@@ -167,11 +167,11 @@ function Rpc() {
|
|
|
167
167
|
});
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Rpc, "Rpc");
|
|
171
171
|
|
|
172
172
|
// src/decorators/ctx.ts
|
|
173
173
|
|
|
174
|
-
var Ctx = /* @__PURE__ */
|
|
174
|
+
var Ctx = /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (target, property) => {
|
|
175
175
|
_phecdacore.setMeta.call(void 0, target, _phecdacore.SHARE_KEY, void 0, {
|
|
176
176
|
ctxs: [
|
|
177
177
|
property
|
|
@@ -200,7 +200,7 @@ function Define(key, value) {
|
|
|
200
200
|
}
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Define, "Define");
|
|
204
204
|
|
|
205
205
|
|
|
206
206
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Construct } from 'phecda-core';
|
|
2
|
-
import { b as MetaData, M as Meta, E as Emitter } from './meta-
|
|
2
|
+
import { b as MetaData, M as Meta, E as Emitter } from './meta-BTnLXuCa.js';
|
|
3
3
|
|
|
4
4
|
declare abstract class Generator {
|
|
5
5
|
private _path;
|
|
@@ -33,6 +33,7 @@ declare class ServerPhecda {
|
|
|
33
33
|
add(Model: Construct): Promise<void>;
|
|
34
34
|
del(tag: PropertyKey): Promise<any>;
|
|
35
35
|
destroy(): Promise<void>;
|
|
36
|
+
createProxyModule(tag: PropertyKey): {};
|
|
36
37
|
protected buildDepModule(Model: Construct): Promise<{
|
|
37
38
|
module: any;
|
|
38
39
|
tag: PropertyKey;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Construct } from 'phecda-core';
|
|
2
|
-
import { b as MetaData, M as Meta, E as Emitter } from './meta-
|
|
2
|
+
import { b as MetaData, M as Meta, E as Emitter } from './meta-BTnLXuCa.mjs';
|
|
3
3
|
|
|
4
4
|
declare abstract class Generator {
|
|
5
5
|
private _path;
|
|
@@ -33,6 +33,7 @@ declare class ServerPhecda {
|
|
|
33
33
|
add(Model: Construct): Promise<void>;
|
|
34
34
|
del(tag: PropertyKey): Promise<any>;
|
|
35
35
|
destroy(): Promise<void>;
|
|
36
|
+
createProxyModule(tag: PropertyKey): {};
|
|
36
37
|
protected buildDepModule(Model: Construct): Promise<{
|
|
37
38
|
module: any;
|
|
38
39
|
tag: PropertyKey;
|
package/dist/helper.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-
|
|
1
|
+
import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-BTnLXuCa.mjs';
|
|
2
2
|
import 'phecda-core';
|
|
3
3
|
|
|
4
4
|
declare function HMR(cb: (...args: any) => any): void;
|
package/dist/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-
|
|
1
|
+
import { C as ControllerMetaData, M as Meta, a as ControllerMeta } from './meta-BTnLXuCa.js';
|
|
2
2
|
import 'phecda-core';
|
|
3
3
|
|
|
4
4
|
declare function HMR(cb: (...args: any) => any): void;
|
package/dist/helper.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
require('./chunk-
|
|
10
|
+
var _chunkK54JYYXKjs = require('./chunk-K54JYYXK.js');
|
|
11
|
+
require('./chunk-KFFS2P7I.js');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -18,4 +18,4 @@ require('./chunk-RQSQRZL4.js');
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
exports.HMR =
|
|
21
|
+
exports.HMR = _chunkK54JYYXKjs.HMR; exports.argToReq = _chunkK54JYYXKjs.argToReq; exports.createControllerMetaMap = _chunkK54JYYXKjs.createControllerMetaMap; exports.detectAopDep = _chunkK54JYYXKjs.detectAopDep; exports.genClientQueue = _chunkK54JYYXKjs.genClientQueue; exports.mergeObject = _chunkK54JYYXKjs.mergeObject; exports.resolveDep = _chunkK54JYYXKjs.resolveDep; exports.shallowClone = _chunkK54JYYXKjs.shallowClone;
|
package/dist/helper.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
|
|
2
2
|
import { BaseMacro } from 'elysia/dist/types';
|
|
3
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpContext, a as HttpOptions } from '../../types-BxlzVoRv.mjs';
|
|
4
|
+
import { F as Factory } from '../../core-DU7gQKSk.mjs';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-BTnLXuCa.mjs';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
9
|
interface ElysiaCtx extends HttpContext {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Elysia as Elysia$1, Context, LocalHook, InputSchema, RouteSchema, SingletonBase } from 'elysia';
|
|
2
2
|
import { BaseMacro } from 'elysia/dist/types';
|
|
3
|
-
import { H as HttpContext, a as HttpOptions } from '../../types-
|
|
4
|
-
import { F as Factory } from '../../core-
|
|
3
|
+
import { H as HttpContext, a as HttpOptions } from '../../types--E-OCZhC.js';
|
|
4
|
+
import { F as Factory } from '../../core-CzElxZoF.js';
|
|
5
5
|
import 'node:http';
|
|
6
|
-
import '../../meta-
|
|
6
|
+
import '../../meta-BTnLXuCa.js';
|
|
7
7
|
import 'phecda-core';
|
|
8
8
|
|
|
9
9
|
interface ElysiaCtx extends HttpContext {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkY2OLA5OJjs = require('../../chunk-Y2OLA5OJ.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkK54JYYXKjs = require('../../chunk-K54JYYXK.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkKFFS2P7Ijs = require('../../chunk-KFFS2P7I.js');
|
|
14
14
|
|
|
15
15
|
// src/http/elysia/bind.ts
|
|
16
16
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -19,14 +19,14 @@ var debug = _debug2.default.call(void 0, "phecda-server/elysia");
|
|
|
19
19
|
function bind(app, data, opts = {}) {
|
|
20
20
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
21
21
|
const { moduleMap, meta } = data;
|
|
22
|
-
const metaMap =
|
|
22
|
+
const metaMap = _chunkK54JYYXKjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
23
23
|
const { controller, http, func, tag } = meta2.data;
|
|
24
24
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
25
25
|
debug(`register method "${func}" in module "${tag}"`);
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
-
|
|
29
|
+
_chunkK54JYYXKjs.detectAopDep.call(void 0, meta, {
|
|
30
30
|
addons: [
|
|
31
31
|
...globalAddons,
|
|
32
32
|
...parallelAddons
|
|
@@ -35,29 +35,29 @@ function bind(app, data, opts = {}) {
|
|
|
35
35
|
});
|
|
36
36
|
registerRoute();
|
|
37
37
|
function registerRoute() {
|
|
38
|
-
|
|
38
|
+
_chunkK54JYYXKjs.Context.applyAddons(globalAddons, app, "elysia");
|
|
39
39
|
if (parallelRoute) {
|
|
40
40
|
const parallelRouter = new (0, _elysia.Elysia)();
|
|
41
|
-
|
|
41
|
+
_chunkK54JYYXKjs.Context.applyAddons(parallelAddons, app, "elysia");
|
|
42
42
|
parallelRouter.post(parallelRoute, async (c) => {
|
|
43
43
|
const { body } = c;
|
|
44
44
|
async function errorHandler(e) {
|
|
45
|
-
const error = await
|
|
45
|
+
const error = await _chunkK54JYYXKjs.Context.filterRecord.default(e);
|
|
46
46
|
c.set.status = error.status;
|
|
47
47
|
return error;
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
49
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, errorHandler, "errorHandler");
|
|
50
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkK54JYYXKjs.BadRequestException)("data format should be an array"));
|
|
51
51
|
try {
|
|
52
52
|
return Promise.all(body.map((item, i) => {
|
|
53
53
|
return new Promise(async (resolve) => {
|
|
54
54
|
const { tag, func } = item;
|
|
55
55
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
56
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
56
|
+
if (!metaMap.has(tag)) return resolve(await _chunkK54JYYXKjs.Context.filterRecord.default(new (0, _chunkK54JYYXKjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
57
57
|
const meta2 = metaMap.get(tag)[func];
|
|
58
|
-
if (!meta2) return resolve(await
|
|
58
|
+
if (!meta2) return resolve(await _chunkK54JYYXKjs.Context.filterRecord.default(new (0, _chunkK54JYYXKjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
59
59
|
const { data: { params } } = meta2;
|
|
60
|
-
const aop =
|
|
60
|
+
const aop = _chunkK54JYYXKjs.Context.getAop(meta2, {
|
|
61
61
|
globalGuards,
|
|
62
62
|
globalFilter,
|
|
63
63
|
globalPipe
|
|
@@ -73,24 +73,24 @@ function bind(app, data, opts = {}) {
|
|
|
73
73
|
tag,
|
|
74
74
|
func,
|
|
75
75
|
app,
|
|
76
|
-
...
|
|
77
|
-
getCookie: /* @__PURE__ */
|
|
78
|
-
setCookie: /* @__PURE__ */
|
|
76
|
+
..._chunkK54JYYXKjs.argToReq.call(void 0, params, item.args, c.headers),
|
|
77
|
+
getCookie: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
|
|
78
|
+
setCookie: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
|
|
79
79
|
...opts2,
|
|
80
80
|
value
|
|
81
81
|
}), "setCookie"),
|
|
82
|
-
delCookie: /* @__PURE__ */
|
|
83
|
-
redirect: /* @__PURE__ */
|
|
84
|
-
setResHeaders: /* @__PURE__ */
|
|
85
|
-
setResStatus: /* @__PURE__ */
|
|
86
|
-
getRequest: /* @__PURE__ */
|
|
82
|
+
delCookie: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
|
|
83
|
+
redirect: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
84
|
+
setResHeaders: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
|
|
85
|
+
setResStatus: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (status) => c.set.status = status, "setResStatus"),
|
|
86
|
+
getRequest: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, () => {
|
|
87
87
|
throw new Error("elysia can't support getRequest");
|
|
88
88
|
}, "getRequest"),
|
|
89
|
-
getResponse: /* @__PURE__ */
|
|
89
|
+
getResponse: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, () => {
|
|
90
90
|
throw new Error("elysia can't support getResponse");
|
|
91
91
|
}, "getResponse")
|
|
92
92
|
};
|
|
93
|
-
const context = new (0,
|
|
93
|
+
const context = new (0, _chunkK54JYYXKjs.Context)(contextData);
|
|
94
94
|
context.run(aop, resolve, resolve);
|
|
95
95
|
});
|
|
96
96
|
})).then((ret) => {
|
|
@@ -112,13 +112,13 @@ function bind(app, data, opts = {}) {
|
|
|
112
112
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
113
113
|
let aop;
|
|
114
114
|
if (!dynamic) {
|
|
115
|
-
aop =
|
|
115
|
+
aop = _chunkK54JYYXKjs.Context.getAop(meta2, {
|
|
116
116
|
globalFilter,
|
|
117
117
|
globalGuards,
|
|
118
118
|
globalPipe
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
_chunkK54JYYXKjs.Context.applyAddons(addons, subApp, "elysia");
|
|
122
122
|
subApp[http.type](http.prefix + http.route, async (c) => {
|
|
123
123
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
124
124
|
const contextData = {
|
|
@@ -134,33 +134,33 @@ function bind(app, data, opts = {}) {
|
|
|
134
134
|
params: c.params,
|
|
135
135
|
headers: c.headers,
|
|
136
136
|
app,
|
|
137
|
-
getCookie: /* @__PURE__ */
|
|
138
|
-
setCookie: /* @__PURE__ */
|
|
137
|
+
getCookie: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (key) => c.cookie[key].value, "getCookie"),
|
|
138
|
+
setCookie: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (key, value, opts2 = {}) => c.cookie[key].set({
|
|
139
139
|
...opts2,
|
|
140
140
|
value
|
|
141
141
|
}), "setCookie"),
|
|
142
|
-
delCookie: /* @__PURE__ */
|
|
143
|
-
redirect: /* @__PURE__ */
|
|
144
|
-
setResHeaders: /* @__PURE__ */
|
|
145
|
-
setResStatus: /* @__PURE__ */
|
|
146
|
-
getRequest: /* @__PURE__ */
|
|
142
|
+
delCookie: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (key) => c.cookie[key].remove(), "delCookie"),
|
|
143
|
+
redirect: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (url) => c.redirect(url), "redirect"),
|
|
144
|
+
setResHeaders: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (headers) => Object.assign(c.set.headers, headers), "setResHeaders"),
|
|
145
|
+
setResStatus: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, (status) => c.set.status = status, "setResStatus"),
|
|
146
|
+
getRequest: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, () => {
|
|
147
147
|
throw new Error("elysia can't support getRequest");
|
|
148
148
|
}, "getRequest"),
|
|
149
|
-
getResponse: /* @__PURE__ */
|
|
149
|
+
getResponse: /* @__PURE__ */ _chunkKFFS2P7Ijs.__name.call(void 0, () => {
|
|
150
150
|
throw new Error("elysia can't support getResponse");
|
|
151
151
|
}, "getResponse")
|
|
152
152
|
};
|
|
153
153
|
if (dynamic) {
|
|
154
|
-
aop =
|
|
154
|
+
aop = _chunkK54JYYXKjs.Context.getAop(meta2, {
|
|
155
155
|
globalFilter,
|
|
156
156
|
globalGuards,
|
|
157
157
|
globalPipe
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
|
-
const context = new (0,
|
|
160
|
+
const context = new (0, _chunkK54JYYXKjs.Context)(contextData);
|
|
161
161
|
if (http.headers) c.set.headers = http.headers;
|
|
162
162
|
if (dynamic) {
|
|
163
|
-
aop =
|
|
163
|
+
aop = _chunkK54JYYXKjs.Context.getAop(meta2, {
|
|
164
164
|
globalFilter,
|
|
165
165
|
globalGuards,
|
|
166
166
|
globalPipe
|
|
@@ -175,13 +175,13 @@ function bind(app, data, opts = {}) {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, registerRoute, "registerRoute");
|
|
179
179
|
}
|
|
180
|
-
|
|
180
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, bind, "bind");
|
|
181
181
|
function Elysia(opts) {
|
|
182
|
-
return
|
|
182
|
+
return _chunkY2OLA5OJjs.Define.call(void 0, "elysia", opts);
|
|
183
183
|
}
|
|
184
|
-
|
|
184
|
+
_chunkKFFS2P7Ijs.__name.call(void 0, Elysia, "Elysia");
|
|
185
185
|
|
|
186
186
|
|
|
187
187
|
|