@warlock.js/cascade 4.0.156 → 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,2162 +0,0 @@
1
- import {ColumnBuilder}from'./column-builder.js';import {ForeignKeyBuilder}from'./foreign-key-builder.js';/**
2
- * Base class for all database migrations.
3
- *
4
- * Provides a fluent API for defining schema changes that work across
5
- * both SQL and NoSQL databases. The migration driver handles translating
6
- * operations to native database commands.
7
- *
8
- * Migrations are executed in order based on their `createdAt` timestamp,
9
- * which is typically extracted from the filename (e.g., `2024-01-15_create-users`).
10
- *
11
- * @example
12
- * ```typescript
13
- * // Using Migration.for() to bind to a model
14
- * export default class extends Migration.for(User) {
15
- * public up(): void {
16
- * this.string("email").unique();
17
- * this.integer("age").nullable();
18
- * this.geoIndex("location");
19
- * }
20
- *
21
- * public down(): void {
22
- * this.dropColumn("email");
23
- * this.dropColumn("age");
24
- * this.dropGeoIndex("location");
25
- * }
26
- * }
27
- * ```
28
- *
29
- * @example
30
- * ```typescript
31
- * // Manual table migration (without model binding)
32
- * export default class CreateUsersTable extends Migration {
33
- * public readonly table = "users";
34
- *
35
- * public up(): void {
36
- * this.createTable();
37
- * this.id();
38
- * this.string("name");
39
- * this.string("email").unique();
40
- * this.timestamps();
41
- * }
42
- *
43
- * public down(): void {
44
- * this.dropTable();
45
- * }
46
- * }
47
- * ```
48
- */
49
- class Migration {
50
- /**
51
- * Migration name that will be labeled with
52
- * If record is enabled in migration, it will be stored as migration name
53
- * in database
54
- *
55
- * @example
56
- * ```typescript
57
- * "2024-01-15_create-users";
58
- * ```
59
- */
60
- static migrationName;
61
- /**
62
- * Table/collection name for this migration.
63
- *
64
- * Must be defined by each migration class (either directly or via `Migration.for()`).
65
- */
66
- table;
67
- /**
68
- * Sort order
69
- * If not provided, it will be ordered alphabetically
70
- */
71
- static order;
72
- /**
73
- * Optional data source override.
74
- *
75
- * If specified, this migration will use a specific data source
76
- * instead of the default one. Can be a string name or DataSource instance.
77
- */
78
- dataSource;
79
- /**
80
- * Optional timestamp override.
81
- *
82
- * By default, the migration runner extracts this from the filename.
83
- * Set explicitly to override the execution order.
84
- *
85
- * Format: ISO 8601 or any parseable date string.
86
- */
87
- static createdAt;
88
- /**
89
- * Whether to wrap migration in a transaction.
90
- *
91
- * Defaults to `true` for SQL databases that support DDL transactions.
92
- * Set to `false` for operations that cannot be transactional.
93
- *
94
- * Note: MongoDB does not support transactions for most DDL operations.
95
- */
96
- transactional;
97
- /**
98
- * Migration driver instance (injected by the runner).
99
- */
100
- driver;
101
- /**
102
- * Migration defaults from the resolved DataSource.
103
- * @internal
104
- */
105
- /** @internal — readable by factory-generated subclasses */
106
- _migrationDefaults;
107
- /**
108
- * Queued operations to execute.
109
- */
110
- pendingOperations = [];
111
- // ============================================================================
112
- // STATIC FACTORY
113
- // ============================================================================
114
- /**
115
- * Create a migration class bound to a specific model.
116
- *
117
- * Automatically inherits the model's table name and data source,
118
- * reducing boilerplate and ensuring consistency.
119
- *
120
- * @param model - Model class to bind
121
- * @returns Abstract migration class bound to the model
122
- *
123
- * @example
124
- * ```typescript
125
- * export default class extends Migration.for(User) {
126
- * public up(): void {
127
- * this.string("avatar").nullable();
128
- * }
129
- *
130
- * public down(): void {
131
- * this.dropColumn("avatar");
132
- * }
133
- * }
134
- * ```
135
- */
136
- static for(model) {
137
- class BoundMigration extends Migration {
138
- table = model.table;
139
- dataSource = model.dataSource;
140
- }
141
- return BoundMigration;
142
- }
143
- // ============================================================================
144
- // DRIVER INJECTION
145
- // ============================================================================
146
- /**
147
- * Set the migration driver.
148
- *
149
- * Called by the migration runner before executing up/down.
150
- *
151
- * @param driver - Migration driver instance
152
- * @internal
153
- */
154
- setDriver(driver) {
155
- this.driver = driver;
156
- }
157
- /**
158
- * Set migration defaults from the resolved DataSource.
159
- *
160
- * @param defaults - Migration defaults (UUID strategy, etc.)
161
- * @internal
162
- */
163
- setMigrationDefaults(defaults) {
164
- this._migrationDefaults = defaults;
165
- }
166
- /**
167
- * Get the migration driver.
168
- *
169
- * @returns The migration driver instance
170
- */
171
- getDriver() {
172
- return this.driver;
173
- }
174
- /**
175
- * Get database engine (MongoDB, Postgress...etc)
176
- */
177
- get databaseEngine() {
178
- return this.driver.driver.name;
179
- }
180
- // ============================================================================
181
- // EXECUTE OPERATIONS
182
- // ============================================================================
183
- /**
184
- * Execute all pending operations.
185
- *
186
- * @deprecated Use toSQL() instead — migrations now generate SQL rather than
187
- * executing DDL directly through the driver.
188
- * @internal
189
- */
190
- async execute() {
191
- for (const op of this.pendingOperations) {
192
- await this.executeOperation(op);
193
- }
194
- this.pendingOperations.length = 0;
195
- }
196
- /**
197
- * Serialize all queued pending operations into a flat list of SQL strings.
198
- *
199
- * Call this AFTER invoking `up()` or `down()` to extract the SQL for the
200
- * operations that were queued during that call. The pending queue is cleared
201
- * after serializing so the instance is safe to reuse.
202
- *
203
- * @example
204
- * ```typescript
205
- * const migration = new CreateUsersTable();
206
- * migration.setDriver(driver);
207
- *
208
- * // Up SQL
209
- * await migration.up();
210
- * const upSQL = migration.toSQL();
211
- *
212
- * // Down SQL — reuse the same instance
213
- * await migration.down();
214
- * const downSQL = migration.toSQL();
215
- * ```
216
- */
217
- toSQL() {
218
- const serializer = this.driver.driver.getSQLSerializer();
219
- const statements = serializer.serializeAll(this.pendingOperations, this.table);
220
- this.pendingOperations.length = 0;
221
- return statements;
222
- }
223
- /**
224
- * Execute a single pending operation.
225
- */
226
- async executeOperation(op) {
227
- switch (op.type) {
228
- case "addColumn": {
229
- const column = op.payload;
230
- await this.driver.addColumn(this.table, column);
231
- if (column.checkConstraint) {
232
- await this.driver.addCheck(this.table, column.checkConstraint.name, column.checkConstraint.expression);
233
- }
234
- break;
235
- }
236
- case "dropColumn":
237
- await this.driver.dropColumn(this.table, op.payload);
238
- break;
239
- case "dropColumns":
240
- await this.driver.dropColumns(this.table, op.payload);
241
- break;
242
- case "renameColumn": {
243
- const { from, to } = op.payload;
244
- await this.driver.renameColumn(this.table, from, to);
245
- break;
246
- }
247
- case "modifyColumn":
248
- await this.driver.modifyColumn(this.table, op.payload);
249
- break;
250
- case "createIndex":
251
- await this.driver.createIndex(this.table, op.payload);
252
- break;
253
- case "dropIndex":
254
- await this.driver.dropIndex(this.table, op.payload);
255
- break;
256
- case "createUniqueIndex": {
257
- const { columns, name } = op.payload;
258
- await this.driver.createUniqueIndex(this.table, columns, name);
259
- break;
260
- }
261
- case "dropUniqueIndex":
262
- await this.driver.dropUniqueIndex(this.table, op.payload);
263
- break;
264
- case "createFullTextIndex": {
265
- const { columns, options } = op.payload;
266
- await this.driver.createFullTextIndex(this.table, columns, options);
267
- break;
268
- }
269
- case "dropFullTextIndex":
270
- await this.driver.dropFullTextIndex(this.table, op.payload);
271
- break;
272
- case "createGeoIndex": {
273
- const { column, options } = op.payload;
274
- await this.driver.createGeoIndex(this.table, column, options);
275
- break;
276
- }
277
- case "dropGeoIndex":
278
- await this.driver.dropGeoIndex(this.table, op.payload);
279
- break;
280
- case "createVectorIndex": {
281
- const { column, options } = op.payload;
282
- await this.driver.createVectorIndex(this.table, column, options);
283
- break;
284
- }
285
- case "dropVectorIndex":
286
- await this.driver.dropVectorIndex(this.table, op.payload);
287
- break;
288
- case "createTTLIndex": {
289
- const { column, seconds } = op.payload;
290
- await this.driver.createTTLIndex(this.table, column, seconds);
291
- break;
292
- }
293
- case "dropTTLIndex":
294
- await this.driver.dropTTLIndex(this.table, op.payload);
295
- break;
296
- case "addForeignKey":
297
- await this.driver.addForeignKey(this.table, op.payload);
298
- break;
299
- case "dropForeignKey":
300
- await this.driver.dropForeignKey(this.table, op.payload);
301
- break;
302
- case "addPrimaryKey":
303
- await this.driver.addPrimaryKey(this.table, op.payload);
304
- break;
305
- case "dropPrimaryKey":
306
- await this.driver.dropPrimaryKey(this.table);
307
- break;
308
- case "addCheck": {
309
- const { name, expression } = op.payload;
310
- await this.driver.addCheck(this.table, name, expression);
311
- break;
312
- }
313
- case "dropCheck":
314
- await this.driver.dropCheck(this.table, op.payload);
315
- break;
316
- case "createTable":
317
- await this.driver.createTable(this.table);
318
- break;
319
- case "createTableIfNotExists":
320
- await this.driver.createTableIfNotExists(this.table);
321
- break;
322
- case "dropTable":
323
- await this.driver.dropTable(this.table);
324
- break;
325
- case "dropTableIfExists":
326
- await this.driver.dropTableIfExists(this.table);
327
- break;
328
- case "renameTable":
329
- await this.driver.renameTable(this.table, op.payload);
330
- break;
331
- case "truncateTable":
332
- await this.driver.truncateTable(this.table);
333
- break;
334
- case "createTimestamps":
335
- await this.driver.createTimestampColumns(this.table);
336
- break;
337
- case "rawStatement":
338
- await this.driver.raw(async (client) => {
339
- const sql = op.payload;
340
- // Handle different driver APIs
341
- if (typeof client.query === "function") {
342
- // PostgreSQL, MySQL - client is the driver instance
343
- await client.query(sql);
344
- }
345
- else if (typeof client.command === "function") {
346
- // MongoDB - client is the Db instance
347
- await client.command({ $eval: sql });
348
- }
349
- else {
350
- throw new Error("Unsupported database driver for statement execution");
351
- }
352
- });
353
- break;
354
- case "setSchemaValidation":
355
- await this.driver.setSchemaValidation(this.table, op.payload);
356
- break;
357
- case "removeSchemaValidation":
358
- await this.driver.removeSchemaValidation(this.table);
359
- break;
360
- }
361
- }
362
- // ============================================================================
363
- // SCHEMA INSPECTION
364
- // ============================================================================
365
- /**
366
- * Check if a table exists.
367
- *
368
- * Useful for conditional migrations and idempotent operations.
369
- *
370
- * @param tableName - Table name to check
371
- * @returns Promise resolving to true if table exists
372
- *
373
- * @example
374
- * ```typescript
375
- * public async up() {
376
- * if (await this.hasTable("users_backup")) {
377
- * this.dropTable("users_backup");
378
- * }
379
- * // ... rest of migration
380
- * }
381
- * ```
382
- */
383
- async hasTable(tableName) {
384
- return this.driver.tableExists(tableName);
385
- }
386
- /**
387
- * Check if a column exists in the current table.
388
- *
389
- * @param columnName - Column name to check
390
- * @returns Promise resolving to true if column exists
391
- *
392
- * @example
393
- * ```typescript
394
- * public async up() {
395
- * if (!(await this.hasColumn("email"))) {
396
- * this.string("email").unique();
397
- * }
398
- * }
399
- * ```
400
- */
401
- async hasColumn(columnName) {
402
- const columns = await this.getColumns();
403
- return columns.some((col) => col.name === columnName);
404
- }
405
- /**
406
- * Get all columns in the current table.
407
- *
408
- * @returns Promise resolving to array of column definitions
409
- *
410
- * @example
411
- * ```typescript
412
- * const columns = await this.getColumns();
413
- * if (columns.find(col => col.type === "string" && !col.length)) {
414
- * // migrate all unbounded strings
415
- * }
416
- * ```
417
- */
418
- async getColumns() {
419
- return this.driver.listColumns(this.table);
420
- }
421
- /**
422
- * List all tables in the current database/connection.
423
- *
424
- * @returns Promise resolving to array of table names
425
- *
426
- * @example
427
- * ```typescript
428
- * const tables = await this.listTables();
429
- * for (const table of tables) {
430
- * // process each table
431
- * }
432
- * ```
433
- */
434
- async listTables() {
435
- return this.driver.listTables();
436
- }
437
- /**
438
- * Get all indexes on the current table.
439
- */
440
- async getIndexes() {
441
- return this.driver.listIndexes(this.table);
442
- }
443
- /**
444
- * Check if a named index exists on the current table.
445
- */
446
- async hasIndex(indexName) {
447
- const indexes = await this.getIndexes();
448
- return indexes.some((idx) => idx.name === indexName);
449
- }
450
- // ============================================================================
451
- // INTERNAL HELPERS
452
- // ============================================================================
453
- /**
454
- * Add a pending index definition.
455
- *
456
- * Called by ColumnBuilder when .unique() or .index() is chained.
457
- * Routes into pendingOperations so indexes execute in definition order
458
- * alongside columns and constraints.
459
- *
460
- * @param index - Index definition
461
- * @internal
462
- */
463
- addPendingIndex(index) {
464
- if (index.unique) {
465
- this.pendingOperations.push({
466
- type: "createUniqueIndex",
467
- payload: { columns: index.columns, name: index.name },
468
- });
469
- }
470
- else {
471
- this.pendingOperations.push({
472
- type: "createIndex",
473
- payload: index,
474
- });
475
- }
476
- }
477
- /**
478
- * Add a foreign key operation.
479
- *
480
- * Called by ForeignKeyBuilder or ColumnBuilder when .references() is called.
481
- *
482
- * @param fk - Foreign key definition
483
- * @internal
484
- */
485
- addForeignKeyOperation(fk) {
486
- this.pendingOperations.push({
487
- type: "addForeignKey",
488
- payload: fk,
489
- });
490
- }
491
- // ============================================================================
492
- // TABLE OPERATIONS
493
- // ============================================================================
494
- /**
495
- * Create the table/collection.
496
- *
497
- * For SQL, this creates an empty table.
498
- * For MongoDB, this creates the collection.
499
- *
500
- * @returns This migration for chaining
501
- */
502
- createTable() {
503
- this.pendingOperations.push({ type: "createTable", payload: null });
504
- return this;
505
- }
506
- /**
507
- * Create table if not exists
508
- */
509
- createTableIfNotExists() {
510
- this.pendingOperations.push({ type: "createTableIfNotExists", payload: null });
511
- return this;
512
- }
513
- /**
514
- * Drop the table/collection.
515
- *
516
- * @returns This migration for chaining
517
- */
518
- dropTable() {
519
- this.pendingOperations.push({ type: "dropTable", payload: null });
520
- return this;
521
- }
522
- /**
523
- * Drop the table/collection if it exists.
524
- *
525
- * No error is thrown if the table doesn't exist.
526
- *
527
- * @returns This migration for chaining
528
- */
529
- dropTableIfExists() {
530
- this.pendingOperations.push({ type: "dropTableIfExists", payload: null });
531
- return this;
532
- }
533
- /**
534
- * Rename the table/collection.
535
- *
536
- * @param newName - New table name
537
- * @returns This migration for chaining
538
- */
539
- renameTableTo(newName) {
540
- this.pendingOperations.push({ type: "renameTable", payload: newName });
541
- return this;
542
- }
543
- /**
544
- * Truncate the table — remove all rows without logging or firing triggers.
545
- *
546
- * Faster than DELETE with no WHERE clause. Resets auto-increment counters
547
- * on most databases.
548
- *
549
- * @returns This migration for chaining
550
- */
551
- truncateTable() {
552
- this.pendingOperations.push({ type: "truncateTable", payload: null });
553
- return this;
554
- }
555
- // ============================================================================
556
- // COLUMN TYPES - STRING
557
- // ============================================================================
558
- /**
559
- * Add a string/varchar column.
560
- *
561
- * @param column - Column name
562
- * @param length - Max length (default: 255)
563
- * @returns Column builder for chaining modifiers
564
- *
565
- * @example
566
- * ```typescript
567
- * this.string("name"); // VARCHAR(255)
568
- * this.string("code", 10); // VARCHAR(10)
569
- * ```
570
- */
571
- string(column, length = 255) {
572
- const builder = new ColumnBuilder(this, column, "string", { length });
573
- this.pendingOperations.push({
574
- type: "addColumn",
575
- payload: builder.getDefinition(),
576
- });
577
- return builder;
578
- }
579
- /**
580
- * Add a fixed-length char column.
581
- *
582
- * @param column - Column name
583
- * @param length - Exact length
584
- * @returns Column builder for chaining modifiers
585
- */
586
- char(column, length) {
587
- const builder = new ColumnBuilder(this, column, "char", { length });
588
- this.pendingOperations.push({
589
- type: "addColumn",
590
- payload: builder.getDefinition(),
591
- });
592
- return builder;
593
- }
594
- /**
595
- * Add a text column (unlimited length).
596
- *
597
- * @param column - Column name
598
- * @returns Column builder for chaining modifiers
599
- */
600
- text(column) {
601
- const builder = new ColumnBuilder(this, column, "text");
602
- this.pendingOperations.push({
603
- type: "addColumn",
604
- payload: builder.getDefinition(),
605
- });
606
- return builder;
607
- }
608
- /**
609
- * Add a medium text column.
610
- *
611
- * @param column - Column name
612
- * @returns Column builder for chaining modifiers
613
- */
614
- mediumText(column) {
615
- const builder = new ColumnBuilder(this, column, "mediumText");
616
- this.pendingOperations.push({
617
- type: "addColumn",
618
- payload: builder.getDefinition(),
619
- });
620
- return builder;
621
- }
622
- /**
623
- * Add a long text column.
624
- *
625
- * @param column - Column name
626
- * @returns Column builder for chaining modifiers
627
- */
628
- longText(column) {
629
- const builder = new ColumnBuilder(this, column, "longText");
630
- this.pendingOperations.push({
631
- type: "addColumn",
632
- payload: builder.getDefinition(),
633
- });
634
- return builder;
635
- }
636
- // ============================================================================
637
- // COLUMN TYPES - NUMERIC
638
- // ============================================================================
639
- /**
640
- * Add an integer column.
641
- *
642
- * @param column - Column name
643
- * @returns Column builder for chaining modifiers
644
- */
645
- integer(column) {
646
- const builder = new ColumnBuilder(this, column, "integer");
647
- this.pendingOperations.push({
648
- type: "addColumn",
649
- payload: builder.getDefinition(),
650
- });
651
- return builder;
652
- }
653
- /**
654
- * Alias for integer().
655
- */
656
- int(column) {
657
- return this.integer(column);
658
- }
659
- /**
660
- * Add a small integer column.
661
- *
662
- * @param column - Column name
663
- * @returns Column builder for chaining modifiers
664
- */
665
- smallInteger(column) {
666
- const builder = new ColumnBuilder(this, column, "smallInteger");
667
- this.pendingOperations.push({
668
- type: "addColumn",
669
- payload: builder.getDefinition(),
670
- });
671
- return builder;
672
- }
673
- /**
674
- * Alias for smallInteger().
675
- */
676
- smallInt(column) {
677
- return this.smallInteger(column);
678
- }
679
- /**
680
- * Add a tiny integer column.
681
- *
682
- * @param column - Column name
683
- * @returns Column builder for chaining modifiers
684
- */
685
- tinyInteger(column) {
686
- const builder = new ColumnBuilder(this, column, "tinyInteger");
687
- this.pendingOperations.push({
688
- type: "addColumn",
689
- payload: builder.getDefinition(),
690
- });
691
- return builder;
692
- }
693
- /**
694
- * Alias for tinyInteger().
695
- */
696
- tinyInt(column) {
697
- return this.tinyInteger(column);
698
- }
699
- /**
700
- * Add a big integer column.
701
- *
702
- * @param column - Column name
703
- * @returns Column builder for chaining modifiers
704
- */
705
- bigInteger(column) {
706
- const builder = new ColumnBuilder(this, column, "bigInteger");
707
- this.pendingOperations.push({
708
- type: "addColumn",
709
- payload: builder.getDefinition(),
710
- });
711
- return builder;
712
- }
713
- /**
714
- * Alias for bigInteger().
715
- */
716
- bigInt(column) {
717
- return this.bigInteger(column);
718
- }
719
- /**
720
- * Add a float column.
721
- *
722
- * @param column - Column name
723
- * @returns Column builder for chaining modifiers
724
- */
725
- float(column) {
726
- const builder = new ColumnBuilder(this, column, "float");
727
- this.pendingOperations.push({
728
- type: "addColumn",
729
- payload: builder.getDefinition(),
730
- });
731
- return builder;
732
- }
733
- /**
734
- * Add a double precision column.
735
- *
736
- * @param column - Column name
737
- * @returns Column builder for chaining modifiers
738
- */
739
- double(column) {
740
- const builder = new ColumnBuilder(this, column, "double");
741
- this.pendingOperations.push({
742
- type: "addColumn",
743
- payload: builder.getDefinition(),
744
- });
745
- return builder;
746
- }
747
- /**
748
- * Add a decimal column with precision and scale.
749
- *
750
- * @param column - Column name
751
- * @param precision - Total digits (default: 8)
752
- * @param scale - Decimal places (default: 2)
753
- * @returns Column builder for chaining modifiers
754
- *
755
- * @example
756
- * ```typescript
757
- * this.decimal("price", 10, 2); // DECIMAL(10,2) - up to 99999999.99
758
- * ```
759
- */
760
- decimal(column, precision = 8, scale = 2) {
761
- const builder = new ColumnBuilder(this, column, "decimal", {
762
- precision,
763
- scale,
764
- });
765
- this.pendingOperations.push({
766
- type: "addColumn",
767
- payload: builder.getDefinition(),
768
- });
769
- return builder;
770
- }
771
- // ============================================================================
772
- // COLUMN TYPES - BOOLEAN
773
- // ============================================================================
774
- /**
775
- * Add a boolean column.
776
- *
777
- * @param column - Column name
778
- * @returns Column builder for chaining modifiers
779
- */
780
- boolean(column) {
781
- const builder = new ColumnBuilder(this, column, "boolean");
782
- this.pendingOperations.push({
783
- type: "addColumn",
784
- payload: builder.getDefinition(),
785
- });
786
- return builder;
787
- }
788
- /**
789
- * Alias for boolean().
790
- */
791
- bool(column) {
792
- return this.boolean(column);
793
- }
794
- // ============================================================================
795
- // COLUMN TYPES - DATE/TIME
796
- // ============================================================================
797
- /**
798
- * Add a date column (date only, no time).
799
- *
800
- * @param column - Column name
801
- * @returns Column builder for chaining modifiers
802
- */
803
- date(column) {
804
- const builder = new ColumnBuilder(this, column, "date");
805
- this.pendingOperations.push({
806
- type: "addColumn",
807
- payload: builder.getDefinition(),
808
- });
809
- return builder;
810
- }
811
- /**
812
- * Add a datetime column (date and time).
813
- *
814
- * @param column - Column name
815
- * @returns Column builder for chaining modifiers
816
- */
817
- dateTime(column) {
818
- const builder = new ColumnBuilder(this, column, "dateTime");
819
- this.pendingOperations.push({
820
- type: "addColumn",
821
- payload: builder.getDefinition(),
822
- });
823
- return builder;
824
- }
825
- /**
826
- * Add a timestamp column.
827
- *
828
- * @param column - Column name
829
- * @returns Column builder for chaining modifiers
830
- */
831
- timestamp(column) {
832
- const builder = new ColumnBuilder(this, column, "timestamp");
833
- this.pendingOperations.push({
834
- type: "addColumn",
835
- payload: builder.getDefinition(),
836
- });
837
- return builder;
838
- }
839
- /**
840
- * Add a time column (time only, no date).
841
- *
842
- * @param column - Column name
843
- * @returns Column builder for chaining modifiers
844
- */
845
- time(column) {
846
- const builder = new ColumnBuilder(this, column, "time");
847
- this.pendingOperations.push({
848
- type: "addColumn",
849
- payload: builder.getDefinition(),
850
- });
851
- return builder;
852
- }
853
- /**
854
- * Add a year column.
855
- *
856
- * @param column - Column name
857
- * @returns Column builder for chaining modifiers
858
- */
859
- year(column) {
860
- const builder = new ColumnBuilder(this, column, "year");
861
- this.pendingOperations.push({
862
- type: "addColumn",
863
- payload: builder.getDefinition(),
864
- });
865
- return builder;
866
- }
867
- // ============================================================================
868
- // COLUMN TYPES - JSON & BINARY
869
- // ============================================================================
870
- /**
871
- * Add a JSON column.
872
- *
873
- * @param column - Column name
874
- * @returns Column builder for chaining modifiers
875
- */
876
- json(column) {
877
- const builder = new ColumnBuilder(this, column, "json");
878
- this.pendingOperations.push({
879
- type: "addColumn",
880
- payload: builder.getDefinition(),
881
- });
882
- return builder;
883
- }
884
- /**
885
- * Alias for json().
886
- */
887
- object(column) {
888
- return this.json(column);
889
- }
890
- /**
891
- * Add a binary/blob column.
892
- *
893
- * @param column - Column name
894
- * @returns Column builder for chaining modifiers
895
- */
896
- binary(column) {
897
- const builder = new ColumnBuilder(this, column, "binary");
898
- this.pendingOperations.push({
899
- type: "addColumn",
900
- payload: builder.getDefinition(),
901
- });
902
- return builder;
903
- }
904
- /**
905
- * Alias for binary().
906
- */
907
- blob(column) {
908
- return this.binary(column);
909
- }
910
- // ============================================================================
911
- // COLUMN TYPES - IDENTIFIERS
912
- // ============================================================================
913
- /**
914
- * Add a UUID column.
915
- *
916
- * @param column - Column name
917
- * @returns Column builder for chaining modifiers
918
- */
919
- uuid(column) {
920
- const builder = new ColumnBuilder(this, column, "uuid");
921
- this.pendingOperations.push({
922
- type: "addColumn",
923
- payload: builder.getDefinition(),
924
- });
925
- return builder;
926
- }
927
- /**
928
- * Add a ULID column.
929
- *
930
- * @param column - Column name
931
- * @returns Column builder for chaining modifiers
932
- */
933
- ulid(column) {
934
- const builder = new ColumnBuilder(this, column, "ulid");
935
- this.pendingOperations.push({
936
- type: "addColumn",
937
- payload: builder.getDefinition(),
938
- });
939
- return builder;
940
- }
941
- // ============================================================================
942
- // COLUMN TYPES - NETWORK
943
- // ============================================================================
944
- /**
945
- * Add an IP address column.
946
- *
947
- * @param column - Column name
948
- * @returns Column builder for chaining modifiers
949
- */
950
- ipAddress(column) {
951
- const builder = new ColumnBuilder(this, column, "ipAddress");
952
- this.pendingOperations.push({
953
- type: "addColumn",
954
- payload: builder.getDefinition(),
955
- });
956
- return builder;
957
- }
958
- /**
959
- * Add a MAC address column.
960
- *
961
- * @param column - Column name
962
- * @returns Column builder for chaining modifiers
963
- */
964
- macAddress(column) {
965
- const builder = new ColumnBuilder(this, column, "macAddress");
966
- this.pendingOperations.push({
967
- type: "addColumn",
968
- payload: builder.getDefinition(),
969
- });
970
- return builder;
971
- }
972
- // ============================================================================
973
- // COLUMN TYPES - GEO & SPATIAL
974
- // ============================================================================
975
- /**
976
- * Add a geo point column.
977
- *
978
- * @param column - Column name
979
- * @returns Column builder for chaining modifiers
980
- */
981
- point(column) {
982
- const builder = new ColumnBuilder(this, column, "point");
983
- this.pendingOperations.push({
984
- type: "addColumn",
985
- payload: builder.getDefinition(),
986
- });
987
- return builder;
988
- }
989
- /**
990
- * Add a polygon column.
991
- *
992
- * @param column - Column name
993
- * @returns Column builder for chaining modifiers
994
- */
995
- polygon(column) {
996
- const builder = new ColumnBuilder(this, column, "polygon");
997
- this.pendingOperations.push({
998
- type: "addColumn",
999
- payload: builder.getDefinition(),
1000
- });
1001
- return builder;
1002
- }
1003
- /**
1004
- * Add a line string column.
1005
- *
1006
- * @param column - Column name
1007
- * @returns Column builder for chaining modifiers
1008
- */
1009
- lineString(column) {
1010
- const builder = new ColumnBuilder(this, column, "lineString");
1011
- this.pendingOperations.push({
1012
- type: "addColumn",
1013
- payload: builder.getDefinition(),
1014
- });
1015
- return builder;
1016
- }
1017
- /**
1018
- * Add a generic geometry column.
1019
- *
1020
- * @param column - Column name
1021
- * @returns Column builder for chaining modifiers
1022
- */
1023
- geometry(column) {
1024
- const builder = new ColumnBuilder(this, column, "geometry");
1025
- this.pendingOperations.push({
1026
- type: "addColumn",
1027
- payload: builder.getDefinition(),
1028
- });
1029
- return builder;
1030
- }
1031
- // ============================================================================
1032
- // COLUMN TYPES - AI/ML
1033
- // ============================================================================
1034
- /**
1035
- * Add a vector column for AI embeddings.
1036
- *
1037
- * Used for storing and searching ML embeddings (e.g., OpenAI, Cohere).
1038
- *
1039
- * @param column - Column name
1040
- * @param dimensions - Vector dimensions (e.g., 1536 for OpenAI ada-002)
1041
- * @returns Column builder for chaining modifiers
1042
- *
1043
- * @example
1044
- * ```typescript
1045
- * this.vector("embedding", 1536); // OpenAI ada-002
1046
- * this.vector("embedding", 384); // Sentence Transformers
1047
- * ```
1048
- */
1049
- vector(column, dimensions) {
1050
- const builder = new ColumnBuilder(this, column, "vector", { dimensions });
1051
- this.pendingOperations.push({
1052
- type: "addColumn",
1053
- payload: builder.getDefinition(),
1054
- });
1055
- return builder;
1056
- }
1057
- // ============================================================================
1058
- // COLUMN TYPES - ENUM & SET
1059
- // ============================================================================
1060
- /**
1061
- * Add an enum column with allowed values.
1062
- *
1063
- * @param column - Column name
1064
- * @param values - Allowed enum values
1065
- * @returns Column builder for chaining modifiers
1066
- *
1067
- * @example
1068
- * ```typescript
1069
- * this.enum("status", ["pending", "active", "archived"]);
1070
- * ```
1071
- */
1072
- enum(column, values) {
1073
- const builder = new ColumnBuilder(this, column, "enum", { values });
1074
- this.pendingOperations.push({
1075
- type: "addColumn",
1076
- payload: builder.getDefinition(),
1077
- });
1078
- return builder;
1079
- }
1080
- /**
1081
- * Add a set column (multiple values from a set).
1082
- *
1083
- * @param column - Column name
1084
- * @param values - Allowed set values
1085
- * @returns Column builder for chaining modifiers
1086
- */
1087
- set(column, values) {
1088
- const builder = new ColumnBuilder(this, column, "set", { values });
1089
- this.pendingOperations.push({
1090
- type: "addColumn",
1091
- payload: builder.getDefinition(),
1092
- });
1093
- return builder;
1094
- }
1095
- // ============================================================================
1096
- // COLUMN TYPES - POSTGRESQL ARRAYS
1097
- // ============================================================================
1098
- /**
1099
- * Add an INTEGER[] column (array of integers).
1100
- *
1101
- * @example
1102
- * ```typescript
1103
- * this.arrayInt("scores"); // INTEGER[]
1104
- * ```
1105
- */
1106
- arrayInt(column) {
1107
- const builder = new ColumnBuilder(this, column, "arrayInt");
1108
- this.pendingOperations.push({ type: "addColumn", payload: builder.getDefinition() });
1109
- return builder;
1110
- }
1111
- /**
1112
- * Add a BIGINT[] column (array of big integers).
1113
- *
1114
- * @example
1115
- * ```typescript
1116
- * this.arrayBigInt("ids"); // BIGINT[]
1117
- * ```
1118
- */
1119
- arrayBigInt(column) {
1120
- const builder = new ColumnBuilder(this, column, "arrayBigInt");
1121
- this.pendingOperations.push({ type: "addColumn", payload: builder.getDefinition() });
1122
- return builder;
1123
- }
1124
- /**
1125
- * Add a REAL[] column (array of floats).
1126
- *
1127
- * @example
1128
- * ```typescript
1129
- * this.arrayFloat("weights"); // REAL[]
1130
- * ```
1131
- */
1132
- arrayFloat(column) {
1133
- const builder = new ColumnBuilder(this, column, "arrayFloat");
1134
- this.pendingOperations.push({ type: "addColumn", payload: builder.getDefinition() });
1135
- return builder;
1136
- }
1137
- /**
1138
- * Add a DECIMAL[] column (array of decimals).
1139
- *
1140
- * @param precision - Total digits
1141
- * @param scale - Digits after decimal point
1142
- *
1143
- * @example
1144
- * ```typescript
1145
- * this.arrayDecimal("prices", 10, 2); // DECIMAL(10,2)[]
1146
- * this.arrayDecimal("amounts"); // DECIMAL[]
1147
- * ```
1148
- */
1149
- arrayDecimal(column, precision, scale) {
1150
- const builder = new ColumnBuilder(this, column, "arrayDecimal", { precision, scale });
1151
- this.pendingOperations.push({ type: "addColumn", payload: builder.getDefinition() });
1152
- return builder;
1153
- }
1154
- /**
1155
- * Add a BOOLEAN[] column (array of booleans).
1156
- *
1157
- * @example
1158
- * ```typescript
1159
- * this.arrayBoolean("flags"); // BOOLEAN[]
1160
- * ```
1161
- */
1162
- arrayBoolean(column) {
1163
- const builder = new ColumnBuilder(this, column, "arrayBoolean");
1164
- this.pendingOperations.push({ type: "addColumn", payload: builder.getDefinition() });
1165
- return builder;
1166
- }
1167
- /**
1168
- * Add a TEXT[] column (array of text values).
1169
- *
1170
- * @example
1171
- * ```typescript
1172
- * this.arrayText("tags"); // TEXT[]
1173
- * ```
1174
- */
1175
- arrayText(column) {
1176
- const builder = new ColumnBuilder(this, column, "arrayText");
1177
- this.pendingOperations.push({ type: "addColumn", payload: builder.getDefinition() });
1178
- return builder;
1179
- }
1180
- /**
1181
- * Add a DATE[] column (array of dates).
1182
- *
1183
- * @example
1184
- * ```typescript
1185
- * this.arrayDate("holidays"); // DATE[]
1186
- * ```
1187
- */
1188
- arrayDate(column) {
1189
- const builder = new ColumnBuilder(this, column, "arrayDate");
1190
- this.pendingOperations.push({ type: "addColumn", payload: builder.getDefinition() });
1191
- return builder;
1192
- }
1193
- /**
1194
- * Add a TIMESTAMPTZ[] column (array of timestamps with time zone).
1195
- *
1196
- * @example
1197
- * ```typescript
1198
- * this.arrayTimestamp("events"); // TIMESTAMPTZ[]
1199
- * ```
1200
- */
1201
- arrayTimestamp(column) {
1202
- const builder = new ColumnBuilder(this, column, "arrayTimestamp");
1203
- this.pendingOperations.push({ type: "addColumn", payload: builder.getDefinition() });
1204
- return builder;
1205
- }
1206
- /**
1207
- * Add a UUID[] column (array of UUIDs).
1208
- *
1209
- * @example
1210
- * ```typescript
1211
- * this.arrayUuid("relatedIds"); // UUID[]
1212
- * ```
1213
- */
1214
- arrayUuid(column) {
1215
- const builder = new ColumnBuilder(this, column, "arrayUuid");
1216
- this.pendingOperations.push({ type: "addColumn", payload: builder.getDefinition() });
1217
- return builder;
1218
- }
1219
- // ============================================================================
1220
- // SHORTCUTS
1221
- // ============================================================================
1222
- /**
1223
- * Add an auto-increment primary key column.
1224
- *
1225
- * Creates an unsigned integer with primary key and auto-increment.
1226
- *
1227
- * @param name - Column name (default: "id")
1228
- * @returns Column builder for chaining modifiers
1229
- *
1230
- * @example
1231
- * ```typescript
1232
- * this.id(); // Creates "id" column
1233
- * this.id("userId"); // Creates "userId" column
1234
- * ```
1235
- */
1236
- id(name = "id") {
1237
- return this.integer(name).primary().autoIncrement().unsigned();
1238
- }
1239
- /**
1240
- * Add a big integer auto-increment primary key column.
1241
- *
1242
- * @param name - Column name (default: "id")
1243
- * @returns Column builder for chaining modifiers
1244
- */
1245
- bigId(name = "id") {
1246
- return this.bigInteger(name).primary().autoIncrement().unsigned();
1247
- }
1248
- /**
1249
- * Add a UUID primary key column.
1250
- *
1251
- * @param name - Column name (default: "id")
1252
- * @returns Column builder for chaining modifiers
1253
- */
1254
- uuidId(name = "id") {
1255
- return this.uuid(name).primary();
1256
- }
1257
- /**
1258
- * Add a UUID primary key column with automatic generation.
1259
- *
1260
- * Delegates UUID expression to the migration driver, which resolves
1261
- * the default based on `migrationDefaults` from the DataSource config.
1262
- *
1263
- * Resolution order:
1264
- * 1. `migrationDefaults.uuidExpression` (raw escape hatch)
1265
- * 2. `migrationDefaults.uuidStrategy` (mapped per driver)
1266
- * 3. Driver default (PostgreSQL: `gen_random_uuid()`, MongoDB: undefined)
1267
- *
1268
- * @param name - Column name (default: "id")
1269
- * @returns Column builder for chaining modifiers
1270
- *
1271
- * @example
1272
- * ```typescript
1273
- * this.primaryUuid(); // id UUID PRIMARY KEY DEFAULT gen_random_uuid()
1274
- * this.primaryUuid("organization_id"); // Custom column name
1275
- * ```
1276
- */
1277
- primaryUuid(name = "id") {
1278
- const uuidDefault = this.driver.getUuidDefault(this._migrationDefaults);
1279
- const builder = this.uuid(name).primary();
1280
- if (uuidDefault) {
1281
- builder.default(uuidDefault);
1282
- }
1283
- return builder;
1284
- }
1285
- /**
1286
- * Add createdAt and updatedAt timestamp columns.
1287
- *
1288
- * Behavior varies by database driver:
1289
- * - PostgreSQL: Creates TIMESTAMPTZ columns with NOW() defaults
1290
- * - MongoDB: No-op (timestamps handled at application level)
1291
- *
1292
- * @returns This migration for chaining
1293
- *
1294
- * @example
1295
- * ```typescript
1296
- * this.timestamps(); // Driver-specific implementation
1297
- * ```
1298
- */
1299
- timestamps() {
1300
- this.pendingOperations.push({ type: "createTimestamps", payload: null });
1301
- return this;
1302
- }
1303
- /**
1304
- * Add a deletedAt column for soft deletes.
1305
- *
1306
- * @param column - Column name (default: "deletedAt")
1307
- * @returns Column builder for chaining modifiers
1308
- */
1309
- softDeletes(column = "deletedAt") {
1310
- return this.dateTime(column).nullable();
1311
- }
1312
- // ============================================================================
1313
- // DROP COLUMN OPERATIONS
1314
- // ============================================================================
1315
- /**
1316
- * Drop a column.
1317
- *
1318
- * @param column - Column name to drop
1319
- * @returns This migration for chaining
1320
- */
1321
- dropColumn(column) {
1322
- this.pendingOperations.push({ type: "dropColumn", payload: column });
1323
- return this;
1324
- }
1325
- /**
1326
- * Drop multiple columns.
1327
- *
1328
- * @param columns - Column names to drop
1329
- * @returns This migration for chaining
1330
- */
1331
- dropColumns(...columns) {
1332
- this.pendingOperations.push({ type: "dropColumns", payload: columns });
1333
- return this;
1334
- }
1335
- /**
1336
- * Rename a column.
1337
- *
1338
- * @param from - Current column name
1339
- * @param to - New column name
1340
- * @returns This migration for chaining
1341
- */
1342
- renameColumn(from, to) {
1343
- this.pendingOperations.push({
1344
- type: "renameColumn",
1345
- payload: { from, to },
1346
- });
1347
- return this;
1348
- }
1349
- // ============================================================================
1350
- // INDEX OPERATIONS
1351
- // ============================================================================
1352
- /**
1353
- * Create an index on one or more columns.
1354
- *
1355
- * @param columns - Column(s) to index
1356
- * @param name - Optional index name
1357
- * @param options - Optional index options (include, concurrently)
1358
- * @returns This migration for chaining
1359
- *
1360
- * @example
1361
- * ```typescript
1362
- * this.index("email");
1363
- * this.index(["firstName", "lastName"], "name_idx");
1364
- * this.index("userId", "idx_user", { include: ["name", "email"] });
1365
- * this.index("email", "idx_email", { concurrently: true });
1366
- * ```
1367
- */
1368
- index(columns, name, options) {
1369
- const cols = Array.isArray(columns) ? columns : [columns];
1370
- this.pendingOperations.push({
1371
- type: "createIndex",
1372
- payload: {
1373
- columns: cols,
1374
- name,
1375
- include: options?.include,
1376
- concurrently: options?.concurrently,
1377
- },
1378
- });
1379
- return this;
1380
- }
1381
- /**
1382
- * Drop an index by name or columns.
1383
- *
1384
- * @param nameOrColumns - Index name (string) or columns array
1385
- * @returns This migration for chaining
1386
- *
1387
- * @example
1388
- * ```typescript
1389
- * this.dropIndex("email_idx"); // Drop by name
1390
- * this.dropIndex(["firstName", "lastName"]); // Drop by columns
1391
- * ```
1392
- */
1393
- dropIndex(nameOrColumns) {
1394
- this.pendingOperations.push({
1395
- type: "dropIndex",
1396
- payload: nameOrColumns,
1397
- });
1398
- return this;
1399
- }
1400
- /**
1401
- * Create a unique constraint/index.
1402
- *
1403
- * @param columns - Column(s) to make unique
1404
- * @param name - Optional constraint name
1405
- * @param options - Optional index options (include, concurrently)
1406
- * @returns This migration for chaining
1407
- *
1408
- * @example
1409
- * ```typescript
1410
- * this.unique("email");
1411
- * this.unique(["userId", "roleId"], "unique_user_role");
1412
- * this.unique("email", "unique_email", { include: ["name"] });
1413
- * ```
1414
- */
1415
- unique(columns, name, options) {
1416
- const cols = Array.isArray(columns) ? columns : [columns];
1417
- this.pendingOperations.push({
1418
- type: "createUniqueIndex",
1419
- payload: {
1420
- columns: cols,
1421
- name,
1422
- include: options?.include,
1423
- concurrently: options?.concurrently,
1424
- },
1425
- });
1426
- return this;
1427
- }
1428
- /**
1429
- * Drop a unique constraint/index.
1430
- *
1431
- * @param columns - Columns in the unique constraint
1432
- * @returns This migration for chaining
1433
- */
1434
- dropUnique(columns) {
1435
- const cols = Array.isArray(columns) ? columns : [columns];
1436
- this.pendingOperations.push({ type: "dropUniqueIndex", payload: cols });
1437
- return this;
1438
- }
1439
- /**
1440
- * Create an expression-based index.
1441
- *
1442
- * Allows indexing on SQL expressions rather than plain columns.
1443
- * Useful for case-insensitive searches, computed values, etc.
1444
- *
1445
- * **Note**: PostgreSQL-specific feature. MongoDB will silently ignore this.
1446
- *
1447
- * @param expressions - SQL expression(s) to index
1448
- * @param name - Optional index name
1449
- * @param options - Optional index options (concurrently)
1450
- * @returns This migration for chaining
1451
- *
1452
- * @example
1453
- * ```typescript
1454
- * // Case-insensitive email index
1455
- * this.expressionIndex(['lower(email)'], 'idx_email_lower');
1456
- *
1457
- * // Multiple expressions
1458
- * this.expressionIndex(['lower(firstName)', 'lower(lastName)'], 'idx_name_lower');
1459
- *
1460
- * // With concurrent creation (requires transactional = false)
1461
- * this.expressionIndex(['lower(email)'], 'idx_email_lower', { concurrently: true });
1462
- * ```
1463
- */
1464
- expressionIndex(expressions, name, options) {
1465
- const exprs = Array.isArray(expressions) ? expressions : [expressions];
1466
- this.pendingOperations.push({
1467
- type: "createIndex",
1468
- payload: {
1469
- columns: [],
1470
- expressions: exprs,
1471
- name,
1472
- concurrently: options?.concurrently,
1473
- },
1474
- });
1475
- return this;
1476
- }
1477
- // ============================================================================
1478
- // FULL-TEXT INDEX
1479
- // ============================================================================
1480
- /**
1481
- * Create a full-text search index.
1482
- *
1483
- * @param columns - Column(s) to index
1484
- * @param options - Full-text options
1485
- * @returns This migration for chaining
1486
- */
1487
- fullText(columns, options) {
1488
- const cols = Array.isArray(columns) ? columns : [columns];
1489
- this.pendingOperations.push({
1490
- type: "createFullTextIndex",
1491
- payload: { columns: cols, options },
1492
- });
1493
- return this;
1494
- }
1495
- /**
1496
- * Drop a full-text search index.
1497
- *
1498
- * @param name - Index name
1499
- * @returns This migration for chaining
1500
- */
1501
- dropFullText(name) {
1502
- this.pendingOperations.push({ type: "dropFullTextIndex", payload: name });
1503
- return this;
1504
- }
1505
- // ============================================================================
1506
- // GEO INDEX
1507
- // ============================================================================
1508
- /**
1509
- * Create a geo-spatial index.
1510
- *
1511
- * @param column - Geo column
1512
- * @param options - Geo index options
1513
- * @returns This migration for chaining
1514
- *
1515
- * @example
1516
- * ```typescript
1517
- * this.geoIndex("location"); // 2dsphere index
1518
- * this.geoIndex("coordinates", { type: "2d" }); // 2d index
1519
- * ```
1520
- */
1521
- geoIndex(column, options) {
1522
- this.pendingOperations.push({
1523
- type: "createGeoIndex",
1524
- payload: { column, options },
1525
- });
1526
- return this;
1527
- }
1528
- /**
1529
- * Drop a geo-spatial index.
1530
- *
1531
- * @param column - Geo column
1532
- * @returns This migration for chaining
1533
- */
1534
- dropGeoIndex(column) {
1535
- this.pendingOperations.push({ type: "dropGeoIndex", payload: column });
1536
- return this;
1537
- }
1538
- // ============================================================================
1539
- // VECTOR INDEX
1540
- // ============================================================================
1541
- /**
1542
- * Create a vector search index for AI embeddings.
1543
- *
1544
- * @param column - Vector column
1545
- * @param options - Vector index options
1546
- * @returns This migration for chaining
1547
- *
1548
- * @example
1549
- * ```typescript
1550
- * this.vectorIndex("embedding", {
1551
- * dimensions: 1536,
1552
- * similarity: "cosine",
1553
- * });
1554
- * ```
1555
- */
1556
- vectorIndex(column, options) {
1557
- this.pendingOperations.push({
1558
- type: "createVectorIndex",
1559
- payload: { column, options },
1560
- });
1561
- return this;
1562
- }
1563
- /**
1564
- * Drop a vector search index.
1565
- *
1566
- * @param column - Vector column
1567
- * @returns This migration for chaining
1568
- */
1569
- dropVectorIndex(column) {
1570
- this.pendingOperations.push({ type: "dropVectorIndex", payload: column });
1571
- return this;
1572
- }
1573
- // ============================================================================
1574
- // TTL INDEX
1575
- // ============================================================================
1576
- /**
1577
- * Create a TTL (time-to-live) index for automatic document expiration.
1578
- *
1579
- * Primarily for MongoDB. Documents are automatically deleted after the
1580
- * specified time has passed since the date in the column.
1581
- *
1582
- * @param column - Date column to check for expiration
1583
- * @param expireAfterSeconds - Seconds after which documents expire
1584
- * @returns This migration for chaining
1585
- *
1586
- * @example
1587
- * ```typescript
1588
- * // Delete sessions 24 hours after createdAt
1589
- * this.ttlIndex("createdAt", 86400);
1590
- * ```
1591
- */
1592
- ttlIndex(column, expireAfterSeconds) {
1593
- this.pendingOperations.push({
1594
- type: "createTTLIndex",
1595
- payload: { column, seconds: expireAfterSeconds },
1596
- });
1597
- return this;
1598
- }
1599
- /**
1600
- * Drop a TTL index.
1601
- *
1602
- * @param column - Column with TTL
1603
- * @returns This migration for chaining
1604
- */
1605
- dropTTLIndex(column) {
1606
- this.pendingOperations.push({ type: "dropTTLIndex", payload: column });
1607
- return this;
1608
- }
1609
- // ============================================================================
1610
- // PRIMARY KEY
1611
- // ============================================================================
1612
- /**
1613
- * Add a composite primary key.
1614
- *
1615
- * @param columns - Columns to include in the primary key
1616
- * @returns This migration for chaining
1617
- */
1618
- primaryKey(columns) {
1619
- this.pendingOperations.push({ type: "addPrimaryKey", payload: columns });
1620
- return this;
1621
- }
1622
- /**
1623
- * Drop the primary key constraint.
1624
- *
1625
- * @returns This migration for chaining
1626
- */
1627
- dropPrimaryKey() {
1628
- this.pendingOperations.push({ type: "dropPrimaryKey", payload: null });
1629
- return this;
1630
- }
1631
- // ============================================================================
1632
- // CHECK CONSTRAINTS
1633
- // ============================================================================
1634
- /**
1635
- * Add a CHECK constraint to the table.
1636
- *
1637
- * SQL-only feature. PostgreSQL, MySQL 8.0+, SQLite support this.
1638
- * Validates that rows satisfy the given SQL expression.
1639
- *
1640
- * @param name - Constraint name
1641
- * @param expression - SQL CHECK expression
1642
- * @returns This migration for chaining
1643
- *
1644
- * @example
1645
- * ```typescript
1646
- * this.check("age_positive", "age >= 0");
1647
- * this.check("valid_email", "email LIKE '%@%'");
1648
- * this.check("price_range", "price BETWEEN 0 AND 1000000");
1649
- * ```
1650
- */
1651
- check(name, expression) {
1652
- this.pendingOperations.push({
1653
- type: "addCheck",
1654
- payload: { name, expression },
1655
- });
1656
- return this;
1657
- }
1658
- /**
1659
- * Drop a CHECK constraint by name.
1660
- *
1661
- * @param name - Constraint name
1662
- * @returns This migration for chaining
1663
- *
1664
- * @example
1665
- * ```typescript
1666
- * this.dropCheck("age_positive");
1667
- * ```
1668
- */
1669
- dropCheck(name) {
1670
- this.pendingOperations.push({
1671
- type: "dropCheck",
1672
- payload: name,
1673
- });
1674
- return this;
1675
- }
1676
- // ============================================================================
1677
- // FOREIGN KEYS (SQL)
1678
- // ============================================================================
1679
- /**
1680
- * Start building a foreign key constraint on an existing column.
1681
- *
1682
- * Use this when adding a foreign key to a column that was defined in a
1683
- * previous migration. For new columns, prefer the inline form:
1684
- * `this.integer("user_id").references("users").onDelete("cascade")`
1685
- *
1686
- * SQL-only feature; NoSQL drivers ignore foreign keys.
1687
- *
1688
- * @param column - Local column that references another table
1689
- * @returns Foreign key builder for chaining
1690
- *
1691
- * @example
1692
- * ```typescript
1693
- * this.foreign("user_id")
1694
- * .references("users", "id")
1695
- * .onDelete("cascade");
1696
- * ```
1697
- */
1698
- foreign(column) {
1699
- return new ForeignKeyBuilder(this, column);
1700
- }
1701
- /**
1702
- * Drop a foreign key constraint.
1703
- *
1704
- * Two calling forms:
1705
- *
1706
- * 1. Auto-compute the name (matches what `addForeignKey` generates):
1707
- * ```typescript
1708
- * this.dropForeign("unit_id", Unit.table);
1709
- * // → drops: fk_{table}_unit_id_units
1710
- * ```
1711
- *
1712
- * 2. Raw constraint name (use when the name was set explicitly):
1713
- * ```typescript
1714
- * this.dropForeign("my_custom_fk_name");
1715
- * ```
1716
- *
1717
- * @param columnOrConstraint - Column name (auto mode) or raw constraint name (raw mode)
1718
- * @param referencesTable - Referenced table name; triggers auto-name computation when provided
1719
- * @returns This migration for chaining
1720
- */
1721
- dropForeign(columnOrConstraint, referencesTable) {
1722
- const constraintName = referencesTable
1723
- ? `fk_${this.table}_${columnOrConstraint}_${referencesTable}`
1724
- : columnOrConstraint;
1725
- this.pendingOperations.push({ type: "dropForeignKey", payload: constraintName });
1726
- return this;
1727
- }
1728
- // ============================================================================
1729
- // SCHEMA VALIDATION (NoSQL)
1730
- // ============================================================================
1731
- /**
1732
- * Set JSON schema validation rules on the collection.
1733
- *
1734
- * MongoDB-only feature. SQL databases ignore this.
1735
- *
1736
- * @param schema - JSON Schema object
1737
- * @returns This migration for chaining
1738
- *
1739
- * @example
1740
- * ```typescript
1741
- * this.schemaValidation({
1742
- * bsonType: "object",
1743
- * required: ["name", "email"],
1744
- * properties: {
1745
- * name: { bsonType: "string" },
1746
- * email: { bsonType: "string" },
1747
- * },
1748
- * });
1749
- * ```
1750
- */
1751
- schemaValidation(schema) {
1752
- this.pendingOperations.push({
1753
- type: "setSchemaValidation",
1754
- payload: schema,
1755
- });
1756
- return this;
1757
- }
1758
- /**
1759
- * Remove schema validation rules from the collection.
1760
- *
1761
- * @returns This migration for chaining
1762
- */
1763
- dropSchemaValidation() {
1764
- this.pendingOperations.push({
1765
- type: "removeSchemaValidation",
1766
- payload: null,
1767
- });
1768
- return this;
1769
- }
1770
- // ============================================================================
1771
- // RAW ACCESS
1772
- // ============================================================================
1773
- /**
1774
- * Execute raw operations with direct driver/connection access.
1775
- *
1776
- * Use this when you need to bypass the migration API entirely and
1777
- * interact with the native database driver directly.
1778
- *
1779
- * @param callback - Callback receiving the native connection
1780
- * @returns Result from callback
1781
- *
1782
- * @example
1783
- * ```typescript
1784
- * await this.withConnection(async (db) => {
1785
- * await db.collection("users").updateMany({}, { $set: { active: true } });
1786
- * });
1787
- * ```
1788
- */
1789
- async withConnection(callback) {
1790
- return this.driver.raw(callback);
1791
- }
1792
- /**
1793
- * Queue a raw SQL string for execution within the migration.
1794
- *
1795
- * The statement is queued and executed in order with other migration
1796
- * operations, within the transaction context if the migration is transactional.
1797
- *
1798
- * Use `withConnection()` instead if you need direct driver access.
1799
- *
1800
- * Works with PostgreSQL, MySQL, etc. For MongoDB, uses $eval command.
1801
- *
1802
- * @param sql - SQL statement to execute
1803
- * @returns This migration for chaining
1804
- *
1805
- * @example
1806
- * ```typescript
1807
- * // Enable PostgreSQL extension
1808
- * this.raw('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"');
1809
- *
1810
- * // Create custom type
1811
- * this.raw('CREATE TYPE mood AS ENUM (\'happy\', \'sad\', \'neutral\')');
1812
- * ```
1813
- */
1814
- raw(sql) {
1815
- this.pendingOperations.push({
1816
- type: "rawStatement",
1817
- payload: sql,
1818
- });
1819
- return this;
1820
- }
1821
- // ============================================================================
1822
- // DECLARATIVE FACTORY STUBS
1823
- // These are assigned after the class body — declared here so TS knows the
1824
- // shape of the static members without triggering abstract-class restrictions.
1825
- // ============================================================================
1826
- /**
1827
- * Create a declarative initial-table migration.
1828
- * Implemented and assigned below the class body.
1829
- */
1830
- static create;
1831
- /**
1832
- * Create a declarative alteration migration.
1833
- * Implemented and assigned below the class body.
1834
- */
1835
- static alter;
1836
- }
1837
- function migrate(model, options) {
1838
- return class AnonymousMigration extends Migration {
1839
- static migrationName = options?.name;
1840
- static createdAt = options?.createdAt;
1841
- table = model.table;
1842
- static transactional = options?.transactional;
1843
- async up() {
1844
- await options?.up?.call(this);
1845
- }
1846
- async down() {
1847
- await options?.down?.call(this);
1848
- }
1849
- };
1850
- }
1851
- /**
1852
- * Wire a `ColumnMap` onto an active migration instance.
1853
- *
1854
- * Fixes up the placeholder column name in each `DetachedColumnBuilder`,
1855
- * pushes the `addColumn` operation, and transfers any pending FK / index
1856
- * side effects from the detached sink to the real migration.
1857
- *
1858
- * @internal
1859
- */
1860
- function wireColumns(migration, columns) {
1861
- for (const [columnName, detached] of Object.entries(columns)) {
1862
- // Overwrite the placeholder name with the real key
1863
- const definition = detached.getDefinition();
1864
- definition.name = columnName;
1865
- // Push the addColumn operation
1866
- migration.pendingOperations.push({
1867
- type: "addColumn",
1868
- payload: definition,
1869
- });
1870
- // Transfer any index operations registered via .unique() / .index()
1871
- // Replace the placeholder column name with the real column name before transfer.
1872
- for (const idx of detached.sink.pendingIndexes) {
1873
- idx.columns = idx.columns.map(col => (col === "__placeholder__" ? columnName : col));
1874
- migration.addPendingIndex(idx);
1875
- }
1876
- // Transfer any FK operations registered via .references()
1877
- for (const fk of detached.sink.pendingForeignKeys) {
1878
- // Fix the column name on the FK definition too
1879
- fk.column = columnName;
1880
- migration.addForeignKeyOperation(fk);
1881
- }
1882
- // Transfer any Vector indexes registered via .vectorIndex()
1883
- if (detached.sink.pendingVectorIndexes) {
1884
- for (const vIdx of detached.sink.pendingVectorIndexes) {
1885
- vIdx.column = columnName;
1886
- migration.vectorIndex(vIdx.column, vIdx.options);
1887
- }
1888
- }
1889
- }
1890
- }
1891
- /**
1892
- * Create a declarative initial-table migration.
1893
- *
1894
- * Automatically handles:
1895
- * - `createTableIfNotExists()`
1896
- * - Primary key (type resolved from `migrationDefaults.primaryKey` → options → `"int"`)
1897
- * - `timestamps()`
1898
- * - `down()` → `dropTableIfExists()`
1899
- *
1900
- * The class-based API remains available for complex migrations (raw SQL,
1901
- * data backfills, conditional logic).
1902
- *
1903
- * @param model - Model class to bind (provides table name + data source)
1904
- * @param columns - Column definitions keyed by column name
1905
- * @param options - Optional overrides
1906
- *
1907
- * @example
1908
- * ```typescript
1909
- * import { Migration, uuid, text, timestamp } from "@warlock.js/cascade";
1910
- * import { Organization } from "app/organizations/models/organization";
1911
- * import { Chat } from "../chat.model";
1912
- *
1913
- * export default Migration.create(Chat, {
1914
- * organization_id: uuid().references(Organization).onDelete("cascade"),
1915
- * title: text(),
1916
- * status: text(),
1917
- * started_at: timestamp().default("NOW()"),
1918
- * closed_at: timestamp().nullable(),
1919
- * }, { order: 5 });
1920
- * ```
1921
- */
1922
- Migration.create = function createMigration(model, columns, options = {}) {
1923
- const { order = 0, createdAt, primaryKey: primaryKeyOverride, timestamps: withTimestamps = true, transactional, } = options;
1924
- return class DeclarativeMigration extends Migration {
1925
- static order = order;
1926
- static createdAt = createdAt;
1927
- static transactional = transactional;
1928
- table = model.table;
1929
- dataSource = model.dataSource;
1930
- async up() {
1931
- this.createTableIfNotExists();
1932
- // Resolve primary key type: option → migrationDefaults → "int"
1933
- const pkType = primaryKeyOverride !== undefined
1934
- ? primaryKeyOverride
1935
- : (this._migrationDefaults?.primaryKey ?? "int");
1936
- if (pkType === "uuid") {
1937
- this.primaryUuid();
1938
- }
1939
- else if (pkType === "bigInt") {
1940
- this.bigId();
1941
- }
1942
- else if (pkType === "int") {
1943
- this.id();
1944
- }
1945
- // pkType === false → skip primary key
1946
- wireColumns(this, columns);
1947
- if (withTimestamps) {
1948
- this.timestamps();
1949
- }
1950
- // ── Composite indexes ───────────────────────────────────────────────
1951
- if (options.index) {
1952
- for (const entry of options.index) {
1953
- this.index(entry.columns, entry.name, {
1954
- include: entry.include,
1955
- concurrently: entry.concurrently,
1956
- });
1957
- }
1958
- }
1959
- // ── Composite unique constraints ────────────────────────────────────
1960
- if (options.unique) {
1961
- for (const entry of options.unique) {
1962
- this.unique(entry.columns, entry.name, {
1963
- include: entry.include,
1964
- concurrently: entry.concurrently,
1965
- });
1966
- }
1967
- }
1968
- if (options.raw) {
1969
- const rawQueries = Array.isArray(options.raw) ? options.raw : [options.raw];
1970
- for (const query of rawQueries) {
1971
- this.raw(query);
1972
- }
1973
- }
1974
- if (options.up) {
1975
- await options.up.call(this);
1976
- }
1977
- }
1978
- async down() {
1979
- if (options.down) {
1980
- await options.down.call(this);
1981
- }
1982
- this.dropTableIfExists();
1983
- }
1984
- };
1985
- };
1986
- /**
1987
- * Create a declarative alteration migration.
1988
- *
1989
- * @param model - Model class to bind
1990
- * @param schema - What to add / drop / rename / modify
1991
- * @param options - Optional overrides
1992
- *
1993
- * @example
1994
- * ```typescript
1995
- * import { Migration, text } from "@warlock.js/cascade";
1996
- * import { User } from "../user.model";
1997
- *
1998
- * export default Migration.alter(User, {
1999
- * add: {
2000
- * phone: text().nullable(),
2001
- * avatar: text().nullable(),
2002
- * },
2003
- * drop: ["legacy_field"],
2004
- * rename: { old_name: "new_name" },
2005
- * });
2006
- * ```
2007
- */
2008
- Migration.alter = function alterMigration(model, schema, options = {}) {
2009
- const { order = 0, createdAt, transactional } = options;
2010
- return class AlterMigration extends Migration {
2011
- static order = order;
2012
- static createdAt = createdAt;
2013
- static transactional = transactional;
2014
- table = model.table;
2015
- dataSource = model.dataSource;
2016
- async up() {
2017
- // ── Column Operations ─────────────────────────────────────────────────
2018
- if (schema.add) {
2019
- wireColumns(this, schema.add);
2020
- }
2021
- if (schema.drop) {
2022
- for (const col of schema.drop) {
2023
- this.dropColumn(col);
2024
- }
2025
- }
2026
- if (schema.rename) {
2027
- for (const [from, to] of Object.entries(schema.rename)) {
2028
- this.renameColumn(from, to);
2029
- }
2030
- }
2031
- if (schema.modify) {
2032
- for (const [columnName, detached] of Object.entries(schema.modify)) {
2033
- const definition = detached.getDefinition();
2034
- definition.name = columnName;
2035
- this.pendingOperations.push({
2036
- type: "modifyColumn",
2037
- payload: definition,
2038
- });
2039
- // Transfer FK side effects
2040
- for (const fk of detached.sink.pendingForeignKeys) {
2041
- fk.column = columnName;
2042
- this.addForeignKeyOperation(fk);
2043
- }
2044
- }
2045
- }
2046
- // ── Regular Indexes ───────────────────────────────────────────────────
2047
- if (schema.addIndex) {
2048
- for (const { columns, name, options: opts } of schema.addIndex) {
2049
- this.index(columns, name, opts);
2050
- }
2051
- }
2052
- if (schema.dropIndex) {
2053
- for (const target of schema.dropIndex) {
2054
- this.dropIndex(target);
2055
- }
2056
- }
2057
- // ── Unique Indexes ────────────────────────────────────────────────────
2058
- if (schema.addUnique) {
2059
- for (const { columns, name, options: opts } of schema.addUnique) {
2060
- this.unique(columns, name, opts);
2061
- }
2062
- }
2063
- if (schema.dropUnique) {
2064
- for (const cols of schema.dropUnique) {
2065
- this.dropUnique(cols);
2066
- }
2067
- }
2068
- // ── Expression Indexes ───────────────────────────────────────────────
2069
- if (schema.addExpressionIndex) {
2070
- for (const { expressions, name, options: opts } of schema.addExpressionIndex) {
2071
- this.expressionIndex(expressions, name, opts);
2072
- }
2073
- }
2074
- // ── Specialized Indexes ───────────────────────────────────────────────
2075
- if (schema.addFullText) {
2076
- for (const { columns, options: opts } of schema.addFullText) {
2077
- this.fullText(columns, opts);
2078
- }
2079
- }
2080
- if (schema.dropFullText) {
2081
- for (const name of schema.dropFullText) {
2082
- this.dropFullText(name);
2083
- }
2084
- }
2085
- if (schema.addGeoIndex) {
2086
- for (const { column, options: opts } of schema.addGeoIndex) {
2087
- this.geoIndex(column, opts);
2088
- }
2089
- }
2090
- if (schema.dropGeoIndex) {
2091
- for (const column of schema.dropGeoIndex) {
2092
- this.dropGeoIndex(column);
2093
- }
2094
- }
2095
- if (schema.addVectorIndex) {
2096
- for (const { column, options: opts } of schema.addVectorIndex) {
2097
- this.vectorIndex(column, opts);
2098
- }
2099
- }
2100
- if (schema.dropVectorIndex) {
2101
- for (const column of schema.dropVectorIndex) {
2102
- this.dropVectorIndex(column);
2103
- }
2104
- }
2105
- if (schema.addTTLIndex) {
2106
- for (const { column, expireAfterSeconds } of schema.addTTLIndex) {
2107
- this.ttlIndex(column, expireAfterSeconds);
2108
- }
2109
- }
2110
- if (schema.dropTTLIndex) {
2111
- for (const column of schema.dropTTLIndex) {
2112
- this.dropTTLIndex(column);
2113
- }
2114
- }
2115
- // ── Foreign Keys ──────────────────────────────────────────────────────
2116
- if (schema.addForeign) {
2117
- for (const fk of schema.addForeign) {
2118
- const tableName = typeof fk.references === "string" ? fk.references : fk.references.table;
2119
- this.foreign(fk.column)
2120
- .references(tableName, fk.on ?? "id")
2121
- .onDelete(fk.onDelete ?? "restrict")
2122
- .onUpdate(fk.onUpdate ?? "restrict");
2123
- }
2124
- }
2125
- if (schema.dropForeign) {
2126
- for (const { columnOrConstraint, referencesTable } of schema.dropForeign) {
2127
- this.dropForeign(columnOrConstraint, referencesTable);
2128
- }
2129
- }
2130
- // ── Check Constraints ─────────────────────────────────────────────────
2131
- if (schema.addCheck) {
2132
- for (const { name, expression } of schema.addCheck) {
2133
- this.check(name, expression);
2134
- }
2135
- }
2136
- if (schema.dropCheck) {
2137
- for (const name of schema.dropCheck) {
2138
- this.dropCheck(name);
2139
- }
2140
- }
2141
- // ── Raw SQL ───────────────────────────────────────────────────────────
2142
- if (schema.raw) {
2143
- const rawQueries = Array.isArray(schema.raw) ? schema.raw : [schema.raw];
2144
- for (const query of rawQueries) {
2145
- this.raw(query);
2146
- }
2147
- }
2148
- if (options.up) {
2149
- await options.up.call(this);
2150
- }
2151
- }
2152
- async down() {
2153
- if (options.down) {
2154
- await options.down.call(this);
2155
- }
2156
- }
2157
- };
2158
- };
2159
- // The no-op re-assignments below silence the TS "used before assigned" check;
2160
- // the real implementations are set by the Migration.create = ... and
2161
- // Migration.alter = ... blocks immediately above.
2162
- Migration.__declarativeFactoriesAttached = true;export{Migration,migrate};//# sourceMappingURL=migration.js.map