@warlock.js/cascade 4.0.162 → 4.0.164

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 (661) 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 +35 -0
  6. package/cjs/context/database-transaction-context.d.ts.map +1 -0
  7. package/cjs/context/database-transaction-context.js +40 -0
  8. package/cjs/context/database-transaction-context.js.map +1 -0
  9. package/cjs/contracts/database-driver.contract.d.ts +450 -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 +49 -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 +522 -0
  24. package/cjs/contracts/migration-driver.contract.d.ts.map +1 -0
  25. package/cjs/contracts/query-builder.contract.d.ts +1609 -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 +108 -0
  30. package/cjs/data-source/data-source-registry.d.ts.map +1 -0
  31. package/cjs/data-source/data-source-registry.js +145 -0
  32. package/cjs/data-source/data-source-registry.js.map +1 -0
  33. package/cjs/data-source/data-source.d.ts +147 -0
  34. package/cjs/data-source/data-source.d.ts.map +1 -0
  35. package/cjs/data-source/data-source.js +83 -0
  36. package/cjs/data-source/data-source.js.map +1 -0
  37. package/cjs/database-dirty-tracker.d.ts +252 -0
  38. package/cjs/database-dirty-tracker.d.ts.map +1 -0
  39. package/cjs/database-dirty-tracker.js +386 -0
  40. package/cjs/database-dirty-tracker.js.map +1 -0
  41. package/cjs/drivers/mongodb/mongodb-blueprint.d.ts +30 -0
  42. package/cjs/drivers/mongodb/mongodb-blueprint.d.ts.map +1 -0
  43. package/cjs/drivers/mongodb/mongodb-blueprint.js +51 -0
  44. package/cjs/drivers/mongodb/mongodb-blueprint.js.map +1 -0
  45. package/cjs/drivers/mongodb/mongodb-driver.d.ts +325 -0
  46. package/cjs/drivers/mongodb/mongodb-driver.d.ts.map +1 -0
  47. package/cjs/drivers/mongodb/mongodb-driver.js +838 -0
  48. package/cjs/drivers/mongodb/mongodb-driver.js.map +1 -0
  49. package/cjs/drivers/mongodb/mongodb-id-generator.d.ts +116 -0
  50. package/cjs/drivers/mongodb/mongodb-id-generator.d.ts.map +1 -0
  51. package/cjs/drivers/mongodb/mongodb-id-generator.js +149 -0
  52. package/cjs/drivers/mongodb/mongodb-id-generator.js.map +1 -0
  53. package/cjs/drivers/mongodb/mongodb-migration-driver.d.ts +317 -0
  54. package/cjs/drivers/mongodb/mongodb-migration-driver.d.ts.map +1 -0
  55. package/cjs/drivers/mongodb/mongodb-migration-driver.js +666 -0
  56. package/cjs/drivers/mongodb/mongodb-migration-driver.js.map +1 -0
  57. package/cjs/drivers/mongodb/mongodb-query-builder.d.ts +1122 -0
  58. package/cjs/drivers/mongodb/mongodb-query-builder.d.ts.map +1 -0
  59. package/cjs/drivers/mongodb/mongodb-query-builder.js +1988 -0
  60. package/cjs/drivers/mongodb/mongodb-query-builder.js.map +1 -0
  61. package/cjs/drivers/mongodb/mongodb-query-operations.d.ts +226 -0
  62. package/cjs/drivers/mongodb/mongodb-query-operations.d.ts.map +1 -0
  63. package/cjs/drivers/mongodb/mongodb-query-operations.js +270 -0
  64. package/cjs/drivers/mongodb/mongodb-query-operations.js.map +1 -0
  65. package/cjs/drivers/mongodb/mongodb-query-parser.d.ts +262 -0
  66. package/cjs/drivers/mongodb/mongodb-query-parser.d.ts.map +1 -0
  67. package/cjs/drivers/mongodb/mongodb-query-parser.js +1351 -0
  68. package/cjs/drivers/mongodb/mongodb-query-parser.js.map +1 -0
  69. package/cjs/drivers/mongodb/mongodb-sync-adapter.d.ts +79 -0
  70. package/cjs/drivers/mongodb/mongodb-sync-adapter.d.ts.map +1 -0
  71. package/cjs/drivers/mongodb/mongodb-sync-adapter.js +146 -0
  72. package/cjs/drivers/mongodb/mongodb-sync-adapter.js.map +1 -0
  73. package/cjs/drivers/mongodb/types.d.ts +43 -0
  74. package/cjs/drivers/mongodb/types.d.ts.map +1 -0
  75. package/cjs/drivers/postgres/index.d.ts +16 -0
  76. package/cjs/drivers/postgres/index.d.ts.map +1 -0
  77. package/cjs/drivers/postgres/postgres-blueprint.d.ts +64 -0
  78. package/cjs/drivers/postgres/postgres-blueprint.d.ts.map +1 -0
  79. package/cjs/drivers/postgres/postgres-blueprint.js +121 -0
  80. package/cjs/drivers/postgres/postgres-blueprint.js.map +1 -0
  81. package/cjs/drivers/postgres/postgres-dialect.d.ts +136 -0
  82. package/cjs/drivers/postgres/postgres-dialect.d.ts.map +1 -0
  83. package/cjs/drivers/postgres/postgres-dialect.js +268 -0
  84. package/cjs/drivers/postgres/postgres-dialect.js.map +1 -0
  85. package/cjs/drivers/postgres/postgres-driver.d.ts +432 -0
  86. package/cjs/drivers/postgres/postgres-driver.d.ts.map +1 -0
  87. package/cjs/drivers/postgres/postgres-driver.js +1010 -0
  88. package/cjs/drivers/postgres/postgres-driver.js.map +1 -0
  89. package/cjs/drivers/postgres/postgres-migration-driver.d.ts +397 -0
  90. package/cjs/drivers/postgres/postgres-migration-driver.d.ts.map +1 -0
  91. package/cjs/drivers/postgres/postgres-migration-driver.js +900 -0
  92. package/cjs/drivers/postgres/postgres-migration-driver.js.map +1 -0
  93. package/cjs/drivers/postgres/postgres-query-builder.d.ts +254 -0
  94. package/cjs/drivers/postgres/postgres-query-builder.d.ts.map +1 -0
  95. package/cjs/drivers/postgres/postgres-query-builder.js +933 -0
  96. package/cjs/drivers/postgres/postgres-query-builder.js.map +1 -0
  97. package/cjs/drivers/postgres/postgres-query-parser.d.ts +328 -0
  98. package/cjs/drivers/postgres/postgres-query-parser.d.ts.map +1 -0
  99. package/cjs/drivers/postgres/postgres-query-parser.js +868 -0
  100. package/cjs/drivers/postgres/postgres-query-parser.js.map +1 -0
  101. package/cjs/drivers/postgres/postgres-sql-serializer.d.ts +37 -0
  102. package/cjs/drivers/postgres/postgres-sql-serializer.d.ts.map +1 -0
  103. package/cjs/drivers/postgres/postgres-sql-serializer.js +400 -0
  104. package/cjs/drivers/postgres/postgres-sql-serializer.js.map +1 -0
  105. package/cjs/drivers/postgres/postgres-sync-adapter.d.ts +83 -0
  106. package/cjs/drivers/postgres/postgres-sync-adapter.d.ts.map +1 -0
  107. package/cjs/drivers/postgres/postgres-sync-adapter.js +197 -0
  108. package/cjs/drivers/postgres/postgres-sync-adapter.js.map +1 -0
  109. package/cjs/drivers/postgres/types.d.ts +144 -0
  110. package/cjs/drivers/postgres/types.d.ts.map +1 -0
  111. package/cjs/drivers/sql/index.d.ts +10 -0
  112. package/cjs/drivers/sql/index.d.ts.map +1 -0
  113. package/cjs/drivers/sql/sql-dialect.contract.d.ts +204 -0
  114. package/cjs/drivers/sql/sql-dialect.contract.d.ts.map +1 -0
  115. package/cjs/drivers/sql/sql-types.d.ts +202 -0
  116. package/cjs/drivers/sql/sql-types.d.ts.map +1 -0
  117. package/cjs/errors/missing-data-source.error.d.ts +22 -0
  118. package/cjs/errors/missing-data-source.error.d.ts.map +1 -0
  119. package/cjs/errors/missing-data-source.error.js +29 -0
  120. package/cjs/errors/missing-data-source.error.js.map +1 -0
  121. package/cjs/errors/transaction-rollback.error.d.ts +20 -0
  122. package/cjs/errors/transaction-rollback.error.d.ts.map +1 -0
  123. package/cjs/errors/transaction-rollback.error.js +27 -0
  124. package/cjs/errors/transaction-rollback.error.js.map +1 -0
  125. package/cjs/events/model-events.d.ts +231 -0
  126. package/cjs/events/model-events.d.ts.map +1 -0
  127. package/cjs/events/model-events.js +259 -0
  128. package/cjs/events/model-events.js.map +1 -0
  129. package/cjs/expressions/aggregate-expressions.d.ts +215 -0
  130. package/cjs/expressions/aggregate-expressions.d.ts.map +1 -0
  131. package/cjs/expressions/aggregate-expressions.js +221 -0
  132. package/cjs/expressions/aggregate-expressions.js.map +1 -0
  133. package/cjs/expressions/index.d.ts +2 -0
  134. package/cjs/expressions/index.d.ts.map +1 -0
  135. package/cjs/index.d.ts +45 -0
  136. package/cjs/index.d.ts.map +1 -0
  137. package/cjs/index.js +1 -0
  138. package/cjs/index.js.map +1 -0
  139. package/cjs/migration/column-builder.d.ts +417 -0
  140. package/cjs/migration/column-builder.d.ts.map +1 -0
  141. package/cjs/migration/column-builder.js +586 -0
  142. package/cjs/migration/column-builder.js.map +1 -0
  143. package/cjs/migration/column-helpers.d.ts +275 -0
  144. package/cjs/migration/column-helpers.d.ts.map +1 -0
  145. package/cjs/migration/column-helpers.js +389 -0
  146. package/cjs/migration/column-helpers.js.map +1 -0
  147. package/cjs/migration/foreign-key-builder.d.ts +103 -0
  148. package/cjs/migration/foreign-key-builder.d.ts.map +1 -0
  149. package/cjs/migration/foreign-key-builder.js +121 -0
  150. package/cjs/migration/foreign-key-builder.js.map +1 -0
  151. package/cjs/migration/index.d.ts +7 -0
  152. package/cjs/migration/index.d.ts.map +1 -0
  153. package/cjs/migration/migration-runner.d.ts +278 -0
  154. package/cjs/migration/migration-runner.d.ts.map +1 -0
  155. package/cjs/migration/migration-runner.js +815 -0
  156. package/cjs/migration/migration-runner.js.map +1 -0
  157. package/cjs/migration/migration.d.ts +1992 -0
  158. package/cjs/migration/migration.d.ts.map +1 -0
  159. package/cjs/migration/migration.js +2162 -0
  160. package/cjs/migration/migration.js.map +1 -0
  161. package/cjs/migration/sql-grammar.d.ts +61 -0
  162. package/cjs/migration/sql-grammar.d.ts.map +1 -0
  163. package/cjs/migration/sql-grammar.js +164 -0
  164. package/cjs/migration/sql-grammar.js.map +1 -0
  165. package/cjs/migration/sql-serializer.d.ts +22 -0
  166. package/cjs/migration/sql-serializer.d.ts.map +1 -0
  167. package/cjs/migration/sql-serializer.js +26 -0
  168. package/cjs/migration/sql-serializer.js.map +1 -0
  169. package/cjs/migration/types.d.ts +155 -0
  170. package/cjs/migration/types.d.ts.map +1 -0
  171. package/cjs/model/methods/accessor-methods.d.ts +13 -0
  172. package/cjs/model/methods/accessor-methods.d.ts.map +1 -0
  173. package/cjs/model/methods/accessor-methods.js +51 -0
  174. package/cjs/model/methods/accessor-methods.js.map +1 -0
  175. package/cjs/model/methods/delete-methods.d.ts +10 -0
  176. package/cjs/model/methods/delete-methods.d.ts.map +1 -0
  177. package/cjs/model/methods/delete-methods.js +10 -0
  178. package/cjs/model/methods/delete-methods.js.map +1 -0
  179. package/cjs/model/methods/dirty-methods.d.ts +10 -0
  180. package/cjs/model/methods/dirty-methods.d.ts.map +1 -0
  181. package/cjs/model/methods/dirty-methods.js +15 -0
  182. package/cjs/model/methods/dirty-methods.js.map +1 -0
  183. package/cjs/model/methods/hydration-methods.d.ts +10 -0
  184. package/cjs/model/methods/hydration-methods.d.ts.map +1 -0
  185. package/cjs/model/methods/hydration-methods.js +57 -0
  186. package/cjs/model/methods/hydration-methods.js.map +1 -0
  187. package/cjs/model/methods/instance-event-methods.d.ts +7 -0
  188. package/cjs/model/methods/instance-event-methods.d.ts.map +1 -0
  189. package/cjs/model/methods/instance-event-methods.js +15 -0
  190. package/cjs/model/methods/instance-event-methods.js.map +1 -0
  191. package/cjs/model/methods/meta-methods.d.ts +7 -0
  192. package/cjs/model/methods/meta-methods.d.ts.map +1 -0
  193. package/cjs/model/methods/meta-methods.js +78 -0
  194. package/cjs/model/methods/meta-methods.js.map +1 -0
  195. package/cjs/model/methods/query-methods.d.ts +24 -0
  196. package/cjs/model/methods/query-methods.d.ts.map +1 -0
  197. package/cjs/model/methods/query-methods.js +164 -0
  198. package/cjs/model/methods/query-methods.js.map +1 -0
  199. package/cjs/model/methods/restore-methods.d.ts +10 -0
  200. package/cjs/model/methods/restore-methods.d.ts.map +1 -0
  201. package/cjs/model/methods/restore-methods.js +13 -0
  202. package/cjs/model/methods/restore-methods.js.map +1 -0
  203. package/cjs/model/methods/scope-methods.d.ts +7 -0
  204. package/cjs/model/methods/scope-methods.d.ts.map +1 -0
  205. package/cjs/model/methods/scope-methods.js +15 -0
  206. package/cjs/model/methods/scope-methods.js.map +1 -0
  207. package/cjs/model/methods/serialization-methods.d.ts +3 -0
  208. package/cjs/model/methods/serialization-methods.d.ts.map +1 -0
  209. package/cjs/model/methods/serialization-methods.js +27 -0
  210. package/cjs/model/methods/serialization-methods.js.map +1 -0
  211. package/cjs/model/methods/static-event-methods.d.ts +9 -0
  212. package/cjs/model/methods/static-event-methods.d.ts.map +1 -0
  213. package/cjs/model/methods/static-event-methods.js +29 -0
  214. package/cjs/model/methods/static-event-methods.js.map +1 -0
  215. package/cjs/model/methods/write-methods.d.ts +10 -0
  216. package/cjs/model/methods/write-methods.d.ts.map +1 -0
  217. package/cjs/model/methods/write-methods.js +52 -0
  218. package/cjs/model/methods/write-methods.js.map +1 -0
  219. package/cjs/model/model.d.ts +1647 -0
  220. package/cjs/model/model.d.ts.map +1 -0
  221. package/cjs/model/model.js +1657 -0
  222. package/cjs/model/model.js.map +1 -0
  223. package/cjs/model/model.types.d.ts +44 -0
  224. package/cjs/model/model.types.d.ts.map +1 -0
  225. package/cjs/model/register-model.d.ts +81 -0
  226. package/cjs/model/register-model.d.ts.map +1 -0
  227. package/cjs/model/register-model.js +94 -0
  228. package/cjs/model/register-model.js.map +1 -0
  229. package/cjs/query-builder/query-builder.d.ts +556 -0
  230. package/cjs/query-builder/query-builder.d.ts.map +1 -0
  231. package/cjs/query-builder/query-builder.js +1070 -0
  232. package/cjs/query-builder/query-builder.js.map +1 -0
  233. package/cjs/relations/helpers.d.ts +156 -0
  234. package/cjs/relations/helpers.d.ts.map +1 -0
  235. package/cjs/relations/helpers.js +202 -0
  236. package/cjs/relations/helpers.js.map +1 -0
  237. package/cjs/relations/index.d.ts +35 -0
  238. package/cjs/relations/index.d.ts.map +1 -0
  239. package/cjs/relations/pivot-operations.d.ts +160 -0
  240. package/cjs/relations/pivot-operations.d.ts.map +1 -0
  241. package/cjs/relations/pivot-operations.js +293 -0
  242. package/cjs/relations/pivot-operations.js.map +1 -0
  243. package/cjs/relations/relation-hydrator.d.ts +68 -0
  244. package/cjs/relations/relation-hydrator.d.ts.map +1 -0
  245. package/cjs/relations/relation-hydrator.js +81 -0
  246. package/cjs/relations/relation-hydrator.js.map +1 -0
  247. package/cjs/relations/relation-loader.d.ts +194 -0
  248. package/cjs/relations/relation-loader.d.ts.map +1 -0
  249. package/cjs/relations/relation-loader.js +466 -0
  250. package/cjs/relations/relation-loader.js.map +1 -0
  251. package/cjs/relations/types.d.ts +306 -0
  252. package/cjs/relations/types.d.ts.map +1 -0
  253. package/cjs/remover/database-remover.d.ts +100 -0
  254. package/cjs/remover/database-remover.d.ts.map +1 -0
  255. package/cjs/remover/database-remover.js +214 -0
  256. package/cjs/remover/database-remover.js.map +1 -0
  257. package/cjs/restorer/database-restorer.d.ts +131 -0
  258. package/cjs/restorer/database-restorer.d.ts.map +1 -0
  259. package/cjs/restorer/database-restorer.js +434 -0
  260. package/cjs/restorer/database-restorer.js.map +1 -0
  261. package/cjs/sql-database-dirty-tracker.d.ts +13 -0
  262. package/cjs/sql-database-dirty-tracker.d.ts.map +1 -0
  263. package/cjs/sql-database-dirty-tracker.js +14 -0
  264. package/cjs/sql-database-dirty-tracker.js.map +1 -0
  265. package/cjs/sync/index.d.ts +12 -0
  266. package/cjs/sync/index.d.ts.map +1 -0
  267. package/cjs/sync/model-events.d.ts +62 -0
  268. package/cjs/sync/model-events.d.ts.map +1 -0
  269. package/cjs/sync/model-events.js +49 -0
  270. package/cjs/sync/model-events.js.map +1 -0
  271. package/cjs/sync/model-sync-operation.d.ts +163 -0
  272. package/cjs/sync/model-sync-operation.d.ts.map +1 -0
  273. package/cjs/sync/model-sync-operation.js +292 -0
  274. package/cjs/sync/model-sync-operation.js.map +1 -0
  275. package/cjs/sync/model-sync.d.ts +130 -0
  276. package/cjs/sync/model-sync.d.ts.map +1 -0
  277. package/cjs/sync/model-sync.js +178 -0
  278. package/cjs/sync/model-sync.js.map +1 -0
  279. package/cjs/sync/sync-context.d.ts +70 -0
  280. package/cjs/sync/sync-context.d.ts.map +1 -0
  281. package/cjs/sync/sync-context.js +101 -0
  282. package/cjs/sync/sync-context.js.map +1 -0
  283. package/cjs/sync/sync-manager.d.ts +213 -0
  284. package/cjs/sync/sync-manager.d.ts.map +1 -0
  285. package/cjs/sync/sync-manager.js +689 -0
  286. package/cjs/sync/sync-manager.js.map +1 -0
  287. package/cjs/sync/types.d.ts +289 -0
  288. package/cjs/sync/types.d.ts.map +1 -0
  289. package/cjs/test-migrations/test-enhanced-features.migration.d.ts +15 -0
  290. package/cjs/test-migrations/test-enhanced-features.migration.d.ts.map +1 -0
  291. package/cjs/types.d.ts +371 -0
  292. package/cjs/types.d.ts.map +1 -0
  293. package/cjs/utils/connect-to-database.d.ts +307 -0
  294. package/cjs/utils/connect-to-database.d.ts.map +1 -0
  295. package/cjs/utils/connect-to-database.js +130 -0
  296. package/cjs/utils/connect-to-database.js.map +1 -0
  297. package/cjs/utils/database-writer.utils.d.ts +15 -0
  298. package/cjs/utils/database-writer.utils.d.ts.map +1 -0
  299. package/cjs/utils/database-writer.utils.js +14 -0
  300. package/cjs/utils/database-writer.utils.js.map +1 -0
  301. package/cjs/utils/define-model.js +100 -0
  302. package/cjs/utils/define-model.js.map +1 -0
  303. package/cjs/utils/is-valid-date-value.d.ts +5 -0
  304. package/cjs/utils/is-valid-date-value.d.ts.map +1 -0
  305. package/cjs/utils/is-valid-date-value.js +25 -0
  306. package/cjs/utils/is-valid-date-value.js.map +1 -0
  307. package/cjs/utils/once-connected.d.ts +146 -0
  308. package/cjs/utils/once-connected.d.ts.map +1 -0
  309. package/cjs/utils/once-connected.js +251 -0
  310. package/cjs/utils/once-connected.js.map +1 -0
  311. package/cjs/validation/database-seal-plugins.d.ts +12 -0
  312. package/cjs/validation/database-seal-plugins.d.ts.map +1 -0
  313. package/cjs/validation/database-seal-plugins.js +1 -0
  314. package/cjs/validation/database-seal-plugins.js.map +1 -0
  315. package/cjs/validation/database-writer-validation-error.d.ts +97 -0
  316. package/cjs/validation/database-writer-validation-error.d.ts.map +1 -0
  317. package/cjs/validation/database-writer-validation-error.js +160 -0
  318. package/cjs/validation/database-writer-validation-error.js.map +1 -0
  319. package/cjs/validation/index.d.ts +3 -0
  320. package/cjs/validation/index.d.ts.map +1 -0
  321. package/cjs/validation/mutators/embed-mutator.d.ts +9 -0
  322. package/cjs/validation/mutators/embed-mutator.d.ts.map +1 -0
  323. package/cjs/validation/mutators/embed-mutator.js +33 -0
  324. package/cjs/validation/mutators/embed-mutator.js.map +1 -0
  325. package/cjs/validation/plugins/embed-validator-plugin.d.ts +24 -0
  326. package/cjs/validation/plugins/embed-validator-plugin.d.ts.map +1 -0
  327. package/cjs/validation/plugins/embed-validator-plugin.js +18 -0
  328. package/cjs/validation/plugins/embed-validator-plugin.js.map +1 -0
  329. package/cjs/validation/rules/database-model-rule.d.ts +7 -0
  330. package/cjs/validation/rules/database-model-rule.d.ts.map +1 -0
  331. package/cjs/validation/rules/database-model-rule.js +27 -0
  332. package/cjs/validation/rules/database-model-rule.js.map +1 -0
  333. package/cjs/validation/transformers/embed-model-transformer.d.ts +3 -0
  334. package/cjs/validation/transformers/embed-model-transformer.d.ts.map +1 -0
  335. package/cjs/validation/transformers/embed-model-transformer.js +18 -0
  336. package/cjs/validation/transformers/embed-model-transformer.js.map +1 -0
  337. package/cjs/validation/validators/embed-validator.d.ts +21 -0
  338. package/cjs/validation/validators/embed-validator.d.ts.map +1 -0
  339. package/cjs/validation/validators/embed-validator.js +43 -0
  340. package/cjs/validation/validators/embed-validator.js.map +1 -0
  341. package/cjs/writer/database-writer.d.ts +181 -0
  342. package/cjs/writer/database-writer.d.ts.map +1 -0
  343. package/cjs/writer/database-writer.js +407 -0
  344. package/cjs/writer/database-writer.js.map +1 -0
  345. package/esm/data-source/data-source-registry.d.ts +108 -0
  346. package/esm/data-source/data-source-registry.d.ts.map +1 -0
  347. package/esm/data-source/data-source-registry.js +145 -0
  348. package/esm/data-source/data-source-registry.js.map +1 -0
  349. package/esm/data-source/data-source.d.ts +147 -0
  350. package/esm/data-source/data-source.d.ts.map +1 -0
  351. package/esm/data-source/data-source.js +83 -0
  352. package/esm/data-source/data-source.js.map +1 -0
  353. package/esm/database-dirty-tracker.d.ts +252 -0
  354. package/esm/database-dirty-tracker.d.ts.map +1 -0
  355. package/esm/database-dirty-tracker.js +386 -0
  356. package/esm/database-dirty-tracker.js.map +1 -0
  357. package/esm/drivers/mongodb/mongodb-blueprint.d.ts +30 -0
  358. package/esm/drivers/mongodb/mongodb-blueprint.d.ts.map +1 -0
  359. package/esm/drivers/mongodb/mongodb-blueprint.js +51 -0
  360. package/esm/drivers/mongodb/mongodb-blueprint.js.map +1 -0
  361. package/esm/drivers/mongodb/mongodb-driver.d.ts +325 -0
  362. package/esm/drivers/mongodb/mongodb-driver.d.ts.map +1 -0
  363. package/esm/drivers/mongodb/mongodb-driver.js +838 -0
  364. package/esm/drivers/mongodb/mongodb-driver.js.map +1 -0
  365. package/esm/drivers/mongodb/mongodb-id-generator.d.ts +116 -0
  366. package/esm/drivers/mongodb/mongodb-id-generator.d.ts.map +1 -0
  367. package/esm/drivers/mongodb/mongodb-id-generator.js +149 -0
  368. package/esm/drivers/mongodb/mongodb-id-generator.js.map +1 -0
  369. package/esm/drivers/mongodb/mongodb-migration-driver.d.ts +317 -0
  370. package/esm/drivers/mongodb/mongodb-migration-driver.d.ts.map +1 -0
  371. package/esm/drivers/mongodb/mongodb-migration-driver.js +666 -0
  372. package/esm/drivers/mongodb/mongodb-migration-driver.js.map +1 -0
  373. package/esm/drivers/mongodb/mongodb-query-builder.d.ts +1122 -0
  374. package/esm/drivers/mongodb/mongodb-query-builder.d.ts.map +1 -0
  375. package/esm/drivers/mongodb/mongodb-query-builder.js +1988 -0
  376. package/esm/drivers/mongodb/mongodb-query-builder.js.map +1 -0
  377. package/esm/drivers/mongodb/mongodb-query-operations.d.ts +226 -0
  378. package/esm/drivers/mongodb/mongodb-query-operations.d.ts.map +1 -0
  379. package/esm/drivers/mongodb/mongodb-query-operations.js +270 -0
  380. package/esm/drivers/mongodb/mongodb-query-operations.js.map +1 -0
  381. package/esm/drivers/mongodb/mongodb-query-parser.d.ts +262 -0
  382. package/esm/drivers/mongodb/mongodb-query-parser.d.ts.map +1 -0
  383. package/esm/drivers/mongodb/mongodb-query-parser.js +1351 -0
  384. package/esm/drivers/mongodb/mongodb-query-parser.js.map +1 -0
  385. package/esm/drivers/mongodb/mongodb-sync-adapter.d.ts +79 -0
  386. package/esm/drivers/mongodb/mongodb-sync-adapter.d.ts.map +1 -0
  387. package/esm/drivers/mongodb/mongodb-sync-adapter.js +146 -0
  388. package/esm/drivers/mongodb/mongodb-sync-adapter.js.map +1 -0
  389. package/esm/drivers/mongodb/types.d.ts +43 -0
  390. package/esm/drivers/mongodb/types.d.ts.map +1 -0
  391. package/esm/drivers/postgres/index.d.ts +16 -0
  392. package/esm/drivers/postgres/index.d.ts.map +1 -0
  393. package/esm/drivers/postgres/postgres-blueprint.d.ts +64 -0
  394. package/esm/drivers/postgres/postgres-blueprint.d.ts.map +1 -0
  395. package/esm/drivers/postgres/postgres-blueprint.js +121 -0
  396. package/esm/drivers/postgres/postgres-blueprint.js.map +1 -0
  397. package/esm/drivers/postgres/postgres-dialect.d.ts +136 -0
  398. package/esm/drivers/postgres/postgres-dialect.d.ts.map +1 -0
  399. package/esm/drivers/postgres/postgres-dialect.js +268 -0
  400. package/esm/drivers/postgres/postgres-dialect.js.map +1 -0
  401. package/esm/drivers/postgres/postgres-driver.d.ts +432 -0
  402. package/esm/drivers/postgres/postgres-driver.d.ts.map +1 -0
  403. package/esm/drivers/postgres/postgres-driver.js +1010 -0
  404. package/esm/drivers/postgres/postgres-driver.js.map +1 -0
  405. package/esm/drivers/postgres/postgres-migration-driver.d.ts +397 -0
  406. package/esm/drivers/postgres/postgres-migration-driver.d.ts.map +1 -0
  407. package/esm/drivers/postgres/postgres-migration-driver.js +900 -0
  408. package/esm/drivers/postgres/postgres-migration-driver.js.map +1 -0
  409. package/esm/drivers/postgres/postgres-query-builder.d.ts +254 -0
  410. package/esm/drivers/postgres/postgres-query-builder.d.ts.map +1 -0
  411. package/esm/drivers/postgres/postgres-query-builder.js +933 -0
  412. package/esm/drivers/postgres/postgres-query-builder.js.map +1 -0
  413. package/esm/drivers/postgres/postgres-query-parser.d.ts +328 -0
  414. package/esm/drivers/postgres/postgres-query-parser.d.ts.map +1 -0
  415. package/esm/drivers/postgres/postgres-query-parser.js +868 -0
  416. package/esm/drivers/postgres/postgres-query-parser.js.map +1 -0
  417. package/esm/drivers/postgres/postgres-sql-serializer.d.ts +37 -0
  418. package/esm/drivers/postgres/postgres-sql-serializer.d.ts.map +1 -0
  419. package/esm/drivers/postgres/postgres-sql-serializer.js +400 -0
  420. package/esm/drivers/postgres/postgres-sql-serializer.js.map +1 -0
  421. package/esm/drivers/postgres/postgres-sync-adapter.d.ts +83 -0
  422. package/esm/drivers/postgres/postgres-sync-adapter.d.ts.map +1 -0
  423. package/esm/drivers/postgres/postgres-sync-adapter.js +197 -0
  424. package/esm/drivers/postgres/postgres-sync-adapter.js.map +1 -0
  425. package/esm/drivers/postgres/types.d.ts +144 -0
  426. package/esm/drivers/postgres/types.d.ts.map +1 -0
  427. package/esm/drivers/sql/index.d.ts +10 -0
  428. package/esm/drivers/sql/index.d.ts.map +1 -0
  429. package/esm/drivers/sql/sql-dialect.contract.d.ts +204 -0
  430. package/esm/drivers/sql/sql-dialect.contract.d.ts.map +1 -0
  431. package/esm/drivers/sql/sql-types.d.ts +202 -0
  432. package/esm/drivers/sql/sql-types.d.ts.map +1 -0
  433. package/esm/errors/missing-data-source.error.d.ts +22 -0
  434. package/esm/errors/missing-data-source.error.d.ts.map +1 -0
  435. package/esm/errors/missing-data-source.error.js +29 -0
  436. package/esm/errors/missing-data-source.error.js.map +1 -0
  437. package/esm/errors/transaction-rollback.error.d.ts +20 -0
  438. package/esm/errors/transaction-rollback.error.d.ts.map +1 -0
  439. package/esm/errors/transaction-rollback.error.js +27 -0
  440. package/esm/errors/transaction-rollback.error.js.map +1 -0
  441. package/esm/events/model-events.d.ts +231 -0
  442. package/esm/events/model-events.d.ts.map +1 -0
  443. package/esm/events/model-events.js +259 -0
  444. package/esm/events/model-events.js.map +1 -0
  445. package/esm/expressions/aggregate-expressions.d.ts +215 -0
  446. package/esm/expressions/aggregate-expressions.d.ts.map +1 -0
  447. package/esm/expressions/aggregate-expressions.js +221 -0
  448. package/esm/expressions/aggregate-expressions.js.map +1 -0
  449. package/esm/expressions/index.d.ts +2 -0
  450. package/esm/expressions/index.d.ts.map +1 -0
  451. package/esm/index.d.ts +45 -0
  452. package/esm/index.d.ts.map +1 -0
  453. package/esm/index.js +1 -0
  454. package/esm/index.js.map +1 -0
  455. package/esm/migration/column-builder.d.ts +417 -0
  456. package/esm/migration/column-builder.d.ts.map +1 -0
  457. package/esm/migration/column-builder.js +586 -0
  458. package/esm/migration/column-builder.js.map +1 -0
  459. package/esm/migration/column-helpers.d.ts +275 -0
  460. package/esm/migration/column-helpers.d.ts.map +1 -0
  461. package/esm/migration/column-helpers.js +389 -0
  462. package/esm/migration/column-helpers.js.map +1 -0
  463. package/esm/migration/foreign-key-builder.d.ts +103 -0
  464. package/esm/migration/foreign-key-builder.d.ts.map +1 -0
  465. package/esm/migration/foreign-key-builder.js +121 -0
  466. package/esm/migration/foreign-key-builder.js.map +1 -0
  467. package/esm/migration/index.d.ts +7 -0
  468. package/esm/migration/index.d.ts.map +1 -0
  469. package/esm/migration/migration-runner.d.ts +278 -0
  470. package/esm/migration/migration-runner.d.ts.map +1 -0
  471. package/esm/migration/migration-runner.js +815 -0
  472. package/esm/migration/migration-runner.js.map +1 -0
  473. package/esm/migration/migration.d.ts +1992 -0
  474. package/esm/migration/migration.d.ts.map +1 -0
  475. package/esm/migration/migration.js +2162 -0
  476. package/esm/migration/migration.js.map +1 -0
  477. package/esm/migration/sql-grammar.d.ts +61 -0
  478. package/esm/migration/sql-grammar.d.ts.map +1 -0
  479. package/esm/migration/sql-grammar.js +164 -0
  480. package/esm/migration/sql-grammar.js.map +1 -0
  481. package/esm/migration/sql-serializer.d.ts +22 -0
  482. package/esm/migration/sql-serializer.d.ts.map +1 -0
  483. package/esm/migration/sql-serializer.js +26 -0
  484. package/esm/migration/sql-serializer.js.map +1 -0
  485. package/esm/migration/types.d.ts +155 -0
  486. package/esm/migration/types.d.ts.map +1 -0
  487. package/esm/model/methods/accessor-methods.d.ts +13 -0
  488. package/esm/model/methods/accessor-methods.d.ts.map +1 -0
  489. package/esm/model/methods/accessor-methods.js +51 -0
  490. package/esm/model/methods/accessor-methods.js.map +1 -0
  491. package/esm/model/methods/delete-methods.d.ts +10 -0
  492. package/esm/model/methods/delete-methods.d.ts.map +1 -0
  493. package/esm/model/methods/delete-methods.js +10 -0
  494. package/esm/model/methods/delete-methods.js.map +1 -0
  495. package/esm/model/methods/dirty-methods.d.ts +10 -0
  496. package/esm/model/methods/dirty-methods.d.ts.map +1 -0
  497. package/esm/model/methods/dirty-methods.js +15 -0
  498. package/esm/model/methods/dirty-methods.js.map +1 -0
  499. package/esm/model/methods/hydration-methods.d.ts +10 -0
  500. package/esm/model/methods/hydration-methods.d.ts.map +1 -0
  501. package/esm/model/methods/hydration-methods.js +57 -0
  502. package/esm/model/methods/hydration-methods.js.map +1 -0
  503. package/esm/model/methods/instance-event-methods.d.ts +7 -0
  504. package/esm/model/methods/instance-event-methods.d.ts.map +1 -0
  505. package/esm/model/methods/instance-event-methods.js +15 -0
  506. package/esm/model/methods/instance-event-methods.js.map +1 -0
  507. package/esm/model/methods/meta-methods.d.ts +7 -0
  508. package/esm/model/methods/meta-methods.d.ts.map +1 -0
  509. package/esm/model/methods/meta-methods.js +78 -0
  510. package/esm/model/methods/meta-methods.js.map +1 -0
  511. package/esm/model/methods/query-methods.d.ts +24 -0
  512. package/esm/model/methods/query-methods.d.ts.map +1 -0
  513. package/esm/model/methods/query-methods.js +164 -0
  514. package/esm/model/methods/query-methods.js.map +1 -0
  515. package/esm/model/methods/restore-methods.d.ts +10 -0
  516. package/esm/model/methods/restore-methods.d.ts.map +1 -0
  517. package/esm/model/methods/restore-methods.js +13 -0
  518. package/esm/model/methods/restore-methods.js.map +1 -0
  519. package/esm/model/methods/scope-methods.d.ts +7 -0
  520. package/esm/model/methods/scope-methods.d.ts.map +1 -0
  521. package/esm/model/methods/scope-methods.js +15 -0
  522. package/esm/model/methods/scope-methods.js.map +1 -0
  523. package/esm/model/methods/serialization-methods.d.ts +3 -0
  524. package/esm/model/methods/serialization-methods.d.ts.map +1 -0
  525. package/esm/model/methods/serialization-methods.js +27 -0
  526. package/esm/model/methods/serialization-methods.js.map +1 -0
  527. package/esm/model/methods/static-event-methods.d.ts +9 -0
  528. package/esm/model/methods/static-event-methods.d.ts.map +1 -0
  529. package/esm/model/methods/static-event-methods.js +29 -0
  530. package/esm/model/methods/static-event-methods.js.map +1 -0
  531. package/esm/model/methods/write-methods.d.ts +10 -0
  532. package/esm/model/methods/write-methods.d.ts.map +1 -0
  533. package/esm/model/methods/write-methods.js +52 -0
  534. package/esm/model/methods/write-methods.js.map +1 -0
  535. package/esm/model/model.d.ts +1647 -0
  536. package/esm/model/model.d.ts.map +1 -0
  537. package/esm/model/model.js +1657 -0
  538. package/esm/model/model.js.map +1 -0
  539. package/esm/model/model.types.d.ts +44 -0
  540. package/esm/model/model.types.d.ts.map +1 -0
  541. package/esm/model/register-model.d.ts +81 -0
  542. package/esm/model/register-model.d.ts.map +1 -0
  543. package/esm/model/register-model.js +94 -0
  544. package/esm/model/register-model.js.map +1 -0
  545. package/esm/query-builder/query-builder.d.ts +556 -0
  546. package/esm/query-builder/query-builder.d.ts.map +1 -0
  547. package/esm/query-builder/query-builder.js +1070 -0
  548. package/esm/query-builder/query-builder.js.map +1 -0
  549. package/esm/relations/helpers.d.ts +156 -0
  550. package/esm/relations/helpers.d.ts.map +1 -0
  551. package/esm/relations/helpers.js +202 -0
  552. package/esm/relations/helpers.js.map +1 -0
  553. package/esm/relations/index.d.ts +35 -0
  554. package/esm/relations/index.d.ts.map +1 -0
  555. package/esm/relations/pivot-operations.d.ts +160 -0
  556. package/esm/relations/pivot-operations.d.ts.map +1 -0
  557. package/esm/relations/pivot-operations.js +293 -0
  558. package/esm/relations/pivot-operations.js.map +1 -0
  559. package/esm/relations/relation-hydrator.d.ts +68 -0
  560. package/esm/relations/relation-hydrator.d.ts.map +1 -0
  561. package/esm/relations/relation-hydrator.js +81 -0
  562. package/esm/relations/relation-hydrator.js.map +1 -0
  563. package/esm/relations/relation-loader.d.ts +194 -0
  564. package/esm/relations/relation-loader.d.ts.map +1 -0
  565. package/esm/relations/relation-loader.js +466 -0
  566. package/esm/relations/relation-loader.js.map +1 -0
  567. package/esm/relations/types.d.ts +306 -0
  568. package/esm/relations/types.d.ts.map +1 -0
  569. package/esm/remover/database-remover.d.ts +100 -0
  570. package/esm/remover/database-remover.d.ts.map +1 -0
  571. package/esm/remover/database-remover.js +214 -0
  572. package/esm/remover/database-remover.js.map +1 -0
  573. package/esm/restorer/database-restorer.d.ts +131 -0
  574. package/esm/restorer/database-restorer.d.ts.map +1 -0
  575. package/esm/restorer/database-restorer.js +434 -0
  576. package/esm/restorer/database-restorer.js.map +1 -0
  577. package/esm/sql-database-dirty-tracker.d.ts +13 -0
  578. package/esm/sql-database-dirty-tracker.d.ts.map +1 -0
  579. package/esm/sql-database-dirty-tracker.js +14 -0
  580. package/esm/sql-database-dirty-tracker.js.map +1 -0
  581. package/esm/sync/index.d.ts +12 -0
  582. package/esm/sync/index.d.ts.map +1 -0
  583. package/esm/sync/model-events.d.ts +62 -0
  584. package/esm/sync/model-events.d.ts.map +1 -0
  585. package/esm/sync/model-events.js +49 -0
  586. package/esm/sync/model-events.js.map +1 -0
  587. package/esm/sync/model-sync-operation.d.ts +163 -0
  588. package/esm/sync/model-sync-operation.d.ts.map +1 -0
  589. package/esm/sync/model-sync-operation.js +292 -0
  590. package/esm/sync/model-sync-operation.js.map +1 -0
  591. package/esm/sync/model-sync.d.ts +130 -0
  592. package/esm/sync/model-sync.d.ts.map +1 -0
  593. package/esm/sync/model-sync.js +178 -0
  594. package/esm/sync/model-sync.js.map +1 -0
  595. package/esm/sync/sync-context.d.ts +70 -0
  596. package/esm/sync/sync-context.d.ts.map +1 -0
  597. package/esm/sync/sync-context.js +101 -0
  598. package/esm/sync/sync-context.js.map +1 -0
  599. package/esm/sync/sync-manager.d.ts +213 -0
  600. package/esm/sync/sync-manager.d.ts.map +1 -0
  601. package/esm/sync/sync-manager.js +689 -0
  602. package/esm/sync/sync-manager.js.map +1 -0
  603. package/esm/sync/types.d.ts +289 -0
  604. package/esm/sync/types.d.ts.map +1 -0
  605. package/esm/test-migrations/test-enhanced-features.migration.d.ts +15 -0
  606. package/esm/test-migrations/test-enhanced-features.migration.d.ts.map +1 -0
  607. package/esm/types.d.ts +371 -0
  608. package/esm/types.d.ts.map +1 -0
  609. package/esm/utils/connect-to-database.d.ts +307 -0
  610. package/esm/utils/connect-to-database.d.ts.map +1 -0
  611. package/esm/utils/connect-to-database.js +130 -0
  612. package/esm/utils/connect-to-database.js.map +1 -0
  613. package/esm/utils/database-writer.utils.d.ts +15 -0
  614. package/esm/utils/database-writer.utils.d.ts.map +1 -0
  615. package/esm/utils/database-writer.utils.js +14 -0
  616. package/esm/utils/database-writer.utils.js.map +1 -0
  617. package/esm/utils/define-model.js +100 -0
  618. package/esm/utils/define-model.js.map +1 -0
  619. package/esm/utils/is-valid-date-value.d.ts +5 -0
  620. package/esm/utils/is-valid-date-value.d.ts.map +1 -0
  621. package/esm/utils/is-valid-date-value.js +25 -0
  622. package/esm/utils/is-valid-date-value.js.map +1 -0
  623. package/esm/utils/once-connected.d.ts +146 -0
  624. package/esm/utils/once-connected.d.ts.map +1 -0
  625. package/esm/utils/once-connected.js +251 -0
  626. package/esm/utils/once-connected.js.map +1 -0
  627. package/esm/validation/database-seal-plugins.d.ts +12 -0
  628. package/esm/validation/database-seal-plugins.d.ts.map +1 -0
  629. package/esm/validation/database-seal-plugins.js +1 -0
  630. package/esm/validation/database-seal-plugins.js.map +1 -0
  631. package/esm/validation/database-writer-validation-error.d.ts +97 -0
  632. package/esm/validation/database-writer-validation-error.d.ts.map +1 -0
  633. package/esm/validation/database-writer-validation-error.js +160 -0
  634. package/esm/validation/database-writer-validation-error.js.map +1 -0
  635. package/esm/validation/index.d.ts +3 -0
  636. package/esm/validation/index.d.ts.map +1 -0
  637. package/esm/validation/mutators/embed-mutator.d.ts +9 -0
  638. package/esm/validation/mutators/embed-mutator.d.ts.map +1 -0
  639. package/esm/validation/mutators/embed-mutator.js +33 -0
  640. package/esm/validation/mutators/embed-mutator.js.map +1 -0
  641. package/esm/validation/plugins/embed-validator-plugin.d.ts +24 -0
  642. package/esm/validation/plugins/embed-validator-plugin.d.ts.map +1 -0
  643. package/esm/validation/plugins/embed-validator-plugin.js +18 -0
  644. package/esm/validation/plugins/embed-validator-plugin.js.map +1 -0
  645. package/esm/validation/rules/database-model-rule.d.ts +7 -0
  646. package/esm/validation/rules/database-model-rule.d.ts.map +1 -0
  647. package/esm/validation/rules/database-model-rule.js +27 -0
  648. package/esm/validation/rules/database-model-rule.js.map +1 -0
  649. package/esm/validation/transformers/embed-model-transformer.d.ts +3 -0
  650. package/esm/validation/transformers/embed-model-transformer.d.ts.map +1 -0
  651. package/esm/validation/transformers/embed-model-transformer.js +18 -0
  652. package/esm/validation/transformers/embed-model-transformer.js.map +1 -0
  653. package/esm/validation/validators/embed-validator.d.ts +21 -0
  654. package/esm/validation/validators/embed-validator.d.ts.map +1 -0
  655. package/esm/validation/validators/embed-validator.js +43 -0
  656. package/esm/validation/validators/embed-validator.js.map +1 -0
  657. package/esm/writer/database-writer.d.ts +181 -0
  658. package/esm/writer/database-writer.d.ts.map +1 -0
  659. package/esm/writer/database-writer.js +407 -0
  660. package/esm/writer/database-writer.js.map +1 -0
  661. package/package.json +4 -4
@@ -0,0 +1,838 @@
1
+ 'use strict';var copper=require('@mongez/copper'),logger=require('@warlock.js/logger'),node_events=require('node:events'),databaseTransactionContext=require('../../context/database-transaction-context.js'),dataSourceRegistry=require('../../data-source/data-source-registry.js'),databaseDirtyTracker=require('../../database-dirty-tracker.js'),transactionRollback_error=require('../../errors/transaction-rollback.error.js'),isValidDateValue=require('../../utils/is-valid-date-value.js'),mongodbBlueprint=require('./mongodb-blueprint.js'),mongodbIdGenerator=require('./mongodb-id-generator.js'),mongodbMigrationDriver=require('./mongodb-migration-driver.js'),mongodbQueryBuilder=require('./mongodb-query-builder.js'),mongodbSyncAdapter=require('./mongodb-sync-adapter.js');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}const DEFAULT_TRANSACTION_OPTIONS = {
2
+ readPreference: "primary",
3
+ readConcern: { level: "local" },
4
+ writeConcern: { w: "majority" },
5
+ };
6
+ // ============================================================
7
+ // Lazy-loaded MongoDB SDK Types
8
+ // ============================================================
9
+ /**
10
+ * Cached MongoDB module (loaded once, reused)
11
+ */
12
+ let MongoDBClient;
13
+ let ObjectId;
14
+ let isModuleExists = null;
15
+ let loadingPromise;
16
+ /**
17
+ * Installation instructions for MongoDB package
18
+ */
19
+ const MONGODB_INSTALL_INSTRUCTIONS = `
20
+ MongoDB driver requires the mongodb package.
21
+ Install it with:
22
+
23
+ npm install mongodb
24
+
25
+ Or with your preferred package manager:
26
+
27
+ pnpm add mongodb
28
+ yarn add mongodb
29
+ `.trim();
30
+ /**
31
+ * Load MongoDB module
32
+ */
33
+ async function loadMongoDB() {
34
+ try {
35
+ loadingPromise = Promise.resolve().then(function(){return /*#__PURE__*/_interopNamespace(require('mongodb'))});
36
+ MongoDBClient = await loadingPromise;
37
+ ObjectId = MongoDBClient.ObjectId;
38
+ isModuleExists = true;
39
+ }
40
+ catch {
41
+ isModuleExists = false;
42
+ }
43
+ }
44
+ loadMongoDB();
45
+ function isMongoDBDriverLoaded() {
46
+ return isModuleExists;
47
+ }
48
+ async function assertModuleIsLoaded() {
49
+ if (isModuleExists === false) {
50
+ throw new Error(MONGODB_INSTALL_INSTRUCTIONS);
51
+ }
52
+ if (isModuleExists === null) {
53
+ await loadingPromise;
54
+ return await assertModuleIsLoaded();
55
+ }
56
+ }
57
+ /**
58
+ * MongoDB driver implementation that fulfils the Cascade driver contract.
59
+ *
60
+ * It encapsulates the native Mongo client, exposes lifecycle events, and
61
+ * provides helpers for CRUD, transactions, atomic updates, and sync adapters.
62
+ */
63
+ class MongoDbDriver {
64
+ config;
65
+ driverOptions;
66
+ events = new node_events.EventEmitter();
67
+ client;
68
+ database;
69
+ connected = false;
70
+ syncAdapterInstance;
71
+ migrationDriverInstance;
72
+ transactionOptions;
73
+ idGeneratorInstance;
74
+ _blueprint;
75
+ get blueprint() {
76
+ if (!this._blueprint) {
77
+ this._blueprint = new mongodbBlueprint.MongoDBBlueprint(this.database);
78
+ }
79
+ return this._blueprint;
80
+ }
81
+ /**
82
+ * The name of this driver.
83
+ */
84
+ name = "mongodb";
85
+ /**
86
+ * Current database name
87
+ */
88
+ _databaseName;
89
+ /**
90
+ * MongoDB driver model defaults.
91
+ *
92
+ * MongoDB follows NoSQL conventions:
93
+ * - camelCase naming for fields (createdAt, updatedAt, deletedAt)
94
+ * - Manual ID generation (auto-increment id field separate from _id)
95
+ * - Timestamps enabled by default
96
+ * - Trash delete strategy with per-collection trash tables
97
+ */
98
+ modelDefaults = {
99
+ namingConvention: "camelCase",
100
+ createdAtColumn: "createdAt",
101
+ updatedAtColumn: "updatedAt",
102
+ deletedAtColumn: "deletedAt",
103
+ timestamps: true,
104
+ autoGenerateId: true,
105
+ strictMode: "strip",
106
+ deleteStrategy: "trash",
107
+ trashTable: (table) => `${table}Trash`, // Per-collection trash (usersTrash, productsTrash)
108
+ };
109
+ /**
110
+ * Create a new MongoDB driver using the supplied connection options.
111
+ *
112
+ * @param config - Connection configuration
113
+ * @param driverOptions - Driver-specific options
114
+ */
115
+ constructor(config, driverOptions) {
116
+ this.config = config;
117
+ this.driverOptions = driverOptions;
118
+ this.transactionOptions = {
119
+ ...DEFAULT_TRANSACTION_OPTIONS,
120
+ ...driverOptions?.transactionOptions,
121
+ };
122
+ }
123
+ /**
124
+ * Get data base name
125
+ */
126
+ get databaseName() {
127
+ if (!this._databaseName) {
128
+ this.resolveDatabaseName();
129
+ }
130
+ return this._databaseName;
131
+ }
132
+ /**
133
+ * Resolve database name either from config or uri
134
+ */
135
+ resolveDatabaseName() {
136
+ if (this.config.database) {
137
+ this._databaseName = this.config.database;
138
+ }
139
+ else if (this.config.uri) {
140
+ this._databaseName = this.config.uri.split("/").pop()?.split("?")?.[0];
141
+ }
142
+ }
143
+ /**
144
+ * Indicates whether the driver currently maintains an active connection.
145
+ */
146
+ get isConnected() {
147
+ return this.connected;
148
+ }
149
+ /**
150
+ * Get the MongoDB database instance.
151
+ *
152
+ * @returns The MongoDB Db instance
153
+ * @throws {Error} If not connected
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const db = driver.getDatabase();
158
+ * const collection = db.collection("users");
159
+ * ```
160
+ */
161
+ getDatabase() {
162
+ if (!this.database) {
163
+ throw new Error("Database not available. Ensure the driver is connected before accessing the database.");
164
+ }
165
+ return this.database;
166
+ }
167
+ /**
168
+ * Get the ID generator instance for this driver.
169
+ *
170
+ * Creates a MongoIdGenerator on first access if autoGenerateId is enabled.
171
+ *
172
+ * @returns The ID generator instance, or undefined if disabled
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * const idGenerator = driver.getIdGenerator();
177
+ * if (idGenerator) {
178
+ * const id = await idGenerator.generateNextId({ table: "users" });
179
+ * }
180
+ * ```
181
+ */
182
+ getIdGenerator() {
183
+ // Return undefined if ID generation is disabled
184
+ if (this.driverOptions?.autoGenerateId === false) {
185
+ return undefined;
186
+ }
187
+ // Create ID generator lazily on first access
188
+ if (!this.idGeneratorInstance) {
189
+ this.idGeneratorInstance = new mongodbIdGenerator.MongoIdGenerator(this, this.driverOptions?.counterCollection);
190
+ }
191
+ return this.idGeneratorInstance;
192
+ }
193
+ /**
194
+ * Establish a MongoDB connection using the configured options.
195
+ * Throws if the connection attempt fails.
196
+ */
197
+ async connect() {
198
+ if (this.connected) {
199
+ return;
200
+ }
201
+ await assertModuleIsLoaded();
202
+ const uri = this.resolveUri();
203
+ const { MongoClient, ObjectId: ObjectIdMongoDB } = MongoDBClient;
204
+ ObjectId = ObjectIdMongoDB;
205
+ const client = new MongoClient(uri, this.buildClientOptions());
206
+ try {
207
+ logger.log.info("database.mongodb", "connection", `Connecting to database ${copper.colors.bold(copper.colors.yellowBright(this.databaseName))}`);
208
+ await client.connect();
209
+ this.client = client;
210
+ this.database = client.db(this.databaseName);
211
+ this.connected = true;
212
+ logger.log.success("database.mongodb", "connection", "Connected to database");
213
+ client.on("close", () => {
214
+ if (this.connected) {
215
+ this.connected = false;
216
+ this.emit("disconnected");
217
+ logger.log.warn("database.mongodb", "connection", "Disconnected from database");
218
+ }
219
+ });
220
+ if (this.config.logging) {
221
+ const ignoredCommands = ["isMaster", "hello", "ping", "saslStart", "saslContinue"];
222
+ client.on("commandStarted", (event) => {
223
+ if (ignoredCommands.includes(event.commandName))
224
+ return;
225
+ let cmdStr = JSON.stringify(event.command);
226
+ if (cmdStr.length > 300) {
227
+ cmdStr = cmdStr.substring(0, 300) + "...";
228
+ }
229
+ logger.log.info({
230
+ module: "database.mongodb",
231
+ action: "query.executing",
232
+ message: `[${event.commandName}] ${cmdStr}`,
233
+ context: { command: event.command },
234
+ });
235
+ });
236
+ client.on("commandSucceeded", (event) => {
237
+ if (ignoredCommands.includes(event.commandName))
238
+ return;
239
+ logger.log.success({
240
+ module: "database.mongodb",
241
+ action: "query.executed",
242
+ message: `[${event.duration.toFixed(2)}ms] [${event.commandName}]`,
243
+ });
244
+ });
245
+ client.on("commandFailed", (event) => {
246
+ if (ignoredCommands.includes(event.commandName))
247
+ return;
248
+ logger.log.error({
249
+ module: "database.mongodb",
250
+ action: "query.error",
251
+ message: `[${event.duration.toFixed(2)}ms] [${event.commandName}]`,
252
+ context: { failure: event.failure },
253
+ });
254
+ });
255
+ }
256
+ this.emit("connected");
257
+ }
258
+ catch (error) {
259
+ await client.close().catch(() => undefined);
260
+ this.emit("disconnected");
261
+ logger.log.error("database.mongodb", "connection", `Failed to connect to database: ${error.message}`);
262
+ throw error;
263
+ }
264
+ }
265
+ /**
266
+ * Close the underlying MongoDB connection.
267
+ */
268
+ async disconnect() {
269
+ if (!this.client) {
270
+ return;
271
+ }
272
+ try {
273
+ await this.client.close();
274
+ }
275
+ finally {
276
+ this.connected = false;
277
+ this.emit("disconnected");
278
+ }
279
+ }
280
+ /**
281
+ * Subscribe to driver lifecycle events.
282
+ */
283
+ on(event, listener) {
284
+ this.events.on(event, listener);
285
+ }
286
+ /**
287
+ * Insert a single document into the given collection.
288
+ */
289
+ async insert(table, document, options) {
290
+ const collection = this.getDatabaseInstance().collection(table);
291
+ const mongoOptions = this.withSession(options);
292
+ const result = await collection.insertOne(document, mongoOptions);
293
+ return {
294
+ document: {
295
+ ...document,
296
+ _id: result.insertedId,
297
+ },
298
+ };
299
+ }
300
+ /**
301
+ * Insert multiple documents into the given collection.
302
+ */
303
+ async insertMany(table, documents, options) {
304
+ const collection = this.getDatabaseInstance().collection(table);
305
+ const mongoOptions = this.withSession(options);
306
+ const result = await collection.insertMany(documents, mongoOptions);
307
+ return documents.map((document, index) => {
308
+ const insertedId = result.insertedIds[index];
309
+ return {
310
+ document: {
311
+ ...document,
312
+ _id: insertedId,
313
+ },
314
+ };
315
+ });
316
+ }
317
+ /**
318
+ * Update a single document that matches the provided filter.
319
+ */
320
+ async update(table, filter, update, options) {
321
+ const collection = this.getDatabaseInstance().collection(table);
322
+ const mongoOptions = this.withSession(options);
323
+ const result = await collection.updateOne(filter, update, mongoOptions);
324
+ return { modifiedCount: result.modifiedCount };
325
+ }
326
+ /**
327
+ * Replace a single document that matches the provided filter.
328
+ */
329
+ async replace(table, filter, document, options) {
330
+ const collection = this.getDatabaseInstance().collection(table);
331
+ const result = await collection.findOneAndReplace(filter, document);
332
+ return result?.value;
333
+ }
334
+ /**
335
+ * Find one and update a single document that matches the provided filter and return the updated document
336
+ */
337
+ async findOneAndUpdate(table, filter, update, options) {
338
+ const collection = this.getDatabaseInstance().collection(table);
339
+ const mongoOptions = this.withSession(options);
340
+ const result = await collection.findOneAndUpdate(filter, update, {
341
+ returnDocument: "after",
342
+ ...mongoOptions,
343
+ });
344
+ return result;
345
+ }
346
+ /**
347
+ * Upsert (insert or update) a single document.
348
+ *
349
+ * Uses MongoDB's findOneAndUpdate with upsert option.
350
+ *
351
+ * @param table - Target collection name
352
+ * @param filter - Filter conditions to find existing document
353
+ * @param document - Document data to insert or update
354
+ * @param options - Optional upsert options
355
+ * @returns The upserted document
356
+ */
357
+ async upsert(table, filter, document, options) {
358
+ const collection = this.getDatabaseInstance().collection(table);
359
+ const mongoOptions = this.withSession(options);
360
+ // Use $set to update all fields from document
361
+ const update = { $set: document };
362
+ const result = await collection.findOneAndUpdate(filter, update, {
363
+ upsert: true,
364
+ returnDocument: "after",
365
+ ...mongoOptions,
366
+ });
367
+ return result;
368
+ }
369
+ /**
370
+ * Find one and delete a single document that matches the provided filter and return the deleted document.
371
+ *
372
+ * @param table - Target collection name
373
+ * @param filter - Filter conditions
374
+ * @param options - Optional delete options
375
+ * @returns The deleted document or null if not found
376
+ */
377
+ async findOneAndDelete(table, filter, options) {
378
+ const collection = this.getDatabaseInstance().collection(table);
379
+ const mongoOptions = this.withSession(options);
380
+ const result = await collection.findOneAndDelete(filter, mongoOptions || {});
381
+ return result;
382
+ }
383
+ /**
384
+ * Update multiple documents that match the provided filter.
385
+ */
386
+ async updateMany(table, filter, update, options) {
387
+ const collection = this.getDatabaseInstance().collection(table);
388
+ const mongoOptions = this.withSession(options);
389
+ const result = await collection.updateMany(filter, update, mongoOptions);
390
+ return { modifiedCount: result.modifiedCount };
391
+ }
392
+ /**
393
+ * Delete a single document that matches the provided filter.
394
+ */
395
+ async delete(table, filter = {}, options) {
396
+ const collection = this.getDatabaseInstance().collection(table);
397
+ const mongoOptions = this.withSession(options);
398
+ const result = await collection.deleteOne(filter, mongoOptions);
399
+ return result.deletedCount > 0 ? 1 : 0;
400
+ }
401
+ /**
402
+ * Delete documents that match the provided filter.
403
+ */
404
+ async deleteMany(table, filter = {}, options) {
405
+ const collection = this.getDatabaseInstance().collection(table);
406
+ const mongoOptions = this.withSession(options);
407
+ const result = await collection.deleteMany(filter, mongoOptions);
408
+ return result.deletedCount ?? 0;
409
+ }
410
+ /**
411
+ * Remove all records from a collection.
412
+ *
413
+ * This uses deleteMany with an empty filter to remove all documents.
414
+ * For very large collections, consider using the migration driver's
415
+ * dropTable + createTable approach for better performance.
416
+ */
417
+ async truncateTable(table, options) {
418
+ const collection = this.getDatabaseInstance().collection(table);
419
+ const mongoOptions = this.withSession(options);
420
+ const result = await collection.deleteMany({}, mongoOptions);
421
+ return result.deletedCount ?? 0;
422
+ }
423
+ /**
424
+ * Serialize the given data
425
+ */
426
+ serialize(data) {
427
+ for (const [key, value] of Object.entries(data)) {
428
+ if (value === undefined) {
429
+ continue; // Skip undefined values
430
+ }
431
+ if (value instanceof ObjectId) {
432
+ value.toString();
433
+ }
434
+ else if (value instanceof Date) {
435
+ value.toISOString();
436
+ }
437
+ else if (typeof value === "bigint") {
438
+ value.toString();
439
+ }
440
+ else ;
441
+ }
442
+ return data;
443
+ }
444
+ /**
445
+ * Get the dirty tracker for this driver.
446
+ */
447
+ getDirtyTracker(data) {
448
+ return new databaseDirtyTracker.DatabaseDirtyTracker(data);
449
+ }
450
+ /**
451
+ * Deserialize the given data
452
+ */
453
+ deserialize(data) {
454
+ if (data._id && typeof data._id === "string") {
455
+ data._id = new ObjectId(data._id);
456
+ }
457
+ for (const [key, value] of Object.entries(data)) {
458
+ // Only re-inflate strings — Mongo driver already returns Date objects from DB reads
459
+ if (typeof value === "string" && isValidDateValue.isValidDateValue(value)) {
460
+ data[key] = new Date(value);
461
+ }
462
+ }
463
+ return data;
464
+ }
465
+ /**
466
+ * Provide a Mongo-backed query builder instance for the given collection.
467
+ */
468
+ queryBuilder(table) {
469
+ return new mongodbQueryBuilder.MongoQueryBuilder(table, dataSourceRegistry.dataSourceRegistry.get());
470
+ }
471
+ /**
472
+ * Begin a MongoDB transaction, returning commit/rollback helpers.
473
+ */
474
+ async beginTransaction() {
475
+ const client = this.getClientInstance();
476
+ const session = client.startSession();
477
+ await session.startTransaction(this.transactionOptions);
478
+ databaseTransactionContext.databaseTransactionContext.enter({ session });
479
+ let finished = false;
480
+ const finalize = async (operation) => {
481
+ if (finished)
482
+ return;
483
+ try {
484
+ await operation();
485
+ }
486
+ finally {
487
+ finished = true;
488
+ databaseTransactionContext.databaseTransactionContext.exit();
489
+ await session.endSession().catch(() => undefined);
490
+ }
491
+ };
492
+ return {
493
+ context: session,
494
+ commit: async () => {
495
+ await finalize(async () => {
496
+ try {
497
+ await session.commitTransaction();
498
+ }
499
+ catch (error) {
500
+ await session.abortTransaction().catch(() => undefined);
501
+ throw error;
502
+ }
503
+ });
504
+ },
505
+ rollback: async () => {
506
+ await finalize(async () => {
507
+ await session.abortTransaction();
508
+ });
509
+ },
510
+ };
511
+ }
512
+ /**
513
+ * Execute a function within a transaction scope (recommended pattern).
514
+ *
515
+ * Automatically commits on success, rolls back on any error, and guarantees
516
+ * resource cleanup. This is the recommended way to use transactions.
517
+ *
518
+ * **MongoDB Requirements:**
519
+ * - Requires MongoDB 4.0+ with replica set or sharded cluster
520
+ * - Standalone MongoDB instances do not support transactions
521
+ *
522
+ * @param fn - Async function to execute within transaction
523
+ * @param options - Transaction options (read preference, write concern, etc.)
524
+ * @returns The return value of the callback function
525
+ * @throws {Error} If transaction fails, is explicitly rolled back, or replica set not configured
526
+ */
527
+ async transaction(fn, options) {
528
+ // Prevent nested transaction() calls
529
+ if (databaseTransactionContext.databaseTransactionContext.hasActiveTransaction()) {
530
+ throw new Error("Nested transaction() calls are not supported. " +
531
+ "Use beginTransaction() with savepoints for advanced transaction patterns.");
532
+ }
533
+ // Check if MongoDB is running as a replica set (required for transactions)
534
+ await this.ensureReplicaSetAvailable();
535
+ const client = this.getClientInstance();
536
+ const session = client.startSession();
537
+ try {
538
+ await session.startTransaction({
539
+ ...this.transactionOptions,
540
+ ...options,
541
+ });
542
+ // Set transaction context for queries within callback
543
+ databaseTransactionContext.databaseTransactionContext.enter({ session });
544
+ try {
545
+ // Create transaction context with rollback method
546
+ const ctx = {
547
+ rollback(reason) {
548
+ throw new transactionRollback_error.TransactionRollbackError(reason);
549
+ },
550
+ };
551
+ // Execute callback
552
+ const result = await fn(ctx);
553
+ // Auto-commit on success
554
+ await session.commitTransaction();
555
+ return result;
556
+ }
557
+ catch (error) {
558
+ // Auto-rollback on any error (including explicit rollback)
559
+ await session.abortTransaction().catch(() => undefined);
560
+ throw error;
561
+ }
562
+ finally {
563
+ // Guaranteed context cleanup
564
+ databaseTransactionContext.databaseTransactionContext.exit();
565
+ }
566
+ }
567
+ finally {
568
+ // Guaranteed session cleanup
569
+ await session.endSession().catch(() => undefined);
570
+ }
571
+ }
572
+ /**
573
+ * Execute atomic operations (typically $inc/$set style updates) against documents.
574
+ *
575
+ * Uses `updateMany` so callers can atomically modify any set of documents.
576
+ */
577
+ async atomic(table, filter, operations, options) {
578
+ const collection = this.getDatabaseInstance().collection(table);
579
+ const mongoOptions = this.withSession(options);
580
+ const result = await collection.updateMany(filter, operations, mongoOptions);
581
+ return { modifiedCount: result.modifiedCount };
582
+ }
583
+ /**
584
+ * Lazily create (and cache) the Mongo sync adapter.
585
+ * The adapter uses this driver instance to ensure all operations
586
+ * participate in active transactions via the session context.
587
+ */
588
+ syncAdapter() {
589
+ if (!this.syncAdapterInstance) {
590
+ this.syncAdapterInstance = new mongodbSyncAdapter.MongoSyncAdapter(this);
591
+ }
592
+ return this.syncAdapterInstance;
593
+ }
594
+ /**
595
+ * Lazily create (and cache) the Mongo migration driver.
596
+ * The migration driver handles schema operations like indexes, collections, etc.
597
+ */
598
+ migrationDriver() {
599
+ if (!this.migrationDriverInstance) {
600
+ this.migrationDriverInstance = new mongodbMigrationDriver.MongoMigrationDriver(this);
601
+ }
602
+ return this.migrationDriverInstance;
603
+ }
604
+ /**
605
+ * Expose the underlying Mongo client for advanced consumers.
606
+ */
607
+ getClient() {
608
+ return this.getClientInstance();
609
+ }
610
+ /**
611
+ * Retrieve the active Mongo client, throwing if the driver is disconnected.
612
+ */
613
+ getClientInstance() {
614
+ if (!this.client) {
615
+ throw new Error("Mongo driver is not connected.");
616
+ }
617
+ return this.client;
618
+ }
619
+ /**
620
+ * Retrieve the active Mongo database, throwing if the driver is disconnected.
621
+ * @private
622
+ */
623
+ getDatabaseInstance() {
624
+ if (!this.database) {
625
+ throw new Error("Mongo driver is not connected to a database.");
626
+ }
627
+ return this.database;
628
+ }
629
+ /**
630
+ * Resolve the Mongo connection string based on provided options.
631
+ */
632
+ resolveUri() {
633
+ if (this.config.uri) {
634
+ return this.config.uri;
635
+ }
636
+ const host = this.config.host ?? "localhost";
637
+ const port = this.config.port ?? 27017;
638
+ return `mongodb://${host}:${port}`;
639
+ }
640
+ /**
641
+ * Build the Mongo client options derived from the driver configuration.
642
+ */
643
+ buildClientOptions() {
644
+ const baseOptions = {
645
+ ...(this.config.clientOptions ?? {}),
646
+ };
647
+ if (this.config.logging) {
648
+ baseOptions.monitorCommands = true;
649
+ }
650
+ if (this.config.username && !baseOptions.auth) {
651
+ baseOptions.auth = {
652
+ username: this.config.username,
653
+ password: this.config.password,
654
+ };
655
+ }
656
+ if (this.config.authSource && !baseOptions.authSource) {
657
+ baseOptions.authSource = this.config.authSource;
658
+ }
659
+ return baseOptions;
660
+ }
661
+ /**
662
+ * Emit a driver lifecycle event.
663
+ */
664
+ emit(event, ...args) {
665
+ this.events.emit(event, ...args);
666
+ }
667
+ /**
668
+ * Ensure MongoDB is running as a replica set (required for transactions).
669
+ *
670
+ * @throws {Error} If MongoDB is running as a standalone instance
671
+ */
672
+ async ensureReplicaSetAvailable() {
673
+ try {
674
+ const admin = this.database.admin();
675
+ const status = await admin.serverStatus();
676
+ if (!status.repl) {
677
+ throw new Error("MongoDB transactions require a replica set or sharded cluster. " +
678
+ "Standalone MongoDB instances do not support transactions.\n\n" +
679
+ "For local development:\n" +
680
+ " - Run MongoDB with --replSet flag: mongod --replSet rs0\n" +
681
+ " - Or use Docker with replica set configuration\n" +
682
+ " - Or use MongoDB Atlas (cloud) which provides replica sets by default");
683
+ }
684
+ }
685
+ catch (error) {
686
+ if (error.message?.includes("replica set")) {
687
+ throw error;
688
+ }
689
+ throw new Error(`Failed to check MongoDB replica set status: ${error.message}`);
690
+ }
691
+ }
692
+ /**
693
+ * Attach the active transaction session (when available) to Mongo options.
694
+ */
695
+ withSession(options) {
696
+ const session = databaseTransactionContext.databaseTransactionContext.getSession();
697
+ if (!session) {
698
+ return options;
699
+ }
700
+ const baseOptions = options ? { ...options } : {};
701
+ baseOptions.session = session;
702
+ return baseOptions;
703
+ }
704
+ // ============================================================
705
+ // SQL Compatibility Operations (Not supported in MongoDB)
706
+ // ============================================================
707
+ /**
708
+ * Return a SQL serializer for this driver's dialect.
709
+ * Not supported for MongoDB.
710
+ */
711
+ getSQLSerializer() {
712
+ throw new Error("MongoDB driver does not support SQL serialization.");
713
+ }
714
+ /**
715
+ * Execute a raw SQL query.
716
+ * Not supported for MongoDB.
717
+ */
718
+ async query(_sql, _params) {
719
+ throw new Error("MongoDB driver does not support raw SQL queries.");
720
+ }
721
+ // ============================================================
722
+ // Database Lifecycle Operations
723
+ // ============================================================
724
+ /**
725
+ * Create a new database.
726
+ *
727
+ * In MongoDB, databases are created automatically when data is first written.
728
+ * This method creates an empty collection to ensure the database exists.
729
+ *
730
+ * @param name - Database name to create
731
+ * @returns true if created, false if already exists
732
+ */
733
+ async createDatabase(name) {
734
+ const client = this.getClientInstance();
735
+ // Check if database already exists
736
+ if (await this.databaseExists(name)) {
737
+ return false;
738
+ }
739
+ try {
740
+ // MongoDB creates databases on first write, so create a system collection
741
+ const db = client.db(name);
742
+ await db.createCollection("__init__");
743
+ // Drop the temp collection
744
+ await db.collection("__init__").drop();
745
+ logger.log.success("database", "lifecycle", `Created database ${name}`);
746
+ return true;
747
+ }
748
+ catch (error) {
749
+ logger.log.error("database", "lifecycle", `Failed to create database ${name}: ${error}`);
750
+ throw error;
751
+ }
752
+ }
753
+ /**
754
+ * Drop a database.
755
+ *
756
+ * @param name - Database name to drop
757
+ * @returns true if dropped, false if didn't exist
758
+ */
759
+ async dropDatabase(name) {
760
+ const client = this.getClientInstance();
761
+ // Check if database exists
762
+ if (!(await this.databaseExists(name))) {
763
+ return false;
764
+ }
765
+ try {
766
+ await client.db(name).dropDatabase();
767
+ logger.log.success("database", "lifecycle", `Dropped database ${name}`);
768
+ return true;
769
+ }
770
+ catch (error) {
771
+ logger.log.error("database", "lifecycle", `Failed to drop database ${name}: ${error}`);
772
+ throw error;
773
+ }
774
+ }
775
+ /**
776
+ * Check if a database exists.
777
+ *
778
+ * @param name - Database name to check
779
+ * @returns true if database exists
780
+ */
781
+ async databaseExists(name) {
782
+ const client = this.getClientInstance();
783
+ const result = await client.db("admin").admin().listDatabases();
784
+ return result.databases.some((db) => db.name === name);
785
+ }
786
+ /**
787
+ * List all databases.
788
+ *
789
+ * @returns Array of database names
790
+ */
791
+ async listDatabases() {
792
+ const client = this.getClientInstance();
793
+ const result = await client.db("admin").admin().listDatabases();
794
+ return result.databases
795
+ .map((db) => db.name)
796
+ .filter((name) => !["admin", "local", "config"].includes(name));
797
+ }
798
+ // ============================================================
799
+ // Table/Collection Management Operations
800
+ // ============================================================
801
+ /**
802
+ * Drop a collection.
803
+ *
804
+ * @param name - Collection name to drop
805
+ * @throws Error if collection doesn't exist
806
+ */
807
+ async dropTable(name) {
808
+ const db = this.getDatabaseInstance();
809
+ await db.collection(name).drop();
810
+ logger.log.success("database", "collection", `Dropped collection ${name}`);
811
+ }
812
+ /**
813
+ * Drop a collection if it exists.
814
+ *
815
+ * @param name - Collection name to drop
816
+ */
817
+ async dropTableIfExists(name) {
818
+ if (await this.blueprint.tableExists(name)) {
819
+ await this.dropTable(name);
820
+ }
821
+ }
822
+ /**
823
+ * Drop all collections in the current database.
824
+ *
825
+ * Useful for `migrate:fresh` command.
826
+ */
827
+ async dropAllTables() {
828
+ const collections = await this.blueprint.listTables();
829
+ if (collections.length === 0) {
830
+ return;
831
+ }
832
+ const db = this.getDatabaseInstance();
833
+ for (const collection of collections) {
834
+ await db.collection(collection).drop();
835
+ }
836
+ logger.log.success("database", "collection", `Dropped ${collections.length} collections`);
837
+ }
838
+ }exports.MongoDbDriver=MongoDbDriver;exports.isMongoDBDriverLoaded=isMongoDBDriverLoaded;//# sourceMappingURL=mongodb-driver.js.map