@nestjs-redisx/core 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +39 -2
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Type, DynamicModule, ForwardReference, InjectionToken, Provider, ModuleMetadata, OnModuleDestroy, Logger, OnModuleInit } from '@nestjs/common';
|
|
2
2
|
import { ModuleRef } from '@nestjs/core';
|
|
3
3
|
import EventEmitter from 'events';
|
|
4
4
|
import Redis, { Cluster } from 'ioredis';
|
|
@@ -139,6 +139,38 @@ interface IRedisDriver$1 {
|
|
|
139
139
|
pipeline(): unknown;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Async configuration options for plugins.
|
|
144
|
+
* Allows plugins to receive configuration from NestJS DI (e.g., ConfigService).
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* CachePlugin.registerAsync({
|
|
149
|
+
* imports: [ConfigModule],
|
|
150
|
+
* inject: [ConfigService],
|
|
151
|
+
* useFactory: (config: ConfigService) => ({
|
|
152
|
+
* l1: { maxSize: config.get('CACHE_L1_MAX_SIZE') },
|
|
153
|
+
* swr: { enabled: config.get('CACHE_SWR_ENABLED') },
|
|
154
|
+
* }),
|
|
155
|
+
* })
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
interface IPluginAsyncOptions<T = unknown> {
|
|
159
|
+
/**
|
|
160
|
+
* Optional modules to import (e.g., ConfigModule).
|
|
161
|
+
* Only needed if the injected services are not globally available.
|
|
162
|
+
*/
|
|
163
|
+
imports?: Array<Type<unknown> | DynamicModule | ForwardReference>;
|
|
164
|
+
/**
|
|
165
|
+
* Dependencies to inject into the factory function.
|
|
166
|
+
*/
|
|
167
|
+
inject?: InjectionToken[];
|
|
168
|
+
/**
|
|
169
|
+
* Factory function that returns plugin options.
|
|
170
|
+
* Receives injected dependencies as arguments.
|
|
171
|
+
*/
|
|
172
|
+
useFactory: (...args: unknown[]) => T | Promise<T>;
|
|
173
|
+
}
|
|
142
174
|
/**
|
|
143
175
|
* Base interface for all RedisX plugins.
|
|
144
176
|
*
|
|
@@ -224,6 +256,11 @@ interface IRedisXPlugin {
|
|
|
224
256
|
* Typically the main service of the plugin.
|
|
225
257
|
*/
|
|
226
258
|
getExports?(): Array<Provider | string | symbol | Type>;
|
|
259
|
+
/**
|
|
260
|
+
* Returns NestJS modules to import.
|
|
261
|
+
* Used by registerAsync() to make injected services available.
|
|
262
|
+
*/
|
|
263
|
+
getImports?(): Array<Type<unknown> | DynamicModule | ForwardReference>;
|
|
227
264
|
/**
|
|
228
265
|
* Returns NestJS controllers this plugin contributes.
|
|
229
266
|
* Controllers handle HTTP endpoints.
|
|
@@ -4914,4 +4951,4 @@ type DeepRequired<T> = {
|
|
|
4914
4951
|
[P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P];
|
|
4915
4952
|
};
|
|
4916
4953
|
|
|
4917
|
-
export { type AsyncFunction, BaseRedisDriver, CLIENT_MANAGER, CommandError, type ConnectionConfig, ConnectionError, ConnectionStatus, DEFAULT_CLIENT_NAME, DEFAULT_COMMAND_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT, DEFAULT_DRIVER_TYPE, DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT, DEFAULT_HEALTH_CHECK_INTERVAL, type DeepPartial, type DeepRequired, DriverError, DriverEvent, type DriverEventHandler, DriverFactory, type DriverType, ErrorCode, type GeoUnit, type IBaseConnectionConfig, type IClientHealthStatus, type IClientManager, type IClientMetadata, type IClientStats, type IClusterConnectionConfig, type IConnectionStats, type ICopyOptions, type IDriverFactoryOptions, type IErrorJSON, type IGeoSearchOptions, type IGeoSearchResult, type IGlobalConfig, type IHealthCheckResult, type IHealthStatus, type ILposOptions, type IManagerEventData, type IMulti, type IPipeline, type IPluginContext, type IReconnectionOptions, type IRedisClient, type IRedisClientOptions, type IRedisDriver, type IRedisDriverManager, type IRedisModuleAsyncOptions, type IRedisModuleOptions, type IRedisModuleOptionsFactory, type IRedisXPlugin, type IRestoreOptions, type IScanOptions, type ISentinelConnectionConfig, type ISetOptions, type ISingleConnectionConfig, type IStreamAddOptions, type IStreamEntry, type IStreamInfo, type IStreamPendingEntry, type IStreamPendingInfo, type IStreamReadGroupOptions, type IStreamReadOptions, type ITlsConfig, type IZRangeByScoreOptions, type IZStoreOptions, InjectRedis, IoRedisAdapter, MODULE_NAME, ManagerEvent, type ManagerEventHandler, NodeRedisAdapter, type Nullable, type Optional, PLUGIN_REGISTRY, PluginRegistryService, REDISX_CONFIG, REDISX_LOGGER, REDIS_CLIENT, REDIS_CLIENTS_INITIALIZATION, REDIS_CLIENTS_MAP, REDIS_DRIVER, REDIS_MODULE_OPTIONS, REGISTERED_PLUGINS, RedisAuthError, RedisClientManager, RedisClusterError, RedisConfigError, RedisConnectionError, RedisInvalidArgsError, RedisKeyNotFoundError, RedisMaxRetriesError, RedisModule, RedisNotConnectedError, RedisNotSupportedError, RedisOperationError, RedisOutOfMemoryError, RedisPipelineError, RedisPoolExhaustedError, RedisReadOnlyError, RedisScriptError, RedisSentinelError, RedisService, RedisTLSError, RedisTimeoutError, RedisTransactionError, RedisTypeMismatchError, RedisValidationError, RedisXError, type StreamReadResult, TimeoutError, ValidationErrorCollector, createDriver, createDrivers, detectAvailableDriver, getClientToken, getDriverToken, getErrorDomain, getRecommendedDriver, hasClass, hasExisting, hasFactory, isClusterConnection, isErrorCode, isErrorDomain, isSentinelConnection, isSingleConnection };
|
|
4954
|
+
export { type AsyncFunction, BaseRedisDriver, CLIENT_MANAGER, CommandError, type ConnectionConfig, ConnectionError, ConnectionStatus, DEFAULT_CLIENT_NAME, DEFAULT_COMMAND_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT, DEFAULT_DRIVER_TYPE, DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT, DEFAULT_HEALTH_CHECK_INTERVAL, type DeepPartial, type DeepRequired, DriverError, DriverEvent, type DriverEventHandler, DriverFactory, type DriverType, ErrorCode, type GeoUnit, type IBaseConnectionConfig, type IClientHealthStatus, type IClientManager, type IClientMetadata, type IClientStats, type IClusterConnectionConfig, type IConnectionStats, type ICopyOptions, type IDriverFactoryOptions, type IErrorJSON, type IGeoSearchOptions, type IGeoSearchResult, type IGlobalConfig, type IHealthCheckResult, type IHealthStatus, type ILposOptions, type IManagerEventData, type IMulti, type IPipeline, type IPluginAsyncOptions, type IPluginContext, type IReconnectionOptions, type IRedisClient, type IRedisClientOptions, type IRedisDriver, type IRedisDriverManager, type IRedisModuleAsyncOptions, type IRedisModuleOptions, type IRedisModuleOptionsFactory, type IRedisXPlugin, type IRestoreOptions, type IScanOptions, type ISentinelConnectionConfig, type ISetOptions, type ISingleConnectionConfig, type IStreamAddOptions, type IStreamEntry, type IStreamInfo, type IStreamPendingEntry, type IStreamPendingInfo, type IStreamReadGroupOptions, type IStreamReadOptions, type ITlsConfig, type IZRangeByScoreOptions, type IZStoreOptions, InjectRedis, IoRedisAdapter, MODULE_NAME, ManagerEvent, type ManagerEventHandler, NodeRedisAdapter, type Nullable, type Optional, PLUGIN_REGISTRY, PluginRegistryService, REDISX_CONFIG, REDISX_LOGGER, REDIS_CLIENT, REDIS_CLIENTS_INITIALIZATION, REDIS_CLIENTS_MAP, REDIS_DRIVER, REDIS_MODULE_OPTIONS, REGISTERED_PLUGINS, RedisAuthError, RedisClientManager, RedisClusterError, RedisConfigError, RedisConnectionError, RedisInvalidArgsError, RedisKeyNotFoundError, RedisMaxRetriesError, RedisModule, RedisNotConnectedError, RedisNotSupportedError, RedisOperationError, RedisOutOfMemoryError, RedisPipelineError, RedisPoolExhaustedError, RedisReadOnlyError, RedisScriptError, RedisSentinelError, RedisService, RedisTLSError, RedisTimeoutError, RedisTransactionError, RedisTypeMismatchError, RedisValidationError, RedisXError, type StreamReadResult, TimeoutError, ValidationErrorCollector, createDriver, createDrivers, detectAvailableDriver, getClientToken, getDriverToken, getErrorDomain, getRecommendedDriver, hasClass, hasExisting, hasFactory, isClusterConnection, isErrorCode, isErrorDomain, isSentinelConnection, isSingleConnection };
|
package/dist/index.js
CHANGED
|
@@ -4718,6 +4718,7 @@ var RedisModule = class {
|
|
|
4718
4718
|
const pluginProviders = [];
|
|
4719
4719
|
const pluginExports = [];
|
|
4720
4720
|
const pluginControllers = [];
|
|
4721
|
+
const pluginImports = [];
|
|
4721
4722
|
if (options.plugins && options.plugins.length > 0) {
|
|
4722
4723
|
options.plugins.forEach((plugin) => {
|
|
4723
4724
|
if (plugin.getProviders) {
|
|
@@ -4732,6 +4733,12 @@ var RedisModule = class {
|
|
|
4732
4733
|
pluginExports.push(...exports2);
|
|
4733
4734
|
}
|
|
4734
4735
|
}
|
|
4736
|
+
if (plugin.getImports) {
|
|
4737
|
+
const imports = plugin.getImports();
|
|
4738
|
+
if (Array.isArray(imports)) {
|
|
4739
|
+
pluginImports.push(...imports);
|
|
4740
|
+
}
|
|
4741
|
+
}
|
|
4735
4742
|
if (plugin.getControllers) {
|
|
4736
4743
|
const controllers = plugin.getControllers();
|
|
4737
4744
|
if (Array.isArray(controllers)) {
|
|
@@ -4744,7 +4751,7 @@ var RedisModule = class {
|
|
|
4744
4751
|
return {
|
|
4745
4752
|
module: RedisModule,
|
|
4746
4753
|
global: true,
|
|
4747
|
-
imports: [import_core.DiscoveryModule],
|
|
4754
|
+
imports: [import_core.DiscoveryModule, ...pluginImports],
|
|
4748
4755
|
// Required for plugins that scan providers (e.g., CachePlugin)
|
|
4749
4756
|
providers: [...providers, ...pluginProviders, { provide: REGISTERED_PLUGINS, useValue: plugins }, PluginRegistryService, RedisService],
|
|
4750
4757
|
controllers: pluginControllers,
|
|
@@ -4805,6 +4812,7 @@ var RedisModule = class {
|
|
|
4805
4812
|
const pluginProviders = [];
|
|
4806
4813
|
const pluginExports = [];
|
|
4807
4814
|
const pluginControllers = [];
|
|
4815
|
+
const pluginImports = [];
|
|
4808
4816
|
if (plugins.length > 0) {
|
|
4809
4817
|
plugins.forEach((plugin) => {
|
|
4810
4818
|
if (plugin.getProviders) {
|
|
@@ -4819,6 +4827,12 @@ var RedisModule = class {
|
|
|
4819
4827
|
pluginExports.push(...exports2);
|
|
4820
4828
|
}
|
|
4821
4829
|
}
|
|
4830
|
+
if (plugin.getImports) {
|
|
4831
|
+
const pluginModules = plugin.getImports();
|
|
4832
|
+
if (Array.isArray(pluginModules)) {
|
|
4833
|
+
pluginImports.push(...pluginModules);
|
|
4834
|
+
}
|
|
4835
|
+
}
|
|
4822
4836
|
if (plugin.getControllers) {
|
|
4823
4837
|
const controllers = plugin.getControllers();
|
|
4824
4838
|
if (Array.isArray(controllers)) {
|
|
@@ -4830,7 +4844,7 @@ var RedisModule = class {
|
|
|
4830
4844
|
return {
|
|
4831
4845
|
module: RedisModule,
|
|
4832
4846
|
global: true,
|
|
4833
|
-
imports: [import_core.DiscoveryModule, ...imports],
|
|
4847
|
+
imports: [import_core.DiscoveryModule, ...imports, ...pluginImports],
|
|
4834
4848
|
// DiscoveryModule required for plugins
|
|
4835
4849
|
providers: [...baseProviders, ...pluginProviders, { provide: REGISTERED_PLUGINS, useValue: plugins }, PluginRegistryService, RedisService],
|
|
4836
4850
|
controllers: pluginControllers,
|