phecda-server 7.0.0-alpha.1 → 7.0.0-alpha.11
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 +33 -25
- 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 -6
- package/register/export.mjs +30 -0
- package/register/index.mjs +50 -40
- package/register/loader.mjs +110 -74
- package/register/utils.mjs +86 -56
- package/dist/chunk-J5CFUN4V.js +0 -73
- package/dist/chunk-WHJ5FALK.mjs +0 -73
package/dist/http/koa/index.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
var _chunkG7JFKM2Mjs = require('../../chunk-G7JFKM2M.js');
|
|
7
8
|
|
|
8
|
-
var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
12
12
|
|
|
13
13
|
// src/http/koa/bind.ts
|
|
14
14
|
var _router = require('@koa/router'); var _router2 = _interopRequireDefault(_router);
|
|
@@ -18,14 +18,14 @@ function bind(router, data, opts = {}) {
|
|
|
18
18
|
const { globalGuards, parallelRoute = "/__PHECDA_SERVER__", globalAddons = [], parallelAddons = [], globalFilter, globalPipe, dynamic = false } = opts;
|
|
19
19
|
const { moduleMap, meta } = data;
|
|
20
20
|
const originStack = router.stack.slice(0, router.stack.length);
|
|
21
|
-
const metaMap =
|
|
21
|
+
const metaMap = _chunkG7JFKM2Mjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
22
22
|
const { controller, http, func, tag } = meta2.data;
|
|
23
23
|
if (controller === "http" && _optionalChain([http, 'optionalAccess', _ => _.type])) {
|
|
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
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -34,35 +34,35 @@ function bind(router, data, opts = {}) {
|
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
36
|
function registerRoute() {
|
|
37
|
-
|
|
37
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(globalAddons, router, "koa");
|
|
38
38
|
if (parallelRoute) {
|
|
39
39
|
const subRouter = new (0, _router2.default)();
|
|
40
|
-
|
|
40
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(parallelAddons, subRouter, "koa");
|
|
41
41
|
subRouter.post(parallelRoute, async (ctx, next) => {
|
|
42
42
|
const { body } = ctx.request;
|
|
43
43
|
async function errorHandler(e) {
|
|
44
|
-
const error = await
|
|
44
|
+
const error = await _chunkG7JFKM2Mjs.Context.filterRecord.default(e);
|
|
45
45
|
ctx.status = error.status;
|
|
46
46
|
ctx.body = error;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
48
|
+
_chunk4LLLQOMFjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
49
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkG7JFKM2Mjs.BadRequestException)("data format should be an array"));
|
|
50
50
|
try {
|
|
51
51
|
return Promise.all(body.map((item, i) => {
|
|
52
52
|
return new Promise(async (resolve) => {
|
|
53
53
|
const { tag, func } = item;
|
|
54
54
|
debug(`(parallel)invoke method "${func}" in module "${tag}"`);
|
|
55
|
-
if (!metaMap.has(tag)) return resolve(await
|
|
55
|
+
if (!metaMap.has(tag)) return resolve(await _chunkG7JFKM2Mjs.Context.filterRecord.default(new (0, _chunkG7JFKM2Mjs.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
56
56
|
const meta2 = metaMap.get(tag)[func];
|
|
57
|
-
if (!meta2) return resolve(await
|
|
58
|
-
const
|
|
59
|
-
const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
|
|
57
|
+
if (!meta2) return resolve(await _chunkG7JFKM2Mjs.Context.filterRecord.default(new (0, _chunkG7JFKM2Mjs.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
58
|
+
const aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
60
59
|
globalGuards,
|
|
61
60
|
globalFilter,
|
|
62
61
|
globalPipe
|
|
63
62
|
});
|
|
64
63
|
const contextData = {
|
|
65
64
|
type: "koa",
|
|
65
|
+
category: "http",
|
|
66
66
|
index: i,
|
|
67
67
|
ctx,
|
|
68
68
|
meta: meta2,
|
|
@@ -70,21 +70,19 @@ function bind(router, data, opts = {}) {
|
|
|
70
70
|
parallel: true,
|
|
71
71
|
next,
|
|
72
72
|
app: router,
|
|
73
|
-
...
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
setCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
|
|
78
|
-
delCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
|
|
73
|
+
...item,
|
|
74
|
+
getCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
|
|
75
|
+
setCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
|
|
76
|
+
delCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
|
|
79
77
|
expires: /* @__PURE__ */ new Date(0)
|
|
80
78
|
}), "delCookie"),
|
|
81
|
-
redirect: /* @__PURE__ */
|
|
82
|
-
setResHeaders: /* @__PURE__ */
|
|
83
|
-
setResStatus: /* @__PURE__ */
|
|
84
|
-
getRequest: /* @__PURE__ */
|
|
85
|
-
getResponse: /* @__PURE__ */
|
|
79
|
+
redirect: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
|
|
80
|
+
setResHeaders: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
|
|
81
|
+
setResStatus: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
|
|
82
|
+
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
83
|
+
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
86
84
|
};
|
|
87
|
-
const context = new (0,
|
|
85
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)(contextData);
|
|
88
86
|
context.run(aop, resolve, resolve);
|
|
89
87
|
});
|
|
90
88
|
})).then((ret) => {
|
|
@@ -103,15 +101,15 @@ function bind(router, data, opts = {}) {
|
|
|
103
101
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
104
102
|
let aop;
|
|
105
103
|
if (!dynamic) {
|
|
106
|
-
aop =
|
|
104
|
+
aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
107
105
|
globalFilter,
|
|
108
106
|
globalGuards,
|
|
109
107
|
globalPipe
|
|
110
108
|
});
|
|
111
109
|
}
|
|
112
110
|
const subRouter = new (0, _router2.default)();
|
|
113
|
-
|
|
114
|
-
router[http.type](http.prefix
|
|
111
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(addons, subRouter, "koa");
|
|
112
|
+
router[http.type](_chunkG7JFKM2Mjs.joinUrl.call(void 0, http.prefix, http.route), async (ctx, next) => {
|
|
115
113
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
116
114
|
const contextData = {
|
|
117
115
|
type: "koa",
|
|
@@ -123,24 +121,25 @@ function bind(router, data, opts = {}) {
|
|
|
123
121
|
func,
|
|
124
122
|
query: ctx.query,
|
|
125
123
|
params: ctx.params,
|
|
124
|
+
category: "http",
|
|
126
125
|
body: ctx.request.body,
|
|
127
126
|
headers: ctx.headers,
|
|
128
127
|
next,
|
|
129
|
-
getCookie: /* @__PURE__ */
|
|
130
|
-
setCookie: /* @__PURE__ */
|
|
131
|
-
delCookie: /* @__PURE__ */
|
|
128
|
+
getCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
|
|
129
|
+
setCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
|
|
130
|
+
delCookie: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (key) => ctx.cookies.set(key, "", {
|
|
132
131
|
expires: /* @__PURE__ */ new Date(0)
|
|
133
132
|
}), "delCookie"),
|
|
134
|
-
redirect: /* @__PURE__ */
|
|
135
|
-
setResHeaders: /* @__PURE__ */
|
|
136
|
-
setResStatus: /* @__PURE__ */
|
|
137
|
-
getRequest: /* @__PURE__ */
|
|
138
|
-
getResponse: /* @__PURE__ */
|
|
133
|
+
redirect: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (url) => ctx.redirect(url), "redirect"),
|
|
134
|
+
setResHeaders: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (headers) => ctx.set(headers), "setResHeaders"),
|
|
135
|
+
setResStatus: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, (status) => ctx.status = status, "setResStatus"),
|
|
136
|
+
getRequest: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
137
|
+
getResponse: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
139
138
|
};
|
|
140
|
-
const context = new (0,
|
|
139
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)(contextData);
|
|
141
140
|
if (http.headers) ctx.set(http.headers);
|
|
142
141
|
if (dynamic) {
|
|
143
|
-
aop =
|
|
142
|
+
aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
144
143
|
globalFilter,
|
|
145
144
|
globalGuards,
|
|
146
145
|
globalPipe
|
|
@@ -159,13 +158,13 @@ function bind(router, data, opts = {}) {
|
|
|
159
158
|
}
|
|
160
159
|
}
|
|
161
160
|
}
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
_chunk4LLLQOMFjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
162
|
+
_chunk4LLLQOMFjs.HMR.call(void 0, async () => {
|
|
164
163
|
router.stack = originStack;
|
|
165
164
|
registerRoute();
|
|
166
165
|
});
|
|
167
166
|
}
|
|
168
|
-
|
|
167
|
+
_chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
|
|
169
168
|
|
|
170
169
|
|
|
171
170
|
exports.bind = bind;
|
package/dist/http/koa/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BadRequestException,
|
|
3
3
|
Context,
|
|
4
|
-
HMR,
|
|
5
|
-
argToReq,
|
|
6
4
|
createControllerMetaMap,
|
|
7
|
-
detectAopDep
|
|
8
|
-
|
|
5
|
+
detectAopDep,
|
|
6
|
+
joinUrl
|
|
7
|
+
} from "../../chunk-Z7NAAE4M.mjs";
|
|
9
8
|
import {
|
|
9
|
+
HMR,
|
|
10
10
|
__name
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-NQ55PA2X.mjs";
|
|
12
12
|
|
|
13
13
|
// src/http/koa/bind.ts
|
|
14
14
|
import Router from "@koa/router";
|
|
@@ -55,7 +55,6 @@ function bind(router, data, opts = {}) {
|
|
|
55
55
|
if (!metaMap.has(tag)) return resolve(await Context.filterRecord.default(new BadRequestException(`module "${tag}" doesn't exist`)));
|
|
56
56
|
const meta2 = metaMap.get(tag)[func];
|
|
57
57
|
if (!meta2) return resolve(await Context.filterRecord.default(new BadRequestException(`"${func}" in "${tag}" doesn't exist`)));
|
|
58
|
-
const { data: { params } } = meta2;
|
|
59
58
|
const aop = Context.getAop(meta2, {
|
|
60
59
|
globalGuards,
|
|
61
60
|
globalFilter,
|
|
@@ -63,6 +62,7 @@ function bind(router, data, opts = {}) {
|
|
|
63
62
|
});
|
|
64
63
|
const contextData = {
|
|
65
64
|
type: "koa",
|
|
65
|
+
category: "http",
|
|
66
66
|
index: i,
|
|
67
67
|
ctx,
|
|
68
68
|
meta: meta2,
|
|
@@ -70,9 +70,7 @@ function bind(router, data, opts = {}) {
|
|
|
70
70
|
parallel: true,
|
|
71
71
|
next,
|
|
72
72
|
app: router,
|
|
73
|
-
...
|
|
74
|
-
tag,
|
|
75
|
-
func,
|
|
73
|
+
...item,
|
|
76
74
|
getCookie: /* @__PURE__ */ __name((key) => ctx.cookies.get(key), "getCookie"),
|
|
77
75
|
setCookie: /* @__PURE__ */ __name((key, value, opts2) => ctx.cookies.set(key, value, opts2), "setCookie"),
|
|
78
76
|
delCookie: /* @__PURE__ */ __name((key) => ctx.cookies.set(key, "", {
|
|
@@ -111,7 +109,7 @@ function bind(router, data, opts = {}) {
|
|
|
111
109
|
}
|
|
112
110
|
const subRouter = new Router();
|
|
113
111
|
Context.applyAddons(addons, subRouter, "koa");
|
|
114
|
-
router[http.type](http.prefix
|
|
112
|
+
router[http.type](joinUrl(http.prefix, http.route), async (ctx, next) => {
|
|
115
113
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
116
114
|
const contextData = {
|
|
117
115
|
type: "koa",
|
|
@@ -123,6 +121,7 @@ function bind(router, data, opts = {}) {
|
|
|
123
121
|
func,
|
|
124
122
|
query: ctx.query,
|
|
125
123
|
params: ctx.params,
|
|
124
|
+
category: "http",
|
|
126
125
|
body: ctx.request.body,
|
|
127
126
|
headers: ctx.headers,
|
|
128
127
|
next,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as
|
|
3
|
-
import { G as Generator } from './core-
|
|
4
|
-
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-
|
|
1
|
+
import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-CR-D39hQ.mjs';
|
|
2
|
+
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_DEV, k as IS_ONLY_GENERATE, m as IS_PURE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, n as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-CR-D39hQ.mjs';
|
|
3
|
+
import { G as Generator } from './core-DIfgUKIU.mjs';
|
|
4
|
+
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-DIfgUKIU.mjs';
|
|
5
5
|
import { Base } from 'phecda-core';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
|
-
import { H as
|
|
8
|
-
export { C as CookieSerializeOptions, a as HttpOptions } from './types-
|
|
9
|
-
import { R as
|
|
10
|
-
export { b as RpcClientOptions, a as RpcServerOptions } from './types-
|
|
7
|
+
import { H as HttpCtx } from './types-DYviSl5B.mjs';
|
|
8
|
+
export { C as CookieSerializeOptions, a as HttpOptions } from './types-DYviSl5B.mjs';
|
|
9
|
+
import { R as RpcCtx } from './types-DqH1qA-q.mjs';
|
|
10
|
+
export { b as RpcClientOptions, a as RpcServerOptions } from './types-DqH1qA-q.mjs';
|
|
11
11
|
export { Mixin } from 'ts-mixer';
|
|
12
12
|
import 'node:http';
|
|
13
13
|
|
|
@@ -102,11 +102,11 @@ interface PipeArg {
|
|
|
102
102
|
reflect: any;
|
|
103
103
|
define: Record<string, any>;
|
|
104
104
|
}
|
|
105
|
-
type GuardType<
|
|
106
|
-
type PipeType<
|
|
107
|
-
type FilterType<
|
|
108
|
-
declare class Context<
|
|
109
|
-
data:
|
|
105
|
+
type GuardType<Ctx extends BaseCtx = any> = (ctx: Ctx, next: () => Promise<any>) => any;
|
|
106
|
+
type PipeType<Ctx extends BaseCtx = any> = (arg: PipeArg, ctx: Ctx) => Promise<any>;
|
|
107
|
+
type FilterType<Ctx extends BaseCtx = any, E extends Exception = any> = (err: E | Error, ctx?: Ctx) => Error | any;
|
|
108
|
+
declare class Context<Ctx extends BaseCtx> {
|
|
109
|
+
data: Ctx;
|
|
110
110
|
method: string;
|
|
111
111
|
params: string[];
|
|
112
112
|
static filterRecord: Record<PropertyKey, FilterType>;
|
|
@@ -119,7 +119,9 @@ declare class Context<Data extends BaseContext> {
|
|
|
119
119
|
value: (router: any, framework: string) => any;
|
|
120
120
|
priority: number;
|
|
121
121
|
}>;
|
|
122
|
-
|
|
122
|
+
ctx: Ctx;
|
|
123
|
+
protected canGetCtx: boolean;
|
|
124
|
+
constructor(data: Ctx);
|
|
123
125
|
static getAop(meta: ControllerMeta, opts: DefaultOptions): {
|
|
124
126
|
guards: GuardType<any>[];
|
|
125
127
|
pipe: PipeType<any>[];
|
|
@@ -135,9 +137,9 @@ declare class Context<Data extends BaseContext> {
|
|
|
135
137
|
static getGuards(guards: string[]): GuardType<any>[];
|
|
136
138
|
static applyAddons(addons: string[], router: any, framework: string): void;
|
|
137
139
|
}
|
|
138
|
-
declare function addPipe<C extends
|
|
139
|
-
declare function addFilter<C extends
|
|
140
|
-
declare function addGuard<C extends
|
|
140
|
+
declare function addPipe<C extends BaseCtx>(key: PropertyKey, pipe: PipeType<C>): void;
|
|
141
|
+
declare function addFilter<C extends BaseCtx>(key: PropertyKey, filter: FilterType<C>): void;
|
|
142
|
+
declare function addGuard<C extends BaseCtx>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
|
|
141
143
|
declare function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority?: number): void;
|
|
142
144
|
|
|
143
145
|
declare class RPCGenerator extends Generator {
|
|
@@ -190,30 +192,40 @@ declare function Define(key: string, value: any): any;
|
|
|
190
192
|
|
|
191
193
|
declare const defaultPipe: PipeType;
|
|
192
194
|
|
|
195
|
+
type LogLevel = 'error' | 'info' | 'warn' | 'log' | 'debug';
|
|
196
|
+
interface Logger {
|
|
197
|
+
log(msg: unknown, level: LogLevel, ctx?: string): void;
|
|
198
|
+
}
|
|
199
|
+
declare function setLogger(logger: Logger): void;
|
|
200
|
+
declare function getLogger(): Logger;
|
|
201
|
+
declare function log(msg: unknown, level?: LogLevel, ctx?: any): void;
|
|
202
|
+
declare function runMiddleware(ctx: HttpCtx, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
|
|
203
|
+
|
|
193
204
|
declare class ServerBase extends Base {
|
|
194
205
|
emitter: Emitter;
|
|
206
|
+
log(msg: unknown, level?: LogLevel): void;
|
|
195
207
|
}
|
|
196
|
-
declare class HttpBase extends ServerBase {
|
|
197
|
-
context:
|
|
208
|
+
declare class HttpBase<Ctx extends HttpCtx = HttpCtx> extends ServerBase {
|
|
209
|
+
context: Ctx;
|
|
198
210
|
}
|
|
199
|
-
declare class RpcBase extends ServerBase {
|
|
200
|
-
context:
|
|
211
|
+
declare class RpcBase<Ctx extends RpcCtx = RpcCtx> extends ServerBase {
|
|
212
|
+
context: Ctx;
|
|
201
213
|
}
|
|
202
214
|
|
|
203
|
-
declare abstract class PFilter<
|
|
215
|
+
declare abstract class PFilter<Ctx extends BaseCtx = any, E extends Exception = Exception> extends ServerBase {
|
|
204
216
|
readonly key: PropertyKey;
|
|
205
217
|
constructor(tag?: string);
|
|
206
|
-
abstract use(error: Error | E, ctx?:
|
|
218
|
+
abstract use(error: Error | E, ctx?: Ctx): BaseError;
|
|
207
219
|
}
|
|
208
220
|
|
|
209
|
-
declare abstract class PGuard<
|
|
210
|
-
abstract use(ctx:
|
|
221
|
+
declare abstract class PGuard<Ctx extends BaseCtx = any> extends ServerBase {
|
|
222
|
+
abstract use(ctx: Ctx, next: () => Promise<any>): any;
|
|
211
223
|
readonly key: PropertyKey;
|
|
212
224
|
priority: number;
|
|
213
225
|
constructor(tag?: string);
|
|
214
226
|
}
|
|
215
227
|
|
|
216
|
-
declare abstract class PPipe<
|
|
228
|
+
declare abstract class PPipe<Ctx extends BaseCtx = any> extends ServerBase {
|
|
217
229
|
readonly key: PropertyKey;
|
|
218
230
|
constructor(tag?: string);
|
|
219
231
|
abstract use(param: {
|
|
@@ -223,7 +235,7 @@ declare abstract class PPipe<C extends BaseContext = any> extends ServerBase {
|
|
|
223
235
|
type: string;
|
|
224
236
|
index: number;
|
|
225
237
|
reflect: any;
|
|
226
|
-
}, ctx:
|
|
238
|
+
}, ctx: Ctx): any;
|
|
227
239
|
}
|
|
228
240
|
|
|
229
241
|
declare abstract class PAddon extends ServerBase {
|
|
@@ -233,8 +245,8 @@ declare abstract class PAddon extends ServerBase {
|
|
|
233
245
|
abstract use(router: any, framework: string): undefined;
|
|
234
246
|
}
|
|
235
247
|
|
|
236
|
-
interface PExtension<
|
|
237
|
-
guard(ctx:
|
|
248
|
+
interface PExtension<Ctx extends BaseCtx = any, E extends Exception = Exception> {
|
|
249
|
+
guard(ctx: Ctx): Promise<boolean> | boolean;
|
|
238
250
|
pipe(param: {
|
|
239
251
|
arg: any;
|
|
240
252
|
option?: any;
|
|
@@ -242,8 +254,8 @@ interface PExtension<C extends BaseContext = any, E extends Exception = Exceptio
|
|
|
242
254
|
type: string;
|
|
243
255
|
index: number;
|
|
244
256
|
reflect: any;
|
|
245
|
-
}, ctx:
|
|
246
|
-
filter(error: Error | E, ctx?:
|
|
257
|
+
}, ctx: Ctx): any;
|
|
258
|
+
filter(error: Error | E, ctx?: Ctx): BaseError;
|
|
247
259
|
addon<Addon = any>(framework: string): Addon;
|
|
248
260
|
}
|
|
249
261
|
declare class PExtension extends ServerBase {
|
|
@@ -253,10 +265,4 @@ declare class PExtension extends ServerBase {
|
|
|
253
265
|
constructor(tag?: string);
|
|
254
266
|
}
|
|
255
267
|
|
|
256
|
-
type LogLevel
|
|
257
|
-
declare function setLogger(logger: Record<LogLevel, (msg: string) => void>): void;
|
|
258
|
-
declare function getLogger(): Record<LogLevel, (msg: string) => void>;
|
|
259
|
-
declare function log(msg: string, level?: LogLevel): void;
|
|
260
|
-
declare function runMiddleware(ctx: HttpContext, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
|
|
261
|
-
|
|
262
|
-
export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseContext, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpContext, InvalidInputException, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcContext, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };
|
|
268
|
+
export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseCtx, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpCtx, InvalidInputException, type LogLevel, type Logger, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcCtx, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as
|
|
3
|
-
import { G as Generator } from './core-
|
|
4
|
-
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-
|
|
1
|
+
import { B as BaseCtx, C as ControllerMeta, D as DefaultOptions, a as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-CR-D39hQ.js';
|
|
2
|
+
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_DEV, k as IS_ONLY_GENERATE, m as IS_PURE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, n as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-CR-D39hQ.js';
|
|
3
|
+
import { G as Generator } from './core-CUTbX_IS.js';
|
|
4
|
+
export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-CUTbX_IS.js';
|
|
5
5
|
import { Base } from 'phecda-core';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
|
-
import { H as
|
|
8
|
-
export { C as CookieSerializeOptions, a as HttpOptions } from './types-
|
|
9
|
-
import { R as
|
|
10
|
-
export { b as RpcClientOptions, a as RpcServerOptions } from './types-
|
|
7
|
+
import { H as HttpCtx } from './types-BF1TDbFV.js';
|
|
8
|
+
export { C as CookieSerializeOptions, a as HttpOptions } from './types-BF1TDbFV.js';
|
|
9
|
+
import { R as RpcCtx } from './types-DYRu0vic.js';
|
|
10
|
+
export { b as RpcClientOptions, a as RpcServerOptions } from './types-DYRu0vic.js';
|
|
11
11
|
export { Mixin } from 'ts-mixer';
|
|
12
12
|
import 'node:http';
|
|
13
13
|
|
|
@@ -102,11 +102,11 @@ interface PipeArg {
|
|
|
102
102
|
reflect: any;
|
|
103
103
|
define: Record<string, any>;
|
|
104
104
|
}
|
|
105
|
-
type GuardType<
|
|
106
|
-
type PipeType<
|
|
107
|
-
type FilterType<
|
|
108
|
-
declare class Context<
|
|
109
|
-
data:
|
|
105
|
+
type GuardType<Ctx extends BaseCtx = any> = (ctx: Ctx, next: () => Promise<any>) => any;
|
|
106
|
+
type PipeType<Ctx extends BaseCtx = any> = (arg: PipeArg, ctx: Ctx) => Promise<any>;
|
|
107
|
+
type FilterType<Ctx extends BaseCtx = any, E extends Exception = any> = (err: E | Error, ctx?: Ctx) => Error | any;
|
|
108
|
+
declare class Context<Ctx extends BaseCtx> {
|
|
109
|
+
data: Ctx;
|
|
110
110
|
method: string;
|
|
111
111
|
params: string[];
|
|
112
112
|
static filterRecord: Record<PropertyKey, FilterType>;
|
|
@@ -119,7 +119,9 @@ declare class Context<Data extends BaseContext> {
|
|
|
119
119
|
value: (router: any, framework: string) => any;
|
|
120
120
|
priority: number;
|
|
121
121
|
}>;
|
|
122
|
-
|
|
122
|
+
ctx: Ctx;
|
|
123
|
+
protected canGetCtx: boolean;
|
|
124
|
+
constructor(data: Ctx);
|
|
123
125
|
static getAop(meta: ControllerMeta, opts: DefaultOptions): {
|
|
124
126
|
guards: GuardType<any>[];
|
|
125
127
|
pipe: PipeType<any>[];
|
|
@@ -135,9 +137,9 @@ declare class Context<Data extends BaseContext> {
|
|
|
135
137
|
static getGuards(guards: string[]): GuardType<any>[];
|
|
136
138
|
static applyAddons(addons: string[], router: any, framework: string): void;
|
|
137
139
|
}
|
|
138
|
-
declare function addPipe<C extends
|
|
139
|
-
declare function addFilter<C extends
|
|
140
|
-
declare function addGuard<C extends
|
|
140
|
+
declare function addPipe<C extends BaseCtx>(key: PropertyKey, pipe: PipeType<C>): void;
|
|
141
|
+
declare function addFilter<C extends BaseCtx>(key: PropertyKey, filter: FilterType<C>): void;
|
|
142
|
+
declare function addGuard<C extends BaseCtx>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
|
|
141
143
|
declare function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority?: number): void;
|
|
142
144
|
|
|
143
145
|
declare class RPCGenerator extends Generator {
|
|
@@ -190,30 +192,40 @@ declare function Define(key: string, value: any): any;
|
|
|
190
192
|
|
|
191
193
|
declare const defaultPipe: PipeType;
|
|
192
194
|
|
|
195
|
+
type LogLevel = 'error' | 'info' | 'warn' | 'log' | 'debug';
|
|
196
|
+
interface Logger {
|
|
197
|
+
log(msg: unknown, level: LogLevel, ctx?: string): void;
|
|
198
|
+
}
|
|
199
|
+
declare function setLogger(logger: Logger): void;
|
|
200
|
+
declare function getLogger(): Logger;
|
|
201
|
+
declare function log(msg: unknown, level?: LogLevel, ctx?: any): void;
|
|
202
|
+
declare function runMiddleware(ctx: HttpCtx, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
|
|
203
|
+
|
|
193
204
|
declare class ServerBase extends Base {
|
|
194
205
|
emitter: Emitter;
|
|
206
|
+
log(msg: unknown, level?: LogLevel): void;
|
|
195
207
|
}
|
|
196
|
-
declare class HttpBase extends ServerBase {
|
|
197
|
-
context:
|
|
208
|
+
declare class HttpBase<Ctx extends HttpCtx = HttpCtx> extends ServerBase {
|
|
209
|
+
context: Ctx;
|
|
198
210
|
}
|
|
199
|
-
declare class RpcBase extends ServerBase {
|
|
200
|
-
context:
|
|
211
|
+
declare class RpcBase<Ctx extends RpcCtx = RpcCtx> extends ServerBase {
|
|
212
|
+
context: Ctx;
|
|
201
213
|
}
|
|
202
214
|
|
|
203
|
-
declare abstract class PFilter<
|
|
215
|
+
declare abstract class PFilter<Ctx extends BaseCtx = any, E extends Exception = Exception> extends ServerBase {
|
|
204
216
|
readonly key: PropertyKey;
|
|
205
217
|
constructor(tag?: string);
|
|
206
|
-
abstract use(error: Error | E, ctx?:
|
|
218
|
+
abstract use(error: Error | E, ctx?: Ctx): BaseError;
|
|
207
219
|
}
|
|
208
220
|
|
|
209
|
-
declare abstract class PGuard<
|
|
210
|
-
abstract use(ctx:
|
|
221
|
+
declare abstract class PGuard<Ctx extends BaseCtx = any> extends ServerBase {
|
|
222
|
+
abstract use(ctx: Ctx, next: () => Promise<any>): any;
|
|
211
223
|
readonly key: PropertyKey;
|
|
212
224
|
priority: number;
|
|
213
225
|
constructor(tag?: string);
|
|
214
226
|
}
|
|
215
227
|
|
|
216
|
-
declare abstract class PPipe<
|
|
228
|
+
declare abstract class PPipe<Ctx extends BaseCtx = any> extends ServerBase {
|
|
217
229
|
readonly key: PropertyKey;
|
|
218
230
|
constructor(tag?: string);
|
|
219
231
|
abstract use(param: {
|
|
@@ -223,7 +235,7 @@ declare abstract class PPipe<C extends BaseContext = any> extends ServerBase {
|
|
|
223
235
|
type: string;
|
|
224
236
|
index: number;
|
|
225
237
|
reflect: any;
|
|
226
|
-
}, ctx:
|
|
238
|
+
}, ctx: Ctx): any;
|
|
227
239
|
}
|
|
228
240
|
|
|
229
241
|
declare abstract class PAddon extends ServerBase {
|
|
@@ -233,8 +245,8 @@ declare abstract class PAddon extends ServerBase {
|
|
|
233
245
|
abstract use(router: any, framework: string): undefined;
|
|
234
246
|
}
|
|
235
247
|
|
|
236
|
-
interface PExtension<
|
|
237
|
-
guard(ctx:
|
|
248
|
+
interface PExtension<Ctx extends BaseCtx = any, E extends Exception = Exception> {
|
|
249
|
+
guard(ctx: Ctx): Promise<boolean> | boolean;
|
|
238
250
|
pipe(param: {
|
|
239
251
|
arg: any;
|
|
240
252
|
option?: any;
|
|
@@ -242,8 +254,8 @@ interface PExtension<C extends BaseContext = any, E extends Exception = Exceptio
|
|
|
242
254
|
type: string;
|
|
243
255
|
index: number;
|
|
244
256
|
reflect: any;
|
|
245
|
-
}, ctx:
|
|
246
|
-
filter(error: Error | E, ctx?:
|
|
257
|
+
}, ctx: Ctx): any;
|
|
258
|
+
filter(error: Error | E, ctx?: Ctx): BaseError;
|
|
247
259
|
addon<Addon = any>(framework: string): Addon;
|
|
248
260
|
}
|
|
249
261
|
declare class PExtension extends ServerBase {
|
|
@@ -253,10 +265,4 @@ declare class PExtension extends ServerBase {
|
|
|
253
265
|
constructor(tag?: string);
|
|
254
266
|
}
|
|
255
267
|
|
|
256
|
-
type LogLevel
|
|
257
|
-
declare function setLogger(logger: Record<LogLevel, (msg: string) => void>): void;
|
|
258
|
-
declare function getLogger(): Record<LogLevel, (msg: string) => void>;
|
|
259
|
-
declare function log(msg: string, level?: LogLevel): void;
|
|
260
|
-
declare function runMiddleware(ctx: HttpContext, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
|
|
261
|
-
|
|
262
|
-
export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseContext, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpContext, InvalidInputException, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcContext, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };
|
|
268
|
+
export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseCtx, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpCtx, InvalidInputException, type LogLevel, type Logger, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcCtx, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };
|