New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@inversifyjs/core

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inversifyjs/core - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

lib/cjs/planning/models/BasePlanParamsAutobindOptions.d.ts

6

CHANGELOG.md
# @inversifyjs/core
## 3.3.0
### Minor Changes
- 9c713eb: Updated `GetOptions` with autobind
## 3.2.0

@@ -4,0 +10,0 @@

3

lib/cjs/common/models/OneToManyMapStar.d.ts
import { Cloneable } from './Cloneable';
export type OneToManyMapStartSpec<TRelation extends object> = {
type OneToManyMapStartSpec<TRelation extends object> = {
[TKey in keyof TRelation]: {

@@ -19,2 +19,3 @@ isOptional: undefined extends TRelation[TKey] ? true : false;

}
export {};
//# sourceMappingURL=OneToManyMapStar.d.ts.map
import { InversifyCoreErrorKind } from './InversifyCoreErrorKind';
export declare const isAppErrorSymbol: unique symbol;
declare const isAppErrorSymbol: unique symbol;
export declare class InversifyCoreError extends Error {

@@ -10,2 +10,3 @@ [isAppErrorSymbol]: true;

}
export {};
//# sourceMappingURL=InversifyCoreError.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InversifyCoreError = exports.isAppErrorSymbol = void 0;
exports.isAppErrorSymbol = Symbol.for('@inversifyjs/core/InversifyCoreError');
exports.InversifyCoreError = void 0;
const isAppErrorSymbol = Symbol.for('@inversifyjs/core/InversifyCoreError');
class InversifyCoreError extends Error {
[exports.isAppErrorSymbol];
[isAppErrorSymbol];
kind;
constructor(kind, message, options) {
super(message, options);
this[exports.isAppErrorSymbol] = true;
this[isAppErrorSymbol] = true;
this.kind = kind;

@@ -16,3 +16,3 @@ }

value !== null &&
value[exports.isAppErrorSymbol] === true);
value[isAppErrorSymbol] === true);
}

@@ -19,0 +19,0 @@ static isErrorOfKind(value, kind) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildFilteredServiceBindings = buildFilteredServiceBindings;
const BindingType_1 = require("../../binding/models/BindingType");
function buildFilteredServiceBindings(params, bindingMetadata, options) {

@@ -9,4 +10,29 @@ const serviceIdentifier = options?.customServiceIdentifier ?? bindingMetadata.serviceIdentifier;

];
return serviceBindings.filter((binding) => binding.isSatisfiedBy(bindingMetadata));
const filteredBindings = serviceBindings.filter((binding) => binding.isSatisfiedBy(bindingMetadata));
if (filteredBindings.length === 0 &&
params.autobindOptions !== undefined &&
typeof serviceIdentifier === 'function') {
const binding = buildInstanceBinding(params.autobindOptions, serviceIdentifier);
params.setBinding(binding);
filteredBindings.push(binding);
}
return filteredBindings;
}
function buildInstanceBinding(autobindOptions, serviceIdentifier) {
return {
cache: {
isRight: false,
value: undefined,
},
id: 0,
implementationType: serviceIdentifier,
isSatisfiedBy: () => true,
moduleId: undefined,
onActivation: undefined,
onDeactivation: undefined,
scope: autobindOptions.scope,
serviceIdentifier,
type: BindingType_1.bindingTypeValues.Instance,
};
}
//# sourceMappingURL=buildFilteredServiceBindings.js.map

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

const subplanParams = {
autobindOptions: params.autobindOptions,
getBindings: params.getBindings,

@@ -61,2 +62,3 @@ getClassMetadata: params.getClassMetadata,

servicesBranch: params.servicesBranch,
setBinding: params.setBinding,
};

@@ -63,0 +65,0 @@ return subplan(subplanParams, bindingMetadataList);

import { Newable, ServiceIdentifier } from '@inversifyjs/common';
import { Binding } from '../../binding/models/Binding';
import { ClassMetadata } from '../../metadata/models/ClassMetadata';
import { BasePlanParamsAutobindOptions } from './BasePlanParamsAutobindOptions';
export interface BasePlanParams {
autobindOptions: BasePlanParamsAutobindOptions | undefined;
getBindings: <TInstance>(serviceIdentifier: ServiceIdentifier<TInstance>) => Iterable<Binding<TInstance>> | undefined;
getClassMetadata: (type: Newable) => ClassMetadata;
servicesBranch: Set<ServiceIdentifier>;
setBinding: <TInstance>(binding: Binding<TInstance>) => void;
}
//# sourceMappingURL=BasePlanParams.d.ts.map
import { MetadataName } from '../../metadata/models/MetadataName';
import { GetOptionsTagConstraint } from './GetOptionsTagConstraint';
export interface GetOptions {
autobind?: boolean;
name?: MetadataName;

@@ -5,0 +6,0 @@ optional?: boolean;

@@ -41,2 +41,3 @@ import { ServiceIdentifier, Either, Newable, LazyServiceIdentifier } from '@inversifyjs/common';

interface GetOptions {
autobind?: boolean;
name?: MetadataName;

@@ -224,6 +225,12 @@ optional?: boolean;

interface BasePlanParamsAutobindOptions {
scope: BindingScope;
}
interface BasePlanParams {
autobindOptions: BasePlanParamsAutobindOptions | undefined;
getBindings: <TInstance>(serviceIdentifier: ServiceIdentifier<TInstance>) => Iterable<Binding<TInstance>> | undefined;
getClassMetadata: (type: Newable) => ClassMetadata;
servicesBranch: Set<ServiceIdentifier>;
setBinding: <TInstance>(binding: Binding<TInstance>) => void;
}

@@ -230,0 +237,0 @@

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

import{getOwnReflectMetadata as e,updateOwnReflectMetadata as n,setReflectMetadata as t}from"@inversifyjs/reflect-metadata-utils";import{getBaseType as o}from"@inversifyjs/prototype-utils";import{stringifyServiceIdentifier as i,LazyServiceIdentifier as r,isPromise as s}from"@inversifyjs/common";const c={Request:"Request",Singleton:"Singleton",Transient:"Transient"},a={ConstantValue:"ConstantValue",DynamicValue:"DynamicValue",Factory:"Factory",Instance:"Instance",Provider:"Provider",ServiceRedirection:"ServiceRedirection"};function*u(...e){for(const n of e)yield*n}class d{#e;#n;#t;constructor(e){this.#e=new Map,this.#n={};for(const n of Reflect.ownKeys(e))this.#n[n]=new Map;this.#t=e}add(e,n){this.#o(e).push(n);for(const t of Reflect.ownKeys(n))this.#i(t,n[t]).push(e)}clone(){const e=Reflect.ownKeys(this.#t),n=new d(this.#t);this.#r(this.#e,n.#e);for(const t of e)this.#r(this.#n[t],n.#n[t]);return n}get(e,n){return this.#n[e].get(n)}getAllKeys(e){return this.#n[e].keys()}removeByRelation(e,n){const t=this.get(e,n);if(void 0===t)return;const o=new Set(t);for(const t of o){const o=this.#e.get(t);if(void 0===o)throw new Error("Expecting model relation, none found");for(const i of o)i[e]===n&&this.#s(t,i);this.#e.delete(t)}}#o(e){let n=this.#e.get(e);return void 0===n&&(n=[],this.#e.set(e,n)),n}#i(e,n){let t=this.#n[e].get(n);return void 0===t&&(t=[],this.#n[e].set(n,t)),t}#r(e,n){for(const[t,o]of e)n.set(t,[...o])}#s(e,n){for(const t of Reflect.ownKeys(n))this.#c(e,t,n[t])}#c(e,n,t){const o=this.#n[n].get(t);if(void 0!==o){const i=o.indexOf(e);-1!==i&&o.splice(i,1),0===o.length&&this.#n[n].delete(t)}}}var l,f,p;!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(l||(l={}));class m{#a;#u;constructor(e,n){this.#a=n??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#u=e}static build(e){return new m(e)}add(e,n){this.#a.add(e,n)}clone(){return new m(this.#u,this.#a.clone())}get(e){const n=[],t=this.#a.get(l.serviceId,e);void 0!==t&&n.push(t);const o=this.#u?.get(e);if(void 0!==o&&n.push(o),0!==n.length)return u(...n)}removeAllByModuleId(e){this.#a.removeByRelation(l.moduleId,e)}removeAllByServiceId(e){this.#a.removeByRelation(l.serviceId,e)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(f||(f={}));class g{#d;#u;constructor(e,n){this.#d=n??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#u=e}static build(e){return new g(e)}clone(){return new g(this.#u,this.#d.clone())}get(e){return this.getNonParentBindings(e)??this.#u?.get(e)}getNonParentBindings(e){return this.#d.get(f.serviceId,e)}getNonParentBoundServices(){return this.#d.getAllKeys(f.serviceId)}getByModuleId(e){return this.#d.get(f.moduleId,e)??this.#u?.getByModuleId(e)}removeAllByModuleId(e){this.#d.removeByRelation(f.moduleId,e)}removeAllByServiceId(e){this.#d.removeByRelation(f.serviceId,e)}set(e){const n={[f.serviceId]:e.serviceIdentifier};void 0!==e.moduleId&&(n[f.moduleId]=e.moduleId),this.#d.add(e,n)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(p||(p={}));class h{#l;#u;constructor(e,n){this.#l=n??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#u=e}static build(e){return new h(e)}add(e,n){this.#l.add(e,n)}clone(){return new h(this.#u,this.#l.clone())}get(e){const n=[],t=this.#l.get(p.serviceId,e);void 0!==t&&n.push(t);const o=this.#u?.get(e);if(void 0!==o&&n.push(o),0!==n.length)return u(...n)}removeAllByModuleId(e){this.#l.removeByRelation(p.moduleId,e)}removeAllByServiceId(e){this.#l.removeByRelation(p.serviceId,e)}}function v(e,n,t){const o=Array.isArray(e)?e:[e];if(void 0!==t)if("number"!=typeof t)Reflect.decorate(o,n.prototype,t);else for(const e of o)e(n,void 0,t);else Reflect.decorate(o,n)}const y="@inversifyjs/core/classMetadataReflectKey";function w(){return{constructorArguments:[],lifecycle:{postConstructMethodName:void 0,preDestroyMethodName:void 0},properties:new Map,scope:void 0}}const M="@inversifyjs/core/pendingClassMetadataCountReflectKey";const I=Symbol.for("@inversifyjs/core/InversifyCoreError");class b extends Error{[I];kind;constructor(e,n,t){super(n,t),this[I]=!0,this.kind=e}static is(e){return"object"==typeof e&&null!==e&&!0===e[I]}static isErrorOfKind(e,n){return b.is(e)&&e.kind===n}}var j,C,$;function x(n){const t=e(n,y)??w();if(!function(n){const t=e(n,M);return void 0!==t&&0!==t}(n))return function(e,n){const t=[];if(n.length<e.length)throw new b(j.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}". "${e.name}" constructor requires at least ${e.length.toString()} arguments, found ${n.length.toString()} instead.\nAre you using @inject, @multiInject or @unmanaged decorators in every non optional constructor argument?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`);for(let e=0;e<n.length;++e)void 0===n[e]&&t.push(e);if(t.length>0)throw new b(j.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}" at constructor indexes "${t.join('", "')}".\n\nAre you using @inject, @multiInject or @unmanaged decorators at those indexes?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`)}(n,t.constructorArguments),t;!function(e,n){const t=[];for(let o=0;o<n.constructorArguments.length;++o){const i=n.constructorArguments[o];void 0!==i&&i.kind!==C.unknown||t.push(` - Missing or incomplete metadata for type "${e.name}" at constructor argument with index ${o.toString()}.\nEvery constructor parameter must be decorated either with @inject, @multiInject or @unmanaged decorator.`)}for(const[o,i]of n.properties)i.kind===C.unknown&&t.push(` - Missing or incomplete metadata for type "${e.name}" at property "${o.toString()}".\nThis property must be decorated either with @inject or @multiInject decorator.`);if(0===t.length)throw new b(j.unknown,`Unexpected class metadata for type "${e.name}" with uncompletion traces.\nThis might be caused by one of the following reasons:\n\n1. A third party library is targeting inversify reflection metadata.\n2. A bug is causing the issue. Consider submiting an issue to fix it.`);throw new b(j.missingInjectionDecorator,`Invalid class metadata at type ${e.name}:\n\n${t.join("\n\n")}`)}(n,t)}function S(){return 0}function R(e){return t=>{void 0!==t&&t.kind===C.unknown&&n(e,M,S,(e=>e-1))}}function A(e,n){return(...t)=>o=>{if(void 0===o)return e(...t);if(o.kind===$.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found");return n(o,...t)}}function T(e){if(e.kind!==C.unknown&&!0!==e.isFromTypescriptParamType)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found")}!function(e){e[e.injectionDecoratorConflict=0]="injectionDecoratorConflict",e[e.missingInjectionDecorator=1]="missingInjectionDecorator",e[e.planning=2]="planning",e[e.resolution=3]="resolution",e[e.unknown=4]="unknown"}(j||(j={})),function(e){e[e.unknown=32]="unknown"}(C||(C={})),function(e){e[e.multipleInjection=0]="multipleInjection",e[e.singleInjection=1]="singleInjection",e[e.unmanaged=2]="unmanaged"}($||($={}));const D=A((function(e,n){return{kind:e,name:void 0,optional:!1,tags:new Map,value:n}}),(function(e,n,t){return T(e),{...e,kind:n,value:t}}));function k(e,n){return t=>{const o=t.properties.get(n);return t.properties.set(n,e(o)),t}}var B;function F(e,n,t,o){if(b.isErrorOfKind(o,j.injectionDecoratorConflict)){const i=function(e,n,t){if(void 0===t){if(void 0===n)throw new b(j.unknown,"Unexpected undefined property and index values");return{kind:B.property,property:n,targetClass:e.constructor}}return"number"==typeof t?{index:t,kind:B.parameter,targetClass:e}:{kind:B.method,method:n,targetClass:e}}(e,n,t);throw new b(j.injectionDecoratorConflict,`Unexpected injection error.\n\nCause:\n\n${o.message}\n\nDetails\n\n${function(e){switch(e.kind){case B.method:return`[class: "${e.targetClass.name}", method: "${e.method.toString()}"]`;case B.parameter:return`[class: "${e.targetClass.name}", index: "${e.index.toString()}"]`;case B.property:return`[class: "${e.targetClass.name}", property: "${e.property.toString()}"]`}}(i)}`,{cause:o})}throw o}function P(e,t){return(o,i,r)=>{try{void 0===r?function(e,t){const o=N(e,t);return(e,t)=>{n(e.constructor,y,w,k(o(e),t))}}(e,t)(o,i):"number"==typeof r?function(e,t){const o=N(e,t);return(e,t,i)=>{if(!function(e,n){return"function"==typeof e&&void 0===n}(e,t))throw new b(j.injectionDecoratorConflict,`Found an @inject decorator in a non constructor parameter.\nFound @inject decorator at method "${t?.toString()??""}" at class "${e.constructor.name}"`);n(e,y,w,function(e,n){return t=>{const o=t.constructorArguments[n];return t.constructorArguments[n]=e(o),t}}(o(e),i))}}(e,t)(o,i,r):function(e,t){const o=N(e,t);return(e,t,i)=>{if(!function(e){return void 0!==e.set}(i))throw new b(j.injectionDecoratorConflict,`Found an @inject decorator in a non setter property method.\nFound @inject decorator at method "${t.toString()}" at class "${e.constructor.name}"`);n(e.constructor,y,w,k(o(e),t))}}(e,t)(o,i,r)}catch(e){F(o,i,r,e)}}}function N(e,n){return t=>{const o=n(t);return n=>(o(n),e(n))}}function E(e){return P(D($.singleInjection,e),R)}!function(e){e[e.method=0]="method",e[e.parameter=1]="parameter",e[e.property=2]="property"}(B||(B={}));const O="@inversifyjs/core/classIsInjectableFlagReflectKey";const U=[Array,BigInt,Boolean,Function,Number,Object,String];function K(t){const o=e(t,"design:paramtypes");void 0!==o&&n(t,y,w,function(e){return n=>(e.forEach(((e,t)=>{var o;void 0!==n.constructorArguments[t]||(o=e,U.includes(o))||(n.constructorArguments[t]=function(e){return{isFromTypescriptParamType:!0,kind:$.singleInjection,name:void 0,optional:!1,tags:new Map,value:e}}(e))})),n)}(o))}function q(o){return i=>{!function(n){if(void 0!==e(n,O))throw new b(j.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class "${n.name}"`);t(n,O,!0)}(i),K(i),void 0!==o&&n(i,y,w,(e=>({...e,scope:o})))}}function V(e,n,t){let o;return e.extendConstructorArguments??!0?(o=[...n.constructorArguments],t.constructorArguments.map(((e,n)=>{o[n]=e}))):o=t.constructorArguments,o}function G(e,n,t){let o;return o=e.extendProperties??!0?new Map(u(n.properties,t.properties)):t.properties,o}function z(e){return t=>{const o=x(e.type);n(t,y,w,function(e,n){const t=t=>({constructorArguments:V(e,n,t),lifecycle:t.lifecycle,properties:G(e,n,t),scope:t.scope});return t}(e,o))}}function H(e){return n=>{const t=o(n);if(void 0===t)throw new b(j.injectionDecoratorConflict,`Expected base type for type "${n.name}", none found.`);z({...e,type:t})(n)}}function J(e){return P(D($.multipleInjection,e),R)}function L(e){return t=>{void 0===t&&n(e,M,S,(e=>e+1))}}function Q(e){return n=>{const t=n??{kind:C.unknown,name:void 0,optional:!1,tags:new Map};if(t.kind===$.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return e(t)}}function W(e){const n=Q(function(e){return n=>{if(void 0!==n.name)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated named decorator");return n.name=e,n}}(e));return P(n,L)}function X(e){if(e.optional)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated optional decorator");return e.optional=!0,e}function Y(){return P(Q(X),L)}function Z(){return(e,t,o)=>{try{n(e.constructor,y,w,(i=t,e=>{if(void 0!==e.lifecycle.postConstructMethodName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated postConstruct decorator");return e.lifecycle.postConstructMethodName=i,e}))}catch(n){F(e,t,void 0,n)}var i}}function _(){return(e,t,o)=>{try{n(e.constructor,y,w,(i=t,e=>{if(void 0!==e.lifecycle.preDestroyMethodName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated preDestroy decorator");return e.lifecycle.preDestroyMethodName=i,e}))}catch(n){F(e,t,void 0,n)}var i}}function ee(e,n){const t=Q(function(e,n){return t=>{if(t.tags.has(e))throw new b(j.injectionDecoratorConflict,"Unexpected duplicated tag decorator with existing tag");return t.tags.set(e,n),t}}(e,n));return P(t,L)}function ne(){return{kind:$.unmanaged}}const te=A(ne,(function(e){if(T(e),function(e){return void 0!==e.name||e.optional||e.tags.size>0}(e))throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return ne()}));function oe(){return P(te(),R)}class ie{#f;constructor(e){this.#f=e}get name(){return this.#f.elem.name}get tags(){return this.#f.elem.tags}get serviceIdentifier(){return this.#f.elem.serviceIdentifier}getAncestor(){if(void 0!==this.#f.previous)return new ie(this.#f.previous)}}class re{last;constructor(e){this.last=e}concat(e){return new re({elem:e,previous:this.last})}[Symbol.iterator](){let e=this.last;return{next:()=>{if(void 0===e)return{done:!0,value:void 0};const n=e.elem;return e=e.previous,{done:!1,value:n}}}}}function se(e,n){e.servicesBranch.has(n)&&function(e,n){const t=(o=[...e.servicesBranch,n],[...o].map(i).join(" -> "));var o;throw new b(j.planning,`Circular dependency found: ${t}`)}(e,n),e.servicesBranch.add(n)}function ce(e,n,t){const o=t?.customServiceIdentifier??n.serviceIdentifier;return[...e.getBindings(o)??[]].filter((e=>e.isSatisfiedBy(n)))}function ae(e){return void 0!==e.redirections}function ue(e,n,t,o){let r,s;ae(t)?(r=t.binding.targetServiceIdentifier,s=t.binding.serviceIdentifier):(r=t.serviceIdentifier,s=t.parent?.binding.serviceIdentifier),Array.isArray(e)?function(e,n,t,o,r){if(0!==e.length){const n=`Ambiguous bindings found for service: "${i(t)}".\n\nRegistered bindings:\n\n${e.map((e=>function(e){switch(e.type){case a.Instance:return`[ type: "${e.type}", serviceIdentifier: "${i(e.serviceIdentifier)}", scope: "${e.scope}", implementationType: "${e.implementationType.name}" ]`;case a.ServiceRedirection:return`[ type: "${e.type}", serviceIdentifier: "${i(e.serviceIdentifier)}", redirection: "${i(e.targetServiceIdentifier)}" ]`;default:return`[ type: "${e.type}", serviceIdentifier: "${i(e.serviceIdentifier)}", scope: "${e.scope}" ]`}}(e.binding))).join("\n")}\n\nTrying to resolve bindings for "${le(t,o)}".\n\n${fe(r)}`;throw new b(j.planning,n)}n||de(t,o,r)}(e,n,r,s,o):function(e,n,t,o,i){if(void 0!==e||n)return;de(t,o,i)}(e,n,r,s,o)}function de(e,n,t){const o=`No bindings found for service: "${i(e)}".\n\nTrying to resolve bindings for "${le(e,n)}".\n\n${fe(t)}`;throw new b(j.planning,o)}function le(e,n){return void 0===n?`${i(e)} (Root service)`:i(n)}function fe(e){const n=0===e.tags.size?"":`\n- tags:\n - ${[...e.tags.keys()].map((e=>e.toString())).join("\n - ")}`;return`Binding metadata:\n- service identifier: ${i(e.serviceIdentifier)}\n- name: ${e.name?.toString()??"-"}${n}`}function pe(e,n,t){if(1!==e.redirections.length)ue(e.redirections,n,e,t);else{const[o]=e.redirections;ae(o)&&pe(o,n,t)}}function me(e,n,t){if(Array.isArray(e.bindings)&&1===e.bindings.length){const[o]=e.bindings;ae(o)&&pe(o,n,t)}else ue(e.bindings,n,e,t)}function ge(e){const n=new Map;void 0!==e.rootConstraints.tag&&n.set(e.rootConstraints.tag.key,e.rootConstraints.tag.value);const t=new re({elem:{name:e.rootConstraints.name,serviceIdentifier:e.rootConstraints.serviceIdentifier,tags:n},previous:void 0}),o=new ie(t.last),i=ce(e,o),r=[],s={bindings:r,parent:void 0,serviceIdentifier:e.rootConstraints.serviceIdentifier};if(r.push(...ye(e,t,i,s)),!e.rootConstraints.isMultiple){me(s,e.rootConstraints.isOptional??!1,o);const[n]=r;s.bindings=n}return{tree:{root:s}}}function he(e,n,t,o){const i={binding:n,classMetadata:e.getClassMetadata(n.implementationType),constructorParams:[],parent:o,propertyParams:new Map};return function(e,n){const t=e.node.classMetadata;for(const[o,i]of t.constructorArguments.entries())e.node.constructorParams[o]=ve(e,n,i);for(const[o,i]of t.properties){const t=ve(e,n,i);void 0!==t&&e.node.propertyParams.set(o,t)}return e.node}({getBindings:e.getBindings,getClassMetadata:e.getClassMetadata,node:i,servicesBranch:e.servicesBranch},t)}function ve(e,n,t){if(t.kind===$.unmanaged)return;const o=r.is(t.value)?t.value.unwrap():t.value,i=n.concat({name:t.name,serviceIdentifier:o,tags:t.tags}),s=new ie(i.last),c=ce(e,s),a=[],u={bindings:a,parent:e.node,serviceIdentifier:o};if(a.push(...ye(e,i,c,u)),t.kind===$.singleInjection){me(u,t.optional,s);const[e]=a;u.bindings=e}return u}function ye(e,n,t,o){const i=ae(o)?o.binding.targetServiceIdentifier:o.serviceIdentifier;se(e,i);const r=[];for(const i of t)switch(i.type){case a.Instance:r.push(he(e,i,n,o));break;case a.ServiceRedirection:{const t=we(e,n,i,o);r.push(t);break}default:r.push({binding:i,parent:o})}return e.servicesBranch.delete(i),r}function we(e,n,t,o){const i={binding:t,parent:o,redirections:[]},r=ce(e,new ie(n.last),{customServiceIdentifier:t.targetServiceIdentifier});return i.redirections.push(...ye(e,n,r,i)),i}function Me(e,n,t){const o=e.getActivations(n);return void 0===o?t:s(t)?Ie(e,t,o[Symbol.iterator]()):function(e,n,t){let o=n,i=t.next();for(;!0!==i.done;){const n=i.value(e.context,o);if(s(n))return Ie(e,n,t);o=n,i=t.next()}return o}(e,t,o[Symbol.iterator]())}async function Ie(e,n,t){let o=await n,i=t.next();for(;!0!==i.done;)o=await i.value(e.context,o),i=t.next();return o}function be(e,n,t){let o=t;if(void 0!==n.onActivation){const t=n.onActivation;o=s(o)?o.then((n=>t(e.context,n))):t(e.context,o)}return Me(e,n.serviceIdentifier,o)}function je(e){return(n,t)=>{if(t.cache.isRight)return t.cache.value;const o=be(n,t,e(n,t));return t.cache={isRight:!0,value:o},o}}const Ce=je((function(e,n){return n.value}));function $e(e){return e}function xe(e,n){return(t,o)=>{const i=e(o);switch(i.scope){case c.Singleton:{if(i.cache.isRight)return i.cache.value;const e=Se(t,o,i,n);return i.cache={isRight:!0,value:e},e}case c.Request:{if(t.requestScopeCache.has(i.id))return t.requestScopeCache.get(i.id);const e=Se(t,o,i,n);return t.requestScopeCache.set(i.id,e),e}case c.Transient:return Se(t,o,i,n)}}}function Se(e,n,t,o){return be(e,t,o(e,n))}const Re=(e=>xe($e,e))((function(e,n){return n.value(e.context)}));const Ae=je((function(e,n){return n.factory(e.context)}));function Te(e,n,t){const o=function(e,n,t){if(void 0===t)return;if(!(t in e))throw new b(j.resolution,`Expecting a "${t.toString()}" property when resolving "${n.implementationType.name}" class @postConstruct decorated method, none found.`);if("function"!=typeof e[t])throw new b(j.resolution,`Expecting a "${t.toString()}" method when resolving "${n.implementationType.name}" class @postConstruct decorated method, a non function property was found instead.`);{let o;try{o=e[t]()}catch(e){throw new b(j.resolution,`Unexpected error found when calling "${t.toString()}" @postConstruct decorated method on class "${n.implementationType.name}"`,{cause:e})}if(s(o))return async function(e,n,t){try{await t}catch(t){throw new b(j.resolution,`Unexpected error found when calling "${n.toString()}" @postConstruct decorated method on class "${e.implementationType.name}"`,{cause:t})}}(n,t,o)}}(e,n,t);return s(o)?o.then((()=>e)):e}function De(e){return(n,t,o)=>{const i=new o.binding.implementationType(...n),r=e(t,i,o);return s(r)?r.then((()=>Te(i,o.binding,o.classMetadata.lifecycle.postConstructMethodName))):Te(i,o.binding,o.classMetadata.lifecycle.postConstructMethodName)}}const ke=je((function(e,n){return n.provider(e.context)}));function Be(e){return e.binding}const Fe=function(e){return(n,t,o)=>{const i=[];for(const[r,c]of o.propertyParams){const a=o.classMetadata.properties.get(r);if(void 0===a)throw new b(j.resolution,`Expecting metadata at property "${r.toString()}", none found`);a.kind!==$.unmanaged&&void 0!==c.bindings&&(t[r]=e(n,c),s(t[r])&&i.push((async()=>{t[r]=await t[r]})()))}if(i.length>0)return Promise.all(i).then((()=>{}))}}(Ke),Pe=function(e){return function n(t,o){const i=[];for(const r of o.redirections)ae(r)?i.push(...n(t,r)):i.push(e(t,r));return i}}(Ue),Ne=function(e,n,t){return(o,i)=>{const r=e(o,i);return s(r)?n(r,o,i):t(r,o,i)}}(function(e){return(n,t)=>{const o=[];for(const i of t.constructorParams)void 0===i?o.push(void 0):o.push(e(n,i));return o.some(s)?Promise.all(o):o}}(Ke),function(e){return async(n,t,o)=>{const i=await n;return e(i,t,o)}}(De(Fe)),De(Fe)),Ee=(e=>xe(Be,e))(Ne);function Oe(e){return Ke(e,e.planResult.tree.root)}function Ue(e,n){switch(n.binding.type){case a.ConstantValue:return Ce(e,n.binding);case a.DynamicValue:return Re(e,n.binding);case a.Factory:return Ae(e,n.binding);case a.Instance:return Ee(e,n);case a.Provider:return ke(e,n.binding)}}function Ke(e,n){if(void 0!==n.bindings)return Array.isArray(n.bindings)?function(e,n){const t=[];for(const o of n)ae(o)?t.push(...Pe(e,o)):t.push(Ue(e,o));if(t.some(s))return Promise.all(t);return t}(e,n.bindings):function(e,n){if(ae(n)){const t=Pe(e,n);if(1===t.length)return t[0];throw new b(j.resolution,"Unexpected multiple resolved values on single injection")}return Ue(e,n)}(e,n.bindings)}function qe(e){return void 0!==e.scope}function Ve(e,n){if(void 0!==e.lifecycle.preDestroyMethodName&&"function"==typeof n[e.lifecycle.preDestroyMethodName])return n[e.lifecycle.preDestroyMethodName]()}function Ge(e,n,t){const o=e.getDeactivations(n);if(void 0!==o)return s(t)?ze(t,o[Symbol.iterator]()):function(e,n){let t=n.next();for(;!0!==t.done;){const o=t.value(e);if(s(o))return ze(e,n);t=n.next()}}(t,o[Symbol.iterator]())}async function ze(e,n){const t=await e;let o=n.next();for(;!0!==o.done;)await o.value(t),o=n.next()}function He(e,n){const t=function(e,n){if(n.type===a.Instance){const t=e.getClassMetadata(n.implementationType),o=n.cache.value;return s(o)?o.then((e=>Ve(t,e))):Ve(t,o)}}(e,n);return void 0===t?Je(e,n):t.then((()=>Je(e,n)))}function Je(e,n){const t=n.cache;return s(t.value)?t.value.then((t=>Le(e,n,t))):Le(e,n,t.value)}function Le(e,n,t){let o;if(void 0!==n.onDeactivation){o=(0,n.onDeactivation)(t)}return void 0===o?Ge(e,n.serviceIdentifier,t):o.then((()=>Ge(e,n.serviceIdentifier,t)))}function Qe(e,n){if(void 0===n)return;const t=function(e){const n=[];for(const t of e)qe(t)&&t.scope===c.Singleton&&t.cache.isRight&&n.push(t);return n}(n),o=[];for(const n of t){const t=He(e,n);void 0!==t&&o.push(t)}return o.length>0?Promise.all(o).then((()=>{})):void 0}function We(e,n){const t=e.getBindingsFromModule(n);return Qe(e,t)}function Xe(e,n){const t=e.getBindings(n);return Qe(e,t)}export{m as ActivationsService,g as BindingService,$ as ClassElementMetadataKind,h as DeactivationsService,c as bindingScopeValues,a as bindingTypeValues,v as decorate,x as getClassMetadata,E as inject,H as injectFromBase,q as injectable,J as multiInject,W as named,Y as optional,ge as plan,Z as postConstruct,_ as preDestroy,Oe as resolve,We as resolveModuleDeactivations,Xe as resolveServiceDeactivations,ee as tagged,oe as unmanaged};
import{getOwnReflectMetadata as n,updateOwnReflectMetadata as e,setReflectMetadata as t}from"@inversifyjs/reflect-metadata-utils";import{getBaseType as o}from"@inversifyjs/prototype-utils";import{stringifyServiceIdentifier as i,LazyServiceIdentifier as r,isPromise as s}from"@inversifyjs/common";const c={Request:"Request",Singleton:"Singleton",Transient:"Transient"},a={ConstantValue:"ConstantValue",DynamicValue:"DynamicValue",Factory:"Factory",Instance:"Instance",Provider:"Provider",ServiceRedirection:"ServiceRedirection"};function*u(...n){for(const e of n)yield*e}class d{#n;#e;#t;constructor(n){this.#n=new Map,this.#e={};for(const e of Reflect.ownKeys(n))this.#e[e]=new Map;this.#t=n}add(n,e){this.#o(n).push(e);for(const t of Reflect.ownKeys(e))this.#i(t,e[t]).push(n)}clone(){const n=Reflect.ownKeys(this.#t),e=new d(this.#t);this.#r(this.#n,e.#n);for(const t of n)this.#r(this.#e[t],e.#e[t]);return e}get(n,e){return this.#e[n].get(e)}getAllKeys(n){return this.#e[n].keys()}removeByRelation(n,e){const t=this.get(n,e);if(void 0===t)return;const o=new Set(t);for(const t of o){const o=this.#n.get(t);if(void 0===o)throw new Error("Expecting model relation, none found");for(const i of o)i[n]===e&&this.#s(t,i);this.#n.delete(t)}}#o(n){let e=this.#n.get(n);return void 0===e&&(e=[],this.#n.set(n,e)),e}#i(n,e){let t=this.#e[n].get(e);return void 0===t&&(t=[],this.#e[n].set(e,t)),t}#r(n,e){for(const[t,o]of n)e.set(t,[...o])}#s(n,e){for(const t of Reflect.ownKeys(e))this.#c(n,t,e[t])}#c(n,e,t){const o=this.#e[e].get(t);if(void 0!==o){const i=o.indexOf(n);-1!==i&&o.splice(i,1),0===o.length&&this.#e[e].delete(t)}}}var l,f,p;!function(n){n.moduleId="moduleId",n.serviceId="serviceId"}(l||(l={}));class m{#a;#u;constructor(n,e){this.#a=e??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#u=n}static build(n){return new m(n)}add(n,e){this.#a.add(n,e)}clone(){return new m(this.#u,this.#a.clone())}get(n){const e=[],t=this.#a.get(l.serviceId,n);void 0!==t&&e.push(t);const o=this.#u?.get(n);if(void 0!==o&&e.push(o),0!==e.length)return u(...e)}removeAllByModuleId(n){this.#a.removeByRelation(l.moduleId,n)}removeAllByServiceId(n){this.#a.removeByRelation(l.serviceId,n)}}!function(n){n.moduleId="moduleId",n.serviceId="serviceId"}(f||(f={}));class g{#d;#u;constructor(n,e){this.#d=e??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#u=n}static build(n){return new g(n)}clone(){return new g(this.#u,this.#d.clone())}get(n){return this.getNonParentBindings(n)??this.#u?.get(n)}getNonParentBindings(n){return this.#d.get(f.serviceId,n)}getNonParentBoundServices(){return this.#d.getAllKeys(f.serviceId)}getByModuleId(n){return this.#d.get(f.moduleId,n)??this.#u?.getByModuleId(n)}removeAllByModuleId(n){this.#d.removeByRelation(f.moduleId,n)}removeAllByServiceId(n){this.#d.removeByRelation(f.serviceId,n)}set(n){const e={[f.serviceId]:n.serviceIdentifier};void 0!==n.moduleId&&(e[f.moduleId]=n.moduleId),this.#d.add(n,e)}}!function(n){n.moduleId="moduleId",n.serviceId="serviceId"}(p||(p={}));class h{#l;#u;constructor(n,e){this.#l=e??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#u=n}static build(n){return new h(n)}add(n,e){this.#l.add(n,e)}clone(){return new h(this.#u,this.#l.clone())}get(n){const e=[],t=this.#l.get(p.serviceId,n);void 0!==t&&e.push(t);const o=this.#u?.get(n);if(void 0!==o&&e.push(o),0!==e.length)return u(...e)}removeAllByModuleId(n){this.#l.removeByRelation(p.moduleId,n)}removeAllByServiceId(n){this.#l.removeByRelation(p.serviceId,n)}}function v(n,e,t){const o=Array.isArray(n)?n:[n];if(void 0!==t)if("number"!=typeof t)Reflect.decorate(o,e.prototype,t);else for(const n of o)n(e,void 0,t);else Reflect.decorate(o,e)}const y="@inversifyjs/core/classMetadataReflectKey";function w(){return{constructorArguments:[],lifecycle:{postConstructMethodName:void 0,preDestroyMethodName:void 0},properties:new Map,scope:void 0}}const M="@inversifyjs/core/pendingClassMetadataCountReflectKey";const I=Symbol.for("@inversifyjs/core/InversifyCoreError");class b extends Error{[I];kind;constructor(n,e,t){super(e,t),this[I]=!0,this.kind=n}static is(n){return"object"==typeof n&&null!==n&&!0===n[I]}static isErrorOfKind(n,e){return b.is(n)&&n.kind===e}}var j,C,$;function x(e){const t=n(e,y)??w();if(!function(e){const t=n(e,M);return void 0!==t&&0!==t}(e))return function(n,e){const t=[];if(e.length<n.length)throw new b(j.missingInjectionDecorator,`Found unexpected missing metadata on type "${n.name}". "${n.name}" constructor requires at least ${n.length.toString()} arguments, found ${e.length.toString()} instead.\nAre you using @inject, @multiInject or @unmanaged decorators in every non optional constructor argument?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`);for(let n=0;n<e.length;++n)void 0===e[n]&&t.push(n);if(t.length>0)throw new b(j.missingInjectionDecorator,`Found unexpected missing metadata on type "${n.name}" at constructor indexes "${t.join('", "')}".\n\nAre you using @inject, @multiInject or @unmanaged decorators at those indexes?\n\nIf you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`)}(e,t.constructorArguments),t;!function(n,e){const t=[];for(let o=0;o<e.constructorArguments.length;++o){const i=e.constructorArguments[o];void 0!==i&&i.kind!==C.unknown||t.push(` - Missing or incomplete metadata for type "${n.name}" at constructor argument with index ${o.toString()}.\nEvery constructor parameter must be decorated either with @inject, @multiInject or @unmanaged decorator.`)}for(const[o,i]of e.properties)i.kind===C.unknown&&t.push(` - Missing or incomplete metadata for type "${n.name}" at property "${o.toString()}".\nThis property must be decorated either with @inject or @multiInject decorator.`);if(0===t.length)throw new b(j.unknown,`Unexpected class metadata for type "${n.name}" with uncompletion traces.\nThis might be caused by one of the following reasons:\n\n1. A third party library is targeting inversify reflection metadata.\n2. A bug is causing the issue. Consider submiting an issue to fix it.`);throw new b(j.missingInjectionDecorator,`Invalid class metadata at type ${n.name}:\n\n${t.join("\n\n")}`)}(e,t)}function S(){return 0}function R(n){return t=>{void 0!==t&&t.kind===C.unknown&&e(n,M,S,(n=>n-1))}}function A(n,e){return(...t)=>o=>{if(void 0===o)return n(...t);if(o.kind===$.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found");return e(o,...t)}}function T(n){if(n.kind!==C.unknown&&!0!==n.isFromTypescriptParamType)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found")}!function(n){n[n.injectionDecoratorConflict=0]="injectionDecoratorConflict",n[n.missingInjectionDecorator=1]="missingInjectionDecorator",n[n.planning=2]="planning",n[n.resolution=3]="resolution",n[n.unknown=4]="unknown"}(j||(j={})),function(n){n[n.unknown=32]="unknown"}(C||(C={})),function(n){n[n.multipleInjection=0]="multipleInjection",n[n.singleInjection=1]="singleInjection",n[n.unmanaged=2]="unmanaged"}($||($={}));const D=A((function(n,e){return{kind:n,name:void 0,optional:!1,tags:new Map,value:e}}),(function(n,e,t){return T(n),{...n,kind:e,value:t}}));function k(n,e){return t=>{const o=t.properties.get(e);return t.properties.set(e,n(o)),t}}var B;function F(n,e,t,o){if(b.isErrorOfKind(o,j.injectionDecoratorConflict)){const i=function(n,e,t){if(void 0===t){if(void 0===e)throw new b(j.unknown,"Unexpected undefined property and index values");return{kind:B.property,property:e,targetClass:n.constructor}}return"number"==typeof t?{index:t,kind:B.parameter,targetClass:n}:{kind:B.method,method:e,targetClass:n}}(n,e,t);throw new b(j.injectionDecoratorConflict,`Unexpected injection error.\n\nCause:\n\n${o.message}\n\nDetails\n\n${function(n){switch(n.kind){case B.method:return`[class: "${n.targetClass.name}", method: "${n.method.toString()}"]`;case B.parameter:return`[class: "${n.targetClass.name}", index: "${n.index.toString()}"]`;case B.property:return`[class: "${n.targetClass.name}", property: "${n.property.toString()}"]`}}(i)}`,{cause:o})}throw o}function O(n,t){return(o,i,r)=>{try{void 0===r?function(n,t){const o=P(n,t);return(n,t)=>{e(n.constructor,y,w,k(o(n),t))}}(n,t)(o,i):"number"==typeof r?function(n,t){const o=P(n,t);return(n,t,i)=>{if(!function(n,e){return"function"==typeof n&&void 0===e}(n,t))throw new b(j.injectionDecoratorConflict,`Found an @inject decorator in a non constructor parameter.\nFound @inject decorator at method "${t?.toString()??""}" at class "${n.constructor.name}"`);e(n,y,w,function(n,e){return t=>{const o=t.constructorArguments[e];return t.constructorArguments[e]=n(o),t}}(o(n),i))}}(n,t)(o,i,r):function(n,t){const o=P(n,t);return(n,t,i)=>{if(!function(n){return void 0!==n.set}(i))throw new b(j.injectionDecoratorConflict,`Found an @inject decorator in a non setter property method.\nFound @inject decorator at method "${t.toString()}" at class "${n.constructor.name}"`);e(n.constructor,y,w,k(o(n),t))}}(n,t)(o,i,r)}catch(n){F(o,i,r,n)}}}function P(n,e){return t=>{const o=e(t);return e=>(o(e),n(e))}}function N(n){return O(D($.singleInjection,n),R)}!function(n){n[n.method=0]="method",n[n.parameter=1]="parameter",n[n.property=2]="property"}(B||(B={}));const E="@inversifyjs/core/classIsInjectableFlagReflectKey";const U=[Array,BigInt,Boolean,Function,Number,Object,String];function K(t){const o=n(t,"design:paramtypes");void 0!==o&&e(t,y,w,function(n){return e=>(n.forEach(((n,t)=>{var o;void 0!==e.constructorArguments[t]||(o=n,U.includes(o))||(e.constructorArguments[t]=function(n){return{isFromTypescriptParamType:!0,kind:$.singleInjection,name:void 0,optional:!1,tags:new Map,value:n}}(n))})),e)}(o))}function q(o){return i=>{!function(e){if(void 0!==n(e,E))throw new b(j.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class "${e.name}"`);t(e,E,!0)}(i),K(i),void 0!==o&&e(i,y,w,(n=>({...n,scope:o})))}}function V(n,e,t){let o;return n.extendConstructorArguments??!0?(o=[...e.constructorArguments],t.constructorArguments.map(((n,e)=>{o[e]=n}))):o=t.constructorArguments,o}function G(n,e,t){let o;return o=n.extendProperties??!0?new Map(u(e.properties,t.properties)):t.properties,o}function z(n){return t=>{const o=x(n.type);e(t,y,w,function(n,e){const t=t=>({constructorArguments:V(n,e,t),lifecycle:t.lifecycle,properties:G(n,e,t),scope:t.scope});return t}(n,o))}}function H(n){return e=>{const t=o(e);if(void 0===t)throw new b(j.injectionDecoratorConflict,`Expected base type for type "${e.name}", none found.`);z({...n,type:t})(e)}}function J(n){return O(D($.multipleInjection,n),R)}function L(n){return t=>{void 0===t&&e(n,M,S,(n=>n+1))}}function Q(n){return e=>{const t=e??{kind:C.unknown,name:void 0,optional:!1,tags:new Map};if(t.kind===$.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return n(t)}}function W(n){const e=Q(function(n){return e=>{if(void 0!==e.name)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated named decorator");return e.name=n,e}}(n));return O(e,L)}function X(n){if(n.optional)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated optional decorator");return n.optional=!0,n}function Y(){return O(Q(X),L)}function Z(){return(n,t,o)=>{try{e(n.constructor,y,w,(i=t,n=>{if(void 0!==n.lifecycle.postConstructMethodName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated postConstruct decorator");return n.lifecycle.postConstructMethodName=i,n}))}catch(e){F(n,t,void 0,e)}var i}}function _(){return(n,t,o)=>{try{e(n.constructor,y,w,(i=t,n=>{if(void 0!==n.lifecycle.preDestroyMethodName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated preDestroy decorator");return n.lifecycle.preDestroyMethodName=i,n}))}catch(e){F(n,t,void 0,e)}var i}}function nn(n,e){const t=Q(function(n,e){return t=>{if(t.tags.has(n))throw new b(j.injectionDecoratorConflict,"Unexpected duplicated tag decorator with existing tag");return t.tags.set(n,e),t}}(n,e));return O(t,L)}function en(){return{kind:$.unmanaged}}const tn=A(en,(function(n){if(T(n),function(n){return void 0!==n.name||n.optional||n.tags.size>0}(n))throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return en()}));function on(){return O(tn(),R)}class rn{#f;constructor(n){this.#f=n}get name(){return this.#f.elem.name}get tags(){return this.#f.elem.tags}get serviceIdentifier(){return this.#f.elem.serviceIdentifier}getAncestor(){if(void 0!==this.#f.previous)return new rn(this.#f.previous)}}class sn{last;constructor(n){this.last=n}concat(n){return new sn({elem:n,previous:this.last})}[Symbol.iterator](){let n=this.last;return{next:()=>{if(void 0===n)return{done:!0,value:void 0};const e=n.elem;return n=n.previous,{done:!1,value:e}}}}}function cn(n,e){n.servicesBranch.has(e)&&function(n,e){const t=(o=[...n.servicesBranch,e],[...o].map(i).join(" -> "));var o;throw new b(j.planning,`Circular dependency found: ${t}`)}(n,e),n.servicesBranch.add(e)}function an(n,e,t){const o=t?.customServiceIdentifier??e.serviceIdentifier,i=[...n.getBindings(o)??[]].filter((n=>n.isSatisfiedBy(e)));if(0===i.length&&void 0!==n.autobindOptions&&"function"==typeof o){const e=function(n,e){return{cache:{isRight:!1,value:void 0},id:0,implementationType:e,isSatisfiedBy:()=>!0,moduleId:void 0,onActivation:void 0,onDeactivation:void 0,scope:n.scope,serviceIdentifier:e,type:a.Instance}}(n.autobindOptions,o);n.setBinding(e),i.push(e)}return i}function un(n){return void 0!==n.redirections}function dn(n,e,t,o){let r,s;un(t)?(r=t.binding.targetServiceIdentifier,s=t.binding.serviceIdentifier):(r=t.serviceIdentifier,s=t.parent?.binding.serviceIdentifier),Array.isArray(n)?function(n,e,t,o,r){if(0!==n.length){const e=`Ambiguous bindings found for service: "${i(t)}".\n\nRegistered bindings:\n\n${n.map((n=>function(n){switch(n.type){case a.Instance:return`[ type: "${n.type}", serviceIdentifier: "${i(n.serviceIdentifier)}", scope: "${n.scope}", implementationType: "${n.implementationType.name}" ]`;case a.ServiceRedirection:return`[ type: "${n.type}", serviceIdentifier: "${i(n.serviceIdentifier)}", redirection: "${i(n.targetServiceIdentifier)}" ]`;default:return`[ type: "${n.type}", serviceIdentifier: "${i(n.serviceIdentifier)}", scope: "${n.scope}" ]`}}(n.binding))).join("\n")}\n\nTrying to resolve bindings for "${fn(t,o)}".\n\n${pn(r)}`;throw new b(j.planning,e)}e||ln(t,o,r)}(n,e,r,s,o):function(n,e,t,o,i){if(void 0!==n||e)return;ln(t,o,i)}(n,e,r,s,o)}function ln(n,e,t){const o=`No bindings found for service: "${i(n)}".\n\nTrying to resolve bindings for "${fn(n,e)}".\n\n${pn(t)}`;throw new b(j.planning,o)}function fn(n,e){return void 0===e?`${i(n)} (Root service)`:i(e)}function pn(n){const e=0===n.tags.size?"":`\n- tags:\n - ${[...n.tags.keys()].map((n=>n.toString())).join("\n - ")}`;return`Binding metadata:\n- service identifier: ${i(n.serviceIdentifier)}\n- name: ${n.name?.toString()??"-"}${e}`}function mn(n,e,t){if(1!==n.redirections.length)dn(n.redirections,e,n,t);else{const[o]=n.redirections;un(o)&&mn(o,e,t)}}function gn(n,e,t){if(Array.isArray(n.bindings)&&1===n.bindings.length){const[o]=n.bindings;un(o)&&mn(o,e,t)}else dn(n.bindings,e,n,t)}function hn(n){const e=new Map;void 0!==n.rootConstraints.tag&&e.set(n.rootConstraints.tag.key,n.rootConstraints.tag.value);const t=new sn({elem:{name:n.rootConstraints.name,serviceIdentifier:n.rootConstraints.serviceIdentifier,tags:e},previous:void 0}),o=new rn(t.last),i=an(n,o),r=[],s={bindings:r,parent:void 0,serviceIdentifier:n.rootConstraints.serviceIdentifier};if(r.push(...wn(n,t,i,s)),!n.rootConstraints.isMultiple){gn(s,n.rootConstraints.isOptional??!1,o);const[e]=r;s.bindings=e}return{tree:{root:s}}}function vn(n,e,t,o){const i={binding:e,classMetadata:n.getClassMetadata(e.implementationType),constructorParams:[],parent:o,propertyParams:new Map};return function(n,e){const t=n.node.classMetadata;for(const[o,i]of t.constructorArguments.entries())n.node.constructorParams[o]=yn(n,e,i);for(const[o,i]of t.properties){const t=yn(n,e,i);void 0!==t&&n.node.propertyParams.set(o,t)}return n.node}({autobindOptions:n.autobindOptions,getBindings:n.getBindings,getClassMetadata:n.getClassMetadata,node:i,servicesBranch:n.servicesBranch,setBinding:n.setBinding},t)}function yn(n,e,t){if(t.kind===$.unmanaged)return;const o=r.is(t.value)?t.value.unwrap():t.value,i=e.concat({name:t.name,serviceIdentifier:o,tags:t.tags}),s=new rn(i.last),c=an(n,s),a=[],u={bindings:a,parent:n.node,serviceIdentifier:o};if(a.push(...wn(n,i,c,u)),t.kind===$.singleInjection){gn(u,t.optional,s);const[n]=a;u.bindings=n}return u}function wn(n,e,t,o){const i=un(o)?o.binding.targetServiceIdentifier:o.serviceIdentifier;cn(n,i);const r=[];for(const i of t)switch(i.type){case a.Instance:r.push(vn(n,i,e,o));break;case a.ServiceRedirection:{const t=Mn(n,e,i,o);r.push(t);break}default:r.push({binding:i,parent:o})}return n.servicesBranch.delete(i),r}function Mn(n,e,t,o){const i={binding:t,parent:o,redirections:[]},r=an(n,new rn(e.last),{customServiceIdentifier:t.targetServiceIdentifier});return i.redirections.push(...wn(n,e,r,i)),i}function In(n,e,t){const o=n.getActivations(e);return void 0===o?t:s(t)?bn(n,t,o[Symbol.iterator]()):function(n,e,t){let o=e,i=t.next();for(;!0!==i.done;){const e=i.value(n.context,o);if(s(e))return bn(n,e,t);o=e,i=t.next()}return o}(n,t,o[Symbol.iterator]())}async function bn(n,e,t){let o=await e,i=t.next();for(;!0!==i.done;)o=await i.value(n.context,o),i=t.next();return o}function jn(n,e,t){let o=t;if(void 0!==e.onActivation){const t=e.onActivation;o=s(o)?o.then((e=>t(n.context,e))):t(n.context,o)}return In(n,e.serviceIdentifier,o)}function Cn(n){return(e,t)=>{if(t.cache.isRight)return t.cache.value;const o=jn(e,t,n(e,t));return t.cache={isRight:!0,value:o},o}}const $n=Cn((function(n,e){return e.value}));function xn(n){return n}function Sn(n,e){return(t,o)=>{const i=n(o);switch(i.scope){case c.Singleton:{if(i.cache.isRight)return i.cache.value;const n=Rn(t,o,i,e);return i.cache={isRight:!0,value:n},n}case c.Request:{if(t.requestScopeCache.has(i.id))return t.requestScopeCache.get(i.id);const n=Rn(t,o,i,e);return t.requestScopeCache.set(i.id,n),n}case c.Transient:return Rn(t,o,i,e)}}}function Rn(n,e,t,o){return jn(n,t,o(n,e))}const An=(n=>Sn(xn,n))((function(n,e){return e.value(n.context)}));const Tn=Cn((function(n,e){return e.factory(n.context)}));function Dn(n,e,t){const o=function(n,e,t){if(void 0===t)return;if(!(t in n))throw new b(j.resolution,`Expecting a "${t.toString()}" property when resolving "${e.implementationType.name}" class @postConstruct decorated method, none found.`);if("function"!=typeof n[t])throw new b(j.resolution,`Expecting a "${t.toString()}" method when resolving "${e.implementationType.name}" class @postConstruct decorated method, a non function property was found instead.`);{let o;try{o=n[t]()}catch(n){throw new b(j.resolution,`Unexpected error found when calling "${t.toString()}" @postConstruct decorated method on class "${e.implementationType.name}"`,{cause:n})}if(s(o))return async function(n,e,t){try{await t}catch(t){throw new b(j.resolution,`Unexpected error found when calling "${e.toString()}" @postConstruct decorated method on class "${n.implementationType.name}"`,{cause:t})}}(e,t,o)}}(n,e,t);return s(o)?o.then((()=>n)):n}function kn(n){return(e,t,o)=>{const i=new o.binding.implementationType(...e),r=n(t,i,o);return s(r)?r.then((()=>Dn(i,o.binding,o.classMetadata.lifecycle.postConstructMethodName))):Dn(i,o.binding,o.classMetadata.lifecycle.postConstructMethodName)}}const Bn=Cn((function(n,e){return e.provider(n.context)}));function Fn(n){return n.binding}const On=function(n){return(e,t,o)=>{const i=[];for(const[r,c]of o.propertyParams){const a=o.classMetadata.properties.get(r);if(void 0===a)throw new b(j.resolution,`Expecting metadata at property "${r.toString()}", none found`);a.kind!==$.unmanaged&&void 0!==c.bindings&&(t[r]=n(e,c),s(t[r])&&i.push((async()=>{t[r]=await t[r]})()))}if(i.length>0)return Promise.all(i).then((()=>{}))}}(qn),Pn=function(n){return function e(t,o){const i=[];for(const r of o.redirections)un(r)?i.push(...e(t,r)):i.push(n(t,r));return i}}(Kn),Nn=function(n,e,t){return(o,i)=>{const r=n(o,i);return s(r)?e(r,o,i):t(r,o,i)}}(function(n){return(e,t)=>{const o=[];for(const i of t.constructorParams)void 0===i?o.push(void 0):o.push(n(e,i));return o.some(s)?Promise.all(o):o}}(qn),function(n){return async(e,t,o)=>{const i=await e;return n(i,t,o)}}(kn(On)),kn(On)),En=(n=>Sn(Fn,n))(Nn);function Un(n){return qn(n,n.planResult.tree.root)}function Kn(n,e){switch(e.binding.type){case a.ConstantValue:return $n(n,e.binding);case a.DynamicValue:return An(n,e.binding);case a.Factory:return Tn(n,e.binding);case a.Instance:return En(n,e);case a.Provider:return Bn(n,e.binding)}}function qn(n,e){if(void 0!==e.bindings)return Array.isArray(e.bindings)?function(n,e){const t=[];for(const o of e)un(o)?t.push(...Pn(n,o)):t.push(Kn(n,o));if(t.some(s))return Promise.all(t);return t}(n,e.bindings):function(n,e){if(un(e)){const t=Pn(n,e);if(1===t.length)return t[0];throw new b(j.resolution,"Unexpected multiple resolved values on single injection")}return Kn(n,e)}(n,e.bindings)}function Vn(n){return void 0!==n.scope}function Gn(n,e){if(void 0!==n.lifecycle.preDestroyMethodName&&"function"==typeof e[n.lifecycle.preDestroyMethodName])return e[n.lifecycle.preDestroyMethodName]()}function zn(n,e,t){const o=n.getDeactivations(e);if(void 0!==o)return s(t)?Hn(t,o[Symbol.iterator]()):function(n,e){let t=e.next();for(;!0!==t.done;){const o=t.value(n);if(s(o))return Hn(n,e);t=e.next()}}(t,o[Symbol.iterator]())}async function Hn(n,e){const t=await n;let o=e.next();for(;!0!==o.done;)await o.value(t),o=e.next()}function Jn(n,e){const t=function(n,e){if(e.type===a.Instance){const t=n.getClassMetadata(e.implementationType),o=e.cache.value;return s(o)?o.then((n=>Gn(t,n))):Gn(t,o)}}(n,e);return void 0===t?Ln(n,e):t.then((()=>Ln(n,e)))}function Ln(n,e){const t=e.cache;return s(t.value)?t.value.then((t=>Qn(n,e,t))):Qn(n,e,t.value)}function Qn(n,e,t){let o;if(void 0!==e.onDeactivation){o=(0,e.onDeactivation)(t)}return void 0===o?zn(n,e.serviceIdentifier,t):o.then((()=>zn(n,e.serviceIdentifier,t)))}function Wn(n,e){if(void 0===e)return;const t=function(n){const e=[];for(const t of n)Vn(t)&&t.scope===c.Singleton&&t.cache.isRight&&e.push(t);return e}(e),o=[];for(const e of t){const t=Jn(n,e);void 0!==t&&o.push(t)}return o.length>0?Promise.all(o).then((()=>{})):void 0}function Xn(n,e){const t=n.getBindingsFromModule(e);return Wn(n,t)}function Yn(n,e){const t=n.getBindings(e);return Wn(n,t)}export{m as ActivationsService,g as BindingService,$ as ClassElementMetadataKind,h as DeactivationsService,c as bindingScopeValues,a as bindingTypeValues,v as decorate,x as getClassMetadata,N as inject,H as injectFromBase,q as injectable,J as multiInject,W as named,Y as optional,hn as plan,Z as postConstruct,_ as preDestroy,Un as resolve,Xn as resolveModuleDeactivations,Yn as resolveServiceDeactivations,nn as tagged,on as unmanaged};
//# sourceMappingURL=index.js.map

@@ -8,8 +8,7 @@ {

"dependencies": {
"@inversifyjs/common": "1.5.0",
"@inversifyjs/prototype-utils": "0.1.0",
"@inversifyjs/reflect-metadata-utils": "1.1.0"
"@inversifyjs/reflect-metadata-utils": "1.1.0",
"@inversifyjs/common": "1.5.0"
},
"devDependencies": {
"@eslint/js": "9.18.0",
"@jest/globals": "29.7.0",

@@ -19,6 +18,4 @@ "@stryker-mutator/core": "8.7.1",

"@stryker-mutator/typescript-checker": "8.7.1",
"@types/node": "22.10.7",
"@typescript-eslint/eslint-plugin": "8.20.0",
"@typescript-eslint/parser": "8.20.0",
"eslint": "9.18.0",
"@types/node": "22.10.10",
"eslint": "9.19.0",
"jest": "29.7.0",

@@ -28,6 +25,5 @@ "prettier": "3.4.2",

"rimraf": "6.0.1",
"rollup": "4.30.1",
"rollup": "4.32.0",
"ts-loader": "9.5.2",
"ts-jest": "29.2.5",
"ts-node": "10.9.2",
"tslib": "2.8.1",

@@ -68,3 +64,3 @@ "typescript": "5.7.3"

},
"version": "3.2.0",
"version": "3.3.0",
"scripts": {

@@ -71,0 +67,0 @@ "build": "pnpm run build:cjs && pnpm run build:esm",

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