@warlock.js/cascade 4.0.48 → 4.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. package/cjs/context/database-data-source-context.d.ts +29 -0
  2. package/cjs/context/database-data-source-context.d.ts.map +1 -0
  3. package/cjs/context/database-data-source-context.js +28 -0
  4. package/cjs/context/database-data-source-context.js.map +1 -0
  5. package/cjs/context/database-transaction-context.d.ts +31 -0
  6. package/cjs/context/database-transaction-context.d.ts.map +1 -0
  7. package/cjs/context/database-transaction-context.js +34 -0
  8. package/cjs/context/database-transaction-context.js.map +1 -0
  9. package/cjs/contracts/database-driver.contract.d.ts +143 -0
  10. package/cjs/contracts/database-driver.contract.d.ts.map +1 -0
  11. package/cjs/contracts/database-id-generator.contract.d.ts +109 -0
  12. package/cjs/contracts/database-id-generator.contract.d.ts.map +1 -0
  13. package/cjs/contracts/database-remover.contract.d.ts +104 -0
  14. package/cjs/contracts/database-remover.contract.d.ts.map +1 -0
  15. package/cjs/contracts/database-restorer.contract.d.ts +143 -0
  16. package/cjs/contracts/database-restorer.contract.d.ts.map +1 -0
  17. package/cjs/contracts/database-writer.contract.d.ts +119 -0
  18. package/cjs/contracts/database-writer.contract.d.ts.map +1 -0
  19. package/cjs/contracts/driver-blueprint.contract.d.ts +45 -0
  20. package/cjs/contracts/driver-blueprint.contract.d.ts.map +1 -0
  21. package/cjs/contracts/index.d.ts +10 -0
  22. package/cjs/contracts/index.d.ts.map +1 -0
  23. package/cjs/contracts/migration-driver.contract.d.ts +365 -0
  24. package/cjs/contracts/migration-driver.contract.d.ts.map +1 -0
  25. package/cjs/contracts/query-builder.contract.d.ts +1128 -0
  26. package/cjs/contracts/query-builder.contract.d.ts.map +1 -0
  27. package/cjs/contracts/sync-adapter.contract.d.ts +58 -0
  28. package/cjs/contracts/sync-adapter.contract.d.ts.map +1 -0
  29. package/cjs/data-source/data-source-registry.d.ts +104 -0
  30. package/cjs/data-source/data-source-registry.d.ts.map +1 -0
  31. package/cjs/data-source/data-source-registry.js +138 -0
  32. package/cjs/data-source/data-source-registry.js.map +1 -0
  33. package/cjs/data-source/data-source.d.ts +106 -0
  34. package/cjs/data-source/data-source.d.ts.map +1 -0
  35. package/cjs/data-source/data-source.js +77 -0
  36. package/cjs/data-source/data-source.js.map +1 -0
  37. package/cjs/database-dirty-tracker.d.ts +253 -0
  38. package/cjs/database-dirty-tracker.d.ts.map +1 -0
  39. package/cjs/database-dirty-tracker.js +389 -0
  40. package/cjs/database-dirty-tracker.js.map +1 -0
  41. package/cjs/drivers/mongo/mongo-id-generator.d.ts +116 -0
  42. package/cjs/drivers/mongo/mongo-id-generator.d.ts.map +1 -0
  43. package/cjs/drivers/mongo/mongo-id-generator.js +149 -0
  44. package/cjs/drivers/mongo/mongo-id-generator.js.map +1 -0
  45. package/cjs/drivers/mongo/mongo-migration-driver.d.ts +228 -0
  46. package/cjs/drivers/mongo/mongo-migration-driver.d.ts.map +1 -0
  47. package/cjs/drivers/mongo/mongo-migration-driver.js +524 -0
  48. package/cjs/drivers/mongo/mongo-migration-driver.js.map +1 -0
  49. package/cjs/drivers/mongo/mongo-query-builder.d.ts +922 -0
  50. package/cjs/drivers/mongo/mongo-query-builder.d.ts.map +1 -0
  51. package/cjs/drivers/mongo/mongo-query-builder.js +1740 -0
  52. package/cjs/drivers/mongo/mongo-query-builder.js.map +1 -0
  53. package/cjs/drivers/mongo/mongo-query-operations.d.ts +226 -0
  54. package/cjs/drivers/mongo/mongo-query-operations.d.ts.map +1 -0
  55. package/cjs/drivers/mongo/mongo-query-operations.js +270 -0
  56. package/cjs/drivers/mongo/mongo-query-operations.js.map +1 -0
  57. package/cjs/drivers/mongo/mongo-query-parser.d.ts +262 -0
  58. package/cjs/drivers/mongo/mongo-query-parser.d.ts.map +1 -0
  59. package/cjs/drivers/mongo/mongo-query-parser.js +1351 -0
  60. package/cjs/drivers/mongo/mongo-query-parser.js.map +1 -0
  61. package/cjs/drivers/mongo/mongo-sync-adapter.d.ts +79 -0
  62. package/cjs/drivers/mongo/mongo-sync-adapter.d.ts.map +1 -0
  63. package/cjs/drivers/mongo/mongo-sync-adapter.js +146 -0
  64. package/cjs/drivers/mongo/mongo-sync-adapter.js.map +1 -0
  65. package/cjs/drivers/mongo/mongodb-blueprint.d.ts +30 -0
  66. package/cjs/drivers/mongo/mongodb-blueprint.d.ts.map +1 -0
  67. package/cjs/drivers/mongo/mongodb-blueprint.js +51 -0
  68. package/cjs/drivers/mongo/mongodb-blueprint.js.map +1 -0
  69. package/cjs/drivers/mongo/mongodb-driver.d.ts +188 -0
  70. package/cjs/drivers/mongo/mongodb-driver.d.ts.map +1 -0
  71. package/cjs/drivers/mongo/mongodb-driver.js +411 -0
  72. package/cjs/drivers/mongo/mongodb-driver.js.map +1 -0
  73. package/cjs/drivers/mongo/types.d.ts +43 -0
  74. package/cjs/drivers/mongo/types.d.ts.map +1 -0
  75. package/cjs/errors/missing-data-source.error.d.ts +22 -0
  76. package/cjs/errors/missing-data-source.error.d.ts.map +1 -0
  77. package/cjs/errors/missing-data-source.error.js +29 -0
  78. package/cjs/errors/missing-data-source.error.js.map +1 -0
  79. package/cjs/events/model-events.d.ts +231 -0
  80. package/cjs/events/model-events.d.ts.map +1 -0
  81. package/cjs/events/model-events.js +259 -0
  82. package/cjs/events/model-events.js.map +1 -0
  83. package/cjs/expressions/aggregate-expressions.d.ts +215 -0
  84. package/cjs/expressions/aggregate-expressions.d.ts.map +1 -0
  85. package/cjs/expressions/aggregate-expressions.js +221 -0
  86. package/cjs/expressions/aggregate-expressions.js.map +1 -0
  87. package/cjs/expressions/index.d.ts +2 -0
  88. package/cjs/expressions/index.d.ts.map +1 -0
  89. package/cjs/index.d.ts +41 -0
  90. package/cjs/index.d.ts.map +1 -0
  91. package/cjs/index.js +1 -267
  92. package/cjs/index.js.map +1 -1
  93. package/cjs/migration/column-builder.d.ts +167 -0
  94. package/cjs/migration/column-builder.d.ts.map +1 -0
  95. package/cjs/migration/column-builder.js +217 -0
  96. package/cjs/migration/column-builder.js.map +1 -0
  97. package/cjs/migration/foreign-key-builder.d.ts +110 -0
  98. package/cjs/migration/foreign-key-builder.d.ts.map +1 -0
  99. package/cjs/migration/foreign-key-builder.js +129 -0
  100. package/cjs/migration/foreign-key-builder.js.map +1 -0
  101. package/cjs/migration/index.d.ts +6 -0
  102. package/cjs/migration/index.d.ts.map +1 -0
  103. package/cjs/migration/migration-runner.d.ts +231 -0
  104. package/cjs/migration/migration-runner.d.ts.map +1 -0
  105. package/cjs/migration/migration-runner.js +443 -0
  106. package/cjs/migration/migration-runner.js.map +1 -0
  107. package/cjs/migration/migration.js +1346 -0
  108. package/cjs/migration/migration.js.map +1 -0
  109. package/cjs/migration/types.d.ts +132 -0
  110. package/cjs/migration/types.d.ts.map +1 -0
  111. package/cjs/model/model.d.ts +1267 -0
  112. package/cjs/model/model.d.ts.map +1 -0
  113. package/cjs/model/model.js +1463 -0
  114. package/cjs/model/model.js.map +1 -0
  115. package/cjs/model/register-model.d.ts +80 -0
  116. package/cjs/model/register-model.d.ts.map +1 -0
  117. package/cjs/model/register-model.js +91 -0
  118. package/cjs/model/register-model.js.map +1 -0
  119. package/cjs/remover/database-remover.d.ts +100 -0
  120. package/cjs/remover/database-remover.d.ts.map +1 -0
  121. package/cjs/remover/database-remover.js +209 -0
  122. package/cjs/remover/database-remover.js.map +1 -0
  123. package/cjs/restorer/database-restorer.d.ts +131 -0
  124. package/cjs/restorer/database-restorer.d.ts.map +1 -0
  125. package/cjs/restorer/database-restorer.js +425 -0
  126. package/cjs/restorer/database-restorer.js.map +1 -0
  127. package/cjs/sync/index.d.ts +12 -0
  128. package/cjs/sync/index.d.ts.map +1 -0
  129. package/cjs/sync/model-events.d.ts +62 -0
  130. package/cjs/sync/model-events.d.ts.map +1 -0
  131. package/cjs/sync/model-events.js +49 -0
  132. package/cjs/sync/model-events.js.map +1 -0
  133. package/cjs/sync/model-sync-operation.d.ts +163 -0
  134. package/cjs/sync/model-sync-operation.d.ts.map +1 -0
  135. package/cjs/sync/model-sync-operation.js +292 -0
  136. package/cjs/sync/model-sync-operation.js.map +1 -0
  137. package/cjs/sync/model-sync.d.ts +130 -0
  138. package/cjs/sync/model-sync.d.ts.map +1 -0
  139. package/cjs/sync/model-sync.js +178 -0
  140. package/cjs/sync/model-sync.js.map +1 -0
  141. package/cjs/sync/sync-context.d.ts +70 -0
  142. package/cjs/sync/sync-context.d.ts.map +1 -0
  143. package/cjs/sync/sync-context.js +101 -0
  144. package/cjs/sync/sync-context.js.map +1 -0
  145. package/cjs/sync/sync-manager.d.ts +213 -0
  146. package/cjs/sync/sync-manager.d.ts.map +1 -0
  147. package/cjs/sync/sync-manager.js +689 -0
  148. package/cjs/sync/sync-manager.js.map +1 -0
  149. package/cjs/sync/types.d.ts +289 -0
  150. package/cjs/sync/types.d.ts.map +1 -0
  151. package/cjs/types.d.ts +45 -0
  152. package/cjs/types.d.ts.map +1 -0
  153. package/cjs/utils/connect-to-database.d.ts +246 -0
  154. package/cjs/utils/connect-to-database.d.ts.map +1 -0
  155. package/cjs/utils/connect-to-database.js +92 -0
  156. package/cjs/utils/connect-to-database.js.map +1 -0
  157. package/cjs/utils/database-writer.utils.d.ts +15 -0
  158. package/cjs/utils/database-writer.utils.d.ts.map +1 -0
  159. package/cjs/utils/database-writer.utils.js +14 -0
  160. package/cjs/utils/database-writer.utils.js.map +1 -0
  161. package/cjs/utils/define-model.js +100 -0
  162. package/cjs/utils/define-model.js.map +1 -0
  163. package/cjs/utils/once-connected.d.ts +146 -0
  164. package/cjs/utils/once-connected.d.ts.map +1 -0
  165. package/cjs/utils/once-connected.js +252 -0
  166. package/cjs/utils/once-connected.js.map +1 -0
  167. package/cjs/validation/database-seal-plugins.d.ts +2 -0
  168. package/cjs/validation/database-seal-plugins.d.ts.map +1 -0
  169. package/cjs/validation/database-seal-plugins.js +4 -0
  170. package/cjs/validation/database-seal-plugins.js.map +1 -0
  171. package/cjs/validation/database-writer-validation-error.d.ts +97 -0
  172. package/cjs/validation/database-writer-validation-error.d.ts.map +1 -0
  173. package/cjs/validation/database-writer-validation-error.js +160 -0
  174. package/cjs/validation/database-writer-validation-error.js.map +1 -0
  175. package/cjs/validation/index.d.ts +3 -0
  176. package/cjs/validation/index.d.ts.map +1 -0
  177. package/cjs/validation/mutators/embed-mutator.d.ts +9 -0
  178. package/cjs/validation/mutators/embed-mutator.d.ts.map +1 -0
  179. package/cjs/validation/mutators/embed-mutator.js +33 -0
  180. package/cjs/validation/mutators/embed-mutator.js.map +1 -0
  181. package/cjs/validation/plugins/embed-validator-plugin.d.ts +24 -0
  182. package/cjs/validation/plugins/embed-validator-plugin.d.ts.map +1 -0
  183. package/cjs/validation/plugins/embed-validator-plugin.js +18 -0
  184. package/cjs/validation/plugins/embed-validator-plugin.js.map +1 -0
  185. package/cjs/validation/rules/database-model-rule.d.ts +7 -0
  186. package/cjs/validation/rules/database-model-rule.d.ts.map +1 -0
  187. package/cjs/validation/rules/database-model-rule.js +27 -0
  188. package/cjs/validation/rules/database-model-rule.js.map +1 -0
  189. package/cjs/validation/transformers/embed-model-transformer.d.ts +3 -0
  190. package/cjs/validation/transformers/embed-model-transformer.d.ts.map +1 -0
  191. package/cjs/validation/transformers/embed-model-transformer.js +18 -0
  192. package/cjs/validation/transformers/embed-model-transformer.js.map +1 -0
  193. package/cjs/validation/validators/embed-validator.d.ts +21 -0
  194. package/cjs/validation/validators/embed-validator.d.ts.map +1 -0
  195. package/cjs/validation/validators/embed-validator.js +42 -0
  196. package/cjs/validation/validators/embed-validator.js.map +1 -0
  197. package/cjs/writer/database-writer.d.ts +181 -0
  198. package/cjs/writer/database-writer.d.ts.map +1 -0
  199. package/cjs/writer/database-writer.js +402 -0
  200. package/cjs/writer/database-writer.js.map +1 -0
  201. package/esm/context/database-data-source-context.d.ts +29 -0
  202. package/esm/context/database-data-source-context.d.ts.map +1 -0
  203. package/esm/context/database-data-source-context.js +28 -0
  204. package/esm/context/database-data-source-context.js.map +1 -0
  205. package/esm/context/database-transaction-context.d.ts +31 -0
  206. package/esm/context/database-transaction-context.d.ts.map +1 -0
  207. package/esm/context/database-transaction-context.js +34 -0
  208. package/esm/context/database-transaction-context.js.map +1 -0
  209. package/esm/contracts/database-driver.contract.d.ts +143 -0
  210. package/esm/contracts/database-driver.contract.d.ts.map +1 -0
  211. package/esm/contracts/database-id-generator.contract.d.ts +109 -0
  212. package/esm/contracts/database-id-generator.contract.d.ts.map +1 -0
  213. package/esm/contracts/database-remover.contract.d.ts +104 -0
  214. package/esm/contracts/database-remover.contract.d.ts.map +1 -0
  215. package/esm/contracts/database-restorer.contract.d.ts +143 -0
  216. package/esm/contracts/database-restorer.contract.d.ts.map +1 -0
  217. package/esm/contracts/database-writer.contract.d.ts +119 -0
  218. package/esm/contracts/database-writer.contract.d.ts.map +1 -0
  219. package/esm/contracts/driver-blueprint.contract.d.ts +45 -0
  220. package/esm/contracts/driver-blueprint.contract.d.ts.map +1 -0
  221. package/esm/contracts/index.d.ts +10 -0
  222. package/esm/contracts/index.d.ts.map +1 -0
  223. package/esm/contracts/migration-driver.contract.d.ts +365 -0
  224. package/esm/contracts/migration-driver.contract.d.ts.map +1 -0
  225. package/esm/contracts/query-builder.contract.d.ts +1128 -0
  226. package/esm/contracts/query-builder.contract.d.ts.map +1 -0
  227. package/esm/contracts/sync-adapter.contract.d.ts +58 -0
  228. package/esm/contracts/sync-adapter.contract.d.ts.map +1 -0
  229. package/esm/data-source/data-source-registry.d.ts +104 -0
  230. package/esm/data-source/data-source-registry.d.ts.map +1 -0
  231. package/esm/data-source/data-source-registry.js +138 -0
  232. package/esm/data-source/data-source-registry.js.map +1 -0
  233. package/esm/data-source/data-source.d.ts +106 -0
  234. package/esm/data-source/data-source.d.ts.map +1 -0
  235. package/esm/data-source/data-source.js +77 -0
  236. package/esm/data-source/data-source.js.map +1 -0
  237. package/esm/database-dirty-tracker.d.ts +253 -0
  238. package/esm/database-dirty-tracker.d.ts.map +1 -0
  239. package/esm/database-dirty-tracker.js +389 -0
  240. package/esm/database-dirty-tracker.js.map +1 -0
  241. package/esm/drivers/mongo/mongo-id-generator.d.ts +116 -0
  242. package/esm/drivers/mongo/mongo-id-generator.d.ts.map +1 -0
  243. package/esm/drivers/mongo/mongo-id-generator.js +149 -0
  244. package/esm/drivers/mongo/mongo-id-generator.js.map +1 -0
  245. package/esm/drivers/mongo/mongo-migration-driver.d.ts +228 -0
  246. package/esm/drivers/mongo/mongo-migration-driver.d.ts.map +1 -0
  247. package/esm/drivers/mongo/mongo-migration-driver.js +524 -0
  248. package/esm/drivers/mongo/mongo-migration-driver.js.map +1 -0
  249. package/esm/drivers/mongo/mongo-query-builder.d.ts +922 -0
  250. package/esm/drivers/mongo/mongo-query-builder.d.ts.map +1 -0
  251. package/esm/drivers/mongo/mongo-query-builder.js +1740 -0
  252. package/esm/drivers/mongo/mongo-query-builder.js.map +1 -0
  253. package/esm/drivers/mongo/mongo-query-operations.d.ts +226 -0
  254. package/esm/drivers/mongo/mongo-query-operations.d.ts.map +1 -0
  255. package/esm/drivers/mongo/mongo-query-operations.js +270 -0
  256. package/esm/drivers/mongo/mongo-query-operations.js.map +1 -0
  257. package/esm/drivers/mongo/mongo-query-parser.d.ts +262 -0
  258. package/esm/drivers/mongo/mongo-query-parser.d.ts.map +1 -0
  259. package/esm/drivers/mongo/mongo-query-parser.js +1351 -0
  260. package/esm/drivers/mongo/mongo-query-parser.js.map +1 -0
  261. package/esm/drivers/mongo/mongo-sync-adapter.d.ts +79 -0
  262. package/esm/drivers/mongo/mongo-sync-adapter.d.ts.map +1 -0
  263. package/esm/drivers/mongo/mongo-sync-adapter.js +146 -0
  264. package/esm/drivers/mongo/mongo-sync-adapter.js.map +1 -0
  265. package/esm/drivers/mongo/mongodb-blueprint.d.ts +30 -0
  266. package/esm/drivers/mongo/mongodb-blueprint.d.ts.map +1 -0
  267. package/esm/drivers/mongo/mongodb-blueprint.js +51 -0
  268. package/esm/drivers/mongo/mongodb-blueprint.js.map +1 -0
  269. package/esm/drivers/mongo/mongodb-driver.d.ts +188 -0
  270. package/esm/drivers/mongo/mongodb-driver.d.ts.map +1 -0
  271. package/esm/drivers/mongo/mongodb-driver.js +411 -0
  272. package/esm/drivers/mongo/mongodb-driver.js.map +1 -0
  273. package/esm/drivers/mongo/types.d.ts +43 -0
  274. package/esm/drivers/mongo/types.d.ts.map +1 -0
  275. package/esm/errors/missing-data-source.error.d.ts +22 -0
  276. package/esm/errors/missing-data-source.error.d.ts.map +1 -0
  277. package/esm/errors/missing-data-source.error.js +29 -0
  278. package/esm/errors/missing-data-source.error.js.map +1 -0
  279. package/esm/events/model-events.d.ts +231 -0
  280. package/esm/events/model-events.d.ts.map +1 -0
  281. package/esm/events/model-events.js +259 -0
  282. package/esm/events/model-events.js.map +1 -0
  283. package/esm/expressions/aggregate-expressions.d.ts +215 -0
  284. package/esm/expressions/aggregate-expressions.d.ts.map +1 -0
  285. package/esm/expressions/aggregate-expressions.js +221 -0
  286. package/esm/expressions/aggregate-expressions.js.map +1 -0
  287. package/esm/expressions/index.d.ts +2 -0
  288. package/esm/expressions/index.d.ts.map +1 -0
  289. package/esm/index.d.ts +41 -0
  290. package/esm/index.d.ts.map +1 -0
  291. package/esm/index.js +1 -40
  292. package/esm/index.js.map +1 -1
  293. package/esm/migration/column-builder.d.ts +167 -0
  294. package/esm/migration/column-builder.d.ts.map +1 -0
  295. package/esm/migration/column-builder.js +217 -0
  296. package/esm/migration/column-builder.js.map +1 -0
  297. package/esm/migration/foreign-key-builder.d.ts +110 -0
  298. package/esm/migration/foreign-key-builder.d.ts.map +1 -0
  299. package/esm/migration/foreign-key-builder.js +129 -0
  300. package/esm/migration/foreign-key-builder.js.map +1 -0
  301. package/esm/migration/index.d.ts +6 -0
  302. package/esm/migration/index.d.ts.map +1 -0
  303. package/esm/migration/migration-runner.d.ts +231 -0
  304. package/esm/migration/migration-runner.d.ts.map +1 -0
  305. package/esm/migration/migration-runner.js +443 -0
  306. package/esm/migration/migration-runner.js.map +1 -0
  307. package/esm/migration/migration.js +1346 -0
  308. package/esm/migration/migration.js.map +1 -0
  309. package/esm/migration/types.d.ts +132 -0
  310. package/esm/migration/types.d.ts.map +1 -0
  311. package/esm/model/model.d.ts +1267 -0
  312. package/esm/model/model.d.ts.map +1 -0
  313. package/esm/model/model.js +1463 -0
  314. package/esm/model/model.js.map +1 -0
  315. package/esm/model/register-model.d.ts +80 -0
  316. package/esm/model/register-model.d.ts.map +1 -0
  317. package/esm/model/register-model.js +91 -0
  318. package/esm/model/register-model.js.map +1 -0
  319. package/esm/remover/database-remover.d.ts +100 -0
  320. package/esm/remover/database-remover.d.ts.map +1 -0
  321. package/esm/remover/database-remover.js +209 -0
  322. package/esm/remover/database-remover.js.map +1 -0
  323. package/esm/restorer/database-restorer.d.ts +131 -0
  324. package/esm/restorer/database-restorer.d.ts.map +1 -0
  325. package/esm/restorer/database-restorer.js +425 -0
  326. package/esm/restorer/database-restorer.js.map +1 -0
  327. package/esm/sync/index.d.ts +12 -0
  328. package/esm/sync/index.d.ts.map +1 -0
  329. package/esm/sync/model-events.d.ts +62 -0
  330. package/esm/sync/model-events.d.ts.map +1 -0
  331. package/esm/sync/model-events.js +49 -0
  332. package/esm/sync/model-events.js.map +1 -0
  333. package/esm/sync/model-sync-operation.d.ts +163 -0
  334. package/esm/sync/model-sync-operation.d.ts.map +1 -0
  335. package/esm/sync/model-sync-operation.js +292 -0
  336. package/esm/sync/model-sync-operation.js.map +1 -0
  337. package/esm/sync/model-sync.d.ts +130 -0
  338. package/esm/sync/model-sync.d.ts.map +1 -0
  339. package/esm/sync/model-sync.js +178 -0
  340. package/esm/sync/model-sync.js.map +1 -0
  341. package/esm/sync/sync-context.d.ts +70 -0
  342. package/esm/sync/sync-context.d.ts.map +1 -0
  343. package/esm/sync/sync-context.js +101 -0
  344. package/esm/sync/sync-context.js.map +1 -0
  345. package/esm/sync/sync-manager.d.ts +213 -0
  346. package/esm/sync/sync-manager.d.ts.map +1 -0
  347. package/esm/sync/sync-manager.js +689 -0
  348. package/esm/sync/sync-manager.js.map +1 -0
  349. package/esm/sync/types.d.ts +289 -0
  350. package/esm/sync/types.d.ts.map +1 -0
  351. package/esm/types.d.ts +45 -0
  352. package/esm/types.d.ts.map +1 -0
  353. package/esm/utils/connect-to-database.d.ts +246 -0
  354. package/esm/utils/connect-to-database.d.ts.map +1 -0
  355. package/esm/utils/connect-to-database.js +92 -0
  356. package/esm/utils/connect-to-database.js.map +1 -0
  357. package/esm/utils/database-writer.utils.d.ts +15 -0
  358. package/esm/utils/database-writer.utils.d.ts.map +1 -0
  359. package/esm/utils/database-writer.utils.js +14 -0
  360. package/esm/utils/database-writer.utils.js.map +1 -0
  361. package/esm/utils/define-model.js +100 -0
  362. package/esm/utils/define-model.js.map +1 -0
  363. package/esm/utils/once-connected.d.ts +146 -0
  364. package/esm/utils/once-connected.d.ts.map +1 -0
  365. package/esm/utils/once-connected.js +252 -0
  366. package/esm/utils/once-connected.js.map +1 -0
  367. package/esm/validation/database-seal-plugins.d.ts +2 -0
  368. package/esm/validation/database-seal-plugins.d.ts.map +1 -0
  369. package/esm/validation/database-seal-plugins.js +4 -0
  370. package/esm/validation/database-seal-plugins.js.map +1 -0
  371. package/esm/validation/database-writer-validation-error.d.ts +97 -0
  372. package/esm/validation/database-writer-validation-error.d.ts.map +1 -0
  373. package/esm/validation/database-writer-validation-error.js +160 -0
  374. package/esm/validation/database-writer-validation-error.js.map +1 -0
  375. package/esm/validation/index.d.ts +3 -0
  376. package/esm/validation/index.d.ts.map +1 -0
  377. package/esm/validation/mutators/embed-mutator.d.ts +9 -0
  378. package/esm/validation/mutators/embed-mutator.d.ts.map +1 -0
  379. package/esm/validation/mutators/embed-mutator.js +33 -0
  380. package/esm/validation/mutators/embed-mutator.js.map +1 -0
  381. package/esm/validation/plugins/embed-validator-plugin.d.ts +24 -0
  382. package/esm/validation/plugins/embed-validator-plugin.d.ts.map +1 -0
  383. package/esm/validation/plugins/embed-validator-plugin.js +18 -0
  384. package/esm/validation/plugins/embed-validator-plugin.js.map +1 -0
  385. package/esm/validation/rules/database-model-rule.d.ts +7 -0
  386. package/esm/validation/rules/database-model-rule.d.ts.map +1 -0
  387. package/esm/validation/rules/database-model-rule.js +27 -0
  388. package/esm/validation/rules/database-model-rule.js.map +1 -0
  389. package/esm/validation/transformers/embed-model-transformer.d.ts +3 -0
  390. package/esm/validation/transformers/embed-model-transformer.d.ts.map +1 -0
  391. package/esm/validation/transformers/embed-model-transformer.js +18 -0
  392. package/esm/validation/transformers/embed-model-transformer.js.map +1 -0
  393. package/esm/validation/validators/embed-validator.d.ts +21 -0
  394. package/esm/validation/validators/embed-validator.d.ts.map +1 -0
  395. package/esm/validation/validators/embed-validator.js +42 -0
  396. package/esm/validation/validators/embed-validator.js.map +1 -0
  397. package/esm/writer/database-writer.d.ts +181 -0
  398. package/esm/writer/database-writer.d.ts.map +1 -0
  399. package/esm/writer/database-writer.js +402 -0
  400. package/esm/writer/database-writer.js.map +1 -0
  401. package/package.json +61 -52
@@ -0,0 +1,178 @@
1
+ import {ModelSyncOperation}from'./model-sync-operation.js';/**
2
+ * ModelSync facade for registering sync operations.
3
+ *
4
+ * Provides a clean API for defining sync relationships between models
5
+ * with automatic cleanup support for HMR (Hot Module Replacement).
6
+ *
7
+ * @module cascade-next/sync/model-sync
8
+ */
9
+ /**
10
+ * ModelSync facade implementation.
11
+ *
12
+ * Manages sync operation registration with scoped cleanup support.
13
+ * Uses a registration stack to track operations created during
14
+ * a `register()` callback for proper HMR cleanup.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // In events file
19
+ * export const cleanup = modelSync.register(() => {
20
+ * Category.sync(Product, "category");
21
+ * Tag.syncMany(Post, "tags").identifyBy("id");
22
+ * });
23
+ * ```
24
+ */
25
+ class ModelSyncFacade {
26
+ /**
27
+ * All active sync operations.
28
+ */
29
+ operations = [];
30
+ /**
31
+ * Stack for tracking operations during register() callbacks.
32
+ * Each element is an array of operations created in that scope.
33
+ */
34
+ registrationStack = [];
35
+ // ============================================================================
36
+ // PUBLIC API
37
+ // ============================================================================
38
+ /**
39
+ * Create a sync operation for a single embedded document.
40
+ *
41
+ * When the source model is updated, the target model's field
42
+ * will be updated with the embedded data.
43
+ *
44
+ * @param source - Source model class that triggers sync
45
+ * @param target - Target model class that receives data
46
+ * @param field - Field path in target model
47
+ * @returns Sync operation for chaining configuration
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * // When Category updates, update Product.category
52
+ * modelSync.sync(Category, Product, "category");
53
+ *
54
+ * // With configuration
55
+ * modelSync.sync(Category, Product, "category")
56
+ * .embed("embedMinimal")
57
+ * .watchFields(["name", "slug"]);
58
+ * ```
59
+ */
60
+ sync(source, target, field) {
61
+ const operation = new ModelSyncOperation(source, target, field, false);
62
+ this.trackOperation(operation);
63
+ return operation;
64
+ }
65
+ /**
66
+ * Create a sync operation for an array of embedded documents.
67
+ *
68
+ * When the source model is updated, the corresponding element
69
+ * in the target model's array field will be updated.
70
+ *
71
+ * @param source - Source model class that triggers sync
72
+ * @param target - Target model class that receives data
73
+ * @param field - Array field path in target model
74
+ * @returns Sync operation for chaining configuration
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * // When Tag updates, update Post.tags[i] where tags[i].id matches
79
+ * modelSync.syncMany(Tag, Post, "tags").identifyBy("id");
80
+ * ```
81
+ */
82
+ syncMany(source, target, field) {
83
+ const operation = new ModelSyncOperation(source, target, field, true);
84
+ this.trackOperation(operation);
85
+ return operation;
86
+ }
87
+ /**
88
+ * Register sync operations with automatic cleanup.
89
+ *
90
+ * Executes the callback function which should contain sync registrations.
91
+ * Returns a cleanup function that unsubscribes all operations created
92
+ * during the callback - perfect for HMR module cleanup.
93
+ *
94
+ * @param callback - Function that registers sync operations
95
+ * @returns Cleanup function that unsubscribes all registered operations
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * // In src/app/blog/events/sync.ts
100
+ * export const cleanup = modelSync.register(() => {
101
+ * Category.sync(Product, "category");
102
+ * Tag.syncMany(Post, "tags").identifyBy("id");
103
+ * Author.sync(Article, "author").unsetOnDelete();
104
+ * });
105
+ * ```
106
+ */
107
+ register(callback) {
108
+ // Create a new scope for tracking operations
109
+ const scopedOperations = [];
110
+ this.registrationStack.push(scopedOperations);
111
+ try {
112
+ // Execute callback - operations are tracked via trackOperation()
113
+ callback();
114
+ }
115
+ finally {
116
+ // Remove the scope from stack
117
+ this.registrationStack.pop();
118
+ }
119
+ // Return cleanup function for just these scoped operations
120
+ return () => {
121
+ for (const operation of scopedOperations) {
122
+ operation.unsubscribe();
123
+ // Remove from global operations array
124
+ const index = this.operations.indexOf(operation);
125
+ if (index !== -1) {
126
+ this.operations.splice(index, 1);
127
+ }
128
+ }
129
+ };
130
+ }
131
+ /**
132
+ * Clear all registered sync operations.
133
+ * Useful for testing or complete reset.
134
+ */
135
+ clear() {
136
+ for (const operation of this.operations) {
137
+ operation.unsubscribe();
138
+ }
139
+ this.operations.length = 0;
140
+ }
141
+ /**
142
+ * Get count of active sync operations.
143
+ * Useful for debugging and testing.
144
+ */
145
+ get count() {
146
+ return this.operations.length;
147
+ }
148
+ // ============================================================================
149
+ // PRIVATE HELPERS
150
+ // ============================================================================
151
+ /**
152
+ * Track a new operation in global list and current registration scope.
153
+ */
154
+ trackOperation(operation) {
155
+ // Always add to global operations
156
+ this.operations.push(operation);
157
+ // If inside a register() callback, also track in the current scope
158
+ const currentScope = this.registrationStack[this.registrationStack.length - 1];
159
+ if (currentScope) {
160
+ currentScope.push(operation);
161
+ }
162
+ }
163
+ }
164
+ /**
165
+ * Global modelSync facade instance.
166
+ *
167
+ * Use this to register sync operations between models.
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * import { modelSync } from "@warlock.js/cascade";
172
+ *
173
+ * export const cleanup = modelSync.register(() => {
174
+ * Category.sync(Product, "category");
175
+ * });
176
+ * ```
177
+ */
178
+ const modelSync = new ModelSyncFacade();export{modelSync};//# sourceMappingURL=model-sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-sync.js","sources":["../../src/sync/model-sync.ts"],"sourcesContent":[null],"names":[],"mappings":"2DAAA;;;;;;;AAOG;AAMH;;;;;;;;;;;;;;;AAeG;AACH,MAAM,eAAe,CAAA;AACnB;;AAEG;IACc,UAAU,GAAyB,EAAE,CAAC;AAEvD;;;AAGG;IACc,iBAAiB,GAA2B,EAAE,CAAC;;;;AAMhE;;;;;;;;;;;;;;;;;;;;;AAqBG;AACI,IAAA,IAAI,CACT,MAAyB,EACzB,MAAyB,EACzB,KAAa,EAAA;AAEb,QAAA,MAAM,SAAS,GAAG,IAAI,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AACvE,QAAA,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;AAC/B,QAAA,OAAO,SAAS,CAAC;KAClB;AAED;;;;;;;;;;;;;;;;AAgBG;AACI,IAAA,QAAQ,CACb,MAAyB,EACzB,MAAyB,EACzB,KAAa,EAAA;AAEb,QAAA,MAAM,SAAS,GAAG,IAAI,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AACtE,QAAA,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;AAC/B,QAAA,OAAO,SAAS,CAAC;KAClB;AAED;;;;;;;;;;;;;;;;;;;AAmBG;AACI,IAAA,QAAQ,CAAC,QAAoB,EAAA;;QAElC,MAAM,gBAAgB,GAAyB,EAAE,CAAC;AAClD,QAAA,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAE9C,IAAI;;AAEF,YAAA,QAAQ,EAAE,CAAC;AACZ,SAAA;AAAS,gBAAA;;AAER,YAAA,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;AAC9B,SAAA;;AAGD,QAAA,OAAO,MAAK;AACV,YAAA,KAAK,MAAM,SAAS,IAAI,gBAAgB,EAAE;gBACxC,SAAS,CAAC,WAAW,EAAE,CAAC;;gBAGxB,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACjD,gBAAA,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;oBAChB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;AAClC,iBAAA;AACF,aAAA;AACH,SAAC,CAAC;KACH;AAED;;;AAGG;IACI,KAAK,GAAA;AACV,QAAA,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE;YACvC,SAAS,CAAC,WAAW,EAAE,CAAC;AACzB,SAAA;AACD,QAAA,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;KAC5B;AAED;;;AAGG;AACH,IAAA,IAAW,KAAK,GAAA;AACd,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;KAC/B;;;;AAMD;;AAEG;AACK,IAAA,cAAc,CAAC,SAA6B,EAAA;;AAElD,QAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;;AAGhC,QAAA,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC/E,QAAA,IAAI,YAAY,EAAE;AAChB,YAAA,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC9B,SAAA;KACF;AACF,CAAA;AAED;;;;;;;;;;;;;AAaG;AACU,MAAA,SAAS,GAAG,IAAI,eAAe"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Sync context management and validation.
3
+ *
4
+ * @module cascade-next/sync/sync-context
5
+ */
6
+ import type { SyncContext, SyncInstruction } from "./types";
7
+ /**
8
+ * Default maximum sync depth.
9
+ * Prevents infinite sync chains.
10
+ */
11
+ export declare const DEFAULT_MAX_SYNC_DEPTH = 3;
12
+ /**
13
+ * Manages sync context and provides validation utilities.
14
+ */
15
+ export declare class SyncContextManager {
16
+ /**
17
+ * Creates a new sync context from a sync instruction.
18
+ *
19
+ * @param instruction - The sync instruction to create context from
20
+ * @param affectedCount - Number of documents affected
21
+ * @returns A new sync context
22
+ */
23
+ static createContext(instruction: SyncInstruction, affectedCount: number): SyncContext;
24
+ /**
25
+ * Validates if a sync operation can proceed based on depth and cycle detection.
26
+ *
27
+ * @param depth - Current sync depth
28
+ * @param chain - Current sync chain
29
+ * @param targetModel - Target model name
30
+ * @param maxDepth - Maximum allowed depth
31
+ * @param preventCircular - Whether to prevent circular references
32
+ * @returns Validation result with success flag and optional error message
33
+ */
34
+ static validate(depth: number, chain: string[], targetModel: string, maxDepth: number, preventCircular: boolean): {
35
+ valid: boolean;
36
+ error?: string;
37
+ };
38
+ /**
39
+ * Checks if adding a target model would create a cycle in the sync chain.
40
+ *
41
+ * @param chain - Current sync chain
42
+ * @param targetModel - Model to be added to the chain
43
+ * @returns True if adding the model would create a cycle
44
+ */
45
+ static hasCycle(chain: string[], targetModel: string): boolean;
46
+ /**
47
+ * Creates a new sync chain by appending a model name.
48
+ *
49
+ * @param chain - Current sync chain
50
+ * @param modelName - Model name to append
51
+ * @returns New sync chain array
52
+ */
53
+ static extendChain(chain: string[], modelName: string): string[];
54
+ /**
55
+ * Formats a sync chain for display.
56
+ *
57
+ * @param chain - Sync chain to format
58
+ * @returns Formatted string (e.g., "Category → Product → Module")
59
+ */
60
+ static formatChain(chain: string[]): string;
61
+ /**
62
+ * Checks if the current depth allows for further syncing.
63
+ *
64
+ * @param currentDepth - Current depth in the chain
65
+ * @param maxDepth - Maximum allowed depth
66
+ * @returns True if more syncing is allowed
67
+ */
68
+ static canSyncDeeper(currentDepth: number, maxDepth: number): boolean;
69
+ }
70
+ //# sourceMappingURL=sync-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-context.d.ts","sourceRoot":"","sources":["../../src/sync/sync-context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;GAEG;AACH,qBAAa,kBAAkB;IAC7B;;;;;;OAMG;WACW,aAAa,CACzB,WAAW,EAAE,eAAe,EAC5B,aAAa,EAAE,MAAM,GACpB,WAAW;IAcd;;;;;;;;;OASG;WACW,QAAQ,CACpB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EAAE,EACf,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,OAAO,GACvB;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAoBrC;;;;;;OAMG;WACW,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAIrE;;;;;;OAMG;WACW,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAIvE;;;;;OAKG;WACW,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;IAIlD;;;;;;OAMG;WACW,aAAa,CACzB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACf,OAAO;CAGX"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Sync context management and validation.
3
+ *
4
+ * @module cascade-next/sync/sync-context
5
+ */
6
+ /**
7
+ * Default maximum sync depth.
8
+ * Prevents infinite sync chains.
9
+ */
10
+ const DEFAULT_MAX_SYNC_DEPTH = 3;
11
+ /**
12
+ * Manages sync context and provides validation utilities.
13
+ */
14
+ class SyncContextManager {
15
+ /**
16
+ * Creates a new sync context from a sync instruction.
17
+ *
18
+ * @param instruction - The sync instruction to create context from
19
+ * @param affectedCount - Number of documents affected
20
+ * @returns A new sync context
21
+ */
22
+ static createContext(instruction, affectedCount) {
23
+ return {
24
+ sourceModel: instruction.sourceModel,
25
+ sourceId: instruction.sourceId,
26
+ currentDepth: instruction.depth,
27
+ syncChain: [...instruction.chain],
28
+ targetModel: instruction.targetModel,
29
+ filter: { ...instruction.filter },
30
+ update: { ...instruction.update },
31
+ affectedCount,
32
+ timestamp: new Date(),
33
+ };
34
+ }
35
+ /**
36
+ * Validates if a sync operation can proceed based on depth and cycle detection.
37
+ *
38
+ * @param depth - Current sync depth
39
+ * @param chain - Current sync chain
40
+ * @param targetModel - Target model name
41
+ * @param maxDepth - Maximum allowed depth
42
+ * @param preventCircular - Whether to prevent circular references
43
+ * @returns Validation result with success flag and optional error message
44
+ */
45
+ static validate(depth, chain, targetModel, maxDepth, preventCircular) {
46
+ // Check depth limit
47
+ if (depth > maxDepth) {
48
+ return {
49
+ valid: false,
50
+ error: `Sync depth limit exceeded: ${depth} > ${maxDepth}. Chain: ${chain.join(" → ")}`,
51
+ };
52
+ }
53
+ // Check for circular references
54
+ if (preventCircular && this.hasCycle(chain, targetModel)) {
55
+ return {
56
+ valid: false,
57
+ error: `Circular sync detected: ${targetModel} already exists in chain [${chain.join(" → ")}]`,
58
+ };
59
+ }
60
+ return { valid: true };
61
+ }
62
+ /**
63
+ * Checks if adding a target model would create a cycle in the sync chain.
64
+ *
65
+ * @param chain - Current sync chain
66
+ * @param targetModel - Model to be added to the chain
67
+ * @returns True if adding the model would create a cycle
68
+ */
69
+ static hasCycle(chain, targetModel) {
70
+ return chain.includes(targetModel);
71
+ }
72
+ /**
73
+ * Creates a new sync chain by appending a model name.
74
+ *
75
+ * @param chain - Current sync chain
76
+ * @param modelName - Model name to append
77
+ * @returns New sync chain array
78
+ */
79
+ static extendChain(chain, modelName) {
80
+ return [...chain, modelName];
81
+ }
82
+ /**
83
+ * Formats a sync chain for display.
84
+ *
85
+ * @param chain - Sync chain to format
86
+ * @returns Formatted string (e.g., "Category → Product → Module")
87
+ */
88
+ static formatChain(chain) {
89
+ return chain.join(" → ");
90
+ }
91
+ /**
92
+ * Checks if the current depth allows for further syncing.
93
+ *
94
+ * @param currentDepth - Current depth in the chain
95
+ * @param maxDepth - Maximum allowed depth
96
+ * @returns True if more syncing is allowed
97
+ */
98
+ static canSyncDeeper(currentDepth, maxDepth) {
99
+ return currentDepth < maxDepth;
100
+ }
101
+ }export{DEFAULT_MAX_SYNC_DEPTH,SyncContextManager};//# sourceMappingURL=sync-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-context.js","sources":["../../src/sync/sync-context.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;AAIG;AAIH;;;AAGG;AACI,MAAM,sBAAsB,GAAG,EAAE;AAExC;;AAEG;MACU,kBAAkB,CAAA;AAC7B;;;;;;AAMG;AACI,IAAA,OAAO,aAAa,CACzB,WAA4B,EAC5B,aAAqB,EAAA;QAErB,OAAO;YACL,WAAW,EAAE,WAAW,CAAC,WAAW;YACpC,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,YAAY,EAAE,WAAW,CAAC,KAAK;AAC/B,YAAA,SAAS,EAAE,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC;YACjC,WAAW,EAAE,WAAW,CAAC,WAAW;AACpC,YAAA,MAAM,EAAE,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE;AACjC,YAAA,MAAM,EAAE,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE;YACjC,aAAa;YACb,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC;KACH;AAED;;;;;;;;;AASG;IACI,OAAO,QAAQ,CACpB,KAAa,EACb,KAAe,EACf,WAAmB,EACnB,QAAgB,EAChB,eAAwB,EAAA;;QAGxB,IAAI,KAAK,GAAG,QAAQ,EAAE;YACpB,OAAO;AACL,gBAAA,KAAK,EAAE,KAAK;AACZ,gBAAA,KAAK,EAAE,CAAA,2BAAA,EAA8B,KAAK,CAAA,GAAA,EAAM,QAAQ,CAAA,SAAA,EAAY,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAE,CAAA;aACxF,CAAC;AACH,SAAA;;QAGD,IAAI,eAAe,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE;YACxD,OAAO;AACL,gBAAA,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,CAA2B,wBAAA,EAAA,WAAW,CAA6B,0BAAA,EAAA,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAG,CAAA,CAAA;aAC/F,CAAC;AACH,SAAA;AAED,QAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;KACxB;AAED;;;;;;AAMG;AACI,IAAA,OAAO,QAAQ,CAAC,KAAe,EAAE,WAAmB,EAAA;AACzD,QAAA,OAAO,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;KACpC;AAED;;;;;;AAMG;AACI,IAAA,OAAO,WAAW,CAAC,KAAe,EAAE,SAAiB,EAAA;AAC1D,QAAA,OAAO,CAAC,GAAG,KAAK,EAAE,SAAS,CAAC,CAAC;KAC9B;AAED;;;;;AAKG;IACI,OAAO,WAAW,CAAC,KAAe,EAAA;AACvC,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC1B;AAED;;;;;;AAMG;AACI,IAAA,OAAO,aAAa,CACzB,YAAoB,EACpB,QAAgB,EAAA;QAEhB,OAAO,YAAY,GAAG,QAAQ,CAAC;KAChC;AACF"}
@@ -0,0 +1,213 @@
1
+ /**
2
+ * Sync manager service for handling multi-level sync operations.
3
+ *
4
+ * @module cascade-next/sync/sync-manager
5
+ */
6
+ import type { DriverContract } from "../contracts/database-driver.contract";
7
+ import { ChildModel, Model } from "../model/model";
8
+ import type { SyncConfig, SyncResult } from "./types";
9
+ /**
10
+ * Manages sync operations across models with multi-level support.
11
+ */
12
+ export declare class SyncManager {
13
+ private readonly sourceModel;
14
+ private readonly driver;
15
+ /**
16
+ * Creates a new sync manager.
17
+ *
18
+ * @param sourceModel - The source model class
19
+ * @param driver - The database driver
20
+ */
21
+ constructor(sourceModel: ChildModel<Model>, driver: DriverContract);
22
+ /**
23
+ * Executes sync operations for a model update.
24
+ *
25
+ * @param sourceId - The source model ID
26
+ * @param updatedData - The updated data to sync (Model instance or plain data)
27
+ * @param changedFields - Fields that were changed (for filtering)
28
+ * @returns Sync result with success status and details
29
+ */
30
+ syncUpdate(sourceId: string | number, updatedData: Record<string, unknown> | Model, changedFields: string[]): Promise<SyncResult>;
31
+ /**
32
+ * Executes sync operations for a model update with a specific config.
33
+ * Used by ModelSyncOperation for event-based sync.
34
+ *
35
+ * @param sourceId - The source model ID
36
+ * @param updatedData - The updated data to sync
37
+ * @param changedFields - Fields that were changed
38
+ * @param config - The sync configuration to use
39
+ * @returns Sync result with success status and details
40
+ */
41
+ syncUpdateWithConfig(sourceId: string | number, updatedData: Record<string, unknown> | Model, changedFields: string[], config: SyncConfig): Promise<SyncResult>;
42
+ /**
43
+ * Executes sync delete operations with a specific config.
44
+ * Used by ModelSyncOperation for event-based sync.
45
+ *
46
+ * @param sourceId - The source model ID
47
+ * @param config - The sync configuration to use
48
+ * @returns Sync result with success status and details
49
+ */
50
+ syncDeleteWithConfig(sourceId: string | number, config: SyncConfig): Promise<SyncResult>;
51
+ /**
52
+ * Executes sync operations for a model deletion.
53
+ *
54
+ * @param sourceId - The source model ID
55
+ * @returns Sync result with success status and details
56
+ */
57
+ syncDelete(sourceId: string | number): Promise<SyncResult>;
58
+ /**
59
+ * Collects sync instructions recursively with depth limiting.
60
+ *
61
+ * @param payload - Data payload
62
+ * @returns Array of sync instructions
63
+ */
64
+ private collectInstructions;
65
+ /**
66
+ * Collects delete sync instructions.
67
+ *
68
+ * @param sourceId - Source model ID
69
+ * @param syncConfigs - Sync configurations
70
+ * @param options - Instruction options
71
+ * @returns Array of sync instructions
72
+ */
73
+ private collectDeleteInstructions;
74
+ /**
75
+ * Collects instructions for the next level in the sync chain.
76
+ *
77
+ * @param parentInstruction - The parent instruction
78
+ * @param embedData - Embedded data from parent
79
+ * @param changedFields - Changed fields
80
+ * @param parentConfig - Parent sync config
81
+ * @param parentOptions - Parent instruction options
82
+ * @returns Array of next-level sync instructions
83
+ */
84
+ private collectNextLevelInstructions;
85
+ /**
86
+ * Builds an update sync instruction.
87
+ *
88
+ * @param sourceId - Source model ID
89
+ * @param config - Sync configuration
90
+ * @param embedData - Embedded data to sync
91
+ * @param options - Instruction options
92
+ * @returns Sync instruction
93
+ */
94
+ private buildUpdateInstruction;
95
+ /**
96
+ * Builds a delete sync instruction.
97
+ *
98
+ * @param sourceId - Source model ID
99
+ * @param config - Sync configuration
100
+ * @param options - Instruction options
101
+ * @returns Sync instruction
102
+ */
103
+ private buildDeleteInstruction;
104
+ /**
105
+ * Builds a filter for identifying target documents.
106
+ *
107
+ * @param sourceId - Source model ID
108
+ * @param config - Sync configuration
109
+ * @returns Filter object
110
+ */
111
+ private buildFilter;
112
+ /**
113
+ * Builds an update operation for syncing data.
114
+ *
115
+ * @param embedData - Embedded data to sync
116
+ * @param config - Sync configuration
117
+ * @returns Update operation object
118
+ */
119
+ private buildUpdate;
120
+ /**
121
+ * Executes sync instructions with batch optimization.
122
+ * Groups by depth and target table for optimal batching.
123
+ *
124
+ * @param instructions - Array of sync instructions
125
+ * @returns Sync result
126
+ */
127
+ private executeInstructions;
128
+ /**
129
+ * Executes instructions in batch.
130
+ *
131
+ * @param instructions - Instructions to execute
132
+ * @param result - Result object to update
133
+ */
134
+ private executeBatch;
135
+ /**
136
+ * Executes instructions individually (fallback).
137
+ * Provides detailed error reporting for each failed instruction.
138
+ *
139
+ * @param instructions - Instructions to execute
140
+ * @param result - Result object to update
141
+ */
142
+ private executeIndividual;
143
+ /**
144
+ * Formats a sync error with detailed context.
145
+ *
146
+ * @param instruction - The failed instruction
147
+ * @param error - The error that occurred
148
+ * @returns Formatted error message
149
+ */
150
+ private formatSyncError;
151
+ /**
152
+ * Groups instructions by depth for batch processing.
153
+ *
154
+ * @param instructions - Instructions to group
155
+ * @returns Map of depth to instructions (sorted ascending)
156
+ */
157
+ private groupByDepth;
158
+ /**
159
+ * Groups instructions by target table for batch optimization.
160
+ *
161
+ * @param instructions - Instructions to group
162
+ * @returns Map of table name to instructions
163
+ */
164
+ private groupByTable;
165
+ /**
166
+ * Checks if sync should proceed based on watched fields.
167
+ *
168
+ * @param config - Sync configuration
169
+ * @param changedFields - Fields that changed
170
+ * @returns True if sync should proceed
171
+ */
172
+ private shouldSync;
173
+ /**
174
+ * Gets embedded data from the source model.
175
+ *
176
+ * @param data - Source model data or Model instance
177
+ * @param config - Sync configuration
178
+ * @returns Embedded data
179
+ */
180
+ private getEmbedData;
181
+ /**
182
+ * Gets sync configurations from the source model.
183
+ *
184
+ * @returns Array of sync configurations
185
+ */
186
+ private getSyncConfigs;
187
+ /**
188
+ * Gets sync configurations for a specific model.
189
+ *
190
+ * @param modelClass - The model class
191
+ * @returns Array of sync configurations
192
+ */
193
+ private getSyncConfigsForModel;
194
+ /**
195
+ * Emits a syncing event.
196
+ *
197
+ * @param instruction - The sync instruction
198
+ */
199
+ private emitSyncingEvent;
200
+ /**
201
+ * Emits a synced event.
202
+ *
203
+ * @param context - The sync context
204
+ */
205
+ private emitSyncedEvent;
206
+ /**
207
+ * Creates an empty sync result.
208
+ *
209
+ * @returns Empty sync result
210
+ */
211
+ private createEmptyResult;
212
+ }
213
+ //# sourceMappingURL=sync-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-manager.d.ts","sourceRoot":"","sources":["../../src/sync/sync-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAEV,UAAU,EAIV,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IAExC;;;;;OAKG;gBACgB,WAAW,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,cAAc;IAKzE;;;;;;;OAOG;IACU,UAAU,CACrB,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,EAC5C,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,UAAU,CAAC;IAsDtB;;;;;;;;;OASG;IACU,oBAAoB,CAC/B,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,EAC5C,aAAa,EAAE,MAAM,EAAE,EACvB,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,UAAU,CAAC;IAkDtB;;;;;;;OAOG;IACU,oBAAoB,CAC/B,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,UAAU,CAAC;IAgDtB;;;;;OAKG;IACU,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAgDvE;;;;;OAKG;YACW,mBAAmB;IAqDjC;;;;;;;OAOG;YACW,yBAAyB;IAiCvC;;;;;;;;;OASG;YACW,4BAA4B;IAiC1C;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;IAgC9B;;;;;;;OAOG;IACH,OAAO,CAAC,sBAAsB;IAqB9B;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAanB;;;;;;OAMG;YACW,mBAAmB;IA0CjC;;;;;OAKG;YACW,YAAY;IAoB1B;;;;;;OAMG;YACW,iBAAiB;IAgD/B;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAavB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAepB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAcpB;;;;;;OAMG;IACH,OAAO,CAAC,UAAU;IAQlB;;;;;;OAMG;YACW,YAAY;IAyB1B;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAYtB;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAY9B;;;;OAIG;YACW,gBAAgB;IAkB9B;;;;OAIG;YACW,eAAe;IAkB7B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;CAW1B"}