joist-core 2.3.0 → 2.4.0-next.2

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 (1548) hide show
  1. package/build/BaseEntity.cjs +112 -0
  2. package/build/BaseEntity.cjs.map +1 -0
  3. package/build/BaseEntity.d.cts +73 -0
  4. package/build/BaseEntity.d.cts.map +1 -0
  5. package/build/BaseEntity.d.mts +73 -0
  6. package/build/BaseEntity.d.mts.map +1 -0
  7. package/build/BaseEntity.js +99 -110
  8. package/build/BaseEntity.js.map +1 -1
  9. package/build/Entity.cjs +12 -0
  10. package/build/Entity.cjs.map +1 -0
  11. package/build/Entity.d.cts +42 -0
  12. package/build/Entity.d.cts.map +1 -0
  13. package/build/Entity.d.mts +42 -0
  14. package/build/Entity.d.mts.map +1 -0
  15. package/build/Entity.js +8 -5
  16. package/build/Entity.js.map +1 -1
  17. package/build/EntityFields.cjs +1 -0
  18. package/build/EntityFields.d.cts +36 -0
  19. package/build/EntityFields.d.cts.map +1 -0
  20. package/build/EntityFields.d.mts +36 -0
  21. package/build/EntityFields.d.mts.map +1 -0
  22. package/build/EntityFields.js +1 -3
  23. package/build/EntityManager.cjs +1935 -0
  24. package/build/EntityManager.cjs.map +1 -0
  25. package/build/EntityManager.d.cts +835 -0
  26. package/build/EntityManager.d.cts.map +1 -0
  27. package/build/EntityManager.d.mts +835 -0
  28. package/build/EntityManager.d.mts.map +1 -0
  29. package/build/EntityManager.js +1812 -2211
  30. package/build/EntityManager.js.map +1 -1
  31. package/build/EntityMetadata.cjs +75 -0
  32. package/build/EntityMetadata.cjs.map +1 -0
  33. package/build/EntityMetadata.d.cts +262 -0
  34. package/build/EntityMetadata.d.cts.map +1 -0
  35. package/build/EntityMetadata.d.mts +262 -0
  36. package/build/EntityMetadata.d.mts.map +1 -0
  37. package/build/EntityMetadata.js +31 -48
  38. package/build/EntityMetadata.js.map +1 -1
  39. package/build/EnumMetadata.cjs +1 -0
  40. package/build/EnumMetadata.d.cts +18 -0
  41. package/build/EnumMetadata.d.cts.map +1 -0
  42. package/build/EnumMetadata.d.mts +18 -0
  43. package/build/EnumMetadata.d.mts.map +1 -0
  44. package/build/EnumMetadata.js +1 -3
  45. package/build/IndexManager.cjs +178 -0
  46. package/build/IndexManager.cjs.map +1 -0
  47. package/build/IndexManager.d.cts +36 -0
  48. package/build/IndexManager.d.cts.map +1 -0
  49. package/build/IndexManager.d.mts +36 -0
  50. package/build/IndexManager.d.mts.map +1 -0
  51. package/build/IndexManager.js +169 -218
  52. package/build/IndexManager.js.map +1 -1
  53. package/build/InstanceData.cjs +218 -0
  54. package/build/InstanceData.cjs.map +1 -0
  55. package/build/InstanceData.d.cts +98 -0
  56. package/build/InstanceData.d.cts.map +1 -0
  57. package/build/InstanceData.d.mts +98 -0
  58. package/build/InstanceData.d.mts.map +1 -0
  59. package/build/InstanceData.js +215 -222
  60. package/build/InstanceData.js.map +1 -1
  61. package/build/PluginManager.cjs +89 -0
  62. package/build/PluginManager.cjs.map +1 -0
  63. package/build/PluginManager.d.cts +112 -0
  64. package/build/PluginManager.d.cts.map +1 -0
  65. package/build/PluginManager.d.mts +112 -0
  66. package/build/PluginManager.d.mts.map +1 -0
  67. package/build/PluginManager.js +80 -106
  68. package/build/PluginManager.js.map +1 -1
  69. package/build/RowData.cjs +37 -0
  70. package/build/RowData.cjs.map +1 -0
  71. package/build/RowData.d.cts +53 -0
  72. package/build/RowData.d.cts.map +1 -0
  73. package/build/RowData.d.mts +53 -0
  74. package/build/RowData.d.mts.map +1 -0
  75. package/build/RowData.js +35 -0
  76. package/build/RowData.js.map +1 -0
  77. package/build/_virtual/_rolldown/runtime.cjs +23 -0
  78. package/build/batchloaders/BatchLoader.cjs +49 -0
  79. package/build/batchloaders/BatchLoader.cjs.map +1 -0
  80. package/build/batchloaders/BatchLoader.d.cts +17 -0
  81. package/build/batchloaders/BatchLoader.d.cts.map +1 -0
  82. package/build/batchloaders/BatchLoader.d.mts +17 -0
  83. package/build/batchloaders/BatchLoader.d.mts.map +1 -0
  84. package/build/batchloaders/BatchLoader.js +45 -54
  85. package/build/batchloaders/BatchLoader.js.map +1 -1
  86. package/build/batchloaders/enumCollectionBatchLoader.cjs +66 -0
  87. package/build/batchloaders/enumCollectionBatchLoader.cjs.map +1 -0
  88. package/build/batchloaders/enumCollectionBatchLoader.d.cts +11 -0
  89. package/build/batchloaders/enumCollectionBatchLoader.d.cts.map +1 -0
  90. package/build/batchloaders/enumCollectionBatchLoader.d.mts +11 -0
  91. package/build/batchloaders/enumCollectionBatchLoader.d.mts.map +1 -0
  92. package/build/batchloaders/enumCollectionBatchLoader.js +58 -48
  93. package/build/batchloaders/enumCollectionBatchLoader.js.map +1 -1
  94. package/build/batchloaders/loadBatchLoader.cjs +78 -0
  95. package/build/batchloaders/loadBatchLoader.cjs.map +1 -0
  96. package/build/batchloaders/loadBatchLoader.d.cts +20 -0
  97. package/build/batchloaders/loadBatchLoader.d.cts.map +1 -0
  98. package/build/batchloaders/loadBatchLoader.d.mts +20 -0
  99. package/build/batchloaders/loadBatchLoader.d.mts.map +1 -0
  100. package/build/batchloaders/loadBatchLoader.js +72 -51
  101. package/build/batchloaders/loadBatchLoader.js.map +1 -1
  102. package/build/batchloaders/manyToManyBatchLoader.cjs +78 -0
  103. package/build/batchloaders/manyToManyBatchLoader.cjs.map +1 -0
  104. package/build/batchloaders/manyToManyBatchLoader.d.cts +11 -0
  105. package/build/batchloaders/manyToManyBatchLoader.d.cts.map +1 -0
  106. package/build/batchloaders/manyToManyBatchLoader.d.mts +11 -0
  107. package/build/batchloaders/manyToManyBatchLoader.d.mts.map +1 -0
  108. package/build/batchloaders/manyToManyBatchLoader.js +70 -61
  109. package/build/batchloaders/manyToManyBatchLoader.js.map +1 -1
  110. package/build/batchloaders/oneToManyBatchLoader.cjs +63 -0
  111. package/build/batchloaders/oneToManyBatchLoader.cjs.map +1 -0
  112. package/build/batchloaders/oneToManyBatchLoader.d.cts +11 -0
  113. package/build/batchloaders/oneToManyBatchLoader.d.cts.map +1 -0
  114. package/build/batchloaders/oneToManyBatchLoader.d.mts +11 -0
  115. package/build/batchloaders/oneToManyBatchLoader.d.mts.map +1 -0
  116. package/build/batchloaders/oneToManyBatchLoader.js +58 -48
  117. package/build/batchloaders/oneToManyBatchLoader.js.map +1 -1
  118. package/build/batchloaders/oneToOneBatchLoader.cjs +64 -0
  119. package/build/batchloaders/oneToOneBatchLoader.cjs.map +1 -0
  120. package/build/batchloaders/oneToOneBatchLoader.d.cts +10 -0
  121. package/build/batchloaders/oneToOneBatchLoader.d.cts.map +1 -0
  122. package/build/batchloaders/oneToOneBatchLoader.d.mts +10 -0
  123. package/build/batchloaders/oneToOneBatchLoader.d.mts.map +1 -0
  124. package/build/batchloaders/oneToOneBatchLoader.js +59 -50
  125. package/build/batchloaders/oneToOneBatchLoader.js.map +1 -1
  126. package/build/batchloaders/populateBatchLoader.cjs +155 -0
  127. package/build/batchloaders/populateBatchLoader.cjs.map +1 -0
  128. package/build/batchloaders/populateBatchLoader.d.cts +17 -0
  129. package/build/batchloaders/populateBatchLoader.d.cts.map +1 -0
  130. package/build/batchloaders/populateBatchLoader.d.mts +17 -0
  131. package/build/batchloaders/populateBatchLoader.d.mts.map +1 -0
  132. package/build/batchloaders/populateBatchLoader.js +147 -203
  133. package/build/batchloaders/populateBatchLoader.js.map +1 -1
  134. package/build/batchloaders/recursiveChildrenBatchLoader.cjs +78 -0
  135. package/build/batchloaders/recursiveChildrenBatchLoader.cjs.map +1 -0
  136. package/build/batchloaders/recursiveChildrenBatchLoader.d.cts +10 -0
  137. package/build/batchloaders/recursiveChildrenBatchLoader.d.cts.map +1 -0
  138. package/build/batchloaders/recursiveChildrenBatchLoader.d.mts +10 -0
  139. package/build/batchloaders/recursiveChildrenBatchLoader.d.mts.map +1 -0
  140. package/build/batchloaders/recursiveChildrenBatchLoader.js +71 -72
  141. package/build/batchloaders/recursiveChildrenBatchLoader.js.map +1 -1
  142. package/build/batchloaders/recursiveM2mBatchLoader.cjs +83 -0
  143. package/build/batchloaders/recursiveM2mBatchLoader.cjs.map +1 -0
  144. package/build/batchloaders/recursiveM2mBatchLoader.d.cts +10 -0
  145. package/build/batchloaders/recursiveM2mBatchLoader.d.cts.map +1 -0
  146. package/build/batchloaders/recursiveM2mBatchLoader.d.mts +10 -0
  147. package/build/batchloaders/recursiveM2mBatchLoader.d.mts.map +1 -0
  148. package/build/batchloaders/recursiveM2mBatchLoader.js +76 -79
  149. package/build/batchloaders/recursiveM2mBatchLoader.js.map +1 -1
  150. package/build/batchloaders/recursiveParentsBatchLoader.cjs +65 -0
  151. package/build/batchloaders/recursiveParentsBatchLoader.cjs.map +1 -0
  152. package/build/batchloaders/recursiveParentsBatchLoader.d.cts +10 -0
  153. package/build/batchloaders/recursiveParentsBatchLoader.d.cts.map +1 -0
  154. package/build/batchloaders/recursiveParentsBatchLoader.d.mts +10 -0
  155. package/build/batchloaders/recursiveParentsBatchLoader.d.mts.map +1 -0
  156. package/build/batchloaders/recursiveParentsBatchLoader.js +58 -55
  157. package/build/batchloaders/recursiveParentsBatchLoader.js.map +1 -1
  158. package/build/changes.cjs +221 -0
  159. package/build/changes.cjs.map +1 -0
  160. package/build/changes.d.cts +95 -0
  161. package/build/changes.d.cts.map +1 -0
  162. package/build/changes.d.mts +95 -0
  163. package/build/changes.d.mts.map +1 -0
  164. package/build/changes.js +208 -285
  165. package/build/changes.js.map +1 -1
  166. package/build/config.cjs +295 -0
  167. package/build/config.cjs.map +1 -0
  168. package/build/config.d.cts +277 -0
  169. package/build/config.d.cts.map +1 -0
  170. package/build/config.d.mts +277 -0
  171. package/build/config.d.mts.map +1 -0
  172. package/build/config.js +255 -301
  173. package/build/config.js.map +1 -1
  174. package/build/configure.cjs +324 -0
  175. package/build/configure.cjs.map +1 -0
  176. package/build/configure.d.cts +19 -0
  177. package/build/configure.d.cts.map +1 -0
  178. package/build/configure.d.mts +19 -0
  179. package/build/configure.d.mts.map +1 -0
  180. package/build/configure.js +265 -348
  181. package/build/configure.js.map +1 -1
  182. package/build/dataloaders/fastWhereFilterHash.cjs +140 -0
  183. package/build/dataloaders/fastWhereFilterHash.cjs.map +1 -0
  184. package/build/dataloaders/fastWhereFilterHash.d.cts +18 -0
  185. package/build/dataloaders/fastWhereFilterHash.d.cts.map +1 -0
  186. package/build/dataloaders/fastWhereFilterHash.d.mts +18 -0
  187. package/build/dataloaders/fastWhereFilterHash.d.mts.map +1 -0
  188. package/build/dataloaders/fastWhereFilterHash.js +108 -133
  189. package/build/dataloaders/fastWhereFilterHash.js.map +1 -1
  190. package/build/dataloaders/findByUniqueDataLoader.cjs +58 -0
  191. package/build/dataloaders/findByUniqueDataLoader.cjs.map +1 -0
  192. package/build/dataloaders/findByUniqueDataLoader.d.cts +10 -0
  193. package/build/dataloaders/findByUniqueDataLoader.d.cts.map +1 -0
  194. package/build/dataloaders/findByUniqueDataLoader.d.mts +10 -0
  195. package/build/dataloaders/findByUniqueDataLoader.d.mts.map +1 -0
  196. package/build/dataloaders/findByUniqueDataLoader.js +53 -44
  197. package/build/dataloaders/findByUniqueDataLoader.js.map +1 -1
  198. package/build/dataloaders/findCountDataLoader.cjs +123 -0
  199. package/build/dataloaders/findCountDataLoader.cjs.map +1 -0
  200. package/build/dataloaders/findCountDataLoader.d.cts +19 -0
  201. package/build/dataloaders/findCountDataLoader.d.cts.map +1 -0
  202. package/build/dataloaders/findCountDataLoader.d.mts +19 -0
  203. package/build/dataloaders/findCountDataLoader.d.mts.map +1 -0
  204. package/build/dataloaders/findCountDataLoader.js +112 -109
  205. package/build/dataloaders/findCountDataLoader.js.map +1 -1
  206. package/build/dataloaders/findDataLoader.cjs +365 -0
  207. package/build/dataloaders/findDataLoader.cjs.map +1 -0
  208. package/build/dataloaders/findDataLoader.d.cts +79 -0
  209. package/build/dataloaders/findDataLoader.d.cts.map +1 -0
  210. package/build/dataloaders/findDataLoader.d.mts +79 -0
  211. package/build/dataloaders/findDataLoader.d.mts.map +1 -0
  212. package/build/dataloaders/findDataLoader.js +298 -382
  213. package/build/dataloaders/findDataLoader.js.map +1 -1
  214. package/build/dataloaders/findIdsDataLoader.cjs +82 -0
  215. package/build/dataloaders/findIdsDataLoader.cjs.map +1 -0
  216. package/build/dataloaders/findIdsDataLoader.d.cts +9 -0
  217. package/build/dataloaders/findIdsDataLoader.d.cts.map +1 -0
  218. package/build/dataloaders/findIdsDataLoader.d.mts +9 -0
  219. package/build/dataloaders/findIdsDataLoader.d.mts.map +1 -0
  220. package/build/dataloaders/findIdsDataLoader.js +77 -74
  221. package/build/dataloaders/findIdsDataLoader.js.map +1 -1
  222. package/build/dataloaders/findOrCreateDataLoader.cjs +120 -0
  223. package/build/dataloaders/findOrCreateDataLoader.cjs.map +1 -0
  224. package/build/dataloaders/findOrCreateDataLoader.d.cts +15 -0
  225. package/build/dataloaders/findOrCreateDataLoader.d.cts.map +1 -0
  226. package/build/dataloaders/findOrCreateDataLoader.d.mts +15 -0
  227. package/build/dataloaders/findOrCreateDataLoader.d.mts.map +1 -0
  228. package/build/dataloaders/findOrCreateDataLoader.js +102 -164
  229. package/build/dataloaders/findOrCreateDataLoader.js.map +1 -1
  230. package/build/dataloaders/findPaginatedDataLoader.cjs +98 -0
  231. package/build/dataloaders/findPaginatedDataLoader.cjs.map +1 -0
  232. package/build/dataloaders/findPaginatedDataLoader.d.cts +10 -0
  233. package/build/dataloaders/findPaginatedDataLoader.d.cts.map +1 -0
  234. package/build/dataloaders/findPaginatedDataLoader.d.mts +10 -0
  235. package/build/dataloaders/findPaginatedDataLoader.d.mts.map +1 -0
  236. package/build/dataloaders/findPaginatedDataLoader.js +93 -80
  237. package/build/dataloaders/findPaginatedDataLoader.js.map +1 -1
  238. package/build/dataloaders/lensDataLoader.cjs +178 -0
  239. package/build/dataloaders/lensDataLoader.cjs.map +1 -0
  240. package/build/dataloaders/lensDataLoader.d.cts +15 -0
  241. package/build/dataloaders/lensDataLoader.d.cts.map +1 -0
  242. package/build/dataloaders/lensDataLoader.d.mts +15 -0
  243. package/build/dataloaders/lensDataLoader.d.mts.map +1 -0
  244. package/build/dataloaders/lensDataLoader.js +172 -176
  245. package/build/dataloaders/lensDataLoader.js.map +1 -1
  246. package/build/dataloaders/manyToManyFindDataLoader.cjs +84 -0
  247. package/build/dataloaders/manyToManyFindDataLoader.cjs.map +1 -0
  248. package/build/dataloaders/manyToManyFindDataLoader.d.cts +12 -0
  249. package/build/dataloaders/manyToManyFindDataLoader.d.cts.map +1 -0
  250. package/build/dataloaders/manyToManyFindDataLoader.d.mts +12 -0
  251. package/build/dataloaders/manyToManyFindDataLoader.d.mts.map +1 -0
  252. package/build/dataloaders/manyToManyFindDataLoader.js +76 -70
  253. package/build/dataloaders/manyToManyFindDataLoader.js.map +1 -1
  254. package/build/dataloaders/oneToManyFindDataLoader.cjs +77 -0
  255. package/build/dataloaders/oneToManyFindDataLoader.cjs.map +1 -0
  256. package/build/dataloaders/oneToManyFindDataLoader.d.cts +12 -0
  257. package/build/dataloaders/oneToManyFindDataLoader.d.cts.map +1 -0
  258. package/build/dataloaders/oneToManyFindDataLoader.d.mts +12 -0
  259. package/build/dataloaders/oneToManyFindDataLoader.d.mts.map +1 -0
  260. package/build/dataloaders/oneToManyFindDataLoader.js +71 -67
  261. package/build/dataloaders/oneToManyFindDataLoader.js.map +1 -1
  262. package/build/defaults.cjs +195 -0
  263. package/build/defaults.cjs.map +1 -0
  264. package/build/defaults.d.cts +56 -0
  265. package/build/defaults.d.cts.map +1 -0
  266. package/build/defaults.d.mts +56 -0
  267. package/build/defaults.d.mts.map +1 -0
  268. package/build/defaults.js +171 -271
  269. package/build/defaults.js.map +1 -1
  270. package/build/drivers/Driver.cjs +3 -0
  271. package/build/drivers/Driver.d.cts +51 -0
  272. package/build/drivers/Driver.d.cts.map +1 -0
  273. package/build/drivers/Driver.d.mts +51 -0
  274. package/build/drivers/Driver.d.mts.map +1 -0
  275. package/build/drivers/Driver.js +3 -3
  276. package/build/drivers/EntityWriter.cjs +208 -0
  277. package/build/drivers/EntityWriter.cjs.map +1 -0
  278. package/build/drivers/EntityWriter.d.cts +66 -0
  279. package/build/drivers/EntityWriter.d.cts.map +1 -0
  280. package/build/drivers/EntityWriter.d.mts +66 -0
  281. package/build/drivers/EntityWriter.d.mts.map +1 -0
  282. package/build/drivers/EntityWriter.js +183 -219
  283. package/build/drivers/EntityWriter.js.map +1 -1
  284. package/build/drivers/IdAssigner.cjs +89 -0
  285. package/build/drivers/IdAssigner.cjs.map +1 -0
  286. package/build/drivers/IdAssigner.d.cts +50 -0
  287. package/build/drivers/IdAssigner.d.cts.map +1 -0
  288. package/build/drivers/IdAssigner.d.mts +50 -0
  289. package/build/drivers/IdAssigner.d.mts.map +1 -0
  290. package/build/drivers/IdAssigner.js +80 -124
  291. package/build/drivers/IdAssigner.js.map +1 -1
  292. package/build/drivers/driverApi.cjs +19 -0
  293. package/build/drivers/driverApi.cjs.map +1 -0
  294. package/build/drivers/driverApi.d.cts +22 -0
  295. package/build/drivers/driverApi.d.cts.map +1 -0
  296. package/build/drivers/driverApi.d.mts +22 -0
  297. package/build/drivers/driverApi.d.mts.map +1 -0
  298. package/build/drivers/driverApi.js +18 -0
  299. package/build/drivers/driverApi.js.map +1 -0
  300. package/build/drivers/index.cjs +7 -0
  301. package/build/drivers/index.d.cts +4 -0
  302. package/build/drivers/index.d.mts +4 -0
  303. package/build/drivers/index.js +3 -22
  304. package/build/fields.cjs +127 -0
  305. package/build/fields.cjs.map +1 -0
  306. package/build/fields.d.cts +29 -0
  307. package/build/fields.d.cts.map +1 -0
  308. package/build/fields.d.mts +29 -0
  309. package/build/fields.d.mts.map +1 -0
  310. package/build/fields.js +98 -160
  311. package/build/fields.js.map +1 -1
  312. package/build/flush/FlushLock.cjs +51 -0
  313. package/build/flush/FlushLock.cjs.map +1 -0
  314. package/build/flush/FlushLock.d.cts +29 -0
  315. package/build/flush/FlushLock.d.cts.map +1 -0
  316. package/build/flush/FlushLock.d.mts +29 -0
  317. package/build/flush/FlushLock.d.mts.map +1 -0
  318. package/build/flush/FlushLock.js +51 -0
  319. package/build/flush/FlushLock.js.map +1 -0
  320. package/build/flush/JoinRows.cjs +263 -0
  321. package/build/flush/JoinRows.cjs.map +1 -0
  322. package/build/flush/JoinRows.d.cts +120 -0
  323. package/build/flush/JoinRows.d.cts.map +1 -0
  324. package/build/flush/JoinRows.d.mts +120 -0
  325. package/build/flush/JoinRows.d.mts.map +1 -0
  326. package/build/flush/JoinRows.js +261 -0
  327. package/build/flush/JoinRows.js.map +1 -0
  328. package/build/flush/PendingChanges.cjs +1 -0
  329. package/build/flush/PendingChanges.d.cts +29 -0
  330. package/build/flush/PendingChanges.d.cts.map +1 -0
  331. package/build/flush/PendingChanges.d.mts +29 -0
  332. package/build/flush/PendingChanges.d.mts.map +1 -0
  333. package/build/flush/PendingChanges.js +1 -0
  334. package/build/flush/Todo.cjs +71 -0
  335. package/build/flush/Todo.cjs.map +1 -0
  336. package/build/flush/Todo.d.cts +38 -0
  337. package/build/flush/Todo.d.cts.map +1 -0
  338. package/build/flush/Todo.d.mts +38 -0
  339. package/build/flush/Todo.d.mts.map +1 -0
  340. package/build/flush/Todo.js +67 -0
  341. package/build/flush/Todo.js.map +1 -0
  342. package/build/getProperties.cjs +87 -0
  343. package/build/getProperties.cjs.map +1 -0
  344. package/build/getProperties.d.cts +30 -0
  345. package/build/getProperties.d.cts.map +1 -0
  346. package/build/getProperties.d.mts +30 -0
  347. package/build/getProperties.d.mts.map +1 -0
  348. package/build/getProperties.js +71 -128
  349. package/build/getProperties.js.map +1 -1
  350. package/build/index.cjs +524 -0
  351. package/build/index.cjs.map +1 -0
  352. package/build/index.d.cts +180 -0
  353. package/build/index.d.cts.map +1 -0
  354. package/build/index.d.mts +180 -0
  355. package/build/index.d.mts.map +1 -0
  356. package/build/index.js +171 -292
  357. package/build/index.js.map +1 -1
  358. package/build/json.cjs +79 -0
  359. package/build/json.cjs.map +1 -0
  360. package/build/json.d.cts +76 -0
  361. package/build/json.d.cts.map +1 -0
  362. package/build/json.d.mts +76 -0
  363. package/build/json.d.mts.map +1 -0
  364. package/build/json.js +68 -106
  365. package/build/json.js.map +1 -1
  366. package/build/k.cjs +9 -0
  367. package/build/k.cjs.map +1 -0
  368. package/build/k.d.cts +1 -0
  369. package/build/k.d.mts +1 -0
  370. package/build/k.js +6 -6
  371. package/build/k.js.map +1 -1
  372. package/build/keys.cjs +181 -0
  373. package/build/keys.cjs.map +1 -0
  374. package/build/keys.d.cts +55 -0
  375. package/build/keys.d.cts.map +1 -0
  376. package/build/keys.d.mts +55 -0
  377. package/build/keys.d.mts.map +1 -0
  378. package/build/keys.js +129 -162
  379. package/build/keys.js.map +1 -1
  380. package/build/loading/HintTree.cjs +67 -0
  381. package/build/loading/HintTree.cjs.map +1 -0
  382. package/build/loading/HintTree.d.cts +45 -0
  383. package/build/loading/HintTree.d.cts.map +1 -0
  384. package/build/loading/HintTree.d.mts +45 -0
  385. package/build/loading/HintTree.d.mts.map +1 -0
  386. package/build/loading/HintTree.js +66 -0
  387. package/build/loading/HintTree.js.map +1 -0
  388. package/build/loading/IsLoadedCache.cjs +58 -0
  389. package/build/loading/IsLoadedCache.cjs.map +1 -0
  390. package/build/loading/IsLoadedCache.d.cts +35 -0
  391. package/build/loading/IsLoadedCache.d.cts.map +1 -0
  392. package/build/loading/IsLoadedCache.d.mts +35 -0
  393. package/build/loading/IsLoadedCache.d.mts.map +1 -0
  394. package/build/loading/IsLoadedCache.js +57 -0
  395. package/build/loading/IsLoadedCache.js.map +1 -0
  396. package/build/loading/loadHints.cjs +95 -0
  397. package/build/loading/loadHints.cjs.map +1 -0
  398. package/build/loading/loadHints.d.cts +116 -0
  399. package/build/loading/loadHints.d.cts.map +1 -0
  400. package/build/loading/loadHints.d.mts +116 -0
  401. package/build/loading/loadHints.d.mts.map +1 -0
  402. package/build/loading/loadHints.js +88 -0
  403. package/build/loading/loadHints.js.map +1 -0
  404. package/build/loading/loadLens.cjs +212 -0
  405. package/build/loading/loadLens.cjs.map +1 -0
  406. package/build/loading/loadLens.d.cts +77 -0
  407. package/build/loading/loadLens.d.cts.map +1 -0
  408. package/build/loading/loadLens.d.mts +77 -0
  409. package/build/loading/loadLens.d.mts.map +1 -0
  410. package/build/loading/loadLens.js +201 -0
  411. package/build/loading/loadLens.js.map +1 -0
  412. package/build/loading/withLoaded.cjs +64 -0
  413. package/build/loading/withLoaded.cjs.map +1 -0
  414. package/build/loading/withLoaded.d.cts +65 -0
  415. package/build/loading/withLoaded.d.cts.map +1 -0
  416. package/build/loading/withLoaded.d.mts +65 -0
  417. package/build/loading/withLoaded.d.mts.map +1 -0
  418. package/build/loading/withLoaded.js +61 -0
  419. package/build/loading/withLoaded.js.map +1 -0
  420. package/build/logging/FactoryLogger.cjs +66 -0
  421. package/build/logging/FactoryLogger.cjs.map +1 -0
  422. package/build/logging/FactoryLogger.d.cts +27 -0
  423. package/build/logging/FactoryLogger.d.cts.map +1 -0
  424. package/build/logging/FactoryLogger.d.mts +27 -0
  425. package/build/logging/FactoryLogger.d.mts.map +1 -0
  426. package/build/logging/FactoryLogger.js +58 -73
  427. package/build/logging/FactoryLogger.js.map +1 -1
  428. package/build/logging/FieldLogger.cjs +57 -0
  429. package/build/logging/FieldLogger.cjs.map +1 -0
  430. package/build/logging/FieldLogger.d.cts +32 -0
  431. package/build/logging/FieldLogger.d.cts.map +1 -0
  432. package/build/logging/FieldLogger.d.mts +32 -0
  433. package/build/logging/FieldLogger.d.mts.map +1 -0
  434. package/build/logging/FieldLogger.js +51 -67
  435. package/build/logging/FieldLogger.js.map +1 -1
  436. package/build/logging/ReactionLogger.cjs +93 -0
  437. package/build/logging/ReactionLogger.cjs.map +1 -0
  438. package/build/logging/ReactionLogger.d.cts +37 -0
  439. package/build/logging/ReactionLogger.d.cts.map +1 -0
  440. package/build/logging/ReactionLogger.d.mts +37 -0
  441. package/build/logging/ReactionLogger.d.mts.map +1 -0
  442. package/build/logging/ReactionLogger.js +76 -66
  443. package/build/logging/ReactionLogger.js.map +1 -1
  444. package/build/newEntity.cjs +89 -0
  445. package/build/newEntity.cjs.map +1 -0
  446. package/build/newEntity.d.cts +48 -0
  447. package/build/newEntity.d.cts.map +1 -0
  448. package/build/newEntity.d.mts +48 -0
  449. package/build/newEntity.d.mts.map +1 -0
  450. package/build/newEntity.js +71 -94
  451. package/build/newEntity.js.map +1 -1
  452. package/build/newTestInstance.cjs +539 -0
  453. package/build/newTestInstance.cjs.map +1 -0
  454. package/build/newTestInstance.d.cts +207 -0
  455. package/build/newTestInstance.d.cts.map +1 -0
  456. package/build/newTestInstance.d.mts +207 -0
  457. package/build/newTestInstance.d.mts.map +1 -0
  458. package/build/newTestInstance.js +459 -721
  459. package/build/newTestInstance.js.map +1 -1
  460. package/build/normalizeHints.cjs +58 -0
  461. package/build/normalizeHints.cjs.map +1 -0
  462. package/build/normalizeHints.d.cts +24 -0
  463. package/build/normalizeHints.d.cts.map +1 -0
  464. package/build/normalizeHints.d.mts +24 -0
  465. package/build/normalizeHints.d.mts.map +1 -0
  466. package/build/normalizeHints.js +40 -55
  467. package/build/normalizeHints.js.map +1 -1
  468. package/build/nowUTC.cjs +15 -0
  469. package/build/nowUTC.cjs.map +1 -0
  470. package/build/nowUTC.d.cts +10 -0
  471. package/build/nowUTC.d.cts.map +1 -0
  472. package/build/nowUTC.d.mts +10 -0
  473. package/build/nowUTC.d.mts.map +1 -0
  474. package/build/nowUTC.js +14 -0
  475. package/build/nowUTC.js.map +1 -0
  476. package/build/plugins/ImmutableEntitiesPlugin.cjs +21 -0
  477. package/build/plugins/ImmutableEntitiesPlugin.cjs.map +1 -0
  478. package/build/plugins/ImmutableEntitiesPlugin.d.cts +12 -0
  479. package/build/plugins/ImmutableEntitiesPlugin.d.cts.map +1 -0
  480. package/build/plugins/ImmutableEntitiesPlugin.d.mts +12 -0
  481. package/build/plugins/ImmutableEntitiesPlugin.d.mts.map +1 -0
  482. package/build/plugins/ImmutableEntitiesPlugin.js +19 -20
  483. package/build/plugins/ImmutableEntitiesPlugin.js.map +1 -1
  484. package/build/plugins/PreloadPlugin.cjs +3 -0
  485. package/build/plugins/PreloadPlugin.d.cts +77 -0
  486. package/build/plugins/PreloadPlugin.d.cts.map +1 -0
  487. package/build/plugins/PreloadPlugin.d.mts +77 -0
  488. package/build/plugins/PreloadPlugin.d.mts.map +1 -0
  489. package/build/plugins/PreloadPlugin.js +3 -3
  490. package/build/preloading/JsonAggregatePreloader.cjs +280 -0
  491. package/build/preloading/JsonAggregatePreloader.cjs.map +1 -0
  492. package/build/preloading/JsonAggregatePreloader.d.cts +19 -0
  493. package/build/preloading/JsonAggregatePreloader.d.cts.map +1 -0
  494. package/build/preloading/JsonAggregatePreloader.d.mts +19 -0
  495. package/build/preloading/JsonAggregatePreloader.d.mts.map +1 -0
  496. package/build/preloading/JsonAggregatePreloader.js +270 -320
  497. package/build/preloading/JsonAggregatePreloader.js.map +1 -1
  498. package/build/preloading/canPreload.cjs +19 -0
  499. package/build/preloading/canPreload.cjs.map +1 -0
  500. package/build/preloading/canPreload.d.cts +6 -0
  501. package/build/preloading/canPreload.d.cts.map +1 -0
  502. package/build/preloading/canPreload.d.mts +6 -0
  503. package/build/preloading/canPreload.d.mts.map +1 -0
  504. package/build/preloading/canPreload.js +15 -21
  505. package/build/preloading/canPreload.js.map +1 -1
  506. package/build/preloading/partitionHint.cjs +43 -0
  507. package/build/preloading/partitionHint.cjs.map +1 -0
  508. package/build/preloading/partitionHint.d.cts +8 -0
  509. package/build/preloading/partitionHint.d.cts.map +1 -0
  510. package/build/preloading/partitionHint.d.mts +8 -0
  511. package/build/preloading/partitionHint.d.mts.map +1 -0
  512. package/build/preloading/partitionHint.js +36 -56
  513. package/build/preloading/partitionHint.js.map +1 -1
  514. package/build/queries/ConditionBuilder.cjs +106 -0
  515. package/build/queries/ConditionBuilder.cjs.map +1 -0
  516. package/build/queries/ConditionBuilder.d.cts +31 -0
  517. package/build/queries/ConditionBuilder.d.cts.map +1 -0
  518. package/build/queries/ConditionBuilder.d.mts +31 -0
  519. package/build/queries/ConditionBuilder.d.mts.map +1 -0
  520. package/build/queries/ConditionBuilder.js +105 -0
  521. package/build/queries/ConditionBuilder.js.map +1 -0
  522. package/build/queries/conditions.cjs +15 -0
  523. package/build/queries/conditions.cjs.map +1 -0
  524. package/build/queries/conditions.d.cts +38 -0
  525. package/build/queries/conditions.d.cts.map +1 -0
  526. package/build/queries/conditions.d.mts +38 -0
  527. package/build/queries/conditions.d.mts.map +1 -0
  528. package/build/queries/conditions.js +13 -0
  529. package/build/queries/conditions.js.map +1 -0
  530. package/build/queries/entityQueryUtils.cjs +60 -0
  531. package/build/queries/entityQueryUtils.cjs.map +1 -0
  532. package/build/queries/entityQueryUtils.d.cts +19 -0
  533. package/build/queries/entityQueryUtils.d.cts.map +1 -0
  534. package/build/queries/entityQueryUtils.d.mts +19 -0
  535. package/build/queries/entityQueryUtils.d.mts.map +1 -0
  536. package/build/queries/entityQueryUtils.js +56 -0
  537. package/build/queries/entityQueryUtils.js.map +1 -0
  538. package/build/queries/find/Aliases.cjs +301 -0
  539. package/build/queries/find/Aliases.cjs.map +1 -0
  540. package/build/queries/find/Aliases.d.cts +122 -0
  541. package/build/queries/find/Aliases.d.cts.map +1 -0
  542. package/build/queries/find/Aliases.d.mts +122 -0
  543. package/build/queries/find/Aliases.d.mts.map +1 -0
  544. package/build/queries/find/Aliases.js +293 -0
  545. package/build/queries/find/Aliases.js.map +1 -0
  546. package/build/queries/find/DeferredAlias.cjs +25 -0
  547. package/build/queries/find/DeferredAlias.cjs.map +1 -0
  548. package/build/queries/find/DeferredAlias.d.cts +22 -0
  549. package/build/queries/find/DeferredAlias.d.cts.map +1 -0
  550. package/build/queries/find/DeferredAlias.d.mts +22 -0
  551. package/build/queries/find/DeferredAlias.d.mts.map +1 -0
  552. package/build/queries/find/DeferredAlias.js +22 -0
  553. package/build/queries/find/DeferredAlias.js.map +1 -0
  554. package/build/queries/find/EntityFilter.cjs +27 -0
  555. package/build/queries/find/EntityFilter.cjs.map +1 -0
  556. package/build/queries/find/EntityFilter.d.cts +127 -0
  557. package/build/queries/find/EntityFilter.d.cts.map +1 -0
  558. package/build/queries/find/EntityFilter.d.mts +127 -0
  559. package/build/queries/find/EntityFilter.d.mts.map +1 -0
  560. package/build/queries/find/EntityFilter.js +26 -0
  561. package/build/queries/find/EntityFilter.js.map +1 -0
  562. package/build/queries/find/EntityGraphQLFilter.cjs +52 -0
  563. package/build/queries/find/EntityGraphQLFilter.cjs.map +1 -0
  564. package/build/queries/find/EntityGraphQLFilter.d.cts +59 -0
  565. package/build/queries/find/EntityGraphQLFilter.d.cts.map +1 -0
  566. package/build/queries/find/EntityGraphQLFilter.d.mts +59 -0
  567. package/build/queries/find/EntityGraphQLFilter.d.mts.map +1 -0
  568. package/build/queries/find/EntityGraphQLFilter.js +50 -0
  569. package/build/queries/find/EntityGraphQLFilter.js.map +1 -0
  570. package/build/queries/find/QueryParser.cjs +553 -0
  571. package/build/queries/find/QueryParser.cjs.map +1 -0
  572. package/build/queries/find/QueryParser.collectionJoins.cjs +353 -0
  573. package/build/queries/find/QueryParser.collectionJoins.cjs.map +1 -0
  574. package/build/queries/find/QueryParser.collectionJoins.d.cts +30 -0
  575. package/build/queries/find/QueryParser.collectionJoins.d.cts.map +1 -0
  576. package/build/queries/find/QueryParser.collectionJoins.d.mts +30 -0
  577. package/build/queries/find/QueryParser.collectionJoins.d.mts.map +1 -0
  578. package/build/queries/find/QueryParser.collectionJoins.js +352 -0
  579. package/build/queries/find/QueryParser.collectionJoins.js.map +1 -0
  580. package/build/queries/find/QueryParser.d.cts +192 -0
  581. package/build/queries/find/QueryParser.d.cts.map +1 -0
  582. package/build/queries/find/QueryParser.d.mts +192 -0
  583. package/build/queries/find/QueryParser.d.mts.map +1 -0
  584. package/build/queries/find/QueryParser.js +546 -0
  585. package/build/queries/find/QueryParser.js.map +1 -0
  586. package/build/queries/find/QueryParser.pruning.cjs +115 -0
  587. package/build/queries/find/QueryParser.pruning.cjs.map +1 -0
  588. package/build/queries/find/QueryParser.pruning.d.cts +8 -0
  589. package/build/queries/find/QueryParser.pruning.d.cts.map +1 -0
  590. package/build/queries/find/QueryParser.pruning.d.mts +8 -0
  591. package/build/queries/find/QueryParser.pruning.d.mts.map +1 -0
  592. package/build/queries/find/QueryParser.pruning.js +113 -0
  593. package/build/queries/find/QueryParser.pruning.js.map +1 -0
  594. package/build/queries/find/QueryVisitor.cjs +77 -0
  595. package/build/queries/find/QueryVisitor.cjs.map +1 -0
  596. package/build/queries/find/QueryVisitor.d.cts +24 -0
  597. package/build/queries/find/QueryVisitor.d.cts.map +1 -0
  598. package/build/queries/find/QueryVisitor.d.mts +24 -0
  599. package/build/queries/find/QueryVisitor.d.mts.map +1 -0
  600. package/build/queries/find/QueryVisitor.js +74 -0
  601. package/build/queries/find/QueryVisitor.js.map +1 -0
  602. package/build/queries/find/buildFindQuery.cjs +112 -0
  603. package/build/queries/find/buildFindQuery.cjs.map +1 -0
  604. package/build/queries/find/buildFindQuery.d.cts +24 -0
  605. package/build/queries/find/buildFindQuery.d.cts.map +1 -0
  606. package/build/queries/find/buildFindQuery.d.mts +24 -0
  607. package/build/queries/find/buildFindQuery.d.mts.map +1 -0
  608. package/build/queries/find/buildFindQuery.js +110 -0
  609. package/build/queries/find/buildFindQuery.js.map +1 -0
  610. package/build/queries/find/scopes.cjs +301 -0
  611. package/build/queries/find/scopes.cjs.map +1 -0
  612. package/build/queries/find/scopes.d.cts +188 -0
  613. package/build/queries/find/scopes.d.cts.map +1 -0
  614. package/build/queries/find/scopes.d.mts +188 -0
  615. package/build/queries/find/scopes.d.mts.map +1 -0
  616. package/build/queries/find/scopes.js +296 -0
  617. package/build/queries/find/scopes.js.map +1 -0
  618. package/build/queries/parsedConditions.cjs +21 -0
  619. package/build/queries/parsedConditions.cjs.map +1 -0
  620. package/build/queries/parsedConditions.d.cts +127 -0
  621. package/build/queries/parsedConditions.d.cts.map +1 -0
  622. package/build/queries/parsedConditions.d.mts +127 -0
  623. package/build/queries/parsedConditions.d.mts.map +1 -0
  624. package/build/queries/parsedConditions.js +20 -0
  625. package/build/queries/parsedConditions.js.map +1 -0
  626. package/build/queries/renderConditions.cjs +66 -0
  627. package/build/queries/renderConditions.cjs.map +1 -0
  628. package/build/queries/renderConditions.d.cts +15 -0
  629. package/build/queries/renderConditions.d.cts.map +1 -0
  630. package/build/queries/renderConditions.d.mts +15 -0
  631. package/build/queries/renderConditions.d.mts.map +1 -0
  632. package/build/queries/renderConditions.js +64 -0
  633. package/build/queries/renderConditions.js.map +1 -0
  634. package/build/queries/skipCondition.cjs +14 -0
  635. package/build/queries/skipCondition.cjs.map +1 -0
  636. package/build/queries/skipCondition.d.cts +7 -0
  637. package/build/queries/skipCondition.d.cts.map +1 -0
  638. package/build/queries/skipCondition.d.mts +7 -0
  639. package/build/queries/skipCondition.d.mts.map +1 -0
  640. package/build/queries/skipCondition.js +13 -0
  641. package/build/queries/skipCondition.js.map +1 -0
  642. package/build/queries/sql/AliasAssigner.cjs +35 -0
  643. package/build/queries/sql/AliasAssigner.cjs.map +1 -0
  644. package/build/queries/sql/AliasAssigner.d.cts +13 -0
  645. package/build/queries/sql/AliasAssigner.d.cts.map +1 -0
  646. package/build/queries/sql/AliasAssigner.d.mts +13 -0
  647. package/build/queries/sql/AliasAssigner.d.mts.map +1 -0
  648. package/build/queries/sql/AliasAssigner.js +34 -0
  649. package/build/queries/sql/AliasAssigner.js.map +1 -0
  650. package/build/queries/sql/Expr.cjs +529 -0
  651. package/build/queries/sql/Expr.cjs.map +1 -0
  652. package/build/queries/sql/Expr.d.cts +284 -0
  653. package/build/queries/sql/Expr.d.cts.map +1 -0
  654. package/build/queries/sql/Expr.d.mts +284 -0
  655. package/build/queries/sql/Expr.d.mts.map +1 -0
  656. package/build/queries/sql/Expr.js +512 -0
  657. package/build/queries/sql/Expr.js.map +1 -0
  658. package/build/queries/sql/JoinTree.cjs +72 -0
  659. package/build/queries/sql/JoinTree.cjs.map +1 -0
  660. package/build/queries/sql/JoinTree.d.cts +107 -0
  661. package/build/queries/sql/JoinTree.d.cts.map +1 -0
  662. package/build/queries/sql/JoinTree.d.mts +107 -0
  663. package/build/queries/sql/JoinTree.d.mts.map +1 -0
  664. package/build/queries/sql/JoinTree.js +71 -0
  665. package/build/queries/sql/JoinTree.js.map +1 -0
  666. package/build/queries/sql/Tables.cjs +803 -0
  667. package/build/queries/sql/Tables.cjs.map +1 -0
  668. package/build/queries/sql/Tables.d.cts +322 -0
  669. package/build/queries/sql/Tables.d.cts.map +1 -0
  670. package/build/queries/sql/Tables.d.mts +322 -0
  671. package/build/queries/sql/Tables.d.mts.map +1 -0
  672. package/build/queries/sql/Tables.js +786 -0
  673. package/build/queries/sql/Tables.js.map +1 -0
  674. package/build/queries/sql/custom.cjs +52 -0
  675. package/build/queries/sql/custom.cjs.map +1 -0
  676. package/build/queries/sql/custom.d.cts +85 -0
  677. package/build/queries/sql/custom.d.cts.map +1 -0
  678. package/build/queries/sql/custom.d.mts +85 -0
  679. package/build/queries/sql/custom.d.mts.map +1 -0
  680. package/build/queries/sql/custom.js +49 -0
  681. package/build/queries/sql/custom.js.map +1 -0
  682. package/build/queries/sql/execute.cjs +276 -0
  683. package/build/queries/sql/execute.cjs.map +1 -0
  684. package/build/queries/sql/execute.d.cts +294 -0
  685. package/build/queries/sql/execute.d.cts.map +1 -0
  686. package/build/queries/sql/execute.d.mts +294 -0
  687. package/build/queries/sql/execute.d.mts.map +1 -0
  688. package/build/queries/sql/execute.js +273 -0
  689. package/build/queries/sql/execute.js.map +1 -0
  690. package/build/queries/sql/expressions/arrayAgg.cjs +63 -0
  691. package/build/queries/sql/expressions/arrayAgg.cjs.map +1 -0
  692. package/build/queries/sql/expressions/arrayAgg.d.cts +24 -0
  693. package/build/queries/sql/expressions/arrayAgg.d.cts.map +1 -0
  694. package/build/queries/sql/expressions/arrayAgg.d.mts +24 -0
  695. package/build/queries/sql/expressions/arrayAgg.d.mts.map +1 -0
  696. package/build/queries/sql/expressions/arrayAgg.js +61 -0
  697. package/build/queries/sql/expressions/arrayAgg.js.map +1 -0
  698. package/build/queries/sql/expressions/case.cjs +71 -0
  699. package/build/queries/sql/expressions/case.cjs.map +1 -0
  700. package/build/queries/sql/expressions/case.d.cts +57 -0
  701. package/build/queries/sql/expressions/case.d.cts.map +1 -0
  702. package/build/queries/sql/expressions/case.d.mts +57 -0
  703. package/build/queries/sql/expressions/case.d.mts.map +1 -0
  704. package/build/queries/sql/expressions/case.js +68 -0
  705. package/build/queries/sql/expressions/case.js.map +1 -0
  706. package/build/queries/sql/expressions/coalesce.cjs +25 -0
  707. package/build/queries/sql/expressions/coalesce.cjs.map +1 -0
  708. package/build/queries/sql/expressions/coalesce.d.cts +21 -0
  709. package/build/queries/sql/expressions/coalesce.d.cts.map +1 -0
  710. package/build/queries/sql/expressions/coalesce.d.mts +21 -0
  711. package/build/queries/sql/expressions/coalesce.d.mts.map +1 -0
  712. package/build/queries/sql/expressions/coalesce.js +22 -0
  713. package/build/queries/sql/expressions/coalesce.js.map +1 -0
  714. package/build/queries/sql/expressions/codecs.cjs +126 -0
  715. package/build/queries/sql/expressions/codecs.cjs.map +1 -0
  716. package/build/queries/sql/expressions/codecs.d.cts +11 -0
  717. package/build/queries/sql/expressions/codecs.d.cts.map +1 -0
  718. package/build/queries/sql/expressions/codecs.d.mts +11 -0
  719. package/build/queries/sql/expressions/codecs.d.mts.map +1 -0
  720. package/build/queries/sql/expressions/codecs.js +125 -0
  721. package/build/queries/sql/expressions/codecs.js.map +1 -0
  722. package/build/queries/sql/expressions/expression.cjs +102 -0
  723. package/build/queries/sql/expressions/expression.cjs.map +1 -0
  724. package/build/queries/sql/expressions/expression.d.cts +23 -0
  725. package/build/queries/sql/expressions/expression.d.cts.map +1 -0
  726. package/build/queries/sql/expressions/expression.d.mts +23 -0
  727. package/build/queries/sql/expressions/expression.d.mts.map +1 -0
  728. package/build/queries/sql/expressions/expression.js +97 -0
  729. package/build/queries/sql/expressions/expression.js.map +1 -0
  730. package/build/queries/sql/expressions/greatest.cjs +25 -0
  731. package/build/queries/sql/expressions/greatest.cjs.map +1 -0
  732. package/build/queries/sql/expressions/greatest.d.cts +21 -0
  733. package/build/queries/sql/expressions/greatest.d.cts.map +1 -0
  734. package/build/queries/sql/expressions/greatest.d.mts +21 -0
  735. package/build/queries/sql/expressions/greatest.d.mts.map +1 -0
  736. package/build/queries/sql/expressions/greatest.js +22 -0
  737. package/build/queries/sql/expressions/greatest.js.map +1 -0
  738. package/build/queries/sql/expressions/least.cjs +25 -0
  739. package/build/queries/sql/expressions/least.cjs.map +1 -0
  740. package/build/queries/sql/expressions/least.d.cts +21 -0
  741. package/build/queries/sql/expressions/least.d.cts.map +1 -0
  742. package/build/queries/sql/expressions/least.d.mts +21 -0
  743. package/build/queries/sql/expressions/least.d.mts.map +1 -0
  744. package/build/queries/sql/expressions/least.js +22 -0
  745. package/build/queries/sql/expressions/least.js.map +1 -0
  746. package/build/queries/sql/expressions/nullIf.cjs +27 -0
  747. package/build/queries/sql/expressions/nullIf.cjs.map +1 -0
  748. package/build/queries/sql/expressions/nullIf.d.cts +22 -0
  749. package/build/queries/sql/expressions/nullIf.d.cts.map +1 -0
  750. package/build/queries/sql/expressions/nullIf.d.mts +22 -0
  751. package/build/queries/sql/expressions/nullIf.d.mts.map +1 -0
  752. package/build/queries/sql/expressions/nullIf.js +24 -0
  753. package/build/queries/sql/expressions/nullIf.js.map +1 -0
  754. package/build/queries/sql/expressions/parseExpression.cjs +75 -0
  755. package/build/queries/sql/expressions/parseExpression.cjs.map +1 -0
  756. package/build/queries/sql/expressions/parseExpression.d.cts +19 -0
  757. package/build/queries/sql/expressions/parseExpression.d.cts.map +1 -0
  758. package/build/queries/sql/expressions/parseExpression.d.mts +19 -0
  759. package/build/queries/sql/expressions/parseExpression.d.mts.map +1 -0
  760. package/build/queries/sql/expressions/parseExpression.js +70 -0
  761. package/build/queries/sql/expressions/parseExpression.js.map +1 -0
  762. package/build/queries/sql/expressions/types.cjs +1 -0
  763. package/build/queries/sql/expressions/types.d.cts +114 -0
  764. package/build/queries/sql/expressions/types.d.cts.map +1 -0
  765. package/build/queries/sql/expressions/types.d.mts +114 -0
  766. package/build/queries/sql/expressions/types.d.mts.map +1 -0
  767. package/build/queries/sql/expressions/types.js +1 -0
  768. package/build/queries/sql/keywords.cjs +136 -0
  769. package/build/queries/sql/keywords.cjs.map +1 -0
  770. package/build/queries/sql/keywords.d.cts +18 -0
  771. package/build/queries/sql/keywords.d.cts.map +1 -0
  772. package/build/queries/sql/keywords.d.mts +18 -0
  773. package/build/queries/sql/keywords.d.mts.map +1 -0
  774. package/build/queries/sql/keywords.js +132 -0
  775. package/build/queries/sql/keywords.js.map +1 -0
  776. package/build/queries/sql/query.cjs +1610 -0
  777. package/build/queries/sql/query.cjs.map +1 -0
  778. package/build/queries/sql/query.d.cts +844 -0
  779. package/build/queries/sql/query.d.cts.map +1 -0
  780. package/build/queries/sql/query.d.mts +844 -0
  781. package/build/queries/sql/query.d.mts.map +1 -0
  782. package/build/queries/sql/query.js +1592 -0
  783. package/build/queries/sql/query.js.map +1 -0
  784. package/build/queries/unnest.cjs +62 -0
  785. package/build/queries/unnest.cjs.map +1 -0
  786. package/build/queries/unnest.d.cts +16 -0
  787. package/build/queries/unnest.d.cts.map +1 -0
  788. package/build/queries/unnest.d.mts +16 -0
  789. package/build/queries/unnest.d.mts.map +1 -0
  790. package/build/queries/unnest.js +60 -0
  791. package/build/queries/unnest.js.map +1 -0
  792. package/build/queries/valueFilters.cjs +240 -0
  793. package/build/queries/valueFilters.cjs.map +1 -0
  794. package/build/queries/valueFilters.d.cts +26 -0
  795. package/build/queries/valueFilters.d.cts.map +1 -0
  796. package/build/queries/valueFilters.d.mts +26 -0
  797. package/build/queries/valueFilters.d.mts.map +1 -0
  798. package/build/queries/valueFilters.js +236 -0
  799. package/build/queries/valueFilters.js.map +1 -0
  800. package/build/reactivity/ReactionsManager.cjs +264 -0
  801. package/build/reactivity/ReactionsManager.cjs.map +1 -0
  802. package/build/reactivity/ReactionsManager.d.cts +98 -0
  803. package/build/reactivity/ReactionsManager.d.cts.map +1 -0
  804. package/build/reactivity/ReactionsManager.d.mts +98 -0
  805. package/build/reactivity/ReactionsManager.d.mts.map +1 -0
  806. package/build/reactivity/ReactionsManager.js +263 -0
  807. package/build/reactivity/ReactionsManager.js.map +1 -0
  808. package/build/reactivity/reactiveHints.cjs +328 -0
  809. package/build/reactivity/reactiveHints.cjs.map +1 -0
  810. package/build/reactivity/reactiveHints.d.cts +143 -0
  811. package/build/reactivity/reactiveHints.d.cts.map +1 -0
  812. package/build/reactivity/reactiveHints.d.mts +143 -0
  813. package/build/reactivity/reactiveHints.d.mts.map +1 -0
  814. package/build/reactivity/reactiveHints.js +321 -0
  815. package/build/reactivity/reactiveHints.js.map +1 -0
  816. package/build/relations/AbstractPropertyImpl.cjs +16 -0
  817. package/build/relations/AbstractPropertyImpl.cjs.map +1 -0
  818. package/build/relations/AbstractPropertyImpl.d.cts +11 -0
  819. package/build/relations/AbstractPropertyImpl.d.cts.map +1 -0
  820. package/build/relations/AbstractPropertyImpl.d.mts +11 -0
  821. package/build/relations/AbstractPropertyImpl.d.mts.map +1 -0
  822. package/build/relations/AbstractPropertyImpl.js +13 -13
  823. package/build/relations/AbstractPropertyImpl.js.map +1 -1
  824. package/build/relations/AbstractRelationImpl.cjs +15 -0
  825. package/build/relations/AbstractRelationImpl.cjs.map +1 -0
  826. package/build/relations/AbstractRelationImpl.d.cts +43 -0
  827. package/build/relations/AbstractRelationImpl.d.cts.map +1 -0
  828. package/build/relations/AbstractRelationImpl.d.mts +43 -0
  829. package/build/relations/AbstractRelationImpl.d.mts.map +1 -0
  830. package/build/relations/AbstractRelationImpl.js +12 -17
  831. package/build/relations/AbstractRelationImpl.js.map +1 -1
  832. package/build/relations/AsyncProperty.cjs +75 -0
  833. package/build/relations/AsyncProperty.cjs.map +1 -0
  834. package/build/relations/AsyncProperty.d.cts +40 -0
  835. package/build/relations/AsyncProperty.d.cts.map +1 -0
  836. package/build/relations/AsyncProperty.d.mts +40 -0
  837. package/build/relations/AsyncProperty.d.mts.map +1 -0
  838. package/build/relations/AsyncProperty.js +61 -70
  839. package/build/relations/AsyncProperty.js.map +1 -1
  840. package/build/relations/AsyncReactiveField.cjs +110 -0
  841. package/build/relations/AsyncReactiveField.cjs.map +1 -0
  842. package/build/relations/AsyncReactiveField.d.cts +50 -0
  843. package/build/relations/AsyncReactiveField.d.cts.map +1 -0
  844. package/build/relations/AsyncReactiveField.d.mts +50 -0
  845. package/build/relations/AsyncReactiveField.d.mts.map +1 -0
  846. package/build/relations/AsyncReactiveField.js +97 -116
  847. package/build/relations/AsyncReactiveField.js.map +1 -1
  848. package/build/relations/Collection.cjs +23 -0
  849. package/build/relations/Collection.cjs.map +1 -0
  850. package/build/relations/Collection.d.cts +37 -0
  851. package/build/relations/Collection.d.cts.map +1 -0
  852. package/build/relations/Collection.d.mts +37 -0
  853. package/build/relations/Collection.d.mts.map +1 -0
  854. package/build/relations/Collection.js +14 -11
  855. package/build/relations/Collection.js.map +1 -1
  856. package/build/relations/CustomCollection.cjs +144 -0
  857. package/build/relations/CustomCollection.cjs.map +1 -0
  858. package/build/relations/CustomCollection.d.cts +74 -0
  859. package/build/relations/CustomCollection.d.cts.map +1 -0
  860. package/build/relations/CustomCollection.d.mts +74 -0
  861. package/build/relations/CustomCollection.d.mts.map +1 -0
  862. package/build/relations/CustomCollection.js +138 -162
  863. package/build/relations/CustomCollection.js.map +1 -1
  864. package/build/relations/CustomReference.cjs +142 -0
  865. package/build/relations/CustomReference.cjs.map +1 -0
  866. package/build/relations/CustomReference.d.cts +76 -0
  867. package/build/relations/CustomReference.d.cts.map +1 -0
  868. package/build/relations/CustomReference.d.mts +76 -0
  869. package/build/relations/CustomReference.d.mts.map +1 -0
  870. package/build/relations/CustomReference.js +135 -147
  871. package/build/relations/CustomReference.js.map +1 -1
  872. package/build/relations/EnumCollection.cjs +178 -0
  873. package/build/relations/EnumCollection.cjs.map +1 -0
  874. package/build/relations/EnumCollection.d.cts +86 -0
  875. package/build/relations/EnumCollection.d.cts.map +1 -0
  876. package/build/relations/EnumCollection.d.mts +86 -0
  877. package/build/relations/EnumCollection.d.mts.map +1 -0
  878. package/build/relations/EnumCollection.js +172 -207
  879. package/build/relations/EnumCollection.js.map +1 -1
  880. package/build/relations/LargeCollection.cjs +4 -0
  881. package/build/relations/LargeCollection.d.cts +22 -0
  882. package/build/relations/LargeCollection.d.cts.map +1 -0
  883. package/build/relations/LargeCollection.d.mts +22 -0
  884. package/build/relations/LargeCollection.d.mts.map +1 -0
  885. package/build/relations/LargeCollection.js +4 -3
  886. package/build/relations/LazyField.cjs +140 -0
  887. package/build/relations/LazyField.cjs.map +1 -0
  888. package/build/relations/LazyField.d.cts +51 -0
  889. package/build/relations/LazyField.d.cts.map +1 -0
  890. package/build/relations/LazyField.d.mts +51 -0
  891. package/build/relations/LazyField.d.mts.map +1 -0
  892. package/build/relations/LazyField.js +134 -0
  893. package/build/relations/LazyField.js.map +1 -0
  894. package/build/relations/ManyToManyCollection.cjs +421 -0
  895. package/build/relations/ManyToManyCollection.cjs.map +1 -0
  896. package/build/relations/ManyToManyCollection.d.cts +59 -0
  897. package/build/relations/ManyToManyCollection.d.cts.map +1 -0
  898. package/build/relations/ManyToManyCollection.d.mts +59 -0
  899. package/build/relations/ManyToManyCollection.d.mts.map +1 -0
  900. package/build/relations/ManyToManyCollection.js +411 -471
  901. package/build/relations/ManyToManyCollection.js.map +1 -1
  902. package/build/relations/ManyToManyLargeCollection.cjs +91 -0
  903. package/build/relations/ManyToManyLargeCollection.cjs.map +1 -0
  904. package/build/relations/ManyToManyLargeCollection.d.cts +34 -0
  905. package/build/relations/ManyToManyLargeCollection.d.cts.map +1 -0
  906. package/build/relations/ManyToManyLargeCollection.d.mts +34 -0
  907. package/build/relations/ManyToManyLargeCollection.d.mts.map +1 -0
  908. package/build/relations/ManyToManyLargeCollection.js +85 -118
  909. package/build/relations/ManyToManyLargeCollection.js.map +1 -1
  910. package/build/relations/ManyToOneReference.cjs +364 -0
  911. package/build/relations/ManyToOneReference.cjs.map +1 -0
  912. package/build/relations/ManyToOneReference.d.cts +121 -0
  913. package/build/relations/ManyToOneReference.d.cts.map +1 -0
  914. package/build/relations/ManyToOneReference.d.mts +121 -0
  915. package/build/relations/ManyToOneReference.d.mts.map +1 -0
  916. package/build/relations/ManyToOneReference.js +344 -411
  917. package/build/relations/ManyToOneReference.js.map +1 -1
  918. package/build/relations/OneToManyCollection.cjs +492 -0
  919. package/build/relations/OneToManyCollection.cjs.map +1 -0
  920. package/build/relations/OneToManyCollection.d.cts +69 -0
  921. package/build/relations/OneToManyCollection.d.cts.map +1 -0
  922. package/build/relations/OneToManyCollection.d.mts +69 -0
  923. package/build/relations/OneToManyCollection.d.mts.map +1 -0
  924. package/build/relations/OneToManyCollection.js +480 -579
  925. package/build/relations/OneToManyCollection.js.map +1 -1
  926. package/build/relations/OneToManyLargeCollection.cjs +85 -0
  927. package/build/relations/OneToManyLargeCollection.cjs.map +1 -0
  928. package/build/relations/OneToManyLargeCollection.d.cts +29 -0
  929. package/build/relations/OneToManyLargeCollection.d.cts.map +1 -0
  930. package/build/relations/OneToManyLargeCollection.d.mts +29 -0
  931. package/build/relations/OneToManyLargeCollection.d.mts.map +1 -0
  932. package/build/relations/OneToManyLargeCollection.js +79 -99
  933. package/build/relations/OneToManyLargeCollection.js.map +1 -1
  934. package/build/relations/OneToOneReference.cjs +209 -0
  935. package/build/relations/OneToOneReference.cjs.map +1 -0
  936. package/build/relations/OneToOneReference.d.cts +97 -0
  937. package/build/relations/OneToOneReference.d.cts.map +1 -0
  938. package/build/relations/OneToOneReference.d.mts +97 -0
  939. package/build/relations/OneToOneReference.d.mts.map +1 -0
  940. package/build/relations/OneToOneReference.js +193 -221
  941. package/build/relations/OneToOneReference.js.map +1 -1
  942. package/build/relations/PolymorphicReference.cjs +210 -0
  943. package/build/relations/PolymorphicReference.cjs.map +1 -0
  944. package/build/relations/PolymorphicReference.d.cts +93 -0
  945. package/build/relations/PolymorphicReference.d.cts.map +1 -0
  946. package/build/relations/PolymorphicReference.d.mts +93 -0
  947. package/build/relations/PolymorphicReference.d.mts.map +1 -0
  948. package/build/relations/PolymorphicReference.js +200 -237
  949. package/build/relations/PolymorphicReference.js.map +1 -1
  950. package/build/relations/PropertySymbols.cjs +7 -0
  951. package/build/relations/PropertySymbols.cjs.map +1 -0
  952. package/build/relations/PropertySymbols.d.cts +5 -0
  953. package/build/relations/PropertySymbols.d.cts.map +1 -0
  954. package/build/relations/PropertySymbols.d.mts +5 -0
  955. package/build/relations/PropertySymbols.d.mts.map +1 -0
  956. package/build/relations/PropertySymbols.js +6 -0
  957. package/build/relations/PropertySymbols.js.map +1 -0
  958. package/build/relations/ReactiveField.cjs +114 -0
  959. package/build/relations/ReactiveField.cjs.map +1 -0
  960. package/build/relations/ReactiveField.d.cts +88 -0
  961. package/build/relations/ReactiveField.d.cts.map +1 -0
  962. package/build/relations/ReactiveField.d.mts +88 -0
  963. package/build/relations/ReactiveField.d.mts.map +1 -0
  964. package/build/relations/ReactiveField.js +104 -137
  965. package/build/relations/ReactiveField.js.map +1 -1
  966. package/build/relations/ReactiveGetter.cjs +40 -0
  967. package/build/relations/ReactiveGetter.cjs.map +1 -0
  968. package/build/relations/ReactiveGetter.d.cts +33 -0
  969. package/build/relations/ReactiveGetter.d.cts.map +1 -0
  970. package/build/relations/ReactiveGetter.d.mts +33 -0
  971. package/build/relations/ReactiveGetter.d.mts.map +1 -0
  972. package/build/relations/ReactiveGetter.js +30 -31
  973. package/build/relations/ReactiveGetter.js.map +1 -1
  974. package/build/relations/ReactiveManyToMany.cjs +198 -0
  975. package/build/relations/ReactiveManyToMany.cjs.map +1 -0
  976. package/build/relations/ReactiveManyToMany.d.cts +63 -0
  977. package/build/relations/ReactiveManyToMany.d.cts.map +1 -0
  978. package/build/relations/ReactiveManyToMany.d.mts +63 -0
  979. package/build/relations/ReactiveManyToMany.d.mts.map +1 -0
  980. package/build/relations/ReactiveManyToMany.js +187 -238
  981. package/build/relations/ReactiveManyToMany.js.map +1 -1
  982. package/build/relations/ReactiveManyToManyOtherSide.cjs +148 -0
  983. package/build/relations/ReactiveManyToManyOtherSide.cjs.map +1 -0
  984. package/build/relations/ReactiveManyToManyOtherSide.d.cts +53 -0
  985. package/build/relations/ReactiveManyToManyOtherSide.d.cts.map +1 -0
  986. package/build/relations/ReactiveManyToManyOtherSide.d.mts +53 -0
  987. package/build/relations/ReactiveManyToManyOtherSide.d.mts.map +1 -0
  988. package/build/relations/ReactiveManyToManyOtherSide.js +139 -152
  989. package/build/relations/ReactiveManyToManyOtherSide.js.map +1 -1
  990. package/build/relations/ReactiveReference.cjs +336 -0
  991. package/build/relations/ReactiveReference.cjs.map +1 -0
  992. package/build/relations/ReactiveReference.d.cts +124 -0
  993. package/build/relations/ReactiveReference.d.cts.map +1 -0
  994. package/build/relations/ReactiveReference.d.mts +124 -0
  995. package/build/relations/ReactiveReference.d.mts.map +1 -0
  996. package/build/relations/ReactiveReference.js +321 -385
  997. package/build/relations/ReactiveReference.js.map +1 -1
  998. package/build/relations/ReadOnlyCollection.cjs +18 -0
  999. package/build/relations/ReadOnlyCollection.cjs.map +1 -0
  1000. package/build/relations/ReadOnlyCollection.d.cts +22 -0
  1001. package/build/relations/ReadOnlyCollection.d.cts.map +1 -0
  1002. package/build/relations/ReadOnlyCollection.d.mts +22 -0
  1003. package/build/relations/ReadOnlyCollection.d.mts.map +1 -0
  1004. package/build/relations/ReadOnlyCollection.js +9 -9
  1005. package/build/relations/ReadOnlyCollection.js.map +1 -1
  1006. package/build/relations/RecursiveCollection.cjs +386 -0
  1007. package/build/relations/RecursiveCollection.cjs.map +1 -0
  1008. package/build/relations/RecursiveCollection.d.cts +112 -0
  1009. package/build/relations/RecursiveCollection.d.cts.map +1 -0
  1010. package/build/relations/RecursiveCollection.d.mts +112 -0
  1011. package/build/relations/RecursiveCollection.d.mts.map +1 -0
  1012. package/build/relations/RecursiveCollection.js +367 -427
  1013. package/build/relations/RecursiveCollection.js.map +1 -1
  1014. package/build/relations/RecursiveCycleError.cjs +17 -0
  1015. package/build/relations/RecursiveCycleError.cjs.map +1 -0
  1016. package/build/relations/RecursiveCycleError.d.cts +15 -0
  1017. package/build/relations/RecursiveCycleError.d.cts.map +1 -0
  1018. package/build/relations/RecursiveCycleError.d.mts +15 -0
  1019. package/build/relations/RecursiveCycleError.d.mts.map +1 -0
  1020. package/build/relations/RecursiveCycleError.js +14 -13
  1021. package/build/relations/RecursiveCycleError.js.map +1 -1
  1022. package/build/relations/Reference.cjs +25 -0
  1023. package/build/relations/Reference.cjs.map +1 -0
  1024. package/build/relations/Reference.d.cts +39 -0
  1025. package/build/relations/Reference.d.cts.map +1 -0
  1026. package/build/relations/Reference.d.mts +39 -0
  1027. package/build/relations/Reference.d.mts.map +1 -0
  1028. package/build/relations/Reference.js +15 -14
  1029. package/build/relations/Reference.js.map +1 -1
  1030. package/build/relations/ReferenceSymbols.cjs +7 -0
  1031. package/build/relations/ReferenceSymbols.cjs.map +1 -0
  1032. package/build/relations/ReferenceSymbols.d.cts +5 -0
  1033. package/build/relations/ReferenceSymbols.d.cts.map +1 -0
  1034. package/build/relations/ReferenceSymbols.d.mts +5 -0
  1035. package/build/relations/ReferenceSymbols.d.mts.map +1 -0
  1036. package/build/relations/ReferenceSymbols.js +6 -0
  1037. package/build/relations/ReferenceSymbols.js.map +1 -0
  1038. package/build/relations/Relation.cjs +17 -0
  1039. package/build/relations/Relation.cjs.map +1 -0
  1040. package/build/relations/Relation.d.cts +16 -0
  1041. package/build/relations/Relation.d.cts.map +1 -0
  1042. package/build/relations/Relation.d.mts +16 -0
  1043. package/build/relations/Relation.d.mts.map +1 -0
  1044. package/build/relations/Relation.js +10 -8
  1045. package/build/relations/Relation.js.map +1 -1
  1046. package/build/relations/RelationSymbols.cjs +9 -0
  1047. package/build/relations/RelationSymbols.cjs.map +1 -0
  1048. package/build/relations/RelationSymbols.d.cts +6 -0
  1049. package/build/relations/RelationSymbols.d.cts.map +1 -0
  1050. package/build/relations/RelationSymbols.d.mts +6 -0
  1051. package/build/relations/RelationSymbols.d.mts.map +1 -0
  1052. package/build/relations/RelationSymbols.js +7 -0
  1053. package/build/relations/RelationSymbols.js.map +1 -0
  1054. package/build/relations/hasAsyncMethod.cjs +47 -0
  1055. package/build/relations/hasAsyncMethod.cjs.map +1 -0
  1056. package/build/relations/hasAsyncMethod.d.cts +29 -0
  1057. package/build/relations/hasAsyncMethod.d.cts.map +1 -0
  1058. package/build/relations/hasAsyncMethod.d.mts +29 -0
  1059. package/build/relations/hasAsyncMethod.d.mts.map +1 -0
  1060. package/build/relations/hasAsyncMethod.js +40 -43
  1061. package/build/relations/hasAsyncMethod.js.map +1 -1
  1062. package/build/relations/hasManyDerived.cjs +35 -0
  1063. package/build/relations/hasManyDerived.cjs.map +1 -0
  1064. package/build/relations/hasManyDerived.d.cts +25 -0
  1065. package/build/relations/hasManyDerived.d.cts.map +1 -0
  1066. package/build/relations/hasManyDerived.d.mts +25 -0
  1067. package/build/relations/hasManyDerived.d.mts.map +1 -0
  1068. package/build/relations/hasManyDerived.js +30 -28
  1069. package/build/relations/hasManyDerived.js.map +1 -1
  1070. package/build/relations/hasManyThrough.cjs +29 -0
  1071. package/build/relations/hasManyThrough.cjs.map +1 -0
  1072. package/build/relations/hasManyThrough.d.cts +16 -0
  1073. package/build/relations/hasManyThrough.d.cts.map +1 -0
  1074. package/build/relations/hasManyThrough.d.mts +16 -0
  1075. package/build/relations/hasManyThrough.d.mts.map +1 -0
  1076. package/build/relations/hasManyThrough.js +24 -20
  1077. package/build/relations/hasManyThrough.js.map +1 -1
  1078. package/build/relations/hasOneDerived.cjs +32 -0
  1079. package/build/relations/hasOneDerived.cjs.map +1 -0
  1080. package/build/relations/hasOneDerived.d.cts +15 -0
  1081. package/build/relations/hasOneDerived.d.cts.map +1 -0
  1082. package/build/relations/hasOneDerived.d.mts +15 -0
  1083. package/build/relations/hasOneDerived.d.mts.map +1 -0
  1084. package/build/relations/hasOneDerived.js +27 -20
  1085. package/build/relations/hasOneDerived.js.map +1 -1
  1086. package/build/relations/hasOneThrough.cjs +31 -0
  1087. package/build/relations/hasOneThrough.cjs.map +1 -0
  1088. package/build/relations/hasOneThrough.d.cts +16 -0
  1089. package/build/relations/hasOneThrough.d.cts.map +1 -0
  1090. package/build/relations/hasOneThrough.d.mts +16 -0
  1091. package/build/relations/hasOneThrough.d.mts.map +1 -0
  1092. package/build/relations/hasOneThrough.js +26 -22
  1093. package/build/relations/hasOneThrough.js.map +1 -1
  1094. package/build/relations/hasProperty.cjs +109 -0
  1095. package/build/relations/hasProperty.cjs.map +1 -0
  1096. package/build/relations/hasProperty.d.cts +53 -0
  1097. package/build/relations/hasProperty.d.cts.map +1 -0
  1098. package/build/relations/hasProperty.d.mts +53 -0
  1099. package/build/relations/hasProperty.d.mts.map +1 -0
  1100. package/build/relations/hasProperty.js +90 -95
  1101. package/build/relations/hasProperty.js.map +1 -1
  1102. package/build/relations/index.cjs +99 -0
  1103. package/build/relations/index.d.cts +32 -0
  1104. package/build/relations/index.d.mts +32 -0
  1105. package/build/relations/index.js +31 -97
  1106. package/build/relations/isCascadeDelete.cjs +11 -0
  1107. package/build/relations/isCascadeDelete.cjs.map +1 -0
  1108. package/build/relations/isCascadeDelete.d.cts +7 -0
  1109. package/build/relations/isCascadeDelete.d.cts.map +1 -0
  1110. package/build/relations/isCascadeDelete.d.mts +7 -0
  1111. package/build/relations/isCascadeDelete.d.mts.map +1 -0
  1112. package/build/relations/isCascadeDelete.js +10 -0
  1113. package/build/relations/isCascadeDelete.js.map +1 -0
  1114. package/build/resurrection.cjs +74 -0
  1115. package/build/resurrection.cjs.map +1 -0
  1116. package/build/resurrection.d.cts +13 -0
  1117. package/build/resurrection.d.cts.map +1 -0
  1118. package/build/resurrection.d.mts +13 -0
  1119. package/build/resurrection.d.mts.map +1 -0
  1120. package/build/resurrection.js +48 -69
  1121. package/build/resurrection.js.map +1 -1
  1122. package/build/rules.cjs +227 -0
  1123. package/build/rules.cjs.map +1 -0
  1124. package/build/rules.d.cts +145 -0
  1125. package/build/rules.d.cts.map +1 -0
  1126. package/build/rules.d.mts +145 -0
  1127. package/build/rules.d.mts.map +1 -0
  1128. package/build/rules.js +189 -204
  1129. package/build/rules.js.map +1 -1
  1130. package/build/runtimeConfig.cjs +25 -0
  1131. package/build/runtimeConfig.cjs.map +1 -0
  1132. package/build/runtimeConfig.d.cts +24 -0
  1133. package/build/runtimeConfig.d.cts.map +1 -0
  1134. package/build/runtimeConfig.d.mts +24 -0
  1135. package/build/runtimeConfig.d.mts.map +1 -0
  1136. package/build/runtimeConfig.js +16 -12
  1137. package/build/runtimeConfig.js.map +1 -1
  1138. package/build/serde/TypeInfo.cjs +80 -0
  1139. package/build/serde/TypeInfo.cjs.map +1 -0
  1140. package/build/serde/TypeInfo.d.cts +57 -0
  1141. package/build/serde/TypeInfo.d.cts.map +1 -0
  1142. package/build/serde/TypeInfo.d.mts +57 -0
  1143. package/build/serde/TypeInfo.d.mts.map +1 -0
  1144. package/build/serde/TypeInfo.js +78 -0
  1145. package/build/serde/TypeInfo.js.map +1 -0
  1146. package/build/serde/columns.cjs +63 -0
  1147. package/build/serde/columns.cjs.map +1 -0
  1148. package/build/serde/columns.d.cts +38 -0
  1149. package/build/serde/columns.d.cts.map +1 -0
  1150. package/build/serde/columns.d.mts +38 -0
  1151. package/build/serde/columns.d.mts.map +1 -0
  1152. package/build/serde/columns.js +62 -0
  1153. package/build/serde/columns.js.map +1 -0
  1154. package/build/serde/fieldSerde.cjs +188 -0
  1155. package/build/serde/fieldSerde.cjs.map +1 -0
  1156. package/build/serde/fieldSerde.d.cts +87 -0
  1157. package/build/serde/fieldSerde.d.cts.map +1 -0
  1158. package/build/serde/fieldSerde.d.mts +87 -0
  1159. package/build/serde/fieldSerde.d.mts.map +1 -0
  1160. package/build/serde/fieldSerde.js +182 -0
  1161. package/build/serde/fieldSerde.js.map +1 -0
  1162. package/build/serde/serde.cjs +499 -0
  1163. package/build/serde/serde.cjs.map +1 -0
  1164. package/build/serde/serde.d.cts +248 -0
  1165. package/build/serde/serde.d.cts.map +1 -0
  1166. package/build/serde/serde.d.mts +248 -0
  1167. package/build/serde/serde.d.mts.map +1 -0
  1168. package/build/serde/serde.js +485 -0
  1169. package/build/serde/serde.js.map +1 -0
  1170. package/build/serde/temporal.cjs +57 -0
  1171. package/build/serde/temporal.cjs.map +1 -0
  1172. package/build/serde/temporal.d.cts +44 -0
  1173. package/build/serde/temporal.d.cts.map +1 -0
  1174. package/build/serde/temporal.d.mts +44 -0
  1175. package/build/serde/temporal.d.mts.map +1 -0
  1176. package/build/serde/temporal.js +55 -0
  1177. package/build/serde/temporal.js.map +1 -0
  1178. package/build/serde/temporalMappers.cjs +62 -0
  1179. package/build/serde/temporalMappers.cjs.map +1 -0
  1180. package/build/serde/temporalMappers.d.cts +36 -0
  1181. package/build/serde/temporalMappers.d.cts.map +1 -0
  1182. package/build/serde/temporalMappers.d.mts +36 -0
  1183. package/build/serde/temporalMappers.d.mts.map +1 -0
  1184. package/build/serde/temporalMappers.js +58 -0
  1185. package/build/serde/temporalMappers.js.map +1 -0
  1186. package/build/trusted.cjs +16 -0
  1187. package/build/trusted.cjs.map +1 -0
  1188. package/build/trusted.d.cts +8 -0
  1189. package/build/trusted.d.cts.map +1 -0
  1190. package/build/trusted.d.mts +8 -0
  1191. package/build/trusted.d.mts.map +1 -0
  1192. package/build/trusted.js +8 -8
  1193. package/build/trusted.js.map +1 -1
  1194. package/build/typeMap.cjs +3 -0
  1195. package/build/typeMap.d.cts +88 -0
  1196. package/build/typeMap.d.cts.map +1 -0
  1197. package/build/typeMap.d.mts +88 -0
  1198. package/build/typeMap.d.mts.map +1 -0
  1199. package/build/typeMap.js +3 -3
  1200. package/build/upsert.cjs +175 -0
  1201. package/build/upsert.cjs.map +1 -0
  1202. package/build/upsert.d.cts +42 -0
  1203. package/build/upsert.d.cts.map +1 -0
  1204. package/build/upsert.d.mts +42 -0
  1205. package/build/upsert.d.mts.map +1 -0
  1206. package/build/upsert.js +159 -274
  1207. package/build/upsert.js.map +1 -1
  1208. package/build/utils.cjs +204 -0
  1209. package/build/utils.cjs.map +1 -0
  1210. package/build/utils.d.cts +65 -0
  1211. package/build/utils.d.cts.map +1 -0
  1212. package/build/utils.d.mts +65 -0
  1213. package/build/utils.d.mts.map +1 -0
  1214. package/build/utils.js +123 -192
  1215. package/build/utils.js.map +1 -1
  1216. package/package.json +34 -14
  1217. package/build/AliasAssigner.d.ts +0 -10
  1218. package/build/AliasAssigner.d.ts.map +0 -1
  1219. package/build/AliasAssigner.js +0 -39
  1220. package/build/AliasAssigner.js.map +0 -1
  1221. package/build/Aliases.d.ts +0 -117
  1222. package/build/Aliases.d.ts.map +0 -1
  1223. package/build/Aliases.js +0 -457
  1224. package/build/Aliases.js.map +0 -1
  1225. package/build/BaseEntity.d.ts +0 -68
  1226. package/build/BaseEntity.d.ts.map +0 -1
  1227. package/build/ConditionBuilder.d.ts +0 -29
  1228. package/build/ConditionBuilder.d.ts.map +0 -1
  1229. package/build/ConditionBuilder.js +0 -112
  1230. package/build/ConditionBuilder.js.map +0 -1
  1231. package/build/Entity.d.ts +0 -39
  1232. package/build/Entity.d.ts.map +0 -1
  1233. package/build/EntityFields.d.ts +0 -37
  1234. package/build/EntityFields.d.ts.map +0 -1
  1235. package/build/EntityFields.js.map +0 -1
  1236. package/build/EntityFilter.d.ts +0 -134
  1237. package/build/EntityFilter.d.ts.map +0 -1
  1238. package/build/EntityFilter.js +0 -21
  1239. package/build/EntityFilter.js.map +0 -1
  1240. package/build/EntityGraphQLFilter.d.ts +0 -56
  1241. package/build/EntityGraphQLFilter.d.ts.map +0 -1
  1242. package/build/EntityGraphQLFilter.js +0 -53
  1243. package/build/EntityGraphQLFilter.js.map +0 -1
  1244. package/build/EntityManager.d.ts +0 -740
  1245. package/build/EntityManager.d.ts.map +0 -1
  1246. package/build/EntityMetadata.d.ts +0 -233
  1247. package/build/EntityMetadata.d.ts.map +0 -1
  1248. package/build/EnumMetadata.d.ts +0 -15
  1249. package/build/EnumMetadata.d.ts.map +0 -1
  1250. package/build/EnumMetadata.js.map +0 -1
  1251. package/build/FlushLock.d.ts +0 -26
  1252. package/build/FlushLock.d.ts.map +0 -1
  1253. package/build/FlushLock.js +0 -57
  1254. package/build/FlushLock.js.map +0 -1
  1255. package/build/HintTree.d.ts +0 -42
  1256. package/build/HintTree.d.ts.map +0 -1
  1257. package/build/HintTree.js +0 -64
  1258. package/build/HintTree.js.map +0 -1
  1259. package/build/IndexManager.d.ts +0 -31
  1260. package/build/IndexManager.d.ts.map +0 -1
  1261. package/build/InstanceData.d.ts +0 -79
  1262. package/build/InstanceData.d.ts.map +0 -1
  1263. package/build/IsLoadedCache.d.ts +0 -32
  1264. package/build/IsLoadedCache.d.ts.map +0 -1
  1265. package/build/IsLoadedCache.js +0 -91
  1266. package/build/IsLoadedCache.js.map +0 -1
  1267. package/build/JoinRows.d.ts +0 -117
  1268. package/build/JoinRows.d.ts.map +0 -1
  1269. package/build/JoinRows.js +0 -320
  1270. package/build/JoinRows.js.map +0 -1
  1271. package/build/PendingChanges.d.ts +0 -26
  1272. package/build/PendingChanges.d.ts.map +0 -1
  1273. package/build/PendingChanges.js +0 -3
  1274. package/build/PendingChanges.js.map +0 -1
  1275. package/build/PluginManager.d.ts +0 -102
  1276. package/build/PluginManager.d.ts.map +0 -1
  1277. package/build/QueryParser.collectionJoins.d.ts +0 -27
  1278. package/build/QueryParser.collectionJoins.d.ts.map +0 -1
  1279. package/build/QueryParser.collectionJoins.js +0 -466
  1280. package/build/QueryParser.collectionJoins.js.map +0 -1
  1281. package/build/QueryParser.collectionJoins.test.d.ts +0 -2
  1282. package/build/QueryParser.collectionJoins.test.d.ts.map +0 -1
  1283. package/build/QueryParser.collectionJoins.test.js +0 -772
  1284. package/build/QueryParser.collectionJoins.test.js.map +0 -1
  1285. package/build/QueryParser.d.ts +0 -336
  1286. package/build/QueryParser.d.ts.map +0 -1
  1287. package/build/QueryParser.js +0 -965
  1288. package/build/QueryParser.js.map +0 -1
  1289. package/build/QueryParser.pruning.d.ts +0 -7
  1290. package/build/QueryParser.pruning.d.ts.map +0 -1
  1291. package/build/QueryParser.pruning.js +0 -195
  1292. package/build/QueryParser.pruning.js.map +0 -1
  1293. package/build/QueryParser.pruning.test.d.ts +0 -2
  1294. package/build/QueryParser.pruning.test.d.ts.map +0 -1
  1295. package/build/QueryParser.pruning.test.js +0 -106
  1296. package/build/QueryParser.pruning.test.js.map +0 -1
  1297. package/build/QueryParser.test.d.ts +0 -2
  1298. package/build/QueryParser.test.d.ts.map +0 -1
  1299. package/build/QueryParser.test.js +0 -27
  1300. package/build/QueryParser.test.js.map +0 -1
  1301. package/build/QueryVisitor.d.ts +0 -19
  1302. package/build/QueryVisitor.d.ts.map +0 -1
  1303. package/build/QueryVisitor.js +0 -106
  1304. package/build/QueryVisitor.js.map +0 -1
  1305. package/build/ReactionsManager.d.ts +0 -85
  1306. package/build/ReactionsManager.d.ts.map +0 -1
  1307. package/build/ReactionsManager.js +0 -315
  1308. package/build/ReactionsManager.js.map +0 -1
  1309. package/build/Todo.d.ts +0 -35
  1310. package/build/Todo.d.ts.map +0 -1
  1311. package/build/Todo.js +0 -73
  1312. package/build/Todo.js.map +0 -1
  1313. package/build/batchloaders/BatchLoader.d.ts +0 -14
  1314. package/build/batchloaders/BatchLoader.d.ts.map +0 -1
  1315. package/build/batchloaders/enumCollectionBatchLoader.d.ts +0 -7
  1316. package/build/batchloaders/enumCollectionBatchLoader.d.ts.map +0 -1
  1317. package/build/batchloaders/loadBatchLoader.d.ts +0 -17
  1318. package/build/batchloaders/loadBatchLoader.d.ts.map +0 -1
  1319. package/build/batchloaders/manyToManyBatchLoader.d.ts +0 -7
  1320. package/build/batchloaders/manyToManyBatchLoader.d.ts.map +0 -1
  1321. package/build/batchloaders/oneToManyBatchLoader.d.ts +0 -7
  1322. package/build/batchloaders/oneToManyBatchLoader.d.ts.map +0 -1
  1323. package/build/batchloaders/oneToOneBatchLoader.d.ts +0 -7
  1324. package/build/batchloaders/oneToOneBatchLoader.d.ts.map +0 -1
  1325. package/build/batchloaders/populateBatchLoader.d.ts +0 -13
  1326. package/build/batchloaders/populateBatchLoader.d.ts.map +0 -1
  1327. package/build/batchloaders/recursiveChildrenBatchLoader.d.ts +0 -7
  1328. package/build/batchloaders/recursiveChildrenBatchLoader.d.ts.map +0 -1
  1329. package/build/batchloaders/recursiveM2mBatchLoader.d.ts +0 -7
  1330. package/build/batchloaders/recursiveM2mBatchLoader.d.ts.map +0 -1
  1331. package/build/batchloaders/recursiveParentsBatchLoader.d.ts +0 -7
  1332. package/build/batchloaders/recursiveParentsBatchLoader.d.ts.map +0 -1
  1333. package/build/changes.d.ts +0 -92
  1334. package/build/changes.d.ts.map +0 -1
  1335. package/build/config.d.ts +0 -250
  1336. package/build/config.d.ts.map +0 -1
  1337. package/build/config.test.d.ts +0 -2
  1338. package/build/config.test.d.ts.map +0 -1
  1339. package/build/config.test.js +0 -53
  1340. package/build/config.test.js.map +0 -1
  1341. package/build/configure.d.ts +0 -15
  1342. package/build/configure.d.ts.map +0 -1
  1343. package/build/dataloaders/fastWhereFilterHash.d.ts +0 -15
  1344. package/build/dataloaders/fastWhereFilterHash.d.ts.map +0 -1
  1345. package/build/dataloaders/fastWhereFilterHash.test.d.ts +0 -2
  1346. package/build/dataloaders/fastWhereFilterHash.test.d.ts.map +0 -1
  1347. package/build/dataloaders/fastWhereFilterHash.test.js +0 -59
  1348. package/build/dataloaders/fastWhereFilterHash.test.js.map +0 -1
  1349. package/build/dataloaders/findByUniqueDataLoader.d.ts +0 -7
  1350. package/build/dataloaders/findByUniqueDataLoader.d.ts.map +0 -1
  1351. package/build/dataloaders/findCountDataLoader.d.ts +0 -16
  1352. package/build/dataloaders/findCountDataLoader.d.ts.map +0 -1
  1353. package/build/dataloaders/findDataLoader.d.ts +0 -76
  1354. package/build/dataloaders/findDataLoader.d.ts.map +0 -1
  1355. package/build/dataloaders/findIdsDataLoader.d.ts +0 -6
  1356. package/build/dataloaders/findIdsDataLoader.d.ts.map +0 -1
  1357. package/build/dataloaders/findOrCreateDataLoader.d.ts +0 -13
  1358. package/build/dataloaders/findOrCreateDataLoader.d.ts.map +0 -1
  1359. package/build/dataloaders/findPaginatedDataLoader.d.ts +0 -7
  1360. package/build/dataloaders/findPaginatedDataLoader.d.ts.map +0 -1
  1361. package/build/dataloaders/lensDataLoader.d.ts +0 -12
  1362. package/build/dataloaders/lensDataLoader.d.ts.map +0 -1
  1363. package/build/dataloaders/manyToManyFindDataLoader.d.ts +0 -8
  1364. package/build/dataloaders/manyToManyFindDataLoader.d.ts.map +0 -1
  1365. package/build/dataloaders/oneToManyFindDataLoader.d.ts +0 -8
  1366. package/build/dataloaders/oneToManyFindDataLoader.d.ts.map +0 -1
  1367. package/build/defaults.d.ts +0 -54
  1368. package/build/defaults.d.ts.map +0 -1
  1369. package/build/driverApi.d.ts +0 -19
  1370. package/build/driverApi.d.ts.map +0 -1
  1371. package/build/driverApi.js +0 -17
  1372. package/build/driverApi.js.map +0 -1
  1373. package/build/drivers/Driver.d.ts +0 -26
  1374. package/build/drivers/Driver.d.ts.map +0 -1
  1375. package/build/drivers/Driver.js.map +0 -1
  1376. package/build/drivers/EntityWriter.d.ts +0 -64
  1377. package/build/drivers/EntityWriter.d.ts.map +0 -1
  1378. package/build/drivers/IdAssigner.d.ts +0 -48
  1379. package/build/drivers/IdAssigner.d.ts.map +0 -1
  1380. package/build/drivers/buildRawQuery.d.ts +0 -22
  1381. package/build/drivers/buildRawQuery.d.ts.map +0 -1
  1382. package/build/drivers/buildRawQuery.js +0 -153
  1383. package/build/drivers/buildRawQuery.js.map +0 -1
  1384. package/build/drivers/buildUtils.d.ts +0 -9
  1385. package/build/drivers/buildUtils.d.ts.map +0 -1
  1386. package/build/drivers/buildUtils.js +0 -88
  1387. package/build/drivers/buildUtils.js.map +0 -1
  1388. package/build/drivers/index.d.ts +0 -6
  1389. package/build/drivers/index.d.ts.map +0 -1
  1390. package/build/drivers/index.js.map +0 -1
  1391. package/build/fields.d.ts +0 -26
  1392. package/build/fields.d.ts.map +0 -1
  1393. package/build/getProperties.d.ts +0 -28
  1394. package/build/getProperties.d.ts.map +0 -1
  1395. package/build/index.d.ts +0 -133
  1396. package/build/index.d.ts.map +0 -1
  1397. package/build/json.d.ts +0 -77
  1398. package/build/json.d.ts.map +0 -1
  1399. package/build/k.d.ts +0 -2
  1400. package/build/k.d.ts.map +0 -1
  1401. package/build/keys.d.ts +0 -49
  1402. package/build/keys.d.ts.map +0 -1
  1403. package/build/keywords.d.ts +0 -5
  1404. package/build/keywords.d.ts.map +0 -1
  1405. package/build/keywords.js +0 -124
  1406. package/build/keywords.js.map +0 -1
  1407. package/build/loadHints.d.ts +0 -121
  1408. package/build/loadHints.d.ts.map +0 -1
  1409. package/build/loadHints.js +0 -129
  1410. package/build/loadHints.js.map +0 -1
  1411. package/build/loadLens.d.ts +0 -77
  1412. package/build/loadLens.d.ts.map +0 -1
  1413. package/build/loadLens.js +0 -320
  1414. package/build/loadLens.js.map +0 -1
  1415. package/build/logging/FactoryLogger.d.ts +0 -24
  1416. package/build/logging/FactoryLogger.d.ts.map +0 -1
  1417. package/build/logging/FieldLogger.d.ts +0 -27
  1418. package/build/logging/FieldLogger.d.ts.map +0 -1
  1419. package/build/logging/ReactionLogger.d.ts +0 -27
  1420. package/build/logging/ReactionLogger.d.ts.map +0 -1
  1421. package/build/newEntity.d.ts +0 -45
  1422. package/build/newEntity.d.ts.map +0 -1
  1423. package/build/newTestInstance.d.ts +0 -208
  1424. package/build/newTestInstance.d.ts.map +0 -1
  1425. package/build/normalizeHints.d.ts +0 -23
  1426. package/build/normalizeHints.d.ts.map +0 -1
  1427. package/build/plugins/ImmutableEntitiesPlugin.d.ts +0 -9
  1428. package/build/plugins/ImmutableEntitiesPlugin.d.ts.map +0 -1
  1429. package/build/plugins/PreloadPlugin.d.ts +0 -69
  1430. package/build/plugins/PreloadPlugin.d.ts.map +0 -1
  1431. package/build/plugins/PreloadPlugin.js.map +0 -1
  1432. package/build/preloading/JsonAggregatePreloader.d.ts +0 -16
  1433. package/build/preloading/JsonAggregatePreloader.d.ts.map +0 -1
  1434. package/build/preloading/canPreload.d.ts +0 -3
  1435. package/build/preloading/canPreload.d.ts.map +0 -1
  1436. package/build/preloading/partitionHint.d.ts +0 -5
  1437. package/build/preloading/partitionHint.d.ts.map +0 -1
  1438. package/build/reactiveHints.d.ts +0 -146
  1439. package/build/reactiveHints.d.ts.map +0 -1
  1440. package/build/reactiveHints.js +0 -509
  1441. package/build/reactiveHints.js.map +0 -1
  1442. package/build/relations/AbstractPropertyImpl.d.ts +0 -8
  1443. package/build/relations/AbstractPropertyImpl.d.ts.map +0 -1
  1444. package/build/relations/AbstractRelationImpl.d.ts +0 -41
  1445. package/build/relations/AbstractRelationImpl.d.ts.map +0 -1
  1446. package/build/relations/AsyncProperty.d.ts +0 -36
  1447. package/build/relations/AsyncProperty.d.ts.map +0 -1
  1448. package/build/relations/AsyncReactiveField.d.ts +0 -41
  1449. package/build/relations/AsyncReactiveField.d.ts.map +0 -1
  1450. package/build/relations/Collection.d.ts +0 -33
  1451. package/build/relations/Collection.d.ts.map +0 -1
  1452. package/build/relations/CustomCollection.d.ts +0 -69
  1453. package/build/relations/CustomCollection.d.ts.map +0 -1
  1454. package/build/relations/CustomReference.d.ts +0 -71
  1455. package/build/relations/CustomReference.d.ts.map +0 -1
  1456. package/build/relations/EnumCollection.d.ts +0 -81
  1457. package/build/relations/EnumCollection.d.ts.map +0 -1
  1458. package/build/relations/LargeCollection.d.ts +0 -19
  1459. package/build/relations/LargeCollection.d.ts.map +0 -1
  1460. package/build/relations/LargeCollection.js.map +0 -1
  1461. package/build/relations/ManyToManyCollection.d.ts +0 -52
  1462. package/build/relations/ManyToManyCollection.d.ts.map +0 -1
  1463. package/build/relations/ManyToManyLargeCollection.d.ts +0 -31
  1464. package/build/relations/ManyToManyLargeCollection.d.ts.map +0 -1
  1465. package/build/relations/ManyToOneReference.d.ts +0 -117
  1466. package/build/relations/ManyToOneReference.d.ts.map +0 -1
  1467. package/build/relations/OneToManyCollection.d.ts +0 -62
  1468. package/build/relations/OneToManyCollection.d.ts.map +0 -1
  1469. package/build/relations/OneToManyLargeCollection.d.ts +0 -26
  1470. package/build/relations/OneToManyLargeCollection.d.ts.map +0 -1
  1471. package/build/relations/OneToOneReference.d.ts +0 -93
  1472. package/build/relations/OneToOneReference.d.ts.map +0 -1
  1473. package/build/relations/PolymorphicReference.d.ts +0 -89
  1474. package/build/relations/PolymorphicReference.d.ts.map +0 -1
  1475. package/build/relations/ReactiveField.d.ts +0 -85
  1476. package/build/relations/ReactiveField.d.ts.map +0 -1
  1477. package/build/relations/ReactiveGetter.d.ts +0 -30
  1478. package/build/relations/ReactiveGetter.d.ts.map +0 -1
  1479. package/build/relations/ReactiveManyToMany.d.ts +0 -57
  1480. package/build/relations/ReactiveManyToMany.d.ts.map +0 -1
  1481. package/build/relations/ReactiveManyToManyOtherSide.d.ts +0 -48
  1482. package/build/relations/ReactiveManyToManyOtherSide.d.ts.map +0 -1
  1483. package/build/relations/ReactiveReference.d.ts +0 -119
  1484. package/build/relations/ReactiveReference.d.ts.map +0 -1
  1485. package/build/relations/ReadOnlyCollection.d.ts +0 -19
  1486. package/build/relations/ReadOnlyCollection.d.ts.map +0 -1
  1487. package/build/relations/RecursiveCollection.d.ts +0 -108
  1488. package/build/relations/RecursiveCollection.d.ts.map +0 -1
  1489. package/build/relations/RecursiveCycleError.d.ts +0 -13
  1490. package/build/relations/RecursiveCycleError.d.ts.map +0 -1
  1491. package/build/relations/Reference.d.ts +0 -35
  1492. package/build/relations/Reference.d.ts.map +0 -1
  1493. package/build/relations/Relation.d.ts +0 -14
  1494. package/build/relations/Relation.d.ts.map +0 -1
  1495. package/build/relations/hasAsyncMethod.d.ts +0 -27
  1496. package/build/relations/hasAsyncMethod.d.ts.map +0 -1
  1497. package/build/relations/hasManyDerived.d.ts +0 -22
  1498. package/build/relations/hasManyDerived.d.ts.map +0 -1
  1499. package/build/relations/hasManyThrough.d.ts +0 -10
  1500. package/build/relations/hasManyThrough.d.ts.map +0 -1
  1501. package/build/relations/hasOneDerived.d.ts +0 -12
  1502. package/build/relations/hasOneDerived.d.ts.map +0 -1
  1503. package/build/relations/hasOneThrough.d.ts +0 -10
  1504. package/build/relations/hasOneThrough.d.ts.map +0 -1
  1505. package/build/relations/hasProperty.d.ts +0 -50
  1506. package/build/relations/hasProperty.d.ts.map +0 -1
  1507. package/build/relations/index.d.ts +0 -30
  1508. package/build/relations/index.d.ts.map +0 -1
  1509. package/build/relations/index.js.map +0 -1
  1510. package/build/resurrection.d.ts +0 -10
  1511. package/build/resurrection.d.ts.map +0 -1
  1512. package/build/rules.d.ts +0 -123
  1513. package/build/rules.d.ts.map +0 -1
  1514. package/build/runtimeConfig.d.ts +0 -17
  1515. package/build/runtimeConfig.d.ts.map +0 -1
  1516. package/build/scopes.d.ts +0 -185
  1517. package/build/scopes.d.ts.map +0 -1
  1518. package/build/scopes.js +0 -302
  1519. package/build/scopes.js.map +0 -1
  1520. package/build/serde.d.ts +0 -277
  1521. package/build/serde.d.ts.map +0 -1
  1522. package/build/serde.js +0 -517
  1523. package/build/serde.js.map +0 -1
  1524. package/build/temporal.d.ts +0 -46
  1525. package/build/temporal.d.ts.map +0 -1
  1526. package/build/temporal.js +0 -66
  1527. package/build/temporal.js.map +0 -1
  1528. package/build/temporalMappers.d.ts +0 -25
  1529. package/build/temporalMappers.d.ts.map +0 -1
  1530. package/build/temporalMappers.js +0 -59
  1531. package/build/temporalMappers.js.map +0 -1
  1532. package/build/trusted.d.ts +0 -5
  1533. package/build/trusted.d.ts.map +0 -1
  1534. package/build/typeMap.d.ts +0 -68
  1535. package/build/typeMap.d.ts.map +0 -1
  1536. package/build/typeMap.js.map +0 -1
  1537. package/build/unnest.d.ts +0 -13
  1538. package/build/unnest.d.ts.map +0 -1
  1539. package/build/unnest.js +0 -85
  1540. package/build/unnest.js.map +0 -1
  1541. package/build/upsert.d.ts +0 -42
  1542. package/build/upsert.d.ts.map +0 -1
  1543. package/build/utils.d.ts +0 -60
  1544. package/build/utils.d.ts.map +0 -1
  1545. package/build/withLoaded.d.ts +0 -56
  1546. package/build/withLoaded.d.ts.map +0 -1
  1547. package/build/withLoaded.js +0 -76
  1548. package/build/withLoaded.js.map +0 -1
@@ -0,0 +1,1935 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
3
+ const require_batchloaders_BatchLoader = require("./batchloaders/BatchLoader.cjs");
4
+ require("./relations/Collection.cjs");
5
+ const require_relations_CustomCollection = require("./relations/CustomCollection.cjs");
6
+ const require_relations_CustomReference = require("./relations/CustomReference.cjs");
7
+ const require_normalizeHints = require("./normalizeHints.cjs");
8
+ require("./batchloaders/recursiveChildrenBatchLoader.cjs");
9
+ require("./batchloaders/recursiveM2mBatchLoader.cjs");
10
+ require("./batchloaders/recursiveParentsBatchLoader.cjs");
11
+ const require_relations_RecursiveCycleError = require("./relations/RecursiveCycleError.cjs");
12
+ require("./relations/RecursiveCollection.cjs");
13
+ const require_reactivity_reactiveHints = require("./reactivity/reactiveHints.cjs");
14
+ const require_loading_loadHints = require("./loading/loadHints.cjs");
15
+ const require_relations_hasAsyncMethod = require("./relations/hasAsyncMethod.cjs");
16
+ const require_relations_AsyncProperty = require("./relations/AsyncProperty.cjs");
17
+ const require_fields = require("./fields.cjs");
18
+ const require_keys = require("./keys.cjs");
19
+ const require_RowData = require("./RowData.cjs");
20
+ const require_relations_LazyField = require("./relations/LazyField.cjs");
21
+ const require_relations_Reference = require("./relations/Reference.cjs");
22
+ require("./batchloaders/manyToManyBatchLoader.cjs");
23
+ require("./batchloaders/oneToManyBatchLoader.cjs");
24
+ const require_queries_find_scopes = require("./queries/find/scopes.cjs");
25
+ const require_relations_OneToManyCollection = require("./relations/OneToManyCollection.cjs");
26
+ const require_relations_ManyToOneReference = require("./relations/ManyToOneReference.cjs");
27
+ require("./batchloaders/oneToOneBatchLoader.cjs");
28
+ const require_relations_ReactiveReference = require("./relations/ReactiveReference.cjs");
29
+ const require_relations_OneToOneReference = require("./relations/OneToOneReference.cjs");
30
+ const require_relations_PolymorphicReference = require("./relations/PolymorphicReference.cjs");
31
+ require("./relations/index.cjs");
32
+ const require_utils = require("./utils.cjs");
33
+ const require_newEntity = require("./newEntity.cjs");
34
+ require("./typeMap.cjs");
35
+ const require_rules = require("./rules.cjs");
36
+ const require_configure = require("./configure.cjs");
37
+ const require_config = require("./config.cjs");
38
+ const require_EntityMetadata = require("./EntityMetadata.cjs");
39
+ const require_trusted = require("./trusted.cjs");
40
+ const require_defaults = require("./defaults.cjs");
41
+ require("./dataloaders/lensDataLoader.cjs");
42
+ const require_loading_loadLens = require("./loading/loadLens.cjs");
43
+ require("./logging/FactoryLogger.cjs");
44
+ const require_newTestInstance = require("./newTestInstance.cjs");
45
+ const require_queries_find_EntityFilter = require("./queries/find/EntityFilter.cjs");
46
+ const require_flush_JoinRows = require("./flush/JoinRows.cjs");
47
+ const require_PluginManager = require("./PluginManager.cjs");
48
+ const require_queries_find_QueryParser_collectionJoins = require("./queries/find/QueryParser.collectionJoins.cjs");
49
+ const require_flush_Todo = require("./flush/Todo.cjs");
50
+ const require_dataloaders_findDataLoader = require("./dataloaders/findDataLoader.cjs");
51
+ require("./drivers/index.cjs");
52
+ const require_logging_FieldLogger = require("./logging/FieldLogger.cjs");
53
+ const require_logging_ReactionLogger = require("./logging/ReactionLogger.cjs");
54
+ require("./plugins/PreloadPlugin.cjs");
55
+ const require_queries_sql_query = require("./queries/sql/query.cjs");
56
+ const require_upsert = require("./upsert.cjs");
57
+ const require_index = require("./index.cjs");
58
+ require("./batchloaders/enumCollectionBatchLoader.cjs");
59
+ const require_batchloaders_loadBatchLoader = require("./batchloaders/loadBatchLoader.cjs");
60
+ const require_batchloaders_populateBatchLoader = require("./batchloaders/populateBatchLoader.cjs");
61
+ const require_dataloaders_findByUniqueDataLoader = require("./dataloaders/findByUniqueDataLoader.cjs");
62
+ const require_dataloaders_findCountDataLoader = require("./dataloaders/findCountDataLoader.cjs");
63
+ const require_dataloaders_findIdsDataLoader = require("./dataloaders/findIdsDataLoader.cjs");
64
+ const require_dataloaders_findOrCreateDataLoader = require("./dataloaders/findOrCreateDataLoader.cjs");
65
+ const require_dataloaders_findPaginatedDataLoader = require("./dataloaders/findPaginatedDataLoader.cjs");
66
+ const require_flush_FlushLock = require("./flush/FlushLock.cjs");
67
+ const require_IndexManager = require("./IndexManager.cjs");
68
+ const require_loading_IsLoadedCache = require("./loading/IsLoadedCache.cjs");
69
+ const require_queries_sql_execute = require("./queries/sql/execute.cjs");
70
+ const require_reactivity_ReactionsManager = require("./reactivity/ReactionsManager.cjs");
71
+ const require_Entity = require("./Entity.cjs");
72
+ const require_BaseEntity = require("./BaseEntity.cjs");
73
+ let dataloader = require("dataloader");
74
+ dataloader = require_runtime.__toESM(dataloader, 1);
75
+ //#region src/EntityManager.ts
76
+ Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
77
+ function isId(value) {
78
+ return value && typeof value === "string";
79
+ }
80
+ /**
81
+ * The EntityManager is the primary way nearly all code, i.e. anything that finds/creates/updates/deletes entities,
82
+ * will interact with the database.
83
+ *
84
+ * It acts both an Identity Cache (preventing loading the same row twice into memory as separate entities, and then
85
+ * having drift between the two instances) and as a Unit of Work (tracking all changes to entities and then batch
86
+ * flushing only the entities that have changed).
87
+ *
88
+ * Note that the type parameters (C, I, and Entity) will be filled in by codegen with the values specific to your
89
+ * application, so you can import your app-specific EntityManager like:
90
+ *
91
+ * ```ts
92
+ * import { EntityManager } from "src/entities";
93
+ * ```
94
+ *
95
+ * @param C The type of your application-specific app-wide/request-wide Context object that will be passed to hooks
96
+ * @typeParam C - the application-specific context (typically the request-level context)
97
+ * @typeParam Entity - the application's based entity type (i.e. with number ids or string ids)
98
+ * @typeParamTX - the application's Transaction type, i.e. `Knex`
99
+ */
100
+ var EntityManager = class EntityManager {
101
+ ctx;
102
+ driver;
103
+ /** When we're flushing, the connection/transaction. */
104
+ txn;
105
+ entityLimit = defaultEntityLimit;
106
+ #entitiesArray = [];
107
+ #maybePendingFlushEntities = /* @__PURE__ */ new Set();
108
+ #entitiesById = /* @__PURE__ */ new Map();
109
+ #entitiesByTag = /* @__PURE__ */ new Map();
110
+ #indexManager = new require_IndexManager.IndexManager();
111
+ #isValidating = false;
112
+ #findRestricted = false;
113
+ #pendingPercolate = /* @__PURE__ */ new Map();
114
+ #preloadedRelations = /* @__PURE__ */ new Map();
115
+ /**
116
+ * Tracks cascade deletes.
117
+ *
118
+ * We originally used a beforeDelete lifecycle hook to implement this, but tracking this
119
+ * individually allows us to a) recursively cascade deletes even during the 1st iteration
120
+ * of our `flush` loop, and b) cascade deletions before we recalc fields & run user hooks,
121
+ * so that both see the most accurate state.
122
+ */
123
+ #pendingDeletes = [];
124
+ #hasAnyDeletes = false;
125
+ #dataloaders = {};
126
+ #batchLoaders = {};
127
+ #joinRows = {};
128
+ /** Stores any `source -> downstream` reactions to recalc during `em.flush`. */
129
+ #rm = new require_reactivity_ReactionsManager.ReactionsManager(this);
130
+ /** Ensures our `em.flush` method is not interrupted. */
131
+ #fl = new require_flush_FlushLock.FlushLock();
132
+ #hooks = {
133
+ beforeBegin: [],
134
+ afterBegin: [],
135
+ beforeCommit: [],
136
+ afterCommit: []
137
+ };
138
+ #preloader;
139
+ #fieldLogger = require_logging_FieldLogger.noopFieldLogger;
140
+ #isLoadedCache = new require_loading_IsLoadedCache.IsLoadedCache();
141
+ #merging;
142
+ /** Track `a#1`, `a#2`, etc indexes for `em.create`-d entities. */
143
+ #createCounter = void 0;
144
+ __api;
145
+ #isRefreshing = false;
146
+ mode = "writes";
147
+ constructor(ctx, driverOrOpts) {
148
+ const opts = driverOrOpts.constructor === Object ? driverOrOpts : { driver: driverOrOpts };
149
+ this.ctx = ctx;
150
+ this.driver = opts.driver ?? opts.em.driver;
151
+ this.#preloader = opts.preloadPlugin ?? (opts.em ? opts.em.#preloader : this.driver.defaultPlugins.preloadPlugin);
152
+ const pluginManager = new require_PluginManager.PluginManager(this);
153
+ if (opts.em) {
154
+ this.#hooks = {
155
+ beforeBegin: [...opts.em.#hooks.beforeBegin],
156
+ afterBegin: [...opts.em.#hooks.afterBegin],
157
+ beforeCommit: [...opts.em.#hooks.beforeCommit],
158
+ afterCommit: [...opts.em.#hooks.afterCommit]
159
+ };
160
+ opts.em.__api.pluginManager.cloneTo(pluginManager);
161
+ }
162
+ const em = this;
163
+ this.__api = {
164
+ preloader: this.#preloader,
165
+ pendingPercolate: this.#pendingPercolate,
166
+ mutatedCollections: /* @__PURE__ */ new Set(),
167
+ pendingLoads: /* @__PURE__ */ new Set(),
168
+ hooks: this.#hooks,
169
+ rm: this.#rm,
170
+ indexManager: this.#indexManager,
171
+ isLoadedCache: this.#isLoadedCache,
172
+ pluginManager,
173
+ markMaybePending(entity) {
174
+ em.#maybePendingFlushEntities.add(entity);
175
+ },
176
+ unmarkMaybePending(entity) {
177
+ em.#maybePendingFlushEntities.delete(entity);
178
+ },
179
+ hasAnyDeletes() {
180
+ return em.#hasAnyDeletes;
181
+ },
182
+ pendingDeleteIds(type) {
183
+ return em.#pendingDeletes.filter((entity) => entity instanceof type && entity.idMaybe !== void 0).map((entity) => require_keys.keyToNumber(require_EntityMetadata.getMetadata(entity), entity.id));
184
+ },
185
+ isMerging(entity) {
186
+ return em.#merging?.has(entity) ?? false;
187
+ },
188
+ joinRows(m2m) {
189
+ return require_utils.getOrSet(em.#joinRows, m2m.joinTableName, () => new require_flush_JoinRows.JoinRows(m2m, em.#rm));
190
+ },
191
+ /** Returns `a:1.books` if it's in our preload cache. */
192
+ getPreloadedRelation(taggedId, fieldName) {
193
+ return em.#preloadedRelations.get(taggedId)?.get(fieldName);
194
+ },
195
+ /** Stores `a:1.books` in our preload cache. */
196
+ setPreloadedRelation(taggedId, fieldName, children) {
197
+ let map = em.#preloadedRelations.get(taggedId);
198
+ if (!map) {
199
+ map = /* @__PURE__ */ new Map();
200
+ em.#preloadedRelations.set(taggedId, map);
201
+ }
202
+ map.set(fieldName, children);
203
+ },
204
+ get isValidating() {
205
+ return em.#isValidating;
206
+ },
207
+ checkWritesAllowed() {
208
+ if (em.mode === "read-only") throw new ReadOnlyError();
209
+ return em.#fl.checkWritesAllowed();
210
+ },
211
+ get fieldLogger() {
212
+ return em.#fieldLogger;
213
+ },
214
+ clearDataloaders() {
215
+ em.#dataloaders = {};
216
+ em.#batchLoaders = {};
217
+ },
218
+ clearPreloadedRelations() {
219
+ em.#preloadedRelations = /* @__PURE__ */ new Map();
220
+ },
221
+ setIsRefreshing(isRefreshing) {
222
+ em.#isRefreshing = isRefreshing;
223
+ }
224
+ };
225
+ }
226
+ /** Returns a read-only shallow copy of the currently-loaded entities. */
227
+ get entities() {
228
+ return [...this.#entitiesArray];
229
+ }
230
+ /** Returns a list of all pending creates, updates, deletes, and m2m changes that would be flushed. */
231
+ get pendingChanges() {
232
+ const changes = [];
233
+ for (const entity of this.#entitiesArray) switch (require_BaseEntity.getInstanceData(entity).pendingOperation) {
234
+ case "insert":
235
+ changes.push({
236
+ kind: "create",
237
+ entity
238
+ });
239
+ break;
240
+ case "update":
241
+ changes.push({
242
+ kind: "update",
243
+ entity
244
+ });
245
+ break;
246
+ case "delete": changes.push({
247
+ kind: "delete",
248
+ entity
249
+ });
250
+ }
251
+ for (const joinRows of Object.values(this.#joinRows)) {
252
+ const todo = joinRows.toTodo();
253
+ if (todo && !todo.m2m.otherEnum) {
254
+ for (const row of todo.newRows) {
255
+ const entities = Object.values(row.columns);
256
+ changes.push({
257
+ kind: "m2m",
258
+ op: "add",
259
+ joinTableName: todo.m2m.joinTableName,
260
+ entities
261
+ });
262
+ }
263
+ for (const row of todo.deletedRows) {
264
+ const entities = Object.values(row.columns);
265
+ changes.push({
266
+ kind: "m2m",
267
+ op: "remove",
268
+ joinTableName: todo.m2m.joinTableName,
269
+ entities
270
+ });
271
+ }
272
+ }
273
+ }
274
+ return changes;
275
+ }
276
+ /** Returns a read-only list of the currently-loaded entities of `type`. */
277
+ getEntities(type) {
278
+ const meta = require_EntityMetadata.getMetadata(type);
279
+ const entities = this.#entitiesByTag.get(meta.tagName) ?? [];
280
+ return meta.baseType ? entities.filter((e) => e instanceof type) : entities;
281
+ }
282
+ getEntity(id) {
283
+ return this.#entitiesById.get(id);
284
+ }
285
+ async find(type, where, options) {
286
+ this.#assertFindAllowed("find");
287
+ const { populate, ...rest } = options || {};
288
+ const normalized = require_queries_find_EntityFilter.mergeFindOptions(where, rest);
289
+ const settings = {
290
+ where: normalized.where,
291
+ ...normalized.options
292
+ };
293
+ const result = await (hasPaginationSettings(normalized.options) ? require_dataloaders_findPaginatedDataLoader.findPaginatedDataLoader(this, type, settings, populate) : require_dataloaders_findDataLoader.findDataLoader(this, type, settings, populate)).catch(function find(err) {
294
+ throw appendStack(err, /* @__PURE__ */ new Error());
295
+ });
296
+ if (populate) await this.populate(result, populate);
297
+ return result;
298
+ }
299
+ query(q, options) {
300
+ this.#assertFindAllowed("query");
301
+ const em = this;
302
+ return (async function query() {
303
+ const plan = require_queries_sql_query.parseUserQuery(q);
304
+ if (options?.populate && plan.output.kind !== "entity") require_utils.fail("em.query populate requires an entity selection");
305
+ const { rows } = await em.driver.executeQuery(em, plan.sql, plan.bindings);
306
+ const result = plan.decodeRows(em, rows);
307
+ if (options?.populate) await em.populate(result, options.populate);
308
+ return result;
309
+ })().catch(function query(err) {
310
+ throw appendStack(err, /* @__PURE__ */ new Error());
311
+ });
312
+ }
313
+ execute(statement) {
314
+ const em = this;
315
+ return (async function execute() {
316
+ if (require_queries_sql_execute.isMutation(statement)) {
317
+ if (em.mode === "read-only") throw new ReadOnlyError();
318
+ if (em.mode === "in-memory-writes") require_utils.fail("SQL mutations do not support in-memory-writes mode");
319
+ } else em.#assertFindAllowed("execute");
320
+ const plan = require_queries_sql_execute.parseStatement(statement);
321
+ if (!plan) return {
322
+ rowCount: 0,
323
+ rows: []
324
+ };
325
+ const result = await em.driver.executeQuery(em, plan.sql, plan.bindings);
326
+ return require_queries_sql_execute.decodeStatementResult(em, plan, result);
327
+ })().catch(function execute(err) {
328
+ throw appendStack(err, /* @__PURE__ */ new Error());
329
+ });
330
+ }
331
+ /** Fails fast if `em.${method}` is called from a regular validation rule, i.e. steers to `config.addCommitRule`. */
332
+ #assertFindAllowed(method) {
333
+ if (this.#findRestricted) throw new Error(`em.${method} cannot be called from a validation rule (added via config.addRule), because rules run before the flush and would query stale, pre-flush data. Use config.addCommitRule instead, which runs after the INSERT/UPDATE/DELETEs are flushed (within the same transaction) and so sees the changed state.`);
334
+ }
335
+ /** Runs the post-parse find pipeline: plugins mutate the logical AST, then Joist optimizes/prunes before SQL. */
336
+ async executeFind(meta, operation, parsed, settings) {
337
+ const { checkLimit, findSettings } = this.prepareFind(meta, operation, parsed, settings);
338
+ return this.executePreparedFind(meta, operation, parsed, findSettings, checkLimit);
339
+ }
340
+ /** Like {@link executeFind}, but returns a {@link RowData}; see {@link executePreparedFindRowData}. */
341
+ async executeFindRowData(meta, operation, parsed, settings) {
342
+ const { checkLimit, findSettings } = this.prepareFind(meta, operation, parsed, settings);
343
+ return this.executePreparedFindRowData(meta, operation, parsed, findSettings, checkLimit);
344
+ }
345
+ /** Executes a query that has already had find hooks and optimizations applied. */
346
+ async executePreparedFind(meta, operation, parsed, findSettings, checkLimit) {
347
+ const { pluginManager } = getEmInternalApi(this);
348
+ const rows = await this.driver.executeFind(this, parsed, findSettings);
349
+ if ((checkLimit ?? !("limit" in findSettings && findSettings.limit === void 0)) && rows.length >= this.entityLimit) throw new Error(`Query returned more than ${this.entityLimit} entityLimit rows`);
350
+ if (pluginManager.hasHook("afterFind")) pluginManager.afterFind(meta, operation, new require_RowData.PojoRowData(rows));
351
+ return rows;
352
+ }
353
+ /**
354
+ * Like {@link executePreparedFind}, but returns a {@link RowData}: lazy wire rows when the
355
+ * driver has `lazyRows` enabled, else classic POJO rows wrapped in a `PojoRowData` — so
356
+ * loaders can hydrate from one shape without caring which the driver provides.
357
+ */
358
+ async executePreparedFindRowData(meta, operation, parsed, findSettings, checkLimit) {
359
+ const { executeFindRowData } = this.driver;
360
+ if (executeFindRowData === void 0) return new require_RowData.PojoRowData(await this.executePreparedFind(meta, operation, parsed, findSettings, checkLimit));
361
+ const { pluginManager } = getEmInternalApi(this);
362
+ const rowData = await executeFindRowData.call(this.driver, this, parsed, findSettings);
363
+ if ((checkLimit ?? !("limit" in findSettings && findSettings.limit === void 0)) && rowData.rowCount >= this.entityLimit) throw new Error(`Query returned more than ${this.entityLimit} entityLimit rows`);
364
+ pluginManager.afterFind(meta, operation, rowData);
365
+ return rowData;
366
+ }
367
+ /**
368
+ * Runs pre-SQL find hooks and optimizations against a parsed query.
369
+ *
370
+ * This allows plugins to see "pre-batched" / "logical" query ASTs, instead of our
371
+ * more complicated `_find` batched queries. The flow would be:
372
+ *
373
+ * - A loader calls `prepareFind(originalQuery)`
374
+ * - Plugins inspect/modify the query as/if needed
375
+ * - The loader crafts a new, more complicated query that embeds the originalQuery
376
+ * - The loader calls `executePreparedFind` with the 2nd query
377
+ */
378
+ prepareFind(meta, operation, parsed, settings) {
379
+ const { checkLimit, ...findSettings } = settings;
380
+ const { pluginManager } = getEmInternalApi(this);
381
+ pluginManager.beforeFind(meta, operation, parsed, findSettings);
382
+ require_queries_find_QueryParser_collectionJoins.optimizeCollectionJoins(parsed, settings);
383
+ return {
384
+ checkLimit,
385
+ findSettings
386
+ };
387
+ }
388
+ async findGql(type, where, options) {
389
+ if (!options) return this.find(type, where);
390
+ const normalized = { ...options };
391
+ if ("limit" in normalized) normalized.limit = normalized.limit ?? void 0;
392
+ if ("offset" in normalized) normalized.offset = normalized.offset ?? void 0;
393
+ return this.find(type, where, normalized);
394
+ }
395
+ async findOne(type, where, options) {
396
+ const list = await this.find(type, where, options);
397
+ if (list.length === 0) return;
398
+ else if (list.length === 1) return list[0];
399
+ else throw new TooManyError(`Found more than one: ${list.map((e) => e.toString()).join(", ")}`);
400
+ }
401
+ async findOneOrFail(type, where, options) {
402
+ const list = await this.find(type, where, options);
403
+ if (list.length === 0) throw new NotFoundError(`Did not find ${type.name} for given query`);
404
+ else if (list.length > 1) throw new TooManyError(`Found more than one: ${list.map((e) => e.toString()).join(", ")}`);
405
+ return list[0];
406
+ }
407
+ async findByUnique(type, where, options = {}) {
408
+ this.#assertFindAllowed("findByUnique");
409
+ const { populate, softDeletes = "exclude" } = options;
410
+ const entries = Object.entries(where);
411
+ if (entries.length !== 1) throw new Error("findByUnique only accepts a single field");
412
+ const [fieldName, value] = entries[0];
413
+ const field = require_EntityMetadata.getMetadata(type).allFields[fieldName];
414
+ const row = await require_dataloaders_findByUniqueDataLoader.findByUniqueDataLoader(this, type, field, softDeletes).load(value).catch(function findByUnique(err) {
415
+ throw appendStack(err, /* @__PURE__ */ new Error());
416
+ });
417
+ if (!row) return;
418
+ else {
419
+ const [entity] = this.hydrate(type, [row]);
420
+ if (this.#hasAnyDeletes && entity.isDeletedEntity) return;
421
+ if (populate) await this.populate(entity, populate);
422
+ return entity;
423
+ }
424
+ }
425
+ /**
426
+ * Returns the count of entities that match the `where` clause.
427
+ *
428
+ * The `where` clause, and any options.conditions, matches the same syntax
429
+ * as `em.find`.
430
+ *
431
+ * Note: this method is not currently auto-batched, so it will cause N+1s if called in a loop.
432
+ */
433
+ async findCount(type, where, options = {}) {
434
+ this.#assertFindAllowed("findCount");
435
+ const normalized = require_dataloaders_findCountDataLoader.mergeCountOptions(where, options);
436
+ const settings = {
437
+ where: normalized.where,
438
+ ...normalized.options
439
+ };
440
+ let count = await require_dataloaders_findCountDataLoader.findCountDataLoader(this, type, settings).catch(function findCount(err) {
441
+ throw appendStack(err, /* @__PURE__ */ new Error());
442
+ });
443
+ if (require_queries_find_scopes.isSelectAllFilter(where, options.conditions)) {
444
+ const tagged = this.#entitiesByTag.get(require_EntityMetadata.getMetadata(type).tagName) ?? [];
445
+ for (const entity of tagged) if (entity instanceof type) {
446
+ if (entity.isNewEntity) count++;
447
+ else if (entity.isDeletedEntity) count--;
448
+ }
449
+ }
450
+ return count;
451
+ }
452
+ /**
453
+ * Returns the IDs of entities that match the `where` clause.
454
+ *
455
+ * The `where` clause, and any options.conditions, matches the same syntax
456
+ * as `em.find`.
457
+ */
458
+ async findIds(type, where, options = {}) {
459
+ this.#assertFindAllowed("findIds");
460
+ const normalized = require_dataloaders_findCountDataLoader.mergeCountOptions(where, options);
461
+ const settings = {
462
+ where: normalized.where,
463
+ ...normalized.options
464
+ };
465
+ return require_dataloaders_findIdsDataLoader.findIdsDataLoader(this, type, settings).catch(function findIds(err) {
466
+ throw appendStack(err, /* @__PURE__ */ new Error());
467
+ });
468
+ }
469
+ async findWithNewOrChanged(type, where, options) {
470
+ const { softDeletes = "exclude", populate } = options ?? {};
471
+ const copy = Object.fromEntries(Object.entries(where).filter(([, v]) => v !== void 0));
472
+ const unchanged = (await this.find(type, copy, { softDeletes })).filter((e) => !e.isNewEntity && !e.isDirtyEntity && !e.isDeletedEntity);
473
+ const maybeNew = this.filterEntities(type, where).filter((e) => (e.isNewEntity || e.isDirtyEntity) && !e.isDeletedEntity);
474
+ const found = [...unchanged, ...maybeNew];
475
+ if (populate) await this.populate(found, populate);
476
+ return found;
477
+ }
478
+ async findOrCreate(type, where, ifNew, upsert, options) {
479
+ const { softDeletes = "exclude", populate } = options ?? {};
480
+ const entity = await require_dataloaders_findOrCreateDataLoader.findOrCreateDataLoader(this, type, where, softDeletes).load({
481
+ ifNew,
482
+ upsert
483
+ }).catch(function findOrCreate(err) {
484
+ throw appendStack(err, /* @__PURE__ */ new Error());
485
+ });
486
+ if (populate) await this.populate(entity, populate);
487
+ return entity;
488
+ }
489
+ /** Creates a new `type` and marks it as loaded, i.e. we know its collections are all safe to access in memory. */
490
+ create(type, opts) {
491
+ return this.#doCreate(type, opts, false);
492
+ }
493
+ /**
494
+ * Creates a new `type` but with `opts` that are nullable, to accept partial-update-style input.
495
+ *
496
+ * Note that `createPartial` doesn't support the full upsert behavior, i.e. this method:
497
+ *
498
+ * - always creates,
499
+ * - does not support relation markers like `op`, `delete`, and `remove`,
500
+ * - does not accept deep input, but
501
+ * - fields set to `undefined` will be skipped instead of unset
502
+ *
503
+ * See `upsert` for the upsert/deep upsert behavior.
504
+ */
505
+ createPartial(type, opts) {
506
+ return this.#doCreate(type, opts, true);
507
+ }
508
+ /**
509
+ * Create or updates `type` based on partial-update-style `input`.
510
+ *
511
+ * This supports upsert behavior, i.e.:
512
+ *
513
+ * - findOrCreate the primary entity being updated (based on the `id` key being provided),
514
+ * - upsert relation markers like `op`, `delete`, and `remove` are supported,
515
+ * - deep input is supported, i.e. `{ firstName: "Bob", books: [{ title: "b1" } ] }`, and
516
+ * - fields set to `undefined` will be skipped instead of unset
517
+ */
518
+ upsert(type, input) {
519
+ return require_upsert.upsert(this, type, input);
520
+ }
521
+ async clone(entityOrArray, opts) {
522
+ const { deep = {}, skipIf, skip = {}, postClone } = opts ?? {};
523
+ const todo = /* @__PURE__ */ new Set();
524
+ const skipMap = /* @__PURE__ */ new WeakMap();
525
+ await crawl(todo, skipMap, Array.isArray(entityOrArray) ? entityOrArray : [entityOrArray], deep, {
526
+ skipIf,
527
+ skip
528
+ });
529
+ const deferredRelations = [];
530
+ const clones = [...todo].map((entity) => {
531
+ const skip = skipMap.get(entity) ?? [];
532
+ const meta = require_EntityMetadata.getMetadata(entity);
533
+ const copy = Object.fromEntries(Object.values(meta.allFields).map((f) => {
534
+ if (skip.includes(f.fieldName)) return void 0;
535
+ switch (f.kind) {
536
+ case "primitive": if (!f.derived && !f.protected) return [f.fieldName, require_fields.getField(entity, f.fieldName)];
537
+ else return;
538
+ case "enum": if (f.derived) return;
539
+ else return [f.fieldName, require_fields.getField(entity, f.fieldName)];
540
+ case "m2o":
541
+ case "poly": {
542
+ if (f.kind === "m2o" && f.derived) return void 0;
543
+ const existingIdOrEntity = require_fields.getField(entity, f.fieldName);
544
+ const target = require_Entity.isEntity(existingIdOrEntity) ? existingIdOrEntity : this.getEntity(existingIdOrEntity);
545
+ if (target && todo.has(target)) {
546
+ deferredRelations.push([
547
+ entity,
548
+ f.fieldName,
549
+ target
550
+ ]);
551
+ return [f.fieldName, void 0];
552
+ } else return [f.fieldName, existingIdOrEntity];
553
+ }
554
+ case "primaryKey":
555
+ case "o2m":
556
+ case "m2m":
557
+ case "m2mEnum":
558
+ case "o2o":
559
+ case "lo2m": return;
560
+ default: require_utils.assertNever(f);
561
+ }
562
+ }).filter(isDefined));
563
+ return [entity, this.create(require_index.asConcreteCstr(meta.cstr), copy)];
564
+ });
565
+ const entityToClone = new Map(clones);
566
+ clones.forEach(([, clone]) => {
567
+ require_index.getRelationEntries(clone).forEach(([fieldName, value]) => {
568
+ if (value instanceof require_relations_ManyToOneReference.ManyToOneReferenceImpl || value instanceof require_relations_PolymorphicReference.PolymorphicReferenceImpl || value instanceof require_relations_ReactiveReference.ReactiveReferenceImpl) {
569
+ const existingIdOrEntity = require_fields.getField(clone, fieldName);
570
+ const existing = require_Entity.isEntity(existingIdOrEntity) ? existingIdOrEntity : this.getEntity(existingIdOrEntity);
571
+ if (existing) clone[fieldName].set(entityToClone.get(existing) ?? existing);
572
+ }
573
+ });
574
+ });
575
+ deferredRelations.forEach(([source, fieldName, target]) => {
576
+ entityToClone.get(source)[fieldName].set(entityToClone.get(target));
577
+ });
578
+ if (postClone) await Promise.all(clones.map(([original, clone]) => postClone(original, clone)));
579
+ return Array.isArray(entityOrArray) ? entityOrArray.filter((original) => entityToClone.has(original)).map((original) => entityToClone.get(original)) : clones[0] ? clones[0][1] : require_utils.fail("no entities were cloned given the provided options");
580
+ }
581
+ /**
582
+ * Merges multiple source entities into a target entity by updating all references that point
583
+ * to the source entities to instead point to the target entity.
584
+ *
585
+ * This method loads all relations from the source entities, updates any entity that
586
+ * references a source entity to reference the target entity instead, and then automatically
587
+ * deletes the source entities.
588
+ *
589
+ * @param target - The entity that will become the target of all merged references
590
+ * @param sources - Array of entities whose references will be redirected to the target
591
+ * @param opts - Options to control merge behavior
592
+ * @param autoDelete - Whether to automatically delete source entities (default: true)
593
+ * @returns Promise that resolves when all references have been updated and sources deleted
594
+ *
595
+ * @example
596
+ * // Merge duplicate authors - all books pointing to author2 will now point to author1
597
+ * // author2 will be automatically deleted
598
+ * await em.merge(author1, [author2]);
599
+ *
600
+ * @example
601
+ * // Merge multiple duplicate publishers into one
602
+ * // publisher2 and publisher3 will be automatically deleted
603
+ * await em.merge(publisher1, [publisher2, publisher3]);
604
+ *
605
+ * @example
606
+ * // Merge without auto-deleting sources (for custom cleanup logic)
607
+ * await em.merge(author1, [author2], { autoDelete: false });
608
+ * // Custom logic here...
609
+ * em.delete(author2);
610
+ */
611
+ async merge(target, sources, opts) {
612
+ const autoDelete = opts?.autoDelete ?? true;
613
+ if (sources.length === 0) return [];
614
+ this.#merging ??= /* @__PURE__ */ new Set();
615
+ this.#merging.add(target);
616
+ const targetMeta = require_EntityMetadata.getMetadata(target);
617
+ for (const source of sources) {
618
+ const sourceMeta = require_EntityMetadata.getMetadata(source);
619
+ if (sourceMeta.type !== targetMeta.type) throw new Error(`Cannot merge entities of different types: ${targetMeta.type} and ${sourceMeta.type}`);
620
+ }
621
+ const fields = Object.values(targetMeta.allFields).filter((field) => [
622
+ "o2m",
623
+ "m2o",
624
+ "m2m",
625
+ "o2o"
626
+ ].includes(field.kind)).map((field) => field.fieldName);
627
+ await this.populate(sources, fields);
628
+ const changedEntities = [];
629
+ for (const source of sources) for (const field of Object.values(targetMeta.allFields)) {
630
+ const { kind } = field;
631
+ if (kind === "o2m") for (const other of source[field.fieldName].get) {
632
+ this.#merging.add(other);
633
+ other[field.otherFieldName].set(target);
634
+ changedEntities.push(other);
635
+ }
636
+ else if (kind === "o2o") {
637
+ const otherField = field.otherMetadata().allFields[field.otherFieldName];
638
+ if (otherField.kind === "m2o" && otherField.derived) continue;
639
+ const other = source[field.fieldName].get;
640
+ if (other) {
641
+ this.#merging.add(other);
642
+ other[field.otherFieldName].set(target);
643
+ changedEntities.push(other);
644
+ }
645
+ } else if (kind === "m2m") for (const other of source[field.fieldName].get) {
646
+ this.#merging.add(other);
647
+ const collection = other[field.otherFieldName];
648
+ collection.remove(source);
649
+ collection.add(target);
650
+ changedEntities.push(other);
651
+ }
652
+ else if (kind === "primitive" || kind === "primaryKey" || kind === "enum" || kind === "m2mEnum" || kind === "poly" || kind === "m2o" || kind === "lo2m") {} else require_utils.assertNever(kind);
653
+ }
654
+ if (autoDelete) for (const source of sources) this.delete(source);
655
+ return changedEntities;
656
+ }
657
+ async load(typeOrId, id, hint) {
658
+ let type;
659
+ if (typeof typeOrId === "string") {
660
+ type = require_configure.getConstructorFromTaggedId(typeOrId);
661
+ id = typeOrId;
662
+ } else {
663
+ type = typeOrId;
664
+ id = id || require_utils.fail(`Invalid ${typeOrId.name} id: ${id}`);
665
+ }
666
+ const meta = require_EntityMetadata.getMetadata(type);
667
+ const taggedId = require_keys.toTaggedId(meta, id);
668
+ let entity = this.findExistingInstance(taggedId);
669
+ if (!entity) {
670
+ await require_batchloaders_loadBatchLoader.loadBatchLoader(this, meta).load({
671
+ taggedId,
672
+ hint
673
+ }).catch(function load(err) {
674
+ throw appendStack(err, /* @__PURE__ */ new Error());
675
+ });
676
+ entity = this.findExistingInstance(taggedId);
677
+ }
678
+ if (!entity) throw new NotFoundError(`${taggedId} was not found`);
679
+ if (hint) await this.populate(entity, hint);
680
+ if (meta.inheritanceType === "sti" && !(entity instanceof type)) throw new Error(`${entity} is ${entity.constructor.name} but should be ${type.name}`);
681
+ return entity;
682
+ }
683
+ async loadAll(type, _ids, hint) {
684
+ const meta = require_EntityMetadata.getMetadata(type);
685
+ const entities = new Array(_ids.length);
686
+ let idsToLoad;
687
+ let positionsToLoad;
688
+ for (let i = 0; i < _ids.length; i++) {
689
+ const id = require_keys.tagId(meta, _ids[i]);
690
+ const entity = this.findExistingInstance(id);
691
+ if (entity) entities[i] = entity;
692
+ else {
693
+ (idsToLoad ??= []).push(id);
694
+ (positionsToLoad ??= []).push(i);
695
+ }
696
+ }
697
+ if (idsToLoad) {
698
+ await require_batchloaders_loadBatchLoader.loadBatchLoader(this, meta).loadAll(idsToLoad.map((id) => ({
699
+ taggedId: id,
700
+ hint
701
+ }))).catch(function loadAll(err) {
702
+ throw appendStack(err, /* @__PURE__ */ new Error());
703
+ });
704
+ let idsNotFound;
705
+ for (let j = 0; j < positionsToLoad.length; j++) {
706
+ const entity = this.findExistingInstance(idsToLoad[j]);
707
+ entities[positionsToLoad[j]] = entity;
708
+ if (entity === void 0) (idsNotFound ??= []).push(idsToLoad[j]);
709
+ }
710
+ if (idsNotFound) throw new NotFoundError(`${idsNotFound.join(",")} were not found`);
711
+ }
712
+ const loadedEntities = entities;
713
+ if (hint) await this.populate(loadedEntities, hint);
714
+ if (meta.inheritanceType === "sti" && meta.baseType) {
715
+ const wrongType = loadedEntities.filter((e) => !(e instanceof meta.cstr));
716
+ if (wrongType.length > 0) throw new Error(`${wrongType.join(", ")} were not of type ${meta.cstr.name}`);
717
+ }
718
+ return loadedEntities;
719
+ }
720
+ async loadAllIfExists(type, _ids, hint) {
721
+ const meta = require_EntityMetadata.getMetadata(type);
722
+ const maybeEntities = new Array(_ids.length);
723
+ let idsToLoad;
724
+ let positionsToLoad;
725
+ for (let i = 0; i < _ids.length; i++) {
726
+ const id = require_keys.tagId(meta, _ids[i]);
727
+ const entity = this.findExistingInstance(id);
728
+ if (entity) maybeEntities[i] = entity;
729
+ else {
730
+ (idsToLoad ??= []).push(id);
731
+ (positionsToLoad ??= []).push(i);
732
+ }
733
+ }
734
+ let entities;
735
+ if (idsToLoad) {
736
+ await require_batchloaders_loadBatchLoader.loadBatchLoader(this, meta).loadAll(idsToLoad.map((id) => ({
737
+ taggedId: id,
738
+ hint
739
+ }))).catch(function loadAllIfExists(err) {
740
+ throw appendStack(err, /* @__PURE__ */ new Error());
741
+ });
742
+ for (let j = 0; j < positionsToLoad.length; j++) maybeEntities[positionsToLoad[j]] = this.findExistingInstance(idsToLoad[j]);
743
+ entities = [];
744
+ for (const entity of maybeEntities) if (entity !== void 0) entities.push(entity);
745
+ } else entities = maybeEntities;
746
+ if (hint) await this.populate(entities, hint);
747
+ return entities;
748
+ }
749
+ async loadLens(entities, fn, populate) {
750
+ const result = await require_loading_loadLens.loadLens(entities, fn);
751
+ if (populate) await this.populate(result, populate);
752
+ return result;
753
+ }
754
+ loadFromQuery(type, rows, populate) {
755
+ if (Array.isArray(rows)) {
756
+ const entities = this.hydrate(type, rows);
757
+ if (populate) return this.populate(entities, populate);
758
+ return entities;
759
+ } else return rows.then((rows) => {
760
+ const entities = this.hydrate(type, rows);
761
+ if (populate) return this.populate(entities, populate);
762
+ return entities;
763
+ });
764
+ }
765
+ async loadFromRows(type, rows, populate) {
766
+ const entities = this.hydrate(type, rows);
767
+ if (populate) await this.populate(entities, populate);
768
+ return entities;
769
+ }
770
+ async populate(entityOrList, hintOrOpts, fn) {
771
+ const { hint: hintOpt, ...opts } = typeof hintOrOpts === "object" && "hint" in hintOrOpts ? hintOrOpts : { hint: hintOrOpts };
772
+ opts[require_relations_hasAsyncMethod.AsyncMethodPopulateSecret] = true;
773
+ const list = require_utils.toArray(entityOrList).filter((e) => {
774
+ return e !== void 0 && !require_BaseEntity.getInstanceData(e).isDeletedAndFlushed;
775
+ });
776
+ if (list.length === 0) return !fn ? entityOrList : fn(entityOrList);
777
+ if (!opts.forceReload && list.every((entity) => !entity.isNewEntity && require_loading_loadHints.isLoadedForPopulate(entity, hintOpt))) return fn ? fn(entityOrList) : entityOrList;
778
+ const meta = require_EntityMetadata.getMetadata(list[0]);
779
+ if (this.#preloader) {
780
+ const [preload, non] = this.#preloader.partitionHint(meta, hintOpt);
781
+ if (preload) await require_batchloaders_populateBatchLoader.populateBatchLoader(this, meta, preload, "preload", opts).loadAll(list.map((entity) => ({
782
+ entity,
783
+ hint: preload
784
+ }))).catch(function populate(err) {
785
+ throw appendStack(err, /* @__PURE__ */ new Error());
786
+ });
787
+ if (non) await require_batchloaders_populateBatchLoader.populateBatchLoader(this, meta, non, "intermixed", opts).loadAll(list.map((entity) => ({
788
+ entity,
789
+ hint: non
790
+ }))).catch(function populate(err) {
791
+ throw appendStack(err, /* @__PURE__ */ new Error());
792
+ });
793
+ } else await require_batchloaders_populateBatchLoader.populateBatchLoader(this, meta, hintOpt, "intermixed", opts).loadAll(list.map((entity) => ({
794
+ entity,
795
+ hint: hintOpt
796
+ }))).catch(function populate(err) {
797
+ throw appendStack(err, /* @__PURE__ */ new Error());
798
+ });
799
+ return fn ? fn(entityOrList) : entityOrList;
800
+ }
801
+ /**
802
+ * Executes `fn` with a transaction, and automatically calls `flush`/`commit` at the end.
803
+ *
804
+ * This ensures both any `.find` and `.flush` operations happen within the same
805
+ * transaction, which is useful for enforcing cross-table/application-level invariants that
806
+ * cannot be enforced with database-level constraints.
807
+ */
808
+ async transaction(fn) {
809
+ return this.driver.transaction(this, async (txn) => {
810
+ const result = await fn(txn);
811
+ await this.flush();
812
+ return result;
813
+ });
814
+ }
815
+ delete(entityOrArray) {
816
+ for (const entity of require_utils.toArray(entityOrArray)) {
817
+ if (!require_BaseEntity.getInstanceData(entity).markDeleted()) continue;
818
+ this.#hasAnyDeletes = true;
819
+ this.#rm.queueAllDownstreamFields(entity, "deleted");
820
+ getCascadeDeleteRelations(entity).forEach((r) => r.maybeCascadeDelete());
821
+ this.#pendingDeletes.push(entity);
822
+ }
823
+ }
824
+ async assignNewIds() {
825
+ let pendingEntities = this.entities.filter((e) => e.isNewEntity && !e.isDeletedEntity && !e.idTaggedMaybe);
826
+ await this.getLoader("assign-new-ids", "global", async (entities) => {
827
+ let todos = require_flush_Todo.createTodos(entities);
828
+ await this.driver.assignNewIds(this, todos);
829
+ for (const e of entities) this.#entitiesById.set(e.idTagged, e);
830
+ return entities;
831
+ }).loadMany(pendingEntities).catch(function assignNewIds(err) {
832
+ throw appendStack(err, /* @__PURE__ */ new Error());
833
+ });
834
+ }
835
+ /**
836
+ * Immediately assigns async defaults to `entities`.
837
+ *
838
+ * Normally async defaults wait until `em.flush` to run, because their async nature requires
839
+ * an `await` / `Promise` to be evaluated, and `em.create` is synchronous.
840
+ *
841
+ * This `assignDefaults` methods like you move that up, and immediately invoke
842
+ * any default logic against the `entities`.
843
+ */
844
+ async setDefaults(entities) {
845
+ return require_trusted.runInTrustedContext(async () => {
846
+ const suppressedTypeErrors = [];
847
+ const entitiesByType = require_utils.groupBy(entities.filter((e) => e.isNewEntity), (e) => require_EntityMetadata.getMetadata(e));
848
+ await require_defaults.setAsyncDefaults(suppressedTypeErrors, this.ctx, entitiesByType);
849
+ });
850
+ }
851
+ /**
852
+ * Flushes the SQL for any changed entities to the database.
853
+ *
854
+ * If this is run outside of an existing transaction, it will `BEGIN` and `COMMIT`
855
+ * a new transaction on every `.flush()` call so that all of the `INSERT`s/etc.
856
+ * happen atomically.
857
+ *
858
+ * If this is run within an existing transaction, i.e. `EntityManager.transaction`,
859
+ * then it will only issue `INSERT`s/etc. and defer to the caller to `COMMIT`
860
+ * the transaction.
861
+ *
862
+ * It returns entities that have changed (an entity is considered changed if it has been deleted, inserted, or updated)
863
+ */
864
+ async flush(flushOptions = {}) {
865
+ return require_trusted.runInTrustedContext(() => this.#flush(flushOptions));
866
+ }
867
+ async #flush(flushOptions = {}) {
868
+ if (this.mode === "read-only") throw new ReadOnlyError();
869
+ const { skipValidation = false } = flushOptions;
870
+ this.#fl.startLock();
871
+ const allFlushedEntities = /* @__PURE__ */ new Set();
872
+ try {
873
+ await this.#fl.allowWrites(async () => {
874
+ await this.flushDeletes();
875
+ await this.#rm.recalcPendingReactables("reactables");
876
+ });
877
+ const createdThenDeleted = /* @__PURE__ */ new Set();
878
+ const hooksInvoked = /* @__PURE__ */ new Set();
879
+ let hookLoops = 0;
880
+ let now = getNow();
881
+ const suppressedDefaultTypeErrors = [];
882
+ const runHooksOnPendingEntities = async () => {
883
+ if (hookLoops++ >= 10) throw new Error("runHooksOnPendingEntities has ran 10 iterations, aborting");
884
+ const pendingLoads = [...getEmInternalApi(this).pendingLoads];
885
+ if (pendingLoads.length > 0) {
886
+ getEmInternalApi(this).pendingLoads.clear();
887
+ await Promise.all(pendingLoads.map((collection) => collection.load()));
888
+ }
889
+ const pendingFlush = /* @__PURE__ */ new Set();
890
+ const pendingHooks = /* @__PURE__ */ new Set();
891
+ const alreadyRanHooks = /* @__PURE__ */ new Set();
892
+ findPendingFlushEntities(this.#maybePendingFlushEntities, hooksInvoked, pendingFlush, pendingHooks, alreadyRanHooks);
893
+ if (alreadyRanHooks.size > 0) maybeBumpUpdatedAt(this.#rm, require_flush_Todo.createTodos(alreadyRanHooks), now);
894
+ while (pendingHooks.size > 0) await this.#fl.allowWrites(async () => {
895
+ let todos = require_flush_Todo.createTodos(pendingHooks);
896
+ await require_defaults.setAsyncDefaults(suppressedDefaultTypeErrors, this.ctx, require_flush_Todo.Todo.groupInsertsByTypeAndSubType(todos));
897
+ maybeBumpUpdatedAt(this.#rm, todos, now);
898
+ for (const group of maybeSetupHookOrdering(todos)) {
899
+ await beforeCreate(this.ctx, group);
900
+ await beforeUpdate(this.ctx, group);
901
+ await beforeFlush(this.ctx, group);
902
+ }
903
+ recalcSynchronousDerivedFields(todos);
904
+ do {
905
+ await this.flushDeletes();
906
+ await this.#rm.recalcPendingReactables("reactables");
907
+ } while (this.#pendingDeletes.length > 0);
908
+ if (this.#rm.hasPendingTypeErrors) {
909
+ await this.#rm.recalcPendingTypeErrors();
910
+ if (this.#rm.needsRecalc("reactables")) await this.#rm.recalcPendingReactables("reactables");
911
+ }
912
+ for (const e of pendingHooks) hooksInvoked.add(e);
913
+ pendingHooks.clear();
914
+ findPendingFlushEntities(this.#maybePendingFlushEntities, hooksInvoked, pendingFlush, pendingHooks, alreadyRanHooks);
915
+ if (pendingHooks.size === 0 && this.#rm.hasPendingTypeErrors) await this.#rm.recalcPendingTypeErrors();
916
+ });
917
+ return [...pendingFlush].filter((e) => {
918
+ const createThenDelete = e.isDeletedEntity && e.isNewEntity;
919
+ if (createThenDelete) createdThenDeleted.add(e);
920
+ return !createThenDelete;
921
+ });
922
+ };
923
+ const { pluginManager } = getEmInternalApi(this);
924
+ const runValidation = async (entityTodos, joinRowTodos, validate) => {
925
+ const changedEntities = entitiesFromTodos(entityTodos, joinRowTodos);
926
+ try {
927
+ this.#isValidating = true;
928
+ await pluginManager.beforeValidate(changedEntities);
929
+ if (validate) {
930
+ this.#findRestricted = true;
931
+ try {
932
+ await validateSimpleRules(entityTodos);
933
+ if (suppressedDefaultTypeErrors.length > 0) throw suppressedDefaultTypeErrors[0];
934
+ await validateReactiveRules(this, this.#rm.logger, entityTodos, joinRowTodos);
935
+ } finally {
936
+ this.#findRestricted = false;
937
+ }
938
+ await afterValidation(this.ctx, entityTodos);
939
+ }
940
+ await pluginManager.afterValidate(changedEntities);
941
+ } finally {
942
+ this.#isValidating = false;
943
+ }
944
+ };
945
+ const runCommitValidation = async (entityTodos, joinRowTodos) => {
946
+ this.#dataloaders = {};
947
+ this.#batchLoaders = {};
948
+ this.#preloadedRelations = /* @__PURE__ */ new Map();
949
+ try {
950
+ this.#isValidating = true;
951
+ await validateSimpleRules(entityTodos, (config) => config.commitRules);
952
+ await validateReactiveRules(this, this.#rm.logger, entityTodos, joinRowTodos, (meta) => meta.reactiveCommitRules);
953
+ } finally {
954
+ this.#isValidating = false;
955
+ }
956
+ };
957
+ const commitRuleTodos = {};
958
+ const commitRuleJoinRowTodos = {};
959
+ const commitRuleSeen = /* @__PURE__ */ new Set();
960
+ function collectCommitRuleTodos(entityTodos, joinRowTodos) {
961
+ if (skipValidation) return;
962
+ for (const todo of Object.values(entityTodos)) {
963
+ if (!todo.metadata.hasCommitRules) continue;
964
+ for (const key of [
965
+ "inserts",
966
+ "updates",
967
+ "deletes"
968
+ ]) for (const e of todo[key]) if (!commitRuleSeen.has(e)) {
969
+ commitRuleSeen.add(e);
970
+ require_flush_Todo.getTodo(commitRuleTodos, e)[key].push(e);
971
+ }
972
+ }
973
+ for (const [table, todo] of Object.entries(joinRowTodos)) {
974
+ if (!todo.m2m.meta.hasCommitRules && !todo.m2m.otherMeta?.hasCommitRules) continue;
975
+ const into = commitRuleJoinRowTodos[table] ??= {
976
+ ...todo,
977
+ newRows: [],
978
+ deletedRows: []
979
+ };
980
+ for (const key of ["newRows", "deletedRows"]) for (const r of todo[key]) if (!commitRuleSeen.has(r)) {
981
+ commitRuleSeen.add(r);
982
+ into[key].push(r);
983
+ }
984
+ }
985
+ }
986
+ let entitiesToFlush = await runHooksOnPendingEntities();
987
+ for (const e of entitiesToFlush) allFlushedEntities.add(e);
988
+ let entityTodos = require_flush_Todo.createTodos(entitiesToFlush);
989
+ let joinRowTodos = require_flush_Todo.combineJoinRows(this.#joinRows);
990
+ await runValidation(entityTodos, joinRowTodos, !skipValidation);
991
+ this.#rm.throwIfAnySuppressedTypeErrors();
992
+ if (suppressedDefaultTypeErrors.length > 0) throw suppressedDefaultTypeErrors[0];
993
+ if (Object.keys(entityTodos).length > 0 || Object.keys(joinRowTodos).length > 0) {
994
+ await this.driver.transaction(this, async () => {
995
+ do {
996
+ if (Object.keys(entityTodos).length > 0 || Object.keys(joinRowTodos).length > 0) {
997
+ await this.driver.flush(this, entityTodos, joinRowTodos);
998
+ collectCommitRuleTodos(entityTodos, joinRowTodos);
999
+ }
1000
+ pluginManager.afterWrite(entityTodos, joinRowTodos);
1001
+ if (this.#rm.hasPendingReactiveQueries()) {
1002
+ for (const e of entitiesToFlush) {
1003
+ if (e.isNewEntity && !e.isDeletedEntity) this.#entitiesById.set(e.idTagged, e);
1004
+ require_BaseEntity.getInstanceData(e).resetForRqfLoop();
1005
+ }
1006
+ await this.#fl.allowWrites(async () => {
1007
+ await this.#rm.recalcPendingReactables("reactiveQueries");
1008
+ await this.#rm.recalcPendingReactables("reactables");
1009
+ });
1010
+ now = getNow();
1011
+ entitiesToFlush = await runHooksOnPendingEntities();
1012
+ for (const e of entitiesToFlush) allFlushedEntities.add(e);
1013
+ entityTodos = require_flush_Todo.createTodos(entitiesToFlush);
1014
+ joinRowTodos = require_flush_Todo.combineJoinRows(this.#joinRows);
1015
+ await runValidation(entityTodos, joinRowTodos, true);
1016
+ this.#rm.throwIfAnySuppressedTypeErrors();
1017
+ } else entityTodos = {};
1018
+ } while (Object.keys(entityTodos).length > 0);
1019
+ if (Object.keys(commitRuleTodos).length > 0 || Object.keys(commitRuleJoinRowTodos).length > 0) {
1020
+ for (const e of allFlushedEntities) if (e.isNewEntity && !e.isDeletedEntity) this.#entitiesById.set(e.idTagged, e);
1021
+ await runCommitValidation(commitRuleTodos, commitRuleJoinRowTodos);
1022
+ }
1023
+ await beforeCommit(this.ctx, allFlushedEntities);
1024
+ if (this.mode === "in-memory-writes") throw new InMemoryRollbackError();
1025
+ });
1026
+ await afterCommit(this.ctx, allFlushedEntities);
1027
+ for (const e of allFlushedEntities) {
1028
+ const instanceData = require_BaseEntity.getInstanceData(e);
1029
+ if (e.isNewEntity && !e.isDeletedEntity) this.#entitiesById.set(e.idTagged, e);
1030
+ instanceData.resetAfterFlushed();
1031
+ const { relations } = instanceData;
1032
+ if (relations) {
1033
+ for (const rel of Object.values(relations)) if (rel instanceof require_relations_AsyncProperty.AsyncPropertyImpl || rel instanceof require_relations_LazyField.LazyFieldImpl) rel.resetAfterFlush();
1034
+ }
1035
+ }
1036
+ for (const joinRow of Object.values(joinRowTodos)) joinRow.resetAfterFlushed();
1037
+ const { mutatedCollections } = getEmInternalApi(this);
1038
+ for (const o2m of mutatedCollections.values()) o2m.resetAddedRemoved();
1039
+ mutatedCollections.clear();
1040
+ this.#dataloaders = {};
1041
+ this.#batchLoaders = {};
1042
+ this.#preloadedRelations = /* @__PURE__ */ new Map();
1043
+ this.#rm.clear();
1044
+ }
1045
+ for (const e of createdThenDeleted) require_BaseEntity.getInstanceData(e).fixupCreatedThenDeleted();
1046
+ this.#merging?.clear();
1047
+ return [...allFlushedEntities].sort((a, b) => require_BaseEntity.getInstanceData(a).entityIndex - require_BaseEntity.getInstanceData(b).entityIndex);
1048
+ } catch (e) {
1049
+ if (e instanceof require_relations_RecursiveCycleError.RecursiveCycleError) {
1050
+ const entity = e.entities[0];
1051
+ for (const meta of require_EntityMetadata.getBaseAndSelfMetas(require_EntityMetadata.getMetadata(entity))) {
1052
+ const messageFn = meta.config.__data.cycleMessages[e.fieldName] ?? meta.config.__data.cycleMessages[entity[e.fieldName]?.otherFieldName];
1053
+ if (messageFn) throw new require_rules.ValidationErrors([{
1054
+ entity,
1055
+ message: messageFn(entity, e.entities)
1056
+ }]);
1057
+ }
1058
+ }
1059
+ const detail = e && typeof e === "object" && "detail" in e && typeof e.detail === "string" ? e.detail : void 0;
1060
+ if (e && typeof e === "object" && "constraint" in e && typeof e.constraint === "string") {
1061
+ const message = require_config.constraintNameToValidationError[e.constraint];
1062
+ if (message) {
1063
+ const errors = new require_rules.ValidationErrors(message);
1064
+ if (detail) errors.message = `${message} — ${detail}`;
1065
+ throw errors;
1066
+ }
1067
+ }
1068
+ if (e instanceof InMemoryRollbackError) return [...allFlushedEntities].sort((a, b) => require_BaseEntity.getInstanceData(a).entityIndex - require_BaseEntity.getInstanceData(b).entityIndex);
1069
+ if (detail && e instanceof Error) e.message = `${e.message} — ${detail}`;
1070
+ throw e;
1071
+ } finally {
1072
+ this.#rm.clearSuppressedTypeErrors();
1073
+ this.#fl.releaseLock();
1074
+ require_newTestInstance.resetFactoryCreated();
1075
+ }
1076
+ }
1077
+ /**
1078
+ * A very simple toJSON.
1079
+ *
1080
+ * This is not really meant to be useful, it's to prevent huge/circular output if
1081
+ * an EntityManager accidentally ends up getting logged to something like pino that
1082
+ * over-zealous toJSONs anything it touches.
1083
+ */
1084
+ toJSON() {
1085
+ return `<EntityManager ${this.entities.length}>`;
1086
+ }
1087
+ async refresh(param) {
1088
+ this.#isRefreshing = true;
1089
+ this.#dataloaders = {};
1090
+ this.#batchLoaders = {};
1091
+ this.#preloadedRelations = /* @__PURE__ */ new Map();
1092
+ const deepLoad = param && "deepLoad" in param && param.deepLoad;
1093
+ let todo = param === void 0 ? this.#entitiesArray : Array.isArray(param) ? param : require_Entity.isEntity(param) ? [param] : this.#entitiesArray;
1094
+ const done = /* @__PURE__ */ new Set();
1095
+ while (todo.length > 0) {
1096
+ const copy = [...todo];
1097
+ copy.forEach((e) => done.add(e));
1098
+ todo = [];
1099
+ const entitiesToRefresh = copy.filter((e) => e.idTaggedMaybe && !e.isDeletedEntity);
1100
+ await Promise.all(entitiesToRefresh.map((entity) => {
1101
+ const hint = require_index.getRelationEntries(entity).filter(([_, r]) => deepLoad || r.isLoaded).map(([k]) => k);
1102
+ return require_batchloaders_loadBatchLoader.loadBatchLoader(this, require_EntityMetadata.getMetadata(entity), true).load({
1103
+ taggedId: entity.idTagged,
1104
+ hint
1105
+ }).catch(function refresh(err) {
1106
+ throw appendStack(err, /* @__PURE__ */ new Error());
1107
+ });
1108
+ }));
1109
+ const [custom, builtin] = require_utils.partition(entitiesToRefresh.filter((e) => !require_BaseEntity.getInstanceData(e).isDeletedEntity).flatMap((entity) => require_index.getRelations(entity).filter((r) => deepLoad || r.isLoaded)), isCustomRelation);
1110
+ await Promise.all(builtin.map((r) => {
1111
+ if (r.isPreloaded && !r.isLoaded) {
1112
+ r.preload();
1113
+ return;
1114
+ } else return r.load({ forceReload: true });
1115
+ }));
1116
+ await Promise.all(custom.map((r) => r.load({ forceReload: true })));
1117
+ if (deepLoad) todo.push(...builtin.filter((r) => "get" in r).map((r) => r.get).flatMap((value) => Array.isArray(value) ? value : [value]).filter((value) => require_Entity.isEntity(value) && !done.has(value)));
1118
+ }
1119
+ this.#isRefreshing = false;
1120
+ }
1121
+ get numberOfEntities() {
1122
+ return this.entities.length;
1123
+ }
1124
+ findExistingInstance(id) {
1125
+ return this.#entitiesById.get(id);
1126
+ }
1127
+ /**
1128
+ * Takes a result `row` from a custom query and maps the db values into a new-or-existing domain object for that row.
1129
+ *
1130
+ * The `overwriteExisting` controls whether `row`'s values should overwrite the existing fields on
1131
+ * an entity. By default this is true, as we assume the user calling this means they know the DB has
1132
+ * updated values that should be put into the entities. A few internal callers set this to false,
1133
+ * i.e. when we're loading collections and have db results that are potentially stale compared to
1134
+ * the WIP entity state.
1135
+ */
1136
+ hydrate(type, rows, options) {
1137
+ return this.hydrateFromRowData(type, new require_RowData.PojoRowData(rows), options);
1138
+ }
1139
+ /**
1140
+ * Hydrates a query's `RowData`, running any sidecar reads, and always `finalize`s the result.
1141
+ *
1142
+ * This is the internal API for Joist's find/load loaders: `sidecars` is where reads of
1143
+ * non-entity columns (preload aggregates, `_tags`, found-id checks) belong — they must run
1144
+ * before `finalize`, because compaction drops unretained rows — and the `try/finally`
1145
+ * guarantees a failed hydration or sidecar read still releases the result's unretained
1146
+ * buffers instead of pinning them.
1147
+ */
1148
+ hydrateAndFinalize(type, rowData, opts) {
1149
+ try {
1150
+ const entities = this.hydrateFromRowData(type, rowData, opts);
1151
+ opts?.sidecars?.(entities);
1152
+ return entities;
1153
+ } finally {
1154
+ rowData.finalize?.();
1155
+ }
1156
+ }
1157
+ /**
1158
+ * Like {@link hydrate}, but reads rows from a {@link RowData}, i.e. a driver-produced
1159
+ * lazy query result, instead of an array of POJO rows.
1160
+ *
1161
+ * This is an internal API used by Joist's own find loaders (usually via
1162
+ * {@link hydrateAndFinalize}); rows whose entities are kept (newly created or
1163
+ * overwrite-refreshed) are `retain`-ed on the `RowData` so the caller can later `finalize`
1164
+ * (trim/compact) the result.
1165
+ */
1166
+ hydrateFromRowData(type, rowData, options) {
1167
+ const maybeBaseMeta = require_EntityMetadata.getMetadata(type);
1168
+ const overwriteExisting = options?.overwriteExisting === true;
1169
+ const count = rowData.rowCount;
1170
+ const entities = new Array(count);
1171
+ for (let i = 0; i < count; i++) {
1172
+ const id = rowData.get(i, "id");
1173
+ const taggedId = id === void 0 || id === null ? require_utils.fail("No id column was available") : require_keys.keyToTaggedId(maybeBaseMeta, id);
1174
+ let entity = this.findExistingInstance(taggedId);
1175
+ if (!entity) {
1176
+ const meta = findConcreteMeta(maybeBaseMeta, rowData, i);
1177
+ entity = require_newEntity.newEntity(this, require_index.asConcreteCstr(meta.cstr), false);
1178
+ const instanceData = require_BaseEntity.getInstanceData(entity);
1179
+ instanceData.rowData = rowData;
1180
+ instanceData.rowIndex = i;
1181
+ rowData.retain?.(i);
1182
+ instanceData.data["id"] = taggedId;
1183
+ this.#doRegister(entity, taggedId, meta, true);
1184
+ } else if (overwriteExisting) {
1185
+ const instanceData = require_BaseEntity.getInstanceData(entity);
1186
+ instanceData.rowData = rowData;
1187
+ instanceData.rowIndex = i;
1188
+ rowData.retain?.(i);
1189
+ const { data } = instanceData;
1190
+ const dataKeys = Object.keys(data);
1191
+ if (dataKeys.length > ("id" in data ? 1 : 0)) {
1192
+ const allFields = require_EntityMetadata.getMetadata(entity).allFields;
1193
+ const changedFields = instanceData.isNewEntity ? entity.changes.fieldsWithoutRelations : Object.keys(instanceData.originalData);
1194
+ for (const fieldName of dataKeys) {
1195
+ if (fieldName === "id") continue;
1196
+ data[fieldName] = (allFields[fieldName].serde ?? require_utils.fail(`Missing serde for ${fieldName}`)).fromRow(rowData, i);
1197
+ if (changedFields.includes(fieldName)) instanceData.markFieldClean(fieldName);
1198
+ }
1199
+ }
1200
+ }
1201
+ entities[i] = entity;
1202
+ }
1203
+ return entities;
1204
+ }
1205
+ touch(entityOrEntities) {
1206
+ for (const entity of require_utils.toArray(entityOrEntities)) require_BaseEntity.getInstanceData(entity).markTouched();
1207
+ }
1208
+ async recalc(entityOrEntities, reactionName) {
1209
+ const entities = require_utils.toArray(entityOrEntities).filter((entity) => !entity.isDeletedEntity);
1210
+ if (reactionName !== void 0) {
1211
+ const reactions = entities.map((entity) => {
1212
+ return require_EntityMetadata.getBaseAndSelfMetas(require_EntityMetadata.getMetadata(entity)).flatMap((meta) => meta.config.__data.reactions).find((reaction) => reaction.name === reactionName) ?? require_utils.fail(`Reaction '${reactionName}' not found on ${require_EntityMetadata.getMetadata(entity).type}`);
1213
+ });
1214
+ await require_trusted.runInTrustedContext(() => Promise.allSettled(reactions.map((reaction, i) => reaction.fn(entities[i], this.ctx))).then(require_utils.failIfAnyRejected));
1215
+ await this.#rm.recalcPendingReactables("reactables");
1216
+ return;
1217
+ }
1218
+ const relations = entities.flatMap((entity) => Object.values(require_EntityMetadata.getMetadata(entity).allFields).filter((f) => "derived" in f && f.derived === "async").map((field) => entity[field.fieldName]));
1219
+ const results = await Promise.allSettled(relations.map((r) => r.load({ forceReload: true })));
1220
+ const relationsPendingAssignedIds = [];
1221
+ const failures = [];
1222
+ results.forEach((result, i) => {
1223
+ if (result.status === "rejected") {
1224
+ if (result.reason instanceof require_index.NoIdError) relationsPendingAssignedIds.push(relations[i]);
1225
+ else failures.push(result.reason);
1226
+ }
1227
+ });
1228
+ if (relationsPendingAssignedIds.length > 0) {
1229
+ await this.assignNewIds();
1230
+ (await Promise.allSettled(relationsPendingAssignedIds.map((r) => r.load({ forceReload: true })))).forEach((result) => {
1231
+ if (result.status === "rejected") failures.push(result.reason);
1232
+ });
1233
+ }
1234
+ if (failures.length > 0) throw failures[0];
1235
+ entities.flatMap((entity) => Object.values(require_EntityMetadata.getMetadata(entity).allFields).filter((f) => "derived" in f && f.derived === "sync").forEach((field) => {
1236
+ require_fields.setField(entity, field.fieldName, entity[field.fieldName]);
1237
+ }));
1238
+ await this.#rm.recalcPendingReactables("reactables");
1239
+ }
1240
+ beforeBegin(fn) {
1241
+ this.#hooks.beforeBegin.push(fn);
1242
+ }
1243
+ afterBegin(fn) {
1244
+ this.#hooks.afterBegin.push(fn);
1245
+ }
1246
+ beforeCommit(fn) {
1247
+ this.#hooks.beforeCommit.push(fn);
1248
+ }
1249
+ afterCommit(fn) {
1250
+ this.#hooks.afterCommit.push(fn);
1251
+ }
1252
+ /**
1253
+ * Returns an EntityManager-scoped (i.e. request scoped) data loader.
1254
+ *
1255
+ * @param operation the operation being batched, i.e. `load` or `o2m-load`, to avoid clashing batch keys
1256
+ * across fundamentally different operations
1257
+ * @param batchKey for a given operation, i.e. `load`, a batch key `Author` to batch all Author loads together
1258
+ * @param fn the batch load function, i.e. that will accept all `.load(...)`-d Author ids to load as a single db call
1259
+ * @param opts optional DataLoader options
1260
+ * @returns a DataLoader scoped to the `operation` + `batchKey` combination
1261
+ */
1262
+ getLoader(operation, batchKey, fn, opts) {
1263
+ const loadersForKind = this.#dataloaders[operation] ??= {};
1264
+ return require_utils.getOrSet(loadersForKind, batchKey, () => new dataloader.default(fn, opts));
1265
+ }
1266
+ /**
1267
+ * Like `getLoader`, but returns a `BatchLoader` where all callers in the same tick
1268
+ * share a single `Promise<void>` instead of getting per-key promises.
1269
+ *
1270
+ * The batch function should write results via side channels (e.g. `setPreloadedRelation`).
1271
+ */
1272
+ getBatchLoader(operation, batchKey, fn) {
1273
+ const loadersForKind = this.#batchLoaders[operation] ??= {};
1274
+ return require_utils.getOrSet(loadersForKind, batchKey, () => new require_batchloaders_BatchLoader.BatchLoader(fn));
1275
+ }
1276
+ toString() {
1277
+ return "EntityManager";
1278
+ }
1279
+ /** Recursively cascades any pending deletions. */
1280
+ async flushDeletes() {
1281
+ let entities = this.#pendingDeletes;
1282
+ if (entities.length === 0) return;
1283
+ this.#pendingDeletes = [];
1284
+ let relationsToCleanup = [];
1285
+ while (entities.length > 0) {
1286
+ const p = entities.flatMap(getCascadeDeleteRelations).map((r) => r.load().then(() => r.maybeCascadeDelete()));
1287
+ await Promise.all(p);
1288
+ const todos = require_flush_Todo.createTodos(entities);
1289
+ await beforeDelete(this.ctx, todos);
1290
+ for (const entity of entities) {
1291
+ const relations = require_index.getRelations(entity);
1292
+ const start = relationsToCleanup.length;
1293
+ relationsToCleanup.length += relations.length;
1294
+ for (let i = 0; i < relations.length; i++) relationsToCleanup[start + i] = relations[i];
1295
+ }
1296
+ entities = this.#pendingDeletes;
1297
+ this.#pendingDeletes = [];
1298
+ }
1299
+ await Promise.all(relationsToCleanup.map((r) => r.cleanupOnEntityDeleted()));
1300
+ }
1301
+ setReactionLogging(arg) {
1302
+ this.#rm.setLogger(typeof arg === "boolean" ? arg ? new require_logging_ReactionLogger.ReactionLogger() : void 0 : arg);
1303
+ }
1304
+ setFieldLogging(arg) {
1305
+ if (arg instanceof require_logging_FieldLogger.FieldLogger) {
1306
+ this.#fieldLogger = arg;
1307
+ return;
1308
+ }
1309
+ const writeFn = getDefaultWriteFn(this.ctx);
1310
+ if (typeof arg === "boolean") this.#fieldLogger = arg ? new require_logging_FieldLogger.FieldLogger([], writeFn) : require_logging_FieldLogger.noopFieldLogger;
1311
+ else if (typeof arg === "string" || Array.isArray(arg)) {
1312
+ const watching = (Array.isArray(arg) ? arg : [arg]).map((spec) => {
1313
+ const [_, entity, fields, breakpoint] = spec.match(/^([^.!]+)(?:\.([^!]*))?(!)?$/) ?? require_utils.fail(`Unsupported spec ${spec}`);
1314
+ const fieldNames = fields?.split(",");
1315
+ const meta = require_configure.getMetadataForType(entity);
1316
+ fieldNames?.forEach((field) => {
1317
+ if (!meta.allFields[field]) throw new Error(`Field ${field} not found on ${entity}`);
1318
+ });
1319
+ return {
1320
+ entity,
1321
+ fieldNames,
1322
+ breakpoint: !!breakpoint
1323
+ };
1324
+ });
1325
+ this.#fieldLogger = new require_logging_FieldLogger.FieldLogger(watching, writeFn);
1326
+ } else throw new Error("Unsupported override for setFieldLogging");
1327
+ }
1328
+ async [Symbol.asyncDispose]() {
1329
+ await this.flush();
1330
+ }
1331
+ /** Returns entities matching the filter using indexed search when available. */
1332
+ filterEntities(cstr, where) {
1333
+ const meta = require_EntityMetadata.getMetadata(cstr);
1334
+ const entities = this.#entitiesByTag.get(meta.tagName) ?? [];
1335
+ if (!require_utils.hasAnyKey(where)) return entities.filter((e) => e instanceof cstr && !e.isDeletedEntity);
1336
+ if (this.#indexManager.shouldIndexType(entities.length)) {
1337
+ this.#indexManager.enableIndexingForType(meta, entities, where);
1338
+ const result = [];
1339
+ for (const e of this.#indexManager.findMatching(meta, entities, where)) if (e instanceof cstr && !e.isDeletedEntity) result.push(e);
1340
+ return result;
1341
+ } else return entities.filter((e) => e instanceof cstr && !e.isDeletedEntity && require_dataloaders_findOrCreateDataLoader.entityMatches(e, where));
1342
+ }
1343
+ /**
1344
+ * Creates a new EntityManager that shares the same entities as the current one but allows independent changes.
1345
+ *
1346
+ * This is useful for scenarios where you want to:
1347
+ *
1348
+ * - Preload data for use as a cache
1349
+ * - Make speculative changes that may or may not be committed
1350
+ * - Escape a transaction scope
1351
+ *
1352
+ * The fork will:
1353
+ *
1354
+ * - Copy all currently loaded entities to the new EntityManager
1355
+ * - Copy any loaded relation data to keep `.isLoaded` / `.get` state consistent
1356
+ * - Copy and update references to the EntityManager and its entities in the context, which is itself shallowly copied
1357
+ *
1358
+ * The fork will NOT:
1359
+ *
1360
+ * - Copy any pending changes (must call .flush() first)
1361
+ * - Share any changes made in either EntityManager with the other
1362
+ *
1363
+ * @param opts options to control the fork behavior
1364
+ * - allowPendingChanges - allows the em being forked to have pending changes and forces the resulting em to have
1365
+ * `mode` set to "in-memory-writes". Changes to entities in the original em will be copied to the resulting em.
1366
+ * Optional. default: false
1367
+ *
1368
+ * @throws {Error} If called on an EntityManager with pending changes
1369
+ * @returns A new EntityManager with copied entity state
1370
+ */
1371
+ fork(opts = {}) {
1372
+ const { allowPendingChanges = false } = opts;
1373
+ const oldEm = this;
1374
+ const ctx = { ...oldEm.ctx };
1375
+ const newEm = new EntityManager(ctx, { em: oldEm });
1376
+ if (allowPendingChanges) newEm.mode = "in-memory-writes";
1377
+ for (const [tag, entities] of oldEm.#entitiesByTag.entries()) {
1378
+ const baseCstr = require_configure.getConstructorFromTag(tag);
1379
+ let rows = new Array(entities.length);
1380
+ let i = 0;
1381
+ for (const entity of entities) {
1382
+ const instanceData = entity.__data;
1383
+ if (!allowPendingChanges && instanceData.pendingOperation !== "none") require_utils.fail("Cannot fork an EntityManager with pending changes");
1384
+ else if (instanceData.isNewEntity) newEm.create(entity.constructor, {});
1385
+ else {
1386
+ rows[i] = createRowFromEntityData(entity);
1387
+ i++;
1388
+ }
1389
+ }
1390
+ if (rows.length !== i) rows = rows.slice(0, i);
1391
+ newEm.hydrate(baseCstr, rows);
1392
+ }
1393
+ function mapEntity(oldEntity) {
1394
+ if (oldEntity.isNewEntity) return newEm.#entitiesById.get(oldEntity.toTaggedString());
1395
+ else return newEm.#entitiesById.get(oldEntity.idTagged);
1396
+ }
1397
+ function mapEntities(v) {
1398
+ if (v === void 0) return void 0;
1399
+ const result = new Array(v.length);
1400
+ for (let i = 0; i < v.length; i++) result[i] = mapEntity(v[i]);
1401
+ return result;
1402
+ }
1403
+ if (allowPendingChanges) for (const oldEntity of oldEm.entities) {
1404
+ const oldInstanceData = oldEntity.__data;
1405
+ if (!(oldInstanceData.isNewEntity || oldInstanceData.isDirtyEntity)) continue;
1406
+ const { originalData: oldOriginalData, data: oldData } = oldInstanceData;
1407
+ const newInstanceData = mapEntity(oldEntity).__data;
1408
+ const { data: newData } = newInstanceData;
1409
+ const maybeEntity = (value) => require_Entity.isEntity(value) ? mapEntity(value) : value;
1410
+ const fields = Object.keys(oldEntity.isNewEntity ? oldData : oldOriginalData);
1411
+ for (const field of fields) {
1412
+ if (field in oldOriginalData) newInstanceData.markFieldDirty(field, maybeEntity(oldOriginalData[field]));
1413
+ newData[field] = maybeEntity(oldData[field]);
1414
+ }
1415
+ }
1416
+ for (const oldEntity of oldEm.entities) {
1417
+ const newEntity = mapEntity(oldEntity);
1418
+ if (oldEntity.isDeletedEntity) {
1419
+ newEntity.__data.markDeleted();
1420
+ continue;
1421
+ }
1422
+ const { relations } = oldEntity.__data;
1423
+ if (!relations) continue;
1424
+ for (const [field, relation] of Object.entries(relations)) {
1425
+ if (!("import" in relation)) continue;
1426
+ if (oldEntity.isNewEntity) {
1427
+ const oldValue = relation.get;
1428
+ if (oldValue === void 0) continue;
1429
+ if (Array.isArray(oldValue) && oldValue.length === 0) continue;
1430
+ const newValue = Array.isArray(oldValue) ? mapEntities(oldValue) : mapEntity(oldValue);
1431
+ delete newEntity.__data.data[field];
1432
+ newEntity[field].setFromOpts(newValue);
1433
+ } else if ("_isLoaded" in relation ? relation._isLoaded : relation.isLoaded) newEntity[field].import(relation, mapEntity, mapEntities);
1434
+ }
1435
+ }
1436
+ for (const [key, value] of Object.entries(ctx)) if (require_Entity.isEntity(value) && value.em === oldEm) ctx[key] = mapEntity(value);
1437
+ else if (value === oldEm) ctx[key] = newEm;
1438
+ return newEm;
1439
+ }
1440
+ importEntity(source, hint, normalizedHint) {
1441
+ if (source.isNewEntity) require_utils.fail("cannot import new entities");
1442
+ if (source.isDeletedEntity) require_utils.fail("cannot import deleted entities");
1443
+ if (source.isDirtyEntity) require_utils.fail("cannot import dirty entities");
1444
+ hint ??= {};
1445
+ if (!normalizedHint) {
1446
+ require_loading_loadHints.assertLoaded(source, hint);
1447
+ normalizedHint = require_normalizeHints.deepNormalizeHint(hint);
1448
+ }
1449
+ if (source.em === this) return source;
1450
+ const meta = require_EntityMetadata.getMetadata(source);
1451
+ let result = this.#entitiesById.get(source.idTagged);
1452
+ if (!result) {
1453
+ const meta = require_EntityMetadata.getMetadata(source);
1454
+ const row = createRowFromEntityData(source);
1455
+ result = this.hydrate(require_EntityMetadata.getBaseMeta(meta).cstr, [row])[0];
1456
+ }
1457
+ for (const [fieldName, subHint] of Object.entries(normalizedHint)) {
1458
+ const field = meta.allFields[fieldName];
1459
+ const relationOrProp = result[fieldName];
1460
+ if (!field) {
1461
+ let loadHint = relationOrProp.loadHint ?? require_utils.fail(`${source}.${fieldName} cannot be imported as it has no loadHint`);
1462
+ this.importEntity(source, loadHint);
1463
+ } else if ("import" in relationOrProp) relationOrProp.import(source[fieldName], (e) => this.importEntity(e, subHint, subHint), (entities) => {
1464
+ if (entities === void 0) return void 0;
1465
+ const result = new Array(entities.length);
1466
+ for (let i = 0; i < entities.length; i++) result[i] = this.importEntity(entities[i], subHint, subHint);
1467
+ return result;
1468
+ });
1469
+ }
1470
+ return result;
1471
+ }
1472
+ addPlugin(plugin) {
1473
+ getEmInternalApi(this).pluginManager.addPlugin(plugin);
1474
+ }
1475
+ getPlugins() {
1476
+ return getEmInternalApi(this).pluginManager.plugins;
1477
+ }
1478
+ get isRefreshing() {
1479
+ return this.#isRefreshing;
1480
+ }
1481
+ get isFlushing() {
1482
+ return this.#fl.isFlushing;
1483
+ }
1484
+ /** Creates a new `type` and marks it as loaded, i.e. we know its collections are all safe to access in memory. */
1485
+ #doCreate(type, opts, partial) {
1486
+ const entity = require_newEntity.newEntity(this, type, true);
1487
+ const meta = require_EntityMetadata.getMetadata(type);
1488
+ const counter = this.#createCounter ??= /* @__PURE__ */ new Map();
1489
+ const i = (counter.get(meta.tagName) ?? 0) + 1;
1490
+ counter.set(meta.tagName, i);
1491
+ require_BaseEntity.getInstanceData(entity).createId = String(i);
1492
+ this.#doRegister(entity, opts.id);
1493
+ const baseMeta = require_EntityMetadata.getBaseMeta(require_EntityMetadata.getMetadata(entity));
1494
+ if (baseMeta.timestampFields) this.#assignTimestamps(entity, baseMeta);
1495
+ if (baseMeta.inheritanceType === "sti") setStiDiscriminatorValue(baseMeta, entity);
1496
+ getEmInternalApi(this)?.fieldLogger.logCreate(entity);
1497
+ require_index.setOpts(entity, opts, {
1498
+ partial,
1499
+ calledFromConstructor: true
1500
+ });
1501
+ if (!this.fakeInstance) require_defaults.setSyncDefaults(entity);
1502
+ this.#rm.queueAllDownstreamFields(entity, "created");
1503
+ return entity;
1504
+ }
1505
+ #assignTimestamps(entity, baseMeta) {
1506
+ const { createdAt, updatedAt } = baseMeta.timestampFields ?? {};
1507
+ const { data } = require_BaseEntity.getInstanceData(entity);
1508
+ const now = /* @__PURE__ */ new Date();
1509
+ if (createdAt) data[createdAt] = baseMeta.fields[createdAt].serde.mapFromNow(now);
1510
+ if (updatedAt) data[updatedAt] = baseMeta.fields[updatedAt].serde.mapFromNow(now);
1511
+ }
1512
+ /** Registers a newly-instantiated entity with our EntityManager; only called by #doCreate and hydrate. */
1513
+ #doRegister(entity, id, meta, skipDuplicateCheck = false) {
1514
+ const maybeId = id ?? entity.idTaggedMaybe;
1515
+ if (maybeId) {
1516
+ if (!skipDuplicateCheck && this.findExistingInstance(maybeId) !== void 0) throw new Error(`Entity ${entity} has a duplicate instance already loaded`);
1517
+ this.#entitiesById.set(maybeId, entity);
1518
+ } else this.#entitiesById.set(entity.toTaggedString(), entity);
1519
+ require_BaseEntity.getInstanceData(entity).entityIndex = this.#entitiesArray.length;
1520
+ this.#entitiesArray.push(entity);
1521
+ meta ??= require_EntityMetadata.getMetadata(entity);
1522
+ const set = this.#entitiesByTag.get(meta.tagName) ?? [];
1523
+ if (set.length === 0) this.#entitiesByTag.set(meta.tagName, set);
1524
+ set.push(entity);
1525
+ if (this.#entitiesArray.length >= this.entityLimit) {
1526
+ const topTypes = [...this.#entitiesByTag.entries()].map(([tag, entities]) => ({
1527
+ tag,
1528
+ count: entities.length
1529
+ })).sort((a, b) => b.count - a.count).slice(0, 3).map(({ tag, count }) => `${tag}=${count}`).join(", ");
1530
+ throw new Error(`More than ${this.entityLimit} entities have been instantiated (top entities: ${topTypes})`);
1531
+ }
1532
+ }
1533
+ };
1534
+ function getEmInternalApi(em) {
1535
+ return em["__api"];
1536
+ }
1537
+ let defaultEntityLimit = 5e4;
1538
+ function getDefaultEntityLimit() {
1539
+ return defaultEntityLimit;
1540
+ }
1541
+ function setDefaultEntityLimit(limit) {
1542
+ defaultEntityLimit = limit;
1543
+ }
1544
+ function resetDefaultEntityLimit() {
1545
+ defaultEntityLimit = 5e4;
1546
+ }
1547
+ function isKey(k) {
1548
+ return typeof k === "string";
1549
+ }
1550
+ /** Compares `a` to `b`, where `b` might be an id. */
1551
+ function sameEntity(a, b) {
1552
+ if (a === b) return true;
1553
+ if (a === void 0 || b === void 0 || a === null || b === null) return (a === void 0 || a === null) && (b === void 0 || b === null);
1554
+ if (require_Entity.isEntity(a) && require_Entity.isEntity(b)) return a === b;
1555
+ return (require_Entity.isEntity(a) ? a.idTaggedMaybe : a) === (require_Entity.isEntity(b) ? b.idTaggedMaybe : b);
1556
+ }
1557
+ /** Compares the value `a` to `b`, with handling of new entities w/o ids assigned yet. */
1558
+ function sameReference(a, b) {
1559
+ return sameEntity(require_relations_Reference.isLoadedReference(a) ? a.get : a.idTaggedMaybe, require_relations_Reference.isLoadedReference(b) ? b.get : b.idTaggedMaybe);
1560
+ }
1561
+ /** Thrown by `findOneOrFail`, 'load' & 'loadAll' if an entity is not found. */
1562
+ var NotFoundError = class extends Error {};
1563
+ /** Thrown by `findOne` and `findOneOrFail` if more than one entity is found. */
1564
+ var TooManyError = class extends Error {
1565
+ constructor(message) {
1566
+ super(message);
1567
+ }
1568
+ };
1569
+ /**
1570
+ * For the entities currently in `todos`, find any reactive validation rules that point
1571
+ * from the currently-changed entities back to each rule's originally-defined-in entity,
1572
+ * and ensure those entities are added to `todos`.
1573
+ */
1574
+ async function validateReactiveRules(em, logger, todos, joinRowTodos, getRules = (meta) => meta.reactiveRules) {
1575
+ logger.logStartingValidate(em, todos);
1576
+ const fns = /* @__PURE__ */ new Map();
1577
+ const walks = [];
1578
+ async function followAndQueue(triggered, rule) {
1579
+ if (triggered.length === 0) return;
1580
+ const found = (await require_reactivity_reactiveHints.followReverseHint(rule.name, triggered, rule.path)).filter((entity) => !entity.isDeletedEntity).filter((e) => e instanceof rule.cstr);
1581
+ let entities = fns.get(rule.fn);
1582
+ if (!entities) {
1583
+ entities = /* @__PURE__ */ new Set();
1584
+ fns.set(rule.fn, entities);
1585
+ }
1586
+ walks.push({
1587
+ todo: triggered,
1588
+ r: rule,
1589
+ entities: found
1590
+ });
1591
+ found.forEach((entity) => {
1592
+ entities.add(entity);
1593
+ });
1594
+ }
1595
+ const p1 = Object.values(todos).flatMap((todo) => {
1596
+ const rules = getRules(todo.metadata);
1597
+ if (rules.length === 0) return [];
1598
+ const entities = [
1599
+ ...todo.inserts,
1600
+ ...todo.updates,
1601
+ ...todo.deletes
1602
+ ];
1603
+ return rules.map((rule) => {
1604
+ return followAndQueue(entities.filter((e) => {
1605
+ if (!(e instanceof rule.source)) return false;
1606
+ if (e.isNewEntity || e.isDeletedEntity) return true;
1607
+ const { originalData } = require_BaseEntity.getInstanceData(e);
1608
+ for (const field of rule.fields) if (field in originalData) return true;
1609
+ return false;
1610
+ }), rule);
1611
+ });
1612
+ });
1613
+ const p2 = Object.values(joinRowTodos).flatMap((todo) => {
1614
+ const entities = [...todo.newRows, ...todo.deletedRows].flatMap((jr) => Object.values(jr.columns)).filter(require_Entity.isEntity);
1615
+ const a = getRules(todo.m2m.meta).filter((rule) => rule.fields.includes(todo.m2m.fieldName)).map((rule) => {
1616
+ return followAndQueue(entities.filter((e) => e instanceof todo.m2m.meta.cstr), rule);
1617
+ });
1618
+ const { otherMeta, otherFieldName } = todo.m2m;
1619
+ const b = otherMeta ? getRules(otherMeta).filter((rule) => rule.fields.includes(otherFieldName)).map((rule) => {
1620
+ return followAndQueue(entities.filter((e) => e instanceof otherMeta.cstr), rule);
1621
+ }) : [];
1622
+ return [...a, ...b];
1623
+ });
1624
+ require_utils.failIfAnyRejected(await Promise.allSettled([...p1, ...p2]));
1625
+ logger.logWalks(walks, "validate");
1626
+ const p3 = [...fns.entries()].flatMap(([fn, entities]) => [...entities].map(async (entity) => coerceError(entity, await fn(entity))));
1627
+ const errors = require_utils.failIfAnyRejected(await Promise.allSettled(p3)).flat();
1628
+ if (errors.length > 0) throw new require_rules.ValidationErrors(errors);
1629
+ }
1630
+ async function validateSimpleRules(todos, getRules = (config) => config.rules) {
1631
+ let p = void 0;
1632
+ for (const todoKey in todos) {
1633
+ const { inserts, updates } = todos[todoKey];
1634
+ for (const entities of [inserts, updates]) for (const entity of entities) {
1635
+ if (entity.isDeletedEntity) continue;
1636
+ for (const m of require_EntityMetadata.getBaseAndSelfMetas(require_EntityMetadata.getMetadata(entity))) for (const rule of getRules(m.config.__data)) {
1637
+ if (rule.hint !== void 0) continue;
1638
+ (p ??= []).push(invokeRule(entity, rule.fn));
1639
+ }
1640
+ }
1641
+ }
1642
+ if (!p) return;
1643
+ const errors = require_utils.failIfAnyRejected(await Promise.allSettled(p)).flat();
1644
+ if (errors.length > 0) throw new require_rules.ValidationErrors(errors);
1645
+ }
1646
+ /** Invokes a single validation rule, coercing its result/sync throws into a promise. */
1647
+ async function invokeRule(entity, fn) {
1648
+ return coerceError(entity, await fn(entity));
1649
+ }
1650
+ function driverBeforeBegin(em, txn) {
1651
+ return Promise.all(getEmInternalApi(em).hooks.beforeBegin.map((fn) => fn(em, txn)));
1652
+ }
1653
+ function driverAfterBegin(em, txn) {
1654
+ return Promise.all(getEmInternalApi(em).hooks.afterBegin.map((fn) => fn(em, txn)));
1655
+ }
1656
+ function driverBeforeCommit(em, txn) {
1657
+ return Promise.all(getEmInternalApi(em).hooks.beforeCommit.map((fn) => fn(em, txn)));
1658
+ }
1659
+ function driverAfterCommit(em, txn) {
1660
+ return Promise.all(getEmInternalApi(em).hooks.afterCommit.map((fn) => fn(em, txn)));
1661
+ }
1662
+ async function runHookOnTodos(ctx, hook, todos, keys) {
1663
+ let entities = void 0;
1664
+ for (const todoKey in todos) {
1665
+ const todo = todos[todoKey];
1666
+ if (!metaHasHook(todo.metadata, hook)) continue;
1667
+ for (const k of keys) for (const e of todo[k]) {
1668
+ if (k !== "deletes" && e.isDeletedEntity) continue;
1669
+ (entities ??= []).push(e);
1670
+ }
1671
+ }
1672
+ if (entities) return runHook(ctx, hook, entities);
1673
+ }
1674
+ /** Returns whether `meta`'s base/self/sub hierarchy has any `hook` functions registered. */
1675
+ function metaHasHook(meta, hook) {
1676
+ for (const m of require_EntityMetadata.getBaseSelfAndSubMetas(meta)) if (m.config.__data.hooks[hook].length > 0) return true;
1677
+ return false;
1678
+ }
1679
+ async function runHook(ctx, hook, entities) {
1680
+ let p = void 0;
1681
+ for (const entity of entities) for (const m of require_EntityMetadata.getBaseAndSelfMetas(require_EntityMetadata.getMetadata(entity))) for (const fn of m.config.__data.hooks[hook]) (p ??= []).push(invokeHook(fn, entity, ctx));
1682
+ if (!p) return;
1683
+ const results = await Promise.allSettled(p);
1684
+ require_utils.failIfAnyRejected(results);
1685
+ }
1686
+ /** Invokes a single hook fn, coercing sync throws into rejections. */
1687
+ async function invokeHook(fn, entity, ctx) {
1688
+ return fn(entity, ctx);
1689
+ }
1690
+ function beforeDelete(ctx, todos) {
1691
+ return runHookOnTodos(ctx, "beforeDelete", todos, ["deletes"]);
1692
+ }
1693
+ function beforeFlush(ctx, todos) {
1694
+ return runHookOnTodos(ctx, "beforeFlush", todos, ["inserts", "updates"]);
1695
+ }
1696
+ function beforeCreate(ctx, todos) {
1697
+ return runHookOnTodos(ctx, "beforeCreate", todos, ["inserts"]);
1698
+ }
1699
+ function beforeUpdate(ctx, todos) {
1700
+ return runHookOnTodos(ctx, "beforeUpdate", todos, ["updates"]);
1701
+ }
1702
+ function afterValidation(ctx, todos) {
1703
+ return runHookOnTodos(ctx, "afterValidation", todos, ["inserts", "updates"]);
1704
+ }
1705
+ /** Collects changed entities from flush todos, i.e. m2m endpoint entities. */
1706
+ function entitiesFromTodos(entityTodos, joinRowTodos) {
1707
+ const entities = /* @__PURE__ */ new Set();
1708
+ for (const todo of Object.values(entityTodos)) for (const list of [
1709
+ todo.inserts,
1710
+ todo.updates,
1711
+ todo.deletes
1712
+ ]) for (const entity of list) entities.add(entity);
1713
+ for (const todo of Object.values(joinRowTodos)) for (const rows of [todo.newRows, todo.deletedRows]) for (const row of rows) for (const value of Object.values(row.columns)) if (require_Entity.isEntity(value)) entities.add(value);
1714
+ return [...entities];
1715
+ }
1716
+ function beforeCommit(ctx, entities) {
1717
+ return runHook(ctx, "beforeCommit", [...entities]);
1718
+ }
1719
+ function afterCommit(ctx, entities) {
1720
+ return runHook(ctx, "afterCommit", [...entities]);
1721
+ }
1722
+ /** Given a validation rule result `maybeError`, returns a canonical `ValidationError[]`. */
1723
+ function coerceError(entity, maybeError) {
1724
+ if (maybeError === void 0) return [];
1725
+ else if (typeof maybeError === "string") return [{
1726
+ entity,
1727
+ message: maybeError
1728
+ }];
1729
+ else if (Array.isArray(maybeError)) return maybeError.map((e) => {
1730
+ if (typeof e === "string") return {
1731
+ entity,
1732
+ message: e
1733
+ };
1734
+ else return {
1735
+ entity,
1736
+ ...e
1737
+ };
1738
+ });
1739
+ else return [{
1740
+ entity,
1741
+ ...maybeError
1742
+ }];
1743
+ }
1744
+ /** Evaluates each (non-async) derived field to see if it's value has changed. */
1745
+ function recalcSynchronousDerivedFields(todos) {
1746
+ for (const todoKey in todos) {
1747
+ const todo = todos[todoKey];
1748
+ for (const entities of [todo.inserts, todo.updates]) for (const entity of entities) {
1749
+ if (entity.isDeletedEntity) continue;
1750
+ for (const fieldName of require_EntityMetadata.getMetadata(entity).syncDerivedFields) require_fields.setField(entity, fieldName, entity[fieldName]);
1751
+ }
1752
+ }
1753
+ }
1754
+ /** Recursively crawls through `entity`, with the given populate `deep` hint, and adds anything found to `found`. */
1755
+ async function crawl(found, skipMap, entities, deep, opts = {}) {
1756
+ const { skipIf = () => false } = opts ?? {};
1757
+ const skip = require_normalizeHints.deepNormalizeHint(opts.skip ?? {});
1758
+ const skipFields = Object.keys(skip).filter((key) => Object.keys(skip[key]).length === 0);
1759
+ const entitiesToClone = entities.filter((e) => !skipIf(e));
1760
+ for (const entity of entitiesToClone) {
1761
+ found.add(entity);
1762
+ skipMap.set(entity, skipFields);
1763
+ }
1764
+ await Promise.all(entitiesToClone.flatMap((entity) => Object.entries(adaptHint(deep)).map(async ([relationName, nested]) => {
1765
+ const relation = entity[relationName];
1766
+ const _opts = {
1767
+ ...opts,
1768
+ skip: skip[relationName]
1769
+ };
1770
+ if (relation instanceof require_relations_OneToManyCollection.OneToManyCollection) await crawl(found, skipMap, await relation.load(), nested, _opts);
1771
+ else if (relation instanceof require_relations_OneToOneReference.OneToOneReferenceImpl) {
1772
+ const related = await relation.load();
1773
+ if (related) await crawl(found, skipMap, [related], nested, _opts);
1774
+ } else if (relation instanceof require_relations_ManyToOneReference.ManyToOneReferenceImpl) {
1775
+ const related = await relation.load();
1776
+ if (related) await crawl(found, skipMap, [related], nested, _opts);
1777
+ } else if (relation instanceof require_relations_ReactiveReference.ReactiveReferenceImpl) await crawl(found, skipMap, await relation.load(), nested, _opts);
1778
+ else require_utils.fail(`Uncloneable relation: ${relationName}`);
1779
+ })));
1780
+ }
1781
+ /** Takes our flexible string or array or hash load hint and makes it always a hash. */
1782
+ function adaptHint(hint) {
1783
+ if (typeof hint === "string") return { [hint]: {} };
1784
+ else if (Array.isArray(hint)) return Object.fromEntries(hint.map((relation) => [relation, {}]));
1785
+ else if (hint) return hint;
1786
+ else return {};
1787
+ }
1788
+ function isDefined(param) {
1789
+ return param !== null && param !== void 0;
1790
+ }
1791
+ function getCascadeDeleteRelations(entity) {
1792
+ return require_EntityMetadata.getBaseAndSelfMetas(require_EntityMetadata.getMetadata(entity)).flatMap((meta) => {
1793
+ return meta.config.__data.cascadeDeleteFields.map((fieldName) => entity[fieldName]);
1794
+ });
1795
+ }
1796
+ function isCustomRelation(r) {
1797
+ return r instanceof require_relations_CustomCollection.CustomCollection || r instanceof require_relations_CustomReference.CustomReference || r instanceof require_relations_ReactiveReference.ReactiveReferenceImpl;
1798
+ }
1799
+ function maybeBumpUpdatedAt(rm, todos, now) {
1800
+ for (const todo of Object.values(todos)) {
1801
+ const { updatedAt } = todo.metadata.timestampFields ?? {};
1802
+ if (updatedAt) for (const e of todo.updates) {
1803
+ const orm = require_BaseEntity.getInstanceData(e);
1804
+ orm.markFieldDirty(updatedAt, require_fields.getField(e, updatedAt));
1805
+ const serde = todo.metadata.fields[updatedAt].serde;
1806
+ orm.data[updatedAt] = serde.mapFromNow(now);
1807
+ rm.queueDownstreamReactables(e, updatedAt);
1808
+ }
1809
+ }
1810
+ }
1811
+ let lastNow = void 0;
1812
+ function setLastNow(now) {
1813
+ lastNow = now;
1814
+ }
1815
+ function getNow() {
1816
+ let now = /* @__PURE__ */ new Date();
1817
+ if (lastNow && (lastNow.getTime() === now.getTime() || now.getTime() < lastNow.getTime())) now = new Date(lastNow.getTime() + 1);
1818
+ lastNow = now;
1819
+ return now;
1820
+ }
1821
+ /** Given a `row` from the db, resolves the CTI/STI subtype, if applicable. */
1822
+ function findConcreteMeta(maybeBaseMeta, rowData, rowIndex) {
1823
+ if (maybeBaseMeta.inheritanceType === void 0) return maybeBaseMeta;
1824
+ const __class = rowData.get(rowIndex, "__class");
1825
+ if (!__class && maybeBaseMeta.inheritanceType !== "sti") return maybeBaseMeta;
1826
+ if (__class) {
1827
+ if (__class === "_" && maybeBaseMeta.ctiAbstract) {
1828
+ const id = rowData.get(rowIndex, "id");
1829
+ throw new Error(`${maybeBaseMeta.type} ${require_keys.tagId(maybeBaseMeta, id)} must be instantiated via a subtype`);
1830
+ }
1831
+ return maybeBaseMeta.subTypesByType.get(__class) ?? maybeBaseMeta;
1832
+ } else if (maybeBaseMeta.inheritanceType === "sti") {
1833
+ const baseMeta = require_EntityMetadata.getBaseMeta(maybeBaseMeta);
1834
+ const value = rowData.get(rowIndex, baseMeta.stiDiscriminatorColumnName);
1835
+ return baseMeta.subTypesByStiValue.get(value) ?? baseMeta;
1836
+ } else throw new Error("Unknown inheritance type");
1837
+ }
1838
+ /** Sets the `Animal.type` enum to the right subtype value. */
1839
+ function setStiDiscriminatorValue(baseMeta, entity) {
1840
+ const typeName = entity.constructor.name;
1841
+ const st = baseMeta.subTypesByType.get(typeName);
1842
+ if (st) {
1843
+ const code = baseMeta.fields[baseMeta.stiDiscriminatorField].enumDetailType.findById(st.stiDiscriminatorValue).code;
1844
+ entity[baseMeta.stiDiscriminatorField] = code;
1845
+ } else entity[baseMeta.stiDiscriminatorField] = void 0;
1846
+ }
1847
+ function findPendingFlushEntities(maybePendingFlushEntities, hooksInvoked, pendingFlush, pendingHooks, alreadyRanHooks) {
1848
+ for (const e of maybePendingFlushEntities) {
1849
+ if (require_BaseEntity.getInstanceData(e).pendingOperation === "none") {
1850
+ maybePendingFlushEntities.delete(e);
1851
+ continue;
1852
+ }
1853
+ if (!hooksInvoked.has(e)) pendingHooks.add(e);
1854
+ else alreadyRanHooks.add(e);
1855
+ pendingFlush.add(e);
1856
+ }
1857
+ }
1858
+ /** Returns true if the caller explicitly asked `find` to use SQL pagination. */
1859
+ function hasPaginationSettings(options) {
1860
+ return "limit" in options || "offset" in options;
1861
+ }
1862
+ /** An error we throw to get knex to `ROLLBACK`, but then catch. */
1863
+ var InMemoryRollbackError = class extends Error {};
1864
+ /** An error thrown when `em.mode === "read-only"` but entities are mutated/flushed. */
1865
+ var ReadOnlyError = class extends Error {
1866
+ constructor() {
1867
+ super("EntityManager is read-only");
1868
+ }
1869
+ };
1870
+ function maybeSetupHookOrdering(todos) {
1871
+ const group1 = {};
1872
+ const group2 = {};
1873
+ for (const todo of Object.values(todos)) {
1874
+ const group = todo.metadata.config.__data.runHooksBefore.some((cstr) => require_EntityMetadata.getBaseMeta(require_EntityMetadata.getMetadata(cstr)).type in todos) ? group1 : group2;
1875
+ group[todo.metadata.type] = todo;
1876
+ }
1877
+ return Object.keys(group1).length ? [group1, group2] : [group2];
1878
+ }
1879
+ /**
1880
+ * Given an `err` thrown in "a different context", i.e. a database error or dataloader error
1881
+ * that doesn't include our stack trace, append our stack for better debugging.
1882
+ *
1883
+ * See https://github.com/brianc/node-postgres/pull/2983
1884
+ */
1885
+ function appendStack(err, dummy) {
1886
+ if (err && typeof err === "object" && "stack" in err) err.stack += dummy.stack.replace(/.*\n/, "\n");
1887
+ return err;
1888
+ }
1889
+ /** Probe for `ctx.logger.debug` if it exists, otherwise fallback on `console.log`. */
1890
+ function getDefaultWriteFn(ctx) {
1891
+ return ctx && typeof ctx === "object" && "logger" in ctx && ctx.logger && typeof ctx.logger === "object" && "debug" in ctx.logger && ctx.logger.debug instanceof Function ? ctx.logger.debug.bind(ctx.logger) : console.log;
1892
+ }
1893
+ const fieldMap = {};
1894
+ function createRowFromEntityData(e, opts = {}) {
1895
+ const { preferOriginalData = true } = opts;
1896
+ const { rowData, rowIndex, data, originalData } = e.__data;
1897
+ const __class = e.constructor.name;
1898
+ const { metadata: meta } = e.__data;
1899
+ if (!fieldMap[__class]) {
1900
+ fieldMap[__class] = [];
1901
+ for (const field of Object.values(meta.allFields)) {
1902
+ if (!field.serde) continue;
1903
+ for (const column of field.serde.columns) fieldMap[__class].push([field, column]);
1904
+ }
1905
+ }
1906
+ const row = meta.inheritanceType === "cti" ? { __class } : {};
1907
+ for (const [field, column] of fieldMap[__class]) {
1908
+ const value = field.fieldName in originalData || field.fieldName in data ? column.rowValue(preferOriginalData && field.fieldName in originalData ? originalData : data) : rowData.get(rowIndex, column.columnName);
1909
+ row[column.columnName] = value ?? null;
1910
+ }
1911
+ return row;
1912
+ }
1913
+ //#endregion
1914
+ exports.EntityManager = EntityManager;
1915
+ exports.NotFoundError = NotFoundError;
1916
+ exports.ReadOnlyError = ReadOnlyError;
1917
+ exports.TooManyError = TooManyError;
1918
+ exports.appendStack = appendStack;
1919
+ exports.createRowFromEntityData = createRowFromEntityData;
1920
+ exports.driverAfterBegin = driverAfterBegin;
1921
+ exports.driverAfterCommit = driverAfterCommit;
1922
+ exports.driverBeforeBegin = driverBeforeBegin;
1923
+ exports.driverBeforeCommit = driverBeforeCommit;
1924
+ exports.getDefaultEntityLimit = getDefaultEntityLimit;
1925
+ exports.getEmInternalApi = getEmInternalApi;
1926
+ exports.isDefined = isDefined;
1927
+ exports.isId = isId;
1928
+ exports.isKey = isKey;
1929
+ exports.resetDefaultEntityLimit = resetDefaultEntityLimit;
1930
+ exports.sameEntity = sameEntity;
1931
+ exports.sameReference = sameReference;
1932
+ exports.setDefaultEntityLimit = setDefaultEntityLimit;
1933
+ exports.setLastNow = setLastNow;
1934
+
1935
+ //# sourceMappingURL=EntityManager.cjs.map