phecda-server 3.2.0-alpha.5 → 4.0.0-alpha.11
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/core-91ada79c.d.ts +21 -0
- package/dist/index.d.ts +97 -101
- package/dist/index.js +389 -449
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +375 -440
- package/dist/index.mjs.map +1 -1
- package/dist/rpc/rabbitmq/index.d.ts +23 -0
- package/dist/rpc/rabbitmq/index.js +363 -0
- package/dist/rpc/rabbitmq/index.js.map +1 -0
- package/dist/rpc/rabbitmq/index.mjs +337 -0
- package/dist/rpc/rabbitmq/index.mjs.map +1 -0
- package/dist/rpc/redis/index.d.ts +24 -0
- package/dist/rpc/redis/index.js +366 -0
- package/dist/rpc/redis/index.js.map +1 -0
- package/dist/rpc/redis/index.mjs +334 -0
- package/dist/rpc/redis/index.mjs.map +1 -0
- package/dist/server/express/index.d.ts +22 -0
- package/dist/server/express/index.js +422 -0
- package/dist/server/express/index.js.map +1 -0
- package/dist/server/express/index.mjs +391 -0
- package/dist/server/express/index.mjs.map +1 -0
- package/dist/server/fastify/index.d.ts +21 -0
- package/dist/server/fastify/index.js +402 -0
- package/dist/server/fastify/index.js.map +1 -0
- package/dist/server/fastify/index.mjs +377 -0
- package/dist/server/fastify/index.mjs.map +1 -0
- package/dist/server/h3/index.d.ts +21 -0
- package/dist/server/h3/index.js +435 -0
- package/dist/server/h3/index.js.map +1 -0
- package/dist/server/h3/index.mjs +410 -0
- package/dist/server/h3/index.mjs.map +1 -0
- package/dist/test.d.ts +3 -3
- package/dist/test.js +397 -251
- package/dist/test.js.map +1 -1
- package/dist/test.mjs +397 -251
- package/dist/test.mjs.map +1 -1
- package/dist/{types-b69250fd.d.ts → types-70714e01.d.ts} +28 -41
- package/package.json +45 -2
- package/register/index.mjs +2 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { P, a as Emitter, C as Construct } from './types-70714e01.js';
|
|
2
|
+
|
|
3
|
+
declare class Meta {
|
|
4
|
+
data: P.Meta;
|
|
5
|
+
handlers: P.Handler[];
|
|
6
|
+
paramsType: any[];
|
|
7
|
+
constructor(data: P.Meta, handlers: P.Handler[], paramsType: any[]);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare const emitter: Emitter;
|
|
11
|
+
declare function Factory(Modules: (new (...args: any) => any)[], opts?: {
|
|
12
|
+
http?: string;
|
|
13
|
+
rpc?: string;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
moduleMap: Map<string, any>;
|
|
16
|
+
meta: Meta[];
|
|
17
|
+
constructorMap: Map<any, any>;
|
|
18
|
+
update: (Module: Construct) => Promise<void>;
|
|
19
|
+
}>;
|
|
20
|
+
|
|
21
|
+
export { Factory as F, Meta as M, emitter as e };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,160 +1,112 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export {
|
|
1
|
+
import { E as Exception, P } from './types-70714e01.js';
|
|
2
|
+
export { B as BaseError, C as Construct, a as Emitter, M as MergeType, R as RequestType, S as ServerErr, T as ToInstance } from './types-70714e01.js';
|
|
3
|
+
export { F as Factory, M as Meta, e as emitter } from './core-91ada79c.js';
|
|
4
4
|
export * from 'phecda-core';
|
|
5
5
|
|
|
6
|
-
declare class
|
|
7
|
-
|
|
6
|
+
declare class Histroy {
|
|
7
|
+
guard: string[];
|
|
8
|
+
interceptor: string[];
|
|
9
|
+
record(name: string, type: 'guard' | 'interceptor'): boolean;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
declare class
|
|
12
|
+
declare class UndefinedException extends Exception {
|
|
11
13
|
constructor(message: string);
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
declare class
|
|
16
|
+
declare class ValidateException extends Exception {
|
|
15
17
|
constructor(message: string);
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
declare class
|
|
20
|
+
declare class ForbiddenException extends Exception {
|
|
19
21
|
constructor(message: string);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
declare class
|
|
24
|
+
declare class BadRequestException extends Exception {
|
|
23
25
|
constructor(message: string);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
declare class
|
|
28
|
+
declare class NotFoundException extends Exception {
|
|
27
29
|
constructor(message: string);
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
declare class
|
|
32
|
+
declare class ConflictException extends Exception {
|
|
31
33
|
constructor(message: string);
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
declare class
|
|
36
|
+
declare class BadGatewayException extends Exception {
|
|
35
37
|
constructor(message: string);
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
declare class
|
|
40
|
+
declare class InvalidInputException extends Exception {
|
|
39
41
|
constructor(message: string);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
declare class
|
|
44
|
+
declare class UnsupportedMediaTypeException extends Exception {
|
|
43
45
|
constructor(message: string);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
declare class
|
|
48
|
+
declare class PayloadLargeException extends Exception {
|
|
47
49
|
constructor(message: string);
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
declare class
|
|
52
|
+
declare class TimeoutException extends Exception {
|
|
51
53
|
constructor(message: string);
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
declare class
|
|
56
|
+
declare class UnauthorizedException extends Exception {
|
|
55
57
|
constructor(message: string);
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
declare class
|
|
60
|
+
declare class ServiceUnavailableException extends Exception {
|
|
59
61
|
constructor(message: string);
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
declare class
|
|
63
|
-
|
|
64
|
-
interceptor: string[];
|
|
65
|
-
record(name: string, type: 'guard' | 'interceptor'): boolean;
|
|
64
|
+
declare class FrameworkException extends Exception {
|
|
65
|
+
constructor(message: string);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
declare
|
|
69
|
-
|
|
68
|
+
declare const guardsRecord: Record<string, P.Guard<any>>;
|
|
69
|
+
declare class Context<Data = any> {
|
|
70
|
+
tag: string;
|
|
70
71
|
data: Data;
|
|
71
72
|
method: string;
|
|
72
73
|
params: string[];
|
|
73
|
-
static metaRecord: Record<string, Meta>;
|
|
74
|
-
static metaDataRecord: Record<string, ReturnType<typeof parseMeta>>;
|
|
75
|
-
static guardsRecord: Record<string, any>;
|
|
76
|
-
static interceptorsRecord: Record<string, any>;
|
|
77
|
-
post: ((...params: any) => any)[];
|
|
78
74
|
history: Histroy;
|
|
79
|
-
|
|
80
|
-
static
|
|
81
|
-
static
|
|
82
|
-
|
|
83
|
-
useInterceptor(interceptors: string[], isMerge?: boolean): Promise<void>;
|
|
84
|
-
usePost(data: any): Promise<any>;
|
|
85
|
-
}
|
|
86
|
-
declare function addGuard(key: string, handler: P.Guard): void;
|
|
87
|
-
declare function addInterceptor(key: string, handler: P.Interceptor): void;
|
|
88
|
-
declare function parseMeta(meta: Meta): {
|
|
89
|
-
guards: string[];
|
|
90
|
-
reflect: any[];
|
|
91
|
-
interceptors: string[];
|
|
92
|
-
middlewares: string[];
|
|
93
|
-
handlers: P.Handler[];
|
|
94
|
-
params: {
|
|
95
|
-
type: string;
|
|
96
|
-
index: number;
|
|
97
|
-
key: string;
|
|
98
|
-
option?: any;
|
|
99
|
-
}[];
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
declare class ServerContext extends Context<ServerCtx | ServerMergeCtx> {
|
|
103
|
-
static pipe: P.Pipe;
|
|
104
|
-
static filter: ServerFilter;
|
|
75
|
+
static filter: P.Filter;
|
|
76
|
+
static pipeRecord: Record<string, P.Pipe>;
|
|
77
|
+
static guardsRecord: Record<string, P.Guard>;
|
|
78
|
+
static interceptorsRecord: Record<string, P.Interceptor>;
|
|
105
79
|
static middlewareRecord: Record<string, (...params: any) => any>;
|
|
106
|
-
|
|
80
|
+
postInterceptors: Function[];
|
|
81
|
+
constructor(tag: string, data: Data);
|
|
107
82
|
usePipe(args: {
|
|
108
83
|
arg: any;
|
|
109
|
-
|
|
84
|
+
pipe?: string;
|
|
85
|
+
pipeOpts?: any;
|
|
110
86
|
type: string;
|
|
111
87
|
key: string;
|
|
112
88
|
index: number;
|
|
113
89
|
reflect: any;
|
|
114
|
-
}[]
|
|
115
|
-
static useFilter(arg: any, data: ServerCtx | ServerMergeCtx): any;
|
|
90
|
+
}[]): Promise<any[]>;
|
|
116
91
|
useFilter(arg: any): any;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
declare
|
|
123
|
-
declare
|
|
124
|
-
declare
|
|
125
|
-
declare
|
|
126
|
-
declare
|
|
127
|
-
declare const APP_SYMBOL = "__PS__";
|
|
128
|
-
|
|
129
|
-
declare const emitter: Emitter;
|
|
130
|
-
declare function Factory(Modules: (new (...args: any) => any)[], opts?: {
|
|
131
|
-
dev?: boolean;
|
|
132
|
-
file?: string;
|
|
133
|
-
}): Promise<{
|
|
134
|
-
moduleMap: Map<string, any>;
|
|
135
|
-
meta: Meta[];
|
|
136
|
-
constructorMap: Map<any, any>;
|
|
137
|
-
update: (Module: Construct) => Promise<void>;
|
|
138
|
-
}>;
|
|
139
|
-
declare class Dev {
|
|
140
|
-
[UNMOUNT_SYMBOL]: (() => void)[];
|
|
141
|
-
onUnmount(cb: () => void): void;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
interface Options {
|
|
145
|
-
dev?: boolean;
|
|
146
|
-
route?: string;
|
|
147
|
-
globalGuards?: string[];
|
|
148
|
-
globalInterceptors?: string[];
|
|
149
|
-
middlewares?: string[];
|
|
150
|
-
}
|
|
151
|
-
declare function bindApp(app: Express | Router, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, options?: Options): void;
|
|
92
|
+
useGuard(guards: string[]): Promise<void>;
|
|
93
|
+
usePostInterceptor(ret: any): Promise<any>;
|
|
94
|
+
useInterceptor(interceptors: string[]): Promise<true | undefined>;
|
|
95
|
+
static useMiddleware(middlewares: string[]): any[];
|
|
96
|
+
}
|
|
97
|
+
declare function addMiddleware(key: string, handler: (...params: any) => any): void;
|
|
98
|
+
declare function addPipe(key: string, pipe: P.Pipe): void;
|
|
99
|
+
declare function setFilter(filter: P.Filter): void;
|
|
100
|
+
declare function addGuard(key: string, handler: P.Guard): void;
|
|
101
|
+
declare function addInterceptor(key: string, handler: P.Interceptor): void;
|
|
152
102
|
|
|
153
|
-
declare function BaseParam(type: string, key: string
|
|
154
|
-
declare function
|
|
155
|
-
declare function
|
|
156
|
-
declare function
|
|
157
|
-
declare function
|
|
103
|
+
declare function BaseParam(type: string, key: string): any;
|
|
104
|
+
declare function Pipe(key?: string, opts?: any): (target: any, k: PropertyKey, index: number) => void;
|
|
105
|
+
declare function Body(key?: string): any;
|
|
106
|
+
declare function Head(key: string): any;
|
|
107
|
+
declare function Query(key?: string): any;
|
|
108
|
+
declare function Param(key: string): any;
|
|
109
|
+
declare function Arg(): any;
|
|
158
110
|
|
|
159
111
|
declare function Route(route: string, type?: string): any;
|
|
160
112
|
declare function Get(route: string): any;
|
|
@@ -163,6 +115,9 @@ declare function Put(route: string): any;
|
|
|
163
115
|
declare function Patch(route: string): any;
|
|
164
116
|
declare function Delete(route: string): any;
|
|
165
117
|
declare function Controller(route: string): any;
|
|
118
|
+
declare function Rpc(...types: ('mq' | 'redis' | string)[]): (target: any, key?: PropertyKey) => void;
|
|
119
|
+
declare function Event(isEvent?: boolean): (target: any, key?: PropertyKey) => void;
|
|
120
|
+
|
|
166
121
|
declare function Guard(...guards: string[]): any;
|
|
167
122
|
declare function Middle(...middlewares: string[]): any;
|
|
168
123
|
declare function Interceptor(...interceptors: string[]): any;
|
|
@@ -172,7 +127,48 @@ declare function Define(key: string, value: any): (target: any, k?: PropertyKey)
|
|
|
172
127
|
|
|
173
128
|
declare const defaultPipe: P.Pipe;
|
|
174
129
|
|
|
175
|
-
declare function isMerge(data: ServerCtx | ServerMergeCtx): data is ServerMergeCtx;
|
|
176
130
|
declare function resolveDep(ret: any, key: string): any;
|
|
177
131
|
|
|
178
|
-
|
|
132
|
+
declare const MERGE_SYMBOL = "__PS_MERGE__";
|
|
133
|
+
declare const UNMOUNT_SYMBOL = "__PS_UNMOUNT__";
|
|
134
|
+
declare const MODULE_SYMBOL = "__PS_MODULE__";
|
|
135
|
+
declare const META_SYMBOL = "__PS_META__";
|
|
136
|
+
declare const APP_SYMBOL = "__PS__";
|
|
137
|
+
|
|
138
|
+
declare class Dev {
|
|
139
|
+
[UNMOUNT_SYMBOL]: (() => void)[];
|
|
140
|
+
onUnmount(cb: () => void): void;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
declare abstract class PFilter {
|
|
144
|
+
constructor();
|
|
145
|
+
abstract use<C, S, E extends Exception>(error: Error | E, tag?: string, ctx?: C): S;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare abstract class PGuard {
|
|
149
|
+
abstract use<C>(tag: string, ctx: C): Promise<boolean> | boolean;
|
|
150
|
+
constructor(tag: string);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare abstract class PInterceptor {
|
|
154
|
+
abstract use<C>(tag: string, ctx: C): ((arg: any) => any) | void;
|
|
155
|
+
constructor(tag: string);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
declare abstract class PPipe {
|
|
159
|
+
constructor(key: string);
|
|
160
|
+
abstract use<C>(args: {
|
|
161
|
+
arg: any;
|
|
162
|
+
option?: any;
|
|
163
|
+
key: string;
|
|
164
|
+
type: string;
|
|
165
|
+
index: number;
|
|
166
|
+
reflect: any;
|
|
167
|
+
}, tag: string, ctx: C): Promise<any>;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare function generateRPCCode(meta: P.Meta[]): string;
|
|
171
|
+
|
|
172
|
+
declare function generateHTTPCode(meta: P.Meta[]): string;
|
|
173
|
+
|
|
174
|
+
export { APP_SYMBOL, Arg, BadGatewayException, BadRequestException, BaseParam, Body, ConflictException, Context, Controller, Define, Delete, Dev, Event, Exception, ForbiddenException, FrameworkException, Get, Guard, Head, Header, Interceptor, InvalidInputException, MERGE_SYMBOL, META_SYMBOL, MODULE_SYMBOL, Middle, NotFoundException, P, PFilter, PGuard, PInterceptor, PPipe, Param, Patch, PayloadLargeException, Pipe, Post, Put, Query, Route, Rpc, ServiceUnavailableException, TimeoutException, UNMOUNT_SYMBOL, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, addGuard, addInterceptor, addMiddleware, addPipe, defaultPipe, generateHTTPCode, generateRPCCode, guardsRecord, resolveDep, setFilter };
|