phecda-server 1.0.1 → 1.1.0
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/client/index.d.ts +7 -5
- package/dist/client/index.js +2 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +2 -2
- package/dist/client/index.mjs.map +1 -1
- package/dist/index.d.ts +99 -57
- package/dist/index.js +309 -106
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +299 -106
- package/dist/index.mjs.map +1 -1
- package/dist/{types-6e2842b3.d.ts → types-acc60391.d.ts} +27 -4
- package/package.json +5 -3
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
-
import { R as RequestType,
|
|
2
|
+
import { R as RequestType, c as PRes, b as ResOrErr, a as PError } from '../types-acc60391.js';
|
|
3
|
+
import 'express';
|
|
4
|
+
import 'amqplib';
|
|
3
5
|
|
|
4
6
|
interface RequestArgs {
|
|
5
7
|
body: Record<string, any>;
|
|
@@ -8,9 +10,9 @@ interface RequestArgs {
|
|
|
8
10
|
realParam: string;
|
|
9
11
|
method: RequestType;
|
|
10
12
|
url: string;
|
|
11
|
-
|
|
13
|
+
tag: string;
|
|
12
14
|
}
|
|
13
|
-
type MergedReqArg = Pick<RequestArgs, 'body' | 'query' | 'params' | '
|
|
15
|
+
type MergedReqArg = Pick<RequestArgs, 'body' | 'query' | 'params' | 'tag'>;
|
|
14
16
|
declare function toReq(arg: RequestArgs): {
|
|
15
17
|
method: RequestType;
|
|
16
18
|
url: string;
|
|
@@ -20,8 +22,8 @@ declare function toReq(arg: RequestArgs): {
|
|
|
20
22
|
};
|
|
21
23
|
declare const merge: (...args: RequestArgs[]) => MergedReqArg[];
|
|
22
24
|
type RequestMethod = <F extends (...args: any[]) => any>(fn: F, args: Parameters<F>) => Promise<ReturnType<F>>;
|
|
23
|
-
declare function createReq(instance: AxiosInstance): <R>(arg: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<Awaited<R
|
|
24
|
-
declare function createMergeReq(instance: AxiosInstance, key?: string): <R extends unknown[]>(args: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<ResOrErr<R
|
|
25
|
+
declare function createReq(instance: AxiosInstance): <R>(arg: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<PRes<Awaited<R>>>>;
|
|
26
|
+
declare function createMergeReq(instance: AxiosInstance, key?: string): <R extends unknown[]>(args: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<ResOrErr<PRes<R>>>>;
|
|
25
27
|
declare function isError<T = any>(data: T | PError): data is PError;
|
|
26
28
|
declare function $S(index: number, key?: string): any;
|
|
27
29
|
|
package/dist/client/index.js
CHANGED
|
@@ -48,9 +48,9 @@ __name(toReq, "toReq");
|
|
|
48
48
|
var merge = /* @__PURE__ */ __name((...args) => {
|
|
49
49
|
const ret = [];
|
|
50
50
|
for (const i of args) {
|
|
51
|
-
const { body, query, params,
|
|
51
|
+
const { body, query, params, tag } = i;
|
|
52
52
|
ret.push({
|
|
53
|
-
|
|
53
|
+
tag,
|
|
54
54
|
body,
|
|
55
55
|
query,
|
|
56
56
|
params
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/index.ts","../../src/common.ts"],"sourcesContent":["import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'\nimport type { PError, RequestType, ResOrErr } from '../types'\nimport { SERIES_SYMBOL } from '../common'\ninterface RequestArgs {\n body: Record<string, any>\n query: Record<string, string>\n params: Record<string, string>\n realParam: string\n method: RequestType\n url: string\n
|
|
1
|
+
{"version":3,"sources":["../../src/client/index.ts","../../src/common.ts"],"sourcesContent":["import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'\nimport type { PError, PRes, RequestType, ResOrErr } from '../types'\nimport { SERIES_SYMBOL } from '../common'\ninterface RequestArgs {\n body: Record<string, any>\n query: Record<string, string>\n params: Record<string, string>\n realParam: string\n method: RequestType\n url: string\n tag: string\n}\ntype MergedReqArg = Pick<RequestArgs, 'body' | 'query' | 'params' | 'tag' >\nexport function toReq(arg: RequestArgs) {\n const { body, query, realParam, method, url } = arg\n return { method, url, body, query: Object.keys(query).length > 0 ? `?${Object.entries(query).map(([k, v]) => `${k}=${v}`).join('&')}` : '', params: realParam }\n}\n\nexport const merge = (...args: RequestArgs[]) => {\n const ret = [] as MergedReqArg[]\n for (const i of args) {\n const { body, query, params, tag } = i\n ret.push({ tag, body, query, params })\n }\n\n return ret\n}\n\nexport type RequestMethod = <F extends (...args: any[]) => any >(fn: F, args: Parameters<F>) => Promise<ReturnType<F>>\n\nexport function createReq(instance: AxiosInstance): <R>(arg: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<PRes<Awaited<R>>> > {\n // @ts-expect-error methods without route decorator won't send request\n return (arg: any, config?: AxiosRequestConfig) => {\n const { url, params, query, body, method } = toReq(arg as RequestArgs)\n if (!method) {\n console.warn('methods without route decorator won\\'t send request')\n return\n }\n\n const ret = [`${url}${params}${query}`] as any[]\n body && ret.push(body)\n config && ret.push(config)\n // @ts-expect-error misdirction\n return instance[method](...ret)\n }\n}\n\nexport function createMergeReq(instance: AxiosInstance, key = '/__PHECDA_SERVER__'): < R extends unknown[]>(args: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<ResOrErr<PRes<R>>>> {\n // @ts-expect-error misdirction\n return (args: RequestArgs[], config?: AxiosRequestConfig) => {\n return instance.post(key, merge(...args), config)\n }\n}\n\nexport function isError<T = any>(data: T | PError): data is PError {\n return typeof data === 'object' && (data as any).error\n}\n\nexport function $S(index: number, key = ''): any {\n return `${SERIES_SYMBOL}@${index}@${key}`\n}\n","export const SERIES_SYMBOL = '__symbol_series__'\nexport const REQ_SYMBOL = '__symbol_req__'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA;;;;;;;;;;;;ACFO,IAAMA,gBAAgB;;;ADatB,SAASC,MAAMC,KAAkB;AACtC,QAAM,EAAEC,MAAMC,OAAOC,WAAWC,QAAQC,IAAG,IAAKL;AAChD,SAAO;IAAEI;IAAQC;IAAKJ;IAAMC,OAAOI,OAAOC,KAAKL,KAAAA,EAAOM,SAAS,IAAI,IAAIF,OAAOG,QAAQP,KAAAA,EAAOQ,IAAI,CAAC,CAACC,GAAGC,CAAAA,MAAO,GAAGD,KAAKC,GAAG,EAAEC,KAAK,GAAA,MAAS;IAAIC,QAAQX;EAAU;AAChK;AAHgBJ;AAKT,IAAMgB,QAAQ,2BAAIC,SAAwB;AAC/C,QAAMC,MAAM,CAAA;AACZ,aAAWC,KAAKF,MAAM;AACpB,UAAM,EAAEf,MAAMC,OAAOY,QAAQK,IAAG,IAAKD;AACrCD,QAAIG,KAAK;MAAED;MAAKlB;MAAMC;MAAOY;IAAO,CAAA;EACtC;AAEA,SAAOG;AACT,GARqB;AAYd,SAASI,UAAUC,UAAgH;AAExI,SAAO,CAACtB,KAAUuB,WAAgC;AAChD,UAAM,EAAElB,KAAKS,QAAQZ,OAAOD,MAAMG,OAAM,IAAKL,MAAMC,GAAAA;AACnD,QAAI,CAACI,QAAQ;AACXoB,cAAQC,KAAK,oDAAA;AACb;IACF;AAEA,UAAMR,MAAM;MAAC,GAAGZ,MAAMS,SAASZ;;AAC/BD,YAAQgB,IAAIG,KAAKnB,IAAAA;AACjBsB,cAAUN,IAAIG,KAAKG,MAAAA;AAEnB,WAAOD,SAASlB,QAAO,GAAIa,GAAAA;EAC7B;AACF;AAfgBI;AAiBT,SAASK,eAAeJ,UAAyBK,MAAM,sBAAiI;AAE7L,SAAO,CAACX,MAAqBO,WAAgC;AAC3D,WAAOD,SAASM,KAAKD,KAAKZ,MAAAA,GAASC,IAAAA,GAAOO,MAAAA;EAC5C;AACF;AALgBG;AAOT,SAASG,QAAiBC,MAAkC;AACjE,SAAO,OAAOA,SAAS,YAAaA,KAAaC;AACnD;AAFgBF;AAIT,SAASG,GAAGC,OAAeN,MAAM,IAAS;AAC/C,SAAO,GAAGO,iBAAiBD,SAASN;AACtC;AAFgBK;","names":["SERIES_SYMBOL","toReq","arg","body","query","realParam","method","url","Object","keys","length","entries","map","k","v","join","params","merge","args","ret","i","tag","push","createReq","instance","config","console","warn","createMergeReq","key","post","isError","data","error","$S","index","SERIES_SYMBOL"]}
|
package/dist/client/index.mjs
CHANGED
|
@@ -19,9 +19,9 @@ __name(toReq, "toReq");
|
|
|
19
19
|
var merge = /* @__PURE__ */ __name((...args) => {
|
|
20
20
|
const ret = [];
|
|
21
21
|
for (const i of args) {
|
|
22
|
-
const { body, query, params,
|
|
22
|
+
const { body, query, params, tag } = i;
|
|
23
23
|
ret.push({
|
|
24
|
-
|
|
24
|
+
tag,
|
|
25
25
|
body,
|
|
26
26
|
query,
|
|
27
27
|
params
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/common.ts","../../src/client/index.ts"],"sourcesContent":["export const SERIES_SYMBOL = '__symbol_series__'\nexport const REQ_SYMBOL = '__symbol_req__'\n","import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'\nimport type { PError, RequestType, ResOrErr } from '../types'\nimport { SERIES_SYMBOL } from '../common'\ninterface RequestArgs {\n body: Record<string, any>\n query: Record<string, string>\n params: Record<string, string>\n realParam: string\n method: RequestType\n url: string\n
|
|
1
|
+
{"version":3,"sources":["../../src/common.ts","../../src/client/index.ts"],"sourcesContent":["export const SERIES_SYMBOL = '__symbol_series__'\nexport const REQ_SYMBOL = '__symbol_req__'\n","import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'\nimport type { PError, PRes, RequestType, ResOrErr } from '../types'\nimport { SERIES_SYMBOL } from '../common'\ninterface RequestArgs {\n body: Record<string, any>\n query: Record<string, string>\n params: Record<string, string>\n realParam: string\n method: RequestType\n url: string\n tag: string\n}\ntype MergedReqArg = Pick<RequestArgs, 'body' | 'query' | 'params' | 'tag' >\nexport function toReq(arg: RequestArgs) {\n const { body, query, realParam, method, url } = arg\n return { method, url, body, query: Object.keys(query).length > 0 ? `?${Object.entries(query).map(([k, v]) => `${k}=${v}`).join('&')}` : '', params: realParam }\n}\n\nexport const merge = (...args: RequestArgs[]) => {\n const ret = [] as MergedReqArg[]\n for (const i of args) {\n const { body, query, params, tag } = i\n ret.push({ tag, body, query, params })\n }\n\n return ret\n}\n\nexport type RequestMethod = <F extends (...args: any[]) => any >(fn: F, args: Parameters<F>) => Promise<ReturnType<F>>\n\nexport function createReq(instance: AxiosInstance): <R>(arg: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<PRes<Awaited<R>>> > {\n // @ts-expect-error methods without route decorator won't send request\n return (arg: any, config?: AxiosRequestConfig) => {\n const { url, params, query, body, method } = toReq(arg as RequestArgs)\n if (!method) {\n console.warn('methods without route decorator won\\'t send request')\n return\n }\n\n const ret = [`${url}${params}${query}`] as any[]\n body && ret.push(body)\n config && ret.push(config)\n // @ts-expect-error misdirction\n return instance[method](...ret)\n }\n}\n\nexport function createMergeReq(instance: AxiosInstance, key = '/__PHECDA_SERVER__'): < R extends unknown[]>(args: R, config?: AxiosRequestConfig) => Promise<AxiosResponse<ResOrErr<PRes<R>>>> {\n // @ts-expect-error misdirction\n return (args: RequestArgs[], config?: AxiosRequestConfig) => {\n return instance.post(key, merge(...args), config)\n }\n}\n\nexport function isError<T = any>(data: T | PError): data is PError {\n return typeof data === 'object' && (data as any).error\n}\n\nexport function $S(index: number, key = ''): any {\n return `${SERIES_SYMBOL}@${index}@${key}`\n}\n"],"mappings":";;;;AAAO,IAAMA,gBAAgB;;;ACatB,SAASC,MAAMC,KAAkB;AACtC,QAAM,EAAEC,MAAMC,OAAOC,WAAWC,QAAQC,IAAG,IAAKL;AAChD,SAAO;IAAEI;IAAQC;IAAKJ;IAAMC,OAAOI,OAAOC,KAAKL,KAAAA,EAAOM,SAAS,IAAI,IAAIF,OAAOG,QAAQP,KAAAA,EAAOQ,IAAI,CAAC,CAACC,GAAGC,CAAAA,MAAO,GAAGD,KAAKC,GAAG,EAAEC,KAAK,GAAA,MAAS;IAAIC,QAAQX;EAAU;AAChK;AAHgBJ;AAKT,IAAMgB,QAAQ,2BAAIC,SAAwB;AAC/C,QAAMC,MAAM,CAAA;AACZ,aAAWC,KAAKF,MAAM;AACpB,UAAM,EAAEf,MAAMC,OAAOY,QAAQK,IAAG,IAAKD;AACrCD,QAAIG,KAAK;MAAED;MAAKlB;MAAMC;MAAOY;IAAO,CAAA;EACtC;AAEA,SAAOG;AACT,GARqB;AAYd,SAASI,UAAUC,UAAgH;AAExI,SAAO,CAACtB,KAAUuB,WAAgC;AAChD,UAAM,EAAElB,KAAKS,QAAQZ,OAAOD,MAAMG,OAAM,IAAKL,MAAMC,GAAAA;AACnD,QAAI,CAACI,QAAQ;AACXoB,cAAQC,KAAK,oDAAA;AACb;IACF;AAEA,UAAMR,MAAM;MAAC,GAAGZ,MAAMS,SAASZ;;AAC/BD,YAAQgB,IAAIG,KAAKnB,IAAAA;AACjBsB,cAAUN,IAAIG,KAAKG,MAAAA;AAEnB,WAAOD,SAASlB,QAAO,GAAIa,GAAAA;EAC7B;AACF;AAfgBI;AAiBT,SAASK,eAAeJ,UAAyBK,MAAM,sBAAiI;AAE7L,SAAO,CAACX,MAAqBO,WAAgC;AAC3D,WAAOD,SAASM,KAAKD,KAAKZ,MAAAA,GAASC,IAAAA,GAAOO,MAAAA;EAC5C;AACF;AALgBG;AAOT,SAASG,QAAiBC,MAAkC;AACjE,SAAO,OAAOA,SAAS,YAAaA,KAAaC;AACnD;AAFgBF;AAIT,SAASG,GAAGC,OAAeN,MAAM,IAAS;AAC/C,SAAO,GAAGO,iBAAiBD,SAASN;AACtC;AAFgBK;","names":["SERIES_SYMBOL","toReq","arg","body","query","realParam","method","url","Object","keys","length","entries","map","k","v","join","params","merge","args","ret","i","tag","push","createReq","instance","config","console","warn","createMergeReq","key","post","isError","data","error","$S","index","SERIES_SYMBOL"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,48 @@
|
|
|
1
|
-
import { S as ServerMeta, R as RequestType, C as Construct } from './types-
|
|
2
|
-
export { M as MergeType,
|
|
1
|
+
import { S as ServerMeta, P as PHandler, R as RequestType, C as Construct } from './types-acc60391.js';
|
|
2
|
+
export { B as BaseError, M as MergeType, e as MqContextData, a as PError, c as PRes, b as ResOrErr, d as ServerContextData, T as Transform, U as UnWrap } from './types-acc60391.js';
|
|
3
3
|
import { Express } from 'express';
|
|
4
4
|
import { PluginOption } from 'vite';
|
|
5
|
+
export * from 'phecda-core';
|
|
6
|
+
import amqplib from 'amqplib';
|
|
7
|
+
|
|
8
|
+
interface ValidatePipe {
|
|
9
|
+
transform(args: {
|
|
10
|
+
arg: any;
|
|
11
|
+
validate?: boolean;
|
|
12
|
+
}[], reflect: any[]): Promise<any[]>;
|
|
13
|
+
}
|
|
14
|
+
declare const defaultPipe: ValidatePipe;
|
|
15
|
+
|
|
16
|
+
declare class HttpException extends Error {
|
|
17
|
+
message: string;
|
|
18
|
+
status: number;
|
|
19
|
+
description: string;
|
|
20
|
+
constructor(message: string, status: number, description?: string);
|
|
21
|
+
get data(): {
|
|
22
|
+
message: string;
|
|
23
|
+
description: string;
|
|
24
|
+
status: number;
|
|
25
|
+
error: boolean;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare class UndefinedException extends HttpException {
|
|
30
|
+
constructor(message: string);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare class ValidateException extends HttpException {
|
|
34
|
+
constructor(message: string);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare class ForbiddenException extends HttpException {
|
|
38
|
+
constructor(message: string);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare class BadRequestException extends HttpException {
|
|
42
|
+
constructor(message: string);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type ErrorFilter<E extends HttpException = any> = (err: E | Error, contextData: any) => any;
|
|
5
46
|
|
|
6
47
|
declare class Phistroy {
|
|
7
48
|
guard: string[];
|
|
@@ -11,45 +52,33 @@ declare class Phistroy {
|
|
|
11
52
|
|
|
12
53
|
declare class Pmeta {
|
|
13
54
|
data: ServerMeta;
|
|
55
|
+
handlers: PHandler[];
|
|
14
56
|
reflect: any[];
|
|
15
|
-
constructor(data: ServerMeta, reflect: any[]);
|
|
57
|
+
constructor(data: ServerMeta, handlers: PHandler[], reflect: any[]);
|
|
16
58
|
}
|
|
17
59
|
|
|
18
|
-
|
|
19
|
-
transform(args: {
|
|
20
|
-
arg: any;
|
|
21
|
-
validate?: boolean;
|
|
22
|
-
}[], reflect: any[]): Promise<any[]>;
|
|
23
|
-
}
|
|
24
|
-
declare const defaultPipe: Ppipe;
|
|
25
|
-
|
|
26
|
-
declare class Pcontext {
|
|
60
|
+
declare abstract class Pcontext {
|
|
27
61
|
key: string;
|
|
28
|
-
|
|
62
|
+
data: any;
|
|
29
63
|
method: string;
|
|
30
64
|
params: string[];
|
|
31
|
-
static
|
|
32
|
-
static
|
|
65
|
+
static metaRecord: Record<string, Pmeta>;
|
|
66
|
+
static metaDataRecord: Record<string, ReturnType<typeof parseMeta>>;
|
|
67
|
+
static instanceRecord: Record<string, any>;
|
|
33
68
|
static guardsRecord: Record<string, (req: any, isMerge: boolean) => boolean>;
|
|
34
|
-
static middlewareRecord: Record<string, (...params: any) => boolean>;
|
|
35
69
|
static interceptorsRecord: Record<string, (req: any, isMerge: boolean) => any>;
|
|
36
70
|
post: ((...params: any) => any)[];
|
|
37
71
|
history: Phistroy;
|
|
38
|
-
constructor(key: string,
|
|
72
|
+
constructor(key: string, data: any);
|
|
39
73
|
static registerGuard(key: string, handler: any): void;
|
|
40
74
|
static registerInterceptor(key: string, handler: any): void;
|
|
41
|
-
static useMiddleware(middlewares: string[]): ((...params: any) => boolean)[];
|
|
42
75
|
useGuard(guards: string[], isMerge?: boolean): Promise<void>;
|
|
43
76
|
useInterceptor(interceptors: string[], isMerge?: boolean): Promise<void>;
|
|
44
77
|
usePost(data: any): Promise<any>;
|
|
45
|
-
usePipe(args: {
|
|
46
|
-
arg: any;
|
|
47
|
-
validate?: boolean;
|
|
48
|
-
}[], reflect: any[]): Promise<any[]>;
|
|
49
78
|
}
|
|
50
|
-
declare function addGuard(key: string, handler: (
|
|
51
|
-
declare function addInterceptor(key: string, handler: (
|
|
52
|
-
declare function
|
|
79
|
+
declare function addGuard(key: string, handler: (contextData: any, isMerge: boolean) => boolean): void;
|
|
80
|
+
declare function addInterceptor(key: string, handler: (contextData: any, isMerge: boolean) => any): void;
|
|
81
|
+
declare function getInstance(tag: string): any;
|
|
53
82
|
declare function parseMeta(meta: Pmeta): {
|
|
54
83
|
guards: string[];
|
|
55
84
|
reflect: any[];
|
|
@@ -62,6 +91,34 @@ declare function parseMeta(meta: Pmeta): {
|
|
|
62
91
|
}[];
|
|
63
92
|
};
|
|
64
93
|
|
|
94
|
+
declare class ServerContext extends Pcontext {
|
|
95
|
+
static pipe: ValidatePipe;
|
|
96
|
+
static filter: ErrorFilter<any>;
|
|
97
|
+
static middlewareRecord: Record<string, (...params: any) => boolean>;
|
|
98
|
+
static useMiddleware(middlewares: string[]): ((...params: any) => boolean)[];
|
|
99
|
+
usePipe(args: {
|
|
100
|
+
arg: any;
|
|
101
|
+
validate?: boolean;
|
|
102
|
+
}[], reflect: any[]): Promise<any[]>;
|
|
103
|
+
useFilter(arg: any): any;
|
|
104
|
+
}
|
|
105
|
+
declare function useServerPipe(pipe: ValidatePipe): void;
|
|
106
|
+
declare function useServerFilter(filter: ErrorFilter): void;
|
|
107
|
+
|
|
108
|
+
declare class RabbitMqContext extends Pcontext {
|
|
109
|
+
static pipe: ValidatePipe;
|
|
110
|
+
static filter: ErrorFilter<any>;
|
|
111
|
+
static middlewareRecord: Record<string, (...params: any) => boolean>;
|
|
112
|
+
static useMiddleware(middlewares: string[]): ((...params: any) => boolean)[];
|
|
113
|
+
usePipe(args: {
|
|
114
|
+
arg: any;
|
|
115
|
+
validate?: boolean;
|
|
116
|
+
}[], reflect: any[]): Promise<any[]>;
|
|
117
|
+
useFilter(arg: any): any;
|
|
118
|
+
}
|
|
119
|
+
declare function useMqPipe(pipe: ValidatePipe): void;
|
|
120
|
+
declare function useMqFilter(filter: ErrorFilter): void;
|
|
121
|
+
|
|
65
122
|
declare class Pcompiler {
|
|
66
123
|
content: string;
|
|
67
124
|
classMap: Record<string, {
|
|
@@ -74,6 +131,11 @@ declare class Pcompiler {
|
|
|
74
131
|
key: string;
|
|
75
132
|
index: number;
|
|
76
133
|
}[]): void;
|
|
134
|
+
addMqMethod(className: string, methodName: string, exchange?: string, routeKey?: string, queue?: string, params?: {
|
|
135
|
+
type: string;
|
|
136
|
+
key: string;
|
|
137
|
+
index: number;
|
|
138
|
+
}[]): void;
|
|
77
139
|
}
|
|
78
140
|
|
|
79
141
|
interface Options {
|
|
@@ -87,10 +149,10 @@ declare function bindApp(app: Express, { meta, moduleMap }: {
|
|
|
87
149
|
moduleMap: any;
|
|
88
150
|
}, options?: Options): void;
|
|
89
151
|
|
|
90
|
-
declare function Factory<T>(Modules: Construct<T>[]): {
|
|
152
|
+
declare function Factory<T>(Modules: Construct<T>[]): Promise<{
|
|
91
153
|
moduleMap: Map<string, any>;
|
|
92
154
|
meta: Pmeta[];
|
|
93
|
-
}
|
|
155
|
+
}>;
|
|
94
156
|
|
|
95
157
|
declare function BaseParam(type: string, key: string, validate?: boolean): any;
|
|
96
158
|
declare function Body(key?: string, validate?: boolean): any;
|
|
@@ -106,38 +168,18 @@ declare function Controller(route: string): any;
|
|
|
106
168
|
declare function Guard(guardKey: string): any;
|
|
107
169
|
declare function Interceptor(interceptorKey: string): any;
|
|
108
170
|
|
|
109
|
-
declare function
|
|
171
|
+
declare function MQ(queue: string, routeKey: string, options?: amqplib.Options.Consume): (target: any, k: PropertyKey) => void;
|
|
172
|
+
|
|
173
|
+
declare function Inject(_target: any): void;
|
|
110
174
|
declare function Header(name: string, value: string): (target: any, k: PropertyKey) => void;
|
|
111
175
|
|
|
112
176
|
declare function Server(localPath: string): PluginOption;
|
|
113
177
|
|
|
114
|
-
declare
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
message: string;
|
|
121
|
-
description: string;
|
|
122
|
-
status: number;
|
|
123
|
-
error: boolean;
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
declare class UndefinedException extends HttpException {
|
|
128
|
-
constructor(message: string);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
declare class ValidateException extends HttpException {
|
|
132
|
-
constructor(message: string);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
declare class ForbiddenException extends HttpException {
|
|
136
|
-
constructor(message: string);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
declare class BadRequestException extends HttpException {
|
|
140
|
-
constructor(message: string);
|
|
141
|
-
}
|
|
178
|
+
declare function bindMQ(ch: amqplib.Channel, { meta, moduleMap }: {
|
|
179
|
+
meta: Pmeta[];
|
|
180
|
+
moduleMap: any;
|
|
181
|
+
}): Promise<void>;
|
|
182
|
+
type MqMethod<T> = (arg: T) => void;
|
|
183
|
+
declare function createPub<T extends (...args: any[]) => any>(ch: amqplib.Channel, method: T, type?: string): Promise<MqMethod<Parameters<T>>>;
|
|
142
184
|
|
|
143
|
-
export { BadRequestException, BaseParam, Body, Construct, Controller, Delete, Factory, ForbiddenException, Get, Guard, Header, HttpException, Inject, Interceptor, Options, Param, Pcompiler, Pcontext, Pmeta, Post,
|
|
185
|
+
export { BadRequestException, BaseParam, Body, Construct, Controller, Delete, Factory, ForbiddenException, Get, Guard, Header, HttpException, Inject, Interceptor, MQ, Options, PHandler, Param, Pcompiler, Pcontext, Pmeta, Post, Put, Query, RabbitMqContext, RequestType, Route, Server, ServerContext, ServerMeta, UndefinedException, ValidateException, ValidatePipe, addGuard, addInterceptor, bindApp, bindMQ, createPub, defaultPipe, getInstance, parseMeta, useMqFilter, useMqPipe, useServerFilter, useServerPipe };
|