@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,922 @@
1
+ import { GenericObject } from "@mongez/reinforcements";
2
+ import type { Collection } from "mongodb";
3
+ import type { CursorPaginationOptions, CursorPaginationResult, GroupByInput, HavingInput, JoinOptions, OrderDirection, PaginationOptions, PaginationResult, QueryBuilderContract, RawExpression, WhereCallback, WhereObject, WhereOperator } from "../../contracts";
4
+ import { type DataSource } from "../../data-source/data-source";
5
+ import { MongoQueryOperations } from "./mongo-query-operations";
6
+ import { MongoQueryParser } from "./mongo-query-parser";
7
+ import type { Operation } from "./types";
8
+ /**
9
+ * MongoDB-specific query builder implementation using aggregation pipeline.
10
+ */
11
+ export declare class MongoQueryBuilder<T = unknown> implements QueryBuilderContract<T> {
12
+ readonly table: string;
13
+ /**
14
+ * Ordered list of operations to be converted to MongoDB aggregation pipeline.
15
+ * Public to allow parser access.
16
+ */
17
+ operations: Operation[];
18
+ /**
19
+ * Data source instance
20
+ */
21
+ readonly dataSource: DataSource;
22
+ /**
23
+ * Lazy-loaded operations helper for constructing pipeline operations.
24
+ */
25
+ protected _operationsHelper?: MongoQueryOperations;
26
+ hydrateCallback?: (data: any, index: number) => any;
27
+ private fetchingCallback?;
28
+ private hydratingCallback?;
29
+ private fetchedCallback?;
30
+ pendingGlobalScopes?: Map<string, any>;
31
+ availableLocalScopes?: Map<string, any>;
32
+ disabledGlobalScopes: Set<string>;
33
+ scopesApplied: boolean;
34
+ /**
35
+ * Create a new query builder for the given collection.
36
+ * @param collection - The MongoDB collection to query
37
+ */
38
+ constructor(table: string, dataSource?: DataSource);
39
+ /**
40
+ * Gets the operations helper instance, creating it if needed.
41
+ * @returns The operations helper instance
42
+ */
43
+ protected get operationsHelper(): MongoQueryOperations;
44
+ /**
45
+ * Get collection instance
46
+ */
47
+ get collection(): Collection;
48
+ /**
49
+ * Add hydrate callback function
50
+ */
51
+ hydrate(callback: (data: any, index: number) => any): this;
52
+ /**
53
+ * Register a callback to be invoked before query execution
54
+ * @returns Unsubscribe function to remove the callback
55
+ */
56
+ onFetching(callback: (query: this) => void | Promise<void>): () => void;
57
+ /**
58
+ * Register a callback to be invoked after records are fetched but before hydration
59
+ * @returns Unsubscribe function to remove the callback
60
+ */
61
+ onHydrating(callback: (records: any[], context: any) => void | Promise<void>): () => void;
62
+ /**
63
+ * Register a callback to be invoked after records are fetched and hydrated
64
+ * @returns Unsubscribe function to remove the callback
65
+ */
66
+ onFetched(callback: (records: any[], context: any) => void | Promise<void>): () => void;
67
+ /**
68
+ * Disable one or more global scopes for this query
69
+ */
70
+ withoutGlobalScope(...scopeNames: string[]): this;
71
+ /**
72
+ * Disable all global scopes for this query
73
+ */
74
+ withoutGlobalScopes(): this;
75
+ /**
76
+ * Apply a local scope to this query
77
+ */
78
+ scope(scopeName: string): this;
79
+ /**
80
+ * Apply pending global scopes before query execution
81
+ */
82
+ private applyPendingScopes;
83
+ /**
84
+ * Adds a WHERE clause to filter documents. Supports equality, operators, objects, or callbacks.
85
+ * @param field - Field name, or conditions object, or callback
86
+ * @param operator - Comparison operator
87
+ * @param value - Value to compare
88
+ */
89
+ where(field: string, value: unknown): this;
90
+ where(field: string, operator: WhereOperator, value: unknown): this;
91
+ where(conditions: WhereObject): this;
92
+ where(callback: WhereCallback<T>): this;
93
+ /**
94
+ * Adds an OR WHERE clause. Works like where() but uses OR logic.
95
+ * @param field - Field name, or conditions object, or callback
96
+ * @param operator - Comparison operator
97
+ * @param value - Value to compare
98
+ */
99
+ orWhere(field: string, value: unknown): this;
100
+ orWhere(field: string, operator: WhereOperator, value: unknown): this;
101
+ orWhere(conditions: WhereObject): this;
102
+ orWhere(callback: WhereCallback<T>): this;
103
+ /**
104
+ * Adds a raw WHERE clause using MongoDB's native query syntax.
105
+ * @param expression - Raw MongoDB expression
106
+ * @param bindings - Optional parameter bindings for string expressions
107
+ */
108
+ whereRaw(expression: RawExpression, bindings?: unknown[]): this;
109
+ /**
110
+ * Adds a raw OR WHERE clause using MongoDB's native query syntax.
111
+ * @param expression - Raw MongoDB expression
112
+ * @param bindings - Optional parameter bindings
113
+ */
114
+ orWhereRaw(expression: RawExpression, bindings?: unknown[]): this;
115
+ /**
116
+ * Adds a WHERE clause comparing two columns/fields directly.
117
+ * @param first - The first field name
118
+ * @param operator - The comparison operator
119
+ * @param second - The second field name
120
+ */
121
+ whereColumn(first: string, operator: WhereOperator, second: string): this;
122
+ /**
123
+ * Adds an OR WHERE clause comparing two columns/fields directly.
124
+ * @param first - The first field name
125
+ * @param operator - The comparison operator
126
+ * @param second - The second field name
127
+ */
128
+ orWhereColumn(first: string, operator: WhereOperator, second: string): this;
129
+ /**
130
+ * Adds multiple column comparison clauses at once.
131
+ * @param comparisons - Array of tuples [leftField, operator, rightField]
132
+ */
133
+ whereColumns(comparisons: Array<[left: string, operator: WhereOperator, right: string]>): this;
134
+ /**
135
+ * Filters documents where a field's value falls between two other fields.
136
+ * @param field - The field to check
137
+ * @param lowerColumn - The field defining the lower bound
138
+ * @param upperColumn - The field defining the upper bound
139
+ */
140
+ whereBetweenColumns(field: string, lowerColumn: string, upperColumn: string): this;
141
+ /**
142
+ * Filters documents where a date field matches the given date (ignoring time).
143
+ * @param field - The date field name
144
+ * @param value - The date to match
145
+ */
146
+ whereDate(field: string, value: Date | string): this;
147
+ /**
148
+ * Alias for `whereDate()`. Filters by exact date match (ignoring time).
149
+ * @param field - The date field name
150
+ * @param value - The date to match
151
+ */
152
+ whereDateEquals(field: string, value: Date | string): this;
153
+ /**
154
+ * Filters documents where a date field is before the given date.
155
+ * @param field - The date field name
156
+ * @param value - The cutoff date
157
+ */
158
+ whereDateBefore(field: string, value: Date | string): this;
159
+ /**
160
+ * Filters documents where a date field is after the given date.
161
+ * @param field - The date field name
162
+ * @param value - The cutoff date
163
+ */
164
+ whereDateAfter(field: string, value: Date | string): this;
165
+ /**
166
+ * Filters documents where a time field matches the given time (HH:MM:SS format).
167
+ * @param field - The time/datetime field name
168
+ * @param value - The time string in HH:MM:SS format
169
+ */
170
+ whereTime(field: string, value: string): this;
171
+ /**
172
+ * Filters documents where the day of the month matches the given value (1-31).
173
+ * @param field - The date field name
174
+ * @param value - The day of the month
175
+ */
176
+ whereDay(field: string, value: number): this;
177
+ /**
178
+ * Filters documents where the month matches the given value (1-12).
179
+ * @param field - The date field name
180
+ * @param value - The month number
181
+ */
182
+ whereMonth(field: string, value: number): this;
183
+ /**
184
+ * Filters documents where the year matches the given value.
185
+ * @param field - The date field name
186
+ * @param value - The year
187
+ */
188
+ whereYear(field: string, value: number): this;
189
+ /**
190
+ * Filters documents where a JSON field contains the specified value.
191
+ * @param path - The JSON path to check
192
+ * @param value - The value to search for
193
+ */
194
+ whereJsonContains(path: string, value: unknown): this;
195
+ /**
196
+ * Filters documents where a JSON field does NOT contain the specified value.
197
+ * @param path - The JSON path to check
198
+ * @param value - The value to exclude
199
+ */
200
+ whereJsonDoesntContain(path: string, value: unknown): this;
201
+ /**
202
+ * Filters documents where a JSON field contains a specific key.
203
+ * @param path - The JSON path to check for key existence
204
+ */
205
+ whereJsonContainsKey(path: string): this;
206
+ /**
207
+ * Filters documents where a JSON array or string has a specific length.
208
+ * @param path - The JSON path to check
209
+ * @param operator - The comparison operator
210
+ * @param value - The length value to compare against
211
+ */
212
+ whereJsonLength(path: string, operator: WhereOperator, value: number): this;
213
+ /**
214
+ * Filters documents where a JSON field is an array.
215
+ * @param path - The JSON path to check
216
+ */
217
+ whereJsonIsArray(path: string): this;
218
+ /**
219
+ * Filters documents where a JSON field is an object.
220
+ * @param path - The JSON path to check
221
+ */
222
+ whereJsonIsObject(path: string): this;
223
+ /**
224
+ * Filters documents where an array field has a specific length.
225
+ * @param field - The array field name
226
+ * @param operator - The comparison operator
227
+ * @param value - The length value to compare against
228
+ */
229
+ whereArrayLength(field: string, operator: WhereOperator, value: number): this;
230
+ /**
231
+ * Filters documents by ID (convenience method for `where("id", value)`).
232
+ * @param value - The ID value to match
233
+ */
234
+ whereId(value: string | number): this;
235
+ /**
236
+ * Filters documents by multiple IDs (convenience method for `whereIn("id", values)`).
237
+ * @param values - Array of ID values to match
238
+ */
239
+ whereIds(values: Array<string | number>): this;
240
+ /**
241
+ * Filters documents by UUID (convenience method for `where("uuid", value)`).
242
+ * @param value - The UUID string to match
243
+ */
244
+ whereUuid(value: string): this;
245
+ /**
246
+ * Filters documents by ULID (convenience method for `where("ulid", value)`).
247
+ * @param value - The ULID string to match
248
+ */
249
+ whereUlid(value: string): this;
250
+ /**
251
+ * Performs full-text search on one or more fields.
252
+ * @param fields - Field name or array of field names to search
253
+ * @param query - The search query string
254
+ */
255
+ whereFullText(fields: string | string[], query: string): this;
256
+ /**
257
+ * Performs full-text search with OR logic.
258
+ * @param fields - Field name or array of field names to search
259
+ * @param query - The search query string
260
+ */
261
+ orWhereFullText(fields: string | string[], query: string): this;
262
+ /**
263
+ * Alias for `whereFullText()` with a single field.
264
+ * @param field - The field name to search
265
+ * @param query - The search query string
266
+ */
267
+ whereSearch(field: string, query: string): this;
268
+ /**
269
+ * Negates a set of conditions using a callback.
270
+ * @param callback - Callback function defining conditions to negate
271
+ */
272
+ whereNot(callback: WhereCallback<T>): this;
273
+ /**
274
+ * Negates a set of conditions with OR logic.
275
+ * @param callback - Callback function defining conditions to negate
276
+ */
277
+ orWhereNot(callback: WhereCallback<T>): this;
278
+ /**
279
+ * Filters documents where a field's value matches any value in the given array.
280
+ * @param field - The field name to check
281
+ * @param values - Array of values to match against
282
+ */
283
+ whereIn(field: string, values: unknown[]): this;
284
+ /**
285
+ * Filters documents where a field's value does NOT match any value in the array.
286
+ * @param field - The field name to check
287
+ * @param values - Array of values to exclude
288
+ */
289
+ whereNotIn(field: string, values: unknown[]): this;
290
+ /**
291
+ * Filters documents where a field's value is null or undefined.
292
+ * @param field - The field name to check
293
+ */
294
+ whereNull(field: string): this;
295
+ /**
296
+ * Filters documents where a field's value is NOT null or undefined.
297
+ * @param field - The field name to check
298
+ */
299
+ whereNotNull(field: string): this;
300
+ /**
301
+ * Filters documents where a field's value falls within the given range (inclusive).
302
+ * @param field - The field name to check
303
+ * @param range - Tuple of [min, max] values
304
+ */
305
+ whereBetween(field: string, range: [unknown, unknown]): this;
306
+ /**
307
+ * Filters documents where a field's value is NOT within the given range.
308
+ * @param field - The field name to check
309
+ * @param range - Tuple of [min, max] values to exclude
310
+ */
311
+ whereNotBetween(field: string, range: [unknown, unknown]): this;
312
+ /**
313
+ * Filters documents where a field matches the given pattern (case-insensitive).
314
+ * @param field - The field name to search
315
+ * @param pattern - The pattern to match
316
+ */
317
+ whereLike(field: string, pattern: RegExp | string): this;
318
+ /**
319
+ * Filters documents where a field does NOT match the given pattern.
320
+ * @param field - The field name to search
321
+ * @param pattern - The pattern to exclude
322
+ */
323
+ whereNotLike(field: string, pattern: RegExp | string): this;
324
+ /**
325
+ * Filters documents where a field's value starts with the given prefix.
326
+ * @param field - The field name to check
327
+ * @param value - The prefix to match
328
+ */
329
+ whereStartsWith(field: string, value: string | number): this;
330
+ /**
331
+ * Filters documents where a field's value does NOT start with the given prefix.
332
+ * @param field - The field name to check
333
+ * @param value - The prefix to exclude
334
+ */
335
+ whereNotStartsWith(field: string, value: string | number): this;
336
+ /**
337
+ * Filters documents where a field's value ends with the given suffix.
338
+ * @param field - The field name to check
339
+ * @param value - The suffix to match
340
+ */
341
+ whereEndsWith(field: string, value: string | number): this;
342
+ /**
343
+ * Filters documents where a field's value does NOT end with the given suffix.
344
+ * @param field - The field name to check
345
+ * @param value - The suffix to exclude
346
+ */
347
+ whereNotEndsWith(field: string, value: string | number): this;
348
+ /**
349
+ * Filters documents where a date field falls within the given date range.
350
+ * @param field - The date field name
351
+ * @param range - Tuple of [startDate, endDate]
352
+ */
353
+ whereDateBetween(field: string, range: [Date, Date]): this;
354
+ /**
355
+ * Filters documents where a date field is NOT within the given date range.
356
+ * @param field - The date field name
357
+ * @param range - Tuple of [startDate, endDate] to exclude
358
+ */
359
+ whereDateNotBetween(field: string, range: [Date, Date]): this;
360
+ /**
361
+ * Filters documents where a field exists (has any value including null).
362
+ * @param field - The field name to check for existence
363
+ * @param callback - Optional callback for subquery existence
364
+ */
365
+ whereExists(field: string): this;
366
+ whereExists(callback: WhereCallback<T>): this;
367
+ /**
368
+ * Filters documents where a field does NOT exist in the document.
369
+ * @param field - The field name to check for absence
370
+ * @param callback - Optional callback for subquery non-existence
371
+ */
372
+ whereNotExists(field: string): this;
373
+ whereNotExists(callback: WhereCallback<T>): this;
374
+ /**
375
+ * Filters documents where an array field has a specific size.
376
+ * @param field - The array field name
377
+ * @param size - The exact size to match
378
+ * @param operator - Optional comparison operator
379
+ */
380
+ whereSize(field: string, size: number): this;
381
+ whereSize(field: string, operator: ">" | ">=" | "=" | "<" | "<=", size: number): this;
382
+ /**
383
+ * Performs a full-text search on the specified fields.
384
+ * @param query - The search query string
385
+ * @param filters - Optional additional filter conditions
386
+ */
387
+ textSearch(query: string, filters?: WhereObject): this;
388
+ /**
389
+ * Filters documents where an array field contains the given value.
390
+ * @param field - The array field name
391
+ * @param value - The value to search for in the array
392
+ * @param key - Optional key to check within array objects
393
+ */
394
+ whereArrayContains(field: string, value: unknown, key?: string): this;
395
+ /**
396
+ * Filters documents where an array field does NOT contain the given value.
397
+ * @param field - The array field name
398
+ * @param value - The value to exclude from the array
399
+ * @param key - Optional key to check within array objects
400
+ */
401
+ whereArrayNotContains(field: string, value: unknown, key?: string): this;
402
+ /**
403
+ * Filters documents where an array field contains the value OR is empty.
404
+ * @param field - The array field name
405
+ * @param value - The value to search for
406
+ * @param key - Optional key to check within array objects
407
+ */
408
+ whereArrayHasOrEmpty(field: string, value: unknown, key?: string): this;
409
+ /**
410
+ * Filters documents where an array field does NOT contain the value AND is not empty.
411
+ * @param field - The array field name
412
+ * @param value - The value to exclude
413
+ * @param key - Optional key to check within array objects
414
+ */
415
+ whereArrayNotHaveOrEmpty(field: string, value: unknown, key?: string): this;
416
+ /**
417
+ * Internal helper for processing where clause arguments.
418
+ * @param prefix - The operation prefix
419
+ * @param args - The arguments passed to where/orWhere
420
+ */
421
+ protected addWhereClause(prefix: "where" | "orWhere", args: any[]): void;
422
+ /**
423
+ * Internal helper for adding raw where clauses.
424
+ * @param type - The operation type
425
+ * @param expression - The raw expression in MongoDB query language
426
+ * @param bindings - Optional bindings for the expression
427
+ */
428
+ protected addRawWhere(type: "whereRaw" | "orWhereRaw", expression: RawExpression, bindings?: unknown[]): this;
429
+ /**
430
+ * Normalizes select field arguments into a structured format.
431
+ * @param args - The arguments to normalize
432
+ * @returns Normalized selection object with fields and aliases
433
+ */
434
+ protected normalizeSelectFields(args: any[]): {
435
+ fields?: string[];
436
+ projection?: Record<string, unknown>;
437
+ };
438
+ /**
439
+ * Specifies which fields to include in the query results.
440
+ * Supports arrays, multiple args, or object with aliases/inclusion/exclusion.
441
+ * @param fields - Field names, array, or projection object
442
+ */
443
+ select(fields: string[]): this;
444
+ select(fields: Record<string, 0 | 1 | boolean | string>): this;
445
+ select(...fields: string[]): this;
446
+ /**
447
+ * Selects a field with an alias.
448
+ * @param field - The field to select
449
+ * @param alias - The alias name for the field
450
+ * @returns The query builder instance
451
+ */
452
+ selectAs(field: string, alias: string): this;
453
+ /**
454
+ * Adds a computed field using a raw MongoDB expression.
455
+ * @param expression - The raw MongoDB expression
456
+ * @param bindings - Optional parameter bindings for string expressions
457
+ */
458
+ selectRaw(expression: RawExpression, bindings?: unknown[]): this;
459
+ /**
460
+ * Adds multiple computed fields using raw MongoDB expressions.
461
+ * @param definitions - Array of field definitions with alias, expression, and optional bindings
462
+ */
463
+ selectRawMany(definitions: Array<{
464
+ alias: string;
465
+ expression: RawExpression;
466
+ bindings?: unknown[];
467
+ }>): this;
468
+ /**
469
+ * Adds a subquery as a computed field.
470
+ * @param expression - The subquery expression
471
+ * @param alias - The alias for the computed field
472
+ */
473
+ selectSub(expression: RawExpression, alias: string): this;
474
+ /**
475
+ * Adds an additional subquery field to existing selections.
476
+ * @param expression - The subquery expression
477
+ * @param alias - The alias for the computed field
478
+ */
479
+ addSelectSub(expression: RawExpression, alias: string): this;
480
+ /**
481
+ * Adds an aggregate value as a computed field.
482
+ * @param field - The field to aggregate
483
+ * @param aggregate - The aggregate function to apply
484
+ * @param alias - The alias for the computed field
485
+ */
486
+ selectAggregate(field: string, aggregate: "sum" | "avg" | "min" | "max" | "count" | "first" | "last", alias: string): this;
487
+ /**
488
+ * Adds a boolean field indicating whether a related document exists.
489
+ * @param field - The field to check for existence
490
+ * @param alias - The alias for the boolean field
491
+ */
492
+ selectExists(field: string, alias: string): this;
493
+ /**
494
+ * Adds a count field for a related collection.
495
+ * @param field - The field to count
496
+ * @param alias - The alias for the count field
497
+ */
498
+ selectCount(field: string, alias: string): this;
499
+ /**
500
+ * Adds a CASE-like conditional field using multiple conditions.
501
+ * @param cases - Array of when/then pairs
502
+ * @param otherwise - Default value if no conditions match
503
+ * @param alias - The alias for the computed field
504
+ */
505
+ selectCase(cases: Array<{
506
+ when: RawExpression;
507
+ then: RawExpression | unknown;
508
+ }>, otherwise: RawExpression | unknown, alias: string): this;
509
+ /**
510
+ * Adds a simple conditional field (if/else).
511
+ * @param condition - The condition to evaluate
512
+ * @param thenValue - Value if condition is true
513
+ * @param elseValue - Value if condition is false
514
+ * @param alias - The alias for the computed field
515
+ */
516
+ selectWhen(condition: RawExpression, thenValue: RawExpression | unknown, elseValue: RawExpression | unknown, alias: string): this;
517
+ /**
518
+ * Allows direct manipulation of the MongoDB projection object.
519
+ * @param callback - Function that receives and modifies the projection object
520
+ */
521
+ selectDriverProjection(callback: (projection: Record<string, unknown>) => void): this;
522
+ /**
523
+ * Extracts a JSON field from a document.
524
+ * @param path - The JSON path to extract
525
+ * @param alias - Optional alias for the extracted field
526
+ */
527
+ selectJson(path: string, alias?: string): this;
528
+ /**
529
+ * Extracts a JSON field using a raw MongoDB expression.
530
+ * @param path - The JSON path
531
+ * @param expression - The raw expression for extraction
532
+ * @param alias - The alias for the extracted field
533
+ */
534
+ selectJsonRaw(path: string, expression: RawExpression, alias: string): this;
535
+ /**
536
+ * Excludes a JSON path from the results.
537
+ * @param path - The JSON path to exclude
538
+ */
539
+ deselectJson(path: string): this;
540
+ /**
541
+ * Concatenates multiple fields into a single string field.
542
+ * @param fields - Array of fields or expressions to concatenate
543
+ * @param alias - The alias for the concatenated field
544
+ */
545
+ selectConcat(fields: Array<string | RawExpression>, alias: string): this;
546
+ /**
547
+ * Returns the first non-null value from a list of fields.
548
+ * @param fields - Array of fields to check
549
+ * @param alias - The alias for the coalesced field
550
+ */
551
+ selectCoalesce(fields: Array<string | RawExpression>, alias: string): this;
552
+ /**
553
+ * Adds window function operations to the query.
554
+ * @param spec - The window function specification
555
+ */
556
+ selectWindow(spec: RawExpression): this;
557
+ /**
558
+ * Excludes specific fields from the query results.
559
+ * @param fields - Field names to exclude
560
+ */
561
+ deselect(fields: string[]): this;
562
+ deselect(...fields: Array<string | string[]>): this;
563
+ /**
564
+ * Returns only distinct values for the specified fields.
565
+ * @param fields - Optional field names to use for distinctness
566
+ */
567
+ distinctValues(fields?: string | string[]): this;
568
+ /**
569
+ * Adds additional fields to an existing selection.
570
+ * @param fields - Additional field names to include
571
+ */
572
+ addSelect(fields: string[]): this;
573
+ addSelect(...fields: Array<string | string[]>): this;
574
+ /**
575
+ * Removes all field selection restrictions.
576
+ */
577
+ clearSelect(): this;
578
+ /**
579
+ * Alias for `clearSelect()`. Removes all field restrictions.
580
+ */
581
+ selectAll(): this;
582
+ /**
583
+ * Alias for `clearSelect()`. Resets to default field selection.
584
+ */
585
+ selectDefault(): this;
586
+ /**
587
+ * Orders the query results by a specific field or multiple fields.
588
+ *
589
+ * @param field - The field name to sort by, or an object with multiple fields
590
+ * @param direction - The sort direction (only used when field is a string)
591
+ *
592
+ * @example
593
+ * ```typescript
594
+ * // Single field
595
+ * query.orderBy("createdAt", "desc");
596
+ *
597
+ * // Multiple fields
598
+ * query.orderBy({ id: "asc", age: "desc", createdAt: "desc" });
599
+ * ```
600
+ */
601
+ orderBy(field: string, direction?: OrderDirection): this;
602
+ orderBy(fields: Record<string, OrderDirection>): this;
603
+ /**
604
+ * Orders the query results by a field in descending order.
605
+ * @param field - The field name to sort by
606
+ */
607
+ orderByDesc(field: string): this;
608
+ /**
609
+ * Orders the query results using a raw MongoDB sort expression.
610
+ * @param expression - The raw MongoDB sort expression
611
+ * @param bindings - Optional parameter bindings
612
+ */
613
+ orderByRaw(expression: RawExpression, bindings?: unknown[]): this;
614
+ /**
615
+ * Orders the query results randomly.
616
+ */
617
+ orderByRandom(limit?: number): this;
618
+ /**
619
+ * Orders results by a date field in descending order (newest first).
620
+ * @param column - The date column to sort by
621
+ */
622
+ latest(column?: string): Promise<T[]>;
623
+ /**
624
+ * Orders results by a date field in ascending order (oldest first).
625
+ * @param column - The date column to sort by
626
+ */
627
+ oldest(column?: string): this;
628
+ /**
629
+ * Limits the number of documents returned by the query.
630
+ * @param value - The maximum number of documents to return
631
+ */
632
+ limit(value: number): this;
633
+ /**
634
+ * Skips a specified number of documents in the query results.
635
+ * @param value - The number of documents to skip
636
+ */
637
+ skip(value: number): this;
638
+ /**
639
+ * Alias for `skip()`. Skips a specified number of documents.
640
+ * @param value - The number of documents to skip
641
+ */
642
+ offset(value: number): this;
643
+ /**
644
+ * Alias for `limit()`. Limits the number of documents returned.
645
+ * @param value - The maximum number of documents to return
646
+ */
647
+ take(value: number): this;
648
+ /**
649
+ * Applies cursor-based filtering for pagination.
650
+ * @param after - Cursor value for forward pagination
651
+ * @param before - Cursor value for backward pagination
652
+ */
653
+ cursor(after?: unknown, before?: unknown): this;
654
+ /**
655
+ * Groups documents by one or more fields.
656
+ *
657
+ * @param fields - Field(s) to group by
658
+ * @param aggregates - Optional aggregate operations to perform
659
+ *
660
+ * @example
661
+ * ```typescript
662
+ * import { $agg } from '@warlock.js/cascade';
663
+ *
664
+ * // Simple grouping
665
+ * query.groupBy("type");
666
+ *
667
+ * // Grouping with aggregates
668
+ * query.groupBy("type", {
669
+ * count: $agg.count(),
670
+ * total: $agg.sum("duration")
671
+ * });
672
+ * ```
673
+ */
674
+ groupBy(fields: GroupByInput): this;
675
+ groupBy(fields: GroupByInput, aggregates: Record<string, RawExpression>): this;
676
+ /**
677
+ * Groups documents using a raw MongoDB expression.
678
+ * @param expression - The raw grouping expression
679
+ * @param bindings - Optional parameter bindings
680
+ */
681
+ groupByRaw(expression: RawExpression, bindings?: unknown[]): this;
682
+ /**
683
+ * Filters grouped results based on aggregate conditions.
684
+ * @param field - The aggregate field to filter on
685
+ * @param value - The value to compare against
686
+ * @param operator - The comparison operator
687
+ * @param condition - A condition object for complex filters
688
+ */
689
+ having(field: string, value: unknown): this;
690
+ having(field: string, operator: WhereOperator, value: unknown): this;
691
+ having(condition: HavingInput): this;
692
+ /**
693
+ * Filters grouped results using a raw MongoDB expression.
694
+ * @param expression - The raw having expression
695
+ * @param bindings - Optional parameter bindings
696
+ */
697
+ havingRaw(expression: RawExpression, bindings?: unknown[]): this;
698
+ /**
699
+ * Performs a left outer join with another collection.
700
+ * @param options - Join configuration including table, fields, and optional pipeline
701
+ */
702
+ join(options: JoinOptions): this;
703
+ /**
704
+ * Allows direct manipulation of the native MongoDB query.
705
+ * @param builder - Function that receives and modifies the native query
706
+ */
707
+ raw(builder: (native: unknown) => unknown): this;
708
+ /**
709
+ * Extends the query builder with driver-specific functionality.
710
+ * @param extension - The extension name
711
+ * @param _args - Extension-specific arguments
712
+ * @returns The extension's return value
713
+ */
714
+ extend<R>(extension: string, ..._args: unknown[]): R;
715
+ /**
716
+ * Creates a deep copy of the query builder.
717
+ * @returns A new query builder instance with copied operations
718
+ */
719
+ clone(): this;
720
+ /**
721
+ * Executes a callback with the query builder without breaking the chain.
722
+ * @param callback - Function to execute with the builder
723
+ */
724
+ tap(callback: (builder: this) => void): this;
725
+ /**
726
+ * Conditionally applies query modifications based on a condition.
727
+ * @param condition - The condition to evaluate
728
+ * @param callback - Function to execute if condition is true
729
+ * @param otherwise - Optional function to execute if condition is false
730
+ *
731
+ * @example
732
+ * query.when(searchTerm, (q, term) => q.whereLike('name', term))
733
+ */
734
+ when<V>(condition: V | boolean, callback: (builder: this, value: V) => void, otherwise?: (builder: this) => void): this;
735
+ /**
736
+ * Executes the query and returns all matching documents.
737
+ * @returns an array of matching documents
738
+ */
739
+ get<Output = T>(): Promise<Output[]>;
740
+ /**
741
+ * Execute the query and get first result
742
+ * This is different than `first` as first adds a `limit = 1` to the pipeline
743
+ */
744
+ getFirst<Output = T>(): Promise<Output | null>;
745
+ /**
746
+ * Executes the query and returns the first matching document.
747
+ * @returns the first document or null
748
+ */
749
+ first<Output = T>(): Promise<Output | null>;
750
+ /**
751
+ * Executes the query and returns the first matching document, throwing if none found.
752
+ * @returns the first document
753
+ */
754
+ firstOrFail<Output = T>(): Promise<Output>;
755
+ /**
756
+ * Configures the query to retrieve the last matching document.
757
+ */
758
+ last<Output = T>(field?: string): Promise<Output | null>;
759
+ /**
760
+ * Counts the number of documents matching the query.
761
+ * @returns the count of matching documents
762
+ */
763
+ count(): Promise<number>;
764
+ /**
765
+ * Calculates the sum of a numeric field across matching documents.
766
+ * @param field - The numeric field to sum
767
+ * @returns the sum value
768
+ */
769
+ sum(field: string): Promise<number>;
770
+ /**
771
+ * Calculates the average value of a numeric field across matching documents.
772
+ * @param field - The numeric field to average
773
+ * @returns the average value
774
+ */
775
+ avg(field: string): Promise<number>;
776
+ /**
777
+ * Finds the minimum value of a field across matching documents.
778
+ * @param field - The field to find the minimum of
779
+ * @returns the minimum value
780
+ */
781
+ min(field: string): Promise<number>;
782
+ /**
783
+ * Finds the maximum value of a field across matching documents.
784
+ * @param field - The field to find the maximum of
785
+ * @returns the maximum value
786
+ */
787
+ max(field: string): Promise<number>;
788
+ /**
789
+ * Returns an array of distinct values for a field, respecting query filters.
790
+ * @param field - The field to get distinct values from
791
+ * @returns an array of distinct values
792
+ */
793
+ distinct<T = unknown>(field: string, ignoreNull?: boolean): Promise<T[]>;
794
+ /**
795
+ * Count distinct values for a field, respecting query filters.
796
+ * @param field - The field to count distinct values for
797
+ * @returns the count of distinct values
798
+ */
799
+ countDistinct(field: string, ignoreNull?: boolean): Promise<number>;
800
+ /**
801
+ * Extracts a single field value from each matching document.
802
+ * @param field - The field to extract
803
+ * @returns an array of field values
804
+ */
805
+ pluck<T = unknown>(field: string): Promise<T[]>;
806
+ /**
807
+ * Gets the value of a single field from the first matching document.
808
+ * @param field - The field to extract
809
+ * @returns the field value or null
810
+ */
811
+ value<T = unknown>(field: string): Promise<T | null>;
812
+ /**
813
+ * Checks if any documents match the query.
814
+ * @param filter - Optional filter to apply to the query
815
+ * @returns true if documents exist, false otherwise
816
+ */
817
+ exists(filter?: GenericObject): Promise<boolean>;
818
+ /**
819
+ * Checks if no documents match the query.
820
+ * @param filter - Optional filter to apply to the query
821
+ * @returns true if no documents exist, false otherwise
822
+ */
823
+ notExists(filter?: GenericObject): Promise<boolean>;
824
+ /**
825
+ * Increments a numeric field by the specified amount for first matching document.
826
+ * @param field - The field to increment
827
+ * @param amount - The amount to increment by (default: 1)
828
+ * @returns the new value
829
+ */
830
+ increment(field: string, amount?: number): Promise<number>;
831
+ /**
832
+ * Decrements a numeric field by the specified amount.
833
+ * @param field - The field to decrement
834
+ * @param amount - The amount to decrement by
835
+ * @returns the new value
836
+ */
837
+ decrement(field: string, amount?: number): Promise<number>;
838
+ /**
839
+ * Increments a numeric field by the specified amount for all matching documents.
840
+ * @param field - The field to increment
841
+ * @param amount - The amount to increment by (default: 1)
842
+ * @returns the number of documents modified
843
+ */
844
+ incrementMany(field: string, amount?: number): Promise<number>;
845
+ /**
846
+ * Decrements a numeric field by the specified amount for all matching documents.
847
+ * @param field - The field to decrement
848
+ * @param amount - The amount to decrement by (default: 1)
849
+ * @returns the number of documents modified
850
+ */
851
+ decrementMany(field: string, amount?: number): Promise<number>;
852
+ /**
853
+ * Delete all documents matching the query.
854
+ */
855
+ delete(): Promise<number>;
856
+ /**
857
+ * Delete a single document matching the query.
858
+ */
859
+ deleteOne(): Promise<number>;
860
+ /**
861
+ * Update the given fields for all documents matching the query.
862
+ */
863
+ update(fields: Record<string, unknown>): Promise<number>;
864
+ /**
865
+ * Unset the given fields from all documents matching the query.
866
+ */
867
+ unset(...fields: string[]): Promise<number>;
868
+ /**
869
+ * Processes query results in chunks, executing a callback for each chunk.
870
+ * @param size - The number of documents per chunk
871
+ * @param callback - Function to execute for each chunk
872
+ * @returns void
873
+ */
874
+ chunk(size: number, callback: (rows: T[], chunkIndex: number) => Promise<boolean | void> | boolean | void): Promise<void>;
875
+ /**
876
+ * Executes the query with traditional page-based pagination.
877
+ * @param options - Pagination options
878
+ * @returns pagination result with data and metadata
879
+ */
880
+ paginate(options: PaginationOptions): Promise<PaginationResult<T>>;
881
+ /**
882
+ * Executes the query with cursor-based pagination supporting both directions.
883
+ * @param options - Cursor pagination options
884
+ * @returns cursor pagination result with data and cursor info
885
+ */
886
+ cursorPaginate(options: CursorPaginationOptions): Promise<CursorPaginationResult<T>>;
887
+ /**
888
+ * Returns the MongoDB aggregation pipeline that will be executed.
889
+ * @returns The MongoDB aggregation pipeline array
890
+ */
891
+ parse(): any[];
892
+ /**
893
+ * Returns a formatted string representation of the query pipeline.
894
+ * @returns A formatted string representation of the pipeline
895
+ */
896
+ pretty(): string;
897
+ /**
898
+ * Returns the MongoDB query execution plan.
899
+ * @returns MongoDB's explain output
900
+ */
901
+ explain(): Promise<unknown>;
902
+ /**
903
+ * Get query parser instance
904
+ */
905
+ protected getParser(): MongoQueryParser;
906
+ /**
907
+ * Build the MongoDB aggregation pipeline from the operations list.
908
+ * @returns The MongoDB aggregation pipeline
909
+ */
910
+ protected buildPipeline(): any[];
911
+ /**
912
+ * Build a MongoDB filter object from the query's where clauses.
913
+ * Used for update operations like increment/decrement.
914
+ * @returns The MongoDB filter object
915
+ */
916
+ protected buildFilter(): Record<string, unknown>;
917
+ /**
918
+ * Execute the aggregate command
919
+ */
920
+ protected execute<T extends any = any>(pipeline?: any[]): Promise<T[]>;
921
+ }
922
+ //# sourceMappingURL=mongo-query-builder.d.ts.map