import { type FactoryProvider, type InjectionToken, type ModuleMetadata, type Provider } from '@nestjs/common'; /** * Options for async module configuration. * * @template T - The type of configuration object the factory produces. */ export interface IAsyncModuleOptions { /** * Optional NestJS module imports needed by the provider. */ imports?: ModuleMetadata['imports']; /** * Optional DI tokens to inject into the factory function. */ inject?: FactoryProvider['inject']; /** * The factory function that produces the configuration object. * * @param args - Injected dependencies. * @returns The configuration object, or a promise that resolves to it. */ useFactory: (...args: unknown[]) => T | Promise; } /** * Creates a standard NestJS async module provider array and imports. * * This function extracts the common pattern for configuring dynamic modules * using the async factory provider approach, avoiding duplication across * modules that support both sync and async initialization. * * @template T - The type of configuration object the factory produces. * @param token - The injection token (typically a symbol or class) that identifies the provider. * @param options - The async module options including the factory function. * @param additionalProviders - Optional array of additional providers to include. * @returns An object containing the providers array and imports array. * * @example * ```typescript * const { providers, imports } = CreateAsyncProviders( * MY_CONFIG_TOKEN, * { * imports: [ConfigModule], * inject: [ConfigService], * useFactory: async (config: ConfigService) => ({ * apiKey: config.get('MY_API_KEY'), * }), * }, * [MyAdditionalService], * ); * * return { * module: MyModule, * providers, * imports, * exports: [MY_CONFIG_TOKEN], * }; * ``` */ export declare function CreateAsyncProviders(token: InjectionToken, options: IAsyncModuleOptions, additionalProviders?: Provider[]): { providers: Provider[]; imports: ModuleMetadata['imports']; }; //# sourceMappingURL=module-factory.d.ts.map