@shellicar/core-di 2.1.1 → 2.3.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 +13 -13
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -5,24 +5,24 @@
|
|
|
5
5
|
## Installation & Quick Start
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
|
|
8
|
+
pnpm install @shellicar/core-di
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
pnpm add @shellicar/core-di
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import { createServiceCollection } from '@shellicar/core-di';
|
|
11
|
+
## Quick Example
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
```typescript
|
|
14
|
+
import { Container, injectable } from '@shellicar/core-di';
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
@injectable()
|
|
17
|
+
class Foo {
|
|
18
|
+
sayHello() {
|
|
19
|
+
console.log('Hello from Foo');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
24
22
|
|
|
25
|
-
const
|
|
23
|
+
const container = new Container();
|
|
24
|
+
const foo = container.resolve(Foo);
|
|
25
|
+
foo.sayHello();
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
## Documentation
|
package/dist/index.cjs
CHANGED
|
@@ -1 +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||{}),
|
|
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||{}),E=(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))(E||{}),w=(e=>(e.Error="ERROR",e.LastRegistered="LAST_REGISTERED",e))(w||{}),M={registrationMode:"ERROR",logLevel:2},O=t((()=>new Map),"createRegistrationMap"),y=t((()=>new Map),"createDescriptorMap"),I=class extends Error{static{t(this,"ServiceError")}},R=class extends I{static{t(this,"UnregisteredServiceError")}name="UnregisteredServiceError";constructor(e){super(`Resolving service that has not been registered: ${e.name}`),Object.setPrototypeOf(this,new.target.prototype)}},x=class extends I{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 I{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 I{static{t(this,"SelfDependencyError")}name="SelfDependencyError";constructor(){super("Service depending on itself"),Object.setPrototypeOf(this,new.target.prototype)}},D=class extends I{static{t(this,"ScopedSingletonRegistrationError")}name="ScopedSingletonRegistrationError";constructor(){super("Cannot register a singleton in a scoped service collection"),Object.setPrototypeOf(this,new.target.prototype)}},P=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){return{implementation:t,lifetime:"RESOLVE",createInstance:e??(()=>new t)}}singleton(){if(this.isScoped)throw new D;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}},C=class{static{t(this,"IDisposable")}},N=class{static{t(this,"IServiceModule")}},T=class{static{t(this,"IResolutionScope")}},j=class extends T{static{t(this,"IScopedProvider")}},A=class extends T{static{t(this,"IServiceProvider")}},F=class{static{t(this,"IServiceCollection")}},G=class{static{t(this,"ILifetimeBuilder")}},B=class{static{t(this,"IServiceBuilder")}},U=class{constructor(e,t){this.singletons=e,this.scoped=t}static{t(this,"ResolutionContext")}transient=O();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]}},V="design:dependencies",W=t(((e,t)=>Reflect.getMetadata(e,t)),"getMetadata"),$=t(((e,t,r)=>Reflect.defineMetadata(e,t,r)),"defineMetadata"),k=class e{constructor(e,t,r=O()){this.logger=e,this.Services=t,this.singletons=r}static{t(this,"ServiceProvider")}scoped=O();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 U(this.singletons,this.scoped))))}resolve(e,t){if(e.prototype===T.prototype||e.prototype===j.prototype||e.prototype===A.prototype)return this;const r=this.getSingleDescriptor(e);return this.resolveInternal(r,t??new U(this.singletons,this.scoped))}getSingleDescriptor(e){const t=this.Services.get(e);if(0===t.length)throw new R(e);if(t.length>1&&"ERROR"===this.Services.options.registrationMode)throw new x(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 L(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=W(V,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}},_=class e{constructor(e,t,r,s=y()){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 P(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=y();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 k(this.logger,this.clone())}},q=class{static{t(this,"ILogger")}debug(e,...t){}info(e,...t){}error(e,...t){}warn(e,...t){}},z=class extends q{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)}},H=t((e=>({...M,...e})),"mergeOptions"),J=t((e=>{const t=H(e),r=t.logger??new z(t);return new _(r,t,!1)}),"createServiceCollection"),K=t(((e,t,r,s)=>{let i=W(e,t);void 0===i&&(i={},$(e,i,t)),i[r]=s}),"tagProperty"),Q=t((e=>(t,r)=>function(t){const s=this.constructor;return K(V,s,r.name,e),t}),"dependsOn");exports.DefaultServiceCollectionOptions=M,exports.IDisposable=C,exports.ILifetimeBuilder=G,exports.ILogger=q,exports.IResolutionScope=T,exports.IScopedProvider=j,exports.IServiceBuilder=B,exports.IServiceCollection=F,exports.IServiceModule=N,exports.IServiceProvider=A,exports.Lifetime=m,exports.LogLevel=E,exports.MultipleRegistrationError=x,exports.ResolveMultipleMode=w,exports.ScopedSingletonRegistrationError=D,exports.SelfDependencyError=b,exports.ServiceCreationError=L,exports.ServiceError=I,exports.UnregisteredServiceError=R,exports.createServiceCollection=J,exports.dependsOn=Q;//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +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;AAVS,MAAA,CAAA,gBAAA,EAAA,kBAAA,CAAA;AAYT,SAAS,mBAAA,CACP,YACA,MAAgB,EAAA;AAEhB,EAAA,UAAA,CAAW,OAAO,EAAA,CAAG,OAAQ,CAAA,CAAC,SAA6B,KAAA;AACzD,IAAM,MAAA,SAAA,GAAY,UAAU,MAAM,CAAA;AAClC,IAAA,IAAI,SAAW,EAAA;AACb,MAAS,MAAA,GAAA,SAAA;;GAEZ,CAAA;AACD,EAAO,OAAA,MAAA;AACT;AAXS,MAAA,CAAA,mBAAA,EAAA,qBAAA,CAAA;AAuBH,SAAU,QACd,CAAA,UAAA,EACA,MACA,EAAA,WAAA,EACA,UAA+B,EAAA;AAE/B,EAAA,IAAI,CAAC,KAAM,CAAA,OAAA,CAAQ,UAAU,CAAK,IAAA,UAAA,CAAW,WAAW,CAAG,EAAA;AACzD,IAAA,MAAM,IAAI,SAAS,EAAA;;AAGrB,EAAA,IAAI,gBAAgB,SAAW,EAAA;AAC7B,IAAA,OAAO,gBACL,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,GAAG;AACL,CAHqB,CAAA,EAAA,cAAA,CAAA;AAUR,IAAA,uBAAA,2BAA2B,OAAoE,KAAA;AAC1G,EAAM,MAAA,aAAA,GAAgB,aAAa,OAAO,CAAA;AAC1C,EAAA,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,GAAWA,YAAe,CAAA,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.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"]}
|
|
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/types.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;AAVS,MAAA,CAAA,gBAAA,EAA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AAa,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.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 { Lifetime, LogLevel, ResolveMultipleMode } from './enums';\nimport type { ILifetimeBuilder, IResolutionScope, IServiceModule } from './interfaces';\nimport type { ILogger } from './logger';\nimport type { ConsoleLogger } from './private/consoleLogger';\n\nexport type SourceType = object;\n\nexport type AbstractNewable<T> = abstract new (...args: any[]) => T;\nexport type Newable<T> = new (...args: any[]) => T;\n\nexport type ServiceIdentifier<T extends SourceType> = { prototype: T; name: string }; //AbstractNewable<T>;\nexport type ServiceImplementation<T extends SourceType> = Newable<T>;\nexport type ServiceRegistration<T extends SourceType> = ServiceIdentifier<T> | ServiceImplementation<T>;\n\nexport type InstanceFactory<T extends SourceType> = (x: IResolutionScope) => T;\n\nexport type ServiceModuleType = Newable<IServiceModule>;\n\nexport type ServiceDescriptor<T extends SourceType> = {\n readonly implementation: ServiceRegistration<T>;\n lifetime: Lifetime;\n createInstance(context: IResolutionScope): T;\n};\n\nexport type MetadataType<T extends SourceType> = Record<string | symbol, ServiceIdentifier<T>>;\n\nexport type ServiceCollectionOptions = {\n /**\n * Whether calling `resolve` when there are multiple registrations\n * will result in an error or resolve the last registered service.\n * @default ResolveMultipleMode.Error\n */\n registrationMode: ResolveMultipleMode;\n /**\n * The default log level for the console logger.\n * @defaultValue {@link LogLevel.Warn}\n */\n logLevel: LogLevel;\n /**\n * Custom implementation for logger. Ignores log level.\n * @defaultValue {@link ConsoleLogger}\n */\n logger?: ILogger;\n};\n\nexport type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;\n\nexport type EnsureObject<T> = T extends object ? T : never;\n\nexport type ServiceBuilderOptions<T extends SourceType> = {\n (implementation: ServiceImplementation<T>): ILifetimeBuilder;\n (implementation: ServiceIdentifier<T>, factory: InstanceFactory<T>): ILifetimeBuilder;\n};\n\nexport type RegistrationMap<T extends SourceType = any> = Map<ServiceRegistration<T>, T>;\nexport type DescriptorMap<T extends SourceType = any> = Map<ServiceIdentifier<T>, ServiceDescriptor<T>[]>;\n\nexport const createRegistrationMap = <T extends SourceType = any>() => {\n return new Map<ServiceRegistration<T>, T>();\n};\n\nexport const createDescriptorMap = <T extends SourceType = any>() => {\n return new Map<ServiceIdentifier<T>, ServiceDescriptor<T>[]>();\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, ServiceRegistration, 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>): ILifetimeBuilder;\n public to(implementation: ServiceIdentifier<T>, factory?: InstanceFactory<T>): ILifetimeBuilder;\n public to(implementation: ServiceRegistration<T>, factory?: InstanceFactory<T> | undefined): 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: ServiceRegistration<T>): ServiceDescriptor<T> {\n return {\n implementation,\n lifetime: Lifetime.Resolve,\n createInstance: factory ?? (() => new (implementation as ServiceImplementation<T>)()),\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 RegistrationMap, type ServiceRegistration, type SourceType, createRegistrationMap } from '../types';\n\nexport class ResolutionContext {\n constructor(\n private readonly singletons: RegistrationMap,\n private readonly scoped: RegistrationMap,\n ) {}\n\n private readonly transient: RegistrationMap = createRegistrationMap();\n\n public getFromLifetime<T extends SourceType>(implementation: ServiceRegistration<T>, lifetime: Lifetime): T | null {\n const map = this.getMapForLifetime(lifetime);\n return map?.get(implementation);\n }\n\n public setForLifetime<T extends SourceType>(implementation: ServiceRegistration<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, RegistrationMap>> = {\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, type ServiceIdentifier, type ServiceImplementation, type ServiceRegistration, type SourceType, createRegistrationMap } from '../types';\nimport { ResolutionContext } from './ResolutionContext';\nimport { DesignDependenciesKey } from './constants';\nimport { getMetadata } from './metadata';\n\nexport class ServiceProvider implements IServiceProvider, IScopedProvider {\n private scoped = createRegistrationMap();\n private created: IDisposable[] = [];\n\n constructor(\n private readonly logger: ILogger,\n public readonly Services: IServiceCollection,\n private readonly singletons = createRegistrationMap(),\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: ServiceRegistration<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 DescriptorMap, type EnsureObject, type ServiceCollectionOptions, type ServiceDescriptor, type ServiceIdentifier, type ServiceModuleType, type SourceType, type UnionToIntersection, createDescriptorMap } 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 = createDescriptorMap(),\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: DescriptorMap = createDescriptorMap();\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.d.cts
CHANGED
|
@@ -31,10 +31,11 @@ type ServiceIdentifier<T extends SourceType> = {
|
|
|
31
31
|
name: string;
|
|
32
32
|
};
|
|
33
33
|
type ServiceImplementation<T extends SourceType> = Newable<T>;
|
|
34
|
+
type ServiceRegistration<T extends SourceType> = ServiceIdentifier<T> | ServiceImplementation<T>;
|
|
34
35
|
type InstanceFactory<T extends SourceType> = (x: IResolutionScope) => T;
|
|
35
36
|
type ServiceModuleType = Newable<IServiceModule>;
|
|
36
37
|
type ServiceDescriptor<T extends SourceType> = {
|
|
37
|
-
readonly implementation:
|
|
38
|
+
readonly implementation: ServiceRegistration<T>;
|
|
38
39
|
lifetime: Lifetime;
|
|
39
40
|
createInstance(context: IResolutionScope): T;
|
|
40
41
|
};
|
|
@@ -61,7 +62,7 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
|
61
62
|
type EnsureObject<T> = T extends object ? T : never;
|
|
62
63
|
type ServiceBuilderOptions<T extends SourceType> = {
|
|
63
64
|
(implementation: ServiceImplementation<T>): ILifetimeBuilder;
|
|
64
|
-
(implementation:
|
|
65
|
+
(implementation: ServiceIdentifier<T>, factory: InstanceFactory<T>): ILifetimeBuilder;
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
declare abstract class IDisposable {
|
|
@@ -157,4 +158,4 @@ declare class ScopedSingletonRegistrationError extends ServiceError {
|
|
|
157
158
|
constructor();
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
export { type AbstractNewable, DefaultServiceCollectionOptions, IDisposable, ILifetimeBuilder, ILogger, IResolutionScope, IScopedProvider, IServiceBuilder, IServiceCollection, IServiceModule, IServiceProvider, type InstanceFactory, Lifetime, LogLevel, type MetadataType, MultipleRegistrationError, type Newable, ResolveMultipleMode, ScopedSingletonRegistrationError, SelfDependencyError, type ServiceCollectionOptions, ServiceCreationError, type ServiceDescriptor, ServiceError, type ServiceIdentifier, type ServiceImplementation, type ServiceModuleType, type SourceType, UnregisteredServiceError, createServiceCollection, dependsOn };
|
|
161
|
+
export { type AbstractNewable, DefaultServiceCollectionOptions, IDisposable, ILifetimeBuilder, ILogger, IResolutionScope, IScopedProvider, IServiceBuilder, IServiceCollection, IServiceModule, IServiceProvider, type InstanceFactory, Lifetime, LogLevel, type MetadataType, MultipleRegistrationError, type Newable, ResolveMultipleMode, ScopedSingletonRegistrationError, SelfDependencyError, type ServiceCollectionOptions, ServiceCreationError, type ServiceDescriptor, ServiceError, type ServiceIdentifier, type ServiceImplementation, type ServiceModuleType, type ServiceRegistration, type SourceType, UnregisteredServiceError, createServiceCollection, dependsOn };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,10 +31,11 @@ type ServiceIdentifier<T extends SourceType> = {
|
|
|
31
31
|
name: string;
|
|
32
32
|
};
|
|
33
33
|
type ServiceImplementation<T extends SourceType> = Newable<T>;
|
|
34
|
+
type ServiceRegistration<T extends SourceType> = ServiceIdentifier<T> | ServiceImplementation<T>;
|
|
34
35
|
type InstanceFactory<T extends SourceType> = (x: IResolutionScope) => T;
|
|
35
36
|
type ServiceModuleType = Newable<IServiceModule>;
|
|
36
37
|
type ServiceDescriptor<T extends SourceType> = {
|
|
37
|
-
readonly implementation:
|
|
38
|
+
readonly implementation: ServiceRegistration<T>;
|
|
38
39
|
lifetime: Lifetime;
|
|
39
40
|
createInstance(context: IResolutionScope): T;
|
|
40
41
|
};
|
|
@@ -61,7 +62,7 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
|
61
62
|
type EnsureObject<T> = T extends object ? T : never;
|
|
62
63
|
type ServiceBuilderOptions<T extends SourceType> = {
|
|
63
64
|
(implementation: ServiceImplementation<T>): ILifetimeBuilder;
|
|
64
|
-
(implementation:
|
|
65
|
+
(implementation: ServiceIdentifier<T>, factory: InstanceFactory<T>): ILifetimeBuilder;
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
declare abstract class IDisposable {
|
|
@@ -157,4 +158,4 @@ declare class ScopedSingletonRegistrationError extends ServiceError {
|
|
|
157
158
|
constructor();
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
export { type AbstractNewable, DefaultServiceCollectionOptions, IDisposable, ILifetimeBuilder, ILogger, IResolutionScope, IScopedProvider, IServiceBuilder, IServiceCollection, IServiceModule, IServiceProvider, type InstanceFactory, Lifetime, LogLevel, type MetadataType, MultipleRegistrationError, type Newable, ResolveMultipleMode, ScopedSingletonRegistrationError, SelfDependencyError, type ServiceCollectionOptions, ServiceCreationError, type ServiceDescriptor, ServiceError, type ServiceIdentifier, type ServiceImplementation, type ServiceModuleType, type SourceType, UnregisteredServiceError, createServiceCollection, dependsOn };
|
|
161
|
+
export { type AbstractNewable, DefaultServiceCollectionOptions, IDisposable, ILifetimeBuilder, ILogger, IResolutionScope, IScopedProvider, IServiceBuilder, IServiceCollection, IServiceModule, IServiceProvider, type InstanceFactory, Lifetime, LogLevel, type MetadataType, MultipleRegistrationError, type Newable, ResolveMultipleMode, ScopedSingletonRegistrationError, SelfDependencyError, type ServiceCollectionOptions, ServiceCreationError, type ServiceDescriptor, ServiceError, type ServiceIdentifier, type ServiceImplementation, type ServiceModuleType, type ServiceRegistration, type SourceType, UnregisteredServiceError, createServiceCollection, dependsOn };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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")}},
|
|
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=t((()=>new Map),"createRegistrationMap"),O=t((()=>new Map),"createDescriptorMap"),R=class extends Error{static{t(this,"ServiceError")}},I=class extends R{static{t(this,"UnregisteredServiceError")}name="UnregisteredServiceError";constructor(e){super(`Resolving service that has not been registered: ${e.name}`),Object.setPrototypeOf(this,new.target.prototype)}},b=class extends R{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 R{constructor(e,t){super(`Error creating service: ${e.name}`),this.innerError=t,Object.setPrototypeOf(this,new.target.prototype)}static{t(this,"ServiceCreationError")}name="ServiceCreationError"},D=class extends R{static{t(this,"SelfDependencyError")}name="SelfDependencyError";constructor(){super("Service depending on itself"),Object.setPrototypeOf(this,new.target.prototype)}},P=class extends R{static{t(this,"ScopedSingletonRegistrationError")}name="ScopedSingletonRegistrationError";constructor(){super("Cannot register a singleton in a scoped service collection"),Object.setPrototypeOf(this,new.target.prototype)}},C=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){return{implementation:t,lifetime:"RESOLVE",createInstance:e??(()=>new t)}}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}},N=class{static{t(this,"IDisposable")}},T=class{static{t(this,"IServiceModule")}},x=class{static{t(this,"IResolutionScope")}},j=class extends x{static{t(this,"IScopedProvider")}},A=class extends x{static{t(this,"IServiceProvider")}},F=class{static{t(this,"IServiceCollection")}},G=class{static{t(this,"ILifetimeBuilder")}},B=class{static{t(this,"IServiceBuilder")}},V=class{constructor(e,t){this.singletons=e,this.scoped=t}static{t(this,"ResolutionContext")}transient=y();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]}},W="design:dependencies",$=t(((e,t)=>Reflect.getMetadata(e,t)),"getMetadata"),U=t(((e,t,r)=>Reflect.defineMetadata(e,t,r)),"defineMetadata"),k=class e{constructor(e,t,r=y()){this.logger=e,this.Services=t,this.singletons=r}static{t(this,"ServiceProvider")}scoped=y();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 V(this.singletons,this.scoped))))}resolve(e,t){if(e.prototype===x.prototype||e.prototype===j.prototype||e.prototype===A.prototype)return this;const r=this.getSingleDescriptor(e);return this.resolveInternal(r,t??new V(this.singletons,this.scoped))}getSingleDescriptor(e){const t=this.Services.get(e);if(0===t.length)throw new I(e);if(t.length>1&&"ERROR"===this.Services.options.registrationMode)throw new b(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 L(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=$(W,e)??{};this.logger.debug("Dependencies",e.name,s);for(const[i,o]of Object.entries(s)){if(o===e)throw new D;{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=O()){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 C(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=O();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 k(this.logger,this.clone())}},q=class{static{t(this,"ILogger")}debug(e,...t){}info(e,...t){}error(e,...t){}warn(e,...t){}},z=class extends q{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)}},H=t((e=>({...M,...e})),"mergeOptions"),J=t((e=>{const t=H(e),r=t.logger??new z(t);return new _(r,t,!1)}),"createServiceCollection"),K=t(((e,t,r,s)=>{let i=$(e,t);void 0===i&&(i={},U(e,i,t)),i[r]=s}),"tagProperty"),Q=t((e=>(t,r)=>function(t){const s=this.constructor;return K(W,s,r.name,e),t}),"dependsOn");export{M as DefaultServiceCollectionOptions,N as IDisposable,G as ILifetimeBuilder,q as ILogger,x as IResolutionScope,j as IScopedProvider,B as IServiceBuilder,F as IServiceCollection,T as IServiceModule,A as IServiceProvider,m as Lifetime,w as LogLevel,b as MultipleRegistrationError,E as ResolveMultipleMode,P as ScopedSingletonRegistrationError,D as SelfDependencyError,L as ServiceCreationError,R as ServiceError,I as UnregisteredServiceError,J as createServiceCollection,Q as dependsOn};//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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;AAVS,MAAA,CAAA,gBAAA,EAAA,kBAAA,CAAA;AAYT,SAAS,mBAAA,CACP,YACA,MAAgB,EAAA;AAEhB,EAAA,UAAA,CAAW,OAAO,EAAA,CAAG,OAAQ,CAAA,CAAC,SAA6B,KAAA;AACzD,IAAM,MAAA,SAAA,GAAY,UAAU,MAAM,CAAA;AAClC,IAAA,IAAI,SAAW,EAAA;AACb,MAAS,MAAA,GAAA,SAAA;;GAEZ,CAAA;AACD,EAAO,OAAA,MAAA;AACT;AAXS,MAAA,CAAA,mBAAA,EAAA,qBAAA,CAAA;AAuBH,SAAU,QACd,CAAA,UAAA,EACA,MACA,EAAA,WAAA,EACA,UAA+B,EAAA;AAE/B,EAAA,I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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"]}
|
|
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/types.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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K,CAAA;AAC3D,CAJuC,EAAA,yBAAA;;;ACXvC,IAAM,WAAc,mBAAA,MAAA,CAAA,CAAuB,WAAqB,EAAA,gBAAA,EAA0B,MAAuB,UAAqC,KAAA;AACpJ,EAAI,IAAA,QAAA,GAAWA,YAAe,CAAA,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 { Lifetime, LogLevel, ResolveMultipleMode } from './enums';\nimport type { ILifetimeBuilder, IResolutionScope, IServiceModule } from './interfaces';\nimport type { ILogger } from './logger';\nimport type { ConsoleLogger } from './private/consoleLogger';\n\nexport type SourceType = object;\n\nexport type AbstractNewable<T> = abstract new (...args: any[]) => T;\nexport type Newable<T> = new (...args: any[]) => T;\n\nexport type ServiceIdentifier<T extends SourceType> = { prototype: T; name: string }; //AbstractNewable<T>;\nexport type ServiceImplementation<T extends SourceType> = Newable<T>;\nexport type ServiceRegistration<T extends SourceType> = ServiceIdentifier<T> | ServiceImplementation<T>;\n\nexport type InstanceFactory<T extends SourceType> = (x: IResolutionScope) => T;\n\nexport type ServiceModuleType = Newable<IServiceModule>;\n\nexport type ServiceDescriptor<T extends SourceType> = {\n readonly implementation: ServiceRegistration<T>;\n lifetime: Lifetime;\n createInstance(context: IResolutionScope): T;\n};\n\nexport type MetadataType<T extends SourceType> = Record<string | symbol, ServiceIdentifier<T>>;\n\nexport type ServiceCollectionOptions = {\n /**\n * Whether calling `resolve` when there are multiple registrations\n * will result in an error or resolve the last registered service.\n * @default ResolveMultipleMode.Error\n */\n registrationMode: ResolveMultipleMode;\n /**\n * The default log level for the console logger.\n * @defaultValue {@link LogLevel.Warn}\n */\n logLevel: LogLevel;\n /**\n * Custom implementation for logger. Ignores log level.\n * @defaultValue {@link ConsoleLogger}\n */\n logger?: ILogger;\n};\n\nexport type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;\n\nexport type EnsureObject<T> = T extends object ? T : never;\n\nexport type ServiceBuilderOptions<T extends SourceType> = {\n (implementation: ServiceImplementation<T>): ILifetimeBuilder;\n (implementation: ServiceIdentifier<T>, factory: InstanceFactory<T>): ILifetimeBuilder;\n};\n\nexport type RegistrationMap<T extends SourceType = any> = Map<ServiceRegistration<T>, T>;\nexport type DescriptorMap<T extends SourceType = any> = Map<ServiceIdentifier<T>, ServiceDescriptor<T>[]>;\n\nexport const createRegistrationMap = <T extends SourceType = any>() => {\n return new Map<ServiceRegistration<T>, T>();\n};\n\nexport const createDescriptorMap = <T extends SourceType = any>() => {\n return new Map<ServiceIdentifier<T>, ServiceDescriptor<T>[]>();\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, ServiceRegistration, 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>): ILifetimeBuilder;\n public to(implementation: ServiceIdentifier<T>, factory?: InstanceFactory<T>): ILifetimeBuilder;\n public to(implementation: ServiceRegistration<T>, factory?: InstanceFactory<T> | undefined): 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: ServiceRegistration<T>): ServiceDescriptor<T> {\n return {\n implementation,\n lifetime: Lifetime.Resolve,\n createInstance: factory ?? (() => new (implementation as ServiceImplementation<T>)()),\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 RegistrationMap, type ServiceRegistration, type SourceType, createRegistrationMap } from '../types';\n\nexport class ResolutionContext {\n constructor(\n private readonly singletons: RegistrationMap,\n private readonly scoped: RegistrationMap,\n ) {}\n\n private readonly transient: RegistrationMap = createRegistrationMap();\n\n public getFromLifetime<T extends SourceType>(implementation: ServiceRegistration<T>, lifetime: Lifetime): T | null {\n const map = this.getMapForLifetime(lifetime);\n return map?.get(implementation);\n }\n\n public setForLifetime<T extends SourceType>(implementation: ServiceRegistration<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, RegistrationMap>> = {\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, type ServiceIdentifier, type ServiceImplementation, type ServiceRegistration, type SourceType, createRegistrationMap } from '../types';\nimport { ResolutionContext } from './ResolutionContext';\nimport { DesignDependenciesKey } from './constants';\nimport { getMetadata } from './metadata';\n\nexport class ServiceProvider implements IServiceProvider, IScopedProvider {\n private scoped = createRegistrationMap();\n private created: IDisposable[] = [];\n\n constructor(\n private readonly logger: ILogger,\n public readonly Services: IServiceCollection,\n private readonly singletons = createRegistrationMap(),\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: ServiceRegistration<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 DescriptorMap, type EnsureObject, type ServiceCollectionOptions, type ServiceDescriptor, type ServiceIdentifier, type ServiceModuleType, type SourceType, type UnionToIntersection, createDescriptorMap } 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 = createDescriptorMap(),\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: DescriptorMap = createDescriptorMap();\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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shellicar/core-di",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Stephen Hellicar",
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
|
-
"main": "./dist/index.
|
|
27
|
-
"module": "./dist/index.
|
|
28
|
-
"types": "./dist/index.d.
|
|
26
|
+
"main": "./dist/index.cjs",
|
|
27
|
+
"module": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.cts",
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
31
|
"require": {
|
|
32
|
-
"types": "./dist/index.d.
|
|
33
|
-
"default": "./dist/index.
|
|
32
|
+
"types": "./dist/index.d.cts",
|
|
33
|
+
"default": "./dist/index.cjs"
|
|
34
34
|
},
|
|
35
35
|
"import": {
|
|
36
36
|
"types": "./dist/index.d.ts",
|
|
37
|
-
"default": "./dist/index.
|
|
37
|
+
"default": "./dist/index.js"
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
},
|
|
@@ -43,12 +43,13 @@
|
|
|
43
43
|
],
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@abraham/reflection": "^0.12.0",
|
|
46
|
+
"@js-joda/core": "^5.6.4",
|
|
46
47
|
"@tsconfig/node20": "^20.1.4",
|
|
47
|
-
"@types/node": "^22.10.
|
|
48
|
+
"@types/node": "^22.10.7",
|
|
48
49
|
"terser": "^5.37.0",
|
|
49
50
|
"tsup": "^8.3.5",
|
|
50
51
|
"typescript": "^5.7.3",
|
|
51
|
-
"vitest": "^
|
|
52
|
+
"vitest": "^3.0.2"
|
|
52
53
|
},
|
|
53
54
|
"scripts": {
|
|
54
55
|
"build": "tsup",
|