import { Logger, LoggerConfig } from '#logger/logger.js'; import { Class, Provider, UseFactoryTuple } from '#di'; import { LogMediator } from '#logger/log-mediator.js'; import { AnyFn } from '#types/mix.js'; import { NormalizedProvider } from './ng-utils.js'; /** * This class has utilites to adding providers to DI in more type safe way. * * You can use this as follow: * * ```ts Module({ // ... providersPerMod: new Providers() .useLogConfig({ level: 'debug' }) .useClass(SomeService, ExtendedService), }) export class SomeModule {} * ``` */ export declare class Providers { protected providers: Provider[]; protected setedIf?: boolean; protected ifCondition?: boolean; passThrough(provider: Provider): this; useValue(token: NonNullable, useValue: T, multi?: boolean): this; useClass(token: A, useClass: B, multi?: boolean): this; useToken(token: NonNullable, useToken: T, multi?: boolean): this; useFactory(token: NonNullable, useFactory: AnyFn, deps?: any[], multi?: boolean): this; useFactory(token: NonNullable, useFactory: UseFactoryTuple, multi?: boolean): this; useLogger(useLogger: Partial, useConfig?: LoggerConfig): this; useLogConfig(useConfig: LoggerConfig): this; useSystemLogMediator>(CustomLogMediator: T): this; /** * ### Conditions * * If the `condition` is `true`, then the following expression will work. * * __Example 1__ * ```ts const providers = new Providers().$if(true).useValue('token', 'value'); [...providers]; // return [{ token: 'token', useValue: 'value' }] ``` * * __Example 2__ * ```ts const value = new Providers() .$if(false) .useValue('token1', 'value1') .useValue('token2', 'value2'); [...providers]; // return [{ token: 'token2', useValue: 'value2' }] ``` */ $if(condition: any): this; /** * ### Plugins * * You can even use plugins for this class: * * ```ts class Plugin1 extends Providers { method1() { if (this.true) { // ... } return this.self; } } class Plugin2 extends Providers { method2() { if (this.true) { // ... } return this.self; } } const providers = [...new Providers() .use(Plugin1) .use(Plugin2) .method1() .method2() .useLogConfig({ level: 'trace' }) .useClass(SomeService, ExtendedService)]; * ``` * * That is, after using the use() method, you will be able to use plugin methods. * As you can see, each plugin method should only add providers if the`if (this.true)' * condition is truthy. Additionally, each method must return `this.self`. * * This should be done so that the `providers.$if()` method works correctly. */ $use>(Plugin: T): T['prototype'] & this; protected resetIfConditions(): void; protected get true(): boolean | undefined; protected get self(): this; protected [Symbol.iterator](): { next: () => { done: boolean; value: Provider; }; }; protected pushProvider(provider: NormalizedProvider, multi?: boolean): void; } //# sourceMappingURL=providers.d.ts.map