phecda-server 1.0.0 → 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 +10 -7
- package/dist/client/index.js +16 -4
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +13 -4
- package/dist/client/index.mjs.map +1 -1
- package/dist/index.d.ts +128 -59
- package/dist/index.js +488 -126
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +474 -125
- 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;
|
|
@@ -18,10 +20,11 @@ declare function toReq(arg: RequestArgs): {
|
|
|
18
20
|
query: string;
|
|
19
21
|
params: string;
|
|
20
22
|
};
|
|
21
|
-
declare const merge: (...args: RequestArgs[]) =>
|
|
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;
|
|
28
|
+
declare function $S(index: number, key?: string): any;
|
|
26
29
|
|
|
27
|
-
export { RequestMethod, createMergeReq, createReq, isError, merge, toReq };
|
|
30
|
+
export { $S, RequestMethod, createMergeReq, createReq, isError, merge, toReq };
|
package/dist/client/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/client/index.ts
|
|
22
22
|
var client_exports = {};
|
|
23
23
|
__export(client_exports, {
|
|
24
|
+
$S: () => $S,
|
|
24
25
|
createMergeReq: () => createMergeReq,
|
|
25
26
|
createReq: () => createReq,
|
|
26
27
|
isError: () => isError,
|
|
@@ -28,6 +29,11 @@ __export(client_exports, {
|
|
|
28
29
|
toReq: () => toReq
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(client_exports);
|
|
32
|
+
|
|
33
|
+
// src/common.ts
|
|
34
|
+
var SERIES_SYMBOL = "__symbol_series__";
|
|
35
|
+
|
|
36
|
+
// src/client/index.ts
|
|
31
37
|
function toReq(arg) {
|
|
32
38
|
const { body, query, realParam, method, url } = arg;
|
|
33
39
|
return {
|
|
@@ -40,14 +46,15 @@ function toReq(arg) {
|
|
|
40
46
|
}
|
|
41
47
|
__name(toReq, "toReq");
|
|
42
48
|
var merge = /* @__PURE__ */ __name((...args) => {
|
|
43
|
-
const ret =
|
|
49
|
+
const ret = [];
|
|
44
50
|
for (const i of args) {
|
|
45
|
-
const {
|
|
46
|
-
ret
|
|
51
|
+
const { body, query, params, tag } = i;
|
|
52
|
+
ret.push({
|
|
53
|
+
tag,
|
|
47
54
|
body,
|
|
48
55
|
query,
|
|
49
56
|
params
|
|
50
|
-
};
|
|
57
|
+
});
|
|
51
58
|
}
|
|
52
59
|
return ret;
|
|
53
60
|
}, "merge");
|
|
@@ -77,8 +84,13 @@ function isError(data) {
|
|
|
77
84
|
return typeof data === "object" && data.error;
|
|
78
85
|
}
|
|
79
86
|
__name(isError, "isError");
|
|
87
|
+
function $S(index, key = "") {
|
|
88
|
+
return `${SERIES_SYMBOL}@${index}@${key}`;
|
|
89
|
+
}
|
|
90
|
+
__name($S, "$S");
|
|
80
91
|
// Annotate the CommonJS export names for ESM import in node:
|
|
81
92
|
0 && (module.exports = {
|
|
93
|
+
$S,
|
|
82
94
|
createMergeReq,
|
|
83
95
|
createReq,
|
|
84
96
|
isError,
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'\nimport type { PError, RequestType, ResOrErr } from '../types'\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
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
|
+
// src/common.ts
|
|
5
|
+
var SERIES_SYMBOL = "__symbol_series__";
|
|
6
|
+
|
|
4
7
|
// src/client/index.ts
|
|
5
8
|
function toReq(arg) {
|
|
6
9
|
const { body, query, realParam, method, url } = arg;
|
|
@@ -14,14 +17,15 @@ function toReq(arg) {
|
|
|
14
17
|
}
|
|
15
18
|
__name(toReq, "toReq");
|
|
16
19
|
var merge = /* @__PURE__ */ __name((...args) => {
|
|
17
|
-
const ret =
|
|
20
|
+
const ret = [];
|
|
18
21
|
for (const i of args) {
|
|
19
|
-
const {
|
|
20
|
-
ret
|
|
22
|
+
const { body, query, params, tag } = i;
|
|
23
|
+
ret.push({
|
|
24
|
+
tag,
|
|
21
25
|
body,
|
|
22
26
|
query,
|
|
23
27
|
params
|
|
24
|
-
};
|
|
28
|
+
});
|
|
25
29
|
}
|
|
26
30
|
return ret;
|
|
27
31
|
}, "merge");
|
|
@@ -51,7 +55,12 @@ function isError(data) {
|
|
|
51
55
|
return typeof data === "object" && data.error;
|
|
52
56
|
}
|
|
53
57
|
__name(isError, "isError");
|
|
58
|
+
function $S(index, key = "") {
|
|
59
|
+
return `${SERIES_SYMBOL}@${index}@${key}`;
|
|
60
|
+
}
|
|
61
|
+
__name($S, "$S");
|
|
54
62
|
export {
|
|
63
|
+
$S,
|
|
55
64
|
createMergeReq,
|
|
56
65
|
createReq,
|
|
57
66
|
isError,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'\nimport type { PError, RequestType, ResOrErr } from '../types'\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,47 +1,123 @@
|
|
|
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';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
data: ServerMeta;
|
|
8
|
-
reflect: any[];
|
|
9
|
-
constructor(data: ServerMeta, reflect: any[]);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface Ppipe {
|
|
8
|
+
interface ValidatePipe {
|
|
13
9
|
transform(args: {
|
|
14
10
|
arg: any;
|
|
15
11
|
validate?: boolean;
|
|
16
12
|
}[], reflect: any[]): Promise<any[]>;
|
|
17
13
|
}
|
|
18
|
-
declare const defaultPipe:
|
|
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
|
+
}
|
|
19
28
|
|
|
20
|
-
declare class
|
|
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;
|
|
46
|
+
|
|
47
|
+
declare class Phistroy {
|
|
48
|
+
guard: string[];
|
|
49
|
+
interceptor: string[];
|
|
50
|
+
record(name: string, type: 'guard' | 'interceptor'): boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare class Pmeta {
|
|
54
|
+
data: ServerMeta;
|
|
55
|
+
handlers: PHandler[];
|
|
56
|
+
reflect: any[];
|
|
57
|
+
constructor(data: ServerMeta, handlers: PHandler[], reflect: any[]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare abstract class Pcontext {
|
|
21
61
|
key: string;
|
|
22
|
-
|
|
62
|
+
data: any;
|
|
23
63
|
method: string;
|
|
24
64
|
params: string[];
|
|
25
|
-
static
|
|
26
|
-
static
|
|
27
|
-
static
|
|
28
|
-
static
|
|
29
|
-
static
|
|
30
|
-
|
|
65
|
+
static metaRecord: Record<string, Pmeta>;
|
|
66
|
+
static metaDataRecord: Record<string, ReturnType<typeof parseMeta>>;
|
|
67
|
+
static instanceRecord: Record<string, any>;
|
|
68
|
+
static guardsRecord: Record<string, (req: any, isMerge: boolean) => boolean>;
|
|
69
|
+
static interceptorsRecord: Record<string, (req: any, isMerge: boolean) => any>;
|
|
70
|
+
post: ((...params: any) => any)[];
|
|
71
|
+
history: Phistroy;
|
|
72
|
+
constructor(key: string, data: any);
|
|
31
73
|
static registerGuard(key: string, handler: any): void;
|
|
32
74
|
static registerInterceptor(key: string, handler: any): void;
|
|
33
|
-
useGuard(
|
|
34
|
-
useInterceptor(
|
|
35
|
-
usePost(
|
|
75
|
+
useGuard(guards: string[], isMerge?: boolean): Promise<void>;
|
|
76
|
+
useInterceptor(interceptors: string[], isMerge?: boolean): Promise<void>;
|
|
77
|
+
usePost(data: any): Promise<any>;
|
|
78
|
+
}
|
|
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;
|
|
82
|
+
declare function parseMeta(meta: Pmeta): {
|
|
83
|
+
guards: string[];
|
|
84
|
+
reflect: any[];
|
|
85
|
+
interceptors: string[];
|
|
86
|
+
middlewares: string[];
|
|
87
|
+
params: {
|
|
88
|
+
type: string;
|
|
89
|
+
key: string;
|
|
90
|
+
validate: boolean | undefined;
|
|
91
|
+
}[];
|
|
92
|
+
};
|
|
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)[];
|
|
36
113
|
usePipe(args: {
|
|
37
114
|
arg: any;
|
|
38
115
|
validate?: boolean;
|
|
39
116
|
}[], reflect: any[]): Promise<any[]>;
|
|
40
|
-
|
|
117
|
+
useFilter(arg: any): any;
|
|
41
118
|
}
|
|
42
|
-
declare function
|
|
43
|
-
declare function
|
|
44
|
-
declare function usePipe(pipe: Ppipe): void;
|
|
119
|
+
declare function useMqPipe(pipe: ValidatePipe): void;
|
|
120
|
+
declare function useMqFilter(filter: ErrorFilter): void;
|
|
45
121
|
|
|
46
122
|
declare class Pcompiler {
|
|
47
123
|
content: string;
|
|
@@ -55,20 +131,31 @@ declare class Pcompiler {
|
|
|
55
131
|
key: string;
|
|
56
132
|
index: number;
|
|
57
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;
|
|
58
139
|
}
|
|
59
140
|
|
|
141
|
+
interface Options {
|
|
142
|
+
route?: string;
|
|
143
|
+
globalGuards?: string[];
|
|
144
|
+
globalInterceptors?: string[];
|
|
145
|
+
middlewares?: string[];
|
|
146
|
+
}
|
|
60
147
|
declare function bindApp(app: Express, { meta, moduleMap }: {
|
|
61
148
|
meta: Pmeta[];
|
|
62
149
|
moduleMap: any;
|
|
63
|
-
},
|
|
150
|
+
}, options?: Options): void;
|
|
64
151
|
|
|
65
|
-
declare function Factory<T>(Modules: Construct<T>[]): {
|
|
152
|
+
declare function Factory<T>(Modules: Construct<T>[]): Promise<{
|
|
66
153
|
moduleMap: Map<string, any>;
|
|
67
154
|
meta: Pmeta[];
|
|
68
|
-
}
|
|
155
|
+
}>;
|
|
69
156
|
|
|
70
157
|
declare function BaseParam(type: string, key: string, validate?: boolean): any;
|
|
71
|
-
declare function Body(key
|
|
158
|
+
declare function Body(key?: string, validate?: boolean): any;
|
|
72
159
|
declare function Query(key: string, validate?: boolean): any;
|
|
73
160
|
declare function Param(key: string, validate?: boolean): any;
|
|
74
161
|
|
|
@@ -78,39 +165,21 @@ declare function Post(route: string): any;
|
|
|
78
165
|
declare function Put(route: string): any;
|
|
79
166
|
declare function Delete(route: string): any;
|
|
80
167
|
declare function Controller(route: string): any;
|
|
168
|
+
declare function Guard(guardKey: string): any;
|
|
169
|
+
declare function Interceptor(interceptorKey: string): any;
|
|
170
|
+
|
|
171
|
+
declare function MQ(queue: string, routeKey: string, options?: amqplib.Options.Consume): (target: any, k: PropertyKey) => void;
|
|
81
172
|
|
|
82
|
-
declare function Inject(): void;
|
|
173
|
+
declare function Inject(_target: any): void;
|
|
83
174
|
declare function Header(name: string, value: string): (target: any, k: PropertyKey) => void;
|
|
84
175
|
|
|
85
176
|
declare function Server(localPath: string): PluginOption;
|
|
86
177
|
|
|
87
|
-
declare
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
message: string;
|
|
94
|
-
description: string;
|
|
95
|
-
status: number;
|
|
96
|
-
error: boolean;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
declare class UndefinedException extends HttpException {
|
|
101
|
-
constructor(message: string);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
declare class ValidateException extends HttpException {
|
|
105
|
-
constructor(message: string);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
declare class ForbiddenException extends HttpException {
|
|
109
|
-
constructor(message: string);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
declare class BadRequestException extends HttpException {
|
|
113
|
-
constructor(message: string);
|
|
114
|
-
}
|
|
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>>>;
|
|
115
184
|
|
|
116
|
-
export { BadRequestException, BaseParam, Body, Construct, Controller, Delete, Factory, ForbiddenException, Get, Header, HttpException, Inject, Param, Pcompiler, 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 };
|