@decaf-ts/core 0.24.0 → 0.25.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 (340) hide show
  1. package/lib/cjs/index.cjs +1 -1
  2. package/lib/esm/index.js +1 -1
  3. package/lib/types/auth/decorators.d.cts +2 -2
  4. package/lib/types/auth/decorators.d.mts +2 -2
  5. package/lib/types/auth/index.d.cts +2 -2
  6. package/lib/types/auth/index.d.mts +2 -2
  7. package/lib/types/fs/FilesystemAdapter.d.cts +5 -5
  8. package/lib/types/fs/FilesystemAdapter.d.mts +5 -5
  9. package/lib/types/fs/FsDispatch.d.cts +4 -4
  10. package/lib/types/fs/FsDispatch.d.mts +4 -4
  11. package/lib/types/fs/index.d.cts +4 -4
  12. package/lib/types/fs/index.d.mts +4 -4
  13. package/lib/types/fs/indexStore.d.cts +2 -2
  14. package/lib/types/fs/indexStore.d.mts +2 -2
  15. package/lib/types/fs/types.d.cts +2 -2
  16. package/lib/types/fs/types.d.mts +2 -2
  17. package/lib/types/identity/decorators.d.cts +3 -3
  18. package/lib/types/identity/decorators.d.mts +3 -3
  19. package/lib/types/identity/index.d.cts +1 -1
  20. package/lib/types/identity/index.d.mts +1 -1
  21. package/lib/types/index.d.cts +13 -13
  22. package/lib/types/index.d.mts +13 -13
  23. package/lib/types/interfaces/ContextuallyLogged.d.cts +2 -2
  24. package/lib/types/interfaces/ContextuallyLogged.d.mts +2 -2
  25. package/lib/types/interfaces/Observable.d.cts +1 -1
  26. package/lib/types/interfaces/Observable.d.mts +1 -1
  27. package/lib/types/interfaces/Paginatable.d.cts +1 -1
  28. package/lib/types/interfaces/Paginatable.d.mts +1 -1
  29. package/lib/types/interfaces/Queriable.d.cts +2 -2
  30. package/lib/types/interfaces/Queriable.d.mts +2 -2
  31. package/lib/types/interfaces/RawExecutor.d.cts +1 -1
  32. package/lib/types/interfaces/RawExecutor.d.mts +1 -1
  33. package/lib/types/interfaces/index.d.cts +7 -7
  34. package/lib/types/interfaces/index.d.mts +7 -7
  35. package/lib/types/migrations/Migration.d.cts +4 -4
  36. package/lib/types/migrations/Migration.d.mts +4 -4
  37. package/lib/types/migrations/MigrationService.d.cts +7 -7
  38. package/lib/types/migrations/MigrationService.d.mts +7 -7
  39. package/lib/types/migrations/MigrationTaskBuilder.d.cts +3 -3
  40. package/lib/types/migrations/MigrationTaskBuilder.d.mts +3 -3
  41. package/lib/types/migrations/MigrationTasks.d.cts +2 -2
  42. package/lib/types/migrations/MigrationTasks.d.mts +2 -2
  43. package/lib/types/migrations/SemverMigrationVersioning.d.cts +1 -1
  44. package/lib/types/migrations/SemverMigrationVersioning.d.mts +1 -1
  45. package/lib/types/migrations/StandardMigrationVersioning.d.cts +1 -1
  46. package/lib/types/migrations/StandardMigrationVersioning.d.mts +1 -1
  47. package/lib/types/migrations/constants.d.cts +1 -1
  48. package/lib/types/migrations/constants.d.mts +1 -1
  49. package/lib/types/migrations/decorators.d.cts +1 -1
  50. package/lib/types/migrations/decorators.d.mts +1 -1
  51. package/lib/types/migrations/index.d.cts +9 -9
  52. package/lib/types/migrations/index.d.mts +9 -9
  53. package/lib/types/migrations/types.d.cts +5 -5
  54. package/lib/types/migrations/types.d.mts +5 -5
  55. package/lib/types/model/SequenceModel.d.cts +1 -1
  56. package/lib/types/model/SequenceModel.d.mts +1 -1
  57. package/lib/types/model/construction.d.cts +4 -4
  58. package/lib/types/model/construction.d.mts +4 -4
  59. package/lib/types/model/decorators.d.cts +4 -4
  60. package/lib/types/model/decorators.d.mts +4 -4
  61. package/lib/types/model/index.d.cts +6 -6
  62. package/lib/types/model/index.d.mts +6 -6
  63. package/lib/types/model/indexing.d.cts +1 -1
  64. package/lib/types/model/indexing.d.mts +1 -1
  65. package/lib/types/model/types.d.cts +2 -2
  66. package/lib/types/model/types.d.mts +2 -2
  67. package/lib/types/overrides/Metadata.d.cts +6 -6
  68. package/lib/types/overrides/Metadata.d.mts +6 -6
  69. package/lib/types/overrides/Model.d.cts +3 -3
  70. package/lib/types/overrides/Model.d.mts +3 -3
  71. package/lib/types/overrides/index.d.cts +5 -5
  72. package/lib/types/overrides/index.d.mts +5 -5
  73. package/lib/types/overrides/injectables.d.cts +2 -2
  74. package/lib/types/overrides/injectables.d.mts +2 -2
  75. package/lib/types/persistence/Adapter.d.cts +15 -15
  76. package/lib/types/persistence/Adapter.d.mts +15 -15
  77. package/lib/types/persistence/Context.d.cts +1 -1
  78. package/lib/types/persistence/Context.d.mts +1 -1
  79. package/lib/types/persistence/ContextLock.d.cts +1 -1
  80. package/lib/types/persistence/ContextLock.d.mts +1 -1
  81. package/lib/types/persistence/Dispatch.d.cts +4 -4
  82. package/lib/types/persistence/Dispatch.d.mts +4 -4
  83. package/lib/types/persistence/ObserverHandler.d.cts +4 -4
  84. package/lib/types/persistence/ObserverHandler.d.mts +4 -4
  85. package/lib/types/persistence/Sequence.d.cts +7 -7
  86. package/lib/types/persistence/Sequence.d.mts +7 -7
  87. package/lib/types/persistence/constants.d.cts +2 -2
  88. package/lib/types/persistence/constants.d.mts +2 -2
  89. package/lib/types/persistence/decorators.d.cts +3 -3
  90. package/lib/types/persistence/decorators.d.mts +3 -3
  91. package/lib/types/persistence/event-filters.d.cts +2 -2
  92. package/lib/types/persistence/event-filters.d.mts +2 -2
  93. package/lib/types/persistence/index.d.cts +13 -13
  94. package/lib/types/persistence/index.d.mts +13 -13
  95. package/lib/types/persistence/transactions.d.cts +2 -2
  96. package/lib/types/persistence/transactions.d.mts +2 -2
  97. package/lib/types/persistence/types.d.cts +8 -8
  98. package/lib/types/persistence/types.d.mts +8 -8
  99. package/lib/types/query/Condition.d.cts +2 -2
  100. package/lib/types/query/Condition.d.mts +2 -2
  101. package/lib/types/query/MethodQueryBuilder.d.cts +1 -1
  102. package/lib/types/query/MethodQueryBuilder.d.mts +1 -1
  103. package/lib/types/query/Paginator.d.cts +3 -3
  104. package/lib/types/query/Paginator.d.mts +3 -3
  105. package/lib/types/query/Statement.d.cts +11 -11
  106. package/lib/types/query/Statement.d.mts +11 -11
  107. package/lib/types/query/decorators.d.cts +3 -3
  108. package/lib/types/query/decorators.d.mts +3 -3
  109. package/lib/types/query/index.d.cts +11 -11
  110. package/lib/types/query/index.d.mts +11 -11
  111. package/lib/types/query/options.d.cts +4 -4
  112. package/lib/types/query/options.d.mts +4 -4
  113. package/lib/types/query/selectors.d.cts +1 -1
  114. package/lib/types/query/selectors.d.mts +1 -1
  115. package/lib/types/query/types.d.cts +3 -3
  116. package/lib/types/query/types.d.mts +3 -3
  117. package/lib/types/query/utils.d.cts +1 -1
  118. package/lib/types/query/utils.d.mts +1 -1
  119. package/lib/types/ram/RamAdapter.d.cts +7 -7
  120. package/lib/types/ram/RamAdapter.d.mts +7 -7
  121. package/lib/types/ram/RamPaginator.d.cts +4 -4
  122. package/lib/types/ram/RamPaginator.d.mts +4 -4
  123. package/lib/types/ram/RamStatement.d.cts +5 -5
  124. package/lib/types/ram/RamStatement.d.mts +5 -5
  125. package/lib/types/ram/handlers.d.cts +3 -3
  126. package/lib/types/ram/handlers.d.mts +3 -3
  127. package/lib/types/ram/index.d.cts +6 -6
  128. package/lib/types/ram/index.d.mts +6 -6
  129. package/lib/types/ram/types.d.cts +3 -3
  130. package/lib/types/ram/types.d.mts +3 -3
  131. package/lib/types/repository/Repository.d.cts +13 -13
  132. package/lib/types/repository/Repository.d.mts +13 -13
  133. package/lib/types/repository/constants.d.cts +1 -1
  134. package/lib/types/repository/constants.d.mts +1 -1
  135. package/lib/types/repository/index.d.cts +7 -7
  136. package/lib/types/repository/index.d.mts +7 -7
  137. package/lib/types/repository/types.d.cts +1 -1
  138. package/lib/types/repository/types.d.mts +1 -1
  139. package/lib/types/services/ModelService.d.cts +8 -8
  140. package/lib/types/services/ModelService.d.mts +8 -8
  141. package/lib/types/services/PersistenceService.d.cts +4 -4
  142. package/lib/types/services/PersistenceService.d.mts +4 -4
  143. package/lib/types/services/index.d.cts +3 -3
  144. package/lib/types/services/index.d.mts +3 -3
  145. package/lib/types/services/services.d.cts +5 -5
  146. package/lib/types/services/services.d.mts +5 -5
  147. package/lib/types/tasks/CleanUpTask.d.cts +5 -5
  148. package/lib/types/tasks/CleanUpTask.d.mts +5 -5
  149. package/lib/types/tasks/TaskContext.d.cts +7 -7
  150. package/lib/types/tasks/TaskContext.d.mts +7 -7
  151. package/lib/types/tasks/TaskEngine.d.cts +18 -18
  152. package/lib/types/tasks/TaskEngine.d.mts +18 -18
  153. package/lib/types/tasks/TaskErrors.d.cts +2 -2
  154. package/lib/types/tasks/TaskErrors.d.mts +2 -2
  155. package/lib/types/tasks/TaskEventBus.d.cts +7 -7
  156. package/lib/types/tasks/TaskEventBus.d.mts +7 -7
  157. package/lib/types/tasks/TaskEventService.d.cts +3 -3
  158. package/lib/types/tasks/TaskEventService.d.mts +3 -3
  159. package/lib/types/tasks/TaskHandler.d.cts +3 -3
  160. package/lib/types/tasks/TaskHandler.d.mts +3 -3
  161. package/lib/types/tasks/TaskHandlerRegistry.d.cts +1 -1
  162. package/lib/types/tasks/TaskHandlerRegistry.d.mts +1 -1
  163. package/lib/types/tasks/TaskService.d.cts +15 -15
  164. package/lib/types/tasks/TaskService.d.mts +15 -15
  165. package/lib/types/tasks/TaskStateChangeError.d.cts +2 -2
  166. package/lib/types/tasks/TaskStateChangeError.d.mts +2 -2
  167. package/lib/types/tasks/TaskTracker.d.cts +8 -8
  168. package/lib/types/tasks/TaskTracker.d.mts +8 -8
  169. package/lib/types/tasks/builder.d.cts +4 -4
  170. package/lib/types/tasks/builder.d.mts +4 -4
  171. package/lib/types/tasks/constants.d.cts +1 -1
  172. package/lib/types/tasks/constants.d.mts +1 -1
  173. package/lib/types/tasks/index.d.cts +17 -17
  174. package/lib/types/tasks/index.d.mts +17 -17
  175. package/lib/types/tasks/logging.d.cts +1 -1
  176. package/lib/types/tasks/logging.d.mts +1 -1
  177. package/lib/types/tasks/models/TaskBackoffModel.d.cts +1 -1
  178. package/lib/types/tasks/models/TaskBackoffModel.d.mts +1 -1
  179. package/lib/types/tasks/models/TaskEventModel.d.cts +1 -1
  180. package/lib/types/tasks/models/TaskEventModel.d.mts +1 -1
  181. package/lib/types/tasks/models/TaskModel.d.cts +6 -6
  182. package/lib/types/tasks/models/TaskModel.d.mts +6 -6
  183. package/lib/types/tasks/models/TaskStepResultModel.d.cts +2 -2
  184. package/lib/types/tasks/models/TaskStepResultModel.d.mts +2 -2
  185. package/lib/types/tasks/models/index.d.cts +8 -8
  186. package/lib/types/tasks/models/index.d.mts +8 -8
  187. package/lib/types/tasks/types.d.cts +10 -10
  188. package/lib/types/tasks/types.d.mts +10 -10
  189. package/lib/types/tasks/utils.d.cts +2 -2
  190. package/lib/types/tasks/utils.d.mts +2 -2
  191. package/lib/types/utils/ContextualLoggedClass.d.cts +4 -4
  192. package/lib/types/utils/ContextualLoggedClass.d.mts +4 -4
  193. package/lib/types/utils/decorators.d.cts +1 -1
  194. package/lib/types/utils/decorators.d.mts +1 -1
  195. package/lib/types/utils/index.d.cts +6 -6
  196. package/lib/types/utils/index.d.mts +6 -6
  197. package/lib/types/workers/TaskEngine.d.cts +6 -6
  198. package/lib/types/workers/TaskEngine.d.mts +6 -6
  199. package/lib/types/workers/WorkThreadEnvironment.d.cts +1 -1
  200. package/lib/types/workers/WorkThreadEnvironment.d.mts +1 -1
  201. package/lib/types/workers/index.d.cts +4 -4
  202. package/lib/types/workers/index.d.mts +4 -4
  203. package/lib/types/workers/messages.d.cts +1 -1
  204. package/lib/types/workers/messages.d.mts +1 -1
  205. package/lib/types/workers/types.d.cts +3 -3
  206. package/lib/types/workers/types.d.mts +3 -3
  207. package/package.json +1 -1
  208. package/lib/types/auth/constants.d.ts +0 -5
  209. package/lib/types/auth/decorators.d.ts +0 -5
  210. package/lib/types/auth/index.d.ts +0 -2
  211. package/lib/types/fs/FilesystemAdapter.d.ts +0 -70
  212. package/lib/types/fs/FsDispatch.d.ts +0 -7
  213. package/lib/types/fs/helpers.d.ts +0 -17
  214. package/lib/types/fs/index.d.ts +0 -4
  215. package/lib/types/fs/indexStore.d.ts +0 -28
  216. package/lib/types/fs/locks/FilesystemLock.d.ts +0 -13
  217. package/lib/types/fs/locks/FilesystemMultiLock.d.ts +0 -8
  218. package/lib/types/fs/types.d.ts +0 -40
  219. package/lib/types/identity/decorators.d.ts +0 -72
  220. package/lib/types/identity/index.d.ts +0 -6
  221. package/lib/types/index.d.ts +0 -34
  222. package/lib/types/interfaces/ContextuallyLogged.d.ts +0 -8
  223. package/lib/types/interfaces/ErrorParser.d.ts +0 -16
  224. package/lib/types/interfaces/Executor.d.ts +0 -16
  225. package/lib/types/interfaces/Observable.d.ts +0 -33
  226. package/lib/types/interfaces/Observer.d.ts +0 -15
  227. package/lib/types/interfaces/Paginatable.d.ts +0 -20
  228. package/lib/types/interfaces/Queriable.d.ts +0 -47
  229. package/lib/types/interfaces/RawExecutor.d.ts +0 -28
  230. package/lib/types/interfaces/SequenceOptions.d.ts +0 -79
  231. package/lib/types/interfaces/index.d.ts +0 -12
  232. package/lib/types/migrations/Migration.d.ts +0 -19
  233. package/lib/types/migrations/MigrationService.d.ts +0 -63
  234. package/lib/types/migrations/MigrationTaskBuilder.d.ts +0 -10
  235. package/lib/types/migrations/MigrationTasks.d.ts +0 -9
  236. package/lib/types/migrations/MigrationVersioning.d.ts +0 -7
  237. package/lib/types/migrations/SemverMigrationVersioning.d.ts +0 -10
  238. package/lib/types/migrations/StandardMigrationVersioning.d.ts +0 -12
  239. package/lib/types/migrations/constants.d.ts +0 -2
  240. package/lib/types/migrations/decorators.d.ts +0 -12
  241. package/lib/types/migrations/index.d.ts +0 -15
  242. package/lib/types/migrations/types.d.ts +0 -46
  243. package/lib/types/model/BaseModel.d.ts +0 -37
  244. package/lib/types/model/SequenceModel.d.ts +0 -32
  245. package/lib/types/model/construction.d.ts +0 -455
  246. package/lib/types/model/decorators.d.ts +0 -237
  247. package/lib/types/model/index.d.ts +0 -11
  248. package/lib/types/model/indexing.d.ts +0 -20
  249. package/lib/types/model/types.d.ts +0 -60
  250. package/lib/types/overrides/Metadata.d.ts +0 -22
  251. package/lib/types/overrides/Model.d.ts +0 -94
  252. package/lib/types/overrides/ModelBuilder.d.ts +0 -31
  253. package/lib/types/overrides/index.d.ts +0 -11
  254. package/lib/types/overrides/injectables.d.ts +0 -10
  255. package/lib/types/overrides/overrides.d.ts +0 -1
  256. package/lib/types/persistence/Adapter.d.ts +0 -469
  257. package/lib/types/persistence/Context.d.ts +0 -16
  258. package/lib/types/persistence/ContextLock.d.ts +0 -18
  259. package/lib/types/persistence/Dispatch.d.ts +0 -128
  260. package/lib/types/persistence/ObserverHandler.d.ts +0 -111
  261. package/lib/types/persistence/Sequence.d.ts +0 -126
  262. package/lib/types/persistence/constants.d.ts +0 -74
  263. package/lib/types/persistence/decorators.d.ts +0 -28
  264. package/lib/types/persistence/errors.d.ts +0 -33
  265. package/lib/types/persistence/event-filters.d.ts +0 -20
  266. package/lib/types/persistence/generators.d.ts +0 -14
  267. package/lib/types/persistence/index.d.ts +0 -18
  268. package/lib/types/persistence/transactions.d.ts +0 -4
  269. package/lib/types/persistence/types.d.ts +0 -86
  270. package/lib/types/query/Condition.d.ts +0 -131
  271. package/lib/types/query/MethodQueryBuilder.d.ts +0 -185
  272. package/lib/types/query/Paginator.d.ts +0 -105
  273. package/lib/types/query/Statement.d.ts +0 -136
  274. package/lib/types/query/constants.d.ts +0 -69
  275. package/lib/types/query/decorators.d.ts +0 -8
  276. package/lib/types/query/errors.d.ts +0 -21
  277. package/lib/types/query/index.d.ts +0 -16
  278. package/lib/types/query/options.d.ts +0 -393
  279. package/lib/types/query/selectors.d.ts +0 -39
  280. package/lib/types/query/types.d.ts +0 -158
  281. package/lib/types/query/utils.d.ts +0 -40
  282. package/lib/types/ram/RamAdapter.d.ts +0 -341
  283. package/lib/types/ram/RamPaginator.d.ts +0 -54
  284. package/lib/types/ram/RamStatement.d.ts +0 -92
  285. package/lib/types/ram/constants.d.ts +0 -8
  286. package/lib/types/ram/handlers.d.ts +0 -24
  287. package/lib/types/ram/index.d.ts +0 -12
  288. package/lib/types/ram/types.d.ts +0 -50
  289. package/lib/types/repository/Repository.d.ts +0 -501
  290. package/lib/types/repository/constants.d.ts +0 -36
  291. package/lib/types/repository/decorators.d.ts +0 -30
  292. package/lib/types/repository/errors.d.ts +0 -19
  293. package/lib/types/repository/index.d.ts +0 -12
  294. package/lib/types/repository/injectables.d.ts +0 -95
  295. package/lib/types/repository/types.d.ts +0 -28
  296. package/lib/types/repository/utils.d.ts +0 -36
  297. package/lib/types/services/ModelService.d.ts +0 -45
  298. package/lib/types/services/PersistenceService.d.ts +0 -17
  299. package/lib/types/services/index.d.ts +0 -8
  300. package/lib/types/services/services.d.ts +0 -96
  301. package/lib/types/tasks/CleanUpTask.d.ts +0 -15
  302. package/lib/types/tasks/TaskContext.d.ts +0 -30
  303. package/lib/types/tasks/TaskEngine.d.ts +0 -97
  304. package/lib/types/tasks/TaskErrors.d.ts +0 -65
  305. package/lib/types/tasks/TaskEventBus.d.ts +0 -17
  306. package/lib/types/tasks/TaskEventService.d.ts +0 -7
  307. package/lib/types/tasks/TaskHandler.d.ts +0 -12
  308. package/lib/types/tasks/TaskHandlerRegistry.d.ts +0 -8
  309. package/lib/types/tasks/TaskService.d.ts +0 -65
  310. package/lib/types/tasks/TaskStateChangeError.d.ts +0 -11
  311. package/lib/types/tasks/TaskTracker.d.ts +0 -47
  312. package/lib/types/tasks/builder.d.ts +0 -72
  313. package/lib/types/tasks/constants.d.ts +0 -31
  314. package/lib/types/tasks/decorators.d.ts +0 -4
  315. package/lib/types/tasks/index.d.ts +0 -23
  316. package/lib/types/tasks/logging.d.ts +0 -31
  317. package/lib/types/tasks/models/TaskBackoffModel.d.ts +0 -9
  318. package/lib/types/tasks/models/TaskErrorModel.d.ts +0 -8
  319. package/lib/types/tasks/models/TaskEventModel.d.ts +0 -11
  320. package/lib/types/tasks/models/TaskIOSerializer.d.ts +0 -33
  321. package/lib/types/tasks/models/TaskLogEntryModel.d.ts +0 -10
  322. package/lib/types/tasks/models/TaskModel.d.ts +0 -43
  323. package/lib/types/tasks/models/TaskStepResultModel.d.ts +0 -9
  324. package/lib/types/tasks/models/TaskStepSpecModel.d.ts +0 -9
  325. package/lib/types/tasks/models/index.d.ts +0 -8
  326. package/lib/types/tasks/types.d.ts +0 -71
  327. package/lib/types/tasks/utils.d.ts +0 -5
  328. package/lib/types/utils/ContextualLoggedClass.d.ts +0 -37
  329. package/lib/types/utils/decorators.d.ts +0 -27
  330. package/lib/types/utils/errors.d.ts +0 -56
  331. package/lib/types/utils/index.d.ts +0 -11
  332. package/lib/types/utils/throttling.d.ts +0 -9
  333. package/lib/types/utils/types.d.ts +0 -23
  334. package/lib/types/utils/utils.d.ts +0 -22
  335. package/lib/types/workers/TaskEngine.d.ts +0 -40
  336. package/lib/types/workers/WorkThreadEnvironment.d.ts +0 -35
  337. package/lib/types/workers/index.d.ts +0 -5
  338. package/lib/types/workers/messages.d.ts +0 -69
  339. package/lib/types/workers/types.d.ts +0 -41
  340. package/lib/types/workers/workerThread.d.ts +0 -1
@@ -1,111 +0,0 @@
1
- import { Observer } from "../interfaces";
2
- import { EventIds, ObserverFilter, PersistenceObservable } from "./types";
3
- import { BulkCrudOperationKeys, OperationKeys } from "@decaf-ts/db-decorators";
4
- import { Model } from "@decaf-ts/decorator-validation";
5
- import { Constructor } from "@decaf-ts/decoration";
6
- import { ContextualArgs } from "../utils/ContextualLoggedClass";
7
- import { Context } from "./Context";
8
- /**
9
- * @description Manages a collection of observers for database events
10
- * @summary The ObserverHandler class implements the Observable interface and provides a centralized
11
- * way to manage multiple observers. It allows registering observers with optional filters to control
12
- * which events they receive notifications for, and handles the process of notifying all relevant
13
- * observers when database events occur.
14
- * @class ObserverHandler
15
- * @example
16
- * ```typescript
17
- * // Create an observer handler
18
- * const handler = new ObserverHandler();
19
- *
20
- * // Register an observer
21
- * const myObserver = {
22
- * refresh: async (table, event, id) => {
23
- * console.log(`Change in ${table}: ${event} for ID ${id}`);
24
- * }
25
- * };
26
- *
27
- * // Add observer with a filter for only user table events
28
- * handler.observe(myObserver, (table, event, id) => table === 'users');
29
- *
30
- * // Notify observers about an event
31
- * await handler.updateObservers(logger, 'users', 'CREATE', 123);
32
- *
33
- * // Remove an observer when no longer needed
34
- * handler.unObserve(myObserver);
35
- * ```
36
- */
37
- export declare class ObserverHandler<C extends Context<any> = Context> implements PersistenceObservable<C> {
38
- /**
39
- * @description Collection of registered observers
40
- * @summary Array of observer objects along with their optional filters
41
- */
42
- protected readonly observers: {
43
- observer: Observer;
44
- filter?: ObserverFilter;
45
- }[];
46
- /**
47
- * @description Gets the number of registered observers
48
- * @summary Returns the count of observers currently registered with this handler
49
- * @return {number} The number of registered observers
50
- */
51
- count(): number;
52
- /**
53
- * @description Registers a new observer
54
- * @summary Adds an observer to the collection with an optional filter function
55
- * @param {Observer} observer - The observer to register
56
- * @param {ObserverFilter} [filter] - Optional filter function to determine which events the observer receives
57
- * @return {void}
58
- */
59
- observe(observer: Observer, filter?: ObserverFilter): () => void;
60
- /**
61
- * @description Unregisters an observer
62
- * @summary Removes an observer from the collection
63
- * @param {Observer} observer - The observer to unregister
64
- * @return {void}
65
- */
66
- unObserve(observer: Observer): void;
67
- /**
68
- * @description Notifies all relevant observers about a database event
69
- * @summary Filters observers based on their filter functions and calls refresh on each matching observer
70
- * @param {string} table - The name of the table where the event occurred
71
- * @param {OperationKeys|BulkCrudOperationKeys|string} event - The type of operation that occurred
72
- * @param {EventIds} id - The identifier(s) of the affected record(s)
73
- * @param {...any[]} args - Additional arguments to pass to the observers
74
- * @return {Promise<void>} A promise that resolves when all observers have been notified
75
- * @mermaid
76
- * sequenceDiagram
77
- * participant Client
78
- * participant ObserverHandler
79
- * participant Observer
80
- *
81
- * Client->>ObserverHandler: updateObservers(log, table, event, id, ...args)
82
- *
83
- * ObserverHandler->>ObserverHandler: Filter observers
84
- *
85
- * loop For each observer with matching filter
86
- * alt Observer has filter
87
- * ObserverHandler->>Observer: Apply filter(table, event, id)
88
- * alt Filter throws error
89
- * ObserverHandler->>Logger: Log error
90
- * ObserverHandler-->>ObserverHandler: Skip observer
91
- * else Filter returns true
92
- * ObserverHandler->>Observer: refresh(table, event, id, ...args)
93
- * else Filter returns false
94
- * ObserverHandler-->>ObserverHandler: Skip observer
95
- * end
96
- * else No filter
97
- * ObserverHandler->>Observer: refresh(table, event, id, ...args)
98
- * end
99
- * end
100
- *
101
- * ObserverHandler->>ObserverHandler: Process results
102
- * loop For each result
103
- * alt Result is rejected
104
- * ObserverHandler->>Logger: Log error
105
- * end
106
- * end
107
- *
108
- * ObserverHandler-->>Client: Return
109
- */
110
- updateObservers<M extends Model>(model: Constructor<M> | string, event: OperationKeys | BulkCrudOperationKeys | string, id: EventIds, ...args: ContextualArgs<any>): Promise<void>;
111
- }
@@ -1,126 +0,0 @@
1
- import { Model } from "@decaf-ts/decorator-validation";
2
- import { SequenceOptions, SequenceOptionsType } from "../interfaces/SequenceOptions";
3
- import { Constructor } from "@decaf-ts/decoration";
4
- import { ContextualizedArgs, ContextualLoggedClass, MaybeContextualArg, MethodOrOperation } from "../utils/ContextualLoggedClass";
5
- import { Adapter } from "./Adapter";
6
- import { Repo } from "../repository/Repository";
7
- import { SequenceModel } from "../model/SequenceModel";
8
- import { Context } from "./Context";
9
- import { MultiLock } from "@decaf-ts/transactional-decorators";
10
- import type { ContextOf, FlagsOf } from "./types";
11
- /**
12
- * @description Abstract base class for sequence generation
13
- * @summary Provides a framework for generating sequential values (like primary keys) in the persistence layer.
14
- * Implementations of this class handle the specifics of how sequences are stored and incremented in different
15
- * database systems.
16
- * @param {SequenceOptions} options - Configuration options for the sequence generator
17
- * @class Sequence
18
- * @example
19
- * ```typescript
20
- * // Example implementation for a specific database
21
- * class PostgresSequence extends Sequence {
22
- * constructor(options: SequenceOptions) {
23
- * super(options);
24
- * }
25
- *
26
- * async next(): Promise<number> {
27
- * // Implementation to get next value from PostgreSQL sequence
28
- * const result = await this.options.executor.raw(`SELECT nextval('${this.options.name}')`);
29
- * return parseInt(result.rows[0].nextval);
30
- * }
31
- *
32
- * async current(): Promise<number> {
33
- * // Implementation to get current value from PostgreSQL sequence
34
- * const result = await this.options.executor.raw(`SELECT currval('${this.options.name}')`);
35
- * return parseInt(result.rows[0].currval);
36
- * }
37
- *
38
- * async range(count: number): Promise<number[]> {
39
- * // Implementation to get a range of values
40
- * const values: number[] = [];
41
- * for (let i = 0; i < count; i++) {
42
- * values.push(await this.next());
43
- * }
44
- * return values;
45
- * }
46
- * }
47
- *
48
- * // Usage
49
- * const sequence = new PostgresSequence({
50
- * name: 'user_id_seq',
51
- * executor: dbExecutor
52
- * });
53
- *
54
- * const nextId = await sequence.next();
55
- * ```
56
- */
57
- export declare class Sequence<A extends Adapter<any, any, any, any> = Adapter<any, any, any, any>> extends ContextualLoggedClass<any> {
58
- protected readonly options: SequenceOptions;
59
- protected readonly adapter: A;
60
- protected repo: Repo<SequenceModel>;
61
- protected static readonly lock: MultiLock;
62
- /**
63
- * @description Creates a new sequence instance
64
- * @summary Protected constructor that initializes the sequence with the provided options
65
- */
66
- constructor(options: SequenceOptions, adapter: A, overrides?: Partial<FlagsOf<A>>);
67
- /**
68
- * @description Retrieves the current value of the sequence
69
- * @summary Gets the current value of the sequence from storage. If the sequence
70
- * doesn't exist yet, it returns the configured starting value.
71
- * @return A promise that resolves to the current sequence value
72
- */
73
- current(...args: MaybeContextualArg<any>): Promise<string | number | bigint>;
74
- /**
75
- * @description Increments the sequence value
76
- * @summary Increases the current sequence value by the specified amount and persists
77
- * the new value to storage. This method handles both numeric and BigInt sequence types.
78
- * @param {string | number | bigint} current - The current value of the sequence
79
- * @param {number} [count] - Optional amount to increment by, defaults to the sequence's incrementBy value
80
- * @return A promise that resolves to the new sequence value after incrementing
81
- */
82
- protected increment(count: number | undefined, context: Context<any>): Promise<string | number | bigint>;
83
- /**
84
- * @description Gets the next value in the sequence
85
- * @summary Retrieves the current value of the sequence and increments it by the
86
- * configured increment amount. This is the main method used to get a new sequential value.
87
- * @return A promise that resolves to the next value in the sequence
88
- */
89
- next(...argz: MaybeContextualArg<any>): Promise<number | string | bigint>;
90
- /**
91
- * @description Generates a range of sequential values
92
- * @summary Retrieves a specified number of sequential values from the sequence.
93
- * This is useful when you need to allocate multiple IDs at once.
94
- * The method increments the sequence by the total amount needed and returns all values in the range.
95
- * @param {number} count - The number of sequential values to generate
96
- * @return A promise that resolves to an array of sequential values
97
- */
98
- range(count: number, ...argz: MaybeContextualArg<any>): Promise<(number | string | bigint)[]>;
99
- /**
100
- * @description Ensures the sequence exists and is at least a given value
101
- * @summary Upserts the sequence record to the provided value when missing, and optionally only when the
102
- * provided value is greater than the persisted one. This is used by decorators that want to "seed" a
103
- * sequence based on an existing model value (for example when overriding/bootstrapping sequences).
104
- */
105
- ensureAtLeast(value: string | number | bigint, ...argz: MaybeContextualArg<any>): Promise<string | number | bigint>;
106
- protected parse(value: string | number | bigint): string | number | bigint;
107
- protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<ContextOf<typeof this.adapter>, ARGS>, operation: METHOD): ContextualizedArgs<ContextOf<typeof this.adapter>, ARGS, METHOD extends string ? true : false>;
108
- protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<ContextOf<typeof this.adapter>, ARGS>, operation: METHOD, allowCreate: false): ContextualizedArgs<ContextOf<typeof this.adapter>, ARGS, METHOD extends string ? true : false>;
109
- protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<ContextOf<typeof this.adapter>, ARGS>, operation: METHOD, allowCreate: true): Promise<ContextualizedArgs<ContextOf<typeof this.adapter>, ARGS, METHOD extends string ? true : false>>;
110
- /**
111
- * @description Gets the primary key sequence name for a model
112
- * @summary Utility method that returns the standardized sequence name for a model's primary key
113
- * @template M - The model type
114
- * @param {M|Constructor<M>} model - The model instance or constructor
115
- * @return {string} The sequence name for the model's primary key
116
- */
117
- static pk<M extends Model>(model: M | Constructor<M>): string;
118
- /**
119
- * @description Parses a sequence value to the appropriate type
120
- * @summary Converts a sequence value to the specified type (Number or BigInt)
121
- * @param {"Number"|"BigInt"|undefined} type - The target type to convert to
122
- * @param {string|number|bigint} value - The value to convert
123
- * @return {string|number|bigint} The converted value
124
- */
125
- static parseValue(type: SequenceOptionsType, value: string | number | bigint): string | number | bigint;
126
- }
@@ -1,74 +0,0 @@
1
- import { BulkCrudOperationKeys, OperationKeys } from "@decaf-ts/db-decorators";
2
- import { AdapterFlags, ContextFlags } from "./types";
3
- import { PreparedStatementKeys } from "../query/constants";
4
- /**
5
- * @description Persistence-related constant keys
6
- * @summary Enum containing string constants used throughout the persistence layer for metadata, relations, and other persistence-related operations
7
- * @enum {string}
8
- * @readonly
9
- * @memberOf module:core
10
- */
11
- export declare enum PersistenceKeys {
12
- PERSISTENCE = "persistence",
13
- /** @description Key for index metadata */
14
- INDEX = "index",
15
- /** @description Key for sequence metadata */
16
- SEQUENCE = "sequence",
17
- /** @description Key for unique constraint metadata */
18
- UNIQUE = "unique",
19
- /** @description Key for adapter metadata */
20
- ADAPTER = "adapter",
21
- /** @description Template for injectable adapter names */
22
- INJECTABLE = "decaf_{0}_adapter_for_{1}",
23
- SERVICE = "service",
24
- /** @description Key for table name metadata */
25
- TABLE = "table",
26
- /** @description Key for column name metadata */
27
- COLUMN = "column",
28
- /** @description Key for general metadata storage */
29
- METADATA = "__metadata",
30
- /** @description Key for created-by ownership metadata */
31
- OWNERSHIP = "ownership",
32
- /** @description Key for created-by ownership metadata */
33
- CREATED_BY = "ownership.created-by",
34
- /** @description Key for updated-by ownership metadata */
35
- UPDATED_BY = "ownership.updated-by",
36
- /** @description Key for relations metadata storage */
37
- RELATIONS = "__relations",
38
- /** @description Key for relations metadata storage */
39
- RELATION = "relation",
40
- /** @description Key for one-to-one relation metadata */
41
- ONE_TO_ONE = "relation.one-to-one",
42
- /** @description Key for one-to-many relation metadata */
43
- ONE_TO_MANY = "relation.one-to-many",
44
- /** @description Key for many-to-one relation metadata */
45
- MANY_TO_ONE = "relation.many-to-one",
46
- /** @description Key for many-to-one relation metadata */
47
- MANY_TO_MANY = "relation.many-to-many",
48
- /** @description Key for populate metadata */
49
- POPULATE = "populate",
50
- /** @description Key for populate metadata */
51
- NO_VALIDATE = "no-validate",
52
- /** @description Key for migration classes */
53
- MIGRATION = "migration",
54
- STATEMENT = "statement",
55
- QUERY = "query",
56
- UUID = "uuid",
57
- TAG_FOR_DELETION = "tag_for_deletion",
58
- INITIALIZATION = "initialization",
59
- SHUTDOWN = "shutdown",
60
- BY_KEY = "by-key",
61
- AUTH = "auth",
62
- AUTH_ROLE = "auth-role",
63
- DECAF_ROUTE = "DecafRoute",
64
- THROTTLE = "throttle",
65
- PERSISTENT_VERSION = "persistent-version",
66
- DEFAULT_QUERY_ATTR = "default-query-attr"
67
- }
68
- export declare const DefaultContextFlags: ContextFlags<any>;
69
- export declare const DefaultAdapterFlags: AdapterFlags;
70
- export declare const TransactionOperationKeys: (string | OperationKeys | BulkCrudOperationKeys | PersistenceKeys | PreparedStatementKeys)[];
71
- export declare const NonTransactionOperationKeys: (string | OperationKeys | BulkCrudOperationKeys | PersistenceKeys | PreparedStatementKeys)[];
72
- export declare const SelectOperationKeys: (string | OperationKeys | BulkCrudOperationKeys | PersistenceKeys | PreparedStatementKeys)[];
73
- export declare const MultipleSelectOperationKeys: (string | OperationKeys | BulkCrudOperationKeys | PersistenceKeys | PreparedStatementKeys)[];
74
- export declare const PaginationOperationKeys: (string | OperationKeys | BulkCrudOperationKeys | PersistenceKeys | PreparedStatementKeys)[];
@@ -1,28 +0,0 @@
1
- import { Model } from "@decaf-ts/decorator-validation";
2
- import { ContextOf } from "./types";
3
- import { Repo } from "../repository/Repository";
4
- import { ContextualArgs } from "../utils/ContextualLoggedClass";
5
- /**
6
- * @description Handler function that sets a timestamp property to the current timestamp.
7
- * @summary Updates a model property with the current timestamp from the repository context.
8
- * @template M - The model type extending Model
9
- * @template R - The repository type extending IRepository
10
- * @template V - The data type for the operation
11
- * @template F - The repository flags type
12
- * @template C - The context type
13
- * @param {C} context - The repository context containing the current timestamp
14
- * @param {V} data - The data being processed
15
- * @param key - The property key to update
16
- * @param {M} model - The model instance being updated
17
- * @return {Promise<void>} A promise that resolves when the timestamp has been set
18
- * @function uuidCreateUpdateHandler
19
- */
20
- export declare function uuidCreateUpdateHandler<M extends Model<boolean>, R extends Repo<M>>(this: R, context: ContextOf<R>, data: UUIDMetadata, key: keyof M, model: M): Promise<void>;
21
- export type UUIDMetadata = {
22
- update: boolean;
23
- seed?: string | (<M extends Model>(model: M, ...args: ContextualArgs<any>) => string);
24
- args?: any[];
25
- };
26
- export declare function uuid(...args: any[]): (target: any, propertyKey?: any) => void;
27
- export declare function uuid(update: boolean, ...args: any[]): (target: any, propertyKey?: any) => void;
28
- export declare function uuid(seed: string | (<M extends Model>(model: M, ...args: ContextualArgs<any>) => string), ...args: any[]): (target: any, propertyKey?: any) => void;
@@ -1,33 +0,0 @@
1
- import { InternalError } from "@decaf-ts/db-decorators";
2
- /**
3
- * @description Error thrown when an unsupported operation is attempted
4
- * @summary This error is thrown when an operation is requested that is not supported by the current
5
- * persistence adapter or configuration. It extends the BaseError class and sets a 500 status code.
6
- * @param {string|Error} msg - The error message or an Error object to wrap
7
- * @class UnsupportedError
8
- * @example
9
- * ```typescript
10
- * // Throwing an UnsupportedError
11
- * if (!adapter.supportsTransactions()) {
12
- * throw new UnsupportedError('Transactions are not supported by this adapter');
13
- * }
14
- *
15
- * // Catching an UnsupportedError
16
- * try {
17
- * await adapter.beginTransaction();
18
- * } catch (error) {
19
- * if (error instanceof UnsupportedError) {
20
- * console.error('Operation not supported:', error.message);
21
- * }
22
- * }
23
- * ```
24
- */
25
- export declare class UnsupportedError extends InternalError {
26
- constructor(msg: string | Error | unknown);
27
- }
28
- export declare class MigrationError extends InternalError {
29
- constructor(msg: string | Error | unknown, name?: string);
30
- }
31
- export declare class MigrationRuleError extends MigrationError {
32
- constructor(msg: string | Error | unknown);
33
- }
@@ -1,20 +0,0 @@
1
- import { AllOperationKeys, ObserverFilter } from "./types";
2
- import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
3
- import type { Repo } from "../repository/Repository";
4
- export declare function onlyOnCreate(clazz: ModelConstructor<any>): ObserverFilter;
5
- export declare function onlyOnUpdate(clazz: ModelConstructor<any>): ObserverFilter;
6
- export declare function onlyOnDelete(clazz: ModelConstructor<any>): ObserverFilter;
7
- export declare function onlyOnTransactional(clazz: ModelConstructor<any>): ObserverFilter;
8
- export declare function onlyOnSingle(clazz: ModelConstructor<any>): ObserverFilter;
9
- export declare function onlyOnBulk(clazz: ModelConstructor<any>): ObserverFilter;
10
- export declare function onlyOnFilter(clazz: ModelConstructor<any>, ops: AllOperationKeys[]): ObserverFilter;
11
- export type AvailableFilters = typeof DefaultRepositoryFilters;
12
- export declare const DefaultRepositoryFilters: {
13
- onlyOnCreate: typeof onlyOnCreate;
14
- onlyOnUpdate: typeof onlyOnUpdate;
15
- onlyOnDelete: typeof onlyOnDelete;
16
- onlyOnTransactional: typeof onlyOnTransactional;
17
- onlyOnSingle: typeof onlyOnSingle;
18
- onlyOnBulk: typeof onlyOnBulk;
19
- };
20
- export declare function getFilters<M extends Model>(repo: Repo<M>): Record<keyof typeof DefaultRepositoryFilters, ObserverFilter>;
@@ -1,14 +0,0 @@
1
- export interface Generator<OUT extends string | number = string> {
2
- generate(prev?: OUT): OUT | Promise<OUT>;
3
- }
4
- export declare class UUID implements Generator {
5
- private static _instance;
6
- generate(prev?: string): string | Promise<string>;
7
- static get instance(): UUID;
8
- }
9
- export declare class Serial implements Generator {
10
- private static _instance;
11
- private count;
12
- generate(prev?: string): string | Promise<string>;
13
- static get instance(): Serial;
14
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * @description Exports for the persistence module.
3
- * @summary This file exports all the necessary components for the persistence functionality, including Dispatch, constants, and more.
4
- * @module core/persistence
5
- */
6
- export * from "./Dispatch";
7
- export * from "./constants";
8
- export * from "./Context";
9
- export * from "./ContextLock";
10
- export * from "./decorators";
11
- export * from "./errors";
12
- export * from "./generators";
13
- export * from "./event-filters";
14
- export * from "./ObserverHandler";
15
- export * from "./Sequence";
16
- export * from "./types";
17
- export * from "./transactions";
18
- export * from "./Adapter";
@@ -1,4 +0,0 @@
1
- import { Adapter } from "../persistence/Adapter";
2
- import { ContextLock } from "../persistence/ContextLock";
3
- export declare function getAdapterTransaction(obj: any, ...args: any[]): import(".").AdapterTransaction<Adapter<any, any, any, any>>;
4
- export declare function getContextLock(obj: any, ...args: any[]): ContextLock;
@@ -1,86 +0,0 @@
1
- import { BulkCrudOperationKeys, LoggerOfFlags, OperationKeys, RepositoryFlags, ContextFlags as CtxFlags } from "@decaf-ts/db-decorators";
2
- import { Adapter } from "./Adapter";
3
- import { Observable, type Observer } from "../interfaces/index";
4
- import { Logger } from "@decaf-ts/logging";
5
- import { Constructor } from "@decaf-ts/decoration";
6
- import { Model } from "@decaf-ts/decorator-validation";
7
- import { ContextualArgs, ContextualLoggedClass } from "../utils/ContextualLoggedClass";
8
- import { Context } from "./Context";
9
- import { Repository } from "../repository/Repository";
10
- import { PersistenceKeys } from "./constants";
11
- import { PreparedStatementKeys } from "../query/constants";
12
- import { ContextLock } from "./ContextLock";
13
- export type FlagsOfContext<C extends Context<any>> = C extends Context<infer F> ? F : never;
14
- export type LoggerOfContext<C extends Context<any>> = LoggerOfFlags<FlagsOfContext<C>>;
15
- export type ContextOfRepository<R extends Repository<any, any>> = R extends Repository<any, infer A> ? ContextOf<A> : never;
16
- export type FlagsOfRepository<R extends Repository<any, any>> = FlagsOfContext<ContextOfRepository<R>>;
17
- export type LoggerOfRepository<R extends Repository<any, any>> = LoggerOfContext<ContextOfRepository<R>>;
18
- export type ContextOf<OBJ extends Repository<any, any> | Adapter<any, any, any, any> | ContextualLoggedClass<any>> = OBJ extends Adapter<any, any, any, infer C> ? C : OBJ extends Repository<any, any> ? ContextOfRepository<OBJ> : OBJ extends ContextualLoggedClass<infer C> ? C : never;
19
- export type ConfigOf<OBJ extends Adapter<any, any, any, any>> = OBJ extends Adapter<infer C, any, any, any> ? C : never;
20
- export type LoggerOfAdapter<A extends Adapter<any, any, any, any>> = A extends Adapter<any, any, any, infer C> ? LoggerOfContext<C> : never;
21
- export type FlagsOfAdapter<A extends Adapter<any, any, any, any>> = A extends Adapter<any, any, any, infer C> ? FlagsOfContext<C> : never;
22
- export type LoggerOf<OBJ extends AdapterFlags<any> | Context<any> | Adapter<any, any, any> | Repository<any, any>> = OBJ extends AdapterFlags<any> ? LoggerOfFlags<OBJ> : OBJ extends Context<any> ? LoggerOfContext<OBJ> : OBJ extends Repository<any, any> ? LoggerOfRepository<OBJ> : OBJ extends Adapter<any, any, any> ? LoggerOfAdapter<OBJ> : Logger;
23
- export type ConfOf<A extends Adapter<any, any, any, any>> = A extends Adapter<infer C, any, any> ? C : never;
24
- export type FlagsOf<OBJ extends Repository<any, any> | Adapter<any, any, any, any> | Context<any>> = OBJ extends Context<any> ? FlagsOfContext<OBJ> : OBJ extends Repository<any, any> ? FlagsOfRepository<OBJ> : OBJ extends Adapter<any, any, any, any> ? FlagsOfAdapter<OBJ> : never;
25
- export type PersistenceObservable<CONTEXT extends Context<any>> = Observable<[
26
- Observer,
27
- ObserverFilter?
28
- ], [
29
- Constructor | string,
30
- OperationKeys | BulkCrudOperationKeys | string,
31
- EventIds,
32
- ...ContextualArgs<CONTEXT>
33
- ]>;
34
- export type PersistenceObserver<CONTEXT extends Context<any>> = Observer<[
35
- Constructor | string,
36
- OperationKeys | BulkCrudOperationKeys | string,
37
- EventIds,
38
- ...ContextualArgs<CONTEXT>
39
- ]>;
40
- /**
41
- * @description Type representing possible ID formats for database events
42
- * @summary A union type that defines the possible formats for event identifiers in the persistence layer.
43
- * These can be single values (string, number, bigint) or arrays of these types.
44
- * @typedef {(string|number|bigint|string[]|number[]|bigint[])} EventIds
45
- * @memberOf module:core
46
- */
47
- export type EventIds = string | number | bigint | string[] | number[] | bigint[];
48
- export type ObserverFilter = (table: Constructor | string, event: AllOperationKeys, id: EventIds, ...args: ContextualArgs<any>) => boolean;
49
- export type InferredAdapterConfig<A> = A extends Adapter<infer CONF, any, any> ? CONF : never;
50
- export interface AdapterDispatch<A extends Adapter<any, any, any, any>> extends PersistenceObservable<ContextOf<A>> {
51
- close(...args: ContextualArgs<ContextOf<A>>): Promise<void>;
52
- updateObservers<M extends Model>(table: Constructor<M> | string, event: OperationKeys | BulkCrudOperationKeys | string, id: EventIds, ...args: ContextualArgs<ContextOf<A>>): Promise<void>;
53
- }
54
- export type RepositoryFor<A extends Adapter<any, any, any, any>> = A extends Adapter<any, any, any, any> ? ReturnType<A["repository"]> : never;
55
- export type PreparedModel = {
56
- record: Record<string, any>;
57
- id: string;
58
- transient?: Record<string, any>;
59
- };
60
- export type ContextFlags<LOG extends Logger> = CtxFlags<LOG> & Pick<RepositoryFlags<LOG>, "operation" | "correlationId" | "ignoreDevSafeGuards" | "parentContext" | "childContexts"> & {
61
- pending?: Record<string, string[]>;
62
- transactionLock?: ContextLock;
63
- };
64
- export type AdapterFlags<LOG extends Logger = Logger> = RepositoryFlags<LOG> & ContextFlags<LOG> & {
65
- allowGenerationOverride: boolean;
66
- afterQueryHandlers: boolean;
67
- enforceUpdateValidation: boolean;
68
- allowRawStatements: boolean;
69
- forcePrepareSimpleQueries: boolean;
70
- forcePrepareComplexQueries: boolean;
71
- cacheForPopulate: Record<string, any>;
72
- preferFromCache: boolean;
73
- noEmit: boolean;
74
- noEmitSingle: boolean;
75
- noEmitBulk: boolean;
76
- breakOnSingleFailureInBulk: boolean;
77
- observeFullResult: boolean;
78
- paginateByBookmark: boolean;
79
- dryRun: boolean;
80
- lock?: ContextLock;
81
- };
82
- export type RawResult<R, D extends boolean> = D extends true ? R : {
83
- data: R;
84
- count?: number;
85
- };
86
- export type AllOperationKeys = OperationKeys | BulkCrudOperationKeys | PersistenceKeys | PreparedStatementKeys | string;
@@ -1,131 +0,0 @@
1
- import { AttributeOption, ConditionBuilderOption } from "./options";
2
- import { ConditionalAsync, Model, ModelArg, ModelErrorDefinition } from "@decaf-ts/decorator-validation";
3
- import { GroupOperator, Operator } from "./constants";
4
- type InferAsync<M> = M extends Model<infer A> ? A : false;
5
- /**
6
- * @description Represents a logical condition for database queries
7
- * @summary A class that encapsulates query conditions with support for complex logical operations.
8
- * This class allows for building and combining query conditions using logical operators (AND, OR, NOT)
9
- * and comparison operators (equals, not equals, greater than, etc.).
10
- * @template M - The model type this condition operates on
11
- * @param {string | Condition<M>} attr1 - The attribute name or a nested condition
12
- * @param {Operator | GroupOperator} operator - The operator to use for the condition
13
- * @param {any} comparison - The value to compare against or another condition
14
- * @class Condition
15
- * @example
16
- * // Create a simple condition
17
- * const nameCondition = Condition.attribute("name").eq("John");
18
- *
19
- * // Create a complex condition
20
- * const complexCondition = Condition.attribute("age").gt(18)
21
- * .and(Condition.attribute("status").eq("active"));
22
- *
23
- * // Use the builder pattern
24
- * const userQuery = Condition.builder()
25
- * .attribute("email").regexp(".*@example.com")
26
- * .and(Condition.attribute("lastLogin").gt(new Date("2023-01-01")));
27
- * @mermaid
28
- * sequenceDiagram
29
- * participant Dev
30
- * participant Condition
31
- * Dev->>Condition: builder().attribute("age").gt(18)
32
- * Condition-->>Dev: Condition(age > 18)
33
- * Dev->>Condition: .and(attribute("status").eq("active"))
34
- * Condition-->>Dev: Condition((age > 18) AND (status = "active"))
35
- */
36
- export declare class Condition<M extends Model<any>> extends Model<InferAsync<M>> {
37
- protected attr1?: string | Condition<M>;
38
- protected operator?: Operator | GroupOperator;
39
- protected comparison?: any;
40
- private constructor();
41
- private constructor();
42
- /**
43
- * @description Combines this condition with another using logical AND
44
- * @summary Joins two conditions with an AND operator, requiring both to be true
45
- * @param {Condition<M>} condition - The condition to combine with this one
46
- * @return {Condition<M>} A new condition representing the AND operation
47
- */
48
- and(condition: Condition<M>): Condition<M>;
49
- /**
50
- * @description Combines this condition with another using logical OR
51
- * @summary Joins two conditions with an OR operator, requiring at least one to be true
52
- * @param {Condition<M>} condition - The condition to combine with this one
53
- * @return {Condition<M>} A new condition representing the OR operation
54
- */
55
- or(condition: Condition<M>): Condition<M>;
56
- /**
57
- * @description Creates a negation condition
58
- * @summary Excludes a value from the result by applying a NOT operator
59
- * @param {any} val - The value to negate
60
- * @return {Condition<M>} A new condition representing the NOT operation
61
- */
62
- not(val: any): Condition<M>;
63
- /**
64
- * @description Validates the condition and checks for errors
65
- * @summary Extends the base validation to ensure the condition is properly formed
66
- * @param {...string[]} exceptions - Fields to exclude from validation
67
- * @return {ModelErrorDefinition | undefined} Error definition if validation fails, undefined otherwise
68
- */
69
- hasErrors(...exceptions: string[]): ConditionalAsync<InferAsync<M>, ModelErrorDefinition | undefined>;
70
- /**
71
- * @description Creates a new condition that combines two conditions with logical AND
72
- * @summary Static method that joins two conditions with an AND operator, requiring both to be true
73
- * @template M - The model type this condition operates on
74
- * @param {Condition<M>} condition1 - The first condition
75
- * @param {Condition<M>} condition2 - The second condition
76
- * @return {Condition<M>} A new condition representing the AND operation
77
- */
78
- static and<M extends Model>(condition1: Condition<M>, condition2: Condition<M>): Condition<M>;
79
- /**
80
- * @description Creates a new condition that combines two conditions with logical OR
81
- * @summary Static method that joins two conditions with an OR operator, requiring at least one to be true
82
- * @template M - The model type this condition operates on
83
- * @param {Condition<M>} condition1 - The first condition
84
- * @param {Condition<M>} condition2 - The second condition
85
- * @return {Condition<M>} A new condition representing the OR operation
86
- */
87
- static or<M extends Model>(condition1: Condition<M>, condition2: Condition<M>): Condition<M>;
88
- /**
89
- * @description Creates a new condition that groups two conditions with a specified operator
90
- * @summary Private static method that combines two conditions using the specified group operator
91
- * @template M - The model type this condition operates on
92
- * @param {Condition<M>} condition1 - The first condition
93
- * @param {GroupOperator} operator - The group operator to use (AND, OR)
94
- * @param {Condition<M>} condition2 - The second condition
95
- * @return {Condition<M>} A new condition representing the grouped operation
96
- */
97
- private static group;
98
- /**
99
- * @description Creates a condition builder for a specific model attribute
100
- * @summary Static method that initializes a condition builder with the specified attribute
101
- * @template M - The model type this condition operates on
102
- * @param attr - The model attribute to build a condition for
103
- * @return {AttributeOption<M>} A condition builder initialized with the attribute
104
- */
105
- static attribute<M extends Model>(attr: keyof M): AttributeOption<M>;
106
- /**
107
- * @description Alias for the attribute method
108
- * @summary Shorthand method that initializes a condition builder with the specified attribute
109
- * @template M - The model type this condition operates on
110
- * @param attr - The model attribute to build a condition for
111
- * @return {AttributeOption<M>} A condition builder initialized with the attribute
112
- */
113
- static attr<M extends Model>(attr: keyof M): AttributeOption<M>;
114
- /**
115
- * @description Provides a fluent API to build query conditions
116
- * @summary A builder class that simplifies the creation of database query conditions
117
- * with a chainable interface for setting attributes and operators
118
- * @template M - The model type this condition builder operates on
119
- * @class ConditionBuilder
120
- */
121
- private static Builder;
122
- /**
123
- * @description Creates a new condition builder
124
- * @summary Factory method that returns a new instance of the condition builder
125
- * @template M - The model type this condition builder will operate on
126
- * @return {ConditionBuilderOption<M>} A new condition builder instance
127
- */
128
- static builder<M extends Model>(): ConditionBuilderOption<M>;
129
- static from(obj: ModelArg<Condition<any>>): Condition<Model<any>>;
130
- }
131
- export {};