@warlock.js/cascade 4.0.48 → 4.0.58

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 (401) hide show
  1. package/cjs/context/database-data-source-context.d.ts +29 -0
  2. package/cjs/context/database-data-source-context.d.ts.map +1 -0
  3. package/cjs/context/database-data-source-context.js +28 -0
  4. package/cjs/context/database-data-source-context.js.map +1 -0
  5. package/cjs/context/database-transaction-context.d.ts +31 -0
  6. package/cjs/context/database-transaction-context.d.ts.map +1 -0
  7. package/cjs/context/database-transaction-context.js +34 -0
  8. package/cjs/context/database-transaction-context.js.map +1 -0
  9. package/cjs/contracts/database-driver.contract.d.ts +143 -0
  10. package/cjs/contracts/database-driver.contract.d.ts.map +1 -0
  11. package/cjs/contracts/database-id-generator.contract.d.ts +109 -0
  12. package/cjs/contracts/database-id-generator.contract.d.ts.map +1 -0
  13. package/cjs/contracts/database-remover.contract.d.ts +104 -0
  14. package/cjs/contracts/database-remover.contract.d.ts.map +1 -0
  15. package/cjs/contracts/database-restorer.contract.d.ts +143 -0
  16. package/cjs/contracts/database-restorer.contract.d.ts.map +1 -0
  17. package/cjs/contracts/database-writer.contract.d.ts +119 -0
  18. package/cjs/contracts/database-writer.contract.d.ts.map +1 -0
  19. package/cjs/contracts/driver-blueprint.contract.d.ts +45 -0
  20. package/cjs/contracts/driver-blueprint.contract.d.ts.map +1 -0
  21. package/cjs/contracts/index.d.ts +10 -0
  22. package/cjs/contracts/index.d.ts.map +1 -0
  23. package/cjs/contracts/migration-driver.contract.d.ts +365 -0
  24. package/cjs/contracts/migration-driver.contract.d.ts.map +1 -0
  25. package/cjs/contracts/query-builder.contract.d.ts +1128 -0
  26. package/cjs/contracts/query-builder.contract.d.ts.map +1 -0
  27. package/cjs/contracts/sync-adapter.contract.d.ts +58 -0
  28. package/cjs/contracts/sync-adapter.contract.d.ts.map +1 -0
  29. package/cjs/data-source/data-source-registry.d.ts +104 -0
  30. package/cjs/data-source/data-source-registry.d.ts.map +1 -0
  31. package/cjs/data-source/data-source-registry.js +138 -0
  32. package/cjs/data-source/data-source-registry.js.map +1 -0
  33. package/cjs/data-source/data-source.d.ts +106 -0
  34. package/cjs/data-source/data-source.d.ts.map +1 -0
  35. package/cjs/data-source/data-source.js +77 -0
  36. package/cjs/data-source/data-source.js.map +1 -0
  37. package/cjs/database-dirty-tracker.d.ts +253 -0
  38. package/cjs/database-dirty-tracker.d.ts.map +1 -0
  39. package/cjs/database-dirty-tracker.js +389 -0
  40. package/cjs/database-dirty-tracker.js.map +1 -0
  41. package/cjs/drivers/mongo/mongo-id-generator.d.ts +116 -0
  42. package/cjs/drivers/mongo/mongo-id-generator.d.ts.map +1 -0
  43. package/cjs/drivers/mongo/mongo-id-generator.js +149 -0
  44. package/cjs/drivers/mongo/mongo-id-generator.js.map +1 -0
  45. package/cjs/drivers/mongo/mongo-migration-driver.d.ts +228 -0
  46. package/cjs/drivers/mongo/mongo-migration-driver.d.ts.map +1 -0
  47. package/cjs/drivers/mongo/mongo-migration-driver.js +524 -0
  48. package/cjs/drivers/mongo/mongo-migration-driver.js.map +1 -0
  49. package/cjs/drivers/mongo/mongo-query-builder.d.ts +922 -0
  50. package/cjs/drivers/mongo/mongo-query-builder.d.ts.map +1 -0
  51. package/cjs/drivers/mongo/mongo-query-builder.js +1740 -0
  52. package/cjs/drivers/mongo/mongo-query-builder.js.map +1 -0
  53. package/cjs/drivers/mongo/mongo-query-operations.d.ts +226 -0
  54. package/cjs/drivers/mongo/mongo-query-operations.d.ts.map +1 -0
  55. package/cjs/drivers/mongo/mongo-query-operations.js +270 -0
  56. package/cjs/drivers/mongo/mongo-query-operations.js.map +1 -0
  57. package/cjs/drivers/mongo/mongo-query-parser.d.ts +262 -0
  58. package/cjs/drivers/mongo/mongo-query-parser.d.ts.map +1 -0
  59. package/cjs/drivers/mongo/mongo-query-parser.js +1351 -0
  60. package/cjs/drivers/mongo/mongo-query-parser.js.map +1 -0
  61. package/cjs/drivers/mongo/mongo-sync-adapter.d.ts +79 -0
  62. package/cjs/drivers/mongo/mongo-sync-adapter.d.ts.map +1 -0
  63. package/cjs/drivers/mongo/mongo-sync-adapter.js +146 -0
  64. package/cjs/drivers/mongo/mongo-sync-adapter.js.map +1 -0
  65. package/cjs/drivers/mongo/mongodb-blueprint.d.ts +30 -0
  66. package/cjs/drivers/mongo/mongodb-blueprint.d.ts.map +1 -0
  67. package/cjs/drivers/mongo/mongodb-blueprint.js +51 -0
  68. package/cjs/drivers/mongo/mongodb-blueprint.js.map +1 -0
  69. package/cjs/drivers/mongo/mongodb-driver.d.ts +188 -0
  70. package/cjs/drivers/mongo/mongodb-driver.d.ts.map +1 -0
  71. package/cjs/drivers/mongo/mongodb-driver.js +411 -0
  72. package/cjs/drivers/mongo/mongodb-driver.js.map +1 -0
  73. package/cjs/drivers/mongo/types.d.ts +43 -0
  74. package/cjs/drivers/mongo/types.d.ts.map +1 -0
  75. package/cjs/errors/missing-data-source.error.d.ts +22 -0
  76. package/cjs/errors/missing-data-source.error.d.ts.map +1 -0
  77. package/cjs/errors/missing-data-source.error.js +29 -0
  78. package/cjs/errors/missing-data-source.error.js.map +1 -0
  79. package/cjs/events/model-events.d.ts +231 -0
  80. package/cjs/events/model-events.d.ts.map +1 -0
  81. package/cjs/events/model-events.js +259 -0
  82. package/cjs/events/model-events.js.map +1 -0
  83. package/cjs/expressions/aggregate-expressions.d.ts +215 -0
  84. package/cjs/expressions/aggregate-expressions.d.ts.map +1 -0
  85. package/cjs/expressions/aggregate-expressions.js +221 -0
  86. package/cjs/expressions/aggregate-expressions.js.map +1 -0
  87. package/cjs/expressions/index.d.ts +2 -0
  88. package/cjs/expressions/index.d.ts.map +1 -0
  89. package/cjs/index.d.ts +41 -0
  90. package/cjs/index.d.ts.map +1 -0
  91. package/cjs/index.js +1 -267
  92. package/cjs/index.js.map +1 -1
  93. package/cjs/migration/column-builder.d.ts +167 -0
  94. package/cjs/migration/column-builder.d.ts.map +1 -0
  95. package/cjs/migration/column-builder.js +217 -0
  96. package/cjs/migration/column-builder.js.map +1 -0
  97. package/cjs/migration/foreign-key-builder.d.ts +110 -0
  98. package/cjs/migration/foreign-key-builder.d.ts.map +1 -0
  99. package/cjs/migration/foreign-key-builder.js +129 -0
  100. package/cjs/migration/foreign-key-builder.js.map +1 -0
  101. package/cjs/migration/index.d.ts +6 -0
  102. package/cjs/migration/index.d.ts.map +1 -0
  103. package/cjs/migration/migration-runner.d.ts +231 -0
  104. package/cjs/migration/migration-runner.d.ts.map +1 -0
  105. package/cjs/migration/migration-runner.js +443 -0
  106. package/cjs/migration/migration-runner.js.map +1 -0
  107. package/cjs/migration/migration.js +1346 -0
  108. package/cjs/migration/migration.js.map +1 -0
  109. package/cjs/migration/types.d.ts +132 -0
  110. package/cjs/migration/types.d.ts.map +1 -0
  111. package/cjs/model/model.d.ts +1267 -0
  112. package/cjs/model/model.d.ts.map +1 -0
  113. package/cjs/model/model.js +1463 -0
  114. package/cjs/model/model.js.map +1 -0
  115. package/cjs/model/register-model.d.ts +80 -0
  116. package/cjs/model/register-model.d.ts.map +1 -0
  117. package/cjs/model/register-model.js +91 -0
  118. package/cjs/model/register-model.js.map +1 -0
  119. package/cjs/remover/database-remover.d.ts +100 -0
  120. package/cjs/remover/database-remover.d.ts.map +1 -0
  121. package/cjs/remover/database-remover.js +209 -0
  122. package/cjs/remover/database-remover.js.map +1 -0
  123. package/cjs/restorer/database-restorer.d.ts +131 -0
  124. package/cjs/restorer/database-restorer.d.ts.map +1 -0
  125. package/cjs/restorer/database-restorer.js +425 -0
  126. package/cjs/restorer/database-restorer.js.map +1 -0
  127. package/cjs/sync/index.d.ts +12 -0
  128. package/cjs/sync/index.d.ts.map +1 -0
  129. package/cjs/sync/model-events.d.ts +62 -0
  130. package/cjs/sync/model-events.d.ts.map +1 -0
  131. package/cjs/sync/model-events.js +49 -0
  132. package/cjs/sync/model-events.js.map +1 -0
  133. package/cjs/sync/model-sync-operation.d.ts +163 -0
  134. package/cjs/sync/model-sync-operation.d.ts.map +1 -0
  135. package/cjs/sync/model-sync-operation.js +292 -0
  136. package/cjs/sync/model-sync-operation.js.map +1 -0
  137. package/cjs/sync/model-sync.d.ts +130 -0
  138. package/cjs/sync/model-sync.d.ts.map +1 -0
  139. package/cjs/sync/model-sync.js +178 -0
  140. package/cjs/sync/model-sync.js.map +1 -0
  141. package/cjs/sync/sync-context.d.ts +70 -0
  142. package/cjs/sync/sync-context.d.ts.map +1 -0
  143. package/cjs/sync/sync-context.js +101 -0
  144. package/cjs/sync/sync-context.js.map +1 -0
  145. package/cjs/sync/sync-manager.d.ts +213 -0
  146. package/cjs/sync/sync-manager.d.ts.map +1 -0
  147. package/cjs/sync/sync-manager.js +689 -0
  148. package/cjs/sync/sync-manager.js.map +1 -0
  149. package/cjs/sync/types.d.ts +289 -0
  150. package/cjs/sync/types.d.ts.map +1 -0
  151. package/cjs/types.d.ts +45 -0
  152. package/cjs/types.d.ts.map +1 -0
  153. package/cjs/utils/connect-to-database.d.ts +246 -0
  154. package/cjs/utils/connect-to-database.d.ts.map +1 -0
  155. package/cjs/utils/connect-to-database.js +92 -0
  156. package/cjs/utils/connect-to-database.js.map +1 -0
  157. package/cjs/utils/database-writer.utils.d.ts +15 -0
  158. package/cjs/utils/database-writer.utils.d.ts.map +1 -0
  159. package/cjs/utils/database-writer.utils.js +14 -0
  160. package/cjs/utils/database-writer.utils.js.map +1 -0
  161. package/cjs/utils/define-model.js +100 -0
  162. package/cjs/utils/define-model.js.map +1 -0
  163. package/cjs/utils/once-connected.d.ts +146 -0
  164. package/cjs/utils/once-connected.d.ts.map +1 -0
  165. package/cjs/utils/once-connected.js +252 -0
  166. package/cjs/utils/once-connected.js.map +1 -0
  167. package/cjs/validation/database-seal-plugins.d.ts +2 -0
  168. package/cjs/validation/database-seal-plugins.d.ts.map +1 -0
  169. package/cjs/validation/database-seal-plugins.js +4 -0
  170. package/cjs/validation/database-seal-plugins.js.map +1 -0
  171. package/cjs/validation/database-writer-validation-error.d.ts +97 -0
  172. package/cjs/validation/database-writer-validation-error.d.ts.map +1 -0
  173. package/cjs/validation/database-writer-validation-error.js +160 -0
  174. package/cjs/validation/database-writer-validation-error.js.map +1 -0
  175. package/cjs/validation/index.d.ts +3 -0
  176. package/cjs/validation/index.d.ts.map +1 -0
  177. package/cjs/validation/mutators/embed-mutator.d.ts +9 -0
  178. package/cjs/validation/mutators/embed-mutator.d.ts.map +1 -0
  179. package/cjs/validation/mutators/embed-mutator.js +33 -0
  180. package/cjs/validation/mutators/embed-mutator.js.map +1 -0
  181. package/cjs/validation/plugins/embed-validator-plugin.d.ts +24 -0
  182. package/cjs/validation/plugins/embed-validator-plugin.d.ts.map +1 -0
  183. package/cjs/validation/plugins/embed-validator-plugin.js +18 -0
  184. package/cjs/validation/plugins/embed-validator-plugin.js.map +1 -0
  185. package/cjs/validation/rules/database-model-rule.d.ts +7 -0
  186. package/cjs/validation/rules/database-model-rule.d.ts.map +1 -0
  187. package/cjs/validation/rules/database-model-rule.js +27 -0
  188. package/cjs/validation/rules/database-model-rule.js.map +1 -0
  189. package/cjs/validation/transformers/embed-model-transformer.d.ts +3 -0
  190. package/cjs/validation/transformers/embed-model-transformer.d.ts.map +1 -0
  191. package/cjs/validation/transformers/embed-model-transformer.js +18 -0
  192. package/cjs/validation/transformers/embed-model-transformer.js.map +1 -0
  193. package/cjs/validation/validators/embed-validator.d.ts +21 -0
  194. package/cjs/validation/validators/embed-validator.d.ts.map +1 -0
  195. package/cjs/validation/validators/embed-validator.js +42 -0
  196. package/cjs/validation/validators/embed-validator.js.map +1 -0
  197. package/cjs/writer/database-writer.d.ts +181 -0
  198. package/cjs/writer/database-writer.d.ts.map +1 -0
  199. package/cjs/writer/database-writer.js +402 -0
  200. package/cjs/writer/database-writer.js.map +1 -0
  201. package/esm/context/database-data-source-context.d.ts +29 -0
  202. package/esm/context/database-data-source-context.d.ts.map +1 -0
  203. package/esm/context/database-data-source-context.js +28 -0
  204. package/esm/context/database-data-source-context.js.map +1 -0
  205. package/esm/context/database-transaction-context.d.ts +31 -0
  206. package/esm/context/database-transaction-context.d.ts.map +1 -0
  207. package/esm/context/database-transaction-context.js +34 -0
  208. package/esm/context/database-transaction-context.js.map +1 -0
  209. package/esm/contracts/database-driver.contract.d.ts +143 -0
  210. package/esm/contracts/database-driver.contract.d.ts.map +1 -0
  211. package/esm/contracts/database-id-generator.contract.d.ts +109 -0
  212. package/esm/contracts/database-id-generator.contract.d.ts.map +1 -0
  213. package/esm/contracts/database-remover.contract.d.ts +104 -0
  214. package/esm/contracts/database-remover.contract.d.ts.map +1 -0
  215. package/esm/contracts/database-restorer.contract.d.ts +143 -0
  216. package/esm/contracts/database-restorer.contract.d.ts.map +1 -0
  217. package/esm/contracts/database-writer.contract.d.ts +119 -0
  218. package/esm/contracts/database-writer.contract.d.ts.map +1 -0
  219. package/esm/contracts/driver-blueprint.contract.d.ts +45 -0
  220. package/esm/contracts/driver-blueprint.contract.d.ts.map +1 -0
  221. package/esm/contracts/index.d.ts +10 -0
  222. package/esm/contracts/index.d.ts.map +1 -0
  223. package/esm/contracts/migration-driver.contract.d.ts +365 -0
  224. package/esm/contracts/migration-driver.contract.d.ts.map +1 -0
  225. package/esm/contracts/query-builder.contract.d.ts +1128 -0
  226. package/esm/contracts/query-builder.contract.d.ts.map +1 -0
  227. package/esm/contracts/sync-adapter.contract.d.ts +58 -0
  228. package/esm/contracts/sync-adapter.contract.d.ts.map +1 -0
  229. package/esm/data-source/data-source-registry.d.ts +104 -0
  230. package/esm/data-source/data-source-registry.d.ts.map +1 -0
  231. package/esm/data-source/data-source-registry.js +138 -0
  232. package/esm/data-source/data-source-registry.js.map +1 -0
  233. package/esm/data-source/data-source.d.ts +106 -0
  234. package/esm/data-source/data-source.d.ts.map +1 -0
  235. package/esm/data-source/data-source.js +77 -0
  236. package/esm/data-source/data-source.js.map +1 -0
  237. package/esm/database-dirty-tracker.d.ts +253 -0
  238. package/esm/database-dirty-tracker.d.ts.map +1 -0
  239. package/esm/database-dirty-tracker.js +389 -0
  240. package/esm/database-dirty-tracker.js.map +1 -0
  241. package/esm/drivers/mongo/mongo-id-generator.d.ts +116 -0
  242. package/esm/drivers/mongo/mongo-id-generator.d.ts.map +1 -0
  243. package/esm/drivers/mongo/mongo-id-generator.js +149 -0
  244. package/esm/drivers/mongo/mongo-id-generator.js.map +1 -0
  245. package/esm/drivers/mongo/mongo-migration-driver.d.ts +228 -0
  246. package/esm/drivers/mongo/mongo-migration-driver.d.ts.map +1 -0
  247. package/esm/drivers/mongo/mongo-migration-driver.js +524 -0
  248. package/esm/drivers/mongo/mongo-migration-driver.js.map +1 -0
  249. package/esm/drivers/mongo/mongo-query-builder.d.ts +922 -0
  250. package/esm/drivers/mongo/mongo-query-builder.d.ts.map +1 -0
  251. package/esm/drivers/mongo/mongo-query-builder.js +1740 -0
  252. package/esm/drivers/mongo/mongo-query-builder.js.map +1 -0
  253. package/esm/drivers/mongo/mongo-query-operations.d.ts +226 -0
  254. package/esm/drivers/mongo/mongo-query-operations.d.ts.map +1 -0
  255. package/esm/drivers/mongo/mongo-query-operations.js +270 -0
  256. package/esm/drivers/mongo/mongo-query-operations.js.map +1 -0
  257. package/esm/drivers/mongo/mongo-query-parser.d.ts +262 -0
  258. package/esm/drivers/mongo/mongo-query-parser.d.ts.map +1 -0
  259. package/esm/drivers/mongo/mongo-query-parser.js +1351 -0
  260. package/esm/drivers/mongo/mongo-query-parser.js.map +1 -0
  261. package/esm/drivers/mongo/mongo-sync-adapter.d.ts +79 -0
  262. package/esm/drivers/mongo/mongo-sync-adapter.d.ts.map +1 -0
  263. package/esm/drivers/mongo/mongo-sync-adapter.js +146 -0
  264. package/esm/drivers/mongo/mongo-sync-adapter.js.map +1 -0
  265. package/esm/drivers/mongo/mongodb-blueprint.d.ts +30 -0
  266. package/esm/drivers/mongo/mongodb-blueprint.d.ts.map +1 -0
  267. package/esm/drivers/mongo/mongodb-blueprint.js +51 -0
  268. package/esm/drivers/mongo/mongodb-blueprint.js.map +1 -0
  269. package/esm/drivers/mongo/mongodb-driver.d.ts +188 -0
  270. package/esm/drivers/mongo/mongodb-driver.d.ts.map +1 -0
  271. package/esm/drivers/mongo/mongodb-driver.js +411 -0
  272. package/esm/drivers/mongo/mongodb-driver.js.map +1 -0
  273. package/esm/drivers/mongo/types.d.ts +43 -0
  274. package/esm/drivers/mongo/types.d.ts.map +1 -0
  275. package/esm/errors/missing-data-source.error.d.ts +22 -0
  276. package/esm/errors/missing-data-source.error.d.ts.map +1 -0
  277. package/esm/errors/missing-data-source.error.js +29 -0
  278. package/esm/errors/missing-data-source.error.js.map +1 -0
  279. package/esm/events/model-events.d.ts +231 -0
  280. package/esm/events/model-events.d.ts.map +1 -0
  281. package/esm/events/model-events.js +259 -0
  282. package/esm/events/model-events.js.map +1 -0
  283. package/esm/expressions/aggregate-expressions.d.ts +215 -0
  284. package/esm/expressions/aggregate-expressions.d.ts.map +1 -0
  285. package/esm/expressions/aggregate-expressions.js +221 -0
  286. package/esm/expressions/aggregate-expressions.js.map +1 -0
  287. package/esm/expressions/index.d.ts +2 -0
  288. package/esm/expressions/index.d.ts.map +1 -0
  289. package/esm/index.d.ts +41 -0
  290. package/esm/index.d.ts.map +1 -0
  291. package/esm/index.js +1 -40
  292. package/esm/index.js.map +1 -1
  293. package/esm/migration/column-builder.d.ts +167 -0
  294. package/esm/migration/column-builder.d.ts.map +1 -0
  295. package/esm/migration/column-builder.js +217 -0
  296. package/esm/migration/column-builder.js.map +1 -0
  297. package/esm/migration/foreign-key-builder.d.ts +110 -0
  298. package/esm/migration/foreign-key-builder.d.ts.map +1 -0
  299. package/esm/migration/foreign-key-builder.js +129 -0
  300. package/esm/migration/foreign-key-builder.js.map +1 -0
  301. package/esm/migration/index.d.ts +6 -0
  302. package/esm/migration/index.d.ts.map +1 -0
  303. package/esm/migration/migration-runner.d.ts +231 -0
  304. package/esm/migration/migration-runner.d.ts.map +1 -0
  305. package/esm/migration/migration-runner.js +443 -0
  306. package/esm/migration/migration-runner.js.map +1 -0
  307. package/esm/migration/migration.js +1346 -0
  308. package/esm/migration/migration.js.map +1 -0
  309. package/esm/migration/types.d.ts +132 -0
  310. package/esm/migration/types.d.ts.map +1 -0
  311. package/esm/model/model.d.ts +1267 -0
  312. package/esm/model/model.d.ts.map +1 -0
  313. package/esm/model/model.js +1463 -0
  314. package/esm/model/model.js.map +1 -0
  315. package/esm/model/register-model.d.ts +80 -0
  316. package/esm/model/register-model.d.ts.map +1 -0
  317. package/esm/model/register-model.js +91 -0
  318. package/esm/model/register-model.js.map +1 -0
  319. package/esm/remover/database-remover.d.ts +100 -0
  320. package/esm/remover/database-remover.d.ts.map +1 -0
  321. package/esm/remover/database-remover.js +209 -0
  322. package/esm/remover/database-remover.js.map +1 -0
  323. package/esm/restorer/database-restorer.d.ts +131 -0
  324. package/esm/restorer/database-restorer.d.ts.map +1 -0
  325. package/esm/restorer/database-restorer.js +425 -0
  326. package/esm/restorer/database-restorer.js.map +1 -0
  327. package/esm/sync/index.d.ts +12 -0
  328. package/esm/sync/index.d.ts.map +1 -0
  329. package/esm/sync/model-events.d.ts +62 -0
  330. package/esm/sync/model-events.d.ts.map +1 -0
  331. package/esm/sync/model-events.js +49 -0
  332. package/esm/sync/model-events.js.map +1 -0
  333. package/esm/sync/model-sync-operation.d.ts +163 -0
  334. package/esm/sync/model-sync-operation.d.ts.map +1 -0
  335. package/esm/sync/model-sync-operation.js +292 -0
  336. package/esm/sync/model-sync-operation.js.map +1 -0
  337. package/esm/sync/model-sync.d.ts +130 -0
  338. package/esm/sync/model-sync.d.ts.map +1 -0
  339. package/esm/sync/model-sync.js +178 -0
  340. package/esm/sync/model-sync.js.map +1 -0
  341. package/esm/sync/sync-context.d.ts +70 -0
  342. package/esm/sync/sync-context.d.ts.map +1 -0
  343. package/esm/sync/sync-context.js +101 -0
  344. package/esm/sync/sync-context.js.map +1 -0
  345. package/esm/sync/sync-manager.d.ts +213 -0
  346. package/esm/sync/sync-manager.d.ts.map +1 -0
  347. package/esm/sync/sync-manager.js +689 -0
  348. package/esm/sync/sync-manager.js.map +1 -0
  349. package/esm/sync/types.d.ts +289 -0
  350. package/esm/sync/types.d.ts.map +1 -0
  351. package/esm/types.d.ts +45 -0
  352. package/esm/types.d.ts.map +1 -0
  353. package/esm/utils/connect-to-database.d.ts +246 -0
  354. package/esm/utils/connect-to-database.d.ts.map +1 -0
  355. package/esm/utils/connect-to-database.js +92 -0
  356. package/esm/utils/connect-to-database.js.map +1 -0
  357. package/esm/utils/database-writer.utils.d.ts +15 -0
  358. package/esm/utils/database-writer.utils.d.ts.map +1 -0
  359. package/esm/utils/database-writer.utils.js +14 -0
  360. package/esm/utils/database-writer.utils.js.map +1 -0
  361. package/esm/utils/define-model.js +100 -0
  362. package/esm/utils/define-model.js.map +1 -0
  363. package/esm/utils/once-connected.d.ts +146 -0
  364. package/esm/utils/once-connected.d.ts.map +1 -0
  365. package/esm/utils/once-connected.js +252 -0
  366. package/esm/utils/once-connected.js.map +1 -0
  367. package/esm/validation/database-seal-plugins.d.ts +2 -0
  368. package/esm/validation/database-seal-plugins.d.ts.map +1 -0
  369. package/esm/validation/database-seal-plugins.js +4 -0
  370. package/esm/validation/database-seal-plugins.js.map +1 -0
  371. package/esm/validation/database-writer-validation-error.d.ts +97 -0
  372. package/esm/validation/database-writer-validation-error.d.ts.map +1 -0
  373. package/esm/validation/database-writer-validation-error.js +160 -0
  374. package/esm/validation/database-writer-validation-error.js.map +1 -0
  375. package/esm/validation/index.d.ts +3 -0
  376. package/esm/validation/index.d.ts.map +1 -0
  377. package/esm/validation/mutators/embed-mutator.d.ts +9 -0
  378. package/esm/validation/mutators/embed-mutator.d.ts.map +1 -0
  379. package/esm/validation/mutators/embed-mutator.js +33 -0
  380. package/esm/validation/mutators/embed-mutator.js.map +1 -0
  381. package/esm/validation/plugins/embed-validator-plugin.d.ts +24 -0
  382. package/esm/validation/plugins/embed-validator-plugin.d.ts.map +1 -0
  383. package/esm/validation/plugins/embed-validator-plugin.js +18 -0
  384. package/esm/validation/plugins/embed-validator-plugin.js.map +1 -0
  385. package/esm/validation/rules/database-model-rule.d.ts +7 -0
  386. package/esm/validation/rules/database-model-rule.d.ts.map +1 -0
  387. package/esm/validation/rules/database-model-rule.js +27 -0
  388. package/esm/validation/rules/database-model-rule.js.map +1 -0
  389. package/esm/validation/transformers/embed-model-transformer.d.ts +3 -0
  390. package/esm/validation/transformers/embed-model-transformer.d.ts.map +1 -0
  391. package/esm/validation/transformers/embed-model-transformer.js +18 -0
  392. package/esm/validation/transformers/embed-model-transformer.js.map +1 -0
  393. package/esm/validation/validators/embed-validator.d.ts +21 -0
  394. package/esm/validation/validators/embed-validator.d.ts.map +1 -0
  395. package/esm/validation/validators/embed-validator.js +42 -0
  396. package/esm/validation/validators/embed-validator.js.map +1 -0
  397. package/esm/writer/database-writer.d.ts +181 -0
  398. package/esm/writer/database-writer.d.ts.map +1 -0
  399. package/esm/writer/database-writer.js +402 -0
  400. package/esm/writer/database-writer.js.map +1 -0
  401. package/package.json +61 -52
@@ -0,0 +1,1346 @@
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
+ 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
+ * Queued operations to execute.
103
+ */
104
+ pendingOperations = [];
105
+ /**
106
+ * Pending indexes from column builders.
107
+ */
108
+ pendingIndexes = [];
109
+ // ============================================================================
110
+ // STATIC FACTORY
111
+ // ============================================================================
112
+ /**
113
+ * Create a migration class bound to a specific model.
114
+ *
115
+ * Automatically inherits the model's table name and data source,
116
+ * reducing boilerplate and ensuring consistency.
117
+ *
118
+ * @param model - Model class to bind
119
+ * @returns Abstract migration class bound to the model
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * export default class extends Migration.for(User) {
124
+ * public up(): void {
125
+ * this.string("avatar").nullable();
126
+ * }
127
+ *
128
+ * public down(): void {
129
+ * this.dropColumn("avatar");
130
+ * }
131
+ * }
132
+ * ```
133
+ */
134
+ static for(model) {
135
+ class BoundMigration extends Migration {
136
+ table = model.table;
137
+ dataSource = model.dataSource;
138
+ }
139
+ return BoundMigration;
140
+ }
141
+ // ============================================================================
142
+ // DRIVER INJECTION
143
+ // ============================================================================
144
+ /**
145
+ * Set the migration driver.
146
+ *
147
+ * Called by the migration runner before executing up/down.
148
+ *
149
+ * @param driver - Migration driver instance
150
+ * @internal
151
+ */
152
+ setDriver(driver) {
153
+ this.driver = driver;
154
+ }
155
+ /**
156
+ * Get the migration driver.
157
+ *
158
+ * @returns The migration driver instance
159
+ */
160
+ getDriver() {
161
+ return this.driver;
162
+ }
163
+ // ============================================================================
164
+ // EXECUTE OPERATIONS
165
+ // ============================================================================
166
+ /**
167
+ * Execute all pending operations.
168
+ *
169
+ * Called by the migration runner after up() or down() completes.
170
+ * Executes operations in the order they were defined.
171
+ *
172
+ * @internal
173
+ */
174
+ async execute() {
175
+ // Execute column/table operations
176
+ for (const op of this.pendingOperations) {
177
+ await this.executeOperation(op);
178
+ }
179
+ // Execute pending indexes from column builders
180
+ for (const index of this.pendingIndexes) {
181
+ if (index.unique) {
182
+ await this.driver.createUniqueIndex(this.table, index.columns, index.name);
183
+ }
184
+ else {
185
+ await this.driver.createIndex(this.table, index);
186
+ }
187
+ }
188
+ // Clear pending operations after execution
189
+ this.pendingOperations.length = 0;
190
+ this.pendingIndexes.length = 0;
191
+ }
192
+ /**
193
+ * Execute a single pending operation.
194
+ */
195
+ async executeOperation(op) {
196
+ switch (op.type) {
197
+ case "addColumn":
198
+ await this.driver.addColumn(this.table, op.payload);
199
+ break;
200
+ case "dropColumn":
201
+ await this.driver.dropColumn(this.table, op.payload);
202
+ break;
203
+ case "dropColumns":
204
+ await this.driver.dropColumns(this.table, op.payload);
205
+ break;
206
+ case "renameColumn": {
207
+ const { from, to } = op.payload;
208
+ await this.driver.renameColumn(this.table, from, to);
209
+ break;
210
+ }
211
+ case "modifyColumn":
212
+ await this.driver.modifyColumn(this.table, op.payload);
213
+ break;
214
+ case "createIndex":
215
+ await this.driver.createIndex(this.table, op.payload);
216
+ break;
217
+ case "dropIndex":
218
+ await this.driver.dropIndex(this.table, op.payload);
219
+ break;
220
+ case "createUniqueIndex": {
221
+ const { columns, name } = op.payload;
222
+ await this.driver.createUniqueIndex(this.table, columns, name);
223
+ break;
224
+ }
225
+ case "dropUniqueIndex":
226
+ await this.driver.dropUniqueIndex(this.table, op.payload);
227
+ break;
228
+ case "createFullTextIndex": {
229
+ const { columns, options } = op.payload;
230
+ await this.driver.createFullTextIndex(this.table, columns, options);
231
+ break;
232
+ }
233
+ case "dropFullTextIndex":
234
+ await this.driver.dropFullTextIndex(this.table, op.payload);
235
+ break;
236
+ case "createGeoIndex": {
237
+ const { column, options } = op.payload;
238
+ await this.driver.createGeoIndex(this.table, column, options);
239
+ break;
240
+ }
241
+ case "dropGeoIndex":
242
+ await this.driver.dropGeoIndex(this.table, op.payload);
243
+ break;
244
+ case "createVectorIndex": {
245
+ const { column, options } = op.payload;
246
+ await this.driver.createVectorIndex(this.table, column, options);
247
+ break;
248
+ }
249
+ case "dropVectorIndex":
250
+ await this.driver.dropVectorIndex(this.table, op.payload);
251
+ break;
252
+ case "createTTLIndex": {
253
+ const { column, seconds } = op.payload;
254
+ await this.driver.createTTLIndex(this.table, column, seconds);
255
+ break;
256
+ }
257
+ case "dropTTLIndex":
258
+ await this.driver.dropTTLIndex(this.table, op.payload);
259
+ break;
260
+ case "addForeignKey":
261
+ await this.driver.addForeignKey(this.table, op.payload);
262
+ break;
263
+ case "dropForeignKey":
264
+ await this.driver.dropForeignKey(this.table, op.payload);
265
+ break;
266
+ case "addPrimaryKey":
267
+ await this.driver.addPrimaryKey(this.table, op.payload);
268
+ break;
269
+ case "dropPrimaryKey":
270
+ await this.driver.dropPrimaryKey(this.table);
271
+ break;
272
+ case "createTable":
273
+ await this.driver.createTable(this.table);
274
+ break;
275
+ case "createTableIfNotExists":
276
+ await this.driver.createTableIfNotExists(this.table);
277
+ break;
278
+ case "dropTable":
279
+ await this.driver.dropTable(this.table);
280
+ break;
281
+ case "dropTableIfExists":
282
+ await this.driver.dropTableIfExists(this.table);
283
+ break;
284
+ case "renameTable":
285
+ await this.driver.renameTable(this.table, op.payload);
286
+ break;
287
+ case "setSchemaValidation":
288
+ await this.driver.setSchemaValidation(this.table, op.payload);
289
+ break;
290
+ case "removeSchemaValidation":
291
+ await this.driver.removeSchemaValidation(this.table);
292
+ break;
293
+ }
294
+ }
295
+ // ============================================================================
296
+ // INTERNAL HELPERS
297
+ // ============================================================================
298
+ /**
299
+ * Add a pending index definition.
300
+ *
301
+ * Called by ColumnBuilder when .unique() or .index() is chained.
302
+ *
303
+ * @param index - Index definition
304
+ * @internal
305
+ */
306
+ addPendingIndex(index) {
307
+ this.pendingIndexes.push(index);
308
+ }
309
+ /**
310
+ * Add a foreign key operation.
311
+ *
312
+ * Called by ForeignKeyBuilder when .add() is called.
313
+ *
314
+ * @param fk - Foreign key definition
315
+ * @internal
316
+ */
317
+ addForeignKeyOperation(fk) {
318
+ this.pendingOperations.push({
319
+ type: "addForeignKey",
320
+ payload: fk,
321
+ });
322
+ }
323
+ // ============================================================================
324
+ // TABLE OPERATIONS
325
+ // ============================================================================
326
+ /**
327
+ * Create the table/collection.
328
+ *
329
+ * For SQL, this creates an empty table.
330
+ * For MongoDB, this creates the collection.
331
+ *
332
+ * @returns This migration for chaining
333
+ */
334
+ createTable() {
335
+ this.pendingOperations.push({ type: "createTable", payload: null });
336
+ return this;
337
+ }
338
+ /**
339
+ * Create table if not exists
340
+ */
341
+ createTableIfNotExists() {
342
+ this.pendingOperations.push({ type: "createTableIfNotExists", payload: null });
343
+ return this;
344
+ }
345
+ /**
346
+ * Drop the table/collection.
347
+ *
348
+ * @returns This migration for chaining
349
+ */
350
+ dropTable() {
351
+ this.pendingOperations.push({ type: "dropTable", payload: null });
352
+ return this;
353
+ }
354
+ /**
355
+ * Drop the table/collection if it exists.
356
+ *
357
+ * No error is thrown if the table doesn't exist.
358
+ *
359
+ * @returns This migration for chaining
360
+ */
361
+ dropTableIfExists() {
362
+ this.pendingOperations.push({ type: "dropTableIfExists", payload: null });
363
+ return this;
364
+ }
365
+ /**
366
+ * Rename the table/collection.
367
+ *
368
+ * @param newName - New table name
369
+ * @returns This migration for chaining
370
+ */
371
+ renameTableTo(newName) {
372
+ this.pendingOperations.push({ type: "renameTable", payload: newName });
373
+ return this;
374
+ }
375
+ // ============================================================================
376
+ // COLUMN TYPES - STRING
377
+ // ============================================================================
378
+ /**
379
+ * Add a string/varchar column.
380
+ *
381
+ * @param column - Column name
382
+ * @param length - Max length (default: 255)
383
+ * @returns Column builder for chaining modifiers
384
+ *
385
+ * @example
386
+ * ```typescript
387
+ * this.string("name"); // VARCHAR(255)
388
+ * this.string("code", 10); // VARCHAR(10)
389
+ * ```
390
+ */
391
+ string(column, length = 255) {
392
+ const builder = new ColumnBuilder(this, column, "string", { length });
393
+ this.pendingOperations.push({
394
+ type: "addColumn",
395
+ payload: builder.getDefinition(),
396
+ });
397
+ return builder;
398
+ }
399
+ /**
400
+ * Add a fixed-length char column.
401
+ *
402
+ * @param column - Column name
403
+ * @param length - Exact length
404
+ * @returns Column builder for chaining modifiers
405
+ */
406
+ char(column, length) {
407
+ const builder = new ColumnBuilder(this, column, "char", { length });
408
+ this.pendingOperations.push({
409
+ type: "addColumn",
410
+ payload: builder.getDefinition(),
411
+ });
412
+ return builder;
413
+ }
414
+ /**
415
+ * Add a text column (unlimited length).
416
+ *
417
+ * @param column - Column name
418
+ * @returns Column builder for chaining modifiers
419
+ */
420
+ text(column) {
421
+ const builder = new ColumnBuilder(this, column, "text");
422
+ this.pendingOperations.push({
423
+ type: "addColumn",
424
+ payload: builder.getDefinition(),
425
+ });
426
+ return builder;
427
+ }
428
+ /**
429
+ * Add a medium text column.
430
+ *
431
+ * @param column - Column name
432
+ * @returns Column builder for chaining modifiers
433
+ */
434
+ mediumText(column) {
435
+ const builder = new ColumnBuilder(this, column, "mediumText");
436
+ this.pendingOperations.push({
437
+ type: "addColumn",
438
+ payload: builder.getDefinition(),
439
+ });
440
+ return builder;
441
+ }
442
+ /**
443
+ * Add a long text column.
444
+ *
445
+ * @param column - Column name
446
+ * @returns Column builder for chaining modifiers
447
+ */
448
+ longText(column) {
449
+ const builder = new ColumnBuilder(this, column, "longText");
450
+ this.pendingOperations.push({
451
+ type: "addColumn",
452
+ payload: builder.getDefinition(),
453
+ });
454
+ return builder;
455
+ }
456
+ // ============================================================================
457
+ // COLUMN TYPES - NUMERIC
458
+ // ============================================================================
459
+ /**
460
+ * Add an integer column.
461
+ *
462
+ * @param column - Column name
463
+ * @returns Column builder for chaining modifiers
464
+ */
465
+ integer(column) {
466
+ const builder = new ColumnBuilder(this, column, "integer");
467
+ this.pendingOperations.push({
468
+ type: "addColumn",
469
+ payload: builder.getDefinition(),
470
+ });
471
+ return builder;
472
+ }
473
+ /**
474
+ * Alias for integer().
475
+ */
476
+ int(column) {
477
+ return this.integer(column);
478
+ }
479
+ /**
480
+ * Add a small integer column.
481
+ *
482
+ * @param column - Column name
483
+ * @returns Column builder for chaining modifiers
484
+ */
485
+ smallInteger(column) {
486
+ const builder = new ColumnBuilder(this, column, "smallInteger");
487
+ this.pendingOperations.push({
488
+ type: "addColumn",
489
+ payload: builder.getDefinition(),
490
+ });
491
+ return builder;
492
+ }
493
+ /**
494
+ * Alias for smallInteger().
495
+ */
496
+ smallInt(column) {
497
+ return this.smallInteger(column);
498
+ }
499
+ /**
500
+ * Add a tiny integer column.
501
+ *
502
+ * @param column - Column name
503
+ * @returns Column builder for chaining modifiers
504
+ */
505
+ tinyInteger(column) {
506
+ const builder = new ColumnBuilder(this, column, "tinyInteger");
507
+ this.pendingOperations.push({
508
+ type: "addColumn",
509
+ payload: builder.getDefinition(),
510
+ });
511
+ return builder;
512
+ }
513
+ /**
514
+ * Alias for tinyInteger().
515
+ */
516
+ tinyInt(column) {
517
+ return this.tinyInteger(column);
518
+ }
519
+ /**
520
+ * Add a big integer column.
521
+ *
522
+ * @param column - Column name
523
+ * @returns Column builder for chaining modifiers
524
+ */
525
+ bigInteger(column) {
526
+ const builder = new ColumnBuilder(this, column, "bigInteger");
527
+ this.pendingOperations.push({
528
+ type: "addColumn",
529
+ payload: builder.getDefinition(),
530
+ });
531
+ return builder;
532
+ }
533
+ /**
534
+ * Alias for bigInteger().
535
+ */
536
+ bigInt(column) {
537
+ return this.bigInteger(column);
538
+ }
539
+ /**
540
+ * Add a float column.
541
+ *
542
+ * @param column - Column name
543
+ * @returns Column builder for chaining modifiers
544
+ */
545
+ float(column) {
546
+ const builder = new ColumnBuilder(this, column, "float");
547
+ this.pendingOperations.push({
548
+ type: "addColumn",
549
+ payload: builder.getDefinition(),
550
+ });
551
+ return builder;
552
+ }
553
+ /**
554
+ * Add a double precision column.
555
+ *
556
+ * @param column - Column name
557
+ * @returns Column builder for chaining modifiers
558
+ */
559
+ double(column) {
560
+ const builder = new ColumnBuilder(this, column, "double");
561
+ this.pendingOperations.push({
562
+ type: "addColumn",
563
+ payload: builder.getDefinition(),
564
+ });
565
+ return builder;
566
+ }
567
+ /**
568
+ * Add a decimal column with precision and scale.
569
+ *
570
+ * @param column - Column name
571
+ * @param precision - Total digits (default: 8)
572
+ * @param scale - Decimal places (default: 2)
573
+ * @returns Column builder for chaining modifiers
574
+ *
575
+ * @example
576
+ * ```typescript
577
+ * this.decimal("price", 10, 2); // DECIMAL(10,2) - up to 99999999.99
578
+ * ```
579
+ */
580
+ decimal(column, precision = 8, scale = 2) {
581
+ const builder = new ColumnBuilder(this, column, "decimal", {
582
+ precision,
583
+ scale,
584
+ });
585
+ this.pendingOperations.push({
586
+ type: "addColumn",
587
+ payload: builder.getDefinition(),
588
+ });
589
+ return builder;
590
+ }
591
+ // ============================================================================
592
+ // COLUMN TYPES - BOOLEAN
593
+ // ============================================================================
594
+ /**
595
+ * Add a boolean column.
596
+ *
597
+ * @param column - Column name
598
+ * @returns Column builder for chaining modifiers
599
+ */
600
+ boolean(column) {
601
+ const builder = new ColumnBuilder(this, column, "boolean");
602
+ this.pendingOperations.push({
603
+ type: "addColumn",
604
+ payload: builder.getDefinition(),
605
+ });
606
+ return builder;
607
+ }
608
+ /**
609
+ * Alias for boolean().
610
+ */
611
+ bool(column) {
612
+ return this.boolean(column);
613
+ }
614
+ // ============================================================================
615
+ // COLUMN TYPES - DATE/TIME
616
+ // ============================================================================
617
+ /**
618
+ * Add a date column (date only, no time).
619
+ *
620
+ * @param column - Column name
621
+ * @returns Column builder for chaining modifiers
622
+ */
623
+ date(column) {
624
+ const builder = new ColumnBuilder(this, column, "date");
625
+ this.pendingOperations.push({
626
+ type: "addColumn",
627
+ payload: builder.getDefinition(),
628
+ });
629
+ return builder;
630
+ }
631
+ /**
632
+ * Add a datetime column (date and time).
633
+ *
634
+ * @param column - Column name
635
+ * @returns Column builder for chaining modifiers
636
+ */
637
+ dateTime(column) {
638
+ const builder = new ColumnBuilder(this, column, "dateTime");
639
+ this.pendingOperations.push({
640
+ type: "addColumn",
641
+ payload: builder.getDefinition(),
642
+ });
643
+ return builder;
644
+ }
645
+ /**
646
+ * Add a timestamp column.
647
+ *
648
+ * @param column - Column name
649
+ * @returns Column builder for chaining modifiers
650
+ */
651
+ timestamp(column) {
652
+ const builder = new ColumnBuilder(this, column, "timestamp");
653
+ this.pendingOperations.push({
654
+ type: "addColumn",
655
+ payload: builder.getDefinition(),
656
+ });
657
+ return builder;
658
+ }
659
+ /**
660
+ * Add a time column (time only, no date).
661
+ *
662
+ * @param column - Column name
663
+ * @returns Column builder for chaining modifiers
664
+ */
665
+ time(column) {
666
+ const builder = new ColumnBuilder(this, column, "time");
667
+ this.pendingOperations.push({
668
+ type: "addColumn",
669
+ payload: builder.getDefinition(),
670
+ });
671
+ return builder;
672
+ }
673
+ /**
674
+ * Add a year column.
675
+ *
676
+ * @param column - Column name
677
+ * @returns Column builder for chaining modifiers
678
+ */
679
+ year(column) {
680
+ const builder = new ColumnBuilder(this, column, "year");
681
+ this.pendingOperations.push({
682
+ type: "addColumn",
683
+ payload: builder.getDefinition(),
684
+ });
685
+ return builder;
686
+ }
687
+ // ============================================================================
688
+ // COLUMN TYPES - JSON & BINARY
689
+ // ============================================================================
690
+ /**
691
+ * Add a JSON column.
692
+ *
693
+ * @param column - Column name
694
+ * @returns Column builder for chaining modifiers
695
+ */
696
+ json(column) {
697
+ const builder = new ColumnBuilder(this, column, "json");
698
+ this.pendingOperations.push({
699
+ type: "addColumn",
700
+ payload: builder.getDefinition(),
701
+ });
702
+ return builder;
703
+ }
704
+ /**
705
+ * Alias for json().
706
+ */
707
+ object(column) {
708
+ return this.json(column);
709
+ }
710
+ /**
711
+ * Add a binary/blob column.
712
+ *
713
+ * @param column - Column name
714
+ * @returns Column builder for chaining modifiers
715
+ */
716
+ binary(column) {
717
+ const builder = new ColumnBuilder(this, column, "binary");
718
+ this.pendingOperations.push({
719
+ type: "addColumn",
720
+ payload: builder.getDefinition(),
721
+ });
722
+ return builder;
723
+ }
724
+ /**
725
+ * Alias for binary().
726
+ */
727
+ blob(column) {
728
+ return this.binary(column);
729
+ }
730
+ // ============================================================================
731
+ // COLUMN TYPES - IDENTIFIERS
732
+ // ============================================================================
733
+ /**
734
+ * Add a UUID column.
735
+ *
736
+ * @param column - Column name
737
+ * @returns Column builder for chaining modifiers
738
+ */
739
+ uuid(column) {
740
+ const builder = new ColumnBuilder(this, column, "uuid");
741
+ this.pendingOperations.push({
742
+ type: "addColumn",
743
+ payload: builder.getDefinition(),
744
+ });
745
+ return builder;
746
+ }
747
+ /**
748
+ * Add a ULID column.
749
+ *
750
+ * @param column - Column name
751
+ * @returns Column builder for chaining modifiers
752
+ */
753
+ ulid(column) {
754
+ const builder = new ColumnBuilder(this, column, "ulid");
755
+ this.pendingOperations.push({
756
+ type: "addColumn",
757
+ payload: builder.getDefinition(),
758
+ });
759
+ return builder;
760
+ }
761
+ // ============================================================================
762
+ // COLUMN TYPES - NETWORK
763
+ // ============================================================================
764
+ /**
765
+ * Add an IP address column.
766
+ *
767
+ * @param column - Column name
768
+ * @returns Column builder for chaining modifiers
769
+ */
770
+ ipAddress(column) {
771
+ const builder = new ColumnBuilder(this, column, "ipAddress");
772
+ this.pendingOperations.push({
773
+ type: "addColumn",
774
+ payload: builder.getDefinition(),
775
+ });
776
+ return builder;
777
+ }
778
+ /**
779
+ * Add a MAC address column.
780
+ *
781
+ * @param column - Column name
782
+ * @returns Column builder for chaining modifiers
783
+ */
784
+ macAddress(column) {
785
+ const builder = new ColumnBuilder(this, column, "macAddress");
786
+ this.pendingOperations.push({
787
+ type: "addColumn",
788
+ payload: builder.getDefinition(),
789
+ });
790
+ return builder;
791
+ }
792
+ // ============================================================================
793
+ // COLUMN TYPES - GEO & SPATIAL
794
+ // ============================================================================
795
+ /**
796
+ * Add a geo point column.
797
+ *
798
+ * @param column - Column name
799
+ * @returns Column builder for chaining modifiers
800
+ */
801
+ point(column) {
802
+ const builder = new ColumnBuilder(this, column, "point");
803
+ this.pendingOperations.push({
804
+ type: "addColumn",
805
+ payload: builder.getDefinition(),
806
+ });
807
+ return builder;
808
+ }
809
+ /**
810
+ * Add a polygon column.
811
+ *
812
+ * @param column - Column name
813
+ * @returns Column builder for chaining modifiers
814
+ */
815
+ polygon(column) {
816
+ const builder = new ColumnBuilder(this, column, "polygon");
817
+ this.pendingOperations.push({
818
+ type: "addColumn",
819
+ payload: builder.getDefinition(),
820
+ });
821
+ return builder;
822
+ }
823
+ /**
824
+ * Add a line string column.
825
+ *
826
+ * @param column - Column name
827
+ * @returns Column builder for chaining modifiers
828
+ */
829
+ lineString(column) {
830
+ const builder = new ColumnBuilder(this, column, "lineString");
831
+ this.pendingOperations.push({
832
+ type: "addColumn",
833
+ payload: builder.getDefinition(),
834
+ });
835
+ return builder;
836
+ }
837
+ /**
838
+ * Add a generic geometry column.
839
+ *
840
+ * @param column - Column name
841
+ * @returns Column builder for chaining modifiers
842
+ */
843
+ geometry(column) {
844
+ const builder = new ColumnBuilder(this, column, "geometry");
845
+ this.pendingOperations.push({
846
+ type: "addColumn",
847
+ payload: builder.getDefinition(),
848
+ });
849
+ return builder;
850
+ }
851
+ // ============================================================================
852
+ // COLUMN TYPES - AI/ML
853
+ // ============================================================================
854
+ /**
855
+ * Add a vector column for AI embeddings.
856
+ *
857
+ * Used for storing and searching ML embeddings (e.g., OpenAI, Cohere).
858
+ *
859
+ * @param column - Column name
860
+ * @param dimensions - Vector dimensions (e.g., 1536 for OpenAI ada-002)
861
+ * @returns Column builder for chaining modifiers
862
+ *
863
+ * @example
864
+ * ```typescript
865
+ * this.vector("embedding", 1536); // OpenAI ada-002
866
+ * this.vector("embedding", 384); // Sentence Transformers
867
+ * ```
868
+ */
869
+ vector(column, dimensions) {
870
+ const builder = new ColumnBuilder(this, column, "vector", { dimensions });
871
+ this.pendingOperations.push({
872
+ type: "addColumn",
873
+ payload: builder.getDefinition(),
874
+ });
875
+ return builder;
876
+ }
877
+ // ============================================================================
878
+ // COLUMN TYPES - ENUM & SET
879
+ // ============================================================================
880
+ /**
881
+ * Add an enum column with allowed values.
882
+ *
883
+ * @param column - Column name
884
+ * @param values - Allowed enum values
885
+ * @returns Column builder for chaining modifiers
886
+ *
887
+ * @example
888
+ * ```typescript
889
+ * this.enum("status", ["pending", "active", "archived"]);
890
+ * ```
891
+ */
892
+ enum(column, values) {
893
+ const builder = new ColumnBuilder(this, column, "enum", { values });
894
+ this.pendingOperations.push({
895
+ type: "addColumn",
896
+ payload: builder.getDefinition(),
897
+ });
898
+ return builder;
899
+ }
900
+ /**
901
+ * Add a set column (multiple values from a set).
902
+ *
903
+ * @param column - Column name
904
+ * @param values - Allowed set values
905
+ * @returns Column builder for chaining modifiers
906
+ */
907
+ set(column, values) {
908
+ const builder = new ColumnBuilder(this, column, "set", { values });
909
+ this.pendingOperations.push({
910
+ type: "addColumn",
911
+ payload: builder.getDefinition(),
912
+ });
913
+ return builder;
914
+ }
915
+ // ============================================================================
916
+ // SHORTCUTS
917
+ // ============================================================================
918
+ /**
919
+ * Add an auto-increment primary key column.
920
+ *
921
+ * Creates an unsigned integer with primary key and auto-increment.
922
+ *
923
+ * @param name - Column name (default: "id")
924
+ * @returns Column builder for chaining modifiers
925
+ *
926
+ * @example
927
+ * ```typescript
928
+ * this.id(); // Creates "id" column
929
+ * this.id("userId"); // Creates "userId" column
930
+ * ```
931
+ */
932
+ id(name = "id") {
933
+ return this.integer(name).primary().autoIncrement().unsigned();
934
+ }
935
+ /**
936
+ * Add a big integer auto-increment primary key column.
937
+ *
938
+ * @param name - Column name (default: "id")
939
+ * @returns Column builder for chaining modifiers
940
+ */
941
+ bigId(name = "id") {
942
+ return this.bigInteger(name).primary().autoIncrement().unsigned();
943
+ }
944
+ /**
945
+ * Add a UUID primary key column.
946
+ *
947
+ * @param name - Column name (default: "id")
948
+ * @returns Column builder for chaining modifiers
949
+ */
950
+ uuidId(name = "id") {
951
+ return this.uuid(name).primary();
952
+ }
953
+ /**
954
+ * Add createdAt and updatedAt timestamp columns.
955
+ *
956
+ * @returns This migration for chaining
957
+ *
958
+ * @example
959
+ * ```typescript
960
+ * this.timestamps(); // Creates createdAt and updatedAt
961
+ * ```
962
+ */
963
+ timestamps() {
964
+ this.dateTime("createdAt");
965
+ this.dateTime("updatedAt");
966
+ return this;
967
+ }
968
+ /**
969
+ * Add a deletedAt column for soft deletes.
970
+ *
971
+ * @param column - Column name (default: "deletedAt")
972
+ * @returns Column builder for chaining modifiers
973
+ */
974
+ softDeletes(column = "deletedAt") {
975
+ return this.dateTime(column).nullable();
976
+ }
977
+ // ============================================================================
978
+ // DROP COLUMN OPERATIONS
979
+ // ============================================================================
980
+ /**
981
+ * Drop a column.
982
+ *
983
+ * @param column - Column name to drop
984
+ * @returns This migration for chaining
985
+ */
986
+ dropColumn(column) {
987
+ this.pendingOperations.push({ type: "dropColumn", payload: column });
988
+ return this;
989
+ }
990
+ /**
991
+ * Drop multiple columns.
992
+ *
993
+ * @param columns - Column names to drop
994
+ * @returns This migration for chaining
995
+ */
996
+ dropColumns(...columns) {
997
+ this.pendingOperations.push({ type: "dropColumns", payload: columns });
998
+ return this;
999
+ }
1000
+ /**
1001
+ * Rename a column.
1002
+ *
1003
+ * @param from - Current column name
1004
+ * @param to - New column name
1005
+ * @returns This migration for chaining
1006
+ */
1007
+ renameColumn(from, to) {
1008
+ this.pendingOperations.push({
1009
+ type: "renameColumn",
1010
+ payload: { from, to },
1011
+ });
1012
+ return this;
1013
+ }
1014
+ // ============================================================================
1015
+ // INDEX OPERATIONS
1016
+ // ============================================================================
1017
+ /**
1018
+ * Create an index on one or more columns.
1019
+ *
1020
+ * @param columns - Column(s) to index
1021
+ * @param name - Optional index name
1022
+ * @returns This migration for chaining
1023
+ *
1024
+ * @example
1025
+ * ```typescript
1026
+ * this.index("email");
1027
+ * this.index(["firstName", "lastName"], "name_idx");
1028
+ * ```
1029
+ */
1030
+ index(columns, name) {
1031
+ const cols = Array.isArray(columns) ? columns : [columns];
1032
+ this.pendingOperations.push({
1033
+ type: "createIndex",
1034
+ payload: { columns: cols, name },
1035
+ });
1036
+ return this;
1037
+ }
1038
+ /**
1039
+ * Drop an index by name or columns.
1040
+ *
1041
+ * @param nameOrColumns - Index name (string) or columns array
1042
+ * @returns This migration for chaining
1043
+ *
1044
+ * @example
1045
+ * ```typescript
1046
+ * this.dropIndex("email_idx"); // Drop by name
1047
+ * this.dropIndex(["firstName", "lastName"]); // Drop by columns
1048
+ * ```
1049
+ */
1050
+ dropIndex(nameOrColumns) {
1051
+ this.pendingOperations.push({
1052
+ type: "dropIndex",
1053
+ payload: nameOrColumns,
1054
+ });
1055
+ return this;
1056
+ }
1057
+ /**
1058
+ * Create a unique constraint/index.
1059
+ *
1060
+ * @param columns - Column(s) to make unique
1061
+ * @param name - Optional constraint name
1062
+ * @returns This migration for chaining
1063
+ */
1064
+ unique(columns, name) {
1065
+ const cols = Array.isArray(columns) ? columns : [columns];
1066
+ this.pendingOperations.push({
1067
+ type: "createUniqueIndex",
1068
+ payload: { columns: cols, name },
1069
+ });
1070
+ return this;
1071
+ }
1072
+ /**
1073
+ * Drop a unique constraint/index.
1074
+ *
1075
+ * @param columns - Columns in the unique constraint
1076
+ * @returns This migration for chaining
1077
+ */
1078
+ dropUnique(columns) {
1079
+ const cols = Array.isArray(columns) ? columns : [columns];
1080
+ this.pendingOperations.push({ type: "dropUniqueIndex", payload: cols });
1081
+ return this;
1082
+ }
1083
+ // ============================================================================
1084
+ // FULL-TEXT INDEX
1085
+ // ============================================================================
1086
+ /**
1087
+ * Create a full-text search index.
1088
+ *
1089
+ * @param columns - Column(s) to index
1090
+ * @param options - Full-text options
1091
+ * @returns This migration for chaining
1092
+ */
1093
+ fullText(columns, options) {
1094
+ const cols = Array.isArray(columns) ? columns : [columns];
1095
+ this.pendingOperations.push({
1096
+ type: "createFullTextIndex",
1097
+ payload: { columns: cols, options },
1098
+ });
1099
+ return this;
1100
+ }
1101
+ /**
1102
+ * Drop a full-text search index.
1103
+ *
1104
+ * @param name - Index name
1105
+ * @returns This migration for chaining
1106
+ */
1107
+ dropFullText(name) {
1108
+ this.pendingOperations.push({ type: "dropFullTextIndex", payload: name });
1109
+ return this;
1110
+ }
1111
+ // ============================================================================
1112
+ // GEO INDEX
1113
+ // ============================================================================
1114
+ /**
1115
+ * Create a geo-spatial index.
1116
+ *
1117
+ * @param column - Geo column
1118
+ * @param options - Geo index options
1119
+ * @returns This migration for chaining
1120
+ *
1121
+ * @example
1122
+ * ```typescript
1123
+ * this.geoIndex("location"); // 2dsphere index
1124
+ * this.geoIndex("coordinates", { type: "2d" }); // 2d index
1125
+ * ```
1126
+ */
1127
+ geoIndex(column, options) {
1128
+ this.pendingOperations.push({
1129
+ type: "createGeoIndex",
1130
+ payload: { column, options },
1131
+ });
1132
+ return this;
1133
+ }
1134
+ /**
1135
+ * Drop a geo-spatial index.
1136
+ *
1137
+ * @param column - Geo column
1138
+ * @returns This migration for chaining
1139
+ */
1140
+ dropGeoIndex(column) {
1141
+ this.pendingOperations.push({ type: "dropGeoIndex", payload: column });
1142
+ return this;
1143
+ }
1144
+ // ============================================================================
1145
+ // VECTOR INDEX
1146
+ // ============================================================================
1147
+ /**
1148
+ * Create a vector search index for AI embeddings.
1149
+ *
1150
+ * @param column - Vector column
1151
+ * @param options - Vector index options
1152
+ * @returns This migration for chaining
1153
+ *
1154
+ * @example
1155
+ * ```typescript
1156
+ * this.vectorIndex("embedding", {
1157
+ * dimensions: 1536,
1158
+ * similarity: "cosine",
1159
+ * });
1160
+ * ```
1161
+ */
1162
+ vectorIndex(column, options) {
1163
+ this.pendingOperations.push({
1164
+ type: "createVectorIndex",
1165
+ payload: { column, options },
1166
+ });
1167
+ return this;
1168
+ }
1169
+ /**
1170
+ * Drop a vector search index.
1171
+ *
1172
+ * @param column - Vector column
1173
+ * @returns This migration for chaining
1174
+ */
1175
+ dropVectorIndex(column) {
1176
+ this.pendingOperations.push({ type: "dropVectorIndex", payload: column });
1177
+ return this;
1178
+ }
1179
+ // ============================================================================
1180
+ // TTL INDEX
1181
+ // ============================================================================
1182
+ /**
1183
+ * Create a TTL (time-to-live) index for automatic document expiration.
1184
+ *
1185
+ * Primarily for MongoDB. Documents are automatically deleted after the
1186
+ * specified time has passed since the date in the column.
1187
+ *
1188
+ * @param column - Date column to check for expiration
1189
+ * @param expireAfterSeconds - Seconds after which documents expire
1190
+ * @returns This migration for chaining
1191
+ *
1192
+ * @example
1193
+ * ```typescript
1194
+ * // Delete sessions 24 hours after createdAt
1195
+ * this.ttlIndex("createdAt", 86400);
1196
+ * ```
1197
+ */
1198
+ ttlIndex(column, expireAfterSeconds) {
1199
+ this.pendingOperations.push({
1200
+ type: "createTTLIndex",
1201
+ payload: { column, seconds: expireAfterSeconds },
1202
+ });
1203
+ return this;
1204
+ }
1205
+ /**
1206
+ * Drop a TTL index.
1207
+ *
1208
+ * @param column - Column with TTL
1209
+ * @returns This migration for chaining
1210
+ */
1211
+ dropTTLIndex(column) {
1212
+ this.pendingOperations.push({ type: "dropTTLIndex", payload: column });
1213
+ return this;
1214
+ }
1215
+ // ============================================================================
1216
+ // PRIMARY KEY
1217
+ // ============================================================================
1218
+ /**
1219
+ * Add a composite primary key.
1220
+ *
1221
+ * @param columns - Columns to include in the primary key
1222
+ * @returns This migration for chaining
1223
+ */
1224
+ primaryKey(columns) {
1225
+ this.pendingOperations.push({ type: "addPrimaryKey", payload: columns });
1226
+ return this;
1227
+ }
1228
+ /**
1229
+ * Drop the primary key constraint.
1230
+ *
1231
+ * @returns This migration for chaining
1232
+ */
1233
+ dropPrimaryKey() {
1234
+ this.pendingOperations.push({ type: "dropPrimaryKey", payload: null });
1235
+ return this;
1236
+ }
1237
+ // ============================================================================
1238
+ // FOREIGN KEYS (SQL)
1239
+ // ============================================================================
1240
+ /**
1241
+ * Start building a foreign key constraint.
1242
+ *
1243
+ * SQL-only feature; NoSQL drivers ignore foreign keys.
1244
+ *
1245
+ * @param column - Local column that references another table
1246
+ * @returns Foreign key builder for chaining
1247
+ *
1248
+ * @example
1249
+ * ```typescript
1250
+ * this.foreign("user_id")
1251
+ * .references("users", "id")
1252
+ * .onDelete("cascade")
1253
+ * .add();
1254
+ * ```
1255
+ */
1256
+ foreign(column) {
1257
+ return new ForeignKeyBuilder(this, column);
1258
+ }
1259
+ /**
1260
+ * Drop a foreign key constraint by name.
1261
+ *
1262
+ * @param name - Constraint name
1263
+ * @returns This migration for chaining
1264
+ */
1265
+ dropForeign(name) {
1266
+ this.pendingOperations.push({ type: "dropForeignKey", payload: name });
1267
+ return this;
1268
+ }
1269
+ // ============================================================================
1270
+ // SCHEMA VALIDATION (NoSQL)
1271
+ // ============================================================================
1272
+ /**
1273
+ * Set JSON schema validation rules on the collection.
1274
+ *
1275
+ * MongoDB-only feature. SQL databases ignore this.
1276
+ *
1277
+ * @param schema - JSON Schema object
1278
+ * @returns This migration for chaining
1279
+ *
1280
+ * @example
1281
+ * ```typescript
1282
+ * this.schemaValidation({
1283
+ * bsonType: "object",
1284
+ * required: ["name", "email"],
1285
+ * properties: {
1286
+ * name: { bsonType: "string" },
1287
+ * email: { bsonType: "string" },
1288
+ * },
1289
+ * });
1290
+ * ```
1291
+ */
1292
+ schemaValidation(schema) {
1293
+ this.pendingOperations.push({
1294
+ type: "setSchemaValidation",
1295
+ payload: schema,
1296
+ });
1297
+ return this;
1298
+ }
1299
+ /**
1300
+ * Remove schema validation rules from the collection.
1301
+ *
1302
+ * @returns This migration for chaining
1303
+ */
1304
+ dropSchemaValidation() {
1305
+ this.pendingOperations.push({
1306
+ type: "removeSchemaValidation",
1307
+ payload: null,
1308
+ });
1309
+ return this;
1310
+ }
1311
+ // ============================================================================
1312
+ // RAW ACCESS
1313
+ // ============================================================================
1314
+ /**
1315
+ * Execute raw operations with direct driver access.
1316
+ *
1317
+ * Use this for database-specific operations not covered by the API.
1318
+ *
1319
+ * @param callback - Callback receiving the native connection
1320
+ * @returns Result from callback
1321
+ *
1322
+ * @example
1323
+ * ```typescript
1324
+ * await this.raw(async (db) => {
1325
+ * await db.collection("users").updateMany({}, { $set: { active: true } });
1326
+ * });
1327
+ * ```
1328
+ */
1329
+ async raw(callback) {
1330
+ return this.driver.raw(callback);
1331
+ }
1332
+ }
1333
+ function migrate(model, options) {
1334
+ return class AnonymousMigration extends Migration {
1335
+ static migrationName = options?.name;
1336
+ static createdAt = options?.createdAt;
1337
+ table = model.table;
1338
+ static transactional = options?.transactional;
1339
+ async up() {
1340
+ options?.up?.call(this);
1341
+ }
1342
+ async down() {
1343
+ options?.down?.call(this);
1344
+ }
1345
+ };
1346
+ }export{Migration,migrate};//# sourceMappingURL=migration.js.map