@xeno-js/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1971 @@
1
+ import { IPipelineBehavior, IRequest, IExtendendService, IBaseAuthService, IServiceExtractor, HttpHeaders, Optional, ICache, ICacheKeyBuilder, IBaseMapper, AuthClaims, Identity, ICommand, IQuery, IConcurrencyService, IConfigurationService, ILoggerClient, IGateKeeper, IIdempotencyStore, ILogger, IMediator, IMiddleware, IStrategy, IPolicyRegistry, HttpMethod, RequestContext, IServiceResilience, Metadata, IFactory, ITransactionState, IUnitOfWork, IDisposable, IValidatorService, IIdentityAccessor, IContextAccessor, INetworkContextAccessor, UserContext, Factory, IBaseAccessor, AuthConfig, CookieOptions, SetupAction, HttpClientConfig, LogLevel, Dictionary, AuthPolicy, ResponseDto, IHandler, ResultType, ISpecification, CacheConfig, DbConfig, IReadDao, IReadDataSource, IMapper, IRepository, IWriteDataSource, IController, AppError } from '@xeno-js/shared';
2
+ export * from '@xeno-js/shared';
3
+ export { Query as BaseQuery } from '@xeno-js/shared';
4
+ import { SupabaseClientOptions } from '@supabase/supabase-js';
5
+ import { Client } from '@libsql/client/web';
6
+ import { LibSQLDatabase } from 'drizzle-orm/libsql';
7
+ import { NodePgDatabase } from 'drizzle-orm/node-postgres';
8
+ export * from 'drizzle-orm';
9
+ export { Query } from 'drizzle-orm';
10
+
11
+ /**
12
+ * @description This file defines the injection tokens used for dependency injection in the application.
13
+ * Injection tokens are unique identifiers that are used to register and resolve dependencies in the container.
14
+ * They can be symbols, strings, or classes, but using symbols is a common practice to avoid naming collisions.
15
+ *
16
+ * @author Xeno
17
+ * @version 1.0.0
18
+ * @since 2025-09-30
19
+ * @link https://github.com/xeno-js/xeno-js
20
+ */
21
+ interface ApplicationRegistry<T = unknown, Ttx = unknown> {
22
+ readonly ALLOW_ORIGIN: IAllowOrigin;
23
+ readonly ALLOW_METHOD: IAllowMethod;
24
+ /** @description Token used to register and resolve the AuthorizationPipeline instance in the dependency injection container.
25
+ *
26
+ * @author Xeno
27
+ * @version 1.0.0
28
+ * @since 2025-09-30
29
+ * @link https://github.com/xeno-js/xeno-js
30
+ */
31
+ readonly AUTHORIZATION_PIPELINE: IPipelineBehavior<IRequest, unknown>;
32
+ /** @description Token used to register and resolve the AuthService instance in the dependency injection container.
33
+ *
34
+ * @author Xeno
35
+ * @version 1.0.0
36
+ * @since 2025-09-30
37
+ * @link https://github.com/xeno-js/xeno-js
38
+ */
39
+ readonly AUTH_SERVICE: IExtendendService;
40
+ readonly BASE_AUTH_SERVICE: IBaseAuthService;
41
+ /** @description Token used to register and resolve the BearerTokenExtractor instance in the dependency injection container.
42
+ *
43
+ * @author Xeno
44
+ * @version 1.0.0
45
+ * @since 2025-09-30
46
+ * @link https://github.com/xeno-js/xeno-js
47
+ */
48
+ readonly BEARER_TOKEN_EXTRACTOR: IServiceExtractor<HttpHeaders, Optional<string>>;
49
+ /** @description Token used to register and resolve the InMemoryCache instance in the dependency injection container.
50
+ *
51
+ * @author Xeno
52
+ * @version 1.0.0
53
+ * @since 2025-09-30
54
+ * @link https://github.com/xeno-js/xeno-js
55
+ */
56
+ readonly CACHE: ICache;
57
+ /** @description Token used to register and resolve the CacheKeyBuilder instance in the dependency injection container.
58
+ *
59
+ * @author Xeno
60
+ * @version 1.0.0
61
+ * @since 2025-09-30
62
+ * @link https://github.com/xeno-js/xeno-js
63
+ */
64
+ readonly CACHE_KEY_BUILDER: ICacheKeyBuilder;
65
+ /** @description Token used to register and resolve the ClaimsIdentityMapper instance in the dependency injection container.
66
+ *
67
+ * @author Xeno
68
+ * @version 1.0.0
69
+ * @since 2025-09-30
70
+ * @link https://github.com/xeno-js/xeno-js
71
+ */
72
+ readonly CLAIMS_IDENTITY_MAPPER: IBaseMapper<AuthClaims, Identity>;
73
+ /** @description Token used to register and resolve the CommandPipeline behaviors in the dependency injection container.
74
+ *
75
+ * @author Xeno
76
+ * @version 1.0.0
77
+ * @since 2025-09-30
78
+ * @link https://github.com/xeno-js/xeno-js
79
+ */
80
+ readonly COMMAND_PIPELINES_BEHAVIOR: IPipelineBehavior<ICommand, unknown>;
81
+ /** @description Token used to register and resolve the CompositePipeline instance in the dependency injection container.
82
+ *
83
+ * @author Xeno
84
+ * @version 1.0.0
85
+ * @since 2025-09-30
86
+ * @link https://github.com/xeno-js/xeno-js
87
+ */
88
+ readonly COMPOSITE_PIPELINE: IPipelineBehavior<IQuery, unknown>;
89
+ /** @description Token used to register and resolve the ConcurrencyRetryPipeline instance in the dependency injection container.
90
+ *
91
+ * @author Xeno
92
+ * @version 1.0.0
93
+ * @since 2025-09-30
94
+ * @link https://github.com/xeno-js/xeno-js
95
+ */
96
+ readonly CONCURRENCY_RETRY_PIPELINE: IPipelineBehavior<ICommand, unknown>;
97
+ /** @description Token used to register and resolve the ConcurrencyService instance in the dependency injection container.
98
+ *
99
+ * @author Xeno
100
+ * @version 1.0.0
101
+ * @since 2025-09-30
102
+ * @link https://github.com/xeno-js/xeno-js
103
+ */
104
+ readonly CONCURRENCY_SERVICE: IConcurrencyService;
105
+ /** @description Token used to register and resolve the ConfigurationService instance in the dependency injection container.
106
+ *
107
+ * @author Xeno
108
+ * @version 1.0.0
109
+ * @since 2025-09-30
110
+ * @link https://github.com/xeno-js/xeno-js
111
+ */
112
+ readonly CONFIGURATION_SERVICE: IConfigurationService;
113
+ /** @description Token used to register and resolve the ConsoleLogger instance in the dependency injection container.
114
+ *
115
+ * @author Xeno
116
+ * @version 1.0.0
117
+ * @since 2025-09-30
118
+ * @link https://github.com/xeno-js/xeno-js
119
+ */
120
+ readonly CONSOLE_LOGGER: ILoggerClient;
121
+ /** @description Token used to register and resolve the DbContext instance in the dependency injection container.
122
+ *
123
+ * @author Xeno
124
+ * @version 1.0.0
125
+ * @since 2025-09-30
126
+ * @link https://github.com/xeno-js/xeno-js
127
+ */
128
+ readonly DB_CONTEXT: T;
129
+ /** @description Token used to register and resolve the ExceptionPipeline instance in the dependency injection container.
130
+ *
131
+ * @author Xeno
132
+ * @version 1.0.0
133
+ * @since 2025-09-30
134
+ * @link https://github.com/xeno-js/xeno-js
135
+ */
136
+ readonly EXCEPTION_PIPELINE: IPipelineBehavior<IRequest, unknown>;
137
+ /** @description Token used to register and resolve the GateKeeper instance in the dependency injection container.
138
+ *
139
+ * @author Xeno
140
+ * @version 1.0.0
141
+ * @since 2025-09-30
142
+ * @link https://github.com/xeno-js/xeno-js
143
+ */
144
+ readonly GATE_KEEPER: IGateKeeper;
145
+ /** @description Token used to register and resolve the IdempotencyPipeline instance in the dependency injection container.
146
+ *
147
+ * @author Xeno
148
+ * @version 1.0.0
149
+ * @since 2025-09-30
150
+ * @link https://github.com/xeno-js/xeno-js
151
+ */
152
+ readonly IDEMPOTENCY_PIPELINE: IPipelineBehavior<ICommand, unknown>;
153
+ /** @description Token used to register and resolve the IdempotencyStore instance in the dependency injection container.
154
+ *
155
+ * @author Xeno
156
+ * @version 1.0.0
157
+ * @since 2025-09-30
158
+ * @link https://github.com/xeno-js/xeno-js
159
+ */
160
+ readonly IDEMPOTENCY_STORE: IIdempotencyStore;
161
+ /** @description Token used to register and resolve the Logger instance in the dependency injection container.
162
+ *
163
+ * @author Xeno
164
+ * @version 1.0.0
165
+ * @since 2025-09-30
166
+ * @link https://github.com/xeno-js/xeno-js
167
+ */
168
+ readonly LOGGER: ILogger;
169
+ /** @description Token used to register and resolve the LoggingPipeline instance in the dependency injection container.
170
+ *
171
+ * @author Xeno
172
+ * @version 1.0.0
173
+ * @since 2025-09-30
174
+ * @link https://github.com/xeno-js/xeno-js
175
+ */
176
+ readonly LOGGING_PIPELINE: IPipelineBehavior<IRequest, unknown>;
177
+ /** @description Token used to register and resolve the Mediator instance in the dependency injection container.
178
+ *
179
+ * @author Xeno
180
+ * @version 1.0.0
181
+ * @since 2025-09-30
182
+ * @link https://github.com/xeno-js/xeno-js
183
+ */
184
+ readonly MEDIATOR: IMediator;
185
+ /** @description Token used to register and resolve the RequestContextMiddleware in the dependency injection container.
186
+ *
187
+ * @author Xeno
188
+ * @version 1.0.0
189
+ * @since 2025-09-30
190
+ * @link https://github.com/xeno-js/xeno-js
191
+ */
192
+ readonly MIDDLEWARE: IMiddleware<HttpHeaders>;
193
+ readonly AUTH_MIDDLEWARE: IMiddleware<HttpHeaders>;
194
+ readonly CSRF_MIDDLEWARE: IMiddleware<HttpHeaders>;
195
+ readonly ALLOW_ORIGIN_MIDDLEWARE: IMiddleware<HttpHeaders>;
196
+ readonly CORS_MIDDLEWARE: IMiddleware<HttpHeaders>;
197
+ readonly METHOD_CHECK_MIDDLEWARE: IMiddleware<HttpHeaders>;
198
+ readonly OPTIONS_MIDDLEWARE: IMiddleware<HttpHeaders>;
199
+ readonly REQUEST_CONTEXT_MIDDLEWARE: IMiddleware<HttpHeaders>;
200
+ readonly RATE_LIMITER_MIDDLEWARE: IMiddleware<HttpHeaders>;
201
+ /** @description Token used to register and resolve the PerformancePipeline instance in the dependency injection container.
202
+ *
203
+ * @author Xeno
204
+ * @version 1.0.0
205
+ * @since 2025-09-30
206
+ * @link https://github.com/xeno-js/xeno-js
207
+ */
208
+ readonly PERFORMANCE_PIPELINE: IPipelineBehavior<IRequest, unknown>;
209
+ /** @description Token used to register and resolve the PermissionAuthorizationPipeline instance in the dependency injection container.
210
+ *
211
+ * @author Xeno
212
+ * @version 1.0.0
213
+ * @since 2025-09-30
214
+ * @link https://github.com/xeno-js/xeno-js
215
+ */
216
+ readonly PERMISSION_AUTHORIZATION_PIPELINE: IStrategy<IRequest>;
217
+ /** @description Token used to register and resolve the PinoLogger instance in the dependency injection container.
218
+ *
219
+ * @author Xeno
220
+ * @version 1.0.0
221
+ * @since 2025-09-30
222
+ * @link https://github.com/xeno-js/xeno-js
223
+ */
224
+ readonly PINO_LOGGER: ILoggerClient;
225
+ /** @description Token used to register and resolve the PolicyRegistry instance in the dependency injection container.
226
+ *
227
+ * @author Xeno
228
+ * @version 1.0.0
229
+ * @since 2025-09-30
230
+ * @link https://github.com/xeno-js/xeno-js
231
+ */
232
+ readonly POLICY_REGISTRY: IPolicyRegistry;
233
+ /** @description Token used to register and resolve the QueryCachingPipeline instance in the dependency injection container.
234
+ *
235
+ * @author Xeno
236
+ * @version 1.0.0
237
+ * @since 2025-09-30
238
+ * @link https://github.com/xeno-js/xeno-js
239
+ */
240
+ readonly QUERY_CACHING_PIPELINE: IPipelineBehavior<IQuery, unknown>;
241
+ /** @description Token used to register and resolve the QueryPipeline behaviors in the dependency injection container.
242
+ *
243
+ * @author Xeno
244
+ * @version 1.0.0
245
+ * @since 2025-09-30
246
+ * @link https://github.com/xeno-js/xeno-js
247
+ */
248
+ readonly QUERY_PIPELINES_BEHAVIOR: IPipelineBehavior<IQuery, unknown>;
249
+ /** @description Token used to register and resolve the RoutesRegistry instance in the dependency injection container.
250
+ *
251
+ * @author Xeno
252
+ * @version 1.0.0
253
+ * @since 2025-09-30
254
+ * @link https://github.com/xeno-js/xeno-js
255
+ */
256
+ readonly REGISTRY_ROUTES: Record<`/${string}`, Record<HttpMethod, 'isPublic'>>;
257
+ /** @description Token used to register and resolve the RequestContext instance in the dependency injection container.
258
+ *
259
+ * @author Xeno
260
+ * @version 1.0.0
261
+ * @since 2025-09-30
262
+ * @link https://github.com/xeno-js/xeno-js
263
+ */
264
+ readonly REQUEST_CONTEXT: IRequestContext<RequestContext, ApplicationRegistry<T>>;
265
+ /** @description Token used to register and resolve the IServiceResilience instance in the dependency injection container.
266
+ *
267
+ * @author Xeno
268
+ * @version 1.0.0
269
+ * @since 2025-09-30
270
+ * @link https://github.com/xeno-js/xeno-js
271
+ */
272
+ readonly RESILIENCE_CLIENT: IServiceResilience;
273
+ /** @description Token used to register and resolve the RoleAuthorizationPipeline instance in the dependency injection container.
274
+ *
275
+ * @author Xeno
276
+ * @version 1.0.0
277
+ * @since 2025-09-30
278
+ * @link https://github.com/xeno-js/xeno-js
279
+ */
280
+ readonly ROLE_AUTHORIZATION_PIPELINE: IStrategy<IRequest>;
281
+ /** @description Token used to register and resolve the SchemaValidationStrategy instance in the dependency injection container.
282
+ *
283
+ * @author Xeno
284
+ * @version 1.0.0
285
+ * @since 2025-09-30
286
+ * @link https://github.com/xeno-js/xeno-js
287
+ */
288
+ readonly SCHEMA_VALIDATION_STRATEGY: IStrategy<IRequest, boolean>;
289
+ /** @description Token used to register and resolve the SentryLogger instance in the dependency injection container.
290
+ *
291
+ * @author Xeno
292
+ * @version 1.0.0
293
+ * @since 2025-09-30
294
+ * @link https://github.com/xeno-js/xeno-js
295
+ */
296
+ readonly SENTRY_LOGGER: ILoggerClient;
297
+ /** @description Token used to register and resolve the ServiceContainer instance in the dependency injection container.
298
+ *
299
+ * @author Xeno
300
+ * @version 1.0.0
301
+ * @since 2025-09-30
302
+ * @link https://github.com/xeno-js/xeno-js
303
+ */
304
+ readonly SERVICE_CONTAINER: IServiceContainer;
305
+ /** @description Token used to register and resolve the ServiceExtractor instance in the dependency injection container.
306
+ *
307
+ * @author Xeno
308
+ * @version 1.0.0
309
+ * @since 2025-09-30
310
+ * @link https://github.com/xeno-js/xeno-js
311
+ */
312
+ readonly SERVICE_EXTRACTOR: IServiceExtractor<HttpHeaders, Metadata>;
313
+ /** @description Token used to register and resolve the ServiceScopeFactory instance in the dependency injection container.
314
+ *
315
+ * @author Xeno
316
+ * @version 1.0.0
317
+ * @since 2025-09-30
318
+ * @link https://github.com/xeno-js/xeno-js
319
+ */
320
+ readonly SERVICE_SCOPE_FACTORY: IFactory<void, IServiceScope>;
321
+ /** @description Token used to register and resolve the TenantAuthorizationPipeline instance in the dependency injection container.
322
+ *
323
+ * @author Xeno
324
+ * @version 1.0.0
325
+ * @since 2025-09-30
326
+ * @link https://github.com/xeno-js/xeno-js
327
+ */
328
+ readonly TENANT_AUTHORIZATION_PIPELINE: IStrategy<IRequest>;
329
+ /** @description Token used to register and resolve the TransactionState instance in the dependency injection container.
330
+ *
331
+ * @author Xeno
332
+ * @version 1.0.0
333
+ * @since 2025-09-30
334
+ * @link https://github.com/xeno-js/xeno-js
335
+ */
336
+ readonly TRANSACTION_STATE: ITransactionState<Ttx>;
337
+ /** @description Token used to register and resolve the UnitOfWork instance in the dependency injection container.
338
+ *
339
+ * @author Xeno
340
+ * @version 1.0.0
341
+ * @since 2025-09-30
342
+ * @link https://github.com/xeno-js/xeno-js
343
+ */
344
+ readonly UNIT_OF_WORK: IUnitOfWork & IDisposable;
345
+ /** @description Token used to register and resolve the UserAuthorizationPipeline instance in the dependency injection container.
346
+ *
347
+ * @author Xeno
348
+ * @version 1.0.0
349
+ * @since 2025-09-30
350
+ * @link https://github.com/xeno-js/xeno-js
351
+ */
352
+ readonly USER_AUTHORIZATION_PIPELINE: IStrategy<IRequest>;
353
+ /** @description Token used to register and resolve the ValidationPipeline instance in the dependency injection container.
354
+ *
355
+ * @author Xeno
356
+ * @version 1.0.0
357
+ * @since 2025-09-30
358
+ * @link https://github.com/xeno-js/xeno-js
359
+ */
360
+ readonly VALIDATION_PIPELINE: IPipelineBehavior<IRequest, unknown>;
361
+ /** @description Token used to register and resolve the ZodValidator instance in the dependency injection container.
362
+ *
363
+ * @author Xeno
364
+ * @version 1.0.0
365
+ * @since 2025-09-30
366
+ * @link https://github.com/xeno-js/xeno-js
367
+ */
368
+ readonly ZOD_VALIDATOR: IValidatorService;
369
+ /** @description Token used to register and resolve the IIdentityAccessor in the dependency injection container, allowing access only to current user identity information.
370
+ *
371
+ * @author Xeno
372
+ * @version 1.0.0
373
+ * @since 2025-09-30
374
+ * @link https://github.com/xeno-js/xeno-js
375
+ */
376
+ readonly IDENTITY_ACCESSOR: IIdentityAccessor;
377
+ /** @description Token used to register and resolve the IServiceScopeAccessor in the dependency injection container, granting controlled access to the current request scope.
378
+ *
379
+ * @author Xeno
380
+ * @version 1.0.0
381
+ * @since 2025-09-30
382
+ * @link https://github.com/xeno-js/xeno-js
383
+ */
384
+ readonly SERVICE_SCOPE_ACCESSOR: IServiceScopeAccessor<ApplicationRegistry<T>>;
385
+ /** @description Token used to register and resolve the IContextAccessor instance in the dependency injection container to fetch execution context properties.
386
+ *
387
+ * @author Xeno
388
+ * @version 1.0.0
389
+ * @since 2025-09-30
390
+ * @link https://github.com/xeno-js/xeno-js
391
+ */
392
+ readonly CONTEXT_ACCESSOR: IContextAccessor<RequestContext>;
393
+ /** @description Token used to register and resolve the INetworkContextAccessor instance in the dependency injection container to fetch networking/observability context data.
394
+ *
395
+ * @author Xeno
396
+ * @version 1.0.0
397
+ * @since 2025-09-30
398
+ * @link https://github.com/xeno-js/xeno-js
399
+ */
400
+ readonly NETWORK_CONTEXT_ACCESSOR: INetworkContextAccessor;
401
+ /** @description Token used to register and resolve the UserContext factory in the dependency injection container.
402
+ *
403
+ * @author Xeno
404
+ * @version 1.0.0
405
+ * @since 2025-09-30
406
+ * @link https://github.com/xeno-js/xeno-js
407
+ */
408
+ readonly USER_CONTEXT_FACTORY: IFactory<void, UserContext>;
409
+ }
410
+
411
+ /**
412
+ * @fileoverview Defines the IServiceScope interface for scoped dependency injection.
413
+ *
414
+ * @author Xeno
415
+ * @version 1.0.0
416
+ * @since 2025-09-30
417
+ * @link https://github.com/xeno-js/xeno-js
418
+ */
419
+ /**
420
+ * @description Represents a logical scope for resolving scoped services,
421
+ * mimicking the .NET `IServiceScope` pattern.
422
+ *
423
+ * A scope is created by {@link IServiceContainer.createScope} and provides
424
+ * its own isolated instance cache for services registered with scoped lifetime.
425
+ * Singleton and transient services are still resolved through the root container.
426
+ *
427
+ * Call {@link dispose} when the scope is no longer needed to release all
428
+ * scoped instances and invalidate the scope.
429
+ *
430
+ * @author Xeno
431
+ * @version 1.0.0
432
+ * @since 2025-09-30
433
+ * @link https://github.com/xeno-js/xeno-js
434
+ */
435
+ interface IServiceScope<Registry extends ApplicationRegistry<unknown> = ApplicationRegistry<unknown>> extends IDisposable {
436
+ /**
437
+ * Resolves and returns the service registered under the given token.
438
+ * Scoped services can only be resolved through a scope;
439
+ * resolving them directly from the root container throws an error.
440
+ *
441
+ * @param token - The injection token identifying the service to resolve.
442
+ * @returns The resolved service instance of type `T`.
443
+ * @throws An error if no registration is found for the given token.
444
+ * @throws An error if the scope has already been disposed.
445
+ *
446
+ * @author Xeno
447
+ * @version 1.0.0
448
+ * @since 2025-09-30
449
+ * @link https://github.com/xeno-js/xeno-js
450
+ */
451
+ resolve<K extends keyof Registry>(token: K): Registry[K];
452
+ }
453
+
454
+ /**
455
+ * @fileoverview Defines the IServiceContainer interface for a dependency injection container.
456
+ *
457
+ * @author Xeno
458
+ * @version 1.0.0
459
+ * @since 2025-09-30
460
+ * @link https://github.com/xeno-js/xeno-js
461
+ */
462
+ interface IServiceProvider<Registry extends ApplicationRegistry<unknown> = ApplicationRegistry<unknown>> {
463
+ /**
464
+ * Resolves and returns the service registered under the given token.
465
+ * Scoped services can only be resolved through a scope;
466
+ * resolving them directly from the root container throws an error.
467
+ *
468
+ * @param token - The injection token identifying the service to resolve.
469
+ * @returns The resolved service instance of type `T`.
470
+ * @throws An error if no registration is found for the given token.
471
+ * @throws An error if the scope has already been disposed.
472
+ *
473
+ * @author Xeno
474
+ * @version 1.0.0
475
+ * @since 2025-09-30
476
+ * @link https://github.com/xeno-js/xeno-js
477
+ */
478
+ resolve<K extends keyof Registry>(token: K): Registry[K];
479
+ }
480
+ /**
481
+ * @description Agnostic contract for a dependency injection container that mimics
482
+ * the .NET ServiceCollection builder pattern.
483
+ *
484
+ * Each registration method returns `this` to enable a fluent builder chain.
485
+ * Dependencies are expressed as an ordered array of injection tokens
486
+ * that the container will resolve and inject into the constructor.
487
+ *
488
+ * @author Xeno
489
+ * @version 1.0.0
490
+ * @since 2025-09-30
491
+ * @link https://github.com/xeno-js/xeno-js
492
+ */
493
+ interface IServiceContainer<Registry extends ApplicationRegistry<unknown> = ApplicationRegistry<unknown>> extends IServiceProvider<Registry>, IDisposable {
494
+ /**
495
+ * Registers an implementation under the given token with **singleton** lifetime.
496
+ * A single instance is created on first resolution and reused for every
497
+ * subsequent call within the container's lifetime.
498
+ *
499
+ * @param token - The unique injection token that identifies this service binding.
500
+ * @param factory - Factory function that creates the service instance, receiving the scope as an argument.
501
+ * @returns The container instance to allow method chaining.
502
+ *
503
+ * @author Xeno
504
+ * @version 1.0.0
505
+ * @since 2025-09-30
506
+ * @link https://github.com/xeno-js/xeno-js
507
+ */
508
+ addSingleton<K extends keyof Registry>(token: K, factory: Factory<Registry[K], [IServiceScope<Registry>]>): this;
509
+ /**
510
+ * Registers an implementation under the given token with **transient** lifetime.
511
+ * A new instance is created on every call to {@link resolve}.
512
+ *
513
+ * @param token - The unique injection token that identifies this service binding.
514
+ * @param factory - Factory function that creates the service instance, receiving the scope as an argument.
515
+ * @returns The container instance to allow method chaining.
516
+ *
517
+ * @author Xeno
518
+ * @version 1.0.0
519
+ * @since 2025-09-30
520
+ * @link https://github.com/xeno-js/xeno-js
521
+ */
522
+ addTransient<K extends keyof Registry>(token: K, factory: Factory<Registry[K], [IServiceScope<Registry>]>): this;
523
+ /**
524
+ * Registers an implementation under the given token with **scoped** lifetime.
525
+ * One instance is created per logical scope (e.g. per HTTP request).
526
+ * Scoped services must be resolved through an {@link IServiceScope} obtained
527
+ * via {@link createScope}; resolving them directly from the root container throws.
528
+ *
529
+ * @param token - The unique injection token that identifies this service binding.
530
+ * @param factory - Factory function that creates the service instance, receiving the scope as an argument.
531
+ * @returns The container instance to allow method chaining.
532
+ *
533
+ * @author Xeno
534
+ * @version 1.0.0
535
+ * @since 2025-09-30
536
+ * @link https://github.com/xeno-js/xeno-js
537
+ */
538
+ addScoped<K extends keyof Registry>(token: K, factory: Factory<Registry[K], [IServiceScope<Registry>]>): this;
539
+ /**
540
+ * Creates a new {@link IServiceScope}.
541
+ *
542
+ * The returned scope shares singleton instances with the root container
543
+ * and maintains its own isolated cache for scoped services.
544
+ * Call {@link IServiceScope.dispose} when the scope is no longer needed.
545
+ *
546
+ * @returns A new scope instance.
547
+ *
548
+ * @author Xeno
549
+ * @version 1.0.0
550
+ * @since 2025-09-30
551
+ * @link https://github.com/xeno-js/xeno-js
552
+ */
553
+ createScope(): IServiceScope<Registry>;
554
+ }
555
+
556
+ /**
557
+ * @fileoverview Defines the ServiceDescriptor type for service registrations.
558
+
559
+ *
560
+ * @author Xeno
561
+ * @version 1.0.0
562
+ * @since 2025-09-30
563
+ * @link https://github.com/xeno-js/xeno-js
564
+ */
565
+ /**
566
+ * @description The possible lifetimes for a service registration, determining
567
+ * how instances are managed and cached by the container.
568
+
569
+ *
570
+ * @author Xeno
571
+ * @version 1.0.0
572
+ * @since 2025-09-30
573
+ * @link https://github.com/xeno-js/xeno-js
574
+ */
575
+ type Lifetime = 'singleton' | 'transient' | 'scoped';
576
+ /**
577
+ * @description Describes a service registration in the container, including
578
+ * the implementation constructor, its dependencies, and its lifetime.
579
+
580
+ *
581
+ * @author Xeno
582
+ * @version 1.0.0
583
+ * @since 2025-09-30
584
+ * @link https://github.com/xeno-js/xeno-js
585
+ */
586
+ interface ServiceDescriptor<T, TRegistry extends ApplicationRegistry<unknown> = ApplicationRegistry<unknown>> {
587
+ /**
588
+ * @description The injection token that uniquely identifies this service registration.
589
+
590
+ *
591
+ * @author Xeno
592
+ * @version 1.0.0
593
+ * @since 2025-09-30
594
+ * @link https://github.com/xeno-js/xeno-js
595
+ */
596
+ readonly token: keyof TRegistry;
597
+ /**
598
+ * @description The lifetime of the service, determining how instances are
599
+ * managed and cached by the container.
600
+
601
+ *
602
+ * @author Xeno
603
+ * @version 1.0.0
604
+ * @since 2025-09-30
605
+ * @link https://github.com/xeno-js/xeno-js
606
+ */
607
+ readonly lifetime: Lifetime;
608
+ /**
609
+ * @description Factory function to create the service instance.
610
+ * This factory will be used instead of the constructor.
611
+
612
+ *
613
+ * @author Xeno
614
+ * @version 1.0.0
615
+ * @since 2025-09-30
616
+ * @link https://github.com/xeno-js/xeno-js
617
+ */
618
+ readonly factory: (container: IServiceProvider<TRegistry>) => T;
619
+ }
620
+
621
+ /**
622
+ * @description This file defines the types for the execution context used in the application. The execution context includes the request context, which contains information about the identity of the user or system executing the request, as well as network and tracing contexts for observability. Additionally, it includes a service scope for managing dependencies during the execution of a request.
623
+ *
624
+ * @author Xeno
625
+ * @version 1.0.0
626
+ * @since 2025-09-30
627
+ * @link https://github.com/xeno-js/xeno-js
628
+ */
629
+
630
+ /**
631
+ * The ExecutionContext interface represents the context of a request execution, encapsulating the request context and the service scope. The request context contains information about the identity of the user or system executing the request, as well as network and tracing contexts for observability. The service scope allows for managing dependencies during the execution of a request, ensuring that services are properly scoped and disposed of after the request is processed.
632
+
633
+ *
634
+ * @author Xeno
635
+ * @version 1.0.0
636
+ * @since 2025-09-30
637
+ * @link https://github.com/xeno-js/xeno-js
638
+ */
639
+ interface ExecutionContext<TRegistry extends ApplicationRegistry = ApplicationRegistry> {
640
+ /** The request context containing information about the identity, network, and tracing contexts for the current request execution.
641
+ *
642
+ * @author Xeno
643
+ * @version 1.0.0
644
+ * @since 2025-09-30
645
+ * @link https://github.com/xeno-js/xeno-js
646
+ */
647
+ context: RequestContext;
648
+ /** The service scope for managing dependencies during the execution of a request. This allows for proper scoping and disposal of services after the request is processed.
649
+ *
650
+ * @author Xeno
651
+ * @version 1.0.0
652
+ * @since 2025-09-30
653
+ * @link https://github.com/xeno-js/xeno-js
654
+ */
655
+ scope: IServiceScope<TRegistry>;
656
+ }
657
+
658
+ /**
659
+ * @fileoverview Defines the IRequestContext interface for managing user identity context within the application.
660
+ *
661
+ * @author Xeno
662
+ * @version 1.0.0
663
+ * @since 2025-09-30
664
+ * @link https://github.com/xeno-js/xeno-js
665
+ */
666
+
667
+ /**
668
+ * An interface for managing user identity context within the application. This interface provides methods for executing asynchronous functions with the current user's identity context and retrieving the current user's identity information. It allows for seamless integration of identity management into various parts of the application, ensuring that identity-related data is properly propagated and accessible when needed.
669
+ *
670
+ * @author Xeno
671
+ * @version 1.0.0
672
+ * @since 2025-09-30
673
+ * @link https://github.com/xeno-js/xeno-js
674
+ */
675
+ interface IRequestContext<TCtx, TRegistry extends ApplicationRegistry = ApplicationRegistry> extends IBaseAccessor<TCtx>, IServiceScopeAccessor<TRegistry> {
676
+ /**
677
+ * Executes the provided asynchronous function with the current user's identity context. This allows the function to access identity information such as user ID, roles, and correlation ID while performing its operations. The function will be executed within the scope of the current request's identity, ensuring that any identity-related data is properly propagated throughout the execution flow.
678
+ * @param ctx The current user's identity context.
679
+ * @param fn An asynchronous function that takes the current user's identity as an argument and returns a promise of type T. This function will be executed with the identity context of the current request.
680
+ * @returns A promise that resolves to the result of the provided function, allowing the caller to handle the outcome of the operation performed within the identity context.
681
+ *
682
+ * @author Xeno
683
+ * @version 1.0.0
684
+ * @since 2025-09-30
685
+ * @link https://github.com/xeno-js/xeno-js
686
+ */
687
+ runAsync<T = unknown>(ctx: TCtx, fn: () => Promise<T>): Promise<T>;
688
+ updateIdentity(identity: Identity): void;
689
+ }
690
+ /**
691
+ * @description The IIdentityAccessor interface is a contract that defines the structure and behavior of an identity accessor within the application. It provides a method for retrieving the current user's identity information, including user ID, roles, and correlation ID. This interface is essential for managing user identity and ensuring that identity-related data is accessible when needed.
692
+ *
693
+ *
694
+ * @author Xeno
695
+ * @version 1.0.0
696
+ * @since 2025-09-30
697
+ * @link https://github.com/xeno-js/xeno-js
698
+ */
699
+ interface IServiceScopeAccessor<TRegistry extends ApplicationRegistry<unknown> = ApplicationRegistry<unknown>> {
700
+ /**
701
+ * Retrieves the current service scope, which allows for managing dependencies during the execution of a request. This method enables access to the service scope, ensuring that services are properly scoped and disposed of after the request is processed.
702
+ * @returns An object representing the current service scope, allowing for resolution of dependencies and management of services during the execution of a request.
703
+ *
704
+ * @author Xeno
705
+ * @version 1.0.0
706
+ * @since 2025-09-30
707
+ * @link https://github.com/xeno-js/xeno-js
708
+ */
709
+ getScope(): Optional<IServiceScope<TRegistry>>;
710
+ }
711
+
712
+ /**
713
+ * @description Represents a module that can be registered with the service container.
714
+ *
715
+ * @template TOptions - The type of configuration options for the module.
716
+
717
+ *
718
+ * @author Xeno
719
+ * @version 1.0.0
720
+ * @since 2025-09-30
721
+ * @link https://github.com/xeno-js/xeno-js
722
+ */
723
+ interface IModule<TRegistry extends ApplicationRegistry<unknown> = ApplicationRegistry<unknown>, TOptions = unknown> {
724
+ /**
725
+ * @description Configures the module with the provided options.
726
+ *
727
+ * @param container - The service container to register services with.
728
+ * @param opts - The configuration options for the module.
729
+
730
+ *
731
+ * @author Xeno
732
+ * @version 1.0.0
733
+ * @since 2025-09-30
734
+ * @link https://github.com/xeno-js/xeno-js
735
+ */
736
+ configure(container: IServiceContainer<TRegistry>, opts?: Optional<TOptions>): Promise<void>;
737
+ }
738
+
739
+ /**
740
+ * @description Interface for the allow method service.
741
+ *
742
+ * @author Xeno
743
+ * @version 1.0.0
744
+ * @since 2025-09-30
745
+ * @link https://github.com/xeno-js/xeno-js
746
+ */
747
+ interface IAllowMethod {
748
+ /** @description Check if the given method is allowed for the given path.
749
+ * @param path The path to check.
750
+ * @param method The method to check.
751
+ * @returns True if the method is allowed, false otherwise.
752
+ *
753
+ * @author Xeno
754
+ * @version 1.0.0
755
+ * @since 2025-09-30
756
+ * @link https://github.com/xeno-js/xeno-js
757
+ */
758
+ check(path: string, method: HttpMethod): boolean;
759
+ }
760
+
761
+ /**
762
+ * @description Interface for the allow origin service.
763
+ *
764
+ * @author Xeno
765
+ * @version 1.0.0
766
+ * @since 2025-09-30
767
+ * @link https://github.com/xeno-js/xeno-js
768
+ */
769
+ interface IAllowOrigin {
770
+ /** @description Check if the given origin is allowed.
771
+ * @param origin The origin to check.
772
+ * @returns True if the origin is allowed, false otherwise.
773
+ *
774
+ * @author Xeno
775
+ * @version 1.0.0
776
+ * @since 2025-09-30
777
+ * @link https://github.com/xeno-js/xeno-js
778
+ */
779
+ isAllowed(origin: Optional<string>): boolean;
780
+ }
781
+
782
+ interface ISsrCookie {
783
+ name: string;
784
+ value: string;
785
+ }
786
+ interface ISsrCookieToSet extends ISsrCookie {
787
+ options?: CookieOptions;
788
+ }
789
+ interface ISsrCookieHandler {
790
+ getAll(): ISsrCookie[];
791
+ setAll(cookies: ISsrCookieToSet[]): void;
792
+ }
793
+ interface AuthSsrConfig<TOption, TRegistry extends ApplicationRegistry = ApplicationRegistry> extends AuthConfig<TOption> {
794
+ ssrOpts: Optional<(container: IServiceContainer<TRegistry>) => ISsrCookieHandler>;
795
+ }
796
+
797
+ /**
798
+ * @description This file defines the ResilienceConfig interface, which specifies the configuration options for implementing resilience features such as retries, circuit breakers, and bulkheads in service calls. The ResilienceConfig interface includes properties for configuring retry attempts, base delay, maximum delay, consecutive failures for circuit breakers, half-open timeout, and maximum concurrent operations for bulkheads. This configuration can be used to enhance the reliability of service interactions by automatically handling transient faults and preventing cascading failures in distributed systems.
799
+
800
+ *
801
+ * @author Xeno
802
+ * @version 1.0.0
803
+ * @since 2025-09-30
804
+ * @link https://github.com/xeno-js/xeno-js
805
+ */
806
+ interface ResilienceConfig {
807
+ /**
808
+ * @description Configuration for retry mechanism, including the number of retry attempts, base delay in milliseconds for the first retry, and maximum delay in milliseconds for subsequent retries. This configuration allows for implementing an exponential backoff strategy to manage retries effectively and avoid overwhelming the service with rapid retry attempts.
809
+
810
+ *
811
+ * @author Xeno
812
+ * @version 1.0.0
813
+ * @since 2025-09-30
814
+ * @link https://github.com/xeno-js/xeno-js
815
+ */
816
+ retry: {
817
+ /** @description The number of retry attempts to be made before giving up on the operation. This helps to ensure that transient faults are handled gracefully without overwhelming the service with excessive retries.
818
+ *
819
+ * @author Xeno
820
+ * @version 1.0.0
821
+ * @since 2025-09-30
822
+ * @link https://github.com/xeno-js/xeno-js
823
+ */
824
+ attempts: Optional<number>;
825
+ /** @description The base delay in milliseconds for the first retry attempt. This value is used to calculate the delay for subsequent retries using an exponential backoff strategy, which helps to manage retries effectively and avoid overwhelming the service with rapid retry attempts.
826
+ *
827
+ * @author Xeno
828
+ * @version 1.0.0
829
+ * @since 2025-09-30
830
+ * @link https://github.com/xeno-js/xeno-js
831
+ */
832
+ baseDelayMs: Optional<number>;
833
+ /** @description The maximum delay in milliseconds for subsequent retry attempts. This value is used to cap the delay for retries when using an exponential backoff strategy, ensuring that the delay does not grow indefinitely and allowing for a reasonable retry strategy that balances between retrying too quickly and waiting too long.
834
+ *
835
+ * @author Xeno
836
+ * @version 1.0.0
837
+ * @since 2025-09-30
838
+ * @link https://github.com/xeno-js/xeno-js
839
+ */
840
+ maxDelayMs: Optional<number>;
841
+ };
842
+ /**
843
+ * @description Configuration for circuit breaker mechanism, including the number of consecutive failures required to trip the circuit breaker and the timeout duration in milliseconds for the half-open state. This configuration helps to prevent cascading failures by temporarily blocking calls to a service that is experiencing issues, allowing it time to recover before accepting new requests.
844
+
845
+ *
846
+ * @author Xeno
847
+ * @version 1.0.0
848
+ * @since 2025-09-30
849
+ * @link https://github.com/xeno-js/xeno-js
850
+ */
851
+ circuitBreaker: {
852
+ /** @description The number of consecutive failures required to trip the circuit breaker. When the number of consecutive failures reaches this threshold, the circuit breaker will open, preventing further calls to the service until it is allowed to half-open after a specified timeout. This helps to prevent cascading failures by temporarily blocking calls to a service that is experiencing issues, allowing it time to recover before accepting new requests.
853
+ *
854
+ * @author Xeno
855
+ * @version 1.0.0
856
+ * @since 2025-09-30
857
+ * @link https://github.com/xeno-js/xeno-js
858
+ */
859
+ consecutiveFailures: Optional<number>;
860
+ /** @description The timeout duration in milliseconds for the half-open state of the circuit breaker. After the circuit breaker has been tripped and is in the open state, it will transition to the half-open state after this timeout duration. In the half-open state, a limited number of calls will be allowed to test if the service has recovered. If the calls succeed, the circuit breaker will close and allow normal operation to resume. If the calls fail, the circuit breaker will open again, preventing further calls until the next timeout period. This configuration helps to manage the recovery process of a service that is experiencing issues and ensures that it can return to normal operation gracefully.
861
+ *
862
+ * @author Xeno
863
+ * @version 1.0.0
864
+ * @since 2025-09-30
865
+ * @link https://github.com/xeno-js/xeno-js
866
+ */
867
+ halfOpenTimeoutMs: Optional<number>;
868
+ };
869
+ /**
870
+ * @description Configuration for bulkhead mechanism, including the maximum number of concurrent operations allowed. This configuration helps to isolate failures and prevent resource exhaustion by limiting the number of concurrent calls to a service, ensuring that other parts of the system can continue to function even if one service is experiencing issues.
871
+
872
+ *
873
+ * @author Xeno
874
+ * @version 1.0.0
875
+ * @since 2025-09-30
876
+ * @link https://github.com/xeno-js/xeno-js
877
+ */
878
+ bulkhead: {
879
+ /** @description The maximum number of concurrent operations allowed. This helps to isolate failures and prevent resource exhaustion by limiting the number of concurrent calls to a service, ensuring that other parts of the system can continue to function even if one service is experiencing issues.
880
+ *
881
+ * @author Xeno
882
+ * @version 1.0.0
883
+ * @since 2025-09-30
884
+ * @link https://github.com/xeno-js/xeno-js
885
+ */
886
+ maxConcurrent: Optional<number>;
887
+ };
888
+ }
889
+
890
+ /**
891
+ * @description HttpCoreConfig is an interface that defines the configuration options for the core HTTP functionality of the application. It includes two properties: 'http' of type HttpConfig, which specifies the configuration for the HTTP client, and 'resilience' of type ResilienceConfig, which provides the settings for implementing resilience strategies such as retries, circuit breakers, and timeouts. This interface allows for a centralized configuration of both HTTP and resilience features in the application.
892
+ *
893
+ * @author Xeno
894
+ * @version 1.0.0
895
+ * @since 2025-09-30
896
+ * @link https://github.com/xeno-js/xeno-js
897
+ */
898
+ interface HttpCoreConfig<TRegistry extends ApplicationRegistry<unknown> = ApplicationRegistry<unknown>> {
899
+ /** @description A unique token used for identifying the RemoteDataSource instance in the dependency injection container.
900
+ *
901
+ * @author Xeno
902
+ * @version 1.0.0
903
+ * @since 2025-09-30
904
+ * @link https://github.com/xeno-js/xeno-js
905
+ */
906
+ dataSourceToken: SetupAction<IServiceContainer<TRegistry>>;
907
+ /** @description The configuration options for the HTTP client, including default headers, base URL, and timeout settings.
908
+ *
909
+ * @author Xeno
910
+ * @version 1.0.0
911
+ * @since 2025-09-30
912
+ * @link https://github.com/xeno-js/xeno-js
913
+ */
914
+ http: HttpConfig<TRegistry>;
915
+ /** @description The configuration options for implementing resilience strategies, including retries, circuit breakers, and timeouts. This allows for enhancing the reliability of service interactions by automatically handling transient faults and preventing cascading failures in distributed systems.
916
+ *
917
+ * @author Xeno
918
+ * @version 1.0.0
919
+ * @since 2025-09-30
920
+ * @link https://github.com/xeno-js/xeno-js
921
+ */
922
+ resilience: ResilienceConfig;
923
+ }
924
+ /**
925
+ * @description HttpConfig is an interface that defines the configuration options for an HTTP client. It includes a required 'client' property of type HttpClientConfig, which specifies the default headers, base URL, and timeout for the HTTP client. Additionally, it has an optional 'resilience' property that indicates whether resilience features are enabled and provides the corresponding ResilienceConfig if they are.
926
+ *
927
+ * @author Xeno
928
+ * @version 1.0.0
929
+ * @since 2025-09-30
930
+ * @link https://github.com/xeno-js/xeno-js
931
+ */
932
+ interface HttpConfig<TRegistry extends ApplicationRegistry<unknown> = ApplicationRegistry<unknown>> {
933
+ /** @description A unique token used for identifying the HTTP client configuration in the dependency injection container.
934
+ *
935
+ * @author Xeno
936
+ * @version 1.0.0
937
+ * @since 2025-09-30
938
+ * @link https://github.com/xeno-js/xeno-js
939
+ */
940
+ token: keyof TRegistry;
941
+ /** @description The configuration options for the HTTP client, including default headers, base URL, and timeout settings.
942
+ *
943
+ * @author Xeno
944
+ * @version 1.0.0
945
+ * @since 2025-09-30
946
+ * @link https://github.com/xeno-js/xeno-js
947
+ */
948
+ client: HttpClientConfig;
949
+ }
950
+
951
+ /**
952
+ * @description Interface defining the structure of a logger configuration object. This includes properties such as the minimum log level that should be captured by the logger. The log level determines the severity of log messages that will be processed and forwarded to the logging clients, allowing developers to control the verbosity of logs based on the needs of the application and its operational context.
953
+ *
954
+ *
955
+ * @author Xeno
956
+ * @version 1.0.0
957
+ * @since 2025-09-30
958
+ * @link https://github.com/xeno-js/xeno-js
959
+ */
960
+ interface LoggerConfig<TRegistry extends ApplicationRegistry = ApplicationRegistry> {
961
+ /**
962
+ * @description
963
+ * The level property specifies the minimum log level that should be captured by the logger. Log levels typically include DEBUG, INFO, WARN, and ERROR, with each level representing a different severity of log messages. By setting the log level, developers can control the verbosity of the logs and ensure that only relevant information is captured based on the needs of the application and its operational context.
964
+
965
+ *
966
+ * @author Xeno
967
+ * @version 1.0.0
968
+ * @since 2025-09-30
969
+ * @link https://github.com/xeno-js/xeno-js
970
+ */
971
+ level: Optional<LogLevel>;
972
+ /** @description Flag to enable or disable console logging. If set to true, log messages will be output to the console. If set to false or not defined, console logging will be disabled, and log messages will not be output to the console.
973
+ *
974
+ * @author Xeno
975
+ * @version 1.0.0
976
+ * @since 2025-09-30
977
+ * @link https://github.com/xeno-js/xeno-js
978
+ */
979
+ console: boolean;
980
+ /** @description Optional configuration for Sentry logger integration. If provided and enabled, the application will use Sentry as a logging client to capture and report log messages to the Sentry service. The configuration includes specific details for Sentry integration, such as the Data Source Name (DSN) and environment, allowing for flexible and modular logging configuration in the application.
981
+ *
982
+ * @author Xeno
983
+ * @version 1.0.0
984
+ * @since 2025-09-30
985
+ * @link https://github.com/xeno-js/xeno-js
986
+ */
987
+ sentry: {
988
+ /** @description Optional configuration for Sentry logger integration, including details such as the Data Source Name (DSN) and environment. If provided, this configuration will be used to initialize the Sentry logger client for capturing and reporting log messages to the Sentry service. If not defined, default Sentry configuration settings will be used.
989
+ *
990
+ * @author Xeno
991
+ * @version 1.0.0
992
+ * @since 2025-09-30
993
+ * @link https://github.com/xeno-js/xeno-js
994
+ */
995
+ config: Optional<SentryLoggerConfig>;
996
+ };
997
+ /** @description Optional configuration for Pino logger integration. If provided and enabled, the application will use Pino as a logging client to capture and manage log messages. The configuration includes specific details for Pino integration, such as the destination for log output, allowing for flexible and modular logging configuration in the application.
998
+ *
999
+ * @author Xeno
1000
+ * @version 1.0.0
1001
+ * @since 2025-09-30
1002
+ * @link https://github.com/xeno-js/xeno-js
1003
+ */
1004
+ pino: {
1005
+ /** @description Optional configuration for Pino logger integration, including details such as the destination for log output. If provided, this configuration will be used to initialize the Pino logger client for capturing and managing log messages. If not defined, default Pino configuration settings will be used.
1006
+ *
1007
+ * @author Xeno
1008
+ * @version 1.0.0
1009
+ * @since 2025-09-30
1010
+ * @link https://github.com/xeno-js/xeno-js
1011
+ */
1012
+ config: Optional<PinoLoggerConfig>;
1013
+ };
1014
+ /** @description Optional array of custom logger clients to be used in addition to the built-in console, Sentry, and Pino loggers. If provided, these custom loggers will be registered and used for capturing and managing log messages based on their respective configurations. If not defined or empty, only the enabled built-in loggers will be used.
1015
+ *
1016
+ * @author Xeno
1017
+ * @version 1.0.0
1018
+ * @since 2025-09-30
1019
+ * @link https://github.com/xeno-js/xeno-js
1020
+ */
1021
+ customLoggers: Optional<(container: IServiceScope<TRegistry>) => ILoggerClient>[];
1022
+ }
1023
+ /**
1024
+ * @description Interface defining the structure of the configuration object required to initialize a logger. This includes properties such as the Data Source Name (DSN) for connecting to the logging service, the environment in which the application is running (e.g., development, production), and the minimum log level that should be captured by the logger.
1025
+
1026
+ *
1027
+ * @author Xeno
1028
+ * @version 1.0.0
1029
+ * @since 2025-09-30
1030
+ * @link https://github.com/xeno-js/xeno-js
1031
+ */
1032
+ interface SentryLoggerConfig {
1033
+ /**
1034
+ * @description
1035
+ * The Data Source Name (DSN) is a string that provides the necessary information for the logger to connect to the logging service. It typically includes the protocol, public key, secret key, host, and project ID. The DSN is essential for authenticating and routing log data to the correct destination in the logging infrastructure.
1036
+
1037
+ *
1038
+ * @author Xeno
1039
+ * @version 1.0.0
1040
+ * @since 2025-09-30
1041
+ * @link https://github.com/xeno-js/xeno-js
1042
+ */
1043
+ dsn: Optional<string>;
1044
+ /**
1045
+ * @description
1046
+ * The environment property indicates the context in which the application is running, such as 'development', 'staging', or 'production'. This information can be used by the logging service to categorize and filter logs based on the environment, allowing for better organization and analysis of log data.
1047
+
1048
+ *
1049
+ * @author Xeno
1050
+ * @version 1.0.0
1051
+ * @since 2025-09-30
1052
+ * @link https://github.com/xeno-js/xeno-js
1053
+ */
1054
+ environment: Optional<string>;
1055
+ }
1056
+ /**
1057
+ * @description Interface defining the structure of the configuration object required to initialize a Pino logger. This includes properties such as the destination for log output, which can be a file path, a stream, or a logging service endpoint. By configuring the destination, developers can control where the log data is stored or sent, enabling integration with various logging infrastructures and facilitating log management and analysis.
1058
+
1059
+ *
1060
+ * @author Xeno
1061
+ * @version 1.0.0
1062
+ * @since 2025-09-30
1063
+ * @link https://github.com/xeno-js/xeno-js
1064
+ */
1065
+ interface PinoLoggerConfig {
1066
+ /**
1067
+ * @description
1068
+ * The destination property specifies the output destination for the logs generated by the Pino logger. This can be a file path, a stream, or a logging service endpoint. By configuring the destination, developers can control where the log data is stored or sent, enabling integration with various logging infrastructures and facilitating log management and analysis.
1069
+
1070
+ *
1071
+ * @author Xeno
1072
+ * @version 1.0.0
1073
+ * @since 2025-09-30
1074
+ * @link https://github.com/xeno-js/xeno-js
1075
+ */
1076
+ destination?: Optional<Destination>;
1077
+ /** @description Optional environment name for the Pino logger configuration. This can be used to specify the context in which the application is running (e.g., development, production) and can help with categorizing and filtering log messages based on the environment.
1078
+ *
1079
+ * @author Xeno
1080
+ * @version 1.0.0
1081
+ * @since 2025-09-30
1082
+ * @link https://github.com/xeno-js/xeno-js
1083
+ */
1084
+ env?: Optional<string>;
1085
+ /** @description Optional file path for the Pino logger configuration. If specified, log messages will be written to the specified file instead of the default output destination. This allows for flexible log management and storage based on application requirements.
1086
+ *
1087
+ * @author Xeno
1088
+ * @version 1.0.0
1089
+ * @since 2025-09-30
1090
+ * @link https://github.com/xeno-js/xeno-js
1091
+ */
1092
+ filePath?: Optional<string>;
1093
+ /** @description Optional flag to enable pretty printing of log messages. When set to true, log messages will be formatted in a more human-readable way, which can be useful for development and debugging purposes.
1094
+ *
1095
+ * @author Xeno
1096
+ * @version 1.0.0
1097
+ * @since 2025-09-30
1098
+ * @link https://github.com/xeno-js/xeno-js
1099
+ */
1100
+ prettyPrint?: Optional<boolean>;
1101
+ }
1102
+ type Destination = 'stdout' | 'file';
1103
+
1104
+ /**
1105
+ * @description Configuration for the middleware.
1106
+ *
1107
+ * @author Xeno
1108
+ * @version 1.0.0
1109
+ * @since 2025-09-30
1110
+ * @link https://github.com/xeno-js/xeno-js
1111
+ */
1112
+ interface MiddlewareConfig {
1113
+ /**
1114
+ * @description
1115
+ * The isSSR property is a boolean flag that indicates whether the application is running in a server-side rendering (SSR) environment. In an SSR environment, the application is rendered on the server-side and then sent to the client-side for display. This property is useful for configuring middleware or other components that may behave differently in an SSR environment. For example, certain middleware may need to be disabled or modified when running in an SSR environment to prevent issues with server-side rendering. By setting the isSSR property to true or false, developers can configure middleware or other components to behave appropriately in an SSR environment.
1116
+ *
1117
+ * @author Xeno
1118
+ * @version 1.0.0
1119
+ * @since 2025-09-30
1120
+ * @link https://github.com/xeno-js/xeno-js
1121
+ */
1122
+ isSSR: boolean;
1123
+ /**
1124
+ * @description
1125
+ * The rateLimite property is an object that contains two properties: maxRequests and windowSeconds. These properties are used to configure rate limiting for the application. Rate limiting is a technique used to prevent abuse or excessive use of a system or service by limiting the number of requests that can be made within a given time period. The maxRequests property specifies the maximum number of requests that can be made within the specified windowSeconds, and the windowSeconds property specifies the duration of the window in seconds.
1126
+ *
1127
+ * @author Xeno
1128
+ * @version 1.0.0
1129
+ * @since 2025-09-30
1130
+ * @link https://github.com/xeno-js/xeno-js
1131
+ */
1132
+ rateLimite: {
1133
+ /**
1134
+ * @description
1135
+ * The maxRequests property specifies the maximum number of requests that can be made within the specified windowSeconds. This property is used to configure rate limiting for the application. Rate limiting is a technique used to prevent abuse or excessive use of a system or service by limiting the number of requests that can be made within a given time period. The maxRequests property specifies the maximum number of requests that can be made within the specified windowSeconds, and the windowSeconds property specifies the duration of the window in seconds.
1136
+ *
1137
+ * @author Xeno
1138
+ * @version 1.0.0
1139
+ * @since 2025-09-30
1140
+ * @link https://github.com/xeno-js/xeno-js
1141
+ */
1142
+ maxRequests: Optional<number>;
1143
+ /**
1144
+ * @description
1145
+ * The windowSeconds property specifies the duration of the window in seconds. This property is used to configure rate limiting for the application. Rate limiting is a technique used to prevent abuse or excessive use of a system or service by limiting the number of requests that can be made within a given time period. The windowSeconds property specifies the duration of the window in seconds, and the maxRequests property specifies the maximum number of requests that can be made within the specified windowSeconds.
1146
+ *
1147
+ * @author Xeno
1148
+ * @version 1.0.0
1149
+ * @since 2025-09-30
1150
+ * @link https://github.com/xeno-js/xeno-js
1151
+ */
1152
+ windowSeconds: Optional<number>;
1153
+ };
1154
+ /**
1155
+ * @description
1156
+ * The cors property is an optional property that can be used to configure Cross-Origin Resource Sharing (CORS) for the application. CORS is a mechanism that allows resources on a web page to be requested from another domain outside the domain from which the resource originated. The cors property is an object that contains properties to configure CORS, such as allowedOrigins, allowedMethods, allowedHeaders, and exposedHeaders.
1157
+ *
1158
+ * @author Xeno
1159
+ * @version 1.0.0
1160
+ * @since 2025-09-30
1161
+ * @link https://github.com/xeno-js/xeno-js
1162
+ */
1163
+ csrf: Optional<string>;
1164
+ /**
1165
+ * @description
1166
+ * The cors property is an optional property that can be used to configure Cross-Origin Resource Sharing (CORS) for the application. CORS is a mechanism that allows resources on a web page to be requested from another domain outside the domain from which the resource originated. The cors property is an object that contains properties to configure CORS, such as allowedOrigins, allowedMethods, allowedHeaders, and exposedHeaders.
1167
+ *
1168
+ * @author Xeno
1169
+ * @version 1.0.0
1170
+ * @since 2025-09-30
1171
+ * @link https://github.com/xeno-js/xeno-js
1172
+ */
1173
+ optionsMiddleware: boolean;
1174
+ /**
1175
+ * @description
1176
+ * The routeRegistry property is an optional property that can be used to configure the routing of HTTP requests in the application. It is an object that contains properties to define the routes and their corresponding HTTP methods. The routeRegistry property is used to map incoming HTTP requests to the appropriate route handlers, allowing the application to handle requests based on the defined routes and methods.
1177
+ *
1178
+ * @author Xeno
1179
+ * @version 1.0.0
1180
+ * @since 2025-09-30
1181
+ * @link https://github.com/xeno-js/xeno-js
1182
+ */
1183
+ routeRegistry: Optional<Dictionary<HttpMethod[]>>;
1184
+ /**
1185
+ * @description
1186
+ * The trustedIpHeader property is an optional property that can be used to configure the trusted IP header for the application. It is a string that specifies the name of the header that contains the trusted IP address. This property is used to determine the trusted IP address of the client making the request, which can be useful for security and authentication purposes.
1187
+ *
1188
+ * @author Xeno
1189
+ * @version 1.0.0
1190
+ * @since 2025-09-30
1191
+ * @link https://github.com/xeno-js/xeno-js
1192
+ */
1193
+ trustedIpHeader: Optional<string>;
1194
+ /**
1195
+ * @description
1196
+ * The allowOrigins property is an optional property that can be used to configure the allowed origins for the application. It is an array of strings that specifies the origins that are allowed to make requests to the application. This property is used to implement Cross-Origin Resource Sharing (CORS) and restrict access to the application based on the origin of the request.
1197
+ *
1198
+ * @author Xeno
1199
+ * @version 1.0.0
1200
+ * @since 2025-09-30
1201
+ * @link https://github.com/xeno-js/xeno-js
1202
+ */
1203
+ allowOrigins: Optional<string[]>;
1204
+ /**
1205
+ * @description
1206
+ * The cors property is a boolean property that is used to enable or disable Cross-Origin Resource Sharing (CORS) for the application. CORS is a mechanism that allows resources on a web page to be requested from another domain outside the domain from which the first resource was served. This property is used to configure the CORS middleware that is responsible for handling CORS requests and responses.
1207
+ *
1208
+ * @author Xeno
1209
+ * @version 1.0.0
1210
+ * @since 2025-09-30
1211
+ * @link https://github.com/xeno-js/xeno-js
1212
+ */
1213
+ cors: boolean;
1214
+ }
1215
+
1216
+ /**
1217
+ * @description PipelineConfig defines the configuration options for the CQRS pipelines in the application. It includes settings for performance monitoring, authorization, validation, command bus, and query bus. Each section allows for enabling or disabling specific features and providing additional configuration details as needed. This configuration is used by the CqrsModule to set up the appropriate middleware and services in the dependency injection container based on the specified options.
1218
+
1219
+ *
1220
+ * @author Xeno
1221
+ * @version 1.0.0
1222
+ * @since 2025-09-30
1223
+ * @link https://github.com/xeno-js/xeno-js
1224
+ */
1225
+ interface PipelineConfig<TRegistry extends ApplicationRegistry<unknown> = ApplicationRegistry<unknown>, TSchema = unknown> {
1226
+ /** @description Configuration for performance monitoring, including the ability to set a threshold in milliseconds for logging slow operations. If enabled, the PerformancePipeline will log a warning whenever the execution of a command or query exceeds the specified threshold, helping to identify potential performance bottlenecks in the application. If the threshold is not defined, all operations will be monitored without duration-based filtering.
1227
+ *
1228
+ * @author Xeno
1229
+ * @version 1.0.0
1230
+ * @since 2025-09-30
1231
+ * @link https://github.com/xeno-js/xeno-js
1232
+ */
1233
+ performance: {
1234
+ /** @description Optional threshold in milliseconds for logging slow operations. If defined, the PerformancePipeline will log a warning whenever the execution of a command or query exceeds this duration, allowing for performance monitoring and optimization. If not defined, all operations will be monitored without duration-based filtering.
1235
+ *
1236
+ * @author Xeno
1237
+ * @version 1.0.0
1238
+ * @since 2025-09-30
1239
+ * @link https://github.com/xeno-js/xeno-js
1240
+ */
1241
+ thresholdMs: Optional<number>;
1242
+ };
1243
+ /** @description Configuration for authorization, allowing the enabling of authorization strategies based on tenant, policy, roles, and permissions. If enabled, the authorization pipeline will evaluate the specified strategies for each command or query, ensuring that only authorized users can perform certain actions. The configuration also includes the ability to define custom authorization strategies via injection tokens, providing flexibility in implementing application-specific access rules.
1244
+ *
1245
+ * @author Xeno
1246
+ * @version 1.0.0
1247
+ * @since 2025-09-30
1248
+ * @link https://github.com/xeno-js/xeno-js
1249
+ */
1250
+ authorization: {
1251
+ /** @description Configuration for policy-based authorization, allowing the definition of a policy registry and the option to enable role-based or permission-based checks. If policy-based authorization is enabled, the authorization pipeline will include a strategy that evaluates the defined policies for each command or query, ensuring that users meet the necessary criteria based on their roles and permissions. The policy registry allows for central management of authorization policies, making it easier to maintain and update access rules across the application.
1252
+ *
1253
+ * @author Xeno
1254
+ * @version 1.0.0
1255
+ * @since 2025-09-30
1256
+ * @link https://github.com/xeno-js/xeno-js
1257
+ */
1258
+ policies: Optional<Dictionary<AuthPolicy>>;
1259
+ /** @description An optional array of custom authorization strategies defined via injection tokens. If provided, these strategies will be included in the authorization pipeline and evaluated for each command or query, allowing for custom logic to determine if a user is authorized to perform a specific action. This provides flexibility in implementing application-specific access rules that may not fit into standard tenant-based or policy-based checks. Each strategy should implement the IStrategy interface and return a boolean indicating whether the command or query is authorized.
1260
+ *
1261
+ * @author Xeno
1262
+ * @version 1.0.0
1263
+ * @since 2025-09-30
1264
+ * @link https://github.com/xeno-js/xeno-js
1265
+ */
1266
+ customAuthorizationStrategy?: Optional<(container: IServiceScope<TRegistry>) => IStrategy<IRequest>>[];
1267
+ };
1268
+ /** @description Configuration for validation, allowing the enabling of validation based on Zod schemas or custom validation strategies. If enabled, the validation pipeline will validate commands and queries based on the specified criteria, ensuring that input data meets expectations before further processing. The configuration includes the ability to define Zod schemas for structural validation or to use custom strategies via injection tokens, providing flexibility in implementing application-specific validation rules.
1269
+ *
1270
+ * @author Xeno
1271
+ * @version 1.0.0
1272
+ * @since 2025-09-30
1273
+ * @link https://github.com/xeno-js/xeno-js
1274
+ */
1275
+ validation: {
1276
+ /** @description An optional configuration for Zod-based validation, allowing the definition of schemas for validating the structure and content of commands and queries. If provided, the validation pipeline will use these schemas to validate incoming requests, ensuring that they conform to the expected format and contain valid data before being processed further. This provides a powerful and flexible way to enforce data integrity and prevent invalid input from causing issues in the application.
1277
+ *
1278
+ * @author Xeno
1279
+ * @version 1.0.0
1280
+ * @since 2025-09-30
1281
+ * @link https://github.com/xeno-js/xeno-js
1282
+ */
1283
+ zod: Optional<SchemaConfig<TSchema>>;
1284
+ /** @description An optional array of custom validation strategies defined via injection tokens. If provided, these strategies will be included in the validation pipeline and evaluated for each command or query, allowing for custom logic to determine if the input data is valid. This provides flexibility in implementing application-specific validation rules that may not fit into standard schema-based validation. Each strategy should implement the IStrategy interface and return a boolean indicating whether the command or query is valid.
1285
+ *
1286
+ * @author Xeno
1287
+ * @version 1.0.0
1288
+ * @since 2025-09-30
1289
+ * @link https://github.com/xeno-js/xeno-js
1290
+ */
1291
+ customValidationStrategy?: Optional<(container: IServiceScope<TRegistry>) => IStrategy<IRequest, boolean>>[];
1292
+ };
1293
+ /** @description Configuration for the command bus, allowing the enabling of features such as idempotency and concurrency management. If enabled, the command bus pipeline will include specific behaviors to handle these features, such as acquiring locks to ensure idempotency or managing retries in case of concurrency conflicts. The configuration includes specific details for each feature, such as TTLs for idempotency locks or delay strategies for concurrency retries, providing granular control over how commands are processed and managed within the application.
1294
+ *
1295
+ * @author Xeno
1296
+ * @version 1.0.0
1297
+ * @since 2025-09-30
1298
+ * @link https://github.com/xeno-js/xeno-js
1299
+ */
1300
+ commandBus: {
1301
+ idempotency: Optional<IdempotencyConfig>;
1302
+ concurrency: Optional<ConcurrencyConfig>;
1303
+ };
1304
+ /** @description Configuration for the query bus, allowing the enabling of features such as result caching. If enabled, the query bus pipeline will include specific behaviors to handle caching, such as storing query results in a cache system and retrieving results from the cache when available. The configuration includes specific details for caching, such as settings for Redis integration or the ability to use a custom cache via injection tokens, providing flexibility in how query results are stored and retrieved within the application.
1305
+ *
1306
+ * @author Xeno
1307
+ * @version 1.0.0
1308
+ * @since 2025-09-30
1309
+ * @link https://github.com/xeno-js/xeno-js
1310
+ */
1311
+ queryBus: {
1312
+ /** @description Flag to enable or disable query bus features. If set to true, the query bus pipeline will include additional behaviors based on the specified configuration, such as result caching. If set to false or not defined, the query bus will operate without these additional features, allowing queries to be processed in a standard manner without caching or other enhancements.
1313
+ *
1314
+ * @author Xeno
1315
+ * @version 1.0.0
1316
+ * @since 2025-09-30
1317
+ * @link https://github.com/xeno-js/xeno-js
1318
+ */
1319
+ isEnabled: boolean;
1320
+ };
1321
+ }
1322
+ /** @description Configuration for caching, allowing the enabling of Redis integration or the use of a custom cache. If enabled, the query bus and command bus (in case of idempotency) pipelines will use the configured cache system to store and retrieve data efficiently. The configuration includes specific details for Redis integration, such as host, port, and credentials, as well as the ability to define a custom cache via injection tokens, providing flexibility in how the cache is implemented and used within the application.
1323
+ *
1324
+ * @author Xeno
1325
+ * @version 1.0.0
1326
+ * @since 2025-09-30
1327
+ * @link https://github.com/xeno-js/xeno-js
1328
+ */
1329
+ interface SchemaConfig<TSchema> {
1330
+ /** @description A record of Zod schemas, where each key represents a specific command or query type, and the corresponding value is the Zod schema used to validate that type. If provided, the validation pipeline will use these schemas to validate incoming requests, ensuring that they conform to the expected format and contain valid data before being processed further. This allows for powerful and flexible validation rules based on the structure and content of commands and queries.
1331
+ *
1332
+ * @author Xeno
1333
+ * @version 1.0.0
1334
+ * @since 2025-09-30
1335
+ * @link https://github.com/xeno-js/xeno-js
1336
+ */
1337
+ schemas: Dictionary<TSchema>;
1338
+ }
1339
+ /** @description Configuration for idempotency, allowing the definition of TTLs for locks and processed results. If enabled, the command bus pipeline will include specific behaviors to handle idempotency, such as acquiring locks to ensure that a command with the same ID is processed only once and storing the results of processed commands for a defined period. The configuration includes specific details for TTLs, such as the duration of the lock and the duration for which processed results are retained, providing granular control over how idempotency is managed within the application.
1340
+ *
1341
+ * @author Xeno
1342
+ * @version 1.0.0
1343
+ * @since 2025-09-30
1344
+ * @link https://github.com/xeno-js/xeno-js
1345
+ */
1346
+ interface IdempotencyConfig {
1347
+ /** @description Optional TTL in seconds for the idempotency lock. This defines how long the lock should be held to prevent duplicate processing of commands with the same ID. If not defined, a default value will be used.
1348
+ *
1349
+ * @author Xeno
1350
+ * @version 1.0.0
1351
+ * @since 2025-09-30
1352
+ * @link https://github.com/xeno-js/xeno-js
1353
+ */
1354
+ lockTtlSeconds: Optional<number>;
1355
+ /** @description Optional TTL in seconds for storing the results of processed commands. This defines how long the results of a processed command should be retained in the cache, allowing for retrieval if the same command is received again within that period. If not defined, a default value will be used.
1356
+ *
1357
+ * @author Xeno
1358
+ * @version 1.0.0
1359
+ * @since 2025-09-30
1360
+ * @link https://github.com/xeno-js/xeno-js
1361
+ */
1362
+ processedTtlSeconds: Optional<number>;
1363
+ }
1364
+ /** @description Configuration for concurrency management, allowing the definition of maximum retries and delay strategies for retries. If enabled, the command bus pipeline will include specific behaviors to handle concurrency conflicts, such as retrying a command in case of failure due to a conflict. The configuration includes specific details for retries, such as the maximum number of attempts and delay strategies (e.g., exponential backoff with jitter) between attempts, providing granular control over how concurrency is managed within the application.
1365
+ *
1366
+ * @author Xeno
1367
+ * @version 1.0.0
1368
+ * @since 2025-09-30
1369
+ * @link https://github.com/xeno-js/xeno-js
1370
+ */
1371
+ interface ConcurrencyConfig {
1372
+ /** @description Optional maximum number of retry attempts in case of concurrency conflicts. This defines how many times the command bus should attempt to retry a command if it fails due to a concurrency issue, such as a version conflict in an optimistic concurrency control scenario. If not defined, a default value will be used.
1373
+ *
1374
+ * @author Xeno
1375
+ * @version 1.0.0
1376
+ * @since 2025-09-30
1377
+ * @link https://github.com/xeno-js/xeno-js
1378
+ */
1379
+ maxRetries?: Optional<number>; /** @description Optional configuration for delay strategies between retry attempts. This can include settings for exponential backoff, jitter, or fixed delays to manage the timing of retries in case of concurrency conflicts. If not defined, a default delay strategy will be used.
1380
+ *
1381
+ * @author Xeno
1382
+ * @version 1.0.0
1383
+ * @since 2025-09-30
1384
+ * @link https://github.com/xeno-js/xeno-js
1385
+ */
1386
+ delayConfig: {
1387
+ /** @description Base delay in milliseconds for retries. This defines the initial delay before the first retry attempt in case of a concurrency conflict. If using an exponential backoff strategy, this base delay will be multiplied for each subsequent retry attempt. If not defined, a default value will be used.
1388
+ *
1389
+ * @author Xeno
1390
+ * @version 1.0.0
1391
+ * @since 2025-09-30
1392
+ * @link https://github.com/xeno-js/xeno-js
1393
+ */
1394
+ baseDelayMs: number;
1395
+ /** @description Optional maximum delay in milliseconds for retries. This defines the upper limit for the delay between retry attempts, preventing excessively long delays in case of multiple retries. If not defined, a default value will be used.
1396
+ *
1397
+ * @author Xeno
1398
+ * @version 1.0.0
1399
+ * @since 2025-09-30
1400
+ * @link https://github.com/xeno-js/xeno-js
1401
+ */
1402
+ maxJitterMs: number;
1403
+ };
1404
+ }
1405
+
1406
+ /**
1407
+ * Utils that provide utility functions for interacting with the service container and managing scoped service resolution.
1408
+ */
1409
+ declare const ContainerUtils: Readonly<{
1410
+ /**
1411
+ * Resolves a scoped service from the container using the provided token.
1412
+ * @param token * The token to resolve from the registry.
1413
+ * @param container * The container to resolve the service from.
1414
+ *
1415
+ * @returns The resolved service instance.
1416
+ * @throws Error if the active service scope is not available.
1417
+ */
1418
+ resolveServiceScoped<K extends keyof T, T extends ApplicationRegistry>(token: K, container: IServiceContainer<T>): T[K];
1419
+ /**
1420
+ * Executes a service action within the context of a scoped service.
1421
+ * @param endpoint * The endpoint to execute the action on.
1422
+ * @param method * The HTTP method to use for the action.
1423
+ * @param headers * The headers to include in the request.
1424
+ * @param transport * The transport object containing the request and response objects.
1425
+ * @param container * The container to resolve the service from.
1426
+ * @param action * The action to execute within the scoped service.
1427
+ *
1428
+ * @returns Promise<ResponseDto<TResponse>> A promise that resolves to the response DTO of the executed action.
1429
+ * @throws Error If the active service scope is not available.
1430
+ * @throws Error If the service is not found in the container.
1431
+ * @throws Error If the service is not a scoped service.
1432
+ */
1433
+ runExecute<TResponse, T extends ApplicationRegistry, TRes, TReq>(endpoint: string, method: Optional<string>, headers: HttpHeaders, transport: {
1434
+ res: TRes;
1435
+ req: TReq;
1436
+ }, container: IServiceContainer<T>, action: () => Promise<ResponseDto<TResponse>>): Promise<ResponseDto<TResponse>>;
1437
+ }>;
1438
+
1439
+ /**
1440
+ * BaseHandler is an abstract class that implements the IHandler interface.
1441
+ * It provides a base implementation for handling requests and executing strategies.
1442
+ *
1443
+ * @author Xeno
1444
+ * @version 1.0.0
1445
+ * @since 2025-09-30
1446
+ * @link https://github.com/xeno-js/xeno-js
1447
+ */
1448
+ declare abstract class BaseHandler<TRequest extends IRequest<TResponse>, TResponse> implements IHandler<TRequest, TResponse> {
1449
+ private readonly _identityFactory;
1450
+ constructor(_identityFactory: IFactory<void, UserContext>);
1451
+ handle(request: TRequest, signal: AbortSignal): Promise<ResultType<TResponse>>;
1452
+ /**
1453
+ * Executes the strategy for the given request.
1454
+ * @param request - The request to be handled.
1455
+ * @param signal - (Optional) The abort signal for the request.
1456
+ * @throws {AppError} If the strategy execution fails.
1457
+ * @protected - This method should be overridden by subclasses.
1458
+ * @abstract - This method must be implemented by subclasses.
1459
+ * @async - This method is asynchronous.
1460
+ * @template TRequest - The type of the request.
1461
+ * @template TResponse - The type of the response.
1462
+ * @returns {Promise<ResultType<TResponse>>} A promise that resolves to the result of the strategy execution.
1463
+ *
1464
+ * @author Xeno
1465
+ * @version 1.0.0
1466
+ * @since 2025-09-30
1467
+ * @link https://github.com/xeno-js/xeno-js
1468
+ */
1469
+ protected abstract executeAsync(request: TRequest, signal?: Optional<AbortSignal>): Promise<ResultType<TResponse>>;
1470
+ /**
1471
+ * Gets the current context.
1472
+ * @returns {UserContext} The current context.
1473
+ * {@link UserContext}
1474
+ */
1475
+ protected _getCurrentContext(): UserContext;
1476
+ }
1477
+
1478
+ /**
1479
+ * @description Abstract base class for authorization strategies in the CQRS pipeline. This class implements the IStrategy interface and provides a common structure for performing authorization checks based on the identity of the authenticated user. It defines an abstract method performAuthorizationCheck that must be implemented by concrete authorization strategies to specify the logic for checking if the user has the necessary permissions to execute a given request. The execute method retrieves the user's identity from the request context and ensures that the user is authenticated before delegating to the performAuthorizationCheck method for further authorization validation. If the user is not authenticated, it returns a failed Result with an appropriate AppError indicating that authentication is required.
1480
+ *
1481
+ * @author Xeno
1482
+ * @version 1.0.0
1483
+ * @since 2025-09-30
1484
+ * @link https://github.com/xeno-js/xeno-js
1485
+ */
1486
+ declare abstract class BaseAuthorizationStrategy<TInput extends IRequest> implements IStrategy<TInput> {
1487
+ private readonly _requestContext;
1488
+ /**
1489
+ * @description Constructs a new instance of the BaseAuthorizationStrategy class, which serves as an abstract base for specific authorization strategies in the CQRS pipeline. It takes an IRequestContext as a parameter, which is used to retrieve the identity of the currently authenticated user during the authorization process. This context is essential for performing the authorization checks based on the user's identity when executing requests that require specific permissions.
1490
+ * @param requestContext An instance of IRequestContext used to access the identity of the currently authenticated user. This context is essential for performing the authorization checks based on the user's identity when executing requests that require specific permissions.
1491
+ *
1492
+ * @author Xeno
1493
+ * @version 1.0.0
1494
+ * @since 2025-09-30
1495
+ * @link https://github.com/xeno-js/xeno-js
1496
+ */
1497
+ constructor(_requestContext: IContextAccessor<RequestContext>);
1498
+ execute(request: IRequest): Promise<ResultType<void>>;
1499
+ /**
1500
+ * @description Abstract method that must be implemented by concrete authorization strategies to perform the actual authorization check. This method is called after the user's identity has been retrieved and verified. It receives the request and the user's identity as parameters and should return a Result indicating whether the authorization check passed or failed.
1501
+ * @param request The incoming request for which the authorization check is being performed. This request contains information about the action being attempted and any relevant data needed for the authorization logic.
1502
+ * @param auth The identity of the currently authenticated user, which includes information such as the user's ID, tenant ID, and roles. This context is used to determine if the user has the necessary permissions to execute the request.
1503
+ * @returns A Result indicating the outcome of the authorization check. If the check passes, it should return a successful Result with a void value. If the check fails, it should return a failed Result with an appropriate AppError describing the reason for the failure.
1504
+ *
1505
+ * @author Xeno
1506
+ * @version 1.0.0
1507
+ * @since 2025-09-30
1508
+ * @link https://github.com/xeno-js/xeno-js
1509
+ */
1510
+ protected abstract performAuthorizationCheck(request: IRequest, auth: Identity): Promise<ResultType<void>>;
1511
+ }
1512
+
1513
+ /**
1514
+ * Base class for specifications, providing default implementations for logical operations (AND, OR, NOT).
1515
+ *
1516
+ * @template T - The type of the candidate object that the specification will evaluate.
1517
+
1518
+ *
1519
+ * @author Xeno
1520
+ * @version 1.0.0
1521
+ * @since 2025-09-30
1522
+ * @link https://github.com/xeno-js/xeno-js
1523
+ */
1524
+ declare abstract class Specification<T> implements ISpecification<T> {
1525
+ /**
1526
+ * Determines if the candidate satisfies the specification criteria.
1527
+ *
1528
+ * @param candidate - The object to evaluate against the specification.
1529
+ * @returns A boolean indicating whether the candidate satisfies the specification.
1530
+
1531
+ *
1532
+ * @author Xeno
1533
+ * @version 1.0.0
1534
+ * @since 2025-09-30
1535
+ * @link https://github.com/xeno-js/xeno-js
1536
+ */
1537
+ abstract isSatisfiedBy(candidate: T): boolean;
1538
+ /**
1539
+ * Combines this specification with another specification using a logical AND operation.
1540
+ *
1541
+ * @param other - Another specification to combine with this specification.
1542
+ * @returns A new specification that represents the logical AND of this and the other specification.
1543
+
1544
+ *
1545
+ * @author Xeno
1546
+ * @version 1.0.0
1547
+ * @since 2025-09-30
1548
+ * @link https://github.com/xeno-js/xeno-js
1549
+ */
1550
+ and(other: ISpecification<T>): ISpecification<T>;
1551
+ /**
1552
+ * Combines this specification with another specification using a logical OR operation.
1553
+ *
1554
+ * @param other - Another specification to combine with this specification.
1555
+ * @returns A new specification that represents the logical OR of this and the other specification.
1556
+
1557
+ *
1558
+ * @author Xeno
1559
+ * @version 1.0.0
1560
+ * @since 2025-09-30
1561
+ * @link https://github.com/xeno-js/xeno-js
1562
+ */
1563
+ or(other: ISpecification<T>): ISpecification<T>;
1564
+ /**
1565
+ * Inverts this specification using a logical NOT operation.
1566
+ *
1567
+ * @returns A new specification that represents the logical NOT of this specification.
1568
+
1569
+ *
1570
+ * @author Xeno
1571
+ * @version 1.0.0
1572
+ * @since 2025-09-30
1573
+ * @link https://github.com/xeno-js/xeno-js
1574
+ */
1575
+ not(): ISpecification<T>;
1576
+ }
1577
+
1578
+ /**
1579
+ * @description Type definition for the database context used in the application.
1580
+ * Polymorphically handles both PostgreSQL and libSQL (SQLite/Turso) engines.
1581
+ *
1582
+ * @author Xeno
1583
+ * @version 1.0.0
1584
+ * @since 2025-09-30
1585
+ * @link https://github.com/xeno-js/xeno-js
1586
+ */
1587
+ type DbContext<TSchema extends Dictionary = Dictionary> = NodePgDatabase<TSchema> | (LibSQLDatabase<TSchema> & {
1588
+ $client: Client;
1589
+ });
1590
+ /**
1591
+ * @description Type definition for the transaction object used in the database context.
1592
+ * Polymorphically handles both PostgreSQL and libSQL (SQLite/Turso) engines.
1593
+ *
1594
+ * @author Xeno
1595
+ * @version 1.0.0
1596
+ * @since 2025-09-30
1597
+ * @link https://github.com/xeno-js/xeno-js
1598
+ */
1599
+ type DbTransaction = Parameters<Parameters<DbContext['transaction']>[0]>[0];
1600
+
1601
+ /**
1602
+ * @description The XenoRegistry type is an alias for the ApplicationRegistry specialized with DbContext. It represents the registry of application services and dependencies, specifically tailored for applications that utilize a database context. This type is used throughout the application to ensure consistent typing and to facilitate dependency injection and service resolution.
1603
+ * @author Xeno
1604
+ * @version 1.0.0
1605
+ * @since 2025-09-30
1606
+ * @link https://github.com/xeno-js/xeno-js
1607
+ */
1608
+ type XenoRegistry<TSchema extends Dictionary = Dictionary, TExtensions = object> = ApplicationRegistry<DbContext<TSchema>, DbTransaction> & Readonly<Omit<TExtensions, keyof ApplicationRegistry<DbContext, DbTransaction>>>;
1609
+
1610
+ /**
1611
+ * @description The AppBuilder class provides a fluent, .NET-style API for configuring and bootstrapping the application.
1612
+ * It orchestrates the registration of various modules (CQRS, HTTP, Database, Logging, Auth) into the ServiceContainer.
1613
+
1614
+ *
1615
+ * @author Xeno
1616
+ * @version 1.0.0
1617
+ * @since 2025-09-30
1618
+ * @link https://github.com/xeno-js/xeno-js
1619
+ */
1620
+ declare class AppBuilder<TRegistry extends XenoRegistry = XenoRegistry> {
1621
+ private readonly _container;
1622
+ private readonly _configuration;
1623
+ constructor(container?: IServiceContainer<TRegistry>);
1624
+ private readonly _modules;
1625
+ private _pipelineConfig;
1626
+ private _config;
1627
+ private _middlewareConfig;
1628
+ private readonly _httpConfig;
1629
+ private _isContextModuleQueued;
1630
+ private _isMiddlewareModuleQueued;
1631
+ private _isPipelineModuleQueued;
1632
+ private _isLoggerModuleQueued;
1633
+ private _isAuthModuleQueued;
1634
+ private _isDbContextModuleQueued;
1635
+ private _isConcurrencyServiceQueued;
1636
+ private _isCacheModuleQueued;
1637
+ /**
1638
+ * @description Enables the use of middlewares in the application. Middlewares can be used for cross-cutting concerns such as logging, authentication, and request/response manipulation.
1639
+ * @returns The current instance of AppBuilder for method chaining.
1640
+
1641
+ *
1642
+ * @author Xeno
1643
+ * @version 1.0.0
1644
+ * @since 2025-09-30
1645
+ * @link https://github.com/xeno-js/xeno-js
1646
+ */
1647
+ addMiddlewares(setupAction: SetupAction<MiddlewareConfig, IConfigurationService>): this;
1648
+ /**
1649
+ * @description Enables the use of context in the application. Context can be used to store and manage request-specific data, such as user information, correlation IDs, and other metadata that needs to be accessible throughout the request lifecycle.
1650
+ * @returns The current instance of AppBuilder for method chaining.
1651
+
1652
+ *
1653
+ * @author Xeno
1654
+ * @version 1.0.0
1655
+ * @since 2025-09-30
1656
+ * @link https://github.com/xeno-js/xeno-js
1657
+ */
1658
+ addContext(): this;
1659
+ /**
1660
+ * @description Configures the logger for the application. This method allows you to set up logging options such as log level, console logging, and integration with external logging services like Sentry or Pino.
1661
+ * @param setupAction A callback function that receives a LoggerConfig object to configure the logger settings.
1662
+ * @returns The current instance of AppBuilder for method chaining.
1663
+
1664
+ *
1665
+ * @author Xeno
1666
+ * @version 1.0.0
1667
+ * @since 2025-09-30
1668
+ * @link https://github.com/xeno-js/xeno-js
1669
+ */
1670
+ addLogger(setupAction?: SetupAction<LoggerConfig<TRegistry>, IConfigurationService>): this;
1671
+ /**
1672
+ * @description Configures the caching settings for the application. This method allows you to set up caching options such as Redis configuration or in-memory caching.
1673
+ * @param setupAction A callback function that receives a CacheConfig object to configure the caching settings.
1674
+ * @returns The current instance of AppBuilder for method chaining.
1675
+
1676
+ *
1677
+ * @author Xeno
1678
+ * @version 1.0.0
1679
+ * @since 2025-09-30
1680
+ * @link https://github.com/xeno-js/xeno-js
1681
+ */
1682
+ addCache(setupAction?: SetupAction<CacheConfig, IConfigurationService>): this;
1683
+ /**
1684
+ * @description Configures the authentication client for the application. This method allows you to set up authentication options such as the authentication server URL, API key, and additional options.
1685
+ * @param setupAction A callback function that receives an AuthClientConfig object to configure the authentication client settings.
1686
+ * @returns The current instance of AppBuilder for method chaining.
1687
+
1688
+ *
1689
+ * @author Xeno
1690
+ * @version 1.0.0
1691
+ * @since 2025-09-30
1692
+ * @link https://github.com/xeno-js/xeno-js
1693
+ */
1694
+ addAuth(setupAction: SetupAction<AuthSsrConfig<SupabaseClientOptions<'public'>>, IConfigurationService>): this;
1695
+ /**
1696
+ * @description Configures the database settings for the application. This method allows you to set up database options such as enabling/disabling the database, connection string, and table definitions.
1697
+ * @param setupAction A callback function that receives a DbConfig object to configure the database settings.
1698
+ * @returns The current instance of AppBuilder for method chaining.
1699
+
1700
+ *
1701
+ * @author Xeno
1702
+ * @version 1.0.0
1703
+ * @since 2025-09-30
1704
+ * @link https://github.com/xeno-js/xeno-js
1705
+ */
1706
+ addDb(setupAction: SetupAction<DbConfig, IConfigurationService>): this;
1707
+ /**
1708
+ * @description Enables the use of the service for concurrency control in the application. This method allows you to limit the number of concurrent asynchronous tasks being executed, which is useful for managing system resources and preventing event loop blocking during massive batch operations.
1709
+ * @returns The current instance of AppBuilder for method chaining.
1710
+
1711
+ *
1712
+ * @author Xeno
1713
+ * @version 1.0.0
1714
+ * @since 2025-09-30
1715
+ * @link https://github.com/xeno-js/xeno-js
1716
+ */
1717
+ addConcurrencyService(): this;
1718
+ /**
1719
+ * @description Configures the CQRS pipeline settings for the application. This method allows you to set up various aspects of the CQRS pipeline, including performance monitoring, authorization, validation, command bus settings, and query bus settings.
1720
+ * @param setupAction A callback function that receives a PipelineConfig object to configure the CQRS pipeline settings.
1721
+ * @returns The current instance of AppBuilder for method chaining.
1722
+
1723
+ *
1724
+ * @author Xeno
1725
+ * @version 1.0.0
1726
+ * @since 2025-09-30
1727
+ * @link https://github.com/xeno-js/xeno-js
1728
+ */
1729
+ addPipeline(setupAction?: SetupAction<PipelineConfig<TRegistry>, IConfigurationService>): this;
1730
+ /**
1731
+ * @description Configures the HTTP core settings for the application. This method allows you to set up HTTP core options such as data source token, HTTP client configuration, and resilience settings.
1732
+ * @param setupAction A callback function that receives an HttpCoreConfig object to configure the HTTP core settings.
1733
+ * @returns The current instance of AppBuilder for method chaining.
1734
+
1735
+ *
1736
+ * @author Xeno
1737
+ * @version 1.0.0
1738
+ * @since 2025-09-30
1739
+ * @link https://github.com/xeno-js/xeno-js
1740
+ */
1741
+ addHttpCore(setupAction: SetupAction<HttpCoreConfig<TRegistry>, IConfigurationService>): this;
1742
+ addAllowOrigin(setupAction: SetupAction<string[], IConfigurationService>): this;
1743
+ /**
1744
+ * @description Registers services in the application. This method allows you to add custom services to the dependency injection container, enabling modular and organized configuration of services.
1745
+ * @param setupAction A callback function that receives the IServiceContainer to register services.
1746
+ * @returns The current instance of AppBuilder for method chaining.
1747
+ *
1748
+ * @author Xeno
1749
+ * @version 1.0.0
1750
+ * @since 2025-09-30
1751
+ * @link https://github.com/xeno-js/xeno-js
1752
+ */
1753
+ addServices(setupAction: SetupAction<IServiceContainer<TRegistry>, IConfigurationService>): this;
1754
+ /**
1755
+ * @description Registers a module in the application. A module is a self-contained unit of functionality that can configure services and dependencies in the service container. This method allows you to add custom modules to the application, enabling modular and organized configuration of services.
1756
+ * @param factory A factory function that creates the module instance.
1757
+ * @param opts Optional configuration options for the module.
1758
+ * @returns The current instance of AppBuilder for method chaining.
1759
+ *
1760
+ *
1761
+ * @author Xeno
1762
+ * @version 1.0.0
1763
+ * @since 2025-09-30
1764
+ * @link https://github.com/xeno-js/xeno-js
1765
+ */
1766
+ addModule<T>(name: string, factory: () => Promise<IModule<TRegistry, T>>, opts?: T): this;
1767
+ /**
1768
+ * @description Resolves a service from the dependency injection container.
1769
+ * @param token The injection token used to identify the service.
1770
+ * @returns The resolved service instance.
1771
+
1772
+ *
1773
+ * @author Xeno
1774
+ * @version 1.0.0
1775
+ * @since 2025-09-30
1776
+ * @link https://github.com/xeno-js/xeno-js
1777
+ */
1778
+ resolve<K extends keyof TRegistry>(token: K): TRegistry[K];
1779
+ /**
1780
+ * @description Finalizes the configuration and initializes all registered modules in the container.
1781
+ * @returns The fully configured ServiceContainer.
1782
+
1783
+ *
1784
+ * @author Xeno
1785
+ * @version 1.0.0
1786
+ * @since 2025-09-30
1787
+ * @link https://github.com/xeno-js/xeno-js
1788
+ */
1789
+ build(): Promise<IServiceContainer<TRegistry>>;
1790
+ /**
1791
+ * @description Queues the configuration of the CQRS pipeline module if it has not already been queued. This method ensures that the pipeline module is only added once, even if multiple pipeline-related configurations are made.
1792
+
1793
+ *
1794
+ * @author Xeno
1795
+ * @version 1.0.0
1796
+ * @since 2025-09-30
1797
+ * @link https://github.com/xeno-js/xeno-js
1798
+ */
1799
+ private _queuePipelineModule;
1800
+ /**
1801
+ * @description Queues the configuration of the middleware module if it has not already been queued. This method ensures that the middleware module is only added once, even if multiple middleware-related configurations are made.
1802
+
1803
+ *
1804
+ * @author Xeno
1805
+ * @version 1.0.0
1806
+ * @since 2025-09-30
1807
+ * @link https://github.com/xeno-js/xeno-js
1808
+ */
1809
+ private _queueMiddlewareModule;
1810
+ /**
1811
+ * @description Queues the configuration of the context module if it has not already been queued. This method ensures that the context module is only added once, even if multiple context-related configurations are made.
1812
+
1813
+ *
1814
+ * @author Xeno
1815
+ * @version 1.0.0
1816
+ * @since 2025-09-30
1817
+ * @link https://github.com/xeno-js/xeno-js
1818
+ */
1819
+ private _queueContextModule;
1820
+ }
1821
+
1822
+ interface SupabaseServerAuthFactoryInput<TRegistry extends XenoRegistry> {
1823
+ config: AuthSsrConfig<SupabaseClientOptions<'public'>>;
1824
+ container: IServiceContainer<TRegistry>;
1825
+ }
1826
+ declare class SupabaseServerAuthFactory<TRegistry extends XenoRegistry = XenoRegistry> implements IFactory<SupabaseServerAuthFactoryInput<TRegistry>, IExtendendService> {
1827
+ create({ config, container, }: SupabaseServerAuthFactoryInput<TRegistry>): IExtendendService;
1828
+ }
1829
+
1830
+ /**
1831
+ * An abstract generic read-only DAO that provides basic read operations for entities of type T, using a Data Transfer Object (DTO) of type TDto for data access. This class relies on an IReadDataSource to perform database operations and an IMapper to convert between entities and DTOs.
1832
+ * @template T - The type of the entity that the DAO will manage.
1833
+ * @template TDto - The type of the Data Transfer Object (DTO) used for data access.
1834
+
1835
+ *
1836
+ * @author Xeno
1837
+ * @version 1.0.0
1838
+ * @since 2025-09-30
1839
+ * @link https://github.com/xeno-js/xeno-js
1840
+ */
1841
+ declare abstract class ReadDao<T, TDto> implements IReadDao<T> {
1842
+ private readonly _dataSource;
1843
+ private readonly _mapper;
1844
+ /**
1845
+ * Constructs a new ReadDao instance.
1846
+ * @param _dataSource An instance of IReadDataSource used to execute SQL queries and commands for data access.
1847
+ * @param _mapper An instance of IMapper used to convert between entities and DTOs.
1848
+ *
1849
+ *
1850
+ * @author Xeno
1851
+ * @version 1.0.0
1852
+ * @since 2025-09-30
1853
+ * @link https://github.com/xeno-js/xeno-js
1854
+ */
1855
+ constructor(_dataSource: IReadDataSource<TDto>, _mapper: IMapper<T, TDto>);
1856
+ findById(id: string | number, ctx: UserContext, signal: Optional<AbortSignal>): Promise<ResultType<Optional<T>>>;
1857
+ findAll(ctx: UserContext, signal: Optional<AbortSignal>): Promise<ResultType<T[]>>;
1858
+ }
1859
+
1860
+ /**
1861
+ * An abstract generic repository that provides basic CRUD operations for entities of type T, using a Data Transfer Object (DTO) of type TDto for data access. This class relies on an IWriteDataSource to perform database operations and an IMapper to convert between entities and DTOs.
1862
+ * @template T - The type of the entity that the repository will manage.
1863
+ * @template TDto - The type of the Data Transfer Object (DTO) used for data access.
1864
+
1865
+ *
1866
+ * @author Xeno
1867
+ * @version 1.0.0
1868
+ * @since 2025-09-30
1869
+ * @link https://github.com/xeno-js/xeno-js
1870
+ */
1871
+ declare abstract class Repository<T, TDto> implements IRepository<T> {
1872
+ private readonly _dataSource;
1873
+ private readonly _mapper;
1874
+ /**
1875
+ * Constructs a new Repository instance.
1876
+ * @param _dataSource An instance of IWriteDataSource used to execute SQL queries and commands for data access.
1877
+ * @param _mapper An instance of IMapper used to convert between entities and DTOs.
1878
+ *
1879
+ *
1880
+ * @author Xeno
1881
+ * @version 1.0.0
1882
+ * @since 2025-09-30
1883
+ * @link https://github.com/xeno-js/xeno-js
1884
+ */
1885
+ constructor(_dataSource: IWriteDataSource<TDto>, _mapper: IMapper<T, TDto>);
1886
+ findById(id: string | number, ctx: UserContext, signal: Optional<AbortSignal>): Promise<ResultType<Optional<T>>>;
1887
+ findAll(ctx: UserContext, signal: Optional<AbortSignal>): Promise<ResultType<T[]>>;
1888
+ save(entity: T, signal: Optional<AbortSignal>): Promise<ResultType<void>>;
1889
+ delete(entity: T, ctx: UserContext, signal: Optional<AbortSignal>): Promise<ResultType<void>>;
1890
+ update(id: string | number, entity: Partial<T>, ctx: UserContext, signal: Optional<AbortSignal>): Promise<ResultType<void>>;
1891
+ }
1892
+
1893
+ /**
1894
+ * BaseController is an abstract class that implements the IController interface. It provides a foundation for creating specific controllers that handle incoming requests and return responses. The class requires a mediator to facilitate communication between different parts of the application.
1895
+ * @template TRequest - The type of the request object that the controller will handle.
1896
+ * @template TResponse - The type of the response object that the controller will return.
1897
+ *
1898
+ * @author Xeno
1899
+ * @version 1.0.0
1900
+ * @since 2025-09-30
1901
+ * @link https://github.com/xeno-js/xeno-js
1902
+ */
1903
+ declare abstract class BaseController<TRequest, TResponse> implements IController<TRequest, TResponse> {
1904
+ private readonly _requestContext;
1905
+ private readonly _mediator;
1906
+ /**
1907
+ * Constructs a new instance of the BaseController class.
1908
+ * @param _requestContext - An instance of IContextAccessor used to manage the execution context for requests.
1909
+ * @param _mediator - An instance of IMediator used to facilitate communication between different parts of the application.
1910
+ *
1911
+ * @author Xeno
1912
+ * @version 1.0.0
1913
+ * @since 2025-09-30
1914
+ * @link https://github.com/xeno-js/xeno-js
1915
+ */
1916
+ constructor(_requestContext: IContextAccessor<RequestContext>, _mediator: IMediator);
1917
+ abstract handle(request: TRequest): Promise<ResponseDto<TResponse>>;
1918
+ /**
1919
+ * Helper to return a successful 200/201 response.
1920
+ * @param data - The data to include in the response.
1921
+ * @param status - The HTTP status code (default is 200).
1922
+ * @param meta - Optional metadata to include in the response.
1923
+ * @param headers - Optional headers to include in the response.
1924
+ * @returns A ResponseDto containing the data and status.
1925
+ *
1926
+ * @author Xeno
1927
+ * @version 1.0.0
1928
+ * @since 2025-09-30
1929
+ * @link https://github.com/xeno-js/xeno-js
1930
+ */
1931
+ protected ok<T>(data: T, status?: number, meta?: Optional<Dictionary>, headers?: Optional<Dictionary<string[]>>): ResponseDto<T>;
1932
+ /**
1933
+ * Helper to automatically map a failed Result (from the CQRS pipeline)
1934
+ * into a standardized ErrorResponseDto.
1935
+ * @param error - The AppError instance representing the error.
1936
+ * @param details - Optional additional details about the error.
1937
+ * @param headers - Optional headers to include in the error response.
1938
+ * @returns A ResponseDto representing the error response.
1939
+ *
1940
+ * @author Xeno
1941
+ * @version 1.0.0
1942
+ * @since 2025-09-30
1943
+ * @link https://github.com/xeno-js/xeno-js
1944
+ */
1945
+ protected fail(error: AppError, details?: Optional<string>, headers?: Optional<Dictionary<string[]>>): ResponseDto<TResponse>;
1946
+ /**
1947
+ * Helper to send a query through the mediator and return the result.
1948
+ * @param request - The IQuery instance to be sent.
1949
+ * @returns A promise resolving to the result of the query.
1950
+ *
1951
+ * @author Xeno
1952
+ * @version 1.0.0
1953
+ * @since 2025-09-30
1954
+ * @link https://github.com/xeno-js/xeno-js
1955
+ */
1956
+ protected _query(request: IQuery<TResponse>): Promise<ResultType<TResponse>>;
1957
+ /**
1958
+ * Helper to send a command through the mediator and return the result.
1959
+ * @param request - The ICommand instance to be sent.
1960
+ * @returns A promise resolving to the result of the command.
1961
+ *
1962
+ * @author Xeno
1963
+ * @version 1.0.0
1964
+ * @since 2025-09-30
1965
+ * @link https://github.com/xeno-js/xeno-js
1966
+ */
1967
+ protected _send(request: ICommand<TResponse>): Promise<ResultType<TResponse>>;
1968
+ protected getContext(): Optional<RequestContext>;
1969
+ }
1970
+
1971
+ export { AppBuilder, type ApplicationRegistry, type AuthSsrConfig, BaseAuthorizationStrategy, BaseController, BaseHandler, ContainerUtils, type DbContext, type DbTransaction, type ExecutionContext, type HttpConfig, type HttpCoreConfig, type IAllowMethod, type IAllowOrigin, type IModule, type IRequestContext, type IServiceContainer, type IServiceProvider, type IServiceScope, type IServiceScopeAccessor, type ISsrCookie, type ISsrCookieHandler, type ISsrCookieToSet, type Lifetime, type LoggerConfig, type MiddlewareConfig, type PinoLoggerConfig, type PipelineConfig, ReadDao, Repository, type ResilienceConfig, type SchemaConfig, type SentryLoggerConfig, type ServiceDescriptor, Specification, SupabaseServerAuthFactory, type XenoRegistry };