Socket
Socket
Sign inDemoInstall

@tsed/di

Package Overview
Dependencies
Maintainers
0
Versions
982
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 7.73.6 to 7.74.0

lib/cjs/common/interfaces/ImportTokenProviderOpts.js

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/schema")):"function"==typeof define&&define.amd?define(["@tsed/core","@tsed/schema"],t):"object"==typeof exports?exports["@tsed/di"]=t(require("@tsed/core"),require("@tsed/schema")):e["@tsed/di"]=t(e["@tsed/core"],e["@tsed/schema"])}(self,((e,t)=>(()=>{"use strict";var r={803:t=>{t.exports=e},953:e=>{e.exports=t}},s={};function o(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return r[e](n,n.exports,o),n.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{Configuration:()=>l,Constant:()=>d,Container:()=>_,Controller:()=>P,ControllerProvider:()=>x,DIConfiguration:()=>K,DI_PARAMS:()=>t,DI_PARAM_OPTIONS:()=>r,GlobalProviderRegistry:()=>m,GlobalProviders:()=>O,INJECTABLE_PROP:()=>e,Inject:()=>p,Injectable:()=>T,InjectablePropertyType:()=>s,InjectionError:()=>U,InjectorService:()=>Y,Intercept:()=>R,Interceptor:()=>C,InvalidPropertyTokenError:()=>a,LOGGER:()=>W,LazyInject:()=>S,LocalsContainer:()=>V,Module:()=>w,OptionalLazyInject:()=>I,Opts:()=>j,OverrideProvider:()=>N,Provider:()=>v,ProviderScope:()=>g,ProviderType:()=>f,Scope:()=>A,Service:()=>D,UndefinedTokenError:()=>G,UseOpts:()=>M,Value:()=>L,colors:()=>F,createContainer:()=>H,getConfiguration:()=>Z,getConstructorDependencies:()=>c,getTokens:()=>z,injectProperty:()=>h,mergeMount:()=>X,registerController:()=>b,registerProvider:()=>E,registerValue:()=>k,resolveControllers:()=>J,setConstructorDependencies:()=>u});const e="DI:INJECTABLE_PROP",t="DI:PARAMS",r="DI:PARAM:OPTIONS";var s,i=o(803);class a extends Error{name="INVALID_TOKEN_ERROR";constructor(e,t){super(`Object isn't a valid token. Please check the token set on ${(0,i.nameOf)((0,i.classOf)(e))}.${t}.\n- Check that it is not a circular reference.\n- Check that the token (class or symbol) exists`)}}function c(e,t){return i.Metadata.getOwn("override:ctor:design:paramtypes",e,t)||[...i.Metadata.getParamTypes(e,t)]||[]}function u(e,t){i.Metadata.set("override:ctor:design:paramtypes",t,e)}function h(t,r,s){i.Store.from(t).merge(e,{[r]:{bindingType:i.DecoratorTypes.PROP,propertyKey:r,...s}})}function p(e,t=(e=>e)){return(s,o,n)=>{switch((0,i.decoratorTypeOf)([s,o,n])){case i.DecoratorTypes.PARAM_CTOR:if(e){const t=c(s,o),r=t[n];t[n]=r===Array?[e]:e,i.Metadata.setParamTypes(s,o,t),u(s,t)}break;case i.DecoratorTypes.PROP:const l=e||i.Metadata.getType(s,o);if(l===Object)throw new a(s,String(o));h(s,String(o),{resolver(n,a,{options:c,...u}){const h=i.Metadata.getType(s,o);if(a.set(r,{...c}),h===Array){let s;return s||(s=n.getMany(e,a,u),a.delete(r)),s.forEach(((e,t)=>{(0,i.isPromise)(s)&&e.then((e=>{s[t]=e}))})),()=>t(s)}let p;return p||(p=n.invoke(l,a,u),a.delete(r)),(0,i.isPromise)(p)&&p.then((e=>{p=e})),()=>t(p)}});break;default:throw new i.UnsupportedDecoratorType(p,[s,o,n])}}}function l(e={}){return(...t)=>{switch((0,i.decoratorTypeOf)(t)){case i.DecoratorTypes.CLASS:(0,i.StoreSet)("configuration",e)(t[0]);break;default:case i.DecoratorTypes.PARAM_CTOR:return p(l)(t[0],t[1],t[2])}}}function d(t,r){return(o,n)=>{i.Store.from(o).merge(e,{[n]:{bindingType:s.CONSTANT,propertyKey:n,expression:t,defaultValue:r}})}}!function(e){e.METHOD="method",e.PROPERTY="property",e.CONSTANT="constant",e.VALUE="value",e.INTERCEPTOR="interceptor"}(s||(s={}));var g,f,y=o(953);!function(e){e.SINGLETON="singleton",e.REQUEST="request",e.INSTANCE="instance"}(g||(g={})),function(e){e.VALUE="value",e.FACTORY="factory",e.SERVICE="service",e.PROVIDER="provider",e.MODULE="module",e.CONTROLLER="controller",e.INTERCEPTOR="interceptor",e.MIDDLEWARE="middleware"}(f||(f={}));class v{type=f.PROVIDER;deps;imports;alias;useFactory;useAsyncFactory;useValue;hooks;_useClass;_provide;_store;_tokenStore;constructor(e,t={}){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,i.getClassOrSymbol)(e),this._tokenStore=this._store=i.Store.from(e))}get useClass(){return this._useClass}set useClass(e){(0,i.isClass)(e)&&(this._useClass=(0,i.classOf)(e),this._store=i.Store.from(e),this.hooks=(0,i.methodsOf)(this._useClass).reduce(((e,{propertyKey:t})=>String(t).startsWith("$")?{...e,[t]:(e,...r)=>e[t](...r)}:e),{}))}get className(){return this.name}get name(){return(0,i.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()?g.SINGLETON:this.get("scope")}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",[])}get(e){return this.store.get(e)||this._tokenStore.get(e)}isAsync(){return!!this.useAsyncFactory}clone(){return new((0,i.classOf)(this))(this._provide,this)}hasChildren(){return!!this.children.length}hasParent(){return!!this.store.get("parentController")}toString(){return["Token",this.name,this.useClass&&(0,i.nameOf)(this.useClass),this.useFactory&&"Factory",this.useValue&&"Value",this.useAsyncFactory&&"AsyncFactory"].filter(Boolean).join(":")}}class m extends Map{#e=new Map;get(e){return super.get((0,i.getClassOrSymbol)(e))}has(e){return super.has((0,i.getClassOrSymbol)(e))}set(e,t){return super.set((0,i.getClassOrSymbol)(e),t),this}merge(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,i.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}onInvoke(e,t,r){const s=this.#e.get(e.type);s?.onInvoke&&s.onInvoke(e,t,r)}getRegistrySettings(e){let t="provider";if("string"==typeof e)t=e;else{const r=this.get(e);r&&(t=r.type)}return this.#e.get(t)||{model:v}}createRegisterFn(e){return(t,r)=>{t=Object.assign({instance:r},t,{type:e}),this.merge(t.provide,t)}}createIfNotExists(e,t){const r=t.type||f.PROVIDER;if(!this.has(e)){const{model:s=v}=this.#e.get(r)||{},o=new s(e,t);this.set(e,o)}return this.get(e)}}const O=new m;function E(e){if(!e.provide)throw new Error("Provider.provide is required");return O.merge(e.provide,e)}O.createRegistry(f.CONTROLLER,v);const k=(e,t)=>{e.provide||(e={provide:e}),e=Object.assign({scope:g.SINGLETON,useValue:t},e,{type:f.VALUE}),O.merge(e.provide,e)},b=O.createRegisterFn(f.CONTROLLER);function P(e){const{children:t=[],path:r,...s}=function(e){return"string"==typeof e||e instanceof RegExp||(0,i.isArrayOrArrayClass)(e)?{path:e}:e}(e);return(0,i.useDecorators)((e=>{b({provide:e,...s})}),r&&(0,y.Path)(r),(0,y.Children)(...t))}function T(e={}){return t=>{E({...e,...e.provide?{useClass:t}:{provide:t}})}}function R(t,r){return(...o)=>{const[n,a,c]=o;switch((0,i.decoratorTypeOf)(o)){case i.DecoratorTypes.CLASS:(0,i.decorateMethodsOf)(n,R(t,r));break;case i.DecoratorTypes.METHOD:return i.Store.from(n).merge(e,{[a]:{options:r,propertyKey:a,useType:t,bindingType:s.INTERCEPTOR}}),c}}}function C(){return T({type:f.INTERCEPTOR})}function S(e,t,{optional:r=!1,packageName:s=t.toString()}={}){return(o,n)=>{let a,c;h(o,n,{resolver:o=>async()=>{if(!c){const n=await(0,i.importPackage)(s,t,r);if(c=n[e],!c&&!r)throw new Error(`Unable to lazy load the "${e}". The token isn't a valid token provider.`);a=c?await o.lazyInvoke(c):{}}return a}})}}function I(e,t){return S(e,t,{optional:!0})}function w(e={}){const{scopes:t,imports:r,resolvers:s,deps:o,scope:n,...a}=e;return(0,i.useDecorators)(l(a),T({type:f.MODULE,scope:g.SINGLETON,imports:r,deps:o,injectable:!1,resolvers:s}))}function A(e=g.REQUEST){return(0,i.StoreSet)("scope",e)}function j(e,t,s){A(g.INSTANCE)((0,i.classOf)(e)),p(r)(e,t,s)}function N(e){return t=>{O.get(e).useClass=t}}function D(){return T()}function M(t){return(s,o,n)=>{switch((0,i.decoratorTypeOf)([s,o,n])){case i.DecoratorTypes.PARAM_CTOR:i.Store.from(s).merge(`${r}:${n}`,t);break;case i.DecoratorTypes.PROP:i.Store.from(s).merge(e,{[o]:{options:t}});break;default:throw new i.UnsupportedDecoratorType(M,[s,o,n])}}}function L(t,r){return(o,n)=>{i.Store.from(o).merge(e,{[n]:{bindingType:s.VALUE,propertyKey:n,expression:t,defaultValue:r}})}}class _ extends Map{add(e,t={}){const r=O.get(e)?.clone()||new v(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);return[...this].reduce(((r,[s,o])=>t.includes(o.type)||!e?[...r,o]:r),[])}addProviders(e){e.forEach((e=>{this.hasProvider(e.provide)||this.setProvider(e.provide,e.clone())}))}}class x extends v{tokenRouter;constructor(e,t={}){super(e,t),this.type=f.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)}}class V extends Map{hooks=new i.Hooks;async destroy(){await this.hooks.asyncEmit("$onDestroy")}}const $=e=>e=>(process.env.NO_COLOR,e),F={red:$(),yellow:$(),green:$()};class U extends Error{name="INJECTION_ERROR";tokens=[];origin;constructor(e,t){super((0,i.isString)(t)?t:""),this.tokens=[e],t&&((0,i.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,i.nameOf)(e))).join(" > ");this.message=`Injection failed on ${s}${r}`}static throwInjectorError(e,t,r){throw t&&(0,i.isClass)(e)&&(r.message=function(e,t){let r="";const s=(0,i.getConstructorArgNames)(e).map(((e,s)=>(t.index===s&&(r=e,e=F.red(e)),`${e}: ${(0,i.nameOf)(t.deps[s])}`))).join(", "),o=(0,i.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)+F.red("^"+"‾".repeat(r.length-1)))(n):"")}(e,{...t,message:r.message})),new U(e,r)}}class G extends Error{name="UNDEFINED_TOKEN_ERROR";constructor(){super("Given token is undefined. Have you enabled emitDecoratorMetadata in your tsconfig.json or decorated your class with @Injectable, @Service, ... decorator ?")}}class K{default=new Map;map=new Map;constructor(e={}){return Object.entries({scopes:{},resolvers:[],imports:[],routes:[],logger:{},...e}).forEach((([e,t])=>{this.default.set(e,t)})),(0,i.proxyDelegation)(this,{ownKeys:e=>[...e.default.keys(),...e.map.keys()]})}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 scopes(){return this.map.get("scopes")}set scopes(e){this.map.set("scopes",e)}get resolvers(){return this.getRaw("resolvers")}set resolvers(e){this.map.set("resolvers",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,i.setValue)(this.map,e,t),this}get(e,t){return this.getRaw(e,t)}resolve(e){return e.replace("${rootDir}",this.rootDir)}getRaw(e,t){const r=(0,i.getValue)(this.map,e);return void 0!==r?r:(0,i.getValue)(this.default,e,t)}}function H(e){const t=new _(O.entries());return e&&t.delete(e),t}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;const q=["mount","imports"];function z(e){return e?(0,i.isArray)(e)?e.filter(i.isClass).map((e=>({token:e}))):Object.keys(e).reduce(((t,r)=>[...t,...[].concat(e[r]).filter(i.isClass).map((e=>({route:r,token:e})))]),[]):[]}function B(e){return e.map((({token:e})=>O.get(e))).filter((e=>e?.type===f.MODULE&&e.configuration)).flatMap((e=>J(e.configuration)))}function J(e){const t=q.flatMap((t=>z(e[t])));return[...B(t),...t].filter((e=>!!e.route))}var Q;let Y=Q=class extends _{settings=new K;logger=console;resolvedConfiguration=!1;#t=new V;#r=new i.Hooks;constructor(){super(),this.#t.set(Q,this)}get resolvers(){return this.settings.resolvers}get scopes(){return this.settings.scopes||{}}scopeOf(e){return e.scope||this.scopes[e.type]||g.SINGLETON}toArray(){return[...this.#t.values()]}get(e,t={}){const r=this.getInstance(e);if(void 0!==r)return r;if(!this.hasProvider(e))for(const r of this.resolvers){const s=r.get(e,t);if(void 0!==s)return s}}getMany(e,t,r){return this.getProviders(e).map((e=>this.invoke(e.token,t,r)))}has(e){return void 0!==this.#t.get(e)}alias(e,t){return this.#t.set(t,this.#t.get(e)),this}invoke(e,t,s={}){let o=t?t.get(e):void 0;if(void 0!==o)return o;if(e===l)return this.settings;if(o=s.rebuild?void 0:this.getInstance(e),null!=o)return o;if(e===r)return{};const n=this.ensureProvider(e),a=t=>{this.#t.set(e,t),n?.alias&&this.alias(e,n.alias)};if(!n||s.rebuild)return o=this.resolve(e,t,s),this.hasProvider(e)&&a(o),o;switch(o=this.resolve(e,t,s),this.scopeOf(n)){case g.SINGLETON:return n.hooks&&!s.rebuild&&this.registerHooks(n,o),n.isAsync()&&(0,i.isPromise)(o)?(a(o),o=o.then((e=>(a(e),e))),o):(a(o),o);case g.REQUEST:return t&&(t.set(e,o),n.hooks&&n.hooks.$onDestroy&&t.hooks.on("$onDestroy",((...e)=>n.hooks.$onDestroy(o,...e)))),o}return o}async loadAsync(){for(const[,e]of this)!this.has(e.token)&&e.isAsync()&&await this.invoke(e.token)}loadSync(){for(const[,e]of this)this.has(e.token)||this.scopeOf(e)!==g.SINGLETON||this.invoke(e.token)}bootstrap(e=H()){return this.addProviders(e),this.resolveConfiguration(),this.settings.imports=this.settings.imports?.filter((e=>e.token!==Q)).map((e=>{if("token"in e&&"use"in e){const{token:t,use:r}=e,s=this.getProvider(t);if(s)return s.useValue=r,s.useFactory=void 0,s.useAsyncFactory=void 0,void(s.useClass=void 0)}return e})).filter(Boolean),this}loadModule(e){this.settings.routes=this.settings.routes.concat(J(this.settings));const t=H();return t.delete(e),t.addProvider(e,{type:"server:module",scope:g.SINGLETON}),this.load(t)}async load(e=H()){this.bootstrap(e),await this.loadAsync(),this.loadSync(),await this.emit("$beforeInit"),await this.emit("$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])=>{["resolvers","mount","imports"].includes(t)||(r=e.has(t)?(0,i.deepMerge)(e.get(t),r):(0,i.deepClone)(r),e.set(t,r))})),t.resolvers&&(this.settings.resolvers=this.settings.resolvers.concat(t.resolvers))})),e.forEach(((e,t)=>{this.settings.set(t,(0,i.deepMerge)(e,this.settings.get(t)))})),this.resolvedConfiguration=!0}bindInjectableProperties(t,r,o){const n=(0,i.ancestorsOf)((0,i.classOf)(t)).reduce(((t,r)=>({...t,...i.Store.from(r).get(e)||{}})),{});Object.values(n).forEach((e=>{switch(e.bindingType){case s.PROPERTY:this.bindProperty(t,e,r,o);break;case s.CONSTANT:this.bindConstant(t,e);break;case s.VALUE:this.bindValue(t,e);break;case s.INTERCEPTOR:this.bindInterceptor(t,e)}}))}bindProperty(e,{propertyKey:t,resolver:r,options:s={}},o,n){let a;a=r(this,o,{...n,options:s}),(0,i.catchError)((()=>Object.defineProperty(e,t,{get:a})))}bindValue(e,{propertyKey:t,expression:r,defaultValue:s}){const o={get:()=>this.settings.get(r)||s,set:e=>this.settings.set(r,e),enumerable:!0,configurable:!0};(0,i.catchError)((()=>Object.defineProperty(e,t,o)))}bindConstant(e,{propertyKey:t,expression:r,defaultValue:s}){let o;const n={get:()=>{if(void 0!==o)return o;const e=this.settings.get(r,s);return o=Object.freeze((0,i.deepClone)(e)),o},enumerable:!0,configurable:!0};(0,i.catchError)((()=>Object.defineProperty(e,t,n)))}bindInterceptor(e,{propertyKey:t,useType:r,options:s}){const o=(0,i.classOf)(e),n=e[t];e[t]=(...i)=>{const a=t=>{if(!t)return n.apply(e,i);throw t},c={target:o,propertyKey:t,args:i,options:s,next:a};return this.get(r).intercept({...c,options:s},a)}}async lazyInvoke(e){let t=this.getInstance(e);return t||(t=await this.invoke(e),(0,i.isFunction)(t?.$onInit)&&await t.$onInit()),t}emit(e,...t){return this.#r.asyncEmit(e,t)}alter(e,t,...r){return this.#r.alter(e,t,r)}alterAsync(e,t,...r){return this.#r.asyncAlter(e,t,r)}destroy(){return this.emit("$onDestroy")}ensureProvider(e){return!this.hasProvider(e)&&O.has(e)&&this.addProvider(e),this.getProvider(e)}getInstance(e){return this.#t.get(e)}resolve(e,t=new V,s={}){const o=this.mapInvokeOptions(e,t,s);if(!o)return;const{token:n,deps:a,construct:c,imports:u,provider:h}=o;let p;h&&O.onInvoke(h,t,{...o,injector:this});let l=!1;try{const e=e=>(o,n)=>{if(l={token:o,index:n,deps:a},o!==r){const e=h?.store?.get(`${r}:${n}`);t.set(r,e||{})}return(0,i.isArray)(o)?this.getMany(o[0],t,s):(0,i.isInheritedFrom)(o,v,1)?h:this.invoke(o,t,{parent:e})};u.forEach(e());const o=a.map(e(n));l=!1,p=c(o)}catch(e){U.throwInjectorError(n,l,e)}if(void 0===p)throw new U(n,`Unable to create new instance from undefined value. Check your provider declaration for ${(0,i.nameOf)(n)}`);return p&&(0,i.isClass)((0,i.classOf)(p))&&this.bindInjectableProperties(p,t,s),p}mapInvokeOptions(e,t,s){let o,n,a=s.imports,u=s.deps,h=s.scope;if(!e||e===Object)throw new G;if(this.hasProvider(e)?n=this.getProvider(e):(n=new v(e),this.resolvers.forEach((s=>{const o=s.get(e,t.get(r));void 0!==o&&(n.useFactory=()=>o)}))),h=h||this.scopeOf(n),u=u||n.deps,a=a||n.imports,void 0!==n.useValue)o=()=>(0,i.isFunction)(n.useValue)?n.useValue():n.useValue;else if(n.useFactory)o=e=>n.useFactory(...e);else if(n.useAsyncFactory)o=async e=>(e=await Promise.all(e),n.useAsyncFactory(...e));else{if(!n.useClass)return!1;u=u||c(n.useClass),o=e=>new n.useClass(...e)}return{token:e,scope:h||i.Store.from(e).get("scope")||g.SINGLETON,deps:u||[],imports:a||[],construct:o,provider:n}}registerHooks(e,t){e.hooks&&Object.entries(e.hooks).forEach((([r,s])=>{this.#r.on(r,((...r)=>s(this.get(e.token)||t,...r)))}))}};Y=Q=function(e,t,r,s){var o,n=arguments.length,i=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(n<3?o(i):n>3?o(t,r,i):o(t,r))||i);return n>3&&i&&Object.defineProperty(t,r,i),i}([T({scope:g.SINGLETON,global:!0}),function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[])],Y);const W=Symbol.for("LOGGER");function X(e={},t={}){return Object.entries(t).reduce(((e,[t,r])=>({...e,[t]:(e[t]||[]).concat(r)})),e)}function Z(e,t={}){const r=i.Store.from(e).get("configuration")||{};return{...r,...t,mount:X(r.mount,t.mount)}}E({provide:W,deps:[Y],useFactory:e=>e.logger})})(),n})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@tsed/core"),require("@tsed/schema")):"function"==typeof define&&define.amd?define(["@tsed/core","@tsed/schema"],t):"object"==typeof exports?exports["@tsed/di"]=t(require("@tsed/core"),require("@tsed/schema")):e["@tsed/di"]=t(e["@tsed/core"],e["@tsed/schema"])}(self,((e,t)=>(()=>{"use strict";var r={803:t=>{t.exports=e},953:e=>{e.exports=t}},s={};function o(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return r[e](n,n.exports,o),n.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{Configuration:()=>p,Constant:()=>d,Container:()=>_,Controller:()=>P,ControllerProvider:()=>x,DIConfiguration:()=>K,DI_PARAMS:()=>t,DI_PARAM_OPTIONS:()=>r,GlobalProviderRegistry:()=>m,GlobalProviders:()=>O,INJECTABLE_PROP:()=>e,Inject:()=>l,Injectable:()=>T,InjectablePropertyType:()=>s,InjectionError:()=>U,InjectorService:()=>Y,Intercept:()=>C,Interceptor:()=>R,InvalidPropertyTokenError:()=>a,LOGGER:()=>W,LazyInject:()=>I,LocalsContainer:()=>V,Module:()=>w,OptionalLazyInject:()=>S,Opts:()=>j,OverrideProvider:()=>N,Provider:()=>v,ProviderScope:()=>g,ProviderType:()=>f,Scope:()=>A,Service:()=>D,UndefinedTokenError:()=>G,UseOpts:()=>M,Value:()=>L,colors:()=>$,createContainer:()=>H,getConfiguration:()=>Z,getConstructorDependencies:()=>c,getTokens:()=>z,injectProperty:()=>h,mergeMount:()=>X,registerController:()=>b,registerProvider:()=>E,registerValue:()=>k,resolveControllers:()=>J,setConstructorDependencies:()=>u});const e="DI:INJECTABLE_PROP",t="DI:PARAMS",r="DI:PARAM:OPTIONS";var s,i=o(803);class a extends Error{name="INVALID_TOKEN_ERROR";constructor(e,t){super(`Object isn't a valid token. Please check the token set on ${(0,i.nameOf)((0,i.classOf)(e))}.${t}.\n- Check that it is not a circular reference.\n- Check that the token (class or symbol) exists`)}}function c(e,t){return i.Metadata.getOwn("override:ctor:design:paramtypes",e,t)||[...i.Metadata.getParamTypes(e,t)]||[]}function u(e,t){i.Metadata.set("override:ctor:design:paramtypes",t,e)}function h(t,r,s){i.Store.from(t).merge(e,{[r]:{bindingType:i.DecoratorTypes.PROP,propertyKey:r,...s}})}function l(e,t=(e=>e)){return(s,o,n)=>{switch((0,i.decoratorTypeOf)([s,o,n])){case i.DecoratorTypes.PARAM_CTOR:if(e){const t=c(s,o),r=t[n];t[n]=r===Array?[e]:e,i.Metadata.setParamTypes(s,o,t),u(s,t)}break;case i.DecoratorTypes.PROP:const p=e||i.Metadata.getType(s,o);if(p===Object)throw new a(s,String(o));h(s,String(o),{resolver(n,a,{options:c,...u}){const h=i.Metadata.getType(s,o);if(a.set(r,{...c}),h===Array){let s;return s||(s=n.getMany(e,a,u),a.delete(r)),s.forEach(((e,t)=>{(0,i.isPromise)(s)&&e.then((e=>{s[t]=e}))})),()=>t(s)}let l;return l||(l=n.invoke(p,a,u),a.delete(r)),(0,i.isPromise)(l)&&l.then((e=>{l=e})),()=>t(l)}});break;default:throw new i.UnsupportedDecoratorType(l,[s,o,n])}}}function p(e={}){return(...t)=>{switch((0,i.decoratorTypeOf)(t)){case i.DecoratorTypes.CLASS:(0,i.StoreSet)("configuration",e)(t[0]);break;default:case i.DecoratorTypes.PARAM_CTOR:return l(p)(t[0],t[1],t[2])}}}function d(t,r){return(o,n)=>{i.Store.from(o).merge(e,{[n]:{bindingType:s.CONSTANT,propertyKey:n,expression:t,defaultValue:r}})}}!function(e){e.METHOD="method",e.PROPERTY="property",e.CONSTANT="constant",e.VALUE="value",e.INTERCEPTOR="interceptor"}(s||(s={}));var g,f,y=o(953);!function(e){e.SINGLETON="singleton",e.REQUEST="request",e.INSTANCE="instance"}(g||(g={})),function(e){e.VALUE="value",e.FACTORY="factory",e.SERVICE="service",e.PROVIDER="provider",e.MODULE="module",e.CONTROLLER="controller",e.INTERCEPTOR="interceptor",e.MIDDLEWARE="middleware"}(f||(f={}));class v{type=f.PROVIDER;deps;imports;alias;useFactory;useAsyncFactory;useValue;hooks;_useClass;_provide;_store;_tokenStore;constructor(e,t={}){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,i.getClassOrSymbol)(e),this._tokenStore=this._store=i.Store.from(e))}get useClass(){return this._useClass}set useClass(e){(0,i.isClass)(e)&&(this._useClass=(0,i.classOf)(e),this._store=i.Store.from(e),this.hooks=(0,i.methodsOf)(this._useClass).reduce(((e,{propertyKey:t})=>String(t).startsWith("$")?{...e,[t]:(e,...r)=>e[t](...r)}:e),{}))}get className(){return this.name}get name(){return(0,i.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()?g.SINGLETON:this.get("scope")}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",[])}get(e){return this.store.get(e)||this._tokenStore.get(e)}isAsync(){return!!this.useAsyncFactory}clone(){return new((0,i.classOf)(this))(this._provide,this)}hasChildren(){return!!this.children.length}hasParent(){return!!this.store.get("parentController")}toString(){return["Token",this.name,this.useClass&&(0,i.nameOf)(this.useClass),this.useFactory&&"Factory",this.useValue&&"Value",this.useAsyncFactory&&"AsyncFactory"].filter(Boolean).join(":")}}class m extends Map{#e=new Map;get(e){return super.get((0,i.getClassOrSymbol)(e))}has(e){return super.has((0,i.getClassOrSymbol)(e))}set(e,t){return super.set((0,i.getClassOrSymbol)(e),t),this}merge(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,i.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}onInvoke(e,t,r){const s=this.#e.get(e.type);s?.onInvoke&&s.onInvoke(e,t,r)}getRegistrySettings(e){let t="provider";if("string"==typeof e)t=e;else{const r=this.get(e);r&&(t=r.type)}return this.#e.get(t)||{model:v}}createRegisterFn(e){return(t,r)=>{t=Object.assign({instance:r},t,{type:e}),this.merge(t.provide,t)}}createIfNotExists(e,t){const r=t.type||f.PROVIDER;if(!this.has(e)){const{model:s=v}=this.#e.get(r)||{},o=new s(e,t);this.set(e,o)}return this.get(e)}}const O=new m;function E(e){if(!e.provide)throw new Error("Provider.provide is required");return O.merge(e.provide,e)}O.createRegistry(f.CONTROLLER,v);const k=(e,t)=>{e.provide||(e={provide:e}),e=Object.assign({scope:g.SINGLETON,useValue:t},e,{type:f.VALUE}),O.merge(e.provide,e)},b=O.createRegisterFn(f.CONTROLLER);function P(e){const{children:t=[],path:r,...s}=function(e){return"string"==typeof e||e instanceof RegExp||(0,i.isArrayOrArrayClass)(e)?{path:e}:e}(e);return(0,i.useDecorators)((e=>{b({provide:e,...s})}),r&&(0,y.Path)(r),(0,y.Children)(...t))}function T(e={}){return t=>{E({...e,...e.provide?{useClass:t}:{provide:t}})}}function C(t,r){return(...o)=>{const[n,a,c]=o;switch((0,i.decoratorTypeOf)(o)){case i.DecoratorTypes.CLASS:(0,i.decorateMethodsOf)(n,C(t,r));break;case i.DecoratorTypes.METHOD:return i.Store.from(n).merge(e,{[a]:{options:r,propertyKey:a,useType:t,bindingType:s.INTERCEPTOR}}),c}}}function R(){return T({type:f.INTERCEPTOR})}function I(e,t,{optional:r=!1,packageName:s=t.toString()}={}){return(o,n)=>{let a,c;h(o,n,{resolver:o=>async()=>{if(!c){const n=await(0,i.importPackage)(s,t,r);if(c=n[e],!c&&!r)throw new Error(`Unable to lazy load the "${e}". The token isn't a valid token provider.`);a=c?await o.lazyInvoke(c):{}}return a}})}}function S(e,t){return I(e,t,{optional:!0})}function w(e={}){const{scopes:t,imports:r,resolvers:s,deps:o,scope:n,...a}=e;return(0,i.useDecorators)(p(a),T({type:f.MODULE,scope:g.SINGLETON,imports:r,deps:o,injectable:!1,resolvers:s}))}function A(e=g.REQUEST){return(0,i.StoreSet)("scope",e)}function j(e,t,s){A(g.INSTANCE)((0,i.classOf)(e)),l(r)(e,t,s)}function N(e){return t=>{O.get(e).useClass=t}}function D(){return T()}function M(t){return(s,o,n)=>{switch((0,i.decoratorTypeOf)([s,o,n])){case i.DecoratorTypes.PARAM_CTOR:i.Store.from(s).merge(`${r}:${n}`,t);break;case i.DecoratorTypes.PROP:i.Store.from(s).merge(e,{[o]:{options:t}});break;default:throw new i.UnsupportedDecoratorType(M,[s,o,n])}}}function L(t,r){return(o,n)=>{i.Store.from(o).merge(e,{[n]:{bindingType:s.VALUE,propertyKey:n,expression:t,defaultValue:r}})}}class _ extends Map{add(e,t={}){const r=O.get(e)?.clone()||new v(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);return[...this].reduce(((r,[s,o])=>t.includes(o.type)||!e?[...r,o]:r),[])}addProviders(e){e.forEach((e=>{this.hasProvider(e.provide)||this.setProvider(e.provide,e.clone())}))}}class x extends v{tokenRouter;constructor(e,t={}){super(e,t),this.type=f.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)}}class V extends Map{hooks=new i.Hooks;async destroy(){await this.hooks.asyncEmit("$onDestroy")}}const F=e=>e=>(process.env.NO_COLOR,e),$={red:F(),yellow:F(),green:F()};class U extends Error{name="INJECTION_ERROR";tokens=[];origin;constructor(e,t){super((0,i.isString)(t)?t:""),this.tokens=[e],t&&((0,i.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,i.nameOf)(e))).join(" > ");this.message=`Injection failed on ${s}${r}`}static throwInjectorError(e,t,r){throw t&&(0,i.isClass)(e)&&(r.message=function(e,t){let r="";const s=(0,i.getConstructorArgNames)(e).map(((e,s)=>(t.index===s&&(r=e,e=$.red(e)),`${e}: ${(0,i.nameOf)(t.deps[s])}`))).join(", "),o=(0,i.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)+$.red("^"+"‾".repeat(r.length-1)))(n):"")}(e,{...t,message:r.message})),new U(e,r)}}class G extends Error{name="UNDEFINED_TOKEN_ERROR";constructor(){super("Given token is undefined. Have you enabled emitDecoratorMetadata in your tsconfig.json or decorated your class with @Injectable, @Service, ... decorator ?")}}class K{default=new Map;map=new Map;constructor(e={}){return Object.entries({scopes:{},resolvers:[],imports:[],routes:[],logger:{},...e}).forEach((([e,t])=>{this.default.set(e,t)})),(0,i.proxyDelegation)(this,{ownKeys:e=>[...e.default.keys(),...e.map.keys()]})}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 scopes(){return this.map.get("scopes")}set scopes(e){this.map.set("scopes",e)}get resolvers(){return this.getRaw("resolvers")}set resolvers(e){this.map.set("resolvers",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,i.setValue)(this.map,e,t),this}get(e,t){return this.getRaw(e,t)}resolve(e){return e.replace("${rootDir}",this.rootDir)}getRaw(e,t){const r=(0,i.getValue)(this.map,e);return void 0!==r?r:(0,i.getValue)(this.default,e,t)}}function H(e){const t=new _(O.entries());return e&&t.delete(e),t}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;const q=["mount","imports"];function z(e){return e?(0,i.isArray)(e)?e.filter(i.isClass).map((e=>({token:e}))):Object.keys(e).reduce(((t,r)=>[...t,...[].concat(e[r]).filter(i.isClass).map((e=>({route:r,token:e})))]),[]):[]}function B(e){return e.map((({token:e})=>O.get(e))).filter((e=>e?.type===f.MODULE&&e.configuration)).flatMap((e=>J(e.configuration)))}function J(e){const t=q.flatMap((t=>z(e[t])));return[...B(t),...t].filter((e=>!!e.route))}var Q;let Y=Q=class extends _{settings=new K;logger=console;resolvedConfiguration=!1;#t=new V;#r=new i.Hooks;constructor(){super(),this.#t.set(Q,this)}get resolvers(){return this.settings.resolvers}get scopes(){return this.settings.scopes||{}}scopeOf(e){return e.scope||this.scopes[e.type]||g.SINGLETON}toArray(){return[...this.#t.values()]}get(e,t={}){const r=this.getInstance(e);if(void 0!==r)return r;if(!this.hasProvider(e))for(const r of this.resolvers){const s=r.get(e,t);if(void 0!==s)return s}}getMany(e,t,r){return this.getProviders(e).map((e=>this.invoke(e.token,t,r)))}has(e){return void 0!==this.#t.get(e)}alias(e,t){return this.#t.set(t,this.#t.get(e)),this}invoke(e,t,s={}){let o=t?t.get(e):void 0;if(void 0!==o)return o;if(e===p)return this.settings;if(o=s.rebuild?void 0:this.getInstance(e),null!=o)return o;if(e===r)return{};const n=this.ensureProvider(e),a=t=>{this.#t.set(e,t),n?.alias&&this.alias(e,n.alias)};if(!n||s.rebuild)return o=this.resolve(e,t,s),this.hasProvider(e)&&a(o),o;switch(o=this.resolve(e,t,s),this.scopeOf(n)){case g.SINGLETON:return n.hooks&&!s.rebuild&&this.registerHooks(n,o),n.isAsync()&&(0,i.isPromise)(o)?(a(o),o=o.then((e=>(a(e),e))),o):(a(o),o);case g.REQUEST:return t&&(t.set(e,o),n.hooks&&n.hooks.$onDestroy&&t.hooks.on("$onDestroy",((...e)=>n.hooks.$onDestroy(o,...e)))),o}return o}async loadAsync(){for(const[,e]of this)!this.has(e.token)&&e.isAsync()&&await this.invoke(e.token)}loadSync(){for(const[,e]of this)this.has(e.token)||this.scopeOf(e)!==g.SINGLETON||this.invoke(e.token)}bootstrap(e=H()){return this.addProviders(e),this.resolveConfiguration(),this.resolveImportsProviders(),this}loadModule(e){this.settings.routes=this.settings.routes.concat(J(this.settings));const t=H();return t.delete(e),t.addProvider(e,{type:"server:module",scope:g.SINGLETON}),this.load(t)}async load(e=H()){this.bootstrap(e),await this.loadAsync(),this.loadSync(),await this.emit("$beforeInit"),await this.emit("$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])=>{["resolvers","mount","imports"].includes(t)||(r=e.has(t)?(0,i.deepMerge)(e.get(t),r):(0,i.deepClone)(r),e.set(t,r))})),t.resolvers&&(this.settings.resolvers=this.settings.resolvers.concat(t.resolvers))})),e.forEach(((e,t)=>{this.settings.set(t,(0,i.deepMerge)(e,this.settings.get(t)))})),this.resolvedConfiguration=!0}bindInjectableProperties(t,r,o){const n=(0,i.ancestorsOf)((0,i.classOf)(t)).reduce(((t,r)=>({...t,...i.Store.from(r).get(e)||{}})),{});Object.values(n).forEach((e=>{switch(e.bindingType){case s.PROPERTY:this.bindProperty(t,e,r,o);break;case s.CONSTANT:this.bindConstant(t,e);break;case s.VALUE:this.bindValue(t,e);break;case s.INTERCEPTOR:this.bindInterceptor(t,e)}}))}bindProperty(e,{propertyKey:t,resolver:r,options:s={}},o,n){let a;a=r(this,o,{...n,options:s}),(0,i.catchError)((()=>Object.defineProperty(e,t,{get:a})))}bindValue(e,{propertyKey:t,expression:r,defaultValue:s}){const o={get:()=>this.settings.get(r)||s,set:e=>this.settings.set(r,e),enumerable:!0,configurable:!0};(0,i.catchError)((()=>Object.defineProperty(e,t,o)))}bindConstant(e,{propertyKey:t,expression:r,defaultValue:s}){let o;const n={get:()=>{if(void 0!==o)return o;const e=this.settings.get(r,s);return o=Object.freeze((0,i.deepClone)(e)),o},enumerable:!0,configurable:!0};(0,i.catchError)((()=>Object.defineProperty(e,t,n)))}bindInterceptor(e,{propertyKey:t,useType:r,options:s}){const o=(0,i.classOf)(e),n=e[t];e[t]=(...i)=>{const a=t=>{if(!t)return n.apply(e,i);throw t},c={target:o,propertyKey:t,args:i,options:s,next:a};return this.get(r).intercept({...c,options:s},a)}}async lazyInvoke(e){let t=this.getInstance(e);return t||(t=await this.invoke(e),(0,i.isFunction)(t?.$onInit)&&await t.$onInit()),t}emit(e,...t){return this.#r.asyncEmit(e,t)}alter(e,t,...r){return this.#r.alter(e,t,r)}alterAsync(e,t,...r){return this.#r.asyncAlter(e,t,r)}destroy(){return this.emit("$onDestroy")}ensureProvider(e){return!this.hasProvider(e)&&O.has(e)&&this.addProvider(e),this.getProvider(e)}getInstance(e){return this.#t.get(e)}resolve(e,t=new V,s={}){const o=this.mapInvokeOptions(e,t,s);if(!o)return;const{token:n,deps:a,construct:c,imports:u,provider:h}=o;let l;h&&O.onInvoke(h,t,{...o,injector:this});let p=!1;try{const e=e=>(o,n)=>{if(p={token:o,index:n,deps:a},o!==r){const e=h?.store?.get(`${r}:${n}`);t.set(r,e||{})}return(0,i.isArray)(o)?this.getMany(o[0],t,s):(0,i.isInheritedFrom)(o,v,1)?h:this.invoke(o,t,{parent:e})};u.forEach(e());const o=a.map(e(n));p=!1,l=c(o)}catch(e){U.throwInjectorError(n,p,e)}if(void 0===l)throw new U(n,`Unable to create new instance from undefined value. Check your provider declaration for ${(0,i.nameOf)(n)}`);return l&&(0,i.isClass)((0,i.classOf)(l))&&this.bindInjectableProperties(l,t,s),l}resolveImportsProviders(){this.settings.imports=this.settings.imports?.filter((e=>e.token!==Q)).map((e=>{if("token"in e){const{token:t,...r}=e,s=this.getProvider(t);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,s){let o,n,a=s.imports,u=s.deps,h=s.scope;if(!e||e===Object)throw new G;if(this.hasProvider(e)?n=this.getProvider(e):(n=new v(e),this.resolvers.forEach((s=>{const o=s.get(e,t.get(r));void 0!==o&&(n.useFactory=()=>o)}))),h=h||this.scopeOf(n),u=u||n.deps,a=a||n.imports,void 0!==n.useValue)o=()=>(0,i.isFunction)(n.useValue)?n.useValue():n.useValue;else if(n.useFactory)o=e=>n.useFactory(...e);else if(n.useAsyncFactory)o=async e=>(e=await Promise.all(e),n.useAsyncFactory(...e));else{if(!n.useClass)return!1;u=u||c(n.useClass),o=e=>new n.useClass(...e)}return{token:e,scope:h||i.Store.from(e).get("scope")||g.SINGLETON,deps:u||[],imports:a||[],construct:o,provider:n}}registerHooks(e,t){e.hooks&&Object.entries(e.hooks).forEach((([r,s])=>{this.#r.on(r,((...r)=>s(this.get(e.token)||t,...r)))}))}};Y=Q=function(e,t,r,s){var o,n=arguments.length,i=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,r):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,s);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(i=(n<3?o(i):n>3?o(t,r,i):o(t,r))||i);return n>3&&i&&Object.defineProperty(t,r,i),i}([T({scope:g.SINGLETON,global:!0}),function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[])],Y);const W=Symbol.for("LOGGER");function X(e={},t={}){return Object.entries(t).reduce(((e,[t,r])=>({...e,[t]:(e[t]||[]).concat(r)})),e)}function Z(e,t={}){const r=i.Store.from(e).get("configuration")||{};return{...r,...t,mount:X(r.mount,t.mount)}}E({provide:W,deps:[Y],useFactory:e=>e.logger})})(),n})()));
//# sourceMappingURL=di.umd.min.js.map

@@ -37,2 +37,3 @@ "use strict";

tslib_1.__exportStar(require("./interfaces/DIResolver.js"), exports);
tslib_1.__exportStar(require("./interfaces/ImportTokenProviderOpts.js"), exports);
tslib_1.__exportStar(require("./interfaces/InjectableProperties.js"), exports);

@@ -39,0 +40,0 @@ tslib_1.__exportStar(require("./interfaces/InterceptorContext.js"), exports);

@@ -231,22 +231,3 @@ "use strict";

// allow mocking or changing provider instance before loading injector
this.settings.imports = this.settings.imports
?.filter((meta) => meta.token !== InjectorService_1)
.map((meta) => {
if ("token" in meta && "use" in meta) {
const { token, use } = meta;
const provider = this.getProvider(token);
if (provider) {
provider.useValue = use;
// @ts-ignore
provider.useFactory = undefined;
// @ts-ignore
provider.useAsyncFactory = undefined;
// @ts-ignore
provider.useClass = undefined;
return;
}
}
return meta;
})
.filter(Boolean);
this.resolveImportsProviders();
return this;

@@ -531,2 +512,35 @@ }

}
resolveImportsProviders() {
this.settings.imports = this.settings.imports
?.filter((meta) => meta.token !== InjectorService_1)
.map((meta) => {
if ("token" in meta) {
const { token, ...props } = meta;
const provider = this.getProvider(token);
if (provider) {
provider.useValue = undefined;
provider.useAsyncFactory = undefined;
provider.useFactory = undefined;
if ("useClass" in props) {
provider.useClass = props.useClass;
return;
}
if ("useFactory" in props) {
provider.useFactory = props.useFactory;
return;
}
if ("useAsyncFactory" in props) {
provider.useAsyncFactory = props.useAsyncFactory;
return;
}
if ("use" in props) {
provider.useValue = props.use;
return;
}
}
}
return meta;
})
.filter(Boolean);
}
/**

@@ -533,0 +547,0 @@ * Create options to invoke a provider or class.

@@ -34,2 +34,3 @@ /**

export * from "./interfaces/DIResolver.js";
export * from "./interfaces/ImportTokenProviderOpts.js";
export * from "./interfaces/InjectableProperties.js";

@@ -36,0 +37,0 @@ export * from "./interfaces/InterceptorContext.js";

@@ -228,22 +228,3 @@ var InjectorService_1;

// allow mocking or changing provider instance before loading injector
this.settings.imports = this.settings.imports
?.filter((meta) => meta.token !== InjectorService_1)
.map((meta) => {
if ("token" in meta && "use" in meta) {
const { token, use } = meta;
const provider = this.getProvider(token);
if (provider) {
provider.useValue = use;
// @ts-ignore
provider.useFactory = undefined;
// @ts-ignore
provider.useAsyncFactory = undefined;
// @ts-ignore
provider.useClass = undefined;
return;
}
}
return meta;
})
.filter(Boolean);
this.resolveImportsProviders();
return this;

@@ -528,2 +509,35 @@ }

}
resolveImportsProviders() {
this.settings.imports = this.settings.imports
?.filter((meta) => meta.token !== InjectorService_1)
.map((meta) => {
if ("token" in meta) {
const { token, ...props } = meta;
const provider = this.getProvider(token);
if (provider) {
provider.useValue = undefined;
provider.useAsyncFactory = undefined;
provider.useFactory = undefined;
if ("useClass" in props) {
provider.useClass = props.useClass;
return;
}
if ("useFactory" in props) {
provider.useFactory = props.useFactory;
return;
}
if ("useAsyncFactory" in props) {
provider.useAsyncFactory = props.useAsyncFactory;
return;
}
if ("use" in props) {
provider.useValue = props.use;
return;
}
}
}
return meta;
})
.filter(Boolean);
}
/**

@@ -530,0 +544,0 @@ * Create options to invoke a provider or class.

import { Store, Type } from "@tsed/core";
import { ProviderOpts } from "../interfaces/ProviderOpts.js";
import { TokenProvider } from "../interfaces/TokenProvider.js";
import type { ProviderOpts } from "../interfaces/ProviderOpts.js";
import type { TokenProvider } from "../interfaces/TokenProvider.js";
import { ProviderScope } from "./ProviderScope.js";
import { ProviderType } from "./ProviderType.js";
export type ProviderHookCallback<T = any> = (instance: T, ...args: any[]) => Promise<void> | void;
export type ProviderHookCallback<T = any> = (instance: T, ...args: unknown[]) => Promise<void> | void;
export declare class Provider<T = any> implements ProviderOpts<T> {

@@ -13,7 +13,7 @@ /**

deps: TokenProvider[];
imports: any[];
imports: (TokenProvider | [TokenProvider])[];
alias?: string;
useFactory: Function;
useAsyncFactory: Function;
useValue: any;
useFactory?: Function;
useAsyncFactory?: Function;
useValue?: unknown;
hooks?: Record<string, ProviderHookCallback<T>>;

@@ -20,0 +20,0 @@ private _useClass;

@@ -34,2 +34,3 @@ /**

export * from "./interfaces/DIResolver.js";
export * from "./interfaces/ImportTokenProviderOpts.js";
export * from "./interfaces/InjectableProperties.js";

@@ -36,0 +37,0 @@ export * from "./interfaces/InterceptorContext.js";

import type { ProviderScope } from "../domain/ProviderScope.js";
import type { DIResolver } from "./DIResolver.js";
import type { ImportTokenProviderOpts } from "./ImportTokenProviderOpts.js";
import type { TokenProvider } from "./TokenProvider.js";
import { TokenProviderOpts } from "./TokenProvider.js";
declare global {

@@ -20,3 +20,3 @@ namespace TsED {

*/
imports: (TokenProvider | TokenProviderOpts)[];
imports: (TokenProvider | ImportTokenProviderOpts)[];
/**

@@ -23,0 +23,0 @@ * Mount controllers

@@ -5,3 +5,4 @@ import { Env } from "@tsed/core";

import type { DIResolver } from "../interfaces/DIResolver.js";
import type { TokenProvider, TokenProviderOpts } from "../interfaces/TokenProvider.js";
import type { ImportTokenProviderOpts } from "../interfaces/ImportTokenProviderOpts.js";
import type { TokenProvider } from "../interfaces/TokenProvider.js";
import type { TokenRoute } from "../interfaces/TokenRoute.js";

@@ -22,4 +23,4 @@ export declare class DIConfiguration {

set resolvers(resolvers: DIResolver[]);
get imports(): (TokenProvider | TokenProviderOpts)[];
set imports(imports: (TokenProvider | TokenProviderOpts)[]);
get imports(): (TokenProvider | ImportTokenProviderOpts)[];
set imports(imports: (TokenProvider | ImportTokenProviderOpts)[]);
get routes(): TokenRoute[];

@@ -26,0 +27,0 @@ set routes(routes: TokenRoute[]);

@@ -5,6 +5,6 @@ import { Container } from "../domain/Container.js";

import { ProviderScope } from "../domain/ProviderScope.js";
import { DILogger } from "../interfaces/DILogger.js";
import type { DILogger } from "../interfaces/DILogger.js";
import { InjectablePropertyOptions, InjectablePropertyValue } from "../interfaces/InjectableProperties.js";
import { InvokeOptions } from "../interfaces/InvokeOptions.js";
import { TokenProvider } from "../interfaces/TokenProvider.js";
import type { InvokeOptions } from "../interfaces/InvokeOptions.js";
import type { TokenProvider } from "../interfaces/TokenProvider.js";
import { DIConfiguration } from "./DIConfiguration.js";

@@ -214,2 +214,3 @@ /**

protected resolve<T>(target: TokenProvider, locals?: LocalsContainer, options?: Partial<InvokeOptions<T>>): T | Promise<T>;
private resolveImportsProviders;
/**

@@ -216,0 +217,0 @@ * Create options to invoke a provider or class.

@@ -1,2 +0,2 @@

import { InjectorService, TokenProvider, TokenProviderOpts } from "../../common/index.js";
import { InjectorService, TokenProvider, type UseImportTokenProviderOpts } from "../../common/index.js";
import { DIContext } from "../domain/DIContext.js";

@@ -28,3 +28,3 @@ /**

*/
static invoke<T = any>(target: TokenProvider, providers?: TokenProviderOpts[]): Promise<T>;
static invoke<T = any>(target: TokenProvider, providers?: UseImportTokenProviderOpts[]): Promise<T>;
/**

@@ -31,0 +31,0 @@ * Return the instance from injector registry

{
"name": "@tsed/di",
"version": "7.73.6",
"version": "7.74.0",
"description": "DI module for Ts.ED Framework",

@@ -28,7 +28,7 @@ "source": "./src/index.ts",

"devDependencies": {
"@tsed/barrels": "7.73.6",
"@tsed/core": "7.73.6",
"@tsed/barrels": "7.74.0",
"@tsed/core": "7.74.0",
"@tsed/logger": ">=6.7.5",
"@tsed/schema": "7.73.6",
"@tsed/typescript": "7.73.6",
"@tsed/schema": "7.74.0",
"@tsed/typescript": "7.74.0",
"cross-env": "7.0.3",

@@ -41,5 +41,5 @@ "eslint": "^8.57.0",

"peerDependencies": {
"@tsed/core": "7.73.6",
"@tsed/core": "7.74.0",
"@tsed/logger": ">=6.7.5",
"@tsed/schema": "7.73.6"
"@tsed/schema": "7.74.0"
},

@@ -46,0 +46,0 @@ "peerDependenciesMeta": {

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

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