@xeno-js/core 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICache, Optional, IExtendendAuthService, IBaseAuthService, ICacheKeyBuilder, IPipelineBehavior, ICommand, IConcurrencyService, IConfigurationService, ILogger, IMediator, IMiddleware, HttpHeaders, IQuery, RequestContext, IServiceResilience, IServiceExtractor, Metadata, IUnitOfWork, IDisposable, IValidatorService, IIdentityAccessor, IContextAccessor, INetworkContextAccessor, IFactory, UserContext, Factory, IBaseAccessor, Identity, HttpMethod, AuthConfig, CookieOptions, SetupAction, HttpClientConfig, LogLevel, ILoggerClient, Dictionary, AuthPolicy, IStrategy, IRequest, ResponseDto, IHandler, ResultType, ISpecification, CacheConfig, DbConfig, IReadDao, IReadDataSource, IMapper, IRepository, IWriteDataSource, IController, AppError } from '@xeno-js/shared';
1
+ import { ICache, Optional, IExtendendAuthService, IBaseAuthService, ICacheKeyBuilder, IPipelineBehavior, ICommand, IConcurrencyService, IConfigurationService, ILogger, IMediator, IMiddleware, HttpHeaders, IQuery, RequestContext, IServiceResilience, IServiceExtractor, Metadata, IUnitOfWork, IDisposable, IValidatorService, IIdentityAccessor, IContextAccessor, INetworkContextAccessor, IFactory, UserContext, ITransactionState, Factory, IBaseAccessor, Identity, HttpMethod, AuthConfig, CookieOptions, SetupAction, HttpClientConfig, LogLevel, ILoggerClient, Dictionary, AuthPolicy, IStrategy, IRequest, ResponseDto, IHandler, ResultType, ISpecification, CacheConfig, DbConfig, IReadDao, IReadDataSource, IMapper, IRepository, IWriteDataSource, IController, AppError } from '@xeno-js/shared';
2
2
  export * from '@xeno-js/shared';
3
3
  export { Query as BaseQuery } from '@xeno-js/shared';
4
4
  import { SupabaseClientOptions } from '@supabase/supabase-js';
@@ -54,7 +54,7 @@ interface IRateLimitKeyBuilder {
54
54
  * @since 2025-09-30
55
55
  * @link https://github.com/xeno-js/xeno-js
56
56
  */
57
- interface ApplicationRegistry<T = unknown> {
57
+ interface ApplicationRegistry<T = unknown, Ttx = unknown> {
58
58
  /** @description Token used to register and resolve the Extended AuthService instance in the dependency injection container.
59
59
  *
60
60
  * @author Xeno
@@ -255,6 +255,14 @@ interface ApplicationRegistry<T = unknown> {
255
255
  * @link https://github.com/xeno-js/xeno-js
256
256
  */
257
257
  readonly USER_CONTEXT_FACTORY: IFactory<void, UserContext>;
258
+ /** @description Token used to register and resolve the TransactionState instance in the dependency injection container.
259
+ *
260
+ * @author Xeno
261
+ * @version 1.0.0
262
+ * @since 2025-09-30
263
+ * @link https://github.com/xeno-js/xeno-js
264
+ */
265
+ readonly TRANSACTION_STATE: ITransactionState<Ttx>;
258
266
  }
259
267
 
260
268
  /**
@@ -1581,7 +1589,7 @@ type DbTransaction = Parameters<Parameters<DbContext['transaction']>[0]>[0];
1581
1589
  * @since 2025-09-30
1582
1590
  * @link https://github.com/xeno-js/xeno-js
1583
1591
  */
1584
- type XenoRegistry<TSchema extends Dictionary = Dictionary, TExtensions = object> = ApplicationRegistry<DbContext<TSchema>> & Readonly<Omit<TExtensions, keyof ApplicationRegistry<DbContext<TSchema>>>>;
1592
+ type XenoRegistry<TSchema extends Dictionary = Dictionary, TExtensions = object> = ApplicationRegistry<DbContext<TSchema>, DbTransaction> & Readonly<Omit<TExtensions, keyof ApplicationRegistry<DbContext<TSchema>, DbTransaction>>>;
1585
1593
 
1586
1594
  /**
1587
1595
  * @description The AppBuilder class provides a fluent, .NET-style API for configuring and bootstrapping the application.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ICache, Optional, IExtendendAuthService, IBaseAuthService, ICacheKeyBuilder, IPipelineBehavior, ICommand, IConcurrencyService, IConfigurationService, ILogger, IMediator, IMiddleware, HttpHeaders, IQuery, RequestContext, IServiceResilience, IServiceExtractor, Metadata, IUnitOfWork, IDisposable, IValidatorService, IIdentityAccessor, IContextAccessor, INetworkContextAccessor, IFactory, UserContext, Factory, IBaseAccessor, Identity, HttpMethod, AuthConfig, CookieOptions, SetupAction, HttpClientConfig, LogLevel, ILoggerClient, Dictionary, AuthPolicy, IStrategy, IRequest, ResponseDto, IHandler, ResultType, ISpecification, CacheConfig, DbConfig, IReadDao, IReadDataSource, IMapper, IRepository, IWriteDataSource, IController, AppError } from '@xeno-js/shared';
1
+ import { ICache, Optional, IExtendendAuthService, IBaseAuthService, ICacheKeyBuilder, IPipelineBehavior, ICommand, IConcurrencyService, IConfigurationService, ILogger, IMediator, IMiddleware, HttpHeaders, IQuery, RequestContext, IServiceResilience, IServiceExtractor, Metadata, IUnitOfWork, IDisposable, IValidatorService, IIdentityAccessor, IContextAccessor, INetworkContextAccessor, IFactory, UserContext, ITransactionState, Factory, IBaseAccessor, Identity, HttpMethod, AuthConfig, CookieOptions, SetupAction, HttpClientConfig, LogLevel, ILoggerClient, Dictionary, AuthPolicy, IStrategy, IRequest, ResponseDto, IHandler, ResultType, ISpecification, CacheConfig, DbConfig, IReadDao, IReadDataSource, IMapper, IRepository, IWriteDataSource, IController, AppError } from '@xeno-js/shared';
2
2
  export * from '@xeno-js/shared';
3
3
  export { Query as BaseQuery } from '@xeno-js/shared';
4
4
  import { SupabaseClientOptions } from '@supabase/supabase-js';
@@ -54,7 +54,7 @@ interface IRateLimitKeyBuilder {
54
54
  * @since 2025-09-30
55
55
  * @link https://github.com/xeno-js/xeno-js
56
56
  */
57
- interface ApplicationRegistry<T = unknown> {
57
+ interface ApplicationRegistry<T = unknown, Ttx = unknown> {
58
58
  /** @description Token used to register and resolve the Extended AuthService instance in the dependency injection container.
59
59
  *
60
60
  * @author Xeno
@@ -255,6 +255,14 @@ interface ApplicationRegistry<T = unknown> {
255
255
  * @link https://github.com/xeno-js/xeno-js
256
256
  */
257
257
  readonly USER_CONTEXT_FACTORY: IFactory<void, UserContext>;
258
+ /** @description Token used to register and resolve the TransactionState instance in the dependency injection container.
259
+ *
260
+ * @author Xeno
261
+ * @version 1.0.0
262
+ * @since 2025-09-30
263
+ * @link https://github.com/xeno-js/xeno-js
264
+ */
265
+ readonly TRANSACTION_STATE: ITransactionState<Ttx>;
258
266
  }
259
267
 
260
268
  /**
@@ -1581,7 +1589,7 @@ type DbTransaction = Parameters<Parameters<DbContext['transaction']>[0]>[0];
1581
1589
  * @since 2025-09-30
1582
1590
  * @link https://github.com/xeno-js/xeno-js
1583
1591
  */
1584
- type XenoRegistry<TSchema extends Dictionary = Dictionary, TExtensions = object> = ApplicationRegistry<DbContext<TSchema>> & Readonly<Omit<TExtensions, keyof ApplicationRegistry<DbContext<TSchema>>>>;
1592
+ type XenoRegistry<TSchema extends Dictionary = Dictionary, TExtensions = object> = ApplicationRegistry<DbContext<TSchema>, DbTransaction> & Readonly<Omit<TExtensions, keyof ApplicationRegistry<DbContext<TSchema>, DbTransaction>>>;
1585
1593
 
1586
1594
  /**
1587
1595
  * @description The AppBuilder class provides a fluent, .NET-style API for configuring and bootstrapping the application.
package/dist/index.js CHANGED
@@ -3011,12 +3011,16 @@ var init_db_module = __esm({
3011
3011
  const { DbUtils: DbUtils2 } = await Promise.resolve().then(() => (init_db_utils(), db_utils_exports));
3012
3012
  const db = opts.enableSqlLite ? await DbUtils2.addSqlLite(opts) : await DbUtils2.addDbClient(opts);
3013
3013
  const { TransactionState: TransactionState2 } = await Promise.resolve().then(() => (init_transaction_state(), transaction_state_exports));
3014
- const ttx = new TransactionState2();
3014
+ container.addScoped("TRANSACTION_STATE", () => {
3015
+ return new TransactionState2();
3016
+ });
3015
3017
  const { UnitOfWork: UnitOfWork2 } = await Promise.resolve().then(() => (init_unit_of_work(), unit_of_work_exports));
3016
- container.addScoped(TOKENS4.UNIT_OF_WORK, () => {
3018
+ container.addScoped(TOKENS4.UNIT_OF_WORK, (c) => {
3019
+ const ttx = c.resolve("TRANSACTION_STATE");
3017
3020
  return new UnitOfWork2(db, ttx);
3018
3021
  });
3019
- container.addScoped(TOKENS4.DB_CONTEXT, () => {
3022
+ container.addScoped(TOKENS4.DB_CONTEXT, (c) => {
3023
+ const ttx = c.resolve("TRANSACTION_STATE");
3020
3024
  return new Proxy(db, {
3021
3025
  get(_target, prop, receiver) {
3022
3026
  const activeState = ttx.state;
@@ -4522,6 +4526,12 @@ var ServiceContainer = class {
4522
4526
  this.registrations.set(token, { token, lifetime, factory });
4523
4527
  }
4524
4528
  resolve(token) {
4529
+ const registration = this.registrations.get(token);
4530
+ if (registration?.lifetime === "scoped") {
4531
+ throw new Error(
4532
+ `[DI Container Error]: Scoped service '${String(token)}' requires an active scope.`
4533
+ );
4534
+ }
4525
4535
  return this.internalExecuteInContext(() => this.rootScope.resolve(token));
4526
4536
  }
4527
4537
  createScope() {