joist-core 2.3.0-next.97 → 2.3.0-next.99

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 (747) hide show
  1. package/build/BaseEntity.cjs.map +1 -1
  2. package/build/BaseEntity.js.map +1 -1
  3. package/build/Entity.cjs.map +1 -1
  4. package/build/Entity.js.map +1 -1
  5. package/build/EntityManager.cjs +45 -46
  6. package/build/EntityManager.cjs.map +1 -1
  7. package/build/EntityManager.d.cts +7 -7
  8. package/build/EntityManager.d.cts.map +1 -1
  9. package/build/EntityManager.d.mts +7 -7
  10. package/build/EntityManager.d.mts.map +1 -1
  11. package/build/EntityManager.js +27 -28
  12. package/build/EntityManager.js.map +1 -1
  13. package/build/EntityMetadata.cjs +0 -2
  14. package/build/EntityMetadata.cjs.map +1 -1
  15. package/build/EntityMetadata.d.cts +3 -3
  16. package/build/EntityMetadata.d.mts +3 -3
  17. package/build/EntityMetadata.js +0 -2
  18. package/build/EntityMetadata.js.map +1 -1
  19. package/build/IndexManager.cjs +1 -1
  20. package/build/IndexManager.cjs.map +1 -1
  21. package/build/IndexManager.js +1 -1
  22. package/build/IndexManager.js.map +1 -1
  23. package/build/InstanceData.cjs.map +1 -1
  24. package/build/InstanceData.js.map +1 -1
  25. package/build/PluginManager.cjs +0 -1
  26. package/build/PluginManager.cjs.map +1 -1
  27. package/build/PluginManager.d.cts +1 -1
  28. package/build/PluginManager.d.mts +1 -1
  29. package/build/PluginManager.js +0 -1
  30. package/build/PluginManager.js.map +1 -1
  31. package/build/batchloaders/enumCollectionBatchLoader.cjs +1 -1
  32. package/build/batchloaders/enumCollectionBatchLoader.cjs.map +1 -1
  33. package/build/batchloaders/enumCollectionBatchLoader.d.cts +1 -1
  34. package/build/batchloaders/enumCollectionBatchLoader.d.mts +1 -1
  35. package/build/batchloaders/enumCollectionBatchLoader.js +1 -1
  36. package/build/batchloaders/enumCollectionBatchLoader.js.map +1 -1
  37. package/build/batchloaders/loadBatchLoader.cjs +3 -4
  38. package/build/batchloaders/loadBatchLoader.cjs.map +1 -1
  39. package/build/batchloaders/loadBatchLoader.d.cts +1 -1
  40. package/build/batchloaders/loadBatchLoader.d.mts +1 -1
  41. package/build/batchloaders/loadBatchLoader.js +2 -3
  42. package/build/batchloaders/loadBatchLoader.js.map +1 -1
  43. package/build/batchloaders/manyToManyBatchLoader.cjs +1 -1
  44. package/build/batchloaders/manyToManyBatchLoader.cjs.map +1 -1
  45. package/build/batchloaders/manyToManyBatchLoader.d.cts +1 -1
  46. package/build/batchloaders/manyToManyBatchLoader.d.mts +1 -1
  47. package/build/batchloaders/manyToManyBatchLoader.js +1 -1
  48. package/build/batchloaders/manyToManyBatchLoader.js.map +1 -1
  49. package/build/batchloaders/oneToManyBatchLoader.cjs +1 -1
  50. package/build/batchloaders/oneToManyBatchLoader.cjs.map +1 -1
  51. package/build/batchloaders/oneToManyBatchLoader.js +1 -1
  52. package/build/batchloaders/oneToManyBatchLoader.js.map +1 -1
  53. package/build/batchloaders/oneToOneBatchLoader.cjs +1 -1
  54. package/build/batchloaders/oneToOneBatchLoader.cjs.map +1 -1
  55. package/build/batchloaders/oneToOneBatchLoader.js +1 -1
  56. package/build/batchloaders/oneToOneBatchLoader.js.map +1 -1
  57. package/build/batchloaders/populateBatchLoader.cjs +11 -12
  58. package/build/batchloaders/populateBatchLoader.cjs.map +1 -1
  59. package/build/batchloaders/populateBatchLoader.d.cts +1 -1
  60. package/build/batchloaders/populateBatchLoader.d.mts +1 -1
  61. package/build/batchloaders/populateBatchLoader.js +7 -8
  62. package/build/batchloaders/populateBatchLoader.js.map +1 -1
  63. package/build/batchloaders/recursiveChildrenBatchLoader.cjs +2 -2
  64. package/build/batchloaders/recursiveChildrenBatchLoader.cjs.map +1 -1
  65. package/build/batchloaders/recursiveChildrenBatchLoader.js +2 -2
  66. package/build/batchloaders/recursiveChildrenBatchLoader.js.map +1 -1
  67. package/build/batchloaders/recursiveM2mBatchLoader.cjs +2 -2
  68. package/build/batchloaders/recursiveM2mBatchLoader.cjs.map +1 -1
  69. package/build/batchloaders/recursiveM2mBatchLoader.js +2 -2
  70. package/build/batchloaders/recursiveM2mBatchLoader.js.map +1 -1
  71. package/build/batchloaders/recursiveParentsBatchLoader.cjs +2 -2
  72. package/build/batchloaders/recursiveParentsBatchLoader.cjs.map +1 -1
  73. package/build/batchloaders/recursiveParentsBatchLoader.js +2 -2
  74. package/build/batchloaders/recursiveParentsBatchLoader.js.map +1 -1
  75. package/build/changes.cjs +2 -3
  76. package/build/changes.cjs.map +1 -1
  77. package/build/changes.js +2 -3
  78. package/build/changes.js.map +1 -1
  79. package/build/config.cjs +3 -3
  80. package/build/config.cjs.map +1 -1
  81. package/build/config.d.cts +2 -2
  82. package/build/config.d.mts +2 -2
  83. package/build/config.js +1 -1
  84. package/build/config.js.map +1 -1
  85. package/build/configure.cjs +10 -10
  86. package/build/configure.cjs.map +1 -1
  87. package/build/configure.js +5 -5
  88. package/build/configure.js.map +1 -1
  89. package/build/dataloaders/fastWhereFilterHash.cjs +8 -8
  90. package/build/dataloaders/fastWhereFilterHash.cjs.map +1 -1
  91. package/build/dataloaders/fastWhereFilterHash.d.cts.map +1 -1
  92. package/build/dataloaders/fastWhereFilterHash.d.mts.map +1 -1
  93. package/build/dataloaders/fastWhereFilterHash.js +3 -3
  94. package/build/dataloaders/fastWhereFilterHash.js.map +1 -1
  95. package/build/dataloaders/findByUniqueDataLoader.cjs.map +1 -1
  96. package/build/dataloaders/findByUniqueDataLoader.d.cts.map +1 -1
  97. package/build/dataloaders/findByUniqueDataLoader.d.mts.map +1 -1
  98. package/build/dataloaders/findByUniqueDataLoader.js.map +1 -1
  99. package/build/dataloaders/findCountDataLoader.cjs +2 -2
  100. package/build/dataloaders/findCountDataLoader.cjs.map +1 -1
  101. package/build/dataloaders/findCountDataLoader.js +1 -1
  102. package/build/dataloaders/findCountDataLoader.js.map +1 -1
  103. package/build/dataloaders/findDataLoader.cjs +6 -6
  104. package/build/dataloaders/findDataLoader.cjs.map +1 -1
  105. package/build/dataloaders/findDataLoader.d.cts +1 -1
  106. package/build/dataloaders/findDataLoader.d.mts +1 -1
  107. package/build/dataloaders/findDataLoader.js +3 -3
  108. package/build/dataloaders/findDataLoader.js.map +1 -1
  109. package/build/dataloaders/findIdsDataLoader.cjs +3 -3
  110. package/build/dataloaders/findIdsDataLoader.cjs.map +1 -1
  111. package/build/dataloaders/findIdsDataLoader.js +2 -2
  112. package/build/dataloaders/findIdsDataLoader.js.map +1 -1
  113. package/build/dataloaders/findOrCreateDataLoader.cjs +1 -1
  114. package/build/dataloaders/findOrCreateDataLoader.cjs.map +1 -1
  115. package/build/dataloaders/findOrCreateDataLoader.d.cts.map +1 -1
  116. package/build/dataloaders/findOrCreateDataLoader.d.mts.map +1 -1
  117. package/build/dataloaders/findOrCreateDataLoader.js +1 -1
  118. package/build/dataloaders/findOrCreateDataLoader.js.map +1 -1
  119. package/build/dataloaders/findPaginatedDataLoader.cjs +6 -6
  120. package/build/dataloaders/findPaginatedDataLoader.cjs.map +1 -1
  121. package/build/dataloaders/findPaginatedDataLoader.d.cts +1 -1
  122. package/build/dataloaders/findPaginatedDataLoader.d.mts +1 -1
  123. package/build/dataloaders/findPaginatedDataLoader.js +3 -3
  124. package/build/dataloaders/findPaginatedDataLoader.js.map +1 -1
  125. package/build/dataloaders/lensDataLoader.cjs +3 -3
  126. package/build/dataloaders/lensDataLoader.cjs.map +1 -1
  127. package/build/dataloaders/lensDataLoader.d.cts.map +1 -1
  128. package/build/dataloaders/lensDataLoader.d.mts.map +1 -1
  129. package/build/dataloaders/lensDataLoader.js +2 -2
  130. package/build/dataloaders/lensDataLoader.js.map +1 -1
  131. package/build/dataloaders/manyToManyFindDataLoader.cjs +1 -1
  132. package/build/dataloaders/manyToManyFindDataLoader.cjs.map +1 -1
  133. package/build/dataloaders/manyToManyFindDataLoader.d.cts.map +1 -1
  134. package/build/dataloaders/manyToManyFindDataLoader.d.mts.map +1 -1
  135. package/build/dataloaders/manyToManyFindDataLoader.js +1 -1
  136. package/build/dataloaders/manyToManyFindDataLoader.js.map +1 -1
  137. package/build/dataloaders/oneToManyFindDataLoader.cjs +1 -1
  138. package/build/dataloaders/oneToManyFindDataLoader.cjs.map +1 -1
  139. package/build/dataloaders/oneToManyFindDataLoader.d.cts.map +1 -1
  140. package/build/dataloaders/oneToManyFindDataLoader.d.mts.map +1 -1
  141. package/build/dataloaders/oneToManyFindDataLoader.js +1 -1
  142. package/build/dataloaders/oneToManyFindDataLoader.js.map +1 -1
  143. package/build/defaults.cjs +5 -5
  144. package/build/defaults.cjs.map +1 -1
  145. package/build/defaults.d.cts +1 -1
  146. package/build/defaults.d.cts.map +1 -1
  147. package/build/defaults.d.mts +1 -1
  148. package/build/defaults.d.mts.map +1 -1
  149. package/build/defaults.js +4 -4
  150. package/build/defaults.js.map +1 -1
  151. package/build/drivers/Driver.cjs +0 -1
  152. package/build/drivers/Driver.d.cts +1 -1
  153. package/build/drivers/Driver.d.mts +1 -1
  154. package/build/drivers/Driver.js +0 -1
  155. package/build/drivers/EntityWriter.cjs +6 -7
  156. package/build/drivers/EntityWriter.cjs.map +1 -1
  157. package/build/drivers/EntityWriter.d.cts +1 -1
  158. package/build/drivers/EntityWriter.d.mts +1 -1
  159. package/build/drivers/EntityWriter.js +2 -3
  160. package/build/drivers/EntityWriter.js.map +1 -1
  161. package/build/drivers/IdAssigner.cjs +0 -1
  162. package/build/drivers/IdAssigner.cjs.map +1 -1
  163. package/build/drivers/IdAssigner.d.cts +1 -1
  164. package/build/drivers/IdAssigner.d.mts +1 -1
  165. package/build/drivers/IdAssigner.js +0 -1
  166. package/build/drivers/IdAssigner.js.map +1 -1
  167. package/build/drivers/driverApi.cjs +19 -0
  168. package/build/drivers/driverApi.cjs.map +1 -0
  169. package/build/drivers/driverApi.d.cts +22 -0
  170. package/build/drivers/driverApi.d.cts.map +1 -0
  171. package/build/drivers/driverApi.d.mts +22 -0
  172. package/build/drivers/driverApi.d.mts.map +1 -0
  173. package/build/drivers/driverApi.js +18 -0
  174. package/build/drivers/driverApi.js.map +1 -0
  175. package/build/fields.cjs +3 -3
  176. package/build/fields.cjs.map +1 -1
  177. package/build/fields.js +2 -2
  178. package/build/fields.js.map +1 -1
  179. package/build/{FlushLock.cjs → flush/FlushLock.cjs} +1 -1
  180. package/build/flush/FlushLock.cjs.map +1 -0
  181. package/build/{FlushLock.d.cts → flush/FlushLock.d.cts} +1 -1
  182. package/build/flush/FlushLock.d.cts.map +1 -0
  183. package/build/{FlushLock.d.mts → flush/FlushLock.d.mts} +1 -1
  184. package/build/flush/FlushLock.d.mts.map +1 -0
  185. package/build/{FlushLock.js → flush/FlushLock.js} +1 -1
  186. package/build/flush/FlushLock.js.map +1 -0
  187. package/build/{JoinRows.cjs → flush/JoinRows.cjs} +5 -8
  188. package/build/flush/JoinRows.cjs.map +1 -0
  189. package/build/{JoinRows.d.cts → flush/JoinRows.d.cts} +5 -5
  190. package/build/flush/JoinRows.d.cts.map +1 -0
  191. package/build/{JoinRows.d.mts → flush/JoinRows.d.mts} +5 -5
  192. package/build/flush/JoinRows.d.mts.map +1 -0
  193. package/build/{JoinRows.js → flush/JoinRows.js} +5 -8
  194. package/build/flush/JoinRows.js.map +1 -0
  195. package/build/{PendingChanges.cjs → flush/PendingChanges.cjs} +0 -1
  196. package/build/{PendingChanges.d.cts → flush/PendingChanges.d.cts} +2 -2
  197. package/build/flush/PendingChanges.d.cts.map +1 -0
  198. package/build/{PendingChanges.d.mts → flush/PendingChanges.d.mts} +2 -2
  199. package/build/flush/PendingChanges.d.mts.map +1 -0
  200. package/build/flush/PendingChanges.js +1 -0
  201. package/build/{Todo.cjs → flush/Todo.cjs} +4 -6
  202. package/build/flush/Todo.cjs.map +1 -0
  203. package/build/{Todo.d.cts → flush/Todo.d.cts} +3 -3
  204. package/build/flush/Todo.d.cts.map +1 -0
  205. package/build/{Todo.d.mts → flush/Todo.d.mts} +3 -3
  206. package/build/flush/Todo.d.mts.map +1 -0
  207. package/build/{Todo.js → flush/Todo.js} +4 -6
  208. package/build/flush/Todo.js.map +1 -0
  209. package/build/getProperties.cjs.map +1 -1
  210. package/build/getProperties.js.map +1 -1
  211. package/build/index.cjs +100 -100
  212. package/build/index.cjs.map +1 -1
  213. package/build/index.d.cts +15 -15
  214. package/build/index.d.mts +15 -15
  215. package/build/index.js +42 -42
  216. package/build/index.js.map +1 -1
  217. package/build/json.cjs +4 -4
  218. package/build/json.cjs.map +1 -1
  219. package/build/json.js +3 -3
  220. package/build/json.js.map +1 -1
  221. package/build/keys.cjs +1 -1
  222. package/build/keys.cjs.map +1 -1
  223. package/build/keys.js +1 -1
  224. package/build/keys.js.map +1 -1
  225. package/build/{HintTree.cjs → loading/HintTree.cjs} +2 -5
  226. package/build/loading/HintTree.cjs.map +1 -0
  227. package/build/{HintTree.d.cts → loading/HintTree.d.cts} +3 -3
  228. package/build/loading/HintTree.d.cts.map +1 -0
  229. package/build/{HintTree.d.mts → loading/HintTree.d.mts} +3 -3
  230. package/build/loading/HintTree.d.mts.map +1 -0
  231. package/build/{HintTree.js → loading/HintTree.js} +2 -5
  232. package/build/loading/HintTree.js.map +1 -0
  233. package/build/{IsLoadedCache.cjs → loading/IsLoadedCache.cjs} +2 -3
  234. package/build/loading/IsLoadedCache.cjs.map +1 -0
  235. package/build/{IsLoadedCache.d.cts → loading/IsLoadedCache.d.cts} +2 -2
  236. package/build/loading/IsLoadedCache.d.cts.map +1 -0
  237. package/build/{IsLoadedCache.d.mts → loading/IsLoadedCache.d.mts} +2 -2
  238. package/build/loading/IsLoadedCache.d.mts.map +1 -0
  239. package/build/{IsLoadedCache.js → loading/IsLoadedCache.js} +2 -3
  240. package/build/{IsLoadedCache.cjs.map → loading/IsLoadedCache.js.map} +1 -1
  241. package/build/{loadHints.cjs → loading/loadHints.cjs} +6 -11
  242. package/build/loading/loadHints.cjs.map +1 -0
  243. package/build/{loadHints.d.cts → loading/loadHints.d.cts} +14 -14
  244. package/build/loading/loadHints.d.cts.map +1 -0
  245. package/build/{loadHints.d.mts → loading/loadHints.d.mts} +14 -14
  246. package/build/loading/loadHints.d.mts.map +1 -0
  247. package/build/{loadHints.js → loading/loadHints.js} +3 -8
  248. package/build/loading/loadHints.js.map +1 -0
  249. package/build/{loadLens.cjs → loading/loadLens.cjs} +8 -9
  250. package/build/loading/loadLens.cjs.map +1 -0
  251. package/build/{loadLens.d.cts → loading/loadLens.d.cts} +3 -3
  252. package/build/loading/loadLens.d.cts.map +1 -0
  253. package/build/{loadLens.d.mts → loading/loadLens.d.mts} +3 -3
  254. package/build/loading/loadLens.d.mts.map +1 -0
  255. package/build/{loadLens.js → loading/loadLens.js} +8 -9
  256. package/build/loading/loadLens.js.map +1 -0
  257. package/build/{withLoaded.cjs → loading/withLoaded.cjs} +12 -13
  258. package/build/loading/withLoaded.cjs.map +1 -0
  259. package/build/{withLoaded.d.cts → loading/withLoaded.d.cts} +9 -9
  260. package/build/loading/withLoaded.d.cts.map +1 -0
  261. package/build/{withLoaded.d.mts → loading/withLoaded.d.mts} +9 -9
  262. package/build/loading/withLoaded.d.mts.map +1 -0
  263. package/build/{withLoaded.js → loading/withLoaded.js} +10 -11
  264. package/build/loading/withLoaded.js.map +1 -0
  265. package/build/logging/FactoryLogger.cjs.map +1 -1
  266. package/build/logging/FactoryLogger.d.cts.map +1 -1
  267. package/build/logging/FactoryLogger.d.mts.map +1 -1
  268. package/build/logging/FactoryLogger.js.map +1 -1
  269. package/build/logging/FieldLogger.cjs.map +1 -1
  270. package/build/logging/FieldLogger.d.cts.map +1 -1
  271. package/build/logging/FieldLogger.d.mts.map +1 -1
  272. package/build/logging/FieldLogger.js.map +1 -1
  273. package/build/logging/ReactionLogger.cjs +0 -2
  274. package/build/logging/ReactionLogger.cjs.map +1 -1
  275. package/build/logging/ReactionLogger.d.cts +2 -2
  276. package/build/logging/ReactionLogger.d.cts.map +1 -1
  277. package/build/logging/ReactionLogger.d.mts +2 -2
  278. package/build/logging/ReactionLogger.d.mts.map +1 -1
  279. package/build/logging/ReactionLogger.js +0 -2
  280. package/build/logging/ReactionLogger.js.map +1 -1
  281. package/build/newEntity.cjs.map +1 -1
  282. package/build/newEntity.js.map +1 -1
  283. package/build/newTestInstance.cjs +3 -3
  284. package/build/newTestInstance.cjs.map +1 -1
  285. package/build/newTestInstance.d.cts +1 -1
  286. package/build/newTestInstance.d.cts.map +1 -1
  287. package/build/newTestInstance.d.mts +1 -1
  288. package/build/newTestInstance.d.mts.map +1 -1
  289. package/build/newTestInstance.js +2 -2
  290. package/build/newTestInstance.js.map +1 -1
  291. package/build/normalizeHints.cjs +0 -2
  292. package/build/normalizeHints.cjs.map +1 -1
  293. package/build/normalizeHints.d.cts +2 -2
  294. package/build/normalizeHints.d.mts +2 -2
  295. package/build/normalizeHints.js +0 -2
  296. package/build/normalizeHints.js.map +1 -1
  297. package/build/nowUTC.cjs +2 -2
  298. package/build/nowUTC.cjs.map +1 -1
  299. package/build/nowUTC.d.cts +1 -1
  300. package/build/nowUTC.d.mts +1 -1
  301. package/build/nowUTC.js +1 -1
  302. package/build/nowUTC.js.map +1 -1
  303. package/build/plugins/ImmutableEntitiesPlugin.cjs.map +1 -1
  304. package/build/plugins/ImmutableEntitiesPlugin.js.map +1 -1
  305. package/build/plugins/PreloadPlugin.cjs +0 -2
  306. package/build/plugins/PreloadPlugin.d.cts +2 -2
  307. package/build/plugins/PreloadPlugin.d.mts +2 -2
  308. package/build/plugins/PreloadPlugin.js +0 -2
  309. package/build/preloading/JsonAggregatePreloader.cjs +1 -4
  310. package/build/preloading/JsonAggregatePreloader.cjs.map +1 -1
  311. package/build/preloading/JsonAggregatePreloader.d.cts +2 -2
  312. package/build/preloading/JsonAggregatePreloader.d.cts.map +1 -1
  313. package/build/preloading/JsonAggregatePreloader.d.mts +2 -2
  314. package/build/preloading/JsonAggregatePreloader.d.mts.map +1 -1
  315. package/build/preloading/JsonAggregatePreloader.js +1 -4
  316. package/build/preloading/JsonAggregatePreloader.js.map +1 -1
  317. package/build/preloading/canPreload.cjs.map +1 -1
  318. package/build/preloading/canPreload.js.map +1 -1
  319. package/build/preloading/partitionHint.cjs +2 -3
  320. package/build/preloading/partitionHint.cjs.map +1 -1
  321. package/build/preloading/partitionHint.d.cts +1 -1
  322. package/build/preloading/partitionHint.d.mts +1 -1
  323. package/build/preloading/partitionHint.js +2 -3
  324. package/build/preloading/partitionHint.js.map +1 -1
  325. package/build/queries/ConditionBuilder.cjs.map +1 -1
  326. package/build/queries/ConditionBuilder.d.cts +1 -1
  327. package/build/queries/ConditionBuilder.d.mts +1 -1
  328. package/build/queries/ConditionBuilder.js.map +1 -1
  329. package/build/queries/conditions.cjs.map +1 -1
  330. package/build/queries/conditions.js.map +1 -1
  331. package/build/queries/entityQueryUtils.cjs.map +1 -1
  332. package/build/queries/entityQueryUtils.js.map +1 -1
  333. package/build/queries/find/Aliases.cjs +1 -1
  334. package/build/queries/find/Aliases.cjs.map +1 -1
  335. package/build/queries/find/Aliases.d.cts.map +1 -1
  336. package/build/queries/find/Aliases.d.mts.map +1 -1
  337. package/build/queries/find/Aliases.js +1 -1
  338. package/build/queries/find/Aliases.js.map +1 -1
  339. package/build/queries/find/DeferredAlias.cjs.map +1 -1
  340. package/build/queries/find/DeferredAlias.js.map +1 -1
  341. package/build/queries/find/EntityFilter.cjs.map +1 -1
  342. package/build/queries/find/EntityFilter.js.map +1 -1
  343. package/build/queries/find/EntityGraphQLFilter.cjs.map +1 -1
  344. package/build/queries/find/EntityGraphQLFilter.js.map +1 -1
  345. package/build/queries/find/QueryParser.cjs +2 -2
  346. package/build/queries/find/QueryParser.cjs.map +1 -1
  347. package/build/queries/find/QueryParser.collectionJoins.cjs.map +1 -1
  348. package/build/queries/find/QueryParser.collectionJoins.js.map +1 -1
  349. package/build/queries/find/QueryParser.d.cts.map +1 -1
  350. package/build/queries/find/QueryParser.d.mts.map +1 -1
  351. package/build/queries/find/QueryParser.js +2 -2
  352. package/build/queries/find/QueryParser.js.map +1 -1
  353. package/build/queries/find/QueryParser.pruning.cjs.map +1 -1
  354. package/build/queries/find/QueryParser.pruning.js.map +1 -1
  355. package/build/queries/find/QueryVisitor.cjs.map +1 -1
  356. package/build/queries/find/QueryVisitor.js.map +1 -1
  357. package/build/queries/find/buildFindQuery.cjs.map +1 -1
  358. package/build/queries/find/buildFindQuery.js.map +1 -1
  359. package/build/queries/find/scopes.cjs.map +1 -1
  360. package/build/queries/find/scopes.d.cts +1 -1
  361. package/build/queries/find/scopes.d.mts +1 -1
  362. package/build/queries/find/scopes.js.map +1 -1
  363. package/build/queries/parsedConditions.cjs.map +1 -1
  364. package/build/queries/parsedConditions.js.map +1 -1
  365. package/build/queries/renderConditions.cjs.map +1 -1
  366. package/build/queries/renderConditions.js.map +1 -1
  367. package/build/queries/skipCondition.cjs.map +1 -1
  368. package/build/queries/skipCondition.js.map +1 -1
  369. package/build/queries/sql/AliasAssigner.cjs.map +1 -1
  370. package/build/queries/sql/AliasAssigner.js.map +1 -1
  371. package/build/queries/sql/Expr.cjs +2 -2
  372. package/build/queries/sql/Expr.cjs.map +1 -1
  373. package/build/queries/sql/Expr.d.cts +1 -1
  374. package/build/queries/sql/Expr.d.mts +1 -1
  375. package/build/queries/sql/Expr.js +1 -1
  376. package/build/queries/sql/Expr.js.map +1 -1
  377. package/build/queries/sql/Tables.cjs +1 -1
  378. package/build/queries/sql/Tables.cjs.map +1 -1
  379. package/build/queries/sql/Tables.d.cts.map +1 -1
  380. package/build/queries/sql/Tables.d.mts.map +1 -1
  381. package/build/queries/sql/Tables.js +1 -1
  382. package/build/queries/sql/Tables.js.map +1 -1
  383. package/build/queries/sql/execute.cjs +1 -1
  384. package/build/queries/sql/execute.cjs.map +1 -1
  385. package/build/queries/sql/execute.js +1 -1
  386. package/build/queries/sql/execute.js.map +1 -1
  387. package/build/queries/sql/expressions/arrayAgg.cjs.map +1 -1
  388. package/build/queries/sql/expressions/arrayAgg.js.map +1 -1
  389. package/build/queries/sql/expressions/case.cjs.map +1 -1
  390. package/build/queries/sql/expressions/case.js.map +1 -1
  391. package/build/queries/sql/expressions/coalesce.cjs.map +1 -1
  392. package/build/queries/sql/expressions/coalesce.js.map +1 -1
  393. package/build/queries/sql/expressions/codecs.cjs +2 -2
  394. package/build/queries/sql/expressions/codecs.cjs.map +1 -1
  395. package/build/queries/sql/expressions/codecs.js +1 -1
  396. package/build/queries/sql/expressions/codecs.js.map +1 -1
  397. package/build/queries/sql/expressions/expression.cjs.map +1 -1
  398. package/build/queries/sql/expressions/expression.d.cts.map +1 -1
  399. package/build/queries/sql/expressions/expression.d.mts.map +1 -1
  400. package/build/queries/sql/expressions/expression.js.map +1 -1
  401. package/build/queries/sql/expressions/greatest.cjs.map +1 -1
  402. package/build/queries/sql/expressions/greatest.js.map +1 -1
  403. package/build/queries/sql/expressions/least.cjs.map +1 -1
  404. package/build/queries/sql/expressions/least.js.map +1 -1
  405. package/build/queries/sql/expressions/nullIf.cjs.map +1 -1
  406. package/build/queries/sql/expressions/nullIf.js.map +1 -1
  407. package/build/queries/sql/expressions/parseExpression.cjs.map +1 -1
  408. package/build/queries/sql/expressions/parseExpression.js.map +1 -1
  409. package/build/queries/sql/expressions/types.d.cts.map +1 -1
  410. package/build/queries/sql/expressions/types.d.mts.map +1 -1
  411. package/build/queries/sql/query.cjs +1 -1
  412. package/build/queries/sql/query.cjs.map +1 -1
  413. package/build/queries/sql/query.d.cts +1 -1
  414. package/build/queries/sql/query.d.mts +1 -1
  415. package/build/queries/sql/query.js +1 -1
  416. package/build/queries/sql/query.js.map +1 -1
  417. package/build/{unnest.cjs → queries/unnest.cjs} +1 -2
  418. package/build/queries/unnest.cjs.map +1 -0
  419. package/build/{unnest.d.cts → queries/unnest.d.cts} +3 -3
  420. package/build/queries/unnest.d.cts.map +1 -0
  421. package/build/{unnest.d.mts → queries/unnest.d.mts} +3 -3
  422. package/build/queries/unnest.d.mts.map +1 -0
  423. package/build/{unnest.js → queries/unnest.js} +1 -2
  424. package/build/queries/unnest.js.map +1 -0
  425. package/build/queries/valueFilters.cjs.map +1 -1
  426. package/build/queries/valueFilters.d.cts +1 -1
  427. package/build/queries/valueFilters.d.cts.map +1 -1
  428. package/build/queries/valueFilters.d.mts +1 -1
  429. package/build/queries/valueFilters.d.mts.map +1 -1
  430. package/build/queries/valueFilters.js.map +1 -1
  431. package/build/{ReactionsManager.cjs → reactivity/ReactionsManager.cjs} +8 -10
  432. package/build/reactivity/ReactionsManager.cjs.map +1 -0
  433. package/build/{ReactionsManager.d.cts → reactivity/ReactionsManager.d.cts} +5 -6
  434. package/build/reactivity/ReactionsManager.d.cts.map +1 -0
  435. package/build/{ReactionsManager.d.mts → reactivity/ReactionsManager.d.mts} +5 -6
  436. package/build/reactivity/ReactionsManager.d.mts.map +1 -0
  437. package/build/{ReactionsManager.js → reactivity/ReactionsManager.js} +6 -8
  438. package/build/reactivity/ReactionsManager.js.map +1 -0
  439. package/build/{reactiveHints.cjs → reactivity/reactiveHints.cjs} +12 -16
  440. package/build/reactivity/reactiveHints.cjs.map +1 -0
  441. package/build/{reactiveHints.d.cts → reactivity/reactiveHints.d.cts} +17 -17
  442. package/build/reactivity/reactiveHints.d.cts.map +1 -0
  443. package/build/{reactiveHints.d.mts → reactivity/reactiveHints.d.mts} +17 -17
  444. package/build/reactivity/reactiveHints.d.mts.map +1 -0
  445. package/build/{reactiveHints.js → reactivity/reactiveHints.js} +12 -16
  446. package/build/reactivity/reactiveHints.js.map +1 -0
  447. package/build/relations/AbstractRelationImpl.cjs.map +1 -1
  448. package/build/relations/AbstractRelationImpl.js.map +1 -1
  449. package/build/relations/AsyncProperty.cjs.map +1 -1
  450. package/build/relations/AsyncProperty.js.map +1 -1
  451. package/build/relations/AsyncReactiveField.cjs +6 -6
  452. package/build/relations/AsyncReactiveField.cjs.map +1 -1
  453. package/build/relations/AsyncReactiveField.d.cts +1 -1
  454. package/build/relations/AsyncReactiveField.d.mts +1 -1
  455. package/build/relations/AsyncReactiveField.js +4 -4
  456. package/build/relations/AsyncReactiveField.js.map +1 -1
  457. package/build/relations/Collection.cjs +1 -1
  458. package/build/relations/Collection.cjs.map +1 -1
  459. package/build/relations/Collection.js +1 -1
  460. package/build/relations/Collection.js.map +1 -1
  461. package/build/relations/CustomCollection.cjs.map +1 -1
  462. package/build/relations/CustomCollection.d.cts +1 -1
  463. package/build/relations/CustomCollection.d.mts +1 -1
  464. package/build/relations/CustomCollection.js.map +1 -1
  465. package/build/relations/CustomReference.cjs +1 -1
  466. package/build/relations/CustomReference.cjs.map +1 -1
  467. package/build/relations/CustomReference.d.cts +1 -1
  468. package/build/relations/CustomReference.d.mts +1 -1
  469. package/build/relations/CustomReference.js +1 -1
  470. package/build/relations/CustomReference.js.map +1 -1
  471. package/build/relations/EnumCollection.cjs.map +1 -1
  472. package/build/relations/EnumCollection.d.cts +1 -1
  473. package/build/relations/EnumCollection.d.mts +1 -1
  474. package/build/relations/EnumCollection.js.map +1 -1
  475. package/build/relations/LazyField.cjs +4 -4
  476. package/build/relations/LazyField.cjs.map +1 -1
  477. package/build/relations/LazyField.js +4 -4
  478. package/build/relations/LazyField.js.map +1 -1
  479. package/build/relations/ManyToManyCollection.cjs +3 -3
  480. package/build/relations/ManyToManyCollection.cjs.map +1 -1
  481. package/build/relations/ManyToManyCollection.js +3 -3
  482. package/build/relations/ManyToManyCollection.js.map +1 -1
  483. package/build/relations/ManyToManyLargeCollection.cjs +3 -3
  484. package/build/relations/ManyToManyLargeCollection.cjs.map +1 -1
  485. package/build/relations/ManyToManyLargeCollection.js +3 -3
  486. package/build/relations/ManyToManyLargeCollection.js.map +1 -1
  487. package/build/relations/ManyToOneReference.cjs +4 -4
  488. package/build/relations/ManyToOneReference.cjs.map +1 -1
  489. package/build/relations/ManyToOneReference.js +4 -4
  490. package/build/relations/ManyToOneReference.js.map +1 -1
  491. package/build/relations/OneToManyCollection.cjs +1 -2
  492. package/build/relations/OneToManyCollection.cjs.map +1 -1
  493. package/build/relations/OneToManyCollection.d.cts +1 -1
  494. package/build/relations/OneToManyCollection.d.mts +1 -1
  495. package/build/relations/OneToManyCollection.js +1 -2
  496. package/build/relations/OneToManyCollection.js.map +1 -1
  497. package/build/relations/OneToManyLargeCollection.cjs +1 -1
  498. package/build/relations/OneToManyLargeCollection.cjs.map +1 -1
  499. package/build/relations/OneToManyLargeCollection.js +1 -1
  500. package/build/relations/OneToManyLargeCollection.js.map +1 -1
  501. package/build/relations/OneToOneReference.cjs +5 -5
  502. package/build/relations/OneToOneReference.cjs.map +1 -1
  503. package/build/relations/OneToOneReference.js +5 -5
  504. package/build/relations/OneToOneReference.js.map +1 -1
  505. package/build/relations/PolymorphicReference.cjs +3 -3
  506. package/build/relations/PolymorphicReference.cjs.map +1 -1
  507. package/build/relations/PolymorphicReference.js +3 -3
  508. package/build/relations/PolymorphicReference.js.map +1 -1
  509. package/build/relations/ReactiveField.cjs +5 -6
  510. package/build/relations/ReactiveField.cjs.map +1 -1
  511. package/build/relations/ReactiveField.d.cts +2 -2
  512. package/build/relations/ReactiveField.d.mts +2 -2
  513. package/build/relations/ReactiveField.js +3 -4
  514. package/build/relations/ReactiveField.js.map +1 -1
  515. package/build/relations/ReactiveGetter.cjs +0 -1
  516. package/build/relations/ReactiveGetter.cjs.map +1 -1
  517. package/build/relations/ReactiveGetter.d.cts +1 -1
  518. package/build/relations/ReactiveGetter.d.mts +1 -1
  519. package/build/relations/ReactiveGetter.js +0 -1
  520. package/build/relations/ReactiveGetter.js.map +1 -1
  521. package/build/relations/ReactiveManyToMany.cjs +5 -6
  522. package/build/relations/ReactiveManyToMany.cjs.map +1 -1
  523. package/build/relations/ReactiveManyToMany.d.cts +2 -2
  524. package/build/relations/ReactiveManyToMany.d.cts.map +1 -1
  525. package/build/relations/ReactiveManyToMany.d.mts +2 -2
  526. package/build/relations/ReactiveManyToMany.d.mts.map +1 -1
  527. package/build/relations/ReactiveManyToMany.js +3 -4
  528. package/build/relations/ReactiveManyToMany.js.map +1 -1
  529. package/build/relations/ReactiveManyToManyOtherSide.cjs +1 -3
  530. package/build/relations/ReactiveManyToManyOtherSide.cjs.map +1 -1
  531. package/build/relations/ReactiveManyToManyOtherSide.d.cts +2 -2
  532. package/build/relations/ReactiveManyToManyOtherSide.d.mts +2 -2
  533. package/build/relations/ReactiveManyToManyOtherSide.js +1 -3
  534. package/build/relations/ReactiveManyToManyOtherSide.js.map +1 -1
  535. package/build/relations/ReactiveReference.cjs +8 -9
  536. package/build/relations/ReactiveReference.cjs.map +1 -1
  537. package/build/relations/ReactiveReference.d.cts +2 -2
  538. package/build/relations/ReactiveReference.d.cts.map +1 -1
  539. package/build/relations/ReactiveReference.d.mts +2 -2
  540. package/build/relations/ReactiveReference.d.mts.map +1 -1
  541. package/build/relations/ReactiveReference.js +6 -7
  542. package/build/relations/ReactiveReference.js.map +1 -1
  543. package/build/relations/ReadOnlyCollection.cjs.map +1 -1
  544. package/build/relations/ReadOnlyCollection.js.map +1 -1
  545. package/build/relations/RecursiveCollection.cjs +3 -4
  546. package/build/relations/RecursiveCollection.cjs.map +1 -1
  547. package/build/relations/RecursiveCollection.d.cts +1 -1
  548. package/build/relations/RecursiveCollection.d.mts +1 -1
  549. package/build/relations/RecursiveCollection.js +3 -4
  550. package/build/relations/RecursiveCollection.js.map +1 -1
  551. package/build/relations/RecursiveCycleError.cjs.map +1 -1
  552. package/build/relations/RecursiveCycleError.js.map +1 -1
  553. package/build/relations/Reference.cjs +1 -1
  554. package/build/relations/Reference.cjs.map +1 -1
  555. package/build/relations/Reference.js +1 -1
  556. package/build/relations/Reference.js.map +1 -1
  557. package/build/relations/Relation.cjs.map +1 -1
  558. package/build/relations/Relation.js.map +1 -1
  559. package/build/relations/hasAsyncMethod.cjs +2 -2
  560. package/build/relations/hasAsyncMethod.cjs.map +1 -1
  561. package/build/relations/hasAsyncMethod.d.cts +1 -1
  562. package/build/relations/hasAsyncMethod.d.mts +1 -1
  563. package/build/relations/hasAsyncMethod.js +1 -1
  564. package/build/relations/hasAsyncMethod.js.map +1 -1
  565. package/build/relations/hasManyDerived.cjs +3 -3
  566. package/build/relations/hasManyDerived.cjs.map +1 -1
  567. package/build/relations/hasManyDerived.d.cts +1 -1
  568. package/build/relations/hasManyDerived.d.mts +1 -1
  569. package/build/relations/hasManyDerived.js +2 -2
  570. package/build/relations/hasManyDerived.js.map +1 -1
  571. package/build/relations/hasManyThrough.cjs +6 -6
  572. package/build/relations/hasManyThrough.cjs.map +1 -1
  573. package/build/relations/hasManyThrough.d.cts +1 -1
  574. package/build/relations/hasManyThrough.d.mts +1 -1
  575. package/build/relations/hasManyThrough.js +2 -2
  576. package/build/relations/hasManyThrough.js.map +1 -1
  577. package/build/relations/hasOneDerived.cjs +3 -3
  578. package/build/relations/hasOneDerived.cjs.map +1 -1
  579. package/build/relations/hasOneDerived.d.cts +1 -1
  580. package/build/relations/hasOneDerived.d.mts +1 -1
  581. package/build/relations/hasOneDerived.js +2 -2
  582. package/build/relations/hasOneDerived.js.map +1 -1
  583. package/build/relations/hasOneThrough.cjs +7 -7
  584. package/build/relations/hasOneThrough.cjs.map +1 -1
  585. package/build/relations/hasOneThrough.d.cts +1 -1
  586. package/build/relations/hasOneThrough.d.mts +1 -1
  587. package/build/relations/hasOneThrough.js +2 -2
  588. package/build/relations/hasOneThrough.js.map +1 -1
  589. package/build/relations/hasProperty.cjs +4 -4
  590. package/build/relations/hasProperty.cjs.map +1 -1
  591. package/build/relations/hasProperty.d.cts +2 -2
  592. package/build/relations/hasProperty.d.mts +2 -2
  593. package/build/relations/hasProperty.js +2 -2
  594. package/build/relations/hasProperty.js.map +1 -1
  595. package/build/relations/index.cjs +10 -10
  596. package/build/relations/index.js +10 -10
  597. package/build/relations/isCascadeDelete.cjs.map +1 -1
  598. package/build/relations/isCascadeDelete.js.map +1 -1
  599. package/build/resurrection.cjs.map +1 -1
  600. package/build/resurrection.js.map +1 -1
  601. package/build/rules.cjs +3 -4
  602. package/build/rules.cjs.map +1 -1
  603. package/build/rules.d.cts +1 -1
  604. package/build/rules.d.mts +1 -1
  605. package/build/rules.js +3 -4
  606. package/build/rules.js.map +1 -1
  607. package/build/runtimeConfig.cjs.map +1 -1
  608. package/build/runtimeConfig.js.map +1 -1
  609. package/build/{TypeInfo.cjs → serde/TypeInfo.cjs} +1 -1
  610. package/build/serde/TypeInfo.cjs.map +1 -0
  611. package/build/{TypeInfo.d.cts → serde/TypeInfo.d.cts} +2 -2
  612. package/build/serde/TypeInfo.d.cts.map +1 -0
  613. package/build/{TypeInfo.d.mts → serde/TypeInfo.d.mts} +2 -2
  614. package/build/serde/TypeInfo.d.mts.map +1 -0
  615. package/build/{TypeInfo.js → serde/TypeInfo.js} +1 -1
  616. package/build/serde/TypeInfo.js.map +1 -0
  617. package/build/{columns.cjs → serde/columns.cjs} +1 -1
  618. package/build/serde/columns.cjs.map +1 -0
  619. package/build/{columns.d.cts → serde/columns.d.cts} +2 -2
  620. package/build/serde/columns.d.cts.map +1 -0
  621. package/build/{columns.d.mts → serde/columns.d.mts} +2 -2
  622. package/build/serde/columns.d.mts.map +1 -0
  623. package/build/{columns.js → serde/columns.js} +1 -1
  624. package/build/serde/columns.js.map +1 -0
  625. package/build/{fieldSerde.cjs → serde/fieldSerde.cjs} +6 -6
  626. package/build/serde/fieldSerde.cjs.map +1 -0
  627. package/build/{fieldSerde.d.cts → serde/fieldSerde.d.cts} +5 -5
  628. package/build/serde/fieldSerde.d.cts.map +1 -0
  629. package/build/{fieldSerde.d.mts → serde/fieldSerde.d.mts} +5 -5
  630. package/build/serde/fieldSerde.d.mts.map +1 -0
  631. package/build/{fieldSerde.js → serde/fieldSerde.js} +6 -6
  632. package/build/serde/fieldSerde.js.map +1 -0
  633. package/build/{serde.cjs → serde/serde.cjs} +25 -26
  634. package/build/serde/serde.cjs.map +1 -0
  635. package/build/{serde.d.cts → serde/serde.d.cts} +1 -1
  636. package/build/serde/serde.d.cts.map +1 -0
  637. package/build/{serde.d.mts → serde/serde.d.mts} +1 -1
  638. package/build/serde/serde.d.mts.map +1 -0
  639. package/build/{serde.js → serde/serde.js} +4 -5
  640. package/build/serde/serde.js.map +1 -0
  641. package/build/{temporal.cjs → serde/temporal.cjs} +1 -1
  642. package/build/serde/temporal.cjs.map +1 -0
  643. package/build/{temporal.d.cts → serde/temporal.d.cts} +1 -1
  644. package/build/serde/temporal.d.cts.map +1 -0
  645. package/build/{temporal.d.mts → serde/temporal.d.mts} +1 -1
  646. package/build/serde/temporal.d.mts.map +1 -0
  647. package/build/{temporal.js → serde/temporal.js} +1 -1
  648. package/build/serde/temporal.js.map +1 -0
  649. package/build/{temporalMappers.cjs → serde/temporalMappers.cjs} +4 -5
  650. package/build/serde/temporalMappers.cjs.map +1 -0
  651. package/build/{temporalMappers.d.cts → serde/temporalMappers.d.cts} +1 -1
  652. package/build/serde/temporalMappers.d.cts.map +1 -0
  653. package/build/{temporalMappers.d.mts → serde/temporalMappers.d.mts} +1 -1
  654. package/build/serde/temporalMappers.d.mts.map +1 -0
  655. package/build/{temporalMappers.js → serde/temporalMappers.js} +2 -3
  656. package/build/serde/temporalMappers.js.map +1 -0
  657. package/build/upsert.cjs +1 -1
  658. package/build/upsert.cjs.map +1 -1
  659. package/build/upsert.d.cts.map +1 -1
  660. package/build/upsert.d.mts.map +1 -1
  661. package/build/upsert.js +1 -1
  662. package/build/upsert.js.map +1 -1
  663. package/build/utils.cjs +0 -1
  664. package/build/utils.cjs.map +1 -1
  665. package/build/utils.d.cts +1 -1
  666. package/build/utils.d.mts +1 -1
  667. package/build/utils.js +0 -1
  668. package/build/utils.js.map +1 -1
  669. package/package.json +2 -2
  670. package/build/FlushLock.cjs.map +0 -1
  671. package/build/FlushLock.d.cts.map +0 -1
  672. package/build/FlushLock.d.mts.map +0 -1
  673. package/build/FlushLock.js.map +0 -1
  674. package/build/HintTree.cjs.map +0 -1
  675. package/build/HintTree.d.cts.map +0 -1
  676. package/build/HintTree.d.mts.map +0 -1
  677. package/build/HintTree.js.map +0 -1
  678. package/build/IsLoadedCache.d.cts.map +0 -1
  679. package/build/IsLoadedCache.d.mts.map +0 -1
  680. package/build/IsLoadedCache.js.map +0 -1
  681. package/build/JoinRows.cjs.map +0 -1
  682. package/build/JoinRows.d.cts.map +0 -1
  683. package/build/JoinRows.d.mts.map +0 -1
  684. package/build/JoinRows.js.map +0 -1
  685. package/build/PendingChanges.d.cts.map +0 -1
  686. package/build/PendingChanges.d.mts.map +0 -1
  687. package/build/PendingChanges.js +0 -2
  688. package/build/ReactionsManager.cjs.map +0 -1
  689. package/build/ReactionsManager.d.cts.map +0 -1
  690. package/build/ReactionsManager.d.mts.map +0 -1
  691. package/build/ReactionsManager.js.map +0 -1
  692. package/build/Todo.cjs.map +0 -1
  693. package/build/Todo.d.cts.map +0 -1
  694. package/build/Todo.d.mts.map +0 -1
  695. package/build/Todo.js.map +0 -1
  696. package/build/TypeInfo.cjs.map +0 -1
  697. package/build/TypeInfo.d.cts.map +0 -1
  698. package/build/TypeInfo.d.mts.map +0 -1
  699. package/build/TypeInfo.js.map +0 -1
  700. package/build/columns.cjs.map +0 -1
  701. package/build/columns.d.cts.map +0 -1
  702. package/build/columns.d.mts.map +0 -1
  703. package/build/columns.js.map +0 -1
  704. package/build/driverApi.cjs +0 -18
  705. package/build/driverApi.cjs.map +0 -1
  706. package/build/driverApi.d.cts +0 -22
  707. package/build/driverApi.d.cts.map +0 -1
  708. package/build/driverApi.d.mts +0 -22
  709. package/build/driverApi.d.mts.map +0 -1
  710. package/build/driverApi.js +0 -18
  711. package/build/driverApi.js.map +0 -1
  712. package/build/fieldSerde.cjs.map +0 -1
  713. package/build/fieldSerde.d.cts.map +0 -1
  714. package/build/fieldSerde.d.mts.map +0 -1
  715. package/build/fieldSerde.js.map +0 -1
  716. package/build/loadHints.cjs.map +0 -1
  717. package/build/loadHints.d.cts.map +0 -1
  718. package/build/loadHints.d.mts.map +0 -1
  719. package/build/loadHints.js.map +0 -1
  720. package/build/loadLens.cjs.map +0 -1
  721. package/build/loadLens.d.cts.map +0 -1
  722. package/build/loadLens.d.mts.map +0 -1
  723. package/build/loadLens.js.map +0 -1
  724. package/build/reactiveHints.cjs.map +0 -1
  725. package/build/reactiveHints.d.cts.map +0 -1
  726. package/build/reactiveHints.d.mts.map +0 -1
  727. package/build/reactiveHints.js.map +0 -1
  728. package/build/serde.cjs.map +0 -1
  729. package/build/serde.d.cts.map +0 -1
  730. package/build/serde.d.mts.map +0 -1
  731. package/build/serde.js.map +0 -1
  732. package/build/temporal.cjs.map +0 -1
  733. package/build/temporal.d.cts.map +0 -1
  734. package/build/temporal.d.mts.map +0 -1
  735. package/build/temporal.js.map +0 -1
  736. package/build/temporalMappers.cjs.map +0 -1
  737. package/build/temporalMappers.d.cts.map +0 -1
  738. package/build/temporalMappers.d.mts.map +0 -1
  739. package/build/temporalMappers.js.map +0 -1
  740. package/build/unnest.cjs.map +0 -1
  741. package/build/unnest.d.cts.map +0 -1
  742. package/build/unnest.d.mts.map +0 -1
  743. package/build/unnest.js.map +0 -1
  744. package/build/withLoaded.cjs.map +0 -1
  745. package/build/withLoaded.d.cts.map +0 -1
  746. package/build/withLoaded.d.mts.map +0 -1
  747. package/build/withLoaded.js.map +0 -1
package/build/keys.js CHANGED
@@ -1,5 +1,5 @@
1
- import { assertNever, fail } from "./utils.js";
2
1
  import "./relations/index.js";
2
+ import { assertNever, fail } from "./utils.js";
3
3
  import { getMetadata } from "./EntityMetadata.js";
4
4
  import "./EntityManager.js";
5
5
  import { isEntity } from "./Entity.js";
package/build/keys.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","names":[],"sources":["../src/keys.ts"],"sourcesContent":["import { BaseEntity } from \"./BaseEntity.ts\";\nimport { type Entity, type IdType, isEntity } from \"./Entity.ts\";\nimport { type EntityConstructor, type IdOf, type TaggedId } from \"./EntityManager.ts\";\nimport { type EntityMetadata, getMetadata } from \"./EntityMetadata.ts\";\nimport { type Reference } from \"./relations/index.ts\";\nimport { assertNever, fail } from \"./utils.ts\";\n\nlet tagDelimiter: string | undefined = \":\";\n\n/** Sets the process-wide tagged-id format during metadata boot. */\nexport function setTaggedIdDelimiter(delimiter: string | undefined): void {\n tagDelimiter = delimiter;\n}\n\n// I'm not entirely sure this is still necessary, but use a small subset of EntityMetadata so\n// that this file doesn't have to import the type and potentially create import cycles.\ntype HasTagName = {\n tagName: string;\n /** The database column type, i.e. used to do `::type` casts in Postgres. */\n idDbType: \"bigint\" | \"int\" | \"uuid\" | \"text\";\n};\n\n/** Converts our internal/always-tagged `id` to the domain entity's `id` type (could be a number or uuid). */\nexport function toIdOf<T extends Entity>(meta: EntityMetadata<T>, id: TaggedId | undefined): IdOf<T> | undefined {\n if (!id) return undefined;\n switch (meta.idType) {\n case \"number\":\n return Number(deTagId(meta, id)) as IdOf<T>;\n case \"tagged-string\":\n return id as IdOf<T>;\n case \"untagged-string\":\n return deTagId(meta, id) as IdOf<T>;\n default:\n return assertNever(meta.idType);\n }\n}\n\n// Before a referred-to object is saved, we keep its instance in our data\n// map, and then assume it will be persisted before we're asked to persist\nexport function maybeResolveReferenceToId(\n value: Entity | Reference<any, any, any> | string | undefined,\n): TaggedId | undefined {\n return typeof value === \"string\" ? value : value?.idTaggedMaybe;\n}\n\n/** Converts `value` to a number, i.e. for string ids, unless its undefined. */\nexport function keyToNumber(meta: HasTagName, value: string | number): number;\nexport function keyToNumber(meta: HasTagName, value: string | number | undefined): number | undefined;\nexport function keyToNumber(meta: HasTagName, value: any): number | undefined {\n if (value === undefined || value === null) {\n return undefined;\n } else if (typeof value === \"number\") {\n return value;\n } else if (typeof value === \"string\") {\n if (tagDelimiter === undefined) {\n const id = value.startsWith(meta.tagName) ? value.slice(meta.tagName.length) : value;\n return maybeNumberUnlessUuid(meta, id);\n }\n const delimiterIndex = value.indexOf(tagDelimiter);\n if (delimiterIndex === -1) {\n return maybeNumberUnlessUuid(meta, value);\n }\n const tag = value.slice(0, delimiterIndex);\n if (tag !== meta.tagName) {\n throw new Error(`Invalid tagged id, expected tag ${meta.tagName}, got ${value}`);\n }\n return maybeNumberUnlessUuid(meta, value.slice(delimiterIndex + tagDelimiter.length));\n } else {\n throw new Error(`Invalid key ${value}`);\n }\n}\n\n// UUIDs, text, and bigints are strings at the database boundary, so lie to the type system and pretend they're numbers.\nfunction maybeNumberUnlessUuid(meta: HasTagName, key: string): number {\n switch (meta.idDbType) {\n case \"bigint\":\n case \"uuid\":\n case \"text\":\n return key as any;\n case \"int\":\n return Number(key);\n default:\n assertNever(meta.idDbType);\n }\n}\n\n/** Converts `dbValue` (big int, int, uuid) to a tagged string, unless its undefined. */\nexport function keyToTaggedId(meta: HasTagName, dbValue: string | number): TaggedId | undefined {\n if (dbValue === undefined || dbValue === null) return undefined;\n return `${meta.tagName}${tagDelimiter ?? \"\"}${dbValue}`;\n}\n\n/** Fails if any keys are untagged; internal batch-loader keys must always be tagged. */\nexport function assertIdsAreTagged(keys: readonly string[]): void {\n for (const key of keys) {\n const isTagged = tagDelimiter === undefined ? validSlugId.test(key) : key.indexOf(tagDelimiter) !== -1;\n if (!isTagged) throw new Error(`Key ${key} is missing a tag`);\n }\n}\n\nconst validSlugId = /^([a-z]+)(\\d+)$/i;\nconst uuidIshId = /[0-9a-z-]+/i;\n\n/** Returns whether `id` is tagged and a probably-correct value. */\nexport function isTaggedId(id: string | number): boolean;\n/** Returns whether `id` is tagged and the tag matches `meta`'s tag. */\nexport function isTaggedId(meta: EntityMetadata, id: string): boolean;\nexport function isTaggedId(metaOrId: string | number | HasTagName, id?: string): boolean {\n if (typeof metaOrId === \"number\") {\n // number overload\n return false;\n } else if (typeof metaOrId === \"string\") {\n // string overload\n return tagDelimiter === undefined ? validSlugId.test(metaOrId) : hasTagDelimiter(metaOrId);\n } else {\n // meta + string overload\n return isTaggedIdForMeta(metaOrId, id!);\n }\n}\n\nexport function assertIdIsTagged(id: string): void {\n if (!isTaggedId(id)) {\n throw new Error(`Key is not tagged ${id}`);\n }\n}\n\n/** We accept an entity in case this is m2o storing a not-yet-saved entity. */\nexport function toTaggedId(meta: HasTagName, id: IdType): TaggedId;\nexport function toTaggedId(meta: HasTagName, id: IdType | undefined): TaggedId | undefined;\nexport function toTaggedId(meta: HasTagName, id: IdType | undefined): TaggedId | undefined {\n if (typeof id === \"number\") {\n return `${meta.tagName}${tagDelimiter ?? \"\"}${id}`;\n } else if (typeof id === \"string\") {\n // This seems odd, but is covered by a unit test, so I guess we need it?\n if (id === \"\") return undefined;\n if (tagDelimiter === undefined) {\n const tag = validSlugId.exec(id)?.[1];\n if (tag && tag !== meta.tagName) {\n throw new Error(`Invalid tagged id, expected tag ${meta.tagName}, got ${id}`);\n }\n return tag ? id : `${meta.tagName}${id}`;\n } else {\n const i = id.indexOf(tagDelimiter);\n if (i === -1) return `${meta.tagName}${tagDelimiter}${id}`;\n const tag = id.slice(0, i);\n if (tag !== meta.tagName) {\n throw new Error(`Invalid tagged id, expected tag ${meta.tagName}, got ${id}`);\n }\n }\n }\n return id;\n}\n\n/** Similar to `toTaggedId`, but we accept an entity for handling relations to not-yet-saved entities. */\nexport function ensureTagged<T extends Entity>(\n meta: HasTagName,\n value: T | string | number | undefined,\n): T | TaggedId | undefined {\n return isEntity(value) ? value : toTaggedId(meta, value);\n}\n\n/** Tags a potentially untagged id, while our API inputs still accept either tagged or untagged ids. */\nexport function tagId(meta: HasTagName, id: string | number): string;\nexport function tagId(cstr: EntityConstructor<any>, id: string | number): string;\nexport function tagId(meta: HasTagName, id: string | number | null | undefined): string | undefined;\nexport function tagId(cstr: EntityConstructor<any>, id: string | number | null | undefined): string | undefined;\nexport function tagId(\n metaOrCstr: HasTagName | EntityConstructor<any>,\n id: string | number | null | undefined,\n): string | undefined {\n const meta = metadata(metaOrCstr);\n const tag = meta.tagName;\n if (typeof id === \"number\") {\n return `${tag}${tagDelimiter ?? \"\"}${id}`;\n }\n if (id === null || id === undefined) {\n return undefined;\n }\n if (tagDelimiter === undefined) {\n const existingTag = validSlugId.exec(id)?.[1];\n if (existingTag && existingTag !== tag) {\n throw new Error(`Invalid tagged id, expected tag ${tag}, got ${id}`);\n }\n return existingTag ? id : `${tag}${id}`;\n }\n // Avoid using includes/split, for a faster indexOf + length + startsWith\n const delimiterIndex = id.indexOf(tagDelimiter);\n if (delimiterIndex !== -1) {\n if (delimiterIndex !== tag.length || !id.startsWith(tag)) {\n throw new Error(`Invalid tagged id, expected tag ${tag}, got ${id}`);\n }\n return id;\n }\n return `${tag}${tagDelimiter}${id}`;\n}\n\n/** Adds the tag prefixes. */\nexport function tagIds(meta: HasTagName, keys: readonly (string | number)[]): readonly string[];\nexport function tagIds(cstr: EntityConstructor<any>, keys: readonly (string | number)[]): readonly string[];\nexport function tagIds(\n metaOrCstr: HasTagName | EntityConstructor<any>,\n keys: readonly (string | number)[],\n): readonly string[] {\n return keys.map((k) => tagId(metaOrCstr as any, k));\n}\n\nexport function deTagId(meta: HasTagName, id: string | number): string;\nexport function deTagId(meta: HasTagName, id: string | number | undefined): string | undefined;\nexport function deTagId(entity: Entity): string;\nexport function deTagId(entityOrMeta: Entity | HasTagName, id?: string | number): string | undefined {\n const meta = entityOrMeta instanceof BaseEntity ? getMetadata(entityOrMeta) : (entityOrMeta as HasTagName);\n id = id ?? (entityOrMeta as Entity).id;\n return id === undefined ? undefined : keyToNumber(meta, id).toString();\n}\n\n/** Removes the tag prefixes so we can use the keys for SQL operations. */\nexport function deTagIds(meta: HasTagName, keys: readonly string[]): readonly string[] {\n const deTagged = Array(keys.length);\n for (let i = 0; i < keys.length; i++) deTagged[i] = deTagId(meta, keys[i]);\n return deTagged;\n}\n\n/** Removes the tag prefixes so we can use the keys for SQL operations. */\nexport function unsafeDeTagIds(keys: readonly string[]): readonly string[] {\n const deTagged = Array(keys.length);\n for (let i = 0; i < keys.length; i++) {\n if (tagDelimiter === undefined) {\n deTagged[i] = validSlugId.exec(keys[i])?.[2];\n } else {\n const delimiterIndex = keys[i].indexOf(tagDelimiter);\n deTagged[i] = delimiterIndex === -1 ? undefined : keys[i].slice(delimiterIndex + tagDelimiter.length);\n }\n }\n return deTagged;\n}\n\n/** Given a tagged id, returns its tag. */\nexport function tagFromId(id: string): string {\n if (tagDelimiter === undefined) {\n return validSlugId.exec(id)?.[1] ?? fail(`Unknown tagged id format: \"${id}\"`);\n }\n const delimiterIndex = id.indexOf(tagDelimiter);\n return delimiterIndex > 0 && delimiterIndex + tagDelimiter.length < id.length\n ? id.slice(0, delimiterIndex)\n : fail(`Unknown tagged id format: \"${id}\"`);\n}\n\n/** Returns the metadata needed to format an id. */\nfunction metadata(metaOrCstr: HasTagName | EntityConstructor<any>): HasTagName {\n return typeof metaOrCstr === \"function\" ? getMetadata(metaOrCstr) : metaOrCstr;\n}\n\n/** Returns whether `id` has the tag and database id shape required by `meta`. */\nfunction isTaggedIdForMeta(meta: HasTagName, id: string): boolean {\n if (tagDelimiter === undefined) {\n return validSlugId.exec(id)?.[1] === meta.tagName;\n }\n const delimiterIndex = id.indexOf(tagDelimiter);\n if (delimiterIndex === -1) return false;\n const tag = id.slice(0, delimiterIndex);\n const untaggedId = id.slice(delimiterIndex + tagDelimiter.length);\n if (meta.tagName !== tag) return false;\n switch (meta.idDbType) {\n case \"int\":\n case \"bigint\":\n return !Number.isNaN(Number(untaggedId));\n case \"uuid\":\n return uuidIshId.test(untaggedId);\n case \"text\":\n return true;\n default:\n return assertNever(meta.idDbType);\n }\n}\n\n/** Returns whether `id` has a non-empty tag and value separated by the configured delimiter. */\nfunction hasTagDelimiter(id: string): boolean {\n if (tagDelimiter === undefined) return false;\n const delimiterIndex = id.indexOf(tagDelimiter);\n return delimiterIndex > 0 && delimiterIndex + tagDelimiter.length < id.length;\n}\n"],"mappings":";;;;;;;AAOA,IAAI,eAAmC;;AAGvC,SAAgB,qBAAqB,WAAqC;CACxE,eAAe;AACjB;;AAWA,SAAgB,OAAyB,MAAyB,IAA+C;CAC/G,IAAI,CAAC,IAAI,OAAO,KAAA;CAChB,QAAQ,KAAK,QAAb;EACE,KAAK,UACH,OAAO,OAAO,QAAQ,MAAM,EAAE,CAAC;EACjC,KAAK,iBACH,OAAO;EACT,KAAK,mBACH,OAAO,QAAQ,MAAM,E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a,MAAM;CACtG;CAEF,OAAO;AACT;;AAGA,SAAgB,UAAU,IAAoB;CAC5C,IAAI,iBAAiB,KAAA,GACnB,OAAO,YAAY,KAAK,EAAE,CAAC,GAAG,MAAM,KAAK,8BAA8B,GAAG,EAAE;CAE9E,MAAM,iBAAiB,GAAG,QAAQ,YAAY;CAC9C,OAAO,iBAAiB,KAAK,iBAAiB,aAAa,SAAS,GAAG,SACnE,GAAG,MAAM,GAAG,cAAc,IAC1B,KAAK,8BAA8B,GAAG,EAAE;AAC9C;;AAGA,SAAS,SAAS,YAA6D;CAC7E,OAAO,OAAO,eAAe,aAAa,YAAY,UAAU,IAAI;AACtE;;AAGA,SAAS,kBAAkB,MAAkB,IAAqB;CAChE,IAAI,iBAAiB,KAAA,GACnB,OAAO,YAAY,KAAK,EAAE,CAAC,GAAG,OAAO,KAAK;CAE5C,MAAM,iBAAiB,GAAG,QAAQ,YAAY;CAC9C,IAAI,mBAAmB,IAAI,OAAO;CAClC,MAAM,MAAM,GAAG,MAAM,GAAG,cAAc;CACtC,MAAM,aAAa,GAAG,MAAM,iBAAiB,aAAa,MAAM;CAChE,IAAI,KAAK,YAAY,KAAK,OAAO;CACjC,QAAQ,KAAK,UAAb;EACE,KAAK;EACL,KAAK,UACH,OAAO,CAAC,OAAO,MAAM,OAAO,UAAU,CAAC;EACzC,KAAK,QACH,OAAO,UAAU,KAAK,UAAU;EAClC,KAAK,QACH,OAAO;EACT,SACE,OAAO,YAAY,KAAK,QAAQ;CACpC;AACF;;AAGA,SAAS,gBAAgB,IAAqB;CAC5C,IAAI,iBAAiB,KAAA,GAAW,OAAO;CACvC,MAAM,iBAAiB,GAAG,QAAQ,YAAY;CAC9C,OAAO,iBAAiB,KAAK,iBAAiB,aAAa,SAAS,GAAG;AACzE"}
1
+ {"version":3,"file":"keys.js","names":[],"sources":["../src/keys.ts"],"sourcesContent":["import { BaseEntity } from \"src/BaseEntity.ts\";\nimport { type Entity, type IdType, isEntity } from \"src/Entity.ts\";\nimport { type EntityConstructor, type IdOf, type TaggedId } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, getMetadata } from \"src/EntityMetadata.ts\";\nimport { type Reference } from \"src/relations/index.ts\";\nimport { assertNever, fail } from \"src/utils.ts\";\n\nlet tagDelimiter: string | undefined = \":\";\n\n/** Sets the process-wide tagged-id format during metadata boot. */\nexport function setTaggedIdDelimiter(delimiter: string | undefined): void {\n tagDelimiter = delimiter;\n}\n\n// I'm not entirely sure this is still necessary, but use a small subset of EntityMetadata so\n// that this file doesn't have to import the type and potentially create import cycles.\ntype HasTagName = {\n tagName: string;\n /** The database column type, i.e. used to do `::type` casts in Postgres. */\n idDbType: \"bigint\" | \"int\" | \"uuid\" | \"text\";\n};\n\n/** Converts our internal/always-tagged `id` to the domain entity's `id` type (could be a number or uuid). */\nexport function toIdOf<T extends Entity>(meta: EntityMetadata<T>, id: TaggedId | undefined): IdOf<T> | undefined {\n if (!id) return undefined;\n switch (meta.idType) {\n case \"number\":\n return Number(deTagId(meta, id)) as IdOf<T>;\n case \"tagged-string\":\n return id as IdOf<T>;\n case \"untagged-string\":\n return deTagId(meta, id) as IdOf<T>;\n default:\n return assertNever(meta.idType);\n }\n}\n\n// Before a referred-to object is saved, we keep its instance in our data\n// map, and then assume it will be persisted before we're asked to persist\nexport function maybeResolveReferenceToId(\n value: Entity | Reference<any, any, any> | string | undefined,\n): TaggedId | undefined {\n return typeof value === \"string\" ? value : value?.idTaggedMaybe;\n}\n\n/** Converts `value` to a number, i.e. for string ids, unless its undefined. */\nexport function keyToNumber(meta: HasTagName, value: string | number): number;\nexport function keyToNumber(meta: HasTagName, value: string | number | undefined): number | undefined;\nexport function keyToNumber(meta: HasTagName, value: any): number | undefined {\n if (value === undefined || value === null) {\n return undefined;\n } else if (typeof value === \"number\") {\n return value;\n } else if (typeof value === \"string\") {\n if (tagDelimiter === undefined) {\n const id = value.startsWith(meta.tagName) ? value.slice(meta.tagName.length) : value;\n return maybeNumberUnlessUuid(meta, id);\n }\n const delimiterIndex = value.indexOf(tagDelimiter);\n if (delimiterIndex === -1) {\n return maybeNumberUnlessUuid(meta, value);\n }\n const tag = value.slice(0, delimiterIndex);\n if (tag !== meta.tagName) {\n throw new Error(`Invalid tagged id, expected tag ${meta.tagName}, got ${value}`);\n }\n return maybeNumberUnlessUuid(meta, value.slice(delimiterIndex + tagDelimiter.length));\n } else {\n throw new Error(`Invalid key ${value}`);\n }\n}\n\n// UUIDs, text, and bigints are strings at the database boundary, so lie to the type system and pretend they're numbers.\nfunction maybeNumberUnlessUuid(meta: HasTagName, key: string): number {\n switch (meta.idDbType) {\n case \"bigint\":\n case \"uuid\":\n case \"text\":\n return key as any;\n case \"int\":\n return Number(key);\n default:\n assertNever(meta.idDbType);\n }\n}\n\n/** Converts `dbValue` (big int, int, uuid) to a tagged string, unless its undefined. */\nexport function keyToTaggedId(meta: HasTagName, dbValue: string | number): TaggedId | undefined {\n if (dbValue === undefined || dbValue === null) return undefined;\n return `${meta.tagName}${tagDelimiter ?? \"\"}${dbValue}`;\n}\n\n/** Fails if any keys are untagged; internal batch-loader keys must always be tagged. */\nexport function assertIdsAreTagged(keys: readonly string[]): void {\n for (const key of keys) {\n const isTagged = tagDelimiter === undefined ? validSlugId.test(key) : key.indexOf(tagDelimiter) !== -1;\n if (!isTagged) throw new Error(`Key ${key} is missing a tag`);\n }\n}\n\nconst validSlugId = /^([a-z]+)(\\d+)$/i;\nconst uuidIshId = /[0-9a-z-]+/i;\n\n/** Returns whether `id` is tagged and a probably-correct value. */\nexport function isTaggedId(id: string | number): boolean;\n/** Returns whether `id` is tagged and the tag matches `meta`'s tag. */\nexport function isTaggedId(meta: EntityMetadata, id: string): boolean;\nexport function isTaggedId(metaOrId: string | number | HasTagName, id?: string): boolean {\n if (typeof metaOrId === \"number\") {\n // number overload\n return false;\n } else if (typeof metaOrId === \"string\") {\n // string overload\n return tagDelimiter === undefined ? validSlugId.test(metaOrId) : hasTagDelimiter(metaOrId);\n } else {\n // meta + string overload\n return isTaggedIdForMeta(metaOrId, id!);\n }\n}\n\nexport function assertIdIsTagged(id: string): void {\n if (!isTaggedId(id)) {\n throw new Error(`Key is not tagged ${id}`);\n }\n}\n\n/** We accept an entity in case this is m2o storing a not-yet-saved entity. */\nexport function toTaggedId(meta: HasTagName, id: IdType): TaggedId;\nexport function toTaggedId(meta: HasTagName, id: IdType | undefined): TaggedId | undefined;\nexport function toTaggedId(meta: HasTagName, id: IdType | undefined): TaggedId | undefined {\n if (typeof id === \"number\") {\n return `${meta.tagName}${tagDelimiter ?? \"\"}${id}`;\n } else if (typeof id === \"string\") {\n // This seems odd, but is covered by a unit test, so I guess we need it?\n if (id === \"\") return undefined;\n if (tagDelimiter === undefined) {\n const tag = validSlugId.exec(id)?.[1];\n if (tag && tag !== meta.tagName) {\n throw new Error(`Invalid tagged id, expected tag ${meta.tagName}, got ${id}`);\n }\n return tag ? id : `${meta.tagName}${id}`;\n } else {\n const i = id.indexOf(tagDelimiter);\n if (i === -1) return `${meta.tagName}${tagDelimiter}${id}`;\n const tag = id.slice(0, i);\n if (tag !== meta.tagName) {\n throw new Error(`Invalid tagged id, expected tag ${meta.tagName}, got ${id}`);\n }\n }\n }\n return id;\n}\n\n/** Similar to `toTaggedId`, but we accept an entity for handling relations to not-yet-saved entities. */\nexport function ensureTagged<T extends Entity>(\n meta: HasTagName,\n value: T | string | number | undefined,\n): T | TaggedId | undefined {\n return isEntity(value) ? value : toTaggedId(meta, value);\n}\n\n/** Tags a potentially untagged id, while our API inputs still accept either tagged or untagged ids. */\nexport function tagId(meta: HasTagName, id: string | number): string;\nexport function tagId(cstr: EntityConstructor<any>, id: string | number): string;\nexport function tagId(meta: HasTagName, id: string | number | null | undefined): string | undefined;\nexport function tagId(cstr: EntityConstructor<any>, id: string | number | null | undefined): string | undefined;\nexport function tagId(\n metaOrCstr: HasTagName | EntityConstructor<any>,\n id: string | number | null | undefined,\n): string | undefined {\n const meta = metadata(metaOrCstr);\n const tag = meta.tagName;\n if (typeof id === \"number\") {\n return `${tag}${tagDelimiter ?? \"\"}${id}`;\n }\n if (id === null || id === undefined) {\n return undefined;\n }\n if (tagDelimiter === undefined) {\n const existingTag = validSlugId.exec(id)?.[1];\n if (existingTag && existingTag !== tag) {\n throw new Error(`Invalid tagged id, expected tag ${tag}, got ${id}`);\n }\n return existingTag ? id : `${tag}${id}`;\n }\n // Avoid using includes/split, for a faster indexOf + length + startsWith\n const delimiterIndex = id.indexOf(tagDelimiter);\n if (delimiterIndex !== -1) {\n if (delimiterIndex !== tag.length || !id.startsWith(tag)) {\n throw new Error(`Invalid tagged id, expected tag ${tag}, got ${id}`);\n }\n return id;\n }\n return `${tag}${tagDelimiter}${id}`;\n}\n\n/** Adds the tag prefixes. */\nexport function tagIds(meta: HasTagName, keys: readonly (string | number)[]): readonly string[];\nexport function tagIds(cstr: EntityConstructor<any>, keys: readonly (string | number)[]): readonly string[];\nexport function tagIds(\n metaOrCstr: HasTagName | EntityConstructor<any>,\n keys: readonly (string | number)[],\n): readonly string[] {\n return keys.map((k) => tagId(metaOrCstr as any, k));\n}\n\nexport function deTagId(meta: HasTagName, id: string | number): string;\nexport function deTagId(meta: HasTagName, id: string | number | undefined): string | undefined;\nexport function deTagId(entity: Entity): string;\nexport function deTagId(entityOrMeta: Entity | HasTagName, id?: string | number): string | undefined {\n const meta = entityOrMeta instanceof BaseEntity ? getMetadata(entityOrMeta) : (entityOrMeta as HasTagName);\n id = id ?? (entityOrMeta as Entity).id;\n return id === undefined ? undefined : keyToNumber(meta, id).toString();\n}\n\n/** Removes the tag prefixes so we can use the keys for SQL operations. */\nexport function deTagIds(meta: HasTagName, keys: readonly string[]): readonly string[] {\n const deTagged = Array(keys.length);\n for (let i = 0; i < keys.length; i++) deTagged[i] = deTagId(meta, keys[i]);\n return deTagged;\n}\n\n/** Removes the tag prefixes so we can use the keys for SQL operations. */\nexport function unsafeDeTagIds(keys: readonly string[]): readonly string[] {\n const deTagged = Array(keys.length);\n for (let i = 0; i < keys.length; i++) {\n if (tagDelimiter === undefined) {\n deTagged[i] = validSlugId.exec(keys[i])?.[2];\n } else {\n const delimiterIndex = keys[i].indexOf(tagDelimiter);\n deTagged[i] = delimiterIndex === -1 ? undefined : keys[i].slice(delimiterIndex + tagDelimiter.length);\n }\n }\n return deTagged;\n}\n\n/** Given a tagged id, returns its tag. */\nexport function tagFromId(id: string): string {\n if (tagDelimiter === undefined) {\n return validSlugId.exec(id)?.[1] ?? fail(`Unknown tagged id format: \"${id}\"`);\n }\n const delimiterIndex = id.indexOf(tagDelimiter);\n return delimiterIndex > 0 && delimiterIndex + tagDelimiter.length < id.length\n ? id.slice(0, delimiterIndex)\n : fail(`Unknown tagged id format: \"${id}\"`);\n}\n\n/** Returns the metadata needed to format an id. */\nfunction metadata(metaOrCstr: HasTagName | EntityConstructor<any>): HasTagName {\n return typeof metaOrCstr === \"function\" ? getMetadata(metaOrCstr) : metaOrCstr;\n}\n\n/** Returns whether `id` has the tag and database id shape required by `meta`. */\nfunction isTaggedIdForMeta(meta: HasTagName, id: string): boolean {\n if (tagDelimiter === undefined) {\n return validSlugId.exec(id)?.[1] === meta.tagName;\n }\n const delimiterIndex = id.indexOf(tagDelimiter);\n if (delimiterIndex === -1) return false;\n const tag = id.slice(0, delimiterIndex);\n const untaggedId = id.slice(delimiterIndex + tagDelimiter.length);\n if (meta.tagName !== tag) return false;\n switch (meta.idDbType) {\n case \"int\":\n case \"bigint\":\n return !Number.isNaN(Number(untaggedId));\n case \"uuid\":\n return uuidIshId.test(untaggedId);\n case \"text\":\n return true;\n default:\n return assertNever(meta.idDbType);\n }\n}\n\n/** Returns whether `id` has a non-empty tag and value separated by the configured delimiter. */\nfunction hasTagDelimiter(id: string): boolean {\n if (tagDelimiter === undefined) return false;\n const delimiterIndex = id.indexOf(tagDelimiter);\n return delimiterIndex > 0 && delimiterIndex + tagDelimiter.length < id.length;\n}\n"],"mappings":";;;;;;;AAOA,IAAI,eAAmC;;AAGvC,SAAgB,qBAAqB,WAAqC;CACxE,e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AAM,iBAAiB,GAAG,QAAQ,YAAY;CAC9C,OAAO,iBAAiB,KAAK,iBAAiB,aAAa,SAAS,GAAG;AACzE"}
@@ -1,9 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_normalizeHints = require("./normalizeHints.cjs");
3
- require("./loadHints.cjs");
4
- require("./EntityManager.cjs");
5
- require("./Entity.cjs");
6
- //#region src/HintTree.ts
2
+ const require_normalizeHints = require("../normalizeHints.cjs");
3
+ //#region src/loading/HintTree.ts
7
4
  /**
8
5
  * Given a number of potentially overlapping load hints, i.e. `{ authors: "books" }` and
9
6
  * `{ authors: "reviews" }`, combines them into a single `HintNode` tree, with bookkeeping
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HintTree.cjs","names":["normalizeHint"],"sources":["../../src/loading/HintTree.ts"],"sourcesContent":["import type { Entity } from \"src/Entity.ts\";\nimport type { TaggedId } from \"src/EntityManager.ts\";\nimport type { LoadHint } from \"src/loading/loadHints.ts\";\nimport { normalizeHint } from \"src/normalizeHints.ts\";\n\n// We support preloading in `populate` with existing entities, or `load` with just ids.\n// (We could ask `populate` to convert its entities to ids, but it's convenient for it\n// to keep the HintTree populated with Entities so that newly-created entities can have\n// their collections marked as loaded.\nexport type EntityOrId = Entity | TaggedId;\n\nexport type HintNode<E extends EntityOrId> = {\n /** These entities are the root entities of our preload, i.e. we use them to trim the tree to prevent over-fetching. */\n entities: Set<E>;\n /** A runtime indication of the type of `E`. */\n entitiesKind: \"instances\" | \"ids\" | \"none\";\n /** The hints to preload at this node, i.e. if `E` is `Author`, the `books: \"reviews` or just `comments: {}`. */\n hints: { [key: string]: HintNode<E> };\n};\n\n/**\n * Given a number of potentially overlapping load hints, i.e. `{ authors: \"books\" }` and\n * `{ authors: \"reviews\" }`, combines them into a single `HintNode` tree, with bookkeeping\n * of which entities requested each specific node of the tree.\n *\n * I.e. if we're populating three publishers, two with `{ authors: \"books\" }` and one with\n * `{ authors: \"reviews\" }`, we'll end up with a tree like:\n *\n * ```\n * {\n * authors: {\n * entities: [p1, p2, p3],\n * hints: {\n * books: { entities: [p1, p2], hints: {} },\n * reviews: { entities: [p3], hints: {} },\n * }\n * }\n * }\n * ```\n *\n * Which will let us preload `authors` for all three publishers, but `books` only for the\n * first two, and `reviews` only for the third, i.e. we can prevent over-fetching.\n */\nexport function buildHintTree<E extends EntityOrId>(\n hints: readonly { entity: E; hint: LoadHint<any> | undefined }[] | LoadHint<any>,\n): HintNode<E> {\n if (Array.isArray(hints)) {\n // This might be a top-level LoadHint string[] like [\"books\"]\n const isLoadHint = hints.length > 0 && typeof hints[0] === \"string\";\n if (isLoadHint) {\n const root: HintNode<E> = { entitiesKind: \"none\", entities: new Set(), hints: {} };\n addHintNode(root, undefined, hints as LoadHint<any>);\n return root;\n } else {\n const entitiesKind = typeof hints[0].entity === \"string\" ? (\"ids\" as const) : (\"instances\" as const);\n const root: HintNode<E> = { entitiesKind, entities: new Set(), hints: {} };\n for (const { entity, hint } of hints) {\n addHintNode(root, entity, hint);\n }\n return root;\n }\n } else {\n const root: HintNode<E> = { entitiesKind: \"none\", entities: new Set(), hints: {} };\n addHintNode(root, undefined, hints as LoadHint<any>);\n return root;\n }\n}\n\nfunction addHintNode<E extends EntityOrId>(node: HintNode<E>, entity: E | undefined, hint: LoadHint<any> | undefined) {\n // It's tempting to filter out new entities here, but we need to call `.load()` on their\n // relations to ensure the `.get`s will later work, even if we don't look in the db for them.\n if (entity) node.entities.add(entity);\n if (hint) {\n for (const [key, nestedHint] of Object.entries(normalizeHint(hint))) {\n const child = (node.hints[key] ??= { entitiesKind: node.entitiesKind, entities: new Set(), hints: {} });\n addHintNode(child, entity, nestedHint);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,cACd,OACa;CACb,IAAI,MAAM,QAAQ,KAAK,GAAG;EAGxB,IADmB,MAAM,SAAS,KAAK,OAAO,MAAM,OAAO,UAC3C;GACd,MAAM,OAAoB;IAAE,cAAc;IAAQ,0BAAU,IAAI,IAAI;IAAG,OAAO,CAAC;GAAE;GACjF,YAAY,MAAM,KAAA,GAAW,KAAsB;GACnD,OAAO;EACT,OAAO;GAEL,MAAM,OAAoB;IAAE,cADP,OAAO,MAAM,EAAE,CAAC,WAAW,WAAY,QAAmB;IACrC,0BAAU,IAAI,IAAI;IAAG,OAAO,CAAC;GAAE;GACzE,KAAK,MAAM,EAAE,QAAQ,UAAU,OAC7B,YAAY,MAAM,QAAQ,IAAI;GAEhC,OAAO;EACT;CACF,OAAO;EACL,MAAM,OAAoB;GAAE,cAAc;GAAQ,0BAAU,IAAI,IAAI;GAAG,OAAO,CAAC;EAAE;EACjF,YAAY,MAAM,KAAA,GAAW,KAAsB;EACnD,OAAO;CACT;AACF;AAEA,SAAS,YAAkC,MAAmB,QAAuB,MAAiC;CAGpH,IAAI,QAAQ,KAAK,SAAS,IAAI,MAAM;CACpC,IAAI,MACF,KAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QAAQA,uBAAAA,cAAc,IAAI,CAAC,GAEhE,YAAY,KADQ,MAAM,SAAS;EAAE,cAAc,KAAK;EAAc,0BAAU,IAAI,IAAI;EAAG,OAAO,CAAC;CAAE,GAClF,QAAQ,UAAU;AAG3C"}
@@ -1,7 +1,7 @@
1
1
  import { LoadHint } from "./loadHints.cjs";
2
- import { TaggedId } from "./EntityManager.cjs";
3
- import { Entity } from "./Entity.cjs";
4
- //#region src/HintTree.d.ts
2
+ import { TaggedId } from "../EntityManager.cjs";
3
+ import { Entity } from "../Entity.cjs";
4
+ //#region src/loading/HintTree.d.ts
5
5
  type EntityOrId = Entity | TaggedId;
6
6
  type HintNode<E extends EntityOrId> = {
7
7
  /** These entities are the root entities of our preload, i.e. we use them to trim the tree to prevent over-fetching. */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HintTree.d.cts","names":[],"sources":["../../src/loading/HintTree.ts"],"mappings":";;;;KASY,aAAa,SAAS;KAEtB,SAAS,UAAU;;EAE7B,UAAU,IAAI;;EAEd;;EAEA;KAAU,cAAc,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BnB,cAAc,UAAU,YACtC;EAAkB,QAAQ;EAAG,MAAM;MAAgC,gBAClE,SAAS"}
@@ -1,7 +1,7 @@
1
1
  import { LoadHint } from "./loadHints.mjs";
2
- import { TaggedId } from "./EntityManager.mjs";
3
- import { Entity } from "./Entity.mjs";
4
- //#region src/HintTree.d.ts
2
+ import { TaggedId } from "../EntityManager.mjs";
3
+ import { Entity } from "../Entity.mjs";
4
+ //#region src/loading/HintTree.d.ts
5
5
  type EntityOrId = Entity | TaggedId;
6
6
  type HintNode<E extends EntityOrId> = {
7
7
  /** These entities are the root entities of our preload, i.e. we use them to trim the tree to prevent over-fetching. */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HintTree.d.mts","names":[],"sources":["../../src/loading/HintTree.ts"],"mappings":";;;;KASY,aAAa,SAAS;KAEtB,SAAS,UAAU;;EAE7B,UAAU,IAAI;;EAEd;;EAEA;KAAU,cAAc,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BnB,cAAc,UAAU,YACtC;EAAkB,QAAQ;EAAG,MAAM;MAAgC,gBAClE,SAAS"}
@@ -1,8 +1,5 @@
1
- import { normalizeHint } from "./normalizeHints.js";
2
- import "./loadHints.js";
3
- import "./EntityManager.js";
4
- import "./Entity.js";
5
- //#region src/HintTree.ts
1
+ import { normalizeHint } from "../normalizeHints.js";
2
+ //#region src/loading/HintTree.ts
6
3
  /**
7
4
  * Given a number of potentially overlapping load hints, i.e. `{ authors: "books" }` and
8
5
  * `{ authors: "reviews" }`, combines them into a single `HintNode` tree, with bookkeeping
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HintTree.js","names":[],"sources":["../../src/loading/HintTree.ts"],"sourcesContent":["import type { Entity } from \"src/Entity.ts\";\nimport type { TaggedId } from \"src/EntityManager.ts\";\nimport type { LoadHint } from \"src/loading/loadHints.ts\";\nimport { normalizeHint } from \"src/normalizeHints.ts\";\n\n// We support preloading in `populate` with existing entities, or `load` with just ids.\n// (We could ask `populate` to convert its entities to ids, but it's convenient for it\n// to keep the HintTree populated with Entities so that newly-created entities can have\n// their collections marked as loaded.\nexport type EntityOrId = Entity | TaggedId;\n\nexport type HintNode<E extends EntityOrId> = {\n /** These entities are the root entities of our preload, i.e. we use them to trim the tree to prevent over-fetching. */\n entities: Set<E>;\n /** A runtime indication of the type of `E`. */\n entitiesKind: \"instances\" | \"ids\" | \"none\";\n /** The hints to preload at this node, i.e. if `E` is `Author`, the `books: \"reviews` or just `comments: {}`. */\n hints: { [key: string]: HintNode<E> };\n};\n\n/**\n * Given a number of potentially overlapping load hints, i.e. `{ authors: \"books\" }` and\n * `{ authors: \"reviews\" }`, combines them into a single `HintNode` tree, with bookkeeping\n * of which entities requested each specific node of the tree.\n *\n * I.e. if we're populating three publishers, two with `{ authors: \"books\" }` and one with\n * `{ authors: \"reviews\" }`, we'll end up with a tree like:\n *\n * ```\n * {\n * authors: {\n * entities: [p1, p2, p3],\n * hints: {\n * books: { entities: [p1, p2], hints: {} },\n * reviews: { entities: [p3], hints: {} },\n * }\n * }\n * }\n * ```\n *\n * Which will let us preload `authors` for all three publishers, but `books` only for the\n * first two, and `reviews` only for the third, i.e. we can prevent over-fetching.\n */\nexport function buildHintTree<E extends EntityOrId>(\n hints: readonly { entity: E; hint: LoadHint<any> | undefined }[] | LoadHint<any>,\n): HintNode<E> {\n if (Array.isArray(hints)) {\n // This might be a top-level LoadHint string[] like [\"books\"]\n const isLoadHint = hints.length > 0 && typeof hints[0] === \"string\";\n if (isLoadHint) {\n const root: HintNode<E> = { entitiesKind: \"none\", entities: new Set(), hints: {} };\n addHintNode(root, undefined, hints as LoadHint<any>);\n return root;\n } else {\n const entitiesKind = typeof hints[0].entity === \"string\" ? (\"ids\" as const) : (\"instances\" as const);\n const root: HintNode<E> = { entitiesKind, entities: new Set(), hints: {} };\n for (const { entity, hint } of hints) {\n addHintNode(root, entity, hint);\n }\n return root;\n }\n } else {\n const root: HintNode<E> = { entitiesKind: \"none\", entities: new Set(), hints: {} };\n addHintNode(root, undefined, hints as LoadHint<any>);\n return root;\n }\n}\n\nfunction addHintNode<E extends EntityOrId>(node: HintNode<E>, entity: E | undefined, hint: LoadHint<any> | undefined) {\n // It's tempting to filter out new entities here, but we need to call `.load()` on their\n // relations to ensure the `.get`s will later work, even if we don't look in the db for them.\n if (entity) node.entities.add(entity);\n if (hint) {\n for (const [key, nestedHint] of Object.entries(normalizeHint(hint))) {\n const child = (node.hints[key] ??= { entitiesKind: node.entitiesKind, entities: new Set(), hints: {} });\n addHintNode(child, entity, nestedHint);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,cACd,OACa;CACb,IAAI,MAAM,QAAQ,KAAK,GAAG;EAGxB,IADmB,MAAM,SAAS,KAAK,OAAO,MAAM,OAAO,UAC3C;GACd,MAAM,OAAoB;IAAE,cAAc;IAAQ,0BAAU,IAAI,IAAI;IAAG,OAAO,CAAC;GAAE;GACjF,YAAY,MAAM,KAAA,GAAW,KAAsB;GACnD,OAAO;EACT,OAAO;GAEL,MAAM,OAAoB;IAAE,cADP,OAAO,MAAM,EAAE,CAAC,WAAW,WAAY,QAAmB;IACrC,0BAAU,IAAI,IAAI;IAAG,OAAO,CAAC;GAAE;GACzE,KAAK,MAAM,EAAE,QAAQ,UAAU,OAC7B,YAAY,MAAM,QAAQ,IAAI;GAEhC,OAAO;EACT;CACF,OAAO;EACL,MAAM,OAAoB;GAAE,cAAc;GAAQ,0BAAU,IAAI,IAAI;GAAG,OAAO,CAAC;EAAE;EACjF,YAAY,MAAM,KAAA,GAAW,KAAsB;EACnD,OAAO;CACT;AACF;AAEA,SAAS,YAAkC,MAAmB,QAAuB,MAAiC;CAGpH,IAAI,QAAQ,KAAK,SAAS,IAAI,MAAM;CACpC,IAAI,MACF,KAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QAAQ,cAAc,IAAI,CAAC,GAEhE,YAAY,KADQ,MAAM,SAAS;EAAE,cAAc,KAAK;EAAc,0BAAU,IAAI,IAAI;EAAG,OAAO,CAAC;CAAE,GAClF,QAAQ,UAAU;AAG3C"}
@@ -1,7 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_EntityMetadata = require("./EntityMetadata.cjs");
3
- require("./Entity.cjs");
4
- //#region src/IsLoadedCache.ts
2
+ const require_EntityMetadata = require("../EntityMetadata.cjs");
3
+ //#region src/loading/IsLoadedCache.ts
5
4
  var IsLoadedCache = class {
6
5
  #smartCache = {};
7
6
  #naiveCache = /* @__PURE__ */ new Set();
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IsLoadedCache.cjs","names":["getMetadata","#smartCache","#smartDirtySets","#naiveCache","#naiveDirtySets","#resetDownstreamReactables"],"sources":["../../src/loading/IsLoadedCache.ts"],"sourcesContent":["import type { Entity } from \"src/Entity.ts\";\nimport { type EntityMetadata, getMetadata } from \"src/EntityMetadata.ts\";\n\n/**\n * Interface for our relations that have dynamic & expensive `isLoaded` checks.\n *\n * ...and also `OneToManyCollection.get` calls.\n *\n * The primary m2o/o2m/m2m relations all have trivial `isLoaded` checks--are they\n * loaded or not.\n *\n * But for \"composite relations\", i.e. a ReactiveField or ReactiveRelation whose\n * \"load-ness\" is calculated by evaluating its load hint across a subgraph of entities\n * & relations, load-ness can be more dynamic true-then-false, as its subgraph changes.\n *\n * To avoid performance issues (see https://github.com/joist-orm/joist-orm/issues/1166),\n * we cache this dynamic/expensive `isLoaded` checks, and then do targeted, reactivity-driven\n * cache invalidation whenever relations are mutated (via a hook in `setField`).\n */\nexport interface IsLoadedCachable {\n entity: Entity;\n fieldName: string;\n isLoaded: boolean;\n resetIsLoaded(): void;\n}\n\nexport class IsLoadedCache {\n // Cache of `{ tag -> { fieldName -> Set<IsLoadedCachable> } }` to hold derived relations\n // we can selectively invalidate by walking from the mutated field to any downstream\n // cacheables.\n #smartCache: Record<string, Record<string, Set<IsLoadedCachable>>> = {};\n // A dumb cache for things that are hard selectively invalidate (o2m.get, recursive collections,\n // and custom references/collections), so any mutation resets these.\n #naiveCache = new Set<IsLoadedCachable>();\n // Counter to skip reactive hint walking when no smart cache sets are populated.\n #smartDirtySets = 0;\n // Counter to fast-path resetIsLoaded when the naive cache is empty.\n #naiveDirtySets = 0;\n\n /** Adds a ReactiveField/Relation/Collection to be invalidated when its dependencies change. */\n add(target: IsLoadedCachable): void {\n const meta = getMetadata(target.entity);\n const set = ((this.#smartCache[meta.tagName] ??= {})[target.fieldName] ??= new Set());\n if (set.size === 0) {\n this.#smartDirtySets++;\n }\n set.add(target);\n }\n\n addNaive(target: IsLoadedCachable): void {\n if (this.#naiveCache.size === 0) this.#naiveDirtySets++;\n this.#naiveCache.add(target);\n }\n\n /** Resets any in-memory #isLoaded/#isCached caches that depend on `entity.fieldName`. */\n resetIsLoaded(entity: Entity, fieldName: string): void {\n if (this.#smartDirtySets === 0 && this.#naiveDirtySets === 0) return;\n // Reset caches that we can deterministically find by walking the reactivity hints\n if (this.#smartDirtySets > 0) {\n this.#resetDownstreamReactables(getMetadata(entity), fieldName);\n }\n // We could use this to invalidate m2o.get, but it doesn't work for collections\n // with an orderBy, when the orderBy changes, so for now we use the blunt naiveCache.\n // const field = meta.allFields[fieldName];\n // if (field.kind === \"m2o\") {\n // const otherMeta = field.otherMetadata();\n // const set = this.smartCache[otherMeta.tagName]?.[field.otherFieldName];\n // if (set) {\n // for (const target of set) target.resetIsLoaded();\n // set.clear();\n // }\n // }\n if (this.#naiveCache.size > 0) {\n for (const target of this.#naiveCache.values()) target.resetIsLoaded();\n this.#naiveCache.clear();\n this.#naiveDirtySets--;\n }\n }\n\n /**\n * Given a `meta+field`, statically find all downstream Reactables, and if any of those\n * Reactables are a) in-memory already, and b) registered themselves as cached,\n * tell them to reset.\n */\n #resetDownstreamReactables(meta: EntityMetadata, fieldName: string): void {\n // These are reactables in other entities that are watching/reacting to this entity/fieldName\n const reactables = meta.reactablesIncludingReadOnlyByField!.get(fieldName);\n if (reactables === undefined) return;\n for (const r of reactables) {\n if (this.#smartDirtySets === 0) return;\n // I.e. we've written to Author.firstName, and this reactable in Book/otherMeta depends on it\n const otherMeta = getMetadata(r.cstr);\n // Find any cache entries for this cstr + name\n const set = this.#smartCache[otherMeta.tagName]?.[r.name];\n if (set?.size > 0) {\n for (const target of set) {\n target.resetIsLoaded();\n // Is this target itself a RF/RR? If so, transitively reset its cache as well.\n const otherMeta = getMetadata(target.entity);\n const otherField = otherMeta.allFields[target.fieldName];\n if (\"derived\" in otherField && otherField.derived) {\n this.#resetDownstreamReactables(otherMeta, otherField.fieldName);\n }\n }\n set.clear();\n this.#smartDirtySets--;\n }\n }\n }\n}\n"],"mappings":";;;AA0BA,IAAa,gBAAb,MAA2B;CAIzB,cAAqE,CAAC;CAGtE,8BAAc,IAAI,IAAsB;CAExC,kBAAkB;CAElB,kBAAkB;;CAGlB,IAAI,QAAgC;EAClC,MAAM,OAAOA,uBAAAA,YAAY,OAAO,MAAM;EACtC,MAAM,MAAO,CAAC,KAAKC,YAAY,KAAK,aAAa,CAAC,EAAA,CAAG,OAAO,+BAAe,IAAI,IAAI;EACnF,IAAI,IAAI,SAAS,GACf,KAAKC;EAEP,IAAI,IAAI,MAAM;CAChB;CAEA,SAAS,QAAgC;EACvC,IAAI,KAAKC,YAAY,SAAS,GAAG,KAAKC;EACtC,KAAKD,YAAY,IAAI,MAAM;CAC7B;;CAGA,cAAc,QAAgB,WAAyB;EACrD,IAAI,KAAKD,oBAAoB,KAAK,KAAKE,oBAAoB,GAAG;EAE9D,IAAI,KAAKF,kBAAkB,GACzB,KAAKG,2BAA2BL,uBAAAA,YAAY,MAAM,GAAG,SAAS;EAahE,IAAI,KAAKG,YAAY,OAAO,GAAG;GAC7B,KAAK,MAAM,UAAU,KAAKA,YAAY,OAAO,GAAG,OAAO,cAAc;GACrE,KAAKA,YAAY,MAAM;GACvB,KAAKC;EACP;CACF;;;;;;CAOA,2BAA2B,MAAsB,WAAyB;EAExE,MAAM,aAAa,KAAK,mCAAoC,IAAI,SAAS;EACzE,IAAI,eAAe,KAAA,GAAW;EAC9B,KAAK,MAAM,KAAK,YAAY;GAC1B,IAAI,KAAKF,oBAAoB,GAAG;GAEhC,MAAM,YAAYF,uBAAAA,YAAY,EAAE,IAAI;GAEpC,MAAM,MAAM,KAAKC,YAAY,UAAU,QAAQ,GAAG,EAAE;GACpD,IAAI,KAAK,OAAO,GAAG;IACjB,KAAK,MAAM,UAAU,KAAK;KACxB,OAAO,cAAc;KAErB,MAAM,YAAYD,uBAAAA,YAAY,OAAO,MAAM;KAC3C,MAAM,aAAa,UAAU,UAAU,OAAO;KAC9C,IAAI,aAAa,cAAc,WAAW,SACxC,KAAKK,2BAA2B,WAAW,WAAW,SAAS;IAEnE;IACA,IAAI,MAAM;IACV,KAAKH;GACP;EACF;CACF;AACF"}
@@ -1,5 +1,5 @@
1
- import { Entity } from "./Entity.cjs";
2
- //#region src/IsLoadedCache.d.ts
1
+ import { Entity } from "../Entity.cjs";
2
+ //#region src/loading/IsLoadedCache.d.ts
3
3
  /**
4
4
  * Interface for our relations that have dynamic & expensive `isLoaded` checks.
5
5
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IsLoadedCache.d.cts","names":[],"sources":["../../src/loading/IsLoadedCache.ts"],"mappings":";;;;;;;;;;;;;;;;;;UAmBiB;EACf,QAAQ;EACR;EACA;EACA;;cAGW;;;EAcX,IAAI,QAAQ;EASZ,SAAS,QAAQ;;EAMjB,cAAc,QAAQ,QAAQ"}
@@ -1,5 +1,5 @@
1
- import { Entity } from "./Entity.mjs";
2
- //#region src/IsLoadedCache.d.ts
1
+ import { Entity } from "../Entity.mjs";
2
+ //#region src/loading/IsLoadedCache.d.ts
3
3
  /**
4
4
  * Interface for our relations that have dynamic & expensive `isLoaded` checks.
5
5
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IsLoadedCache.d.mts","names":[],"sources":["../../src/loading/IsLoadedCache.ts"],"mappings":";;;;;;;;;;;;;;;;;;UAmBiB;EACf,QAAQ;EACR;EACA;EACA;;cAGW;;;EAcX,IAAI,QAAQ;EASZ,SAAS,QAAQ;;EAMjB,cAAc,QAAQ,QAAQ"}
@@ -1,6 +1,5 @@
1
- import { getMetadata } from "./EntityMetadata.js";
2
- import "./Entity.js";
3
- //#region src/IsLoadedCache.ts
1
+ import { getMetadata } from "../EntityMetadata.js";
2
+ //#region src/loading/IsLoadedCache.ts
4
3
  var IsLoadedCache = class {
5
4
  #smartCache = {};
6
5
  #naiveCache = /* @__PURE__ */ new Set();
@@ -1 +1 @@
1
- {"version":3,"file":"IsLoadedCache.cjs","names":["getMetadata","#smartCache","#smartDirtySets","#naiveCache","#naiveDirtySets","#resetDownstreamReactables"],"sources":["../src/IsLoadedCache.ts"],"sourcesContent":["import { type Entity } from \"./Entity.ts\";\nimport { type EntityMetadata, getMetadata } from \"./EntityMetadata.ts\";\n\n/**\n * Interface for our relations that have dynamic & expensive `isLoaded` checks.\n *\n * ...and also `OneToManyCollection.get` calls.\n *\n * The primary m2o/o2m/m2m relations all have trivial `isLoaded` checks--are they\n * loaded or not.\n *\n * But for \"composite relations\", i.e. a ReactiveField or ReactiveRelation whose\n * \"load-ness\" is calculated by evaluating its load hint across a subgraph of entities\n * & relations, load-ness can be more dynamic true-then-false, as its subgraph changes.\n *\n * To avoid performance issues (see https://github.com/joist-orm/joist-orm/issues/1166),\n * we cache this dynamic/expensive `isLoaded` checks, and then do targeted, reactivity-driven\n * cache invalidation whenever relations are mutated (via a hook in `setField`).\n */\nexport interface IsLoadedCachable {\n entity: Entity;\n fieldName: string;\n isLoaded: boolean;\n resetIsLoaded(): void;\n}\n\nexport class IsLoadedCache {\n // Cache of `{ tag -> { fieldName -> Set<IsLoadedCachable> } }` to hold derived relations\n // we can selectively invalidate by walking from the mutated field to any downstream\n // cacheables.\n #smartCache: Record<string, Record<string, Set<IsLoadedCachable>>> = {};\n // A dumb cache for things that are hard selectively invalidate (o2m.get, recursive collections,\n // and custom references/collections), so any mutation resets these.\n #naiveCache = new Set<IsLoadedCachable>();\n // Counter to skip reactive hint walking when no smart cache sets are populated.\n #smartDirtySets = 0;\n // Counter to fast-path resetIsLoaded when the naive cache is empty.\n #naiveDirtySets = 0;\n\n /** Adds a ReactiveField/Relation/Collection to be invalidated when its dependencies change. */\n add(target: IsLoadedCachable): void {\n const meta = getMetadata(target.entity);\n const set = ((this.#smartCache[meta.tagName] ??= {})[target.fieldName] ??= new Set());\n if (set.size === 0) {\n this.#smartDirtySets++;\n }\n set.add(target);\n }\n\n addNaive(target: IsLoadedCachable): void {\n if (this.#naiveCache.size === 0) this.#naiveDirtySets++;\n this.#naiveCache.add(target);\n }\n\n /** Resets any in-memory #isLoaded/#isCached caches that depend on `entity.fieldName`. */\n resetIsLoaded(entity: Entity, fieldName: string): void {\n if (this.#smartDirtySets === 0 && this.#naiveDirtySets === 0) return;\n // Reset caches that we can deterministically find by walking the reactivity hints\n if (this.#smartDirtySets > 0) {\n this.#resetDownstreamReactables(getMetadata(entity), fieldName);\n }\n // We could use this to invalidate m2o.get, but it doesn't work for collections\n // with an orderBy, when the orderBy changes, so for now we use the blunt naiveCache.\n // const field = meta.allFields[fieldName];\n // if (field.kind === \"m2o\") {\n // const otherMeta = field.otherMetadata();\n // const set = this.smartCache[otherMeta.tagName]?.[field.otherFieldName];\n // if (set) {\n // for (const target of set) target.resetIsLoaded();\n // set.clear();\n // }\n // }\n if (this.#naiveCache.size > 0) {\n for (const target of this.#naiveCache.values()) target.resetIsLoaded();\n this.#naiveCache.clear();\n this.#naiveDirtySets--;\n }\n }\n\n /**\n * Given a `meta+field`, statically find all downstream Reactables, and if any of those\n * Reactables are a) in-memory already, and b) registered themselves as cached,\n * tell them to reset.\n */\n #resetDownstreamReactables(meta: EntityMetadata, fieldName: string): void {\n // These are reactables in other entities that are watching/reacting to this entity/fieldName\n const reactables = meta.reactablesIncludingReadOnlyByField!.get(fieldName);\n if (reactables === undefined) return;\n for (const r of reactables) {\n if (this.#smartDirtySets === 0) return;\n // I.e. we've written to Author.firstName, and this reactable in Book/otherMeta depends on it\n const otherMeta = getMetadata(r.cstr);\n // Find any cache entries for this cstr + name\n const set = this.#smartCache[otherMeta.tagName]?.[r.name];\n if (set?.size > 0) {\n for (const target of set) {\n target.resetIsLoaded();\n // Is this target itself a RF/RR? If so, transitively reset its cache as well.\n const otherMeta = getMetadata(target.entity);\n const otherField = otherMeta.allFields[target.fieldName];\n if (\"derived\" in otherField && otherField.derived) {\n this.#resetDownstreamReactables(otherMeta, otherField.fieldName);\n }\n }\n set.clear();\n this.#smartDirtySets--;\n }\n }\n }\n}\n"],"mappings":";;;;AA0BA,IAAa,gBAAb,MAA2B;CAIzB,cAAqE,CAAC;CAGtE,8BAAc,IAAI,IAAsB;CAExC,kBAAkB;CAElB,kBAAkB;;CAGlB,IAAI,QAAgC;EAClC,MAAM,OAAOA,uBAAAA,YAAY,OAAO,MAAM;EACtC,MAAM,MAAO,CAAC,KAAKC,YAAY,KAAK,aAAa,CAAC,EAAA,CAAG,OAAO,+BAAe,IAAI,IAAI;EACnF,IAAI,IAAI,SAAS,GACf,KAAKC;EAEP,IAAI,IAAI,MAAM;CAChB;CAEA,SAAS,QAAgC;EACvC,IAAI,KAAKC,YAAY,SAAS,GAAG,KAAKC;EACtC,KAAKD,YAAY,IAAI,MAAM;CAC7B;;CAGA,cAAc,QAAgB,WAAyB;EACrD,IAAI,KAAKD,oBAAoB,KAAK,KAAKE,oBAAoB,GAAG;EAE9D,IAAI,KAAKF,kBAAkB,GACzB,KAAKG,2BAA2BL,uBAAAA,YAAY,MAAM,GAAG,SAAS;EAahE,IAAI,KAAKG,YAAY,OAAO,GAAG;GAC7B,KAAK,MAAM,UAAU,KAAKA,YAAY,OAAO,GAAG,OAAO,cAAc;GACrE,KAAKA,YAAY,MAAM;GACvB,KAAKC;EACP;CACF;;;;;;CAOA,2BAA2B,MAAsB,WAAyB;EAExE,MAAM,aAAa,KAAK,mCAAoC,IAAI,SAAS;EACzE,IAAI,eAAe,KAAA,GAAW;EAC9B,KAAK,MAAM,KAAK,YAAY;GAC1B,IAAI,KAAKF,oBAAoB,GAAG;GAEhC,MAAM,YAAYF,uBAAAA,YAAY,EAAE,IAAI;GAEpC,MAAM,MAAM,KAAKC,YAAY,UAAU,QAAQ,GAAG,EAAE;GACpD,IAAI,KAAK,OAAO,GAAG;IACjB,KAAK,MAAM,UAAU,KAAK;KACxB,OAAO,cAAc;KAErB,MAAM,YAAYD,uBAAAA,YAAY,OAAO,MAAM;KAC3C,MAAM,aAAa,UAAU,UAAU,OAAO;KAC9C,IAAI,aAAa,cAAc,WAAW,SACxC,KAAKK,2BAA2B,WAAW,WAAW,SAAS;IAEnE;IACA,IAAI,MAAM;IACV,KAAKH;GACP;EACF;CACF;AACF"}
1
+ {"version":3,"file":"IsLoadedCache.js","names":["#smartCache","#smartDirtySets","#naiveCache","#naiveDirtySets","#resetDownstreamReactables"],"sources":["../../src/loading/IsLoadedCache.ts"],"sourcesContent":["import type { Entity } from \"src/Entity.ts\";\nimport { type EntityMetadata, getMetadata } from \"src/EntityMetadata.ts\";\n\n/**\n * Interface for our relations that have dynamic & expensive `isLoaded` checks.\n *\n * ...and also `OneToManyCollection.get` calls.\n *\n * The primary m2o/o2m/m2m relations all have trivial `isLoaded` checks--are they\n * loaded or not.\n *\n * But for \"composite relations\", i.e. a ReactiveField or ReactiveRelation whose\n * \"load-ness\" is calculated by evaluating its load hint across a subgraph of entities\n * & relations, load-ness can be more dynamic true-then-false, as its subgraph changes.\n *\n * To avoid performance issues (see https://github.com/joist-orm/joist-orm/issues/1166),\n * we cache this dynamic/expensive `isLoaded` checks, and then do targeted, reactivity-driven\n * cache invalidation whenever relations are mutated (via a hook in `setField`).\n */\nexport interface IsLoadedCachable {\n entity: Entity;\n fieldName: string;\n isLoaded: boolean;\n resetIsLoaded(): void;\n}\n\nexport class IsLoadedCache {\n // Cache of `{ tag -> { fieldName -> Set<IsLoadedCachable> } }` to hold derived relations\n // we can selectively invalidate by walking from the mutated field to any downstream\n // cacheables.\n #smartCache: Record<string, Record<string, Set<IsLoadedCachable>>> = {};\n // A dumb cache for things that are hard selectively invalidate (o2m.get, recursive collections,\n // and custom references/collections), so any mutation resets these.\n #naiveCache = new Set<IsLoadedCachable>();\n // Counter to skip reactive hint walking when no smart cache sets are populated.\n #smartDirtySets = 0;\n // Counter to fast-path resetIsLoaded when the naive cache is empty.\n #naiveDirtySets = 0;\n\n /** Adds a ReactiveField/Relation/Collection to be invalidated when its dependencies change. */\n add(target: IsLoadedCachable): void {\n const meta = getMetadata(target.entity);\n const set = ((this.#smartCache[meta.tagName] ??= {})[target.fieldName] ??= new Set());\n if (set.size === 0) {\n this.#smartDirtySets++;\n }\n set.add(target);\n }\n\n addNaive(target: IsLoadedCachable): void {\n if (this.#naiveCache.size === 0) this.#naiveDirtySets++;\n this.#naiveCache.add(target);\n }\n\n /** Resets any in-memory #isLoaded/#isCached caches that depend on `entity.fieldName`. */\n resetIsLoaded(entity: Entity, fieldName: string): void {\n if (this.#smartDirtySets === 0 && this.#naiveDirtySets === 0) return;\n // Reset caches that we can deterministically find by walking the reactivity hints\n if (this.#smartDirtySets > 0) {\n this.#resetDownstreamReactables(getMetadata(entity), fieldName);\n }\n // We could use this to invalidate m2o.get, but it doesn't work for collections\n // with an orderBy, when the orderBy changes, so for now we use the blunt naiveCache.\n // const field = meta.allFields[fieldName];\n // if (field.kind === \"m2o\") {\n // const otherMeta = field.otherMetadata();\n // const set = this.smartCache[otherMeta.tagName]?.[field.otherFieldName];\n // if (set) {\n // for (const target of set) target.resetIsLoaded();\n // set.clear();\n // }\n // }\n if (this.#naiveCache.size > 0) {\n for (const target of this.#naiveCache.values()) target.resetIsLoaded();\n this.#naiveCache.clear();\n this.#naiveDirtySets--;\n }\n }\n\n /**\n * Given a `meta+field`, statically find all downstream Reactables, and if any of those\n * Reactables are a) in-memory already, and b) registered themselves as cached,\n * tell them to reset.\n */\n #resetDownstreamReactables(meta: EntityMetadata, fieldName: string): void {\n // These are reactables in other entities that are watching/reacting to this entity/fieldName\n const reactables = meta.reactablesIncludingReadOnlyByField!.get(fieldName);\n if (reactables === undefined) return;\n for (const r of reactables) {\n if (this.#smartDirtySets === 0) return;\n // I.e. we've written to Author.firstName, and this reactable in Book/otherMeta depends on it\n const otherMeta = getMetadata(r.cstr);\n // Find any cache entries for this cstr + name\n const set = this.#smartCache[otherMeta.tagName]?.[r.name];\n if (set?.size > 0) {\n for (const target of set) {\n target.resetIsLoaded();\n // Is this target itself a RF/RR? If so, transitively reset its cache as well.\n const otherMeta = getMetadata(target.entity);\n const otherField = otherMeta.allFields[target.fieldName];\n if (\"derived\" in otherField && otherField.derived) {\n this.#resetDownstreamReactables(otherMeta, otherField.fieldName);\n }\n }\n set.clear();\n this.#smartDirtySets--;\n }\n }\n }\n}\n"],"mappings":";;AA0BA,IAAa,gBAAb,MAA2B;CAIzB,cAAqE,CAAC;CAGtE,8BAAc,IAAI,IAAsB;CAExC,kBAAkB;CAElB,kBAAkB;;CAGlB,IAAI,QAAgC;EAClC,MAAM,OAAO,YAAY,OAAO,MAAM;EACtC,MAAM,MAAO,CAAC,KAAKA,YAAY,KAAK,aAAa,CAAC,EAAA,CAAG,OAAO,+BAAe,IAAI,IAAI;EACnF,IAAI,IAAI,SAAS,GACf,KAAKC;EAEP,IAAI,IAAI,MAAM;CAChB;CAEA,SAAS,QAAgC;EACvC,IAAI,KAAKC,YAAY,SAAS,GAAG,KAAKC;EACtC,KAAKD,YAAY,IAAI,MAAM;CAC7B;;CAGA,cAAc,QAAgB,WAAyB;EACrD,IAAI,KAAKD,oBAAoB,KAAK,KAAKE,oBAAoB,GAAG;EAE9D,IAAI,KAAKF,kBAAkB,GACzB,KAAKG,2BAA2B,YAAY,MAAM,GAAG,SAAS;EAahE,IAAI,KAAKF,YAAY,OAAO,GAAG;GAC7B,KAAK,MAAM,UAAU,KAAKA,YAAY,OAAO,GAAG,OAAO,cAAc;GACrE,KAAKA,YAAY,MAAM;GACvB,KAAKC;EACP;CACF;;;;;;CAOA,2BAA2B,MAAsB,WAAyB;EAExE,MAAM,aAAa,KAAK,mCAAoC,IAAI,SAAS;EACzE,IAAI,eAAe,KAAA,GAAW;EAC9B,KAAK,MAAM,KAAK,YAAY;GAC1B,IAAI,KAAKF,oBAAoB,GAAG;GAEhC,MAAM,YAAY,YAAY,EAAE,IAAI;GAEpC,MAAM,MAAM,KAAKD,YAAY,UAAU,QAAQ,GAAG,EAAE;GACpD,IAAI,KAAK,OAAO,GAAG;IACjB,KAAK,MAAM,UAAU,KAAK;KACxB,OAAO,cAAc;KAErB,MAAM,YAAY,YAAY,OAAO,MAAM;KAC3C,MAAM,aAAa,UAAU,UAAU,OAAO;KAC9C,IAAI,aAAa,cAAc,WAAW,SACxC,KAAKI,2BAA2B,WAAW,WAAW,SAAS;IAEnE;IACA,IAAI,MAAM;IACV,KAAKH;GACP;EACF;CACF;AACF"}
@@ -1,12 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("./typeMap.cjs");
3
- require("./relations/OneToOneReference.cjs");
4
- const require_reactiveHints = require("./reactiveHints.cjs");
5
- require("./normalizeHints.cjs");
6
- const require_utils = require("./utils.cjs");
7
- require("./relations/index.cjs");
8
- require("./Entity.cjs");
9
- //#region src/loadHints.ts
2
+ const require_reactivity_reactiveHints = require("../reactivity/reactiveHints.cjs");
3
+ const require_utils = require("../utils.cjs");
4
+ //#region src/loading/loadHints.ts
10
5
  /** Detects whether an entity is newly created, and so we can treat all the relations as loaded. */
11
6
  function isNew(e) {
12
7
  return e.isNewEntity;
@@ -20,7 +15,7 @@ function isLoaded(entity, hint) {
20
15
  } else if (typeof hint === "object") {
21
16
  for (const entry of Object.entries(hint)) {
22
17
  const [key, nestedHint] = entry;
23
- const relation = require_reactiveHints.getRelationFromMaybePolyKey(entity, key);
18
+ const relation = require_reactivity_reactiveHints.getRelationFromMaybePolyKey(entity, key);
24
19
  if (!relation || typeof relation.load !== "function") continue;
25
20
  if (relation.isLoaded) {
26
21
  const result = relation.get;
@@ -42,7 +37,7 @@ function isLoaded(entity, hint) {
42
37
  */
43
38
  function isLoadedForPopulate(entity, hint) {
44
39
  if (typeof hint === "string") {
45
- const relation = require_reactiveHints.getRelationFromMaybePolyKey(entity, hint);
40
+ const relation = require_reactivity_reactiveHints.getRelationFromMaybePolyKey(entity, hint);
46
41
  return !!relation && typeof relation.load === "function" && relation.isLoaded;
47
42
  } else if (Array.isArray(hint)) {
48
43
  for (const key of hint) if (!isLoadedForPopulate(entity, key)) return false;
@@ -50,7 +45,7 @@ function isLoadedForPopulate(entity, hint) {
50
45
  } else if (typeof hint === "object") {
51
46
  for (const entry of Object.entries(hint)) {
52
47
  const [key, nestedHint] = entry;
53
- const relation = require_reactiveHints.getRelationFromMaybePolyKey(entity, key);
48
+ const relation = require_reactivity_reactiveHints.getRelationFromMaybePolyKey(entity, key);
54
49
  if (!relation || typeof relation.load !== "function" || !relation.isLoaded) return false;
55
50
  const result = relation.get;
56
51
  if (Array.isArray(result)) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadHints.cjs","names":["getRelationFromMaybePolyKey"],"sources":["../../src/loading/loadHints.ts"],"sourcesContent":["import type { Entity } from \"src/Entity.ts\";\nimport type { NormalizeHint } from \"src/normalizeHints.ts\";\nimport { getRelationFromMaybePolyKey } from \"src/reactivity/reactiveHints.ts\";\nimport type {\n AsyncMethod,\n Collection,\n EnumCollection,\n LoadedCollection,\n LoadedEnumCollection,\n LoadedMethod,\n LoadedProperty,\n LoadedReadOnlyCollection,\n LoadedReference,\n OneToOneReference,\n Property,\n ReadOnlyCollection,\n Reference,\n Relation,\n} from \"src/relations/index.ts\";\nimport type { LoadedOneToOneReference } from \"src/relations/OneToOneReference.ts\";\nimport type { OptsOf } from \"src/typeMap.ts\";\nimport { type MaybePromise, type NullOrDefinedOr, fail } from \"src/utils.ts\";\n\nconst deepLoad = Symbol();\ntype DeepLoadHint<T extends Entity> = NestedLoadHint<T> & { [deepLoad]: true };\n\n// Use any to correctly handle subtype/base type load hints.\n//\n// If a load hint is typed as `LoadHint<SmallPublisher, \"authors\">`, but the property\n// is actually `Publisher.authors`, if we do `P extends LoadedCollection<SmallPublisher, ...>`\n// the `SmallPublisher !== Publisher`, so the `authors` property doesn't match, and then\n// we drop the rest of the nested load hint.\n//\n// But if we check `P extends LoadedCollection<any, ...>` it works.\ntype MaybeBaseType = any;\n\n/** Marks a given `T[K]` field as the loaded/synchronous version of the collection. */\nexport type MarkLoaded<T extends Entity, P, UH = {}> =\n P extends EnumCollection<MaybeBaseType, infer E>\n ? LoadedEnumCollection<T, E>\n : P extends OneToOneReference<MaybeBaseType, infer U>\n ? LoadedOneToOneReference<T, Loaded<U, UH>>\n : P extends Reference<MaybeBaseType, infer U, infer N>\n ? LoadedReference<T, Loaded<U, UH>, N>\n : P extends Collection<MaybeBaseType, infer U>\n ? LoadedCollection<T, Loaded<U, UH>>\n : P extends ReadOnlyCollection<MaybeBaseType, infer U>\n ? LoadedReadOnlyCollection<T, Loaded<U, UH>>\n : P extends Property<MaybeBaseType, infer V>\n ? // prettier-ignore\n [V] extends [(infer U extends Entity) | undefined]\n ? LoadedProperty<T, Loaded<U, UH> | Exclude<V, U>>\n : V extends readonly (infer U extends Entity)[]\n ? LoadedProperty<T, Loaded<U, UH>[]>\n : LoadedProperty<T, V>\n : P extends AsyncMethod<T, infer A, infer V>\n ? LoadedMethod<T, A, V>\n : unknown;\n\n/** A version of MarkLoaded the uses `DeepLoadHint` for tests. */\ntype MarkDeepLoaded<T extends Entity, P> =\n P extends EnumCollection<MaybeBaseType, infer E>\n ? LoadedEnumCollection<T, E>\n : P extends OneToOneReference<MaybeBaseType, infer U>\n ? LoadedOneToOneReference<T, Loaded<U, DeepLoadHint<U>>>\n : P extends Reference<MaybeBaseType, infer U, infer N>\n ? LoadedReference<T, Loaded<U, DeepLoadHint<U>>, N>\n : P extends Collection<MaybeBaseType, infer U>\n ? LoadedCollection<T, Loaded<U, DeepLoadHint<U>>>\n : P extends ReadOnlyCollection<MaybeBaseType, infer U>\n ? LoadedReadOnlyCollection<T, Loaded<U, DeepLoadHint<U>>>\n : P extends Property<MaybeBaseType, infer V>\n ? // prettier-ignore\n [V] extends [(infer U extends Entity) | undefined]\n ? LoadedProperty<T, Loaded<U, DeepLoadHint<U>> | Exclude<V, U>>\n : V extends readonly (infer U extends Entity)[]\n ? LoadedProperty<T, Loaded<U, DeepLoadHint<U>>[]>\n : LoadedProperty<T, V>\n : P extends AsyncMethod<T, infer A, infer V>\n ? LoadedMethod<T, A, V>\n : unknown;\n\n/**\n * A helper type for `New` that marks every `Reference` and `LoadedCollection` in `T` as loaded.\n *\n * We also look in opts `O` for the \"`U`\" type, i.e. the next level up/down in the graph,\n * because the call site's opts may be using an also-marked loaded parent/child as an opt,\n * so this will infer the type of that parent/child and use that for the `U` type.\n *\n * This means things like `entity.parent.get.grandParent.get` will work on the resulting\n * type.\n *\n * Note that this is also purposefully broken out of `New` because of some weirdness\n * around type narrowing that wasn't working when inlined into `New`.\n */\ntype MaybeUseOptsType<T extends Entity, O, K extends keyof T & keyof O> =\n O[K] extends NullOrDefinedOr<infer OK>\n ? OK extends Entity\n ? T[K] extends OneToOneReference<T, infer U>\n ? LoadedOneToOneReference<T, U>\n : T[K] extends Reference<T, infer U, infer N>\n ? LoadedReference<T, OK, N>\n : never\n : OK extends Array<infer OU>\n ? OU extends Entity\n ? T[K] extends Collection<T, infer U>\n ? LoadedCollection<T, OU>\n : never\n : T[K]\n : T[K]\n : never;\n\n/**\n * Marks all references/collections of `T` as loaded, i.e. for newly instantiated entities where\n * we know there are no already-existing rows with fk's to this new entity in the database.\n *\n * `O` is the generic from the call site so that if the caller passes `{ author: SomeLoadedAuthor }`,\n * we'll prefer that type, as it might have more nested load hints that we can't otherwise assume.\n */\nexport type New<T extends Entity, O extends OptsOf<T> = OptsOf<T>> = T & {\n // K will be `keyof T` and `keyof O` for codegen'd relations, but custom relations\n // line `hasOneThrough` and `hasOneDerived` will not pass `keyof O` and so use the\n // `: MarkLoaded`.\n //\n // Note that the safest thing is to probably make this `: unknown` instead so that\n // custom relations are not marked loaded, b/c they will very likely require a `.load`\n // to work. However, we have some tests that currently expect `author.image.get` to work\n // on a new author, so keeping the `MarkLoaded` behavior for now.\n [K in keyof T]: K extends keyof O ? MaybeUseOptsType<T, O, K> : MarkLoaded<T, T[K]>;\n};\n\n/**\n * Marks all references/collections of `T` as deeply loaded, which is only useful for\n * tests where we can have \"the whole object graph\" in-memory.\n */\nexport type DeepNew<T extends Entity> = Loaded<T, DeepLoadHint<T>>;\n\n/** Detects whether an entity is newly created, and so we can treat all the relations as loaded. */\nexport function isNew<T extends Entity>(e: T): e is New<T> {\n return e.isNewEntity;\n}\n\n/**\n * All the loadable fields, i.e. relations or lazy-loaded/async properties, in an entity.\n *\n * We use a mapped type (instead of a code-generated type) so that we can pick up custom\n * fields that have be added to the entity classes, i.e. `Author.numberOfBooks2` async\n * properties.\n */\nexport type Loadable<T extends Entity> = {\n -readonly [K in keyof T as LoadableValue<T[K]> extends never ? never : K]: LoadableValue<T[K]>;\n};\n\n/**\n * Given an entity field/value, return the loadable entity.\n *\n * I.e. `Author.books` as a Reference or Collection, return `Book`.\n *\n * Note that we usually return entities, but for AsyncProperties it could be\n * a calculated primitive value like number or string.\n */\nexport type LoadableValue<V> =\n V extends EnumCollection<any, infer E>\n ? E\n : V extends Reference<any, infer U, any>\n ? U\n : V extends Collection<any, infer U>\n ? U\n : V extends ReadOnlyCollection<any, infer U>\n ? U\n : V extends AsyncMethod<any, any, infer V>\n ? V\n : V extends Property<any, infer P>\n ? // If the Property returns `Comment | undefined`, then we want to return `Comment`\n // prettier-ignore\n P extends (infer U extends Entity) | undefined ? U : P\n : never;\n\n/**\n * A load hint of a single key, multiple keys, or nested keys and sub-hints.\n *\n * Load hints are different from reactive hints in that load hints include only references,\n * collections, and async properties to preload (like `Book.author` or `Author.books`), and\n * do not include any primitive fields (like `Author.firstName`).\n */\nexport type LoadHint<T extends Entity> =\n | (keyof Loadable<T> & string)\n | ReadonlyArray<keyof Loadable<T> & string>\n | NestedLoadHint<T>;\n\nexport type NestedLoadHint<T extends Entity> = {\n // Don't filter out entity-loadable keys, because we need to support `{ numberOfBooks2: {} }`\n [K in keyof Loadable<T>]?: Loadable<T>[K] extends infer U extends Entity ? LoadHint<U> : {};\n};\n\n/** Given an entity `T` that is being populated with hints `H`, marks the `H` attributes as populated. */\nexport type Loaded<T extends Entity, H> = T & {\n [K in keyof T & keyof NormalizeHint<H>]: H extends DeepLoadHint<T>\n ? MarkDeepLoaded<T, T[K]>\n : MarkLoaded<T, T[K], NormalizeHint<H>[K]>;\n};\n\n/** Recursively checks if the relations from a load hint are loaded on an entity. */\nexport function isLoaded<T extends Entity, H extends LoadHint<T>>(entity: T, hint: H): entity is Loaded<T, H> {\n if (typeof hint === \"string\") {\n return (entity as any)[hint].isLoaded;\n } else if (Array.isArray(hint)) {\n for (const key of hint as string[]) {\n if (!(entity as any)[key].isLoaded) return false;\n }\n return true;\n } else if (typeof hint === \"object\") {\n for (const entry of Object.entries(hint as object)) {\n const [key, nestedHint] = entry;\n const relation = getRelationFromMaybePolyKey(entity, key);\n if (!relation || typeof relation.load !== \"function\") continue;\n if (relation.isLoaded) {\n const result = relation.get;\n if (Array.isArray(result)) {\n for (const entity of result) {\n if (!isLoaded(entity, nestedHint)) return false;\n }\n } else if (result && !isLoaded(result, nestedHint)) {\n return false;\n }\n } else {\n return false;\n }\n }\n return true;\n } else {\n throw new Error(`Unexpected hint ${hint}`);\n }\n}\n\n/**\n * Recursively checks if a relation-only populate hint is loaded on an entity.\n *\n * Unlike `isLoaded`, this returns `false` for non-loadable/primitive leaves instead of ignoring them, because\n * `ReactiveField.load` calls `em.populate` with load hints converted from reactive hints, i.e. `{ firstName: {} }`.\n * Treating those primitive leaves as loaded would let `EntityManager.populate` skip the batchloader path and change\n * reactive recalculation ordering, so the populate fast-path only applies to true relation populate hints.\n */\nexport function isLoadedForPopulate<T extends Entity, H extends LoadHint<T>>(\n entity: T,\n hint: H,\n): entity is Loaded<T, H> {\n if (typeof hint === \"string\") {\n const relation = getRelationFromMaybePolyKey(entity, hint);\n return !!relation && typeof relation.load === \"function\" && relation.isLoaded;\n } else if (Array.isArray(hint)) {\n for (const key of hint as string[]) {\n if (!isLoadedForPopulate(entity, key as H)) return false;\n }\n return true;\n } else if (typeof hint === \"object\") {\n for (const entry of Object.entries(hint as object)) {\n const [key, nestedHint] = entry;\n const relation = getRelationFromMaybePolyKey(entity, key);\n if (!relation || typeof relation.load !== \"function\" || !relation.isLoaded) return false;\n const result = relation.get;\n if (Array.isArray(result)) {\n for (const entity of result) {\n if (!isLoadedForPopulate(entity, nestedHint as LoadHint<typeof entity>)) return false;\n }\n } else if (result && !isLoadedForPopulate(result, nestedHint as LoadHint<typeof result>)) {\n return false;\n }\n }\n return true;\n } else {\n throw new Error(`Unexpected hint ${hint}`);\n }\n}\n\nexport function maybePopulateThen<T extends Entity, H extends LoadHint<T>, R>(\n entity: T,\n hint: H,\n fn: (loaded: Loaded<T, H>) => R,\n): MaybePromise<R> {\n return isLoaded(entity, hint) ? fn(entity) : (entity as any).populate(hint).then(fn);\n}\n\n/**\n * Runtime checks that `entity` has `hint` loaded, and type guards it as a `Loaded<T, hint>`.\n *\n * Similar to `ensureLoaded`, although `ensureLoaded` returns its value.\n */\nexport function assertLoaded<T extends Entity, const H extends LoadHint<T>>(\n entity: T,\n hint: H,\n): asserts entity is Loaded<T, H> {\n if (!isLoaded(entity, hint)) fail(`${entity.id} is not loaded for ${JSON.stringify(hint)}`);\n}\n\n/**\n * Runtime checks that `entity` has `hint` loaded, and returns it as a `Loaded<T, entity>`.\n *\n * Similar to `assertLoaded`, although `assertLoaded` is a boolean type guard.\n */\nexport function ensureLoaded<T extends Entity, const H extends LoadHint<T>>(entity: T, hint: H): Loaded<T, H> {\n assertLoaded<T, H>(entity, hint);\n return entity;\n}\n\n/**\n * Unsafe type check for `entity` to `hint`, *without* a runtime type check.\n *\n * You should only use this if you're extremely sure that entity has hint loaded.\n */\nexport function unsafeLoaded<T extends Entity, const H extends LoadHint<T>>(entity: T, hint: H): Loaded<T, H> {\n return entity as Loaded<T, H>;\n}\n\n/** From any `Relations` field in `T`, i.e. for loader hints. */\nexport type RelationsIn<T extends Entity> = SubType<T, Relation<any, any>>;\n\n// https://medium.com/dailyjs/typescript-create-a-condition-based-subset-types-9d902cea5b8c\ntype SubType<T, C> = Pick<T, { [K in keyof T]: T[K] extends C ? K : never }[keyof T]>;\n"],"mappings":";;;;;AA0IA,SAAgB,MAAwB,GAAmB;CACzD,OAAO,EAAE;AACX;;AA+DA,SAAgB,SAAkD,QAAW,MAAiC;CAC5G,IAAI,OAAO,SAAS,UAClB,OAAQ,OAAe,KAAK,CAAC;MACxB,IAAI,MAAM,QAAQ,IAAI,GAAG;EAC9B,KAAK,MAAM,OAAO,MAChB,IAAI,CAAE,OAAe,IAAI,CAAC,UAAU,OAAO;EAE7C,OAAO;CACT,OAAO,IAAI,OAAO,SAAS,UAAU;EACnC,KAAK,MAAM,SAAS,OAAO,QAAQ,IAAc,GAAG;GAClD,MAAM,CAAC,KAAK,cAAc;GAC1B,MAAM,WAAWA,iCAAAA,4BAA4B,QAAQ,GAAG;GACxD,IAAI,CAAC,YAAY,OAAO,SAAS,SAAS,YAAY;GACtD,IAAI,SAAS,UAAU;IACrB,MAAM,SAAS,SAAS;IACxB,IAAI,MAAM,QAAQ,MAAM,GACjB;UAAA,MAAM,UAAU,QACnB,IAAI,CAAC,SAAS,QAAQ,UAAU,GAAG,OAAO;IAAA,OAEvC,IAAI,UAAU,CAAC,SAAS,QAAQ,UAAU,GAC/C,OAAO;GAEX,OACE,OAAO;EAEX;EACA,OAAO;CACT,OACE,MAAM,IAAI,MAAM,mBAAmB,MAAM;AAE7C;;;;;;;;;AAUA,SAAgB,oBACd,QACA,MACwB;CACxB,IAAI,OAAO,SAA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";
2
- import { NormalizeHint } from "./normalizeHints.cjs";
3
- import { Collection, LoadedCollection } from "./relations/Collection.cjs";
4
- import { EnumCollection, LoadedEnumCollection } from "./relations/EnumCollection.cjs";
5
- import { AsyncMethod, LoadedMethod } from "./relations/hasAsyncMethod.cjs";
6
- import { LoadedProperty, Property } from "./relations/hasProperty.cjs";
7
- import { LoadedReference, Reference } from "./relations/Reference.cjs";
8
- import { Relation } from "./relations/Relation.cjs";
9
- import { LoadedOneToOneReference, OneToOneReference } from "./relations/OneToOneReference.cjs";
10
- import { LoadedReadOnlyCollection, ReadOnlyCollection } from "./relations/ReadOnlyCollection.cjs";
11
- import "./relations/index.cjs";
12
- import { MaybePromise, NullOrDefinedOr } from "./utils.cjs";
13
- import { Entity } from "./Entity.cjs";
14
- //#region src/loadHints.d.ts
1
+ import { OptsOf } from "../typeMap.cjs";
2
+ import { NormalizeHint } from "../normalizeHints.cjs";
3
+ import { Collection, LoadedCollection } from "../relations/Collection.cjs";
4
+ import { EnumCollection, LoadedEnumCollection } from "../relations/EnumCollection.cjs";
5
+ import { AsyncMethod, LoadedMethod } from "../relations/hasAsyncMethod.cjs";
6
+ import { LoadedProperty, Property } from "../relations/hasProperty.cjs";
7
+ import { LoadedReference, Reference } from "../relations/Reference.cjs";
8
+ import { Relation } from "../relations/Relation.cjs";
9
+ import { LoadedOneToOneReference, OneToOneReference } from "../relations/OneToOneReference.cjs";
10
+ import { LoadedReadOnlyCollection, ReadOnlyCollection } from "../relations/ReadOnlyCollection.cjs";
11
+ import "../relations/index.cjs";
12
+ import { MaybePromise, NullOrDefinedOr } from "../utils.cjs";
13
+ import { Entity } from "../Entity.cjs";
14
+ //#region src/loading/loadHints.d.ts
15
15
  declare const deepLoad: unique symbol;
16
16
  type DeepLoadHint<T extends Entity> = NestedLoadHint<T> & {
17
17
  [deepLoad]: true;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadHints.d.cts","names":[],"sources":["../../src/loading/loadHints.ts"],"mappings":";;;;;;;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;;;;;iBAwC3F,oBAAoB,UAAU,QAAQ,UAAU,SAAS,IACvE,QAAQ,GACR,MAAM,IACL,UAAU,OAAO,GAAG;iBA6BP,kBAAkB,UAAU,QAAQ,UAAU,SAAS,IAAI,GACzE,QAAQ,GACR,MAAM,GACN,KAAK,QAAQ,OAAO,GAAG,OAAO,IAC7B,aAAa;;;;;;iBASA,aAAa,UAAU,cAAc,UAAU,SAAS,IACtE,QAAQ,GACR,MAAM,YACG,UAAU,OAAO,GAAG;;;;;;iBASf,aAAa,UAAU,cAAc,UAAU,SAAS,IAAI,QAAQ,GAAG,MAAM,IAAI,OAAO,GAAG;;;;;;iBAU3F,aAAa,UAAU,cAAc,UAAU,SAAS,IAAI,QAAQ,GAAG,MAAM,IAAI,OAAO,GAAG;;KAK/F,YAAY,UAAU,UAAU,QAAQ,GAAG;KAGlD,QAAQ,GAAG,KAAK,KAAK,MAAM,WAAW,IAAI,EAAE,WAAW,IAAI,mBAAkB"}
@@ -1,17 +1,17 @@
1
- import { OptsOf } from "./typeMap.mjs";
2
- import { NormalizeHint } from "./normalizeHints.mjs";
3
- import { Collection, LoadedCollection } from "./relations/Collection.mjs";
4
- import { EnumCollection, LoadedEnumCollection } from "./relations/EnumCollection.mjs";
5
- import { AsyncMethod, LoadedMethod } from "./relations/hasAsyncMethod.mjs";
6
- import { LoadedProperty, Property } from "./relations/hasProperty.mjs";
7
- import { LoadedReference, Reference } from "./relations/Reference.mjs";
8
- import { Relation } from "./relations/Relation.mjs";
9
- import { LoadedOneToOneReference, OneToOneReference } from "./relations/OneToOneReference.mjs";
10
- import { LoadedReadOnlyCollection, ReadOnlyCollection } from "./relations/ReadOnlyCollection.mjs";
11
- import "./relations/index.mjs";
12
- import { MaybePromise, NullOrDefinedOr } from "./utils.mjs";
13
- import { Entity } from "./Entity.mjs";
14
- //#region src/loadHints.d.ts
1
+ import { OptsOf } from "../typeMap.mjs";
2
+ import { NormalizeHint } from "../normalizeHints.mjs";
3
+ import { Collection, LoadedCollection } from "../relations/Collection.mjs";
4
+ import { EnumCollection, LoadedEnumCollection } from "../relations/EnumCollection.mjs";
5
+ import { AsyncMethod, LoadedMethod } from "../relations/hasAsyncMethod.mjs";
6
+ import { LoadedProperty, Property } from "../relations/hasProperty.mjs";
7
+ import { LoadedReference, Reference } from "../relations/Reference.mjs";
8
+ import { Relation } from "../relations/Relation.mjs";
9
+ import { LoadedOneToOneReference, OneToOneReference } from "../relations/OneToOneReference.mjs";
10
+ import { LoadedReadOnlyCollection, ReadOnlyCollection } from "../relations/ReadOnlyCollection.mjs";
11
+ import "../relations/index.mjs";
12
+ import { MaybePromise, NullOrDefinedOr } from "../utils.mjs";
13
+ import { Entity } from "../Entity.mjs";
14
+ //#region src/loading/loadHints.d.ts
15
15
  declare const deepLoad: unique symbol;
16
16
  type DeepLoadHint<T extends Entity> = NestedLoadHint<T> & {
17
17
  [deepLoad]: true;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadHints.d.mts","names":[],"sources":["../../src/loading/loadHints.ts"],"mappings":";;;;;;;;;;;;;;cAuBM;KACD,aAAa,UAAU,UAAU,eAAe;GAAQ;;KAUxD;;KAGO,WAAW,UAAU,QAAQ,GAAG,WAC1C,UAAU,eAAe,qBAAqB,KAC1C,qBAAqB,GAAG,KACxB,UAAU,kBAAkB,qBAAqB,KAC/C,wBAAwB,GAAG,OAAO,GAAG,OACrC,UAAU,UAAU,qBAAqB,SAAS,KAChD,gBAAgB,GAAG,OAAO,GAAG,KAAK,KAClC,UAAU,WAAW,qBAAqB,KACxC,iBAAiB,GAAG,OAAO,GAAG,OAC9B,UAAU,mBAAmB,qBAAqB,KAChD,yBAAyB,GAAG,OAAO,GAAG,OACtC,UAAU,SAAS,qBAAqB,MAErC,mBAAmB,UAAU,uBACxC,eAAe,GAAG,OAAO,GAAG,MAAM,QAAQ,GAAG,MAC7C,0BAA0B,UAAU,YACpC,eAAe,GAAG,OAAO,GAAG,SAC5B,eAAe,GAAG,KACR,UAAU,YAAY,SAAS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,mBAAkB"}
@@ -1,11 +1,6 @@
1
- import "./typeMap.js";
2
- import "./relations/OneToOneReference.js";
3
- import { getRelationFromMaybePolyKey } from "./reactiveHints.js";
4
- import "./normalizeHints.js";
5
- import { fail } from "./utils.js";
6
- import "./relations/index.js";
7
- import "./Entity.js";
8
- //#region src/loadHints.ts
1
+ import { getRelationFromMaybePolyKey } from "../reactivity/reactiveHints.js";
2
+ import { fail } from "../utils.js";
3
+ //#region src/loading/loadHints.ts
9
4
  /** Detects whether an entity is newly created, and so we can treat all the relations as loaded. */
10
5
  function isNew(e) {
11
6
  return e.isNewEntity;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadHints.js","names":[],"sources":["../../src/loading/loadHints.ts"],"sourcesContent":["import type { Entity } from \"src/Entity.ts\";\nimport type { NormalizeHint } from \"src/normalizeHints.ts\";\nimport { getRelationFromMaybePolyKey } from \"src/reactivity/reactiveHints.ts\";\nimport type {\n AsyncMethod,\n Collection,\n EnumCollection,\n LoadedCollection,\n LoadedEnumCollection,\n LoadedMethod,\n LoadedProperty,\n LoadedReadOnlyCollection,\n LoadedReference,\n OneToOneReference,\n Property,\n ReadOnlyCollection,\n Reference,\n Relation,\n} from \"src/relations/index.ts\";\nimport type { LoadedOneToOneReference } from \"src/relations/OneToOneReference.ts\";\nimport type { OptsOf } from \"src/typeMap.ts\";\nimport { type MaybePromise, type NullOrDefinedOr, fail } from \"src/utils.ts\";\n\nconst deepLoad = Symbol();\ntype DeepLoadHint<T extends Entity> = NestedLoadHint<T> & { [deepLoad]: true };\n\n// Use any to correctly handle subtype/base type load hints.\n//\n// If a load hint is typed as `LoadHint<SmallPublisher, \"authors\">`, but the property\n// is actually `Publisher.authors`, if we do `P extends LoadedCollection<SmallPublisher, ...>`\n// the `SmallPublisher !== Publisher`, so the `authors` property doesn't match, and then\n// we drop the rest of the nested load hint.\n//\n// But if we check `P extends LoadedCollection<any, ...>` it works.\ntype MaybeBaseType = any;\n\n/** Marks a given `T[K]` field as the loaded/synchronous version of the collection. */\nexport type MarkLoaded<T extends Entity, P, UH = {}> =\n P extends EnumCollection<MaybeBaseType, infer E>\n ? LoadedEnumCollection<T, E>\n : P extends OneToOneReference<MaybeBaseType, infer U>\n ? LoadedOneToOneReference<T, Loaded<U, UH>>\n : P extends Reference<MaybeBaseType, infer U, infer N>\n ? LoadedReference<T, Loaded<U, UH>, N>\n : P extends Collection<MaybeBaseType, infer U>\n ? LoadedCollection<T, Loaded<U, UH>>\n : P extends ReadOnlyCollection<MaybeBaseType, infer U>\n ? LoadedReadOnlyCollection<T, Loaded<U, UH>>\n : P extends Property<MaybeBaseType, infer V>\n ? // prettier-ignore\n [V] extends [(infer U extends Entity) | undefined]\n ? LoadedProperty<T, Loaded<U, UH> | Exclude<V, U>>\n : V extends readonly (infer U extends Entity)[]\n ? LoadedProperty<T, Loaded<U, UH>[]>\n : LoadedProperty<T, V>\n : P extends AsyncMethod<T, infer A, infer V>\n ? LoadedMethod<T, A, V>\n : unknown;\n\n/** A version of MarkLoaded the uses `DeepLoadHint` for tests. */\ntype MarkDeepLoaded<T extends Entity, P> =\n P extends EnumCollection<MaybeBaseType, infer E>\n ? LoadedEnumCollection<T, E>\n : P extends OneToOneReference<MaybeBaseType, infer U>\n ? LoadedOneToOneReference<T, Loaded<U, DeepLoadHint<U>>>\n : P extends Reference<MaybeBaseType, infer U, infer N>\n ? LoadedReference<T, Loaded<U, DeepLoadHint<U>>, N>\n : P extends Collection<MaybeBaseType, infer U>\n ? LoadedCollection<T, Loaded<U, DeepLoadHint<U>>>\n : P extends ReadOnlyCollection<MaybeBaseType, infer U>\n ? LoadedReadOnlyCollection<T, Loaded<U, DeepLoadHint<U>>>\n : P extends Property<MaybeBaseType, infer V>\n ? // prettier-ignore\n [V] extends [(infer U extends Entity) | undefined]\n ? LoadedProperty<T, Loaded<U, DeepLoadHint<U>> | Exclude<V, U>>\n : V extends readonly (infer U extends Entity)[]\n ? LoadedProperty<T, Loaded<U, DeepLoadHint<U>>[]>\n : LoadedProperty<T, V>\n : P extends AsyncMethod<T, infer A, infer V>\n ? LoadedMethod<T, A, V>\n : unknown;\n\n/**\n * A helper type for `New` that marks every `Reference` and `LoadedCollection` in `T` as loaded.\n *\n * We also look in opts `O` for the \"`U`\" type, i.e. the next level up/down in the graph,\n * because the call site's opts may be using an also-marked loaded parent/child as an opt,\n * so this will infer the type of that parent/child and use that for the `U` type.\n *\n * This means things like `entity.parent.get.grandParent.get` will work on the resulting\n * type.\n *\n * Note that this is also purposefully broken out of `New` because of some weirdness\n * around type narrowing that wasn't working when inlined into `New`.\n */\ntype MaybeUseOptsType<T extends Entity, O, K extends keyof T & keyof O> =\n O[K] extends NullOrDefinedOr<infer OK>\n ? OK extends Entity\n ? T[K] extends OneToOneReference<T, infer U>\n ? LoadedOneToOneReference<T, U>\n : T[K] extends Reference<T, infer U, infer N>\n ? LoadedReference<T, OK, N>\n : never\n : OK extends Array<infer OU>\n ? OU extends Entity\n ? T[K] extends Collection<T, infer U>\n ? LoadedCollection<T, OU>\n : never\n : T[K]\n : T[K]\n : never;\n\n/**\n * Marks all references/collections of `T` as loaded, i.e. for newly instantiated entities where\n * we know there are no already-existing rows with fk's to this new entity in the database.\n *\n * `O` is the generic from the call site so that if the caller passes `{ author: SomeLoadedAuthor }`,\n * we'll prefer that type, as it might have more nested load hints that we can't otherwise assume.\n */\nexport type New<T extends Entity, O extends OptsOf<T> = OptsOf<T>> = T & {\n // K will be `keyof T` and `keyof O` for codegen'd relations, but custom relations\n // line `hasOneThrough` and `hasOneDerived` will not pass `keyof O` and so use the\n // `: MarkLoaded`.\n //\n // Note that the safest thing is to probably make this `: unknown` instead so that\n // custom relations are not marked loaded, b/c they will very likely require a `.load`\n // to work. However, we have some tests that currently expect `author.image.get` to work\n // on a new author, so keeping the `MarkLoaded` behavior for now.\n [K in keyof T]: K extends keyof O ? MaybeUseOptsType<T, O, K> : MarkLoaded<T, T[K]>;\n};\n\n/**\n * Marks all references/collections of `T` as deeply loaded, which is only useful for\n * tests where we can have \"the whole object graph\" in-memory.\n */\nexport type DeepNew<T extends Entity> = Loaded<T, DeepLoadHint<T>>;\n\n/** Detects whether an entity is newly created, and so we can treat all the relations as loaded. */\nexport function isNew<T extends Entity>(e: T): e is New<T> {\n return e.isNewEntity;\n}\n\n/**\n * All the loadable fields, i.e. relations or lazy-loaded/async properties, in an entity.\n *\n * We use a mapped type (instead of a code-generated type) so that we can pick up custom\n * fields that have be added to the entity classes, i.e. `Author.numberOfBooks2` async\n * properties.\n */\nexport type Loadable<T extends Entity> = {\n -readonly [K in keyof T as LoadableValue<T[K]> extends never ? never : K]: LoadableValue<T[K]>;\n};\n\n/**\n * Given an entity field/value, return the loadable entity.\n *\n * I.e. `Author.books` as a Reference or Collection, return `Book`.\n *\n * Note that we usually return entities, but for AsyncProperties it could be\n * a calculated primitive value like number or string.\n */\nexport type LoadableValue<V> =\n V extends EnumCollection<any, infer E>\n ? E\n : V extends Reference<any, infer U, any>\n ? U\n : V extends Collection<any, infer U>\n ? U\n : V extends ReadOnlyCollection<any, infer U>\n ? U\n : V extends AsyncMethod<any, any, infer V>\n ? V\n : V extends Property<any, infer P>\n ? // If the Property returns `Comment | undefined`, then we want to return `Comment`\n // prettier-ignore\n P extends (infer U extends Entity) | undefined ? U : P\n : never;\n\n/**\n * A load hint of a single key, multiple keys, or nested keys and sub-hints.\n *\n * Load hints are different from reactive hints in that load hints include only references,\n * collections, and async properties to preload (like `Book.author` or `Author.books`), and\n * do not include any primitive fields (like `Author.firstName`).\n */\nexport type LoadHint<T extends Entity> =\n | (keyof Loadable<T> & string)\n | ReadonlyArray<keyof Loadable<T> & string>\n | NestedLoadHint<T>;\n\nexport type NestedLoadHint<T extends Entity> = {\n // Don't filter out entity-loadable keys, because we need to support `{ numberOfBooks2: {} }`\n [K in keyof Loadable<T>]?: Loadable<T>[K] extends infer U extends Entity ? LoadHint<U> : {};\n};\n\n/** Given an entity `T` that is being populated with hints `H`, marks the `H` attributes as populated. */\nexport type Loaded<T extends Entity, H> = T & {\n [K in keyof T & keyof NormalizeHint<H>]: H extends DeepLoadHint<T>\n ? MarkDeepLoaded<T, T[K]>\n : MarkLoaded<T, T[K], NormalizeHint<H>[K]>;\n};\n\n/** Recursively checks if the relations from a load hint are loaded on an entity. */\nexport function isLoaded<T extends Entity, H extends LoadHint<T>>(entity: T, hint: H): entity is Loaded<T, H> {\n if (typeof hint === \"string\") {\n return (entity as any)[hint].isLoaded;\n } else if (Array.isArray(hint)) {\n for (const key of hint as string[]) {\n if (!(entity as any)[key].isLoaded) return false;\n }\n return true;\n } else if (typeof hint === \"object\") {\n for (const entry of Object.entries(hint as object)) {\n const [key, nestedHint] = entry;\n const relation = getRelationFromMaybePolyKey(entity, key);\n if (!relation || typeof relation.load !== \"function\") continue;\n if (relation.isLoaded) {\n const result = relation.get;\n if (Array.isArray(result)) {\n for (const entity of result) {\n if (!isLoaded(entity, nestedHint)) return false;\n }\n } else if (result && !isLoaded(result, nestedHint)) {\n return false;\n }\n } else {\n return false;\n }\n }\n return true;\n } else {\n throw new Error(`Unexpected hint ${hint}`);\n }\n}\n\n/**\n * Recursively checks if a relation-only populate hint is loaded on an entity.\n *\n * Unlike `isLoaded`, this returns `false` for non-loadable/primitive leaves instead of ignoring them, because\n * `ReactiveField.load` calls `em.populate` with load hints converted from reactive hints, i.e. `{ firstName: {} }`.\n * Treating those primitive leaves as loaded would let `EntityManager.populate` skip the batchloader path and change\n * reactive recalculation ordering, so the populate fast-path only applies to true relation populate hints.\n */\nexport function isLoadedForPopulate<T extends Entity, H extends LoadHint<T>>(\n entity: T,\n hint: H,\n): entity is Loaded<T, H> {\n if (typeof hint === \"string\") {\n const relation = getRelationFromMaybePolyKey(entity, hint);\n return !!relation && typeof relation.load === \"function\" && relation.isLoaded;\n } else if (Array.isArray(hint)) {\n for (const key of hint as string[]) {\n if (!isLoadedForPopulate(entity, key as H)) return false;\n }\n return true;\n } else if (typeof hint === \"object\") {\n for (const entry of Object.entries(hint as object)) {\n const [key, nestedHint] = entry;\n const relation = getRelationFromMaybePolyKey(entity, key);\n if (!relation || typeof relation.load !== \"function\" || !relation.isLoaded) return false;\n const result = relation.get;\n if (Array.isArray(result)) {\n for (const entity of result) {\n if (!isLoadedForPopulate(entity, nestedHint as LoadHint<typeof entity>)) return false;\n }\n } else if (result && !isLoadedForPopulate(result, nestedHint as LoadHint<typeof result>)) {\n return false;\n }\n }\n return true;\n } else {\n throw new Error(`Unexpected hint ${hint}`);\n }\n}\n\nexport function maybePopulateThen<T extends Entity, H extends LoadHint<T>, R>(\n entity: T,\n hint: H,\n fn: (loaded: Loaded<T, H>) => R,\n): MaybePromise<R> {\n return isLoaded(entity, hint) ? fn(entity) : (entity as any).populate(hint).then(fn);\n}\n\n/**\n * Runtime checks that `entity` has `hint` loaded, and type guards it as a `Loaded<T, hint>`.\n *\n * Similar to `ensureLoaded`, although `ensureLoaded` returns its value.\n */\nexport function assertLoaded<T extends Entity, const H extends LoadHint<T>>(\n entity: T,\n hint: H,\n): asserts entity is Loaded<T, H> {\n if (!isLoaded(entity, hint)) fail(`${entity.id} is not loaded for ${JSON.stringify(hint)}`);\n}\n\n/**\n * Runtime checks that `entity` has `hint` loaded, and returns it as a `Loaded<T, entity>`.\n *\n * Similar to `assertLoaded`, although `assertLoaded` is a boolean type guard.\n */\nexport function ensureLoaded<T extends Entity, const H extends LoadHint<T>>(entity: T, hint: H): Loaded<T, H> {\n assertLoaded<T, H>(entity, hint);\n return entity;\n}\n\n/**\n * Unsafe type check for `entity` to `hint`, *without* a runtime type check.\n *\n * You should only use this if you're extremely sure that entity has hint loaded.\n */\nexport function unsafeLoaded<T extends Entity, const H extends LoadHint<T>>(entity: T, hint: H): Loaded<T, H> {\n return entity as Loaded<T, H>;\n}\n\n/** From any `Relations` field in `T`, i.e. for loader hints. */\nexport type RelationsIn<T extends Entity> = SubType<T, Relation<any, any>>;\n\n// https://medium.com/dailyjs/typescript-create-a-condition-based-subset-types-9d902cea5b8c\ntype SubType<T, C> = Pick<T, {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AK,cAAc;GAC1B,MAAM,WAAW,4BAA4B,QAAQ,GAAG;GACxD,IAAI,CAAC,YAAY,OAAO,SAAS,SAAS,cAAc,CAAC,SAAS,UAAU,OAAO;GACnF,MAAM,SAAS,SAAS;GACxB,IAAI,MAAM,QAAQ,MAAM,GACjB;SAAA,MAAM,UAAU,QACnB,IAAI,CAAC,oBAAoB,QAAQ,UAAqC,GAAG,OAAO;GAAA,OAE7E,IAAI,UAAU,CAAC,oBAAoB,QAAQ,UAAqC,GACrF,OAAO;EAEX;EACA,OAAO;CACT,OACE,MAAM,IAAI,MAAM,mBAAmB,MAAM;AAE7C;AAEA,SAAgB,kBACd,QACA,MACA,IACiB;CACjB,OAAO,SAAS,QAAQ,IAAI,IAAI,GAAG,MAAM,IAAK,OAAe,SAAS,IAAI,CAAC,CAAC,KAAK,EAAE;AACrF;;;;;;AAOA,SAAgB,aACd,QACA,MACgC;CAChC,IAAI,CAAC,SAAS,QAAQ,IAAI,GAAG,KAAK,GAAG,OAAO,GAAG,qBAAqB,KAAK,UAAU,IAAI,GAAG;AAC5F;;;;;;AAOA,SAAgB,aAA4D,QAAW,MAAuB;CAC5G,aAAmB,QAAQ,IAAI;CAC/B,OAAO;AACT;;;;;;AAOA,SAAgB,aAA4D,QAAW,MAAuB;CAC5G,OAAO;AACT"}
@@ -1,13 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_relations_AbstractRelationImpl = require("./relations/AbstractRelationImpl.cjs");
3
- const require_relations_hasProperty = require("./relations/hasProperty.cjs");
4
- require("./loadHints.cjs");
5
- require("./relations/index.cjs");
6
- const require_EntityMetadata = require("./EntityMetadata.cjs");
7
- const require_dataloaders_lensDataLoader = require("./dataloaders/lensDataLoader.cjs");
8
- const require_EntityManager = require("./EntityManager.cjs");
9
- const require_Entity = require("./Entity.cjs");
10
- //#region src/loadLens.ts
2
+ const require_relations_AbstractRelationImpl = require("../relations/AbstractRelationImpl.cjs");
3
+ const require_relations_hasProperty = require("../relations/hasProperty.cjs");
4
+ require("../relations/index.cjs");
5
+ const require_EntityMetadata = require("../EntityMetadata.cjs");
6
+ const require_dataloaders_lensDataLoader = require("../dataloaders/lensDataLoader.cjs");
7
+ const require_EntityManager = require("../EntityManager.cjs");
8
+ const require_Entity = require("../Entity.cjs");
9
+ //#region src/loading/loadLens.ts
11
10
  /**
12
11
  * Allows declaratively loading/traversing several layers of references at once.
13
12
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadLens.cjs","names":["isEntity","getMetadata","lensDataLoader","appendStack","AbstractRelationImpl","isProperty"],"sources":["../../src/loading/loadLens.ts"],"sourcesContent":["import { lensDataLoader } from \"src/dataloaders/lensDataLoader.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { appendStack } from \"src/EntityManager.ts\";\nimport {\n type EntityMetadata,\n type Field,\n type ManyToManyField,\n type ManyToOneField,\n type OneToManyField,\n type OneToOneField,\n type PrimitiveField,\n getMetadata,\n} from \"src/EntityMetadata.ts\";\nimport type { LoadHint } from \"src/loading/loadHints.ts\";\nimport { AbstractRelationImpl } from \"src/relations/AbstractRelationImpl.ts\";\nimport { isProperty } from \"src/relations/index.ts\";\n\n/** Generically matches on a Reference/Collection's load method. */\ntype LoadLike<U> = { load(): Promise<U> };\n\n/** Generically matches a property or zero-arg method that returns a promise. */\ntype PromiseFnLike<U> = () => PromiseLike<U>;\n\n/**\n * Given a parent type `R` (that is our current lens \"return type\", i.e. `Author` or `Author | undefined` or `Author[]`),\n * and the type `V` of the \"next step\" of the traversal (i.e. itself `Book` or `Book | undefined` or `Book[]`, depending\n * on the relation being traversed), returns `V` mapped to \"the right format\" based on `R`.\n *\n * I.e.:\n *\n * - `Author | undefined` that navigates a `Book` will become `Book | undefined`\n * - `Author` that navigates a `Book | undefined` will also become `Book | undefined`\n * - `Author[]` that navigates a `Book | undefined` will become a `Book[]`\n * - `Author | undefined` that navigates a `Book[]` will become a `Book[]`\n */\n// The extra `[]` around `V` and `ReadonlyArray<any>` are to keep the type as `Array<Foo | undefined>`\n// instead of `Foo[] | undefined[]`.\n// When `P extends ReadonlyArray, i.e. we're in flatMap mode, we're also in filter undefined mode.\ntype MaybeArray<R, V> =\n R extends ReadonlyArray<any>\n ? [V] extends [ReadonlyArray<infer U>]\n ? DropUndefined<U>[]\n : DropUndefined<V>[]\n : V extends ReadonlyArray<any>\n ? V\n : [R] extends [undefined]\n ? V | undefined\n : V;\n\n// ([R] extends [undefined]) ? (V) : V;\n\n/** Given a type T that we come across in the path, de-array it to continue our flatMap-ish semantics. */\ntype MaybeDropArray<T> = T extends ReadonlyArray<infer U> ? U : T;\n\ntype DropUndefined<T> = Exclude<T, undefined>;\n\n/**\n * A type for declaratively walking the object graph.\n *\n * This is not technically a Lens that can `get/set`, but the idea is generally the same.\n *\n * `T` is the type we're on, i.e. when `T = Author` we can do `.firstName` or `.lastName.\n * `R` is either a `T` or `T[]` or `T | undefined` and just captures whether we've hit a\n * list at any point in the lens navigation path.\n */\nexport type Lens<T, R = T> = {\n [P in keyof T]: T[P] extends LoadLike<infer U>\n ? Lens<MaybeDropArray<DropUndefined<U>>, MaybeArray<R, U>>\n : T[P] extends PromiseFnLike<infer U>\n ? Lens<MaybeDropArray<DropUndefined<U>>, MaybeArray<R, U>>\n : Lens<MaybeDropArray<DropUndefined<T[P]>>, MaybeArray<R, T[P]>>;\n};\n\n/**\n * Allows declaratively loading/traversing several layers of references at once.\n *\n * I.e.:\n *\n * ```typescript\n * const publisher = await book.load(b => b.author.publisher);\n * ```\n */\n// For some reason accepting Lens<this, this> does not work when called from within the entity\n// subclass itself, so we use the codegen hammer in our subclass to force the right Lens type\n// in a .load stub that just calls us for the implementation.\nexport async function loadLens<T extends Entity, U, V>(\n start: T | readonly T[],\n fn: (lens: Lens<T>) => Lens<U, V>,\n opts: { forceReload?: boolean; sql?: boolean } = {},\n): Promise<V> {\n return loadLensPath(start, collectPaths(fn), opts);\n}\n\n/** Loads a precomputed lens path, avoiding repeated lambda/proxy evaluation for long-lived relation declarations. */\nexport function loadLensPath<T extends Entity, V>(\n start: T | readonly T[],\n paths: string[],\n opts: { forceReload?: boolean; sql?: boolean } = {},\n): Promise<V> {\n // Probe for the meta, so we can track when/if it needs to flip to a collection (even after hitting undefined)\n const meta = Array.isArray(start)\n ? isEntity(start[0]) && getMetadata(start[0])\n : isEntity(start) && getMetadata(start);\n // This should only happen for `start=[]`, which we know should return `[]`\n if (!meta) return [] as unknown as Promise<V>;\n\n // If we're already loaded, just return\n if (!opts.forceReload && isLensLoadedPath(start, paths)) {\n // Keep this synchronous to avoid adding a promise turn; this preserves nuanced hook timing in production code.\n return getLensPath(meta, start, paths) as Promise<V>;\n }\n\n return loadLensPathAsync(meta, start, paths, opts);\n}\n\n/**\n * Loads an unloaded lens path, keeping the already-loaded shortcut in `loadLensPath` synchronous.\n *\n * I.e. this avoids adding an extra promise turn for already-loaded paths during concurrent hooks.\n */\nasync function loadLensPathAsync<T extends Entity, V>(\n meta: EntityMetadata,\n start: T | readonly T[],\n paths: string[],\n opts: { forceReload?: boolean; sql?: boolean },\n): Promise<V> {\n // See if we can load this via SQL\n if (opts.sql) {\n // Are all paths SQL query-able?\n if (!isAllSqlPaths(meta, paths)) {\n throw new Error(\"Cannot use loadLens opts.sql with non-SQL paths\");\n }\n // If there is only 1 path, don't both with the fancy join\n if (paths.length > 1) {\n // TODO We can only do this is _none_ of the paths are loaded, otherwise we'll miss WIP mutations\n if (isReadOnlyArray(start)) {\n const em = start[0].em;\n return (await lensDataLoader(em, meta.cstr, true, paths)\n .loadMany(start.map((e) => e.idTagged))\n .catch(function loadLens(err) {\n throw appendStack(err, new Error());\n })) as V;\n } else {\n const em = start.em;\n return (await lensDataLoader(em, meta.cstr, false, paths)\n .load(start.idTagged)\n .catch(function loadLens(err) {\n throw appendStack(err, new Error());\n })) as V;\n }\n }\n }\n\n // This could be `Entity | Entity[] | undefined` as we keep walking\n let current: any = start;\n let currentMeta: EntityMetadata | undefined = meta;\n let seenSoftDeleted = false;\n // Now evaluate each step of the path\n for (const path of paths) {\n const field = currentMeta?.allFields[path] as\n | ManyToOneField\n | ManyToManyField\n | OneToManyField\n | OneToOneField\n | PrimitiveField\n | undefined;\n if (Array.isArray(current)) {\n current = (await Promise.all(current.map((c) => maybeLoad(c, path, opts)))).flat();\n current = [...new Set(current.filter((c: any) => c !== undefined && !c.isSoftDeletedEntity))];\n // As soon as we hit `current=[]`, we can early return (...`current=undefined` cannot b/c the next path might flip to a list)\n if (current.length === 0) return current!;\n } else if (current) {\n current = await maybeLoad(current, path, opts);\n seenSoftDeleted ||= (current as any)?.isSoftDeletedEntity;\n // If we had been traversing m2o -> m2o (i.e. book -> author) and just hit an o2m/m2m (i.e.\n // book -> author -> comments), and any of our prior m2os like `author` had been soft deleted,\n // just filter everything out.\n //\n // Otherwise, we keep `book -> author`, even if author is soft-deleted, b/c it changes the return\n // type from \"author\" to \"author | undefined\".\n if (Array.isArray(current) && seenSoftDeleted) {\n return [] as any;\n }\n } else {\n // current is undefined; see if we should flip to a list ... which means we can early return\n if (field?.kind === \"o2m\" || field?.kind === \"m2m\") return [] as any;\n }\n currentMeta = nextMeta(current, field);\n }\n return current!;\n}\n\nexport function isAllSqlPaths(meta: EntityMetadata, paths: string[]): boolean {\n for (let i = 0, current = meta; i < paths.length; i++) {\n const next = current.allFields[paths[i]];\n if (next && (next.kind === \"m2o\" || next.kind === \"m2m\" || next.kind === \"o2m\" || next.kind === \"o2o\")) {\n current = next.otherMetadata();\n } else {\n return false;\n }\n }\n return true;\n}\n\n// Given BookReview+[book, author] return [Author, books+bookReviews]\nexport function mapPathsToTarget(source: EntityMetadata, paths: string[]): [EntityMetadata, [EntityMetadata, Field][]] {\n let other = source;\n let fields: [EntityMetadata, Field][] = [];\n for (let i = 0; i < paths.length; i++) {\n const next = other.allFields[paths[i]];\n if (next && (next.kind === \"m2o\" || next.kind === \"m2m\" || next.kind === \"o2m\" || next.kind === \"o2o\")) {\n other = next.otherMetadata();\n fields.push([other, other.allFields[next.otherFieldName]]);\n } else {\n throw new Error(\"Either not an all-SQL path or not supported yet\");\n }\n }\n return [other, fields.reverse()];\n}\n\nfunction maybeLoad(object: any, path: string, opts: { forceReload?: boolean }): unknown {\n if (object === undefined || object === null) {\n return undefined;\n }\n const value = object[path];\n if (value && typeof value === \"object\" && \"load\" in value) {\n return value.load(opts);\n } else if (value && typeof value === \"function\") {\n return value.apply(object);\n } else {\n return value;\n }\n}\n\n/**\n * The synchronous version of `loadLens`.\n *\n * This assumes you've first evaluated the lens with `loadLens` and now can access it synchronously.\n */\nexport function getLens<T, U, V>(\n startMeta: EntityMetadata,\n start: T | readonly T[],\n fn: (lens: Lens<T>) => Lens<U, V>,\n): V {\n return getLensPath(startMeta, start, collectPaths(fn));\n}\n\n/** Synchronously traverses a precomputed lens path. */\nexport function getLensPath<T, V>(startMeta: EntityMetadata, start: T | readonly T[], paths: string[]): V {\n let currentMeta: EntityMetadata | undefined = startMeta;\n let current: any = start;\n let seenSoftDeleted = false;\n // Now evaluate each step of the path\n for (const path of paths) {\n // We might navigate into properties, at which point we won't know the currentMeta\n const field = currentMeta?.allFields[path] as\n | ManyToOneField\n | ManyToManyField\n | OneToManyField\n | OneToOneField\n | PrimitiveField\n | undefined;\n if (Array.isArray(current)) {\n // Use a set to dedup as we go\n const next = new Set();\n // This can be a hot path, so avoid `map` and `flat` and just loop\n for (const c of current) {\n const value = maybeGet(c, path);\n if (Array.isArray(value)) for (const v of value) maybeAdd(next, v);\n else maybeAdd(next, value);\n }\n current = [...next];\n } else if (current) {\n current = maybeGet(current, path);\n seenSoftDeleted ||= (current as any)?.isSoftDeletedEntity;\n // If we had been traversing m2o -> m2o and just hit an o2m/m2m, and any of our\n // prior m2os had been soft-deleted, just filter everything out.\n if (Array.isArray(current) && seenSoftDeleted) {\n return [] as any;\n }\n } else {\n // current is undefined; see if we should flip to a list ... which means we can early return\n if (field?.kind === \"o2m\" || field?.kind === \"m2m\") return [] as any;\n }\n currentMeta = nextMeta(current, field);\n }\n return current!;\n}\n\n/** Returns the next runtime metadata, preserving subtype-specific fields after base-typed traversals. */\nfunction nextMeta(current: unknown, field: Field | undefined): EntityMetadata | undefined {\n const entity = Array.isArray(current) ? current[0] : current;\n if (isEntity(entity)) return getMetadata(entity);\n return field && \"otherMetadata\" in field ? field.otherMetadata() : undefined;\n}\n\nfunction maybeAdd(set: Set<any>, value: any) {\n if (value !== undefined && !value.isSoftDeletedEntity) set.add(value);\n}\n\n/** Returns whether a lens is loaded; primarily for deeply loaded instances in tests. */\nexport function isLensLoaded<T, U, V>(start: T | readonly T[], fn: (lens: Lens<T>) => Lens<U, V>): boolean {\n return isLensLoadedPath(start, collectPaths(fn));\n}\n\n/** Returns whether a precomputed lens path is loaded; primarily for deeply loaded instances in tests. */\nexport function isLensLoadedPath<T>(start: T | readonly T[], paths: string[]): boolean {\n // This is a huge copy/paste of `getLens` but we check `isNotLoaded` and early return\n // as soon as we find any not-loaded relation\n let current: any = start;\n let seenSoftDeleted = false;\n // Now evaluate each step of the path\n for (const path of paths) {\n if (Array.isArray(current)) {\n // Use a set to dedup as we go\n const next = new Set();\n for (const c of current) {\n if (isNotLoaded(c, path)) return false;\n const value = maybeGet(c, path);\n if (Array.isArray(value)) for (const v of value) maybeAdd(next, v);\n else maybeAdd(next, value);\n }\n current = [...next];\n } else {\n if (isNotLoaded(current, path)) return false;\n current = maybeGet(current, path);\n seenSoftDeleted ||= (current as any)?.isSoftDeletedEntity;\n // If we had been traversing m2o -> m2o and just hit an o2m/m2m, and any of our\n // prior m2os had been soft deleted, just filter everything out.\n if (Array.isArray(current) && seenSoftDeleted) {\n return true;\n }\n }\n }\n return true;\n}\n\n/** Accepts a lens like `a => a.books.reviews` and returns a hint like `{ books: { reviews: {} } }`. */\nexport function lensToLoadHint<T extends Entity, U, V>(fn: (lens: Lens<T>) => Lens<U, V>): LoadHint<T> {\n return lensPathToLoadHint(collectPaths(fn));\n}\n\n/** Accepts lens paths like `[books, reviews]` and returns a hint like `{ books: { reviews: {} } }`. */\nexport function lensPathToLoadHint<T extends Entity>(paths: string[]): LoadHint<T> {\n let current = {};\n for (let i = paths.length - 1; i >= 0; i--) {\n const path = paths[i];\n current = { [path]: current };\n }\n return current as LoadHint<T>;\n}\n\n/** Accepts a lens like `a => a.books.reviews` and returns the paths like `[books, reviews]`. */\nexport function lensToPath<T extends Entity, U, V>(fn: (lens: Lens<T>) => Lens<U, V>): string[] {\n return [...collectPaths(fn)];\n}\n\nfunction isNotLoaded(object: any, path: string): boolean {\n const value = object && object[path];\n if (value instanceof AbstractRelationImpl || isProperty(value)) {\n return !value.isLoaded;\n }\n return false;\n}\n\nfunction maybeGet(object: any, path: string): unknown {\n if (object === undefined || object === null) {\n return undefined;\n }\n const value = object[path];\n if (typeof value === \"object\" && \"get\" in value) {\n return value.get;\n } else if (value && typeof value === \"function\") {\n return value.apply(object);\n } else {\n return value;\n }\n}\n\nfunction collectPaths(fn: Function): string[] {\n const paths: string[] = [];\n // The proxy collects the path navigations that the user's `fn` lambda invokes.\n const proxy = new Proxy(\n {},\n {\n get(_, property, receiver) {\n paths.push(String(property));\n return receiver;\n },\n },\n );\n // Invoke the lens function to record the navigation path on our proxy\n fn(proxy as any);\n return paths;\n}\n\n// Work around https://github.com/microsoft/TypeScript/issues/17002\nfunction isReadOnlyArray<T>(value: T | readonly T[]): value is readonly T[] {\n return Array.isArray(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqFA,eAAsB,SACpB,OACA,IACA,OAAiD,CAAC,GACtC;CACZ,OAAO,aAAa,OAAO,aAAa,EAAE,GAAG,IAAI;AACnD;;AAGA,SAAgB,aACd,OACA,OACA,OAAiD,CAAC,GACtC;CAEZ,MAAM,OAAO,MAAM,QAAQ,KAAK,IAC5BA,eAAAA,SAAS,MAAM,EAAE,KAAKC,uBAAAA,YAAY,MAAM,EAAE,IAC1CD,eAAAA,SAAS,KAAK,KAAKC,uBAAAA,YAAY,KAAK;CAExC,IAAI,CAAC,MAAM,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AI,OAAO,UAAU,YAAY,SAAS,OACxC,OAAO,MAAM;MACR,IAAI,SAAS,OAAO,UAAU,YACnC,OAAO,MAAM,MAAM,MAAM;MAEzB,OAAO;AAEX;AAEA,SAAS,aAAa,IAAwB;CAC5C,MAAM,QAAkB,CAAC;CAYzB,GAAG,IAVe,MAChB,CAAC,GACD,EACE,IAAI,GAAG,UAAU,UAAU;EACzB,MAAM,KAAK,OAAO,QAAQ,CAAC;EAC3B,OAAO;CACT,EACF,CAGK,CAAQ;CACf,OAAO;AACT;AAGA,SAAS,gBAAmB,OAAgD;CAC1E,OAAO,MAAM,QAAQ,KAAK;AAC5B"}
@@ -1,7 +1,7 @@
1
1
  import { LoadHint } from "./loadHints.cjs";
2
- import { EntityMetadata, Field } from "./EntityMetadata.cjs";
3
- import { Entity } from "./Entity.cjs";
4
- //#region src/loadLens.d.ts
2
+ import { EntityMetadata, Field } from "../EntityMetadata.cjs";
3
+ import { Entity } from "../Entity.cjs";
4
+ //#region src/loading/loadLens.d.ts
5
5
  /** Generically matches on a Reference/Collection's load method. */
6
6
  type LoadLike<U> = {
7
7
  load(): Promise<U>;