@warlock.js/cascade 4.0.157 → 4.0.158

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 (689) hide show
  1. package/package.json +4 -4
  2. package/cjs/context/database-data-source-context.d.ts +0 -29
  3. package/cjs/context/database-data-source-context.d.ts.map +0 -1
  4. package/cjs/context/database-data-source-context.js +0 -28
  5. package/cjs/context/database-data-source-context.js.map +0 -1
  6. package/cjs/context/database-transaction-context.d.ts +0 -35
  7. package/cjs/context/database-transaction-context.d.ts.map +0 -1
  8. package/cjs/context/database-transaction-context.js +0 -40
  9. package/cjs/context/database-transaction-context.js.map +0 -1
  10. package/cjs/contracts/database-driver.contract.d.ts +0 -450
  11. package/cjs/contracts/database-driver.contract.d.ts.map +0 -1
  12. package/cjs/contracts/database-id-generator.contract.d.ts +0 -109
  13. package/cjs/contracts/database-id-generator.contract.d.ts.map +0 -1
  14. package/cjs/contracts/database-remover.contract.d.ts +0 -104
  15. package/cjs/contracts/database-remover.contract.d.ts.map +0 -1
  16. package/cjs/contracts/database-restorer.contract.d.ts +0 -143
  17. package/cjs/contracts/database-restorer.contract.d.ts.map +0 -1
  18. package/cjs/contracts/database-writer.contract.d.ts +0 -119
  19. package/cjs/contracts/database-writer.contract.d.ts.map +0 -1
  20. package/cjs/contracts/driver-blueprint.contract.d.ts +0 -49
  21. package/cjs/contracts/driver-blueprint.contract.d.ts.map +0 -1
  22. package/cjs/contracts/index.d.ts +0 -10
  23. package/cjs/contracts/index.d.ts.map +0 -1
  24. package/cjs/contracts/migration-driver.contract.d.ts +0 -522
  25. package/cjs/contracts/migration-driver.contract.d.ts.map +0 -1
  26. package/cjs/contracts/query-builder.contract.d.ts +0 -1609
  27. package/cjs/contracts/query-builder.contract.d.ts.map +0 -1
  28. package/cjs/contracts/sync-adapter.contract.d.ts +0 -58
  29. package/cjs/contracts/sync-adapter.contract.d.ts.map +0 -1
  30. package/cjs/data-source/data-source-registry.d.ts +0 -108
  31. package/cjs/data-source/data-source-registry.d.ts.map +0 -1
  32. package/cjs/data-source/data-source-registry.js +0 -145
  33. package/cjs/data-source/data-source-registry.js.map +0 -1
  34. package/cjs/data-source/data-source.d.ts +0 -147
  35. package/cjs/data-source/data-source.d.ts.map +0 -1
  36. package/cjs/data-source/data-source.js +0 -83
  37. package/cjs/data-source/data-source.js.map +0 -1
  38. package/cjs/database-dirty-tracker.d.ts +0 -252
  39. package/cjs/database-dirty-tracker.d.ts.map +0 -1
  40. package/cjs/database-dirty-tracker.js +0 -386
  41. package/cjs/database-dirty-tracker.js.map +0 -1
  42. package/cjs/drivers/mongodb/mongodb-blueprint.d.ts +0 -30
  43. package/cjs/drivers/mongodb/mongodb-blueprint.d.ts.map +0 -1
  44. package/cjs/drivers/mongodb/mongodb-blueprint.js +0 -51
  45. package/cjs/drivers/mongodb/mongodb-blueprint.js.map +0 -1
  46. package/cjs/drivers/mongodb/mongodb-driver.d.ts +0 -324
  47. package/cjs/drivers/mongodb/mongodb-driver.d.ts.map +0 -1
  48. package/cjs/drivers/mongodb/mongodb-driver.js +0 -799
  49. package/cjs/drivers/mongodb/mongodb-driver.js.map +0 -1
  50. package/cjs/drivers/mongodb/mongodb-id-generator.d.ts +0 -116
  51. package/cjs/drivers/mongodb/mongodb-id-generator.d.ts.map +0 -1
  52. package/cjs/drivers/mongodb/mongodb-id-generator.js +0 -149
  53. package/cjs/drivers/mongodb/mongodb-id-generator.js.map +0 -1
  54. package/cjs/drivers/mongodb/mongodb-migration-driver.d.ts +0 -317
  55. package/cjs/drivers/mongodb/mongodb-migration-driver.d.ts.map +0 -1
  56. package/cjs/drivers/mongodb/mongodb-migration-driver.js +0 -666
  57. package/cjs/drivers/mongodb/mongodb-migration-driver.js.map +0 -1
  58. package/cjs/drivers/mongodb/mongodb-query-builder.d.ts +0 -1122
  59. package/cjs/drivers/mongodb/mongodb-query-builder.d.ts.map +0 -1
  60. package/cjs/drivers/mongodb/mongodb-query-builder.js +0 -1988
  61. package/cjs/drivers/mongodb/mongodb-query-builder.js.map +0 -1
  62. package/cjs/drivers/mongodb/mongodb-query-operations.d.ts +0 -226
  63. package/cjs/drivers/mongodb/mongodb-query-operations.d.ts.map +0 -1
  64. package/cjs/drivers/mongodb/mongodb-query-operations.js +0 -270
  65. package/cjs/drivers/mongodb/mongodb-query-operations.js.map +0 -1
  66. package/cjs/drivers/mongodb/mongodb-query-parser.d.ts +0 -262
  67. package/cjs/drivers/mongodb/mongodb-query-parser.d.ts.map +0 -1
  68. package/cjs/drivers/mongodb/mongodb-query-parser.js +0 -1351
  69. package/cjs/drivers/mongodb/mongodb-query-parser.js.map +0 -1
  70. package/cjs/drivers/mongodb/mongodb-sync-adapter.d.ts +0 -79
  71. package/cjs/drivers/mongodb/mongodb-sync-adapter.d.ts.map +0 -1
  72. package/cjs/drivers/mongodb/mongodb-sync-adapter.js +0 -146
  73. package/cjs/drivers/mongodb/mongodb-sync-adapter.js.map +0 -1
  74. package/cjs/drivers/mongodb/types.d.ts +0 -43
  75. package/cjs/drivers/mongodb/types.d.ts.map +0 -1
  76. package/cjs/drivers/postgres/index.d.ts +0 -16
  77. package/cjs/drivers/postgres/index.d.ts.map +0 -1
  78. package/cjs/drivers/postgres/postgres-blueprint.d.ts +0 -64
  79. package/cjs/drivers/postgres/postgres-blueprint.d.ts.map +0 -1
  80. package/cjs/drivers/postgres/postgres-blueprint.js +0 -121
  81. package/cjs/drivers/postgres/postgres-blueprint.js.map +0 -1
  82. package/cjs/drivers/postgres/postgres-dialect.d.ts +0 -136
  83. package/cjs/drivers/postgres/postgres-dialect.d.ts.map +0 -1
  84. package/cjs/drivers/postgres/postgres-dialect.js +0 -268
  85. package/cjs/drivers/postgres/postgres-dialect.js.map +0 -1
  86. package/cjs/drivers/postgres/postgres-driver.d.ts +0 -432
  87. package/cjs/drivers/postgres/postgres-driver.d.ts.map +0 -1
  88. package/cjs/drivers/postgres/postgres-driver.js +0 -965
  89. package/cjs/drivers/postgres/postgres-driver.js.map +0 -1
  90. package/cjs/drivers/postgres/postgres-migration-driver.d.ts +0 -397
  91. package/cjs/drivers/postgres/postgres-migration-driver.d.ts.map +0 -1
  92. package/cjs/drivers/postgres/postgres-migration-driver.js +0 -900
  93. package/cjs/drivers/postgres/postgres-migration-driver.js.map +0 -1
  94. package/cjs/drivers/postgres/postgres-query-builder.d.ts +0 -254
  95. package/cjs/drivers/postgres/postgres-query-builder.d.ts.map +0 -1
  96. package/cjs/drivers/postgres/postgres-query-builder.js +0 -933
  97. package/cjs/drivers/postgres/postgres-query-builder.js.map +0 -1
  98. package/cjs/drivers/postgres/postgres-query-parser.d.ts +0 -328
  99. package/cjs/drivers/postgres/postgres-query-parser.d.ts.map +0 -1
  100. package/cjs/drivers/postgres/postgres-query-parser.js +0 -864
  101. package/cjs/drivers/postgres/postgres-query-parser.js.map +0 -1
  102. package/cjs/drivers/postgres/postgres-sql-serializer.d.ts +0 -37
  103. package/cjs/drivers/postgres/postgres-sql-serializer.d.ts.map +0 -1
  104. package/cjs/drivers/postgres/postgres-sql-serializer.js +0 -400
  105. package/cjs/drivers/postgres/postgres-sql-serializer.js.map +0 -1
  106. package/cjs/drivers/postgres/postgres-sync-adapter.d.ts +0 -83
  107. package/cjs/drivers/postgres/postgres-sync-adapter.d.ts.map +0 -1
  108. package/cjs/drivers/postgres/postgres-sync-adapter.js +0 -197
  109. package/cjs/drivers/postgres/postgres-sync-adapter.js.map +0 -1
  110. package/cjs/drivers/postgres/types.d.ts +0 -142
  111. package/cjs/drivers/postgres/types.d.ts.map +0 -1
  112. package/cjs/drivers/sql/index.d.ts +0 -10
  113. package/cjs/drivers/sql/index.d.ts.map +0 -1
  114. package/cjs/drivers/sql/sql-dialect.contract.d.ts +0 -204
  115. package/cjs/drivers/sql/sql-dialect.contract.d.ts.map +0 -1
  116. package/cjs/drivers/sql/sql-types.d.ts +0 -202
  117. package/cjs/drivers/sql/sql-types.d.ts.map +0 -1
  118. package/cjs/errors/missing-data-source.error.d.ts +0 -22
  119. package/cjs/errors/missing-data-source.error.d.ts.map +0 -1
  120. package/cjs/errors/missing-data-source.error.js +0 -29
  121. package/cjs/errors/missing-data-source.error.js.map +0 -1
  122. package/cjs/errors/transaction-rollback.error.d.ts +0 -20
  123. package/cjs/errors/transaction-rollback.error.d.ts.map +0 -1
  124. package/cjs/errors/transaction-rollback.error.js +0 -27
  125. package/cjs/errors/transaction-rollback.error.js.map +0 -1
  126. package/cjs/events/model-events.d.ts +0 -231
  127. package/cjs/events/model-events.d.ts.map +0 -1
  128. package/cjs/events/model-events.js +0 -259
  129. package/cjs/events/model-events.js.map +0 -1
  130. package/cjs/expressions/aggregate-expressions.d.ts +0 -215
  131. package/cjs/expressions/aggregate-expressions.d.ts.map +0 -1
  132. package/cjs/expressions/aggregate-expressions.js +0 -221
  133. package/cjs/expressions/aggregate-expressions.js.map +0 -1
  134. package/cjs/expressions/index.d.ts +0 -2
  135. package/cjs/expressions/index.d.ts.map +0 -1
  136. package/cjs/index.d.ts +0 -45
  137. package/cjs/index.d.ts.map +0 -1
  138. package/cjs/index.js +0 -1
  139. package/cjs/index.js.map +0 -1
  140. package/cjs/migration/column-builder.d.ts +0 -417
  141. package/cjs/migration/column-builder.d.ts.map +0 -1
  142. package/cjs/migration/column-builder.js +0 -586
  143. package/cjs/migration/column-builder.js.map +0 -1
  144. package/cjs/migration/column-helpers.d.ts +0 -275
  145. package/cjs/migration/column-helpers.d.ts.map +0 -1
  146. package/cjs/migration/column-helpers.js +0 -389
  147. package/cjs/migration/column-helpers.js.map +0 -1
  148. package/cjs/migration/foreign-key-builder.d.ts +0 -103
  149. package/cjs/migration/foreign-key-builder.d.ts.map +0 -1
  150. package/cjs/migration/foreign-key-builder.js +0 -121
  151. package/cjs/migration/foreign-key-builder.js.map +0 -1
  152. package/cjs/migration/index.d.ts +0 -7
  153. package/cjs/migration/index.d.ts.map +0 -1
  154. package/cjs/migration/migration-runner.d.ts +0 -278
  155. package/cjs/migration/migration-runner.d.ts.map +0 -1
  156. package/cjs/migration/migration-runner.js +0 -815
  157. package/cjs/migration/migration-runner.js.map +0 -1
  158. package/cjs/migration/migration.d.ts +0 -1992
  159. package/cjs/migration/migration.d.ts.map +0 -1
  160. package/cjs/migration/migration.js +0 -2162
  161. package/cjs/migration/migration.js.map +0 -1
  162. package/cjs/migration/sql-grammar.d.ts +0 -61
  163. package/cjs/migration/sql-grammar.d.ts.map +0 -1
  164. package/cjs/migration/sql-grammar.js +0 -164
  165. package/cjs/migration/sql-grammar.js.map +0 -1
  166. package/cjs/migration/sql-serializer.d.ts +0 -22
  167. package/cjs/migration/sql-serializer.d.ts.map +0 -1
  168. package/cjs/migration/sql-serializer.js +0 -26
  169. package/cjs/migration/sql-serializer.js.map +0 -1
  170. package/cjs/migration/types.d.ts +0 -155
  171. package/cjs/migration/types.d.ts.map +0 -1
  172. package/cjs/model/methods/accessor-methods.d.ts +0 -13
  173. package/cjs/model/methods/accessor-methods.d.ts.map +0 -1
  174. package/cjs/model/methods/accessor-methods.js +0 -51
  175. package/cjs/model/methods/accessor-methods.js.map +0 -1
  176. package/cjs/model/methods/delete-methods.d.ts +0 -10
  177. package/cjs/model/methods/delete-methods.d.ts.map +0 -1
  178. package/cjs/model/methods/delete-methods.js +0 -10
  179. package/cjs/model/methods/delete-methods.js.map +0 -1
  180. package/cjs/model/methods/dirty-methods.d.ts +0 -10
  181. package/cjs/model/methods/dirty-methods.d.ts.map +0 -1
  182. package/cjs/model/methods/dirty-methods.js +0 -15
  183. package/cjs/model/methods/dirty-methods.js.map +0 -1
  184. package/cjs/model/methods/hydration-methods.d.ts +0 -10
  185. package/cjs/model/methods/hydration-methods.d.ts.map +0 -1
  186. package/cjs/model/methods/hydration-methods.js +0 -57
  187. package/cjs/model/methods/hydration-methods.js.map +0 -1
  188. package/cjs/model/methods/instance-event-methods.d.ts +0 -7
  189. package/cjs/model/methods/instance-event-methods.d.ts.map +0 -1
  190. package/cjs/model/methods/instance-event-methods.js +0 -15
  191. package/cjs/model/methods/instance-event-methods.js.map +0 -1
  192. package/cjs/model/methods/meta-methods.d.ts +0 -7
  193. package/cjs/model/methods/meta-methods.d.ts.map +0 -1
  194. package/cjs/model/methods/meta-methods.js +0 -78
  195. package/cjs/model/methods/meta-methods.js.map +0 -1
  196. package/cjs/model/methods/query-methods.d.ts +0 -24
  197. package/cjs/model/methods/query-methods.d.ts.map +0 -1
  198. package/cjs/model/methods/query-methods.js +0 -161
  199. package/cjs/model/methods/query-methods.js.map +0 -1
  200. package/cjs/model/methods/restore-methods.d.ts +0 -10
  201. package/cjs/model/methods/restore-methods.d.ts.map +0 -1
  202. package/cjs/model/methods/restore-methods.js +0 -13
  203. package/cjs/model/methods/restore-methods.js.map +0 -1
  204. package/cjs/model/methods/scope-methods.d.ts +0 -7
  205. package/cjs/model/methods/scope-methods.d.ts.map +0 -1
  206. package/cjs/model/methods/scope-methods.js +0 -15
  207. package/cjs/model/methods/scope-methods.js.map +0 -1
  208. package/cjs/model/methods/serialization-methods.d.ts +0 -3
  209. package/cjs/model/methods/serialization-methods.d.ts.map +0 -1
  210. package/cjs/model/methods/serialization-methods.js +0 -27
  211. package/cjs/model/methods/serialization-methods.js.map +0 -1
  212. package/cjs/model/methods/static-event-methods.d.ts +0 -9
  213. package/cjs/model/methods/static-event-methods.d.ts.map +0 -1
  214. package/cjs/model/methods/static-event-methods.js +0 -29
  215. package/cjs/model/methods/static-event-methods.js.map +0 -1
  216. package/cjs/model/methods/write-methods.d.ts +0 -10
  217. package/cjs/model/methods/write-methods.d.ts.map +0 -1
  218. package/cjs/model/methods/write-methods.js +0 -52
  219. package/cjs/model/methods/write-methods.js.map +0 -1
  220. package/cjs/model/model.d.ts +0 -1650
  221. package/cjs/model/model.d.ts.map +0 -1
  222. package/cjs/model/model.js +0 -1657
  223. package/cjs/model/model.js.map +0 -1
  224. package/cjs/model/model.types.d.ts +0 -44
  225. package/cjs/model/model.types.d.ts.map +0 -1
  226. package/cjs/model/register-model.d.ts +0 -81
  227. package/cjs/model/register-model.d.ts.map +0 -1
  228. package/cjs/model/register-model.js +0 -94
  229. package/cjs/model/register-model.js.map +0 -1
  230. package/cjs/query-builder/query-builder.d.ts +0 -556
  231. package/cjs/query-builder/query-builder.d.ts.map +0 -1
  232. package/cjs/query-builder/query-builder.js +0 -1070
  233. package/cjs/query-builder/query-builder.js.map +0 -1
  234. package/cjs/relations/helpers.d.ts +0 -156
  235. package/cjs/relations/helpers.d.ts.map +0 -1
  236. package/cjs/relations/helpers.js +0 -201
  237. package/cjs/relations/helpers.js.map +0 -1
  238. package/cjs/relations/index.d.ts +0 -35
  239. package/cjs/relations/index.d.ts.map +0 -1
  240. package/cjs/relations/pivot-operations.d.ts +0 -160
  241. package/cjs/relations/pivot-operations.d.ts.map +0 -1
  242. package/cjs/relations/pivot-operations.js +0 -293
  243. package/cjs/relations/pivot-operations.js.map +0 -1
  244. package/cjs/relations/relation-hydrator.d.ts +0 -68
  245. package/cjs/relations/relation-hydrator.d.ts.map +0 -1
  246. package/cjs/relations/relation-hydrator.js +0 -81
  247. package/cjs/relations/relation-hydrator.js.map +0 -1
  248. package/cjs/relations/relation-loader.d.ts +0 -194
  249. package/cjs/relations/relation-loader.d.ts.map +0 -1
  250. package/cjs/relations/relation-loader.js +0 -466
  251. package/cjs/relations/relation-loader.js.map +0 -1
  252. package/cjs/relations/types.d.ts +0 -306
  253. package/cjs/relations/types.d.ts.map +0 -1
  254. package/cjs/remover/database-remover.d.ts +0 -100
  255. package/cjs/remover/database-remover.d.ts.map +0 -1
  256. package/cjs/remover/database-remover.js +0 -214
  257. package/cjs/remover/database-remover.js.map +0 -1
  258. package/cjs/restorer/database-restorer.d.ts +0 -131
  259. package/cjs/restorer/database-restorer.d.ts.map +0 -1
  260. package/cjs/restorer/database-restorer.js +0 -434
  261. package/cjs/restorer/database-restorer.js.map +0 -1
  262. package/cjs/sql-database-dirty-tracker.d.ts +0 -13
  263. package/cjs/sql-database-dirty-tracker.d.ts.map +0 -1
  264. package/cjs/sql-database-dirty-tracker.js +0 -14
  265. package/cjs/sql-database-dirty-tracker.js.map +0 -1
  266. package/cjs/sync/index.d.ts +0 -12
  267. package/cjs/sync/index.d.ts.map +0 -1
  268. package/cjs/sync/model-events.d.ts +0 -62
  269. package/cjs/sync/model-events.d.ts.map +0 -1
  270. package/cjs/sync/model-events.js +0 -49
  271. package/cjs/sync/model-events.js.map +0 -1
  272. package/cjs/sync/model-sync-operation.d.ts +0 -163
  273. package/cjs/sync/model-sync-operation.d.ts.map +0 -1
  274. package/cjs/sync/model-sync-operation.js +0 -292
  275. package/cjs/sync/model-sync-operation.js.map +0 -1
  276. package/cjs/sync/model-sync.d.ts +0 -130
  277. package/cjs/sync/model-sync.d.ts.map +0 -1
  278. package/cjs/sync/model-sync.js +0 -178
  279. package/cjs/sync/model-sync.js.map +0 -1
  280. package/cjs/sync/sync-context.d.ts +0 -70
  281. package/cjs/sync/sync-context.d.ts.map +0 -1
  282. package/cjs/sync/sync-context.js +0 -101
  283. package/cjs/sync/sync-context.js.map +0 -1
  284. package/cjs/sync/sync-manager.d.ts +0 -213
  285. package/cjs/sync/sync-manager.d.ts.map +0 -1
  286. package/cjs/sync/sync-manager.js +0 -689
  287. package/cjs/sync/sync-manager.js.map +0 -1
  288. package/cjs/sync/types.d.ts +0 -289
  289. package/cjs/sync/types.d.ts.map +0 -1
  290. package/cjs/test-migrations/test-enhanced-features.migration.d.ts +0 -15
  291. package/cjs/test-migrations/test-enhanced-features.migration.d.ts.map +0 -1
  292. package/cjs/types.d.ts +0 -371
  293. package/cjs/types.d.ts.map +0 -1
  294. package/cjs/utils/connect-to-database.d.ts +0 -300
  295. package/cjs/utils/connect-to-database.d.ts.map +0 -1
  296. package/cjs/utils/connect-to-database.js +0 -128
  297. package/cjs/utils/connect-to-database.js.map +0 -1
  298. package/cjs/utils/database-writer.utils.d.ts +0 -15
  299. package/cjs/utils/database-writer.utils.d.ts.map +0 -1
  300. package/cjs/utils/database-writer.utils.js +0 -14
  301. package/cjs/utils/database-writer.utils.js.map +0 -1
  302. package/cjs/utils/define-model.js +0 -100
  303. package/cjs/utils/define-model.js.map +0 -1
  304. package/cjs/utils/is-valid-date-value.d.ts +0 -5
  305. package/cjs/utils/is-valid-date-value.d.ts.map +0 -1
  306. package/cjs/utils/is-valid-date-value.js +0 -25
  307. package/cjs/utils/is-valid-date-value.js.map +0 -1
  308. package/cjs/utils/once-connected.d.ts +0 -146
  309. package/cjs/utils/once-connected.d.ts.map +0 -1
  310. package/cjs/utils/once-connected.js +0 -251
  311. package/cjs/utils/once-connected.js.map +0 -1
  312. package/cjs/validation/database-seal-plugins.d.ts +0 -12
  313. package/cjs/validation/database-seal-plugins.d.ts.map +0 -1
  314. package/cjs/validation/database-seal-plugins.js +0 -1
  315. package/cjs/validation/database-seal-plugins.js.map +0 -1
  316. package/cjs/validation/database-writer-validation-error.d.ts +0 -97
  317. package/cjs/validation/database-writer-validation-error.d.ts.map +0 -1
  318. package/cjs/validation/database-writer-validation-error.js +0 -160
  319. package/cjs/validation/database-writer-validation-error.js.map +0 -1
  320. package/cjs/validation/index.d.ts +0 -3
  321. package/cjs/validation/index.d.ts.map +0 -1
  322. package/cjs/validation/mutators/embed-mutator.d.ts +0 -9
  323. package/cjs/validation/mutators/embed-mutator.d.ts.map +0 -1
  324. package/cjs/validation/mutators/embed-mutator.js +0 -33
  325. package/cjs/validation/mutators/embed-mutator.js.map +0 -1
  326. package/cjs/validation/plugins/embed-validator-plugin.d.ts +0 -24
  327. package/cjs/validation/plugins/embed-validator-plugin.d.ts.map +0 -1
  328. package/cjs/validation/plugins/embed-validator-plugin.js +0 -18
  329. package/cjs/validation/plugins/embed-validator-plugin.js.map +0 -1
  330. package/cjs/validation/rules/database-model-rule.d.ts +0 -7
  331. package/cjs/validation/rules/database-model-rule.d.ts.map +0 -1
  332. package/cjs/validation/rules/database-model-rule.js +0 -27
  333. package/cjs/validation/rules/database-model-rule.js.map +0 -1
  334. package/cjs/validation/transformers/embed-model-transformer.d.ts +0 -3
  335. package/cjs/validation/transformers/embed-model-transformer.d.ts.map +0 -1
  336. package/cjs/validation/transformers/embed-model-transformer.js +0 -18
  337. package/cjs/validation/transformers/embed-model-transformer.js.map +0 -1
  338. package/cjs/validation/validators/embed-validator.d.ts +0 -21
  339. package/cjs/validation/validators/embed-validator.d.ts.map +0 -1
  340. package/cjs/validation/validators/embed-validator.js +0 -43
  341. package/cjs/validation/validators/embed-validator.js.map +0 -1
  342. package/cjs/writer/database-writer.d.ts +0 -181
  343. package/cjs/writer/database-writer.d.ts.map +0 -1
  344. package/cjs/writer/database-writer.js +0 -407
  345. package/cjs/writer/database-writer.js.map +0 -1
  346. package/esm/context/database-data-source-context.d.ts +0 -29
  347. package/esm/context/database-data-source-context.d.ts.map +0 -1
  348. package/esm/context/database-data-source-context.js +0 -28
  349. package/esm/context/database-data-source-context.js.map +0 -1
  350. package/esm/context/database-transaction-context.d.ts +0 -35
  351. package/esm/context/database-transaction-context.d.ts.map +0 -1
  352. package/esm/context/database-transaction-context.js +0 -40
  353. package/esm/context/database-transaction-context.js.map +0 -1
  354. package/esm/contracts/database-driver.contract.d.ts +0 -450
  355. package/esm/contracts/database-driver.contract.d.ts.map +0 -1
  356. package/esm/contracts/database-id-generator.contract.d.ts +0 -109
  357. package/esm/contracts/database-id-generator.contract.d.ts.map +0 -1
  358. package/esm/contracts/database-remover.contract.d.ts +0 -104
  359. package/esm/contracts/database-remover.contract.d.ts.map +0 -1
  360. package/esm/contracts/database-restorer.contract.d.ts +0 -143
  361. package/esm/contracts/database-restorer.contract.d.ts.map +0 -1
  362. package/esm/contracts/database-writer.contract.d.ts +0 -119
  363. package/esm/contracts/database-writer.contract.d.ts.map +0 -1
  364. package/esm/contracts/driver-blueprint.contract.d.ts +0 -49
  365. package/esm/contracts/driver-blueprint.contract.d.ts.map +0 -1
  366. package/esm/contracts/index.d.ts +0 -10
  367. package/esm/contracts/index.d.ts.map +0 -1
  368. package/esm/contracts/migration-driver.contract.d.ts +0 -522
  369. package/esm/contracts/migration-driver.contract.d.ts.map +0 -1
  370. package/esm/contracts/query-builder.contract.d.ts +0 -1609
  371. package/esm/contracts/query-builder.contract.d.ts.map +0 -1
  372. package/esm/contracts/sync-adapter.contract.d.ts +0 -58
  373. package/esm/contracts/sync-adapter.contract.d.ts.map +0 -1
  374. package/esm/data-source/data-source-registry.d.ts +0 -108
  375. package/esm/data-source/data-source-registry.d.ts.map +0 -1
  376. package/esm/data-source/data-source-registry.js +0 -145
  377. package/esm/data-source/data-source-registry.js.map +0 -1
  378. package/esm/data-source/data-source.d.ts +0 -147
  379. package/esm/data-source/data-source.d.ts.map +0 -1
  380. package/esm/data-source/data-source.js +0 -83
  381. package/esm/data-source/data-source.js.map +0 -1
  382. package/esm/database-dirty-tracker.d.ts +0 -252
  383. package/esm/database-dirty-tracker.d.ts.map +0 -1
  384. package/esm/database-dirty-tracker.js +0 -386
  385. package/esm/database-dirty-tracker.js.map +0 -1
  386. package/esm/drivers/mongodb/mongodb-blueprint.d.ts +0 -30
  387. package/esm/drivers/mongodb/mongodb-blueprint.d.ts.map +0 -1
  388. package/esm/drivers/mongodb/mongodb-blueprint.js +0 -51
  389. package/esm/drivers/mongodb/mongodb-blueprint.js.map +0 -1
  390. package/esm/drivers/mongodb/mongodb-driver.d.ts +0 -324
  391. package/esm/drivers/mongodb/mongodb-driver.d.ts.map +0 -1
  392. package/esm/drivers/mongodb/mongodb-driver.js +0 -799
  393. package/esm/drivers/mongodb/mongodb-driver.js.map +0 -1
  394. package/esm/drivers/mongodb/mongodb-id-generator.d.ts +0 -116
  395. package/esm/drivers/mongodb/mongodb-id-generator.d.ts.map +0 -1
  396. package/esm/drivers/mongodb/mongodb-id-generator.js +0 -149
  397. package/esm/drivers/mongodb/mongodb-id-generator.js.map +0 -1
  398. package/esm/drivers/mongodb/mongodb-migration-driver.d.ts +0 -317
  399. package/esm/drivers/mongodb/mongodb-migration-driver.d.ts.map +0 -1
  400. package/esm/drivers/mongodb/mongodb-migration-driver.js +0 -666
  401. package/esm/drivers/mongodb/mongodb-migration-driver.js.map +0 -1
  402. package/esm/drivers/mongodb/mongodb-query-builder.d.ts +0 -1122
  403. package/esm/drivers/mongodb/mongodb-query-builder.d.ts.map +0 -1
  404. package/esm/drivers/mongodb/mongodb-query-builder.js +0 -1988
  405. package/esm/drivers/mongodb/mongodb-query-builder.js.map +0 -1
  406. package/esm/drivers/mongodb/mongodb-query-operations.d.ts +0 -226
  407. package/esm/drivers/mongodb/mongodb-query-operations.d.ts.map +0 -1
  408. package/esm/drivers/mongodb/mongodb-query-operations.js +0 -270
  409. package/esm/drivers/mongodb/mongodb-query-operations.js.map +0 -1
  410. package/esm/drivers/mongodb/mongodb-query-parser.d.ts +0 -262
  411. package/esm/drivers/mongodb/mongodb-query-parser.d.ts.map +0 -1
  412. package/esm/drivers/mongodb/mongodb-query-parser.js +0 -1351
  413. package/esm/drivers/mongodb/mongodb-query-parser.js.map +0 -1
  414. package/esm/drivers/mongodb/mongodb-sync-adapter.d.ts +0 -79
  415. package/esm/drivers/mongodb/mongodb-sync-adapter.d.ts.map +0 -1
  416. package/esm/drivers/mongodb/mongodb-sync-adapter.js +0 -146
  417. package/esm/drivers/mongodb/mongodb-sync-adapter.js.map +0 -1
  418. package/esm/drivers/mongodb/types.d.ts +0 -43
  419. package/esm/drivers/mongodb/types.d.ts.map +0 -1
  420. package/esm/drivers/postgres/index.d.ts +0 -16
  421. package/esm/drivers/postgres/index.d.ts.map +0 -1
  422. package/esm/drivers/postgres/postgres-blueprint.d.ts +0 -64
  423. package/esm/drivers/postgres/postgres-blueprint.d.ts.map +0 -1
  424. package/esm/drivers/postgres/postgres-blueprint.js +0 -121
  425. package/esm/drivers/postgres/postgres-blueprint.js.map +0 -1
  426. package/esm/drivers/postgres/postgres-dialect.d.ts +0 -136
  427. package/esm/drivers/postgres/postgres-dialect.d.ts.map +0 -1
  428. package/esm/drivers/postgres/postgres-dialect.js +0 -268
  429. package/esm/drivers/postgres/postgres-dialect.js.map +0 -1
  430. package/esm/drivers/postgres/postgres-driver.d.ts +0 -432
  431. package/esm/drivers/postgres/postgres-driver.d.ts.map +0 -1
  432. package/esm/drivers/postgres/postgres-driver.js +0 -965
  433. package/esm/drivers/postgres/postgres-driver.js.map +0 -1
  434. package/esm/drivers/postgres/postgres-migration-driver.d.ts +0 -397
  435. package/esm/drivers/postgres/postgres-migration-driver.d.ts.map +0 -1
  436. package/esm/drivers/postgres/postgres-migration-driver.js +0 -900
  437. package/esm/drivers/postgres/postgres-migration-driver.js.map +0 -1
  438. package/esm/drivers/postgres/postgres-query-builder.d.ts +0 -254
  439. package/esm/drivers/postgres/postgres-query-builder.d.ts.map +0 -1
  440. package/esm/drivers/postgres/postgres-query-builder.js +0 -933
  441. package/esm/drivers/postgres/postgres-query-builder.js.map +0 -1
  442. package/esm/drivers/postgres/postgres-query-parser.d.ts +0 -328
  443. package/esm/drivers/postgres/postgres-query-parser.d.ts.map +0 -1
  444. package/esm/drivers/postgres/postgres-query-parser.js +0 -864
  445. package/esm/drivers/postgres/postgres-query-parser.js.map +0 -1
  446. package/esm/drivers/postgres/postgres-sql-serializer.d.ts +0 -37
  447. package/esm/drivers/postgres/postgres-sql-serializer.d.ts.map +0 -1
  448. package/esm/drivers/postgres/postgres-sql-serializer.js +0 -400
  449. package/esm/drivers/postgres/postgres-sql-serializer.js.map +0 -1
  450. package/esm/drivers/postgres/postgres-sync-adapter.d.ts +0 -83
  451. package/esm/drivers/postgres/postgres-sync-adapter.d.ts.map +0 -1
  452. package/esm/drivers/postgres/postgres-sync-adapter.js +0 -197
  453. package/esm/drivers/postgres/postgres-sync-adapter.js.map +0 -1
  454. package/esm/drivers/postgres/types.d.ts +0 -142
  455. package/esm/drivers/postgres/types.d.ts.map +0 -1
  456. package/esm/drivers/sql/index.d.ts +0 -10
  457. package/esm/drivers/sql/index.d.ts.map +0 -1
  458. package/esm/drivers/sql/sql-dialect.contract.d.ts +0 -204
  459. package/esm/drivers/sql/sql-dialect.contract.d.ts.map +0 -1
  460. package/esm/drivers/sql/sql-types.d.ts +0 -202
  461. package/esm/drivers/sql/sql-types.d.ts.map +0 -1
  462. package/esm/errors/missing-data-source.error.d.ts +0 -22
  463. package/esm/errors/missing-data-source.error.d.ts.map +0 -1
  464. package/esm/errors/missing-data-source.error.js +0 -29
  465. package/esm/errors/missing-data-source.error.js.map +0 -1
  466. package/esm/errors/transaction-rollback.error.d.ts +0 -20
  467. package/esm/errors/transaction-rollback.error.d.ts.map +0 -1
  468. package/esm/errors/transaction-rollback.error.js +0 -27
  469. package/esm/errors/transaction-rollback.error.js.map +0 -1
  470. package/esm/events/model-events.d.ts +0 -231
  471. package/esm/events/model-events.d.ts.map +0 -1
  472. package/esm/events/model-events.js +0 -259
  473. package/esm/events/model-events.js.map +0 -1
  474. package/esm/expressions/aggregate-expressions.d.ts +0 -215
  475. package/esm/expressions/aggregate-expressions.d.ts.map +0 -1
  476. package/esm/expressions/aggregate-expressions.js +0 -221
  477. package/esm/expressions/aggregate-expressions.js.map +0 -1
  478. package/esm/expressions/index.d.ts +0 -2
  479. package/esm/expressions/index.d.ts.map +0 -1
  480. package/esm/index.d.ts +0 -45
  481. package/esm/index.d.ts.map +0 -1
  482. package/esm/index.js +0 -1
  483. package/esm/index.js.map +0 -1
  484. package/esm/migration/column-builder.d.ts +0 -417
  485. package/esm/migration/column-builder.d.ts.map +0 -1
  486. package/esm/migration/column-builder.js +0 -586
  487. package/esm/migration/column-builder.js.map +0 -1
  488. package/esm/migration/column-helpers.d.ts +0 -275
  489. package/esm/migration/column-helpers.d.ts.map +0 -1
  490. package/esm/migration/column-helpers.js +0 -389
  491. package/esm/migration/column-helpers.js.map +0 -1
  492. package/esm/migration/foreign-key-builder.d.ts +0 -103
  493. package/esm/migration/foreign-key-builder.d.ts.map +0 -1
  494. package/esm/migration/foreign-key-builder.js +0 -121
  495. package/esm/migration/foreign-key-builder.js.map +0 -1
  496. package/esm/migration/index.d.ts +0 -7
  497. package/esm/migration/index.d.ts.map +0 -1
  498. package/esm/migration/migration-runner.d.ts +0 -278
  499. package/esm/migration/migration-runner.d.ts.map +0 -1
  500. package/esm/migration/migration-runner.js +0 -815
  501. package/esm/migration/migration-runner.js.map +0 -1
  502. package/esm/migration/migration.d.ts +0 -1992
  503. package/esm/migration/migration.d.ts.map +0 -1
  504. package/esm/migration/migration.js +0 -2162
  505. package/esm/migration/migration.js.map +0 -1
  506. package/esm/migration/sql-grammar.d.ts +0 -61
  507. package/esm/migration/sql-grammar.d.ts.map +0 -1
  508. package/esm/migration/sql-grammar.js +0 -164
  509. package/esm/migration/sql-grammar.js.map +0 -1
  510. package/esm/migration/sql-serializer.d.ts +0 -22
  511. package/esm/migration/sql-serializer.d.ts.map +0 -1
  512. package/esm/migration/sql-serializer.js +0 -26
  513. package/esm/migration/sql-serializer.js.map +0 -1
  514. package/esm/migration/types.d.ts +0 -155
  515. package/esm/migration/types.d.ts.map +0 -1
  516. package/esm/model/methods/accessor-methods.d.ts +0 -13
  517. package/esm/model/methods/accessor-methods.d.ts.map +0 -1
  518. package/esm/model/methods/accessor-methods.js +0 -51
  519. package/esm/model/methods/accessor-methods.js.map +0 -1
  520. package/esm/model/methods/delete-methods.d.ts +0 -10
  521. package/esm/model/methods/delete-methods.d.ts.map +0 -1
  522. package/esm/model/methods/delete-methods.js +0 -10
  523. package/esm/model/methods/delete-methods.js.map +0 -1
  524. package/esm/model/methods/dirty-methods.d.ts +0 -10
  525. package/esm/model/methods/dirty-methods.d.ts.map +0 -1
  526. package/esm/model/methods/dirty-methods.js +0 -15
  527. package/esm/model/methods/dirty-methods.js.map +0 -1
  528. package/esm/model/methods/hydration-methods.d.ts +0 -10
  529. package/esm/model/methods/hydration-methods.d.ts.map +0 -1
  530. package/esm/model/methods/hydration-methods.js +0 -57
  531. package/esm/model/methods/hydration-methods.js.map +0 -1
  532. package/esm/model/methods/instance-event-methods.d.ts +0 -7
  533. package/esm/model/methods/instance-event-methods.d.ts.map +0 -1
  534. package/esm/model/methods/instance-event-methods.js +0 -15
  535. package/esm/model/methods/instance-event-methods.js.map +0 -1
  536. package/esm/model/methods/meta-methods.d.ts +0 -7
  537. package/esm/model/methods/meta-methods.d.ts.map +0 -1
  538. package/esm/model/methods/meta-methods.js +0 -78
  539. package/esm/model/methods/meta-methods.js.map +0 -1
  540. package/esm/model/methods/query-methods.d.ts +0 -24
  541. package/esm/model/methods/query-methods.d.ts.map +0 -1
  542. package/esm/model/methods/query-methods.js +0 -161
  543. package/esm/model/methods/query-methods.js.map +0 -1
  544. package/esm/model/methods/restore-methods.d.ts +0 -10
  545. package/esm/model/methods/restore-methods.d.ts.map +0 -1
  546. package/esm/model/methods/restore-methods.js +0 -13
  547. package/esm/model/methods/restore-methods.js.map +0 -1
  548. package/esm/model/methods/scope-methods.d.ts +0 -7
  549. package/esm/model/methods/scope-methods.d.ts.map +0 -1
  550. package/esm/model/methods/scope-methods.js +0 -15
  551. package/esm/model/methods/scope-methods.js.map +0 -1
  552. package/esm/model/methods/serialization-methods.d.ts +0 -3
  553. package/esm/model/methods/serialization-methods.d.ts.map +0 -1
  554. package/esm/model/methods/serialization-methods.js +0 -27
  555. package/esm/model/methods/serialization-methods.js.map +0 -1
  556. package/esm/model/methods/static-event-methods.d.ts +0 -9
  557. package/esm/model/methods/static-event-methods.d.ts.map +0 -1
  558. package/esm/model/methods/static-event-methods.js +0 -29
  559. package/esm/model/methods/static-event-methods.js.map +0 -1
  560. package/esm/model/methods/write-methods.d.ts +0 -10
  561. package/esm/model/methods/write-methods.d.ts.map +0 -1
  562. package/esm/model/methods/write-methods.js +0 -52
  563. package/esm/model/methods/write-methods.js.map +0 -1
  564. package/esm/model/model.d.ts +0 -1650
  565. package/esm/model/model.d.ts.map +0 -1
  566. package/esm/model/model.js +0 -1657
  567. package/esm/model/model.js.map +0 -1
  568. package/esm/model/model.types.d.ts +0 -44
  569. package/esm/model/model.types.d.ts.map +0 -1
  570. package/esm/model/register-model.d.ts +0 -81
  571. package/esm/model/register-model.d.ts.map +0 -1
  572. package/esm/model/register-model.js +0 -94
  573. package/esm/model/register-model.js.map +0 -1
  574. package/esm/query-builder/query-builder.d.ts +0 -556
  575. package/esm/query-builder/query-builder.d.ts.map +0 -1
  576. package/esm/query-builder/query-builder.js +0 -1070
  577. package/esm/query-builder/query-builder.js.map +0 -1
  578. package/esm/relations/helpers.d.ts +0 -156
  579. package/esm/relations/helpers.d.ts.map +0 -1
  580. package/esm/relations/helpers.js +0 -201
  581. package/esm/relations/helpers.js.map +0 -1
  582. package/esm/relations/index.d.ts +0 -35
  583. package/esm/relations/index.d.ts.map +0 -1
  584. package/esm/relations/pivot-operations.d.ts +0 -160
  585. package/esm/relations/pivot-operations.d.ts.map +0 -1
  586. package/esm/relations/pivot-operations.js +0 -293
  587. package/esm/relations/pivot-operations.js.map +0 -1
  588. package/esm/relations/relation-hydrator.d.ts +0 -68
  589. package/esm/relations/relation-hydrator.d.ts.map +0 -1
  590. package/esm/relations/relation-hydrator.js +0 -81
  591. package/esm/relations/relation-hydrator.js.map +0 -1
  592. package/esm/relations/relation-loader.d.ts +0 -194
  593. package/esm/relations/relation-loader.d.ts.map +0 -1
  594. package/esm/relations/relation-loader.js +0 -466
  595. package/esm/relations/relation-loader.js.map +0 -1
  596. package/esm/relations/types.d.ts +0 -306
  597. package/esm/relations/types.d.ts.map +0 -1
  598. package/esm/remover/database-remover.d.ts +0 -100
  599. package/esm/remover/database-remover.d.ts.map +0 -1
  600. package/esm/remover/database-remover.js +0 -214
  601. package/esm/remover/database-remover.js.map +0 -1
  602. package/esm/restorer/database-restorer.d.ts +0 -131
  603. package/esm/restorer/database-restorer.d.ts.map +0 -1
  604. package/esm/restorer/database-restorer.js +0 -434
  605. package/esm/restorer/database-restorer.js.map +0 -1
  606. package/esm/sql-database-dirty-tracker.d.ts +0 -13
  607. package/esm/sql-database-dirty-tracker.d.ts.map +0 -1
  608. package/esm/sql-database-dirty-tracker.js +0 -14
  609. package/esm/sql-database-dirty-tracker.js.map +0 -1
  610. package/esm/sync/index.d.ts +0 -12
  611. package/esm/sync/index.d.ts.map +0 -1
  612. package/esm/sync/model-events.d.ts +0 -62
  613. package/esm/sync/model-events.d.ts.map +0 -1
  614. package/esm/sync/model-events.js +0 -49
  615. package/esm/sync/model-events.js.map +0 -1
  616. package/esm/sync/model-sync-operation.d.ts +0 -163
  617. package/esm/sync/model-sync-operation.d.ts.map +0 -1
  618. package/esm/sync/model-sync-operation.js +0 -292
  619. package/esm/sync/model-sync-operation.js.map +0 -1
  620. package/esm/sync/model-sync.d.ts +0 -130
  621. package/esm/sync/model-sync.d.ts.map +0 -1
  622. package/esm/sync/model-sync.js +0 -178
  623. package/esm/sync/model-sync.js.map +0 -1
  624. package/esm/sync/sync-context.d.ts +0 -70
  625. package/esm/sync/sync-context.d.ts.map +0 -1
  626. package/esm/sync/sync-context.js +0 -101
  627. package/esm/sync/sync-context.js.map +0 -1
  628. package/esm/sync/sync-manager.d.ts +0 -213
  629. package/esm/sync/sync-manager.d.ts.map +0 -1
  630. package/esm/sync/sync-manager.js +0 -689
  631. package/esm/sync/sync-manager.js.map +0 -1
  632. package/esm/sync/types.d.ts +0 -289
  633. package/esm/sync/types.d.ts.map +0 -1
  634. package/esm/test-migrations/test-enhanced-features.migration.d.ts +0 -15
  635. package/esm/test-migrations/test-enhanced-features.migration.d.ts.map +0 -1
  636. package/esm/types.d.ts +0 -371
  637. package/esm/types.d.ts.map +0 -1
  638. package/esm/utils/connect-to-database.d.ts +0 -300
  639. package/esm/utils/connect-to-database.d.ts.map +0 -1
  640. package/esm/utils/connect-to-database.js +0 -128
  641. package/esm/utils/connect-to-database.js.map +0 -1
  642. package/esm/utils/database-writer.utils.d.ts +0 -15
  643. package/esm/utils/database-writer.utils.d.ts.map +0 -1
  644. package/esm/utils/database-writer.utils.js +0 -14
  645. package/esm/utils/database-writer.utils.js.map +0 -1
  646. package/esm/utils/define-model.js +0 -100
  647. package/esm/utils/define-model.js.map +0 -1
  648. package/esm/utils/is-valid-date-value.d.ts +0 -5
  649. package/esm/utils/is-valid-date-value.d.ts.map +0 -1
  650. package/esm/utils/is-valid-date-value.js +0 -25
  651. package/esm/utils/is-valid-date-value.js.map +0 -1
  652. package/esm/utils/once-connected.d.ts +0 -146
  653. package/esm/utils/once-connected.d.ts.map +0 -1
  654. package/esm/utils/once-connected.js +0 -251
  655. package/esm/utils/once-connected.js.map +0 -1
  656. package/esm/validation/database-seal-plugins.d.ts +0 -12
  657. package/esm/validation/database-seal-plugins.d.ts.map +0 -1
  658. package/esm/validation/database-seal-plugins.js +0 -1
  659. package/esm/validation/database-seal-plugins.js.map +0 -1
  660. package/esm/validation/database-writer-validation-error.d.ts +0 -97
  661. package/esm/validation/database-writer-validation-error.d.ts.map +0 -1
  662. package/esm/validation/database-writer-validation-error.js +0 -160
  663. package/esm/validation/database-writer-validation-error.js.map +0 -1
  664. package/esm/validation/index.d.ts +0 -3
  665. package/esm/validation/index.d.ts.map +0 -1
  666. package/esm/validation/mutators/embed-mutator.d.ts +0 -9
  667. package/esm/validation/mutators/embed-mutator.d.ts.map +0 -1
  668. package/esm/validation/mutators/embed-mutator.js +0 -33
  669. package/esm/validation/mutators/embed-mutator.js.map +0 -1
  670. package/esm/validation/plugins/embed-validator-plugin.d.ts +0 -24
  671. package/esm/validation/plugins/embed-validator-plugin.d.ts.map +0 -1
  672. package/esm/validation/plugins/embed-validator-plugin.js +0 -18
  673. package/esm/validation/plugins/embed-validator-plugin.js.map +0 -1
  674. package/esm/validation/rules/database-model-rule.d.ts +0 -7
  675. package/esm/validation/rules/database-model-rule.d.ts.map +0 -1
  676. package/esm/validation/rules/database-model-rule.js +0 -27
  677. package/esm/validation/rules/database-model-rule.js.map +0 -1
  678. package/esm/validation/transformers/embed-model-transformer.d.ts +0 -3
  679. package/esm/validation/transformers/embed-model-transformer.d.ts.map +0 -1
  680. package/esm/validation/transformers/embed-model-transformer.js +0 -18
  681. package/esm/validation/transformers/embed-model-transformer.js.map +0 -1
  682. package/esm/validation/validators/embed-validator.d.ts +0 -21
  683. package/esm/validation/validators/embed-validator.d.ts.map +0 -1
  684. package/esm/validation/validators/embed-validator.js +0 -43
  685. package/esm/validation/validators/embed-validator.js.map +0 -1
  686. package/esm/writer/database-writer.d.ts +0 -181
  687. package/esm/writer/database-writer.d.ts.map +0 -1
  688. package/esm/writer/database-writer.js +0 -407
  689. package/esm/writer/database-writer.js.map +0 -1
@@ -1,815 +0,0 @@
1
- 'use strict';var copper=require('@mongez/copper'),logger=require('@warlock.js/logger'),fs=require('fs'),path=require('path'),dataSourceRegistry=require('../data-source/data-source-registry.js'),sqlGrammar=require('./sql-grammar.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var fs__default=/*#__PURE__*/_interopDefault(fs);var path__default=/*#__PURE__*/_interopDefault(path);/**
2
- * Parse createdAt timestamp from custom format to Date.
3
- * Supports both: MM-DD-YYYY_HH-MM-SS and DD-MM-YYYY_HH-MM-SS
4
- * Intelligently detects format by checking if first value > 12 (must be day)
5
- * Falls back to standard Date parsing for ISO strings.
6
- */
7
- function parseCreatedAt(createdAt) {
8
- const match = createdAt.match(/^(\d{2})-(\d{2})-(\d{4})_(\d{2})-(\d{2})-(\d{2})$/);
9
- if (match) {
10
- const [, first, second, year, hour, minute, second_time] = match;
11
- const firstNum = parseInt(first);
12
- const secondNum = parseInt(second);
13
- let month, day;
14
- // Intelligently detect format:
15
- // If first > 12, it must be DD-MM-YYYY (day can't be month)
16
- // If second > 12, it must be MM-DD-YYYY (day can't be month)
17
- // Otherwise, assume MM-DD-YYYY (US format as default)
18
- if (firstNum > 12) {
19
- // DD-MM-YYYY format
20
- day = firstNum;
21
- month = secondNum;
22
- }
23
- else if (secondNum > 12) {
24
- // MM-DD-YYYY format
25
- month = firstNum;
26
- day = secondNum;
27
- }
28
- else {
29
- // Ambiguous - default to MM-DD-YYYY
30
- month = firstNum;
31
- day = secondNum;
32
- }
33
- const date = new Date(parseInt(year), month - 1, // JavaScript months are 0-indexed
34
- day, parseInt(hour), parseInt(minute), parseInt(second_time));
35
- // Validate the date is actually valid
36
- if (isNaN(date.getTime())) {
37
- return undefined;
38
- }
39
- return date;
40
- }
41
- // Fallback to standard Date parsing for ISO strings
42
- try {
43
- const date = new Date(createdAt);
44
- return isNaN(date.getTime()) ? undefined : date;
45
- }
46
- catch {
47
- return undefined;
48
- }
49
- }
50
- /**
51
- * Comparator for sorting migration classes.
52
- *
53
- * Priority:
54
- * 1. `createdAt` timestamp (older = earlier)
55
- * 2. Alphabetical by migration name (last resort)
56
- */
57
- function sortMigrations(a, b) {
58
- // Sort by createdAt timestamp
59
- const aDate = a.createdAt ? parseCreatedAt(a.createdAt) : undefined;
60
- const bDate = b.createdAt ? parseCreatedAt(b.createdAt) : undefined;
61
- if (aDate && bDate)
62
- return aDate.getTime() - bDate.getTime();
63
- if (aDate)
64
- return -1;
65
- if (bDate)
66
- return 1;
67
- // Last resort: alphabetical
68
- return a.migrationName.localeCompare(b.migrationName);
69
- }
70
- /**
71
- * Migration runner that executes migrations.
72
- *
73
- * This is a pure executor - it doesn't discover migrations.
74
- * Discovery is handled by the framework (e.g., @warlock.js/core CLI).
75
- *
76
- * The migration name is read from the static `name` property on the class,
77
- * which should be set by the CLI after importing:
78
- *
79
- * @example
80
- * ```typescript
81
- * // In CLI after importing:
82
- * const { default: MigrationClass } = await import("./create-users.migration.ts");
83
- * MigrationClass.migrationName ??= "create-users";
84
- *
85
- * // Then register or execute:
86
- * runner.register(MigrationClass);
87
- * // or
88
- * await runner.execute(MigrationClass);
89
- * ```
90
- *
91
- * @example
92
- * ```typescript
93
- * // Simple direct execution
94
- * await runner.execute(CreateUsersTable);
95
- * await runner.rollback(CreateUsersTable);
96
- *
97
- * // Registry pattern for batch operations
98
- * runner.register(CreateUsersTable);
99
- * runner.register(AddEmailIndex);
100
- * await runner.runAll();
101
- * await runner.rollbackAll();
102
- * ```
103
- */
104
- class MigrationRunner {
105
- /** Registered migrations */
106
- migrations = [];
107
- /** Data source to use */
108
- dataSource;
109
- /** Cached migration driver */
110
- cachedMigrationDriver;
111
- /** Table name for tracking migrations */
112
- migrationsTable;
113
- /** Whether to log operations */
114
- verbose;
115
- /**
116
- * Create a new migration runner.
117
- *
118
- * @param options - Runner options
119
- */
120
- constructor(options = {}) {
121
- this.dataSource = options.dataSource;
122
- this.migrationsTable = options.migrationsTable ?? "_migrations";
123
- this.verbose = options.verbose ?? true;
124
- }
125
- // ============================================================================
126
- // DATA SOURCE
127
- // ============================================================================
128
- /**
129
- * Set the data source.
130
- */
131
- setDataSource(dataSource) {
132
- this.dataSource = dataSource;
133
- this.cachedMigrationDriver = undefined;
134
- return this;
135
- }
136
- /**
137
- * Get the data source.
138
- */
139
- getDataSource() {
140
- if (!this.dataSource) {
141
- this.dataSource = dataSourceRegistry.dataSourceRegistry.get();
142
- }
143
- return this.dataSource;
144
- }
145
- /**
146
- * Get the migration driver.
147
- */
148
- getMigrationDriver() {
149
- if (!this.cachedMigrationDriver) {
150
- this.cachedMigrationDriver = this.getDataSource().driver.migrationDriver();
151
- }
152
- return this.cachedMigrationDriver;
153
- }
154
- // ============================================================================
155
- // REGISTRATION
156
- // ============================================================================
157
- /**
158
- * Register a migration.
159
- *
160
- * The migration name is read from `MigrationClass.migrationName`.
161
- *
162
- * @param MigrationClass - Migration class (must have static `name` set)
163
- * @param createdAt - Optional timestamp for ordering
164
- * @returns This runner for chaining
165
- *
166
- * @example
167
- * ```typescript
168
- * CreateUsersTable.migrationName = "2024-01-15_create-users";
169
- * runner.register(CreateUsersTable);
170
- * ```
171
- */
172
- register(MigrationClass) {
173
- const name = MigrationClass.migrationName;
174
- if (!name) {
175
- throw new Error(`Migration class must have a static 'migrationName' property set. ` +
176
- `Set it in CLI after importing: MigrationClass.migrationName = "filename";`);
177
- }
178
- // Avoid duplicates
179
- if (!this.migrations.some((m) => m.migrationName === name)) {
180
- this.migrations.push(MigrationClass);
181
- }
182
- return this;
183
- }
184
- /**
185
- * Register multiple migrations.
186
- *
187
- * @param migrations - Array of migration classes
188
- * @returns This runner for chaining
189
- */
190
- registerMany(migrations) {
191
- for (const MigrationClass of migrations) {
192
- this.register(MigrationClass);
193
- }
194
- return this;
195
- }
196
- /**
197
- * Clear all registered migrations.
198
- */
199
- clear() {
200
- this.migrations.length = 0;
201
- return this;
202
- }
203
- /**
204
- * Get all registered migration names.
205
- */
206
- getRegisteredNames() {
207
- return this.migrations.map((m) => m.migrationName);
208
- }
209
- // ============================================================================
210
- // SINGLE EXECUTION
211
- // ============================================================================
212
- /**
213
- * Execute a single migration's up() method.
214
- *
215
- * @param MigrationClass - Migration class to execute
216
- * @param options - Execution options
217
- * @returns Migration result
218
- *
219
- * @example
220
- * ```typescript
221
- * await runner.execute(CreateUsersTable);
222
- * await runner.execute(AddEmailIndex, { dryRun: true });
223
- * ```
224
- */
225
- async run(MigrationClass, options = {}) {
226
- return this.runMigration(MigrationClass, "up", {
227
- dryRun: options.dryRun,
228
- record: options.record ?? false,
229
- });
230
- }
231
- /**
232
- * Execute a single migration's down() method.
233
- *
234
- * @param MigrationClass - Migration class to rollback
235
- * @param options - Execution options
236
- * @returns Migration result
237
- *
238
- * @example
239
- * ```typescript
240
- * await runner.rollback(CreateUsersTable);
241
- * ```
242
- */
243
- async rollback(MigrationClass, options = {}) {
244
- return this.runMigration(MigrationClass, "down", {
245
- dryRun: options.dryRun,
246
- record: options.record ?? false,
247
- });
248
- }
249
- // ============================================================================
250
- // BATCH EXECUTION (REGISTERED MIGRATIONS)
251
- // ============================================================================
252
- /**
253
- * Run all pending registered migrations.
254
- *
255
- * Only runs migrations not already in the migrations table.
256
- *
257
- * @param options - Execution options
258
- * @returns Results for each migration
259
- *
260
- * @example
261
- * ```typescript
262
- * runner.register(CreateUsersTable);
263
- * runner.register(AddEmailIndex);
264
- * const results = await runner.runAll();
265
- * ```
266
- */
267
- async runAll(options = {}) {
268
- const { dryRun = false, record = true } = options;
269
- const results = [];
270
- // Get pending migrations
271
- const pending = await this.getPendingMigrations();
272
- if (pending.length === 0) {
273
- logger.log.warn("database", "migration", "Nothing to migrate.");
274
- return results;
275
- }
276
- logger.log.info("database", "migration", `Found ${pending.length} pending migration(s). Generating SQL pool...`);
277
- const nextBatch = await this.getNextBatchNumber();
278
- const taggedStatements = [];
279
- const migrationsData = [];
280
- // 1. Collect SQL from each pending migration.
281
- // Fire extension checks concurrently as we encounter CREATE EXTENSION
282
- // statements — they resolve before execution begins.
283
- const extensionChecks = [];
284
- for (const MigrationClass of pending) {
285
- const migration = this.createMigrationInstance(MigrationClass);
286
- const name = MigrationClass.migrationName;
287
- await migration.up();
288
- const upStatements = migration.toSQL();
289
- migrationsData.push({ MigrationClass, migration, name });
290
- for (const sql of upStatements) {
291
- const statementType = sqlGrammar.SQLGrammar.classify(sql);
292
- if (statementType === "CREATE_EXTENSION") {
293
- const ext = sqlGrammar.SQLGrammar.extractExtensionName(sql);
294
- if (ext)
295
- extensionChecks.push(this.informIfExtensionMissing(ext));
296
- }
297
- taggedStatements.push({
298
- sql,
299
- phase: sqlGrammar.SQLGrammar.phase(sql),
300
- statementType,
301
- createdAt: MigrationClass.createdAt,
302
- migrationName: name,
303
- });
304
- }
305
- }
306
- // 2. Resolve all extension checks before any SQL is executed.
307
- // Each check displays a rich message if the extension is missing
308
- // but does not throw — execution continues and Postgres will
309
- // surface its own error with full context already shown.
310
- await Promise.all(extensionChecks);
311
- // 3. Sort all SQL statements globally across all pending migrations
312
- const sortedStatements = sqlGrammar.SQLGrammar.sort(taggedStatements);
313
- // 4. Execute in a single batch
314
- if (dryRun) {
315
- logger.log.info("database", "migration", "Dry run enabled. Would execute the following statements:");
316
- for (const statement of sortedStatements) {
317
- console.log(`-- [${statement.statementType}] Phase ${statement.phase} [${statement.migrationName}]`);
318
- console.log(statement.sql + ";\n");
319
- }
320
- return [];
321
- }
322
- const driver = this.getDataSource().driver;
323
- let transactionFailed = false;
324
- let errorMessage = "";
325
- /** The migration name that owns the SQL statement that threw. */
326
- let failingMigrationName;
327
- const startTime = Date.now();
328
- /**
329
- * Execute all sorted statements, capturing which migration owns the
330
- * statement that throws — so we report a precise culprit instead of
331
- * blaming every migration in the batch.
332
- */
333
- const executeStatements = async () => {
334
- for (const statement of sortedStatements) {
335
- try {
336
- await driver.query(statement.sql);
337
- }
338
- catch (err) {
339
- failingMigrationName = statement.migrationName;
340
- throw err;
341
- }
342
- }
343
- if (record) {
344
- for (const data of migrationsData) {
345
- await this.recordMigration(data.name, nextBatch, data.MigrationClass.createdAt
346
- ? parseCreatedAt(data.MigrationClass.createdAt)
347
- : new Date());
348
- }
349
- }
350
- };
351
- try {
352
- if (driver.transaction) {
353
- await driver.transaction(executeStatements);
354
- }
355
- else {
356
- await executeStatements();
357
- }
358
- }
359
- catch (err) {
360
- transactionFailed = true;
361
- errorMessage = err instanceof Error ? err.message : String(err);
362
- }
363
- const durationMs = Date.now() - startTime;
364
- // Report results per-migration.
365
- // Only the migration that owns the failing statement is marked as failed;
366
- // all others are reported as rolled back / not reached.
367
- for (const data of migrationsData) {
368
- const isCulprit = transactionFailed && data.name === failingMigrationName;
369
- const wasSkipped = transactionFailed && !isCulprit;
370
- results.push({
371
- name: data.name,
372
- table: data.migration.table,
373
- direction: "up",
374
- success: !transactionFailed,
375
- error: isCulprit ? errorMessage : undefined,
376
- durationMs: Math.round(durationMs / migrationsData.length),
377
- executedAt: new Date(),
378
- });
379
- if (isCulprit) {
380
- logger.log.error("database", "migration", `${copper.colors.magenta(data.name)}: ✗ Failed: ${errorMessage}`);
381
- }
382
- else if (wasSkipped) {
383
- logger.log.warn("database", "migration", `${copper.colors.magenta(data.name)}: rolled back (batch transaction failed)`);
384
- }
385
- else {
386
- logger.log.success("database", "migration", `Migrated: ${copper.colors.magenta(data.name)} successfully`);
387
- }
388
- }
389
- if (transactionFailed) {
390
- logger.log.error("database", "migration", `Batch execution failed. Rollback performed if transactional.`);
391
- throw new Error("Migration batch failed: " + errorMessage);
392
- }
393
- const successCount = results.filter((r) => r.success).length;
394
- logger.log.success("database", "migration", `Migration bulk phase execution complete: ${successCount}/${pending.length} migrations processed successfully.`);
395
- return results;
396
- }
397
- /**
398
- * Export migrations as phase-ordered SQL files in database/sql/ directory.
399
- * By default, it exports all registered migrations. Use `pendingOnly: true` to export only pending ones.
400
- */
401
- async exportSQL(options = {}) {
402
- const migrationsToExport = options.pendingOnly
403
- ? await this.getPendingMigrations()
404
- : this.migrations;
405
- if (migrationsToExport.length === 0) {
406
- logger.log.warn("database", "migration", "No migrations to export.");
407
- return;
408
- }
409
- logger.log.info("database", "migration", `Exporting ${migrationsToExport.length} ${options.pendingOnly ? "pending " : ""}migration(s) to SQL files...`);
410
- const upStatements = [];
411
- const downStatements = [];
412
- for (const MigrationClass of migrationsToExport) {
413
- const migration = this.createMigrationInstance(MigrationClass);
414
- const name = MigrationClass.migrationName;
415
- // Collect up SQL
416
- await migration.up();
417
- for (const sql of migration.toSQL()) {
418
- upStatements.push({
419
- sql,
420
- phase: sqlGrammar.SQLGrammar.phase(sql),
421
- statementType: sqlGrammar.SQLGrammar.classify(sql),
422
- createdAt: MigrationClass.createdAt,
423
- migrationName: name,
424
- });
425
- }
426
- // Collect down SQL (reuse same instance — toSQL() cleared pendingOps)
427
- await migration.down();
428
- for (const sql of migration.toSQL()) {
429
- downStatements.push({
430
- sql,
431
- phase: sqlGrammar.SQLGrammar.phase(sql),
432
- statementType: sqlGrammar.SQLGrammar.classify(sql),
433
- createdAt: MigrationClass.createdAt,
434
- migrationName: name,
435
- });
436
- }
437
- }
438
- const sortedUp = sqlGrammar.SQLGrammar.sort(upStatements);
439
- // Down SQL: reverse order (undo in reverse dependency order)
440
- const sortedDown = downStatements.reverse();
441
- const upSQLString = this.formatSQLForExport(sortedUp, options.compact);
442
- const downSQLString = this.formatSQLForExport(sortedDown, options.compact);
443
- const rootPath = process.cwd();
444
- const sqlDir = path__default.default.join(rootPath, "database", "sql");
445
- if (!fs__default.default.existsSync(sqlDir)) {
446
- fs__default.default.mkdirSync(sqlDir, { recursive: true });
447
- }
448
- const timestamp = new Date().toISOString().replace(/T/, "_").replace(/:/g, "-").split(".")[0];
449
- const upPath = path__default.default.join(sqlDir, `migration_${timestamp}.up.sql`);
450
- const downPath = path__default.default.join(sqlDir, `migration_${timestamp}.down.sql`);
451
- fs__default.default.writeFileSync(upPath, upSQLString);
452
- fs__default.default.writeFileSync(downPath, downSQLString);
453
- logger.log.success("database", "migration", `Exported to:\n- ${upPath}\n- ${downPath}`);
454
- }
455
- /**
456
- * Rollback the last batch of migrations.
457
- *
458
- * @param options - Execution options
459
- * @returns Results for each migration
460
- */
461
- async rollbackLast(options = {}) {
462
- return this.rollbackBatches(1, options);
463
- }
464
- /**
465
- * Rollback N batches of migrations.
466
- *
467
- * @param batches - Number of batches to rollback
468
- * @param options - Execution options
469
- * @returns Results for each migration
470
- */
471
- async rollbackBatches(batches, options = {}) {
472
- const dryRun = options.dryRun ?? false;
473
- const record = options.record ?? true;
474
- const results = [];
475
- const toRollback = await this.getMigrationsToRollback(batches);
476
- if (toRollback.length === 0) {
477
- logger.log.warn("database", "migration", "Nothing to rollback.");
478
- return results;
479
- }
480
- logger.log.info("database", "migration", `Rolling back ${toRollback.length} migration(s).`);
481
- for (const MigrationClass of toRollback) {
482
- const result = await this.runMigration(MigrationClass, "down", {
483
- dryRun,
484
- record,
485
- });
486
- results.push(result);
487
- if (!result.success) {
488
- break;
489
- }
490
- }
491
- const successCount = results.filter((r) => r.success).length;
492
- logger.log.success("database", "migration", `Rollback complete: ${successCount}/${toRollback.length} successful.`);
493
- return results;
494
- }
495
- /**
496
- * Rollback all executed migrations.
497
- *
498
- * @param options - Execution options
499
- * @returns Results for each migration
500
- */
501
- async rollbackAll(options = {}) {
502
- const executed = await this.getExecutedMigrations();
503
- if (executed.length === 0) {
504
- logger.log.warn("database", "migration", "Nothing to rollback.");
505
- return [];
506
- }
507
- const maxBatch = Math.max(...executed.map((r) => r.batch));
508
- return this.rollbackBatches(maxBatch, options);
509
- }
510
- /**
511
- * Reset and re-run: rollback all then run all.
512
- *
513
- * @param options - Execution options
514
- * @returns Combined results
515
- */
516
- async fresh(options = {}) {
517
- const rollbackResults = await this.rollbackAll(options);
518
- const runResults = await this.runAll(options);
519
- return [...rollbackResults, ...runResults];
520
- }
521
- // ============================================================================
522
- // STATUS
523
- // ============================================================================
524
- /**
525
- * Get status of all registered migrations.
526
- */
527
- async status() {
528
- const executed = await this.getExecutedMigrations();
529
- const executedMap = new Map(executed.map((r) => [r.name, r]));
530
- return this.migrations.map((MigrationClass) => {
531
- const instance = new MigrationClass();
532
- const name = MigrationClass.migrationName;
533
- const record = executedMap.get(name);
534
- return {
535
- name,
536
- table: instance.table,
537
- executed: !!record,
538
- batch: record?.batch ?? null,
539
- };
540
- });
541
- }
542
- // ============================================================================
543
- // EXTENSION PRE-FLIGHT
544
- // ============================================================================
545
- /**
546
- * Check whether a database extension is available and inform the developer
547
- * if it is not installed.
548
- *
549
- * Does NOT throw — execution proceeds normally. If the extension is truly
550
- * missing, the database will surface its own error with full context already
551
- * displayed to the developer.
552
- *
553
- * @example
554
- * await this.informIfExtensionMissing("vector");
555
- */
556
- async informIfExtensionMissing(extension) {
557
- try {
558
- const migrationDriver = this.getMigrationDriver();
559
- const isAvailable = await migrationDriver.isExtensionAvailable(extension);
560
- if (!isAvailable) {
561
- const hr = "─".repeat(60);
562
- console.log(`\n${copper.colors.yellow(hr)}`);
563
- console.log(copper.colors.yellow(` ⚠ Missing Database Extension: ${copper.colors.bold(extension)}`));
564
- console.log(copper.colors.yellow(hr));
565
- console.log();
566
- console.log(` A pending migration requires the ${copper.colors.cyan(extension)} extension,`);
567
- console.log(` which is not installed on your database server.`);
568
- console.log();
569
- console.log(` ${copper.colors.bold("This means the physical database server is missing the extension package.")}`);
570
- console.log(` You cannot simply run CREATE EXTENSION until the package is installed`);
571
- console.log(` on the host machine or Docker container.`);
572
- console.log();
573
- const docsUrl = migrationDriver.getExtensionDocsUrl(extension);
574
- if (docsUrl) {
575
- console.log(` ${copper.colors.bold("Or follow the installation guide:")}`);
576
- console.log(` ${copper.colors.cyan(docsUrl)}`);
577
- }
578
- console.log(`\n${copper.colors.yellow(hr)}\n`);
579
- }
580
- }
581
- catch {
582
- // If the check itself fails, silently skip — don't break the migration.
583
- }
584
- }
585
- // ============================================================================
586
- // PRIVATE HELPERS
587
- // ============================================================================
588
- /**
589
- * Run a single migration.
590
- */
591
- async runMigration(MigrationClass, direction, options = {}) {
592
- const { dryRun = false, record = true } = options;
593
- const startTime = Date.now();
594
- let success = true;
595
- let error;
596
- const migration = new MigrationClass();
597
- const name = MigrationClass.migrationName;
598
- logger.log.info("database", "migration", `${direction === "up" ? "Migrating" : "Rolling back"}: ${copper.colors.magenta(name)}...`);
599
- try {
600
- if (!dryRun) {
601
- const driver = this.getMigrationDriver();
602
- migration.setDriver(driver);
603
- migration.setMigrationDefaults(this.getDataSource().migrationDefaults);
604
- // ============================================================================
605
- // TRANSACTION RESOLUTION (3-tier hierarchy)
606
- // ============================================================================
607
- // 1. Migration-level explicit override
608
- // 2. Config-level global override
609
- // 3. Driver default (PostgreSQL: true, MongoDB: false)
610
- const shouldUseTransaction = migration.transactional ??
611
- this.getDataSource().migrations?.transactional ??
612
- driver.getDefaultTransactional();
613
- // ============================================================================
614
- // EXECUTE WITH OR WITHOUT TRANSACTION
615
- // ============================================================================
616
- // Collect SQL for the requested direction
617
- if (direction === "up") {
618
- await migration.up();
619
- }
620
- else {
621
- await migration.down();
622
- }
623
- const sqlStatements = migration.toSQL();
624
- const databaseDriver = this.getDataSource().driver;
625
- if (shouldUseTransaction && databaseDriver.transaction) {
626
- // Transactional execution
627
- await databaseDriver.transaction(async () => {
628
- // Execute generated SQL statements sequentially (no phase-sorting here since it's single execution)
629
- for (const sql of sqlStatements) {
630
- await databaseDriver.query(sql);
631
- }
632
- // Record migration tracking
633
- if (record) {
634
- if (direction === "up") {
635
- const batch = options.batch ?? (await this.getNextBatchNumber());
636
- await this.recordMigration(name, batch, MigrationClass.createdAt ? parseCreatedAt(MigrationClass.createdAt) : new Date());
637
- }
638
- else {
639
- await this.removeMigrationRecord(name);
640
- }
641
- }
642
- });
643
- }
644
- else {
645
- // Non-transactional execution
646
- for (const sql of sqlStatements) {
647
- await databaseDriver.query(sql);
648
- }
649
- if (record) {
650
- if (direction === "up") {
651
- const batch = options.batch ?? (await this.getNextBatchNumber());
652
- await this.recordMigration(name, batch, MigrationClass.createdAt ? parseCreatedAt(MigrationClass.createdAt) : new Date());
653
- }
654
- else {
655
- await this.removeMigrationRecord(name);
656
- }
657
- }
658
- }
659
- }
660
- }
661
- catch (err) {
662
- success = false;
663
- error = err instanceof Error ? err.message : String(err);
664
- logger.log.error("database", "migration", `${copper.colors.magenta(name)}: ✗ Failed: ${error}`);
665
- throw err;
666
- }
667
- const durationMs = Date.now() - startTime;
668
- if (success) {
669
- logger.log.success("database", "migration", `${direction == "up" ? "Migrated" : "Rolled back"}: ${copper.colors.magenta(name)} successfully (${durationMs}ms)`);
670
- }
671
- return {
672
- name,
673
- table: migration.table,
674
- direction,
675
- success,
676
- error,
677
- durationMs,
678
- executedAt: new Date(),
679
- };
680
- }
681
- /**
682
- * Create, configure, and return a ready-to-use migration instance.
683
- *
684
- * Centralises the repeated "new + setDriver + setMigrationDefaults" boilerplate
685
- * that all batch/single execution paths need.
686
- *
687
- * @internal
688
- */
689
- createMigrationInstance(MigrationClass) {
690
- const migration = new MigrationClass();
691
- migration.setDriver(this.getMigrationDriver());
692
- migration.setMigrationDefaults(this.getDataSource().migrationDefaults);
693
- return migration;
694
- }
695
- /**
696
- * Format an ordered array of TaggedSQL into a human-readable SQL file string.
697
- *
698
- * Consecutive statements that belong to the same (phase, migration) group share
699
- * a single block comment at the top, avoiding the noisy per-statement repetition.
700
- *
701
- * Example output:
702
- * ```sql
703
- * /* Phase 3 [create-users] *\/
704
- * ALTER TABLE "users" ADD COLUMN "name" TEXT NOT NULL;
705
- * ALTER TABLE "users" ADD COLUMN "email" TEXT NOT NULL;
706
- *
707
- * /* Phase 4 [create-users] *\/
708
- * CREATE UNIQUE INDEX ...;
709
- * ```
710
- *
711
- * @internal
712
- */
713
- formatSQLForExport(statements, compact = false) {
714
- const lines = [];
715
- if (compact) {
716
- // Just output raw statements, no grouping, no blank lines
717
- for (const stmt of statements) {
718
- lines.push(`${stmt.sql};`);
719
- }
720
- return lines.join("\n");
721
- }
722
- // Group statements by their phase and migration name
723
- const grouped = new Map();
724
- for (const stmt of statements) {
725
- const groupKey = `Phase ${stmt.phase} [${stmt.migrationName}]`;
726
- if (!grouped.has(groupKey)) {
727
- grouped.set(groupKey, []);
728
- }
729
- grouped.get(groupKey).push(stmt.sql);
730
- }
731
- // Format each group
732
- for (const [groupKey, sqls] of grouped.entries()) {
733
- if (lines.length > 0)
734
- lines.push(""); // blank line between groups
735
- lines.push(`/* ${groupKey} */`);
736
- for (const sql of sqls) {
737
- lines.push(`${sql};`);
738
- }
739
- }
740
- return lines.join("\n");
741
- }
742
- /**
743
- * Get pending (not executed) registered migrations.
744
- */
745
- async getPendingMigrations() {
746
- const executed = await this.getExecutedMigrations();
747
- const executedNames = new Set(executed.map((r) => r.name));
748
- const migrations = this.migrations.filter((m) => !executedNames.has(m.migrationName));
749
- return migrations.sort(sortMigrations);
750
- }
751
- /**
752
- * Get migrations to rollback.
753
- */
754
- async getMigrationsToRollback(batches) {
755
- const executed = await this.getExecutedMigrations();
756
- if (executed.length === 0)
757
- return [];
758
- const batchNumbers = [...new Set(executed.map((r) => r.batch))]
759
- .sort((a, b) => b - a)
760
- .slice(0, batches);
761
- const toRollback = executed.filter((r) => batchNumbers.includes(r.batch)).reverse();
762
- const migrations = toRollback
763
- .map((r) => this.migrations.find((m) => m.migrationName === r.name))
764
- .filter((m) => !!m);
765
- return migrations.sort(sortMigrations);
766
- }
767
- /**
768
- * Get executed migration records.
769
- */
770
- async getExecutedMigrations() {
771
- const driver = this.getDataSource().driver;
772
- try {
773
- const migrationDriver = this.getMigrationDriver();
774
- // Ensure migrations table exists
775
- await migrationDriver.ensureMigrationsTable(this.migrationsTable);
776
- const queryBuilder = driver.queryBuilder(this.migrationsTable);
777
- return await queryBuilder.orderBy("batch", "asc").orderBy("name", "asc").get();
778
- }
779
- catch {
780
- return [];
781
- }
782
- }
783
- /**
784
- * Record a migration.
785
- */
786
- async recordMigration(name, batch, createdAt) {
787
- const driver = this.getDataSource().driver;
788
- const migrationDriver = this.getMigrationDriver();
789
- // Ensure migrations table exists
790
- await migrationDriver.ensureMigrationsTable(this.migrationsTable);
791
- await driver.insert(this.migrationsTable, {
792
- name,
793
- batch,
794
- executedAt: new Date(),
795
- createdAt,
796
- });
797
- }
798
- /**
799
- * Remove a migration record.
800
- */
801
- async removeMigrationRecord(name) {
802
- const driver = this.getDataSource().driver;
803
- await driver.delete(this.migrationsTable, { name });
804
- }
805
- /**
806
- * Get next batch number.
807
- */
808
- async getNextBatchNumber() {
809
- const executed = await this.getExecutedMigrations();
810
- if (executed.length === 0)
811
- return 1;
812
- return Math.max(...executed.map((r) => r.batch)) + 1;
813
- }
814
- }
815
- const migrationRunner = new MigrationRunner();exports.MigrationRunner=MigrationRunner;exports.migrationRunner=migrationRunner;//# sourceMappingURL=migration-runner.js.map