1 | import { DynamicModule } from '../interfaces';
|
2 | import { Logger } from '../services/logger.service';
|
3 | import { DEFAULT_FACTORY_CLASS_METHOD_KEY, DEFAULT_METHOD_KEY } from './constants';
|
4 | import { ConfigurableModuleHost } from './interfaces';
|
5 |
|
6 |
|
7 |
|
8 | export interface ConfigurableModuleBuilderOptions {
|
9 | |
10 |
|
11 |
|
12 |
|
13 | optionsInjectionToken?: string | symbol;
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | moduleName?: string;
|
22 | |
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | alwaysTransient?: boolean;
|
30 | }
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | export declare class ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey extends string = typeof DEFAULT_METHOD_KEY, FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY, ExtraModuleDefinitionOptions = {}> {
|
38 | protected readonly options: ConfigurableModuleBuilderOptions;
|
39 | protected staticMethodKey: StaticMethodKey;
|
40 | protected factoryClassMethodKey: FactoryClassMethodKey;
|
41 | protected extras: ExtraModuleDefinitionOptions;
|
42 | protected transformModuleDefinition: (definition: DynamicModule, extraOptions: ExtraModuleDefinitionOptions) => DynamicModule;
|
43 | protected readonly logger: Logger;
|
44 | constructor(options?: ConfigurableModuleBuilderOptions, parentBuilder?: ConfigurableModuleBuilder<ModuleOptions>);
|
45 | /**
|
46 | * Registers the "extras" object (a set of extra options that can be used to modify the dynamic module definition).
|
47 | * Values you specify within the "extras" object will be used as default values (that can be overridden by module consumers).
|
48 | *
|
49 | * This method also applies the so-called "module definition transform function" that takes the auto-generated
|
50 | * dynamic module object ("DynamicModule") and the actual consumer "extras" object as input parameters.
|
51 | * The "extras" object consists of values explicitly specified by module consumers and default values.
|
52 | *
|
53 | * @example
|
54 | * ```typescript
|
55 | * .setExtras<{ isGlobal?: boolean }>({ isGlobal: false }, (definition, extras) =>
|
56 | * ({ ...definition, global: extras.isGlobal })
|
57 | * )
|
58 | * ```
|
59 | */
|
60 | setExtras<ExtraModuleDefinitionOptions>(extras: ExtraModuleDefinitionOptions, transformDefinition?: (definition: DynamicModule, extras: ExtraModuleDefinitionOptions) => DynamicModule): ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
61 | /**
|
62 | * Dynamic modules must expose public static methods that let you pass in
|
63 | * configuration parameters (control the module's behavior from the outside).
|
64 | * Some frequently used names that you may have seen in other modules are:
|
65 | * "forRoot", "forFeature", "register", "configure".
|
66 | *
|
67 | * This method "setClassMethodName" lets you specify the name of the
|
68 | * method that will be auto-generated.
|
69 | *
|
70 | * @param key name of the method
|
71 | */
|
72 | setClassMethodName<StaticMethodKey extends string>(key: StaticMethodKey): ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
73 | /**
|
74 | * Asynchronously configured modules (that rely on other modules, i.e. "ConfigModule")
|
75 | * let you pass the configuration factory class that will be registered and instantiated as a provider.
|
76 | * This provider then will be used to retrieve the module's configuration. To provide the configuration,
|
77 | * the corresponding factory method must be implemented.
|
78 | *
|
79 | * This method ("setFactoryMethodName") lets you control what method name will have to be
|
80 | * implemented by the config factory (default is "create").
|
81 | *
|
82 | * @param key name of the method
|
83 | */
|
84 | setFactoryMethodName<FactoryClassMethodKey extends string>(key: FactoryClassMethodKey): ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
85 | /**
|
86 | * Returns an object consisting of multiple properties that lets you
|
87 | * easily construct dynamic configurable modules. See "ConfigurableModuleHost" interface for more details.
|
88 | */
|
89 | build(): ConfigurableModuleHost<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
90 | private constructInjectionTokenString;
|
91 | private createConfigurableModuleCls;
|
92 | private createTypeProxy;
|
93 | }
|
94 |
|
\ | No newline at end of file |