import { AsyncLocalStorage } from 'async_hooks'; import { DeepPropertyType, RecursiveKeyOf } from '../types/recursive-key-of.type'; import { AnyIfNever, StringIfNever, TypeIfUndefined } from '../types/type-if-type.type'; import { ClsContextOptions, ClsStore } from './cls.options'; export declare class ClsService { private readonly als; constructor(als: AsyncLocalStorage); /** * Set (or overrides) a value on the CLS context. * @param key the key * @param value the value to set */ set = any, P extends DeepPropertyType = any>(key: StringIfNever | keyof ClsStore, value: AnyIfNever

): void; /** * Set a value on the CLS context if it doesn't already exist * @param key the key * @param value the value to set * @returns `true` if value vas set, `false` if it existed before */ setIfUndefined = any, P extends DeepPropertyType = any>(key: StringIfNever | keyof ClsStore, value: AnyIfNever

): boolean; /** * Retrieve the whole CLS context * @returns the value stored under the key or undefined */ get(): AnyIfNever; /** * Retrieve a value from the CLS context by key. * @param key the key from which to retrieve the value, returns the whole context if ommited * @returns the value stored under the key or undefined */ get = any, P = DeepPropertyType>(key?: StringIfNever | keyof ClsStore): TypeIfUndefined>, R>; /** * Check if a key is in the CLS context * @param key the key to check * @returns true if the key is in the CLS context */ has = any>(key: StringIfNever | keyof ClsStore): boolean; /** * Retrieve the request ID (a shorthand for `cls.get(CLS_ID)`) * @returns the request ID or undefined */ getId(): string; /** * Run the callback with a shared CLS context. * @returns whatever the callback returns */ run(callback: () => T): T; run(options: ClsContextOptions, callback: () => T): T; /** * Run the callbacks with a new CLS context. * * @param store the default context contents * @param callback function to run * @returns whatever the callback returns */ runWith(store: S, callback: () => T): T; /** * Run any following code with a shared CLS context. */ enter(): void; enter(options: ClsContextOptions): void; /** * Run any following code with a shared ClS context * @param store the default context contents */ enterWith(store?: S): void; /** * Run the callback outside of a shared CLS context * @param callback function to run * @returns whatever the callback returns */ exit(callback: () => T): T; /** * Whether the current code runs within an active CLS context. * @returns true if a CLS context is active */ isActive(): boolean; /** * Accessors for getting or setting instances of Proxy providers * in the CLS context. */ readonly proxy: ClsProxyAccessors; } declare class ClsProxyAccessors { private readonly cls; constructor(cls: ClsService); /** * Retrieve a Proxy provider from the CLS context * based on its injection token. */ get(proxyToken: string | symbol): T; get(proxyToken: new (...args: any) => T): T; /** * Replace an instance of a Proxy provider in the CLS context * based on its injection token. */ set(proxyToken: string | symbol, value: T): void; set(proxyToken: new (...args: any) => T, value: T): void; /** * Use to manually trigger resolution of Proxy Providers * 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. */ resolve(proxyTokens?: any[]): Promise; } export {}; //# sourceMappingURL=cls.service.d.ts.map