@warlock.js/cascade 4.0.157 → 4.0.158

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (689) hide show
  1. package/package.json +4 -4
  2. package/cjs/context/database-data-source-context.d.ts +0 -29
  3. package/cjs/context/database-data-source-context.d.ts.map +0 -1
  4. package/cjs/context/database-data-source-context.js +0 -28
  5. package/cjs/context/database-data-source-context.js.map +0 -1
  6. package/cjs/context/database-transaction-context.d.ts +0 -35
  7. package/cjs/context/database-transaction-context.d.ts.map +0 -1
  8. package/cjs/context/database-transaction-context.js +0 -40
  9. package/cjs/context/database-transaction-context.js.map +0 -1
  10. package/cjs/contracts/database-driver.contract.d.ts +0 -450
  11. package/cjs/contracts/database-driver.contract.d.ts.map +0 -1
  12. package/cjs/contracts/database-id-generator.contract.d.ts +0 -109
  13. package/cjs/contracts/database-id-generator.contract.d.ts.map +0 -1
  14. package/cjs/contracts/database-remover.contract.d.ts +0 -104
  15. package/cjs/contracts/database-remover.contract.d.ts.map +0 -1
  16. package/cjs/contracts/database-restorer.contract.d.ts +0 -143
  17. package/cjs/contracts/database-restorer.contract.d.ts.map +0 -1
  18. package/cjs/contracts/database-writer.contract.d.ts +0 -119
  19. package/cjs/contracts/database-writer.contract.d.ts.map +0 -1
  20. package/cjs/contracts/driver-blueprint.contract.d.ts +0 -49
  21. package/cjs/contracts/driver-blueprint.contract.d.ts.map +0 -1
  22. package/cjs/contracts/index.d.ts +0 -10
  23. package/cjs/contracts/index.d.ts.map +0 -1
  24. package/cjs/contracts/migration-driver.contract.d.ts +0 -522
  25. package/cjs/contracts/migration-driver.contract.d.ts.map +0 -1
  26. package/cjs/contracts/query-builder.contract.d.ts +0 -1609
  27. package/cjs/contracts/query-builder.contract.d.ts.map +0 -1
  28. package/cjs/contracts/sync-adapter.contract.d.ts +0 -58
  29. package/cjs/contracts/sync-adapter.contract.d.ts.map +0 -1
  30. package/cjs/data-source/data-source-registry.d.ts +0 -108
  31. package/cjs/data-source/data-source-registry.d.ts.map +0 -1
  32. package/cjs/data-source/data-source-registry.js +0 -145
  33. package/cjs/data-source/data-source-registry.js.map +0 -1
  34. package/cjs/data-source/data-source.d.ts +0 -147
  35. package/cjs/data-source/data-source.d.ts.map +0 -1
  36. package/cjs/data-source/data-source.js +0 -83
  37. package/cjs/data-source/data-source.js.map +0 -1
  38. package/cjs/database-dirty-tracker.d.ts +0 -252
  39. package/cjs/database-dirty-tracker.d.ts.map +0 -1
  40. package/cjs/database-dirty-tracker.js +0 -386
  41. package/cjs/database-dirty-tracker.js.map +0 -1
  42. package/cjs/drivers/mongodb/mongodb-blueprint.d.ts +0 -30
  43. package/cjs/drivers/mongodb/mongodb-blueprint.d.ts.map +0 -1
  44. package/cjs/drivers/mongodb/mongodb-blueprint.js +0 -51
  45. package/cjs/drivers/mongodb/mongodb-blueprint.js.map +0 -1
  46. package/cjs/drivers/mongodb/mongodb-driver.d.ts +0 -324
  47. package/cjs/drivers/mongodb/mongodb-driver.d.ts.map +0 -1
  48. package/cjs/drivers/mongodb/mongodb-driver.js +0 -799
  49. package/cjs/drivers/mongodb/mongodb-driver.js.map +0 -1
  50. package/cjs/drivers/mongodb/mongodb-id-generator.d.ts +0 -116
  51. package/cjs/drivers/mongodb/mongodb-id-generator.d.ts.map +0 -1
  52. package/cjs/drivers/mongodb/mongodb-id-generator.js +0 -149
  53. package/cjs/drivers/mongodb/mongodb-id-generator.js.map +0 -1
  54. package/cjs/drivers/mongodb/mongodb-migration-driver.d.ts +0 -317
  55. package/cjs/drivers/mongodb/mongodb-migration-driver.d.ts.map +0 -1
  56. package/cjs/drivers/mongodb/mongodb-migration-driver.js +0 -666
  57. package/cjs/drivers/mongodb/mongodb-migration-driver.js.map +0 -1
  58. package/cjs/drivers/mongodb/mongodb-query-builder.d.ts +0 -1122
  59. package/cjs/drivers/mongodb/mongodb-query-builder.d.ts.map +0 -1
  60. package/cjs/drivers/mongodb/mongodb-query-builder.js +0 -1988
  61. package/cjs/drivers/mongodb/mongodb-query-builder.js.map +0 -1
  62. package/cjs/drivers/mongodb/mongodb-query-operations.d.ts +0 -226
  63. package/cjs/drivers/mongodb/mongodb-query-operations.d.ts.map +0 -1
  64. package/cjs/drivers/mongodb/mongodb-query-operations.js +0 -270
  65. package/cjs/drivers/mongodb/mongodb-query-operations.js.map +0 -1
  66. package/cjs/drivers/mongodb/mongodb-query-parser.d.ts +0 -262
  67. package/cjs/drivers/mongodb/mongodb-query-parser.d.ts.map +0 -1
  68. package/cjs/drivers/mongodb/mongodb-query-parser.js +0 -1351
  69. package/cjs/drivers/mongodb/mongodb-query-parser.js.map +0 -1
  70. package/cjs/drivers/mongodb/mongodb-sync-adapter.d.ts +0 -79
  71. package/cjs/drivers/mongodb/mongodb-sync-adapter.d.ts.map +0 -1
  72. package/cjs/drivers/mongodb/mongodb-sync-adapter.js +0 -146
  73. package/cjs/drivers/mongodb/mongodb-sync-adapter.js.map +0 -1
  74. package/cjs/drivers/mongodb/types.d.ts +0 -43
  75. package/cjs/drivers/mongodb/types.d.ts.map +0 -1
  76. package/cjs/drivers/postgres/index.d.ts +0 -16
  77. package/cjs/drivers/postgres/index.d.ts.map +0 -1
  78. package/cjs/drivers/postgres/postgres-blueprint.d.ts +0 -64
  79. package/cjs/drivers/postgres/postgres-blueprint.d.ts.map +0 -1
  80. package/cjs/drivers/postgres/postgres-blueprint.js +0 -121
  81. package/cjs/drivers/postgres/postgres-blueprint.js.map +0 -1
  82. package/cjs/drivers/postgres/postgres-dialect.d.ts +0 -136
  83. package/cjs/drivers/postgres/postgres-dialect.d.ts.map +0 -1
  84. package/cjs/drivers/postgres/postgres-dialect.js +0 -268
  85. package/cjs/drivers/postgres/postgres-dialect.js.map +0 -1
  86. package/cjs/drivers/postgres/postgres-driver.d.ts +0 -432
  87. package/cjs/drivers/postgres/postgres-driver.d.ts.map +0 -1
  88. package/cjs/drivers/postgres/postgres-driver.js +0 -965
  89. package/cjs/drivers/postgres/postgres-driver.js.map +0 -1
  90. package/cjs/drivers/postgres/postgres-migration-driver.d.ts +0 -397
  91. package/cjs/drivers/postgres/postgres-migration-driver.d.ts.map +0 -1
  92. package/cjs/drivers/postgres/postgres-migration-driver.js +0 -900
  93. package/cjs/drivers/postgres/postgres-migration-driver.js.map +0 -1
  94. package/cjs/drivers/postgres/postgres-query-builder.d.ts +0 -254
  95. package/cjs/drivers/postgres/postgres-query-builder.d.ts.map +0 -1
  96. package/cjs/drivers/postgres/postgres-query-builder.js +0 -933
  97. package/cjs/drivers/postgres/postgres-query-builder.js.map +0 -1
  98. package/cjs/drivers/postgres/postgres-query-parser.d.ts +0 -328
  99. package/cjs/drivers/postgres/postgres-query-parser.d.ts.map +0 -1
  100. package/cjs/drivers/postgres/postgres-query-parser.js +0 -864
  101. package/cjs/drivers/postgres/postgres-query-parser.js.map +0 -1
  102. package/cjs/drivers/postgres/postgres-sql-serializer.d.ts +0 -37
  103. package/cjs/drivers/postgres/postgres-sql-serializer.d.ts.map +0 -1
  104. package/cjs/drivers/postgres/postgres-sql-serializer.js +0 -400
  105. package/cjs/drivers/postgres/postgres-sql-serializer.js.map +0 -1
  106. package/cjs/drivers/postgres/postgres-sync-adapter.d.ts +0 -83
  107. package/cjs/drivers/postgres/postgres-sync-adapter.d.ts.map +0 -1
  108. package/cjs/drivers/postgres/postgres-sync-adapter.js +0 -197
  109. package/cjs/drivers/postgres/postgres-sync-adapter.js.map +0 -1
  110. package/cjs/drivers/postgres/types.d.ts +0 -142
  111. package/cjs/drivers/postgres/types.d.ts.map +0 -1
  112. package/cjs/drivers/sql/index.d.ts +0 -10
  113. package/cjs/drivers/sql/index.d.ts.map +0 -1
  114. package/cjs/drivers/sql/sql-dialect.contract.d.ts +0 -204
  115. package/cjs/drivers/sql/sql-dialect.contract.d.ts.map +0 -1
  116. package/cjs/drivers/sql/sql-types.d.ts +0 -202
  117. package/cjs/drivers/sql/sql-types.d.ts.map +0 -1
  118. package/cjs/errors/missing-data-source.error.d.ts +0 -22
  119. package/cjs/errors/missing-data-source.error.d.ts.map +0 -1
  120. package/cjs/errors/missing-data-source.error.js +0 -29
  121. package/cjs/errors/missing-data-source.error.js.map +0 -1
  122. package/cjs/errors/transaction-rollback.error.d.ts +0 -20
  123. package/cjs/errors/transaction-rollback.error.d.ts.map +0 -1
  124. package/cjs/errors/transaction-rollback.error.js +0 -27
  125. package/cjs/errors/transaction-rollback.error.js.map +0 -1
  126. package/cjs/events/model-events.d.ts +0 -231
  127. package/cjs/events/model-events.d.ts.map +0 -1
  128. package/cjs/events/model-events.js +0 -259
  129. package/cjs/events/model-events.js.map +0 -1
  130. package/cjs/expressions/aggregate-expressions.d.ts +0 -215
  131. package/cjs/expressions/aggregate-expressions.d.ts.map +0 -1
  132. package/cjs/expressions/aggregate-expressions.js +0 -221
  133. package/cjs/expressions/aggregate-expressions.js.map +0 -1
  134. package/cjs/expressions/index.d.ts +0 -2
  135. package/cjs/expressions/index.d.ts.map +0 -1
  136. package/cjs/index.d.ts +0 -45
  137. package/cjs/index.d.ts.map +0 -1
  138. package/cjs/index.js +0 -1
  139. package/cjs/index.js.map +0 -1
  140. package/cjs/migration/column-builder.d.ts +0 -417
  141. package/cjs/migration/column-builder.d.ts.map +0 -1
  142. package/cjs/migration/column-builder.js +0 -586
  143. package/cjs/migration/column-builder.js.map +0 -1
  144. package/cjs/migration/column-helpers.d.ts +0 -275
  145. package/cjs/migration/column-helpers.d.ts.map +0 -1
  146. package/cjs/migration/column-helpers.js +0 -389
  147. package/cjs/migration/column-helpers.js.map +0 -1
  148. package/cjs/migration/foreign-key-builder.d.ts +0 -103
  149. package/cjs/migration/foreign-key-builder.d.ts.map +0 -1
  150. package/cjs/migration/foreign-key-builder.js +0 -121
  151. package/cjs/migration/foreign-key-builder.js.map +0 -1
  152. package/cjs/migration/index.d.ts +0 -7
  153. package/cjs/migration/index.d.ts.map +0 -1
  154. package/cjs/migration/migration-runner.d.ts +0 -278
  155. package/cjs/migration/migration-runner.d.ts.map +0 -1
  156. package/cjs/migration/migration-runner.js +0 -815
  157. package/cjs/migration/migration-runner.js.map +0 -1
  158. package/cjs/migration/migration.d.ts +0 -1992
  159. package/cjs/migration/migration.d.ts.map +0 -1
  160. package/cjs/migration/migration.js +0 -2162
  161. package/cjs/migration/migration.js.map +0 -1
  162. package/cjs/migration/sql-grammar.d.ts +0 -61
  163. package/cjs/migration/sql-grammar.d.ts.map +0 -1
  164. package/cjs/migration/sql-grammar.js +0 -164
  165. package/cjs/migration/sql-grammar.js.map +0 -1
  166. package/cjs/migration/sql-serializer.d.ts +0 -22
  167. package/cjs/migration/sql-serializer.d.ts.map +0 -1
  168. package/cjs/migration/sql-serializer.js +0 -26
  169. package/cjs/migration/sql-serializer.js.map +0 -1
  170. package/cjs/migration/types.d.ts +0 -155
  171. package/cjs/migration/types.d.ts.map +0 -1
  172. package/cjs/model/methods/accessor-methods.d.ts +0 -13
  173. package/cjs/model/methods/accessor-methods.d.ts.map +0 -1
  174. package/cjs/model/methods/accessor-methods.js +0 -51
  175. package/cjs/model/methods/accessor-methods.js.map +0 -1
  176. package/cjs/model/methods/delete-methods.d.ts +0 -10
  177. package/cjs/model/methods/delete-methods.d.ts.map +0 -1
  178. package/cjs/model/methods/delete-methods.js +0 -10
  179. package/cjs/model/methods/delete-methods.js.map +0 -1
  180. package/cjs/model/methods/dirty-methods.d.ts +0 -10
  181. package/cjs/model/methods/dirty-methods.d.ts.map +0 -1
  182. package/cjs/model/methods/dirty-methods.js +0 -15
  183. package/cjs/model/methods/dirty-methods.js.map +0 -1
  184. package/cjs/model/methods/hydration-methods.d.ts +0 -10
  185. package/cjs/model/methods/hydration-methods.d.ts.map +0 -1
  186. package/cjs/model/methods/hydration-methods.js +0 -57
  187. package/cjs/model/methods/hydration-methods.js.map +0 -1
  188. package/cjs/model/methods/instance-event-methods.d.ts +0 -7
  189. package/cjs/model/methods/instance-event-methods.d.ts.map +0 -1
  190. package/cjs/model/methods/instance-event-methods.js +0 -15
  191. package/cjs/model/methods/instance-event-methods.js.map +0 -1
  192. package/cjs/model/methods/meta-methods.d.ts +0 -7
  193. package/cjs/model/methods/meta-methods.d.ts.map +0 -1
  194. package/cjs/model/methods/meta-methods.js +0 -78
  195. package/cjs/model/methods/meta-methods.js.map +0 -1
  196. package/cjs/model/methods/query-methods.d.ts +0 -24
  197. package/cjs/model/methods/query-methods.d.ts.map +0 -1
  198. package/cjs/model/methods/query-methods.js +0 -161
  199. package/cjs/model/methods/query-methods.js.map +0 -1
  200. package/cjs/model/methods/restore-methods.d.ts +0 -10
  201. package/cjs/model/methods/restore-methods.d.ts.map +0 -1
  202. package/cjs/model/methods/restore-methods.js +0 -13
  203. package/cjs/model/methods/restore-methods.js.map +0 -1
  204. package/cjs/model/methods/scope-methods.d.ts +0 -7
  205. package/cjs/model/methods/scope-methods.d.ts.map +0 -1
  206. package/cjs/model/methods/scope-methods.js +0 -15
  207. package/cjs/model/methods/scope-methods.js.map +0 -1
  208. package/cjs/model/methods/serialization-methods.d.ts +0 -3
  209. package/cjs/model/methods/serialization-methods.d.ts.map +0 -1
  210. package/cjs/model/methods/serialization-methods.js +0 -27
  211. package/cjs/model/methods/serialization-methods.js.map +0 -1
  212. package/cjs/model/methods/static-event-methods.d.ts +0 -9
  213. package/cjs/model/methods/static-event-methods.d.ts.map +0 -1
  214. package/cjs/model/methods/static-event-methods.js +0 -29
  215. package/cjs/model/methods/static-event-methods.js.map +0 -1
  216. package/cjs/model/methods/write-methods.d.ts +0 -10
  217. package/cjs/model/methods/write-methods.d.ts.map +0 -1
  218. package/cjs/model/methods/write-methods.js +0 -52
  219. package/cjs/model/methods/write-methods.js.map +0 -1
  220. package/cjs/model/model.d.ts +0 -1650
  221. package/cjs/model/model.d.ts.map +0 -1
  222. package/cjs/model/model.js +0 -1657
  223. package/cjs/model/model.js.map +0 -1
  224. package/cjs/model/model.types.d.ts +0 -44
  225. package/cjs/model/model.types.d.ts.map +0 -1
  226. package/cjs/model/register-model.d.ts +0 -81
  227. package/cjs/model/register-model.d.ts.map +0 -1
  228. package/cjs/model/register-model.js +0 -94
  229. package/cjs/model/register-model.js.map +0 -1
  230. package/cjs/query-builder/query-builder.d.ts +0 -556
  231. package/cjs/query-builder/query-builder.d.ts.map +0 -1
  232. package/cjs/query-builder/query-builder.js +0 -1070
  233. package/cjs/query-builder/query-builder.js.map +0 -1
  234. package/cjs/relations/helpers.d.ts +0 -156
  235. package/cjs/relations/helpers.d.ts.map +0 -1
  236. package/cjs/relations/helpers.js +0 -201
  237. package/cjs/relations/helpers.js.map +0 -1
  238. package/cjs/relations/index.d.ts +0 -35
  239. package/cjs/relations/index.d.ts.map +0 -1
  240. package/cjs/relations/pivot-operations.d.ts +0 -160
  241. package/cjs/relations/pivot-operations.d.ts.map +0 -1
  242. package/cjs/relations/pivot-operations.js +0 -293
  243. package/cjs/relations/pivot-operations.js.map +0 -1
  244. package/cjs/relations/relation-hydrator.d.ts +0 -68
  245. package/cjs/relations/relation-hydrator.d.ts.map +0 -1
  246. package/cjs/relations/relation-hydrator.js +0 -81
  247. package/cjs/relations/relation-hydrator.js.map +0 -1
  248. package/cjs/relations/relation-loader.d.ts +0 -194
  249. package/cjs/relations/relation-loader.d.ts.map +0 -1
  250. package/cjs/relations/relation-loader.js +0 -466
  251. package/cjs/relations/relation-loader.js.map +0 -1
  252. package/cjs/relations/types.d.ts +0 -306
  253. package/cjs/relations/types.d.ts.map +0 -1
  254. package/cjs/remover/database-remover.d.ts +0 -100
  255. package/cjs/remover/database-remover.d.ts.map +0 -1
  256. package/cjs/remover/database-remover.js +0 -214
  257. package/cjs/remover/database-remover.js.map +0 -1
  258. package/cjs/restorer/database-restorer.d.ts +0 -131
  259. package/cjs/restorer/database-restorer.d.ts.map +0 -1
  260. package/cjs/restorer/database-restorer.js +0 -434
  261. package/cjs/restorer/database-restorer.js.map +0 -1
  262. package/cjs/sql-database-dirty-tracker.d.ts +0 -13
  263. package/cjs/sql-database-dirty-tracker.d.ts.map +0 -1
  264. package/cjs/sql-database-dirty-tracker.js +0 -14
  265. package/cjs/sql-database-dirty-tracker.js.map +0 -1
  266. package/cjs/sync/index.d.ts +0 -12
  267. package/cjs/sync/index.d.ts.map +0 -1
  268. package/cjs/sync/model-events.d.ts +0 -62
  269. package/cjs/sync/model-events.d.ts.map +0 -1
  270. package/cjs/sync/model-events.js +0 -49
  271. package/cjs/sync/model-events.js.map +0 -1
  272. package/cjs/sync/model-sync-operation.d.ts +0 -163
  273. package/cjs/sync/model-sync-operation.d.ts.map +0 -1
  274. package/cjs/sync/model-sync-operation.js +0 -292
  275. package/cjs/sync/model-sync-operation.js.map +0 -1
  276. package/cjs/sync/model-sync.d.ts +0 -130
  277. package/cjs/sync/model-sync.d.ts.map +0 -1
  278. package/cjs/sync/model-sync.js +0 -178
  279. package/cjs/sync/model-sync.js.map +0 -1
  280. package/cjs/sync/sync-context.d.ts +0 -70
  281. package/cjs/sync/sync-context.d.ts.map +0 -1
  282. package/cjs/sync/sync-context.js +0 -101
  283. package/cjs/sync/sync-context.js.map +0 -1
  284. package/cjs/sync/sync-manager.d.ts +0 -213
  285. package/cjs/sync/sync-manager.d.ts.map +0 -1
  286. package/cjs/sync/sync-manager.js +0 -689
  287. package/cjs/sync/sync-manager.js.map +0 -1
  288. package/cjs/sync/types.d.ts +0 -289
  289. package/cjs/sync/types.d.ts.map +0 -1
  290. package/cjs/test-migrations/test-enhanced-features.migration.d.ts +0 -15
  291. package/cjs/test-migrations/test-enhanced-features.migration.d.ts.map +0 -1
  292. package/cjs/types.d.ts +0 -371
  293. package/cjs/types.d.ts.map +0 -1
  294. package/cjs/utils/connect-to-database.d.ts +0 -300
  295. package/cjs/utils/connect-to-database.d.ts.map +0 -1
  296. package/cjs/utils/connect-to-database.js +0 -128
  297. package/cjs/utils/connect-to-database.js.map +0 -1
  298. package/cjs/utils/database-writer.utils.d.ts +0 -15
  299. package/cjs/utils/database-writer.utils.d.ts.map +0 -1
  300. package/cjs/utils/database-writer.utils.js +0 -14
  301. package/cjs/utils/database-writer.utils.js.map +0 -1
  302. package/cjs/utils/define-model.js +0 -100
  303. package/cjs/utils/define-model.js.map +0 -1
  304. package/cjs/utils/is-valid-date-value.d.ts +0 -5
  305. package/cjs/utils/is-valid-date-value.d.ts.map +0 -1
  306. package/cjs/utils/is-valid-date-value.js +0 -25
  307. package/cjs/utils/is-valid-date-value.js.map +0 -1
  308. package/cjs/utils/once-connected.d.ts +0 -146
  309. package/cjs/utils/once-connected.d.ts.map +0 -1
  310. package/cjs/utils/once-connected.js +0 -251
  311. package/cjs/utils/once-connected.js.map +0 -1
  312. package/cjs/validation/database-seal-plugins.d.ts +0 -12
  313. package/cjs/validation/database-seal-plugins.d.ts.map +0 -1
  314. package/cjs/validation/database-seal-plugins.js +0 -1
  315. package/cjs/validation/database-seal-plugins.js.map +0 -1
  316. package/cjs/validation/database-writer-validation-error.d.ts +0 -97
  317. package/cjs/validation/database-writer-validation-error.d.ts.map +0 -1
  318. package/cjs/validation/database-writer-validation-error.js +0 -160
  319. package/cjs/validation/database-writer-validation-error.js.map +0 -1
  320. package/cjs/validation/index.d.ts +0 -3
  321. package/cjs/validation/index.d.ts.map +0 -1
  322. package/cjs/validation/mutators/embed-mutator.d.ts +0 -9
  323. package/cjs/validation/mutators/embed-mutator.d.ts.map +0 -1
  324. package/cjs/validation/mutators/embed-mutator.js +0 -33
  325. package/cjs/validation/mutators/embed-mutator.js.map +0 -1
  326. package/cjs/validation/plugins/embed-validator-plugin.d.ts +0 -24
  327. package/cjs/validation/plugins/embed-validator-plugin.d.ts.map +0 -1
  328. package/cjs/validation/plugins/embed-validator-plugin.js +0 -18
  329. package/cjs/validation/plugins/embed-validator-plugin.js.map +0 -1
  330. package/cjs/validation/rules/database-model-rule.d.ts +0 -7
  331. package/cjs/validation/rules/database-model-rule.d.ts.map +0 -1
  332. package/cjs/validation/rules/database-model-rule.js +0 -27
  333. package/cjs/validation/rules/database-model-rule.js.map +0 -1
  334. package/cjs/validation/transformers/embed-model-transformer.d.ts +0 -3
  335. package/cjs/validation/transformers/embed-model-transformer.d.ts.map +0 -1
  336. package/cjs/validation/transformers/embed-model-transformer.js +0 -18
  337. package/cjs/validation/transformers/embed-model-transformer.js.map +0 -1
  338. package/cjs/validation/validators/embed-validator.d.ts +0 -21
  339. package/cjs/validation/validators/embed-validator.d.ts.map +0 -1
  340. package/cjs/validation/validators/embed-validator.js +0 -43
  341. package/cjs/validation/validators/embed-validator.js.map +0 -1
  342. package/cjs/writer/database-writer.d.ts +0 -181
  343. package/cjs/writer/database-writer.d.ts.map +0 -1
  344. package/cjs/writer/database-writer.js +0 -407
  345. package/cjs/writer/database-writer.js.map +0 -1
  346. package/esm/context/database-data-source-context.d.ts +0 -29
  347. package/esm/context/database-data-source-context.d.ts.map +0 -1
  348. package/esm/context/database-data-source-context.js +0 -28
  349. package/esm/context/database-data-source-context.js.map +0 -1
  350. package/esm/context/database-transaction-context.d.ts +0 -35
  351. package/esm/context/database-transaction-context.d.ts.map +0 -1
  352. package/esm/context/database-transaction-context.js +0 -40
  353. package/esm/context/database-transaction-context.js.map +0 -1
  354. package/esm/contracts/database-driver.contract.d.ts +0 -450
  355. package/esm/contracts/database-driver.contract.d.ts.map +0 -1
  356. package/esm/contracts/database-id-generator.contract.d.ts +0 -109
  357. package/esm/contracts/database-id-generator.contract.d.ts.map +0 -1
  358. package/esm/contracts/database-remover.contract.d.ts +0 -104
  359. package/esm/contracts/database-remover.contract.d.ts.map +0 -1
  360. package/esm/contracts/database-restorer.contract.d.ts +0 -143
  361. package/esm/contracts/database-restorer.contract.d.ts.map +0 -1
  362. package/esm/contracts/database-writer.contract.d.ts +0 -119
  363. package/esm/contracts/database-writer.contract.d.ts.map +0 -1
  364. package/esm/contracts/driver-blueprint.contract.d.ts +0 -49
  365. package/esm/contracts/driver-blueprint.contract.d.ts.map +0 -1
  366. package/esm/contracts/index.d.ts +0 -10
  367. package/esm/contracts/index.d.ts.map +0 -1
  368. package/esm/contracts/migration-driver.contract.d.ts +0 -522
  369. package/esm/contracts/migration-driver.contract.d.ts.map +0 -1
  370. package/esm/contracts/query-builder.contract.d.ts +0 -1609
  371. package/esm/contracts/query-builder.contract.d.ts.map +0 -1
  372. package/esm/contracts/sync-adapter.contract.d.ts +0 -58
  373. package/esm/contracts/sync-adapter.contract.d.ts.map +0 -1
  374. package/esm/data-source/data-source-registry.d.ts +0 -108
  375. package/esm/data-source/data-source-registry.d.ts.map +0 -1
  376. package/esm/data-source/data-source-registry.js +0 -145
  377. package/esm/data-source/data-source-registry.js.map +0 -1
  378. package/esm/data-source/data-source.d.ts +0 -147
  379. package/esm/data-source/data-source.d.ts.map +0 -1
  380. package/esm/data-source/data-source.js +0 -83
  381. package/esm/data-source/data-source.js.map +0 -1
  382. package/esm/database-dirty-tracker.d.ts +0 -252
  383. package/esm/database-dirty-tracker.d.ts.map +0 -1
  384. package/esm/database-dirty-tracker.js +0 -386
  385. package/esm/database-dirty-tracker.js.map +0 -1
  386. package/esm/drivers/mongodb/mongodb-blueprint.d.ts +0 -30
  387. package/esm/drivers/mongodb/mongodb-blueprint.d.ts.map +0 -1
  388. package/esm/drivers/mongodb/mongodb-blueprint.js +0 -51
  389. package/esm/drivers/mongodb/mongodb-blueprint.js.map +0 -1
  390. package/esm/drivers/mongodb/mongodb-driver.d.ts +0 -324
  391. package/esm/drivers/mongodb/mongodb-driver.d.ts.map +0 -1
  392. package/esm/drivers/mongodb/mongodb-driver.js +0 -799
  393. package/esm/drivers/mongodb/mongodb-driver.js.map +0 -1
  394. package/esm/drivers/mongodb/mongodb-id-generator.d.ts +0 -116
  395. package/esm/drivers/mongodb/mongodb-id-generator.d.ts.map +0 -1
  396. package/esm/drivers/mongodb/mongodb-id-generator.js +0 -149
  397. package/esm/drivers/mongodb/mongodb-id-generator.js.map +0 -1
  398. package/esm/drivers/mongodb/mongodb-migration-driver.d.ts +0 -317
  399. package/esm/drivers/mongodb/mongodb-migration-driver.d.ts.map +0 -1
  400. package/esm/drivers/mongodb/mongodb-migration-driver.js +0 -666
  401. package/esm/drivers/mongodb/mongodb-migration-driver.js.map +0 -1
  402. package/esm/drivers/mongodb/mongodb-query-builder.d.ts +0 -1122
  403. package/esm/drivers/mongodb/mongodb-query-builder.d.ts.map +0 -1
  404. package/esm/drivers/mongodb/mongodb-query-builder.js +0 -1988
  405. package/esm/drivers/mongodb/mongodb-query-builder.js.map +0 -1
  406. package/esm/drivers/mongodb/mongodb-query-operations.d.ts +0 -226
  407. package/esm/drivers/mongodb/mongodb-query-operations.d.ts.map +0 -1
  408. package/esm/drivers/mongodb/mongodb-query-operations.js +0 -270
  409. package/esm/drivers/mongodb/mongodb-query-operations.js.map +0 -1
  410. package/esm/drivers/mongodb/mongodb-query-parser.d.ts +0 -262
  411. package/esm/drivers/mongodb/mongodb-query-parser.d.ts.map +0 -1
  412. package/esm/drivers/mongodb/mongodb-query-parser.js +0 -1351
  413. package/esm/drivers/mongodb/mongodb-query-parser.js.map +0 -1
  414. package/esm/drivers/mongodb/mongodb-sync-adapter.d.ts +0 -79
  415. package/esm/drivers/mongodb/mongodb-sync-adapter.d.ts.map +0 -1
  416. package/esm/drivers/mongodb/mongodb-sync-adapter.js +0 -146
  417. package/esm/drivers/mongodb/mongodb-sync-adapter.js.map +0 -1
  418. package/esm/drivers/mongodb/types.d.ts +0 -43
  419. package/esm/drivers/mongodb/types.d.ts.map +0 -1
  420. package/esm/drivers/postgres/index.d.ts +0 -16
  421. package/esm/drivers/postgres/index.d.ts.map +0 -1
  422. package/esm/drivers/postgres/postgres-blueprint.d.ts +0 -64
  423. package/esm/drivers/postgres/postgres-blueprint.d.ts.map +0 -1
  424. package/esm/drivers/postgres/postgres-blueprint.js +0 -121
  425. package/esm/drivers/postgres/postgres-blueprint.js.map +0 -1
  426. package/esm/drivers/postgres/postgres-dialect.d.ts +0 -136
  427. package/esm/drivers/postgres/postgres-dialect.d.ts.map +0 -1
  428. package/esm/drivers/postgres/postgres-dialect.js +0 -268
  429. package/esm/drivers/postgres/postgres-dialect.js.map +0 -1
  430. package/esm/drivers/postgres/postgres-driver.d.ts +0 -432
  431. package/esm/drivers/postgres/postgres-driver.d.ts.map +0 -1
  432. package/esm/drivers/postgres/postgres-driver.js +0 -965
  433. package/esm/drivers/postgres/postgres-driver.js.map +0 -1
  434. package/esm/drivers/postgres/postgres-migration-driver.d.ts +0 -397
  435. package/esm/drivers/postgres/postgres-migration-driver.d.ts.map +0 -1
  436. package/esm/drivers/postgres/postgres-migration-driver.js +0 -900
  437. package/esm/drivers/postgres/postgres-migration-driver.js.map +0 -1
  438. package/esm/drivers/postgres/postgres-query-builder.d.ts +0 -254
  439. package/esm/drivers/postgres/postgres-query-builder.d.ts.map +0 -1
  440. package/esm/drivers/postgres/postgres-query-builder.js +0 -933
  441. package/esm/drivers/postgres/postgres-query-builder.js.map +0 -1
  442. package/esm/drivers/postgres/postgres-query-parser.d.ts +0 -328
  443. package/esm/drivers/postgres/postgres-query-parser.d.ts.map +0 -1
  444. package/esm/drivers/postgres/postgres-query-parser.js +0 -864
  445. package/esm/drivers/postgres/postgres-query-parser.js.map +0 -1
  446. package/esm/drivers/postgres/postgres-sql-serializer.d.ts +0 -37
  447. package/esm/drivers/postgres/postgres-sql-serializer.d.ts.map +0 -1
  448. package/esm/drivers/postgres/postgres-sql-serializer.js +0 -400
  449. package/esm/drivers/postgres/postgres-sql-serializer.js.map +0 -1
  450. package/esm/drivers/postgres/postgres-sync-adapter.d.ts +0 -83
  451. package/esm/drivers/postgres/postgres-sync-adapter.d.ts.map +0 -1
  452. package/esm/drivers/postgres/postgres-sync-adapter.js +0 -197
  453. package/esm/drivers/postgres/postgres-sync-adapter.js.map +0 -1
  454. package/esm/drivers/postgres/types.d.ts +0 -142
  455. package/esm/drivers/postgres/types.d.ts.map +0 -1
  456. package/esm/drivers/sql/index.d.ts +0 -10
  457. package/esm/drivers/sql/index.d.ts.map +0 -1
  458. package/esm/drivers/sql/sql-dialect.contract.d.ts +0 -204
  459. package/esm/drivers/sql/sql-dialect.contract.d.ts.map +0 -1
  460. package/esm/drivers/sql/sql-types.d.ts +0 -202
  461. package/esm/drivers/sql/sql-types.d.ts.map +0 -1
  462. package/esm/errors/missing-data-source.error.d.ts +0 -22
  463. package/esm/errors/missing-data-source.error.d.ts.map +0 -1
  464. package/esm/errors/missing-data-source.error.js +0 -29
  465. package/esm/errors/missing-data-source.error.js.map +0 -1
  466. package/esm/errors/transaction-rollback.error.d.ts +0 -20
  467. package/esm/errors/transaction-rollback.error.d.ts.map +0 -1
  468. package/esm/errors/transaction-rollback.error.js +0 -27
  469. package/esm/errors/transaction-rollback.error.js.map +0 -1
  470. package/esm/events/model-events.d.ts +0 -231
  471. package/esm/events/model-events.d.ts.map +0 -1
  472. package/esm/events/model-events.js +0 -259
  473. package/esm/events/model-events.js.map +0 -1
  474. package/esm/expressions/aggregate-expressions.d.ts +0 -215
  475. package/esm/expressions/aggregate-expressions.d.ts.map +0 -1
  476. package/esm/expressions/aggregate-expressions.js +0 -221
  477. package/esm/expressions/aggregate-expressions.js.map +0 -1
  478. package/esm/expressions/index.d.ts +0 -2
  479. package/esm/expressions/index.d.ts.map +0 -1
  480. package/esm/index.d.ts +0 -45
  481. package/esm/index.d.ts.map +0 -1
  482. package/esm/index.js +0 -1
  483. package/esm/index.js.map +0 -1
  484. package/esm/migration/column-builder.d.ts +0 -417
  485. package/esm/migration/column-builder.d.ts.map +0 -1
  486. package/esm/migration/column-builder.js +0 -586
  487. package/esm/migration/column-builder.js.map +0 -1
  488. package/esm/migration/column-helpers.d.ts +0 -275
  489. package/esm/migration/column-helpers.d.ts.map +0 -1
  490. package/esm/migration/column-helpers.js +0 -389
  491. package/esm/migration/column-helpers.js.map +0 -1
  492. package/esm/migration/foreign-key-builder.d.ts +0 -103
  493. package/esm/migration/foreign-key-builder.d.ts.map +0 -1
  494. package/esm/migration/foreign-key-builder.js +0 -121
  495. package/esm/migration/foreign-key-builder.js.map +0 -1
  496. package/esm/migration/index.d.ts +0 -7
  497. package/esm/migration/index.d.ts.map +0 -1
  498. package/esm/migration/migration-runner.d.ts +0 -278
  499. package/esm/migration/migration-runner.d.ts.map +0 -1
  500. package/esm/migration/migration-runner.js +0 -815
  501. package/esm/migration/migration-runner.js.map +0 -1
  502. package/esm/migration/migration.d.ts +0 -1992
  503. package/esm/migration/migration.d.ts.map +0 -1
  504. package/esm/migration/migration.js +0 -2162
  505. package/esm/migration/migration.js.map +0 -1
  506. package/esm/migration/sql-grammar.d.ts +0 -61
  507. package/esm/migration/sql-grammar.d.ts.map +0 -1
  508. package/esm/migration/sql-grammar.js +0 -164
  509. package/esm/migration/sql-grammar.js.map +0 -1
  510. package/esm/migration/sql-serializer.d.ts +0 -22
  511. package/esm/migration/sql-serializer.d.ts.map +0 -1
  512. package/esm/migration/sql-serializer.js +0 -26
  513. package/esm/migration/sql-serializer.js.map +0 -1
  514. package/esm/migration/types.d.ts +0 -155
  515. package/esm/migration/types.d.ts.map +0 -1
  516. package/esm/model/methods/accessor-methods.d.ts +0 -13
  517. package/esm/model/methods/accessor-methods.d.ts.map +0 -1
  518. package/esm/model/methods/accessor-methods.js +0 -51
  519. package/esm/model/methods/accessor-methods.js.map +0 -1
  520. package/esm/model/methods/delete-methods.d.ts +0 -10
  521. package/esm/model/methods/delete-methods.d.ts.map +0 -1
  522. package/esm/model/methods/delete-methods.js +0 -10
  523. package/esm/model/methods/delete-methods.js.map +0 -1
  524. package/esm/model/methods/dirty-methods.d.ts +0 -10
  525. package/esm/model/methods/dirty-methods.d.ts.map +0 -1
  526. package/esm/model/methods/dirty-methods.js +0 -15
  527. package/esm/model/methods/dirty-methods.js.map +0 -1
  528. package/esm/model/methods/hydration-methods.d.ts +0 -10
  529. package/esm/model/methods/hydration-methods.d.ts.map +0 -1
  530. package/esm/model/methods/hydration-methods.js +0 -57
  531. package/esm/model/methods/hydration-methods.js.map +0 -1
  532. package/esm/model/methods/instance-event-methods.d.ts +0 -7
  533. package/esm/model/methods/instance-event-methods.d.ts.map +0 -1
  534. package/esm/model/methods/instance-event-methods.js +0 -15
  535. package/esm/model/methods/instance-event-methods.js.map +0 -1
  536. package/esm/model/methods/meta-methods.d.ts +0 -7
  537. package/esm/model/methods/meta-methods.d.ts.map +0 -1
  538. package/esm/model/methods/meta-methods.js +0 -78
  539. package/esm/model/methods/meta-methods.js.map +0 -1
  540. package/esm/model/methods/query-methods.d.ts +0 -24
  541. package/esm/model/methods/query-methods.d.ts.map +0 -1
  542. package/esm/model/methods/query-methods.js +0 -161
  543. package/esm/model/methods/query-methods.js.map +0 -1
  544. package/esm/model/methods/restore-methods.d.ts +0 -10
  545. package/esm/model/methods/restore-methods.d.ts.map +0 -1
  546. package/esm/model/methods/restore-methods.js +0 -13
  547. package/esm/model/methods/restore-methods.js.map +0 -1
  548. package/esm/model/methods/scope-methods.d.ts +0 -7
  549. package/esm/model/methods/scope-methods.d.ts.map +0 -1
  550. package/esm/model/methods/scope-methods.js +0 -15
  551. package/esm/model/methods/scope-methods.js.map +0 -1
  552. package/esm/model/methods/serialization-methods.d.ts +0 -3
  553. package/esm/model/methods/serialization-methods.d.ts.map +0 -1
  554. package/esm/model/methods/serialization-methods.js +0 -27
  555. package/esm/model/methods/serialization-methods.js.map +0 -1
  556. package/esm/model/methods/static-event-methods.d.ts +0 -9
  557. package/esm/model/methods/static-event-methods.d.ts.map +0 -1
  558. package/esm/model/methods/static-event-methods.js +0 -29
  559. package/esm/model/methods/static-event-methods.js.map +0 -1
  560. package/esm/model/methods/write-methods.d.ts +0 -10
  561. package/esm/model/methods/write-methods.d.ts.map +0 -1
  562. package/esm/model/methods/write-methods.js +0 -52
  563. package/esm/model/methods/write-methods.js.map +0 -1
  564. package/esm/model/model.d.ts +0 -1650
  565. package/esm/model/model.d.ts.map +0 -1
  566. package/esm/model/model.js +0 -1657
  567. package/esm/model/model.js.map +0 -1
  568. package/esm/model/model.types.d.ts +0 -44
  569. package/esm/model/model.types.d.ts.map +0 -1
  570. package/esm/model/register-model.d.ts +0 -81
  571. package/esm/model/register-model.d.ts.map +0 -1
  572. package/esm/model/register-model.js +0 -94
  573. package/esm/model/register-model.js.map +0 -1
  574. package/esm/query-builder/query-builder.d.ts +0 -556
  575. package/esm/query-builder/query-builder.d.ts.map +0 -1
  576. package/esm/query-builder/query-builder.js +0 -1070
  577. package/esm/query-builder/query-builder.js.map +0 -1
  578. package/esm/relations/helpers.d.ts +0 -156
  579. package/esm/relations/helpers.d.ts.map +0 -1
  580. package/esm/relations/helpers.js +0 -201
  581. package/esm/relations/helpers.js.map +0 -1
  582. package/esm/relations/index.d.ts +0 -35
  583. package/esm/relations/index.d.ts.map +0 -1
  584. package/esm/relations/pivot-operations.d.ts +0 -160
  585. package/esm/relations/pivot-operations.d.ts.map +0 -1
  586. package/esm/relations/pivot-operations.js +0 -293
  587. package/esm/relations/pivot-operations.js.map +0 -1
  588. package/esm/relations/relation-hydrator.d.ts +0 -68
  589. package/esm/relations/relation-hydrator.d.ts.map +0 -1
  590. package/esm/relations/relation-hydrator.js +0 -81
  591. package/esm/relations/relation-hydrator.js.map +0 -1
  592. package/esm/relations/relation-loader.d.ts +0 -194
  593. package/esm/relations/relation-loader.d.ts.map +0 -1
  594. package/esm/relations/relation-loader.js +0 -466
  595. package/esm/relations/relation-loader.js.map +0 -1
  596. package/esm/relations/types.d.ts +0 -306
  597. package/esm/relations/types.d.ts.map +0 -1
  598. package/esm/remover/database-remover.d.ts +0 -100
  599. package/esm/remover/database-remover.d.ts.map +0 -1
  600. package/esm/remover/database-remover.js +0 -214
  601. package/esm/remover/database-remover.js.map +0 -1
  602. package/esm/restorer/database-restorer.d.ts +0 -131
  603. package/esm/restorer/database-restorer.d.ts.map +0 -1
  604. package/esm/restorer/database-restorer.js +0 -434
  605. package/esm/restorer/database-restorer.js.map +0 -1
  606. package/esm/sql-database-dirty-tracker.d.ts +0 -13
  607. package/esm/sql-database-dirty-tracker.d.ts.map +0 -1
  608. package/esm/sql-database-dirty-tracker.js +0 -14
  609. package/esm/sql-database-dirty-tracker.js.map +0 -1
  610. package/esm/sync/index.d.ts +0 -12
  611. package/esm/sync/index.d.ts.map +0 -1
  612. package/esm/sync/model-events.d.ts +0 -62
  613. package/esm/sync/model-events.d.ts.map +0 -1
  614. package/esm/sync/model-events.js +0 -49
  615. package/esm/sync/model-events.js.map +0 -1
  616. package/esm/sync/model-sync-operation.d.ts +0 -163
  617. package/esm/sync/model-sync-operation.d.ts.map +0 -1
  618. package/esm/sync/model-sync-operation.js +0 -292
  619. package/esm/sync/model-sync-operation.js.map +0 -1
  620. package/esm/sync/model-sync.d.ts +0 -130
  621. package/esm/sync/model-sync.d.ts.map +0 -1
  622. package/esm/sync/model-sync.js +0 -178
  623. package/esm/sync/model-sync.js.map +0 -1
  624. package/esm/sync/sync-context.d.ts +0 -70
  625. package/esm/sync/sync-context.d.ts.map +0 -1
  626. package/esm/sync/sync-context.js +0 -101
  627. package/esm/sync/sync-context.js.map +0 -1
  628. package/esm/sync/sync-manager.d.ts +0 -213
  629. package/esm/sync/sync-manager.d.ts.map +0 -1
  630. package/esm/sync/sync-manager.js +0 -689
  631. package/esm/sync/sync-manager.js.map +0 -1
  632. package/esm/sync/types.d.ts +0 -289
  633. package/esm/sync/types.d.ts.map +0 -1
  634. package/esm/test-migrations/test-enhanced-features.migration.d.ts +0 -15
  635. package/esm/test-migrations/test-enhanced-features.migration.d.ts.map +0 -1
  636. package/esm/types.d.ts +0 -371
  637. package/esm/types.d.ts.map +0 -1
  638. package/esm/utils/connect-to-database.d.ts +0 -300
  639. package/esm/utils/connect-to-database.d.ts.map +0 -1
  640. package/esm/utils/connect-to-database.js +0 -128
  641. package/esm/utils/connect-to-database.js.map +0 -1
  642. package/esm/utils/database-writer.utils.d.ts +0 -15
  643. package/esm/utils/database-writer.utils.d.ts.map +0 -1
  644. package/esm/utils/database-writer.utils.js +0 -14
  645. package/esm/utils/database-writer.utils.js.map +0 -1
  646. package/esm/utils/define-model.js +0 -100
  647. package/esm/utils/define-model.js.map +0 -1
  648. package/esm/utils/is-valid-date-value.d.ts +0 -5
  649. package/esm/utils/is-valid-date-value.d.ts.map +0 -1
  650. package/esm/utils/is-valid-date-value.js +0 -25
  651. package/esm/utils/is-valid-date-value.js.map +0 -1
  652. package/esm/utils/once-connected.d.ts +0 -146
  653. package/esm/utils/once-connected.d.ts.map +0 -1
  654. package/esm/utils/once-connected.js +0 -251
  655. package/esm/utils/once-connected.js.map +0 -1
  656. package/esm/validation/database-seal-plugins.d.ts +0 -12
  657. package/esm/validation/database-seal-plugins.d.ts.map +0 -1
  658. package/esm/validation/database-seal-plugins.js +0 -1
  659. package/esm/validation/database-seal-plugins.js.map +0 -1
  660. package/esm/validation/database-writer-validation-error.d.ts +0 -97
  661. package/esm/validation/database-writer-validation-error.d.ts.map +0 -1
  662. package/esm/validation/database-writer-validation-error.js +0 -160
  663. package/esm/validation/database-writer-validation-error.js.map +0 -1
  664. package/esm/validation/index.d.ts +0 -3
  665. package/esm/validation/index.d.ts.map +0 -1
  666. package/esm/validation/mutators/embed-mutator.d.ts +0 -9
  667. package/esm/validation/mutators/embed-mutator.d.ts.map +0 -1
  668. package/esm/validation/mutators/embed-mutator.js +0 -33
  669. package/esm/validation/mutators/embed-mutator.js.map +0 -1
  670. package/esm/validation/plugins/embed-validator-plugin.d.ts +0 -24
  671. package/esm/validation/plugins/embed-validator-plugin.d.ts.map +0 -1
  672. package/esm/validation/plugins/embed-validator-plugin.js +0 -18
  673. package/esm/validation/plugins/embed-validator-plugin.js.map +0 -1
  674. package/esm/validation/rules/database-model-rule.d.ts +0 -7
  675. package/esm/validation/rules/database-model-rule.d.ts.map +0 -1
  676. package/esm/validation/rules/database-model-rule.js +0 -27
  677. package/esm/validation/rules/database-model-rule.js.map +0 -1
  678. package/esm/validation/transformers/embed-model-transformer.d.ts +0 -3
  679. package/esm/validation/transformers/embed-model-transformer.d.ts.map +0 -1
  680. package/esm/validation/transformers/embed-model-transformer.js +0 -18
  681. package/esm/validation/transformers/embed-model-transformer.js.map +0 -1
  682. package/esm/validation/validators/embed-validator.d.ts +0 -21
  683. package/esm/validation/validators/embed-validator.d.ts.map +0 -1
  684. package/esm/validation/validators/embed-validator.js +0 -43
  685. package/esm/validation/validators/embed-validator.js.map +0 -1
  686. package/esm/writer/database-writer.d.ts +0 -181
  687. package/esm/writer/database-writer.d.ts.map +0 -1
  688. package/esm/writer/database-writer.js +0 -407
  689. package/esm/writer/database-writer.js.map +0 -1
@@ -1,1650 +0,0 @@
1
- import { type GenericObject } from "@mongez/reinforcements";
2
- import type { ObjectValidator } from "@warlock.js/seal";
3
- import type { DriverContract, PaginationOptions, PaginationResult, RemoverResult, UpdateOperations, WriterOptions } from "../contracts";
4
- import { QueryBuilderContract, WhereCallback, WhereObject, WhereOperator } from "../contracts";
5
- import type { DataSource } from "../data-source/data-source";
6
- import { DatabaseDirtyTracker } from "../database-dirty-tracker";
7
- import type { ModelEventListener, ModelEventName } from "../events/model-events";
8
- import { ModelEvents } from "../events/model-events";
9
- import type { ModelSnapshot } from "../relations/relation-hydrator";
10
- import type { ModelSyncOperationContract } from "../sync/types";
11
- import type { DeleteStrategy, StrictMode } from "../types";
12
- import type { ChildModel, GlobalScopeDefinition, GlobalScopeOptions, LocalScopeCallback, ModelSchema } from "./model.types";
13
- export type { ChildModel, GlobalScopeDefinition, GlobalScopeOptions, LocalScopeCallback, ModelSchema, ScopeTiming, } from "./model.types";
14
- /**
15
- * Base class that powers all Cascade models.
16
- *
17
- * Provides:
18
- * - Type-safe value accessors with dot-notation support (get, set, has, unset, merge)
19
- * - Automatic dirty tracking for efficient partial updates
20
- * - Lifecycle event hooks (saving, created, deleting, etc.)
21
- * - Integration with the data-source registry for multi-database support
22
- * - Support for both per-model and global event listeners
23
- *
24
- * @template TSchema - The shape of the model's underlying data
25
- *
26
- * @example
27
- * ```typescript
28
- * interface UserSchema {
29
- * id: number;
30
- * name: string;
31
- * email: string;
32
- * }
33
- *
34
- * class User extends Model<UserSchema> {
35
- * public static table = "users";
36
- * }
37
- *
38
- * const user = new User({ name: "Alice" });
39
- * user.set("email", "alice@example.com");
40
- * console.log(user.hasChanges()); // true
41
- * ```
42
- */
43
- export declare abstract class Model<TSchema extends ModelSchema = ModelSchema> {
44
- /**
45
- * The database table or collection name associated with this model.
46
- *
47
- * Must be defined by each concrete model subclass.
48
- *
49
- * @example
50
- * ```typescript
51
- * class User extends Model {
52
- * public static table = "users";
53
- * }
54
- * ```
55
- */
56
- static table: string;
57
- /**
58
- * Resource for this model.
59
- * It is a class that holds a toJSON function
60
- * Called when the model is being converted to JSON (by calling toJSON or JSON.stringify(model))
61
- *
62
- * @example
63
- * ```typescript
64
- * class User extends Model {
65
- * public static resource = UserResource;
66
- * }
67
- * ```
68
- */
69
- static resource?: any;
70
- /**
71
- * Resource columns
72
- * Define what columns should be sent to the resource (if any) when converting to JSON
73
- */
74
- static resourceColumns?: string[];
75
- /**
76
- * JSON keys for this model.
77
- * This could be used if resource is not passed
78
- * It will select only these keys from the model
79
- * @example
80
- * ```typescript
81
- * class User extends Model {
82
- * public static toJsonColumns = ["id", "name"];
83
- * }
84
- * ```
85
- */
86
- static toJsonColumns?: string[];
87
- /**
88
- * Data source reference for this model.
89
- *
90
- * Can be:
91
- * - A string name registered in the data-source registry
92
- * - A DataSource instance
93
- * - Undefined (falls back to the default data source)
94
- *
95
- * @example
96
- * ```typescript
97
- * class User extends Model {
98
- * public static dataSource = "primary";
99
- * }
100
- * ```
101
- */
102
- static dataSource?: string | DataSource;
103
- /**
104
- * Query builder class
105
- */
106
- static builder?: new (...args: any[]) => QueryBuilderContract<Model>;
107
- /**
108
- * Primary key field name used to identify records.
109
- *
110
- * @default "id"
111
- *
112
- * @example
113
- * ```typescript
114
- * class User extends Model {
115
- * public static primaryKey = "_id"; // MongoDB
116
- * }
117
- *
118
- * class Product extends Model {
119
- * public static primaryKey = "id"; // SQL
120
- * }
121
- * ```
122
- */
123
- static primaryKey: string;
124
- /**
125
- * Embeded fields when document is Being embeded
126
- */
127
- static embed?: string[];
128
- /**
129
- * Validation and casting schema using @warlock.js/seal.
130
- *
131
- * Defines validation rules and data transformations for the model.
132
- * Used automatically during save operations.
133
- *
134
- * @example
135
- * ```typescript
136
- * import { v } from "@warlock.js/seal";
137
- *
138
- * class User extends Model {
139
- * public static schema = v.object({
140
- * name: v.string().required().trim(),
141
- * age: v.number().min(0).max(120),
142
- * email: v.string().email().required().toLowerCase(),
143
- * createdAt: v.date().default(() => new Date()),
144
- * });
145
- * }
146
- * ```
147
- */
148
- static schema?: ObjectValidator;
149
- /**
150
- * Strict mode behavior for unknown fields.
151
- *
152
- * - `"strip"`: Remove unknown fields silently (default, recommended for APIs)
153
- * - `"fail"`: Throw validation error on unknown fields (strict validation)
154
- * - `"allow"`: Allow unknown fields to pass through (permissive)
155
- *
156
- * @default "strip"
157
- *
158
- * @example
159
- * ```typescript
160
- * import { Model, type StrictMode } from "@warlock.js/cascade";
161
- *
162
- * class User extends Model {
163
- * public static strictMode: StrictMode = "fail"; // Throw on unknown fields
164
- * }
165
- *
166
- * const user = new User({ name: "Alice", unknownField: "value" });
167
- * await user.save(); // DatabaseWriterValidationError: unknown field
168
- * ```
169
- */
170
- static strictMode: StrictMode;
171
- /**
172
- * Auto-generate incremental `id` field on insert (NoSQL only).
173
- *
174
- * When enabled, the ID generator creates a sequential integer ID
175
- * separate from the database's native ID (_id for MongoDB).
176
- *
177
- * **Note:** SQL databases use native AUTO_INCREMENT and don't need this.
178
- *
179
- * @default true
180
- *
181
- * @example
182
- * ```typescript
183
- * class User extends Model {
184
- * public static autoGenerateId = true;
185
- * }
186
- *
187
- * const user = new User({ name: "Alice" });
188
- * await user.save();
189
- * console.log(user.get("_id")); // ObjectId("...") - MongoDB
190
- * console.log(user.get("id")); // 1 - Generated
191
- * ```
192
- */
193
- static autoGenerateId: boolean;
194
- /**
195
- * Initial ID value for the first record.
196
- *
197
- * If not set, defaults to 1 or uses `randomInitialId`.
198
- *
199
- * @example
200
- * ```typescript
201
- * class User extends Model {
202
- * public static initialId = 1000; // Start from 1000
203
- * }
204
- * ```
205
- */
206
- static initialId?: number;
207
- /**
208
- * Randomly generate the initial ID.
209
- *
210
- * Can be:
211
- * - `true`: Generate random ID between 10000-499999
212
- * - Function: Custom random ID generator
213
- * - `false`: Use `initialId` or default to 1
214
- *
215
- * @default false
216
- *
217
- * @example
218
- * ```typescript
219
- * class User extends Model {
220
- * public static randomInitialId = true; // Random 10000-499999
221
- * }
222
- *
223
- * class Product extends Model {
224
- * public static randomInitialId = () => Math.floor(Math.random() * 1000000);
225
- * }
226
- * ```
227
- */
228
- static randomInitialId?: boolean | (() => number);
229
- /**
230
- * Amount to increment ID by for each new record.
231
- *
232
- * If not set, defaults to 1 or uses `randomIncrement`.
233
- *
234
- * @default 1
235
- *
236
- * @example
237
- * ```typescript
238
- * class User extends Model {
239
- * public static incrementIdBy = 5; // Increment by 5
240
- * }
241
- * ```
242
- */
243
- static incrementIdBy?: number;
244
- /**
245
- * Randomly generate the increment amount.
246
- *
247
- * Can be:
248
- * - `true`: Generate random increment between 1-10
249
- * - Function: Custom random increment generator
250
- * - `false`: Use `incrementIdBy` or default to 1
251
- *
252
- * @default false
253
- *
254
- * @example
255
- * ```typescript
256
- * class User extends Model {
257
- * public static randomIncrement = true; // Random 1-10
258
- * }
259
- *
260
- * class Product extends Model {
261
- * public static randomIncrement = () => Math.floor(Math.random() * 100);
262
- * }
263
- * ```
264
- */
265
- static randomIncrement?: boolean | (() => number);
266
- /**
267
- * Created at column name.
268
- */
269
- static createdAtColumn?: string | false;
270
- /**
271
- * Updated at column name.
272
- */
273
- static updatedAtColumn?: string | false;
274
- /**
275
- * Delete strategy for this model.
276
- *
277
- * Controls how models are deleted:
278
- * - `"trash"` - Moves to trash collection, then deletes
279
- * - `"permanent"` - Direct deletion (hard delete)
280
- * - `"soft"` - Sets deletedAt timestamp (soft delete)
281
- *
282
- * Can be overridden by destroy() options.
283
- * Falls back to data source default if not set.
284
- *
285
- * @example
286
- * ```typescript
287
- * class User extends Model {
288
- * public static deleteStrategy: DeleteStrategy = "soft";
289
- * }
290
- * ```
291
- */
292
- static deleteStrategy?: DeleteStrategy;
293
- /**
294
- * Column name for soft delete timestamp.
295
- *
296
- * Used when delete strategy is "soft".
297
- *
298
- * @default "deletedAt"
299
- *
300
- * @example
301
- * ```typescript
302
- * class User extends Model {
303
- * public static deletedAtColumn = "archivedAt";
304
- * }
305
- * ```
306
- */
307
- static deletedAtColumn: string | false;
308
- /**
309
- * Trash table/collection name override.
310
- *
311
- * If not set, defaults to `{table}Trash` or data source default.
312
- * Used when delete strategy is "trash".
313
- *
314
- * @example
315
- * ```typescript
316
- * class User extends Model {
317
- * public static trashTable = "userRecycleBin";
318
- * }
319
- * ```
320
- */
321
- static trashTable?: string;
322
- /**
323
- * Global scopes that are automatically applied to all queries.
324
- * These scopes are inherited by child models.
325
- */
326
- static globalScopes: Map<string, GlobalScopeDefinition>;
327
- /**
328
- * Local scopes that can be manually applied to queries.
329
- * These are reusable query snippets that developers opt into.
330
- */
331
- static localScopes: Map<string, LocalScopeCallback>;
332
- /**
333
- * Relation definitions for this model.
334
- *
335
- * Define relationships to other models using helper functions:
336
- * - `hasMany()` - One-to-many (User has many Posts)
337
- * - `hasOne()` - One-to-one (User has one Profile)
338
- * - `belongsTo()` - Inverse of hasMany/hasOne (Post belongs to User)
339
- * - `belongsToMany()` - Many-to-many with pivot table (User has many Roles)
340
- *
341
- * @example
342
- * ```typescript
343
- * import { hasMany, belongsTo, belongsToMany, hasOne } from "@warlock.js/cascade";
344
- *
345
- * class User extends Model {
346
- * public posts?: Post[]; // Optional: for TypeScript autocomplete
347
- *
348
- * static relations = {
349
- * posts: hasMany("Post"),
350
- * profile: hasOne("Profile"),
351
- * organization: belongsTo("Organization"),
352
- * roles: belongsToMany("Role", { pivot: "user_roles" }),
353
- * };
354
- * }
355
- *
356
- * // Usage:
357
- * const users = await User.query().with("posts").get();
358
- * console.log(users[0].posts); // Post[]
359
- * ```
360
- */
361
- static relations: Record<string, any>;
362
- /**
363
- * Flag indicating whether this model instance represents a new (unsaved) record.
364
- *
365
- * - `true`: The model has not been persisted to the database yet
366
- * - `false`: The model represents an existing database record
367
- *
368
- * This flag is used by the writer to determine whether to perform an insert or update.
369
- */
370
- isNew: boolean;
371
- /**
372
- * The raw mutable data backing this model instance.
373
- *
374
- * All field accessors (get, set, merge, etc.) operate on this object.
375
- */
376
- data: TSchema;
377
- /**
378
- * Dirty tracker that monitors changes to the model's data.
379
- *
380
- * Tracks:
381
- * - Which fields have been modified (dirty columns)
382
- * - Which fields have been removed
383
- * - Original vs. current values for each dirty field
384
- *
385
- * Used by the writer to generate efficient partial update payloads.
386
- */
387
- readonly dirtyTracker: DatabaseDirtyTracker;
388
- /**
389
- * Model instance events.
390
- * Allows registering listeners for lifecycle events on this specific instance.
391
- */
392
- events: ModelEvents<any>;
393
- /**
394
- * Map of loaded relations for this model instance.
395
- *
396
- * Populated automatically when using `with()` for eager loading,
397
- * or when calling `load()` for lazy loading.
398
- *
399
- * @example
400
- * ```typescript
401
- * const user = await User.query().with("posts").first();
402
- * console.log(user.loadedRelations.get("posts")); // Post[]
403
- *
404
- * // Also accessible as direct properties:
405
- * console.log(user.posts); // Post[]\n * ```
406
- */
407
- loadedRelations: Map<string, any>;
408
- /**
409
- * Column name for active status.
410
- */
411
- protected isActiveColumn: string;
412
- /**
413
- * Constructs a new model instance with optional initial data.
414
- *
415
- * Initializes the dirty tracker with a snapshot of the provided data.
416
- *
417
- * @param initialData - Partial data to populate the model
418
- *
419
- * @example
420
- * ```typescript
421
- * const user = new User({ name: "Alice", email: "alice@example.com" });
422
- * ```
423
- */
424
- constructor(initialData?: Partial<TSchema>);
425
- /**
426
- * Lazily load one or more relations for this model instance.
427
- *
428
- * This method loads relations on-demand after the model has been fetched.
429
- * The loaded relations are attached directly to the model instance and
430
- * also stored in `loadedRelations` map.
431
- *
432
- * @param relations - Relation name(s) to load
433
- * @returns This model instance for chaining
434
- *
435
- * @example
436
- * ```typescript
437
- * const user = await User.first();
438
- *
439
- * // Load single relation
440
- * await user.load("posts");
441
- * console.log(user.posts); // Post[]
442
- *
443
- * // Load multiple relations
444
- * await user.load("posts", "organization");
445
- *
446
- * // Chain with other operations
447
- * const posts = await user.load("posts").then(() => user.posts);
448
- * ```
449
- */
450
- load(...relations: string[]): Promise<this>;
451
- /**
452
- * Check if a relation has been loaded.
453
- *
454
- * @param relationName - Name of the relation to check
455
- * @returns True if the relation has been loaded
456
- *
457
- * @example
458
- * ```typescript
459
- * const user = await User.first();
460
- *
461
- * console.log(user.isLoaded("posts")); // false
462
- * await user.load("posts");
463
- * console.log(user.isLoaded("posts")); // true
464
- * ```
465
- */
466
- isLoaded(relationName: string): boolean;
467
- /**
468
- * Get a loaded relation by name.
469
- *
470
- * Returns undefined if the relation has not been loaded.
471
- *
472
- * @param relationName - Name of the relation to get
473
- * @returns The loaded relation data, or undefined
474
- *
475
- * @example
476
- * ```typescript
477
- * const user = await User.query().with("posts").first();
478
- *
479
- * const posts = user.getRelation<Post[]>("posts");
480
- * console.log(posts?.length);
481
- * ```
482
- */
483
- getRelation<TRelation = any>(relationName: string): TRelation | undefined;
484
- /**
485
- * Get a model class by its name from the global registry.
486
- *
487
- * Models must be decorated with @RegisterModel() to be available in the registry.
488
- *
489
- * @param name - The model class name
490
- * @returns The model class or undefined if not found
491
- *
492
- * @example
493
- * ```typescript
494
- * const UserModel = Model.getModel("User");
495
- * if (UserModel) {
496
- * const user = await UserModel.find(1);
497
- * }
498
- * ```
499
- */
500
- static getModel(name: string): ChildModel<Model<ModelSchema>>;
501
- /**
502
- * Get all registered models from the global registry.
503
- *
504
- * Only models decorated with @RegisterModel() will appear here.
505
- *
506
- * @returns A Map of all registered model classes by name
507
- *
508
- * @example
509
- * ```typescript
510
- * const allModels = Model.getAllModels();
511
- * for (const [name, ModelClass] of allModels) {
512
- * console.log(`Found model: ${name} with table: ${ModelClass.table}`);
513
- * }
514
- * ```
515
- */
516
- static getAllModels(): Map<string, ChildModel<Model<ModelSchema>>>;
517
- /**
518
- * Create a sync operation for a single embedded document.
519
- *
520
- * When this model is updated, the target model's field
521
- * will be updated with the embedded data.
522
- *
523
- * @param TargetModel - Target model class that receives data
524
- * @param targetField - Field path in target model
525
- * @returns Sync operation for chaining configuration
526
- *
527
- * @example
528
- * ```typescript
529
- * // When Category updates, update Product.category
530
- * Category.sync(Product, "category");
531
- * ```
532
- */
533
- static sync<TModel extends Model = Model>(this: ChildModel<TModel>, TargetModel: ChildModel<Model>, targetField: string): ModelSyncOperationContract;
534
- /**
535
- * Create a sync operation for an array of embedded documents.
536
- *
537
- * When this model is updated, the corresponding element
538
- * in the target model's array field will be updated.
539
- *
540
- * @param TargetModel - Target model class that receives data
541
- * @param targetField - Array field path in target model
542
- * @returns Sync operation for chaining configuration
543
- *
544
- * @example
545
- * ```typescript
546
- * // When Tag updates, update Post.tags[i] where tags[i].id matches
547
- * Tag.syncMany(Post, "tags").identifyBy("id");
548
- * ```
549
- */
550
- static syncMany<TModel extends Model = Model>(this: ChildModel<TModel>, TargetModel: ChildModel<Model>, targetField: string): ModelSyncOperationContract;
551
- /**
552
- * Get model id
553
- */
554
- get id(): number | string;
555
- /**
556
- * Get uuid
557
- */
558
- get uuid(): string;
559
- /**
560
- * Retrieves a field value from the model's data.
561
- *
562
- * Supports both top-level keys and dot-notation paths for nested access.
563
- *
564
- * @param field - The field name or dot-notation path (e.g., "address.city")
565
- * @param defaultValue - Value to return if the field is missing
566
- * @returns The field value or the default value if not found
567
- *
568
- * @example
569
- * ```typescript
570
- * user.get("name"); // "Alice"
571
- * user.get("address.city", "Unknown"); // "Unknown" if address.city is missing
572
- * ```
573
- */
574
- get<TKey extends keyof TSchema & string>(field: TKey): TSchema[TKey];
575
- get<TKey extends keyof TSchema & string>(field: TKey, defaultValue: TSchema[TKey]): TSchema[TKey];
576
- get<Type extends unknown = any>(field: string): Type;
577
- get<Type extends unknown = any>(field: string, defaultValue: Type): Type;
578
- /**
579
- * Get only the values of the given fields
580
- */
581
- only<TKey extends keyof TSchema & string>(fields: TKey[]): Record<TKey, TSchema[TKey]>;
582
- only(fields: string[]): Record<string, unknown>;
583
- /**
584
- * Get a string value
585
- */
586
- string(key: string, defaultValue?: string): string | undefined;
587
- /**
588
- * Get a number value
589
- */
590
- number(key: string, defaultValue?: number): number | undefined;
591
- /**
592
- * Get a boolean value
593
- */
594
- boolean(key: string, defaultValue?: boolean): boolean | undefined;
595
- /**
596
- * Sets a field value in the model's data and marks it as dirty.
597
- *
598
- * Supports both top-level keys and dot-notation paths for nested assignment.
599
- * Automatically updates the dirty tracker to reflect the change.
600
- *
601
- * @param field - The field name or dot-notation path (e.g., "address.city")
602
- * @param value - The value to assign
603
- * @returns The model instance for method chaining
604
- *
605
- * @example
606
- * ```typescript
607
- * user.set("name", "Bob").set("address.city", "NYC");
608
- * ```
609
- */
610
- set<TKey extends keyof TSchema & string>(field: TKey, value: TSchema[TKey]): this;
611
- set(field: string, value: unknown): this;
612
- /**
613
- * Checks whether a field exists in the model's data.
614
- *
615
- * Supports both top-level keys and dot-notation paths.
616
- *
617
- * @param field - The field name or dot-notation path
618
- * @returns `true` if the field exists, `false` otherwise
619
- *
620
- * @example
621
- * ```typescript
622
- * user.has("name"); // true
623
- * user.has("address.zipCode"); // false
624
- * ```
625
- */
626
- has<TKey extends keyof TSchema & string>(field: TKey): boolean;
627
- has(field: string): boolean;
628
- /**
629
- * Increment the given field by the given amount
630
- */
631
- increment<TKey extends keyof TSchema & string>(field: TKey, amount: number): this;
632
- increment(field: string, amount?: number): this;
633
- /**
634
- * Decrement the given field by the given amount
635
- */
636
- decrement<TKey extends keyof TSchema & string>(field: TKey, amount: number): this;
637
- decrement(field: string, amount?: number): this;
638
- /**
639
- * Removes one or more fields from the model's data and marks them as removed.
640
- *
641
- * Supports both top-level keys and dot-notation paths.
642
- * Automatically updates the dirty tracker to reflect the removal.
643
- *
644
- * @param fields - One or more field names or dot-notation paths to remove
645
- * @returns The model instance for method chaining
646
- *
647
- * @example
648
- * ```typescript
649
- * user.unset("tempField", "address.oldZip");
650
- * ```
651
- */
652
- unset(...fields: (keyof TSchema & string)[]): this;
653
- unset(...fields: string[]): this;
654
- /**
655
- * Merges new values into the model's data and marks changed fields as dirty.
656
- *
657
- * Performs a deep merge, preserving existing nested structures.
658
- * Automatically updates the dirty tracker to reflect all changes.
659
- *
660
- * @param values - Partial data to merge into the model
661
- * @returns The model instance for method chaining
662
- *
663
- * @example
664
- * ```typescript
665
- * user.merge({ name: "Charlie", address: { city: "LA" } });
666
- * ```
667
- */
668
- merge(values: Partial<TSchema>): this;
669
- merge(values: Record<string, unknown>): this;
670
- /**
671
- * Perform atomoic update from current model instance
672
- * Please note that it would require the id to be existing in the current
673
- * model instance
674
- * @returns number of affected records
675
- */
676
- atomicUpdate(operations: Record<string, unknown>): Promise<number>;
677
- /**
678
- * Perform atomic increment
679
- * This would issue a query update and update the given field without
680
- * saving the model
681
- */
682
- atomicIncrement<T extends keyof TSchema & string>(field: T, amount?: number): Promise<number>;
683
- /**
684
- * Perform atomic decrement
685
- * This would issue a query update and update the given field without
686
- * saving the model
687
- */
688
- atomicDecrement<T extends keyof TSchema & string>(field: T, amount?: number): Promise<number>;
689
- /**
690
- * Determine if current model is active
691
- */
692
- get isActive(): boolean;
693
- /**
694
- * Get created at date
695
- */
696
- get createdAt(): Date | undefined;
697
- /**
698
- * Get updated at date
699
- */
700
- get updatedAt(): Date | undefined;
701
- /**
702
- * Check if current model record is created by the given user model
703
- */
704
- isCreatedBy(user: Model | GenericObject): boolean;
705
- /**
706
- * Checks whether the model's data has changed since instantiation or last reset.
707
- *
708
- * @returns `true` if any fields have been modified or removed, `false` otherwise
709
- *
710
- * @example
711
- * ```typescript
712
- * const user = new User({ name: "Alice" });
713
- * user.hasChanges(); // false
714
- * user.set("name", "Bob");
715
- * user.hasChanges(); // true
716
- * ```
717
- */
718
- hasChanges(): boolean;
719
- /**
720
- * Check if the given column has been modified.
721
- *
722
- * @param column - The column name to check
723
- * @returns `true` if the column has been modified, `false` otherwise
724
- *
725
- * @example
726
- * ```typescript
727
- * user.set("name", "Bob");
728
- * user.isDirty("name"); // true
729
- * ```
730
- */
731
- isDirty(column: string): boolean;
732
- /**
733
- * Retrieves all dirty columns with their old and new values.
734
- *
735
- * @returns A record mapping each dirty column to its previous and current value
736
- *
737
- * @example
738
- * ```typescript
739
- * user.set("name", "Bob");
740
- * user.getDirtyColumnsWithValues();
741
- * // { name: { oldValue: "Alice", newValue: "Bob" } }
742
- * ```
743
- */
744
- getDirtyColumnsWithValues(): Record<string, {
745
- oldValue: unknown;
746
- newValue: unknown;
747
- }>;
748
- /**
749
- * Lists all columns that have been removed from the model's data.
750
- *
751
- * @returns An array of field names that were present initially but have been unset
752
- *
753
- * @example
754
- * ```typescript
755
- * user.unset("tempField");
756
- * user.getRemovedColumns(); // ["tempField"]
757
- * ```
758
- */
759
- getRemovedColumns(): string[];
760
- /**
761
- * Lists all columns that have been modified since instantiation or last reset.
762
- *
763
- * @returns An array of field names that have changed
764
- *
765
- * @example
766
- * ```typescript
767
- * user.set("name", "Bob");
768
- * user.getDirtyColumns(); // ["name"]
769
- * ```
770
- */
771
- getDirtyColumns(): string[];
772
- /**
773
- * Emits a lifecycle event to both per-model and global listeners.
774
- *
775
- * This method is public so that external services (like the writer) can trigger
776
- * lifecycle events when appropriate.
777
- *
778
- * @param event - The event name (e.g., "saving", "created", "deleting")
779
- * @param context - Optional context data to pass to listeners
780
- *
781
- * @example
782
- * ```typescript
783
- * await user.emitEvent("saving");
784
- * await user.emitEvent("validated", { errors: [] });
785
- * ```
786
- */
787
- emitEvent<TContext = unknown>(event: ModelEventName, context?: TContext): Promise<void>;
788
- /**
789
- * Register a listener for a model lifecycle event on this instance.
790
- *
791
- * @param event - Event name (e.g., "saving", "updated")
792
- * @param listener - Callback function
793
- * @returns Unsubscribe function
794
- */
795
- on<TContext = unknown>(event: ModelEventName, listener: ModelEventListener<this, TContext>): () => void;
796
- /**
797
- * Register a one-time listener for a model lifecycle event on this instance.
798
- *
799
- * @param event - Event name
800
- * @param listener - Callback function
801
- * @returns Unsubscribe function
802
- */
803
- once<TContext = unknown>(event: ModelEventName, listener: ModelEventListener<this, TContext>): () => void;
804
- /**
805
- * Remove a listener from this instance.
806
- *
807
- * @param event - Event name
808
- * @param listener - Callback function to remove
809
- */
810
- off<TContext = unknown>(event: ModelEventName, listener: ModelEventListener<this, TContext>): void;
811
- /**
812
- * Resolves the data source associated with this model.
813
- *
814
- * Resolution order:
815
- * 1. If `dataSource` is a string, looks it up in the data-source registry
816
- * 2. If `dataSource` is a DataSource instance, returns it directly
817
- * 3. Otherwise, returns the default data source from the registry
818
- *
819
- * @returns The resolved DataSource instance
820
- * @throws Error if no data source is found
821
- *
822
- * @example
823
- * ```typescript
824
- * class User extends Model {
825
- * public static dataSource = "primary";
826
- * }
827
- *
828
- * const ds = User.getDataSource();
829
- * ```
830
- */
831
- static getDataSource(): DataSource;
832
- /**
833
- * Get driver instance
834
- */
835
- static getDriver(): DriverContract;
836
- /**
837
- * Generate next id and set it to current model's id
838
- */
839
- generateNextId(): Promise<number | string>;
840
- /**
841
- * Apply model defaults from data source configuration.
842
- *
843
- * This is called automatically by getDataSource() the first time
844
- * a model accesses its data source. Defaults are only applied if
845
- * the model doesn't already have its own value set.
846
- *
847
- * The hierarchy is:
848
- * 1. Model static property (highest priority - skipped here)
849
- * 2. Database config modelDefaults (passed here)
850
- * 3. Driver modelDefaults (merged before passing here)
851
- * 4. Framework defaults (fallback values in the code)
852
- *
853
- * @param defaults - Model default configuration from data source
854
- */
855
- static applyModelDefaults(defaults: any): void;
856
- /**
857
- * Add a global scope that is automatically applied to all queries.
858
- *
859
- * Global scopes are inherited by child models and applied before query execution.
860
- * Use for security filters, multi-tenancy, soft deletes, etc.
861
- *
862
- * @param name - Unique name for the scope
863
- * @param callback - Function that modifies the query
864
- * @param options - Scope options (timing: 'before' | 'after')
865
- *
866
- * @example
867
- * ```typescript
868
- * // Multi-tenancy scope
869
- * Model.addGlobalScope('tenant', (query) => {
870
- * query.where('tenantId', getCurrentTenant());
871
- * }, { timing: 'before' });
872
- *
873
- * // Soft delete scope
874
- * User.addGlobalScope('notDeleted', (query) => {
875
- * query.whereNull('deletedAt');
876
- * });
877
- * ```
878
- */
879
- static addGlobalScope(name: string, callback: (query: QueryBuilderContract) => void, options?: GlobalScopeOptions): void;
880
- /**
881
- * Remove a global scope by name.
882
- *
883
- * @param name - Name of the scope to remove
884
- *
885
- * @example
886
- * ```typescript
887
- * Model.removeGlobalScope('tenant');
888
- * ```
889
- */
890
- static removeGlobalScope(name: string): void;
891
- /**
892
- * Add a local scope that can be manually applied to queries.
893
- *
894
- * Local scopes are reusable query snippets that developers opt into.
895
- * They are not automatically applied.
896
- *
897
- * @param name - Unique name for the scope
898
- * @param callback - Function that modifies the query
899
- *
900
- * @example
901
- * ```typescript
902
- * // Define reusable scopes
903
- * User.addScope('active', (query) => {
904
- * query.where('isActive', true);
905
- * });
906
- *
907
- * User.addScope('admins', (query) => {
908
- * query.where('role', 'admin');
909
- * });
910
- *
911
- * // Use explicitly
912
- * await User.query().scope('active').get();
913
- * await User.query().scope('admins').get();
914
- * ```
915
- */
916
- static addScope(name: string, callback: LocalScopeCallback): void;
917
- /**
918
- * Remove a local scope by name.
919
- *
920
- * @param name - Name of the scope to remove
921
- *
922
- * @example
923
- * ```typescript
924
- * User.removeScope('active');
925
- * ```
926
- */
927
- static removeScope(name: string): void;
928
- /**
929
- * Create a new query builder for this model
930
- */
931
- static query<TModel extends Model = Model>(this: ChildModel<TModel>): QueryBuilderContract<TModel>;
932
- /**
933
- * Short hand for the query builder method with
934
- */
935
- /**
936
- * Eagerly load one or more relations with the query results.
937
- *
938
- * Relations are loaded in separate optimized queries to prevent N+1 problems.
939
- * The loaded relations are attached to each model instance.
940
- *
941
- * @param relation - Single relation name to load
942
- * @returns Query builder for chaining
943
- *
944
- * @example
945
- * ```typescript
946
- * // Load single relation
947
- * const user = await User.query().with("posts").find(1);
948
- * console.log(user.posts); // Post[]
949
- *
950
- * // Load multiple relations
951
- * const user = await User.query().with("posts", "organization").find(1);
952
- *
953
- * // Load nested relations
954
- * const user = await User.query().with("posts.comments.author").find(1);
955
- * ```
956
- */
957
- static with<TModel extends Model = Model>(this: ChildModel<TModel>, relation: string): QueryBuilderContract<TModel>;
958
- /**
959
- * Eagerly load multiple relations.
960
- *
961
- * @param relations - Relation names to load
962
- * @returns Query builder for chaining
963
- */
964
- static with<TModel extends Model = Model>(this: ChildModel<TModel>, ...relations: string[]): QueryBuilderContract<TModel>;
965
- /**
966
- * Eagerly load a relation with a constraint callback.
967
- *
968
- * The callback receives the relation query builder, allowing you to
969
- * add conditions, ordering, or limits to the related query.
970
- *
971
- * @param relation - Relation name to load
972
- * @param constraint - Callback to configure the relation query
973
- * @returns Query builder for chaining
974
- *
975
- * @example
976
- * ```typescript
977
- * const user = await User.query()
978
- * .with("posts", (query) => {
979
- * query.where("isPublished", true)
980
- * .orderBy("createdAt", "desc")
981
- * .limit(5);
982
- * })
983
- * .find(1);
984
- * ```
985
- */
986
- static with<TModel extends Model = Model>(this: ChildModel<TModel>, relation: string, constraint: (query: QueryBuilderContract) => void): QueryBuilderContract<TModel>;
987
- /**
988
- * Eagerly load multiple relations with constraints.
989
- *
990
- * Pass an object where keys are relation names and values are either:
991
- * - `true` to load without constraints
992
- * - A callback function to configure the relation query
993
- *
994
- * @param relations - Object mapping relation names to constraints
995
- * @returns Query builder for chaining
996
- *
997
- * @example
998
- * ```typescript
999
- * const user = await User.query()
1000
- * .with({
1001
- * posts: (query) => query.where("isPublished", true),
1002
- * organization: true,
1003
- * roles: (query) => query.orderBy("priority"),
1004
- * })
1005
- * .find(1);
1006
- * ```
1007
- */
1008
- static with<TModel extends Model = Model>(this: ChildModel<TModel>, relations: Record<string, boolean | ((query: QueryBuilderContract) => void)>): QueryBuilderContract<TModel>;
1009
- /**
1010
- * Load relations using database JOINs in a single query.
1011
- *
1012
- * Unlike `with()` which uses separate queries, `joinWith()` uses
1013
- * LEFT JOIN (SQL) or $lookup (MongoDB) to fetch related data
1014
- * in a single query. The related data is hydrated into proper
1015
- * model instances and attached to the main model.
1016
- *
1017
- * Best for: belongsTo and hasOne relations where you need
1018
- * efficient single-query loading.
1019
- *
1020
- * @param relations - Relation names to load via JOIN
1021
- * @returns Query builder for chaining
1022
- *
1023
- * @example
1024
- * ```typescript
1025
- * // Single relation
1026
- * const post = await Post.joinWith("author").first();
1027
- * console.log(post.author); // User model instance
1028
- * console.log(post.data); // { id, title, authorId } - no author data
1029
- *
1030
- * // Multiple relations
1031
- * const post = await Post.joinWith("author", "category").first();
1032
- * ```
1033
- */
1034
- static joinWith<TModel extends Model = Model>(this: ChildModel<TModel>, ...relations: string[]): QueryBuilderContract<TModel>;
1035
- /**
1036
- * Create new query builder.
1037
- *
1038
- * If the model has a static `builder` property set to a query builder class,
1039
- * it will be instantiated instead of the default driver query builder.
1040
- *
1041
- * @example
1042
- * ```typescript
1043
- * class UserQueryBuilder<T = User> extends MongoQueryBuilder<T> {
1044
- * active() { return this.where("isActive", true); }
1045
- * }
1046
- *
1047
- * class User extends Model {
1048
- * static builder = UserQueryBuilder; // That's it! ✨
1049
- * }
1050
- *
1051
- * // Now User.query() returns UserQueryBuilder<User> with autocomplete!
1052
- * ```
1053
- */
1054
- static newQueryBuilder<TModel extends Model = Model>(this: ChildModel<TModel>): QueryBuilderContract<TModel>;
1055
- /**
1056
- * Get First matched record for the given filter
1057
- */
1058
- static first<TModel extends Model = Model>(this: ChildModel<TModel>, filter?: Record<string, unknown>): Promise<TModel | null>;
1059
- /**
1060
- * Get last matched record for the given filter
1061
- */
1062
- static last<TModel extends Model = Model>(this: ChildModel<TModel>, filter?: Record<string, unknown>): Promise<TModel | null>;
1063
- /**
1064
- * Use where clause directly
1065
- */
1066
- static where<TModel extends Model = Model>(this: ChildModel<TModel>, field: string, value: unknown): QueryBuilderContract<TModel>;
1067
- static where<TModel extends Model = Model>(this: ChildModel<TModel>, field: string, operator: WhereOperator, value: unknown): QueryBuilderContract<TModel>;
1068
- static where<TModel extends Model = Model>(this: (new (...args: any[]) => TModel) & Pick<typeof Model, "query" | "getDataSource" | "table">, conditions: WhereObject): QueryBuilderContract<TModel>;
1069
- static where<TModel extends Model = Model>(this: (new (...args: any[]) => TModel) & Pick<typeof Model, "query" | "getDataSource" | "table">, callback: WhereCallback<TModel>): QueryBuilderContract<TModel>;
1070
- /**
1071
- * Count the number of records in the table
1072
- * @param filter - The filter to apply to the query
1073
- */
1074
- static count<TModel extends Model = Model>(this: ChildModel<TModel>, filter?: Record<string, unknown>): Promise<number>;
1075
- /**
1076
- * Find record by id
1077
- */
1078
- static find<TModel extends Model = Model>(this: ChildModel<TModel>, id: string | number): Promise<TModel | null>;
1079
- /**
1080
- * Get all records from the table
1081
- *
1082
- * @param filter - The filter to apply to the query
1083
- * @returns All records from the table
1084
- */
1085
- static all<TModel extends Model = Model>(this: ChildModel<TModel>, filter?: Record<string, unknown>): Promise<TModel[]>;
1086
- /**
1087
- * Perform pagination
1088
- */
1089
- static paginate<TModel extends Model = Model>(this: ChildModel<TModel>, options?: PaginationOptions & {
1090
- filter?: Record<string, unknown>;
1091
- }): Promise<PaginationResult<TModel>>;
1092
- /**
1093
- * Get latest records from the table
1094
- *
1095
- * @param filter - The filter to apply to the query
1096
- */
1097
- static latest<TModel extends Model = Model>(this: ChildModel<TModel>, filter?: Record<string, unknown>): Promise<TModel[]>;
1098
- /**
1099
- * Increment the given field by the given amount using atomic update
1100
- *
1101
- * @example ```typescript
1102
- * // Increase age by 1 for user id 1
1103
- * User.increment({id: 1}, "age", 1);
1104
- * // Increase age by 1 and views by 2 for user id 1
1105
- * User.increment({id: 1}, {age: 1, views: 2});
1106
- * ```
1107
- */
1108
- static increase<TModel extends Model = Model>(this: ChildModel<TModel>, filter: Record<string, unknown>, field: string, amount: number): Promise<number>;
1109
- /**
1110
- * Decrement the given field by the given amount using atomic update
1111
- * @example ```typescript
1112
- * // Decrease age by 1 for user id 1
1113
- * User.decrement({id: 1}, "age", 1);
1114
- * // Decrease age by 1 and views by 2 for user id 1
1115
- * User.decrement({id: 1}, {age: 1, views: 2});
1116
- * ```
1117
- */
1118
- static decrease<TModel extends Model = Model>(this: ChildModel<TModel>, filter: Record<string, unknown>, field: string, amount: number): Promise<number>;
1119
- /**
1120
- * Perform atomic operation
1121
- * Example
1122
- *
1123
- * ```typescript
1124
- * const user = await User.atomic({id: 1}, {$inc: {age: 1}})
1125
- * Returns user model with updated age
1126
- */
1127
- static atomic<TModel extends Model = Model>(this: ChildModel<TModel>, filter: Record<string, unknown>, operations: UpdateOperations): Promise<number>;
1128
- /**
1129
- * Perform a direct update $set for the given id
1130
- */
1131
- static update<TModel extends Model = Model>(this: ChildModel<TModel>, id: string | number, data: Record<string, unknown>): Promise<number>;
1132
- /**
1133
- * Find one and update multiple records that matches the provided filter and return the updated record
1134
- * @param filter - Filter conditions
1135
- * @param update - Update operations ($set, $unset, $inc)
1136
- * @returns The updated records
1137
- */
1138
- static findAndUpdate<TModel extends Model = Model>(this: ChildModel<TModel>, filter: Record<string, unknown>, update: UpdateOperations): Promise<TModel[]>;
1139
- /**
1140
- * Find one and update a single record that matches the provided filter and return the updated record
1141
- * @param filter - Filter conditions
1142
- * @param update - Update operations ($set, $unset, $inc)
1143
- * @returns The updated record or null
1144
- */
1145
- static findOneAndUpdate<TModel extends Model = Model>(this: ChildModel<TModel>, filter: Record<string, unknown>, update: UpdateOperations): Promise<TModel | null>;
1146
- /**
1147
- * Find and replace the entire document that matches the provided filter and return the replaced document
1148
- */
1149
- static findAndReplace<TModel extends Model = Model>(this: ChildModel<TModel>, filter: Record<string, unknown>, document: Record<string, unknown>): Promise<TModel | null>;
1150
- /**
1151
- * Destroy (delete) the current model instance from the database.
1152
- *
1153
- * Emits lifecycle events:
1154
- * - `deleting` - Before deletion
1155
- * - `deleted` - After successful deletion
1156
- *
1157
- * @param options - Destroy options (strategy override, skipEvents)
1158
- * @throws {Error} If the model is new (not saved) or if deletion fails
1159
- *
1160
- * @example
1161
- * ```typescript
1162
- * const user = await User.find(1);
1163
- * await user.destroy(); // Uses default strategy
1164
- * await user.destroy({ strategy: "permanent" }); // Override strategy
1165
- * await user.destroy({ skipEvents: true }); // Silent delete
1166
- * ```
1167
- */
1168
- destroy(options?: {
1169
- strategy?: DeleteStrategy;
1170
- skipEvents?: boolean;
1171
- }): Promise<RemoverResult>;
1172
- /**
1173
- * Get the class constructor from an instance.
1174
- *
1175
- * This helper method allows instance methods to access static properties
1176
- * and methods of the model class in a type-safe way.
1177
- *
1178
- * @returns The model class constructor
1179
- *
1180
- * @example
1181
- * ```typescript
1182
- * const constructor = this.self();
1183
- * const table = constructor.table;
1184
- * await constructor.deleteOne({ id: 1 });
1185
- * ```
1186
- */
1187
- self<TModel extends Model = this>(): ChildModel<TModel>;
1188
- /**
1189
- * Creates an immutable clone of the model with its current state.
1190
- *
1191
- * The cloned model:
1192
- * - Contains a deep copy of all current data
1193
- * - Has frozen (immutable) data that cannot be modified
1194
- * - Preserves the `isNew` flag from the original
1195
- * - Has no dirty changes (clean state)
1196
- * - Cannot be saved or modified
1197
- *
1198
- * This is useful for:
1199
- * - Creating snapshots of model state
1200
- * - Passing read-only model data to other parts of the application
1201
- * - Preventing accidental mutations
1202
- * - Maintaining historical records
1203
- *
1204
- * @returns A new immutable model instance with the current state
1205
- *
1206
- * @example
1207
- * ```typescript
1208
- * const user = new User({ name: "Alice", email: "alice@example.com" });
1209
- * await user.save();
1210
- *
1211
- * // Create an immutable snapshot
1212
- * const snapshot = user.clone();
1213
- *
1214
- * // This will throw an error because the clone is immutable
1215
- * snapshot.set("name", "Bob"); // TypeError: Cannot assign to read only property
1216
- *
1217
- * // Original can still be modified
1218
- * user.set("name", "Bob");
1219
- * await user.save();
1220
- * ```
1221
- */
1222
- clone(): this;
1223
- /**
1224
- * Recursively freezes an object and all its nested properties.
1225
- *
1226
- * @param obj - The object to freeze
1227
- * @returns The frozen object
1228
- */
1229
- deepFreeze<T>(obj: T): T;
1230
- /**
1231
- * Get table name
1232
- */
1233
- getTableName(): string;
1234
- /**
1235
- * Get primary key name
1236
- */
1237
- getPrimaryKey(): string;
1238
- /**
1239
- * Get model schema
1240
- */
1241
- getSchema(): ObjectValidator;
1242
- /**
1243
- * Check if schema has the given key
1244
- */
1245
- schemaHas(key: string): boolean;
1246
- /**
1247
- * Get strict mode
1248
- */
1249
- getStrictMode(): StrictMode;
1250
- /**
1251
- * Get data source (Connection)
1252
- */
1253
- getConnection(): DataSource;
1254
- /**
1255
- * Delete all matching documents from the table.
1256
- */
1257
- static delete<TModel extends Model = Model>(this: ChildModel<TModel>, filter?: Record<string, unknown>): Promise<number>;
1258
- /**
1259
- * Delete a single matching document from the table.
1260
- */
1261
- static deleteOne<TModel extends Model = Model>(this: ChildModel<TModel>, filter?: Record<string, unknown>): Promise<number>;
1262
- /**
1263
- * Restore a single deleted record by its ID.
1264
- *
1265
- * Automatically detects whether the record was deleted via "trash" or "soft" strategy.
1266
- * Handles ID conflicts based on options.
1267
- *
1268
- * @param id - The primary key value of the record to restore
1269
- * @param options - Restorer options (onIdConflict, skipEvents)
1270
- * @returns The restored model instance
1271
- *
1272
- * @throws {Error} If record not found in trash or soft-deleted records
1273
- * @throws {Error} If ID conflict and onIdConflict is "fail"
1274
- *
1275
- * @example
1276
- * ```typescript
1277
- * // Restore with default options (assign new ID if conflict)
1278
- * const user = await User.restore(123);
1279
- *
1280
- * // Restore and fail if ID conflict
1281
- * const user = await User.restore(123, { onIdConflict: "fail" });
1282
- *
1283
- * // Silent restore (skip events)
1284
- * const user = await User.restore(123, { skipEvents: true });
1285
- * ```
1286
- */
1287
- static restore<TModel extends Model = Model>(this: ChildModel<TModel>, id: string | number, options?: {
1288
- onIdConflict?: "fail" | "assignNew";
1289
- skipEvents?: boolean;
1290
- }): Promise<TModel>;
1291
- /**
1292
- * Restore all deleted records for the model's table.
1293
- *
1294
- * Restores all records from the trash table (if using trash strategy)
1295
- * or all soft-deleted records (if using soft strategy).
1296
- *
1297
- * @param options - Restorer options (onIdConflict, skipEvents)
1298
- * @returns Array of restored model instances
1299
- *
1300
- * @example
1301
- * ```typescript
1302
- * // Restore all with default options
1303
- * const users = await User.restoreAll();
1304
- *
1305
- * // Restore all and fail on any ID conflict
1306
- * const users = await User.restoreAll({ onIdConflict: "fail" });
1307
- * ```
1308
- */
1309
- static restoreAll<TModel extends Model = Model>(this: ChildModel<TModel>, options?: {
1310
- onIdConflict?: "fail" | "assignNew";
1311
- skipEvents?: boolean;
1312
- }): Promise<TModel[]>;
1313
- /**
1314
- * Create a new record in database and return the model instance.
1315
- *
1316
- * The data type is automatically inferred from the model's schema type.
1317
- *
1318
- * @param data - Partial data matching the model's schema type
1319
- * @returns The created model instance
1320
- *
1321
- * @example
1322
- * ```typescript
1323
- * // TypeScript automatically infers UserSchema from User model
1324
- * const user = await User.create({
1325
- * name: "Alice",
1326
- * email: "alice@example.com",
1327
- * age: 30
1328
- * });
1329
- * // Type: User (with UserSchema inferred)
1330
- * ```
1331
- */
1332
- static create<TModel extends Model = Model, TSchema extends ModelSchema = TModel extends Model<infer S> ? S : ModelSchema>(this: ChildModel<TModel>, data: Partial<TSchema>): Promise<TModel>;
1333
- /**
1334
- * Create many documents and return an array of created models
1335
- */
1336
- static createMany<TModel extends Model = Model, TSchema extends ModelSchema = TModel extends Model<infer S> ? S : ModelSchema>(this: ChildModel<TModel>, data: Partial<TSchema>[]): Promise<TModel[]>;
1337
- /**
1338
- * Find a record or create it if not found.
1339
- *
1340
- * Does NOT update existing records - returns them as-is.
1341
- * Useful when you want to ensure a record exists without modifying it.
1342
- *
1343
- * @param filter - Conditions to find by
1344
- * @param data - Data to create if not found (merged with filter)
1345
- * @returns Promise resolving to found or created model
1346
- *
1347
- * @example
1348
- * ```typescript
1349
- * // Ensure default admin exists (don't modify if exists)
1350
- * const admin = await User.findOrCreate(
1351
- * { email: "admin@example.com" },
1352
- * { email: "admin@example.com", name: "Admin", role: "admin" }
1353
- * );
1354
- * // If admin exists, returns existing (password unchanged)
1355
- * // If not found, creates new admin
1356
- * ```
1357
- */
1358
- static findOrCreate<TModel extends Model = Model, TSchema extends ModelSchema = TModel extends Model<infer S> ? S : ModelSchema>(this: ChildModel<TModel>, filter: Partial<TSchema>, data: Partial<TSchema>): Promise<TModel>;
1359
- /**
1360
- * Upsert (insert or update) a record atomically.
1361
- *
1362
- * Uses the driver's native upsert operation for atomic insert-or-update.
1363
- * More efficient than updateOrCreate as it's a single database operation.
1364
- *
1365
- * Includes full Model features:
1366
- * - ID generation (if creating)
1367
- * - createdAt timestamp (if creating)
1368
- * - updatedAt timestamp (always)
1369
- * - Validation & casting
1370
- * - Lifecycle events
1371
- *
1372
- * @param filter - Conditions to find by (used for conflict detection)
1373
- * @param data - Data to update or create (merged with filter)
1374
- * @param options - Upsert options (conflictColumns for PostgreSQL, etc.)
1375
- * @returns Promise resolving to upserted model
1376
- *
1377
- * @example
1378
- * ```typescript
1379
- * // PostgreSQL: upsert on unique email
1380
- * const user = await User.upsert(
1381
- * { email: "user@example.com" },
1382
- * {
1383
- * email: "user@example.com",
1384
- * name: "John Updated",
1385
- * lastSyncedAt: new Date()
1386
- * },
1387
- * { conflictColumns: ["email"] }
1388
- * );
1389
- *
1390
- * // MongoDB: upsert by filter
1391
- * const user = await User.upsert(
1392
- * { externalId: "ext-123" },
1393
- * {
1394
- * externalId: "ext-123",
1395
- * name: "John Updated",
1396
- * email: "john.new@example.com"
1397
- * }
1398
- * );
1399
- * ```
1400
- */
1401
- static upsert<TModel extends Model = Model, TSchema extends ModelSchema = TModel extends Model<infer S> ? S : ModelSchema>(this: ChildModel<TModel>, filter: Partial<TSchema>, data: Partial<TSchema>, options?: Record<string, unknown>): Promise<TModel>;
1402
- /**
1403
- * Update a record or create it if not found (upsert).
1404
- *
1405
- * @deprecated Use `upsert()` instead for better performance and atomicity.
1406
- * This method is kept for backward compatibility but uses upsert internally.
1407
- *
1408
- * @param filter - Conditions to find by
1409
- * @param data - Data to update or create (merged with filter)
1410
- * @returns Promise resolving to updated or created model
1411
- */
1412
- static updateOrCreate<TModel extends Model = Model, TSchema extends ModelSchema = TModel extends Model<infer S> ? S : ModelSchema>(this: ChildModel<TModel>, filter: Partial<TSchema>, data: Partial<TSchema>, options?: Record<string, unknown>): Promise<TModel>;
1413
- /**
1414
- * Find one and delete a record that matches the filter and return the deleted record.
1415
- *
1416
- * @param filter - Filter conditions
1417
- * @param options - Optional delete options
1418
- * @returns The deleted model instance or null if not found
1419
- *
1420
- * @example
1421
- * ```typescript
1422
- * const deleted = await User.findOneAndDelete({ id: 1 });
1423
- * if (deleted) {
1424
- * console.log('Deleted user:', deleted.get('name'));
1425
- * }
1426
- * ```
1427
- */
1428
- static findOneAndDelete<TModel extends Model = Model>(this: ChildModel<TModel>, filter: Record<string, unknown>, options?: Record<string, unknown>): Promise<TModel | null>;
1429
- /**
1430
- * Returns embedded data for sync operations.
1431
- * Excludes internal MongoDB fields and ensures proper date serialization.
1432
- *
1433
- * @returns Embedded data object suitable for syncing
1434
- *
1435
- * @example
1436
- * ```typescript
1437
- * const user = await User.find(1);
1438
- * const embedData = user.embedData;
1439
- * // Returns: { id: 1, name: "Alice", email: "alice@example.com", ... }
1440
- * // Excludes: _id
1441
- * ```
1442
- */
1443
- get embedData(): Record<string, unknown>;
1444
- /**
1445
- * Cleanup model events
1446
- */
1447
- static $cleanup(): void;
1448
- /**
1449
- * Accesses the event emitter dedicated to this model constructor.
1450
- *
1451
- * Each model subclass gets its own isolated event emitter, allowing you to
1452
- * register lifecycle hooks that only apply to that specific model.
1453
- *
1454
- * @returns The ModelEvents instance for this model constructor
1455
- *
1456
- * @example
1457
- * ```typescript
1458
- * User.events().onSaving((user) => {
1459
- * console.log("User is being saved:", user);
1460
- * });
1461
- * ```
1462
- */
1463
- static events<TModel extends Model = Model>(this: ChildModel<TModel>): ModelEvents<TModel>;
1464
- /**
1465
- * Registers an event listener for this model constructor.
1466
- *
1467
- * Convenience shorthand for `Model.events().on(...)`.
1468
- *
1469
- * @param event - The event name (e.g., "saving", "created")
1470
- * @param listener - The callback to invoke when the event fires
1471
- * @returns An unsubscribe function
1472
- *
1473
- * @example
1474
- * ```typescript
1475
- * const unsubscribe = User.on("saving", (user) => {
1476
- * console.log("Saving user:", user);
1477
- * });
1478
- * ```
1479
- */
1480
- static on<TModel extends Model = Model, TContext = unknown>(this: ChildModel<TModel>, event: ModelEventName, listener: ModelEventListener<TModel, TContext>): () => void;
1481
- /**
1482
- * Registers a one-time event listener for this model constructor.
1483
- *
1484
- * The listener will automatically unsubscribe after its first invocation.
1485
- * Convenience shorthand for `Model.events().once(...)`.
1486
- *
1487
- * @param event - The event name (e.g., "saving", "created")
1488
- * @param listener - The callback to invoke when the event fires
1489
- * @returns An unsubscribe function
1490
- *
1491
- * @example
1492
- * ```typescript
1493
- * User.once("created", (user) => {
1494
- * console.log("First user created:", user);
1495
- * });
1496
- * ```
1497
- */
1498
- static once<TModel extends Model = Model, TContext = unknown>(this: ChildModel<TModel>, event: ModelEventName, listener: ModelEventListener<TModel, TContext>): () => void;
1499
- /**
1500
- * Removes an event listener from this model constructor.
1501
- *
1502
- * Convenience shorthand for `Model.events().off(...)`.
1503
- *
1504
- * @param event - The event name
1505
- * @param listener - The callback to remove
1506
- *
1507
- * @example
1508
- * ```typescript
1509
- * const listener = (user) => console.log(user);
1510
- * User.on("saving", listener);
1511
- * User.off("saving", listener);
1512
- * ```
1513
- */
1514
- static off<TModel extends Model = Model, TContext = unknown>(this: ChildModel<TModel>, event: ModelEventName, listener: ModelEventListener<TModel, TContext>): void;
1515
- /**
1516
- * Accesses the global event emitter shared by all model instances.
1517
- *
1518
- * Use this for cross-cutting concerns like auditing, logging, or injecting
1519
- * common fields (e.g., `createdBy`, `updatedBy`) across all models.
1520
- *
1521
- * @returns The global ModelEvents instance
1522
- *
1523
- * @example
1524
- * ```typescript
1525
- * Model.globalEvents().onSaving((model) => {
1526
- * model.set("updatedAt", new Date());
1527
- * });
1528
- * ```
1529
- */
1530
- static globalEvents(): ModelEvents<Model>;
1531
- /**
1532
- * Replace the model's data entirely.
1533
- *
1534
- * Used internally by the writer after validation to update the model
1535
- * with validated/casted data.
1536
- *
1537
- * **Warning:** This replaces all data and updates the dirty tracker.
1538
- * Use with caution in application code.
1539
- *
1540
- * @param data - New data to replace current data
1541
- *
1542
- * @example
1543
- * ```typescript
1544
- * // Internal usage by writer
1545
- * model.replaceData(validatedData);
1546
- * ```
1547
- */
1548
- replaceData(data: Record<string, unknown>): void;
1549
- /**
1550
- * Save the model to the database.
1551
- *
1552
- * Performs insert if `isNew === true`, otherwise performs update.
1553
- * Automatically validates, casts, generates IDs, and emits lifecycle events.
1554
- *
1555
- * **Features:**
1556
- * - Validation via @warlock.js/seal schema
1557
- * - Data casting (string → number, etc.)
1558
- * - ID generation (NoSQL only)
1559
- * - Partial updates (only changed fields)
1560
- * - Lifecycle events (validating, saving, created/updated, saved)
1561
- *
1562
- * @param data - Optional data to merge before saving
1563
- * @param options - Save options
1564
- * @returns The model instance for method chaining
1565
- *
1566
- * @throws {ValidationError} If validation fails
1567
- * @throws {Error} If database operation fails
1568
- *
1569
- * @example
1570
- * ```typescript
1571
- * // Simple save
1572
- * const user = new User({ name: "Alice" });
1573
- * await user.save();
1574
- *
1575
- * // Merge data before saving
1576
- * await user.save({ age: 31, email: "alice@example.com" });
1577
- *
1578
- * // Silent save (no events)
1579
- * await user.save(null, { skipEvents: true });
1580
- *
1581
- * // Skip validation
1582
- * await user.save(null, { skipValidation: true });
1583
- *
1584
- * // Method chaining
1585
- * await user.set("name", "Bob").save();
1586
- * ```
1587
- */
1588
- save(options?: WriterOptions & {
1589
- merge?: Partial<TSchema>;
1590
- }): Promise<this>;
1591
- /**
1592
- * Serialize the model data for storage in the database.
1593
- *
1594
- * Uses the driver's `serialize` to apply driver-specific type transformations
1595
- * (e.g. Date → ISO string, BigInt → string for Postgres).
1596
- *
1597
- * **Not** the same as `toSnapshot` — this is a DB write concern, not a cache concern.
1598
- */
1599
- serialize(): Record<string, unknown>;
1600
- /**
1601
- * Produce a plain-object snapshot of this model suitable for cache storage.
1602
- *
1603
- * - `data`: The model's own fields, serialized via the driver (handles Dates, BigInt, ObjectId).
1604
- * - `relations`: Each entry in `loadedRelations` recursively snapshotted via `toSnapshot`.
1605
- * A relation that was loaded but resolved to `null` is stored as `null` (not omitted),
1606
- * so that `fromSnapshot` can distinguish "loaded + null" from "never loaded".
1607
- *
1608
- * Use `Model.fromSnapshot(snapshot)` to reconstruct.
1609
- *
1610
- * @example
1611
- * ```typescript
1612
- * await cache.set(key, chat.toSnapshot());
1613
- * ```
1614
- */
1615
- toSnapshot(): ModelSnapshot;
1616
- /**
1617
- * Reconstruct a model instance (with relations) from a cache snapshot.
1618
- *
1619
- * Counterpart to `toSnapshot`. Applies driver deserialization (e.g. ISO string → Date)
1620
- * and recursively hydrates any nested relation snapshots via `RelationHydrator`.
1621
- *
1622
- * @example
1623
- * ```typescript
1624
- * const snapshot = await cache.get(key);
1625
- * const chat = Chat.fromSnapshot(snapshot);
1626
- * chat.unit; // Unit model instance, fully hydrated
1627
- * ```
1628
- */
1629
- static fromSnapshot<TModel extends Model>(this: ChildModel<TModel>, snapshot: ModelSnapshot): TModel;
1630
- /**
1631
- * Create a model instance from raw data (no relations).
1632
- *
1633
- * This is the data-only hydration path, used by the query builder when
1634
- * converting a raw DB row into a model instance. Relations are NOT restored
1635
- * here — use `fromSnapshot` when restoring from a cache snapshot that
1636
- * includes relation data.
1637
- *
1638
- * @example
1639
- * ```typescript
1640
- * // Query builder internals:
1641
- * const user = User.hydrate(rawRow);
1642
- * ```
1643
- */
1644
- static hydrate<TModel extends Model = Model>(this: ChildModel<TModel>, data: Record<string, unknown>): TModel;
1645
- /**
1646
- * Convert the model into JSON
1647
- */
1648
- toJSON(): Record<string, unknown>;
1649
- }
1650
- //# sourceMappingURL=model.d.ts.map