phecda-server 5.0.0-beta.20 → 5.0.0-beta.21

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.
@@ -197,7 +197,6 @@ var Histroy = (_class = class {constructor() { _class.prototype.__init.call(this
197
197
  _chunkXHKBG2VAjs.__name.call(void 0, Histroy, "Histroy");
198
198
 
199
199
  // src/context.ts
200
- var guardRecord = {};
201
200
  var _Context = class {
202
201
 
203
202
 
@@ -300,25 +299,25 @@ function addPlugin(key, handler) {
300
299
  _chunkXHKBG2VAjs.__name.call(void 0, addPlugin, "addPlugin");
301
300
  function addPipe(key, handler) {
302
301
  if (Context.pipeRecord[key] && Context.pipeRecord[key] !== handler)
303
- _chunkXHKBG2VAjs.log.call(void 0, `overwrite Pipe "${String(key)}"`, "warn");
302
+ _chunkXHKBG2VAjs.log.call(void 0, `overwrite PipeType "${String(key)}"`, "warn");
304
303
  Context.pipeRecord[key] = handler;
305
304
  }
306
305
  _chunkXHKBG2VAjs.__name.call(void 0, addPipe, "addPipe");
307
306
  function addFilter(key, handler) {
308
307
  if (Context.filterRecord[key] && Context.filterRecord[key] !== handler)
309
- _chunkXHKBG2VAjs.log.call(void 0, `overwrite Filter "${String(key)}"`, "warn");
308
+ _chunkXHKBG2VAjs.log.call(void 0, `overwrite FilterType "${String(key)}"`, "warn");
310
309
  Context.filterRecord[key] = handler;
311
310
  }
312
311
  _chunkXHKBG2VAjs.__name.call(void 0, addFilter, "addFilter");
313
312
  function addGuard(key, handler) {
314
313
  if (Context.guardRecord[key] && Context.guardRecord[key] !== handler)
315
- _chunkXHKBG2VAjs.log.call(void 0, `overwrite Guard "${String(key)}"`, "warn");
314
+ _chunkXHKBG2VAjs.log.call(void 0, `overwrite GuardType "${String(key)}"`, "warn");
316
315
  Context.guardRecord[key] = handler;
317
316
  }
318
317
  _chunkXHKBG2VAjs.__name.call(void 0, addGuard, "addGuard");
319
318
  function addInterceptor(key, handler) {
320
319
  if (Context.interceptorRecord[key] && Context.interceptorRecord[key] !== handler)
321
- _chunkXHKBG2VAjs.log.call(void 0, `overwrite Interceptor "${String(key)}"`, "warn");
320
+ _chunkXHKBG2VAjs.log.call(void 0, `overwrite InterceptorType "${String(key)}"`, "warn");
322
321
  Context.interceptorRecord[key] = handler;
323
322
  }
324
323
  _chunkXHKBG2VAjs.__name.call(void 0, addInterceptor, "addInterceptor");
@@ -357,13 +356,13 @@ function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
357
356
  if (missPlugins.length)
358
357
  _chunkXHKBG2VAjs.log.call(void 0, `${_picocolors2.default.white(`Plugin [${missPlugins.join(",")}]`)} doesn't exist`, "warn");
359
358
  if (missGuards.length)
360
- _chunkXHKBG2VAjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
359
+ _chunkXHKBG2VAjs.log.call(void 0, `${_picocolors2.default.magenta(`GuardType [${missGuards.join(",")}]`)} doesn't exist`, "warn");
361
360
  if (missInterceptors.length)
362
- _chunkXHKBG2VAjs.log.call(void 0, `${_picocolors2.default.cyan(`Interceptor [${missInterceptors.join(",")}]`)} doesn't exist`, "warn");
361
+ _chunkXHKBG2VAjs.log.call(void 0, `${_picocolors2.default.cyan(`InterceptorType [${missInterceptors.join(",")}]`)} doesn't exist`, "warn");
363
362
  if (missPipes.length)
364
- _chunkXHKBG2VAjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
363
+ _chunkXHKBG2VAjs.log.call(void 0, `${_picocolors2.default.blue(`PipeType [${missPipes.join(",")}]`)} doesn't exist`, "warn");
365
364
  if (missFilters.length)
366
- _chunkXHKBG2VAjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
365
+ _chunkXHKBG2VAjs.log.call(void 0, `${_picocolors2.default.red(`FilterType [${missFilters.join(",")}]`)} doesn't exist`, "warn");
367
366
  }
368
367
  _chunkXHKBG2VAjs.__name.call(void 0, isAopDepInject, "isAopDepInject");
369
368
 
@@ -391,5 +390,4 @@ _chunkXHKBG2VAjs.__name.call(void 0, isAopDepInject, "isAopDepInject");
391
390
 
392
391
 
393
392
 
394
-
395
- exports.Exception = Exception; exports.ValidateException = ValidateException; exports.defaultPipe = defaultPipe; exports.UndefinedException = UndefinedException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.guardRecord = guardRecord; exports.Context = Context; exports.addPlugin = addPlugin; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addInterceptor = addInterceptor; exports.isAopDepInject = isAopDepInject;
393
+ exports.Exception = Exception; exports.ValidateException = ValidateException; exports.defaultPipe = defaultPipe; exports.UndefinedException = UndefinedException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.Context = Context; exports.addPlugin = addPlugin; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addInterceptor = addInterceptor; exports.isAopDepInject = isAopDepInject;
@@ -197,7 +197,6 @@ var Histroy = class {
197
197
  __name(Histroy, "Histroy");
198
198
 
199
199
  // src/context.ts
200
- var guardRecord = {};
201
200
  var _Context = class {
202
201
  data;
203
202
  method;
@@ -300,25 +299,25 @@ function addPlugin(key, handler) {
300
299
  __name(addPlugin, "addPlugin");
301
300
  function addPipe(key, handler) {
302
301
  if (Context.pipeRecord[key] && Context.pipeRecord[key] !== handler)
303
- log(`overwrite Pipe "${String(key)}"`, "warn");
302
+ log(`overwrite PipeType "${String(key)}"`, "warn");
304
303
  Context.pipeRecord[key] = handler;
305
304
  }
306
305
  __name(addPipe, "addPipe");
307
306
  function addFilter(key, handler) {
308
307
  if (Context.filterRecord[key] && Context.filterRecord[key] !== handler)
309
- log(`overwrite Filter "${String(key)}"`, "warn");
308
+ log(`overwrite FilterType "${String(key)}"`, "warn");
310
309
  Context.filterRecord[key] = handler;
311
310
  }
312
311
  __name(addFilter, "addFilter");
313
312
  function addGuard(key, handler) {
314
313
  if (Context.guardRecord[key] && Context.guardRecord[key] !== handler)
315
- log(`overwrite Guard "${String(key)}"`, "warn");
314
+ log(`overwrite GuardType "${String(key)}"`, "warn");
316
315
  Context.guardRecord[key] = handler;
317
316
  }
318
317
  __name(addGuard, "addGuard");
319
318
  function addInterceptor(key, handler) {
320
319
  if (Context.interceptorRecord[key] && Context.interceptorRecord[key] !== handler)
321
- log(`overwrite Interceptor "${String(key)}"`, "warn");
320
+ log(`overwrite InterceptorType "${String(key)}"`, "warn");
322
321
  Context.interceptorRecord[key] = handler;
323
322
  }
324
323
  __name(addInterceptor, "addInterceptor");
@@ -357,13 +356,13 @@ function isAopDepInject(meta, { guards, interceptors, plugins } = {}) {
357
356
  if (missPlugins.length)
358
357
  log(`${pc.white(`Plugin [${missPlugins.join(",")}]`)} doesn't exist`, "warn");
359
358
  if (missGuards.length)
360
- log(`${pc.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
359
+ log(`${pc.magenta(`GuardType [${missGuards.join(",")}]`)} doesn't exist`, "warn");
361
360
  if (missInterceptors.length)
362
- log(`${pc.cyan(`Interceptor [${missInterceptors.join(",")}]`)} doesn't exist`, "warn");
361
+ log(`${pc.cyan(`InterceptorType [${missInterceptors.join(",")}]`)} doesn't exist`, "warn");
363
362
  if (missPipes.length)
364
- log(`${pc.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
363
+ log(`${pc.blue(`PipeType [${missPipes.join(",")}]`)} doesn't exist`, "warn");
365
364
  if (missFilters.length)
366
- log(`${pc.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
365
+ log(`${pc.red(`FilterType [${missFilters.join(",")}]`)} doesn't exist`, "warn");
367
366
  }
368
367
  __name(isAopDepInject, "isAopDepInject");
369
368
 
@@ -384,7 +383,6 @@ export {
384
383
  UnauthorizedException,
385
384
  ServiceUnavailableException,
386
385
  FrameworkException,
387
- guardRecord,
388
386
  Context,
389
387
  addPlugin,
390
388
  addPipe,
@@ -1,19 +1,6 @@
1
1
  import { Events, Construct } from 'phecda-core';
2
2
  import { IncomingHttpHeaders } from 'node:http';
3
3
 
4
- declare class Exception extends Error {
5
- message: string;
6
- status: number;
7
- description: string;
8
- constructor(message: string, status: number, description?: string);
9
- get data(): {
10
- message: string;
11
- description: string;
12
- status: number;
13
- __PS_ERROR__: boolean;
14
- };
15
- }
16
-
17
4
  declare const MERGE_SYMBOL = "__PS_MERGE__";
18
5
  declare const UNMOUNT_SYMBOL = "__PS_UNMOUNT__";
19
6
  declare const MODULE_SYMBOL = "__PS_MODULE__";
@@ -26,27 +13,39 @@ declare const ERROR_SYMBOL = "__PS_ERROR__";
26
13
  declare const PS_FILE_RE: RegExp;
27
14
  declare const PS_IMPORT_RE: RegExp;
28
15
 
16
+ interface MetaData {
17
+ http?: {
18
+ type: P.RequestType;
19
+ route: string;
20
+ };
21
+ rpc?: {
22
+ type: string[];
23
+ isEvent: boolean;
24
+ };
25
+ ctx?: string;
26
+ define?: any;
27
+ header: Record<string, string>;
28
+ params: {
29
+ type: string;
30
+ index: number;
31
+ key: string;
32
+ pipe?: string;
33
+ pipeOpts?: any;
34
+ }[];
35
+ guards: string[];
36
+ filter?: string;
37
+ interceptors: string[];
38
+ plugins: string[];
39
+ method: string;
40
+ name: string;
41
+ tag: PropertyKey;
42
+ }
29
43
  declare class Meta {
30
- data: P.MetaData;
44
+ data: MetaData;
31
45
  paramsType: any[];
32
- constructor(data: P.MetaData, paramsType: any[]);
46
+ constructor(data: MetaData, paramsType: any[]);
33
47
  }
34
48
 
35
- interface Emitter {
36
- on<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void;
37
- once<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void;
38
- off<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void;
39
- removeAllListeners<N extends keyof Events>(eventName: N): void;
40
- emit<N extends keyof Events>(eventName: N, param: Events[N]): void;
41
- }
42
- type ToControllerMap<T = any> = {
43
- [K in keyof T]: T[K] extends (new (...args: any) => any) ? PickFunc<InstanceType<T[K]>> : void;
44
- };
45
- type PickKeysByValue<Type, Value> = {
46
- [Key in keyof Type]: Type[Key] extends Value ? Key : never;
47
- }[keyof Type];
48
- type PickFunc<T> = Pick<T, PickKeysByValue<T, (...args: any) => any>>;
49
- type RequestType = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
50
49
  declare namespace P {
51
50
  interface BaseContext {
52
51
  meta: Meta;
@@ -62,6 +61,7 @@ declare namespace P {
62
61
  body: Record<string, any>;
63
62
  headers: IncomingHttpHeaders;
64
63
  index?: number;
64
+ data: any;
65
65
  }
66
66
  interface Error {
67
67
  [ERROR_SYMBOL]: true;
@@ -69,52 +69,32 @@ declare namespace P {
69
69
  message: string;
70
70
  description: string;
71
71
  }
72
- type ResOrErr<R> = {
73
- [K in keyof R]: Awaited<R[K]> | Error;
74
- };
75
- type Res<T> = T extends {
72
+ type Ret<T> = Awaited<T> extends {
76
73
  toJSON(): infer R;
77
- } ? R : T;
78
- type Guard<C extends BaseContext = any> = ((ctx: C) => Promise<boolean> | boolean);
79
- type Interceptor<C extends BaseContext = any> = (ctx: C) => (any | ((ret: any) => any));
80
- type Pipe<C extends BaseContext = any> = (arg: {
81
- arg: any;
82
- option?: any;
83
- key: string;
84
- type: string;
85
- index: number;
86
- reflect: any;
87
- }, ctx: C) => Promise<any>;
88
- type Filter<C extends BaseContext = any, E extends Exception = any> = (err: E | Error, ctx?: C) => Error | any;
89
- interface MetaData {
90
- http?: {
91
- type: RequestType;
92
- route: string;
93
- };
94
- rpc?: {
95
- type: string[];
96
- isEvent: boolean;
97
- };
98
- ctx?: string;
99
- define?: any;
100
- header: Record<string, string>;
101
- params: {
102
- type: string;
103
- index: number;
104
- key: string;
105
- pipe?: string;
106
- pipeOpts?: any;
107
- }[];
108
- guards: string[];
109
- filter?: string;
110
- interceptors: string[];
111
- plugins: string[];
112
- method: string;
113
- name: string;
114
- tag: PropertyKey;
115
- }
74
+ } ? R : Awaited<T>;
75
+ type RequestType = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head';
116
76
  }
117
77
 
78
+ interface Emitter {
79
+ on<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void;
80
+ once<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void;
81
+ off<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void;
82
+ removeAllListeners<N extends keyof Events>(eventName: N): void;
83
+ emit<N extends keyof Events>(eventName: N, param: Events[N]): void;
84
+ }
85
+ type ToClientMap<T = any> = {
86
+ [K in keyof T]: T[K] extends (new (...args: any) => any) ? ToClientInstance<PickFunc<InstanceType<T[K]>>> : void;
87
+ };
88
+ type ToClientInstance<R extends Record<string, (...args: any) => any>> = {
89
+ [K in keyof R]: ToClientFn<R[K]>;
90
+ };
91
+ type ToClientFn<T extends (...args: any) => any> = (...p: Parameters<T>) => Promise<P.Ret<ReturnType<T>>>;
92
+ type PickKeysByValue<Type, Value> = {
93
+ [Key in keyof Type]: Type[Key] extends Value ? Key : never;
94
+ }[keyof Type];
95
+ type PickFunc<T> = Pick<T, PickKeysByValue<T, (...args: any) => any>>;
96
+ type OmitFunction<T> = Omit<T, PickKeysByValue<T, (...args: any) => any>>;
97
+
118
98
  declare function Injectable(): (target: any) => void;
119
99
  declare const emitter: Emitter;
120
100
  declare function Factory(models: (new (...args: any) => any)[], opts?: {
@@ -129,4 +109,4 @@ declare function Factory(models: (new (...args: any) => any)[], opts?: {
129
109
  destroy: () => Promise<void>;
130
110
  }>;
131
111
 
132
- export { APP_SYMBOL as A, Exception as E, Factory as F, Injectable as I, Meta as M, P, RequestType as R, ToControllerMap as T, UNMOUNT_SYMBOL as U, Emitter as a, PickKeysByValue as b, PickFunc as c, MERGE_SYMBOL as d, emitter as e, MODULE_SYMBOL as f, META_SYMBOL as g, IS_DEV as h, IS_STRICT as i, IS_LOG_BAN as j, ERROR_SYMBOL as k, PS_FILE_RE as l, PS_IMPORT_RE as m };
112
+ export { APP_SYMBOL as A, Emitter as E, Factory as F, Injectable as I, Meta as M, OmitFunction as O, P, ToClientMap as T, UNMOUNT_SYMBOL as U, MetaData as a, ToClientInstance as b, ToClientFn as c, PickFunc as d, emitter as e, MERGE_SYMBOL as f, MODULE_SYMBOL as g, META_SYMBOL as h, IS_DEV as i, IS_STRICT as j, IS_LOG_BAN as k, ERROR_SYMBOL as l, PS_FILE_RE as m, PS_IMPORT_RE as n };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as Exception, P, M as Meta, U as UNMOUNT_SYMBOL } from './core-d11fe855.js';
2
- export { A as APP_SYMBOL, k as ERROR_SYMBOL, a as Emitter, F as Factory, h as IS_DEV, j as IS_LOG_BAN, i as IS_STRICT, I as Injectable, d as MERGE_SYMBOL, g as META_SYMBOL, f as MODULE_SYMBOL, l as PS_FILE_RE, m as PS_IMPORT_RE, c as PickFunc, b as PickKeysByValue, R as RequestType, T as ToControllerMap, e as emitter } from './core-d11fe855.js';
1
+ import { P, M as Meta, U as UNMOUNT_SYMBOL, a as MetaData } from './core-895ed04d.js';
2
+ export { A as APP_SYMBOL, l as ERROR_SYMBOL, E as Emitter, F as Factory, i as IS_DEV, k as IS_LOG_BAN, j as IS_STRICT, I as Injectable, f as MERGE_SYMBOL, h as META_SYMBOL, g as MODULE_SYMBOL, O as OmitFunction, m as PS_FILE_RE, n as PS_IMPORT_RE, d as PickFunc, c as ToClientFn, b as ToClientInstance, T as ToClientMap, e as emitter } from './core-895ed04d.js';
3
3
  import { Construct, AbConstruct } from 'phecda-core';
4
4
  export * from 'phecda-core';
5
5
  import 'node:http';
@@ -10,6 +10,19 @@ declare class Histroy {
10
10
  record(name: string, type: 'guard' | 'interceptor'): boolean;
11
11
  }
12
12
 
13
+ declare class Exception extends Error {
14
+ message: string;
15
+ status: number;
16
+ description: string;
17
+ constructor(message: string, status: number, description?: string);
18
+ get data(): {
19
+ message: string;
20
+ description: string;
21
+ status: number;
22
+ __PS_ERROR__: boolean;
23
+ };
24
+ }
25
+
13
26
  declare class UndefinedException extends Exception {
14
27
  constructor(message: string);
15
28
  }
@@ -66,16 +79,26 @@ declare class FrameworkException extends Exception {
66
79
  constructor(message: string);
67
80
  }
68
81
 
69
- declare const guardRecord: Record<string, P.Guard<any>>;
82
+ type GuardType<C extends P.BaseContext = any> = ((ctx: C) => Promise<boolean> | boolean);
83
+ type InterceptorType<C extends P.BaseContext = any> = (ctx: C) => (any | ((ret: any) => any));
84
+ type PipeType<C extends P.BaseContext = any> = (arg: {
85
+ arg: any;
86
+ option?: any;
87
+ key: string;
88
+ type: string;
89
+ index: number;
90
+ reflect: any;
91
+ }, ctx: C) => Promise<any>;
92
+ type FilterType<C extends P.BaseContext = any, E extends Exception = any> = (err: E | Error, ctx?: C) => Error | any;
70
93
  declare class Context<Data extends P.BaseContext> {
71
94
  data: Data;
72
95
  method: string;
73
96
  params: string[];
74
97
  history: Histroy;
75
- static filterRecord: Record<PropertyKey, P.Filter>;
76
- static pipeRecord: Record<PropertyKey, P.Pipe>;
77
- static guardRecord: Record<PropertyKey, P.Guard>;
78
- static interceptorRecord: Record<PropertyKey, P.Interceptor>;
98
+ static filterRecord: Record<PropertyKey, FilterType>;
99
+ static pipeRecord: Record<PropertyKey, PipeType>;
100
+ static guardRecord: Record<PropertyKey, GuardType>;
101
+ static interceptorRecord: Record<PropertyKey, InterceptorType>;
79
102
  static pluginRecord: Record<PropertyKey, any>;
80
103
  postInterceptors: Function[];
81
104
  constructor(data: Data);
@@ -95,10 +118,10 @@ declare class Context<Data extends P.BaseContext> {
95
118
  static usePlugin(plugins: string[]): any[];
96
119
  }
97
120
  declare function addPlugin<T>(key: PropertyKey, handler: T): void;
98
- declare function addPipe<C extends P.BaseContext>(key: PropertyKey, handler: P.Pipe<C>): void;
99
- declare function addFilter<C extends P.BaseContext>(key: PropertyKey, handler: P.Filter<C>): void;
100
- declare function addGuard<C extends P.BaseContext>(key: PropertyKey, handler: P.Guard<C>): void;
101
- declare function addInterceptor<C extends P.BaseContext>(key: PropertyKey, handler: P.Interceptor<C>): void;
121
+ declare function addPipe<C extends P.BaseContext>(key: PropertyKey, handler: PipeType<C>): void;
122
+ declare function addFilter<C extends P.BaseContext>(key: PropertyKey, handler: FilterType<C>): void;
123
+ declare function addGuard<C extends P.BaseContext>(key: PropertyKey, handler: GuardType<C>): void;
124
+ declare function addInterceptor<C extends P.BaseContext>(key: PropertyKey, handler: InterceptorType<C>): void;
102
125
  declare function isAopDepInject(meta: Meta[], { guards, interceptors, plugins }?: {
103
126
  guards?: string[];
104
127
  interceptors?: string[];
@@ -132,7 +155,7 @@ declare function Header(name: string, value: string): (target: any, k: PropertyK
132
155
  declare function Ctx(target: any, key: PropertyKey): void;
133
156
  declare function Define(key: string, value: any): (target: any, k?: PropertyKey) => void;
134
157
 
135
- declare const defaultPipe: P.Pipe;
158
+ declare const defaultPipe: PipeType;
136
159
 
137
160
  declare function resolveDep(ret: any, key: string): any;
138
161
  declare function argToReq(params: Meta['data']['params'], args: any[], headers: Record<string, any>): any;
@@ -200,13 +223,13 @@ declare class PExtension extends Dev {
200
223
  constructor(tag?: string);
201
224
  }
202
225
 
203
- declare function generateRPCCode(meta: P.MetaData[]): string;
226
+ declare function generateRPCCode(meta: MetaData[]): string;
204
227
 
205
- declare function generateHTTPCode(meta: P.MetaData[]): string;
228
+ declare function generateHTTPCode(meta: MetaData[]): string;
206
229
 
207
230
  declare function log(msg: string, level?: 'error' | 'info' | 'warn'): void;
208
231
  declare function getConfig<C = any>(key: string, defaultConf?: C): C;
209
232
  declare function setConfig<C = any>(key: string, conf: C, force?: boolean): void;
210
233
  declare function Mix<C1 extends Construct | AbConstruct, C2 extends Construct>(InternalClass: C1, ExtendClass: C2): new (...args: ConstructorParameters<C2>) => InstanceType<C1> & InstanceType<C2>;
211
234
 
212
- export { Arg, BadGatewayException, BadRequestException, BaseParam, Body, ConflictException, Context, Controller, Ctx, Define, Delete, Dev, Event, Exception, Filter, ForbiddenException, FrameworkException, Get, Guard, Head, Header, Interceptor, InvalidInputException, Meta, Mix, NotFoundException, P, PExtension, PFilter, PGuard, PInterceptor, PPipe, PPlugin, Param, Patch, PayloadLargeException, Pipe, Plugin, Post, Put, Query, Route, Rpc, ServiceUnavailableException, TimeoutException, UNMOUNT_SYMBOL, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, addFilter, addGuard, addInterceptor, addPipe, addPlugin, argToReq, defaultPipe, generateHTTPCode, generateRPCCode, getConfig, guardRecord, isAopDepInject, log, resolveDep, setConfig };
235
+ export { Arg, BadGatewayException, BadRequestException, BaseParam, Body, ConflictException, Context, Controller, Ctx, Define, Delete, Dev, Event, Exception, Filter, FilterType, ForbiddenException, FrameworkException, Get, Guard, GuardType, Head, Header, Interceptor, InterceptorType, InvalidInputException, Meta, MetaData, Mix, NotFoundException, P, PExtension, PFilter, PGuard, PInterceptor, PPipe, PPlugin, Param, Patch, PayloadLargeException, Pipe, PipeType, Plugin, Post, Put, Query, Route, Rpc, ServiceUnavailableException, TimeoutException, UNMOUNT_SYMBOL, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, addFilter, addGuard, addInterceptor, addPipe, addPlugin, argToReq, defaultPipe, generateHTTPCode, generateRPCCode, getConfig, isAopDepInject, log, resolveDep, setConfig };
package/dist/index.js CHANGED
@@ -34,8 +34,7 @@ var _chunkEVF2CXTPjs = require('./chunk-EVF2CXTP.js');
34
34
 
35
35
 
36
36
 
37
-
38
- var _chunkWNTTAFLCjs = require('./chunk-WNTTAFLC.js');
37
+ var _chunk562XCEUUjs = require('./chunk-562XCEUU.js');
39
38
 
40
39
 
41
40
 
@@ -330,9 +329,9 @@ var PFilter = class extends Dev {
330
329
  constructor(tag) {
331
330
  super();
332
331
  this.key = tag || _phecdacore.getTag.call(void 0, this);
333
- _chunkWNTTAFLCjs.addFilter.call(void 0, this.key, this.use.bind(this));
332
+ _chunk562XCEUUjs.addFilter.call(void 0, this.key, this.use.bind(this));
334
333
  this.onUnmount(() => {
335
- delete _chunkWNTTAFLCjs.Context.filterRecord[this.key];
334
+ delete _chunk562XCEUUjs.Context.filterRecord[this.key];
336
335
  });
337
336
  }
338
337
  };
@@ -345,9 +344,9 @@ var PGuard = class extends Dev {
345
344
  constructor(tag) {
346
345
  super();
347
346
  this.key = tag || _phecdacore.getTag.call(void 0, this);
348
- _chunkWNTTAFLCjs.addGuard.call(void 0, this.key, this.use.bind(this));
347
+ _chunk562XCEUUjs.addGuard.call(void 0, this.key, this.use.bind(this));
349
348
  this.onUnmount(() => {
350
- delete _chunkWNTTAFLCjs.Context.guardRecord[this.key];
349
+ delete _chunk562XCEUUjs.Context.guardRecord[this.key];
351
350
  });
352
351
  }
353
352
  };
@@ -361,9 +360,9 @@ var PInterceptor = class extends Dev {
361
360
  super();
362
361
  this.key = tag || _phecdacore.getTag.call(void 0, this);
363
362
  this.onUnmount(() => {
364
- delete _chunkWNTTAFLCjs.Context.interceptorRecord[this.key];
363
+ delete _chunk562XCEUUjs.Context.interceptorRecord[this.key];
365
364
  });
366
- _chunkWNTTAFLCjs.addInterceptor.call(void 0, this.key, this.use.bind(this));
365
+ _chunk562XCEUUjs.addInterceptor.call(void 0, this.key, this.use.bind(this));
367
366
  }
368
367
  };
369
368
  _chunkXHKBG2VAjs.__name.call(void 0, PInterceptor, "PInterceptor");
@@ -375,9 +374,9 @@ var PPipe = class extends Dev {
375
374
  constructor(tag) {
376
375
  super();
377
376
  this.key = tag || _phecdacore.getTag.call(void 0, this);
378
- _chunkWNTTAFLCjs.addPipe.call(void 0, this.key, this.use.bind(this));
377
+ _chunk562XCEUUjs.addPipe.call(void 0, this.key, this.use.bind(this));
379
378
  this.onUnmount(() => {
380
- delete _chunkWNTTAFLCjs.Context.pipeRecord[this.key];
379
+ delete _chunk562XCEUUjs.Context.pipeRecord[this.key];
381
380
  });
382
381
  }
383
382
  };
@@ -390,9 +389,9 @@ var PPlugin = class extends Dev {
390
389
  constructor(tag) {
391
390
  super();
392
391
  this.key = tag || _phecdacore.getTag.call(void 0, this);
393
- _chunkWNTTAFLCjs.addPlugin.call(void 0, this.key, this.use.bind(this));
392
+ _chunk562XCEUUjs.addPlugin.call(void 0, this.key, this.use.bind(this));
394
393
  this.onUnmount(() => {
395
- delete _chunkWNTTAFLCjs.Context.pluginRecord[this.key];
394
+ delete _chunk562XCEUUjs.Context.pluginRecord[this.key];
396
395
  });
397
396
  }
398
397
  };
@@ -406,33 +405,33 @@ var PExtension = class extends Dev {
406
405
  super();
407
406
  const key = this.key = tag || _phecdacore.getTag.call(void 0, this);
408
407
  if (this.pipe) {
409
- _chunkWNTTAFLCjs.addPipe.call(void 0, key, this.pipe.bind(this));
408
+ _chunk562XCEUUjs.addPipe.call(void 0, key, this.pipe.bind(this));
410
409
  this.onUnmount(() => {
411
- delete _chunkWNTTAFLCjs.Context.pipeRecord[key];
410
+ delete _chunk562XCEUUjs.Context.pipeRecord[key];
412
411
  });
413
412
  }
414
413
  if (this.plugin) {
415
- _chunkWNTTAFLCjs.addPlugin.call(void 0, key, this.plugin.bind(this));
414
+ _chunk562XCEUUjs.addPlugin.call(void 0, key, this.plugin.bind(this));
416
415
  this.onUnmount(() => {
417
- delete _chunkWNTTAFLCjs.Context.pluginRecord[key];
416
+ delete _chunk562XCEUUjs.Context.pluginRecord[key];
418
417
  });
419
418
  }
420
419
  if (this.intercept) {
421
- _chunkWNTTAFLCjs.addInterceptor.call(void 0, key, this.intercept.bind(this));
420
+ _chunk562XCEUUjs.addInterceptor.call(void 0, key, this.intercept.bind(this));
422
421
  this.onUnmount(() => {
423
- delete _chunkWNTTAFLCjs.Context.interceptorRecord[key];
422
+ delete _chunk562XCEUUjs.Context.interceptorRecord[key];
424
423
  });
425
424
  }
426
425
  if (this.guard) {
427
- _chunkWNTTAFLCjs.addGuard.call(void 0, key, this.guard.bind(this));
426
+ _chunk562XCEUUjs.addGuard.call(void 0, key, this.guard.bind(this));
428
427
  this.onUnmount(() => {
429
- delete _chunkWNTTAFLCjs.Context.guardRecord[key];
428
+ delete _chunk562XCEUUjs.Context.guardRecord[key];
430
429
  });
431
430
  }
432
431
  if (this.filter) {
433
- _chunkWNTTAFLCjs.addFilter.call(void 0, key, this.filter.bind(this));
432
+ _chunk562XCEUUjs.addFilter.call(void 0, key, this.filter.bind(this));
434
433
  this.onUnmount(() => {
435
- delete _chunkWNTTAFLCjs.Context.filterRecord[key];
434
+ delete _chunk562XCEUUjs.Context.filterRecord[key];
436
435
  });
437
436
  }
438
437
  }
@@ -515,5 +514,4 @@ _chunkXHKBG2VAjs.__name.call(void 0, PExtension, "PExtension");
515
514
 
516
515
 
517
516
 
518
-
519
- exports.APP_SYMBOL = _chunkXHKBG2VAjs.APP_SYMBOL; exports.Arg = Arg; exports.BadGatewayException = _chunkWNTTAFLCjs.BadGatewayException; exports.BadRequestException = _chunkWNTTAFLCjs.BadRequestException; exports.BaseParam = BaseParam; exports.Body = Body; exports.ConflictException = _chunkWNTTAFLCjs.ConflictException; exports.Context = _chunkWNTTAFLCjs.Context; exports.Controller = Controller; exports.Ctx = Ctx; exports.Define = Define; exports.Delete = Delete; exports.Dev = Dev; exports.ERROR_SYMBOL = _chunkXHKBG2VAjs.ERROR_SYMBOL; exports.Event = Event; exports.Exception = _chunkWNTTAFLCjs.Exception; exports.Factory = _chunkFMPVMJLEjs.Factory; exports.Filter = Filter; exports.ForbiddenException = _chunkWNTTAFLCjs.ForbiddenException; exports.FrameworkException = _chunkWNTTAFLCjs.FrameworkException; exports.Get = Get; exports.Guard = Guard; exports.Head = Head; exports.Header = Header; exports.IS_DEV = _chunkXHKBG2VAjs.IS_DEV; exports.IS_LOG_BAN = _chunkXHKBG2VAjs.IS_LOG_BAN; exports.IS_STRICT = _chunkXHKBG2VAjs.IS_STRICT; exports.Injectable = _chunkFMPVMJLEjs.Injectable; exports.Interceptor = Interceptor; exports.InvalidInputException = _chunkWNTTAFLCjs.InvalidInputException; exports.MERGE_SYMBOL = _chunkXHKBG2VAjs.MERGE_SYMBOL; exports.META_SYMBOL = _chunkXHKBG2VAjs.META_SYMBOL; exports.MODULE_SYMBOL = _chunkXHKBG2VAjs.MODULE_SYMBOL; exports.Meta = _chunkFMPVMJLEjs.Meta; exports.Mix = _chunkXHKBG2VAjs.Mix; exports.NotFoundException = _chunkWNTTAFLCjs.NotFoundException; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PPlugin = PPlugin; exports.PS_FILE_RE = _chunkXHKBG2VAjs.PS_FILE_RE; exports.PS_IMPORT_RE = _chunkXHKBG2VAjs.PS_IMPORT_RE; exports.Param = Param; exports.Patch = Patch; exports.PayloadLargeException = _chunkWNTTAFLCjs.PayloadLargeException; exports.Pipe = Pipe; exports.Plugin = Plugin; exports.Post = Post; exports.Put = Put; exports.Query = Query; exports.Route = Route; exports.Rpc = Rpc; exports.ServiceUnavailableException = _chunkWNTTAFLCjs.ServiceUnavailableException; exports.TimeoutException = _chunkWNTTAFLCjs.TimeoutException; exports.UNMOUNT_SYMBOL = _chunkXHKBG2VAjs.UNMOUNT_SYMBOL; exports.UnauthorizedException = _chunkWNTTAFLCjs.UnauthorizedException; exports.UndefinedException = _chunkWNTTAFLCjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunkWNTTAFLCjs.UnsupportedMediaTypeException; exports.ValidateException = _chunkWNTTAFLCjs.ValidateException; exports.addFilter = _chunkWNTTAFLCjs.addFilter; exports.addGuard = _chunkWNTTAFLCjs.addGuard; exports.addInterceptor = _chunkWNTTAFLCjs.addInterceptor; exports.addPipe = _chunkWNTTAFLCjs.addPipe; exports.addPlugin = _chunkWNTTAFLCjs.addPlugin; exports.argToReq = _chunkEVF2CXTPjs.argToReq; exports.defaultPipe = _chunkWNTTAFLCjs.defaultPipe; exports.emitter = _chunkFMPVMJLEjs.emitter; exports.generateHTTPCode = _chunkFMPVMJLEjs.generateHTTPCode; exports.generateRPCCode = _chunkFMPVMJLEjs.generateRPCCode; exports.getConfig = _chunkXHKBG2VAjs.getConfig; exports.guardRecord = _chunkWNTTAFLCjs.guardRecord; exports.isAopDepInject = _chunkWNTTAFLCjs.isAopDepInject; exports.log = _chunkXHKBG2VAjs.log; exports.resolveDep = _chunkEVF2CXTPjs.resolveDep; exports.setConfig = _chunkXHKBG2VAjs.setConfig;
517
+ exports.APP_SYMBOL = _chunkXHKBG2VAjs.APP_SYMBOL; exports.Arg = Arg; exports.BadGatewayException = _chunk562XCEUUjs.BadGatewayException; exports.BadRequestException = _chunk562XCEUUjs.BadRequestException; exports.BaseParam = BaseParam; exports.Body = Body; exports.ConflictException = _chunk562XCEUUjs.ConflictException; exports.Context = _chunk562XCEUUjs.Context; exports.Controller = Controller; exports.Ctx = Ctx; exports.Define = Define; exports.Delete = Delete; exports.Dev = Dev; exports.ERROR_SYMBOL = _chunkXHKBG2VAjs.ERROR_SYMBOL; exports.Event = Event; exports.Exception = _chunk562XCEUUjs.Exception; exports.Factory = _chunkFMPVMJLEjs.Factory; exports.Filter = Filter; exports.ForbiddenException = _chunk562XCEUUjs.ForbiddenException; exports.FrameworkException = _chunk562XCEUUjs.FrameworkException; exports.Get = Get; exports.Guard = Guard; exports.Head = Head; exports.Header = Header; exports.IS_DEV = _chunkXHKBG2VAjs.IS_DEV; exports.IS_LOG_BAN = _chunkXHKBG2VAjs.IS_LOG_BAN; exports.IS_STRICT = _chunkXHKBG2VAjs.IS_STRICT; exports.Injectable = _chunkFMPVMJLEjs.Injectable; exports.Interceptor = Interceptor; exports.InvalidInputException = _chunk562XCEUUjs.InvalidInputException; exports.MERGE_SYMBOL = _chunkXHKBG2VAjs.MERGE_SYMBOL; exports.META_SYMBOL = _chunkXHKBG2VAjs.META_SYMBOL; exports.MODULE_SYMBOL = _chunkXHKBG2VAjs.MODULE_SYMBOL; exports.Meta = _chunkFMPVMJLEjs.Meta; exports.Mix = _chunkXHKBG2VAjs.Mix; exports.NotFoundException = _chunk562XCEUUjs.NotFoundException; exports.PExtension = PExtension; exports.PFilter = PFilter; exports.PGuard = PGuard; exports.PInterceptor = PInterceptor; exports.PPipe = PPipe; exports.PPlugin = PPlugin; exports.PS_FILE_RE = _chunkXHKBG2VAjs.PS_FILE_RE; exports.PS_IMPORT_RE = _chunkXHKBG2VAjs.PS_IMPORT_RE; exports.Param = Param; exports.Patch = Patch; exports.PayloadLargeException = _chunk562XCEUUjs.PayloadLargeException; exports.Pipe = Pipe; exports.Plugin = Plugin; exports.Post = Post; exports.Put = Put; exports.Query = Query; exports.Route = Route; exports.Rpc = Rpc; exports.ServiceUnavailableException = _chunk562XCEUUjs.ServiceUnavailableException; exports.TimeoutException = _chunk562XCEUUjs.TimeoutException; exports.UNMOUNT_SYMBOL = _chunkXHKBG2VAjs.UNMOUNT_SYMBOL; exports.UnauthorizedException = _chunk562XCEUUjs.UnauthorizedException; exports.UndefinedException = _chunk562XCEUUjs.UndefinedException; exports.UnsupportedMediaTypeException = _chunk562XCEUUjs.UnsupportedMediaTypeException; exports.ValidateException = _chunk562XCEUUjs.ValidateException; exports.addFilter = _chunk562XCEUUjs.addFilter; exports.addGuard = _chunk562XCEUUjs.addGuard; exports.addInterceptor = _chunk562XCEUUjs.addInterceptor; exports.addPipe = _chunk562XCEUUjs.addPipe; exports.addPlugin = _chunk562XCEUUjs.addPlugin; exports.argToReq = _chunkEVF2CXTPjs.argToReq; exports.defaultPipe = _chunk562XCEUUjs.defaultPipe; exports.emitter = _chunkFMPVMJLEjs.emitter; exports.generateHTTPCode = _chunkFMPVMJLEjs.generateHTTPCode; exports.generateRPCCode = _chunkFMPVMJLEjs.generateRPCCode; exports.getConfig = _chunkXHKBG2VAjs.getConfig; exports.isAopDepInject = _chunk562XCEUUjs.isAopDepInject; exports.log = _chunkXHKBG2VAjs.log; exports.resolveDep = _chunkEVF2CXTPjs.resolveDep; exports.setConfig = _chunkXHKBG2VAjs.setConfig;
package/dist/index.mjs CHANGED
@@ -33,9 +33,8 @@ import {
33
33
  addPipe,
34
34
  addPlugin,
35
35
  defaultPipe,
36
- guardRecord,
37
36
  isAopDepInject
38
- } from "./chunk-PXI5J4LR.mjs";
37
+ } from "./chunk-AL36AJMH.mjs";
39
38
  import {
40
39
  APP_SYMBOL,
41
40
  ERROR_SYMBOL,
@@ -511,7 +510,6 @@ export {
511
510
  generateHTTPCode,
512
511
  generateRPCCode,
513
512
  getConfig,
514
- guardRecord,
515
513
  isAopDepInject,
516
514
  log,
517
515
  resolveDep,
@@ -1,5 +1,5 @@
1
1
  import { Kafka } from 'kafkajs';
2
- import { P, F as Factory, T as ToControllerMap } from '../../core-d11fe855.js';
2
+ import { P, F as Factory, T as ToClientMap } from '../../core-895ed04d.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -17,6 +17,6 @@ interface KafkaCtx extends P.BaseContext {
17
17
  }
18
18
  declare function bind(kafka: Kafka, topic: string, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: Options): Promise<void>;
19
19
 
20
- declare function createClient<S extends Record<string, any>>(kafka: Kafka, topic: string, controllers: S): Promise<ToControllerMap<S>>;
20
+ declare function createClient<S extends Record<string, any>>(kafka: Kafka, topic: string, controllers: S): Promise<ToClientMap<S>>;
21
21
 
22
22
  export { KafkaCtx, Options, bind, createClient };
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkWNTTAFLCjs = require('../../chunk-WNTTAFLC.js');
5
+ var _chunk562XCEUUjs = require('../../chunk-562XCEUU.js');
6
6
 
7
7
 
8
8
 
@@ -23,7 +23,7 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
23
23
  fromBeginning: true
24
24
  });
25
25
  function handleMeta() {
26
- _chunkXHKBG2VAjs.IS_DEV && _chunkWNTTAFLCjs.isAopDepInject.call(void 0, meta, {
26
+ _chunkXHKBG2VAjs.IS_DEV && _chunk562XCEUUjs.isAopDepInject.call(void 0, meta, {
27
27
  guards: globalGuards,
28
28
  interceptors: globalInterceptors
29
29
  });
@@ -46,7 +46,7 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
46
46
  messages: [
47
47
  {
48
48
  value: JSON.stringify({
49
- data: new (0, _chunkWNTTAFLCjs.BadRequestException)(`service "${tag}" doesn't exist`).data,
49
+ data: new (0, _chunk562XCEUUjs.BadRequestException)(`service "${tag}" doesn't exist`).data,
50
50
  error: true,
51
51
  id
52
52
  })
@@ -57,7 +57,7 @@ async function bind(kafka, topic, { moduleMap, meta }, opts) {
57
57
  return;
58
58
  }
59
59
  const meta2 = metaMap.get(tag);
60
- const context = new (0, _chunkWNTTAFLCjs.Context)({
60
+ const context = new (0, _chunk562XCEUUjs.Context)({
61
61
  type: "kafka",
62
62
  moduleMap,
63
63
  meta: meta2,
@@ -2,7 +2,7 @@ import {
2
2
  BadRequestException,
3
3
  Context,
4
4
  isAopDepInject
5
- } from "../../chunk-PXI5J4LR.mjs";
5
+ } from "../../chunk-AL36AJMH.mjs";
6
6
  import {
7
7
  IS_DEV,
8
8
  __name
@@ -1,5 +1,5 @@
1
1
  import amqplib from 'amqplib';
2
- import { P, F as Factory, T as ToControllerMap } from '../../core-d11fe855.js';
2
+ import { P, F as Factory, T as ToClientMap } from '../../core-895ed04d.js';
3
3
  import 'phecda-core';
4
4
  import 'node:http';
5
5
 
@@ -15,6 +15,6 @@ interface RabbitmqCtx extends P.BaseContext {
15
15
  }
16
16
  declare function bind(ch: amqplib.Channel, queue: string, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, opts?: Options): Promise<void>;
17
17
 
18
- declare function createClient<S extends Record<string, any>>(ch: amqplib.Channel, queue: string, controllers: S): Promise<ToControllerMap<S>>;
18
+ declare function createClient<S extends Record<string, any>>(ch: amqplib.Channel, queue: string, controllers: S): Promise<ToClientMap<S>>;
19
19
 
20
20
  export { Options, RabbitmqCtx, bind, createClient };