phecda-server 5.0.0-beta.23 → 5.0.0-beta.25
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-MUTWLASF.mjs → chunk-5SGIQCRQ.mjs} +10 -3
- package/dist/{chunk-BZFD4POH.js → chunk-CGZDB67F.js} +10 -3
- package/dist/chunk-FJN6EM6U.js +15 -0
- package/dist/chunk-H2R7D4JG.mjs +15 -0
- package/dist/{chunk-MVLQQG2M.js → chunk-LBYIXY22.js} +5 -7
- package/dist/chunk-QEMKN5MI.js +13 -0
- package/dist/{chunk-TTMMVS24.mjs → chunk-WGVYHYYO.mjs} +6 -8
- package/dist/chunk-WUQB4ETW.mjs +13 -0
- package/dist/{core-510d1263.d.ts → core-b5a99f34.d.ts} +4 -3
- package/dist/helper-705abda7.d.ts +12 -0
- package/dist/helper-fcb2f1d7.d.ts +7 -0
- package/dist/index.d.ts +15 -10
- package/dist/index.js +32 -31
- package/dist/index.mjs +14 -13
- package/dist/rpc/kafka/index.d.ts +8 -9
- package/dist/rpc/kafka/index.js +107 -83
- package/dist/rpc/kafka/index.mjs +108 -84
- package/dist/rpc/rabbitmq/index.d.ts +7 -8
- package/dist/rpc/rabbitmq/index.js +148 -106
- package/dist/rpc/rabbitmq/index.mjs +150 -108
- package/dist/rpc/redis/index.d.ts +7 -8
- package/dist/rpc/redis/index.js +112 -65
- package/dist/rpc/redis/index.mjs +113 -66
- package/dist/server/express/index.d.ts +4 -9
- package/dist/server/express/index.js +49 -38
- package/dist/server/express/index.mjs +44 -33
- package/dist/server/fastify/index.d.ts +4 -9
- package/dist/server/fastify/index.js +48 -37
- package/dist/server/fastify/index.mjs +43 -32
- package/dist/server/h3/index.d.ts +4 -4
- package/dist/server/h3/index.js +48 -37
- package/dist/server/h3/index.mjs +43 -32
- package/dist/server/hyper-express/index.d.ts +4 -9
- package/dist/server/hyper-express/index.js +47 -36
- package/dist/server/hyper-express/index.mjs +42 -31
- package/dist/server/koa/index.d.ts +4 -9
- package/dist/server/koa/index.js +50 -39
- package/dist/server/koa/index.mjs +45 -34
- package/dist/test.d.ts +1 -1
- package/dist/test.js +2 -2
- package/dist/test.mjs +1 -1
- package/package.json +6 -2
- package/register/loader.mjs +27 -1
|
@@ -321,7 +321,7 @@ function addInterceptor(key, handler) {
|
|
|
321
321
|
Context.interceptorRecord[key] = handler;
|
|
322
322
|
}
|
|
323
323
|
__name(addInterceptor, "addInterceptor");
|
|
324
|
-
function
|
|
324
|
+
function detectAopDep(meta, { guards, interceptors, plugins } = {}) {
|
|
325
325
|
const pluginSet = new Set(plugins);
|
|
326
326
|
const guardSet = new Set(guards);
|
|
327
327
|
const interceptorSet = new Set(interceptors);
|
|
@@ -363,8 +363,15 @@ function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
|
|
|
363
363
|
log(`${pc.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
|
|
364
364
|
if (missFilters.length)
|
|
365
365
|
log(`${pc.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
|
|
366
|
+
return {
|
|
367
|
+
missPlugins,
|
|
368
|
+
missGuards,
|
|
369
|
+
missInterceptors,
|
|
370
|
+
missPipes,
|
|
371
|
+
missFilters
|
|
372
|
+
};
|
|
366
373
|
}
|
|
367
|
-
__name(
|
|
374
|
+
__name(detectAopDep, "detectAopDep");
|
|
368
375
|
|
|
369
376
|
export {
|
|
370
377
|
Exception,
|
|
@@ -389,5 +396,5 @@ export {
|
|
|
389
396
|
addFilter,
|
|
390
397
|
addGuard,
|
|
391
398
|
addInterceptor,
|
|
392
|
-
|
|
399
|
+
detectAopDep
|
|
393
400
|
};
|
|
@@ -321,7 +321,7 @@ function addInterceptor(key, handler) {
|
|
|
321
321
|
Context.interceptorRecord[key] = handler;
|
|
322
322
|
}
|
|
323
323
|
_chunkPC6CFB6Sjs.__name.call(void 0, addInterceptor, "addInterceptor");
|
|
324
|
-
function
|
|
324
|
+
function detectAopDep(meta, { guards, interceptors, plugins } = {}) {
|
|
325
325
|
const pluginSet = new Set(plugins);
|
|
326
326
|
const guardSet = new Set(guards);
|
|
327
327
|
const interceptorSet = new Set(interceptors);
|
|
@@ -363,8 +363,15 @@ function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
|
|
|
363
363
|
_chunkPC6CFB6Sjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
|
|
364
364
|
if (missFilters.length)
|
|
365
365
|
_chunkPC6CFB6Sjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
|
|
366
|
+
return {
|
|
367
|
+
missPlugins,
|
|
368
|
+
missGuards,
|
|
369
|
+
missInterceptors,
|
|
370
|
+
missPipes,
|
|
371
|
+
missFilters
|
|
372
|
+
};
|
|
366
373
|
}
|
|
367
|
-
_chunkPC6CFB6Sjs.__name.call(void 0,
|
|
374
|
+
_chunkPC6CFB6Sjs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
368
375
|
|
|
369
376
|
|
|
370
377
|
|
|
@@ -390,4 +397,4 @@ _chunkPC6CFB6Sjs.__name.call(void 0, isAopDepInject, "isAopDepInject");
|
|
|
390
397
|
|
|
391
398
|
|
|
392
399
|
|
|
393
|
-
exports.Exception = Exception; exports.ValidateException = ValidateException; exports.defaultPipe = defaultPipe; exports.UndefinedException = UndefinedException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.Context = Context; exports.addPlugin = addPlugin; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addInterceptor = addInterceptor; exports.
|
|
400
|
+
exports.Exception = Exception; exports.ValidateException = ValidateException; exports.defaultPipe = defaultPipe; exports.UndefinedException = UndefinedException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.Context = Context; exports.addPlugin = addPlugin; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addInterceptor = addInterceptor; exports.detectAopDep = detectAopDep;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkPC6CFB6Sjs = require('./chunk-PC6CFB6S.js');
|
|
5
|
+
|
|
6
|
+
// src/hmr.ts
|
|
7
|
+
function HMR(cb) {
|
|
8
|
+
if (_chunkPC6CFB6Sjs.IS_DEV)
|
|
9
|
+
_optionalChain([globalThis, 'access', _ => _.__PS_HMR__, 'optionalAccess', _2 => _2.push, 'call', _3 => _3(cb)]);
|
|
10
|
+
}
|
|
11
|
+
_chunkPC6CFB6Sjs.__name.call(void 0, HMR, "HMR");
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.HMR = HMR;
|
|
@@ -32,15 +32,13 @@ var Compiler = /* @__PURE__ */ _chunkPC6CFB6Sjs.__name.call(void 0, (_class =cl
|
|
|
32
32
|
}
|
|
33
33
|
addMethod(args) {
|
|
34
34
|
const { rpc, name, method, tag } = args;
|
|
35
|
-
if (!rpc
|
|
35
|
+
if (!rpc)
|
|
36
36
|
return;
|
|
37
37
|
if (!this.classMap[name])
|
|
38
38
|
this.classMap[name] = {};
|
|
39
39
|
this.classMap[name][method] = `
|
|
40
40
|
${method}(){
|
|
41
|
-
return {tag:'${tag}
|
|
42
|
-
return `${p}"${c}",`;
|
|
43
|
-
}, "")}]}
|
|
41
|
+
return {tag:'${tag}',method:"${method}",isEvent:${!!rpc.isEvent},queue:"${rpc.queue || ""}"}
|
|
44
42
|
|
|
45
43
|
}
|
|
46
44
|
`;
|
|
@@ -78,7 +76,7 @@ var Compiler3 = /* @__PURE__ */ _chunkPC6CFB6Sjs.__name.call(void 0, (_class2 =
|
|
|
78
76
|
this.classMap[name] = {};
|
|
79
77
|
this.classMap[name][method] = `
|
|
80
78
|
${method}(...args){
|
|
81
|
-
const ret={tag:"${tag}
|
|
79
|
+
const ret={tag:"${tag}",method:"${method}",body:{},headers:{},query:{},params:{},method:"${http.type}",url:"${url}",args}
|
|
82
80
|
|
|
83
81
|
${params.reduce((p, c, i) => `${p}ret.${c.type}${c.key ? `['${c.key}']` : ""}=args[${i}]
|
|
84
82
|
${c.type === "params" ? `ret.url=ret.url.replace('{{${c.key}}}',args[${i}])` : ""}
|
|
@@ -116,8 +114,8 @@ async function Factory(models, opts = {}) {
|
|
|
116
114
|
const dependenceGraph = /* @__PURE__ */ new Map();
|
|
117
115
|
const isolateSet = /* @__PURE__ */ new Set();
|
|
118
116
|
const { http, rpc } = opts;
|
|
119
|
-
if (!_phecdacore.
|
|
120
|
-
_phecdacore.
|
|
117
|
+
if (!_phecdacore.getInject.call(void 0, "watcher")) {
|
|
118
|
+
_phecdacore.setInject.call(void 0, "watcher", ({ eventName, instance, key, options }) => {
|
|
121
119
|
const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
|
|
122
120
|
if (_optionalChain([options, 'optionalAccess', _2 => _2.once]))
|
|
123
121
|
emitter.once(eventName, fn);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkPC6CFB6Sjs = require('./chunk-PC6CFB6S.js');
|
|
4
|
+
|
|
5
|
+
// src/rpc/helper.ts
|
|
6
|
+
function generateReturnQueue(queue) {
|
|
7
|
+
return `${queue}/return`;
|
|
8
|
+
}
|
|
9
|
+
_chunkPC6CFB6Sjs.__name.call(void 0, generateReturnQueue, "generateReturnQueue");
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.generateReturnQueue = generateReturnQueue;
|
|
@@ -32,15 +32,13 @@ var Compiler = /* @__PURE__ */ __name(class Compiler2 {
|
|
|
32
32
|
}
|
|
33
33
|
addMethod(args) {
|
|
34
34
|
const { rpc, name, method, tag } = args;
|
|
35
|
-
if (!rpc
|
|
35
|
+
if (!rpc)
|
|
36
36
|
return;
|
|
37
37
|
if (!this.classMap[name])
|
|
38
38
|
this.classMap[name] = {};
|
|
39
39
|
this.classMap[name][method] = `
|
|
40
40
|
${method}(){
|
|
41
|
-
return {tag:'${tag}
|
|
42
|
-
return `${p}"${c}",`;
|
|
43
|
-
}, "")}]}
|
|
41
|
+
return {tag:'${tag}',method:"${method}",isEvent:${!!rpc.isEvent},queue:"${rpc.queue || ""}"}
|
|
44
42
|
|
|
45
43
|
}
|
|
46
44
|
`;
|
|
@@ -78,7 +76,7 @@ var Compiler3 = /* @__PURE__ */ __name(class Compiler4 {
|
|
|
78
76
|
this.classMap[name] = {};
|
|
79
77
|
this.classMap[name][method] = `
|
|
80
78
|
${method}(...args){
|
|
81
|
-
const ret={tag:"${tag}
|
|
79
|
+
const ret={tag:"${tag}",method:"${method}",body:{},headers:{},query:{},params:{},method:"${http.type}",url:"${url}",args}
|
|
82
80
|
|
|
83
81
|
${params.reduce((p, c, i) => `${p}ret.${c.type}${c.key ? `['${c.key}']` : ""}=args[${i}]
|
|
84
82
|
${c.type === "params" ? `ret.url=ret.url.replace('{{${c.key}}}',args[${i}])` : ""}
|
|
@@ -100,7 +98,7 @@ __name(generateHTTPCode, "generateHTTPCode");
|
|
|
100
98
|
import "reflect-metadata";
|
|
101
99
|
import fs from "fs";
|
|
102
100
|
import EventEmitter from "node:events";
|
|
103
|
-
import { Empty, SHARE_KEY, get, getExposeKey,
|
|
101
|
+
import { Empty, SHARE_KEY, get, getExposeKey, getInject, getState, getTag, invokeHandler, isPhecda, setInject } from "phecda-core";
|
|
104
102
|
import Debug from "debug";
|
|
105
103
|
function Injectable() {
|
|
106
104
|
return (target) => Empty(target);
|
|
@@ -116,8 +114,8 @@ async function Factory(models, opts = {}) {
|
|
|
116
114
|
const dependenceGraph = /* @__PURE__ */ new Map();
|
|
117
115
|
const isolateSet = /* @__PURE__ */ new Set();
|
|
118
116
|
const { http, rpc } = opts;
|
|
119
|
-
if (!
|
|
120
|
-
|
|
117
|
+
if (!getInject("watcher")) {
|
|
118
|
+
setInject("watcher", ({ eventName, instance, key, options }) => {
|
|
121
119
|
const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
|
|
122
120
|
if (options?.once)
|
|
123
121
|
emitter.once(eventName, fn);
|
|
@@ -19,8 +19,8 @@ interface MetaData {
|
|
|
19
19
|
route: string;
|
|
20
20
|
};
|
|
21
21
|
rpc?: {
|
|
22
|
-
|
|
23
|
-
isEvent
|
|
22
|
+
queue?: string;
|
|
23
|
+
isEvent?: boolean;
|
|
24
24
|
};
|
|
25
25
|
ctx?: string;
|
|
26
26
|
define?: any;
|
|
@@ -38,7 +38,7 @@ interface MetaData {
|
|
|
38
38
|
plugins: string[];
|
|
39
39
|
method: string;
|
|
40
40
|
name: string;
|
|
41
|
-
tag:
|
|
41
|
+
tag: string;
|
|
42
42
|
}
|
|
43
43
|
declare class Meta {
|
|
44
44
|
data: MetaData;
|
|
@@ -53,6 +53,7 @@ declare namespace P {
|
|
|
53
53
|
parallel?: boolean;
|
|
54
54
|
type: string;
|
|
55
55
|
tag: string;
|
|
56
|
+
method: string;
|
|
56
57
|
[key: string]: any;
|
|
57
58
|
}
|
|
58
59
|
interface HttpContext extends BaseContext {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { M as Meta } from './core-b5a99f34.js';
|
|
2
|
+
|
|
3
|
+
declare function resolveDep(ret: any, key: string): any;
|
|
4
|
+
interface ServerOptions {
|
|
5
|
+
route?: string;
|
|
6
|
+
globalGuards?: string[];
|
|
7
|
+
globalInterceptors?: string[];
|
|
8
|
+
plugins?: string[];
|
|
9
|
+
}
|
|
10
|
+
declare function argToReq(params: Meta['data']['params'], args: any[], headers: Record<string, any>): any;
|
|
11
|
+
|
|
12
|
+
export { ServerOptions as S, argToReq as a, resolveDep as r };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { P, M as Meta, U as UNMOUNT_SYMBOL, a as MetaData } from './core-
|
|
2
|
-
export { m as ERROR_SYMBOL, E as Emitter, F as Factory, j as IS_DEV, l as IS_LOG_BAN, k as IS_STRICT, I as Injectable, f as MERGE_SYMBOL, h as META_SYMBOL, g as MODULE_SYMBOL, O as OmitFunction, n as PS_FILE_RE, o as PS_IMPORT_RE, i as PS_SYMBOL, d as PickFunc, c as ToClientFn, b as ToClientInstance, T as ToClientMap, e as emitter } from './core-
|
|
1
|
+
import { P, M as Meta, U as UNMOUNT_SYMBOL, a as MetaData } from './core-b5a99f34.js';
|
|
2
|
+
export { m as ERROR_SYMBOL, E as Emitter, F as Factory, j as IS_DEV, l as IS_LOG_BAN, k as IS_STRICT, I as Injectable, f as MERGE_SYMBOL, h as META_SYMBOL, g as MODULE_SYMBOL, O as OmitFunction, n as PS_FILE_RE, o as PS_IMPORT_RE, i as PS_SYMBOL, d as PickFunc, c as ToClientFn, b as ToClientInstance, T as ToClientMap, e as emitter } from './core-b5a99f34.js';
|
|
3
3
|
import { Construct, AbConstruct } from 'phecda-core';
|
|
4
4
|
export * from 'phecda-core';
|
|
5
|
+
export { R as RpcOptions, g as generateReturnQueue } from './helper-fcb2f1d7.js';
|
|
6
|
+
export { S as ServerOptions, a as argToReq, r as resolveDep } from './helper-705abda7.js';
|
|
5
7
|
import 'node:http';
|
|
6
8
|
|
|
7
9
|
declare class Histroy {
|
|
@@ -122,11 +124,17 @@ declare function addPipe<C extends P.BaseContext>(key: PropertyKey, handler: Pip
|
|
|
122
124
|
declare function addFilter<C extends P.BaseContext>(key: PropertyKey, handler: FilterType<C>): void;
|
|
123
125
|
declare function addGuard<C extends P.BaseContext>(key: PropertyKey, handler: GuardType<C>): void;
|
|
124
126
|
declare function addInterceptor<C extends P.BaseContext>(key: PropertyKey, handler: InterceptorType<C>): void;
|
|
125
|
-
declare function
|
|
127
|
+
declare function detectAopDep(meta: Meta[], { guards, interceptors, plugins }?: {
|
|
126
128
|
guards?: string[];
|
|
127
129
|
interceptors?: string[];
|
|
128
130
|
plugins?: string[];
|
|
129
|
-
}):
|
|
131
|
+
}): {
|
|
132
|
+
missPlugins: string[];
|
|
133
|
+
missGuards: string[];
|
|
134
|
+
missInterceptors: string[];
|
|
135
|
+
missPipes: string[];
|
|
136
|
+
missFilters: string[];
|
|
137
|
+
};
|
|
130
138
|
|
|
131
139
|
declare function BaseParam(type: string, key: string): any;
|
|
132
140
|
declare function Pipe(key?: string, opts?: any): (target: any, k: PropertyKey, index: number) => void;
|
|
@@ -143,8 +151,8 @@ declare function Put(route?: string): any;
|
|
|
143
151
|
declare function Patch(route?: string): any;
|
|
144
152
|
declare function Delete(route?: string): any;
|
|
145
153
|
declare function Controller(route?: string): any;
|
|
146
|
-
declare function Rpc(
|
|
147
|
-
declare function
|
|
154
|
+
declare function Rpc(isEvent?: boolean): (target: any, key?: PropertyKey) => void;
|
|
155
|
+
declare function Queue(queue: string): (target: any, key?: PropertyKey) => void;
|
|
148
156
|
|
|
149
157
|
declare function Guard(...guards: string[]): any;
|
|
150
158
|
declare function Plugin(...plugins: string[]): any;
|
|
@@ -157,9 +165,6 @@ declare function Define(key: string, value: any): (target: any, k?: PropertyKey)
|
|
|
157
165
|
|
|
158
166
|
declare const defaultPipe: PipeType;
|
|
159
167
|
|
|
160
|
-
declare function resolveDep(ret: any, key: string): any;
|
|
161
|
-
declare function argToReq(params: Meta['data']['params'], args: any[], headers: Record<string, any>): any;
|
|
162
|
-
|
|
163
168
|
declare class Dev {
|
|
164
169
|
private readonly [UNMOUNT_SYMBOL];
|
|
165
170
|
protected context: P.BaseContext;
|
|
@@ -232,4 +237,4 @@ declare function getConfig<C = any>(key: string, defaultConf?: C): C;
|
|
|
232
237
|
declare function setConfig<C = any>(key: string, conf: C, force?: boolean): void;
|
|
233
238
|
declare function Mix<C1 extends Construct | AbConstruct, C2 extends Construct>(InternalClass: C1, ExtendClass: C2): new (...args: ConstructorParameters<C2>) => InstanceType<C1> & InstanceType<C2>;
|
|
234
239
|
|
|
235
|
-
export { Arg, BadGatewayException, BadRequestException, BaseParam, Body, ConflictException, Context, Controller, Ctx, Define, Delete, Dev,
|
|
240
|
+
export { Arg, BadGatewayException, BadRequestException, BaseParam, Body, ConflictException, Context, Controller, Ctx, Define, Delete, Dev, Exception, Filter, FilterType, ForbiddenException, FrameworkException, Get, Guard, GuardType, Head, Header, Interceptor, InterceptorType, InvalidInputException, Meta, MetaData, Mix, NotFoundException, P, PExtension, PFilter, PGuard, PInterceptor, PPipe, PPlugin, Param, Patch, PayloadLargeException, Pipe, PipeType, Plugin, Post, Put, Query, Queue, Route, Rpc, ServiceUnavailableException, TimeoutException, UNMOUNT_SYMBOL, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, addFilter, addGuard, addInterceptor, addPipe, addPlugin, defaultPipe, detectAopDep, generateHTTPCode, generateRPCCode, getConfig, log, setConfig };
|
package/dist/index.js
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkLBYIXY22js = require('./chunk-LBYIXY22.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkXCXOCS2Zjs = require('./chunk-XCXOCS2Z.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
var _chunkQEMKN5MIjs = require('./chunk-QEMKN5MI.js');
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
@@ -34,7 +35,9 @@ var _chunkXCXOCS2Zjs = require('./chunk-XCXOCS2Z.js');
|
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
var _chunkCGZDB67Fjs = require('./chunk-CGZDB67F.js');
|
|
38
41
|
|
|
39
42
|
|
|
40
43
|
|
|
@@ -165,7 +168,7 @@ function Controller(route = "") {
|
|
|
165
168
|
return Route(route);
|
|
166
169
|
}
|
|
167
170
|
_chunkPC6CFB6Sjs.__name.call(void 0, Controller, "Controller");
|
|
168
|
-
function Rpc(
|
|
171
|
+
function Rpc(isEvent = false) {
|
|
169
172
|
return (target, key) => {
|
|
170
173
|
if (!key)
|
|
171
174
|
key = _phecdacore.SHARE_KEY;
|
|
@@ -174,25 +177,22 @@ function Rpc(...types) {
|
|
|
174
177
|
const state = _phecdacore.getOwnState.call(void 0, target, key);
|
|
175
178
|
if (!state.rpc)
|
|
176
179
|
state.rpc = {};
|
|
177
|
-
state.rpc.
|
|
180
|
+
state.rpc.isEvent = isEvent;
|
|
178
181
|
_phecdacore.setState.call(void 0, target, key, state);
|
|
179
182
|
};
|
|
180
183
|
}
|
|
181
184
|
_chunkPC6CFB6Sjs.__name.call(void 0, Rpc, "Rpc");
|
|
182
|
-
function
|
|
185
|
+
function Queue(queue) {
|
|
183
186
|
return (target, key) => {
|
|
184
187
|
if (!key)
|
|
185
188
|
key = _phecdacore.SHARE_KEY;
|
|
186
189
|
target = key === _phecdacore.SHARE_KEY ? target.prototype : target;
|
|
187
190
|
_phecdacore.setStateKey.call(void 0, target, key);
|
|
188
191
|
const state = _phecdacore.getOwnState.call(void 0, target, key);
|
|
189
|
-
|
|
190
|
-
state.rpc = {};
|
|
191
|
-
state.rpc.isEvent = isEvent;
|
|
192
|
-
_phecdacore.setState.call(void 0, target, key, state);
|
|
192
|
+
state.rpc.queue = queue;
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
-
_chunkPC6CFB6Sjs.__name.call(void 0,
|
|
195
|
+
_chunkPC6CFB6Sjs.__name.call(void 0, Queue, "Queue");
|
|
196
196
|
|
|
197
197
|
// src/decorators/aop.ts
|
|
198
198
|
|
|
@@ -329,9 +329,9 @@ var PFilter = class extends Dev {
|
|
|
329
329
|
constructor(tag) {
|
|
330
330
|
super();
|
|
331
331
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
332
|
-
|
|
332
|
+
_chunkCGZDB67Fjs.addFilter.call(void 0, this.key, this.use.bind(this));
|
|
333
333
|
this.onUnmount(() => {
|
|
334
|
-
delete
|
|
334
|
+
delete _chunkCGZDB67Fjs.Context.filterRecord[this.key];
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
};
|
|
@@ -344,9 +344,9 @@ var PGuard = class extends Dev {
|
|
|
344
344
|
constructor(tag) {
|
|
345
345
|
super();
|
|
346
346
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
347
|
-
|
|
347
|
+
_chunkCGZDB67Fjs.addGuard.call(void 0, this.key, this.use.bind(this));
|
|
348
348
|
this.onUnmount(() => {
|
|
349
|
-
delete
|
|
349
|
+
delete _chunkCGZDB67Fjs.Context.guardRecord[this.key];
|
|
350
350
|
});
|
|
351
351
|
}
|
|
352
352
|
};
|
|
@@ -360,9 +360,9 @@ var PInterceptor = class extends Dev {
|
|
|
360
360
|
super();
|
|
361
361
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
362
362
|
this.onUnmount(() => {
|
|
363
|
-
delete
|
|
363
|
+
delete _chunkCGZDB67Fjs.Context.interceptorRecord[this.key];
|
|
364
364
|
});
|
|
365
|
-
|
|
365
|
+
_chunkCGZDB67Fjs.addInterceptor.call(void 0, this.key, this.use.bind(this));
|
|
366
366
|
}
|
|
367
367
|
};
|
|
368
368
|
_chunkPC6CFB6Sjs.__name.call(void 0, PInterceptor, "PInterceptor");
|
|
@@ -374,9 +374,9 @@ var PPipe = class extends Dev {
|
|
|
374
374
|
constructor(tag) {
|
|
375
375
|
super();
|
|
376
376
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
377
|
-
|
|
377
|
+
_chunkCGZDB67Fjs.addPipe.call(void 0, this.key, this.use.bind(this));
|
|
378
378
|
this.onUnmount(() => {
|
|
379
|
-
delete
|
|
379
|
+
delete _chunkCGZDB67Fjs.Context.pipeRecord[this.key];
|
|
380
380
|
});
|
|
381
381
|
}
|
|
382
382
|
};
|
|
@@ -389,9 +389,9 @@ var PPlugin = class extends Dev {
|
|
|
389
389
|
constructor(tag) {
|
|
390
390
|
super();
|
|
391
391
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
392
|
-
|
|
392
|
+
_chunkCGZDB67Fjs.addPlugin.call(void 0, this.key, this.use.bind(this));
|
|
393
393
|
this.onUnmount(() => {
|
|
394
|
-
delete
|
|
394
|
+
delete _chunkCGZDB67Fjs.Context.pluginRecord[this.key];
|
|
395
395
|
});
|
|
396
396
|
}
|
|
397
397
|
};
|
|
@@ -405,33 +405,33 @@ var PExtension = class extends Dev {
|
|
|
405
405
|
super();
|
|
406
406
|
const key = this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
407
407
|
if (this.pipe) {
|
|
408
|
-
|
|
408
|
+
_chunkCGZDB67Fjs.addPipe.call(void 0, key, this.pipe.bind(this));
|
|
409
409
|
this.onUnmount(() => {
|
|
410
|
-
delete
|
|
410
|
+
delete _chunkCGZDB67Fjs.Context.pipeRecord[key];
|
|
411
411
|
});
|
|
412
412
|
}
|
|
413
413
|
if (this.plugin) {
|
|
414
|
-
|
|
414
|
+
_chunkCGZDB67Fjs.addPlugin.call(void 0, key, this.plugin.bind(this));
|
|
415
415
|
this.onUnmount(() => {
|
|
416
|
-
delete
|
|
416
|
+
delete _chunkCGZDB67Fjs.Context.pluginRecord[key];
|
|
417
417
|
});
|
|
418
418
|
}
|
|
419
419
|
if (this.intercept) {
|
|
420
|
-
|
|
420
|
+
_chunkCGZDB67Fjs.addInterceptor.call(void 0, key, this.intercept.bind(this));
|
|
421
421
|
this.onUnmount(() => {
|
|
422
|
-
delete
|
|
422
|
+
delete _chunkCGZDB67Fjs.Context.interceptorRecord[key];
|
|
423
423
|
});
|
|
424
424
|
}
|
|
425
425
|
if (this.guard) {
|
|
426
|
-
|
|
426
|
+
_chunkCGZDB67Fjs.addGuard.call(void 0, key, this.guard.bind(this));
|
|
427
427
|
this.onUnmount(() => {
|
|
428
|
-
delete
|
|
428
|
+
delete _chunkCGZDB67Fjs.Context.guardRecord[key];
|
|
429
429
|
});
|
|
430
430
|
}
|
|
431
431
|
if (this.filter) {
|
|
432
|
-
|
|
432
|
+
_chunkCGZDB67Fjs.addFilter.call(void 0, key, this.filter.bind(this));
|
|
433
433
|
this.onUnmount(() => {
|
|
434
|
-
delete
|
|
434
|
+
delete _chunkCGZDB67Fjs.Context.filterRecord[key];
|
|
435
435
|
});
|
|
436
436
|
}
|
|
437
437
|
}
|
|
@@ -514,4 +514,5 @@ _chunkPC6CFB6Sjs.__name.call(void 0, PExtension, "PExtension");
|
|
|
514
514
|
|
|
515
515
|
|
|
516
516
|
|
|
517
|
-
|
|
517
|
+
|
|
518
|
+
exports.Arg = Arg; exports.BadGatewayException = _chunkCGZDB67Fjs.BadGatewayException; exports.BadRequestException = _chunkCGZDB67Fjs.BadRequestException; exports.BaseParam = BaseParam; exports.Body = Body; exports.ConflictException = _chunkCGZDB67Fjs.ConflictException; exports.Context = _chunkCGZDB67Fjs.Context; exports.Controller = Controller; exports.Ctx = Ctx; exports.Define = Define; exports.Delete = Delete; exports.Dev = Dev; exports.ERROR_SYMBOL = _chunkPC6CFB6Sjs.ERROR_SYMBOL; exports.Exception = _chunkCGZDB67Fjs.Exception; exports.Factory = _chunkLBYIXY22js.Factory; exports.Filter = Filter; exports.ForbiddenException = _chunkCGZDB67Fjs.ForbiddenException; exports.FrameworkException = _chunkCGZDB67Fjs.FrameworkException; exports.Get = Get; exports.Guard = Guard; exports.Head = Head; exports.Header = Header; exports.IS_DEV = _chunkPC6CFB6Sjs.IS_DEV; exports.IS_LOG_BAN = _chunkPC6CFB6Sjs.IS_LOG_BAN; exports.IS_STRICT = _chunkPC6CFB6Sjs.IS_STRICT; exports.Injectable = _chunkLBYIXY22js.Injectable; exports.Interceptor = Interceptor; exports.InvalidInputException = _chunkCGZDB67Fjs.InvalidInputException; exports.MERGE_SYMBOL = _chunkPC6CFB6Sjs.MERGE_SYMBOL; exports.META_SYMBOL = _chunkPC6CFB6Sjs.META_SYMBOL; exports.MODULE_SYMBOL = _chunkPC6CFB6Sjs.MODULE_SYMBOL; exports.Meta = _chunkLBYIXY22js.Meta; exports.Mix = _chunkPC6CFB6Sjs.Mix; exports.NotFoundException = _chunkCGZDB67Fjs.NotFoundException; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PPlugin = PPlugin; exports.PS_FILE_RE = _chunkPC6CFB6Sjs.PS_FILE_RE; exports.PS_IMPORT_RE = _chunkPC6CFB6Sjs.PS_IMPORT_RE; exports.PS_SYMBOL = _chunkPC6CFB6Sjs.PS_SYMBOL; exports.Param = Param; exports.Patch = Patch; exports.PayloadLargeException = _chunkCGZDB67Fjs.PayloadLargeException; exports.Pipe = Pipe; exports.Plugin = Plugin; exports.Post = Post; exports.Put = Put; exports.Query = Query; exports.Queue = Queue; exports.Route = Route; exports.Rpc = Rpc; exports.ServiceUnavailableException = _chunkCGZDB67Fjs.ServiceUnavailableException; exports.TimeoutException = _chunkCGZDB67Fjs.TimeoutException; exports.UNMOUNT_SYMBOL = _chunkPC6CFB6Sjs.UNMOUNT_SYMBOL; exports.UnauthorizedException = _chunkCGZDB67Fjs.UnauthorizedException; exports.UndefinedException = _chunkCGZDB67Fjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkCGZDB67Fjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkCGZDB67Fjs.ValidateException; exports.addFilter = _chunkCGZDB67Fjs.addFilter; exports.addGuard = _chunkCGZDB67Fjs.addGuard; exports.addInterceptor = _chunkCGZDB67Fjs.addInterceptor; exports.addPipe = _chunkCGZDB67Fjs.addPipe; exports.addPlugin = _chunkCGZDB67Fjs.addPlugin; exports.argToReq = _chunkXCXOCS2Zjs.argToReq; exports.defaultPipe = _chunkCGZDB67Fjs.defaultPipe; exports.detectAopDep = _chunkCGZDB67Fjs.detectAopDep; exports.emitter = _chunkLBYIXY22js.emitter; exports.generateHTTPCode = _chunkLBYIXY22js.generateHTTPCode; exports.generateRPCCode = _chunkLBYIXY22js.generateRPCCode; exports.generateReturnQueue = _chunkQEMKN5MIjs.generateReturnQueue; exports.getConfig = _chunkPC6CFB6Sjs.getConfig; exports.log = _chunkPC6CFB6Sjs.log; exports.resolveDep = _chunkXCXOCS2Zjs.resolveDep; exports.setConfig = _chunkPC6CFB6Sjs.setConfig;
|
package/dist/index.mjs
CHANGED
|
@@ -5,11 +5,14 @@ import {
|
|
|
5
5
|
emitter,
|
|
6
6
|
generateHTTPCode,
|
|
7
7
|
generateRPCCode
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-WGVYHYYO.mjs";
|
|
9
9
|
import {
|
|
10
10
|
argToReq,
|
|
11
11
|
resolveDep
|
|
12
12
|
} from "./chunk-LISNM5WU.mjs";
|
|
13
|
+
import {
|
|
14
|
+
generateReturnQueue
|
|
15
|
+
} from "./chunk-WUQB4ETW.mjs";
|
|
13
16
|
import {
|
|
14
17
|
BadGatewayException,
|
|
15
18
|
BadRequestException,
|
|
@@ -33,8 +36,8 @@ import {
|
|
|
33
36
|
addPipe,
|
|
34
37
|
addPlugin,
|
|
35
38
|
defaultPipe,
|
|
36
|
-
|
|
37
|
-
} from "./chunk-
|
|
39
|
+
detectAopDep
|
|
40
|
+
} from "./chunk-5SGIQCRQ.mjs";
|
|
38
41
|
import {
|
|
39
42
|
ERROR_SYMBOL,
|
|
40
43
|
IS_DEV,
|
|
@@ -165,7 +168,7 @@ function Controller(route = "") {
|
|
|
165
168
|
return Route(route);
|
|
166
169
|
}
|
|
167
170
|
__name(Controller, "Controller");
|
|
168
|
-
function Rpc(
|
|
171
|
+
function Rpc(isEvent = false) {
|
|
169
172
|
return (target, key) => {
|
|
170
173
|
if (!key)
|
|
171
174
|
key = SHARE_KEY;
|
|
@@ -174,25 +177,22 @@ function Rpc(...types) {
|
|
|
174
177
|
const state = getOwnState2(target, key);
|
|
175
178
|
if (!state.rpc)
|
|
176
179
|
state.rpc = {};
|
|
177
|
-
state.rpc.
|
|
180
|
+
state.rpc.isEvent = isEvent;
|
|
178
181
|
setState2(target, key, state);
|
|
179
182
|
};
|
|
180
183
|
}
|
|
181
184
|
__name(Rpc, "Rpc");
|
|
182
|
-
function
|
|
185
|
+
function Queue(queue) {
|
|
183
186
|
return (target, key) => {
|
|
184
187
|
if (!key)
|
|
185
188
|
key = SHARE_KEY;
|
|
186
189
|
target = key === SHARE_KEY ? target.prototype : target;
|
|
187
190
|
setStateKey2(target, key);
|
|
188
191
|
const state = getOwnState2(target, key);
|
|
189
|
-
|
|
190
|
-
state.rpc = {};
|
|
191
|
-
state.rpc.isEvent = isEvent;
|
|
192
|
-
setState2(target, key, state);
|
|
192
|
+
state.rpc.queue = queue;
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
-
__name(
|
|
195
|
+
__name(Queue, "Queue");
|
|
196
196
|
|
|
197
197
|
// src/decorators/aop.ts
|
|
198
198
|
import { SHARE_KEY as SHARE_KEY2, getOwnState as getOwnState3, setState as setState3, setStateKey as setStateKey3 } from "phecda-core";
|
|
@@ -451,7 +451,6 @@ export {
|
|
|
451
451
|
Delete,
|
|
452
452
|
Dev,
|
|
453
453
|
ERROR_SYMBOL,
|
|
454
|
-
Event,
|
|
455
454
|
Exception,
|
|
456
455
|
Factory,
|
|
457
456
|
Filter,
|
|
@@ -490,6 +489,7 @@ export {
|
|
|
490
489
|
Post,
|
|
491
490
|
Put,
|
|
492
491
|
Query,
|
|
492
|
+
Queue,
|
|
493
493
|
Route,
|
|
494
494
|
Rpc,
|
|
495
495
|
ServiceUnavailableException,
|
|
@@ -506,11 +506,12 @@ export {
|
|
|
506
506
|
addPlugin,
|
|
507
507
|
argToReq,
|
|
508
508
|
defaultPipe,
|
|
509
|
+
detectAopDep,
|
|
509
510
|
emitter,
|
|
510
511
|
generateHTTPCode,
|
|
511
512
|
generateRPCCode,
|
|
513
|
+
generateReturnQueue,
|
|
512
514
|
getConfig,
|
|
513
|
-
isAopDepInject,
|
|
514
515
|
log,
|
|
515
516
|
resolveDep,
|
|
516
517
|
setConfig
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { P, F as Factory, T as ToClientMap } from '../../core-
|
|
1
|
+
import { Consumer, Producer } from 'kafkajs';
|
|
2
|
+
import { P, F as Factory, T as ToClientMap } from '../../core-b5a99f34.js';
|
|
3
|
+
import { R as RpcOptions } from '../../helper-fcb2f1d7.js';
|
|
3
4
|
import 'phecda-core';
|
|
4
5
|
import 'node:http';
|
|
5
6
|
|
|
6
|
-
interface Options {
|
|
7
|
-
globalGuards?: string[];
|
|
8
|
-
globalInterceptors?: string[];
|
|
9
|
-
}
|
|
10
7
|
interface KafkaCtx extends P.BaseContext {
|
|
11
8
|
type: 'kafka';
|
|
12
9
|
topic: string;
|
|
@@ -15,8 +12,10 @@ interface KafkaCtx extends P.BaseContext {
|
|
|
15
12
|
pause(): () => void;
|
|
16
13
|
data: any;
|
|
17
14
|
}
|
|
18
|
-
declare function bind(
|
|
15
|
+
declare function bind(consumer: Consumer, producer: Producer, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: RpcOptions): Promise<void>;
|
|
19
16
|
|
|
20
|
-
declare function createClient<S extends Record<string, any>>(
|
|
17
|
+
declare function createClient<S extends Record<string, any>>(producer: Producer, consumer: Consumer, controllers: S, opts?: {
|
|
18
|
+
timeout?: number;
|
|
19
|
+
}): Promise<ToClientMap<S>>;
|
|
21
20
|
|
|
22
|
-
export { KafkaCtx,
|
|
21
|
+
export { KafkaCtx, bind, createClient };
|