@sasscore/database 0.0.1

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 (254) hide show
  1. package/README.md +281 -0
  2. package/dist/connection/index.d.ts +7 -0
  3. package/dist/connection/index.d.ts.map +1 -0
  4. package/dist/connection/index.js +7 -0
  5. package/dist/connection/index.js.map +1 -0
  6. package/dist/connection/infrastructure/connection.module.d.ts +18 -0
  7. package/dist/connection/infrastructure/connection.module.d.ts.map +1 -0
  8. package/dist/connection/infrastructure/connection.module.js +75 -0
  9. package/dist/connection/infrastructure/connection.module.js.map +1 -0
  10. package/dist/connection/infrastructure/sequelize.service.d.ts +16 -0
  11. package/dist/connection/infrastructure/sequelize.service.d.ts.map +1 -0
  12. package/dist/connection/infrastructure/sequelize.service.js +56 -0
  13. package/dist/connection/infrastructure/sequelize.service.js.map +1 -0
  14. package/dist/database.module.d.ts +25 -0
  15. package/dist/database.module.d.ts.map +1 -0
  16. package/dist/database.module.js +71 -0
  17. package/dist/database.module.js.map +1 -0
  18. package/dist/health/database-health.service.d.ts +12 -0
  19. package/dist/health/database-health.service.d.ts.map +1 -0
  20. package/dist/health/database-health.service.js +48 -0
  21. package/dist/health/database-health.service.js.map +1 -0
  22. package/dist/health/database-health.types.d.ts +8 -0
  23. package/dist/health/database-health.types.d.ts.map +1 -0
  24. package/dist/health/database-health.types.js +2 -0
  25. package/dist/health/database-health.types.js.map +1 -0
  26. package/dist/health/health.module.d.ts +3 -0
  27. package/dist/health/health.module.d.ts.map +1 -0
  28. package/dist/health/health.module.js +20 -0
  29. package/dist/health/health.module.js.map +1 -0
  30. package/dist/health/index.d.ts +12 -0
  31. package/dist/health/index.d.ts.map +1 -0
  32. package/dist/health/index.js +9 -0
  33. package/dist/health/index.js.map +1 -0
  34. package/dist/health/migration-health.service.d.ts +14 -0
  35. package/dist/health/migration-health.service.d.ts.map +1 -0
  36. package/dist/health/migration-health.service.js +43 -0
  37. package/dist/health/migration-health.service.js.map +1 -0
  38. package/dist/health/migration-health.types.d.ts +9 -0
  39. package/dist/health/migration-health.types.d.ts.map +1 -0
  40. package/dist/health/migration-health.types.js +2 -0
  41. package/dist/health/migration-health.types.js.map +1 -0
  42. package/dist/health/outbox-health.service.d.ts +14 -0
  43. package/dist/health/outbox-health.service.d.ts.map +1 -0
  44. package/dist/health/outbox-health.service.js +79 -0
  45. package/dist/health/outbox-health.service.js.map +1 -0
  46. package/dist/health/outbox-health.types.d.ts +15 -0
  47. package/dist/health/outbox-health.types.d.ts.map +1 -0
  48. package/dist/health/outbox-health.types.js +2 -0
  49. package/dist/health/outbox-health.types.js.map +1 -0
  50. package/dist/index.d.ts +26 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +24 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/migrations/20260826173000-create-outbox-events.d.ts +5 -0
  55. package/dist/migrations/20260826173000-create-outbox-events.d.ts.map +1 -0
  56. package/dist/migrations/20260826173000-create-outbox-events.js +102 -0
  57. package/dist/migrations/20260826173000-create-outbox-events.js.map +1 -0
  58. package/dist/migrations/create-migration-registry.d.ts +9 -0
  59. package/dist/migrations/create-migration-registry.d.ts.map +1 -0
  60. package/dist/migrations/create-migration-registry.js +37 -0
  61. package/dist/migrations/create-migration-registry.js.map +1 -0
  62. package/dist/migrations/index.d.ts +7 -0
  63. package/dist/migrations/index.d.ts.map +1 -0
  64. package/dist/migrations/index.js +6 -0
  65. package/dist/migrations/index.js.map +1 -0
  66. package/dist/migrations/migration-registry.d.ts +4 -0
  67. package/dist/migrations/migration-registry.d.ts.map +1 -0
  68. package/dist/migrations/migration-registry.js +4 -0
  69. package/dist/migrations/migration-registry.js.map +1 -0
  70. package/dist/migrations/migration-runner.d.ts +27 -0
  71. package/dist/migrations/migration-runner.d.ts.map +1 -0
  72. package/dist/migrations/migration-runner.js +135 -0
  73. package/dist/migrations/migration-runner.js.map +1 -0
  74. package/dist/migrations/migration.helpers.d.ts +8 -0
  75. package/dist/migrations/migration.helpers.d.ts.map +1 -0
  76. package/dist/migrations/migration.helpers.js +9 -0
  77. package/dist/migrations/migration.helpers.js.map +1 -0
  78. package/dist/migrations/migration.types.d.ts +26 -0
  79. package/dist/migrations/migration.types.d.ts.map +1 -0
  80. package/dist/migrations/migration.types.js +2 -0
  81. package/dist/migrations/migration.types.js.map +1 -0
  82. package/dist/models/base.model.d.ts +17 -0
  83. package/dist/models/base.model.d.ts.map +1 -0
  84. package/dist/models/base.model.js +56 -0
  85. package/dist/models/base.model.js.map +1 -0
  86. package/dist/models/index.d.ts +2 -0
  87. package/dist/models/index.d.ts.map +1 -0
  88. package/dist/models/index.js +2 -0
  89. package/dist/models/index.js.map +1 -0
  90. package/dist/outbox/application/outbox.processor.d.ts +20 -0
  91. package/dist/outbox/application/outbox.processor.d.ts.map +1 -0
  92. package/dist/outbox/application/outbox.processor.js +66 -0
  93. package/dist/outbox/application/outbox.processor.js.map +1 -0
  94. package/dist/outbox/application/outbox.publisher.d.ts +17 -0
  95. package/dist/outbox/application/outbox.publisher.d.ts.map +1 -0
  96. package/dist/outbox/application/outbox.publisher.js +33 -0
  97. package/dist/outbox/application/outbox.publisher.js.map +1 -0
  98. package/dist/outbox/application/ports/event-dispatcher.port.d.ts +7 -0
  99. package/dist/outbox/application/ports/event-dispatcher.port.d.ts.map +1 -0
  100. package/dist/outbox/application/ports/event-dispatcher.port.js +2 -0
  101. package/dist/outbox/application/ports/event-dispatcher.port.js.map +1 -0
  102. package/dist/outbox/domain/entities/domain-event.entity.d.ts +11 -0
  103. package/dist/outbox/domain/entities/domain-event.entity.d.ts.map +1 -0
  104. package/dist/outbox/domain/entities/domain-event.entity.js +15 -0
  105. package/dist/outbox/domain/entities/domain-event.entity.js.map +1 -0
  106. package/dist/outbox/domain/entities/outbox-event.types.d.ts +21 -0
  107. package/dist/outbox/domain/entities/outbox-event.types.d.ts.map +1 -0
  108. package/dist/outbox/domain/entities/outbox-event.types.js +2 -0
  109. package/dist/outbox/domain/entities/outbox-event.types.js.map +1 -0
  110. package/dist/outbox/domain/index.d.ts +5 -0
  111. package/dist/outbox/domain/index.d.ts.map +1 -0
  112. package/dist/outbox/domain/index.js +3 -0
  113. package/dist/outbox/domain/index.js.map +1 -0
  114. package/dist/outbox/domain/repositories/outbox.repository.interface.d.ts +13 -0
  115. package/dist/outbox/domain/repositories/outbox.repository.interface.d.ts.map +1 -0
  116. package/dist/outbox/domain/repositories/outbox.repository.interface.js +2 -0
  117. package/dist/outbox/domain/repositories/outbox.repository.interface.js.map +1 -0
  118. package/dist/outbox/domain/value-objects/event-types.d.ts +19 -0
  119. package/dist/outbox/domain/value-objects/event-types.d.ts.map +1 -0
  120. package/dist/outbox/domain/value-objects/event-types.js +18 -0
  121. package/dist/outbox/domain/value-objects/event-types.js.map +1 -0
  122. package/dist/outbox/event-dispatcher.d.ts +3 -0
  123. package/dist/outbox/event-dispatcher.d.ts.map +1 -0
  124. package/dist/outbox/event-dispatcher.js +3 -0
  125. package/dist/outbox/event-dispatcher.js.map +1 -0
  126. package/dist/outbox/event.entity.d.ts +4 -0
  127. package/dist/outbox/event.entity.d.ts.map +1 -0
  128. package/dist/outbox/event.entity.js +3 -0
  129. package/dist/outbox/event.entity.js.map +1 -0
  130. package/dist/outbox/index.d.ts +19 -0
  131. package/dist/outbox/index.d.ts.map +1 -0
  132. package/dist/outbox/index.js +17 -0
  133. package/dist/outbox/index.js.map +1 -0
  134. package/dist/outbox/infrastructure/dispatch/event-dispatcher.d.ts +21 -0
  135. package/dist/outbox/infrastructure/dispatch/event-dispatcher.d.ts.map +1 -0
  136. package/dist/outbox/infrastructure/dispatch/event-dispatcher.js +55 -0
  137. package/dist/outbox/infrastructure/dispatch/event-dispatcher.js.map +1 -0
  138. package/dist/outbox/infrastructure/dispatch/flat-handler.registry.d.ts +13 -0
  139. package/dist/outbox/infrastructure/dispatch/flat-handler.registry.d.ts.map +1 -0
  140. package/dist/outbox/infrastructure/dispatch/flat-handler.registry.js +46 -0
  141. package/dist/outbox/infrastructure/dispatch/flat-handler.registry.js.map +1 -0
  142. package/dist/outbox/infrastructure/outbox.module.d.ts +13 -0
  143. package/dist/outbox/infrastructure/outbox.module.d.ts.map +1 -0
  144. package/dist/outbox/infrastructure/outbox.module.js +53 -0
  145. package/dist/outbox/infrastructure/outbox.module.js.map +1 -0
  146. package/dist/outbox/infrastructure/persistence/outbox-event.model.d.ts +106 -0
  147. package/dist/outbox/infrastructure/persistence/outbox-event.model.d.ts.map +1 -0
  148. package/dist/outbox/infrastructure/persistence/outbox-event.model.js +186 -0
  149. package/dist/outbox/infrastructure/persistence/outbox-event.model.js.map +1 -0
  150. package/dist/outbox/infrastructure/persistence/outbox-persistence.module.d.ts +9 -0
  151. package/dist/outbox/infrastructure/persistence/outbox-persistence.module.d.ts.map +1 -0
  152. package/dist/outbox/infrastructure/persistence/outbox-persistence.module.js +25 -0
  153. package/dist/outbox/infrastructure/persistence/outbox-persistence.module.js.map +1 -0
  154. package/dist/outbox/infrastructure/persistence/sequelize-outbox.repository.d.ts +24 -0
  155. package/dist/outbox/infrastructure/persistence/sequelize-outbox.repository.d.ts.map +1 -0
  156. package/dist/outbox/infrastructure/persistence/sequelize-outbox.repository.js +191 -0
  157. package/dist/outbox/infrastructure/persistence/sequelize-outbox.repository.js.map +1 -0
  158. package/dist/outbox/outbox-flat-handler.registry.d.ts +4 -0
  159. package/dist/outbox/outbox-flat-handler.registry.d.ts.map +1 -0
  160. package/dist/outbox/outbox-flat-handler.registry.js +4 -0
  161. package/dist/outbox/outbox-flat-handler.registry.js.map +1 -0
  162. package/dist/outbox/outbox.constants.d.ts +3 -0
  163. package/dist/outbox/outbox.constants.d.ts.map +1 -0
  164. package/dist/outbox/outbox.constants.js +3 -0
  165. package/dist/outbox/outbox.constants.js.map +1 -0
  166. package/dist/outbox/outbox.module.d.ts +3 -0
  167. package/dist/outbox/outbox.module.d.ts.map +1 -0
  168. package/dist/outbox/outbox.module.js +3 -0
  169. package/dist/outbox/outbox.module.js.map +1 -0
  170. package/dist/outbox/outbox.processor.d.ts +4 -0
  171. package/dist/outbox/outbox.processor.d.ts.map +1 -0
  172. package/dist/outbox/outbox.processor.js +4 -0
  173. package/dist/outbox/outbox.processor.js.map +1 -0
  174. package/dist/outbox/outbox.publisher.d.ts +3 -0
  175. package/dist/outbox/outbox.publisher.d.ts.map +1 -0
  176. package/dist/outbox/outbox.publisher.js +3 -0
  177. package/dist/outbox/outbox.publisher.js.map +1 -0
  178. package/dist/outbox/outbox.repository.d.ts +3 -0
  179. package/dist/outbox/outbox.repository.d.ts.map +1 -0
  180. package/dist/outbox/outbox.repository.js +3 -0
  181. package/dist/outbox/outbox.repository.js.map +1 -0
  182. package/dist/providers/database.providers.d.ts +4 -0
  183. package/dist/providers/database.providers.d.ts.map +1 -0
  184. package/dist/providers/database.providers.js +25 -0
  185. package/dist/providers/database.providers.js.map +1 -0
  186. package/dist/providers/database.tokens.d.ts +43 -0
  187. package/dist/providers/database.tokens.d.ts.map +1 -0
  188. package/dist/providers/database.tokens.js +43 -0
  189. package/dist/providers/database.tokens.js.map +1 -0
  190. package/dist/providers/index.d.ts +3 -0
  191. package/dist/providers/index.d.ts.map +1 -0
  192. package/dist/providers/index.js +3 -0
  193. package/dist/providers/index.js.map +1 -0
  194. package/dist/repositories/index.d.ts +5 -0
  195. package/dist/repositories/index.d.ts.map +1 -0
  196. package/dist/repositories/index.js +4 -0
  197. package/dist/repositories/index.js.map +1 -0
  198. package/dist/repositories/main.repository.d.ts +163 -0
  199. package/dist/repositories/main.repository.d.ts.map +1 -0
  200. package/dist/repositories/main.repository.js +1120 -0
  201. package/dist/repositories/main.repository.js.map +1 -0
  202. package/dist/repositories/repository-execution-mode.enum.d.ts +11 -0
  203. package/dist/repositories/repository-execution-mode.enum.d.ts.map +1 -0
  204. package/dist/repositories/repository-execution-mode.enum.js +12 -0
  205. package/dist/repositories/repository-execution-mode.enum.js.map +1 -0
  206. package/dist/repositories/repository.types.d.ts +65 -0
  207. package/dist/repositories/repository.types.d.ts.map +1 -0
  208. package/dist/repositories/repository.types.js +2 -0
  209. package/dist/repositories/repository.types.js.map +1 -0
  210. package/dist/repositories/tenant-scope-mode.enum.d.ts +13 -0
  211. package/dist/repositories/tenant-scope-mode.enum.d.ts.map +1 -0
  212. package/dist/repositories/tenant-scope-mode.enum.js +14 -0
  213. package/dist/repositories/tenant-scope-mode.enum.js.map +1 -0
  214. package/dist/tenancy/domain/ports/tenant-context.port.d.ts +22 -0
  215. package/dist/tenancy/domain/ports/tenant-context.port.d.ts.map +1 -0
  216. package/dist/tenancy/domain/ports/tenant-context.port.js +2 -0
  217. package/dist/tenancy/domain/ports/tenant-context.port.js.map +1 -0
  218. package/dist/tenancy/index.d.ts +8 -0
  219. package/dist/tenancy/index.d.ts.map +1 -0
  220. package/dist/tenancy/index.js +7 -0
  221. package/dist/tenancy/index.js.map +1 -0
  222. package/dist/tenancy/infrastructure/cls-tenant-context.adapter.d.ts +26 -0
  223. package/dist/tenancy/infrastructure/cls-tenant-context.adapter.d.ts.map +1 -0
  224. package/dist/tenancy/infrastructure/cls-tenant-context.adapter.js +73 -0
  225. package/dist/tenancy/infrastructure/cls-tenant-context.adapter.js.map +1 -0
  226. package/dist/tenancy/infrastructure/tenant-context.module.d.ts +7 -0
  227. package/dist/tenancy/infrastructure/tenant-context.module.d.ts.map +1 -0
  228. package/dist/tenancy/infrastructure/tenant-context.module.js +32 -0
  229. package/dist/tenancy/infrastructure/tenant-context.module.js.map +1 -0
  230. package/dist/tokens.d.ts +6 -0
  231. package/dist/tokens.d.ts.map +1 -0
  232. package/dist/tokens.js +6 -0
  233. package/dist/tokens.js.map +1 -0
  234. package/dist/transaction-manager/application/transaction-manager.service.d.ts +12 -0
  235. package/dist/transaction-manager/application/transaction-manager.service.d.ts.map +1 -0
  236. package/dist/transaction-manager/application/transaction-manager.service.js +29 -0
  237. package/dist/transaction-manager/application/transaction-manager.service.js.map +1 -0
  238. package/dist/transaction-manager/domain/ports/transaction-manager.port.d.ts +9 -0
  239. package/dist/transaction-manager/domain/ports/transaction-manager.port.d.ts.map +1 -0
  240. package/dist/transaction-manager/domain/ports/transaction-manager.port.js +2 -0
  241. package/dist/transaction-manager/domain/ports/transaction-manager.port.js.map +1 -0
  242. package/dist/transaction-manager/index.d.ts +7 -0
  243. package/dist/transaction-manager/index.d.ts.map +1 -0
  244. package/dist/transaction-manager/index.js +6 -0
  245. package/dist/transaction-manager/index.js.map +1 -0
  246. package/dist/types/database-module-options.d.ts +12 -0
  247. package/dist/types/database-module-options.d.ts.map +1 -0
  248. package/dist/types/database-module-options.js +2 -0
  249. package/dist/types/database-module-options.js.map +1 -0
  250. package/dist/types/index.d.ts +2 -0
  251. package/dist/types/index.d.ts.map +1 -0
  252. package/dist/types/index.js +2 -0
  253. package/dist/types/index.js.map +1 -0
  254. package/package.json +69 -0
@@ -0,0 +1,8 @@
1
+ export type DatabaseHealthStatus = 'up' | 'down';
2
+ /** Result of {@link DatabaseHealth.check} — no HTTP concerns. */
3
+ export interface DatabaseHealthResult {
4
+ status: DatabaseHealthStatus;
5
+ latencyMs: number;
6
+ error?: string;
7
+ }
8
+ //# sourceMappingURL=database-health.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database-health.types.d.ts","sourceRoot":"","sources":["../../health/database-health.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,IAAI,GAAG,MAAM,CAAC;AAEjD,iEAAiE;AACjE,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=database-health.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database-health.types.js","sourceRoot":"","sources":["../../health/database-health.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export declare class DatabaseHealthModule {
2
+ }
3
+ //# sourceMappingURL=health.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.module.d.ts","sourceRoot":"","sources":["../../health/health.module.ts"],"names":[],"mappings":"AAIA,qBAKa,oBAAoB;CAAG"}
@@ -0,0 +1,20 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Global, Module } from '@nestjs/common';
8
+ import { DatabaseHealth } from './database-health.service.js';
9
+ import { OutboxHealth } from './outbox-health.service.js';
10
+ let DatabaseHealthModule = class DatabaseHealthModule {
11
+ };
12
+ DatabaseHealthModule = __decorate([
13
+ Global(),
14
+ Module({
15
+ providers: [DatabaseHealth, OutboxHealth],
16
+ exports: [DatabaseHealth, OutboxHealth],
17
+ })
18
+ ], DatabaseHealthModule);
19
+ export { DatabaseHealthModule };
20
+ //# sourceMappingURL=health.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.module.js","sourceRoot":"","sources":["../../health/health.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAOnD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oBAAoB;IALhC,MAAM,EAAE;IACR,MAAM,CAAC;QACN,SAAS,EAAE,CAAC,cAAc,EAAE,YAAY,CAAC;QACzC,OAAO,EAAE,CAAC,cAAc,EAAE,YAAY,CAAC;KACxC,CAAC;GACW,oBAAoB,CAAG"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @sasscore/database/health
3
+ */
4
+ export { DATABASE_TOKENS } from '../tokens.js';
5
+ export { DatabaseHealth } from './database-health.service.js';
6
+ export type { DatabaseHealthResult, DatabaseHealthStatus, } from './database-health.types.js';
7
+ export { MigrationHealth } from './migration-health.service.js';
8
+ export type { MigrationHealthResult, MigrationHealthStatus, } from './migration-health.types.js';
9
+ export { OutboxHealth } from './outbox-health.service.js';
10
+ export type { OutboxHealthOptions, OutboxHealthResult, OutboxHealthStatus, } from './outbox-health.types.js';
11
+ export { DatabaseHealthModule } from './health.module.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../health/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,YAAY,EACV,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,YAAY,EACV,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @sasscore/database/health
3
+ */
4
+ export { DATABASE_TOKENS } from '../tokens.js';
5
+ export { DatabaseHealth } from './database-health.service.js';
6
+ export { MigrationHealth } from './migration-health.service.js';
7
+ export { OutboxHealth } from './outbox-health.service.js';
8
+ export { DatabaseHealthModule } from './health.module.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../health/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAK9D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAKhE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAM1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Sequelize } from 'sequelize';
2
+ import type { MigrationDefinition } from '../migrations/migration.types.js';
3
+ import type { MigrationHealthResult } from './migration-health.types.js';
4
+ /**
5
+ * Probe migration ledger vs registered migrations.
6
+ * Host apps expose this via their own health controllers.
7
+ */
8
+ export declare class MigrationHealth {
9
+ private readonly sequelize;
10
+ private readonly migrations;
11
+ constructor(sequelize: Sequelize, migrations: MigrationDefinition[]);
12
+ check(): Promise<MigrationHealthResult>;
13
+ }
14
+ //# sourceMappingURL=migration-health.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-health.service.d.ts","sourceRoot":"","sources":["../../health/migration-health.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE;;;GAGG;AACH,qBAAa,eAAe;IAExB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,mBAAmB,EAAE;IAG9C,KAAK,IAAI,OAAO,CAAC,qBAAqB,CAAC;CA+B9C"}
@@ -0,0 +1,43 @@
1
+ import { MigrationRunner } from '../migrations/migration-runner.js';
2
+ /**
3
+ * Probe migration ledger vs registered migrations.
4
+ * Host apps expose this via their own health controllers.
5
+ */
6
+ export class MigrationHealth {
7
+ sequelize;
8
+ migrations;
9
+ constructor(sequelize, migrations) {
10
+ this.sequelize = sequelize;
11
+ this.migrations = migrations;
12
+ }
13
+ async check() {
14
+ try {
15
+ const runner = new MigrationRunner(this.sequelize, this.migrations);
16
+ const status = await runner.getStatus();
17
+ if (status.upToDate) {
18
+ return {
19
+ status: 'up-to-date',
20
+ appliedCount: status.applied.length,
21
+ pendingCount: 0,
22
+ };
23
+ }
24
+ return {
25
+ status: 'pending',
26
+ appliedCount: status.applied.length,
27
+ pendingCount: status.pending.length,
28
+ pendingNames: status.pending.map((m) => m.name),
29
+ };
30
+ }
31
+ catch (error) {
32
+ return {
33
+ status: 'unknown',
34
+ appliedCount: 0,
35
+ pendingCount: 0,
36
+ error: error instanceof Error
37
+ ? error.message
38
+ : 'Migration status check failed',
39
+ };
40
+ }
41
+ }
42
+ }
43
+ //# sourceMappingURL=migration-health.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-health.service.js","sourceRoot":"","sources":["../../health/migration-health.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAGpE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAEP;IACA;IAFnB,YACmB,SAAoB,EACpB,UAAiC;QADjC,cAAS,GAAT,SAAS,CAAW;QACpB,eAAU,GAAV,UAAU,CAAuB;IACjD,CAAC;IAEJ,KAAK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YACpE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC;YAExC,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACpB,OAAO;oBACL,MAAM,EAAE,YAAY;oBACpB,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;oBACnC,YAAY,EAAE,CAAC;iBAChB,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;gBACnC,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;gBACnC,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aAChD,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,YAAY,EAAE,CAAC;gBACf,YAAY,EAAE,CAAC;gBACf,KAAK,EACH,KAAK,YAAY,KAAK;oBACpB,CAAC,CAAC,KAAK,CAAC,OAAO;oBACf,CAAC,CAAC,+BAA+B;aACtC,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ export type MigrationHealthStatus = 'up-to-date' | 'pending' | 'unknown';
2
+ export interface MigrationHealthResult {
3
+ status: MigrationHealthStatus;
4
+ appliedCount: number;
5
+ pendingCount: number;
6
+ pendingNames?: string[];
7
+ error?: string;
8
+ }
9
+ //# sourceMappingURL=migration-health.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-health.types.d.ts","sourceRoot":"","sources":["../../health/migration-health.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;AAEzE,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=migration-health.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-health.types.js","sourceRoot":"","sources":["../../health/migration-health.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { Sequelize } from 'sequelize-typescript';
2
+ import type { OutboxHealthResult } from './outbox-health.types.js';
3
+ /**
4
+ * Probe transactional outbox backlog and failure states.
5
+ * Requires `outbox_events` table (run core migrations first).
6
+ */
7
+ export declare class OutboxHealth {
8
+ private readonly sequelize;
9
+ /** Age in seconds after which pending events count as lag. */
10
+ private readonly lagThresholdSeconds;
11
+ constructor(sequelize: Sequelize);
12
+ check(): Promise<OutboxHealthResult>;
13
+ }
14
+ //# sourceMappingURL=outbox-health.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox-health.service.d.ts","sourceRoot":"","sources":["../../health/outbox-health.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAYnE;;;GAGG;AACH,qBACa,YAAY;IAMrB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAL5B,8DAA8D;IAC9D,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAO;gBAIxB,SAAS,EAAE,SAAS;IAGjC,KAAK,IAAI,OAAO,CAAC,kBAAkB,CAAC;CAoD3C"}
@@ -0,0 +1,79 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { Inject, Injectable } from '@nestjs/common';
14
+ import { DATABASE_TOKENS } from '../providers/database.tokens.js';
15
+ /**
16
+ * Probe transactional outbox backlog and failure states.
17
+ * Requires `outbox_events` table (run core migrations first).
18
+ */
19
+ let OutboxHealth = class OutboxHealth {
20
+ sequelize;
21
+ /** Age in seconds after which pending events count as lag. */
22
+ lagThresholdSeconds = 300;
23
+ constructor(sequelize) {
24
+ this.sequelize = sequelize;
25
+ }
26
+ async check() {
27
+ try {
28
+ const [counts] = (await this.sequelize.query(`
29
+ SELECT
30
+ COUNT(*) FILTER (WHERE status = 'pending') AS pending,
31
+ COUNT(*) FILTER (WHERE status = 'failed') AS failed,
32
+ COUNT(*) FILTER (WHERE status = 'dead_letter') AS dead_letter
33
+ FROM outbox_events
34
+ `));
35
+ const row = counts?.[0] ?? {
36
+ pending: '0',
37
+ failed: '0',
38
+ dead_letter: '0',
39
+ };
40
+ const pendingCount = Number(row.pending) || 0;
41
+ const failedCount = Number(row.failed) || 0;
42
+ const deadLetterCount = Number(row.dead_letter) || 0;
43
+ let lagSeconds;
44
+ if (pendingCount > 0) {
45
+ const [lagRows] = (await this.sequelize.query(`
46
+ SELECT EXTRACT(EPOCH FROM (NOW() - MIN(created_at))) AS age_seconds
47
+ FROM outbox_events
48
+ WHERE status = 'pending'
49
+ `));
50
+ lagSeconds = Number(lagRows?.[0]?.age_seconds) || 0;
51
+ }
52
+ const lagging = pendingCount > 0 && (lagSeconds ?? 0) > this.lagThresholdSeconds;
53
+ const hasFailures = failedCount > 0 || deadLetterCount > 0;
54
+ return {
55
+ status: lagging || hasFailures ? 'degraded' : 'healthy',
56
+ pendingCount,
57
+ failedCount,
58
+ deadLetterCount,
59
+ ...(lagSeconds !== undefined ? { lagSeconds } : {}),
60
+ };
61
+ }
62
+ catch (error) {
63
+ return {
64
+ status: 'unknown',
65
+ pendingCount: 0,
66
+ failedCount: 0,
67
+ deadLetterCount: 0,
68
+ error: error instanceof Error ? error.message : 'Outbox health check failed',
69
+ };
70
+ }
71
+ }
72
+ };
73
+ OutboxHealth = __decorate([
74
+ Injectable(),
75
+ __param(0, Inject(DATABASE_TOKENS.SEQUELIZE)),
76
+ __metadata("design:paramtypes", [Function])
77
+ ], OutboxHealth);
78
+ export { OutboxHealth };
79
+ //# sourceMappingURL=outbox-health.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox-health.service.js","sourceRoot":"","sources":["../../health/outbox-health.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAalE;;;GAGG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAY;IAMJ;IALnB,8DAA8D;IAC7C,mBAAmB,GAAG,GAAG,CAAC;IAE3C,YAEmB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IACpC,CAAC;IAEJ,KAAK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;;;;;;OAM5C,CAAC,CAAgC,CAAC;YAEnC,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI;gBACzB,OAAO,EAAE,GAAG;gBACZ,MAAM,EAAE,GAAG;gBACX,WAAW,EAAE,GAAG;aACjB,CAAC;YACF,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC9C,MAAM,W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AAS,CAAC,CAAA;;GALzB,YAAY,CA6DxB"}
@@ -0,0 +1,15 @@
1
+ export type OutboxHealthStatus = 'healthy' | 'degraded' | 'unknown';
2
+ export interface OutboxHealthResult {
3
+ status: OutboxHealthStatus;
4
+ pendingCount: number;
5
+ failedCount: number;
6
+ deadLetterCount: number;
7
+ /** Pending events older than threshold (seconds). */
8
+ lagSeconds?: number;
9
+ error?: string;
10
+ }
11
+ export interface OutboxHealthOptions {
12
+ /** Age in seconds after which pending events count as lag. Default 300. */
13
+ lagThresholdSeconds?: number;
14
+ }
15
+ //# sourceMappingURL=outbox-health.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox-health.types.d.ts","sourceRoot":"","sources":["../../health/outbox-health.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAEpE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,2EAA2E;IAC3E,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=outbox-health.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbox-health.types.js","sourceRoot":"","sources":["../../health/outbox-health.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @sasscore/database — root public API
3
+ *
4
+ * Subpath imports (preferred for bounded contexts):
5
+ * @sasscore/database/connection
6
+ * @sasscore/database/tenancy
7
+ * @sasscore/database/transaction-manager
8
+ * @sasscore/database/outbox
9
+ * @sasscore/database/health
10
+ * @sasscore/database/migrations
11
+ * @sasscore/database/models
12
+ * @sasscore/database/repositories
13
+ */
14
+ export { DatabaseDomainModule, DatabaseDomainModule as DatabaseModule, } from './database.module.js';
15
+ export type { DatabaseModuleOptions } from './types/index.js';
16
+ export { DATABASE_TOKENS, OUTBOX_TOKENS, TENANCY_TOKENS, TRANSACTION_TOKENS, } from './tokens.js';
17
+ export { DatabaseConnectionModule } from './connection/index.js';
18
+ export type { ITenantContext } from './tenancy/index.js';
19
+ export { ClsTenantContextAdapter, TenantContextModule, type ClsTenantUserData, } from './tenancy/index.js';
20
+ export { type ITransactionManager, DatabaseTransactionManager, } from './transaction-manager/index.js';
21
+ export { DomainEvent, EVENT_TYPES, type EventType, type IOutboxRepository, OutboxPublisher, type OutboxPublishOptions, OutboxProcessor, type OutboxBatchResult, DatabaseOutboxModule, } from './outbox/index.js';
22
+ export { DatabaseHealth, DatabaseHealthModule, MigrationHealth, OutboxHealth, type DatabaseHealthResult, type DatabaseHealthStatus, type MigrationHealthResult, type MigrationHealthStatus, type OutboxHealthResult, type OutboxHealthStatus, } from './health/index.js';
23
+ export { type MigrationDefinition, type MigrationSource, type AppliedMigrationRecord, type MigrationRunStatus, defineCoreMigration, defineClientMigration, createMigrationRegistry, databaseMigrations, MigrationRunner, MIGRATION_ADVISORY_LOCK_KEY, SCHEMA_MIGRATIONS_TABLE, } from './migrations/index.js';
24
+ export { BaseModel, BASE_MODEL_OPTIONS } from './models/index.js';
25
+ export { MainRepository, TenantScopeMode, RepositoryExecutionMode, } from './repositories/index.js';
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,IAAI,cAAc,GACvC,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,mBAAmB,EACxB,0BAA0B,GAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,WAAW,EACX,WAAW,EACX,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,eAAe,EACf,KAAK,oBAAoB,EACzB,eAAe,EACf,KAAK,iBAAiB,EACtB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACL,cAAc,EACd,eAAe,EACf,uBAAuB,GACxB,MAAM,yBAAyB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @sasscore/database — root public API
3
+ *
4
+ * Subpath imports (preferred for bounded contexts):
5
+ * @sasscore/database/connection
6
+ * @sasscore/database/tenancy
7
+ * @sasscore/database/transaction-manager
8
+ * @sasscore/database/outbox
9
+ * @sasscore/database/health
10
+ * @sasscore/database/migrations
11
+ * @sasscore/database/models
12
+ * @sasscore/database/repositories
13
+ */
14
+ export { DatabaseDomainModule, DatabaseDomainModule as DatabaseModule, } from './database.module.js';
15
+ export { DATABASE_TOKENS, OUTBOX_TOKENS, TENANCY_TOKENS, TRANSACTION_TOKENS, } from './tokens.js';
16
+ export { DatabaseConnectionModule } from './connection/index.js';
17
+ export { ClsTenantContextAdapter, TenantContextModule, } from './tenancy/index.js';
18
+ export { DatabaseTransactionManager, } from './transaction-manager/index.js';
19
+ export { DomainEvent, EVENT_TYPES, OutboxPublisher, OutboxProcessor, DatabaseOutboxModule, } from './outbox/index.js';
20
+ export { DatabaseHealth, DatabaseHealthModule, MigrationHealth, OutboxHealth, } from './health/index.js';
21
+ export { defineCoreMigration, defineClientMigration, createMigrationRegistry, databaseMigrations, MigrationRunner, MIGRATION_ADVISORY_LOCK_KEY, SCHEMA_MIGRATIONS_TABLE, } from './migrations/index.js';
22
+ export { BaseModel, BASE_MODEL_OPTIONS } from './models/index.js';
23
+ export { MainRepository, TenantScopeMode, RepositoryExecutionMode, } from './repositories/index.js';
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,IAAI,cAAc,GACvC,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EACL,uBAAuB,EACvB,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,0BAA0B,GAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,WAAW,EACX,WAAW,EAGX,eAAe,EAEf,eAAe,EAEf,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,YAAY,GAOb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAKL,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACL,cAAc,EACd,eAAe,EACf,uBAAuB,GACxB,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Baseline outbox schema for @sasscore/database (current model, not legacy history).
3
+ */
4
+ export declare const createOutboxEvents: import("./migration.types.js").MigrationDefinition;
5
+ //# sourceMappingURL=20260826173000-create-outbox-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20260826173000-create-outbox-events.d.ts","sourceRoot":"","sources":["../../migrations/20260826173000-create-outbox-events.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,kBAAkB,oDAkH7B,CAAC"}
@@ -0,0 +1,102 @@
1
+ import { DataTypes } from 'sequelize';
2
+ import { defineCoreMigration } from './migration.helpers.js';
3
+ /**
4
+ * Baseline outbox schema for @sasscore/database (current model, not legacy history).
5
+ */
6
+ export const createOutboxEvents = defineCoreMigration({
7
+ name: '20260826173000-create-outbox-events',
8
+ async up(queryInterface, transaction) {
9
+ await queryInterface.createTable('outbox_events', {
10
+ id: {
11
+ type: DataTypes.INTEGER,
12
+ autoIncrement: true,
13
+ primaryKey: true,
14
+ allowNull: false,
15
+ },
16
+ aggregate_type: {
17
+ type: DataTypes.STRING(50),
18
+ allowNull: false,
19
+ },
20
+ aggregate_id: {
21
+ type: DataTypes.STRING(255),
22
+ allowNull: false,
23
+ },
24
+ event_type: {
25
+ type: DataTypes.STRING(100),
26
+ allowNull: false,
27
+ },
28
+ event_version: {
29
+ type: DataTypes.INTEGER,
30
+ allowNull: false,
31
+ defaultValue: 1,
32
+ },
33
+ payload: {
34
+ type: DataTypes.JSONB,
35
+ allowNull: false,
36
+ },
37
+ status: {
38
+ type: DataTypes.STRING(20),
39
+ allowNull: false,
40
+ defaultValue: 'pending',
41
+ },
42
+ retry_count: {
43
+ type: DataTypes.INTEGER,
44
+ allowNull: false,
45
+ defaultValue: 0,
46
+ },
47
+ next_retry_at: {
48
+ type: DataTypes.DATE,
49
+ allowNull: true,
50
+ },
51
+ processed_at: {
52
+ type: DataTypes.DATE,
53
+ allowNull: true,
54
+ },
55
+ processing_started_at: {
56
+ type: DataTypes.DATE,
57
+ allowNull: true,
58
+ },
59
+ correlation_id: {
60
+ type: DataTypes.UUID,
61
+ allowNull: true,
62
+ },
63
+ causation_id: {
64
+ type: DataTypes.UUID,
65
+ allowNull: true,
66
+ },
67
+ error: {
68
+ type: DataTypes.TEXT,
69
+ allowNull: true,
70
+ },
71
+ created_at: {
72
+ type: DataTypes.DATE,
73
+ allowNull: false,
74
+ defaultValue: DataTypes.NOW,
75
+ },
76
+ updated_at: {
77
+ type: DataTypes.DATE,
78
+ allowNull: false,
79
+ defaultValue: DataTypes.NOW,
80
+ },
81
+ }, { transaction });
82
+ await queryInterface.addIndex('outbox_events', ['status', 'created_at'], {
83
+ name: 'idx_outbox_status_created',
84
+ transaction,
85
+ });
86
+ await queryInterface.addIndex('outbox_events', ['status', 'next_retry_at', 'created_at'], { name: 'idx_outbox_polling', transaction });
87
+ await queryInterface.addIndex('outbox_events', ['aggregate_type', 'aggregate_id'], { name: 'idx_outbox_aggregate', transaction });
88
+ await queryInterface.addIndex('outbox_events', ['correlation_id'], {
89
+ name: 'idx_outbox_correlation',
90
+ transaction,
91
+ });
92
+ await queryInterface.sequelize.query(`
93
+ ALTER TABLE outbox_events
94
+ ADD CONSTRAINT chk_outbox_status
95
+ CHECK (status IN ('pending', 'processing', 'processed', 'failed', 'dead_letter'));
96
+ `, { transaction });
97
+ },
98
+ async down(queryInterface, transaction) {
99
+ await queryInterface.dropTable('outbox_events', { transaction });
100
+ },
101
+ });
102
+ //# sourceMappingURL=20260826173000-create-outbox-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"20260826173000-create-outbox-events.js","sourceRoot":"","sources":["../../migrations/20260826173000-create-outbox-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyC,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;IACpD,IAAI,EAAE,qCAAqC;IAE3C,KAAK,CAAC,EAAE,CAAC,cAA8B,EAAE,WAAwB;QAC/D,MAAM,cAAc,CAAC,WAAW,CAC9B,eAAe,EACf;YACE,EAAE,EAAE;gBACF,IAAI,EAAE,SAAS,CAAC,OAAO;gBACvB,aAAa,EAAE,IAAI;gBACnB,UAAU,EAAE,IAAI;gBAChB,SAAS,EAAE,KAAK;aACjB;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC1B,SAAS,EAAE,KAAK;aACjB;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;gBAC3B,SAAS,EAAE,KAAK;aACjB;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC;gBAC3B,SAAS,EAAE,KAAK;aACjB;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,SAAS,CAAC,OAAO;gBACvB,SAAS,EAAE,KAAK;gBAChB,YAAY,EAAE,CAAC;aAChB;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,SAAS,CAAC,KAAK;gBACrB,SAAS,EAAE,KAAK;aACjB;YACD,MAAM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AE,eAAe,EAAE,YAAY,CAAC,EACzC,EAAE,IAAI,EAAE,oBAAoB,EAAE,WAAW,EAAE,CAC5C,CAAC;QACF,MAAM,cAAc,CAAC,QAAQ,CAC3B,eAAe,EACf,CAAC,gBAAgB,EAAE,cAAc,CAAC,EAClC,EAAE,IAAI,EAAE,sBAAsB,EAAE,WAAW,EAAE,CAC9C,CAAC;QACF,MAAM,cAAc,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC,gBAAgB,CAAC,EAAE;YACjE,IAAI,EAAE,wBAAwB;YAC9B,WAAW;SACZ,CAAC,CAAC;QAEH,MAAM,cAAc,CAAC,SAAS,CAAC,KAAK,CAClC;;;;KAID,EACC,EAAE,WAAW,EAAE,CAChB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,cAA8B,EAAE,WAAwB;QACjE,MAAM,cAAc,CAAC,SAAS,CAAC,eAAe,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IACnE,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { MigrationDefinition, MigrationSource } from './migration.types.js';
2
+ /**
3
+ * Immutable composition of migration groups from one or more packages.
4
+ * Sorts by `name` and fails fast on duplicate migration IDs or invalid sources.
5
+ */
6
+ export declare function createMigrationRegistry(...groups: MigrationDefinition[][]): MigrationDefinition[];
7
+ /** @internal exported for tests */
8
+ export declare function assertMigrationSource(source: string): asserts source is MigrationSource;
9
+ //# sourceMappingURL=create-migration-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-migration-registry.d.ts","sourceRoot":"","sources":["../../migrations/create-migration-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIjF;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,MAAM,EAAE,mBAAmB,EAAE,EAAE,GACjC,mBAAmB,EAAE,CAiBvB;AAqBD,mCAAmC;AACnC,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,eAAe,CAIvF"}
@@ -0,0 +1,37 @@
1
+ const CORE_NAME_PATTERN = /^\d{14}-/;
2
+ /**
3
+ * Immutable composition of migration groups from one or more packages.
4
+ * Sorts by `name` and fails fast on duplicate migration IDs or invalid sources.
5
+ */
6
+ export function createMigrationRegistry(...groups) {
7
+ const flat = groups.flat();
8
+ const seen = new Set();
9
+ for (const migration of flat) {
10
+ validateMigrationDefinition(migration);
11
+ if (seen.has(migration.name)) {
12
+ throw new Error(`Duplicate migration name: "${migration.name}". ` +
13
+ 'Each MigrationDefinition.name must be globally unique across packages.');
14
+ }
15
+ seen.add(migration.name);
16
+ }
17
+ return flat.slice().sort((a, b) => a.name.localeCompare(b.name));
18
+ }
19
+ function validateMigrationDefinition(migration) {
20
+ if (!migration.name?.trim()) {
21
+ throw new Error('MigrationDefinition.name is required');
22
+ }
23
+ if (migration.source !== 'core' && migration.source !== 'client') {
24
+ throw new Error(`Migration "${migration.name}": source must be "core" or "client"`);
25
+ }
26
+ if (migration.source === 'client' && !CORE_NAME_PATTERN.test(migration.name)) {
27
+ throw new Error(`Client migration "${migration.name}" must use a timestamp prefix ` +
28
+ '(e.g. 20260901120000-create-products) to avoid colliding with Core.');
29
+ }
30
+ }
31
+ /** @internal exported for tests */
32
+ export function assertMigrationSource(source) {
33
+ if (source !== 'core' && source !== 'client') {
34
+ throw new Error(`Invalid migration source: ${source}`);
35
+ }
36
+ }
37
+ //# sourceMappingURL=create-migration-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-migration-registry.js","sourceRoot":"","sources":["../../migrations/create-migration-registry.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAErC;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,GAAG,MAA+B;IAElC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3B,MAA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,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,6BAA6B,MAAM,EAAE,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type { MigrationDefinition, MigrationSource, AppliedMigrationRecord, MigrationRunStatus, } from './migration.types.js';
2
+ export { defineCoreMigration, defineClientMigration, } from './migration.helpers.js';
3
+ export { createMigrationRegistry } from './create-migration-registry.js';
4
+ export { MigrationRunner, MIGRATION_ADVISORY_LOCK_KEY, SCHEMA_MIGRATIONS_TABLE, } from './migration-runner.js';
5
+ export { databaseMigrations } from './migration-registry.js';
6
+ export { createOutboxEvents } from './20260826173000-create-outbox-events.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../migrations/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { defineCoreMigration, defineClientMigration, } from './migration.helpers.js';
2
+ export { createMigrationRegistry } from './create-migration-registry.js';
3
+ export { MigrationRunner, MIGRATION_ADVISORY_LOCK_KEY, SCHEMA_MIGRATIONS_TABLE, } from './migration-runner.js';
4
+ export { databaseMigrations } from './migration-registry.js';
5
+ export { createOutboxEvents } from './20260826173000-create-outbox-events.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../migrations/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { MigrationDefinition } from './migration.types.js';
2
+ /** Migrations owned by `@sasscore/database` (outbox schema, …). Host composes + runs. */
3
+ export declare const databaseMigrations: MigrationDefinition[];
4
+ //# sourceMappingURL=migration-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-registry.d.ts","sourceRoot":"","sources":["../../migrations/migration-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,yFAAyF;AACzF,eAAO,MAAM,kBAAkB,EAAE,mBAAmB,EAAyB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { createOutboxEvents } from './20260826173000-create-outbox-events.js';
2
+ /** Migrations owned by `@sasscore/database` (outbox schema, …). Host composes + runs. */
3
+ export const databaseMigrations = [createOutboxEvents];
4
+ //# sourceMappingURL=migration-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-registry.js","sourceRoot":"","sources":["../../migrations/migration-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAG9E,yFAAyF;AACzF,MAAM,CAAC,MAAM,kBAAkB,GAA0B,CAAC,kBAAkB,CAAC,CAAC"}