diject 0.0.1

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.
@@ -0,0 +1,823 @@
1
+ import { AsyncLocalStorage } from 'async_hooks';
2
+
3
+ declare class AlsToken<T = any> {
4
+ readonly key: string;
5
+ constructor(key: string);
6
+ static isAlsToken(token: any): token is AlsToken;
7
+ }
8
+ declare function createAlsToken<T = any>(key: string): AlsToken<T>;
9
+ declare const INJECTIONS: unique symbol;
10
+
11
+ declare enum Scope {
12
+ SINGLETON = "singleton",
13
+ REQUEST = "request",
14
+ TRANSIENT = "transient"
15
+ }
16
+ declare class FactoryWrapper {
17
+ factory: Function;
18
+ pending?: Promise<any>;
19
+ constructor(factory: Function);
20
+ }
21
+ declare function hasOnInit(instance: any): instance is OnInit;
22
+ declare function hasOnDestroy(instance: any): instance is OnDestroy;
23
+ declare function isNamedToken(token: unknown): token is Token;
24
+ declare function isConstructor(token: unknown): token is Constructor;
25
+ declare function isArrayToken(token: unknown): token is Constructor[];
26
+ declare function isRegistryEntry(value: unknown): value is RegistryEntry;
27
+ declare function hasSingletonInstance(entry: RegistryEntry): boolean;
28
+ declare function isReqScope(entry: RegistryEntry, requestId?: string): boolean;
29
+ declare function hasSingletonPending(entry: RegistryEntry): boolean;
30
+ declare function hasOnBootComplete(instance: any): instance is {
31
+ onBootComplete: () => Promise<void>;
32
+ };
33
+ declare function isAlsToken(token: unknown): token is AlsToken;
34
+
35
+ type Constructor<T = any> = new (...args: any[]) => T;
36
+ type Factory<T = any> = (requestId?: string) => T;
37
+ type AsyncFactory<T = any> = (requestId?: string) => Promise<T>;
38
+ interface OnInit {
39
+ onInit(): void | Promise<void>;
40
+ }
41
+ interface OnDestroy {
42
+ onDestroy(): void | Promise<void>;
43
+ }
44
+ interface OnBootComplete {
45
+ onBootComplete(): void | Promise<void>;
46
+ }
47
+ type Metadata = Record<string, any>;
48
+ interface MetadataQuery {
49
+ [key: string]: any | ((value: any) => boolean);
50
+ }
51
+ interface RegistryEntry {
52
+ scope: Scope;
53
+ factory: (requestId?: string) => any;
54
+ pending?: Promise<any>;
55
+ instance?: any;
56
+ metadata?: Metadata;
57
+ }
58
+ type Token = Constructor | string | symbol | AlsToken;
59
+ type Options = {
60
+ scope?: Scope;
61
+ deps?: Constructor[];
62
+ factory?: Factory | AsyncFactory;
63
+ metadata?: Metadata;
64
+ };
65
+ interface PropertyInjection {
66
+ propertyKey: string | symbol;
67
+ token: any;
68
+ optional?: boolean;
69
+ }
70
+ interface PropsInject {
71
+ name?: string;
72
+ global?: boolean;
73
+ canInject?(instance: any, constructor: Constructor): boolean;
74
+ inject(instance: any, constructor?: Constructor, registry?: Map<any, any>, injections?: PropertyInjection[]): void | Promise<void>;
75
+ }
76
+ interface RegEntryOpts {
77
+ token: Token | Constructor;
78
+ type?: string;
79
+ scope?: Scope;
80
+ factory?: Factory;
81
+ deps?: Constructor[];
82
+ input?: unknown;
83
+ metadata?: Metadata;
84
+ }
85
+ type TStore = Record<string, any>;
86
+ interface InjectionDefinition {
87
+ type: string;
88
+ target?: Constructor;
89
+ methodName?: string;
90
+ propertyKey?: string | symbol;
91
+ handler?: Function;
92
+ options?: any;
93
+ order?: number;
94
+ scope?: 'global' | 'controller' | 'method';
95
+ name?: string;
96
+ [key: string]: any;
97
+ }
98
+
99
+ declare class Resolver {
100
+ private container;
101
+ private resolving;
102
+ private instances;
103
+ private nameToToken;
104
+ private registry;
105
+ private requestScoped;
106
+ private requestPromises;
107
+ private store;
108
+ constructor(container: Container);
109
+ getInjections<T>(type: string): T[];
110
+ getInjectionsFor<T>(type: string, target: Constructor, methodName?: string): T[];
111
+ hasInjection(type: any, target: Constructor, methodName?: string): boolean;
112
+ private getRequestId;
113
+ private resolveToken;
114
+ get<T>(token: string): T;
115
+ get<T>(token: symbol): T;
116
+ get<T>(token: Constructor<T>, requestId?: string): T;
117
+ private getBindingSync;
118
+ resolve<T>(token: string): Promise<T>;
119
+ resolve<T>(token: symbol): Promise<T>;
120
+ resolve<T>(token: Constructor<T>, requestId?: string): Promise<T>;
121
+ private resolveBinding;
122
+ private createInstance;
123
+ private cache;
124
+ init(instance: any): Promise<void>;
125
+ destroy(instance: any): Promise<void>;
126
+ private getReqCache;
127
+ private getReqPromiseCache;
128
+ private ensureReqPromiseCache;
129
+ private ensureReqCache;
130
+ getOrdered<T>(token: any, key: keyof T, direction?: 'asc' | 'desc'): T[];
131
+ private isObject;
132
+ private checkTokenExist;
133
+ private checkCircularDep;
134
+ private getByName;
135
+ /**
136
+ * Get all registered tokens
137
+ */
138
+ findAll(): Token[];
139
+ /**
140
+ * Get all registered values (entries)
141
+ */
142
+ getAll(): any[];
143
+ /**
144
+ * Get all entries as [token, value] pairs
145
+ */
146
+ entries(): [Token, any][];
147
+ /**
148
+ * Get only class constructors (filters out symbols, configs, primitives)
149
+ */
150
+ getClasses(): Constructor[];
151
+ /**
152
+ * Check if value is a class constructor
153
+ */
154
+ private isClass;
155
+ }
156
+
157
+ declare class Instantiator {
158
+ private container;
159
+ private propsInject;
160
+ private injectorTokens;
161
+ constructor(container: Container);
162
+ build<T>(ClassRef: Constructor<T>, requestId?: string, explicitDeps?: Constructor[]): Promise<T>;
163
+ private resolveDependencies;
164
+ private injectProperties;
165
+ private isInjectorToken;
166
+ addInjector(injector: PropsInject): void;
167
+ use(injector: PropsInject): this;
168
+ }
169
+
170
+ declare class AlsStore<T extends Record<string, any> = any> {
171
+ protected readonly als: AsyncLocalStorage<Map<string, any>>;
172
+ run<R>(data: Partial<T>, fn: () => R): R;
173
+ get<K extends keyof T>(key: K): T[K] | undefined;
174
+ set<K extends keyof T>(key: K, data: T[K]): void;
175
+ set(data: Partial<T>): void;
176
+ has(key: keyof T): boolean;
177
+ isActive(): boolean;
178
+ all(): Partial<T> | undefined;
179
+ delete(key: keyof T): void;
180
+ clear(): void;
181
+ }
182
+
183
+ declare class Container {
184
+ private static instance;
185
+ readonly registry: Map<Token, RegistryEntry>;
186
+ readonly nameToToken: Map<string, Token>;
187
+ readonly requestScoped: Map<string, Map<Token, any>>;
188
+ readonly requestPromises: Map<string, Map<Token, Promise<any>>>;
189
+ readonly instantiator: Instantiator;
190
+ private readonly register;
191
+ readonly resolver: Resolver;
192
+ private readonly deleter;
193
+ readonly store: AlsStore<TStore>;
194
+ constructor();
195
+ /**
196
+ * Get the global singleton container instance
197
+ * Creates one if it doesn't exist
198
+ */
199
+ static getInstance(): Container;
200
+ /**
201
+ * Create a new isolated container instance
202
+ * Useful for testing to avoid shared state
203
+ * @example
204
+ * const testContainer = Container.create();
205
+ */
206
+ static create(): Container;
207
+ /**
208
+ * Reset the global singleton instance
209
+ * Clears all registrations and creates a fresh container
210
+ * Primarily for testing cleanup
211
+ */
212
+ static reset(): Promise<Container>;
213
+ /**
214
+ * Check if a global instance exists
215
+ */
216
+ static hasInstance(): boolean;
217
+ set<T>(token: Token, value: T): this;
218
+ set<T>(token: string, value: T): this;
219
+ set<T>(token: symbol, value: T): this;
220
+ set<T>(token: Constructor[], options?: Scope | Options): this;
221
+ set<T>(token: Constructor, value?: T | Scope | Options): this;
222
+ use(injector: any): this;
223
+ get<T>(token: AlsToken<T>): T | any;
224
+ get<T>(token: Constructor<T>, requestId?: string): T;
225
+ get<T>(token: string): T | any;
226
+ get<T>(token: symbol): T | any;
227
+ resolve<T>(token: Token | Constructor<T>, requestId?: string): Promise<T>;
228
+ resolve<T>(token: string): Promise<T | any>;
229
+ resolve<T>(token: symbol): Promise<T>;
230
+ push<T>(token: Token, ...items: T[]): this;
231
+ filter<T>(token: Token, predicate: (item: T) => boolean): T[];
232
+ setInjection(definition: InjectionDefinition): Token;
233
+ getInjections<T extends {
234
+ type: string;
235
+ }>(type: T['type']): T[];
236
+ getInjectionsFor<T extends {
237
+ type: string;
238
+ target?: Constructor;
239
+ methodName?: string;
240
+ }>(type: T['type'], target: Constructor, methodName?: string): T[];
241
+ getOrdered<T>(token: Token, key: keyof T, direction?: 'asc' | 'desc'): T[];
242
+ has(token: Token): boolean;
243
+ delete(token: Token): Promise<void>;
244
+ run<R>(data: Partial<TStore>, fn: () => R): R;
245
+ isActive(): boolean;
246
+ all(): Partial<TStore> | undefined;
247
+ clearStore(): void;
248
+ cleanupReq(requestId?: string): Promise<void>;
249
+ bulkRemove(items: Constructor[]): Promise<this>;
250
+ clear(): Promise<void>;
251
+ /**
252
+ * Configure default metadata values that will be applied to all future registrations
253
+ * @param metadata - Default metadata to merge with existing defaults
254
+ * @example
255
+ * container.setDefaults({ layer: 'core', priority: 10 })
256
+ * container.setDefaults({ domain: 'auth', critical: true })
257
+ */
258
+ setDefaults(metadata: Metadata): this;
259
+ /**
260
+ * Set metadata on a token
261
+ * @example
262
+ * container.setMeta(UserService, 'layer', 'domain')
263
+ * container.setMeta(UserService, { layer: 'domain', priority: 5 })
264
+ */
265
+ setMeta(token: Token, key: string, value: any): this;
266
+ setMeta(token: Token, metadata: Metadata): this;
267
+ /**
268
+ * Get metadata from a token
269
+ * @example
270
+ * container.getMeta(UserService, 'layer') // 'domain'
271
+ * container.getMeta(UserService) // { layer: 'domain', priority: 5 }
272
+ */
273
+ getMeta(token: Token, key?: string): any;
274
+ /**
275
+ * Check if token has metadata key
276
+ */
277
+ hasMeta(token: Token, key: string): boolean;
278
+ /**
279
+ * Delete metadata from a token
280
+ */
281
+ deleteMeta(token: Token, key: string): this;
282
+ /**
283
+ * Clear all metadata from a token
284
+ */
285
+ clearMeta(token: Token): this;
286
+ /**
287
+ * Find tokens by metadata query
288
+ * @example
289
+ * container.find({ layer: 'core' })
290
+ * container.find({ layer: 'domain', priority: (p) => p > 5 })
291
+ * container.find({ type: 'controller' })
292
+ * container.find({ type: 'service' })
293
+ */
294
+ find(query: MetadataQuery): Token[];
295
+ /**
296
+ * Find tokens that have a specific metadata key
297
+ * @example
298
+ * container.findByKey('priority')
299
+ */
300
+ findByKey(key: string): Token[];
301
+ /**
302
+ * Group tokens by a metadata key
303
+ * @example
304
+ * container.groupBy('layer') // Map { 'core' => [...], 'domain' => [...] }
305
+ * container.groupBy('type') // Map { 'controller' => [...], 'service' => [...] }
306
+ */
307
+ groupBy(key: string): Map<any, Token[]>;
308
+ /**
309
+ * Get all unique values for a metadata key
310
+ * @example
311
+ * container.getValues('layer') // Set { 'core', 'domain', 'app' }
312
+ * container.getValues('type') // Set { 'controller', 'service', 'repository' }
313
+ */
314
+ getValues(key: string): Set<any>;
315
+ /**
316
+ * Filter tokens with custom predicate
317
+ * @example
318
+ * container.filterBy((meta) => meta.tags?.includes('critical'))
319
+ */
320
+ filterBy(predicate: (metadata: Metadata, token: Token) => boolean): Token[];
321
+ /**
322
+ * Bulk set metadata on multiple tokens
323
+ * @example
324
+ * container.bulkSetMeta([UserService, OrderService], { layer: 'domain' })
325
+ */
326
+ bulkSetMeta(tokens: Token[], metadata: Metadata): this;
327
+ boot<T = any>(services?: Token[] | Constructor[]): Promise<T[]>;
328
+ /**
329
+ * Boot services by metadata query
330
+ * @example
331
+ * await container.bootBy({ layer: 'core' })
332
+ * await container.bootBy({ type: 'controller' })
333
+ * await container.bootBy({ critical: true })
334
+ */
335
+ bootBy(query: MetadataQuery): Promise<void>;
336
+ /**
337
+ * Boot services in phases based on metadata
338
+ * @example
339
+ * await container.bootPhased('layer', ['core', 'domain', 'app'])
340
+ * await container.bootPhased('type', ['service', 'controller'])
341
+ */
342
+ bootPhased(key: string, phases: any[]): Promise<void>;
343
+ /**
344
+ * Boot with custom ordering by metadata key
345
+ * @example
346
+ * await container.bootOrdered('priority', 'desc')
347
+ */
348
+ bootOrdered(key: string, order?: 'asc' | 'desc'): Promise<void>;
349
+ private notifyBootComplete;
350
+ load(providers: Constructor[]): Promise<void>;
351
+ /**
352
+ * Get all registered tokens
353
+ * @example
354
+ * container.findAll() // [UserService, Symbol(config), 'myToken', ...]
355
+ */
356
+ findAll(): Token[];
357
+ /**
358
+ * Get all registered values/entries
359
+ * @example
360
+ * container.getAll() // [RegistryEntry, configValue, ...]
361
+ */
362
+ getAll(): any[];
363
+ /**
364
+ * Get all entries as [token, value] pairs
365
+ * @example
366
+ * container.entries() // [[UserService, entry], [Symbol(config), value], ...]
367
+ */
368
+ entries(): [Token, any][];
369
+ /**
370
+ * Get only class constructors (filters out symbols, configs, primitives)
371
+ * Useful for scanning decorators on classes
372
+ * @example
373
+ * container.getClasses() // [UserService, OrderController, AuthRepository, ...]
374
+ */
375
+ getClasses(): Constructor[];
376
+ }
377
+ declare const container: Container;
378
+ declare function set<T>(token: AlsToken<T>, value: T): Container;
379
+ declare function set<T>(token: string, value: T): Container;
380
+ declare function set<T>(token: symbol, value: T): Container;
381
+ declare function set<T>(token: Constructor[], options?: Scope | Options): Container;
382
+ declare function set<T>(token: Constructor<T>, value?: T | Scope | Options): Container;
383
+ declare function get<T>(token: AlsToken<T>): T | any;
384
+ declare function get<T>(token: Constructor<T>, requestId?: string): T;
385
+ declare function get<T>(token: string): T | any;
386
+ declare function get<T>(token: symbol): T | any;
387
+ declare function resolve<T>(token: Constructor<T>, requestId?: string): Promise<T>;
388
+ declare function resolve<T>(token: string): Promise<T>;
389
+ declare function resolve<T>(token: symbol): Promise<T>;
390
+ declare function has(token: Token): boolean;
391
+ declare function boot(services?: Constructor[]): Promise<any[]>;
392
+ declare function reset(): Promise<Container>;
393
+ declare function findAll(): Token[];
394
+ declare function getAll(): any[];
395
+ declare function getClasses(): Constructor[];
396
+
397
+ declare class BaseError extends Error {
398
+ readonly code: string;
399
+ message: string;
400
+ readonly status?: number;
401
+ name: string;
402
+ constructor(code: string, message: string, status?: number);
403
+ toJSON(): Record<string, any>;
404
+ toResponse(): Response;
405
+ static is(error: unknown): error is BaseError;
406
+ static hasCode(error: unknown, code: string): boolean;
407
+ static from(error: unknown, fallbackStatus?: number): BaseError;
408
+ }
409
+ declare const DI_CODES: {
410
+ readonly MISSING_PROVIDER: "DI_001";
411
+ readonly CIRCULAR_DEPENDENCY: "DI_002";
412
+ readonly NOT_INJECTABLE: "DI_003";
413
+ readonly SCOPE_VIOLATION: "DI_004";
414
+ readonly CONSTRUCTOR_RESOLUTION: "DI_005";
415
+ readonly TYPE_MISMATCH: "DI_006";
416
+ readonly NOT_REGISTERED: "DI_007";
417
+ readonly SINGLETON_NOT_INITIALIZED: "DI_008";
418
+ readonly REQUEST_ID_REQUIRED: "DI_009";
419
+ readonly REQUEST_INSTANCE_NOT_FOUND: "DI_010";
420
+ readonly TRANSIENT_SYNC_NOT_SUPPORTED: "DI_011";
421
+ readonly ASYNC_FACTORY_REQUIRED: "DI_012";
422
+ readonly CANNOT_PUSH_TO_CLASS: "DI_013";
423
+ };
424
+ declare const DIError: {
425
+ missingProvider: (token: Token, context?: string) => never;
426
+ circularDependency: (chain: Token[]) => never;
427
+ notInjectable: (target: Constructor) => never;
428
+ scopeViolation: (token: Token, reason: string) => never;
429
+ constructorResolve: (target: Constructor, index: number) => never;
430
+ typeMismatch: (target: Constructor, expected: string, actual: string) => never;
431
+ notRegistered: (token: Token) => never;
432
+ singletonNotInitialized: (token: Token) => never;
433
+ requestIdRequired: (token: Token) => never;
434
+ requestInstanceNotFound: (token: Token, requestId: string) => never;
435
+ transientSyncNotSupported: (token: Token) => never;
436
+ asyncFactoryRequired: (token: Token) => never;
437
+ cannotPushToClass: (token: Token) => never;
438
+ };
439
+
440
+ declare class MetadataManager {
441
+ private registry;
442
+ private keyIndex;
443
+ private valueIndex;
444
+ constructor(registry: Map<Token, any>);
445
+ set(token: Token, key: string, value: any): void;
446
+ set(token: Token, metadata: Metadata): void;
447
+ private updateIndexes;
448
+ get(token: Token, key?: string): any;
449
+ has(token: Token, key: string): boolean;
450
+ delete(token: Token, key: string): void;
451
+ clear(token: Token): void;
452
+ find(query: MetadataQuery): Token[];
453
+ private parseQuery;
454
+ private findTokens;
455
+ private findByIntersection;
456
+ private findByScan;
457
+ private sortTokens;
458
+ findByKey(key: string): Token[];
459
+ getValues(key: string): Set<any>;
460
+ groupBy(key: string): Map<any, Token[]>;
461
+ filter(predicate: (metadata: Metadata, token: Token) => boolean): Token[];
462
+ private matches;
463
+ bulkSet(tokens: Token[], metadata: Metadata): void;
464
+ copy(from: Token, to: Token): void;
465
+ removeToken(token: Token): void;
466
+ clearIndexes(): void;
467
+ }
468
+
469
+ declare class Register {
470
+ private container;
471
+ private registry;
472
+ private nameToToken;
473
+ private instantiator;
474
+ private store;
475
+ readonly metadata: MetadataManager;
476
+ private defaultMetadata;
477
+ constructor(container: Container);
478
+ setDefaults(metadata: Metadata): this;
479
+ push<T>(token: Token, ...items: T[]): void;
480
+ filter<T>(token: Token, predicate: (item: T) => boolean): T[];
481
+ setInjection(definition: InjectionDefinition): Token;
482
+ set<T>(token: string, input: T): this;
483
+ set<T>(token: symbol, value: T): this;
484
+ set<T>(token: Constructor[], options?: Scope | Options): this;
485
+ set<T>(token: Constructor, input?: Scope | Options): this;
486
+ set<T>(token: AlsToken<T>, input: T): this;
487
+ private registerEntry;
488
+ private handleConstructor;
489
+ private handleArrayToken;
490
+ private handleNamedToken;
491
+ private handleAlsToken;
492
+ private validateType;
493
+ private resolveCtx;
494
+ /**
495
+ * Resolve scope with priority:
496
+ * 1. Explicit scope passed to set() (e.g., container.set(Svc, Scope.REQUEST))
497
+ * 2. Scope in options object (e.g., container.set(Svc, { scope: Scope.REQUEST }))
498
+ * 3. Scope from decorator (e.g., @Service(Scope.REQUEST))
499
+ * 4. Default: SINGLETON
500
+ */
501
+ private resolveScope;
502
+ private isFactory;
503
+ private isScope;
504
+ private asOptions;
505
+ private isInstance;
506
+ private cleanInput;
507
+ private cleanOptions;
508
+ getByName(name: string): Token | undefined;
509
+ }
510
+
511
+ declare class Deleter {
512
+ private readonly container;
513
+ private readonly registry;
514
+ private readonly store;
515
+ private readonly nameToToken;
516
+ private readonly requestScoped;
517
+ private readonly requestPromises;
518
+ constructor(container: Container);
519
+ cleanupReq(requestId?: string): Promise<void>;
520
+ private destroyRequestScopedInstances;
521
+ private clearRequestMaps;
522
+ delete(token: Token): Promise<void>;
523
+ private deleteAlsToken;
524
+ private deleteNamedToken;
525
+ private deleteRegistryToken;
526
+ private destroyRegistryValue;
527
+ private cleanTokenFromRequestScopes;
528
+ private removeTokenFromMaps;
529
+ clear(): Promise<void>;
530
+ private collectRegistryDestroyPromises;
531
+ private collectRequestScopedDestroyPromises;
532
+ private shouldSkipRegistryEntry;
533
+ private extractInstance;
534
+ private clearAllMaps;
535
+ private clearRegistryPreservingContainer;
536
+ destroy(instance: any): Promise<void>;
537
+ private resolveRequestId;
538
+ private resolveToken;
539
+ private isDestroyableValue;
540
+ }
541
+
542
+ /** Marks a class as injectable */
543
+ declare const INJECTABLE: unique symbol;
544
+ /** Scope of the injectable (singleton, transient, request) */
545
+ declare const SCOPE: unique symbol;
546
+ /** Type category: 'service' | 'controller' | 'repository' | etc. */
547
+ declare const CLASS_TYPE: unique symbol;
548
+ /** Custom metadata attached via @Meta() */
549
+ declare const METADATA: unique symbol;
550
+ /** @Service marker */
551
+ declare const SERVICE: unique symbol;
552
+ /** @Controller marker */
553
+ declare const CONTROLLER: unique symbol;
554
+ /** @Controller path */
555
+ declare const CONTROLLER_PATH: unique symbol;
556
+ /** @Repository marker */
557
+ declare const REPOSITORY: unique symbol;
558
+ /** @Repository database name */
559
+ declare const DATABASE: unique symbol;
560
+ /** Property injection metadata */
561
+ declare const INJECT_PROPS: unique symbol;
562
+ /** Constructor parameter injection metadata */
563
+ declare const INJECT_PARAMS: unique symbol;
564
+ /** @Scan property decorator metadata */
565
+ declare const SCAN_PROPS: unique symbol;
566
+ declare const DESIGN_PARAMTYPES = "design:paramtypes";
567
+ declare const DESIGN_TYPE = "design:type";
568
+ declare const DESIGN_RETURNTYPE = "design:returntype";
569
+
570
+ type NextFunction = () => void;
571
+ interface InjectableType {
572
+ token: Token;
573
+ index: number;
574
+ }
575
+ interface InjectableOptions {
576
+ scope?: Scope;
577
+ }
578
+ interface Registration {
579
+ factory: Factory;
580
+ scope: Scope;
581
+ }
582
+ type DecoratorMetadata = Record<string, any>;
583
+ interface ServiceOptions {
584
+ scope?: Scope;
585
+ metadata?: DecoratorMetadata;
586
+ }
587
+ interface ControllerOptions {
588
+ path?: string;
589
+ metadata?: DecoratorMetadata;
590
+ }
591
+ interface RepositoryOptions {
592
+ database?: string;
593
+ metadata?: DecoratorMetadata;
594
+ }
595
+
596
+ /**
597
+ * Get the class type set by decorators
598
+ * Returns: 'service' | 'controller' | 'repository' | undefined
599
+ */
600
+ declare function getClassType(target: Function): string | undefined;
601
+ /**
602
+ * @internal Used by decorators to set class type
603
+ */
604
+ declare function setClassType(target: Function, type: string): void;
605
+ declare function isInjectable(target: Function): boolean;
606
+ /**
607
+ * @internal
608
+ */
609
+ declare function setInjectable(target: Function, value?: boolean): void;
610
+ declare function getScope(target: Function): Scope;
611
+ /**
612
+ * @internal
613
+ */
614
+ declare function setScope(target: Function, scope: Scope): void;
615
+ declare function getDecoratorMetadata(target: Function): DecoratorMetadata;
616
+ declare function hasDecoratorMetadata(target: Function, key: string): boolean;
617
+ declare function getDecoratorMetadataValue<T = any>(target: Function, key: string): T | undefined;
618
+ /**
619
+ * @internal
620
+ */
621
+ declare function mergeMetadata(target: Function, metadata: DecoratorMetadata): void;
622
+
623
+ /**
624
+ * Get constructor or method parameter types via reflect-metadata
625
+ *
626
+ * @example
627
+ * ```ts
628
+ * // Constructor params
629
+ * getParamTypes(MyClass) // [UserRepo, Logger]
630
+ *
631
+ * // Method params
632
+ * getParamTypes(MyClass.prototype, 'someMethod') // [string, number]
633
+ * ```
634
+ */
635
+ declare function getParamTypes(target: any, propertyKey?: string | symbol): any[];
636
+ /**
637
+ * Get the declared type of a property via reflect-metadata
638
+ *
639
+ * @example
640
+ * ```ts
641
+ * class MyService {
642
+ * @Inject() userRepo: UserRepository;
643
+ * }
644
+ *
645
+ * getPropertyType(MyService.prototype, 'userRepo') // UserRepository
646
+ * ```
647
+ */
648
+ declare function getPropertyType(target: any, propertyKey: string | symbol): any;
649
+ /**
650
+ * Get the return type of a method via reflect-metadata
651
+ *
652
+ * @example
653
+ * ```ts
654
+ * class MyService {
655
+ * getUser(): User { ... }
656
+ * }
657
+ *
658
+ * getReturnType(MyService.prototype, 'getUser') // User
659
+ * ```
660
+ */
661
+ declare function getReturnType(target: any, propertyKey: string | symbol): any;
662
+ /**
663
+ * Get property or return type via reflect-metadata
664
+ *
665
+ * @deprecated Use getPropertyType() or getReturnType() instead
666
+ */
667
+ declare function getReflectType(target: any, propertyKey: string | symbol, kind?: 'property' | 'return'): any;
668
+
669
+ declare class MetaHelper {
670
+ static get<T>(key: symbol, target: any, propertyKey?: string | symbol): T | any;
671
+ static define(key: symbol, value: any, target: any, propertyKey?: string | symbol): void;
672
+ static append<T>(key: symbol, value: T, target: any, propertyKey?: string): void;
673
+ static appendMany<T>(key: symbol, values: T[], target: any, propertyKey?: string | symbol): void;
674
+ static merge<T extends Record<string, any>>(key: symbol, value: T, target: any, propertyKey?: string): void;
675
+ }
676
+
677
+ /**
678
+ * Core Inject decorator - injects dependencies into properties and constructor parameters
679
+ *
680
+ * @example
681
+ * ```ts
682
+ * class MyService {
683
+ * @Inject() userRepo: UserRepository;
684
+ * @Inject('config') config: any;
685
+ *
686
+ * constructor(@Inject('db') db: Database) {}
687
+ * }
688
+ * ```
689
+ */
690
+ declare function Inject(token?: any): any;
691
+ declare function getPropertyInjections(target: Function): any[];
692
+ declare function getParameterInjections(target: Function): any[];
693
+
694
+ /**
695
+ * Core Injectable decorator - marks a class as injectable
696
+ *
697
+ * @internal Use @Service, @Repository, or @Controller instead
698
+ *
699
+ * @example
700
+ * ```ts
701
+ * @Injectable()
702
+ * class GenericService {}
703
+ *
704
+ * @Injectable(Scope.TRANSIENT)
705
+ * class TransientService {}
706
+ * ```
707
+ */
708
+ declare function Injectable(scope?: Scope): ClassDecorator;
709
+
710
+ /**
711
+ * Service decorator - marks a class as an injectable service
712
+ *
713
+ * @example
714
+ * ```ts
715
+ * @Service()
716
+ * class UserService {}
717
+ *
718
+ * @Service(Scope.TRANSIENT)
719
+ * class RequestHandler {}
720
+ *
721
+ * @Service({ scope: Scope.SINGLETON, metadata: { layer: 'domain' } })
722
+ * class DomainService {}
723
+ * ```
724
+ */
725
+ declare function Service(options?: Scope | ServiceOptions): ClassDecorator;
726
+ declare function isService(target: Function): boolean;
727
+
728
+ /**
729
+ * Controller decorator with optional metadata
730
+ *
731
+ * @example
732
+ * ```ts
733
+ * @Controller('/users')
734
+ * class UserController {}
735
+ *
736
+ * @Controller({ path: '/api/users', metadata: { version: 'v1' } })
737
+ * class UserApiController {}
738
+ * ```
739
+ */
740
+ declare function Controller(options?: string | ControllerOptions): ClassDecorator;
741
+ declare function isController(target: Function): boolean;
742
+ declare function getPath(target: Function): string | undefined;
743
+
744
+ /**
745
+ * Repository decorator for data access layer
746
+ *
747
+ * @example
748
+ * ```ts
749
+ * @Repository()
750
+ * class UserRepository {}
751
+ *
752
+ * @Repository('postgres')
753
+ * class PostgresUserRepository {}
754
+ *
755
+ * @Repository({ database: 'mongodb', metadata: { layer: 'data' } })
756
+ * class MongoUserRepository {}
757
+ * ```
758
+ */
759
+ declare function Repository(options?: string | RepositoryOptions): ClassDecorator;
760
+ declare function isRepository(target: Function): boolean;
761
+ declare function getDatabase(target: Function): string | undefined;
762
+
763
+ /**
764
+ * Stackable metadata decorator for classes
765
+ *
766
+ * @example
767
+ * ```ts
768
+ * @Service()
769
+ * @Meta({ layer: 'domain', priority: 10 })
770
+ * @Meta({ tags: ['critical'] })
771
+ * class UserService {}
772
+ * ```
773
+ */
774
+ declare function Meta(metadata: DecoratorMetadata): ClassDecorator;
775
+
776
+ /**
777
+ * Inject the DI Container itself
778
+ *
779
+ * @example
780
+ * ```ts
781
+ * class MyService {
782
+ * @DI() container: Container;
783
+ *
784
+ * doSomething() {
785
+ * const config = this.container.get('config');
786
+ * }
787
+ * }
788
+ * ```
789
+ */
790
+ declare function DI(): PropertyDecorator;
791
+
792
+ /**
793
+ * Inject AlsStore for accessing AsyncLocalStorage context
794
+ *
795
+ * @example
796
+ * ```ts
797
+ * class MyService {
798
+ * @Store() store: AlsStore;
799
+ *
800
+ * doSomething() {
801
+ * const requestId = this.store.get(REQUEST_ID);
802
+ * }
803
+ * }
804
+ * ```
805
+ */
806
+ declare function Store(): PropertyDecorator;
807
+
808
+ /**
809
+ * Value injection decorator - injects values (strings, objects, numbers) by token
810
+ * Returns undefined if the token is not registered (optional by default)
811
+ *
812
+ * @example
813
+ * ```ts
814
+ * class MyService {
815
+ * @Value('API_KEY') apiKey?: string;
816
+ * @Value('CONFIG') config?: { port: number };
817
+ * @Value(DATABASE_URL) dbUrl?: string;
818
+ * }
819
+ * ```
820
+ */
821
+ declare function Value(token: any): PropertyDecorator;
822
+
823
+ export { AlsStore, AlsToken, type AsyncFactory, BaseError, CLASS_TYPE, CONTROLLER, CONTROLLER_PATH, type Constructor, Container, Controller, type ControllerOptions, DATABASE, DESIGN_PARAMTYPES, DESIGN_RETURNTYPE, DESIGN_TYPE, DI, DIError, DI_CODES, type DecoratorMetadata, Deleter, type Factory, FactoryWrapper, INJECTABLE, INJECTIONS, INJECT_PARAMS, INJECT_PROPS, Inject, Injectable, type InjectableOptions, type InjectableType, type InjectionDefinition, Instantiator, METADATA, Meta, MetaHelper, type Metadata, MetadataManager, type MetadataQuery, type NextFunction, type OnBootComplete, type OnDestroy, type OnInit, type Options, type PropertyInjection, type PropsInject, REPOSITORY, type RegEntryOpts, Register, type Registration, type RegistryEntry, Repository, type RepositoryOptions, Resolver, SCAN_PROPS, SCOPE, SERVICE, Scope, Service, type ServiceOptions, Store, type TStore, type Token, Value, boot, container, createAlsToken, findAll, get, getAll, getClassType, getClasses, getDatabase, getDecoratorMetadata, getDecoratorMetadataValue, getParamTypes, getParameterInjections, getPath, getPropertyInjections, getPropertyType, getReflectType, getReturnType, getScope, has, hasDecoratorMetadata, hasOnBootComplete, hasOnDestroy, hasOnInit, hasSingletonInstance, hasSingletonPending, isAlsToken, isArrayToken, isConstructor, isController, isInjectable, isNamedToken, isRegistryEntry, isRepository, isReqScope, isService, mergeMetadata, reset, resolve, set, setClassType, setInjectable, setScope };