phecda-server 7.1.4 → 8.0.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/dist/{chunk-MKRHYZCL.mjs → chunk-FI5756JX.mjs} +2 -2
- package/dist/{chunk-P3CS65OP.mjs → chunk-G5IH3TP7.mjs} +81 -21
- package/dist/{chunk-OV3UJLGP.js → chunk-LD7YMHIE.js} +81 -21
- package/dist/{chunk-YRS4ECPT.js → chunk-OLNN4U3O.js} +12 -8
- package/dist/{chunk-5MAGRSEM.mjs → chunk-PFPOEZHH.mjs} +12 -8
- package/dist/{chunk-DPPDWBYO.js → chunk-UYZSUBX4.js} +2 -2
- package/dist/{core-B5yKYkMJ.d.mts → core-BTSHIAyB.d.ts} +2 -1
- package/dist/{core-BRuvL6hY.d.ts → core-D1YYphEn.d.mts} +2 -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 +30 -30
- package/dist/http/elysia/index.mjs +15 -15
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +27 -27
- package/dist/http/express/index.mjs +14 -14
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +29 -29
- package/dist/http/fastify/index.mjs +15 -15
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +28 -28
- package/dist/http/h3/index.mjs +14 -14
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +26 -26
- package/dist/http/hono/index.mjs +14 -14
- 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 +26 -26
- package/dist/http/hyper-express/index.mjs +14 -14
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +27 -27
- package/dist/http/koa/index.mjs +14 -14
- package/dist/index.d.mts +20 -13
- package/dist/index.d.ts +20 -13
- package/dist/index.js +112 -71
- package/dist/index.mjs +69 -28
- package/dist/{meta-C_eDyXnK.d.ts → meta-DNF6Fl27.d.mts} +11 -9
- package/dist/{meta-C_eDyXnK.d.mts → meta-DNF6Fl27.d.ts} +11 -9
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +16 -16
- package/dist/rpc/bullmq/index.mjs +11 -11
- package/dist/rpc/electron/index.d.mts +3 -3
- package/dist/rpc/electron/index.d.ts +3 -3
- package/dist/rpc/electron/index.js +11 -11
- package/dist/rpc/electron/index.mjs +7 -7
- 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 +9 -9
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +14 -14
- package/dist/rpc/nats/index.mjs +9 -9
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +14 -14
- package/dist/rpc/rabbitmq/index.mjs +9 -9
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +14 -14
- package/dist/rpc/redis/index.mjs +9 -9
- package/dist/rpc/ws/index.d.mts +3 -3
- package/dist/rpc/ws/index.d.ts +3 -3
- package/dist/rpc/ws/index.js +10 -10
- package/dist/rpc/ws/index.mjs +6 -6
- package/dist/test.d.mts +2 -2
- package/dist/test.d.ts +2 -2
- package/dist/test.js +5 -5
- package/dist/test.mjs +4 -4
- package/dist/{types-7-m2wEkP.d.mts → types-BOZ8yE2L.d.mts} +1 -1
- package/dist/{types-BuvMT1ta.d.ts → types-Cosv4nol.d.ts} +1 -1
- package/dist/{types-BKHBmSQN.d.mts → types-DtiHAXQB.d.mts} +1 -1
- package/dist/{types-B6aU8oT-.d.ts → types-YJ55P7A_.d.ts} +1 -1
- package/package.json +3 -4
- package/register/export.mjs +5 -1
- package/register/utils.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Events } from 'phecda-core';
|
|
1
|
+
import { Events, Construct } from 'phecda-core';
|
|
2
2
|
|
|
3
3
|
declare const ERROR_SYMBOL = "__PS_ERROR__";
|
|
4
4
|
declare const IS_DEV: boolean;
|
|
@@ -23,7 +23,7 @@ interface BaseCtx {
|
|
|
23
23
|
moduleMap: Record<string, any>;
|
|
24
24
|
type: string;
|
|
25
25
|
tag: string;
|
|
26
|
-
|
|
26
|
+
method: string;
|
|
27
27
|
category: string;
|
|
28
28
|
[key: string]: any;
|
|
29
29
|
}
|
|
@@ -39,24 +39,24 @@ interface BaseError {
|
|
|
39
39
|
message: string;
|
|
40
40
|
description: string;
|
|
41
41
|
}
|
|
42
|
-
type
|
|
42
|
+
type BaseRequestMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
|
|
43
43
|
declare class CustomResponse<Value> {
|
|
44
44
|
_ps_response: Value;
|
|
45
45
|
}
|
|
46
46
|
type ExtractResponse<Class extends CustomResponse<any>> = Class extends CustomResponse<infer Value> ? Value : never;
|
|
47
47
|
|
|
48
48
|
interface ServiceMetaData {
|
|
49
|
-
|
|
49
|
+
method: string;
|
|
50
50
|
name: string;
|
|
51
51
|
tag: string;
|
|
52
52
|
define?: any;
|
|
53
|
-
|
|
53
|
+
meta: any;
|
|
54
54
|
[key: string]: any;
|
|
55
55
|
}
|
|
56
56
|
interface ControllerMetaData extends ServiceMetaData {
|
|
57
57
|
controller: string;
|
|
58
58
|
http?: {
|
|
59
|
-
|
|
59
|
+
method: BaseRequestMethod;
|
|
60
60
|
prefix: string;
|
|
61
61
|
route: string;
|
|
62
62
|
headers?: Record<string, string>;
|
|
@@ -72,7 +72,7 @@ interface ControllerMetaData extends ServiceMetaData {
|
|
|
72
72
|
key: string;
|
|
73
73
|
pipe?: string;
|
|
74
74
|
define: Record<string, any>;
|
|
75
|
-
|
|
75
|
+
meta: any;
|
|
76
76
|
}[];
|
|
77
77
|
guards: string[];
|
|
78
78
|
pipe?: string;
|
|
@@ -83,10 +83,12 @@ type MetaData = ControllerMetaData | ServiceMetaData;
|
|
|
83
83
|
declare class Meta {
|
|
84
84
|
data: MetaData;
|
|
85
85
|
paramsType: any[];
|
|
86
|
-
|
|
86
|
+
module: any;
|
|
87
|
+
model: Construct;
|
|
88
|
+
constructor(data: MetaData, paramsType: any[], module: any, model: Construct);
|
|
87
89
|
}
|
|
88
90
|
interface ControllerMeta extends Meta {
|
|
89
91
|
data: ControllerMetaData;
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
export { type BaseCtx as B, CustomResponse as C, type DefaultOptions as D, type Emitter as E, IS_DEV as I, LOG_LEVEL as L, Meta as M, PS_EXIT_CODE as P, type ServiceMetaData as S, type ControllerMeta as a, type ControllerMetaData as b, type BaseError as c, type
|
|
94
|
+
export { type BaseCtx as B, CustomResponse as C, type DefaultOptions as D, type Emitter as E, IS_DEV as I, LOG_LEVEL as L, Meta as M, PS_EXIT_CODE as P, type ServiceMetaData as S, type ControllerMeta as a, type ControllerMetaData as b, type BaseError as c, type BaseRequestMethod as d, type ExtractResponse as e, type MetaData as f, ERROR_SYMBOL as g, IS_ONLY_GENERATE as h, IS_STRICT as i, IS_PURE as j };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcCtx, a as RpcServerOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-D1YYphEn.mjs';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions } from '../../types-BOZ8yE2L.mjs';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.mjs';
|
|
6
6
|
|
|
7
7
|
interface BullmqCtx extends RpcCtx {
|
|
8
8
|
type: 'bullmq';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WorkerOptions, QueueOptions, Worker, Queue } from 'bullmq';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcCtx, a as RpcServerOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-BTSHIAyB.js';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions } from '../../types-YJ55P7A_.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.js';
|
|
6
6
|
|
|
7
7
|
interface BullmqCtx extends RpcCtx {
|
|
8
8
|
type: 'bullmq';
|
package/dist/rpc/bullmq/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkLD7YMHIEjs = require('../../chunk-LD7YMHIE.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -17,28 +17,28 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
17
17
|
const workerMap = {};
|
|
18
18
|
const queueMap = {};
|
|
19
19
|
const existQueue = /* @__PURE__ */ new Set();
|
|
20
|
-
const metaMap =
|
|
21
|
-
const { controller, rpc,
|
|
20
|
+
const metaMap = _chunkLD7YMHIEjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
21
|
+
const { controller, rpc, method, tag } = meta2.data;
|
|
22
22
|
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
|
|
23
|
-
debug(`register method "${
|
|
23
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
_chunkLD7YMHIEjs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
guards: globalGuards
|
|
29
29
|
}, "rpc");
|
|
30
30
|
async function subscribeQueues() {
|
|
31
31
|
existQueue.clear();
|
|
32
32
|
for (const [tag, record] of metaMap) {
|
|
33
|
-
for (const
|
|
34
|
-
const meta2 = metaMap.get(tag)[
|
|
33
|
+
for (const method in record) {
|
|
34
|
+
const meta2 = metaMap.get(tag)[method];
|
|
35
35
|
const { data: { rpc, addons } } = meta2;
|
|
36
36
|
if (rpc) {
|
|
37
37
|
const queue = rpc.queue || defaultQueue || tag;
|
|
38
38
|
if (existQueue.has(queue)) continue;
|
|
39
39
|
existQueue.add(queue);
|
|
40
40
|
workerMap[queue] = new (0, _bullmq.Worker)(queue, handleRequest, workerOpts);
|
|
41
|
-
|
|
41
|
+
_chunkLD7YMHIEjs.Context.applyAddons(addons, workerMap[queue], "bullmq");
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -46,24 +46,24 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
46
46
|
_chunk4LLLQOMFjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
47
47
|
async function handleRequest(job) {
|
|
48
48
|
const { data } = job;
|
|
49
|
-
const { tag,
|
|
49
|
+
const { tag, method, args, id, queue: clientQueue, _ps } = data;
|
|
50
50
|
if (_ps !== 1) return;
|
|
51
|
-
debug(`invoke method "${
|
|
52
|
-
const meta2 = metaMap.get(tag)[
|
|
51
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
52
|
+
const meta2 = metaMap.get(tag)[method];
|
|
53
53
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
54
54
|
if (!isEvent && !(clientQueue in queueMap)) queueMap[clientQueue] = new (0, _bullmq.Queue)(clientQueue, queueOpts);
|
|
55
|
-
const aop =
|
|
55
|
+
const aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
56
56
|
globalFilter,
|
|
57
57
|
globalGuards,
|
|
58
58
|
globalPipe
|
|
59
59
|
});
|
|
60
|
-
const context = new (0,
|
|
60
|
+
const context = new (0, _chunkLD7YMHIEjs.Context)({
|
|
61
61
|
type: "bullmq",
|
|
62
62
|
category: "rpc",
|
|
63
63
|
moduleMap,
|
|
64
64
|
meta: meta2,
|
|
65
65
|
tag,
|
|
66
|
-
|
|
66
|
+
method,
|
|
67
67
|
data,
|
|
68
68
|
args,
|
|
69
69
|
id,
|
|
@@ -71,13 +71,13 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
71
71
|
isEvent
|
|
72
72
|
});
|
|
73
73
|
await context.run(aop, (returnData) => {
|
|
74
|
-
if (!isEvent) queueMap[clientQueue].add(`${tag}-${
|
|
74
|
+
if (!isEvent) queueMap[clientQueue].add(`${tag}-${method}`, {
|
|
75
75
|
data: returnData,
|
|
76
76
|
id
|
|
77
77
|
});
|
|
78
78
|
}, (err) => {
|
|
79
79
|
if (!isEvent) {
|
|
80
|
-
queueMap[clientQueue].add(`${tag}-${
|
|
80
|
+
queueMap[clientQueue].add(`${tag}-${method}`, {
|
|
81
81
|
data: err,
|
|
82
82
|
error: true,
|
|
83
83
|
id
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
Context,
|
|
3
3
|
createControllerMetaMap,
|
|
4
4
|
detectAopDep
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-G5IH3TP7.mjs";
|
|
6
6
|
import {
|
|
7
7
|
HMR,
|
|
8
8
|
__name
|
|
@@ -18,9 +18,9 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
18
18
|
const queueMap = {};
|
|
19
19
|
const existQueue = /* @__PURE__ */ new Set();
|
|
20
20
|
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
21
|
-
const { controller, rpc,
|
|
21
|
+
const { controller, rpc, method, tag } = meta2.data;
|
|
22
22
|
if (controller === "rpc" && rpc?.queue !== void 0) {
|
|
23
|
-
debug(`register method "${
|
|
23
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
@@ -30,8 +30,8 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
30
30
|
async function subscribeQueues() {
|
|
31
31
|
existQueue.clear();
|
|
32
32
|
for (const [tag, record] of metaMap) {
|
|
33
|
-
for (const
|
|
34
|
-
const meta2 = metaMap.get(tag)[
|
|
33
|
+
for (const method in record) {
|
|
34
|
+
const meta2 = metaMap.get(tag)[method];
|
|
35
35
|
const { data: { rpc, addons } } = meta2;
|
|
36
36
|
if (rpc) {
|
|
37
37
|
const queue = rpc.queue || defaultQueue || tag;
|
|
@@ -46,10 +46,10 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
46
46
|
__name(subscribeQueues, "subscribeQueues");
|
|
47
47
|
async function handleRequest(job) {
|
|
48
48
|
const { data } = job;
|
|
49
|
-
const { tag,
|
|
49
|
+
const { tag, method, args, id, queue: clientQueue, _ps } = data;
|
|
50
50
|
if (_ps !== 1) return;
|
|
51
|
-
debug(`invoke method "${
|
|
52
|
-
const meta2 = metaMap.get(tag)[
|
|
51
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
52
|
+
const meta2 = metaMap.get(tag)[method];
|
|
53
53
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
54
54
|
if (!isEvent && !(clientQueue in queueMap)) queueMap[clientQueue] = new Queue(clientQueue, queueOpts);
|
|
55
55
|
const aop = Context.getAop(meta2, {
|
|
@@ -63,7 +63,7 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
63
63
|
moduleMap,
|
|
64
64
|
meta: meta2,
|
|
65
65
|
tag,
|
|
66
|
-
|
|
66
|
+
method,
|
|
67
67
|
data,
|
|
68
68
|
args,
|
|
69
69
|
id,
|
|
@@ -71,13 +71,13 @@ async function create({ moduleMap, meta }, opts = {}) {
|
|
|
71
71
|
isEvent
|
|
72
72
|
});
|
|
73
73
|
await context.run(aop, (returnData) => {
|
|
74
|
-
if (!isEvent) queueMap[clientQueue].add(`${tag}-${
|
|
74
|
+
if (!isEvent) queueMap[clientQueue].add(`${tag}-${method}`, {
|
|
75
75
|
data: returnData,
|
|
76
76
|
id
|
|
77
77
|
});
|
|
78
78
|
}, (err) => {
|
|
79
79
|
if (!isEvent) {
|
|
80
|
-
queueMap[clientQueue].add(`${tag}-${
|
|
80
|
+
queueMap[clientQueue].add(`${tag}-${method}`, {
|
|
81
81
|
data: err,
|
|
82
82
|
error: true,
|
|
83
83
|
id
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Electron from 'electron';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcCtx, a as RpcServerOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-D1YYphEn.mjs';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions } from '../../types-BOZ8yE2L.mjs';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.mjs';
|
|
6
6
|
|
|
7
7
|
interface ElectronCtx extends RpcCtx {
|
|
8
8
|
type: 'electron';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Electron from 'electron';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcCtx, a as RpcServerOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-BTSHIAyB.js';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions } from '../../types-YJ55P7A_.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.js';
|
|
6
6
|
|
|
7
7
|
interface ElectronCtx extends RpcCtx {
|
|
8
8
|
type: 'electron';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkLD7YMHIEjs = require('../../chunk-LD7YMHIE.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
@@ -12,37 +12,37 @@ var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
|
12
12
|
var debug = _debug2.default.call(void 0, "phecda-server/electron");
|
|
13
13
|
function bind(IPC, { moduleMap, meta }, opts = {}) {
|
|
14
14
|
const { globalGuards, globalFilter, globalPipe, globalAddons = [] } = opts;
|
|
15
|
-
const metaMap =
|
|
16
|
-
const { controller, rpc,
|
|
15
|
+
const metaMap = _chunkLD7YMHIEjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
16
|
+
const { controller, rpc, method, tag } = meta2.data;
|
|
17
17
|
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
|
|
18
|
-
debug(`register method "${
|
|
18
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
19
19
|
return true;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
_chunkLD7YMHIEjs.detectAopDep.call(void 0, meta, {
|
|
23
23
|
guards: globalGuards,
|
|
24
24
|
addons: globalAddons
|
|
25
25
|
}, "rpc");
|
|
26
26
|
IPC.handle("phecda-server:invoke", callback);
|
|
27
27
|
IPC.on("phecda-server:send", callback);
|
|
28
28
|
async function callback(event, data) {
|
|
29
|
-
const {
|
|
30
|
-
debug(`invoke method "${
|
|
29
|
+
const { method, id, tag, _ps, args } = data || {};
|
|
30
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
31
31
|
if (_ps !== 1) return;
|
|
32
|
-
const meta2 = metaMap.get(tag)[
|
|
32
|
+
const meta2 = metaMap.get(tag)[method];
|
|
33
33
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
34
|
-
const aop =
|
|
34
|
+
const aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
35
35
|
globalFilter,
|
|
36
36
|
globalGuards,
|
|
37
37
|
globalPipe
|
|
38
38
|
});
|
|
39
|
-
const context = new (0,
|
|
39
|
+
const context = new (0, _chunkLD7YMHIEjs.Context)({
|
|
40
40
|
type: "electron",
|
|
41
41
|
category: "rpc",
|
|
42
42
|
moduleMap,
|
|
43
43
|
meta: meta2,
|
|
44
44
|
tag,
|
|
45
|
-
|
|
45
|
+
method,
|
|
46
46
|
args,
|
|
47
47
|
id,
|
|
48
48
|
isEvent,
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
Context,
|
|
3
3
|
createControllerMetaMap,
|
|
4
4
|
detectAopDep
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-G5IH3TP7.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "../../chunk-NQ55PA2X.mjs";
|
|
@@ -13,9 +13,9 @@ var debug = Debug("phecda-server/electron");
|
|
|
13
13
|
function bind(IPC, { moduleMap, meta }, opts = {}) {
|
|
14
14
|
const { globalGuards, globalFilter, globalPipe, globalAddons = [] } = opts;
|
|
15
15
|
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
16
|
-
const { controller, rpc,
|
|
16
|
+
const { controller, rpc, method, tag } = meta2.data;
|
|
17
17
|
if (controller === "rpc" && rpc?.queue !== void 0) {
|
|
18
|
-
debug(`register method "${
|
|
18
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
19
19
|
return true;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
@@ -26,10 +26,10 @@ function bind(IPC, { moduleMap, meta }, opts = {}) {
|
|
|
26
26
|
IPC.handle("phecda-server:invoke", callback);
|
|
27
27
|
IPC.on("phecda-server:send", callback);
|
|
28
28
|
async function callback(event, data) {
|
|
29
|
-
const {
|
|
30
|
-
debug(`invoke method "${
|
|
29
|
+
const { method, id, tag, _ps, args } = data || {};
|
|
30
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
31
31
|
if (_ps !== 1) return;
|
|
32
|
-
const meta2 = metaMap.get(tag)[
|
|
32
|
+
const meta2 = metaMap.get(tag)[method];
|
|
33
33
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
34
34
|
const aop = Context.getAop(meta2, {
|
|
35
35
|
globalFilter,
|
|
@@ -42,7 +42,7 @@ function bind(IPC, { moduleMap, meta }, opts = {}) {
|
|
|
42
42
|
moduleMap,
|
|
43
43
|
meta: meta2,
|
|
44
44
|
tag,
|
|
45
|
-
|
|
45
|
+
method,
|
|
46
46
|
args,
|
|
47
47
|
id,
|
|
48
48
|
isEvent,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Consumer, Producer } from 'kafkajs';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcCtx, a as RpcServerOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-D1YYphEn.mjs';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions } from '../../types-BOZ8yE2L.mjs';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.mjs';
|
|
6
6
|
|
|
7
7
|
interface KafkaCtx extends RpcCtx {
|
|
8
8
|
type: 'kafka';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Consumer, Producer } from 'kafkajs';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcCtx, a as RpcServerOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-BTSHIAyB.js';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions } from '../../types-YJ55P7A_.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.js';
|
|
6
6
|
|
|
7
7
|
interface KafkaCtx extends RpcCtx {
|
|
8
8
|
type: 'kafka';
|
package/dist/rpc/kafka/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkLD7YMHIEjs = require('../../chunk-LD7YMHIE.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
var _chunk4LLLQOMFjs = require('../../chunk-4LLLQOMF.js');
|
|
@@ -13,26 +13,26 @@ var debug = _debug2.default.call(void 0, "phecda-server/kafka");
|
|
|
13
13
|
async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
14
14
|
const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
15
15
|
const existQueue = /* @__PURE__ */ new Set();
|
|
16
|
-
const metaMap =
|
|
17
|
-
const { controller, rpc,
|
|
16
|
+
const metaMap = _chunkLD7YMHIEjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
17
|
+
const { controller, rpc, method, tag } = meta2.data;
|
|
18
18
|
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _ => _.queue]) !== void 0) {
|
|
19
|
-
debug(`register method "${
|
|
19
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
-
|
|
23
|
+
_chunkLD7YMHIEjs.detectAopDep.call(void 0, meta, {
|
|
24
24
|
guards: globalGuards,
|
|
25
25
|
addons: globalAddons
|
|
26
26
|
}, "rpc");
|
|
27
|
-
|
|
27
|
+
_chunkLD7YMHIEjs.Context.applyAddons(globalAddons, {
|
|
28
28
|
consumer,
|
|
29
29
|
producer
|
|
30
30
|
}, "kafka");
|
|
31
31
|
async function subscribeQueues() {
|
|
32
32
|
existQueue.clear();
|
|
33
33
|
for (const [tag, record] of metaMap) {
|
|
34
|
-
for (const
|
|
35
|
-
const meta2 = metaMap.get(tag)[
|
|
34
|
+
for (const method in record) {
|
|
35
|
+
const meta2 = metaMap.get(tag)[method];
|
|
36
36
|
const { data: { rpc } } = meta2;
|
|
37
37
|
if (rpc) {
|
|
38
38
|
const queue = rpc.queue || defaultQueue || tag;
|
|
@@ -52,18 +52,18 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
52
52
|
eachMessage: /* @__PURE__ */ _chunk4LLLQOMFjs.__name.call(void 0, async ({ message, partition, topic, heartbeat, pause }) => {
|
|
53
53
|
if (!existQueue.has(topic)) return;
|
|
54
54
|
const data = JSON.parse(message.value.toString());
|
|
55
|
-
const { tag,
|
|
55
|
+
const { tag, method, id, queue: clientQueue, _ps, args } = data;
|
|
56
56
|
if (_ps !== 1) return;
|
|
57
|
-
debug(`invoke method "${
|
|
58
|
-
const meta2 = metaMap.get(tag)[
|
|
57
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
58
|
+
const meta2 = metaMap.get(tag)[method];
|
|
59
59
|
const { data: { rpc } } = meta2;
|
|
60
60
|
const isEvent = rpc.isEvent;
|
|
61
|
-
const aop =
|
|
61
|
+
const aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
62
62
|
globalFilter,
|
|
63
63
|
globalGuards,
|
|
64
64
|
globalPipe
|
|
65
65
|
});
|
|
66
|
-
const context = new (0,
|
|
66
|
+
const context = new (0, _chunkLD7YMHIEjs.Context)({
|
|
67
67
|
type: "kafka",
|
|
68
68
|
category: "rpc",
|
|
69
69
|
moduleMap,
|
|
@@ -71,7 +71,7 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
71
71
|
args,
|
|
72
72
|
id,
|
|
73
73
|
tag,
|
|
74
|
-
|
|
74
|
+
method,
|
|
75
75
|
partition,
|
|
76
76
|
topic,
|
|
77
77
|
heartbeat,
|
package/dist/rpc/kafka/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
Context,
|
|
3
3
|
createControllerMetaMap,
|
|
4
4
|
detectAopDep
|
|
5
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-G5IH3TP7.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__name
|
|
8
8
|
} from "../../chunk-NQ55PA2X.mjs";
|
|
@@ -14,9 +14,9 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
14
14
|
const { globalGuards, globalFilter, globalPipe, globalAddons = [], defaultQueue } = opts;
|
|
15
15
|
const existQueue = /* @__PURE__ */ new Set();
|
|
16
16
|
const metaMap = createControllerMetaMap(meta, (meta2) => {
|
|
17
|
-
const { controller, rpc,
|
|
17
|
+
const { controller, rpc, method, tag } = meta2.data;
|
|
18
18
|
if (controller === "rpc" && rpc?.queue !== void 0) {
|
|
19
|
-
debug(`register method "${
|
|
19
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
@@ -31,8 +31,8 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
31
31
|
async function subscribeQueues() {
|
|
32
32
|
existQueue.clear();
|
|
33
33
|
for (const [tag, record] of metaMap) {
|
|
34
|
-
for (const
|
|
35
|
-
const meta2 = metaMap.get(tag)[
|
|
34
|
+
for (const method in record) {
|
|
35
|
+
const meta2 = metaMap.get(tag)[method];
|
|
36
36
|
const { data: { rpc } } = meta2;
|
|
37
37
|
if (rpc) {
|
|
38
38
|
const queue = rpc.queue || defaultQueue || tag;
|
|
@@ -52,10 +52,10 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
52
52
|
eachMessage: /* @__PURE__ */ __name(async ({ message, partition, topic, heartbeat, pause }) => {
|
|
53
53
|
if (!existQueue.has(topic)) return;
|
|
54
54
|
const data = JSON.parse(message.value.toString());
|
|
55
|
-
const { tag,
|
|
55
|
+
const { tag, method, id, queue: clientQueue, _ps, args } = data;
|
|
56
56
|
if (_ps !== 1) return;
|
|
57
|
-
debug(`invoke method "${
|
|
58
|
-
const meta2 = metaMap.get(tag)[
|
|
57
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
58
|
+
const meta2 = metaMap.get(tag)[method];
|
|
59
59
|
const { data: { rpc } } = meta2;
|
|
60
60
|
const isEvent = rpc.isEvent;
|
|
61
61
|
const aop = Context.getAop(meta2, {
|
|
@@ -71,7 +71,7 @@ async function bind({ consumer, producer }, { moduleMap, meta }, opts = {}) {
|
|
|
71
71
|
args,
|
|
72
72
|
id,
|
|
73
73
|
tag,
|
|
74
|
-
|
|
74
|
+
method,
|
|
75
75
|
partition,
|
|
76
76
|
topic,
|
|
77
77
|
heartbeat,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NatsConnection } from 'nats';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcCtx, a as RpcServerOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-D1YYphEn.mjs';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions } from '../../types-BOZ8yE2L.mjs';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.mjs';
|
|
6
6
|
|
|
7
7
|
interface NatsCtx extends RpcCtx {
|
|
8
8
|
type: 'nats';
|
package/dist/rpc/nats/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NatsConnection } from 'nats';
|
|
2
|
-
import { F as Factory } from '../../core-
|
|
3
|
-
import { R as RpcCtx, a as RpcServerOptions } from '../../types-
|
|
2
|
+
import { F as Factory } from '../../core-BTSHIAyB.js';
|
|
3
|
+
import { R as RpcCtx, a as RpcServerOptions } from '../../types-YJ55P7A_.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
|
-
import '../../meta-
|
|
5
|
+
import '../../meta-DNF6Fl27.js';
|
|
6
6
|
|
|
7
7
|
interface NatsCtx extends RpcCtx {
|
|
8
8
|
type: 'nats';
|
package/dist/rpc/nats/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkLD7YMHIEjs = require('../../chunk-LD7YMHIE.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -17,23 +17,23 @@ 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 =
|
|
21
|
-
const { controller, rpc,
|
|
20
|
+
const metaMap = _chunkLD7YMHIEjs.createControllerMetaMap.call(void 0, meta, (meta2) => {
|
|
21
|
+
const { controller, rpc, method, tag } = meta2.data;
|
|
22
22
|
if (controller === "rpc" && _optionalChain([rpc, 'optionalAccess', _2 => _2.queue]) !== void 0) {
|
|
23
|
-
debug(`register method "${
|
|
23
|
+
debug(`register method "${method}" in module "${tag}"`);
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
_chunkLD7YMHIEjs.detectAopDep.call(void 0, meta, {
|
|
28
28
|
addons: globalAddons,
|
|
29
29
|
guards: globalGuards
|
|
30
30
|
}, "rpc");
|
|
31
|
-
|
|
31
|
+
_chunkLD7YMHIEjs.Context.applyAddons(globalAddons, nc, "nats");
|
|
32
32
|
async function subscribeQueues() {
|
|
33
33
|
existQueue.clear();
|
|
34
34
|
for (const [tag, record] of metaMap) {
|
|
35
|
-
for (const
|
|
36
|
-
const meta2 = metaMap.get(tag)[
|
|
35
|
+
for (const method in record) {
|
|
36
|
+
const meta2 = metaMap.get(tag)[method];
|
|
37
37
|
const { data: { rpc } } = meta2;
|
|
38
38
|
if (rpc) {
|
|
39
39
|
const queue = rpc.queue || defaultQueue || tag;
|
|
@@ -50,24 +50,24 @@ async function bind(nc, { moduleMap, meta }, opts = {}) {
|
|
|
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
|
-
const { tag,
|
|
53
|
+
const { tag, method, id, _ps, args } = data;
|
|
54
54
|
if (_ps !== 1) return;
|
|
55
|
-
debug(`invoke method "${
|
|
56
|
-
const meta2 = metaMap.get(tag)[
|
|
55
|
+
debug(`invoke method "${method}" in module "${tag}"`);
|
|
56
|
+
const meta2 = metaMap.get(tag)[method];
|
|
57
57
|
const { data: { rpc: { isEvent } = {} } } = meta2;
|
|
58
58
|
if (isEvent) msg.respond("{}");
|
|
59
|
-
const aop =
|
|
59
|
+
const aop = _chunkLD7YMHIEjs.Context.getAop(meta2, {
|
|
60
60
|
globalFilter,
|
|
61
61
|
globalGuards,
|
|
62
62
|
globalPipe
|
|
63
63
|
});
|
|
64
|
-
const context = new (0,
|
|
64
|
+
const context = new (0, _chunkLD7YMHIEjs.Context)({
|
|
65
65
|
type: "nats",
|
|
66
66
|
category: "rpc",
|
|
67
67
|
moduleMap,
|
|
68
68
|
meta: meta2,
|
|
69
69
|
tag,
|
|
70
|
-
|
|
70
|
+
method,
|
|
71
71
|
args,
|
|
72
72
|
id,
|
|
73
73
|
msg,
|