@kuckit/infrastructure 1.0.2 → 2.0.0

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 (131) hide show
  1. package/dist/apply-decorators-CW23qWy7.d.ts +23 -0
  2. package/dist/apply-decorators-CaHIAL5X.js +29 -0
  3. package/dist/apply-decorators-CaHIAL5X.js.map +1 -0
  4. package/dist/cache/in-memory-cache-store.d.ts +2 -0
  5. package/dist/cache/in-memory-cache-store.js +3 -0
  6. package/dist/cache/index.d.ts +3 -0
  7. package/dist/cache/index.js +4 -0
  8. package/dist/cache-BjdZ-Ye4.js +1 -0
  9. package/dist/core.module-B1TdC0yX.d.ts +17 -0
  10. package/dist/core.module-DMtIkTcz.js +48 -0
  11. package/dist/core.module-DMtIkTcz.js.map +1 -0
  12. package/dist/db/drizzle/db.d.ts +2 -0
  13. package/dist/db/drizzle/db.js +3 -0
  14. package/dist/db/drizzle/repositories/index.d.ts +3 -0
  15. package/dist/db/drizzle/repositories/index.js +4 -0
  16. package/dist/db/drizzle/repositories/user.drizzle.d.ts +2 -0
  17. package/dist/db/drizzle/repositories/user.drizzle.js +3 -0
  18. package/dist/db/transaction.d.ts +2 -0
  19. package/dist/db/transaction.js +4 -0
  20. package/dist/db-C4IcCT04.js +25 -0
  21. package/dist/db-C4IcCT04.js.map +1 -0
  22. package/dist/db-tAPHBDyL.d.ts +17 -0
  23. package/dist/decorators/apply-decorators.d.ts +2 -0
  24. package/dist/decorators/apply-decorators.js +5 -0
  25. package/dist/decorators/index.d.ts +8 -0
  26. package/dist/decorators/index.js +9 -0
  27. package/dist/decorators/use-case-decorator.d.ts +3 -0
  28. package/dist/decorators/use-case-decorator.js +4 -0
  29. package/dist/decorators/with-caching.d.ts +2 -0
  30. package/dist/decorators/with-caching.js +3 -0
  31. package/dist/decorators/with-rate-limit.d.ts +2 -0
  32. package/dist/decorators/with-rate-limit.js +3 -0
  33. package/dist/decorators/with-retry.d.ts +2 -0
  34. package/dist/decorators/with-retry.js +3 -0
  35. package/dist/decorators-CqyPE9AQ.js +1 -0
  36. package/dist/error-handler-BDid7SIZ.d.ts +47 -0
  37. package/dist/error-handler-D4s_TTI1.js +80 -0
  38. package/dist/error-handler-D4s_TTI1.js.map +1 -0
  39. package/dist/errors/error-handler.d.ts +3 -0
  40. package/dist/errors/error-handler.js +4 -0
  41. package/dist/errors/index.d.ts +4 -0
  42. package/dist/errors/index.js +5 -0
  43. package/dist/errors-BB_jeye8.js +43 -0
  44. package/dist/errors-BB_jeye8.js.map +1 -0
  45. package/dist/errors-DfkerzdO.js +1 -0
  46. package/dist/event-publisher-adapter-B02oKEmP.js +46 -0
  47. package/dist/event-publisher-adapter-B02oKEmP.js.map +1 -0
  48. package/dist/event-publisher-adapter-CpxK0OJ3.d.ts +12 -0
  49. package/dist/events/event-publisher-adapter.d.ts +2 -0
  50. package/dist/events/event-publisher-adapter.js +3 -0
  51. package/dist/events/in-memory-event-bus.d.ts +2 -0
  52. package/dist/events/in-memory-event-bus.js +3 -0
  53. package/dist/events/in-memory-event-publisher.d.ts +2 -0
  54. package/dist/events/in-memory-event-publisher.js +3 -0
  55. package/dist/events/index.d.ts +5 -0
  56. package/dist/events/index.js +6 -0
  57. package/dist/events-Dqynhuj2.js +1 -0
  58. package/dist/in-memory-cache-store-BaRxM--K.d.ts +31 -0
  59. package/dist/in-memory-cache-store-oClww-8m.js +72 -0
  60. package/dist/in-memory-cache-store-oClww-8m.js.map +1 -0
  61. package/dist/in-memory-event-bus-BCyPrNAE.js +60 -0
  62. package/dist/in-memory-event-bus-BCyPrNAE.js.map +1 -0
  63. package/dist/in-memory-event-bus-CqIBLRze.d.ts +21 -0
  64. package/dist/in-memory-event-publisher-BdOlxfkx.js +28 -0
  65. package/dist/in-memory-event-publisher-BdOlxfkx.js.map +1 -0
  66. package/dist/in-memory-event-publisher-CxOQ-hnq.d.ts +12 -0
  67. package/dist/in-memory-rate-limiter-BDSHZXxf.js +72 -0
  68. package/dist/in-memory-rate-limiter-BDSHZXxf.js.map +1 -0
  69. package/dist/in-memory-rate-limiter-DJsxdZZR.d.ts +34 -0
  70. package/dist/index-B5F3AfVc.d.ts +1 -0
  71. package/dist/index-B7z6dpFd.d.ts +1 -0
  72. package/dist/index-BH67NKRs.d.ts +2 -0
  73. package/dist/index-C0yeuOwC.d.ts +1 -0
  74. package/dist/index-C6nYd7xV.d.ts +2 -0
  75. package/dist/index-DVGDAddE.d.ts +1 -0
  76. package/dist/index-DXJbbtWQ.d.ts +1 -0
  77. package/dist/index-LKrIp3Oo.d.ts +1 -0
  78. package/dist/index.d.ts +29 -506
  79. package/dist/index.js +27 -969
  80. package/dist/logger-Bl10drB8.d.ts +23 -0
  81. package/dist/logging/index.d.ts +5 -0
  82. package/dist/logging/index.js +5 -0
  83. package/dist/logging/request-logger.d.ts +2 -0
  84. package/dist/logging/request-logger.js +3 -0
  85. package/dist/logging/structured-logger.d.ts +3 -0
  86. package/dist/logging/structured-logger.js +3 -0
  87. package/dist/logging-4mLSrMc6.js +1 -0
  88. package/dist/modules/core.module.d.ts +10 -0
  89. package/dist/modules/core.module.js +13 -0
  90. package/dist/modules/index.d.ts +12 -0
  91. package/dist/modules/index.js +16 -0
  92. package/dist/modules/types.d.ts +9 -0
  93. package/dist/modules/types.js +6 -0
  94. package/dist/modules/user.module.d.ts +10 -0
  95. package/dist/modules/user.module.js +4 -0
  96. package/dist/modules-C_2SF3he.js +1 -0
  97. package/dist/rate-limiter/in-memory-rate-limiter.d.ts +2 -0
  98. package/dist/rate-limiter/in-memory-rate-limiter.js +3 -0
  99. package/dist/rate-limiter/index.d.ts +3 -0
  100. package/dist/rate-limiter/index.js +4 -0
  101. package/dist/rate-limiter-BnvPGJOK.js +1 -0
  102. package/dist/repositories-nTfSJyvW.js +1 -0
  103. package/dist/request-logger-CK3SOnoz.d.ts +23 -0
  104. package/dist/request-logger-Cw1XQWTV.js +49 -0
  105. package/dist/request-logger-Cw1XQWTV.js.map +1 -0
  106. package/dist/structured-logger-BsxDI9zX.js +119 -0
  107. package/dist/structured-logger-BsxDI9zX.js.map +1 -0
  108. package/dist/structured-logger-Dz06Uz-u.d.ts +47 -0
  109. package/dist/transaction-akuz5Fch.d.ts +22 -0
  110. package/dist/transaction-r4Sy3eC-.js +35 -0
  111. package/dist/transaction-r4Sy3eC-.js.map +1 -0
  112. package/dist/types-65aFqB5L.d.ts +62 -0
  113. package/dist/use-case-decorator-DzPSPSv5.d.ts +52 -0
  114. package/dist/use-case-decorator-GmDeYViz.js +118 -0
  115. package/dist/use-case-decorator-GmDeYViz.js.map +1 -0
  116. package/dist/user.drizzle-9kkstnkV.d.ts +12 -0
  117. package/dist/user.drizzle-CgKIqqb3.js +57 -0
  118. package/dist/user.drizzle-CgKIqqb3.js.map +1 -0
  119. package/dist/user.module-BEpCbKsU.js +17 -0
  120. package/dist/user.module-BEpCbKsU.js.map +1 -0
  121. package/dist/user.module-D3lVJ98T.d.ts +15 -0
  122. package/dist/with-caching-BniS1aZd.d.ts +39 -0
  123. package/dist/with-caching-NmBxu7vJ.js +37 -0
  124. package/dist/with-caching-NmBxu7vJ.js.map +1 -0
  125. package/dist/with-rate-limit-Cp2V1RHn.js +48 -0
  126. package/dist/with-rate-limit-Cp2V1RHn.js.map +1 -0
  127. package/dist/with-rate-limit-DK4ZF-Qg.d.ts +45 -0
  128. package/dist/with-retry-B9-hUj7I.d.ts +40 -0
  129. package/dist/with-retry-coyYPiX1.js +49 -0
  130. package/dist/with-retry-coyYPiX1.js.map +1 -0
  131. package/package.json +4 -4
@@ -0,0 +1,23 @@
1
+ //#region src/decorators/apply-decorators.d.ts
2
+ /**
3
+ * Helper to apply decorators to use cases in module registration
4
+ * Reduces boilerplate in feature modules
5
+ *
6
+ * Usage:
7
+ * ```
8
+ * getUserProfile: asFunction(({ userRepository, ...deps }) =>
9
+ * applyDecorators(
10
+ * makeGetUserProfile({ userRepository }),
11
+ * deps,
12
+ * 'getUserProfile'
13
+ * )
14
+ * ).scoped(),
15
+ * ```
16
+ */
17
+ declare const applyDecorators: <T extends (...args: any[]) => Promise<any>>(useCase: T, deps: {
18
+ logger: any;
19
+ requestId?: string;
20
+ }, featureName: string) => T;
21
+ //#endregion
22
+ export { applyDecorators as t };
23
+ //# sourceMappingURL=apply-decorators-CW23qWy7.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { t as decorateUseCase } from "./use-case-decorator-GmDeYViz.js";
2
+
3
+ //#region src/decorators/apply-decorators.ts
4
+ /**
5
+ * Helper to apply decorators to use cases in module registration
6
+ * Reduces boilerplate in feature modules
7
+ *
8
+ * Usage:
9
+ * ```
10
+ * getUserProfile: asFunction(({ userRepository, ...deps }) =>
11
+ * applyDecorators(
12
+ * makeGetUserProfile({ userRepository }),
13
+ * deps,
14
+ * 'getUserProfile'
15
+ * )
16
+ * ).scoped(),
17
+ * ```
18
+ */
19
+ const applyDecorators = (useCase, deps, featureName) => {
20
+ return decorateUseCase(useCase, {
21
+ logger: deps.logger,
22
+ requestId: deps.requestId,
23
+ feature: featureName
24
+ }, featureName);
25
+ };
26
+
27
+ //#endregion
28
+ export { applyDecorators as t };
29
+ //# sourceMappingURL=apply-decorators-CaHIAL5X.js.map
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
1
+ import { t as InMemoryCacheStore } from "../in-memory-cache-store-BaRxM--K.js";
2
+ export { InMemoryCacheStore };
@@ -0,0 +1,3 @@
1
+ import { t as InMemoryCacheStore } from "../in-memory-cache-store-oClww-8m.js";
2
+
3
+ export { InMemoryCacheStore };
@@ -0,0 +1,3 @@
1
+ import { t as InMemoryCacheStore } from "../in-memory-cache-store-BaRxM--K.js";
2
+ import { t as CacheStore } from "../index-C6nYd7xV.js";
3
+ export { CacheStore, InMemoryCacheStore };
@@ -0,0 +1,4 @@
1
+ import { t as InMemoryCacheStore } from "../in-memory-cache-store-oClww-8m.js";
2
+ import "../cache-BjdZ-Ye4.js";
3
+
4
+ export { InMemoryCacheStore };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,17 @@
1
+ import { n as Cradle } from "./types-65aFqB5L.js";
2
+ import { AwilixContainer } from "awilix";
3
+
4
+ //#region src/modules/core.module.d.ts
5
+
6
+ /**
7
+ * Core module: singleton registrations for infrastructure
8
+ * - Database pool and connection
9
+ * - Clock
10
+ * - Logger (structured, Loki/Prometheus compatible)
11
+ * - AI provider
12
+ * - Auth
13
+ */
14
+ declare const registerCoreModule: (container: AwilixContainer<Cradle>) => void;
15
+ //#endregion
16
+ export { registerCoreModule as t };
17
+ //# sourceMappingURL=core.module-B1TdC0yX.d.ts.map
@@ -0,0 +1,48 @@
1
+ import { n as createDbPool, t as createDb } from "./db-C4IcCT04.js";
2
+ import { n as makeStructuredLogger } from "./structured-logger-BsxDI9zX.js";
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-oClww-8m.js";
7
+ import { t as InMemoryRateLimiterStore } from "./in-memory-rate-limiter-BDSHZXxf.js";
8
+ import { asClass, asFunction, asValue } from "awilix";
9
+ import { SystemClock } from "@kuckit/domain/ports/clock";
10
+ import { google } from "@ai-sdk/google";
11
+ import { auth } from "@kuckit/auth";
12
+
13
+ //#region src/modules/core.module.ts
14
+ /**
15
+ * Core module: singleton registrations for infrastructure
16
+ * - Database pool and connection
17
+ * - Clock
18
+ * - Logger (structured, Loki/Prometheus compatible)
19
+ * - AI provider
20
+ * - Auth
21
+ */
22
+ const registerCoreModule = (container) => {
23
+ container.register({
24
+ dbPool: asFunction(({ config }) => createDbPool(config.databaseUrl)).singleton(),
25
+ db: asFunction(({ dbPool }) => createDb(dbPool)).singleton(),
26
+ clock: asValue(new SystemClock()),
27
+ logger: asFunction(({ config }) => makeStructuredLogger({
28
+ enableFile: config.enableFileLogging,
29
+ logDir: config.logDir,
30
+ minLevel: config.logLevel
31
+ })).singleton(),
32
+ errorHandler: asFunction(({ logger }) => makeErrorHandler(logger)).singleton(),
33
+ auth: asValue(auth),
34
+ aiProvider: asFunction(() => google("gemini-2.5-flash")).singleton(),
35
+ eventBus: asFunction(({ logger }) => new InMemoryEventBus(logger)).singleton(),
36
+ cacheStore: asClass(InMemoryCacheStore).singleton(),
37
+ rateLimiterStore: asClass(InMemoryRateLimiterStore).singleton(),
38
+ requestLogger: asFunction(({ logger, requestId, session }) => makeRequestLogger({
39
+ requestId,
40
+ userId: session?.user?.id,
41
+ baseLogger: logger
42
+ })).scoped()
43
+ });
44
+ };
45
+
46
+ //#endregion
47
+ export { registerCoreModule as t };
48
+ //# sourceMappingURL=core.module-DMtIkTcz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.module-DMtIkTcz.js","names":[],"sources":["../src/modules/core.module.ts"],"sourcesContent":["import { asClass, asFunction, asValue, type AwilixContainer } from 'awilix'\nimport { SystemClock } from '@kuckit/domain/ports/clock'\nimport { google } from '@ai-sdk/google'\nimport { auth } from '@kuckit/auth'\nimport { createDbPool, createDb } from '../db/drizzle/db'\nimport { makeStructuredLogger, makeRequestLogger } 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 any,\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: asValue(auth),\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\n\t\tcacheStore: asClass(InMemoryCacheStore).singleton(),\n\n\t\t// Rate limiter store\n\t\trateLimiterStore: asClass(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,QAAQ,KAAK;EAEnB,YAAY,iBAAiB,OAAO,mBAAmB,CAAC,CAAC,WAAW;EAGpE,UAAU,YAAY,EAAE,aAAa,IAAI,iBAAiB,OAAO,CAAC,CAAC,WAAW;EAG9E,YAAY,QAAQ,mBAAmB,CAAC,WAAW;EAGnD,kBAAkB,QAAQ,yBAAyB,CAAC,WAAW;EAG/D,eAAe,YAAY,EAAE,QAAQ,WAAW,cAC/C,kBAAkB;GACjB;GACA,QAAQ,SAAS,MAAM;GACvB,YAAY;GACZ,CAAC,CACF,CAAC,QAAQ;EACV,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { n as createDbPool, t as createDb } from "../../db-tAPHBDyL.js";
2
+ export { createDb, createDbPool };
@@ -0,0 +1,3 @@
1
+ import { n as createDbPool, t as createDb } from "../../db-C4IcCT04.js";
2
+
3
+ export { createDb, createDbPool };
@@ -0,0 +1,3 @@
1
+ import { t as makeDrizzleUserRepository } from "../../../user.drizzle-9kkstnkV.js";
2
+ import "../../../index-B5F3AfVc.js";
3
+ export { makeDrizzleUserRepository };
@@ -0,0 +1,4 @@
1
+ import { t as makeDrizzleUserRepository } from "../../../user.drizzle-CgKIqqb3.js";
2
+ import "../../../repositories-nTfSJyvW.js";
3
+
4
+ export { makeDrizzleUserRepository };
@@ -0,0 +1,2 @@
1
+ import { t as makeDrizzleUserRepository } from "../../../user.drizzle-9kkstnkV.js";
2
+ export { makeDrizzleUserRepository };
@@ -0,0 +1,3 @@
1
+ import { t as makeDrizzleUserRepository } from "../../../user.drizzle-CgKIqqb3.js";
2
+
3
+ export { makeDrizzleUserRepository };
@@ -0,0 +1,2 @@
1
+ import { n as runInTransaction, t as TransactionFn } from "../transaction-akuz5Fch.js";
2
+ export { TransactionFn, runInTransaction };
@@ -0,0 +1,4 @@
1
+ import "../user.drizzle-CgKIqqb3.js";
2
+ import { t as runInTransaction } from "../transaction-r4Sy3eC-.js";
3
+
4
+ export { runInTransaction };
@@ -0,0 +1,25 @@
1
+ import { drizzle } from "drizzle-orm/node-postgres";
2
+ import { Pool } from "pg";
3
+
4
+ //#region src/db/drizzle/db.ts
5
+ /**
6
+ * Create database connection pool
7
+ */
8
+ const createDbPool = (connectionString) => {
9
+ return new Pool({
10
+ connectionString,
11
+ max: 20,
12
+ idleTimeoutMillis: 3e4,
13
+ connectionTimeoutMillis: 2e3
14
+ });
15
+ };
16
+ /**
17
+ * Create Drizzle instance from pool
18
+ */
19
+ const createDb = (pool) => {
20
+ return drizzle(pool);
21
+ };
22
+
23
+ //#endregion
24
+ export { createDbPool as n, createDb as t };
25
+ //# sourceMappingURL=db-C4IcCT04.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-C4IcCT04.js","names":[],"sources":["../src/db/drizzle/db.ts"],"sourcesContent":["import { drizzle } from 'drizzle-orm/node-postgres'\nimport { Pool } from 'pg'\n\n/**\n * Create database connection pool\n */\nexport const createDbPool = (connectionString: string): Pool => {\n\treturn new Pool({\n\t\tconnectionString,\n\t\tmax: 20,\n\t\tidleTimeoutMillis: 30000,\n\t\tconnectionTimeoutMillis: 2000,\n\t})\n}\n\n/**\n * Create Drizzle instance from pool\n */\nexport const createDb = (pool: Pool) => {\n\treturn drizzle(pool)\n}\n"],"mappings":";;;;;;;AAMA,MAAa,gBAAgB,qBAAmC;AAC/D,QAAO,IAAI,KAAK;EACf;EACA,KAAK;EACL,mBAAmB;EACnB,yBAAyB;EACzB,CAAC;;;;;AAMH,MAAa,YAAY,SAAe;AACvC,QAAO,QAAQ,KAAK"}
@@ -0,0 +1,17 @@
1
+ import * as drizzle_orm_node_postgres0 from "drizzle-orm/node-postgres";
2
+ import { Pool } from "pg";
3
+
4
+ //#region src/db/drizzle/db.d.ts
5
+ /**
6
+ * Create database connection pool
7
+ */
8
+ declare const createDbPool: (connectionString: string) => Pool;
9
+ /**
10
+ * Create Drizzle instance from pool
11
+ */
12
+ declare const createDb: (pool: Pool) => drizzle_orm_node_postgres0.NodePgDatabase<Record<string, never>> & {
13
+ $client: Pool;
14
+ };
15
+ //#endregion
16
+ export { createDbPool as n, createDb as t };
17
+ //# sourceMappingURL=db-tAPHBDyL.d.ts.map
@@ -0,0 +1,2 @@
1
+ import { t as applyDecorators } from "../apply-decorators-CW23qWy7.js";
2
+ export { applyDecorators };
@@ -0,0 +1,5 @@
1
+ import "../errors-BB_jeye8.js";
2
+ import "../use-case-decorator-GmDeYViz.js";
3
+ import { t as applyDecorators } from "../apply-decorators-CaHIAL5X.js";
4
+
5
+ export { applyDecorators };
@@ -0,0 +1,8 @@
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";
8
+ export { DecoratorContext, PerformanceMetrics, RateLimitError, UseCase, WithCachingOptions, WithRateLimitOptions, WithRetryOptions, applyDecorators, decorateUseCase, makeDecoratedUseCase, withCaching, withErrorHandling, withPerformanceMonitoring, withRateLimit, withRequestTracing, withRetry };
@@ -0,0 +1,9 @@
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";
8
+
9
+ export { RateLimitError, applyDecorators, decorateUseCase, makeDecoratedUseCase, withCaching, withErrorHandling, withPerformanceMonitoring, withRateLimit, withRequestTracing, withRetry };
@@ -0,0 +1,3 @@
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";
3
+ export { DecoratorContext, PerformanceMetrics, UseCase, decorateUseCase, makeDecoratedUseCase, withErrorHandling, withPerformanceMonitoring, withRequestTracing };
@@ -0,0 +1,4 @@
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
+
4
+ export { decorateUseCase, makeDecoratedUseCase, withErrorHandling, withPerformanceMonitoring, withRequestTracing };
@@ -0,0 +1,2 @@
1
+ import { n as withCaching, t as WithCachingOptions } from "../with-caching-BniS1aZd.js";
2
+ export { WithCachingOptions, withCaching };
@@ -0,0 +1,3 @@
1
+ import { t as withCaching } from "../with-caching-NmBxu7vJ.js";
2
+
3
+ export { withCaching };
@@ -0,0 +1,2 @@
1
+ import { n as WithRateLimitOptions, r as withRateLimit, t as RateLimitError } from "../with-rate-limit-DK4ZF-Qg.js";
2
+ export { RateLimitError, WithRateLimitOptions, withRateLimit };
@@ -0,0 +1,3 @@
1
+ import { n as withRateLimit, t as RateLimitError } from "../with-rate-limit-Cp2V1RHn.js";
2
+
3
+ export { RateLimitError, withRateLimit };
@@ -0,0 +1,2 @@
1
+ import { n as withRetry, t as WithRetryOptions } from "../with-retry-B9-hUj7I.js";
2
+ export { WithRetryOptions, withRetry };
@@ -0,0 +1,3 @@
1
+ import { t as withRetry } from "../with-retry-coyYPiX1.js";
2
+
3
+ export { withRetry };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,47 @@
1
+ import { n as Logger } from "./logger-Bl10drB8.js";
2
+
3
+ //#region src/errors/error-handler.d.ts
4
+
5
+ /**
6
+ * Serialized error for API responses
7
+ */
8
+ interface SerializedError {
9
+ code: string;
10
+ message: string;
11
+ statusCode: number;
12
+ meta?: Record<string, any>;
13
+ }
14
+ /**
15
+ * Error handler for structured error logging and serialization
16
+ */
17
+ declare class ErrorHandler {
18
+ private logger;
19
+ constructor(logger: Logger);
20
+ /**
21
+ * Handle error and serialize for API response
22
+ */
23
+ handle(error: unknown, context?: Record<string, any>): SerializedError;
24
+ /**
25
+ * Normalize any error to AppError
26
+ */
27
+ private normalize;
28
+ /**
29
+ * Log error with appropriate level
30
+ */
31
+ private log;
32
+ /**
33
+ * Serialize error for API response
34
+ */
35
+ private serialize;
36
+ /**
37
+ * Create error handler factory
38
+ */
39
+ static create(logger: Logger): ErrorHandler;
40
+ }
41
+ /**
42
+ * Factory for error handler
43
+ */
44
+ declare const makeErrorHandler: (logger: Logger) => ErrorHandler;
45
+ //#endregion
46
+ export { SerializedError as n, makeErrorHandler as r, ErrorHandler as t };
47
+ //# sourceMappingURL=error-handler-BDid7SIZ.d.ts.map
@@ -0,0 +1,80 @@
1
+ import { t as AppError } from "./errors-BB_jeye8.js";
2
+
3
+ //#region src/errors/error-handler.ts
4
+ /**
5
+ * Error handler for structured error logging and serialization
6
+ */
7
+ var ErrorHandler = class ErrorHandler {
8
+ constructor(logger) {
9
+ this.logger = logger;
10
+ }
11
+ /**
12
+ * Handle error and serialize for API response
13
+ */
14
+ handle(error, context) {
15
+ const appError = this.normalize(error);
16
+ this.log(appError, context);
17
+ return this.serialize(appError);
18
+ }
19
+ /**
20
+ * Normalize any error to AppError
21
+ */
22
+ normalize(error) {
23
+ if (error instanceof AppError) return error;
24
+ if (error instanceof Error) return new AppError("INTERNAL_SERVER_ERROR", error.message, {
25
+ statusCode: 500,
26
+ meta: { originalError: error.name }
27
+ });
28
+ return new AppError("INTERNAL_SERVER_ERROR", "Unknown error occurred", { statusCode: 500 });
29
+ }
30
+ /**
31
+ * Log error with appropriate level
32
+ */
33
+ log(error, context) {
34
+ const logContext = {
35
+ code: error.code,
36
+ severity: error.severity,
37
+ stack: error.stack,
38
+ ...context
39
+ };
40
+ switch (error.severity) {
41
+ case "LOW":
42
+ this.logger.debug(error.message, logContext);
43
+ break;
44
+ case "MEDIUM":
45
+ this.logger.warn(error.message, logContext);
46
+ break;
47
+ case "HIGH":
48
+ case "CRITICAL":
49
+ this.logger.error(error.message, logContext);
50
+ break;
51
+ }
52
+ }
53
+ /**
54
+ * Serialize error for API response
55
+ */
56
+ serialize(error) {
57
+ return {
58
+ code: error.code,
59
+ message: error.message,
60
+ statusCode: error.statusCode,
61
+ ...Object.keys(error.meta).length > 0 && { meta: error.meta }
62
+ };
63
+ }
64
+ /**
65
+ * Create error handler factory
66
+ */
67
+ static create(logger) {
68
+ return new ErrorHandler(logger);
69
+ }
70
+ };
71
+ /**
72
+ * Factory for error handler
73
+ */
74
+ const makeErrorHandler = (logger) => {
75
+ return ErrorHandler.create(logger);
76
+ };
77
+
78
+ //#endregion
79
+ export { makeErrorHandler as n, ErrorHandler as t };
80
+ //# sourceMappingURL=error-handler-D4s_TTI1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler-D4s_TTI1.js","names":["logger: Logger"],"sources":["../src/errors/error-handler.ts"],"sourcesContent":["import type { Logger } from '../../../domain/src/ports/logger'\nimport { AppError } from '../../../domain/src/errors'\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, any>\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, any>): 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('INTERNAL_SERVER_ERROR' as any, error.message, {\n\t\t\t\tstatusCode: 500,\n\t\t\t\tmeta: { originalError: error.name },\n\t\t\t})\n\t\t}\n\n\t\treturn new AppError('INTERNAL_SERVER_ERROR' as any, 'Unknown error occurred', {\n\t\t\tstatusCode: 500,\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, any>): 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 * 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,SAAgD;EACtE,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,yBAAgC,MAAM,SAAS;GAClE,YAAY;GACZ,MAAM,EAAE,eAAe,MAAM,MAAM;GACnC,CAAC;AAGH,SAAO,IAAI,SAAS,yBAAgC,0BAA0B,EAC7E,YAAY,KACZ,CAAC;;;;;CAMH,AAAQ,IAAI,OAAiB,SAAqC;EACjE,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,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"}
@@ -0,0 +1,3 @@
1
+ import "../logger-Bl10drB8.js";
2
+ import { n as SerializedError, r as makeErrorHandler, t as ErrorHandler } from "../error-handler-BDid7SIZ.js";
3
+ export { ErrorHandler, SerializedError, makeErrorHandler };
@@ -0,0 +1,4 @@
1
+ import "../errors-BB_jeye8.js";
2
+ import { n as makeErrorHandler, t as ErrorHandler } from "../error-handler-D4s_TTI1.js";
3
+
4
+ export { ErrorHandler, makeErrorHandler };
@@ -0,0 +1,4 @@
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";
4
+ export { ErrorHandler, SerializedError, makeErrorHandler };
@@ -0,0 +1,5 @@
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";
4
+
5
+ export { ErrorHandler, makeErrorHandler };
@@ -0,0 +1,43 @@
1
+ //#region ../domain/src/errors/index.ts
2
+ /**
3
+ * Severity levels for error classification
4
+ */
5
+ let ErrorSeverity = /* @__PURE__ */ function(ErrorSeverity$1) {
6
+ ErrorSeverity$1["LOW"] = "LOW";
7
+ ErrorSeverity$1["MEDIUM"] = "MEDIUM";
8
+ ErrorSeverity$1["HIGH"] = "HIGH";
9
+ ErrorSeverity$1["CRITICAL"] = "CRITICAL";
10
+ return ErrorSeverity$1;
11
+ }({});
12
+ /**
13
+ * Application error base class
14
+ */
15
+ var AppError = class AppError extends Error {
16
+ code;
17
+ severity;
18
+ statusCode;
19
+ meta;
20
+ constructor(code, message, options = {}) {
21
+ super(message);
22
+ this.name = "AppError";
23
+ this.code = code;
24
+ this.severity = options.severity || ErrorSeverity.MEDIUM;
25
+ this.statusCode = options.statusCode || 500;
26
+ this.meta = options.meta || {};
27
+ Object.setPrototypeOf(this, AppError.prototype);
28
+ }
29
+ toJSON() {
30
+ return {
31
+ name: this.name,
32
+ code: this.code,
33
+ message: this.message,
34
+ severity: this.severity,
35
+ statusCode: this.statusCode,
36
+ meta: this.meta
37
+ };
38
+ }
39
+ };
40
+
41
+ //#endregion
42
+ export { AppError as t };
43
+ //# sourceMappingURL=errors-BB_jeye8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-BB_jeye8.js","names":[],"sources":["../../domain/src/errors/index.ts"],"sourcesContent":["/**\n * Application error codes (domain-level)\n */\nexport enum ErrorCode {\n\t// User errors\n\tUSER_NOT_FOUND = 'USER_NOT_FOUND',\n\tUSER_ALREADY_EXISTS = 'USER_ALREADY_EXISTS',\n\tINVALID_EMAIL = 'INVALID_EMAIL',\n\n\t// Auth errors\n\tUNAUTHORIZED = 'UNAUTHORIZED',\n\tFORBIDDEN = 'FORBIDDEN',\n\tSESSION_EXPIRED = 'SESSION_EXPIRED',\n\n\t// Validation errors\n\tINVALID_INPUT = 'INVALID_INPUT',\n\tVALIDATION_ERROR = 'VALIDATION_ERROR',\n\n\t// Rate limiting\n\tRATE_LIMITED = 'RATE_LIMITED',\n\n\t// Generic errors\n\tNOT_FOUND = 'NOT_FOUND',\n\tCONFLICT = 'CONFLICT',\n\tINTERNAL_SERVER_ERROR = 'INTERNAL_SERVER_ERROR',\n}\n\n/**\n * Severity levels for error classification\n */\nexport enum ErrorSeverity {\n\tLOW = 'LOW', // Client error, expected\n\tMEDIUM = 'MEDIUM', // Unexpected but recoverable\n\tHIGH = 'HIGH', // System error, requires attention\n\tCRITICAL = 'CRITICAL', // Complete system failure\n}\n\n/**\n * Application error base class\n */\nexport class AppError extends Error {\n\tpublic readonly code: ErrorCode\n\tpublic readonly severity: ErrorSeverity\n\tpublic readonly statusCode: number\n\tpublic readonly meta: Record<string, any>\n\n\tconstructor(\n\t\tcode: ErrorCode,\n\t\tmessage: string,\n\t\toptions: {\n\t\t\tstatusCode?: number\n\t\t\tseverity?: ErrorSeverity\n\t\t\tmeta?: Record<string, any>\n\t\t} = {}\n\t) {\n\t\tsuper(message)\n\t\tthis.name = 'AppError'\n\t\tthis.code = code\n\t\tthis.severity = options.severity || ErrorSeverity.MEDIUM\n\t\tthis.statusCode = options.statusCode || 500\n\t\tthis.meta = options.meta || {}\n\n\t\tObject.setPrototypeOf(this, AppError.prototype)\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\tseverity: this.severity,\n\t\t\tstatusCode: this.statusCode,\n\t\t\tmeta: this.meta,\n\t\t}\n\t}\n}\n\n/**\n * Helper functions to create specific errors\n */\n\nexport const notFound = (resource: string, meta?: Record<string, any>) =>\n\tnew AppError(ErrorCode.NOT_FOUND, `${resource} not found`, {\n\t\tstatusCode: 404,\n\t\tseverity: ErrorSeverity.LOW,\n\t\tmeta,\n\t})\n\nexport const unauthorized = (reason: string, meta?: Record<string, any>) =>\n\tnew AppError(ErrorCode.UNAUTHORIZED, reason, {\n\t\tstatusCode: 401,\n\t\tseverity: ErrorSeverity.LOW,\n\t\tmeta,\n\t})\n\nexport const forbidden = (reason: string, meta?: Record<string, any>) =>\n\tnew AppError(ErrorCode.FORBIDDEN, reason, {\n\t\tstatusCode: 403,\n\t\tseverity: ErrorSeverity.LOW,\n\t\tmeta,\n\t})\n\nexport const validationError = (message: string, meta?: Record<string, any>) =>\n\tnew AppError(ErrorCode.VALIDATION_ERROR, message, {\n\t\tstatusCode: 400,\n\t\tseverity: ErrorSeverity.LOW,\n\t\tmeta,\n\t})\n\nexport const conflict = (message: string, meta?: Record<string, any>) =>\n\tnew AppError(ErrorCode.CONFLICT, message, {\n\t\tstatusCode: 409,\n\t\tseverity: ErrorSeverity.LOW,\n\t\tmeta,\n\t})\n\nexport const internalError = (message: string, meta?: Record<string, any>) =>\n\tnew AppError(ErrorCode.INTERNAL_SERVER_ERROR, message, {\n\t\tstatusCode: 500,\n\t\tseverity: ErrorSeverity.HIGH,\n\t\tmeta,\n\t})\n"],"mappings":";;;;AA8BA,IAAY,0DAAL;AACN;AACA;AACA;AACA;;;;;;AAMD,IAAa,WAAb,MAAa,iBAAiB,MAAM;CACnC,AAAgB;CAChB,AAAgB;CAChB,AAAgB;CAChB,AAAgB;CAEhB,YACC,MACA,SACA,UAII,EAAE,EACL;AACD,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,WAAW,QAAQ,YAAY,cAAc;AAClD,OAAK,aAAa,QAAQ,cAAc;AACxC,OAAK,OAAO,QAAQ,QAAQ,EAAE;AAE9B,SAAO,eAAe,MAAM,SAAS,UAAU;;CAGhD,SAAS;AACR,SAAO;GACN,MAAM,KAAK;GACX,MAAM,KAAK;GACX,SAAS,KAAK;GACd,UAAU,KAAK;GACf,YAAY,KAAK;GACjB,MAAM,KAAK;GACX"}
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,46 @@
1
+ import { randomUUID } from "crypto";
2
+
3
+ //#region src/events/event-publisher-adapter.ts
4
+ /**
5
+ * Adapter that implements EventPublisher port using EventBus
6
+ * Converts the simplified EventPublisher interface to full EventBus types
7
+ */
8
+ const makeEventPublisherAdapter = (eventBus, logger) => {
9
+ return {
10
+ async publish(eventName, payload, aggregateId) {
11
+ const event = {
12
+ name: eventName,
13
+ payload,
14
+ meta: {
15
+ eventId: randomUUID(),
16
+ occurredAt: /* @__PURE__ */ new Date(),
17
+ version: 1,
18
+ aggregateId,
19
+ correlationId: randomUUID()
20
+ }
21
+ };
22
+ logger.debug("Publishing event", {
23
+ eventName,
24
+ eventId: event.meta.eventId,
25
+ aggregateId
26
+ });
27
+ await eventBus.publish(event);
28
+ },
29
+ subscribe(eventName, handler) {
30
+ return eventBus.subscribe(eventName, async (event) => {
31
+ try {
32
+ await handler(event.payload);
33
+ } catch (error) {
34
+ logger.error("Error in event handler", {
35
+ eventName,
36
+ error: error instanceof Error ? error.message : "Unknown error"
37
+ });
38
+ }
39
+ });
40
+ }
41
+ };
42
+ };
43
+
44
+ //#endregion
45
+ export { makeEventPublisherAdapter as t };
46
+ //# sourceMappingURL=event-publisher-adapter-B02oKEmP.js.map
@@ -0,0 +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"}
@@ -0,0 +1,12 @@
1
+ import { EventBus, EventPublisher, Logger } from "@kuckit/domain";
2
+
3
+ //#region src/events/event-publisher-adapter.d.ts
4
+
5
+ /**
6
+ * Adapter that implements EventPublisher port using EventBus
7
+ * Converts the simplified EventPublisher interface to full EventBus types
8
+ */
9
+ declare const makeEventPublisherAdapter: (eventBus: EventBus, logger: Logger) => EventPublisher;
10
+ //#endregion
11
+ export { makeEventPublisherAdapter as t };
12
+ //# sourceMappingURL=event-publisher-adapter-CpxK0OJ3.d.ts.map
@@ -0,0 +1,2 @@
1
+ import { t as makeEventPublisherAdapter } from "../event-publisher-adapter-CpxK0OJ3.js";
2
+ export { makeEventPublisherAdapter };
@@ -0,0 +1,3 @@
1
+ import { t as makeEventPublisherAdapter } from "../event-publisher-adapter-B02oKEmP.js";
2
+
3
+ export { makeEventPublisherAdapter };
@@ -0,0 +1,2 @@
1
+ import { t as InMemoryEventBus } from "../in-memory-event-bus-CqIBLRze.js";
2
+ export { InMemoryEventBus };
@@ -0,0 +1,3 @@
1
+ import { t as InMemoryEventBus } from "../in-memory-event-bus-BCyPrNAE.js";
2
+
3
+ export { InMemoryEventBus };
@@ -0,0 +1,2 @@
1
+ import { t as makeInMemoryEventPublisher } from "../in-memory-event-publisher-CxOQ-hnq.js";
2
+ export { makeInMemoryEventPublisher };