@venizia/ignis-inversion 0.0.6 → 0.0.7-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 +18 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
[](https://www.typescriptlang.org/)
|
|
10
10
|
|
|
11
|
-
A ~350-line Dependency Injection & Inversion of Control (IoC) container featuring decorator-based constructor and property injection, fluent Binding API, singleton/transient scoping, namespace auto-tagging, Provider pattern, and tag-based discovery. Part of the [
|
|
11
|
+
A ~350-line Dependency Injection & Inversion of Control (IoC) container featuring decorator-based constructor and property injection, fluent Binding API, singleton/transient scoping, namespace auto-tagging, Provider pattern, and tag-based discovery. Part of the [IGNIS Framework](https://github.com/VENIZIA-AI/ignis).
|
|
12
12
|
|
|
13
13
|
[Installation](#installation) • [Quick Start](#quick-start) • [API Reference](#container) • [Documentation](https://venizia-ai.github.io/ignis)
|
|
14
14
|
|
|
@@ -28,7 +28,7 @@ A ~350-line Dependency Injection & Inversion of Control (IoC) container featurin
|
|
|
28
28
|
|
|
29
29
|
## Philosophy
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
IGNIS Inversion takes the best ideas from **LoopBack 4**'s IoC system -- decorator-based injection, fluent binding configuration, namespace-driven organization -- and strips them down to ~350 lines of focused, zero-overhead container logic. No complex module system, no provider hierarchies, no framework lock-in. Just a fast, type-safe container that works with any TypeScript project.
|
|
32
32
|
|
|
33
33
|
**Why this exists:**
|
|
34
34
|
|
|
@@ -39,7 +39,7 @@ Ignis Inversion takes the best ideas from **LoopBack 4**'s IoC system -- decorat
|
|
|
39
39
|
| **InversifyJS** | Powerful but heavy for projects that need a simple, fast container |
|
|
40
40
|
| **tsyringe** | Minimal but lacks fluent configuration, tagging, and property injection |
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
IGNIS Inversion gives you **constructor injection, property injection, singleton/transient scoping, tag-based discovery, and a provider pattern** -- all in a single dependency with no runtime overhead.
|
|
43
43
|
|
|
44
44
|
---
|
|
45
45
|
|
|
@@ -79,7 +79,7 @@ Ignis Inversion gives you **constructor injection, property injection, singleton
|
|
|
79
79
|
- [Cache Management](#cache-management)
|
|
80
80
|
- [Real-World Example: Mini Application](#real-world-example-mini-application)
|
|
81
81
|
- [Container Independence](#container-independence)
|
|
82
|
-
- [Integration with Other
|
|
82
|
+
- [Integration with Other IGNIS Packages](#integration-with-other-ignis-packages)
|
|
83
83
|
- [How Core Uses Inversion](#how-core-uses-inversion)
|
|
84
84
|
- [How Boot Uses Inversion](#how-boot-uses-inversion)
|
|
85
85
|
- [MetadataRegistry Extension via Mixins](#metadataregistry-extension-via-mixins)
|
|
@@ -440,7 +440,7 @@ class OrderService {
|
|
|
440
440
|
|
|
441
441
|
### Binding Keys
|
|
442
442
|
|
|
443
|
-
|
|
443
|
+
IGNIS uses a **namespace-based naming convention** for binding keys. This keeps large applications organized and enables tag-based discovery.
|
|
444
444
|
|
|
445
445
|
```typescript
|
|
446
446
|
import { BindingKeys } from '@venizia/ignis-inversion';
|
|
@@ -497,7 +497,7 @@ export class BaseHelper {
|
|
|
497
497
|
- **Binding** sets `scope` to its binding key string (e.g., `'services.UserService'`).
|
|
498
498
|
- **MetadataRegistry** sets `scope` to `'MetadataRegistry'`.
|
|
499
499
|
|
|
500
|
-
`BaseHelper` exists so that every DI primitive carries a human-readable label for logging and debugging. In the full
|
|
500
|
+
`BaseHelper` exists so that every DI primitive carries a human-readable label for logging and debugging. In the full IGNIS framework, the core package extends `BaseHelper` with a `Logger` instance, but the inversion package keeps it minimal.
|
|
501
501
|
|
|
502
502
|
---
|
|
503
503
|
|
|
@@ -1015,7 +1015,7 @@ const pool = container.get<Pool>({ key: 'datasources.Pool' });
|
|
|
1015
1015
|
|
|
1016
1016
|
The container detects class-based providers using `isClassProvider()`, which checks whether the target has a `prototype.value` method. If detected, the provider is instantiated via `container.instantiate()` (which performs full two-phase DI on the provider class), and then its `value(container)` method is called.
|
|
1017
1017
|
|
|
1018
|
-
The full
|
|
1018
|
+
The full IGNIS framework also provides a `BaseProvider<T>` abstract class (in `@venizia/ignis` core) that extends `BaseHelper` and implements `IProvider<T>`, giving providers access to scoped logging.
|
|
1019
1019
|
|
|
1020
1020
|
---
|
|
1021
1021
|
|
|
@@ -1287,7 +1287,7 @@ This design is intentional: metadata describes the class's **dependencies**, whi
|
|
|
1287
1287
|
|
|
1288
1288
|
---
|
|
1289
1289
|
|
|
1290
|
-
## Integration with Other
|
|
1290
|
+
## Integration with Other IGNIS Packages
|
|
1291
1291
|
|
|
1292
1292
|
### How Core Uses Inversion
|
|
1293
1293
|
|
|
@@ -1951,10 +1951,10 @@ BindingKeys.build({ namespace: 'services', key: '' });
|
|
|
1951
1951
|
|
|
1952
1952
|
InversifyJS uses similar concepts but with different API shapes. Here is a mapping:
|
|
1953
1953
|
|
|
1954
|
-
| InversifyJS |
|
|
1954
|
+
| InversifyJS | IGNIS Inversion | Notes |
|
|
1955
1955
|
|:------------|:----------------|:------|
|
|
1956
|
-
| `@injectable()` | `@injectable({})` |
|
|
1957
|
-
| `@inject(TYPES.Logger)` | `@inject({ key: 'services.Logger' })` |
|
|
1956
|
+
| `@injectable()` | `@injectable({})` | IGNIS requires an options object (can be empty) |
|
|
1957
|
+
| `@inject(TYPES.Logger)` | `@inject({ key: 'services.Logger' })` | IGNIS uses options objects, supports string or symbol keys |
|
|
1958
1958
|
| `container.bind<T>(TYPES.Logger).to(Logger)` | `container.bind({ key: 'services.Logger' }).toClass(Logger)` | Fluent chain on options-based `bind()` |
|
|
1959
1959
|
| `container.bind<T>(TYPES.Logger).to(Logger).inSingletonScope()` | `container.bind({ key: 'services.Logger' }).toClass(Logger).setScope('singleton')` | Scope via `setScope()` |
|
|
1960
1960
|
| `container.bind<T>(TYPES.Config).toConstantValue(val)` | `container.bind({ key: 'config' }).toValue(val)` | `toValue` instead of `toConstantValue` |
|
|
@@ -1992,7 +1992,7 @@ const svc = container.get<UserService>(TYPES.UserService);
|
|
|
1992
1992
|
```
|
|
1993
1993
|
|
|
1994
1994
|
```typescript
|
|
1995
|
-
//
|
|
1995
|
+
// IGNIS Inversion equivalent
|
|
1996
1996
|
@injectable({})
|
|
1997
1997
|
class UserService {
|
|
1998
1998
|
constructor(
|
|
@@ -2014,7 +2014,7 @@ const svc = container.get<UserService>({ key: 'services.UserService' });
|
|
|
2014
2014
|
|
|
2015
2015
|
tsyringe uses a token-based approach with a global container. Here is the mapping:
|
|
2016
2016
|
|
|
2017
|
-
| tsyringe |
|
|
2017
|
+
| tsyringe | IGNIS Inversion | Notes |
|
|
2018
2018
|
|:---------|:----------------|:------|
|
|
2019
2019
|
| `@injectable()` | `@injectable({})` | Similar, options object required |
|
|
2020
2020
|
| `@inject('token')` | `@inject({ key: 'token' })` | Options object |
|
|
@@ -2023,15 +2023,15 @@ tsyringe uses a token-based approach with a global container. Here is the mappin
|
|
|
2023
2023
|
| `container.register('token', { useFactory: fn })` | `container.bind({ key: 'token' }).toProvider(fn)` | Factory/provider |
|
|
2024
2024
|
| `container.resolve(Cls)` | `container.resolve(Cls)` or `container.instantiate(Cls)` | Nearly identical |
|
|
2025
2025
|
| `@singleton()` | `@injectable({})` + `.setScope('singleton')` | Scope on binding, not decorator |
|
|
2026
|
-
| `container.createChildContainer()` | N/A |
|
|
2026
|
+
| `container.createChildContainer()` | N/A | IGNIS has no child containers |
|
|
2027
2027
|
| `@injectAll('token')` | `container.findByTag({ tag }).map(b => b.getValue(container))` | Use tag discovery |
|
|
2028
2028
|
|
|
2029
2029
|
**Key differences from tsyringe:**
|
|
2030
2030
|
|
|
2031
|
-
-
|
|
2032
|
-
-
|
|
2033
|
-
-
|
|
2034
|
-
- Property injection is supported natively in
|
|
2031
|
+
- IGNIS does not have a global container -- you always create explicit `Container` instances.
|
|
2032
|
+
- IGNIS has no child containers. Each container is independent.
|
|
2033
|
+
- IGNIS uses namespace-based string keys with auto-tagging, rather than string/symbol tokens.
|
|
2034
|
+
- Property injection is supported natively in IGNIS (tsyringe only supports constructor injection).
|
|
2035
2035
|
|
|
2036
2036
|
---
|
|
2037
2037
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ignis-inversion",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7-0",
|
|
4
4
|
"description": "Lightweight, high-performance Dependency Injection and Inversion of Control container for TypeScript (~350 lines). Features decorator-based constructor and property injection, fluent Binding API, singleton/transient scoping, namespace auto-tagging, Provider pattern, tag-based discovery, and reflect-metadata integration. Inspired by LoopBack 4 and InversifyJS but simpler. Zero framework lock-in — works standalone or with Ignis.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"architecture",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"devDependencies": {
|
|
111
111
|
"@types/bun": "^1.3.14",
|
|
112
112
|
"@types/lodash": "^4.17.23",
|
|
113
|
-
"@venizia/dev-configs": "^0.0.
|
|
113
|
+
"@venizia/dev-configs": "^0.0.8-0",
|
|
114
114
|
"eslint": "^10.4.0",
|
|
115
115
|
"prettier": "^3.8.3",
|
|
116
116
|
"tsc-alias": "^1.8.17",
|