-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
/
configurable-module-host.interface.ts
77 lines (76 loc) 路 2.41 KB
/
configurable-module-host.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { ConfigurableModuleAsyncOptions } from './configurable-module-async-options.interface';
import { ConfigurableModuleCls } from './configurable-module-cls.interface';
/**
* Configurable module host. See properties for more details
*
* @publicApi
*/
export interface ConfigurableModuleHost<
ModuleOptions = Record<string, unknown>,
MethodKey extends string = string,
FactoryClassMethodKey extends string = string,
ExtraModuleDefinitionOptions = {},
> {
/**
* Class that represents a blueprint/prototype for a configurable Nest module.
* This class provides static methods for constructing dynamic modules. Their names
* can be controlled through the "MethodKey" type argument.
*
* Your module class should inherit from this class to make the static methods available.
*
* @example
* ```typescript
* @Module({})
* class IntegrationModule extends ConfigurableModuleCls {
* // ...
* }
* ```
*/
ConfigurableModuleClass: ConfigurableModuleCls<
ModuleOptions,
MethodKey,
FactoryClassMethodKey,
ExtraModuleDefinitionOptions
>;
/**
* Module options provider token. Can be used to inject the "options object" to
* providers registered within the host module.
*/
MODULE_OPTIONS_TOKEN: string | symbol;
/**
* Can be used to auto-infer the compound "async module options" type.
* Note: this property is not supposed to be used as a value.
*
* @example
* ```typescript
* @Module({})
* class IntegrationModule extends ConfigurableModuleCls {
* static module = initializer(IntegrationModule);
*
* static registerAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule {
* return super.registerAsync(options);
* }
* ```
*/
ASYNC_OPTIONS_TYPE: ConfigurableModuleAsyncOptions<
ModuleOptions,
FactoryClassMethodKey
> &
Partial<ExtraModuleDefinitionOptions>;
/**
* Can be used to auto-infer the compound "module options" type (options interface + extra module definition options).
* Note: this property is not supposed to be used as a value.
*
* @example
* ```typescript
* @Module({})
* class IntegrationModule extends ConfigurableModuleCls {
* static module = initializer(IntegrationModule);
*
* static register(options: typeof OPTIONS_TYPE): DynamicModule {
* return super.register(options);
* }
* ```
*/
OPTIONS_TYPE: ModuleOptions & Partial<ExtraModuleDefinitionOptions>;
}