Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tsed/di

Package Overview
Dependencies
Maintainers
0
Versions
1030
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tsed/di - npm Package Compare versions

Comparing version 8.0.0-rc.6 to 8.0.0

2

lib/browser/di.umd.min.js

@@ -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:()=>I,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:()=>O,InjectorService:()=>R,Intercept:()=>ie,Interceptor:()=>ae,InvalidPropertyTokenError:()=>F,LOGGER:()=>ke,LazyInject:()=>he,LocalsContainer:()=>h,Module:()=>pe,OptionalLazyInject:()=>de,Opts:()=>ge,OverrideProvider:()=>ye,Provider:()=>p,ProviderScope:()=>a,ProviderType:()=>c,Scope:()=>fe,Service:()=>me,UseOpts:()=>ve,Value:()=>Ee,bindConstant:()=>X,bindIntercept:()=>ne,bindValue:()=>Oe,cleanAllLocalsContainer:()=>z,colors:()=>v,configuration:()=>N,constant:()=>Y,controller:()=>x,createContainer:()=>E,destroyInjector:()=>w,detachLocalsContainer:()=>H,discoverHooks:()=>d,getConfiguration:()=>Ie,getConstructorDependencies:()=>P,getInterceptorOptions:()=>oe,inject:()=>B,injectMany:()=>Q,injectable:()=>$,injector:()=>S,interceptor:()=>L,invokeOptions:()=>q,lazyInject:()=>ce,localsContainer:()=>K,mergeMount:()=>be,optionalLazyInject:()=>ue,providerBuilder:()=>_,refValue:()=>Pe,registerProvider:()=>D,setConstructorDependencies:()=>k});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{constructor(e,t={}){this.type=c.PROVIDER,this.hooks={},this.provide=e,this.useClass=e,Object.assign(this,{...t})}get token(){return this._provide}get provide(){return this._provide}set provide(e){e&&(this._provide=(0,u.getClassOrSymbol)(e),this._tokenStore=this._store=u.Store.from(e))}get useClass(){return this._useClass}set useClass(e){(0,u.isClass)(e)&&(this._useClass=(0,u.classOf)(e),this._store=u.Store.from(e),this.hooks=d(this._useClass))}get className(){return this.name}get name(){return(0,u.nameOf)(this.provide)}get store(){return this._store}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._tokenStore.get(e)||t}isAsync(){return!!this.useAsyncFactory}clone(){return new((0,u.classOf)(this))(this._provide,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{#e=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.#e.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.#e.get(t)||{model:p}}createProvider(e,t){const r=t.type||c.PROVIDER,{model:s=p}=this.#e.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.provide)||this.setProvider(e.provide,e.clone())}))}}const m=e=>e=>(process.env.NO_COLOR,e),v={red:m(),yellow:m(),green:m()};class O 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=v.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)+v.red("^"+"‾".repeat(r.length-1)))(n):"")}(e,{...t,message:r.message})),new O(e,r)}}function E(e){const t=new y(g.entries());return e&&t.delete(e),t}function P(e,t){return u.Metadata.getOwn("override:ctor:design:paramtypes",e,t)||[...u.Metadata.getParamTypes(e,t)]||[]}function k(e,t){u.Metadata.set("override:ctor:design:paramtypes",t,e)}const b=Symbol.for("CONFIGURATION");class I{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 C=["mount","imports"];class R extends y{#t;#r;constructor(){super(),this.logger=console,this.resolvedConfiguration=!1,this.#t=new h,this.#r=!1,this.#t.set(R,this),this.#t.set(I,new I)}get settings(){return this.#t.get(I)}set settings(e){this.#t.set(I,e)}isLoaded(){return this.#r}toArray(){return[...this.#t.values()]}get(e,t){return this.has(e)?this.#t.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.#t.get(e)}alias(e,t){return this.#t.set(t,this.#t.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.#t.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=E()){this.#r=!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])=>{C.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.#t.forEach(((e,t)=>{(0,l.$off)(t)}))}bootstrap(e=E()){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){O.throwInjectorError(o,d,e)}if(void 0===h)throw new O(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||P(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.#t.get(e.token),...t)))}))}}setToCache(e,t){const r=t=>{this.#t.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 T=new R;function S(){return T}async function w(){await T.destroy(),T=new R}function A(){return e=>class extends e{constructor(...t){super(...function(e,t){const r=S(),s=new h,o=P(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 S().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(e){return $(e.provide,e).inspect()}function _(e,t={}){return(r,s={})=>{const o={global:!S().isLoaded(),...s,...t,provide:r},n=g.merge(r,o);return o.global||S().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 M=["type","scope","path","alias","hooks","deps","imports","configuration","priority"],$=_(M),L=_(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,S())),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 S().resolve(e,{...t,...q(),locals:t?.locals||K()})}function Q(e,t){return S().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=P(t,r),n=o[s];o[s]=n===Array?[e]:e,u.Metadata.setParamTypes(t,r,o),k(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(I)(t[0],t[1],t[2])}}}function Y(e,t){return S().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)}$(W).factory((()=>S().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.provide?{useClass:t}:{provide:t}};$(r.provide,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)},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(!S().has(t)){const e=await B(t);"$onInit"in e&&(0,u.isFunction)(e.$onInit)&&await e.$onInit()}return S().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 ve(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(ve,[t,o,n])}}}function Oe(e,t,r,s){const o={get:()=>S().settings.get(r,s),set(e){S().settings.set(r,e)},enumerable:!0,configurable:!0};(0,u.catchError)((()=>Reflect.deleteProperty(e,t))),(0,u.catchError)((()=>Reflect.defineProperty(e,t,o)))}function Ee(e,t){return(r,s)=>Oe(r,s,e,t)}function Pe(e,t){return Object.freeze({get value(){return S().settings.get(e,t)},set value(t){S().settings.set(e,t)}})}!function(e){e.METHOD="method",e.PROPERTY="property",e.CONSTANT="constant",e.VALUE="value",e.INTERCEPTOR="interceptor"}(ee||(ee={}));const ke=Symbol.for("LOGGER");function be(e={},t={}){return Object.entries(t).reduce(((e,[t,r])=>({...e,[t]:(e[t]||[]).concat(r)})),e)}function Ie(e,t={}){const r=u.Store.from(e).get("configuration")||{};return{...r,...t,mount:be(r.mount,t.mount)}}D({provide:ke,deps:[R],useFactory:e=>e.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(...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)},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

@@ -22,3 +22,3 @@ import { isArrayOrArrayClass, useDecorators } from "@tsed/core";

* @Controller("/calendars")
* export provide CalendarCtrl {
* export class CalendarCtrl {
*

@@ -25,0 +25,0 @@ * @Get("/:id")

@@ -14,3 +14,3 @@ import { injectable } from "../fn/injectable.js";

* - scope (@@ProviderScope@@): Kind of provider. (Default: `ProviderScope.SINGLETON`)
* - provide (@@TokenProvider@@): An injection token (Note: This option override default metadata generated by Typescript).
* - token (@@TokenProvider@@): An injection token (Note: This option override default metadata generated by Typescript).
* - deps (`Type<any>`): List of class or provider which will be injected to the constructor (Note: This options override default metadata generated by Typescript).

@@ -25,7 +25,7 @@ *

...options,
...(options.provide ? { useClass: target } : { provide: target })
...(options.token ? { useClass: target } : { token: target })
};
injectable(opts.provide, opts);
injectable(opts.token, opts);
};
}
//# sourceMappingURL=injectable.js.map

@@ -62,4 +62,4 @@ import { GlobalProviders } from "../registries/GlobalProviders.js";

container.forEach((provider) => {
if (!this.hasProvider(provider.provide)) {
this.setProvider(provider.provide, provider.clone());
if (!this.hasProvider(provider.token)) {
this.setProvider(provider.token, provider.clone());
}

@@ -66,0 +66,0 @@ });

import { Provider } from "./Provider.js";
import { ProviderType } from "./ProviderType.js";
export class ControllerProvider extends Provider {
constructor(provide, options = {}) {
super(provide, options);
constructor(token, options = {}) {
super(token, options);
this.type = ProviderType.CONTROLLER;

@@ -7,0 +7,0 @@ }

@@ -7,2 +7,6 @@ import { classOf, getClassOrSymbol, isClass, nameOf, Store } from "@tsed/core";

export class Provider {
#useClass;
#token;
#store;
#tokenStore;
constructor(token, options = {}) {

@@ -14,22 +18,35 @@ /**

this.hooks = {};
this.provide = token;
this.token = token;
this.useClass = token;
Object.assign(this, {
...options
});
Object.assign(this, options);
if (options instanceof Provider) {
this.#useClass = options.#useClass;
this.#store = options.#store;
this.#tokenStore = options.#tokenStore;
}
}
get token() {
return this._provide;
return this.#token;
}
set token(value) {
if (value) {
this.#token = getClassOrSymbol(value);
this.#tokenStore = this.#store = Store.from(value);
}
}
/**
* @deprecated
*/
get provide() {
return this._provide;
return this.token;
}
/**
* @deprecated
* @param value
*/
set provide(value) {
if (value) {
this._provide = getClassOrSymbol(value);
this._tokenStore = this._store = Store.from(value);
}
this.token = value;
}
get useClass() {
return this._useClass;
return this.#useClass;
}

@@ -42,5 +59,5 @@ /**

if (isClass(value)) {
this._useClass = classOf(value);
this._store = Store.from(value);
this.hooks = discoverHooks(this._useClass);
this.#useClass = classOf(value);
this.#store = Store.from(value);
this.hooks = discoverHooks(this.#useClass);
}

@@ -52,6 +69,6 @@ }

get name() {
return nameOf(this.provide);
return nameOf(this.token);
}
get store() {
return this._store;
return this.#store;
}

@@ -102,3 +119,3 @@ get path() {

get(key, defaultValue) {
return this.store.get(key) || this._tokenStore.get(key) || defaultValue;
return this.store.get(key) || this.#tokenStore.get(key) || defaultValue;
}

@@ -109,3 +126,3 @@ isAsync() {

clone() {
return new (classOf(this))(this._provide, this);
return new (classOf(this))(this.token, this);
}

@@ -112,0 +129,0 @@ /**

@@ -8,7 +8,10 @@ import { ControllerProvider } from "../domain/ControllerProvider.js";

* Register a provider configuration.
* @param {ProviderOpts<any>} opts
* @deprecated Since v8. Use injectable() function instead.
*/
export function registerProvider(opts) {
return injectable(opts.provide, opts).inspect();
export function registerProvider({ token, provide, ...opts }) {
return injectable(token || provide, {
...opts,
token: token || provide
}).inspect();
}
//# sourceMappingURL=ProviderRegistry.js.map

@@ -1,11 +0,5 @@

import { registerProvider } from "../registries/ProviderRegistry.js";
import { InjectorService } from "./InjectorService.js";
import { injectable } from "../fn/injectable.js";
import { injector } from "../fn/injector.js";
export const LOGGER = Symbol.for("LOGGER");
registerProvider({
provide: LOGGER,
deps: [InjectorService],
useFactory(injector) {
return injector.logger;
}
});
injectable(LOGGER).factory(() => injector().logger);
//# sourceMappingURL=DILogger.js.map

@@ -11,3 +11,3 @@ import "../registries/ProviderRegistry.js";

...baseOpts,
provide: token
token
};

@@ -14,0 +14,0 @@ const provider = GlobalProviders.merge(token, merged);

@@ -20,3 +20,3 @@ import { Type } from "@tsed/core";

* @Controller("/calendars")
* export provide CalendarCtrl {
* export class CalendarCtrl {
*

@@ -23,0 +23,0 @@ * @Get("/:id")

@@ -14,3 +14,3 @@ import type { ProviderOpts } from "../interfaces/ProviderOpts.js";

* - scope (@@ProviderScope@@): Kind of provider. (Default: `ProviderScope.SINGLETON`)
* - provide (@@TokenProvider@@): An injection token (Note: This option override default metadata generated by Typescript).
* - token (@@TokenProvider@@): An injection token (Note: This option override default metadata generated by Typescript).
* - deps (`Type<any>`): List of class or provider which will be injected to the constructor (Note: This options override default metadata generated by Typescript).

@@ -17,0 +17,0 @@ *

@@ -10,3 +10,3 @@ import { TokenProvider } from "../interfaces/TokenProvider.js";

tokenRouter: string;
constructor(provide: TokenProvider, options?: Partial<Provider>);
constructor(token: TokenProvider, options?: Partial<Provider>);
/**

@@ -13,0 +13,0 @@ *

@@ -8,2 +8,3 @@ import { type AbstractType, Store, Type } from "@tsed/core";

export declare class Provider<T = any> implements ProviderOpts<T> {
#private;
/**

@@ -21,10 +22,14 @@ * Token group provider to retrieve all provider from the same type

hooks: Record<string, ProviderHookCallback<T>>;
private _useClass;
private _provide;
private _store;
private _tokenStore;
[key: string]: any;
constructor(token: TokenProvider<T>, options?: Partial<Provider>);
get token(): TokenProvider;
set token(value: TokenProvider);
/**
* @deprecated
*/
get provide(): TokenProvider;
/**
* @deprecated
* @param value
*/
set provide(value: TokenProvider);

@@ -31,0 +36,0 @@ get useClass(): Type<T>;

@@ -9,3 +9,3 @@ import type { Type } from "@tsed/core";

*/
provide: TokenProvider<T>;
token: TokenProvider<T>;
/**

@@ -12,0 +12,0 @@ * Create alias token to retrieve the instance provider.

import type { ProviderOpts } from "../interfaces/ProviderOpts.js";
import type { TokenProvider } from "../interfaces/TokenProvider.js";
type Opts<Type = any> = Partial<ProviderOpts<Type>> & ({
token: TokenProvider<Type>;
} | {
/**
* @deprecated use token prop instead
*/
provide: TokenProvider<Type>;
});
/**
* Register a provider configuration.
* @param {ProviderOpts<any>} opts
* @deprecated Since v8. Use injectable() function instead.
*/
export declare function registerProvider<Type = any>(opts: Partial<ProviderOpts<Type>> & Pick<ProviderOpts<Type>, "provide">): import("../index.js").Provider<any>;
export declare function registerProvider<Type = any>({ token, provide, ...opts }: Opts<Type>): import("../index.js").Provider<any>;
export {};

@@ -5,3 +5,3 @@ {

"type": "module",
"version": "8.0.0-rc.6",
"version": "8.0.0",
"source": "./src/index.ts",

@@ -33,8 +33,8 @@ "main": "./lib/esm/index.js",

"devDependencies": {
"@tsed/barrels": "8.0.0-rc.6",
"@tsed/core": "8.0.0-rc.6",
"@tsed/hooks": "8.0.0-rc.6",
"@tsed/barrels": "8.0.0",
"@tsed/core": "8.0.0",
"@tsed/hooks": "8.0.0",
"@tsed/logger": "^6.7.8",
"@tsed/schema": "8.0.0-rc.6",
"@tsed/typescript": "8.0.0-rc.6",
"@tsed/schema": "8.0.0",
"@tsed/typescript": "8.0.0",
"cross-env": "7.0.3",

@@ -47,6 +47,6 @@ "eslint": "9.12.0",

"peerDependencies": {
"@tsed/core": "8.0.0-rc.6",
"@tsed/hooks": "8.0.0-rc.6",
"@tsed/core": "8.0.0",
"@tsed/hooks": "8.0.0",
"@tsed/logger": ">=6.7.5",
"@tsed/schema": "8.0.0-rc.6"
"@tsed/schema": "8.0.0"
},

@@ -73,6 +73,3 @@ "peerDependenciesMeta": {

"author": "Romain Lenzotti",
"license": "MIT",
"publishConfig": {
"tag": "rc"
}
"license": "MIT"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc