joist-core 2.3.0-next.7 → 2.3.0-next.71

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