Rename DIContainer to TSInjex and refactor interfaces

- Renamed DIContainer class and related references to TSInjex to better indicate its purpose as a TypeScript-based dependency injection container.
- Extracted IDependency interface to a separate file to improve modularity.
- Split the ITSInjex interface into ITSInjexRegister and ITSInjexResolve, then extended them in a new ITSInjex interface to clarify the separation of concerns.
- Updated tests and decorators to reflect the renaming and interface changes.
- Adjusted helper, functions, and index export to align with the new TSInjex structure.
This commit is contained in:
2024-08-14 20:21:05 +02:00
committed by Max P.
parent 8d607c7f0c
commit 3dbbfc8e1e
13 changed files with 106 additions and 59 deletions

View File

@@ -1,4 +1,4 @@
import { ITSInjex } from './IDIContainer';
import { ITSInjex } from './ITSInjex';
/**
* General error class for {@link ITSInjex} interface.

View File

@@ -0,0 +1,14 @@
/**
* Dependency Entry Interface
*/
export interface IDependency {
/**
* The dependency itself
*/
dependency: unknown;
/**
* If true, the dependency is deprecated => a warning
* is logged when the dependency is resolved
*/
deprecated?: boolean;
}

View File

@@ -1,17 +1,17 @@
/**
* Static Dependency Injection Container Interface
* Static TSInjex Interface
*/
export interface ITSInjex_ {
export interface ITSInjex_ extends ITSInjexRegister, ITSInjexResolve {
/**
* Get the **singleton** Dependency Injection Container
* Get the **singleton** TSInjex instance.
*/
getInstance(): ITSInjex;
}
/**
* Dependency Injection Container Interface
* Register method for static and instance Dependency Injection Container.
*/
export interface ITSInjex {
export interface ITSInjexRegister {
/**
* Register a dependency.
* @param identifier The identifier of the dependency.
@@ -34,7 +34,12 @@ export interface ITSInjex {
* @param deprecated No warning is logged when the dependency is resolved.
*/
register<T>(identifier: string, dependency: T, deprecated?: false): void;
}
/**
* Resolve method for static and instance Dependency Injection Container.
*/
export interface ITSInjexResolve {
/**
* Resolve a dependency
* @param identifier The identifier of the dependency
@@ -58,3 +63,8 @@ export interface ITSInjex {
*/
resolve<T>(identifier: string, necessary?: false): T | undefined;
}
/**
* TSInjex Interface
*/
export interface ITSInjex extends ITSInjexRegister, ITSInjexResolve {}