phecda-server 7.0.0-alpha.4 → 7.0.0-alpha.6
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/dist/{chunk-MMG73S64.mjs → chunk-3C7Z3IJN.mjs} +1 -1
- package/dist/chunk-62FBZWGW.js +106 -0
- package/dist/{chunk-A53KNKY4.mjs → chunk-HTY3H33L.mjs} +33 -3
- package/dist/{chunk-KUGFI6SC.mjs → chunk-ICI5KUDX.mjs} +1 -1
- package/dist/{chunk-6EBEME3I.js → chunk-JF4YU32E.js} +51 -51
- package/dist/chunk-KSDE5G57.mjs +106 -0
- package/dist/{chunk-QCOBXM7F.js → chunk-UKRQVTEY.js} +24 -24
- package/dist/{chunk-PKSWGQLW.js → chunk-WYI2F7LD.js} +50 -20
- package/dist/{core-C1kHRqU9.d.ts → core-CzElxZoF.d.ts} +2 -1
- package/dist/{core-CSiaRU7r.d.mts → core-DU7gQKSk.d.mts} +2 -1
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +3 -3
- package/dist/helper.mjs +2 -2
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +40 -40
- package/dist/http/elysia/index.mjs +3 -3
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +37 -37
- package/dist/http/express/index.mjs +2 -2
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +38 -38
- package/dist/http/fastify/index.mjs +3 -3
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +37 -37
- package/dist/http/h3/index.mjs +2 -2
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +35 -35
- package/dist/http/hono/index.mjs +2 -2
- package/dist/http/hyper-express/index.d.mts +3 -3
- package/dist/http/hyper-express/index.d.ts +3 -3
- package/dist/http/hyper-express/index.js +35 -35
- package/dist/http/hyper-express/index.mjs +2 -2
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +37 -37
- package/dist/http/koa/index.mjs +2 -2
- package/dist/index.d.mts +19 -15
- package/dist/index.d.ts +19 -15
- package/dist/index.js +43 -38
- package/dist/index.mjs +9 -4
- package/dist/{meta-D1M85Hef.d.ts → meta-BTnLXuCa.d.mts} +2 -1
- package/dist/{meta-D1M85Hef.d.mts → meta-BTnLXuCa.d.ts} +2 -1
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +14 -14
- package/dist/rpc/bullmq/index.mjs +2 -2
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +14 -14
- package/dist/rpc/kafka/index.mjs +2 -2
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +13 -13
- package/dist/rpc/nats/index.mjs +2 -2
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +15 -15
- package/dist/rpc/rabbitmq/index.mjs +2 -2
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +13 -13
- package/dist/rpc/redis/index.mjs +2 -2
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/test.js +6 -6
- package/dist/test.mjs +2 -2
- package/dist/{types-ee1FBodH.d.ts → types--E-OCZhC.d.ts} +1 -1
- package/dist/{types-JMhFVp-Z.d.mts → types-BYqBeqrs.d.mts} +1 -1
- package/dist/{types-wbHHC93P.d.mts → types-BxlzVoRv.d.mts} +1 -1
- package/dist/{types-C9Remkup.d.ts → types-CbfaGkPA.d.ts} +1 -1
- package/package.json +1 -1
- package/register/loader.mjs +2 -1
- package/register/utils.mjs +56 -56
- package/dist/chunk-QD3QR3NW.mjs +0 -73
- package/dist/chunk-RQSQRZL4.js +0 -73
|
@@ -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-DU7gQKSk.mjs';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-BYqBeqrs.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-BTnLXuCa.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-CzElxZoF.js';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CbfaGkPA.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-BTnLXuCa.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface BullmqCtx extends RpcContext {
|
package/dist/rpc/bullmq/index.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkJF4YU32Ejs = require('../../chunk-JF4YU32E.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk62FBZWGWjs = require('../../chunk-62FBZWGW.js');
|
|
11
11
|
|
|
12
12
|
// src/rpc/bullmq/create.ts
|
|
13
13
|
var _bullmq = require('bullmq');
|
|
@@ -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 = _chunkJF4YU32Ejs.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
|
+
_chunkJF4YU32Ejs.detectAopDep.call(void 0, meta, {
|
|
29
29
|
guards: globalGuards
|
|
30
30
|
}, "rpc");
|
|
31
31
|
async function subscribeQueues() {
|
|
@@ -39,12 +39,12 @@ 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
|
+
_chunkJF4YU32Ejs.Context.applyAddons(addons, workerMap[queue], "bullmq");
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
_chunk62FBZWGWjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
48
48
|
async function handleRequest(job) {
|
|
49
49
|
const { data } = job;
|
|
50
50
|
const { tag, func, args, id, queue: clientQueue, _ps } = data;
|
|
@@ -53,12 +53,12 @@ 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 = _chunkJF4YU32Ejs.Context.getAop(meta2, {
|
|
57
57
|
globalFilter,
|
|
58
58
|
globalGuards,
|
|
59
59
|
globalPipe
|
|
60
60
|
});
|
|
61
|
-
const context = new (0,
|
|
61
|
+
const context = new (0, _chunkJF4YU32Ejs.Context)({
|
|
62
62
|
type: "bullmq",
|
|
63
63
|
category: "rpc",
|
|
64
64
|
moduleMap,
|
|
@@ -86,9 +86,9 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
_chunk62FBZWGWjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
90
90
|
subscribeQueues();
|
|
91
|
-
|
|
91
|
+
_chunkJF4YU32Ejs.HMR.call(void 0, async () => {
|
|
92
92
|
for (const i in workerMap) await workerMap[i].close(true);
|
|
93
93
|
for (const i in queueMap) await queueMap[i].close();
|
|
94
94
|
await subscribeQueues();
|
|
@@ -98,7 +98,7 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
98
98
|
queueMap
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
_chunk62FBZWGWjs.__name.call(void 0, create, "create");
|
|
102
102
|
|
|
103
103
|
// src/rpc/bullmq/client.ts
|
|
104
104
|
var _events = require('events');
|
|
@@ -109,7 +109,7 @@ async function createClient(controllers, opts = {}) {
|
|
|
109
109
|
const { max, workerOpts, queueOpts, timeout, key } = opts;
|
|
110
110
|
const ret = {};
|
|
111
111
|
const emitter = new (0, _events.EventEmitter)();
|
|
112
|
-
const clientQueue =
|
|
112
|
+
const clientQueue = _chunkJF4YU32Ejs.genClientQueue.call(void 0, key);
|
|
113
113
|
const queueMap = {};
|
|
114
114
|
new (0, _bullmq.Worker)(clientQueue, async (job) => {
|
|
115
115
|
const { data, id, error } = job.data;
|
|
@@ -154,7 +154,7 @@ async function createClient(controllers, opts = {}) {
|
|
|
154
154
|
if (error) reject(data);
|
|
155
155
|
else resolve(data);
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
_chunk62FBZWGWjs.__name.call(void 0, listener, "listener");
|
|
158
158
|
eventCount++;
|
|
159
159
|
emitter.once(id, listener);
|
|
160
160
|
});
|
|
@@ -164,7 +164,7 @@ async function createClient(controllers, opts = {}) {
|
|
|
164
164
|
}
|
|
165
165
|
return ret;
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
_chunk62FBZWGWjs.__name.call(void 0, createClient, "createClient");
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-3C7Z3IJN.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-KSDE5G57.mjs";
|
|
11
11
|
|
|
12
12
|
// src/rpc/bullmq/create.ts
|
|
13
13
|
import { Queue, Worker } from "bullmq";
|
|
@@ -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-DU7gQKSk.mjs';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-BYqBeqrs.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-BTnLXuCa.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-CzElxZoF.js';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CbfaGkPA.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-BTnLXuCa.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface KafkaCtx extends RpcContext {
|
package/dist/rpc/kafka/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkJF4YU32Ejs = require('../../chunk-JF4YU32E.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk62FBZWGWjs = require('../../chunk-62FBZWGW.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 = _chunkJF4YU32Ejs.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
|
+
_chunkJF4YU32Ejs.detectAopDep.call(void 0, meta, {
|
|
25
25
|
guards: globalGuards,
|
|
26
26
|
addons: globalAddons
|
|
27
27
|
}, "rpc");
|
|
28
|
-
|
|
28
|
+
_chunkJF4YU32Ejs.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
|
+
_chunk62FBZWGWjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
51
51
|
await subscribeQueues();
|
|
52
52
|
await consumer.run({
|
|
53
|
-
eachMessage: /* @__PURE__ */
|
|
53
|
+
eachMessage: /* @__PURE__ */ _chunk62FBZWGWjs.__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,12 +59,12 @@ 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 = _chunkJF4YU32Ejs.Context.getAop(meta2, {
|
|
63
63
|
globalFilter,
|
|
64
64
|
globalGuards,
|
|
65
65
|
globalPipe
|
|
66
66
|
});
|
|
67
|
-
const context = new (0,
|
|
67
|
+
const context = new (0, _chunkJF4YU32Ejs.Context)({
|
|
68
68
|
type: "kafka",
|
|
69
69
|
category: "rpc",
|
|
70
70
|
moduleMap,
|
|
@@ -113,7 +113,7 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
113
113
|
}, "eachMessage")
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
_chunk62FBZWGWjs.__name.call(void 0, bind, "bind");
|
|
117
117
|
|
|
118
118
|
// src/rpc/kafka/client.ts
|
|
119
119
|
var _events = require('events');
|
|
@@ -122,7 +122,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
122
122
|
let eventCount = 1;
|
|
123
123
|
const ret = {};
|
|
124
124
|
const emitter = new (0, _events.EventEmitter)();
|
|
125
|
-
const clientQueue =
|
|
125
|
+
const clientQueue = _chunkJF4YU32Ejs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
126
126
|
await consumer.subscribe({
|
|
127
127
|
topic: clientQueue,
|
|
128
128
|
fromBeginning: true
|
|
@@ -172,7 +172,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
172
172
|
if (error) reject(data);
|
|
173
173
|
else resolve(data);
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
_chunk62FBZWGWjs.__name.call(void 0, listener, "listener");
|
|
176
176
|
eventCount++;
|
|
177
177
|
emitter.once(id, listener);
|
|
178
178
|
});
|
|
@@ -181,7 +181,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
183
|
await consumer.run({
|
|
184
|
-
eachMessage: /* @__PURE__ */
|
|
184
|
+
eachMessage: /* @__PURE__ */ _chunk62FBZWGWjs.__name.call(void 0, async ({ message, topic }) => {
|
|
185
185
|
if (clientQueue === topic && message.value) {
|
|
186
186
|
const { data, id, error } = JSON.parse(message.value.toString());
|
|
187
187
|
emitter.emit(id, data, error);
|
|
@@ -190,7 +190,7 @@ async function createClient({ producer, consumer }, controllers, opts) {
|
|
|
190
190
|
});
|
|
191
191
|
return ret;
|
|
192
192
|
}
|
|
193
|
-
|
|
193
|
+
_chunk62FBZWGWjs.__name.call(void 0, createClient, "createClient");
|
|
194
194
|
|
|
195
195
|
|
|
196
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-3C7Z3IJN.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-KSDE5G57.mjs";
|
|
10
10
|
|
|
11
11
|
// src/rpc/kafka/bind.ts
|
|
12
12
|
import Debug from "debug";
|
|
@@ -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-DU7gQKSk.mjs';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-BYqBeqrs.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-BTnLXuCa.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-CzElxZoF.js';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CbfaGkPA.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-BTnLXuCa.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface NatsCtx extends RpcContext {
|
package/dist/rpc/nats/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkJF4YU32Ejs = require('../../chunk-JF4YU32E.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk62FBZWGWjs = require('../../chunk-62FBZWGW.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 = _chunkJF4YU32Ejs.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
|
+
_chunkJF4YU32Ejs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
addons: globalAddons,
|
|
29
29
|
guards: globalGuards
|
|
30
30
|
}, "rpc");
|
|
31
|
-
|
|
31
|
+
_chunkJF4YU32Ejs.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
|
+
_chunk62FBZWGWjs.__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,12 +56,12 @@ 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 = _chunkJF4YU32Ejs.Context.getAop(meta2, {
|
|
60
60
|
globalFilter,
|
|
61
61
|
globalGuards,
|
|
62
62
|
globalPipe
|
|
63
63
|
});
|
|
64
|
-
const context = new (0,
|
|
64
|
+
const context = new (0, _chunkJF4YU32Ejs.Context)({
|
|
65
65
|
type: "nats",
|
|
66
66
|
category: "rpc",
|
|
67
67
|
moduleMap,
|
|
@@ -88,14 +88,14 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
88
88
|
})));
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
_chunk62FBZWGWjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
92
92
|
subscribeQueues();
|
|
93
|
-
|
|
93
|
+
_chunkJF4YU32Ejs.HMR.call(void 0, async () => {
|
|
94
94
|
for (const i in subscriptionMap) subscriptionMap[i].unsubscribe();
|
|
95
95
|
await subscribeQueues();
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
_chunk62FBZWGWjs.__name.call(void 0, bind, "bind");
|
|
99
99
|
|
|
100
100
|
// src/rpc/nats/client.ts
|
|
101
101
|
|
|
@@ -145,7 +145,7 @@ async function createClient(nc, controllers, opts) {
|
|
|
145
145
|
if (error) reject(data);
|
|
146
146
|
else resolve(data);
|
|
147
147
|
}
|
|
148
|
-
|
|
148
|
+
_chunk62FBZWGWjs.__name.call(void 0, handler, "handler");
|
|
149
149
|
eventCount++;
|
|
150
150
|
});
|
|
151
151
|
};
|
|
@@ -154,7 +154,7 @@ async function createClient(nc, controllers, opts) {
|
|
|
154
154
|
}
|
|
155
155
|
return ret;
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
_chunk62FBZWGWjs.__name.call(void 0, createClient, "createClient");
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
|
package/dist/rpc/nats/index.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
HMR,
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-3C7Z3IJN.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__name
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-KSDE5G57.mjs";
|
|
10
10
|
|
|
11
11
|
// src/rpc/nats/bind.ts
|
|
12
12
|
import { StringCodec } from "nats";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import amqplib from 'amqplib';
|
|
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-DU7gQKSk.mjs';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-BYqBeqrs.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-BTnLXuCa.mjs';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface RabbitmqCtx extends RpcContext {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import amqplib from 'amqplib';
|
|
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-CzElxZoF.js';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CbfaGkPA.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-BTnLXuCa.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface RabbitmqCtx extends RpcContext {
|
|
@@ -4,29 +4,29 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkJF4YU32Ejs = require('../../chunk-JF4YU32E.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk62FBZWGWjs = require('../../chunk-62FBZWGW.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 = _chunkJF4YU32Ejs.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
|
+
_chunkJF4YU32Ejs.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
|
+
_chunkJF4YU32Ejs.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
|
+
_chunk62FBZWGWjs.__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
|
+
_chunk62FBZWGWjs.__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,12 +58,12 @@ 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 = _chunkJF4YU32Ejs.Context.getAop(meta2, {
|
|
62
62
|
globalFilter,
|
|
63
63
|
globalGuards,
|
|
64
64
|
globalPipe
|
|
65
65
|
});
|
|
66
|
-
const context = new (0,
|
|
66
|
+
const context = new (0, _chunkJF4YU32Ejs.Context)({
|
|
67
67
|
type: "rabbitmq",
|
|
68
68
|
category: "rpc",
|
|
69
69
|
moduleMap,
|
|
@@ -91,14 +91,14 @@ async function bind(ch, { moduleMap, meta }, opts = {}) {
|
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
_chunk62FBZWGWjs.__name.call(void 0, handleRequest, "handleRequest");
|
|
95
95
|
subscribeQueues();
|
|
96
|
-
|
|
96
|
+
_chunkJF4YU32Ejs.HMR.call(void 0, async () => {
|
|
97
97
|
for (const queue of existQueue) await ch.deleteQueue(queue);
|
|
98
98
|
await subscribeQueues();
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
_chunk62FBZWGWjs.__name.call(void 0, bind, "bind");
|
|
102
102
|
|
|
103
103
|
// src/rpc/rabbitmq/client.ts
|
|
104
104
|
var _events = require('events');
|
|
@@ -107,7 +107,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
107
107
|
let eventCount = 0;
|
|
108
108
|
const ret = {};
|
|
109
109
|
const emitter = new (0, _events.EventEmitter)();
|
|
110
|
-
const clientQueue =
|
|
110
|
+
const clientQueue = _chunkJF4YU32Ejs.genClientQueue.call(void 0, _optionalChain([opts, 'optionalAccess', _2 => _2.key]));
|
|
111
111
|
await ch.assertQueue(clientQueue);
|
|
112
112
|
ch.consume(clientQueue, (msg) => {
|
|
113
113
|
if (!msg) return;
|
|
@@ -152,7 +152,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
152
152
|
if (error) reject(data);
|
|
153
153
|
else resolve(data);
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
_chunk62FBZWGWjs.__name.call(void 0, listener, "listener");
|
|
156
156
|
eventCount++;
|
|
157
157
|
emitter.once(id, listener);
|
|
158
158
|
});
|
|
@@ -162,7 +162,7 @@ async function createClient(ch, controllers, opts) {
|
|
|
162
162
|
}
|
|
163
163
|
return ret;
|
|
164
164
|
}
|
|
165
|
-
|
|
165
|
+
_chunk62FBZWGWjs.__name.call(void 0, createClient, "createClient");
|
|
166
166
|
|
|
167
167
|
|
|
168
168
|
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
createControllerMetaMap,
|
|
5
5
|
detectAopDep,
|
|
6
6
|
genClientQueue
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-3C7Z3IJN.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__name
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-KSDE5G57.mjs";
|
|
11
11
|
|
|
12
12
|
// src/rpc/rabbitmq/bind.ts
|
|
13
13
|
import Debug from "debug";
|
|
@@ -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-DU7gQKSk.mjs';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-BYqBeqrs.mjs';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-BTnLXuCa.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-CzElxZoF.js';
|
|
3
|
+
import { R as RpcContext, a as RpcServerOptions, b as RpcClientOptions } from '../../types-CbfaGkPA.js';
|
|
4
|
+
import { T as ToClientMap } from '../../meta-BTnLXuCa.js';
|
|
5
5
|
import 'phecda-core';
|
|
6
6
|
|
|
7
7
|
interface RedisCtx extends RpcContext {
|