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 2.2.0 to 3.0.0

15

CHANGELOG.md
# @inversifyjs/core
## 3.0.0
### Major Changes
- 7f97e76: Removed `MetadataTargetName`
- 7f97e76: Updated `ManagedClassElementMetadata` with no `targetName`
- 7f97e76: Updated `MaybeManagedClassElementMetadata` with no `targetName`
- 7f97e76: Removed `targetName`
### Minor Changes
- 50fa92a: Updated `BindingService` with `getNonParentBindings`
- 6c381a8: Updated `BindingToSyntax` with more flexible factory and provider constraints
- bbddebc: Updated `Provider` with right args.
## 2.2.0

@@ -4,0 +19,0 @@

2

lib/cjs/binding/models/Provider.d.ts

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

export type Provider<TActivated, in TArgs extends unknown[] = any[]> = (...args: TArgs[]) => Promise<TActivated>;
export type Provider<TActivated, in TArgs extends unknown[] = any[]> = (...args: TArgs) => Promise<TActivated>;
//# sourceMappingURL=Provider.d.ts.map

@@ -18,2 +18,3 @@ import { ServiceIdentifier } from '@inversifyjs/common';

get<TResolved>(serviceIdentifier: ServiceIdentifier): Iterable<Binding<TResolved>> | undefined;
getNonParentBindings<TResolved>(serviceId: ServiceIdentifier): Iterable<Binding<TResolved>> | undefined;
getNonParentBoundServices(): Iterable<ServiceIdentifier>;

@@ -20,0 +21,0 @@ getByModuleId<TResolved>(moduleId: number): Iterable<Binding<TResolved>> | undefined;

@@ -34,5 +34,8 @@ "use strict";

get(serviceIdentifier) {
return (this.#bindingMaps.get(BindingRelationKind.serviceId, serviceIdentifier) ??
return (this.getNonParentBindings(serviceIdentifier) ??
this.#parent?.get(serviceIdentifier));
}
getNonParentBindings(serviceId) {
return this.#bindingMaps.get(BindingRelationKind.serviceId, serviceId);
}
getNonParentBoundServices() {

@@ -39,0 +42,0 @@ return this.#bindingMaps.getAllKeys(BindingRelationKind.serviceId);

@@ -1,4 +0,4 @@

export declare function decorate(decorators: ClassDecorator[], target: Function): void;
export declare function decorate(decorators: ParameterDecorator[], target: Function, parameterIndex: number): void;
export declare function decorate(decorators: MethodDecorator[] | PropertyDecorator[], target: Function, property: string | symbol): void;
export declare function decorate(decorators: ClassDecorator | ClassDecorator[], target: Function): void;
export declare function decorate(decorators: ParameterDecorator | ParameterDecorator[], target: Function, parameterIndex: number): void;
export declare function decorate(decorators: MethodDecorator | PropertyDecorator | MethodDecorator[] | PropertyDecorator[], target: Function, property: string | symbol): void;
//# sourceMappingURL=decorate.d.ts.map

@@ -5,5 +5,8 @@ "use strict";

function decorate(decorators, target, parameterIndexOrProperty) {
const parsedDecorators = Array.isArray(decorators)
? decorators
: [decorators];
if (parameterIndexOrProperty === undefined) {
// Asume ClassDecorator[]
Reflect.decorate(decorators, target);
Reflect.decorate(parsedDecorators, target);
return;

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

// Asume ParameterDecorator[]
for (const decorator of decorators) {
for (const decorator of parsedDecorators) {
decorator(target, undefined, parameterIndexOrProperty);

@@ -19,4 +22,4 @@ }

}
Reflect.decorate(decorators, target.prototype, parameterIndexOrProperty);
Reflect.decorate(parsedDecorators, target.prototype, parameterIndexOrProperty);
}
//# sourceMappingURL=decorate.js.map

@@ -32,3 +32,2 @@ import { BaseBinding } from './binding/models/BaseBinding';

import { tagged } from './metadata/decorators/tagged';
import { targetName } from './metadata/decorators/targetName';
import { unmanaged } from './metadata/decorators/unmanaged';

@@ -42,3 +41,2 @@ import { ClassElementMetadata } from './metadata/models/ClassElementMetadata';

import { MetadataTag } from './metadata/models/MetadataTag';
import { MetadataTargetName } from './metadata/models/MetadataTargetName';
import { UnmanagedClassElementMetadata } from './metadata/models/UnmanagedClassElementMetadata';

@@ -68,4 +66,4 @@ import { plan } from './planning/calculations/plan';

import { Resolved } from './resolution/models/Resolved';
export type { BaseBinding, BaseBindingNode, BasePlanParams, Binding, BindingActivation, BindingActivationRelation, BindingDeactivation, BindingDeactivationRelation, BindingMetadata, BindingScope, BindingType, ClassElementMetadata, ClassMetadata, ClassMetadataLifecycle, ConstantValueBinding, DeactivationParams, DynamicValueBinding, DynamicValueBuilder, Factory, FactoryBinding, GetOptions, GetOptionsTagConstraint, InstanceBinding, LeafBindingNode, ManagedClassElementMetadata, MetadataName, MetadataTag, MetadataTargetName, OptionalGetOptions, PlanBindingNode, PlanParams, PlanParamsConstraint, PlanParamsTagConstraint, PlanResult, PlanServiceNode, PlanServiceNodeParent, PlanServiceRedirectionBindingNode, PlanTree, Provider, ProviderBinding, ResolutionContext, ResolutionParams, Resolved, ScopedBinding, ServiceRedirectionBinding, UnmanagedClassElementMetadata, };
export { ActivationsService, bindingScopeValues, BindingService, bindingTypeValues, ClassElementMetadataKind, DeactivationsService, decorate, getClassMetadata, multiInject, inject, injectable, injectFromBase, named, optional, postConstruct, plan, preDestroy, resolve, resolveModuleDeactivations, resolveServiceDeactivations, tagged, targetName, unmanaged, };
export type { BaseBinding, BaseBindingNode, BasePlanParams, Binding, BindingActivation, BindingActivationRelation, BindingDeactivation, BindingDeactivationRelation, BindingMetadata, BindingScope, BindingType, ClassElementMetadata, ClassMetadata, ClassMetadataLifecycle, ConstantValueBinding, DeactivationParams, DynamicValueBinding, DynamicValueBuilder, Factory, FactoryBinding, GetOptions, GetOptionsTagConstraint, InstanceBinding, LeafBindingNode, ManagedClassElementMetadata, MetadataName, MetadataTag, OptionalGetOptions, PlanBindingNode, PlanParams, PlanParamsConstraint, PlanParamsTagConstraint, PlanResult, PlanServiceNode, PlanServiceNodeParent, PlanServiceRedirectionBindingNode, PlanTree, Provider, ProviderBinding, ResolutionContext, ResolutionParams, Resolved, ScopedBinding, ServiceRedirectionBinding, UnmanagedClassElementMetadata, };
export { ActivationsService, bindingScopeValues, BindingService, bindingTypeValues, ClassElementMetadataKind, DeactivationsService, decorate, getClassMetadata, multiInject, inject, injectable, injectFromBase, named, optional, postConstruct, plan, preDestroy, resolve, resolveModuleDeactivations, resolveServiceDeactivations, tagged, unmanaged, };
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unmanaged = exports.targetName = exports.tagged = exports.resolveServiceDeactivations = exports.resolveModuleDeactivations = exports.resolve = exports.preDestroy = exports.plan = exports.postConstruct = exports.optional = exports.named = exports.injectFromBase = exports.injectable = exports.inject = exports.multiInject = exports.getClassMetadata = exports.decorate = exports.DeactivationsService = exports.ClassElementMetadataKind = exports.bindingTypeValues = exports.BindingService = exports.bindingScopeValues = exports.ActivationsService = void 0;
exports.unmanaged = exports.tagged = exports.resolveServiceDeactivations = exports.resolveModuleDeactivations = exports.resolve = exports.preDestroy = exports.plan = exports.postConstruct = exports.optional = exports.named = exports.injectFromBase = exports.injectable = exports.inject = exports.multiInject = exports.getClassMetadata = exports.decorate = exports.DeactivationsService = exports.ClassElementMetadataKind = exports.bindingTypeValues = exports.BindingService = exports.bindingScopeValues = exports.ActivationsService = void 0;
const BindingScope_1 = require("./binding/models/BindingScope");

@@ -36,4 +36,2 @@ Object.defineProperty(exports, "bindingScopeValues", { enumerable: true, get: function () { return BindingScope_1.bindingScopeValues; } });

Object.defineProperty(exports, "tagged", { enumerable: true, get: function () { return tagged_1.tagged; } });
const targetName_1 = require("./metadata/decorators/targetName");
Object.defineProperty(exports, "targetName", { enumerable: true, get: function () { return targetName_1.targetName; } });
const unmanaged_1 = require("./metadata/decorators/unmanaged");

@@ -40,0 +38,0 @@ Object.defineProperty(exports, "unmanaged", { enumerable: true, get: function () { return unmanaged_1.unmanaged; } });

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

tags: new Map(),
targetName: undefined,
value: type,

@@ -15,0 +14,0 @@ };

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

tags: new Map(),
targetName: undefined,
value: serviceIdentifier,

@@ -13,0 +12,0 @@ };

@@ -11,5 +11,4 @@ "use strict";

tags: new Map(),
targetName: undefined,
};
}
//# sourceMappingURL=buildDefaultMaybeClassElementMetadata.js.map

@@ -16,7 +16,4 @@ "use strict";

function hasManagedMetadata(metadata) {
return (metadata.name !== undefined ||
metadata.optional ||
metadata.tags.size > 0 ||
metadata.targetName !== undefined);
return (metadata.name !== undefined || metadata.optional || metadata.tags.size > 0);
}
//# sourceMappingURL=buildUnmanagedMetadataFromMaybeManagedMetadata.js.map

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

import { MetadataTag } from './MetadataTag';
import { MetadataTargetName } from './MetadataTargetName';
export interface ManagedClassElementMetadata extends BaseClassElementMetadata<ClassElementMetadataKind.singleInjection | ClassElementMetadataKind.multipleInjection> {

@@ -13,5 +12,4 @@ isFromTypescriptParamType?: true;

tags: Map<MetadataTag, unknown>;
targetName: MetadataTargetName | undefined;
value: ServiceIdentifier | LazyServiceIdentifier;
}
//# sourceMappingURL=ManagedClassElementMetadata.d.ts.map

@@ -5,3 +5,2 @@ import { BaseClassElementMetadata } from './BaseClassElementMetadata';

import { MetadataTag } from './MetadataTag';
import { MetadataTargetName } from './MetadataTargetName';
export interface MaybeManagedClassElementMetadata extends BaseClassElementMetadata<MaybeClassElementMetadataKind.unknown> {

@@ -11,4 +10,3 @@ name: MetadataName | undefined;

tags: Map<MetadataTag, unknown>;
targetName: MetadataTargetName | undefined;
}
//# sourceMappingURL=MaybeManagedClassElementMetadata.d.ts.map

@@ -17,7 +17,6 @@ "use strict";

if (metadata.kind !== ClassElementMetadataKind_1.ClassElementMetadataKind.unmanaged) {
const propertyName = metadata.targetName ?? propertyKey;
instance[propertyName] = resolveServiceNode(params, propertyNode);
if ((0, common_1.isPromise)(instance[propertyName])) {
instance[propertyKey] = resolveServiceNode(params, propertyNode);
if ((0, common_1.isPromise)(instance[propertyKey])) {
propertyAssignmentPromises.push((async () => {
instance[propertyName] = await instance[propertyName];
instance[propertyKey] = await instance[propertyKey];
})());

@@ -24,0 +23,0 @@ }

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

type Provider<TActivated, in TArgs extends unknown[] = any[]> = (...args: TArgs[]) => Promise<TActivated>;
type Provider<TActivated, in TArgs extends unknown[] = any[]> = (...args: TArgs) => Promise<TActivated>;

@@ -132,2 +132,3 @@ interface ProviderBinding<TActivated extends Provider<unknown>> extends ScopedBinding<typeof bindingTypeValues.Provider, typeof bindingScopeValues.Singleton, TActivated> {

get<TResolved>(serviceIdentifier: ServiceIdentifier): Iterable<Binding<TResolved>> | undefined;
getNonParentBindings<TResolved>(serviceId: ServiceIdentifier): Iterable<Binding<TResolved>> | undefined;
getNonParentBoundServices(): Iterable<ServiceIdentifier>;

@@ -159,5 +160,5 @@ getByModuleId<TResolved>(moduleId: number): Iterable<Binding<TResolved>> | undefined;

declare function decorate(decorators: ClassDecorator[], target: Function): void;
declare function decorate(decorators: ParameterDecorator[], target: Function, parameterIndex: number): void;
declare function decorate(decorators: MethodDecorator[] | PropertyDecorator[], target: Function, property: string | symbol): void;
declare function decorate(decorators: ClassDecorator | ClassDecorator[], target: Function): void;
declare function decorate(decorators: ParameterDecorator | ParameterDecorator[], target: Function, parameterIndex: number): void;
declare function decorate(decorators: MethodDecorator | PropertyDecorator | MethodDecorator[] | PropertyDecorator[], target: Function, property: string | symbol): void;

@@ -174,4 +175,2 @@ interface BaseClassElementMetadata<TKind> {

type MetadataTargetName = string;
interface ManagedClassElementMetadata extends BaseClassElementMetadata<ClassElementMetadataKind.singleInjection | ClassElementMetadataKind.multipleInjection> {

@@ -182,3 +181,2 @@ isFromTypescriptParamType?: true;

tags: Map<MetadataTag, unknown>;
targetName: MetadataTargetName | undefined;
value: ServiceIdentifier | LazyServiceIdentifier;

@@ -228,4 +226,2 @@ }

declare function targetName(targetName: MetadataTargetName): ParameterDecorator & PropertyDecorator;
declare function unmanaged(): ParameterDecorator & PropertyDecorator;

@@ -315,2 +311,2 @@

export { ActivationsService, type BaseBinding, type BaseBindingNode, type BasePlanParams, type Binding, type BindingActivation, type BindingActivationRelation, type BindingDeactivation, type BindingDeactivationRelation, type BindingMetadata, type BindingScope, BindingService, type BindingType, type ClassElementMetadata, ClassElementMetadataKind, type ClassMetadata, type ClassMetadataLifecycle, type ConstantValueBinding, type DeactivationParams, DeactivationsService, type DynamicValueBinding, type DynamicValueBuilder, type Factory, type FactoryBinding, type GetOptions, type GetOptionsTagConstraint, type InstanceBinding, type LeafBindingNode, type ManagedClassElementMetadata, type MetadataName, type MetadataTag, type MetadataTargetName, type OptionalGetOptions, type PlanBindingNode, type PlanParams, type PlanParamsConstraint, type PlanParamsTagConstraint, type PlanResult, type PlanServiceNode, type PlanServiceNodeParent, type PlanServiceRedirectionBindingNode, type PlanTree, type Provider, type ProviderBinding, type ResolutionContext, type ResolutionParams, type Resolved, type ScopedBinding, type ServiceRedirectionBinding, type UnmanagedClassElementMetadata, bindingScopeValues, bindingTypeValues, decorate, getClassMetadata, inject, injectFromBase, injectable, multiInject, named, optional, plan, postConstruct, preDestroy, resolve, resolveModuleDeactivations, resolveServiceDeactivations, tagged, targetName, unmanaged };
export { ActivationsService, type BaseBinding, type BaseBindingNode, type BasePlanParams, type Binding, type BindingActivation, type BindingActivationRelation, type BindingDeactivation, type BindingDeactivationRelation, type BindingMetadata, type BindingScope, BindingService, type BindingType, type ClassElementMetadata, ClassElementMetadataKind, type ClassMetadata, type ClassMetadataLifecycle, type ConstantValueBinding, type DeactivationParams, DeactivationsService, type DynamicValueBinding, type DynamicValueBuilder, type Factory, type FactoryBinding, type GetOptions, type GetOptionsTagConstraint, type InstanceBinding, type LeafBindingNode, type ManagedClassElementMetadata, type MetadataName, type MetadataTag, type OptionalGetOptions, type PlanBindingNode, type PlanParams, type PlanParamsConstraint, type PlanParamsTagConstraint, type PlanResult, type PlanServiceNode, type PlanServiceNodeParent, type PlanServiceRedirectionBindingNode, type PlanTree, type Provider, type ProviderBinding, type ResolutionContext, type ResolutionParams, type Resolved, type ScopedBinding, type ServiceRedirectionBinding, type UnmanagedClassElementMetadata, bindingScopeValues, bindingTypeValues, decorate, getClassMetadata, inject, injectFromBase, injectable, multiInject, named, optional, plan, postConstruct, preDestroy, resolve, resolveModuleDeactivations, resolveServiceDeactivations, tagged, unmanaged };

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

import{getReflectMetadata as e,updateReflectMetadata as t,setReflectMetadata as n}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 t of e)yield*t}class d{#e;#t;#n;constructor(e){this.#e=new Map,this.#t={};for(const t of Reflect.ownKeys(e))this.#t[t]=new Map;this.#n=e}clone(){const e=Reflect.ownKeys(this.#n),t=new d(this.#n);this.#o(this.#e,t.#e);for(const n of e)this.#o(this.#t[n],t.#t[n]);return t}get(e,t){return this.#t[e].get(t)?.values()}getAllKeys(e){return this.#t[e].keys()}removeByRelation(e,t){const n=this.get(e,t);if(void 0!==n)for(const e of n){const t=this.#e.get(e);if(void 0===t)throw new Error("Expecting model relation, none found");this.#i(e,t),this.#e.delete(e)}}set(e,t){this.#e.set(e,t);for(const n of Reflect.ownKeys(t))this.#r(n,t[n]).add(e)}#r(e,t){let n=this.#t[e].get(t);return void 0===n&&(n=new Set,this.#t[e].set(t,n)),n}#o(e,t){for(const[n,o]of e)t.set(n,o)}#i(e,t){for(const n of Reflect.ownKeys(t))this.#s(e,n,t[n])}#s(e,t,n){const o=this.#t[t].get(n);void 0!==o&&(o.delete(e),0===o.size&&this.#t[t].delete(n))}}var l,f,p;!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(l||(l={}));class m{#c;#a;constructor(e,t){this.#c=t??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#a=e}static build(e){return new m(e)}add(e,t){this.#c.set(e,t)}clone(){return new m(this.#a,this.#c.clone())}get(e){const t=[],n=this.#c.get(l.serviceId,e);void 0!==n&&t.push(n);const o=this.#a?.get(e);if(void 0!==o&&t.push(o),0!==t.length)return u(...t)}removeAllByModuleId(e){this.#c.removeByRelation(l.moduleId,e)}removeAllByServiceId(e){this.#c.removeByRelation(l.serviceId,e)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(f||(f={}));class g{#u;#a;constructor(e,t){this.#u=t??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#a=e}static build(e){return new g(e)}clone(){return new g(this.#a,this.#u.clone())}get(e){return this.#u.get(f.serviceId,e)??this.#a?.get(e)}getNonParentBoundServices(){return this.#u.getAllKeys(f.serviceId)}getByModuleId(e){return this.#u.get(f.moduleId,e)??this.#a?.getByModuleId(e)}removeAllByModuleId(e){this.#u.removeByRelation(f.moduleId,e)}removeAllByServiceId(e){this.#u.removeByRelation(f.serviceId,e)}set(e){const t={[f.serviceId]:e.serviceIdentifier};void 0!==e.moduleId&&(t[f.moduleId]=e.moduleId),this.#u.set(e,t)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(p||(p={}));class v{#d;#a;constructor(e,t){this.#d=t??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#a=e}static build(e){return new v(e)}add(e,t){this.#d.set(e,t)}clone(){return new v(this.#a,this.#d.clone())}get(e){const t=[],n=this.#d.get(p.serviceId,e);void 0!==n&&t.push(n);const o=this.#a?.get(e);if(void 0!==o&&t.push(o),0!==t.length)return u(...t)}removeAllByModuleId(e){this.#d.removeByRelation(p.moduleId,e)}removeAllByServiceId(e){this.#d.removeByRelation(p.serviceId,e)}}function h(e,t,n){if(void 0!==n)if("number"!=typeof n)Reflect.decorate(e,t.prototype,n);else for(const o of e)o(t,void 0,n);else Reflect.decorate(e,t)}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,t,n){super(t,n),this[I]=!0,this.kind=e}static is(e){return"object"==typeof e&&null!==e&&!0===e[I]}static isErrorOfKind(e,t){return b.is(e)&&e.kind===t}}var j,C,x;function $(t){const n=e(t,y)??w();if(!function(t){const n=e(t,M);return void 0!==n&&0!==n}(t))return function(e,t){const n=[];if(t.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 ${t.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<t.length;++e)void 0===t[e]&&n.push(e);if(n.length>0)throw new b(j.missingInjectionDecorator,`Found unexpected missing metadata on type "${e.name}" at constructor indexes "${n.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`)}(t,n.constructorArguments),n;!function(e,t){const n=[];for(let o=0;o<t.constructorArguments.length;++o){const i=t.constructorArguments[o];void 0!==i&&i.kind!==C.unknown||n.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 t.properties)i.kind===C.unknown&&n.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===n.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${n.join("\n\n")}`)}(t,n)}function R(){return 0}function S(e){return n=>{void 0!==n&&n.kind===C.unknown&&t(e,M,R,(e=>e-1))}}function A(e,t){return(...n)=>o=>{if(void 0===o)return e(...n);if(o.kind===x.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found");return t(o,...n)}}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=0]="unknown"}(C||(C={})),function(e){e[e.multipleInjection=0]="multipleInjection",e[e.singleInjection=1]="singleInjection",e[e.unmanaged=2]="unmanaged"}(x||(x={}));const D=A((function(e,t){return{kind:e,name:void 0,optional:!1,tags:new Map,targetName:void 0,value:t}}),(function(e,t,n){return T(e),{...e,kind:t,value:n}}));var k;function B(e,t,n,o){if(b.isErrorOfKind(o,j.injectionDecoratorConflict)){const i=function(e,t,n){if(void 0===n){if(void 0===t)throw new b(j.unknown,"Unexpected undefined property and index values");return{kind:k.property,property:t,targetClass:e.constructor}}return{index:n,kind:k.parameter,targetClass:e}}(e,t,n);throw new b(j.injectionDecoratorConflict,`Unexpected injection error.\n\nCause:\n\n${o.message}\n\nDetails\n\n${function(e){switch(e.kind){case k.parameter:return`[class: "${e.targetClass.name}", index: "${e.index.toString()}"]`;case k.property:return`[class: "${e.targetClass.name}", property: "${e.property.toString()}"]`}}(i)}`,{cause:o})}throw o}function N(e,n){return(o,i,r)=>{void 0===r?function(e,n){const o=F(e,n);return(e,n)=>{t(e.constructor,y,w,function(e,t){return n=>{const o=n.properties.get(t);return n.properties.set(t,e(o)),n}}(o(e),n))}}(e,n)(o,i):function(e,n){const o=F(e,n);return(e,n,i)=>{if(!function(e,t){return"function"==typeof e&&void 0===t}(e,n))throw new Error(`Found an @inject decorator in a non constructor parameter.\nFound @inject decorator at method "${n?.toString()??""}" at class "${e.constructor.name}"`);t(e,y,w,function(e,t){return n=>{const o=n.constructorArguments[t];return n.constructorArguments[t]=e(o),n}}(o(e),i))}}(e,n)(o,i,r)}}function F(e,t){return n=>{const o=t(n);return t=>(o(t),e(t))}}function P(e){const t=D(x.singleInjection,e);return(e,n,o)=>{try{void 0===o?N(t,S)(e,n):N(t,S)(e,n,o)}catch(t){B(e,n,o,t)}}}!function(e){e[e.parameter=0]="parameter",e[e.property=1]="property"}(k||(k={}));const E="@inversifyjs/core/classIsInjectableFlagReflectKey";const U=[Array,BigInt,Boolean,Function,Number,Object,String];function O(n){const o=e(n,"design:paramtypes");void 0!==o&&t(n,y,w,function(e){return t=>(e.forEach(((e,n)=>{var o;void 0!==t.constructorArguments[n]||(o=e,U.includes(o))||(t.constructorArguments[n]=function(e){return{isFromTypescriptParamType:!0,kind:x.singleInjection,name:void 0,optional:!1,tags:new Map,targetName:void 0,value:e}}(e))})),t)}(o))}function K(o){return i=>{!function(t){if(void 0!==e(t,E))throw new b(j.injectionDecoratorConflict,"Cannot apply @injectable decorator multiple times");n(t,E,!0)}(i),O(i),void 0!==o&&t(i,y,w,(e=>({...e,scope:o})))}}function q(e,t,n){let o;return e.extendConstructorArguments??!1?(o=[...t.constructorArguments],n.constructorArguments.map(((e,t)=>{o[t]=e}))):o=n.constructorArguments,o}function V(e,t,n){let o;return o=e.extendProperties??!1?new Map(u(t.properties,n.properties)):n.properties,o}function z(e){return n=>{const o=$(e.type);t(n,y,w,function(e,t){const n=n=>({constructorArguments:q(e,t,n),lifecycle:n.lifecycle,properties:V(e,t,n),scope:n.scope});return n}(e,o))}}function G(e){return t=>{const n=o(t);if(void 0===n)throw new b(j.injectionDecoratorConflict,`Expected base type for type "${t.name}", none found.`);z({...e,type:n})(t)}}function H(e){const t=D(x.multipleInjection,e);return(e,n,o)=>{try{void 0===o?N(t,S)(e,n):N(t,S)(e,n,o)}catch(t){B(e,n,o,t)}}}function J(e){return n=>{void 0===n&&t(e,M,R,(e=>e+1))}}function L(e){return t=>{const n=t??{kind:C.unknown,name:void 0,optional:!1,tags:new Map,targetName:void 0};if(n.kind===x.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return e(n)}}function Q(e){const t=L(function(e){return t=>{if(void 0!==t.name)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated named decorator");return t.name=e,t}}(e));return(e,n,o)=>{try{void 0===o?N(t,J)(e,n):N(t,J)(e,n,o)}catch(t){B(e,n,o,t)}}}function W(e){if(e.optional)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated optional decorator");return e.optional=!0,e}function X(){const e=L(W);return(t,n,o)=>{try{void 0===o?N(e,J)(t,n):N(e,J)(t,n,o)}catch(e){B(t,n,o,e)}}}function Y(){return(e,n,o)=>{try{t(e.constructor,y,w,(i=n,e=>{if(void 0!==e.lifecycle.postConstructMethodName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated postConstruct decorator");return e.lifecycle.postConstructMethodName=i,e}))}catch(t){B(e,n,void 0,t)}var i}}function Z(){return(e,n,o)=>{try{t(e.constructor,y,w,(i=n,e=>{if(void 0!==e.lifecycle.preDestroyMethodName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated preDestroy decorator");return e.lifecycle.preDestroyMethodName=i,e}))}catch(t){B(e,n,void 0,t)}var i}}function _(e,t){const n=L(function(e,t){return n=>{if(n.tags.has(e))throw new b(j.injectionDecoratorConflict,"Unexpected duplicated tag decorator with existing tag");return n.tags.set(e,t),n}}(e,t));return(e,t,o)=>{try{void 0===o?N(n,J)(e,t):N(n,J)(e,t,o)}catch(n){B(e,t,o,n)}}}function ee(e){const t=L(function(e){return t=>{if(void 0!==t.targetName)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated targetName decorator");return t.targetName=e,t}}(e));return(e,n,o)=>{try{void 0===o?N(t,J)(e,n):N(t,J)(e,n,o)}catch(t){B(e,n,o,t)}}}function te(){return{kind:x.unmanaged}}const ne=A(te,(function(e){if(T(e),function(e){return void 0!==e.name||e.optional||e.tags.size>0||void 0!==e.targetName}(e))throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return te()}));function oe(){const e=ne();return(t,n,o)=>{try{void 0===o?N(e,S)(t,n):N(e,S)(t,n,o)}catch(e){B(t,n,o,e)}}}class ie{last;constructor(e){this.last=e}concat(e){return new ie({elem:e,previous:this.last})}[Symbol.iterator](){let e=this.last;return{next:()=>{if(void 0===e)return{done:!0,value:void 0};const t=e.elem;return e=e.previous,{done:!1,value:t}}}}}function re(e,t){e.servicesBranch.has(t)&&function(e,t){const n=(o=[...e.servicesBranch,t],[...o].map(i).join(" -> "));var o;throw new b(j.planning,`Circular dependency found: ${n}`)}(e,t),e.servicesBranch.add(t)}class se{#l;constructor(e){this.#l=e}get name(){return this.#l.elem.name}get tags(){return this.#l.elem.tags}get serviceIdentifier(){return this.#l.elem.serviceIdentifier}getAncestor(){if(void 0!==this.#l.previous)return new se(this.#l.previous)}}function ce(e,t,n){const o=new se(t.last),i=n?.customServiceIdentifier??o.serviceIdentifier;return[...e.getBindings(i)??[]].filter((e=>e.isSatisfiedBy(o)))}function ae(e){return void 0!==e.redirections}function ue(e,t,n){let o,r;ae(n)?(o=n.binding.targetServiceIdentifier,r=n.binding.serviceIdentifier):(o=n.serviceIdentifier,r=n.parent?.binding.serviceIdentifier),Array.isArray(e)?function(e,t,n,o){if(0!==e.length){const t=`Ambiguous bindings found for service: "${i(n)}".\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(n,o)}".`;throw new b(j.planning,t)}t||de(n,o)}(e,t,o,r):function(e,t,n,o){if(void 0!==e||t)return;de(n,o)}(e,t,o,r)}function de(e,t){const n=`No bindings found for service: "${i(e)}".\n\nTrying to resolve bindings for "${le(e,t)}".`;throw new b(j.planning,n)}function le(e,t){return void 0===t?`${i(e)} (Root service)`:i(t)}function fe(e,t){if(1!==e.redirections.length)ue(e.redirections,t,e);else{const[n]=e.redirections;ae(n)&&fe(n,t)}}function pe(e,t){if(Array.isArray(e.bindings)&&1===e.bindings.length){const[n]=e.bindings;ae(n)&&fe(n,t)}else ue(e.bindings,t,e)}function me(e){const t=new Map;void 0!==e.rootConstraints.tag&&t.set(e.rootConstraints.tag.key,e.rootConstraints.tag.value);const n=new ie({elem:{name:e.rootConstraints.name,serviceIdentifier:e.rootConstraints.serviceIdentifier,tags:t},previous:void 0}),o=ce(e,n),i=[],r={bindings:i,parent:void 0,serviceIdentifier:e.rootConstraints.serviceIdentifier};if(i.push(...he(e,n,o,r)),!e.rootConstraints.isMultiple){pe(r,e.rootConstraints.isOptional??!1);const[t]=i;r.bindings=t}return{tree:{root:r}}}function ge(e,t,n,o){const i={binding:t,classMetadata:e.getClassMetadata(t.implementationType),constructorParams:[],parent:o,propertyParams:new Map};return function(e,t){const n=e.node.classMetadata;for(const[o,i]of n.constructorArguments.entries())e.node.constructorParams[o]=ve(e,t,i);for(const[o,i]of n.properties){const n=ve(e,t,i);void 0!==n&&e.node.propertyParams.set(o,n)}return e.node}({getBindings:e.getBindings,getClassMetadata:e.getClassMetadata,node:i,servicesBranch:e.servicesBranch},n)}function ve(e,t,n){if(n.kind===x.unmanaged)return;const o=r.is(n.value)?n.value.unwrap():n.value,i=t.concat({name:n.name,serviceIdentifier:o,tags:n.tags}),s=ce(e,i),c=[],a={bindings:c,parent:e.node,serviceIdentifier:o};if(c.push(...he(e,i,s,a)),n.kind===x.singleInjection){pe(a,n.optional);const[e]=c;a.bindings=e}return a}function he(e,t,n,o){const i=ae(o)?o.binding.targetServiceIdentifier:o.serviceIdentifier;re(e,i);const r=[];for(const i of n)switch(i.type){case a.Instance:r.push(ge(e,i,t,o));break;case a.ServiceRedirection:{const n=ye(e,t,i,o);r.push(n);break}default:r.push({binding:i,parent:o})}return e.servicesBranch.delete(i),r}function ye(e,t,n,o){const i={binding:n,parent:o,redirections:[]},r=ce(e,t,{customServiceIdentifier:n.targetServiceIdentifier});return i.redirections.push(...he(e,t,r,i)),i}function we(e,t,n){const o=e.getActivations(t);return void 0===o?n:s(n)?Me(e,n,o[Symbol.iterator]()):function(e,t,n){let o=t,i=n.next();for(;!0!==i.done;){const t=i.value(e.context,o);if(s(t))return Me(e,t,n);o=t,i=n.next()}return o}(e,n,o[Symbol.iterator]())}async function Me(e,t,n){let o=await t,i=n.next();for(;!0!==i.done;)o=await i.value(e.context,o),i=n.next();return o}function Ie(e,t,n){let o=n;if(void 0!==t.onActivation){const n=t.onActivation;o=s(o)?o.then((t=>n(e.context,t))):n(e.context,o)}return we(e,t.serviceIdentifier,o)}function be(e){return(t,n)=>{if(n.cache.isRight)return n.cache.value;const o=Ie(t,n,e(t,n));return n.cache={isRight:!0,value:o},o}}const je=be((function(e,t){return t.value}));function Ce(e){return e}function xe(e,t){return(n,o)=>{const i=e(o);switch(i.scope){case c.Singleton:{if(i.cache.isRight)return i.cache.value;const e=$e(n,o,i,t);return i.cache={isRight:!0,value:e},e}case c.Request:{if(n.requestScopeCache.has(i.id))return n.requestScopeCache.get(i.id);const e=$e(n,o,i,t);return n.requestScopeCache.set(i.id,e),e}case c.Transient:return $e(n,o,i,t)}}}function $e(e,t,n,o){return Ie(e,n,o(e,t))}const Re=(e=>xe(Ce,e))((function(e,t){return t.value(e.context)}));const Se=be((function(e,t){return t.factory(e.context)}));function Ae(e,t,n){const o=function(e,t,n){if(void 0===n)return;if(!(n in e))throw new b(j.resolution,`Expecting a "${n.toString()}" property when resolving "${t.implementationType.name}" class @postConstruct decorated method, none found.`);if("function"!=typeof e[n])throw new b(j.resolution,`Expecting a "${n.toString()}" method when resolving "${t.implementationType.name}" class @postConstruct decorated method, a non function property was found instead.`);{let o;try{o=e[n]()}catch(e){throw new b(j.resolution,`Unexpected error found when calling "${n.toString()}" @postConstruct decorated method on class "${t.implementationType.name}"`,{cause:e})}if(s(o))return async function(e,t,n){try{await n}catch(n){throw new b(j.resolution,`Unexpected error found when calling "${t.toString()}" @postConstruct decorated method on class "${e.implementationType.name}"`,{cause:n})}}(t,n,o)}}(e,t,n);return s(o)?o.then((()=>e)):e}function Te(e){return(t,n,o)=>{const i=new o.binding.implementationType(...t),r=e(n,i,o);return s(r)?r.then((()=>Ae(i,o.binding,o.classMetadata.lifecycle.postConstructMethodName))):Ae(i,o.binding,o.classMetadata.lifecycle.postConstructMethodName)}}const De=be((function(e,t){return t.provider(e.context)}));function ke(e){return e.binding}const Be=function(e){return(t,n,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`);if(a.kind!==x.unmanaged){const o=a.targetName??r;n[o]=e(t,c),s(n[o])&&i.push((async()=>{n[o]=await n[o]})())}}if(i.length>0)return Promise.all(i).then((()=>{}))}}(Oe),Ne=function(e){return function t(n,o){const i=[];for(const r of o.redirections)ae(r)?i.push(...t(n,r)):i.push(e(n,r));return i}}(Ue),Fe=function(e,t,n){return(o,i)=>{const r=e(o,i);return s(r)?t(r,o,i):n(r,o,i)}}(function(e){return(t,n)=>{const o=[];for(const i of n.constructorParams)void 0===i?o.push(void 0):o.push(e(t,i));return o.some(s)?Promise.all(o):o}}(Oe),function(e){return async(t,n,o)=>{const i=await t;return e(i,n,o)}}(Te(Be)),Te(Be)),Pe=(e=>xe(ke,e))(Fe);function Ee(e){return Oe(e,e.planResult.tree.root)}function Ue(e,t){switch(t.binding.type){case a.ConstantValue:return je(e,t.binding);case a.DynamicValue:return Re(e,t.binding);case a.Factory:return Se(e,t.binding);case a.Instance:return Pe(e,t);case a.Provider:return De(e,t.binding)}}function Oe(e,t){if(void 0!==t.bindings)return Array.isArray(t.bindings)?function(e,t){const n=[];for(const o of t)ae(o)?n.push(...Ne(e,o)):n.push(Ue(e,o));if(n.some(s))return Promise.all(n);return n}(e,t.bindings):function(e,t){if(ae(t)){const n=Ne(e,t);if(1===n.length)return n[0];throw new b(j.resolution,"Unexpected multiple resolved values on single injection")}return Ue(e,t)}(e,t.bindings)}function Ke(e){return void 0!==e.scope}function qe(e,t){if(void 0!==e.lifecycle.preDestroyMethodName&&"function"==typeof t[e.lifecycle.preDestroyMethodName])return t[e.lifecycle.preDestroyMethodName]()}function Ve(e,t,n){const o=e.getDeactivations(t);if(void 0!==o)return s(n)?ze(n,o[Symbol.iterator]()):function(e,t){let n=t.next();for(;!0!==n.done;){const o=n.value(e);if(s(o))return ze(e,t);n=t.next()}}(n,o[Symbol.iterator]())}async function ze(e,t){const n=await e;let o=t.next();for(;!0!==o.done;)await o.value(n),o=t.next()}function Ge(e,t){const n=function(e,t){if(t.type===a.Instance){const n=e.getClassMetadata(t.implementationType),o=t.cache.value;return s(o)?o.then((e=>qe(n,e))):qe(n,o)}}(e,t);return void 0===n?He(e,t):n.then((()=>He(e,t)))}function He(e,t){const n=t.cache;return s(n.value)?n.value.then((n=>Je(e,t,n))):Je(e,t,n.value)}function Je(e,t,n){let o;if(void 0!==t.onDeactivation){o=(0,t.onDeactivation)(n)}return void 0===o?Ve(e,t.serviceIdentifier,n):o.then((()=>Ve(e,t.serviceIdentifier,n)))}function Le(e,t){if(void 0===t)return;const n=function(e){const t=[];for(const n of e)Ke(n)&&n.scope===c.Singleton&&n.cache.isRight&&t.push(n);return t}(t),o=[];for(const t of n){const n=Ge(e,t);void 0!==n&&o.push(n)}return o.length>0?Promise.all(o).then((()=>{})):void 0}function Qe(e,t){const n=e.getBindingsFromModule(t);return Le(e,n)}function We(e,t){const n=e.getBindings(t);return Le(e,n)}export{m as ActivationsService,g as BindingService,x as ClassElementMetadataKind,v as DeactivationsService,c as bindingScopeValues,a as bindingTypeValues,h as decorate,$ as getClassMetadata,P as inject,G as injectFromBase,K as injectable,H as multiInject,Q as named,X as optional,me as plan,Y as postConstruct,Z as preDestroy,Ee as resolve,Qe as resolveModuleDeactivations,We as resolveServiceDeactivations,_ as tagged,ee as targetName,oe as unmanaged};
import{getReflectMetadata as e,updateReflectMetadata 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}clone(){const e=Reflect.ownKeys(this.#t),n=new d(this.#t);this.#o(this.#e,n.#e);for(const t of e)this.#o(this.#n[t],n.#n[t]);return n}get(e,n){return this.#n[e].get(n)?.values()}getAllKeys(e){return this.#n[e].keys()}removeByRelation(e,n){const t=this.get(e,n);if(void 0!==t)for(const e of t){const n=this.#e.get(e);if(void 0===n)throw new Error("Expecting model relation, none found");this.#i(e,n),this.#e.delete(e)}}set(e,n){this.#e.set(e,n);for(const t of Reflect.ownKeys(n))this.#r(t,n[t]).add(e)}#r(e,n){let t=this.#n[e].get(n);return void 0===t&&(t=new Set,this.#n[e].set(n,t)),t}#o(e,n){for(const[t,o]of e)n.set(t,o)}#i(e,n){for(const t of Reflect.ownKeys(n))this.#s(e,t,n[t])}#s(e,n,t){const o=this.#n[n].get(t);void 0!==o&&(o.delete(e),0===o.size&&this.#n[n].delete(t))}}var l,f,p;!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(l||(l={}));class g{#c;#a;constructor(e,n){this.#c=n??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#a=e}static build(e){return new g(e)}add(e,n){this.#c.set(e,n)}clone(){return new g(this.#a,this.#c.clone())}get(e){const n=[],t=this.#c.get(l.serviceId,e);void 0!==t&&n.push(t);const o=this.#a?.get(e);if(void 0!==o&&n.push(o),0!==n.length)return u(...n)}removeAllByModuleId(e){this.#c.removeByRelation(l.moduleId,e)}removeAllByServiceId(e){this.#c.removeByRelation(l.serviceId,e)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(f||(f={}));class m{#u;#a;constructor(e,n){this.#u=n??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#a=e}static build(e){return new m(e)}clone(){return new m(this.#a,this.#u.clone())}get(e){return this.getNonParentBindings(e)??this.#a?.get(e)}getNonParentBindings(e){return this.#u.get(f.serviceId,e)}getNonParentBoundServices(){return this.#u.getAllKeys(f.serviceId)}getByModuleId(e){return this.#u.get(f.moduleId,e)??this.#a?.getByModuleId(e)}removeAllByModuleId(e){this.#u.removeByRelation(f.moduleId,e)}removeAllByServiceId(e){this.#u.removeByRelation(f.serviceId,e)}set(e){const n={[f.serviceId]:e.serviceIdentifier};void 0!==e.moduleId&&(n[f.moduleId]=e.moduleId),this.#u.set(e,n)}}!function(e){e.moduleId="moduleId",e.serviceId="serviceId"}(p||(p={}));class v{#d;#a;constructor(e,n){this.#d=n??new d({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#a=e}static build(e){return new v(e)}add(e,n){this.#d.set(e,n)}clone(){return new v(this.#a,this.#d.clone())}get(e){const n=[],t=this.#d.get(p.serviceId,e);void 0!==t&&n.push(t);const o=this.#a?.get(e);if(void 0!==o&&n.push(o),0!==n.length)return u(...n)}removeAllByModuleId(e){this.#d.removeByRelation(p.moduleId,e)}removeAllByServiceId(e){this.#d.removeByRelation(p.serviceId,e)}}function h(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,x;function $(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 R(){return 0}function S(e){return t=>{void 0!==t&&t.kind===C.unknown&&n(e,M,R,(e=>e-1))}}function A(e,n){return(...t)=>o=>{if(void 0===o)return e(...t);if(o.kind===x.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=0]="unknown"}(C||(C={})),function(e){e[e.multipleInjection=0]="multipleInjection",e[e.singleInjection=1]="singleInjection",e[e.unmanaged=2]="unmanaged"}(x||(x={}));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}}));var k;function B(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:k.property,property:n,targetClass:e.constructor}}return{index:t,kind:k.parameter,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 k.parameter:return`[class: "${e.targetClass.name}", index: "${e.index.toString()}"]`;case k.property:return`[class: "${e.targetClass.name}", property: "${e.property.toString()}"]`}}(i)}`,{cause:o})}throw o}function P(e,t){return(o,i,r)=>{void 0===r?function(e,t){const o=F(e,t);return(e,t)=>{n(e.constructor,y,w,function(e,n){return t=>{const o=t.properties.get(n);return t.properties.set(n,e(o)),t}}(o(e),t))}}(e,t)(o,i):function(e,t){const o=F(e,t);return(e,t,i)=>{if(!function(e,n){return"function"==typeof e&&void 0===n}(e,t))throw new Error(`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 F(e,n){return t=>{const o=n(t);return n=>(o(n),e(n))}}function N(e){const n=D(x.singleInjection,e);return(e,t,o)=>{try{void 0===o?P(n,S)(e,t):P(n,S)(e,t,o)}catch(n){B(e,t,o,n)}}}!function(e){e[e.parameter=0]="parameter",e[e.property=1]="property"}(k||(k={}));const E="@inversifyjs/core/classIsInjectableFlagReflectKey";const U=[Array,BigInt,Boolean,Function,Number,Object,String];function O(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:x.singleInjection,name:void 0,optional:!1,tags:new Map,value:e}}(e))})),n)}(o))}function K(o){return i=>{!function(n){if(void 0!==e(n,E))throw new b(j.injectionDecoratorConflict,"Cannot apply @injectable decorator multiple times");t(n,E,!0)}(i),O(i),void 0!==o&&n(i,y,w,(e=>({...e,scope:o})))}}function q(e,n,t){let o;return e.extendConstructorArguments??!1?(o=[...n.constructorArguments],t.constructorArguments.map(((e,n)=>{o[n]=e}))):o=t.constructorArguments,o}function V(e,n,t){let o;return o=e.extendProperties??!1?new Map(u(n.properties,t.properties)):t.properties,o}function z(e){return t=>{const o=$(e.type);n(t,y,w,function(e,n){const t=t=>({constructorArguments:q(e,n,t),lifecycle:t.lifecycle,properties:V(e,n,t),scope:t.scope});return t}(e,o))}}function G(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 H(e){const n=D(x.multipleInjection,e);return(e,t,o)=>{try{void 0===o?P(n,S)(e,t):P(n,S)(e,t,o)}catch(n){B(e,t,o,n)}}}function J(e){return t=>{void 0===t&&n(e,M,R,(e=>e+1))}}function L(e){return n=>{const t=n??{kind:C.unknown,name:void 0,optional:!1,tags:new Map};if(t.kind===x.unmanaged)throw new b(j.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return e(t)}}function Q(e){const n=L(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(e,t,o)=>{try{void 0===o?P(n,J)(e,t):P(n,J)(e,t,o)}catch(n){B(e,t,o,n)}}}function W(e){if(e.optional)throw new b(j.injectionDecoratorConflict,"Unexpected duplicated optional decorator");return e.optional=!0,e}function X(){const e=L(W);return(n,t,o)=>{try{void 0===o?P(e,J)(n,t):P(e,J)(n,t,o)}catch(e){B(n,t,o,e)}}}function Y(){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){B(e,t,void 0,n)}var i}}function Z(){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){B(e,t,void 0,n)}var i}}function _(e,n){const t=L(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(e,n,o)=>{try{void 0===o?P(t,J)(e,n):P(t,J)(e,n,o)}catch(t){B(e,n,o,t)}}}function ee(){return{kind:x.unmanaged}}const ne=A(ee,(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 ee()}));function te(){const e=ne();return(n,t,o)=>{try{void 0===o?P(e,S)(n,t):P(e,S)(n,t,o)}catch(e){B(n,t,o,e)}}}class oe{last;constructor(e){this.last=e}concat(e){return new oe({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 ie(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)}class re{#l;constructor(e){this.#l=e}get name(){return this.#l.elem.name}get tags(){return this.#l.elem.tags}get serviceIdentifier(){return this.#l.elem.serviceIdentifier}getAncestor(){if(void 0!==this.#l.previous)return new re(this.#l.previous)}}function se(e,n,t){const o=new re(n.last),i=t?.customServiceIdentifier??o.serviceIdentifier;return[...e.getBindings(i)??[]].filter((e=>e.isSatisfiedBy(o)))}function ce(e){return void 0!==e.redirections}function ae(e,n,t){let o,r;ce(t)?(o=t.binding.targetServiceIdentifier,r=t.binding.serviceIdentifier):(o=t.serviceIdentifier,r=t.parent?.binding.serviceIdentifier),Array.isArray(e)?function(e,n,t,o){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 "${de(t,o)}".`;throw new b(j.planning,n)}n||ue(t,o)}(e,n,o,r):function(e,n,t,o){if(void 0!==e||n)return;ue(t,o)}(e,n,o,r)}function ue(e,n){const t=`No bindings found for service: "${i(e)}".\n\nTrying to resolve bindings for "${de(e,n)}".`;throw new b(j.planning,t)}function de(e,n){return void 0===n?`${i(e)} (Root service)`:i(n)}function le(e,n){if(1!==e.redirections.length)ae(e.redirections,n,e);else{const[t]=e.redirections;ce(t)&&le(t,n)}}function fe(e,n){if(Array.isArray(e.bindings)&&1===e.bindings.length){const[t]=e.bindings;ce(t)&&le(t,n)}else ae(e.bindings,n,e)}function pe(e){const n=new Map;void 0!==e.rootConstraints.tag&&n.set(e.rootConstraints.tag.key,e.rootConstraints.tag.value);const t=new oe({elem:{name:e.rootConstraints.name,serviceIdentifier:e.rootConstraints.serviceIdentifier,tags:n},previous:void 0}),o=se(e,t),i=[],r={bindings:i,parent:void 0,serviceIdentifier:e.rootConstraints.serviceIdentifier};if(i.push(...ve(e,t,o,r)),!e.rootConstraints.isMultiple){fe(r,e.rootConstraints.isOptional??!1);const[n]=i;r.bindings=n}return{tree:{root:r}}}function ge(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]=me(e,n,i);for(const[o,i]of t.properties){const t=me(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 me(e,n,t){if(t.kind===x.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=se(e,i),c=[],a={bindings:c,parent:e.node,serviceIdentifier:o};if(c.push(...ve(e,i,s,a)),t.kind===x.singleInjection){fe(a,t.optional);const[e]=c;a.bindings=e}return a}function ve(e,n,t,o){const i=ce(o)?o.binding.targetServiceIdentifier:o.serviceIdentifier;ie(e,i);const r=[];for(const i of t)switch(i.type){case a.Instance:r.push(ge(e,i,n,o));break;case a.ServiceRedirection:{const t=he(e,n,i,o);r.push(t);break}default:r.push({binding:i,parent:o})}return e.servicesBranch.delete(i),r}function he(e,n,t,o){const i={binding:t,parent:o,redirections:[]},r=se(e,n,{customServiceIdentifier:t.targetServiceIdentifier});return i.redirections.push(...ve(e,n,r,i)),i}function ye(e,n,t){const o=e.getActivations(n);return void 0===o?t:s(t)?we(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 we(e,n,t);o=n,i=t.next()}return o}(e,t,o[Symbol.iterator]())}async function we(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 Me(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 ye(e,n.serviceIdentifier,o)}function Ie(e){return(n,t)=>{if(t.cache.isRight)return t.cache.value;const o=Me(n,t,e(n,t));return t.cache={isRight:!0,value:o},o}}const be=Ie((function(e,n){return n.value}));function je(e){return e}function Ce(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=xe(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=xe(t,o,i,n);return t.requestScopeCache.set(i.id,e),e}case c.Transient:return xe(t,o,i,n)}}}function xe(e,n,t,o){return Me(e,t,o(e,n))}const $e=(e=>Ce(je,e))((function(e,n){return n.value(e.context)}));const Re=Ie((function(e,n){return n.factory(e.context)}));function Se(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 Ae(e){return(n,t,o)=>{const i=new o.binding.implementationType(...n),r=e(t,i,o);return s(r)?r.then((()=>Se(i,o.binding,o.classMetadata.lifecycle.postConstructMethodName))):Se(i,o.binding,o.classMetadata.lifecycle.postConstructMethodName)}}const Te=Ie((function(e,n){return n.provider(e.context)}));function De(e){return e.binding}const ke=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!==x.unmanaged&&(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((()=>{}))}}(Ue),Be=function(e){return function n(t,o){const i=[];for(const r of o.redirections)ce(r)?i.push(...n(t,r)):i.push(e(t,r));return i}}(Ee),Pe=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}}(Ue),function(e){return async(n,t,o)=>{const i=await n;return e(i,t,o)}}(Ae(ke)),Ae(ke)),Fe=(e=>Ce(De,e))(Pe);function Ne(e){return Ue(e,e.planResult.tree.root)}function Ee(e,n){switch(n.binding.type){case a.ConstantValue:return be(e,n.binding);case a.DynamicValue:return $e(e,n.binding);case a.Factory:return Re(e,n.binding);case a.Instance:return Fe(e,n);case a.Provider:return Te(e,n.binding)}}function Ue(e,n){if(void 0!==n.bindings)return Array.isArray(n.bindings)?function(e,n){const t=[];for(const o of n)ce(o)?t.push(...Be(e,o)):t.push(Ee(e,o));if(t.some(s))return Promise.all(t);return t}(e,n.bindings):function(e,n){if(ce(n)){const t=Be(e,n);if(1===t.length)return t[0];throw new b(j.resolution,"Unexpected multiple resolved values on single injection")}return Ee(e,n)}(e,n.bindings)}function Oe(e){return void 0!==e.scope}function Ke(e,n){if(void 0!==e.lifecycle.preDestroyMethodName&&"function"==typeof n[e.lifecycle.preDestroyMethodName])return n[e.lifecycle.preDestroyMethodName]()}function qe(e,n,t){const o=e.getDeactivations(n);if(void 0!==o)return s(t)?Ve(t,o[Symbol.iterator]()):function(e,n){let t=n.next();for(;!0!==t.done;){const o=t.value(e);if(s(o))return Ve(e,n);t=n.next()}}(t,o[Symbol.iterator]())}async function Ve(e,n){const t=await e;let o=n.next();for(;!0!==o.done;)await o.value(t),o=n.next()}function ze(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=>Ke(t,e))):Ke(t,o)}}(e,n);return void 0===t?Ge(e,n):t.then((()=>Ge(e,n)))}function Ge(e,n){const t=n.cache;return s(t.value)?t.value.then((t=>He(e,n,t))):He(e,n,t.value)}function He(e,n,t){let o;if(void 0!==n.onDeactivation){o=(0,n.onDeactivation)(t)}return void 0===o?qe(e,n.serviceIdentifier,t):o.then((()=>qe(e,n.serviceIdentifier,t)))}function Je(e,n){if(void 0===n)return;const t=function(e){const n=[];for(const t of e)Oe(t)&&t.scope===c.Singleton&&t.cache.isRight&&n.push(t);return n}(n),o=[];for(const n of t){const t=ze(e,n);void 0!==t&&o.push(t)}return o.length>0?Promise.all(o).then((()=>{})):void 0}function Le(e,n){const t=e.getBindingsFromModule(n);return Je(e,t)}function Qe(e,n){const t=e.getBindings(n);return Je(e,t)}export{g as ActivationsService,m as BindingService,x as ClassElementMetadataKind,v as DeactivationsService,c as bindingScopeValues,a as bindingTypeValues,h as decorate,$ as getClassMetadata,N as inject,G as injectFromBase,K as injectable,H as multiInject,Q as named,X as optional,pe as plan,Y as postConstruct,Z as preDestroy,Ne as resolve,Le as resolveModuleDeactivations,Qe as resolveServiceDeactivations,_ as tagged,te as unmanaged};
//# sourceMappingURL=index.js.map

@@ -27,3 +27,3 @@ {

"rollup": "4.30.1",
"ts-loader": "9.5.1",
"ts-loader": "9.5.2",
"ts-jest": "29.2.5",

@@ -66,3 +66,3 @@ "ts-node": "10.9.2",

},
"version": "2.2.0",
"version": "3.0.0",
"scripts": {

@@ -69,0 +69,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

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