@xeno-js/core 0.1.10 → 0.1.12
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/LICENSE +18 -12
- package/README.md +358 -322
- package/dist/index.cjs +19 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/package.json +16 -11
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
|
|
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.
|
|
@@ -1596,6 +1604,7 @@ type XenoRegistry<TSchema extends Dictionary = Dictionary, TExtensions = object>
|
|
|
1596
1604
|
declare class AppBuilder<TRegistry extends XenoRegistry = XenoRegistry> {
|
|
1597
1605
|
private readonly _container;
|
|
1598
1606
|
private readonly _configuration;
|
|
1607
|
+
private _isBuilded;
|
|
1599
1608
|
constructor(container?: IServiceContainer<TRegistry>);
|
|
1600
1609
|
private readonly _modules;
|
|
1601
1610
|
private _pipelineConfig;
|
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
|
|
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.
|
|
@@ -1596,6 +1604,7 @@ type XenoRegistry<TSchema extends Dictionary = Dictionary, TExtensions = object>
|
|
|
1596
1604
|
declare class AppBuilder<TRegistry extends XenoRegistry = XenoRegistry> {
|
|
1597
1605
|
private readonly _container;
|
|
1598
1606
|
private readonly _configuration;
|
|
1607
|
+
private _isBuilded;
|
|
1599
1608
|
constructor(container?: IServiceContainer<TRegistry>);
|
|
1600
1609
|
private readonly _modules;
|
|
1601
1610
|
private _pipelineConfig;
|
package/dist/index.js
CHANGED
|
@@ -2435,9 +2435,7 @@ var init_cockatiel_resilience_factory = __esm({
|
|
|
2435
2435
|
}
|
|
2436
2436
|
}
|
|
2437
2437
|
if (isNetworkError) return true;
|
|
2438
|
-
if (Guards31.isDefined(status))
|
|
2439
|
-
return status === 408 || status === 429 || status >= 500 && status < 600;
|
|
2440
|
-
}
|
|
2438
|
+
if (Guards31.isDefined(status)) return status === 408 || status >= 500 && status < 600;
|
|
2441
2439
|
return false;
|
|
2442
2440
|
}
|
|
2443
2441
|
isTransientAndIdempotent(error) {
|
|
@@ -3011,12 +3009,16 @@ var init_db_module = __esm({
|
|
|
3011
3009
|
const { DbUtils: DbUtils2 } = await Promise.resolve().then(() => (init_db_utils(), db_utils_exports));
|
|
3012
3010
|
const db = opts.enableSqlLite ? await DbUtils2.addSqlLite(opts) : await DbUtils2.addDbClient(opts);
|
|
3013
3011
|
const { TransactionState: TransactionState2 } = await Promise.resolve().then(() => (init_transaction_state(), transaction_state_exports));
|
|
3014
|
-
|
|
3012
|
+
container.addScoped("TRANSACTION_STATE", () => {
|
|
3013
|
+
return new TransactionState2();
|
|
3014
|
+
});
|
|
3015
3015
|
const { UnitOfWork: UnitOfWork2 } = await Promise.resolve().then(() => (init_unit_of_work(), unit_of_work_exports));
|
|
3016
|
-
container.addScoped(TOKENS4.UNIT_OF_WORK, () => {
|
|
3016
|
+
container.addScoped(TOKENS4.UNIT_OF_WORK, (c) => {
|
|
3017
|
+
const ttx = c.resolve("TRANSACTION_STATE");
|
|
3017
3018
|
return new UnitOfWork2(db, ttx);
|
|
3018
3019
|
});
|
|
3019
|
-
container.addScoped(TOKENS4.DB_CONTEXT, () => {
|
|
3020
|
+
container.addScoped(TOKENS4.DB_CONTEXT, (c) => {
|
|
3021
|
+
const ttx = c.resolve("TRANSACTION_STATE");
|
|
3020
3022
|
return new Proxy(db, {
|
|
3021
3023
|
get(_target, prop, receiver) {
|
|
3022
3024
|
const activeState = ttx.state;
|
|
@@ -3341,8 +3343,8 @@ var init_cqrs_module = __esm({
|
|
|
3341
3343
|
);
|
|
3342
3344
|
if (Guards46.isDefined(validationPipelines)) pipelines.push(validationPipelines);
|
|
3343
3345
|
}
|
|
3344
|
-
const commandPipelines = pipelines;
|
|
3345
|
-
const queryPipelines = pipelines;
|
|
3346
|
+
const commandPipelines = [...pipelines];
|
|
3347
|
+
const queryPipelines = [...pipelines];
|
|
3346
3348
|
if (Guards46.isDefined(opts.commandBus.idempotency) || Guards46.isDefined(opts.commandBus.concurrency)) {
|
|
3347
3349
|
const { PipelineUtils: PipelineUtils2 } = await Promise.resolve().then(() => (init_pipeline_utils(), pipeline_utils_exports));
|
|
3348
3350
|
const newCommandPipelines = await PipelineUtils2.addCommand(container, opts.commandBus);
|
|
@@ -4522,6 +4524,12 @@ var ServiceContainer = class {
|
|
|
4522
4524
|
this.registrations.set(token, { token, lifetime, factory });
|
|
4523
4525
|
}
|
|
4524
4526
|
resolve(token) {
|
|
4527
|
+
const registration = this.registrations.get(token);
|
|
4528
|
+
if (registration?.lifetime === "scoped") {
|
|
4529
|
+
throw new Error(
|
|
4530
|
+
`[DI Container Error]: Scoped service '${String(token)}' requires an active scope.`
|
|
4531
|
+
);
|
|
4532
|
+
}
|
|
4525
4533
|
return this.internalExecuteInContext(() => this.rootScope.resolve(token));
|
|
4526
4534
|
}
|
|
4527
4535
|
createScope() {
|
|
@@ -4641,6 +4649,7 @@ var isDisposable = Object.freeze({
|
|
|
4641
4649
|
var AppBuilder = class {
|
|
4642
4650
|
_container = new ServiceContainer();
|
|
4643
4651
|
_configuration;
|
|
4652
|
+
_isBuilded = false;
|
|
4644
4653
|
constructor(container) {
|
|
4645
4654
|
this._container = container ?? new ServiceContainer();
|
|
4646
4655
|
this._container.addSingleton(
|
|
@@ -5008,6 +5017,7 @@ var AppBuilder = class {
|
|
|
5008
5017
|
* @link https://github.com/xeno-js/xeno-js
|
|
5009
5018
|
*/
|
|
5010
5019
|
async build() {
|
|
5020
|
+
if (this._isBuilded) return this._container;
|
|
5011
5021
|
console.info("\u2699\uFE0F Bootstrapping application modules...");
|
|
5012
5022
|
const sortedModules = this._modules.sort((a, b) => a.priority - b.priority);
|
|
5013
5023
|
for (const queued of sortedModules) {
|
|
@@ -5028,6 +5038,7 @@ var AppBuilder = class {
|
|
|
5028
5038
|
}
|
|
5029
5039
|
}
|
|
5030
5040
|
console.info("\u2705 Application modules bootstrapped successfully.");
|
|
5041
|
+
this._isBuilded = true;
|
|
5031
5042
|
return this._container;
|
|
5032
5043
|
}
|
|
5033
5044
|
// ─────────────────────────────────────────────────────────────────────────────
|