phecda-server 5.0.0-beta.29 → 5.0.0-beta.30
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-5ETU2MGE.js → chunk-73OVCWNF.js} +3 -1
- package/dist/{chunk-YA4E3HD5.mjs → chunk-EJTRJ5YR.mjs} +3 -1
- package/dist/{chunk-NHO4IK7R.js → chunk-MEVDHQPQ.js} +17 -17
- package/dist/{chunk-JF5EF46A.mjs → chunk-UMZSURNA.mjs} +17 -17
- package/dist/{core-4ec3eae2.d.ts → core-3f295d7c.d.ts} +20 -13
- package/dist/{helper-059cdc2a.d.ts → helper-df321ded.d.ts} +1 -1
- package/dist/index.d.ts +13 -12
- package/dist/index.js +31 -23
- package/dist/index.mjs +10 -2
- package/dist/rpc/bullmq/index.d.ts +1 -1
- package/dist/rpc/bullmq/index.js +6 -6
- package/dist/rpc/bullmq/index.mjs +3 -3
- package/dist/rpc/kafka/index.d.ts +1 -1
- package/dist/rpc/kafka/index.js +6 -6
- package/dist/rpc/kafka/index.mjs +3 -3
- package/dist/rpc/nats/index.d.ts +1 -1
- package/dist/rpc/nats/index.js +6 -6
- package/dist/rpc/nats/index.mjs +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +1 -1
- package/dist/rpc/rabbitmq/index.js +6 -6
- package/dist/rpc/rabbitmq/index.mjs +3 -3
- package/dist/rpc/redis/index.d.ts +1 -1
- package/dist/rpc/redis/index.js +6 -6
- package/dist/rpc/redis/index.mjs +3 -3
- package/dist/server/elysia/index.d.ts +2 -2
- package/dist/server/elysia/index.js +17 -17
- package/dist/server/elysia/index.mjs +6 -6
- package/dist/server/express/index.d.ts +2 -2
- package/dist/server/express/index.js +15 -15
- package/dist/server/express/index.mjs +5 -5
- package/dist/server/fastify/index.d.ts +2 -2
- package/dist/server/fastify/index.js +18 -18
- package/dist/server/fastify/index.mjs +6 -6
- package/dist/server/h3/index.d.ts +1 -1
- package/dist/server/h3/index.js +15 -15
- package/dist/server/h3/index.mjs +5 -5
- package/dist/server/hono/index.d.ts +2 -2
- package/dist/server/hono/index.js +15 -15
- package/dist/server/hono/index.mjs +5 -5
- package/dist/server/hyper-express/index.d.ts +2 -2
- package/dist/server/hyper-express/index.js +15 -15
- package/dist/server/hyper-express/index.mjs +5 -5
- package/dist/server/koa/index.d.ts +2 -2
- package/dist/server/koa/index.js +15 -15
- package/dist/server/koa/index.mjs +5 -5
- package/dist/test.d.ts +1 -1
- package/package.json +1 -1
|
@@ -40,7 +40,7 @@ _chunk252GLGJLjs.__name.call(void 0, ValidateException, "ValidateException");
|
|
|
40
40
|
|
|
41
41
|
// src/pipe.ts
|
|
42
42
|
var _phecdacore = require('phecda-core');
|
|
43
|
-
var defaultPipe = /* @__PURE__ */ _chunk252GLGJLjs.__name.call(void 0, ({ arg, reflect, index }) => {
|
|
43
|
+
var defaultPipe = /* @__PURE__ */ _chunk252GLGJLjs.__name.call(void 0, ({ arg, reflect, index, defaultValue }) => {
|
|
44
44
|
if (_phecdacore.isPhecda.call(void 0, reflect)) {
|
|
45
45
|
const instance = _phecdacore.plainToClass.call(void 0, reflect, arg);
|
|
46
46
|
const err = _phecdacore.transformInstance.call(void 0, instance);
|
|
@@ -48,6 +48,8 @@ var defaultPipe = /* @__PURE__ */ _chunk252GLGJLjs.__name.call(void 0, ({ arg, r
|
|
|
48
48
|
throw new ValidateException(err[0]);
|
|
49
49
|
arg = instance;
|
|
50
50
|
} else {
|
|
51
|
+
if (arg === void 0 && defaultValue !== void 0)
|
|
52
|
+
return defaultValue;
|
|
51
53
|
if ([
|
|
52
54
|
Number,
|
|
53
55
|
Boolean
|
|
@@ -40,7 +40,7 @@ __name(ValidateException, "ValidateException");
|
|
|
40
40
|
|
|
41
41
|
// src/pipe.ts
|
|
42
42
|
import { isPhecda, plainToClass, transformInstance } from "phecda-core";
|
|
43
|
-
var defaultPipe = /* @__PURE__ */ __name(({ arg, reflect, index }) => {
|
|
43
|
+
var defaultPipe = /* @__PURE__ */ __name(({ arg, reflect, index, defaultValue }) => {
|
|
44
44
|
if (isPhecda(reflect)) {
|
|
45
45
|
const instance = plainToClass(reflect, arg);
|
|
46
46
|
const err = transformInstance(instance);
|
|
@@ -48,6 +48,8 @@ var defaultPipe = /* @__PURE__ */ __name(({ arg, reflect, index }) => {
|
|
|
48
48
|
throw new ValidateException(err[0]);
|
|
49
49
|
arg = instance;
|
|
50
50
|
} else {
|
|
51
|
+
if (arg === void 0 && defaultValue !== void 0)
|
|
52
|
+
return defaultValue;
|
|
51
53
|
if ([
|
|
52
54
|
Number,
|
|
53
55
|
Boolean
|
|
@@ -4,7 +4,7 @@ var _chunk252GLGJLjs = require('./chunk-252GLGJL.js');
|
|
|
4
4
|
|
|
5
5
|
// src/decorators/param.ts
|
|
6
6
|
var _phecdacore = require('phecda-core');
|
|
7
|
-
function BaseParam(type, key) {
|
|
7
|
+
function BaseParam(type, key, defaultValue) {
|
|
8
8
|
return (target, k, index) => {
|
|
9
9
|
_phecdacore.setStateKey.call(void 0, target, k);
|
|
10
10
|
const state = _phecdacore.getOwnState.call(void 0, target, k);
|
|
@@ -14,19 +14,21 @@ function BaseParam(type, key) {
|
|
|
14
14
|
if (existItem)
|
|
15
15
|
Object.assign(existItem, {
|
|
16
16
|
type,
|
|
17
|
-
key
|
|
17
|
+
key,
|
|
18
|
+
defaultValue
|
|
18
19
|
});
|
|
19
20
|
else
|
|
20
21
|
state.params.push({
|
|
21
22
|
type,
|
|
22
23
|
key,
|
|
23
|
-
index
|
|
24
|
+
index,
|
|
25
|
+
defaultValue
|
|
24
26
|
});
|
|
25
27
|
_phecdacore.setState.call(void 0, target, k, state);
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
30
|
_chunk252GLGJLjs.__name.call(void 0, BaseParam, "BaseParam");
|
|
29
|
-
function Pipe(key
|
|
31
|
+
function Pipe(key) {
|
|
30
32
|
return (target, k, index) => {
|
|
31
33
|
_phecdacore.setStateKey.call(void 0, target, k);
|
|
32
34
|
const state = _phecdacore.getOwnState.call(void 0, target, k);
|
|
@@ -35,37 +37,35 @@ function Pipe(key, opts) {
|
|
|
35
37
|
const existItem = state.params.find((item) => item.index === index);
|
|
36
38
|
if (existItem)
|
|
37
39
|
Object.assign(existItem, {
|
|
38
|
-
pipe: key
|
|
39
|
-
pipeOpts: opts
|
|
40
|
+
pipe: key
|
|
40
41
|
});
|
|
41
42
|
else
|
|
42
43
|
state.params.push({
|
|
43
44
|
pipe: key,
|
|
44
|
-
pipeOpts: opts,
|
|
45
45
|
index
|
|
46
46
|
});
|
|
47
47
|
_phecdacore.setState.call(void 0, target, k, state);
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
_chunk252GLGJLjs.__name.call(void 0, Pipe, "Pipe");
|
|
51
|
-
function Body(key = "") {
|
|
52
|
-
return BaseParam("body", key);
|
|
51
|
+
function Body(key = "", defaultValue) {
|
|
52
|
+
return BaseParam("body", key, defaultValue);
|
|
53
53
|
}
|
|
54
54
|
_chunk252GLGJLjs.__name.call(void 0, Body, "Body");
|
|
55
|
-
function Head(key) {
|
|
56
|
-
return BaseParam("headers", key.toLowerCase());
|
|
55
|
+
function Head(key, defaultValue) {
|
|
56
|
+
return BaseParam("headers", key.toLowerCase(), defaultValue);
|
|
57
57
|
}
|
|
58
58
|
_chunk252GLGJLjs.__name.call(void 0, Head, "Head");
|
|
59
|
-
function Query(key = "") {
|
|
60
|
-
return BaseParam("query", key);
|
|
59
|
+
function Query(key = "", defaultValue) {
|
|
60
|
+
return BaseParam("query", key, defaultValue);
|
|
61
61
|
}
|
|
62
62
|
_chunk252GLGJLjs.__name.call(void 0, Query, "Query");
|
|
63
|
-
function Param(key) {
|
|
64
|
-
return BaseParam("params", key);
|
|
63
|
+
function Param(key, defaultValue) {
|
|
64
|
+
return BaseParam("params", key, defaultValue);
|
|
65
65
|
}
|
|
66
66
|
_chunk252GLGJLjs.__name.call(void 0, Param, "Param");
|
|
67
|
-
function Arg() {
|
|
68
|
-
return BaseParam("params", "");
|
|
67
|
+
function Arg(defaultValue) {
|
|
68
|
+
return BaseParam("params", "", defaultValue);
|
|
69
69
|
}
|
|
70
70
|
_chunk252GLGJLjs.__name.call(void 0, Arg, "Arg");
|
|
71
71
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// src/decorators/param.ts
|
|
6
6
|
import { getOwnState, setState, setStateKey } from "phecda-core";
|
|
7
|
-
function BaseParam(type, key) {
|
|
7
|
+
function BaseParam(type, key, defaultValue) {
|
|
8
8
|
return (target, k, index) => {
|
|
9
9
|
setStateKey(target, k);
|
|
10
10
|
const state = getOwnState(target, k);
|
|
@@ -14,19 +14,21 @@ function BaseParam(type, key) {
|
|
|
14
14
|
if (existItem)
|
|
15
15
|
Object.assign(existItem, {
|
|
16
16
|
type,
|
|
17
|
-
key
|
|
17
|
+
key,
|
|
18
|
+
defaultValue
|
|
18
19
|
});
|
|
19
20
|
else
|
|
20
21
|
state.params.push({
|
|
21
22
|
type,
|
|
22
23
|
key,
|
|
23
|
-
index
|
|
24
|
+
index,
|
|
25
|
+
defaultValue
|
|
24
26
|
});
|
|
25
27
|
setState(target, k, state);
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
30
|
__name(BaseParam, "BaseParam");
|
|
29
|
-
function Pipe(key
|
|
31
|
+
function Pipe(key) {
|
|
30
32
|
return (target, k, index) => {
|
|
31
33
|
setStateKey(target, k);
|
|
32
34
|
const state = getOwnState(target, k);
|
|
@@ -35,37 +37,35 @@ function Pipe(key, opts) {
|
|
|
35
37
|
const existItem = state.params.find((item) => item.index === index);
|
|
36
38
|
if (existItem)
|
|
37
39
|
Object.assign(existItem, {
|
|
38
|
-
pipe: key
|
|
39
|
-
pipeOpts: opts
|
|
40
|
+
pipe: key
|
|
40
41
|
});
|
|
41
42
|
else
|
|
42
43
|
state.params.push({
|
|
43
44
|
pipe: key,
|
|
44
|
-
pipeOpts: opts,
|
|
45
45
|
index
|
|
46
46
|
});
|
|
47
47
|
setState(target, k, state);
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
__name(Pipe, "Pipe");
|
|
51
|
-
function Body(key = "") {
|
|
52
|
-
return BaseParam("body", key);
|
|
51
|
+
function Body(key = "", defaultValue) {
|
|
52
|
+
return BaseParam("body", key, defaultValue);
|
|
53
53
|
}
|
|
54
54
|
__name(Body, "Body");
|
|
55
|
-
function Head(key) {
|
|
56
|
-
return BaseParam("headers", key.toLowerCase());
|
|
55
|
+
function Head(key, defaultValue) {
|
|
56
|
+
return BaseParam("headers", key.toLowerCase(), defaultValue);
|
|
57
57
|
}
|
|
58
58
|
__name(Head, "Head");
|
|
59
|
-
function Query(key = "") {
|
|
60
|
-
return BaseParam("query", key);
|
|
59
|
+
function Query(key = "", defaultValue) {
|
|
60
|
+
return BaseParam("query", key, defaultValue);
|
|
61
61
|
}
|
|
62
62
|
__name(Query, "Query");
|
|
63
|
-
function Param(key) {
|
|
64
|
-
return BaseParam("params", key);
|
|
63
|
+
function Param(key, defaultValue) {
|
|
64
|
+
return BaseParam("params", key, defaultValue);
|
|
65
65
|
}
|
|
66
66
|
__name(Param, "Param");
|
|
67
|
-
function Arg() {
|
|
68
|
-
return BaseParam("params", "");
|
|
67
|
+
function Arg(defaultValue) {
|
|
68
|
+
return BaseParam("params", "", defaultValue);
|
|
69
69
|
}
|
|
70
70
|
__name(Arg, "Arg");
|
|
71
71
|
|
|
@@ -18,7 +18,7 @@ interface MetaData {
|
|
|
18
18
|
index: number;
|
|
19
19
|
key: string;
|
|
20
20
|
pipe?: string;
|
|
21
|
-
|
|
21
|
+
defaultValue?: any;
|
|
22
22
|
}[];
|
|
23
23
|
guards: string[];
|
|
24
24
|
filter?: string;
|
|
@@ -53,18 +53,20 @@ interface Emitter {
|
|
|
53
53
|
removeAllListeners<N extends keyof Events>(eventName: N): void;
|
|
54
54
|
emit<N extends keyof Events>(eventName: N, param: Events[N]): void;
|
|
55
55
|
}
|
|
56
|
-
type
|
|
57
|
-
|
|
56
|
+
type AnyFunction = (...args: any) => any;
|
|
57
|
+
type ParseInstance<Instance extends Record<string, AnyFunction>> = {
|
|
58
|
+
[Key in keyof Instance]: ToClientFn<Instance[Key]>;
|
|
58
59
|
};
|
|
59
|
-
type
|
|
60
|
-
[
|
|
61
|
-
};
|
|
62
|
-
type ToClientFn<T extends (...args: any) => any> = (...p: Parameters<T>) => Promise<BaseReturn<ReturnType<T>>>;
|
|
63
|
-
type PickKeysByValue<Type, Value> = {
|
|
64
|
-
[Key in keyof Type]: Type[Key] extends Value ? Key : never;
|
|
60
|
+
type PickFuncKeys<Type> = {
|
|
61
|
+
[Key in keyof Type]: Type[Key] extends (...args: any) => any ? (ReturnType<Type[Key]> extends CustomResponse<any> ? never : Key) : never;
|
|
65
62
|
}[keyof Type];
|
|
66
|
-
type
|
|
67
|
-
|
|
63
|
+
type ToClientMap<ControllerMap extends Record<string, Construct>> = {
|
|
64
|
+
[Key in keyof ControllerMap]: ToClientInstance<InstanceType<ControllerMap[Key]>>;
|
|
65
|
+
};
|
|
66
|
+
type ToClientInstance<Instance extends Record<string, any>> = ParseInstance<PickFunc<Instance>>;
|
|
67
|
+
type ToClientFn<Func extends AnyFunction> = (...p: Parameters<Func>) => Promise<BaseReturn<ReturnType<Func>>>;
|
|
68
|
+
type PickFunc<Instance> = Pick<Instance, PickFuncKeys<Instance>>;
|
|
69
|
+
type OmitFunction<Instance> = Omit<Instance, PickFuncKeys<Instance>>;
|
|
68
70
|
interface BaseContext {
|
|
69
71
|
meta: Meta;
|
|
70
72
|
moduleMap: Record<string, any>;
|
|
@@ -75,11 +77,11 @@ interface BaseContext {
|
|
|
75
77
|
}
|
|
76
78
|
interface HttpContext extends BaseContext {
|
|
77
79
|
parallel?: true;
|
|
80
|
+
index?: number;
|
|
78
81
|
query: Record<string, any>;
|
|
79
82
|
params: Record<string, string>;
|
|
80
83
|
body: Record<string, any>;
|
|
81
84
|
headers: IncomingHttpHeaders;
|
|
82
|
-
index?: number;
|
|
83
85
|
data: any;
|
|
84
86
|
}
|
|
85
87
|
interface RpcContext extends BaseContext {
|
|
@@ -102,6 +104,11 @@ type BaseReturn<T> = Awaited<T> extends {
|
|
|
102
104
|
toJSON(): infer R;
|
|
103
105
|
} ? R : Awaited<T>;
|
|
104
106
|
type BaseRequestType = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
|
|
107
|
+
declare const ResponseSymbol: unique symbol;
|
|
108
|
+
declare class CustomResponse<Value> {
|
|
109
|
+
[ResponseSymbol]: Value;
|
|
110
|
+
}
|
|
111
|
+
type ExtractResponse<Class extends CustomResponse<any>> = Class extends CustomResponse<infer Value> ? Value : never;
|
|
105
112
|
|
|
106
113
|
declare function Injectable(): (target: any) => void;
|
|
107
114
|
declare const emitter: Emitter;
|
|
@@ -119,4 +126,4 @@ declare function Factory(models: (new (...args: any) => any)[], opts?: {
|
|
|
119
126
|
destroy: () => Promise<void>;
|
|
120
127
|
}>;
|
|
121
128
|
|
|
122
|
-
export { BaseContext as B, Emitter as E, Factory as F, HttpContext as H, Injectable as I, Meta as M, OmitFunction as O, PickFunc as P, RpcContext as R, ToClientMap as T, UNMOUNT_SYMBOL as U, BaseError as a, MetaData as b, ToClientInstance as c, ToClientFn as d, BaseReturn as e, BaseRequestType as f,
|
|
129
|
+
export { BaseContext as B, CustomResponse as C, Emitter as E, Factory as F, HttpContext as H, Injectable as I, Meta as M, OmitFunction as O, PickFunc as P, RpcContext as R, ToClientMap as T, UNMOUNT_SYMBOL as U, BaseError as a, MetaData as b, ToClientInstance as c, ToClientFn as d, BaseReturn as e, BaseRequestType as f, ExtractResponse as g, emitter as h, ERROR_SYMBOL as i, IS_HMR as j, IS_ONLY_CODE as k, IS_STRICT as l, IS_LOG_BAN as m, PS_FILE_RE as n, PS_EXIT_CODE as o };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { B as BaseContext, M as Meta, U as UNMOUNT_SYMBOL, a as BaseError, b as MetaData } from './core-
|
|
2
|
-
export { f as BaseRequestType, e as BaseReturn,
|
|
1
|
+
import { B as BaseContext, M as Meta, U as UNMOUNT_SYMBOL, a as BaseError, b as MetaData } from './core-3f295d7c.js';
|
|
2
|
+
export { f as BaseRequestType, e as BaseReturn, C as CustomResponse, i as ERROR_SYMBOL, E as Emitter, g as ExtractResponse, F as Factory, H as HttpContext, j as IS_HMR, m as IS_LOG_BAN, k as IS_ONLY_CODE, l as IS_STRICT, I as Injectable, O as OmitFunction, o as PS_EXIT_CODE, n as PS_FILE_RE, P as PickFunc, R as RpcContext, d as ToClientFn, c as ToClientInstance, T as ToClientMap, h as emitter } from './core-3f295d7c.js';
|
|
3
3
|
import { Construct, AbConstruct } from 'phecda-core';
|
|
4
4
|
export * from 'phecda-core';
|
|
5
5
|
export { a as RpcClientOptions, R as RpcServerOptions, g as genClientQueue } from './helper-9e206c66.js';
|
|
6
|
-
export { S as ServerOptions, a as argToReq, r as resolveDep } from './helper-
|
|
6
|
+
export { S as ServerOptions, a as argToReq, r as resolveDep } from './helper-df321ded.js';
|
|
7
7
|
import 'http';
|
|
8
8
|
|
|
9
9
|
declare class Histroy {
|
|
@@ -93,11 +93,12 @@ type GuardType<C extends BaseContext = any> = ((ctx: C) => Promise<boolean> | bo
|
|
|
93
93
|
type InterceptorType<C extends BaseContext = any> = (ctx: C) => (any | ((ret: any) => any));
|
|
94
94
|
type PipeType<C extends BaseContext = any> = (arg: {
|
|
95
95
|
arg: any;
|
|
96
|
-
|
|
96
|
+
pipe?: string;
|
|
97
97
|
key: string;
|
|
98
98
|
type: string;
|
|
99
99
|
index: number;
|
|
100
100
|
reflect: any;
|
|
101
|
+
defaultValue?: any;
|
|
101
102
|
}, ctx: C) => Promise<any>;
|
|
102
103
|
type FilterType<C extends BaseContext = any, E extends Exception = any> = (err: E | Error, ctx?: C) => Error | any;
|
|
103
104
|
declare class Context<Data extends BaseContext> {
|
|
@@ -115,7 +116,7 @@ declare class Context<Data extends BaseContext> {
|
|
|
115
116
|
usePipe(args: {
|
|
116
117
|
arg: any;
|
|
117
118
|
pipe?: string;
|
|
118
|
-
|
|
119
|
+
defaultValue?: any;
|
|
119
120
|
type: string;
|
|
120
121
|
key: string;
|
|
121
122
|
index: number;
|
|
@@ -144,13 +145,13 @@ declare function detectAopDep(meta: Meta[], { guards, interceptors, plugins }?:
|
|
|
144
145
|
missFilters: string[];
|
|
145
146
|
};
|
|
146
147
|
|
|
147
|
-
declare function BaseParam(type: string, key: string): any;
|
|
148
|
-
declare function Pipe(key?: string
|
|
149
|
-
declare function Body(key?: string): any;
|
|
150
|
-
declare function Head(key: string): any;
|
|
151
|
-
declare function Query(key?: string): any;
|
|
152
|
-
declare function Param(key: string): any;
|
|
153
|
-
declare function Arg(): any;
|
|
148
|
+
declare function BaseParam(type: string, key: string, defaultValue?: any): any;
|
|
149
|
+
declare function Pipe(key?: string): (target: any, k: PropertyKey, index: number) => void;
|
|
150
|
+
declare function Body(key?: string, defaultValue?: any): any;
|
|
151
|
+
declare function Head(key: string, defaultValue?: any): any;
|
|
152
|
+
declare function Query(key?: string, defaultValue?: any): any;
|
|
153
|
+
declare function Param(key: string, defaultValue?: any): any;
|
|
154
|
+
declare function Arg(defaultValue?: any): any;
|
|
154
155
|
|
|
155
156
|
declare function Route(route: string, type?: string): any;
|
|
156
157
|
declare function Get(route?: string): any;
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var _chunk3BW2WVX6js = require('./chunk-3BW2WVX6.js');
|
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _chunkMEVDHQPQjs = require('./chunk-MEVDHQPQ.js');
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
@@ -64,7 +64,7 @@ var _chunkP4K7ECP2js = require('./chunk-P4K7ECP2.js');
|
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
var
|
|
67
|
+
var _chunk73OVCWNFjs = require('./chunk-73OVCWNF.js');
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
|
|
@@ -81,6 +81,13 @@ var _chunk5ETU2MGEjs = require('./chunk-5ETU2MGE.js');
|
|
|
81
81
|
|
|
82
82
|
var _chunk252GLGJLjs = require('./chunk-252GLGJL.js');
|
|
83
83
|
|
|
84
|
+
// src/types.ts
|
|
85
|
+
var ResponseSymbol = Symbol("response");
|
|
86
|
+
var CustomResponse = class {
|
|
87
|
+
|
|
88
|
+
};
|
|
89
|
+
_chunk252GLGJLjs.__name.call(void 0, CustomResponse, "CustomResponse");
|
|
90
|
+
|
|
84
91
|
// src/modules/dev.ts
|
|
85
92
|
var _phecdacore = require('phecda-core'); _createStarExport(_phecdacore);
|
|
86
93
|
var __decorate = function(decorators, target, key, desc) {
|
|
@@ -124,9 +131,9 @@ var PFilter = class extends Dev {
|
|
|
124
131
|
constructor(tag) {
|
|
125
132
|
super();
|
|
126
133
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
127
|
-
|
|
134
|
+
_chunk73OVCWNFjs.addFilter.call(void 0, this.key, this.use.bind(this));
|
|
128
135
|
this.onUnmount(() => {
|
|
129
|
-
delete
|
|
136
|
+
delete _chunk73OVCWNFjs.Context.filterRecord[this.key];
|
|
130
137
|
});
|
|
131
138
|
}
|
|
132
139
|
};
|
|
@@ -139,9 +146,9 @@ var PGuard = class extends Dev {
|
|
|
139
146
|
constructor(tag) {
|
|
140
147
|
super();
|
|
141
148
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
142
|
-
|
|
149
|
+
_chunk73OVCWNFjs.addGuard.call(void 0, this.key, this.use.bind(this));
|
|
143
150
|
this.onUnmount(() => {
|
|
144
|
-
delete
|
|
151
|
+
delete _chunk73OVCWNFjs.Context.guardRecord[this.key];
|
|
145
152
|
});
|
|
146
153
|
}
|
|
147
154
|
};
|
|
@@ -155,9 +162,9 @@ var PInterceptor = class extends Dev {
|
|
|
155
162
|
super();
|
|
156
163
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
157
164
|
this.onUnmount(() => {
|
|
158
|
-
delete
|
|
165
|
+
delete _chunk73OVCWNFjs.Context.interceptorRecord[this.key];
|
|
159
166
|
});
|
|
160
|
-
|
|
167
|
+
_chunk73OVCWNFjs.addInterceptor.call(void 0, this.key, this.use.bind(this));
|
|
161
168
|
}
|
|
162
169
|
};
|
|
163
170
|
_chunk252GLGJLjs.__name.call(void 0, PInterceptor, "PInterceptor");
|
|
@@ -169,9 +176,9 @@ var PPipe = class extends Dev {
|
|
|
169
176
|
constructor(tag) {
|
|
170
177
|
super();
|
|
171
178
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
172
|
-
|
|
179
|
+
_chunk73OVCWNFjs.addPipe.call(void 0, this.key, this.use.bind(this));
|
|
173
180
|
this.onUnmount(() => {
|
|
174
|
-
delete
|
|
181
|
+
delete _chunk73OVCWNFjs.Context.pipeRecord[this.key];
|
|
175
182
|
});
|
|
176
183
|
}
|
|
177
184
|
};
|
|
@@ -184,9 +191,9 @@ var PPlugin = class extends Dev {
|
|
|
184
191
|
constructor(tag) {
|
|
185
192
|
super();
|
|
186
193
|
this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
187
|
-
|
|
194
|
+
_chunk73OVCWNFjs.addPlugin.call(void 0, this.key, this.use.bind(this));
|
|
188
195
|
this.onUnmount(() => {
|
|
189
|
-
delete
|
|
196
|
+
delete _chunk73OVCWNFjs.Context.pluginRecord[this.key];
|
|
190
197
|
});
|
|
191
198
|
}
|
|
192
199
|
};
|
|
@@ -200,33 +207,33 @@ var PExtension = class extends Dev {
|
|
|
200
207
|
super();
|
|
201
208
|
const key = this.key = tag || _phecdacore.getTag.call(void 0, this);
|
|
202
209
|
if (this.pipe) {
|
|
203
|
-
|
|
210
|
+
_chunk73OVCWNFjs.addPipe.call(void 0, key, this.pipe.bind(this));
|
|
204
211
|
this.onUnmount(() => {
|
|
205
|
-
delete
|
|
212
|
+
delete _chunk73OVCWNFjs.Context.pipeRecord[key];
|
|
206
213
|
});
|
|
207
214
|
}
|
|
208
215
|
if (this.plugin) {
|
|
209
|
-
|
|
216
|
+
_chunk73OVCWNFjs.addPlugin.call(void 0, key, this.plugin.bind(this));
|
|
210
217
|
this.onUnmount(() => {
|
|
211
|
-
delete
|
|
218
|
+
delete _chunk73OVCWNFjs.Context.pluginRecord[key];
|
|
212
219
|
});
|
|
213
220
|
}
|
|
214
221
|
if (this.intercept) {
|
|
215
|
-
|
|
222
|
+
_chunk73OVCWNFjs.addInterceptor.call(void 0, key, this.intercept.bind(this));
|
|
216
223
|
this.onUnmount(() => {
|
|
217
|
-
delete
|
|
224
|
+
delete _chunk73OVCWNFjs.Context.interceptorRecord[key];
|
|
218
225
|
});
|
|
219
226
|
}
|
|
220
227
|
if (this.guard) {
|
|
221
|
-
|
|
228
|
+
_chunk73OVCWNFjs.addGuard.call(void 0, key, this.guard.bind(this));
|
|
222
229
|
this.onUnmount(() => {
|
|
223
|
-
delete
|
|
230
|
+
delete _chunk73OVCWNFjs.Context.guardRecord[key];
|
|
224
231
|
});
|
|
225
232
|
}
|
|
226
233
|
if (this.filter) {
|
|
227
|
-
|
|
234
|
+
_chunk73OVCWNFjs.addFilter.call(void 0, key, this.filter.bind(this));
|
|
228
235
|
this.onUnmount(() => {
|
|
229
|
-
delete
|
|
236
|
+
delete _chunk73OVCWNFjs.Context.filterRecord[key];
|
|
230
237
|
});
|
|
231
238
|
}
|
|
232
239
|
}
|
|
@@ -312,4 +319,5 @@ _chunk252GLGJLjs.__name.call(void 0, PExtension, "PExtension");
|
|
|
312
319
|
|
|
313
320
|
|
|
314
321
|
|
|
315
|
-
|
|
322
|
+
|
|
323
|
+
exports.Arg = _chunkMEVDHQPQjs.Arg; exports.BadGatewayException = _chunk73OVCWNFjs.BadGatewayException; exports.BadRequestException = _chunk73OVCWNFjs.BadRequestException; exports.BaseParam = _chunkMEVDHQPQjs.BaseParam; exports.Body = _chunkMEVDHQPQjs.Body; exports.ConflictException = _chunk73OVCWNFjs.ConflictException; exports.Context = _chunk73OVCWNFjs.Context; exports.Controller = _chunkMEVDHQPQjs.Controller; exports.Ctx = _chunkMEVDHQPQjs.Ctx; exports.CustomResponse = CustomResponse; exports.Define = _chunkMEVDHQPQjs.Define; exports.Delete = _chunkMEVDHQPQjs.Delete; exports.Dev = Dev; exports.ERROR_SYMBOL = _chunk252GLGJLjs.ERROR_SYMBOL; exports.Event = _chunkMEVDHQPQjs.Event; exports.Exception = _chunk73OVCWNFjs.Exception; exports.Factory = _chunk3BW2WVX6js.Factory; exports.Filter = _chunkMEVDHQPQjs.Filter; exports.ForbiddenException = _chunk73OVCWNFjs.ForbiddenException; exports.FrameworkException = _chunk73OVCWNFjs.FrameworkException; exports.Get = _chunkMEVDHQPQjs.Get; exports.Guard = _chunkMEVDHQPQjs.Guard; exports.Head = _chunkMEVDHQPQjs.Head; exports.Header = _chunkMEVDHQPQjs.Header; exports.IS_HMR = _chunk252GLGJLjs.IS_HMR; exports.IS_LOG_BAN = _chunk252GLGJLjs.IS_LOG_BAN; exports.IS_ONLY_CODE = _chunk252GLGJLjs.IS_ONLY_CODE; exports.IS_STRICT = _chunk252GLGJLjs.IS_STRICT; exports.Injectable = _chunk3BW2WVX6js.Injectable; exports.Interceptor = _chunkMEVDHQPQjs.Interceptor; exports.InvalidInputException = _chunk73OVCWNFjs.InvalidInputException; exports.Meta = _chunk3BW2WVX6js.Meta; exports.Mix = _chunk252GLGJLjs.Mix; exports.NotFoundException = _chunk73OVCWNFjs.NotFoundException; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PPlugin = PPlugin; exports.PS_EXIT_CODE = _chunk252GLGJLjs.PS_EXIT_CODE; exports.PS_FILE_RE = _chunk252GLGJLjs.PS_FILE_RE; exports.Param = _chunkMEVDHQPQjs.Param; exports.Patch = _chunkMEVDHQPQjs.Patch; exports.PayloadLargeException = _chunk73OVCWNFjs.PayloadLargeException; exports.Pipe = _chunkMEVDHQPQjs.Pipe; exports.Plugin = _chunkMEVDHQPQjs.Plugin; exports.Post = _chunkMEVDHQPQjs.Post; exports.Put = _chunkMEVDHQPQjs.Put; exports.Query = _chunkMEVDHQPQjs.Query; exports.Queue = _chunkMEVDHQPQjs.Queue; exports.Route = _chunkMEVDHQPQjs.Route; exports.ServiceUnavailableException = _chunk73OVCWNFjs.ServiceUnavailableException; exports.TimeoutException = _chunk73OVCWNFjs.TimeoutException; exports.TimerException = _chunk73OVCWNFjs.TimerException; exports.UNMOUNT_SYMBOL = _chunk252GLGJLjs.UNMOUNT_SYMBOL; exports.UnauthorizedException = _chunk73OVCWNFjs.UnauthorizedException; exports.UndefinedException = _chunk73OVCWNFjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunk73OVCWNFjs.UnsupportedMediaTypeException; exports.ValidateException = _chunk73OVCWNFjs.ValidateException; exports.WorkerException = _chunk73OVCWNFjs.WorkerException; exports.addFilter = _chunk73OVCWNFjs.addFilter; exports.addGuard = _chunk73OVCWNFjs.addGuard; exports.addInterceptor = _chunk73OVCWNFjs.addInterceptor; exports.addPipe = _chunk73OVCWNFjs.addPipe; exports.addPlugin = _chunk73OVCWNFjs.addPlugin; exports.argToReq = _chunkP4K7ECP2js.argToReq; exports.defaultPipe = _chunk73OVCWNFjs.defaultPipe; exports.detectAopDep = _chunk73OVCWNFjs.detectAopDep; exports.emitter = _chunk3BW2WVX6js.emitter; exports.genClientQueue = _chunk3QLIIO6Djs.genClientQueue; exports.generateHTTPCode = _chunk3BW2WVX6js.generateHTTPCode; exports.generateRPCCode = _chunk3BW2WVX6js.generateRPCCode; exports.getConfig = _chunk252GLGJLjs.getConfig; exports.log = _chunk252GLGJLjs.log; exports.resolveDep = _chunkP4K7ECP2js.resolveDep; exports.setConfig = _chunk252GLGJLjs.setConfig;
|
package/dist/index.mjs
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
Query,
|
|
34
34
|
Queue,
|
|
35
35
|
Route
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-UMZSURNA.mjs";
|
|
37
37
|
import {
|
|
38
38
|
argToReq,
|
|
39
39
|
resolveDep
|
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
addPlugin,
|
|
65
65
|
defaultPipe,
|
|
66
66
|
detectAopDep
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-EJTRJ5YR.mjs";
|
|
68
68
|
import {
|
|
69
69
|
ERROR_SYMBOL,
|
|
70
70
|
IS_HMR,
|
|
@@ -81,6 +81,13 @@ import {
|
|
|
81
81
|
setConfig
|
|
82
82
|
} from "./chunk-J5GQYGQN.mjs";
|
|
83
83
|
|
|
84
|
+
// src/types.ts
|
|
85
|
+
var ResponseSymbol = Symbol("response");
|
|
86
|
+
var CustomResponse = class {
|
|
87
|
+
[ResponseSymbol];
|
|
88
|
+
};
|
|
89
|
+
__name(CustomResponse, "CustomResponse");
|
|
90
|
+
|
|
84
91
|
// src/modules/dev.ts
|
|
85
92
|
import { Empty, Unmount } from "phecda-core";
|
|
86
93
|
var __decorate = function(decorators, target, key, desc) {
|
|
@@ -245,6 +252,7 @@ export {
|
|
|
245
252
|
Context,
|
|
246
253
|
Controller,
|
|
247
254
|
Ctx,
|
|
255
|
+
CustomResponse,
|
|
248
256
|
Define,
|
|
249
257
|
Delete,
|
|
250
258
|
Dev,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConnectionOptions, Worker, Queue } from 'bullmq';
|
|
2
|
-
import { R as RpcContext, F as Factory, T as ToClientMap } from '../../core-
|
|
2
|
+
import { R as RpcContext, F as Factory, T as ToClientMap } from '../../core-3f295d7c.js';
|
|
3
3
|
import { R as RpcServerOptions, a as RpcClientOptions } from '../../helper-9e206c66.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
5
|
import 'http';
|
package/dist/rpc/bullmq/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var _chunk74LBSVLEjs = require('../../chunk-74LBSVLE.js');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk73OVCWNFjs = require('../../chunk-73OVCWNF.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunk252GLGJLjs = require('../../chunk-252GLGJL.js');
|
|
@@ -56,7 +56,7 @@ async function bind(connectOpts, { moduleMap, meta }, opts) {
|
|
|
56
56
|
queueMap[clientQueue] = new (0, _bullmq.Queue)(clientQueue, {
|
|
57
57
|
connection: connectOpts
|
|
58
58
|
});
|
|
59
|
-
const context = new (0,
|
|
59
|
+
const context = new (0, _chunk73OVCWNFjs.Context)({
|
|
60
60
|
type: "bullmq",
|
|
61
61
|
moduleMap,
|
|
62
62
|
meta: meta2,
|
|
@@ -82,11 +82,11 @@ async function bind(connectOpts, { moduleMap, meta }, opts) {
|
|
|
82
82
|
]);
|
|
83
83
|
if (i1 !== void 0)
|
|
84
84
|
return i1;
|
|
85
|
-
const handleArgs = await context.usePipe(params.map(({ type, key, pipe,
|
|
85
|
+
const handleArgs = await context.usePipe(params.map(({ type, key, pipe, defaultValue, index }, i) => {
|
|
86
86
|
return {
|
|
87
87
|
arg: args[i],
|
|
88
88
|
pipe,
|
|
89
|
-
|
|
89
|
+
defaultValue,
|
|
90
90
|
key,
|
|
91
91
|
type,
|
|
92
92
|
index,
|
|
@@ -122,14 +122,14 @@ async function bind(connectOpts, { moduleMap, meta }, opts) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
_chunk252GLGJLjs.__name.call(void 0, subscribeQueues, "subscribeQueues");
|
|
125
|
-
|
|
125
|
+
_chunk73OVCWNFjs.detectAopDep.call(void 0, meta, {
|
|
126
126
|
guards: globalGuards,
|
|
127
127
|
interceptors: globalInterceptors
|
|
128
128
|
}, "rpc");
|
|
129
129
|
handleMeta();
|
|
130
130
|
subscribeQueues();
|
|
131
131
|
_chunk74LBSVLEjs.HMR.call(void 0, async () => {
|
|
132
|
-
|
|
132
|
+
_chunk73OVCWNFjs.detectAopDep.call(void 0, meta, {
|
|
133
133
|
guards: globalGuards,
|
|
134
134
|
interceptors: globalInterceptors
|
|
135
135
|
}, "rpc");
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
Context,
|
|
9
9
|
detectAopDep
|
|
10
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-EJTRJ5YR.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__name
|
|
13
13
|
} from "../../chunk-J5GQYGQN.mjs";
|
|
@@ -82,11 +82,11 @@ async function bind(connectOpts, { moduleMap, meta }, opts) {
|
|
|
82
82
|
]);
|
|
83
83
|
if (i1 !== void 0)
|
|
84
84
|
return i1;
|
|
85
|
-
const handleArgs = await context.usePipe(params.map(({ type, key, pipe,
|
|
85
|
+
const handleArgs = await context.usePipe(params.map(({ type, key, pipe, defaultValue, index }, i) => {
|
|
86
86
|
return {
|
|
87
87
|
arg: args[i],
|
|
88
88
|
pipe,
|
|
89
|
-
|
|
89
|
+
defaultValue,
|
|
90
90
|
key,
|
|
91
91
|
type,
|
|
92
92
|
index,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Consumer, Producer } from 'kafkajs';
|
|
2
|
-
import { R as RpcContext, F as Factory, T as ToClientMap } from '../../core-
|
|
2
|
+
import { R as RpcContext, F as Factory, T as ToClientMap } from '../../core-3f295d7c.js';
|
|
3
3
|
import { R as RpcServerOptions, a as RpcClientOptions } from '../../helper-9e206c66.js';
|
|
4
4
|
import 'phecda-core';
|
|
5
5
|
import 'http';
|