@shellicar/core-di 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  > A basic dependency injection library for TypeScript
4
4
 
5
- [![npm package](https://img.shields.io/npm/v/@shellicar/core-di.svg)](https://npmjs.com/package/@shellicar/core-di)
6
- [![build status](https://github.com/shellicar/core-di/actions/workflows/node.js.yml/badge.svg)](https://github.com/shellicar/core-di/actions/workflows/node.js.yml)
7
-
8
5
  ## Installation & Quick Start
9
6
 
10
7
  ```sh
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e=Object.defineProperty,t=(t,r)=>e(t,"name",{value:r,configurable:!0}),r=new WeakMap;function s(e,t,r,s){return e.reverse().forEach((e=>{s=e(t,r,s)||s})),s}function i(e,t){return e.reverse().forEach((e=>{const r=e(t);r&&(t=r)})),t}function o(e,t,r,o){if(!Array.isArray(e)||0===e.length)throw new TypeError;return void 0!==r?s(e,t,r,o):"function"==typeof t?i(e,t):void 0}function n(e,t){return r.get(e)&&r.get(e).get(t)}function c(e,t,r){if(void 0===t)throw new TypeError;const s=n(t,r);return s&&s.get(e)}function a(e,t){const s=r.get(e)||new Map;r.set(e,s);const i=s.get(t)||new Map;return s.set(t,i),i}function l(e,t,r,s){if(s&&!["string","symbol"].includes(typeof s))throw new TypeError;(n(r,s)||a(r,s)).set(e,t)}function p(e,t,r){return c(e,t,r)?c(e,t,r):Object.getPrototypeOf(t)?p(e,Object.getPrototypeOf(t),r):void 0}function d(e,r){return t((function(t,s){l(e,r,t,s)}),"decorator")}function h(e,t,r){return p(e,t,r)}function g(e,t,r){return c(e,t,r)}function u(e,t,r){return!!c(e,t,r)}function f(e,t,r){return!!p(e,t,r)}function v(e,t,r,s){l(e,t,r,s)}t(s,"decorateProperty"),t(i,"decorateConstructor"),t(o,"decorate"),t(n,"getMetadataMap"),t(c,"ordinaryGetOwnMetadata"),t(a,"createMetadataMap"),t(l,"ordinaryDefineOwnMetadata"),t(p,"ordinaryGetMetadata"),t(d,"metadata"),t(h,"getMetadata"),t(g,"getOwnMetadata"),t(u,"hasOwnMetadata"),t(f,"hasMetadata"),t(v,"defineMetadata");var S={decorate:o,defineMetadata:v,getMetadata:h,getOwnMetadata:g,hasMetadata:f,hasOwnMetadata:u,metadata:d};Object.assign(Reflect,S);var m=(e=>(e.Resolve="RESOLVE",e.Transient="TRANSIENT",e.Scoped="SCOPED",e.Singleton="SINGLETON",e))(m||{}),w=(e=>(e[e.Debug=0]="Debug",e[e.Info=1]="Info",e[e.Warn=2]="Warn",e[e.Error=3]="Error",e[e.None=4]="None",e))(w||{}),E=(e=>(e.Error="ERROR",e.LastRegistered="LAST_REGISTERED",e))(E||{}),M={registrationMode:"ERROR",logLevel:2},O=class extends Error{static{t(this,"ServiceError")}},y=class extends O{static{t(this,"UnregisteredServiceError")}name="UnregisteredServiceError";constructor(e){super(`Resolving service that has not been registered: ${e.name}`),Object.setPrototypeOf(this,new.target.prototype)}},I=class extends O{static{t(this,"MultipleRegistrationError")}name="MultipleRegistrationError";constructor(e){super(`Multiple services have been registered: ${e.name}`),Object.setPrototypeOf(this,new.target.prototype)}},x=class extends O{constructor(e,t){super(`Error creating service: ${e.name}`),this.innerError=t,Object.setPrototypeOf(this,new.target.prototype)}static{t(this,"ServiceCreationError")}name="ServiceCreationError"},R=class extends O{static{t(this,"SelfDependencyError")}name="SelfDependencyError";constructor(){super("Service depending on itself"),Object.setPrototypeOf(this,new.target.prototype)}},L=class extends O{static{t(this,"ScopedSingletonRegistrationError")}name="ScopedSingletonRegistrationError";constructor(){super("Cannot register a singleton in a scoped service collection"),Object.setPrototypeOf(this,new.target.prototype)}},b=class{constructor(e,t,r){this.identifiers=e,this.isScoped=t,this.addService=r}static{t(this,"ServiceBuilder")}descriptor;to(e,t){this.descriptor=this.createDescriptor(t,e);for(const e of this.identifiers)this.addService(e,this.descriptor);return this}createDescriptor(e,t){const r=e??(()=>new t);return{implementation:t,createInstance:r,lifetime:"RESOLVE"}}singleton(){if(this.isScoped)throw new L;return this.ensureDescriptor().lifetime="SINGLETON",this}scoped(){return this.ensureDescriptor().lifetime="SCOPED",this}transient(){return this.ensureDescriptor().lifetime="TRANSIENT",this}ensureDescriptor(){if(!this.descriptor)throw new Error("Must call to() before setting lifetime");return this.descriptor}},D=class{static{t(this,"IDisposable")}},P=class{static{t(this,"IServiceModule")}},C=class{static{t(this,"IResolutionScope")}},N=class extends C{static{t(this,"IScopedProvider")}},T=class extends C{static{t(this,"IServiceProvider")}},j=class{static{t(this,"IServiceCollection")}},A=class{static{t(this,"ILifetimeBuilder")}},F=class{static{t(this,"IServiceBuilder")}},G=class{constructor(e,t){this.singletons=e,this.scoped=t}static{t(this,"ResolutionContext")}transient=new Map;getFromLifetime(e,t){const r=this.getMapForLifetime(t);return r?.get(e)}setForLifetime(e,t,r){const s=this.getMapForLifetime(r);s?.set(e,t)}getMapForLifetime(e){return{SINGLETON:this.singletons,SCOPED:this.scoped,RESOLVE:this.transient}[e]}},B="design:dependencies",U=t(((e,t)=>Reflect.getMetadata(e,t)),"getMetadata"),V=t(((e,t,r)=>Reflect.defineMetadata(e,t,r)),"defineMetadata"),W=class e{constructor(e,t,r=new Map){this.logger=e,this.Services=t,this.singletons=r}static{t(this,"ServiceProvider")}scoped=new Map;created=[];[Symbol.dispose](){for(const e of this.created)e[Symbol.dispose]()}resolveInternal(e,t){let r=t.getFromLifetime(e.implementation,e.lifetime);return null==r&&(r=this.createInstance(e,t)),r}resolveAll(e,t){return this.Services.get(e).map((e=>this.resolveInternal(e,t??new G(this.singletons,this.scoped))))}resolve(e,t){if(e.prototype===C.prototype||e.prototype===N.prototype||e.prototype===T.prototype)return this;const r=this.getSingleDescriptor(e);return this.resolveInternal(r,t??new G(this.singletons,this.scoped))}getSingleDescriptor(e){const t=this.Services.get(e);if(0===t.length)throw new y(e);if(t.length>1&&"ERROR"===this.Services.options.registrationMode)throw new I(e);return t[t.length-1]}createInstance(e,t){const r=this.createInstanceInternal(e,t);return this.setDependencies(e.implementation,r,t),t.setForLifetime(e.implementation,r,e.lifetime),r}wrapContext(e){return{resolve:t((t=>this.resolve(t,e)),"resolve"),resolveAll:t((t=>this.resolveAll(t,e)),"resolveAll")}}createInstanceInternal(e,t){let r;try{r=e.createInstance(this.wrapContext(t))}catch(t){throw this.logger.error(t),new x(e.implementation,t)}return"SINGLETON"!==e.lifetime&&Symbol.dispose in r&&this.created.push(r),r}createScope(){return new e(this.logger,this.Services.clone(!0),this.singletons)}setDependencies(e,t,r){const s=U(B,e)??{};this.logger.debug("Dependencies",e.name,s);for(const[i,o]of Object.entries(s)){if(o===e)throw new R;{this.logger.debug("Resolving",o.name,"for",e.name);const s=this.resolve(o,r);t[i]=s}}return t}},$=class e{constructor(e,t,r,s=new Map){this.logger=e,this.options=t,this.isScoped=r,this.services=s}static{t(this,"ServiceCollection")}registerModules(...e){for(const t of e){(new t).registerServices(this)}}get(e){return this.services.get(e)??[]}overrideLifetime(e,t){for(const r of this.get(e))r.lifetime=t}register(...e){return new b(e,this.isScoped,((e,t)=>this.addService(e,t)))}addService(e,t){this.logger.info("Adding service",{identifier:e.name,descriptor:t});let r=this.services.get(e);null==r&&(r=[],this.services.set(e,r)),r.push(t)}clone(t){const r=new Map;for(const[e,t]of this.services){const s=t.map((e=>({...e})));r.set(e,s)}return new e(this.logger,this.options,!0===t,r)}buildProvider(){return new W(this.logger,this.clone())}},k=class{static{t(this,"ILogger")}debug(e,...t){}info(e,...t){}error(e,...t){}warn(e,...t){}},_=class extends k{constructor(e){super(),this.options=e}static{t(this,"ConsoleLogger")}debug(e,...t){this.options.logLevel<=0&&console.debug(e,...t)}info(e,...t){this.options.logLevel<=1&&console.info(e,...t)}warn(e,...t){this.options.logLevel<=2&&console.warn(e,...t)}error(e,...t){this.options.logLevel<=3&&console.error(e,...t)}},q=t((e=>({...M,...e})),"mergeOptions"),z=t((e=>{const t=q(e),r=t.logger??new _(t);return new $(r,t,!1)}),"createServiceCollection"),H=t(((e,t,r,s)=>{let i=U(e,t);void 0===i&&(i={},V(e,i,t)),i[r]=s}),"tagProperty"),J=t((e=>(t,r)=>function(t){const s=this.constructor;return H(B,s,r.name,e),t}),"dependsOn");exports.DefaultServiceCollectionOptions=M,exports.IDisposable=D,exports.ILifetimeBuilder=A,exports.ILogger=k,exports.IResolutionScope=C,exports.IScopedProvider=N,exports.IServiceBuilder=F,exports.IServiceCollection=j,exports.IServiceModule=P,exports.IServiceProvider=T,exports.Lifetime=m,exports.LogLevel=w,exports.MultipleRegistrationError=I,exports.ResolveMultipleMode=E,exports.ScopedSingletonRegistrationError=L,exports.SelfDependencyError=R,exports.ServiceCreationError=x,exports.ServiceError=O,exports.UnregisteredServiceError=y,exports.createServiceCollection=z,exports.dependsOn=J;//# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/@abraham+reflection@0.12.0/node_modules/@abraham/reflection/src/index.ts","../src/enums.ts","../src/defaults.ts","../src/errors.ts","../src/private/ServiceBuilder.ts","../src/interfaces.ts","../src/private/ResolutionContext.ts","../src/private/constants.ts","../src/private/metadata.ts","../src/private/ServiceProvider.ts","../src/private/ServiceCollection.ts","../src/logger.ts","../src/private/consoleLogger.ts","../src/createServiceCollection.ts","../src/dependsOn.ts"],"names":["Lifetime","LogLevel","ResolveMultipleMode","getMetadata","defineMetadata","metadata"],"mappings":";;;;AAUA,IAAM,QAAA,uBAAe,OAAO,EAAA;AAE5B,SAAS,gBACP,CAAA,UAAA,EACA,MACA,EAAA,WAAA,EACA,UAA+B,EAAA;AAE/B,EAAA,UAAA,CAAW,OAAO,EAAA,CAAG,OAAQ,CAAA,CAAC,SAA8B,KAAA;AAC1D,IAAA,UAAA,GAAa,SAAU,CAAA,MAAA,EAAQ,WAAa,EAAA,UAAU,CAAK,IAAA,UAAA;GAC5D,CAAA;AACD,EAAO,OAAA,UAAA;AACT;A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AAgB,CAAA;AAAA;AAExD,EAAA,QAAA,CAAS,IAAI,CAAI,GAAA,UAAA;AACnB,CAPoB,EAAA,aAAA,CAAA;AAcP,IAAA,SAAA,2BAAmC,UAAqC,KAAA;AACnF,EAAO,OAAA,CAAC,OAAkB,GAAoC,KAAA;AAC5D,IAAA,OAAO,SAAwB,YAAmB,EAAA;AAChD,MAAA,MAAM,SAAS,IAAK,CAAA,WAAA;AACpB,MAAA,WAAA,CAAY,qBAAuB,EAAA,MAAA,EAAQ,GAAI,CAAA,IAAA,EAAM,UAAU,CAAA;AAC/D,MAAO,OAAA,YAAA;AAAA,KACT;AAAA,GACF;AACF,CARyB,EAAA,WAAA","file":"index.cjs","sourcesContent":["export type Decorator = ClassDecorator | MemberDecorator;\nexport type MemberDecorator = <T>(\n target: Target,\n propertyKey: PropertyKey,\n descriptor?: TypedPropertyDescriptor<T>,\n) => TypedPropertyDescriptor<T> | void;\nexport type MetadataKey = string | symbol;\nexport type PropertyKey = string | symbol;\nexport type Target = object | Function;\n\nconst Metadata = new WeakMap();\n\nfunction decorateProperty(\n decorators: MemberDecorator[],\n target: Target,\n propertyKey: PropertyKey,\n descriptor?: PropertyDescriptor,\n): PropertyDescriptor | undefined {\n decorators.reverse().forEach((decorator: MemberDecorator) => {\n descriptor = decorator(target, propertyKey, descriptor) || descriptor;\n });\n return descriptor;\n}\n\nfunction decorateConstructor(\n decorators: ClassDecorator[],\n target: Function,\n): Function {\n decorators.reverse().forEach((decorator: ClassDecorator) => {\n const decorated = decorator(target);\n if (decorated) {\n target = decorated;\n }\n });\n return target;\n}\n\nexport function decorate(\n decorators: ClassDecorator[],\n target: Function,\n): Function;\nexport function decorate(\n decorators: MemberDecorator[],\n target: object,\n propertyKey?: PropertyKey,\n attributes?: PropertyDescriptor,\n): PropertyDescriptor | undefined;\nexport function decorate(\n decorators: Decorator[],\n target: Target,\n propertyKey?: PropertyKey,\n attributes?: PropertyDescriptor,\n): Function | PropertyDescriptor | undefined {\n if (!Array.isArray(decorators) || decorators.length === 0) {\n throw new TypeError();\n }\n\n if (propertyKey !== undefined) {\n return decorateProperty(\n decorators as MemberDecorator[],\n target,\n propertyKey,\n attributes,\n );\n }\n\n if (typeof target === 'function') {\n return decorateConstructor(decorators as ClassDecorator[], target);\n }\n\n return;\n}\n\nfunction getMetadataMap<MetadataValue>(\n target: Target,\n propertyKey?: PropertyKey,\n): Map<MetadataKey, MetadataValue> | undefined {\n return Metadata.get(target) && Metadata.get(target).get(propertyKey);\n}\n\nfunction ordinaryGetOwnMetadata<MetadataValue>(\n metadataKey: MetadataKey,\n target: Target,\n propertyKey?: PropertyKey,\n): MetadataValue | undefined {\n if (target === undefined) {\n throw new TypeError();\n }\n const metadataMap = getMetadataMap<MetadataValue>(target, propertyKey);\n return metadataMap && metadataMap.get(metadataKey);\n}\n\nfunction createMetadataMap<MetadataValue>(\n target: Target,\n propertyKey?: PropertyKey,\n): Map<MetadataKey, MetadataValue> {\n const targetMetadata =\n Metadata.get(target) ||\n new Map<PropertyKey | undefined, Map<MetadataKey, MetadataValue>>();\n Metadata.set(target, targetMetadata);\n const metadataMap =\n targetMetadata.get(propertyKey) || new Map<MetadataKey, MetadataValue>();\n targetMetadata.set(propertyKey, metadataMap);\n return metadataMap;\n}\n\nfunction ordinaryDefineOwnMetadata<MetadataValue>(\n metadataKey: MetadataKey,\n metadataValue: MetadataValue,\n target: Target,\n propertyKey?: PropertyKey,\n): void {\n if (propertyKey && !['string', 'symbol'].includes(typeof propertyKey)) {\n throw new TypeError();\n }\n\n (\n getMetadataMap<MetadataValue>(target, propertyKey) ||\n createMetadataMap<MetadataValue>(target, propertyKey)\n ).set(metadataKey, metadataValue);\n}\n\nfunction ordinaryGetMetadata<MetadataValue>(\n metadataKey: MetadataKey,\n target: Target,\n propertyKey?: PropertyKey,\n): MetadataValue | undefined {\n return ordinaryGetOwnMetadata<MetadataValue>(metadataKey, target, propertyKey)\n ? ordinaryGetOwnMetadata<MetadataValue>(metadataKey, target, propertyKey)\n : Object.getPrototypeOf(target)\n ? ordinaryGetMetadata(\n metadataKey,\n Object.getPrototypeOf(target),\n propertyKey,\n )\n : undefined;\n}\n\nexport function metadata<MetadataValue>(\n metadataKey: MetadataKey,\n metadataValue: MetadataValue,\n) {\n return function decorator(target: Target, propertyKey?: PropertyKey): void {\n ordinaryDefineOwnMetadata<MetadataValue>(\n metadataKey,\n metadataValue,\n target,\n propertyKey,\n );\n };\n}\n\nexport function getMetadata<MetadataValue>(\n metadataKey: MetadataKey,\n target: Target,\n propertyKey?: PropertyKey,\n): MetadataValue | undefined {\n return ordinaryGetMetadata<MetadataValue>(metadataKey, target, propertyKey);\n}\n\nexport function getOwnMetadata<MetadataValue>(\n metadataKey: MetadataKey,\n target: Target,\n propertyKey?: PropertyKey,\n): MetadataValue | undefined {\n return ordinaryGetOwnMetadata<MetadataValue>(\n metadataKey,\n target,\n propertyKey,\n );\n}\n\nexport function hasOwnMetadata(\n metadataKey: MetadataKey,\n target: Target,\n propertyKey?: PropertyKey,\n): boolean {\n return !!ordinaryGetOwnMetadata(metadataKey, target, propertyKey);\n}\n\nexport function hasMetadata(\n metadataKey: MetadataKey,\n target: Target,\n propertyKey?: PropertyKey,\n): boolean {\n return !!ordinaryGetMetadata(metadataKey, target, propertyKey);\n}\n\nexport function defineMetadata<MetadataValue>(\n metadataKey: MetadataKey,\n metadataValue: MetadataValue,\n target: Target,\n propertyKey?: PropertyKey,\n): void {\n ordinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);\n}\n\nexport const Reflection = {\n decorate,\n defineMetadata,\n getMetadata,\n getOwnMetadata,\n hasMetadata,\n hasOwnMetadata,\n metadata,\n};\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Reflect {\n let decorate: typeof Reflection.decorate;\n let defineMetadata: typeof Reflection.defineMetadata;\n let getMetadata: typeof Reflection.getMetadata;\n let getOwnMetadata: typeof Reflection.getOwnMetadata;\n let hasOwnMetadata: typeof Reflection.hasOwnMetadata;\n let hasMetadata: typeof Reflection.hasMetadata;\n let metadata: typeof Reflection.metadata;\n }\n}\n\nObject.assign(Reflect, Reflection);\n","export enum Lifetime {\n Resolve = 'RESOLVE',\n Transient = 'TRANSIENT',\n Scoped = 'SCOPED',\n Singleton = 'SINGLETON',\n}\n\nexport enum LogLevel {\n Debug = 0,\n Info = 1,\n Warn = 2,\n Error = 3,\n None = 4,\n}\n\nexport enum ResolveMultipleMode {\n Error = 'ERROR',\n LastRegistered = 'LAST_REGISTERED',\n}\n","import { LogLevel, ResolveMultipleMode } from './enums';\nimport type { ServiceCollectionOptions } from './types';\n\nexport const DefaultServiceCollectionOptions: ServiceCollectionOptions = {\n registrationMode: ResolveMultipleMode.Error,\n logLevel: LogLevel.Warn,\n};\n","import type { ServiceIdentifier } from './types';\n\nexport abstract class ServiceError extends Error {}\n\nexport class UnregisteredServiceError<T extends object> extends ServiceError {\n name = 'UnregisteredServiceError';\n constructor(identifier: ServiceIdentifier<T>) {\n super(`Resolving service that has not been registered: ${identifier.name}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class MultipleRegistrationError<T extends object> extends ServiceError {\n name = 'MultipleRegistrationError';\n constructor(identifier: ServiceIdentifier<T>) {\n super(`Multiple services have been registered: ${identifier.name}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class ServiceCreationError<T extends object> extends ServiceError {\n name = 'ServiceCreationError';\n constructor(\n identifier: ServiceIdentifier<T>,\n public readonly innerError: any,\n ) {\n super(`Error creating service: ${identifier.name}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class SelfDependencyError extends ServiceError {\n name = 'SelfDependencyError';\n constructor() {\n super('Service depending on itself');\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class ScopedSingletonRegistrationError extends ServiceError {\n name = 'ScopedSingletonRegistrationError';\n constructor() {\n super('Cannot register a singleton in a scoped service collection');\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import { Lifetime } from '../enums';\nimport { ScopedSingletonRegistrationError } from '../errors';\nimport type { ILifetimeBuilder, IServiceBuilder } from '../interfaces';\nimport type { InstanceFactory, ServiceDescriptor, ServiceIdentifier, ServiceImplementation, SourceType } from '../types';\n\nexport class ServiceBuilder<T extends SourceType> implements IServiceBuilder<T> {\n private descriptor: ServiceDescriptor<T> | undefined;\n\n constructor(\n private readonly identifiers: ServiceIdentifier<T>[],\n private readonly isScoped: boolean,\n private readonly addService: (identifier: ServiceIdentifier<T>, descriptor: ServiceDescriptor<T>) => void,\n ) {}\n\n public to(implementation: ServiceImplementation<T>, factory?: InstanceFactory<T>): ILifetimeBuilder {\n this.descriptor = this.createDescriptor(factory, implementation);\n\n for (const identifier of this.identifiers) {\n this.addService(identifier, this.descriptor);\n }\n return this;\n }\n\n private createDescriptor(factory: InstanceFactory<T> | undefined, implementation: ServiceImplementation<T>): ServiceDescriptor<T> {\n const createInstance = factory ?? (() => new implementation());\n\n return {\n implementation,\n createInstance,\n lifetime: Lifetime.Resolve,\n };\n }\n\n public singleton(): this {\n if (this.isScoped) {\n throw new ScopedSingletonRegistrationError();\n }\n this.ensureDescriptor().lifetime = Lifetime.Singleton;\n return this;\n }\n\n public scoped(): this {\n this.ensureDescriptor().lifetime = Lifetime.Scoped;\n return this;\n }\n\n public transient(): this {\n this.ensureDescriptor().lifetime = Lifetime.Transient;\n return this;\n }\n\n private ensureDescriptor(): ServiceDescriptor<T> {\n if (!this.descriptor) {\n throw new Error('Must call to() before setting lifetime');\n }\n return this.descriptor;\n }\n}\n","import type { Lifetime } from './enums';\nimport { ResolveMultipleMode } from './enums';\nimport type { EnsureObject, ServiceBuilderOptions, ServiceCollectionOptions, ServiceDescriptor, ServiceIdentifier, ServiceModuleType, SourceType, UnionToIntersection } from './types';\n\nexport abstract class IDisposable {\n public abstract [Symbol.dispose](): void;\n}\n\nexport abstract class IServiceModule {\n public abstract registerServices(services: IServiceCollection): void;\n}\n\nexport abstract class IResolutionScope {\n /**\n * Resolves a single implementation for the given identifier.\n * @template T The type of service to resolve\n * @param identifier The service identifier\n * @returns The resolved instance\n * @throws {MultipleRegistrationError} When multiple implementations exist (unless {@link ServiceCollectionOptions.registrationMode} is set to {@link ResolveMultipleMode.LastRegistered}).\n * @throws {UnregisteredServiceError} When no implementation exists\n */\n public abstract resolve<T extends SourceType>(identifier: ServiceIdentifier<T>): T;\n\n /**\n * Resolves all implementations for the given identifier.\n * @template T The type of service to resolve\n * @param identifier The service identifier\n * @returns Array of resolved instances\n */\n public abstract resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>): T[];\n}\n\nexport abstract class IScopedProvider extends IResolutionScope implements IDisposable {\n public abstract readonly Services: IServiceCollection;\n public abstract [Symbol.dispose](): void;\n}\n\nexport abstract class IServiceProvider extends IResolutionScope {\n public abstract readonly Services: IServiceCollection;\n public abstract createScope(): IScopedProvider;\n}\n\nexport abstract class IServiceCollection {\n public abstract readonly options: ServiceCollectionOptions;\n public abstract get<T extends SourceType>(identifier: ServiceIdentifier<T>): ServiceDescriptor<T>[];\n public abstract register<Types extends SourceType[]>(...identifiers: { [K in keyof Types]: ServiceIdentifier<Types[K]> }): IServiceBuilder<EnsureObject<UnionToIntersection<Types[number]>>>;\n public abstract registerModules(...modules: ServiceModuleType[]): void;\n public abstract overrideLifetime<T extends SourceType>(identifier: ServiceIdentifier<T>, lifetime: Lifetime): void;\n public abstract buildProvider(): IServiceProvider;\n public abstract clone(): IServiceCollection;\n public abstract clone(scoped: true): IServiceCollection;\n}\n\nexport abstract class ILifetimeBuilder {\n public abstract singleton(): ILifetimeBuilder;\n public abstract scoped(): ILifetimeBuilder;\n public abstract transient(): ILifetimeBuilder;\n}\n\nexport abstract class IServiceBuilder<T extends SourceType> {\n public abstract to: ServiceBuilderOptions<T>;\n}\n","import { Lifetime } from '../enums';\nimport type { ServiceImplementation, SourceType } from '../types';\n\nexport class ResolutionContext {\n constructor(\n private readonly singletons: Map<ServiceImplementation<any>, any>,\n private readonly scoped: Map<ServiceImplementation<any>, any>,\n ) {}\n\n private readonly transient = new Map<ServiceImplementation<any>, any>();\n\n public getFromLifetime<T extends SourceType>(implementation: ServiceImplementation<T>, lifetime: Lifetime): T {\n const map = this.getMapForLifetime(lifetime);\n return map?.get(implementation);\n }\n\n public setForLifetime<T extends SourceType>(implementation: ServiceImplementation<T>, instance: T, lifetime: Lifetime): void {\n const map = this.getMapForLifetime(lifetime);\n map?.set(implementation, instance);\n }\n\n private getMapForLifetime(lifetime: Lifetime) {\n const map: Partial<Record<Lifetime, Map<ServiceImplementation<any>, any>>> = {\n [Lifetime.Singleton]: this.singletons,\n [Lifetime.Scoped]: this.scoped,\n [Lifetime.Resolve]: this.transient,\n };\n return map[lifetime];\n }\n}\n","export const DesignDependenciesKey = 'design:dependencies';\n","import '@abraham/reflection';\nimport type { MetadataType, SourceType } from '../types';\n\nexport const getMetadata = <T extends SourceType>(key: string, obj: object): MetadataType<T> | undefined => Reflect.getMetadata(key, obj);\nexport const defineMetadata = <T extends SourceType>(key: string, metadata: MetadataType<T>, obj: object) => Reflect.defineMetadata(key, metadata, obj);\n","import { Lifetime } from '../enums';\nimport { ResolveMultipleMode } from '../enums';\nimport { MultipleRegistrationError, SelfDependencyError, ServiceCreationError, UnregisteredServiceError } from '../errors';\nimport { type IDisposable, IResolutionScope, IScopedProvider, type IServiceCollection } from '../interfaces';\nimport { IServiceProvider } from '../interfaces';\nimport type { ILogger } from '../logger';\nimport type { ServiceDescriptor, ServiceIdentifier, ServiceImplementation, SourceType } from '../types';\nimport { ResolutionContext } from './ResolutionContext';\nimport { DesignDependenciesKey } from './constants';\nimport { getMetadata } from './metadata';\n\nexport class ServiceProvider implements IServiceProvider, IScopedProvider {\n private scoped = new Map<ServiceImplementation<any>, any>();\n private created: IDisposable[] = [];\n\n constructor(\n private readonly logger: ILogger,\n public readonly Services: IServiceCollection,\n private readonly singletons = new Map<ServiceImplementation<any>, any>(),\n ) {}\n\n [Symbol.dispose]() {\n for (const x of this.created) {\n x[Symbol.dispose]();\n }\n }\n\n private resolveInternal<T extends SourceType>(descriptor: ServiceDescriptor<T>, context: ResolutionContext): T {\n let instance = context.getFromLifetime(descriptor.implementation, descriptor.lifetime);\n if (instance == null) {\n instance = this.createInstance(descriptor, context);\n }\n return instance;\n }\n\n public resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>, context?: ResolutionContext): T[] {\n const descriptors = this.Services.get(identifier);\n return descriptors.map((descriptor) => this.resolveInternal<T>(descriptor, context ?? new ResolutionContext(this.singletons, this.scoped)));\n }\n\n public resolve<T extends SourceType>(identifier: ServiceIdentifier<T>, context?: ResolutionContext): T {\n if (identifier.prototype === IResolutionScope.prototype || identifier.prototype === IScopedProvider.prototype || identifier.prototype === IServiceProvider.prototype) {\n return this as IResolutionScope & IScopedProvider & IServiceProvider as T;\n }\n\n const descriptor = this.getSingleDescriptor(identifier);\n return this.resolveInternal(descriptor, context ?? new ResolutionContext(this.singletons, this.scoped));\n }\n\n private getSingleDescriptor<T extends SourceType>(identifier: ServiceIdentifier<T>) {\n const descriptors = this.Services.get(identifier);\n if (descriptors.length === 0) {\n throw new UnregisteredServiceError(identifier);\n }\n\n if (descriptors.length > 1) {\n if (this.Services.options.registrationMode === ResolveMultipleMode.Error) {\n throw new MultipleRegistrationError(identifier);\n }\n }\n const descriptor = descriptors[descriptors.length - 1];\n return descriptor;\n }\n\n private createInstance<T extends SourceType>(descriptor: ServiceDescriptor<T>, context: ResolutionContext): T {\n const instance = this.createInstanceInternal(descriptor, context);\n this.setDependencies(descriptor.implementation, instance, context);\n context.setForLifetime(descriptor.implementation, instance, descriptor.lifetime);\n return instance;\n }\n\n private wrapContext(context: ResolutionContext): IResolutionScope {\n const resolve = (identifier: ServiceIdentifier<any>) => this.resolve(identifier, context);\n const resolveAll = (identifier: ServiceIdentifier<any>) => this.resolveAll(identifier, context);\n\n return {\n resolve,\n resolveAll,\n };\n }\n\n private createInstanceInternal<T extends SourceType>(descriptor: ServiceDescriptor<T>, context: ResolutionContext) {\n let instance: T | undefined;\n try {\n instance = descriptor.createInstance(this.wrapContext(context));\n } catch (err) {\n this.logger.error(err);\n throw new ServiceCreationError(descriptor.implementation, err);\n }\n if (descriptor.lifetime !== Lifetime.Singleton && Symbol.dispose in instance) {\n this.created.push(instance as IDisposable);\n }\n return instance;\n }\n\n public createScope(): IScopedProvider {\n return new ServiceProvider(this.logger, this.Services.clone(true), this.singletons);\n }\n\n private setDependencies<T extends SourceType>(implementation: ServiceImplementation<T>, instance: T, context: ResolutionContext): T {\n const dependencies = getMetadata<T>(DesignDependenciesKey, implementation) ?? {};\n this.logger.debug('Dependencies', implementation.name, dependencies);\n for (const [key, identifier] of Object.entries(dependencies)) {\n if (identifier !== implementation) {\n this.logger.debug('Resolving', identifier.name, 'for', implementation.name);\n const dep = this.resolve(identifier, context);\n (instance as Record<string, T>)[key] = dep;\n } else {\n throw new SelfDependencyError();\n }\n }\n return instance;\n }\n}\n","import type { Lifetime } from '../enums';\nimport type { IServiceBuilder, IServiceCollection, IServiceProvider } from '../interfaces';\nimport type { ILogger } from '../logger';\nimport type { EnsureObject, ServiceCollectionOptions, ServiceDescriptor, ServiceIdentifier, ServiceModuleType, SourceType, UnionToIntersection } from '../types';\nimport { ServiceBuilder } from './ServiceBuilder';\nimport { ServiceProvider } from './ServiceProvider';\n\nexport class ServiceCollection implements IServiceCollection {\n constructor(\n private readonly logger: ILogger,\n public readonly options: ServiceCollectionOptions,\n private readonly isScoped: boolean,\n private readonly services = new Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>(),\n ) {}\n\n public registerModules(...modules: ServiceModuleType[]): void {\n for (const x of modules) {\n const module = new x();\n module.registerServices(this);\n }\n }\n\n get<T extends SourceType>(key: ServiceIdentifier<T>): ServiceDescriptor<T>[] {\n return this.services.get(key) ?? [];\n }\n\n public overrideLifetime<T extends SourceType>(identifier: ServiceIdentifier<T>, lifetime: Lifetime): void {\n for (const descriptor of this.get(identifier)) {\n descriptor.lifetime = lifetime;\n }\n }\n\n register<Types extends SourceType[]>(...identifiers: { [K in keyof Types]: ServiceIdentifier<Types[K]> }): IServiceBuilder<EnsureObject<UnionToIntersection<Types[number]>>> {\n return new ServiceBuilder(identifiers, this.isScoped, (identifier, descriptor) => this.addService(identifier, descriptor));\n }\n\n private addService<T extends SourceType>(identifier: ServiceIdentifier<T>, descriptor: ServiceDescriptor<T>) {\n this.logger.info('Adding service', { identifier: identifier.name, descriptor });\n let existing = this.services.get(identifier);\n if (existing == null) {\n existing = [];\n this.services.set(identifier, existing);\n }\n existing.push(descriptor);\n }\n\n public clone(scoped?: unknown): IServiceCollection {\n const clonedMap = new Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>();\n for (const [key, descriptors] of this.services) {\n const clonedDescriptors = descriptors.map((descriptor) => ({ ...descriptor }));\n clonedMap.set(key, clonedDescriptors);\n }\n\n return new ServiceCollection(this.logger, this.options, scoped === true, clonedMap);\n }\n\n public buildProvider(): IServiceProvider {\n return new ServiceProvider(this.logger, this.clone());\n }\n}\n","export abstract class ILogger {\n public debug(_message?: any, ..._optionalParams: any[]) {}\n public info(_message?: any, ..._optionalParams: any[]) {}\n public error(_message?: any, ..._optionalParams: any[]) {}\n public warn(_message?: any, ..._optionalParams: any[]) {}\n}\n","import { LogLevel } from '../enums';\nimport { ILogger } from '../logger';\nimport type { ServiceCollectionOptions } from '../types';\n\nexport class ConsoleLogger extends ILogger {\n constructor(private readonly options: ServiceCollectionOptions) {\n super();\n }\n\n public override debug(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Debug) {\n console.debug(message, ...optionalParams);\n }\n }\n\n public override info(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Info) {\n console.info(message, ...optionalParams);\n }\n }\n\n public override warn(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Warn) {\n console.warn(message, ...optionalParams);\n }\n }\n\n public override error(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Error) {\n console.error(message, ...optionalParams);\n }\n }\n}\n","import { DefaultServiceCollectionOptions } from './defaults';\nimport type { IServiceCollection } from './interfaces';\nimport { ServiceCollection } from './private/ServiceCollection';\nimport { ConsoleLogger } from './private/consoleLogger';\nimport type { ServiceCollectionOptions } from './types';\n\nconst mergeOptions = (options: Partial<ServiceCollectionOptions> | undefined): ServiceCollectionOptions => ({\n ...DefaultServiceCollectionOptions,\n ...options,\n});\n\n/**\n * Creates a service collection with the (optionally) provided options\n * @param options - Optional configuration for the service collection.\n * @defaultValue Default options are taken from {@link DefaultServiceCollectionOptions}.\n */\nexport const createServiceCollection = (options?: Partial<ServiceCollectionOptions>): IServiceCollection => {\n const mergedOptions = mergeOptions(options);\n const logger = mergedOptions.logger ?? new ConsoleLogger(mergedOptions);\n return new ServiceCollection(logger, mergedOptions, false);\n};\n","import { IResolutionScope, IScopedProvider, IServiceProvider } from './interfaces';\nimport { DesignDependenciesKey } from './private/constants';\nimport { defineMetadata, getMetadata } from './private/metadata';\nimport type { ServiceIdentifier, SourceType } from './types';\n\nconst tagProperty = <T extends SourceType>(metadataKey: string, annotationTarget: object, name: string | symbol, identifier: ServiceIdentifier<T>) => {\n let existing = getMetadata<T>(metadataKey, annotationTarget);\n if (existing === undefined) {\n existing = {};\n defineMetadata(metadataKey, existing, annotationTarget);\n }\n existing[name] = identifier;\n};\n\n/**\n * declares a dependency, use on a class field.\n * Can also depend on {@link IServiceProvider}, {@link IResolutionScope}, or {@link IScopedProvider}.\n * @param identifier the identifier to depend on, i.e. the interface\n */\nexport const dependsOn = <T extends SourceType>(identifier: ServiceIdentifier<T>) => {\n return (value: undefined, ctx: ClassFieldDecoratorContext) => {\n return function (this: object, initialValue: any) {\n const target = this.constructor;\n tagProperty(DesignDependenciesKey, target, ctx.name, identifier);\n return initialValue;\n };\n };\n};\n"]}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";require("@abraham/reflection");var e=Object.defineProperty,t=(t,r)=>e(t,"name",{value:r,configurable:!0}),r=(e=>(e.Resolve="RESOLVE",e.Transient="TRANSIENT",e.Scoped="SCOPED",e.Singleton="SINGLETON",e))(r||{}),s=(e=>(e[e.Debug=0]="Debug",e[e.Info=1]="Info",e[e.Warn=2]="Warn",e[e.Error=3]="Error",e[e.None=4]="None",e))(s||{}),i=(e=>(e.Error="ERROR",e.LastRegistered="LAST_REGISTERED",e))(i||{}),o={registrationMode:"ERROR",logLevel:2},n=class extends Error{static{t(this,"ServiceError")}},c=class extends n{static{t(this,"UnregisteredServiceError")}name="UnregisteredServiceError";constructor(e){super(`Resolving service that has not been registered: ${e.name}`),Object.setPrototypeOf(this,new.target.prototype)}},l=class extends n{static{t(this,"MultipleRegistrationError")}name="MultipleRegistrationError";constructor(e){super(`Multiple services have been registered: ${e.name}`),Object.setPrototypeOf(this,new.target.prototype)}},a=class extends n{constructor(e,t){super(`Error creating service: ${e.name}`),this.innerError=t,Object.setPrototypeOf(this,new.target.prototype)}static{t(this,"ServiceCreationError")}name="ServiceCreationError"},p=class extends n{static{t(this,"SelfDependencyError")}name="SelfDependencyError";constructor(){super("Service depending on itself"),Object.setPrototypeOf(this,new.target.prototype)}},h=class extends n{static{t(this,"ScopedSingletonRegistrationError")}name="ScopedSingletonRegistrationError";constructor(){super("Cannot register a singleton in a scoped service collection"),Object.setPrototypeOf(this,new.target.prototype)}},g=class{constructor(e,t,r){this.identifiers=e,this.isScoped=t,this.addService=r}static{t(this,"ServiceBuilder")}descriptor;to(e,t){this.descriptor=this.createDescriptor(t,e);for(const e of this.identifiers)this.addService(e,this.descriptor);return this}createDescriptor(e,t){const r=e??(()=>new t);return{implementation:t,createInstance:r,lifetime:"RESOLVE"}}singleton(){if(this.isScoped)throw new h;return this.ensureDescriptor().lifetime="SINGLETON",this}scoped(){return this.ensureDescriptor().lifetime="SCOPED",this}transient(){return this.ensureDescriptor().lifetime="TRANSIENT",this}ensureDescriptor(){if(!this.descriptor)throw new Error("Must call to() before setting lifetime");return this.descriptor}},d=class{static{t(this,"IDisposable")}},u=class{static{t(this,"IServiceModule")}},v=class{static{t(this,"IResolutionScope")}},S=class extends v{static{t(this,"IScopedProvider")}},f=class extends v{static{t(this,"IServiceProvider")}},m=class{static{t(this,"IServiceCollection")}},E=class{static{t(this,"ILifetimeBuilder")}},I=class{static{t(this,"IServiceBuilder")}},w=class{constructor(e,t){this.singletons=e,this.scoped=t}static{t(this,"ResolutionContext")}transient=new Map;getFromLifetime(e,t){const r=this.getMapForLifetime(t);return r?.get(e)}setForLifetime(e,t,r){const s=this.getMapForLifetime(r);s?.set(e,t)}getMapForLifetime(e){return{SINGLETON:this.singletons,SCOPED:this.scoped,RESOLVE:this.transient}[e]}},x="design:dependencies",R=t(((e,t)=>Reflect.getMetadata(e,t)),"getMetadata"),L=t(((e,t,r)=>Reflect.defineMetadata(e,t,r)),"defineMetadata"),O=class e{constructor(e,t,r=new Map){this.logger=e,this.Services=t,this.singletons=r}static{t(this,"ServiceProvider")}scoped=new Map;created=[];[Symbol.dispose](){for(const e of this.created)e[Symbol.dispose]()}resolveInternal(e,t){let r=t.getFromLifetime(e.implementation,e.lifetime);return null==r&&(r=this.createInstance(e,t)),r}resolveAll(e,t){return this.Services.get(e).map((e=>this.resolveInternal(e,t??new w(this.singletons,this.scoped))))}resolve(e,t){if(e.prototype===v.prototype||e.prototype===S.prototype||e.prototype===f.prototype)return this;const r=this.getSingleDescriptor(e);return this.resolveInternal(r,t??new w(this.singletons,this.scoped))}getSingleDescriptor(e){const t=this.Services.get(e);if(0===t.length)throw new c(e);if(t.length>1&&"ERROR"===this.Services.options.registrationMode)throw new l(e);return t[t.length-1]}createInstance(e,t){const r=this.createInstanceInternal(e,t);return this.setDependencies(e.implementation,r,t),t.setForLifetime(e.implementation,r,e.lifetime),r}wrapContext(e){return{resolve:t((t=>this.resolve(t,e)),"resolve"),resolveAll:t((t=>this.resolveAll(t,e)),"resolveAll")}}createInstanceInternal(e,t){let r;try{r=e.createInstance(this.wrapContext(t))}catch(t){throw this.logger.error(t),new a(e.implementation,t)}return"SINGLETON"!==e.lifetime&&Symbol.dispose in r&&this.created.push(r),r}createScope(){return new e(this.logger,this.Services.clone(!0),this.singletons)}setDependencies(e,t,r){const s=R(x,e)??{};this.logger.debug("Dependencies",e.name,s);for(const[i,o]of Object.entries(s)){if(o===e)throw new p;{this.logger.debug("Resolving",o.name,"for",e.name);const s=this.resolve(o,r);t[i]=s}}return t}},b=class e{constructor(e,t,r,s=new Map){this.logger=e,this.options=t,this.isScoped=r,this.services=s}static{t(this,"ServiceCollection")}registerModules(...e){for(const t of e){(new t).registerServices(this)}}get(e){return this.services.get(e)??[]}overrideLifetime(e,t){for(const r of this.get(e))r.lifetime=t}register(...e){return new g(e,this.isScoped,((e,t)=>this.addService(e,t)))}addService(e,t){this.logger.info("Adding service",{identifier:e.name,descriptor:t});let r=this.services.get(e);null==r&&(r=[],this.services.set(e,r)),r.push(t)}clone(t){const r=new Map;for(const[e,t]of this.services){const s=t.map((e=>({...e})));r.set(e,s)}return new e(this.logger,this.options,!0===t,r)}buildProvider(){return new O(this.logger,this.clone())}},y=class{static{t(this,"ILogger")}debug(e,...t){}info(e,...t){}error(e,...t){}warn(e,...t){}},M=class extends y{constructor(e){super(),this.options=e}static{t(this,"ConsoleLogger")}debug(e,...t){this.options.logLevel<=0&&console.debug(e,...t)}info(e,...t){this.options.logLevel<=1&&console.info(e,...t)}warn(e,...t){this.options.logLevel<=2&&console.warn(e,...t)}error(e,...t){this.options.logLevel<=3&&console.error(e,...t)}},D=t((e=>({...o,...e})),"mergeOptions"),C=t((e=>{const t=D(e),r=t.logger??new M(t);return new b(r,t,!1)}),"createServiceCollection"),P=t(((e,t,r,s)=>{let i=R(e,t);void 0===i&&(i={},L(e,i,t)),i[r]=s}),"tagProperty"),N=t((e=>(t,r)=>function(t){const s=this.constructor;return P(x,s,r.name,e),t}),"dependsOn");exports.DefaultServiceCollectionOptions=o,exports.IDisposable=d,exports.ILifetimeBuilder=E,exports.ILogger=y,exports.IResolutionScope=v,exports.IScopedProvider=S,exports.IServiceBuilder=I,exports.IServiceCollection=m,exports.IServiceModule=u,exports.IServiceProvider=f,exports.Lifetime=r,exports.LogLevel=s,exports.MultipleRegistrationError=l,exports.ResolveMultipleMode=i,exports.ScopedSingletonRegistrationError=h,exports.SelfDependencyError=p,exports.ServiceCreationError=a,exports.ServiceError=n,exports.UnregisteredServiceError=c,exports.createServiceCollection=C,exports.dependsOn=N;//# sourceMappingURL=index.js.map
1
+ var e=Object.defineProperty,t=(t,r)=>e(t,"name",{value:r,configurable:!0}),r=new WeakMap;function s(e,t,r,s){return e.reverse().forEach((e=>{s=e(t,r,s)||s})),s}function i(e,t){return e.reverse().forEach((e=>{const r=e(t);r&&(t=r)})),t}function o(e,t,r,o){if(!Array.isArray(e)||0===e.length)throw new TypeError;return void 0!==r?s(e,t,r,o):"function"==typeof t?i(e,t):void 0}function n(e,t){return r.get(e)&&r.get(e).get(t)}function c(e,t,r){if(void 0===t)throw new TypeError;const s=n(t,r);return s&&s.get(e)}function a(e,t){const s=r.get(e)||new Map;r.set(e,s);const i=s.get(t)||new Map;return s.set(t,i),i}function l(e,t,r,s){if(s&&!["string","symbol"].includes(typeof s))throw new TypeError;(n(r,s)||a(r,s)).set(e,t)}function h(e,t,r){return c(e,t,r)?c(e,t,r):Object.getPrototypeOf(t)?h(e,Object.getPrototypeOf(t),r):void 0}function d(e,r){return t((function(t,s){l(e,r,t,s)}),"decorator")}function p(e,t,r){return h(e,t,r)}function g(e,t,r){return c(e,t,r)}function u(e,t,r){return!!c(e,t,r)}function f(e,t,r){return!!h(e,t,r)}function v(e,t,r,s){l(e,t,r,s)}t(s,"decorateProperty"),t(i,"decorateConstructor"),t(o,"decorate"),t(n,"getMetadataMap"),t(c,"ordinaryGetOwnMetadata"),t(a,"createMetadataMap"),t(l,"ordinaryDefineOwnMetadata"),t(h,"ordinaryGetMetadata"),t(d,"metadata"),t(p,"getMetadata"),t(g,"getOwnMetadata"),t(u,"hasOwnMetadata"),t(f,"hasMetadata"),t(v,"defineMetadata");var S={decorate:o,defineMetadata:v,getMetadata:p,getOwnMetadata:g,hasMetadata:f,hasOwnMetadata:u,metadata:d};Object.assign(Reflect,S);var m=(e=>(e.Resolve="RESOLVE",e.Transient="TRANSIENT",e.Scoped="SCOPED",e.Singleton="SINGLETON",e))(m||{}),w=(e=>(e[e.Debug=0]="Debug",e[e.Info=1]="Info",e[e.Warn=2]="Warn",e[e.Error=3]="Error",e[e.None=4]="None",e))(w||{}),E=(e=>(e.Error="ERROR",e.LastRegistered="LAST_REGISTERED",e))(E||{}),M={registrationMode:"ERROR",logLevel:2},y=class extends Error{static{t(this,"ServiceError")}},O=class extends y{static{t(this,"UnregisteredServiceError")}name="UnregisteredServiceError";constructor(e){super(`Resolving service that has not been registered: ${e.name}`),Object.setPrototypeOf(this,new.target.prototype)}},I=class extends y{static{t(this,"MultipleRegistrationError")}name="MultipleRegistrationError";constructor(e){super(`Multiple services have been registered: ${e.name}`),Object.setPrototypeOf(this,new.target.prototype)}},R=class extends y{constructor(e,t){super(`Error creating service: ${e.name}`),this.innerError=t,Object.setPrototypeOf(this,new.target.prototype)}static{t(this,"ServiceCreationError")}name="ServiceCreationError"},b=class extends y{static{t(this,"SelfDependencyError")}name="SelfDependencyError";constructor(){super("Service depending on itself"),Object.setPrototypeOf(this,new.target.prototype)}},L=class extends y{static{t(this,"ScopedSingletonRegistrationError")}name="ScopedSingletonRegistrationError";constructor(){super("Cannot register a singleton in a scoped service collection"),Object.setPrototypeOf(this,new.target.prototype)}},D=class{constructor(e,t,r){this.identifiers=e,this.isScoped=t,this.addService=r}static{t(this,"ServiceBuilder")}descriptor;to(e,t){this.descriptor=this.createDescriptor(t,e);for(const e of this.identifiers)this.addService(e,this.descriptor);return this}createDescriptor(e,t){const r=e??(()=>new t);return{implementation:t,createInstance:r,lifetime:"RESOLVE"}}singleton(){if(this.isScoped)throw new L;return this.ensureDescriptor().lifetime="SINGLETON",this}scoped(){return this.ensureDescriptor().lifetime="SCOPED",this}transient(){return this.ensureDescriptor().lifetime="TRANSIENT",this}ensureDescriptor(){if(!this.descriptor)throw new Error("Must call to() before setting lifetime");return this.descriptor}},P=class{static{t(this,"IDisposable")}},C=class{static{t(this,"IServiceModule")}},N=class{static{t(this,"IResolutionScope")}},T=class extends N{static{t(this,"IScopedProvider")}},x=class extends N{static{t(this,"IServiceProvider")}},j=class{static{t(this,"IServiceCollection")}},A=class{static{t(this,"ILifetimeBuilder")}},F=class{static{t(this,"IServiceBuilder")}},G=class{constructor(e,t){this.singletons=e,this.scoped=t}static{t(this,"ResolutionContext")}transient=new Map;getFromLifetime(e,t){const r=this.getMapForLifetime(t);return r?.get(e)}setForLifetime(e,t,r){const s=this.getMapForLifetime(r);s?.set(e,t)}getMapForLifetime(e){return{SINGLETON:this.singletons,SCOPED:this.scoped,RESOLVE:this.transient}[e]}},B="design:dependencies",V=t(((e,t)=>Reflect.getMetadata(e,t)),"getMetadata"),W=t(((e,t,r)=>Reflect.defineMetadata(e,t,r)),"defineMetadata"),$=class e{constructor(e,t,r=new Map){this.logger=e,this.Services=t,this.singletons=r}static{t(this,"ServiceProvider")}scoped=new Map;created=[];[Symbol.dispose](){for(const e of this.created)e[Symbol.dispose]()}resolveInternal(e,t){let r=t.getFromLifetime(e.implementation,e.lifetime);return null==r&&(r=this.createInstance(e,t)),r}resolveAll(e,t){return this.Services.get(e).map((e=>this.resolveInternal(e,t??new G(this.singletons,this.scoped))))}resolve(e,t){if(e.prototype===N.prototype||e.prototype===T.prototype||e.prototype===x.prototype)return this;const r=this.getSingleDescriptor(e);return this.resolveInternal(r,t??new G(this.singletons,this.scoped))}getSingleDescriptor(e){const t=this.Services.get(e);if(0===t.length)throw new O(e);if(t.length>1&&"ERROR"===this.Services.options.registrationMode)throw new I(e);return t[t.length-1]}createInstance(e,t){const r=this.createInstanceInternal(e,t);return this.setDependencies(e.implementation,r,t),t.setForLifetime(e.implementation,r,e.lifetime),r}wrapContext(e){return{resolve:t((t=>this.resolve(t,e)),"resolve"),resolveAll:t((t=>this.resolveAll(t,e)),"resolveAll")}}createInstanceInternal(e,t){let r;try{r=e.createInstance(this.wrapContext(t))}catch(t){throw this.logger.error(t),new R(e.implementation,t)}return"SINGLETON"!==e.lifetime&&Symbol.dispose in r&&this.created.push(r),r}createScope(){return new e(this.logger,this.Services.clone(!0),this.singletons)}setDependencies(e,t,r){const s=V(B,e)??{};this.logger.debug("Dependencies",e.name,s);for(const[i,o]of Object.entries(s)){if(o===e)throw new b;{this.logger.debug("Resolving",o.name,"for",e.name);const s=this.resolve(o,r);t[i]=s}}return t}},U=class e{constructor(e,t,r,s=new Map){this.logger=e,this.options=t,this.isScoped=r,this.services=s}static{t(this,"ServiceCollection")}registerModules(...e){for(const t of e){(new t).registerServices(this)}}get(e){return this.services.get(e)??[]}overrideLifetime(e,t){for(const r of this.get(e))r.lifetime=t}register(...e){return new D(e,this.isScoped,((e,t)=>this.addService(e,t)))}addService(e,t){this.logger.info("Adding service",{identifier:e.name,descriptor:t});let r=this.services.get(e);null==r&&(r=[],this.services.set(e,r)),r.push(t)}clone(t){const r=new Map;for(const[e,t]of this.services){const s=t.map((e=>({...e})));r.set(e,s)}return new e(this.logger,this.options,!0===t,r)}buildProvider(){return new $(this.logger,this.clone())}},k=class{static{t(this,"ILogger")}debug(e,...t){}info(e,...t){}error(e,...t){}warn(e,...t){}},_=class extends k{constructor(e){super(),this.options=e}static{t(this,"ConsoleLogger")}debug(e,...t){this.options.logLevel<=0&&console.debug(e,...t)}info(e,...t){this.options.logLevel<=1&&console.info(e,...t)}warn(e,...t){this.options.logLevel<=2&&console.warn(e,...t)}error(e,...t){this.options.logLevel<=3&&console.error(e,...t)}},q=t((e=>({...M,...e})),"mergeOptions"),z=t((e=>{const t=q(e),r=t.logger??new _(t);return new U(r,t,!1)}),"createServiceCollection"),H=t(((e,t,r,s)=>{let i=V(e,t);void 0===i&&(i={},W(e,i,t)),i[r]=s}),"tagProperty"),J=t((e=>(t,r)=>function(t){const s=this.constructor;return H(B,s,r.name,e),t}),"dependsOn");export{M as DefaultServiceCollectionOptions,P as IDisposable,A as ILifetimeBuilder,k as ILogger,N as IResolutionScope,T as IScopedProvider,F as IServiceBuilder,j as IServiceCollection,C as IServiceModule,x as IServiceProvider,m as Lifetime,w as LogLevel,I as MultipleRegistrationError,E as ResolveMultipleMode,L as ScopedSingletonRegistrationError,b as SelfDependencyError,R as ServiceCreationError,y as ServiceError,O as UnregisteredServiceError,z as createServiceCollection,J as dependsOn};//# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/enums.ts","../src/defaults.ts","../src/errors.ts","../src/private/ServiceBuilder.ts","../src/interfaces.ts","../src/private/ResolutionContext.ts","../src/private/constants.ts","../src/private/metadata.ts","../src/private/ServiceProvider.ts","../src/private/ServiceCollection.ts","../src/logger.ts","../src/private/consoleLogger.ts","../src/createServiceCollection.ts","../src/dependsOn.ts"],"names":["Lifetime","LogLevel","ResolveMultipleMode"],"mappings":";;;;AAAY,IAAA,QAAA,qBAAAA,SAAL,KAAA;AACL,EAAAA,UAAA,SAAU,CAAA,GAAA,SAAA;AACV,EAAAA,UAAA,WAAY,CAAA,GAAA,WAAA;AACZ,EAAAA,UAAA,QAAS,CAAA,GAAA,QAAA;AACT,EAAAA,UAAA,WAAY,CAAA,GAAA,WAAA;AAJF,EAAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA;AAOA,IAAA,QAAA,qBAAAC,SAAL,KAAA;AACL,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,WAAQ,CAAR,CAAA,GAAA,OAAA;AACA,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,UAAO,CAAP,CAAA,GAAA,MAAA;AACA,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,UAAO,CAAP,CAAA,GAAA,MAAA;AACA,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,WAAQ,CAAR,CAAA,GAAA,OAAA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AA,MAAM,MAAS,GAAA,aAAA,CAAc,MAAU,IAAA,IAAI,cAAc,aAAa,CAAA;AACtE,EAAA,OAAO,IAAI,iBAAA,CAAkB,MAAQ,EAAA,aAAA,EAAe,KAAK,CAAA;AAC3D,CAJuC,EAAA,yBAAA;;;ACXvC,IAAM,WAAc,mBAAA,MAAA,CAAA,CAAuB,WAAqB,EAAA,gBAAA,EAA0B,MAAuB,UAAqC,KAAA;AACpJ,EAAI,IAAA,QAAA,GAAW,WAAe,CAAA,WAAA,EAAa,gBAAgB,CAAA;AAC3D,EAAA,IAAI,aAAa,SAAW,EAAA;AAC1B,IAAA,QAAA,GAAW,EAAC;AACZ,IAAe,cAAA,CAAA,WAAA,EAAa,UAAU,gBAAgB,CAAA;AAAA;AAExD,EAAA,QAAA,CAAS,IAAI,CAAI,GAAA,UAAA;AACnB,CAPoB,EAAA,aAAA,CAAA;AAcP,IAAA,SAAA,2BAAmC,UAAqC,KAAA;AACnF,EAAO,OAAA,CAAC,OAAkB,GAAoC,KAAA;AAC5D,IAAA,OAAO,SAAwB,YAAmB,EAAA;AAChD,MAAA,MAAM,SAAS,IAAK,CAAA,WAAA;AACpB,MAAA,WAAA,CAAY,qBAAuB,EAAA,MAAA,EAAQ,GAAI,CAAA,IAAA,EAAM,UAAU,CAAA;AAC/D,MAAO,OAAA,YAAA;AAAA,KACT;AAAA,GACF;AACF,CARyB,EAAA,WAAA","file":"index.js","sourcesContent":["export enum Lifetime {\n Resolve = 'RESOLVE',\n Transient = 'TRANSIENT',\n Scoped = 'SCOPED',\n Singleton = 'SINGLETON',\n}\n\nexport enum LogLevel {\n Debug = 0,\n Info = 1,\n Warn = 2,\n Error = 3,\n None = 4,\n}\n\nexport enum ResolveMultipleMode {\n Error = 'ERROR',\n LastRegistered = 'LAST_REGISTERED',\n}\n","import { LogLevel, ResolveMultipleMode } from './enums';\nimport type { ServiceCollectionOptions } from './types';\n\nexport const DefaultServiceCollectionOptions: ServiceCollectionOptions = {\n registrationMode: ResolveMultipleMode.Error,\n logLevel: LogLevel.Warn,\n};\n","import type { ServiceIdentifier } from './types';\n\nexport abstract class ServiceError extends Error {}\n\nexport class UnregisteredServiceError<T extends object> extends ServiceError {\n name = 'UnregisteredServiceError';\n constructor(identifier: ServiceIdentifier<T>) {\n super(`Resolving service that has not been registered: ${identifier.name}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class MultipleRegistrationError<T extends object> extends ServiceError {\n name = 'MultipleRegistrationError';\n constructor(identifier: ServiceIdentifier<T>) {\n super(`Multiple services have been registered: ${identifier.name}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class ServiceCreationError<T extends object> extends ServiceError {\n name = 'ServiceCreationError';\n constructor(\n identifier: ServiceIdentifier<T>,\n public readonly innerError: any,\n ) {\n super(`Error creating service: ${identifier.name}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class SelfDependencyError extends ServiceError {\n name = 'SelfDependencyError';\n constructor() {\n super('Service depending on itself');\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class ScopedSingletonRegistrationError extends ServiceError {\n name = 'ScopedSingletonRegistrationError';\n constructor() {\n super('Cannot register a singleton in a scoped service collection');\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import { Lifetime } from '../enums';\nimport { ScopedSingletonRegistrationError } from '../errors';\nimport type { ILifetimeBuilder, IServiceBuilder } from '../interfaces';\nimport type { InstanceFactory, ServiceDescriptor, ServiceIdentifier, ServiceImplementation, SourceType } from '../types';\n\nexport class ServiceBuilder<T extends SourceType> implements IServiceBuilder<T> {\n private descriptor: ServiceDescriptor<T> | undefined;\n\n constructor(\n private readonly identifiers: ServiceIdentifier<T>[],\n private readonly isScoped: boolean,\n private readonly addService: (identifier: ServiceIdentifier<T>, descriptor: ServiceDescriptor<T>) => void,\n ) {}\n\n public to(implementation: ServiceImplementation<T>, factory?: InstanceFactory<T>): ILifetimeBuilder {\n this.descriptor = this.createDescriptor(factory, implementation);\n\n for (const identifier of this.identifiers) {\n this.addService(identifier, this.descriptor);\n }\n return this;\n }\n\n private createDescriptor(factory: InstanceFactory<T> | undefined, implementation: ServiceImplementation<T>): ServiceDescriptor<T> {\n const createInstance = factory ?? (() => new implementation());\n\n return {\n implementation,\n createInstance,\n lifetime: Lifetime.Resolve,\n };\n }\n\n public singleton(): this {\n if (this.isScoped) {\n throw new ScopedSingletonRegistrationError();\n }\n this.ensureDescriptor().lifetime = Lifetime.Singleton;\n return this;\n }\n\n public scoped(): this {\n this.ensureDescriptor().lifetime = Lifetime.Scoped;\n return this;\n }\n\n public transient(): this {\n this.ensureDescriptor().lifetime = Lifetime.Transient;\n return this;\n }\n\n private ensureDescriptor(): ServiceDescriptor<T> {\n if (!this.descriptor) {\n throw new Error('Must call to() before setting lifetime');\n }\n return this.descriptor;\n }\n}\n","import type { Lifetime } from './enums';\nimport { ResolveMultipleMode } from './enums';\nimport type { EnsureObject, ServiceBuilderOptions, ServiceCollectionOptions, ServiceDescriptor, ServiceIdentifier, ServiceModuleType, SourceType, UnionToIntersection } from './types';\n\nexport abstract class IDisposable {\n public abstract [Symbol.dispose](): void;\n}\n\nexport abstract class IServiceModule {\n public abstract registerServices(services: IServiceCollection): void;\n}\n\nexport abstract class IResolutionScope {\n /**\n * Resolves a single implementation for the given identifier.\n * @template T The type of service to resolve\n * @param identifier The service identifier\n * @returns The resolved instance\n * @throws {MultipleRegistrationError} When multiple implementations exist (unless {@link ServiceCollectionOptions.registrationMode} is set to {@link ResolveMultipleMode.LastRegistered}).\n * @throws {UnregisteredServiceError} When no implementation exists\n */\n public abstract resolve<T extends SourceType>(identifier: ServiceIdentifier<T>): T;\n\n /**\n * Resolves all implementations for the given identifier.\n * @template T The type of service to resolve\n * @param identifier The service identifier\n * @returns Array of resolved instances\n */\n public abstract resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>): T[];\n}\n\nexport abstract class IScopedProvider extends IResolutionScope implements IDisposable {\n public abstract readonly Services: IServiceCollection;\n public abstract [Symbol.dispose](): void;\n}\n\nexport abstract class IServiceProvider extends IResolutionScope {\n public abstract readonly Services: IServiceCollection;\n public abstract createScope(): IScopedProvider;\n}\n\nexport abstract class IServiceCollection {\n public abstract readonly options: ServiceCollectionOptions;\n public abstract get<T extends SourceType>(identifier: ServiceIdentifier<T>): ServiceDescriptor<T>[];\n public abstract register<Types extends SourceType[]>(...identifiers: { [K in keyof Types]: ServiceIdentifier<Types[K]> }): IServiceBuilder<EnsureObject<UnionToIntersection<Types[number]>>>;\n public abstract registerModules(...modules: ServiceModuleType[]): void;\n public abstract overrideLifetime<T extends SourceType>(identifier: ServiceIdentifier<T>, lifetime: Lifetime): void;\n public abstract buildProvider(): IServiceProvider;\n public abstract clone(): IServiceCollection;\n public abstract clone(scoped: true): IServiceCollection;\n}\n\nexport abstract class ILifetimeBuilder {\n public abstract singleton(): ILifetimeBuilder;\n public abstract scoped(): ILifetimeBuilder;\n public abstract transient(): ILifetimeBuilder;\n}\n\nexport abstract class IServiceBuilder<T extends SourceType> {\n public abstract to: ServiceBuilderOptions<T>;\n}\n","import { Lifetime } from '../enums';\nimport type { ServiceImplementation, SourceType } from '../types';\n\nexport class ResolutionContext {\n constructor(\n private readonly singletons: Map<ServiceImplementation<any>, any>,\n private readonly scoped: Map<ServiceImplementation<any>, any>,\n ) {}\n\n private readonly transient = new Map<ServiceImplementation<any>, any>();\n\n public getFromLifetime<T extends SourceType>(implementation: ServiceImplementation<T>, lifetime: Lifetime): T {\n const map = this.getMapForLifetime(lifetime);\n return map?.get(implementation);\n }\n\n public setForLifetime<T extends SourceType>(implementation: ServiceImplementation<T>, instance: T, lifetime: Lifetime): void {\n const map = this.getMapForLifetime(lifetime);\n map?.set(implementation, instance);\n }\n\n private getMapForLifetime(lifetime: Lifetime) {\n const map: Partial<Record<Lifetime, Map<ServiceImplementation<any>, any>>> = {\n [Lifetime.Singleton]: this.singletons,\n [Lifetime.Scoped]: this.scoped,\n [Lifetime.Resolve]: this.transient,\n };\n return map[lifetime];\n }\n}\n","export const DesignDependenciesKey = 'design:dependencies';\n","import '@abraham/reflection';\nimport type { MetadataType, SourceType } from '../types';\n\nexport const getMetadata = <T extends SourceType>(key: string, obj: object): MetadataType<T> | undefined => Reflect.getMetadata(key, obj);\nexport const defineMetadata = <T extends SourceType>(key: string, metadata: MetadataType<T>, obj: object) => Reflect.defineMetadata(key, metadata, obj);\n","import { Lifetime } from '../enums';\nimport { ResolveMultipleMode } from '../enums';\nimport { MultipleRegistrationError, SelfDependencyError, ServiceCreationError, UnregisteredServiceError } from '../errors';\nimport { type IDisposable, IResolutionScope, IScopedProvider, type IServiceCollection } from '../interfaces';\nimport { IServiceProvider } from '../interfaces';\nimport type { ILogger } from '../logger';\nimport type { ServiceDescriptor, ServiceIdentifier, ServiceImplementation, SourceType } from '../types';\nimport { ResolutionContext } from './ResolutionContext';\nimport { DesignDependenciesKey } from './constants';\nimport { getMetadata } from './metadata';\n\nexport class ServiceProvider implements IServiceProvider, IScopedProvider {\n private scoped = new Map<ServiceImplementation<any>, any>();\n private created: IDisposable[] = [];\n\n constructor(\n private readonly logger: ILogger,\n public readonly Services: IServiceCollection,\n private readonly singletons = new Map<ServiceImplementation<any>, any>(),\n ) {}\n\n [Symbol.dispose]() {\n for (const x of this.created) {\n x[Symbol.dispose]();\n }\n }\n\n private resolveInternal<T extends SourceType>(descriptor: ServiceDescriptor<T>, context: ResolutionContext): T {\n let instance = context.getFromLifetime(descriptor.implementation, descriptor.lifetime);\n if (instance == null) {\n instance = this.createInstance(descriptor, context);\n }\n return instance;\n }\n\n public resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>, context?: ResolutionContext): T[] {\n const descriptors = this.Services.get(identifier);\n return descriptors.map((descriptor) => this.resolveInternal<T>(descriptor, context ?? new ResolutionContext(this.singletons, this.scoped)));\n }\n\n public resolve<T extends SourceType>(identifier: ServiceIdentifier<T>, context?: ResolutionContext): T {\n if (identifier.prototype === IResolutionScope.prototype || identifier.prototype === IScopedProvider.prototype || identifier.prototype === IServiceProvider.prototype) {\n return this as IResolutionScope & IScopedProvider & IServiceProvider as T;\n }\n\n const descriptor = this.getSingleDescriptor(identifier);\n return this.resolveInternal(descriptor, context ?? new ResolutionContext(this.singletons, this.scoped));\n }\n\n private getSingleDescriptor<T extends SourceType>(identifier: ServiceIdentifier<T>) {\n const descriptors = this.Services.get(identifier);\n if (descriptors.length === 0) {\n throw new UnregisteredServiceError(identifier);\n }\n\n if (descriptors.length > 1) {\n if (this.Services.options.registrationMode === ResolveMultipleMode.Error) {\n throw new MultipleRegistrationError(identifier);\n }\n }\n const descriptor = descriptors[descriptors.length - 1];\n return descriptor;\n }\n\n private createInstance<T extends SourceType>(descriptor: ServiceDescriptor<T>, context: ResolutionContext): T {\n const instance = this.createInstanceInternal(descriptor, context);\n this.setDependencies(descriptor.implementation, instance, context);\n context.setForLifetime(descriptor.implementation, instance, descriptor.lifetime);\n return instance;\n }\n\n private wrapContext(context: ResolutionContext): IResolutionScope {\n const resolve = (identifier: ServiceIdentifier<any>) => this.resolve(identifier, context);\n const resolveAll = (identifier: ServiceIdentifier<any>) => this.resolveAll(identifier, context);\n\n return {\n resolve,\n resolveAll,\n };\n }\n\n private createInstanceInternal<T extends SourceType>(descriptor: ServiceDescriptor<T>, context: ResolutionContext) {\n let instance: T | undefined;\n try {\n instance = descriptor.createInstance(this.wrapContext(context));\n } catch (err) {\n this.logger.error(err);\n throw new ServiceCreationError(descriptor.implementation, err);\n }\n if (descriptor.lifetime !== Lifetime.Singleton && Symbol.dispose in instance) {\n this.created.push(instance as IDisposable);\n }\n return instance;\n }\n\n public createScope(): IScopedProvider {\n return new ServiceProvider(this.logger, this.Services.clone(true), this.singletons);\n }\n\n private setDependencies<T extends SourceType>(implementation: ServiceImplementation<T>, instance: T, context: ResolutionContext): T {\n const dependencies = getMetadata<T>(DesignDependenciesKey, implementation) ?? {};\n this.logger.debug('Dependencies', implementation.name, dependencies);\n for (const [key, identifier] of Object.entries(dependencies)) {\n if (identifier !== implementation) {\n this.logger.debug('Resolving', identifier.name, 'for', implementation.name);\n const dep = this.resolve(identifier, context);\n (instance as Record<string, T>)[key] = dep;\n } else {\n throw new SelfDependencyError();\n }\n }\n return instance;\n }\n}\n","import type { Lifetime } from '../enums';\nimport type { IServiceBuilder, IServiceCollection, IServiceProvider } from '../interfaces';\nimport type { ILogger } from '../logger';\nimport type { EnsureObject, ServiceCollectionOptions, ServiceDescriptor, ServiceIdentifier, ServiceModuleType, SourceType, UnionToIntersection } from '../types';\nimport { ServiceBuilder } from './ServiceBuilder';\nimport { ServiceProvider } from './ServiceProvider';\n\nexport class ServiceCollection implements IServiceCollection {\n constructor(\n private readonly logger: ILogger,\n public readonly options: ServiceCollectionOptions,\n private readonly isScoped: boolean,\n private readonly services = new Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>(),\n ) {}\n\n public registerModules(...modules: ServiceModuleType[]): void {\n for (const x of modules) {\n const module = new x();\n module.registerServices(this);\n }\n }\n\n get<T extends SourceType>(key: ServiceIdentifier<T>): ServiceDescriptor<T>[] {\n return this.services.get(key) ?? [];\n }\n\n public overrideLifetime<T extends SourceType>(identifier: ServiceIdentifier<T>, lifetime: Lifetime): void {\n for (const descriptor of this.get(identifier)) {\n descriptor.lifetime = lifetime;\n }\n }\n\n register<Types extends SourceType[]>(...identifiers: { [K in keyof Types]: ServiceIdentifier<Types[K]> }): IServiceBuilder<EnsureObject<UnionToIntersection<Types[number]>>> {\n return new ServiceBuilder(identifiers, this.isScoped, (identifier, descriptor) => this.addService(identifier, descriptor));\n }\n\n private addService<T extends SourceType>(identifier: ServiceIdentifier<T>, descriptor: ServiceDescriptor<T>) {\n this.logger.info('Adding service', { identifier: identifier.name, descriptor });\n let existing = this.services.get(identifier);\n if (existing == null) {\n existing = [];\n this.services.set(identifier, existing);\n }\n existing.push(descriptor);\n }\n\n public clone(scoped?: unknown): IServiceCollection {\n const clonedMap = new Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>();\n for (const [key, descriptors] of this.services) {\n const clonedDescriptors = descriptors.map((descriptor) => ({ ...descriptor }));\n clonedMap.set(key, clonedDescriptors);\n }\n\n return new ServiceCollection(this.logger, this.options, scoped === true, clonedMap);\n }\n\n public buildProvider(): IServiceProvider {\n return new ServiceProvider(this.logger, this.clone());\n }\n}\n","export abstract class ILogger {\n public debug(_message?: any, ..._optionalParams: any[]) {}\n public info(_message?: any, ..._optionalParams: any[]) {}\n public error(_message?: any, ..._optionalParams: any[]) {}\n public warn(_message?: any, ..._optionalParams: any[]) {}\n}\n","import { LogLevel } from '../enums';\nimport { ILogger } from '../logger';\nimport type { ServiceCollectionOptions } from '../types';\n\nexport class ConsoleLogger extends ILogger {\n constructor(private readonly options: ServiceCollectionOptions) {\n super();\n }\n\n public override debug(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Debug) {\n console.debug(message, ...optionalParams);\n }\n }\n\n public override info(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Info) {\n console.info(message, ...optionalParams);\n }\n }\n\n public override warn(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Warn) {\n console.warn(message, ...optionalParams);\n }\n }\n\n public override error(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Error) {\n console.error(message, ...optionalParams);\n }\n }\n}\n","import { DefaultServiceCollectionOptions } from './defaults';\nimport type { IServiceCollection } from './interfaces';\nimport { ServiceCollection } from './private/ServiceCollection';\nimport { ConsoleLogger } from './private/consoleLogger';\nimport type { ServiceCollectionOptions } from './types';\n\nconst mergeOptions = (options: Partial<ServiceCollectionOptions> | undefined): ServiceCollectionOptions => ({\n ...DefaultServiceCollectionOptions,\n ...options,\n});\n\n/**\n * Creates a service collection with the (optionally) provided options\n * @param options - Optional configuration for the service collection.\n * @defaultValue Default options are taken from {@link DefaultServiceCollectionOptions}.\n */\nexport const createServiceCollection = (options?: Partial<ServiceCollectionOptions>): IServiceCollection => {\n const mergedOptions = mergeOptions(options);\n const logger = mergedOptions.logger ?? new ConsoleLogger(mergedOptions);\n return new ServiceCollection(logger, mergedOptions, false);\n};\n","import { IResolutionScope, IScopedProvider, IServiceProvider } from './interfaces';\nimport { DesignDependenciesKey } from './private/constants';\nimport { defineMetadata, getMetadata } from './private/metadata';\nimport type { ServiceIdentifier, SourceType } from './types';\n\nconst tagProperty = <T extends SourceType>(metadataKey: string, annotationTarget: object, name: string | symbol, identifier: ServiceIdentifier<T>) => {\n let existing = getMetadata<T>(metadataKey, annotationTarget);\n if (existing === undefined) {\n existing = {};\n defineMetadata(metadataKey, existing, annotationTarget);\n }\n existing[name] = identifier;\n};\n\n/**\n * declares a dependency, use on a class field.\n * Can also depend on {@link IServiceProvider}, {@link IResolutionScope}, or {@link IScopedProvider}.\n * @param identifier the identifier to depend on, i.e. the interface\n */\nexport const dependsOn = <T extends SourceType>(identifier: ServiceIdentifier<T>) => {\n return (value: undefined, ctx: ClassFieldDecoratorContext) => {\n return function (this: object, initialValue: any) {\n const target = this.constructor;\n tagProperty(DesignDependenciesKey, target, ctx.name, identifier);\n return initialValue;\n };\n };\n};\n"]}
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/@abraham+reflection@0.12.0/node_modules/@abraham/reflection/src/index.ts","../src/enums.ts","../src/defaults.ts","../src/errors.ts","../src/private/ServiceBuilder.ts","../src/interfaces.ts","../src/private/ResolutionContext.ts","../src/private/constants.ts","../src/private/metadata.ts","../src/private/ServiceProvider.ts","../src/private/ServiceCollection.ts","../src/logger.ts","../src/private/consoleLogger.ts","../src/createServiceCollection.ts","../src/dependsOn.ts"],"names":["Lifetime","LogLevel","ResolveMultipleMode","getMetadata","defineMetadata","metadata"],"mappings":";;;;AAUA,IAAM,QAAA,uBAAe,OAAO,EAAA;AAE5B,SAAS,gBACP,CAAA,UAAA,EACA,MACA,EAAA,WAAA,EACA,UAA+B,EAAA;AAE/B,EAAA,UAAA,CAAW,OAAO,EAAA,CAAG,OAAQ,CAAA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,WAAA,EAAa,gBAAgB,CAAA;AAC3D,EAAA,IAAI,aAAa,SAAW,EAAA;AAC1B,IAAA,QAAA,GAAW,EAAC;AACZ,IAAAC,eAAAA,CAAe,WAAa,EAAA,QAAA,EAAU,gBAAgB,CAAA;AAAA;AAExD,EAAA,QAAA,CAAS,IAAI,CAAI,GAAA,UAAA;AACnB,CAPoB,EAAA,aAAA,CAAA;AAcP,IAAA,SAAA,2BAAmC,UAAqC,KAAA;AACnF,EAAO,OAAA,CAAC,OAAkB,GAAoC,KAAA;AAC5D,IAAA,OAAO,SAAwB,YAAmB,EAAA;AAChD,MAAA,MAAM,SAAS,IAAK,CAAA,WAAA;AACpB,MAAA,WAAA,CAAY,qBAAuB,EAAA,MAAA,EAAQ,GAAI,CAAA,IAAA,EAAM,UAAU,CAAA;AAC/D,MAAO,OAAA,YAAA;AAAA,KACT;AAAA,GACF;AACF,CARyB,EAAA,WAAA","file":"index.js","sourcesContent":["export type Decorator = ClassDecorator | MemberDecorator;\nexport type MemberDecorator = <T>(\n target: Target,\n propertyKey: PropertyKey,\n descriptor?: TypedPropertyDescriptor<T>,\n) => TypedPropertyDescriptor<T> | void;\nexport type MetadataKey = string | symbol;\nexport type PropertyKey = string | symbol;\nexport type Target = object | Function;\n\nconst Metadata = new WeakMap();\n\nfunction decorateProperty(\n decorators: MemberDecorator[],\n target: Target,\n propertyKey: PropertyKey,\n descriptor?: PropertyDescriptor,\n): PropertyDescriptor | undefined {\n decorators.reverse().forEach((decorator: MemberDecorator) => {\n descriptor = decorator(target, propertyKey, descriptor) || descriptor;\n });\n return descriptor;\n}\n\nfunction decorateConstructor(\n decorators: ClassDecorator[],\n target: Function,\n): Function {\n decorators.reverse().forEach((decorator: ClassDecorator) => {\n const decorated = decorator(target);\n if (decorated) {\n target = decorated;\n }\n });\n return target;\n}\n\nexport function decorate(\n decorators: ClassDecorator[],\n target: Function,\n): Function;\nexport function decorate(\n decorators: MemberDecorator[],\n target: object,\n propertyKey?: PropertyKey,\n attributes?: PropertyDescriptor,\n): PropertyDescriptor | undefined;\nexport function decorate(\n decorators: Decorator[],\n target: Target,\n propertyKey?: PropertyKey,\n attributes?: PropertyDescriptor,\n): Function | PropertyDescriptor | undefined {\n if (!Array.isArray(decorators) || decorators.length === 0) {\n throw new TypeError();\n }\n\n if (propertyKey !== undefined) {\n return decorateProperty(\n decorators as MemberDecorator[],\n target,\n propertyKey,\n attributes,\n );\n }\n\n if (typeof target === 'function') {\n return decorateConstructor(decorators as ClassDecorator[], target);\n }\n\n return;\n}\n\nfunction getMetadataMap<MetadataValue>(\n target: Target,\n propertyKey?: PropertyKey,\n): Map<MetadataKey, MetadataValue> | undefined {\n return Metadata.get(target) && Metadata.get(target).get(propertyKey);\n}\n\nfunction ordinaryGetOwnMetadata<MetadataValue>(\n metadataKey: MetadataKey,\n target: Target,\n propertyKey?: PropertyKey,\n): MetadataValue | undefined {\n if (target === undefined) {\n throw new TypeError();\n }\n const metadataMap = getMetadataMap<MetadataValue>(target, propertyKey);\n return metadataMap && metadataMap.get(metadataKey);\n}\n\nfunction createMetadataMap<MetadataValue>(\n target: Target,\n propertyKey?: PropertyKey,\n): Map<MetadataKey, MetadataValue> {\n const targetMetadata =\n Metadata.get(target) ||\n new Map<PropertyKey | undefined, Map<MetadataKey, MetadataValue>>();\n Metadata.set(target, targetMetadata);\n const metadataMap =\n targetMetadata.get(propertyKey) || new Map<MetadataKey, MetadataValue>();\n targetMetadata.set(propertyKey, metadataMap);\n return metadataMap;\n}\n\nfunction ordinaryDefineOwnMetadata<MetadataValue>(\n metadataKey: MetadataKey,\n metadataValue: MetadataValue,\n target: Target,\n propertyKey?: PropertyKey,\n): void {\n if (propertyKey && !['string', 'symbol'].includes(typeof propertyKey)) {\n throw new TypeError();\n }\n\n (\n getMetadataMap<MetadataValue>(target, propertyKey) ||\n createMetadataMap<MetadataValue>(target, propertyKey)\n ).set(metadataKey, metadataValue);\n}\n\nfunction ordinaryGetMetadata<MetadataValue>(\n metadataKey: MetadataKey,\n target: Target,\n propertyKey?: PropertyKey,\n): MetadataValue | undefined {\n return ordinaryGetOwnMetadata<MetadataValue>(metadataKey, target, propertyKey)\n ? ordinaryGetOwnMetadata<MetadataValue>(metadataKey, target, propertyKey)\n : Object.getPrototypeOf(target)\n ? ordinaryGetMetadata(\n metadataKey,\n Object.getPrototypeOf(target),\n propertyKey,\n )\n : undefined;\n}\n\nexport function metadata<MetadataValue>(\n metadataKey: MetadataKey,\n metadataValue: MetadataValue,\n) {\n return function decorator(target: Target, propertyKey?: PropertyKey): void {\n ordinaryDefineOwnMetadata<MetadataValue>(\n metadataKey,\n metadataValue,\n target,\n propertyKey,\n );\n };\n}\n\nexport function getMetadata<MetadataValue>(\n metadataKey: MetadataKey,\n target: Target,\n propertyKey?: PropertyKey,\n): MetadataValue | undefined {\n return ordinaryGetMetadata<MetadataValue>(metadataKey, target, propertyKey);\n}\n\nexport function getOwnMetadata<MetadataValue>(\n metadataKey: MetadataKey,\n target: Target,\n propertyKey?: PropertyKey,\n): MetadataValue | undefined {\n return ordinaryGetOwnMetadata<MetadataValue>(\n metadataKey,\n target,\n propertyKey,\n );\n}\n\nexport function hasOwnMetadata(\n metadataKey: MetadataKey,\n target: Target,\n propertyKey?: PropertyKey,\n): boolean {\n return !!ordinaryGetOwnMetadata(metadataKey, target, propertyKey);\n}\n\nexport function hasMetadata(\n metadataKey: MetadataKey,\n target: Target,\n propertyKey?: PropertyKey,\n): boolean {\n return !!ordinaryGetMetadata(metadataKey, target, propertyKey);\n}\n\nexport function defineMetadata<MetadataValue>(\n metadataKey: MetadataKey,\n metadataValue: MetadataValue,\n target: Target,\n propertyKey?: PropertyKey,\n): void {\n ordinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);\n}\n\nexport const Reflection = {\n decorate,\n defineMetadata,\n getMetadata,\n getOwnMetadata,\n hasMetadata,\n hasOwnMetadata,\n metadata,\n};\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Reflect {\n let decorate: typeof Reflection.decorate;\n let defineMetadata: typeof Reflection.defineMetadata;\n let getMetadata: typeof Reflection.getMetadata;\n let getOwnMetadata: typeof Reflection.getOwnMetadata;\n let hasOwnMetadata: typeof Reflection.hasOwnMetadata;\n let hasMetadata: typeof Reflection.hasMetadata;\n let metadata: typeof Reflection.metadata;\n }\n}\n\nObject.assign(Reflect, Reflection);\n","export enum Lifetime {\n Resolve = 'RESOLVE',\n Transient = 'TRANSIENT',\n Scoped = 'SCOPED',\n Singleton = 'SINGLETON',\n}\n\nexport enum LogLevel {\n Debug = 0,\n Info = 1,\n Warn = 2,\n Error = 3,\n None = 4,\n}\n\nexport enum ResolveMultipleMode {\n Error = 'ERROR',\n LastRegistered = 'LAST_REGISTERED',\n}\n","import { LogLevel, ResolveMultipleMode } from './enums';\nimport type { ServiceCollectionOptions } from './types';\n\nexport const DefaultServiceCollectionOptions: ServiceCollectionOptions = {\n registrationMode: ResolveMultipleMode.Error,\n logLevel: LogLevel.Warn,\n};\n","import type { ServiceIdentifier } from './types';\n\nexport abstract class ServiceError extends Error {}\n\nexport class UnregisteredServiceError<T extends object> extends ServiceError {\n name = 'UnregisteredServiceError';\n constructor(identifier: ServiceIdentifier<T>) {\n super(`Resolving service that has not been registered: ${identifier.name}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class MultipleRegistrationError<T extends object> extends ServiceError {\n name = 'MultipleRegistrationError';\n constructor(identifier: ServiceIdentifier<T>) {\n super(`Multiple services have been registered: ${identifier.name}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class ServiceCreationError<T extends object> extends ServiceError {\n name = 'ServiceCreationError';\n constructor(\n identifier: ServiceIdentifier<T>,\n public readonly innerError: any,\n ) {\n super(`Error creating service: ${identifier.name}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class SelfDependencyError extends ServiceError {\n name = 'SelfDependencyError';\n constructor() {\n super('Service depending on itself');\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class ScopedSingletonRegistrationError extends ServiceError {\n name = 'ScopedSingletonRegistrationError';\n constructor() {\n super('Cannot register a singleton in a scoped service collection');\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import { Lifetime } from '../enums';\nimport { ScopedSingletonRegistrationError } from '../errors';\nimport type { ILifetimeBuilder, IServiceBuilder } from '../interfaces';\nimport type { InstanceFactory, ServiceDescriptor, ServiceIdentifier, ServiceImplementation, SourceType } from '../types';\n\nexport class ServiceBuilder<T extends SourceType> implements IServiceBuilder<T> {\n private descriptor: ServiceDescriptor<T> | undefined;\n\n constructor(\n private readonly identifiers: ServiceIdentifier<T>[],\n private readonly isScoped: boolean,\n private readonly addService: (identifier: ServiceIdentifier<T>, descriptor: ServiceDescriptor<T>) => void,\n ) {}\n\n public to(implementation: ServiceImplementation<T>, factory?: InstanceFactory<T>): ILifetimeBuilder {\n this.descriptor = this.createDescriptor(factory, implementation);\n\n for (const identifier of this.identifiers) {\n this.addService(identifier, this.descriptor);\n }\n return this;\n }\n\n private createDescriptor(factory: InstanceFactory<T> | undefined, implementation: ServiceImplementation<T>): ServiceDescriptor<T> {\n const createInstance = factory ?? (() => new implementation());\n\n return {\n implementation,\n createInstance,\n lifetime: Lifetime.Resolve,\n };\n }\n\n public singleton(): this {\n if (this.isScoped) {\n throw new ScopedSingletonRegistrationError();\n }\n this.ensureDescriptor().lifetime = Lifetime.Singleton;\n return this;\n }\n\n public scoped(): this {\n this.ensureDescriptor().lifetime = Lifetime.Scoped;\n return this;\n }\n\n public transient(): this {\n this.ensureDescriptor().lifetime = Lifetime.Transient;\n return this;\n }\n\n private ensureDescriptor(): ServiceDescriptor<T> {\n if (!this.descriptor) {\n throw new Error('Must call to() before setting lifetime');\n }\n return this.descriptor;\n }\n}\n","import type { Lifetime } from './enums';\nimport { ResolveMultipleMode } from './enums';\nimport type { EnsureObject, ServiceBuilderOptions, ServiceCollectionOptions, ServiceDescriptor, ServiceIdentifier, ServiceModuleType, SourceType, UnionToIntersection } from './types';\n\nexport abstract class IDisposable {\n public abstract [Symbol.dispose](): void;\n}\n\nexport abstract class IServiceModule {\n public abstract registerServices(services: IServiceCollection): void;\n}\n\nexport abstract class IResolutionScope {\n /**\n * Resolves a single implementation for the given identifier.\n * @template T The type of service to resolve\n * @param identifier The service identifier\n * @returns The resolved instance\n * @throws {MultipleRegistrationError} When multiple implementations exist (unless {@link ServiceCollectionOptions.registrationMode} is set to {@link ResolveMultipleMode.LastRegistered}).\n * @throws {UnregisteredServiceError} When no implementation exists\n */\n public abstract resolve<T extends SourceType>(identifier: ServiceIdentifier<T>): T;\n\n /**\n * Resolves all implementations for the given identifier.\n * @template T The type of service to resolve\n * @param identifier The service identifier\n * @returns Array of resolved instances\n */\n public abstract resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>): T[];\n}\n\nexport abstract class IScopedProvider extends IResolutionScope implements IDisposable {\n public abstract readonly Services: IServiceCollection;\n public abstract [Symbol.dispose](): void;\n}\n\nexport abstract class IServiceProvider extends IResolutionScope {\n public abstract readonly Services: IServiceCollection;\n public abstract createScope(): IScopedProvider;\n}\n\nexport abstract class IServiceCollection {\n public abstract readonly options: ServiceCollectionOptions;\n public abstract get<T extends SourceType>(identifier: ServiceIdentifier<T>): ServiceDescriptor<T>[];\n public abstract register<Types extends SourceType[]>(...identifiers: { [K in keyof Types]: ServiceIdentifier<Types[K]> }): IServiceBuilder<EnsureObject<UnionToIntersection<Types[number]>>>;\n public abstract registerModules(...modules: ServiceModuleType[]): void;\n public abstract overrideLifetime<T extends SourceType>(identifier: ServiceIdentifier<T>, lifetime: Lifetime): void;\n public abstract buildProvider(): IServiceProvider;\n public abstract clone(): IServiceCollection;\n public abstract clone(scoped: true): IServiceCollection;\n}\n\nexport abstract class ILifetimeBuilder {\n public abstract singleton(): ILifetimeBuilder;\n public abstract scoped(): ILifetimeBuilder;\n public abstract transient(): ILifetimeBuilder;\n}\n\nexport abstract class IServiceBuilder<T extends SourceType> {\n public abstract to: ServiceBuilderOptions<T>;\n}\n","import { Lifetime } from '../enums';\nimport type { ServiceImplementation, SourceType } from '../types';\n\nexport class ResolutionContext {\n constructor(\n private readonly singletons: Map<ServiceImplementation<any>, any>,\n private readonly scoped: Map<ServiceImplementation<any>, any>,\n ) {}\n\n private readonly transient = new Map<ServiceImplementation<any>, any>();\n\n public getFromLifetime<T extends SourceType>(implementation: ServiceImplementation<T>, lifetime: Lifetime): T {\n const map = this.getMapForLifetime(lifetime);\n return map?.get(implementation);\n }\n\n public setForLifetime<T extends SourceType>(implementation: ServiceImplementation<T>, instance: T, lifetime: Lifetime): void {\n const map = this.getMapForLifetime(lifetime);\n map?.set(implementation, instance);\n }\n\n private getMapForLifetime(lifetime: Lifetime) {\n const map: Partial<Record<Lifetime, Map<ServiceImplementation<any>, any>>> = {\n [Lifetime.Singleton]: this.singletons,\n [Lifetime.Scoped]: this.scoped,\n [Lifetime.Resolve]: this.transient,\n };\n return map[lifetime];\n }\n}\n","export const DesignDependenciesKey = 'design:dependencies';\n","import '@abraham/reflection';\nimport type { MetadataType, SourceType } from '../types';\n\nexport const getMetadata = <T extends SourceType>(key: string, obj: object): MetadataType<T> | undefined => Reflect.getMetadata(key, obj);\nexport const defineMetadata = <T extends SourceType>(key: string, metadata: MetadataType<T>, obj: object) => Reflect.defineMetadata(key, metadata, obj);\n","import { Lifetime } from '../enums';\nimport { ResolveMultipleMode } from '../enums';\nimport { MultipleRegistrationError, SelfDependencyError, ServiceCreationError, UnregisteredServiceError } from '../errors';\nimport { type IDisposable, IResolutionScope, IScopedProvider, type IServiceCollection } from '../interfaces';\nimport { IServiceProvider } from '../interfaces';\nimport type { ILogger } from '../logger';\nimport type { ServiceDescriptor, ServiceIdentifier, ServiceImplementation, SourceType } from '../types';\nimport { ResolutionContext } from './ResolutionContext';\nimport { DesignDependenciesKey } from './constants';\nimport { getMetadata } from './metadata';\n\nexport class ServiceProvider implements IServiceProvider, IScopedProvider {\n private scoped = new Map<ServiceImplementation<any>, any>();\n private created: IDisposable[] = [];\n\n constructor(\n private readonly logger: ILogger,\n public readonly Services: IServiceCollection,\n private readonly singletons = new Map<ServiceImplementation<any>, any>(),\n ) {}\n\n [Symbol.dispose]() {\n for (const x of this.created) {\n x[Symbol.dispose]();\n }\n }\n\n private resolveInternal<T extends SourceType>(descriptor: ServiceDescriptor<T>, context: ResolutionContext): T {\n let instance = context.getFromLifetime(descriptor.implementation, descriptor.lifetime);\n if (instance == null) {\n instance = this.createInstance(descriptor, context);\n }\n return instance;\n }\n\n public resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>, context?: ResolutionContext): T[] {\n const descriptors = this.Services.get(identifier);\n return descriptors.map((descriptor) => this.resolveInternal<T>(descriptor, context ?? new ResolutionContext(this.singletons, this.scoped)));\n }\n\n public resolve<T extends SourceType>(identifier: ServiceIdentifier<T>, context?: ResolutionContext): T {\n if (identifier.prototype === IResolutionScope.prototype || identifier.prototype === IScopedProvider.prototype || identifier.prototype === IServiceProvider.prototype) {\n return this as IResolutionScope & IScopedProvider & IServiceProvider as T;\n }\n\n const descriptor = this.getSingleDescriptor(identifier);\n return this.resolveInternal(descriptor, context ?? new ResolutionContext(this.singletons, this.scoped));\n }\n\n private getSingleDescriptor<T extends SourceType>(identifier: ServiceIdentifier<T>) {\n const descriptors = this.Services.get(identifier);\n if (descriptors.length === 0) {\n throw new UnregisteredServiceError(identifier);\n }\n\n if (descriptors.length > 1) {\n if (this.Services.options.registrationMode === ResolveMultipleMode.Error) {\n throw new MultipleRegistrationError(identifier);\n }\n }\n const descriptor = descriptors[descriptors.length - 1];\n return descriptor;\n }\n\n private createInstance<T extends SourceType>(descriptor: ServiceDescriptor<T>, context: ResolutionContext): T {\n const instance = this.createInstanceInternal(descriptor, context);\n this.setDependencies(descriptor.implementation, instance, context);\n context.setForLifetime(descriptor.implementation, instance, descriptor.lifetime);\n return instance;\n }\n\n private wrapContext(context: ResolutionContext): IResolutionScope {\n const resolve = (identifier: ServiceIdentifier<any>) => this.resolve(identifier, context);\n const resolveAll = (identifier: ServiceIdentifier<any>) => this.resolveAll(identifier, context);\n\n return {\n resolve,\n resolveAll,\n };\n }\n\n private createInstanceInternal<T extends SourceType>(descriptor: ServiceDescriptor<T>, context: ResolutionContext) {\n let instance: T | undefined;\n try {\n instance = descriptor.createInstance(this.wrapContext(context));\n } catch (err) {\n this.logger.error(err);\n throw new ServiceCreationError(descriptor.implementation, err);\n }\n if (descriptor.lifetime !== Lifetime.Singleton && Symbol.dispose in instance) {\n this.created.push(instance as IDisposable);\n }\n return instance;\n }\n\n public createScope(): IScopedProvider {\n return new ServiceProvider(this.logger, this.Services.clone(true), this.singletons);\n }\n\n private setDependencies<T extends SourceType>(implementation: ServiceImplementation<T>, instance: T, context: ResolutionContext): T {\n const dependencies = getMetadata<T>(DesignDependenciesKey, implementation) ?? {};\n this.logger.debug('Dependencies', implementation.name, dependencies);\n for (const [key, identifier] of Object.entries(dependencies)) {\n if (identifier !== implementation) {\n this.logger.debug('Resolving', identifier.name, 'for', implementation.name);\n const dep = this.resolve(identifier, context);\n (instance as Record<string, T>)[key] = dep;\n } else {\n throw new SelfDependencyError();\n }\n }\n return instance;\n }\n}\n","import type { Lifetime } from '../enums';\nimport type { IServiceBuilder, IServiceCollection, IServiceProvider } from '../interfaces';\nimport type { ILogger } from '../logger';\nimport type { EnsureObject, ServiceCollectionOptions, ServiceDescriptor, ServiceIdentifier, ServiceModuleType, SourceType, UnionToIntersection } from '../types';\nimport { ServiceBuilder } from './ServiceBuilder';\nimport { ServiceProvider } from './ServiceProvider';\n\nexport class ServiceCollection implements IServiceCollection {\n constructor(\n private readonly logger: ILogger,\n public readonly options: ServiceCollectionOptions,\n private readonly isScoped: boolean,\n private readonly services = new Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>(),\n ) {}\n\n public registerModules(...modules: ServiceModuleType[]): void {\n for (const x of modules) {\n const module = new x();\n module.registerServices(this);\n }\n }\n\n get<T extends SourceType>(key: ServiceIdentifier<T>): ServiceDescriptor<T>[] {\n return this.services.get(key) ?? [];\n }\n\n public overrideLifetime<T extends SourceType>(identifier: ServiceIdentifier<T>, lifetime: Lifetime): void {\n for (const descriptor of this.get(identifier)) {\n descriptor.lifetime = lifetime;\n }\n }\n\n register<Types extends SourceType[]>(...identifiers: { [K in keyof Types]: ServiceIdentifier<Types[K]> }): IServiceBuilder<EnsureObject<UnionToIntersection<Types[number]>>> {\n return new ServiceBuilder(identifiers, this.isScoped, (identifier, descriptor) => this.addService(identifier, descriptor));\n }\n\n private addService<T extends SourceType>(identifier: ServiceIdentifier<T>, descriptor: ServiceDescriptor<T>) {\n this.logger.info('Adding service', { identifier: identifier.name, descriptor });\n let existing = this.services.get(identifier);\n if (existing == null) {\n existing = [];\n this.services.set(identifier, existing);\n }\n existing.push(descriptor);\n }\n\n public clone(scoped?: unknown): IServiceCollection {\n const clonedMap = new Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>();\n for (const [key, descriptors] of this.services) {\n const clonedDescriptors = descriptors.map((descriptor) => ({ ...descriptor }));\n clonedMap.set(key, clonedDescriptors);\n }\n\n return new ServiceCollection(this.logger, this.options, scoped === true, clonedMap);\n }\n\n public buildProvider(): IServiceProvider {\n return new ServiceProvider(this.logger, this.clone());\n }\n}\n","export abstract class ILogger {\n public debug(_message?: any, ..._optionalParams: any[]) {}\n public info(_message?: any, ..._optionalParams: any[]) {}\n public error(_message?: any, ..._optionalParams: any[]) {}\n public warn(_message?: any, ..._optionalParams: any[]) {}\n}\n","import { LogLevel } from '../enums';\nimport { ILogger } from '../logger';\nimport type { ServiceCollectionOptions } from '../types';\n\nexport class ConsoleLogger extends ILogger {\n constructor(private readonly options: ServiceCollectionOptions) {\n super();\n }\n\n public override debug(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Debug) {\n console.debug(message, ...optionalParams);\n }\n }\n\n public override info(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Info) {\n console.info(message, ...optionalParams);\n }\n }\n\n public override warn(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Warn) {\n console.warn(message, ...optionalParams);\n }\n }\n\n public override error(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Error) {\n console.error(message, ...optionalParams);\n }\n }\n}\n","import { DefaultServiceCollectionOptions } from './defaults';\nimport type { IServiceCollection } from './interfaces';\nimport { ServiceCollection } from './private/ServiceCollection';\nimport { ConsoleLogger } from './private/consoleLogger';\nimport type { ServiceCollectionOptions } from './types';\n\nconst mergeOptions = (options: Partial<ServiceCollectionOptions> | undefined): ServiceCollectionOptions => ({\n ...DefaultServiceCollectionOptions,\n ...options,\n});\n\n/**\n * Creates a service collection with the (optionally) provided options\n * @param options - Optional configuration for the service collection.\n * @defaultValue Default options are taken from {@link DefaultServiceCollectionOptions}.\n */\nexport const createServiceCollection = (options?: Partial<ServiceCollectionOptions>): IServiceCollection => {\n const mergedOptions = mergeOptions(options);\n const logger = mergedOptions.logger ?? new ConsoleLogger(mergedOptions);\n return new ServiceCollection(logger, mergedOptions, false);\n};\n","import { IResolutionScope, IScopedProvider, IServiceProvider } from './interfaces';\nimport { DesignDependenciesKey } from './private/constants';\nimport { defineMetadata, getMetadata } from './private/metadata';\nimport type { ServiceIdentifier, SourceType } from './types';\n\nconst tagProperty = <T extends SourceType>(metadataKey: string, annotationTarget: object, name: string | symbol, identifier: ServiceIdentifier<T>) => {\n let existing = getMetadata<T>(metadataKey, annotationTarget);\n if (existing === undefined) {\n existing = {};\n defineMetadata(metadataKey, existing, annotationTarget);\n }\n existing[name] = identifier;\n};\n\n/**\n * declares a dependency, use on a class field.\n * Can also depend on {@link IServiceProvider}, {@link IResolutionScope}, or {@link IScopedProvider}.\n * @param identifier the identifier to depend on, i.e. the interface\n */\nexport const dependsOn = <T extends SourceType>(identifier: ServiceIdentifier<T>) => {\n return (value: undefined, ctx: ClassFieldDecoratorContext) => {\n return function (this: object, initialValue: any) {\n const target = this.constructor;\n tagProperty(DesignDependenciesKey, target, ctx.name, identifier);\n return initialValue;\n };\n };\n};\n"]}
package/package.json CHANGED
@@ -1,57 +1,58 @@
1
1
  {
2
2
  "name": "@shellicar/core-di",
3
- "version": "2.1.0",
3
+ "private": false,
4
+ "version": "2.2.0",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Stephen Hellicar",
4
8
  "description": "A basic dependency injection library",
9
+ "keywords": [
10
+ "dependency injection",
11
+ "di",
12
+ "inversion of control container",
13
+ "ioc"
14
+ ],
5
15
  "repository": {
6
16
  "type": "git",
7
17
  "url": "git+https://github.com/shellicar/core-di.git"
8
18
  },
9
- "private": false,
19
+ "bugs": {
20
+ "url": "https://github.com/shellicar/core-di/issues"
21
+ },
22
+ "homepage": "https://github.com/shellicar/core-di#readme",
10
23
  "publishConfig": {
11
24
  "access": "public"
12
25
  },
13
- "main": "./dist/index.js",
14
- "module": "./dist/index.mjs",
15
- "types": "./dist/index.d.ts",
26
+ "main": "./dist/index.cjs",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.cts",
16
29
  "exports": {
17
30
  ".": {
18
31
  "require": {
19
- "types": "./dist/index.d.ts",
20
- "default": "./dist/index.js"
32
+ "types": "./dist/index.d.cts",
33
+ "default": "./dist/index.cjs"
21
34
  },
22
35
  "import": {
23
36
  "types": "./dist/index.d.ts",
24
- "default": "./dist/index.mjs"
37
+ "default": "./dist/index.js"
25
38
  }
26
39
  }
27
40
  },
28
41
  "files": [
29
42
  "dist"
30
43
  ],
31
- "keywords": [
32
- "dependency injection",
33
- "di",
34
- "inversion of control container",
35
- "ioc"
36
- ],
37
- "author": "Stephen Hellicar",
38
- "license": "MIT",
39
- "bugs": {
40
- "url": "https://github.com/shellicar/core-di/issues"
41
- },
42
- "homepage": "https://github.com/shellicar/core-di#readme",
43
44
  "devDependencies": {
44
45
  "@abraham/reflection": "^0.12.0",
45
46
  "@tsconfig/node20": "^20.1.4",
46
47
  "@types/node": "^22.10.5",
47
48
  "terser": "^5.37.0",
48
49
  "tsup": "^8.3.5",
49
- "typescript": "^5.7.2",
50
+ "typescript": "^5.7.3",
50
51
  "vitest": "^2.1.8"
51
52
  },
52
53
  "scripts": {
53
- "build": "tsup-node",
54
- "dev": "tsup-node --watch",
54
+ "build": "tsup",
55
+ "dev": "tsup --watch",
55
56
  "test": "vitest run",
56
57
  "type-check": "tsc -p tsconfig.check.json"
57
58
  }
package/dist/index.mjs DELETED
@@ -1 +0,0 @@
1
- import"@abraham/reflection";var e=Object.defineProperty,t=(t,s)=>e(t,"name",{value:s,configurable:!0}),s=(e=>(e.Resolve="RESOLVE",e.Transient="TRANSIENT",e.Scoped="SCOPED",e.Singleton="SINGLETON",e))(s||{}),r=(e=>(e[e.Debug=0]="Debug",e[e.Info=1]="Info",e[e.Warn=2]="Warn",e[e.Error=3]="Error",e[e.None=4]="None",e))(r||{}),i=(e=>(e.Error="ERROR",e.LastRegistered="LAST_REGISTERED",e))(i||{}),o={registrationMode:"ERROR",logLevel:2},n=class extends Error{static{t(this,"ServiceError")}},c=class extends n{static{t(this,"UnregisteredServiceError")}name="UnregisteredServiceError";constructor(e){super(`Resolving service that has not been registered: ${e.name}`),Object.setPrototypeOf(this,new.target.prototype)}},a=class extends n{static{t(this,"MultipleRegistrationError")}name="MultipleRegistrationError";constructor(e){super(`Multiple services have been registered: ${e.name}`),Object.setPrototypeOf(this,new.target.prototype)}},l=class extends n{constructor(e,t){super(`Error creating service: ${e.name}`),this.innerError=t,Object.setPrototypeOf(this,new.target.prototype)}static{t(this,"ServiceCreationError")}name="ServiceCreationError"},h=class extends n{static{t(this,"SelfDependencyError")}name="SelfDependencyError";constructor(){super("Service depending on itself"),Object.setPrototypeOf(this,new.target.prototype)}},p=class extends n{static{t(this,"ScopedSingletonRegistrationError")}name="ScopedSingletonRegistrationError";constructor(){super("Cannot register a singleton in a scoped service collection"),Object.setPrototypeOf(this,new.target.prototype)}},g=class{constructor(e,t,s){this.identifiers=e,this.isScoped=t,this.addService=s}static{t(this,"ServiceBuilder")}descriptor;to(e,t){this.descriptor=this.createDescriptor(t,e);for(const e of this.identifiers)this.addService(e,this.descriptor);return this}createDescriptor(e,t){const s=e??(()=>new t);return{implementation:t,createInstance:s,lifetime:"RESOLVE"}}singleton(){if(this.isScoped)throw new p;return this.ensureDescriptor().lifetime="SINGLETON",this}scoped(){return this.ensureDescriptor().lifetime="SCOPED",this}transient(){return this.ensureDescriptor().lifetime="TRANSIENT",this}ensureDescriptor(){if(!this.descriptor)throw new Error("Must call to() before setting lifetime");return this.descriptor}},d=class{static{t(this,"IDisposable")}},u=class{static{t(this,"IServiceModule")}},f=class{static{t(this,"IResolutionScope")}},v=class extends f{static{t(this,"IScopedProvider")}},S=class extends f{static{t(this,"IServiceProvider")}},m=class{static{t(this,"IServiceCollection")}},E=class{static{t(this,"ILifetimeBuilder")}},w=class{static{t(this,"IServiceBuilder")}},I=class{constructor(e,t){this.singletons=e,this.scoped=t}static{t(this,"ResolutionContext")}transient=new Map;getFromLifetime(e,t){const s=this.getMapForLifetime(t);return s?.get(e)}setForLifetime(e,t,s){const r=this.getMapForLifetime(s);r?.set(e,t)}getMapForLifetime(e){return{SINGLETON:this.singletons,SCOPED:this.scoped,RESOLVE:this.transient}[e]}},R="design:dependencies",O=t(((e,t)=>Reflect.getMetadata(e,t)),"getMetadata"),L=t(((e,t,s)=>Reflect.defineMetadata(e,t,s)),"defineMetadata"),b=class e{constructor(e,t,s=new Map){this.logger=e,this.Services=t,this.singletons=s}static{t(this,"ServiceProvider")}scoped=new Map;created=[];[Symbol.dispose](){for(const e of this.created)e[Symbol.dispose]()}resolveInternal(e,t){let s=t.getFromLifetime(e.implementation,e.lifetime);return null==s&&(s=this.createInstance(e,t)),s}resolveAll(e,t){return this.Services.get(e).map((e=>this.resolveInternal(e,t??new I(this.singletons,this.scoped))))}resolve(e,t){if(e.prototype===f.prototype||e.prototype===v.prototype||e.prototype===S.prototype)return this;const s=this.getSingleDescriptor(e);return this.resolveInternal(s,t??new I(this.singletons,this.scoped))}getSingleDescriptor(e){const t=this.Services.get(e);if(0===t.length)throw new c(e);if(t.length>1&&"ERROR"===this.Services.options.registrationMode)throw new a(e);return t[t.length-1]}createInstance(e,t){const s=this.createInstanceInternal(e,t);return this.setDependencies(e.implementation,s,t),t.setForLifetime(e.implementation,s,e.lifetime),s}wrapContext(e){return{resolve:t((t=>this.resolve(t,e)),"resolve"),resolveAll:t((t=>this.resolveAll(t,e)),"resolveAll")}}createInstanceInternal(e,t){let s;try{s=e.createInstance(this.wrapContext(t))}catch(t){throw this.logger.error(t),new l(e.implementation,t)}return"SINGLETON"!==e.lifetime&&Symbol.dispose in s&&this.created.push(s),s}createScope(){return new e(this.logger,this.Services.clone(!0),this.singletons)}setDependencies(e,t,s){const r=O(R,e)??{};this.logger.debug("Dependencies",e.name,r);for(const[i,o]of Object.entries(r)){if(o===e)throw new h;{this.logger.debug("Resolving",o.name,"for",e.name);const r=this.resolve(o,s);t[i]=r}}return t}},y=class e{constructor(e,t,s,r=new Map){this.logger=e,this.options=t,this.isScoped=s,this.services=r}static{t(this,"ServiceCollection")}registerModules(...e){for(const t of e){(new t).registerServices(this)}}get(e){return this.services.get(e)??[]}overrideLifetime(e,t){for(const s of this.get(e))s.lifetime=t}register(...e){return new g(e,this.isScoped,((e,t)=>this.addService(e,t)))}addService(e,t){this.logger.info("Adding service",{identifier:e.name,descriptor:t});let s=this.services.get(e);null==s&&(s=[],this.services.set(e,s)),s.push(t)}clone(t){const s=new Map;for(const[e,t]of this.services){const r=t.map((e=>({...e})));s.set(e,r)}return new e(this.logger,this.options,!0===t,s)}buildProvider(){return new b(this.logger,this.clone())}},D=class{static{t(this,"ILogger")}debug(e,...t){}info(e,...t){}error(e,...t){}warn(e,...t){}},M=class extends D{constructor(e){super(),this.options=e}static{t(this,"ConsoleLogger")}debug(e,...t){this.options.logLevel<=0&&console.debug(e,...t)}info(e,...t){this.options.logLevel<=1&&console.info(e,...t)}warn(e,...t){this.options.logLevel<=2&&console.warn(e,...t)}error(e,...t){this.options.logLevel<=3&&console.error(e,...t)}},N=t((e=>({...o,...e})),"mergeOptions"),P=t((e=>{const t=N(e),s=t.logger??new M(t);return new y(s,t,!1)}),"createServiceCollection"),x=t(((e,t,s,r)=>{let i=O(e,t);void 0===i&&(i={},L(e,i,t)),i[s]=r}),"tagProperty"),C=t((e=>(t,s)=>function(t){const r=this.constructor;return x(R,r,s.name,e),t}),"dependsOn");export{o as DefaultServiceCollectionOptions,d as IDisposable,E as ILifetimeBuilder,D as ILogger,f as IResolutionScope,v as IScopedProvider,w as IServiceBuilder,m as IServiceCollection,u as IServiceModule,S as IServiceProvider,s as Lifetime,r as LogLevel,a as MultipleRegistrationError,i as ResolveMultipleMode,p as ScopedSingletonRegistrationError,h as SelfDependencyError,l as ServiceCreationError,n as ServiceError,c as UnregisteredServiceError,P as createServiceCollection,C as dependsOn};//# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/enums.ts","../src/defaults.ts","../src/errors.ts","../src/private/ServiceBuilder.ts","../src/interfaces.ts","../src/private/ResolutionContext.ts","../src/private/constants.ts","../src/private/metadata.ts","../src/private/ServiceProvider.ts","../src/private/ServiceCollection.ts","../src/logger.ts","../src/private/consoleLogger.ts","../src/createServiceCollection.ts","../src/dependsOn.ts"],"names":["Lifetime","LogLevel","ResolveMultipleMode"],"mappings":";;;;AAAY,IAAA,QAAA,qBAAAA,SAAL,KAAA;AACL,EAAAA,UAAA,SAAU,CAAA,GAAA,SAAA;AACV,EAAAA,UAAA,WAAY,CAAA,GAAA,WAAA;AACZ,EAAAA,UAAA,QAAS,CAAA,GAAA,QAAA;AACT,EAAAA,UAAA,WAAY,CAAA,GAAA,WAAA;AAJF,EAAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA;AAOA,IAAA,QAAA,qBAAAC,SAAL,KAAA;AACL,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,WAAQ,CAAR,CAAA,GAAA,OAA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,\n Warn = 2,\n Error = 3,\n None = 4,\n}\n\nexport enum ResolveMultipleMode {\n Error = 'ERROR',\n LastRegistered = 'LAST_REGISTERED',\n}\n","import { LogLevel, ResolveMultipleMode } from './enums';\nimport type { ServiceCollectionOptions } from './types';\n\nexport const DefaultServiceCollectionOptions: ServiceCollectionOptions = {\n registrationMode: ResolveMultipleMode.Error,\n logLevel: LogLevel.Warn,\n};\n","import type { ServiceIdentifier } from './types';\n\nexport abstract class ServiceError extends Error {}\n\nexport class UnregisteredServiceError<T extends object> extends ServiceError {\n name = 'UnregisteredServiceError';\n constructor(identifier: ServiceIdentifier<T>) {\n super(`Resolving service that has not been registered: ${identifier.name}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class MultipleRegistrationError<T extends object> extends ServiceError {\n name = 'MultipleRegistrationError';\n constructor(identifier: ServiceIdentifier<T>) {\n super(`Multiple services have been registered: ${identifier.name}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class ServiceCreationError<T extends object> extends ServiceError {\n name = 'ServiceCreationError';\n constructor(\n identifier: ServiceIdentifier<T>,\n public readonly innerError: any,\n ) {\n super(`Error creating service: ${identifier.name}`);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class SelfDependencyError extends ServiceError {\n name = 'SelfDependencyError';\n constructor() {\n super('Service depending on itself');\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class ScopedSingletonRegistrationError extends ServiceError {\n name = 'ScopedSingletonRegistrationError';\n constructor() {\n super('Cannot register a singleton in a scoped service collection');\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import { Lifetime } from '../enums';\nimport { ScopedSingletonRegistrationError } from '../errors';\nimport type { ILifetimeBuilder, IServiceBuilder } from '../interfaces';\nimport type { InstanceFactory, ServiceDescriptor, ServiceIdentifier, ServiceImplementation, SourceType } from '../types';\n\nexport class ServiceBuilder<T extends SourceType> implements IServiceBuilder<T> {\n private descriptor: ServiceDescriptor<T> | undefined;\n\n constructor(\n private readonly identifiers: ServiceIdentifier<T>[],\n private readonly isScoped: boolean,\n private readonly addService: (identifier: ServiceIdentifier<T>, descriptor: ServiceDescriptor<T>) => void,\n ) {}\n\n public to(implementation: ServiceImplementation<T>, factory?: InstanceFactory<T>): ILifetimeBuilder {\n this.descriptor = this.createDescriptor(factory, implementation);\n\n for (const identifier of this.identifiers) {\n this.addService(identifier, this.descriptor);\n }\n return this;\n }\n\n private createDescriptor(factory: InstanceFactory<T> | undefined, implementation: ServiceImplementation<T>): ServiceDescriptor<T> {\n const createInstance = factory ?? (() => new implementation());\n\n return {\n implementation,\n createInstance,\n lifetime: Lifetime.Resolve,\n };\n }\n\n public singleton(): this {\n if (this.isScoped) {\n throw new ScopedSingletonRegistrationError();\n }\n this.ensureDescriptor().lifetime = Lifetime.Singleton;\n return this;\n }\n\n public scoped(): this {\n this.ensureDescriptor().lifetime = Lifetime.Scoped;\n return this;\n }\n\n public transient(): this {\n this.ensureDescriptor().lifetime = Lifetime.Transient;\n return this;\n }\n\n private ensureDescriptor(): ServiceDescriptor<T> {\n if (!this.descriptor) {\n throw new Error('Must call to() before setting lifetime');\n }\n return this.descriptor;\n }\n}\n","import type { Lifetime } from './enums';\nimport { ResolveMultipleMode } from './enums';\nimport type { EnsureObject, ServiceBuilderOptions, ServiceCollectionOptions, ServiceDescriptor, ServiceIdentifier, ServiceModuleType, SourceType, UnionToIntersection } from './types';\n\nexport abstract class IDisposable {\n public abstract [Symbol.dispose](): void;\n}\n\nexport abstract class IServiceModule {\n public abstract registerServices(services: IServiceCollection): void;\n}\n\nexport abstract class IResolutionScope {\n /**\n * Resolves a single implementation for the given identifier.\n * @template T The type of service to resolve\n * @param identifier The service identifier\n * @returns The resolved instance\n * @throws {MultipleRegistrationError} When multiple implementations exist (unless {@link ServiceCollectionOptions.registrationMode} is set to {@link ResolveMultipleMode.LastRegistered}).\n * @throws {UnregisteredServiceError} When no implementation exists\n */\n public abstract resolve<T extends SourceType>(identifier: ServiceIdentifier<T>): T;\n\n /**\n * Resolves all implementations for the given identifier.\n * @template T The type of service to resolve\n * @param identifier The service identifier\n * @returns Array of resolved instances\n */\n public abstract resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>): T[];\n}\n\nexport abstract class IScopedProvider extends IResolutionScope implements IDisposable {\n public abstract readonly Services: IServiceCollection;\n public abstract [Symbol.dispose](): void;\n}\n\nexport abstract class IServiceProvider extends IResolutionScope {\n public abstract readonly Services: IServiceCollection;\n public abstract createScope(): IScopedProvider;\n}\n\nexport abstract class IServiceCollection {\n public abstract readonly options: ServiceCollectionOptions;\n public abstract get<T extends SourceType>(identifier: ServiceIdentifier<T>): ServiceDescriptor<T>[];\n public abstract register<Types extends SourceType[]>(...identifiers: { [K in keyof Types]: ServiceIdentifier<Types[K]> }): IServiceBuilder<EnsureObject<UnionToIntersection<Types[number]>>>;\n public abstract registerModules(...modules: ServiceModuleType[]): void;\n public abstract overrideLifetime<T extends SourceType>(identifier: ServiceIdentifier<T>, lifetime: Lifetime): void;\n public abstract buildProvider(): IServiceProvider;\n public abstract clone(): IServiceCollection;\n public abstract clone(scoped: true): IServiceCollection;\n}\n\nexport abstract class ILifetimeBuilder {\n public abstract singleton(): ILifetimeBuilder;\n public abstract scoped(): ILifetimeBuilder;\n public abstract transient(): ILifetimeBuilder;\n}\n\nexport abstract class IServiceBuilder<T extends SourceType> {\n public abstract to: ServiceBuilderOptions<T>;\n}\n","import { Lifetime } from '../enums';\nimport type { ServiceImplementation, SourceType } from '../types';\n\nexport class ResolutionContext {\n constructor(\n private readonly singletons: Map<ServiceImplementation<any>, any>,\n private readonly scoped: Map<ServiceImplementation<any>, any>,\n ) {}\n\n private readonly transient = new Map<ServiceImplementation<any>, any>();\n\n public getFromLifetime<T extends SourceType>(implementation: ServiceImplementation<T>, lifetime: Lifetime): T {\n const map = this.getMapForLifetime(lifetime);\n return map?.get(implementation);\n }\n\n public setForLifetime<T extends SourceType>(implementation: ServiceImplementation<T>, instance: T, lifetime: Lifetime): void {\n const map = this.getMapForLifetime(lifetime);\n map?.set(implementation, instance);\n }\n\n private getMapForLifetime(lifetime: Lifetime) {\n const map: Partial<Record<Lifetime, Map<ServiceImplementation<any>, any>>> = {\n [Lifetime.Singleton]: this.singletons,\n [Lifetime.Scoped]: this.scoped,\n [Lifetime.Resolve]: this.transient,\n };\n return map[lifetime];\n }\n}\n","export const DesignDependenciesKey = 'design:dependencies';\n","import '@abraham/reflection';\nimport type { MetadataType, SourceType } from '../types';\n\nexport const getMetadata = <T extends SourceType>(key: string, obj: object): MetadataType<T> | undefined => Reflect.getMetadata(key, obj);\nexport const defineMetadata = <T extends SourceType>(key: string, metadata: MetadataType<T>, obj: object) => Reflect.defineMetadata(key, metadata, obj);\n","import { Lifetime } from '../enums';\nimport { ResolveMultipleMode } from '../enums';\nimport { MultipleRegistrationError, SelfDependencyError, ServiceCreationError, UnregisteredServiceError } from '../errors';\nimport { type IDisposable, IResolutionScope, IScopedProvider, type IServiceCollection } from '../interfaces';\nimport { IServiceProvider } from '../interfaces';\nimport type { ILogger } from '../logger';\nimport type { ServiceDescriptor, ServiceIdentifier, ServiceImplementation, SourceType } from '../types';\nimport { ResolutionContext } from './ResolutionContext';\nimport { DesignDependenciesKey } from './constants';\nimport { getMetadata } from './metadata';\n\nexport class ServiceProvider implements IServiceProvider, IScopedProvider {\n private scoped = new Map<ServiceImplementation<any>, any>();\n private created: IDisposable[] = [];\n\n constructor(\n private readonly logger: ILogger,\n public readonly Services: IServiceCollection,\n private readonly singletons = new Map<ServiceImplementation<any>, any>(),\n ) {}\n\n [Symbol.dispose]() {\n for (const x of this.created) {\n x[Symbol.dispose]();\n }\n }\n\n private resolveInternal<T extends SourceType>(descriptor: ServiceDescriptor<T>, context: ResolutionContext): T {\n let instance = context.getFromLifetime(descriptor.implementation, descriptor.lifetime);\n if (instance == null) {\n instance = this.createInstance(descriptor, context);\n }\n return instance;\n }\n\n public resolveAll<T extends SourceType>(identifier: ServiceIdentifier<T>, context?: ResolutionContext): T[] {\n const descriptors = this.Services.get(identifier);\n return descriptors.map((descriptor) => this.resolveInternal<T>(descriptor, context ?? new ResolutionContext(this.singletons, this.scoped)));\n }\n\n public resolve<T extends SourceType>(identifier: ServiceIdentifier<T>, context?: ResolutionContext): T {\n if (identifier.prototype === IResolutionScope.prototype || identifier.prototype === IScopedProvider.prototype || identifier.prototype === IServiceProvider.prototype) {\n return this as IResolutionScope & IScopedProvider & IServiceProvider as T;\n }\n\n const descriptor = this.getSingleDescriptor(identifier);\n return this.resolveInternal(descriptor, context ?? new ResolutionContext(this.singletons, this.scoped));\n }\n\n private getSingleDescriptor<T extends SourceType>(identifier: ServiceIdentifier<T>) {\n const descriptors = this.Services.get(identifier);\n if (descriptors.length === 0) {\n throw new UnregisteredServiceError(identifier);\n }\n\n if (descriptors.length > 1) {\n if (this.Services.options.registrationMode === ResolveMultipleMode.Error) {\n throw new MultipleRegistrationError(identifier);\n }\n }\n const descriptor = descriptors[descriptors.length - 1];\n return descriptor;\n }\n\n private createInstance<T extends SourceType>(descriptor: ServiceDescriptor<T>, context: ResolutionContext): T {\n const instance = this.createInstanceInternal(descriptor, context);\n this.setDependencies(descriptor.implementation, instance, context);\n context.setForLifetime(descriptor.implementation, instance, descriptor.lifetime);\n return instance;\n }\n\n private wrapContext(context: ResolutionContext): IResolutionScope {\n const resolve = (identifier: ServiceIdentifier<any>) => this.resolve(identifier, context);\n const resolveAll = (identifier: ServiceIdentifier<any>) => this.resolveAll(identifier, context);\n\n return {\n resolve,\n resolveAll,\n };\n }\n\n private createInstanceInternal<T extends SourceType>(descriptor: ServiceDescriptor<T>, context: ResolutionContext) {\n let instance: T | undefined;\n try {\n instance = descriptor.createInstance(this.wrapContext(context));\n } catch (err) {\n this.logger.error(err);\n throw new ServiceCreationError(descriptor.implementation, err);\n }\n if (descriptor.lifetime !== Lifetime.Singleton && Symbol.dispose in instance) {\n this.created.push(instance as IDisposable);\n }\n return instance;\n }\n\n public createScope(): IScopedProvider {\n return new ServiceProvider(this.logger, this.Services.clone(true), this.singletons);\n }\n\n private setDependencies<T extends SourceType>(implementation: ServiceImplementation<T>, instance: T, context: ResolutionContext): T {\n const dependencies = getMetadata<T>(DesignDependenciesKey, implementation) ?? {};\n this.logger.debug('Dependencies', implementation.name, dependencies);\n for (const [key, identifier] of Object.entries(dependencies)) {\n if (identifier !== implementation) {\n this.logger.debug('Resolving', identifier.name, 'for', implementation.name);\n const dep = this.resolve(identifier, context);\n (instance as Record<string, T>)[key] = dep;\n } else {\n throw new SelfDependencyError();\n }\n }\n return instance;\n }\n}\n","import type { Lifetime } from '../enums';\nimport type { IServiceBuilder, IServiceCollection, IServiceProvider } from '../interfaces';\nimport type { ILogger } from '../logger';\nimport type { EnsureObject, ServiceCollectionOptions, ServiceDescriptor, ServiceIdentifier, ServiceModuleType, SourceType, UnionToIntersection } from '../types';\nimport { ServiceBuilder } from './ServiceBuilder';\nimport { ServiceProvider } from './ServiceProvider';\n\nexport class ServiceCollection implements IServiceCollection {\n constructor(\n private readonly logger: ILogger,\n public readonly options: ServiceCollectionOptions,\n private readonly isScoped: boolean,\n private readonly services = new Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>(),\n ) {}\n\n public registerModules(...modules: ServiceModuleType[]): void {\n for (const x of modules) {\n const module = new x();\n module.registerServices(this);\n }\n }\n\n get<T extends SourceType>(key: ServiceIdentifier<T>): ServiceDescriptor<T>[] {\n return this.services.get(key) ?? [];\n }\n\n public overrideLifetime<T extends SourceType>(identifier: ServiceIdentifier<T>, lifetime: Lifetime): void {\n for (const descriptor of this.get(identifier)) {\n descriptor.lifetime = lifetime;\n }\n }\n\n register<Types extends SourceType[]>(...identifiers: { [K in keyof Types]: ServiceIdentifier<Types[K]> }): IServiceBuilder<EnsureObject<UnionToIntersection<Types[number]>>> {\n return new ServiceBuilder(identifiers, this.isScoped, (identifier, descriptor) => this.addService(identifier, descriptor));\n }\n\n private addService<T extends SourceType>(identifier: ServiceIdentifier<T>, descriptor: ServiceDescriptor<T>) {\n this.logger.info('Adding service', { identifier: identifier.name, descriptor });\n let existing = this.services.get(identifier);\n if (existing == null) {\n existing = [];\n this.services.set(identifier, existing);\n }\n existing.push(descriptor);\n }\n\n public clone(scoped?: unknown): IServiceCollection {\n const clonedMap = new Map<ServiceIdentifier<any>, ServiceDescriptor<any>[]>();\n for (const [key, descriptors] of this.services) {\n const clonedDescriptors = descriptors.map((descriptor) => ({ ...descriptor }));\n clonedMap.set(key, clonedDescriptors);\n }\n\n return new ServiceCollection(this.logger, this.options, scoped === true, clonedMap);\n }\n\n public buildProvider(): IServiceProvider {\n return new ServiceProvider(this.logger, this.clone());\n }\n}\n","export abstract class ILogger {\n public debug(_message?: any, ..._optionalParams: any[]) {}\n public info(_message?: any, ..._optionalParams: any[]) {}\n public error(_message?: any, ..._optionalParams: any[]) {}\n public warn(_message?: any, ..._optionalParams: any[]) {}\n}\n","import { LogLevel } from '../enums';\nimport { ILogger } from '../logger';\nimport type { ServiceCollectionOptions } from '../types';\n\nexport class ConsoleLogger extends ILogger {\n constructor(private readonly options: ServiceCollectionOptions) {\n super();\n }\n\n public override debug(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Debug) {\n console.debug(message, ...optionalParams);\n }\n }\n\n public override info(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Info) {\n console.info(message, ...optionalParams);\n }\n }\n\n public override warn(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Warn) {\n console.warn(message, ...optionalParams);\n }\n }\n\n public override error(message?: any, ...optionalParams: any[]): void {\n if (this.options.logLevel <= LogLevel.Error) {\n console.error(message, ...optionalParams);\n }\n }\n}\n","import { DefaultServiceCollectionOptions } from './defaults';\nimport type { IServiceCollection } from './interfaces';\nimport { ServiceCollection } from './private/ServiceCollection';\nimport { ConsoleLogger } from './private/consoleLogger';\nimport type { ServiceCollectionOptions } from './types';\n\nconst mergeOptions = (options: Partial<ServiceCollectionOptions> | undefined): ServiceCollectionOptions => ({\n ...DefaultServiceCollectionOptions,\n ...options,\n});\n\n/**\n * Creates a service collection with the (optionally) provided options\n * @param options - Optional configuration for the service collection.\n * @defaultValue Default options are taken from {@link DefaultServiceCollectionOptions}.\n */\nexport const createServiceCollection = (options?: Partial<ServiceCollectionOptions>): IServiceCollection => {\n const mergedOptions = mergeOptions(options);\n const logger = mergedOptions.logger ?? new ConsoleLogger(mergedOptions);\n return new ServiceCollection(logger, mergedOptions, false);\n};\n","import { IResolutionScope, IScopedProvider, IServiceProvider } from './interfaces';\nimport { DesignDependenciesKey } from './private/constants';\nimport { defineMetadata, getMetadata } from './private/metadata';\nimport type { ServiceIdentifier, SourceType } from './types';\n\nconst tagProperty = <T extends SourceType>(metadataKey: string, annotationTarget: object, name: string | symbol, identifier: ServiceIdentifier<T>) => {\n let existing = getMetadata<T>(metadataKey, annotationTarget);\n if (existing === undefined) {\n existing = {};\n defineMetadata(metadataKey, existing, annotationTarget);\n }\n existing[name] = identifier;\n};\n\n/**\n * declares a dependency, use on a class field.\n * Can also depend on {@link IServiceProvider}, {@link IResolutionScope}, or {@link IScopedProvider}.\n * @param identifier the identifier to depend on, i.e. the interface\n */\nexport const dependsOn = <T extends SourceType>(identifier: ServiceIdentifier<T>) => {\n return (value: undefined, ctx: ClassFieldDecoratorContext) => {\n return function (this: object, initialValue: any) {\n const target = this.constructor;\n tagProperty(DesignDependenciesKey, target, ctx.name, identifier);\n return initialValue;\n };\n };\n};\n"]}
File without changes