API
This chapter describes the programmatic API of the ClsService
and the ClsModule
options.
From bec6221775786b16714e914efe415ee85c3650fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C5=A0vanda?= <46406259+Papooch@users.noreply.github.com> Date: Mon, 22 Jan 2024 18:29:04 +0100 Subject: [PATCH] Deploy website - based on 1d3cd280a33fe33693cfdbc3350311a8a12e978b --- .nojekyll | 0 404.html | 15 +- api.html | 16 +- api/module-options.html | 143 ++++++++++++++---- api/service-interface.html | 107 ++++++++++--- assets/css/styles.46bfc1df.css | 1 - assets/css/styles.bd300c91.css | 1 + assets/js/075c86f0.0a105794.js | 1 + assets/js/17896441.c5c50487.js | 1 + assets/js/17896441.ea3c4b97.js | 1 - assets/js/18c15bff.c5c7db9a.js | 1 + assets/js/1be78505.cee9dfcc.js | 1 - assets/js/2d4cceda.9ec420e4.js | 1 + assets/js/3ac8ff5d.22ee9ecc.js | 1 - assets/js/3ac8ff5d.a4c650c8.js | 1 + assets/js/3b39bba3.4068951c.js | 1 - assets/js/3b39bba3.b1845d7a.js | 1 + assets/js/471.006e7ee7.js | 1 + assets/js/49.c17c1426.js | 2 + ...LICENSE.txt => 49.c17c1426.js.LICENSE.txt} | 0 assets/js/4998a0a4.487f790a.js | 1 - assets/js/4998a0a4.8311d530.js | 1 + assets/js/4c9a797e.5a451edf.js | 1 + assets/js/4c9a797e.ac0c8500.js | 1 - assets/js/561.5fe53f02.js | 1 - assets/js/57c14adc.8d411baa.js | 1 + assets/js/57c14adc.b808beff.js | 1 - assets/js/592cbe55.9bb5699b.js | 1 + assets/js/592cbe55.e18bfa3e.js | 1 - assets/js/5e95c892.eba74bf1.js | 1 + assets/js/6212613f.4cda7fb0.js | 1 - assets/js/6212613f.570af20d.js | 1 + assets/js/67fa07c1.8b7b0bb2.js | 1 - assets/js/6bb5cc7f.b7a03c73.js | 1 + assets/js/6fbaaecb.c904afaa.js | 1 + assets/js/734.9c54f551.js | 2 - assets/js/739a1e5f.97c3a5dc.js | 1 + assets/js/75a2ce58.288a270b.js | 1 - assets/js/765.099e041d.js | 1 + assets/js/{77.6d8f1b9f.js => 807.e07e7e07.js} | 2 +- assets/js/81cbaa95.e887b585.js | 1 - assets/js/849c94ea.51e67d40.js | 1 - assets/js/86ea57e0.93a2d1c1.js | 1 - assets/js/86ea57e0.ff6330f0.js | 1 + assets/js/893.bb801cd0.js | 1 - assets/js/935f2afb.da867498.js | 1 - assets/js/935f2afb.ff295151.js | 1 + assets/js/94e5e920.1b12a2be.js | 1 - assets/js/94e5e920.d469aee9.js | 1 + assets/js/97d55a5e.1919b209.js | 1 - assets/js/97d55a5e.5ff21a4a.js | 1 + assets/js/a2c1fdb7.6caaee3d.js | 1 + assets/js/a2c1fdb7.de805607.js | 1 - assets/js/a7bd4aaa.6b9c6fa4.js | 1 + assets/js/a886e75a.d95036fe.js | 1 + assets/js/a8d12efa.0b5297db.js | 1 + assets/js/a8d12efa.ae0cc29a.js | 1 - assets/js/a94703ab.74e9a79f.js | 1 + assets/js/ae4976f8.5406cedc.js | 1 - assets/js/ae4976f8.fa94a518.js | 1 + assets/js/b09df872.558f0f47.js | 1 + assets/js/b09df872.6dc93e4a.js | 1 - assets/js/b67d68ed.2e3abcf2.js | 1 + assets/js/b787da23.6d6bf314.js | 1 + assets/js/b787da23.d6a197ad.js | 1 - assets/js/baa2f4d8.57f99fd1.js | 1 + assets/js/d459cca2.2e06c629.js | 1 - assets/js/d459cca2.51d3b722.js | 1 + assets/js/df604e10.30be9c5a.js | 1 - assets/js/df604e10.c9ad986f.js | 1 + assets/js/e2112352.413a0485.js | 1 + assets/js/e83b8e0a.c7551c54.js | 1 + assets/js/eb9c95da.97b9461c.js | 1 + assets/js/eca1a52a.c89c6ab1.js | 1 - assets/js/eca1a52a.cbfb27da.js | 1 + assets/js/ef9f7d37.246c8683.js | 1 - assets/js/ef9f7d37.a21a56ab.js | 1 + ...7469c.a8f155a8.js => effe0ec2.1d686911.js} | 2 +- assets/js/f83e606a.14966a77.js | 1 + assets/js/f83e606a.269bd854.js | 1 - assets/js/main.4229acf3.js | 2 - assets/js/main.ca4c7257.js | 2 + ...CENSE.txt => main.ca4c7257.js.LICENSE.txt} | 56 +++---- assets/js/runtime~main.4f1a7fee.js | 1 + assets/js/runtime~main.8a2e657e.js | 1 - considerations.html | 17 +-- considerations/compatibility.html | 51 +++++-- considerations/security.html | 22 +-- features-and-use-cases.html | 16 +- .../additional-cls-setup.html | 24 +-- features-and-use-cases/breakin-out-of-di.html | 16 -- .../breaking-out-of-di.html | 17 +++ features-and-use-cases/proxy-providers.html | 70 +++++++-- features-and-use-cases/request-id.html | 23 +-- .../type-safety-and-type-inference.html | 39 +++-- .../usage-outside-of-web-request.html | 20 +-- img/favicon.ico | Bin img/logo.png | Bin index.html | 47 ++++-- introduction/how-it-works.html | 17 +-- introduction/installation.html | 18 +-- introduction/quick-start.html | 41 +++-- lunr-index-1697660838110.json | 1 - lunr-index-1705944535620.json | 1 + lunr-index.json | 2 +- migration-guide.html | 16 +- migration-guide/v2x-v3x.html | 25 +-- migration-guide/v3x-v4x.html | 26 ++++ plugins.html | 23 +++ plugins/available-plugins.html | 17 +++ plugins/available-plugins/transactional.html | 86 +++++++++++ .../creating-custom-adapter.html | 14 ++ .../transactional/prisma-adapter.html | 25 +++ plugins/plugin-api.html | 17 +++ search-doc-1697660838110.json | 1 - search-doc-1705944535620.json | 1 + search-doc.json | 2 +- setting-up-cls-context.html | 22 +-- setting-up-cls-context/using-a-decorator.html | 18 +++ setting-up-cls-context/using-a-decurator.html | 16 -- setting-up-cls-context/using-a-guard.html | 26 ++-- .../using-a-middleware.html | 31 ++-- .../using-an-interceptor.html | 25 +-- setting-up-cls-context/using_cls_run.html | 16 ++ sitemap.xml | 2 +- 125 files changed, 929 insertions(+), 343 deletions(-) mode change 100755 => 100644 .nojekyll mode change 100755 => 100644 404.html mode change 100755 => 100644 api.html mode change 100755 => 100644 api/module-options.html mode change 100755 => 100644 api/service-interface.html delete mode 100755 assets/css/styles.46bfc1df.css create mode 100644 assets/css/styles.bd300c91.css create mode 100644 assets/js/075c86f0.0a105794.js create mode 100644 assets/js/17896441.c5c50487.js delete mode 100755 assets/js/17896441.ea3c4b97.js create mode 100644 assets/js/18c15bff.c5c7db9a.js delete mode 100755 assets/js/1be78505.cee9dfcc.js create mode 100644 assets/js/2d4cceda.9ec420e4.js delete mode 100755 assets/js/3ac8ff5d.22ee9ecc.js create mode 100644 assets/js/3ac8ff5d.a4c650c8.js delete mode 100755 assets/js/3b39bba3.4068951c.js create mode 100644 assets/js/3b39bba3.b1845d7a.js create mode 100644 assets/js/471.006e7ee7.js create mode 100644 assets/js/49.c17c1426.js rename assets/js/{734.9c54f551.js.LICENSE.txt => 49.c17c1426.js.LICENSE.txt} (100%) mode change 100755 => 100644 delete mode 100755 assets/js/4998a0a4.487f790a.js create mode 100644 assets/js/4998a0a4.8311d530.js create mode 100644 assets/js/4c9a797e.5a451edf.js delete mode 100755 assets/js/4c9a797e.ac0c8500.js delete mode 100755 assets/js/561.5fe53f02.js create mode 100644 assets/js/57c14adc.8d411baa.js delete mode 100755 assets/js/57c14adc.b808beff.js create mode 100644 assets/js/592cbe55.9bb5699b.js delete mode 100755 assets/js/592cbe55.e18bfa3e.js create mode 100644 assets/js/5e95c892.eba74bf1.js delete mode 100755 assets/js/6212613f.4cda7fb0.js create mode 100644 assets/js/6212613f.570af20d.js delete mode 100755 assets/js/67fa07c1.8b7b0bb2.js create mode 100644 assets/js/6bb5cc7f.b7a03c73.js create mode 100644 assets/js/6fbaaecb.c904afaa.js delete mode 100755 assets/js/734.9c54f551.js create mode 100644 assets/js/739a1e5f.97c3a5dc.js delete mode 100755 assets/js/75a2ce58.288a270b.js create mode 100644 assets/js/765.099e041d.js rename assets/js/{77.6d8f1b9f.js => 807.e07e7e07.js} (51%) mode change 100755 => 100644 delete mode 100755 assets/js/81cbaa95.e887b585.js delete mode 100755 assets/js/849c94ea.51e67d40.js delete mode 100755 assets/js/86ea57e0.93a2d1c1.js create mode 100644 assets/js/86ea57e0.ff6330f0.js delete mode 100755 assets/js/893.bb801cd0.js delete mode 100755 assets/js/935f2afb.da867498.js create mode 100644 assets/js/935f2afb.ff295151.js delete mode 100755 assets/js/94e5e920.1b12a2be.js create mode 100644 assets/js/94e5e920.d469aee9.js delete mode 100755 assets/js/97d55a5e.1919b209.js create mode 100644 assets/js/97d55a5e.5ff21a4a.js create mode 100644 assets/js/a2c1fdb7.6caaee3d.js delete mode 100755 assets/js/a2c1fdb7.de805607.js create mode 100644 assets/js/a7bd4aaa.6b9c6fa4.js create mode 100644 assets/js/a886e75a.d95036fe.js create mode 100644 assets/js/a8d12efa.0b5297db.js delete mode 100755 assets/js/a8d12efa.ae0cc29a.js create mode 100644 assets/js/a94703ab.74e9a79f.js delete mode 100755 assets/js/ae4976f8.5406cedc.js create mode 100644 assets/js/ae4976f8.fa94a518.js create mode 100644 assets/js/b09df872.558f0f47.js delete mode 100755 assets/js/b09df872.6dc93e4a.js create mode 100644 assets/js/b67d68ed.2e3abcf2.js create mode 100644 assets/js/b787da23.6d6bf314.js delete mode 100755 assets/js/b787da23.d6a197ad.js create mode 100644 assets/js/baa2f4d8.57f99fd1.js delete mode 100755 assets/js/d459cca2.2e06c629.js create mode 100644 assets/js/d459cca2.51d3b722.js delete mode 100755 assets/js/df604e10.30be9c5a.js create mode 100644 assets/js/df604e10.c9ad986f.js create mode 100644 assets/js/e2112352.413a0485.js create mode 100644 assets/js/e83b8e0a.c7551c54.js create mode 100644 assets/js/eb9c95da.97b9461c.js delete mode 100755 assets/js/eca1a52a.c89c6ab1.js create mode 100644 assets/js/eca1a52a.cbfb27da.js delete mode 100755 assets/js/ef9f7d37.246c8683.js create mode 100644 assets/js/ef9f7d37.a21a56ab.js rename assets/js/{1cd7469c.a8f155a8.js => effe0ec2.1d686911.js} (66%) mode change 100755 => 100644 create mode 100644 assets/js/f83e606a.14966a77.js delete mode 100755 assets/js/f83e606a.269bd854.js delete mode 100755 assets/js/main.4229acf3.js create mode 100644 assets/js/main.ca4c7257.js rename assets/js/{main.4229acf3.js.LICENSE.txt => main.ca4c7257.js.LICENSE.txt} (66%) mode change 100755 => 100644 create mode 100644 assets/js/runtime~main.4f1a7fee.js delete mode 100755 assets/js/runtime~main.8a2e657e.js mode change 100755 => 100644 considerations.html mode change 100755 => 100644 considerations/compatibility.html mode change 100755 => 100644 considerations/security.html mode change 100755 => 100644 features-and-use-cases.html mode change 100755 => 100644 features-and-use-cases/additional-cls-setup.html delete mode 100755 features-and-use-cases/breakin-out-of-di.html create mode 100644 features-and-use-cases/breaking-out-of-di.html mode change 100755 => 100644 features-and-use-cases/proxy-providers.html mode change 100755 => 100644 features-and-use-cases/request-id.html mode change 100755 => 100644 features-and-use-cases/type-safety-and-type-inference.html mode change 100755 => 100644 features-and-use-cases/usage-outside-of-web-request.html mode change 100755 => 100644 img/favicon.ico mode change 100755 => 100644 img/logo.png mode change 100755 => 100644 index.html mode change 100755 => 100644 introduction/how-it-works.html mode change 100755 => 100644 introduction/installation.html mode change 100755 => 100644 introduction/quick-start.html delete mode 100755 lunr-index-1697660838110.json create mode 100644 lunr-index-1705944535620.json mode change 100755 => 100644 lunr-index.json mode change 100755 => 100644 migration-guide.html mode change 100755 => 100644 migration-guide/v2x-v3x.html create mode 100644 migration-guide/v3x-v4x.html create mode 100644 plugins.html create mode 100644 plugins/available-plugins.html create mode 100644 plugins/available-plugins/transactional.html create mode 100644 plugins/available-plugins/transactional/creating-custom-adapter.html create mode 100644 plugins/available-plugins/transactional/prisma-adapter.html create mode 100644 plugins/plugin-api.html delete mode 100755 search-doc-1697660838110.json create mode 100644 search-doc-1705944535620.json mode change 100755 => 100644 search-doc.json mode change 100755 => 100644 setting-up-cls-context.html create mode 100644 setting-up-cls-context/using-a-decorator.html delete mode 100755 setting-up-cls-context/using-a-decurator.html mode change 100755 => 100644 setting-up-cls-context/using-a-guard.html mode change 100755 => 100644 setting-up-cls-context/using-a-middleware.html mode change 100755 => 100644 setting-up-cls-context/using-an-interceptor.html create mode 100644 setting-up-cls-context/using_cls_run.html mode change 100755 => 100644 sitemap.xml diff --git a/.nojekyll b/.nojekyll old mode 100755 new mode 100644 diff --git a/404.html b/404.html old mode 100755 new mode 100644 index 3d0f516..cca0bf5 --- a/404.html +++ b/404.html @@ -1,16 +1,13 @@ - +
- -We could not find what you were looking for.
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
We could not find what you were looking for.
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
This chapter describes the programmatic API of the ClsService
and the ClsModule
options.
This chapter describes the programmatic API of the ClsService
and the ClsModule
options.
The ClsModule.forRoot()
method takes the following ClsModuleOptions
:
middleware?:
ClsMiddlewareOptions
-An object with additional options for the ClsMiddleware
, see below.
guard?:
ClsGuardOptions
-An object with additional options for the ClsGuard
, see below.
interceptor?:
ClsInterceptorOptions
-An object with additional options for the ClsInterceptor
, see below.
global?:
boolean
(default false
)
-Whether to make the module global, so you do not have to import ClsModule.forFeature()
in other modules.
proxyProviders?:
Type[]
-Array of Proxy Providers that should be registered in the root module. Currently only accepts sync class Proxy providers, use ClsModule.forFeatureAsync()
for more complex use-cases.
ClsModule.forRootAsync()
is also available. You can supply the usual imports
, inject
and useFactory
parameters as usual.
Please note: If you intend to use multiple enhancers at the same time (e.g. initialize the CLS context in a middleware and then set some CLS variables additional CLS variables in an interceptor), be aware that the only the first one in the chain will set the Request ID.
The ClsModule.forFeature()
method can be used to register a Proxy Providers. The Sync method only accepts Class Proxy providers.
The ClsModule.forFeatureAsync()
method accepts either ClsModuleProxyClassProviderOptions
or ClsModuleProxyFactoryProviderOptions
that both accept these options:
provide?:
any
-Custom injection token to use for the provider. In case of a class provider, this parameter is optional, as the class reference passed to useClass
will be used by default.
imports?
any[]
-Optional list of imported modules that export the providers which are required for the provider.
extraProviders?:
Provider[]
-Optional list of additional providers that should be available to the Proxy. Useful for passing configuration from a parent dynamic module.
The ClsModuleProxyClassProviderOptions
interface further accepts:
useClass:
Type
@InjectableProxy
.The ClsModuleProxyFactoryProviderOptions
interface further accepts:
inject:
any[]
-An array of injection tokens for providers used in the useFactory
.
useFactory:
(...args: any[]) => any
-Factory function that accepts an array of providers in the order of the according tokens in the inject
array. Returns (or resolves with) an object (or a function) that will be used by this Proxy Provider.
All of the Cls{Middleware,Guard,Interceptor}Options
take the following parameters (either in ClsModuleOptions
or directly when instantiating them manually):
mount?:
boolean
(default false
)
-Whether to automatically mount the middleware/guard/interceptor to every route (not applicable when instantiating them manually)
generateId?:
boolean
(default false
)
-Whether to automatically generate a request ID. It will be available under the CLS_ID
key.
idGenerator?:
(req: Request) => string | Promise<string>
-idGenerator?:
(ctx: ExecutionContext) => string | Promise<string>
-An optional function for generating the request ID. It takes the Request
object (or the ExecutionContext
in case of a Guard or Interceptor) as an argument and (synchronously or asynchronously) returns a string. The default implementation uses Math.random()
to generate a string of 8 characters.
setup?:
(cls: ClsService, req: Request) => void | Promise<void>;
-setup?:
(cls: ClsService, ctx: ExecutionContext) => void | Promise<void>;
-Function that executes after the CLS context had been initialised. It can be used to put additional variables in the CLS context.
resolveProxyProviders?:
boolean
(default true
)
-Whether to automatically resolve Proxy Providers in the enhancer (if any are registered).
The ClsMiddlewareOptions
additionally takes the following parameters:
saveReq?:
boolean
(default true
)
-Whether to store the Request object to the context. It will be available under the CLS_REQ
key.
saveRes?:
boolean
(default false
)
-Whether to store the Response object to the context. It will be available under the CLS_RES
key
useEnterWith?:
boolean
(default false
)
-Set to true
to set up the context using a call to AsyncLocalStorage#enterWith
instead of wrapping the next()
call with the safer AsyncLocalStorage#run
. Most of the time this should not be necessary, but some frameworks are known to lose the context with run
.
The ClsModule.forRoot()
method takes the following ClsModuleOptions
:
middleware?:
ClsMiddlewareOptions
+An object with additional options for the ClsMiddleware
, see below.
guard?:
ClsGuardOptions
+An object with additional options for the ClsGuard
, see below.
interceptor?:
ClsInterceptorOptions
+An object with additional options for the ClsInterceptor
, see below.
global?:
boolean
** (default false
)
+Whether to make the module global, so you do not have to import ClsModule.forFeature()
in other modules.
proxyProviders?:
Type[]
+Array of Proxy Providers that should be registered in the root module. Currently only accepts sync class Proxy providers, use ClsModule.forFeatureAsync()
for more complex use-cases.
ClsModule.forRootAsync()
is also available. You can supply the usual imports
, inject
and useFactory
parameters as usual.
Please note: If you intend to use multiple enhancers at the same time (e.g. initialize the CLS context in a middleware and then set some additional CLS variables in an interceptor), be aware that the only the first one in the chain will set the Request ID.
The ClsModule.forFeature()
method can be used to register a Proxy Providers. The Sync method only accepts Class Proxy providers.
The ClsModule.forFeatureAsync()
method accepts either ClsModuleProxyClassProviderOptions
or ClsModuleProxyFactoryProviderOptions
that both accept these options:
provide?:
any
+Custom injection token to use for the provider. In case of a class provider, this parameter is optional, as the class reference passed to useClass
will be used by default.
imports?
any[]
+Optional list of imported modules that export the providers which are required for the provider.
extraProviders?:
Provider[]
+Optional list of additional providers that should be available to the Proxy. Useful for passing configuration from a parent dynamic module.
The ClsModuleProxyClassProviderOptions
interface further accepts:
useClass:
Type
@InjectableProxy
.The ClsModuleProxyFactoryProviderOptions
interface further accepts:
inject:
any[]
+An array of injection tokens for providers used in the useFactory
.
useFactory:
(...args: any[]) => any
+Factory function that accepts an array of providers in the order of the according tokens in the inject
array. Returns (or resolves with) an object (or a function) that will be used by this Proxy Provider.
type?:
'function' | 'object'
+Whether the Proxy Provider should be a function or an object. Defaults to 'object'
. See Caveats for more information.
All of the Cls{Middleware,Guard,Interceptor}Options
take the following parameters (either in ClsModuleOptions
or directly when instantiating them manually):
mount?:
boolean
(default false
)
+Whether to automatically mount the middleware/guard/interceptor to every route (not applicable when instantiating them manually)
generateId?:
boolean
(default false
)
+Whether to automatically generate a request ID. It will be available under the CLS_ID
key.
idGenerator?:
(req: Request) => string | Promise<string>
+idGenerator?:
(ctx: ExecutionContext) => string | Promise<string>
+An optional function for generating the request ID. It takes the Request
object (or the ExecutionContext
in case of a Guard or Interceptor) as an argument and (synchronously or asynchronously) returns a string. The default implementation uses Math.random()
to generate a string of 8 characters.
setup?:
(cls: ClsService, req: Request) => void | Promise<void>;
+setup?:
(cls: ClsService, ctx: ExecutionContext) => void | Promise<void>;
+Function that executes after the CLS context had been initialised. It can be used to put additional variables in the CLS context.
resolveProxyProviders?:
boolean
(default true
)
+Whether to automatically resolve Proxy Providers in the enhancer (if any are registered).
initializePlugins?:
boolean
(default true
)
+Whether to run the onClsInit
hook for plugins as a part of the CLS context registration (runs before resolveProxyProviders
just after setup
).
The ClsMiddlewareOptions
additionally takes the following parameters:
saveReq?:
boolean
(default true
)
+Whether to store the Request object to the context. It will be available under the CLS_REQ
key.
saveRes?:
boolean
(default false
)
+Whether to store the Response object to the context. It will be available under the CLS_RES
key
useEnterWith?:
boolean
(default false
)
+Set to true
to set up the context using a call to AsyncLocalStorage#enterWith
instead of wrapping the next()
call with the safer AsyncLocalStorage#run
. Most of the time this should not be necessary, but some frameworks are known to lose the context with run
.
The injectable ClsService
provides the following API to manipulate the cls context:
The S
type parameter is used as the type of custom ClsStore
.
get
(): S
-Get the entire CLS context.
get
(key?: keyof S): S[key]
-Retrieve a value from the CLS context by key.
getId
(): string;
-Retrieve the request ID (a shorthand for cls.get(CLS_ID)
)
has
(key: keyof S): boolean
-Check if a key is in the CLS context.
set
(key: keyof S, value: S[key]): void
-Set a value on the CLS context.
setIfUndefined
(key: keyof S, value: S[key]): void
-Set a value on the CLS context only if it hasn't been already set. Useful for ensuring idempotence if you have multiple entry points.
run
(callback: () => T): T
+
The injectable ClsService
provides the following API to manipulate the cls context:
The S
type parameter is used as the type of custom ClsStore
.
get
(): S
+Get the entire CLS context.
get
(key?: keyof S): S[key]
+Retrieve a value from the CLS context by key.
getId
(): string;
+Retrieve the request ID (a shorthand for cls.get(CLS_ID)
)
has
(key: keyof S): boolean
+Check if a key is in the CLS context.
set
(key: keyof S, value: S[key]): void
+Set a value on the CLS context.
setIfUndefined
(key: keyof S, value: S[key]): void
+Set a value on the CLS context only if it hasn't been already set. Useful for ensuring idempotence if you have multiple entry points.
run
(callback: () => T): T
run
(options: ClsContextOptions, callback: () => T): T;
-Run the callback in a shared CLS context. Optionally takes an options object as the first parameter.
runWith
(store: S, callback: () => T): T
-Run the callback in a new CLS context (while supplying the default store).
enter
(): void;
+Run the callback in a shared CLS context. Optionally takes an options object as the first parameter.
runWith
(store: S, callback: () => T): T
+Run the callback in a new CLS context (while supplying the default store).
enter
(): void;
enter
(options: ClsContextOptions): void
-Run any following code in a shared CLS context. Optionally takes an options object as the first parameter.
enterWith
(store: S): void
-Run any following code in a new CLS context (while supplying the default store).
exit
(callback: () => T): T
-Run the callback without access to a shared CLS context.
isActive
(): boolean
-Whether the current code runs within an active CLS context.
resolveProxyProviders
(): Promise<void>
-Manually trigger resolution of Proxy Providers.
The run
and enter
methods can take an additional options object with the following settings:
ifNested?:
'override' | 'inherit' | 'reuse'
override
(default) - Run the callback with an new empty context.inherit
- Run the callback with a shallow copy of the parent context.reuse
- Reuse existing context without creating a new one. All modifications to the existing context will be reflected.enterWith
(store: S): void
+Run any following code in a new CLS context (while supplying the default store).
exit
(callback: () => T): T
+Run the callback without access to a shared CLS context.
isActive
(): boolean
+Whether the current code runs within an active CLS context.
resolveProxyProviders
(): Promise<void>
+Manually trigger resolution of Proxy Providers.
initializePlugins
(): Promise<void>
+Manually trigger onClsInit
hooks of registered plugins.
The run
and enter
methods can take an additional options object with the following settings:
ifNested?:
'inherit' | 'reuse' | 'override'
inherit
(default) - Run the callback with a shallow copy of the parent context.reuse
- Reuse existing context without creating a new one. All modifications to the
+existing context will be reflected.override
- Run the callback with an new empty context.::: Note
+Until v4
, the default behavior was override
. This was changed to inherit
since v4
to make the behavior more intuitive.
:::
ifNested
option",id:"changed-default-of-ifnested-option",level:2},{value:"Changed default of resolveProxyProviders
in UseCls
decorator",id:"changed-default-of-resolveproxyproviders-in-usecls-decorator",level:2}];function l(e){const o={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",p:"p",pre:"pre",...(0,t.a)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(o.h1,{id:"v3x--v4x",children:[(0,n.jsx)(o.code,{children:"v3.x"})," \u2192 ",(0,n.jsx)(o.code,{children:"v4.x"})]}),"\n",(0,n.jsxs)(o.p,{children:["The ",(0,n.jsx)(o.code,{children:"v4"})," major version should be largely backwards compatible with ",(0,n.jsx)(o.code,{children:"v3"}),". However, breaking changes were introduced in some less-used APIs that should be mentioned."]}),"\n",(0,n.jsx)(o.h2,{id:"changed-base-type-of-proxy-providers",children:"Changed base type of Proxy Providers"}),"\n",(0,n.jsxs)(o.p,{children:["The default underlying value of ",(0,n.jsx)(o.a,{href:"/nestjs-cls/features-and-use-cases/proxy-providers",children:"Proxy Providers"})," was changed to ",(0,n.jsx)(o.code,{children:"{}"}),". This means that the ",(0,n.jsx)(o.code,{children:"typeof"})," operator will now return ",(0,n.jsx)(o.code,{children:"'object'"}),", which is more intuitive. (",(0,n.jsx)(o.a,{href:"https://github.com/Papooch/nestjs-cls/issues/82",children:"Link to original discussion"}),")"]}),"\n",(0,n.jsxs)(o.p,{children:["The use-case of using a Proxy Provider as a function is still supported, but now requires the ",(0,n.jsx)(o.code,{children:"type"})," option to be set to ",(0,n.jsx)(o.code,{children:"'function'"}),"."]}),"\n",(0,n.jsx)(o.pre,{children:(0,n.jsx)(o.code,{className:"language-ts",children:"ClsModule.forFeature({\n provide: 'class-proxy',\n useClass: SomeClass,\n});\nClsModule.forFeature({\n provide: 'function-proxy',\n useFactory: () => someFunction,\n // highlight-start\n type: 'function',\n // highlight-end\n});\n"})}),"\n",(0,n.jsx)(o.pre,{children:(0,n.jsx)(o.code,{className:"language-ts",children:"@Injectable()\nclass SomeService {\n constructor(\n @Inject('class-proxy')\n private readonly someClass: SomeClass,\n @Inject('function-proxy')\n private readonly functionProvider: () => void,\n ) {\n console.log(typeof this.someClass); // 'object'\n console.log(typeof this.functionProvider); // 'function'\n }\n}\n"})}),"\n",(0,n.jsxs)(o.h2,{id:"changed-default-of-ifnested-option",children:["Changed default of ",(0,n.jsx)(o.code,{children:"ifNested"})," option"]}),"\n",(0,n.jsxs)(o.p,{children:["The default of the ",(0,n.jsx)(o.a,{href:"/nestjs-cls/api/service-interface#clscontextoptions",children:(0,n.jsx)(o.code,{children:"ifNested"})})," option was changed from ",(0,n.jsx)(o.code,{children:"override"})," to ",(0,n.jsx)(o.code,{children:"inherit"}),", which more closely aligns with ",(0,n.jsx)(o.em,{children:"most"})," real-world use-cases."]}),"\n",(0,n.jsxs)(o.p,{children:["If you used the ",(0,n.jsx)(o.code,{children:"ClsService#run"})," method ",(0,n.jsx)(o.em,{children:"without"})," explicitly setting the ",(0,n.jsx)(o.code,{children:"ifNested"})," option, you should check if the new default behavior is compatible with your use-case and adjust accordingly."]}),"\n",(0,n.jsx)(o.pre,{children:(0,n.jsx)(o.code,{className:"language-ts",children:"this.cls.run(\n // highlight-start\n { ifNested: 'override' },\n // highlight-end\n () => {\n // ... rest of the code\n },\n);\n"})}),"\n",(0,n.jsxs)(o.h2,{id:"changed-default-of-resolveproxyproviders-in-usecls-decorator",children:["Changed default of ",(0,n.jsx)(o.code,{children:"resolveProxyProviders"})," in ",(0,n.jsx)(o.code,{children:"UseCls"})," decorator"]}),"\n",(0,n.jsxs)(o.p,{children:["This value was undocumented in ",(0,n.jsx)(o.code,{children:"v3"}),", but the default was ",(0,n.jsx)(o.code,{children:"false"}),". It was changed to ",(0,n.jsx)(o.code,{children:"true"})," in ",(0,n.jsx)(o.code,{children:"v4"})," to align with the default behavior of other enhancers."]}),"\n",(0,n.jsxs)(o.p,{children:["This change should not affect most use-cases, because you either don't use Proxy Providers at all, or you use them and therefore had to set it to ",(0,n.jsx)(o.code,{children:"true"})," anyway. The only case where this might be a breaking change is if you used the ",(0,n.jsx)(o.code,{children:"@UseCls"})," in a module where you explicitly ",(0,n.jsx)(o.em,{children:"did not"})," want to resolve Proxy Providers and therefore did not import their dependencies. In that case, you should set the ",(0,n.jsx)(o.code,{children:"resolveProxyProviders"})," option to ",(0,n.jsx)(o.code,{children:"false"})," in the decorator."]})]})}function h(e={}){const{wrapper:o}={...(0,t.a)(),...e.components};return o?(0,n.jsx)(o,{...e,children:(0,n.jsx)(l,{...e})}):l(e)}},1670:(e,o,s)=>{s.d(o,{Z:()=>d,a:()=>r});var n=s(7378);const t={},i=n.createContext(t);function r(e){const o=n.useContext(i);return n.useMemo((function(){return"function"==typeof e?e(o):{...o,...e}}),[o,e])}function d(e){let o;return o=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:r(e.components),n.createElement(i.Provider,{value:o},e.children)}}}]);
\ No newline at end of file
diff --git a/assets/js/17896441.c5c50487.js b/assets/js/17896441.c5c50487.js
new file mode 100644
index 0000000..a873c1d
--- /dev/null
+++ b/assets/js/17896441.c5c50487.js
@@ -0,0 +1 @@
+(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[918],{8135:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>$t});var s=n(7378),a=n(8836),o=n(3879),i=n(4246);const l=s.createContext(null);function c(e){let{children:t,content:n}=e;const a=function(e){return(0,s.useMemo)((()=>({metadata:e.metadata,frontMatter:e.frontMatter,assets:e.assets,contentTitle:e.contentTitle,toc:e.toc})),[e])}(n);return(0,i.jsx)(l.Provider,{value:a,children:t})}function r(){const e=(0,s.useContext)(l);if(null===e)throw new o.i6("DocProvider");return e}function d(){const{metadata:e,frontMatter:t,assets:n}=r();return(0,i.jsx)(a.d,{title:e.title,description:e.description,keywords:t.keywords,image:n.image??t.image})}var u=n(624),m=n(7980),h=n(7419),p=n(5237);function f(e){const{permalink:t,title:n,subLabel:s,isNext:a}=e;return(0,i.jsxs)(p.Z,{className:(0,u.Z)("pagination-nav__link",a?"pagination-nav__link--next":"pagination-nav__link--prev"),to:t,children:[s&&(0,i.jsx)("div",{className:"pagination-nav__sublabel",children:s}),(0,i.jsx)("div",{className:"pagination-nav__label",children:n})]})}function x(e){const{previous:t,next:n}=e;return(0,i.jsxs)("nav",{className:"pagination-nav docusaurus-mt-lg","aria-label":(0,h.I)({id:"theme.docs.paginator.navAriaLabel",message:"Docs pages",description:"The ARIA label for the docs pagination"}),children:[t&&(0,i.jsx)(f,{...t,subLabel:(0,i.jsx)(h.Z,{id:"theme.docs.paginator.previous",description:"The label used to navigate to the previous doc",children:"Previous"})}),n&&(0,i.jsx)(f,{...n,subLabel:(0,i.jsx)(h.Z,{id:"theme.docs.paginator.next",description:"The label used to navigate to the next doc",children:"Next"}),isNext:!0})]})}function b(){const{metadata:e}=r();return(0,i.jsx)(x,{previous:e.previous,next:e.next})}var g=n(9939),j=n(4924),v=n(5854),N=n(8072),C=n(2885);const k={unreleased:function(e){let{siteTitle:t,versionMetadata:n}=e;return(0,i.jsx)(h.Z,{id:"theme.docs.versions.unreleasedVersionLabel",description:"The label used to tell the user that he's browsing an unreleased doc version",values:{siteTitle:t,versionLabel:(0,i.jsx)("b",{children:n.label})},children:"This is unreleased documentation for {siteTitle} {versionLabel} version."})},unmaintained:function(e){let{siteTitle:t,versionMetadata:n}=e;return(0,i.jsx)(h.Z,{id:"theme.docs.versions.unmaintainedVersionLabel",description:"The label used to tell the user that he's browsing an unmaintained doc version",values:{siteTitle:t,versionLabel:(0,i.jsx)("b",{children:n.label})},children:"This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained."})}};function L(e){const t=k[e.versionMetadata.banner];return(0,i.jsx)(t,{...e})}function y(e){let{versionLabel:t,to:n,onClick:s}=e;return(0,i.jsx)(h.Z,{id:"theme.docs.versions.latestVersionSuggestionLabel",description:"The label used to tell the user to check the latest version",values:{versionLabel:t,latestVersionLink:(0,i.jsx)("b",{children:(0,i.jsx)(p.Z,{to:n,onClick:s,children:(0,i.jsx)(h.Z,{id:"theme.docs.versions.latestVersionLinkLabel",description:"The label used for the latest version suggestion link label",children:"latest version"})})})},children:"For up-to-date documentation, see the {latestVersionLink} ({versionLabel})."})}function B(e){let{className:t,versionMetadata:n}=e;const{siteConfig:{title:s}}=(0,g.Z)(),{pluginId:a}=(0,j.gA)({failfast:!0}),{savePreferredVersionName:o}=(0,N.J)(a),{latestDocSuggestion:l,latestVersionSuggestion:c}=(0,j.Jo)(a),r=l??(d=c).docs.find((e=>e.id===d.mainDocId));var d;return(0,i.jsxs)("div",{className:(0,u.Z)(t,v.k.docs.docVersionBanner,"alert alert--warning margin-bottom--md"),role:"alert",children:[(0,i.jsx)("div",{children:(0,i.jsx)(L,{siteTitle:s,versionMetadata:n})}),(0,i.jsx)("div",{className:"margin-top--md",children:(0,i.jsx)(y,{versionLabel:c.label,to:r.path,onClick:()=>o(c.name)})})]})}function _(e){let{className:t}=e;const n=(0,C.E)();return n.banner?(0,i.jsx)(B,{className:t,versionMetadata:n}):null}function w(e){let{className:t}=e;const n=(0,C.E)();return n.badge?(0,i.jsx)("span",{className:(0,u.Z)(t,v.k.docs.docVersionBadge,"badge badge--secondary"),children:(0,i.jsx)(h.Z,{id:"theme.docs.versionBadge.label",values:{versionLabel:n.label},children:"Version: {versionLabel}"})}):null}function Z(e){let{lastUpdatedAt:t,formattedLastUpdatedAt:n}=e;return(0,i.jsx)(h.Z,{id:"theme.lastUpdated.atDate",description:"The words used to describe on which date a page has been last updated",values:{date:(0,i.jsx)("b",{children:(0,i.jsx)("time",{dateTime:new Date(1e3*t).toISOString(),children:n})})},children:" on {date}"})}function T(e){let{lastUpdatedBy:t}=e;return(0,i.jsx)(h.Z,{id:"theme.lastUpdated.byUser",description:"The words used to describe by who the page has been last updated",values:{user:(0,i.jsx)("b",{children:t})},children:" by {user}"})}function E(e){let{lastUpdatedAt:t,formattedLastUpdatedAt:n,lastUpdatedBy:s}=e;return(0,i.jsxs)("span",{className:v.k.common.lastUpdated,children:[(0,i.jsx)(h.Z,{id:"theme.lastUpdated.lastUpdatedAtBy",description:"The sentence used to display when a page has been last updated, and by who",values:{atDate:t&&n?(0,i.jsx)(Z,{lastUpdatedAt:t,formattedLastUpdatedAt:n}):"",byUser:s?(0,i.jsx)(T,{lastUpdatedBy:s}):""},children:"Last updated{atDate}{byUser}"}),!1]})}const H={iconEdit:"iconEdit_bHB7"};function A(e){let{className:t,...n}=e;return(0,i.jsx)("svg",{fill:"currentColor",height:"20",width:"20",viewBox:"0 0 40 40",className:(0,u.Z)(H.iconEdit,t),"aria-hidden":"true",...n,children:(0,i.jsx)("g",{children:(0,i.jsx)("path",{d:"m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"})})})}function I(e){let{editUrl:t}=e;return(0,i.jsxs)(p.Z,{to:t,className:v.k.common.editThisPage,children:[(0,i.jsx)(A,{}),(0,i.jsx)(h.Z,{id:"theme.common.editThisPage",description:"The link label to edit the current page",children:"Edit this page"})]})}const M={tag:"tag_otG2",tagRegular:"tagRegular_s0E1",tagWithCount:"tagWithCount_PGyn"};function U(e){let{permalink:t,label:n,count:s}=e;return(0,i.jsxs)(p.Z,{href:t,className:(0,u.Z)(M.tag,s?M.tagWithCount:M.tagRegular),children:[n,s&&(0,i.jsx)("span",{children:s})]})}const S={tags:"tags_Ow0B",tag:"tag_DFxh"};function z(e){let{tags:t}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("b",{children:(0,i.jsx)(h.Z,{id:"theme.tags.tagsListLabel",description:"The label alongside a tag list",children:"Tags:"})}),(0,i.jsx)("ul",{className:(0,u.Z)(S.tags,"padding--none","margin-left--sm"),children:t.map((e=>{let{label:t,permalink:n}=e;return(0,i.jsx)("li",{className:S.tag,children:(0,i.jsx)(U,{label:t,permalink:n})},n)}))})]})}const R={lastUpdated:"lastUpdated_pbO5"};function O(e){return(0,i.jsx)("div",{className:(0,u.Z)(v.k.docs.docFooterTagsRow,"row margin-bottom--sm"),children:(0,i.jsx)("div",{className:"col",children:(0,i.jsx)(z,{...e})})})}function V(e){let{editUrl:t,lastUpdatedAt:n,lastUpdatedBy:s,formattedLastUpdatedAt:a}=e;return(0,i.jsxs)("div",{className:(0,u.Z)(v.k.docs.docFooterEditMetaRow,"row"),children:[(0,i.jsx)("div",{className:"col",children:t&&(0,i.jsx)(I,{editUrl:t})}),(0,i.jsx)("div",{className:(0,u.Z)("col",R.lastUpdated),children:(n||s)&&(0,i.jsx)(E,{lastUpdatedAt:n,formattedLastUpdatedAt:a,lastUpdatedBy:s})})]})}function D(){const{metadata:e}=r(),{editUrl:t,lastUpdatedAt:n,formattedLastUpdatedAt:s,lastUpdatedBy:a,tags:o}=e,l=o.length>0,c=!!(t||n||a);return l||c?(0,i.jsxs)("footer",{className:(0,u.Z)(v.k.docs.docFooter,"docusaurus-mt-lg"),children:[l&&(0,i.jsx)(O,{tags:o}),c&&(0,i.jsx)(V,{editUrl:t,lastUpdatedAt:n,lastUpdatedBy:a,formattedLastUpdatedAt:s})]}):null}var P=n(4229),W=n(9899);function $(e){const t=e.map((e=>({...e,parentIndex:-1,children:[]}))),n=Array(7).fill(-1);t.forEach(((e,t)=>{const s=n.slice(2,e.level);e.parentIndex=Math.max(...s),n[e.level]=t}));const s=[];return t.forEach((e=>{const{parentIndex:n,...a}=e;n>=0?t[n].children.push(a):s.push(a)})),s}function F(e){let{toc:t,minHeadingLevel:n,maxHeadingLevel:s}=e;return t.flatMap((e=>{const t=F({toc:e.children,minHeadingLevel:n,maxHeadingLevel:s});return function(e){return e.level>=n&&e.level<=s}(e)?[{...e,children:t}]:t}))}function q(e){const t=e.getBoundingClientRect();return t.top===t.bottom?q(e.parentNode):t}function G(e,t){let{anchorTopOffset:n}=t;const s=e.find((e=>q(e).top>=n));if(s){return function(e){return e.top>0&&e.bottom["'])(?.*?)\1/,ve=/\{(? [\d,-]+)\}/,Ne={js:{start:"\\/\\/",end:""},jsBlock:{start:"\\/\\*",end:"\\*\\/"},jsx:{start:"\\{\\s*\\/\\*",end:"\\*\\/\\s*\\}"},bash:{start:"#",end:""},html:{start:"\x3c!--",end:"--\x3e"}},Ce={...Ne,lua:{start:"--",end:""},wasm:{start:"\\;\\;",end:""},tex:{start:"%",end:""},vb:{start:"['\u2018\u2019]",end:""},rem:{start:"[Rr][Ee][Mm]\\b",end:""},f90:{start:"!",end:""},ml:{start:"\\(\\*",end:"\\*\\)"},cobol:{start:"\\*>",end:""}},ke=Object.keys(Ne);function Le(e,t){const n=e.map((e=>{const{start:n,end:s}=Ce[e];return`(?:${n}\\s*(${t.flatMap((e=>[e.line,e.block?.start,e.block?.end].filter(Boolean))).join("|")})\\s*${s})`})).join("|");return new RegExp(`^\\s*(?:${n})\\s*$`)}function ye(e,t){let n=e.replace(/\n$/,"");const{language:s,magicComments:a,metastring:o}=t;if(o&&ve.test(o)){const e=o.match(ve).groups.range;if(0===a.length)throw new Error(`A highlight range has been given in code block's metastring (\`\`\` ${o}), but no magic comment config is available. Docusaurus applies the first magic comment entry's className for metastring ranges.`);const t=a[0].className,s=ge()(e).filter((e=>e>0)).map((e=>[e-1,[t]]));return{lineClassNames:Object.fromEntries(s),code:n}}if(void 0===s)return{lineClassNames:{},code:n};const i=function(e,t){switch(e){case"js":case"javascript":case"ts":case"typescript":return Le(["js","jsBlock"],t);case"jsx":case"tsx":return Le(["js","jsBlock","jsx"],t);case"html":return Le(["js","jsBlock","html"],t);case"python":case"py":case"bash":return Le(["bash"],t);case"markdown":case"md":return Le(["html","jsx","bash"],t);case"tex":case"latex":case"matlab":return Le(["tex"],t);case"lua":case"haskell":case"sql":return Le(["lua"],t);case"wasm":return Le(["wasm"],t);case"vb":case"vbnet":case"vba":case"visual-basic":return Le(["vb","rem"],t);case"batch":return Le(["rem"],t);case"basic":return Le(["rem","f90"],t);case"fsharp":return Le(["js","ml"],t);case"ocaml":case"sml":return Le(["ml"],t);case"fortran":return Le(["f90"],t);case"cobol":return Le(["cobol"],t);default:return Le(ke,t)}}(s,a),l=n.split("\n"),c=Object.fromEntries(a.map((e=>[e.className,{start:0,range:""}]))),r=Object.fromEntries(a.filter((e=>e.line)).map((e=>{let{className:t,line:n}=e;return[n,t]}))),d=Object.fromEntries(a.filter((e=>e.block)).map((e=>{let{className:t,block:n}=e;return[n.start,t]}))),u=Object.fromEntries(a.filter((e=>e.block)).map((e=>{let{className:t,block:n}=e;return[n.end,t]})));for(let h=0;h void 0!==e));r[t]?c[r[t]].range+=`${h},`:d[t]?c[d[t]].start=h:u[t]&&(c[u[t]].range+=`${c[u[t]].start}-${h-1},`),l.splice(h,1)}n=l.join("\n");const m={};return Object.entries(c).forEach((e=>{let[t,{range:n}]=e;ge()(n).forEach((e=>{m[e]??=[],m[e].push(t)}))})),{lineClassNames:m,code:n}}const Be={codeBlockContainer:"codeBlockContainer_mQmQ"};function _e(e){let{as:t,...n}=e;const s=function(e){const t={color:"--prism-color",backgroundColor:"--prism-background-color"},n={};return Object.entries(e.plain).forEach((e=>{let[s,a]=e;const o=t[s];o&&"string"==typeof a&&(n[o]=a)})),n}(xe());return(0,i.jsx)(t,{...n,style:s,className:(0,u.Z)(n.className,Be.codeBlockContainer,v.k.common.codeBlock)})}const we={codeBlockContent:"codeBlockContent_D5yF",codeBlockTitle:"codeBlockTitle_x_ju",codeBlock:"codeBlock_RMoD",codeBlockStandalone:"codeBlockStandalone_wQog",codeBlockLines:"codeBlockLines_AclH",codeBlockLinesWithNumbering:"codeBlockLinesWithNumbering_O625",buttonGroup:"buttonGroup_aaMX"};function Ze(e){let{children:t,className:n}=e;return(0,i.jsx)(_e,{as:"pre",tabIndex:0,className:(0,u.Z)(we.codeBlockStandalone,"thin-scrollbar",n),children:(0,i.jsx)("code",{className:we.codeBlockLines,children:t})})}const Te={attributes:!0,characterData:!0,childList:!0,subtree:!0};function Ee(e,t){const[n,a]=(0,s.useState)(),i=(0,s.useCallback)((()=>{a(e.current?.closest("[role=tabpanel][hidden]"))}),[e,a]);(0,s.useEffect)((()=>{i()}),[i]),function(e,t,n){void 0===n&&(n=Te);const a=(0,o.zX)(t),i=(0,o.Ql)(n);(0,s.useEffect)((()=>{const t=new MutationObserver(a);return e&&t.observe(e,i),()=>t.disconnect()}),[e,a,i])}(n,(e=>{e.forEach((e=>{"attributes"===e.type&&"hidden"===e.attributeName&&(t(),i())}))}),{attributes:!0,characterData:!1,childList:!1,subtree:!1})}var He=n(6101);const Ae={codeLine:"codeLine_FAqz",codeLineNumber:"codeLineNumber_BE9Z",codeLineContent:"codeLineContent_EF2y"};function Ie(e){let{line:t,classNames:n,showLineNumbers:s,getLineProps:a,getTokenProps:o}=e;1===t.length&&"\n"===t[0].content&&(t[0].content="");const l=a({line:t,className:(0,u.Z)(n,s&&Ae.codeLine)}),c=t.map(((e,t)=>(0,i.jsx)("span",{...o({token:e,key:t})},t)));return(0,i.jsxs)("span",{...l,children:[s?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{className:Ae.codeLineNumber}),(0,i.jsx)("span",{className:Ae.codeLineContent,children:c})]}):c,(0,i.jsx)("br",{})]})}function Me(e){return(0,i.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,i.jsx)("path",{fill:"currentColor",d:"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"})})}function Ue(e){return(0,i.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,i.jsx)("path",{fill:"currentColor",d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})}const Se={copyButtonCopied:"copyButtonCopied_TYdd",copyButtonIcons:"copyButtonIcons_z5j7",copyButtonIcon:"copyButtonIcon_FoOz",copyButtonSuccessIcon:"copyButtonSuccessIcon_L0B6"};function ze(e){let{code:t,className:n}=e;const[a,o]=(0,s.useState)(!1),l=(0,s.useRef)(void 0),c=(0,s.useCallback)((()=>{!function(e,t){let{target:n=document.body}=void 0===t?{}:t;if("string"!=typeof e)throw new TypeError(`Expected parameter \`text\` to be a \`string\`, got \`${typeof e}\`.`);const s=document.createElement("textarea"),a=document.activeElement;s.value=e,s.setAttribute("readonly",""),s.style.contain="strict",s.style.position="absolute",s.style.left="-9999px",s.style.fontSize="12pt";const o=document.getSelection(),i=o.rangeCount>0&&o.getRangeAt(0);n.append(s),s.select(),s.selectionStart=0,s.selectionEnd=e.length;let l=!1;try{l=document.execCommand("copy")}catch{}s.remove(),i&&(o.removeAllRanges(),o.addRange(i)),a&&a.focus()}(t),o(!0),l.current=window.setTimeout((()=>{o(!1)}),1e3)}),[t]);return(0,s.useEffect)((()=>()=>window.clearTimeout(l.current)),[]),(0,i.jsx)("button",{type:"button","aria-label":a?(0,h.I)({id:"theme.CodeBlock.copied",message:"Copied",description:"The copied button label on code blocks"}):(0,h.I)({id:"theme.CodeBlock.copyButtonAriaLabel",message:"Copy code to clipboard",description:"The ARIA label for copy code blocks button"}),title:(0,h.I)({id:"theme.CodeBlock.copy",message:"Copy",description:"The copy button label on code blocks"}),className:(0,u.Z)("clean-btn",n,Se.copyButton,a&&Se.copyButtonCopied),onClick:c,children:(0,i.jsxs)("span",{className:Se.copyButtonIcons,"aria-hidden":"true",children:[(0,i.jsx)(Me,{className:Se.copyButtonIcon}),(0,i.jsx)(Ue,{className:Se.copyButtonSuccessIcon})]})})}function Re(e){return(0,i.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,i.jsx)("path",{fill:"currentColor",d:"M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"})})}const Oe={wordWrapButtonIcon:"wordWrapButtonIcon_HV9T",wordWrapButtonEnabled:"wordWrapButtonEnabled_XzR1"};function Ve(e){let{className:t,onClick:n,isEnabled:s}=e;const a=(0,h.I)({id:"theme.CodeBlock.wordWrapToggle",message:"Toggle word wrap",description:"The title attribute for toggle word wrapping button of code block lines"});return(0,i.jsx)("button",{type:"button",onClick:n,className:(0,u.Z)("clean-btn",t,s&&Oe.wordWrapButtonEnabled),"aria-label":a,title:a,children:(0,i.jsx)(Re,{className:Oe.wordWrapButtonIcon,"aria-hidden":"true"})})}function De(e){let{children:t,className:n="",metastring:a,title:o,showLineNumbers:l,language:c}=e;const{prism:{defaultLanguage:r,magicComments:d}}=(0,W.L)(),m=function(e){return e?.toLowerCase()}(c??function(e){const t=e.split(" ").find((e=>e.startsWith("language-")));return t?.replace(/language-/,"")}(n)??r),h=xe(),p=function(){const[e,t]=(0,s.useState)(!1),[n,a]=(0,s.useState)(!1),o=(0,s.useRef)(null),i=(0,s.useCallback)((()=>{const n=o.current.querySelector("code");e?n.removeAttribute("style"):(n.style.whiteSpace="pre-wrap",n.style.overflowWrap="anywhere"),t((e=>!e))}),[o,e]),l=(0,s.useCallback)((()=>{const{scrollWidth:e,clientWidth:t}=o.current,n=e>t||o.current.querySelector("code").hasAttribute("style");a(n)}),[o]);return Ee(o,l),(0,s.useEffect)((()=>{l()}),[e,l]),(0,s.useEffect)((()=>(window.addEventListener("resize",l,{passive:!0}),()=>{window.removeEventListener("resize",l)})),[l]),{codeBlockRef:o,isEnabled:e,isCodeScrollable:n,toggle:i}}(),f=function(e){return e?.match(je)?.groups.title??""}(a)||o,{lineClassNames:x,code:b}=ye(t,{metastring:a,language:m,magicComments:d}),g=l??function(e){return Boolean(e?.includes("showLineNumbers"))}(a);return(0,i.jsxs)(_e,{as:"div",className:(0,u.Z)(n,m&&!n.includes(`language-${m}`)&&`language-${m}`),children:[f&&(0,i.jsx)("div",{className:we.codeBlockTitle,children:f}),(0,i.jsxs)("div",{className:we.codeBlockContent,children:[(0,i.jsx)(He.y$,{theme:h,code:b,language:m??"text",children:e=>{let{className:t,style:n,tokens:s,getLineProps:a,getTokenProps:o}=e;return(0,i.jsx)("pre",{tabIndex:0,ref:p.codeBlockRef,className:(0,u.Z)(t,we.codeBlock,"thin-scrollbar"),style:n,children:(0,i.jsx)("code",{className:(0,u.Z)(we.codeBlockLines,g&&we.codeBlockLinesWithNumbering),children:s.map(((e,t)=>(0,i.jsx)(Ie,{line:e,getLineProps:a,getTokenProps:o,classNames:x[t],showLineNumbers:g},t)))})})}}),(0,i.jsxs)("div",{className:we.buttonGroup,children:[(p.isEnabled||p.isCodeScrollable)&&(0,i.jsx)(Ve,{className:we.codeButton,onClick:()=>p.toggle(),isEnabled:p.isEnabled}),(0,i.jsx)(ze,{className:we.codeButton,code:b})]})]})]})}function Pe(e){let{children:t,...n}=e;const a=(0,pe.Z)(),o=function(e){return s.Children.toArray(e).some((e=>(0,s.isValidElement)(e)))?e:Array.isArray(e)?e.join(""):e}(t),l="string"==typeof o?De:Ze;return(0,i.jsx)(l,{...n,children:o},String(a))}function We(e){return(0,i.jsx)("code",{...e})}const $e={details:"details_IpIu",isBrowser:"isBrowser_QD4r",collapsibleContent:"collapsibleContent_Fd2D"};function Fe(e){return!!e&&("SUMMARY"===e.tagName||Fe(e.parentElement))}function qe(e,t){return!!e&&(e===t||qe(e.parentElement,t))}function Ge(e){let{summary:t,children:n,...a}=e;const o=(0,pe.Z)(),l=(0,s.useRef)(null),{collapsed:c,setCollapsed:r}=(0,P.u)({initialState:!a.open}),[d,m]=(0,s.useState)(a.open),h=s.isValidElement(t)?t:(0,i.jsx)("summary",{children:t??"Details"});return(0,i.jsxs)("details",{...a,ref:l,open:d,"data-collapsed":c,className:(0,u.Z)($e.details,o&&$e.isBrowser,a.className),onMouseDown:e=>{Fe(e.target)&&e.detail>1&&e.preventDefault()},onClick:e=>{e.stopPropagation();const t=e.target;Fe(t)&&qe(t,l.current)&&(e.preventDefault(),c?(r(!1),m(!0)):r(!0))},children:[h,(0,i.jsx)(P.z,{lazy:!1,collapsed:c,disableSSRStyle:!0,onCollapseTransitionEnd:e=>{r(e),m(!e)},children:(0,i.jsx)("div",{className:$e.collapsibleContent,children:n})})]})}const Qe={details:"details_jERq"},Xe="alert alert--info";function Je(e){let{...t}=e;return(0,i.jsx)(Ge,{...t,className:(0,u.Z)(Xe,Qe.details,t.className)})}function Ye(e){const t=s.Children.toArray(e.children),n=t.find((e=>s.isValidElement(e)&&"summary"===e.type)),a=(0,i.jsx)(i.Fragment,{children:t.filter((e=>e!==n))});return(0,i.jsx)(Je,{...e,summary:n,children:a})}function Ke(e){return(0,i.jsx)(ue.Z,{...e})}const et={containsTaskList:"containsTaskList_QWGu"};function tt(e){if(void 0!==e)return(0,u.Z)(e,e?.includes("contains-task-list")&&et.containsTaskList)}const nt={img:"img_SS3x"};function st(e){const{mdxAdmonitionTitle:t,rest:n}=function(e){const t=s.Children.toArray(e),n=t.find((e=>s.isValidElement(e)&&"mdxAdmonitionTitle"===e.type)),a=t.filter((e=>e!==n)),o=n?.props.children;return{mdxAdmonitionTitle:o,rest:a.length>0?(0,i.jsx)(i.Fragment,{children:a}):null}}(e.children),a=e.title??t;return{...e,...a&&{title:a},children:n}}const at={admonition:"admonition_WCGJ",admonitionHeading:"admonitionHeading_GCBg",admonitionIcon:"admonitionIcon_L39b",admonitionContent:"admonitionContent_pbrs"};function ot(e){let{type:t,className:n,children:s}=e;return(0,i.jsx)("div",{className:(0,u.Z)(v.k.common.admonition,v.k.common.admonitionType(t),at.admonition,n),children:s})}function it(e){let{icon:t,title:n}=e;return(0,i.jsxs)("div",{className:at.admonitionHeading,children:[(0,i.jsx)("span",{className:at.admonitionIcon,children:t}),n]})}function lt(e){let{children:t}=e;return t?(0,i.jsx)("div",{className:at.admonitionContent,children:t}):null}function ct(e){const{type:t,icon:n,title:s,children:a,className:o}=e;return(0,i.jsxs)(ot,{type:t,className:o,children:[(0,i.jsx)(it,{title:s,icon:n}),(0,i.jsx)(lt,{children:a})]})}function rt(e){return(0,i.jsx)("svg",{viewBox:"0 0 14 16",...e,children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})})}const dt={icon:(0,i.jsx)(rt,{}),title:(0,i.jsx)(h.Z,{id:"theme.admonition.note",description:"The default label used for the Note admonition (:::note)",children:"note"})};function ut(e){return(0,i.jsx)(ct,{...dt,...e,className:(0,u.Z)("alert alert--secondary",e.className),children:e.children})}function mt(e){return(0,i.jsx)("svg",{viewBox:"0 0 12 16",...e,children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})})}const ht={icon:(0,i.jsx)(mt,{}),title:(0,i.jsx)(h.Z,{id:"theme.admonition.tip",description:"The default label used for the Tip admonition (:::tip)",children:"tip"})};function pt(e){return(0,i.jsx)(ct,{...ht,...e,className:(0,u.Z)("alert alert--success",e.className),children:e.children})}function ft(e){return(0,i.jsx)("svg",{viewBox:"0 0 14 16",...e,children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})})}const xt={icon:(0,i.jsx)(ft,{}),title:(0,i.jsx)(h.Z,{id:"theme.admonition.info",description:"The default label used for the Info admonition (:::info)",children:"info"})};function bt(e){return(0,i.jsx)(ct,{...xt,...e,className:(0,u.Z)("alert alert--info",e.className),children:e.children})}function gt(e){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",...e,children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})})}const jt={icon:(0,i.jsx)(gt,{}),title:(0,i.jsx)(h.Z,{id:"theme.admonition.warning",description:"The default label used for the Warning admonition (:::warning)",children:"warning"})};function vt(e){return(0,i.jsx)("svg",{viewBox:"0 0 12 16",...e,children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"})})}const Nt={icon:(0,i.jsx)(vt,{}),title:(0,i.jsx)(h.Z,{id:"theme.admonition.danger",description:"The default label used for the Danger admonition (:::danger)",children:"danger"})};const Ct={icon:(0,i.jsx)(gt,{}),title:(0,i.jsx)(h.Z,{id:"theme.admonition.caution",description:"The default label used for the Caution admonition (:::caution)",children:"caution"})};const kt={...{note:ut,tip:pt,info:bt,warning:function(e){return(0,i.jsx)(ct,{...jt,...e,className:(0,u.Z)("alert alert--warning",e.className),children:e.children})},danger:function(e){return(0,i.jsx)(ct,{...Nt,...e,className:(0,u.Z)("alert alert--danger",e.className),children:e.children})}},...{secondary:e=>(0,i.jsx)(ut,{title:"secondary",...e}),important:e=>(0,i.jsx)(bt,{title:"important",...e}),success:e=>(0,i.jsx)(pt,{title:"success",...e}),caution:function(e){return(0,i.jsx)(ct,{...Ct,...e,className:(0,u.Z)("alert alert--warning",e.className),children:e.children})}}};function Lt(e){const t=st(e),n=(s=t.type,kt[s]||(console.warn(`No admonition component found for admonition type "${s}". Using Info as fallback.`),kt.info));var s;return(0,i.jsx)(n,{...t})}const yt={Head:he.Z,details:Ye,Details:Ye,code:function(e){return function(e){return void 0!==e.children&&s.Children.toArray(e.children).every((e=>"string"==typeof e&&!e.includes("\n")))}(e)?(0,i.jsx)(We,{...e}):(0,i.jsx)(Pe,{...e})},a:function(e){return(0,i.jsx)(p.Z,{...e})},pre:function(e){return(0,i.jsx)(i.Fragment,{children:e.children})},ul:function(e){return(0,i.jsx)("ul",{...e,className:tt(e.className)})},img:function(e){return(0,i.jsx)("img",{loading:"lazy",...e,className:(t=e.className,(0,u.Z)(t,nt.img))});var t},h1:e=>(0,i.jsx)(Ke,{as:"h1",...e}),h2:e=>(0,i.jsx)(Ke,{as:"h2",...e}),h3:e=>(0,i.jsx)(Ke,{as:"h3",...e}),h4:e=>(0,i.jsx)(Ke,{as:"h4",...e}),h5:e=>(0,i.jsx)(Ke,{as:"h5",...e}),h6:e=>(0,i.jsx)(Ke,{as:"h6",...e}),admonition:Lt,mermaid:()=>null};function Bt(e){let{children:t}=e;return(0,i.jsx)(me.Z,{components:yt,children:t})}function _t(e){let{children:t}=e;const n=function(){const{metadata:e,frontMatter:t,contentTitle:n}=r();return t.hide_title||void 0!==n?null:e.title}();return(0,i.jsxs)("div",{className:(0,u.Z)(v.k.docs.docMarkdown,"markdown"),children:[n&&(0,i.jsx)("header",{children:(0,i.jsx)(ue.Z,{as:"h1",children:n})}),(0,i.jsx)(Bt,{children:t})]})}var wt=n(7470),Zt=n(6440),Tt=n(1847);function Et(e){return(0,i.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,i.jsx)("path",{d:"M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z",fill:"currentColor"})})}const Ht={breadcrumbHomeIcon:"breadcrumbHomeIcon_sfvy"};function At(){const e=(0,Tt.Z)("/");return(0,i.jsx)("li",{className:"breadcrumbs__item",children:(0,i.jsx)(p.Z,{"aria-label":(0,h.I)({id:"theme.docs.breadcrumbs.home",message:"Home page",description:"The ARIA label for the home page in the breadcrumbs"}),className:"breadcrumbs__link",href:e,children:(0,i.jsx)(Et,{className:Ht.breadcrumbHomeIcon})})})}const It={breadcrumbsContainer:"breadcrumbsContainer_T5ub"};function Mt(e){let{children:t,href:n,isLast:s}=e;const a="breadcrumbs__link";return s?(0,i.jsx)("span",{className:a,itemProp:"name",children:t}):n?(0,i.jsx)(p.Z,{className:a,href:n,itemProp:"item",children:(0,i.jsx)("span",{itemProp:"name",children:t})}):(0,i.jsx)("span",{className:a,children:t})}function Ut(e){let{children:t,active:n,index:s,addMicrodata:a}=e;return(0,i.jsxs)("li",{...a&&{itemScope:!0,itemProp:"itemListElement",itemType:"https://schema.org/ListItem"},className:(0,u.Z)("breadcrumbs__item",{"breadcrumbs__item--active":n}),children:[t,(0,i.jsx)("meta",{itemProp:"position",content:String(s+1)})]})}function St(){const e=(0,wt.s1)(),t=(0,Zt.Ns)();return e?(0,i.jsx)("nav",{className:(0,u.Z)(v.k.docs.docBreadcrumbs,It.breadcrumbsContainer),"aria-label":(0,h.I)({id:"theme.docs.breadcrumbs.navAriaLabel",message:"Breadcrumbs",description:"The ARIA label for the breadcrumbs"}),children:(0,i.jsxs)("ul",{className:"breadcrumbs",itemScope:!0,itemType:"https://schema.org/BreadcrumbList",children:[t&&(0,i.jsx)(At,{}),e.map(((t,n)=>{const s=n===e.length-1,a="category"===t.type&&t.linkUnlisted?void 0:t.href;return(0,i.jsx)(Ut,{active:s,index:n,addMicrodata:!!a,children:(0,i.jsx)(Mt,{href:a,isLast:s,children:t.label})},n)}))]})}):null}function zt(){return(0,i.jsx)(h.Z,{id:"theme.unlistedContent.title",description:"The unlisted content banner title",children:"Unlisted page"})}function Rt(){return(0,i.jsx)(h.Z,{id:"theme.unlistedContent.message",description:"The unlisted content banner message",children:"This page is unlisted. Search engines will not index it, and only users having a direct link can access it."})}function Ot(){return(0,i.jsx)(he.Z,{children:(0,i.jsx)("meta",{name:"robots",content:"noindex, nofollow"})})}function Vt(e){let{className:t}=e;return(0,i.jsx)(Lt,{type:"caution",title:(0,i.jsx)(zt,{}),className:(0,u.Z)(t,v.k.common.unlistedBanner),children:(0,i.jsx)(Rt,{})})}function Dt(e){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Ot,{}),(0,i.jsx)(Vt,{...e})]})}const Pt={docItemContainer:"docItemContainer_tjFy",docItemCol:"docItemCol_Qr34"};function Wt(e){let{children:t}=e;const n=function(){const{frontMatter:e,toc:t}=r(),n=(0,m.i)(),s=e.hide_table_of_contents,a=!s&&t.length>0;return{hidden:s,mobile:a?(0,i.jsx)(oe,{}):void 0,desktop:!a||"desktop"!==n&&"ssr"!==n?void 0:(0,i.jsx)(de,{})}}(),{metadata:{unlisted:s}}=r();return(0,i.jsxs)("div",{className:"row",children:[(0,i.jsxs)("div",{className:(0,u.Z)("col",!n.hidden&&Pt.docItemCol),children:[s&&(0,i.jsx)(Dt,{}),(0,i.jsx)(_,{}),(0,i.jsxs)("div",{className:Pt.docItemContainer,children:[(0,i.jsxs)("article",{children:[(0,i.jsx)(St,{}),(0,i.jsx)(w,{}),n.mobile,(0,i.jsx)(_t,{children:t}),(0,i.jsx)(D,{})]}),(0,i.jsx)(b,{})]})]}),n.desktop&&(0,i.jsx)("div",{className:"col col--3",children:n.desktop})]})}function $t(e){const t=`docs-doc-id-${e.content.metadata.id}`,n=e.content;return(0,i.jsx)(c,{content:e.content,children:(0,i.jsxs)(a.FG,{className:t,children:[(0,i.jsx)(d,{}),(0,i.jsx)(Wt,{children:(0,i.jsx)(n,{})})]})})}},6324:(e,t)=>{function n(e){let t,n=[];for(let s of e.split(",").map((e=>e.trim())))if(/^-?\d+$/.test(s))n.push(parseInt(s,10));else if(t=s.match(/^(-?\d+)(-|\.\.\.?|\u2025|\u2026|\u22EF)(-?\d+)$/)){let[e,s,a,o]=t;if(s&&o){s=parseInt(s),o=parseInt(o);const e=s {"use strict";n.d(t,{Z:()=>l,a:()=>i});var s=n(7378);const a={},o=s.createContext(a);function i(e){const t=s.useContext(o);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:i(e.components),s.createElement(o.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/17896441.ea3c4b97.js b/assets/js/17896441.ea3c4b97.js deleted file mode 100755 index 66f86e7..0000000 --- a/assets/js/17896441.ea3c4b97.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[918],{5318:(e,t,n)=>{"use strict";n.d(t,{Zo:()=>d,kt:()=>f});var a=n(7378);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function l(e){for(var t=1;t =0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var s=a.createContext({}),i=function(e){var t=a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):l(l({},t),e)),n},d=function(e){var t=i(e.components);return a.createElement(s.Provider,{value:t},e.children)},m="mdxType",u={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},p=a.forwardRef((function(e,t){var n=e.components,o=e.mdxType,r=e.originalType,s=e.parentName,d=c(e,["components","mdxType","originalType","parentName"]),m=i(n),p=o,f=m["".concat(s,".").concat(p)]||m[p]||u[p]||r;return n?a.createElement(f,l(l({ref:t},d),{},{components:n})):a.createElement(f,l({ref:t},d))}));function f(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var r=n.length,l=new Array(r);l[0]=p;var c={};for(var s in t)hasOwnProperty.call(t,s)&&(c[s]=t[s]);c.originalType=e,c[m]="string"==typeof e?e:o,l[1]=c;for(var i=2;i {"use strict";n.r(t),n.d(t,{default:()=>xt});var a=n(7378),o=n(8831),r=n(1763);const l=a.createContext(null);function c(e){let{children:t,content:n}=e;const o=function(e){return(0,a.useMemo)((()=>({metadata:e.metadata,frontMatter:e.frontMatter,assets:e.assets,contentTitle:e.contentTitle,toc:e.toc})),[e])}(n);return a.createElement(l.Provider,{value:o},t)}function s(){const e=(0,a.useContext)(l);if(null===e)throw new r.i6("DocProvider");return e}function i(){const{metadata:e,frontMatter:t,assets:n}=s();return a.createElement(o.d,{title:e.title,description:e.description,keywords:t.keywords,image:n.image??t.image})}var d=n(8944),m=n(8357),u=n(5773),p=n(9213),f=n(1884);function h(e){const{permalink:t,title:n,subLabel:o,isNext:r}=e;return a.createElement(f.Z,{className:(0,d.Z)("pagination-nav__link",r?"pagination-nav__link--next":"pagination-nav__link--prev"),to:t},o&&a.createElement("div",{className:"pagination-nav__sublabel"},o),a.createElement("div",{className:"pagination-nav__label"},n))}function g(e){const{previous:t,next:n}=e;return a.createElement("nav",{className:"pagination-nav docusaurus-mt-lg","aria-label":(0,p.I)({id:"theme.docs.paginator.navAriaLabel",message:"Docs pages",description:"The ARIA label for the docs pagination"})},t&&a.createElement(h,(0,u.Z)({},t,{subLabel:a.createElement(p.Z,{id:"theme.docs.paginator.previous",description:"The label used to navigate to the previous doc"},"Previous")})),n&&a.createElement(h,(0,u.Z)({},n,{subLabel:a.createElement(p.Z,{id:"theme.docs.paginator.next",description:"The label used to navigate to the next doc"},"Next"),isNext:!0})))}function b(){const{metadata:e}=s();return a.createElement(g,{previous:e.previous,next:e.next})}var v=n(353),E=n(6282),y=n(5484),k=n(4453),N=n(5611);const C={unreleased:function(e){let{siteTitle:t,versionMetadata:n}=e;return a.createElement(p.Z,{id:"theme.docs.versions.unreleasedVersionLabel",description:"The label used to tell the user that he's browsing an unreleased doc version",values:{siteTitle:t,versionLabel:a.createElement("b",null,n.label)}},"This is unreleased documentation for {siteTitle} {versionLabel} version.")},unmaintained:function(e){let{siteTitle:t,versionMetadata:n}=e;return a.createElement(p.Z,{id:"theme.docs.versions.unmaintainedVersionLabel",description:"The label used to tell the user that he's browsing an unmaintained doc version",values:{siteTitle:t,versionLabel:a.createElement("b",null,n.label)}},"This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.")}};function L(e){const t=C[e.versionMetadata.banner];return a.createElement(t,e)}function _(e){let{versionLabel:t,to:n,onClick:o}=e;return a.createElement(p.Z,{id:"theme.docs.versions.latestVersionSuggestionLabel",description:"The label used to tell the user to check the latest version",values:{versionLabel:t,latestVersionLink:a.createElement("b",null,a.createElement(f.Z,{to:n,onClick:o},a.createElement(p.Z,{id:"theme.docs.versions.latestVersionLinkLabel",description:"The label used for the latest version suggestion link label"},"latest version")))}},"For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).")}function w(e){let{className:t,versionMetadata:n}=e;const{siteConfig:{title:o}}=(0,v.Z)(),{pluginId:r}=(0,E.gA)({failfast:!0}),{savePreferredVersionName:l}=(0,k.J)(r),{latestDocSuggestion:c,latestVersionSuggestion:s}=(0,E.Jo)(r),i=c??(m=s).docs.find((e=>e.id===m.mainDocId));var m;return a.createElement("div",{className:(0,d.Z)(t,y.k.docs.docVersionBanner,"alert alert--warning margin-bottom--md"),role:"alert"},a.createElement("div",null,a.createElement(L,{siteTitle:o,versionMetadata:n})),a.createElement("div",{className:"margin-top--md"},a.createElement(_,{versionLabel:s.label,to:i.path,onClick:()=>l(s.name)})))}function T(e){let{className:t}=e;const n=(0,N.E)();return n.banner?a.createElement(w,{className:t,versionMetadata:n}):null}function B(e){let{className:t}=e;const n=(0,N.E)();return n.badge?a.createElement("span",{className:(0,d.Z)(t,y.k.docs.docVersionBadge,"badge badge--secondary")},a.createElement(p.Z,{id:"theme.docs.versionBadge.label",values:{versionLabel:n.label}},"Version: {versionLabel}")):null}function Z(e){let{lastUpdatedAt:t,formattedLastUpdatedAt:n}=e;return a.createElement(p.Z,{id:"theme.lastUpdated.atDate",description:"The words used to describe on which date a page has been last updated",values:{date:a.createElement("b",null,a.createElement("time",{dateTime:new Date(1e3*t).toISOString()},n))}}," on {date}")}function x(e){let{lastUpdatedBy:t}=e;return a.createElement(p.Z,{id:"theme.lastUpdated.byUser",description:"The words used to describe by who the page has been last updated",values:{user:a.createElement("b",null,t)}}," by {user}")}function O(e){let{lastUpdatedAt:t,formattedLastUpdatedAt:n,lastUpdatedBy:o}=e;return a.createElement("span",{className:y.k.common.lastUpdated},a.createElement(p.Z,{id:"theme.lastUpdated.lastUpdatedAtBy",description:"The sentence used to display when a page has been last updated, and by who",values:{atDate:t&&n?a.createElement(Z,{lastUpdatedAt:t,formattedLastUpdatedAt:n}):"",byUser:o?a.createElement(x,{lastUpdatedBy:o}):""}},"Last updated{atDate}{byUser}"),!1)}const H={iconEdit:"iconEdit_bHB7"};function j(e){let{className:t,...n}=e;return a.createElement("svg",(0,u.Z)({fill:"currentColor",height:"20",width:"20",viewBox:"0 0 40 40",className:(0,d.Z)(H.iconEdit,t),"aria-hidden":"true"},n),a.createElement("g",null,a.createElement("path",{d:"m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"})))}function A(e){let{editUrl:t}=e;return a.createElement("a",{href:t,target:"_blank",rel:"noreferrer noopener",className:y.k.common.editThisPage},a.createElement(j,null),a.createElement(p.Z,{id:"theme.common.editThisPage",description:"The link label to edit the current page"},"Edit this page"))}const I={tag:"tag_otG2",tagRegular:"tagRegular_s0E1",tagWithCount:"tagWithCount_PGyn"};function M(e){let{permalink:t,label:n,count:o}=e;return a.createElement(f.Z,{href:t,className:(0,d.Z)(I.tag,o?I.tagWithCount:I.tagRegular)},n,o&&a.createElement("span",null,o))}const S={tags:"tags_Ow0B",tag:"tag_DFxh"};function P(e){let{tags:t}=e;return a.createElement(a.Fragment,null,a.createElement("b",null,a.createElement(p.Z,{id:"theme.tags.tagsListLabel",description:"The label alongside a tag list"},"Tags:")),a.createElement("ul",{className:(0,d.Z)(S.tags,"padding--none","margin-left--sm")},t.map((e=>{let{label:t,permalink:n}=e;return a.createElement("li",{key:n,className:S.tag},a.createElement(M,{label:t,permalink:n}))}))))}const z={lastUpdated:"lastUpdated_pbO5"};function U(e){return a.createElement("div",{className:(0,d.Z)(y.k.docs.docFooterTagsRow,"row margin-bottom--sm")},a.createElement("div",{className:"col"},a.createElement(P,e)))}function D(e){let{editUrl:t,lastUpdatedAt:n,lastUpdatedBy:o,formattedLastUpdatedAt:r}=e;return a.createElement("div",{className:(0,d.Z)(y.k.docs.docFooterEditMetaRow,"row")},a.createElement("div",{className:"col"},t&&a.createElement(A,{editUrl:t})),a.createElement("div",{className:(0,d.Z)("col",z.lastUpdated)},(n||o)&&a.createElement(O,{lastUpdatedAt:n,formattedLastUpdatedAt:r,lastUpdatedBy:o})))}function R(){const{metadata:e}=s(),{editUrl:t,lastUpdatedAt:n,formattedLastUpdatedAt:o,lastUpdatedBy:r,tags:l}=e,c=l.length>0,i=!!(t||n||r);return c||i?a.createElement("footer",{className:(0,d.Z)(y.k.docs.docFooter,"docusaurus-mt-lg")},c&&a.createElement(U,{tags:l}),i&&a.createElement(D,{editUrl:t,lastUpdatedAt:n,lastUpdatedBy:r,formattedLastUpdatedAt:o})):null}var V=n(376),W=n(624);function F(e){const t=e.map((e=>({...e,parentIndex:-1,children:[]}))),n=Array(7).fill(-1);t.forEach(((e,t)=>{const a=n.slice(2,e.level);e.parentIndex=Math.max(...a),n[e.level]=t}));const a=[];return t.forEach((e=>{const{parentIndex:n,...o}=e;n>=0?t[n].children.push(o):a.push(o)})),a}function $(e){let{toc:t,minHeadingLevel:n,maxHeadingLevel:a}=e;return t.flatMap((e=>{const t=$({toc:e.children,minHeadingLevel:n,maxHeadingLevel:a});return function(e){return e.level>=n&&e.level<=a}(e)?[{...e,children:t}]:t}))}function q(e){const t=e.getBoundingClientRect();return t.top===t.bottom?q(e.parentNode):t}function G(e,t){let{anchorTopOffset:n}=t;const a=e.find((e=>q(e).top>=n));if(a){return function(e){return e.top>0&&e.bottom {e.current=t?0:document.querySelector(".navbar").clientHeight}),[t]),e}function X(e){const t=(0,a.useRef)(void 0),n=Q();(0,a.useEffect)((()=>{if(!e)return()=>{};const{linkClassName:a,linkActiveClassName:o,minHeadingLevel:r,maxHeadingLevel:l}=e;function c(){const e=function(e){return Array.from(document.getElementsByClassName(e))}(a),c=function(e){let{minHeadingLevel:t,maxHeadingLevel:n}=e;const a=[];for(let o=t;o<=n;o+=1)a.push(`h${o}.anchor`);return Array.from(document.querySelectorAll(a.join()))}({minHeadingLevel:r,maxHeadingLevel:l}),s=G(c,{anchorTopOffset:n.current}),i=e.find((e=>s&&s.id===function(e){return decodeURIComponent(e.href.substring(e.href.indexOf("#")+1))}(e)));e.forEach((e=>{!function(e,n){n?(t.current&&t.current!==e&&t.current.classList.remove(o),e.classList.add(o),t.current=e):e.classList.remove(o)}(e,e===i)}))}return document.addEventListener("scroll",c),document.addEventListener("resize",c),c(),()=>{document.removeEventListener("scroll",c),document.removeEventListener("resize",c)}}),[e,n])}function J(e){let{toc:t,className:n,linkClassName:o,isChild:r}=e;return t.length?a.createElement("ul",{className:r?void 0:n},t.map((e=>a.createElement("li",{key:e.id},a.createElement("a",{href:`#${e.id}`,className:o??void 0,dangerouslySetInnerHTML:{__html:e.value}}),a.createElement(J,{isChild:!0,toc:e.children,className:n,linkClassName:o}))))):null}const Y=a.memo(J);function K(e){let{toc:t,className:n="table-of-contents table-of-contents__left-border",linkClassName:o="table-of-contents__link",linkActiveClassName:r,minHeadingLevel:l,maxHeadingLevel:c,...s}=e;const i=(0,W.L)(),d=l??i.tableOfContents.minHeadingLevel,m=c??i.tableOfContents.maxHeadingLevel,p=function(e){let{toc:t,minHeadingLevel:n,maxHeadingLevel:o}=e;return(0,a.useMemo)((()=>$({toc:F(t),minHeadingLevel:n,maxHeadingLevel:o})),[t,n,o])}({toc:t,minHeadingLevel:d,maxHeadingLevel:m});return X((0,a.useMemo)((()=>{if(o&&r)return{linkClassName:o,linkActiveClassName:r,minHeadingLevel:d,maxHeadingLevel:m}}),[o,r,d,m])),a.createElement(Y,(0,u.Z)({toc:p,className:n,linkClassName:o},s))}const ee={tocCollapsibleButton:"tocCollapsibleButton_iI2p",tocCollapsibleButtonExpanded:"tocCollapsibleButtonExpanded_cHjC"};function te(e){let{collapsed:t,...n}=e;return a.createElement("button",(0,u.Z)({type:"button"},n,{className:(0,d.Z)("clean-btn",ee.tocCollapsibleButton,!t&&ee.tocCollapsibleButtonExpanded,n.className)}),a.createElement(p.Z,{id:"theme.TOCCollapsible.toggleButtonLabel",description:"The label used by the button on the collapsible TOC component"},"On this page"))}const ne={tocCollapsible:"tocCollapsible_wXna",tocCollapsibleContent:"tocCollapsibleContent_vea0",tocCollapsibleExpanded:"tocCollapsibleExpanded_BbRn"};function ae(e){let{toc:t,className:n,minHeadingLevel:o,maxHeadingLevel:r}=e;const{collapsed:l,toggleCollapsed:c}=(0,V.u)({initialState:!0});return a.createElement("div",{className:(0,d.Z)(ne.tocCollapsible,!l&&ne.tocCollapsibleExpanded,n)},a.createElement(te,{collapsed:l,onClick:c}),a.createElement(V.z,{lazy:!0,className:ne.tocCollapsibleContent,collapsed:l},a.createElement(K,{toc:t,minHeadingLevel:o,maxHeadingLevel:r})))}const oe={tocMobile:"tocMobile_Ojys"};function re(){const{toc:e,frontMatter:t}=s();return a.createElement(ae,{toc:e,minHeadingLevel:t.toc_min_heading_level,maxHeadingLevel:t.toc_max_heading_level,className:(0,d.Z)(y.k.docs.docTocMobile,oe.tocMobile)})}const le={tableOfContents:"tableOfContents_XG6w",docItemContainer:"docItemContainer_Tr6w"},ce="table-of-contents__link toc-highlight",se="table-of-contents__link--active";function ie(e){let{className:t,...n}=e;return a.createElement("div",{className:(0,d.Z)(le.tableOfContents,"thin-scrollbar",t)},a.createElement(K,(0,u.Z)({},n,{linkClassName:ce,linkActiveClassName:se})))}function de(){const{toc:e,frontMatter:t}=s();return a.createElement(ie,{toc:e,minHeadingLevel:t.toc_min_heading_level,maxHeadingLevel:t.toc_max_heading_level,className:y.k.docs.docTocDesktop})}const me={anchorWithStickyNavbar:"anchorWithStickyNavbar_JmGV",anchorWithHideOnScrollNavbar:"anchorWithHideOnScrollNavbar_pMLv"};function ue(e){let{as:t,id:n,...o}=e;const{navbar:{hideOnScroll:r}}=(0,W.L)();if("h1"===t||!n)return a.createElement(t,(0,u.Z)({},o,{id:void 0}));const l=(0,p.I)({id:"theme.common.headingLinkTitle",message:"Direct link to {heading}",description:"Title for link to heading"},{heading:"string"==typeof o.children?o.children:n});return a.createElement(t,(0,u.Z)({},o,{className:(0,d.Z)("anchor",r?me.anchorWithHideOnScrollNavbar:me.anchorWithStickyNavbar,o.className),id:n}),o.children,a.createElement(f.Z,{className:"hash-link",to:`#${n}`,"aria-label":l,title:l},"\u200b"))}var pe=n(5318),fe=n(7092);var he=n(6457),ge=n(5421);function be(){const{prism:e}=(0,W.L)(),{colorMode:t}=(0,ge.I)(),n=e.theme,a=e.darkTheme||n;return"dark"===t?a:n}var ve=n(6324),Ee=n.n(ve);const ye=/title=(? ["'])(?.*?)\1/,ke=/\{(? [\d,-]+)\}/,Ne={js:{start:"\\/\\/",end:""},jsBlock:{start:"\\/\\*",end:"\\*\\/"},jsx:{start:"\\{\\s*\\/\\*",end:"\\*\\/\\s*\\}"},bash:{start:"#",end:""},html:{start:"\x3c!--",end:"--\x3e"}};function Ce(e,t){const n=e.map((e=>{const{start:n,end:a}=Ne[e];return`(?:${n}\\s*(${t.flatMap((e=>[e.line,e.block?.start,e.block?.end].filter(Boolean))).join("|")})\\s*${a})`})).join("|");return new RegExp(`^\\s*(?:${n})\\s*$`)}function Le(e,t){let n=e.replace(/\n$/,"");const{language:a,magicComments:o,metastring:r}=t;if(r&&ke.test(r)){const e=r.match(ke).groups.range;if(0===o.length)throw new Error(`A highlight range has been given in code block's metastring (\`\`\` ${r}), but no magic comment config is available. Docusaurus applies the first magic comment entry's className for metastring ranges.`);const t=o[0].className,a=Ee()(e).filter((e=>e>0)).map((e=>[e-1,[t]]));return{lineClassNames:Object.fromEntries(a),code:n}}if(void 0===a)return{lineClassNames:{},code:n};const l=function(e,t){switch(e){case"js":case"javascript":case"ts":case"typescript":return Ce(["js","jsBlock"],t);case"jsx":case"tsx":return Ce(["js","jsBlock","jsx"],t);case"html":return Ce(["js","jsBlock","html"],t);case"python":case"py":case"bash":return Ce(["bash"],t);case"markdown":case"md":return Ce(["html","jsx","bash"],t);default:return Ce(Object.keys(Ne),t)}}(a,o),c=n.split("\n"),s=Object.fromEntries(o.map((e=>[e.className,{start:0,range:""}]))),i=Object.fromEntries(o.filter((e=>e.line)).map((e=>{let{className:t,line:n}=e;return[n,t]}))),d=Object.fromEntries(o.filter((e=>e.block)).map((e=>{let{className:t,block:n}=e;return[n.start,t]}))),m=Object.fromEntries(o.filter((e=>e.block)).map((e=>{let{className:t,block:n}=e;return[n.end,t]})));for(let p=0;p void 0!==e));i[t]?s[i[t]].range+=`${p},`:d[t]?s[d[t]].start=p:m[t]&&(s[m[t]].range+=`${s[m[t]].start}-${p-1},`),c.splice(p,1)}n=c.join("\n");const u={};return Object.entries(s).forEach((e=>{let[t,{range:n}]=e;Ee()(n).forEach((e=>{u[e]??=[],u[e].push(t)}))})),{lineClassNames:u,code:n}}const _e={codeBlockContainer:"codeBlockContainer_mQmQ"};function we(e){let{as:t,...n}=e;const o=function(e){const t={color:"--prism-color",backgroundColor:"--prism-background-color"},n={};return Object.entries(e.plain).forEach((e=>{let[a,o]=e;const r=t[a];r&&"string"==typeof o&&(n[r]=o)})),n}(be());return a.createElement(t,(0,u.Z)({},n,{style:o,className:(0,d.Z)(n.className,_e.codeBlockContainer,y.k.common.codeBlock)}))}const Te={codeBlockContent:"codeBlockContent_D5yF",codeBlockTitle:"codeBlockTitle_x_ju",codeBlock:"codeBlock_RMoD",codeBlockStandalone:"codeBlockStandalone_wQog",codeBlockLines:"codeBlockLines_AclH",codeBlockLinesWithNumbering:"codeBlockLinesWithNumbering_O625",buttonGroup:"buttonGroup_aaMX"};function Be(e){let{children:t,className:n}=e;return a.createElement(we,{as:"pre",tabIndex:0,className:(0,d.Z)(Te.codeBlockStandalone,"thin-scrollbar",n)},a.createElement("code",{className:Te.codeBlockLines},t))}const Ze={attributes:!0,characterData:!0,childList:!0,subtree:!0};function xe(e,t){const[n,o]=(0,a.useState)(),l=(0,a.useCallback)((()=>{o(e.current?.closest("[role=tabpanel][hidden]"))}),[e,o]);(0,a.useEffect)((()=>{l()}),[l]),function(e,t,n){void 0===n&&(n=Ze);const o=(0,r.zX)(t),l=(0,r.Ql)(n);(0,a.useEffect)((()=>{const t=new MutationObserver(o);return e&&t.observe(e,l),()=>t.disconnect()}),[e,o,l])}(n,(e=>{e.forEach((e=>{"attributes"===e.type&&"hidden"===e.attributeName&&(t(),l())}))}),{attributes:!0,characterData:!1,childList:!1,subtree:!1})}const Oe={plain:{backgroundColor:"#2a2734",color:"#9a86fd"},styles:[{types:["comment","prolog","doctype","cdata","punctuation"],style:{color:"#6c6783"}},{types:["namespace"],style:{opacity:.7}},{types:["tag","operator","number"],style:{color:"#e09142"}},{types:["property","function"],style:{color:"#9a86fd"}},{types:["tag-id","selector","atrule-id"],style:{color:"#eeebff"}},{types:["attr-name"],style:{color:"#c4b9fe"}},{types:["boolean","string","entity","url","attr-value","keyword","control","directive","unit","statement","regex","atrule","placeholder","variable"],style:{color:"#ffcc99"}},{types:["deleted"],style:{textDecorationLine:"line-through"}},{types:["inserted"],style:{textDecorationLine:"underline"}},{types:["italic"],style:{fontStyle:"italic"}},{types:["important","bold"],style:{fontWeight:"bold"}},{types:["important"],style:{color:"#c4b9fe"}}]};var He={Prism:n(2349).Z,theme:Oe};function je(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ae(){return Ae=Object.assign||function(e){for(var t=1;t 0&&e[n-1]===t?e:e.concat(t)};function Pe(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&-1===t.indexOf(a)&&(n[a]=e[a]);return n}var ze=function(e){function t(){for(var t=this,n=[],a=arguments.length;a--;)n[a]=arguments[a];e.apply(this,n),je(this,"getThemeDict",(function(e){if(void 0!==t.themeDict&&e.theme===t.prevTheme&&e.language===t.prevLanguage)return t.themeDict;t.prevTheme=e.theme,t.prevLanguage=e.language;var n=e.theme?function(e,t){var n=e.plain,a=Object.create(null),o=e.styles.reduce((function(e,n){var a=n.languages,o=n.style;return a&&!a.includes(t)||n.types.forEach((function(t){var n=Ae({},e[t],o);e[t]=n})),e}),a);return o.root=n,o.plain=Ae({},n,{backgroundColor:null}),o}(e.theme,e.language):void 0;return t.themeDict=n})),je(this,"getLineProps",(function(e){var n=e.key,a=e.className,o=e.style,r=Ae({},Pe(e,["key","className","style","line"]),{className:"token-line",style:void 0,key:void 0}),l=t.getThemeDict(t.props);return void 0!==l&&(r.style=l.plain),void 0!==o&&(r.style=void 0!==r.style?Ae({},r.style,o):o),void 0!==n&&(r.key=n),a&&(r.className+=" "+a),r})),je(this,"getStyleForToken",(function(e){var n=e.types,a=e.empty,o=n.length,r=t.getThemeDict(t.props);if(void 0!==r){if(1===o&&"plain"===n[0])return a?{display:"inline-block"}:void 0;if(1===o&&!a)return r[n[0]];var l=a?{display:"inline-block"}:{},c=n.map((function(e){return r[e]}));return Object.assign.apply(Object,[l].concat(c))}})),je(this,"getTokenProps",(function(e){var n=e.key,a=e.className,o=e.style,r=e.token,l=Ae({},Pe(e,["key","className","style","token"]),{className:"token "+r.types.join(" "),children:r.content,style:t.getStyleForToken(r),key:void 0});return void 0!==o&&(l.style=void 0!==l.style?Ae({},l.style,o):o),void 0!==n&&(l.key=n),a&&(l.className+=" "+a),l})),je(this,"tokenize",(function(e,t,n,a){var o={code:t,grammar:n,language:a,tokens:[]};e.hooks.run("before-tokenize",o);var r=o.tokens=e.tokenize(o.code,o.grammar,o.language);return e.hooks.run("after-tokenize",o),r}))}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.render=function(){var e=this.props,t=e.Prism,n=e.language,a=e.code,o=e.children,r=this.getThemeDict(this.props),l=t.languages[n];return o({tokens:function(e){for(var t=[[]],n=[e],a=[0],o=[e.length],r=0,l=0,c=[],s=[c];l>-1;){for(;(r=a[l]++) 0?d:["plain"],i=m):(d=Se(d,m.type),m.alias&&(d=Se(d,m.alias)),i=m.content),"string"==typeof i){var u=i.split(Ie),p=u.length;c.push({types:d,content:u[0]});for(var f=1;f a.createElement("span",(0,u.Z)({key:t},l({token:e,key:t})))));return a.createElement("span",c,o?a.createElement(a.Fragment,null,a.createElement("span",{className:De.codeLineNumber}),a.createElement("span",{className:De.codeLineContent},s)):s,a.createElement("br",null))}function Ve(e){return a.createElement("svg",(0,u.Z)({viewBox:"0 0 24 24"},e),a.createElement("path",{fill:"currentColor",d:"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"}))}function We(e){return a.createElement("svg",(0,u.Z)({viewBox:"0 0 24 24"},e),a.createElement("path",{fill:"currentColor",d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"}))}const Fe={copyButtonCopied:"copyButtonCopied_TYdd",copyButtonIcons:"copyButtonIcons_z5j7",copyButtonIcon:"copyButtonIcon_FoOz",copyButtonSuccessIcon:"copyButtonSuccessIcon_L0B6"};function $e(e){let{code:t,className:n}=e;const[o,r]=(0,a.useState)(!1),l=(0,a.useRef)(void 0),c=(0,a.useCallback)((()=>{!function(e,t){let{target:n=document.body}=void 0===t?{}:t;if("string"!=typeof e)throw new TypeError(`Expected parameter \`text\` to be a \`string\`, got \`${typeof e}\`.`);const a=document.createElement("textarea"),o=document.activeElement;a.value=e,a.setAttribute("readonly",""),a.style.contain="strict",a.style.position="absolute",a.style.left="-9999px",a.style.fontSize="12pt";const r=document.getSelection(),l=r.rangeCount>0&&r.getRangeAt(0);n.append(a),a.select(),a.selectionStart=0,a.selectionEnd=e.length;let c=!1;try{c=document.execCommand("copy")}catch{}a.remove(),l&&(r.removeAllRanges(),r.addRange(l)),o&&o.focus()}(t),r(!0),l.current=window.setTimeout((()=>{r(!1)}),1e3)}),[t]);return(0,a.useEffect)((()=>()=>window.clearTimeout(l.current)),[]),a.createElement("button",{type:"button","aria-label":o?(0,p.I)({id:"theme.CodeBlock.copied",message:"Copied",description:"The copied button label on code blocks"}):(0,p.I)({id:"theme.CodeBlock.copyButtonAriaLabel",message:"Copy code to clipboard",description:"The ARIA label for copy code blocks button"}),title:(0,p.I)({id:"theme.CodeBlock.copy",message:"Copy",description:"The copy button label on code blocks"}),className:(0,d.Z)("clean-btn",n,Fe.copyButton,o&&Fe.copyButtonCopied),onClick:c},a.createElement("span",{className:Fe.copyButtonIcons,"aria-hidden":"true"},a.createElement(Ve,{className:Fe.copyButtonIcon}),a.createElement(We,{className:Fe.copyButtonSuccessIcon})))}function qe(e){return a.createElement("svg",(0,u.Z)({viewBox:"0 0 24 24"},e),a.createElement("path",{fill:"currentColor",d:"M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"}))}const Ge={wordWrapButtonIcon:"wordWrapButtonIcon_HV9T",wordWrapButtonEnabled:"wordWrapButtonEnabled_XzR1"};function Qe(e){let{className:t,onClick:n,isEnabled:o}=e;const r=(0,p.I)({id:"theme.CodeBlock.wordWrapToggle",message:"Toggle word wrap",description:"The title attribute for toggle word wrapping button of code block lines"});return a.createElement("button",{type:"button",onClick:n,className:(0,d.Z)("clean-btn",t,o&&Ge.wordWrapButtonEnabled),"aria-label":r,title:r},a.createElement(qe,{className:Ge.wordWrapButtonIcon,"aria-hidden":"true"}))}function Xe(e){let{children:t,className:n="",metastring:o,title:r,showLineNumbers:l,language:c}=e;const{prism:{defaultLanguage:s,magicComments:i}}=(0,W.L)(),m=c??function(e){const t=e.split(" ").find((e=>e.startsWith("language-")));return t?.replace(/language-/,"")}(n)??s,p=be(),f=function(){const[e,t]=(0,a.useState)(!1),[n,o]=(0,a.useState)(!1),r=(0,a.useRef)(null),l=(0,a.useCallback)((()=>{const n=r.current.querySelector("code");e?n.removeAttribute("style"):(n.style.whiteSpace="pre-wrap",n.style.overflowWrap="anywhere"),t((e=>!e))}),[r,e]),c=(0,a.useCallback)((()=>{const{scrollWidth:e,clientWidth:t}=r.current,n=e>t||r.current.querySelector("code").hasAttribute("style");o(n)}),[r]);return xe(r,c),(0,a.useEffect)((()=>{c()}),[e,c]),(0,a.useEffect)((()=>(window.addEventListener("resize",c,{passive:!0}),()=>{window.removeEventListener("resize",c)})),[c]),{codeBlockRef:r,isEnabled:e,isCodeScrollable:n,toggle:l}}(),h=function(e){return e?.match(ye)?.groups.title??""}(o)||r,{lineClassNames:g,code:b}=Le(t,{metastring:o,language:m,magicComments:i}),v=l??function(e){return Boolean(e?.includes("showLineNumbers"))}(o);return a.createElement(we,{as:"div",className:(0,d.Z)(n,m&&!n.includes(`language-${m}`)&&`language-${m}`)},h&&a.createElement("div",{className:Te.codeBlockTitle},h),a.createElement("div",{className:Te.codeBlockContent},a.createElement(Ue,(0,u.Z)({},He,{theme:p,code:b,language:m??"text"}),(e=>{let{className:t,tokens:n,getLineProps:o,getTokenProps:r}=e;return a.createElement("pre",{tabIndex:0,ref:f.codeBlockRef,className:(0,d.Z)(t,Te.codeBlock,"thin-scrollbar")},a.createElement("code",{className:(0,d.Z)(Te.codeBlockLines,v&&Te.codeBlockLinesWithNumbering)},n.map(((e,t)=>a.createElement(Re,{key:t,line:e,getLineProps:o,getTokenProps:r,classNames:g[t],showLineNumbers:v})))))})),a.createElement("div",{className:Te.buttonGroup},(f.isEnabled||f.isCodeScrollable)&&a.createElement(Qe,{className:Te.codeButton,onClick:()=>f.toggle(),isEnabled:f.isEnabled}),a.createElement($e,{className:Te.codeButton,code:b}))))}function Je(e){let{children:t,...n}=e;const o=(0,he.Z)(),r=function(e){return a.Children.toArray(e).some((e=>(0,a.isValidElement)(e)))?e:Array.isArray(e)?e.join(""):e}(t),l="string"==typeof r?Xe:Be;return a.createElement(l,(0,u.Z)({key:String(o)},n),r)}const Ye={details:"details_IpIu",isBrowser:"isBrowser_QD4r",collapsibleContent:"collapsibleContent_Fd2D"};function Ke(e){return!!e&&("SUMMARY"===e.tagName||Ke(e.parentElement))}function et(e,t){return!!e&&(e===t||et(e.parentElement,t))}function tt(e){let{summary:t,children:n,...o}=e;const r=(0,he.Z)(),l=(0,a.useRef)(null),{collapsed:c,setCollapsed:s}=(0,V.u)({initialState:!o.open}),[i,m]=(0,a.useState)(o.open),p=a.isValidElement(t)?t:a.createElement("summary",null,t??"Details");return a.createElement("details",(0,u.Z)({},o,{ref:l,open:i,"data-collapsed":c,className:(0,d.Z)(Ye.details,r&&Ye.isBrowser,o.className),onMouseDown:e=>{Ke(e.target)&&e.detail>1&&e.preventDefault()},onClick:e=>{e.stopPropagation();const t=e.target;Ke(t)&&et(t,l.current)&&(e.preventDefault(),c?(s(!1),m(!0)):s(!0))}}),p,a.createElement(V.z,{lazy:!1,collapsed:c,disableSSRStyle:!0,onCollapseTransitionEnd:e=>{s(e),m(!e)}},a.createElement("div",{className:Ye.collapsibleContent},n)))}const nt={details:"details_jERq"},at="alert alert--info";function ot(e){let{...t}=e;return a.createElement(tt,(0,u.Z)({},t,{className:(0,d.Z)(at,nt.details,t.className)}))}function rt(e){return a.createElement(ue,e)}const lt={containsTaskList:"containsTaskList_QWGu"};const ct={img:"img_SS3x"};const st="admonition_uH4V",it="admonitionHeading_P5_N",dt="admonitionIcon_MF44",mt="admonitionContent_yySL";const ut={note:{infimaClassName:"secondary",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 14 16"},a.createElement("path",{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"}))},label:a.createElement(p.Z,{id:"theme.admonition.note",description:"The default label used for the Note admonition (:::note)"},"note")},tip:{infimaClassName:"success",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 12 16"},a.createElement("path",{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"}))},label:a.createElement(p.Z,{id:"theme.admonition.tip",description:"The default label used for the Tip admonition (:::tip)"},"tip")},danger:{infimaClassName:"danger",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 12 16"},a.createElement("path",{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"}))},label:a.createElement(p.Z,{id:"theme.admonition.danger",description:"The default label used for the Danger admonition (:::danger)"},"danger")},info:{infimaClassName:"info",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 14 16"},a.createElement("path",{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"}))},label:a.createElement(p.Z,{id:"theme.admonition.info",description:"The default label used for the Info admonition (:::info)"},"info")},caution:{infimaClassName:"warning",iconComponent:function(){return a.createElement("svg",{viewBox:"0 0 16 16"},a.createElement("path",{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"}))},label:a.createElement(p.Z,{id:"theme.admonition.caution",description:"The default label used for the Caution admonition (:::caution)"},"caution")}},pt={secondary:"note",important:"info",success:"tip",warning:"danger"};function ft(e){const{mdxAdmonitionTitle:t,rest:n}=function(e){const t=a.Children.toArray(e),n=t.find((e=>a.isValidElement(e)&&"mdxAdmonitionTitle"===e.props?.mdxType)),o=a.createElement(a.Fragment,null,t.filter((e=>e!==n)));return{mdxAdmonitionTitle:n,rest:o}}(e.children);return{...e,title:e.title??t,children:n}}const ht={head:function(e){const t=a.Children.map(e.children,(e=>a.isValidElement(e)?function(e){if(e.props?.mdxType&&e.props.originalType){const{mdxType:t,originalType:n,...o}=e.props;return a.createElement(e.props.originalType,o)}return e}(e):e));return a.createElement(fe.Z,e,t)},code:function(e){const t=["a","abbr","b","br","button","cite","code","del","dfn","em","i","img","input","ins","kbd","label","object","output","q","ruby","s","small","span","strong","sub","sup","time","u","var","wbr"];return a.Children.toArray(e.children).every((e=>"string"==typeof e&&!e.includes("\n")||(0,a.isValidElement)(e)&&t.includes(e.props?.mdxType)))?a.createElement("code",e):a.createElement(Je,e)},a:function(e){return a.createElement(f.Z,e)},pre:function(e){return a.createElement(Je,(0,a.isValidElement)(e.children)&&"code"===e.children.props?.originalType?e.children.props:{...e})},details:function(e){const t=a.Children.toArray(e.children),n=t.find((e=>a.isValidElement(e)&&"summary"===e.props?.mdxType)),o=a.createElement(a.Fragment,null,t.filter((e=>e!==n)));return a.createElement(ot,(0,u.Z)({},e,{summary:n}),o)},ul:function(e){return a.createElement("ul",(0,u.Z)({},e,{className:(t=e.className,(0,d.Z)(t,t?.includes("contains-task-list")&<.containsTaskList))}));var t},img:function(e){return a.createElement("img",(0,u.Z)({loading:"lazy"},e,{className:(t=e.className,(0,d.Z)(t,ct.img))}));var t},h1:e=>a.createElement(rt,(0,u.Z)({as:"h1"},e)),h2:e=>a.createElement(rt,(0,u.Z)({as:"h2"},e)),h3:e=>a.createElement(rt,(0,u.Z)({as:"h3"},e)),h4:e=>a.createElement(rt,(0,u.Z)({as:"h4"},e)),h5:e=>a.createElement(rt,(0,u.Z)({as:"h5"},e)),h6:e=>a.createElement(rt,(0,u.Z)({as:"h6"},e)),admonition:function(e){const{children:t,type:n,title:o,icon:r}=ft(e),l=function(e){const t=pt[e]??e,n=ut[t];return n||(console.warn(`No admonition config found for admonition type "${t}". Using Info as fallback.`),ut.info)}(n),c=o??l.label,{iconComponent:s}=l,i=r??a.createElement(s,null);return a.createElement("div",{className:(0,d.Z)(y.k.common.admonition,y.k.common.admonitionType(e.type),"alert",`alert--${l.infimaClassName}`,st)},a.createElement("div",{className:it},a.createElement("span",{className:dt},i),c),a.createElement("div",{className:mt},t))},mermaid:()=>null};function gt(e){let{children:t}=e;return a.createElement(pe.Zo,{components:ht},t)}function bt(e){let{children:t}=e;const n=function(){const{metadata:e,frontMatter:t,contentTitle:n}=s();return t.hide_title||void 0!==n?null:e.title}();return a.createElement("div",{className:(0,d.Z)(y.k.docs.docMarkdown,"markdown")},n&&a.createElement("header",null,a.createElement(ue,{as:"h1"},n)),a.createElement(gt,null,t))}var vt=n(5161),Et=n(8862),yt=n(8948);function kt(e){return a.createElement("svg",(0,u.Z)({viewBox:"0 0 24 24"},e),a.createElement("path",{d:"M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z",fill:"currentColor"}))}const Nt={breadcrumbHomeIcon:"breadcrumbHomeIcon_sfvy"};function Ct(){const e=(0,yt.Z)("/");return a.createElement("li",{className:"breadcrumbs__item"},a.createElement(f.Z,{"aria-label":(0,p.I)({id:"theme.docs.breadcrumbs.home",message:"Home page",description:"The ARIA label for the home page in the breadcrumbs"}),className:"breadcrumbs__link",href:e},a.createElement(kt,{className:Nt.breadcrumbHomeIcon})))}const Lt={breadcrumbsContainer:"breadcrumbsContainer_T5ub"};function _t(e){let{children:t,href:n,isLast:o}=e;const r="breadcrumbs__link";return o?a.createElement("span",{className:r,itemProp:"name"},t):n?a.createElement(f.Z,{className:r,href:n,itemProp:"item"},a.createElement("span",{itemProp:"name"},t)):a.createElement("span",{className:r},t)}function wt(e){let{children:t,active:n,index:o,addMicrodata:r}=e;return a.createElement("li",(0,u.Z)({},r&&{itemScope:!0,itemProp:"itemListElement",itemType:"https://schema.org/ListItem"},{className:(0,d.Z)("breadcrumbs__item",{"breadcrumbs__item--active":n})}),t,a.createElement("meta",{itemProp:"position",content:String(o+1)}))}function Tt(){const e=(0,vt.s1)(),t=(0,Et.Ns)();return e?a.createElement("nav",{className:(0,d.Z)(y.k.docs.docBreadcrumbs,Lt.breadcrumbsContainer),"aria-label":(0,p.I)({id:"theme.docs.breadcrumbs.navAriaLabel",message:"Breadcrumbs",description:"The ARIA label for the breadcrumbs"})},a.createElement("ul",{className:"breadcrumbs",itemScope:!0,itemType:"https://schema.org/BreadcrumbList"},t&&a.createElement(Ct,null),e.map(((t,n)=>{const o=n===e.length-1;return a.createElement(wt,{key:n,active:o,index:n,addMicrodata:!!t.href},a.createElement(_t,{href:t.href,isLast:o},t.label))})))):null}const Bt={docItemContainer:"docItemContainer_tjFy",docItemCol:"docItemCol_Qr34"};function Zt(e){let{children:t}=e;const n=function(){const{frontMatter:e,toc:t}=s(),n=(0,m.i)(),o=e.hide_table_of_contents,r=!o&&t.length>0;return{hidden:o,mobile:r?a.createElement(re,null):void 0,desktop:!r||"desktop"!==n&&"ssr"!==n?void 0:a.createElement(de,null)}}();return a.createElement("div",{className:"row"},a.createElement("div",{className:(0,d.Z)("col",!n.hidden&&Bt.docItemCol)},a.createElement(T,null),a.createElement("div",{className:Bt.docItemContainer},a.createElement("article",null,a.createElement(Tt,null),a.createElement(B,null),n.mobile,a.createElement(bt,null,t),a.createElement(R,null)),a.createElement(b,null))),n.desktop&&a.createElement("div",{className:"col col--3"},n.desktop))}function xt(e){const t=`docs-doc-id-${e.content.metadata.unversionedId}`,n=e.content;return a.createElement(c,{content:e.content},a.createElement(o.FG,{className:t},a.createElement(i,null),a.createElement(Zt,null,a.createElement(n,null))))}},5611:(e,t,n)=>{"use strict";n.d(t,{E:()=>c,q:()=>l});var a=n(7378),o=n(1763);const r=a.createContext(null);function l(e){let{children:t,version:n}=e;return a.createElement(r.Provider,{value:n},t)}function c(){const e=(0,a.useContext)(r);if(null===e)throw new o.i6("DocsVersionProvider");return e}},6324:(e,t)=>{function n(e){let t,n=[];for(let a of e.split(",").map((e=>e.trim())))if(/^-?\d+$/.test(a))n.push(parseInt(a,10));else if(t=a.match(/^(-?\d+)(-|\.\.\.?|\u2025|\u2026|\u22EF)(-?\d+)$/)){let[e,a,o,r]=t;if(a&&r){a=parseInt(a),r=parseInt(r);const e=a
{s.r(t),s.d(t,{assets:()=>a,contentTitle:()=>r,default:()=>d,frontMatter:()=>o,metadata:()=>i,toc:()=>l});var n=s(4246),c=s(1670);const o={},r="Using the ClsService Instance",i={id:"setting-up-cls-context/using_cls_run",title:"Using the ClsService Instance",description:"All other methods of setting up the CLS context ultimately use the ClsService#run or ClsService#enter methods.",source:"@site/docs/02_setting-up-cls-context/05_using_cls_run.md",sourceDirName:"02_setting-up-cls-context",slug:"/setting-up-cls-context/using_cls_run",permalink:"/nestjs-cls/setting-up-cls-context/using_cls_run",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/02_setting-up-cls-context/05_using_cls_run.md",tags:[],version:"current",sidebarPosition:5,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Using a Decorator",permalink:"/nestjs-cls/setting-up-cls-context/using-a-decorator"},next:{title:"Features and use cases",permalink:"/nestjs-cls/features-and-use-cases/"}},a={},l=[];function u(e){const t={a:"a",code:"code",h1:"h1",p:"p",...(0,c.a)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.h1,{id:"using-the-clsservice-instance",children:"Using the ClsService Instance"}),"\n",(0,n.jsxs)(t.p,{children:["All other methods of setting up the CLS context ultimately use the ",(0,n.jsx)(t.code,{children:"ClsService#run"})," or ",(0,n.jsx)(t.code,{children:"ClsService#enter"})," methods."]}),"\n",(0,n.jsxs)(t.p,{children:["If all other attempts fail or you want to have a more fine-grained control over the CLS context, you can use ",(0,n.jsx)(t.code,{children:"ClsService"})," instance to wrap any piece of code in a CLS context."]}),"\n",(0,n.jsxs)(t.p,{children:["An example is available in the ",(0,n.jsx)(t.a,{href:"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request",children:"Usage outside of web request"})," section."]})]})}function d(e={}){const{wrapper:t}={...(0,c.a)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(u,{...e})}):u(e)}},1670:(e,t,s)=>{s.d(t,{Z:()=>i,a:()=>r});var n=s(7378);const c={},o=n.createContext(c);function r(e){const t=n.useContext(o);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:r(e.components),n.createElement(o.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/1be78505.cee9dfcc.js b/assets/js/1be78505.cee9dfcc.js deleted file mode 100755 index 0a8fced..0000000 --- a/assets/js/1be78505.cee9dfcc.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[514,893],{5553:(e,t,n)=>{n.r(t),n.d(t,{default:()=>ge});var a=n(7378),o=n(8944),l=n(8831),r=n(5484),c=n(3149),i=n(5161),s=n(5611),d=n(2095),m=n(9176),u=n(9213),b=n(3457),p=n(4993);const h={backToTopButton:"backToTopButton_iEvu",backToTopButtonShow:"backToTopButtonShow_DO8w"};function E(){const{shown:e,scrollToTop:t}=function(e){let{threshold:t}=e;const[n,o]=(0,a.useState)(!1),l=(0,a.useRef)(!1),{startScroll:r,cancelScroll:c}=(0,b.Ct)();return(0,b.RF)(((e,n)=>{let{scrollY:a}=e;const r=n?.scrollY;r&&(l.current?l.current=!1:a>=r?(c(),o(!1)):a {e.location.hash&&(l.current=!0,o(!1))})),{shown:n,scrollToTop:()=>r(0)}}({threshold:300});return a.createElement("button",{"aria-label":(0,u.I)({id:"theme.BackToTopButton.buttonAriaLabel",message:"Scroll back to top",description:"The ARIA label for the back to top button"}),className:(0,o.Z)("clean-btn",r.k.common.backToTopButton,h.backToTopButton,e&&h.backToTopButtonShow),type:"button",onClick:t})}var f=n(6903),g=n(3620),v=n(8357),k=n(624),_=n(898),C=n(5773);function I(e){return a.createElement("svg",(0,C.Z)({width:"20",height:"20","aria-hidden":"true"},e),a.createElement("g",{fill:"#7a7a7a"},a.createElement("path",{d:"M9.992 10.023c0 .2-.062.399-.172.547l-4.996 7.492a.982.982 0 01-.828.454H1c-.55 0-1-.453-1-1 0-.2.059-.403.168-.551l4.629-6.942L.168 3.078A.939.939 0 010 2.528c0-.548.45-.997 1-.997h2.996c.352 0 .649.18.828.45L9.82 9.472c.11.148.172.347.172.55zm0 0"}),a.createElement("path",{d:"M19.98 10.023c0 .2-.058.399-.168.547l-4.996 7.492a.987.987 0 01-.828.454h-3c-.547 0-.996-.453-.996-1 0-.2.059-.403.168-.551l4.625-6.942-4.625-6.945a.939.939 0 01-.168-.55 1 1 0 01.996-.997h3c.348 0 .649.18.828.45l4.996 7.492c.11.148.168.347.168.55zm0 0"})))}const S={collapseSidebarButton:"collapseSidebarButton_oTwn",collapseSidebarButtonIcon:"collapseSidebarButtonIcon_pMEX"};function N(e){let{onClick:t}=e;return a.createElement("button",{type:"button",title:(0,u.I)({id:"theme.docs.sidebar.collapseButtonTitle",message:"Collapse sidebar",description:"The title attribute for collapse button of doc sidebar"}),"aria-label":(0,u.I)({id:"theme.docs.sidebar.collapseButtonAriaLabel",message:"Collapse sidebar",description:"The title attribute for collapse button of doc sidebar"}),className:(0,o.Z)("button button--secondary button--outline",S.collapseSidebarButton),onClick:t},a.createElement(I,{className:S.collapseSidebarButtonIcon}))}var T=n(10),Z=n(1763);const x=Symbol("EmptyContext"),B=a.createContext(x);function w(e){let{children:t}=e;const[n,o]=(0,a.useState)(null),l=(0,a.useMemo)((()=>({expandedItem:n,setExpandedItem:o})),[n]);return a.createElement(B.Provider,{value:l},t)}var y=n(376),L=n(8862),A=n(1884),M=n(6457);function H(e){let{categoryLabel:t,onClick:n}=e;return a.createElement("button",{"aria-label":(0,u.I)({id:"theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel",message:"Toggle the collapsible sidebar category '{label}'",description:"The ARIA label to toggle the collapsible sidebar category"},{label:t}),type:"button",className:"clean-btn menu__caret",onClick:n})}function P(e){let{item:t,onItemClick:n,activePath:l,level:c,index:s,...d}=e;const{items:m,label:u,collapsible:b,className:p,href:h}=t,{docs:{sidebar:{autoCollapseCategories:E}}}=(0,k.L)(),f=function(e){const t=(0,M.Z)();return(0,a.useMemo)((()=>e.href?e.href:!t&&e.collapsible?(0,i.Wl)(e):void 0),[e,t])}(t),g=(0,i._F)(t,l),v=(0,L.Mg)(h,l),{collapsed:_,setCollapsed:I}=(0,y.u)({initialState:()=>!!b&&(!g&&t.collapsed)}),{expandedItem:S,setExpandedItem:N}=function(){const e=(0,a.useContext)(B);if(e===x)throw new Z.i6("DocSidebarItemsExpandedStateProvider");return e}(),T=function(e){void 0===e&&(e=!_),N(e?null:s),I(e)};return function(e){let{isActive:t,collapsed:n,updateCollapsed:o}=e;const l=(0,Z.D9)(t);(0,a.useEffect)((()=>{t&&!l&&n&&o(!1)}),[t,l,n,o])}({isActive:g,collapsed:_,updateCollapsed:T}),(0,a.useEffect)((()=>{b&&null!=S&&S!==s&&E&&I(!0)}),[b,S,s,I,E]),a.createElement("li",{className:(0,o.Z)(r.k.docs.docSidebarItemCategory,r.k.docs.docSidebarItemCategoryLevel(c),"menu__list-item",{"menu__list-item--collapsed":_},p)},a.createElement("div",{className:(0,o.Z)("menu__list-item-collapsible",{"menu__list-item-collapsible--active":v})},a.createElement(A.Z,(0,C.Z)({className:(0,o.Z)("menu__link",{"menu__link--sublist":b,"menu__link--sublist-caret":!h&&b,"menu__link--active":g}),onClick:b?e=>{n?.(t),h?T(!1):(e.preventDefault(),T())}:()=>{n?.(t)},"aria-current":v?"page":void 0,"aria-expanded":b?!_:void 0,href:b?f??"#":f},d),u),h&&b&&a.createElement(H,{categoryLabel:u,onClick:e=>{e.preventDefault(),T()}})),a.createElement(y.z,{lazy:!0,as:"ul",className:"menu__list",collapsed:_},a.createElement(O,{items:m,tabIndex:_?-1:0,onItemClick:n,activePath:l,level:c+1})))}var F=n(5626),W=n(6125);const R={menuExternalLink:"menuExternalLink_BiEj"};function D(e){let{item:t,onItemClick:n,activePath:l,level:c,index:s,...d}=e;const{href:m,label:u,className:b,autoAddBaseUrl:p}=t,h=(0,i._F)(t,l),E=(0,F.Z)(m);return a.createElement("li",{className:(0,o.Z)(r.k.docs.docSidebarItemLink,r.k.docs.docSidebarItemLinkLevel(c),"menu__list-item",b),key:u},a.createElement(A.Z,(0,C.Z)({className:(0,o.Z)("menu__link",!E&&R.menuExternalLink,{"menu__link--active":h}),autoAddBaseUrl:p,"aria-current":h?"page":void 0,to:m},E&&{onClick:n?()=>n(t):void 0},d),u,!E&&a.createElement(W.Z,null)))}const V={menuHtmlItem:"menuHtmlItem_OniL"};function j(e){let{item:t,level:n,index:l}=e;const{value:c,defaultStyle:i,className:s}=t;return a.createElement("li",{className:(0,o.Z)(r.k.docs.docSidebarItemLink,r.k.docs.docSidebarItemLinkLevel(n),i&&[V.menuHtmlItem,"menu__list-item"],s),key:l,dangerouslySetInnerHTML:{__html:c}})}function Y(e){let{item:t,...n}=e;switch(t.type){case"category":return a.createElement(P,(0,C.Z)({item:t},n));case"html":return a.createElement(j,(0,C.Z)({item:t},n));default:return a.createElement(D,(0,C.Z)({item:t},n))}}function z(e){let{items:t,...n}=e;return a.createElement(w,null,t.map(((e,t)=>a.createElement(Y,(0,C.Z)({key:t,item:e,index:t},n)))))}const O=(0,a.memo)(z),U={menu:"menu_jmj1",menuWithAnnouncementBar:"menuWithAnnouncementBar_YufC"};function G(e){let{path:t,sidebar:n,className:l}=e;const c=function(){const{isActive:e}=(0,T.nT)(),[t,n]=(0,a.useState)(e);return(0,b.RF)((t=>{let{scrollY:a}=t;e&&n(0===a)}),[e]),e&&t}();return a.createElement("nav",{"aria-label":(0,u.I)({id:"theme.docs.sidebar.navAriaLabel",message:"Docs sidebar",description:"The ARIA label for the sidebar navigation"}),className:(0,o.Z)("menu thin-scrollbar",U.menu,c&&U.menuWithAnnouncementBar,l)},a.createElement("ul",{className:(0,o.Z)(r.k.docs.docSidebarMenu,"menu__list")},a.createElement(O,{items:n,activePath:t,level:1})))}const K="sidebar_CUen",q="sidebarWithHideableNavbar_w4KB",J="sidebarHidden_k6VE",Q="sidebarLogo_CYvI";function X(e){let{path:t,sidebar:n,onCollapse:l,isHidden:r}=e;const{navbar:{hideOnScroll:c},docs:{sidebar:{hideable:i}}}=(0,k.L)();return a.createElement("div",{className:(0,o.Z)(K,c&&q,r&&J)},c&&a.createElement(_.Z,{tabIndex:-1,className:Q}),a.createElement(G,{path:t,sidebar:n}),i&&a.createElement(N,{onClick:l}))}const $=a.memo(X);var ee=n(3471),te=n(5536);const ne=e=>{let{sidebar:t,path:n}=e;const l=(0,te.e)();return a.createElement("ul",{className:(0,o.Z)(r.k.docs.docSidebarMenu,"menu__list")},a.createElement(O,{items:t,activePath:n,onItemClick:e=>{"category"===e.type&&e.href&&l.toggle(),"link"===e.type&&l.toggle()},level:1}))};function ae(e){return a.createElement(ee.Zo,{component:ne,props:e})}const oe=a.memo(ae);function le(e){const t=(0,v.i)(),n="desktop"===t||"ssr"===t,o="mobile"===t;return a.createElement(a.Fragment,null,n&&a.createElement($,e),o&&a.createElement(oe,e))}const re={expandButton:"expandButton_YOoA",expandButtonIcon:"expandButtonIcon_GZLG"};function ce(e){let{toggleSidebar:t}=e;return a.createElement("div",{className:re.expandButton,title:(0,u.I)({id:"theme.docs.sidebar.expandButtonTitle",message:"Expand sidebar",description:"The ARIA label and title attribute for expand button of doc sidebar"}),"aria-label":(0,u.I)({id:"theme.docs.sidebar.expandButtonAriaLabel",message:"Expand sidebar",description:"The ARIA label and title attribute for expand button of doc sidebar"}),tabIndex:0,role:"button",onKeyDown:t,onClick:t},a.createElement(I,{className:re.expandButtonIcon}))}const ie={docSidebarContainer:"docSidebarContainer_y0RQ",docSidebarContainerHidden:"docSidebarContainerHidden_uArb",sidebarViewport:"sidebarViewport_EJ1r"};function se(e){let{children:t}=e;const n=(0,d.V)();return a.createElement(a.Fragment,{key:n?.name??"noSidebar"},t)}function de(e){let{sidebar:t,hiddenSidebarContainer:n,setHiddenSidebarContainer:l}=e;const{pathname:c}=(0,g.TH)(),[i,s]=(0,a.useState)(!1),d=(0,a.useCallback)((()=>{i&&s(!1),!i&&(0,f.n)()&&s(!0),l((e=>!e))}),[l,i]);return a.createElement("aside",{className:(0,o.Z)(r.k.docs.docSidebarContainer,ie.docSidebarContainer,n&&ie.docSidebarContainerHidden),onTransitionEnd:e=>{e.currentTarget.classList.contains(ie.docSidebarContainer)&&n&&s(!0)}},a.createElement(se,null,a.createElement("div",{className:(0,o.Z)(ie.sidebarViewport,i&&ie.sidebarViewportHidden)},a.createElement(le,{sidebar:t,path:c,onCollapse:d,isHidden:i}),i&&a.createElement(ce,{toggleSidebar:d}))))}const me={docMainContainer:"docMainContainer_sTIZ",docMainContainerEnhanced:"docMainContainerEnhanced_iSjt",docItemWrapperEnhanced:"docItemWrapperEnhanced_PxMR"};function ue(e){let{hiddenSidebarContainer:t,children:n}=e;const l=(0,d.V)();return a.createElement("main",{className:(0,o.Z)(me.docMainContainer,(t||!l)&&me.docMainContainerEnhanced)},a.createElement("div",{className:(0,o.Z)("container padding-top--md padding-bottom--lg",me.docItemWrapper,t&&me.docItemWrapperEnhanced)},n))}const be={docPage:"docPage_KLoz",docsWrapper:"docsWrapper_ct1J"};function pe(e){let{children:t}=e;const n=(0,d.V)(),[o,l]=(0,a.useState)(!1);return a.createElement(m.Z,{wrapperClassName:be.docsWrapper},a.createElement(E,null),a.createElement("div",{className:be.docPage},n&&a.createElement(de,{sidebar:n.items,hiddenSidebarContainer:o,setHiddenSidebarContainer:l}),a.createElement(ue,{hiddenSidebarContainer:o},t)))}var he=n(3893),Ee=n(505);function fe(e){const{versionMetadata:t}=e;return a.createElement(a.Fragment,null,a.createElement(Ee.Z,{version:t.version,tag:(0,c.os)(t.pluginId,t.version)}),a.createElement(l.d,null,t.noIndex&&a.createElement("meta",{name:"robots",content:"noindex, nofollow"})))}function ge(e){const{versionMetadata:t}=e,n=(0,i.hI)(e);if(!n)return a.createElement(he.default,null);const{docElement:c,sidebarName:m,sidebarItems:u}=n;return a.createElement(a.Fragment,null,a.createElement(fe,e),a.createElement(l.FG,{className:(0,o.Z)(r.k.wrapper.docsPages,r.k.page.docsDocPage,e.versionMetadata.className)},a.createElement(s.q,{version:t},a.createElement(d.b,{name:m,items:u},a.createElement(pe,null,c)))))}},3893:(e,t,n)=>{n.r(t),n.d(t,{default:()=>c});var a=n(7378),o=n(9213),l=n(8831),r=n(9176);function c(){return a.createElement(a.Fragment,null,a.createElement(l.d,{title:(0,o.I)({id:"theme.NotFound.title",message:"Page Not Found"})}),a.createElement(r.Z,null,a.createElement("main",{className:"container margin-vert--xl"},a.createElement("div",{className:"row"},a.createElement("div",{className:"col col--6 col--offset-3"},a.createElement("h1",{className:"hero__title"},a.createElement(o.Z,{id:"theme.NotFound.title",description:"The title of the 404 page"},"Page Not Found")),a.createElement("p",null,a.createElement(o.Z,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page"},"We could not find what you were looking for.")),a.createElement("p",null,a.createElement(o.Z,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page"},"Please contact the owner of the site that linked you to the original URL and let them know their link is broken.")))))))}},5611:(e,t,n)=>{n.d(t,{E:()=>c,q:()=>r});var a=n(7378),o=n(1763);const l=a.createContext(null);function r(e){let{children:t,version:n}=e;return a.createElement(l.Provider,{value:n},t)}function c(){const e=(0,a.useContext)(l);if(null===e)throw new o.i6("DocsVersionProvider");return e}}}]); \ No newline at end of file diff --git a/assets/js/2d4cceda.9ec420e4.js b/assets/js/2d4cceda.9ec420e4.js new file mode 100644 index 0000000..aa85757 --- /dev/null +++ b/assets/js/2d4cceda.9ec420e4.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[285],{2599:(e,t,n)=>{n.d(t,{Z:()=>i});n(7378);var a=n(624);const r={tabItem:"tabItem_wHwb"};var s=n(4246);function i(e){let{children:t,hidden:n,className:i}=e;return(0,s.jsx)("div",{role:"tabpanel",className:(0,a.Z)(r.tabItem,i),hidden:n,children:t})}},8447:(e,t,n)=>{n.d(t,{Z:()=>w});var a=n(7378),r=n(624),s=n(9169),i=n(3620),l=n(9749),o=n(8981),c=n(56),u=n(8796);function d(e){return a.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,a.isValidElement)(e)&&function(e){const{props:t}=e;return!!t&&"object"==typeof t&&"value"in t}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function p(e){const{values:t,children:n}=e;return(0,a.useMemo)((()=>{const e=t??function(e){return d(e).map((e=>{let{props:{value:t,label:n,attributes:a,default:r}}=e;return{value:t,label:n,attributes:a,default:r}}))}(n);return function(e){const t=(0,c.l)(e,((e,t)=>e.value===t.value));if(t.length>0)throw new Error(`Docusaurus error: Duplicate values "${t.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[t,n])}function h(e){let{value:t,tabValues:n}=e;return n.some((e=>e.value===t))}function m(e){let{queryString:t=!1,groupId:n}=e;const r=(0,i.k6)(),s=function(e){let{queryString:t=!1,groupId:n}=e;if("string"==typeof t)return t;if(!1===t)return null;if(!0===t&&!n)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return n??null}({queryString:t,groupId:n});return[(0,o._X)(s),(0,a.useCallback)((e=>{if(!s)return;const t=new URLSearchParams(r.location.search);t.set(s,e),r.replace({...r.location,search:t.toString()})}),[s,r])]}function g(e){const{defaultValue:t,queryString:n=!1,groupId:r}=e,s=p(e),[i,o]=(0,a.useState)((()=>function(e){let{defaultValue:t,tabValues:n}=e;if(0===n.length)throw new Error("Docusaurus error: the component requires at least one children component");if(t){if(!h({value:t,tabValues:n}))throw new Error(`Docusaurus error: The has a defaultValue "${t}" but none of its children has the corresponding value. Available values are: ${n.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return t}const a=n.find((e=>e.default))??n[0];if(!a)throw new Error("Unexpected error: 0 tabValues");return a.value}({defaultValue:t,tabValues:s}))),[c,d]=m({queryString:n,groupId:r}),[g,b]=function(e){let{groupId:t}=e;const n=function(e){return e?`docusaurus.tab.${e}`:null}(t),[r,s]=(0,u.Nk)(n);return[r,(0,a.useCallback)((e=>{n&&s.set(e)}),[n,s])]}({groupId:r}),f=(()=>{const e=c??g;return h({value:e,tabValues:s})?e:null})();(0,l.Z)((()=>{f&&o(f)}),[f]);return{selectedValue:i,selectValue:(0,a.useCallback)((e=>{if(!h({value:e,tabValues:s}))throw new Error(`Can't select invalid tab value=${e}`);o(e),d(e),b(e)}),[d,b,s]),tabValues:s}}var b=n(362);const f={tabList:"tabList_J5MA",tabItem:"tabItem_l0OV"};var v=n(4246);function x(e){let{className:t,block:n,selectedValue:a,selectValue:i,tabValues:l}=e;const o=[],{blockElementScrollPositionUntilNextRender:c}=(0,s.o5)(),u=e=>{const t=e.currentTarget,n=o.indexOf(t),r=l[n].value;r!==a&&(c(t),i(r))},d=e=>{let t=null;switch(e.key){case"Enter":u(e);break;case"ArrowRight":{const n=o.indexOf(e.currentTarget)+1;t=o[n]??o[0];break}case"ArrowLeft":{const n=o.indexOf(e.currentTarget)-1;t=o[n]??o[o.length-1];break}}t?.focus()};return(0,v.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,r.Z)("tabs",{"tabs--block":n},t),children:l.map((e=>{let{value:t,label:n,attributes:s}=e;return(0,v.jsx)("li",{role:"tab",tabIndex:a===t?0:-1,"aria-selected":a===t,ref:e=>o.push(e),onKeyDown:d,onClick:u,...s,className:(0,r.Z)("tabs__item",f.tabItem,s?.className,{"tabs__item--active":a===t}),children:n??t},t)}))})}function j(e){let{lazy:t,children:n,selectedValue:r}=e;const s=(Array.isArray(n)?n:[n]).filter(Boolean);if(t){const e=s.find((e=>e.props.value===r));return e?(0,a.cloneElement)(e,{className:"margin-top--md"}):null}return(0,v.jsx)("div",{className:"margin-top--md",children:s.map(((e,t)=>(0,a.cloneElement)(e,{key:t,hidden:e.props.value!==r})))})}function y(e){const t=g(e);return(0,v.jsxs)("div",{className:(0,r.Z)("tabs-container",f.tabList),children:[(0,v.jsx)(x,{...e,...t}),(0,v.jsx)(j,{...e,...t})]})}function w(e){const t=(0,b.Z)();return(0,v.jsx)(y,{...e,children:d(e.children)},String(t))}},2822:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>u,contentTitle:()=>o,default:()=>h,frontMatter:()=>l,metadata:()=>c,toc:()=>d});var a=n(4246),r=n(1670),s=n(8447),i=n(2599);const l={},o="Prisma adapter",c={id:"plugins/available-plugins/transactional/prisma-adapter",title:"Prisma adapter",description:"Installation",source:"@site/docs/06_plugins/01_available-plugins/01-transactional/01-prisma-adapter.md",sourceDirName:"06_plugins/01_available-plugins/01-transactional",slug:"/plugins/available-plugins/transactional/prisma-adapter",permalink:"/nestjs-cls/plugins/available-plugins/transactional/prisma-adapter",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/06_plugins/01_available-plugins/01-transactional/01-prisma-adapter.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"@nestjs-cls/transactional",permalink:"/nestjs-cls/plugins/available-plugins/transactional/"},next:{title:"Creating a custom adapter",permalink:"/nestjs-cls/plugins/available-plugins/transactional/creating-custom-adapter"}},u={},d=[{value:"Installation",id:"installation",level:2},{value:"Registration",id:"registration",level:2},{value:"Typing & usage",id:"typing--usage",level:2},{value:"Example",id:"example",level:2},{value:"Caveats",id:"caveats",level:2}];function p(e){const t={code:"code",h1:"h1",h2:"h2",p:"p",pre:"pre",...(0,r.a)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.h1,{id:"prisma-adapter",children:"Prisma adapter"}),"\n",(0,a.jsx)(t.h2,{id:"installation",children:"Installation"}),"\n",(0,a.jsxs)(s.Z,{children:[(0,a.jsx)(i.Z,{value:"npm",label:"npm",default:!0,children:(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-bash",children:"npm install @nestjs-cls/transactional-adapter-prisma\n"})})}),(0,a.jsx)(i.Z,{value:"yarn",label:"yarn",children:(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-bash",children:"yarn add @nestjs-cls/transactional-adapter-prisma\n"})})}),(0,a.jsx)(i.Z,{value:"pnpm",label:"pnpm",children:(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-bash",children:"pnpm add @nestjs-cls/transactional-adapter-prisma\n"})})})]}),"\n",(0,a.jsx)(t.h2,{id:"registration",children:"Registration"}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-ts",children:"ClsModule.forRoot({\n plugins: [\n new ClsPluginTransactional({\n imports: [\n // module in which the PrismaClient is provided\n PrismaModule\n ],\n adapter: new TransactionalAdapterPrisma({\n // the injection token of the PrismaClient\n prismaInjectionToken: PrismaService,\n }),\n }),\n ],\n}),\n"})}),"\n",(0,a.jsx)(t.h2,{id:"typing--usage",children:"Typing & usage"}),"\n",(0,a.jsxs)(t.p,{children:["The ",(0,a.jsx)(t.code,{children:"tx"})," property on the ",(0,a.jsx)(t.code,{children:"TransactionHost "})," refers to the transactional ",(0,a.jsx)(t.code,{children:"PrismaClient"})," instance when used in a transactional context. It is the instance that is passed to the ",(0,a.jsx)(t.code,{children:"prisma.$transaction(( tx ) => { ... })"})," callback."]}),"\n",(0,a.jsxs)(t.p,{children:["Outside of a transactional context, it refers to the regular ",(0,a.jsx)(t.code,{children:"PrismaClient"})," instance (but is typed as the transactional one)."]}),"\n",(0,a.jsx)(t.h2,{id:"example",children:"Example"}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-ts",metastring:'title="user.service.ts"',children:"@Injectable()\nclass UserService {\n constructor(private readonly userRepository: UserRepository) {}\n\n @Transactional()\n async runTransaction() {\n // highlight-start\n // both methods are executed in the same transaction\n const user = await this.userRepository.createUser('John');\n const foundUser = await this.userRepository.getUserById(r1.id);\n // highlight-end\n assert(foundUser.id === user.id);\n }\n}\n"})}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-ts",metastring:'title="user.repository.ts"',children:"@Injectable()\nclass UserRepository {\n constructor(\n private readonly txHost: TransactionHost ,\n ) {}\n\n async getUserById(id: number) {\n // highlight-start\n // txHost.tx is typed as the transactional PrismaClient\n return this.txHost.tx.user.findUnique({ where: { id } });\n // highlight-end\n }\n\n async createUser(name: string) {\n return this.txHost.tx.user.create({\n data: { name: name, email: `${name}@email.com` },\n });\n }\n}\n"})}),"\n",(0,a.jsx)(t.h2,{id:"caveats",children:"Caveats"}),"\n",(0,a.jsxs)(t.p,{children:["Since Prisma generates its own client to ",(0,a.jsx)(t.code,{children:"node_modules"}),", this plugin works with the assumption that the types for the client are available as ",(0,a.jsx)(t.code,{children:"@prisma/client"}),". If you have a different setup, you might need to use ",(0,a.jsx)(t.code,{children:"declare module '@prisma/client'"})," to make typescript happy."]})]})}function h(e={}){const{wrapper:t}={...(0,r.a)(),...e.components};return t?(0,a.jsx)(t,{...e,children:(0,a.jsx)(p,{...e})}):p(e)}},1670:(e,t,n)=>{n.d(t,{Z:()=>l,a:()=>i});var a=n(7378);const r={},s=a.createContext(r);function i(e){const t=a.useContext(s);return a.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function l(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),a.createElement(s.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/3ac8ff5d.22ee9ecc.js b/assets/js/3ac8ff5d.22ee9ecc.js deleted file mode 100755 index 23d5e45..0000000 --- a/assets/js/3ac8ff5d.22ee9ecc.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[332],{5318:(e,t,r)=>{r.d(t,{Zo:()=>u,kt:()=>h});var n=r(7378);function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t =0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n =0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var c=n.createContext({}),l=function(e){var t=n.useContext(c),r=t;return e&&(r="function"==typeof e?e(t):a(a({},t),e)),r},u=function(e){var t=l(e.components);return n.createElement(c.Provider,{value:t},e.children)},p="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},f=n.forwardRef((function(e,t){var r=e.components,o=e.mdxType,i=e.originalType,c=e.parentName,u=s(e,["components","mdxType","originalType","parentName"]),p=l(r),f=o,h=p["".concat(c,".").concat(f)]||p[f]||d[f]||i;return r?n.createElement(h,a(a({ref:t},u),{},{components:r})):n.createElement(h,a({ref:t},u))}));function h(e,t){var r=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var i=r.length,a=new Array(i);a[0]=f;var s={};for(var c in t)hasOwnProperty.call(t,c)&&(s[c]=t[c]);s.originalType=e,s[p]="string"==typeof e?e:o,a[1]=s;for(var l=2;l{r.r(t),r.d(t,{assets:()=>c,contentTitle:()=>a,default:()=>d,frontMatter:()=>i,metadata:()=>s,toc:()=>l});var n=r(5773),o=(r(7378),r(5318));const i={},a="How it works",s={unversionedId:"introduction/how-it-works",id:"introduction/how-it-works",title:"How it works",description:"Continuation-local storage provides a common space for storing and retrieving data throughout the life of a function/callback call chain. In NestJS, this allows for sharing request data across the lifetime of a single request - without the need for request-scoped providers. It also makes it easy to track and log request ids throughout the whole application.",source:"@site/docs/01_introduction/03_how-it-works.md",sourceDirName:"01_introduction",slug:"/introduction/how-it-works",permalink:"/nestjs-cls/introduction/how-it-works",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/01_introduction/03_how-it-works.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Quick Start",permalink:"/nestjs-cls/introduction/quick-start"},next:{title:"Setting up the CLS context",permalink:"/nestjs-cls/setting-up-cls-context/"}},c={},l=[],u={toc:l},p="wrapper";function d(e){let{components:t,...r}=e;return(0,o.kt)(p,(0,n.Z)({},u,r,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"how-it-works"},"How it works"),(0,o.kt)("p",null,"Continuation-local storage provides a common space for storing and retrieving data throughout the life of a function/callback call chain. In NestJS, this allows for sharing request data across the lifetime of a single request - without the need for request-scoped providers. It also makes it easy to track and log request ids throughout the whole application."),(0,o.kt)("p",null,"To make CLS work, it is required to set up the CLS context first. This is done by calling ",(0,o.kt)("inlineCode",{parentName:"p"},"cls.run()")," (or ",(0,o.kt)("inlineCode",{parentName:"p"},"cls.enter()"),", see ",(0,o.kt)("a",{parentName:"p",href:"/nestjs-cls/considerations/security"},"Security considerations")," for more info) somewhere in the app. Once that is set up, anything that is called within the same callback chain has access to the same storage with ",(0,o.kt)("inlineCode",{parentName:"p"},"cls.set()")," and ",(0,o.kt)("inlineCode",{parentName:"p"},"cls.get()"),"."))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/3ac8ff5d.a4c650c8.js b/assets/js/3ac8ff5d.a4c650c8.js new file mode 100644 index 0000000..2f7235b --- /dev/null +++ b/assets/js/3ac8ff5d.a4c650c8.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[332],{4760:(t,e,o)=>{o.r(e),o.d(e,{assets:()=>a,contentTitle:()=>r,default:()=>h,frontMatter:()=>i,metadata:()=>c,toc:()=>l});var s=o(4246),n=o(1670);const i={},r="How it works",c={id:"introduction/how-it-works",title:"How it works",description:"Continuation-local storage provides a common space for storing and retrieving data throughout the life of a function/callback call chain. In NestJS, this allows for sharing request data across the lifetime of a single request - without the need for request-scoped providers. It also makes it easy to track and log request ids throughout the whole application.",source:"@site/docs/01_introduction/03_how-it-works.md",sourceDirName:"01_introduction",slug:"/introduction/how-it-works",permalink:"/nestjs-cls/introduction/how-it-works",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/01_introduction/03_how-it-works.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Quick Start",permalink:"/nestjs-cls/introduction/quick-start"},next:{title:"Setting up the CLS context",permalink:"/nestjs-cls/setting-up-cls-context/"}},a={},l=[];function d(t){const e={a:"a",code:"code",h1:"h1",p:"p",...(0,n.a)(),...t.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e.h1,{id:"how-it-works",children:"How it works"}),"\n",(0,s.jsx)(e.p,{children:"Continuation-local storage provides a common space for storing and retrieving data throughout the life of a function/callback call chain. In NestJS, this allows for sharing request data across the lifetime of a single request - without the need for request-scoped providers. It also makes it easy to track and log request ids throughout the whole application."}),"\n",(0,s.jsxs)(e.p,{children:["To make CLS work, it is required to set up the CLS context first. This is done by calling ",(0,s.jsx)(e.code,{children:"cls.run()"})," (or ",(0,s.jsx)(e.code,{children:"cls.enter()"}),", see ",(0,s.jsx)(e.a,{href:"/nestjs-cls/considerations/security",children:"Security considerations"})," for more info) somewhere in the app. Once that is set up, anything that is called within the same callback chain has access to the same storage with ",(0,s.jsx)(e.code,{children:"cls.set()"})," and ",(0,s.jsx)(e.code,{children:"cls.get()"}),"."]})]})}function h(t={}){const{wrapper:e}={...(0,n.a)(),...t.components};return e?(0,s.jsx)(e,{...t,children:(0,s.jsx)(d,{...t})}):d(t)}},1670:(t,e,o)=>{o.d(e,{Z:()=>c,a:()=>r});var s=o(7378);const n={},i=s.createContext(n);function r(t){const e=s.useContext(i);return s.useMemo((function(){return"function"==typeof t?t(e):{...e,...t}}),[e,t])}function c(t){let e;return e=t.disableParentContext?"function"==typeof t.components?t.components(n):t.components||n:r(t.components),s.createElement(i.Provider,{value:e},t.children)}}}]); \ No newline at end of file diff --git a/assets/js/3b39bba3.4068951c.js b/assets/js/3b39bba3.4068951c.js deleted file mode 100755 index 24ba4cf..0000000 --- a/assets/js/3b39bba3.4068951c.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[546],{5318:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>f});var r=n(7378);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t =0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var u=r.createContext({}),i=function(e){var t=r.useContext(u),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=i(e.components);return r.createElement(u.Provider,{value:t},e.children)},p="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},m=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,l=e.originalType,u=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),p=i(n),m=a,f=p["".concat(u,".").concat(m)]||p[m]||d[m]||l;return n?r.createElement(f,o(o({ref:t},c),{},{components:n})):r.createElement(f,o({ref:t},c))}));function f(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var l=n.length,o=new Array(l);o[0]=m;var s={};for(var u in t)hasOwnProperty.call(t,u)&&(s[u]=t[u]);s.originalType=e,s[p]="string"==typeof e?e:a,o[1]=s;for(var i=2;i {n.r(t),n.d(t,{assets:()=>x,contentTitle:()=>I,default:()=>_,frontMatter:()=>j,metadata:()=>N,toc:()=>V});var r=n(5773),a=n(7378),l=n(5318),o=n(8944),s=n(3457),u=n(3620),i=n(654),c=n(784),p=n(1819);function d(e){return function(e){return a.Children.map(e,(e=>{if(!e||(0,a.isValidElement)(e)&&function(e){const{props:t}=e;return!!t&&"object"==typeof t&&"value"in t}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}(e).map((e=>{let{props:{value:t,label:n,attributes:r,default:a}}=e;return{value:t,label:n,attributes:r,default:a}}))}function m(e){const{values:t,children:n}=e;return(0,a.useMemo)((()=>{const e=t??d(n);return function(e){const t=(0,c.l)(e,((e,t)=>e.value===t.value));if(t.length>0)throw new Error(`Docusaurus error: Duplicate values "${t.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[t,n])}function f(e){let{value:t,tabValues:n}=e;return n.some((e=>e.value===t))}function b(e){let{queryString:t=!1,groupId:n}=e;const r=(0,u.k6)(),l=function(e){let{queryString:t=!1,groupId:n}=e;if("string"==typeof t)return t;if(!1===t)return null;if(!0===t&&!n)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return n??null}({queryString:t,groupId:n});return[(0,i._X)(l),(0,a.useCallback)((e=>{if(!l)return;const t=new URLSearchParams(r.location.search);t.set(l,e),r.replace({...r.location,search:t.toString()})}),[l,r])]}function y(e){const{defaultValue:t,queryString:n=!1,groupId:r}=e,l=m(e),[o,s]=(0,a.useState)((()=>function(e){let{defaultValue:t,tabValues:n}=e;if(0===n.length)throw new Error("Docusaurus error: the component requires at least one children component");if(t){if(!f({value:t,tabValues:n}))throw new Error(`Docusaurus error: The has a defaultValue "${t}" but none of its children has the corresponding value. Available values are: ${n.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return t}const r=n.find((e=>e.default))??n[0];if(!r)throw new Error("Unexpected error: 0 tabValues");return r.value}({defaultValue:t,tabValues:l}))),[u,i]=b({queryString:n,groupId:r}),[c,d]=function(e){let{groupId:t}=e;const n=function(e){return e?`docusaurus.tab.${e}`:null}(t),[r,l]=(0,p.Nk)(n);return[r,(0,a.useCallback)((e=>{n&&l.set(e)}),[n,l])]}({groupId:r}),y=(()=>{const e=u??c;return f({value:e,tabValues:l})?e:null})();(0,a.useLayoutEffect)((()=>{y&&s(y)}),[y]);return{selectedValue:o,selectValue:(0,a.useCallback)((e=>{if(!f({value:e,tabValues:l}))throw new Error(`Can't select invalid tab value=${e}`);s(e),i(e),d(e)}),[i,d,l]),tabValues:l}}var h=n(6457);const v={tabList:"tabList_J5MA",tabItem:"tabItem_l0OV"};function g(e){let{className:t,block:n,selectedValue:l,selectValue:u,tabValues:i}=e;const c=[],{blockElementScrollPositionUntilNextRender:p}=(0,s.o5)(),d=e=>{const t=e.currentTarget,n=c.indexOf(t),r=i[n].value;r!==l&&(p(t),u(r))},m=e=>{let t=null;switch(e.key){case"Enter":d(e);break;case"ArrowRight":{const n=c.indexOf(e.currentTarget)+1;t=c[n]??c[0];break}case"ArrowLeft":{const n=c.indexOf(e.currentTarget)-1;t=c[n]??c[c.length-1];break}}t?.focus()};return a.createElement("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,o.Z)("tabs",{"tabs--block":n},t)},i.map((e=>{let{value:t,label:n,attributes:s}=e;return a.createElement("li",(0,r.Z)({role:"tab",tabIndex:l===t?0:-1,"aria-selected":l===t,key:t,ref:e=>c.push(e),onKeyDown:m,onClick:d},s,{className:(0,o.Z)("tabs__item",v.tabItem,s?.className,{"tabs__item--active":l===t})}),n??t)})))}function k(e){let{lazy:t,children:n,selectedValue:r}=e;const l=(Array.isArray(n)?n:[n]).filter(Boolean);if(t){const e=l.find((e=>e.props.value===r));return e?(0,a.cloneElement)(e,{className:"margin-top--md"}):null}return a.createElement("div",{className:"margin-top--md"},l.map(((e,t)=>(0,a.cloneElement)(e,{key:t,hidden:e.props.value!==r}))))}function w(e){const t=y(e);return a.createElement("div",{className:(0,o.Z)("tabs-container",v.tabList)},a.createElement(g,(0,r.Z)({},e,t)),a.createElement(k,(0,r.Z)({},e,t)))}function E(e){const t=(0,h.Z)();return a.createElement(w,(0,r.Z)({key:String(t)},e))}const T={tabItem:"tabItem_wHwb"};function O(e){let{children:t,hidden:n,className:r}=e;return a.createElement("div",{role:"tabpanel",className:(0,o.Z)(T.tabItem,r),hidden:n},t)}const j={},I="Installation",N={unversionedId:"introduction/installation",id:"introduction/installation",title:"Installation",description:"Install as any other NPM package using your favorite package manager.",source:"@site/docs/01_introduction/01_installation.md",sourceDirName:"01_introduction",slug:"/introduction/installation",permalink:"/nestjs-cls/introduction/installation",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/01_introduction/01_installation.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Introduction",permalink:"/nestjs-cls/"},next:{title:"Quick Start",permalink:"/nestjs-cls/introduction/quick-start"}},x={},V=[],P={toc:V},S="wrapper";function _(e){let{components:t,...n}=e;return(0,l.kt)(S,(0,r.Z)({},P,n,{components:t,mdxType:"MDXLayout"}),(0,l.kt)("h1",{id:"installation"},"Installation"),(0,l.kt)("p",null,"Install as any other NPM package using your favorite package manager."),(0,l.kt)(E,{mdxType:"Tabs"},(0,l.kt)(O,{value:"apple",label:"npm",default:!0,mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-sh"},"npm install nestjs-cls\n"))),(0,l.kt)(O,{value:"orange",label:"yarn",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-sh"},"yarn add nestjs-cls\n"))),(0,l.kt)(O,{value:"banana",label:"pnpm",mdxType:"TabItem"},(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-sh"},"pnpm add nestjs-cls\n")))),(0,l.kt)("admonition",{type:"info"},(0,l.kt)("p",{parentName:"admonition"},"This module requires additional peer deps, like the ",(0,l.kt)("inlineCode",{parentName:"p"},"@nestjs/core")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"@nestjs/common")," libraries, but it is assumed those are already installed.")))}_.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/3b39bba3.b1845d7a.js b/assets/js/3b39bba3.b1845d7a.js new file mode 100644 index 0000000..f9a038b --- /dev/null +++ b/assets/js/3b39bba3.b1845d7a.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[546],{2599:(e,t,n)=>{n.d(t,{Z:()=>l});n(7378);var a=n(624);const r={tabItem:"tabItem_wHwb"};var s=n(4246);function l(e){let{children:t,hidden:n,className:l}=e;return(0,s.jsx)("div",{role:"tabpanel",className:(0,a.Z)(r.tabItem,l),hidden:n,children:t})}},8447:(e,t,n)=>{n.d(t,{Z:()=>k});var a=n(7378),r=n(624),s=n(9169),l=n(3620),o=n(9749),i=n(8981),u=n(56),c=n(8796);function d(e){return a.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,a.isValidElement)(e)&&function(e){const{props:t}=e;return!!t&&"object"==typeof t&&"value"in t}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function p(e){const{values:t,children:n}=e;return(0,a.useMemo)((()=>{const e=t??function(e){return d(e).map((e=>{let{props:{value:t,label:n,attributes:a,default:r}}=e;return{value:t,label:n,attributes:a,default:r}}))}(n);return function(e){const t=(0,u.l)(e,((e,t)=>e.value===t.value));if(t.length>0)throw new Error(`Docusaurus error: Duplicate values "${t.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[t,n])}function h(e){let{value:t,tabValues:n}=e;return n.some((e=>e.value===t))}function m(e){let{queryString:t=!1,groupId:n}=e;const r=(0,l.k6)(),s=function(e){let{queryString:t=!1,groupId:n}=e;if("string"==typeof t)return t;if(!1===t)return null;if(!0===t&&!n)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return n??null}({queryString:t,groupId:n});return[(0,i._X)(s),(0,a.useCallback)((e=>{if(!s)return;const t=new URLSearchParams(r.location.search);t.set(s,e),r.replace({...r.location,search:t.toString()})}),[s,r])]}function f(e){const{defaultValue:t,queryString:n=!1,groupId:r}=e,s=p(e),[l,i]=(0,a.useState)((()=>function(e){let{defaultValue:t,tabValues:n}=e;if(0===n.length)throw new Error("Docusaurus error: the component requires at least one children component");if(t){if(!h({value:t,tabValues:n}))throw new Error(`Docusaurus error: The has a defaultValue "${t}" but none of its children has the corresponding value. Available values are: ${n.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return t}const a=n.find((e=>e.default))??n[0];if(!a)throw new Error("Unexpected error: 0 tabValues");return a.value}({defaultValue:t,tabValues:s}))),[u,d]=m({queryString:n,groupId:r}),[f,b]=function(e){let{groupId:t}=e;const n=function(e){return e?`docusaurus.tab.${e}`:null}(t),[r,s]=(0,c.Nk)(n);return[r,(0,a.useCallback)((e=>{n&&s.set(e)}),[n,s])]}({groupId:r}),v=(()=>{const e=u??f;return h({value:e,tabValues:s})?e:null})();(0,o.Z)((()=>{v&&i(v)}),[v]);return{selectedValue:l,selectValue:(0,a.useCallback)((e=>{if(!h({value:e,tabValues:s}))throw new Error(`Can't select invalid tab value=${e}`);i(e),d(e),b(e)}),[d,b,s]),tabValues:s}}var b=n(362);const v={tabList:"tabList_J5MA",tabItem:"tabItem_l0OV"};var g=n(4246);function j(e){let{className:t,block:n,selectedValue:a,selectValue:l,tabValues:o}=e;const i=[],{blockElementScrollPositionUntilNextRender:u}=(0,s.o5)(),c=e=>{const t=e.currentTarget,n=i.indexOf(t),r=o[n].value;r!==a&&(u(t),l(r))},d=e=>{let t=null;switch(e.key){case"Enter":c(e);break;case"ArrowRight":{const n=i.indexOf(e.currentTarget)+1;t=i[n]??i[0];break}case"ArrowLeft":{const n=i.indexOf(e.currentTarget)-1;t=i[n]??i[i.length-1];break}}t?.focus()};return(0,g.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,r.Z)("tabs",{"tabs--block":n},t),children:o.map((e=>{let{value:t,label:n,attributes:s}=e;return(0,g.jsx)("li",{role:"tab",tabIndex:a===t?0:-1,"aria-selected":a===t,ref:e=>i.push(e),onKeyDown:d,onClick:c,...s,className:(0,r.Z)("tabs__item",v.tabItem,s?.className,{"tabs__item--active":a===t}),children:n??t},t)}))})}function x(e){let{lazy:t,children:n,selectedValue:r}=e;const s=(Array.isArray(n)?n:[n]).filter(Boolean);if(t){const e=s.find((e=>e.props.value===r));return e?(0,a.cloneElement)(e,{className:"margin-top--md"}):null}return(0,g.jsx)("div",{className:"margin-top--md",children:s.map(((e,t)=>(0,a.cloneElement)(e,{key:t,hidden:e.props.value!==r})))})}function y(e){const t=f(e);return(0,g.jsxs)("div",{className:(0,r.Z)("tabs-container",v.tabList),children:[(0,g.jsx)(j,{...e,...t}),(0,g.jsx)(x,{...e,...t})]})}function k(e){const t=(0,b.Z)();return(0,g.jsx)(y,{...e,children:d(e.children)},String(t))}},7309:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>h,frontMatter:()=>o,metadata:()=>u,toc:()=>d});var a=n(4246),r=n(1670),s=n(8447),l=n(2599);const o={},i="Installation",u={id:"introduction/installation",title:"Installation",description:"Install as any other NPM package using your favorite package manager.",source:"@site/docs/01_introduction/01_installation.md",sourceDirName:"01_introduction",slug:"/introduction/installation",permalink:"/nestjs-cls/introduction/installation",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/01_introduction/01_installation.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Introduction",permalink:"/nestjs-cls/"},next:{title:"Quick Start",permalink:"/nestjs-cls/introduction/quick-start"}},c={},d=[];function p(e){const t={admonition:"admonition",code:"code",h1:"h1",p:"p",pre:"pre",...(0,r.a)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.h1,{id:"installation",children:"Installation"}),"\n",(0,a.jsx)(t.p,{children:"Install as any other NPM package using your favorite package manager."}),"\n",(0,a.jsxs)(s.Z,{children:[(0,a.jsx)(l.Z,{value:"npm",label:"npm",default:!0,children:(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-sh",children:"npm install nestjs-cls\n"})})}),(0,a.jsx)(l.Z,{value:"yarn",label:"yarn",children:(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-sh",children:"yarn add nestjs-cls\n"})})}),(0,a.jsx)(l.Z,{value:"pnpm",label:"pnpm",children:(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-sh",children:"pnpm add nestjs-cls\n"})})})]}),"\n",(0,a.jsx)(t.admonition,{type:"info",children:(0,a.jsxs)(t.p,{children:["This module requires additional peer deps, like the ",(0,a.jsx)(t.code,{children:"@nestjs/core"})," and ",(0,a.jsx)(t.code,{children:"@nestjs/common"})," libraries, but it is assumed those are already installed."]})})]})}function h(e={}){const{wrapper:t}={...(0,r.a)(),...e.components};return t?(0,a.jsx)(t,{...e,children:(0,a.jsx)(p,{...e})}):p(e)}},1670:(e,t,n)=>{n.d(t,{Z:()=>o,a:()=>l});var a=n(7378);const r={},s=a.createContext(r);function l(e){const t=a.useContext(s);return a.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),a.createElement(s.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/471.006e7ee7.js b/assets/js/471.006e7ee7.js new file mode 100644 index 0000000..3275300 --- /dev/null +++ b/assets/js/471.006e7ee7.js @@ -0,0 +1 @@ +(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[471],{5911:(s,c,e)=>{"use strict";e.d(c,{Z:()=>t});var n=e(8230);const t=n},5352:()=>{}}]); \ No newline at end of file diff --git a/assets/js/49.c17c1426.js b/assets/js/49.c17c1426.js new file mode 100644 index 0000000..0d6c4a7 --- /dev/null +++ b/assets/js/49.c17c1426.js @@ -0,0 +1,2 @@ +/*! For license information please see 49.c17c1426.js.LICENSE.txt */ +(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[49],{2082:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>m});var i=n(1273),r=n.n(i),s=n(5911);s.Z.tokenizer.separator=/[\s\-/]+/;const o=class{constructor(e,t,n,i){void 0===n&&(n="/"),this.searchDocs=e,this.lunrIndex=s.Z.Index.load(t),this.baseUrl=n,this.maxHits=i}getLunrResult(e){return this.lunrIndex.query((function(t){const n=s.Z.tokenizer(e);t.term(n,{boost:10}),t.term(n,{wildcard:s.Z.Query.wildcard.TRAILING})}))}getHit(e,t,n){return{hierarchy:{lvl0:e.pageTitle||e.title,lvl1:0===e.type?null:e.title},url:e.url,version:e.version,_snippetResult:n?{content:{value:n,matchLevel:"full"}}:null,_highlightResult:{hierarchy:{lvl0:{value:0===e.type?t||e.title:e.pageTitle},lvl1:0===e.type?null:{value:t||e.title}}}}}getTitleHit(e,t,n){const i=t[0],r=t[0]+n;let s=e.title.substring(0,i)+''+e.title.substring(i,r)+""+e.title.substring(r,e.title.length);return this.getHit(e,s)}getKeywordHit(e,t,n){const i=t[0],r=t[0]+n;let s=e.title+"
Keywords: "+e.keywords.substring(0,i)+''+e.keywords.substring(i,r)+""+e.keywords.substring(r,e.keywords.length)+"";return this.getHit(e,s)}getContentHit(e,t){const n=t[0],i=t[0]+t[1];let r=n,s=i,o=!0,a=!0;for(let c=0;c<3;c++){const t=e.content.lastIndexOf(" ",r-2),n=e.content.lastIndexOf(".",r-2);if(n>0&&n>t){r=n+1,o=!1;break}if(t<0){r=0,o=!1;break}r=t+1}for(let c=0;c<10;c++){const t=e.content.indexOf(" ",s+1),n=e.content.indexOf(".",s+1);if(n>0&&n'+e.content.substring(n,i)+"",u+=e.content.substring(i,s),a&&(u+=" ..."),this.getHit(e,null,u)}search(e){return new Promise(((t,n)=>{const i=this.getLunrResult(e),r=[];i.length>this.maxHits&&(i.length=this.maxHits),this.titleHitsRes=[],this.contentHitsRes=[],i.forEach((t=>{const n=this.searchDocs[t.ref],{metadata:i}=t.matchData;for(let s in i)if(i[s].title){if(!this.titleHitsRes.includes(t.ref)){const o=i[s].title.position[0];r.push(this.getTitleHit(n,o,e.length)),this.titleHitsRes.push(t.ref)}}else if(i[s].content){const e=i[s].content.position[0];r.push(this.getContentHit(n,e))}else if(i[s].keywords){const o=i[s].keywords.position[0];r.push(this.getKeywordHit(n,o,e.length)),this.titleHitsRes.push(t.ref)}})),r.length>this.maxHits&&(r.length=this.maxHits),t(r)}))}};var a=n(2500),u=n.n(a);const c="algolia-docsearch",l=`${c}-suggestion`,h={suggestion:`\n \n \n {{{category}}}\n\n\n\n \n `,suggestionSimple:`\n\n {{{subcategory}}}\n\n {{#isTextOrSubcategoryNonEmpty}}\n\n\n {{/isTextOrSubcategoryNonEmpty}}\n{{{subcategory}}}\n{{{title}}}\n {{#text}}{{{text}}}{{/text}}\n {{#version}}{{version}}{{/version}}\n\n\n `,footer:`\n \n `,empty:`\n\n {{^isLvl0}}\n {{{category}}}\n {{^isLvl1}}\n {{^isLvl1EmptyOrDuplicate}}\n \n {{{subcategory}}}\n \n {{/isLvl1EmptyOrDuplicate}}\n {{/isLvl1}}\n {{/isLvl0}}\n\n\n {{#isLvl2}}\n {{{title}}}\n {{/isLvl2}}\n {{#isLvl1}}\n {{{subcategory}}}\n {{/isLvl1}}\n {{#isLvl0}}\n {{{category}}}\n {{/isLvl0}}\n\n\n {{#text}}\n\n\n\n {{/text}}\n{{{text}}}\n\n\n `,searchBox:'\n \n\n \n '};var p=n(3847),d=n.n(p);const f={mergeKeyWithParent(e,t){if(void 0===e[t])return e;if("object"!=typeof e[t])return e;const n=d().extend({},e,e[t]);return delete n[t],n},groupBy(e,t){const n={};return d().each(e,((e,i)=>{if(void 0===i[t])throw new Error(`[groupBy]: Object has no key ${t}`);let r=i[t];"string"==typeof r&&(r=r.toLowerCase()),Object.prototype.hasOwnProperty.call(n,r)||(n[r]=[]),n[r].push(i)})),n},values:e=>Object.keys(e).map((t=>e[t])),flatten(e){const t=[];return e.forEach((e=>{Array.isArray(e)?e.forEach((e=>{t.push(e)})):t.push(e)})),t},flattenAndFlagFirst(e,t){const n=this.values(e).map((e=>e.map(((e,n)=>(e[t]=0===n,e)))));return this.flatten(n)},compact(e){const t=[];return e.forEach((e=>{e&&t.push(e)})),t},getHighlightedValue:(e,t)=>e._highlightResult&&e._highlightResult.hierarchy_camel&&e._highlightResult.hierarchy_camel[t]&&e._highlightResult.hierarchy_camel[t].matchLevel&&"none"!==e._highlightResult.hierarchy_camel[t].matchLevel&&e._highlightResult.hierarchy_camel[t].value?e._highlightResult.hierarchy_camel[t].value:e._highlightResult&&e._highlightResult&&e._highlightResult[t]&&e._highlightResult[t].value?e._highlightResult[t].value:e[t],getSnippetedValue(e,t){if(!e._snippetResult||!e._snippetResult[t]||!e._snippetResult[t].value)return e[t];let n=e._snippetResult[t].value;return n[0]!==n[0].toUpperCase()&&(n=`\u2026${n}`),-1===[".","!","?"].indexOf(n[n.length-1])&&(n=`${n}\u2026`),n},deepClone:e=>JSON.parse(JSON.stringify(e))};class g{constructor(e){let{searchDocs:t,searchIndex:n,inputSelector:i,debug:r=!1,baseUrl:s="/",queryDataCallback:a=null,autocompleteOptions:c={debug:!1,hint:!1,autoselect:!0},transformData:l=!1,queryHook:p=!1,handleSelected:f=!1,enhancedSearchInput:m=!1,layout:y="column",maxHits:v=5}=e;this.input=g.getInputFromSelector(i),this.queryDataCallback=a||null;const x=!(!c||!c.debug)&&c.debug;c.debug=r||x,this.autocompleteOptions=c,this.autocompleteOptions.cssClasses=this.autocompleteOptions.cssClasses||{},this.autocompleteOptions.cssClasses.prefix=this.autocompleteOptions.cssClasses.prefix||"ds";const b=this.input&&"function"==typeof this.input.attr&&this.input.attr("aria-label");this.autocompleteOptions.ariaLabel=this.autocompleteOptions.ariaLabel||b||"search input",this.isSimpleLayout="simple"===y,this.client=new o(t,n,s,v),m&&(this.input=g.injectSearchBox(this.input)),this.autocomplete=u()(this.input,c,[{source:this.getAutocompleteSource(l,p),templates:{suggestion:g.getSuggestionTemplate(this.isSimpleLayout),footer:h.footer,empty:g.getEmptyTemplate()}}]);const w=f;this.handleSelected=w||this.handleSelected,w&&d()(".algolia-autocomplete").on("click",".ds-suggestions a",(e=>{e.preventDefault()})),this.autocomplete.on("autocomplete:selected",this.handleSelected.bind(null,this.autocomplete.autocomplete)),this.autocomplete.on("autocomplete:shown",this.handleShown.bind(null,this.input)),m&&g.bindSearchBoxEvent(),document.addEventListener("keydown",(e=>{(e.ctrlKey||e.metaKey)&&"k"==e.key&&(this.input.focus(),e.preventDefault())}))}static injectSearchBox(e){e.before(h.searchBox);const t=e.prev().prev().find("input");return e.remove(),t}static bindSearchBoxEvent(){d()('.searchbox [type="reset"]').on("click",(function(){d()("input#docsearch").focus(),d()(this).addClass("hide"),u().autocomplete.setVal("")})),d()("input#docsearch").on("keyup",(()=>{const e=document.querySelector("input#docsearch"),t=document.querySelector('.searchbox [type="reset"]');t.className="searchbox__reset",0===e.value.length&&(t.className+=" hide")}))}static getInputFromSelector(e){const t=d()(e).filter("input");return t.length?d()(t[0]):null}getAutocompleteSource(e,t){return(n,i)=>{t&&(n=t(n)||n),this.client.search(n).then((t=>{this.queryDataCallback&&"function"==typeof this.queryDataCallback&&this.queryDataCallback(t),e&&(t=e(t)||t),i(g.formatHits(t))}))}}static formatHits(e){const t=f.deepClone(e).map((e=>(e._highlightResult&&(e._highlightResult=f.mergeKeyWithParent(e._highlightResult,"hierarchy")),f.mergeKeyWithParent(e,"hierarchy"))));let n=f.groupBy(t,"lvl0");return d().each(n,((e,t)=>{const i=f.groupBy(t,"lvl1"),r=f.flattenAndFlagFirst(i,"isSubCategoryHeader");n[e]=r})),n=f.flattenAndFlagFirst(n,"isCategoryHeader"),n.map((e=>{const t=g.formatURL(e),n=f.getHighlightedValue(e,"lvl0"),i=f.getHighlightedValue(e,"lvl1")||n,r=f.compact([f.getHighlightedValue(e,"lvl2")||i,f.getHighlightedValue(e,"lvl3"),f.getHighlightedValue(e,"lvl4"),f.getHighlightedValue(e,"lvl5"),f.getHighlightedValue(e,"lvl6")]).join(' '),s=f.getSnippetedValue(e,"content"),o=i&&""!==i||r&&""!==r,a=!i||""===i||i===n,u=r&&""!==r&&r!==i,c=!u&&i&&""!==i&&i!==n,l=!c&&!u,h=e.version;return{isLvl0:l,isLvl1:c,isLvl2:u,isLvl1EmptyOrDuplicate:a,isCategoryHeader:e.isCategoryHeader,isSubCategoryHeader:e.isSubCategoryHeader,isTextOrSubcategoryNonEmpty:o,category:n,subcategory:i,title:r,text:s,url:t,version:h}}))}static formatURL(e){const{url:t,anchor:n}=e;if(t){return-1!==t.indexOf("#")?t:n?`${e.url}#${e.anchor}`:t}return n?`#${e.anchor}`:(console.warn("no anchor nor url for : ",JSON.stringify(e)),null)}static getEmptyTemplate(){return e=>r().compile(h.empty).render(e)}static getSuggestionTemplate(e){const t=e?h.suggestionSimple:h.suggestion,n=r().compile(t);return e=>n.render(e)}handleSelected(e,t,n,i,r){void 0===r&&(r={}),"click"!==r.selectionMethod&&(e.setVal(""),window.location.assign(n.url))}handleShown(e){const t=e.offset().left+e.width()/2;let n=d()(document).width()/2;isNaN(n)&&(n=900);const i=t-n>=0?"algolia-autocomplete-right":"algolia-autocomplete-left",r=t-n<0?"algolia-autocomplete-right":"algolia-autocomplete-left",s=d()(".algolia-autocomplete");s.hasClass(i)||s.addClass(i),s.hasClass(r)&&s.removeClass(r)}}const m=g},2500:(e,t,n)=>{"use strict";e.exports=n(2587)},7360:(e,t,n)=>{"use strict";var i=n(5567),r={wrapper:{position:"relative",display:"inline-block"},hint:{position:"absolute",top:"0",left:"0",borderColor:"transparent",boxShadow:"none",opacity:"1"},input:{position:"relative",verticalAlign:"top",backgroundColor:"transparent"},inputWithNoHint:{position:"relative",verticalAlign:"top"},dropdown:{position:"absolute",top:"100%",left:"0",zIndex:"100",display:"none"},suggestions:{display:"block"},suggestion:{whiteSpace:"nowrap",cursor:"pointer"},suggestionChild:{whiteSpace:"normal"},ltr:{left:"0",right:"auto"},rtl:{left:"auto",right:"0"},defaultClasses:{root:"algolia-autocomplete",prefix:"aa",noPrefix:!1,dropdownMenu:"dropdown-menu",input:"input",hint:"hint",suggestions:"suggestions",suggestion:"suggestion",cursor:"cursor",dataset:"dataset",empty:"empty"},appendTo:{wrapper:{position:"absolute",zIndex:"100",display:"none"},input:{},inputWithNoHint:{},dropdown:{display:"block"}}};i.isMsie()&&i.mixin(r.input,{backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)"}),i.isMsie()&&i.isMsie()<=7&&i.mixin(r.input,{marginTop:"-1px"}),e.exports=r},3039:(e,t,n)=>{"use strict";var i="aaDataset",r="aaValue",s="aaDatum",o=n(5567),a=n(7294),u=n(4534),c=n(7360),l=n(8222);function h(e){var t;(e=e||{}).templates=e.templates||{},e.source||o.error("missing source"),e.name&&(t=e.name,!/^[_a-zA-Z0-9-]+$/.test(t))&&o.error("invalid dataset name: "+e.name),this.query=null,this._isEmpty=!0,this.highlight=!!e.highlight,this.name=void 0===e.name||null===e.name?o.getUniqueId():e.name,this.source=e.source,this.displayFn=function(e){return e=e||"value",o.isFunction(e)?e:t;function t(t){return t[e]}}(e.display||e.displayKey),this.debounce=e.debounce,this.cache=!1!==e.cache,this.templates=function(e,t){return{empty:e.empty&&o.templatify(e.empty),header:e.header&&o.templatify(e.header),footer:e.footer&&o.templatify(e.footer),suggestion:e.suggestion||n};function n(e){return"\n\n\n\n\n\n\n No results found for query "{{query}}"\n\n"+t(e)+"
"}}(e.templates,this.displayFn),this.css=o.mixin({},c,e.appendTo?c.appendTo:{}),this.cssClasses=e.cssClasses=o.mixin({},c.defaultClasses,e.cssClasses||{}),this.cssClasses.prefix=e.cssClasses.formattedPrefix||o.formatPrefix(this.cssClasses.prefix,this.cssClasses.noPrefix);var n=o.className(this.cssClasses.prefix,this.cssClasses.dataset);this.$el=e.$menu&&e.$menu.find(n+"-"+this.name).length>0?a.element(e.$menu.find(n+"-"+this.name)[0]):a.element(u.dataset.replace("%CLASS%",this.name).replace("%PREFIX%",this.cssClasses.prefix).replace("%DATASET%",this.cssClasses.dataset)),this.$menu=e.$menu,this.clearCachedSuggestions()}h.extractDatasetName=function(e){return a.element(e).data(i)},h.extractValue=function(e){return a.element(e).data(r)},h.extractDatum=function(e){var t=a.element(e).data(s);return"string"==typeof t&&(t=JSON.parse(t)),t},o.mixin(h.prototype,l,{_render:function(e,t){if(this.$el){var n,c=this,l=[].slice.call(arguments,2);if(this.$el.empty(),n=t&&t.length,this._isEmpty=!n,!n&&this.templates.empty)this.$el.html(function(){var t=[].slice.call(arguments,0);return t=[{query:e,isEmpty:!0}].concat(t),c.templates.empty.apply(this,t)}.apply(this,l)).prepend(c.templates.header?h.apply(this,l):null).append(c.templates.footer?p.apply(this,l):null);else if(n)this.$el.html(function(){var e,n,l=[].slice.call(arguments,0),h=this,p=u.suggestions.replace("%PREFIX%",this.cssClasses.prefix).replace("%SUGGESTIONS%",this.cssClasses.suggestions);return e=a.element(p).css(this.css.suggestions),n=o.map(t,d),e.append.apply(e,n),e;function d(e){var t,n=u.suggestion.replace("%PREFIX%",h.cssClasses.prefix).replace("%SUGGESTION%",h.cssClasses.suggestion);return(t=a.element(n).attr({role:"option",id:["option",Math.floor(1e8*Math.random())].join("-")}).append(c.templates.suggestion.apply(this,[e].concat(l)))).data(i,c.name),t.data(r,c.displayFn(e)||void 0),t.data(s,JSON.stringify(e)),t.children().each((function(){a.element(this).css(h.css.suggestionChild)})),t}}.apply(this,l)).prepend(c.templates.header?h.apply(this,l):null).append(c.templates.footer?p.apply(this,l):null);else if(t&&!Array.isArray(t))throw new TypeError("suggestions must be an array");this.$menu&&this.$menu.addClass(this.cssClasses.prefix+(n?"with":"without")+"-"+this.name).removeClass(this.cssClasses.prefix+(n?"without":"with")+"-"+this.name),this.trigger("rendered",e)}function h(){var t=[].slice.call(arguments,0);return t=[{query:e,isEmpty:!n}].concat(t),c.templates.header.apply(this,t)}function p(){var t=[].slice.call(arguments,0);return t=[{query:e,isEmpty:!n}].concat(t),c.templates.footer.apply(this,t)}},getRoot:function(){return this.$el},update:function(e){function t(t){if(!this.canceled&&e===this.query){var n=[].slice.call(arguments,1);this.cacheSuggestions(e,t,n),this._render.apply(this,[e,t].concat(n))}}if(this.query=e,this.canceled=!1,this.shouldFetchFromCache(e))t.apply(this,[this.cachedSuggestions].concat(this.cachedRenderExtraArgs));else{var n=this,i=function(){n.canceled||n.source(e,t.bind(n))};if(this.debounce){clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout((function(){n.debounceTimeout=null,i()}),this.debounce)}else i()}},cacheSuggestions:function(e,t,n){this.cachedQuery=e,this.cachedSuggestions=t,this.cachedRenderExtraArgs=n},shouldFetchFromCache:function(e){return this.cache&&this.cachedQuery===e&&this.cachedSuggestions&&this.cachedSuggestions.length},clearCachedSuggestions:function(){delete this.cachedQuery,delete this.cachedSuggestions,delete this.cachedRenderExtraArgs},cancel:function(){this.canceled=!0},clear:function(){this.$el&&(this.cancel(),this.$el.empty(),this.trigger("rendered",""))},isEmpty:function(){return this._isEmpty},destroy:function(){this.clearCachedSuggestions(),this.$el=null}}),e.exports=h},2570:(e,t,n)=>{"use strict";var i=n(5567),r=n(7294),s=n(8222),o=n(3039),a=n(7360);function u(e){var t,n,s,o=this;(e=e||{}).menu||i.error("menu is required"),i.isArray(e.datasets)||i.isObject(e.datasets)||i.error("1 or more datasets required"),e.datasets||i.error("datasets is required"),this.isOpen=!1,this.isEmpty=!0,this.minLength=e.minLength||0,this.templates={},this.appendTo=e.appendTo||!1,this.css=i.mixin({},a,e.appendTo?a.appendTo:{}),this.cssClasses=e.cssClasses=i.mixin({},a.defaultClasses,e.cssClasses||{}),this.cssClasses.prefix=e.cssClasses.formattedPrefix||i.formatPrefix(this.cssClasses.prefix,this.cssClasses.noPrefix),t=i.bind(this._onSuggestionClick,this),n=i.bind(this._onSuggestionMouseEnter,this),s=i.bind(this._onSuggestionMouseLeave,this);var c=i.className(this.cssClasses.prefix,this.cssClasses.suggestion);this.$menu=r.element(e.menu).on("mouseenter.aa",c,n).on("mouseleave.aa",c,s).on("click.aa",c,t),this.$container=e.appendTo?e.wrapper:this.$menu,e.templates&&e.templates.header&&(this.templates.header=i.templatify(e.templates.header),this.$menu.prepend(this.templates.header())),e.templates&&e.templates.empty&&(this.templates.empty=i.templatify(e.templates.empty),this.$empty=r.element(''),this.$menu.append(this.$empty),this.$empty.hide()),this.datasets=i.map(e.datasets,(function(t){return function(e,t,n){return new u.Dataset(i.mixin({$menu:e,cssClasses:n},t))}(o.$menu,t,e.cssClasses)})),i.each(this.datasets,(function(e){var t=e.getRoot();t&&0===t.parent().length&&o.$menu.append(t),e.onSync("rendered",o._onRendered,o)})),e.templates&&e.templates.footer&&(this.templates.footer=i.templatify(e.templates.footer),this.$menu.append(this.templates.footer()));var l=this;r.element(window).resize((function(){l._redraw()}))}i.mixin(u.prototype,s,{_onSuggestionClick:function(e){this.trigger("suggestionClicked",r.element(e.currentTarget))},_onSuggestionMouseEnter:function(e){var t=r.element(e.currentTarget);if(!t.hasClass(i.className(this.cssClasses.prefix,this.cssClasses.cursor,!0))){this._removeCursor();var n=this;setTimeout((function(){n._setCursor(t,!1)}),0)}},_onSuggestionMouseLeave:function(e){if(e.relatedTarget&&r.element(e.relatedTarget).closest("."+i.className(this.cssClasses.prefix,this.cssClasses.cursor,!0)).length>0)return;this._removeCursor(),this.trigger("cursorRemoved")},_onRendered:function(e,t){if(this.isEmpty=i.every(this.datasets,(function(e){return e.isEmpty()})),this.isEmpty)if(t.length>=this.minLength&&this.trigger("empty"),this.$empty)if(t.length=this.minLength?this._show():this._hide());this.trigger("datasetRendered")},_hide:function(){this.$container.hide()},_show:function(){this.$container.css("display","block"),this._redraw(),this.trigger("shown")},_redraw:function(){this.isOpen&&this.appendTo&&this.trigger("redrawn")},_getSuggestions:function(){return this.$menu.find(i.className(this.cssClasses.prefix,this.cssClasses.suggestion))},_getCursor:function(){return this.$menu.find(i.className(this.cssClasses.prefix,this.cssClasses.cursor)).first()},_setCursor:function(e,t){e.first().addClass(i.className(this.cssClasses.prefix,this.cssClasses.cursor,!0)).attr("aria-selected","true"),this.trigger("cursorMoved",t)},_removeCursor:function(){this._getCursor().removeClass(i.className(this.cssClasses.prefix,this.cssClasses.cursor,!0)).removeAttr("aria-selected")},_moveCursor:function(e){var t,n,i,r;this.isOpen&&(n=this._getCursor(),t=this._getSuggestions(),this._removeCursor(),-1!==(i=((i=t.index(n)+e)+1)%(t.length+1)-1)?(i<-1&&(i=t.length-1),this._setCursor(r=t.eq(i),!0),this._ensureVisible(r)):this.trigger("cursorRemoved"))},_ensureVisible:function(e){var t,n,i,r;n=(t=e.position().top)+e.height()+parseInt(e.css("margin-top"),10)+parseInt(e.css("margin-bottom"),10),i=this.$menu.scrollTop(),r=this.$menu.height()+parseInt(this.$menu.css("padding-top"),10)+parseInt(this.$menu.css("padding-bottom"),10),t<0?this.$menu.scrollTop(i+t):r {"use strict";var i=n(5567),r=n(7294);function s(e){e&&e.el||i.error("EventBus initialized without el"),this.$el=r.element(e.el)}i.mixin(s.prototype,{trigger:function(e,t,n,r){var s=i.Event("autocomplete:"+e);return this.$el.trigger(s,[t,n,r]),s}}),e.exports=s},8222:(e,t,n)=>{"use strict";var i=n(8194),r=/\s+/;function s(e,t,n,i){var s;if(!n)return this;for(t=t.split(r),n=i?function(e,t){return e.bind?e.bind(t):function(){e.apply(t,[].slice.call(arguments,0))}}(n,i):n,this._callbacks=this._callbacks||{};s=t.shift();)this._callbacks[s]=this._callbacks[s]||{sync:[],async:[]},this._callbacks[s][e].push(n);return this}function o(e,t,n){return function(){for(var i,r=0,s=e.length;!i&&r {"use strict";e.exports={wrapper:'',dropdown:'',dataset:'',suggestions:'',suggestion:''}},2981:(e,t,n)=>{"use strict";var i;i={9:"tab",27:"esc",37:"left",39:"right",13:"enter",38:"up",40:"down"};var r=n(5567),s=n(7294),o=n(8222);function a(e){var t,n,o,a,u,c=this;(e=e||{}).input||r.error("input is missing"),t=r.bind(this._onBlur,this),n=r.bind(this._onFocus,this),o=r.bind(this._onKeydown,this),a=r.bind(this._onInput,this),this.$hint=s.element(e.hint),this.$input=s.element(e.input).on("blur.aa",t).on("focus.aa",n).on("keydown.aa",o),0===this.$hint.length&&(this.setHint=this.getHint=this.clearHint=this.clearHintIfInvalid=r.noop),r.isMsie()?this.$input.on("keydown.aa keypress.aa cut.aa paste.aa",(function(e){i[e.which||e.keyCode]||r.defer(r.bind(c._onInput,c,e))})):this.$input.on("input.aa",a),this.query=this.$input.val(),this.$overflowHelper=(u=this.$input,s.element('').css({position:"absolute",visibility:"hidden",whiteSpace:"pre",fontFamily:u.css("font-family"),fontSize:u.css("font-size"),fontStyle:u.css("font-style"),fontVariant:u.css("font-variant"),fontWeight:u.css("font-weight"),wordSpacing:u.css("word-spacing"),letterSpacing:u.css("letter-spacing"),textIndent:u.css("text-indent"),textRendering:u.css("text-rendering"),textTransform:u.css("text-transform")}).insertAfter(u))}function u(e){return e.altKey||e.ctrlKey||e.metaKey||e.shiftKey}a.normalizeQuery=function(e){return(e||"").replace(/^\s*/g,"").replace(/\s{2,}/g," ")},r.mixin(a.prototype,o,{_onBlur:function(){this.resetInputValue(),this.$input.removeAttr("aria-activedescendant"),this.trigger("blurred")},_onFocus:function(){this.trigger("focused")},_onKeydown:function(e){var t=i[e.which||e.keyCode];this._managePreventDefault(t,e),t&&this._shouldTrigger(t,e)&&this.trigger(t+"Keyed",e)},_onInput:function(){this._checkInputValue()},_managePreventDefault:function(e,t){var n,i,r;switch(e){case"tab":i=this.getHint(),r=this.getInputValue(),n=i&&i!==r&&!u(t);break;case"up":case"down":n=!u(t);break;default:n=!1}n&&t.preventDefault()},_shouldTrigger:function(e,t){var n;if("tab"===e)n=!u(t);else n=!0;return n},_checkInputValue:function(){var e,t,n,i,r;e=this.getInputValue(),i=e,r=this.query,n=!(!(t=a.normalizeQuery(i)===a.normalizeQuery(r))||!this.query)&&this.query.length!==e.length,this.query=e,t?n&&this.trigger("whitespaceChanged",this.query):this.trigger("queryChanged",this.query)},focus:function(){this.$input.focus()},blur:function(){this.$input.blur()},getQuery:function(){return this.query},setQuery:function(e){this.query=e},getInputValue:function(){return this.$input.val()},setInputValue:function(e,t){void 0===e&&(e=this.query),this.$input.val(e),t?this.clearHint():this._checkInputValue()},expand:function(){this.$input.attr("aria-expanded","true")},collapse:function(){this.$input.attr("aria-expanded","false")},setActiveDescendant:function(e){this.$input.attr("aria-activedescendant",e)},removeActiveDescendant:function(){this.$input.removeAttr("aria-activedescendant")},resetInputValue:function(){this.setInputValue(this.query,!0)},getHint:function(){return this.$hint.val()},setHint:function(e){this.$hint.val(e)},clearHint:function(){this.setHint("")},clearHintIfInvalid:function(){var e,t,n;n=(e=this.getInputValue())!==(t=this.getHint())&&0===t.indexOf(e),""!==e&&n&&!this.hasOverflow()||this.clearHint()},getLanguageDirection:function(){return(this.$input.css("direction")||"ltr").toLowerCase()},hasOverflow:function(){var e=this.$input.width()-2;return this.$overflowHelper.text(this.getInputValue()),this.$overflowHelper.width()>=e},isCursorAtEnd:function(){var e,t,n;return e=this.$input.val().length,t=this.$input[0].selectionStart,r.isNumber(t)?t===e:!document.selection||((n=document.selection.createRange()).moveStart("character",-e),e===n.text.length)},destroy:function(){this.$hint.off(".aa"),this.$input.off(".aa"),this.$hint=this.$input=this.$overflowHelper=null}}),e.exports=a},4015:(e,t,n)=>{"use strict";var i="aaAttrs",r=n(5567),s=n(7294),o=n(8924),a=n(2981),u=n(2570),c=n(4534),l=n(7360);function h(e){var t,n;if((e=e||{}).input||r.error("missing input"),this.isActivated=!1,this.debug=!!e.debug,this.autoselect=!!e.autoselect,this.autoselectOnBlur=!!e.autoselectOnBlur,this.openOnFocus=!!e.openOnFocus,this.minLength=r.isNumber(e.minLength)?e.minLength:1,this.autoWidth=void 0===e.autoWidth||!!e.autoWidth,this.clearOnSelected=!!e.clearOnSelected,this.tabAutocomplete=void 0===e.tabAutocomplete||!!e.tabAutocomplete,e.hint=!!e.hint,e.hint&&e.appendTo)throw new Error("[autocomplete.js] hint and appendTo options can't be used at the same time");this.css=e.css=r.mixin({},l,e.appendTo?l.appendTo:{}),this.cssClasses=e.cssClasses=r.mixin({},l.defaultClasses,e.cssClasses||{}),this.cssClasses.prefix=e.cssClasses.formattedPrefix=r.formatPrefix(this.cssClasses.prefix,this.cssClasses.noPrefix),this.listboxId=e.listboxId=[this.cssClasses.root,"listbox",r.getUniqueId()].join("-");var a=function(e){var t,n,o,a;t=s.element(e.input),n=s.element(c.wrapper.replace("%ROOT%",e.cssClasses.root)).css(e.css.wrapper),e.appendTo||"block"!==t.css("display")||"table"!==t.parent().css("display")||n.css("display","table-cell");var u=c.dropdown.replace("%PREFIX%",e.cssClasses.prefix).replace("%DROPDOWN_MENU%",e.cssClasses.dropdownMenu);o=s.element(u).css(e.css.dropdown).attr({role:"listbox",id:e.listboxId}),e.templates&&e.templates.dropdownMenu&&o.html(r.templatify(e.templates.dropdownMenu)());a=t.clone().css(e.css.hint).css(function(e){return{backgroundAttachment:e.css("background-attachment"),backgroundClip:e.css("background-clip"),backgroundColor:e.css("background-color"),backgroundImage:e.css("background-image"),backgroundOrigin:e.css("background-origin"),backgroundPosition:e.css("background-position"),backgroundRepeat:e.css("background-repeat"),backgroundSize:e.css("background-size")}}(t)),a.val("").addClass(r.className(e.cssClasses.prefix,e.cssClasses.hint,!0)).removeAttr("id name placeholder required").prop("readonly",!0).attr({"aria-hidden":"true",autocomplete:"off",spellcheck:"false",tabindex:-1}),a.removeData&&a.removeData();t.data(i,{"aria-autocomplete":t.attr("aria-autocomplete"),"aria-expanded":t.attr("aria-expanded"),"aria-owns":t.attr("aria-owns"),autocomplete:t.attr("autocomplete"),dir:t.attr("dir"),role:t.attr("role"),spellcheck:t.attr("spellcheck"),style:t.attr("style"),type:t.attr("type")}),t.addClass(r.className(e.cssClasses.prefix,e.cssClasses.input,!0)).attr({autocomplete:"off",spellcheck:!1,role:"combobox","aria-autocomplete":e.datasets&&e.datasets[0]&&e.datasets[0].displayKey?"both":"list","aria-expanded":"false","aria-label":e.ariaLabel,"aria-owns":e.listboxId}).css(e.hint?e.css.input:e.css.inputWithNoHint);try{t.attr("dir")||t.attr("dir","auto")}catch(l){}return n=e.appendTo?n.appendTo(s.element(e.appendTo).eq(0)).eq(0):t.wrap(n).parent(),n.prepend(e.hint?a:null).append(o),{wrapper:n,input:t,hint:a,menu:o}}(e);this.$node=a.wrapper;var u=this.$input=a.input;t=a.menu,n=a.hint,e.dropdownMenuContainer&&s.element(e.dropdownMenuContainer).css("position","relative").append(t.css("top","0")),u.on("blur.aa",(function(e){var n=document.activeElement;r.isMsie()&&(t[0]===n||t[0].contains(n))&&(e.preventDefault(),e.stopImmediatePropagation(),r.defer((function(){u.focus()})))})),t.on("mousedown.aa",(function(e){e.preventDefault()})),this.eventBus=e.eventBus||new o({el:u}),this.dropdown=new h.Dropdown({appendTo:e.appendTo,wrapper:this.$node,menu:t,datasets:e.datasets,templates:e.templates,cssClasses:e.cssClasses,minLength:this.minLength}).onSync("suggestionClicked",this._onSuggestionClicked,this).onSync("cursorMoved",this._onCursorMoved,this).onSync("cursorRemoved",this._onCursorRemoved,this).onSync("opened",this._onOpened,this).onSync("closed",this._onClosed,this).onSync("shown",this._onShown,this).onSync("empty",this._onEmpty,this).onSync("redrawn",this._onRedrawn,this).onAsync("datasetRendered",this._onDatasetRendered,this),this.input=new h.Input({input:u,hint:n}).onSync("focused",this._onFocused,this).onSync("blurred",this._onBlurred,this).onSync("enterKeyed",this._onEnterKeyed,this).onSync("tabKeyed",this._onTabKeyed,this).onSync("escKeyed",this._onEscKeyed,this).onSync("upKeyed",this._onUpKeyed,this).onSync("downKeyed",this._onDownKeyed,this).onSync("leftKeyed",this._onLeftKeyed,this).onSync("rightKeyed",this._onRightKeyed,this).onSync("queryChanged",this._onQueryChanged,this).onSync("whitespaceChanged",this._onWhitespaceChanged,this),this._bindKeyboardShortcuts(e),this._setLanguageDirection()}r.mixin(h.prototype,{_bindKeyboardShortcuts:function(e){if(e.keyboardShortcuts){var t=this.$input,n=[];r.each(e.keyboardShortcuts,(function(e){"string"==typeof e&&(e=e.toUpperCase().charCodeAt(0)),n.push(e)})),s.element(document).keydown((function(e){var i=e.target||e.srcElement,r=i.tagName;if(!i.isContentEditable&&"INPUT"!==r&&"SELECT"!==r&&"TEXTAREA"!==r){var s=e.which||e.keyCode;-1!==n.indexOf(s)&&(t.focus(),e.stopPropagation(),e.preventDefault())}}))}},_onSuggestionClicked:function(e,t){var n;(n=this.dropdown.getDatumForSuggestion(t))&&this._select(n,{selectionMethod:"click"})},_onCursorMoved:function(e,t){var n=this.dropdown.getDatumForCursor(),i=this.dropdown.getCurrentCursor().attr("id");this.input.setActiveDescendant(i),n&&(t&&this.input.setInputValue(n.value,!0),this.eventBus.trigger("cursorchanged",n.raw,n.datasetName))},_onCursorRemoved:function(){this.input.resetInputValue(),this._updateHint(),this.eventBus.trigger("cursorremoved")},_onDatasetRendered:function(){this._updateHint(),this.eventBus.trigger("updated")},_onOpened:function(){this._updateHint(),this.input.expand(),this.eventBus.trigger("opened")},_onEmpty:function(){this.eventBus.trigger("empty")},_onRedrawn:function(){this.$node.css("top","0px"),this.$node.css("left","0px");var e=this.$input[0].getBoundingClientRect();this.autoWidth&&this.$node.css("width",e.width+"px");var t=this.$node[0].getBoundingClientRect(),n=e.bottom-t.top;this.$node.css("top",n+"px");var i=e.left-t.left;this.$node.css("left",i+"px"),this.eventBus.trigger("redrawn")},_onShown:function(){this.eventBus.trigger("shown"),this.autoselect&&this.dropdown.cursorTopSuggestion()},_onClosed:function(){this.input.clearHint(),this.input.removeActiveDescendant(),this.input.collapse(),this.eventBus.trigger("closed")},_onFocused:function(){if(this.isActivated=!0,this.openOnFocus){var e=this.input.getQuery();e.length>=this.minLength?this.dropdown.update(e):this.dropdown.empty(),this.dropdown.open()}},_onBlurred:function(){var e,t;e=this.dropdown.getDatumForCursor(),t=this.dropdown.getDatumForTopSuggestion();var n={selectionMethod:"blur"};this.debug||(this.autoselectOnBlur&&e?this._select(e,n):this.autoselectOnBlur&&t?this._select(t,n):(this.isActivated=!1,this.dropdown.empty(),this.dropdown.close()))},_onEnterKeyed:function(e,t){var n,i;n=this.dropdown.getDatumForCursor(),i=this.dropdown.getDatumForTopSuggestion();var r={selectionMethod:"enterKey"};n?(this._select(n,r),t.preventDefault()):this.autoselect&&i&&(this._select(i,r),t.preventDefault())},_onTabKeyed:function(e,t){if(this.tabAutocomplete){var n;(n=this.dropdown.getDatumForCursor())?(this._select(n,{selectionMethod:"tabKey"}),t.preventDefault()):this._autocomplete(!0)}else this.dropdown.close()},_onEscKeyed:function(){this.dropdown.close(),this.input.resetInputValue()},_onUpKeyed:function(){var e=this.input.getQuery();this.dropdown.isEmpty&&e.length>=this.minLength?this.dropdown.update(e):this.dropdown.moveCursorUp(),this.dropdown.open()},_onDownKeyed:function(){var e=this.input.getQuery();this.dropdown.isEmpty&&e.length>=this.minLength?this.dropdown.update(e):this.dropdown.moveCursorDown(),this.dropdown.open()},_onLeftKeyed:function(){"rtl"===this.dir&&this._autocomplete()},_onRightKeyed:function(){"ltr"===this.dir&&this._autocomplete()},_onQueryChanged:function(e,t){this.input.clearHintIfInvalid(),t.length>=this.minLength?this.dropdown.update(t):this.dropdown.empty(),this.dropdown.open(),this._setLanguageDirection()},_onWhitespaceChanged:function(){this._updateHint(),this.dropdown.open()},_setLanguageDirection:function(){var e=this.input.getLanguageDirection();this.dir!==e&&(this.dir=e,this.$node.css("direction",e),this.dropdown.setLanguageDirection(e))},_updateHint:function(){var e,t,n,i,s;(e=this.dropdown.getDatumForTopSuggestion())&&this.dropdown.isVisible()&&!this.input.hasOverflow()?(t=this.input.getInputValue(),n=a.normalizeQuery(t),i=r.escapeRegExChars(n),(s=new RegExp("^(?:"+i+")(.+$)","i").exec(e.value))?this.input.setHint(t+s[1]):this.input.clearHint()):this.input.clearHint()},_autocomplete:function(e){var t,n,i,r;t=this.input.getHint(),n=this.input.getQuery(),i=e||this.input.isCursorAtEnd(),t&&n!==t&&i&&((r=this.dropdown.getDatumForTopSuggestion())&&this.input.setInputValue(r.value),this.eventBus.trigger("autocompleted",r.raw,r.datasetName))},_select:function(e,t){void 0!==e.value&&this.input.setQuery(e.value),this.clearOnSelected?this.setVal(""):this.input.setInputValue(e.value,!0),this._setLanguageDirection(),!1===this.eventBus.trigger("selected",e.raw,e.datasetName,t).isDefaultPrevented()&&(this.dropdown.close(),r.defer(r.bind(this.dropdown.empty,this.dropdown)))},open:function(){if(!this.isActivated){var e=this.input.getInputValue();e.length>=this.minLength?this.dropdown.update(e):this.dropdown.empty()}this.dropdown.open()},close:function(){this.dropdown.close()},setVal:function(e){e=r.toStr(e),this.isActivated?this.input.setInputValue(e):(this.input.setQuery(e),this.input.setInputValue(e,!0)),this._setLanguageDirection()},getVal:function(){return this.input.getQuery()},destroy:function(){this.input.destroy(),this.dropdown.destroy(),function(e,t){var n=e.find(r.className(t.prefix,t.input));r.each(n.data(i),(function(e,t){void 0===e?n.removeAttr(t):n.attr(t,e)})),n.detach().removeClass(r.className(t.prefix,t.input,!0)).insertAfter(e),n.removeData&&n.removeData(i);e.remove()}(this.$node,this.cssClasses),this.$node=null},getWrapper:function(){return this.dropdown.$container[0]}}),h.Dropdown=u,h.Input=a,h.sources=n(7514),e.exports=h},7294:e=>{"use strict";e.exports={element:null}},2314:e=>{"use strict";e.exports=function(e){var t=e.match(/Algolia for JavaScript \((\d+\.)(\d+\.)(\d+)\)/)||e.match(/Algolia for vanilla JavaScript (\d+\.)(\d+\.)(\d+)/);if(t)return[t[1],t[2],t[3]]}},5567:(e,t,n)=>{"use strict";var i,r=n(7294);function s(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}e.exports={isArray:null,isFunction:null,isObject:null,bind:null,each:null,map:null,mixin:null,isMsie:function(e){if(void 0===e&&(e=navigator.userAgent),/(msie|trident)/i.test(e)){var t=e.match(/(msie |rv:)(\d+(.\d+)?)/i);if(t)return t[2]}return!1},escapeRegExChars:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isNumber:function(e){return"number"==typeof e},toStr:function(e){return null==e?"":e+""},cloneDeep:function(e){var t=this.mixin({},e),n=this;return this.each(t,(function(e,i){e&&(n.isArray(e)?t[i]=[].concat(e):n.isObject(e)&&(t[i]=n.cloneDeep(e)))})),t},error:function(e){throw new Error(e)},every:function(e,t){var n=!0;return e?(this.each(e,(function(i,r){n&&(n=t.call(null,i,r,e)&&n)})),!!n):n},any:function(e,t){var n=!1;return e?(this.each(e,(function(i,r){if(t.call(null,i,r,e))return n=!0,!1})),n):n},getUniqueId:(i=0,function(){return i++}),templatify:function(e){if(this.isFunction(e))return e;var t=r.element(e);return"SCRIPT"===t.prop("tagName")?function(){return t.text()}:function(){return String(e)}},defer:function(e){setTimeout(e,0)},noop:function(){},formatPrefix:function(e,t){return t?"":e+"-"},className:function(e,t,n){return(n?"":".")+e+t},escapeHighlightedString:function(e,t,n){t=t||"";var i=document.createElement("div");i.appendChild(document.createTextNode(t)),n=n||"";var r=document.createElement("div");r.appendChild(document.createTextNode(n));var o=document.createElement("div");return o.appendChild(document.createTextNode(e)),o.innerHTML.replace(RegExp(s(i.innerHTML),"g"),t).replace(RegExp(s(r.innerHTML),"g"),n)}}},9529:(e,t,n)=>{"use strict";var i=n(5567),r=n(5293),s=n(2314);e.exports=function(e,t){var n=s(e.as._ua);return n&&n[0]>=3&&n[1]>20&&((t=t||{}).additionalUA="autocomplete.js "+r),function(n,r){e.search(n,t,(function(e,t){e?i.error(e.message):r(t.hits,t)}))}}},7514:(e,t,n)=>{"use strict";e.exports={hits:n(9529),popularIn:n(3692)}},3692:(e,t,n)=>{"use strict";var i=n(5567),r=n(5293),s=n(2314);e.exports=function(e,t,n,o){var a=s(e.as._ua);if(a&&a[0]>=3&&a[1]>20&&((t=t||{}).additionalUA="autocomplete.js "+r),!n.source)return i.error("Missing 'source' key");var u=i.isFunction(n.source)?n.source:function(e){return e[n.source]};if(!n.index)return i.error("Missing 'index' key");var c=n.index;return o=o||{},function(a,l){e.search(a,t,(function(e,a){if(e)i.error(e.message);else{if(a.hits.length>0){var h=a.hits[0],p=i.mixin({hitsPerPage:0},n);delete p.source,delete p.index;var d=s(c.as._ua);return d&&d[0]>=3&&d[1]>20&&(t.additionalUA="autocomplete.js "+r),void c.search(u(h),p,(function(e,t){if(e)i.error(e.message);else{var n=[];if(o.includeAll){var r=o.allTitle||"All departments";n.push(i.mixin({facet:{value:r,count:t.nbHits}},i.cloneDeep(h)))}i.each(t.facets,(function(e,t){i.each(e,(function(e,r){n.push(i.mixin({facet:{facet:t,value:r,count:e}},i.cloneDeep(h)))}))}));for(var s=1;s{"use strict";var i=n(3847);n(7294).element=i;var r=n(5567);r.isArray=i.isArray,r.isFunction=i.isFunction,r.isObject=i.isPlainObject,r.bind=i.proxy,r.each=function(e,t){i.each(e,(function(e,n){return t(n,e)}))},r.map=i.map,r.mixin=i.extend,r.Event=i.Event;var s="aaAutocomplete",o=n(4015),a=n(8924);function u(e,t,n,u){n=r.isArray(n)?n:[].slice.call(arguments,2);var c=i(e).each((function(e,r){var c=i(r),l=new a({el:c}),h=u||new o({input:c,eventBus:l,dropdownMenuContainer:t.dropdownMenuContainer,hint:void 0===t.hint||!!t.hint,minLength:t.minLength,autoselect:t.autoselect,autoselectOnBlur:t.autoselectOnBlur,tabAutocomplete:t.tabAutocomplete,openOnFocus:t.openOnFocus,templates:t.templates,debug:t.debug,clearOnSelected:t.clearOnSelected,cssClasses:t.cssClasses,datasets:n,keyboardShortcuts:t.keyboardShortcuts,appendTo:t.appendTo,autoWidth:t.autoWidth,ariaLabel:t.ariaLabel||r.getAttribute("aria-label")});c.data(s,h)}));return c.autocomplete={},r.each(["open","close","getVal","setVal","destroy","getWrapper"],(function(e){c.autocomplete[e]=function(){var t,n=arguments;return c.each((function(r,o){var a=i(o).data(s);t=a[e].apply(a,n)})),t}})),c}u.sources=o.sources,u.escapeHighlightedString=r.escapeHighlightedString;var c="autocomplete"in window,l=window.autocomplete;u.noConflict=function(){return c?window.autocomplete=l:delete window.autocomplete,u},e.exports=u},5293:e=>{e.exports="0.37.1"},3847:e=>{var t;t=window,e.exports=function(e){var t,n,i=function(){var t,n,i,r,s,o,a=[],u=a.concat,c=a.filter,l=a.slice,h=e.document,p={},d={},f={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},g=/^\s*<(\w+|!)[^>]*>/,m=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,v=/^(?:body|html)$/i,x=/([A-Z])/g,b=["val","css","html","text","data","width","height","offset"],w=["after","prepend","before","append"],S=h.createElement("table"),C=h.createElement("tr"),E={tr:h.createElement("tbody"),tbody:S,thead:S,tfoot:S,td:C,th:C,"*":h.createElement("div")},k=/complete|loaded|interactive/,_=/^[\w-]*$/,T={},L=T.toString,O={},A=h.createElement("div"),$={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},P=Array.isArray||function(e){return e instanceof Array};function I(e){return null==e?String(e):T[L.call(e)]||"object"}function Q(e){return"function"==I(e)}function R(e){return null!=e&&e==e.window}function N(e){return null!=e&&e.nodeType==e.DOCUMENT_NODE}function D(e){return"object"==I(e)}function F(e){return D(e)&&!R(e)&&Object.getPrototypeOf(e)==Object.prototype}function j(e){var t=!!e&&"length"in e&&e.length,n=i.type(e);return"function"!=n&&!R(e)&&("array"==n||0===t||"number"==typeof t&&t>0&&t-1 in e)}function H(e){return c.call(e,(function(e){return null!=e}))}function V(e){return e.length>0?i.fn.concat.apply([],e):e}function B(e){return e.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function M(e){return e in d?d[e]:d[e]=new RegExp("(^|\\s)"+e+"(\\s|$)")}function q(e,t){return"number"!=typeof t||f[B(e)]?t:t+"px"}function z(e){var t,n;return p[e]||(t=h.createElement(e),h.body.appendChild(t),n=getComputedStyle(t,"").getPropertyValue("display"),t.parentNode.removeChild(t),"none"==n&&(n="block"),p[e]=n),p[e]}function K(e){return"children"in e?l.call(e.children):i.map(e.childNodes,(function(e){if(1==e.nodeType)return e}))}function W(e,t){var n,i=e?e.length:0;for(n=0;n$2>")),n===t&&(n=g.test(e)&&RegExp.$1),n in E||(n="*"),(a=E[n]).innerHTML=""+e,s=i.each(l.call(a.childNodes),(function(){a.removeChild(this)}))),F(r)&&(o=i(s),i.each(r,(function(e,t){b.indexOf(e)>-1?o[e](t):o.attr(e,t)}))),s},O.Z=function(e,t){return new W(e,t)},O.isZ=function(e){return e instanceof O.Z},O.init=function(e,n){var r;if(!e)return O.Z();if("string"==typeof e)if("<"==(e=e.trim())[0]&&g.test(e))r=O.fragment(e,RegExp.$1,n),e=null;else{if(n!==t)return i(n).find(e);r=O.qsa(h,e)}else{if(Q(e))return i(h).ready(e);if(O.isZ(e))return e;if(P(e))r=H(e);else if(D(e))r=[e],e=null;else if(g.test(e))r=O.fragment(e.trim(),RegExp.$1,n),e=null;else{if(n!==t)return i(n).find(e);r=O.qsa(h,e)}}return O.Z(r,e)},(i=function(e,t){return O.init(e,t)}).extend=function(e){var t,n=l.call(arguments,1);return"boolean"==typeof e&&(t=e,e=n.shift()),n.forEach((function(n){U(e,n,t)})),e},O.qsa=function(e,t){var n,i="#"==t[0],r=!i&&"."==t[0],s=i||r?t.slice(1):t,o=_.test(s);return e.getElementById&&o&&i?(n=e.getElementById(s))?[n]:[]:1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType?[]:l.call(o&&!i&&e.getElementsByClassName?r?e.getElementsByClassName(s):e.getElementsByTagName(t):e.querySelectorAll(t))},i.contains=h.documentElement.contains?function(e,t){return e!==t&&e.contains(t)}:function(e,t){for(;t&&(t=t.parentNode);)if(t===e)return!0;return!1},i.type=I,i.isFunction=Q,i.isWindow=R,i.isArray=P,i.isPlainObject=F,i.isEmptyObject=function(e){var t;for(t in e)return!1;return!0},i.isNumeric=function(e){var t=Number(e),n=typeof e;return null!=e&&"boolean"!=n&&("string"!=n||e.length)&&!isNaN(t)&&isFinite(t)||!1},i.inArray=function(e,t,n){return a.indexOf.call(t,e,n)},i.camelCase=s,i.trim=function(e){return null==e?"":String.prototype.trim.call(e)},i.uuid=0,i.support={},i.expr={},i.noop=function(){},i.map=function(e,t){var n,i,r,s=[];if(j(e))for(i=0;i =0?e:e+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each((function(){null!=this.parentNode&&this.parentNode.removeChild(this)}))},each:function(e){return a.every.call(this,(function(t,n){return!1!==e.call(t,n,t)})),this},filter:function(e){return Q(e)?this.not(this.not(e)):i(c.call(this,(function(t){return O.matches(t,e)})))},add:function(e,t){return i(o(this.concat(i(e,t))))},is:function(e){return this.length>0&&O.matches(this[0],e)},not:function(e){var n=[];if(Q(e)&&e.call!==t)this.each((function(t){e.call(this,t)||n.push(this)}));else{var r="string"==typeof e?this.filter(e):j(e)&&Q(e.item)?l.call(e):i(e);this.forEach((function(e){r.indexOf(e)<0&&n.push(e)}))}return i(n)},has:function(e){return this.filter((function(){return D(e)?i.contains(this,e):i(this).find(e).size()}))},eq:function(e){return-1===e?this.slice(e):this.slice(e,+e+1)},first:function(){var e=this[0];return e&&!D(e)?e:i(e)},last:function(){var e=this[this.length-1];return e&&!D(e)?e:i(e)},find:function(e){var t=this;return e?"object"==typeof e?i(e).filter((function(){var e=this;return a.some.call(t,(function(t){return i.contains(t,e)}))})):1==this.length?i(O.qsa(this[0],e)):this.map((function(){return O.qsa(this,e)})):i()},closest:function(e,t){var n=[],r="object"==typeof e&&i(e);return this.each((function(i,s){for(;s&&!(r?r.indexOf(s)>=0:O.matches(s,e));)s=s!==t&&!N(s)&&s.parentNode;s&&n.indexOf(s)<0&&n.push(s)})),i(n)},parents:function(e){for(var t=[],n=this;n.length>0;)n=i.map(n,(function(e){if((e=e.parentNode)&&!N(e)&&t.indexOf(e)<0)return t.push(e),e}));return Z(t,e)},parent:function(e){return Z(o(this.pluck("parentNode")),e)},children:function(e){return Z(this.map((function(){return K(this)})),e)},contents:function(){return this.map((function(){return this.contentDocument||l.call(this.childNodes)}))},siblings:function(e){return Z(this.map((function(e,t){return c.call(K(t.parentNode),(function(e){return e!==t}))})),e)},empty:function(){return this.each((function(){this.innerHTML=""}))},pluck:function(e){return i.map(this,(function(t){return t[e]}))},show:function(){return this.each((function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=z(this.nodeName))}))},replaceWith:function(e){return this.before(e).remove()},wrap:function(e){var t=Q(e);if(this[0]&&!t)var n=i(e).get(0),r=n.parentNode||this.length>1;return this.each((function(s){i(this).wrapAll(t?e.call(this,s):r?n.cloneNode(!0):n)}))},wrapAll:function(e){if(this[0]){var t;for(i(this[0]).before(e=i(e));(t=e.children()).length;)e=t.first();i(e).append(this)}return this},wrapInner:function(e){var t=Q(e);return this.each((function(n){var r=i(this),s=r.contents(),o=t?e.call(this,n):e;s.length?s.wrapAll(o):r.append(o)}))},unwrap:function(){return this.parent().each((function(){i(this).replaceWith(i(this).children())})),this},clone:function(){return this.map((function(){return this.cloneNode(!0)}))},hide:function(){return this.css("display","none")},toggle:function(e){return this.each((function(){var n=i(this);(e===t?"none"==n.css("display"):e)?n.show():n.hide()}))},prev:function(e){return i(this.pluck("previousElementSibling")).filter(e||"*")},next:function(e){return i(this.pluck("nextElementSibling")).filter(e||"*")},html:function(e){return 0 in arguments?this.each((function(t){var n=this.innerHTML;i(this).empty().append(G(this,e,t,n))})):0 in this?this[0].innerHTML:null},text:function(e){return 0 in arguments?this.each((function(t){var n=G(this,e,t,this.textContent);this.textContent=null==n?"":""+n})):0 in this?this.pluck("textContent").join(""):null},attr:function(e,i){var r;return"string"!=typeof e||1 in arguments?this.each((function(t){if(1===this.nodeType)if(D(e))for(n in e)J(this,n,e[n]);else J(this,e,G(this,i,t,this.getAttribute(e)))})):0 in this&&1==this[0].nodeType&&null!=(r=this[0].getAttribute(e))?r:t},removeAttr:function(e){return this.each((function(){1===this.nodeType&&e.split(" ").forEach((function(e){J(this,e)}),this)}))},prop:function(e,t){return e=$[e]||e,1 in arguments?this.each((function(n){this[e]=G(this,t,n,this[e])})):this[0]&&this[0][e]},removeProp:function(e){return e=$[e]||e,this.each((function(){delete this[e]}))},data:function(e,n){var i="data-"+e.replace(x,"-$1").toLowerCase(),r=1 in arguments?this.attr(i,n):this.attr(i);return null!==r?Y(r):t},val:function(e){return 0 in arguments?(null==e&&(e=""),this.each((function(t){this.value=G(this,e,t,this.value)}))):this[0]&&(this[0].multiple?i(this[0]).find("option").filter((function(){return this.selected})).pluck("value"):this[0].value)},offset:function(t){if(t)return this.each((function(e){var n=i(this),r=G(this,t,e,n.offset()),s=n.offsetParent().offset(),o={top:r.top-s.top,left:r.left-s.left};"static"==n.css("position")&&(o.position="relative"),n.css(o)}));if(!this.length)return null;if(h.documentElement!==this[0]&&!i.contains(h.documentElement,this[0]))return{top:0,left:0};var n=this[0].getBoundingClientRect();return{left:n.left+e.pageXOffset,top:n.top+e.pageYOffset,width:Math.round(n.width),height:Math.round(n.height)}},css:function(e,t){if(arguments.length<2){var r=this[0];if("string"==typeof e){if(!r)return;return r.style[s(e)]||getComputedStyle(r,"").getPropertyValue(e)}if(P(e)){if(!r)return;var o={},a=getComputedStyle(r,"");return i.each(e,(function(e,t){o[t]=r.style[s(t)]||a.getPropertyValue(t)})),o}}var u="";if("string"==I(e))t||0===t?u=B(e)+":"+q(e,t):this.each((function(){this.style.removeProperty(B(e))}));else for(n in e)e[n]||0===e[n]?u+=B(n)+":"+q(n,e[n])+";":this.each((function(){this.style.removeProperty(B(n))}));return this.each((function(){this.style.cssText+=";"+u}))},index:function(e){return e?this.indexOf(i(e)[0]):this.parent().children().indexOf(this[0])},hasClass:function(e){return!!e&&a.some.call(this,(function(e){return this.test(X(e))}),M(e))},addClass:function(e){return e?this.each((function(t){if("className"in this){r=[];var n=X(this);G(this,e,t,n).split(/\s+/g).forEach((function(e){i(this).hasClass(e)||r.push(e)}),this),r.length&&X(this,n+(n?" ":"")+r.join(" "))}})):this},removeClass:function(e){return this.each((function(n){if("className"in this){if(e===t)return X(this,"");r=X(this),G(this,e,n,r).split(/\s+/g).forEach((function(e){r=r.replace(M(e)," ")})),X(this,r.trim())}}))},toggleClass:function(e,n){return e?this.each((function(r){var s=i(this);G(this,e,r,X(this)).split(/\s+/g).forEach((function(e){(n===t?!s.hasClass(e):n)?s.addClass(e):s.removeClass(e)}))})):this},scrollTop:function(e){if(this.length){var n="scrollTop"in this[0];return e===t?n?this[0].scrollTop:this[0].pageYOffset:this.each(n?function(){this.scrollTop=e}:function(){this.scrollTo(this.scrollX,e)})}},scrollLeft:function(e){if(this.length){var n="scrollLeft"in this[0];return e===t?n?this[0].scrollLeft:this[0].pageXOffset:this.each(n?function(){this.scrollLeft=e}:function(){this.scrollTo(e,this.scrollY)})}},position:function(){if(this.length){var e=this[0],t=this.offsetParent(),n=this.offset(),r=v.test(t[0].nodeName)?{top:0,left:0}:t.offset();return n.top-=parseFloat(i(e).css("margin-top"))||0,n.left-=parseFloat(i(e).css("margin-left"))||0,r.top+=parseFloat(i(t[0]).css("border-top-width"))||0,r.left+=parseFloat(i(t[0]).css("border-left-width"))||0,{top:n.top-r.top,left:n.left-r.left}}},offsetParent:function(){return this.map((function(){for(var e=this.offsetParent||h.body;e&&!v.test(e.nodeName)&&"static"==i(e).css("position");)e=e.offsetParent;return e}))}},i.fn.detach=i.fn.remove,["width","height"].forEach((function(e){var n=e.replace(/./,(function(e){return e[0].toUpperCase()}));i.fn[e]=function(r){var s,o=this[0];return r===t?R(o)?o["inner"+n]:N(o)?o.documentElement["scroll"+n]:(s=this.offset())&&s[e]:this.each((function(t){(o=i(this)).css(e,G(this,r,t,o[e]()))}))}})),w.forEach((function(n,r){var s=r%2;i.fn[n]=function(){var n,o,a=i.map(arguments,(function(e){var r=[];return"array"==(n=I(e))?(e.forEach((function(e){return e.nodeType!==t?r.push(e):i.zepto.isZ(e)?r=r.concat(e.get()):void(r=r.concat(O.fragment(e)))})),r):"object"==n||null==e?e:O.fragment(e)})),u=this.length>1;return a.length<1?this:this.each((function(t,n){o=s?n:n.parentNode,n=0==r?n.nextSibling:1==r?n.firstChild:2==r?n:null;var c=i.contains(h.documentElement,o);a.forEach((function(t){if(u)t=t.cloneNode(!0);else if(!o)return i(t).remove();o.insertBefore(t,n),c&&ee(t,(function(t){if(!(null==t.nodeName||"SCRIPT"!==t.nodeName.toUpperCase()||t.type&&"text/javascript"!==t.type||t.src)){var n=t.ownerDocument?t.ownerDocument.defaultView:e;n.eval.call(n,t.innerHTML)}}))}))}))},i.fn[s?n+"To":"insert"+(r?"Before":"After")]=function(e){return i(e)[n](this),this}})),O.Z.prototype=W.prototype=i.fn,O.uniq=o,O.deserializeValue=Y,i.zepto=O,i}();return function(t){var n,i=1,r=Array.prototype.slice,s=t.isFunction,o=function(e){return"string"==typeof e},a={},u={},c="onfocusin"in e,l={focus:"focusin",blur:"focusout"},h={mouseenter:"mouseover",mouseleave:"mouseout"};function p(e){return e._zid||(e._zid=i++)}function d(e,t,n,i){if((t=f(t)).ns)var r=g(t.ns);return(a[p(e)]||[]).filter((function(e){return e&&(!t.e||e.e==t.e)&&(!t.ns||r.test(e.ns))&&(!n||p(e.fn)===p(n))&&(!i||e.sel==i)}))}function f(e){var t=(""+e).split(".");return{e:t[0],ns:t.slice(1).sort().join(" ")}}function g(e){return new RegExp("(?:^| )"+e.replace(" "," .* ?")+"(?: |$)")}function m(e,t){return e.del&&!c&&e.e in l||!!t}function y(e){return h[e]||c&&l[e]||e}function v(e,i,r,s,o,u,c){var l=p(e),d=a[l]||(a[l]=[]);i.split(/\s/).forEach((function(i){if("ready"==i)return t(document).ready(r);var a=f(i);a.fn=r,a.sel=o,a.e in h&&(r=function(e){var n=e.relatedTarget;if(!n||n!==this&&!t.contains(this,n))return a.fn.apply(this,arguments)}),a.del=u;var l=u||r;a.proxy=function(t){if(!(t=E(t)).isImmediatePropagationStopped()){try{var i=Object.getOwnPropertyDescriptor(t,"data");i&&!i.writable||(t.data=s)}catch(t){}var r=l.apply(e,t._args==n?[t]:[t].concat(t._args));return!1===r&&(t.preventDefault(),t.stopPropagation()),r}},a.i=d.length,d.push(a),"addEventListener"in e&&e.addEventListener(y(a.e),a.proxy,m(a,c))}))}function x(e,t,n,i,r){var s=p(e);(t||"").split(/\s/).forEach((function(t){d(e,t,n,i).forEach((function(t){delete a[s][t.i],"removeEventListener"in e&&e.removeEventListener(y(t.e),t.proxy,m(t,r))}))}))}u.click=u.mousedown=u.mouseup=u.mousemove="MouseEvents",t.event={add:v,remove:x},t.proxy=function(e,n){var i=2 in arguments&&r.call(arguments,2);if(s(e)){var a=function(){return e.apply(n,i?i.concat(r.call(arguments)):arguments)};return a._zid=p(e),a}if(o(n))return i?(i.unshift(e[n],e),t.proxy.apply(null,i)):t.proxy(e[n],e);throw new TypeError("expected function")},t.fn.bind=function(e,t,n){return this.on(e,t,n)},t.fn.unbind=function(e,t){return this.off(e,t)},t.fn.one=function(e,t,n,i){return this.on(e,t,n,i,1)};var b=function(){return!0},w=function(){return!1},S=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,C={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};function E(e,i){if(i||!e.isDefaultPrevented){i||(i=e),t.each(C,(function(t,n){var r=i[t];e[t]=function(){return this[n]=b,r&&r.apply(i,arguments)},e[n]=w}));try{e.timeStamp||(e.timeStamp=Date.now())}catch(r){}(i.defaultPrevented!==n?i.defaultPrevented:"returnValue"in i?!1===i.returnValue:i.getPreventDefault&&i.getPreventDefault())&&(e.isDefaultPrevented=b)}return e}function k(e){var t,i={originalEvent:e};for(t in e)S.test(t)||e[t]===n||(i[t]=e[t]);return E(i,e)}t.fn.delegate=function(e,t,n){return this.on(t,e,n)},t.fn.undelegate=function(e,t,n){return this.off(t,e,n)},t.fn.live=function(e,n){return t(document.body).delegate(this.selector,e,n),this},t.fn.die=function(e,n){return t(document.body).undelegate(this.selector,e,n),this},t.fn.on=function(e,i,a,u,c){var l,h,p=this;return e&&!o(e)?(t.each(e,(function(e,t){p.on(e,i,a,t,c)})),p):(o(i)||s(u)||!1===u||(u=a,a=i,i=n),u!==n&&!1!==a||(u=a,a=n),!1===u&&(u=w),p.each((function(n,s){c&&(l=function(e){return x(s,e.type,u),u.apply(this,arguments)}),i&&(h=function(e){var n,o=t(e.target).closest(i,s).get(0);if(o&&o!==s)return n=t.extend(k(e),{currentTarget:o,liveFired:s}),(l||u).apply(o,[n].concat(r.call(arguments,1)))}),v(s,e,u,a,i,h||l)})))},t.fn.off=function(e,i,r){var a=this;return e&&!o(e)?(t.each(e,(function(e,t){a.off(e,i,t)})),a):(o(i)||s(r)||!1===r||(r=i,i=n),!1===r&&(r=w),a.each((function(){x(this,e,r,i)})))},t.fn.trigger=function(e,n){return(e=o(e)||t.isPlainObject(e)?t.Event(e):E(e))._args=n,this.each((function(){e.type in l&&"function"==typeof this[e.type]?this[e.type]():"dispatchEvent"in this?this.dispatchEvent(e):t(this).triggerHandler(e,n)}))},t.fn.triggerHandler=function(e,n){var i,r;return this.each((function(s,a){(i=k(o(e)?t.Event(e):e))._args=n,i.target=a,t.each(d(a,e.type||e),(function(e,t){if(r=t.proxy(i),i.isImmediatePropagationStopped())return!1}))})),r},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach((function(e){t.fn[e]=function(t){return 0 in arguments?this.bind(e,t):this.trigger(e)}})),t.Event=function(e,t){o(e)||(e=(t=e).type);var n=document.createEvent(u[e]||"Events"),i=!0;if(t)for(var r in t)"bubbles"==r?i=!!t[r]:n[r]=t[r];return n.initEvent(e,i,!0),E(n)}}(i),n=[],i.fn.remove=function(){return this.each((function(){this.parentNode&&("IMG"===this.tagName&&(n.push(this),this.src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",t&&clearTimeout(t),t=setTimeout((function(){n=[]}),6e4)),this.parentNode.removeChild(this))}))},function(e){var t={},n=e.fn.data,i=e.camelCase,r=e.expando="Zepto"+ +new Date,s=[];function o(s,o){var u=s[r],c=u&&t[u];if(void 0===o)return c||a(s);if(c){if(o in c)return c[o];var l=i(o);if(l in c)return c[l]}return n.call(e(s),o)}function a(n,s,o){var a=n[r]||(n[r]=++e.uuid),c=t[a]||(t[a]=u(n));return void 0!==s&&(c[i(s)]=o),c}function u(t){var n={};return e.each(t.attributes||s,(function(t,r){0==r.name.indexOf("data-")&&(n[i(r.name.replace("data-",""))]=e.zepto.deserializeValue(r.value))})),n}e.fn.data=function(t,n){return void 0===n?e.isPlainObject(t)?this.each((function(n,i){e.each(t,(function(e,t){a(i,e,t)}))})):0 in this?o(this[0],t):void 0:this.each((function(){a(this,t,n)}))},e.data=function(t,n,i){return e(t).data(n,i)},e.hasData=function(n){var i=n[r],s=i&&t[i];return!!s&&!e.isEmptyObject(s)},e.fn.removeData=function(n){return"string"==typeof n&&(n=n.split(/\s+/)),this.each((function(){var s=this[r],o=s&&t[s];o&&e.each(n||o,(function(e){delete o[n?i(this):e]}))}))},["remove","empty"].forEach((function(t){var n=e.fn[t];e.fn[t]=function(){var e=this.find("*");return"remove"===t&&(e=e.add(this)),e.removeData(),n.call(this)}}))}(i),i}(t)},8897:(e,t)=>{!function(e){var t=/\S/,n=/\"/g,i=/\n/g,r=/\r/g,s=/\\/g,o=/\u2028/,a=/\u2029/;function u(e){"}"===e.n.substr(e.n.length-1)&&(e.n=e.n.substring(0,e.n.length-1))}function c(e){return e.trim?e.trim():e.replace(/^\s*|\s*$/g,"")}function l(e,t,n){if(t.charAt(n)!=e.charAt(0))return!1;for(var i=1,r=e.length;i ":7,"=":8,_v:9,"{":10,"&":11,_t:12},e.scan=function(n,i){var r=n.length,s=0,o=null,a=null,h="",p=[],d=!1,f=0,g=0,m="{{",y="}}";function v(){h.length>0&&(p.push({tag:"_t",text:new String(h)}),h="")}function x(n,i){if(v(),n&&function(){for(var n=!0,i=g;i "==r.tag&&(r.indent=p[s].text.toString()),p.splice(s,1));else i||p.push({tag:"\n"});d=!1,g=p.length}function b(e,t){var n="="+y,i=e.indexOf(n,t),r=c(e.substring(e.indexOf("=",t)+1,i)).split(" ");return m=r[0],y=r[r.length-1],i+n.length-1}for(i&&(i=i.split(" "),m=i[0],y=i[1]),f=0;f 0;){if(u=t.shift(),s&&"<"==s.tag&&!(u.tag in h))throw new Error("Illegal content in < super tag.");if(e.tags[u.tag]<=e.tags.$||d(u,r))i.push(u),u.nodes=p(t,u.tag,i,r);else{if("/"==u.tag){if(0===i.length)throw new Error("Closing tag without opener: /"+u.n);if(a=i.pop(),u.n!=a.n&&!f(u.n,a.n,r))throw new Error("Nesting error: "+a.n+" vs. "+u.n);return a.end=u.i,o}"\n"==u.tag&&(u.last=0==t.length||"\n"==t[0].tag)}o.push(u)}if(i.length>0)throw new Error("missing closing tag: "+i.pop().n);return o}function d(e,t){for(var n=0,i=t.length;n":x,"<":function(t,n){var i={partials:{},code:"",subs:{},inPartial:!0};e.walk(t.nodes,i);var r=n.partials[x(t,n)];r.subs=i.subs,r.partials=i.partials},$:function(t,n){var i={subs:{},code:"",partials:n.partials,prefix:t.n};e.walk(t.nodes,i),n.subs[t.n]=i.code,n.inPartial||(n.code+='t.sub("'+y(t.n)+'",c,p,i);')},"\n":function(e,t){t.code+=w('"\\n"'+(e.last?"":" + i"))},_v:function(e,t){t.code+="t.b(t.v(t."+v(e.n)+'("'+y(e.n)+'",c,p,0)));'},_t:function(e,t){t.code+=w('"'+y(e.text)+'"')},"{":b,"&":b},e.walk=function(t,n){for(var i,r=0,s=t.length;r {var i=n(8897);i.Template=n(3067).Template,i.template=i.Template,e.exports=i},3067:(e,t)=>{!function(e){function t(e,t,n){var i;return t&&"object"==typeof t&&(void 0!==t[e]?i=t[e]:n&&t.get&&"function"==typeof t.get&&(i=t.get(e))),i}e.Template=function(e,t,n,i){e=e||{},this.r=e.code||this.r,this.c=n,this.options=i||{},this.text=t||"",this.partials=e.partials||{},this.subs=e.subs||{},this.buf=""},e.Template.prototype={r:function(e,t,n){return""},v:function(e){return e=u(e),a.test(e)?e.replace(n,"&").replace(i,"<").replace(r,">").replace(s,"'").replace(o,"""):e},t:u,render:function(e,t,n){return this.ri([e],t||{},n)},ri:function(e,t,n){return this.r(e,t,n)},ep:function(e,t){var n=this.partials[e],i=t[n.name];if(n.instance&&n.base==i)return n.instance;if("string"==typeof i){if(!this.c)throw new Error("No compiler available.");i=this.c.compile(i,this.options)}if(!i)return null;if(this.partials[e].base=i,n.subs){for(key in t.stackText||(t.stackText={}),n.subs)t.stackText[key]||(t.stackText[key]=void 0!==this.activeSub&&t.stackText[this.activeSub]?t.stackText[this.activeSub]:this.text);i=function(e,t,n,i,r,s){function o(){}function a(){}var u;o.prototype=e,a.prototype=e.subs;var c=new o;for(u in c.subs=new a,c.subsText={},c.buf="",i=i||{},c.stackSubs=i,c.subsText=s,t)i[u]||(i[u]=t[u]);for(u in i)c.subs[u]=i[u];for(u in r=r||{},c.stackPartials=r,n)r[u]||(r[u]=n[u]);for(u in r)c.partials[u]=r[u];return c}(i,n.subs,n.partials,this.stackSubs,this.stackPartials,t.stackText)}return this.partials[e].instance=i,i},rp:function(e,t,n,i){var r=this.ep(e,n);return r?r.ri(t,n,i):""},rs:function(e,t,n){var i=e[e.length-1];if(c(i))for(var r=0;r=0;u--)if(void 0!==(s=t(e,n[u],a))){o=!0;break}return o?(r||"function"!=typeof s||(s=this.mv(s,n,i)),s):!r&&""},ls:function(e,t,n,i,r){var s=this.options.delimiters;return this.options.delimiters=r,this.b(this.ct(u(e.call(t,i)),t,n)),this.options.delimiters=s,!1},ct:function(e,t,n){if(this.options.disableLambda)throw new Error("Lambda features disabled.");return this.c.compile(e,this.options).render(t,n)},b:function(e){this.buf+=e},fl:function(){var e=this.buf;return this.buf="",e},ms:function(e,t,n,i,r,s,o){var a,u=t[t.length-1],c=e.call(u);return"function"==typeof c?!!i||(a=this.activeSub&&this.subsText&&this.subsText[this.activeSub]?this.subsText[this.activeSub]:this.text,this.ls(c,u,n,a.substring(r,s),o)):c},mv:function(e,t,n){var i=t[t.length-1],r=e.call(i);return"function"==typeof r?this.ct(u(r.call(i)),i,n):r},sub:function(e,t,n,i){var r=this.subs[e];r&&(this.activeSub=e,r(t,n,this,i),this.activeSub=!1)}};var n=/&/g,i=//g,s=/\'/g,o=/\"/g,a=/[&<>\"\']/;function u(e){return String(null==e?"":e)}var c=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}}(t)},8194:(e,t,n)=>{"use strict";var i,r,s,o=[n(5352),n(717),n(4752),n(2696),n(4206),n(8842)],a=-1,u=[],c=!1;function l(){i&&r&&(i=!1,r.length?u=r.concat(u):a=-1,u.length&&h())}function h(){if(!i){c=!1,i=!0;for(var e=u.length,t=setTimeout(l);e;){for(r=u,u=[];r&&++a 1)for(var n=1;n {"use strict";t.test=function(){return!n.g.setImmediate&&void 0!==n.g.MessageChannel},t.install=function(e){var t=new n.g.MessageChannel;return t.port1.onmessage=e,function(){t.port2.postMessage(0)}}},4752:(e,t,n)=>{"use strict";var i=n.g.MutationObserver||n.g.WebKitMutationObserver;t.test=function(){return i},t.install=function(e){var t=0,r=new i(e),s=n.g.document.createTextNode("");return r.observe(s,{characterData:!0}),function(){s.data=t=++t%2}}},717:(e,t,n)=>{"use strict";t.test=function(){return"function"==typeof n.g.queueMicrotask},t.install=function(e){return function(){n.g.queueMicrotask(e)}}},4206:(e,t,n)=>{"use strict";t.test=function(){return"document"in n.g&&"onreadystatechange"in n.g.document.createElement("script")},t.install=function(e){return function(){var t=n.g.document.createElement("script");return t.onreadystatechange=function(){e(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},n.g.document.documentElement.appendChild(t),e}}},8842:(e,t)=>{"use strict";t.test=function(){return!0},t.install=function(e){return function(){setTimeout(e,0)}}},8230:(e,t,n)=>{var i,r;!function(){var s,o,a,u,c,l,h,p,d,f,g,m,y,v,x,b,w,S,C,E,k,_,T,L,O,A,$,P,I,Q,R=function(e){var t=new R.Builder;return t.pipeline.add(R.trimmer,R.stopWordFilter,R.stemmer),t.searchPipeline.add(R.stemmer),e.call(t,t),t.build()};R.version="2.3.9",R.utils={},R.utils.warn=(s=this,function(e){s.console&&console.warn&&console.warn(e)}),R.utils.asString=function(e){return null==e?"":e.toString()},R.utils.clone=function(e){if(null==e)return e;for(var t=Object.create(null),n=Object.keys(e),i=0;i 0){var u=R.utils.clone(t)||{};u.position=[o,a],u.index=r.length,r.push(new R.Token(n.slice(o,s),u))}o=s+1}}return r},R.tokenizer.separator=/[\s\-]+/,R.Pipeline=function(){this._stack=[]},R.Pipeline.registeredFunctions=Object.create(null),R.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&R.utils.warn("Overwriting existing registered function: "+t),e.label=t,R.Pipeline.registeredFunctions[e.label]=e},R.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||R.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},R.Pipeline.load=function(e){var t=new R.Pipeline;return e.forEach((function(e){var n=R.Pipeline.registeredFunctions[e];if(!n)throw new Error("Cannot load unregistered function: "+e);t.add(n)})),t},R.Pipeline.prototype.add=function(){Array.prototype.slice.call(arguments).forEach((function(e){R.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)}),this)},R.Pipeline.prototype.after=function(e,t){R.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);if(-1==n)throw new Error("Cannot find existingFn");n+=1,this._stack.splice(n,0,t)},R.Pipeline.prototype.before=function(e,t){R.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);if(-1==n)throw new Error("Cannot find existingFn");this._stack.splice(n,0,t)},R.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);-1!=t&&this._stack.splice(t,1)},R.Pipeline.prototype.run=function(e){for(var t=this._stack.length,n=0;n 1&&(s e&&(n=r),s!=e);)i=n-t,r=t+Math.floor(i/2),s=this.elements[2*r];return s==e||s>e?2*r:s a?c+=2:o==a&&(t+=n[u+1]*i[c+1],u+=2,c+=2);return t},R.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},R.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),t=1,n=0;t 0){var s,o=r.str.charAt(0);o in r.node.edges?s=r.node.edges[o]:(s=new R.TokenSet,r.node.edges[o]=s),1==r.str.length&&(s.final=!0),i.push({node:s,editsRemaining:r.editsRemaining,str:r.str.slice(1)})}if(0!=r.editsRemaining){if("*"in r.node.edges)var a=r.node.edges["*"];else{a=new R.TokenSet;r.node.edges["*"]=a}if(0==r.str.length&&(a.final=!0),i.push({node:a,editsRemaining:r.editsRemaining-1,str:r.str}),r.str.length>1&&i.push({node:r.node,editsRemaining:r.editsRemaining-1,str:r.str.slice(1)}),1==r.str.length&&(r.node.final=!0),r.str.length>=1){if("*"in r.node.edges)var u=r.node.edges["*"];else{u=new R.TokenSet;r.node.edges["*"]=u}1==r.str.length&&(u.final=!0),i.push({node:u,editsRemaining:r.editsRemaining-1,str:r.str.slice(1)})}if(r.str.length>1){var c,l=r.str.charAt(0),h=r.str.charAt(1);h in r.node.edges?c=r.node.edges[h]:(c=new R.TokenSet,r.node.edges[h]=c),1==r.str.length&&(c.final=!0),i.push({node:c,editsRemaining:r.editsRemaining-1,str:l+r.str.slice(2)})}}}return n},R.TokenSet.fromString=function(e){for(var t=new R.TokenSet,n=t,i=0,r=e.length;i =e;t--){var n=this.uncheckedNodes[t],i=n.child.toString();i in this.minimizedNodes?n.parent.edges[n.char]=this.minimizedNodes[i]:(n.child._str=i,this.minimizedNodes[i]=n.child),this.uncheckedNodes.pop()}},R.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},R.Index.prototype.search=function(e){return this.query((function(t){new R.QueryParser(e,t).parse()}))},R.Index.prototype.query=function(e){for(var t=new R.Query(this.fields),n=Object.create(null),i=Object.create(null),r=Object.create(null),s=Object.create(null),o=Object.create(null),a=0;a 1?1:e},R.Builder.prototype.k1=function(e){this._k1=e},R.Builder.prototype.add=function(e,t){var n=e[this._ref],i=Object.keys(this._fields);this._documents[n]=t||{},this.documentCount+=1;for(var r=0;r =this.length)return R.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},R.QueryLexer.prototype.width=function(){return this.pos-this.start},R.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},R.QueryLexer.prototype.backup=function(){this.pos-=1},R.QueryLexer.prototype.acceptDigitRun=function(){var e,t;do{t=(e=this.next()).charCodeAt(0)}while(t>47&&t<58);e!=R.QueryLexer.EOS&&this.backup()},R.QueryLexer.prototype.more=function(){return this.pos 1&&(e.backup(),e.emit(R.QueryLexer.TERM)),e.ignore(),e.more())return R.QueryLexer.lexText},R.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(R.QueryLexer.EDIT_DISTANCE),R.QueryLexer.lexText},R.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(R.QueryLexer.BOOST),R.QueryLexer.lexText},R.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(R.QueryLexer.TERM)},R.QueryLexer.termSeparator=R.tokenizer.separator,R.QueryLexer.lexText=function(e){for(;;){var t=e.next();if(t==R.QueryLexer.EOS)return R.QueryLexer.lexEOS;if(92!=t.charCodeAt(0)){if(":"==t)return R.QueryLexer.lexField;if("~"==t)return e.backup(),e.width()>0&&e.emit(R.QueryLexer.TERM),R.QueryLexer.lexEditDistance;if("^"==t)return e.backup(),e.width()>0&&e.emit(R.QueryLexer.TERM),R.QueryLexer.lexBoost;if("+"==t&&1===e.width())return e.emit(R.QueryLexer.PRESENCE),R.QueryLexer.lexText;if("-"==t&&1===e.width())return e.emit(R.QueryLexer.PRESENCE),R.QueryLexer.lexText;if(t.match(R.QueryLexer.termSeparator))return R.QueryLexer.lexTerm}else e.escapeCharacter()}},R.QueryParser=function(e,t){this.lexer=new R.QueryLexer(e),this.query=t,this.currentClause={},this.lexemeIdx=0},R.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=R.QueryParser.parseClause;e;)e=e(this);return this.query},R.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},R.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},R.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},R.QueryParser.parseClause=function(e){var t=e.peekLexeme();if(null!=t)switch(t.type){case R.QueryLexer.PRESENCE:return R.QueryParser.parsePresence;case R.QueryLexer.FIELD:return R.QueryParser.parseField;case R.QueryLexer.TERM:return R.QueryParser.parseTerm;default:var n="expected either a field or a term, found "+t.type;throw t.str.length>=1&&(n+=" with value '"+t.str+"'"),new R.QueryParseError(n,t.start,t.end)}},R.QueryParser.parsePresence=function(e){var t=e.consumeLexeme();if(null!=t){switch(t.str){case"-":e.currentClause.presence=R.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=R.Query.presence.REQUIRED;break;default:var n="unrecognised presence operator'"+t.str+"'";throw new R.QueryParseError(n,t.start,t.end)}var i=e.peekLexeme();if(null==i){n="expecting term or field, found nothing";throw new R.QueryParseError(n,t.start,t.end)}switch(i.type){case R.QueryLexer.FIELD:return R.QueryParser.parseField;case R.QueryLexer.TERM:return R.QueryParser.parseTerm;default:n="expecting term or field, found '"+i.type+"'";throw new R.QueryParseError(n,i.start,i.end)}}},R.QueryParser.parseField=function(e){var t=e.consumeLexeme();if(null!=t){if(-1==e.query.allFields.indexOf(t.str)){var n=e.query.allFields.map((function(e){return"'"+e+"'"})).join(", "),i="unrecognised field '"+t.str+"', possible fields: "+n;throw new R.QueryParseError(i,t.start,t.end)}e.currentClause.fields=[t.str];var r=e.peekLexeme();if(null==r){i="expecting term, found nothing";throw new R.QueryParseError(i,t.start,t.end)}if(r.type===R.QueryLexer.TERM)return R.QueryParser.parseTerm;i="expecting term, found '"+r.type+"'";throw new R.QueryParseError(i,r.start,r.end)}},R.QueryParser.parseTerm=function(e){var t=e.consumeLexeme();if(null!=t){e.currentClause.term=t.str.toLowerCase(),-1!=t.str.indexOf("*")&&(e.currentClause.usePipeline=!1);var n=e.peekLexeme();if(null!=n)switch(n.type){case R.QueryLexer.TERM:return e.nextClause(),R.QueryParser.parseTerm;case R.QueryLexer.FIELD:return e.nextClause(),R.QueryParser.parseField;case R.QueryLexer.EDIT_DISTANCE:return R.QueryParser.parseEditDistance;case R.QueryLexer.BOOST:return R.QueryParser.parseBoost;case R.QueryLexer.PRESENCE:return e.nextClause(),R.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+n.type+"'";throw new R.QueryParseError(i,n.start,n.end)}else e.nextClause()}},R.QueryParser.parseEditDistance=function(e){var t=e.consumeLexeme();if(null!=t){var n=parseInt(t.str,10);if(isNaN(n)){var i="edit distance must be numeric";throw new R.QueryParseError(i,t.start,t.end)}e.currentClause.editDistance=n;var r=e.peekLexeme();if(null!=r)switch(r.type){case R.QueryLexer.TERM:return e.nextClause(),R.QueryParser.parseTerm;case R.QueryLexer.FIELD:return e.nextClause(),R.QueryParser.parseField;case R.QueryLexer.EDIT_DISTANCE:return R.QueryParser.parseEditDistance;case R.QueryLexer.BOOST:return R.QueryParser.parseBoost;case R.QueryLexer.PRESENCE:return e.nextClause(),R.QueryParser.parsePresence;default:i="Unexpected lexeme type '"+r.type+"'";throw new R.QueryParseError(i,r.start,r.end)}else e.nextClause()}},R.QueryParser.parseBoost=function(e){var t=e.consumeLexeme();if(null!=t){var n=parseInt(t.str,10);if(isNaN(n)){var i="boost must be numeric";throw new R.QueryParseError(i,t.start,t.end)}e.currentClause.boost=n;var r=e.peekLexeme();if(null!=r)switch(r.type){case R.QueryLexer.TERM:return e.nextClause(),R.QueryParser.parseTerm;case R.QueryLexer.FIELD:return e.nextClause(),R.QueryParser.parseField;case R.QueryLexer.EDIT_DISTANCE:return R.QueryParser.parseEditDistance;case R.QueryLexer.BOOST:return R.QueryParser.parseBoost;case R.QueryLexer.PRESENCE:return e.nextClause(),R.QueryParser.parsePresence;default:i="Unexpected lexeme type '"+r.type+"'";throw new R.QueryParseError(i,r.start,r.end)}else e.nextClause()}},void 0===(r="function"==typeof(i=function(){return R})?i.call(t,n,t,e):i)||(e.exports=r)}()}}]); \ No newline at end of file diff --git a/assets/js/734.9c54f551.js.LICENSE.txt b/assets/js/49.c17c1426.js.LICENSE.txt old mode 100755 new mode 100644 similarity index 100% rename from assets/js/734.9c54f551.js.LICENSE.txt rename to assets/js/49.c17c1426.js.LICENSE.txt diff --git a/assets/js/4998a0a4.487f790a.js b/assets/js/4998a0a4.487f790a.js deleted file mode 100755 index 412a024..0000000 --- a/assets/js/4998a0a4.487f790a.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[872],{5318:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var r=n(7378);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t =0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var l=r.createContext({}),p=function(e){var t=r.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},c=function(e){var t=p(e.components);return r.createElement(l.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},y=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,s=e.originalType,l=e.parentName,c=o(e,["components","mdxType","originalType","parentName"]),u=p(n),y=a,m=u["".concat(l,".").concat(y)]||u[y]||d[y]||s;return n?r.createElement(m,i(i({ref:t},c),{},{components:n})):r.createElement(m,i({ref:t},c))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var s=n.length,i=new Array(s);i[0]=y;var o={};for(var l in t)hasOwnProperty.call(t,l)&&(o[l]=t[l]);o.originalType=e,o[u]="string"==typeof e?e:a,i[1]=o;for(var p=2;p {n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>i,default:()=>d,frontMatter:()=>s,metadata:()=>o,toc:()=>p});var r=n(5773),a=(n(7378),n(5318));const s={},i="Type safety and type inference",o={unversionedId:"features-and-use-cases/type-safety-and-type-inference",id:"features-and-use-cases/type-safety-and-type-inference",title:"Type safety and type inference",description:"Since v2.0",source:"@site/docs/03_features-and-use-cases/05_type-safety-and-type-inference.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/type-safety-and-type-inference",permalink:"/nestjs-cls/features-and-use-cases/type-safety-and-type-inference",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/05_type-safety-and-type-inference.md",tags:[],version:"current",sidebarPosition:5,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Usage outside of web request",permalink:"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request"},next:{title:"Proxy Providers",permalink:"/nestjs-cls/features-and-use-cases/proxy-providers"}},l={},p=[{value:"Type-safe ClsService",id:"type-safe-clsservice",level:2},{value:"Using a type parameter",id:"using-a-type-parameter",level:3},{value:"Using Typescript module augmentation",id:"using-typescript-module-augmentation",level:3},{value:"Using a custom provider",id:"using-a-custom-provider",level:3},{value:"Terminal Type",id:"terminal-type",level:2}],c={toc:p},u="wrapper";function d(e){let{components:t,...n}=e;return(0,a.kt)(u,(0,r.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("h1",{id:"type-safety-and-type-inference"},"Type safety and type inference"),(0,a.kt)("blockquote",null,(0,a.kt)("p",{parentName:"blockquote"},"Since ",(0,a.kt)("inlineCode",{parentName:"p"},"v2.0"))),(0,a.kt)("p",null,"By default the CLS context is untyped and allows setting and retrieving any ",(0,a.kt)("inlineCode",{parentName:"p"},"string")," or ",(0,a.kt)("inlineCode",{parentName:"p"},"symbol")," keys from the context. Some safety can be enforced by using ",(0,a.kt)("inlineCode",{parentName:"p"},"CONSTANTS")," instead of magic strings, but that might not be enough."),(0,a.kt)("h2",{id:"type-safe-clsservice"},"Type-safe ClsService"),(0,a.kt)("p",null,"It is possible to specify a custom interface for the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsService")," and get proper typing and automatic type inference when retrieving or setting values. This works even for ",(0,a.kt)("em",{parentName:"p"},"nested objects")," using a dot notation."),(0,a.kt)("p",null,"To create a typed CLS Store, start by creating an interface that extends ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsStore"),"."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts",metastring:"title=my-cls-service.interface.ts",title:"my-cls-service.interface.ts"},"export interface MyClsStore extends ClsStore {\n tenantId: string;\n user: {\n id: number;\n authorized: boolean;\n };\n}\n")),(0,a.kt)("h3",{id:"using-a-type-parameter"},"Using a type parameter"),(0,a.kt)("p",null,"Then you can inject the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsService")," with a type parameter ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsService")," to make use of the safe typing."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},"export class MyService {\n // highlight-start\n constructor(private readonly cls: ClsService ) {}\n // highlight-end\n\n doTheThing() {\n // a boolean type will be enforced here\n this.cls.set('user.authorized', true);\n\n // tenantId will be inferred as a string\n const tenantId = this.cls.get('tenantId');\n\n // userId will be inferred as a number\n const userId = this.cls.get('user.id');\n\n // user will be inferred as { id: number, authorized: boolean }\n const user = this.cls.get('user');\n\n // you'll even get intellisense for the keys, because the type\n // will be inferred as:\n // symbol | 'tenantId\u02d9 | 'user' | 'user.id' | 'user.authorized'\n\n // alternatively, since the `get` method returns the whole store\n // when called without arguments, you can use object destructuring\n const { tenantId, user } = this.cls.get();\n\n // accessing a nonexistent property will result in a type error\n const notExist = this.cls.get('user.name');\n }\n}\n")),(0,a.kt)("h3",{id:"using-typescript-module-augmentation"},"Using Typescript module augmentation"),(0,a.kt)("p",null,"Alternatively, if you feel like using ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsService ")," everywhere is tedious, you can instead globally ",(0,a.kt)("a",{parentName:"p",href:"https://www.typescriptlang.org/docs/handbook/declaration-merging.html"},"augment the ",(0,a.kt)("inlineCode",{parentName:"a"},"ClsStore interface")),"."),(0,a.kt)("p",null,"Now you don't need to specify the type parameter on ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsService")," to still get the string typing."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},"declare module 'nestjs-cls' {\n interface ClsStore {\n tenantId: string;\n user: {\n id: number;\n authorized: boolean;\n };\n }\n}\n")),(0,a.kt)("h3",{id:"using-a-custom-provider"},"Using a custom provider"),(0,a.kt)("p",null,"For even more transparent approach without augmenting the declaration, you can create a typed ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsService")," by extending it and creating a custom provider out of it:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},"export class MyClsService extends ClsService {}\n\n@Module({\n imports: [ClsModule.forFeature()],\n providers: [\n {\n provide: MyClsService,\n useExisting: ClsService,\n },\n ],\n exports: [MyClsService],\n})\nclass MyClsModule {}\n")),(0,a.kt)("p",null,"Now you can inject ",(0,a.kt)("inlineCode",{parentName:"p"},"MyClsService")," as an alias for ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsService "),' without "polluting" the global type space.'),(0,a.kt)("h2",{id:"terminal-type"},"Terminal Type"),(0,a.kt)("p",null,"It can happen, that the object you want to store in the context is too complex, or contains cyclic references."),(0,a.kt)("p",null,"In that case, typescript might complain that ",(0,a.kt)("em",{parentName:"p"},"type instantiation is too deep, possibly infinite"),". That is due to the fact that it tries to generate all possible paths inside the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsStore"),". If that's the case, you can use the ",(0,a.kt)("inlineCode",{parentName:"p"},"Terminal")," type to stop generating the paths for a certain subtree:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},"interface ClsStore {\n tenantId: string;\n // highlight-start\n user: Terminal<{\n id: number;\n authorized: boolean;\n }>;\n // highlight-end\n}\n")),(0,a.kt)("p",null,"This will only generate the paths ",(0,a.kt)("inlineCode",{parentName:"p"},"tenantId | user")," and won't allow directly accessing nested keys (like ",(0,a.kt)("inlineCode",{parentName:"p"},"cls.get('user.id')"),", but you'll still get fully typing for things like ",(0,a.kt)("inlineCode",{parentName:"p"},"const { id } = cls.get('user')"),"). See issue ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/Papooch/nestjs-cls/issues/22"},"#22")," for more details."))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/4998a0a4.8311d530.js b/assets/js/4998a0a4.8311d530.js new file mode 100644 index 0000000..8e9afbd --- /dev/null +++ b/assets/js/4998a0a4.8311d530.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[872],{5436:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>o,contentTitle:()=>a,default:()=>u,frontMatter:()=>i,metadata:()=>c,toc:()=>l});var s=t(4246),r=t(1670);const i={},a="Type safety and type inference",c={id:"features-and-use-cases/type-safety-and-type-inference",title:"Type safety and type inference",description:"Since v2.0",source:"@site/docs/03_features-and-use-cases/05_type-safety-and-type-inference.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/type-safety-and-type-inference",permalink:"/nestjs-cls/features-and-use-cases/type-safety-and-type-inference",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/05_type-safety-and-type-inference.md",tags:[],version:"current",sidebarPosition:5,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Usage outside of web request",permalink:"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request"},next:{title:"Proxy Providers",permalink:"/nestjs-cls/features-and-use-cases/proxy-providers"}},o={},l=[{value:"Type-safe ClsService",id:"type-safe-clsservice",level:2},{value:"Using a type parameter",id:"using-a-type-parameter",level:3},{value:"Using Typescript module augmentation",id:"using-typescript-module-augmentation",level:3},{value:"Using a custom provider",id:"using-a-custom-provider",level:3},{value:"Terminal Type",id:"terminal-type",level:2}];function d(e){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",...(0,r.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h1,{id:"type-safety-and-type-inference",children:"Type safety and type inference"}),"\n",(0,s.jsxs)(n.blockquote,{children:["\n",(0,s.jsxs)(n.p,{children:["Since ",(0,s.jsx)(n.code,{children:"v2.0"})]}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["By default the CLS context is untyped and allows setting and retrieving any ",(0,s.jsx)(n.code,{children:"string"})," or ",(0,s.jsx)(n.code,{children:"symbol"})," keys from the context. Some safety can be enforced by using ",(0,s.jsx)(n.code,{children:"CONSTANTS"})," instead of magic strings, but that might not be enough."]}),"\n",(0,s.jsx)(n.h2,{id:"type-safe-clsservice",children:"Type-safe ClsService"}),"\n",(0,s.jsxs)(n.p,{children:["It is possible to specify a custom interface for the ",(0,s.jsx)(n.code,{children:"ClsService"})," and get proper typing and automatic type inference when retrieving or setting values. This works even for ",(0,s.jsx)(n.em,{children:"nested objects"})," using a dot notation."]}),"\n",(0,s.jsxs)(n.p,{children:["To create a typed CLS Store, start by creating an interface that extends ",(0,s.jsx)(n.code,{children:"ClsStore"}),"."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",metastring:"title=my-cls-service.interface.ts",children:"export interface MyClsStore extends ClsStore {\n tenantId: string;\n user: {\n id: number;\n authorized: boolean;\n };\n}\n"})}),"\n",(0,s.jsx)(n.h3,{id:"using-a-type-parameter",children:"Using a type parameter"}),"\n",(0,s.jsxs)(n.p,{children:["Then you can inject the ",(0,s.jsx)(n.code,{children:"ClsService"})," with a type parameter ",(0,s.jsx)(n.code,{children:"ClsService "})," to make use of the safe typing."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"export class MyService {\n // highlight-start\n constructor(private readonly cls: ClsService ) {}\n // highlight-end\n\n doTheThing() {\n // a boolean type will be enforced here\n this.cls.set('user.authorized', true);\n\n // tenantId will be inferred as a string\n const tenantId = this.cls.get('tenantId');\n\n // userId will be inferred as a number\n const userId = this.cls.get('user.id');\n\n // user will be inferred as { id: number, authorized: boolean }\n const user = this.cls.get('user');\n\n // you'll even get intellisense for the keys, because the type\n // will be inferred as:\n // symbol | 'tenantId\u02d9 | 'user' | 'user.id' | 'user.authorized'\n\n // alternatively, since the `get` method returns the whole store\n // when called without arguments, you can use object destructuring\n const { tenantId, user } = this.cls.get();\n\n // accessing a nonexistent property will result in a type error\n const notExist = this.cls.get('user.name');\n }\n}\n"})}),"\n",(0,s.jsx)(n.h3,{id:"using-typescript-module-augmentation",children:"Using Typescript module augmentation"}),"\n",(0,s.jsxs)(n.p,{children:["Alternatively, if you feel like using ",(0,s.jsx)(n.code,{children:"ClsService "})," everywhere is tedious, you can instead globally ",(0,s.jsxs)(n.a,{href:"https://www.typescriptlang.org/docs/handbook/declaration-merging.html",children:["augment the ",(0,s.jsx)(n.code,{children:"ClsStore interface"})]}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["Now you don't need to specify the type parameter on ",(0,s.jsx)(n.code,{children:"ClsService"})," to still get the string typing."]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"declare module 'nestjs-cls' {\n interface ClsStore {\n tenantId: string;\n user: {\n id: number;\n authorized: boolean;\n };\n }\n}\n"})}),"\n",(0,s.jsx)(n.h3,{id:"using-a-custom-provider",children:"Using a custom provider"}),"\n",(0,s.jsxs)(n.p,{children:["For even more transparent approach without augmenting the declaration, you can create a typed ",(0,s.jsx)(n.code,{children:"ClsService"})," by extending it and creating a custom provider out of it:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"export class MyClsService extends ClsService {}\n\n@Module({\n imports: [ClsModule.forFeature()],\n providers: [\n {\n provide: MyClsService,\n useExisting: ClsService,\n },\n ],\n exports: [MyClsService],\n})\nclass MyClsModule {}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Now you can inject ",(0,s.jsx)(n.code,{children:"MyClsService"})," as an alias for ",(0,s.jsx)(n.code,{children:"ClsService "}),' without "polluting" the global type space.']}),"\n",(0,s.jsx)(n.h2,{id:"terminal-type",children:"Terminal Type"}),"\n",(0,s.jsx)(n.p,{children:"It can happen, that the object you want to store in the context is too complex, or contains cyclic references."}),"\n",(0,s.jsxs)(n.p,{children:["In that case, typescript might complain that ",(0,s.jsx)(n.em,{children:"type instantiation is too deep, possibly infinite"}),". That is due to the fact that it tries to generate all possible paths inside the ",(0,s.jsx)(n.code,{children:"ClsStore"}),". If that's the case, you can use the ",(0,s.jsx)(n.code,{children:"Terminal"})," type to stop generating the paths for a certain subtree:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"interface ClsStore {\n tenantId: string;\n // highlight-start\n user: Terminal<{\n id: number;\n authorized: boolean;\n }>;\n // highlight-end\n}\n"})}),"\n",(0,s.jsxs)(n.p,{children:["This will only generate the paths ",(0,s.jsx)(n.code,{children:"tenantId | user"})," and won't allow directly accessing nested keys (like ",(0,s.jsx)(n.code,{children:"cls.get('user.id')"}),", but you'll still get fully typing for things like ",(0,s.jsx)(n.code,{children:"const { id } = cls.get('user')"}),"). See issue ",(0,s.jsx)(n.a,{href:"https://github.com/Papooch/nestjs-cls/issues/22",children:"#22"})," for more details."]})]})}function u(e={}){const{wrapper:n}={...(0,r.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},1670:(e,n,t)=>{t.d(n,{Z:()=>c,a:()=>a});var s=t(7378);const r={},i=s.createContext(r);function a(e){const n=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:a(e.components),s.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/4c9a797e.5a451edf.js b/assets/js/4c9a797e.5a451edf.js new file mode 100644 index 0000000..083f983 --- /dev/null +++ b/assets/js/4c9a797e.5a451edf.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[720],{5875:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>a,contentTitle:()=>c,default:()=>l,frontMatter:()=>o,metadata:()=>i,toc:()=>d});var n=s(4246),r=s(1670);const o={},c="API",i={id:"api/index",title:"API",description:"This chapter describes the programmatic API of the ClsService and the ClsModule options.",source:"@site/docs/04_api/index.md",sourceDirName:"04_api",slug:"/api/",permalink:"/nestjs-cls/api/",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/04_api/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Proxy Providers",permalink:"/nestjs-cls/features-and-use-cases/proxy-providers"},next:{title:"Service Interface",permalink:"/nestjs-cls/api/service-interface"}},a={},d=[];function p(e){const t={code:"code",h1:"h1",p:"p",...(0,r.a)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.h1,{id:"api",children:"API"}),"\n",(0,n.jsxs)(t.p,{children:["This chapter describes the programmatic API of the ",(0,n.jsx)(t.code,{children:"ClsService"})," and the ",(0,n.jsx)(t.code,{children:"ClsModule"})," options."]})]})}function l(e={}){const{wrapper:t}={...(0,r.a)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(p,{...e})}):p(e)}},1670:(e,t,s)=>{s.d(t,{Z:()=>i,a:()=>c});var n=s(7378);const r={},o=n.createContext(r);function c(e){const t=n.useContext(o);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),n.createElement(o.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/4c9a797e.ac0c8500.js b/assets/js/4c9a797e.ac0c8500.js deleted file mode 100755 index 48b9979..0000000 --- a/assets/js/4c9a797e.ac0c8500.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[720],{5318:(e,t,r)=>{r.d(t,{Zo:()=>l,kt:()=>m});var n=r(7378);function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t =0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n =0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var s=n.createContext({}),p=function(e){var t=n.useContext(s),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},l=function(e){var t=p(e.components);return n.createElement(s.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},f=n.forwardRef((function(e,t){var r=e.components,o=e.mdxType,a=e.originalType,s=e.parentName,l=c(e,["components","mdxType","originalType","parentName"]),u=p(r),f=o,m=u["".concat(s,".").concat(f)]||u[f]||d[f]||a;return r?n.createElement(m,i(i({ref:t},l),{},{components:r})):n.createElement(m,i({ref:t},l))}));function m(e,t){var r=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var a=r.length,i=new Array(a);i[0]=f;var c={};for(var s in t)hasOwnProperty.call(t,s)&&(c[s]=t[s]);c.originalType=e,c[u]="string"==typeof e?e:o,i[1]=c;for(var p=2;p{r.r(t),r.d(t,{assets:()=>s,contentTitle:()=>i,default:()=>d,frontMatter:()=>a,metadata:()=>c,toc:()=>p});var n=r(5773),o=(r(7378),r(5318));const a={},i="API",c={unversionedId:"api/index",id:"api/index",title:"API",description:"This chapter describes the programmatic API of the ClsService and the ClsModule options.",source:"@site/docs/04_api/index.md",sourceDirName:"04_api",slug:"/api/",permalink:"/nestjs-cls/api/",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/04_api/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Proxy Providers",permalink:"/nestjs-cls/features-and-use-cases/proxy-providers"},next:{title:"Service Interface",permalink:"/nestjs-cls/api/service-interface"}},s={},p=[],l={toc:p},u="wrapper";function d(e){let{components:t,...r}=e;return(0,o.kt)(u,(0,n.Z)({},l,r,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"api"},"API"),(0,o.kt)("p",null,"This chapter describes the programmatic API of the ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsService")," and the ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsModule")," options."))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/561.5fe53f02.js b/assets/js/561.5fe53f02.js deleted file mode 100755 index 5f9c7d0..0000000 --- a/assets/js/561.5fe53f02.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[561],{7213:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>v});var i=s(1273),l=s.n(i);const n=s(8230);n.tokenizer.separator=/[\s\-/]+/;const a=class{constructor(e,t,s){void 0===s&&(s="/"),this.searchDocs=e,this.lunrIndex=n.Index.load(t),this.baseUrl=s}getLunrResult(e){return this.lunrIndex.query((function(t){const s=n.tokenizer(e);t.term(s,{boost:10}),t.term(s,{wildcard:n.Query.wildcard.TRAILING})}))}getHit(e,t,s){return{hierarchy:{lvl0:e.pageTitle||e.title,lvl1:0===e.type?null:e.title},url:e.url,_snippetResult:s?{content:{value:s,matchLevel:"full"}}:null,_highlightResult:{hierarchy:{lvl0:{value:0===e.type?t||e.title:e.pageTitle},lvl1:0===e.type?null:{value:t||e.title}}}}}getTitleHit(e,t,s){const i=t[0],l=t[0]+s;let n=e.title.substring(0,i)+''+e.title.substring(i,l)+""+e.title.substring(l,e.title.length);return this.getHit(e,n)}getKeywordHit(e,t,s){const i=t[0],l=t[0]+s;let n=e.title+"
Keywords: "+e.keywords.substring(0,i)+''+e.keywords.substring(i,l)+""+e.keywords.substring(l,e.keywords.length)+"";return this.getHit(e,n)}getContentHit(e,t){const s=t[0],i=t[0]+t[1];let l=s,n=i,a=!0,r=!0;for(let c=0;c<3;c++){const t=e.content.lastIndexOf(" ",l-2),s=e.content.lastIndexOf(".",l-2);if(s>0&&s>t){l=s+1,a=!1;break}if(t<0){l=0,a=!1;break}l=t+1}for(let c=0;c<10;c++){const t=e.content.indexOf(" ",n+1),s=e.content.indexOf(".",n+1);if(s>0&&s'+e.content.substring(s,i)+"",o+=e.content.substring(i,n),r&&(o+=" ..."),this.getHit(e,null,o)}search(e){return new Promise(((t,s)=>{const i=this.getLunrResult(e),l=[];i.length>5&&(i.length=5),this.titleHitsRes=[],this.contentHitsRes=[],i.forEach((t=>{const s=this.searchDocs[t.ref],{metadata:i}=t.matchData;for(let n in i)if(i[n].title){if(!this.titleHitsRes.includes(t.ref)){const a=i[n].title.position[0];l.push(this.getTitleHit(s,a,e.length)),this.titleHitsRes.push(t.ref)}}else if(i[n].content){const e=i[n].content.position[0];l.push(this.getContentHit(s,e))}else if(i[n].keywords){const a=i[n].keywords.position[0];l.push(this.getKeywordHit(s,a,e.length)),this.titleHitsRes.push(t.ref)}})),l.length>5&&(l.length=5),t(l)}))}};var r=s(2500),o=s.n(r);const c="algolia-docsearch",h=`${c}-suggestion`,u={suggestion:`\n \n \n {{{category}}}\n\n\n\n \n `,suggestionSimple:`\n\n {{{subcategory}}}\n\n {{#isTextOrSubcategoryNonEmpty}}\n\n\n {{/isTextOrSubcategoryNonEmpty}}\n{{{subcategory}}}\n{{{title}}}\n {{#text}}{{{text}}}{{/text}}\n\n\n `,footer:`\n \n `,empty:`\n\n {{^isLvl0}}\n {{{category}}}\n {{^isLvl1}}\n {{^isLvl1EmptyOrDuplicate}}\n \n {{{subcategory}}}\n \n {{/isLvl1EmptyOrDuplicate}}\n {{/isLvl1}}\n {{/isLvl0}}\n\n\n {{#isLvl2}}\n {{{title}}}\n {{/isLvl2}}\n {{#isLvl1}}\n {{{subcategory}}}\n {{/isLvl1}}\n {{#isLvl0}}\n {{{category}}}\n {{/isLvl0}}\n\n\n {{#text}}\n\n\n\n {{/text}}\n{{{text}}}\n\n\n `,searchBox:'\n \n\n \n '};var g=s(3847),d=s.n(g);const p={mergeKeyWithParent(e,t){if(void 0===e[t])return e;if("object"!=typeof e[t])return e;const s=d().extend({},e,e[t]);return delete s[t],s},groupBy(e,t){const s={};return d().each(e,((e,i)=>{if(void 0===i[t])throw new Error(`[groupBy]: Object has no key ${t}`);let l=i[t];"string"==typeof l&&(l=l.toLowerCase()),Object.prototype.hasOwnProperty.call(s,l)||(s[l]=[]),s[l].push(i)})),s},values:e=>Object.keys(e).map((t=>e[t])),flatten(e){const t=[];return e.forEach((e=>{Array.isArray(e)?e.forEach((e=>{t.push(e)})):t.push(e)})),t},flattenAndFlagFirst(e,t){const s=this.values(e).map((e=>e.map(((e,s)=>(e[t]=0===s,e)))));return this.flatten(s)},compact(e){const t=[];return e.forEach((e=>{e&&t.push(e)})),t},getHighlightedValue:(e,t)=>e._highlightResult&&e._highlightResult.hierarchy_camel&&e._highlightResult.hierarchy_camel[t]&&e._highlightResult.hierarchy_camel[t].matchLevel&&"none"!==e._highlightResult.hierarchy_camel[t].matchLevel&&e._highlightResult.hierarchy_camel[t].value?e._highlightResult.hierarchy_camel[t].value:e._highlightResult&&e._highlightResult&&e._highlightResult[t]&&e._highlightResult[t].value?e._highlightResult[t].value:e[t],getSnippetedValue(e,t){if(!e._snippetResult||!e._snippetResult[t]||!e._snippetResult[t].value)return e[t];let s=e._snippetResult[t].value;return s[0]!==s[0].toUpperCase()&&(s=`\u2026${s}`),-1===[".","!","?"].indexOf(s[s.length-1])&&(s=`${s}\u2026`),s},deepClone:e=>JSON.parse(JSON.stringify(e))};class y{constructor(e){let{searchDocs:t,searchIndex:s,inputSelector:i,debug:l=!1,baseUrl:n="/",queryDataCallback:r=null,autocompleteOptions:c={debug:!1,hint:!1,autoselect:!0},transformData:h=!1,queryHook:g=!1,handleSelected:p=!1,enhancedSearchInput:v=!1,layout:m="collumns"}=e;this.input=y.getInputFromSelector(i),this.queryDataCallback=r||null;const b=!(!c||!c.debug)&&c.debug;c.debug=l||b,this.autocompleteOptions=c,this.autocompleteOptions.cssClasses=this.autocompleteOptions.cssClasses||{},this.autocompleteOptions.cssClasses.prefix=this.autocompleteOptions.cssClasses.prefix||"ds";const f=this.input&&"function"==typeof this.input.attr&&this.input.attr("aria-label");this.autocompleteOptions.ariaLabel=this.autocompleteOptions.ariaLabel||f||"search input",this.isSimpleLayout="simple"===m,this.client=new a(t,s,n),v&&(this.input=y.injectSearchBox(this.input)),this.autocomplete=o()(this.input,c,[{source:this.getAutocompleteSource(h,g),templates:{suggestion:y.getSuggestionTemplate(this.isSimpleLayout),footer:u.footer,empty:y.getEmptyTemplate()}}]);const x=p;this.handleSelected=x||this.handleSelected,x&&d()(".algolia-autocomplete").on("click",".ds-suggestions a",(e=>{e.preventDefault()})),this.autocomplete.on("autocomplete:selected",this.handleSelected.bind(null,this.autocomplete.autocomplete)),this.autocomplete.on("autocomplete:shown",this.handleShown.bind(null,this.input)),v&&y.bindSearchBoxEvent()}static injectSearchBox(e){e.before(u.searchBox);const t=e.prev().prev().find("input");return e.remove(),t}static bindSearchBoxEvent(){d()('.searchbox [type="reset"]').on("click",(function(){d()("input#docsearch").focus(),d()(this).addClass("hide"),o().autocomplete.setVal("")})),d()("input#docsearch").on("keyup",(()=>{const e=document.querySelector("input#docsearch"),t=document.querySelector('.searchbox [type="reset"]');t.className="searchbox__reset",0===e.value.length&&(t.className+=" hide")}))}static getInputFromSelector(e){const t=d()(e).filter("input");return t.length?d()(t[0]):null}getAutocompleteSource(e,t){return(s,i)=>{t&&(s=t(s)||s),this.client.search(s).then((t=>{this.queryDataCallback&&"function"==typeof this.queryDataCallback&&this.queryDataCallback(t),e&&(t=e(t)||t),i(y.formatHits(t))}))}}static formatHits(e){const t=p.deepClone(e).map((e=>(e._highlightResult&&(e._highlightResult=p.mergeKeyWithParent(e._highlightResult,"hierarchy")),p.mergeKeyWithParent(e,"hierarchy"))));let s=p.groupBy(t,"lvl0");return d().each(s,((e,t)=>{const i=p.groupBy(t,"lvl1"),l=p.flattenAndFlagFirst(i,"isSubCategoryHeader");s[e]=l})),s=p.flattenAndFlagFirst(s,"isCategoryHeader"),s.map((e=>{const t=y.formatURL(e),s=p.getHighlightedValue(e,"lvl0"),i=p.getHighlightedValue(e,"lvl1")||s,l=p.compact([p.getHighlightedValue(e,"lvl2")||i,p.getHighlightedValue(e,"lvl3"),p.getHighlightedValue(e,"lvl4"),p.getHighlightedValue(e,"lvl5"),p.getHighlightedValue(e,"lvl6")]).join(' '),n=p.getSnippetedValue(e,"content"),a=i&&""!==i||l&&""!==l,r=l&&""!==l&&l!==i,o=!r&&i&&""!==i&&i!==s;return{isLvl0:!o&&!r,isLvl1:o,isLvl2:r,isLvl1EmptyOrDuplicate:!i||""===i||i===s,isCategoryHeader:e.isCategoryHeader,isSubCategoryHeader:e.isSubCategoryHeader,isTextOrSubcategoryNonEmpty:a,category:s,subcategory:i,title:l,text:n,url:t}}))}static formatURL(e){const{url:t,anchor:s}=e;if(t){return-1!==t.indexOf("#")?t:s?`${e.url}#${e.anchor}`:t}return s?`#${e.anchor}`:(console.warn("no anchor nor url for : ",JSON.stringify(e)),null)}static getEmptyTemplate(){return e=>l().compile(u.empty).render(e)}static getSuggestionTemplate(e){const t=e?u.suggestionSimple:u.suggestion,s=l().compile(t);return e=>s.render(e)}handleSelected(e,t,s,i,l){void 0===l&&(l={}),"click"!==l.selectionMethod&&(e.setVal(""),window.location.assign(s.url))}handleShown(e){const t=e.offset().left+e.width()/2;let s=d()(document).width()/2;isNaN(s)&&(s=900);const i=t-s>=0?"algolia-autocomplete-right":"algolia-autocomplete-left",l=t-s<0?"algolia-autocomplete-right":"algolia-autocomplete-left",n=d()(".algolia-autocomplete");n.hasClass(i)||n.addClass(i),n.hasClass(l)&&n.removeClass(l)}}const v=y},5352:()=>{}}]); \ No newline at end of file diff --git a/assets/js/57c14adc.8d411baa.js b/assets/js/57c14adc.8d411baa.js new file mode 100644 index 0000000..cceecf7 --- /dev/null +++ b/assets/js/57c14adc.8d411baa.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[507],{3253:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>d,contentTitle:()=>c,default:()=>l,frontMatter:()=>r,metadata:()=>i,toc:()=>a});var n=s(4246),o=s(1670);const r={},c="Security",i={id:"considerations/security",title:"Security",description:"It is often discussed whether AsyncLocalStorage is safe to use for concurrent requests (because of a possible context leak) and whether the context could be lost_ throughout the duration of a request.",source:"@site/docs/05_considerations/01_security.md",sourceDirName:"05_considerations",slug:"/considerations/security",permalink:"/nestjs-cls/considerations/security",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/05_considerations/01_security.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Considerations",permalink:"/nestjs-cls/considerations/"},next:{title:"Compatibility",permalink:"/nestjs-cls/considerations/compatibility"}},d={},a=[];function h(e){const t={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",p:"p",strong:"strong",...(0,o.a)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.h1,{id:"security",children:"Security"}),"\n",(0,n.jsxs)(t.p,{children:["It is often discussed whether ",(0,n.jsx)(t.a,{href:"https://nodejs.org/api/async_context.html",children:(0,n.jsx)(t.code,{children:"AsyncLocalStorage"})})," is safe to use for ",(0,n.jsx)(t.em,{children:"concurrent requests"})," (because of a possible context leak) and whether the context could be ",(0,n.jsx)(t.em,{children:"lost"})," throughout the duration of a request."]}),"\n",(0,n.jsxs)(t.p,{children:["The ",(0,n.jsx)(t.code,{children:"ClsMiddleware"})," and ",(0,n.jsx)(t.code,{children:"ClsInterceptor"})," by default uses the safe ",(0,n.jsx)(t.code,{children:"run()"})," method, which it should not leak context, but in some rare cases, the context can be lost."]}),"\n",(0,n.jsxs)(t.p,{children:["The ",(0,n.jsx)(t.code,{children:"ClsGuard"})," (and ",(0,n.jsx)(t.code,{children:"ClsMiddleware"}),", if configured so) uses the less safe ",(0,n.jsx)(t.code,{children:"enterWith()"})," method, which might be needed in case the ",(0,n.jsx)(t.code,{children:"run()"})," method causes context loss."]}),"\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.strong,{children:"This has a consequence that should be taken into account:"})}),"\n",(0,n.jsx)(t.admonition,{type:"caution",children:(0,n.jsxs)(t.p,{children:["When the ",(0,n.jsx)(t.code,{children:"enterWith"})," method is used, any consequent requests ",(0,n.jsx)(t.em,{children:"get access"})," to the CLS context of the previous request ",(0,n.jsxs)(t.em,{children:["until the request hits the ",(0,n.jsx)(t.code,{children:"enterWith"})," call"]}),"."]})}),"\n",(0,n.jsxs)(t.p,{children:["That means, when using ",(0,n.jsx)(t.code,{children:"ClsMiddleware"})," with the ",(0,n.jsx)(t.code,{children:"useEnterWith"})," option, or ",(0,n.jsx)(t.code,{children:"ClsGuard"})," to set up context, be sure to mount them as early in the request lifetime as possible and do not use any other enhancers that rely on ",(0,n.jsx)(t.code,{children:"ClsService"})," before them. For ",(0,n.jsx)(t.code,{children:"ClsGuard"}),", that means you should probably manually mount it in ",(0,n.jsx)(t.code,{children:"AppModule"})," if you require any other guard to run ",(0,n.jsx)(t.em,{children:"after"})," it."]}),"\n",(0,n.jsx)(t.p,{children:"The next chapter addresses compatibility with various transport protocols."})]})}function l(e={}){const{wrapper:t}={...(0,o.a)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(h,{...e})}):h(e)}},1670:(e,t,s)=>{s.d(t,{Z:()=>i,a:()=>c});var n=s(7378);const o={},r=n.createContext(o);function c(e){const t=n.useContext(r);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:c(e.components),n.createElement(r.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/57c14adc.b808beff.js b/assets/js/57c14adc.b808beff.js deleted file mode 100755 index 4aa75b6..0000000 --- a/assets/js/57c14adc.b808beff.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[507],{5318:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>h});var r=n(7378);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t\n\n\n\n\n\n\n No results found for query "{{query}}"\n\n=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var c=r.createContext({}),l=function(e){var t=r.useContext(c),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},p=function(e){var t=l(e.components);return r.createElement(c.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},m=r.forwardRef((function(e,t){var n=e.components,o=e.mdxType,a=e.originalType,c=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),u=l(n),m=o,h=u["".concat(c,".").concat(m)]||u[m]||d[m]||a;return n?r.createElement(h,i(i({ref:t},p),{},{components:n})):r.createElement(h,i({ref:t},p))}));function h(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var a=n.length,i=new Array(a);i[0]=m;var s={};for(var c in t)hasOwnProperty.call(t,c)&&(s[c]=t[c]);s.originalType=e,s[u]="string"==typeof e?e:o,i[1]=s;for(var l=2;l{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>d,frontMatter:()=>a,metadata:()=>s,toc:()=>l});var r=n(5773),o=(n(7378),n(5318));const a={},i="Security",s={unversionedId:"considerations/security",id:"considerations/security",title:"Security",description:"It is often discussed whether AsyncLocalStorage is safe to use for concurrent requests (because of a possible context leak) and whether the context could be lost_ throughout the duration of a request.",source:"@site/docs/05_considerations/01_security.md",sourceDirName:"05_considerations",slug:"/considerations/security",permalink:"/nestjs-cls/considerations/security",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/05_considerations/01_security.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Considerations",permalink:"/nestjs-cls/considerations/"},next:{title:"Compatibility",permalink:"/nestjs-cls/considerations/compatibility"}},c={},l=[],p={toc:l},u="wrapper";function d(e){let{components:t,...n}=e;return(0,o.kt)(u,(0,r.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"security"},"Security"),(0,o.kt)("p",null,"It is often discussed whether ",(0,o.kt)("a",{parentName:"p",href:"https://nodejs.org/api/async_context.html"},(0,o.kt)("inlineCode",{parentName:"a"},"AsyncLocalStorage"))," is safe to use for ",(0,o.kt)("em",{parentName:"p"},"concurrent requests")," (because of a possible context leak) and whether the context could be ",(0,o.kt)("em",{parentName:"p"},"lost")," throughout the duration of a request."),(0,o.kt)("p",null,"The ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsMiddleware")," and ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsInterceptor")," by default uses the safe ",(0,o.kt)("inlineCode",{parentName:"p"},"run()")," method, which it should not leak context, but in some rare cases, the context can be lost."),(0,o.kt)("p",null,"The ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsGuard")," (and ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsMiddleware"),", if configured so) uses the less safe ",(0,o.kt)("inlineCode",{parentName:"p"},"enterWith()")," method, which might be needed in case the ",(0,o.kt)("inlineCode",{parentName:"p"},"run()")," method causes context loss."),(0,o.kt)("p",null,(0,o.kt)("strong",{parentName:"p"},"This has a consequence that should be taken into account:")),(0,o.kt)("admonition",{type:"caution"},(0,o.kt)("p",{parentName:"admonition"},"When the ",(0,o.kt)("inlineCode",{parentName:"p"},"enterWith")," method is used, any consequent requests ",(0,o.kt)("em",{parentName:"p"},"get access")," to the CLS context of the previous request ",(0,o.kt)("em",{parentName:"p"},"until the request hits the ",(0,o.kt)("inlineCode",{parentName:"em"},"enterWith")," call"),".")),(0,o.kt)("p",null,"That means, when using ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsMiddleware")," with the ",(0,o.kt)("inlineCode",{parentName:"p"},"useEnterWith")," option, or ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsGuard")," to set up context, be sure to mount them as early in the request lifetime as possible and do not use any other enhancers that rely on ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsService")," before them. For ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsGuard"),", that means you should probably manually mount it in ",(0,o.kt)("inlineCode",{parentName:"p"},"AppModule")," if you require any other guard to run ",(0,o.kt)("em",{parentName:"p"},"after")," it."),(0,o.kt)("p",null,"The next chapter addresses compatibility with various transport protocols."))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/592cbe55.9bb5699b.js b/assets/js/592cbe55.9bb5699b.js new file mode 100644 index 0000000..1715aa7 --- /dev/null +++ b/assets/js/592cbe55.9bb5699b.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[437],{652:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>a,contentTitle:()=>o,default:()=>h,frontMatter:()=>i,metadata:()=>c,toc:()=>l});var r=s(4246),t=s(1670);const i={},o="Proxy Providers",c={id:"features-and-use-cases/proxy-providers",title:"Proxy Providers",description:"Since v3.0",source:"@site/docs/03_features-and-use-cases/06_proxy-providers.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/proxy-providers",permalink:"/nestjs-cls/features-and-use-cases/proxy-providers",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/06_proxy-providers.md",tags:[],version:"current",sidebarPosition:6,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Type safety and type inference",permalink:"/nestjs-cls/features-and-use-cases/type-safety-and-type-inference"},next:{title:"API",permalink:"/nestjs-cls/api/"}},a={},l=[{value:"Class Proxy Providers",id:"class-proxy-providers",level:2},{value:"Populate in an enhancer",id:"populate-in-an-enhancer",level:3},{value:"Self-populating Proxy Provider",id:"self-populating-proxy-provider",level:3},{value:"Factory Proxy Providers",id:"factory-proxy-providers",level:2},{value:"Caveats",id:"caveats",level:2},{value:"No primitive values",id:"no-primitive-values",level:3},{value:" function
Proxies must be explicitly enabled",id:"function-proxies-must-be-explicitly-enabled",level:3},{value:"Delayed resolution of Proxy Providers",id:"delayed-resolution-of-proxy-providers",level:2},{value:"Outside web request",id:"outside-web-request",level:3},{value:"With cls.run()",id:"with-clsrun",level:4},{value:"With @UseCls()",id:"with-usecls",level:4}];function d(e){const n={a:"a",admonition:"admonition",blockquote:"blockquote",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",p:"p",pre:"pre",...(0,t.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h1,{id:"proxy-providers",children:"Proxy Providers"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["Since ",(0,r.jsx)(n.code,{children:"v3.0"})]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["This feature was inspired by how REQUEST-scoped providers (",(0,r.jsx)(n.em,{children:'"beans"'}),") work in the Spring framework for Java/Kotlin."]}),"\n",(0,r.jsxs)(n.p,{children:["Using this technique, NestJS does not need to re-create a whole DI-subtree on each request (which has ",(0,r.jsx)(n.a,{href:"https://docs.nestjs.com/fundamentals/injection-scopes#scope-hierarchy",children:"certain implications which disallows the use of REQUEST-scoped providers in certain situations"}),")."]}),"\n",(0,r.jsxs)(n.p,{children:["Rather, it injects a ",(0,r.jsx)(n.em,{children:"SINGLETON"})," ",(0,r.jsx)(n.a,{href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy",children:"Proxy"})," instance, which delegates access and calls to the actual instance, which is created for each request when the CLS context is set up."]}),"\n",(0,r.jsxs)(n.p,{children:["There are two kinds of Proxy providers - ",(0,r.jsx)(n.a,{href:"#class-proxy-providers",children:(0,r.jsx)(n.em,{children:"Class"})})," and ",(0,r.jsx)(n.a,{href:"#factory-proxy-providers",children:(0,r.jsx)(n.em,{children:"Factory"})}),"."]}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:["Please note that there are ",(0,r.jsx)(n.a,{href:"#caveats",children:(0,r.jsx)(n.em,{children:"some caveats"})})," to using this technique."]})}),"\n",(0,r.jsx)(n.h2,{id:"class-proxy-providers",children:"Class Proxy Providers"}),"\n",(0,r.jsxs)(n.p,{children:["These providers look like your regular class providers, with the exception that is the ",(0,r.jsx)(n.code,{children:"@InjectableProxy()"})," decorator to make them easily distinguishable."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",metastring:"title=user.proxy.ts",children:"// highlight-start\n@InjectableProxy()\n// highlight-end\nexport class User {\n id: number;\n role: string;\n}\n"})}),"\n",(0,r.jsxs)(n.p,{children:["To register the proxy provider, use the ",(0,r.jsx)(n.code,{children:"ClsModule.forFeature()"})," registration,\nwhich exposes it an injectable provider in the parent module."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"ClsModule.forFeature(User);\n"})}),"\n",(0,r.jsx)(n.p,{children:"It can be then injected using the class name."}),"\n",(0,r.jsxs)(n.p,{children:["However, what will be actually injected ",(0,r.jsx)(n.em,{children:"is not"})," the instance of the class, but rather the Proxy which redirects all access to an unique instance stored in the CLS context."]}),"\n",(0,r.jsx)(n.h3,{id:"populate-in-an-enhancer",children:"Populate in an enhancer"}),"\n",(0,r.jsx)(n.p,{children:"A Class provider defined in this way will be empty upon creation, so we must assign context values to it somewhere. One place to do it is an interceptor"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",metastring:"title=user.interceptor.ts",children:"@Injectable()\nexport class UserInterceptor implements NestInterceptor {\n // we can inject the proxy here\n // highlight-start\n constructor(private readonly user: User) {}\n // highlight-end\n\n intercept(context: ExecutionContext, next: CallHandler): Observable{\n const request = context.switchToHttp().getRequest();\n\n // and assign or change values as it was a normal object\n // highlight-start\n this.user.id = request.user.id;\n this.user.role = 'admin';\n // highlight-end\n\n return next.handle();\n }\n}\n"})}),"\n",(0,r.jsx)(n.h3,{id:"self-populating-proxy-provider",children:"Self-populating Proxy Provider"}),"\n",(0,r.jsx)(n.p,{children:"It is also possible to inject other providers into the Proxy Provider to avoid having to do this in a separate component."}),"\n",(0,r.jsxs)(n.p,{children:["For the convenience, the ",(0,r.jsx)(n.code,{children:"CLS_REQ"})," and ",(0,r.jsx)(n.code,{children:"CLS_RES"})," are also made into Proxy Providers and are exported from the ",(0,r.jsx)(n.code,{children:"ClsModule"}),"."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",metastring:"title=user-with-rile.proxy.ts",children:"@InjectableProxy()\nexport class UserWithRole {\n id: number;\n role: string;\n\n constructor(\n // highlight-start\n @Inject(CLS_REQ) request: Request,\n // highlight-end\n roleService: RoleService,\n ) {\n this.id = request.user.id;\n this.role = roleService.getForId(request.user.id);\n }\n}\n"})}),"\n",(0,r.jsxs)(n.p,{children:["If you need to inject a provider from an external module, use the ",(0,r.jsx)(n.code,{children:"ClsModule.forFeatureAsync()"})," registration to import the containing module."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"ClsModule.forFeatureAsync({\n // make RoleService available to the Proxy provider\n import: [RoleModule],\n useClass: UserWithRole,\n});\n"})}),"\n",(0,r.jsx)(n.admonition,{type:"tip",children:(0,r.jsxs)(n.p,{children:["Using ",(0,r.jsx)(n.code,{children:"@Inject(CLS_REQ)"}),", you can entirely replace ",(0,r.jsx)(n.code,{children:"@Inject(REQUEST)"})," in REQUEST-SCOPED providers to turn them into CLS-enabled singletons without changing the implementation."]})}),"\n",(0,r.jsx)(n.h2,{id:"factory-proxy-providers",children:"Factory Proxy Providers"}),"\n",(0,r.jsx)(n.p,{children:"Like your normal factory providers, Proxy factory providers look familiar."}),"\n",(0,r.jsxs)(n.p,{children:["They can be only registered using the ",(0,r.jsx)(n.code,{children:"ClsModule.forFeatureAsync()"})," method."]}),"\n",(0,r.jsx)(n.p,{children:"Here's an example of a hypothetical factory provider that dynamically resolves to a specific tenant database connection:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"ClsModule.forFeatureAsync({\n provide: TENANT_CONNECTION,\n import: [DatabaseConnectionModule],\n inject: [CLS_REQ, DatabaseConnectionService],\n useFactory: async (req: Request, dbService: DatabaseConnectionService) => {\n const tenantId = req.params['tenantId'];\n const connection = await dbService.getTenantConnection(tenantId);\n return connection;\n },\n global: true, // make the TENANT_CONNECTION available for injection globally\n});\n"})}),"\n",(0,r.jsxs)(n.p,{children:["Again, the factory will be called on each request and the result will be stored in the CLS context. The ",(0,r.jsx)(n.code,{children:"TENANT_CONNECTION"})," provider, however, will still be a singleton and will not affect the scope of whatever it is injected into."]}),"\n",(0,r.jsxs)(n.p,{children:["In the service, it can be injected using the ",(0,r.jsx)(n.code,{children:"provide"})," token as usual:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",metastring:"title=dogs.service.ts",children:"@Injectable()\nclass DogsService {\n constructor(\n @Inject(TENANT_CONNECTION)\n private readonly connection: TenantConnection,\n ) {}\n\n getAll() {\n return this.connection.dogs.getAll();\n }\n}\n"})}),"\n",(0,r.jsx)(n.h2,{id:"caveats",children:"Caveats"}),"\n",(0,r.jsx)(n.h3,{id:"no-primitive-values",children:"No primitive values"}),"\n",(0,r.jsxs)(n.p,{children:["Proxy Factory providers ",(0,r.jsx)(n.em,{children:"cannot"})," return a ",(0,r.jsx)(n.em,{children:"primitive value"}),". This is because the provider itself is the Proxy and it only delegates access once a property or a method is called on it (or if it itself is called in case the factory returns a function)."]}),"\n",(0,r.jsxs)(n.h3,{id:"function-proxies-must-be-explicitly-enabled",children:[(0,r.jsx)(n.code,{children:"function"})," Proxies must be explicitly enabled"]}),"\n",(0,r.jsxs)(n.p,{children:["In order to support injecting proxies of ",(0,r.jsx)(n.em,{children:"functions"}),", the underlying proxy ",(0,r.jsx)(n.em,{children:"target"}),' must be a function, too, in order to be able to implement the "apply" trap. However, this information cannot be extracted from the factory function itself, so if your factory returns a function, you must explicitly set the ',(0,r.jsx)(n.code,{children:"type"})," property to ",(0,r.jsx)(n.code,{children:"function"})," in the provider definition."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"{\n provide: SOME_FUNCTION,\n useFactory: () => {\n return () => {\n // do something\n };\n },\n // highlight-start\n type: 'function',\n // highlight-end\n}\n"})}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:["In versions prior to ",(0,r.jsx)(n.code,{children:"v4.0"}),", calling ",(0,r.jsx)(n.code,{children:"typeof"})," on an instance of a Proxy provider always returned ",(0,r.jsx)(n.code,{children:"function"}),", regardless of the value it holds. This is no longer the case. Please see ",(0,r.jsx)(n.a,{href:"https://github.com/Papooch/nestjs-cls/issues/82",children:"Issue #82"})]})}),"\n",(0,r.jsx)(n.h2,{id:"delayed-resolution-of-proxy-providers",children:"Delayed resolution of Proxy Providers"}),"\n",(0,r.jsxs)(n.p,{children:["By default, proxy providers are resolved as soon as the ",(0,r.jsx)(n.code,{children:"setup"})," function in an enhancer (middleware/guard/interceptor) finishes. For some use cases, it might be required that the resolution is delayed until some later point in the request lifecycle once more information is present in the CLS ."]}),"\n",(0,r.jsxs)(n.p,{children:["To achieve that, set ",(0,r.jsx)(n.code,{children:"resolveProxyProviders"})," to ",(0,r.jsx)(n.code,{children:"false"})," in the enhancer options and call ",(0,r.jsx)(n.code,{children:"ClsService#resolveProxyProviders()"})," manually at any time."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"ClsModule.forRoot({\n middleware: {\n // highlight-start\n resolveProxyProviders: false,\n // highlight-end\n },\n});\n"})}),"\n",(0,r.jsx)(n.h3,{id:"outside-web-request",children:"Outside web request"}),"\n",(0,r.jsxs)(n.p,{children:["This is also necessary ",(0,r.jsx)(n.a,{href:"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request",children:"outside the context of web request"}),", otherwise all access to an injected Proxy Provider will return ",(0,r.jsx)(n.code,{children:"undefined"}),"."]}),"\n",(0,r.jsx)(n.h4,{id:"with-clsrun",children:"With cls.run()"}),"\n",(0,r.jsxs)(n.p,{children:["If you set up the context with ",(0,r.jsx)(n.code,{children:"cls.run()"})," to wrap any subsequent code thar relies on Proxy Providers."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",metastring:"title=cron.controller.ts",children:"@Injectable()\nexport class CronController {\n constructor(\n private readonly someService: SomeService,\n private readonly cls: ClsService,\n );\n\n @Cron('45 * * * * *')\n async handleCron() {\n await this.cls.run(async () => {\n // prepare the context\n this.cls.set('some-key', 'some-value');\n // highlight-start\n // trigger Proxy Provider resolution\n await this.cls.resolveProxyProviders();\n // highlight-end\n await this.someService.doTheThing();\n });\n }\n}\n"})}),"\n",(0,r.jsx)(n.h4,{id:"with-usecls",children:"With @UseCls()"}),"\n",(0,r.jsxs)(n.p,{children:["Since the ",(0,r.jsx)(n.code,{children:"@UseCls()"})," decorator wraps the function body with ",(0,r.jsx)(n.code,{children:"cls.run()"})," automatically, you can use the ",(0,r.jsx)(n.code,{children:"setup"})," function to prepare the context."]}),"\n",(0,r.jsxs)(n.p,{children:["The Proxy Providers will be resolved after the ",(0,r.jsx)(n.code,{children:"setup"})," phase."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",metastring:"title=cron.controller.ts",children:"@Injectable()\nexport class CronController {\n constructor(private readonly someService: SomeService);\n\n @Cron('45 * * * * *')\n @UseCls({\n // highlight-start\n setup: (cls) => {\n cls.set('some-key', 'some-value');\n },\n // highlight-end\n })\n async handleCron() {\n await this.someService.doTheThing();\n }\n}\n"})})]})}function h(e={}){const{wrapper:n}={...(0,t.a)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}},1670:(e,n,s)=>{s.d(n,{Z:()=>c,a:()=>o});var r=s(7378);const t={},i=r.createContext(t);function o(e){const n=r.useContext(i);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:o(e.components),r.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/592cbe55.e18bfa3e.js b/assets/js/592cbe55.e18bfa3e.js deleted file mode 100755 index bb654b0..0000000 --- a/assets/js/592cbe55.e18bfa3e.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[437],{5318:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>m});var r=n(7378);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t =0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var l=r.createContext({}),p=function(e){var t=r.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},c=function(e){var t=p(e.components);return r.createElement(l.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},h=r.forwardRef((function(e,t){var n=e.components,o=e.mdxType,a=e.originalType,l=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),h=o,m=u["".concat(l,".").concat(h)]||u[h]||d[h]||a;return n?r.createElement(m,i(i({ref:t},c),{},{components:n})):r.createElement(m,i({ref:t},c))}));function m(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var a=n.length,i=new Array(a);i[0]=h;var s={};for(var l in t)hasOwnProperty.call(t,l)&&(s[l]=t[l]);s.originalType=e,s[u]="string"==typeof e?e:o,i[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>i,default:()=>d,frontMatter:()=>a,metadata:()=>s,toc:()=>p});var r=n(5773),o=(n(7378),n(5318));const a={},i="Proxy Providers",s={unversionedId:"features-and-use-cases/proxy-providers",id:"features-and-use-cases/proxy-providers",title:"Proxy Providers",description:"Since v3.0",source:"@site/docs/03_features-and-use-cases/06_proxy-providers.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/proxy-providers",permalink:"/nestjs-cls/features-and-use-cases/proxy-providers",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/06_proxy-providers.md",tags:[],version:"current",sidebarPosition:6,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Type safety and type inference",permalink:"/nestjs-cls/features-and-use-cases/type-safety-and-type-inference"},next:{title:"API",permalink:"/nestjs-cls/api/"}},l={},p=[{value:"Class Proxy Providers",id:"class-proxy-providers",level:2},{value:"Populate in an enhancer",id:"populate-in-an-enhancer",level:3},{value:"Self-populating Proxy Provider",id:"self-populating-proxy-provider",level:3},{value:"Factory Proxy Providers",id:"factory-proxy-providers",level:2},{value:"Caveats",id:"caveats",level:2},{value:"No primitive values",id:"no-primitive-values",level:3},{value:" typeof
Proxies is alwaysfunction
",id:"typeof-proxies-is-always-function",level:3},{value:"Delayed resolution of Proxy Providers",id:"delayed-resolution-of-proxy-providers",level:2},{value:"Outside web request",id:"outside-web-request",level:3},{value:"With cls.run()",id:"with-clsrun",level:4},{value:"With @UseCls()",id:"with-usecls",level:4}],c={toc:p},u="wrapper";function d(e){let{components:t,...n}=e;return(0,o.kt)(u,(0,r.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"proxy-providers"},"Proxy Providers"),(0,o.kt)("blockquote",null,(0,o.kt)("p",{parentName:"blockquote"},"Since ",(0,o.kt)("inlineCode",{parentName:"p"},"v3.0"))),(0,o.kt)("p",null,"This feature was inspired by how REQUEST-scoped providers (",(0,o.kt)("em",{parentName:"p"},'"beans"'),") work in the Spring framework for Java/Kotlin."),(0,o.kt)("p",null,"Using this technique, NestJS does not need to re-create a whole DI-subtree on each request (which has ",(0,o.kt)("a",{parentName:"p",href:"https://docs.nestjs.com/fundamentals/injection-scopes#scope-hierarchy"},"certain implications which disallows the use of REQUEST-scoped providers in certain situations"),")."),(0,o.kt)("p",null,"Rather, it injects a ",(0,o.kt)("em",{parentName:"p"},"SINGLETON")," ",(0,o.kt)("a",{parentName:"p",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy"},"Proxy")," instance, which delegates access and calls to the actual instance, which is created for each request when the CLS context is set up."),(0,o.kt)("p",null,"There are two kinds of Proxy providers - ",(0,o.kt)("a",{parentName:"p",href:"#class-proxy-providers"},(0,o.kt)("em",{parentName:"a"},"Class"))," and ",(0,o.kt)("a",{parentName:"p",href:"#factory-proxy-providers"},(0,o.kt)("em",{parentName:"a"},"Factory")),"."),(0,o.kt)("admonition",{type:"note"},(0,o.kt)("p",{parentName:"admonition"},"Please note that there are ",(0,o.kt)("a",{parentName:"p",href:"#caveats"},(0,o.kt)("em",{parentName:"a"},"some caveats"))," to using this technique.")),(0,o.kt)("h2",{id:"class-proxy-providers"},"Class Proxy Providers"),(0,o.kt)("p",null,"These providers look like your regular class providers, with the exception that is the ",(0,o.kt)("inlineCode",{parentName:"p"},"@InjectableProxy()")," decorator to make them easily distinguishable."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:"title=user.proxy.ts",title:"user.proxy.ts"},"// highlight-start\n@InjectableProxy()\n// highlight-end\nexport class User {\n id: number;\n role: string;\n}\n")),(0,o.kt)("p",null,"To register the proxy provider, use the ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsModule.forFeature()")," registration,\nwhich exposes it an injectable provider in the parent module."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts"},"ClsModule.forFeature(User);\n")),(0,o.kt)("p",null,"It can be then injected using the class name."),(0,o.kt)("p",null,"However, what will be actually injected ",(0,o.kt)("em",{parentName:"p"},"is not")," the instance of the class, but rather the Proxy which redirects all access to an unique instance stored in the CLS context."),(0,o.kt)("h3",{id:"populate-in-an-enhancer"},"Populate in an enhancer"),(0,o.kt)("p",null,"A Class provider defined in this way will be empty upon creation, so we must assign context values to it somewhere. One place to do it is an interceptor"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:"title=user.interceptor.ts",title:"user.interceptor.ts"},"@Injectable()\nexport class UserInterceptor implements NestInterceptor {\n // we can inject the proxy here\n // highlight-start\n constructor(private readonly user: User) {}\n // highlight-end\n\n intercept(context: ExecutionContext, next: CallHandler): Observable{\n const request = context.switchToHttp().getRequest();\n\n // and assign or change values as it was a normal object\n // highlight-start\n this.user.id = request.user.id;\n this.user.role = 'admin';\n // highlight-end\n\n return next.handle();\n }\n}\n")),(0,o.kt)("h3",{id:"self-populating-proxy-provider"},"Self-populating Proxy Provider"),(0,o.kt)("p",null,"It is also possible to inject other providers into the Proxy Provider to avoid having to do this in a separate component."),(0,o.kt)("p",null,"For the convenience, the ",(0,o.kt)("inlineCode",{parentName:"p"},"CLS_REQ")," and ",(0,o.kt)("inlineCode",{parentName:"p"},"CLS_RES")," are also made into Proxy Providers and are exported from the ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsModule"),"."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:"title=user-with-rile.proxy.ts",title:"user-with-rile.proxy.ts"},"@InjectableProxy()\nexport class UserWithRole {\n id: number;\n role: string;\n\n constructor(\n // highlight-start\n @Inject(CLS_REQ) request: Request,\n // highlight-end\n roleService: RoleService,\n ) {\n this.id = request.user.id;\n this.role = roleService.getForId(request.user.id);\n }\n}\n")),(0,o.kt)("p",null,"If you need to inject a provider from an external module, use the ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsModule.forFeatureAsync()")," registration to import the containing module."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts"},"ClsModule.forFeatureAsync({\n // make RoleService available to the Proxy provider\n import: [RoleModule],\n useClass: UserWithRole,\n});\n")),(0,o.kt)("admonition",{type:"tip"},(0,o.kt)("p",{parentName:"admonition"},"Using ",(0,o.kt)("inlineCode",{parentName:"p"},"@Inject(CLS_REQ)"),", you can entirely replace ",(0,o.kt)("inlineCode",{parentName:"p"},"@Inject(REQUEST)")," in REQUEST-SCOPED providers to turn them into CLS-enabled singletons without changing the implementation.")),(0,o.kt)("h2",{id:"factory-proxy-providers"},"Factory Proxy Providers"),(0,o.kt)("p",null,"Like your normal factory providers, Proxy factory providers look familiar."),(0,o.kt)("p",null,"They can be only registered using the ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsModule.forFeatureAsync()")," method."),(0,o.kt)("p",null,"Here's an example of a hypothetical factory provider that dynamically resolves to a specific tenant database connection:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts"},"ClsModule.forFeatureAsync({\n provide: TENANT_CONNECTION,\n import: [DatabaseConnectionModule],\n inject: [CLS_REQ, DatabaseConnectionService],\n useFactory: async (req: Request, dbService: DatabaseConnectionService) => {\n const tenantId = req.params['tenantId'];\n const connection = await dbService.getTenantConnection(tenantId);\n return connection;\n },\n global: true, // make the TENANT_CONNECTION available for injection globally\n});\n")),(0,o.kt)("p",null,"Again, the factory will be called on each request and the result will be stored in the CLS context. The ",(0,o.kt)("inlineCode",{parentName:"p"},"TENANT_CONNECTION")," provider, however, will still be a singleton and will not affect the scope of whatever it is injected into."),(0,o.kt)("p",null,"In the service, it can be injected using the ",(0,o.kt)("inlineCode",{parentName:"p"},"provide")," token as usual:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:"title=dogs.service.ts",title:"dogs.service.ts"},"@Injectable()\nclass DogsService {\n constructor(\n @Inject(TENANT_CONNECTION)\n private readonly connection: TenantConnection,\n ) {}\n\n getAll() {\n return this.connection.dogs.getAll();\n }\n}\n")),(0,o.kt)("h2",{id:"caveats"},"Caveats"),(0,o.kt)("h3",{id:"no-primitive-values"},"No primitive values"),(0,o.kt)("p",null,"Proxy Factory providers ",(0,o.kt)("em",{parentName:"p"},"cannot")," return a ",(0,o.kt)("em",{parentName:"p"},"primitive value"),". This is because the provider itself is the Proxy and it only delegates access once a property or a method is called on it (or if it itself is called in case the factory returns a function)."),(0,o.kt)("h3",{id:"typeof-proxies-is-always-function"},(0,o.kt)("inlineCode",{parentName:"h3"},"typeof")," Proxies is always ",(0,o.kt)("inlineCode",{parentName:"h3"},"function")),(0,o.kt)("p",null,"In order to support injecting proxies of ",(0,o.kt)("em",{parentName:"p"},"functions"),", the underlying proxy ",(0,o.kt)("em",{parentName:"p"},"target"),' is an empty function, too. It must be this way in order to be able to implement the "apply" trap.'),(0,o.kt)("p",null,"As a result of this, calling ",(0,o.kt)("inlineCode",{parentName:"p"},"typeof")," on an instance of a Proxy will always return ",(0,o.kt)("inlineCode",{parentName:"p"},"function"),", regardless of the value it holds. This is fine for most applications, but must be taken into consideration in some cases - please see ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/Papooch/nestjs-cls/issues/82"},"Issue #82")," for more info and possible workarounds."),(0,o.kt)("h2",{id:"delayed-resolution-of-proxy-providers"},"Delayed resolution of Proxy Providers"),(0,o.kt)("p",null,"By default, proxy providers are resolved as soon as the ",(0,o.kt)("inlineCode",{parentName:"p"},"setup")," function in an enhancer (middleware/guard/interceptor) finishes. For some use cases, it might be required that the resolution is delayed until some later point in the request lifecycle once more information is present in the CLS ."),(0,o.kt)("p",null,"To achieve that, set ",(0,o.kt)("inlineCode",{parentName:"p"},"resolveProxyProviders")," to ",(0,o.kt)("inlineCode",{parentName:"p"},"false")," in the enhancer options and call ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsService#resolveProxyProviders()")," manually at any time."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts"},"ClsModule.forRoot({\n middleware: {\n // highlight-start\n resolveProxyProviders: false,\n // highlight-end\n },\n});\n")),(0,o.kt)("h3",{id:"outside-web-request"},"Outside web request"),(0,o.kt)("p",null,"This is also necessary ",(0,o.kt)("a",{parentName:"p",href:"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request"},"outside the context of web request"),", otherwise all access to an injected Proxy Provider will return ",(0,o.kt)("inlineCode",{parentName:"p"},"undefined"),"."),(0,o.kt)("h4",{id:"with-clsrun"},"With cls.run()"),(0,o.kt)("p",null,"If you set up the context with ",(0,o.kt)("inlineCode",{parentName:"p"},"cls.run()")," to wrap any subsequent code thar relies on Proxy Providers."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:"title=cron.controller.ts",title:"cron.controller.ts"},"@Injectable()\nexport class CronController {\n constructor(\n private readonly someService: SomeService,\n private readonly cls: ClsService,\n );\n\n @Cron('45 * * * * *')\n async handleCron() {\n await this.cls.run(async () => {\n // prepare the context\n this.cls.set('some-key', 'some-value');\n // highlight-start\n // trigger Proxy Provider resolution\n await this.cls.resolveProxyProviders();\n // highlight-end\n await this.someService.doTheThing();\n });\n }\n}\n")),(0,o.kt)("h4",{id:"with-usecls"},"With @UseCls()"),(0,o.kt)("p",null,"The ",(0,o.kt)("inlineCode",{parentName:"p"},"resolveProxyProviders")," is set to ",(0,o.kt)("inlineCode",{parentName:"p"},"false")," by default on the ",(0,o.kt)("inlineCode",{parentName:"p"},"@UseCls")," decorator. To achieve the same behavior using it, you must set it to ",(0,o.kt)("inlineCode",{parentName:"p"},"true"),"."),(0,o.kt)("p",null,"The Proxy Providers will be resolved after the ",(0,o.kt)("inlineCode",{parentName:"p"},"setup")," phase."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:"title=cron.controller.ts",title:"cron.controller.ts"},"@Injectable()\nexport class CronController {\n constructor(private readonly someService: SomeService);\n\n @Cron('45 * * * * *')\n @UseCls({\n // highlight-start\n resolveProxyProviders: true,\n setup: (cls) => {\n this.cls.set('some-key', 'some-value');\n },\n // highlight-end\n })\n async handleCron() {\n await this.someService.doTheThing();\n }\n}\n")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/5e95c892.eba74bf1.js b/assets/js/5e95c892.eba74bf1.js new file mode 100644 index 0000000..7608a33 --- /dev/null +++ b/assets/js/5e95c892.eba74bf1.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[661],{32:(s,e,c)=>{c.r(e),c.d(e,{default:()=>d});c(7378);var r=c(624),n=c(8836),t=c(5854),u=c(5473),a=c(9145),l=c(4246);function d(s){return(0,l.jsx)(n.FG,{className:(0,r.Z)(t.k.wrapper.docsPages),children:(0,l.jsx)(a.Z,{children:(0,u.H)(s.route.routes)})})}}}]); \ No newline at end of file diff --git a/assets/js/6212613f.4cda7fb0.js b/assets/js/6212613f.4cda7fb0.js deleted file mode 100755 index 423ac77..0000000 --- a/assets/js/6212613f.4cda7fb0.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[849],{5318:(e,t,n)=>{n.d(t,{Zo:()=>u,kt:()=>m});var r=n(7378);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t =0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var c=r.createContext({}),l=function(e){var t=r.useContext(c),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},u=function(e){var t=l(e.components);return r.createElement(c.Provider,{value:t},e.children)},d="mdxType",p={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},f=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,s=e.originalType,c=e.parentName,u=i(e,["components","mdxType","originalType","parentName"]),d=l(n),f=a,m=d["".concat(c,".").concat(f)]||d[f]||p[f]||s;return n?r.createElement(m,o(o({ref:t},u),{},{components:n})):r.createElement(m,o({ref:t},u))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var s=n.length,o=new Array(s);o[0]=f;var i={};for(var c in t)hasOwnProperty.call(t,c)&&(i[c]=t[c]);i.originalType=e,i[d]="string"==typeof e?e:a,o[1]=i;for(var l=2;l {n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>o,default:()=>p,frontMatter:()=>s,metadata:()=>i,toc:()=>l});var r=n(5773),a=(n(7378),n(5318));const s={},o="Additional CLS Setup",i={unversionedId:"features-and-use-cases/additional-cls-setup",id:"features-and-use-cases/additional-cls-setup",title:"Additional CLS Setup",description:"The CLS middleware/guard/interceptor provide some default functionality, but sometimes you might want to store more contextual things in the CLS.",source:"@site/docs/03_features-and-use-cases/02_additional-cls-setup.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/additional-cls-setup",permalink:"/nestjs-cls/features-and-use-cases/additional-cls-setup",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/02_additional-cls-setup.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Request ID",permalink:"/nestjs-cls/features-and-use-cases/request-id"},next:{title:"Breaking out of DI",permalink:"/nestjs-cls/features-and-use-cases/breakin-out-of-di"}},c={},l=[{value:"Middleware",id:"middleware",level:2},{value:"Enhancers",id:"enhancers",level:2}],u={toc:l},d="wrapper";function p(e){let{components:t,...n}=e;return(0,a.kt)(d,(0,r.Z)({},u,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("h1",{id:"additional-cls-setup"},"Additional CLS Setup"),(0,a.kt)("p",null,"The CLS middleware/guard/interceptor provide some default functionality, but sometimes you might want to store more contextual things in the CLS."),(0,a.kt)("p",null,"This can be of course done in a custom enhancer bound after, but for this scenario, the options expose a ",(0,a.kt)("inlineCode",{parentName:"p"},"setup")," function, which will be executed in the enhancer right after the CLS context is set up."),(0,a.kt)("p",null,"The function receives the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsService")," instance, and can be asynchronous."),(0,a.kt)("h2",{id:"middleware"},"Middleware"),(0,a.kt)("p",null,"In case of middleware the ",(0,a.kt)("inlineCode",{parentName:"p"},"Request")," and ",(0,a.kt)("inlineCode",{parentName:"p"},"Response")," objects are passed as the second and third parameters."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},"ClsModule.forRoot({\n middleware: {\n mount: true,\n // highlight-start\n setup: (cls, req: Request, res: Response) => {\n cls.set('TENANT_ID', req.params('tenant_id'));\n cls.set('AUTH', { authenticated: false });\n },\n // highlight-end\n },\n});\n")),(0,a.kt)("h2",{id:"enhancers"},"Enhancers"),(0,a.kt)("p",null,"In a guard or interceptor, the ",(0,a.kt)("inlineCode",{parentName:"p"},"ExecutionContext")," object is passed as a second parameter."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},"ClsModule.forRoot({\n interceptor: {\n mount: true,\n // highlight-start\n setup: (cls, context) => {\n const req = context.switchToHttp().getRequest();\n cls.set('TENANT_ID', req.params('tenant_id'));\n cls.set('AUTH', { authenticated: false });\n },\n // highlight-end\n },\n});\n")))}p.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/6212613f.570af20d.js b/assets/js/6212613f.570af20d.js new file mode 100644 index 0000000..fa583e4 --- /dev/null +++ b/assets/js/6212613f.570af20d.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[849],{2867:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>r,default:()=>u,frontMatter:()=>i,metadata:()=>o,toc:()=>d});var s=n(4246),a=n(1670);const i={},r="Additional CLS Setup",o={id:"features-and-use-cases/additional-cls-setup",title:"Additional CLS Setup",description:"The CLS middleware/guard/interceptor provide some default functionality, but sometimes you might want to store more contextual things in the CLS.",source:"@site/docs/03_features-and-use-cases/02_additional-cls-setup.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/additional-cls-setup",permalink:"/nestjs-cls/features-and-use-cases/additional-cls-setup",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/02_additional-cls-setup.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Request ID",permalink:"/nestjs-cls/features-and-use-cases/request-id"},next:{title:"Breaking out of DI",permalink:"/nestjs-cls/features-and-use-cases/breaking-out-of-di"}},c={},d=[{value:"Middleware",id:"middleware",level:2},{value:"Enhancers",id:"enhancers",level:2}];function l(e){const t={code:"code",h1:"h1",h2:"h2",p:"p",pre:"pre",...(0,a.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h1,{id:"additional-cls-setup",children:"Additional CLS Setup"}),"\n",(0,s.jsx)(t.p,{children:"The CLS middleware/guard/interceptor provide some default functionality, but sometimes you might want to store more contextual things in the CLS."}),"\n",(0,s.jsxs)(t.p,{children:["This can be of course done in a custom enhancer bound after, but for this scenario, the options expose a ",(0,s.jsx)(t.code,{children:"setup"})," function, which will be executed in the enhancer right after the CLS context is set up."]}),"\n",(0,s.jsxs)(t.p,{children:["The function receives the ",(0,s.jsx)(t.code,{children:"ClsService"})," instance, and can be asynchronous."]}),"\n",(0,s.jsx)(t.h2,{id:"middleware",children:"Middleware"}),"\n",(0,s.jsxs)(t.p,{children:["In case of middleware the ",(0,s.jsx)(t.code,{children:"Request"})," and ",(0,s.jsx)(t.code,{children:"Response"})," objects are passed as the second and third parameters."]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"ClsModule.forRoot({\n middleware: {\n mount: true,\n // highlight-start\n setup: (cls, req: Request, res: Response) => {\n cls.set('TENANT_ID', req.params('tenant_id'));\n cls.set('AUTH', { authenticated: false });\n },\n // highlight-end\n },\n});\n"})}),"\n",(0,s.jsx)(t.h2,{id:"enhancers",children:"Enhancers"}),"\n",(0,s.jsxs)(t.p,{children:["In a guard or interceptor, the ",(0,s.jsx)(t.code,{children:"ExecutionContext"})," object is passed as a second parameter."]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"ClsModule.forRoot({\n interceptor: {\n mount: true,\n // highlight-start\n setup: (cls, context) => {\n const req = context.switchToHttp().getRequest ();\n cls.set('TENANT_ID', req.params('tenant_id'));\n cls.set('AUTH', { authenticated: false });\n },\n // highlight-end\n },\n});\n"})})]})}function u(e={}){const{wrapper:t}={...(0,a.a)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(l,{...e})}):l(e)}},1670:(e,t,n)=>{n.d(t,{Z:()=>o,a:()=>r});var s=n(7378);const a={},i=s.createContext(a);function r(e){const t=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:r(e.components),s.createElement(i.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/67fa07c1.8b7b0bb2.js b/assets/js/67fa07c1.8b7b0bb2.js deleted file mode 100755 index 4598018..0000000 --- a/assets/js/67fa07c1.8b7b0bb2.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[164],{5318:(e,t,r)=>{r.d(t,{Zo:()=>l,kt:()=>f});var n=r(7378);function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t =0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n =0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var c=n.createContext({}),p=function(e){var t=n.useContext(c),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},l=function(e){var t=p(e.components);return n.createElement(c.Provider,{value:t},e.children)},u="mdxType",m={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},d=n.forwardRef((function(e,t){var r=e.components,o=e.mdxType,a=e.originalType,c=e.parentName,l=s(e,["components","mdxType","originalType","parentName"]),u=p(r),d=o,f=u["".concat(c,".").concat(d)]||u[d]||m[d]||a;return r?n.createElement(f,i(i({ref:t},l),{},{components:r})):n.createElement(f,i({ref:t},l))}));function f(e,t){var r=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var a=r.length,i=new Array(a);i[0]=d;var s={};for(var c in t)hasOwnProperty.call(t,c)&&(s[c]=t[c]);s.originalType=e,s[u]="string"==typeof e?e:o,i[1]=s;for(var p=2;p{r.r(t),r.d(t,{assets:()=>c,contentTitle:()=>i,default:()=>m,frontMatter:()=>a,metadata:()=>s,toc:()=>p});var n=r(5773),o=(r(7378),r(5318));const a={},i="v2.x \u2192 v3.x",s={unversionedId:"migration-guide/v2x-v3x",id:"migration-guide/v2x-v3x",title:"v2.x \u2192 v3.x",description:"- The root registration method was renamed from register (resp. registerAsync) to forRoot (resp. forRootAsync) to align with the convention.",source:"@site/docs/06_migration-guide/01_v2x-v3x.md",sourceDirName:"06_migration-guide",slug:"/migration-guide/v2x-v3x",permalink:"/nestjs-cls/migration-guide/v2x-v3x",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/06_migration-guide/01_v2x-v3x.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Migration guide",permalink:"/nestjs-cls/migration-guide/"}},c={},p=[],l={toc:p},u="wrapper";function m(e){let{components:t,...r}=e;return(0,o.kt)(u,(0,n.Z)({},l,r,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"v2x--v3x"},(0,o.kt)("inlineCode",{parentName:"h1"},"v2.x")," \u2192 ",(0,o.kt)("inlineCode",{parentName:"h1"},"v3.x")),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},"The root registration method was ",(0,o.kt)("em",{parentName:"p"},"renamed")," from ",(0,o.kt)("inlineCode",{parentName:"p"},"register")," (resp. ",(0,o.kt)("inlineCode",{parentName:"p"},"registerAsync"),") to ",(0,o.kt)("inlineCode",{parentName:"p"},"forRoot")," (resp. ",(0,o.kt)("inlineCode",{parentName:"p"},"forRootAsync"),") to align with the convention."),(0,o.kt)("pre",{parentName:"li"},(0,o.kt)("code",{parentName:"pre",className:"language-diff"},"// highlight-start\n- ClsModule.register({\n+ ClsModule.forRoot({\n// highlight-end\n middleware: { mount: true },\n }),\n"))),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},"Namespace injection support with ",(0,o.kt)("inlineCode",{parentName:"p"},"forFeature")," was dropped entirely, and now that method is used to register ",(0,o.kt)("a",{parentName:"p",href:"/nestjs-cls/features-and-use-cases/proxy-providers"},"Proxy Providers"),". If you still have a use case for namespaces, you can create a namespaced ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsService")," and use a custom provider to inject it.",(0,o.kt)("br",{parentName:"p"}),"\n","Example:"),(0,o.kt)("pre",{parentName:"li"},(0,o.kt)("code",{parentName:"pre",className:"language-ts"},"class MyContextService extends ClsService {}\nconst myContextService = new MyContextService(new AsyncLocalStorage());\n\n// [...]\nproviders: [\n {\n provide: MyContextService,\n useValue: myContextService,\n },\n];\n")))))}m.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/6bb5cc7f.b7a03c73.js b/assets/js/6bb5cc7f.b7a03c73.js new file mode 100644 index 0000000..5442ab0 --- /dev/null +++ b/assets/js/6bb5cc7f.b7a03c73.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[499],{6035:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>r,contentTitle:()=>c,default:()=>l,frontMatter:()=>i,metadata:()=>a,toc:()=>d});var n=s(4246),o=s(1670);const i={},c="Breaking out of DI",a={id:"features-and-use-cases/breaking-out-of-di",title:"Breaking out of DI",description:"While this package aims to be compatible with NestJS's Dependency Injection, it is also possible to access the CLS context outside of it.",source:"@site/docs/03_features-and-use-cases/03_breaking-out-of-di.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/breaking-out-of-di",permalink:"/nestjs-cls/features-and-use-cases/breaking-out-of-di",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/03_breaking-out-of-di.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Additional CLS Setup",permalink:"/nestjs-cls/features-and-use-cases/additional-cls-setup"},next:{title:"Usage outside of web request",permalink:"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request"}},r={},d=[];function u(e){const t={admonition:"admonition",code:"code",h1:"h1",p:"p",pre:"pre",strong:"strong",...(0,o.a)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.h1,{id:"breaking-out-of-di",children:"Breaking out of DI"}),"\n",(0,n.jsx)(t.p,{children:"While this package aims to be compatible with NestJS's Dependency Injection, it is also possible to access the CLS context outside of it."}),"\n",(0,n.jsxs)(t.p,{children:["For that, it provides the static ",(0,n.jsx)(t.code,{children:"ClsServiceManager"})," class that exposes the ",(0,n.jsx)(t.code,{children:"getClsService()"})," method which can be used to retrieve the context outside of Nest's injection context (e.g. in top-level functions)"]}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-ts",children:"function helper() {\n const cls = ClsServiceManager.getClsService();\n // you now have access to the shared storage\n console.log(cls.getId());\n}\n"})}),"\n",(0,n.jsx)(t.admonition,{type:"caution",children:(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.strong,{children:"Please note"}),": Only use this feature where absolutely necessary. Using this technique instead of dependency injection will make it difficult to mock the ClsService and your code will become harder to test."]})})]})}function l(e={}){const{wrapper:t}={...(0,o.a)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(u,{...e})}):u(e)}},1670:(e,t,s)=>{s.d(t,{Z:()=>a,a:()=>c});var n=s(7378);const o={},i=n.createContext(o);function c(e){const t=n.useContext(i);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:c(e.components),n.createElement(i.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/6fbaaecb.c904afaa.js b/assets/js/6fbaaecb.c904afaa.js new file mode 100644 index 0000000..78fd66f --- /dev/null +++ b/assets/js/6fbaaecb.c904afaa.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[979],{726:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>s,default:()=>g,frontMatter:()=>r,metadata:()=>a,toc:()=>u});var i=t(4246),o=t(1670);const r={},s="Migration guide",a={id:"migration-guide/index",title:"Migration guide",description:"In case you're upgrading to a new major version of this library, follow the according migration guide.",source:"@site/docs/10_migration-guide/index.md",sourceDirName:"10_migration-guide",slug:"/migration-guide/",permalink:"/nestjs-cls/migration-guide/",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/10_migration-guide/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Plugin API",permalink:"/nestjs-cls/plugins/plugin-api"},next:{title:"v3.x \u2192 v4.x",permalink:"/nestjs-cls/migration-guide/v3x-v4x"}},c={},u=[];function d(e){const n={h1:"h1",p:"p",...(0,o.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.h1,{id:"migration-guide",children:"Migration guide"}),"\n",(0,i.jsx)(n.p,{children:"In case you're upgrading to a new major version of this library, follow the according migration guide."})]})}function g(e={}){const{wrapper:n}={...(0,o.a)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}},1670:(e,n,t)=>{t.d(n,{Z:()=>a,a:()=>s});var i=t(7378);const o={},r=i.createContext(o);function s(e){const n=i.useContext(r);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:s(e.components),i.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/734.9c54f551.js b/assets/js/734.9c54f551.js deleted file mode 100755 index 21a3e3f..0000000 --- a/assets/js/734.9c54f551.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! For license information please see 734.9c54f551.js.LICENSE.txt */ -(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[734],{2500:(e,t,n)=>{"use strict";e.exports=n(2587)},7360:(e,t,n)=>{"use strict";var i=n(5567),r={wrapper:{position:"relative",display:"inline-block"},hint:{position:"absolute",top:"0",left:"0",borderColor:"transparent",boxShadow:"none",opacity:"1"},input:{position:"relative",verticalAlign:"top",backgroundColor:"transparent"},inputWithNoHint:{position:"relative",verticalAlign:"top"},dropdown:{position:"absolute",top:"100%",left:"0",zIndex:"100",display:"none"},suggestions:{display:"block"},suggestion:{whiteSpace:"nowrap",cursor:"pointer"},suggestionChild:{whiteSpace:"normal"},ltr:{left:"0",right:"auto"},rtl:{left:"auto",right:"0"},defaultClasses:{root:"algolia-autocomplete",prefix:"aa",noPrefix:!1,dropdownMenu:"dropdown-menu",input:"input",hint:"hint",suggestions:"suggestions",suggestion:"suggestion",cursor:"cursor",dataset:"dataset",empty:"empty"},appendTo:{wrapper:{position:"absolute",zIndex:"100",display:"none"},input:{},inputWithNoHint:{},dropdown:{display:"block"}}};i.isMsie()&&i.mixin(r.input,{backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)"}),i.isMsie()&&i.isMsie()<=7&&i.mixin(r.input,{marginTop:"-1px"}),e.exports=r},3039:(e,t,n)=>{"use strict";var i="aaDataset",r="aaValue",s="aaDatum",o=n(5567),a=n(7294),u=n(4534),c=n(7360),l=n(2064);function h(e){var t;(e=e||{}).templates=e.templates||{},e.source||o.error("missing source"),e.name&&(t=e.name,!/^[_a-zA-Z0-9-]+$/.test(t))&&o.error("invalid dataset name: "+e.name),this.query=null,this._isEmpty=!0,this.highlight=!!e.highlight,this.name=void 0===e.name||null===e.name?o.getUniqueId():e.name,this.source=e.source,this.displayFn=function(e){return e=e||"value",o.isFunction(e)?e:t;function t(t){return t[e]}}(e.display||e.displayKey),this.debounce=e.debounce,this.cache=!1!==e.cache,this.templates=function(e,t){return{empty:e.empty&&o.templatify(e.empty),header:e.header&&o.templatify(e.header),footer:e.footer&&o.templatify(e.footer),suggestion:e.suggestion||n};function n(e){return" "+t(e)+"
"}}(e.templates,this.displayFn),this.css=o.mixin({},c,e.appendTo?c.appendTo:{}),this.cssClasses=e.cssClasses=o.mixin({},c.defaultClasses,e.cssClasses||{}),this.cssClasses.prefix=e.cssClasses.formattedPrefix||o.formatPrefix(this.cssClasses.prefix,this.cssClasses.noPrefix);var n=o.className(this.cssClasses.prefix,this.cssClasses.dataset);this.$el=e.$menu&&e.$menu.find(n+"-"+this.name).length>0?a.element(e.$menu.find(n+"-"+this.name)[0]):a.element(u.dataset.replace("%CLASS%",this.name).replace("%PREFIX%",this.cssClasses.prefix).replace("%DATASET%",this.cssClasses.dataset)),this.$menu=e.$menu,this.clearCachedSuggestions()}h.extractDatasetName=function(e){return a.element(e).data(i)},h.extractValue=function(e){return a.element(e).data(r)},h.extractDatum=function(e){var t=a.element(e).data(s);return"string"==typeof t&&(t=JSON.parse(t)),t},o.mixin(h.prototype,l,{_render:function(e,t){if(this.$el){var n,c=this,l=[].slice.call(arguments,2);if(this.$el.empty(),n=t&&t.length,this._isEmpty=!n,!n&&this.templates.empty)this.$el.html(function(){var t=[].slice.call(arguments,0);return t=[{query:e,isEmpty:!0}].concat(t),c.templates.empty.apply(this,t)}.apply(this,l)).prepend(c.templates.header?h.apply(this,l):null).append(c.templates.footer?p.apply(this,l):null);else if(n)this.$el.html(function(){var e,n,l=[].slice.call(arguments,0),h=this,p=u.suggestions.replace("%PREFIX%",this.cssClasses.prefix).replace("%SUGGESTIONS%",this.cssClasses.suggestions);return e=a.element(p).css(this.css.suggestions),n=o.map(t,f),e.append.apply(e,n),e;function f(e){var t,n=u.suggestion.replace("%PREFIX%",h.cssClasses.prefix).replace("%SUGGESTION%",h.cssClasses.suggestion);return(t=a.element(n).attr({role:"option",id:["option",Math.floor(1e8*Math.random())].join("-")}).append(c.templates.suggestion.apply(this,[e].concat(l)))).data(i,c.name),t.data(r,c.displayFn(e)||void 0),t.data(s,JSON.stringify(e)),t.children().each((function(){a.element(this).css(h.css.suggestionChild)})),t}}.apply(this,l)).prepend(c.templates.header?h.apply(this,l):null).append(c.templates.footer?p.apply(this,l):null);else if(t&&!Array.isArray(t))throw new TypeError("suggestions must be an array");this.$menu&&this.$menu.addClass(this.cssClasses.prefix+(n?"with":"without")+"-"+this.name).removeClass(this.cssClasses.prefix+(n?"without":"with")+"-"+this.name),this.trigger("rendered",e)}function h(){var t=[].slice.call(arguments,0);return t=[{query:e,isEmpty:!n}].concat(t),c.templates.header.apply(this,t)}function p(){var t=[].slice.call(arguments,0);return t=[{query:e,isEmpty:!n}].concat(t),c.templates.footer.apply(this,t)}},getRoot:function(){return this.$el},update:function(e){function t(t){if(!this.canceled&&e===this.query){var n=[].slice.call(arguments,1);this.cacheSuggestions(e,t,n),this._render.apply(this,[e,t].concat(n))}}if(this.query=e,this.canceled=!1,this.shouldFetchFromCache(e))t.apply(this,[this.cachedSuggestions].concat(this.cachedRenderExtraArgs));else{var n=this,i=function(){n.canceled||n.source(e,t.bind(n))};if(this.debounce){clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout((function(){n.debounceTimeout=null,i()}),this.debounce)}else i()}},cacheSuggestions:function(e,t,n){this.cachedQuery=e,this.cachedSuggestions=t,this.cachedRenderExtraArgs=n},shouldFetchFromCache:function(e){return this.cache&&this.cachedQuery===e&&this.cachedSuggestions&&this.cachedSuggestions.length},clearCachedSuggestions:function(){delete this.cachedQuery,delete this.cachedSuggestions,delete this.cachedRenderExtraArgs},cancel:function(){this.canceled=!0},clear:function(){this.$el&&(this.cancel(),this.$el.empty(),this.trigger("rendered",""))},isEmpty:function(){return this._isEmpty},destroy:function(){this.clearCachedSuggestions(),this.$el=null}}),e.exports=h},2570:(e,t,n)=>{"use strict";var i=n(5567),r=n(7294),s=n(2064),o=n(3039),a=n(7360);function u(e){var t,n,s,o=this;(e=e||{}).menu||i.error("menu is required"),i.isArray(e.datasets)||i.isObject(e.datasets)||i.error("1 or more datasets required"),e.datasets||i.error("datasets is required"),this.isOpen=!1,this.isEmpty=!0,this.minLength=e.minLength||0,this.templates={},this.appendTo=e.appendTo||!1,this.css=i.mixin({},a,e.appendTo?a.appendTo:{}),this.cssClasses=e.cssClasses=i.mixin({},a.defaultClasses,e.cssClasses||{}),this.cssClasses.prefix=e.cssClasses.formattedPrefix||i.formatPrefix(this.cssClasses.prefix,this.cssClasses.noPrefix),t=i.bind(this._onSuggestionClick,this),n=i.bind(this._onSuggestionMouseEnter,this),s=i.bind(this._onSuggestionMouseLeave,this);var c=i.className(this.cssClasses.prefix,this.cssClasses.suggestion);this.$menu=r.element(e.menu).on("mouseenter.aa",c,n).on("mouseleave.aa",c,s).on("click.aa",c,t),this.$container=e.appendTo?e.wrapper:this.$menu,e.templates&&e.templates.header&&(this.templates.header=i.templatify(e.templates.header),this.$menu.prepend(this.templates.header())),e.templates&&e.templates.empty&&(this.templates.empty=i.templatify(e.templates.empty),this.$empty=r.element(''),this.$menu.append(this.$empty),this.$empty.hide()),this.datasets=i.map(e.datasets,(function(t){return function(e,t,n){return new u.Dataset(i.mixin({$menu:e,cssClasses:n},t))}(o.$menu,t,e.cssClasses)})),i.each(this.datasets,(function(e){var t=e.getRoot();t&&0===t.parent().length&&o.$menu.append(t),e.onSync("rendered",o._onRendered,o)})),e.templates&&e.templates.footer&&(this.templates.footer=i.templatify(e.templates.footer),this.$menu.append(this.templates.footer()));var l=this;r.element(window).resize((function(){l._redraw()}))}i.mixin(u.prototype,s,{_onSuggestionClick:function(e){this.trigger("suggestionClicked",r.element(e.currentTarget))},_onSuggestionMouseEnter:function(e){var t=r.element(e.currentTarget);if(!t.hasClass(i.className(this.cssClasses.prefix,this.cssClasses.cursor,!0))){this._removeCursor();var n=this;setTimeout((function(){n._setCursor(t,!1)}),0)}},_onSuggestionMouseLeave:function(e){if(e.relatedTarget&&r.element(e.relatedTarget).closest("."+i.className(this.cssClasses.prefix,this.cssClasses.cursor,!0)).length>0)return;this._removeCursor(),this.trigger("cursorRemoved")},_onRendered:function(e,t){if(this.isEmpty=i.every(this.datasets,(function(e){return e.isEmpty()})),this.isEmpty)if(t.length>=this.minLength&&this.trigger("empty"),this.$empty)if(t.length=this.minLength?this._show():this._hide());this.trigger("datasetRendered")},_hide:function(){this.$container.hide()},_show:function(){this.$container.css("display","block"),this._redraw(),this.trigger("shown")},_redraw:function(){this.isOpen&&this.appendTo&&this.trigger("redrawn")},_getSuggestions:function(){return this.$menu.find(i.className(this.cssClasses.prefix,this.cssClasses.suggestion))},_getCursor:function(){return this.$menu.find(i.className(this.cssClasses.prefix,this.cssClasses.cursor)).first()},_setCursor:function(e,t){e.first().addClass(i.className(this.cssClasses.prefix,this.cssClasses.cursor,!0)).attr("aria-selected","true"),this.trigger("cursorMoved",t)},_removeCursor:function(){this._getCursor().removeClass(i.className(this.cssClasses.prefix,this.cssClasses.cursor,!0)).removeAttr("aria-selected")},_moveCursor:function(e){var t,n,i,r;this.isOpen&&(n=this._getCursor(),t=this._getSuggestions(),this._removeCursor(),-1!==(i=((i=t.index(n)+e)+1)%(t.length+1)-1)?(i<-1&&(i=t.length-1),this._setCursor(r=t.eq(i),!0),this._ensureVisible(r)):this.trigger("cursorRemoved"))},_ensureVisible:function(e){var t,n,i,r;n=(t=e.position().top)+e.height()+parseInt(e.css("margin-top"),10)+parseInt(e.css("margin-bottom"),10),i=this.$menu.scrollTop(),r=this.$menu.height()+parseInt(this.$menu.css("padding-top"),10)+parseInt(this.$menu.css("padding-bottom"),10),t<0?this.$menu.scrollTop(i+t):r {"use strict";var i=n(5567),r=n(7294);function s(e){e&&e.el||i.error("EventBus initialized without el"),this.$el=r.element(e.el)}i.mixin(s.prototype,{trigger:function(e,t,n,r){var s=i.Event("autocomplete:"+e);return this.$el.trigger(s,[t,n,r]),s}}),e.exports=s},2064:(e,t,n)=>{"use strict";var i=n(8194),r=/\s+/;function s(e,t,n,i){var s;if(!n)return this;for(t=t.split(r),n=i?function(e,t){return e.bind?e.bind(t):function(){e.apply(t,[].slice.call(arguments,0))}}(n,i):n,this._callbacks=this._callbacks||{};s=t.shift();)this._callbacks[s]=this._callbacks[s]||{sync:[],async:[]},this._callbacks[s][e].push(n);return this}function o(e,t,n){return function(){for(var i,r=0,s=e.length;!i&&r {"use strict";e.exports={wrapper:'',dropdown:'',dataset:'',suggestions:'',suggestion:''}},2981:(e,t,n)=>{"use strict";var i;i={9:"tab",27:"esc",37:"left",39:"right",13:"enter",38:"up",40:"down"};var r=n(5567),s=n(7294),o=n(2064);function a(e){var t,n,o,a,u,c=this;(e=e||{}).input||r.error("input is missing"),t=r.bind(this._onBlur,this),n=r.bind(this._onFocus,this),o=r.bind(this._onKeydown,this),a=r.bind(this._onInput,this),this.$hint=s.element(e.hint),this.$input=s.element(e.input).on("blur.aa",t).on("focus.aa",n).on("keydown.aa",o),0===this.$hint.length&&(this.setHint=this.getHint=this.clearHint=this.clearHintIfInvalid=r.noop),r.isMsie()?this.$input.on("keydown.aa keypress.aa cut.aa paste.aa",(function(e){i[e.which||e.keyCode]||r.defer(r.bind(c._onInput,c,e))})):this.$input.on("input.aa",a),this.query=this.$input.val(),this.$overflowHelper=(u=this.$input,s.element('').css({position:"absolute",visibility:"hidden",whiteSpace:"pre",fontFamily:u.css("font-family"),fontSize:u.css("font-size"),fontStyle:u.css("font-style"),fontVariant:u.css("font-variant"),fontWeight:u.css("font-weight"),wordSpacing:u.css("word-spacing"),letterSpacing:u.css("letter-spacing"),textIndent:u.css("text-indent"),textRendering:u.css("text-rendering"),textTransform:u.css("text-transform")}).insertAfter(u))}function u(e){return e.altKey||e.ctrlKey||e.metaKey||e.shiftKey}a.normalizeQuery=function(e){return(e||"").replace(/^\s*/g,"").replace(/\s{2,}/g," ")},r.mixin(a.prototype,o,{_onBlur:function(){this.resetInputValue(),this.$input.removeAttr("aria-activedescendant"),this.trigger("blurred")},_onFocus:function(){this.trigger("focused")},_onKeydown:function(e){var t=i[e.which||e.keyCode];this._managePreventDefault(t,e),t&&this._shouldTrigger(t,e)&&this.trigger(t+"Keyed",e)},_onInput:function(){this._checkInputValue()},_managePreventDefault:function(e,t){var n,i,r;switch(e){case"tab":i=this.getHint(),r=this.getInputValue(),n=i&&i!==r&&!u(t);break;case"up":case"down":n=!u(t);break;default:n=!1}n&&t.preventDefault()},_shouldTrigger:function(e,t){var n;if("tab"===e)n=!u(t);else n=!0;return n},_checkInputValue:function(){var e,t,n,i,r;e=this.getInputValue(),i=e,r=this.query,n=!(!(t=a.normalizeQuery(i)===a.normalizeQuery(r))||!this.query)&&this.query.length!==e.length,this.query=e,t?n&&this.trigger("whitespaceChanged",this.query):this.trigger("queryChanged",this.query)},focus:function(){this.$input.focus()},blur:function(){this.$input.blur()},getQuery:function(){return this.query},setQuery:function(e){this.query=e},getInputValue:function(){return this.$input.val()},setInputValue:function(e,t){void 0===e&&(e=this.query),this.$input.val(e),t?this.clearHint():this._checkInputValue()},expand:function(){this.$input.attr("aria-expanded","true")},collapse:function(){this.$input.attr("aria-expanded","false")},setActiveDescendant:function(e){this.$input.attr("aria-activedescendant",e)},removeActiveDescendant:function(){this.$input.removeAttr("aria-activedescendant")},resetInputValue:function(){this.setInputValue(this.query,!0)},getHint:function(){return this.$hint.val()},setHint:function(e){this.$hint.val(e)},clearHint:function(){this.setHint("")},clearHintIfInvalid:function(){var e,t,n;n=(e=this.getInputValue())!==(t=this.getHint())&&0===t.indexOf(e),""!==e&&n&&!this.hasOverflow()||this.clearHint()},getLanguageDirection:function(){return(this.$input.css("direction")||"ltr").toLowerCase()},hasOverflow:function(){var e=this.$input.width()-2;return this.$overflowHelper.text(this.getInputValue()),this.$overflowHelper.width()>=e},isCursorAtEnd:function(){var e,t,n;return e=this.$input.val().length,t=this.$input[0].selectionStart,r.isNumber(t)?t===e:!document.selection||((n=document.selection.createRange()).moveStart("character",-e),e===n.text.length)},destroy:function(){this.$hint.off(".aa"),this.$input.off(".aa"),this.$hint=this.$input=this.$overflowHelper=null}}),e.exports=a},4015:(e,t,n)=>{"use strict";var i="aaAttrs",r=n(5567),s=n(7294),o=n(8924),a=n(2981),u=n(2570),c=n(4534),l=n(7360);function h(e){var t,n;if((e=e||{}).input||r.error("missing input"),this.isActivated=!1,this.debug=!!e.debug,this.autoselect=!!e.autoselect,this.autoselectOnBlur=!!e.autoselectOnBlur,this.openOnFocus=!!e.openOnFocus,this.minLength=r.isNumber(e.minLength)?e.minLength:1,this.autoWidth=void 0===e.autoWidth||!!e.autoWidth,this.clearOnSelected=!!e.clearOnSelected,this.tabAutocomplete=void 0===e.tabAutocomplete||!!e.tabAutocomplete,e.hint=!!e.hint,e.hint&&e.appendTo)throw new Error("[autocomplete.js] hint and appendTo options can't be used at the same time");this.css=e.css=r.mixin({},l,e.appendTo?l.appendTo:{}),this.cssClasses=e.cssClasses=r.mixin({},l.defaultClasses,e.cssClasses||{}),this.cssClasses.prefix=e.cssClasses.formattedPrefix=r.formatPrefix(this.cssClasses.prefix,this.cssClasses.noPrefix),this.listboxId=e.listboxId=[this.cssClasses.root,"listbox",r.getUniqueId()].join("-");var a=function(e){var t,n,o,a;t=s.element(e.input),n=s.element(c.wrapper.replace("%ROOT%",e.cssClasses.root)).css(e.css.wrapper),e.appendTo||"block"!==t.css("display")||"table"!==t.parent().css("display")||n.css("display","table-cell");var u=c.dropdown.replace("%PREFIX%",e.cssClasses.prefix).replace("%DROPDOWN_MENU%",e.cssClasses.dropdownMenu);o=s.element(u).css(e.css.dropdown).attr({role:"listbox",id:e.listboxId}),e.templates&&e.templates.dropdownMenu&&o.html(r.templatify(e.templates.dropdownMenu)());a=t.clone().css(e.css.hint).css(function(e){return{backgroundAttachment:e.css("background-attachment"),backgroundClip:e.css("background-clip"),backgroundColor:e.css("background-color"),backgroundImage:e.css("background-image"),backgroundOrigin:e.css("background-origin"),backgroundPosition:e.css("background-position"),backgroundRepeat:e.css("background-repeat"),backgroundSize:e.css("background-size")}}(t)),a.val("").addClass(r.className(e.cssClasses.prefix,e.cssClasses.hint,!0)).removeAttr("id name placeholder required").prop("readonly",!0).attr({"aria-hidden":"true",autocomplete:"off",spellcheck:"false",tabindex:-1}),a.removeData&&a.removeData();t.data(i,{"aria-autocomplete":t.attr("aria-autocomplete"),"aria-expanded":t.attr("aria-expanded"),"aria-owns":t.attr("aria-owns"),autocomplete:t.attr("autocomplete"),dir:t.attr("dir"),role:t.attr("role"),spellcheck:t.attr("spellcheck"),style:t.attr("style"),type:t.attr("type")}),t.addClass(r.className(e.cssClasses.prefix,e.cssClasses.input,!0)).attr({autocomplete:"off",spellcheck:!1,role:"combobox","aria-autocomplete":e.datasets&&e.datasets[0]&&e.datasets[0].displayKey?"both":"list","aria-expanded":"false","aria-label":e.ariaLabel,"aria-owns":e.listboxId}).css(e.hint?e.css.input:e.css.inputWithNoHint);try{t.attr("dir")||t.attr("dir","auto")}catch(l){}return n=e.appendTo?n.appendTo(s.element(e.appendTo).eq(0)).eq(0):t.wrap(n).parent(),n.prepend(e.hint?a:null).append(o),{wrapper:n,input:t,hint:a,menu:o}}(e);this.$node=a.wrapper;var u=this.$input=a.input;t=a.menu,n=a.hint,e.dropdownMenuContainer&&s.element(e.dropdownMenuContainer).css("position","relative").append(t.css("top","0")),u.on("blur.aa",(function(e){var n=document.activeElement;r.isMsie()&&(t[0]===n||t[0].contains(n))&&(e.preventDefault(),e.stopImmediatePropagation(),r.defer((function(){u.focus()})))})),t.on("mousedown.aa",(function(e){e.preventDefault()})),this.eventBus=e.eventBus||new o({el:u}),this.dropdown=new h.Dropdown({appendTo:e.appendTo,wrapper:this.$node,menu:t,datasets:e.datasets,templates:e.templates,cssClasses:e.cssClasses,minLength:this.minLength}).onSync("suggestionClicked",this._onSuggestionClicked,this).onSync("cursorMoved",this._onCursorMoved,this).onSync("cursorRemoved",this._onCursorRemoved,this).onSync("opened",this._onOpened,this).onSync("closed",this._onClosed,this).onSync("shown",this._onShown,this).onSync("empty",this._onEmpty,this).onSync("redrawn",this._onRedrawn,this).onAsync("datasetRendered",this._onDatasetRendered,this),this.input=new h.Input({input:u,hint:n}).onSync("focused",this._onFocused,this).onSync("blurred",this._onBlurred,this).onSync("enterKeyed",this._onEnterKeyed,this).onSync("tabKeyed",this._onTabKeyed,this).onSync("escKeyed",this._onEscKeyed,this).onSync("upKeyed",this._onUpKeyed,this).onSync("downKeyed",this._onDownKeyed,this).onSync("leftKeyed",this._onLeftKeyed,this).onSync("rightKeyed",this._onRightKeyed,this).onSync("queryChanged",this._onQueryChanged,this).onSync("whitespaceChanged",this._onWhitespaceChanged,this),this._bindKeyboardShortcuts(e),this._setLanguageDirection()}r.mixin(h.prototype,{_bindKeyboardShortcuts:function(e){if(e.keyboardShortcuts){var t=this.$input,n=[];r.each(e.keyboardShortcuts,(function(e){"string"==typeof e&&(e=e.toUpperCase().charCodeAt(0)),n.push(e)})),s.element(document).keydown((function(e){var i=e.target||e.srcElement,r=i.tagName;if(!i.isContentEditable&&"INPUT"!==r&&"SELECT"!==r&&"TEXTAREA"!==r){var s=e.which||e.keyCode;-1!==n.indexOf(s)&&(t.focus(),e.stopPropagation(),e.preventDefault())}}))}},_onSuggestionClicked:function(e,t){var n;(n=this.dropdown.getDatumForSuggestion(t))&&this._select(n,{selectionMethod:"click"})},_onCursorMoved:function(e,t){var n=this.dropdown.getDatumForCursor(),i=this.dropdown.getCurrentCursor().attr("id");this.input.setActiveDescendant(i),n&&(t&&this.input.setInputValue(n.value,!0),this.eventBus.trigger("cursorchanged",n.raw,n.datasetName))},_onCursorRemoved:function(){this.input.resetInputValue(),this._updateHint(),this.eventBus.trigger("cursorremoved")},_onDatasetRendered:function(){this._updateHint(),this.eventBus.trigger("updated")},_onOpened:function(){this._updateHint(),this.input.expand(),this.eventBus.trigger("opened")},_onEmpty:function(){this.eventBus.trigger("empty")},_onRedrawn:function(){this.$node.css("top","0px"),this.$node.css("left","0px");var e=this.$input[0].getBoundingClientRect();this.autoWidth&&this.$node.css("width",e.width+"px");var t=this.$node[0].getBoundingClientRect(),n=e.bottom-t.top;this.$node.css("top",n+"px");var i=e.left-t.left;this.$node.css("left",i+"px"),this.eventBus.trigger("redrawn")},_onShown:function(){this.eventBus.trigger("shown"),this.autoselect&&this.dropdown.cursorTopSuggestion()},_onClosed:function(){this.input.clearHint(),this.input.removeActiveDescendant(),this.input.collapse(),this.eventBus.trigger("closed")},_onFocused:function(){if(this.isActivated=!0,this.openOnFocus){var e=this.input.getQuery();e.length>=this.minLength?this.dropdown.update(e):this.dropdown.empty(),this.dropdown.open()}},_onBlurred:function(){var e,t;e=this.dropdown.getDatumForCursor(),t=this.dropdown.getDatumForTopSuggestion();var n={selectionMethod:"blur"};this.debug||(this.autoselectOnBlur&&e?this._select(e,n):this.autoselectOnBlur&&t?this._select(t,n):(this.isActivated=!1,this.dropdown.empty(),this.dropdown.close()))},_onEnterKeyed:function(e,t){var n,i;n=this.dropdown.getDatumForCursor(),i=this.dropdown.getDatumForTopSuggestion();var r={selectionMethod:"enterKey"};n?(this._select(n,r),t.preventDefault()):this.autoselect&&i&&(this._select(i,r),t.preventDefault())},_onTabKeyed:function(e,t){if(this.tabAutocomplete){var n;(n=this.dropdown.getDatumForCursor())?(this._select(n,{selectionMethod:"tabKey"}),t.preventDefault()):this._autocomplete(!0)}else this.dropdown.close()},_onEscKeyed:function(){this.dropdown.close(),this.input.resetInputValue()},_onUpKeyed:function(){var e=this.input.getQuery();this.dropdown.isEmpty&&e.length>=this.minLength?this.dropdown.update(e):this.dropdown.moveCursorUp(),this.dropdown.open()},_onDownKeyed:function(){var e=this.input.getQuery();this.dropdown.isEmpty&&e.length>=this.minLength?this.dropdown.update(e):this.dropdown.moveCursorDown(),this.dropdown.open()},_onLeftKeyed:function(){"rtl"===this.dir&&this._autocomplete()},_onRightKeyed:function(){"ltr"===this.dir&&this._autocomplete()},_onQueryChanged:function(e,t){this.input.clearHintIfInvalid(),t.length>=this.minLength?this.dropdown.update(t):this.dropdown.empty(),this.dropdown.open(),this._setLanguageDirection()},_onWhitespaceChanged:function(){this._updateHint(),this.dropdown.open()},_setLanguageDirection:function(){var e=this.input.getLanguageDirection();this.dir!==e&&(this.dir=e,this.$node.css("direction",e),this.dropdown.setLanguageDirection(e))},_updateHint:function(){var e,t,n,i,s;(e=this.dropdown.getDatumForTopSuggestion())&&this.dropdown.isVisible()&&!this.input.hasOverflow()?(t=this.input.getInputValue(),n=a.normalizeQuery(t),i=r.escapeRegExChars(n),(s=new RegExp("^(?:"+i+")(.+$)","i").exec(e.value))?this.input.setHint(t+s[1]):this.input.clearHint()):this.input.clearHint()},_autocomplete:function(e){var t,n,i,r;t=this.input.getHint(),n=this.input.getQuery(),i=e||this.input.isCursorAtEnd(),t&&n!==t&&i&&((r=this.dropdown.getDatumForTopSuggestion())&&this.input.setInputValue(r.value),this.eventBus.trigger("autocompleted",r.raw,r.datasetName))},_select:function(e,t){void 0!==e.value&&this.input.setQuery(e.value),this.clearOnSelected?this.setVal(""):this.input.setInputValue(e.value,!0),this._setLanguageDirection(),!1===this.eventBus.trigger("selected",e.raw,e.datasetName,t).isDefaultPrevented()&&(this.dropdown.close(),r.defer(r.bind(this.dropdown.empty,this.dropdown)))},open:function(){if(!this.isActivated){var e=this.input.getInputValue();e.length>=this.minLength?this.dropdown.update(e):this.dropdown.empty()}this.dropdown.open()},close:function(){this.dropdown.close()},setVal:function(e){e=r.toStr(e),this.isActivated?this.input.setInputValue(e):(this.input.setQuery(e),this.input.setInputValue(e,!0)),this._setLanguageDirection()},getVal:function(){return this.input.getQuery()},destroy:function(){this.input.destroy(),this.dropdown.destroy(),function(e,t){var n=e.find(r.className(t.prefix,t.input));r.each(n.data(i),(function(e,t){void 0===e?n.removeAttr(t):n.attr(t,e)})),n.detach().removeClass(r.className(t.prefix,t.input,!0)).insertAfter(e),n.removeData&&n.removeData(i);e.remove()}(this.$node,this.cssClasses),this.$node=null},getWrapper:function(){return this.dropdown.$container[0]}}),h.Dropdown=u,h.Input=a,h.sources=n(7514),e.exports=h},7294:e=>{"use strict";e.exports={element:null}},2314:e=>{"use strict";e.exports=function(e){var t=e.match(/Algolia for JavaScript \((\d+\.)(\d+\.)(\d+)\)/)||e.match(/Algolia for vanilla JavaScript (\d+\.)(\d+\.)(\d+)/);if(t)return[t[1],t[2],t[3]]}},5567:(e,t,n)=>{"use strict";var i,r=n(7294);function s(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}e.exports={isArray:null,isFunction:null,isObject:null,bind:null,each:null,map:null,mixin:null,isMsie:function(e){if(void 0===e&&(e=navigator.userAgent),/(msie|trident)/i.test(e)){var t=e.match(/(msie |rv:)(\d+(.\d+)?)/i);if(t)return t[2]}return!1},escapeRegExChars:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isNumber:function(e){return"number"==typeof e},toStr:function(e){return null==e?"":e+""},cloneDeep:function(e){var t=this.mixin({},e),n=this;return this.each(t,(function(e,i){e&&(n.isArray(e)?t[i]=[].concat(e):n.isObject(e)&&(t[i]=n.cloneDeep(e)))})),t},error:function(e){throw new Error(e)},every:function(e,t){var n=!0;return e?(this.each(e,(function(i,r){n&&(n=t.call(null,i,r,e)&&n)})),!!n):n},any:function(e,t){var n=!1;return e?(this.each(e,(function(i,r){if(t.call(null,i,r,e))return n=!0,!1})),n):n},getUniqueId:(i=0,function(){return i++}),templatify:function(e){if(this.isFunction(e))return e;var t=r.element(e);return"SCRIPT"===t.prop("tagName")?function(){return t.text()}:function(){return String(e)}},defer:function(e){setTimeout(e,0)},noop:function(){},formatPrefix:function(e,t){return t?"":e+"-"},className:function(e,t,n){return(n?"":".")+e+t},escapeHighlightedString:function(e,t,n){t=t||"";var i=document.createElement("div");i.appendChild(document.createTextNode(t)),n=n||"";var r=document.createElement("div");r.appendChild(document.createTextNode(n));var o=document.createElement("div");return o.appendChild(document.createTextNode(e)),o.innerHTML.replace(RegExp(s(i.innerHTML),"g"),t).replace(RegExp(s(r.innerHTML),"g"),n)}}},9529:(e,t,n)=>{"use strict";var i=n(5567),r=n(5293),s=n(2314);e.exports=function(e,t){var n=s(e.as._ua);return n&&n[0]>=3&&n[1]>20&&((t=t||{}).additionalUA="autocomplete.js "+r),function(n,r){e.search(n,t,(function(e,t){e?i.error(e.message):r(t.hits,t)}))}}},7514:(e,t,n)=>{"use strict";e.exports={hits:n(9529),popularIn:n(3692)}},3692:(e,t,n)=>{"use strict";var i=n(5567),r=n(5293),s=n(2314);e.exports=function(e,t,n,o){var a=s(e.as._ua);if(a&&a[0]>=3&&a[1]>20&&((t=t||{}).additionalUA="autocomplete.js "+r),!n.source)return i.error("Missing 'source' key");var u=i.isFunction(n.source)?n.source:function(e){return e[n.source]};if(!n.index)return i.error("Missing 'index' key");var c=n.index;return o=o||{},function(a,l){e.search(a,t,(function(e,a){if(e)i.error(e.message);else{if(a.hits.length>0){var h=a.hits[0],p=i.mixin({hitsPerPage:0},n);delete p.source,delete p.index;var f=s(c.as._ua);return f&&f[0]>=3&&f[1]>20&&(t.additionalUA="autocomplete.js "+r),void c.search(u(h),p,(function(e,t){if(e)i.error(e.message);else{var n=[];if(o.includeAll){var r=o.allTitle||"All departments";n.push(i.mixin({facet:{value:r,count:t.nbHits}},i.cloneDeep(h)))}i.each(t.facets,(function(e,t){i.each(e,(function(e,r){n.push(i.mixin({facet:{facet:t,value:r,count:e}},i.cloneDeep(h)))}))}));for(var s=1;s{"use strict";var i=n(3847);n(7294).element=i;var r=n(5567);r.isArray=i.isArray,r.isFunction=i.isFunction,r.isObject=i.isPlainObject,r.bind=i.proxy,r.each=function(e,t){i.each(e,(function(e,n){return t(n,e)}))},r.map=i.map,r.mixin=i.extend,r.Event=i.Event;var s="aaAutocomplete",o=n(4015),a=n(8924);function u(e,t,n,u){n=r.isArray(n)?n:[].slice.call(arguments,2);var c=i(e).each((function(e,r){var c=i(r),l=new a({el:c}),h=u||new o({input:c,eventBus:l,dropdownMenuContainer:t.dropdownMenuContainer,hint:void 0===t.hint||!!t.hint,minLength:t.minLength,autoselect:t.autoselect,autoselectOnBlur:t.autoselectOnBlur,tabAutocomplete:t.tabAutocomplete,openOnFocus:t.openOnFocus,templates:t.templates,debug:t.debug,clearOnSelected:t.clearOnSelected,cssClasses:t.cssClasses,datasets:n,keyboardShortcuts:t.keyboardShortcuts,appendTo:t.appendTo,autoWidth:t.autoWidth,ariaLabel:t.ariaLabel||r.getAttribute("aria-label")});c.data(s,h)}));return c.autocomplete={},r.each(["open","close","getVal","setVal","destroy","getWrapper"],(function(e){c.autocomplete[e]=function(){var t,n=arguments;return c.each((function(r,o){var a=i(o).data(s);t=a[e].apply(a,n)})),t}})),c}u.sources=o.sources,u.escapeHighlightedString=r.escapeHighlightedString;var c="autocomplete"in window,l=window.autocomplete;u.noConflict=function(){return c?window.autocomplete=l:delete window.autocomplete,u},e.exports=u},5293:e=>{e.exports="0.37.1"},3847:e=>{var t;t=window,e.exports=function(e){var t,n,i=function(){var t,n,i,r,s,o,a=[],u=a.concat,c=a.filter,l=a.slice,h=e.document,p={},f={},d={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},g=/^\s*<(\w+|!)[^>]*>/,m=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,v=/^(?:body|html)$/i,x=/([A-Z])/g,w=["val","css","html","text","data","width","height","offset"],b=["after","prepend","before","append"],S=h.createElement("table"),C=h.createElement("tr"),E={tr:h.createElement("tbody"),tbody:S,thead:S,tfoot:S,td:C,th:C,"*":h.createElement("div")},k=/complete|loaded|interactive/,T=/^[\w-]*$/,_={},O=_.toString,A={},P=h.createElement("div"),L={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},Q=Array.isArray||function(e){return e instanceof Array};function I(e){return null==e?String(e):_[O.call(e)]||"object"}function N(e){return"function"==I(e)}function $(e){return null!=e&&e==e.window}function D(e){return null!=e&&e.nodeType==e.DOCUMENT_NODE}function R(e){return"object"==I(e)}function F(e){return R(e)&&!$(e)&&Object.getPrototypeOf(e)==Object.prototype}function j(e){var t=!!e&&"length"in e&&e.length,n=i.type(e);return"function"!=n&&!$(e)&&("array"==n||0===t||"number"==typeof t&&t>0&&t-1 in e)}function M(e){return c.call(e,(function(e){return null!=e}))}function V(e){return e.length>0?i.fn.concat.apply([],e):e}function B(e){return e.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function q(e){return e in f?f[e]:f[e]=new RegExp("(^|\\s)"+e+"(\\s|$)")}function z(e,t){return"number"!=typeof t||d[B(e)]?t:t+"px"}function H(e){var t,n;return p[e]||(t=h.createElement(e),h.body.appendChild(t),n=getComputedStyle(t,"").getPropertyValue("display"),t.parentNode.removeChild(t),"none"==n&&(n="block"),p[e]=n),p[e]}function K(e){return"children"in e?l.call(e.children):i.map(e.childNodes,(function(e){if(1==e.nodeType)return e}))}function W(e,t){var n,i=e?e.length:0;for(n=0;n$2>")),n===t&&(n=g.test(e)&&RegExp.$1),n in E||(n="*"),(a=E[n]).innerHTML=""+e,s=i.each(l.call(a.childNodes),(function(){a.removeChild(this)}))),F(r)&&(o=i(s),i.each(r,(function(e,t){w.indexOf(e)>-1?o[e](t):o.attr(e,t)}))),s},A.Z=function(e,t){return new W(e,t)},A.isZ=function(e){return e instanceof A.Z},A.init=function(e,n){var r;if(!e)return A.Z();if("string"==typeof e)if("<"==(e=e.trim())[0]&&g.test(e))r=A.fragment(e,RegExp.$1,n),e=null;else{if(n!==t)return i(n).find(e);r=A.qsa(h,e)}else{if(N(e))return i(h).ready(e);if(A.isZ(e))return e;if(Q(e))r=M(e);else if(R(e))r=[e],e=null;else if(g.test(e))r=A.fragment(e.trim(),RegExp.$1,n),e=null;else{if(n!==t)return i(n).find(e);r=A.qsa(h,e)}}return A.Z(r,e)},(i=function(e,t){return A.init(e,t)}).extend=function(e){var t,n=l.call(arguments,1);return"boolean"==typeof e&&(t=e,e=n.shift()),n.forEach((function(n){U(e,n,t)})),e},A.qsa=function(e,t){var n,i="#"==t[0],r=!i&&"."==t[0],s=i||r?t.slice(1):t,o=T.test(s);return e.getElementById&&o&&i?(n=e.getElementById(s))?[n]:[]:1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType?[]:l.call(o&&!i&&e.getElementsByClassName?r?e.getElementsByClassName(s):e.getElementsByTagName(t):e.querySelectorAll(t))},i.contains=h.documentElement.contains?function(e,t){return e!==t&&e.contains(t)}:function(e,t){for(;t&&(t=t.parentNode);)if(t===e)return!0;return!1},i.type=I,i.isFunction=N,i.isWindow=$,i.isArray=Q,i.isPlainObject=F,i.isEmptyObject=function(e){var t;for(t in e)return!1;return!0},i.isNumeric=function(e){var t=Number(e),n=typeof e;return null!=e&&"boolean"!=n&&("string"!=n||e.length)&&!isNaN(t)&&isFinite(t)||!1},i.inArray=function(e,t,n){return a.indexOf.call(t,e,n)},i.camelCase=s,i.trim=function(e){return null==e?"":String.prototype.trim.call(e)},i.uuid=0,i.support={},i.expr={},i.noop=function(){},i.map=function(e,t){var n,i,r,s=[];if(j(e))for(i=0;i =0?e:e+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each((function(){null!=this.parentNode&&this.parentNode.removeChild(this)}))},each:function(e){return a.every.call(this,(function(t,n){return!1!==e.call(t,n,t)})),this},filter:function(e){return N(e)?this.not(this.not(e)):i(c.call(this,(function(t){return A.matches(t,e)})))},add:function(e,t){return i(o(this.concat(i(e,t))))},is:function(e){return this.length>0&&A.matches(this[0],e)},not:function(e){var n=[];if(N(e)&&e.call!==t)this.each((function(t){e.call(this,t)||n.push(this)}));else{var r="string"==typeof e?this.filter(e):j(e)&&N(e.item)?l.call(e):i(e);this.forEach((function(e){r.indexOf(e)<0&&n.push(e)}))}return i(n)},has:function(e){return this.filter((function(){return R(e)?i.contains(this,e):i(this).find(e).size()}))},eq:function(e){return-1===e?this.slice(e):this.slice(e,+e+1)},first:function(){var e=this[0];return e&&!R(e)?e:i(e)},last:function(){var e=this[this.length-1];return e&&!R(e)?e:i(e)},find:function(e){var t=this;return e?"object"==typeof e?i(e).filter((function(){var e=this;return a.some.call(t,(function(t){return i.contains(t,e)}))})):1==this.length?i(A.qsa(this[0],e)):this.map((function(){return A.qsa(this,e)})):i()},closest:function(e,t){var n=[],r="object"==typeof e&&i(e);return this.each((function(i,s){for(;s&&!(r?r.indexOf(s)>=0:A.matches(s,e));)s=s!==t&&!D(s)&&s.parentNode;s&&n.indexOf(s)<0&&n.push(s)})),i(n)},parents:function(e){for(var t=[],n=this;n.length>0;)n=i.map(n,(function(e){if((e=e.parentNode)&&!D(e)&&t.indexOf(e)<0)return t.push(e),e}));return G(t,e)},parent:function(e){return G(o(this.pluck("parentNode")),e)},children:function(e){return G(this.map((function(){return K(this)})),e)},contents:function(){return this.map((function(){return this.contentDocument||l.call(this.childNodes)}))},siblings:function(e){return G(this.map((function(e,t){return c.call(K(t.parentNode),(function(e){return e!==t}))})),e)},empty:function(){return this.each((function(){this.innerHTML=""}))},pluck:function(e){return i.map(this,(function(t){return t[e]}))},show:function(){return this.each((function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=H(this.nodeName))}))},replaceWith:function(e){return this.before(e).remove()},wrap:function(e){var t=N(e);if(this[0]&&!t)var n=i(e).get(0),r=n.parentNode||this.length>1;return this.each((function(s){i(this).wrapAll(t?e.call(this,s):r?n.cloneNode(!0):n)}))},wrapAll:function(e){if(this[0]){var t;for(i(this[0]).before(e=i(e));(t=e.children()).length;)e=t.first();i(e).append(this)}return this},wrapInner:function(e){var t=N(e);return this.each((function(n){var r=i(this),s=r.contents(),o=t?e.call(this,n):e;s.length?s.wrapAll(o):r.append(o)}))},unwrap:function(){return this.parent().each((function(){i(this).replaceWith(i(this).children())})),this},clone:function(){return this.map((function(){return this.cloneNode(!0)}))},hide:function(){return this.css("display","none")},toggle:function(e){return this.each((function(){var n=i(this);(e===t?"none"==n.css("display"):e)?n.show():n.hide()}))},prev:function(e){return i(this.pluck("previousElementSibling")).filter(e||"*")},next:function(e){return i(this.pluck("nextElementSibling")).filter(e||"*")},html:function(e){return 0 in arguments?this.each((function(t){var n=this.innerHTML;i(this).empty().append(Z(this,e,t,n))})):0 in this?this[0].innerHTML:null},text:function(e){return 0 in arguments?this.each((function(t){var n=Z(this,e,t,this.textContent);this.textContent=null==n?"":""+n})):0 in this?this.pluck("textContent").join(""):null},attr:function(e,i){var r;return"string"!=typeof e||1 in arguments?this.each((function(t){if(1===this.nodeType)if(R(e))for(n in e)X(this,n,e[n]);else X(this,e,Z(this,i,t,this.getAttribute(e)))})):0 in this&&1==this[0].nodeType&&null!=(r=this[0].getAttribute(e))?r:t},removeAttr:function(e){return this.each((function(){1===this.nodeType&&e.split(" ").forEach((function(e){X(this,e)}),this)}))},prop:function(e,t){return e=L[e]||e,1 in arguments?this.each((function(n){this[e]=Z(this,t,n,this[e])})):this[0]&&this[0][e]},removeProp:function(e){return e=L[e]||e,this.each((function(){delete this[e]}))},data:function(e,n){var i="data-"+e.replace(x,"-$1").toLowerCase(),r=1 in arguments?this.attr(i,n):this.attr(i);return null!==r?Y(r):t},val:function(e){return 0 in arguments?(null==e&&(e=""),this.each((function(t){this.value=Z(this,e,t,this.value)}))):this[0]&&(this[0].multiple?i(this[0]).find("option").filter((function(){return this.selected})).pluck("value"):this[0].value)},offset:function(t){if(t)return this.each((function(e){var n=i(this),r=Z(this,t,e,n.offset()),s=n.offsetParent().offset(),o={top:r.top-s.top,left:r.left-s.left};"static"==n.css("position")&&(o.position="relative"),n.css(o)}));if(!this.length)return null;if(h.documentElement!==this[0]&&!i.contains(h.documentElement,this[0]))return{top:0,left:0};var n=this[0].getBoundingClientRect();return{left:n.left+e.pageXOffset,top:n.top+e.pageYOffset,width:Math.round(n.width),height:Math.round(n.height)}},css:function(e,t){if(arguments.length<2){var r=this[0];if("string"==typeof e){if(!r)return;return r.style[s(e)]||getComputedStyle(r,"").getPropertyValue(e)}if(Q(e)){if(!r)return;var o={},a=getComputedStyle(r,"");return i.each(e,(function(e,t){o[t]=r.style[s(t)]||a.getPropertyValue(t)})),o}}var u="";if("string"==I(e))t||0===t?u=B(e)+":"+z(e,t):this.each((function(){this.style.removeProperty(B(e))}));else for(n in e)e[n]||0===e[n]?u+=B(n)+":"+z(n,e[n])+";":this.each((function(){this.style.removeProperty(B(n))}));return this.each((function(){this.style.cssText+=";"+u}))},index:function(e){return e?this.indexOf(i(e)[0]):this.parent().children().indexOf(this[0])},hasClass:function(e){return!!e&&a.some.call(this,(function(e){return this.test(J(e))}),q(e))},addClass:function(e){return e?this.each((function(t){if("className"in this){r=[];var n=J(this);Z(this,e,t,n).split(/\s+/g).forEach((function(e){i(this).hasClass(e)||r.push(e)}),this),r.length&&J(this,n+(n?" ":"")+r.join(" "))}})):this},removeClass:function(e){return this.each((function(n){if("className"in this){if(e===t)return J(this,"");r=J(this),Z(this,e,n,r).split(/\s+/g).forEach((function(e){r=r.replace(q(e)," ")})),J(this,r.trim())}}))},toggleClass:function(e,n){return e?this.each((function(r){var s=i(this);Z(this,e,r,J(this)).split(/\s+/g).forEach((function(e){(n===t?!s.hasClass(e):n)?s.addClass(e):s.removeClass(e)}))})):this},scrollTop:function(e){if(this.length){var n="scrollTop"in this[0];return e===t?n?this[0].scrollTop:this[0].pageYOffset:this.each(n?function(){this.scrollTop=e}:function(){this.scrollTo(this.scrollX,e)})}},scrollLeft:function(e){if(this.length){var n="scrollLeft"in this[0];return e===t?n?this[0].scrollLeft:this[0].pageXOffset:this.each(n?function(){this.scrollLeft=e}:function(){this.scrollTo(e,this.scrollY)})}},position:function(){if(this.length){var e=this[0],t=this.offsetParent(),n=this.offset(),r=v.test(t[0].nodeName)?{top:0,left:0}:t.offset();return n.top-=parseFloat(i(e).css("margin-top"))||0,n.left-=parseFloat(i(e).css("margin-left"))||0,r.top+=parseFloat(i(t[0]).css("border-top-width"))||0,r.left+=parseFloat(i(t[0]).css("border-left-width"))||0,{top:n.top-r.top,left:n.left-r.left}}},offsetParent:function(){return this.map((function(){for(var e=this.offsetParent||h.body;e&&!v.test(e.nodeName)&&"static"==i(e).css("position");)e=e.offsetParent;return e}))}},i.fn.detach=i.fn.remove,["width","height"].forEach((function(e){var n=e.replace(/./,(function(e){return e[0].toUpperCase()}));i.fn[e]=function(r){var s,o=this[0];return r===t?$(o)?o["inner"+n]:D(o)?o.documentElement["scroll"+n]:(s=this.offset())&&s[e]:this.each((function(t){(o=i(this)).css(e,Z(this,r,t,o[e]()))}))}})),b.forEach((function(n,r){var s=r%2;i.fn[n]=function(){var n,o,a=i.map(arguments,(function(e){var r=[];return"array"==(n=I(e))?(e.forEach((function(e){return e.nodeType!==t?r.push(e):i.zepto.isZ(e)?r=r.concat(e.get()):void(r=r.concat(A.fragment(e)))})),r):"object"==n||null==e?e:A.fragment(e)})),u=this.length>1;return a.length<1?this:this.each((function(t,n){o=s?n:n.parentNode,n=0==r?n.nextSibling:1==r?n.firstChild:2==r?n:null;var c=i.contains(h.documentElement,o);a.forEach((function(t){if(u)t=t.cloneNode(!0);else if(!o)return i(t).remove();o.insertBefore(t,n),c&&ee(t,(function(t){if(!(null==t.nodeName||"SCRIPT"!==t.nodeName.toUpperCase()||t.type&&"text/javascript"!==t.type||t.src)){var n=t.ownerDocument?t.ownerDocument.defaultView:e;n.eval.call(n,t.innerHTML)}}))}))}))},i.fn[s?n+"To":"insert"+(r?"Before":"After")]=function(e){return i(e)[n](this),this}})),A.Z.prototype=W.prototype=i.fn,A.uniq=o,A.deserializeValue=Y,i.zepto=A,i}();return function(t){var n,i=1,r=Array.prototype.slice,s=t.isFunction,o=function(e){return"string"==typeof e},a={},u={},c="onfocusin"in e,l={focus:"focusin",blur:"focusout"},h={mouseenter:"mouseover",mouseleave:"mouseout"};function p(e){return e._zid||(e._zid=i++)}function f(e,t,n,i){if((t=d(t)).ns)var r=g(t.ns);return(a[p(e)]||[]).filter((function(e){return e&&(!t.e||e.e==t.e)&&(!t.ns||r.test(e.ns))&&(!n||p(e.fn)===p(n))&&(!i||e.sel==i)}))}function d(e){var t=(""+e).split(".");return{e:t[0],ns:t.slice(1).sort().join(" ")}}function g(e){return new RegExp("(?:^| )"+e.replace(" "," .* ?")+"(?: |$)")}function m(e,t){return e.del&&!c&&e.e in l||!!t}function y(e){return h[e]||c&&l[e]||e}function v(e,i,r,s,o,u,c){var l=p(e),f=a[l]||(a[l]=[]);i.split(/\s/).forEach((function(i){if("ready"==i)return t(document).ready(r);var a=d(i);a.fn=r,a.sel=o,a.e in h&&(r=function(e){var n=e.relatedTarget;if(!n||n!==this&&!t.contains(this,n))return a.fn.apply(this,arguments)}),a.del=u;var l=u||r;a.proxy=function(t){if(!(t=E(t)).isImmediatePropagationStopped()){try{var i=Object.getOwnPropertyDescriptor(t,"data");i&&!i.writable||(t.data=s)}catch(t){}var r=l.apply(e,t._args==n?[t]:[t].concat(t._args));return!1===r&&(t.preventDefault(),t.stopPropagation()),r}},a.i=f.length,f.push(a),"addEventListener"in e&&e.addEventListener(y(a.e),a.proxy,m(a,c))}))}function x(e,t,n,i,r){var s=p(e);(t||"").split(/\s/).forEach((function(t){f(e,t,n,i).forEach((function(t){delete a[s][t.i],"removeEventListener"in e&&e.removeEventListener(y(t.e),t.proxy,m(t,r))}))}))}u.click=u.mousedown=u.mouseup=u.mousemove="MouseEvents",t.event={add:v,remove:x},t.proxy=function(e,n){var i=2 in arguments&&r.call(arguments,2);if(s(e)){var a=function(){return e.apply(n,i?i.concat(r.call(arguments)):arguments)};return a._zid=p(e),a}if(o(n))return i?(i.unshift(e[n],e),t.proxy.apply(null,i)):t.proxy(e[n],e);throw new TypeError("expected function")},t.fn.bind=function(e,t,n){return this.on(e,t,n)},t.fn.unbind=function(e,t){return this.off(e,t)},t.fn.one=function(e,t,n,i){return this.on(e,t,n,i,1)};var w=function(){return!0},b=function(){return!1},S=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,C={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};function E(e,i){if(i||!e.isDefaultPrevented){i||(i=e),t.each(C,(function(t,n){var r=i[t];e[t]=function(){return this[n]=w,r&&r.apply(i,arguments)},e[n]=b}));try{e.timeStamp||(e.timeStamp=Date.now())}catch(r){}(i.defaultPrevented!==n?i.defaultPrevented:"returnValue"in i?!1===i.returnValue:i.getPreventDefault&&i.getPreventDefault())&&(e.isDefaultPrevented=w)}return e}function k(e){var t,i={originalEvent:e};for(t in e)S.test(t)||e[t]===n||(i[t]=e[t]);return E(i,e)}t.fn.delegate=function(e,t,n){return this.on(t,e,n)},t.fn.undelegate=function(e,t,n){return this.off(t,e,n)},t.fn.live=function(e,n){return t(document.body).delegate(this.selector,e,n),this},t.fn.die=function(e,n){return t(document.body).undelegate(this.selector,e,n),this},t.fn.on=function(e,i,a,u,c){var l,h,p=this;return e&&!o(e)?(t.each(e,(function(e,t){p.on(e,i,a,t,c)})),p):(o(i)||s(u)||!1===u||(u=a,a=i,i=n),u!==n&&!1!==a||(u=a,a=n),!1===u&&(u=b),p.each((function(n,s){c&&(l=function(e){return x(s,e.type,u),u.apply(this,arguments)}),i&&(h=function(e){var n,o=t(e.target).closest(i,s).get(0);if(o&&o!==s)return n=t.extend(k(e),{currentTarget:o,liveFired:s}),(l||u).apply(o,[n].concat(r.call(arguments,1)))}),v(s,e,u,a,i,h||l)})))},t.fn.off=function(e,i,r){var a=this;return e&&!o(e)?(t.each(e,(function(e,t){a.off(e,i,t)})),a):(o(i)||s(r)||!1===r||(r=i,i=n),!1===r&&(r=b),a.each((function(){x(this,e,r,i)})))},t.fn.trigger=function(e,n){return(e=o(e)||t.isPlainObject(e)?t.Event(e):E(e))._args=n,this.each((function(){e.type in l&&"function"==typeof this[e.type]?this[e.type]():"dispatchEvent"in this?this.dispatchEvent(e):t(this).triggerHandler(e,n)}))},t.fn.triggerHandler=function(e,n){var i,r;return this.each((function(s,a){(i=k(o(e)?t.Event(e):e))._args=n,i.target=a,t.each(f(a,e.type||e),(function(e,t){if(r=t.proxy(i),i.isImmediatePropagationStopped())return!1}))})),r},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach((function(e){t.fn[e]=function(t){return 0 in arguments?this.bind(e,t):this.trigger(e)}})),t.Event=function(e,t){o(e)||(e=(t=e).type);var n=document.createEvent(u[e]||"Events"),i=!0;if(t)for(var r in t)"bubbles"==r?i=!!t[r]:n[r]=t[r];return n.initEvent(e,i,!0),E(n)}}(i),n=[],i.fn.remove=function(){return this.each((function(){this.parentNode&&("IMG"===this.tagName&&(n.push(this),this.src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=",t&&clearTimeout(t),t=setTimeout((function(){n=[]}),6e4)),this.parentNode.removeChild(this))}))},function(e){var t={},n=e.fn.data,i=e.camelCase,r=e.expando="Zepto"+ +new Date,s=[];function o(s,o){var u=s[r],c=u&&t[u];if(void 0===o)return c||a(s);if(c){if(o in c)return c[o];var l=i(o);if(l in c)return c[l]}return n.call(e(s),o)}function a(n,s,o){var a=n[r]||(n[r]=++e.uuid),c=t[a]||(t[a]=u(n));return void 0!==s&&(c[i(s)]=o),c}function u(t){var n={};return e.each(t.attributes||s,(function(t,r){0==r.name.indexOf("data-")&&(n[i(r.name.replace("data-",""))]=e.zepto.deserializeValue(r.value))})),n}e.fn.data=function(t,n){return void 0===n?e.isPlainObject(t)?this.each((function(n,i){e.each(t,(function(e,t){a(i,e,t)}))})):0 in this?o(this[0],t):void 0:this.each((function(){a(this,t,n)}))},e.data=function(t,n,i){return e(t).data(n,i)},e.hasData=function(n){var i=n[r],s=i&&t[i];return!!s&&!e.isEmptyObject(s)},e.fn.removeData=function(n){return"string"==typeof n&&(n=n.split(/\s+/)),this.each((function(){var s=this[r],o=s&&t[s];o&&e.each(n||o,(function(e){delete o[n?i(this):e]}))}))},["remove","empty"].forEach((function(t){var n=e.fn[t];e.fn[t]=function(){var e=this.find("*");return"remove"===t&&(e=e.add(this)),e.removeData(),n.call(this)}}))}(i),i}(t)},9921:(e,t)=>{!function(e){var t=/\S/,n=/\"/g,i=/\n/g,r=/\r/g,s=/\\/g,o=/\u2028/,a=/\u2029/;function u(e){"}"===e.n.substr(e.n.length-1)&&(e.n=e.n.substring(0,e.n.length-1))}function c(e){return e.trim?e.trim():e.replace(/^\s*|\s*$/g,"")}function l(e,t,n){if(t.charAt(n)!=e.charAt(0))return!1;for(var i=1,r=e.length;i ":7,"=":8,_v:9,"{":10,"&":11,_t:12},e.scan=function(n,i){var r=n.length,s=0,o=null,a=null,h="",p=[],f=!1,d=0,g=0,m="{{",y="}}";function v(){h.length>0&&(p.push({tag:"_t",text:new String(h)}),h="")}function x(n,i){if(v(),n&&function(){for(var n=!0,i=g;i "==r.tag&&(r.indent=p[s].text.toString()),p.splice(s,1));else i||p.push({tag:"\n"});f=!1,g=p.length}function w(e,t){var n="="+y,i=e.indexOf(n,t),r=c(e.substring(e.indexOf("=",t)+1,i)).split(" ");return m=r[0],y=r[r.length-1],i+n.length-1}for(i&&(i=i.split(" "),m=i[0],y=i[1]),d=0;d 0;){if(u=t.shift(),s&&"<"==s.tag&&!(u.tag in h))throw new Error("Illegal content in < super tag.");if(e.tags[u.tag]<=e.tags.$||f(u,r))i.push(u),u.nodes=p(t,u.tag,i,r);else{if("/"==u.tag){if(0===i.length)throw new Error("Closing tag without opener: /"+u.n);if(a=i.pop(),u.n!=a.n&&!d(u.n,a.n,r))throw new Error("Nesting error: "+a.n+" vs. "+u.n);return a.end=u.i,o}"\n"==u.tag&&(u.last=0==t.length||"\n"==t[0].tag)}o.push(u)}if(i.length>0)throw new Error("missing closing tag: "+i.pop().n);return o}function f(e,t){for(var n=0,i=t.length;n":x,"<":function(t,n){var i={partials:{},code:"",subs:{},inPartial:!0};e.walk(t.nodes,i);var r=n.partials[x(t,n)];r.subs=i.subs,r.partials=i.partials},$:function(t,n){var i={subs:{},code:"",partials:n.partials,prefix:t.n};e.walk(t.nodes,i),n.subs[t.n]=i.code,n.inPartial||(n.code+='t.sub("'+y(t.n)+'",c,p,i);')},"\n":function(e,t){t.code+=b('"\\n"'+(e.last?"":" + i"))},_v:function(e,t){t.code+="t.b(t.v(t."+v(e.n)+'("'+y(e.n)+'",c,p,0)));'},_t:function(e,t){t.code+=b('"'+y(e.text)+'"')},"{":w,"&":w},e.walk=function(t,n){for(var i,r=0,s=t.length;r {var i=n(9921);i.Template=n(3067).Template,i.template=i.Template,e.exports=i},3067:(e,t)=>{!function(e){function t(e,t,n){var i;return t&&"object"==typeof t&&(void 0!==t[e]?i=t[e]:n&&t.get&&"function"==typeof t.get&&(i=t.get(e))),i}e.Template=function(e,t,n,i){e=e||{},this.r=e.code||this.r,this.c=n,this.options=i||{},this.text=t||"",this.partials=e.partials||{},this.subs=e.subs||{},this.buf=""},e.Template.prototype={r:function(e,t,n){return""},v:function(e){return e=u(e),a.test(e)?e.replace(n,"&").replace(i,"<").replace(r,">").replace(s,"'").replace(o,"""):e},t:u,render:function(e,t,n){return this.ri([e],t||{},n)},ri:function(e,t,n){return this.r(e,t,n)},ep:function(e,t){var n=this.partials[e],i=t[n.name];if(n.instance&&n.base==i)return n.instance;if("string"==typeof i){if(!this.c)throw new Error("No compiler available.");i=this.c.compile(i,this.options)}if(!i)return null;if(this.partials[e].base=i,n.subs){for(key in t.stackText||(t.stackText={}),n.subs)t.stackText[key]||(t.stackText[key]=void 0!==this.activeSub&&t.stackText[this.activeSub]?t.stackText[this.activeSub]:this.text);i=function(e,t,n,i,r,s){function o(){}function a(){}var u;o.prototype=e,a.prototype=e.subs;var c=new o;for(u in c.subs=new a,c.subsText={},c.buf="",i=i||{},c.stackSubs=i,c.subsText=s,t)i[u]||(i[u]=t[u]);for(u in i)c.subs[u]=i[u];for(u in r=r||{},c.stackPartials=r,n)r[u]||(r[u]=n[u]);for(u in r)c.partials[u]=r[u];return c}(i,n.subs,n.partials,this.stackSubs,this.stackPartials,t.stackText)}return this.partials[e].instance=i,i},rp:function(e,t,n,i){var r=this.ep(e,n);return r?r.ri(t,n,i):""},rs:function(e,t,n){var i=e[e.length-1];if(c(i))for(var r=0;r=0;u--)if(void 0!==(s=t(e,n[u],a))){o=!0;break}return o?(r||"function"!=typeof s||(s=this.mv(s,n,i)),s):!r&&""},ls:function(e,t,n,i,r){var s=this.options.delimiters;return this.options.delimiters=r,this.b(this.ct(u(e.call(t,i)),t,n)),this.options.delimiters=s,!1},ct:function(e,t,n){if(this.options.disableLambda)throw new Error("Lambda features disabled.");return this.c.compile(e,this.options).render(t,n)},b:function(e){this.buf+=e},fl:function(){var e=this.buf;return this.buf="",e},ms:function(e,t,n,i,r,s,o){var a,u=t[t.length-1],c=e.call(u);return"function"==typeof c?!!i||(a=this.activeSub&&this.subsText&&this.subsText[this.activeSub]?this.subsText[this.activeSub]:this.text,this.ls(c,u,n,a.substring(r,s),o)):c},mv:function(e,t,n){var i=t[t.length-1],r=e.call(i);return"function"==typeof r?this.ct(u(r.call(i)),i,n):r},sub:function(e,t,n,i){var r=this.subs[e];r&&(this.activeSub=e,r(t,n,this,i),this.activeSub=!1)}};var n=/&/g,i=//g,s=/\'/g,o=/\"/g,a=/[&<>\"\']/;function u(e){return String(null==e?"":e)}var c=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}}(t)},8194:(e,t,n)=>{"use strict";var i,r,s,o=[n(5352),n(717),n(4752),n(2696),n(4206),n(8842)],a=-1,u=[],c=!1;function l(){i&&r&&(i=!1,r.length?u=r.concat(u):a=-1,u.length&&h())}function h(){if(!i){c=!1,i=!0;for(var e=u.length,t=setTimeout(l);e;){for(r=u,u=[];r&&++a 1)for(var n=1;n {"use strict";t.test=function(){return!n.g.setImmediate&&void 0!==n.g.MessageChannel},t.install=function(e){var t=new n.g.MessageChannel;return t.port1.onmessage=e,function(){t.port2.postMessage(0)}}},4752:(e,t,n)=>{"use strict";var i=n.g.MutationObserver||n.g.WebKitMutationObserver;t.test=function(){return i},t.install=function(e){var t=0,r=new i(e),s=n.g.document.createTextNode("");return r.observe(s,{characterData:!0}),function(){s.data=t=++t%2}}},717:(e,t,n)=>{"use strict";t.test=function(){return"function"==typeof n.g.queueMicrotask},t.install=function(e){return function(){n.g.queueMicrotask(e)}}},4206:(e,t,n)=>{"use strict";t.test=function(){return"document"in n.g&&"onreadystatechange"in n.g.document.createElement("script")},t.install=function(e){return function(){var t=n.g.document.createElement("script");return t.onreadystatechange=function(){e(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},n.g.document.documentElement.appendChild(t),e}}},8842:(e,t)=>{"use strict";t.test=function(){return!0},t.install=function(e){return function(){setTimeout(e,0)}}},8230:(e,t,n)=>{var i,r;!function(){var s,o,a,u,c,l,h,p,f,d,g,m,y,v,x,w,b,S,C,E,k,T,_,O,A,P,L,Q,I,N,$=function(e){var t=new $.Builder;return t.pipeline.add($.trimmer,$.stopWordFilter,$.stemmer),t.searchPipeline.add($.stemmer),e.call(t,t),t.build()};$.version="2.3.9",$.utils={},$.utils.warn=(s=this,function(e){s.console&&console.warn&&console.warn(e)}),$.utils.asString=function(e){return null==e?"":e.toString()},$.utils.clone=function(e){if(null==e)return e;for(var t=Object.create(null),n=Object.keys(e),i=0;i 0){var u=$.utils.clone(t)||{};u.position=[o,a],u.index=r.length,r.push(new $.Token(n.slice(o,s),u))}o=s+1}}return r},$.tokenizer.separator=/[\s\-]+/,$.Pipeline=function(){this._stack=[]},$.Pipeline.registeredFunctions=Object.create(null),$.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&$.utils.warn("Overwriting existing registered function: "+t),e.label=t,$.Pipeline.registeredFunctions[e.label]=e},$.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||$.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},$.Pipeline.load=function(e){var t=new $.Pipeline;return e.forEach((function(e){var n=$.Pipeline.registeredFunctions[e];if(!n)throw new Error("Cannot load unregistered function: "+e);t.add(n)})),t},$.Pipeline.prototype.add=function(){Array.prototype.slice.call(arguments).forEach((function(e){$.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)}),this)},$.Pipeline.prototype.after=function(e,t){$.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);if(-1==n)throw new Error("Cannot find existingFn");n+=1,this._stack.splice(n,0,t)},$.Pipeline.prototype.before=function(e,t){$.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);if(-1==n)throw new Error("Cannot find existingFn");this._stack.splice(n,0,t)},$.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);-1!=t&&this._stack.splice(t,1)},$.Pipeline.prototype.run=function(e){for(var t=this._stack.length,n=0;n 1&&(s e&&(n=r),s!=e);)i=n-t,r=t+Math.floor(i/2),s=this.elements[2*r];return s==e||s>e?2*r:s a?c+=2:o==a&&(t+=n[u+1]*i[c+1],u+=2,c+=2);return t},$.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},$.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),t=1,n=0;t 0){var s,o=r.str.charAt(0);o in r.node.edges?s=r.node.edges[o]:(s=new $.TokenSet,r.node.edges[o]=s),1==r.str.length&&(s.final=!0),i.push({node:s,editsRemaining:r.editsRemaining,str:r.str.slice(1)})}if(0!=r.editsRemaining){if("*"in r.node.edges)var a=r.node.edges["*"];else{a=new $.TokenSet;r.node.edges["*"]=a}if(0==r.str.length&&(a.final=!0),i.push({node:a,editsRemaining:r.editsRemaining-1,str:r.str}),r.str.length>1&&i.push({node:r.node,editsRemaining:r.editsRemaining-1,str:r.str.slice(1)}),1==r.str.length&&(r.node.final=!0),r.str.length>=1){if("*"in r.node.edges)var u=r.node.edges["*"];else{u=new $.TokenSet;r.node.edges["*"]=u}1==r.str.length&&(u.final=!0),i.push({node:u,editsRemaining:r.editsRemaining-1,str:r.str.slice(1)})}if(r.str.length>1){var c,l=r.str.charAt(0),h=r.str.charAt(1);h in r.node.edges?c=r.node.edges[h]:(c=new $.TokenSet,r.node.edges[h]=c),1==r.str.length&&(c.final=!0),i.push({node:c,editsRemaining:r.editsRemaining-1,str:l+r.str.slice(2)})}}}return n},$.TokenSet.fromString=function(e){for(var t=new $.TokenSet,n=t,i=0,r=e.length;i =e;t--){var n=this.uncheckedNodes[t],i=n.child.toString();i in this.minimizedNodes?n.parent.edges[n.char]=this.minimizedNodes[i]:(n.child._str=i,this.minimizedNodes[i]=n.child),this.uncheckedNodes.pop()}},$.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},$.Index.prototype.search=function(e){return this.query((function(t){new $.QueryParser(e,t).parse()}))},$.Index.prototype.query=function(e){for(var t=new $.Query(this.fields),n=Object.create(null),i=Object.create(null),r=Object.create(null),s=Object.create(null),o=Object.create(null),a=0;a 1?1:e},$.Builder.prototype.k1=function(e){this._k1=e},$.Builder.prototype.add=function(e,t){var n=e[this._ref],i=Object.keys(this._fields);this._documents[n]=t||{},this.documentCount+=1;for(var r=0;r =this.length)return $.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},$.QueryLexer.prototype.width=function(){return this.pos-this.start},$.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},$.QueryLexer.prototype.backup=function(){this.pos-=1},$.QueryLexer.prototype.acceptDigitRun=function(){var e,t;do{t=(e=this.next()).charCodeAt(0)}while(t>47&&t<58);e!=$.QueryLexer.EOS&&this.backup()},$.QueryLexer.prototype.more=function(){return this.pos 1&&(e.backup(),e.emit($.QueryLexer.TERM)),e.ignore(),e.more())return $.QueryLexer.lexText},$.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit($.QueryLexer.EDIT_DISTANCE),$.QueryLexer.lexText},$.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit($.QueryLexer.BOOST),$.QueryLexer.lexText},$.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit($.QueryLexer.TERM)},$.QueryLexer.termSeparator=$.tokenizer.separator,$.QueryLexer.lexText=function(e){for(;;){var t=e.next();if(t==$.QueryLexer.EOS)return $.QueryLexer.lexEOS;if(92!=t.charCodeAt(0)){if(":"==t)return $.QueryLexer.lexField;if("~"==t)return e.backup(),e.width()>0&&e.emit($.QueryLexer.TERM),$.QueryLexer.lexEditDistance;if("^"==t)return e.backup(),e.width()>0&&e.emit($.QueryLexer.TERM),$.QueryLexer.lexBoost;if("+"==t&&1===e.width())return e.emit($.QueryLexer.PRESENCE),$.QueryLexer.lexText;if("-"==t&&1===e.width())return e.emit($.QueryLexer.PRESENCE),$.QueryLexer.lexText;if(t.match($.QueryLexer.termSeparator))return $.QueryLexer.lexTerm}else e.escapeCharacter()}},$.QueryParser=function(e,t){this.lexer=new $.QueryLexer(e),this.query=t,this.currentClause={},this.lexemeIdx=0},$.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=$.QueryParser.parseClause;e;)e=e(this);return this.query},$.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},$.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},$.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},$.QueryParser.parseClause=function(e){var t=e.peekLexeme();if(null!=t)switch(t.type){case $.QueryLexer.PRESENCE:return $.QueryParser.parsePresence;case $.QueryLexer.FIELD:return $.QueryParser.parseField;case $.QueryLexer.TERM:return $.QueryParser.parseTerm;default:var n="expected either a field or a term, found "+t.type;throw t.str.length>=1&&(n+=" with value '"+t.str+"'"),new $.QueryParseError(n,t.start,t.end)}},$.QueryParser.parsePresence=function(e){var t=e.consumeLexeme();if(null!=t){switch(t.str){case"-":e.currentClause.presence=$.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=$.Query.presence.REQUIRED;break;default:var n="unrecognised presence operator'"+t.str+"'";throw new $.QueryParseError(n,t.start,t.end)}var i=e.peekLexeme();if(null==i){n="expecting term or field, found nothing";throw new $.QueryParseError(n,t.start,t.end)}switch(i.type){case $.QueryLexer.FIELD:return $.QueryParser.parseField;case $.QueryLexer.TERM:return $.QueryParser.parseTerm;default:n="expecting term or field, found '"+i.type+"'";throw new $.QueryParseError(n,i.start,i.end)}}},$.QueryParser.parseField=function(e){var t=e.consumeLexeme();if(null!=t){if(-1==e.query.allFields.indexOf(t.str)){var n=e.query.allFields.map((function(e){return"'"+e+"'"})).join(", "),i="unrecognised field '"+t.str+"', possible fields: "+n;throw new $.QueryParseError(i,t.start,t.end)}e.currentClause.fields=[t.str];var r=e.peekLexeme();if(null==r){i="expecting term, found nothing";throw new $.QueryParseError(i,t.start,t.end)}if(r.type===$.QueryLexer.TERM)return $.QueryParser.parseTerm;i="expecting term, found '"+r.type+"'";throw new $.QueryParseError(i,r.start,r.end)}},$.QueryParser.parseTerm=function(e){var t=e.consumeLexeme();if(null!=t){e.currentClause.term=t.str.toLowerCase(),-1!=t.str.indexOf("*")&&(e.currentClause.usePipeline=!1);var n=e.peekLexeme();if(null!=n)switch(n.type){case $.QueryLexer.TERM:return e.nextClause(),$.QueryParser.parseTerm;case $.QueryLexer.FIELD:return e.nextClause(),$.QueryParser.parseField;case $.QueryLexer.EDIT_DISTANCE:return $.QueryParser.parseEditDistance;case $.QueryLexer.BOOST:return $.QueryParser.parseBoost;case $.QueryLexer.PRESENCE:return e.nextClause(),$.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+n.type+"'";throw new $.QueryParseError(i,n.start,n.end)}else e.nextClause()}},$.QueryParser.parseEditDistance=function(e){var t=e.consumeLexeme();if(null!=t){var n=parseInt(t.str,10);if(isNaN(n)){var i="edit distance must be numeric";throw new $.QueryParseError(i,t.start,t.end)}e.currentClause.editDistance=n;var r=e.peekLexeme();if(null!=r)switch(r.type){case $.QueryLexer.TERM:return e.nextClause(),$.QueryParser.parseTerm;case $.QueryLexer.FIELD:return e.nextClause(),$.QueryParser.parseField;case $.QueryLexer.EDIT_DISTANCE:return $.QueryParser.parseEditDistance;case $.QueryLexer.BOOST:return $.QueryParser.parseBoost;case $.QueryLexer.PRESENCE:return e.nextClause(),$.QueryParser.parsePresence;default:i="Unexpected lexeme type '"+r.type+"'";throw new $.QueryParseError(i,r.start,r.end)}else e.nextClause()}},$.QueryParser.parseBoost=function(e){var t=e.consumeLexeme();if(null!=t){var n=parseInt(t.str,10);if(isNaN(n)){var i="boost must be numeric";throw new $.QueryParseError(i,t.start,t.end)}e.currentClause.boost=n;var r=e.peekLexeme();if(null!=r)switch(r.type){case $.QueryLexer.TERM:return e.nextClause(),$.QueryParser.parseTerm;case $.QueryLexer.FIELD:return e.nextClause(),$.QueryParser.parseField;case $.QueryLexer.EDIT_DISTANCE:return $.QueryParser.parseEditDistance;case $.QueryLexer.BOOST:return $.QueryParser.parseBoost;case $.QueryLexer.PRESENCE:return e.nextClause(),$.QueryParser.parsePresence;default:i="Unexpected lexeme type '"+r.type+"'";throw new $.QueryParseError(i,r.start,r.end)}else e.nextClause()}},void 0===(r="function"==typeof(i=function(){return $})?i.call(t,n,t,e):i)||(e.exports=r)}()}}]); \ No newline at end of file diff --git a/assets/js/739a1e5f.97c3a5dc.js b/assets/js/739a1e5f.97c3a5dc.js new file mode 100644 index 0000000..e16c455 --- /dev/null +++ b/assets/js/739a1e5f.97c3a5dc.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[180],{2599:(e,n,t)=>{t.d(n,{Z:()=>i});t(7378);var a=t(624);const s={tabItem:"tabItem_wHwb"};var r=t(4246);function i(e){let{children:n,hidden:t,className:i}=e;return(0,r.jsx)("div",{role:"tabpanel",className:(0,a.Z)(s.tabItem,i),hidden:t,children:n})}},8447:(e,n,t)=>{t.d(n,{Z:()=>y});var a=t(7378),s=t(624),r=t(9169),i=t(3620),l=t(9749),c=t(8981),o=t(56),d=t(8796);function h(e){return a.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,a.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the component should be , and every should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function u(e){const{values:n,children:t}=e;return(0,a.useMemo)((()=>{const e=n??function(e){return h(e).map((e=>{let{props:{value:n,label:t,attributes:a,default:s}}=e;return{value:n,label:t,attributes:a,default:s}}))}(t);return function(e){const n=(0,o.l)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in . Every value needs to be unique.`)}(e),e}),[n,t])}function p(e){let{value:n,tabValues:t}=e;return t.some((e=>e.value===n))}function m(e){let{queryString:n=!1,groupId:t}=e;const s=(0,i.k6)(),r=function(e){let{queryString:n=!1,groupId:t}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!t)throw new Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return t??null}({queryString:n,groupId:t});return[(0,c._X)(r),(0,a.useCallback)((e=>{if(!r)return;const n=new URLSearchParams(s.location.search);n.set(r,e),s.replace({...s.location,search:n.toString()})}),[r,s])]}function x(e){const{defaultValue:n,queryString:t=!1,groupId:s}=e,r=u(e),[i,c]=(0,a.useState)((()=>function(e){let{defaultValue:n,tabValues:t}=e;if(0===t.length)throw new Error("Docusaurus error: the component requires at least one children component");if(n){if(!p({value:n,tabValues:t}))throw new Error(`Docusaurus error: The has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${t.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const a=t.find((e=>e.default))??t[0];if(!a)throw new Error("Unexpected error: 0 tabValues");return a.value}({defaultValue:n,tabValues:r}))),[o,h]=m({queryString:t,groupId:s}),[x,j]=function(e){let{groupId:n}=e;const t=function(e){return e?`docusaurus.tab.${e}`:null}(n),[s,r]=(0,d.Nk)(t);return[s,(0,a.useCallback)((e=>{t&&r.set(e)}),[t,r])]}({groupId:s}),g=(()=>{const e=o??x;return p({value:e,tabValues:r})?e:null})();(0,l.Z)((()=>{g&&c(g)}),[g]);return{selectedValue:i,selectValue:(0,a.useCallback)((e=>{if(!p({value:e,tabValues:r}))throw new Error(`Can't select invalid tab value=${e}`);c(e),h(e),j(e)}),[h,j,r]),tabValues:r}}var j=t(362);const g={tabList:"tabList_J5MA",tabItem:"tabItem_l0OV"};var b=t(4246);function f(e){let{className:n,block:t,selectedValue:a,selectValue:i,tabValues:l}=e;const c=[],{blockElementScrollPositionUntilNextRender:o}=(0,r.o5)(),d=e=>{const n=e.currentTarget,t=c.indexOf(n),s=l[t].value;s!==a&&(o(n),i(s))},h=e=>{let n=null;switch(e.key){case"Enter":d(e);break;case"ArrowRight":{const t=c.indexOf(e.currentTarget)+1;n=c[t]??c[0];break}case"ArrowLeft":{const t=c.indexOf(e.currentTarget)-1;n=c[t]??c[c.length-1];break}}n?.focus()};return(0,b.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,s.Z)("tabs",{"tabs--block":t},n),children:l.map((e=>{let{value:n,label:t,attributes:r}=e;return(0,b.jsx)("li",{role:"tab",tabIndex:a===n?0:-1,"aria-selected":a===n,ref:e=>c.push(e),onKeyDown:h,onClick:d,...r,className:(0,s.Z)("tabs__item",g.tabItem,r?.className,{"tabs__item--active":a===n}),children:t??n},n)}))})}function v(e){let{lazy:n,children:t,selectedValue:s}=e;const r=(Array.isArray(t)?t:[t]).filter(Boolean);if(n){const e=r.find((e=>e.props.value===s));return e?(0,a.cloneElement)(e,{className:"margin-top--md"}):null}return(0,b.jsx)("div",{className:"margin-top--md",children:r.map(((e,n)=>(0,a.cloneElement)(e,{key:n,hidden:e.props.value!==s})))})}function w(e){const n=x(e);return(0,b.jsxs)("div",{className:(0,s.Z)("tabs-container",g.tabList),children:[(0,b.jsx)(f,{...e,...n}),(0,b.jsx)(v,{...e,...n})]})}function y(e){const n=(0,j.Z)();return(0,b.jsx)(w,{...e,children:h(e.children)},String(n))}},7518:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>d,contentTitle:()=>c,default:()=>p,frontMatter:()=>l,metadata:()=>o,toc:()=>h});var a=t(4246),s=t(1670),r=t(8447),i=t(2599);const l={},c="@nestjs-cls/transactional",o={id:"plugins/available-plugins/transactional/index",title:"@nestjs-cls/transactional",description:"The Transactional plugin for nestjs-cls provides a generic interface that can be used to wrap any function call in",source:"@site/docs/06_plugins/01_available-plugins/01-transactional/index.md",sourceDirName:"06_plugins/01_available-plugins/01-transactional",slug:"/plugins/available-plugins/transactional/",permalink:"/nestjs-cls/plugins/available-plugins/transactional/",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/06_plugins/01_available-plugins/01-transactional/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Available Plugins",permalink:"/nestjs-cls/plugins/available-plugins/"},next:{title:"Prisma adapter",permalink:"/nestjs-cls/plugins/available-plugins/transactional/prisma-adapter"}},d={},h=[{value:"Installation",id:"installation",level:2},{value:"Example",id:"example",level:2},{value:"Plugin registration",id:"plugin-registration",level:3},{value:"Using the TransactionHost",id:"using-the-transactionhost",level:3},{value:"Using the Transactional decorator",id:"using-the-transactional-decorator",level:3},{value:"Passing transaction options",id:"passing-transaction-options",level:3},{value:"ClsPluginTransactional Interface",id:"clsplugintransactional-interface",level:2},{value:"TransactionHost Interface",id:"transactionhost-interface",level:2},{value:"Considerations",id:"considerations",level:2}];function u(e){const n={a:"a",admonition:"admonition",br:"br",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.a)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.h1,{id:"nestjs-clstransactional",children:"@nestjs-cls/transactional"}),"\n",(0,a.jsxs)(n.p,{children:["The ",(0,a.jsx)(n.em,{children:"Transactional"})," plugin for ",(0,a.jsx)(n.code,{children:"nestjs-cls"})," provides a generic interface that can be used to wrap any function call in\na CLS-enabled transaction by storing the transaction reference in the CLS context."]}),"\n",(0,a.jsx)(n.p,{children:"The transaction reference can be then retrieved in any other service and refer to the same transaction without having to pass it around."}),"\n",(0,a.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,a.jsxs)(r.Z,{children:[(0,a.jsx)(i.Z,{value:"npm",label:"npm",default:!0,children:(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-bash",children:"npm install @nestjs-cls/transactional\n"})})}),(0,a.jsx)(i.Z,{value:"yarn",label:"yarn",children:(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-bash",children:"yarn add @nestjs-cls/transactional\n"})})}),(0,a.jsx)(i.Z,{value:"pnpm",label:"pnpm",children:(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-bash",children:"pnpm add @nestjs-cls/transactional\n"})})})]}),"\n",(0,a.jsx)(n.p,{children:"The plugin works in conjunction with various adapters that provide the actual transactional logic and types for the underlying database library, so you'll need to install one of those as well."}),"\n",(0,a.jsx)(n.p,{children:"Adapters for the following libraries are available:"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsxs)(n.li,{children:["Prisma (see ",(0,a.jsx)(n.a,{href:"/nestjs-cls/plugins/available-plugins/transactional/prisma-adapter",children:"prisma-adapter"}),")"]}),"\n"]}),"\n",(0,a.jsxs)(n.p,{children:["Adapters ",(0,a.jsx)(n.em,{children:"will not"})," be implemented for the following libraries:"]}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsxs)(n.li,{children:["TypeORM (since a more fully-featured ",(0,a.jsx)(n.a,{href:"https://github.com/Aliheym/typeorm-transactional",children:"community package already exists"}),")"]}),"\n",(0,a.jsxs)(n.li,{children:["Sequelize (since it already includes a ",(0,a.jsx)(n.a,{href:"https://sequelize.org/docs/v6/other-topics/transactions/#automatically-pass-transactions-to-all-queries",children:"built-in CLS-enabled transaction support"}),")"]}),"\n"]}),"\n",(0,a.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,a.jsxs)(n.p,{children:["For this example, we'll use the ",(0,a.jsx)(n.code,{children:"prisma"})," library and the ",(0,a.jsxs)(n.a,{href:"/nestjs-cls/plugins/available-plugins/transactional/prisma-adapter",children:[(0,a.jsx)(n.code,{children:"@nestjs-cls/transactional-adapter-prisma"})," adapter"]}),". Later, you'll learn how to ",(0,a.jsx)(n.a,{href:"/nestjs-cls/plugins/available-plugins/transactional/creating-custom-adapter",children:"create your own adapter"}),"."]}),"\n",(0,a.jsxs)(n.p,{children:["Suppose we already have a ",(0,a.jsx)(n.code,{children:"PrismaModule"})," which provides a ",(0,a.jsx)(n.code,{children:"PrismaClient"})," instance and two other services ",(0,a.jsx)(n.code,{children:"UserService"})," and ",(0,a.jsx)(n.code,{children:"AccountService"})," which we'd like to make transactional."]}),"\n",(0,a.jsx)(n.h3,{id:"plugin-registration",children:"Plugin registration"}),"\n",(0,a.jsxs)(n.p,{children:["To add register the transactional plugin with ",(0,a.jsx)(n.code,{children:"nestjs-cls"}),", we need to pass it to the ",(0,a.jsx)(n.code,{children:"forRoot"})," method of the ",(0,a.jsx)(n.code,{children:"ClsModule"}),":"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-ts",metastring:'title="app.module.ts"',children:"import { ClsModule } from 'nestjs-cls';\nimport { ClsPluginTransactional } from '@nestjs-cls/transactional';\nimport { TransactionalAdapterPrisma } from '@nestjs-cls/transactional-adapter-prisma';\n// ... other imports\n\n@Module({\n imports: [\n PrismaModule,\n ClsModule.forRoot({\n plugins: [\n // highlight-start\n new ClsPluginTransactional({\n // if PrismaModule is not global, we need to make it available to the plugin\n imports: [PrismaModule],\n adapter: new TransactionalAdapterPrisma({\n // each adapter has its own options, see the adapter docs for more info\n prismaInjectionToken: PrismaClient,\n }),\n }),\n // highlight-end\n ],\n }),\n ],\n providers: [UserService, AccountService],\n})\nexport class AppModule {}\n"})}),"\n",(0,a.jsxs)(n.p,{children:["This registers a ",(0,a.jsx)(n.code,{children:"TransactionHost"})," provider in the global context which can be used to start a new transaction and retrieve the current transaction reference."]}),"\n",(0,a.jsx)(n.h3,{id:"using-the-transactionhost",children:"Using the TransactionHost"}),"\n",(0,a.jsxs)(n.p,{children:["Now that we have the plugin registered, we can use the ",(0,a.jsx)(n.code,{children:"TransactionHost"})," to start a new transaction and retrieve the current transaction reference."]}),"\n",(0,a.jsxs)(n.p,{children:["Suppose that any time we create an ",(0,a.jsx)(n.code,{children:"User"}),", we want to create an ",(0,a.jsx)(n.code,{children:"Account"})," for them as well and both operations must either succeed or fail. We can use the ",(0,a.jsx)(n.code,{children:"TransactionHost"})," to start a new transaction and retrieve the current transaction reference."]}),"\n",(0,a.jsxs)(n.p,{children:["The type argument on the ",(0,a.jsx)(n.code,{children:"TransactionHost "})," makes sure that the ",(0,a.jsx)(n.code,{children:"tx"})," property is typed correctly and the ",(0,a.jsx)(n.code,{children:"withTransaction"})," method returns the correct type. This is ensured by the implementation of the adapter:"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-ts",metastring:'title="user.service.ts"',children:"@Injectable()\nclass UserService {\n constructor(\n // highlight-start\n private readonly txHost: TransactionHost ,\n // highlight-end\n private readonly accountService: AccountService,\n ) {}\n\n async createUser(name: string): Promise {\n return this.txHost.withTransaction(async () => {\n const user = await this.txHost.tx.user.create({ data: { name } });\n await this.accountService.createAccountForUser(user.id);\n return user;\n });\n }\n}\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-ts",metastring:'title="user.service.ts"',children:"@Injectable()\nclass AccountService {\n constructor(\n private readonly txHost: TransactionHost ,\n ) {}\n\n async createAccountForUser(id: number): Promise {\n return this.txHost.tx.user.create({\n data: { userId: id, number: Math.random() },\n });\n }\n}\n"})}),"\n",(0,a.jsx)(n.admonition,{type:"note",children:(0,a.jsxs)(n.p,{children:["Notice that we never used either raw ",(0,a.jsx)(n.code,{children:"PrismaClient"})," or the ",(0,a.jsx)(n.code,{children:"prisma.$transaction"})," directly. This is because the adapter takes care of that for us, otherwise the transaction would not be propagated in the CLS context."]})}),"\n",(0,a.jsx)(n.h3,{id:"using-the-transactional-decorator",children:"Using the Transactional decorator"}),"\n",(0,a.jsxs)(n.p,{children:["The ",(0,a.jsx)(n.code,{children:"@Transactional"})," decorator can be used to wrap a method call in the ",(0,a.jsx)(n.code,{children:"withTransaction"})," call implicitly. This saves a lot of boilerplate code and makes the code more readable."]}),"\n",(0,a.jsxs)(n.p,{children:["Using the decorator, we can change the ",(0,a.jsx)(n.code,{children:"createUser"})," method like so without changing the behavior:"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-ts",metastring:'title="user.service.ts"',children:"@Injectable()\nclass UserService {\n constructor(\n private readonly txHost: TransactionHost ,\n private readonly accountService: AccountService,\n ) {}\n\n @Transactional()\n async createUser(name: string): Promise {\n const user = await this.txHost.tx.user.create({ data: { name } });\n await this.accountService.createAccountForUser(user.id);\n return user;\n }\n}\n"})}),"\n",(0,a.jsx)(n.h3,{id:"passing-transaction-options",children:"Passing transaction options"}),"\n",(0,a.jsxs)(n.p,{children:["The both the ",(0,a.jsx)(n.code,{children:"withTransaction"})," method and the ",(0,a.jsx)(n.code,{children:"Transactional"})," decorator accepts an optional ",(0,a.jsx)(n.code,{children:"TransactionOptions"})," object as the first argument. This object can be used to configure the transaction, for example to set the isolation level or the timeout. The type is also provided by the adapter."]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-ts",children:"// highlight-start\n@Transactional ({ isolationLevel: 'Serializable' })\n// highlight-end\nasync createUser(name: string): Promise {\n const user = await this.txHost.tx.user.create({ data: { name } });\n await this.accountService.createAccountForUser(user.id);\n return user;\n}\n"})}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-ts",children:"async createUser(name: string): Promise {\n // highlight-start\n return this.txHost.withTransaction({ isolationLevel: 'Serializable' }, async () => {\n // highlight-end\n const user = await this.txHost.tx.user.create({ data: { name } });\n await this.accountService.createAccountForUser(user.id);\n return user;\n });\n}\n"})}),"\n",(0,a.jsx)(n.h2,{id:"clsplugintransactional-interface",children:"ClsPluginTransactional Interface"}),"\n",(0,a.jsxs)(n.p,{children:["The ",(0,a.jsx)(n.code,{children:"ClsPluginTransactional"})," constructor takes an options object with the following properties:"]}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsxs)(n.li,{children:["\n",(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.strong,{children:(0,a.jsx)(n.em,{children:(0,a.jsx)(n.code,{children:"imports"})})}),(0,a.jsx)(n.code,{children:": any[]"}),(0,a.jsx)(n.br,{}),"\n","An array of NestJS modules that should be imported for the plugin to work. If the dependencies are available in the global context, this is not necessary."]}),"\n"]}),"\n",(0,a.jsxs)(n.li,{children:["\n",(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.strong,{children:(0,a.jsx)(n.em,{children:(0,a.jsx)(n.code,{children:"adapter"})})}),(0,a.jsx)(n.code,{children:": TransactionalAdapter"}),(0,a.jsx)(n.br,{}),"\n","An instance of the adapter that should be used for the plugin."]}),"\n"]}),"\n"]}),"\n",(0,a.jsx)(n.h2,{id:"transactionhost-interface",children:"TransactionHost Interface"}),"\n",(0,a.jsxs)(n.p,{children:["The ",(0,a.jsx)(n.code,{children:"TransactionHost"})," interface is the main working interface of the plugin. It provides the following API:"]}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsxs)(n.li,{children:["\n",(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.strong,{children:(0,a.jsx)(n.em,{children:(0,a.jsx)(n.code,{children:"tx"})})}),(0,a.jsx)(n.code,{children:": Transaction"}),(0,a.jsx)(n.br,{}),"\n","Reference to the currently active transaction. Depending on the adapter implementation for the underlying database library, this can be either a transaction client instance, a transaction object or a transaction ID. If no transaction is active, refers to the default non-transactional client instance (or undefined transaction ID)."]}),"\n"]}),"\n",(0,a.jsxs)(n.li,{children:["\n",(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.strong,{children:(0,a.jsx)(n.em,{children:(0,a.jsx)(n.code,{children:"withTransaction"})})}),(0,a.jsx)(n.code,{children:"(callback): Promise"}),(0,a.jsx)(n.br,{}),"\n",(0,a.jsx)(n.strong,{children:(0,a.jsx)(n.em,{children:(0,a.jsx)(n.code,{children:"withTransaction"})})}),(0,a.jsx)(n.code,{children:"(options, callback): Promise"}),(0,a.jsx)(n.br,{}),"\n","Runs the callback in a transaction. Optionally takes a ",(0,a.jsx)(n.code,{children:"TransactionOptions"})," object as the first parameter."]}),"\n"]}),"\n",(0,a.jsxs)(n.li,{children:["\n",(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.strong,{children:(0,a.jsx)(n.em,{children:(0,a.jsx)(n.code,{children:"withOutTransaction"})})}),(0,a.jsx)(n.code,{children:"(callback): Promise"}),(0,a.jsx)(n.br,{}),"\n","Runs the callback without a transaction (even if one is active in the parent scope)."]}),"\n"]}),"\n",(0,a.jsxs)(n.li,{children:["\n",(0,a.jsxs)(n.p,{children:[(0,a.jsx)(n.strong,{children:(0,a.jsx)(n.em,{children:(0,a.jsx)(n.code,{children:"isTransactionActive"})})}),(0,a.jsx)(n.code,{children:"(): boolean"}),(0,a.jsx)(n.br,{}),"\n","Returns whether a CLS-managed transaction is active in the current scope."]}),"\n"]}),"\n"]}),"\n",(0,a.jsx)(n.h2,{id:"considerations",children:"Considerations"}),"\n",(0,a.jsxs)(n.p,{children:["Please note that at this time, the ",(0,a.jsx)(n.code,{children:"@nestjs-cls/transactional"})," plugin only supports a ",(0,a.jsx)(n.em,{children:"single"})," database connection per application. This means that if you have multiple databases, you can only use one of them with the transactional plugin."]}),"\n",(0,a.jsxs)(n.p,{children:["This is a subject to change in the future, as there are plans to support multiple ",(0,a.jsx)(n.code,{children:"TransactionHost"})," instances, each with their own adapter and a database connection."]})]})}function p(e={}){const{wrapper:n}={...(0,s.a)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(u,{...e})}):u(e)}},1670:(e,n,t)=>{t.d(n,{Z:()=>l,a:()=>i});var a=t(7378);const s={},r=a.createContext(s);function i(e){const n=a.useContext(r);return a.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:i(e.components),a.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/75a2ce58.288a270b.js b/assets/js/75a2ce58.288a270b.js deleted file mode 100755 index acb75ff..0000000 --- a/assets/js/75a2ce58.288a270b.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[678],{5318:(e,t,r)=>{r.d(t,{Zo:()=>u,kt:()=>m});var n=r(7378);function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t =0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n =0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var s=n.createContext({}),l=function(e){var t=n.useContext(s),r=t;return e&&(r="function"==typeof e?e(t):a(a({},t),e)),r},u=function(e){var t=l(e.components);return n.createElement(s.Provider,{value:t},e.children)},p="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},g=n.forwardRef((function(e,t){var r=e.components,i=e.mdxType,o=e.originalType,s=e.parentName,u=c(e,["components","mdxType","originalType","parentName"]),p=l(r),g=i,m=p["".concat(s,".").concat(g)]||p[g]||d[g]||o;return r?n.createElement(m,a(a({ref:t},u),{},{components:r})):n.createElement(m,a({ref:t},u))}));function m(e,t){var r=arguments,i=t&&t.mdxType;if("string"==typeof e||i){var o=r.length,a=new Array(o);a[0]=g;var c={};for(var s in t)hasOwnProperty.call(t,s)&&(c[s]=t[s]);c.originalType=e,c[p]="string"==typeof e?e:i,a[1]=c;for(var l=2;l {r.r(t),r.d(t,{assets:()=>s,contentTitle:()=>a,default:()=>d,frontMatter:()=>o,metadata:()=>c,toc:()=>l});var n=r(5773),i=(r(7378),r(5318));const o={},a="Migration guide",c={unversionedId:"migration-guide/index",id:"migration-guide/index",title:"Migration guide",description:"In case you're upgrading to a new major version of this library, follow the according migration guide.",source:"@site/docs/06_migration-guide/index.md",sourceDirName:"06_migration-guide",slug:"/migration-guide/",permalink:"/nestjs-cls/migration-guide/",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/06_migration-guide/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Compatibility",permalink:"/nestjs-cls/considerations/compatibility"},next:{title:"v2.x \u2192 v3.x",permalink:"/nestjs-cls/migration-guide/v2x-v3x"}},s={},l=[],u={toc:l},p="wrapper";function d(e){let{components:t,...r}=e;return(0,i.kt)(p,(0,n.Z)({},u,r,{components:t,mdxType:"MDXLayout"}),(0,i.kt)("h1",{id:"migration-guide"},"Migration guide"),(0,i.kt)("p",null,"In case you're upgrading to a new major version of this library, follow the according migration guide."))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/765.099e041d.js b/assets/js/765.099e041d.js new file mode 100644 index 0000000..7af2fee --- /dev/null +++ b/assets/js/765.099e041d.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[765],{4718:(e,t,s)=>{s.d(t,{Z:()=>a});s(7378);var n=s(624),i=s(7419),o=s(8825),r=s(4246);function a(e){let{className:t}=e;return(0,r.jsx)("main",{className:(0,n.Z)("container margin-vert--xl",t),children:(0,r.jsx)("div",{className:"row",children:(0,r.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,r.jsx)(o.Z,{as:"h1",className:"hero__title",children:(0,r.jsx)(i.Z,{id:"theme.NotFound.title",description:"The title of the 404 page",children:"Page Not Found"})}),(0,r.jsx)("p",{children:(0,r.jsx)(i.Z,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page",children:"We could not find what you were looking for."})}),(0,r.jsx)("p",{children:(0,r.jsx)(i.Z,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page",children:"Please contact the owner of the site that linked you to the original URL and let them know their link is broken."})})]})})})}},765:(e,t,s)=>{s.r(t),s.d(t,{default:()=>l});s(7378);var n=s(7419),i=s(8836),o=s(9145),r=s(4718),a=s(4246);function l(){const e=(0,n.I)({id:"theme.NotFound.title",message:"Page Not Found"});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.d,{title:e}),(0,a.jsx)(o.Z,{children:(0,a.jsx)(r.Z,{})})]})}}}]); \ No newline at end of file diff --git a/assets/js/77.6d8f1b9f.js b/assets/js/807.e07e7e07.js old mode 100755 new mode 100644 similarity index 51% rename from assets/js/77.6d8f1b9f.js rename to assets/js/807.e07e7e07.js index d2884cc..2c20430 --- a/assets/js/77.6d8f1b9f.js +++ b/assets/js/807.e07e7e07.js @@ -1 +1 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[77],{5077:(s,c,e)=>{e.r(c)}}]); \ No newline at end of file +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[807],{7807:(s,c,e)=>{e.r(c)}}]); \ No newline at end of file diff --git a/assets/js/81cbaa95.e887b585.js b/assets/js/81cbaa95.e887b585.js deleted file mode 100755 index f1b975d..0000000 --- a/assets/js/81cbaa95.e887b585.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[513],{5318:(e,t,n)=>{n.d(t,{Zo:()=>u,kt:()=>f});var r=n(7378);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t =0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var i=r.createContext({}),l=function(e){var t=r.useContext(i),n=t;return e&&(n="function"==typeof e?e(t):s(s({},t),e)),n},u=function(e){var t=l(e.components);return r.createElement(i.Provider,{value:t},e.children)},p="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},m=r.forwardRef((function(e,t){var n=e.components,o=e.mdxType,a=e.originalType,i=e.parentName,u=c(e,["components","mdxType","originalType","parentName"]),p=l(n),m=o,f=p["".concat(i,".").concat(m)]||p[m]||d[m]||a;return n?r.createElement(f,s(s({ref:t},u),{},{components:n})):r.createElement(f,s({ref:t},u))}));function f(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var a=n.length,s=new Array(a);s[0]=m;var c={};for(var i in t)hasOwnProperty.call(t,i)&&(c[i]=t[i]);c.originalType=e,c[p]="string"==typeof e?e:o,s[1]=c;for(var l=2;l{n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>s,default:()=>d,frontMatter:()=>a,metadata:()=>c,toc:()=>l});var r=n(5773),o=(n(7378),n(5318));const a={},s="Using a Decorator",c={unversionedId:"setting-up-cls-context/using-a-decurator",id:"setting-up-cls-context/using-a-decurator",title:"Using a Decorator",description:"The @UseCls() decorator can be used at a method level to declaratively wrap the method with a cls.run() call. This method should only be used outside of the context of a web request.",source:"@site/docs/02_setting-up-cls-context/04_using-a-decurator.md",sourceDirName:"02_setting-up-cls-context",slug:"/setting-up-cls-context/using-a-decurator",permalink:"/nestjs-cls/setting-up-cls-context/using-a-decurator",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/02_setting-up-cls-context/04_using-a-decurator.md",tags:[],version:"current",sidebarPosition:4,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Using an Interceptor",permalink:"/nestjs-cls/setting-up-cls-context/using-an-interceptor"},next:{title:"Features and use cases",permalink:"/nestjs-cls/features-and-use-cases/"}},i={},l=[],u={toc:l},p="wrapper";function d(e){let{components:t,...n}=e;return(0,o.kt)(p,(0,r.Z)({},u,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"using-a-decorator"},"Using a Decorator"),(0,o.kt)("p",null,"The ",(0,o.kt)("inlineCode",{parentName:"p"},"@UseCls()")," decorator can be used at a method level to declaratively wrap the method with a ",(0,o.kt)("inlineCode",{parentName:"p"},"cls.run()")," call. This method should only be used ",(0,o.kt)("a",{parentName:"p",href:"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request"},"outside of the context of a web request"),"."),(0,o.kt)("admonition",{type:"info"},(0,o.kt)("p",{parentName:"admonition"},"Please keep in mind, that since the CLS context initialization ",(0,o.kt)("em",{parentName:"p"},"can")," be async, the ",(0,o.kt)("inlineCode",{parentName:"p"},"@UseCls()")," decorator can ",(0,o.kt)("em",{parentName:"p"},"only")," be used on ",(0,o.kt)("em",{parentName:"p"},"async")," function (those that return a ",(0,o.kt)("inlineCode",{parentName:"p"},"Promise"),").")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/849c94ea.51e67d40.js b/assets/js/849c94ea.51e67d40.js deleted file mode 100755 index 72b65ce..0000000 --- a/assets/js/849c94ea.51e67d40.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[756],{5318:(e,t,n)=>{n.d(t,{Zo:()=>l,kt:()=>m});var r=n(7378);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t =0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var c=r.createContext({}),u=function(e){var t=r.useContext(c),n=t;return e&&(n="function"==typeof e?e(t):a(a({},t),e)),n},l=function(e){var t=u(e.components);return r.createElement(c.Provider,{value:t},e.children)},p="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},f=r.forwardRef((function(e,t){var n=e.components,o=e.mdxType,s=e.originalType,c=e.parentName,l=i(e,["components","mdxType","originalType","parentName"]),p=u(n),f=o,m=p["".concat(c,".").concat(f)]||p[f]||d[f]||s;return n?r.createElement(m,a(a({ref:t},l),{},{components:n})):r.createElement(m,a({ref:t},l))}));function m(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var s=n.length,a=new Array(s);a[0]=f;var i={};for(var c in t)hasOwnProperty.call(t,c)&&(i[c]=t[c]);i.originalType=e,i[p]="string"==typeof e?e:o,a[1]=i;for(var u=2;u {n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>a,default:()=>d,frontMatter:()=>s,metadata:()=>i,toc:()=>u});var r=n(5773),o=(n(7378),n(5318));const s={},a="Breaking out of DI",i={unversionedId:"features-and-use-cases/breakin-out-of-di",id:"features-and-use-cases/breakin-out-of-di",title:"Breaking out of DI",description:"While this package aims to be compatible with NestJS's Dependency Injection, it is also possible to access the CLS context outside of it.",source:"@site/docs/03_features-and-use-cases/03_breakin-out-of-di.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/breakin-out-of-di",permalink:"/nestjs-cls/features-and-use-cases/breakin-out-of-di",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/03_breakin-out-of-di.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Additional CLS Setup",permalink:"/nestjs-cls/features-and-use-cases/additional-cls-setup"},next:{title:"Usage outside of web request",permalink:"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request"}},c={},u=[],l={toc:u},p="wrapper";function d(e){let{components:t,...n}=e;return(0,o.kt)(p,(0,r.Z)({},l,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"breaking-out-of-di"},"Breaking out of DI"),(0,o.kt)("p",null,"While this package aims to be compatible with NestJS's Dependency Injection, it is also possible to access the CLS context outside of it."),(0,o.kt)("p",null,"For that, it provides the static ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsServiceManager")," class that exposes the ",(0,o.kt)("inlineCode",{parentName:"p"},"getClsService()")," method which can be used to retrieve the context outside of Nest's injection context (e.g. in top-level functions)"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts"},"function helper() {\n const cls = ClsServiceManager.getClsService();\n // you now have access to the shared storage\n console.log(cls.getId());\n}\n")),(0,o.kt)("admonition",{type:"caution"},(0,o.kt)("p",{parentName:"admonition"},(0,o.kt)("strong",{parentName:"p"},"Please note"),": Only use this feature where absolutely necessary. Using this technique instead of dependency injection will make it difficult to mock the ClsService and your code will become harder to test.")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/86ea57e0.93a2d1c1.js b/assets/js/86ea57e0.93a2d1c1.js deleted file mode 100755 index 6a96f83..0000000 --- a/assets/js/86ea57e0.93a2d1c1.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[202],{5318:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>h});var a=n(7378);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function i(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var l=a.createContext({}),c=function(e){var t=a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},p=function(e){var t=c(e.components);return a.createElement(l.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},m=a.forwardRef((function(e,t){var n=e.components,o=e.mdxType,r=e.originalType,l=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),u=c(n),m=o,h=u["".concat(l,".").concat(m)]||u[m]||d[m]||r;return n?a.createElement(h,i(i({ref:t},p),{},{components:n})):a.createElement(h,i({ref:t},p))}));function h(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var r=n.length,i=new Array(r);i[0]=m;var s={};for(var l in t)hasOwnProperty.call(t,l)&&(s[l]=t[l]);s.originalType=e,s[u]="string"==typeof e?e:o,i[1]=s;for(var c=2;c {n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>i,default:()=>d,frontMatter:()=>r,metadata:()=>s,toc:()=>c});var a=n(5773),o=(n(7378),n(5318));const r={slug:"/",sidebar_position:0,title:"Introduction"},i="NestJS CLS",s={unversionedId:"introduction/index",id:"introduction/index",title:"Introduction",description:"A continuation-local\\* storage module compatible with NestJS' dependency injection based on Node's AsyncLocalStorage.",source:"@site/docs/01_introduction/index.md",sourceDirName:"01_introduction",slug:"/",permalink:"/nestjs-cls/",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/01_introduction/index.md",tags:[],version:"current",sidebarPosition:0,frontMatter:{slug:"/",sidebar_position:0,title:"Introduction"},sidebar:"documentationSidebar",next:{title:"Installation",permalink:"/nestjs-cls/introduction/installation"}},l={},c=[{value:"Use cases",id:"use-cases",level:2},{value:"Motivation",id:"motivation",level:2},{value:"Highlights",id:"highlights",level:2}],p={toc:c},u="wrapper";function d(e){let{components:t,...n}=e;return(0,o.kt)(u,(0,a.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"nestjs-cls"},"NestJS CLS"),(0,o.kt)("p",null,"A continuation-local","*"," storage module compatible with ",(0,o.kt)("a",{parentName:"p",href:"https://nestjs.com/"},"NestJS"),"' dependency injection based on Node's ",(0,o.kt)("a",{parentName:"p",href:"https://nodejs.org/api/async_context.html#async_context_class_asynclocalstorage"},"AsyncLocalStorage"),"."),(0,o.kt)("blockquote",null,(0,o.kt)("p",{parentName:"blockquote"},(0,o.kt)("em",{parentName:"p"},"Continuation-local storage allows to store state and propagate it throughout callbacks and promise chains. It allows storing data throughout the lifetime of a web request or any other asynchronous duration. It is similar to thread-local storage in other languages."))),(0,o.kt)("h2",{id:"use-cases"},"Use cases"),(0,o.kt)("p",null,"Some common use cases that this library enables include:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Tracking the Request ID and other metadata for logging purposes"),(0,o.kt)("li",{parentName:"ul"},"Keeping track of the user throughout the whole request"),(0,o.kt)("li",{parentName:"ul"},"Making the dynamic Tenant database connection available everywhere in multi-tenant apps"),(0,o.kt)("li",{parentName:"ul"},"Propagating the authentication level or role to restrict access to resources"),(0,o.kt)("li",{parentName:"ul"},"Seamlessly propagating the ",(0,o.kt)("inlineCode",{parentName:"li"},"transaction")," object of your favourite ORM across services without breaking encapsulation and isolation by explicitly passing it around."),(0,o.kt)("li",{parentName:"ul"},'Using "request" context in cases where actual REQUEST-scoped providers are not supported (passport strategies, cron controllers, websocket gateways, ...)')),(0,o.kt)("p",null,"Most of these are to some extent solvable using ",(0,o.kt)("em",{parentName:"p"},"REQUEST-scoped")," providers or passing the context as a parameter, but these solutions are often clunky and come with a whole lot of other issues."),(0,o.kt)("admonition",{type:"info"},(0,o.kt)("p",{parentName:"admonition"},"*"," The name comes from the original implementation based on ",(0,o.kt)("inlineCode",{parentName:"p"},"cls-hooked"),", which was since replaced by the native ",(0,o.kt)("inlineCode",{parentName:"p"},"AsyncLocalStorage"),".")),(0,o.kt)("h2",{id:"motivation"},"Motivation"),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},"NestJS is an amazing framework, but in the plethora of awesome built-in features, I still missed one"),"."),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},"I created this library to solve a specific use case, which was limiting access to only those records which had the same TenantId as the request's user in a central manner. The repository code automatically added a ",(0,o.kt)("inlineCode",{parentName:"em"},"WHERE")," clause to each query, which made sure that other developers couldn't accidentally mix tenant data (all tenants' data were held in the same database) without extra effort.")),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},(0,o.kt)("inlineCode",{parentName:"em"},"AsyncLocalStorage")," is still fairly new and not many people know of its existence and benefits. Here's a nice ",(0,o.kt)("a",{parentName:"em",href:"https://youtu.be/R2RMGQhWyCk?t=9742"},"talk from NodeConf")," about the history. I've invested a great deal of my personal time in making the use of it as pleasant as possible.")),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},"While the use of ",(0,o.kt)("inlineCode",{parentName:"em"},"async_hooks")," is sometimes criticized for ",(0,o.kt)("a",{parentName:"em",href:"https://gist.github.com/Aschen/5cc1f3f3b58f1e284b670b83bb53da7d"},"making Node run slower"),", in my experience, the introduced overhead is negligible compared to any IO operation (like a DB or external API call). If you want fast, use a compiled language.")),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},"Also, if you use some tracing library (like ",(0,o.kt)("inlineCode",{parentName:"em"},"otel"),"), it most likely already uses ",(0,o.kt)("inlineCode",{parentName:"em"},"async_hooks")," under the hood, so you might as well use it to your advantage.")),(0,o.kt)("h2",{id:"highlights"},"Highlights"),(0,o.kt)("blockquote",null,(0,o.kt)("p",{parentName:"blockquote"},(0,o.kt)("strong",{parentName:"p"},"New"),": Version ",(0,o.kt)("inlineCode",{parentName:"p"},"3.0")," introduces ",(0,o.kt)("a",{parentName:"p",href:"/nestjs-cls/features-and-use-cases/proxy-providers"},(0,o.kt)("em",{parentName:"a"},"Proxy Providers"))," as an alternative to the imperative API. (Minor breaking changes were introduced, see ",(0,o.kt)("a",{parentName:"p",href:"/nestjs-cls/migration-guide/v2x-v3x"},"Migration guide"),").")),(0,o.kt)("blockquote",null,(0,o.kt)("p",{parentName:"blockquote"},"Version ",(0,o.kt)("inlineCode",{parentName:"p"},"2.0")," brings advanced ",(0,o.kt)("a",{parentName:"p",href:"/nestjs-cls/features-and-use-cases/type-safety-and-type-inference"},"type safety and type inference"),". However, it requires features from ",(0,o.kt)("inlineCode",{parentName:"p"},"typescript >= 4.4")," - Namely allowing ",(0,o.kt)("inlineCode",{parentName:"p"},"symbol")," members in interfaces. If you can't upgrade but still want to use this library, install version ",(0,o.kt)("inlineCode",{parentName:"p"},"1.6.2"),", which lacks the typing features.")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/86ea57e0.ff6330f0.js b/assets/js/86ea57e0.ff6330f0.js new file mode 100644 index 0000000..87505e8 --- /dev/null +++ b/assets/js/86ea57e0.ff6330f0.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[202],{5737:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>c,contentTitle:()=>a,default:()=>h,frontMatter:()=>o,metadata:()=>r,toc:()=>l});var t=n(4246),i=n(1670);const o={slug:"/",sidebar_position:0,title:"Introduction"},a="NestJS CLS",r={id:"introduction/index",title:"Introduction",description:"A continuation-local\\* storage module compatible with NestJS' dependency injection based on Node's AsyncLocalStorage.",source:"@site/docs/01_introduction/index.md",sourceDirName:"01_introduction",slug:"/",permalink:"/nestjs-cls/",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/01_introduction/index.md",tags:[],version:"current",sidebarPosition:0,frontMatter:{slug:"/",sidebar_position:0,title:"Introduction"},sidebar:"documentationSidebar",next:{title:"Installation",permalink:"/nestjs-cls/introduction/installation"}},c={},l=[{value:"Use cases",id:"use-cases",level:2},{value:"Motivation",id:"motivation",level:2},{value:"Highlights",id:"highlights",level:2}];function d(e){const s={a:"a",admonition:"admonition",blockquote:"blockquote",code:"code",em:"em",h1:"h1",h2:"h2",li:"li",p:"p",strong:"strong",ul:"ul",...(0,i.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.h1,{id:"nestjs-cls",children:"NestJS CLS"}),"\n",(0,t.jsxs)(s.p,{children:["A continuation-local* storage module compatible with ",(0,t.jsx)(s.a,{href:"https://nestjs.com/",children:"NestJS"}),"' dependency injection based on Node's ",(0,t.jsx)(s.a,{href:"https://nodejs.org/api/async_context.html#async_context_class_asynclocalstorage",children:"AsyncLocalStorage"}),"."]}),"\n",(0,t.jsxs)(s.blockquote,{children:["\n",(0,t.jsx)(s.p,{children:(0,t.jsx)(s.em,{children:"Continuation-local storage allows to store state and propagate it throughout callbacks and promise chains. It allows storing data throughout the lifetime of a web request or any other asynchronous duration. It is similar to thread-local storage in other languages."})}),"\n"]}),"\n",(0,t.jsx)(s.h2,{id:"use-cases",children:"Use cases"}),"\n",(0,t.jsx)(s.p,{children:"Some common use cases that this library enables include:"}),"\n",(0,t.jsxs)(s.ul,{children:["\n",(0,t.jsx)(s.li,{children:"Tracking the Request ID and other metadata for logging purposes"}),"\n",(0,t.jsx)(s.li,{children:"Keeping track of the user throughout the whole request"}),"\n",(0,t.jsx)(s.li,{children:"Making the dynamic Tenant database connection available everywhere in multi-tenant apps"}),"\n",(0,t.jsx)(s.li,{children:"Propagating the authentication level or role to restrict access to resources"}),"\n",(0,t.jsxs)(s.li,{children:["Seamlessly propagating database transaction across services without breaking encapsulation and isolation by explicitly passing it around (",(0,t.jsxs)(s.strong,{children:["Now available with the ",(0,t.jsx)(s.a,{href:"/nestjs-cls/plugins/available-plugins/transactional/",children:"Transactional plugin"})]}),")"]}),"\n",(0,t.jsx)(s.li,{children:'Using "request" context in cases where actual REQUEST-scoped providers are not supported (passport strategies, cron controllers, websocket gateways, ...)'}),"\n"]}),"\n",(0,t.jsxs)(s.p,{children:["Most of these are to some extent solvable using ",(0,t.jsx)(s.em,{children:"REQUEST-scoped"})," providers or passing the context as a parameter, but these solutions are often clunky and come with a whole lot of other issues."]}),"\n",(0,t.jsx)(s.admonition,{type:"info",children:(0,t.jsxs)(s.p,{children:["* The name comes from the original implementation based on ",(0,t.jsx)(s.code,{children:"cls-hooked"}),", which was since replaced by the native ",(0,t.jsx)(s.code,{children:"AsyncLocalStorage"}),"."]})}),"\n",(0,t.jsx)(s.h2,{id:"motivation",children:"Motivation"}),"\n",(0,t.jsxs)(s.p,{children:[(0,t.jsx)(s.em,{children:"NestJS is an amazing framework, but in the plethora of awesome built-in features, I still missed one"}),"."]}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsxs)(s.em,{children:["I created this library to solve a specific use case, which was limiting access to only those records which had the same TenantId as the request's user in a central manner. The repository code automatically added a ",(0,t.jsx)(s.code,{children:"WHERE"})," clause to each query, which made sure that other developers couldn't accidentally mix tenant data (all tenants' data were held in the same database) without extra effort."]})}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsxs)(s.em,{children:[(0,t.jsx)(s.code,{children:"AsyncLocalStorage"})," is still fairly new and not many people know of its existence and benefits. Here's a nice ",(0,t.jsx)(s.a,{href:"https://youtu.be/R2RMGQhWyCk?t=9742",children:"talk from NodeConf"})," about the history. I've invested a great deal of my personal time in making the use of it as pleasant as possible."]})}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsxs)(s.em,{children:["While the use of ",(0,t.jsx)(s.code,{children:"async_hooks"})," is sometimes criticized for ",(0,t.jsx)(s.a,{href:"https://gist.github.com/Aschen/5cc1f3f3b58f1e284b670b83bb53da7d",children:"making Node run slower"}),", in my experience, the introduced overhead is negligible compared to any IO operation (like a DB or external API call). If you want fast, use a compiled language."]})}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsxs)(s.em,{children:["Also, if you use some tracing library (like ",(0,t.jsx)(s.code,{children:"otel"}),"), it most likely already uses ",(0,t.jsx)(s.code,{children:"async_hooks"})," under the hood, so you might as well use it to your advantage."]})}),"\n",(0,t.jsx)(s.h2,{id:"highlights",children:"Highlights"}),"\n",(0,t.jsxs)(s.blockquote,{children:["\n",(0,t.jsxs)(s.p,{children:[(0,t.jsx)(s.strong,{children:"New"})," Version ",(0,t.jsx)(s.code,{children:"4.0"})," brings support for ",(0,t.jsx)(s.a,{href:"/nestjs-cls/plugins/",children:"Plugins"})," which enable pre-built integrations with other libraries and frameworks. (See ",(0,t.jsx)(s.a,{href:"/nestjs-cls/migration-guide/v3x-v4x",children:"Migration guide"})," for breaking changes)."]}),"\n"]}),"\n",(0,t.jsxs)(s.blockquote,{children:["\n",(0,t.jsxs)(s.p,{children:["Version ",(0,t.jsx)(s.code,{children:"3.0"})," introduces ",(0,t.jsx)(s.a,{href:"/nestjs-cls/features-and-use-cases/proxy-providers",children:(0,t.jsx)(s.em,{children:"Proxy Providers"})})," as an alternative to the imperative API. (Minor breaking changes were introduced, see ",(0,t.jsx)(s.a,{href:"/nestjs-cls/migration-guide/v2x-v3x",children:"Migration guide"}),")."]}),"\n"]}),"\n",(0,t.jsxs)(s.blockquote,{children:["\n",(0,t.jsxs)(s.p,{children:["Version ",(0,t.jsx)(s.code,{children:"2.0"})," brings advanced ",(0,t.jsx)(s.a,{href:"/nestjs-cls/features-and-use-cases/type-safety-and-type-inference",children:"type safety and type inference"}),". However, it requires features from ",(0,t.jsx)(s.code,{children:"typescript >= 4.4"})," - Namely allowing ",(0,t.jsx)(s.code,{children:"symbol"})," members in interfaces. If you can't upgrade but still want to use this library, install version ",(0,t.jsx)(s.code,{children:"1.6.2"}),", which lacks the typing features."]}),"\n"]})]})}function h(e={}){const{wrapper:s}={...(0,i.a)(),...e.components};return s?(0,t.jsx)(s,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},1670:(e,s,n)=>{n.d(s,{Z:()=>r,a:()=>a});var t=n(7378);const i={},o=t.createContext(i);function a(e){const s=t.useContext(o);return t.useMemo((function(){return"function"==typeof e?e(s):{...s,...e}}),[s,e])}function r(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:a(e.components),t.createElement(o.Provider,{value:s},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/893.bb801cd0.js b/assets/js/893.bb801cd0.js deleted file mode 100755 index 4253cc0..0000000 --- a/assets/js/893.bb801cd0.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[893],{3893:(e,t,n)=>{n.r(t),n.d(t,{default:()=>c});var a=n(7378),l=n(9213),o=n(8831),r=n(9176);function c(){return a.createElement(a.Fragment,null,a.createElement(o.d,{title:(0,l.I)({id:"theme.NotFound.title",message:"Page Not Found"})}),a.createElement(r.Z,null,a.createElement("main",{className:"container margin-vert--xl"},a.createElement("div",{className:"row"},a.createElement("div",{className:"col col--6 col--offset-3"},a.createElement("h1",{className:"hero__title"},a.createElement(l.Z,{id:"theme.NotFound.title",description:"The title of the 404 page"},"Page Not Found")),a.createElement("p",null,a.createElement(l.Z,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page"},"We could not find what you were looking for.")),a.createElement("p",null,a.createElement(l.Z,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page"},"Please contact the owner of the site that linked you to the original URL and let them know their link is broken.")))))))}}}]); \ No newline at end of file diff --git a/assets/js/935f2afb.da867498.js b/assets/js/935f2afb.da867498.js deleted file mode 100755 index 0fcf212..0000000 --- a/assets/js/935f2afb.da867498.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[53],{1109:e=>{e.exports=JSON.parse('{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"documentationSidebar":[{"type":"category","label":"Introduction","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Installation","href":"/nestjs-cls/introduction/installation","docId":"introduction/installation"},{"type":"link","label":"Quick Start","href":"/nestjs-cls/introduction/quick-start","docId":"introduction/quick-start"},{"type":"link","label":"How it works","href":"/nestjs-cls/introduction/how-it-works","docId":"introduction/how-it-works"}],"href":"/nestjs-cls/"},{"type":"category","label":"Setting up the CLS context","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Using a Middleware","href":"/nestjs-cls/setting-up-cls-context/using-a-middleware","docId":"setting-up-cls-context/using-a-middleware"},{"type":"link","label":"Using a Guard","href":"/nestjs-cls/setting-up-cls-context/using-a-guard","docId":"setting-up-cls-context/using-a-guard"},{"type":"link","label":"Using an Interceptor","href":"/nestjs-cls/setting-up-cls-context/using-an-interceptor","docId":"setting-up-cls-context/using-an-interceptor"},{"type":"link","label":"Using a Decorator","href":"/nestjs-cls/setting-up-cls-context/using-a-decurator","docId":"setting-up-cls-context/using-a-decurator"}],"href":"/nestjs-cls/setting-up-cls-context/"},{"type":"category","label":"Features and use cases","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Request ID","href":"/nestjs-cls/features-and-use-cases/request-id","docId":"features-and-use-cases/request-id"},{"type":"link","label":"Additional CLS Setup","href":"/nestjs-cls/features-and-use-cases/additional-cls-setup","docId":"features-and-use-cases/additional-cls-setup"},{"type":"link","label":"Breaking out of DI","href":"/nestjs-cls/features-and-use-cases/breakin-out-of-di","docId":"features-and-use-cases/breakin-out-of-di"},{"type":"link","label":"Usage outside of web request","href":"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request","docId":"features-and-use-cases/usage-outside-of-web-request"},{"type":"link","label":"Type safety and type inference","href":"/nestjs-cls/features-and-use-cases/type-safety-and-type-inference","docId":"features-and-use-cases/type-safety-and-type-inference"},{"type":"link","label":"Proxy Providers","href":"/nestjs-cls/features-and-use-cases/proxy-providers","docId":"features-and-use-cases/proxy-providers"}],"href":"/nestjs-cls/features-and-use-cases/"},{"type":"category","label":"API","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Service Interface","href":"/nestjs-cls/api/service-interface","docId":"api/service-interface"},{"type":"link","label":"Module Options","href":"/nestjs-cls/api/module-options","docId":"api/module-options"}],"href":"/nestjs-cls/api/"},{"type":"category","label":"Considerations","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Security","href":"/nestjs-cls/considerations/security","docId":"considerations/security"},{"type":"link","label":"Compatibility","href":"/nestjs-cls/considerations/compatibility","docId":"considerations/compatibility"}],"href":"/nestjs-cls/considerations/"},{"type":"category","label":"Migration guide","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"v2.x \u2192 v3.x","href":"/nestjs-cls/migration-guide/v2x-v3x","docId":"migration-guide/v2x-v3x"}],"href":"/nestjs-cls/migration-guide/"}]},"docs":{"api/index":{"id":"api/index","title":"API","description":"This chapter describes the programmatic API of the ClsService and the ClsModule options.","sidebar":"documentationSidebar"},"api/module-options":{"id":"api/module-options","title":"Module Options","description":"forRoot(Async)","sidebar":"documentationSidebar"},"api/service-interface":{"id":"api/service-interface","title":"Service Interface","description":"ClsService","sidebar":"documentationSidebar"},"considerations/compatibility":{"id":"considerations/compatibility","title":"Compatibility","description":"The table below outlines the compatibility with some platforms:","sidebar":"documentationSidebar"},"considerations/index":{"id":"considerations/index","title":"Considerations","description":"This chapter exists to help you decide whether this library is compatible with your project and to address any concerns that you may have.","sidebar":"documentationSidebar"},"considerations/security":{"id":"considerations/security","title":"Security","description":"It is often discussed whether AsyncLocalStorage is safe to use for concurrent requests (because of a possible context leak) and whether the context could be lost_ throughout the duration of a request.","sidebar":"documentationSidebar"},"features-and-use-cases/additional-cls-setup":{"id":"features-and-use-cases/additional-cls-setup","title":"Additional CLS Setup","description":"The CLS middleware/guard/interceptor provide some default functionality, but sometimes you might want to store more contextual things in the CLS.","sidebar":"documentationSidebar"},"features-and-use-cases/breakin-out-of-di":{"id":"features-and-use-cases/breakin-out-of-di","title":"Breaking out of DI","description":"While this package aims to be compatible with NestJS\'s Dependency Injection, it is also possible to access the CLS context outside of it.","sidebar":"documentationSidebar"},"features-and-use-cases/index":{"id":"features-and-use-cases/index","title":"Features and use cases","description":"In addition to the basic functionality described in the Quick start chapter, this module provides several other features to make your life as a developer easier.","sidebar":"documentationSidebar"},"features-and-use-cases/proxy-providers":{"id":"features-and-use-cases/proxy-providers","title":"Proxy Providers","description":"Since v3.0","sidebar":"documentationSidebar"},"features-and-use-cases/request-id":{"id":"features-and-use-cases/request-id","title":"Request ID","description":"Because of a shared storage, CLS is an ideal tool for tracking request (correlation) IDs for the purpose of logging. This package provides an option to automatically generate request IDs in the middleware/guard/interceptor, if you pass { generateId: true } to its options. By default, the generated ID is a string based on Math.random(), but you can provide a custom function in the idGenerator option.","sidebar":"documentationSidebar"},"features-and-use-cases/type-safety-and-type-inference":{"id":"features-and-use-cases/type-safety-and-type-inference","title":"Type safety and type inference","description":"Since v2.0","sidebar":"documentationSidebar"},"features-and-use-cases/usage-outside-of-web-request":{"id":"features-and-use-cases/usage-outside-of-web-request","title":"Usage outside of web request","description":"Sometimes, a part of the app that relies on the CLS storage might need to be called outside of the context of a web request - for example, in a Cron job, while consuming a Queue or during the application bootstrap. In such cases, there are no enhancers that can be bound to the handler to set up the context.","sidebar":"documentationSidebar"},"introduction/how-it-works":{"id":"introduction/how-it-works","title":"How it works","description":"Continuation-local storage provides a common space for storing and retrieving data throughout the life of a function/callback call chain. In NestJS, this allows for sharing request data across the lifetime of a single request - without the need for request-scoped providers. It also makes it easy to track and log request ids throughout the whole application.","sidebar":"documentationSidebar"},"introduction/index":{"id":"introduction/index","title":"Introduction","description":"A continuation-local\\\\* storage module compatible with NestJS\' dependency injection based on Node\'s AsyncLocalStorage.","sidebar":"documentationSidebar"},"introduction/installation":{"id":"introduction/installation","title":"Installation","description":"Install as any other NPM package using your favorite package manager.","sidebar":"documentationSidebar"},"introduction/quick-start":{"id":"introduction/quick-start","title":"Quick Start","description":"Background","sidebar":"documentationSidebar"},"migration-guide/index":{"id":"migration-guide/index","title":"Migration guide","description":"In case you\'re upgrading to a new major version of this library, follow the according migration guide.","sidebar":"documentationSidebar"},"migration-guide/v2x-v3x":{"id":"migration-guide/v2x-v3x","title":"v2.x \u2192 v3.x","description":"- The root registration method was renamed from register (resp. registerAsync) to forRoot (resp. forRootAsync) to align with the convention.","sidebar":"documentationSidebar"},"setting-up-cls-context/index":{"id":"setting-up-cls-context/index","title":"Setting up the CLS context","description":"This package provides three methods of setting up the CLS context for incoming requests. This is mainly due to the fact that different underlying platforms are compatible with only some of these methods - see Compatibility considerations.","sidebar":"documentationSidebar"},"setting-up-cls-context/using-a-decurator":{"id":"setting-up-cls-context/using-a-decurator","title":"Using a Decorator","description":"The @UseCls() decorator can be used at a method level to declaratively wrap the method with a cls.run() call. This method should only be used outside of the context of a web request.","sidebar":"documentationSidebar"},"setting-up-cls-context/using-a-guard":{"id":"setting-up-cls-context/using-a-guard","title":"Using a Guard","description":"The ClsGuard can be also used set up the CLS context. While it is not a \\"guard\\" per-se, it\'s the second best place to set up the CLS context, since after a middleware, it is the first piece of code that the request hits.","sidebar":"documentationSidebar"},"setting-up-cls-context/using-a-middleware":{"id":"setting-up-cls-context/using-a-middleware","title":"Using a Middleware","description":"This section applies only if you use a HTTP transport (REST or GraphQL)","sidebar":"documentationSidebar"},"setting-up-cls-context/using-an-interceptor":{"id":"setting-up-cls-context/using-an-interceptor","title":"Using an Interceptor","description":"Another place to initiate the CLS context is an ClsInterceptor, which, unlike the ClsGuard uses AsyncLocalStorage#run method to wrap the following code, which is considered safer than enterWith.","sidebar":"documentationSidebar"}}}')}}]); \ No newline at end of file diff --git a/assets/js/935f2afb.ff295151.js b/assets/js/935f2afb.ff295151.js new file mode 100644 index 0000000..eae1f62 --- /dev/null +++ b/assets/js/935f2afb.ff295151.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[53],{1109:e=>{e.exports=JSON.parse('{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"documentationSidebar":[{"type":"category","label":"Introduction","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Installation","href":"/nestjs-cls/introduction/installation","docId":"introduction/installation","unlisted":false},{"type":"link","label":"Quick Start","href":"/nestjs-cls/introduction/quick-start","docId":"introduction/quick-start","unlisted":false},{"type":"link","label":"How it works","href":"/nestjs-cls/introduction/how-it-works","docId":"introduction/how-it-works","unlisted":false}],"href":"/nestjs-cls/"},{"type":"category","label":"Setting up the CLS context","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Using a Middleware","href":"/nestjs-cls/setting-up-cls-context/using-a-middleware","docId":"setting-up-cls-context/using-a-middleware","unlisted":false},{"type":"link","label":"Using a Guard","href":"/nestjs-cls/setting-up-cls-context/using-a-guard","docId":"setting-up-cls-context/using-a-guard","unlisted":false},{"type":"link","label":"Using an Interceptor","href":"/nestjs-cls/setting-up-cls-context/using-an-interceptor","docId":"setting-up-cls-context/using-an-interceptor","unlisted":false},{"type":"link","label":"Using a Decorator","href":"/nestjs-cls/setting-up-cls-context/using-a-decorator","docId":"setting-up-cls-context/using-a-decorator","unlisted":false},{"type":"link","label":"Using the ClsService Instance","href":"/nestjs-cls/setting-up-cls-context/using_cls_run","docId":"setting-up-cls-context/using_cls_run","unlisted":false}],"href":"/nestjs-cls/setting-up-cls-context/"},{"type":"category","label":"Features and use cases","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Request ID","href":"/nestjs-cls/features-and-use-cases/request-id","docId":"features-and-use-cases/request-id","unlisted":false},{"type":"link","label":"Additional CLS Setup","href":"/nestjs-cls/features-and-use-cases/additional-cls-setup","docId":"features-and-use-cases/additional-cls-setup","unlisted":false},{"type":"link","label":"Breaking out of DI","href":"/nestjs-cls/features-and-use-cases/breaking-out-of-di","docId":"features-and-use-cases/breaking-out-of-di","unlisted":false},{"type":"link","label":"Usage outside of web request","href":"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request","docId":"features-and-use-cases/usage-outside-of-web-request","unlisted":false},{"type":"link","label":"Type safety and type inference","href":"/nestjs-cls/features-and-use-cases/type-safety-and-type-inference","docId":"features-and-use-cases/type-safety-and-type-inference","unlisted":false},{"type":"link","label":"Proxy Providers","href":"/nestjs-cls/features-and-use-cases/proxy-providers","docId":"features-and-use-cases/proxy-providers","unlisted":false}],"href":"/nestjs-cls/features-and-use-cases/"},{"type":"category","label":"API","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Service Interface","href":"/nestjs-cls/api/service-interface","docId":"api/service-interface","unlisted":false},{"type":"link","label":"Module Options","href":"/nestjs-cls/api/module-options","docId":"api/module-options","unlisted":false}],"href":"/nestjs-cls/api/"},{"type":"category","label":"Considerations","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Security","href":"/nestjs-cls/considerations/security","docId":"considerations/security","unlisted":false},{"type":"link","label":"Compatibility","href":"/nestjs-cls/considerations/compatibility","docId":"considerations/compatibility","unlisted":false}],"href":"/nestjs-cls/considerations/"},{"type":"category","label":"Plugins","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"Available Plugins","collapsible":true,"collapsed":true,"items":[{"type":"category","label":"@nestjs-cls/transactional","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Prisma adapter","href":"/nestjs-cls/plugins/available-plugins/transactional/prisma-adapter","docId":"plugins/available-plugins/transactional/prisma-adapter","unlisted":false},{"type":"link","label":"Creating a custom adapter","href":"/nestjs-cls/plugins/available-plugins/transactional/creating-custom-adapter","docId":"plugins/available-plugins/transactional/creating-custom-adapter","unlisted":false}],"href":"/nestjs-cls/plugins/available-plugins/transactional/"}],"href":"/nestjs-cls/plugins/available-plugins/"},{"type":"link","label":"Plugin API","href":"/nestjs-cls/plugins/plugin-api","docId":"plugins/plugin-api","unlisted":false}],"href":"/nestjs-cls/plugins/"},{"type":"category","label":"Migration guide","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"v3.x \u2192 v4.x","href":"/nestjs-cls/migration-guide/v3x-v4x","docId":"migration-guide/v3x-v4x","unlisted":false},{"type":"link","label":"v2.x \u2192 v3.x","href":"/nestjs-cls/migration-guide/v2x-v3x","docId":"migration-guide/v2x-v3x","unlisted":false}],"href":"/nestjs-cls/migration-guide/"}]},"docs":{"api/index":{"id":"api/index","title":"API","description":"This chapter describes the programmatic API of the ClsService and the ClsModule options.","sidebar":"documentationSidebar"},"api/module-options":{"id":"api/module-options","title":"Module Options","description":"forRoot(Async)","sidebar":"documentationSidebar"},"api/service-interface":{"id":"api/service-interface","title":"Service Interface","description":"ClsService","sidebar":"documentationSidebar"},"considerations/compatibility":{"id":"considerations/compatibility","title":"Compatibility","description":"The table below outlines the compatibility with some platforms:","sidebar":"documentationSidebar"},"considerations/index":{"id":"considerations/index","title":"Considerations","description":"This chapter exists to help you decide whether this library is compatible with your project and to address any concerns that you may have.","sidebar":"documentationSidebar"},"considerations/security":{"id":"considerations/security","title":"Security","description":"It is often discussed whether AsyncLocalStorage is safe to use for concurrent requests (because of a possible context leak) and whether the context could be lost_ throughout the duration of a request.","sidebar":"documentationSidebar"},"features-and-use-cases/additional-cls-setup":{"id":"features-and-use-cases/additional-cls-setup","title":"Additional CLS Setup","description":"The CLS middleware/guard/interceptor provide some default functionality, but sometimes you might want to store more contextual things in the CLS.","sidebar":"documentationSidebar"},"features-and-use-cases/breaking-out-of-di":{"id":"features-and-use-cases/breaking-out-of-di","title":"Breaking out of DI","description":"While this package aims to be compatible with NestJS\'s Dependency Injection, it is also possible to access the CLS context outside of it.","sidebar":"documentationSidebar"},"features-and-use-cases/index":{"id":"features-and-use-cases/index","title":"Features and use cases","description":"In addition to the basic functionality described in the Quick start chapter, this module provides several other features to make your life as a developer easier.","sidebar":"documentationSidebar"},"features-and-use-cases/proxy-providers":{"id":"features-and-use-cases/proxy-providers","title":"Proxy Providers","description":"Since v3.0","sidebar":"documentationSidebar"},"features-and-use-cases/request-id":{"id":"features-and-use-cases/request-id","title":"Request ID","description":"Because of a shared storage, CLS is an ideal tool for tracking request (correlation) IDs for the purpose of logging. This package provides an option to automatically generate request IDs in the middleware/guard/interceptor, if you pass { generateId: true } to its options. By default, the generated ID is a string based on Math.random(), but you can provide a custom function in the idGenerator option.","sidebar":"documentationSidebar"},"features-and-use-cases/type-safety-and-type-inference":{"id":"features-and-use-cases/type-safety-and-type-inference","title":"Type safety and type inference","description":"Since v2.0","sidebar":"documentationSidebar"},"features-and-use-cases/usage-outside-of-web-request":{"id":"features-and-use-cases/usage-outside-of-web-request","title":"Usage outside of web request","description":"Sometimes, a part of the app that relies on the CLS storage might need to be called outside of the context of a web request - for example, in a Cron job, while consuming a Queue, during the application bootstrap or in CLI apps.","sidebar":"documentationSidebar"},"introduction/how-it-works":{"id":"introduction/how-it-works","title":"How it works","description":"Continuation-local storage provides a common space for storing and retrieving data throughout the life of a function/callback call chain. In NestJS, this allows for sharing request data across the lifetime of a single request - without the need for request-scoped providers. It also makes it easy to track and log request ids throughout the whole application.","sidebar":"documentationSidebar"},"introduction/index":{"id":"introduction/index","title":"Introduction","description":"A continuation-local\\\\* storage module compatible with NestJS\' dependency injection based on Node\'s AsyncLocalStorage.","sidebar":"documentationSidebar"},"introduction/installation":{"id":"introduction/installation","title":"Installation","description":"Install as any other NPM package using your favorite package manager.","sidebar":"documentationSidebar"},"introduction/quick-start":{"id":"introduction/quick-start","title":"Quick Start","description":"Background","sidebar":"documentationSidebar"},"migration-guide/index":{"id":"migration-guide/index","title":"Migration guide","description":"In case you\'re upgrading to a new major version of this library, follow the according migration guide.","sidebar":"documentationSidebar"},"migration-guide/v2x-v3x":{"id":"migration-guide/v2x-v3x","title":"v2.x \u2192 v3.x","description":"Root registration method renamed","sidebar":"documentationSidebar"},"migration-guide/v3x-v4x":{"id":"migration-guide/v3x-v4x","title":"v3.x \u2192 v4.x","description":"The v4 major version should be largely backwards compatible with v3. However, breaking changes were introduced in some less-used APIs that should be mentioned.","sidebar":"documentationSidebar"},"plugins/available-plugins/index":{"id":"plugins/available-plugins/index","title":"Available Plugins","description":"This section lists all plugins that are maintained by the author of nestjs-cls. They are all published under the @nestjs-cls scope and are kept up to date with any changes to the library.","sidebar":"documentationSidebar"},"plugins/available-plugins/transactional/creating-custom-adapter":{"id":"plugins/available-plugins/transactional/creating-custom-adapter","title":"Creating a custom adapter","description":"TODO: To be written.","sidebar":"documentationSidebar"},"plugins/available-plugins/transactional/index":{"id":"plugins/available-plugins/transactional/index","title":"@nestjs-cls/transactional","description":"The Transactional plugin for nestjs-cls provides a generic interface that can be used to wrap any function call in","sidebar":"documentationSidebar"},"plugins/available-plugins/transactional/prisma-adapter":{"id":"plugins/available-plugins/transactional/prisma-adapter","title":"Prisma adapter","description":"Installation","sidebar":"documentationSidebar"},"plugins/index":{"id":"plugins/index","title":"Plugins","description":"Since v4.0","sidebar":"documentationSidebar"},"plugins/plugin-api":{"id":"plugins/plugin-api","title":"Plugin API","description":"The Plugin API is still experimental and might change in the future, you should not rely on it in production.","sidebar":"documentationSidebar"},"setting-up-cls-context/index":{"id":"setting-up-cls-context/index","title":"Setting up the CLS context","description":"This package provides multiple methods of setting up the CLS context for incoming requests. This is mainly due to the fact that different underlying platforms are compatible with only some of these methods - see Compatibility considerations.","sidebar":"documentationSidebar"},"setting-up-cls-context/using_cls_run":{"id":"setting-up-cls-context/using_cls_run","title":"Using the ClsService Instance","description":"All other methods of setting up the CLS context ultimately use the ClsService#run or ClsService#enter methods.","sidebar":"documentationSidebar"},"setting-up-cls-context/using-a-decorator":{"id":"setting-up-cls-context/using-a-decorator","title":"Using a Decorator","description":"The @UseCls() decorator can be used at a method level to declaratively wrap the method with a cls.run() call. This method should only be used outside of the context of a web request.","sidebar":"documentationSidebar"},"setting-up-cls-context/using-a-guard":{"id":"setting-up-cls-context/using-a-guard","title":"Using a Guard","description":"The ClsGuard can be also used set up the CLS context. While it is not a \\"guard\\" per-se, it\'s the second best place to set up the CLS context, since after a middleware, it is the first piece of code that the request hits.","sidebar":"documentationSidebar"},"setting-up-cls-context/using-a-middleware":{"id":"setting-up-cls-context/using-a-middleware","title":"Using a Middleware","description":"This section applies only if you use a HTTP transport (REST or GraphQL)","sidebar":"documentationSidebar"},"setting-up-cls-context/using-an-interceptor":{"id":"setting-up-cls-context/using-an-interceptor","title":"Using an Interceptor","description":"Another place to initiate the CLS context is an ClsInterceptor, which, unlike the ClsGuard uses AsyncLocalStorage#run method to wrap the following code, which is considered safer than enterWith.","sidebar":"documentationSidebar"}}}')}}]); \ No newline at end of file diff --git a/assets/js/94e5e920.1b12a2be.js b/assets/js/94e5e920.1b12a2be.js deleted file mode 100755 index 6d17a94..0000000 --- a/assets/js/94e5e920.1b12a2be.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[575],{5318:(e,t,r)=>{r.d(t,{Zo:()=>p,kt:()=>f});var n=r(7378);function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t =0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n =0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var c=n.createContext({}),l=function(e){var t=n.useContext(c),r=t;return e&&(r="function"==typeof e?e(t):s(s({},t),e)),r},p=function(e){var t=l(e.components);return n.createElement(c.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},y=n.forwardRef((function(e,t){var r=e.components,o=e.mdxType,i=e.originalType,c=e.parentName,p=a(e,["components","mdxType","originalType","parentName"]),u=l(r),y=o,f=u["".concat(c,".").concat(y)]||u[y]||d[y]||i;return r?n.createElement(f,s(s({ref:t},p),{},{components:r})):n.createElement(f,s({ref:t},p))}));function f(e,t){var r=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var i=r.length,s=new Array(i);s[0]=y;var a={};for(var c in t)hasOwnProperty.call(t,c)&&(a[c]=t[c]);a.originalType=e,a[u]="string"==typeof e?e:o,s[1]=a;for(var l=2;l{r.r(t),r.d(t,{assets:()=>c,contentTitle:()=>s,default:()=>d,frontMatter:()=>i,metadata:()=>a,toc:()=>l});var n=r(5773),o=(r(7378),r(5318));const i={},s="Considerations",a={unversionedId:"considerations/index",id:"considerations/index",title:"Considerations",description:"This chapter exists to help you decide whether this library is compatible with your project and to address any concerns that you may have.",source:"@site/docs/05_considerations/index.md",sourceDirName:"05_considerations",slug:"/considerations/",permalink:"/nestjs-cls/considerations/",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/05_considerations/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Module Options",permalink:"/nestjs-cls/api/module-options"},next:{title:"Security",permalink:"/nestjs-cls/considerations/security"}},c={},l=[],p={toc:l},u="wrapper";function d(e){let{components:t,...r}=e;return(0,o.kt)(u,(0,n.Z)({},p,r,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"considerations"},"Considerations"),(0,o.kt)("p",null,"This chapter exists to help you decide whether this library is compatible with your project and to address any concerns that you may have."),(0,o.kt)("p",null,"You might be also interested in ",(0,o.kt)("a",{parentName:"p",href:"/nestjs-cls/#motivation"},"the Author's take")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/94e5e920.d469aee9.js b/assets/js/94e5e920.d469aee9.js new file mode 100644 index 0000000..cae42cf --- /dev/null +++ b/assets/js/94e5e920.d469aee9.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[575],{9257:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>a,contentTitle:()=>r,default:()=>u,frontMatter:()=>i,metadata:()=>c,toc:()=>d});var s=n(4246),o=n(1670);const i={},r="Considerations",c={id:"considerations/index",title:"Considerations",description:"This chapter exists to help you decide whether this library is compatible with your project and to address any concerns that you may have.",source:"@site/docs/05_considerations/index.md",sourceDirName:"05_considerations",slug:"/considerations/",permalink:"/nestjs-cls/considerations/",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/05_considerations/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Module Options",permalink:"/nestjs-cls/api/module-options"},next:{title:"Security",permalink:"/nestjs-cls/considerations/security"}},a={},d=[];function l(e){const t={a:"a",h1:"h1",p:"p",...(0,o.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h1,{id:"considerations",children:"Considerations"}),"\n",(0,s.jsx)(t.p,{children:"This chapter exists to help you decide whether this library is compatible with your project and to address any concerns that you may have."}),"\n",(0,s.jsxs)(t.p,{children:["You might be also interested in ",(0,s.jsx)(t.a,{href:"/nestjs-cls/#motivation",children:"the Author's take"})]})]})}function u(e={}){const{wrapper:t}={...(0,o.a)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(l,{...e})}):l(e)}},1670:(e,t,n)=>{n.d(t,{Z:()=>c,a:()=>r});var s=n(7378);const o={},i=s.createContext(o);function r(e){const t=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:r(e.components),s.createElement(i.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/97d55a5e.1919b209.js b/assets/js/97d55a5e.1919b209.js deleted file mode 100755 index ef07707..0000000 --- a/assets/js/97d55a5e.1919b209.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[823],{5318:(e,t,n)=>{n.d(t,{Zo:()=>m,kt:()=>c});var a=n(7378);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function i(e){for(var t=1;t =0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var l=a.createContext({}),s=function(e){var t=a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},m=function(e){var t=s(e.components);return a.createElement(l.Provider,{value:t},e.children)},d="mdxType",k={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},u=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,o=e.originalType,l=e.parentName,m=p(e,["components","mdxType","originalType","parentName"]),d=s(n),u=r,c=d["".concat(l,".").concat(u)]||d[u]||k[u]||o;return n?a.createElement(c,i(i({ref:t},m),{},{components:n})):a.createElement(c,i({ref:t},m))}));function c(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var o=n.length,i=new Array(o);i[0]=u;var p={};for(var l in t)hasOwnProperty.call(t,l)&&(p[l]=t[l]);p.originalType=e,p[d]="string"==typeof e?e:r,i[1]=p;for(var s=2;s {n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>i,default:()=>k,frontMatter:()=>o,metadata:()=>p,toc:()=>s});var a=n(5773),r=(n(7378),n(5318));const o={},i="Module Options",p={unversionedId:"api/module-options",id:"api/module-options",title:"Module Options",description:"forRoot(Async)",source:"@site/docs/04_api/02_module-options.md",sourceDirName:"04_api",slug:"/api/module-options",permalink:"/nestjs-cls/api/module-options",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/04_api/02_module-options.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Service Interface",permalink:"/nestjs-cls/api/service-interface"},next:{title:"Considerations",permalink:"/nestjs-cls/considerations/"}},l={},s=[{value:"forRoot(Async)",id:"forrootasync",level:2},{value:"forFeature(Async)",id:"forfeatureasync",level:2},{value:"Middleware & Enhancer options",id:"middleware--enhancer-options",level:2}],m={toc:s},d="wrapper";function k(e){let{components:t,...n}=e;return(0,r.kt)(d,(0,a.Z)({},m,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h1",{id:"module-options"},"Module Options"),(0,r.kt)("h2",{id:"forrootasync"},"forRoot(Async)"),(0,r.kt)("p",null,"The ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsModule.forRoot()")," method takes the following ",(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("inlineCode",{parentName:"strong"},"ClsModuleOptions")),":"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"middleware?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"ClsMiddlewareOptions")),(0,r.kt)("br",{parentName:"p"}),"\n","An object with additional options for the ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsMiddleware"),", see ",(0,r.kt)("a",{parentName:"p",href:"#middleware--enhancer-options"},"below"),".")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"guard?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"ClsGuardOptions")),(0,r.kt)("br",{parentName:"p"}),"\n","An object with additional options for the ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsGuard"),", see ",(0,r.kt)("a",{parentName:"p",href:"#middleware--enhancer-options"},"below"),".")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"interceptor?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"ClsInterceptorOptions")),(0,r.kt)("br",{parentName:"p"}),"\n","An object with additional options for the ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsInterceptor"),", see ",(0,r.kt)("a",{parentName:"p",href:"#middleware--enhancer-options"},"below"),".")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"global?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"boolean"))," (default ",(0,r.kt)("em",{parentName:"p"},(0,r.kt)("inlineCode",{parentName:"em"},"false")),")",(0,r.kt)("br",{parentName:"p"}),"\n","Whether to make the module global, so you do not have to import ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsModule.forFeature()")," in other modules.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"proxyProviders?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"Type[]")),(0,r.kt)("br",{parentName:"p"}),"\n","Array of ",(0,r.kt)("a",{parentName:"p",href:"/nestjs-cls/features-and-use-cases/proxy-providers"},"Proxy Providers")," that should be registered in the root module. Currently only accepts sync class Proxy providers, use ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsModule.forFeatureAsync()")," for more complex use-cases."))),(0,r.kt)("p",null,(0,r.kt)("inlineCode",{parentName:"p"},"ClsModule.forRootAsync()")," is also available. You can supply the usual ",(0,r.kt)("inlineCode",{parentName:"p"},"imports"),", ",(0,r.kt)("inlineCode",{parentName:"p"},"inject")," and ",(0,r.kt)("inlineCode",{parentName:"p"},"useFactory")," parameters as usual."),(0,r.kt)("admonition",{type:"info"},(0,r.kt)("p",{parentName:"admonition"},(0,r.kt)("strong",{parentName:"p"},"Please note"),": If you intend to use multiple enhancers at the same time (e.g. initialize the CLS context in a middleware and then set some CLS variables additional CLS variables in an interceptor), be aware that the only the first one in the chain will set the Request ID.")),(0,r.kt)("h2",{id:"forfeatureasync"},"forFeature(Async)"),(0,r.kt)("p",null,"The ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsModule.forFeature()")," method can be used to register a ",(0,r.kt)("a",{parentName:"p",href:"/nestjs-cls/features-and-use-cases/proxy-providers"},"Proxy Providers"),". The Sync method only accepts Class Proxy providers."),(0,r.kt)("p",null,"The ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsModule.forFeatureAsync()")," method accepts either ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsModuleProxyClassProviderOptions")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsModuleProxyFactoryProviderOptions")," that both accept these options:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"provide?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"any")),(0,r.kt)("br",{parentName:"p"}),"\n","Custom injection token to use for the provider. In case of a class provider, this parameter is optional, as the class reference passed to ",(0,r.kt)("inlineCode",{parentName:"p"},"useClass")," will be used by default.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"imports?"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"any[]")),(0,r.kt)("br",{parentName:"p"}),"\n","Optional list of imported modules that export the providers which are required for the provider.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"extraProviders?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"Provider[]")),"\nOptional list of additional providers that should be available to the Proxy. Useful for passing configuration from a parent dynamic module."))),(0,r.kt)("p",null,"The ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsModuleProxyClassProviderOptions")," interface further accepts:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("strong",{parentName:"li"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"useClass:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"Type")),(0,r.kt)("br",{parentName:"li"}),"The target class that will be used by this Proxy Provider. Make sure it is decorated with ",(0,r.kt)("inlineCode",{parentName:"li"},"@InjectableProxy"),".")),(0,r.kt)("p",null,"The ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsModuleProxyFactoryProviderOptions")," interface further accepts:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"inject:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"any[]")),(0,r.kt)("br",{parentName:"p"}),"\n","An array of injection tokens for providers used in the ",(0,r.kt)("inlineCode",{parentName:"p"},"useFactory"),".")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"useFactory:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"(...args: any[]) => any")),(0,r.kt)("br",{parentName:"p"}),"\n","Factory function that accepts an array of providers in the order of the according tokens in the ",(0,r.kt)("inlineCode",{parentName:"p"},"inject")," array. Returns (or resolves with) an object (or a function) that will be used by this Proxy Provider."))),(0,r.kt)("h2",{id:"middleware--enhancer-options"},"Middleware & Enhancer options"),(0,r.kt)("p",null,"All of the ",(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("inlineCode",{parentName:"strong"},"Cls{Middleware,Guard,Interceptor}Options"))," take the following parameters (either in ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsModuleOptions")," or directly when instantiating them manually):"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"mount?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"boolean"))," (default ",(0,r.kt)("em",{parentName:"p"},(0,r.kt)("inlineCode",{parentName:"em"},"false")),")",(0,r.kt)("br",{parentName:"p"}),"\n","Whether to automatically mount the middleware/guard/interceptor to every route (not applicable when instantiating them manually)")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"generateId?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"boolean"))," (default ",(0,r.kt)("em",{parentName:"p"},(0,r.kt)("inlineCode",{parentName:"em"},"false")),")",(0,r.kt)("br",{parentName:"p"}),"\n","Whether to automatically generate a request ID. It will be available under the ",(0,r.kt)("inlineCode",{parentName:"p"},"CLS_ID")," key.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"idGenerator?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"(req: Request) => string | Promise ")),(0,r.kt)("br",{parentName:"p"}),"\n",(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"idGenerator?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"(ctx: ExecutionContext) => string | Promise ")),(0,r.kt)("br",{parentName:"p"}),"\n","An optional function for generating the request ID. It takes the ",(0,r.kt)("inlineCode",{parentName:"p"},"Request")," object (or the ",(0,r.kt)("inlineCode",{parentName:"p"},"ExecutionContext")," in case of a Guard or Interceptor) as an argument and (synchronously or asynchronously) returns a string. The default implementation uses ",(0,r.kt)("inlineCode",{parentName:"p"},"Math.random()")," to generate a string of 8 characters.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"setup?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"(cls: ClsService, req: Request) => void | Promise ;")),(0,r.kt)("br",{parentName:"p"}),"\n",(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"setup?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"(cls: ClsService, ctx: ExecutionContext) => void | Promise ;")),(0,r.kt)("br",{parentName:"p"}),"\n","Function that executes after the CLS context had been initialised. It can be used to put additional variables in the CLS context.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"resolveProxyProviders?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"boolean"))," (default ",(0,r.kt)("em",{parentName:"p"},(0,r.kt)("inlineCode",{parentName:"em"},"true")),")",(0,r.kt)("br",{parentName:"p"}),"\n","Whether to automatically resolve Proxy Providers in the enhancer (if any are registered)."))),(0,r.kt)("p",null,"The ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsMiddlewareOptions")," additionally takes the following parameters:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"saveReq?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"boolean"))," (default ",(0,r.kt)("em",{parentName:"p"},(0,r.kt)("inlineCode",{parentName:"em"},"true")),")",(0,r.kt)("br",{parentName:"p"}),"\n","Whether to store the ",(0,r.kt)("em",{parentName:"p"},"Request")," object to the context. It will be available under the ",(0,r.kt)("inlineCode",{parentName:"p"},"CLS_REQ")," key.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"saveRes?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"boolean"))," (default ",(0,r.kt)("em",{parentName:"p"},(0,r.kt)("inlineCode",{parentName:"em"},"false")),")",(0,r.kt)("br",{parentName:"p"}),"\n","Whether to store the ",(0,r.kt)("em",{parentName:"p"},"Response")," object to the context. It will be available under the ",(0,r.kt)("inlineCode",{parentName:"p"},"CLS_RES")," key")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"useEnterWith?:"))," ",(0,r.kt)("inlineCode",{parentName:"strong"},"boolean"))," (default ",(0,r.kt)("em",{parentName:"p"},(0,r.kt)("inlineCode",{parentName:"em"},"false")),")",(0,r.kt)("br",{parentName:"p"}),"\n","Set to ",(0,r.kt)("inlineCode",{parentName:"p"},"true")," to set up the context using a call to ",(0,r.kt)("a",{parentName:"p",href:"https://nodejs.org/api/async_context.html#async_context_asynclocalstorage_enterwith_store"},(0,r.kt)("inlineCode",{parentName:"a"},"AsyncLocalStorage#enterWith"))," instead of wrapping the ",(0,r.kt)("inlineCode",{parentName:"p"},"next()")," call with the safer ",(0,r.kt)("a",{parentName:"p",href:"https://nodejs.org/api/async_context.html#async_context_asynclocalstorage_run_store_callback_args"},(0,r.kt)("inlineCode",{parentName:"a"},"AsyncLocalStorage#run")),". Most of the time this should not be necessary, but ",(0,r.kt)("a",{parentName:"p",href:"#graphql"},"some frameworks")," are known to lose the context with ",(0,r.kt)("inlineCode",{parentName:"p"},"run"),"."))))}k.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/97d55a5e.5ff21a4a.js b/assets/js/97d55a5e.5ff21a4a.js new file mode 100644 index 0000000..118d83a --- /dev/null +++ b/assets/js/97d55a5e.5ff21a4a.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[823],{6274:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>d,contentTitle:()=>t,default:()=>a,frontMatter:()=>i,metadata:()=>c,toc:()=>l});var r=s(4246),o=s(1670);const i={},t="Module Options",c={id:"api/module-options",title:"Module Options",description:"forRoot(Async)",source:"@site/docs/04_api/02_module-options.md",sourceDirName:"04_api",slug:"/api/module-options",permalink:"/nestjs-cls/api/module-options",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/04_api/02_module-options.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Service Interface",permalink:"/nestjs-cls/api/service-interface"},next:{title:"Considerations",permalink:"/nestjs-cls/considerations/"}},d={},l=[{value:"forRoot(Async)",id:"forrootasync",level:2},{value:"forFeature(Async)",id:"forfeatureasync",level:2},{value:"Middleware & Enhancer options",id:"middleware--enhancer-options",level:2}];function h(e){const n={a:"a",admonition:"admonition",br:"br",code:"code",em:"em",h1:"h1",h2:"h2",li:"li",p:"p",strong:"strong",ul:"ul",...(0,o.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h1,{id:"module-options",children:"Module Options"}),"\n",(0,r.jsx)(n.h2,{id:"forrootasync",children:"forRoot(Async)"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"ClsModule.forRoot()"})," method takes the following ",(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.code,{children:"ClsModuleOptions"})}),":"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"middleware?:"})})}),(0,r.jsx)(n.code,{children:"ClsMiddlewareOptions"}),(0,r.jsx)(n.br,{}),"\n","An object with additional options for the ",(0,r.jsx)(n.code,{children:"ClsMiddleware"}),", see ",(0,r.jsx)(n.a,{href:"#middleware--enhancer-options",children:"below"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"guard?:"})})}),(0,r.jsx)(n.code,{children:"ClsGuardOptions"}),(0,r.jsx)(n.br,{}),"\n","An object with additional options for the ",(0,r.jsx)(n.code,{children:"ClsGuard"}),", see ",(0,r.jsx)(n.a,{href:"#middleware--enhancer-options",children:"below"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"interceptor?:"})})}),(0,r.jsx)(n.code,{children:"ClsInterceptorOptions"}),(0,r.jsx)(n.br,{}),"\n","An object with additional options for the ",(0,r.jsx)(n.code,{children:"ClsInterceptor"}),", see ",(0,r.jsx)(n.a,{href:"#middleware--enhancer-options",children:"below"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"global?:"})})}),(0,r.jsx)(n.code,{children:"boolean"}),"** (default ",(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"false"})}),")",(0,r.jsx)(n.br,{}),"\n","Whether to make the module global, so you do not have to import ",(0,r.jsx)(n.code,{children:"ClsModule.forFeature()"})," in other modules."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"proxyProviders?:"})})}),(0,r.jsx)(n.code,{children:"Type[]"}),(0,r.jsx)(n.br,{}),"\n","Array of ",(0,r.jsx)(n.a,{href:"/nestjs-cls/features-and-use-cases/proxy-providers",children:"Proxy Providers"})," that should be registered in the root module. Currently only accepts sync class Proxy providers, use ",(0,r.jsx)(n.code,{children:"ClsModule.forFeatureAsync()"})," for more complex use-cases."]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"ClsModule.forRootAsync()"})," is also available. You can supply the usual ",(0,r.jsx)(n.code,{children:"imports"}),", ",(0,r.jsx)(n.code,{children:"inject"})," and ",(0,r.jsx)(n.code,{children:"useFactory"})," parameters as usual."]}),"\n",(0,r.jsx)(n.admonition,{type:"info",children:(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"Please note"}),": If you intend to use multiple enhancers at the same time (e.g. initialize the CLS context in a middleware and then set some additional CLS variables in an interceptor), be aware that the only the first one in the chain will set the Request ID."]})}),"\n",(0,r.jsx)(n.h2,{id:"forfeatureasync",children:"forFeature(Async)"}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"ClsModule.forFeature()"})," method can be used to register a ",(0,r.jsx)(n.a,{href:"/nestjs-cls/features-and-use-cases/proxy-providers",children:"Proxy Providers"}),". The Sync method only accepts Class Proxy providers."]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"ClsModule.forFeatureAsync()"})," method accepts either ",(0,r.jsx)(n.code,{children:"ClsModuleProxyClassProviderOptions"})," or ",(0,r.jsx)(n.code,{children:"ClsModuleProxyFactoryProviderOptions"})," that both accept these options:"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"provide?:"})})}),(0,r.jsx)(n.code,{children:"any"}),(0,r.jsx)(n.br,{}),"\n","Custom injection token to use for the provider. In case of a class provider, this parameter is optional, as the class reference passed to ",(0,r.jsx)(n.code,{children:"useClass"})," will be used by default."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"imports?"})})}),(0,r.jsx)(n.code,{children:"any[]"}),(0,r.jsx)(n.br,{}),"\n","Optional list of imported modules that export the providers which are required for the provider."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"extraProviders?:"})})}),(0,r.jsx)(n.code,{children:"Provider[]"}),(0,r.jsx)(n.br,{}),"\n","Optional list of additional providers that should be available to the Proxy. Useful for passing configuration from a parent dynamic module."]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"ClsModuleProxyClassProviderOptions"})," interface further accepts:"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"useClass:"})})}),(0,r.jsx)(n.code,{children:"Type"}),(0,r.jsx)(n.br,{}),"\n","The target class that will be used by this Proxy Provider. Make sure it is decorated with ",(0,r.jsx)(n.code,{children:"@InjectableProxy"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"ClsModuleProxyFactoryProviderOptions"})," interface further accepts:"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"inject:"})})}),(0,r.jsx)(n.code,{children:"any[]"}),(0,r.jsx)(n.br,{}),"\n","An array of injection tokens for providers used in the ",(0,r.jsx)(n.code,{children:"useFactory"}),"."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"useFactory:"})})}),(0,r.jsx)(n.code,{children:"(...args: any[]) => any"}),(0,r.jsx)(n.br,{}),"\n","Factory function that accepts an array of providers in the order of the according tokens in the ",(0,r.jsx)(n.code,{children:"inject"})," array. Returns (or resolves with) an object (or a function) that will be used by this Proxy Provider."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"type?:"})})}),(0,r.jsx)(n.code,{children:"'function' | 'object'"}),(0,r.jsx)(n.br,{}),"\n","Whether the Proxy Provider should be a function or an object. Defaults to ",(0,r.jsx)(n.code,{children:"'object'"}),". See ",(0,r.jsx)(n.a,{href:"/nestjs-cls/features-and-use-cases/proxy-providers#caveats",children:"Caveats"})," for more information."]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"middleware--enhancer-options",children:"Middleware & Enhancer options"}),"\n",(0,r.jsxs)(n.p,{children:["All of the ",(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.code,{children:"Cls{Middleware,Guard,Interceptor}Options"})})," take the following parameters (either in ",(0,r.jsx)(n.code,{children:"ClsModuleOptions"})," or directly when instantiating them manually):"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"mount?:"})})}),(0,r.jsx)(n.code,{children:"boolean"})," (default ",(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"false"})}),")",(0,r.jsx)(n.br,{}),"\n","Whether to automatically mount the middleware/guard/interceptor to every route (not applicable when instantiating them manually)"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"generateId?:"})})}),(0,r.jsx)(n.code,{children:"boolean"})," (default ",(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"false"})}),")",(0,r.jsx)(n.br,{}),"\n","Whether to automatically generate a request ID. It will be available under the ",(0,r.jsx)(n.code,{children:"CLS_ID"})," key."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"idGenerator?:"})})}),(0,r.jsx)(n.code,{children:"(req: Request) => string | Promise "}),(0,r.jsx)(n.br,{}),"\n",(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"idGenerator?:"})})}),(0,r.jsx)(n.code,{children:"(ctx: ExecutionContext) => string | Promise "}),(0,r.jsx)(n.br,{}),"\n","An optional function for generating the request ID. It takes the ",(0,r.jsx)(n.code,{children:"Request"})," object (or the ",(0,r.jsx)(n.code,{children:"ExecutionContext"})," in case of a Guard or Interceptor) as an argument and (synchronously or asynchronously) returns a string. The default implementation uses ",(0,r.jsx)(n.code,{children:"Math.random()"})," to generate a string of 8 characters."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"setup?:"})})}),(0,r.jsx)(n.code,{children:"(cls: ClsService, req: Request) => void | Promise ;"}),(0,r.jsx)(n.br,{}),"\n",(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"setup?:"})})}),(0,r.jsx)(n.code,{children:"(cls: ClsService, ctx: ExecutionContext) => void | Promise ;"}),(0,r.jsx)(n.br,{}),"\n","Function that executes after the CLS context had been initialised. It can be used to put additional variables in the CLS context."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"resolveProxyProviders?:"})})}),(0,r.jsx)(n.code,{children:"boolean"})," (default ",(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"true"})}),")",(0,r.jsx)(n.br,{}),"\n","Whether to automatically resolve Proxy Providers in the enhancer (if any are registered)."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"initializePlugins?:"})})}),(0,r.jsx)(n.code,{children:"boolean"})," (default ",(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"true"})}),")",(0,r.jsx)(n.br,{}),"\n","Whether to run the ",(0,r.jsx)(n.code,{children:"onClsInit"})," hook for plugins as a part of the CLS context registration (runs before ",(0,r.jsx)(n.code,{children:"resolveProxyProviders"})," just after ",(0,r.jsx)(n.code,{children:"setup"}),")."]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["The ",(0,r.jsx)(n.code,{children:"ClsMiddlewareOptions"})," additionally takes the following parameters:"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"saveReq?:"})})}),(0,r.jsx)(n.code,{children:"boolean"})," (default ",(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"true"})}),")",(0,r.jsx)(n.br,{}),"\n","Whether to store the ",(0,r.jsx)(n.em,{children:"Request"})," object to the context. It will be available under the ",(0,r.jsx)(n.code,{children:"CLS_REQ"})," key."]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"saveRes?:"})})}),(0,r.jsx)(n.code,{children:"boolean"})," (default ",(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"false"})}),")",(0,r.jsx)(n.br,{}),"\n","Whether to store the ",(0,r.jsx)(n.em,{children:"Response"})," object to the context. It will be available under the ",(0,r.jsx)(n.code,{children:"CLS_RES"})," key"]}),"\n"]}),"\n",(0,r.jsxs)(n.li,{children:["\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"useEnterWith?:"})})}),(0,r.jsx)(n.code,{children:"boolean"})," (default ",(0,r.jsx)(n.em,{children:(0,r.jsx)(n.code,{children:"false"})}),")",(0,r.jsx)(n.br,{}),"\n","Set to ",(0,r.jsx)(n.code,{children:"true"})," to set up the context using a call to ",(0,r.jsx)(n.a,{href:"https://nodejs.org/api/async_context.html#async_context_asynclocalstorage_enterwith_store",children:(0,r.jsx)(n.code,{children:"AsyncLocalStorage#enterWith"})})," instead of wrapping the ",(0,r.jsx)(n.code,{children:"next()"})," call with the safer ",(0,r.jsx)(n.a,{href:"https://nodejs.org/api/async_context.html#async_context_asynclocalstorage_run_store_callback_args",children:(0,r.jsx)(n.code,{children:"AsyncLocalStorage#run"})}),". Most of the time this should not be necessary, but ",(0,r.jsx)(n.a,{href:"#graphql",children:"some frameworks"})," are known to lose the context with ",(0,r.jsx)(n.code,{children:"run"}),"."]}),"\n"]}),"\n"]})]})}function a(e={}){const{wrapper:n}={...(0,o.a)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(h,{...e})}):h(e)}},1670:(e,n,s)=>{s.d(n,{Z:()=>c,a:()=>t});var r=s(7378);const o={},i=r.createContext(o);function t(e){const n=r.useContext(i);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:t(e.components),r.createElement(i.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/a2c1fdb7.6caaee3d.js b/assets/js/a2c1fdb7.6caaee3d.js new file mode 100644 index 0000000..0d8e2fb --- /dev/null +++ b/assets/js/a2c1fdb7.6caaee3d.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[776],{5308:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>r,default:()=>p,frontMatter:()=>i,metadata:()=>c,toc:()=>a});var s=n(4246),o=n(1670);const i={},r="Setting up the CLS context",c={id:"setting-up-cls-context/index",title:"Setting up the CLS context",description:"This package provides multiple methods of setting up the CLS context for incoming requests. This is mainly due to the fact that different underlying platforms are compatible with only some of these methods - see Compatibility considerations.",source:"@site/docs/02_setting-up-cls-context/index.md",sourceDirName:"02_setting-up-cls-context",slug:"/setting-up-cls-context/",permalink:"/nestjs-cls/setting-up-cls-context/",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/02_setting-up-cls-context/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"How it works",permalink:"/nestjs-cls/introduction/how-it-works"},next:{title:"Using a Middleware",permalink:"/nestjs-cls/setting-up-cls-context/using-a-middleware"}},l={},a=[{value:"Sync",id:"sync",level:2},{value:"Async",id:"async",level:2}];function d(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",p:"p",pre:"pre",...(0,o.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h1,{id:"setting-up-the-cls-context",children:"Setting up the CLS context"}),"\n",(0,s.jsxs)(t.p,{children:["This package provides multiple methods of setting up the CLS context for incoming requests. This is mainly due to the fact that different underlying platforms are compatible with only some of these methods - see ",(0,s.jsx)(t.a,{href:"/nestjs-cls/considerations/compatibility",children:"Compatibility considerations"}),"."]}),"\n",(0,s.jsxs)(t.p,{children:["For HTTP transports, the context can be preferably set up in a ",(0,s.jsx)(t.code,{children:"ClsMiddleware"}),". For all other platforms, or cases where the ",(0,s.jsx)(t.code,{children:"ClsMiddleware"})," is not applicable, this package also provides a ",(0,s.jsx)(t.code,{children:"ClsGuard"})," and ",(0,s.jsx)(t.code,{children:"ClsInterceptor"}),". While both of these also work with HTTP, they come with some caveats, see below."]}),"\n",(0,s.jsxs)(t.p,{children:["The ",(0,s.jsx)(t.code,{children:"ClsModule"})," provides both ",(0,s.jsx)(t.code,{children:"forRoot"})," and ",(0,s.jsx)(t.code,{children:"forRootAsync"})," methods to configure these."]}),"\n",(0,s.jsx)(t.h2,{id:"sync",children:"Sync"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",metastring:'title="app.module.ts"',children:"@Module({\n imports: [\n ClsModule.forRoot({\n global: true,\n middleware: {\n mount: true,\n generateId: true,\n },\n }),\n ],\n // ...\n})\nexport class AppModule {}\n"})}),"\n",(0,s.jsx)(t.h2,{id:"async",children:"Async"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",metastring:'title="app.module.ts"',children:"@Module({\n imports: [\n ClsModule.forRootAsync({\n global: true,\n inject: [IdGeneratorService]\n useFactory: (idGeneratorService) => ({\n middleware: {\n mount: true,\n generateId: true,\n idGenerator: (req) => idGeneratorService.generate(req)\n },\n })\n }),\n ],\n // ...\n})\nexport class AppModule {}\n"})})]})}function p(e={}){const{wrapper:t}={...(0,o.a)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},1670:(e,t,n)=>{n.d(t,{Z:()=>c,a:()=>r});var s=n(7378);const o={},i=s.createContext(o);function r(e){const t=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:r(e.components),s.createElement(i.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/a2c1fdb7.de805607.js b/assets/js/a2c1fdb7.de805607.js deleted file mode 100755 index 6a0a4d5..0000000 --- a/assets/js/a2c1fdb7.de805607.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[776],{5318:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>f});var r=n(7378);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t =0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var l=r.createContext({}),c=function(e){var t=r.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):a(a({},t),e)),n},p=function(e){var t=c(e.components);return r.createElement(l.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},m=r.forwardRef((function(e,t){var n=e.components,o=e.mdxType,i=e.originalType,l=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),u=c(n),m=o,f=u["".concat(l,".").concat(m)]||u[m]||d[m]||i;return n?r.createElement(f,a(a({ref:t},p),{},{components:n})):r.createElement(f,a({ref:t},p))}));function f(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var i=n.length,a=new Array(i);a[0]=m;var s={};for(var l in t)hasOwnProperty.call(t,l)&&(s[l]=t[l]);s.originalType=e,s[u]="string"==typeof e?e:o,a[1]=s;for(var c=2;c{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>a,default:()=>d,frontMatter:()=>i,metadata:()=>s,toc:()=>c});var r=n(5773),o=(n(7378),n(5318));const i={},a="Setting up the CLS context",s={unversionedId:"setting-up-cls-context/index",id:"setting-up-cls-context/index",title:"Setting up the CLS context",description:"This package provides three methods of setting up the CLS context for incoming requests. This is mainly due to the fact that different underlying platforms are compatible with only some of these methods - see Compatibility considerations.",source:"@site/docs/02_setting-up-cls-context/index.md",sourceDirName:"02_setting-up-cls-context",slug:"/setting-up-cls-context/",permalink:"/nestjs-cls/setting-up-cls-context/",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/02_setting-up-cls-context/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"How it works",permalink:"/nestjs-cls/introduction/how-it-works"},next:{title:"Using a Middleware",permalink:"/nestjs-cls/setting-up-cls-context/using-a-middleware"}},l={},c=[{value:"Sync",id:"sync",level:2},{value:"Async",id:"async",level:2}],p={toc:c},u="wrapper";function d(e){let{components:t,...n}=e;return(0,o.kt)(u,(0,r.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"setting-up-the-cls-context"},"Setting up the CLS context"),(0,o.kt)("p",null,"This package provides ",(0,o.kt)("strong",{parentName:"p"},"three")," methods of setting up the CLS context for incoming requests. This is mainly due to the fact that different underlying platforms are compatible with only some of these methods - see ",(0,o.kt)("a",{parentName:"p",href:"/nestjs-cls/considerations/compatibility"},"Compatibility considerations"),"."),(0,o.kt)("p",null,"For HTTP transports, the context can be preferably set up in a ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsMiddleware"),". For all other platforms, or cases where the ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsMiddleware")," is not applicable, this package also provides a ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsGuard")," and ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsInterceptor"),". While both of these also work with HTTP, they come with some caveats, see below."),(0,o.kt)("p",null,"The ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsModule")," provides both ",(0,o.kt)("inlineCode",{parentName:"p"},"forRoot")," and ",(0,o.kt)("inlineCode",{parentName:"p"},"forRootAsync")," methods to configure these."),(0,o.kt)("h2",{id:"sync"},"Sync"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="app.module.ts"',title:'"app.module.ts"'},"@Module({\n imports: [\n ClsModule.forRoot({\n global: true,\n middleware: {\n mount: true,\n generateId: true,\n },\n }),\n ],\n // ...\n})\nexport class AppModule {}\n")),(0,o.kt)("h2",{id:"async"},"Async"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="app.module.ts"',title:'"app.module.ts"'},"@Module({\n imports: [\n ClsModule.forRootAsync({\n global: true,\n inject: [IdGeneratorService]\n useFactory: (idGeneratorService) => ({\n middleware: {\n mount: true,\n generateId: true,\n idGenerator: (req) => idGeneratorService.generate(req)\n },\n })\n }),\n ],\n // ...\n})\nexport class AppModule {}\n")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/a7bd4aaa.6b9c6fa4.js b/assets/js/a7bd4aaa.6b9c6fa4.js new file mode 100644 index 0000000..6444c37 --- /dev/null +++ b/assets/js/a7bd4aaa.6b9c6fa4.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[518],{2922:(s,n,e)=>{e.r(n),e.d(n,{default:()=>d});e(7378);var r=e(8836),o=e(2064),t=e(2885),c=e(5473),i=e(4386),l=e(4246);function u(s){const{version:n}=s;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(i.Z,{version:n.version,tag:(0,o.os)(n.pluginId,n.version)}),(0,l.jsx)(r.d,{children:n.noIndex&&(0,l.jsx)("meta",{name:"robots",content:"noindex, nofollow"})})]})}function a(s){const{version:n,route:e}=s;return(0,l.jsx)(r.FG,{className:n.className,children:(0,l.jsx)(t.q,{version:n,children:(0,c.H)(e.routes)})})}function d(s){return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(u,{...s}),(0,l.jsx)(a,{...s})]})}}}]); \ No newline at end of file diff --git a/assets/js/a886e75a.d95036fe.js b/assets/js/a886e75a.d95036fe.js new file mode 100644 index 0000000..233447f --- /dev/null +++ b/assets/js/a886e75a.d95036fe.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[466],{877:(t,n,a)=>{a.r(n),a.d(n,{assets:()=>o,contentTitle:()=>r,default:()=>p,frontMatter:()=>i,metadata:()=>c,toc:()=>l});var e=a(4246),s=a(1670);const i={},r="Creating a custom adapter",c={id:"plugins/available-plugins/transactional/creating-custom-adapter",title:"Creating a custom adapter",description:"TODO: To be written.",source:"@site/docs/06_plugins/01_available-plugins/01-transactional/10-creating-custom-adapter.md",sourceDirName:"06_plugins/01_available-plugins/01-transactional",slug:"/plugins/available-plugins/transactional/creating-custom-adapter",permalink:"/nestjs-cls/plugins/available-plugins/transactional/creating-custom-adapter",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/06_plugins/01_available-plugins/01-transactional/10-creating-custom-adapter.md",tags:[],version:"current",sidebarPosition:10,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Prisma adapter",permalink:"/nestjs-cls/plugins/available-plugins/transactional/prisma-adapter"},next:{title:"Plugin API",permalink:"/nestjs-cls/plugins/plugin-api"}},o={},l=[];function u(t){const n={h1:"h1",p:"p",...(0,s.a)(),...t.components};return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(n.h1,{id:"creating-a-custom-adapter",children:"Creating a custom adapter"}),"\n",(0,e.jsx)(n.p,{children:"TODO: To be written."})]})}function p(t={}){const{wrapper:n}={...(0,s.a)(),...t.components};return n?(0,e.jsx)(n,{...t,children:(0,e.jsx)(u,{...t})}):u(t)}},1670:(t,n,a)=>{a.d(n,{Z:()=>c,a:()=>r});var e=a(7378);const s={},i=e.createContext(s);function r(t){const n=e.useContext(i);return e.useMemo((function(){return"function"==typeof t?t(n):{...n,...t}}),[n,t])}function c(t){let n;return n=t.disableParentContext?"function"==typeof t.components?t.components(s):t.components||s:r(t.components),e.createElement(i.Provider,{value:n},t.children)}}}]); \ No newline at end of file diff --git a/assets/js/a8d12efa.0b5297db.js b/assets/js/a8d12efa.0b5297db.js new file mode 100644 index 0000000..ff23b7a --- /dev/null +++ b/assets/js/a8d12efa.0b5297db.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[55],{9446:(e,s,n)=>{n.r(s),n.d(s,{assets:()=>c,contentTitle:()=>r,default:()=>l,frontMatter:()=>a,metadata:()=>i,toc:()=>u});var t=n(4246),o=n(1670);const a={},r="Usage outside of web request",i={id:"features-and-use-cases/usage-outside-of-web-request",title:"Usage outside of web request",description:"Sometimes, a part of the app that relies on the CLS storage might need to be called outside of the context of a web request - for example, in a Cron job, while consuming a Queue, during the application bootstrap or in CLI apps.",source:"@site/docs/03_features-and-use-cases/04_usage-outside-of-web-request.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/usage-outside-of-web-request",permalink:"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/04_usage-outside-of-web-request.md",tags:[],version:"current",sidebarPosition:4,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Breaking out of DI",permalink:"/nestjs-cls/features-and-use-cases/breaking-out-of-di"},next:{title:"Type safety and type inference",permalink:"/nestjs-cls/features-and-use-cases/type-safety-and-type-inference"}},c={},u=[];function d(e){const s={a:"a",admonition:"admonition",code:"code",h1:"h1",p:"p",pre:"pre",...(0,o.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.h1,{id:"usage-outside-of-web-request",children:"Usage outside of web request"}),"\n",(0,t.jsx)(s.p,{children:"Sometimes, a part of the app that relies on the CLS storage might need to be called outside of the context of a web request - for example, in a Cron job, while consuming a Queue, during the application bootstrap or in CLI apps."}),"\n",(0,t.jsx)(s.p,{children:"In such cases, there are no enhancers that can be bound to the handler to set up the context."}),"\n",(0,t.jsxs)(s.p,{children:["Therefore, you as the the developer are responsible for wrapping the execution with ",(0,t.jsx)(s.code,{children:"ClsService#run"}),", or using the ",(0,t.jsx)(s.code,{children:"@UseCls"})," decorator. In any case, if any following code depends on some context variables, these need to be set up manually."]}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-ts",children:"@Injectable()\nexport class CronController {\n constructor(\n private readonly someService: SomeService,\n private readonly cls: ClsService,\n );\n\n @Cron('45 * * * * *')\n async handleCronExample1() {\n // either explicitly wrap the function body with\n // a call to `ClsService#run` ...\n await this.cls.run(async () => {\n this.cls.set('mode', 'cron');\n await this.someService.doTheThing();\n });\n }\n\n @Cron('90 * * * * *')\n // ... or use the convenience decorator which\n // does the wrapping for you seamlessly.\n @UseCls({\n setup: (cls) => {\n cls.set('mode', 'cron');\n },\n })\n async handleCronExample2() {\n await this.someService.doTheThing();\n }\n}\n"})}),"\n",(0,t.jsx)(s.admonition,{type:"caution",children:(0,t.jsxs)(s.p,{children:["Special care must be taken in case you're using ",(0,t.jsx)(s.a,{href:"/nestjs-cls/features-and-use-cases/proxy-providers#outside-web-request",children:"Proxy Providers"}),"."]})})]})}function l(e={}){const{wrapper:s}={...(0,o.a)(),...e.components};return s?(0,t.jsx)(s,{...e,children:(0,t.jsx)(d,{...e})}):d(e)}},1670:(e,s,n)=>{n.d(s,{Z:()=>i,a:()=>r});var t=n(7378);const o={},a=t.createContext(o);function r(e){const s=t.useContext(a);return t.useMemo((function(){return"function"==typeof e?e(s):{...s,...e}}),[s,e])}function i(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:r(e.components),t.createElement(a.Provider,{value:s},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/a8d12efa.ae0cc29a.js b/assets/js/a8d12efa.ae0cc29a.js deleted file mode 100755 index 6d51f5f..0000000 --- a/assets/js/a8d12efa.ae0cc29a.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[55],{5318:(e,t,n)=>{n.d(t,{Zo:()=>l,kt:()=>h});var r=n(7378);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t =0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var c=r.createContext({}),u=function(e){var t=r.useContext(c),n=t;return e&&(n="function"==typeof e?e(t):a(a({},t),e)),n},l=function(e){var t=u(e.components);return r.createElement(c.Provider,{value:t},e.children)},p="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},f=r.forwardRef((function(e,t){var n=e.components,o=e.mdxType,s=e.originalType,c=e.parentName,l=i(e,["components","mdxType","originalType","parentName"]),p=u(n),f=o,h=p["".concat(c,".").concat(f)]||p[f]||d[f]||s;return n?r.createElement(h,a(a({ref:t},l),{},{components:n})):r.createElement(h,a({ref:t},l))}));function h(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var s=n.length,a=new Array(s);a[0]=f;var i={};for(var c in t)hasOwnProperty.call(t,c)&&(i[c]=t[c]);i.originalType=e,i[p]="string"==typeof e?e:o,a[1]=i;for(var u=2;u {n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>a,default:()=>d,frontMatter:()=>s,metadata:()=>i,toc:()=>u});var r=n(5773),o=(n(7378),n(5318));const s={},a="Usage outside of web request",i={unversionedId:"features-and-use-cases/usage-outside-of-web-request",id:"features-and-use-cases/usage-outside-of-web-request",title:"Usage outside of web request",description:"Sometimes, a part of the app that relies on the CLS storage might need to be called outside of the context of a web request - for example, in a Cron job, while consuming a Queue or during the application bootstrap. In such cases, there are no enhancers that can be bound to the handler to set up the context.",source:"@site/docs/03_features-and-use-cases/04_usage-outside-of-web-request.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/usage-outside-of-web-request",permalink:"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/04_usage-outside-of-web-request.md",tags:[],version:"current",sidebarPosition:4,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Breaking out of DI",permalink:"/nestjs-cls/features-and-use-cases/breakin-out-of-di"},next:{title:"Type safety and type inference",permalink:"/nestjs-cls/features-and-use-cases/type-safety-and-type-inference"}},c={},u=[],l={toc:u},p="wrapper";function d(e){let{components:t,...n}=e;return(0,o.kt)(p,(0,r.Z)({},l,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"usage-outside-of-web-request"},"Usage outside of web request"),(0,o.kt)("p",null,"Sometimes, a part of the app that relies on the CLS storage might need to be called outside of the context of a web request - for example, in a Cron job, while consuming a Queue or during the application bootstrap. In such cases, there are no enhancers that can be bound to the handler to set up the context."),(0,o.kt)("p",null,"Therefore, you as the the developer are responsible for wrapping the execution with ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsService#run"),", or using the ",(0,o.kt)("inlineCode",{parentName:"p"},"@UseCls")," decorator. In any case, if any following code depends on some context variables, these need to be set up manually."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts"},"@Injectable()\nexport class CronController {\n constructor(\n private readonly someService: SomeService,\n private readonly cls: ClsService,\n );\n\n @Cron('45 * * * * *')\n async handleCronExample1() {\n // either explicitly wrap the function body with\n // a call to `ClsService#run` ...\n await this.cls.run(async () => {\n this.cls.set('mode', 'cron');\n await this.someService.doTheThing();\n });\n }\n\n @Cron('90 * * * * *')\n // ... or use the convenience decorator which\n // does the wrapping for you seamlessly.\n @UseCls({\n setup: (cls) => {\n cls.set('mode', 'cron');\n },\n })\n async handleCronExample2() {\n await this.someService.doTheThing();\n }\n}\n")),(0,o.kt)("admonition",{type:"caution"},(0,o.kt)("p",{parentName:"admonition"},"Special care must be taken in case you're using ",(0,o.kt)("a",{parentName:"p",href:"/nestjs-cls/features-and-use-cases/proxy-providers#outside-web-request"},"Proxy Providers"),".")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/a94703ab.74e9a79f.js b/assets/js/a94703ab.74e9a79f.js new file mode 100644 index 0000000..8a50065 --- /dev/null +++ b/assets/js/a94703ab.74e9a79f.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[368],{552:(e,t,n)=>{n.r(t),n.d(t,{default:()=>be});var a=n(7378),o=n(624),i=n(8836),s=n(5854),l=n(7470),c=n(8774),r=n(7419),d=n(9169),u=n(6847);const m={backToTopButton:"backToTopButton_iEvu",backToTopButtonShow:"backToTopButtonShow_DO8w"};var b=n(4246);function h(){const{shown:e,scrollToTop:t}=function(e){let{threshold:t}=e;const[n,o]=(0,a.useState)(!1),i=(0,a.useRef)(!1),{startScroll:s,cancelScroll:l}=(0,d.Ct)();return(0,d.RF)(((e,n)=>{let{scrollY:a}=e;const s=n?.scrollY;s&&(i.current?i.current=!1:a>=s?(l(),o(!1)):a{e.location.hash&&(i.current=!0,o(!1))})),{shown:n,scrollToTop:()=>s(0)}}({threshold:300});return(0,b.jsx)("button",{"aria-label":(0,r.I)({id:"theme.BackToTopButton.buttonAriaLabel",message:"Scroll back to top",description:"The ARIA label for the back to top button"}),className:(0,o.Z)("clean-btn",s.k.common.backToTopButton,m.backToTopButton,e&&m.backToTopButtonShow),type:"button",onClick:t})}var p=n(5122),x=n(3620),f=n(7980),j=n(9899),_=n(8340);function k(e){return(0,b.jsx)("svg",{width:"20",height:"20","aria-hidden":"true",...e,children:(0,b.jsxs)("g",{fill:"#7a7a7a",children:[(0,b.jsx)("path",{d:"M9.992 10.023c0 .2-.062.399-.172.547l-4.996 7.492a.982.982 0 01-.828.454H1c-.55 0-1-.453-1-1 0-.2.059-.403.168-.551l4.629-6.942L.168 3.078A.939.939 0 010 2.528c0-.548.45-.997 1-.997h2.996c.352 0 .649.18.828.45L9.82 9.472c.11.148.172.347.172.55zm0 0"}),(0,b.jsx)("path",{d:"M19.98 10.023c0 .2-.058.399-.168.547l-4.996 7.492a.987.987 0 01-.828.454h-3c-.547 0-.996-.453-.996-1 0-.2.059-.403.168-.551l4.625-6.942-4.625-6.945a.939.939 0 01-.168-.55 1 1 0 01.996-.997h3c.348 0 .649.18.828.45l4.996 7.492c.11.148.168.347.168.55zm0 0"})]})})}const v={collapseSidebarButton:"collapseSidebarButton_oTwn",collapseSidebarButtonIcon:"collapseSidebarButtonIcon_pMEX"};function g(e){let{onClick:t}=e;return(0,b.jsx)("button",{type:"button",title:(0,r.I)({id:"theme.docs.sidebar.collapseButtonTitle",message:"Collapse sidebar",description:"The title attribute for collapse button of doc sidebar"}),"aria-label":(0,r.I)({id:"theme.docs.sidebar.collapseButtonAriaLabel",message:"Collapse sidebar",description:"The title attribute for collapse button of doc sidebar"}),className:(0,o.Z)("button button--secondary button--outline",v.collapseSidebarButton),onClick:t,children:(0,b.jsx)(k,{className:v.collapseSidebarButtonIcon})})}var C=n(4234),S=n(3879);const I=Symbol("EmptyContext"),N=a.createContext(I);function T(e){let{children:t}=e;const[n,o]=(0,a.useState)(null),i=(0,a.useMemo)((()=>({expandedItem:n,setExpandedItem:o})),[n]);return(0,b.jsx)(N.Provider,{value:i,children:t})}var B=n(4229),Z=n(6440),L=n(5237),y=n(362);function A(e){let{collapsed:t,categoryLabel:n,onClick:a}=e;return(0,b.jsx)("button",{"aria-label":t?(0,r.I)({id:"theme.DocSidebarItem.expandCategoryAriaLabel",message:"Expand sidebar category '{label}'",description:"The ARIA label to expand the sidebar category"},{label:n}):(0,r.I)({id:"theme.DocSidebarItem.collapseCategoryAriaLabel",message:"Collapse sidebar category '{label}'",description:"The ARIA label to collapse the sidebar category"},{label:n}),type:"button",className:"clean-btn menu__caret",onClick:a})}function E(e){let{item:t,onItemClick:n,activePath:i,level:c,index:r,...d}=e;const{items:u,label:m,collapsible:h,className:p,href:x}=t,{docs:{sidebar:{autoCollapseCategories:f}}}=(0,j.L)(),_=function(e){const t=(0,y.Z)();return(0,a.useMemo)((()=>e.href&&!e.linkUnlisted?e.href:!t&&e.collapsible?(0,l.LM)(e):void 0),[e,t])}(t),k=(0,l._F)(t,i),v=(0,Z.Mg)(x,i),{collapsed:g,setCollapsed:C}=(0,B.u)({initialState:()=>!!h&&(!k&&t.collapsed)}),{expandedItem:T,setExpandedItem:E}=function(){const e=(0,a.useContext)(N);if(e===I)throw new S.i6("DocSidebarItemsExpandedStateProvider");return e}(),w=function(e){void 0===e&&(e=!g),E(e?null:r),C(e)};return function(e){let{isActive:t,collapsed:n,updateCollapsed:o}=e;const i=(0,S.D9)(t);(0,a.useEffect)((()=>{t&&!i&&n&&o(!1)}),[t,i,n,o])}({isActive:k,collapsed:g,updateCollapsed:w}),(0,a.useEffect)((()=>{h&&null!=T&&T!==r&&f&&C(!0)}),[h,T,r,C,f]),(0,b.jsxs)("li",{className:(0,o.Z)(s.k.docs.docSidebarItemCategory,s.k.docs.docSidebarItemCategoryLevel(c),"menu__list-item",{"menu__list-item--collapsed":g},p),children:[(0,b.jsxs)("div",{className:(0,o.Z)("menu__list-item-collapsible",{"menu__list-item-collapsible--active":v}),children:[(0,b.jsx)(L.Z,{className:(0,o.Z)("menu__link",{"menu__link--sublist":h,"menu__link--sublist-caret":!x&&h,"menu__link--active":k}),onClick:h?e=>{n?.(t),x?w(!1):(e.preventDefault(),w())}:()=>{n?.(t)},"aria-current":v?"page":void 0,"aria-expanded":h?!g:void 0,href:h?_??"#":_,...d,children:m}),x&&h&&(0,b.jsx)(A,{collapsed:g,categoryLabel:m,onClick:e=>{e.preventDefault(),w()}})]}),(0,b.jsx)(B.z,{lazy:!0,as:"ul",className:"menu__list",collapsed:g,children:(0,b.jsx)(V,{items:u,tabIndex:g?-1:0,onItemClick:n,activePath:i,level:c+1})})]})}var w=n(4715),H=n(1858);const M={menuExternalLink:"menuExternalLink_BiEj"};function D(e){let{item:t,onItemClick:n,activePath:a,level:i,index:c,...r}=e;const{href:d,label:u,className:m,autoAddBaseUrl:h}=t,p=(0,l._F)(t,a),x=(0,w.Z)(d);return(0,b.jsx)("li",{className:(0,o.Z)(s.k.docs.docSidebarItemLink,s.k.docs.docSidebarItemLinkLevel(i),"menu__list-item",m),children:(0,b.jsxs)(L.Z,{className:(0,o.Z)("menu__link",!x&&M.menuExternalLink,{"menu__link--active":p}),autoAddBaseUrl:h,"aria-current":p?"page":void 0,to:d,...x&&{onClick:n?()=>n(t):void 0},...r,children:[u,!x&&(0,b.jsx)(H.Z,{})]})},u)}const R={menuHtmlItem:"menuHtmlItem_OniL"};function P(e){let{item:t,level:n,index:a}=e;const{value:i,defaultStyle:l,className:c}=t;return(0,b.jsx)("li",{className:(0,o.Z)(s.k.docs.docSidebarItemLink,s.k.docs.docSidebarItemLinkLevel(n),l&&[R.menuHtmlItem,"menu__list-item"],c),dangerouslySetInnerHTML:{__html:i}},a)}function W(e){let{item:t,...n}=e;switch(t.type){case"category":return(0,b.jsx)(E,{item:t,...n});case"html":return(0,b.jsx)(P,{item:t,...n});default:return(0,b.jsx)(D,{item:t,...n})}}function F(e){let{items:t,...n}=e;const a=(0,l.f)(t,n.activePath);return(0,b.jsx)(T,{children:a.map(((e,t)=>(0,b.jsx)(W,{item:e,index:t,...n},t)))})}const V=(0,a.memo)(F),Y={menu:"menu_jmj1",menuWithAnnouncementBar:"menuWithAnnouncementBar_YufC"};function U(e){let{path:t,sidebar:n,className:i}=e;const l=function(){const{isActive:e}=(0,C.nT)(),[t,n]=(0,a.useState)(e);return(0,d.RF)((t=>{let{scrollY:a}=t;e&&n(0===a)}),[e]),e&&t}();return(0,b.jsx)("nav",{"aria-label":(0,r.I)({id:"theme.docs.sidebar.navAriaLabel",message:"Docs sidebar",description:"The ARIA label for the sidebar navigation"}),className:(0,o.Z)("menu thin-scrollbar",Y.menu,l&&Y.menuWithAnnouncementBar,i),children:(0,b.jsx)("ul",{className:(0,o.Z)(s.k.docs.docSidebarMenu,"menu__list"),children:(0,b.jsx)(V,{items:n,activePath:t,level:1})})})}const z="sidebar_CUen",q="sidebarWithHideableNavbar_w4KB",K="sidebarHidden_k6VE",O="sidebarLogo_CYvI";function J(e){let{path:t,sidebar:n,onCollapse:a,isHidden:i}=e;const{navbar:{hideOnScroll:s},docs:{sidebar:{hideable:l}}}=(0,j.L)();return(0,b.jsxs)("div",{className:(0,o.Z)(z,s&&q,i&&K),children:[s&&(0,b.jsx)(_.Z,{tabIndex:-1,className:O}),(0,b.jsx)(U,{path:t,sidebar:n}),l&&(0,b.jsx)(g,{onClick:a})]})}const X=a.memo(J);var G=n(197),Q=n(9067);const $=e=>{let{sidebar:t,path:n}=e;const a=(0,Q.e)();return(0,b.jsx)("ul",{className:(0,o.Z)(s.k.docs.docSidebarMenu,"menu__list"),children:(0,b.jsx)(V,{items:t,activePath:n,onItemClick:e=>{"category"===e.type&&e.href&&a.toggle(),"link"===e.type&&a.toggle()},level:1})})};function ee(e){return(0,b.jsx)(G.Zo,{component:$,props:e})}const te=a.memo(ee);function ne(e){const t=(0,f.i)(),n="desktop"===t||"ssr"===t,a="mobile"===t;return(0,b.jsxs)(b.Fragment,{children:[n&&(0,b.jsx)(X,{...e}),a&&(0,b.jsx)(te,{...e})]})}const ae={expandButton:"expandButton_pLDq",expandButtonIcon:"expandButtonIcon_X5ff"};function oe(e){let{toggleSidebar:t}=e;return(0,b.jsx)("div",{className:ae.expandButton,title:(0,r.I)({id:"theme.docs.sidebar.expandButtonTitle",message:"Expand sidebar",description:"The ARIA label and title attribute for expand button of doc sidebar"}),"aria-label":(0,r.I)({id:"theme.docs.sidebar.expandButtonAriaLabel",message:"Expand sidebar",description:"The ARIA label and title attribute for expand button of doc sidebar"}),tabIndex:0,role:"button",onKeyDown:t,onClick:t,children:(0,b.jsx)(k,{className:ae.expandButtonIcon})})}const ie={docSidebarContainer:"docSidebarContainer_c7NB",docSidebarContainerHidden:"docSidebarContainerHidden_P3S_",sidebarViewport:"sidebarViewport_KYo0"};function se(e){let{children:t}=e;const n=(0,c.V)();return(0,b.jsx)(a.Fragment,{children:t},n?.name??"noSidebar")}function le(e){let{sidebar:t,hiddenSidebarContainer:n,setHiddenSidebarContainer:i}=e;const{pathname:l}=(0,x.TH)(),[c,r]=(0,a.useState)(!1),d=(0,a.useCallback)((()=>{c&&r(!1),!c&&(0,p.n)()&&r(!0),i((e=>!e))}),[i,c]);return(0,b.jsx)("aside",{className:(0,o.Z)(s.k.docs.docSidebarContainer,ie.docSidebarContainer,n&&ie.docSidebarContainerHidden),onTransitionEnd:e=>{e.currentTarget.classList.contains(ie.docSidebarContainer)&&n&&r(!0)},children:(0,b.jsx)(se,{children:(0,b.jsxs)("div",{className:(0,o.Z)(ie.sidebarViewport,c&&ie.sidebarViewportHidden),children:[(0,b.jsx)(ne,{sidebar:t,path:l,onCollapse:d,isHidden:c}),c&&(0,b.jsx)(oe,{toggleSidebar:d})]})})})}const ce={docMainContainer:"docMainContainer_a9sJ",docMainContainerEnhanced:"docMainContainerEnhanced_grEJ",docItemWrapperEnhanced:"docItemWrapperEnhanced_VqDq"};function re(e){let{hiddenSidebarContainer:t,children:n}=e;const a=(0,c.V)();return(0,b.jsx)("main",{className:(0,o.Z)(ce.docMainContainer,(t||!a)&&ce.docMainContainerEnhanced),children:(0,b.jsx)("div",{className:(0,o.Z)("container padding-top--md padding-bottom--lg",ce.docItemWrapper,t&&ce.docItemWrapperEnhanced),children:n})})}const de={docRoot:"docRoot_DfVB",docsWrapper:"docsWrapper__sE8"};function ue(e){let{children:t}=e;const n=(0,c.V)(),[o,i]=(0,a.useState)(!1);return(0,b.jsxs)("div",{className:de.docsWrapper,children:[(0,b.jsx)(h,{}),(0,b.jsxs)("div",{className:de.docRoot,children:[n&&(0,b.jsx)(le,{sidebar:n.items,hiddenSidebarContainer:o,setHiddenSidebarContainer:i}),(0,b.jsx)(re,{hiddenSidebarContainer:o,children:t})]})]})}var me=n(4718);function be(e){const t=(0,l.SN)(e);if(!t)return(0,b.jsx)(me.Z,{});const{docElement:n,sidebarName:a,sidebarItems:r}=t;return(0,b.jsx)(i.FG,{className:(0,o.Z)(s.k.page.docsDocPage),children:(0,b.jsx)(c.b,{name:a,items:r,children:(0,b.jsx)(ue,{children:n})})})}},4718:(e,t,n)=>{n.d(t,{Z:()=>l});n(7378);var a=n(624),o=n(7419),i=n(8825),s=n(4246);function l(e){let{className:t}=e;return(0,s.jsx)("main",{className:(0,a.Z)("container margin-vert--xl",t),children:(0,s.jsx)("div",{className:"row",children:(0,s.jsxs)("div",{className:"col col--6 col--offset-3",children:[(0,s.jsx)(i.Z,{as:"h1",className:"hero__title",children:(0,s.jsx)(o.Z,{id:"theme.NotFound.title",description:"The title of the 404 page",children:"Page Not Found"})}),(0,s.jsx)("p",{children:(0,s.jsx)(o.Z,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page",children:"We could not find what you were looking for."})}),(0,s.jsx)("p",{children:(0,s.jsx)(o.Z,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page",children:"Please contact the owner of the site that linked you to the original URL and let them know their link is broken."})})]})})})}}}]); \ No newline at end of file diff --git a/assets/js/ae4976f8.5406cedc.js b/assets/js/ae4976f8.5406cedc.js deleted file mode 100755 index 090a3c6..0000000 --- a/assets/js/ae4976f8.5406cedc.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[93],{5318:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>h});var a=n(7378);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function i(e){for(var t=1;t =0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var s=a.createContext({}),u=function(e){var t=a.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},p=function(e){var t=u(e.components);return a.createElement(s.Provider,{value:t},e.children)},d="mdxType",c={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},m=a.forwardRef((function(e,t){var n=e.components,o=e.mdxType,r=e.originalType,s=e.parentName,p=l(e,["components","mdxType","originalType","parentName"]),d=u(n),m=o,h=d["".concat(s,".").concat(m)]||d[m]||c[m]||r;return n?a.createElement(h,i(i({ref:t},p),{},{components:n})):a.createElement(h,i({ref:t},p))}));function h(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var r=n.length,i=new Array(r);i[0]=m;var l={};for(var s in t)hasOwnProperty.call(t,s)&&(l[s]=t[s]);l.originalType=e,l[d]="string"==typeof e?e:o,i[1]=l;for(var u=2;u {n.r(t),n.d(t,{assets:()=>s,contentTitle:()=>i,default:()=>c,frontMatter:()=>r,metadata:()=>l,toc:()=>u});var a=n(5773),o=(n(7378),n(5318));const r={},i="Using a Middleware",l={unversionedId:"setting-up-cls-context/using-a-middleware",id:"setting-up-cls-context/using-a-middleware",title:"Using a Middleware",description:"This section applies only if you use a HTTP transport (REST or GraphQL)",source:"@site/docs/02_setting-up-cls-context/01_using-a-middleware.md",sourceDirName:"02_setting-up-cls-context",slug:"/setting-up-cls-context/using-a-middleware",permalink:"/nestjs-cls/setting-up-cls-context/using-a-middleware",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/02_setting-up-cls-context/01_using-a-middleware.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Setting up the CLS context",permalink:"/nestjs-cls/setting-up-cls-context/"},next:{title:"Using a Guard",permalink:"/nestjs-cls/setting-up-cls-context/using-a-guard"}},s={},u=[{value:"Automatically",id:"automatically",level:2},{value:"Manually",id:"manually",level:2},{value:"In the module",id:"in-the-module",level:3},{value:"Using app.use",id:"using-appuse",level:3}],p={toc:u},d="wrapper";function c(e){let{components:t,...n}=e;return(0,o.kt)(d,(0,a.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"using-a-middleware"},"Using a Middleware"),(0,o.kt)("admonition",{type:"info"},(0,o.kt)("p",{parentName:"admonition"},"This section applies only if you use a HTTP transport (REST or GraphQL)")),(0,o.kt)("p",null,"Since in NestJS, HTTP ",(0,o.kt)("strong",{parentName:"p"},"middleware")," is the first thing to run when a request arrives, it is an ideal place to initialise the CLS context. This package provides ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsMiddleware")," that can be mounted to all (or selected) routes inside which the context is set up before the ",(0,o.kt)("inlineCode",{parentName:"p"},"next()")," call."),(0,o.kt)("p",null,"All you have to do is mount it to routes in which you want to use CLS, or pass ",(0,o.kt)("inlineCode",{parentName:"p"},"middleware: { mount: true }")," to the ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsModule.forRoot()")," options which automatically mounts it to all routes."),(0,o.kt)("p",null,"Once that is set up, the ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsService")," will have access to a common storage in all ",(0,o.kt)("em",{parentName:"p"},"Guards, Interceptors, Pipes, Controllers, Services and Exception Filters")," that are called within that route."),(0,o.kt)("h2",{id:"automatically"},"Automatically"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="app.module.ts"',title:'"app.module.ts"'},"@Module({\n imports: [\n ClsModule.forRoot({\n global: true,\n // highlight-start\n middleware: { mount: true },\n // highlight-end\n }),\n ],\n // ...\n})\nexport class AppModule {}\n")),(0,o.kt)("h2",{id:"manually"},"Manually"),(0,o.kt)("p",null,"Sometimes, you might want to only use CLS on certain routes, or you need to have more control over the order of middleware registration in combination with other middlewares."),(0,o.kt)("h3",{id:"in-the-module"},"In the module"),(0,o.kt)("p",null,"In that case, omit the ",(0,o.kt)("inlineCode",{parentName:"p"},"mount")," option or set it to ",(0,o.kt)("inlineCode",{parentName:"p"},"false")," and bind the ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsMiddleware")," manually in the module:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="app.module.ts"',title:'"app.module.ts"'},"@Module({\n imports: [\n ClsModule.forRoot({\n global: true,\n // highlight-start\n middleware: { mount: false },\n // highlight-end\n }),\n ],\n // ...\n})\nexport class AppModule implements NestModule {\n configure(consumer: MiddlewareConsumer) {\n // highlight-start\n consumer.apply(ClsMiddleware).forRoutes('custom/route');\n // highlight-end\n }\n}\n")),(0,o.kt)("h3",{id:"using-appuse"},"Using app.use"),(0,o.kt)("p",null,"Sometimes, however, the previous method won't be enough, because the middleware could be mounted too late and you won't be able to use it in other middlewares that need to run prior to that - for example, the API versioning feature of NestJS apparently interferes with the order, see issue ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/Papooch/nestjs-cls/issues/67"},"#67"),"."),(0,o.kt)("p",null,"In that case, you can mount it directly in the bootstrap method:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="main.ts"',title:'"main.ts"'},"function bootstrap() {\n const app = await NestFactory.create(AppModule);\n // create and mount the middleware manually here\n app.use(\n // highlight-start\n new ClsMiddleware({\n /* ...settings */\n }).use,\n // highlight-end\n );\n await app.listen(3000);\n}\n")),(0,o.kt)("admonition",{type:"caution"},(0,o.kt)("p",{parentName:"admonition"},(0,o.kt)("strong",{parentName:"p"},"Please note"),": If you bind the middleware using ",(0,o.kt)("inlineCode",{parentName:"p"},"app.use()"),", it will not respect middleware settings passed to ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsModule.forRoot()"),", so you will have to provide them yourself in the constructor.")))}c.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/ae4976f8.fa94a518.js b/assets/js/ae4976f8.fa94a518.js new file mode 100644 index 0000000..a3541e1 --- /dev/null +++ b/assets/js/ae4976f8.fa94a518.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[93],{5934:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>r,contentTitle:()=>l,default:()=>u,frontMatter:()=>o,metadata:()=>a,toc:()=>d});var s=n(4246),i=n(1670);const o={},l="Using a Middleware",a={id:"setting-up-cls-context/using-a-middleware",title:"Using a Middleware",description:"This section applies only if you use a HTTP transport (REST or GraphQL)",source:"@site/docs/02_setting-up-cls-context/01_using-a-middleware.md",sourceDirName:"02_setting-up-cls-context",slug:"/setting-up-cls-context/using-a-middleware",permalink:"/nestjs-cls/setting-up-cls-context/using-a-middleware",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/02_setting-up-cls-context/01_using-a-middleware.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Setting up the CLS context",permalink:"/nestjs-cls/setting-up-cls-context/"},next:{title:"Using a Guard",permalink:"/nestjs-cls/setting-up-cls-context/using-a-guard"}},r={},d=[{value:"Automatically",id:"automatically",level:2},{value:"Manually",id:"manually",level:2},{value:"In the module",id:"in-the-module",level:3},{value:"Using app.use",id:"using-appuse",level:3}];function c(e){const t={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...(0,i.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h1,{id:"using-a-middleware",children:"Using a Middleware"}),"\n",(0,s.jsx)(t.admonition,{type:"info",children:(0,s.jsx)(t.p,{children:"This section applies only if you use a HTTP transport (REST or GraphQL)"})}),"\n",(0,s.jsxs)(t.p,{children:["Since in NestJS, HTTP ",(0,s.jsx)(t.strong,{children:"middleware"})," is the first thing to run when a request arrives, it is an ideal place to initialise the CLS context. This package provides ",(0,s.jsx)(t.code,{children:"ClsMiddleware"})," that can be mounted to all (or selected) routes inside which the context is set up before the ",(0,s.jsx)(t.code,{children:"next()"})," call."]}),"\n",(0,s.jsxs)(t.p,{children:["All you have to do is mount it to routes in which you want to use CLS, or pass ",(0,s.jsx)(t.code,{children:"middleware: { mount: true }"})," to the ",(0,s.jsx)(t.code,{children:"ClsModule.forRoot()"})," options which automatically mounts it to all routes."]}),"\n",(0,s.jsxs)(t.p,{children:["Once that is set up, the ",(0,s.jsx)(t.code,{children:"ClsService"})," will have access to a common storage in all ",(0,s.jsx)(t.em,{children:"Guards, Interceptors, Pipes, Controllers, Services and Exception Filters"})," that are called within that route."]}),"\n",(0,s.jsx)(t.h2,{id:"automatically",children:"Automatically"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",metastring:'title="app.module.ts"',children:"@Module({\n imports: [\n ClsModule.forRoot({\n global: true,\n // highlight-start\n middleware: { mount: true },\n // highlight-end\n }),\n ],\n // ...\n})\nexport class AppModule {}\n"})}),"\n",(0,s.jsx)(t.h2,{id:"manually",children:"Manually"}),"\n",(0,s.jsx)(t.p,{children:"Sometimes, you might want to only use CLS on certain routes, or you need to have more control over the order of middleware registration in combination with other middlewares."}),"\n",(0,s.jsx)(t.h3,{id:"in-the-module",children:"In the module"}),"\n",(0,s.jsxs)(t.p,{children:["In that case, omit the ",(0,s.jsx)(t.code,{children:"mount"})," option or set it to ",(0,s.jsx)(t.code,{children:"false"})," and bind the ",(0,s.jsx)(t.code,{children:"ClsMiddleware"})," manually in the module:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",metastring:'title="app.module.ts"',children:"@Module({\n imports: [\n ClsModule.forRoot({\n global: true,\n // highlight-start\n middleware: { mount: false },\n // highlight-end\n }),\n ],\n // ...\n})\nexport class AppModule implements NestModule {\n configure(consumer: MiddlewareConsumer) {\n // highlight-start\n consumer.apply(ClsMiddleware).forRoutes('custom/route');\n // highlight-end\n }\n}\n"})}),"\n",(0,s.jsx)(t.h3,{id:"using-appuse",children:"Using app.use"}),"\n",(0,s.jsxs)(t.p,{children:["Sometimes, however, the previous method won't be enough, because the middleware could be mounted too late and you won't be able to use it in other middlewares that need to run prior to that - for example, the API versioning feature of NestJS apparently interferes with the order, see issue ",(0,s.jsx)(t.a,{href:"https://github.com/Papooch/nestjs-cls/issues/67",children:"#67"}),"."]}),"\n",(0,s.jsx)(t.p,{children:"In that case, you can mount it directly in the bootstrap method:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",metastring:'title="main.ts"',children:"function bootstrap() {\n const app = await NestFactory.create(AppModule);\n // create and mount the middleware manually here\n app.use(\n // highlight-start\n new ClsMiddleware({\n /* ...settings */\n }).use,\n // highlight-end\n );\n await app.listen(3000);\n}\n"})}),"\n",(0,s.jsx)(t.admonition,{type:"caution",children:(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Please note"}),": If you bind the middleware using ",(0,s.jsx)(t.code,{children:"app.use()"}),", it will not respect middleware settings passed to ",(0,s.jsx)(t.code,{children:"ClsModule.forRoot()"}),", so you will have to provide them yourself in the constructor."]})})]})}function u(e={}){const{wrapper:t}={...(0,i.a)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(c,{...e})}):c(e)}},1670:(e,t,n)=>{n.d(t,{Z:()=>a,a:()=>l});var s=n(7378);const i={},o=s.createContext(i);function l(e){const t=s.useContext(o);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),s.createElement(o.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/b09df872.558f0f47.js b/assets/js/b09df872.558f0f47.js new file mode 100644 index 0000000..0d28eca --- /dev/null +++ b/assets/js/b09df872.558f0f47.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[246],{8625:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>h,frontMatter:()=>r,metadata:()=>c,toc:()=>a});var s=t(4246),o=t(1670);const r={},i="Using an Interceptor",c={id:"setting-up-cls-context/using-an-interceptor",title:"Using an Interceptor",description:"Another place to initiate the CLS context is an ClsInterceptor, which, unlike the ClsGuard uses AsyncLocalStorage#run method to wrap the following code, which is considered safer than enterWith.",source:"@site/docs/02_setting-up-cls-context/03_using-an-interceptor.md",sourceDirName:"02_setting-up-cls-context",slug:"/setting-up-cls-context/using-an-interceptor",permalink:"/nestjs-cls/setting-up-cls-context/using-an-interceptor",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/02_setting-up-cls-context/03_using-an-interceptor.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Using a Guard",permalink:"/nestjs-cls/setting-up-cls-context/using-a-guard"},next:{title:"Using a Decorator",permalink:"/nestjs-cls/setting-up-cls-context/using-a-decorator"}},l={},a=[];function d(e){const n={admonition:"admonition",code:"code",em:"em",h1:"h1",p:"p",pre:"pre",strong:"strong",...(0,o.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h1,{id:"using-an-interceptor",children:"Using an Interceptor"}),"\n",(0,s.jsxs)(n.p,{children:["Another place to initiate the CLS context is an ",(0,s.jsx)(n.code,{children:"ClsInterceptor"}),", which, unlike the ",(0,s.jsx)(n.code,{children:"ClsGuard"})," uses ",(0,s.jsx)(n.code,{children:"AsyncLocalStorage#run"})," method to wrap the following code, which is considered safer than ",(0,s.jsx)(n.code,{children:"enterWith"}),"."]}),"\n",(0,s.jsxs)(n.p,{children:["To use it, pass its configuration to the ",(0,s.jsx)(n.code,{children:"interceptor"})," property to the ",(0,s.jsx)(n.code,{children:"ClsModule.forRoot()"})," options:"]}),"\n",(0,s.jsx)(n.h1,{id:"automatically",children:"Automatically"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",metastring:'title="app.module.ts"',children:"@Module({\n imports: [\n ClsModule.forRoot({\n // highlight-start\n interceptor: { mount: true },\n // highlight-end\n }),\n ],\n // ...\n})\nexport class AppModule {}\n"})}),"\n",(0,s.jsx)(n.h1,{id:"manually",children:"Manually"}),"\n",(0,s.jsxs)(n.p,{children:["Or mount it manually as ",(0,s.jsx)(n.code,{children:"APP_INTERCEPTOR"})]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",metastring:'title="app.module.ts"',children:"@Module({\n imports: [\n ClsModule.forRoot({\n // highlight-start\n interceptor: { mount: false }\n // highlight-end\n }),\n ]\n providers: [\n {\n // highlight-start\n provide: APP_INTERCEPTOR,\n useClass: ClsGuard,\n // highlight-end\n },\n ],\n // ...\n})\nexport class AppModule {}\n"})}),"\n",(0,s.jsx)(n.p,{children:"or directly on the Controller/Resolver with:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"@UseInterceptors(ClsInterceptor);\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.strong,{children:"Please note"}),": Since Nest's ",(0,s.jsx)(n.em,{children:"Interceptors"})," run after ",(0,s.jsx)(n.em,{children:"Guards"}),", that means using this method makes CLS ",(0,s.jsx)(n.strong,{children:"unavailable in Guards"})," (and in case of REST Controllers, also in ",(0,s.jsx)(n.strong,{children:"Exception Filters"}),")."]})})]})}function h(e={}){const{wrapper:n}={...(0,o.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},1670:(e,n,t)=>{t.d(n,{Z:()=>c,a:()=>i});var s=t(7378);const o={},r=s.createContext(o);function i(e){const n=s.useContext(r);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),s.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/b09df872.6dc93e4a.js b/assets/js/b09df872.6dc93e4a.js deleted file mode 100755 index 77f0f81..0000000 --- a/assets/js/b09df872.6dc93e4a.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[246],{5318:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>g});var r=n(7378);function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function i(e){for(var t=1;t =0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var l=r.createContext({}),p=function(e){var t=r.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):i(i({},t),e)),n},c=function(e){var t=p(e.components);return r.createElement(l.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},m=r.forwardRef((function(e,t){var n=e.components,o=e.mdxType,a=e.originalType,l=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),u=p(n),m=o,g=u["".concat(l,".").concat(m)]||u[m]||d[m]||a;return n?r.createElement(g,i(i({ref:t},c),{},{components:n})):r.createElement(g,i({ref:t},c))}));function g(e,t){var n=arguments,o=t&&t.mdxType;if("string"==typeof e||o){var a=n.length,i=new Array(a);i[0]=m;var s={};for(var l in t)hasOwnProperty.call(t,l)&&(s[l]=t[l]);s.originalType=e,s[u]="string"==typeof e?e:o,i[1]=s;for(var p=2;p{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>i,default:()=>d,frontMatter:()=>a,metadata:()=>s,toc:()=>p});var r=n(5773),o=(n(7378),n(5318));const a={},i="Using an Interceptor",s={unversionedId:"setting-up-cls-context/using-an-interceptor",id:"setting-up-cls-context/using-an-interceptor",title:"Using an Interceptor",description:"Another place to initiate the CLS context is an ClsInterceptor, which, unlike the ClsGuard uses AsyncLocalStorage#run method to wrap the following code, which is considered safer than enterWith.",source:"@site/docs/02_setting-up-cls-context/03_using-an-interceptor.md",sourceDirName:"02_setting-up-cls-context",slug:"/setting-up-cls-context/using-an-interceptor",permalink:"/nestjs-cls/setting-up-cls-context/using-an-interceptor",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/02_setting-up-cls-context/03_using-an-interceptor.md",tags:[],version:"current",sidebarPosition:3,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Using a Guard",permalink:"/nestjs-cls/setting-up-cls-context/using-a-guard"},next:{title:"Using a Decorator",permalink:"/nestjs-cls/setting-up-cls-context/using-a-decurator"}},l={},p=[],c={toc:p},u="wrapper";function d(e){let{components:t,...n}=e;return(0,o.kt)(u,(0,r.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"using-an-interceptor"},"Using an Interceptor"),(0,o.kt)("p",null,"Another place to initiate the CLS context is an ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsInterceptor"),", which, unlike the ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsGuard")," uses ",(0,o.kt)("inlineCode",{parentName:"p"},"AsyncLocalStorage#run")," method to wrap the following code, which is considered safer than ",(0,o.kt)("inlineCode",{parentName:"p"},"enterWith"),"."),(0,o.kt)("p",null,"To use it, pass its configuration to the ",(0,o.kt)("inlineCode",{parentName:"p"},"interceptor")," property to the ",(0,o.kt)("inlineCode",{parentName:"p"},"ClsModule.forRoot()")," options:"),(0,o.kt)("h1",{id:"automatically"},"Automatically"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="app.module.ts"',title:'"app.module.ts"'},"@Module({\n imports: [\n ClsModule.forRoot({\n // highlight-start\n interceptor: { mount: true },\n // highlight-end\n }),\n ],\n // ...\n})\nexport class AppModule {}\n")),(0,o.kt)("h1",{id:"manually"},"Manually"),(0,o.kt)("p",null,"Or mount it manually as ",(0,o.kt)("inlineCode",{parentName:"p"},"APP_INTERCEPTOR")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="app.module.ts"',title:'"app.module.ts"'},"@Module({\n imports: [\n ClsModule.forRoot({\n // highlight-start\n interceptor: { mount: false }\n // highlight-end\n }),\n ]\n providers: [\n {\n // highlight-start\n provide: APP_INTERCEPTOR,\n useClass: ClsGuard,\n // highlight-end\n },\n ],\n // ...\n})\nexport class AppModule {}\n")),(0,o.kt)("p",null,"or directly on the Controller/Resolver with:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-ts"},"@UseInterceptors(ClsInterceptor);\n")),(0,o.kt)("admonition",{type:"note"},(0,o.kt)("p",{parentName:"admonition"},(0,o.kt)("strong",{parentName:"p"},"Please note"),": Since Nest's ",(0,o.kt)("em",{parentName:"p"},"Interceptors")," run after ",(0,o.kt)("em",{parentName:"p"},"Guards"),", that means using this method makes CLS ",(0,o.kt)("strong",{parentName:"p"},"unavailable in Guards")," (and in case of REST Controllers, also in ",(0,o.kt)("strong",{parentName:"p"},"Exception Filters"),").")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/b67d68ed.2e3abcf2.js b/assets/js/b67d68ed.2e3abcf2.js new file mode 100644 index 0000000..9eb4746 --- /dev/null +++ b/assets/js/b67d68ed.2e3abcf2.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[241],{5575:(n,e,i)=>{i.r(e),i.d(e,{assets:()=>a,contentTitle:()=>r,default:()=>c,frontMatter:()=>s,metadata:()=>l,toc:()=>d});var t=i(4246),o=i(1670);const s={},r="Plugin API",l={id:"plugins/plugin-api",title:"Plugin API",description:"The Plugin API is still experimental and might change in the future, you should not rely on it in production.",source:"@site/docs/06_plugins/02_plugin-api.md",sourceDirName:"06_plugins",slug:"/plugins/plugin-api",permalink:"/nestjs-cls/plugins/plugin-api",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/06_plugins/02_plugin-api.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Creating a custom adapter",permalink:"/nestjs-cls/plugins/available-plugins/transactional/creating-custom-adapter"},next:{title:"Migration guide",permalink:"/nestjs-cls/migration-guide/"}},a={},d=[];function u(n){const e={admonition:"admonition",code:"code",em:"em",h1:"h1",p:"p",pre:"pre",...(0,o.a)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.h1,{id:"plugin-api",children:"Plugin API"}),"\n",(0,t.jsxs)(e.admonition,{type:"warning",children:[(0,t.jsx)(e.p,{children:"The Plugin API is still experimental and might change in the future, you should not rely on it in production."}),(0,t.jsx)(e.p,{children:'Using any of the "official" plugins is safe since they are maintained by the same author. If you want to create your own plugin, you should be aware that the API might change between minor versions.'})]}),"\n",(0,t.jsx)(e.p,{children:"A plugin is, in its core, a NestJS module with some extra options and should implement the following interface:"}),"\n",(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:"language-ts",children:"export interface ClsPlugin {\n /**\n * The name of the plugin, used for logging and debugging\n */\n name: string;\n\n /**\n * Function that is called within a Cls initializer (middleware, interceptor, guard, etc.)\n */\n onClsInit?: (cls: ClsService) => void | Promise ;\n\n /**\n * A lifecycle method called when the `ClsModule` is initialized\n */\n onModuleInit?: () => void | Promise ;\n\n /**\n * A lifecycle method called when the `ClsModule` is destroyed (only when shutdown hooks are enabled)\n */\n onModuleDestroy?: () => void | Promise ;\n\n /**\n * An array of external modules that should be imported for the plugin to work.\n */\n imports?: any[];\n\n /**\n * An array of providers that the plugin provides.\n */\n providers?: Provider[];\n\n /**\n * An array of providers that the plugin provides that should be exported.\n */\n exports?: any[];\n}\n"})}),"\n",(0,t.jsxs)(e.p,{children:["The plugin options are then mixed into a ",(0,t.jsx)(e.em,{children:"global"})," ",(0,t.jsx)(e.code,{children:"ClsPluginModule"})," and the exposed providers can be used for injection by other plugin-related code."]})]})}function c(n={}){const{wrapper:e}={...(0,o.a)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(u,{...n})}):u(n)}},1670:(n,e,i)=>{i.d(e,{Z:()=>l,a:()=>r});var t=i(7378);const o={},s=t.createContext(o);function r(n){const e=t.useContext(s);return t.useMemo((function(){return"function"==typeof n?n(e):{...e,...n}}),[e,n])}function l(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(o):n.components||o:r(n.components),t.createElement(s.Provider,{value:e},n.children)}}}]); \ No newline at end of file diff --git a/assets/js/b787da23.6d6bf314.js b/assets/js/b787da23.6d6bf314.js new file mode 100644 index 0000000..b845918 --- /dev/null +++ b/assets/js/b787da23.6d6bf314.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[126],{9622:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>o,contentTitle:()=>l,default:()=>a,frontMatter:()=>r,metadata:()=>c,toc:()=>d});var n=s(4246),i=s(1670);const r={},l="Compatibility",c={id:"considerations/compatibility",title:"Compatibility",description:"The table below outlines the compatibility with some platforms:",source:"@site/docs/05_considerations/02_compatibility.md",sourceDirName:"05_considerations",slug:"/considerations/compatibility",permalink:"/nestjs-cls/considerations/compatibility",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/05_considerations/02_compatibility.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Security",permalink:"/nestjs-cls/considerations/security"},next:{title:"Plugins",permalink:"/nestjs-cls/plugins/"}},o={},d=[{value:"REST",id:"rest",level:2},{value:"GraphQL",id:"graphql",level:2},{value:" @nestjs/graphql >= 10
",id:"nestjsgraphql--10",level:3},{value:"@nestjs/graphql < 10
",id:"nestjsgraphql--10-1",level:3},{value:"Others",id:"others",level:2},{value:"Websockets",id:"websockets",level:3}];function h(e){const t={a:"a",blockquote:"blockquote",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.a)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.h1,{id:"compatibility",children:"Compatibility"}),"\n",(0,n.jsx)(t.p,{children:"The table below outlines the compatibility with some platforms:"}),"\n",(0,n.jsxs)(t.table,{children:[(0,n.jsx)(t.thead,{children:(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.th,{style:{textAlign:"center"}}),(0,n.jsx)(t.th,{style:{textAlign:"center"},children:"REST"}),(0,n.jsx)(t.th,{style:{textAlign:"center"},children:"GQL"}),(0,n.jsxs)(t.th,{style:{textAlign:"center"},children:["WS",(0,n.jsx)(t.a,{href:"#websockets",children:"*"})]}),(0,n.jsx)(t.th,{style:{textAlign:"center"},children:"Microservices"})]})}),(0,n.jsxs)(t.tbody,{children:[(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"center"},children:(0,n.jsx)(t.strong,{children:"ClsMiddleware"})}),(0,n.jsx)(t.td,{style:{textAlign:"center"},children:"\u2714"}),(0,n.jsx)(t.td,{style:{textAlign:"center"},children:"\u2714"}),(0,n.jsx)(t.td,{style:{textAlign:"center"},children:"\u2716"}),(0,n.jsx)(t.td,{style:{textAlign:"center"},children:"\u2716"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsxs)(t.td,{style:{textAlign:"center"},children:[(0,n.jsx)(t.strong,{children:"ClsGuard"})," ",(0,n.jsx)("br",{}),"(uses ",(0,n.jsx)(t.code,{children:"enterWith"}),")"]}),(0,n.jsx)(t.td,{style:{textAlign:"center"},children:"\u2714"}),(0,n.jsx)(t.td,{style:{textAlign:"center"},children:"\u2714"}),(0,n.jsx)(t.td,{style:{textAlign:"center"},children:"\u2714"}),(0,n.jsx)(t.td,{style:{textAlign:"center"},children:"\u2714"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsxs)(t.td,{style:{textAlign:"center"},children:[(0,n.jsx)(t.strong,{children:"ClsInterceptor"})," ",(0,n.jsx)("br",{}),"(context inaccessible",(0,n.jsx)("br",{}),"in ",(0,n.jsx)(t.em,{children:"Guards"})," and",(0,n.jsx)("br",{})," in ",(0,n.jsx)(t.em,{children:"Exception Filters"}),")"]}),(0,n.jsx)(t.td,{style:{textAlign:"center"},children:"\u2714"}),(0,n.jsx)(t.td,{style:{textAlign:"center"},children:"\u2714"}),(0,n.jsx)(t.td,{style:{textAlign:"center"},children:"\u2714"}),(0,n.jsx)(t.td,{style:{textAlign:"center"},children:"\u2714"})]})]})]}),"\n",(0,n.jsx)(t.h2,{id:"rest",children:"REST"}),"\n",(0,n.jsxs)(t.p,{children:["This package is compatible with Nest-supported REST controllers and the preferred way is to use the ",(0,n.jsx)(t.code,{children:"ClsMiddleware"})," with the ",(0,n.jsx)(t.code,{children:"mount"})," option set to ",(0,n.jsx)(t.code,{children:"true"}),"."]}),"\n",(0,n.jsx)(t.p,{children:"Tested with:"}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsx)(t.li,{children:"\u2714 Express"}),"\n",(0,n.jsx)(t.li,{children:"\u2714 Fastify"}),"\n"]}),"\n",(0,n.jsx)(t.p,{children:"Known issues:"}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:["In case API versioning is used, the automatic mounting of the ",(0,n.jsx)(t.code,{children:"ClsMiddleware"})," does not work and it needs to be mounted manually. See issue ",(0,n.jsx)(t.a,{href:"https://github.com/Papooch/nestjs-cls/issues/67",children:"#67"})," for details."]}),"\n",(0,n.jsxs)(t.li,{children:["Some existing Express middlewares may cause context loss, if that happens, mount the ",(0,n.jsx)(t.code,{children:"ClsMiddleware"})," manually ",(0,n.jsx)(t.em,{children:"after"})," those offending ones (",(0,n.jsx)(t.a,{href:"https://github.com/Papooch/nestjs-cls/issues/50#issuecomment-1368162870",children:"#50"}),")"]}),"\n"]}),"\n",(0,n.jsx)(t.h2,{id:"graphql",children:"GraphQL"}),"\n",(0,n.jsx)(t.p,{children:"Using an interceptor or a guard may result in that enhancer triggering multiple times in case there are multiple queries in the GQL request."}),"\n",(0,n.jsxs)(t.p,{children:["Due to this, you should ensure that any operation on the CLS store within enhancers is ",(0,n.jsx)(t.em,{children:"idempotent"}),". This includes the ",(0,n.jsx)(t.code,{children:"setup"})," function. Therefore, it is advised to use the ",(0,n.jsx)(t.code,{children:"ClsService#setIfUndefined()"})," method."]}),"\n",(0,n.jsx)(t.p,{children:"Tested with:"}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsx)(t.li,{children:"\u2714 Apollo (Express)"}),"\n",(0,n.jsx)(t.li,{children:"\u2714 Mercurius (Fastify)"}),"\n"]}),"\n",(0,n.jsx)(t.h3,{id:"nestjsgraphql--10",children:(0,n.jsx)(t.code,{children:"@nestjs/graphql >= 10"})}),"\n",(0,n.jsxs)(t.p,{children:["Since v10, Nest's GraphQL resolvers are compatible with this package and the preferred way to initialize the CLS context is use the ",(0,n.jsx)(t.code,{children:"ClsMiddleware"})," with the ",(0,n.jsx)(t.code,{children:"mount"})," option."]}),"\n",(0,n.jsx)(t.h3,{id:"nestjsgraphql--10-1",children:(0,n.jsx)(t.code,{children:"@nestjs/graphql < 10"})}),"\n",(0,n.jsxs)(t.p,{children:["For older versions of graphql, the ",(0,n.jsx)(t.code,{children:"ClsMiddleware"})," needs to be ",(0,n.jsx)(t.a,{href:"/nestjs-cls/setting-up-cls-context/using-a-middleware#manually",children:"mounted manually"})," with ",(0,n.jsx)(t.code,{children:"app.use(...)"})," in order to correctly set up the context for resolvers. Additionally, you have to pass ",(0,n.jsx)(t.code,{children:"useEnterWith: true"})," to the ",(0,n.jsx)(t.code,{children:"ClsMiddleware"})," options, because the context gets lost otherwise due to ",(0,n.jsx)(t.a,{href:"https://github.com/apollographql/apollo-server/issues/2042",children:"an issue with CLS and Apollo"})," (sadly, the same is true for ",(0,n.jsx)(t.a,{href:"https://github.com/Papooch/nestjs-cls/issues/1",children:"Mercurius"}),"). This method is functionally identical to just using the ",(0,n.jsx)(t.code,{children:"ClsGuard"}),"."]}),"\n",(0,n.jsxs)(t.p,{children:["Alternatively, you can use the ",(0,n.jsx)(t.code,{children:"ClsInterceptor"}),", which uses the safer ",(0,n.jsx)(t.code,{children:"AsyncLocalStorage#run"})," (thanks to ",(0,n.jsx)(t.a,{href:"https://github.com/Papooch/nestjs-cls/issues/5",children:"andreialecu"}),"), but remember that using it makes CLS unavailable in ",(0,n.jsx)(t.em,{children:"Guards"}),"."]}),"\n",(0,n.jsx)(t.h2,{id:"others",children:"Others"}),"\n",(0,n.jsxs)(t.p,{children:["Use the ",(0,n.jsx)(t.code,{children:"ClsGuard"})," or ",(0,n.jsx)(t.code,{children:"ClsInterceptor"})," to set up context with any other platform."]}),"\n",(0,n.jsx)(t.p,{children:"There are no explicit test for other transports, so I can't guarantee it will work with your platform of choice, but there's nothing that would indicate otherwise."}),"\n",(0,n.jsxs)(t.blockquote,{children:["\n",(0,n.jsxs)(t.p,{children:["If you decide to try this package with a platform that is not listed here, ",(0,n.jsx)(t.strong,{children:"please let me know"})," so I can add the compatibility notice."]}),"\n"]}),"\n",(0,n.jsx)(t.p,{children:"Below are listed transports with which it is confirmed to work:"}),"\n",(0,n.jsx)(t.h3,{id:"websockets",children:"Websockets"}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.em,{children:"Websocket Gateways"})," don't respect globally bound enhancers, therefore it is required to bind the ",(0,n.jsx)(t.code,{children:"ClsGuard"})," or ",(0,n.jsx)(t.code,{children:"ClsInterceptor"})," manually on the ",(0,n.jsx)(t.code,{children:"WebsocketGateway"}),". Special care is also needed for the ",(0,n.jsx)(t.code,{children:"handleConnection"})," method (See ",(0,n.jsx)(t.a,{href:"https://github.com/Papooch/nestjs-cls/issues/8",children:"#8"}),")"]})]})}function a(e={}){const{wrapper:t}={...(0,i.a)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(h,{...e})}):h(e)}},1670:(e,t,s)=>{s.d(t,{Z:()=>c,a:()=>l});var n=s(7378);const i={},r=n.createContext(i);function l(e){const t=n.useContext(r);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),n.createElement(r.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/b787da23.d6a197ad.js b/assets/js/b787da23.d6a197ad.js deleted file mode 100755 index 0b229f9..0000000 --- a/assets/js/b787da23.d6a197ad.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[126],{5318:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>h});var r=n(7378);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var s=r.createContext({}),p=function(e){var t=r.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=p(e.components);return r.createElement(s.Provider,{value:t},e.children)},d="mdxType",u={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},m=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,i=e.originalType,s=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),d=p(n),m=a,h=d["".concat(s,".").concat(m)]||d[m]||u[m]||i;return n?r.createElement(h,o(o({ref:t},c),{},{components:n})):r.createElement(h,o({ref:t},c))}));function h(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var i=n.length,o=new Array(i);o[0]=m;var l={};for(var s in t)hasOwnProperty.call(t,s)&&(l[s]=t[s]);l.originalType=e,l[d]="string"==typeof e?e:a,o[1]=l;for(var p=2;p{n.r(t),n.d(t,{assets:()=>s,contentTitle:()=>o,default:()=>u,frontMatter:()=>i,metadata:()=>l,toc:()=>p});var r=n(5773),a=(n(7378),n(5318));const i={},o="Compatibility",l={unversionedId:"considerations/compatibility",id:"considerations/compatibility",title:"Compatibility",description:"The table below outlines the compatibility with some platforms:",source:"@site/docs/05_considerations/02_compatibility.md",sourceDirName:"05_considerations",slug:"/considerations/compatibility",permalink:"/nestjs-cls/considerations/compatibility",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/05_considerations/02_compatibility.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Security",permalink:"/nestjs-cls/considerations/security"},next:{title:"Migration guide",permalink:"/nestjs-cls/migration-guide/"}},s={},p=[{value:"REST",id:"rest",level:2},{value:"GraphQL",id:"graphql",level:2},{value:" @nestjs/graphql >= 10
",id:"nestjsgraphql--10",level:3},{value:"@nestjs/graphql < 10
",id:"nestjsgraphql--10-1",level:3},{value:"Others",id:"others",level:2},{value:"Websockets",id:"websockets",level:3}],c={toc:p},d="wrapper";function u(e){let{components:t,...n}=e;return(0,a.kt)(d,(0,r.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("h1",{id:"compatibility"},"Compatibility"),(0,a.kt)("p",null,"The table below outlines the compatibility with some platforms:"),(0,a.kt)("table",null,(0,a.kt)("thead",{parentName:"table"},(0,a.kt)("tr",{parentName:"thead"},(0,a.kt)("th",{parentName:"tr",align:"center"}),(0,a.kt)("th",{parentName:"tr",align:"center"},"REST"),(0,a.kt)("th",{parentName:"tr",align:"center"},"GQL"),(0,a.kt)("th",{parentName:"tr",align:"center"},"WS",(0,a.kt)("a",{parentName:"th",href:"#websockets"},"*")),(0,a.kt)("th",{parentName:"tr",align:"center"},"Microservices"))),(0,a.kt)("tbody",{parentName:"table"},(0,a.kt)("tr",{parentName:"tbody"},(0,a.kt)("td",{parentName:"tr",align:"center"},(0,a.kt)("strong",{parentName:"td"},"ClsMiddleware")),(0,a.kt)("td",{parentName:"tr",align:"center"},"\u2714"),(0,a.kt)("td",{parentName:"tr",align:"center"},"\u2714"),(0,a.kt)("td",{parentName:"tr",align:"center"},"\u2716"),(0,a.kt)("td",{parentName:"tr",align:"center"},"\u2716")),(0,a.kt)("tr",{parentName:"tbody"},(0,a.kt)("td",{parentName:"tr",align:"center"},(0,a.kt)("strong",{parentName:"td"},"ClsGuard")," ",(0,a.kt)("br",null),"(uses ",(0,a.kt)("inlineCode",{parentName:"td"},"enterWith"),")"),(0,a.kt)("td",{parentName:"tr",align:"center"},"\u2714"),(0,a.kt)("td",{parentName:"tr",align:"center"},"\u2714"),(0,a.kt)("td",{parentName:"tr",align:"center"},"\u2714"),(0,a.kt)("td",{parentName:"tr",align:"center"},"\u2714")),(0,a.kt)("tr",{parentName:"tbody"},(0,a.kt)("td",{parentName:"tr",align:"center"},(0,a.kt)("strong",{parentName:"td"},"ClsInterceptor")," ",(0,a.kt)("br",null),"(context inaccessible",(0,a.kt)("br",null),"in ",(0,a.kt)("em",{parentName:"td"},"Guards")," and",(0,a.kt)("br",null)," in ",(0,a.kt)("em",{parentName:"td"},"Exception Filters"),")"),(0,a.kt)("td",{parentName:"tr",align:"center"},"\u2714"),(0,a.kt)("td",{parentName:"tr",align:"center"},"\u2714"),(0,a.kt)("td",{parentName:"tr",align:"center"},"\u2714"),(0,a.kt)("td",{parentName:"tr",align:"center"},"\u2714")))),(0,a.kt)("h2",{id:"rest"},"REST"),(0,a.kt)("p",null,"This package is compatible with Nest-supported REST controllers and the preferred way is to use the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsMiddleware")," with the ",(0,a.kt)("inlineCode",{parentName:"p"},"mount")," option set to ",(0,a.kt)("inlineCode",{parentName:"p"},"true"),"."),(0,a.kt)("p",null,"Tested with:"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},"\u2714 Express"),(0,a.kt)("li",{parentName:"ul"},"\u2714 Fastify")),(0,a.kt)("p",null,"Known issues:"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},"In case API versioning is used, the automatic mounting of the ",(0,a.kt)("inlineCode",{parentName:"li"},"ClsMiddleware")," does not work and it needs to be mounted manually. See issue ",(0,a.kt)("a",{parentName:"li",href:"https://github.com/Papooch/nestjs-cls/issues/67"},"#67")," for details."),(0,a.kt)("li",{parentName:"ul"},"Some existing Express middlewares may cause context loss, if that happens, mount the ",(0,a.kt)("inlineCode",{parentName:"li"},"ClsMiddleware")," manually ",(0,a.kt)("em",{parentName:"li"},"after")," those offending ones (",(0,a.kt)("a",{parentName:"li",href:"https://github.com/Papooch/nestjs-cls/issues/50#issuecomment-1368162870"},"#50"),")")),(0,a.kt)("h2",{id:"graphql"},"GraphQL"),(0,a.kt)("p",null,"Using an interceptor or a guard may result in that enhancer triggering multiple times in case there are multiple queries in the GQL request."),(0,a.kt)("p",null,"Due to this, you should ensure that any operation on the CLS store within enhancers is ",(0,a.kt)("em",{parentName:"p"},"idempotent"),". This includes the ",(0,a.kt)("inlineCode",{parentName:"p"},"setup")," function. Therefore, it is advised to use the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsService#setIfUndefined()")," method."),(0,a.kt)("p",null,"Tested with:"),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},"\u2714 Apollo (Express)"),(0,a.kt)("li",{parentName:"ul"},"\u2714 Mercurius (Fastify)")),(0,a.kt)("h3",{id:"nestjsgraphql--10"},(0,a.kt)("inlineCode",{parentName:"h3"},"@nestjs/graphql >= 10")),(0,a.kt)("p",null,"Since v10, Nest's GraphQL resolvers are compatible with this package and the preferred way to initialize the CLS context is use the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsMiddleware")," with the ",(0,a.kt)("inlineCode",{parentName:"p"},"mount")," option."),(0,a.kt)("h3",{id:"nestjsgraphql--10-1"},(0,a.kt)("inlineCode",{parentName:"h3"},"@nestjs/graphql < 10")),(0,a.kt)("p",null,"For older versions of graphql, the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsMiddleware")," needs to be ",(0,a.kt)("a",{parentName:"p",href:"/nestjs-cls/setting-up-cls-context/using-a-middleware#manually"},"mounted manually")," with ",(0,a.kt)("inlineCode",{parentName:"p"},"app.use(...)")," in order to correctly set up the context for resolvers. Additionally, you have to pass ",(0,a.kt)("inlineCode",{parentName:"p"},"useEnterWith: true")," to the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsMiddleware")," options, because the context gets lost otherwise due to ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/apollographql/apollo-server/issues/2042"},"an issue with CLS and Apollo")," (sadly, the same is true for ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/Papooch/nestjs-cls/issues/1"},"Mercurius"),"). This method is functionally identical to just using the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsGuard"),"."),(0,a.kt)("p",null,"Alternatively, you can use the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsInterceptor"),", which uses the safer ",(0,a.kt)("inlineCode",{parentName:"p"},"AsyncLocalStorage#run")," (thanks to ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/Papooch/nestjs-cls/issues/5"},"andreialecu"),"), but remember that using it makes CLS unavailable in ",(0,a.kt)("em",{parentName:"p"},"Guards"),"."),(0,a.kt)("h2",{id:"others"},"Others"),(0,a.kt)("p",null,"Use the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsGuard")," or ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsInterceptor")," to set up context with any other platform."),(0,a.kt)("p",null,"There are no explicit test for other transports, so I can't guarantee it will work with your platform of choice, but there's nothing that would indicate otherwise."),(0,a.kt)("blockquote",null,(0,a.kt)("p",{parentName:"blockquote"},"If you decide to try this package with a platform that is not listed here, ",(0,a.kt)("strong",{parentName:"p"},"please let me know")," so I can add the compatibility notice.")),(0,a.kt)("p",null,"Below are listed transports with which it is confirmed to work:"),(0,a.kt)("h3",{id:"websockets"},"Websockets"),(0,a.kt)("p",null,(0,a.kt)("em",{parentName:"p"},"Websocket Gateways")," don't respect globally bound enhancers, therefore it is required to bind the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsGuard")," or ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsInterceptor")," manually on the ",(0,a.kt)("inlineCode",{parentName:"p"},"WebsocketGateway"),". Special care is also needed for the ",(0,a.kt)("inlineCode",{parentName:"p"},"handleConnection")," method (See ",(0,a.kt)("a",{parentName:"p",href:"https://github.com/Papooch/nestjs-cls/issues/8"},"#8"),")"))}u.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/baa2f4d8.57f99fd1.js b/assets/js/baa2f4d8.57f99fd1.js new file mode 100644 index 0000000..2c452e3 --- /dev/null +++ b/assets/js/baa2f4d8.57f99fd1.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[423],{8711:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>u,frontMatter:()=>s,metadata:()=>d,toc:()=>a});var r=t(4246),o=t(1670);const s={},i="v2.x \u2192 v3.x",d={id:"migration-guide/v2x-v3x",title:"v2.x \u2192 v3.x",description:"Root registration method renamed",source:"@site/docs/10_migration-guide/02_v2x-v3x.md",sourceDirName:"10_migration-guide",slug:"/migration-guide/v2x-v3x",permalink:"/nestjs-cls/migration-guide/v2x-v3x",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/10_migration-guide/02_v2x-v3x.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"v3.x \u2192 v4.x",permalink:"/nestjs-cls/migration-guide/v3x-v4x"}},c={},a=[{value:"Root registration method renamed",id:"root-registration-method-renamed",level:2},{value:"Namespace support dropped",id:"namespace-support-dropped",level:2}];function l(e){const n={a:"a",br:"br",code:"code",em:"em",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",ul:"ul",...(0,o.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(n.h1,{id:"v2x--v3x",children:[(0,r.jsx)(n.code,{children:"v2.x"})," \u2192 ",(0,r.jsx)(n.code,{children:"v3.x"})]}),"\n",(0,r.jsx)(n.h2,{id:"root-registration-method-renamed",children:"Root registration method renamed"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["The root registration method was ",(0,r.jsx)(n.em,{children:"renamed"})," from ",(0,r.jsx)(n.code,{children:"register"})," (resp. ",(0,r.jsx)(n.code,{children:"registerAsync"}),") to ",(0,r.jsx)(n.code,{children:"forRoot"})," (resp. ",(0,r.jsx)(n.code,{children:"forRootAsync"}),") to align with the convention."]}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-diff",children:"// highlight-start\n- ClsModule.register({\n+ ClsModule.forRoot({\n// highlight-end\n middleware: { mount: true },\n }),\n"})}),"\n",(0,r.jsx)(n.h2,{id:"namespace-support-dropped",children:"Namespace support dropped"}),"\n",(0,r.jsxs)(n.p,{children:["Namespace injection support with ",(0,r.jsx)(n.code,{children:"forFeature"})," was dropped entirely, and now that method is used to register ",(0,r.jsx)(n.a,{href:"/nestjs-cls/features-and-use-cases/proxy-providers",children:"Proxy Providers"}),". If you still have a use case for namespaces, you can create a namespaced ",(0,r.jsx)(n.code,{children:"ClsService"})," and use a custom provider to inject it.",(0,r.jsx)(n.br,{}),"\n","Example:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-ts",children:"class MyContextService extends ClsService{}\nconst myContextService = new MyContextService(new AsyncLocalStorage());\n\n// [...]\nproviders: [\n {\n provide: MyContextService,\n useValue: myContextService,\n },\n];\n"})})]})}function u(e={}){const{wrapper:n}={...(0,o.a)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(l,{...e})}):l(e)}},1670:(e,n,t)=>{t.d(n,{Z:()=>d,a:()=>i});var r=t(7378);const o={},s=r.createContext(o);function i(e){const n=r.useContext(s);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function d(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),r.createElement(s.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/d459cca2.2e06c629.js b/assets/js/d459cca2.2e06c629.js deleted file mode 100755 index 328d6df..0000000 --- a/assets/js/d459cca2.2e06c629.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[47],{5318:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>g});var r=n(7378);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t =0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var l=r.createContext({}),u=function(e){var t=r.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):s(s({},t),e)),n},c=function(e){var t=u(e.components);return r.createElement(l.Provider,{value:t},e.children)},p="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},m=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,o=e.originalType,l=e.parentName,c=i(e,["components","mdxType","originalType","parentName"]),p=u(n),m=a,g=p["".concat(l,".").concat(m)]||p[m]||d[m]||o;return n?r.createElement(g,s(s({ref:t},c),{},{components:n})):r.createElement(g,s({ref:t},c))}));function g(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=n.length,s=new Array(o);s[0]=m;var i={};for(var l in t)hasOwnProperty.call(t,l)&&(i[l]=t[l]);i.originalType=e,i[p]="string"==typeof e?e:a,s[1]=i;for(var u=2;u {n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>s,default:()=>d,frontMatter:()=>o,metadata:()=>i,toc:()=>u});var r=n(5773),a=(n(7378),n(5318));const o={},s="Using a Guard",i={unversionedId:"setting-up-cls-context/using-a-guard",id:"setting-up-cls-context/using-a-guard",title:"Using a Guard",description:'The ClsGuard can be also used set up the CLS context. While it is not a "guard" per-se, it\'s the second best place to set up the CLS context, since after a middleware, it is the first piece of code that the request hits.',source:"@site/docs/02_setting-up-cls-context/02_using-a-guard.md",sourceDirName:"02_setting-up-cls-context",slug:"/setting-up-cls-context/using-a-guard",permalink:"/nestjs-cls/setting-up-cls-context/using-a-guard",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/02_setting-up-cls-context/02_using-a-guard.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Using a Middleware",permalink:"/nestjs-cls/setting-up-cls-context/using-a-middleware"},next:{title:"Using an Interceptor",permalink:"/nestjs-cls/setting-up-cls-context/using-an-interceptor"}},l={},u=[{value:"Automatically",id:"automatically",level:2},{value:"Manually",id:"manually",level:2}],c={toc:u},p="wrapper";function d(e){let{components:t,...n}=e;return(0,a.kt)(p,(0,r.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("h1",{id:"using-a-guard"},"Using a Guard"),(0,a.kt)("p",null,"The ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsGuard"),' can be also used set up the CLS context. While it is not a "guard" per-se, it\'s the second best place to set up the CLS context, since after a middleware, it is the first piece of code that the request hits.'),(0,a.kt)("p",null,"To use it, pass its configuration to the ",(0,a.kt)("inlineCode",{parentName:"p"},"guard")," property to the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsModule.forRoot()")," options:"),(0,a.kt)("h2",{id:"automatically"},"Automatically"),(0,a.kt)("p",null,"Use ",(0,a.kt)("inlineCode",{parentName:"p"},"mount: true")),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="app.module.ts"',title:'"app.module.ts"'},"@Module({\n imports: [\n ClsModule.forRoot({\n // highlight-start\n guard: { mount: true },\n // highlight-end\n }),\n ],\n // ...\n})\nexport class AppModule {}\n")),(0,a.kt)("h2",{id:"manually"},"Manually"),(0,a.kt)("p",null,"If you need any other guards to use the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsService"),", it's preferable to mount ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsGuard")," manually as the first guard in the root module:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="app.module.ts"',title:'"app.module.ts"'},"@Module({\n imports: [\n ClsModule.forRoot({\n // highlight-start\n guard: { mount: false }\n // highlight-end\n }),\n ]\n providers: [\n {\n // highlight-start\n provide: APP_GUARD,\n useClass: ClsGuard,\n // highlight-end\n },\n ],\n // ...\n})\nexport class AppModule {}\n")),(0,a.kt)("p",null,"or mount it directly on the Controller/Resolver with"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},"@UseGuards(ClsGuard);\n")),(0,a.kt)("admonition",{type:"caution"},(0,a.kt)("p",{parentName:"admonition"},(0,a.kt)("strong",{parentName:"p"},"Please note"),": since the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsGuard")," uses the ",(0,a.kt)("inlineCode",{parentName:"p"},"AsyncLocalStorage#enterWith")," method, using the ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsGuard")," comes with some ",(0,a.kt)("a",{parentName:"p",href:"/nestjs-cls/considerations/security"},"security considerations"),"!")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/d459cca2.51d3b722.js b/assets/js/d459cca2.51d3b722.js new file mode 100644 index 0000000..76a64e3 --- /dev/null +++ b/assets/js/d459cca2.51d3b722.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[47],{2041:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>r,default:()=>u,frontMatter:()=>o,metadata:()=>a,toc:()=>l});var s=n(4246),i=n(1670);const o={},r="Using a Guard",a={id:"setting-up-cls-context/using-a-guard",title:"Using a Guard",description:'The ClsGuard can be also used set up the CLS context. While it is not a "guard" per-se, it\'s the second best place to set up the CLS context, since after a middleware, it is the first piece of code that the request hits.',source:"@site/docs/02_setting-up-cls-context/02_using-a-guard.md",sourceDirName:"02_setting-up-cls-context",slug:"/setting-up-cls-context/using-a-guard",permalink:"/nestjs-cls/setting-up-cls-context/using-a-guard",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/02_setting-up-cls-context/02_using-a-guard.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Using a Middleware",permalink:"/nestjs-cls/setting-up-cls-context/using-a-middleware"},next:{title:"Using an Interceptor",permalink:"/nestjs-cls/setting-up-cls-context/using-an-interceptor"}},c={},l=[{value:"Automatically",id:"automatically",level:2},{value:"Manually",id:"manually",level:2}];function d(e){const t={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",p:"p",pre:"pre",strong:"strong",...(0,i.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h1,{id:"using-a-guard",children:"Using a Guard"}),"\n",(0,s.jsxs)(t.p,{children:["The ",(0,s.jsx)(t.code,{children:"ClsGuard"}),' can be also used set up the CLS context. While it is not a "guard" per-se, it\'s the second best place to set up the CLS context, since after a middleware, it is the first piece of code that the request hits.']}),"\n",(0,s.jsxs)(t.p,{children:["To use it, pass its configuration to the ",(0,s.jsx)(t.code,{children:"guard"})," property to the ",(0,s.jsx)(t.code,{children:"ClsModule.forRoot()"})," options:"]}),"\n",(0,s.jsx)(t.h2,{id:"automatically",children:"Automatically"}),"\n",(0,s.jsxs)(t.p,{children:["Use ",(0,s.jsx)(t.code,{children:"mount: true"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",metastring:'title="app.module.ts"',children:"@Module({\n imports: [\n ClsModule.forRoot({\n // highlight-start\n guard: { mount: true },\n // highlight-end\n }),\n ],\n // ...\n})\nexport class AppModule {}\n"})}),"\n",(0,s.jsx)(t.h2,{id:"manually",children:"Manually"}),"\n",(0,s.jsxs)(t.p,{children:["If you need any other guards to use the ",(0,s.jsx)(t.code,{children:"ClsService"}),", it's preferable to mount ",(0,s.jsx)(t.code,{children:"ClsGuard"})," manually as the first guard in the root module:"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",metastring:'title="app.module.ts"',children:"@Module({\n imports: [\n ClsModule.forRoot({\n // highlight-start\n guard: { mount: false }\n // highlight-end\n }),\n ]\n providers: [\n {\n // highlight-start\n provide: APP_GUARD,\n useClass: ClsGuard,\n // highlight-end\n },\n ],\n // ...\n})\nexport class AppModule {}\n"})}),"\n",(0,s.jsx)(t.p,{children:"or mount it directly on the Controller/Resolver with"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"@UseGuards(ClsGuard);\n"})}),"\n",(0,s.jsx)(t.admonition,{type:"caution",children:(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"Please note"}),": since the ",(0,s.jsx)(t.code,{children:"ClsGuard"})," uses the ",(0,s.jsx)(t.code,{children:"AsyncLocalStorage#enterWith"})," method, using the ",(0,s.jsx)(t.code,{children:"ClsGuard"})," comes with some ",(0,s.jsx)(t.a,{href:"/nestjs-cls/considerations/security",children:"security considerations"}),"!"]})})]})}function u(e={}){const{wrapper:t}={...(0,i.a)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},1670:(e,t,n)=>{n.d(t,{Z:()=>a,a:()=>r});var s=n(7378);const i={},o=s.createContext(i);function r(e){const t=s.useContext(o);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:r(e.components),s.createElement(o.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/df604e10.30be9c5a.js b/assets/js/df604e10.30be9c5a.js deleted file mode 100755 index 7a6599e..0000000 --- a/assets/js/df604e10.30be9c5a.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[775],{5318:(e,t,n)=>{n.d(t,{Zo:()=>s,kt:()=>d});var a=n(7378);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t =0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var l=a.createContext({}),m=function(e){var t=a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},s=function(e){var t=m(e.components);return a.createElement(l.Provider,{value:t},e.children)},c="mdxType",k={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},N=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,l=e.parentName,s=p(e,["components","mdxType","originalType","parentName"]),c=m(n),N=r,d=c["".concat(l,".").concat(N)]||c[N]||k[N]||i;return n?a.createElement(d,o(o({ref:t},s),{},{components:n})):a.createElement(d,o({ref:t},s))}));function d(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,o=new Array(i);o[0]=N;var p={};for(var l in t)hasOwnProperty.call(t,l)&&(p[l]=t[l]);p.originalType=e,p[c]="string"==typeof e?e:r,o[1]=p;for(var m=2;m{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>o,default:()=>k,frontMatter:()=>i,metadata:()=>p,toc:()=>m});var a=n(5773),r=(n(7378),n(5318));const i={},o="Service Interface",p={unversionedId:"api/service-interface",id:"api/service-interface",title:"Service Interface",description:"ClsService",source:"@site/docs/04_api/01_service-interface.md",sourceDirName:"04_api",slug:"/api/service-interface",permalink:"/nestjs-cls/api/service-interface",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/04_api/01_service-interface.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"API",permalink:"/nestjs-cls/api/"},next:{title:"Module Options",permalink:"/nestjs-cls/api/module-options"}},l={},m=[{value:"ClsService",id:"clsservice",level:2},{value:"ClsContextOptions",id:"clscontextoptions",level:2}],s={toc:m},c="wrapper";function k(e){let{components:t,...n}=e;return(0,r.kt)(c,(0,a.Z)({},s,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h1",{id:"service-interface"},"Service Interface"),(0,r.kt)("h2",{id:"clsservice"},"ClsService"),(0,r.kt)("p",null,"The injectable ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsService")," provides the following API to manipulate the cls context:"),(0,r.kt)("p",null,"The ",(0,r.kt)("inlineCode",{parentName:"p"},"S")," type parameter is used as the type of custom ",(0,r.kt)("inlineCode",{parentName:"p"},"ClsStore"),"."),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"get"))),(0,r.kt)("inlineCode",{parentName:"p"},"(): S"),(0,r.kt)("br",{parentName:"p"}),"\n","Get the entire CLS context.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"get"))),(0,r.kt)("inlineCode",{parentName:"p"},"(key?: keyof S): S[key]"),(0,r.kt)("br",{parentName:"p"}),"\n","Retrieve a value from the CLS context by key.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"getId"))),(0,r.kt)("inlineCode",{parentName:"p"},"(): string;"),(0,r.kt)("br",{parentName:"p"}),"\n","Retrieve the request ID (a shorthand for ",(0,r.kt)("inlineCode",{parentName:"p"},"cls.get(CLS_ID)"),")")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"has"))),(0,r.kt)("inlineCode",{parentName:"p"},"(key: keyof S): boolean"),(0,r.kt)("br",{parentName:"p"}),"\n","Check if a key is in the CLS context.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"set"))),(0,r.kt)("inlineCode",{parentName:"p"},"(key: keyof S, value: S[key]): void"),(0,r.kt)("br",{parentName:"p"}),"\n","Set a value on the CLS context.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"setIfUndefined"))),(0,r.kt)("inlineCode",{parentName:"p"},"(key: keyof S, value: S[key]): void"),(0,r.kt)("br",{parentName:"p"}),"\n","Set a value on the CLS context ",(0,r.kt)("em",{parentName:"p"},"only")," if it hasn't been already set. Useful for ensuring idempotence if you have multiple entry points.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"run"))),(0,r.kt)("inlineCode",{parentName:"p"},"(callback: () => T): T"),(0,r.kt)("br",{parentName:"p"}),"\n",(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"run"))),(0,r.kt)("inlineCode",{parentName:"p"},"(options: ClsContextOptions, callback: () => T): T;"),(0,r.kt)("br",{parentName:"p"}),"\n","Run the callback in a shared CLS context. Optionally takes an ",(0,r.kt)("a",{parentName:"p",href:"#clscontextoptions"},"options object")," as the first parameter.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"runWith"))),(0,r.kt)("inlineCode",{parentName:"p"},"(store: S, callback: () => T): T"),(0,r.kt)("br",{parentName:"p"}),"\n","Run the callback in a new CLS context (while supplying the default store).")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"enter"))),(0,r.kt)("inlineCode",{parentName:"p"},"(): void;"),(0,r.kt)("br",{parentName:"p"}),"\n",(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"enter"))),(0,r.kt)("inlineCode",{parentName:"p"},"(options: ClsContextOptions): void"),(0,r.kt)("br",{parentName:"p"}),"\n","Run any following code in a shared CLS context. Optionally takes an ",(0,r.kt)("a",{parentName:"p",href:"#clscontextoptions"},"options object")," as the first parameter.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"enterWith"))),(0,r.kt)("inlineCode",{parentName:"p"},"(store: S): void"),(0,r.kt)("br",{parentName:"p"}),"\n","Run any following code in a new CLS context (while supplying the default store).")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"exit"))),(0,r.kt)("inlineCode",{parentName:"p"},"(callback: () => T): T"),(0,r.kt)("br",{parentName:"p"}),"\n","Run the callback ",(0,r.kt)("em",{parentName:"p"},"without")," access to a shared CLS context.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"isActive"))),(0,r.kt)("inlineCode",{parentName:"p"},"(): boolean"),(0,r.kt)("br",{parentName:"p"}),"\n","Whether the current code runs within an active CLS context.")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},(0,r.kt)("strong",{parentName:"p"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"resolveProxyProviders"))),(0,r.kt)("inlineCode",{parentName:"p"},"(): Promise "),(0,r.kt)("br",{parentName:"p"}),"\n","Manually trigger resolution of Proxy Providers."))),(0,r.kt)("h2",{id:"clscontextoptions"},"ClsContextOptions"),(0,r.kt)("p",null,"The ",(0,r.kt)("inlineCode",{parentName:"p"},"run")," and ",(0,r.kt)("inlineCode",{parentName:"p"},"enter")," methods can take an additional options object with the following settings:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("strong",{parentName:"li"},(0,r.kt)("em",{parentName:"strong"},(0,r.kt)("inlineCode",{parentName:"em"},"ifNested?:")))," ",(0,r.kt)("inlineCode",{parentName:"li"},"'override' | 'inherit' | 'reuse'"),(0,r.kt)("br",{parentName:"li"}),"Sets the behavior of nested CLS context creation in case the method is invoked in an existing context. It has no effect if no parent context exist.",(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"override")," (default) - Run the callback with an new empty context.",(0,r.kt)("br",{parentName:"li"}),"No values from the parent context will be accessible within the wrapped code."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"inherit")," - Run the callback with a shallow copy of the parent context.",(0,r.kt)("br",{parentName:"li"}),"Re-assignments of top-level properties will not be reflected in the parent context. However, modifications of existing properties ",(0,r.kt)("em",{parentName:"li"},"will")," be reflected."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"reuse")," - Reuse existing context without creating a new one. All modifications to the existing context will be reflected.")))))}k.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/df604e10.c9ad986f.js b/assets/js/df604e10.c9ad986f.js new file mode 100644 index 0000000..33aa3cd --- /dev/null +++ b/assets/js/df604e10.c9ad986f.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[775],{1763:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>o,contentTitle:()=>t,default:()=>x,frontMatter:()=>r,metadata:()=>l,toc:()=>d});var i=s(4246),c=s(1670);const r={},t="Service Interface",l={id:"api/service-interface",title:"Service Interface",description:"ClsService",source:"@site/docs/04_api/01_service-interface.md",sourceDirName:"04_api",slug:"/api/service-interface",permalink:"/nestjs-cls/api/service-interface",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/04_api/01_service-interface.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"API",permalink:"/nestjs-cls/api/"},next:{title:"Module Options",permalink:"/nestjs-cls/api/module-options"}},o={},d=[{value:"ClsService",id:"clsservice",level:2},{value:"ClsContextOptions",id:"clscontextoptions",level:2}];function h(e){const n={a:"a",br:"br",code:"code",em:"em",h1:"h1",h2:"h2",li:"li",p:"p",strong:"strong",ul:"ul",...(0,c.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.h1,{id:"service-interface",children:"Service Interface"}),"\n",(0,i.jsx)(n.h2,{id:"clsservice",children:"ClsService"}),"\n",(0,i.jsxs)(n.p,{children:["The injectable ",(0,i.jsx)(n.code,{children:"ClsService"})," provides the following API to manipulate the cls context:"]}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"S"})," type parameter is used as the type of custom ",(0,i.jsx)(n.code,{children:"ClsStore"}),"."]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"get"})})}),(0,i.jsx)(n.code,{children:"(): S"}),(0,i.jsx)(n.br,{}),"\n","Get the entire CLS context."]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"get"})})}),(0,i.jsx)(n.code,{children:"(key?: keyof S): S[key]"}),(0,i.jsx)(n.br,{}),"\n","Retrieve a value from the CLS context by key."]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"getId"})})}),(0,i.jsx)(n.code,{children:"(): string;"}),(0,i.jsx)(n.br,{}),"\n","Retrieve the request ID (a shorthand for ",(0,i.jsx)(n.code,{children:"cls.get(CLS_ID)"}),")"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"has"})})}),(0,i.jsx)(n.code,{children:"(key: keyof S): boolean"}),(0,i.jsx)(n.br,{}),"\n","Check if a key is in the CLS context."]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"set"})})}),(0,i.jsx)(n.code,{children:"(key: keyof S, value: S[key]): void"}),(0,i.jsx)(n.br,{}),"\n","Set a value on the CLS context."]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"setIfUndefined"})})}),(0,i.jsx)(n.code,{children:"(key: keyof S, value: S[key]): void"}),(0,i.jsx)(n.br,{}),"\n","Set a value on the CLS context ",(0,i.jsx)(n.em,{children:"only"})," if it hasn't been already set. Useful for ensuring idempotence if you have multiple entry points."]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"run"})})}),(0,i.jsx)(n.code,{children:"(callback: () => T): T"}),(0,i.jsx)(n.br,{}),"\n",(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"run"})})}),(0,i.jsx)(n.code,{children:"(options: ClsContextOptions, callback: () => T): T;"}),(0,i.jsx)(n.br,{}),"\n","Run the callback in a shared CLS context. Optionally takes an ",(0,i.jsx)(n.a,{href:"#clscontextoptions",children:"options object"})," as the first parameter."]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"runWith"})})}),(0,i.jsx)(n.code,{children:"(store: S, callback: () => T): T"}),(0,i.jsx)(n.br,{}),"\n","Run the callback in a new CLS context (while supplying the default store)."]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"enter"})})}),(0,i.jsx)(n.code,{children:"(): void;"}),(0,i.jsx)(n.br,{}),"\n",(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"enter"})})}),(0,i.jsx)(n.code,{children:"(options: ClsContextOptions): void"}),(0,i.jsx)(n.br,{}),"\n","Run any following code in a shared CLS context. Optionally takes an ",(0,i.jsx)(n.a,{href:"#clscontextoptions",children:"options object"})," as the first parameter."]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"enterWith"})})}),(0,i.jsx)(n.code,{children:"(store: S): void"}),(0,i.jsx)(n.br,{}),"\n","Run any following code in a new CLS context (while supplying the default store)."]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"exit"})})}),(0,i.jsx)(n.code,{children:"(callback: () => T): T"}),(0,i.jsx)(n.br,{}),"\n","Run the callback ",(0,i.jsx)(n.em,{children:"without"})," access to a shared CLS context."]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"isActive"})})}),(0,i.jsx)(n.code,{children:"(): boolean"}),(0,i.jsx)(n.br,{}),"\n","Whether the current code runs within an active CLS context."]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"resolveProxyProviders"})})}),(0,i.jsx)(n.code,{children:"(): Promise "}),(0,i.jsx)(n.br,{}),"\n","Manually trigger resolution of Proxy Providers."]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"initializePlugins"})})}),(0,i.jsx)(n.code,{children:"(): Promise "}),(0,i.jsx)(n.br,{}),"\n","Manually trigger ",(0,i.jsx)(n.code,{children:"onClsInit"})," hooks of registered plugins."]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"clscontextoptions",children:"ClsContextOptions"}),"\n",(0,i.jsxs)(n.p,{children:["The ",(0,i.jsx)(n.code,{children:"run"})," and ",(0,i.jsx)(n.code,{children:"enter"})," methods can take an additional options object with the following settings:"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.strong,{children:(0,i.jsx)(n.em,{children:(0,i.jsx)(n.code,{children:"ifNested?:"})})}),(0,i.jsx)(n.code,{children:"'inherit' | 'reuse' | 'override'"}),(0,i.jsx)(n.br,{}),"\n","Sets the behavior of nested CLS context creation in case the method is invoked in an existing context. It has no effect if no parent context exist.","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"inherit"})," (default) - Run the callback with a shallow copy of the parent context.",(0,i.jsx)(n.br,{}),"\n","Re-assignments of top-level properties will not be reflected in the parent context. However, modifications of existing properties ",(0,i.jsx)(n.em,{children:"will"})," be reflected."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"reuse"})," - Reuse existing context without creating a new one. All modifications to the\nexisting context will be reflected."]}),"\n",(0,i.jsxs)(n.li,{children:[(0,i.jsx)(n.code,{children:"override"})," - Run the callback with an new empty context.",(0,i.jsx)(n.br,{}),"\n","No values from the parent context will be accessible within the wrapped code."]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"::: Note"}),"\n",(0,i.jsxs)(n.p,{children:["Until ",(0,i.jsx)(n.code,{children:"v4"}),", the default behavior was ",(0,i.jsx)(n.code,{children:"override"}),". This was changed to ",(0,i.jsx)(n.code,{children:"inherit"})," since ",(0,i.jsx)(n.code,{children:"v4"})," to make the behavior more intuitive."]}),"\n",(0,i.jsx)(n.p,{children:":::"})]})}function x(e={}){const{wrapper:n}={...(0,c.a)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},1670:(e,n,s)=>{s.d(n,{Z:()=>l,a:()=>t});var i=s(7378);const c={},r=i.createContext(c);function t(e){const n=i.useContext(r);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:t(e.components),i.createElement(r.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/e2112352.413a0485.js b/assets/js/e2112352.413a0485.js new file mode 100644 index 0000000..ce331c7 --- /dev/null +++ b/assets/js/e2112352.413a0485.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[826],{1267:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>r,contentTitle:()=>i,default:()=>p,frontMatter:()=>a,metadata:()=>c,toc:()=>o});var t=s(4246),l=s(1670);const a={},i="Available Plugins",c={id:"plugins/available-plugins/index",title:"Available Plugins",description:"This section lists all plugins that are maintained by the author of nestjs-cls. They are all published under the @nestjs-cls scope and are kept up to date with any changes to the library.",source:"@site/docs/06_plugins/01_available-plugins/index.md",sourceDirName:"06_plugins/01_available-plugins",slug:"/plugins/available-plugins/",permalink:"/nestjs-cls/plugins/available-plugins/",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/06_plugins/01_available-plugins/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Plugins",permalink:"/nestjs-cls/plugins/"},next:{title:"@nestjs-cls/transactional",permalink:"/nestjs-cls/plugins/available-plugins/transactional/"}},r={},o=[];function u(e){const n={a:"a",code:"code",h1:"h1",li:"li",p:"p",ul:"ul",...(0,l.a)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.h1,{id:"available-plugins",children:"Available Plugins"}),"\n",(0,t.jsxs)(n.p,{children:["This section lists all plugins that are maintained by the author of ",(0,t.jsx)(n.code,{children:"nestjs-cls"}),". They are all published under the ",(0,t.jsx)(n.code,{children:"@nestjs-cls"})," scope and are kept up to date with any changes to the library."]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsx)(n.li,{children:(0,t.jsx)(n.a,{href:"/nestjs-cls/plugins/available-plugins/transactional/",children:"Transactional"})}),"\n"]})]})}function p(e={}){const{wrapper:n}={...(0,l.a)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(u,{...e})}):u(e)}},1670:(e,n,s)=>{s.d(n,{Z:()=>c,a:()=>i});var t=s(7378);const l={},a=t.createContext(l);function i(e){const n=t.useContext(a);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:i(e.components),t.createElement(a.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/e83b8e0a.c7551c54.js b/assets/js/e83b8e0a.c7551c54.js new file mode 100644 index 0000000..1c9dd90 --- /dev/null +++ b/assets/js/e83b8e0a.c7551c54.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[446],{5834:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>r,contentTitle:()=>a,default:()=>d,frontMatter:()=>t,metadata:()=>o,toc:()=>c});var i=s(4246),l=s(1670);const t={},a="Plugins",o={id:"plugins/index",title:"Plugins",description:"Since v4.0",source:"@site/docs/06_plugins/index.md",sourceDirName:"06_plugins",slug:"/plugins/",permalink:"/nestjs-cls/plugins/",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/06_plugins/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Compatibility",permalink:"/nestjs-cls/considerations/compatibility"},next:{title:"Available Plugins",permalink:"/nestjs-cls/plugins/available-plugins/"}},r={},c=[{value:"Usage",id:"usage",level:2},{value:"Available plugins",id:"available-plugins",level:2},{value:"Creating a plugin",id:"creating-a-plugin",level:2}];function u(e){const n={a:"a",code:"code",em:"em",h1:"h1",h2:"h2",p:"p",pre:"pre",strong:"strong",...(0,l.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.h1,{id:"plugins",children:"Plugins"}),"\n",(0,i.jsx)("small",{children:(0,i.jsxs)(n.strong,{children:["Since ",(0,i.jsx)(n.code,{children:"v4.0"})]})}),"\n",(0,i.jsx)(n.p,{children:"Plugins are a way to enable pre-built integrations with other libraries and frameworks. They are a convenient way to enable many real-world use-cases without having to write much boilerplate code."}),"\n",(0,i.jsxs)(n.p,{children:["Plugins can hook into the lifecycle of the ",(0,i.jsx)(n.code,{children:"ClsModule"})," and the CLS context setup of the ",(0,i.jsx)(n.code,{children:"Cls-"})," initializers. They can also provide their own ",(0,i.jsx)(n.em,{children:"Proxy-"})," and regular providers to be used in the application."]}),"\n",(0,i.jsx)(n.h2,{id:"usage",children:"Usage"}),"\n",(0,i.jsxs)(n.p,{children:["To use a plugin, pass it to the ",(0,i.jsx)(n.code,{children:"forRoot"})," method of the ",(0,i.jsx)(n.code,{children:"ClsModule"}),":"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ts",children:"ClsModule.forRoot({\n // highlight-start\n plugins: [new MyPlugin()],\n // highlight-end\n});\n"})}),"\n",(0,i.jsx)(n.h2,{id:"available-plugins",children:"Available plugins"}),"\n",(0,i.jsxs)(n.p,{children:["For a list of plugins managed by the author of ",(0,i.jsx)(n.code,{children:"nestjs-cls"}),", see the ",(0,i.jsx)(n.a,{href:"/nestjs-cls/plugins/available-plugins/",children:"Available Plugins"})," page."]}),"\n",(0,i.jsx)(n.h2,{id:"creating-a-plugin",children:"Creating a plugin"}),"\n",(0,i.jsxs)(n.p,{children:["To create a custom plugin, see the ",(0,i.jsx)(n.a,{href:"/nestjs-cls/plugins/plugin-api",children:"Plugin API"})," reference."]})]})}function d(e={}){const{wrapper:n}={...(0,l.a)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(u,{...e})}):u(e)}},1670:(e,n,s)=>{s.d(n,{Z:()=>o,a:()=>a});var i=s(7378);const l={},t=i.createContext(l);function a(e){const n=i.useContext(t);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:a(e.components),i.createElement(t.Provider,{value:n},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/eb9c95da.97b9461c.js b/assets/js/eb9c95da.97b9461c.js new file mode 100644 index 0000000..7adf786 --- /dev/null +++ b/assets/js/eb9c95da.97b9461c.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[715],{8258:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>a,contentTitle:()=>c,default:()=>h,frontMatter:()=>r,metadata:()=>i,toc:()=>d});var s=n(4246),o=n(1670);const r={},c="Using a Decorator",i={id:"setting-up-cls-context/using-a-decorator",title:"Using a Decorator",description:"The @UseCls() decorator can be used at a method level to declaratively wrap the method with a cls.run() call. This method should only be used outside of the context of a web request.",source:"@site/docs/02_setting-up-cls-context/04_using-a-decorator.md",sourceDirName:"02_setting-up-cls-context",slug:"/setting-up-cls-context/using-a-decorator",permalink:"/nestjs-cls/setting-up-cls-context/using-a-decorator",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/02_setting-up-cls-context/04_using-a-decorator.md",tags:[],version:"current",sidebarPosition:4,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Using an Interceptor",permalink:"/nestjs-cls/setting-up-cls-context/using-an-interceptor"},next:{title:"Using the ClsService Instance",permalink:"/nestjs-cls/setting-up-cls-context/using_cls_run"}},a={},d=[];function l(e){const t={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",p:"p",pre:"pre",...(0,o.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h1,{id:"using-a-decorator",children:"Using a Decorator"}),"\n",(0,s.jsxs)(t.p,{children:["The ",(0,s.jsx)(t.code,{children:"@UseCls()"})," decorator can be used at a method level to declaratively wrap the method with a ",(0,s.jsx)(t.code,{children:"cls.run()"})," call. This method should only be used ",(0,s.jsx)(t.a,{href:"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request",children:"outside of the context of a web request"}),"."]}),"\n",(0,s.jsx)(t.admonition,{type:"info",children:(0,s.jsxs)(t.p,{children:["Please keep in mind, that since the CLS context initialization ",(0,s.jsx)(t.em,{children:"can"})," be async, the ",(0,s.jsx)(t.code,{children:"@UseCls()"})," decorator can ",(0,s.jsx)(t.em,{children:"only"})," be used on ",(0,s.jsx)(t.em,{children:"async"})," function (those that return a ",(0,s.jsx)(t.code,{children:"Promise"}),")."]})}),"\n",(0,s.jsxs)(t.p,{children:["Since there is no request, the ",(0,s.jsx)(t.code,{children:"setup"})," function will not receive a ",(0,s.jsx)(t.code,{children:"Request"})," object. Instead, it will receive the ",(0,s.jsx)(t.code,{children:"this"})," context of the class instance (this also applies to the ",(0,s.jsx)(t.code,{children:"idGenerator"}),"), the ",(0,s.jsx)(t.code,{children:"ClsService"})," reference and all the arguments passed to the decorated method."]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"@Injectable()\nclass SomeService {\n constructor(\n private readonly cls: ClsService,\n private readonly otherService: OtherService,\n ) {}\n\n @UseCls<[string]>({\n generateId: true,\n // highlight-start\n idGenerator: function (this: SomeService) {\n return this.generateId();\n },\n setup: function (this: SomeService, cls: ClsService, value: string) {\n cls.set('some-key', 'some-value');\n },\n // highlight-end\n })\n async startContextualWorkflow(value: string) {\n return this.otherService.doSomething(value);\n }\n\n private generateId() {\n return Math.random();\n }\n}\n"})}),"\n",(0,s.jsx)(t.admonition,{type:"warning",children:(0,s.jsxs)(t.p,{children:["It is important to define the ",(0,s.jsx)(t.code,{children:"setup"})," and ",(0,s.jsx)(t.code,{children:"idGenerator"})," functions as ",(0,s.jsx)(t.code,{children:"function"}),"s, not arrow functions, so that the ",(0,s.jsx)(t.code,{children:"this"})," context is properly bound."]})})]})}function h(e={}){const{wrapper:t}={...(0,o.a)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(l,{...e})}):l(e)}},1670:(e,t,n)=>{n.d(t,{Z:()=>i,a:()=>c});var s=n(7378);const o={},r=s.createContext(o);function c(e){const t=s.useContext(r);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:c(e.components),s.createElement(r.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/eca1a52a.c89c6ab1.js b/assets/js/eca1a52a.c89c6ab1.js deleted file mode 100755 index 3da4bbe..0000000 --- a/assets/js/eca1a52a.c89c6ab1.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[873],{5318:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>m});var r=n(7378);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function a(e){for(var t=1;t =0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var l=r.createContext({}),c=function(e){var t=r.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):a(a({},t),e)),n},p=function(e){var t=c(e.components);return r.createElement(l.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},h=r.forwardRef((function(e,t){var n=e.components,i=e.mdxType,o=e.originalType,l=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),u=c(n),h=i,m=u["".concat(l,".").concat(h)]||u[h]||d[h]||o;return n?r.createElement(m,a(a({ref:t},p),{},{components:n})):r.createElement(m,a({ref:t},p))}));function m(e,t){var n=arguments,i=t&&t.mdxType;if("string"==typeof e||i){var o=n.length,a=new Array(o);a[0]=h;var s={};for(var l in t)hasOwnProperty.call(t,l)&&(s[l]=t[l]);s.originalType=e,s[u]="string"==typeof e?e:i,a[1]=s;for(var c=2;c {n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>a,default:()=>d,frontMatter:()=>o,metadata:()=>s,toc:()=>c});var r=n(5773),i=(n(7378),n(5318));const o={},a="Quick Start",s={unversionedId:"introduction/quick-start",id:"introduction/quick-start",title:"Quick Start",description:"Background",source:"@site/docs/01_introduction/02_quick-start.md",sourceDirName:"01_introduction",slug:"/introduction/quick-start",permalink:"/nestjs-cls/introduction/quick-start",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/01_introduction/02_quick-start.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Installation",permalink:"/nestjs-cls/introduction/installation"},next:{title:"How it works",permalink:"/nestjs-cls/introduction/how-it-works"}},l={},c=[{value:"Background",id:"background",level:2},{value:"Example",id:"example",level:2},{value:"Register the ClsModule",id:"register-the-clsmodule",level:3},{value:"Create IP-address interceptor",id:"create-ip-address-interceptor",level:3},{value:"Mount interceptor to controller",id:"mount-interceptor-to-controller",level:3},{value:"Access CLS context in service",id:"access-cls-context-in-service",level:3},{value:"That's it",id:"thats-it",level:3}],p={toc:c},u="wrapper";function d(e){let{components:t,...n}=e;return(0,i.kt)(u,(0,r.Z)({},p,n,{components:t,mdxType:"MDXLayout"}),(0,i.kt)("h1",{id:"quick-start"},"Quick Start"),(0,i.kt)("h2",{id:"background"},"Background"),(0,i.kt)("p",null,"This library exposes a dynamic ",(0,i.kt)("inlineCode",{parentName:"p"},"ClsModule")," which exposes the injectable ",(0,i.kt)("inlineCode",{parentName:"p"},"ClsService")," and provides means to setting up and interacting with the CLS context."),(0,i.kt)("p",null,"The CLS context is a storage that wraps around a chain of function calls. It can be accessed anywhere during the lifecycle of such chain via the ",(0,i.kt)("inlineCode",{parentName:"p"},"ClsService"),"."),(0,i.kt)("h2",{id:"example"},"Example"),(0,i.kt)("p",null,"Below is an example of using this library to store the client's IP address in an interceptor and retrieving it in a service without explicitly passing it along."),(0,i.kt)("admonition",{type:"note"},(0,i.kt)("p",{parentName:"admonition"},"This example assumes you are using HTTP and therefore can use middleware. For usage with non-HTTP transports, see ",(0,i.kt)("a",{parentName:"p",href:"/nestjs-cls/setting-up-cls-context/"},"Setting up CLS context"),".")),(0,i.kt)("h3",{id:"register-the-clsmodule"},"Register the ClsModule"),(0,i.kt)("p",null,"Register the ",(0,i.kt)("inlineCode",{parentName:"p"},"ClsModule")," and automatically mount the ",(0,i.kt)("inlineCode",{parentName:"p"},"ClsMiddleware")," which wraps the entire request in a shared CLS context on all routes."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="app.module.ts"',title:'"app.module.ts"'},"@Module({\n imports: [\n // highlight-start\n ClsModule.forRoot({\n global: true,\n middleware: { mount: true },\n }),\n // highlight-end\n ],\n providers: [AppService],\n controllers: [AppController],\n})\nexport class AppModule {}\n")),(0,i.kt)("h3",{id:"create-ip-address-interceptor"},"Create IP-address interceptor"),(0,i.kt)("p",null,"Create an interceptor that"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"injects the ",(0,i.kt)("inlineCode",{parentName:"li"},"ClsService")," to get access to the current shared CLS context,"),(0,i.kt)("li",{parentName:"ul"},"extract the users's IP address from the request and stores it into the CLS context,")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="user-ip.interceptor.ts"',title:'"user-ip.interceptor.ts"'},"@Injectable()\nexport class UserIpInterceptor implements NestInterceptor {\n // highlight-start\n constructor(private readonly cls: ClsService) {}\n // highlight-end\n\n intercept(context: ExecutionContext, next: CallHandler): Observable {\n const request = context.switchToHttp().getRequest();\n const userIp = request.connection.remoteAddress;\n // highlight-start\n this.cls.set('ip', userIp);\n // highlight-end\n return next.handle();\n }\n}\n")),(0,i.kt)("h3",{id:"mount-interceptor-to-controller"},"Mount interceptor to controller"),(0,i.kt)("p",null,"By mounting the ",(0,i.kt)("inlineCode",{parentName:"p"},"UserIpInterceptor")," on the controller, it gets access to the same shared CLS context that the ",(0,i.kt)("inlineCode",{parentName:"p"},"ClsMiddleware")," set up."),(0,i.kt)("p",null,"Of course, we could also bind the interceptor globally with ",(0,i.kt)("inlineCode",{parentName:"p"},"APP_INTERCEPTOR"),"."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="app.controller.ts"',title:'"app.controller.ts"'},"// highlight-start\n@UseInterceptors(UserIpInterceptor)\n// highlight-end\n@Injectable()\nexport class AppController {\n constructor(private readonly appService: AppService) {}\n\n @Get('/hello')\n hello() {\n return this.appService.sayHello();\n }\n}\n")),(0,i.kt)("h3",{id:"access-cls-context-in-service"},"Access CLS context in service"),(0,i.kt)("p",null,"In the ",(0,i.kt)("inlineCode",{parentName:"p"},"AppService"),", we can retrieve the user's IP from the CLS context without explicitly passing in anything, and without making the ",(0,i.kt)("inlineCode",{parentName:"p"},"AppService")," request-scoped!"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="app.service.ts"',title:'"app.service.ts"'},"@Injectable()\nexport class AppService {\n // highlight-start\n constructor(private readonly cls: ClsService) {}\n // highlight-end\n\n sayHello() {\n // highlight-start\n const userIp = this.cls.get('ip');\n // highlight-end\n return 'Hello ' + userIp + '!';\n }\n}\n")),(0,i.kt)("h3",{id:"thats-it"},"That's it"),(0,i.kt)("p",null,"This is pretty much all there is to it. This library further provides more quality-of-life features, so read on!"),(0,i.kt)("admonition",{type:"info"},(0,i.kt)("p",{parentName:"admonition"},"If your use-case is really simple, you can instead consider ",(0,i.kt)("a",{parentName:"p",href:"https://docs.nestjs.com/recipes/async-local-storage#custom-implementation"},"creating a custom implementation with ",(0,i.kt)("inlineCode",{parentName:"a"},"AsyncLocalStorage")),". Limiting the number of dependencies in your application is always a good idea!")))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/eca1a52a.cbfb27da.js b/assets/js/eca1a52a.cbfb27da.js new file mode 100644 index 0000000..3cda456 --- /dev/null +++ b/assets/js/eca1a52a.cbfb27da.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[873],{5638:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>c,default:()=>h,frontMatter:()=>i,metadata:()=>o,toc:()=>a});var s=n(4246),r=n(1670);const i={},c="Quick Start",o={id:"introduction/quick-start",title:"Quick Start",description:"Background",source:"@site/docs/01_introduction/02_quick-start.md",sourceDirName:"01_introduction",slug:"/introduction/quick-start",permalink:"/nestjs-cls/introduction/quick-start",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/01_introduction/02_quick-start.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Installation",permalink:"/nestjs-cls/introduction/installation"},next:{title:"How it works",permalink:"/nestjs-cls/introduction/how-it-works"}},l={},a=[{value:"Background",id:"background",level:2},{value:"Example",id:"example",level:2},{value:"Register the ClsModule",id:"register-the-clsmodule",level:3},{value:"Create IP-address interceptor",id:"create-ip-address-interceptor",level:3},{value:"Mount interceptor to controller",id:"mount-interceptor-to-controller",level:3},{value:"Access CLS context in service",id:"access-cls-context-in-service",level:3},{value:"That's it",id:"thats-it",level:3}];function d(e){const t={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",ul:"ul",...(0,r.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h1,{id:"quick-start",children:"Quick Start"}),"\n",(0,s.jsx)(t.h2,{id:"background",children:"Background"}),"\n",(0,s.jsxs)(t.p,{children:["This library exposes a dynamic ",(0,s.jsx)(t.code,{children:"ClsModule"})," which exposes the injectable ",(0,s.jsx)(t.code,{children:"ClsService"})," and provides means to setting up and interacting with the CLS context."]}),"\n",(0,s.jsxs)(t.p,{children:["The CLS context is a storage that wraps around a chain of function calls. It can be accessed anywhere during the lifecycle of such chain via the ",(0,s.jsx)(t.code,{children:"ClsService"}),"."]}),"\n",(0,s.jsx)(t.h2,{id:"example",children:"Example"}),"\n",(0,s.jsx)(t.p,{children:"Below is an example of using this library to store the client's IP address in an interceptor and retrieving it in a service without explicitly passing it along."}),"\n",(0,s.jsx)(t.admonition,{type:"note",children:(0,s.jsxs)(t.p,{children:["This example assumes you are using HTTP and therefore can use middleware. For usage with non-HTTP transports, see ",(0,s.jsx)(t.a,{href:"/nestjs-cls/setting-up-cls-context/",children:"Setting up CLS context"}),"."]})}),"\n",(0,s.jsx)(t.h3,{id:"register-the-clsmodule",children:"Register the ClsModule"}),"\n",(0,s.jsxs)(t.p,{children:["Register the ",(0,s.jsx)(t.code,{children:"ClsModule"})," and automatically mount the ",(0,s.jsx)(t.code,{children:"ClsMiddleware"})," which wraps the entire request in a shared CLS context on all routes."]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",metastring:'title="app.module.ts"',children:"@Module({\n imports: [\n // highlight-start\n ClsModule.forRoot({\n global: true,\n middleware: { mount: true },\n }),\n // highlight-end\n ],\n providers: [AppService],\n controllers: [AppController],\n})\nexport class AppModule {}\n"})}),"\n",(0,s.jsx)(t.h3,{id:"create-ip-address-interceptor",children:"Create IP-address interceptor"}),"\n",(0,s.jsx)(t.p,{children:"Create an interceptor that"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:["injects the ",(0,s.jsx)(t.code,{children:"ClsService"})," to get access to the current shared CLS context,"]}),"\n",(0,s.jsx)(t.li,{children:"extract the users's IP address from the request and stores it into the CLS context,"}),"\n"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",metastring:'title="user-ip.interceptor.ts"',children:"@Injectable()\nexport class UserIpInterceptor implements NestInterceptor {\n // highlight-start\n constructor(private readonly cls: ClsService) {}\n // highlight-end\n\n intercept(context: ExecutionContext, next: CallHandler): Observable {\n const request = context.switchToHttp().getRequest();\n const userIp = request.connection.remoteAddress;\n // highlight-start\n this.cls.set('ip', userIp);\n // highlight-end\n return next.handle();\n }\n}\n"})}),"\n",(0,s.jsx)(t.h3,{id:"mount-interceptor-to-controller",children:"Mount interceptor to controller"}),"\n",(0,s.jsxs)(t.p,{children:["By mounting the ",(0,s.jsx)(t.code,{children:"UserIpInterceptor"})," on the controller, it gets access to the same shared CLS context that the ",(0,s.jsx)(t.code,{children:"ClsMiddleware"})," set up."]}),"\n",(0,s.jsxs)(t.p,{children:["Of course, we could also bind the interceptor globally with ",(0,s.jsx)(t.code,{children:"APP_INTERCEPTOR"}),"."]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",metastring:'title="app.controller.ts"',children:"// highlight-start\n@UseInterceptors(UserIpInterceptor)\n// highlight-end\n@Injectable()\nexport class AppController {\n constructor(private readonly appService: AppService) {}\n\n @Get('/hello')\n hello() {\n return this.appService.sayHello();\n }\n}\n"})}),"\n",(0,s.jsx)(t.h3,{id:"access-cls-context-in-service",children:"Access CLS context in service"}),"\n",(0,s.jsxs)(t.p,{children:["In the ",(0,s.jsx)(t.code,{children:"AppService"}),", we can retrieve the user's IP from the CLS context without explicitly passing in anything, and without making the ",(0,s.jsx)(t.code,{children:"AppService"})," request-scoped!"]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",metastring:'title="app.service.ts"',children:"@Injectable()\nexport class AppService {\n // highlight-start\n constructor(private readonly cls: ClsService) {}\n // highlight-end\n\n sayHello() {\n // highlight-start\n const userIp = this.cls.get('ip');\n // highlight-end\n return 'Hello ' + userIp + '!';\n }\n}\n"})}),"\n",(0,s.jsx)(t.h3,{id:"thats-it",children:"That's it"}),"\n",(0,s.jsx)(t.p,{children:"This is pretty much all there is to it. This library further provides more quality-of-life features, so read on!"}),"\n",(0,s.jsx)(t.admonition,{type:"info",children:(0,s.jsxs)(t.p,{children:["If your use-case is really simple, you can instead consider ",(0,s.jsxs)(t.a,{href:"https://docs.nestjs.com/recipes/async-local-storage#custom-implementation",children:["creating a custom implementation with ",(0,s.jsx)(t.code,{children:"AsyncLocalStorage"})]}),". Limiting the number of dependencies in your application is always a good idea!"]})})]})}function h(e={}){const{wrapper:t}={...(0,r.a)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},1670:(e,t,n)=>{n.d(t,{Z:()=>o,a:()=>c});var s=n(7378);const r={},i=s.createContext(r);function c(e){const t=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:c(e.components),s.createElement(i.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/ef9f7d37.246c8683.js b/assets/js/ef9f7d37.246c8683.js deleted file mode 100755 index 623e2d0..0000000 --- a/assets/js/ef9f7d37.246c8683.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[990],{5318:(e,t,r)=>{r.d(t,{Zo:()=>l,kt:()=>m});var n=r(7378);function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t =0||(s[r]=e[r]);return s}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n =0||Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}var i=n.createContext({}),u=function(e){var t=n.useContext(i),r=t;return e&&(r="function"==typeof e?e(t):o(o({},t),e)),r},l=function(e){var t=u(e.components);return n.createElement(i.Provider,{value:t},e.children)},p="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},f=n.forwardRef((function(e,t){var r=e.components,s=e.mdxType,a=e.originalType,i=e.parentName,l=c(e,["components","mdxType","originalType","parentName"]),p=u(r),f=s,m=p["".concat(i,".").concat(f)]||p[f]||d[f]||a;return r?n.createElement(m,o(o({ref:t},l),{},{components:r})):n.createElement(m,o({ref:t},l))}));function m(e,t){var r=arguments,s=t&&t.mdxType;if("string"==typeof e||s){var a=r.length,o=new Array(a);o[0]=f;var c={};for(var i in t)hasOwnProperty.call(t,i)&&(c[i]=t[i]);c.originalType=e,c[p]="string"==typeof e?e:s,o[1]=c;for(var u=2;u{r.r(t),r.d(t,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>a,metadata:()=>c,toc:()=>u});var n=r(5773),s=(r(7378),r(5318));const a={},o="Features and use cases",c={unversionedId:"features-and-use-cases/index",id:"features-and-use-cases/index",title:"Features and use cases",description:"In addition to the basic functionality described in the Quick start chapter, this module provides several other features to make your life as a developer easier.",source:"@site/docs/03_features-and-use-cases/index.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/",permalink:"/nestjs-cls/features-and-use-cases/",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Using a Decorator",permalink:"/nestjs-cls/setting-up-cls-context/using-a-decurator"},next:{title:"Request ID",permalink:"/nestjs-cls/features-and-use-cases/request-id"}},i={},u=[],l={toc:u},p="wrapper";function d(e){let{components:t,...r}=e;return(0,s.kt)(p,(0,n.Z)({},l,r,{components:t,mdxType:"MDXLayout"}),(0,s.kt)("h1",{id:"features-and-use-cases"},"Features and use cases"),(0,s.kt)("p",null,"In addition to the basic functionality described in the ",(0,s.kt)("a",{parentName:"p",href:"/nestjs-cls/introduction/quick-start"},"Quick start")," chapter, this module provides several other features to make your life as a developer easier."))}d.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/ef9f7d37.a21a56ab.js b/assets/js/ef9f7d37.a21a56ab.js new file mode 100644 index 0000000..f7f2401 --- /dev/null +++ b/assets/js/ef9f7d37.a21a56ab.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[990],{2098:(e,s,t)=>{t.r(s),t.d(s,{assets:()=>o,contentTitle:()=>c,default:()=>l,frontMatter:()=>r,metadata:()=>i,toc:()=>u});var n=t(4246),a=t(1670);const r={},c="Features and use cases",i={id:"features-and-use-cases/index",title:"Features and use cases",description:"In addition to the basic functionality described in the Quick start chapter, this module provides several other features to make your life as a developer easier.",source:"@site/docs/03_features-and-use-cases/index.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/",permalink:"/nestjs-cls/features-and-use-cases/",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/index.md",tags:[],version:"current",frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Using the ClsService Instance",permalink:"/nestjs-cls/setting-up-cls-context/using_cls_run"},next:{title:"Request ID",permalink:"/nestjs-cls/features-and-use-cases/request-id"}},o={},u=[];function d(e){const s={a:"a",h1:"h1",p:"p",...(0,a.a)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(s.h1,{id:"features-and-use-cases",children:"Features and use cases"}),"\n",(0,n.jsxs)(s.p,{children:["In addition to the basic functionality described in the ",(0,n.jsx)(s.a,{href:"/nestjs-cls/introduction/quick-start",children:"Quick start"})," chapter, this module provides several other features to make your life as a developer easier."]})]})}function l(e={}){const{wrapper:s}={...(0,a.a)(),...e.components};return s?(0,n.jsx)(s,{...e,children:(0,n.jsx)(d,{...e})}):d(e)}},1670:(e,s,t)=>{t.d(s,{Z:()=>i,a:()=>c});var n=t(7378);const a={},r=n.createContext(a);function c(e){const s=n.useContext(r);return n.useMemo((function(){return"function"==typeof e?e(s):{...s,...e}}),[s,e])}function i(e){let s;return s=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:c(e.components),n.createElement(r.Provider,{value:s},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/1cd7469c.a8f155a8.js b/assets/js/effe0ec2.1d686911.js old mode 100755 new mode 100644 similarity index 66% rename from assets/js/1cd7469c.a8f155a8.js rename to assets/js/effe0ec2.1d686911.js index 025ee25..376affd --- a/assets/js/1cd7469c.a8f155a8.js +++ b/assets/js/effe0ec2.1d686911.js @@ -1 +1 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[665],{3769:s=>{s.exports=JSON.parse('{"name":"docusaurus-plugin-content-docs","id":"default"}')}}]); \ No newline at end of file +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[378],{3769:s=>{s.exports=JSON.parse('{"name":"docusaurus-plugin-content-docs","id":"default"}')}}]); \ No newline at end of file diff --git a/assets/js/f83e606a.14966a77.js b/assets/js/f83e606a.14966a77.js new file mode 100644 index 0000000..26a822a --- /dev/null +++ b/assets/js/f83e606a.14966a77.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[104],{8472:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>c,contentTitle:()=>a,default:()=>u,frontMatter:()=>o,metadata:()=>i,toc:()=>d});var n=s(4246),r=s(1670);const o={},a="Request ID",i={id:"features-and-use-cases/request-id",title:"Request ID",description:"Because of a shared storage, CLS is an ideal tool for tracking request (correlation) IDs for the purpose of logging. This package provides an option to automatically generate request IDs in the middleware/guard/interceptor, if you pass { generateId: true } to its options. By default, the generated ID is a string based on Math.random(), but you can provide a custom function in the idGenerator option.",source:"@site/docs/03_features-and-use-cases/01_request-id.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/request-id",permalink:"/nestjs-cls/features-and-use-cases/request-id",draft:!1,unlisted:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/01_request-id.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Features and use cases",permalink:"/nestjs-cls/features-and-use-cases/"},next:{title:"Additional CLS Setup",permalink:"/nestjs-cls/features-and-use-cases/additional-cls-setup"}},c={},d=[];function l(e){const t={code:"code",h1:"h1",p:"p",pre:"pre",...(0,r.a)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.h1,{id:"request-id",children:"Request ID"}),"\n",(0,n.jsxs)(t.p,{children:["Because of a shared storage, CLS is an ideal tool for tracking request (correlation) IDs for the purpose of logging. This package provides an option to automatically generate request IDs in the middleware/guard/interceptor, if you pass ",(0,n.jsx)(t.code,{children:"{ generateId: true }"})," to its options. By default, the generated ID is a string based on ",(0,n.jsx)(t.code,{children:"Math.random()"}),", but you can provide a custom function in the ",(0,n.jsx)(t.code,{children:"idGenerator"})," option."]}),"\n",(0,n.jsxs)(t.p,{children:["This function receives the ",(0,n.jsx)(t.code,{children:"Request"})," (or ",(0,n.jsx)(t.code,{children:"ExecutionContext"})," in case a ",(0,n.jsx)(t.code,{children:"ClsGuard"})," is used) as the first parameter, which can be used in the generation process and should return (or resolve with) a string ID that will be stored in the CLS for later use."]}),"\n",(0,n.jsx)(t.p,{children:"Below is an example of retrieving the request ID from the request header with a fallback to an autogenerated one."}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-ts",children:"ClsModule.forRoot({\n middleware: {\n mount: true,\n // highlight-start\n generateId: true,\n idGenerator: (req: Request) =>\n req.headers['X-Request-Id'] ?? uuid();\n // highlight-end\n }\n})\n"})}),"\n",(0,n.jsxs)(t.p,{children:["The ID is stored under the ",(0,n.jsx)(t.code,{children:"CLS_ID"})," constant in the context. The ",(0,n.jsx)(t.code,{children:"ClsService"})," provides a shorthand method ",(0,n.jsx)(t.code,{children:"getId"})," to quickly retrieve it anywhere. It can be for example used in a custom logger:"]}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-ts",metastring:'title="my.logger.ts"',children:"@Injectable()\nclass MyLogger {\n constructor(private readonly cls: ClsService) {}\n\n log(message: string) {\n // highlight-start\n console.log(`<${this.cls.getId()}> ${message}`);\n // highlight-end\n }\n}\n"})}),"\n",(0,n.jsx)(t.p,{children:"Calling this from anywhere within a CLS context results in retrieving the ID:"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-ts",metastring:'title="my.service.ts"',children:"@Injectable()\nclass MyService {\n constructor(private readonly logger: MyLogger);\n\n hello() {\n this.logger.log('Hello');\n // -> logs for ex.: \"<44c2d8ff-49a6-4244-869f-75a2df11517a> Hello\"\n }\n}\n"})})]})}function u(e={}){const{wrapper:t}={...(0,r.a)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(l,{...e})}):l(e)}},1670:(e,t,s)=>{s.d(t,{Z:()=>i,a:()=>a});var n=s(7378);const r={},o=n.createContext(r);function a(e){const t=n.useContext(o);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function i(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:a(e.components),n.createElement(o.Provider,{value:t},e.children)}}}]); \ No newline at end of file diff --git a/assets/js/f83e606a.269bd854.js b/assets/js/f83e606a.269bd854.js deleted file mode 100755 index 75375f6..0000000 --- a/assets/js/f83e606a.269bd854.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[104],{5318:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>f});var r=n(7378);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t =0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r =0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var l=r.createContext({}),u=function(e){var t=r.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=u(e.components);return r.createElement(l.Provider,{value:t},e.children)},d="mdxType",p={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},g=r.forwardRef((function(e,t){var n=e.components,a=e.mdxType,s=e.originalType,l=e.parentName,c=i(e,["components","mdxType","originalType","parentName"]),d=u(n),g=a,f=d["".concat(l,".").concat(g)]||d[g]||p[g]||s;return n?r.createElement(f,o(o({ref:t},c),{},{components:n})):r.createElement(f,o({ref:t},c))}));function f(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var s=n.length,o=new Array(s);o[0]=g;var i={};for(var l in t)hasOwnProperty.call(t,l)&&(i[l]=t[l]);i.originalType=e,i[d]="string"==typeof e?e:a,o[1]=i;for(var u=2;u {n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>o,default:()=>p,frontMatter:()=>s,metadata:()=>i,toc:()=>u});var r=n(5773),a=(n(7378),n(5318));const s={},o="Request ID",i={unversionedId:"features-and-use-cases/request-id",id:"features-and-use-cases/request-id",title:"Request ID",description:"Because of a shared storage, CLS is an ideal tool for tracking request (correlation) IDs for the purpose of logging. This package provides an option to automatically generate request IDs in the middleware/guard/interceptor, if you pass { generateId: true } to its options. By default, the generated ID is a string based on Math.random(), but you can provide a custom function in the idGenerator option.",source:"@site/docs/03_features-and-use-cases/01_request-id.md",sourceDirName:"03_features-and-use-cases",slug:"/features-and-use-cases/request-id",permalink:"/nestjs-cls/features-and-use-cases/request-id",draft:!1,editUrl:"https://github.com/Papooch/nestjs-cls/tree/main/docs/docs/03_features-and-use-cases/01_request-id.md",tags:[],version:"current",sidebarPosition:1,frontMatter:{},sidebar:"documentationSidebar",previous:{title:"Features and use cases",permalink:"/nestjs-cls/features-and-use-cases/"},next:{title:"Additional CLS Setup",permalink:"/nestjs-cls/features-and-use-cases/additional-cls-setup"}},l={},u=[],c={toc:u},d="wrapper";function p(e){let{components:t,...n}=e;return(0,a.kt)(d,(0,r.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("h1",{id:"request-id"},"Request ID"),(0,a.kt)("p",null,"Because of a shared storage, CLS is an ideal tool for tracking request (correlation) IDs for the purpose of logging. This package provides an option to automatically generate request IDs in the middleware/guard/interceptor, if you pass ",(0,a.kt)("inlineCode",{parentName:"p"},"{ generateId: true }")," to its options. By default, the generated ID is a string based on ",(0,a.kt)("inlineCode",{parentName:"p"},"Math.random()"),", but you can provide a custom function in the ",(0,a.kt)("inlineCode",{parentName:"p"},"idGenerator")," option."),(0,a.kt)("p",null,"This function receives the ",(0,a.kt)("inlineCode",{parentName:"p"},"Request")," (or ",(0,a.kt)("inlineCode",{parentName:"p"},"ExecutionContext")," in case a ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsGuard")," is used) as the first parameter, which can be used in the generation process and should return (or resolve with) a string ID that will be stored in the CLS for later use."),(0,a.kt)("p",null,"Below is an example of retrieving the request ID from the request header with a fallback to an autogenerated one."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},"ClsModule.forRoot({\n middleware: {\n mount: true,\n // highlight-start\n generateId: true,\n idGenerator: (req: Request) =>\n req.headers['X-Request-Id'] ?? uuid();\n // highlight-end\n }\n})\n")),(0,a.kt)("p",null,"The ID is stored under the ",(0,a.kt)("inlineCode",{parentName:"p"},"CLS_ID")," constant in the context. The ",(0,a.kt)("inlineCode",{parentName:"p"},"ClsService")," provides a shorthand method ",(0,a.kt)("inlineCode",{parentName:"p"},"getId")," to quickly retrieve it anywhere. It can be for example used in a custom logger:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="my.logger.ts"',title:'"my.logger.ts"'},"@Injectable()\nclass MyLogger {\n constructor(private readonly cls: ClsService) {}\n\n log(message: string) {\n // highlight-start\n console.log(`<${this.cls.getId()}> ${message}`);\n // highlight-end\n }\n}\n")),(0,a.kt)("p",null,"Calling this from anywhere within a CLS context results in retrieving the ID:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts",metastring:'title="my.service.ts"',title:'"my.service.ts"'},"@Injectable()\nclass MyService {\n constructor(private readonly logger: MyLogger);\n\n hello() {\n this.logger.log('Hello');\n // -> logs for ex.: \"<44c2d8ff-49a6-4244-869f-75a2df11517a> Hello\"\n }\n}\n")))}p.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/assets/js/main.4229acf3.js b/assets/js/main.4229acf3.js deleted file mode 100755 index 7360c90..0000000 --- a/assets/js/main.4229acf3.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! For license information please see main.4229acf3.js.LICENSE.txt */ -(self.webpackChunknestjs_cls_docs=self.webpackChunknestjs_cls_docs||[]).push([[179],{6623:(e,t,n)=>{"use strict";n.d(t,{Z:()=>p});var r=n(7378),a=n(5773),o=n(1237),i=n.n(o),l=n(6887);const s={17896441:[()=>Promise.all([n.e(532),n.e(918)]).then(n.bind(n,6417)),"@theme/DocItem",6417],"1be78505":[()=>Promise.all([n.e(532),n.e(514)]).then(n.bind(n,5553)),"@theme/DocPage",5553],"1cd7469c":[()=>n.e(665).then(n.t.bind(n,3769,19)),"/media/papooch/Storage/Ondra/Stuff/Projects/Node/nestjs-cls/docs/.docusaurus/docusaurus-plugin-content-docs/default/plugin-route-context-module-100.json",3769],"3ac8ff5d":[()=>n.e(332).then(n.bind(n,5948)),"@site/docs/01_introduction/03_how-it-works.md",5948],"3b39bba3":[()=>Promise.all([n.e(532),n.e(546)]).then(n.bind(n,864)),"@site/docs/01_introduction/01_installation.md",864],"4998a0a4":[()=>n.e(872).then(n.bind(n,15)),"@site/docs/03_features-and-use-cases/05_type-safety-and-type-inference.md",15],"4c9a797e":[()=>n.e(720).then(n.bind(n,8499)),"@site/docs/04_api/index.md",8499],"57c14adc":[()=>n.e(507).then(n.bind(n,3129)),"@site/docs/05_considerations/01_security.md",3129],"592cbe55":[()=>n.e(437).then(n.bind(n,3080)),"@site/docs/03_features-and-use-cases/06_proxy-providers.md",3080],"6212613f":[()=>n.e(849).then(n.bind(n,7046)),"@site/docs/03_features-and-use-cases/02_additional-cls-setup.md",7046],"67fa07c1":[()=>n.e(164).then(n.bind(n,275)),"@site/docs/06_migration-guide/01_v2x-v3x.md",275],"75a2ce58":[()=>n.e(678).then(n.bind(n,9882)),"@site/docs/06_migration-guide/index.md",9882],"81cbaa95":[()=>n.e(513).then(n.bind(n,6021)),"@site/docs/02_setting-up-cls-context/04_using-a-decurator.md",6021],"849c94ea":[()=>n.e(756).then(n.bind(n,6973)),"@site/docs/03_features-and-use-cases/03_breakin-out-of-di.md",6973],"86ea57e0":[()=>n.e(202).then(n.bind(n,6906)),"@site/docs/01_introduction/index.md",6906],"935f2afb":[()=>n.e(53).then(n.t.bind(n,1109,19)),"~docs/default/version-current-metadata-prop-751.json",1109],"94e5e920":[()=>n.e(575).then(n.bind(n,8337)),"@site/docs/05_considerations/index.md",8337],"97d55a5e":[()=>n.e(823).then(n.bind(n,5769)),"@site/docs/04_api/02_module-options.md",5769],a2c1fdb7:[()=>n.e(776).then(n.bind(n,1930)),"@site/docs/02_setting-up-cls-context/index.md",1930],a8d12efa:[()=>n.e(55).then(n.bind(n,7333)),"@site/docs/03_features-and-use-cases/04_usage-outside-of-web-request.md",7333],ae4976f8:[()=>n.e(93).then(n.bind(n,8642)),"@site/docs/02_setting-up-cls-context/01_using-a-middleware.md",8642],b09df872:[()=>n.e(246).then(n.bind(n,5160)),"@site/docs/02_setting-up-cls-context/03_using-an-interceptor.md",5160],b787da23:[()=>n.e(126).then(n.bind(n,1708)),"@site/docs/05_considerations/02_compatibility.md",1708],d459cca2:[()=>n.e(47).then(n.bind(n,4614)),"@site/docs/02_setting-up-cls-context/02_using-a-guard.md",4614],df604e10:[()=>n.e(775).then(n.bind(n,3250)),"@site/docs/04_api/01_service-interface.md",3250],eca1a52a:[()=>n.e(873).then(n.bind(n,5755)),"@site/docs/01_introduction/02_quick-start.md",5755],ef9f7d37:[()=>n.e(990).then(n.bind(n,6524)),"@site/docs/03_features-and-use-cases/index.md",6524],f83e606a:[()=>n.e(104).then(n.bind(n,6722)),"@site/docs/03_features-and-use-cases/01_request-id.md",6722]};function u(e){let{error:t,retry:n,pastDelay:a}=e;return t?r.createElement("div",{style:{textAlign:"center",color:"#fff",backgroundColor:"#fa383e",borderColor:"#fa383e",borderStyle:"solid",borderRadius:"0.25rem",borderWidth:"1px",boxSizing:"border-box",display:"block",padding:"1rem",flex:"0 0 50%",marginLeft:"25%",marginRight:"25%",marginTop:"5rem",maxWidth:"50%",width:"100%"}},r.createElement("p",null,String(t)),r.createElement("div",null,r.createElement("button",{type:"button",onClick:n},"Retry"))):a?r.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"}},r.createElement("svg",{id:"loader",style:{width:128,height:110,position:"absolute",top:"calc(100vh - 64%)"},viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",stroke:"#61dafb"},r.createElement("g",{fill:"none",fillRule:"evenodd",transform:"translate(1 1)",strokeWidth:"2"},r.createElement("circle",{cx:"22",cy:"22",r:"6",strokeOpacity:"0"},r.createElement("animate",{attributeName:"r",begin:"1.5s",dur:"3s",values:"6;22",calcMode:"linear",repeatCount:"indefinite"}),r.createElement("animate",{attributeName:"stroke-opacity",begin:"1.5s",dur:"3s",values:"1;0",calcMode:"linear",repeatCount:"indefinite"}),r.createElement("animate",{attributeName:"stroke-width",begin:"1.5s",dur:"3s",values:"2;0",calcMode:"linear",repeatCount:"indefinite"})),r.createElement("circle",{cx:"22",cy:"22",r:"6",strokeOpacity:"0"},r.createElement("animate",{attributeName:"r",begin:"3s",dur:"3s",values:"6;22",calcMode:"linear",repeatCount:"indefinite"}),r.createElement("animate",{attributeName:"stroke-opacity",begin:"3s",dur:"3s",values:"1;0",calcMode:"linear",repeatCount:"indefinite"}),r.createElement("animate",{attributeName:"stroke-width",begin:"3s",dur:"3s",values:"2;0",calcMode:"linear",repeatCount:"indefinite"})),r.createElement("circle",{cx:"22",cy:"22",r:"8"},r.createElement("animate",{attributeName:"r",begin:"0s",dur:"1.5s",values:"6;1;2;3;4;5;6",calcMode:"linear",repeatCount:"indefinite"}))))):null}var c=n(3361),d=n(6881);function f(e,t){if("*"===e)return i()({loading:u,loader:()=>n.e(893).then(n.bind(n,3893)),modules:["@theme/NotFound"],webpack:()=>[3893],render(e,t){const n=e.default;return r.createElement(d.z,{value:{plugin:{name:"native",id:"default"}}},r.createElement(n,t))}});const o=l[`${e}-${t}`],f={},p=[],m=[],h=(0,c.Z)(o);return Object.entries(h).forEach((e=>{let[t,n]=e;const r=s[n];r&&(f[t]=r[0],p.push(r[1]),m.push(r[2]))})),i().Map({loading:u,loader:f,modules:p,webpack:()=>m,render(t,n){const i=JSON.parse(JSON.stringify(o));Object.entries(t).forEach((t=>{let[n,r]=t;const a=r.default;if(!a)throw new Error(`The page component at ${e} doesn't have a default export. This makes it impossible to render anything. Consider default-exporting a React component.`);"object"!=typeof a&&"function"!=typeof a||Object.keys(r).filter((e=>"default"!==e)).forEach((e=>{a[e]=r[e]}));let o=i;const l=n.split(".");l.slice(0,-1).forEach((e=>{o=o[e]})),o[l[l.length-1]]=a}));const l=i.__comp;delete i.__comp;const s=i.__context;return delete i.__context,r.createElement(d.z,{value:s},r.createElement(l,(0,a.Z)({},i,n)))}})}const p=[{path:"/nestjs-cls/",component:f("/nestjs-cls/","716"),routes:[{path:"/nestjs-cls/",component:f("/nestjs-cls/","c45"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/api",component:f("/nestjs-cls/api","212"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/api/module-options",component:f("/nestjs-cls/api/module-options","77a"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/api/service-interface",component:f("/nestjs-cls/api/service-interface","0da"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/considerations",component:f("/nestjs-cls/considerations","416"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/considerations/compatibility",component:f("/nestjs-cls/considerations/compatibility","10c"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/considerations/security",component:f("/nestjs-cls/considerations/security","54f"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/features-and-use-cases",component:f("/nestjs-cls/features-and-use-cases","1da"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/features-and-use-cases/additional-cls-setup",component:f("/nestjs-cls/features-and-use-cases/additional-cls-setup","d4a"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/features-and-use-cases/breakin-out-of-di",component:f("/nestjs-cls/features-and-use-cases/breakin-out-of-di","fdb"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/features-and-use-cases/proxy-providers",component:f("/nestjs-cls/features-and-use-cases/proxy-providers","53b"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/features-and-use-cases/request-id",component:f("/nestjs-cls/features-and-use-cases/request-id","b90"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/features-and-use-cases/type-safety-and-type-inference",component:f("/nestjs-cls/features-and-use-cases/type-safety-and-type-inference","88f"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request",component:f("/nestjs-cls/features-and-use-cases/usage-outside-of-web-request","9b7"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/introduction/how-it-works",component:f("/nestjs-cls/introduction/how-it-works","a84"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/introduction/installation",component:f("/nestjs-cls/introduction/installation","885"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/introduction/quick-start",component:f("/nestjs-cls/introduction/quick-start","cf1"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/migration-guide",component:f("/nestjs-cls/migration-guide","25f"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/migration-guide/v2x-v3x",component:f("/nestjs-cls/migration-guide/v2x-v3x","992"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/setting-up-cls-context",component:f("/nestjs-cls/setting-up-cls-context","e63"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/setting-up-cls-context/using-a-decurator",component:f("/nestjs-cls/setting-up-cls-context/using-a-decurator","b75"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/setting-up-cls-context/using-a-guard",component:f("/nestjs-cls/setting-up-cls-context/using-a-guard","8c0"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/setting-up-cls-context/using-a-middleware",component:f("/nestjs-cls/setting-up-cls-context/using-a-middleware","ad9"),exact:!0,sidebar:"documentationSidebar"},{path:"/nestjs-cls/setting-up-cls-context/using-an-interceptor",component:f("/nestjs-cls/setting-up-cls-context/using-an-interceptor","393"),exact:!0,sidebar:"documentationSidebar"}]},{path:"*",component:f("*")}]},3427:(e,t,n)=>{"use strict";n.d(t,{_:()=>a,t:()=>o});var r=n(7378);const a=r.createContext(!1);function o(e){let{children:t}=e;const[n,o]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{o(!0)}),[]),r.createElement(a.Provider,{value:n},t)}},6662:(e,t,n)=>{"use strict";var r=n(7378),a=n(1542),o=n(4289),i=n(2883),l=n(161);const s=[n(142),n(3815),n(4374),n(6222)];var u=n(6623),c=n(3620),d=n(5473);function f(e){let{children:t}=e;return r.createElement(r.Fragment,null,t)}var p=n(5773),m=n(7092),h=n(353),g=n(8948),b=n(624),v=n(8831),y=n(3714),w=n(174),k=n(3149),E=n(505);function S(){const{i18n:{defaultLocale:e,localeConfigs:t}}=(0,h.Z)(),n=(0,y.l)();return r.createElement(m.Z,null,Object.entries(t).map((e=>{let[t,{htmlLang:a}]=e;return r.createElement("link",{key:t,rel:"alternate",href:n.createUrl({locale:t,fullyQualified:!0}),hrefLang:a})})),r.createElement("link",{rel:"alternate",href:n.createUrl({locale:e,fullyQualified:!0}),hrefLang:"x-default"}))}function x(e){let{permalink:t}=e;const{siteConfig:{url:n}}=(0,h.Z)(),a=function(){const{siteConfig:{url:e}}=(0,h.Z)(),{pathname:t}=(0,c.TH)();return e+(0,g.Z)(t)}(),o=t?`${n}${t}`:a;return r.createElement(m.Z,null,r.createElement("meta",{property:"og:url",content:o}),r.createElement("link",{rel:"canonical",href:o}))}function _(){const{i18n:{currentLocale:e}}=(0,h.Z)(),{metadata:t,image:n}=(0,b.L)();return r.createElement(r.Fragment,null,r.createElement(m.Z,null,r.createElement("meta",{name:"twitter:card",content:"summary_large_image"}),r.createElement("body",{className:w.h})),n&&r.createElement(v.d,{image:n}),r.createElement(x,null),r.createElement(S,null),r.createElement(E.Z,{tag:k.HX,locale:e}),r.createElement(m.Z,null,t.map(((e,t)=>r.createElement("meta",(0,p.Z)({key:t},e))))))}const C=new Map;function T(e){if(C.has(e.pathname))return{...e,pathname:C.get(e.pathname)};if((0,d.f)(u.Z,e.pathname).some((e=>{let{route:t}=e;return!0===t.exact})))return C.set(e.pathname,e.pathname),e;const t=e.pathname.trim().replace(/(?:\/index)?\.html$/,"")||"/";return C.set(e.pathname,t),{...e,pathname:t}}var A=n(3427),L=n(5547);function N(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{const r=t.default?.[e]??t[e];return r?.(...n)}));return()=>a.forEach((e=>e?.()))}const R=function(e){let{children:t,location:n,previousLocation:a}=e;return(0,r.useLayoutEffect)((()=>{a!==n&&(!function(e){let{location:t,previousLocation:n}=e;if(!n)return;const r=t.pathname===n.pathname,a=t.hash===n.hash,o=t.search===n.search;if(r&&a&&!o)return;const{hash:i}=t;if(i){const e=decodeURIComponent(i.substring(1)),t=document.getElementById(e);t?.scrollIntoView()}else window.scrollTo(0,0)}({location:n,previousLocation:a}),N("onRouteDidUpdate",{previousLocation:a,location:n}))}),[a,n]),t};function P(e){const t=Array.from(new Set([e,decodeURI(e)])).map((e=>(0,d.f)(u.Z,e))).flat();return Promise.all(t.map((e=>e.route.component.preload?.())))}class O extends r.Component{previousLocation;routeUpdateCleanupCb;constructor(e){super(e),this.previousLocation=null,this.routeUpdateCleanupCb=l.Z.canUseDOM?N("onRouteUpdate",{previousLocation:null,location:this.props.location}):()=>{},this.state={nextRouteHasLoaded:!0}}shouldComponentUpdate(e,t){if(e.location===this.props.location)return t.nextRouteHasLoaded;const n=e.location;return this.previousLocation=this.props.location,this.setState({nextRouteHasLoaded:!1}),this.routeUpdateCleanupCb=N("onRouteUpdate",{previousLocation:this.previousLocation,location:n}),P(n.pathname).then((()=>{this.routeUpdateCleanupCb(),this.setState({nextRouteHasLoaded:!0})})).catch((e=>{console.warn(e),window.location.reload()})),!1}render(){const{children:e,location:t}=this.props;return r.createElement(R,{previousLocation:this.previousLocation,location:t},r.createElement(c.AW,{location:t,render:()=>e}))}}const I=O,D="__docusaurus-base-url-issue-banner-container",M="__docusaurus-base-url-issue-banner",j="__docusaurus-base-url-issue-banner-suggestion-container",F="__DOCUSAURUS_INSERT_BASEURL_BANNER";function B(e){return`\nwindow['${F}'] = true;\n\ndocument.addEventListener('DOMContentLoaded', maybeInsertBanner);\n\nfunction maybeInsertBanner() {\n var shouldInsert = window['${F}'];\n shouldInsert && insertBanner();\n}\n\nfunction insertBanner() {\n var bannerContainer = document.getElementById('${D}');\n if (!bannerContainer) {\n return;\n }\n var bannerHtml = ${JSON.stringify(function(e){return`\n \n\n`}(e)).replace(/{window[F]=!1}),[]),r.createElement(r.Fragment,null,!l.Z.canUseDOM&&r.createElement(m.Z,null,r.createElement("script",null,B(e))),r.createElement("div",{id:D}))}function U(){const{siteConfig:{baseUrl:e,baseUrlIssueBanner:t}}=(0,h.Z)(),{pathname:n}=(0,c.TH)();return t&&n===e?r.createElement(z,null):null}function $(){const{siteConfig:{favicon:e,title:t,noIndex:n},i18n:{currentLocale:a,localeConfigs:o}}=(0,h.Z)(),i=(0,g.Z)(e),{htmlLang:l,direction:s}=o[a];return r.createElement(m.Z,null,r.createElement("html",{lang:l,dir:s}),r.createElement("title",null,t),r.createElement("meta",{property:"og:title",content:t}),r.createElement("meta",{name:"viewport",content:"width=device-width, initial-scale=1.0"}),n&&r.createElement("meta",{name:"robots",content:"noindex, nofollow"}),e&&r.createElement("link",{rel:"icon",href:i}))}var q=n(6293);function H(){const e=(0,d.H)(u.Z),t=(0,c.TH)();return r.createElement(q.Z,null,r.createElement(L.M,null,r.createElement(A.t,null,r.createElement(f,null,r.createElement($,null),r.createElement(_,null),r.createElement(U,null),r.createElement(I,{location:T(t)},e)))))}var G=n(6887);const Z=function(e){try{return document.createElement("link").relList.supports(e)}catch{return!1}}("prefetch")?function(e){return new Promise(((t,n)=>{if("undefined"==typeof document)return void n();const r=document.createElement("link");r.setAttribute("rel","prefetch"),r.setAttribute("href",e),r.onload=()=>t(),r.onerror=()=>n();const a=document.getElementsByTagName("head")[0]??document.getElementsByName("script")[0]?.parentNode;a?.appendChild(r)}))}:function(e){return new Promise(((t,n)=>{const r=new XMLHttpRequest;r.open("GET",e,!0),r.withCredentials=!0,r.onload=()=>{200===r.status?t():n()},r.send(null)}))};var V=n(3361);const W=new Set,Y=new Set,K=()=>navigator.connection?.effectiveType.includes("2g")||navigator.connection?.saveData,Q={prefetch(e){if(!(e=>!K()&&!Y.has(e)&&!W.has(e))(e))return!1;W.add(e);const t=(0,d.f)(u.Z,e).flatMap((e=>{return t=e.route.path,Object.entries(G).filter((e=>{let[n]=e;return n.replace(/-[^-]+$/,"")===t})).flatMap((e=>{let[,t]=e;return Object.values((0,V.Z)(t))}));var t}));return Promise.all(t.map((e=>{const t=n.gca(e);return t&&!t.includes("undefined")?Z(t).catch((()=>{})):Promise.resolve()})))},preload:e=>!!(e=>!K()&&!Y.has(e))(e)&&(Y.add(e),P(e))},X=Object.freeze(Q);if(l.Z.canUseDOM){window.docusaurus=X;const e=a.hydrate;P(window.location.pathname).then((()=>{e(r.createElement(i.B6,null,r.createElement(o.VK,null,r.createElement(H,null))),document.getElementById("__docusaurus"))}))}},5547:(e,t,n)=>{"use strict";n.d(t,{_:()=>c,M:()=>d});var r=n(7378),a=n(6809);const o=JSON.parse('{"docusaurus-lunr-search":{"default":{"fileNames":{"searchDoc":"search-doc-1697660838110.json","lunrIndex":"lunr-index-1697660838110.json"}}},"docusaurus-plugin-content-docs":{"default":{"path":"/nestjs-cls/","versions":[{"name":"current","label":"Next","isLast":true,"path":"/nestjs-cls/","mainDocId":"introduction/index","docs":[{"id":"api/index","path":"/nestjs-cls/api/","sidebar":"documentationSidebar"},{"id":"api/module-options","path":"/nestjs-cls/api/module-options","sidebar":"documentationSidebar"},{"id":"api/service-interface","path":"/nestjs-cls/api/service-interface","sidebar":"documentationSidebar"},{"id":"considerations/compatibility","path":"/nestjs-cls/considerations/compatibility","sidebar":"documentationSidebar"},{"id":"considerations/index","path":"/nestjs-cls/considerations/","sidebar":"documentationSidebar"},{"id":"considerations/security","path":"/nestjs-cls/considerations/security","sidebar":"documentationSidebar"},{"id":"features-and-use-cases/additional-cls-setup","path":"/nestjs-cls/features-and-use-cases/additional-cls-setup","sidebar":"documentationSidebar"},{"id":"features-and-use-cases/breakin-out-of-di","path":"/nestjs-cls/features-and-use-cases/breakin-out-of-di","sidebar":"documentationSidebar"},{"id":"features-and-use-cases/index","path":"/nestjs-cls/features-and-use-cases/","sidebar":"documentationSidebar"},{"id":"features-and-use-cases/proxy-providers","path":"/nestjs-cls/features-and-use-cases/proxy-providers","sidebar":"documentationSidebar"},{"id":"features-and-use-cases/request-id","path":"/nestjs-cls/features-and-use-cases/request-id","sidebar":"documentationSidebar"},{"id":"features-and-use-cases/type-safety-and-type-inference","path":"/nestjs-cls/features-and-use-cases/type-safety-and-type-inference","sidebar":"documentationSidebar"},{"id":"features-and-use-cases/usage-outside-of-web-request","path":"/nestjs-cls/features-and-use-cases/usage-outside-of-web-request","sidebar":"documentationSidebar"},{"id":"introduction/how-it-works","path":"/nestjs-cls/introduction/how-it-works","sidebar":"documentationSidebar"},{"id":"introduction/index","path":"/nestjs-cls/","sidebar":"documentationSidebar"},{"id":"introduction/installation","path":"/nestjs-cls/introduction/installation","sidebar":"documentationSidebar"},{"id":"introduction/quick-start","path":"/nestjs-cls/introduction/quick-start","sidebar":"documentationSidebar"},{"id":"migration-guide/index","path":"/nestjs-cls/migration-guide/","sidebar":"documentationSidebar"},{"id":"migration-guide/v2x-v3x","path":"/nestjs-cls/migration-guide/v2x-v3x","sidebar":"documentationSidebar"},{"id":"setting-up-cls-context/index","path":"/nestjs-cls/setting-up-cls-context/","sidebar":"documentationSidebar"},{"id":"setting-up-cls-context/using-a-decurator","path":"/nestjs-cls/setting-up-cls-context/using-a-decurator","sidebar":"documentationSidebar"},{"id":"setting-up-cls-context/using-a-guard","path":"/nestjs-cls/setting-up-cls-context/using-a-guard","sidebar":"documentationSidebar"},{"id":"setting-up-cls-context/using-a-middleware","path":"/nestjs-cls/setting-up-cls-context/using-a-middleware","sidebar":"documentationSidebar"},{"id":"setting-up-cls-context/using-an-interceptor","path":"/nestjs-cls/setting-up-cls-context/using-an-interceptor","sidebar":"documentationSidebar"}],"draftIds":[],"sidebars":{"documentationSidebar":{"link":{"path":"/nestjs-cls/","label":"Introduction"}}}}],"breadcrumbs":true}}}'),i=JSON.parse('{"defaultLocale":"en","locales":["en"],"path":"i18n","currentLocale":"en","localeConfigs":{"en":{"label":"English","direction":"ltr","htmlLang":"en","calendar":"gregory","path":"en"}}}');var l=n(7529);const s=JSON.parse('{"docusaurusVersion":"2.4.1","siteVersion":"0.0.0","pluginVersions":{"docusaurus-plugin-content-docs":{"type":"package","name":"@docusaurus/plugin-content-docs","version":"2.4.1"},"docusaurus-plugin-content-blog":{"type":"package","name":"@docusaurus/plugin-content-blog","version":"2.4.1"},"docusaurus-plugin-content-pages":{"type":"package","name":"@docusaurus/plugin-content-pages","version":"2.4.1"},"docusaurus-plugin-sitemap":{"type":"package","name":"@docusaurus/plugin-sitemap","version":"2.4.1"},"docusaurus-theme-classic":{"type":"package","name":"@docusaurus/theme-classic","version":"2.4.1"},"docusaurus-lunr-search":{"type":"package","name":"docusaurus-lunr-search","version":"2.3.2"}}}'),u={siteConfig:a.default,siteMetadata:s,globalData:o,i18n:i,codeTranslations:l},c=r.createContext(u);function d(e){let{children:t}=e;return r.createElement(c.Provider,{value:u},t)}},6293:(e,t,n)=>{"use strict";n.d(t,{Z:()=>f});var r=n(7378),a=n(161),o=n(7092),i=n(1721),l=n(9176);function s(e){let{error:t,tryAgain:n}=e;return r.createElement("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-start",minHeight:"100vh",width:"100%",maxWidth:"80ch",fontSize:"20px",margin:"0 auto",padding:"1rem"}},r.createElement("h1",{style:{fontSize:"3rem"}},"This page crashed"),r.createElement("button",{type:"button",onClick:n,style:{margin:"1rem 0",fontSize:"2rem",cursor:"pointer",borderRadius:20,padding:"1rem"}},"Try again"),r.createElement(u,{error:t}))}function u(e){let{error:t}=e;const n=(0,i.getErrorCausalChain)(t).map((e=>e.message)).join("\n\nCause:\n");return r.createElement("p",{style:{whiteSpace:"pre-wrap"}},n)}function c(e){let{error:t,tryAgain:n}=e;return r.createElement(f,{fallback:()=>r.createElement(s,{error:t,tryAgain:n})},r.createElement(o.Z,null,r.createElement("title",null,"Page Error")),r.createElement(l.Z,null,r.createElement(s,{error:t,tryAgain:n})))}const d=e=>r.createElement(c,e);class f extends r.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){a.Z.canUseDOM&&this.setState({error:e})}render(){const{children:e}=this.props,{error:t}=this.state;if(t){const e={error:t,tryAgain:()=>this.setState({error:null})};return(this.props.fallback??d)(e)}return e??null}}},161:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});const r="undefined"!=typeof window&&"document"in window&&"createElement"in window.document,a={canUseDOM:r,canUseEventListeners:r&&("addEventListener"in window||"attachEvent"in window),canUseIntersectionObserver:r&&"IntersectionObserver"in window,canUseViewport:r&&"screen"in window}},7092:(e,t,n)=>{"use strict";n.d(t,{Z:()=>o});var r=n(7378),a=n(2883);function o(e){return r.createElement(a.ql,e)}},1884:(e,t,n)=>{"use strict";n.d(t,{Z:()=>p});var r=n(5773),a=n(7378),o=n(4289),i=n(1721),l=n(353),s=n(5626),u=n(161);const c=a.createContext({collectLink:()=>{}});var d=n(8948);function f(e,t){let{isNavLink:n,to:f,href:p,activeClassName:m,isActive:h,"data-noBrokenLinkCheck":g,autoAddBaseUrl:b=!0,...v}=e;const{siteConfig:{trailingSlash:y,baseUrl:w}}=(0,l.Z)(),{withBaseUrl:k}=(0,d.C)(),E=(0,a.useContext)(c),S=(0,a.useRef)(null);(0,a.useImperativeHandle)(t,(()=>S.current));const x=f||p;const _=(0,s.Z)(x),C=x?.replace("pathname://","");let T=void 0!==C?(A=C,b&&(e=>e.startsWith("/"))(A)?k(A):A):void 0;var A;T&&_&&(T=(0,i.applyTrailingSlash)(T,{trailingSlash:y,baseUrl:w}));const L=(0,a.useRef)(!1),N=n?o.OL:o.rU,R=u.Z.canUseIntersectionObserver,P=(0,a.useRef)(),O=()=>{L.current||null==T||(window.docusaurus.preload(T),L.current=!0)};(0,a.useEffect)((()=>(!R&&_&&null!=T&&window.docusaurus.prefetch(T),()=>{R&&P.current&&P.current.disconnect()})),[P,T,R,_]);const I=T?.startsWith("#")??!1,D=!T||!_||I;return D||g||E.collectLink(T),D?a.createElement("a",(0,r.Z)({ref:S,href:T},x&&!_&&{target:"_blank",rel:"noopener noreferrer"},v)):a.createElement(N,(0,r.Z)({},v,{onMouseEnter:O,onTouchStart:O,innerRef:e=>{S.current=e,R&&e&&_&&(P.current=new window.IntersectionObserver((t=>{t.forEach((t=>{e===t.target&&(t.isIntersecting||t.intersectionRatio>0)&&(P.current.unobserve(e),P.current.disconnect(),null!=T&&window.docusaurus.prefetch(T))}))})),P.current.observe(e))},to:T},n&&{isActive:h,activeClassName:m}))}const p=a.forwardRef(f)},9213:(e,t,n)=>{"use strict";n.d(t,{Z:()=>s,I:()=>l});var r=n(7378);function a(e,t){const n=e.split(/(\{\w+\})/).map(((e,n)=>{if(n%2==1){const n=t?.[e.slice(1,-1)];if(void 0!==n)return n}return e}));return n.some((e=>(0,r.isValidElement)(e)))?n.map(((e,t)=>(0,r.isValidElement)(e)?r.cloneElement(e,{key:t}):e)).filter((e=>""!==e)):n.join("")}var o=n(7529);function i(e){let{id:t,message:n}=e;if(void 0===t&&void 0===n)throw new Error("Docusaurus translation declarations must have at least a translation id or a default translation message");return o[t??n]??n??t}function l(e,t){let{message:n,id:r}=e;return a(i({message:n,id:r}),t)}function s(e){let{children:t,id:n,values:o}=e;if(t&&"string"!=typeof t)throw console.warn("IllegalYour Docusaurus site did not load properly.
\nA very common reason is a wrong site baseUrl configuration.
\nCurrent configured baseUrl = ${e} ${"/"===e?" (default value)":""}
\nWe suggest trying baseUrl =
\nchildren",t),new Error("The Docusaurus component only accept simple string values");const l=i({message:t,id:n});return r.createElement(r.Fragment,null,a(l,o))}},5688:(e,t,n)=>{"use strict";n.d(t,{m:()=>r});const r="default"},5626:(e,t,n)=>{"use strict";function r(e){return/^(?:\w*:|\/\/)/.test(e)}function a(e){return void 0!==e&&!r(e)}n.d(t,{Z:()=>a,b:()=>r})},8948:(e,t,n)=>{"use strict";n.d(t,{C:()=>i,Z:()=>l});var r=n(7378),a=n(353),o=n(5626);function i(){const{siteConfig:{baseUrl:e,url:t}}=(0,a.Z)(),n=(0,r.useCallback)(((n,r)=>function(e,t,n,r){let{forcePrependBaseUrl:a=!1,absolute:i=!1}=void 0===r?{}:r;if(!n||n.startsWith("#")||(0,o.b)(n))return n;if(a)return t+n.replace(/^\//,"");if(n===t.replace(/\/$/,""))return t;const l=n.startsWith(t)?n:t+n.replace(/^\//,"");return i?e+l:l}(t,e,n,r)),[t,e]);return{withBaseUrl:n}}function l(e,t){void 0===t&&(t={});const{withBaseUrl:n}=i();return n(e,t)}},353:(e,t,n)=>{"use strict";n.d(t,{Z:()=>o});var r=n(7378),a=n(5547);function o(){return(0,r.useContext)(a._)}},1869:(e,t,n)=>{"use strict";n.d(t,{OD:()=>o,eZ:()=>i});var r=n(353),a=n(5688);function o(e,t){void 0===t&&(t={});const n=function(){const{globalData:e}=(0,r.Z)();return e}()[e];if(!n&&t.failfast)throw new Error(`Docusaurus plugin global data not found for "${e}" plugin.`);return n}function i(e,t,n){void 0===t&&(t=a.m),void 0===n&&(n={});const r=o(e),i=r?.[t];if(!i&&n.failfast)throw new Error(`Docusaurus plugin global data not found for "${e}" plugin with id "${t}".`);return i}},6457:(e,t,n)=>{"use strict";n.d(t,{Z:()=>o});var r=n(7378),a=n(3427);function o(){return(0,r.useContext)(a._)}},3361:(e,t,n)=>{"use strict";n.d(t,{Z:()=>a});const r=e=>"object"==typeof e&&!!e&&Object.keys(e).length>0;function a(e){const t={};return function e(n,a){Object.entries(n).forEach((n=>{let[o,i]=n;const l=a?`${a}.${o}`:o;r(i)?e(i,l):t[l]=i}))}(e),t}},6881:(e,t,n)=>{"use strict";n.d(t,{_:()=>a,z:()=>o});var r=n(7378);const a=r.createContext(null);function o(e){let{children:t,value:n}=e;const o=r.useContext(a),i=(0,r.useMemo)((()=>function(e){let{parent:t,value:n}=e;if(!t){if(!n)throw new Error("Unexpected: no Docusaurus route context found");if(!("plugin"in n))throw new Error("Unexpected: Docusaurus topmost route context has no `plugin` attribute");return n}const r={...t.data,...n?.data};return{plugin:t.plugin,data:r}}({parent:o,value:n})),[o,n]);return r.createElement(a.Provider,{value:i},t)}},6282:(e,t,n)=>{"use strict";n.d(t,{Iw:()=>p,gA:()=>c,_r:()=>s,Jo:()=>m,zh:()=>u,yW:()=>f,gB:()=>d});var r=n(3620),a=n(1869);const o=e=>e.versions.find((e=>e.isLast));function i(e,t){const n=function(e,t){const n=o(e);return[...e.versions.filter((e=>e!==n)),n].find((e=>!!(0,r.LX)(t,{path:e.path,exact:!1,strict:!1})))}(e,t),a=n?.docs.find((e=>!!(0,r.LX)(t,{path:e.path,exact:!0,strict:!1})));return{activeVersion:n,activeDoc:a,alternateDocVersions:a?function(t){const n={};return e.versions.forEach((e=>{e.docs.forEach((r=>{r.id===t&&(n[e.name]=r)}))})),n}(a.id):{}}}const l={},s=()=>(0,a.OD)("docusaurus-plugin-content-docs")??l,u=e=>(0,a.eZ)("docusaurus-plugin-content-docs",e,{failfast:!0});function c(e){void 0===e&&(e={});const t=s(),{pathname:n}=(0,r.TH)();return function(e,t,n){void 0===n&&(n={});const a=Object.entries(e).sort(((e,t)=>t[1].path.localeCompare(e[1].path))).find((e=>{let[,n]=e;return!!(0,r.LX)(t,{path:n.path,exact:!1,strict:!1})})),o=a?{pluginId:a[0],pluginData:a[1]}:void 0;if(!o&&n.failfast)throw new Error(`Can't find active docs plugin for "${t}" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: ${Object.values(e).map((e=>e.path)).join(", ")}`);return o}(t,n,e)}function d(e){return u(e).versions}function f(e){const t=u(e);return o(t)}function p(e){const t=u(e),{pathname:n}=(0,r.TH)();return i(t,n)}function m(e){const t=u(e),{pathname:n}=(0,r.TH)();return function(e,t){const n=o(e);return{latestDocSuggestion:i(e,t).alternateDocVersions[n.name],latestVersionSuggestion:n}}(t,n)}},4374:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var r=n(8504),a=n.n(r);a().configure({showSpinner:!1});const o={onRouteUpdate(e){let{location:t,previousLocation:n}=e;if(n&&t.pathname!==n.pathname){const e=window.setTimeout((()=>{a().start()}),200);return()=>window.clearTimeout(e)}},onRouteDidUpdate(){a().done()}}},3815:(e,t,n)=>{"use strict";n.r(t);var r=n(2349),a=n(6809);!function(e){const{themeConfig:{prism:t}}=a.default,{additionalLanguages:r}=t;globalThis.Prism=e,r.forEach((e=>{n(3392)(`./prism-${e}`)})),delete globalThis.Prism}(r.Z)},6125:(e,t,n)=>{"use strict";n.d(t,{Z:()=>o});var r=n(7378);const a={iconExternalLink:"iconExternalLink_nPrP"};function o(e){let{width:t=13.5,height:n=13.5}=e;return r.createElement("svg",{width:t,height:n,"aria-hidden":"true",viewBox:"0 0 24 24",className:a.iconExternalLink},r.createElement("path",{fill:"currentColor",d:"M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"}))}},9176:(e,t,n)=>{"use strict";n.d(t,{Z:()=>mt});var r=n(7378),a=n(8944),o=n(6293),i=n(8831),l=n(5773),s=n(3620),u=n(9213),c=n(4993);const d="__docusaurus_skipToContent_fallback";function f(e){e.setAttribute("tabindex","-1"),e.focus(),e.removeAttribute("tabindex")}function p(){const e=(0,r.useRef)(null),{action:t}=(0,s.k6)(),n=(0,r.useCallback)((e=>{e.preventDefault();const t=document.querySelector("main:first-of-type")??document.getElementById(d);t&&f(t)}),[]);return(0,c.S)((n=>{let{location:r}=n;e.current&&!r.hash&&"PUSH"===t&&f(e.current)})),{containerRef:e,onClick:n}}const m=(0,u.I)({id:"theme.common.skipToMainContent",description:"The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation",message:"Skip to main content"});function h(e){const t=e.children??m,{containerRef:n,onClick:a}=p();return r.createElement("div",{ref:n,role:"region","aria-label":m},r.createElement("a",(0,l.Z)({},e,{href:`#${d}`,onClick:a}),t))}var g=n(5484),b=n(174);const v={skipToContent:"skipToContent_oPtH"};function y(){return r.createElement(h,{className:v.skipToContent})}var w=n(624),k=n(10);function E(e){let{width:t=21,height:n=21,color:a="currentColor",strokeWidth:o=1.2,className:i,...s}=e;return r.createElement("svg",(0,l.Z)({viewBox:"0 0 15 15",width:t,height:n},s),r.createElement("g",{stroke:a,strokeWidth:o},r.createElement("path",{d:"M.75.75l13.5 13.5M14.25.75L.75 14.25"})))}const S={closeButton:"closeButton_J5rP"};function x(e){return r.createElement("button",(0,l.Z)({type:"button","aria-label":(0,u.I)({id:"theme.AnnouncementBar.closeButtonAriaLabel",message:"Close",description:"The ARIA label for close button of announcement bar"})},e,{className:(0,a.Z)("clean-btn close",S.closeButton,e.className)}),r.createElement(E,{width:14,height:14,strokeWidth:3.1}))}const _={content:"content_bSb_"};function C(e){const{announcementBar:t}=(0,w.L)(),{content:n}=t;return r.createElement("div",(0,l.Z)({},e,{className:(0,a.Z)(_.content,e.className),dangerouslySetInnerHTML:{__html:n}}))}const T={announcementBar:"announcementBar_zJRd",announcementBarPlaceholder:"announcementBarPlaceholder_NpUd",announcementBarClose:"announcementBarClose_Jjdj",announcementBarContent:"announcementBarContent_t7IR"};function A(){const{announcementBar:e}=(0,w.L)(),{isActive:t,close:n}=(0,k.nT)();if(!t)return null;const{backgroundColor:a,textColor:o,isCloseable:i}=e;return r.createElement("div",{className:T.announcementBar,style:{backgroundColor:a,color:o},role:"banner"},i&&r.createElement("div",{className:T.announcementBarPlaceholder}),r.createElement(C,{className:T.announcementBarContent}),i&&r.createElement(x,{onClick:n,className:T.announcementBarClose}))}var L=n(5536),N=n(3457);var R=n(1763),P=n(3471);const O=r.createContext(null);function I(e){let{children:t}=e;const n=function(){const e=(0,L.e)(),t=(0,P.HY)(),[n,a]=(0,r.useState)(!1),o=null!==t.component,i=(0,R.D9)(o);return(0,r.useEffect)((()=>{o&&!i&&a(!0)}),[o,i]),(0,r.useEffect)((()=>{o?e.shown||a(!0):a(!1)}),[e.shown,o]),(0,r.useMemo)((()=>[n,a]),[n])}();return r.createElement(O.Provider,{value:n},t)}function D(e){if(e.component){const t=e.component;return r.createElement(t,e.props)}}function M(){const e=(0,r.useContext)(O);if(!e)throw new R.i6("NavbarSecondaryMenuDisplayProvider");const[t,n]=e,a=(0,r.useCallback)((()=>n(!1)),[n]),o=(0,P.HY)();return(0,r.useMemo)((()=>({shown:t,hide:a,content:D(o)})),[a,o,t])}function j(e){let{header:t,primaryMenu:n,secondaryMenu:o}=e;const{shown:i}=M();return r.createElement("div",{className:"navbar-sidebar"},t,r.createElement("div",{className:(0,a.Z)("navbar-sidebar__items",{"navbar-sidebar__items--show-secondary":i})},r.createElement("div",{className:"navbar-sidebar__item menu"},n),r.createElement("div",{className:"navbar-sidebar__item menu"},o)))}var F=n(5421),B=n(6457);function z(e){return r.createElement("svg",(0,l.Z)({viewBox:"0 0 24 24",width:24,height:24},e),r.createElement("path",{fill:"currentColor",d:"M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"}))}function U(e){return r.createElement("svg",(0,l.Z)({viewBox:"0 0 24 24",width:24,height:24},e),r.createElement("path",{fill:"currentColor",d:"M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"}))}const $={toggle:"toggle_ki11",toggleButton:"toggleButton_MMFG",darkToggleIcon:"darkToggleIcon_U96C",lightToggleIcon:"lightToggleIcon_lgto",toggleButtonDisabled:"toggleButtonDisabled_Uw7m"};function q(e){let{className:t,buttonClassName:n,value:o,onChange:i}=e;const l=(0,B.Z)(),s=(0,u.I)({message:"Switch between dark and light mode (currently {mode})",id:"theme.colorToggle.ariaLabel",description:"The ARIA label for the navbar color mode toggle"},{mode:"dark"===o?(0,u.I)({message:"dark mode",id:"theme.colorToggle.ariaLabel.mode.dark",description:"The name for the dark color mode"}):(0,u.I)({message:"light mode",id:"theme.colorToggle.ariaLabel.mode.light",description:"The name for the light color mode"})});return r.createElement("div",{className:(0,a.Z)($.toggle,t)},r.createElement("button",{className:(0,a.Z)("clean-btn",$.toggleButton,!l&&$.toggleButtonDisabled,n),type:"button",onClick:()=>i("dark"===o?"light":"dark"),disabled:!l,title:s,"aria-label":s,"aria-live":"polite"},r.createElement(z,{className:(0,a.Z)($.toggleIcon,$.lightToggleIcon)}),r.createElement(U,{className:(0,a.Z)($.toggleIcon,$.darkToggleIcon)})))}const H=r.memo(q),G={darkNavbarColorModeToggle:"darkNavbarColorModeToggle_m8pZ"};function Z(e){let{className:t}=e;const n=(0,w.L)().navbar.style,a=(0,w.L)().colorMode.disableSwitch,{colorMode:o,setColorMode:i}=(0,F.I)();return a?null:r.createElement(H,{className:t,buttonClassName:"dark"===n?G.darkNavbarColorModeToggle:void 0,value:o,onChange:i})}var V=n(898);function W(){return r.createElement(V.Z,{className:"navbar__brand",imageClassName:"navbar__logo",titleClassName:"navbar__title text--truncate"})}function Y(){const e=(0,L.e)();return r.createElement("button",{type:"button","aria-label":(0,u.I)({id:"theme.docs.sidebar.closeSidebarButtonAriaLabel",message:"Close navigation bar",description:"The ARIA label for close button of mobile sidebar"}),className:"clean-btn navbar-sidebar__close",onClick:()=>e.toggle()},r.createElement(E,{color:"var(--ifm-color-emphasis-600)"}))}function K(){return r.createElement("div",{className:"navbar-sidebar__brand"},r.createElement(W,null),r.createElement(Z,{className:"margin-right--md"}),r.createElement(Y,null))}var Q=n(1884),X=n(8948),J=n(5626);function ee(e,t){return void 0!==e&&void 0!==t&&new RegExp(e,"gi").test(t)}var te=n(6125);function ne(e){let{activeBasePath:t,activeBaseRegex:n,to:a,href:o,label:i,html:s,isDropdownLink:u,prependBaseUrlToHref:c,...d}=e;const f=(0,X.Z)(a),p=(0,X.Z)(t),m=(0,X.Z)(o,{forcePrependBaseUrl:!0}),h=i&&o&&!(0,J.Z)(o),g=s?{dangerouslySetInnerHTML:{__html:s}}:{children:r.createElement(r.Fragment,null,i,h&&r.createElement(te.Z,u&&{width:12,height:12}))};return o?r.createElement(Q.Z,(0,l.Z)({href:c?m:o},d,g)):r.createElement(Q.Z,(0,l.Z)({to:f,isNavLink:!0},(t||n)&&{isActive:(e,t)=>n?ee(n,t.pathname):t.pathname.startsWith(p)},d,g))}function re(e){let{className:t,isDropdownItem:n=!1,...o}=e;const i=r.createElement(ne,(0,l.Z)({className:(0,a.Z)(n?"dropdown__link":"navbar__item navbar__link",t),isDropdownLink:n},o));return n?r.createElement("li",null,i):i}function ae(e){let{className:t,isDropdownItem:n,...o}=e;return r.createElement("li",{className:"menu__list-item"},r.createElement(ne,(0,l.Z)({className:(0,a.Z)("menu__link",t)},o)))}function oe(e){let{mobile:t=!1,position:n,...a}=e;const o=t?ae:re;return r.createElement(o,(0,l.Z)({},a,{activeClassName:a.activeClassName??(t?"menu__link--active":"navbar__link--active")}))}var ie=n(376),le=n(8862),se=n(353);function ue(e,t){return e.some((e=>function(e,t){return!!(0,le.Mg)(e.to,t)||!!ee(e.activeBaseRegex,t)||!(!e.activeBasePath||!t.startsWith(e.activeBasePath))}(e,t)))}function ce(e){let{items:t,position:n,className:o,onClick:i,...s}=e;const u=(0,r.useRef)(null),[c,d]=(0,r.useState)(!1);return(0,r.useEffect)((()=>{const e=e=>{u.current&&!u.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),document.addEventListener("focusin",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e),document.removeEventListener("focusin",e)}}),[u]),r.createElement("div",{ref:u,className:(0,a.Z)("navbar__item","dropdown","dropdown--hoverable",{"dropdown--right":"right"===n,"dropdown--show":c})},r.createElement(ne,(0,l.Z)({"aria-haspopup":"true","aria-expanded":c,role:"button",href:s.to?void 0:"#",className:(0,a.Z)("navbar__link",o)},s,{onClick:s.to?void 0:e=>e.preventDefault(),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),d(!c))}}),s.children??s.label),r.createElement("ul",{className:"dropdown__menu"},t.map(((e,t)=>r.createElement(Te,(0,l.Z)({isDropdownItem:!0,activeClassName:"dropdown__link--active"},e,{key:t}))))))}function de(e){let{items:t,className:n,position:o,onClick:i,...u}=e;const c=function(){const{siteConfig:{baseUrl:e}}=(0,se.Z)(),{pathname:t}=(0,s.TH)();return t.replace(e,"/")}(),d=ue(t,c),{collapsed:f,toggleCollapsed:p,setCollapsed:m}=(0,ie.u)({initialState:()=>!d});return(0,r.useEffect)((()=>{d&&m(!d)}),[c,d,m]),r.createElement("li",{className:(0,a.Z)("menu__list-item",{"menu__list-item--collapsed":f})},r.createElement(ne,(0,l.Z)({role:"button",className:(0,a.Z)("menu__link menu__link--sublist menu__link--sublist-caret",n)},u,{onClick:e=>{e.preventDefault(),p()}}),u.children??u.label),r.createElement(ie.z,{lazy:!0,as:"ul",className:"menu__list",collapsed:f},t.map(((e,t)=>r.createElement(Te,(0,l.Z)({mobile:!0,isDropdownItem:!0,onClick:i,activeClassName:"menu__link--active"},e,{key:t}))))))}function fe(e){let{mobile:t=!1,...n}=e;const a=t?de:ce;return r.createElement(a,n)}var pe=n(3714);function me(e){let{width:t=20,height:n=20,...a}=e;return r.createElement("svg",(0,l.Z)({viewBox:"0 0 24 24",width:t,height:n,"aria-hidden":!0},a),r.createElement("path",{fill:"currentColor",d:"M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"}))}const he="iconLanguage_kvP7";var ge=n(42),be=n.n(ge),ve=n(1869);const ye=e=>{const t=(0,r.useRef)(!1),a=(0,r.useRef)(null),[o,i]=(0,r.useState)(!1),l=(0,s.k6)(),{siteConfig:u={}}=(0,se.Z)(),c=(0,B.Z)(),{baseUrl:d}=u,f=(0,ve.eZ)("docusaurus-lunr-search"),p=()=>{t.current||(Promise.all([fetch(`${d}${f.fileNames.searchDoc}`).then((e=>e.json())),fetch(`${d}${f.fileNames.lunrIndex}`).then((e=>e.json())),Promise.all([n.e(734),n.e(561)]).then(n.bind(n,7213)),Promise.all([n.e(532),n.e(77)]).then(n.bind(n,5077))]).then((e=>{let[t,n,{default:r}]=e;0!==t.length&&(((e,t,n)=>{new n({searchDocs:e,searchIndex:t,baseUrl:d,inputSelector:"#search_input_react",handleSelected:(e,t,n)=>{const r=n.url||"/";document.createElement("a").href=r,l.push(r)}})})(t,n,r),i(!0))})),t.current=!0)},m=(0,r.useCallback)((t=>{a.current.contains(t.target)||a.current.focus(),e.handleSearchBarToggle&&e.handleSearchBarToggle(!e.isSearchBarExpanded)}),[e.isSearchBarExpanded]);return c&&p(),r.createElement("div",{className:"navbar__search",key:"search-box"},r.createElement("span",{"aria-label":"expand searchbar",role:"button",className:be()("search-icon",{"search-icon-hidden":e.isSearchBarExpanded}),onClick:m,onKeyDown:m,tabIndex:0}),r.createElement("input",{id:"search_input_react",type:"search",placeholder:o?"Search":"Loading...","aria-label":"Search",className:be()("navbar__search-input",{"search-bar-expanded":e.isSearchBarExpanded},{"search-bar":!e.isSearchBarExpanded}),onClick:p,onMouseOver:p,onFocus:m,onBlur:m,ref:a,disabled:!o}))},we={searchBox:"searchBox_WqAV"};function ke(e){let{children:t,className:n}=e;return r.createElement("div",{className:(0,a.Z)(n,we.searchBox)},t)}var Ee=n(6282),Se=n(5161);var xe=n(4453);const _e=e=>e.docs.find((t=>t.id===e.mainDocId));const Ce={default:oe,localeDropdown:function(e){let{mobile:t,dropdownItemsBefore:n,dropdownItemsAfter:a,...o}=e;const{i18n:{currentLocale:i,locales:c,localeConfigs:d}}=(0,se.Z)(),f=(0,pe.l)(),{search:p,hash:m}=(0,s.TH)(),h=[...n,...c.map((e=>{const n=`${`pathname://${f.createUrl({locale:e,fullyQualified:!1})}`}${p}${m}`;return{label:d[e].label,lang:d[e].htmlLang,to:n,target:"_self",autoAddBaseUrl:!1,className:e===i?t?"menu__link--active":"dropdown__link--active":""}})),...a],g=t?(0,u.I)({message:"Languages",id:"theme.navbar.mobileLanguageDropdown.label",description:"The label for the mobile language switcher dropdown"}):d[i].label;return r.createElement(fe,(0,l.Z)({},o,{mobile:t,label:r.createElement(r.Fragment,null,r.createElement(me,{className:he}),g),items:h}))},search:function(e){let{mobile:t,className:n}=e;return t?null:r.createElement(ke,{className:n},r.createElement(ye,null))},dropdown:fe,html:function(e){let{value:t,className:n,mobile:o=!1,isDropdownItem:i=!1}=e;const l=i?"li":"div";return r.createElement(l,{className:(0,a.Z)({navbar__item:!o&&!i,"menu__list-item":o},n),dangerouslySetInnerHTML:{__html:t}})},doc:function(e){let{docId:t,label:n,docsPluginId:a,...o}=e;const{activeDoc:i}=(0,Ee.Iw)(a),s=(0,Se.vY)(t,a);return null===s?null:r.createElement(oe,(0,l.Z)({exact:!0},o,{isActive:()=>i?.path===s.path||!!i?.sidebar&&i.sidebar===s.sidebar,label:n??s.id,to:s.path}))},docSidebar:function(e){let{sidebarId:t,label:n,docsPluginId:a,...o}=e;const{activeDoc:i}=(0,Ee.Iw)(a),s=(0,Se.oz)(t,a).link;if(!s)throw new Error(`DocSidebarNavbarItem: Sidebar with ID "${t}" doesn't have anything to be linked to.`);return r.createElement(oe,(0,l.Z)({exact:!0},o,{isActive:()=>i?.sidebar===t,label:n??s.label,to:s.path}))},docsVersion:function(e){let{label:t,to:n,docsPluginId:a,...o}=e;const i=(0,Se.lO)(a)[0],s=t??i.label,u=n??(e=>e.docs.find((t=>t.id===e.mainDocId)))(i).path;return r.createElement(oe,(0,l.Z)({},o,{label:s,to:u}))},docsVersionDropdown:function(e){let{mobile:t,docsPluginId:n,dropdownActiveClassDisabled:a,dropdownItemsBefore:o,dropdownItemsAfter:i,...c}=e;const{search:d,hash:f}=(0,s.TH)(),p=(0,Ee.Iw)(n),m=(0,Ee.gB)(n),{savePreferredVersionName:h}=(0,xe.J)(n),g=[...o,...m.map((e=>{const t=p.alternateDocVersions[e.name]??_e(e);return{label:e.label,to:`${t.path}${d}${f}`,isActive:()=>e===p.activeVersion,onClick:()=>h(e.name)}})),...i],b=(0,Se.lO)(n)[0],v=t&&g.length>1?(0,u.I)({id:"theme.navbar.mobileVersionsDropdown.label",message:"Versions",description:"The label for the navbar versions dropdown on mobile view"}):b.label,y=t&&g.length>1?void 0:_e(b).path;return g.length<=1?r.createElement(oe,(0,l.Z)({},c,{mobile:t,label:v,to:y,isActive:a?()=>!1:void 0})):r.createElement(fe,(0,l.Z)({},c,{mobile:t,label:v,to:y,items:g,isActive:a?()=>!1:void 0}))}};function Te(e){let{type:t,...n}=e;const a=function(e,t){return e&&"default"!==e?e:"items"in t?"dropdown":"default"}(t,n),o=Ce[a];if(!o)throw new Error(`No NavbarItem component found for type "${t}".`);return r.createElement(o,n)}function Ae(){const e=(0,L.e)(),t=(0,w.L)().navbar.items;return r.createElement("ul",{className:"menu__list"},t.map(((t,n)=>r.createElement(Te,(0,l.Z)({mobile:!0},t,{onClick:()=>e.toggle(),key:n})))))}function Le(e){return r.createElement("button",(0,l.Z)({},e,{type:"button",className:"clean-btn navbar-sidebar__back"}),r.createElement(u.Z,{id:"theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel",description:"The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)"},"\u2190 Back to main menu"))}function Ne(){const e=0===(0,w.L)().navbar.items.length,t=M();return r.createElement(r.Fragment,null,!e&&r.createElement(Le,{onClick:()=>t.hide()}),t.content)}function Re(){const e=(0,L.e)();var t;return void 0===(t=e.shown)&&(t=!0),(0,r.useEffect)((()=>(document.body.style.overflow=t?"hidden":"visible",()=>{document.body.style.overflow="visible"})),[t]),e.shouldRender?r.createElement(j,{header:r.createElement(K,null),primaryMenu:r.createElement(Ae,null),secondaryMenu:r.createElement(Ne,null)}):null}const Pe={navbarHideable:"navbarHideable_hhpl",navbarHidden:"navbarHidden_nmcs"};function Oe(e){return r.createElement("div",(0,l.Z)({role:"presentation"},e,{className:(0,a.Z)("navbar-sidebar__backdrop",e.className)}))}function Ie(e){let{children:t}=e;const{navbar:{hideOnScroll:n,style:o}}=(0,w.L)(),i=(0,L.e)(),{navbarRef:l,isNavbarVisible:s}=function(e){const[t,n]=(0,r.useState)(e),a=(0,r.useRef)(!1),o=(0,r.useRef)(0),i=(0,r.useCallback)((e=>{null!==e&&(o.current=e.getBoundingClientRect().height)}),[]);return(0,N.RF)(((t,r)=>{let{scrollY:i}=t;if(!e)return;if(i =l?n(!1):i+u {if(!e)return;const r=t.location.hash;if(r?document.getElementById(r.substring(1)):void 0)return a.current=!0,void n(!1);n(!0)})),{navbarRef:i,isNavbarVisible:t}}(n);return r.createElement("nav",{ref:l,"aria-label":(0,u.I)({id:"theme.NavBar.navAriaLabel",message:"Main",description:"The ARIA label for the main navigation"}),className:(0,a.Z)("navbar","navbar--fixed-top",n&&[Pe.navbarHideable,!s&&Pe.navbarHidden],{"navbar--dark":"dark"===o,"navbar--primary":"primary"===o,"navbar-sidebar--show":i.shown})},t,r.createElement(Oe,{onClick:i.toggle}),r.createElement(Re,null))}var De=n(1721);const Me={errorBoundaryError:"errorBoundaryError_WE6Q"};function je(e){return r.createElement("button",(0,l.Z)({type:"button"},e),r.createElement(u.Z,{id:"theme.ErrorPageContent.tryAgain",description:"The label of the button to try again rendering when the React error boundary captures an error"},"Try again"))}function Fe(e){let{error:t}=e;const n=(0,De.getErrorCausalChain)(t).map((e=>e.message)).join("\n\nCause:\n");return r.createElement("p",{className:Me.errorBoundaryError},n)}class Be extends r.Component{componentDidCatch(e,t){throw this.props.onError(e,t)}render(){return this.props.children}}const ze="right";function Ue(e){let{width:t=30,height:n=30,className:a,...o}=e;return r.createElement("svg",(0,l.Z)({className:a,width:t,height:n,viewBox:"0 0 30 30","aria-hidden":"true"},o),r.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:"10",strokeWidth:"2",d:"M4 7h22M4 15h22M4 23h22"}))}function $e(){const{toggle:e,shown:t}=(0,L.e)();return r.createElement("button",{onClick:e,"aria-label":(0,u.I)({id:"theme.docs.sidebar.toggleSidebarButtonAriaLabel",message:"Toggle navigation bar",description:"The ARIA label for hamburger menu button of mobile navigation"}),"aria-expanded":t,className:"navbar__toggle clean-btn",type:"button"},r.createElement(Ue,null))}const qe={colorModeToggle:"colorModeToggle_Hewu"};function He(e){let{items:t}=e;return r.createElement(r.Fragment,null,t.map(((e,t)=>r.createElement(Be,{key:t,onError:t=>new Error(`A theme navbar item failed to render.\nPlease double-check the following navbar item (themeConfig.navbar.items) of your Docusaurus config:\n${JSON.stringify(e,null,2)}`,{cause:t})},r.createElement(Te,e)))))}function Ge(e){let{left:t,right:n}=e;return r.createElement("div",{className:"navbar__inner"},r.createElement("div",{className:"navbar__items"},t),r.createElement("div",{className:"navbar__items navbar__items--right"},n))}function Ze(){const e=(0,L.e)(),t=(0,w.L)().navbar.items,[n,a]=function(e){function t(e){return"left"===(e.position??ze)}return[e.filter(t),e.filter((e=>!t(e)))]}(t),o=t.find((e=>"search"===e.type));return r.createElement(Ge,{left:r.createElement(r.Fragment,null,!e.disabled&&r.createElement($e,null),r.createElement(W,null),r.createElement(He,{items:n})),right:r.createElement(r.Fragment,null,r.createElement(He,{items:a}),r.createElement(Z,{className:qe.colorModeToggle}),!o&&r.createElement(ke,null,r.createElement(ye,null)))})}function Ve(){return r.createElement(Ie,null,r.createElement(Ze,null))}function We(e){let{item:t}=e;const{to:n,href:a,label:o,prependBaseUrlToHref:i,...s}=t,u=(0,X.Z)(n),c=(0,X.Z)(a,{forcePrependBaseUrl:!0});return r.createElement(Q.Z,(0,l.Z)({className:"footer__link-item"},a?{href:i?c:a}:{to:u},s),o,a&&!(0,J.Z)(a)&&r.createElement(te.Z,null))}function Ye(e){let{item:t}=e;return t.html?r.createElement("li",{className:"footer__item",dangerouslySetInnerHTML:{__html:t.html}}):r.createElement("li",{key:t.href??t.to,className:"footer__item"},r.createElement(We,{item:t}))}function Ke(e){let{column:t}=e;return r.createElement("div",{className:"col footer__col"},r.createElement("div",{className:"footer__title"},t.title),r.createElement("ul",{className:"footer__items clean-list"},t.items.map(((e,t)=>r.createElement(Ye,{key:t,item:e})))))}function Qe(e){let{columns:t}=e;return r.createElement("div",{className:"row footer__links"},t.map(((e,t)=>r.createElement(Ke,{key:t,column:e}))))}function Xe(){return r.createElement("span",{className:"footer__link-separator"},"\xb7")}function Je(e){let{item:t}=e;return t.html?r.createElement("span",{className:"footer__link-item",dangerouslySetInnerHTML:{__html:t.html}}):r.createElement(We,{item:t})}function et(e){let{links:t}=e;return r.createElement("div",{className:"footer__links text--center"},r.createElement("div",{className:"footer__links"},t.map(((e,n)=>r.createElement(r.Fragment,{key:n},r.createElement(Je,{item:e}),t.length!==n+1&&r.createElement(Xe,null))))))}function tt(e){let{links:t}=e;return function(e){return"title"in e[0]}(t)?r.createElement(Qe,{columns:t}):r.createElement(et,{links:t})}var nt=n(4034);const rt={footerLogoLink:"footerLogoLink_tutC"};function at(e){let{logo:t}=e;const{withBaseUrl:n}=(0,X.C)(),o={light:n(t.src),dark:n(t.srcDark??t.src)};return r.createElement(nt.Z,{className:(0,a.Z)("footer__logo",t.className),alt:t.alt,sources:o,width:t.width,height:t.height,style:t.style})}function ot(e){let{logo:t}=e;return t.href?r.createElement(Q.Z,{href:t.href,className:rt.footerLogoLink,target:t.target},r.createElement(at,{logo:t})):r.createElement(at,{logo:t})}function it(e){let{copyright:t}=e;return r.createElement("div",{className:"footer__copyright",dangerouslySetInnerHTML:{__html:t}})}function lt(e){let{style:t,links:n,logo:o,copyright:i}=e;return r.createElement("footer",{className:(0,a.Z)("footer",{"footer--dark":"dark"===t})},r.createElement("div",{className:"container container-fluid"},n,(o||i)&&r.createElement("div",{className:"footer__bottom text--center"},o&&r.createElement("div",{className:"margin-bottom--sm"},o),i)))}function st(){const{footer:e}=(0,w.L)();if(!e)return null;const{copyright:t,links:n,logo:a,style:o}=e;return r.createElement(lt,{style:o,links:n&&n.length>0&&r.createElement(tt,{links:n}),logo:a&&r.createElement(ot,{logo:a}),copyright:t&&r.createElement(it,{copyright:t})})}const ut=r.memo(st),ct=(0,R.Qc)([F.S,k.pl,N.OC,xe.L5,i.VC,function(e){let{children:t}=e;return r.createElement(P.n2,null,r.createElement(L.M,null,r.createElement(I,null,t)))}]);function dt(e){let{children:t}=e;return r.createElement(ct,null,t)}function ft(e){let{error:t,tryAgain:n}=e;return r.createElement("main",{className:"container margin-vert--xl"},r.createElement("div",{className:"row"},r.createElement("div",{className:"col col--6 col--offset-3"},r.createElement("h1",{className:"hero__title"},r.createElement(u.Z,{id:"theme.ErrorPageContent.title",description:"The title of the fallback page when the page crashed"},"This page crashed.")),r.createElement("div",{className:"margin-vert--lg"},r.createElement(je,{onClick:n,className:"button button--primary shadow--lw"})),r.createElement("hr",null),r.createElement("div",{className:"margin-vert--md"},r.createElement(Fe,{error:t})))))}const pt={mainWrapper:"mainWrapper_MB5r"};function mt(e){const{children:t,noFooter:n,wrapperClassName:l,title:s,description:u}=e;return(0,b.t)(),r.createElement(dt,null,r.createElement(i.d,{title:s,description:u}),r.createElement(y,null),r.createElement(A,null),r.createElement(Ve,null),r.createElement("div",{id:d,className:(0,a.Z)(g.k.wrapper.main,pt.mainWrapper,l)},r.createElement(o.Z,{fallback:e=>r.createElement(ft,e)},t)),!n&&r.createElement(ut,null))}},898:(e,t,n)=>{"use strict";n.d(t,{Z:()=>d});var r=n(5773),a=n(7378),o=n(1884),i=n(8948),l=n(353),s=n(624),u=n(4034);function c(e){let{logo:t,alt:n,imageClassName:r}=e;const o={light:(0,i.Z)(t.src),dark:(0,i.Z)(t.srcDark||t.src)},l=a.createElement(u.Z,{className:t.className,sources:o,height:t.height,width:t.width,alt:n,style:t.style});return r?a.createElement("div",{className:r},l):l}function d(e){const{siteConfig:{title:t}}=(0,l.Z)(),{navbar:{title:n,logo:u}}=(0,s.L)(),{imageClassName:d,titleClassName:f,...p}=e,m=(0,i.Z)(u?.href||"/"),h=n?"":t,g=u?.alt??h;return a.createElement(o.Z,(0,r.Z)({to:m},p,u?.target&&{target:u.target}),u&&a.createElement(c,{logo:u,alt:g,imageClassName:d}),null!=n&&a.createElement("b",{className:f},n))}},505:(e,t,n)=>{"use strict";n.d(t,{Z:()=>o});var r=n(7378),a=n(7092);function o(e){let{locale:t,version:n,tag:o}=e;const i=t;return r.createElement(a.Z,null,t&&r.createElement("meta",{name:"docusaurus_locale",content:t}),n&&r.createElement("meta",{name:"docusaurus_version",content:n}),o&&r.createElement("meta",{name:"docusaurus_tag",content:o}),i&&r.createElement("meta",{name:"docsearch:language",content:i}),n&&r.createElement("meta",{name:"docsearch:version",content:n}),o&&r.createElement("meta",{name:"docsearch:docusaurus_tag",content:o}))}},4034:(e,t,n)=>{"use strict";n.d(t,{Z:()=>u});var r=n(5773),a=n(7378),o=n(8944),i=n(6457),l=n(5421);const s={themedImage:"themedImage_BQGR","themedImage--light":"themedImage--light_HAxW","themedImage--dark":"themedImage--dark_bGx0"};function u(e){const t=(0,i.Z)(),{colorMode:n}=(0,l.I)(),{sources:u,className:c,alt:d,...f}=e,p=t?"dark"===n?["dark"]:["light"]:["light","dark"];return a.createElement(a.Fragment,null,p.map((e=>a.createElement("img",(0,r.Z)({key:e,src:u[e],alt:d,className:(0,o.Z)(s.themedImage,s[`themedImage--${e}`],c)},f)))))}},376:(e,t,n)=>{"use strict";n.d(t,{u:()=>s,z:()=>g});var r=n(5773),a=n(7378),o=n(161),i=n(6903);const l="ease-in-out";function s(e){let{initialState:t}=e;const[n,r]=(0,a.useState)(t??!1),o=(0,a.useCallback)((()=>{r((e=>!e))}),[]);return{collapsed:n,setCollapsed:r,toggleCollapsed:o}}const u={display:"none",overflow:"hidden",height:"0px"},c={display:"block",overflow:"visible",height:"auto"};function d(e,t){const n=t?u:c;e.style.display=n.display,e.style.overflow=n.overflow,e.style.height=n.height}function f(e){let{collapsibleRef:t,collapsed:n,animation:r}=e;const o=(0,a.useRef)(!1);(0,a.useEffect)((()=>{const e=t.current;function a(){const t=e.scrollHeight,n=r?.duration??function(e){if((0,i.n)())return 1;const t=e/36;return Math.round(10*(4+15*t**.25+t/5))}(t);return{transition:`height ${n}ms ${r?.easing??l}`,height:`${t}px`}}function s(){const t=a();e.style.transition=t.transition,e.style.height=t.height}if(!o.current)return d(e,n),void(o.current=!0);return e.style.willChange="height",function(){const t=requestAnimationFrame((()=>{n?(s(),requestAnimationFrame((()=>{e.style.height=u.height,e.style.overflow=u.overflow}))):(e.style.display="block",requestAnimationFrame((()=>{s()})))}));return()=>cancelAnimationFrame(t)}()}),[t,n,r])}function p(e){if(!o.Z.canUseDOM)return e?u:c}function m(e){let{as:t="div",collapsed:n,children:r,animation:o,onCollapseTransitionEnd:i,className:l,disableSSRStyle:s}=e;const u=(0,a.useRef)(null);return f({collapsibleRef:u,collapsed:n,animation:o}),a.createElement(t,{ref:u,style:s?void 0:p(n),onTransitionEnd:e=>{"height"===e.propertyName&&(d(u.current,n),i?.(n))},className:l},r)}function h(e){let{collapsed:t,...n}=e;const[o,i]=(0,a.useState)(!t),[l,s]=(0,a.useState)(t);return(0,a.useLayoutEffect)((()=>{t||i(!0)}),[t]),(0,a.useLayoutEffect)((()=>{o&&s(t)}),[o,t]),o?a.createElement(m,(0,r.Z)({},n,{collapsed:l})):null}function g(e){let{lazy:t,...n}=e;const r=t?h:m;return a.createElement(r,n)}},10:(e,t,n)=>{"use strict";n.d(t,{nT:()=>m,pl:()=>p});var r=n(7378),a=n(6457),o=n(1819),i=n(1763),l=n(624);const s=(0,o.WA)("docusaurus.announcement.dismiss"),u=(0,o.WA)("docusaurus.announcement.id"),c=()=>"true"===s.get(),d=e=>s.set(String(e)),f=r.createContext(null);function p(e){let{children:t}=e;const n=function(){const{announcementBar:e}=(0,l.L)(),t=(0,a.Z)(),[n,o]=(0,r.useState)((()=>!!t&&c()));(0,r.useEffect)((()=>{o(c())}),[]);const i=(0,r.useCallback)((()=>{d(!0),o(!0)}),[]);return(0,r.useEffect)((()=>{if(!e)return;const{id:t}=e;let n=u.get();"annoucement-bar"===n&&(n="announcement-bar");const r=t!==n;u.set(t),r&&d(!1),!r&&c()||o(!1)}),[e]),(0,r.useMemo)((()=>({isActive:!!e&&!n,close:i})),[e,n,i])}();return r.createElement(f.Provider,{value:n},t)}function m(){const e=(0,r.useContext)(f);if(!e)throw new i.i6("AnnouncementBarProvider");return e}},5421:(e,t,n)=>{"use strict";n.d(t,{I:()=>g,S:()=>h});var r=n(7378),a=n(161),o=n(1763),i=n(1819),l=n(624);const s=r.createContext(void 0),u="theme",c=(0,i.WA)(u),d={light:"light",dark:"dark"},f=e=>e===d.dark?d.dark:d.light,p=e=>a.Z.canUseDOM?f(document.documentElement.getAttribute("data-theme")):f(e),m=e=>{c.set(f(e))};function h(e){let{children:t}=e;const n=function(){const{colorMode:{defaultMode:e,disableSwitch:t,respectPrefersColorScheme:n}}=(0,l.L)(),[a,o]=(0,r.useState)(p(e));(0,r.useEffect)((()=>{t&&c.del()}),[t]);const i=(0,r.useCallback)((function(t,r){void 0===r&&(r={});const{persist:a=!0}=r;t?(o(t),a&&m(t)):(o(n?window.matchMedia("(prefers-color-scheme: dark)").matches?d.dark:d.light:e),c.del())}),[n,e]);(0,r.useEffect)((()=>{document.documentElement.setAttribute("data-theme",f(a))}),[a]),(0,r.useEffect)((()=>{if(t)return;const e=e=>{if(e.key!==u)return;const t=c.get();null!==t&&i(f(t))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)}),[t,i]);const s=(0,r.useRef)(!1);return(0,r.useEffect)((()=>{if(t&&!n)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{window.matchMedia("print").matches||s.current?s.current=window.matchMedia("print").matches:i(null)};return e.addListener(r),()=>e.removeListener(r)}),[i,t,n]),(0,r.useMemo)((()=>({colorMode:a,setColorMode:i,get isDarkTheme(){return a===d.dark},setLightTheme(){i(d.light)},setDarkTheme(){i(d.dark)}})),[a,i])}();return r.createElement(s.Provider,{value:n},t)}function g(){const e=(0,r.useContext)(s);if(null==e)throw new o.i6("ColorModeProvider","Please see https://docusaurus.io/docs/api/themes/configuration#use-color-mode.");return e}},4453:(e,t,n)=>{"use strict";n.d(t,{J:()=>v,L5:()=>g});var r=n(7378),a=n(6282),o=n(5688),i=n(624),l=n(5161),s=n(1763),u=n(1819);const c=e=>`docs-preferred-version-${e}`,d={save:(e,t,n)=>{(0,u.WA)(c(e),{persistence:t}).set(n)},read:(e,t)=>(0,u.WA)(c(e),{persistence:t}).get(),clear:(e,t)=>{(0,u.WA)(c(e),{persistence:t}).del()}},f=e=>Object.fromEntries(e.map((e=>[e,{preferredVersionName:null}])));const p=r.createContext(null);function m(){const e=(0,a._r)(),t=(0,i.L)().docs.versionPersistence,n=(0,r.useMemo)((()=>Object.keys(e)),[e]),[o,l]=(0,r.useState)((()=>f(n)));(0,r.useEffect)((()=>{l(function(e){let{pluginIds:t,versionPersistence:n,allDocsData:r}=e;function a(e){const t=d.read(e,n);return r[e].versions.some((e=>e.name===t))?{preferredVersionName:t}:(d.clear(e,n),{preferredVersionName:null})}return Object.fromEntries(t.map((e=>[e,a(e)])))}({allDocsData:e,versionPersistence:t,pluginIds:n}))}),[e,t,n]);return[o,(0,r.useMemo)((()=>({savePreferredVersion:function(e,n){d.save(e,t,n),l((t=>({...t,[e]:{preferredVersionName:n}})))}})),[t])]}function h(e){let{children:t}=e;const n=m();return r.createElement(p.Provider,{value:n},t)}function g(e){let{children:t}=e;return l.cE?r.createElement(h,null,t):r.createElement(r.Fragment,null,t)}function b(){const e=(0,r.useContext)(p);if(!e)throw new s.i6("DocsPreferredVersionContextProvider");return e}function v(e){void 0===e&&(e=o.m);const t=(0,a.zh)(e),[n,i]=b(),{preferredVersionName:l}=n[e];return{preferredVersion:t.versions.find((e=>e.name===l))??null,savePreferredVersionName:(0,r.useCallback)((t=>{i.savePreferredVersion(e,t)}),[i,e])}}},2095:(e,t,n)=>{"use strict";n.d(t,{V:()=>s,b:()=>l});var r=n(7378),a=n(1763);const o=Symbol("EmptyContext"),i=r.createContext(o);function l(e){let{children:t,name:n,items:a}=e;const o=(0,r.useMemo)((()=>n&&a?{name:n,items:a}:null),[n,a]);return r.createElement(i.Provider,{value:o},t)}function s(){const e=(0,r.useContext)(i);if(e===o)throw new a.i6("DocsSidebarProvider");return e}},5536:(e,t,n)=>{"use strict";n.d(t,{M:()=>d,e:()=>f});var r=n(7378),a=n(3471),o=n(8357),i=n(654),l=n(624),s=n(1763);const u=r.createContext(void 0);function c(){const e=function(){const e=(0,a.HY)(),{items:t}=(0,l.L)().navbar;return 0===t.length&&!e.component}(),t=(0,o.i)(),n=!e&&"mobile"===t,[s,u]=(0,r.useState)(!1);(0,i.Rb)((()=>{if(s)return u(!1),!1}));const c=(0,r.useCallback)((()=>{u((e=>!e))}),[]);return(0,r.useEffect)((()=>{"desktop"===t&&u(!1)}),[t]),(0,r.useMemo)((()=>({disabled:e,shouldRender:n,toggle:c,shown:s})),[e,n,c,s])}function d(e){let{children:t}=e;const n=c();return r.createElement(u.Provider,{value:n},t)}function f(){const e=r.useContext(u);if(void 0===e)throw new s.i6("NavbarMobileSidebarProvider");return e}},3471:(e,t,n)=>{"use strict";n.d(t,{HY:()=>l,Zo:()=>s,n2:()=>i});var r=n(7378),a=n(1763);const o=r.createContext(null);function i(e){let{children:t}=e;const n=(0,r.useState)({component:null,props:null});return r.createElement(o.Provider,{value:n},t)}function l(){const e=(0,r.useContext)(o);if(!e)throw new a.i6("NavbarSecondaryMenuContentProvider");return e[0]}function s(e){let{component:t,props:n}=e;const i=(0,r.useContext)(o);if(!i)throw new a.i6("NavbarSecondaryMenuContentProvider");const[,l]=i,s=(0,a.Ql)(n);return(0,r.useEffect)((()=>{l({component:t,props:s})}),[l,t,s]),(0,r.useEffect)((()=>()=>l({component:null,props:null})),[l]),null}},174:(e,t,n)=>{"use strict";n.d(t,{h:()=>a,t:()=>o});var r=n(7378);const a="navigation-with-keyboard";function o(){(0,r.useEffect)((()=>{function e(e){"keydown"===e.type&&"Tab"===e.key&&document.body.classList.add(a),"mousedown"===e.type&&document.body.classList.remove(a)}return document.addEventListener("keydown",e),document.addEventListener("mousedown",e),()=>{document.body.classList.remove(a),document.removeEventListener("keydown",e),document.removeEventListener("mousedown",e)}}),[])}},8357:(e,t,n)=>{"use strict";n.d(t,{i:()=>u});var r=n(7378),a=n(161);const o={desktop:"desktop",mobile:"mobile",ssr:"ssr"},i=996;function l(){return a.Z.canUseDOM?window.innerWidth>i?o.desktop:o.mobile:o.ssr}const s=!1;function u(){const[e,t]=(0,r.useState)((()=>s?"ssr":l()));return(0,r.useEffect)((()=>{function e(){t(l())}const n=s?window.setTimeout(e,1e3):void 0;return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),clearTimeout(n)}}),[]),e}},5484:(e,t,n)=>{"use strict";n.d(t,{k:()=>r});const r={page:{blogListPage:"blog-list-page",blogPostPage:"blog-post-page",blogTagsListPage:"blog-tags-list-page",blogTagPostListPage:"blog-tags-post-list-page",docsDocPage:"docs-doc-page",docsTagsListPage:"docs-tags-list-page",docsTagDocListPage:"docs-tags-doc-list-page",mdxPage:"mdx-page"},wrapper:{main:"main-wrapper",blogPages:"blog-wrapper",docsPages:"docs-wrapper",mdxPages:"mdx-wrapper"},common:{editThisPage:"theme-edit-this-page",lastUpdated:"theme-last-updated",backToTopButton:"theme-back-to-top-button",codeBlock:"theme-code-block",admonition:"theme-admonition",admonitionType:e=>`theme-admonition-${e}`},layout:{},docs:{docVersionBanner:"theme-doc-version-banner",docVersionBadge:"theme-doc-version-badge",docBreadcrumbs:"theme-doc-breadcrumbs",docMarkdown:"theme-doc-markdown",docTocMobile:"theme-doc-toc-mobile",docTocDesktop:"theme-doc-toc-desktop",docFooter:"theme-doc-footer",docFooterTagsRow:"theme-doc-footer-tags-row",docFooterEditMetaRow:"theme-doc-footer-edit-meta-row",docSidebarContainer:"theme-doc-sidebar-container",docSidebarMenu:"theme-doc-sidebar-menu",docSidebarItemCategory:"theme-doc-sidebar-item-category",docSidebarItemLink:"theme-doc-sidebar-item-link",docSidebarItemCategoryLevel:e=>`theme-doc-sidebar-item-category-level-${e}`,docSidebarItemLinkLevel:e=>`theme-doc-sidebar-item-link-level-${e}`},blog:{}}},6903:(e,t,n)=>{"use strict";function r(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}n.d(t,{n:()=>r})},5161:(e,t,n)=>{"use strict";n.d(t,{Wl:()=>f,_F:()=>h,cE:()=>d,hI:()=>k,lO:()=>v,oz:()=>y,s1:()=>b,vY:()=>w});var r=n(7378),a=n(3620),o=n(5473),i=n(6282),l=n(4453),s=n(2095),u=n(784),c=n(8862);const d=!!i._r;function f(e){if(e.href)return e.href;for(const t of e.items){if("link"===t.type)return t.href;if("category"===t.type){const e=f(t);if(e)return e}}}const p=(e,t)=>void 0!==e&&(0,c.Mg)(e,t),m=(e,t)=>e.some((e=>h(e,t)));function h(e,t){return"link"===e.type?p(e.href,t):"category"===e.type&&(p(e.href,t)||m(e.items,t))}function g(e){let{sidebarItems:t,pathname:n,onlyCategories:r=!1}=e;const a=[];return function e(t){for(const o of t)if("category"===o.type&&((0,c.Mg)(o.href,n)||e(o.items))||"link"===o.type&&(0,c.Mg)(o.href,n)){return r&&"category"!==o.type||a.unshift(o),!0}return!1}(t),a}function b(){const e=(0,s.V)(),{pathname:t}=(0,a.TH)(),n=(0,i.gA)()?.pluginData.breadcrumbs;return!1!==n&&e?g({sidebarItems:e.items,pathname:t}):null}function v(e){const{activeVersion:t}=(0,i.Iw)(e),{preferredVersion:n}=(0,l.J)(e),a=(0,i.yW)(e);return(0,r.useMemo)((()=>(0,u.j)([t,n,a].filter(Boolean))),[t,n,a])}function y(e,t){const n=v(t);return(0,r.useMemo)((()=>{const t=n.flatMap((e=>e.sidebars?Object.entries(e.sidebars):[])),r=t.find((t=>t[0]===e));if(!r)throw new Error(`Can't find any sidebar with id "${e}" in version${n.length>1?"s":""} ${n.map((e=>e.name)).join(", ")}".\nAvailable sidebar ids are:\n- ${t.map((e=>e[0])).join("\n- ")}`);return r[1]}),[e,n])}function w(e,t){const n=v(t);return(0,r.useMemo)((()=>{const t=n.flatMap((e=>e.docs)),r=t.find((t=>t.id===e));if(!r){if(n.flatMap((e=>e.draftIds)).includes(e))return null;throw new Error(`Couldn't find any doc with id "${e}" in version${n.length>1?"s":""} "${n.map((e=>e.name)).join(", ")}".\nAvailable doc ids are:\n- ${(0,u.j)(t.map((e=>e.id))).join("\n- ")}`)}return r}),[e,n])}function k(e){let{route:t,versionMetadata:n}=e;const r=(0,a.TH)(),i=t.routes,l=i.find((e=>(0,a.LX)(r.pathname,e)));if(!l)return null;const s=l.sidebar,u=s?n.docsSidebars[s]:void 0;return{docElement:(0,o.H)(i),sidebarName:s,sidebarItems:u}}},654:(e,t,n)=>{"use strict";n.d(t,{Rb:()=>l,_X:()=>s});var r=n(7378),a=n(3620),o=n(644),i=n(1763);function l(e){!function(e){const t=(0,a.k6)(),n=(0,i.zX)(e);(0,r.useEffect)((()=>t.block(((e,t)=>n(e,t)))),[t,n])}(((t,n)=>{if("POP"===n)return e(t,n)}))}function s(e){return function(e){const t=(0,a.k6)();return(0,o.useSyncExternalStore)(t.listen,(()=>e(t)),(()=>e(t)))}((t=>null===e?null:new URLSearchParams(t.location.search).get(e)))}},784:(e,t,n)=>{"use strict";function r(e,t){return void 0===t&&(t=(e,t)=>e===t),e.filter(((n,r)=>e.findIndex((e=>t(e,n)))!==r))}function a(e){return Array.from(new Set(e))}n.d(t,{j:()=>a,l:()=>r})},8831:(e,t,n)=>{"use strict";n.d(t,{FG:()=>f,d:()=>c,VC:()=>p});var r=n(7378),a=n(8944),o=n(7092),i=n(6881);function l(){const e=r.useContext(i._);if(!e)throw new Error("Unexpected: no Docusaurus route context found");return e}var s=n(8948),u=n(353);function c(e){let{title:t,description:n,keywords:a,image:i,children:l}=e;const c=function(e){const{siteConfig:t}=(0,u.Z)(),{title:n,titleDelimiter:r}=t;return e?.trim().length?`${e.trim()} ${r} ${n}`:n}(t),{withBaseUrl:d}=(0,s.C)(),f=i?d(i,{absolute:!0}):void 0;return r.createElement(o.Z,null,t&&r.createElement("title",null,c),t&&r.createElement("meta",{property:"og:title",content:c}),n&&r.createElement("meta",{name:"description",content:n}),n&&r.createElement("meta",{property:"og:description",content:n}),a&&r.createElement("meta",{name:"keywords",content:Array.isArray(a)?a.join(","):a}),f&&r.createElement("meta",{property:"og:image",content:f}),f&&r.createElement("meta",{name:"twitter:image",content:f}),l)}const d=r.createContext(void 0);function f(e){let{className:t,children:n}=e;const i=r.useContext(d),l=(0,a.Z)(i,t);return r.createElement(d.Provider,{value:l},r.createElement(o.Z,null,r.createElement("html",{className:l})),n)}function p(e){let{children:t}=e;const n=l(),o=`plugin-${n.plugin.name.replace(/docusaurus-(?:plugin|theme)-(?:content-)?/gi,"")}`;const i=`plugin-id-${n.plugin.id}`;return r.createElement(f,{className:(0,a.Z)(o,i)},t)}},1763:(e,t,n)=>{"use strict";n.d(t,{D9:()=>i,Qc:()=>u,Ql:()=>s,i6:()=>l,zX:()=>o});var r=n(7378);const a=n(161).Z.canUseDOM?r.useLayoutEffect:r.useEffect;function o(e){const t=(0,r.useRef)(e);return a((()=>{t.current=e}),[e]),(0,r.useCallback)((function(){return t.current(...arguments)}),[])}function i(e){const t=(0,r.useRef)();return a((()=>{t.current=e})),t.current}class l extends Error{constructor(e,t){super(),this.name="ReactContextError",this.message=`Hook ${this.stack?.split("\n")[1]?.match(/at (?:\w+\.)?(?\w+)/)?.groups.name??""} is called outside the <${e}>. ${t??""}`}}function s(e){const t=Object.entries(e);return t.sort(((e,t)=>e[0].localeCompare(t[0]))),(0,r.useMemo)((()=>e),t.flat())}function u(e){return t=>{let{children:n}=t;return r.createElement(r.Fragment,null,e.reduceRight(((e,t)=>r.createElement(t,null,e)),n))}}},8862:(e,t,n)=>{"use strict";n.d(t,{Mg:()=>i,Ns:()=>l});var r=n(7378),a=n(6623),o=n(353);function i(e,t){const n=e=>(!e||e.endsWith("/")?e:`${e}/`)?.toLowerCase();return n(e)===n(t)}function l(){const{baseUrl:e}=(0,o.Z)().siteConfig;return(0,r.useMemo)((()=>function(e){let{baseUrl:t,routes:n}=e;function r(e){return e.path===t&&!0===e.exact}function a(e){return e.path===t&&!e.exact}return function e(t){if(0===t.length)return;return t.find(r)||e(t.filter(a).flatMap((e=>e.routes??[])))}(n)}({routes:a.Z,baseUrl:e})),[e])}},3457:(e,t,n)=>{"use strict";n.d(t,{Ct:()=>p,OC:()=>s,RF:()=>d,o5:()=>f});var r=n(7378),a=n(161),o=n(6457),i=n(1763);const l=r.createContext(void 0);function s(e){let{children:t}=e;const n=function(){const e=(0,r.useRef)(!0);return(0,r.useMemo)((()=>({scrollEventsEnabledRef:e,enableScrollEvents:()=>{e.current=!0},disableScrollEvents:()=>{e.current=!1}})),[])}();return r.createElement(l.Provider,{value:n},t)}function u(){const e=(0,r.useContext)(l);if(null==e)throw new i.i6("ScrollControllerProvider");return e}const c=()=>a.Z.canUseDOM?{scrollX:window.pageXOffset,scrollY:window.pageYOffset}:null;function d(e,t){void 0===t&&(t=[]);const{scrollEventsEnabledRef:n}=u(),a=(0,r.useRef)(c()),o=(0,i.zX)(e);(0,r.useEffect)((()=>{const e=()=>{if(!n.current)return;const e=c();o(e,a.current),a.current=e},t={passive:!0};return e(),window.addEventListener("scroll",e,t),()=>window.removeEventListener("scroll",e,t)}),[o,n,...t])}function f(){const e=u(),t=function(){const e=(0,r.useRef)({elem:null,top:0}),t=(0,r.useCallback)((t=>{e.current={elem:t,top:t.getBoundingClientRect().top}}),[]),n=(0,r.useCallback)((()=>{const{current:{elem:t,top:n}}=e;if(!t)return{restored:!1};const r=t.getBoundingClientRect().top-n;return r&&window.scrollBy({left:0,top:r}),e.current={elem:null,top:0},{restored:0!==r}}),[]);return(0,r.useMemo)((()=>({save:t,restore:n})),[n,t])}(),n=(0,r.useRef)(void 0),a=(0,r.useCallback)((r=>{t.save(r),e.disableScrollEvents(),n.current=()=>{const{restored:r}=t.restore();if(n.current=void 0,r){const t=()=>{e.enableScrollEvents(),window.removeEventListener("scroll",t)};window.addEventListener("scroll",t)}else e.enableScrollEvents()}}),[e,t]);return(0,r.useLayoutEffect)((()=>{queueMicrotask((()=>n.current?.()))})),{blockElementScrollPositionUntilNextRender:a}}function p(){const e=(0,r.useRef)(null),t=(0,o.Z)()&&"smooth"===getComputedStyle(document.documentElement).scrollBehavior;return{startScroll:n=>{e.current=t?function(e){return window.scrollTo({top:e,behavior:"smooth"}),()=>{}}(n):function(e){let t=null;const n=document.documentElement.scrollTop>e;return function r(){const a=document.documentElement.scrollTop;(n&&a>e||!n&&a t&&cancelAnimationFrame(t)}(n)},cancelScroll:()=>e.current?.()}}},3149:(e,t,n)=>{"use strict";n.d(t,{HX:()=>r,os:()=>a});n(353);const r="default";function a(e,t){return`docs-${e}-${t}`}},1819:(e,t,n)=>{"use strict";n.d(t,{Nk:()=>d,WA:()=>c});var r=n(7378),a=n(644);const o="localStorage";function i(e){let{key:t,oldValue:n,newValue:r,storage:a}=e;if(n===r)return;const o=document.createEvent("StorageEvent");o.initStorageEvent("storage",!1,!1,t,n,r,window.location.href,a),window.dispatchEvent(o)}function l(e){if(void 0===e&&(e=o),"undefined"==typeof window)throw new Error("Browser storage is not available on Node.js/Docusaurus SSR process.");if("none"===e)return null;try{return window[e]}catch(n){return t=n,s||(console.warn("Docusaurus browser storage is not available.\nPossible reasons: running Docusaurus in an iframe, in an incognito browser session, or using too strict browser privacy settings.",t),s=!0),null}var t}let s=!1;const u={get:()=>null,set:()=>{},del:()=>{},listen:()=>()=>{}};function c(e,t){if("undefined"==typeof window)return function(e){function t(){throw new Error(`Illegal storage API usage for storage key "${e}".\nDocusaurus storage APIs are not supposed to be called on the server-rendering process.\nPlease only call storage APIs in effects and event handlers.`)}return{get:t,set:t,del:t,listen:t}}(e);const n=l(t?.persistence);return null===n?u:{get:()=>{try{return n.getItem(e)}catch(t){return console.error(`Docusaurus storage error, can't get key=${e}`,t),null}},set:t=>{try{const r=n.getItem(e);n.setItem(e,t),i({key:e,oldValue:r,newValue:t,storage:n})}catch(r){console.error(`Docusaurus storage error, can't set ${e}=${t}`,r)}},del:()=>{try{const t=n.getItem(e);n.removeItem(e),i({key:e,oldValue:t,newValue:null,storage:n})}catch(t){console.error(`Docusaurus storage error, can't delete key=${e}`,t)}},listen:t=>{try{const r=r=>{r.storageArea===n&&r.key===e&&t(r)};return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)}catch(r){return console.error(`Docusaurus storage error, can't listen for changes of key=${e}`,r),()=>{}}}}}function d(e,t){const n=(0,r.useRef)((()=>null===e?u:c(e,t))).current(),o=(0,r.useCallback)((e=>"undefined"==typeof window?()=>{}:n.listen(e)),[n]);return[(0,a.useSyncExternalStore)(o,(()=>"undefined"==typeof window?null:n.get()),(()=>null)),n]}},3714:(e,t,n)=>{"use strict";n.d(t,{l:()=>o});var r=n(353),a=n(3620);function o(){const{siteConfig:{baseUrl:e,url:t},i18n:{defaultLocale:n,currentLocale:o}}=(0,r.Z)(),{pathname:i}=(0,a.TH)(),l=o===n?e:e.replace(`/${o}/`,"/"),s=i.replace(e,"");return{createUrl:function(e){let{locale:r,fullyQualified:a}=e;return`${a?t:""}${function(e){return e===n?`${l}`:`${l}${e}/`}(r)}${s}`}}}},4993:(e,t,n)=>{"use strict";n.d(t,{S:()=>i});var r=n(7378),a=n(3620),o=n(1763);function i(e){const t=(0,a.TH)(),n=(0,o.D9)(t),i=(0,o.zX)(e);(0,r.useEffect)((()=>{n&&t!==n&&i({location:t,previousLocation:n})}),[i,t,n])}},624:(e,t,n)=>{"use strict";n.d(t,{L:()=>a});var r=n(353);function a(){return(0,r.Z)().siteConfig.themeConfig}},2520:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){const{trailingSlash:n,baseUrl:r}=t;if(e.startsWith("#"))return e;if(void 0===n)return e;const[a]=e.split(/[#?]/),o="/"===a||a===r?a:(i=a,n?function(e){return e.endsWith("/")?e:`${e}/`}(i):function(e){return e.endsWith("/")?e.slice(0,-1):e}(i));var i;return e.replace(a,o)}},6102:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorCausalChain=void 0,t.getErrorCausalChain=function e(t){return t.cause?[t,...e(t.cause)]:[t]}},1721:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorCausalChain=t.applyTrailingSlash=t.blogPostContainerID=void 0,t.blogPostContainerID="__blog-post-container";var a=n(2520);Object.defineProperty(t,"applyTrailingSlash",{enumerable:!0,get:function(){return r(a).default}});var o=n(6102);Object.defineProperty(t,"getErrorCausalChain",{enumerable:!0,get:function(){return o.getErrorCausalChain}})},42:(e,t)=>{var n;!function(){"use strict";var r={}.hasOwnProperty;function a(){for(var e=[],t=0;t {"use strict";function r(e){var t,n,a="";if("string"==typeof e||"number"==typeof e)a+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t a});const a=function(){for(var e,t,n=0,a="";n {"use strict";n.d(t,{lX:()=>w,q_:()=>C,ob:()=>p,PP:()=>A,Ep:()=>f});var r=n(5773);function a(e){return"/"===e.charAt(0)}function o(e,t){for(var n=t,r=n+1,a=e.length;r=0;f--){var p=i[f];"."===p?o(i,f):".."===p?(o(i,f),d++):d&&(o(i,f),d--)}if(!u)for(;d--;d)i.unshift("..");!u||""===i[0]||i[0]&&a(i[0])||i.unshift("");var m=i.join("/");return n&&"/"!==m.substr(-1)&&(m+="/"),m};var l=n(2215);function s(e){return"/"===e.charAt(0)?e:"/"+e}function u(e){return"/"===e.charAt(0)?e.substr(1):e}function c(e,t){return function(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}(e,t)?e.substr(t.length):e}function d(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function f(e){var t=e.pathname,n=e.search,r=e.hash,a=t||"/";return n&&"?"!==n&&(a+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(a+="#"===r.charAt(0)?r:"#"+r),a}function p(e,t,n,a){var o;"string"==typeof e?(o=function(e){var t=e||"/",n="",r="",a=t.indexOf("#");-1!==a&&(r=t.substr(a),t=t.substr(0,a));var o=t.indexOf("?");return-1!==o&&(n=t.substr(o),t=t.substr(0,o)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}}(e),o.state=t):(void 0===(o=(0,r.Z)({},e)).pathname&&(o.pathname=""),o.search?"?"!==o.search.charAt(0)&&(o.search="?"+o.search):o.search="",o.hash?"#"!==o.hash.charAt(0)&&(o.hash="#"+o.hash):o.hash="",void 0!==t&&void 0===o.state&&(o.state=t));try{o.pathname=decodeURI(o.pathname)}catch(l){throw l instanceof URIError?new URIError('Pathname "'+o.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):l}return n&&(o.key=n),a?o.pathname?"/"!==o.pathname.charAt(0)&&(o.pathname=i(o.pathname,a.pathname)):o.pathname=a.pathname:o.pathname||(o.pathname="/"),o}function m(){var e=null;var t=[];return{setPrompt:function(t){return e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,r,a){if(null!=e){var o="function"==typeof e?e(t,n):e;"string"==typeof o?"function"==typeof r?r(o,a):a(!0):a(!1!==o)}else a(!0)},appendListener:function(e){var n=!0;function r(){n&&e.apply(void 0,arguments)}return t.push(r),function(){n=!1,t=t.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),r=0;r t?n.splice(t,n.length-t,a):n.push(a),d({action:r,location:a,index:t,entries:n})}}))},replace:function(e,t){var r="REPLACE",a=p(e,t,h(),w.location);c.confirmTransitionTo(a,r,n,(function(e){e&&(w.entries[w.index]=a,d({action:r,location:a}))}))},go:y,goBack:function(){y(-1)},goForward:function(){y(1)},canGo:function(e){var t=w.index+e;return t>=0&&t {"use strict";var r=n(9185),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},l={};function s(e){return r.isMemo(e)?i:l[e.$$typeof]||a}l[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},l[r.Memo]=i;var u=Object.defineProperty,c=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,f=Object.getOwnPropertyDescriptor,p=Object.getPrototypeOf,m=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(m){var a=p(n);a&&a!==m&&e(t,a,r)}var i=c(n);d&&(i=i.concat(d(n)));for(var l=s(t),h=s(n),g=0;g {"use strict";e.exports=function(e,t,n,r,a,o,i,l){if(!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,r,a,o,i,l],c=0;(s=new Error(t.replace(/%s/g,(function(){return u[c++]})))).name="Invariant Violation"}throw s.framesToPop=1,s}}},5182:e=>{e.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},6222:(e,t,n)=>{"use strict";n.r(t)},142:(e,t,n)=>{"use strict";n.r(t)},8504:function(e,t,n){var r,a;r=function(){var e,t,n={version:"0.2.0"},r=n.settings={minimum:.08,easing:"ease",positionUsing:"",speed:200,trickle:!0,trickleRate:.02,trickleSpeed:800,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:' '};function a(e,t,n){return en?n:e}function o(e){return 100*(-1+e)}function i(e,t,n){var a;return(a="translate3d"===r.positionUsing?{transform:"translate3d("+o(e)+"%,0,0)"}:"translate"===r.positionUsing?{transform:"translate("+o(e)+"%,0)"}:{"margin-left":o(e)+"%"}).transition="all "+t+"ms "+n,a}n.configure=function(e){var t,n;for(t in e)void 0!==(n=e[t])&&e.hasOwnProperty(t)&&(r[t]=n);return this},n.status=null,n.set=function(e){var t=n.isStarted();e=a(e,r.minimum,1),n.status=1===e?null:e;var o=n.render(!t),u=o.querySelector(r.barSelector),c=r.speed,d=r.easing;return o.offsetWidth,l((function(t){""===r.positionUsing&&(r.positionUsing=n.getPositioningCSS()),s(u,i(e,c,d)),1===e?(s(o,{transition:"none",opacity:1}),o.offsetWidth,setTimeout((function(){s(o,{transition:"all "+c+"ms linear",opacity:0}),setTimeout((function(){n.remove(),t()}),c)}),c)):setTimeout(t,c)})),this},n.isStarted=function(){return"number"==typeof n.status},n.start=function(){n.status||n.set(0);var e=function(){setTimeout((function(){n.status&&(n.trickle(),e())}),r.trickleSpeed)};return r.trickle&&e(),this},n.done=function(e){return e||n.status?n.inc(.3+.5*Math.random()).set(1):this},n.inc=function(e){var t=n.status;return t?("number"!=typeof e&&(e=(1-t)*a(Math.random()*t,.1,.95)),t=a(t+e,0,.994),n.set(t)):n.start()},n.trickle=function(){return n.inc(Math.random()*r.trickleRate)},e=0,t=0,n.promise=function(r){return r&&"resolved"!==r.state()?(0===t&&n.start(),e++,t++,r.always((function(){0==--t?(e=0,n.done()):n.set((e-t)/e)})),this):this},n.render=function(e){if(n.isRendered())return document.getElementById("nprogress");c(document.documentElement,"nprogress-busy");var t=document.createElement("div");t.id="nprogress",t.innerHTML=r.template;var a,i=t.querySelector(r.barSelector),l=e?"-100":o(n.status||0),u=document.querySelector(r.parent);return s(i,{transition:"all 0 linear",transform:"translate3d("+l+"%,0,0)"}),r.showSpinner||(a=t.querySelector(r.spinnerSelector))&&p(a),u!=document.body&&c(u,"nprogress-custom-parent"),u.appendChild(t),t},n.remove=function(){d(document.documentElement,"nprogress-busy"),d(document.querySelector(r.parent),"nprogress-custom-parent");var e=document.getElementById("nprogress");e&&p(e)},n.isRendered=function(){return!!document.getElementById("nprogress")},n.getPositioningCSS=function(){var e=document.body.style,t="WebkitTransform"in e?"Webkit":"MozTransform"in e?"Moz":"msTransform"in e?"ms":"OTransform"in e?"O":"";return t+"Perspective"in e?"translate3d":t+"Transform"in e?"translate":"margin"};var l=function(){var e=[];function t(){var n=e.shift();n&&n(t)}return function(n){e.push(n),1==e.length&&t()}}(),s=function(){var e=["Webkit","O","Moz","ms"],t={};function n(e){return e.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,(function(e,t){return t.toUpperCase()}))}function r(t){var n=document.body.style;if(t in n)return t;for(var r,a=e.length,o=t.charAt(0).toUpperCase()+t.slice(1);a--;)if((r=e[a]+o)in n)return r;return t}function a(e){return e=n(e),t[e]||(t[e]=r(e))}function o(e,t,n){t=a(t),e.style[t]=n}return function(e,t){var n,r,a=arguments;if(2==a.length)for(n in t)void 0!==(r=t[n])&&t.hasOwnProperty(n)&&o(e,n,r);else o(e,a[1],a[2])}}();function u(e,t){return("string"==typeof e?e:f(e)).indexOf(" "+t+" ")>=0}function c(e,t){var n=f(e),r=n+t;u(n,t)||(e.className=r.substring(1))}function d(e,t){var n,r=f(e);u(e,t)&&(n=r.replace(" "+t+" "," "),e.className=n.substring(1,n.length-1))}function f(e){return(" "+(e.className||"")+" ").replace(/\s+/gi," ")}function p(e){e&&e.parentNode&&e.parentNode.removeChild(e)}return n},void 0===(a="function"==typeof r?r.call(t,n,t,e):r)||(e.exports=a)},2525:e=>{"use strict";var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(a){return!1}}()?Object.assign:function(e,a){for(var o,i,l=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),s=1;s {"use strict";n.d(t,{Z:()=>o});var r=function(){var e=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,t=0,n={},r={util:{encode:function e(t){return t instanceof a?new a(t.type,e(t.content),t.alias):Array.isArray(t)?t.map(e):t.replace(/&/g,"&").replace(/=d.reach);S+=E.value.length,E=E.next){var x=E.value;if(t.length>e.length)return;if(!(x instanceof a)){var _,C=1;if(v){if(!(_=o(k,S,e,b))||_.index>=e.length)break;var T=_.index,A=_.index+_[0].length,L=S;for(L+=E.value.length;T>=L;)L+=(E=E.next).value.length;if(S=L-=E.value.length,E.value instanceof a)continue;for(var N=E;N!==t.tail&&(Ld.reach&&(d.reach=I);var D=E.prev;if(P&&(D=s(t,D,P),S+=P.length),u(t,D,C),E=s(t,D,new a(f,g?r.tokenize(R,g):R,y,R)),O&&s(t,E,O),C>1){var M={cause:f+","+m,reach:I};i(e,t,n,E.prev,S,M),d&&M.reach>d.reach&&(d.reach=M.reach)}}}}}}function l(){var e={value:null,prev:null,next:null},t={value:null,prev:e,next:null};e.next=t,this.head=e,this.tail=t,this.length=0}function s(e,t,n){var r=t.next,a={value:n,prev:t,next:r};return t.next=a,r.prev=a,e.length++,a}function u(e,t,n){for(var r=t.next,a=0;a "+o.content+""+o.tag+">"},r}(),a=r;r.default=r,a.languages.markup={comment:{pattern://,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern://i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/?[\da-f]{1,8};/i]},a.languages.markup.tag.inside["attr-value"].inside.entity=a.languages.markup.entity,a.languages.markup.doctype.inside["internal-subset"].inside=a.languages.markup,a.hooks.add("wrap",(function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))})),Object.defineProperty(a.languages.markup.tag,"addInlined",{value:function(e,t){var n={};n["language-"+t]={pattern:/(^$)/i,lookbehind:!0,inside:a.languages[t]},n.cdata=/^$/i;var r={"included-cdata":{pattern://i,inside:n}};r["language-"+t]={pattern:/[\s\S]+/,inside:a.languages[t]};var o={};o[e]={pattern:RegExp(/(<__[^>]*>)(?:))*\]\]>|(?!)/.source.replace(/__/g,(function(){return e})),"i"),lookbehind:!0,greedy:!0,inside:r},a.languages.insertBefore("markup","cdata",o)}}),Object.defineProperty(a.languages.markup.tag,"addAttribute",{value:function(e,t){a.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+e+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:a.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),a.languages.html=a.languages.markup,a.languages.mathml=a.languages.markup,a.languages.svg=a.languages.markup,a.languages.xml=a.languages.extend("markup",{}),a.languages.ssml=a.languages.xml,a.languages.atom=a.languages.xml,a.languages.rss=a.languages.xml,function(e){var t="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+t),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+t),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+t),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+t),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var a=["comment","function-name","for-or-select","assign-left","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],o=r.variable[1].inside,i=0;i ]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},a.languages.c=a.languages.extend("clike",{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/}),a.languages.insertBefore("c","string",{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),a.languages.insertBefore("c","string",{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:"property",inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},a.languages.c.string],char:a.languages.c.char,comment:a.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:"function"}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:"keyword"},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:a.languages.c}}}}),a.languages.insertBefore("c","function",{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/}),delete a.languages.c.boolean,function(e){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,n=/\b(?! )\w+(?:\s*\.\s*\w+)*\b/.source.replace(/ /g,(function(){return t.source}));e.languages.cpp=e.languages.extend("c",{"class-name":[{pattern:RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?! )\w+/.source.replace(/ /g,(function(){return t.source}))),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),e.languages.insertBefore("cpp","string",{module:{pattern:RegExp(/(\b(?:import|module)\s+)/.source+"(?:"+/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source+"|"+/ (?:\s*:\s* )?|:\s* /.source.replace(/ /g,(function(){return n}))+")"),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}}),e.languages.insertBefore("cpp","keyword",{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:e.languages.cpp}}}}),e.languages.insertBefore("cpp","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}}),e.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:e.languages.extend("cpp",{})}}),e.languages.insertBefore("inside","double-colon",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},e.languages.cpp["base-clause"])}(a),function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/,inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp("(^|[{}\\s])[^{}\\s](?:[^{};\"'\\s]|\\s+(?![\\s{])|"+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))}(a),function(e){var t,n=/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;e.languages.css.selector={pattern:e.languages.css.selector.pattern,lookbehind:!0,inside:t={"pseudo-element":/:(?:after|before|first-letter|first-line|selection)|::[-\w]+/,"pseudo-class":/:[-\w]+/,class:/\.[-\w]+/,id:/#[-\w]+/,attribute:{pattern:RegExp("\\[(?:[^[\\]\"']|"+n.source+")*\\]"),greedy:!0,inside:{punctuation:/^\[|\]$/,"case-sensitivity":{pattern:/(\s)[si]$/i,lookbehind:!0,alias:"keyword"},namespace:{pattern:/^(\s*)(?:(?!\s)[-*\w\xA0-\uFFFF])*\|(?!=)/,lookbehind:!0,inside:{punctuation:/\|$/}},"attr-name":{pattern:/^(\s*)(?:(?!\s)[-\w\xA0-\uFFFF])+/,lookbehind:!0},"attr-value":[n,{pattern:/(=\s*)(?:(?!\s)[-\w\xA0-\uFFFF])+(?=\s*$)/,lookbehind:!0}],operator:/[|~*^$]?=/}},"n-th":[{pattern:/(\(\s*)[+-]?\d*[\dn](?:\s*[+-]\s*\d+)?(?=\s*\))/,lookbehind:!0,inside:{number:/[\dn]+/,operator:/[+-]/}},{pattern:/(\(\s*)(?:even|odd)(?=\s*\))/i,lookbehind:!0}],combinator:/>|\+|~|\|\|/,punctuation:/[(),]/}},e.languages.css.atrule.inside["selector-function-argument"].inside=t,e.languages.insertBefore("css","property",{variable:{pattern:/(^|[^-\w\xA0-\uFFFF])--(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*/i,lookbehind:!0}});var r={pattern:/(\b\d+)(?:%|[a-z]+(?![\w-]))/,lookbehind:!0},a={pattern:/(^|[^\w.-])-?(?:\d+(?:\.\d+)?|\.\d+)/,lookbehind:!0};e.languages.insertBefore("css","function",{operator:{pattern:/(\s)[+\-*\/](?=\s)/,lookbehind:!0},hexcode:{pattern:/\B#[\da-f]{3,8}\b/i,alias:"color"},color:[{pattern:/(^|[^\w-])(?:AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGr[ae]y|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGr[ae]y|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGr[ae]y|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gr[ae]y|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGr[ae]y|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGr[ae]y|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGr[ae]y|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)(?![\w-])/i,lookbehind:!0},{pattern:/\b(?:hsl|rgb)\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*\)\B|\b(?:hsl|rgb)a\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*(?:0|0?\.\d+|1)\s*\)\B/i,inside:{unit:r,number:a,function:/[\w-]+(?=\()/,punctuation:/[(),]/}}],entity:/\\[\da-f]{1,8}/i,unit:r,number:a})}(a),a.languages.javascript=a.languages.extend("clike",{"class-name":[a.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),a.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,a.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:a.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:a.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:a.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:a.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:a.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),a.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:a.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),a.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),a.languages.markup&&(a.languages.markup.tag.addInlined("script","javascript"),a.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),a.languages.js=a.languages.javascript,function(e){var t=/#(?!\{).+/,n={pattern:/#\{[^}]+\}/,alias:"variable"};e.languages.coffeescript=e.languages.extend("javascript",{comment:t,string:[{pattern:/'(?:\\[\s\S]|[^\\'])*'/,greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,greedy:!0,inside:{interpolation:n}}],keyword:/\b(?:and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,"class-member":{pattern:/@(?!\d)\w+/,alias:"variable"}}),e.languages.insertBefore("coffeescript","comment",{"multiline-comment":{pattern:/###[\s\S]+?###/,alias:"comment"},"block-regex":{pattern:/\/{3}[\s\S]*?\/{3}/,alias:"regex",inside:{comment:t,interpolation:n}}}),e.languages.insertBefore("coffeescript","string",{"inline-javascript":{pattern:/`(?:\\[\s\S]|[^\\`])*`/,inside:{delimiter:{pattern:/^`|`$/,alias:"punctuation"},script:{pattern:/[\s\S]+/,alias:"language-javascript",inside:e.languages.javascript}}},"multiline-string":[{pattern:/'''[\s\S]*?'''/,greedy:!0,alias:"string"},{pattern:/"""[\s\S]*?"""/,greedy:!0,alias:"string",inside:{interpolation:n}}]}),e.languages.insertBefore("coffeescript","keyword",{property:/(?!\d)\w+(?=\s*:(?!:))/}),delete e.languages.coffeescript["template-string"],e.languages.coffee=e.languages.coffeescript}(a),function(e){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ \t]+"+t.source+")?|"+t.source+"(?:[ \t]+"+n.source+")?)",a=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-] )(?:[ \t]*(?:(?![#:]) |: ))*/.source.replace(/ /g,(function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source})),o=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function i(e,t){t=(t||"").replace(/m/g,"")+"m";var n=/([:\-,[{]\s*(?:\s< >[ \t]+)?)(?:< >)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/< >/g,(function(){return r})).replace(/< >/g,(function(){return e}));return RegExp(n,t)}e.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<