@frontmcp/di 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,95 +1,57 @@
1
1
  # @frontmcp/di
2
2
 
3
- Generic dependency injection container and registry utilities for TypeScript applications.
3
+ Dependency injection container and registry utilities for FrontMCP.
4
4
 
5
- ## Features
5
+ [![NPM](https://img.shields.io/npm/v/@frontmcp/di.svg)](https://www.npmjs.com/package/@frontmcp/di)
6
6
 
7
- - Type-safe dependency injection with class tokens
8
- - Configurable token factory with custom prefixes
9
- - Hierarchical provider registries
10
- - Scoped providers (GLOBAL, CONTEXT)
11
- - Indexed registry base class with O(1) lookups
12
- - Adoption pattern for child registries
13
- - Change event subscriptions
7
+ > **Internal package.** Used by `@frontmcp/sdk` — most users do not need to install this directly.
14
8
 
15
- ## Installation
9
+ ## Install
16
10
 
17
11
  ```bash
18
12
  npm install @frontmcp/di reflect-metadata zod
19
13
  ```
20
14
 
21
- ## Usage
15
+ ## Features
16
+
17
+ - **Type-safe DI** — class tokens with configurable prefixes ([docs][docs-providers])
18
+ - **Scoped providers** — GLOBAL and CONTEXT scopes
19
+ - **Hierarchical registries** — parent/child container adoption
20
+ - **Indexed lookups** — O(1) registry queries via `IndexedRegistry`
21
+ - **Change events** — subscribe to registry mutations
22
+ - **Token factory** — `createTokenFactory({ prefix })` for Symbol-based tokens
22
23
 
23
- ```typescript
24
+ ## Quick Example
25
+
26
+ ```ts
24
27
  import 'reflect-metadata';
25
28
  import { DiContainer, createTokenFactory, ProviderScope } from '@frontmcp/di';
26
29
 
27
- // Create a token factory with custom prefix
28
- const tokenFactory = createTokenFactory({ prefix: 'MyApp' });
30
+ const tokens = createTokenFactory({ prefix: 'MyApp' });
29
31
 
30
- // Define providers
31
32
  class DatabaseService {
32
33
  static metadata = { name: 'Database', scope: ProviderScope.GLOBAL };
33
34
  }
34
35
 
35
- // Create container
36
36
  const container = new DiContainer([DatabaseService]);
37
37
  await container.ready;
38
-
39
- // Resolve dependencies
40
38
  const db = container.get(DatabaseService);
41
39
  ```
42
40
 
43
- ## API
44
-
45
- ### Token Factory
46
-
47
- ```typescript
48
- import { createTokenFactory } from '@frontmcp/di';
49
-
50
- const tokens = createTokenFactory({ prefix: 'MyApp' });
51
- const myToken = tokens.type('MyService'); // Symbol('MyApp:type:MyService')
52
- ```
53
-
54
- ### Provider Normalizer
41
+ ## Docs
55
42
 
56
- ```typescript
57
- import { createProviderNormalizer } from '@frontmcp/di';
43
+ | Topic | Link |
44
+ | -------------- | --------------------------- |
45
+ | Providers & DI | [Providers][docs-providers] |
58
46
 
59
- const normalizeProvider = createProviderNormalizer({
60
- type: Symbol('type'),
61
- name: Symbol('name'),
62
- scope: Symbol('scope'),
63
- });
64
- ```
65
-
66
- ### DiContainer
67
-
68
- ```typescript
69
- import { DiContainer } from '@frontmcp/di';
70
-
71
- const container = new DiContainer(providers, parentContainer);
72
- await container.ready;
73
-
74
- container.get(Token); // Get GLOBAL provider
75
- container.resolve(Class); // Resolve or construct
76
- container.buildViews(key); // Build scoped views
77
- ```
78
-
79
- ### IndexedRegistry
47
+ ## Related Packages
80
48
 
81
- Base class for registries with fast lookups:
49
+ - [`@frontmcp/sdk`](../sdk) consumes DI for server-level injection
82
50
 
83
- ```typescript
84
- import { IndexedRegistry } from '@frontmcp/di';
51
+ ## License
85
52
 
86
- class MyRegistry extends IndexedRegistry<MyInstance, MyRecord, MyIndexed, MyMetadata> {
87
- protected buildIndexes(rows: MyIndexed[]): void {
88
- // Build custom indexes
89
- }
90
- }
91
- ```
53
+ Apache-2.0 see [LICENSE](../../LICENSE).
92
54
 
93
- ## License
55
+ <!-- links -->
94
56
 
95
- Apache-2.0
57
+ [docs-providers]: https://docs.agentfront.dev/frontmcp/extensibility/providers
package/esm/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontmcp/di",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "Generic dependency injection container and registry utilities for TypeScript applications",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "license": "Apache-2.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontmcp/di",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "Generic dependency injection container and registry utilities for TypeScript applications",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "license": "Apache-2.0",