Initial commit - Event Planner application
This commit is contained in:
93
node_modules/@nestjs/common/module-utils/configurable-module.builder.d.ts
generated
vendored
Normal file
93
node_modules/@nestjs/common/module-utils/configurable-module.builder.d.ts
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
import { DynamicModule } from '../interfaces';
|
||||
import { Logger } from '../services/logger.service';
|
||||
import { DEFAULT_FACTORY_CLASS_METHOD_KEY, DEFAULT_METHOD_KEY } from './constants';
|
||||
import { ConfigurableModuleHost } from './interfaces';
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
export interface ConfigurableModuleBuilderOptions {
|
||||
/**
|
||||
* Specifies what injection token should be used for the module options provider.
|
||||
* By default, an auto-generated UUID will be used.
|
||||
*/
|
||||
optionsInjectionToken?: string | symbol;
|
||||
/**
|
||||
* By default, an UUID will be used as a module options provider token.
|
||||
* Explicitly specifying the "moduleName" will instruct the "ConfigurableModuleBuilder"
|
||||
* to use a more descriptive provider token.
|
||||
*
|
||||
* For example, `moduleName: "Cache"` will auto-generate the provider token: "CACHE_MODULE_OPTIONS".
|
||||
*/
|
||||
moduleName?: string;
|
||||
/**
|
||||
* Indicates whether module should always be "transient" - meaning,
|
||||
* every time you call the static method to construct a dynamic module,
|
||||
* regardless of what arguments you pass in, a new "unique" module will be created.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
alwaysTransient?: boolean;
|
||||
}
|
||||
/**
|
||||
* Factory that lets you create configurable modules and
|
||||
* provides a way to reduce the majority of dynamic module boilerplate.
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export declare class ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey extends string = typeof DEFAULT_METHOD_KEY, FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY, ExtraModuleDefinitionOptions = {}> {
|
||||
protected readonly options: ConfigurableModuleBuilderOptions;
|
||||
protected staticMethodKey: StaticMethodKey;
|
||||
protected factoryClassMethodKey: FactoryClassMethodKey;
|
||||
protected extras: ExtraModuleDefinitionOptions;
|
||||
protected transformModuleDefinition: (definition: DynamicModule, extraOptions: ExtraModuleDefinitionOptions) => DynamicModule;
|
||||
protected readonly logger: Logger;
|
||||
constructor(options?: ConfigurableModuleBuilderOptions, parentBuilder?: ConfigurableModuleBuilder<ModuleOptions>);
|
||||
/**
|
||||
* Registers the "extras" object (a set of extra options that can be used to modify the dynamic module definition).
|
||||
* Values you specify within the "extras" object will be used as default values (that can be overridden by module consumers).
|
||||
*
|
||||
* This method also applies the so-called "module definition transform function" that takes the auto-generated
|
||||
* dynamic module object ("DynamicModule") and the actual consumer "extras" object as input parameters.
|
||||
* The "extras" object consists of values explicitly specified by module consumers and default values.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* .setExtras<{ isGlobal?: boolean }>({ isGlobal: false }, (definition, extras) =>
|
||||
* ({ ...definition, global: extras.isGlobal })
|
||||
* )
|
||||
* ```
|
||||
*/
|
||||
setExtras<ExtraModuleDefinitionOptions>(extras: ExtraModuleDefinitionOptions, transformDefinition?: (definition: DynamicModule, extras: ExtraModuleDefinitionOptions) => DynamicModule): ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
||||
/**
|
||||
* Dynamic modules must expose public static methods that let you pass in
|
||||
* configuration parameters (control the module's behavior from the outside).
|
||||
* Some frequently used names that you may have seen in other modules are:
|
||||
* "forRoot", "forFeature", "register", "configure".
|
||||
*
|
||||
* This method "setClassMethodName" lets you specify the name of the
|
||||
* method that will be auto-generated.
|
||||
*
|
||||
* @param key name of the method
|
||||
*/
|
||||
setClassMethodName<StaticMethodKey extends string>(key: StaticMethodKey): ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
||||
/**
|
||||
* Asynchronously configured modules (that rely on other modules, i.e. "ConfigModule")
|
||||
* let you pass the configuration factory class that will be registered and instantiated as a provider.
|
||||
* This provider then will be used to retrieve the module's configuration. To provide the configuration,
|
||||
* the corresponding factory method must be implemented.
|
||||
*
|
||||
* This method ("setFactoryMethodName") lets you control what method name will have to be
|
||||
* implemented by the config factory (default is "create").
|
||||
*
|
||||
* @param key name of the method
|
||||
*/
|
||||
setFactoryMethodName<FactoryClassMethodKey extends string>(key: FactoryClassMethodKey): ConfigurableModuleBuilder<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
||||
/**
|
||||
* Returns an object consisting of multiple properties that lets you
|
||||
* easily construct dynamic configurable modules. See "ConfigurableModuleHost" interface for more details.
|
||||
*/
|
||||
build(): ConfigurableModuleHost<ModuleOptions, StaticMethodKey, FactoryClassMethodKey, ExtraModuleDefinitionOptions>;
|
||||
private constructInjectionTokenString;
|
||||
private createConfigurableModuleCls;
|
||||
private createTypeProxy;
|
||||
}
|
||||
219
node_modules/@nestjs/common/module-utils/configurable-module.builder.js
generated
vendored
Normal file
219
node_modules/@nestjs/common/module-utils/configurable-module.builder.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ConfigurableModuleBuilder = void 0;
|
||||
const logger_service_1 = require("../services/logger.service");
|
||||
const random_string_generator_util_1 = require("../utils/random-string-generator.util");
|
||||
const constants_1 = require("./constants");
|
||||
const utils_1 = require("./utils");
|
||||
/**
|
||||
* Factory that lets you create configurable modules and
|
||||
* provides a way to reduce the majority of dynamic module boilerplate.
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
class ConfigurableModuleBuilder {
|
||||
constructor(options = {}, parentBuilder) {
|
||||
this.options = options;
|
||||
this.logger = new logger_service_1.Logger(ConfigurableModuleBuilder.name);
|
||||
if (parentBuilder) {
|
||||
this.staticMethodKey = parentBuilder.staticMethodKey;
|
||||
this.factoryClassMethodKey =
|
||||
parentBuilder.factoryClassMethodKey;
|
||||
this.transformModuleDefinition =
|
||||
parentBuilder.transformModuleDefinition;
|
||||
this.extras = parentBuilder.extras;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Registers the "extras" object (a set of extra options that can be used to modify the dynamic module definition).
|
||||
* Values you specify within the "extras" object will be used as default values (that can be overridden by module consumers).
|
||||
*
|
||||
* This method also applies the so-called "module definition transform function" that takes the auto-generated
|
||||
* dynamic module object ("DynamicModule") and the actual consumer "extras" object as input parameters.
|
||||
* The "extras" object consists of values explicitly specified by module consumers and default values.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* .setExtras<{ isGlobal?: boolean }>({ isGlobal: false }, (definition, extras) =>
|
||||
* ({ ...definition, global: extras.isGlobal })
|
||||
* )
|
||||
* ```
|
||||
*/
|
||||
setExtras(extras, transformDefinition = def => def) {
|
||||
const builder = new ConfigurableModuleBuilder(this.options, this);
|
||||
builder.extras = extras;
|
||||
builder.transformModuleDefinition = transformDefinition;
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Dynamic modules must expose public static methods that let you pass in
|
||||
* configuration parameters (control the module's behavior from the outside).
|
||||
* Some frequently used names that you may have seen in other modules are:
|
||||
* "forRoot", "forFeature", "register", "configure".
|
||||
*
|
||||
* This method "setClassMethodName" lets you specify the name of the
|
||||
* method that will be auto-generated.
|
||||
*
|
||||
* @param key name of the method
|
||||
*/
|
||||
setClassMethodName(key) {
|
||||
const builder = new ConfigurableModuleBuilder(this.options, this);
|
||||
builder.staticMethodKey = key;
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Asynchronously configured modules (that rely on other modules, i.e. "ConfigModule")
|
||||
* let you pass the configuration factory class that will be registered and instantiated as a provider.
|
||||
* This provider then will be used to retrieve the module's configuration. To provide the configuration,
|
||||
* the corresponding factory method must be implemented.
|
||||
*
|
||||
* This method ("setFactoryMethodName") lets you control what method name will have to be
|
||||
* implemented by the config factory (default is "create").
|
||||
*
|
||||
* @param key name of the method
|
||||
*/
|
||||
setFactoryMethodName(key) {
|
||||
const builder = new ConfigurableModuleBuilder(this.options, this);
|
||||
builder.factoryClassMethodKey = key;
|
||||
return builder;
|
||||
}
|
||||
/**
|
||||
* Returns an object consisting of multiple properties that lets you
|
||||
* easily construct dynamic configurable modules. See "ConfigurableModuleHost" interface for more details.
|
||||
*/
|
||||
build() {
|
||||
this.staticMethodKey ??= constants_1.DEFAULT_METHOD_KEY;
|
||||
this.factoryClassMethodKey ??=
|
||||
constants_1.DEFAULT_FACTORY_CLASS_METHOD_KEY;
|
||||
this.options.optionsInjectionToken ??= this.options.moduleName
|
||||
? this.constructInjectionTokenString()
|
||||
: (0, utils_1.generateOptionsInjectionToken)();
|
||||
this.transformModuleDefinition ??= definition => definition;
|
||||
return {
|
||||
ConfigurableModuleClass: this.createConfigurableModuleCls(),
|
||||
MODULE_OPTIONS_TOKEN: this.options.optionsInjectionToken,
|
||||
ASYNC_OPTIONS_TYPE: this.createTypeProxy('ASYNC_OPTIONS_TYPE'),
|
||||
OPTIONS_TYPE: this.createTypeProxy('OPTIONS_TYPE'),
|
||||
};
|
||||
}
|
||||
constructInjectionTokenString() {
|
||||
const moduleNameInSnakeCase = this.options
|
||||
.moduleName.trim()
|
||||
.split(/(?=[A-Z])/)
|
||||
.join('_')
|
||||
.toUpperCase();
|
||||
return `${moduleNameInSnakeCase}_MODULE_OPTIONS`;
|
||||
}
|
||||
createConfigurableModuleCls() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const self = this;
|
||||
const asyncMethodKey = this.staticMethodKey + constants_1.ASYNC_METHOD_SUFFIX;
|
||||
class InternalModuleClass {
|
||||
static [self.staticMethodKey](options) {
|
||||
const providers = [
|
||||
{
|
||||
provide: self.options.optionsInjectionToken,
|
||||
useValue: this.omitExtras(options, self.extras),
|
||||
},
|
||||
];
|
||||
if (self.options.alwaysTransient) {
|
||||
providers.push({
|
||||
provide: constants_1.CONFIGURABLE_MODULE_ID,
|
||||
useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
|
||||
});
|
||||
}
|
||||
return self.transformModuleDefinition({
|
||||
module: this,
|
||||
providers,
|
||||
}, {
|
||||
...self.extras,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
static [asyncMethodKey](options) {
|
||||
const providers = this.createAsyncProviders(options);
|
||||
if (self.options.alwaysTransient) {
|
||||
providers.push({
|
||||
provide: constants_1.CONFIGURABLE_MODULE_ID,
|
||||
useValue: (0, random_string_generator_util_1.randomStringGenerator)(),
|
||||
});
|
||||
}
|
||||
return self.transformModuleDefinition({
|
||||
module: this,
|
||||
imports: options.imports || [],
|
||||
providers,
|
||||
}, {
|
||||
...self.extras,
|
||||
...this.extractExtrasFromAsyncOptions(options, self.extras),
|
||||
});
|
||||
}
|
||||
static omitExtras(input, extras) {
|
||||
if (!extras) {
|
||||
return input;
|
||||
}
|
||||
const moduleOptions = {};
|
||||
const extrasKeys = Object.keys(extras);
|
||||
Object.keys(input)
|
||||
.filter(key => !extrasKeys.includes(key))
|
||||
.forEach(key => {
|
||||
moduleOptions[key] = input[key];
|
||||
});
|
||||
return moduleOptions;
|
||||
}
|
||||
static extractExtrasFromAsyncOptions(input, extras) {
|
||||
if (!extras) {
|
||||
return {};
|
||||
}
|
||||
const extrasOptions = {};
|
||||
Object.keys(input)
|
||||
.filter(key => !constants_1.ASYNC_OPTIONS_METADATA_KEYS.includes(key))
|
||||
.forEach(key => {
|
||||
extrasOptions[key] = input[key];
|
||||
});
|
||||
return extrasOptions;
|
||||
}
|
||||
static createAsyncProviders(options) {
|
||||
if (options.useExisting || options.useFactory) {
|
||||
if (options.inject && options.provideInjectionTokensFrom) {
|
||||
return [
|
||||
this.createAsyncOptionsProvider(options),
|
||||
...(0, utils_1.getInjectionProviders)(options.provideInjectionTokensFrom, options.inject),
|
||||
];
|
||||
}
|
||||
return [this.createAsyncOptionsProvider(options)];
|
||||
}
|
||||
return [
|
||||
this.createAsyncOptionsProvider(options),
|
||||
{
|
||||
provide: options.useClass,
|
||||
useClass: options.useClass,
|
||||
},
|
||||
];
|
||||
}
|
||||
static createAsyncOptionsProvider(options) {
|
||||
if (options.useFactory) {
|
||||
return {
|
||||
provide: self.options.optionsInjectionToken,
|
||||
useFactory: options.useFactory,
|
||||
inject: options.inject || [],
|
||||
};
|
||||
}
|
||||
return {
|
||||
provide: self.options.optionsInjectionToken,
|
||||
useFactory: async (optionsFactory) => await optionsFactory[self.factoryClassMethodKey](),
|
||||
inject: [options.useExisting || options.useClass],
|
||||
};
|
||||
}
|
||||
}
|
||||
return InternalModuleClass;
|
||||
}
|
||||
createTypeProxy(typeName) {
|
||||
const proxy = new Proxy({}, {
|
||||
get: () => {
|
||||
throw new Error(`"${typeName}" is not supposed to be used as a value.`);
|
||||
},
|
||||
});
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
exports.ConfigurableModuleBuilder = ConfigurableModuleBuilder;
|
||||
9
node_modules/@nestjs/common/module-utils/constants.d.ts
generated
vendored
Normal file
9
node_modules/@nestjs/common/module-utils/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export declare const DEFAULT_METHOD_KEY = "register";
|
||||
export declare const DEFAULT_FACTORY_CLASS_METHOD_KEY = "create";
|
||||
export declare const ASYNC_METHOD_SUFFIX = "Async";
|
||||
export declare const CONFIGURABLE_MODULE_ID = "CONFIGURABLE_MODULE_ID";
|
||||
/**
|
||||
* List of keys that are specific to ConfigurableModuleAsyncOptions
|
||||
* and should be excluded when extracting user-defined extras.
|
||||
*/
|
||||
export declare const ASYNC_OPTIONS_METADATA_KEYS: readonly ["useFactory", "useClass", "useExisting", "inject", "imports", "provideInjectionTokensFrom"];
|
||||
19
node_modules/@nestjs/common/module-utils/constants.js
generated
vendored
Normal file
19
node_modules/@nestjs/common/module-utils/constants.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ASYNC_OPTIONS_METADATA_KEYS = exports.CONFIGURABLE_MODULE_ID = exports.ASYNC_METHOD_SUFFIX = exports.DEFAULT_FACTORY_CLASS_METHOD_KEY = exports.DEFAULT_METHOD_KEY = void 0;
|
||||
exports.DEFAULT_METHOD_KEY = 'register';
|
||||
exports.DEFAULT_FACTORY_CLASS_METHOD_KEY = 'create';
|
||||
exports.ASYNC_METHOD_SUFFIX = 'Async';
|
||||
exports.CONFIGURABLE_MODULE_ID = 'CONFIGURABLE_MODULE_ID';
|
||||
/**
|
||||
* List of keys that are specific to ConfigurableModuleAsyncOptions
|
||||
* and should be excluded when extracting user-defined extras.
|
||||
*/
|
||||
exports.ASYNC_OPTIONS_METADATA_KEYS = [
|
||||
'useFactory',
|
||||
'useClass',
|
||||
'useExisting',
|
||||
'inject',
|
||||
'imports',
|
||||
'provideInjectionTokensFrom',
|
||||
];
|
||||
2
node_modules/@nestjs/common/module-utils/index.d.ts
generated
vendored
Normal file
2
node_modules/@nestjs/common/module-utils/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './configurable-module.builder';
|
||||
export * from './interfaces';
|
||||
5
node_modules/@nestjs/common/module-utils/index.js
generated
vendored
Normal file
5
node_modules/@nestjs/common/module-utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./configurable-module.builder"), exports);
|
||||
tslib_1.__exportStar(require("./interfaces"), exports);
|
||||
42
node_modules/@nestjs/common/module-utils/interfaces/configurable-module-async-options.interface.d.ts
generated
vendored
Normal file
42
node_modules/@nestjs/common/module-utils/interfaces/configurable-module-async-options.interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
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
|
||||
* module.
|
||||
*/
|
||||
useFactory?: (...args: any[]) => 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[];
|
||||
}
|
||||
2
node_modules/@nestjs/common/module-utils/interfaces/configurable-module-async-options.interface.js
generated
vendored
Normal file
2
node_modules/@nestjs/common/module-utils/interfaces/configurable-module-async-options.interface.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
13
node_modules/@nestjs/common/module-utils/interfaces/configurable-module-cls.interface.d.ts
generated
vendored
Normal file
13
node_modules/@nestjs/common/module-utils/interfaces/configurable-module-cls.interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { DynamicModule } from '../../interfaces';
|
||||
import { DEFAULT_FACTORY_CLASS_METHOD_KEY, DEFAULT_METHOD_KEY } from '../constants';
|
||||
import { ConfigurableModuleAsyncOptions } from './configurable-module-async-options.interface';
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @publicApi
|
||||
*/
|
||||
export type ConfigurableModuleCls<ModuleOptions, MethodKey extends string = typeof DEFAULT_METHOD_KEY, FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY, ExtraModuleDefinitionOptions = {}> = {
|
||||
new (): any;
|
||||
} & Record<`${MethodKey}`, (options: ModuleOptions & Partial<ExtraModuleDefinitionOptions>) => DynamicModule> & Record<`${MethodKey}Async`, (options: ConfigurableModuleAsyncOptions<ModuleOptions, FactoryClassMethodKey> & Partial<ExtraModuleDefinitionOptions>) => DynamicModule>;
|
||||
2
node_modules/@nestjs/common/module-utils/interfaces/configurable-module-cls.interface.js
generated
vendored
Normal file
2
node_modules/@nestjs/common/module-utils/interfaces/configurable-module-cls.interface.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
62
node_modules/@nestjs/common/module-utils/interfaces/configurable-module-host.interface.d.ts
generated
vendored
Normal file
62
node_modules/@nestjs/common/module-utils/interfaces/configurable-module-host.interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
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>;
|
||||
}
|
||||
2
node_modules/@nestjs/common/module-utils/interfaces/configurable-module-host.interface.js
generated
vendored
Normal file
2
node_modules/@nestjs/common/module-utils/interfaces/configurable-module-host.interface.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
3
node_modules/@nestjs/common/module-utils/interfaces/index.d.ts
generated
vendored
Normal file
3
node_modules/@nestjs/common/module-utils/interfaces/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './configurable-module-async-options.interface';
|
||||
export * from './configurable-module-cls.interface';
|
||||
export * from './configurable-module-host.interface';
|
||||
6
node_modules/@nestjs/common/module-utils/interfaces/index.js
generated
vendored
Normal file
6
node_modules/@nestjs/common/module-utils/interfaces/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./configurable-module-async-options.interface"), exports);
|
||||
tslib_1.__exportStar(require("./configurable-module-cls.interface"), exports);
|
||||
tslib_1.__exportStar(require("./configurable-module-host.interface"), exports);
|
||||
1
node_modules/@nestjs/common/module-utils/utils/generate-options-injection-token.util.d.ts
generated
vendored
Normal file
1
node_modules/@nestjs/common/module-utils/utils/generate-options-injection-token.util.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function generateOptionsInjectionToken(): string;
|
||||
8
node_modules/@nestjs/common/module-utils/utils/generate-options-injection-token.util.js
generated
vendored
Normal file
8
node_modules/@nestjs/common/module-utils/utils/generate-options-injection-token.util.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.generateOptionsInjectionToken = generateOptionsInjectionToken;
|
||||
const random_string_generator_util_1 = require("../../utils/random-string-generator.util");
|
||||
function generateOptionsInjectionToken() {
|
||||
const hash = (0, random_string_generator_util_1.randomStringGenerator)();
|
||||
return `CONFIGURABLE_MODULE_OPTIONS[${hash}]`;
|
||||
}
|
||||
8
node_modules/@nestjs/common/module-utils/utils/get-injection-providers.util.d.ts
generated
vendored
Normal file
8
node_modules/@nestjs/common/module-utils/utils/get-injection-providers.util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { FactoryProvider, Provider } from '../../interfaces';
|
||||
/**
|
||||
*
|
||||
* @param providers List of a module's providers
|
||||
* @param tokens Injection tokens needed for a useFactory function (usually the module's options' token)
|
||||
* @returns All the providers needed for the tokens' injection (searched recursively)
|
||||
*/
|
||||
export declare function getInjectionProviders(providers: Provider[], tokens: FactoryProvider['inject']): Provider[];
|
||||
35
node_modules/@nestjs/common/module-utils/utils/get-injection-providers.util.js
generated
vendored
Normal file
35
node_modules/@nestjs/common/module-utils/utils/get-injection-providers.util.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getInjectionProviders = getInjectionProviders;
|
||||
const shared_utils_1 = require("../../utils/shared.utils");
|
||||
/**
|
||||
* @param value
|
||||
* @returns `true` if value is `OptionalFactoryDependency`
|
||||
*/
|
||||
function isOptionalFactoryDependency(value) {
|
||||
return (!(0, shared_utils_1.isUndefined)(value.token) &&
|
||||
!(0, shared_utils_1.isUndefined)(value.optional) &&
|
||||
!value.prototype);
|
||||
}
|
||||
const mapInjectToTokens = (t) => isOptionalFactoryDependency(t) ? t.token : t;
|
||||
/**
|
||||
*
|
||||
* @param providers List of a module's providers
|
||||
* @param tokens Injection tokens needed for a useFactory function (usually the module's options' token)
|
||||
* @returns All the providers needed for the tokens' injection (searched recursively)
|
||||
*/
|
||||
function getInjectionProviders(providers, tokens) {
|
||||
const result = [];
|
||||
let search = tokens.map(mapInjectToTokens);
|
||||
while (search.length > 0) {
|
||||
const match = (providers ?? []).filter(p => !result.includes(p) && // this prevents circular loops and duplication
|
||||
(search.includes(p) || search.includes(p?.provide)));
|
||||
result.push(...match);
|
||||
// get injection tokens of the matched providers, if any
|
||||
search = match
|
||||
.filter(p => p?.inject)
|
||||
.flatMap(p => p.inject)
|
||||
.map(mapInjectToTokens);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
2
node_modules/@nestjs/common/module-utils/utils/index.d.ts
generated
vendored
Normal file
2
node_modules/@nestjs/common/module-utils/utils/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './generate-options-injection-token.util';
|
||||
export * from './get-injection-providers.util';
|
||||
5
node_modules/@nestjs/common/module-utils/utils/index.js
generated
vendored
Normal file
5
node_modules/@nestjs/common/module-utils/utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./generate-options-injection-token.util"), exports);
|
||||
tslib_1.__exportStar(require("./get-injection-providers.util"), exports);
|
||||
Reference in New Issue
Block a user