@kuckit/infrastructure 2.0.2 → 2.0.5

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.
Files changed (114) hide show
  1. package/dist/{apply-decorators-CaHIAL5X.js → apply-decorators-DA33OBa7.js} +2 -2
  2. package/dist/{apply-decorators-CaHIAL5X.js.map → apply-decorators-DA33OBa7.js.map} +1 -1
  3. package/dist/{apply-decorators-CW23qWy7.d.ts → apply-decorators-zka0zqoX.d.ts} +1 -1
  4. package/dist/cache/in-memory-cache-store.d.ts +1 -1
  5. package/dist/cache/in-memory-cache-store.js +1 -1
  6. package/dist/cache/index.d.ts +2 -2
  7. package/dist/cache/index.js +2 -2
  8. package/dist/{core.module-_mfoxc8b.d.ts → core.module-BEuDFLDA.d.ts} +2 -2
  9. package/dist/{core.module-ehJ0bdNr.js → core.module-oSFmg8ER.js} +5 -5
  10. package/dist/{core.module-ehJ0bdNr.js.map → core.module-oSFmg8ER.js.map} +1 -1
  11. package/dist/db/drizzle/db.d.ts +1 -1
  12. package/dist/db/drizzle/repositories/index.d.ts +2 -2
  13. package/dist/db/drizzle/repositories/user.drizzle.d.ts +1 -1
  14. package/dist/db/transaction.d.ts +1 -1
  15. package/dist/{db-tAPHBDyL.d.ts → db-Brm6l10l.d.ts} +1 -1
  16. package/dist/decorators/apply-decorators.d.ts +1 -1
  17. package/dist/decorators/apply-decorators.js +2 -3
  18. package/dist/decorators/index.d.ts +6 -7
  19. package/dist/decorators/index.js +6 -7
  20. package/dist/decorators/use-case-decorator.d.ts +1 -2
  21. package/dist/decorators/use-case-decorator.js +1 -2
  22. package/dist/decorators/with-caching.d.ts +1 -1
  23. package/dist/decorators/with-caching.js +1 -1
  24. package/dist/decorators/with-rate-limit.d.ts +1 -1
  25. package/dist/decorators/with-rate-limit.js +1 -1
  26. package/dist/decorators/with-retry.d.ts +1 -1
  27. package/dist/decorators/with-retry.js +1 -1
  28. package/dist/{error-handler-D4s_TTI1.js → error-handler-B4kyoFfy.js} +22 -5
  29. package/dist/error-handler-B4kyoFfy.js.map +1 -0
  30. package/dist/{error-handler-BDid7SIZ.d.ts → error-handler-Up4XIzWt.d.ts} +8 -4
  31. package/dist/errors/error-handler.d.ts +1 -2
  32. package/dist/errors/error-handler.js +1 -2
  33. package/dist/errors/index.d.ts +2 -3
  34. package/dist/errors/index.js +2 -3
  35. package/dist/{event-publisher-adapter-B02oKEmP.js → event-publisher-adapter-BHioo53u.js} +1 -1
  36. package/dist/{event-publisher-adapter-B02oKEmP.js.map → event-publisher-adapter-BHioo53u.js.map} +1 -1
  37. package/dist/{event-publisher-adapter-CpxK0OJ3.d.ts → event-publisher-adapter-DZv-0P_I.d.ts} +1 -1
  38. package/dist/events/event-publisher-adapter.d.ts +1 -1
  39. package/dist/events/event-publisher-adapter.js +1 -1
  40. package/dist/events/in-memory-event-bus.d.ts +1 -1
  41. package/dist/events/in-memory-event-bus.js +1 -1
  42. package/dist/events/in-memory-event-publisher.d.ts +1 -1
  43. package/dist/events/in-memory-event-publisher.js +1 -1
  44. package/dist/events/index.d.ts +4 -4
  45. package/dist/events/index.js +4 -4
  46. package/dist/{in-memory-cache-store-DSdz35Ve.d.ts → in-memory-cache-store-B1RVPPwh.d.ts} +1 -1
  47. package/dist/{in-memory-cache-store-BA-Eqsf0.js → in-memory-cache-store-C-v4ag_e.js} +1 -1
  48. package/dist/{in-memory-cache-store-BA-Eqsf0.js.map → in-memory-cache-store-C-v4ag_e.js.map} +1 -1
  49. package/dist/{in-memory-event-bus-CqIBLRze.d.ts → in-memory-event-bus-0rhMMoai.d.ts} +1 -1
  50. package/dist/{in-memory-event-bus-BCyPrNAE.js → in-memory-event-bus-D0n7i3uf.js} +1 -1
  51. package/dist/{in-memory-event-bus-BCyPrNAE.js.map → in-memory-event-bus-D0n7i3uf.js.map} +1 -1
  52. package/dist/{in-memory-event-publisher-CxOQ-hnq.d.ts → in-memory-event-publisher-BuFGCWeP.d.ts} +1 -1
  53. package/dist/{in-memory-event-publisher-BdOlxfkx.js → in-memory-event-publisher-DEMC6qBo.js} +1 -1
  54. package/dist/{in-memory-event-publisher-BdOlxfkx.js.map → in-memory-event-publisher-DEMC6qBo.js.map} +1 -1
  55. package/dist/{in-memory-rate-limiter-DKOwxFD7.js → in-memory-rate-limiter-ClGoFbk6.js} +1 -1
  56. package/dist/{in-memory-rate-limiter-DKOwxFD7.js.map → in-memory-rate-limiter-ClGoFbk6.js.map} +1 -1
  57. package/dist/{in-memory-rate-limiter-DZqM4MOS.d.ts → in-memory-rate-limiter-DjyLAj3S.d.ts} +1 -1
  58. package/dist/index.d.ts +26 -27
  59. package/dist/index.js +19 -20
  60. package/dist/logging/index.d.ts +3 -4
  61. package/dist/logging/request-logger.d.ts +1 -1
  62. package/dist/logging/structured-logger.d.ts +1 -2
  63. package/dist/modules/core.module.d.ts +8 -9
  64. package/dist/modules/core.module.js +6 -7
  65. package/dist/modules/index.d.ts +10 -11
  66. package/dist/modules/index.js +8 -9
  67. package/dist/modules/types.d.ts +7 -8
  68. package/dist/modules/user.module.d.ts +8 -9
  69. package/dist/modules/user.module.js +1 -1
  70. package/dist/rate-limiter/in-memory-rate-limiter.d.ts +1 -1
  71. package/dist/rate-limiter/in-memory-rate-limiter.js +1 -1
  72. package/dist/rate-limiter/index.d.ts +2 -2
  73. package/dist/rate-limiter/index.js +2 -2
  74. package/dist/request-logger-Cw1XQWTV.js.map +1 -1
  75. package/dist/{request-logger-CK3SOnoz.d.ts → request-logger-z3FaJPry.d.ts} +2 -2
  76. package/dist/structured-logger-BsxDI9zX.js.map +1 -1
  77. package/dist/{structured-logger-DyrZwR3S.d.ts → structured-logger-DJJ-0mnW.d.ts} +2 -2
  78. package/dist/{transaction-akuz5Fch.d.ts → transaction-D961784D.d.ts} +1 -1
  79. package/dist/{types-BnE7rffD.d.ts → types-BDBUcrxL.d.ts} +4 -4
  80. package/dist/{use-case-decorator-DzPSPSv5.d.ts → use-case-decorator-D9fX_4EY.d.ts} +2 -2
  81. package/dist/{use-case-decorator-GmDeYViz.js → use-case-decorator-DRIN79Vt.js} +2 -2
  82. package/dist/use-case-decorator-DRIN79Vt.js.map +1 -0
  83. package/dist/{user.drizzle-9kkstnkV.d.ts → user.drizzle-SbUroSiT.d.ts} +1 -1
  84. package/dist/{user.module-DqTfy_MM.d.ts → user.module-DWDd3hGF.d.ts} +2 -2
  85. package/dist/{user.module-BEpCbKsU.js → user.module-iUC-HTqT.js} +1 -1
  86. package/dist/{user.module-BEpCbKsU.js.map → user.module-iUC-HTqT.js.map} +1 -1
  87. package/dist/{with-caching-NmBxu7vJ.js → with-caching-DjOW2Xjh.js} +1 -1
  88. package/dist/{with-caching-NmBxu7vJ.js.map → with-caching-DjOW2Xjh.js.map} +1 -1
  89. package/dist/{with-caching-BniS1aZd.d.ts → with-caching-c8PLIWLG.d.ts} +1 -1
  90. package/dist/{with-rate-limit-Cp2V1RHn.js → with-rate-limit-B1L4rZzs.js} +1 -1
  91. package/dist/{with-rate-limit-Cp2V1RHn.js.map → with-rate-limit-B1L4rZzs.js.map} +1 -1
  92. package/dist/{with-rate-limit-DK4ZF-Qg.d.ts → with-rate-limit-CK5GHSfo.d.ts} +1 -1
  93. package/dist/{with-retry-coyYPiX1.js → with-retry-BFh_Hn_O.js} +1 -1
  94. package/dist/{with-retry-coyYPiX1.js.map → with-retry-BFh_Hn_O.js.map} +1 -1
  95. package/dist/{with-retry-B9-hUj7I.d.ts → with-retry-q6ftxgF2.d.ts} +1 -1
  96. package/package.json +4 -4
  97. package/dist/error-handler-D4s_TTI1.js.map +0 -1
  98. package/dist/errors-BB_jeye8.js +0 -43
  99. package/dist/errors-BB_jeye8.js.map +0 -1
  100. package/dist/logger-Bl10drB8.d.ts +0 -23
  101. package/dist/use-case-decorator-GmDeYViz.js.map +0 -1
  102. /package/dist/{cache-BjdZ-Ye4.js → cache-d2O3d-0Z.js} +0 -0
  103. /package/dist/{decorators-CqyPE9AQ.js → decorators-CW7geFqk.js} +0 -0
  104. /package/dist/{errors-DfkerzdO.js → errors-DXbNwomE.js} +0 -0
  105. /package/dist/{events-Dqynhuj2.js → events-DkUA7Khm.js} +0 -0
  106. /package/dist/{index-BH67NKRs.d.ts → index-B8lmalaK.d.ts} +0 -0
  107. /package/dist/{index-C6nYd7xV.d.ts → index-BS25w2a5.d.ts} +0 -0
  108. /package/dist/{index-B5F3AfVc.d.ts → index-CRDznOKQ.d.ts} +0 -0
  109. /package/dist/{index-B7z6dpFd.d.ts → index-Cg5cFzs-.d.ts} +0 -0
  110. /package/dist/{index-C0yeuOwC.d.ts → index-CuY8tqBC.d.ts} +0 -0
  111. /package/dist/{index-DVGDAddE.d.ts → index-LOv54jhI.d.ts} +0 -0
  112. /package/dist/{index-LKrIp3Oo.d.ts → index-kr8Wk7v5.d.ts} +0 -0
  113. /package/dist/{modules-C_2SF3he.js → modules-BICEbyjm.js} +0 -0
  114. /package/dist/{rate-limiter-BnvPGJOK.js → rate-limiter-DhcBdNmF.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { t as decorateUseCase } from "./use-case-decorator-GmDeYViz.js";
1
+ import { t as decorateUseCase } from "./use-case-decorator-DRIN79Vt.js";
2
2
 
3
3
  //#region src/decorators/apply-decorators.ts
4
4
  /**
@@ -26,4 +26,4 @@ const applyDecorators = (useCase, deps, featureName) => {
26
26
 
27
27
  //#endregion
28
28
  export { applyDecorators as t };
29
- //# sourceMappingURL=apply-decorators-CaHIAL5X.js.map
29
+ //# sourceMappingURL=apply-decorators-DA33OBa7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"apply-decorators-CaHIAL5X.js","names":[],"sources":["../src/decorators/apply-decorators.ts"],"sourcesContent":["import { decorateUseCase } from './use-case-decorator'\n\n/**\n * Helper to apply decorators to use cases in module registration\n * Reduces boilerplate in feature modules\n *\n * Usage:\n * ```\n * getUserProfile: asFunction(({ userRepository, ...deps }) =>\n * applyDecorators(\n * makeGetUserProfile({ userRepository }),\n * deps,\n * 'getUserProfile'\n * )\n * ).scoped(),\n * ```\n */\nexport const applyDecorators = <T extends (...args: any[]) => Promise<any>>(\n\tuseCase: T,\n\tdeps: {\n\t\tlogger: any\n\t\trequestId?: string\n\t},\n\tfeatureName: string\n): T => {\n\treturn decorateUseCase(\n\t\tuseCase,\n\t\t{\n\t\t\tlogger: deps.logger,\n\t\t\trequestId: deps.requestId,\n\t\t\tfeature: featureName,\n\t\t},\n\t\tfeatureName\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAa,mBACZ,SACA,MAIA,gBACO;AACP,QAAO,gBACN,SACA;EACC,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,SAAS;EACT,EACD,YACA"}
1
+ {"version":3,"file":"apply-decorators-DA33OBa7.js","names":[],"sources":["../src/decorators/apply-decorators.ts"],"sourcesContent":["import { decorateUseCase } from './use-case-decorator'\n\n/**\n * Helper to apply decorators to use cases in module registration\n * Reduces boilerplate in feature modules\n *\n * Usage:\n * ```\n * getUserProfile: asFunction(({ userRepository, ...deps }) =>\n * applyDecorators(\n * makeGetUserProfile({ userRepository }),\n * deps,\n * 'getUserProfile'\n * )\n * ).scoped(),\n * ```\n */\nexport const applyDecorators = <T extends (...args: any[]) => Promise<any>>(\n\tuseCase: T,\n\tdeps: {\n\t\tlogger: any\n\t\trequestId?: string\n\t},\n\tfeatureName: string\n): T => {\n\treturn decorateUseCase(\n\t\tuseCase,\n\t\t{\n\t\t\tlogger: deps.logger,\n\t\t\trequestId: deps.requestId,\n\t\t\tfeature: featureName,\n\t\t},\n\t\tfeatureName\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAa,mBACZ,SACA,MAIA,gBACO;AACP,QAAO,gBACN,SACA;EACC,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,SAAS;EACT,EACD,YACA"}
@@ -20,4 +20,4 @@ declare const applyDecorators: <T extends (...args: any[]) => Promise<any>>(useC
20
20
  }, featureName: string) => T;
21
21
  //#endregion
22
22
  export { applyDecorators as t };
23
- //# sourceMappingURL=apply-decorators-CW23qWy7.d.ts.map
23
+ //# sourceMappingURL=apply-decorators-zka0zqoX.d.ts.map
@@ -1,2 +1,2 @@
1
- import { n as makeInMemoryCacheStore, t as InMemoryCacheStore } from "../in-memory-cache-store-DSdz35Ve.js";
1
+ import { n as makeInMemoryCacheStore, t as InMemoryCacheStore } from "../in-memory-cache-store-B1RVPPwh.js";
2
2
  export { InMemoryCacheStore, makeInMemoryCacheStore };
@@ -1,3 +1,3 @@
1
- import { n as makeInMemoryCacheStore, t as InMemoryCacheStore } from "../in-memory-cache-store-BA-Eqsf0.js";
1
+ import { n as makeInMemoryCacheStore, t as InMemoryCacheStore } from "../in-memory-cache-store-C-v4ag_e.js";
2
2
 
3
3
  export { InMemoryCacheStore, makeInMemoryCacheStore };
@@ -1,3 +1,3 @@
1
- import { n as makeInMemoryCacheStore, t as InMemoryCacheStore } from "../in-memory-cache-store-DSdz35Ve.js";
2
- import { t as CacheStore } from "../index-C6nYd7xV.js";
1
+ import { n as makeInMemoryCacheStore, t as InMemoryCacheStore } from "../in-memory-cache-store-B1RVPPwh.js";
2
+ import { t as CacheStore } from "../index-BS25w2a5.js";
3
3
  export { CacheStore, InMemoryCacheStore, makeInMemoryCacheStore };
@@ -1,4 +1,4 @@
1
- import { n as makeInMemoryCacheStore, t as InMemoryCacheStore } from "../in-memory-cache-store-BA-Eqsf0.js";
2
- import "../cache-BjdZ-Ye4.js";
1
+ import { n as makeInMemoryCacheStore, t as InMemoryCacheStore } from "../in-memory-cache-store-C-v4ag_e.js";
2
+ import "../cache-d2O3d-0Z.js";
3
3
 
4
4
  export { InMemoryCacheStore, makeInMemoryCacheStore };
@@ -1,4 +1,4 @@
1
- import { n as Cradle } from "./types-BnE7rffD.js";
1
+ import { n as Cradle } from "./types-BDBUcrxL.js";
2
2
  import { AwilixContainer } from "awilix";
3
3
 
4
4
  //#region src/modules/core.module.d.ts
@@ -14,4 +14,4 @@ import { AwilixContainer } from "awilix";
14
14
  declare const registerCoreModule: (container: AwilixContainer<Cradle>) => void;
15
15
  //#endregion
16
16
  export { registerCoreModule as t };
17
- //# sourceMappingURL=core.module-_mfoxc8b.d.ts.map
17
+ //# sourceMappingURL=core.module-BEuDFLDA.d.ts.map
@@ -1,10 +1,10 @@
1
1
  import { n as createDbPool, t as createDb } from "./db-C4IcCT04.js";
2
2
  import { n as makeStructuredLogger } from "./structured-logger-BsxDI9zX.js";
3
3
  import { t as makeRequestLogger } from "./request-logger-Cw1XQWTV.js";
4
- import { n as makeErrorHandler } from "./error-handler-D4s_TTI1.js";
5
- import { t as InMemoryEventBus } from "./in-memory-event-bus-BCyPrNAE.js";
6
- import { t as InMemoryCacheStore } from "./in-memory-cache-store-BA-Eqsf0.js";
7
- import { t as InMemoryRateLimiterStore } from "./in-memory-rate-limiter-DKOwxFD7.js";
4
+ import { n as makeErrorHandler } from "./error-handler-B4kyoFfy.js";
5
+ import { t as InMemoryEventBus } from "./in-memory-event-bus-D0n7i3uf.js";
6
+ import { t as InMemoryCacheStore } from "./in-memory-cache-store-C-v4ag_e.js";
7
+ import { t as InMemoryRateLimiterStore } from "./in-memory-rate-limiter-ClGoFbk6.js";
8
8
  import { asFunction, asValue } from "awilix";
9
9
  import { SystemClock } from "@kuckit/domain/ports/clock";
10
10
  import { google } from "@ai-sdk/google";
@@ -45,4 +45,4 @@ const registerCoreModule = (container) => {
45
45
 
46
46
  //#endregion
47
47
  export { registerCoreModule as t };
48
- //# sourceMappingURL=core.module-ehJ0bdNr.js.map
48
+ //# sourceMappingURL=core.module-oSFmg8ER.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.module-ehJ0bdNr.js","names":[],"sources":["../src/modules/core.module.ts"],"sourcesContent":["import { asFunction, asValue, type AwilixContainer } from 'awilix'\nimport { SystemClock } from '@kuckit/domain/ports/clock'\nimport { google } from '@ai-sdk/google'\nimport { createAuth } from '@kuckit/auth'\nimport { createDbPool, createDb } from '../db/drizzle/db'\nimport { makeStructuredLogger, makeRequestLogger, type LogLevel } from '../logging'\nimport { makeErrorHandler } from '../errors'\nimport { InMemoryEventBus } from '../events/in-memory-event-bus'\nimport { InMemoryCacheStore } from '../cache/in-memory-cache-store'\nimport { InMemoryRateLimiterStore } from '../rate-limiter/in-memory-rate-limiter'\nimport type { Cradle } from './types'\n\n/**\n * Core module: singleton registrations for infrastructure\n * - Database pool and connection\n * - Clock\n * - Logger (structured, Loki/Prometheus compatible)\n * - AI provider\n * - Auth\n */\nexport const registerCoreModule = (container: AwilixContainer<Cradle>): void => {\n\tcontainer.register({\n\t\t// Database\n\t\tdbPool: asFunction(({ config }) => createDbPool(config.databaseUrl)).singleton(),\n\n\t\tdb: asFunction(({ dbPool }) => createDb(dbPool)).singleton(),\n\n\t\t// Core services\n\t\tclock: asValue(new SystemClock()),\n\n\t\tlogger: asFunction(({ config }) =>\n\t\t\tmakeStructuredLogger({\n\t\t\t\tenableFile: config.enableFileLogging,\n\t\t\t\tlogDir: config.logDir,\n\t\t\t\tminLevel: config.logLevel as LogLevel,\n\t\t\t})\n\t\t).singleton(),\n\n\t\terrorHandler: asFunction(({ logger }) => makeErrorHandler(logger)).singleton(),\n\n\t\t// External integrations\n\t\tauth: asFunction(({ db }) => createAuth({ db })).singleton(),\n\n\t\taiProvider: asFunction(() => google('gemini-2.5-flash')).singleton(),\n\n\t\t// Event bus\n\t\teventBus: asFunction(({ logger }) => new InMemoryEventBus(logger)).singleton(),\n\n\t\t// Cache store (no DI deps, use asFunction to avoid PROXY mode issues)\n\t\tcacheStore: asFunction(() => new InMemoryCacheStore()).singleton(),\n\n\t\t// Rate limiter store (no DI deps, use asFunction to avoid PROXY mode issues)\n\t\trateLimiterStore: asFunction(() => new InMemoryRateLimiterStore()).singleton(),\n\n\t\t// Request-scoped logger (enriched with requestId and userId)\n\t\trequestLogger: asFunction(({ logger, requestId, session }) =>\n\t\t\tmakeRequestLogger({\n\t\t\t\trequestId,\n\t\t\t\tuserId: session?.user?.id,\n\t\t\t\tbaseLogger: logger,\n\t\t\t})\n\t\t).scoped(),\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,sBAAsB,cAA6C;AAC/E,WAAU,SAAS;EAElB,QAAQ,YAAY,EAAE,aAAa,aAAa,OAAO,YAAY,CAAC,CAAC,WAAW;EAEhF,IAAI,YAAY,EAAE,aAAa,SAAS,OAAO,CAAC,CAAC,WAAW;EAG5D,OAAO,QAAQ,IAAI,aAAa,CAAC;EAEjC,QAAQ,YAAY,EAAE,aACrB,qBAAqB;GACpB,YAAY,OAAO;GACnB,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,CAAC,CACF,CAAC,WAAW;EAEb,cAAc,YAAY,EAAE,aAAa,iBAAiB,OAAO,CAAC,CAAC,WAAW;EAG9E,MAAM,YAAY,EAAE,SAAS,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW;EAE5D,YAAY,iBAAiB,OAAO,mBAAmB,CAAC,CAAC,WAAW;EAGpE,UAAU,YAAY,EAAE,aAAa,IAAI,iBAAiB,OAAO,CAAC,CAAC,WAAW;EAG9E,YAAY,iBAAiB,IAAI,oBAAoB,CAAC,CAAC,WAAW;EAGlE,kBAAkB,iBAAiB,IAAI,0BAA0B,CAAC,CAAC,WAAW;EAG9E,eAAe,YAAY,EAAE,QAAQ,WAAW,cAC/C,kBAAkB;GACjB;GACA,QAAQ,SAAS,MAAM;GACvB,YAAY;GACZ,CAAC,CACF,CAAC,QAAQ;EACV,CAAC"}
1
+ {"version":3,"file":"core.module-oSFmg8ER.js","names":[],"sources":["../src/modules/core.module.ts"],"sourcesContent":["import { asFunction, asValue, type AwilixContainer } from 'awilix'\nimport { SystemClock } from '@kuckit/domain/ports/clock'\nimport { google } from '@ai-sdk/google'\nimport { createAuth } from '@kuckit/auth'\nimport { createDbPool, createDb } from '../db/drizzle/db'\nimport { makeStructuredLogger, makeRequestLogger, type LogLevel } from '../logging'\nimport { makeErrorHandler } from '../errors'\nimport { InMemoryEventBus } from '../events/in-memory-event-bus'\nimport { InMemoryCacheStore } from '../cache/in-memory-cache-store'\nimport { InMemoryRateLimiterStore } from '../rate-limiter/in-memory-rate-limiter'\nimport type { Cradle } from './types'\n\n/**\n * Core module: singleton registrations for infrastructure\n * - Database pool and connection\n * - Clock\n * - Logger (structured, Loki/Prometheus compatible)\n * - AI provider\n * - Auth\n */\nexport const registerCoreModule = (container: AwilixContainer<Cradle>): void => {\n\tcontainer.register({\n\t\t// Database\n\t\tdbPool: asFunction(({ config }) => createDbPool(config.databaseUrl)).singleton(),\n\n\t\tdb: asFunction(({ dbPool }) => createDb(dbPool)).singleton(),\n\n\t\t// Core services\n\t\tclock: asValue(new SystemClock()),\n\n\t\tlogger: asFunction(({ config }) =>\n\t\t\tmakeStructuredLogger({\n\t\t\t\tenableFile: config.enableFileLogging,\n\t\t\t\tlogDir: config.logDir,\n\t\t\t\tminLevel: config.logLevel as LogLevel,\n\t\t\t})\n\t\t).singleton(),\n\n\t\terrorHandler: asFunction(({ logger }) => makeErrorHandler(logger)).singleton(),\n\n\t\t// External integrations\n\t\tauth: asFunction(({ db }) => createAuth({ db })).singleton(),\n\n\t\taiProvider: asFunction(() => google('gemini-2.5-flash')).singleton(),\n\n\t\t// Event bus\n\t\teventBus: asFunction(({ logger }) => new InMemoryEventBus(logger)).singleton(),\n\n\t\t// Cache store (no DI deps, use asFunction to avoid PROXY mode issues)\n\t\tcacheStore: asFunction(() => new InMemoryCacheStore()).singleton(),\n\n\t\t// Rate limiter store (no DI deps, use asFunction to avoid PROXY mode issues)\n\t\trateLimiterStore: asFunction(() => new InMemoryRateLimiterStore()).singleton(),\n\n\t\t// Request-scoped logger (enriched with requestId and userId)\n\t\trequestLogger: asFunction(({ logger, requestId, session }) =>\n\t\t\tmakeRequestLogger({\n\t\t\t\trequestId,\n\t\t\t\tuserId: session?.user?.id,\n\t\t\t\tbaseLogger: logger,\n\t\t\t})\n\t\t).scoped(),\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,sBAAsB,cAA6C;AAC/E,WAAU,SAAS;EAElB,QAAQ,YAAY,EAAE,aAAa,aAAa,OAAO,YAAY,CAAC,CAAC,WAAW;EAEhF,IAAI,YAAY,EAAE,aAAa,SAAS,OAAO,CAAC,CAAC,WAAW;EAG5D,OAAO,QAAQ,IAAI,aAAa,CAAC;EAEjC,QAAQ,YAAY,EAAE,aACrB,qBAAqB;GACpB,YAAY,OAAO;GACnB,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,CAAC,CACF,CAAC,WAAW;EAEb,cAAc,YAAY,EAAE,aAAa,iBAAiB,OAAO,CAAC,CAAC,WAAW;EAG9E,MAAM,YAAY,EAAE,SAAS,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW;EAE5D,YAAY,iBAAiB,OAAO,mBAAmB,CAAC,CAAC,WAAW;EAGpE,UAAU,YAAY,EAAE,aAAa,IAAI,iBAAiB,OAAO,CAAC,CAAC,WAAW;EAG9E,YAAY,iBAAiB,IAAI,oBAAoB,CAAC,CAAC,WAAW;EAGlE,kBAAkB,iBAAiB,IAAI,0BAA0B,CAAC,CAAC,WAAW;EAG9E,eAAe,YAAY,EAAE,QAAQ,WAAW,cAC/C,kBAAkB;GACjB;GACA,QAAQ,SAAS,MAAM;GACvB,YAAY;GACZ,CAAC,CACF,CAAC,QAAQ;EACV,CAAC"}
@@ -1,2 +1,2 @@
1
- import { n as createDbPool, t as createDb } from "../../db-tAPHBDyL.js";
1
+ import { n as createDbPool, t as createDb } from "../../db-Brm6l10l.js";
2
2
  export { createDb, createDbPool };
@@ -1,3 +1,3 @@
1
- import { t as makeDrizzleUserRepository } from "../../../user.drizzle-9kkstnkV.js";
2
- import "../../../index-B5F3AfVc.js";
1
+ import { t as makeDrizzleUserRepository } from "../../../user.drizzle-SbUroSiT.js";
2
+ import "../../../index-kr8Wk7v5.js";
3
3
  export { makeDrizzleUserRepository };
@@ -1,2 +1,2 @@
1
- import { t as makeDrizzleUserRepository } from "../../../user.drizzle-9kkstnkV.js";
1
+ import { t as makeDrizzleUserRepository } from "../../../user.drizzle-SbUroSiT.js";
2
2
  export { makeDrizzleUserRepository };
@@ -1,2 +1,2 @@
1
- import { n as runInTransaction, t as TransactionFn } from "../transaction-akuz5Fch.js";
1
+ import { n as runInTransaction, t as TransactionFn } from "../transaction-D961784D.js";
2
2
  export { TransactionFn, runInTransaction };
@@ -14,4 +14,4 @@ declare const createDb: (pool: Pool) => drizzle_orm_node_postgres0.NodePgDatabas
14
14
  };
15
15
  //#endregion
16
16
  export { createDbPool as n, createDb as t };
17
- //# sourceMappingURL=db-tAPHBDyL.d.ts.map
17
+ //# sourceMappingURL=db-Brm6l10l.d.ts.map
@@ -1,2 +1,2 @@
1
- import { t as applyDecorators } from "../apply-decorators-CW23qWy7.js";
1
+ import { t as applyDecorators } from "../apply-decorators-zka0zqoX.js";
2
2
  export { applyDecorators };
@@ -1,5 +1,4 @@
1
- import "../errors-BB_jeye8.js";
2
- import "../use-case-decorator-GmDeYViz.js";
3
- import { t as applyDecorators } from "../apply-decorators-CaHIAL5X.js";
1
+ import "../use-case-decorator-DRIN79Vt.js";
2
+ import { t as applyDecorators } from "../apply-decorators-DA33OBa7.js";
4
3
 
5
4
  export { applyDecorators };
@@ -1,8 +1,7 @@
1
- import { t as applyDecorators } from "../apply-decorators-CW23qWy7.js";
2
- import "../logger-Bl10drB8.js";
3
- import { a as makeDecoratedUseCase, c as withRequestTracing, i as decorateUseCase, n as PerformanceMetrics, o as withErrorHandling, r as UseCase, s as withPerformanceMonitoring, t as DecoratorContext } from "../use-case-decorator-DzPSPSv5.js";
4
- import { n as withCaching, t as WithCachingOptions } from "../with-caching-BniS1aZd.js";
5
- import { n as withRetry, t as WithRetryOptions } from "../with-retry-B9-hUj7I.js";
6
- import { n as WithRateLimitOptions, r as withRateLimit, t as RateLimitError } from "../with-rate-limit-DK4ZF-Qg.js";
7
- import "../index-DXJbbtWQ.js";
1
+ import { t as applyDecorators } from "../apply-decorators-zka0zqoX.js";
2
+ import { a as makeDecoratedUseCase, c as withRequestTracing, i as decorateUseCase, n as PerformanceMetrics, o as withErrorHandling, r as UseCase, s as withPerformanceMonitoring, t as DecoratorContext } from "../use-case-decorator-D9fX_4EY.js";
3
+ import { n as withCaching, t as WithCachingOptions } from "../with-caching-c8PLIWLG.js";
4
+ import { n as withRetry, t as WithRetryOptions } from "../with-retry-q6ftxgF2.js";
5
+ import { n as WithRateLimitOptions, r as withRateLimit, t as RateLimitError } from "../with-rate-limit-CK5GHSfo.js";
6
+ import "../index-LOv54jhI.js";
8
7
  export { DecoratorContext, PerformanceMetrics, RateLimitError, UseCase, WithCachingOptions, WithRateLimitOptions, WithRetryOptions, applyDecorators, decorateUseCase, makeDecoratedUseCase, withCaching, withErrorHandling, withPerformanceMonitoring, withRateLimit, withRequestTracing, withRetry };
@@ -1,9 +1,8 @@
1
- import "../errors-BB_jeye8.js";
2
- import { a as withRequestTracing, i as withPerformanceMonitoring, n as makeDecoratedUseCase, r as withErrorHandling, t as decorateUseCase } from "../use-case-decorator-GmDeYViz.js";
3
- import { t as applyDecorators } from "../apply-decorators-CaHIAL5X.js";
4
- import { t as withCaching } from "../with-caching-NmBxu7vJ.js";
5
- import { t as withRetry } from "../with-retry-coyYPiX1.js";
6
- import { n as withRateLimit, t as RateLimitError } from "../with-rate-limit-Cp2V1RHn.js";
7
- import "../decorators-CqyPE9AQ.js";
1
+ import { a as withRequestTracing, i as withPerformanceMonitoring, n as makeDecoratedUseCase, r as withErrorHandling, t as decorateUseCase } from "../use-case-decorator-DRIN79Vt.js";
2
+ import { t as applyDecorators } from "../apply-decorators-DA33OBa7.js";
3
+ import { t as withCaching } from "../with-caching-DjOW2Xjh.js";
4
+ import { t as withRetry } from "../with-retry-BFh_Hn_O.js";
5
+ import { n as withRateLimit, t as RateLimitError } from "../with-rate-limit-B1L4rZzs.js";
6
+ import "../decorators-CW7geFqk.js";
8
7
 
9
8
  export { RateLimitError, applyDecorators, decorateUseCase, makeDecoratedUseCase, withCaching, withErrorHandling, withPerformanceMonitoring, withRateLimit, withRequestTracing, withRetry };
@@ -1,3 +1,2 @@
1
- import "../logger-Bl10drB8.js";
2
- import { a as makeDecoratedUseCase, c as withRequestTracing, i as decorateUseCase, n as PerformanceMetrics, o as withErrorHandling, r as UseCase, s as withPerformanceMonitoring, t as DecoratorContext } from "../use-case-decorator-DzPSPSv5.js";
1
+ import { a as makeDecoratedUseCase, c as withRequestTracing, i as decorateUseCase, n as PerformanceMetrics, o as withErrorHandling, r as UseCase, s as withPerformanceMonitoring, t as DecoratorContext } from "../use-case-decorator-D9fX_4EY.js";
3
2
  export { DecoratorContext, PerformanceMetrics, UseCase, decorateUseCase, makeDecoratedUseCase, withErrorHandling, withPerformanceMonitoring, withRequestTracing };
@@ -1,4 +1,3 @@
1
- import "../errors-BB_jeye8.js";
2
- import { a as withRequestTracing, i as withPerformanceMonitoring, n as makeDecoratedUseCase, r as withErrorHandling, t as decorateUseCase } from "../use-case-decorator-GmDeYViz.js";
1
+ import { a as withRequestTracing, i as withPerformanceMonitoring, n as makeDecoratedUseCase, r as withErrorHandling, t as decorateUseCase } from "../use-case-decorator-DRIN79Vt.js";
3
2
 
4
3
  export { decorateUseCase, makeDecoratedUseCase, withErrorHandling, withPerformanceMonitoring, withRequestTracing };
@@ -1,2 +1,2 @@
1
- import { n as withCaching, t as WithCachingOptions } from "../with-caching-BniS1aZd.js";
1
+ import { n as withCaching, t as WithCachingOptions } from "../with-caching-c8PLIWLG.js";
2
2
  export { WithCachingOptions, withCaching };
@@ -1,3 +1,3 @@
1
- import { t as withCaching } from "../with-caching-NmBxu7vJ.js";
1
+ import { t as withCaching } from "../with-caching-DjOW2Xjh.js";
2
2
 
3
3
  export { withCaching };
@@ -1,2 +1,2 @@
1
- import { n as WithRateLimitOptions, r as withRateLimit, t as RateLimitError } from "../with-rate-limit-DK4ZF-Qg.js";
1
+ import { n as WithRateLimitOptions, r as withRateLimit, t as RateLimitError } from "../with-rate-limit-CK5GHSfo.js";
2
2
  export { RateLimitError, WithRateLimitOptions, withRateLimit };
@@ -1,3 +1,3 @@
1
- import { n as withRateLimit, t as RateLimitError } from "../with-rate-limit-Cp2V1RHn.js";
1
+ import { n as withRateLimit, t as RateLimitError } from "../with-rate-limit-B1L4rZzs.js";
2
2
 
3
3
  export { RateLimitError, withRateLimit };
@@ -1,2 +1,2 @@
1
- import { n as withRetry, t as WithRetryOptions } from "../with-retry-B9-hUj7I.js";
1
+ import { n as withRetry, t as WithRetryOptions } from "../with-retry-q6ftxgF2.js";
2
2
  export { WithRetryOptions, withRetry };
@@ -1,3 +1,3 @@
1
- import { t as withRetry } from "../with-retry-coyYPiX1.js";
1
+ import { t as withRetry } from "../with-retry-BFh_Hn_O.js";
2
2
 
3
3
  export { withRetry };
@@ -1,4 +1,4 @@
1
- import { t as AppError } from "./errors-BB_jeye8.js";
1
+ import { AppError, ErrorCode } from "@kuckit/domain";
2
2
 
3
3
  //#region src/errors/error-handler.ts
4
4
  /**
@@ -21,11 +21,18 @@ var ErrorHandler = class ErrorHandler {
21
21
  */
22
22
  normalize(error) {
23
23
  if (error instanceof AppError) return error;
24
- if (error instanceof Error) return new AppError("INTERNAL_SERVER_ERROR", error.message, {
24
+ if (error instanceof Error) return new AppError(ErrorCode.INTERNAL_SERVER_ERROR, error.message, {
25
25
  statusCode: 500,
26
- meta: { originalError: error.name }
26
+ meta: {
27
+ originalError: error.name,
28
+ stack: error.stack
29
+ }
30
+ });
31
+ const errorString = typeof error === "string" ? error : typeof error === "object" && error !== null ? this.safeStringify(error) : String(error);
32
+ return new AppError(ErrorCode.INTERNAL_SERVER_ERROR, `Unknown error: ${errorString}`, {
33
+ statusCode: 500,
34
+ meta: { originalValue: errorString }
27
35
  });
28
- return new AppError("INTERNAL_SERVER_ERROR", "Unknown error occurred", { statusCode: 500 });
29
36
  }
30
37
  /**
31
38
  * Log error with appropriate level
@@ -51,6 +58,16 @@ var ErrorHandler = class ErrorHandler {
51
58
  }
52
59
  }
53
60
  /**
61
+ * Safely stringify an object, handling circular references
62
+ */
63
+ safeStringify(obj) {
64
+ try {
65
+ return JSON.stringify(obj);
66
+ } catch {
67
+ return "[Object with circular references]";
68
+ }
69
+ }
70
+ /**
54
71
  * Serialize error for API response
55
72
  */
56
73
  serialize(error) {
@@ -77,4 +94,4 @@ const makeErrorHandler = (logger) => {
77
94
 
78
95
  //#endregion
79
96
  export { makeErrorHandler as n, ErrorHandler as t };
80
- //# sourceMappingURL=error-handler-D4s_TTI1.js.map
97
+ //# sourceMappingURL=error-handler-B4kyoFfy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler-B4kyoFfy.js","names":["logger: Logger"],"sources":["../src/errors/error-handler.ts"],"sourcesContent":["import type { Logger } from '@kuckit/domain'\nimport { AppError, ErrorCode } from '@kuckit/domain'\n\n/**\n * Serialized error for API responses\n */\nexport interface SerializedError {\n\tcode: string\n\tmessage: string\n\tstatusCode: number\n\tmeta?: Record<string, unknown>\n}\n\n/**\n * Error handler for structured error logging and serialization\n */\nexport class ErrorHandler {\n\tconstructor(private logger: Logger) {}\n\n\t/**\n\t * Handle error and serialize for API response\n\t */\n\thandle(error: unknown, context?: Record<string, unknown>): SerializedError {\n\t\tconst appError = this.normalize(error)\n\n\t\t// Log error with context\n\t\tthis.log(appError, context)\n\n\t\t// Serialize for API response\n\t\treturn this.serialize(appError)\n\t}\n\n\t/**\n\t * Normalize any error to AppError\n\t */\n\tprivate normalize(error: unknown): AppError {\n\t\tif (error instanceof AppError) {\n\t\t\treturn error\n\t\t}\n\n\t\tif (error instanceof Error) {\n\t\t\treturn new AppError(ErrorCode.INTERNAL_SERVER_ERROR, error.message, {\n\t\t\t\tstatusCode: 500,\n\t\t\t\tmeta: { originalError: error.name, stack: error.stack },\n\t\t\t})\n\t\t}\n\n\t\t// For non-Error values, try to extract useful info\n\t\tconst errorString =\n\t\t\ttypeof error === 'string'\n\t\t\t\t? error\n\t\t\t\t: typeof error === 'object' && error !== null\n\t\t\t\t\t? this.safeStringify(error)\n\t\t\t\t\t: String(error)\n\n\t\treturn new AppError(ErrorCode.INTERNAL_SERVER_ERROR, `Unknown error: ${errorString}`, {\n\t\t\tstatusCode: 500,\n\t\t\tmeta: { originalValue: errorString },\n\t\t})\n\t}\n\n\t/**\n\t * Log error with appropriate level\n\t */\n\tprivate log(error: AppError, context?: Record<string, unknown>): void {\n\t\tconst logContext = {\n\t\t\tcode: error.code,\n\t\t\tseverity: error.severity,\n\t\t\tstack: error.stack,\n\t\t\t...context,\n\t\t}\n\n\t\tswitch (error.severity) {\n\t\t\tcase 'LOW':\n\t\t\t\tthis.logger.debug(error.message, logContext)\n\t\t\t\tbreak\n\t\t\tcase 'MEDIUM':\n\t\t\t\tthis.logger.warn(error.message, logContext)\n\t\t\t\tbreak\n\t\t\tcase 'HIGH':\n\t\t\tcase 'CRITICAL':\n\t\t\t\tthis.logger.error(error.message, logContext)\n\t\t\t\tbreak\n\t\t}\n\t}\n\n\t/**\n\t * Safely stringify an object, handling circular references\n\t */\n\tprivate safeStringify(obj: object): string {\n\t\ttry {\n\t\t\treturn JSON.stringify(obj)\n\t\t} catch {\n\t\t\treturn '[Object with circular references]'\n\t\t}\n\t}\n\n\t/**\n\t * Serialize error for API response\n\t */\n\tprivate serialize(error: AppError): SerializedError {\n\t\treturn {\n\t\t\tcode: error.code,\n\t\t\tmessage: error.message,\n\t\t\tstatusCode: error.statusCode,\n\t\t\t...(Object.keys(error.meta).length > 0 && { meta: error.meta }),\n\t\t}\n\t}\n\n\t/**\n\t * Create error handler factory\n\t */\n\tstatic create(logger: Logger): ErrorHandler {\n\t\treturn new ErrorHandler(logger)\n\t}\n}\n\n/**\n * Factory for error handler\n */\nexport const makeErrorHandler = (logger: Logger): ErrorHandler => {\n\treturn ErrorHandler.create(logger)\n}\n"],"mappings":";;;;;;AAgBA,IAAa,eAAb,MAAa,aAAa;CACzB,YAAY,AAAQA,QAAgB;EAAhB;;;;;CAKpB,OAAO,OAAgB,SAAoD;EAC1E,MAAM,WAAW,KAAK,UAAU,MAAM;AAGtC,OAAK,IAAI,UAAU,QAAQ;AAG3B,SAAO,KAAK,UAAU,SAAS;;;;;CAMhC,AAAQ,UAAU,OAA0B;AAC3C,MAAI,iBAAiB,SACpB,QAAO;AAGR,MAAI,iBAAiB,MACpB,QAAO,IAAI,SAAS,UAAU,uBAAuB,MAAM,SAAS;GACnE,YAAY;GACZ,MAAM;IAAE,eAAe,MAAM;IAAM,OAAO,MAAM;IAAO;GACvD,CAAC;EAIH,MAAM,cACL,OAAO,UAAU,WACd,QACA,OAAO,UAAU,YAAY,UAAU,OACtC,KAAK,cAAc,MAAM,GACzB,OAAO,MAAM;AAElB,SAAO,IAAI,SAAS,UAAU,uBAAuB,kBAAkB,eAAe;GACrF,YAAY;GACZ,MAAM,EAAE,eAAe,aAAa;GACpC,CAAC;;;;;CAMH,AAAQ,IAAI,OAAiB,SAAyC;EACrE,MAAM,aAAa;GAClB,MAAM,MAAM;GACZ,UAAU,MAAM;GAChB,OAAO,MAAM;GACb,GAAG;GACH;AAED,UAAQ,MAAM,UAAd;GACC,KAAK;AACJ,SAAK,OAAO,MAAM,MAAM,SAAS,WAAW;AAC5C;GACD,KAAK;AACJ,SAAK,OAAO,KAAK,MAAM,SAAS,WAAW;AAC3C;GACD,KAAK;GACL,KAAK;AACJ,SAAK,OAAO,MAAM,MAAM,SAAS,WAAW;AAC5C;;;;;;CAOH,AAAQ,cAAc,KAAqB;AAC1C,MAAI;AACH,UAAO,KAAK,UAAU,IAAI;UACnB;AACP,UAAO;;;;;;CAOT,AAAQ,UAAU,OAAkC;AACnD,SAAO;GACN,MAAM,MAAM;GACZ,SAAS,MAAM;GACf,YAAY,MAAM;GAClB,GAAI,OAAO,KAAK,MAAM,KAAK,CAAC,SAAS,KAAK,EAAE,MAAM,MAAM,MAAM;GAC9D;;;;;CAMF,OAAO,OAAO,QAA8B;AAC3C,SAAO,IAAI,aAAa,OAAO;;;;;;AAOjC,MAAa,oBAAoB,WAAiC;AACjE,QAAO,aAAa,OAAO,OAAO"}
@@ -1,4 +1,4 @@
1
- import { n as Logger } from "./logger-Bl10drB8.js";
1
+ import { Logger } from "@kuckit/domain";
2
2
 
3
3
  //#region src/errors/error-handler.d.ts
4
4
 
@@ -9,7 +9,7 @@ interface SerializedError {
9
9
  code: string;
10
10
  message: string;
11
11
  statusCode: number;
12
- meta?: Record<string, any>;
12
+ meta?: Record<string, unknown>;
13
13
  }
14
14
  /**
15
15
  * Error handler for structured error logging and serialization
@@ -20,7 +20,7 @@ declare class ErrorHandler {
20
20
  /**
21
21
  * Handle error and serialize for API response
22
22
  */
23
- handle(error: unknown, context?: Record<string, any>): SerializedError;
23
+ handle(error: unknown, context?: Record<string, unknown>): SerializedError;
24
24
  /**
25
25
  * Normalize any error to AppError
26
26
  */
@@ -29,6 +29,10 @@ declare class ErrorHandler {
29
29
  * Log error with appropriate level
30
30
  */
31
31
  private log;
32
+ /**
33
+ * Safely stringify an object, handling circular references
34
+ */
35
+ private safeStringify;
32
36
  /**
33
37
  * Serialize error for API response
34
38
  */
@@ -44,4 +48,4 @@ declare class ErrorHandler {
44
48
  declare const makeErrorHandler: (logger: Logger) => ErrorHandler;
45
49
  //#endregion
46
50
  export { SerializedError as n, makeErrorHandler as r, ErrorHandler as t };
47
- //# sourceMappingURL=error-handler-BDid7SIZ.d.ts.map
51
+ //# sourceMappingURL=error-handler-Up4XIzWt.d.ts.map
@@ -1,3 +1,2 @@
1
- import "../logger-Bl10drB8.js";
2
- import { n as SerializedError, r as makeErrorHandler, t as ErrorHandler } from "../error-handler-BDid7SIZ.js";
1
+ import { n as SerializedError, r as makeErrorHandler, t as ErrorHandler } from "../error-handler-Up4XIzWt.js";
3
2
  export { ErrorHandler, SerializedError, makeErrorHandler };
@@ -1,4 +1,3 @@
1
- import "../errors-BB_jeye8.js";
2
- import { n as makeErrorHandler, t as ErrorHandler } from "../error-handler-D4s_TTI1.js";
1
+ import { n as makeErrorHandler, t as ErrorHandler } from "../error-handler-B4kyoFfy.js";
3
2
 
4
3
  export { ErrorHandler, makeErrorHandler };
@@ -1,4 +1,3 @@
1
- import "../logger-Bl10drB8.js";
2
- import { n as SerializedError, r as makeErrorHandler, t as ErrorHandler } from "../error-handler-BDid7SIZ.js";
3
- import "../index-LKrIp3Oo.js";
1
+ import { n as SerializedError, r as makeErrorHandler, t as ErrorHandler } from "../error-handler-Up4XIzWt.js";
2
+ import "../index-DXJbbtWQ.js";
4
3
  export { ErrorHandler, SerializedError, makeErrorHandler };
@@ -1,5 +1,4 @@
1
- import "../errors-BB_jeye8.js";
2
- import { n as makeErrorHandler, t as ErrorHandler } from "../error-handler-D4s_TTI1.js";
3
- import "../errors-DfkerzdO.js";
1
+ import { n as makeErrorHandler, t as ErrorHandler } from "../error-handler-B4kyoFfy.js";
2
+ import "../errors-DXbNwomE.js";
4
3
 
5
4
  export { ErrorHandler, makeErrorHandler };
@@ -43,4 +43,4 @@ const makeEventPublisherAdapter = (eventBus, logger) => {
43
43
 
44
44
  //#endregion
45
45
  export { makeEventPublisherAdapter as t };
46
- //# sourceMappingURL=event-publisher-adapter-B02oKEmP.js.map
46
+ //# sourceMappingURL=event-publisher-adapter-BHioo53u.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-publisher-adapter-B02oKEmP.js","names":[],"sources":["../src/events/event-publisher-adapter.ts"],"sourcesContent":["import { randomUUID } from 'crypto'\nimport type { EventPublisher, EventBus, Logger } from '@kuckit/domain'\n\n/**\n * Adapter that implements EventPublisher port using EventBus\n * Converts the simplified EventPublisher interface to full EventBus types\n */\nexport const makeEventPublisherAdapter = (eventBus: EventBus, logger: Logger): EventPublisher => {\n\treturn {\n\t\tasync publish(\n\t\t\teventName: string,\n\t\t\tpayload: Record<string, any>,\n\t\t\taggregateId: string\n\t\t): Promise<void> {\n\t\t\t// Convert to EventBus event format\n\t\t\tconst event = {\n\t\t\t\tname: eventName as any,\n\t\t\t\tpayload,\n\t\t\t\tmeta: {\n\t\t\t\t\teventId: randomUUID(),\n\t\t\t\t\toccurredAt: new Date(),\n\t\t\t\t\tversion: 1,\n\t\t\t\t\taggregateId,\n\t\t\t\t\tcorrelationId: randomUUID(),\n\t\t\t\t},\n\t\t\t}\n\n\t\t\t// Log the event being published\n\t\t\tlogger.debug('Publishing event', {\n\t\t\t\teventName,\n\t\t\t\teventId: event.meta.eventId,\n\t\t\t\taggregateId,\n\t\t\t})\n\n\t\t\t// Publish through event bus\n\t\t\tawait eventBus.publish(event as any)\n\t\t},\n\n\t\tsubscribe(\n\t\t\teventName: string,\n\t\t\thandler: (payload: Record<string, any>) => void | Promise<void>\n\t\t): () => void {\n\t\t\t// Subscribe through event bus\n\t\t\treturn eventBus.subscribe(eventName as any, async (event: any) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait handler(event.payload)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error('Error in event handler', {\n\t\t\t\t\t\teventName,\n\t\t\t\t\t\terror: error instanceof Error ? error.message : 'Unknown error',\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t}\n}\n"],"mappings":";;;;;;;AAOA,MAAa,6BAA6B,UAAoB,WAAmC;AAChG,QAAO;EACN,MAAM,QACL,WACA,SACA,aACgB;GAEhB,MAAM,QAAQ;IACb,MAAM;IACN;IACA,MAAM;KACL,SAAS,YAAY;KACrB,4BAAY,IAAI,MAAM;KACtB,SAAS;KACT;KACA,eAAe,YAAY;KAC3B;IACD;AAGD,UAAO,MAAM,oBAAoB;IAChC;IACA,SAAS,MAAM,KAAK;IACpB;IACA,CAAC;AAGF,SAAM,SAAS,QAAQ,MAAa;;EAGrC,UACC,WACA,SACa;AAEb,UAAO,SAAS,UAAU,WAAkB,OAAO,UAAe;AACjE,QAAI;AACH,WAAM,QAAQ,MAAM,QAAQ;aACpB,OAAO;AACf,YAAO,MAAM,0BAA0B;MACtC;MACA,OAAO,iBAAiB,QAAQ,MAAM,UAAU;MAChD,CAAC;;KAEF;;EAEH"}
1
+ {"version":3,"file":"event-publisher-adapter-BHioo53u.js","names":[],"sources":["../src/events/event-publisher-adapter.ts"],"sourcesContent":["import { randomUUID } from 'crypto'\nimport type { EventPublisher, EventBus, Logger } from '@kuckit/domain'\n\n/**\n * Adapter that implements EventPublisher port using EventBus\n * Converts the simplified EventPublisher interface to full EventBus types\n */\nexport const makeEventPublisherAdapter = (eventBus: EventBus, logger: Logger): EventPublisher => {\n\treturn {\n\t\tasync publish(\n\t\t\teventName: string,\n\t\t\tpayload: Record<string, any>,\n\t\t\taggregateId: string\n\t\t): Promise<void> {\n\t\t\t// Convert to EventBus event format\n\t\t\tconst event = {\n\t\t\t\tname: eventName as any,\n\t\t\t\tpayload,\n\t\t\t\tmeta: {\n\t\t\t\t\teventId: randomUUID(),\n\t\t\t\t\toccurredAt: new Date(),\n\t\t\t\t\tversion: 1,\n\t\t\t\t\taggregateId,\n\t\t\t\t\tcorrelationId: randomUUID(),\n\t\t\t\t},\n\t\t\t}\n\n\t\t\t// Log the event being published\n\t\t\tlogger.debug('Publishing event', {\n\t\t\t\teventName,\n\t\t\t\teventId: event.meta.eventId,\n\t\t\t\taggregateId,\n\t\t\t})\n\n\t\t\t// Publish through event bus\n\t\t\tawait eventBus.publish(event as any)\n\t\t},\n\n\t\tsubscribe(\n\t\t\teventName: string,\n\t\t\thandler: (payload: Record<string, any>) => void | Promise<void>\n\t\t): () => void {\n\t\t\t// Subscribe through event bus\n\t\t\treturn eventBus.subscribe(eventName as any, async (event: any) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait handler(event.payload)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error('Error in event handler', {\n\t\t\t\t\t\teventName,\n\t\t\t\t\t\terror: error instanceof Error ? error.message : 'Unknown error',\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t}\n}\n"],"mappings":";;;;;;;AAOA,MAAa,6BAA6B,UAAoB,WAAmC;AAChG,QAAO;EACN,MAAM,QACL,WACA,SACA,aACgB;GAEhB,MAAM,QAAQ;IACb,MAAM;IACN;IACA,MAAM;KACL,SAAS,YAAY;KACrB,4BAAY,IAAI,MAAM;KACtB,SAAS;KACT;KACA,eAAe,YAAY;KAC3B;IACD;AAGD,UAAO,MAAM,oBAAoB;IAChC;IACA,SAAS,MAAM,KAAK;IACpB;IACA,CAAC;AAGF,SAAM,SAAS,QAAQ,MAAa;;EAGrC,UACC,WACA,SACa;AAEb,UAAO,SAAS,UAAU,WAAkB,OAAO,UAAe;AACjE,QAAI;AACH,WAAM,QAAQ,MAAM,QAAQ;aACpB,OAAO;AACf,YAAO,MAAM,0BAA0B;MACtC;MACA,OAAO,iBAAiB,QAAQ,MAAM,UAAU;MAChD,CAAC;;KAEF;;EAEH"}
@@ -9,4 +9,4 @@ import { EventBus, EventPublisher, Logger } from "@kuckit/domain";
9
9
  declare const makeEventPublisherAdapter: (eventBus: EventBus, logger: Logger) => EventPublisher;
10
10
  //#endregion
11
11
  export { makeEventPublisherAdapter as t };
12
- //# sourceMappingURL=event-publisher-adapter-CpxK0OJ3.d.ts.map
12
+ //# sourceMappingURL=event-publisher-adapter-DZv-0P_I.d.ts.map
@@ -1,2 +1,2 @@
1
- import { t as makeEventPublisherAdapter } from "../event-publisher-adapter-CpxK0OJ3.js";
1
+ import { t as makeEventPublisherAdapter } from "../event-publisher-adapter-DZv-0P_I.js";
2
2
  export { makeEventPublisherAdapter };
@@ -1,3 +1,3 @@
1
- import { t as makeEventPublisherAdapter } from "../event-publisher-adapter-B02oKEmP.js";
1
+ import { t as makeEventPublisherAdapter } from "../event-publisher-adapter-BHioo53u.js";
2
2
 
3
3
  export { makeEventPublisherAdapter };
@@ -1,2 +1,2 @@
1
- import { t as InMemoryEventBus } from "../in-memory-event-bus-CqIBLRze.js";
1
+ import { t as InMemoryEventBus } from "../in-memory-event-bus-0rhMMoai.js";
2
2
  export { InMemoryEventBus };
@@ -1,3 +1,3 @@
1
- import { t as InMemoryEventBus } from "../in-memory-event-bus-BCyPrNAE.js";
1
+ import { t as InMemoryEventBus } from "../in-memory-event-bus-D0n7i3uf.js";
2
2
 
3
3
  export { InMemoryEventBus };
@@ -1,2 +1,2 @@
1
- import { t as makeInMemoryEventPublisher } from "../in-memory-event-publisher-CxOQ-hnq.js";
1
+ import { t as makeInMemoryEventPublisher } from "../in-memory-event-publisher-BuFGCWeP.js";
2
2
  export { makeInMemoryEventPublisher };
@@ -1,3 +1,3 @@
1
- import { t as makeInMemoryEventPublisher } from "../in-memory-event-publisher-BdOlxfkx.js";
1
+ import { t as makeInMemoryEventPublisher } from "../in-memory-event-publisher-DEMC6qBo.js";
2
2
 
3
3
  export { makeInMemoryEventPublisher };
@@ -1,5 +1,5 @@
1
- import { t as makeEventPublisherAdapter } from "../event-publisher-adapter-CpxK0OJ3.js";
2
- import { t as InMemoryEventBus } from "../in-memory-event-bus-CqIBLRze.js";
3
- import { t as makeInMemoryEventPublisher } from "../in-memory-event-publisher-CxOQ-hnq.js";
4
- import "../index-C0yeuOwC.js";
1
+ import { t as makeEventPublisherAdapter } from "../event-publisher-adapter-DZv-0P_I.js";
2
+ import { t as InMemoryEventBus } from "../in-memory-event-bus-0rhMMoai.js";
3
+ import { t as makeInMemoryEventPublisher } from "../in-memory-event-publisher-BuFGCWeP.js";
4
+ import "../index-CRDznOKQ.js";
5
5
  export { InMemoryEventBus, makeEventPublisherAdapter, makeInMemoryEventPublisher };
@@ -1,6 +1,6 @@
1
- import { t as InMemoryEventBus } from "../in-memory-event-bus-BCyPrNAE.js";
2
- import { t as makeEventPublisherAdapter } from "../event-publisher-adapter-B02oKEmP.js";
3
- import { t as makeInMemoryEventPublisher } from "../in-memory-event-publisher-BdOlxfkx.js";
4
- import "../events-Dqynhuj2.js";
1
+ import { t as InMemoryEventBus } from "../in-memory-event-bus-D0n7i3uf.js";
2
+ import { t as makeEventPublisherAdapter } from "../event-publisher-adapter-BHioo53u.js";
3
+ import { t as makeInMemoryEventPublisher } from "../in-memory-event-publisher-DEMC6qBo.js";
4
+ import "../events-DkUA7Khm.js";
5
5
 
6
6
  export { InMemoryEventBus, makeEventPublisherAdapter, makeInMemoryEventPublisher };
@@ -42,4 +42,4 @@ declare class InMemoryCacheStore implements CacheStore {
42
42
  declare function makeInMemoryCacheStore(cleanupIntervalMs?: number): InMemoryCacheStore;
43
43
  //#endregion
44
44
  export { makeInMemoryCacheStore as n, InMemoryCacheStore as t };
45
- //# sourceMappingURL=in-memory-cache-store-DSdz35Ve.d.ts.map
45
+ //# sourceMappingURL=in-memory-cache-store-B1RVPPwh.d.ts.map
@@ -89,4 +89,4 @@ function makeInMemoryCacheStore(cleanupIntervalMs = 6e4) {
89
89
 
90
90
  //#endregion
91
91
  export { makeInMemoryCacheStore as n, InMemoryCacheStore as t };
92
- //# sourceMappingURL=in-memory-cache-store-BA-Eqsf0.js.map
92
+ //# sourceMappingURL=in-memory-cache-store-C-v4ag_e.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory-cache-store-BA-Eqsf0.js","names":["cleanupIntervalMs: number","entry: CacheEntry<T>"],"sources":["../src/cache/in-memory-cache-store.ts"],"sourcesContent":["import type { CacheStore } from '@kuckit/domain'\n\ninterface CacheEntry<T> {\n\tvalue: T\n\texpiresAt?: number\n}\n\n/**\n * In-memory cache store implementation\n * Suitable for single-process applications or development\n * For distributed systems, use Redis adapter\n *\n * NOTE: Call startCleanup() after construction to enable background cleanup,\n * or use makeInMemoryCacheStore() factory which does this automatically.\n */\nexport class InMemoryCacheStore implements CacheStore {\n\tprivate cache = new Map<string, CacheEntry<unknown>>()\n\tprivate cleanupTimer: NodeJS.Timeout | null = null\n\n\tconstructor(private cleanupIntervalMs: number = 60000) {\n\t\t// Timer is NOT started in constructor to avoid side effects on import.\n\t\t// Call startCleanup() explicitly after construction.\n\t}\n\n\tasync get<T>(key: string): Promise<T | undefined> {\n\t\tconst entry = this.cache.get(key)\n\n\t\tif (!entry) {\n\t\t\treturn undefined\n\t\t}\n\n\t\t// Check if expired\n\t\tif (entry.expiresAt && entry.expiresAt < Date.now()) {\n\t\t\tthis.cache.delete(key)\n\t\t\treturn undefined\n\t\t}\n\n\t\treturn entry.value as T\n\t}\n\n\tasync set<T>(key: string, value: T, ttlMs?: number): Promise<void> {\n\t\tconst entry: CacheEntry<T> = {\n\t\t\tvalue,\n\t\t\texpiresAt: ttlMs ? Date.now() + ttlMs : undefined,\n\t\t}\n\n\t\tthis.cache.set(key, entry)\n\t}\n\n\tasync del(key: string): Promise<void> {\n\t\tthis.cache.delete(key)\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tthis.cache.clear()\n\t}\n\n\tasync has(key: string): Promise<boolean> {\n\t\tconst entry = this.cache.get(key)\n\n\t\tif (!entry) {\n\t\t\treturn false\n\t\t}\n\n\t\t// Check if expired\n\t\tif (entry.expiresAt && entry.expiresAt < Date.now()) {\n\t\t\tthis.cache.delete(key)\n\t\t\treturn false\n\t\t}\n\n\t\treturn true\n\t}\n\n\t/**\n\t * Start background cleanup of expired entries\n\t * Call this after construction to enable automatic cleanup.\n\t */\n\tstartCleanup(): void {\n\t\tif (this.cleanupTimer) return // Already running\n\n\t\tthis.cleanupTimer = setInterval(() => {\n\t\t\tconst now = Date.now()\n\t\t\tlet expired = 0\n\n\t\t\tfor (const [key, entry] of this.cache.entries()) {\n\t\t\t\tif (entry.expiresAt && entry.expiresAt < now) {\n\t\t\t\t\tthis.cache.delete(key)\n\t\t\t\t\texpired++\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Optionally log cleanup metrics\n\t\t\tif (expired > 0) {\n\t\t\t\t// console.debug(`Cache cleanup: removed ${expired} expired entries`)\n\t\t\t}\n\t\t}, this.cleanupIntervalMs)\n\t}\n\n\t/**\n\t * Stop cleanup timer\n\t */\n\tstopCleanup(): void {\n\t\tif (this.cleanupTimer) {\n\t\t\tclearInterval(this.cleanupTimer)\n\t\t\tthis.cleanupTimer = null\n\t\t}\n\t}\n\n\t/**\n\t * Stop cleanup timer (alias for stopCleanup)\n\t * @deprecated Use stopCleanup() instead\n\t */\n\tdestroy(): void {\n\t\tthis.stopCleanup()\n\t}\n}\n\n/**\n * Factory function that creates an InMemoryCacheStore with cleanup started.\n * Use this in DI container registrations.\n */\nexport function makeInMemoryCacheStore(cleanupIntervalMs = 60000): InMemoryCacheStore {\n\tconst store = new InMemoryCacheStore(cleanupIntervalMs)\n\tstore.startCleanup()\n\treturn store\n}\n"],"mappings":";;;;;;;;;AAeA,IAAa,qBAAb,MAAsD;CACrD,AAAQ,wBAAQ,IAAI,KAAkC;CACtD,AAAQ,eAAsC;CAE9C,YAAY,AAAQA,oBAA4B,KAAO;EAAnC;;CAKpB,MAAM,IAAO,KAAqC;EACjD,MAAM,QAAQ,KAAK,MAAM,IAAI,IAAI;AAEjC,MAAI,CAAC,MACJ;AAID,MAAI,MAAM,aAAa,MAAM,YAAY,KAAK,KAAK,EAAE;AACpD,QAAK,MAAM,OAAO,IAAI;AACtB;;AAGD,SAAO,MAAM;;CAGd,MAAM,IAAO,KAAa,OAAU,OAA+B;EAClE,MAAMC,QAAuB;GAC5B;GACA,WAAW,QAAQ,KAAK,KAAK,GAAG,QAAQ;GACxC;AAED,OAAK,MAAM,IAAI,KAAK,MAAM;;CAG3B,MAAM,IAAI,KAA4B;AACrC,OAAK,MAAM,OAAO,IAAI;;CAGvB,MAAM,QAAuB;AAC5B,OAAK,MAAM,OAAO;;CAGnB,MAAM,IAAI,KAA+B;EACxC,MAAM,QAAQ,KAAK,MAAM,IAAI,IAAI;AAEjC,MAAI,CAAC,MACJ,QAAO;AAIR,MAAI,MAAM,aAAa,MAAM,YAAY,KAAK,KAAK,EAAE;AACpD,QAAK,MAAM,OAAO,IAAI;AACtB,UAAO;;AAGR,SAAO;;;;;;CAOR,eAAqB;AACpB,MAAI,KAAK,aAAc;AAEvB,OAAK,eAAe,kBAAkB;GACrC,MAAM,MAAM,KAAK,KAAK;GACtB,IAAI,UAAU;AAEd,QAAK,MAAM,CAAC,KAAK,UAAU,KAAK,MAAM,SAAS,CAC9C,KAAI,MAAM,aAAa,MAAM,YAAY,KAAK;AAC7C,SAAK,MAAM,OAAO,IAAI;AACtB;;AAKF,OAAI,UAAU,GAAG;KAGf,KAAK,kBAAkB;;;;;CAM3B,cAAoB;AACnB,MAAI,KAAK,cAAc;AACtB,iBAAc,KAAK,aAAa;AAChC,QAAK,eAAe;;;;;;;CAQtB,UAAgB;AACf,OAAK,aAAa;;;;;;;AAQpB,SAAgB,uBAAuB,oBAAoB,KAA2B;CACrF,MAAM,QAAQ,IAAI,mBAAmB,kBAAkB;AACvD,OAAM,cAAc;AACpB,QAAO"}
1
+ {"version":3,"file":"in-memory-cache-store-C-v4ag_e.js","names":["cleanupIntervalMs: number","entry: CacheEntry<T>"],"sources":["../src/cache/in-memory-cache-store.ts"],"sourcesContent":["import type { CacheStore } from '@kuckit/domain'\n\ninterface CacheEntry<T> {\n\tvalue: T\n\texpiresAt?: number\n}\n\n/**\n * In-memory cache store implementation\n * Suitable for single-process applications or development\n * For distributed systems, use Redis adapter\n *\n * NOTE: Call startCleanup() after construction to enable background cleanup,\n * or use makeInMemoryCacheStore() factory which does this automatically.\n */\nexport class InMemoryCacheStore implements CacheStore {\n\tprivate cache = new Map<string, CacheEntry<unknown>>()\n\tprivate cleanupTimer: NodeJS.Timeout | null = null\n\n\tconstructor(private cleanupIntervalMs: number = 60000) {\n\t\t// Timer is NOT started in constructor to avoid side effects on import.\n\t\t// Call startCleanup() explicitly after construction.\n\t}\n\n\tasync get<T>(key: string): Promise<T | undefined> {\n\t\tconst entry = this.cache.get(key)\n\n\t\tif (!entry) {\n\t\t\treturn undefined\n\t\t}\n\n\t\t// Check if expired\n\t\tif (entry.expiresAt && entry.expiresAt < Date.now()) {\n\t\t\tthis.cache.delete(key)\n\t\t\treturn undefined\n\t\t}\n\n\t\treturn entry.value as T\n\t}\n\n\tasync set<T>(key: string, value: T, ttlMs?: number): Promise<void> {\n\t\tconst entry: CacheEntry<T> = {\n\t\t\tvalue,\n\t\t\texpiresAt: ttlMs ? Date.now() + ttlMs : undefined,\n\t\t}\n\n\t\tthis.cache.set(key, entry)\n\t}\n\n\tasync del(key: string): Promise<void> {\n\t\tthis.cache.delete(key)\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tthis.cache.clear()\n\t}\n\n\tasync has(key: string): Promise<boolean> {\n\t\tconst entry = this.cache.get(key)\n\n\t\tif (!entry) {\n\t\t\treturn false\n\t\t}\n\n\t\t// Check if expired\n\t\tif (entry.expiresAt && entry.expiresAt < Date.now()) {\n\t\t\tthis.cache.delete(key)\n\t\t\treturn false\n\t\t}\n\n\t\treturn true\n\t}\n\n\t/**\n\t * Start background cleanup of expired entries\n\t * Call this after construction to enable automatic cleanup.\n\t */\n\tstartCleanup(): void {\n\t\tif (this.cleanupTimer) return // Already running\n\n\t\tthis.cleanupTimer = setInterval(() => {\n\t\t\tconst now = Date.now()\n\t\t\tlet expired = 0\n\n\t\t\tfor (const [key, entry] of this.cache.entries()) {\n\t\t\t\tif (entry.expiresAt && entry.expiresAt < now) {\n\t\t\t\t\tthis.cache.delete(key)\n\t\t\t\t\texpired++\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Optionally log cleanup metrics\n\t\t\tif (expired > 0) {\n\t\t\t\t// console.debug(`Cache cleanup: removed ${expired} expired entries`)\n\t\t\t}\n\t\t}, this.cleanupIntervalMs)\n\t}\n\n\t/**\n\t * Stop cleanup timer\n\t */\n\tstopCleanup(): void {\n\t\tif (this.cleanupTimer) {\n\t\t\tclearInterval(this.cleanupTimer)\n\t\t\tthis.cleanupTimer = null\n\t\t}\n\t}\n\n\t/**\n\t * Stop cleanup timer (alias for stopCleanup)\n\t * @deprecated Use stopCleanup() instead\n\t */\n\tdestroy(): void {\n\t\tthis.stopCleanup()\n\t}\n}\n\n/**\n * Factory function that creates an InMemoryCacheStore with cleanup started.\n * Use this in DI container registrations.\n */\nexport function makeInMemoryCacheStore(cleanupIntervalMs = 60000): InMemoryCacheStore {\n\tconst store = new InMemoryCacheStore(cleanupIntervalMs)\n\tstore.startCleanup()\n\treturn store\n}\n"],"mappings":";;;;;;;;;AAeA,IAAa,qBAAb,MAAsD;CACrD,AAAQ,wBAAQ,IAAI,KAAkC;CACtD,AAAQ,eAAsC;CAE9C,YAAY,AAAQA,oBAA4B,KAAO;EAAnC;;CAKpB,MAAM,IAAO,KAAqC;EACjD,MAAM,QAAQ,KAAK,MAAM,IAAI,IAAI;AAEjC,MAAI,CAAC,MACJ;AAID,MAAI,MAAM,aAAa,MAAM,YAAY,KAAK,KAAK,EAAE;AACpD,QAAK,MAAM,OAAO,IAAI;AACtB;;AAGD,SAAO,MAAM;;CAGd,MAAM,IAAO,KAAa,OAAU,OAA+B;EAClE,MAAMC,QAAuB;GAC5B;GACA,WAAW,QAAQ,KAAK,KAAK,GAAG,QAAQ;GACxC;AAED,OAAK,MAAM,IAAI,KAAK,MAAM;;CAG3B,MAAM,IAAI,KAA4B;AACrC,OAAK,MAAM,OAAO,IAAI;;CAGvB,MAAM,QAAuB;AAC5B,OAAK,MAAM,OAAO;;CAGnB,MAAM,IAAI,KAA+B;EACxC,MAAM,QAAQ,KAAK,MAAM,IAAI,IAAI;AAEjC,MAAI,CAAC,MACJ,QAAO;AAIR,MAAI,MAAM,aAAa,MAAM,YAAY,KAAK,KAAK,EAAE;AACpD,QAAK,MAAM,OAAO,IAAI;AACtB,UAAO;;AAGR,SAAO;;;;;;CAOR,eAAqB;AACpB,MAAI,KAAK,aAAc;AAEvB,OAAK,eAAe,kBAAkB;GACrC,MAAM,MAAM,KAAK,KAAK;GACtB,IAAI,UAAU;AAEd,QAAK,MAAM,CAAC,KAAK,UAAU,KAAK,MAAM,SAAS,CAC9C,KAAI,MAAM,aAAa,MAAM,YAAY,KAAK;AAC7C,SAAK,MAAM,OAAO,IAAI;AACtB;;AAKF,OAAI,UAAU,GAAG;KAGf,KAAK,kBAAkB;;;;;CAM3B,cAAoB;AACnB,MAAI,KAAK,cAAc;AACtB,iBAAc,KAAK,aAAa;AAChC,QAAK,eAAe;;;;;;;CAQtB,UAAgB;AACf,OAAK,aAAa;;;;;;;AAQpB,SAAgB,uBAAuB,oBAAoB,KAA2B;CACrF,MAAM,QAAQ,IAAI,mBAAmB,kBAAkB;AACvD,OAAM,cAAc;AACpB,QAAO"}
@@ -18,4 +18,4 @@ declare class InMemoryEventBus implements EventBus {
18
18
  }
19
19
  //#endregion
20
20
  export { InMemoryEventBus as t };
21
- //# sourceMappingURL=in-memory-event-bus-CqIBLRze.d.ts.map
21
+ //# sourceMappingURL=in-memory-event-bus-0rhMMoai.d.ts.map
@@ -57,4 +57,4 @@ var InMemoryEventBus = class {
57
57
 
58
58
  //#endregion
59
59
  export { InMemoryEventBus as t };
60
- //# sourceMappingURL=in-memory-event-bus-BCyPrNAE.js.map
60
+ //# sourceMappingURL=in-memory-event-bus-D0n7i3uf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory-event-bus-BCyPrNAE.js","names":["logger: Logger"],"sources":["../src/events/in-memory-event-bus.ts"],"sourcesContent":["/**\n * In-memory event bus implementation\n * Suitable for single-process applications\n *\n * For distributed systems, implement EventBus with:\n * - Redis Pub/Sub\n * - RabbitMQ\n * - AWS SNS/SQS\n * - Apache Kafka\n */\n\nimport type { EventBus, EventHandler, EventName, TypedDomainEvent } from '@kuckit/domain'\nimport type { Logger } from '@kuckit/domain'\n\n/**\n * In-memory event bus\n * Stores handlers in Sets, executes synchronously or asynchronously\n */\nexport class InMemoryEventBus implements EventBus {\n\tprivate handlers: Map<string, Set<EventHandler>> = new Map()\n\tprivate allHandlers: Set<EventHandler> = new Set()\n\n\tconstructor(private logger: Logger) {}\n\n\tasync publish<TName extends EventName>(event: TypedDomainEvent<TName>): Promise<void> {\n\t\tconst eventName = String(event.name)\n\t\tconst handlers = this.handlers.get(eventName) ?? new Set()\n\t\tconst allHandlers = Array.from(this.allHandlers)\n\t\tconst eventHandlers = [...handlers, ...allHandlers]\n\n\t\t// Execute all handlers, catching errors\n\t\tconst results = await Promise.allSettled(\n\t\t\teventHandlers.map((handler) =>\n\t\t\t\tPromise.resolve(handler(event as any)).catch((error) => {\n\t\t\t\t\tthis.logger.error('Error in event handler', {\n\t\t\t\t\t\teventName,\n\t\t\t\t\t\teventId: event.meta.eventId,\n\t\t\t\t\t\terror,\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t)\n\t\t)\n\n\t\t// Log summary\n\t\tconst failed = results.filter((r) => r.status === 'rejected').length\n\t\tif (failed > 0) {\n\t\t\tthis.logger.warn(`Event published with ${failed} handler errors`, {\n\t\t\t\teventName,\n\t\t\t\teventId: event.meta.eventId,\n\t\t\t})\n\t\t}\n\t}\n\n\tpublishAsync<TName extends EventName>(event: TypedDomainEvent<TName>): void {\n\t\tqueueMicrotask(() => {\n\t\t\tthis.publish(event).catch((error) => {\n\t\t\t\tthis.logger.error('Unhandled error in async event publishing', {\n\t\t\t\t\teventName: event.name,\n\t\t\t\t\teventId: event.meta.eventId,\n\t\t\t\t\terror,\n\t\t\t\t})\n\t\t\t})\n\t\t})\n\t}\n\n\tsubscribe<TName extends EventName>(eventName: TName, handler: EventHandler<TName>): () => void {\n\t\tconst eventNameStr = String(eventName)\n\t\tif (!this.handlers.has(eventNameStr)) {\n\t\t\tthis.handlers.set(eventNameStr, new Set())\n\t\t}\n\n\t\tconst handlerSet = this.handlers.get(eventNameStr)!\n\t\thandlerSet.add(handler as EventHandler)\n\n\t\t// Return unsubscribe function\n\t\treturn () => {\n\t\t\thandlerSet.delete(handler as EventHandler)\n\t\t\tif (handlerSet.size === 0) {\n\t\t\t\tthis.handlers.delete(eventNameStr)\n\t\t\t}\n\t\t}\n\t}\n\n\tsubscribeAll(handler: EventHandler): () => void {\n\t\tthis.allHandlers.add(handler)\n\n\t\t// Return unsubscribe function\n\t\treturn () => {\n\t\t\tthis.allHandlers.delete(handler)\n\t\t}\n\t}\n}\n"],"mappings":";;;;;AAkBA,IAAa,mBAAb,MAAkD;CACjD,AAAQ,2BAA2C,IAAI,KAAK;CAC5D,AAAQ,8BAAiC,IAAI,KAAK;CAElD,YAAY,AAAQA,QAAgB;EAAhB;;CAEpB,MAAM,QAAiC,OAA+C;EACrF,MAAM,YAAY,OAAO,MAAM,KAAK;EACpC,MAAM,WAAW,KAAK,SAAS,IAAI,UAAU,oBAAI,IAAI,KAAK;EAC1D,MAAM,cAAc,MAAM,KAAK,KAAK,YAAY;EAChD,MAAM,gBAAgB,CAAC,GAAG,UAAU,GAAG,YAAY;EAgBnD,MAAM,UAbU,MAAM,QAAQ,WAC7B,cAAc,KAAK,YAClB,QAAQ,QAAQ,QAAQ,MAAa,CAAC,CAAC,OAAO,UAAU;AACvD,QAAK,OAAO,MAAM,0BAA0B;IAC3C;IACA,SAAS,MAAM,KAAK;IACpB;IACA,CAAC;IACD,CACF,CACD,EAGsB,QAAQ,MAAM,EAAE,WAAW,WAAW,CAAC;AAC9D,MAAI,SAAS,EACZ,MAAK,OAAO,KAAK,wBAAwB,OAAO,kBAAkB;GACjE;GACA,SAAS,MAAM,KAAK;GACpB,CAAC;;CAIJ,aAAsC,OAAsC;AAC3E,uBAAqB;AACpB,QAAK,QAAQ,MAAM,CAAC,OAAO,UAAU;AACpC,SAAK,OAAO,MAAM,6CAA6C;KAC9D,WAAW,MAAM;KACjB,SAAS,MAAM,KAAK;KACpB;KACA,CAAC;KACD;IACD;;CAGH,UAAmC,WAAkB,SAA0C;EAC9F,MAAM,eAAe,OAAO,UAAU;AACtC,MAAI,CAAC,KAAK,SAAS,IAAI,aAAa,CACnC,MAAK,SAAS,IAAI,8BAAc,IAAI,KAAK,CAAC;EAG3C,MAAM,aAAa,KAAK,SAAS,IAAI,aAAa;AAClD,aAAW,IAAI,QAAwB;AAGvC,eAAa;AACZ,cAAW,OAAO,QAAwB;AAC1C,OAAI,WAAW,SAAS,EACvB,MAAK,SAAS,OAAO,aAAa;;;CAKrC,aAAa,SAAmC;AAC/C,OAAK,YAAY,IAAI,QAAQ;AAG7B,eAAa;AACZ,QAAK,YAAY,OAAO,QAAQ"}
1
+ {"version":3,"file":"in-memory-event-bus-D0n7i3uf.js","names":["logger: Logger"],"sources":["../src/events/in-memory-event-bus.ts"],"sourcesContent":["/**\n * In-memory event bus implementation\n * Suitable for single-process applications\n *\n * For distributed systems, implement EventBus with:\n * - Redis Pub/Sub\n * - RabbitMQ\n * - AWS SNS/SQS\n * - Apache Kafka\n */\n\nimport type { EventBus, EventHandler, EventName, TypedDomainEvent } from '@kuckit/domain'\nimport type { Logger } from '@kuckit/domain'\n\n/**\n * In-memory event bus\n * Stores handlers in Sets, executes synchronously or asynchronously\n */\nexport class InMemoryEventBus implements EventBus {\n\tprivate handlers: Map<string, Set<EventHandler>> = new Map()\n\tprivate allHandlers: Set<EventHandler> = new Set()\n\n\tconstructor(private logger: Logger) {}\n\n\tasync publish<TName extends EventName>(event: TypedDomainEvent<TName>): Promise<void> {\n\t\tconst eventName = String(event.name)\n\t\tconst handlers = this.handlers.get(eventName) ?? new Set()\n\t\tconst allHandlers = Array.from(this.allHandlers)\n\t\tconst eventHandlers = [...handlers, ...allHandlers]\n\n\t\t// Execute all handlers, catching errors\n\t\tconst results = await Promise.allSettled(\n\t\t\teventHandlers.map((handler) =>\n\t\t\t\tPromise.resolve(handler(event as any)).catch((error) => {\n\t\t\t\t\tthis.logger.error('Error in event handler', {\n\t\t\t\t\t\teventName,\n\t\t\t\t\t\teventId: event.meta.eventId,\n\t\t\t\t\t\terror,\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t)\n\t\t)\n\n\t\t// Log summary\n\t\tconst failed = results.filter((r) => r.status === 'rejected').length\n\t\tif (failed > 0) {\n\t\t\tthis.logger.warn(`Event published with ${failed} handler errors`, {\n\t\t\t\teventName,\n\t\t\t\teventId: event.meta.eventId,\n\t\t\t})\n\t\t}\n\t}\n\n\tpublishAsync<TName extends EventName>(event: TypedDomainEvent<TName>): void {\n\t\tqueueMicrotask(() => {\n\t\t\tthis.publish(event).catch((error) => {\n\t\t\t\tthis.logger.error('Unhandled error in async event publishing', {\n\t\t\t\t\teventName: event.name,\n\t\t\t\t\teventId: event.meta.eventId,\n\t\t\t\t\terror,\n\t\t\t\t})\n\t\t\t})\n\t\t})\n\t}\n\n\tsubscribe<TName extends EventName>(eventName: TName, handler: EventHandler<TName>): () => void {\n\t\tconst eventNameStr = String(eventName)\n\t\tif (!this.handlers.has(eventNameStr)) {\n\t\t\tthis.handlers.set(eventNameStr, new Set())\n\t\t}\n\n\t\tconst handlerSet = this.handlers.get(eventNameStr)!\n\t\thandlerSet.add(handler as EventHandler)\n\n\t\t// Return unsubscribe function\n\t\treturn () => {\n\t\t\thandlerSet.delete(handler as EventHandler)\n\t\t\tif (handlerSet.size === 0) {\n\t\t\t\tthis.handlers.delete(eventNameStr)\n\t\t\t}\n\t\t}\n\t}\n\n\tsubscribeAll(handler: EventHandler): () => void {\n\t\tthis.allHandlers.add(handler)\n\n\t\t// Return unsubscribe function\n\t\treturn () => {\n\t\t\tthis.allHandlers.delete(handler)\n\t\t}\n\t}\n}\n"],"mappings":";;;;;AAkBA,IAAa,mBAAb,MAAkD;CACjD,AAAQ,2BAA2C,IAAI,KAAK;CAC5D,AAAQ,8BAAiC,IAAI,KAAK;CAElD,YAAY,AAAQA,QAAgB;EAAhB;;CAEpB,MAAM,QAAiC,OAA+C;EACrF,MAAM,YAAY,OAAO,MAAM,KAAK;EACpC,MAAM,WAAW,KAAK,SAAS,IAAI,UAAU,oBAAI,IAAI,KAAK;EAC1D,MAAM,cAAc,MAAM,KAAK,KAAK,YAAY;EAChD,MAAM,gBAAgB,CAAC,GAAG,UAAU,GAAG,YAAY;EAgBnD,MAAM,UAbU,MAAM,QAAQ,WAC7B,cAAc,KAAK,YAClB,QAAQ,QAAQ,QAAQ,MAAa,CAAC,CAAC,OAAO,UAAU;AACvD,QAAK,OAAO,MAAM,0BAA0B;IAC3C;IACA,SAAS,MAAM,KAAK;IACpB;IACA,CAAC;IACD,CACF,CACD,EAGsB,QAAQ,MAAM,EAAE,WAAW,WAAW,CAAC;AAC9D,MAAI,SAAS,EACZ,MAAK,OAAO,KAAK,wBAAwB,OAAO,kBAAkB;GACjE;GACA,SAAS,MAAM,KAAK;GACpB,CAAC;;CAIJ,aAAsC,OAAsC;AAC3E,uBAAqB;AACpB,QAAK,QAAQ,MAAM,CAAC,OAAO,UAAU;AACpC,SAAK,OAAO,MAAM,6CAA6C;KAC9D,WAAW,MAAM;KACjB,SAAS,MAAM,KAAK;KACpB;KACA,CAAC;KACD;IACD;;CAGH,UAAmC,WAAkB,SAA0C;EAC9F,MAAM,eAAe,OAAO,UAAU;AACtC,MAAI,CAAC,KAAK,SAAS,IAAI,aAAa,CACnC,MAAK,SAAS,IAAI,8BAAc,IAAI,KAAK,CAAC;EAG3C,MAAM,aAAa,KAAK,SAAS,IAAI,aAAa;AAClD,aAAW,IAAI,QAAwB;AAGvC,eAAa;AACZ,cAAW,OAAO,QAAwB;AAC1C,OAAI,WAAW,SAAS,EACvB,MAAK,SAAS,OAAO,aAAa;;;CAKrC,aAAa,SAAmC;AAC/C,OAAK,YAAY,IAAI,QAAQ;AAG7B,eAAa;AACZ,QAAK,YAAY,OAAO,QAAQ"}
@@ -9,4 +9,4 @@ import { EventPublisher } from "@kuckit/domain";
9
9
  declare const makeInMemoryEventPublisher: () => EventPublisher;
10
10
  //#endregion
11
11
  export { makeInMemoryEventPublisher as t };
12
- //# sourceMappingURL=in-memory-event-publisher-CxOQ-hnq.d.ts.map
12
+ //# sourceMappingURL=in-memory-event-publisher-BuFGCWeP.d.ts.map
@@ -25,4 +25,4 @@ const makeInMemoryEventPublisher = () => {
25
25
 
26
26
  //#endregion
27
27
  export { makeInMemoryEventPublisher as t };
28
- //# sourceMappingURL=in-memory-event-publisher-BdOlxfkx.js.map
28
+ //# sourceMappingURL=in-memory-event-publisher-DEMC6qBo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory-event-publisher-BdOlxfkx.js","names":[],"sources":["../src/events/in-memory-event-publisher.ts"],"sourcesContent":["import type { EventPublisher } from '@kuckit/domain'\n\n/**\n * In-memory event publisher implementation\n * Suitable for development and testing\n */\nexport const makeInMemoryEventPublisher = (): EventPublisher => {\n\tconst subscribers = new Map<string, Set<(payload: Record<string, any>) => Promise<void> | void>>()\n\n\treturn {\n\t\tasync publish(\n\t\t\teventName: string,\n\t\t\tpayload: Record<string, any>,\n\t\t\t_aggregateId: string\n\t\t): Promise<void> {\n\t\t\tconst handlers = subscribers.get(eventName)\n\t\t\tif (!handlers) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Execute all handlers concurrently\n\t\t\tawait Promise.all(Array.from(handlers).map((handler) => Promise.resolve(handler(payload))))\n\t\t},\n\n\t\tsubscribe(\n\t\t\teventName: string,\n\t\t\thandler: (payload: Record<string, any>) => Promise<void> | void\n\t\t): () => void {\n\t\t\tif (!subscribers.has(eventName)) {\n\t\t\t\tsubscribers.set(eventName, new Set())\n\t\t\t}\n\n\t\t\tconst handlers = subscribers.get(eventName)!\n\t\t\thandlers.add(handler)\n\n\t\t\t// Return unsubscribe function\n\t\t\treturn () => {\n\t\t\t\thandlers.delete(handler)\n\t\t\t\tif (handlers.size === 0) {\n\t\t\t\t\tsubscribers.delete(eventName)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t}\n}\n"],"mappings":";;;;;AAMA,MAAa,mCAAmD;CAC/D,MAAM,8BAAc,IAAI,KAA0E;AAElG,QAAO;EACN,MAAM,QACL,WACA,SACA,cACgB;GAChB,MAAM,WAAW,YAAY,IAAI,UAAU;AAC3C,OAAI,CAAC,SACJ;AAID,SAAM,QAAQ,IAAI,MAAM,KAAK,SAAS,CAAC,KAAK,YAAY,QAAQ,QAAQ,QAAQ,QAAQ,CAAC,CAAC,CAAC;;EAG5F,UACC,WACA,SACa;AACb,OAAI,CAAC,YAAY,IAAI,UAAU,CAC9B,aAAY,IAAI,2BAAW,IAAI,KAAK,CAAC;GAGtC,MAAM,WAAW,YAAY,IAAI,UAAU;AAC3C,YAAS,IAAI,QAAQ;AAGrB,gBAAa;AACZ,aAAS,OAAO,QAAQ;AACxB,QAAI,SAAS,SAAS,EACrB,aAAY,OAAO,UAAU;;;EAIhC"}
1
+ {"version":3,"file":"in-memory-event-publisher-DEMC6qBo.js","names":[],"sources":["../src/events/in-memory-event-publisher.ts"],"sourcesContent":["import type { EventPublisher } from '@kuckit/domain'\n\n/**\n * In-memory event publisher implementation\n * Suitable for development and testing\n */\nexport const makeInMemoryEventPublisher = (): EventPublisher => {\n\tconst subscribers = new Map<string, Set<(payload: Record<string, any>) => Promise<void> | void>>()\n\n\treturn {\n\t\tasync publish(\n\t\t\teventName: string,\n\t\t\tpayload: Record<string, any>,\n\t\t\t_aggregateId: string\n\t\t): Promise<void> {\n\t\t\tconst handlers = subscribers.get(eventName)\n\t\t\tif (!handlers) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// Execute all handlers concurrently\n\t\t\tawait Promise.all(Array.from(handlers).map((handler) => Promise.resolve(handler(payload))))\n\t\t},\n\n\t\tsubscribe(\n\t\t\teventName: string,\n\t\t\thandler: (payload: Record<string, any>) => Promise<void> | void\n\t\t): () => void {\n\t\t\tif (!subscribers.has(eventName)) {\n\t\t\t\tsubscribers.set(eventName, new Set())\n\t\t\t}\n\n\t\t\tconst handlers = subscribers.get(eventName)!\n\t\t\thandlers.add(handler)\n\n\t\t\t// Return unsubscribe function\n\t\t\treturn () => {\n\t\t\t\thandlers.delete(handler)\n\t\t\t\tif (handlers.size === 0) {\n\t\t\t\t\tsubscribers.delete(eventName)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t}\n}\n"],"mappings":";;;;;AAMA,MAAa,mCAAmD;CAC/D,MAAM,8BAAc,IAAI,KAA0E;AAElG,QAAO;EACN,MAAM,QACL,WACA,SACA,cACgB;GAChB,MAAM,WAAW,YAAY,IAAI,UAAU;AAC3C,OAAI,CAAC,SACJ;AAID,SAAM,QAAQ,IAAI,MAAM,KAAK,SAAS,CAAC,KAAK,YAAY,QAAQ,QAAQ,QAAQ,QAAQ,CAAC,CAAC,CAAC;;EAG5F,UACC,WACA,SACa;AACb,OAAI,CAAC,YAAY,IAAI,UAAU,CAC9B,aAAY,IAAI,2BAAW,IAAI,KAAK,CAAC;GAGtC,MAAM,WAAW,YAAY,IAAI,UAAU;AAC3C,YAAS,IAAI,QAAQ;AAGrB,gBAAa;AACZ,aAAS,OAAO,QAAQ;AACxB,QAAI,SAAS,SAAS,EACrB,aAAY,OAAO,UAAU;;;EAIhC"}
@@ -89,4 +89,4 @@ function makeInMemoryRateLimiterStore(cleanupIntervalMs = 6e4) {
89
89
 
90
90
  //#endregion
91
91
  export { makeInMemoryRateLimiterStore as n, InMemoryRateLimiterStore as t };
92
- //# sourceMappingURL=in-memory-rate-limiter-DKOwxFD7.js.map
92
+ //# sourceMappingURL=in-memory-rate-limiter-ClGoFbk6.js.map