phecda-server 7.0.0-alpha.1 → 7.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +7 -7
- package/dist/{chunk-V7EI76QQ.mjs → chunk-3FHZB3Z5.mjs} +1 -1
- package/dist/{chunk-GSPBHZBH.js → chunk-NQIFUZL4.js} +1 -1
- package/dist/{core-CYwEPfN4.d.ts → core-C1kHRqU9.d.ts} +1 -1
- package/dist/{core-BIcUwV18.d.mts → core-CSiaRU7r.d.mts} +1 -1
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +2 -2
- package/dist/helper.mjs +1 -1
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +19 -17
- package/dist/http/elysia/index.mjs +3 -1
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +19 -17
- package/dist/http/express/index.mjs +3 -1
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +18 -16
- package/dist/http/fastify/index.mjs +3 -1
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +18 -16
- package/dist/http/h3/index.mjs +3 -1
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +17 -15
- package/dist/http/hono/index.mjs +3 -1
- 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 +17 -15
- package/dist/http/hyper-express/index.mjs +3 -1
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +19 -17
- package/dist/http/koa/index.mjs +3 -1
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +19 -19
- package/dist/index.mjs +2 -2
- package/dist/{meta-BXKLFTgG.d.mts → meta-D1M85Hef.d.mts} +1 -0
- package/dist/{meta-BXKLFTgG.d.ts → meta-D1M85Hef.d.ts} +1 -0
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +9 -8
- package/dist/rpc/bullmq/index.mjs +2 -1
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +8 -7
- package/dist/rpc/kafka/index.mjs +2 -1
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +8 -7
- package/dist/rpc/nats/index.mjs +2 -1
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +9 -8
- package/dist/rpc/rabbitmq/index.mjs +2 -1
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +9 -8
- package/dist/rpc/redis/index.mjs +2 -1
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/{types-BtbL49Zs.d.mts → types-C9Remkup.d.ts} +2 -1
- package/dist/{types-m3IEDKjP.d.ts → types-JMhFVp-Z.d.mts} +2 -1
- package/dist/{types-VFzEM7LL.d.ts → types-ee1FBodH.d.ts} +2 -1
- package/dist/{types-h40T3cRG.d.mts → types-wbHHC93P.d.mts} +2 -1
- package/package.json +1 -1
- package/register/loader.mjs +1 -1
package/dist/http/koa/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkNQIFUZL4js = require('../../chunk-NQIFUZL4.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
|
|
@@ -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 = _chunkNQIFUZL4js.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
|
+
_chunkNQIFUZL4js.detectAopDep.call(void 0, meta, {
|
|
29
29
|
addons: [
|
|
30
30
|
...globalAddons,
|
|
31
31
|
...parallelAddons
|
|
@@ -34,35 +34,36 @@ function bind(router, data, opts = {}) {
|
|
|
34
34
|
});
|
|
35
35
|
registerRoute();
|
|
36
36
|
function registerRoute() {
|
|
37
|
-
|
|
37
|
+
_chunkNQIFUZL4js.Context.applyAddons(globalAddons, router, "koa");
|
|
38
38
|
if (parallelRoute) {
|
|
39
39
|
const subRouter = new (0, _router2.default)();
|
|
40
|
-
|
|
40
|
+
_chunkNQIFUZL4js.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 _chunkNQIFUZL4js.Context.filterRecord.default(e);
|
|
45
45
|
ctx.status = error.status;
|
|
46
46
|
ctx.body = error;
|
|
47
47
|
}
|
|
48
48
|
_chunkJ5CFUN4Vjs.__name.call(void 0, errorHandler, "errorHandler");
|
|
49
|
-
if (!Array.isArray(body)) return errorHandler(new (0,
|
|
49
|
+
if (!Array.isArray(body)) return errorHandler(new (0, _chunkNQIFUZL4js.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 _chunkNQIFUZL4js.Context.filterRecord.default(new (0, _chunkNQIFUZL4js.BadRequestException)(`module "${tag}" doesn't exist`)));
|
|
56
56
|
const meta2 = metaMap.get(tag)[func];
|
|
57
|
-
if (!meta2) return resolve(await
|
|
57
|
+
if (!meta2) return resolve(await _chunkNQIFUZL4js.Context.filterRecord.default(new (0, _chunkNQIFUZL4js.BadRequestException)(`"${func}" in "${tag}" doesn't exist`)));
|
|
58
58
|
const { data: { params } } = meta2;
|
|
59
|
-
const aop =
|
|
59
|
+
const aop = _chunkNQIFUZL4js.Context.getAop(meta2, {
|
|
60
60
|
globalGuards,
|
|
61
61
|
globalFilter,
|
|
62
62
|
globalPipe
|
|
63
63
|
});
|
|
64
64
|
const contextData = {
|
|
65
65
|
type: "koa",
|
|
66
|
+
category: "http",
|
|
66
67
|
index: i,
|
|
67
68
|
ctx,
|
|
68
69
|
meta: meta2,
|
|
@@ -70,7 +71,7 @@ function bind(router, data, opts = {}) {
|
|
|
70
71
|
parallel: true,
|
|
71
72
|
next,
|
|
72
73
|
app: router,
|
|
73
|
-
...
|
|
74
|
+
..._chunkNQIFUZL4js.argToReq.call(void 0, params, item.args, ctx.headers),
|
|
74
75
|
tag,
|
|
75
76
|
func,
|
|
76
77
|
getCookie: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, (key) => ctx.cookies.get(key), "getCookie"),
|
|
@@ -84,7 +85,7 @@ function bind(router, data, opts = {}) {
|
|
|
84
85
|
getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
85
86
|
getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
86
87
|
};
|
|
87
|
-
const context = new (0,
|
|
88
|
+
const context = new (0, _chunkNQIFUZL4js.Context)(contextData);
|
|
88
89
|
context.run(aop, resolve, resolve);
|
|
89
90
|
});
|
|
90
91
|
})).then((ret) => {
|
|
@@ -103,14 +104,14 @@ function bind(router, data, opts = {}) {
|
|
|
103
104
|
if (!_optionalChain([http, 'optionalAccess', _2 => _2.type])) continue;
|
|
104
105
|
let aop;
|
|
105
106
|
if (!dynamic) {
|
|
106
|
-
aop =
|
|
107
|
+
aop = _chunkNQIFUZL4js.Context.getAop(meta2, {
|
|
107
108
|
globalFilter,
|
|
108
109
|
globalGuards,
|
|
109
110
|
globalPipe
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
const subRouter = new (0, _router2.default)();
|
|
113
|
-
|
|
114
|
+
_chunkNQIFUZL4js.Context.applyAddons(addons, subRouter, "koa");
|
|
114
115
|
router[http.type](http.prefix + http.route, async (ctx, next) => {
|
|
115
116
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
116
117
|
const contextData = {
|
|
@@ -123,6 +124,7 @@ function bind(router, data, opts = {}) {
|
|
|
123
124
|
func,
|
|
124
125
|
query: ctx.query,
|
|
125
126
|
params: ctx.params,
|
|
127
|
+
category: "http",
|
|
126
128
|
body: ctx.request.body,
|
|
127
129
|
headers: ctx.headers,
|
|
128
130
|
next,
|
|
@@ -137,10 +139,10 @@ function bind(router, data, opts = {}) {
|
|
|
137
139
|
getRequest: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => ctx.req, "getRequest"),
|
|
138
140
|
getResponse: /* @__PURE__ */ _chunkJ5CFUN4Vjs.__name.call(void 0, () => ctx.res, "getResponse")
|
|
139
141
|
};
|
|
140
|
-
const context = new (0,
|
|
142
|
+
const context = new (0, _chunkNQIFUZL4js.Context)(contextData);
|
|
141
143
|
if (http.headers) ctx.set(http.headers);
|
|
142
144
|
if (dynamic) {
|
|
143
|
-
aop =
|
|
145
|
+
aop = _chunkNQIFUZL4js.Context.getAop(meta2, {
|
|
144
146
|
globalFilter,
|
|
145
147
|
globalGuards,
|
|
146
148
|
globalPipe
|
|
@@ -160,7 +162,7 @@ function bind(router, data, opts = {}) {
|
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
164
|
_chunkJ5CFUN4Vjs.__name.call(void 0, registerRoute, "registerRoute");
|
|
163
|
-
|
|
165
|
+
_chunkNQIFUZL4js.HMR.call(void 0, async () => {
|
|
164
166
|
router.stack = originStack;
|
|
165
167
|
registerRoute();
|
|
166
168
|
});
|
package/dist/http/koa/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
argToReq,
|
|
6
6
|
createControllerMetaMap,
|
|
7
7
|
detectAopDep
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-3FHZB3Z5.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
11
|
} from "../../chunk-WHJ5FALK.mjs";
|
|
@@ -63,6 +63,7 @@ function bind(router, data, opts = {}) {
|
|
|
63
63
|
});
|
|
64
64
|
const contextData = {
|
|
65
65
|
type: "koa",
|
|
66
|
+
category: "http",
|
|
66
67
|
index: i,
|
|
67
68
|
ctx,
|
|
68
69
|
meta: meta2,
|
|
@@ -123,6 +124,7 @@ function bind(router, data, opts = {}) {
|
|
|
123
124
|
func,
|
|
124
125
|
query: ctx.query,
|
|
125
126
|
params: ctx.params,
|
|
127
|
+
category: "http",
|
|
126
128
|
body: ctx.request.body,
|
|
127
129
|
headers: ctx.headers,
|
|
128
130
|
next,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { B as BaseContext, a as ControllerMeta, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-
|
|
2
|
-
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_HMR, k as IS_ONLY_GENERATE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, m as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-
|
|
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 BaseContext, a as ControllerMeta, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-D1M85Hef.mjs';
|
|
2
|
+
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_HMR, k as IS_ONLY_GENERATE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, m as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-D1M85Hef.mjs';
|
|
3
|
+
import { G as Generator } from './core-CSiaRU7r.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-CSiaRU7r.mjs';
|
|
5
5
|
import { Base } from 'phecda-core';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
|
-
import { H as HttpContext } from './types-
|
|
8
|
-
export { C as CookieSerializeOptions, a as HttpOptions } from './types-
|
|
9
|
-
import { R as RpcContext } from './types-
|
|
10
|
-
export { b as RpcClientOptions, a as RpcServerOptions } from './types-
|
|
7
|
+
import { H as HttpContext } from './types-wbHHC93P.mjs';
|
|
8
|
+
export { C as CookieSerializeOptions, a as HttpOptions } from './types-wbHHC93P.mjs';
|
|
9
|
+
import { R as RpcContext } from './types-JMhFVp-Z.mjs';
|
|
10
|
+
export { b as RpcClientOptions, a as RpcServerOptions } from './types-JMhFVp-Z.mjs';
|
|
11
11
|
export { Mixin } from 'ts-mixer';
|
|
12
12
|
import 'node:http';
|
|
13
13
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { B as BaseContext, a as ControllerMeta, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-
|
|
2
|
-
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_HMR, k as IS_ONLY_GENERATE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, m as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-
|
|
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 BaseContext, a as ControllerMeta, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-D1M85Hef.js';
|
|
2
|
+
export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_HMR, k as IS_ONLY_GENERATE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, m as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-D1M85Hef.js';
|
|
3
|
+
import { G as Generator } from './core-C1kHRqU9.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-C1kHRqU9.js';
|
|
5
5
|
import { Base } from 'phecda-core';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
|
-
import { H as HttpContext } from './types-
|
|
8
|
-
export { C as CookieSerializeOptions, a as HttpOptions } from './types-
|
|
9
|
-
import { R as RpcContext } from './types-
|
|
10
|
-
export { b as RpcClientOptions, a as RpcServerOptions } from './types-
|
|
7
|
+
import { H as HttpContext } from './types-ee1FBodH.js';
|
|
8
|
+
export { C as CookieSerializeOptions, a as HttpOptions } from './types-ee1FBodH.js';
|
|
9
|
+
import { R as RpcContext } from './types-C9Remkup.js';
|
|
10
|
+
export { b as RpcClientOptions, a as RpcServerOptions } from './types-C9Remkup.js';
|
|
11
11
|
export { Mixin } from 'ts-mixer';
|
|
12
12
|
import 'node:http';
|
|
13
13
|
|
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ var _chunkMBCHNDAYjs = require('./chunk-MBCHNDAY.js');
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
var
|
|
59
|
+
var _chunkNQIFUZL4js = require('./chunk-NQIFUZL4.js');
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
|
|
@@ -131,9 +131,9 @@ var PFilter = class extends ServerBase {
|
|
|
131
131
|
constructor(tag) {
|
|
132
132
|
super();
|
|
133
133
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
134
|
-
|
|
134
|
+
_chunkNQIFUZL4js.addFilter.call(void 0, this.key, this.use.bind(this));
|
|
135
135
|
this.onUnmount(() => {
|
|
136
|
-
delete
|
|
136
|
+
delete _chunkNQIFUZL4js.Context.filterRecord[this.key];
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
};
|
|
@@ -149,9 +149,9 @@ var PGuard = (_class2 = class extends ServerBase {
|
|
|
149
149
|
constructor(tag) {
|
|
150
150
|
super();_class2.prototype.__init2.call(this);;
|
|
151
151
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
152
|
-
|
|
152
|
+
_chunkNQIFUZL4js.addGuard.call(void 0, this.key, this.use.bind(this), this.priority);
|
|
153
153
|
this.onUnmount(() => {
|
|
154
|
-
delete
|
|
154
|
+
delete _chunkNQIFUZL4js.Context.guardRecord[this.key];
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
}, _class2);
|
|
@@ -166,9 +166,9 @@ var PPipe = class extends ServerBase {
|
|
|
166
166
|
constructor(tag) {
|
|
167
167
|
super();
|
|
168
168
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
169
|
-
|
|
169
|
+
_chunkNQIFUZL4js.addPipe.call(void 0, this.key, this.use.bind(this));
|
|
170
170
|
this.onUnmount(() => {
|
|
171
|
-
delete
|
|
171
|
+
delete _chunkNQIFUZL4js.Context.pipeRecord[this.key];
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
};
|
|
@@ -184,9 +184,9 @@ var PAddon = (_class3 = class extends ServerBase {
|
|
|
184
184
|
constructor(tag) {
|
|
185
185
|
super();_class3.prototype.__init3.call(this);;
|
|
186
186
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
187
|
-
|
|
187
|
+
_chunkNQIFUZL4js.addAddon.call(void 0, this.key, this.use.bind(this), this.priority);
|
|
188
188
|
this.onUnmount(() => {
|
|
189
|
-
delete
|
|
189
|
+
delete _chunkNQIFUZL4js.Context.addonRecord[this.key];
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
}, _class3);
|
|
@@ -204,27 +204,27 @@ var PExtension = class extends ServerBase {
|
|
|
204
204
|
super();
|
|
205
205
|
const key = this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
206
206
|
if (this.pipe) {
|
|
207
|
-
|
|
207
|
+
_chunkNQIFUZL4js.addPipe.call(void 0, key, this.pipe.bind(this));
|
|
208
208
|
this.onUnmount(() => {
|
|
209
|
-
delete
|
|
209
|
+
delete _chunkNQIFUZL4js.Context.pipeRecord[key];
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
if (this.addon) {
|
|
213
|
-
|
|
213
|
+
_chunkNQIFUZL4js.addAddon.call(void 0, key, this.addon.bind(this), this.addonPriority);
|
|
214
214
|
this.onUnmount(() => {
|
|
215
|
-
delete
|
|
215
|
+
delete _chunkNQIFUZL4js.Context.addonRecord[key];
|
|
216
216
|
});
|
|
217
217
|
}
|
|
218
218
|
if (this.guard) {
|
|
219
|
-
|
|
219
|
+
_chunkNQIFUZL4js.addGuard.call(void 0, key, this.guard.bind(this), this.guardPriority);
|
|
220
220
|
this.onUnmount(() => {
|
|
221
|
-
delete
|
|
221
|
+
delete _chunkNQIFUZL4js.Context.guardRecord[key];
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
224
|
if (this.filter) {
|
|
225
|
-
|
|
225
|
+
_chunkNQIFUZL4js.addFilter.call(void 0, key, this.filter.bind(this));
|
|
226
226
|
this.onUnmount(() => {
|
|
227
|
-
delete
|
|
227
|
+
delete _chunkNQIFUZL4js.Context.filterRecord[key];
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
230
|
}
|
|
@@ -308,7 +308,7 @@ var HTTPGenerator = (_class5 = class extends Generator {constructor(...args4) {
|
|
|
308
308
|
if (!this.classMap[name]) this.classMap[name] = {};
|
|
309
309
|
this.classMap[name][func] = `
|
|
310
310
|
${func}(...args){
|
|
311
|
-
const ret={tag:"${tag}",func:"${func}",body:{},headers:{},query:{},params:{},method:"${http.type}",url:"${url}"
|
|
311
|
+
const ret={tag:"${tag}",func:"${func}",body:{},headers:{},query:{},params:{},method:"${http.type}",url:"${url}"}
|
|
312
312
|
|
|
313
313
|
${params.reduce((p, c, i) => `${p}ret.${c.type}${c.key ? `['${c.key}']` : ""}=args[${i}]
|
|
314
314
|
${c.type === "params" ? `ret.url=ret.url.replace('{{${c.key}}}',args[${i}])` : ""}
|
|
@@ -404,4 +404,4 @@ return ret
|
|
|
404
404
|
|
|
405
405
|
|
|
406
406
|
|
|
407
|
-
exports.Addon = _chunkMBCHNDAYjs.Addon; exports.Arg = _chunkMBCHNDAYjs.Arg; exports.BadGatewayException =
|
|
407
|
+
exports.Addon = _chunkMBCHNDAYjs.Addon; exports.Arg = _chunkMBCHNDAYjs.Arg; exports.BadGatewayException = _chunkNQIFUZL4js.BadGatewayException; exports.BadRequestException = _chunkNQIFUZL4js.BadRequestException; exports.BaseParam = _chunkMBCHNDAYjs.BaseParam; exports.Body = _chunkMBCHNDAYjs.Body; exports.ConflictException = _chunkNQIFUZL4js.ConflictException; exports.Context = _chunkNQIFUZL4js.Context; exports.Controller = _chunkMBCHNDAYjs.Controller; exports.Ctx = _chunkMBCHNDAYjs.Ctx; exports.CustomResponse = CustomResponse; exports.Define = _chunkMBCHNDAYjs.Define; exports.Delete = _chunkMBCHNDAYjs.Delete; exports.ERROR_SYMBOL = _chunkJ5CFUN4Vjs.ERROR_SYMBOL; exports.Exception = _chunkNQIFUZL4js.Exception; exports.Factory = _chunk7YQ57BQSjs.Factory; exports.Filter = _chunkMBCHNDAYjs.Filter; exports.ForbiddenException = _chunkNQIFUZL4js.ForbiddenException; exports.FrameworkException = _chunkNQIFUZL4js.FrameworkException; exports.Generator = Generator; exports.Get = _chunkMBCHNDAYjs.Get; exports.Guard = _chunkMBCHNDAYjs.Guard; exports.HTTPGenerator = HTTPGenerator; exports.Head = _chunkMBCHNDAYjs.Head; exports.Header = _chunkMBCHNDAYjs.Header; exports.HttpBase = HttpBase; exports.IS_HMR = _chunkJ5CFUN4Vjs.IS_HMR; exports.IS_ONLY_GENERATE = _chunkJ5CFUN4Vjs.IS_ONLY_GENERATE; exports.IS_STRICT = _chunkJ5CFUN4Vjs.IS_STRICT; exports.InvalidInputException = _chunkNQIFUZL4js.InvalidInputException; exports.LOG_LEVEL = _chunkJ5CFUN4Vjs.LOG_LEVEL; exports.Meta = _chunk7YQ57BQSjs.Meta; exports.Mixin = _chunkJ5CFUN4Vjs.Mixin; exports.NotFoundException = _chunkNQIFUZL4js.NotFoundException; exports.PAddon = PAddon; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PPipe = PPipe; exports.PS_EXIT_CODE = _chunkJ5CFUN4Vjs.PS_EXIT_CODE; exports.Param = _chunkMBCHNDAYjs.Param; exports.Patch = _chunkMBCHNDAYjs.Patch; exports.PayloadLargeException = _chunkNQIFUZL4js.PayloadLargeException; exports.Pipe = _chunkMBCHNDAYjs.Pipe; exports.Post = _chunkMBCHNDAYjs.Post; exports.Put = _chunkMBCHNDAYjs.Put; exports.Query = _chunkMBCHNDAYjs.Query; exports.Queue = _chunkMBCHNDAYjs.Queue; exports.RPCGenerator = RPCGenerator; exports.Route = _chunkMBCHNDAYjs.Route; exports.Rpc = _chunkMBCHNDAYjs.Rpc; exports.RpcBase = RpcBase; exports.Search = _chunkMBCHNDAYjs.Search; exports.ServerBase = ServerBase; exports.ServerPhecda = _chunk7YQ57BQSjs.ServerPhecda; exports.ServiceUnavailableException = _chunkNQIFUZL4js.ServiceUnavailableException; exports.TimeoutException = _chunkNQIFUZL4js.TimeoutException; exports.TimerException = _chunkNQIFUZL4js.TimerException; exports.UnauthorizedException = _chunkNQIFUZL4js.UnauthorizedException; exports.UndefinedException = _chunkNQIFUZL4js.UndefinedException; exports.UnsupportedMediaTypeException = _chunkNQIFUZL4js.UnsupportedMediaTypeException; exports.ValidateException = _chunkNQIFUZL4js.ValidateException; exports.WorkerException = _chunkNQIFUZL4js.WorkerException; exports.addAddon = _chunkNQIFUZL4js.addAddon; exports.addFilter = _chunkNQIFUZL4js.addFilter; exports.addGuard = _chunkNQIFUZL4js.addGuard; exports.addPipe = _chunkNQIFUZL4js.addPipe; exports.defaultPipe = _chunkNQIFUZL4js.defaultPipe; exports.defaultServerInject = _chunk7YQ57BQSjs.defaultServerInject; exports.emitter = _chunk7YQ57BQSjs.emitter; exports.getLogger = _chunkJ5CFUN4Vjs.getLogger; exports.log = _chunkJ5CFUN4Vjs.log; exports.phecdaNamespace = _chunk7YQ57BQSjs.phecdaNamespace; exports.runMiddleware = _chunkJ5CFUN4Vjs.runMiddleware; exports.setLogger = _chunkJ5CFUN4Vjs.setLogger; exports.useS = _chunk7YQ57BQSjs.useS;
|
package/dist/index.mjs
CHANGED
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
addGuard,
|
|
57
57
|
addPipe,
|
|
58
58
|
defaultPipe
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-3FHZB3Z5.mjs";
|
|
60
60
|
import {
|
|
61
61
|
ERROR_SYMBOL,
|
|
62
62
|
IS_HMR,
|
|
@@ -308,7 +308,7 @@ var HTTPGenerator = class extends Generator {
|
|
|
308
308
|
if (!this.classMap[name]) this.classMap[name] = {};
|
|
309
309
|
this.classMap[name][func] = `
|
|
310
310
|
${func}(...args){
|
|
311
|
-
const ret={tag:"${tag}",func:"${func}",body:{},headers:{},query:{},params:{},method:"${http.type}",url:"${url}"
|
|
311
|
+
const ret={tag:"${tag}",func:"${func}",body:{},headers:{},query:{},params:{},method:"${http.type}",url:"${url}"}
|
|
312
312
|
|
|
313
313
|
${params.reduce((p, c, i) => `${p}ret.${c.type}${c.key ? `['${c.key}']` : ""}=args[${i}]
|
|
314
314
|
${c.type === "params" ? `ret.url=ret.url.replace('{{${c.key}}}',args[${i}])` : ""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-CSiaRU7r.mjs';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-JMhFVp-Z.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-D1M85Hef.mjs';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface BullmqCtx extends RpcContext {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-C1kHRqU9.js';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-C9Remkup.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-D1M85Hef.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface BullmqCtx extends RpcContext {
|
package/dist/rpc/bullmq/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkNQIFUZL4js = require('../../chunk-NQIFUZL4.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
|
|
@@ -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 = _chunkNQIFUZL4js.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
|
+
_chunkNQIFUZL4js.detectAopDep.call(void 0, meta, {
|
|
29
29
|
guards: globalGuards
|
|
30
30
|
}, "rpc");
|
|
31
31
|
async function subscribeQueues() {
|
|
@@ -39,7 +39,7 @@ 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
|
+
_chunkNQIFUZL4js.Context.applyAddons(addons, workerMap[queue], "bullmq");
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -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 = _chunkNQIFUZL4js.Context.getAop(meta2, {
|
|
57
57
|
globalFilter,
|
|
58
58
|
globalGuards,
|
|
59
59
|
globalPipe
|
|
60
60
|
});
|
|
61
|
-
const context = new (0,
|
|
61
|
+
const context = new (0, _chunkNQIFUZL4js.Context)({
|
|
62
62
|
type: "bullmq",
|
|
63
|
+
category: "rpc",
|
|
63
64
|
moduleMap,
|
|
64
65
|
meta: meta2,
|
|
65
66
|
tag,
|
|
@@ -87,7 +88,7 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
87
88
|
}
|
|
88
89
|
_chunkJ5CFUN4Vjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
89
90
|
subscribeQueues();
|
|
90
|
-
|
|
91
|
+
_chunkNQIFUZL4js.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();
|
|
@@ -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 = _chunkNQIFUZL4js.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;
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-3FHZB3Z5.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
10
|
} from "../../chunk-WHJ5FALK.mjs";
|
|
@@ -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,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Consumer, Producer } from 'kafkajs';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-CSiaRU7r.mjs';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-JMhFVp-Z.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-D1M85Hef.mjs';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface KafkaCtx extends RpcContext {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Consumer, Producer } from 'kafkajs';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-C1kHRqU9.js';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-C9Remkup.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-D1M85Hef.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface KafkaCtx extends RpcContext {
|
package/dist/rpc/kafka/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkNQIFUZL4js = require('../../chunk-NQIFUZL4.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
|
|
@@ -14,18 +14,18 @@ var debug = _debug2.default.call(void 0, "phecda-server/kafka");
|
|
|
14
14
|
async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
15
15
|
const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
16
16
|
const existQueue = /* @__PURE__ */ new Set();
|
|
17
|
-
const metaMap =
|
|
17
|
+
const metaMap = _chunkNQIFUZL4js.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
18
18
|
const { controller, rpc, func, tag } = meta2.data;
|
|
19
19
|
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
|
|
20
20
|
debug(`register method "${func}" in module "${tag}"`);
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
_chunkNQIFUZL4js.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
|
-
|
|
28
|
+
_chunkNQIFUZL4js.Context.applyAddons(globalAddons, {
|
|
29
29
|
consumer,
|
|
30
30
|
producer
|
|
31
31
|
}, "kafka");
|
|
@@ -59,13 +59,14 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
59
59
|
const meta2 = metaMap.get(tag)[func];
|
|
60
60
|
const { data: { rpc } } = meta2;
|
|
61
61
|
const isEvent = rpc.isEvent;
|
|
62
|
-
const aop =
|
|
62
|
+
const aop = _chunkNQIFUZL4js.Context.getAop(meta2, {
|
|
63
63
|
globalFilter,
|
|
64
64
|
globalGuards,
|
|
65
65
|
globalPipe
|
|
66
66
|
});
|
|
67
|
-
const context = new (0,
|
|
67
|
+
const context = new (0, _chunkNQIFUZL4js.Context)({
|
|
68
68
|
type: "kafka",
|
|
69
|
+
category: "rpc",
|
|
69
70
|
moduleMap,
|
|
70
71
|
meta: meta2,
|
|
71
72
|
args,
|
|
@@ -121,7 +122,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
121
122
|
let eventCount = 1;
|
|
122
123
|
const ret = {};
|
|
123
124
|
const emitter = new (0, _events.EventEmitter)();
|
|
124
|
-
const clientQueue =
|
|
125
|
+
const clientQueue = _chunkNQIFUZL4js.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
125
126
|
await consumer.subscribe({
|
|
126
127
|
topic: clientQueue,
|
|
127
128
|
fromBeginning: true
|
package/dist/rpc/kafka/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createControllerMetaMap,
|
|
4
4
|
detectAopDep,
|
|
5
5
|
genClientQueue
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-3FHZB3Z5.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
9
|
} from "../../chunk-WHJ5FALK.mjs";
|
|
@@ -66,6 +66,7 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
66
66
|
});
|
|
67
67
|
const context = new Context({
|
|
68
68
|
type: "kafka",
|
|
69
|
+
category: "rpc",
|
|
69
70
|
moduleMap,
|
|
70
71
|
meta: meta2,
|
|
71
72
|
args,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NatsConnection } from 'nats';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-CSiaRU7r.mjs';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-JMhFVp-Z.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-D1M85Hef.mjs';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface NatsCtx extends RpcContext {
|
package/dist/rpc/nats/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NatsConnection } from 'nats';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-C1kHRqU9.js';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-C9Remkup.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-D1M85Hef.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface NatsCtx extends RpcContext {
|