phecda-server 6.1.0 → 7.0.0-alpha.1

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.
Files changed (82) hide show
  1. package/assets/ps.json +24 -24
  2. package/bin/cli.mjs +165 -157
  3. package/dist/{chunk-NL6QBQAR.js → chunk-7YQ57BQS.js} +21 -22
  4. package/dist/chunk-GSPBHZBH.js +534 -0
  5. package/dist/{chunk-J7B24YSE.mjs → chunk-HMVLXNV3.mjs} +5 -14
  6. package/dist/{chunk-TVT62GIX.js → chunk-J5CFUN4V.js} +8 -1
  7. package/dist/{chunk-JDV2XJYE.js → chunk-MBCHNDAY.js} +27 -36
  8. package/dist/{chunk-2CFYUXPM.mjs → chunk-V7EI76QQ.mjs} +136 -141
  9. package/dist/{chunk-G7TD2VB7.mjs → chunk-WHJ5FALK.mjs} +7 -0
  10. package/dist/{chunk-3H3T54IC.mjs → chunk-XYVMNY2X.mjs} +4 -5
  11. package/dist/{core-P1CsH6jz.d.mts → core-BIcUwV18.d.mts} +1 -1
  12. package/dist/{core-BlN0Spy9.d.ts → core-CYwEPfN4.d.ts} +1 -1
  13. package/dist/helper.d.mts +4 -6
  14. package/dist/helper.d.ts +4 -6
  15. package/dist/helper.js +3 -3
  16. package/dist/helper.mjs +2 -2
  17. package/dist/{server → http}/elysia/index.d.mts +5 -5
  18. package/dist/{server → http}/elysia/index.d.ts +5 -5
  19. package/dist/{server → http}/elysia/index.js +80 -62
  20. package/dist/{server → http}/elysia/index.mjs +50 -32
  21. package/dist/{server → http}/express/index.d.mts +5 -5
  22. package/dist/{server → http}/express/index.d.ts +5 -5
  23. package/dist/{server → http}/express/index.js +71 -55
  24. package/dist/{server → http}/express/index.mjs +42 -26
  25. package/dist/{server → http}/fastify/index.d.mts +5 -5
  26. package/dist/{server → http}/fastify/index.d.ts +5 -5
  27. package/dist/{server → http}/fastify/index.js +72 -72
  28. package/dist/{server → http}/fastify/index.mjs +47 -47
  29. package/dist/{server → http}/h3/index.d.mts +5 -5
  30. package/dist/{server → http}/h3/index.d.ts +5 -5
  31. package/dist/http/h3/index.js +160 -0
  32. package/dist/{server → http}/h3/index.mjs +68 -62
  33. package/dist/{server → http}/hono/index.d.mts +5 -5
  34. package/dist/{server → http}/hono/index.d.ts +5 -5
  35. package/dist/{server → http}/hono/index.js +69 -54
  36. package/dist/{server → http}/hono/index.mjs +41 -26
  37. package/dist/{server → http}/hyper-express/index.d.mts +5 -5
  38. package/dist/{server → http}/hyper-express/index.d.ts +5 -5
  39. package/dist/{server → http}/hyper-express/index.js +69 -56
  40. package/dist/{server → http}/hyper-express/index.mjs +41 -28
  41. package/dist/{server → http}/koa/index.d.mts +5 -5
  42. package/dist/{server → http}/koa/index.d.ts +5 -5
  43. package/dist/{server → http}/koa/index.js +71 -55
  44. package/dist/{server → http}/koa/index.mjs +42 -26
  45. package/dist/index.d.mts +52 -41
  46. package/dist/index.d.ts +52 -41
  47. package/dist/index.js +59 -81
  48. package/dist/index.mjs +39 -61
  49. package/dist/{meta-KtfiBIde.d.ts → meta-BXKLFTgG.d.mts} +2 -3
  50. package/dist/{meta-KtfiBIde.d.mts → meta-BXKLFTgG.d.ts} +2 -3
  51. package/dist/rpc/bullmq/index.d.mts +6 -6
  52. package/dist/rpc/bullmq/index.d.ts +6 -6
  53. package/dist/rpc/bullmq/index.js +24 -24
  54. package/dist/rpc/bullmq/index.mjs +14 -14
  55. package/dist/rpc/kafka/index.d.mts +3 -3
  56. package/dist/rpc/kafka/index.d.ts +3 -3
  57. package/dist/rpc/kafka/index.js +25 -21
  58. package/dist/rpc/kafka/index.mjs +15 -11
  59. package/dist/rpc/nats/index.d.mts +3 -3
  60. package/dist/rpc/nats/index.d.ts +3 -3
  61. package/dist/rpc/nats/index.js +22 -21
  62. package/dist/rpc/nats/index.mjs +13 -12
  63. package/dist/rpc/rabbitmq/index.d.mts +3 -3
  64. package/dist/rpc/rabbitmq/index.d.ts +3 -3
  65. package/dist/rpc/rabbitmq/index.js +23 -22
  66. package/dist/rpc/rabbitmq/index.mjs +12 -11
  67. package/dist/rpc/redis/index.d.mts +3 -3
  68. package/dist/rpc/redis/index.d.ts +3 -3
  69. package/dist/rpc/redis/index.js +24 -20
  70. package/dist/rpc/redis/index.mjs +15 -11
  71. package/dist/test.d.mts +3 -3
  72. package/dist/test.d.ts +3 -3
  73. package/dist/test.js +6 -6
  74. package/dist/test.mjs +2 -2
  75. package/dist/{types-JVT0mgLD.d.ts → types-BtbL49Zs.d.mts} +2 -1
  76. package/dist/{types-DIw7B6Up.d.ts → types-VFzEM7LL.d.ts} +5 -5
  77. package/dist/{types-BvD3B5Ny.d.mts → types-h40T3cRG.d.mts} +5 -5
  78. package/dist/{types-t9D1fU6G.d.mts → types-m3IEDKjP.d.ts} +2 -1
  79. package/package.json +23 -23
  80. package/register/loader.mjs +366 -367
  81. package/dist/chunk-DVTBLV6I.js +0 -539
  82. package/dist/server/h3/index.js +0 -154
package/dist/index.d.mts CHANGED
@@ -1,13 +1,13 @@
1
- import { B as BaseContext, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-KtfiBIde.mjs';
2
- export { g as BaseRequestType, f as BaseReturn, a as ControllerMeta, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_HMR, k as IS_ONLY_GENERATE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, m as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-KtfiBIde.mjs';
3
- import { G as Generator } from './core-P1CsH6jz.mjs';
4
- export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-P1CsH6jz.mjs';
1
+ import { B as BaseContext, a as ControllerMeta, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-BXKLFTgG.mjs';
2
+ export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_HMR, k as IS_ONLY_GENERATE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, m as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-BXKLFTgG.mjs';
3
+ import { G as Generator } from './core-BIcUwV18.mjs';
4
+ export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-BIcUwV18.mjs';
5
5
  import { Base } from 'phecda-core';
6
6
  export * from 'phecda-core';
7
- import { H as HttpContext } from './types-BvD3B5Ny.mjs';
8
- export { C as CookieSerializeOptions, a as HttpOptions } from './types-BvD3B5Ny.mjs';
9
- import { R as RpcContext } from './types-t9D1fU6G.mjs';
10
- export { b as RpcClientOptions, a as RpcServerOptions } from './types-t9D1fU6G.mjs';
7
+ import { H as HttpContext } from './types-h40T3cRG.mjs';
8
+ export { C as CookieSerializeOptions, a as HttpOptions } from './types-h40T3cRG.mjs';
9
+ import { R as RpcContext } from './types-BtbL49Zs.mjs';
10
+ export { b as RpcClientOptions, a as RpcServerOptions } from './types-BtbL49Zs.mjs';
11
11
  export { Mixin } from 'ts-mixer';
12
12
  import 'node:http';
13
13
 
@@ -88,6 +88,11 @@ declare class WorkerException extends Exception {
88
88
  constructor(message: string);
89
89
  }
90
90
 
91
+ interface AOP {
92
+ guards: GuardType[];
93
+ pipe: PipeType[];
94
+ filter: FilterType;
95
+ }
91
96
  interface PipeArg {
92
97
  arg: any;
93
98
  pipe?: string;
@@ -97,8 +102,7 @@ interface PipeArg {
97
102
  reflect: any;
98
103
  define: Record<string, any>;
99
104
  }
100
- type GuardType<C extends BaseContext = any> = ((ctx: C) => Promise<boolean> | boolean);
101
- type InterceptorType<C extends BaseContext = any> = (ctx: C) => (any | ((ret: any) => any));
105
+ type GuardType<C extends BaseContext = any> = (ctx: C, next: () => Promise<any>) => any;
102
106
  type PipeType<C extends BaseContext = any> = (arg: PipeArg, ctx: C) => Promise<any>;
103
107
  type FilterType<C extends BaseContext = any, E extends Exception = any> = (err: E | Error, ctx?: C) => Error | any;
104
108
  declare class Context<Data extends BaseContext> {
@@ -107,24 +111,34 @@ declare class Context<Data extends BaseContext> {
107
111
  params: string[];
108
112
  static filterRecord: Record<PropertyKey, FilterType>;
109
113
  static pipeRecord: Record<PropertyKey, PipeType>;
110
- static guardRecord: Record<PropertyKey, GuardType>;
111
- static interceptorRecord: Record<PropertyKey, InterceptorType>;
112
- static pluginRecord: Record<PropertyKey, (framework: string) => any>;
113
- private postInterceptors;
114
+ static guardRecord: Record<PropertyKey, {
115
+ value: GuardType;
116
+ priority: number;
117
+ }>;
118
+ static addonRecord: Record<PropertyKey, {
119
+ value: (router: any, framework: string) => any;
120
+ priority: number;
121
+ }>;
114
122
  constructor(data: Data);
115
- run<ReturnData = any, ReturnErr = any>(opts: DefaultOptions, successCb: (data: any) => ReturnData, failCb: (err: any) => ReturnErr): Promise<ReturnData | ReturnErr>;
116
- private usePipe;
117
- private useFilter;
118
- private useGuard;
119
- private usePostInterceptor;
120
- private useInterceptor;
121
- static usePlugin<Plugin>(plugins: string[], framework: string): Plugin[];
122
- }
123
- declare function addPlugin<T>(key: PropertyKey, handler: (framework: string) => T): void;
124
- declare function addPipe<C extends BaseContext>(key: PropertyKey, handler: PipeType<C>): void;
125
- declare function addFilter<C extends BaseContext>(key: PropertyKey, handler: FilterType<C>): void;
126
- declare function addGuard<C extends BaseContext>(key: PropertyKey, handler: GuardType<C>): void;
127
- declare function addInterceptor<C extends BaseContext>(key: PropertyKey, handler: InterceptorType<C>): void;
123
+ static getAop(meta: ControllerMeta, opts: DefaultOptions): {
124
+ guards: GuardType<any>[];
125
+ pipe: PipeType<any>[];
126
+ filter: FilterType<any, any>;
127
+ };
128
+ run<ResponseData = any, ReturnErr = any>({ guards, filter, pipe, }: {
129
+ guards: GuardType[];
130
+ filter: FilterType;
131
+ pipe: PipeType[];
132
+ }, successCb: (data: any) => ResponseData, failCb: (err: any) => ReturnErr): Promise<ResponseData | ReturnErr>;
133
+ static getPipe(pipe: string[]): PipeType<any>[];
134
+ static getFilter(filter?: string): FilterType<any, any>;
135
+ static getGuards(guards: string[]): GuardType<any>[];
136
+ static applyAddons(addons: string[], router: any, framework: string): void;
137
+ }
138
+ declare function addPipe<C extends BaseContext>(key: PropertyKey, pipe: PipeType<C>): void;
139
+ declare function addFilter<C extends BaseContext>(key: PropertyKey, filter: FilterType<C>): void;
140
+ declare function addGuard<C extends BaseContext>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
141
+ declare function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority?: number): void;
128
142
 
129
143
  declare class RPCGenerator extends Generator {
130
144
  name: string;
@@ -154,8 +168,7 @@ declare function Param(key: string): ParameterDecorator;
154
168
  declare function Arg(target: any, k: string, index: number): void;
155
169
 
156
170
  declare function Guard(...guards: string[]): (target: any, property?: PropertyKey) => void;
157
- declare function Plugin(...plugins: string[]): (target: any, property?: PropertyKey) => void;
158
- declare function Interceptor(...interceptors: string[]): (target: any, property?: PropertyKey) => void;
171
+ declare function Addon(...addons: string[]): (target: any, property?: PropertyKey) => void;
159
172
  declare function Filter(filter: string): (target: any, property?: PropertyKey) => void;
160
173
  declare function Pipe(pipe?: string): (target: any, property?: any, index?: any) => void;
161
174
 
@@ -194,14 +207,9 @@ declare abstract class PFilter<C extends BaseContext = any, E extends Exception
194
207
  }
195
208
 
196
209
  declare abstract class PGuard<C extends BaseContext = any> extends ServerBase {
197
- abstract use(ctx: C): Promise<boolean> | boolean;
198
- readonly key: PropertyKey;
199
- constructor(tag?: string);
200
- }
201
-
202
- declare abstract class PInterceptor<C extends BaseContext = any> extends ServerBase {
203
- abstract use(ctx: C): Function | Promise<Function> | any;
210
+ abstract use(ctx: C, next: () => Promise<any>): any;
204
211
  readonly key: PropertyKey;
212
+ priority: number;
205
213
  constructor(tag?: string);
206
214
  }
207
215
 
@@ -218,14 +226,14 @@ declare abstract class PPipe<C extends BaseContext = any> extends ServerBase {
218
226
  }, ctx: C): any;
219
227
  }
220
228
 
221
- declare abstract class PPlugin extends ServerBase {
229
+ declare abstract class PAddon extends ServerBase {
222
230
  readonly key: PropertyKey;
231
+ priority: number;
223
232
  constructor(tag?: string);
224
- abstract use<Plugin = any>(framework: string): Plugin | undefined;
233
+ abstract use(router: any, framework: string): undefined;
225
234
  }
226
235
 
227
236
  interface PExtension<C extends BaseContext = any, E extends Exception = Exception> {
228
- intercept(ctx: C): Function | Promise<Function> | any;
229
237
  guard(ctx: C): Promise<boolean> | boolean;
230
238
  pipe(param: {
231
239
  arg: any;
@@ -236,10 +244,12 @@ interface PExtension<C extends BaseContext = any, E extends Exception = Exceptio
236
244
  reflect: any;
237
245
  }, ctx: C): any;
238
246
  filter(error: Error | E, ctx?: C): BaseError;
239
- plugin<Plugin = any>(framework: string): Plugin;
247
+ addon<Addon = any>(framework: string): Addon;
240
248
  }
241
249
  declare class PExtension extends ServerBase {
242
250
  readonly key: PropertyKey;
251
+ guardPriority: number;
252
+ addonPriority: number;
243
253
  constructor(tag?: string);
244
254
  }
245
255
 
@@ -247,5 +257,6 @@ type LogLevel = 'error' | 'info' | 'warn' | 'log' | 'debug';
247
257
  declare function setLogger(logger: Record<LogLevel, (msg: string) => void>): void;
248
258
  declare function getLogger(): Record<LogLevel, (msg: string) => void>;
249
259
  declare function log(msg: string, level?: LogLevel): void;
260
+ declare function runMiddleware(ctx: HttpContext, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
250
261
 
251
- export { Arg, BadGatewayException, BadRequestException, BaseContext, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpContext, Interceptor, type InterceptorType, InvalidInputException, MetaData, NotFoundException, PExtension, PFilter, PGuard, PInterceptor, PPipe, PPlugin, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Plugin, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcContext, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addFilter, addGuard, addInterceptor, addPipe, addPlugin, defaultPipe, getLogger, log, setLogger };
262
+ export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseContext, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpContext, InvalidInputException, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcContext, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { B as BaseContext, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-KtfiBIde.js';
2
- export { g as BaseRequestType, f as BaseReturn, a as ControllerMeta, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_HMR, k as IS_ONLY_GENERATE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, m as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-KtfiBIde.js';
3
- import { G as Generator } from './core-BlN0Spy9.js';
4
- export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-BlN0Spy9.js';
1
+ import { B as BaseContext, a as ControllerMeta, D as DefaultOptions, C as ControllerMetaData, b as MetaData, E as Emitter, c as BaseError } from './meta-BXKLFTgG.js';
2
+ export { g as BaseRequestType, f as BaseReturn, h as CustomResponse, j as ERROR_SYMBOL, i as ExtractResponse, I as IS_HMR, k as IS_ONLY_GENERATE, l as IS_STRICT, L as LOG_LEVEL, M as Meta, O as OmitFunction, m as PS_EXIT_CODE, P as PickFunc, S as ServiceMetaData, e as ToClientFn, d as ToClientInstance, T as ToClientMap } from './meta-BXKLFTgG.js';
3
+ import { G as Generator } from './core-CYwEPfN4.js';
4
+ export { F as Factory, O as Options, S as ServerPhecda, d as defaultServerInject, e as emitter, p as phecdaNamespace, u as useS } from './core-CYwEPfN4.js';
5
5
  import { Base } from 'phecda-core';
6
6
  export * from 'phecda-core';
7
- import { H as HttpContext } from './types-DIw7B6Up.js';
8
- export { C as CookieSerializeOptions, a as HttpOptions } from './types-DIw7B6Up.js';
9
- import { R as RpcContext } from './types-JVT0mgLD.js';
10
- export { b as RpcClientOptions, a as RpcServerOptions } from './types-JVT0mgLD.js';
7
+ import { H as HttpContext } from './types-VFzEM7LL.js';
8
+ export { C as CookieSerializeOptions, a as HttpOptions } from './types-VFzEM7LL.js';
9
+ import { R as RpcContext } from './types-m3IEDKjP.js';
10
+ export { b as RpcClientOptions, a as RpcServerOptions } from './types-m3IEDKjP.js';
11
11
  export { Mixin } from 'ts-mixer';
12
12
  import 'node:http';
13
13
 
@@ -88,6 +88,11 @@ declare class WorkerException extends Exception {
88
88
  constructor(message: string);
89
89
  }
90
90
 
91
+ interface AOP {
92
+ guards: GuardType[];
93
+ pipe: PipeType[];
94
+ filter: FilterType;
95
+ }
91
96
  interface PipeArg {
92
97
  arg: any;
93
98
  pipe?: string;
@@ -97,8 +102,7 @@ interface PipeArg {
97
102
  reflect: any;
98
103
  define: Record<string, any>;
99
104
  }
100
- type GuardType<C extends BaseContext = any> = ((ctx: C) => Promise<boolean> | boolean);
101
- type InterceptorType<C extends BaseContext = any> = (ctx: C) => (any | ((ret: any) => any));
105
+ type GuardType<C extends BaseContext = any> = (ctx: C, next: () => Promise<any>) => any;
102
106
  type PipeType<C extends BaseContext = any> = (arg: PipeArg, ctx: C) => Promise<any>;
103
107
  type FilterType<C extends BaseContext = any, E extends Exception = any> = (err: E | Error, ctx?: C) => Error | any;
104
108
  declare class Context<Data extends BaseContext> {
@@ -107,24 +111,34 @@ declare class Context<Data extends BaseContext> {
107
111
  params: string[];
108
112
  static filterRecord: Record<PropertyKey, FilterType>;
109
113
  static pipeRecord: Record<PropertyKey, PipeType>;
110
- static guardRecord: Record<PropertyKey, GuardType>;
111
- static interceptorRecord: Record<PropertyKey, InterceptorType>;
112
- static pluginRecord: Record<PropertyKey, (framework: string) => any>;
113
- private postInterceptors;
114
+ static guardRecord: Record<PropertyKey, {
115
+ value: GuardType;
116
+ priority: number;
117
+ }>;
118
+ static addonRecord: Record<PropertyKey, {
119
+ value: (router: any, framework: string) => any;
120
+ priority: number;
121
+ }>;
114
122
  constructor(data: Data);
115
- run<ReturnData = any, ReturnErr = any>(opts: DefaultOptions, successCb: (data: any) => ReturnData, failCb: (err: any) => ReturnErr): Promise<ReturnData | ReturnErr>;
116
- private usePipe;
117
- private useFilter;
118
- private useGuard;
119
- private usePostInterceptor;
120
- private useInterceptor;
121
- static usePlugin<Plugin>(plugins: string[], framework: string): Plugin[];
122
- }
123
- declare function addPlugin<T>(key: PropertyKey, handler: (framework: string) => T): void;
124
- declare function addPipe<C extends BaseContext>(key: PropertyKey, handler: PipeType<C>): void;
125
- declare function addFilter<C extends BaseContext>(key: PropertyKey, handler: FilterType<C>): void;
126
- declare function addGuard<C extends BaseContext>(key: PropertyKey, handler: GuardType<C>): void;
127
- declare function addInterceptor<C extends BaseContext>(key: PropertyKey, handler: InterceptorType<C>): void;
123
+ static getAop(meta: ControllerMeta, opts: DefaultOptions): {
124
+ guards: GuardType<any>[];
125
+ pipe: PipeType<any>[];
126
+ filter: FilterType<any, any>;
127
+ };
128
+ run<ResponseData = any, ReturnErr = any>({ guards, filter, pipe, }: {
129
+ guards: GuardType[];
130
+ filter: FilterType;
131
+ pipe: PipeType[];
132
+ }, successCb: (data: any) => ResponseData, failCb: (err: any) => ReturnErr): Promise<ResponseData | ReturnErr>;
133
+ static getPipe(pipe: string[]): PipeType<any>[];
134
+ static getFilter(filter?: string): FilterType<any, any>;
135
+ static getGuards(guards: string[]): GuardType<any>[];
136
+ static applyAddons(addons: string[], router: any, framework: string): void;
137
+ }
138
+ declare function addPipe<C extends BaseContext>(key: PropertyKey, pipe: PipeType<C>): void;
139
+ declare function addFilter<C extends BaseContext>(key: PropertyKey, filter: FilterType<C>): void;
140
+ declare function addGuard<C extends BaseContext>(key: PropertyKey, guard: GuardType<C>, priority?: number): void;
141
+ declare function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority?: number): void;
128
142
 
129
143
  declare class RPCGenerator extends Generator {
130
144
  name: string;
@@ -154,8 +168,7 @@ declare function Param(key: string): ParameterDecorator;
154
168
  declare function Arg(target: any, k: string, index: number): void;
155
169
 
156
170
  declare function Guard(...guards: string[]): (target: any, property?: PropertyKey) => void;
157
- declare function Plugin(...plugins: string[]): (target: any, property?: PropertyKey) => void;
158
- declare function Interceptor(...interceptors: string[]): (target: any, property?: PropertyKey) => void;
171
+ declare function Addon(...addons: string[]): (target: any, property?: PropertyKey) => void;
159
172
  declare function Filter(filter: string): (target: any, property?: PropertyKey) => void;
160
173
  declare function Pipe(pipe?: string): (target: any, property?: any, index?: any) => void;
161
174
 
@@ -194,14 +207,9 @@ declare abstract class PFilter<C extends BaseContext = any, E extends Exception
194
207
  }
195
208
 
196
209
  declare abstract class PGuard<C extends BaseContext = any> extends ServerBase {
197
- abstract use(ctx: C): Promise<boolean> | boolean;
198
- readonly key: PropertyKey;
199
- constructor(tag?: string);
200
- }
201
-
202
- declare abstract class PInterceptor<C extends BaseContext = any> extends ServerBase {
203
- abstract use(ctx: C): Function | Promise<Function> | any;
210
+ abstract use(ctx: C, next: () => Promise<any>): any;
204
211
  readonly key: PropertyKey;
212
+ priority: number;
205
213
  constructor(tag?: string);
206
214
  }
207
215
 
@@ -218,14 +226,14 @@ declare abstract class PPipe<C extends BaseContext = any> extends ServerBase {
218
226
  }, ctx: C): any;
219
227
  }
220
228
 
221
- declare abstract class PPlugin extends ServerBase {
229
+ declare abstract class PAddon extends ServerBase {
222
230
  readonly key: PropertyKey;
231
+ priority: number;
223
232
  constructor(tag?: string);
224
- abstract use<Plugin = any>(framework: string): Plugin | undefined;
233
+ abstract use(router: any, framework: string): undefined;
225
234
  }
226
235
 
227
236
  interface PExtension<C extends BaseContext = any, E extends Exception = Exception> {
228
- intercept(ctx: C): Function | Promise<Function> | any;
229
237
  guard(ctx: C): Promise<boolean> | boolean;
230
238
  pipe(param: {
231
239
  arg: any;
@@ -236,10 +244,12 @@ interface PExtension<C extends BaseContext = any, E extends Exception = Exceptio
236
244
  reflect: any;
237
245
  }, ctx: C): any;
238
246
  filter(error: Error | E, ctx?: C): BaseError;
239
- plugin<Plugin = any>(framework: string): Plugin;
247
+ addon<Addon = any>(framework: string): Addon;
240
248
  }
241
249
  declare class PExtension extends ServerBase {
242
250
  readonly key: PropertyKey;
251
+ guardPriority: number;
252
+ addonPriority: number;
243
253
  constructor(tag?: string);
244
254
  }
245
255
 
@@ -247,5 +257,6 @@ type LogLevel = 'error' | 'info' | 'warn' | 'log' | 'debug';
247
257
  declare function setLogger(logger: Record<LogLevel, (msg: string) => void>): void;
248
258
  declare function getLogger(): Record<LogLevel, (msg: string) => void>;
249
259
  declare function log(msg: string, level?: LogLevel): void;
260
+ declare function runMiddleware(ctx: HttpContext, middleware: (req: any, res: any, next?: any) => any): Promise<unknown>;
250
261
 
251
- export { Arg, BadGatewayException, BadRequestException, BaseContext, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpContext, Interceptor, type InterceptorType, InvalidInputException, MetaData, NotFoundException, PExtension, PFilter, PGuard, PInterceptor, PPipe, PPlugin, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Plugin, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcContext, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addFilter, addGuard, addInterceptor, addPipe, addPlugin, defaultPipe, getLogger, log, setLogger };
262
+ export { type AOP, Addon, Arg, BadGatewayException, BadRequestException, BaseContext, BaseError, BaseParam, Body, ConflictException, Context, Controller, ControllerMeta, ControllerMetaData, Ctx, DefaultOptions, Define, Delete, Emitter, Exception, Filter, type FilterType, ForbiddenException, FrameworkException, Generator, Get, Guard, type GuardType, HTTPGenerator, Head, Header, HttpBase, HttpContext, InvalidInputException, MetaData, NotFoundException, PAddon, PExtension, PFilter, PGuard, PPipe, Param, Patch, PayloadLargeException, Pipe, type PipeArg, type PipeType, Post, Put, Query, Queue, RPCGenerator, Route, Rpc, RpcBase, RpcContext, Search, ServerBase, ServiceUnavailableException, TimeoutException, TimerException, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, WorkerException, addAddon, addFilter, addGuard, addPipe, defaultPipe, getLogger, log, runMiddleware, setLogger };