forked from nestjs/nest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configurable-module-async-options.interface.ts
62 lines (60 loc) 路 1.86 KB
/
configurable-module-async-options.interface.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import {
FactoryProvider,
ModuleMetadata,
Provider,
Type,
} from '../../interfaces';
import { DEFAULT_FACTORY_CLASS_METHOD_KEY } from '../constants';
/**
* Interface that must be implemented by the module options factory class.
* Method key varies depending on the "FactoryClassMethodKey" type argument.
*
* @publicApi
*/
export type ConfigurableModuleOptionsFactory<
ModuleOptions,
FactoryClassMethodKey extends string,
> = Record<
`${FactoryClassMethodKey}`,
() => Promise<ModuleOptions> | ModuleOptions
>;
/**
* Interface that represents the module async options object
* Factory method name varies depending on the "FactoryClassMethodKey" type argument.
*
* @publicApi
*/
export interface ConfigurableModuleAsyncOptions<
ModuleOptions,
FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY,
> extends Pick<ModuleMetadata, 'imports'> {
/**
* Injection token resolving to an existing provider. The provider must implement
* the corresponding interface.
*/
useExisting?: Type<
ConfigurableModuleOptionsFactory<ModuleOptions, FactoryClassMethodKey>
>;
/**
* Injection token resolving to a class that will be instantiated as a provider.
* The class must implement the corresponding interface.
*/
useClass?: Type<
ConfigurableModuleOptionsFactory<ModuleOptions, FactoryClassMethodKey>
>;
/**
* Function returning options (or a Promise resolving to options) to configure the
* cache module.
*/
useFactory?: (...args: unknown[]) => Promise<ModuleOptions> | ModuleOptions;
/**
* Dependencies that a Factory may inject.
*/
inject?: FactoryProvider['inject'];
/**
* List of parent module's providers that will be filtered to only provide necessary
* providers for the 'inject' array
* useful to pass options to nested async modules
*/
provideInjectionTokensFrom?: Provider[];
}