@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.cjs
CHANGED
|
@@ -2419,9 +2419,7 @@ var init_cockatiel_resilience_factory = __esm({
|
|
|
2419
2419
|
}
|
|
2420
2420
|
}
|
|
2421
2421
|
if (isNetworkError) return true;
|
|
2422
|
-
if (import_shared53.Guards.isDefined(status))
|
|
2423
|
-
return status === 408 || status === 429 || status >= 500 && status < 600;
|
|
2424
|
-
}
|
|
2422
|
+
if (import_shared53.Guards.isDefined(status)) return status === 408 || status >= 500 && status < 600;
|
|
2425
2423
|
return false;
|
|
2426
2424
|
}
|
|
2427
2425
|
isTransientAndIdempotent(error) {
|
|
@@ -2990,12 +2988,16 @@ var init_db_module = __esm({
|
|
|
2990
2988
|
const { DbUtils: DbUtils2 } = await Promise.resolve().then(() => (init_db_utils(), db_utils_exports));
|
|
2991
2989
|
const db = opts.enableSqlLite ? await DbUtils2.addSqlLite(opts) : await DbUtils2.addDbClient(opts);
|
|
2992
2990
|
const { TransactionState: TransactionState2 } = await Promise.resolve().then(() => (init_transaction_state(), transaction_state_exports));
|
|
2993
|
-
|
|
2991
|
+
container.addScoped("TRANSACTION_STATE", () => {
|
|
2992
|
+
return new TransactionState2();
|
|
2993
|
+
});
|
|
2994
2994
|
const { UnitOfWork: UnitOfWork2 } = await Promise.resolve().then(() => (init_unit_of_work(), unit_of_work_exports));
|
|
2995
|
-
container.addScoped(TOKENS4.UNIT_OF_WORK, () => {
|
|
2995
|
+
container.addScoped(TOKENS4.UNIT_OF_WORK, (c) => {
|
|
2996
|
+
const ttx = c.resolve("TRANSACTION_STATE");
|
|
2996
2997
|
return new UnitOfWork2(db, ttx);
|
|
2997
2998
|
});
|
|
2998
|
-
container.addScoped(TOKENS4.DB_CONTEXT, () => {
|
|
2999
|
+
container.addScoped(TOKENS4.DB_CONTEXT, (c) => {
|
|
3000
|
+
const ttx = c.resolve("TRANSACTION_STATE");
|
|
2999
3001
|
return new Proxy(db, {
|
|
3000
3002
|
get(_target, prop, receiver) {
|
|
3001
3003
|
const activeState = ttx.state;
|
|
@@ -3320,8 +3322,8 @@ var init_cqrs_module = __esm({
|
|
|
3320
3322
|
);
|
|
3321
3323
|
if (Guards46.isDefined(validationPipelines)) pipelines.push(validationPipelines);
|
|
3322
3324
|
}
|
|
3323
|
-
const commandPipelines = pipelines;
|
|
3324
|
-
const queryPipelines = pipelines;
|
|
3325
|
+
const commandPipelines = [...pipelines];
|
|
3326
|
+
const queryPipelines = [...pipelines];
|
|
3325
3327
|
if (Guards46.isDefined(opts.commandBus.idempotency) || Guards46.isDefined(opts.commandBus.concurrency)) {
|
|
3326
3328
|
const { PipelineUtils: PipelineUtils2 } = await Promise.resolve().then(() => (init_pipeline_utils(), pipeline_utils_exports));
|
|
3327
3329
|
const newCommandPipelines = await PipelineUtils2.addCommand(container, opts.commandBus);
|
|
@@ -4469,6 +4471,12 @@ var ServiceContainer = class {
|
|
|
4469
4471
|
this.registrations.set(token, { token, lifetime, factory });
|
|
4470
4472
|
}
|
|
4471
4473
|
resolve(token) {
|
|
4474
|
+
const registration = this.registrations.get(token);
|
|
4475
|
+
if (registration?.lifetime === "scoped") {
|
|
4476
|
+
throw new Error(
|
|
4477
|
+
`[DI Container Error]: Scoped service '${String(token)}' requires an active scope.`
|
|
4478
|
+
);
|
|
4479
|
+
}
|
|
4472
4480
|
return this.internalExecuteInContext(() => this.rootScope.resolve(token));
|
|
4473
4481
|
}
|
|
4474
4482
|
createScope() {
|
|
@@ -4588,6 +4596,7 @@ var isDisposable = Object.freeze({
|
|
|
4588
4596
|
var AppBuilder = class {
|
|
4589
4597
|
_container = new ServiceContainer();
|
|
4590
4598
|
_configuration;
|
|
4599
|
+
_isBuilded = false;
|
|
4591
4600
|
constructor(container) {
|
|
4592
4601
|
this._container = container ?? new ServiceContainer();
|
|
4593
4602
|
this._container.addSingleton(
|
|
@@ -4955,6 +4964,7 @@ var AppBuilder = class {
|
|
|
4955
4964
|
* @link https://github.com/xeno-js/xeno-js
|
|
4956
4965
|
*/
|
|
4957
4966
|
async build() {
|
|
4967
|
+
if (this._isBuilded) return this._container;
|
|
4958
4968
|
console.info("\u2699\uFE0F Bootstrapping application modules...");
|
|
4959
4969
|
const sortedModules = this._modules.sort((a, b) => a.priority - b.priority);
|
|
4960
4970
|
for (const queued of sortedModules) {
|
|
@@ -4975,6 +4985,7 @@ var AppBuilder = class {
|
|
|
4975
4985
|
}
|
|
4976
4986
|
}
|
|
4977
4987
|
console.info("\u2705 Application modules bootstrapped successfully.");
|
|
4988
|
+
this._isBuilded = true;
|
|
4978
4989
|
return this._container;
|
|
4979
4990
|
}
|
|
4980
4991
|
// ─────────────────────────────────────────────────────────────────────────────
|