@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,1128 @@
1
+ /**
2
+ * Ordering direction supported by query builders.
3
+ */
4
+ export type OrderDirection = "asc" | "desc";
5
+ /**
6
+ * Options describing a relationship join.
7
+ */
8
+ export type JoinOptions = {
9
+ /** Target table or collection. */
10
+ table: string;
11
+ /** Local field used in the join condition. */
12
+ localField?: string;
13
+ /** Operator used in the join condition (defaults to equality). */
14
+ operator?: string;
15
+ /** Foreign field used in the join condition. */
16
+ foreignField?: string;
17
+ /** Join type. */
18
+ type?: "inner" | "left" | "right" | "full" | "cross";
19
+ /** Optional alias for the joined relation. */
20
+ alias?: string;
21
+ /** Driver-specific options (e.g. Mongo pipeline). */
22
+ options?: Record<string, unknown>;
23
+ /** Projection overrides for the joined relation. */
24
+ select?: string[];
25
+ /** Extra join conditions expressed as key/value pairs. */
26
+ conditions?: Record<string, unknown>;
27
+ /** Driver specific pipeline/clauses for advanced joins. */
28
+ pipeline?: unknown[];
29
+ };
30
+ /**
31
+ * Pagination result returned by paginate helpers.
32
+ */
33
+ export type PaginationResult<T> = {
34
+ data: T[];
35
+ pagination: {
36
+ total: number;
37
+ page: number;
38
+ limit: number;
39
+ pages: number;
40
+ };
41
+ };
42
+ /**
43
+ * Cursor pagination result.
44
+ */
45
+ export type CursorPaginationResult<T> = {
46
+ data: T[];
47
+ pagination: {
48
+ hasMore: boolean;
49
+ hasPrev?: boolean;
50
+ nextCursor?: unknown;
51
+ prevCursor?: unknown;
52
+ };
53
+ };
54
+ /**
55
+ * Chunk callback signature.
56
+ */
57
+ export type ChunkCallback<T> = (rows: T[], chunkIndex: number) => Promise<boolean | void> | boolean | void;
58
+ /**
59
+ * Cursor pagination options.
60
+ */
61
+ export type CursorPaginationOptions = {
62
+ cursor?: unknown;
63
+ direction?: "next" | "prev";
64
+ limit: number;
65
+ column?: string;
66
+ };
67
+ /**
68
+ * Standard pagination options.
69
+ */
70
+ export type PaginationOptions = {
71
+ page?: number;
72
+ limit?: number;
73
+ };
74
+ /**
75
+ * Supported comparison operators.
76
+ */
77
+ export type WhereOperator = "=" | "!=" | ">" | ">=" | "<" | "<=" | "in" | "notIn" | "between" | "notBetween" | "like" | "notLike" | "startsWith" | "notStartsWith" | "endsWith" | "notEndsWith" | "exists" | string;
78
+ /**
79
+ * Object-based predicate definition.
80
+ */
81
+ import type { GlobalScopeDefinition, LocalScopeCallback } from "../model/model";
82
+ export type WhereObject = Record<string, unknown>;
83
+ /**
84
+ * Callback-based predicate definition.
85
+ */
86
+ export type WhereCallback<T> = (builder: QueryBuilderContract<T>) => unknown;
87
+ /**
88
+ * Group-by payload supporting strings, arrays, or driver specific objects.
89
+ */
90
+ export type GroupByInput = string | string[] | Record<string, unknown> | Array<Record<string, unknown>>;
91
+ /**
92
+ * Having clause payload.
93
+ */
94
+ export type HavingInput = Record<string, unknown> | [field: string, value: unknown] | [field: string, operator: WhereOperator, value: unknown];
95
+ /**
96
+ * Raw expression payload for projection/order/group extensions.
97
+ */
98
+ export type RawExpression = string | Record<string, unknown> | unknown;
99
+ /**
100
+ * Contract that all query builders must implement for building queries in a
101
+ * database-agnostic way. This interface provides a fluent, chainable API
102
+ * for constructing complex database queries.
103
+ *
104
+ * @template T - The type of records returned by the query
105
+ */
106
+ export interface QueryBuilderContract<T = unknown> {
107
+ /**
108
+ * Table name
109
+ */
110
+ table: string;
111
+ /**
112
+ * Hydrate records after fetching is done successfully
113
+ * Add hydrate callback function
114
+ */
115
+ hydrate(callback: (data: any, index: number) => any): this;
116
+ /**
117
+ * Register a callback to be invoked before query execution.
118
+ * Allows modification of the query before it runs.
119
+ * @returns Unsubscribe function to remove the callback
120
+ */
121
+ onFetching(callback: (query: this) => void | Promise<void>): () => void;
122
+ /**
123
+ * Register a callback to be invoked after records are fetched but before hydration.
124
+ * Receives raw records from the database.
125
+ * @returns Unsubscribe function to remove the callback
126
+ */
127
+ onHydrating(callback: (records: any[], context: any) => void | Promise<void>): () => void;
128
+ /**
129
+ * Register a callback to be invoked after records are fetched and hydrated.
130
+ * Receives hydrated model instances.
131
+ * @returns Unsubscribe function to remove the callback
132
+ */
133
+ onFetched(callback: (records: any[], context: any) => void | Promise<void>): () => void;
134
+ /**
135
+ * Pending global scopes to be applied before query execution.
136
+ * Passed from Model.query() and applied in execute().
137
+ */
138
+ pendingGlobalScopes?: Map<string, GlobalScopeDefinition>;
139
+ /**
140
+ * Available local scopes that can be manually applied.
141
+ * Passed from Model.query() for opt-in usage.
142
+ */
143
+ availableLocalScopes?: Map<string, LocalScopeCallback>;
144
+ /**
145
+ * Set of global scope names that have been disabled.
146
+ */
147
+ disabledGlobalScopes?: Set<string>;
148
+ /**
149
+ * Flag indicating whether scopes have been applied.
150
+ */
151
+ scopesApplied?: boolean;
152
+ /**
153
+ * Disable one or more global scopes for this query.
154
+ *
155
+ * @param scopeNames - Names of scopes to disable
156
+ * @returns Query builder for chaining
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * // Disable tenant scope for admin queries
161
+ * await User.query().withoutGlobalScope('tenant').get();
162
+ *
163
+ * // Disable multiple scopes
164
+ * await User.query().withoutGlobalScope('tenant', 'softDelete').get();
165
+ * ```
166
+ */
167
+ withoutGlobalScope(...scopeNames: string[]): this;
168
+ /**
169
+ * Disable all global scopes for this query.
170
+ *
171
+ * @returns Query builder for chaining
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * // Get all users including soft-deleted and from all tenants
176
+ * await User.query().withoutGlobalScopes().get();
177
+ * ```
178
+ */
179
+ withoutGlobalScopes(): this;
180
+ /**
181
+ * Apply a local scope to this query.
182
+ *
183
+ * @param scopeName - Name of the scope to apply
184
+ * @returns Query builder for chaining
185
+ * @throws Error if scope not found
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * // Apply 'active' scope
190
+ * await User.query().scope('active').get();
191
+ *
192
+ * // Chain multiple scopes
193
+ * await User.query().scope('active').scope('admins').get();
194
+ * ```
195
+ */
196
+ scope(scopeName: string): this;
197
+ /**
198
+ * Add a where clause to the query.
199
+ *
200
+ * @example
201
+ * // Simple equality
202
+ * query.where('age', 18)
203
+ *
204
+ * // With operator
205
+ * query.where('age', '>', 18)
206
+ *
207
+ * // Object-based
208
+ * query.where({ age: 18, isActive: true })
209
+ *
210
+ * // Callback-based
211
+ * query.where(q => q.where('age', '>', 18).orWhere('role', 'admin'))
212
+ */
213
+ where(field: string, value: unknown): this;
214
+ where(field: string, operator: WhereOperator, value: unknown): this;
215
+ where(conditions: WhereObject): this;
216
+ where(callback: WhereCallback<T>): this;
217
+ /**
218
+ * Add a raw where clause expressed in the native query language.
219
+ *
220
+ * @example
221
+ * query.whereRaw({ $expr: { $gt: ["$stock", "$reserved"] } })
222
+ * query.whereRaw("this.age > ?", [30])
223
+ */
224
+ whereRaw(expression: RawExpression, bindings?: unknown[]): this;
225
+ /**
226
+ * Add a raw OR where clause expressed in the native query language.
227
+ *
228
+ * @example
229
+ * query.orWhereRaw({ $where: "this.isAdmin === true" })
230
+ */
231
+ orWhereRaw(expression: RawExpression, bindings?: unknown[]): this;
232
+ /**
233
+ * Compare two columns/fields directly.
234
+ *
235
+ * @example
236
+ * query.whereColumn('stock', '>', 'reserved')
237
+ */
238
+ whereColumn(first: string, operator: WhereOperator, second: string): this;
239
+ /**
240
+ * Compare two columns/fields directly using OR logic.
241
+ *
242
+ * @example
243
+ * query.orWhereColumn('startDate', '<', 'endDate')
244
+ */
245
+ orWhereColumn(first: string, operator: WhereOperator, second: string): this;
246
+ /**
247
+ * Compare multiple column pairs at once.
248
+ *
249
+ * @example
250
+ * query.whereColumns([
251
+ * ['price', '>', 'discountPrice'],
252
+ * ['stock', '>=', 'reserved'],
253
+ * ])
254
+ */
255
+ whereColumns(comparisons: Array<[left: string, operator: WhereOperator, right: string]>): this;
256
+ /**
257
+ * Ensure a value falls between two other column values.
258
+ *
259
+ * @example
260
+ * query.whereBetweenColumns('age', 'minAge', 'maxAge')
261
+ */
262
+ whereBetweenColumns(field: string, lowerColumn: string, upperColumn: string): this;
263
+ /**
264
+ * Constrain a field to a specific date (time portion ignored).
265
+ *
266
+ * @example
267
+ * query.whereDate('createdAt', '2024-05-01')
268
+ */
269
+ whereDate(field: string, value: Date | string): this;
270
+ /**
271
+ * Require a field to match a given date exactly.
272
+ */
273
+ whereDateEquals(field: string, value: Date | string): this;
274
+ /**
275
+ * Require a field to be before the given date.
276
+ */
277
+ whereDateBefore(field: string, value: Date | string): this;
278
+ /**
279
+ * Require a field to be after the given date.
280
+ */
281
+ whereDateAfter(field: string, value: Date | string): this;
282
+ /**
283
+ * Constrain a field to match a specific time.
284
+ *
285
+ * @example
286
+ * query.whereTime('opensAt', '08:00')
287
+ */
288
+ whereTime(field: string, value: string): this;
289
+ /**
290
+ * Constrain the day-of-month extracted from a date field.
291
+ */
292
+ whereDay(field: string, value: number): this;
293
+ /**
294
+ * Constrain the month extracted from a date field.
295
+ */
296
+ whereMonth(field: string, value: number): this;
297
+ /**
298
+ * Constrain the year extracted from a date field.
299
+ */
300
+ whereYear(field: string, value: number): this;
301
+ /**
302
+ * Ensure a JSON/array path contains the given value.
303
+ */
304
+ whereJsonContains(path: string, value: unknown): this;
305
+ /**
306
+ * Ensure a JSON/array path does not contain the given value.
307
+ */
308
+ whereJsonDoesntContain(path: string, value: unknown): this;
309
+ /**
310
+ * Ensure a JSON/array path exists.
311
+ */
312
+ whereJsonContainsKey(path: string): this;
313
+ /**
314
+ * Constrain the length of a JSON/array path.
315
+ *
316
+ * @example
317
+ * query.whereJsonLength('tags', '>', 3)
318
+ */
319
+ whereJsonLength(path: string, operator: WhereOperator, value: number): this;
320
+ /**
321
+ * Ensure a JSON path resolves to an array.
322
+ */
323
+ whereJsonIsArray(path: string): this;
324
+ /**
325
+ * Ensure a JSON path resolves to an object.
326
+ */
327
+ whereJsonIsObject(path: string): this;
328
+ /**
329
+ * Constrain the length of an array field.
330
+ *
331
+ * @example
332
+ * query.whereArrayLength('roles', '>=', 2)
333
+ */
334
+ whereArrayLength(field: string, operator: WhereOperator, value: number): this;
335
+ /**
336
+ * Shortcut for filtering by the primary key.
337
+ */
338
+ whereId(value: string | number): this;
339
+ /**
340
+ * Shortcut for filtering by multiple primary keys.
341
+ */
342
+ whereIds(values: Array<string | number>): this;
343
+ /**
344
+ * Shortcut for UUID-based identifiers.
345
+ */
346
+ whereUuid(value: string): this;
347
+ /**
348
+ * Shortcut for ULID-based identifiers.
349
+ */
350
+ whereUlid(value: string): this;
351
+ /**
352
+ * Perform a full-text search across the specified fields.
353
+ */
354
+ whereFullText(fields: string | string[], query: string): this;
355
+ /**
356
+ * Apply a full-text OR clause.
357
+ */
358
+ orWhereFullText(fields: string | string[], query: string): this;
359
+ /**
360
+ * Convenience alias for simple text searches.
361
+ */
362
+ whereSearch(field: string, query: string): this;
363
+ /**
364
+ * Negate a nested callback block.
365
+ */
366
+ whereNot(callback: WhereCallback<T>): this;
367
+ /**
368
+ * Negate a nested callback block with OR logic.
369
+ */
370
+ orWhereNot(callback: WhereCallback<T>): this;
371
+ /**
372
+ * Apply a nested existence check.
373
+ *
374
+ * @example
375
+ * query.whereExists(q => q.where('status', 'active'))
376
+ * query.whereExists('optionalField')
377
+ */
378
+ whereExists(callback: WhereCallback<T>): this;
379
+ /**
380
+ * Apply a nested non-existence check.
381
+ *
382
+ * @example
383
+ * query.whereNotExists(q => q.where('status', 'inactive'))
384
+ * query.whereNotExists('deletedAt')
385
+ */
386
+ whereNotExists(callback: WhereCallback<T>): this;
387
+ /**
388
+ * Add an OR where clause to the query.
389
+ *
390
+ * @example
391
+ * query.where('role', 'admin').orWhere('role', 'moderator')
392
+ */
393
+ orWhere(field: string, value: unknown): this;
394
+ orWhere(field: string, operator: WhereOperator, value: unknown): this;
395
+ orWhere(conditions: WhereObject): this;
396
+ orWhere(callback: WhereCallback<T>): this;
397
+ /**
398
+ * Add a where IN clause to the query.
399
+ *
400
+ * @example
401
+ * query.whereIn('status', ['active', 'pending'])
402
+ */
403
+ whereIn(field: string, values: unknown[]): this;
404
+ /**
405
+ * Add a where NOT IN clause to the query.
406
+ *
407
+ * @example
408
+ * query.whereNotIn('status', ['deleted', 'archived'])
409
+ */
410
+ whereNotIn(field: string, values: unknown[]): this;
411
+ /**
412
+ * Constrain the field to be NULL.
413
+ *
414
+ * @example
415
+ * query.whereNull('deletedAt')
416
+ */
417
+ whereNull(field: string): this;
418
+ /**
419
+ * Constrain the field to be NOT NULL.
420
+ *
421
+ * @example
422
+ * query.whereNotNull('email')
423
+ */
424
+ whereNotNull(field: string): this;
425
+ /**
426
+ * Constrain the field to be between the given range (inclusive).
427
+ *
428
+ * @example
429
+ * query.whereBetween('age', [18, 65])
430
+ */
431
+ whereBetween(field: string, range: [unknown, unknown]): this;
432
+ /**
433
+ * Constrain the field to be outside the given range.
434
+ *
435
+ * @example
436
+ * query.whereNotBetween('age', [18, 65])
437
+ */
438
+ whereNotBetween(field: string, range: [unknown, unknown]): this;
439
+ /**
440
+ * Apply pattern matching (case-insensitive) for the given field.
441
+ *
442
+ * @example
443
+ * query.whereLike('name', '%john%')
444
+ */
445
+ whereLike(field: string, pattern: RegExp | string): this;
446
+ /**
447
+ * Apply pattern exclusion (case-insensitive) for the given field.
448
+ *
449
+ * @example
450
+ * query.whereNotLike('email', '%@spam.com')
451
+ */
452
+ whereNotLike(field: string, pattern: string): this;
453
+ /**
454
+ * Constrain the field to start with the given value.
455
+ *
456
+ * @example
457
+ * query.whereStartsWith('name', 'John')
458
+ */
459
+ whereStartsWith(field: string, value: string | number): this;
460
+ /**
461
+ * Constrain the field to not start with the given value.
462
+ *
463
+ * @example
464
+ * query.whereNotStartsWith('name', 'Admin')
465
+ */
466
+ whereNotStartsWith(field: string, value: string | number): this;
467
+ /**
468
+ * Constrain the field to end with the given value.
469
+ *
470
+ * @example
471
+ * query.whereEndsWith('email', '@example.com')
472
+ */
473
+ whereEndsWith(field: string, value: string | number): this;
474
+ /**
475
+ * Constrain the field to not end with the given value.
476
+ *
477
+ * @example
478
+ * query.whereNotEndsWith('email', '@spam.com')
479
+ */
480
+ whereNotEndsWith(field: string, value: string | number): this;
481
+ /**
482
+ * Constrain the date field to be between the given range.
483
+ *
484
+ * @example
485
+ * query.whereDateBetween('createdAt', [startDate, endDate])
486
+ */
487
+ whereDateBetween(field: string, range: [Date, Date]): this;
488
+ /**
489
+ * Constrain the date field to not be between the given range.
490
+ *
491
+ * @example
492
+ * query.whereDateNotBetween('createdAt', [startDate, endDate])
493
+ */
494
+ whereDateNotBetween(field: string, range: [Date, Date]): this;
495
+ /**
496
+ * Check that a field exists (MongoDB-specific).
497
+ *
498
+ * @example
499
+ * query.whereExists('optionalField')
500
+ */
501
+ whereExists(field: string): this;
502
+ /**
503
+ * Check that a field does not exist (MongoDB-specific).
504
+ *
505
+ * @example
506
+ * query.whereNotExists('optionalField')
507
+ */
508
+ whereNotExists(field: string): this;
509
+ /**
510
+ * Constrain an array/collection field by size.
511
+ *
512
+ * @example
513
+ * // Exact size
514
+ * query.whereSize('tags', 3)
515
+ *
516
+ * // With operator
517
+ * query.whereSize('tags', '>', 0)
518
+ */
519
+ whereSize(field: string, size: number): this;
520
+ whereSize(field: string, operator: ">" | ">=" | "=" | "<" | "<=", size: number): this;
521
+ /**
522
+ * Perform a full-text search (driver-specific implementation).
523
+ *
524
+ * @example
525
+ * query.textSearch('javascript tutorial', { language: 'en' })
526
+ */
527
+ textSearch(query: string, filters?: WhereObject): this;
528
+ /**
529
+ * Constrain an array field to contain the given value.
530
+ * Optionally match by a specific key within array of objects.
531
+ *
532
+ * @example
533
+ * // Simple array
534
+ * query.whereArrayContains('tags', 'javascript')
535
+ *
536
+ * // Array of objects
537
+ * query.whereArrayContains('items', 'laptop', 'name')
538
+ */
539
+ whereArrayContains(field: string, value: unknown, key?: string): this;
540
+ /**
541
+ * Constrain an array field to not contain the given value.
542
+ *
543
+ * @example
544
+ * query.whereArrayNotContains('tags', 'deprecated')
545
+ */
546
+ whereArrayNotContains(field: string, value: unknown, key?: string): this;
547
+ /**
548
+ * Constrain an array field to contain the value OR be empty.
549
+ *
550
+ * @example
551
+ * query.whereArrayHasOrEmpty('permissions', 'admin')
552
+ */
553
+ whereArrayHasOrEmpty(field: string, value: unknown, key?: string): this;
554
+ /**
555
+ * Constrain an array field to not contain the value OR be empty.
556
+ *
557
+ * @example
558
+ * query.whereArrayNotHaveOrEmpty('blockedUsers', userId)
559
+ */
560
+ whereArrayNotHaveOrEmpty(field: string, value: unknown, key?: string): this;
561
+ /**
562
+ * Specify the columns/fields to be selected.
563
+ *
564
+ * @example
565
+ * query.select(['name', 'email', 'age'])
566
+ */
567
+ select(fields: string[]): this;
568
+ select(fields: Record<string, 0 | 1 | boolean>): this;
569
+ select(...fields: Array<string | string[]>): this;
570
+ select(...args: Array<string | string[]>): this;
571
+ /**
572
+ * Select a field with an alias.
573
+ *
574
+ * @example
575
+ * query.selectAs('name', 'fullName')
576
+ */
577
+ selectAs(field: string, alias: string): this;
578
+ /**
579
+ * Add a raw selection/projection expression.
580
+ *
581
+ * @example
582
+ * query.selectRaw({ total: { $sum: "$items.price" } })
583
+ */
584
+ selectRaw(expression: RawExpression, bindings?: unknown[]): this;
585
+ /**
586
+ * Add multiple raw selections at once.
587
+ *
588
+ * @example
589
+ * query.selectRawMany([
590
+ * { alias: "firstName", expression: "$profile.name.first" },
591
+ * { alias: "isAdult", expression: { $gte: ["$age", 18] } },
592
+ * ])
593
+ */
594
+ selectRawMany(definitions: Array<{
595
+ alias: string;
596
+ expression: RawExpression;
597
+ bindings?: unknown[];
598
+ }>): this;
599
+ /**
600
+ * Inject a sub-select expression under the given alias.
601
+ *
602
+ * @example
603
+ * query.selectSub({ $sum: "$items.price" }, "itemsTotal")
604
+ */
605
+ selectSub(expression: RawExpression, alias: string): this;
606
+ /**
607
+ * Add a sub-select expression without clearing previous selects.
608
+ */
609
+ addSelectSub(expression: RawExpression, alias: string): this;
610
+ /**
611
+ * Add a simple aggregate expression to the projection.
612
+ *
613
+ * @example
614
+ * query.selectAggregate("items.price", "sum", "itemsTotal")
615
+ */
616
+ selectAggregate(field: string, aggregate: "sum" | "avg" | "min" | "max" | "count" | "first" | "last", alias: string): this;
617
+ /**
618
+ * Project whether the given field exists.
619
+ *
620
+ * @example
621
+ * query.selectExists("deletedAt", "isDeleted")
622
+ */
623
+ selectExists(field: string, alias: string): this;
624
+ /**
625
+ * Project the number of items in an array field.
626
+ *
627
+ * @example
628
+ * query.selectCount("permissions", "permissionsCount")
629
+ */
630
+ selectCount(field: string, alias: string): this;
631
+ /**
632
+ * Build CASE / switch like conditions in the projection.
633
+ *
634
+ * @example
635
+ * query.selectCase(
636
+ * [
637
+ * { when: { $eq: ["$status", "active"] }, then: "Active" },
638
+ * { when: { $eq: ["$status", "pending"] }, then: "Pending" },
639
+ * ],
640
+ * "Unknown",
641
+ * "statusLabel",
642
+ * )
643
+ */
644
+ selectCase(cases: Array<{
645
+ when: RawExpression;
646
+ then: RawExpression | unknown;
647
+ }>, otherwise: RawExpression | unknown, alias: string): this;
648
+ /**
649
+ * Convenience helper for single condition CASE statements.
650
+ *
651
+ * @example
652
+ * query.selectWhen({ $gt: ["$age", 18] }, "Adult", "Minor", "ageLabel")
653
+ */
654
+ selectWhen(condition: RawExpression, thenValue: RawExpression | unknown, elseValue: RawExpression | unknown, alias: string): this;
655
+ /**
656
+ * Allow direct access to the driver projection object for advanced cases.
657
+ *
658
+ * @example
659
+ * query.selectDriverProjection(projection => {
660
+ * projection.score = { $meta: "textScore" };
661
+ * })
662
+ */
663
+ selectDriverProjection(callback: (projection: Record<string, unknown>) => void): this;
664
+ /**
665
+ * Project a nested JSON path under a new alias.
666
+ *
667
+ * @example
668
+ * query.selectJson("settings->theme", "theme")
669
+ */
670
+ selectJson(path: string, alias?: string): this;
671
+ /**
672
+ * Apply a raw expression to a JSON path.
673
+ *
674
+ * @example
675
+ * query.selectJsonRaw("stats->views", { $ifNull: ["$stats.views", 0] }, "views")
676
+ */
677
+ selectJsonRaw(path: string, expression: RawExpression, alias: string): this;
678
+ /**
679
+ * Exclude a nested JSON path from the projection.
680
+ */
681
+ deselectJson(path: string): this;
682
+ /**
683
+ * Compute concatenated string fields.
684
+ *
685
+ * @example
686
+ * query.selectConcat(["$firstName", " ", "$lastName"], "fullName")
687
+ */
688
+ selectConcat(fields: Array<string | RawExpression>, alias: string): this;
689
+ /**
690
+ * Coalesce a list of values, returning the first non-null entry.
691
+ *
692
+ * @example
693
+ * query.selectCoalesce(["$nickname", "$name"], "displayName")
694
+ */
695
+ selectCoalesce(fields: Array<string | RawExpression>, alias: string): this;
696
+ /**
697
+ * Attach window function output to the projection.
698
+ *
699
+ * @example
700
+ * query.selectWindow({
701
+ * partitionBy: "$category",
702
+ * sortBy: { createdAt: 1 },
703
+ * output: { rank: { $denseRank: {} } },
704
+ * })
705
+ */
706
+ selectWindow(spec: RawExpression): this;
707
+ /**
708
+ * Exclude the given fields from the projection.
709
+ *
710
+ * @example
711
+ * query.deselect(['password', 'token'])
712
+ */
713
+ deselect(fields: string[]): this;
714
+ /**
715
+ * Reset the projection to its default state.
716
+ */
717
+ clearSelect(): this;
718
+ /**
719
+ * Alias for clearSelect() - keeps all fields.
720
+ */
721
+ selectAll(): this;
722
+ /**
723
+ * Restore the default projection (all columns).
724
+ */
725
+ selectDefault(): this;
726
+ /**
727
+ * Mark the query as distinct values for the given fields.
728
+ *
729
+ * @example
730
+ * query.distinctValues('category')
731
+ * query.distinctValues(['category', 'status'])
732
+ */
733
+ distinctValues(fields?: string | string[]): this;
734
+ /**
735
+ * Add additional select fields to the existing projection.
736
+ *
737
+ * @example
738
+ * query.select(['name', 'email']).addSelect(['age'])
739
+ */
740
+ addSelect(fields: string[]): this;
741
+ /**
742
+ * Order results by the specified field and direction.
743
+ *
744
+ * @example
745
+ * query.orderBy('createdAt', 'desc')
746
+ * query.orderBy({ id: 'asc', age: 'desc' })
747
+ */
748
+ orderBy(field: string, direction?: OrderDirection): this;
749
+ orderBy(fields: Record<string, OrderDirection>): this;
750
+ /**
751
+ * Order results descending by the specified field (shortcut).
752
+ *
753
+ * @example
754
+ * query.orderByDesc('createdAt')
755
+ */
756
+ orderByDesc(field: string): this;
757
+ /**
758
+ * Order results using a raw expression.
759
+ *
760
+ * @example
761
+ * query.orderByRaw('RANDOM()')
762
+ */
763
+ orderByRaw(expression: RawExpression, bindings?: unknown[]): this;
764
+ /**
765
+ * Order results randomly.
766
+ *
767
+ * @example
768
+ * query.orderByRandom(100)
769
+ */
770
+ orderByRandom(limit: number): this;
771
+ /**
772
+ * Order by the latest records using a timestamp column (descending).
773
+ * Defaults to 'createdAt'.
774
+ *
775
+ * @example
776
+ * query.latest() // orderBy('createdAt', 'desc')
777
+ * query.latest('updatedAt') // orderBy('updatedAt', 'desc')
778
+ */
779
+ latest(column?: string): Promise<T[]>;
780
+ /**
781
+ * Order by the oldest records using a timestamp column (ascending).
782
+ * Defaults to 'createdAt'.
783
+ *
784
+ * @example
785
+ * query.oldest() // orderBy('createdAt', 'asc')
786
+ */
787
+ oldest(column?: string): this;
788
+ /**
789
+ * Limit the number of results.
790
+ *
791
+ * @example
792
+ * query.limit(10)
793
+ */
794
+ limit(value: number): this;
795
+ /**
796
+ * Skip the specified number of results (alias for offset).
797
+ *
798
+ * @example
799
+ * query.skip(20)
800
+ */
801
+ skip(value: number): this;
802
+ /**
803
+ * Skip the specified number of results.
804
+ *
805
+ * @example
806
+ * query.offset(20)
807
+ */
808
+ offset(value: number): this;
809
+ /**
810
+ * Alias for limit() - take the first N results.
811
+ *
812
+ * @example
813
+ * query.take(5)
814
+ */
815
+ take(value: number): this;
816
+ /**
817
+ * Apply cursor pagination hints.
818
+ *
819
+ * @example
820
+ * query.cursor({ after: lastId })
821
+ */
822
+ cursor(after?: unknown, before?: unknown): this;
823
+ /**
824
+ * Group results by the given fields.
825
+ *
826
+ * @example
827
+ * query.groupBy('category')
828
+ * query.groupBy(['category', 'status'])
829
+ */
830
+ groupBy(fields: GroupByInput): this;
831
+ /**
832
+ * Group results by the given fields with aggregate operations.
833
+ *
834
+ * This method allows you to group documents and compute aggregates in a single
835
+ * operation. It accepts abstract aggregate expressions (from $agg helpers) or
836
+ * raw database-specific expressions.
837
+ *
838
+ * @param fields - Field(s) to group by
839
+ * @param aggregates - Aggregate operations to perform
840
+ *
841
+ * @example
842
+ * ```typescript
843
+ * import { $agg } from '@warlock.js/cascade';
844
+ *
845
+ * // Using abstract expressions (works for all databases)
846
+ * query.groupBy("type", {
847
+ * count: $agg.count(),
848
+ * total: $agg.sum("duration"),
849
+ * avg: $agg.avg("rating")
850
+ * });
851
+ *
852
+ * // Using raw expressions (database-specific)
853
+ * // MongoDB:
854
+ * query.groupBy("type", {
855
+ * count: { $sum: 1 },
856
+ * total: { $sum: "$duration" }
857
+ * });
858
+ *
859
+ * // SQL (future):
860
+ * query.groupBy("type", {
861
+ * count: "COUNT(*)",
862
+ * total: "SUM(duration)"
863
+ * });
864
+ * ```
865
+ */
866
+ groupBy(fields: GroupByInput, aggregates: Record<string, RawExpression>): this;
867
+ /**
868
+ * Apply raw grouping expressions.
869
+ *
870
+ * @example
871
+ * query.groupByRaw('DATE(createdAt)')
872
+ */
873
+ groupByRaw(expression: RawExpression, bindings?: unknown[]): this;
874
+ /**
875
+ * Apply having clause to aggregated results.
876
+ *
877
+ * @example
878
+ * query.groupBy('category').having('count', '>', 10)
879
+ */
880
+ having(field: string, value: unknown): this;
881
+ having(field: string, operator: WhereOperator, value: unknown): this;
882
+ having(condition: HavingInput): this;
883
+ /**
884
+ * Apply raw having clause to aggregated results.
885
+ *
886
+ * @example
887
+ * query.havingRaw('COUNT(*) > ?', [10])
888
+ */
889
+ havingRaw(expression: RawExpression, bindings?: unknown[]): this;
890
+ /**
891
+ * Join another table/collection using a structured payload.
892
+ *
893
+ * @example
894
+ * query.join({
895
+ * table: 'posts',
896
+ * localField: 'userId',
897
+ * foreignField: 'authorId',
898
+ * type: 'left'
899
+ * })
900
+ */
901
+ join(options: JoinOptions): this;
902
+ /**
903
+ * Add driver-specific raw modifications to the query.
904
+ *
905
+ * @example
906
+ * query.raw(nativeQuery => {
907
+ * // Modify native query object
908
+ * return nativeQuery;
909
+ * })
910
+ */
911
+ raw(builder: (native: unknown) => unknown): this;
912
+ /**
913
+ * Extend the query builder with driver-specific extensions.
914
+ *
915
+ * @example
916
+ * query.extend('mongoAggregation', { $match: { ... } })
917
+ */
918
+ extend<R>(extension: string, ...args: unknown[]): R;
919
+ /**
920
+ * Clone the current query builder instance.
921
+ *
922
+ * @example
923
+ * const baseQuery = User.query().where('isActive', true);
924
+ * const adminQuery = baseQuery.clone().where('role', 'admin');
925
+ */
926
+ clone(): this;
927
+ /**
928
+ * Tap into the query builder for debugging or side effects without
929
+ * breaking the fluent chain.
930
+ *
931
+ * @example
932
+ * query.where('age', '>', 18).tap(q => console.log(q.parse())).get()
933
+ */
934
+ tap(callback: (builder: this) => void): this;
935
+ /**
936
+ * Conditionally apply a callback to the query.
937
+ *
938
+ * @example
939
+ * query.when(searchTerm, (q, term) => q.whereLike('name', term))
940
+ */
941
+ when<V>(condition: V | boolean, callback: (builder: this, value: V) => void, otherwise?: (builder: this) => void): this;
942
+ /**
943
+ * Execute the query and return all matching records.
944
+ *
945
+ * @example
946
+ * const users = await User.query().where('isActive', true).get();
947
+ */
948
+ get<Output = T>(): Promise<Output[]>;
949
+ /**
950
+ * Execute the query and return the first matching record.
951
+ *
952
+ * @example
953
+ * const user = await User.query().where('email', 'john@example.com').first();
954
+ */
955
+ first<Output = T>(): Promise<Output | null>;
956
+ /**
957
+ * Execute the query and return the first matching record or throw an error.
958
+ *
959
+ * @throws {Error} If no record is found
960
+ * @example
961
+ * const user = await User.query().where('id', 123).firstOrFail();
962
+ */
963
+ firstOrFail<Output = T>(): Promise<Output>;
964
+ /**
965
+ * Configure query to retrieve the last record.
966
+ *
967
+ * @example
968
+ * const lastUser = await User.query().last().first();
969
+ */
970
+ last<Output = T>(field?: string): Promise<Output | null>;
971
+ /**
972
+ * Count the records matching the query.
973
+ *
974
+ * @example
975
+ * const total = await User.query().where('isActive', true).count();
976
+ */
977
+ count(): Promise<number>;
978
+ /**
979
+ * Aggregate sum for the given field.
980
+ *
981
+ * @example
982
+ * const total = await Order.query().sum('amount');
983
+ */
984
+ sum(field: string): Promise<number>;
985
+ /**
986
+ * Aggregate average for the given field.
987
+ *
988
+ * @example
989
+ * const avgAge = await User.query().avg('age');
990
+ */
991
+ avg(field: string): Promise<number>;
992
+ /**
993
+ * Aggregate minimum for the given field.
994
+ *
995
+ * @example
996
+ * const minPrice = await Product.query().min('price');
997
+ */
998
+ min(field: string): Promise<number>;
999
+ /**
1000
+ * Aggregate maximum for the given field.
1001
+ *
1002
+ * @example
1003
+ * const maxPrice = await Product.query().max('price');
1004
+ */
1005
+ max(field: string): Promise<number>;
1006
+ /**
1007
+ * Retrieve distinct values for a field.
1008
+ * @param field - The field to get distinct values from
1009
+ * @returns an array of distinct values
1010
+ *
1011
+ * @example
1012
+ * const categories = await Product.query().distinct('category');
1013
+ */
1014
+ distinct<T = unknown>(field: string): Promise<T[]>;
1015
+ /**
1016
+ * Retrieve a list of values for the given field.
1017
+ *
1018
+ * @example
1019
+ * const names = await User.query().pluck('name');
1020
+ */
1021
+ pluck(field: string): Promise<unknown[]>;
1022
+ /**
1023
+ * Retrieve a single scalar value for the given field from the first record.
1024
+ *
1025
+ * @example
1026
+ * const email = await User.query().where('id', 123).value('email');
1027
+ */
1028
+ value<T = unknown>(field: string): Promise<T | null>;
1029
+ /**
1030
+ * Determine if any record matches the current query.
1031
+ *
1032
+ * @example
1033
+ * const hasActiveUsers = await User.query().where('isActive', true).exists();
1034
+ */
1035
+ exists(): Promise<boolean>;
1036
+ /**
1037
+ * Determine if no records match the current query.
1038
+ *
1039
+ * @example
1040
+ * const noAdmins = await User.query().where('role', 'admin').doesntExist();
1041
+ */
1042
+ notExists(): Promise<boolean>;
1043
+ /**
1044
+ * Count distinct values for the given field.
1045
+ *
1046
+ * @example
1047
+ * const uniqueCategories = await Product.query().countDistinct('category');
1048
+ */
1049
+ countDistinct(field: string): Promise<number>;
1050
+ /**
1051
+ * Increment a field's value by the given amount.
1052
+ *
1053
+ * @returns the new value
1054
+ * @example
1055
+ * await User.query().where('id', 123).increment('loginCount', 1);
1056
+ */
1057
+ increment(field: string, amount?: number): Promise<number>;
1058
+ /**
1059
+ * Decrement a field's value by the given amount.
1060
+ *
1061
+ * @returns the new value
1062
+ * @example
1063
+ * await Product.query().where('id', 456).decrement('stock', 5);
1064
+ */
1065
+ decrement(field: string, amount?: number): Promise<number>;
1066
+ /**
1067
+ * Increment a field's value by the given amount for all matching documents.
1068
+ * @param field - The field to increment
1069
+ * @param amount - The amount to increment by (default: 1)
1070
+ * @returns the number of documents modified
1071
+ */
1072
+ incrementMany(field: string, amount?: number): Promise<number>;
1073
+ /**
1074
+ * Decrement a field's value by the given amount for all matching documents.
1075
+ * @param field - The field to decrement
1076
+ * @param amount - The amount to decrement by (default: 1)
1077
+ * @returns the number of documents modified
1078
+ */
1079
+ decrementMany(field: string, amount?: number): Promise<number>;
1080
+ /**
1081
+ * Iterate through results in chunks, executing the callback for each chunk.
1082
+ * Return false from the callback to stop iteration.
1083
+ *
1084
+ * @example
1085
+ * await User.query().chunk(100, async (users, index) => {
1086
+ * await processUsers(users);
1087
+ * // Return false to stop
1088
+ * });
1089
+ */
1090
+ chunk(size: number, callback: ChunkCallback<T>): Promise<void>;
1091
+ /**
1092
+ * Paginate the results with standard page/limit pagination.
1093
+ *
1094
+ * @example
1095
+ * const result = await User.query().paginate({ page: 1, limit: 10 });
1096
+ * // { data: [...], total: 100, page: 1, limit: 10, pages: 10 }
1097
+ */
1098
+ paginate(options: PaginationOptions): Promise<PaginationResult<T>>;
1099
+ /**
1100
+ * Paginate using cursor-based strategy for better performance.
1101
+ *
1102
+ * @example
1103
+ * const result = await User.query().cursorPaginate({ limit: 10, cursor: lastId });
1104
+ * // { data: [...], hasMore: true, nextCursor: '...' }
1105
+ */
1106
+ cursorPaginate(options: CursorPaginationOptions): Promise<CursorPaginationResult<T>>;
1107
+ /**
1108
+ * Return the native query representation (SQL string, Mongo Pipeline, etc.).
1109
+ *
1110
+ * @example
1111
+ * const mongoFilter = query.parse();
1112
+ * console.log(mongoFilter); // { age: { $gt: 18 }, isActive: true }
1113
+ */
1114
+ parse(): Promise<unknown> | unknown;
1115
+ /**
1116
+ * Returns a formatted string representation of the query pipeline | SQL string.
1117
+ * @returns A formatted string representation of the pipeline|SQL string
1118
+ */
1119
+ pretty(): string;
1120
+ /**
1121
+ * Ask the underlying driver to explain the query execution plan.
1122
+ *
1123
+ * @example
1124
+ * const plan = await query.explain();
1125
+ */
1126
+ explain(): Promise<unknown>;
1127
+ }
1128
+ //# sourceMappingURL=query-builder.contract.d.ts.map