UNPKG

1.9 kBTypeScriptView Raw
1import { FactoryProvider, ModuleMetadata, Provider, Type } from '../../interfaces';
2import { DEFAULT_FACTORY_CLASS_METHOD_KEY } from '../constants';
3/**
4 * Interface that must be implemented by the module options factory class.
5 * Method key varies depending on the "FactoryClassMethodKey" type argument.
6 *
7 * @publicApi
8 */
9export type ConfigurableModuleOptionsFactory<ModuleOptions, FactoryClassMethodKey extends string> = Record<`${FactoryClassMethodKey}`, () => Promise<ModuleOptions> | ModuleOptions>;
10/**
11 * Interface that represents the module async options object
12 * Factory method name varies depending on the "FactoryClassMethodKey" type argument.
13 *
14 * @publicApi
15 */
16export interface ConfigurableModuleAsyncOptions<ModuleOptions, FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY> extends Pick<ModuleMetadata, 'imports'> {
17 /**
18 * Injection token resolving to an existing provider. The provider must implement
19 * the corresponding interface.
20 */
21 useExisting?: Type<ConfigurableModuleOptionsFactory<ModuleOptions, FactoryClassMethodKey>>;
22 /**
23 * Injection token resolving to a class that will be instantiated as a provider.
24 * The class must implement the corresponding interface.
25 */
26 useClass?: Type<ConfigurableModuleOptionsFactory<ModuleOptions, FactoryClassMethodKey>>;
27 /**
28 * Function returning options (or a Promise resolving to options) to configure the
29 * cache module.
30 */
31 useFactory?: (...args: any[]) => Promise<ModuleOptions> | ModuleOptions;
32 /**
33 * Dependencies that a Factory may inject.
34 */
35 inject?: FactoryProvider['inject'];
36 /**
37 * List of parent module's providers that will be filtered to only provide necessary
38 * providers for the 'inject' array
39 * useful to pass options to nested async modules
40 */
41 provideInjectionTokensFrom?: Provider[];
42}