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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Consumer, Producer } from 'kafkajs';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-DIfgUKIU.mjs';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DqH1qA-q.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-CR-D39hQ.mjs';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
|
-
interface KafkaCtx extends
|
|
7
|
+
interface KafkaCtx extends RpcCtx {
|
|
8
8
|
type: 'kafka';
|
|
9
9
|
topic: string;
|
|
10
10
|
partition: number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Consumer, Producer } from 'kafkajs';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-CUTbX_IS.js';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DYRu0vic.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-CR-D39hQ.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
|
-
interface KafkaCtx extends
|
|
7
|
+
interface KafkaCtx extends RpcCtx {
|
|
8
8
|
type: 'kafka';
|
|
9
9
|
topic: string;
|
|
10
10
|
partition: number;
|
package/dist/rpc/kafka/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkG7JFKM2Mjs = require('../../chunk-G7JFKM2M.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
10
10
|
|
|
11
11
|
// src/rpc/kafka/bind.ts
|
|
12
12
|
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
@@ -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 = _chunkG7JFKM2Mjs.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
|
+
_chunkG7JFKM2Mjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
|
-
|
|
28
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(globalAddons, {
|
|
29
29
|
consumer,
|
|
30
30
|
producer
|
|
31
31
|
}, "kafka");
|
|
@@ -47,10 +47,10 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
_chunk4LLLQOMFjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
51
51
|
await subscribeQueues();
|
|
52
52
|
await consumer.run({
|
|
53
|
-
eachMessage: /* @__PURE__ */
|
|
53
|
+
eachMessage: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, async ({ message, partition, topic, heartbeat, pause }) => {
|
|
54
54
|
if (!existQueue.has(topic)) return;
|
|
55
55
|
const data = JSON.parse(message.value.toString());
|
|
56
56
|
const { tag, func, id, queue: clientQueue, _ps, args } = data;
|
|
@@ -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 = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
63
63
|
globalFilter,
|
|
64
64
|
globalGuards,
|
|
65
65
|
globalPipe
|
|
66
66
|
});
|
|
67
|
-
const context = new (0,
|
|
67
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)({
|
|
68
68
|
type: "kafka",
|
|
69
|
+
category: "rpc",
|
|
69
70
|
moduleMap,
|
|
70
71
|
meta: meta2,
|
|
71
72
|
args,
|
|
@@ -112,7 +113,7 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
112
113
|
}, "eachMessage")
|
|
113
114
|
});
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
_chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
|
|
116
117
|
|
|
117
118
|
// src/rpc/kafka/client.ts
|
|
118
119
|
var _events = require('events');
|
|
@@ -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 = _chunkG7JFKM2Mjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
125
126
|
await consumer.subscribe({
|
|
126
127
|
topic: clientQueue,
|
|
127
128
|
fromBeginning: true
|
|
@@ -171,7 +172,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
171
172
|
if (error) reject(data);
|
|
172
173
|
else resolve(data);
|
|
173
174
|
}
|
|
174
|
-
|
|
175
|
+
_chunk4LLLQOMFjs.__name.call(void 0, listener, "listener");
|
|
175
176
|
eventCount++;
|
|
176
177
|
emitter.once(id, listener);
|
|
177
178
|
});
|
|
@@ -180,7 +181,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
180
181
|
});
|
|
181
182
|
}
|
|
182
183
|
await consumer.run({
|
|
183
|
-
eachMessage: /* @__PURE__ */
|
|
184
|
+
eachMessage: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, async ({ message, topic }) => {
|
|
184
185
|
if (clientQueue === topic && message.value) {
|
|
185
186
|
const { data, id, error } = JSON.parse(message.value.toString());
|
|
186
187
|
emitter.emit(id, data, error);
|
|
@@ -189,7 +190,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
189
190
|
});
|
|
190
191
|
return ret;
|
|
191
192
|
}
|
|
192
|
-
|
|
193
|
+
_chunk4LLLQOMFjs.__name.call(void 0, createClient, "createClient");
|
|
193
194
|
|
|
194
195
|
|
|
195
196
|
|
package/dist/rpc/kafka/index.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
createControllerMetaMap,
|
|
4
4
|
detectAopDep,
|
|
5
5
|
genClientQueue
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-Z7NAAE4M.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-NQ55PA2X.mjs";
|
|
10
10
|
|
|
11
11
|
// src/rpc/kafka/bind.ts
|
|
12
12
|
import Debug from "debug";
|
|
@@ -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,10 +1,10 @@
|
|
|
1
1
|
import { NatsConnection } from 'nats';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-DIfgUKIU.mjs';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DqH1qA-q.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-CR-D39hQ.mjs';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
|
-
interface NatsCtx extends
|
|
7
|
+
interface NatsCtx extends RpcCtx {
|
|
8
8
|
type: 'nats';
|
|
9
9
|
msg: any;
|
|
10
10
|
}
|
package/dist/rpc/nats/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NatsConnection } from 'nats';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-CUTbX_IS.js';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DYRu0vic.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-CR-D39hQ.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
|
-
interface NatsCtx extends
|
|
7
|
+
interface NatsCtx extends RpcCtx {
|
|
8
8
|
type: 'nats';
|
|
9
9
|
msg: any;
|
|
10
10
|
}
|
package/dist/rpc/nats/index.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
var _chunkG7JFKM2Mjs = require('../../chunk-G7JFKM2M.js');
|
|
5
6
|
|
|
6
|
-
var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
10
10
|
|
|
11
11
|
// src/rpc/nats/bind.ts
|
|
12
12
|
var _nats = require('nats');
|
|
@@ -17,18 +17,18 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
17
17
|
const sc = _nats.StringCodec.call(void 0, );
|
|
18
18
|
const subscriptionMap = {};
|
|
19
19
|
const existQueue = /* @__PURE__ */ new Set();
|
|
20
|
-
const metaMap =
|
|
20
|
+
const metaMap = _chunkG7JFKM2Mjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
21
21
|
const { controller, rpc, func, tag } = meta2.data;
|
|
22
22
|
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _2 => _2.queue]) !== void 0) {
|
|
23
23
|
debug(`register method "${func}" in module "${tag}"`);
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
_chunkG7JFKM2Mjs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
addons: globalAddons,
|
|
29
29
|
guards: globalGuards
|
|
30
30
|
}, "rpc");
|
|
31
|
-
|
|
31
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(globalAddons, nc, "nats");
|
|
32
32
|
async function subscribeQueues() {
|
|
33
33
|
existQueue.clear();
|
|
34
34
|
for (const [tag, record] of metaMap) {
|
|
@@ -47,7 +47,7 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
_chunk4LLLQOMFjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
51
51
|
async function handleRequest(_, msg) {
|
|
52
52
|
const data = JSON.parse(sc.decode(msg.data));
|
|
53
53
|
const { tag, func, id, _ps, args } = data;
|
|
@@ -56,13 +56,14 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
56
56
|
const meta2 = metaMap.get(tag)[func];
|
|
57
57
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
58
58
|
if (isEvent) msg.respond("{}");
|
|
59
|
-
const aop =
|
|
59
|
+
const aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
60
60
|
globalFilter,
|
|
61
61
|
globalGuards,
|
|
62
62
|
globalPipe
|
|
63
63
|
});
|
|
64
|
-
const context = new (0,
|
|
64
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)({
|
|
65
65
|
type: "nats",
|
|
66
|
+
category: "rpc",
|
|
66
67
|
moduleMap,
|
|
67
68
|
meta: meta2,
|
|
68
69
|
tag,
|
|
@@ -87,14 +88,14 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
87
88
|
})));
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
+
_chunk4LLLQOMFjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
91
92
|
subscribeQueues();
|
|
92
|
-
|
|
93
|
+
_chunk4LLLQOMFjs.HMR.call(void 0, async () => {
|
|
93
94
|
for (const i in subscriptionMap) subscriptionMap[i].unsubscribe();
|
|
94
95
|
await subscribeQueues();
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
+
_chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
|
|
98
99
|
|
|
99
100
|
// src/rpc/nats/client.ts
|
|
100
101
|
|
|
@@ -144,7 +145,7 @@ async function createClient(nc, controllers, opts) {
|
|
|
144
145
|
if (error) reject(data);
|
|
145
146
|
else resolve(data);
|
|
146
147
|
}
|
|
147
|
-
|
|
148
|
+
_chunk4LLLQOMFjs.__name.call(void 0, handler, "handler");
|
|
148
149
|
eventCount++;
|
|
149
150
|
});
|
|
150
151
|
};
|
|
@@ -153,7 +154,7 @@ async function createClient(nc, controllers, opts) {
|
|
|
153
154
|
}
|
|
154
155
|
return ret;
|
|
155
156
|
}
|
|
156
|
-
|
|
157
|
+
_chunk4LLLQOMFjs.__name.call(void 0, createClient, "createClient");
|
|
157
158
|
|
|
158
159
|
|
|
159
160
|
|
package/dist/rpc/nats/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Context,
|
|
3
|
-
HMR,
|
|
4
3
|
createControllerMetaMap,
|
|
5
4
|
detectAopDep
|
|
6
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-Z7NAAE4M.mjs";
|
|
7
6
|
import {
|
|
7
|
+
HMR,
|
|
8
8
|
__name
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-NQ55PA2X.mjs";
|
|
10
10
|
|
|
11
11
|
// src/rpc/nats/bind.ts
|
|
12
12
|
import { StringCodec } from "nats";
|
|
@@ -63,6 +63,7 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
63
63
|
});
|
|
64
64
|
const context = new Context({
|
|
65
65
|
type: "nats",
|
|
66
|
+
category: "rpc",
|
|
66
67
|
moduleMap,
|
|
67
68
|
meta: meta2,
|
|
68
69
|
tag,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import amqplib from 'amqplib';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-DIfgUKIU.mjs';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DqH1qA-q.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-CR-D39hQ.mjs';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
|
-
interface RabbitmqCtx extends
|
|
7
|
+
interface RabbitmqCtx extends RpcCtx {
|
|
8
8
|
type: 'rabbitmq';
|
|
9
9
|
ch: amqplib.Channel;
|
|
10
10
|
msg: amqplib.ConsumeMessage;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import amqplib from 'amqplib';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-CUTbX_IS.js';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DYRu0vic.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-CR-D39hQ.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
|
-
interface RabbitmqCtx extends
|
|
7
|
+
interface RabbitmqCtx extends RpcCtx {
|
|
8
8
|
type: 'rabbitmq';
|
|
9
9
|
ch: amqplib.Channel;
|
|
10
10
|
msg: amqplib.ConsumeMessage;
|
|
@@ -3,30 +3,30 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunkG7JFKM2Mjs = require('../../chunk-G7JFKM2M.js');
|
|
6
7
|
|
|
7
|
-
var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
11
11
|
|
|
12
12
|
// src/rpc/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
16
|
const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
17
|
-
const metaMap =
|
|
17
|
+
const metaMap = _chunkG7JFKM2Mjs.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
|
+
_chunkG7JFKM2Mjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
28
|
const existQueue = /* @__PURE__ */ new Set();
|
|
29
|
-
|
|
29
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(globalAddons, ch, "rabbitmq");
|
|
30
30
|
async function subscribeQueues() {
|
|
31
31
|
existQueue.clear();
|
|
32
32
|
for (const [tag, record] of metaMap) {
|
|
@@ -45,12 +45,12 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
_chunk4LLLQOMFjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
49
49
|
async function handleRequest(msg) {
|
|
50
50
|
function send(queue, data) {
|
|
51
51
|
ch.sendToQueue(queue, Buffer.from(JSON.stringify(data)));
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
_chunk4LLLQOMFjs.__name.call(void 0, send, "send");
|
|
54
54
|
if (msg) {
|
|
55
55
|
const data = JSON.parse(msg.content.toString());
|
|
56
56
|
const { tag, func, id, queue: clientQueue, _ps, args } = data;
|
|
@@ -58,13 +58,14 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
58
58
|
debug(`invoke method "${func}" in module "${tag}"`);
|
|
59
59
|
const meta2 = metaMap.get(tag)[func];
|
|
60
60
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
61
|
-
const aop =
|
|
61
|
+
const aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
62
62
|
globalFilter,
|
|
63
63
|
globalGuards,
|
|
64
64
|
globalPipe
|
|
65
65
|
});
|
|
66
|
-
const context = new (0,
|
|
66
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)({
|
|
67
67
|
type: "rabbitmq",
|
|
68
|
+
category: "rpc",
|
|
68
69
|
moduleMap,
|
|
69
70
|
meta: meta2,
|
|
70
71
|
tag,
|
|
@@ -90,14 +91,14 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
_chunk4LLLQOMFjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
94
95
|
subscribeQueues();
|
|
95
|
-
|
|
96
|
+
_chunk4LLLQOMFjs.HMR.call(void 0, async () => {
|
|
96
97
|
for (const queue of existQueue) await ch.deleteQueue(queue);
|
|
97
98
|
await subscribeQueues();
|
|
98
99
|
});
|
|
99
100
|
}
|
|
100
|
-
|
|
101
|
+
_chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
|
|
101
102
|
|
|
102
103
|
// src/rpc/rabbitmq/client.ts
|
|
103
104
|
var _events = require('events');
|
|
@@ -106,7 +107,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
106
107
|
let eventCount = 0;
|
|
107
108
|
const ret = {};
|
|
108
109
|
const emitter = new (0, _events.EventEmitter)();
|
|
109
|
-
const clientQueue =
|
|
110
|
+
const clientQueue = _chunkG7JFKM2Mjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
110
111
|
await ch.assertQueue(clientQueue);
|
|
111
112
|
ch.consume(clientQueue, (msg) => {
|
|
112
113
|
if (!msg) return;
|
|
@@ -151,7 +152,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
151
152
|
if (error) reject(data);
|
|
152
153
|
else resolve(data);
|
|
153
154
|
}
|
|
154
|
-
|
|
155
|
+
_chunk4LLLQOMFjs.__name.call(void 0, listener, "listener");
|
|
155
156
|
eventCount++;
|
|
156
157
|
emitter.once(id, listener);
|
|
157
158
|
});
|
|
@@ -161,7 +162,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
161
162
|
}
|
|
162
163
|
return ret;
|
|
163
164
|
}
|
|
164
|
-
|
|
165
|
+
_chunk4LLLQOMFjs.__name.call(void 0, createClient, "createClient");
|
|
165
166
|
|
|
166
167
|
|
|
167
168
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Context,
|
|
3
|
-
HMR,
|
|
4
3
|
createControllerMetaMap,
|
|
5
4
|
detectAopDep,
|
|
6
5
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-Z7NAAE4M.mjs";
|
|
8
7
|
import {
|
|
8
|
+
HMR,
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-NQ55PA2X.mjs";
|
|
11
11
|
|
|
12
12
|
// src/rpc/rabbitmq/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
@@ -65,6 +65,7 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
65
65
|
});
|
|
66
66
|
const context = new Context({
|
|
67
67
|
type: "rabbitmq",
|
|
68
|
+
category: "rpc",
|
|
68
69
|
moduleMap,
|
|
69
70
|
meta: meta2,
|
|
70
71
|
tag,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-DIfgUKIU.mjs';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DqH1qA-q.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-CR-D39hQ.mjs';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
|
-
interface RedisCtx extends
|
|
7
|
+
interface RedisCtx extends RpcCtx {
|
|
8
8
|
type: 'redis';
|
|
9
9
|
redis: Redis;
|
|
10
10
|
msg: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Redis from 'ioredis';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as
|
|
4
|
-
import { T as ToClientMap } from '../../meta-
|
|
2
|
+
import { F as Factory } from '../../core-CUTbX_IS.js';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions, b as RpcClientOptions } from '../../types-DYRu0vic.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-CR-D39hQ.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
|
-
interface RedisCtx extends
|
|
7
|
+
interface RedisCtx extends RpcCtx {
|
|
8
8
|
type: 'redis';
|
|
9
9
|
redis: Redis;
|
|
10
10
|
msg: string;
|
package/dist/rpc/redis/index.js
CHANGED
|
@@ -3,30 +3,30 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunkG7JFKM2Mjs = require('../../chunk-G7JFKM2M.js');
|
|
6
7
|
|
|
7
|
-
var _chunkGSPBHZBHjs = require('../../chunk-GSPBHZBH.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
11
11
|
|
|
12
12
|
// src/rpc/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
16
|
const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
17
|
-
const metaMap =
|
|
17
|
+
const metaMap = _chunkG7JFKM2Mjs.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
|
+
_chunkG7JFKM2Mjs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
28
|
const existQueue = /* @__PURE__ */ new Set();
|
|
29
|
-
|
|
29
|
+
_chunkG7JFKM2Mjs.Context.applyAddons(globalAddons, {
|
|
30
30
|
pub,
|
|
31
31
|
sub
|
|
32
32
|
}, "redis");
|
|
@@ -45,7 +45,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
_chunk4LLLQOMFjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
49
49
|
sub.on("message", async (channel, msg) => {
|
|
50
50
|
if (!existQueue.has(channel)) return;
|
|
51
51
|
if (msg) {
|
|
@@ -55,13 +55,14 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
55
55
|
if (_ps !== 1) return;
|
|
56
56
|
const meta2 = metaMap.get(tag)[func];
|
|
57
57
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
58
|
-
const aop =
|
|
58
|
+
const aop = _chunkG7JFKM2Mjs.Context.getAop(meta2, {
|
|
59
59
|
globalFilter,
|
|
60
60
|
globalGuards,
|
|
61
61
|
globalPipe
|
|
62
62
|
});
|
|
63
|
-
const context = new (0,
|
|
63
|
+
const context = new (0, _chunkG7JFKM2Mjs.Context)({
|
|
64
64
|
type: "redis",
|
|
65
|
+
category: "rpc",
|
|
65
66
|
moduleMap,
|
|
66
67
|
redis: sub,
|
|
67
68
|
meta: meta2,
|
|
@@ -91,12 +92,12 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
91
92
|
}
|
|
92
93
|
});
|
|
93
94
|
subscribeQueues();
|
|
94
|
-
|
|
95
|
+
_chunk4LLLQOMFjs.HMR.call(void 0, async () => {
|
|
95
96
|
for (const queue of existQueue) await sub.unsubscribe(queue);
|
|
96
97
|
subscribeQueues();
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
|
-
|
|
100
|
+
_chunk4LLLQOMFjs.__name.call(void 0, bind, "bind");
|
|
100
101
|
|
|
101
102
|
// src/rpc/redis/client.ts
|
|
102
103
|
var _events = require('events'); var _events2 = _interopRequireDefault(_events);
|
|
@@ -105,7 +106,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
105
106
|
let eventId = 1;
|
|
106
107
|
let eventCount = 0;
|
|
107
108
|
const emitter = new (0, _events2.default)();
|
|
108
|
-
const clientQueue =
|
|
109
|
+
const clientQueue = _chunkG7JFKM2Mjs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
109
110
|
await sub.subscribe(clientQueue);
|
|
110
111
|
for (const i in controllers) {
|
|
111
112
|
ret[i] = new Proxy(new controllers[i](), {
|
|
@@ -145,7 +146,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
145
146
|
if (error) reject(data);
|
|
146
147
|
else resolve(data);
|
|
147
148
|
}
|
|
148
|
-
|
|
149
|
+
_chunk4LLLQOMFjs.__name.call(void 0, listener, "listener");
|
|
149
150
|
eventCount++;
|
|
150
151
|
emitter.once(id, listener);
|
|
151
152
|
});
|
|
@@ -161,7 +162,7 @@ async function createClient({ pub, sub }, controllers, opts) {
|
|
|
161
162
|
});
|
|
162
163
|
return ret;
|
|
163
164
|
}
|
|
164
|
-
|
|
165
|
+
_chunk4LLLQOMFjs.__name.call(void 0, createClient, "createClient");
|
|
165
166
|
|
|
166
167
|
|
|
167
168
|
|
package/dist/rpc/redis/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Context,
|
|
3
|
-
HMR,
|
|
4
3
|
createControllerMetaMap,
|
|
5
4
|
detectAopDep,
|
|
6
5
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-Z7NAAE4M.mjs";
|
|
8
7
|
import {
|
|
8
|
+
HMR,
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-NQ55PA2X.mjs";
|
|
11
11
|
|
|
12
12
|
// src/rpc/redis/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
@@ -62,6 +62,7 @@ function bind({ sub, pub }, { moduleMap, meta }, opts = {}) {
|
|
|
62
62
|
});
|
|
63
63
|
const context = new Context({
|
|
64
64
|
type: "redis",
|
|
65
|
+
category: "rpc",
|
|
65
66
|
moduleMap,
|
|
66
67
|
redis: sub,
|
|
67
68
|
meta: meta2,
|