@tsed/di
Advanced tools
Comparing version 8.3.3 to 8.3.4
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@tsed/core"),require("@tsed/hooks"),require("@tsed/schema")):"function"==typeof define&&define.amd?define(["@tsed/core","@tsed/hooks","@tsed/schema"],t):"object"==typeof exports?exports["@tsed/di"]=t(require("@tsed/core"),require("@tsed/hooks"),require("@tsed/schema")):e["@tsed/di"]=t(e["@tsed/core"],e["@tsed/hooks"],e["@tsed/schema"])}(self,((e,t,r)=>(()=>{"use strict";var s={803:t=>{t.exports=e},488:e=>{e.exports=t},953:e=>{e.exports=r}},o={};function n(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return s[e](r,r.exports,n),r.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{n.r(i),n.d(i,{AutoInjectable:()=>A,CONFIGURATION:()=>b,Configuration:()=>W,Constant:()=>Z,Container:()=>y,Controller:()=>re,ControllerProvider:()=>j,DIConfiguration:()=>C,DI_INJECTABLE_PROPS:()=>t,DI_INTERCEPTOR_OPTIONS:()=>o,DI_INVOKE_OPTIONS:()=>e,DI_USE_OPTIONS:()=>r,DI_USE_PARAM_OPTIONS:()=>s,GlobalProviderRegistry:()=>f,GlobalProviders:()=>g,Inject:()=>J,Injectable:()=>se,InjectablePropertyType:()=>ee,InjectionError:()=>v,InjectorService:()=>R,Intercept:()=>ie,Interceptor:()=>ae,InvalidPropertyTokenError:()=>F,LOGGER:()=>Pe,LazyInject:()=>he,LocalsContainer:()=>h,Module:()=>pe,OptionalLazyInject:()=>de,Opts:()=>ge,OverrideProvider:()=>ye,Provider:()=>p,ProviderScope:()=>a,ProviderType:()=>c,Scope:()=>fe,Service:()=>me,UseOpts:()=>Oe,Value:()=>ke,bindConstant:()=>X,bindIntercept:()=>ne,bindValue:()=>ve,cleanAllLocalsContainer:()=>z,colors:()=>O,configuration:()=>N,constant:()=>Y,controller:()=>x,createContainer:()=>k,destroyInjector:()=>w,detachLocalsContainer:()=>H,discoverHooks:()=>d,getConfiguration:()=>Ce,getConstructorDependencies:()=>E,getInterceptorOptions:()=>oe,inject:()=>B,injectMany:()=>Q,injectable:()=>L,injector:()=>T,interceptor:()=>_,invokeOptions:()=>q,lazyInject:()=>ce,localsContainer:()=>K,mergeMount:()=>be,optionalLazyInject:()=>ue,providerBuilder:()=>M,refValue:()=>Ee,registerProvider:()=>D,setConstructorDependencies:()=>P});const e=Symbol("DI_INVOKE_OPTIONS"),t=Symbol("DI_INJECTABLE_PROPS"),r="DI_USE_OPTIONS",s="DI_USE_PARAM_OPTIONS",o="DI_INTERCEPTOR_OPTIONS";var a,c,u=n(803),l=n(488);class h extends Map{constructor(){super(...arguments),this.hooks=new l.Hooks}async destroy(){await this.hooks.asyncEmit("$onDestroy")}}function d(e){return(0,u.methodsOf)(e).reduce(((e,{propertyKey:t})=>{if(String(t).startsWith("$")){const r=(e,...r)=>e?.[t](...r);return{...e,[t]:r}}return e}),{})}!function(e){e.SINGLETON="singleton",e.REQUEST="request",e.INSTANCE="instance"}(a||(a={})),function(e){e.VALUE="value",e.PROVIDER="provider",e.MODULE="module",e.CONTROLLER="controller",e.INTERCEPTOR="interceptor",e.MIDDLEWARE="middleware"}(c||(c={}));class p{#e;#t;#r;#s;constructor(e,t={}){this.type=c.PROVIDER,this.hooks={},this.token=e,this.useClass=e,Object.assign(this,t),t instanceof p&&(this.#e=t.#e,this.#r=t.#r,this.#s=t.#s)}get token(){return this.#t}set token(e){e&&(this.#t=(0,u.getClassOrSymbol)(e),this.#s=this.#r=u.Store.from(e))}get provide(){return this.token}set provide(e){this.token=e}get useClass(){return this.#e}set useClass(e){(0,u.isClass)(e)&&(this.#e=(0,u.classOf)(e),this.#r=u.Store.from(e),this.hooks=d(this.#e))}get className(){return this.name}get name(){return(0,u.nameOf)(this.token)}get store(){return this.#r}get path(){return this.store.get("path","/")}set path(e){this.store.set("path",e)}get scope(){return this.isAsync()?a.SINGLETON:this.get("scope",a.SINGLETON)}set scope(e){this.store.set("scope",e)}get configuration(){return this.get("configuration")}set configuration(e){this.store.set("configuration",e)}get children(){return this.store.get("childrenControllers",[])}set children(e){this.store.set("childrenControllers",e)}getArgOpts(e){return this.store.get(`${s}:${e}`)}get(e,t){return this.store.get(e)||this.#s.get(e)||t}isAsync(){return!!this.useAsyncFactory}clone(){return new((0,u.classOf)(this))(this.token,this)}hasChildren(){return!!this.children.length}hasParent(){return!!this.store.get("parentController")}toString(){return["Token",this.name,this.useClass&&(0,u.nameOf)(this.useClass),this.useFactory&&"Factory",this.useValue&&"Value",this.useAsyncFactory&&"AsyncFactory"].filter(Boolean).join(":")}}class f extends Map{#o=new Map;get(e){return super.get((0,u.getClassOrSymbol)(e))}has(e){return super.has((0,u.getClassOrSymbol)(e))}set(e,t){return super.set((0,u.getClassOrSymbol)(e),t),this}merge(e,t){if(!1===t.global)return g.createProvider(e,t);const r=this.createIfNotExists(e,t);return Object.keys(t).forEach((e=>{r[e]=t[e]})),this.set(e,r),r}delete(e){return super.delete((0,u.getClassOrSymbol)(e))}createRegistry(e,t,r={}){const s=this.getRegistrySettings(e);return r=Object.assign(s,{...r,model:t}),this.#o.set(e,r),this}getRegistrySettings(e){let t=c.PROVIDER;if("string"==typeof e)t=e;else{const r=this.get(e);r&&(t=r.type)}return this.#o.get(t)||{model:p}}createProvider(e,t){const r=t.type||c.PROVIDER,{model:s=p}=this.#o.get(r)||{};return new s(e,t)}createIfNotExists(e,t){if(!this.has(e)){const r=this.createProvider(e,t);this.set(e,r)}return this.get(e)}}const g=new f;class y extends Map{add(e,t={}){const r=g.get(e)?.clone()||new p(e);return Object.assign(r,t),super.set(e,r)}addProvider(e,t={}){return this.add(e,t)}hasProvider(e){return super.has(e)}setProvider(e,t){return super.set(e,t)}getProvider(e){return super.get(e)}getProviders(e){const t=[].concat(e).map(String);return[...this].reduce(((r,[s,o])=>t.includes(String(o.type))||!e?[...r,o]:r),[])}addProviders(e){e.forEach((e=>{this.hasProvider(e.token)||this.setProvider(e.token,e.clone())}))}}const m=e=>e=>(process.env.NO_COLOR,e),O={red:m(),yellow:m(),green:m()};class v extends Error{constructor(e,t){super((0,u.isString)(t)?t:""),this.name="INJECTION_ERROR",this.tokens=[],this.tokens=[e],t&&((0,u.isString)(t)?this.origin={message:t,stack:this.stack}:t.tokens?(this.tokens=this.tokens.concat(t.tokens),this.origin=t.origin):(this.origin=t,this.stack=t.stack));const r=this.origin?"\nOrigin: "+this.origin.message:"",s=this.tokens.map((e=>(0,u.nameOf)(e))).join(" > ");this.message=`Injection failed on ${s}${r}`}static throwInjectorError(e,t,r){throw t&&(0,u.isClass)(e)&&(r.message=function(e,t){let r="";const s=(0,u.getConstructorArgNames)(e).map(((e,s)=>(t.index===s&&(r=e,e=O.red(e)),`${e}: ${(0,u.nameOf)(t.deps[s])}`))).join(", "),o=(0,u.nameOf)(e)+"->constructor("+s+")",n=o.indexOf(r)-5;return"Unable to inject dependency. "+t.message+"\n\n"+o+"\n"+(n>-1?(e=>" ".repeat(e)+O.red("^"+"‾".repeat(r.length-1)))(n):"")}(e,{...t,message:r.message})),new v(e,r)}}function k(e){const t=new y(g.entries());return e&&t.delete(e),t}function E(e,t){return u.Metadata.getOwn("override:ctor:design:paramtypes",e,t)||[...u.Metadata.getParamTypes(e,t)]||[]}function P(e,t){u.Metadata.set("override:ctor:design:paramtypes",t,e)}const b=Symbol.for("CONFIGURATION");class C{constructor(e={}){this.default=new Map,this.map=new Map,Object.entries({imports:[],routes:[],logger:{},...e}).forEach((([e,t])=>{this.default.set(e,t)}))}get version(){return this.get("version")}set version(e){this.map.set("version",e)}get rootDir(){return this.get("rootDir")}set rootDir(e){this.map.set("rootDir",e)}get env(){return this.map.get("env")}set env(e){this.map.set("env",e)}get imports(){return this.get("imports")}set imports(e){this.map.set("imports",e)}get routes(){return this.get("routes")}set routes(e){this.map.set("routes",e)}get logger(){return this.get("logger")}set logger(e){const t={...this.logger,...e};this.map.set("logger",t)}get debug(){return"debug"===this.logger.level}set debug(e){this.logger={...this.logger,level:e?"debug":"info"}}forEach(e,t){return new Set([...Array.from(this.default.keys()),...Array.from(this.map.keys())]).forEach((t=>{e(this.getRaw(t),t,this.map)}),t)}set(e,t){return"string"==typeof e?Reflect.has(this,e)?this[e]=t:this.setRaw(e,t):Object.entries(e).forEach((([e,t])=>{this.set(e,t)})),this}setRaw(e,t){return(0,u.setValue)(this.map,e,t),this}get(e,t){return this.getRaw(e,t)}getRaw(e,t){const r=(0,u.getValue)(this.map,e);return void 0!==r?r:(0,u.getValue)(this.default,e,t)}}const I=["mount","imports"];class R extends y{#n;#i;constructor(){super(),this.logger=console,this.resolvedConfiguration=!1,this.#n=new h,this.#i=!1,this.#n.set(R,this),this.#n.set(C,new C)}get settings(){return this.#n.get(C)}set settings(e){this.#n.set(C,e)}isLoaded(){return this.#i}toArray(){return[...this.#n.values()]}get(e,t){return this.has(e)?this.#n.get(e):this.resolve(e,t)}getMany(e,t){return this.getProviders(e).map((e=>this.resolve(e.token,t)))}has(e){return void 0!==this.#n.get(e)}alias(e,t){return this.#n.set(t,this.#n.get(e)),this}resolve(e,t={}){let r=t.locals?t.locals.get(e):void 0;if(void 0!==r)return r;if(e===s)return t.useOpts;if(r=t.rebuild?void 0:this.#n.get(e),null!=r)return r;const o=this.ensureProvider(e);if(!o||t.rebuild)return r=this.invokeToken(e,t),o?this.setToCache(o,r):r;switch(r=this.invokeToken(e,t),o.scope){case a.SINGLETON:return t.rebuild||this.registerHooks(o,t),this.setToCache(o,r);case a.REQUEST:return t.locals&&(t.locals.set(o.token,r),this.registerHooks(o,t)),r}return r}invoke(e,t={}){return this.resolve(e,t)}async loadAsync(){for(const[,e]of this)!this.has(e.token)&&e.isAsync()&&await this.resolve(e.token)}loadSync(){for(const[,e]of this)this.has(e.token)||e.scope!==a.SINGLETON||this.resolve(e.token)}async load(e=k()){this.#i=!0,await(0,l.$asyncEmit)("$beforeInit"),this.bootstrap(e),await this.loadAsync(),this.loadSync(),await(0,l.$asyncEmit)("$onInit")}resolveConfiguration(){if(this.resolvedConfiguration)return;const e=new Map;super.forEach((t=>{t.configuration&&"server:module"!==t.type&&Object.entries(t.configuration).forEach((([t,r])=>{I.includes(t)||(r=e.has(t)?(0,u.deepMerge)(e.get(t),r):(0,u.deepClone)(r),e.set(t,r))}))})),e.forEach(((e,t)=>{this.settings.set(t,(0,u.deepMerge)(e,this.settings.get(t)))})),this.resolvedConfiguration=!0}emit(e,...t){return(0,l.$asyncEmit)(e,t)}alter(e,t,...r){return(0,l.$alter)(e,t,r)}alterAsync(e,t,...r){return(0,l.$asyncAlter)(e,t,r)}async destroy(){await(0,l.$asyncEmit)("$onDestroy"),this.#n.forEach(((e,t)=>{(0,l.$off)(t)}))}bootstrap(e=k()){return this.addProviders(e),this.resolveConfiguration(),this.resolveImportsProviders(),this}ensureProvider(e,t=!1){return this.hasProvider(e)||!g.has(e)&&!t||this.addProvider(e),this.getProvider(e)}invokeToken(t,r={}){const s=this.mapInvokeOptions(t,r);if(!s)return;const{token:o,deps:n,construct:i,imports:a,provider:c}=s;let h;(0,l.$emit)("$beforeInvoke",o,[s]),(0,l.$emit)(`$beforeInvoke:${String(c.type)}`,[s]);let d=!1;try{const e=e=>(t,s)=>(d={token:t,index:s,deps:n},(0,u.isArray)(t)?this.getMany(t[0],r):(0,u.isInheritedFrom)(t,p,1)?c:this.resolve(t,{parent:e,locals:r.locals,useOpts:c?.getArgOpts(s)||r.useOpts}));a.forEach(e());const t=n.map(e(o));d=!1,h=i(t)}catch(e){v.throwInjectorError(o,d,e)}if(void 0===h)throw new v(o,`Unable to create new instance from undefined value. Check your provider declaration for ${(0,u.nameOf)(o)}`);return h&&(0,u.isClass)((0,u.classOf)(h))&&Reflect.defineProperty(h,e,{get:()=>({rebuild:r.rebuild,locals:r.locals})}),(0,l.$emit)("$afterInvoke",o,[h,s]),h}resolveImportsProviders(){this.settings.imports=this.settings.imports?.filter((e=>(0,u.isObject)(e)&&"token"in e&&e.token!==R)).map((e=>{if((0,u.isObject)(e)&&"token"in e){const{token:t,...r}=e,s=this.ensureProvider(t,!0);if(s){if(s.useValue=void 0,s.useAsyncFactory=void 0,s.useFactory=void 0,"useClass"in r)return void(s.useClass=r.useClass);if("useFactory"in r)return void(s.useFactory=r.useFactory);if("useAsyncFactory"in r)return void(s.useAsyncFactory=r.useAsyncFactory);if("use"in r)return void(s.useValue=r.use)}}return e})).filter(Boolean)}mapInvokeOptions(e,t){const r=t.locals||new h;t.locals=r;let s,o,n=t.imports,i=t.deps;if(!e||e===Object)throw new Error("Given token is undefined. Could mean a circular dependency problem. Try to use @Inject(() => Token) to solve it.");if(o=this.hasProvider(e)?this.getProvider(e):new p(e),i=i||o.deps,n=n||o.imports,void 0!==o.useValue)s=()=>(0,u.isFunction)(o.useValue)?o.useValue():o.useValue;else if(o.useFactory)s=e=>o.useFactory(...e);else if(o.useAsyncFactory)s=async e=>(e=await Promise.all(e),o.useAsyncFactory(...e));else{if(!o.useClass)return!1;i=i||E(o.useClass),s=e=>new o.useClass(...e)}return{token:e,deps:i||[],imports:n||[],construct:s,provider:o,locals:r}}registerHooks(e,t){if(e.hooks){if(e.scope===a.REQUEST){if(t.locals&&e.hooks?.$onDestroy){const{locals:r}=t;t.locals.hooks.on("$onDestroy",((...t)=>e.hooks?.$onDestroy?.(r.get(e.token),...t)))}return}Object.entries(e.hooks).forEach((([t,r])=>{(0,l.$on)(t,e.token,((...t)=>r(this.#n.get(e.token),...t)))}))}}setToCache(e,t){const r=t=>{this.#n.set(e.token,t),e?.alias&&this.alias(e.token,e.alias)};return!("isAsync"in e)||e.isAsync()||(0,u.isPromise)(t)?(r(t),t=t.then((e=>(r(e),e)))):(r(t),t)}}let S=new R;function T(){return S}async function w(){await S.destroy(),S=new R}function A(){return e=>class extends e{constructor(...t){super(...function(e,t){const r=T(),s=new h,o=E(e),n=[],i=Math.max(o.length,t.length);for(let a=0;a<i;a++)if(void 0!==t[a])n.push(t[a]);else{const t=o[a],i=(0,u.isArray)(t)?r.getMany(t[0],{locals:s,parent:e}):r.invoke(t,{locals:s,parent:e});n.push(i)}return n}(e,t))}}}function N(e,t){if(e){const r=u.Store.from(e);return t&&r.set("configuration",t),r.get("configuration",t)}return T().settings}class j extends p{constructor(e,t={}){super(e,t),this.type=c.CONTROLLER}get middlewares(){return Object.assign({use:[],useAfter:[],useBefore:[]},this.store.get("middlewares",{}))}set middlewares(e){const t=this.middlewares;Object.keys(e).forEach((r=>{((e,t,r)=>{t[e]=t[e].concat(r[e])})(r,t,e)})),this.store.set("middlewares",t)}}function D({token:e,provide:t,...r}){return L(e||t,{...r,token:e||t}).inspect()}function M(e,t={}){return(r,s={})=>{const o={global:!T().isLoaded(),...s,...t,token:r},n=g.merge(r,o);return o.global||T().setProvider(r,n),e.reduce(((e,t)=>({...e,[t]:function(e){return n[t]=e,this}})),{factory(e){return n.useFactory=e,this},asyncFactory(e){return n.useAsyncFactory=e,this},value(e){return n.useValue=e,n.type=c.VALUE,this},class(e){return n.useClass=e,this},store:()=>n.store,inspect:()=>n,token:()=>n.token})}}g.createRegistry(c.CONTROLLER,j);const $=["type","scope","path","alias","hooks","deps","imports","configuration","priority"],L=M($),_=M($,{type:c.INTERCEPTOR}),x=M([...$,"middlewares"],{type:c.CONTROLLER});class F extends Error{constructor(e,t){super(`Object isn't a valid token. Please check the token set on ${(0,u.nameOf)((0,u.classOf)(e))}.${t}.\n- Check that it is not a circular reference.\n- Check that the token (class or symbol) exists`),this.name="INVALID_TOKEN_ERROR"}}let V,U={};const G=[];function K({providers:e,rebuild:t}={}){return V&&!e||(V=new h,e&&(e.forEach((e=>{V.set(e.token,e.use)})),V.set(R,T())),t&&(U.rebuild=t)),V}function q(){return{...U}}function H(){V&&G.push(V),V=void 0,U={}}function z(){H(),G.map((e=>e.clear()))}function B(e,t){return T().resolve(e,{...t,...q(),locals:t?.locals||K()})}function Q(e,t){return T().getMany(e,{...t,locals:t?.locals||K()})}function J(s,o={}){return o="function"==typeof o?{transform:o}:o,(n,i,a)=>{switch((0,u.decoratorTypeOf)([n,i,a])){case u.DecoratorTypes.PARAM_CTOR:s&&function(e,{target:t,propertyKey:r,parameterIndex:s}){const o=E(t,r),n=o[s];o[s]=n===Array?[e]:e,u.Metadata.setParamTypes(t,r,o),P(t,o)}(s,{target:n,propertyKey:i,parameterIndex:a});break;case u.DecoratorTypes.PROP:!function(s,o,{token:n,transform:i=(e=>e),useOpts:a}){const c=Symbol();s[t]||Reflect.defineProperty(s,t,{value:new Set,enumerable:!1,configurable:!1}),s[t].add(o),(0,u.catchError)((()=>Reflect.deleteProperty(s,o))),Reflect.defineProperty(s,o,{get(){const t=function(e,t,r){const s=e||u.Metadata.getType(t,r);if(s===Object)throw new F(t,String(r));return s}(n,s,o),l=u.Metadata.getType(s,o),h={rebuild:!!this[e]?.rebuild,locals:this[e]?.locals,useOpts:a||u.Store.from(s,o).get(r)};return void 0===this[c]&&(this[c]=l===Array?Q(n,h):B(t,h)),[].concat(this[c]).forEach(((e,t)=>{(0,u.isPromise)(this[c])&&e.then((e=>{this[c][t]=e,l!==Array&&(this[c]=e)}))})),i(this[c],{self:this,target:s,propertyKey:o})}})}(n,i,{...o,token:s})}}}function W(e={}){return(...t)=>{switch((0,u.decoratorTypeOf)(t)){case u.DecoratorTypes.CLASS:N(t[0],e);break;default:case u.DecoratorTypes.PARAM_CTOR:return J(C)(t[0],t[1],t[2])}}}function Y(e,t){return T().settings.get(e,t)}function X(e,t,r,s){const o=Symbol();(0,u.catchError)((()=>Reflect.deleteProperty(e,t))),Reflect.defineProperty(e,t,{get(){if(void 0!==this[o])return this[o];const e=Y(r,s);return this[o]=Object.freeze((0,u.deepClone)(e)),this[o]},set(e){void 0===(Y(r,s)||this[o])&&void 0!==e&&(this[o]=e)},enumerable:!0,configurable:!0})}function Z(e,t){return(r,s)=>X(r,s,e,t)}L(W).factory((()=>T().settings));var ee,te=n(953);function re(e){const{children:t=[],path:r,...s}=function(e){return"string"==typeof e||e instanceof RegExp||(0,u.isArrayOrArrayClass)(e)?{path:e}:e}(e);return(0,u.useDecorators)((e=>{x(e,s)}),r&&(0,te.Path)(r),(0,te.Children)(...t))}function se(e={}){return t=>{const r={...e,...e.token?{useClass:t}:{token:t}};L(r.token,r)}}function oe(e,t){return u.Store.fromMethod(e,t).get(o)}function ne(t,r,s,n){const i=(0,u.classOf)(t),a=Reflect.getOwnPropertyDescriptor(i.prototype,r),c=a.value,l=Symbol();return u.Store.fromMethod(i,r).set(o,n),a.value=function(...o){const i=e=>{if(!e)return c.apply(this,o);throw e},a={target:t,propertyKey:r,args:o,options:n,next:i},u={rebuild:!!this[e]?.rebuild,locals:this[e]?.locals};return this[l]=this[l]||B(s,u),this[l].intercept({...a,options:n},i)},Reflect.deleteProperty(i.prototype,r),Reflect.defineProperty(i.prototype,r,a),a}function ie(e,t){return(...r)=>{const[s,o]=r;switch((0,u.decoratorTypeOf)(r)){case u.DecoratorTypes.CLASS:(0,u.decorateMethodsOf)(s,ie(e,t));break;case u.DecoratorTypes.METHOD:return ne(s,o,e,t)}}}function ae(){return se({type:c.INTERCEPTOR})}async function ce(e){const{default:t}=await e();if(!T().has(t)){const e=await B(t);"$onInit"in e&&(0,u.isFunction)(e.$onInit)&&await e.$onInit()}return T().get(t)}async function ue(e){try{return await ce(e)}catch(e){return}}function le(e,t=!1){function r(e,r){return async()=>{try{const{[e]:t}=await r();return{default:t}}catch(e){if(!t)throw e;return}}}return(0,u.isFunction)(e[0])?r("default",e[0]):r(e[0],e[1])}function he(...e){let t=le(e);return(e,r)=>{(0,u.catchError)((()=>Reflect.deleteProperty(e,r))),Reflect.defineProperty(e,r,{get:async()=>ce(t)})}}function de(...e){const t=le(e,!0);return(e,r)=>{(0,u.catchError)((()=>Reflect.deleteProperty(e,r))),Reflect.defineProperty(e,r,{get:async()=>ue(t)})}}function pe(e={}){const{scopes:t,imports:r,deps:s,scope:o,...n}=e;return(0,u.useDecorators)(W(n),se({type:c.MODULE,scope:a.SINGLETON,imports:r,deps:s,injectable:!1}))}function fe(e=a.REQUEST){return(0,u.StoreSet)("scope",e)}function ge(e,t,r){fe(a.INSTANCE)((0,u.classOf)(e)),J(s)(e,t,r)}function ye(e){return t=>{g.get(e).useClass=t}}function me(){return se()}function Oe(e){return(t,o,n)=>{switch((0,u.decoratorTypeOf)([t,o,n])){case u.DecoratorTypes.PARAM_CTOR:u.Store.from(t).merge(`${s}:${n}`,e);break;case u.DecoratorTypes.PROP:u.Store.from(t,o).set(r,e);break;default:throw new u.UnsupportedDecoratorType(Oe,[t,o,n])}}}function ve(e,t,r,s){const o={get:()=>T().settings.get(r,s),set(e){T().settings.set(r,e)},enumerable:!0,configurable:!0};(0,u.catchError)((()=>Reflect.deleteProperty(e,t))),(0,u.catchError)((()=>Reflect.defineProperty(e,t,o)))}function ke(e,t){return(r,s)=>ve(r,s,e,t)}function Ee(e,t){return Object.freeze({get value(){return T().settings.get(e,t)},set value(t){T().settings.set(e,t)}})}!function(e){e.METHOD="method",e.PROPERTY="property",e.CONSTANT="constant",e.VALUE="value",e.INTERCEPTOR="interceptor"}(ee||(ee={}));const Pe=Symbol.for("LOGGER");function be(e={},t={}){return Object.entries(t).reduce(((e,[t,r])=>({...e,[t]:(e[t]||[]).concat(r)})),e)}function Ce(e,t={}){const r=u.Store.from(e).get("configuration")||{};return{...r,...t,mount:be(r.mount,t.mount)}}L(Pe).factory((()=>T().logger))})(),i})())); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@tsed/core"),require("@tsed/hooks"),require("@tsed/schema")):"function"==typeof define&&define.amd?define(["@tsed/core","@tsed/hooks","@tsed/schema"],t):"object"==typeof exports?exports["@tsed/di"]=t(require("@tsed/core"),require("@tsed/hooks"),require("@tsed/schema")):e["@tsed/di"]=t(e["@tsed/core"],e["@tsed/hooks"],e["@tsed/schema"])}(self,((e,t,r)=>(()=>{"use strict";var s={803:t=>{t.exports=e},488:e=>{e.exports=t},953:e=>{e.exports=r}},o={};function n(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return s[e](r,r.exports,n),r.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{n.r(i),n.d(i,{AutoInjectable:()=>A,CONFIGURATION:()=>b,Configuration:()=>W,Constant:()=>Z,Container:()=>y,Controller:()=>re,ControllerProvider:()=>j,DIConfiguration:()=>C,DI_INJECTABLE_PROPS:()=>t,DI_INTERCEPTOR_OPTIONS:()=>o,DI_INVOKE_OPTIONS:()=>e,DI_USE_OPTIONS:()=>r,DI_USE_PARAM_OPTIONS:()=>s,GlobalProviderRegistry:()=>f,GlobalProviders:()=>g,Inject:()=>J,Injectable:()=>se,InjectablePropertyType:()=>ee,InjectionError:()=>v,InjectorService:()=>R,Intercept:()=>ie,Interceptor:()=>ae,InvalidPropertyTokenError:()=>F,LOGGER:()=>Pe,LazyInject:()=>he,LocalsContainer:()=>h,Module:()=>pe,OptionalLazyInject:()=>de,Opts:()=>ge,OverrideProvider:()=>ye,Provider:()=>p,ProviderScope:()=>a,ProviderType:()=>c,Scope:()=>fe,Service:()=>me,UseOpts:()=>Oe,Value:()=>ke,bindConstant:()=>X,bindIntercept:()=>ne,bindValue:()=>ve,cleanAllLocalsContainer:()=>z,colors:()=>O,configuration:()=>N,constant:()=>Y,controller:()=>x,createContainer:()=>k,destroyInjector:()=>w,detachLocalsContainer:()=>H,discoverHooks:()=>d,getConfiguration:()=>Ce,getConstructorDependencies:()=>E,getInterceptorOptions:()=>oe,inject:()=>B,injectMany:()=>Q,injectable:()=>L,injector:()=>T,interceptor:()=>_,invokeOptions:()=>q,lazyInject:()=>ce,localsContainer:()=>K,mergeMount:()=>be,optionalLazyInject:()=>ue,providerBuilder:()=>M,refValue:()=>Ee,registerProvider:()=>D,setConstructorDependencies:()=>P});const e=Symbol("DI_INVOKE_OPTIONS"),t=Symbol("DI_INJECTABLE_PROPS"),r="DI_USE_OPTIONS",s="DI_USE_PARAM_OPTIONS",o="DI_INTERCEPTOR_OPTIONS";var a,c,u=n(803),l=n(488);class h extends Map{constructor(){super(...arguments),this.hooks=new l.Hooks}async destroy(){await this.hooks.asyncEmit("$onDestroy")}}function d(e){return(0,u.methodsOf)(e).reduce(((e,{propertyKey:t})=>{if(String(t).startsWith("$")){const r=(e,...r)=>e?.[t](...r);return{...e,[t]:r}}return e}),{})}!function(e){e.SINGLETON="singleton",e.REQUEST="request",e.INSTANCE="instance"}(a||(a={})),function(e){e.VALUE="value",e.PROVIDER="provider",e.MODULE="module",e.CONTROLLER="controller",e.INTERCEPTOR="interceptor",e.MIDDLEWARE="middleware"}(c||(c={}));class p{#e;#t;#r;#s;constructor(e,t={}){this.type=c.PROVIDER,this.hooks={},this.token=e,this.useClass=e,Object.assign(this,t),t instanceof p&&(this.#e=t.#e,this.#r=t.#r,this.#s=t.#s)}get token(){return this.#t}set token(e){e&&(this.#t=(0,u.getClassOrSymbol)(e),this.#s=this.#r=u.Store.from(e))}get provide(){return this.token}set provide(e){this.token=e}get useClass(){return this.#e}set useClass(e){(0,u.isClass)(e)&&(this.#e=(0,u.classOf)(e),this.#r=u.Store.from(e),this.hooks=d(this.#e))}get className(){return this.name}get name(){return(0,u.nameOf)(this.token)}get store(){return this.#r}get path(){return this.store.get("path","/")}set path(e){this.store.set("path",e)}get scope(){return this.isAsync()?a.SINGLETON:this.get("scope",a.SINGLETON)}set scope(e){this.store.set("scope",e)}get configuration(){return this.get("configuration")}set configuration(e){this.store.set("configuration",e)}get children(){return this.store.get("childrenControllers",[])}set children(e){this.store.set("childrenControllers",e)}getArgOpts(e){return this.store.get(`${s}:${e}`)}get(e,t){return this.store.get(e)||this.#s.get(e)||t}isAsync(){return!!this.useAsyncFactory}clone(){return new((0,u.classOf)(this))(this.token,this)}hasChildren(){return!!this.children.length}hasParent(){return!!this.store.get("parentController")}toString(){return["Token",this.name,this.useClass&&(0,u.nameOf)(this.useClass),this.useFactory&&"Factory",this.useValue&&"Value",this.useAsyncFactory&&"AsyncFactory"].filter(Boolean).join(":")}}class f extends Map{#o=new Map;get(e){return super.get((0,u.getClassOrSymbol)(e))}has(e){return super.has((0,u.getClassOrSymbol)(e))}set(e,t){return super.set((0,u.getClassOrSymbol)(e),t),this}merge(e,t){if(!1===t.global)return g.createProvider(e,t);const r=this.createIfNotExists(e,t);return Object.keys(t).forEach((e=>{r[e]=t[e]})),this.set(e,r),r}delete(e){return super.delete((0,u.getClassOrSymbol)(e))}createRegistry(e,t,r={}){const s=this.getRegistrySettings(e);return r=Object.assign(s,{...r,model:t}),this.#o.set(e,r),this}getRegistrySettings(e){let t=c.PROVIDER;if("string"==typeof e)t=e;else{const r=this.get(e);r&&(t=r.type)}return this.#o.get(t)||{model:p}}createProvider(e,t){const r=t.type||c.PROVIDER,{model:s=p}=this.#o.get(r)||{};return new s(e,t)}createIfNotExists(e,t){if(!this.has(e)){const r=this.createProvider(e,t);this.set(e,r)}return this.get(e)}}const g=new f;class y extends Map{add(e,t={}){const r=g.get(e)?.clone()||new p(e);return Object.assign(r,t),super.set(e,r)}addProvider(e,t={}){return this.add(e,t)}hasProvider(e){return super.has(e)}setProvider(e,t){return super.set(e,t)}getProvider(e){return super.get(e)}getProviders(e){const t=[].concat(e).map(String);return[...this].reduce(((r,[s,o])=>t.includes(String(o.type))||!e?[...r,o]:r),[])}addProviders(e){e.forEach((e=>{this.hasProvider(e.token)||this.setProvider(e.token,e.clone())}))}}const m=e=>e=>(process.env.NO_COLOR,e),O={red:m(),yellow:m(),green:m()};class v extends Error{constructor(e,t){super((0,u.isString)(t)?t:""),this.name="INJECTION_ERROR",this.tokens=[],this.tokens=[e],t&&((0,u.isString)(t)?this.origin={message:t,stack:this.stack}:t.tokens?(this.tokens=this.tokens.concat(t.tokens),this.origin=t.origin):(this.origin=t,this.stack=t.stack));const r=this.origin?"\nOrigin: "+this.origin.message:"",s=this.tokens.map((e=>(0,u.nameOf)(e))).join(" > ");this.message=`Injection failed on ${s}${r}`}static throwInjectorError(e,t,r){throw t&&(0,u.isClass)(e)&&(r.message=function(e,t){let r="";const s=(0,u.getConstructorArgNames)(e).map(((e,s)=>(t.index===s&&(r=e,e=O.red(e)),`${e}: ${(0,u.nameOf)(t.deps[s])}`))).join(", "),o=(0,u.nameOf)(e)+"->constructor("+s+")",n=o.indexOf(r)-5;return"Unable to inject dependency. "+t.message+"\n\n"+o+"\n"+(n>-1?(e=>" ".repeat(e)+O.red("^"+"‾".repeat(r.length-1)))(n):"")}(e,{...t,message:r.message})),new v(e,r)}}function k(e){const t=new y(g.entries());return e&&t.delete(e),t}function E(e,t){return u.Metadata.getOwn("override:ctor:design:paramtypes",e,t)||[...u.Metadata.getParamTypes(e,t)]||[]}function P(e,t){u.Metadata.set("override:ctor:design:paramtypes",t,e)}const b=Symbol.for("CONFIGURATION");class C{constructor(e={}){this.default=new Map,this.map=new Map,Object.entries({imports:[],routes:[],logger:{},...e}).forEach((([e,t])=>{this.default.set(e,t)}))}get version(){return this.get("version")}set version(e){this.map.set("version",e)}get rootDir(){return this.get("rootDir")}set rootDir(e){this.map.set("rootDir",e)}get env(){return this.map.get("env")}set env(e){this.map.set("env",e)}get imports(){return this.get("imports")}set imports(e){this.map.set("imports",e)}get routes(){return this.get("routes")}set routes(e){this.map.set("routes",e)}get logger(){return this.get("logger")}set logger(e){const t={...this.logger,...e};this.map.set("logger",t)}get debug(){return"debug"===this.logger.level}set debug(e){this.logger={...this.logger,level:e?"debug":"info"}}forEach(e,t){return new Set([...Array.from(this.default.keys()),...Array.from(this.map.keys())]).forEach((t=>{e(this.getRaw(t),t,this.map)}),t)}set(e,t){return"string"==typeof e?Reflect.has(this,e)?this[e]=t:this.setRaw(e,t):Object.entries(e).forEach((([e,t])=>{this.set(e,t)})),this}setRaw(e,t){return(0,u.setValue)(this.map,e,t),this}get(e,t){return this.getRaw(e,t)}getRaw(e,t){const r=(0,u.getValue)(this.map,e);return void 0!==r?r:(0,u.getValue)(this.default,e,t)}}const I=["mount","imports"];class R extends y{#n;#i;constructor(){super(),this.logger=console,this.resolvedConfiguration=!1,this.#n=new h,this.#i=!1,this.#n.set(R,this),this.#n.set(C,new C)}get settings(){return this.#n.get(C)}set settings(e){this.#n.set(C,e)}isLoaded(){return this.#i}toArray(){return[...this.#n.values()]}get(e,t){return this.has(e)?this.#n.get(e):this.resolve(e,t)}getMany(e,t){return this.getProviders(e).map((e=>this.resolve(e.token,t)))}has(e){return void 0!==this.#n.get(e)}alias(e,t){return this.#n.set(t,this.#n.get(e)),this}resolve(e,t={}){let r=t.locals?t.locals.get(e):void 0;if(void 0!==r)return r;if(e===s)return t.useOpts;if(r=t.rebuild?void 0:this.#n.get(e),null!=r)return r;const o=this.ensureProvider(e);if(!o||t.rebuild)return r=this.invokeToken(e,t),o?this.setToCache(o,r):r;switch(r=this.invokeToken(e,t),o.scope){case a.SINGLETON:return t.rebuild||this.registerHooks(o,t),this.setToCache(o,r);case a.REQUEST:return t.locals&&(t.locals.set(o.token,r),this.registerHooks(o,t)),r}return r}invoke(e,t={}){return this.resolve(e,t)}async loadAsync(){for(const[,e]of this)!this.has(e.token)&&e.isAsync()&&await this.resolve(e.token)}loadSync(){for(const[,e]of this)this.has(e.token)||e.scope!==a.SINGLETON||this.resolve(e.token)}async load(e=k()){this.#i=!0,await(0,l.$asyncEmit)("$beforeInit"),this.bootstrap(e),await this.loadAsync(),this.loadSync(),await(0,l.$asyncEmit)("$onInit")}resolveConfiguration(){if(this.resolvedConfiguration)return;const e=new Map;super.forEach((t=>{t.configuration&&"server:module"!==t.type&&Object.entries(t.configuration).forEach((([t,r])=>{I.includes(t)||(r=e.has(t)?(0,u.deepMerge)(e.get(t),r):(0,u.deepClone)(r),e.set(t,r))}))})),e.forEach(((e,t)=>{this.settings.set(t,(0,u.deepMerge)(e,this.settings.get(t)))})),this.resolvedConfiguration=!0}emit(e,...t){return(0,l.$asyncEmit)(e,t)}alter(e,t,...r){return(0,l.$alter)(e,t,r)}alterAsync(e,t,...r){return(0,l.$asyncAlter)(e,t,r)}async destroy(){await(0,l.$asyncEmit)("$onDestroy"),this.#n.forEach(((e,t)=>{(0,l.$off)(t)}))}bootstrap(e=k()){return this.addProviders(e),this.resolveConfiguration(),this.resolveImportsProviders(),this}ensureProvider(e,t=!1){return this.hasProvider(e)||!g.has(e)&&!t||this.addProvider(e),this.getProvider(e)}invokeToken(t,r={}){const s=this.mapInvokeOptions(t,r);if(!s)return;const{token:o,deps:n,construct:i,imports:a,provider:c}=s;let h;(0,l.$emit)("$beforeInvoke",o,[s]),(0,l.$emit)(`$beforeInvoke:${String(c.type)}`,[s]);let d=!1;try{const e=e=>(t,s)=>(d={token:t,index:s,deps:n},(0,u.isArray)(t)?this.getMany(t[0],r):(0,u.isInheritedFrom)(t,p,1)?c:this.resolve(t,{parent:e,locals:r.locals,useOpts:c?.getArgOpts(s)||r.useOpts}));a.forEach(e());const t=n.map(e(o));d=!1,h=i(t)}catch(e){v.throwInjectorError(o,d,e)}if(void 0===h)throw new v(o,`Unable to create new instance from undefined value. Check your provider declaration for ${(0,u.nameOf)(o)}`);return h&&(0,u.isClass)((0,u.classOf)(h))&&Reflect.defineProperty(h,e,{get:()=>({rebuild:r.rebuild,locals:r.locals})}),(0,l.$emit)("$afterInvoke",o,[h,s]),h}resolveImportsProviders(){this.settings.imports=this.settings.imports?.filter((e=>(0,u.isObject)(e)&&"token"in e&&e.token!==R)).map((e=>{if((0,u.isObject)(e)&&"token"in e){const{token:t,...r}=e,s=this.ensureProvider(t,!0);if(s){if(s.useValue=void 0,s.useAsyncFactory=void 0,s.useFactory=void 0,"useClass"in r)return void(s.useClass=r.useClass);if("useFactory"in r)return void(s.useFactory=r.useFactory);if("useAsyncFactory"in r)return void(s.useAsyncFactory=r.useAsyncFactory);if("use"in r)return void(s.useValue=r.use)}}return e})).filter(Boolean)}mapInvokeOptions(e,t){const r=t.locals||new h;t.locals=r;let s,o,n=t.imports,i=t.deps;if(!e||e===Object)throw new Error("Given token is undefined. Could mean a circular dependency problem. Try to use @Inject(() => Token) to solve it.");if(o=this.hasProvider(e)?this.getProvider(e):new p(e),i=i||o.deps,n=n||o.imports,void 0!==o.useValue)s=()=>(0,u.isFunction)(o.useValue)?o.useValue():o.useValue;else if(o.useFactory)s=e=>o.useFactory(...e);else if(o.useAsyncFactory)s=async e=>(e=await Promise.all(e),o.useAsyncFactory(...e));else{if(!o.useClass)return!1;i=i||E(o.useClass),s=e=>new o.useClass(...e)}return{token:e,deps:i||[],imports:n||[],construct:s,provider:o,locals:r}}registerHooks(e,t){if(e.hooks){if(e.scope===a.REQUEST){if(t.locals&&e.hooks?.$onDestroy){const{locals:r}=t;t.locals.hooks.on("$onDestroy",((...t)=>e.hooks?.$onDestroy?.(r.get(e.token),...t)))}return}Object.entries(e.hooks).forEach((([t,r])=>{(0,l.$on)(t,e.token,((...t)=>r(this.#n.get(e.token),...t)))}))}}setToCache(e,t){const r=t=>{this.#n.set(e.token,t),e?.alias&&this.alias(e.token,e.alias)};return!("isAsync"in e)||e.isAsync()||(0,u.isPromise)(t)?(r(t),t=t.then((e=>(r(e),e)))):(r(t),t)}}let S=new R;function T(){return S}async function w(){await S.destroy(),S=new R}function A(){return e=>class extends e{constructor(...t){super(...function(e,t){const r=T(),s=new h,o=E(e),n=[],i=Math.max(o.length,t.length);for(let a=0;a<i;a++)if(void 0!==t[a])n.push(t[a]);else{const t=o[a],i=(0,u.isArray)(t)?r.getMany(t[0],{locals:s,parent:e}):r.invoke(t,{locals:s,parent:e});n.push(i)}return n}(e,t))}}}function N(e,t){if(e){const r=u.Store.from(e);return t&&r.set("configuration",t),r.get("configuration",t)}return T().settings}class j extends p{constructor(e,t={}){super(e,t),this.type=c.CONTROLLER}get middlewares(){return Object.assign({use:[],useAfter:[],useBefore:[]},this.store.get("middlewares",{}))}set middlewares(e){const t=this.middlewares;Object.keys(e).forEach((r=>{((e,t,r)=>{t[e]=t[e].concat(r[e])})(r,t,e)})),this.store.set("middlewares",t)}}function D({token:e,provide:t,...r}){return L(e||t,{...r,token:e||t}).inspect()}function M(e,t={}){return(r,s={})=>{const o={global:!T().isLoaded(),...s,...t,token:r},n=g.merge(r,o);return o.global||T().setProvider(r,n),e.reduce(((e,t)=>({...e,[t]:function(e){return n[t]=e,this}})),{factory(e){return n.useFactory=e,this},asyncFactory(e){return n.useAsyncFactory=e,this},value(e){return n.useValue=e,n.type=c.VALUE,this},class(e){return n.useClass=e,this},store:()=>n.store,inspect:()=>n,token:()=>n.token})}}g.createRegistry(c.CONTROLLER,j);const $=["type","scope","path","alias","hooks","deps","imports","configuration","priority"],L=M($),_=M($,{type:c.INTERCEPTOR}),x=M([...$,"middlewares"],{type:c.CONTROLLER});class F extends Error{constructor(e,t){super(`Object isn't a valid token. Please check the token set on ${(0,u.nameOf)((0,u.classOf)(e))}.${t}.\n- Check that it is not a circular reference.\n- Check that the token (class or symbol) exists`),this.name="INVALID_TOKEN_ERROR"}}let V,U={};const G=[];function K({providers:e,rebuild:t}={}){return V&&!e||(V=new h,e&&(e.forEach((e=>{V.set(e.token,e.use)})),V.set(R,T())),t&&(U.rebuild=t)),V}function q(){return{...U}}function H(){V&&G.push(V),V=void 0,U={}}function z(){H(),G.map((e=>e.clear()))}function B(e,t){return T().resolve(e,{...t,...q(),locals:t?.locals||K()})}function Q(e,t){return T().getMany(e,{...t,locals:t?.locals||K()})}function J(s,o={}){return o="function"==typeof o?{transform:o}:o,(n,i,a)=>{switch((0,u.decoratorTypeOf)([n,i,a])){case u.DecoratorTypes.PARAM_CTOR:s&&function(e,{target:t,propertyKey:r,parameterIndex:s}){const o=E(t,r),n=o[s];o[s]=n===Array?[e]:e,u.Metadata.setParamTypes(t,r,o),P(t,o)}(s,{target:n,propertyKey:i,parameterIndex:a});break;case u.DecoratorTypes.PROP:!function(s,o,{token:n,transform:i=(e=>e),useOpts:a}){const c=Symbol();s[t]||Reflect.defineProperty(s,t,{value:new Set,enumerable:!1,configurable:!1}),s[t].add(o),(0,u.catchError)((()=>Reflect.deleteProperty(s,o))),Reflect.defineProperty(s,o,{get(){const t=function(e,t,r){const s=e||u.Metadata.getType(t,r);if(s===Object)throw new F(t,String(r));return s}(n,s,o),l=u.Metadata.getType(s,o),h={rebuild:!!this[e]?.rebuild,locals:this[e]?.locals,useOpts:a||u.Store.from(s,o).get(r)};return void 0===this[c]&&(this[c]=l===Array?Q(n,h):B(t,h)),[].concat(this[c]).forEach(((e,t)=>{(0,u.isPromise)(this[c])&&e.then((e=>{this[c][t]=e,l!==Array&&(this[c]=e)}))})),i(this[c],{self:this,target:s,propertyKey:o})}})}(n,i,{...o,token:s})}}}function W(e={}){return(...t)=>{switch((0,u.decoratorTypeOf)(t)){case u.DecoratorTypes.CLASS:N(t[0],e);break;default:case u.DecoratorTypes.PARAM_CTOR:return J(C)(t[0],t[1],t[2])}}}function Y(e,t){return T().settings.get(e,t)}function X(e,t,r,s){const o=Symbol();(0,u.catchError)((()=>Reflect.deleteProperty(e,t))),Reflect.defineProperty(e,t,{get(){if(void 0!==this[o])return this[o];const e=Y(r,s);return this[o]=Object.freeze((0,u.deepClone)(e)),this[o]},set(e){void 0===(Y(r,s)||this[o])&&void 0!==e&&(this[o]=e)},enumerable:!0,configurable:!0})}function Z(e,t){return(r,s)=>X(r,s,e,t)}L(W).factory((()=>T().settings));var ee,te=n(953);function re(e){const{children:t=[],path:r,...s}=function(e){return"string"==typeof e||e instanceof RegExp||(0,u.isArrayOrArrayClass)(e)?{path:e}:e}(e);return(0,u.useDecorators)((e=>{x(e,s)}),r&&(0,te.Path)(r),(0,te.Children)(...t))}function se(e={}){return t=>{const r={...e,...e.token?{useClass:t}:{token:t}};L(r.token,r)}}function oe(e,t){return u.Store.fromMethod(e,t).get(o)}function ne(t,r,s,n){const i=(0,u.classOf)(t),a=Reflect.getOwnPropertyDescriptor(i.prototype,r),c=a.value,l=Symbol();return u.Store.fromMethod(i,r).set(o,n),a.value=function(...t){const o=e=>{if(!e)return c.apply(this,t);throw e},a={target:i,propertyKey:r,args:t,options:n,next:o},u={rebuild:!!this[e]?.rebuild,locals:this[e]?.locals};return this[l]=this[l]||B(s,u),this[l].intercept({...a,options:n},o)},Reflect.deleteProperty(i.prototype,r),Reflect.defineProperty(i.prototype,r,a),a}function ie(e,t){return(...r)=>{const[s,o]=r;switch((0,u.decoratorTypeOf)(r)){case u.DecoratorTypes.CLASS:(0,u.decorateMethodsOf)(s,ie(e,t));break;case u.DecoratorTypes.METHOD:return ne(s,o,e,t)}}}function ae(){return se({type:c.INTERCEPTOR})}async function ce(e){const{default:t}=await e();if(!T().has(t)){const e=await B(t);"$onInit"in e&&(0,u.isFunction)(e.$onInit)&&await e.$onInit()}return T().get(t)}async function ue(e){try{return await ce(e)}catch(e){return}}function le(e,t=!1){function r(e,r){return async()=>{try{const{[e]:t}=await r();return{default:t}}catch(e){if(!t)throw e;return}}}return(0,u.isFunction)(e[0])?r("default",e[0]):r(e[0],e[1])}function he(...e){let t=le(e);return(e,r)=>{(0,u.catchError)((()=>Reflect.deleteProperty(e,r))),Reflect.defineProperty(e,r,{get:async()=>ce(t)})}}function de(...e){const t=le(e,!0);return(e,r)=>{(0,u.catchError)((()=>Reflect.deleteProperty(e,r))),Reflect.defineProperty(e,r,{get:async()=>ue(t)})}}function pe(e={}){const{scopes:t,imports:r,deps:s,scope:o,...n}=e;return(0,u.useDecorators)(W(n),se({type:c.MODULE,scope:a.SINGLETON,imports:r,deps:s,injectable:!1}))}function fe(e=a.REQUEST){return(0,u.StoreSet)("scope",e)}function ge(e,t,r){fe(a.INSTANCE)((0,u.classOf)(e)),J(s)(e,t,r)}function ye(e){return t=>{g.get(e).useClass=t}}function me(){return se()}function Oe(e){return(t,o,n)=>{switch((0,u.decoratorTypeOf)([t,o,n])){case u.DecoratorTypes.PARAM_CTOR:u.Store.from(t).merge(`${s}:${n}`,e);break;case u.DecoratorTypes.PROP:u.Store.from(t,o).set(r,e);break;default:throw new u.UnsupportedDecoratorType(Oe,[t,o,n])}}}function ve(e,t,r,s){const o={get:()=>T().settings.get(r,s),set(e){T().settings.set(r,e)},enumerable:!0,configurable:!0};(0,u.catchError)((()=>Reflect.deleteProperty(e,t))),(0,u.catchError)((()=>Reflect.defineProperty(e,t,o)))}function ke(e,t){return(r,s)=>ve(r,s,e,t)}function Ee(e,t){return Object.freeze({get value(){return T().settings.get(e,t)},set value(t){T().settings.set(e,t)}})}!function(e){e.METHOD="method",e.PROPERTY="property",e.CONSTANT="constant",e.VALUE="value",e.INTERCEPTOR="interceptor"}(ee||(ee={}));const Pe=Symbol.for("LOGGER");function be(e={},t={}){return Object.entries(t).reduce(((e,[t,r])=>({...e,[t]:(e[t]||[]).concat(r)})),e)}function Ce(e,t={}){const r=u.Store.from(e).get("configuration")||{};return{...r,...t,mount:be(r.mount,t.mount)}}L(Pe).factory((()=>T().logger))})(),i})())); | ||
//# sourceMappingURL=di.umd.min.js.map |
@@ -21,3 +21,3 @@ import { classOf, decorateMethodsOf, decoratorTypeOf, DecoratorTypes, Store } from "@tsed/core"; | ||
const context = { | ||
target, | ||
target: klass, | ||
propertyKey, | ||
@@ -24,0 +24,0 @@ args, |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "8.3.3", | ||
"version": "8.3.4", | ||
"source": "./src/index.ts", | ||
@@ -34,8 +34,8 @@ "main": "./lib/esm/index.js", | ||
"devDependencies": { | ||
"@tsed/barrels": "8.3.3", | ||
"@tsed/core": "8.3.3", | ||
"@tsed/hooks": "8.3.3", | ||
"@tsed/barrels": "8.3.4", | ||
"@tsed/core": "8.3.4", | ||
"@tsed/hooks": "8.3.4", | ||
"@tsed/logger": "^7.0.1", | ||
"@tsed/schema": "8.3.3", | ||
"@tsed/typescript": "8.3.3", | ||
"@tsed/schema": "8.3.4", | ||
"@tsed/typescript": "8.3.4", | ||
"cross-env": "7.0.3", | ||
@@ -48,6 +48,6 @@ "eslint": "9.12.0", | ||
"peerDependencies": { | ||
"@tsed/core": "8.3.3", | ||
"@tsed/hooks": "8.3.3", | ||
"@tsed/core": "8.3.4", | ||
"@tsed/hooks": "8.3.4", | ||
"@tsed/logger": ">=7.0.1", | ||
"@tsed/schema": "8.3.3" | ||
"@tsed/schema": "8.3.4" | ||
}, | ||
@@ -54,0 +54,0 @@ "peerDependenciesMeta": { |
@@ -1,2 +0,2 @@ | ||
import {catchError} from "@tsed/core"; | ||
import {catchError, classOf, nameOf} from "@tsed/core"; | ||
@@ -16,2 +16,4 @@ import {DITest} from "../../node/index.js"; | ||
expect(nameOf(context.target)).toContain("Service"); | ||
return `${retValue} - ${context.options || ""} - intercepted 1`; | ||
@@ -18,0 +20,0 @@ } |
@@ -32,3 +32,3 @@ import {classOf, decorateMethodsOf, DecoratorParameters, decoratorTypeOf, DecoratorTypes, nameOf, Store, Type} from "@tsed/core"; | ||
const context: InterceptorContext<any> = { | ||
target, | ||
target: klass, | ||
propertyKey, | ||
@@ -35,0 +35,0 @@ args, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
579277
10905