phecda-server 2.1.3 → 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -225,7 +225,7 @@ declare function bindApp(app: Express | Router, { meta, moduleMap }: Awaited<Ret
225
225
 
226
226
  declare function BaseParam(type: string, key: string, validate?: any): any;
227
227
  declare function Body(key?: string, pipeOpts?: any): any;
228
- declare function Query(key: string, pipeOpts?: any): any;
228
+ declare function Query(key?: string, pipeOpts?: any): any;
229
229
  declare function Param(key: string, pipeOpts?: any): any;
230
230
 
231
231
  declare function Route(route: string, type?: string): any;
package/dist/index.js CHANGED
@@ -663,47 +663,52 @@ function getMetaFromInstance(instance, name, tag) {
663
663
  const baseState = (0, import_phecda_core2.getState)(instance, "__CLASS") || {};
664
664
  initState(baseState);
665
665
  return vars.map((i) => {
666
+ const meta = {};
666
667
  const state = (0, import_phecda_core2.getState)(instance, i) || {};
667
- if (baseState.route && state.route)
668
- state.route.route = baseState.route.route + state.route.route;
669
- state.name = name;
670
- state.tag = tag;
671
- state.method = i;
668
+ initState(state);
669
+ if (state.route) {
670
+ meta.route = {
671
+ route: (baseState.route?.route || "") + state.route.route,
672
+ type: state.route.type
673
+ };
674
+ }
675
+ meta.name = name;
676
+ meta.tag = tag;
677
+ meta.method = i;
672
678
  const params = [];
673
679
  for (const i2 of state.params || []) {
674
680
  params.unshift(i2);
675
681
  if (i2.index === 0)
676
682
  break;
677
683
  }
678
- state.params = params;
679
- initState(state);
680
- state.define = {
684
+ meta.params = params;
685
+ meta.define = {
681
686
  ...baseState.define,
682
687
  ...state.define
683
688
  };
684
- state.header = {
689
+ meta.header = {
685
690
  ...baseState.header,
686
691
  ...state.header
687
692
  };
688
- state.middlewares = [
693
+ meta.middlewares = [
689
694
  .../* @__PURE__ */ new Set([
690
695
  ...baseState.middlewares,
691
696
  ...state.middlewares
692
697
  ])
693
698
  ];
694
- state.guards = [
699
+ meta.guards = [
695
700
  .../* @__PURE__ */ new Set([
696
701
  ...baseState.guards,
697
702
  ...state.guards
698
703
  ])
699
704
  ];
700
- state.interceptors = [
705
+ meta.interceptors = [
701
706
  .../* @__PURE__ */ new Set([
702
707
  ...baseState.interceptors,
703
708
  ...state.interceptors
704
709
  ])
705
710
  ];
706
- return new Meta(state, (0, import_phecda_core2.getHandler)(instance, i), getParamtypes(instance, i) || []);
711
+ return new Meta(meta, (0, import_phecda_core2.getHandler)(instance, i), getParamtypes(instance, i) || []);
707
712
  });
708
713
  }
709
714
  __name(getMetaFromInstance, "getMetaFromInstance");
@@ -732,17 +737,17 @@ var import_phecda_core5 = require("phecda-core");
732
737
  var import_phecda_core3 = require("phecda-core");
733
738
  function BaseParam(type, key, validate) {
734
739
  return (target, k, index) => {
735
- (0, import_phecda_core3.setModalVar)(target, k);
736
- (0, import_phecda_core3.mergeState)(target, k, {
737
- params: [
738
- {
739
- type,
740
- key,
741
- index,
742
- validate
743
- }
744
- ]
740
+ (0, import_phecda_core3.setModelVar)(target, k);
741
+ const state = target._namespace.__STATE_NAMESPACE__.get(k) || {};
742
+ if (!state.params)
743
+ state.params = [];
744
+ state.params.push({
745
+ type,
746
+ key,
747
+ index,
748
+ validate
745
749
  });
750
+ (0, import_phecda_core3.setState)(target, k, state);
746
751
  };
747
752
  }
748
753
  __name(BaseParam, "BaseParam");
@@ -750,7 +755,7 @@ function Body(key = "", pipeOpts) {
750
755
  return BaseParam("body", key, pipeOpts);
751
756
  }
752
757
  __name(Body, "Body");
753
- function Query(key, pipeOpts) {
758
+ function Query(key = "", pipeOpts) {
754
759
  return BaseParam("query", key, pipeOpts);
755
760
  }
756
761
  __name(Query, "Query");
@@ -763,23 +768,16 @@ __name(Param, "Param");
763
768
  var import_phecda_core4 = require("phecda-core");
764
769
  function Route(route, type) {
765
770
  return (target, key) => {
766
- if (key) {
767
- (0, import_phecda_core4.setModalVar)(target, key);
768
- (0, import_phecda_core4.mergeState)(target, key, {
769
- route: {
770
- route,
771
- type
772
- }
773
- });
774
- } else {
775
- (0, import_phecda_core4.setModalVar)(target.prototype, "__CLASS");
776
- (0, import_phecda_core4.mergeState)(target.prototype, "__CLASS", {
777
- route: {
778
- route,
779
- type
780
- }
781
- });
782
- }
771
+ if (!key)
772
+ key = "__CLASS";
773
+ target = key === "__CLASS" ? target.prototype : target;
774
+ (0, import_phecda_core4.setModelVar)(target, key);
775
+ const state = target._namespace.__STATE_NAMESPACE__.get(key) || {};
776
+ state.route = {
777
+ route,
778
+ type
779
+ };
780
+ (0, import_phecda_core4.setState)(target, key, state);
783
781
  };
784
782
  }
785
783
  __name(Route, "Route");
@@ -805,61 +803,43 @@ function Controller(route) {
805
803
  __name(Controller, "Controller");
806
804
  function Guard(...guards) {
807
805
  return (target, key) => {
808
- if (key) {
809
- (0, import_phecda_core4.setModalVar)(target, key);
810
- (0, import_phecda_core4.mergeState)(target, key, {
811
- guards: [
812
- ...guards
813
- ]
814
- });
815
- } else {
816
- (0, import_phecda_core4.setModalVar)(target.prototype, "__CLASS");
817
- (0, import_phecda_core4.mergeState)(target.prototype, "__CLASS", {
818
- guards: [
819
- ...guards
820
- ]
821
- });
822
- }
806
+ if (!key)
807
+ key = "__CLASS";
808
+ target = key === "__CLASS" ? target.prototype : target;
809
+ (0, import_phecda_core4.setModelVar)(target, key);
810
+ const state = target._namespace.__STATE_NAMESPACE__.get(key) || {};
811
+ if (!state.guards)
812
+ state.guards = [];
813
+ state.guards.push(...guards);
814
+ (0, import_phecda_core4.setState)(target, key, state);
823
815
  };
824
816
  }
825
817
  __name(Guard, "Guard");
826
818
  function Middle(...middlewares) {
827
819
  return (target, key) => {
828
- if (key) {
829
- (0, import_phecda_core4.setModalVar)(target, key);
830
- (0, import_phecda_core4.mergeState)(target, key, {
831
- middlewares: [
832
- ...middlewares
833
- ]
834
- });
835
- } else {
836
- (0, import_phecda_core4.setModalVar)(target.prototype, "__CLASS");
837
- (0, import_phecda_core4.mergeState)(target.prototype, "__CLASS", {
838
- middlewares: [
839
- ...middlewares
840
- ]
841
- });
842
- }
820
+ if (!key)
821
+ key = "__CLASS";
822
+ target = key === "__CLASS" ? target.prototype : target;
823
+ (0, import_phecda_core4.setModelVar)(target, key);
824
+ const state = target._namespace.__STATE_NAMESPACE__.get(key) || {};
825
+ if (!state.middlewares)
826
+ state.middlewares = [];
827
+ state.middlewares.push(...middlewares);
828
+ (0, import_phecda_core4.setState)(target, key, state);
843
829
  };
844
830
  }
845
831
  __name(Middle, "Middle");
846
832
  function Interceptor(...interceptors) {
847
833
  return (target, key) => {
848
- if (key) {
849
- (0, import_phecda_core4.setModalVar)(target, key);
850
- (0, import_phecda_core4.mergeState)(target, key, {
851
- interceptors: [
852
- ...interceptors
853
- ]
854
- });
855
- } else {
856
- (0, import_phecda_core4.setModalVar)(target.prototype, "__CLASS");
857
- (0, import_phecda_core4.mergeState)(target.prototype, "__CLASS", {
858
- interceptors: [
859
- ...interceptors
860
- ]
861
- });
862
- }
834
+ if (!key)
835
+ key = "__CLASS";
836
+ target = key === "__CLASS" ? target.prototype : target;
837
+ (0, import_phecda_core4.setModelVar)(target, key);
838
+ const state = target._namespace.__STATE_NAMESPACE__.get(key) || {};
839
+ if (!state.interceptors)
840
+ state.interceptors = [];
841
+ state.interceptors.push(...interceptors);
842
+ (0, import_phecda_core4.setState)(target, key, state);
863
843
  };
864
844
  }
865
845
  __name(Interceptor, "Interceptor");
@@ -867,33 +847,27 @@ __name(Interceptor, "Interceptor");
867
847
  // src/decorators/index.ts
868
848
  function Header(name, value) {
869
849
  return (target, k) => {
870
- (0, import_phecda_core5.setModalVar)(target, k);
871
- (0, import_phecda_core5.mergeState)(target, k, {
872
- header: {
873
- name,
874
- value
875
- }
876
- });
850
+ (0, import_phecda_core5.setModelVar)(target, k);
851
+ const state = target._namespace.__STATE_NAMESPACE__.get(k) || {};
852
+ if (!state.header)
853
+ state.header = {};
854
+ state.header[name] = value;
855
+ (0, import_phecda_core5.setState)(target, k, state);
877
856
  };
878
857
  }
879
858
  __name(Header, "Header");
880
859
  function Define(key, value) {
881
860
  return (target, k) => {
882
- if (k) {
883
- (0, import_phecda_core5.setModalVar)(target, k);
884
- (0, import_phecda_core5.mergeState)(target, k, {
885
- define: {
886
- [key]: value
887
- }
888
- });
889
- } else {
890
- (0, import_phecda_core5.setModalVar)(target.prototype, "__CLASS");
891
- (0, import_phecda_core5.mergeState)(target.prototype, "__CLASS", {
892
- define: {
893
- [key]: value
894
- }
895
- });
861
+ if (!k) {
862
+ k = "__CLASS";
863
+ target = target.prototype;
896
864
  }
865
+ (0, import_phecda_core5.setModelVar)(target, k);
866
+ const state = target._namespace.__STATE_NAMESPACE__.get(k) || {};
867
+ if (!state.define)
868
+ state.define = {};
869
+ state.define[key] = value;
870
+ (0, import_phecda_core5.setState)(target, k, state);
897
871
  };
898
872
  }
899
873
  __name(Define, "Define");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/pipe.ts","../src/exception/base.ts","../src/exception/validate.ts","../src/exception/undefine.ts","../src/exception/forbidden.ts","../src/exception/bad-request.ts","../src/exception/not-found.ts","../src/exception/conflict.ts","../src/exception/bad-gateway.ts","../src/exception/invalid-input.ts","../src/exception/media-type.ts","../src/exception/payload-large.ts","../src/exception/timeout.ts","../src/exception/unauthorized.ts","../src/exception/unavailable-service.ts","../src/exception/framework.ts","../src/filter.ts","../src/history.ts","../src/context/base.ts","../src/context/server.ts","../src/types.ts","../src/utils.ts","../src/common.ts","../src/server/express.ts","../src/core.ts","../src/meta.ts","../src/decorators/index.ts","../src/decorators/param.ts","../src/decorators/route.ts"],"sourcesContent":["export * from './context'\nexport * from './types'\nexport * from './server/express'\nexport * from './core'\nexport * from './decorators'\nexport * from './exception'\nexport * from './pipe'\nexport * from './meta'\nexport * from 'phecda-core'\nexport * from './utils'\nexport * from './common'\n","import { isPhecda, plainToClass } from 'phecda-core'\nimport { ValidateException } from './exception/validate'\n\nimport type { P } from './types'\n\nexport const defaultPipe = {\n // todo: add more params\n async transform(args: { arg: any; validate: boolean }[], reflect: any[]) {\n for (const i in args) {\n const { validate, arg } = args[i]\n if (validate === false || !reflect[i]/** work for undefined */)\n continue\n\n if (isPhecda(reflect[i])) {\n const ret = await plainToClass(reflect[i], arg, { transform: true })\n if (ret.err.length > 0)\n throw new ValidateException(ret.err[0])\n args[i].arg = ret.data\n }\n else {\n if ([Number, Boolean].includes(reflect[i])) {\n args[i].arg = reflect[i](arg)\n\n if (reflect[i] === Number && Object.is(args[i].arg, NaN))\n throw new ValidateException(`parameter ${Number(i) + 1} should be a number`)\n }\n }\n }\n return args.map(item => item.arg)\n },\n} as P.Pipe\n","export class HttpException extends Error {\n constructor(public message: string, public status: number, public description = 'Http exception') {\n super(message)\n }\n\n get data() {\n return { message: this.message, description: this.description, status: this.status, error: true }\n }\n}\n","import { HttpException } from './base'\n\nexport class ValidateException extends HttpException {\n constructor(message: string) {\n super(message, 400, 'Validate exception')\n }\n}\n","import { HttpException } from './base'\n\nexport class UndefinedException extends HttpException {\n constructor(message: string) {\n super(message, 500, 'Undefined error')\n }\n}\n","import { HttpException } from './base'\n\nexport class ForbiddenException extends HttpException {\n constructor(message: string) {\n super(message, 403, 'Forbidden resource')\n }\n}\n","import { HttpException } from './base'\n\nexport class BadRequestException extends HttpException {\n constructor(message: string) {\n super(message, 400, 'Bad Request')\n }\n}\n","import { HttpException } from './base'\n\nexport class NotFoundException extends HttpException {\n constructor(message: string) {\n super(message, 404, 'Not Found')\n }\n}\n","import { HttpException } from './base'\n\nexport class ConflictException extends HttpException {\n constructor(message: string) {\n super(message, 409, 'Conflict')\n }\n}\n","import { HttpException } from './base'\n\nexport class BadGatewayException extends HttpException {\n constructor(message: string) {\n super(message, 502, 'Bad Gatrway')\n }\n}\n","import { HttpException } from './base'\n\nexport class InvalidInputException extends HttpException {\n constructor(message: string) {\n super(message, 502, 'Invalid Input')\n }\n}\n","import { HttpException } from './base'\n\nexport class UnsupportedMediaTypeException extends HttpException {\n constructor(message: string) {\n super(message, 415, 'Unsupported Media Type')\n }\n}\n","import { HttpException } from './base'\n\nexport class PayloadLargeException extends HttpException {\n constructor(message: string) {\n super(message, 413, 'Payload Too Large')\n }\n}\n","import { HttpException } from './base'\n\nexport class TimeoutException extends HttpException {\n constructor(message: string) {\n super(message, 408, 'Request Timeout',\n )\n }\n}\n","import { HttpException } from './base'\n\nexport class UnauthorizedException extends HttpException {\n constructor(message: string) {\n super(message, 401, 'Unauthorized')\n }\n}\n","import { HttpException } from './base'\n\nexport class ServiceUnavailableException extends HttpException {\n constructor(message: string) {\n super(message, 503, 'Service Unavailable')\n }\n}\n","import { HttpException } from './base'\n\nexport class FrameworkException extends HttpException {\n constructor(message: string) {\n super(`[phecda-server] ${message}`, 500, 'Framework Error')\n }\n}\n","import { HttpException, UndefinedException } from './exception'\nimport type { ServerFilter } from './types'\n\nexport const serverFilter: ServerFilter = (e: any) => {\n if (!(e instanceof HttpException))\n e = new UndefinedException(e.message || e)\n return e.data\n}\n","export class Phistroy {\n guard: string[] = []\n interceptor: string[] = []\n record(name: string, type: 'guard' | 'interceptor') {\n if (!this[type].includes(name)) {\n this[type].push(name)\n return true\n }\n return false\n }\n}\n","import { ForbiddenException, FrameworkException } from '../exception'\nimport { Phistroy } from '../history'\n\nimport type { Meta } from '../meta'\nimport type { P } from '../types'\n\nexport abstract class Context<Data = any> {\n method: string\n params: string[]\n\n static metaRecord: Record<string, Meta> = {}\n static metaDataRecord: Record<string, ReturnType<typeof parseMeta>> = {}\n static instanceRecord: Record<string, any> = {}\n static guardsRecord: Record<string, any> = {}\n static interceptorsRecord: Record<string, any > = {}\n // static serverRecord: Record<string, Context> = {}\n post: ((...params: any) => any)[]\n history = new Phistroy()\n\n constructor(public key: string, public data: Data) {\n }\n\n static registerGuard(key: string, handler: any) {\n Context.guardsRecord[key] = handler\n }\n\n static registerInterceptor(key: string, handler: any) {\n Context.interceptorsRecord[key] = handler\n }\n\n async useGuard(guards: string[], isMerge = false) {\n for (const guard of guards) {\n if (this.history.record(guard, 'guard')) {\n if (!(guard in Context.guardsRecord))\n throw new FrameworkException(`can't find guard named ${guard}`)\n if (!await Context.guardsRecord[guard](this.data, isMerge))\n throw new ForbiddenException(`Guard exception--${guard}`)\n }\n }\n }\n\n async useInterceptor(interceptors: string[], isMerge = false) {\n const ret = []\n for (const interceptor of interceptors) {\n if (this.history.record(interceptor, 'interceptor')) {\n if (!(interceptor in Context.interceptorsRecord))\n throw new FrameworkException(`can't find guard named ${interceptor}`)\n const post = await Context.interceptorsRecord[interceptor](this.data, isMerge)\n if (post)\n ret.push(post)\n }\n }\n this.post = ret\n }\n\n async usePost(data: any) {\n if (!this.post)\n return data\n for (const cb of this.post)\n data = (await cb(data)) | data\n\n return data\n }\n}\n\nexport function addGuard(key: string, handler: P.Guard) {\n Context.registerGuard(key, handler)\n}\n\nexport function addInterceptor(key: string, handler: P.Interceptor) {\n Context.registerInterceptor(key, handler)\n}\nexport function getInstance(tag: string) {\n return Context.instanceRecord[tag]\n}\n\nexport function parseMeta(meta: Meta) {\n const { data: { params, guards, interceptors, middlewares }, reflect } = meta\n return {\n guards,\n reflect,\n interceptors,\n middlewares,\n params: params.map((param) => {\n const { type, key, validate } = param\n return { type, key, validate }\n }),\n }\n}\n","import type { RequestHandler } from 'express'\nimport { defaultPipe } from '../pipe'\nimport { serverFilter } from '../filter'\nimport { FrameworkException } from '../exception'\nimport type { P, ServerCtx, ServerFilter, ServerMergeCtx } from '../types'\nimport { Context } from './base'\n\nexport class ServerContext extends Context<ServerCtx | ServerMergeCtx > {\n static pipe = defaultPipe\n static filter = serverFilter\n static middlewareRecord: Record<string, (...params: any) => any> = {}\n static useMiddleware(middlewares: string[]) {\n return middlewares.map((m) => {\n if (!(m in ServerContext.middlewareRecord))\n throw new FrameworkException(`can't find middleware named ${m}`)\n return ServerContext.middlewareRecord[m]\n })\n }\n\n async usePipe(args: { arg: any; validate?: boolean }[], reflect: any[]) {\n return ServerContext.pipe.transform?.(args, reflect)\n }\n\n static useFilter(arg: any, data: ServerCtx | ServerMergeCtx) {\n return ServerContext.filter(arg, data)\n }\n\n useFilter(arg: any) {\n return ServerContext.filter(arg, this.data)\n }\n}\n\nexport function addMiddleware(key: string, handler: RequestHandler) {\n ServerContext.middlewareRecord[key] = handler\n}\n\nexport function useServerPipe(pipe: P.Pipe) {\n ServerContext.pipe = pipe\n}\nexport function useServerFilter(filter: ServerFilter) {\n ServerContext.filter = filter\n}\n","import type { Request, Response } from 'express'\nimport type { Events } from 'phecda-core'\nimport type { Meta } from './meta'\nimport type { HttpException } from './exception'\nexport type Construct<T = any> = new (...args: any[]) => T\n\nexport interface Emitter {\n on<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n once<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n off<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n removeAllListeners<N extends keyof Events>(eventName: N): void\n emit<N extends keyof Events>(eventName: N, param: Events[N]): void\n}\n\nexport type RequestType = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head'\n\nexport type MergeType = <R extends Promise<any>[]> (...args: R) => { [K in keyof R]: Awaited<R[K]> }\n\nexport interface ServerMergeCtx {\n request: Request\n response: Response\n meta: Record<string, Meta>\n isMerge: true\n tags?: string[]\n}\n\nexport interface ServerCtx {\n request: Request\n response: Response\n meta: Meta\n}\nexport interface BaseError {\n error: true\n status: number\n}\nexport type ServerFilter<E extends HttpException = any> = (err: E | Error, contextData: ServerMergeCtx | ServerCtx) => any\n\nexport class Base {\n context: ServerMergeCtx | ServerCtx\n}\n\nexport namespace P{\n export interface Error extends BaseError { message: string; description: string}\n\n export type ResOrErr<R > = { [K in keyof R]: Awaited<R[K]> | Error }\n\n export type Res<T> = T\n export type Guard = ((contextData: ServerCtx, isMerge?: false) => Promise<boolean> | boolean) | ((contextData: ServerMergeCtx, isMerge?: true) => Promise<boolean> | boolean)\n export type Interceptor = ((contextData: ServerCtx, isMerge?: false) => any) | ((contextData: ServerMergeCtx, isMerge?: true) => any)\n export interface Handler {\n error?: (arg: any) => void\n }\n export interface Meta {\n route?: {\n type: RequestType\n route: string\n }\n // mq?: {\n // queue: string\n // routeKey: string\n // options: amqplib.Options.Consume\n\n // }\n define?: any\n header: Record<string, string>\n params: { type: string; index: number; key: string; validate?: boolean }[]\n guards: string[]\n interceptors: string[]\n middlewares: string[]\n method: string\n name: string\n tag: string\n }\n export interface Pipe {\n transform(args: { arg: any; validate?: boolean }[], reflect: any[]): Promise<any[]>\n }\n\n}\n","import type { ServerCtx, ServerMergeCtx } from './types'\n\nexport const isUndefined = (obj: any): obj is undefined =>\n typeof obj === 'undefined'\nexport const isNil = (obj: any): obj is null | undefined =>\n isUndefined(obj) || obj === null\n\nexport const isObject = (fn: any): fn is object =>\n !isNil(fn) && typeof fn === 'object'\n\nexport function resolveDep(ret: any, key: string) {\n if (key)\n return ret?.[key]\n return ret\n}\n\nexport function isMerge(data: ServerCtx | ServerMergeCtx): data is ServerMergeCtx {\n return !!(data as ServerMergeCtx).isMerge\n}\n\nconst fnRegexCheckCacheMap = new WeakMap()\n\nexport function isConstructable(fn: any) {\n const hasPrototypeMethods\n = fn.prototype && fn.prototype.constructor === fn && Object.getOwnPropertyNames(fn.prototype).length > 1\n\n if (hasPrototypeMethods)\n return true\n if (fnRegexCheckCacheMap.has(fn))\n return fnRegexCheckCacheMap.get(fn)\n\n let constructable = hasPrototypeMethods\n if (!constructable) {\n const fnString = fn.toString()\n const constructableFunctionRegex = /^function\\b\\s[A-Z].*/\n const classRegex = /^class\\b/\n constructable = constructableFunctionRegex.test(fnString) || classRegex.test(fnString)\n }\n fnRegexCheckCacheMap.set(fn, constructable)\n\n return constructable\n}\n","export const SERIES_SYMBOL = '__symbol_series__'\nexport const MERGE_SYMBOL = '__symbol_req__'\n","import type { Express, Router } from 'express'\nimport { Context, ServerContext, parseMeta } from '../context'\nimport { isObject, resolveDep } from '../utils'\nimport { MERGE_SYMBOL, SERIES_SYMBOL } from '../common'\nimport type { Factory } from '../core'\nimport { BadRequestException } from '../exception'\nimport type { Meta } from '../meta'\nimport type { ServerMergeCtx } from '../types'\n\nexport interface Options {\n/**\n * 专用路由的值,默认为/__PHECDA_SERVER__,处理phecda-client发出的合并请求\n */\n route?: string\n /**\n * 全局守卫\n */\n globalGuards?: string[]\n /**\n * 全局拦截器\n */\n globalInterceptors?: string[]\n /**\n * 专用路由的中间件,全局中间件请在bindApp以外设置\n */\n middlewares?: string[]\n}\n\nexport function bindApp(app: Express | Router, { meta, moduleMap }: Awaited<ReturnType<typeof Factory>>, options: Options = {}) {\n const { globalGuards, globalInterceptors, route, middlewares: proMiddle } = { route: '/__PHECDA_SERVER__', globalGuards: [], globalInterceptors: [], middlewares: [], ...options } as Required<Options>\n const methodMap = {} as Record<string, (...args: any[]) => any>\n const contextMeta = {} as Record<string, Meta>\n for (const i of meta) {\n const { name, method, route, header, tag } = i.data\n const instance = moduleMap.get(tag)!\n const methodTag = `${tag}-${method}`\n contextMeta[methodTag] = i\n Context.metaRecord[methodTag] = i\n let {\n guards,\n reflect,\n interceptors,\n params,\n middlewares,\n } = Context.metaDataRecord[methodTag] ? Context.metaDataRecord[methodTag] : (Context.metaDataRecord[methodTag] = parseMeta(i))\n\n guards = [...globalGuards!, ...guards]\n interceptors = [...globalInterceptors!, ...interceptors]\n\n const handler = instance[method].bind(instance)\n methodMap[methodTag] = handler\n Context.instanceRecord[name] = instance\n if (route) {\n (app as Express)[route.type](route.route, ...ServerContext.useMiddleware(middlewares), async (req, res) => {\n const contextData = {\n request: req,\n meta: i,\n response: res,\n }\n const context = new ServerContext(methodTag, contextData)\n\n try {\n for (const name in header)\n res.set(name, header[name])\n await context.useGuard(guards)\n await context.useInterceptor(interceptors)\n const args = await context.usePipe(params.map(({ type, key, validate }) => {\n return { arg: resolveDep((req as any)[type], key), validate }\n }), reflect)\n instance.context = contextData\n\n const ret = await context.usePost(await handler(...args))\n if (isObject(ret))\n res.json(ret)\n else\n res.send(String(ret))\n }\n catch (e: any) {\n i.handlers.forEach(handler => handler.error?.(e))\n const err = await context.useFilter(e)\n res.status(err.status).json(err)\n }\n })\n }\n }\n\n (app as Express).post(route, (req, _res, next) => {\n (req as any)[MERGE_SYMBOL] = true\n next()\n }, ...ServerContext.useMiddleware(proMiddle), async (req, res) => {\n const { body: { category, data } } = req\n\n const contextData = {\n request: req,\n response: res,\n meta: contextMeta,\n isMerge: true,\n } as unknown as ServerMergeCtx\n\n if (!Array.isArray(data))\n return res.json(await ServerContext.useFilter(new BadRequestException('data format should be an array'), contextData))\n\n contextData.tags = data.map((item: any) => item.tag)\n\n const context = new ServerContext(route, contextData)\n const ret = [] as any[]\n\n if (category === 'series') {\n for (const item of data) {\n const { tag } = item\n const [name] = tag.split('-')\n const {\n guards,\n reflect,\n interceptors,\n params,\n } = Context.metaDataRecord[tag]\n const instance = moduleMap.get(name)\n\n try {\n if (!params)\n throw new BadRequestException(`\"${tag}\" doesn't exist`)\n\n await context.useGuard(guards, true)\n await context.useInterceptor(interceptors, true)\n const args = await context.usePipe(params.map(({ type, key, validate }) => {\n const arg = resolveDep(item[type], key)\n if (typeof arg === 'string' && arg.startsWith(SERIES_SYMBOL)) {\n const [, index, argKey] = arg.split('@')\n return { arg: resolveDep(ret[Number(index)], argKey || key), validate }\n }\n\n return { arg, validate }\n }), reflect) as any\n instance.context = contextData\n\n ret.push(await context.usePost(await methodMap[tag](...args)))\n }\n catch (e: any) {\n const m = Context.metaRecord[tag]\n m.handlers.forEach(handler => handler.error?.(e))\n ret.push(await context.useFilter(e))\n }\n }\n return res.json(ret)\n }\n if (category === 'parallel') {\n return Promise.all(data.map((item: any) => {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve) => {\n const { tag } = item\n const [name] = tag.split('-')\n const {\n guards,\n reflect,\n interceptors,\n params,\n } = Context.metaDataRecord[tag]\n const instance = moduleMap.get(name)\n\n try {\n if (!params)\n throw new BadRequestException(`\"${tag}\" doesn't exist`)\n\n await context.useGuard(guards, true)\n await context.useInterceptor(interceptors, true)\n const args = await context.usePipe(params.map(({ type, key, validate }) => {\n const arg = resolveDep(item[type], key)\n return { arg, validate }\n }), reflect) as any\n instance.context = contextData\n resolve(await context.usePost(await methodMap[tag](...args)))\n }\n catch (e: any) {\n const m = Context.metaRecord[tag]\n m.handlers.forEach(handler => handler.error?.(e))\n resolve(await context.useFilter(e))\n }\n })\n })).then((ret) => {\n res.json(ret)\n })\n }\n\n res.json(await context.useFilter(new BadRequestException('category should be \\'parallel\\' or \\'series\\'')))\n })\n}\n","import 'reflect-metadata'\nimport fs from 'fs'\nimport EventEmitter from 'node:events'\nimport type { Phecda } from 'phecda-core'\nimport { getExposeKey, getHandler, getState, injectProperty, registerAsync } from 'phecda-core'\nimport type { Construct, Emitter, P } from './types'\nimport { Meta } from './meta'\n// TODO: support both emitter types and origin emitter type in future\nexport const emitter: Emitter = new EventEmitter() as any\n\nexport async function Factory(Modules: (new (...args: any) => any)[]) {\n const moduleMap = new Map<string, InstanceType<Construct>>()\n const meta: Meta[] = []\n injectProperty('watcher', ({ eventName, instance, key, options }: { eventName: string; instance: any; key: string; options?: { once: boolean } }) => {\n const fn = typeof instance[key] === 'function' ? instance[key].bind(instance) : (v: any) => instance[key] = v\n\n if (options?.once)\n (emitter as any).once(eventName, fn)\n\n else\n (emitter as any).on(eventName, fn)\n })\n\n for (const Module of Modules)\n await buildNestModule(Module, moduleMap, meta)\n\n return { moduleMap, meta, output: (p = 'pmeta.js') => fs.writeFileSync(p, JSON.stringify(meta.map(item => item.data))) }\n}\n\nasync function buildNestModule(Module: Construct, map: Map<string, InstanceType<Construct>>, meta: Meta[]) {\n const paramtypes = getParamtypes(Module) as Construct[]\n let instance: InstanceType<Construct>\n const tag = Module.prototype?.__TAG__ || Module.name\n if (map.has(tag)) {\n instance = map.get(tag)\n if (!instance)\n throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${tag}--[module] ${Module}`)\n\n return instance\n }\n map.set(tag, undefined)\n if (paramtypes) {\n const paramtypesInstances = [] as any[]\n for (const i in paramtypes)\n paramtypesInstances[i] = await buildNestModule(paramtypes[i], map, meta)\n\n instance = new Module(...paramtypesInstances)\n }\n else {\n instance = new Module()\n }\n meta.push(...getMetaFromInstance(instance, Module.name, tag))\n await registerAsync(instance)\n map.set(tag, instance)\n\n return instance\n}\n\nfunction getMetaFromInstance(instance: Phecda, name: string, tag: string) {\n const vars = getExposeKey(instance).filter(item => item !== '__CLASS')\n const baseState = (getState(instance, '__CLASS') || {}) as P.Meta\n initState(baseState)\n return vars.map((i) => {\n const state = (getState(instance, i) || {}) as P.Meta\n if (baseState.route && state.route)\n state.route.route = baseState.route.route + state.route.route\n state.name = name\n state.tag = tag\n state.method = i\n const params = [] as any[]\n for (const i of state.params || []) {\n params.unshift(i)\n if (i.index === 0)\n break\n }\n state.params = params\n initState(state)\n state.define = { ...baseState.define, ...state.define }\n state.header = { ...baseState.header, ...state.header }\n state.middlewares = [...new Set([...baseState.middlewares, ...state.middlewares])]\n state.guards = [...new Set([...baseState.guards, ...state.guards])]\n state.interceptors = [...new Set([...baseState.interceptors, ...state.interceptors])]\n\n return new Meta(state as unknown as P.Meta, getHandler(instance, i), getParamtypes(instance, i) || [])\n })\n}\n\nfunction getParamtypes(Module: any, key?: string | symbol) {\n return Reflect.getMetadata('design:paramtypes', Module, key!)\n}\n\nfunction initState(state: any) {\n if (!state.define)\n state.define = {}\n if (!state.header)\n state.header = {}\n if (!state.middlewares)\n state.middlewares = []\n if (!state.guards)\n state.guards = []\n if (!state.interceptors)\n state.interceptors = []\n}\n","import type { P } from './types'\n\nexport class Meta {\n constructor(public data: P.Meta, public handlers: P.Handler[], public reflect: any[]) {\n\n }\n}\n","import { mergeState, setModalVar } from 'phecda-core'\n/**\n *\n * @deprecate\n */\n// export function Inject(_target: any) { }\n\nexport function Header(name: string, value: string) {\n return (target: any, k: PropertyKey) => {\n setModalVar(target, k)\n mergeState(target, k, {\n header: { name, value },\n })\n }\n}\n\nexport function Define(key: string, value: any) {\n return (target: any, k?: PropertyKey) => {\n if (k) {\n setModalVar(target, k)\n mergeState(target, k, {\n define: { [key]: value },\n })\n }\n else {\n setModalVar(target.prototype, '__CLASS')\n mergeState(target.prototype, '__CLASS', {\n define: { [key]: value },\n })\n }\n }\n}\n\nexport * from './param'\nexport * from './route'\n","import { mergeState, setModalVar } from 'phecda-core'\n\nexport function BaseParam(type: string, key: string, validate?: any): any {\n return (target: any, k: PropertyKey, index: number) => {\n setModalVar(target, k)\n mergeState(target, k, {\n params: [{ type, key, index, validate }],\n })\n }\n}\n\nexport function Body(key = '', pipeOpts?: any) {\n return BaseParam('body', key, pipeOpts)\n}\nexport function Query(key: string, pipeOpts?: any) {\n return BaseParam('query', key, pipeOpts)\n}\nexport function Param(key: string, pipeOpts?: any) {\n return BaseParam('params', key, pipeOpts)\n}\n","import { mergeState, setModalVar } from 'phecda-core'\n\nexport function Route(route: string, type?: string): any {\n return (target: any, key?: PropertyKey) => {\n if (key) {\n setModalVar(target, key)\n mergeState(target, key, {\n route: {\n route,\n type,\n },\n })\n }\n else {\n setModalVar(target.prototype, '__CLASS')\n mergeState(target.prototype, '__CLASS', {\n route: {\n route,\n type,\n },\n })\n }\n }\n}\n\nexport function Get(route: string) {\n return Route(route, 'get')\n}\n\nexport function Post(route: string) {\n return Route(route, 'post')\n}\nexport function Put(route: string) {\n return Route(route, 'put')\n}\n\nexport function Delete(route: string) {\n return Route(route, 'delete')\n}\n\nexport function Controller(route: string) {\n return Route(route)\n}\n\nexport function Guard(...guards: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (key) {\n setModalVar(target, key)\n mergeState(target, key, {\n guards: [...guards],\n })\n }\n else {\n setModalVar(target.prototype, '__CLASS')\n mergeState(target.prototype, '__CLASS', {\n guards: [...guards],\n })\n }\n }\n}\n\nexport function Middle(...middlewares: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (key) {\n setModalVar(target, key)\n mergeState(target, key, {\n middlewares: [...middlewares],\n })\n }\n else {\n setModalVar(target.prototype, '__CLASS')\n mergeState(target.prototype, '__CLASS', {\n middlewares: [...middlewares],\n })\n }\n }\n}\n\nexport function Interceptor(...interceptors: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (key) {\n setModalVar(target, key)\n mergeState(target, key, {\n interceptors: [...interceptors],\n })\n }\n else {\n setModalVar(target.prototype, '__CLASS')\n mergeState(target.prototype, '__CLASS', {\n interceptors: [...interceptors],\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA,yBAAuC;;;ACAhC,IAAMA,gBAAN,cAA4BC,MAAAA;EACdC;EAAwBC;EAAuBC;EAAlEC,YAAmBH,SAAwBC,QAAuBC,cAAc,kBAAkB;AAChG,UAAMF,OAAAA;mBADWA;kBAAwBC;uBAAuBC;EAElE;EAEA,IAAIE,OAAO;AACT,WAAO;MAAEJ,SAAS,KAAKA;MAASE,aAAa,KAAKA;MAAaD,QAAQ,KAAKA;MAAQI,OAAO;IAAK;EAClG;AACF;AARaP;;;ACEN,IAAMQ,oBAAN,cAAgCC,cAAAA;EACrCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,oBAAA;EACtB;AACF;AAJaH;;;AFGN,IAAMI,cAAc;EAEzB,MAAMC,UAAUC,MAAyCC,SAAgB;AACvE,eAAWC,KAAKF,MAAM;AACpB,YAAM,EAAEG,UAAUC,IAAG,IAAKJ,KAAKE;AAC/B,UAAIC,aAAa,SAAS,CAACF,QAAQC;AACjC;AAEF,cAAIG,6BAASJ,QAAQC,EAAE,GAAG;AACxB,cAAMI,MAAM,UAAMC,iCAAaN,QAAQC,IAAIE,KAAK;UAAEL,WAAW;QAAK,CAAA;AAClE,YAAIO,IAAIE,IAAIC,SAAS;AACnB,gBAAM,IAAIC,kBAAkBJ,IAAIE,IAAI,EAAE;AACxCR,aAAKE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SAASE,eAAeC,cAA6B;AAC1D,SAAO,CAACf,QAAaC,QAAsB;AACzC,QAAIA,KAAK;AACPC,2CAAYF,QAAQC,GAAAA;AACpBE,0CAAWH,QAAQC,KAAK;QACtBc,cAAc;aAAIA;;MACpB,CAAA;IACF,OACK;AACHb,2CAAYF,OAAOI,WAAW,SAAA;AAC9BD,0CAAWH,OAAOI,WAAW,WAAW;QACtCW,cAAc;aAAIA;;MACpB,CAAA;IACF;EACF;AACF;AAfgBD;;;AFvET,SAASE,OAAOC,MAAcC,OAAe;AAClD,SAAO,CAACC,QAAaC,MAAmB;AACtCC,yCAAYF,QAAQC,CAAAA;AACpBE,wCAAWH,QAAQC,GAAG;MACpBG,QAAQ;QAAEN;QAAMC;MAAM;IACxB,CAAA;EACF;AACF;AAPgBF;AAST,SAASQ,OAAOC,KAAaP,OAAY;AAC9C,SAAO,CAACC,QAAaC,MAAoB;AACvC,QAAIA,GAAG;AACLC,2CAAYF,QAAQC,CAAAA;AACpBE,0CAAWH,QAAQC,GAAG;QACpBM,QAAQ;UAAE,CAACD,MAAMP;QAAM;MACzB,CAAA;IACF,OACK;AACHG,2CAAYF,OAAOQ,WAAW,SAAA;AAC9BL,0CAAWH,OAAOQ,WAAW,WAAW;QACtCD,QAAQ;UAAE,CAACD,MAAMP;QAAM;MACzB,CAAA;IACF;EACF;AACF;AAfgBM;;;A3BRhB,wBAAc,wBARd;","names":["HttpException","Error","message","status","description","constructor","data","error","ValidateException","HttpException","constructor","message","defaultPipe","transform","args","reflect","i","validate","arg","isPhecda","ret","plainToClass","err","length","ValidateException","data","Number","Boolean","includes","Object","is","NaN","map","item","UndefinedException","HttpException","constructor","message","ForbiddenException","HttpException","constructor","message","BadRequestException","HttpException","constructor","message","NotFoundException","HttpException","constructor","message","ConflictException","HttpException","constructor","message","BadGatewayException","HttpException","constructor","message","InvalidInputException","HttpException","constructor","message","UnsupportedMediaTypeException","HttpException","constructor","message","PayloadLargeException","HttpException","constructor","message","TimeoutException","HttpException","constructor","message","UnauthorizedException","HttpException","constructor","message","ServiceUnavailableException","HttpException","constructor","message","FrameworkException","HttpException","constructor","message","serverFilter","e","HttpException","UndefinedException","message","data","Phistroy","guard","interceptor","record","name","type","includes","push","Context","key","data","method","params","post","history","constructor","Phistroy","registerGuard","handler","guardsRecord","registerInterceptor","interceptorsRecord","useGuard","guards","isMerge","guard","record","FrameworkException","ForbiddenException","useInterceptor","interceptors","ret","interceptor","push","usePost","cb","metaRecord","metaDataRecord","instanceRecord","addGuard","addInterceptor","getInstance","tag","parseMeta","meta","middlewares","reflect","map","param","type","validate","ServerContext","Context","useMiddleware","middlewares","map","m","middlewareRecord","FrameworkException","usePipe","args","reflect","pipe","transform","useFilter","arg","data","filter","defaultPipe","serverFilter","addMiddleware","key","handler","useServerPipe","useServerFilter","Base","context","isUndefined","obj","isNil","isObject","fn","resolveDep","ret","key","isMerge","data","fnRegexCheckCacheMap","WeakMap","isConstructable","hasPrototypeMethods","prototype","constructor","Object","getOwnPropertyNames","length","has","get","constructable","fnString","toString","constructableFunctionRegex","classRegex","test","set","SERIES_SYMBOL","MERGE_SYMBOL","bindApp","app","meta","moduleMap","options","globalGuards","globalInterceptors","route","middlewares","proMiddle","methodMap","contextMeta","i","name","method","header","tag","data","instance","get","methodTag","Context","metaRecord","guards","reflect","interceptors","params","metaDataRecord","parseMeta","handler","bind","instanceRecord","type","ServerContext","useMiddleware","req","res","contextData","request","response","context","set","useGuard","useInterceptor","args","usePipe","map","key","validate","arg","resolveDep","ret","usePost","isObject","json","send","String","e","handlers","forEach","error","err","useFilter","status","post","_res","next","MERGE_SYMBOL","body","category","isMerge","Array","isArray","BadRequestException","tags","item","split","startsWith","SERIES_SYMBOL","index","argKey","Number","push","m","Promise","all","resolve","then","import_phecda_core","Meta","data","handlers","reflect","constructor","emitter","EventEmitter","Factory","Modules","moduleMap","Map","meta","injectProperty","eventName","instance","key","options","fn","bind","v","once","on","Module","buildNestModule","output","p","fs","writeFileSync","JSON","stringify","map","item","data","paramtypes","getParamtypes","tag","prototype","__TAG__","name","has","get","Error","set","undefined","paramtypesInstances","i","push","getMetaFromInstance","registerAsync","vars","getExposeKey","filter","baseState","getState","initState","state","route","method","params","unshift","index","define","header","middlewares","Set","guards","interceptors","Meta","getHandler","Reflect","getMetadata","import_phecda_core","import_phecda_core","BaseParam","type","key","validate","target","k","index","setModalVar","mergeState","params","Body","pipeOpts","Query","Param","import_phecda_core","Route","route","type","target","key","setModalVar","mergeState","prototype","Get","Post","Put","Delete","Controller","Guard","guards","Middle","middlewares","Interceptor","interceptors","Header","name","value","target","k","setModalVar","mergeState","header","Define","key","define","prototype"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/pipe.ts","../src/exception/base.ts","../src/exception/validate.ts","../src/exception/undefine.ts","../src/exception/forbidden.ts","../src/exception/bad-request.ts","../src/exception/not-found.ts","../src/exception/conflict.ts","../src/exception/bad-gateway.ts","../src/exception/invalid-input.ts","../src/exception/media-type.ts","../src/exception/payload-large.ts","../src/exception/timeout.ts","../src/exception/unauthorized.ts","../src/exception/unavailable-service.ts","../src/exception/framework.ts","../src/filter.ts","../src/history.ts","../src/context/base.ts","../src/context/server.ts","../src/types.ts","../src/utils.ts","../src/common.ts","../src/server/express.ts","../src/core.ts","../src/meta.ts","../src/decorators/index.ts","../src/decorators/param.ts","../src/decorators/route.ts"],"sourcesContent":["export * from './context'\nexport * from './types'\nexport * from './server/express'\nexport * from './core'\nexport * from './decorators'\nexport * from './exception'\nexport * from './pipe'\nexport * from './meta'\nexport * from 'phecda-core'\nexport * from './utils'\nexport * from './common'\n","import { isPhecda, plainToClass } from 'phecda-core'\nimport { ValidateException } from './exception/validate'\n\nimport type { P } from './types'\n\nexport const defaultPipe = {\n // todo: add more params\n async transform(args: { arg: any; validate: boolean }[], reflect: any[]) {\n for (const i in args) {\n const { validate, arg } = args[i]\n if (validate === false || !reflect[i]/** work for undefined */)\n continue\n\n if (isPhecda(reflect[i])) {\n const ret = await plainToClass(reflect[i], arg, { transform: true })\n if (ret.err.length > 0)\n throw new ValidateException(ret.err[0])\n args[i].arg = ret.data\n }\n else {\n if ([Number, Boolean].includes(reflect[i])) {\n args[i].arg = reflect[i](arg)\n\n if (reflect[i] === Number && Object.is(args[i].arg, NaN))\n throw new ValidateException(`parameter ${Number(i) + 1} should be a number`)\n }\n }\n }\n return args.map(item => item.arg)\n },\n} as P.Pipe\n","export class HttpException extends Error {\n constructor(public message: string, public status: number, public description = 'Http exception') {\n super(message)\n }\n\n get data() {\n return { message: this.message, description: this.description, status: this.status, error: true }\n }\n}\n","import { HttpException } from './base'\n\nexport class ValidateException extends HttpException {\n constructor(message: string) {\n super(message, 400, 'Validate exception')\n }\n}\n","import { HttpException } from './base'\n\nexport class UndefinedException extends HttpException {\n constructor(message: string) {\n super(message, 500, 'Undefined error')\n }\n}\n","import { HttpException } from './base'\n\nexport class ForbiddenException extends HttpException {\n constructor(message: string) {\n super(message, 403, 'Forbidden resource')\n }\n}\n","import { HttpException } from './base'\n\nexport class BadRequestException extends HttpException {\n constructor(message: string) {\n super(message, 400, 'Bad Request')\n }\n}\n","import { HttpException } from './base'\n\nexport class NotFoundException extends HttpException {\n constructor(message: string) {\n super(message, 404, 'Not Found')\n }\n}\n","import { HttpException } from './base'\n\nexport class ConflictException extends HttpException {\n constructor(message: string) {\n super(message, 409, 'Conflict')\n }\n}\n","import { HttpException } from './base'\n\nexport class BadGatewayException extends HttpException {\n constructor(message: string) {\n super(message, 502, 'Bad Gatrway')\n }\n}\n","import { HttpException } from './base'\n\nexport class InvalidInputException extends HttpException {\n constructor(message: string) {\n super(message, 502, 'Invalid Input')\n }\n}\n","import { HttpException } from './base'\n\nexport class UnsupportedMediaTypeException extends HttpException {\n constructor(message: string) {\n super(message, 415, 'Unsupported Media Type')\n }\n}\n","import { HttpException } from './base'\n\nexport class PayloadLargeException extends HttpException {\n constructor(message: string) {\n super(message, 413, 'Payload Too Large')\n }\n}\n","import { HttpException } from './base'\n\nexport class TimeoutException extends HttpException {\n constructor(message: string) {\n super(message, 408, 'Request Timeout',\n )\n }\n}\n","import { HttpException } from './base'\n\nexport class UnauthorizedException extends HttpException {\n constructor(message: string) {\n super(message, 401, 'Unauthorized')\n }\n}\n","import { HttpException } from './base'\n\nexport class ServiceUnavailableException extends HttpException {\n constructor(message: string) {\n super(message, 503, 'Service Unavailable')\n }\n}\n","import { HttpException } from './base'\n\nexport class FrameworkException extends HttpException {\n constructor(message: string) {\n super(`[phecda-server] ${message}`, 500, 'Framework Error')\n }\n}\n","import { HttpException, UndefinedException } from './exception'\nimport type { ServerFilter } from './types'\n\nexport const serverFilter: ServerFilter = (e: any) => {\n if (!(e instanceof HttpException))\n e = new UndefinedException(e.message || e)\n return e.data\n}\n","export class Phistroy {\n guard: string[] = []\n interceptor: string[] = []\n record(name: string, type: 'guard' | 'interceptor') {\n if (!this[type].includes(name)) {\n this[type].push(name)\n return true\n }\n return false\n }\n}\n","import { ForbiddenException, FrameworkException } from '../exception'\nimport { Phistroy } from '../history'\n\nimport type { Meta } from '../meta'\nimport type { P } from '../types'\n\nexport abstract class Context<Data = any> {\n method: string\n params: string[]\n\n static metaRecord: Record<string, Meta> = {}\n static metaDataRecord: Record<string, ReturnType<typeof parseMeta>> = {}\n static instanceRecord: Record<string, any> = {}\n static guardsRecord: Record<string, any> = {}\n static interceptorsRecord: Record<string, any > = {}\n // static serverRecord: Record<string, Context> = {}\n post: ((...params: any) => any)[]\n history = new Phistroy()\n\n constructor(public key: string, public data: Data) {\n }\n\n static registerGuard(key: string, handler: any) {\n Context.guardsRecord[key] = handler\n }\n\n static registerInterceptor(key: string, handler: any) {\n Context.interceptorsRecord[key] = handler\n }\n\n async useGuard(guards: string[], isMerge = false) {\n for (const guard of guards) {\n if (this.history.record(guard, 'guard')) {\n if (!(guard in Context.guardsRecord))\n throw new FrameworkException(`can't find guard named ${guard}`)\n if (!await Context.guardsRecord[guard](this.data, isMerge))\n throw new ForbiddenException(`Guard exception--${guard}`)\n }\n }\n }\n\n async useInterceptor(interceptors: string[], isMerge = false) {\n const ret = []\n for (const interceptor of interceptors) {\n if (this.history.record(interceptor, 'interceptor')) {\n if (!(interceptor in Context.interceptorsRecord))\n throw new FrameworkException(`can't find guard named ${interceptor}`)\n const post = await Context.interceptorsRecord[interceptor](this.data, isMerge)\n if (post)\n ret.push(post)\n }\n }\n this.post = ret\n }\n\n async usePost(data: any) {\n if (!this.post)\n return data\n for (const cb of this.post)\n data = (await cb(data)) | data\n\n return data\n }\n}\n\nexport function addGuard(key: string, handler: P.Guard) {\n Context.registerGuard(key, handler)\n}\n\nexport function addInterceptor(key: string, handler: P.Interceptor) {\n Context.registerInterceptor(key, handler)\n}\nexport function getInstance(tag: string) {\n return Context.instanceRecord[tag]\n}\n\nexport function parseMeta(meta: Meta) {\n const { data: { params, guards, interceptors, middlewares }, reflect } = meta\n return {\n guards,\n reflect,\n interceptors,\n middlewares,\n params: params.map((param) => {\n const { type, key, validate } = param\n return { type, key, validate }\n }),\n }\n}\n","import type { RequestHandler } from 'express'\nimport { defaultPipe } from '../pipe'\nimport { serverFilter } from '../filter'\nimport { FrameworkException } from '../exception'\nimport type { P, ServerCtx, ServerFilter, ServerMergeCtx } from '../types'\nimport { Context } from './base'\n\nexport class ServerContext extends Context<ServerCtx | ServerMergeCtx > {\n static pipe = defaultPipe\n static filter = serverFilter\n static middlewareRecord: Record<string, (...params: any) => any> = {}\n static useMiddleware(middlewares: string[]) {\n return middlewares.map((m) => {\n if (!(m in ServerContext.middlewareRecord))\n throw new FrameworkException(`can't find middleware named ${m}`)\n return ServerContext.middlewareRecord[m]\n })\n }\n\n async usePipe(args: { arg: any; validate?: boolean }[], reflect: any[]) {\n return ServerContext.pipe.transform?.(args, reflect)\n }\n\n static useFilter(arg: any, data: ServerCtx | ServerMergeCtx) {\n return ServerContext.filter(arg, data)\n }\n\n useFilter(arg: any) {\n return ServerContext.filter(arg, this.data)\n }\n}\n\nexport function addMiddleware(key: string, handler: RequestHandler) {\n ServerContext.middlewareRecord[key] = handler\n}\n\nexport function useServerPipe(pipe: P.Pipe) {\n ServerContext.pipe = pipe\n}\nexport function useServerFilter(filter: ServerFilter) {\n ServerContext.filter = filter\n}\n","import type { Request, Response } from 'express'\nimport type { Events } from 'phecda-core'\nimport type { Meta } from './meta'\nimport type { HttpException } from './exception'\nexport type Construct<T = any> = new (...args: any[]) => T\n\nexport interface Emitter {\n on<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n once<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n off<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n removeAllListeners<N extends keyof Events>(eventName: N): void\n emit<N extends keyof Events>(eventName: N, param: Events[N]): void\n}\n\nexport type RequestType = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head'\n\nexport type MergeType = <R extends Promise<any>[]> (...args: R) => { [K in keyof R]: Awaited<R[K]> }\n\nexport interface ServerMergeCtx {\n request: Request\n response: Response\n meta: Record<string, Meta>\n isMerge: true\n tags?: string[]\n}\n\nexport interface ServerCtx {\n request: Request\n response: Response\n meta: Meta\n}\nexport interface BaseError {\n error: true\n status: number\n}\nexport type ServerFilter<E extends HttpException = any> = (err: E | Error, contextData: ServerMergeCtx | ServerCtx) => any\n\nexport class Base {\n context: ServerMergeCtx | ServerCtx\n}\n\nexport namespace P{\n export interface Error extends BaseError { message: string; description: string}\n\n export type ResOrErr<R > = { [K in keyof R]: Awaited<R[K]> | Error }\n\n export type Res<T> = T\n export type Guard = ((contextData: ServerCtx, isMerge?: false) => Promise<boolean> | boolean) | ((contextData: ServerMergeCtx, isMerge?: true) => Promise<boolean> | boolean)\n export type Interceptor = ((contextData: ServerCtx, isMerge?: false) => any) | ((contextData: ServerMergeCtx, isMerge?: true) => any)\n export interface Handler {\n error?: (arg: any) => void\n }\n export interface Meta {\n route?: {\n type: RequestType\n route: string\n }\n // mq?: {\n // queue: string\n // routeKey: string\n // options: amqplib.Options.Consume\n\n // }\n define?: any\n header: Record<string, string>\n params: { type: string; index: number; key: string; validate?: boolean }[]\n guards: string[]\n interceptors: string[]\n middlewares: string[]\n method: string\n name: string\n tag: string\n }\n export interface Pipe {\n transform(args: { arg: any; validate?: boolean }[], reflect: any[]): Promise<any[]>\n }\n\n}\n","import type { ServerCtx, ServerMergeCtx } from './types'\n\nexport const isUndefined = (obj: any): obj is undefined =>\n typeof obj === 'undefined'\nexport const isNil = (obj: any): obj is null | undefined =>\n isUndefined(obj) || obj === null\n\nexport const isObject = (fn: any): fn is object =>\n !isNil(fn) && typeof fn === 'object'\n\nexport function resolveDep(ret: any, key: string) {\n if (key)\n return ret?.[key]\n return ret\n}\n\nexport function isMerge(data: ServerCtx | ServerMergeCtx): data is ServerMergeCtx {\n return !!(data as ServerMergeCtx).isMerge\n}\n\nconst fnRegexCheckCacheMap = new WeakMap()\n\nexport function isConstructable(fn: any) {\n const hasPrototypeMethods\n = fn.prototype && fn.prototype.constructor === fn && Object.getOwnPropertyNames(fn.prototype).length > 1\n\n if (hasPrototypeMethods)\n return true\n if (fnRegexCheckCacheMap.has(fn))\n return fnRegexCheckCacheMap.get(fn)\n\n let constructable = hasPrototypeMethods\n if (!constructable) {\n const fnString = fn.toString()\n const constructableFunctionRegex = /^function\\b\\s[A-Z].*/\n const classRegex = /^class\\b/\n constructable = constructableFunctionRegex.test(fnString) || classRegex.test(fnString)\n }\n fnRegexCheckCacheMap.set(fn, constructable)\n\n return constructable\n}\n","export const SERIES_SYMBOL = '__symbol_series__'\nexport const MERGE_SYMBOL = '__symbol_req__'\n","import type { Express, Router } from 'express'\nimport { Context, ServerContext, parseMeta } from '../context'\nimport { isObject, resolveDep } from '../utils'\nimport { MERGE_SYMBOL, SERIES_SYMBOL } from '../common'\nimport type { Factory } from '../core'\nimport { BadRequestException } from '../exception'\nimport type { Meta } from '../meta'\nimport type { ServerMergeCtx } from '../types'\n\nexport interface Options {\n/**\n * 专用路由的值,默认为/__PHECDA_SERVER__,处理phecda-client发出的合并请求\n */\n route?: string\n /**\n * 全局守卫\n */\n globalGuards?: string[]\n /**\n * 全局拦截器\n */\n globalInterceptors?: string[]\n /**\n * 专用路由的中间件,全局中间件请在bindApp以外设置\n */\n middlewares?: string[]\n}\n\nexport function bindApp(app: Express | Router, { meta, moduleMap }: Awaited<ReturnType<typeof Factory>>, options: Options = {}) {\n const { globalGuards, globalInterceptors, route, middlewares: proMiddle } = { route: '/__PHECDA_SERVER__', globalGuards: [], globalInterceptors: [], middlewares: [], ...options } as Required<Options>\n const methodMap = {} as Record<string, (...args: any[]) => any>\n const contextMeta = {} as Record<string, Meta>\n for (const i of meta) {\n const { name, method, route, header, tag } = i.data\n const instance = moduleMap.get(tag)!\n const methodTag = `${tag}-${method}`\n contextMeta[methodTag] = i\n Context.metaRecord[methodTag] = i\n let {\n guards,\n reflect,\n interceptors,\n params,\n middlewares,\n } = Context.metaDataRecord[methodTag] ? Context.metaDataRecord[methodTag] : (Context.metaDataRecord[methodTag] = parseMeta(i))\n\n guards = [...globalGuards!, ...guards]\n interceptors = [...globalInterceptors!, ...interceptors]\n\n const handler = instance[method].bind(instance)\n methodMap[methodTag] = handler\n Context.instanceRecord[name] = instance\n if (route) {\n (app as Express)[route.type](route.route, ...ServerContext.useMiddleware(middlewares), async (req, res) => {\n const contextData = {\n request: req,\n meta: i,\n response: res,\n }\n const context = new ServerContext(methodTag, contextData)\n\n try {\n for (const name in header)\n res.set(name, header[name])\n await context.useGuard(guards)\n await context.useInterceptor(interceptors)\n const args = await context.usePipe(params.map(({ type, key, validate }) => {\n return { arg: resolveDep((req as any)[type], key), validate }\n }), reflect)\n instance.context = contextData\n\n const ret = await context.usePost(await handler(...args))\n if (isObject(ret))\n res.json(ret)\n else\n res.send(String(ret))\n }\n catch (e: any) {\n i.handlers.forEach(handler => handler.error?.(e))\n const err = await context.useFilter(e)\n res.status(err.status).json(err)\n }\n })\n }\n }\n\n (app as Express).post(route, (req, _res, next) => {\n (req as any)[MERGE_SYMBOL] = true\n next()\n }, ...ServerContext.useMiddleware(proMiddle), async (req, res) => {\n const { body: { category, data } } = req\n\n const contextData = {\n request: req,\n response: res,\n meta: contextMeta,\n isMerge: true,\n } as unknown as ServerMergeCtx\n\n if (!Array.isArray(data))\n return res.json(await ServerContext.useFilter(new BadRequestException('data format should be an array'), contextData))\n\n contextData.tags = data.map((item: any) => item.tag)\n\n const context = new ServerContext(route, contextData)\n const ret = [] as any[]\n\n if (category === 'series') {\n for (const item of data) {\n const { tag } = item\n const [name] = tag.split('-')\n const {\n guards,\n reflect,\n interceptors,\n params,\n } = Context.metaDataRecord[tag]\n const instance = moduleMap.get(name)\n\n try {\n if (!params)\n throw new BadRequestException(`\"${tag}\" doesn't exist`)\n\n await context.useGuard(guards, true)\n await context.useInterceptor(interceptors, true)\n const args = await context.usePipe(params.map(({ type, key, validate }) => {\n const arg = resolveDep(item[type], key)\n if (typeof arg === 'string' && arg.startsWith(SERIES_SYMBOL)) {\n const [, index, argKey] = arg.split('@')\n return { arg: resolveDep(ret[Number(index)], argKey || key), validate }\n }\n\n return { arg, validate }\n }), reflect) as any\n instance.context = contextData\n\n ret.push(await context.usePost(await methodMap[tag](...args)))\n }\n catch (e: any) {\n const m = Context.metaRecord[tag]\n m.handlers.forEach(handler => handler.error?.(e))\n ret.push(await context.useFilter(e))\n }\n }\n return res.json(ret)\n }\n if (category === 'parallel') {\n return Promise.all(data.map((item: any) => {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve) => {\n const { tag } = item\n const [name] = tag.split('-')\n const {\n guards,\n reflect,\n interceptors,\n params,\n } = Context.metaDataRecord[tag]\n const instance = moduleMap.get(name)\n\n try {\n if (!params)\n throw new BadRequestException(`\"${tag}\" doesn't exist`)\n\n await context.useGuard(guards, true)\n await context.useInterceptor(interceptors, true)\n const args = await context.usePipe(params.map(({ type, key, validate }) => {\n const arg = resolveDep(item[type], key)\n return { arg, validate }\n }), reflect) as any\n instance.context = contextData\n resolve(await context.usePost(await methodMap[tag](...args)))\n }\n catch (e: any) {\n const m = Context.metaRecord[tag]\n m.handlers.forEach(handler => handler.error?.(e))\n resolve(await context.useFilter(e))\n }\n })\n })).then((ret) => {\n res.json(ret)\n })\n }\n\n res.json(await context.useFilter(new BadRequestException('category should be \\'parallel\\' or \\'series\\'')))\n })\n}\n","import 'reflect-metadata'\nimport fs from 'fs'\nimport EventEmitter from 'node:events'\nimport type { Phecda } from 'phecda-core'\nimport { getExposeKey, getHandler, getState, injectProperty, registerAsync } from 'phecda-core'\nimport type { Construct, Emitter, P } from './types'\nimport { Meta } from './meta'\n// TODO: support both emitter types and origin emitter type in future\nexport const emitter: Emitter = new EventEmitter() as any\n\nexport async function Factory(Modules: (new (...args: any) => any)[]) {\n const moduleMap = new Map<string, InstanceType<Construct>>()\n const meta: Meta[] = []\n injectProperty('watcher', ({ eventName, instance, key, options }: { eventName: string; instance: any; key: string; options?: { once: boolean } }) => {\n const fn = typeof instance[key] === 'function' ? instance[key].bind(instance) : (v: any) => instance[key] = v\n\n if (options?.once)\n (emitter as any).once(eventName, fn)\n\n else\n (emitter as any).on(eventName, fn)\n })\n\n for (const Module of Modules)\n await buildNestModule(Module, moduleMap, meta)\n\n return { moduleMap, meta, output: (p = 'pmeta.js') => fs.writeFileSync(p, JSON.stringify(meta.map(item => item.data))) }\n}\n\nasync function buildNestModule(Module: Construct, map: Map<string, InstanceType<Construct>>, meta: Meta[]) {\n const paramtypes = getParamtypes(Module) as Construct[]\n let instance: InstanceType<Construct>\n const tag = Module.prototype?.__TAG__ || Module.name\n\n if (map.has(tag)) {\n instance = map.get(tag)\n if (!instance)\n throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${tag}--[module] ${Module}`)\n\n return instance\n }\n map.set(tag, undefined)\n if (paramtypes) {\n const paramtypesInstances = [] as any[]\n for (const i in paramtypes)\n paramtypesInstances[i] = await buildNestModule(paramtypes[i], map, meta)\n\n instance = new Module(...paramtypesInstances)\n }\n else {\n instance = new Module()\n }\n meta.push(...getMetaFromInstance(instance, Module.name, tag))\n await registerAsync(instance)\n map.set(tag, instance)\n\n return instance\n}\n\nfunction getMetaFromInstance(instance: Phecda, name: string, tag: string) {\n const vars = getExposeKey(instance).filter(item => item !== '__CLASS')\n const baseState = (getState(instance, '__CLASS') || {}) as P.Meta\n initState(baseState)\n\n return vars.map((i) => {\n const meta = {} as P.Meta\n const state = (getState(instance, i) || {}) as P.Meta\n initState(state)\n if (state.route) {\n meta.route = {\n route: (baseState.route?.route || '') + (state.route.route),\n type: state.route.type,\n }\n }\n\n meta.name = name\n meta.tag = tag\n meta.method = i as string\n const params = [] as any[]\n for (const i of state.params || []) {\n params.unshift(i)\n if (i.index === 0)\n break\n }\n meta.params = params\n meta.define = { ...baseState.define, ...state.define }\n meta.header = { ...baseState.header, ...state.header }\n meta.middlewares = [...new Set([...baseState.middlewares, ...state.middlewares])]\n meta.guards = [...new Set([...baseState.guards, ...state.guards])]\n meta.interceptors = [...new Set([...baseState.interceptors, ...state.interceptors])]\n\n return new Meta(meta as unknown as P.Meta, getHandler(instance, i), getParamtypes(instance, i as string) || [])\n })\n}\n\nfunction getParamtypes(Module: any, key?: string | symbol) {\n return Reflect.getMetadata('design:paramtypes', Module, key!)\n}\n\nfunction initState(state: any) {\n if (!state.define)\n state.define = {}\n if (!state.header)\n state.header = {}\n if (!state.middlewares)\n state.middlewares = []\n if (!state.guards)\n state.guards = []\n if (!state.interceptors)\n state.interceptors = []\n}\n","import type { P } from './types'\n\nexport class Meta {\n constructor(public data: P.Meta, public handlers: P.Handler[], public reflect: any[]) {\n\n }\n}\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function Header(name: string, value: string) {\n return (target: any, k: PropertyKey) => {\n setModelVar(target, k)\n const state = target._namespace.__STATE_NAMESPACE__.get(k) || {}\n if (!state.header)\n state.header = {}\n\n state.header[name] = value\n setState(target, k, state)\n }\n}\n\nexport function Define(key: string, value: any) {\n return (target: any, k?: PropertyKey) => {\n if (!k) {\n k = '__CLASS'\n target = target.prototype\n }\n\n setModelVar(target, k)\n const state = target._namespace.__STATE_NAMESPACE__.get(k) || {}\n if (!state.define)\n state.define = {}\n\n state.define[key] = value\n setState(target, k, state)\n }\n}\n\nexport * from './param'\nexport * from './route'\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function BaseParam(type: string, key: string, validate?: any): any {\n return (target: any, k: PropertyKey, index: number) => {\n setModelVar(target, k)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(k) || {}\n if (!state.params)\n state.params = []\n\n state.params.push({ type, key, index, validate })\n setState(target, k, state)\n }\n}\n\nexport function Body(key = '', pipeOpts?: any) {\n return BaseParam('body', key, pipeOpts)\n}\nexport function Query(key = '', pipeOpts?: any) {\n return BaseParam('query', key, pipeOpts)\n}\nexport function Param(key: string, pipeOpts?: any) {\n return BaseParam('params', key, pipeOpts)\n}\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function Route(route: string, type?: string): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n state.route = {\n route,\n type,\n }\n setState(target, key, state)\n }\n}\n\nexport function Get(route: string) {\n return Route(route, 'get')\n}\n\nexport function Post(route: string) {\n return Route(route, 'post')\n}\nexport function Put(route: string) {\n return Route(route, 'put')\n}\n\nexport function Delete(route: string) {\n return Route(route, 'delete')\n}\n\nexport function Controller(route: string) {\n return Route(route)\n}\n\nexport function Guard(...guards: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n if (!state.guards)\n state.guards = []\n state.guards.push(...guards)\n setState(target, key, state)\n }\n}\n\nexport function Middle(...middlewares: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n if (!state.middlewares)\n state.middlewares = []\n state.middlewares.push(...middlewares)\n setState(target, key, state)\n }\n}\n\nexport function Interceptor(...interceptors: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n if (!state.interceptors)\n state.interceptors = []\n state.interceptors.push(...interceptors)\n setState(target, key, state)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA,yBAAuC;;;ACAhC,IAAMA,gBAAN,cAA4BC,MAAAA;EACdC;EAAwBC;EAAuBC;EAAlEC,YAAmBH,SAAwBC,QAAuBC,cAAc,kBAAkB;AAChG,UAAMF,OAAAA;mBADWA;kBAAwBC;uBAAuBC;EAElE;EAEA,IAAIE,OAAO;AACT,WAAO;MAAEJ,SAAS,KAAKA;MAASE,aAAa,KAAKA;MAAaD,QAAQ,KAAKA;MAAQI,OAAO;IAAK;EAClG;AACF;AARaP;;;ACEN,IAAMQ,oBAAN,cAAgCC,cAAAA;EACrCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,oBAAA;EACtB;AACF;AAJaH;;;AFGN,IAAMI,cAAc;EAEzB,MAAMC,UAAUC,MAAyCC,SAAgB;AACvE,eAAWC,KAAKF,MAAM;AACpB,YAAM,EAAEG,UAAUC,IAAG,IAAKJ,KAAKE;AAC/B,UAAIC,aAAa,SAAS,CAACF,QAAQC;AACjC;AAEF,cAAIG,6BAASJ,QAAQC,EAAE,GAAG;AACxB,cAAMI,MAAM,UAAMC,iCAAaN,QAAQC,IAAIE,KAAK;UAAEL,WAAW;QAAK,CAAA;AAClE,YAAIO,IAAIE,IAAIC,SAAS;AACnB,gBAAM,IAAI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;AACNA,UAAI;AACJD,eAASA,OAAOW;IAClB;AAEAT,yCAAYF,QAAQC,CAAAA;AACpB,UAAME,QAAQH,OAAOI,WAAWC,oBAAoBC,IAAIL,CAAAA,KAAM,CAAC;AAC/D,QAAI,CAACE,MAAMS;AACTT,YAAMS,SAAS,CAAC;AAElBT,UAAMS,OAAOF,OAAOX;AACpBS,sCAASR,QAAQC,GAAGE,KAAAA;EACtB;AACF;AAfgBM;;;A3BNhB,wBAAc,wBARd;","names":["HttpException","Error","message","status","description","constructor","data","error","ValidateException","HttpException","constructor","message","defaultPipe","transform","args","reflect","i","validate","arg","isPhecda","ret","plainToClass","err","length","ValidateException","data","Number","Boolean","includes","Object","is","NaN","map","item","UndefinedException","HttpException","constructor","message","ForbiddenException","HttpException","constructor","message","BadRequestException","HttpException","constructor","message","NotFoundException","HttpException","constructor","message","ConflictException","HttpException","constructor","message","BadGatewayException","HttpException","constructor","message","InvalidInputException","HttpException","constructor","message","UnsupportedMediaTypeException","HttpException","constructor","message","PayloadLargeException","HttpException","constructor","message","TimeoutException","HttpException","constructor","message","UnauthorizedException","HttpException","constructor","message","ServiceUnavailableException","HttpException","constructor","message","FrameworkException","HttpException","constructor","message","serverFilter","e","HttpException","UndefinedException","message","data","Phistroy","guard","interceptor","record","name","type","includes","push","Context","key","data","method","params","post","history","constructor","Phistroy","registerGuard","handler","guardsRecord","registerInterceptor","interceptorsRecord","useGuard","guards","isMerge","guard","record","FrameworkException","ForbiddenException","useInterceptor","interceptors","ret","interceptor","push","usePost","cb","metaRecord","metaDataRecord","instanceRecord","addGuard","addInterceptor","getInstance","tag","parseMeta","meta","middlewares","reflect","map","param","type","validate","ServerContext","Context","useMiddleware","middlewares","map","m","middlewareRecord","FrameworkException","usePipe","args","reflect","pipe","transform","useFilter","arg","data","filter","defaultPipe","serverFilter","addMiddleware","key","handler","useServerPipe","useServerFilter","Base","context","isUndefined","obj","isNil","isObject","fn","resolveDep","ret","key","isMerge","data","fnRegexCheckCacheMap","WeakMap","isConstructable","hasPrototypeMethods","prototype","constructor","Object","getOwnPropertyNames","length","has","get","constructable","fnString","toString","constructableFunctionRegex","classRegex","test","set","SERIES_SYMBOL","MERGE_SYMBOL","bindApp","app","meta","moduleMap","options","globalGuards","globalInterceptors","route","middlewares","proMiddle","methodMap","contextMeta","i","name","method","header","tag","data","instance","get","methodTag","Context","metaRecord","guards","reflect","interceptors","params","metaDataRecord","parseMeta","handler","bind","instanceRecord","type","ServerContext","useMiddleware","req","res","contextData","request","response","context","set","useGuard","useInterceptor","args","usePipe","map","key","validate","arg","resolveDep","ret","usePost","isObject","json","send","String","e","handlers","forEach","error","err","useFilter","status","post","_res","next","MERGE_SYMBOL","body","category","isMerge","Array","isArray","BadRequestException","tags","item","split","startsWith","SERIES_SYMBOL","index","argKey","Number","push","m","Promise","all","resolve","then","import_phecda_core","Meta","data","handlers","reflect","constructor","emitter","EventEmitter","Factory","Modules","moduleMap","Map","meta","injectProperty","eventName","instance","key","options","fn","bind","v","once","on","Module","buildNestModule","output","p","fs","writeFileSync","JSON","stringify","map","item","data","paramtypes","getParamtypes","tag","prototype","__TAG__","name","has","get","Error","set","undefined","paramtypesInstances","i","push","getMetaFromInstance","registerAsync","vars","getExposeKey","filter","baseState","getState","initState","state","route","type","method","params","unshift","index","define","header","middlewares","Set","guards","interceptors","Meta","getHandler","Reflect","getMetadata","import_phecda_core","import_phecda_core","BaseParam","type","key","validate","target","k","index","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","params","push","setState","Body","pipeOpts","Query","Param","import_phecda_core","Route","route","type","target","key","prototype","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","setState","Get","Post","Put","Delete","Controller","Guard","guards","push","Middle","middlewares","Interceptor","interceptors","Header","name","value","target","k","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","header","setState","Define","key","prototype","define"]}
package/dist/index.mjs CHANGED
@@ -580,47 +580,52 @@ function getMetaFromInstance(instance, name, tag) {
580
580
  const baseState = getState(instance, "__CLASS") || {};
581
581
  initState(baseState);
582
582
  return vars.map((i) => {
583
+ const meta = {};
583
584
  const state = getState(instance, i) || {};
584
- if (baseState.route && state.route)
585
- state.route.route = baseState.route.route + state.route.route;
586
- state.name = name;
587
- state.tag = tag;
588
- state.method = i;
585
+ initState(state);
586
+ if (state.route) {
587
+ meta.route = {
588
+ route: (baseState.route?.route || "") + state.route.route,
589
+ type: state.route.type
590
+ };
591
+ }
592
+ meta.name = name;
593
+ meta.tag = tag;
594
+ meta.method = i;
589
595
  const params = [];
590
596
  for (const i2 of state.params || []) {
591
597
  params.unshift(i2);
592
598
  if (i2.index === 0)
593
599
  break;
594
600
  }
595
- state.params = params;
596
- initState(state);
597
- state.define = {
601
+ meta.params = params;
602
+ meta.define = {
598
603
  ...baseState.define,
599
604
  ...state.define
600
605
  };
601
- state.header = {
606
+ meta.header = {
602
607
  ...baseState.header,
603
608
  ...state.header
604
609
  };
605
- state.middlewares = [
610
+ meta.middlewares = [
606
611
  .../* @__PURE__ */ new Set([
607
612
  ...baseState.middlewares,
608
613
  ...state.middlewares
609
614
  ])
610
615
  ];
611
- state.guards = [
616
+ meta.guards = [
612
617
  .../* @__PURE__ */ new Set([
613
618
  ...baseState.guards,
614
619
  ...state.guards
615
620
  ])
616
621
  ];
617
- state.interceptors = [
622
+ meta.interceptors = [
618
623
  .../* @__PURE__ */ new Set([
619
624
  ...baseState.interceptors,
620
625
  ...state.interceptors
621
626
  ])
622
627
  ];
623
- return new Meta(state, getHandler(instance, i), getParamtypes(instance, i) || []);
628
+ return new Meta(meta, getHandler(instance, i), getParamtypes(instance, i) || []);
624
629
  });
625
630
  }
626
631
  __name(getMetaFromInstance, "getMetaFromInstance");
@@ -643,23 +648,23 @@ function initState(state) {
643
648
  __name(initState, "initState");
644
649
 
645
650
  // src/decorators/index.ts
646
- import { mergeState as mergeState3, setModalVar as setModalVar3 } from "phecda-core";
651
+ import { setModelVar as setModelVar3, setState as setState3 } from "phecda-core";
647
652
 
648
653
  // src/decorators/param.ts
649
- import { mergeState, setModalVar } from "phecda-core";
654
+ import { setModelVar, setState } from "phecda-core";
650
655
  function BaseParam(type, key, validate) {
651
656
  return (target, k, index) => {
652
- setModalVar(target, k);
653
- mergeState(target, k, {
654
- params: [
655
- {
656
- type,
657
- key,
658
- index,
659
- validate
660
- }
661
- ]
657
+ setModelVar(target, k);
658
+ const state = target._namespace.__STATE_NAMESPACE__.get(k) || {};
659
+ if (!state.params)
660
+ state.params = [];
661
+ state.params.push({
662
+ type,
663
+ key,
664
+ index,
665
+ validate
662
666
  });
667
+ setState(target, k, state);
663
668
  };
664
669
  }
665
670
  __name(BaseParam, "BaseParam");
@@ -667,7 +672,7 @@ function Body(key = "", pipeOpts) {
667
672
  return BaseParam("body", key, pipeOpts);
668
673
  }
669
674
  __name(Body, "Body");
670
- function Query(key, pipeOpts) {
675
+ function Query(key = "", pipeOpts) {
671
676
  return BaseParam("query", key, pipeOpts);
672
677
  }
673
678
  __name(Query, "Query");
@@ -677,26 +682,19 @@ function Param(key, pipeOpts) {
677
682
  __name(Param, "Param");
678
683
 
679
684
  // src/decorators/route.ts
680
- import { mergeState as mergeState2, setModalVar as setModalVar2 } from "phecda-core";
685
+ import { setModelVar as setModelVar2, setState as setState2 } from "phecda-core";
681
686
  function Route(route, type) {
682
687
  return (target, key) => {
683
- if (key) {
684
- setModalVar2(target, key);
685
- mergeState2(target, key, {
686
- route: {
687
- route,
688
- type
689
- }
690
- });
691
- } else {
692
- setModalVar2(target.prototype, "__CLASS");
693
- mergeState2(target.prototype, "__CLASS", {
694
- route: {
695
- route,
696
- type
697
- }
698
- });
699
- }
688
+ if (!key)
689
+ key = "__CLASS";
690
+ target = key === "__CLASS" ? target.prototype : target;
691
+ setModelVar2(target, key);
692
+ const state = target._namespace.__STATE_NAMESPACE__.get(key) || {};
693
+ state.route = {
694
+ route,
695
+ type
696
+ };
697
+ setState2(target, key, state);
700
698
  };
701
699
  }
702
700
  __name(Route, "Route");
@@ -722,61 +720,43 @@ function Controller(route) {
722
720
  __name(Controller, "Controller");
723
721
  function Guard(...guards) {
724
722
  return (target, key) => {
725
- if (key) {
726
- setModalVar2(target, key);
727
- mergeState2(target, key, {
728
- guards: [
729
- ...guards
730
- ]
731
- });
732
- } else {
733
- setModalVar2(target.prototype, "__CLASS");
734
- mergeState2(target.prototype, "__CLASS", {
735
- guards: [
736
- ...guards
737
- ]
738
- });
739
- }
723
+ if (!key)
724
+ key = "__CLASS";
725
+ target = key === "__CLASS" ? target.prototype : target;
726
+ setModelVar2(target, key);
727
+ const state = target._namespace.__STATE_NAMESPACE__.get(key) || {};
728
+ if (!state.guards)
729
+ state.guards = [];
730
+ state.guards.push(...guards);
731
+ setState2(target, key, state);
740
732
  };
741
733
  }
742
734
  __name(Guard, "Guard");
743
735
  function Middle(...middlewares) {
744
736
  return (target, key) => {
745
- if (key) {
746
- setModalVar2(target, key);
747
- mergeState2(target, key, {
748
- middlewares: [
749
- ...middlewares
750
- ]
751
- });
752
- } else {
753
- setModalVar2(target.prototype, "__CLASS");
754
- mergeState2(target.prototype, "__CLASS", {
755
- middlewares: [
756
- ...middlewares
757
- ]
758
- });
759
- }
737
+ if (!key)
738
+ key = "__CLASS";
739
+ target = key === "__CLASS" ? target.prototype : target;
740
+ setModelVar2(target, key);
741
+ const state = target._namespace.__STATE_NAMESPACE__.get(key) || {};
742
+ if (!state.middlewares)
743
+ state.middlewares = [];
744
+ state.middlewares.push(...middlewares);
745
+ setState2(target, key, state);
760
746
  };
761
747
  }
762
748
  __name(Middle, "Middle");
763
749
  function Interceptor(...interceptors) {
764
750
  return (target, key) => {
765
- if (key) {
766
- setModalVar2(target, key);
767
- mergeState2(target, key, {
768
- interceptors: [
769
- ...interceptors
770
- ]
771
- });
772
- } else {
773
- setModalVar2(target.prototype, "__CLASS");
774
- mergeState2(target.prototype, "__CLASS", {
775
- interceptors: [
776
- ...interceptors
777
- ]
778
- });
779
- }
751
+ if (!key)
752
+ key = "__CLASS";
753
+ target = key === "__CLASS" ? target.prototype : target;
754
+ setModelVar2(target, key);
755
+ const state = target._namespace.__STATE_NAMESPACE__.get(key) || {};
756
+ if (!state.interceptors)
757
+ state.interceptors = [];
758
+ state.interceptors.push(...interceptors);
759
+ setState2(target, key, state);
780
760
  };
781
761
  }
782
762
  __name(Interceptor, "Interceptor");
@@ -784,33 +764,27 @@ __name(Interceptor, "Interceptor");
784
764
  // src/decorators/index.ts
785
765
  function Header(name, value) {
786
766
  return (target, k) => {
787
- setModalVar3(target, k);
788
- mergeState3(target, k, {
789
- header: {
790
- name,
791
- value
792
- }
793
- });
767
+ setModelVar3(target, k);
768
+ const state = target._namespace.__STATE_NAMESPACE__.get(k) || {};
769
+ if (!state.header)
770
+ state.header = {};
771
+ state.header[name] = value;
772
+ setState3(target, k, state);
794
773
  };
795
774
  }
796
775
  __name(Header, "Header");
797
776
  function Define(key, value) {
798
777
  return (target, k) => {
799
- if (k) {
800
- setModalVar3(target, k);
801
- mergeState3(target, k, {
802
- define: {
803
- [key]: value
804
- }
805
- });
806
- } else {
807
- setModalVar3(target.prototype, "__CLASS");
808
- mergeState3(target.prototype, "__CLASS", {
809
- define: {
810
- [key]: value
811
- }
812
- });
778
+ if (!k) {
779
+ k = "__CLASS";
780
+ target = target.prototype;
813
781
  }
782
+ setModelVar3(target, k);
783
+ const state = target._namespace.__STATE_NAMESPACE__.get(k) || {};
784
+ if (!state.define)
785
+ state.define = {};
786
+ state.define[key] = value;
787
+ setState3(target, k, state);
814
788
  };
815
789
  }
816
790
  __name(Define, "Define");
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/pipe.ts","../src/exception/base.ts","../src/exception/validate.ts","../src/exception/undefine.ts","../src/exception/forbidden.ts","../src/exception/bad-request.ts","../src/exception/not-found.ts","../src/exception/conflict.ts","../src/exception/bad-gateway.ts","../src/exception/invalid-input.ts","../src/exception/media-type.ts","../src/exception/payload-large.ts","../src/exception/timeout.ts","../src/exception/unauthorized.ts","../src/exception/unavailable-service.ts","../src/exception/framework.ts","../src/filter.ts","../src/history.ts","../src/context/base.ts","../src/context/server.ts","../src/types.ts","../src/utils.ts","../src/common.ts","../src/server/express.ts","../src/core.ts","../src/meta.ts","../src/decorators/index.ts","../src/decorators/param.ts","../src/decorators/route.ts","../src/index.ts"],"sourcesContent":["import { isPhecda, plainToClass } from 'phecda-core'\nimport { ValidateException } from './exception/validate'\n\nimport type { P } from './types'\n\nexport const defaultPipe = {\n // todo: add more params\n async transform(args: { arg: any; validate: boolean }[], reflect: any[]) {\n for (const i in args) {\n const { validate, arg } = args[i]\n if (validate === false || !reflect[i]/** work for undefined */)\n continue\n\n if (isPhecda(reflect[i])) {\n const ret = await plainToClass(reflect[i], arg, { transform: true })\n if (ret.err.length > 0)\n throw new ValidateException(ret.err[0])\n args[i].arg = ret.data\n }\n else {\n if ([Number, Boolean].includes(reflect[i])) {\n args[i].arg = reflect[i](arg)\n\n if (reflect[i] === Number && Object.is(args[i].arg, NaN))\n throw new ValidateException(`parameter ${Number(i) + 1} should be a number`)\n }\n }\n }\n return args.map(item => item.arg)\n },\n} as P.Pipe\n","export class HttpException extends Error {\n constructor(public message: string, public status: number, public description = 'Http exception') {\n super(message)\n }\n\n get data() {\n return { message: this.message, description: this.description, status: this.status, error: true }\n }\n}\n","import { HttpException } from './base'\n\nexport class ValidateException extends HttpException {\n constructor(message: string) {\n super(message, 400, 'Validate exception')\n }\n}\n","import { HttpException } from './base'\n\nexport class UndefinedException extends HttpException {\n constructor(message: string) {\n super(message, 500, 'Undefined error')\n }\n}\n","import { HttpException } from './base'\n\nexport class ForbiddenException extends HttpException {\n constructor(message: string) {\n super(message, 403, 'Forbidden resource')\n }\n}\n","import { HttpException } from './base'\n\nexport class BadRequestException extends HttpException {\n constructor(message: string) {\n super(message, 400, 'Bad Request')\n }\n}\n","import { HttpException } from './base'\n\nexport class NotFoundException extends HttpException {\n constructor(message: string) {\n super(message, 404, 'Not Found')\n }\n}\n","import { HttpException } from './base'\n\nexport class ConflictException extends HttpException {\n constructor(message: string) {\n super(message, 409, 'Conflict')\n }\n}\n","import { HttpException } from './base'\n\nexport class BadGatewayException extends HttpException {\n constructor(message: string) {\n super(message, 502, 'Bad Gatrway')\n }\n}\n","import { HttpException } from './base'\n\nexport class InvalidInputException extends HttpException {\n constructor(message: string) {\n super(message, 502, 'Invalid Input')\n }\n}\n","import { HttpException } from './base'\n\nexport class UnsupportedMediaTypeException extends HttpException {\n constructor(message: string) {\n super(message, 415, 'Unsupported Media Type')\n }\n}\n","import { HttpException } from './base'\n\nexport class PayloadLargeException extends HttpException {\n constructor(message: string) {\n super(message, 413, 'Payload Too Large')\n }\n}\n","import { HttpException } from './base'\n\nexport class TimeoutException extends HttpException {\n constructor(message: string) {\n super(message, 408, 'Request Timeout',\n )\n }\n}\n","import { HttpException } from './base'\n\nexport class UnauthorizedException extends HttpException {\n constructor(message: string) {\n super(message, 401, 'Unauthorized')\n }\n}\n","import { HttpException } from './base'\n\nexport class ServiceUnavailableException extends HttpException {\n constructor(message: string) {\n super(message, 503, 'Service Unavailable')\n }\n}\n","import { HttpException } from './base'\n\nexport class FrameworkException extends HttpException {\n constructor(message: string) {\n super(`[phecda-server] ${message}`, 500, 'Framework Error')\n }\n}\n","import { HttpException, UndefinedException } from './exception'\nimport type { ServerFilter } from './types'\n\nexport const serverFilter: ServerFilter = (e: any) => {\n if (!(e instanceof HttpException))\n e = new UndefinedException(e.message || e)\n return e.data\n}\n","export class Phistroy {\n guard: string[] = []\n interceptor: string[] = []\n record(name: string, type: 'guard' | 'interceptor') {\n if (!this[type].includes(name)) {\n this[type].push(name)\n return true\n }\n return false\n }\n}\n","import { ForbiddenException, FrameworkException } from '../exception'\nimport { Phistroy } from '../history'\n\nimport type { Meta } from '../meta'\nimport type { P } from '../types'\n\nexport abstract class Context<Data = any> {\n method: string\n params: string[]\n\n static metaRecord: Record<string, Meta> = {}\n static metaDataRecord: Record<string, ReturnType<typeof parseMeta>> = {}\n static instanceRecord: Record<string, any> = {}\n static guardsRecord: Record<string, any> = {}\n static interceptorsRecord: Record<string, any > = {}\n // static serverRecord: Record<string, Context> = {}\n post: ((...params: any) => any)[]\n history = new Phistroy()\n\n constructor(public key: string, public data: Data) {\n }\n\n static registerGuard(key: string, handler: any) {\n Context.guardsRecord[key] = handler\n }\n\n static registerInterceptor(key: string, handler: any) {\n Context.interceptorsRecord[key] = handler\n }\n\n async useGuard(guards: string[], isMerge = false) {\n for (const guard of guards) {\n if (this.history.record(guard, 'guard')) {\n if (!(guard in Context.guardsRecord))\n throw new FrameworkException(`can't find guard named ${guard}`)\n if (!await Context.guardsRecord[guard](this.data, isMerge))\n throw new ForbiddenException(`Guard exception--${guard}`)\n }\n }\n }\n\n async useInterceptor(interceptors: string[], isMerge = false) {\n const ret = []\n for (const interceptor of interceptors) {\n if (this.history.record(interceptor, 'interceptor')) {\n if (!(interceptor in Context.interceptorsRecord))\n throw new FrameworkException(`can't find guard named ${interceptor}`)\n const post = await Context.interceptorsRecord[interceptor](this.data, isMerge)\n if (post)\n ret.push(post)\n }\n }\n this.post = ret\n }\n\n async usePost(data: any) {\n if (!this.post)\n return data\n for (const cb of this.post)\n data = (await cb(data)) | data\n\n return data\n }\n}\n\nexport function addGuard(key: string, handler: P.Guard) {\n Context.registerGuard(key, handler)\n}\n\nexport function addInterceptor(key: string, handler: P.Interceptor) {\n Context.registerInterceptor(key, handler)\n}\nexport function getInstance(tag: string) {\n return Context.instanceRecord[tag]\n}\n\nexport function parseMeta(meta: Meta) {\n const { data: { params, guards, interceptors, middlewares }, reflect } = meta\n return {\n guards,\n reflect,\n interceptors,\n middlewares,\n params: params.map((param) => {\n const { type, key, validate } = param\n return { type, key, validate }\n }),\n }\n}\n","import type { RequestHandler } from 'express'\nimport { defaultPipe } from '../pipe'\nimport { serverFilter } from '../filter'\nimport { FrameworkException } from '../exception'\nimport type { P, ServerCtx, ServerFilter, ServerMergeCtx } from '../types'\nimport { Context } from './base'\n\nexport class ServerContext extends Context<ServerCtx | ServerMergeCtx > {\n static pipe = defaultPipe\n static filter = serverFilter\n static middlewareRecord: Record<string, (...params: any) => any> = {}\n static useMiddleware(middlewares: string[]) {\n return middlewares.map((m) => {\n if (!(m in ServerContext.middlewareRecord))\n throw new FrameworkException(`can't find middleware named ${m}`)\n return ServerContext.middlewareRecord[m]\n })\n }\n\n async usePipe(args: { arg: any; validate?: boolean }[], reflect: any[]) {\n return ServerContext.pipe.transform?.(args, reflect)\n }\n\n static useFilter(arg: any, data: ServerCtx | ServerMergeCtx) {\n return ServerContext.filter(arg, data)\n }\n\n useFilter(arg: any) {\n return ServerContext.filter(arg, this.data)\n }\n}\n\nexport function addMiddleware(key: string, handler: RequestHandler) {\n ServerContext.middlewareRecord[key] = handler\n}\n\nexport function useServerPipe(pipe: P.Pipe) {\n ServerContext.pipe = pipe\n}\nexport function useServerFilter(filter: ServerFilter) {\n ServerContext.filter = filter\n}\n","import type { Request, Response } from 'express'\nimport type { Events } from 'phecda-core'\nimport type { Meta } from './meta'\nimport type { HttpException } from './exception'\nexport type Construct<T = any> = new (...args: any[]) => T\n\nexport interface Emitter {\n on<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n once<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n off<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n removeAllListeners<N extends keyof Events>(eventName: N): void\n emit<N extends keyof Events>(eventName: N, param: Events[N]): void\n}\n\nexport type RequestType = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head'\n\nexport type MergeType = <R extends Promise<any>[]> (...args: R) => { [K in keyof R]: Awaited<R[K]> }\n\nexport interface ServerMergeCtx {\n request: Request\n response: Response\n meta: Record<string, Meta>\n isMerge: true\n tags?: string[]\n}\n\nexport interface ServerCtx {\n request: Request\n response: Response\n meta: Meta\n}\nexport interface BaseError {\n error: true\n status: number\n}\nexport type ServerFilter<E extends HttpException = any> = (err: E | Error, contextData: ServerMergeCtx | ServerCtx) => any\n\nexport class Base {\n context: ServerMergeCtx | ServerCtx\n}\n\nexport namespace P{\n export interface Error extends BaseError { message: string; description: string}\n\n export type ResOrErr<R > = { [K in keyof R]: Awaited<R[K]> | Error }\n\n export type Res<T> = T\n export type Guard = ((contextData: ServerCtx, isMerge?: false) => Promise<boolean> | boolean) | ((contextData: ServerMergeCtx, isMerge?: true) => Promise<boolean> | boolean)\n export type Interceptor = ((contextData: ServerCtx, isMerge?: false) => any) | ((contextData: ServerMergeCtx, isMerge?: true) => any)\n export interface Handler {\n error?: (arg: any) => void\n }\n export interface Meta {\n route?: {\n type: RequestType\n route: string\n }\n // mq?: {\n // queue: string\n // routeKey: string\n // options: amqplib.Options.Consume\n\n // }\n define?: any\n header: Record<string, string>\n params: { type: string; index: number; key: string; validate?: boolean }[]\n guards: string[]\n interceptors: string[]\n middlewares: string[]\n method: string\n name: string\n tag: string\n }\n export interface Pipe {\n transform(args: { arg: any; validate?: boolean }[], reflect: any[]): Promise<any[]>\n }\n\n}\n","import type { ServerCtx, ServerMergeCtx } from './types'\n\nexport const isUndefined = (obj: any): obj is undefined =>\n typeof obj === 'undefined'\nexport const isNil = (obj: any): obj is null | undefined =>\n isUndefined(obj) || obj === null\n\nexport const isObject = (fn: any): fn is object =>\n !isNil(fn) && typeof fn === 'object'\n\nexport function resolveDep(ret: any, key: string) {\n if (key)\n return ret?.[key]\n return ret\n}\n\nexport function isMerge(data: ServerCtx | ServerMergeCtx): data is ServerMergeCtx {\n return !!(data as ServerMergeCtx).isMerge\n}\n\nconst fnRegexCheckCacheMap = new WeakMap()\n\nexport function isConstructable(fn: any) {\n const hasPrototypeMethods\n = fn.prototype && fn.prototype.constructor === fn && Object.getOwnPropertyNames(fn.prototype).length > 1\n\n if (hasPrototypeMethods)\n return true\n if (fnRegexCheckCacheMap.has(fn))\n return fnRegexCheckCacheMap.get(fn)\n\n let constructable = hasPrototypeMethods\n if (!constructable) {\n const fnString = fn.toString()\n const constructableFunctionRegex = /^function\\b\\s[A-Z].*/\n const classRegex = /^class\\b/\n constructable = constructableFunctionRegex.test(fnString) || classRegex.test(fnString)\n }\n fnRegexCheckCacheMap.set(fn, constructable)\n\n return constructable\n}\n","export const SERIES_SYMBOL = '__symbol_series__'\nexport const MERGE_SYMBOL = '__symbol_req__'\n","import type { Express, Router } from 'express'\nimport { Context, ServerContext, parseMeta } from '../context'\nimport { isObject, resolveDep } from '../utils'\nimport { MERGE_SYMBOL, SERIES_SYMBOL } from '../common'\nimport type { Factory } from '../core'\nimport { BadRequestException } from '../exception'\nimport type { Meta } from '../meta'\nimport type { ServerMergeCtx } from '../types'\n\nexport interface Options {\n/**\n * 专用路由的值,默认为/__PHECDA_SERVER__,处理phecda-client发出的合并请求\n */\n route?: string\n /**\n * 全局守卫\n */\n globalGuards?: string[]\n /**\n * 全局拦截器\n */\n globalInterceptors?: string[]\n /**\n * 专用路由的中间件,全局中间件请在bindApp以外设置\n */\n middlewares?: string[]\n}\n\nexport function bindApp(app: Express | Router, { meta, moduleMap }: Awaited<ReturnType<typeof Factory>>, options: Options = {}) {\n const { globalGuards, globalInterceptors, route, middlewares: proMiddle } = { route: '/__PHECDA_SERVER__', globalGuards: [], globalInterceptors: [], middlewares: [], ...options } as Required<Options>\n const methodMap = {} as Record<string, (...args: any[]) => any>\n const contextMeta = {} as Record<string, Meta>\n for (const i of meta) {\n const { name, method, route, header, tag } = i.data\n const instance = moduleMap.get(tag)!\n const methodTag = `${tag}-${method}`\n contextMeta[methodTag] = i\n Context.metaRecord[methodTag] = i\n let {\n guards,\n reflect,\n interceptors,\n params,\n middlewares,\n } = Context.metaDataRecord[methodTag] ? Context.metaDataRecord[methodTag] : (Context.metaDataRecord[methodTag] = parseMeta(i))\n\n guards = [...globalGuards!, ...guards]\n interceptors = [...globalInterceptors!, ...interceptors]\n\n const handler = instance[method].bind(instance)\n methodMap[methodTag] = handler\n Context.instanceRecord[name] = instance\n if (route) {\n (app as Express)[route.type](route.route, ...ServerContext.useMiddleware(middlewares), async (req, res) => {\n const contextData = {\n request: req,\n meta: i,\n response: res,\n }\n const context = new ServerContext(methodTag, contextData)\n\n try {\n for (const name in header)\n res.set(name, header[name])\n await context.useGuard(guards)\n await context.useInterceptor(interceptors)\n const args = await context.usePipe(params.map(({ type, key, validate }) => {\n return { arg: resolveDep((req as any)[type], key), validate }\n }), reflect)\n instance.context = contextData\n\n const ret = await context.usePost(await handler(...args))\n if (isObject(ret))\n res.json(ret)\n else\n res.send(String(ret))\n }\n catch (e: any) {\n i.handlers.forEach(handler => handler.error?.(e))\n const err = await context.useFilter(e)\n res.status(err.status).json(err)\n }\n })\n }\n }\n\n (app as Express).post(route, (req, _res, next) => {\n (req as any)[MERGE_SYMBOL] = true\n next()\n }, ...ServerContext.useMiddleware(proMiddle), async (req, res) => {\n const { body: { category, data } } = req\n\n const contextData = {\n request: req,\n response: res,\n meta: contextMeta,\n isMerge: true,\n } as unknown as ServerMergeCtx\n\n if (!Array.isArray(data))\n return res.json(await ServerContext.useFilter(new BadRequestException('data format should be an array'), contextData))\n\n contextData.tags = data.map((item: any) => item.tag)\n\n const context = new ServerContext(route, contextData)\n const ret = [] as any[]\n\n if (category === 'series') {\n for (const item of data) {\n const { tag } = item\n const [name] = tag.split('-')\n const {\n guards,\n reflect,\n interceptors,\n params,\n } = Context.metaDataRecord[tag]\n const instance = moduleMap.get(name)\n\n try {\n if (!params)\n throw new BadRequestException(`\"${tag}\" doesn't exist`)\n\n await context.useGuard(guards, true)\n await context.useInterceptor(interceptors, true)\n const args = await context.usePipe(params.map(({ type, key, validate }) => {\n const arg = resolveDep(item[type], key)\n if (typeof arg === 'string' && arg.startsWith(SERIES_SYMBOL)) {\n const [, index, argKey] = arg.split('@')\n return { arg: resolveDep(ret[Number(index)], argKey || key), validate }\n }\n\n return { arg, validate }\n }), reflect) as any\n instance.context = contextData\n\n ret.push(await context.usePost(await methodMap[tag](...args)))\n }\n catch (e: any) {\n const m = Context.metaRecord[tag]\n m.handlers.forEach(handler => handler.error?.(e))\n ret.push(await context.useFilter(e))\n }\n }\n return res.json(ret)\n }\n if (category === 'parallel') {\n return Promise.all(data.map((item: any) => {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve) => {\n const { tag } = item\n const [name] = tag.split('-')\n const {\n guards,\n reflect,\n interceptors,\n params,\n } = Context.metaDataRecord[tag]\n const instance = moduleMap.get(name)\n\n try {\n if (!params)\n throw new BadRequestException(`\"${tag}\" doesn't exist`)\n\n await context.useGuard(guards, true)\n await context.useInterceptor(interceptors, true)\n const args = await context.usePipe(params.map(({ type, key, validate }) => {\n const arg = resolveDep(item[type], key)\n return { arg, validate }\n }), reflect) as any\n instance.context = contextData\n resolve(await context.usePost(await methodMap[tag](...args)))\n }\n catch (e: any) {\n const m = Context.metaRecord[tag]\n m.handlers.forEach(handler => handler.error?.(e))\n resolve(await context.useFilter(e))\n }\n })\n })).then((ret) => {\n res.json(ret)\n })\n }\n\n res.json(await context.useFilter(new BadRequestException('category should be \\'parallel\\' or \\'series\\'')))\n })\n}\n","import 'reflect-metadata'\nimport fs from 'fs'\nimport EventEmitter from 'node:events'\nimport type { Phecda } from 'phecda-core'\nimport { getExposeKey, getHandler, getState, injectProperty, registerAsync } from 'phecda-core'\nimport type { Construct, Emitter, P } from './types'\nimport { Meta } from './meta'\n// TODO: support both emitter types and origin emitter type in future\nexport const emitter: Emitter = new EventEmitter() as any\n\nexport async function Factory(Modules: (new (...args: any) => any)[]) {\n const moduleMap = new Map<string, InstanceType<Construct>>()\n const meta: Meta[] = []\n injectProperty('watcher', ({ eventName, instance, key, options }: { eventName: string; instance: any; key: string; options?: { once: boolean } }) => {\n const fn = typeof instance[key] === 'function' ? instance[key].bind(instance) : (v: any) => instance[key] = v\n\n if (options?.once)\n (emitter as any).once(eventName, fn)\n\n else\n (emitter as any).on(eventName, fn)\n })\n\n for (const Module of Modules)\n await buildNestModule(Module, moduleMap, meta)\n\n return { moduleMap, meta, output: (p = 'pmeta.js') => fs.writeFileSync(p, JSON.stringify(meta.map(item => item.data))) }\n}\n\nasync function buildNestModule(Module: Construct, map: Map<string, InstanceType<Construct>>, meta: Meta[]) {\n const paramtypes = getParamtypes(Module) as Construct[]\n let instance: InstanceType<Construct>\n const tag = Module.prototype?.__TAG__ || Module.name\n if (map.has(tag)) {\n instance = map.get(tag)\n if (!instance)\n throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${tag}--[module] ${Module}`)\n\n return instance\n }\n map.set(tag, undefined)\n if (paramtypes) {\n const paramtypesInstances = [] as any[]\n for (const i in paramtypes)\n paramtypesInstances[i] = await buildNestModule(paramtypes[i], map, meta)\n\n instance = new Module(...paramtypesInstances)\n }\n else {\n instance = new Module()\n }\n meta.push(...getMetaFromInstance(instance, Module.name, tag))\n await registerAsync(instance)\n map.set(tag, instance)\n\n return instance\n}\n\nfunction getMetaFromInstance(instance: Phecda, name: string, tag: string) {\n const vars = getExposeKey(instance).filter(item => item !== '__CLASS')\n const baseState = (getState(instance, '__CLASS') || {}) as P.Meta\n initState(baseState)\n return vars.map((i) => {\n const state = (getState(instance, i) || {}) as P.Meta\n if (baseState.route && state.route)\n state.route.route = baseState.route.route + state.route.route\n state.name = name\n state.tag = tag\n state.method = i\n const params = [] as any[]\n for (const i of state.params || []) {\n params.unshift(i)\n if (i.index === 0)\n break\n }\n state.params = params\n initState(state)\n state.define = { ...baseState.define, ...state.define }\n state.header = { ...baseState.header, ...state.header }\n state.middlewares = [...new Set([...baseState.middlewares, ...state.middlewares])]\n state.guards = [...new Set([...baseState.guards, ...state.guards])]\n state.interceptors = [...new Set([...baseState.interceptors, ...state.interceptors])]\n\n return new Meta(state as unknown as P.Meta, getHandler(instance, i), getParamtypes(instance, i) || [])\n })\n}\n\nfunction getParamtypes(Module: any, key?: string | symbol) {\n return Reflect.getMetadata('design:paramtypes', Module, key!)\n}\n\nfunction initState(state: any) {\n if (!state.define)\n state.define = {}\n if (!state.header)\n state.header = {}\n if (!state.middlewares)\n state.middlewares = []\n if (!state.guards)\n state.guards = []\n if (!state.interceptors)\n state.interceptors = []\n}\n","import type { P } from './types'\n\nexport class Meta {\n constructor(public data: P.Meta, public handlers: P.Handler[], public reflect: any[]) {\n\n }\n}\n","import { mergeState, setModalVar } from 'phecda-core'\n/**\n *\n * @deprecate\n */\n// export function Inject(_target: any) { }\n\nexport function Header(name: string, value: string) {\n return (target: any, k: PropertyKey) => {\n setModalVar(target, k)\n mergeState(target, k, {\n header: { name, value },\n })\n }\n}\n\nexport function Define(key: string, value: any) {\n return (target: any, k?: PropertyKey) => {\n if (k) {\n setModalVar(target, k)\n mergeState(target, k, {\n define: { [key]: value },\n })\n }\n else {\n setModalVar(target.prototype, '__CLASS')\n mergeState(target.prototype, '__CLASS', {\n define: { [key]: value },\n })\n }\n }\n}\n\nexport * from './param'\nexport * from './route'\n","import { mergeState, setModalVar } from 'phecda-core'\n\nexport function BaseParam(type: string, key: string, validate?: any): any {\n return (target: any, k: PropertyKey, index: number) => {\n setModalVar(target, k)\n mergeState(target, k, {\n params: [{ type, key, index, validate }],\n })\n }\n}\n\nexport function Body(key = '', pipeOpts?: any) {\n return BaseParam('body', key, pipeOpts)\n}\nexport function Query(key: string, pipeOpts?: any) {\n return BaseParam('query', key, pipeOpts)\n}\nexport function Param(key: string, pipeOpts?: any) {\n return BaseParam('params', key, pipeOpts)\n}\n","import { mergeState, setModalVar } from 'phecda-core'\n\nexport function Route(route: string, type?: string): any {\n return (target: any, key?: PropertyKey) => {\n if (key) {\n setModalVar(target, key)\n mergeState(target, key, {\n route: {\n route,\n type,\n },\n })\n }\n else {\n setModalVar(target.prototype, '__CLASS')\n mergeState(target.prototype, '__CLASS', {\n route: {\n route,\n type,\n },\n })\n }\n }\n}\n\nexport function Get(route: string) {\n return Route(route, 'get')\n}\n\nexport function Post(route: string) {\n return Route(route, 'post')\n}\nexport function Put(route: string) {\n return Route(route, 'put')\n}\n\nexport function Delete(route: string) {\n return Route(route, 'delete')\n}\n\nexport function Controller(route: string) {\n return Route(route)\n}\n\nexport function Guard(...guards: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (key) {\n setModalVar(target, key)\n mergeState(target, key, {\n guards: [...guards],\n })\n }\n else {\n setModalVar(target.prototype, '__CLASS')\n mergeState(target.prototype, '__CLASS', {\n guards: [...guards],\n })\n }\n }\n}\n\nexport function Middle(...middlewares: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (key) {\n setModalVar(target, key)\n mergeState(target, key, {\n middlewares: [...middlewares],\n })\n }\n else {\n setModalVar(target.prototype, '__CLASS')\n mergeState(target.prototype, '__CLASS', {\n middlewares: [...middlewares],\n })\n }\n }\n}\n\nexport function Interceptor(...interceptors: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (key) {\n setModalVar(target, key)\n mergeState(target, key, {\n interceptors: [...interceptors],\n })\n }\n else {\n setModalVar(target.prototype, '__CLASS')\n mergeState(target.prototype, '__CLASS', {\n interceptors: [...interceptors],\n })\n }\n }\n}\n","export * from './context'\nexport * from './types'\nexport * from './server/express'\nexport * from './core'\nexport * from './decorators'\nexport * from './exception'\nexport * from './pipe'\nexport * from './meta'\nexport * from 'phecda-core'\nexport * from './utils'\nexport * from './common'\n"],"mappings":";;;;;;;;;AAAA,SAASA,UAAUC,oBAAoB;;;ACAhC,IAAMC,gBAAN,cAA4BC,MAAAA;EACdC;EAAwBC;EAAuBC;EAAlEC,YAAmBH,SAAwBC,QAAuBC,cAAc,kBAAkB;AAChG,UAAMF,OAAAA;mBADWA;kBAAwBC;uBAAuBC;EAElE;EAEA,IAAIE,OAAO;AACT,WAAO;MAAEJ,SAAS,KAAKA;MAASE,aAAa,KAAKA;MAAaD,QAAQ,KAAKA;MAAQI,OAAO;IAAK;EAClG;AACF;AARaP;;;ACEN,IAAMQ,oBAAN,cAAgCC,cAAAA;EACrCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,oBAAA;EACtB;AACF;AAJaH;;;AFGN,IAAMI,cAAc;EAEzB,MAAMC,UAAUC,MAAyCC,SAAgB;AACvE,eAAWC,KAAKF,MAAM;AACpB,YAAM,EAAE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,YAAWH,OAAOQ,WAAW,WAAW;QACtCD,QAAQ;UAAE,CAACD,MAAMP;QAAM;MACzB,CAAA;IACF;EACF;AACF;AAfgBM;;;AGRhB,cAAc;","names":["isPhecda","plainToClass","HttpException","Error","message","status","description","constructor","data","error","ValidateException","HttpException","constructor","message","defaultPipe","transform","args","reflect","i","validate","arg","isPhecda","ret","plainToClass","err","length","ValidateException","data","Number","Boolean","includes","Object","is","NaN","map","item","UndefinedException","HttpException","constructor","message","ForbiddenException","HttpException","constructor","message","BadRequestException","HttpException","constructor","message","NotFoundException","HttpException","constructor","message","ConflictException","HttpException","constructor","message","BadGatewayException","HttpException","constructor","message","InvalidInputException","HttpException","constructor","message","UnsupportedMediaTypeException","HttpException","constructor","message","PayloadLargeException","HttpException","constructor","message","TimeoutException","HttpException","constructor","message","UnauthorizedException","HttpException","constructor","message","ServiceUnavailableException","HttpException","constructor","message","FrameworkException","HttpException","constructor","message","serverFilter","e","HttpException","UndefinedException","message","data","Phistroy","guard","interceptor","record","name","type","includes","push","Context","key","data","method","params","post","history","constructor","Phistroy","registerGuard","handler","guardsRecord","registerInterceptor","interceptorsRecord","useGuard","guards","isMerge","guard","record","FrameworkException","ForbiddenException","useInterceptor","interceptors","ret","interceptor","push","usePost","cb","metaRecord","metaDataRecord","instanceRecord","addGuard","addInterceptor","getInstance","tag","parseMeta","meta","middlewares","reflect","map","param","type","validate","ServerContext","Context","useMiddleware","middlewares","map","m","middlewareRecord","FrameworkException","usePipe","args","reflect","pipe","transform","useFilter","arg","data","filter","defaultPipe","serverFilter","addMiddleware","key","handler","useServerPipe","useServerFilter","Base","context","isUndefined","obj","isNil","isObject","fn","resolveDep","ret","key","isMerge","data","fnRegexCheckCacheMap","WeakMap","isConstructable","hasPrototypeMethods","prototype","constructor","Object","getOwnPropertyNames","length","has","get","constructable","fnString","toString","constructableFunctionRegex","classRegex","test","set","SERIES_SYMBOL","MERGE_SYMBOL","bindApp","app","meta","moduleMap","options","globalGuards","globalInterceptors","route","middlewares","proMiddle","methodMap","contextMeta","i","name","method","header","tag","data","instance","get","methodTag","Context","metaRecord","guards","reflect","interceptors","params","metaDataRecord","parseMeta","handler","bind","instanceRecord","type","ServerContext","useMiddleware","req","res","contextData","request","response","context","set","useGuard","useInterceptor","args","usePipe","map","key","validate","arg","resolveDep","ret","usePost","isObject","json","send","String","e","handlers","forEach","error","err","useFilter","status","post","_res","next","MERGE_SYMBOL","body","category","isMerge","Array","isArray","BadRequestException","tags","item","split","startsWith","SERIES_SYMBOL","index","argKey","Number","push","m","Promise","all","resolve","then","fs","EventEmitter","getExposeKey","getHandler","getState","injectProperty","registerAsync","Meta","data","handlers","reflect","constructor","emitter","EventEmitter","Factory","Modules","moduleMap","Map","meta","injectProperty","eventName","instance","key","options","fn","bind","v","once","on","Module","buildNestModule","output","p","fs","writeFileSync","JSON","stringify","map","item","data","paramtypes","getParamtypes","tag","prototype","__TAG__","name","has","get","Error","set","undefined","paramtypesInstances","i","push","getMetaFromInstance","registerAsync","vars","getExposeKey","filter","baseState","getState","initState","state","route","method","params","unshift","index","define","header","middlewares","Set","guards","interceptors","Meta","getHandler","Reflect","getMetadata","mergeState","setModalVar","mergeState","setModalVar","BaseParam","type","key","validate","target","k","index","setModalVar","mergeState","params","Body","pipeOpts","Query","Param","mergeState","setModalVar","Route","route","type","target","key","setModalVar","mergeState","prototype","Get","Post","Put","Delete","Controller","Guard","guards","Middle","middlewares","Interceptor","interceptors","Header","name","value","target","k","setModalVar","mergeState","header","Define","key","define","prototype"]}
1
+ {"version":3,"sources":["../src/pipe.ts","../src/exception/base.ts","../src/exception/validate.ts","../src/exception/undefine.ts","../src/exception/forbidden.ts","../src/exception/bad-request.ts","../src/exception/not-found.ts","../src/exception/conflict.ts","../src/exception/bad-gateway.ts","../src/exception/invalid-input.ts","../src/exception/media-type.ts","../src/exception/payload-large.ts","../src/exception/timeout.ts","../src/exception/unauthorized.ts","../src/exception/unavailable-service.ts","../src/exception/framework.ts","../src/filter.ts","../src/history.ts","../src/context/base.ts","../src/context/server.ts","../src/types.ts","../src/utils.ts","../src/common.ts","../src/server/express.ts","../src/core.ts","../src/meta.ts","../src/decorators/index.ts","../src/decorators/param.ts","../src/decorators/route.ts","../src/index.ts"],"sourcesContent":["import { isPhecda, plainToClass } from 'phecda-core'\nimport { ValidateException } from './exception/validate'\n\nimport type { P } from './types'\n\nexport const defaultPipe = {\n // todo: add more params\n async transform(args: { arg: any; validate: boolean }[], reflect: any[]) {\n for (const i in args) {\n const { validate, arg } = args[i]\n if (validate === false || !reflect[i]/** work for undefined */)\n continue\n\n if (isPhecda(reflect[i])) {\n const ret = await plainToClass(reflect[i], arg, { transform: true })\n if (ret.err.length > 0)\n throw new ValidateException(ret.err[0])\n args[i].arg = ret.data\n }\n else {\n if ([Number, Boolean].includes(reflect[i])) {\n args[i].arg = reflect[i](arg)\n\n if (reflect[i] === Number && Object.is(args[i].arg, NaN))\n throw new ValidateException(`parameter ${Number(i) + 1} should be a number`)\n }\n }\n }\n return args.map(item => item.arg)\n },\n} as P.Pipe\n","export class HttpException extends Error {\n constructor(public message: string, public status: number, public description = 'Http exception') {\n super(message)\n }\n\n get data() {\n return { message: this.message, description: this.description, status: this.status, error: true }\n }\n}\n","import { HttpException } from './base'\n\nexport class ValidateException extends HttpException {\n constructor(message: string) {\n super(message, 400, 'Validate exception')\n }\n}\n","import { HttpException } from './base'\n\nexport class UndefinedException extends HttpException {\n constructor(message: string) {\n super(message, 500, 'Undefined error')\n }\n}\n","import { HttpException } from './base'\n\nexport class ForbiddenException extends HttpException {\n constructor(message: string) {\n super(message, 403, 'Forbidden resource')\n }\n}\n","import { HttpException } from './base'\n\nexport class BadRequestException extends HttpException {\n constructor(message: string) {\n super(message, 400, 'Bad Request')\n }\n}\n","import { HttpException } from './base'\n\nexport class NotFoundException extends HttpException {\n constructor(message: string) {\n super(message, 404, 'Not Found')\n }\n}\n","import { HttpException } from './base'\n\nexport class ConflictException extends HttpException {\n constructor(message: string) {\n super(message, 409, 'Conflict')\n }\n}\n","import { HttpException } from './base'\n\nexport class BadGatewayException extends HttpException {\n constructor(message: string) {\n super(message, 502, 'Bad Gatrway')\n }\n}\n","import { HttpException } from './base'\n\nexport class InvalidInputException extends HttpException {\n constructor(message: string) {\n super(message, 502, 'Invalid Input')\n }\n}\n","import { HttpException } from './base'\n\nexport class UnsupportedMediaTypeException extends HttpException {\n constructor(message: string) {\n super(message, 415, 'Unsupported Media Type')\n }\n}\n","import { HttpException } from './base'\n\nexport class PayloadLargeException extends HttpException {\n constructor(message: string) {\n super(message, 413, 'Payload Too Large')\n }\n}\n","import { HttpException } from './base'\n\nexport class TimeoutException extends HttpException {\n constructor(message: string) {\n super(message, 408, 'Request Timeout',\n )\n }\n}\n","import { HttpException } from './base'\n\nexport class UnauthorizedException extends HttpException {\n constructor(message: string) {\n super(message, 401, 'Unauthorized')\n }\n}\n","import { HttpException } from './base'\n\nexport class ServiceUnavailableException extends HttpException {\n constructor(message: string) {\n super(message, 503, 'Service Unavailable')\n }\n}\n","import { HttpException } from './base'\n\nexport class FrameworkException extends HttpException {\n constructor(message: string) {\n super(`[phecda-server] ${message}`, 500, 'Framework Error')\n }\n}\n","import { HttpException, UndefinedException } from './exception'\nimport type { ServerFilter } from './types'\n\nexport const serverFilter: ServerFilter = (e: any) => {\n if (!(e instanceof HttpException))\n e = new UndefinedException(e.message || e)\n return e.data\n}\n","export class Phistroy {\n guard: string[] = []\n interceptor: string[] = []\n record(name: string, type: 'guard' | 'interceptor') {\n if (!this[type].includes(name)) {\n this[type].push(name)\n return true\n }\n return false\n }\n}\n","import { ForbiddenException, FrameworkException } from '../exception'\nimport { Phistroy } from '../history'\n\nimport type { Meta } from '../meta'\nimport type { P } from '../types'\n\nexport abstract class Context<Data = any> {\n method: string\n params: string[]\n\n static metaRecord: Record<string, Meta> = {}\n static metaDataRecord: Record<string, ReturnType<typeof parseMeta>> = {}\n static instanceRecord: Record<string, any> = {}\n static guardsRecord: Record<string, any> = {}\n static interceptorsRecord: Record<string, any > = {}\n // static serverRecord: Record<string, Context> = {}\n post: ((...params: any) => any)[]\n history = new Phistroy()\n\n constructor(public key: string, public data: Data) {\n }\n\n static registerGuard(key: string, handler: any) {\n Context.guardsRecord[key] = handler\n }\n\n static registerInterceptor(key: string, handler: any) {\n Context.interceptorsRecord[key] = handler\n }\n\n async useGuard(guards: string[], isMerge = false) {\n for (const guard of guards) {\n if (this.history.record(guard, 'guard')) {\n if (!(guard in Context.guardsRecord))\n throw new FrameworkException(`can't find guard named ${guard}`)\n if (!await Context.guardsRecord[guard](this.data, isMerge))\n throw new ForbiddenException(`Guard exception--${guard}`)\n }\n }\n }\n\n async useInterceptor(interceptors: string[], isMerge = false) {\n const ret = []\n for (const interceptor of interceptors) {\n if (this.history.record(interceptor, 'interceptor')) {\n if (!(interceptor in Context.interceptorsRecord))\n throw new FrameworkException(`can't find guard named ${interceptor}`)\n const post = await Context.interceptorsRecord[interceptor](this.data, isMerge)\n if (post)\n ret.push(post)\n }\n }\n this.post = ret\n }\n\n async usePost(data: any) {\n if (!this.post)\n return data\n for (const cb of this.post)\n data = (await cb(data)) | data\n\n return data\n }\n}\n\nexport function addGuard(key: string, handler: P.Guard) {\n Context.registerGuard(key, handler)\n}\n\nexport function addInterceptor(key: string, handler: P.Interceptor) {\n Context.registerInterceptor(key, handler)\n}\nexport function getInstance(tag: string) {\n return Context.instanceRecord[tag]\n}\n\nexport function parseMeta(meta: Meta) {\n const { data: { params, guards, interceptors, middlewares }, reflect } = meta\n return {\n guards,\n reflect,\n interceptors,\n middlewares,\n params: params.map((param) => {\n const { type, key, validate } = param\n return { type, key, validate }\n }),\n }\n}\n","import type { RequestHandler } from 'express'\nimport { defaultPipe } from '../pipe'\nimport { serverFilter } from '../filter'\nimport { FrameworkException } from '../exception'\nimport type { P, ServerCtx, ServerFilter, ServerMergeCtx } from '../types'\nimport { Context } from './base'\n\nexport class ServerContext extends Context<ServerCtx | ServerMergeCtx > {\n static pipe = defaultPipe\n static filter = serverFilter\n static middlewareRecord: Record<string, (...params: any) => any> = {}\n static useMiddleware(middlewares: string[]) {\n return middlewares.map((m) => {\n if (!(m in ServerContext.middlewareRecord))\n throw new FrameworkException(`can't find middleware named ${m}`)\n return ServerContext.middlewareRecord[m]\n })\n }\n\n async usePipe(args: { arg: any; validate?: boolean }[], reflect: any[]) {\n return ServerContext.pipe.transform?.(args, reflect)\n }\n\n static useFilter(arg: any, data: ServerCtx | ServerMergeCtx) {\n return ServerContext.filter(arg, data)\n }\n\n useFilter(arg: any) {\n return ServerContext.filter(arg, this.data)\n }\n}\n\nexport function addMiddleware(key: string, handler: RequestHandler) {\n ServerContext.middlewareRecord[key] = handler\n}\n\nexport function useServerPipe(pipe: P.Pipe) {\n ServerContext.pipe = pipe\n}\nexport function useServerFilter(filter: ServerFilter) {\n ServerContext.filter = filter\n}\n","import type { Request, Response } from 'express'\nimport type { Events } from 'phecda-core'\nimport type { Meta } from './meta'\nimport type { HttpException } from './exception'\nexport type Construct<T = any> = new (...args: any[]) => T\n\nexport interface Emitter {\n on<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n once<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n off<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void\n removeAllListeners<N extends keyof Events>(eventName: N): void\n emit<N extends keyof Events>(eventName: N, param: Events[N]): void\n}\n\nexport type RequestType = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head'\n\nexport type MergeType = <R extends Promise<any>[]> (...args: R) => { [K in keyof R]: Awaited<R[K]> }\n\nexport interface ServerMergeCtx {\n request: Request\n response: Response\n meta: Record<string, Meta>\n isMerge: true\n tags?: string[]\n}\n\nexport interface ServerCtx {\n request: Request\n response: Response\n meta: Meta\n}\nexport interface BaseError {\n error: true\n status: number\n}\nexport type ServerFilter<E extends HttpException = any> = (err: E | Error, contextData: ServerMergeCtx | ServerCtx) => any\n\nexport class Base {\n context: ServerMergeCtx | ServerCtx\n}\n\nexport namespace P{\n export interface Error extends BaseError { message: string; description: string}\n\n export type ResOrErr<R > = { [K in keyof R]: Awaited<R[K]> | Error }\n\n export type Res<T> = T\n export type Guard = ((contextData: ServerCtx, isMerge?: false) => Promise<boolean> | boolean) | ((contextData: ServerMergeCtx, isMerge?: true) => Promise<boolean> | boolean)\n export type Interceptor = ((contextData: ServerCtx, isMerge?: false) => any) | ((contextData: ServerMergeCtx, isMerge?: true) => any)\n export interface Handler {\n error?: (arg: any) => void\n }\n export interface Meta {\n route?: {\n type: RequestType\n route: string\n }\n // mq?: {\n // queue: string\n // routeKey: string\n // options: amqplib.Options.Consume\n\n // }\n define?: any\n header: Record<string, string>\n params: { type: string; index: number; key: string; validate?: boolean }[]\n guards: string[]\n interceptors: string[]\n middlewares: string[]\n method: string\n name: string\n tag: string\n }\n export interface Pipe {\n transform(args: { arg: any; validate?: boolean }[], reflect: any[]): Promise<any[]>\n }\n\n}\n","import type { ServerCtx, ServerMergeCtx } from './types'\n\nexport const isUndefined = (obj: any): obj is undefined =>\n typeof obj === 'undefined'\nexport const isNil = (obj: any): obj is null | undefined =>\n isUndefined(obj) || obj === null\n\nexport const isObject = (fn: any): fn is object =>\n !isNil(fn) && typeof fn === 'object'\n\nexport function resolveDep(ret: any, key: string) {\n if (key)\n return ret?.[key]\n return ret\n}\n\nexport function isMerge(data: ServerCtx | ServerMergeCtx): data is ServerMergeCtx {\n return !!(data as ServerMergeCtx).isMerge\n}\n\nconst fnRegexCheckCacheMap = new WeakMap()\n\nexport function isConstructable(fn: any) {\n const hasPrototypeMethods\n = fn.prototype && fn.prototype.constructor === fn && Object.getOwnPropertyNames(fn.prototype).length > 1\n\n if (hasPrototypeMethods)\n return true\n if (fnRegexCheckCacheMap.has(fn))\n return fnRegexCheckCacheMap.get(fn)\n\n let constructable = hasPrototypeMethods\n if (!constructable) {\n const fnString = fn.toString()\n const constructableFunctionRegex = /^function\\b\\s[A-Z].*/\n const classRegex = /^class\\b/\n constructable = constructableFunctionRegex.test(fnString) || classRegex.test(fnString)\n }\n fnRegexCheckCacheMap.set(fn, constructable)\n\n return constructable\n}\n","export const SERIES_SYMBOL = '__symbol_series__'\nexport const MERGE_SYMBOL = '__symbol_req__'\n","import type { Express, Router } from 'express'\nimport { Context, ServerContext, parseMeta } from '../context'\nimport { isObject, resolveDep } from '../utils'\nimport { MERGE_SYMBOL, SERIES_SYMBOL } from '../common'\nimport type { Factory } from '../core'\nimport { BadRequestException } from '../exception'\nimport type { Meta } from '../meta'\nimport type { ServerMergeCtx } from '../types'\n\nexport interface Options {\n/**\n * 专用路由的值,默认为/__PHECDA_SERVER__,处理phecda-client发出的合并请求\n */\n route?: string\n /**\n * 全局守卫\n */\n globalGuards?: string[]\n /**\n * 全局拦截器\n */\n globalInterceptors?: string[]\n /**\n * 专用路由的中间件,全局中间件请在bindApp以外设置\n */\n middlewares?: string[]\n}\n\nexport function bindApp(app: Express | Router, { meta, moduleMap }: Awaited<ReturnType<typeof Factory>>, options: Options = {}) {\n const { globalGuards, globalInterceptors, route, middlewares: proMiddle } = { route: '/__PHECDA_SERVER__', globalGuards: [], globalInterceptors: [], middlewares: [], ...options } as Required<Options>\n const methodMap = {} as Record<string, (...args: any[]) => any>\n const contextMeta = {} as Record<string, Meta>\n for (const i of meta) {\n const { name, method, route, header, tag } = i.data\n const instance = moduleMap.get(tag)!\n const methodTag = `${tag}-${method}`\n contextMeta[methodTag] = i\n Context.metaRecord[methodTag] = i\n let {\n guards,\n reflect,\n interceptors,\n params,\n middlewares,\n } = Context.metaDataRecord[methodTag] ? Context.metaDataRecord[methodTag] : (Context.metaDataRecord[methodTag] = parseMeta(i))\n\n guards = [...globalGuards!, ...guards]\n interceptors = [...globalInterceptors!, ...interceptors]\n\n const handler = instance[method].bind(instance)\n methodMap[methodTag] = handler\n Context.instanceRecord[name] = instance\n if (route) {\n (app as Express)[route.type](route.route, ...ServerContext.useMiddleware(middlewares), async (req, res) => {\n const contextData = {\n request: req,\n meta: i,\n response: res,\n }\n const context = new ServerContext(methodTag, contextData)\n\n try {\n for (const name in header)\n res.set(name, header[name])\n await context.useGuard(guards)\n await context.useInterceptor(interceptors)\n const args = await context.usePipe(params.map(({ type, key, validate }) => {\n return { arg: resolveDep((req as any)[type], key), validate }\n }), reflect)\n instance.context = contextData\n\n const ret = await context.usePost(await handler(...args))\n if (isObject(ret))\n res.json(ret)\n else\n res.send(String(ret))\n }\n catch (e: any) {\n i.handlers.forEach(handler => handler.error?.(e))\n const err = await context.useFilter(e)\n res.status(err.status).json(err)\n }\n })\n }\n }\n\n (app as Express).post(route, (req, _res, next) => {\n (req as any)[MERGE_SYMBOL] = true\n next()\n }, ...ServerContext.useMiddleware(proMiddle), async (req, res) => {\n const { body: { category, data } } = req\n\n const contextData = {\n request: req,\n response: res,\n meta: contextMeta,\n isMerge: true,\n } as unknown as ServerMergeCtx\n\n if (!Array.isArray(data))\n return res.json(await ServerContext.useFilter(new BadRequestException('data format should be an array'), contextData))\n\n contextData.tags = data.map((item: any) => item.tag)\n\n const context = new ServerContext(route, contextData)\n const ret = [] as any[]\n\n if (category === 'series') {\n for (const item of data) {\n const { tag } = item\n const [name] = tag.split('-')\n const {\n guards,\n reflect,\n interceptors,\n params,\n } = Context.metaDataRecord[tag]\n const instance = moduleMap.get(name)\n\n try {\n if (!params)\n throw new BadRequestException(`\"${tag}\" doesn't exist`)\n\n await context.useGuard(guards, true)\n await context.useInterceptor(interceptors, true)\n const args = await context.usePipe(params.map(({ type, key, validate }) => {\n const arg = resolveDep(item[type], key)\n if (typeof arg === 'string' && arg.startsWith(SERIES_SYMBOL)) {\n const [, index, argKey] = arg.split('@')\n return { arg: resolveDep(ret[Number(index)], argKey || key), validate }\n }\n\n return { arg, validate }\n }), reflect) as any\n instance.context = contextData\n\n ret.push(await context.usePost(await methodMap[tag](...args)))\n }\n catch (e: any) {\n const m = Context.metaRecord[tag]\n m.handlers.forEach(handler => handler.error?.(e))\n ret.push(await context.useFilter(e))\n }\n }\n return res.json(ret)\n }\n if (category === 'parallel') {\n return Promise.all(data.map((item: any) => {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve) => {\n const { tag } = item\n const [name] = tag.split('-')\n const {\n guards,\n reflect,\n interceptors,\n params,\n } = Context.metaDataRecord[tag]\n const instance = moduleMap.get(name)\n\n try {\n if (!params)\n throw new BadRequestException(`\"${tag}\" doesn't exist`)\n\n await context.useGuard(guards, true)\n await context.useInterceptor(interceptors, true)\n const args = await context.usePipe(params.map(({ type, key, validate }) => {\n const arg = resolveDep(item[type], key)\n return { arg, validate }\n }), reflect) as any\n instance.context = contextData\n resolve(await context.usePost(await methodMap[tag](...args)))\n }\n catch (e: any) {\n const m = Context.metaRecord[tag]\n m.handlers.forEach(handler => handler.error?.(e))\n resolve(await context.useFilter(e))\n }\n })\n })).then((ret) => {\n res.json(ret)\n })\n }\n\n res.json(await context.useFilter(new BadRequestException('category should be \\'parallel\\' or \\'series\\'')))\n })\n}\n","import 'reflect-metadata'\nimport fs from 'fs'\nimport EventEmitter from 'node:events'\nimport type { Phecda } from 'phecda-core'\nimport { getExposeKey, getHandler, getState, injectProperty, registerAsync } from 'phecda-core'\nimport type { Construct, Emitter, P } from './types'\nimport { Meta } from './meta'\n// TODO: support both emitter types and origin emitter type in future\nexport const emitter: Emitter = new EventEmitter() as any\n\nexport async function Factory(Modules: (new (...args: any) => any)[]) {\n const moduleMap = new Map<string, InstanceType<Construct>>()\n const meta: Meta[] = []\n injectProperty('watcher', ({ eventName, instance, key, options }: { eventName: string; instance: any; key: string; options?: { once: boolean } }) => {\n const fn = typeof instance[key] === 'function' ? instance[key].bind(instance) : (v: any) => instance[key] = v\n\n if (options?.once)\n (emitter as any).once(eventName, fn)\n\n else\n (emitter as any).on(eventName, fn)\n })\n\n for (const Module of Modules)\n await buildNestModule(Module, moduleMap, meta)\n\n return { moduleMap, meta, output: (p = 'pmeta.js') => fs.writeFileSync(p, JSON.stringify(meta.map(item => item.data))) }\n}\n\nasync function buildNestModule(Module: Construct, map: Map<string, InstanceType<Construct>>, meta: Meta[]) {\n const paramtypes = getParamtypes(Module) as Construct[]\n let instance: InstanceType<Construct>\n const tag = Module.prototype?.__TAG__ || Module.name\n\n if (map.has(tag)) {\n instance = map.get(tag)\n if (!instance)\n throw new Error(`exist Circular-Dependency or Multiple modules with the same name/tag [tag] ${tag}--[module] ${Module}`)\n\n return instance\n }\n map.set(tag, undefined)\n if (paramtypes) {\n const paramtypesInstances = [] as any[]\n for (const i in paramtypes)\n paramtypesInstances[i] = await buildNestModule(paramtypes[i], map, meta)\n\n instance = new Module(...paramtypesInstances)\n }\n else {\n instance = new Module()\n }\n meta.push(...getMetaFromInstance(instance, Module.name, tag))\n await registerAsync(instance)\n map.set(tag, instance)\n\n return instance\n}\n\nfunction getMetaFromInstance(instance: Phecda, name: string, tag: string) {\n const vars = getExposeKey(instance).filter(item => item !== '__CLASS')\n const baseState = (getState(instance, '__CLASS') || {}) as P.Meta\n initState(baseState)\n\n return vars.map((i) => {\n const meta = {} as P.Meta\n const state = (getState(instance, i) || {}) as P.Meta\n initState(state)\n if (state.route) {\n meta.route = {\n route: (baseState.route?.route || '') + (state.route.route),\n type: state.route.type,\n }\n }\n\n meta.name = name\n meta.tag = tag\n meta.method = i as string\n const params = [] as any[]\n for (const i of state.params || []) {\n params.unshift(i)\n if (i.index === 0)\n break\n }\n meta.params = params\n meta.define = { ...baseState.define, ...state.define }\n meta.header = { ...baseState.header, ...state.header }\n meta.middlewares = [...new Set([...baseState.middlewares, ...state.middlewares])]\n meta.guards = [...new Set([...baseState.guards, ...state.guards])]\n meta.interceptors = [...new Set([...baseState.interceptors, ...state.interceptors])]\n\n return new Meta(meta as unknown as P.Meta, getHandler(instance, i), getParamtypes(instance, i as string) || [])\n })\n}\n\nfunction getParamtypes(Module: any, key?: string | symbol) {\n return Reflect.getMetadata('design:paramtypes', Module, key!)\n}\n\nfunction initState(state: any) {\n if (!state.define)\n state.define = {}\n if (!state.header)\n state.header = {}\n if (!state.middlewares)\n state.middlewares = []\n if (!state.guards)\n state.guards = []\n if (!state.interceptors)\n state.interceptors = []\n}\n","import type { P } from './types'\n\nexport class Meta {\n constructor(public data: P.Meta, public handlers: P.Handler[], public reflect: any[]) {\n\n }\n}\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function Header(name: string, value: string) {\n return (target: any, k: PropertyKey) => {\n setModelVar(target, k)\n const state = target._namespace.__STATE_NAMESPACE__.get(k) || {}\n if (!state.header)\n state.header = {}\n\n state.header[name] = value\n setState(target, k, state)\n }\n}\n\nexport function Define(key: string, value: any) {\n return (target: any, k?: PropertyKey) => {\n if (!k) {\n k = '__CLASS'\n target = target.prototype\n }\n\n setModelVar(target, k)\n const state = target._namespace.__STATE_NAMESPACE__.get(k) || {}\n if (!state.define)\n state.define = {}\n\n state.define[key] = value\n setState(target, k, state)\n }\n}\n\nexport * from './param'\nexport * from './route'\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function BaseParam(type: string, key: string, validate?: any): any {\n return (target: any, k: PropertyKey, index: number) => {\n setModelVar(target, k)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(k) || {}\n if (!state.params)\n state.params = []\n\n state.params.push({ type, key, index, validate })\n setState(target, k, state)\n }\n}\n\nexport function Body(key = '', pipeOpts?: any) {\n return BaseParam('body', key, pipeOpts)\n}\nexport function Query(key = '', pipeOpts?: any) {\n return BaseParam('query', key, pipeOpts)\n}\nexport function Param(key: string, pipeOpts?: any) {\n return BaseParam('params', key, pipeOpts)\n}\n","import { setModelVar, setState } from 'phecda-core'\n\nexport function Route(route: string, type?: string): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n state.route = {\n route,\n type,\n }\n setState(target, key, state)\n }\n}\n\nexport function Get(route: string) {\n return Route(route, 'get')\n}\n\nexport function Post(route: string) {\n return Route(route, 'post')\n}\nexport function Put(route: string) {\n return Route(route, 'put')\n}\n\nexport function Delete(route: string) {\n return Route(route, 'delete')\n}\n\nexport function Controller(route: string) {\n return Route(route)\n}\n\nexport function Guard(...guards: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n if (!state.guards)\n state.guards = []\n state.guards.push(...guards)\n setState(target, key, state)\n }\n}\n\nexport function Middle(...middlewares: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n if (!state.middlewares)\n state.middlewares = []\n state.middlewares.push(...middlewares)\n setState(target, key, state)\n }\n}\n\nexport function Interceptor(...interceptors: string[]): any {\n return (target: any, key?: PropertyKey) => {\n if (!key)\n key = '__CLASS'\n target = key === '__CLASS' ? target.prototype : target\n\n setModelVar(target, key)\n\n const state = target._namespace.__STATE_NAMESPACE__.get(key) || {}\n if (!state.interceptors)\n state.interceptors = []\n state.interceptors.push(...interceptors)\n setState(target, key, state)\n }\n}\n","export * from './context'\nexport * from './types'\nexport * from './server/express'\nexport * from './core'\nexport * from './decorators'\nexport * from './exception'\nexport * from './pipe'\nexport * from './meta'\nexport * from 'phecda-core'\nexport * from './utils'\nexport * from './common'\n"],"mappings":";;;;;;;;;AAAA,SAASA,UAAUC,oBAAoB;;;ACAhC,IAAMC,gBAAN,cAA4BC,MAAAA;EACdC;EAAwBC;EAAuBC;EAAlEC,YAAmBH,SAAwBC,QAAuBC,cAAc,kBAAkB;AAChG,UAAMF,OAAAA;mBADWA;kBAAwBC;uBAAuBC;EAElE;EAEA,IAAIE,OAAO;AACT,WAAO;MAAEJ,SAAS,KAAKA;MAASE,aAAa,KAAKA;MAAaD,QAAQ,KAAKA;MAAQI,OAAO;IAAK;EAClG;AACF;AARaP;;;ACEN,IAAM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,CAAC;AACjE,QAAI,CAACG,MAAMgB;AACThB,YAAMgB,eAAe,CAAA;AACvBhB,UAAMgB,aAAaJ,KAAI,GAAII,YAAAA;AAC3BZ,IAAAA,UAASR,QAAQC,KAAKG,KAAAA;EACxB;AACF;AAdgBe;;;AFpET,SAASE,OAAOC,MAAcC,OAAe;AAClD,SAAO,CAACC,QAAaC,MAAmB;AACtCC,IAAAA,aAAYF,QAAQC,CAAAA;AACpB,UAAME,QAAQH,OAAOI,WAAWC,oBAAoBC,IAAIL,CAAAA,KAAM,CAAC;AAC/D,QAAI,CAACE,MAAMI;AACTJ,YAAMI,SAAS,CAAC;AAElBJ,UAAMI,OAAOT,QAAQC;AACrBS,IAAAA,UAASR,QAAQC,GAAGE,KAAAA;EACtB;AACF;AAVgBN;AAYT,SAASY,OAAOC,KAAaX,OAAY;AAC9C,SAAO,CAACC,QAAaC,MAAoB;AACvC,QAAI,CAACA,GAAG;AACNA,UAAI;AACJD,eAASA,OAAOW;IAClB;AAEAT,IAAAA,aAAYF,QAAQC,CAAAA;AACpB,UAAME,QAAQH,OAAOI,WAAWC,oBAAoBC,IAAIL,CAAAA,KAAM,CAAC;AAC/D,QAAI,CAACE,MAAMS;AACTT,YAAMS,SAAS,CAAC;AAElBT,UAAMS,OAAOF,OAAOX;AACpBS,IAAAA,UAASR,QAAQC,GAAGE,KAAAA;EACtB;AACF;AAfgBM;;;AGNhB,cAAc;","names":["isPhecda","plainToClass","HttpException","Error","message","status","description","constructor","data","error","ValidateException","HttpException","constructor","message","defaultPipe","transform","args","reflect","i","validate","arg","isPhecda","ret","plainToClass","err","length","ValidateException","data","Number","Boolean","includes","Object","is","NaN","map","item","UndefinedException","HttpException","constructor","message","ForbiddenException","HttpException","constructor","message","BadRequestException","HttpException","constructor","message","NotFoundException","HttpException","constructor","message","ConflictException","HttpException","constructor","message","BadGatewayException","HttpException","constructor","message","InvalidInputException","HttpException","constructor","message","UnsupportedMediaTypeException","HttpException","constructor","message","PayloadLargeException","HttpException","constructor","message","TimeoutException","HttpException","constructor","message","UnauthorizedException","HttpException","constructor","message","ServiceUnavailableException","HttpException","constructor","message","FrameworkException","HttpException","constructor","message","serverFilter","e","HttpException","UndefinedException","message","data","Phistroy","guard","interceptor","record","name","type","includes","push","Context","key","data","method","params","post","history","constructor","Phistroy","registerGuard","handler","guardsRecord","registerInterceptor","interceptorsRecord","useGuard","guards","isMerge","guard","record","FrameworkException","ForbiddenException","useInterceptor","interceptors","ret","interceptor","push","usePost","cb","metaRecord","metaDataRecord","instanceRecord","addGuard","addInterceptor","getInstance","tag","parseMeta","meta","middlewares","reflect","map","param","type","validate","ServerContext","Context","useMiddleware","middlewares","map","m","middlewareRecord","FrameworkException","usePipe","args","reflect","pipe","transform","useFilter","arg","data","filter","defaultPipe","serverFilter","addMiddleware","key","handler","useServerPipe","useServerFilter","Base","context","isUndefined","obj","isNil","isObject","fn","resolveDep","ret","key","isMerge","data","fnRegexCheckCacheMap","WeakMap","isConstructable","hasPrototypeMethods","prototype","constructor","Object","getOwnPropertyNames","length","has","get","constructable","fnString","toString","constructableFunctionRegex","classRegex","test","set","SERIES_SYMBOL","MERGE_SYMBOL","bindApp","app","meta","moduleMap","options","globalGuards","globalInterceptors","route","middlewares","proMiddle","methodMap","contextMeta","i","name","method","header","tag","data","instance","get","methodTag","Context","metaRecord","guards","reflect","interceptors","params","metaDataRecord","parseMeta","handler","bind","instanceRecord","type","ServerContext","useMiddleware","req","res","contextData","request","response","context","set","useGuard","useInterceptor","args","usePipe","map","key","validate","arg","resolveDep","ret","usePost","isObject","json","send","String","e","handlers","forEach","error","err","useFilter","status","post","_res","next","MERGE_SYMBOL","body","category","isMerge","Array","isArray","BadRequestException","tags","item","split","startsWith","SERIES_SYMBOL","index","argKey","Number","push","m","Promise","all","resolve","then","fs","EventEmitter","getExposeKey","getHandler","getState","injectProperty","registerAsync","Meta","data","handlers","reflect","constructor","emitter","EventEmitter","Factory","Modules","moduleMap","Map","meta","injectProperty","eventName","instance","key","options","fn","bind","v","once","on","Module","buildNestModule","output","p","fs","writeFileSync","JSON","stringify","map","item","data","paramtypes","getParamtypes","tag","prototype","__TAG__","name","has","get","Error","set","undefined","paramtypesInstances","i","push","getMetaFromInstance","registerAsync","vars","getExposeKey","filter","baseState","getState","initState","state","route","type","method","params","unshift","index","define","header","middlewares","Set","guards","interceptors","Meta","getHandler","Reflect","getMetadata","setModelVar","setState","setModelVar","setState","BaseParam","type","key","validate","target","k","index","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","params","push","setState","Body","pipeOpts","Query","Param","setModelVar","setState","Route","route","type","target","key","prototype","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","setState","Get","Post","Put","Delete","Controller","Guard","guards","push","Middle","middlewares","Interceptor","interceptors","Header","name","value","target","k","setModelVar","state","_namespace","__STATE_NAMESPACE__","get","header","setState","Define","key","prototype","define"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-server",
3
- "version": "2.1.3",
3
+ "version": "3.0.0-alpha.0",
4
4
  "description": "provide express middlewares, `nestjs` format",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "eventemitter3": "^5.0.0",
29
29
  "reflect-metadata": "^0.1.13",
30
- "phecda-core": "1.7.0"
30
+ "phecda-core": "2.0.0-alpha.0"
31
31
  },
32
32
  "scripts": {
33
33
  "dev": "tsup --watch",