phecda-server 6.1.0 → 7.0.0-alpha.1
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 +24 -24
- package/bin/cli.mjs +165 -157
- package/dist/{chunk-NL6QBQAR.js → chunk-7YQ57BQS.js} +21 -22
- package/dist/chunk-GSPBHZBH.js +534 -0
- package/dist/{chunk-J7B24YSE.mjs → chunk-HMVLXNV3.mjs} +5 -14
- package/dist/{chunk-TVT62GIX.js → chunk-J5CFUN4V.js} +8 -1
- package/dist/{chunk-JDV2XJYE.js → chunk-MBCHNDAY.js} +27 -36
- package/dist/{chunk-2CFYUXPM.mjs → chunk-V7EI76QQ.mjs} +136 -141
- package/dist/{chunk-G7TD2VB7.mjs → chunk-WHJ5FALK.mjs} +7 -0
- package/dist/{chunk-3H3T54IC.mjs → chunk-XYVMNY2X.mjs} +4 -5
- package/dist/{core-P1CsH6jz.d.mts → core-BIcUwV18.d.mts} +1 -1
- package/dist/{core-BlN0Spy9.d.ts → core-CYwEPfN4.d.ts} +1 -1
- package/dist/helper.d.mts +4 -6
- package/dist/helper.d.ts +4 -6
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/{server → http}/elysia/index.d.mts +5 -5
- package/dist/{server → http}/elysia/index.d.ts +5 -5
- package/dist/{server → http}/elysia/index.js +80 -62
- package/dist/{server → http}/elysia/index.mjs +50 -32
- package/dist/{server → http}/express/index.d.mts +5 -5
- package/dist/{server → http}/express/index.d.ts +5 -5
- package/dist/{server → http}/express/index.js +71 -55
- package/dist/{server → http}/express/index.mjs +42 -26
- package/dist/{server → http}/fastify/index.d.mts +5 -5
- package/dist/{server → http}/fastify/index.d.ts +5 -5
- package/dist/{server → http}/fastify/index.js +72 -72
- package/dist/{server → http}/fastify/index.mjs +47 -47
- package/dist/{server → http}/h3/index.d.mts +5 -5
- package/dist/{server → http}/h3/index.d.ts +5 -5
- package/dist/http/h3/index.js +160 -0
- package/dist/{server → http}/h3/index.mjs +68 -62
- package/dist/{server → http}/hono/index.d.mts +5 -5
- package/dist/{server → http}/hono/index.d.ts +5 -5
- package/dist/{server → http}/hono/index.js +69 -54
- package/dist/{server → http}/hono/index.mjs +41 -26
- package/dist/{server → http}/hyper-express/index.d.mts +5 -5
- package/dist/{server → http}/hyper-express/index.d.ts +5 -5
- package/dist/{server → http}/hyper-express/index.js +69 -56
- package/dist/{server → http}/hyper-express/index.mjs +41 -28
- package/dist/{server → http}/koa/index.d.mts +5 -5
- package/dist/{server → http}/koa/index.d.ts +5 -5
- package/dist/{server → http}/koa/index.js +71 -55
- package/dist/{server → http}/koa/index.mjs +42 -26
- package/dist/index.d.mts +52 -41
- package/dist/index.d.ts +52 -41
- package/dist/index.js +59 -81
- package/dist/index.mjs +39 -61
- package/dist/{meta-KtfiBIde.d.ts → meta-BXKLFTgG.d.mts} +2 -3
- package/dist/{meta-KtfiBIde.d.mts → meta-BXKLFTgG.d.ts} +2 -3
- package/dist/rpc/bullmq/index.d.mts +6 -6
- package/dist/rpc/bullmq/index.d.ts +6 -6
- package/dist/rpc/bullmq/index.js +24 -24
- package/dist/rpc/bullmq/index.mjs +14 -14
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +25 -21
- package/dist/rpc/kafka/index.mjs +15 -11
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +22 -21
- package/dist/rpc/nats/index.mjs +13 -12
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +23 -22
- package/dist/rpc/rabbitmq/index.mjs +12 -11
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +24 -20
- package/dist/rpc/redis/index.mjs +15 -11
- 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-JVT0mgLD.d.ts → types-BtbL49Zs.d.mts} +2 -1
- package/dist/{types-DIw7B6Up.d.ts → types-VFzEM7LL.d.ts} +5 -5
- package/dist/{types-BvD3B5Ny.d.mts → types-h40T3cRG.d.mts} +5 -5
- package/dist/{types-t9D1fU6G.d.mts → types-m3IEDKjP.d.ts} +2 -1
- package/package.json +23 -23
- package/register/loader.mjs +366 -367
- package/dist/chunk-DVTBLV6I.js +0 -539
- package/dist/server/h3/index.js +0 -154
|
@@ -4,28 +4,29 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
|
|
11
11
|
|
|
12
12
|
// src/rpc/rabbitmq/bind.ts
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
14
14
|
var debug = _debug2.default.call(void 0, "phecda-server/rabbitmq");
|
|
15
15
|
async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
16
|
-
const { globalGuards,
|
|
17
|
-
const metaMap =
|
|
16
|
+
const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
17
|
+
const metaMap = _chunkGSPBHZBHjs.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
|
+
_chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
|
-
|
|
26
|
+
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
28
|
const existQueue = /* @__PURE__ */ new Set();
|
|
29
|
+
_chunkGSPBHZBHjs.Context.applyAddons(globalAddons, ch, "rabbitmq");
|
|
29
30
|
async function subscribeQueues() {
|
|
30
31
|
existQueue.clear();
|
|
31
32
|
for (const [tag, record] of metaMap) {
|
|
@@ -33,7 +34,7 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
33
34
|
const meta2 = metaMap.get(tag)[func];
|
|
34
35
|
const { data: { rpc } } = meta2;
|
|
35
36
|
if (rpc) {
|
|
36
|
-
const queue = rpc.queue || tag;
|
|
37
|
+
const queue = rpc.queue || defaultQueue || tag;
|
|
37
38
|
if (existQueue.has(queue)) continue;
|
|
38
39
|
existQueue.add(queue);
|
|
39
40
|
await ch.assertQueue(queue);
|
|
@@ -44,12 +45,12 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
48
49
|
async function handleRequest(msg) {
|
|
49
50
|
function send(queue, data) {
|
|
50
51
|
ch.sendToQueue(queue, Buffer.from(JSON.stringify(data)));
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, send, "send");
|
|
53
54
|
if (msg) {
|
|
54
55
|
const data = JSON.parse(msg.content.toString());
|
|
55
56
|
const { tag, func, id, queue: clientQueue, _ps, args } = data;
|
|
@@ -57,7 +58,12 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
57
58
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
58
59
|
const meta2 = metaMap.get(tag)[func];
|
|
59
60
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
60
|
-
const
|
|
61
|
+
const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
|
|
62
|
+
globalFilter,
|
|
63
|
+
globalGuards,
|
|
64
|
+
globalPipe
|
|
65
|
+
});
|
|
66
|
+
const context = new (0, _chunkGSPBHZBHjs.Context)({
|
|
61
67
|
type: "rabbitmq",
|
|
62
68
|
moduleMap,
|
|
63
69
|
meta: meta2,
|
|
@@ -70,12 +76,7 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
70
76
|
isEvent,
|
|
71
77
|
queue: msg.fields.routingKey
|
|
72
78
|
});
|
|
73
|
-
await context.run({
|
|
74
|
-
globalGuards,
|
|
75
|
-
globalInterceptors,
|
|
76
|
-
globalFilter,
|
|
77
|
-
globalPipe
|
|
78
|
-
}, (returnData) => {
|
|
79
|
+
await context.run(aop, (returnData) => {
|
|
79
80
|
if (!isEvent) send(clientQueue, {
|
|
80
81
|
data: returnData,
|
|
81
82
|
id
|
|
@@ -89,14 +90,14 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
93
94
|
subscribeQueues();
|
|
94
|
-
|
|
95
|
+
_chunkGSPBHZBHjs.HMR.call(void 0, async () => {
|
|
95
96
|
for (const queue of existQueue) await ch.deleteQueue(queue);
|
|
96
97
|
await subscribeQueues();
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
|
-
|
|
100
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, bind, "bind");
|
|
100
101
|
|
|
101
102
|
// src/rpc/rabbitmq/client.ts
|
|
102
103
|
var _events = require('events');
|
|
@@ -105,7 +106,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
105
106
|
let eventCount = 0;
|
|
106
107
|
const ret = {};
|
|
107
108
|
const emitter = new (0, _events.EventEmitter)();
|
|
108
|
-
const clientQueue =
|
|
109
|
+
const clientQueue = _chunkGSPBHZBHjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
109
110
|
await ch.assertQueue(clientQueue);
|
|
110
111
|
ch.consume(clientQueue, (msg) => {
|
|
111
112
|
if (!msg) return;
|
|
@@ -150,7 +151,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
150
151
|
if (error) reject(data);
|
|
151
152
|
else resolve(data);
|
|
152
153
|
}
|
|
153
|
-
|
|
154
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, listener, "listener");
|
|
154
155
|
eventCount++;
|
|
155
156
|
emitter.once(id, listener);
|
|
156
157
|
});
|
|
@@ -160,7 +161,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
160
161
|
}
|
|
161
162
|
return ret;
|
|
162
163
|
}
|
|
163
|
-
|
|
164
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, createClient, "createClient");
|
|
164
165
|
|
|
165
166
|
|
|
166
167
|
|
|
@@ -4,16 +4,16 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-V7EI76QQ.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-WHJ5FALK.mjs";
|
|
11
11
|
|
|
12
12
|
// src/rpc/rabbitmq/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
14
14
|
var debug = Debug("phecda-server/rabbitmq");
|
|
15
15
|
async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
16
|
-
const { globalGuards,
|
|
16
|
+
const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
17
17
|
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
18
18
|
const { controller, rpc, func, tag } = meta2.data;
|
|
19
19
|
if (controller === "rpc" && rpc?.queue !== void 0) {
|
|
@@ -23,9 +23,10 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
23
23
|
});
|
|
24
24
|
detectAopDep(meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
|
-
|
|
26
|
+
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
28
|
const existQueue = /* @__PURE__ */ new Set();
|
|
29
|
+
Context.applyAddons(globalAddons, ch, "rabbitmq");
|
|
29
30
|
async function subscribeQueues() {
|
|
30
31
|
existQueue.clear();
|
|
31
32
|
for (const [tag, record] of metaMap) {
|
|
@@ -33,7 +34,7 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
33
34
|
const meta2 = metaMap.get(tag)[func];
|
|
34
35
|
const { data: { rpc } } = meta2;
|
|
35
36
|
if (rpc) {
|
|
36
|
-
const queue = rpc.queue || tag;
|
|
37
|
+
const queue = rpc.queue || defaultQueue || tag;
|
|
37
38
|
if (existQueue.has(queue)) continue;
|
|
38
39
|
existQueue.add(queue);
|
|
39
40
|
await ch.assertQueue(queue);
|
|
@@ -57,6 +58,11 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
57
58
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
58
59
|
const meta2 = metaMap.get(tag)[func];
|
|
59
60
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
61
|
+
const aop = Context.getAop(meta2, {
|
|
62
|
+
globalFilter,
|
|
63
|
+
globalGuards,
|
|
64
|
+
globalPipe
|
|
65
|
+
});
|
|
60
66
|
const context = new Context({
|
|
61
67
|
type: "rabbitmq",
|
|
62
68
|
moduleMap,
|
|
@@ -70,12 +76,7 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
70
76
|
isEvent,
|
|
71
77
|
queue: msg.fields.routingKey
|
|
72
78
|
});
|
|
73
|
-
await context.run({
|
|
74
|
-
globalGuards,
|
|
75
|
-
globalInterceptors,
|
|
76
|
-
globalFilter,
|
|
77
|
-
globalPipe
|
|
78
|
-
}, (returnData) => {
|
|
79
|
+
await context.run(aop, (returnData) => {
|
|
79
80
|
if (!isEvent) send(clientQueue, {
|
|
80
81
|
data: returnData,
|
|
81
82
|
id
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
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-BIcUwV18.mjs';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-BtbL49Zs.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-BXKLFTgG.mjs';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface RedisCtx extends RpcContext {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
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-CYwEPfN4.js';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-m3IEDKjP.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-BXKLFTgG.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface RedisCtx extends RpcContext {
|
package/dist/rpc/redis/index.js
CHANGED
|
@@ -4,28 +4,32 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkJ5CFUN4Vjs = require('../../chunk-J5CFUN4V.js');
|
|
11
11
|
|
|
12
12
|
// src/rpc/redis/bind.ts
|
|
13
13
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
14
14
|
var debug = _debug2.default.call(void 0, "phecda-server/redis");
|
|
15
15
|
function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
16
|
-
const { globalGuards,
|
|
17
|
-
const metaMap =
|
|
16
|
+
const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
17
|
+
const metaMap = _chunkGSPBHZBHjs.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
|
+
_chunkGSPBHZBHjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
|
-
|
|
26
|
+
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
28
|
const existQueue = /* @__PURE__ */ new Set();
|
|
29
|
+
_chunkGSPBHZBHjs.Context.applyAddons(globalAddons, {
|
|
30
|
+
pub,
|
|
31
|
+
sub
|
|
32
|
+
}, "redis");
|
|
29
33
|
async function subscribeQueues() {
|
|
30
34
|
existQueue.clear();
|
|
31
35
|
for (const [tag, record] of metaMap) {
|
|
@@ -33,7 +37,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
33
37
|
const meta2 = metaMap.get(tag)[func];
|
|
34
38
|
const { data: { rpc } } = meta2;
|
|
35
39
|
if (rpc) {
|
|
36
|
-
const queue = rpc.queue || tag;
|
|
40
|
+
const queue = rpc.queue || defaultQueue || tag;
|
|
37
41
|
if (existQueue.has(queue)) continue;
|
|
38
42
|
existQueue.add(queue);
|
|
39
43
|
await sub.subscribe(queue);
|
|
@@ -41,7 +45,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
|
-
|
|
48
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
45
49
|
sub.on("message", async (channel, msg) => {
|
|
46
50
|
if (!existQueue.has(channel)) return;
|
|
47
51
|
if (msg) {
|
|
@@ -51,7 +55,12 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
51
55
|
if (_ps !== 1) return;
|
|
52
56
|
const meta2 = metaMap.get(tag)[func];
|
|
53
57
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
54
|
-
const
|
|
58
|
+
const aop = _chunkGSPBHZBHjs.Context.getAop(meta2, {
|
|
59
|
+
globalFilter,
|
|
60
|
+
globalGuards,
|
|
61
|
+
globalPipe
|
|
62
|
+
});
|
|
63
|
+
const context = new (0, _chunkGSPBHZBHjs.Context)({
|
|
55
64
|
type: "redis",
|
|
56
65
|
moduleMap,
|
|
57
66
|
redis: sub,
|
|
@@ -65,12 +74,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
65
74
|
isEvent,
|
|
66
75
|
queue: channel
|
|
67
76
|
});
|
|
68
|
-
await context.run({
|
|
69
|
-
globalGuards,
|
|
70
|
-
globalInterceptors,
|
|
71
|
-
globalFilter,
|
|
72
|
-
globalPipe
|
|
73
|
-
}, (returnData) => {
|
|
77
|
+
await context.run(aop, (returnData) => {
|
|
74
78
|
if (!isEvent) pub.publish(clientQueue, JSON.stringify({
|
|
75
79
|
data: returnData,
|
|
76
80
|
id
|
|
@@ -87,12 +91,12 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
87
91
|
}
|
|
88
92
|
});
|
|
89
93
|
subscribeQueues();
|
|
90
|
-
|
|
94
|
+
_chunkGSPBHZBHjs.HMR.call(void 0, async () => {
|
|
91
95
|
for (const queue of existQueue) await sub.unsubscribe(queue);
|
|
92
96
|
subscribeQueues();
|
|
93
97
|
});
|
|
94
98
|
}
|
|
95
|
-
|
|
99
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, bind, "bind");
|
|
96
100
|
|
|
97
101
|
// src/rpc/redis/client.ts
|
|
98
102
|
var _events = require('events'); var _events2 = _interopRequireDefault(_events);
|
|
@@ -101,7 +105,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
101
105
|
let eventId = 1;
|
|
102
106
|
let eventCount = 0;
|
|
103
107
|
const emitter = new (0, _events2.default)();
|
|
104
|
-
const clientQueue =
|
|
108
|
+
const clientQueue = _chunkGSPBHZBHjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
105
109
|
await sub.subscribe(clientQueue);
|
|
106
110
|
for (const i in controllers) {
|
|
107
111
|
ret[i] = new Proxy(new controllers[i](), {
|
|
@@ -141,7 +145,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
141
145
|
if (error) reject(data);
|
|
142
146
|
else resolve(data);
|
|
143
147
|
}
|
|
144
|
-
|
|
148
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, listener, "listener");
|
|
145
149
|
eventCount++;
|
|
146
150
|
emitter.once(id, listener);
|
|
147
151
|
});
|
|
@@ -157,7 +161,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
157
161
|
});
|
|
158
162
|
return ret;
|
|
159
163
|
}
|
|
160
|
-
|
|
164
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, createClient, "createClient");
|
|
161
165
|
|
|
162
166
|
|
|
163
167
|
|
package/dist/rpc/redis/index.mjs
CHANGED
|
@@ -4,16 +4,16 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-V7EI76QQ.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-WHJ5FALK.mjs";
|
|
11
11
|
|
|
12
12
|
// src/rpc/redis/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
14
14
|
var debug = Debug("phecda-server/redis");
|
|
15
15
|
function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
16
|
-
const { globalGuards,
|
|
16
|
+
const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
17
17
|
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
18
18
|
const { controller, rpc, func, tag } = meta2.data;
|
|
19
19
|
if (controller === "rpc" && rpc?.queue !== void 0) {
|
|
@@ -23,9 +23,13 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
23
23
|
});
|
|
24
24
|
detectAopDep(meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
|
-
|
|
26
|
+
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
28
|
const existQueue = /* @__PURE__ */ new Set();
|
|
29
|
+
Context.applyAddons(globalAddons, {
|
|
30
|
+
pub,
|
|
31
|
+
sub
|
|
32
|
+
}, "redis");
|
|
29
33
|
async function subscribeQueues() {
|
|
30
34
|
existQueue.clear();
|
|
31
35
|
for (const [tag, record] of metaMap) {
|
|
@@ -33,7 +37,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
33
37
|
const meta2 = metaMap.get(tag)[func];
|
|
34
38
|
const { data: { rpc } } = meta2;
|
|
35
39
|
if (rpc) {
|
|
36
|
-
const queue = rpc.queue || tag;
|
|
40
|
+
const queue = rpc.queue || defaultQueue || tag;
|
|
37
41
|
if (existQueue.has(queue)) continue;
|
|
38
42
|
existQueue.add(queue);
|
|
39
43
|
await sub.subscribe(queue);
|
|
@@ -51,6 +55,11 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
51
55
|
if (_ps !== 1) return;
|
|
52
56
|
const meta2 = metaMap.get(tag)[func];
|
|
53
57
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
58
|
+
const aop = Context.getAop(meta2, {
|
|
59
|
+
globalFilter,
|
|
60
|
+
globalGuards,
|
|
61
|
+
globalPipe
|
|
62
|
+
});
|
|
54
63
|
const context = new Context({
|
|
55
64
|
type: "redis",
|
|
56
65
|
moduleMap,
|
|
@@ -65,12 +74,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
65
74
|
isEvent,
|
|
66
75
|
queue: channel
|
|
67
76
|
});
|
|
68
|
-
await context.run({
|
|
69
|
-
globalGuards,
|
|
70
|
-
globalInterceptors,
|
|
71
|
-
globalFilter,
|
|
72
|
-
globalPipe
|
|
73
|
-
}, (returnData) => {
|
|
77
|
+
await context.run(aop, (returnData) => {
|
|
74
78
|
if (!isEvent) pub.publish(clientQueue, JSON.stringify({
|
|
75
79
|
data: returnData,
|
|
76
80
|
id
|
package/dist/test.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import * as supertest from 'supertest';
|
|
|
2
2
|
import { Test } from 'supertest';
|
|
3
3
|
import { Server } from 'node:http';
|
|
4
4
|
import { Construct } from 'phecda-core';
|
|
5
|
-
import { F as Factory } from './core-
|
|
6
|
-
import { P as PickFunc } from './meta-
|
|
5
|
+
import { F as Factory } from './core-BIcUwV18.mjs';
|
|
6
|
+
import { P as PickFunc } from './meta-BXKLFTgG.mjs';
|
|
7
7
|
|
|
8
8
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
9
9
|
get<C extends T[number]>(Model: C): InstanceType<C>;
|
|
@@ -11,7 +11,7 @@ declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
|
11
11
|
type SuperTestRequest<T> = {
|
|
12
12
|
[K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;
|
|
13
13
|
};
|
|
14
|
-
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "type" | "
|
|
14
|
+
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "type" | "query" | "key" | "use" | "on" | "set" | "accept" | "auth" | "withCredentials" | "retry" | "ok" | "redirects" | "timeout" | "buffer" | "serialize" | "parse" | "ca" | "pfx" | "cert"> & {
|
|
15
15
|
module: <T extends Construct>(Module: T) => SuperTestRequest<PickFunc<InstanceType<T>>>;
|
|
16
16
|
}>;
|
|
17
17
|
|
package/dist/test.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import * as supertest from 'supertest';
|
|
|
2
2
|
import { Test } from 'supertest';
|
|
3
3
|
import { Server } from 'node:http';
|
|
4
4
|
import { Construct } from 'phecda-core';
|
|
5
|
-
import { F as Factory } from './core-
|
|
6
|
-
import { P as PickFunc } from './meta-
|
|
5
|
+
import { F as Factory } from './core-CYwEPfN4.js';
|
|
6
|
+
import { P as PickFunc } from './meta-BXKLFTgG.js';
|
|
7
7
|
|
|
8
8
|
declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
9
9
|
get<C extends T[number]>(Model: C): InstanceType<C>;
|
|
@@ -11,7 +11,7 @@ declare function TestFactory<T extends Construct[]>(...Modules: T): Promise<{
|
|
|
11
11
|
type SuperTestRequest<T> = {
|
|
12
12
|
[K in keyof T]: T[K] extends (...args: infer R) => any ? (...args: R) => Test : never;
|
|
13
13
|
};
|
|
14
|
-
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "type" | "
|
|
14
|
+
declare function TestHttp(app: Server | any, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, isAgent?: boolean): Promise<supertest.SuperTestWithHost<Test> & Pick<supertest.Request, "type" | "query" | "key" | "use" | "on" | "set" | "accept" | "auth" | "withCredentials" | "retry" | "ok" | "redirects" | "timeout" | "buffer" | "serialize" | "parse" | "ca" | "pfx" | "cert"> & {
|
|
15
15
|
module: <T extends Construct>(Module: T) => SuperTestRequest<PickFunc<InstanceType<T>>>;
|
|
16
16
|
}>;
|
|
17
17
|
|
package/dist/test.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk7YQ57BQSjs = require('./chunk-7YQ57BQS.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkJ5CFUN4Vjs = require('./chunk-J5CFUN4V.js');
|
|
7
7
|
|
|
8
8
|
// src/test.ts
|
|
9
9
|
var _phecdacore = require('phecda-core');
|
|
10
10
|
async function TestFactory(...Modules) {
|
|
11
|
-
const { moduleMap, modelMap } = await
|
|
11
|
+
const { moduleMap, modelMap } = await _chunk7YQ57BQSjs.Factory.call(void 0, Modules);
|
|
12
12
|
return {
|
|
13
13
|
get(Model) {
|
|
14
14
|
const tag = _phecdacore.getTag.call(void 0, Model);
|
|
@@ -19,7 +19,7 @@ async function TestFactory(...Modules) {
|
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, TestFactory, "TestFactory");
|
|
23
23
|
async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
24
24
|
const { default: request, agent } = await Promise.resolve().then(() => _interopRequireWildcard(require("supertest")));
|
|
25
25
|
const Agent = agent(app);
|
|
@@ -59,11 +59,11 @@ async function TestHttp(app, { moduleMap, meta }, isAgent = true) {
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, module, "module");
|
|
63
63
|
Agent.module = module;
|
|
64
64
|
return Agent;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
_chunkJ5CFUN4Vjs.__name.call(void 0, TestHttp, "TestHttp");
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
|
package/dist/test.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { D as DefaultOptions, B as BaseContext } from './meta-
|
|
1
|
+
import { D as DefaultOptions, B as BaseContext } from './meta-BXKLFTgG.mjs';
|
|
2
2
|
|
|
3
3
|
interface RpcServerOptions extends DefaultOptions {
|
|
4
|
+
defaultQueue?: string;
|
|
4
5
|
}
|
|
5
6
|
interface RpcClientOptions {
|
|
6
7
|
key?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { D as DefaultOptions, B as BaseContext } from './meta-
|
|
2
|
+
import { D as DefaultOptions, B as BaseContext } from './meta-BXKLFTgG.js';
|
|
3
3
|
|
|
4
4
|
interface HttpOptions extends DefaultOptions {
|
|
5
5
|
/**
|
|
@@ -9,11 +9,11 @@ interface HttpOptions extends DefaultOptions {
|
|
|
9
9
|
/**
|
|
10
10
|
* 专用路由的插件(work for merge request),
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
parallelAddons?: string[];
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
* 是否动态计算pipe/guards/filer
|
|
15
|
+
*/
|
|
16
|
+
dynamic?: boolean;
|
|
17
17
|
}
|
|
18
18
|
interface HttpContext extends BaseContext {
|
|
19
19
|
parallel?: true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { D as DefaultOptions, B as BaseContext } from './meta-
|
|
2
|
+
import { D as DefaultOptions, B as BaseContext } from './meta-BXKLFTgG.mjs';
|
|
3
3
|
|
|
4
4
|
interface HttpOptions extends DefaultOptions {
|
|
5
5
|
/**
|
|
@@ -9,11 +9,11 @@ interface HttpOptions extends DefaultOptions {
|
|
|
9
9
|
/**
|
|
10
10
|
* 专用路由的插件(work for merge request),
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
parallelAddons?: string[];
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
* 是否动态计算pipe/guards/filer
|
|
15
|
+
*/
|
|
16
|
+
dynamic?: boolean;
|
|
17
17
|
}
|
|
18
18
|
interface HttpContext extends BaseContext {
|
|
19
19
|
parallel?: true;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { D as DefaultOptions, B as BaseContext } from './meta-
|
|
1
|
+
import { D as DefaultOptions, B as BaseContext } from './meta-BXKLFTgG.js';
|
|
2
2
|
|
|
3
3
|
interface RpcServerOptions extends DefaultOptions {
|
|
4
|
+
defaultQueue?: string;
|
|
4
5
|
}
|
|
5
6
|
interface RpcClientOptions {
|
|
6
7
|
key?: string;
|