@theokit/di 0.1.1 → 0.2.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/CHANGELOG.md +50 -26
- package/LICENSE +2 -2
- package/README.md +3 -3
- package/dist/index.cjs +121 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +160 -70
- package/dist/index.d.ts +160 -70
- package/dist/index.js +121 -28
- package/dist/index.js.map +1 -1
- package/package.json +10 -7
package/dist/index.d.cts
CHANGED
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Constructor of a class — what TypeScript emits for `class X { ... }`.
|
|
7
|
-
* Used as a Class-token
|
|
7
|
+
* Used as a Class-token.
|
|
8
8
|
*/
|
|
9
9
|
type ClassConstructor<T = unknown> = new (...args: any[]) => T;
|
|
10
10
|
/**
|
|
11
11
|
* Token: anything that identifies a dependency in the container.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* Class primary (auto-resolution via `reflect-metadata`),
|
|
14
14
|
* String fallback (for primitives / interfaces). Symbol explicitly NOT
|
|
15
15
|
* supported in v1 (deferred to v2 if real demand surfaces).
|
|
16
16
|
*/
|
|
17
17
|
type Token<T = unknown> = ClassConstructor<T> | string;
|
|
18
18
|
/**
|
|
19
|
-
* Lifecycle scope
|
|
19
|
+
* Lifecycle scope. The container honors three modes:
|
|
20
20
|
*
|
|
21
21
|
* - `SINGLETON` — single instance shared across the entire container
|
|
22
22
|
* - `TRANSIENT` — fresh instance per resolve
|
|
@@ -34,21 +34,62 @@ type Scope = (typeof Scope)[keyof typeof Scope];
|
|
|
34
34
|
* Exactly one of `useClass | useFactory | useValue | useExisting` MUST be set.
|
|
35
35
|
*/
|
|
36
36
|
type Provider<T = unknown> = ClassProvider<T> | FactoryProvider<T> | ValueProvider<T> | ExistingProvider<T>;
|
|
37
|
+
/**
|
|
38
|
+
* Bind a token to a class the container constructs, resolving its constructor parameters.
|
|
39
|
+
*
|
|
40
|
+
* The common case, and the one the bare-class shorthand expands to: passing `MyService` in
|
|
41
|
+
* `providers` is the same as `{ provide: MyService, useClass: MyService }`.
|
|
42
|
+
*
|
|
43
|
+
* The container built it, so the container tears it down: `dispose()` and `@PreDestroy` both run
|
|
44
|
+
* on `container.dispose()`, in reverse construction order.
|
|
45
|
+
*/
|
|
37
46
|
interface ClassProvider<T = unknown> {
|
|
38
47
|
provide: Token<T>;
|
|
39
48
|
useClass: ClassConstructor<T>;
|
|
40
49
|
scope?: Scope;
|
|
41
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Bind a token to whatever a function returns, with its dependencies listed in `inject`.
|
|
53
|
+
*
|
|
54
|
+
* Use it when construction needs more than `new`: a value read from configuration, a handle built
|
|
55
|
+
* by a library, or anything async — a factory may return a Promise, and the token then resolves
|
|
56
|
+
* only through `resolveAsync`. Calling `resolve()` on such a token throws
|
|
57
|
+
* `AsyncProviderInSyncResolveError` rather than handing back the Promise.
|
|
58
|
+
*
|
|
59
|
+
* The container ran the factory, so it tears down what came out — unlike a `useValue`, which it
|
|
60
|
+
* was merely handed.
|
|
61
|
+
*/
|
|
42
62
|
interface FactoryProvider<T = unknown> {
|
|
43
63
|
provide: Token<T>;
|
|
44
64
|
useFactory: (...deps: any[]) => T | Promise<T>;
|
|
45
65
|
inject?: ReadonlyArray<Token>;
|
|
46
66
|
scope?: Scope;
|
|
47
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Bind a token to a value that already exists.
|
|
70
|
+
*
|
|
71
|
+
* The container stores it as given and constructs nothing, so it does not tear it down either:
|
|
72
|
+
* `container.dispose()` leaves a `useValue` alone even when it has a `dispose()` method. You
|
|
73
|
+
* built it and you still hold the reference, so closing it is yours — and a container that closed
|
|
74
|
+
* it too would make an ordinary teardown a double close, which neither side can see coming.
|
|
75
|
+
*
|
|
76
|
+
* The rule is ownership, and it is the same one that decides the other three: the container tears
|
|
77
|
+
* down what it constructed, because in that case nobody else has the reference.
|
|
78
|
+
*/
|
|
48
79
|
interface ValueProvider<T = unknown> {
|
|
49
80
|
provide: Token<T>;
|
|
50
81
|
useValue: T;
|
|
51
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Bind a token as an alias for another token.
|
|
85
|
+
*
|
|
86
|
+
* Both names resolve to the same instance rather than to two of it, which is what makes an alias
|
|
87
|
+
* different from registering the same class twice.
|
|
88
|
+
*
|
|
89
|
+
* Disposal follows from that: the instance is torn down once, by the registration that built it,
|
|
90
|
+
* however many aliases point at it. Counting the alias separately would close one resource once
|
|
91
|
+
* per name it answers to.
|
|
92
|
+
*/
|
|
52
93
|
interface ExistingProvider<T = unknown> {
|
|
53
94
|
provide: Token<T>;
|
|
54
95
|
useExisting: Token<T>;
|
|
@@ -78,7 +119,7 @@ interface ContainerOptions {
|
|
|
78
119
|
* When `true`, allows `register()` / `registerModule()` calls AFTER
|
|
79
120
|
* the first `resolve()`. Default `false` — fail-fast on misuse.
|
|
80
121
|
*
|
|
81
|
-
*
|
|
122
|
+
* Containers freeze after first resolve to prevent
|
|
82
123
|
* subtle bugs where a singleton is constructed with one set of
|
|
83
124
|
* registrations and a different set is added later.
|
|
84
125
|
*/
|
|
@@ -92,7 +133,7 @@ interface Disposable {
|
|
|
92
133
|
dispose(): void | Promise<void>;
|
|
93
134
|
}
|
|
94
135
|
/**
|
|
95
|
-
* `analyze()` debug return shape
|
|
136
|
+
* `analyze()` debug return shape.
|
|
96
137
|
*/
|
|
97
138
|
interface DependencyGraph {
|
|
98
139
|
nodes: ReadonlyArray<{
|
|
@@ -111,7 +152,7 @@ interface DependencyGraph {
|
|
|
111
152
|
* Dependency-graph helpers — used by `container.analyze()` for debug + by
|
|
112
153
|
* the registration phase (future) for proactive cycle detection.
|
|
113
154
|
*
|
|
114
|
-
*
|
|
155
|
+
* Iterative DFS, NOT recursive, so large graphs (100+ nodes)
|
|
115
156
|
* with multiple cycles don't blow the call stack.
|
|
116
157
|
*/
|
|
117
158
|
|
|
@@ -130,31 +171,24 @@ interface GraphEdge {
|
|
|
130
171
|
* - 3 scopes (SINGLETON / TRANSIENT / REQUEST via AsyncLocalStorage)
|
|
131
172
|
* - 4 provider types (useClass / useFactory / useValue / useExisting)
|
|
132
173
|
* - Cycle detection at resolve-time (path tracking)
|
|
133
|
-
* - Promise-lock REQUEST cache
|
|
134
|
-
*
|
|
135
|
-
* - Disposal lifecycle (T3.3) + freeze on first resolve (v1.2 EC-R2-5)
|
|
174
|
+
* - Promise-lock REQUEST cache with cycle-first ordering and reject cleanup
|
|
175
|
+
* - Disposal lifecycle + freeze on first resolve
|
|
136
176
|
*/
|
|
137
177
|
|
|
138
178
|
/**
|
|
139
179
|
* Lightweight DI container. See `README.md` for usage examples.
|
|
140
180
|
*
|
|
141
|
-
* **
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* `rules/architecture.md § 3` (module cohesion) + KISS / YAGNI. ADR D422
|
|
153
|
-
* documents an ongoing Extract-Method refactor targeting individual long
|
|
154
|
-
* methods (not class-level split). Plan `arch-review-fixes-2026-06-06`
|
|
155
|
-
* T11.2 documents this trade-off; audit DB row `principle_violations.id=10`
|
|
156
|
-
* @ `packages/di/src/container.ts:87`; report at
|
|
157
|
-
* `architecture-output/final_report.md § Findings by dimension` PV#10.
|
|
181
|
+
* **On the size of this class.** It is deliberately large: the single point
|
|
182
|
+
* of truth for DI resolution, covering registry lookup, the SINGLETON,
|
|
183
|
+
* TRANSIENT and REQUEST lifecycles, `@Injectable` metadata reads, alias
|
|
184
|
+
* resolution, request-scope propagation through `AsyncLocalStorage`, and the
|
|
185
|
+
* dispose chain. Splitting those concerns across separate classes would
|
|
186
|
+
* fragment cohesion and force consumers to coordinate through an internal
|
|
187
|
+
* micro-interface that buys neither testability nor extensibility.
|
|
188
|
+
*
|
|
189
|
+
* The complexity budget is held at the method level instead: long methods
|
|
190
|
+
* are broken up with Extract Method, which is why several private helpers
|
|
191
|
+
* below exist only to keep their caller readable.
|
|
158
192
|
*/
|
|
159
193
|
declare class Container {
|
|
160
194
|
private readonly registrations;
|
|
@@ -170,7 +204,7 @@ declare class Container {
|
|
|
170
204
|
* - A full Provider (useClass / useFactory / useValue / useExisting)
|
|
171
205
|
* - A bare class (shorthand expands to ClassProvider { provide: X, useClass: X })
|
|
172
206
|
*
|
|
173
|
-
*
|
|
207
|
+
* ClassProvider validation runs via `validateClassProvider()`
|
|
174
208
|
* regardless of which API path was used.
|
|
175
209
|
*/
|
|
176
210
|
register<T>(providerOrClass: Provider<T> | ClassConstructor<T>): void;
|
|
@@ -179,9 +213,9 @@ declare class Container {
|
|
|
179
213
|
* modules. Walks imports BFS, registers every provider, validates
|
|
180
214
|
* exports.
|
|
181
215
|
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
216
|
+
* An undecorated class throws `InvalidModuleError`. Respects the
|
|
217
|
+
* freeze-after-first-resolve guarantee — each child `register()` checks
|
|
218
|
+
* `assertNotFrozen`.
|
|
185
219
|
*/
|
|
186
220
|
registerModule(moduleClass: ClassConstructor): void;
|
|
187
221
|
/**
|
|
@@ -203,14 +237,14 @@ declare class Container {
|
|
|
203
237
|
* providers resolved within `callback` (or any async continuation) share
|
|
204
238
|
* a single per-request cache.
|
|
205
239
|
*
|
|
206
|
-
*
|
|
240
|
+
* try/finally guarantees REQUEST-scoped instances are disposed
|
|
207
241
|
* even if the callback throws.
|
|
208
242
|
*/
|
|
209
243
|
runInRequest<R>(callback: () => R | Promise<R>): Promise<R>;
|
|
210
244
|
/**
|
|
211
245
|
* Debug helper — returns a snapshot of the dependency graph.
|
|
212
246
|
*
|
|
213
|
-
*
|
|
247
|
+
* Detects cycles in unused providers too (resolve-time
|
|
214
248
|
* detection only fires for resolves that actually traverse the cycle).
|
|
215
249
|
* Use this proactively in tests / dev mode to surface latent cycles.
|
|
216
250
|
*/
|
|
@@ -234,13 +268,13 @@ declare class Container {
|
|
|
234
268
|
private tokenOf;
|
|
235
269
|
private validateProvider;
|
|
236
270
|
/**
|
|
237
|
-
*
|
|
271
|
+
* Shared by both declarative providers: [] AND imperative
|
|
238
272
|
* register() — every class provider must have @Injectable().
|
|
239
273
|
*/
|
|
240
274
|
private validateClassProvider;
|
|
241
275
|
private assertNotDisposed;
|
|
242
276
|
/**
|
|
243
|
-
*
|
|
277
|
+
* The container freezes on first resolve. Late registrations
|
|
244
278
|
* require explicit `allowDynamicRegistration: true` (testing escape hatch).
|
|
245
279
|
*/
|
|
246
280
|
private assertNotFrozen;
|
|
@@ -260,14 +294,14 @@ declare class Container {
|
|
|
260
294
|
* Resolve constructor params + build instance. Tries sync first; if any
|
|
261
295
|
* dep is async, falls back to awaiting via `resolveAsync`.
|
|
262
296
|
*
|
|
263
|
-
* Refactored via Extract Method
|
|
264
|
-
* - validateMetadata:
|
|
297
|
+
* Refactored via Extract Method: orchestrates 3 helpers:
|
|
298
|
+
* - validateMetadata: detect emitDecoratorMetadata off
|
|
265
299
|
* - tryResolveSync: sync resolution loop with AsyncProvider bailout
|
|
266
300
|
* - resolveAllAsync: Promise.all fallback when any dep is async
|
|
267
301
|
*/
|
|
268
302
|
private constructClassWithAsyncFallback;
|
|
269
303
|
/**
|
|
270
|
-
*
|
|
304
|
+
* Detection: zero paramTypes for a class that declares a non-empty
|
|
271
305
|
* constructor strongly suggests emitDecoratorMetadata is off.
|
|
272
306
|
*/
|
|
273
307
|
private validateMetadata;
|
|
@@ -293,6 +327,14 @@ declare class Container {
|
|
|
293
327
|
private lookupCache;
|
|
294
328
|
private storeInCache;
|
|
295
329
|
private deleteFromCache;
|
|
330
|
+
/**
|
|
331
|
+
* Record an instance for teardown, when this container is the one that should tear it down.
|
|
332
|
+
*
|
|
333
|
+
* Two questions, in this order. Does the container OWN it — see `containerOwned`; a value the
|
|
334
|
+
* caller handed in and an instance reached through an alias are both refused here. And does it
|
|
335
|
+
* have any teardown at all: a class whose only teardown is `@PreDestroy` has no `dispose()`, so
|
|
336
|
+
* testing `isDisposable` alone would silently skip it.
|
|
337
|
+
*/
|
|
296
338
|
private trackInstance;
|
|
297
339
|
private assertRequestActive;
|
|
298
340
|
private createContext;
|
|
@@ -323,7 +365,7 @@ interface InjectableOptions {
|
|
|
323
365
|
}
|
|
324
366
|
/**
|
|
325
367
|
* Marks a class as DI-managed. Without this decorator, the container
|
|
326
|
-
* rejects the class at registration time
|
|
368
|
+
* rejects the class at registration time.
|
|
327
369
|
*
|
|
328
370
|
* @example
|
|
329
371
|
* @Injectable()
|
|
@@ -335,11 +377,14 @@ interface InjectableOptions {
|
|
|
335
377
|
declare function Injectable(options?: InjectableOptions): ClassDecorator;
|
|
336
378
|
|
|
337
379
|
/**
|
|
338
|
-
*
|
|
339
|
-
*
|
|
380
|
+
* `@PostConstruct` — method the container calls once the instance is built and every
|
|
381
|
+
* constructor dependency is injected.
|
|
340
382
|
*
|
|
341
|
-
*
|
|
342
|
-
* the
|
|
383
|
+
* Runs once per instance, so a SINGLETON initialises once no matter how often it is
|
|
384
|
+
* resolved. If the method returns a Promise, `container.resolveAsync()` awaits it before
|
|
385
|
+
* handing the instance back; `container.resolve()` cannot await, so it throws
|
|
386
|
+
* `AsyncPostConstructInSyncResolveError` rather than return a half-initialised object.
|
|
387
|
+
* A hook that throws propagates, for the same reason.
|
|
343
388
|
*
|
|
344
389
|
* @example
|
|
345
390
|
* ```ts
|
|
@@ -356,8 +401,13 @@ declare function Injectable(options?: InjectableOptions): ClassDecorator;
|
|
|
356
401
|
*/
|
|
357
402
|
declare function PostConstruct(target: object, propertyKey: string | symbol): void;
|
|
358
403
|
/**
|
|
359
|
-
*
|
|
360
|
-
*
|
|
404
|
+
* `@PreDestroy` — method the container calls when the instance is torn down:
|
|
405
|
+
* `container.dispose()` for SINGLETON, the end of `runInRequest()` for REQUEST.
|
|
406
|
+
*
|
|
407
|
+
* Runs BEFORE `dispose()` when the class has both, and is awaited if it returns a
|
|
408
|
+
* Promise. A class needs no `dispose()` to be torn down — declaring this hook is enough
|
|
409
|
+
* for the container to track it. A hook that throws does not stop the remaining
|
|
410
|
+
* instances; the failures surface together as an `AggregateError`.
|
|
361
411
|
*
|
|
362
412
|
* @example
|
|
363
413
|
* ```ts
|
|
@@ -418,38 +468,63 @@ declare function Module(metadata: ModuleMetadata): ClassDecorator;
|
|
|
418
468
|
declare function Optional(): ParameterDecorator;
|
|
419
469
|
|
|
420
470
|
/**
|
|
421
|
-
*
|
|
422
|
-
* when multiple implementations exist for the same token.
|
|
471
|
+
* `@Primary` — marks a class as the preferred implementation of a token.
|
|
423
472
|
*
|
|
424
|
-
*
|
|
473
|
+
* **This container does not read it.** The decorator records the mark under
|
|
474
|
+
* `METADATA_KEYS.PRIMARY` and nothing else happens: `Container` keeps one
|
|
475
|
+
* registration per token, so registering a second provider for the same token
|
|
476
|
+
* replaces the first regardless of this mark, with a warning on stderr.
|
|
477
|
+
*
|
|
478
|
+
* It stays because the metadata key is exported and the annotation is a real
|
|
479
|
+
* declaration of intent — code generators, module loaders and application
|
|
480
|
+
* wiring can act on it. What it is not is a resolution rule enforced here.
|
|
481
|
+
*
|
|
482
|
+
* Selecting between competing implementations would require the container to
|
|
483
|
+
* hold several registrations per token, which changes cache keys, cycle
|
|
484
|
+
* detection and disposal. That is a design decision, not a missing branch, and
|
|
485
|
+
* it has not been made. Until it is, pick your implementation at registration
|
|
486
|
+
* time:
|
|
425
487
|
*
|
|
426
488
|
* @example
|
|
427
489
|
* ```ts
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
* @Injectable()
|
|
433
|
-
* class PayPalPayments implements PaymentGateway { ... }
|
|
490
|
+
* // Decide in the wiring, where the choice is visible:
|
|
491
|
+
* const container = new Container({
|
|
492
|
+
* providers: [{ provide: PAYMENTS, useClass: useStripe ? StripePayments : PayPalPayments }],
|
|
493
|
+
* });
|
|
434
494
|
*
|
|
435
|
-
* //
|
|
495
|
+
* // Read the mark yourself if you want to drive that choice from the class:
|
|
496
|
+
* Reflect.getMetadata(METADATA_KEYS.PRIMARY, StripePayments); // true
|
|
436
497
|
* ```
|
|
437
498
|
*/
|
|
438
|
-
declare function Primary(target:
|
|
499
|
+
declare function Primary(target: abstract new (...args: never) => unknown): void;
|
|
439
500
|
|
|
440
501
|
/**
|
|
441
|
-
*
|
|
502
|
+
* `@Qualifier(name)` — names which implementation a constructor parameter wants.
|
|
503
|
+
*
|
|
504
|
+
* **This container does not read it.** The decorator records the name under
|
|
505
|
+
* `METADATA_KEYS.QUALIFIER_NAMES`, keyed by parameter index, and resolution
|
|
506
|
+
* ignores it: `Container` holds one registration per token, so there is nothing
|
|
507
|
+
* for a qualifier to choose between.
|
|
442
508
|
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
509
|
+
* It stays because the metadata key is exported and the annotation is a real
|
|
510
|
+
* declaration of intent that surrounding tooling can act on. What it is not is a
|
|
511
|
+
* resolution rule enforced here.
|
|
512
|
+
*
|
|
513
|
+
* To actually select an implementation today, give each one its own token and
|
|
514
|
+
* inject that token — which is the same decision, made somewhere a reader can
|
|
515
|
+
* see it:
|
|
445
516
|
*
|
|
446
517
|
* @example
|
|
447
518
|
* ```ts
|
|
519
|
+
* const STRIPE = "payments.stripe";
|
|
520
|
+
*
|
|
448
521
|
* @Injectable()
|
|
449
522
|
* class OrderService {
|
|
450
|
-
* constructor(@
|
|
523
|
+
* constructor(@Inject(STRIPE) private payments: PaymentGateway) {}
|
|
451
524
|
* }
|
|
452
525
|
* ```
|
|
526
|
+
*
|
|
527
|
+
* @see {@link Primary} — the same limitation, from the provider's side.
|
|
453
528
|
*/
|
|
454
529
|
declare function Qualifier(name: string): ParameterDecorator;
|
|
455
530
|
|
|
@@ -477,9 +552,9 @@ declare class TokenNotFoundError extends Error {
|
|
|
477
552
|
}
|
|
478
553
|
/**
|
|
479
554
|
* Thrown when a resolution chain contains a cycle (A → B → A).
|
|
480
|
-
*
|
|
555
|
+
* Detected at resolve-time, not register-time.
|
|
481
556
|
*
|
|
482
|
-
*
|
|
557
|
+
* The cycle check happens BEFORE cache lookup in resolveAsync
|
|
483
558
|
* to prevent infinite Promise await deadlocks on async REQUEST-scoped
|
|
484
559
|
* cycles.
|
|
485
560
|
*/
|
|
@@ -497,6 +572,21 @@ declare class AsyncProviderInSyncResolveError extends Error {
|
|
|
497
572
|
readonly name: "AsyncProviderInSyncResolveError";
|
|
498
573
|
constructor(token: Token);
|
|
499
574
|
}
|
|
575
|
+
/**
|
|
576
|
+
* Thrown when a class resolved through sync `resolve()` declares an async
|
|
577
|
+
* `@PostConstruct` hook.
|
|
578
|
+
*
|
|
579
|
+
* The synchronous path cannot await it, and returning an instance whose
|
|
580
|
+
* initialiser is still running would hand the caller something that looks ready
|
|
581
|
+
* and is not — a failure that surfaces later, somewhere else. Failing here names
|
|
582
|
+
* the class and the method instead.
|
|
583
|
+
*/
|
|
584
|
+
declare class AsyncPostConstructInSyncResolveError extends Error {
|
|
585
|
+
readonly className: string;
|
|
586
|
+
readonly methodName: string;
|
|
587
|
+
readonly name: "AsyncPostConstructInSyncResolveError";
|
|
588
|
+
constructor(className: string, methodName: string);
|
|
589
|
+
}
|
|
500
590
|
/**
|
|
501
591
|
* Thrown when a REQUEST-scoped provider is resolved outside of
|
|
502
592
|
* `container.runInRequest()`.
|
|
@@ -512,7 +602,7 @@ declare class ScopeViolationError extends Error {
|
|
|
512
602
|
* `design:paramtypes` metadata that the container needs to auto-resolve
|
|
513
603
|
* constructor parameters.
|
|
514
604
|
*
|
|
515
|
-
*
|
|
605
|
+
* validateClassProvider() is called by BOTH the declarative
|
|
516
606
|
* `providers: []` path AND the imperative `container.register()` path.
|
|
517
607
|
*/
|
|
518
608
|
declare class MissingInjectableError extends Error {
|
|
@@ -534,7 +624,7 @@ declare class ContainerDisposedError extends Error {
|
|
|
534
624
|
}
|
|
535
625
|
/**
|
|
536
626
|
* Thrown when `register()` or `registerModule()` is called AFTER the first
|
|
537
|
-
* `resolve()` has materialized a singleton.
|
|
627
|
+
* `resolve()` has materialized a singleton. The
|
|
538
628
|
* container freezes after first resolve unless
|
|
539
629
|
* `allowDynamicRegistration: true` was passed to the constructor.
|
|
540
630
|
*/
|
|
@@ -585,7 +675,7 @@ declare const METADATA_KEYS: {
|
|
|
585
675
|
readonly SQUAD: "usetheo:di:squad";
|
|
586
676
|
/** Map<string|symbol, StepMetadata> from `@Step()` method decorator. */
|
|
587
677
|
readonly STEP: "usetheo:di:step";
|
|
588
|
-
/**
|
|
678
|
+
/** Map<string|symbol, HitlMetadata> from `@Hitl()` method decorator. */
|
|
589
679
|
readonly HITL: "usetheo:di:hitl";
|
|
590
680
|
/** AutoSummarizeConfig from `@AutoSummarize()` class decorator. */
|
|
591
681
|
readonly AUTO_SUMMARIZE: "usetheo:di:auto-summarize";
|
|
@@ -595,7 +685,7 @@ declare const METADATA_KEYS: {
|
|
|
595
685
|
readonly WORKFLOW: "usetheo:di:workflow";
|
|
596
686
|
/** EvalOptions from `@Eval()` class decorator. */
|
|
597
687
|
readonly EVAL: "usetheo:di:eval";
|
|
598
|
-
/** CronMetadata from `@Cron()` method decorator. */
|
|
688
|
+
/** Map<string|symbol, CronMetadata> from `@Cron()` method decorator. */
|
|
599
689
|
readonly CRON: "usetheo:di:cron";
|
|
600
690
|
/** Map<string|symbol, SubscriptionOptions> from `@Subscription()` property decorator. */
|
|
601
691
|
readonly SUBSCRIPTION: "usetheo:di:subscription";
|
|
@@ -615,14 +705,14 @@ declare const METADATA_KEYS: {
|
|
|
615
705
|
* Module-loader — walks @Module() classes in BFS order, registers their
|
|
616
706
|
* providers, validates imports + exports visibility, detects cyclic imports.
|
|
617
707
|
*
|
|
618
|
-
*
|
|
619
|
-
*
|
|
708
|
+
* Modules are OPT-IN. Default usage is flat container.
|
|
709
|
+
* registerModule() rejects undecorated classes with
|
|
620
710
|
* InvalidModuleError pointing to the missing decorator.
|
|
621
711
|
*/
|
|
622
712
|
|
|
623
713
|
/**
|
|
624
714
|
* Thrown when a class is passed to `Container.registerModule()` without
|
|
625
|
-
* the `@Module()` decorator
|
|
715
|
+
* the `@Module()` decorator.
|
|
626
716
|
*/
|
|
627
717
|
declare class InvalidModuleError extends Error {
|
|
628
718
|
readonly target: {
|
|
@@ -635,7 +725,7 @@ declare class InvalidModuleError extends Error {
|
|
|
635
725
|
}
|
|
636
726
|
/**
|
|
637
727
|
* Thrown when a module declares an export for a token that isn't in its
|
|
638
|
-
* own `providers`
|
|
728
|
+
* own `providers` — this pins register-time validation.
|
|
639
729
|
*/
|
|
640
730
|
declare class InvalidExportError extends Error {
|
|
641
731
|
readonly moduleName: string;
|
|
@@ -652,4 +742,4 @@ declare class CyclicModuleImportError extends Error {
|
|
|
652
742
|
constructor(cycle: ReadonlyArray<string>);
|
|
653
743
|
}
|
|
654
744
|
|
|
655
|
-
export { AsyncProviderInSyncResolveError, type ClassConstructor, type ClassProvider, Container, ContainerDisposedError, ContainerFrozenError, type ContainerOptions, CyclicDependencyError, CyclicModuleImportError, type DependencyGraph, type Disposable, type ExistingProvider, type FactoryProvider, Inject, Injectable, type InjectableOptions, InvalidExportError, InvalidModuleError, METADATA_KEYS, MissingInjectableError, Module, type ModuleMetadata, Optional, PostConstruct, PreDestroy, Primary, type Provider, Qualifier, ReflectMetadataMissingError, type ResolutionContext, Scope, ScopeViolationError, type Token, TokenNotFoundError, type ValueProvider, describeToken };
|
|
745
|
+
export { AsyncPostConstructInSyncResolveError, AsyncProviderInSyncResolveError, type ClassConstructor, type ClassProvider, Container, ContainerDisposedError, ContainerFrozenError, type ContainerOptions, CyclicDependencyError, CyclicModuleImportError, type DependencyGraph, type Disposable, type ExistingProvider, type FactoryProvider, Inject, Injectable, type InjectableOptions, InvalidExportError, InvalidModuleError, METADATA_KEYS, MissingInjectableError, Module, type ModuleMetadata, Optional, PostConstruct, PreDestroy, Primary, type Provider, Qualifier, ReflectMetadataMissingError, type ResolutionContext, Scope, ScopeViolationError, type Token, TokenNotFoundError, type ValueProvider, describeToken };
|