Commit Graph

10 Commits

Author SHA1 Message Date
46c9a8b990 refactor(di): modularize and improve dependency injection for deno
- Consolidate import paths into scoped modules for better structure.
- Refactor decorators (`Inject`, `Register`) for improved type safety.
- Add `clear` method to the DI container for easier test cleanup.
- Introduce lazy initialization for registered instances.
- Add comprehensive unit tests for decorators and DI container.
- Standardize error handling and naming conventions for exceptions.

Signed-off-by: Max P. <Mail@MPassarello.de>
2025-05-02 19:55:16 +02:00
81fb7f0071 refactor(inject): rename necessary parameter to isNecessary for clarity 2025-04-02 21:52:36 +02:00
c6e9fbd2a3 feat!: switch to native ESM with NodeNext module resolution and .js import paths
BREAKING CHANGE: Consumers must use ESM-compatible environments.
All import paths now include .js extensions.
CommonJS (require) is no longer supported.
2025-04-02 21:52:36 +02:00
5bc9aef9ad feat: Add initialization error handling and refactor Inject 2024-08-23 00:17:14 +02:00
75333b3310 Add error handling and constructor checks to Inject
- Import additional exception classes from `src/interfaces/Exceptions`
- Modify `Inject` function to:
  - Accept `init` parameter as a function or `true` for instantiation
  - Throw specific errors: `DependencyResolutionError`, `InjectorError`, `NoInstantiationMethodError`
  - Ensure necessary dependencies are handled properly
  - Define property with `Object.defineProperty` for performance
- Add `hasConstructor` helper function to check if an object has a constructor
2024-08-23 00:17:14 +02:00
567d1c5bd2 Refactor import paths for 'Identifier' type
Unified the import paths of the 'Identifier' type across multiple files to ensure consistency. The 'Identifier' type is now imported from '../types/Identifier' instead of 'src/types/Identifier'. This change reduces ambiguity and aligns the import pattern throughout the codebase.
2024-08-16 18:48:26 +02:00
41be08e02e Refactor DI container for better structure and clarity
- Moved `TSinjex` class to `classes` directory for better organization.
- Updated imports across the codebase to reflect the new location of `TSinjex`.
- Introduced `Identifier` type to standardize dependency identifiers.
- Enhanced JSDoc comments for improved clarity and consistency.
- Adjusted error messages for `DependencyResolutionError` to provide clearer information.
- Updated and expanded decorator and function types to use `Identifier` type.
2024-08-16 16:14:11 +02:00
771b810419 Rename TSInjex to TSinjex and Add Jest Setup in README
Renamed all instances of 'TSInjex' to 'TSinjex' for consistency across the codebase, including interfaces, classes, and test files. Updated the version in `package.json` from 0.0.5 to 0.0.6. Added Jest setup example to the `README.md` to guide developers on initial configuration for testing.
2024-08-14 23:10:44 +02:00
3dbbfc8e1e 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.
2024-08-14 20:23:02 +02:00
6c4db19926 First check-in of the code from the Obsidian Prj project. 2024-08-14 19:40:52 +02:00