@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.cjs CHANGED
@@ -2990,12 +2990,16 @@ var init_db_module = __esm({
2990
2990
  const { DbUtils: DbUtils2 } = await Promise.resolve().then(() => (init_db_utils(), db_utils_exports));
2991
2991
  const db = opts.enableSqlLite ? await DbUtils2.addSqlLite(opts) : await DbUtils2.addDbClient(opts);
2992
2992
  const { TransactionState: TransactionState2 } = await Promise.resolve().then(() => (init_transaction_state(), transaction_state_exports));
2993
- const ttx = new TransactionState2();
2993
+ container.addScoped("TRANSACTION_STATE", () => {
2994
+ return new TransactionState2();
2995
+ });
2994
2996
  const { UnitOfWork: UnitOfWork2 } = await Promise.resolve().then(() => (init_unit_of_work(), unit_of_work_exports));
2995
- container.addScoped(TOKENS4.UNIT_OF_WORK, () => {
2997
+ container.addScoped(TOKENS4.UNIT_OF_WORK, (c) => {
2998
+ const ttx = c.resolve("TRANSACTION_STATE");
2996
2999
  return new UnitOfWork2(db, ttx);
2997
3000
  });
2998
- container.addScoped(TOKENS4.DB_CONTEXT, () => {
3001
+ container.addScoped(TOKENS4.DB_CONTEXT, (c) => {
3002
+ const ttx = c.resolve("TRANSACTION_STATE");
2999
3003
  return new Proxy(db, {
3000
3004
  get(_target, prop, receiver) {
3001
3005
  const activeState = ttx.state;
@@ -4469,6 +4473,12 @@ var ServiceContainer = class {
4469
4473
  this.registrations.set(token, { token, lifetime, factory });
4470
4474
  }
4471
4475
  resolve(token) {
4476
+ const registration = this.registrations.get(token);
4477
+ if (registration?.lifetime === "scoped") {
4478
+ throw new Error(
4479
+ `[DI Container Error]: Scoped service '${String(token)}' requires an active scope.`
4480
+ );
4481
+ }
4472
4482
  return this.internalExecuteInContext(() => this.rootScope.resolve(token));
4473
4483
  }
4474
4484
  createScope() {