nestjs-cls
Advanced tools
Comparing version 4.2.1 to 4.3.0
@@ -94,5 +94,8 @@ /// <reference types="node" /> | ||
* in case `resolveProxyProviders` is not enabled in the enhancer. | ||
* | ||
* @param proxyTokens An optional array of Proxy Provider injection tokens | ||
* to resolve. If not supplied, resolves all registered proxy providers. | ||
*/ | ||
resolveProxyProviders(): Promise<void>; | ||
resolveProxyProviders(proxyTokens?: any[]): Promise<void>; | ||
initializePlugins(): Promise<void>; | ||
} |
@@ -167,8 +167,14 @@ "use strict"; | ||
* in case `resolveProxyProviders` is not enabled in the enhancer. | ||
* | ||
* @param proxyTokens An optional array of Proxy Provider injection tokens | ||
* to resolve. If not supplied, resolves all registered proxy providers. | ||
*/ | ||
async resolveProxyProviders() { | ||
async resolveProxyProviders(proxyTokens) { | ||
// Workaround for a circular dep | ||
// TODO: This should be untangled and cleaned up | ||
const { ProxyProviderManager } = await Promise.resolve().then(() => __importStar(require('./proxy-provider/proxy-provider-manager'))); | ||
await ProxyProviderManager.resolveProxyProviders(); | ||
const proxySymbols = proxyTokens | ||
? proxyTokens.map(get_proxy_provider_symbol_1.getProxyProviderSymbol) | ||
: []; | ||
await ProxyProviderManager.resolveProxyProviders(proxySymbols); | ||
} | ||
@@ -175,0 +181,0 @@ async initializePlugins() { |
@@ -10,3 +10,3 @@ import { FactoryProvider, ValueProvider } from '@nestjs/common'; | ||
private static createProxy; | ||
static resolveProxyProviders(): Promise<void>; | ||
static resolveProxyProviders(providerSymbols?: symbol[]): Promise<void>; | ||
private static resolveProxyProvider; | ||
@@ -13,0 +13,0 @@ private static resolveProxyClassProvider; |
@@ -93,4 +93,7 @@ "use strict"; | ||
} | ||
static async resolveProxyProviders() { | ||
const promises = [...this.proxyProviderMap.keys()].map((providerSymbol) => this.resolveProxyProvider(providerSymbol)); | ||
static async resolveProxyProviders(providerSymbols) { | ||
const providerSymbolsToResolve = (providerSymbols === null || providerSymbols === void 0 ? void 0 : providerSymbols.length) | ||
? providerSymbols | ||
: Array.from(this.proxyProviderMap.keys()); | ||
const promises = providerSymbolsToResolve.map((providerSymbol) => this.resolveProxyProvider(providerSymbol)); | ||
await Promise.all(promises); | ||
@@ -104,2 +107,5 @@ } | ||
const provider = this.proxyProviderMap.get(providerSymbol); | ||
if (!provider) { | ||
throw proxy_provider_exceptions_1.ProxyProviderNotRegisteredException.create(providerSymbol); | ||
} | ||
if ((0, proxy_provider_functions_1.isProxyClassProvider)(provider)) { | ||
@@ -106,0 +112,0 @@ await this.resolveProxyClassProvider(providerSymbol, provider); |
@@ -13,1 +13,5 @@ import { Type } from '@nestjs/common'; | ||
} | ||
export declare class ProxyProviderNotRegisteredException extends Error { | ||
name: string; | ||
static create(providerSymbol: symbol): ProxyProviderNotRegisteredException; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ProxyProviderNotDecoratedException = exports.UnknownProxyDependenciesException = void 0; | ||
exports.ProxyProviderNotRegisteredException = exports.ProxyProviderNotDecoratedException = exports.UnknownProxyDependenciesException = void 0; | ||
class UnknownProxyDependenciesException extends Error { | ||
@@ -19,3 +19,3 @@ constructor() { | ||
const message = this.composeMessage(Provider.name, foundParams.join(', '), notFoundParamName, notFoundParamIndex); | ||
return new UnknownProxyDependenciesException(message); | ||
return new this(message); | ||
} | ||
@@ -44,6 +44,17 @@ static extractDependencyParams(error) { | ||
const message = `Cannot create a Proxy provider for ${Provider.name}. The class must be explicitly decorated with the @InjectableProxy() decorator to distinguish it from a regular provider.`; | ||
return new ProxyProviderNotDecoratedException(message); | ||
return new this(message); | ||
} | ||
} | ||
exports.ProxyProviderNotDecoratedException = ProxyProviderNotDecoratedException; | ||
class ProxyProviderNotRegisteredException extends Error { | ||
constructor() { | ||
super(...arguments); | ||
this.name = ProxyProviderNotRegisteredException.name; | ||
} | ||
static create(providerSymbol) { | ||
const message = `Cannot resolve a Proxy provider for symbol "${providerSymbol.description}", because it was not registered using "ClsModule.forFeature()" or "ClsModule.forFeatureAsync()".`; | ||
return new this(message); | ||
} | ||
} | ||
exports.ProxyProviderNotRegisteredException = ProxyProviderNotRegisteredException; | ||
//# sourceMappingURL=proxy-provider.exceptions.js.map |
{ | ||
"name": "nestjs-cls", | ||
"version": "4.2.1", | ||
"version": "4.3.0", | ||
"description": "A continuation-local storage module compatible with NestJS's dependency injection.", | ||
@@ -5,0 +5,0 @@ "author": "papooch", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
88371
1929