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

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 (580) hide show
  1. package/build/EntityManager.cjs +45 -46
  2. package/build/EntityManager.cjs.map +1 -1
  3. package/build/EntityManager.d.cts +7 -7
  4. package/build/EntityManager.d.mts +7 -7
  5. package/build/EntityManager.js +27 -28
  6. package/build/EntityManager.js.map +1 -1
  7. package/build/EntityMetadata.cjs +0 -2
  8. package/build/EntityMetadata.cjs.map +1 -1
  9. package/build/EntityMetadata.d.cts +3 -3
  10. package/build/EntityMetadata.d.mts +3 -3
  11. package/build/EntityMetadata.js +0 -2
  12. package/build/EntityMetadata.js.map +1 -1
  13. package/build/IndexManager.cjs +1 -1
  14. package/build/IndexManager.js +1 -1
  15. package/build/PluginManager.cjs +0 -1
  16. package/build/PluginManager.cjs.map +1 -1
  17. package/build/PluginManager.d.cts +1 -1
  18. package/build/PluginManager.d.mts +1 -1
  19. package/build/PluginManager.js +0 -1
  20. package/build/PluginManager.js.map +1 -1
  21. package/build/batchloaders/enumCollectionBatchLoader.cjs +1 -1
  22. package/build/batchloaders/enumCollectionBatchLoader.d.cts +1 -1
  23. package/build/batchloaders/enumCollectionBatchLoader.d.mts +1 -1
  24. package/build/batchloaders/enumCollectionBatchLoader.js +1 -1
  25. package/build/batchloaders/loadBatchLoader.cjs +3 -4
  26. package/build/batchloaders/loadBatchLoader.cjs.map +1 -1
  27. package/build/batchloaders/loadBatchLoader.d.cts +1 -1
  28. package/build/batchloaders/loadBatchLoader.d.mts +1 -1
  29. package/build/batchloaders/loadBatchLoader.js +2 -3
  30. package/build/batchloaders/loadBatchLoader.js.map +1 -1
  31. package/build/batchloaders/manyToManyBatchLoader.cjs +1 -1
  32. package/build/batchloaders/manyToManyBatchLoader.d.cts +1 -1
  33. package/build/batchloaders/manyToManyBatchLoader.d.mts +1 -1
  34. package/build/batchloaders/manyToManyBatchLoader.js +1 -1
  35. package/build/batchloaders/oneToManyBatchLoader.cjs +1 -1
  36. package/build/batchloaders/oneToManyBatchLoader.js +1 -1
  37. package/build/batchloaders/oneToOneBatchLoader.cjs +1 -1
  38. package/build/batchloaders/oneToOneBatchLoader.js +1 -1
  39. package/build/batchloaders/populateBatchLoader.cjs +11 -12
  40. package/build/batchloaders/populateBatchLoader.cjs.map +1 -1
  41. package/build/batchloaders/populateBatchLoader.d.cts +1 -1
  42. package/build/batchloaders/populateBatchLoader.d.mts +1 -1
  43. package/build/batchloaders/populateBatchLoader.js +7 -8
  44. package/build/batchloaders/populateBatchLoader.js.map +1 -1
  45. package/build/batchloaders/recursiveChildrenBatchLoader.cjs +2 -2
  46. package/build/batchloaders/recursiveChildrenBatchLoader.js +2 -2
  47. package/build/batchloaders/recursiveM2mBatchLoader.cjs +2 -2
  48. package/build/batchloaders/recursiveM2mBatchLoader.js +2 -2
  49. package/build/batchloaders/recursiveParentsBatchLoader.cjs +2 -2
  50. package/build/batchloaders/recursiveParentsBatchLoader.js +2 -2
  51. package/build/changes.cjs +2 -3
  52. package/build/changes.cjs.map +1 -1
  53. package/build/changes.js +2 -3
  54. package/build/changes.js.map +1 -1
  55. package/build/config.cjs +3 -3
  56. package/build/config.cjs.map +1 -1
  57. package/build/config.d.cts +2 -2
  58. package/build/config.d.mts +2 -2
  59. package/build/config.js +1 -1
  60. package/build/config.js.map +1 -1
  61. package/build/configure.cjs +10 -10
  62. package/build/configure.cjs.map +1 -1
  63. package/build/configure.js +5 -5
  64. package/build/configure.js.map +1 -1
  65. package/build/dataloaders/fastWhereFilterHash.cjs +8 -8
  66. package/build/dataloaders/fastWhereFilterHash.cjs.map +1 -1
  67. package/build/dataloaders/fastWhereFilterHash.d.cts.map +1 -1
  68. package/build/dataloaders/fastWhereFilterHash.d.mts.map +1 -1
  69. package/build/dataloaders/fastWhereFilterHash.js +3 -3
  70. package/build/dataloaders/fastWhereFilterHash.js.map +1 -1
  71. package/build/dataloaders/findByUniqueDataLoader.cjs.map +1 -1
  72. package/build/dataloaders/findByUniqueDataLoader.js.map +1 -1
  73. package/build/dataloaders/findCountDataLoader.cjs +2 -2
  74. package/build/dataloaders/findCountDataLoader.cjs.map +1 -1
  75. package/build/dataloaders/findCountDataLoader.js +1 -1
  76. package/build/dataloaders/findCountDataLoader.js.map +1 -1
  77. package/build/dataloaders/findDataLoader.cjs +6 -6
  78. package/build/dataloaders/findDataLoader.cjs.map +1 -1
  79. package/build/dataloaders/findDataLoader.d.cts +1 -1
  80. package/build/dataloaders/findDataLoader.d.mts +1 -1
  81. package/build/dataloaders/findDataLoader.js +3 -3
  82. package/build/dataloaders/findDataLoader.js.map +1 -1
  83. package/build/dataloaders/findIdsDataLoader.cjs +3 -3
  84. package/build/dataloaders/findIdsDataLoader.cjs.map +1 -1
  85. package/build/dataloaders/findIdsDataLoader.js +2 -2
  86. package/build/dataloaders/findIdsDataLoader.js.map +1 -1
  87. package/build/dataloaders/findOrCreateDataLoader.cjs +1 -1
  88. package/build/dataloaders/findOrCreateDataLoader.js +1 -1
  89. package/build/dataloaders/findPaginatedDataLoader.cjs +6 -6
  90. package/build/dataloaders/findPaginatedDataLoader.cjs.map +1 -1
  91. package/build/dataloaders/findPaginatedDataLoader.d.cts +1 -1
  92. package/build/dataloaders/findPaginatedDataLoader.d.mts +1 -1
  93. package/build/dataloaders/findPaginatedDataLoader.js +3 -3
  94. package/build/dataloaders/findPaginatedDataLoader.js.map +1 -1
  95. package/build/dataloaders/lensDataLoader.cjs +3 -3
  96. package/build/dataloaders/lensDataLoader.cjs.map +1 -1
  97. package/build/dataloaders/lensDataLoader.js +2 -2
  98. package/build/dataloaders/lensDataLoader.js.map +1 -1
  99. package/build/dataloaders/manyToManyFindDataLoader.cjs +1 -1
  100. package/build/dataloaders/manyToManyFindDataLoader.js +1 -1
  101. package/build/dataloaders/oneToManyFindDataLoader.cjs +1 -1
  102. package/build/dataloaders/oneToManyFindDataLoader.js +1 -1
  103. package/build/defaults.cjs +5 -5
  104. package/build/defaults.cjs.map +1 -1
  105. package/build/defaults.d.cts +1 -1
  106. package/build/defaults.d.mts +1 -1
  107. package/build/defaults.js +4 -4
  108. package/build/defaults.js.map +1 -1
  109. package/build/drivers/Driver.cjs +0 -1
  110. package/build/drivers/Driver.d.cts +1 -1
  111. package/build/drivers/Driver.d.mts +1 -1
  112. package/build/drivers/Driver.js +0 -1
  113. package/build/drivers/EntityWriter.cjs +6 -7
  114. package/build/drivers/EntityWriter.cjs.map +1 -1
  115. package/build/drivers/EntityWriter.d.cts +1 -1
  116. package/build/drivers/EntityWriter.d.mts +1 -1
  117. package/build/drivers/EntityWriter.js +2 -3
  118. package/build/drivers/EntityWriter.js.map +1 -1
  119. package/build/drivers/IdAssigner.cjs +0 -1
  120. package/build/drivers/IdAssigner.cjs.map +1 -1
  121. package/build/drivers/IdAssigner.d.cts +1 -1
  122. package/build/drivers/IdAssigner.d.mts +1 -1
  123. package/build/drivers/IdAssigner.js +0 -1
  124. package/build/drivers/IdAssigner.js.map +1 -1
  125. package/build/drivers/driverApi.cjs +19 -0
  126. package/build/drivers/driverApi.cjs.map +1 -0
  127. package/build/drivers/driverApi.d.cts +22 -0
  128. package/build/drivers/driverApi.d.cts.map +1 -0
  129. package/build/drivers/driverApi.d.mts +22 -0
  130. package/build/drivers/driverApi.d.mts.map +1 -0
  131. package/build/drivers/driverApi.js +18 -0
  132. package/build/drivers/driverApi.js.map +1 -0
  133. package/build/fields.cjs +3 -3
  134. package/build/fields.cjs.map +1 -1
  135. package/build/fields.js +2 -2
  136. package/build/fields.js.map +1 -1
  137. package/build/{FlushLock.cjs → flush/FlushLock.cjs} +1 -1
  138. package/build/flush/FlushLock.cjs.map +1 -0
  139. package/build/{FlushLock.d.cts → flush/FlushLock.d.cts} +1 -1
  140. package/build/flush/FlushLock.d.cts.map +1 -0
  141. package/build/{FlushLock.d.mts → flush/FlushLock.d.mts} +1 -1
  142. package/build/flush/FlushLock.d.mts.map +1 -0
  143. package/build/{FlushLock.js → flush/FlushLock.js} +1 -1
  144. package/build/flush/FlushLock.js.map +1 -0
  145. package/build/{JoinRows.cjs → flush/JoinRows.cjs} +5 -8
  146. package/build/flush/JoinRows.cjs.map +1 -0
  147. package/build/{JoinRows.d.cts → flush/JoinRows.d.cts} +5 -5
  148. package/build/flush/JoinRows.d.cts.map +1 -0
  149. package/build/{JoinRows.d.mts → flush/JoinRows.d.mts} +5 -5
  150. package/build/flush/JoinRows.d.mts.map +1 -0
  151. package/build/{JoinRows.js → flush/JoinRows.js} +5 -8
  152. package/build/flush/JoinRows.js.map +1 -0
  153. package/build/{PendingChanges.cjs → flush/PendingChanges.cjs} +0 -1
  154. package/build/{PendingChanges.d.cts → flush/PendingChanges.d.cts} +2 -2
  155. package/build/flush/PendingChanges.d.cts.map +1 -0
  156. package/build/{PendingChanges.d.mts → flush/PendingChanges.d.mts} +2 -2
  157. package/build/flush/PendingChanges.d.mts.map +1 -0
  158. package/build/flush/PendingChanges.js +1 -0
  159. package/build/{Todo.cjs → flush/Todo.cjs} +4 -6
  160. package/build/flush/Todo.cjs.map +1 -0
  161. package/build/{Todo.d.cts → flush/Todo.d.cts} +3 -3
  162. package/build/flush/Todo.d.cts.map +1 -0
  163. package/build/{Todo.d.mts → flush/Todo.d.mts} +3 -3
  164. package/build/flush/Todo.d.mts.map +1 -0
  165. package/build/{Todo.js → flush/Todo.js} +4 -6
  166. package/build/flush/Todo.js.map +1 -0
  167. package/build/index.cjs +99 -99
  168. package/build/index.cjs.map +1 -1
  169. package/build/index.d.cts +15 -15
  170. package/build/index.d.mts +15 -15
  171. package/build/index.js +41 -41
  172. package/build/index.js.map +1 -1
  173. package/build/json.cjs +4 -4
  174. package/build/json.cjs.map +1 -1
  175. package/build/json.js +3 -3
  176. package/build/json.js.map +1 -1
  177. package/build/keys.cjs +1 -1
  178. package/build/keys.js +1 -1
  179. package/build/{HintTree.cjs → loading/HintTree.cjs} +2 -5
  180. package/build/loading/HintTree.cjs.map +1 -0
  181. package/build/{HintTree.d.cts → loading/HintTree.d.cts} +3 -3
  182. package/build/loading/HintTree.d.cts.map +1 -0
  183. package/build/{HintTree.d.mts → loading/HintTree.d.mts} +3 -3
  184. package/build/loading/HintTree.d.mts.map +1 -0
  185. package/build/{HintTree.js → loading/HintTree.js} +2 -5
  186. package/build/loading/HintTree.js.map +1 -0
  187. package/build/{IsLoadedCache.cjs → loading/IsLoadedCache.cjs} +2 -3
  188. package/build/loading/IsLoadedCache.cjs.map +1 -0
  189. package/build/{IsLoadedCache.d.cts → loading/IsLoadedCache.d.cts} +2 -2
  190. package/build/loading/IsLoadedCache.d.cts.map +1 -0
  191. package/build/{IsLoadedCache.d.mts → loading/IsLoadedCache.d.mts} +2 -2
  192. package/build/loading/IsLoadedCache.d.mts.map +1 -0
  193. package/build/{IsLoadedCache.js → loading/IsLoadedCache.js} +2 -3
  194. package/build/loading/IsLoadedCache.js.map +1 -0
  195. package/build/{loadHints.cjs → loading/loadHints.cjs} +6 -11
  196. package/build/loading/loadHints.cjs.map +1 -0
  197. package/build/{loadHints.d.cts → loading/loadHints.d.cts} +14 -14
  198. package/build/loading/loadHints.d.cts.map +1 -0
  199. package/build/{loadHints.d.mts → loading/loadHints.d.mts} +14 -14
  200. package/build/loading/loadHints.d.mts.map +1 -0
  201. package/build/{loadHints.js → loading/loadHints.js} +3 -8
  202. package/build/loading/loadHints.js.map +1 -0
  203. package/build/{loadLens.cjs → loading/loadLens.cjs} +8 -9
  204. package/build/loading/loadLens.cjs.map +1 -0
  205. package/build/{loadLens.d.cts → loading/loadLens.d.cts} +3 -3
  206. package/build/loading/loadLens.d.cts.map +1 -0
  207. package/build/{loadLens.d.mts → loading/loadLens.d.mts} +3 -3
  208. package/build/loading/loadLens.d.mts.map +1 -0
  209. package/build/{loadLens.js → loading/loadLens.js} +8 -9
  210. package/build/loading/loadLens.js.map +1 -0
  211. package/build/{withLoaded.cjs → loading/withLoaded.cjs} +12 -13
  212. package/build/loading/withLoaded.cjs.map +1 -0
  213. package/build/{withLoaded.d.cts → loading/withLoaded.d.cts} +9 -9
  214. package/build/loading/withLoaded.d.cts.map +1 -0
  215. package/build/{withLoaded.d.mts → loading/withLoaded.d.mts} +9 -9
  216. package/build/loading/withLoaded.d.mts.map +1 -0
  217. package/build/{withLoaded.js → loading/withLoaded.js} +10 -11
  218. package/build/loading/withLoaded.js.map +1 -0
  219. package/build/logging/ReactionLogger.cjs +0 -2
  220. package/build/logging/ReactionLogger.cjs.map +1 -1
  221. package/build/logging/ReactionLogger.d.cts +2 -2
  222. package/build/logging/ReactionLogger.d.mts +2 -2
  223. package/build/logging/ReactionLogger.js +0 -2
  224. package/build/logging/ReactionLogger.js.map +1 -1
  225. package/build/newTestInstance.cjs +3 -3
  226. package/build/newTestInstance.cjs.map +1 -1
  227. package/build/newTestInstance.d.cts +1 -1
  228. package/build/newTestInstance.d.mts +1 -1
  229. package/build/newTestInstance.js +2 -2
  230. package/build/newTestInstance.js.map +1 -1
  231. package/build/normalizeHints.cjs +0 -2
  232. package/build/normalizeHints.cjs.map +1 -1
  233. package/build/normalizeHints.d.cts +2 -2
  234. package/build/normalizeHints.d.mts +2 -2
  235. package/build/normalizeHints.js +0 -2
  236. package/build/normalizeHints.js.map +1 -1
  237. package/build/nowUTC.cjs +2 -2
  238. package/build/nowUTC.cjs.map +1 -1
  239. package/build/nowUTC.d.cts +1 -1
  240. package/build/nowUTC.d.mts +1 -1
  241. package/build/nowUTC.js +1 -1
  242. package/build/nowUTC.js.map +1 -1
  243. package/build/plugins/PreloadPlugin.cjs +0 -2
  244. package/build/plugins/PreloadPlugin.d.cts +2 -2
  245. package/build/plugins/PreloadPlugin.d.mts +2 -2
  246. package/build/plugins/PreloadPlugin.js +0 -2
  247. package/build/preloading/JsonAggregatePreloader.cjs +1 -4
  248. package/build/preloading/JsonAggregatePreloader.cjs.map +1 -1
  249. package/build/preloading/JsonAggregatePreloader.d.cts +2 -2
  250. package/build/preloading/JsonAggregatePreloader.d.mts +2 -2
  251. package/build/preloading/JsonAggregatePreloader.js +1 -4
  252. package/build/preloading/JsonAggregatePreloader.js.map +1 -1
  253. package/build/preloading/partitionHint.cjs +2 -3
  254. package/build/preloading/partitionHint.cjs.map +1 -1
  255. package/build/preloading/partitionHint.d.cts +1 -1
  256. package/build/preloading/partitionHint.d.mts +1 -1
  257. package/build/preloading/partitionHint.js +2 -3
  258. package/build/preloading/partitionHint.js.map +1 -1
  259. package/build/queries/ConditionBuilder.cjs.map +1 -1
  260. package/build/queries/ConditionBuilder.d.cts +1 -1
  261. package/build/queries/ConditionBuilder.d.mts +1 -1
  262. package/build/queries/ConditionBuilder.js.map +1 -1
  263. package/build/queries/find/Aliases.cjs +1 -1
  264. package/build/queries/find/Aliases.cjs.map +1 -1
  265. package/build/queries/find/Aliases.js +1 -1
  266. package/build/queries/find/Aliases.js.map +1 -1
  267. package/build/queries/find/QueryParser.cjs +1 -1
  268. package/build/queries/find/QueryParser.js +1 -1
  269. package/build/queries/find/scopes.cjs.map +1 -1
  270. package/build/queries/find/scopes.d.cts +1 -1
  271. package/build/queries/find/scopes.d.mts +1 -1
  272. package/build/queries/find/scopes.js.map +1 -1
  273. package/build/queries/sql/Expr.cjs +2 -2
  274. package/build/queries/sql/Expr.cjs.map +1 -1
  275. package/build/queries/sql/Expr.d.cts +1 -1
  276. package/build/queries/sql/Expr.d.mts +1 -1
  277. package/build/queries/sql/Expr.js +1 -1
  278. package/build/queries/sql/Expr.js.map +1 -1
  279. package/build/queries/sql/Tables.cjs +1 -1
  280. package/build/queries/sql/Tables.cjs.map +1 -1
  281. package/build/queries/sql/Tables.js +1 -1
  282. package/build/queries/sql/Tables.js.map +1 -1
  283. package/build/queries/sql/execute.cjs +1 -1
  284. package/build/queries/sql/execute.cjs.map +1 -1
  285. package/build/queries/sql/execute.js +1 -1
  286. package/build/queries/sql/execute.js.map +1 -1
  287. package/build/queries/sql/expressions/codecs.cjs +2 -2
  288. package/build/queries/sql/expressions/codecs.cjs.map +1 -1
  289. package/build/queries/sql/expressions/codecs.js +1 -1
  290. package/build/queries/sql/expressions/codecs.js.map +1 -1
  291. package/build/queries/sql/expressions/expression.cjs.map +1 -1
  292. package/build/queries/sql/expressions/expression.js.map +1 -1
  293. package/build/queries/sql/query.cjs.map +1 -1
  294. package/build/queries/sql/query.d.cts +1 -1
  295. package/build/queries/sql/query.d.mts +1 -1
  296. package/build/queries/sql/query.js.map +1 -1
  297. package/build/{unnest.cjs → queries/unnest.cjs} +1 -2
  298. package/build/queries/unnest.cjs.map +1 -0
  299. package/build/{unnest.d.cts → queries/unnest.d.cts} +3 -3
  300. package/build/queries/unnest.d.cts.map +1 -0
  301. package/build/{unnest.d.mts → queries/unnest.d.mts} +3 -3
  302. package/build/queries/unnest.d.mts.map +1 -0
  303. package/build/{unnest.js → queries/unnest.js} +1 -2
  304. package/build/queries/unnest.js.map +1 -0
  305. package/build/queries/valueFilters.cjs.map +1 -1
  306. package/build/queries/valueFilters.d.cts +1 -1
  307. package/build/queries/valueFilters.d.mts +1 -1
  308. package/build/queries/valueFilters.js.map +1 -1
  309. package/build/{ReactionsManager.cjs → reactivity/ReactionsManager.cjs} +8 -10
  310. package/build/reactivity/ReactionsManager.cjs.map +1 -0
  311. package/build/{ReactionsManager.d.cts → reactivity/ReactionsManager.d.cts} +5 -6
  312. package/build/reactivity/ReactionsManager.d.cts.map +1 -0
  313. package/build/{ReactionsManager.d.mts → reactivity/ReactionsManager.d.mts} +5 -6
  314. package/build/reactivity/ReactionsManager.d.mts.map +1 -0
  315. package/build/{ReactionsManager.js → reactivity/ReactionsManager.js} +6 -8
  316. package/build/reactivity/ReactionsManager.js.map +1 -0
  317. package/build/{reactiveHints.cjs → reactivity/reactiveHints.cjs} +12 -16
  318. package/build/reactivity/reactiveHints.cjs.map +1 -0
  319. package/build/{reactiveHints.d.cts → reactivity/reactiveHints.d.cts} +17 -17
  320. package/build/reactivity/reactiveHints.d.cts.map +1 -0
  321. package/build/{reactiveHints.d.mts → reactivity/reactiveHints.d.mts} +17 -17
  322. package/build/reactivity/reactiveHints.d.mts.map +1 -0
  323. package/build/{reactiveHints.js → reactivity/reactiveHints.js} +12 -16
  324. package/build/reactivity/reactiveHints.js.map +1 -0
  325. package/build/relations/AsyncReactiveField.cjs +6 -6
  326. package/build/relations/AsyncReactiveField.cjs.map +1 -1
  327. package/build/relations/AsyncReactiveField.d.cts +1 -1
  328. package/build/relations/AsyncReactiveField.d.mts +1 -1
  329. package/build/relations/AsyncReactiveField.js +4 -4
  330. package/build/relations/AsyncReactiveField.js.map +1 -1
  331. package/build/relations/Collection.cjs +1 -1
  332. package/build/relations/Collection.js +1 -1
  333. package/build/relations/CustomCollection.d.cts +1 -1
  334. package/build/relations/CustomCollection.d.mts +1 -1
  335. package/build/relations/CustomReference.cjs +1 -1
  336. package/build/relations/CustomReference.d.cts +1 -1
  337. package/build/relations/CustomReference.d.mts +1 -1
  338. package/build/relations/CustomReference.js +1 -1
  339. package/build/relations/EnumCollection.d.cts +1 -1
  340. package/build/relations/EnumCollection.d.mts +1 -1
  341. package/build/relations/LazyField.cjs +4 -4
  342. package/build/relations/LazyField.js +4 -4
  343. package/build/relations/ManyToManyCollection.cjs +3 -3
  344. package/build/relations/ManyToManyCollection.js +3 -3
  345. package/build/relations/ManyToManyLargeCollection.cjs +3 -3
  346. package/build/relations/ManyToManyLargeCollection.js +3 -3
  347. package/build/relations/ManyToOneReference.cjs +4 -4
  348. package/build/relations/ManyToOneReference.js +4 -4
  349. package/build/relations/OneToManyCollection.cjs +1 -2
  350. package/build/relations/OneToManyCollection.cjs.map +1 -1
  351. package/build/relations/OneToManyCollection.d.cts +1 -1
  352. package/build/relations/OneToManyCollection.d.mts +1 -1
  353. package/build/relations/OneToManyCollection.js +1 -2
  354. package/build/relations/OneToManyCollection.js.map +1 -1
  355. package/build/relations/OneToManyLargeCollection.cjs +1 -1
  356. package/build/relations/OneToManyLargeCollection.js +1 -1
  357. package/build/relations/OneToOneReference.cjs +5 -5
  358. package/build/relations/OneToOneReference.js +5 -5
  359. package/build/relations/PolymorphicReference.cjs +3 -3
  360. package/build/relations/PolymorphicReference.js +3 -3
  361. package/build/relations/ReactiveField.cjs +5 -6
  362. package/build/relations/ReactiveField.cjs.map +1 -1
  363. package/build/relations/ReactiveField.d.cts +2 -2
  364. package/build/relations/ReactiveField.d.mts +2 -2
  365. package/build/relations/ReactiveField.js +3 -4
  366. package/build/relations/ReactiveField.js.map +1 -1
  367. package/build/relations/ReactiveGetter.cjs +0 -1
  368. package/build/relations/ReactiveGetter.cjs.map +1 -1
  369. package/build/relations/ReactiveGetter.d.cts +1 -1
  370. package/build/relations/ReactiveGetter.d.mts +1 -1
  371. package/build/relations/ReactiveGetter.js +0 -1
  372. package/build/relations/ReactiveGetter.js.map +1 -1
  373. package/build/relations/ReactiveManyToMany.cjs +5 -6
  374. package/build/relations/ReactiveManyToMany.cjs.map +1 -1
  375. package/build/relations/ReactiveManyToMany.d.cts +2 -2
  376. package/build/relations/ReactiveManyToMany.d.cts.map +1 -1
  377. package/build/relations/ReactiveManyToMany.d.mts +2 -2
  378. package/build/relations/ReactiveManyToMany.d.mts.map +1 -1
  379. package/build/relations/ReactiveManyToMany.js +3 -4
  380. package/build/relations/ReactiveManyToMany.js.map +1 -1
  381. package/build/relations/ReactiveManyToManyOtherSide.cjs +1 -3
  382. package/build/relations/ReactiveManyToManyOtherSide.cjs.map +1 -1
  383. package/build/relations/ReactiveManyToManyOtherSide.d.cts +2 -2
  384. package/build/relations/ReactiveManyToManyOtherSide.d.mts +2 -2
  385. package/build/relations/ReactiveManyToManyOtherSide.js +1 -3
  386. package/build/relations/ReactiveManyToManyOtherSide.js.map +1 -1
  387. package/build/relations/ReactiveReference.cjs +8 -9
  388. package/build/relations/ReactiveReference.cjs.map +1 -1
  389. package/build/relations/ReactiveReference.d.cts +2 -2
  390. package/build/relations/ReactiveReference.d.cts.map +1 -1
  391. package/build/relations/ReactiveReference.d.mts +2 -2
  392. package/build/relations/ReactiveReference.d.mts.map +1 -1
  393. package/build/relations/ReactiveReference.js +6 -7
  394. package/build/relations/ReactiveReference.js.map +1 -1
  395. package/build/relations/RecursiveCollection.cjs +3 -4
  396. package/build/relations/RecursiveCollection.cjs.map +1 -1
  397. package/build/relations/RecursiveCollection.d.cts +1 -1
  398. package/build/relations/RecursiveCollection.d.mts +1 -1
  399. package/build/relations/RecursiveCollection.js +3 -4
  400. package/build/relations/RecursiveCollection.js.map +1 -1
  401. package/build/relations/Reference.cjs +1 -1
  402. package/build/relations/Reference.js +1 -1
  403. package/build/relations/hasAsyncMethod.cjs +2 -2
  404. package/build/relations/hasAsyncMethod.cjs.map +1 -1
  405. package/build/relations/hasAsyncMethod.d.cts +1 -1
  406. package/build/relations/hasAsyncMethod.d.mts +1 -1
  407. package/build/relations/hasAsyncMethod.js +1 -1
  408. package/build/relations/hasAsyncMethod.js.map +1 -1
  409. package/build/relations/hasManyDerived.cjs +3 -3
  410. package/build/relations/hasManyDerived.cjs.map +1 -1
  411. package/build/relations/hasManyDerived.d.cts +1 -1
  412. package/build/relations/hasManyDerived.d.mts +1 -1
  413. package/build/relations/hasManyDerived.js +2 -2
  414. package/build/relations/hasManyDerived.js.map +1 -1
  415. package/build/relations/hasManyThrough.cjs +6 -6
  416. package/build/relations/hasManyThrough.cjs.map +1 -1
  417. package/build/relations/hasManyThrough.d.cts +1 -1
  418. package/build/relations/hasManyThrough.d.mts +1 -1
  419. package/build/relations/hasManyThrough.js +2 -2
  420. package/build/relations/hasOneDerived.cjs +3 -3
  421. package/build/relations/hasOneDerived.cjs.map +1 -1
  422. package/build/relations/hasOneDerived.d.cts +1 -1
  423. package/build/relations/hasOneDerived.d.mts +1 -1
  424. package/build/relations/hasOneDerived.js +2 -2
  425. package/build/relations/hasOneDerived.js.map +1 -1
  426. package/build/relations/hasOneThrough.cjs +7 -7
  427. package/build/relations/hasOneThrough.cjs.map +1 -1
  428. package/build/relations/hasOneThrough.d.cts +1 -1
  429. package/build/relations/hasOneThrough.d.mts +1 -1
  430. package/build/relations/hasOneThrough.js +2 -2
  431. package/build/relations/hasProperty.cjs +4 -4
  432. package/build/relations/hasProperty.cjs.map +1 -1
  433. package/build/relations/hasProperty.d.cts +2 -2
  434. package/build/relations/hasProperty.d.mts +2 -2
  435. package/build/relations/hasProperty.js +2 -2
  436. package/build/relations/hasProperty.js.map +1 -1
  437. package/build/relations/index.cjs +10 -10
  438. package/build/relations/index.js +10 -10
  439. package/build/rules.cjs +3 -4
  440. package/build/rules.cjs.map +1 -1
  441. package/build/rules.d.cts +1 -1
  442. package/build/rules.d.mts +1 -1
  443. package/build/rules.js +3 -4
  444. package/build/rules.js.map +1 -1
  445. package/build/{TypeInfo.cjs → serde/TypeInfo.cjs} +1 -1
  446. package/build/serde/TypeInfo.cjs.map +1 -0
  447. package/build/{TypeInfo.d.cts → serde/TypeInfo.d.cts} +2 -2
  448. package/build/serde/TypeInfo.d.cts.map +1 -0
  449. package/build/{TypeInfo.d.mts → serde/TypeInfo.d.mts} +2 -2
  450. package/build/serde/TypeInfo.d.mts.map +1 -0
  451. package/build/{TypeInfo.js → serde/TypeInfo.js} +1 -1
  452. package/build/serde/TypeInfo.js.map +1 -0
  453. package/build/{columns.cjs → serde/columns.cjs} +1 -1
  454. package/build/serde/columns.cjs.map +1 -0
  455. package/build/{columns.d.cts → serde/columns.d.cts} +2 -2
  456. package/build/serde/columns.d.cts.map +1 -0
  457. package/build/{columns.d.mts → serde/columns.d.mts} +2 -2
  458. package/build/serde/columns.d.mts.map +1 -0
  459. package/build/{columns.js → serde/columns.js} +1 -1
  460. package/build/serde/columns.js.map +1 -0
  461. package/build/{fieldSerde.cjs → serde/fieldSerde.cjs} +6 -6
  462. package/build/serde/fieldSerde.cjs.map +1 -0
  463. package/build/{fieldSerde.d.cts → serde/fieldSerde.d.cts} +5 -5
  464. package/build/serde/fieldSerde.d.cts.map +1 -0
  465. package/build/{fieldSerde.d.mts → serde/fieldSerde.d.mts} +5 -5
  466. package/build/serde/fieldSerde.d.mts.map +1 -0
  467. package/build/{fieldSerde.js → serde/fieldSerde.js} +6 -6
  468. package/build/serde/fieldSerde.js.map +1 -0
  469. package/build/{serde.cjs → serde/serde.cjs} +25 -26
  470. package/build/serde/serde.cjs.map +1 -0
  471. package/build/{serde.d.cts → serde/serde.d.cts} +1 -1
  472. package/build/serde/serde.d.cts.map +1 -0
  473. package/build/{serde.d.mts → serde/serde.d.mts} +1 -1
  474. package/build/serde/serde.d.mts.map +1 -0
  475. package/build/{serde.js → serde/serde.js} +4 -5
  476. package/build/serde/serde.js.map +1 -0
  477. package/build/{temporal.cjs → serde/temporal.cjs} +1 -1
  478. package/build/serde/temporal.cjs.map +1 -0
  479. package/build/{temporal.d.cts → serde/temporal.d.cts} +1 -1
  480. package/build/serde/temporal.d.cts.map +1 -0
  481. package/build/{temporal.d.mts → serde/temporal.d.mts} +1 -1
  482. package/build/serde/temporal.d.mts.map +1 -0
  483. package/build/{temporal.js → serde/temporal.js} +1 -1
  484. package/build/serde/temporal.js.map +1 -0
  485. package/build/{temporalMappers.cjs → serde/temporalMappers.cjs} +4 -5
  486. package/build/serde/temporalMappers.cjs.map +1 -0
  487. package/build/{temporalMappers.d.cts → serde/temporalMappers.d.cts} +1 -1
  488. package/build/serde/temporalMappers.d.cts.map +1 -0
  489. package/build/{temporalMappers.d.mts → serde/temporalMappers.d.mts} +1 -1
  490. package/build/serde/temporalMappers.d.mts.map +1 -0
  491. package/build/{temporalMappers.js → serde/temporalMappers.js} +2 -3
  492. package/build/serde/temporalMappers.js.map +1 -0
  493. package/build/upsert.cjs +1 -1
  494. package/build/upsert.js +1 -1
  495. package/build/utils.cjs +0 -1
  496. package/build/utils.cjs.map +1 -1
  497. package/build/utils.d.cts +1 -1
  498. package/build/utils.d.mts +1 -1
  499. package/build/utils.js +0 -1
  500. package/build/utils.js.map +1 -1
  501. package/package.json +2 -2
  502. package/build/FlushLock.cjs.map +0 -1
  503. package/build/FlushLock.d.cts.map +0 -1
  504. package/build/FlushLock.d.mts.map +0 -1
  505. package/build/FlushLock.js.map +0 -1
  506. package/build/HintTree.cjs.map +0 -1
  507. package/build/HintTree.d.cts.map +0 -1
  508. package/build/HintTree.d.mts.map +0 -1
  509. package/build/HintTree.js.map +0 -1
  510. package/build/IsLoadedCache.cjs.map +0 -1
  511. package/build/IsLoadedCache.d.cts.map +0 -1
  512. package/build/IsLoadedCache.d.mts.map +0 -1
  513. package/build/IsLoadedCache.js.map +0 -1
  514. package/build/JoinRows.cjs.map +0 -1
  515. package/build/JoinRows.d.cts.map +0 -1
  516. package/build/JoinRows.d.mts.map +0 -1
  517. package/build/JoinRows.js.map +0 -1
  518. package/build/PendingChanges.d.cts.map +0 -1
  519. package/build/PendingChanges.d.mts.map +0 -1
  520. package/build/PendingChanges.js +0 -2
  521. package/build/ReactionsManager.cjs.map +0 -1
  522. package/build/ReactionsManager.d.cts.map +0 -1
  523. package/build/ReactionsManager.d.mts.map +0 -1
  524. package/build/ReactionsManager.js.map +0 -1
  525. package/build/Todo.cjs.map +0 -1
  526. package/build/Todo.d.cts.map +0 -1
  527. package/build/Todo.d.mts.map +0 -1
  528. package/build/Todo.js.map +0 -1
  529. package/build/TypeInfo.cjs.map +0 -1
  530. package/build/TypeInfo.d.cts.map +0 -1
  531. package/build/TypeInfo.d.mts.map +0 -1
  532. package/build/TypeInfo.js.map +0 -1
  533. package/build/columns.cjs.map +0 -1
  534. package/build/columns.d.cts.map +0 -1
  535. package/build/columns.d.mts.map +0 -1
  536. package/build/columns.js.map +0 -1
  537. package/build/driverApi.cjs +0 -18
  538. package/build/driverApi.cjs.map +0 -1
  539. package/build/driverApi.d.cts +0 -22
  540. package/build/driverApi.d.cts.map +0 -1
  541. package/build/driverApi.d.mts +0 -22
  542. package/build/driverApi.d.mts.map +0 -1
  543. package/build/driverApi.js +0 -18
  544. package/build/driverApi.js.map +0 -1
  545. package/build/fieldSerde.cjs.map +0 -1
  546. package/build/fieldSerde.d.cts.map +0 -1
  547. package/build/fieldSerde.d.mts.map +0 -1
  548. package/build/fieldSerde.js.map +0 -1
  549. package/build/loadHints.cjs.map +0 -1
  550. package/build/loadHints.d.cts.map +0 -1
  551. package/build/loadHints.d.mts.map +0 -1
  552. package/build/loadHints.js.map +0 -1
  553. package/build/loadLens.cjs.map +0 -1
  554. package/build/loadLens.d.cts.map +0 -1
  555. package/build/loadLens.d.mts.map +0 -1
  556. package/build/loadLens.js.map +0 -1
  557. package/build/reactiveHints.cjs.map +0 -1
  558. package/build/reactiveHints.d.cts.map +0 -1
  559. package/build/reactiveHints.d.mts.map +0 -1
  560. package/build/reactiveHints.js.map +0 -1
  561. package/build/serde.cjs.map +0 -1
  562. package/build/serde.d.cts.map +0 -1
  563. package/build/serde.d.mts.map +0 -1
  564. package/build/serde.js.map +0 -1
  565. package/build/temporal.cjs.map +0 -1
  566. package/build/temporal.d.cts.map +0 -1
  567. package/build/temporal.d.mts.map +0 -1
  568. package/build/temporal.js.map +0 -1
  569. package/build/temporalMappers.cjs.map +0 -1
  570. package/build/temporalMappers.d.cts.map +0 -1
  571. package/build/temporalMappers.d.mts.map +0 -1
  572. package/build/temporalMappers.js.map +0 -1
  573. package/build/unnest.cjs.map +0 -1
  574. package/build/unnest.d.cts.map +0 -1
  575. package/build/unnest.d.mts.map +0 -1
  576. package/build/unnest.js.map +0 -1
  577. package/build/withLoaded.cjs.map +0 -1
  578. package/build/withLoaded.d.cts.map +0 -1
  579. package/build/withLoaded.d.mts.map +0 -1
  580. package/build/withLoaded.js.map +0 -1
@@ -1,7 +1,7 @@
1
+ import { CustomReference } from "./CustomReference.js";
2
+ import { isLoaded } from "../loading/loadHints.js";
1
3
  import "./Reference.js";
2
- import { isLoaded } from "../loadHints.js";
3
4
  import { lazyField } from "../newEntity.js";
4
- import { CustomReference } from "./CustomReference.js";
5
5
  import "../index.js";
6
6
  import "../Entity.js";
7
7
  //#region src/relations/hasOneDerived.ts
@@ -1 +1 @@
1
- {"version":3,"file":"hasOneDerived.js","names":[],"sources":["../../src/relations/hasOneDerived.ts"],"sourcesContent":["import { isLoaded } from \"..//index.ts\";\nimport { type Entity } from \"../Entity.ts\";\nimport { type LoadHint, type Loaded } from \"../loadHints.ts\";\nimport { lazyField } from \"../newEntity.ts\";\nimport { CustomReference } from \"./CustomReference.ts\";\nimport { type Reference } from \"./Reference.ts\";\n\n/**\n * Creates a CustomReference that can conditionally walk across references in the object graph.\n *\n * I.e. A BookReview \"has one author\" through the `review -> book -> author` relation.\n *\n * Because this is based on `CustomReference`, it will work in populates, i.e. `em.populate(review, \"author\")`.\n */\nexport function hasOneDerived<\n T extends Entity,\n U extends Entity,\n N extends never | undefined,\n V extends U | N,\n const H extends LoadHint<T>,\n>(loadHint: H, get: (entity: Loaded<T, H>) => V): Reference<T, U, N> {\n return lazyField((entity: T) => {\n return new CustomReference<T, U, N>(entity, {\n load: (entity, opts) => entity.em.populate(entity, { hint: loadHint, ...opts }),\n get: () => get(entity as Loaded<T, H>),\n isLoaded: () => isLoaded(entity, loadHint as LoadHint<T>),\n loadHint,\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAgB,cAMd,UAAa,KAAsD;CACnE,OAAO,WAAW,WAAc;EAC9B,OAAO,IAAI,gBAAyB,QAAQ;GAC1C,OAAO,QAAQ,SAAS,OAAO,GAAG,SAAS,QAAQ;IAAE,MAAM;IAAU,GAAG;GAAK,CAAC;GAC9E,WAAW,IAAI,MAAsB;GACrC,gBAAgB,SAAS,QAAQ,QAAuB;GACxD;EACF,CAAC;CACH,CAAC;AACH"}
1
+ {"version":3,"file":"hasOneDerived.js","names":[],"sources":["../../src/relations/hasOneDerived.ts"],"sourcesContent":["import { isLoaded } from \"..//index.ts\";\nimport { type Entity } from \"../Entity.ts\";\nimport type { LoadHint, Loaded } from \"../loading/loadHints.ts\";\nimport { lazyField } from \"../newEntity.ts\";\nimport { CustomReference } from \"./CustomReference.ts\";\nimport { type Reference } from \"./Reference.ts\";\n\n/**\n * Creates a CustomReference that can conditionally walk across references in the object graph.\n *\n * I.e. A BookReview \"has one author\" through the `review -> book -> author` relation.\n *\n * Because this is based on `CustomReference`, it will work in populates, i.e. `em.populate(review, \"author\")`.\n */\nexport function hasOneDerived<\n T extends Entity,\n U extends Entity,\n N extends never | undefined,\n V extends U | N,\n const H extends LoadHint<T>,\n>(loadHint: H, get: (entity: Loaded<T, H>) => V): Reference<T, U, N> {\n return lazyField((entity: T) => {\n return new CustomReference<T, U, N>(entity, {\n load: (entity, opts) => entity.em.populate(entity, { hint: loadHint, ...opts }),\n get: () => get(entity as Loaded<T, H>),\n isLoaded: () => isLoaded(entity, loadHint as LoadHint<T>),\n loadHint,\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAgB,cAMd,UAAa,KAAsD;CACnE,OAAO,WAAW,WAAc;EAC9B,OAAO,IAAI,gBAAyB,QAAQ;GAC1C,OAAO,QAAQ,SAAS,OAAO,GAAG,SAAS,QAAQ;IAAE,MAAM;IAAU,GAAG;GAAK,CAAC;GAC9E,WAAW,IAAI,MAAsB;GACrC,gBAAgB,SAAS,QAAQ,QAAuB;GACxD;EACF,CAAC;CACH,CAAC;AACH"}
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_newEntity = require("../newEntity.cjs");
3
2
  const require_relations_CustomReference = require("./CustomReference.cjs");
3
+ const require_newEntity = require("../newEntity.cjs");
4
4
  const require_EntityMetadata = require("../EntityMetadata.cjs");
5
- const require_loadLens = require("../loadLens.cjs");
5
+ const require_loading_loadLens = require("../loading/loadLens.cjs");
6
6
  require("../index.cjs");
7
7
  //#region src/relations/hasOneThrough.ts
8
8
  /**
@@ -13,14 +13,14 @@ require("../index.cjs");
13
13
  * Because this is based on `CustomReference`, it will work in populates, i.e. `em.populate(review, "author")`.
14
14
  */
15
15
  function hasOneThrough(lens) {
16
- const paths = require_loadLens.lensToPath(lens);
17
- const loadHint = require_loadLens.lensPathToLoadHint(paths);
16
+ const paths = require_loading_loadLens.lensToPath(lens);
17
+ const loadHint = require_loading_loadLens.lensPathToLoadHint(paths);
18
18
  return require_newEntity.lazyField((entity) => {
19
19
  const meta = require_EntityMetadata.getMetadata(entity);
20
20
  return new require_relations_CustomReference.CustomReference(entity, {
21
- load: (entity, opts) => require_loadLens.loadLensPath(entity, paths, opts),
22
- get: () => require_loadLens.getLensPath(meta, entity, paths),
23
- isLoaded: () => require_loadLens.isLensLoadedPath(entity, paths),
21
+ load: (entity, opts) => require_loading_loadLens.loadLensPath(entity, paths, opts),
22
+ get: () => require_loading_loadLens.getLensPath(meta, entity, paths),
23
+ isLoaded: () => require_loading_loadLens.isLensLoadedPath(entity, paths),
24
24
  loadHint
25
25
  });
26
26
  });
@@ -1 +1 @@
1
- {"version":3,"file":"hasOneThrough.cjs","names":["lensToPath","lensPathToLoadHint","lazyField","getMetadata","CustomReference","loadLensPath","getLensPath","isLensLoadedPath"],"sources":["../../src/relations/hasOneThrough.ts"],"sourcesContent":["import {\n CustomReference,\n type Entity,\n type Lens,\n type Reference,\n getLensPath,\n getMetadata,\n isLensLoadedPath,\n lensPathToLoadHint,\n lensToPath,\n loadLensPath,\n} from \"../index.ts\";\nimport { lazyField } from \"../newEntity.ts\";\n\n/**\n * Creates a CustomReference that will walk across references in the object graph.\n *\n * I.e. A BookReview \"has one author\" through the `review -> book -> author` relation.\n *\n * Because this is based on `CustomReference`, it will work in populates, i.e. `em.populate(review, \"author\")`.\n */\nexport function hasOneThrough<T extends Entity, U extends Entity, N extends never | undefined, V extends U | N>(\n lens: (lens: Lens<T>) => Lens<V>,\n): Reference<T, U, N> {\n const paths = lensToPath(lens);\n const loadHint = lensPathToLoadHint<T>(paths);\n return lazyField((entity: T) => {\n const meta = getMetadata(entity);\n return new CustomReference<T, U, N>(entity, {\n load: (entity, opts) => loadLensPath(entity, paths, opts),\n get: () => getLensPath(meta, entity, paths),\n isLoaded: () => isLensLoadedPath(entity, paths),\n loadHint,\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,SAAgB,cACd,MACoB;CACpB,MAAM,QAAQA,iBAAAA,WAAW,IAAI;CAC7B,MAAM,WAAWC,iBAAAA,mBAAsB,KAAK;CAC5C,OAAOC,kBAAAA,WAAW,WAAc;EAC9B,MAAM,OAAOC,uBAAAA,YAAY,MAAM;EAC/B,OAAO,IAAIC,kCAAAA,gBAAyB,QAAQ;GAC1C,OAAO,QAAQ,SAASC,iBAAAA,aAAa,QAAQ,OAAO,IAAI;GACxD,WAAWC,iBAAAA,YAAY,MAAM,QAAQ,KAAK;GAC1C,gBAAgBC,iBAAAA,iBAAiB,QAAQ,KAAK;GAC9C;EACF,CAAC;CACH,CAAC;AACH"}
1
+ {"version":3,"file":"hasOneThrough.cjs","names":["lensToPath","lensPathToLoadHint","lazyField","getMetadata","CustomReference","loadLensPath","getLensPath","isLensLoadedPath"],"sources":["../../src/relations/hasOneThrough.ts"],"sourcesContent":["import {\n CustomReference,\n type Entity,\n type Lens,\n type Reference,\n getLensPath,\n getMetadata,\n isLensLoadedPath,\n lensPathToLoadHint,\n lensToPath,\n loadLensPath,\n} from \"../index.ts\";\nimport { lazyField } from \"../newEntity.ts\";\n\n/**\n * Creates a CustomReference that will walk across references in the object graph.\n *\n * I.e. A BookReview \"has one author\" through the `review -> book -> author` relation.\n *\n * Because this is based on `CustomReference`, it will work in populates, i.e. `em.populate(review, \"author\")`.\n */\nexport function hasOneThrough<T extends Entity, U extends Entity, N extends never | undefined, V extends U | N>(\n lens: (lens: Lens<T>) => Lens<V>,\n): Reference<T, U, N> {\n const paths = lensToPath(lens);\n const loadHint = lensPathToLoadHint<T>(paths);\n return lazyField((entity: T) => {\n const meta = getMetadata(entity);\n return new CustomReference<T, U, N>(entity, {\n load: (entity, opts) => loadLensPath(entity, paths, opts),\n get: () => getLensPath(meta, entity, paths),\n isLoaded: () => isLensLoadedPath(entity, paths),\n loadHint,\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,SAAgB,cACd,MACoB;CACpB,MAAM,QAAQA,yBAAAA,WAAW,IAAI;CAC7B,MAAM,WAAWC,yBAAAA,mBAAsB,KAAK;CAC5C,OAAOC,kBAAAA,WAAW,WAAc;EAC9B,MAAM,OAAOC,uBAAAA,YAAY,MAAM;EAC/B,OAAO,IAAIC,kCAAAA,gBAAyB,QAAQ;GAC1C,OAAO,QAAQ,SAASC,yBAAAA,aAAa,QAAQ,OAAO,IAAI;GACxD,WAAWC,yBAAAA,YAAY,MAAM,QAAQ,KAAK;GAC1C,gBAAgBC,yBAAAA,iBAAiB,QAAQ,KAAK;GAC9C;EACF,CAAC;CACH,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
1
  import { Reference } from "./Reference.cjs";
2
- import { Lens } from "../loadLens.cjs";
2
+ import { Lens } from "../loading/loadLens.cjs";
3
3
  import "../index.cjs";
4
4
  import { Entity } from "../Entity.cjs";
5
5
  //#region src/relations/hasOneThrough.d.ts
@@ -1,5 +1,5 @@
1
1
  import { Reference } from "./Reference.mjs";
2
- import { Lens } from "../loadLens.mjs";
2
+ import { Lens } from "../loading/loadLens.mjs";
3
3
  import "../index.mjs";
4
4
  import { Entity } from "../Entity.mjs";
5
5
  //#region src/relations/hasOneThrough.d.ts
@@ -1,7 +1,7 @@
1
- import { lazyField } from "../newEntity.js";
2
1
  import { CustomReference } from "./CustomReference.js";
2
+ import { lazyField } from "../newEntity.js";
3
3
  import { getMetadata } from "../EntityMetadata.js";
4
- import { getLensPath, isLensLoadedPath, lensPathToLoadHint, lensToPath, loadLensPath } from "../loadLens.js";
4
+ import { getLensPath, isLensLoadedPath, lensPathToLoadHint, lensToPath, loadLensPath } from "../loading/loadLens.js";
5
5
  import "../index.js";
6
6
  //#region src/relations/hasOneThrough.ts
7
7
  /**
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_relations_PropertySymbols = require("./PropertySymbols.cjs");
3
3
  const require_relations_RecursiveCycleError = require("./RecursiveCycleError.cjs");
4
- const require_reactiveHints = require("../reactiveHints.cjs");
5
- const require_loadHints = require("../loadHints.cjs");
4
+ const require_reactivity_reactiveHints = require("../reactivity/reactiveHints.cjs");
5
+ const require_loading_loadHints = require("../loading/loadHints.cjs");
6
6
  const require_utils = require("../utils.cjs");
7
7
  const require_newEntity = require("../newEntity.cjs");
8
8
  const require_EntityMetadata = require("../EntityMetadata.cjs");
@@ -64,7 +64,7 @@ var PropertyImpl = class {
64
64
  return require_utils.tryResolve(() => this.get);
65
65
  }
66
66
  get loadHint() {
67
- if (!this.#hint) this.#hint = require_reactiveHints.convertToLoadHint(require_EntityMetadata.getMetadata(this.#entity), this.#reactiveHint);
67
+ if (!this.#hint) this.#hint = require_reactivity_reactiveHints.convertToLoadHint(require_EntityMetadata.getMetadata(this.#entity), this.#reactiveHint);
68
68
  return this.#hint;
69
69
  }
70
70
  get reactiveHint() {
@@ -83,7 +83,7 @@ var PropertyImpl = class {
83
83
  }, [this.#entity]);
84
84
  }
85
85
  this.#isCheckingLoaded = true;
86
- this.#loaded = require_loadHints.isLoaded(this.#entity, this.loadHint);
86
+ this.#loaded = require_loading_loadHints.isLoaded(this.#entity, this.loadHint);
87
87
  this.#isCheckingLoaded = false;
88
88
  }
89
89
  return !!this.#loaded;
@@ -1 +1 @@
1
- {"version":3,"file":"hasProperty.cjs","names":["lazyField","#entity","#hint","#reactiveHint","#loadPromise","#loaded","tryResolve","convertToLoadHint","getMetadata","#isCheckingLoaded","RecursiveCycleError","isLoaded","PropertyT"],"sources":["../../src/relations/hasProperty.ts"],"sourcesContent":["import { type Entity } from \"../Entity.ts\";\nimport { getMetadata } from \"../EntityMetadata.ts\";\nimport { type LoadHint, type Loaded, isLoaded } from \"../loadHints.ts\";\nimport { lazyField } from \"../newEntity.ts\";\nimport {\n type MaybeReactedPropertyEntity,\n type Reacted,\n type ReactiveHint,\n convertToLoadHint,\n} from \"../reactiveHints.ts\";\nimport { tryResolve } from \"../utils.ts\";\nimport { PropertyT } from \"./PropertySymbols.ts\";\nimport { RecursiveCycleError } from \"./RecursiveCycleError.ts\";\n\nexport { PropertyT };\n\nexport interface Property<T extends Entity, V> {\n // Differentiate from AsyncMethod\n [PropertyT]: T;\n isLoaded: boolean;\n load(): Promise<V>;\n}\n\nexport interface LoadedProperty<T extends Entity, V> {\n get: V;\n}\n\n/**\n * Creates a calculated derived value from a load hint + lambda.\n *\n * The property can be accessed by default as a promise, with `someProperty.load()`.\n *\n * But if `someProperty` is used as a populate hint, then it can be accessed synchronously,\n * with `someProperty.get`.\n */\nexport function hasProperty<T extends Entity, const H extends LoadHint<T>, V>(\n loadHint: H,\n fn: (entity: Loaded<T, H>) => V,\n): Property<T, V> {\n return lazyField((entity: T, fieldName) => {\n return new PropertyImpl(entity, fieldName, loadHint, fn);\n });\n}\n\n/**\n * Creates a calculated derived value from a load hint + lambda.\n *\n * The property can be accessed by default as a promise, with `someProperty.load()`.\n *\n * But if `someProperty` is used as a populate hint, then it can be accessed synchronously,\n * with `someProperty.get`.\n */\nexport function hasReactiveProperty<T extends Entity, const H extends ReactiveHint<T>, V>(\n reactiveHint: H,\n fn: (entity: Reacted<T, H>) => MaybeReactedPropertyEntity<V>,\n): Property<T, V> {\n return lazyField((entity: T, fieldName) => {\n return new PropertyImpl(entity, fieldName, reactiveHint as any, fn as any, { isReactive: true });\n });\n}\n\nexport class PropertyImpl<T extends Entity, H extends LoadHint<T>, V> implements Property<T, V> {\n // We'll probe for loaded if undefined\n #loaded: boolean | undefined = undefined;\n #isCheckingLoaded = false;\n #loadPromise: any;\n\n readonly #entity: T;\n #hint: H | undefined;\n #reactiveHint: ReactiveHint<T> | undefined;\n constructor(\n entity: T,\n private fieldName: string,\n hint: H | ReactiveHint<T>,\n private fn: (entity: Loaded<T, H>) => V,\n private opts: { isReactive?: boolean } = {},\n ) {\n const { isReactive = false } = opts;\n this.#entity = entity;\n this.#hint = isReactive ? undefined : (hint as H);\n this.#reactiveHint = isReactive ? (hint as ReactiveHint<T>) : undefined;\n }\n\n load(): Promise<V> {\n if (!this.isLoaded) {\n const { loadHint, fn } = this;\n return (this.#loadPromise ??= this.#entity.em.populate(this.#entity, loadHint).then((loaded) => {\n this.#loaded = true;\n return fn(loaded);\n }));\n }\n return tryResolve(() => this.get);\n }\n\n get loadHint(): H {\n if (!this.#hint) {\n // Would be nice to statically (but lazily?) cache this...\n this.#hint = convertToLoadHint(getMetadata(this.#entity), this.#reactiveHint as any) as H;\n }\n return this.#hint;\n }\n\n get reactiveHint(): ReactiveHint<T> | undefined {\n return this.#reactiveHint;\n }\n\n get get(): V {\n return this.fn(this.#entity as Loaded<T, H>);\n }\n\n get isLoaded() {\n // Probe the first time, which is useful for factories that are DeepNew\n if (this.#loaded === undefined) {\n if (this.#isCheckingLoaded) {\n this.#isCheckingLoaded = false;\n throw new RecursiveCycleError({ entity: this.#entity, fieldName: this.fieldName }, [this.#entity]);\n }\n this.#isCheckingLoaded = true;\n this.#loaded = isLoaded(this.#entity, this.loadHint);\n this.#isCheckingLoaded = false;\n }\n return !!this.#loaded;\n }\n\n [PropertyT] = undefined as any as T;\n}\n\n/** Type guard utility for determining if an entity field is a Property. */\nexport function isProperty(maybeProperty: any): maybeProperty is Property<any, any> {\n return maybeProperty instanceof PropertyImpl;\n}\n\n/** Type guard utility for determining if an entity field is a loaded Property. */\nexport function isLoadedProperty(maybeProperty: any): maybeProperty is Property<any, any> & LoadedProperty<any, any> {\n return isProperty(maybeProperty) && maybeProperty.isLoaded;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmCA,SAAgB,YACd,UACA,IACgB;CAChB,OAAOA,kBAAAA,WAAW,QAAW,cAAc;EACzC,OAAO,IAAI,aAAa,QAAQ,WAAW,UAAU,EAAE;CACzD,CAAC;AACH;;;;;;;;;AAUA,SAAgB,oBACd,cACA,IACgB;CAChB,OAAOA,kBAAAA,WAAW,QAAW,cAAc;EACzC,OAAO,IAAI,aAAa,QAAQ,WAAW,cAAqB,IAAW,EAAE,YAAY,KAAK,CAAC;CACjG,CAAC;AACH;AAEA,IAAa,eAAb,MAAgG;CA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CAACO,kCAAAA,aAAa,KAAA;AAChB;;AAGA,SAAgB,WAAW,eAAyD;CAClF,OAAO,yBAAyB;AAClC;;AAGA,SAAgB,iBAAiB,eAAoF;CACnH,OAAO,WAAW,aAAa,KAAK,cAAc;AACpD"}
1
+ {"version":3,"file":"hasProperty.cjs","names":["lazyField","#entity","#hint","#reactiveHint","#loadPromise","#loaded","tryResolve","convertToLoadHint","getMetadata","#isCheckingLoaded","RecursiveCycleError","isLoaded","PropertyT"],"sources":["../../src/relations/hasProperty.ts"],"sourcesContent":["import { type Entity } from \"../Entity.ts\";\nimport { getMetadata } from \"../EntityMetadata.ts\";\nimport { type LoadHint, type Loaded, isLoaded } from \"../loading/loadHints.ts\";\nimport { lazyField } from \"../newEntity.ts\";\nimport {\n type MaybeReactedPropertyEntity,\n type Reacted,\n type ReactiveHint,\n convertToLoadHint,\n} from \"../reactivity/reactiveHints.ts\";\nimport { tryResolve } from \"../utils.ts\";\nimport { PropertyT } from \"./PropertySymbols.ts\";\nimport { RecursiveCycleError } from \"./RecursiveCycleError.ts\";\n\nexport { PropertyT };\n\nexport interface Property<T extends Entity, V> {\n // Differentiate from AsyncMethod\n [PropertyT]: T;\n isLoaded: boolean;\n load(): Promise<V>;\n}\n\nexport interface LoadedProperty<T extends Entity, V> {\n get: V;\n}\n\n/**\n * Creates a calculated derived value from a load hint + lambda.\n *\n * The property can be accessed by default as a promise, with `someProperty.load()`.\n *\n * But if `someProperty` is used as a populate hint, then it can be accessed synchronously,\n * with `someProperty.get`.\n */\nexport function hasProperty<T extends Entity, const H extends LoadHint<T>, V>(\n loadHint: H,\n fn: (entity: Loaded<T, H>) => V,\n): Property<T, V> {\n return lazyField((entity: T, fieldName) => {\n return new PropertyImpl(entity, fieldName, loadHint, fn);\n });\n}\n\n/**\n * Creates a calculated derived value from a load hint + lambda.\n *\n * The property can be accessed by default as a promise, with `someProperty.load()`.\n *\n * But if `someProperty` is used as a populate hint, then it can be accessed synchronously,\n * with `someProperty.get`.\n */\nexport function hasReactiveProperty<T extends Entity, const H extends ReactiveHint<T>, V>(\n reactiveHint: H,\n fn: (entity: Reacted<T, H>) => MaybeReactedPropertyEntity<V>,\n): Property<T, V> {\n return lazyField((entity: T, fieldName) => {\n return new PropertyImpl(entity, fieldName, reactiveHint as any, fn as any, { isReactive: true });\n });\n}\n\nexport class PropertyImpl<T extends Entity, H extends LoadHint<T>, V> implements Property<T, V> {\n // We'll probe for loaded if undefined\n #loaded: boolean | undefined = undefined;\n #isCheckingLoaded = false;\n #loadPromise: any;\n\n readonly #entity: T;\n #hint: H | undefined;\n #reactiveHint: ReactiveHint<T> | undefined;\n constructor(\n entity: T,\n private fieldName: string,\n hint: H | ReactiveHint<T>,\n private fn: (entity: Loaded<T, H>) => V,\n private opts: { isReactive?: boolean } = {},\n ) {\n const { isReactive = false } = opts;\n this.#entity = entity;\n this.#hint = isReactive ? undefined : (hint as H);\n this.#reactiveHint = isReactive ? (hint as ReactiveHint<T>) : undefined;\n }\n\n load(): Promise<V> {\n if (!this.isLoaded) {\n const { loadHint, fn } = this;\n return (this.#loadPromise ??= this.#entity.em.populate(this.#entity, loadHint).then((loaded) => {\n this.#loaded = true;\n return fn(loaded);\n }));\n }\n return tryResolve(() => this.get);\n }\n\n get loadHint(): H {\n if (!this.#hint) {\n // Would be nice to statically (but lazily?) cache this...\n this.#hint = convertToLoadHint(getMetadata(this.#entity), this.#reactiveHint as any) as H;\n }\n return this.#hint;\n }\n\n get reactiveHint(): ReactiveHint<T> | undefined {\n return this.#reactiveHint;\n }\n\n get get(): V {\n return this.fn(this.#entity as Loaded<T, H>);\n }\n\n get isLoaded() {\n // Probe the first time, which is useful for factories that are DeepNew\n if (this.#loaded === undefined) {\n if (this.#isCheckingLoaded) {\n this.#isCheckingLoaded = false;\n throw new RecursiveCycleError({ entity: this.#entity, fieldName: this.fieldName }, [this.#entity]);\n }\n this.#isCheckingLoaded = true;\n this.#loaded = isLoaded(this.#entity, this.loadHint);\n this.#isCheckingLoaded = false;\n }\n return !!this.#loaded;\n }\n\n [PropertyT] = undefined as any as T;\n}\n\n/** Type guard utility for determining if an entity field is a Property. */\nexport function isProperty(maybeProperty: any): maybeProperty is Property<any, any> {\n return maybeProperty instanceof PropertyImpl;\n}\n\n/** Type guard utility for determining if an entity field is a loaded Property. */\nexport function isLoadedProperty(maybeProperty: any): maybeProperty is Property<any, any> & LoadedProperty<any, any> {\n return isProperty(maybeProperty) && maybeProperty.isLoaded;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmCA,SAAgB,YACd,UACA,IACgB;CAChB,OAAOA,kBAAAA,WAAW,QAAW,cAAc;EACzC,OAAO,IAAI,aAAa,QAAQ,WAAW,UAAU,EAAE;CACzD,CAAC;AACH;;;;;;;;;AAUA,SAAgB,oBACd,cACA,IACgB;CAChB,OAAOA,kBAAAA,WAAW,QAAW,cAAc;EACzC,OAAO,IAAI,aAAa,QAAQ,WAAW,cAAqB,IAAW,EAAE,YAAY,KAAK,CAAC;CACjG,CAAC;AACH;AAEA,IAAa,eAAb,MAAgG;CAWpF;CAEA;CACA;CAZV,UAA+B,KAAA;CAC/B,oBAAoB;CACpB;CAEA;CACA;CACA;CACA,YACE,QACA,WACA,MACA,IACA,OAAyC,CAAC,GAC1C;EAJQ,KAAA,YAAA;EAEA,KAAA,KAAA;EACA,KAAA,OAAA;EAER,MAAM,EAAE,aAAa,UAAU;EAC/B,KAAKC,UAAU;EACf,KAAKC,QAAQ,aAAa,KAAA,IAAa;EACvC,KAAKC,gBAAgB,aAAc,OAA2B,KAAA;CAChE;CAEA,OAAmB;EACjB,IAAI,CAAC,KAAK,UAAU;GAClB,MAAM,EAAE,UAAU,OAAO;GACzB,OAAQ,KAAKC,iBAAiB,KAAKH,QAAQ,GAAG,SAAS,KAAKA,SAAS,QAAQ,CAAC,CAAC,MAAM,WAAW;IAC9F,KAAKI,UAAU;IACf,OAAO,GAAG,MAAM;GAClB,CAAC;EACH;EACA,OAAOC,cAAAA,iBAAiB,KAAK,GAAG;CAClC;CAEA,IAAI,WAAc;EAChB,IAAI,CAAC,KAAKJ,OAER,KAAKA,QAAQK,iCAAAA,kBAAkBC,uBAAAA,YAAY,KAAKP,OAAO,GAAG,KAAKE,aAAoB;EAErF,OAAO,KAAKD;CACd;CAEA,IAAI,eAA4C;EAC9C,OAAO,KAAKC;CACd;CAEA,IAAI,MAAS;EACX,OAAO,KAAK,GAAG,KAAKF,OAAuB;CAC7C;CAEA,IAAI,WAAW;EAEb,IAAI,KAAKI,YAAY,KAAA,GAAW;GAC9B,IAAI,KAAKI,mBAAmB;IAC1B,KAAKA,oBAAoB;IACzB,MAAM,IAAIC,sCAAAA,oBAAoB;KAAE,QAAQ,KAAKT;KAAS,WAAW,KAAK;IAAU,GAAG,CAAC,KAAKA,OAAO,CAAC;GACnG;GACA,KAAKQ,oBAAoB;GACzB,KAAKJ,UAAUM,0BAAAA,SAAS,KAAKV,SAAS,KAAK,QAAQ;GACnD,KAAKQ,oBAAoB;EAC3B;EACA,OAAO,CAAC,CAAC,KAAKJ;CAChB;CAEA,CAACO,kCAAAA,aAAa,KAAA;AAChB;;AAGA,SAAgB,WAAW,eAAyD;CAClF,OAAO,yBAAyB;AAClC;;AAGA,SAAgB,iBAAiB,eAAoF;CACnH,OAAO,WAAW,aAAa,KAAK,cAAc;AACpD"}
@@ -1,6 +1,6 @@
1
1
  import { PropertyT } from "./PropertySymbols.cjs";
2
- import { LoadHint, Loaded } from "../loadHints.cjs";
3
- import { MaybeReactedPropertyEntity, Reacted, ReactiveHint } from "../reactiveHints.cjs";
2
+ import { LoadHint, Loaded } from "../loading/loadHints.cjs";
3
+ import { MaybeReactedPropertyEntity, Reacted, ReactiveHint } from "../reactivity/reactiveHints.cjs";
4
4
  import { Entity } from "../Entity.cjs";
5
5
  //#region src/relations/hasProperty.d.ts
6
6
  interface Property<T extends Entity, V> {
@@ -1,6 +1,6 @@
1
1
  import { PropertyT } from "./PropertySymbols.mjs";
2
- import { LoadHint, Loaded } from "../loadHints.mjs";
3
- import { MaybeReactedPropertyEntity, Reacted, ReactiveHint } from "../reactiveHints.mjs";
2
+ import { LoadHint, Loaded } from "../loading/loadHints.mjs";
3
+ import { MaybeReactedPropertyEntity, Reacted, ReactiveHint } from "../reactivity/reactiveHints.mjs";
4
4
  import { Entity } from "../Entity.mjs";
5
5
  //#region src/relations/hasProperty.d.ts
6
6
  interface Property<T extends Entity, V> {
@@ -1,7 +1,7 @@
1
1
  import { PropertyT } from "./PropertySymbols.js";
2
2
  import { RecursiveCycleError } from "./RecursiveCycleError.js";
3
- import { convertToLoadHint } from "../reactiveHints.js";
4
- import { isLoaded } from "../loadHints.js";
3
+ import { convertToLoadHint } from "../reactivity/reactiveHints.js";
4
+ import { isLoaded } from "../loading/loadHints.js";
5
5
  import { tryResolve } from "../utils.js";
6
6
  import { lazyField } from "../newEntity.js";
7
7
  import { getMetadata } from "../EntityMetadata.js";
@@ -1 +1 @@
1
- {"version":3,"file":"hasProperty.js","names":["#entity","#hint","#reactiveHint","#loadPromise","#loaded","#isCheckingLoaded"],"sources":["../../src/relations/hasProperty.ts"],"sourcesContent":["import { type Entity } from \"../Entity.ts\";\nimport { getMetadata } from \"../EntityMetadata.ts\";\nimport { type LoadHint, type Loaded, isLoaded } from \"../loadHints.ts\";\nimport { lazyField } from \"../newEntity.ts\";\nimport {\n type MaybeReactedPropertyEntity,\n type Reacted,\n type ReactiveHint,\n convertToLoadHint,\n} from \"../reactiveHints.ts\";\nimport { tryResolve } from \"../utils.ts\";\nimport { PropertyT } from \"./PropertySymbols.ts\";\nimport { RecursiveCycleError } from \"./RecursiveCycleError.ts\";\n\nexport { PropertyT };\n\nexport interface Property<T extends Entity, V> {\n // Differentiate from AsyncMethod\n [PropertyT]: T;\n isLoaded: boolean;\n load(): Promise<V>;\n}\n\nexport interface LoadedProperty<T extends Entity, V> {\n get: V;\n}\n\n/**\n * Creates a calculated derived value from a load hint + lambda.\n *\n * The property can be accessed by default as a promise, with `someProperty.load()`.\n *\n * But if `someProperty` is used as a populate hint, then it can be accessed synchronously,\n * with `someProperty.get`.\n */\nexport function hasProperty<T extends Entity, const H extends LoadHint<T>, V>(\n loadHint: H,\n fn: (entity: Loaded<T, H>) => V,\n): Property<T, V> {\n return lazyField((entity: T, fieldName) => {\n return new PropertyImpl(entity, fieldName, loadHint, fn);\n });\n}\n\n/**\n * Creates a calculated derived value from a load hint + lambda.\n *\n * The property can be accessed by default as a promise, with `someProperty.load()`.\n *\n * But if `someProperty` is used as a populate hint, then it can be accessed synchronously,\n * with `someProperty.get`.\n */\nexport function hasReactiveProperty<T extends Entity, const H extends ReactiveHint<T>, V>(\n reactiveHint: H,\n fn: (entity: Reacted<T, H>) => MaybeReactedPropertyEntity<V>,\n): Property<T, V> {\n return lazyField((entity: T, fieldName) => {\n return new PropertyImpl(entity, fieldName, reactiveHint as any, fn as any, { isReactive: true });\n });\n}\n\nexport class PropertyImpl<T extends Entity, H extends LoadHint<T>, V> implements Property<T, V> {\n // We'll probe for loaded if undefined\n #loaded: boolean | undefined = undefined;\n #isCheckingLoaded = false;\n #loadPromise: any;\n\n readonly #entity: T;\n #hint: H | undefined;\n #reactiveHint: ReactiveHint<T> | undefined;\n constructor(\n entity: T,\n private fieldName: string,\n hint: H | ReactiveHint<T>,\n private fn: (entity: Loaded<T, H>) => V,\n private opts: { isReactive?: boolean } = {},\n ) {\n const { isReactive = false } = opts;\n this.#entity = entity;\n this.#hint = isReactive ? undefined : (hint as H);\n this.#reactiveHint = isReactive ? (hint as ReactiveHint<T>) : undefined;\n }\n\n load(): Promise<V> {\n if (!this.isLoaded) {\n const { loadHint, fn } = this;\n return (this.#loadPromise ??= this.#entity.em.populate(this.#entity, loadHint).then((loaded) => {\n this.#loaded = true;\n return fn(loaded);\n }));\n }\n return tryResolve(() => this.get);\n }\n\n get loadHint(): H {\n if (!this.#hint) {\n // Would be nice to statically (but lazily?) cache this...\n this.#hint = convertToLoadHint(getMetadata(this.#entity), this.#reactiveHint as any) as H;\n }\n return this.#hint;\n }\n\n get reactiveHint(): ReactiveHint<T> | undefined {\n return this.#reactiveHint;\n }\n\n get get(): V {\n return this.fn(this.#entity as Loaded<T, H>);\n }\n\n get isLoaded() {\n // Probe the first time, which is useful for factories that are DeepNew\n if (this.#loaded === undefined) {\n if (this.#isCheckingLoaded) {\n this.#isCheckingLoaded = false;\n throw new RecursiveCycleError({ entity: this.#entity, fieldName: this.fieldName }, [this.#entity]);\n }\n this.#isCheckingLoaded = true;\n this.#loaded = isLoaded(this.#entity, this.loadHint);\n this.#isCheckingLoaded = false;\n }\n return !!this.#loaded;\n }\n\n [PropertyT] = undefined as any as T;\n}\n\n/** Type guard utility for determining if an entity field is a Property. */\nexport function isProperty(maybeProperty: any): maybeProperty is Property<any, any> {\n return maybeProperty instanceof PropertyImpl;\n}\n\n/** Type guard utility for determining if an entity field is a loaded Property. */\nexport function isLoadedProperty(maybeProperty: any): maybeProperty is Property<any, any> & LoadedProperty<any, any> {\n return isProperty(maybeProperty) && maybeProperty.isLoaded;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,SAAgB,YACd,UACA,IACgB;CAChB,OAAO,WAAW,QAAW,cAAc;EACzC,OAAO,IAAI,aAAa,QAAQ,WAAW,UAAU,EAAE;CACzD,CAAC;AACH;;;;;;;;;AAUA,SAAgB,oBACd,cACA,IACgB;CAChB,OAAO,WAAW,QAAW,cAAc;EACzC,OAAO,IAAI,aAAa,QAAQ,WAAW,cAAqB,IAAW,EAAE,YAAY,KAAK,CAAC;CACjG,CAAC;AACH;AAEA,IAAa,eAAb,MAAgG;CAWpF;CAEA;CACA;CAZV,UAA+B,KAAA;CAC/B,oBAAoB;CACpB;CAEA;CACA;CACA;CACA,YACE,QACA,WACA,MACA,IACA,OAAyC,CAAC,GAC1C;EAJQ,KAAA,YAAA;EAEA,KAAA,KAAA;EACA,KAAA,OAAA;EAER,MAAM,EAAE,aAAa,UAAU;EAC/B,KAAKA,UAAU;EACf,KAAKC,QAAQ,aAAa,KAAA,IAAa;EACvC,KAAKC,gBAAgB,aAAc,OAA2B,KAAA;CAChE;CAEA,OAAmB;EACjB,IAAI,CAAC,KAAK,UAAU;GAClB,MAAM,EAAE,UAAU,OAAO;GACzB,OAAQ,KAAKC,iBAAiB,KAAKH,QAAQ,GAAG,SAAS,KAAKA,SAAS,QAAQ,CAAC,CAAC,MAAM,WAAW;IAC9F,KAAKI,UAAU;IACf,OAAO,GAAG,MAAM;GAClB,CAAC;EACH;EACA,OAAO,iBAAiB,KAAK,GAAG;CAClC;CAEA,IAAI,WAAc;EAChB,IAAI,CAAC,KAAKH,OAER,KAAKA,QAAQ,kBAAkB,YAAY,KAAKD,OAAO,GAAG,KAAKE,aAAoB;EAErF,OAAO,KAAKD;CACd;CAEA,IAAI,eAA4C;EAC9C,OAAO,KAAKC;CACd;CAEA,IAAI,MAAS;EACX,OAAO,KAAK,GAAG,KAAKF,OAAuB;CAC7C;CAEA,IAAI,WAAW;EAEb,IAAI,KAAKI,YAAY,KAAA,GAAW;GAC9B,IAAI,KAAKC,mBAAmB;IAC1B,KAAKA,oBAAoB;IACzB,MAAM,IAAI,oBAAoB;KAAE,QAAQ,KAAKL;KAAS,WAAW,KAAK;IAAU,GAAG,CAAC,KAAKA,OAAO,CAAC;GACnG;GACA,KAAKK,oBAAoB;GACzB,KAAKD,UAAU,SAAS,KAAKJ,SAAS,KAAK,QAAQ;GACnD,KAAKK,oBAAoB;EAC3B;EACA,OAAO,CAAC,CAAC,KAAKD;CAChB;CAEA,CAAC,aAAa,KAAA;AAChB;;AAGA,SAAgB,WAAW,eAAyD;CAClF,OAAO,yBAAyB;AAClC;;AAGA,SAAgB,iBAAiB,eAAoF;CACnH,OAAO,WAAW,aAAa,KAAK,cAAc;AACpD"}
1
+ {"version":3,"file":"hasProperty.js","names":["#entity","#hint","#reactiveHint","#loadPromise","#loaded","#isCheckingLoaded"],"sources":["../../src/relations/hasProperty.ts"],"sourcesContent":["import { type Entity } from \"../Entity.ts\";\nimport { getMetadata } from \"../EntityMetadata.ts\";\nimport { type LoadHint, type Loaded, isLoaded } from \"../loading/loadHints.ts\";\nimport { lazyField } from \"../newEntity.ts\";\nimport {\n type MaybeReactedPropertyEntity,\n type Reacted,\n type ReactiveHint,\n convertToLoadHint,\n} from \"../reactivity/reactiveHints.ts\";\nimport { tryResolve } from \"../utils.ts\";\nimport { PropertyT } from \"./PropertySymbols.ts\";\nimport { RecursiveCycleError } from \"./RecursiveCycleError.ts\";\n\nexport { PropertyT };\n\nexport interface Property<T extends Entity, V> {\n // Differentiate from AsyncMethod\n [PropertyT]: T;\n isLoaded: boolean;\n load(): Promise<V>;\n}\n\nexport interface LoadedProperty<T extends Entity, V> {\n get: V;\n}\n\n/**\n * Creates a calculated derived value from a load hint + lambda.\n *\n * The property can be accessed by default as a promise, with `someProperty.load()`.\n *\n * But if `someProperty` is used as a populate hint, then it can be accessed synchronously,\n * with `someProperty.get`.\n */\nexport function hasProperty<T extends Entity, const H extends LoadHint<T>, V>(\n loadHint: H,\n fn: (entity: Loaded<T, H>) => V,\n): Property<T, V> {\n return lazyField((entity: T, fieldName) => {\n return new PropertyImpl(entity, fieldName, loadHint, fn);\n });\n}\n\n/**\n * Creates a calculated derived value from a load hint + lambda.\n *\n * The property can be accessed by default as a promise, with `someProperty.load()`.\n *\n * But if `someProperty` is used as a populate hint, then it can be accessed synchronously,\n * with `someProperty.get`.\n */\nexport function hasReactiveProperty<T extends Entity, const H extends ReactiveHint<T>, V>(\n reactiveHint: H,\n fn: (entity: Reacted<T, H>) => MaybeReactedPropertyEntity<V>,\n): Property<T, V> {\n return lazyField((entity: T, fieldName) => {\n return new PropertyImpl(entity, fieldName, reactiveHint as any, fn as any, { isReactive: true });\n });\n}\n\nexport class PropertyImpl<T extends Entity, H extends LoadHint<T>, V> implements Property<T, V> {\n // We'll probe for loaded if undefined\n #loaded: boolean | undefined = undefined;\n #isCheckingLoaded = false;\n #loadPromise: any;\n\n readonly #entity: T;\n #hint: H | undefined;\n #reactiveHint: ReactiveHint<T> | undefined;\n constructor(\n entity: T,\n private fieldName: string,\n hint: H | ReactiveHint<T>,\n private fn: (entity: Loaded<T, H>) => V,\n private opts: { isReactive?: boolean } = {},\n ) {\n const { isReactive = false } = opts;\n this.#entity = entity;\n this.#hint = isReactive ? undefined : (hint as H);\n this.#reactiveHint = isReactive ? (hint as ReactiveHint<T>) : undefined;\n }\n\n load(): Promise<V> {\n if (!this.isLoaded) {\n const { loadHint, fn } = this;\n return (this.#loadPromise ??= this.#entity.em.populate(this.#entity, loadHint).then((loaded) => {\n this.#loaded = true;\n return fn(loaded);\n }));\n }\n return tryResolve(() => this.get);\n }\n\n get loadHint(): H {\n if (!this.#hint) {\n // Would be nice to statically (but lazily?) cache this...\n this.#hint = convertToLoadHint(getMetadata(this.#entity), this.#reactiveHint as any) as H;\n }\n return this.#hint;\n }\n\n get reactiveHint(): ReactiveHint<T> | undefined {\n return this.#reactiveHint;\n }\n\n get get(): V {\n return this.fn(this.#entity as Loaded<T, H>);\n }\n\n get isLoaded() {\n // Probe the first time, which is useful for factories that are DeepNew\n if (this.#loaded === undefined) {\n if (this.#isCheckingLoaded) {\n this.#isCheckingLoaded = false;\n throw new RecursiveCycleError({ entity: this.#entity, fieldName: this.fieldName }, [this.#entity]);\n }\n this.#isCheckingLoaded = true;\n this.#loaded = isLoaded(this.#entity, this.loadHint);\n this.#isCheckingLoaded = false;\n }\n return !!this.#loaded;\n }\n\n [PropertyT] = undefined as any as T;\n}\n\n/** Type guard utility for determining if an entity field is a Property. */\nexport function isProperty(maybeProperty: any): maybeProperty is Property<any, any> {\n return maybeProperty instanceof PropertyImpl;\n}\n\n/** Type guard utility for determining if an entity field is a loaded Property. */\nexport function isLoadedProperty(maybeProperty: any): maybeProperty is Property<any, any> & LoadedProperty<any, any> {\n return isProperty(maybeProperty) && maybeProperty.isLoaded;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,SAAgB,YACd,UACA,IACgB;CAChB,OAAO,WAAW,QAAW,cAAc;EACzC,OA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W,KAAK;IAAU,GAAG,CAAC,KAAKA,OAAO,CAAC;GACnG;GACA,KAAKK,oBAAoB;GACzB,KAAKD,UAAU,SAAS,KAAKJ,SAAS,KAAK,QAAQ;GACnD,KAAKK,oBAAoB;EAC3B;EACA,OAAO,CAAC,CAAC,KAAKD;CAChB;CAEA,CAAC,aAAa,KAAA;AAChB;;AAGA,SAAgB,WAAW,eAAyD;CAClF,OAAO,yBAAyB;AAClC;;AAGA,SAAgB,iBAAiB,eAAoF;CACnH,OAAO,WAAW,aAAa,KAAK,cAAc;AACpD"}
@@ -1,29 +1,29 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_relations_Collection = require("./Collection.cjs");
3
+ const require_relations_CustomCollection = require("./CustomCollection.cjs");
3
4
  const require_relations_EnumCollection = require("./EnumCollection.cjs");
4
- const require_relations_RecursiveCycleError = require("./RecursiveCycleError.cjs");
5
- const require_relations_hasProperty = require("./hasProperty.cjs");
6
- const require_relations_LazyField = require("./LazyField.cjs");
7
- const require_relations_OneToManyCollection = require("./OneToManyCollection.cjs");
8
- const require_relations_ManyToOneReference = require("./ManyToOneReference.cjs");
9
- const require_relations_Reference = require("./Reference.cjs");
10
- const require_relations_ReactiveReference = require("./ReactiveReference.cjs");
11
- const require_relations_OneToOneReference = require("./OneToOneReference.cjs");
5
+ const require_relations_CustomReference = require("./CustomReference.cjs");
12
6
  const require_relations_ReactiveGetter = require("./ReactiveGetter.cjs");
13
7
  const require_relations_Relation = require("./Relation.cjs");
14
8
  const require_relations_ReadOnlyCollection = require("./ReadOnlyCollection.cjs");
9
+ const require_relations_RecursiveCycleError = require("./RecursiveCycleError.cjs");
15
10
  const require_relations_RecursiveCollection = require("./RecursiveCollection.cjs");
16
- const require_relations_CustomCollection = require("./CustomCollection.cjs");
17
- const require_relations_CustomReference = require("./CustomReference.cjs");
18
11
  const require_relations_hasAsyncMethod = require("./hasAsyncMethod.cjs");
12
+ const require_relations_hasProperty = require("./hasProperty.cjs");
19
13
  const require_relations_AsyncProperty = require("./AsyncProperty.cjs");
14
+ const require_relations_LazyField = require("./LazyField.cjs");
20
15
  const require_relations_hasManyDerived = require("./hasManyDerived.cjs");
21
16
  const require_relations_hasManyThrough = require("./hasManyThrough.cjs");
17
+ const require_relations_Reference = require("./Reference.cjs");
22
18
  const require_relations_hasOneDerived = require("./hasOneDerived.cjs");
23
19
  const require_relations_hasOneThrough = require("./hasOneThrough.cjs");
24
20
  const require_relations_ManyToManyCollection = require("./ManyToManyCollection.cjs");
25
21
  const require_relations_ManyToManyLargeCollection = require("./ManyToManyLargeCollection.cjs");
22
+ const require_relations_OneToManyCollection = require("./OneToManyCollection.cjs");
23
+ const require_relations_ManyToOneReference = require("./ManyToOneReference.cjs");
26
24
  const require_relations_OneToManyLargeCollection = require("./OneToManyLargeCollection.cjs");
25
+ const require_relations_ReactiveReference = require("./ReactiveReference.cjs");
26
+ const require_relations_OneToOneReference = require("./OneToOneReference.cjs");
27
27
  const require_relations_PolymorphicReference = require("./PolymorphicReference.cjs");
28
28
  const require_relations_ReactiveField = require("./ReactiveField.cjs");
29
29
  const require_relations_ReactiveManyToMany = require("./ReactiveManyToMany.cjs");
@@ -1,28 +1,28 @@
1
1
  import { isCollection, isLoadedCollection } from "./Collection.js";
2
+ import { CustomCollection, hasCustomCollection } from "./CustomCollection.js";
2
3
  import { EnumCollectionImpl, hasEnumCollection } from "./EnumCollection.js";
3
- import { RecursiveCycleError } from "./RecursiveCycleError.js";
4
- import { PropertyImpl, hasProperty, hasReactiveProperty, isLoadedProperty, isProperty } from "./hasProperty.js";
5
- import { LazyFieldImpl, hasLazyField, isLazyField, isLoadedLazyField } from "./LazyField.js";
6
- import { OneToManyCollection, hasMany } from "./OneToManyCollection.js";
7
- import { ManyToOneReferenceImpl, hasOne, isManyToOneReference } from "./ManyToOneReference.js";
8
- import { isLoadedReference, isReference } from "./Reference.js";
9
- import { ReactiveReferenceImpl, hasReactiveReference, isReactiveReference } from "./ReactiveReference.js";
10
- import { OneToOneReferenceImpl, hasOneToOne, isLoadedOneToOneReference, isOneToOneReference } from "./OneToOneReference.js";
4
+ import { CustomReference, hasCustomReference } from "./CustomReference.js";
11
5
  import { hasReactiveGetter, isReactiveGetter } from "./ReactiveGetter.js";
12
6
  import { isRelation } from "./Relation.js";
13
7
  import { isLoadedReadOnlyCollection, isReadOnlyCollection } from "./ReadOnlyCollection.js";
8
+ import { RecursiveCycleError } from "./RecursiveCycleError.js";
14
9
  import { hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents } from "./RecursiveCollection.js";
15
- import { CustomCollection, hasCustomCollection } from "./CustomCollection.js";
16
- import { CustomReference, hasCustomReference } from "./CustomReference.js";
17
10
  import { hasAsyncMethod } from "./hasAsyncMethod.js";
11
+ import { PropertyImpl, hasProperty, hasReactiveProperty, isLoadedProperty, isProperty } from "./hasProperty.js";
18
12
  import { AsyncPropertyImpl, hasAsyncProperty, isAsyncProperty, isLoadedAsyncProperty } from "./AsyncProperty.js";
13
+ import { LazyFieldImpl, hasLazyField, isLazyField, isLoadedLazyField } from "./LazyField.js";
19
14
  import { hasManyDerived } from "./hasManyDerived.js";
20
15
  import { hasManyThrough } from "./hasManyThrough.js";
16
+ import { isLoadedReference, isReference } from "./Reference.js";
21
17
  import { hasOneDerived } from "./hasOneDerived.js";
22
18
  import { hasOneThrough } from "./hasOneThrough.js";
23
19
  import { ManyToManyCollection, hasManyToMany } from "./ManyToManyCollection.js";
24
20
  import { ManyToManyLargeCollection, hasLargeManyToMany } from "./ManyToManyLargeCollection.js";
21
+ import { OneToManyCollection, hasMany } from "./OneToManyCollection.js";
22
+ import { ManyToOneReferenceImpl, hasOne, isManyToOneReference } from "./ManyToOneReference.js";
25
23
  import { OneToManyLargeCollection, hasLargeMany } from "./OneToManyLargeCollection.js";
24
+ import { ReactiveReferenceImpl, hasReactiveReference, isReactiveReference } from "./ReactiveReference.js";
25
+ import { OneToOneReferenceImpl, hasOneToOne, isLoadedOneToOneReference, isOneToOneReference } from "./OneToOneReference.js";
26
26
  import { PolymorphicReferenceImpl, hasOnePolymorphic, isPolymorphicReference } from "./PolymorphicReference.js";
27
27
  import { hasReactiveField, isReactiveField } from "./ReactiveField.js";
28
28
  import { ReactiveManyToManyImpl, hasReactiveManyToMany, isReactiveManyToMany } from "./ReactiveManyToMany.js";
package/build/rules.cjs CHANGED
@@ -1,12 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_fields = require("./fields.cjs");
3
- require("./typeMap.cjs");
4
- require("./changes.cjs");
5
3
  const require_relations_Reference = require("./relations/Reference.cjs");
6
- require("./reactiveHints.cjs");
7
- const require_utils = require("./utils.cjs");
8
4
  const require_relations_AsyncReactiveField = require("./relations/AsyncReactiveField.cjs");
9
5
  require("./relations/index.cjs");
6
+ const require_utils = require("./utils.cjs");
7
+ require("./typeMap.cjs");
8
+ require("./changes.cjs");
10
9
  const require_EntityManager = require("./EntityManager.cjs");
11
10
  require("./Entity.cjs");
12
11
  //#region src/rules.ts
@@ -1 +1 @@
1
- {"version":3,"file":"rules.cjs","names":["groupBy","maybePromiseThen","getField","isAsyncReactiveField","isLoadedReference","getEmInternalApi"],"sources":["../src/rules.ts"],"sourcesContent":["import { type Changes, type EntityChanges } from \"./changes.ts\";\nimport { type Entity } from \"./Entity.ts\";\nimport { getEmInternalApi } from \"./EntityManager.ts\";\nimport { getField } from \"./fields.ts\";\nimport { type ReactiveHint } from \"./reactiveHints.ts\";\nimport { type ManyToOneReferenceImpl, isAsyncReactiveField, isLoadedReference } from \"./relations/index.ts\";\nimport { type FieldsOf } from \"./typeMap.ts\";\nimport { type MaybePromise, groupBy, maybePromiseThen } from \"./utils.ts\";\n\nexport enum ValidationCode {\n required = \"required\",\n cannotBeUpdated = \"not-updatable\",\n cannotBeChanged = \"not-changeable\",\n numeric = \"not-numeric\",\n minValue = \"under-min\",\n maxValue = \"over-max\",\n}\n\n/**\n * The return type of `ValidationRule` lambdas.\n *\n * We're flexible and allow rules to return a variety of shapes, like just a string, string[], etc.\n *\n * Returning `undefined` means the rule passed.\n */\nexport type ValidationRuleResult = string | string[] | GenericError | GenericError[] | undefined | void;\n\n/** An entity validation rule. */\nexport type ValidationRule<T extends Entity> = (entity: T) => MaybePromise<ValidationRuleResult>;\n\n/** Internal metadata for an async/reactive validation rule. */\nexport type ValidationRuleInternal<T extends Entity> = {\n name: string;\n hint: ReactiveHint<T> | undefined;\n fn: ValidationRule<T>;\n};\n\n/** A generic error which contains a message, and optional field/codes. */\nexport type GenericError = { message: string; field?: string; code?: string };\n\n/** Combines the GenericError with the `entity` that caused it. */\nexport type ValidationError = { entity: Entity } & GenericError;\n\nexport type ValidationRuleOptsFn<T extends Entity> = (entity: T) => MaybePromise<boolean>;\nexport type ValidationRuleOpts<T extends Entity> = {\n unless?: ValidationRuleOptsFn<T>;\n if?: ValidationRuleOptsFn<T>;\n};\n\nfunction errorMessage(errors: ValidationError[]): string {\n if (errors.length === 1) {\n return `Validation error: ${errors[0].entity.toString()} ${errors[0].message}`;\n } else {\n const message = [...groupBy(errors, (e) => e.entity.toString()).entries()]\n .map(([entityToString, errors]) => `${entityToString} ${errors.map((e) => e.message).join(\", \")}`)\n .join(\", \");\n return `Validation errors (${errors.length}): ${message}`;\n }\n}\n\nexport class ValidationErrors extends Error {\n public errors: Array<GenericError | ValidationError>;\n public readonly toJSON: () => string;\n constructor(errors: ValidationError[]);\n constructor(message: string);\n constructor(messageOrErrors: ValidationError[] | string) {\n super(typeof messageOrErrors === \"string\" ? messageOrErrors : errorMessage(messageOrErrors));\n this.errors = typeof messageOrErrors === \"string\" ? [{ message: messageOrErrors }] : messageOrErrors;\n // Jest clones without prototype, so explictly setting this as a property rather than a class method\n // https://github.com/jestjs/jest/issues/11958\n this.toJSON = () => `ValidationErrors: ${this.message}`;\n }\n}\n\nfunction ruleWithOpts<T extends Entity>(\n opts: ValidationRuleOpts<T> | undefined,\n fn: (entity: T) => ValidationRuleResult,\n): ValidationRule<T> {\n return (entity) => {\n // Since all of our rules are sync, we run the rule first, then check if we should have run it second since this\n // may be an async operation. This way we can avoid running promises if we don't have to.\n const result = fn(entity);\n if (result === undefined) return;\n const { unless, if: _if } = opts ?? {};\n if (unless === undefined && _if === undefined) return result;\n const shouldRun = [unless ?? (() => false), _if ?? (() => true)].map((fn) => fn(entity));\n return maybePromiseThen(\n shouldRun.some((r) => r instanceof Promise) ? Promise.all(shouldRun) : (shouldRun as boolean[]),\n ([unless, _if]) => (!unless && _if ? result : undefined),\n );\n };\n}\n\n/**\n * The fields of `F` that have their own column, i.e. what a required rule can check.\n *\n * The filter is an allow-list (\"keep kinds primitive/enum/m2o/poly\"), not a deny-list (\"drop kind\n * o2o\"), because of how it degrades when `T` is generic/uninferred: `FieldsOf<T>` is then `never`,\n * and `never extends X` is true for any `X`, so an allow-list keeps every key (permissive, exactly\n * like the unfiltered `keyof FieldsOf<T>` before it) while a deny-list would drop every key and\n * break valid calls like `newRequiredRule(\"city\")`.\n */\ntype ColumnBackedFields<F> = {\n [K in keyof F as F[K] extends { kind: \"primitive\" | \"enum\" | \"m2o\" | \"poly\" } ? K : never]: F[K];\n};\n\n/**\n * Creates a validation rule for required fields.\n *\n * This is added automatically by codegen to entities based on FK not-nulls.\n */\nexport function newRequiredRule<T extends Entity>(\n key: keyof ColumnBackedFields<FieldsOf<T>> & string,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n // Use getField so that we peer through relations\n if (getField(entity, key) === undefined) {\n // Sanity check for AsyncReactiveFields--this should be cheap to just always do; alternatively we could\n // have a RQF-specific `rqfRequiredRule` so that other `newRequiredRule` users don't pay the cost of these\n // two `if` checks`.\n if (entity.isNewEntity && isAsyncReactiveField((entity as any)[key])) {\n throw new Error(\n `AsyncReactiveField ${entity.constructor.name}.${key} must have a default value, either in the database or with config.setDefault (see the 4th step in https://joist-orm.io/modeling/reactive-fields/#async-reactive-fields.`,\n );\n }\n return { field: key, code: ValidationCode.required, message: `${key} is required` };\n }\n });\n}\n\n/**\n * Like `newRequiredRule`, but for `lazy` columns (i.e. codegen only wires this up for `lazy` fields).\n *\n * On an already-persisted entity that hasn't loaded the column, we skip the check rather than force-load\n * (or falsely fail) a value that was required when the row was last saved. It still fires on create and\n * when the field is explicitly loaded-then-unset.\n */\nexport function newRequiredLazyFieldRule<T extends Entity>(\n key: keyof FieldsOf<T> & string,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n if (!entity.isNewEntity && !(entity as any)[key].isLoaded) return;\n if (getField(entity, key) === undefined) {\n return { field: key, code: ValidationCode.required, message: `${key} is required` };\n }\n });\n}\n\n/**\n * Creates a validation rule that a field cannot be updated; it can only be set on creation.\n *\n * If the optional `unless` function returns true, then the update is allowed.\n */\nexport function cannotBeUpdated<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n opts?: ValidationRuleOpts<T>,\n): CannotBeUpdatedRule<T>;\nexport function cannotBeUpdated<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n unless?: ValidationRuleOptsFn<T>,\n): CannotBeUpdatedRule<T>;\nexport function cannotBeUpdated<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n optsOrUnless?: ValidationRuleOpts<T> | ValidationRuleOptsFn<T>,\n): CannotBeUpdatedRule<T> {\n const opts = typeof optsOrUnless === \"function\" ? { unless: optsOrUnless } : (optsOrUnless ?? {});\n const fn = ruleWithOpts(opts, (entity: T) => {\n // For now putting the `EntityChanges` cast here to avoid breaking cannotBeUpdated rules\n // on base types, see Publisher.ts's `cannotBeUpdated(\"type\")` repro.\n if ((entity as any as EntityChanges<T>).changes[field].hasUpdated) {\n const value = (entity as any)[field];\n // If we're being changed b/c of an em.merge, that is okay\n if (isLoadedReference(value) && getEmInternalApi(entity.em).isMerging(value.get)) return;\n return { field, code: ValidationCode.cannotBeUpdated, message: `${field} cannot be updated` };\n }\n return;\n });\n return Object.assign(fn, { field, immutable: opts.unless === undefined && opts.if === undefined });\n}\n\n/**\n * Creates a validation rule that a field cannot be changed once set.\n *\n * If the optional `unless` function returns true, then the update is allowed.\n */\nexport function cannotBeChanged<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n opts?: ValidationRuleOpts<T>,\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity: T) => {\n const changes = (entity as any as EntityChanges<T>).changes[field];\n if (changes.kind === \"m2m\" || changes.kind === \"o2m\" || changes.kind === \"m2mEnum\") {\n throw new Error(\"cannotBeChanged is only supported on primitive & m2o fields\");\n } else if (changes.hasUpdated) {\n const originalValue = changes.originalValue;\n if (originalValue === undefined) return;\n const value = getField(entity, field);\n if (getEmInternalApi(entity.em).isMerging(value)) return;\n return { field, code: ValidationCode.cannotBeChanged, message: `${field} cannot be changed` };\n }\n return;\n });\n}\n\ntype CannotBeUpdatedRule<T extends Entity> = ValidationRule<T> & { field: string; immutable: boolean };\n\nexport function isCannotBeUpdatedRule(rule: Function): rule is CannotBeUpdatedRule<any> {\n return \"field\" in rule && \"immutable\" in rule;\n}\n\n/** For STI, enforces subtype-specific relations/FKs at runtime. */\nexport function mustBeSubType<T extends Entity, K extends keyof Changes<T> & string>(\n relationName: K,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n const m2o = (entity as any)[relationName] as ManyToOneReferenceImpl<any, any, any>;\n const other = m2o.get;\n const otherCstr = m2o.otherMeta.cstr;\n if (other && !(other instanceof otherCstr)) {\n return `${relationName} must be a ${otherCstr.name} not ${other}`;\n }\n });\n}\n\n/**\n * Creates a validation rule that a field value cannot be smaller than a\n * certain value.\n *\n * @param field The field to validate\n * @param minValue The inclusive minimum value. e.g 0 range is [0, Infinity]\n * @param opts Optional validation rule options that control when the rule should run:\n * - unless: Function that returns true to skip validation\n * - if: Function that returns true to run validation\n *\n * @example\n * // Age cannot be smaller than 0\n * config.addRule(minValueRule(\"age\", 0));\n */\nexport function minValueRule<T extends Entity, K extends keyof T & string>(\n field: K,\n minValue: number,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n const value = entity[field];\n // Ignore undefined and null values. These should be handled by required rules\n if (value === undefined || value === null) return;\n // Show an error when the value type is not a number\n if (typeof value !== \"number\") {\n return { field, code: ValidationCode.numeric, message: `${field} must be a number` };\n }\n // Show an error when the value is smaller than the minimum value\n if (value < minValue) {\n return {\n field,\n code: ValidationCode.minValue,\n message: `${field} must be greater than or equal to ${minValue}`,\n };\n }\n return;\n });\n}\n\n/**\n * Creates a validation rule that a field value cannot be greater than a\n * certain value.\n *\n * @param field The field to validate\n * @param maxValue The include maximum value. e.g 10 range is [-Infinity, 10]\n * @param opts Optional validation rule options that control when the rule should run:\n * - unless: Function that returns true to skip validation\n * - if: Function that returns true to run validation\n *\n * @example\n * // Age cannot be greater than 150\n * config.addRule(maxValueRule(\"age\", 150));\n */\nexport function maxValueRule<T extends Entity, K extends keyof T & string>(\n field: K,\n maxValue: number,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n const value = entity[field];\n // Ignore undefined and null values. These should be handled by required rules\n if (value === undefined || value === null) return;\n // Show an error when the value type is not a number\n if (typeof value !== \"number\") {\n return { field, code: ValidationCode.numeric, message: `${field} must be a number` };\n }\n // Show an error when the value is smaller than the minimum value\n if (value > maxValue) {\n return {\n field,\n code: ValidationCode.maxValue,\n message: `${field} must be smaller than or equal to ${maxValue}`,\n };\n }\n return;\n });\n}\n\n/**\n * Creates a validation rule that a field value must be within a range of\n * certain values\n *\n * @param field The field to validate\n * @param minValue The inclusive minimum value. e.g 0 [0, Infinity]\n * @param maxValue The include maximum value. e.g 10 [-Infinity, 10]\n * @param opts Optional validation rule options that control when the rule should run:\n * - unless: Function that returns true to skip validation\n * - if: Function that returns true to run validation * @example\n *\n * // Age must be between 0 and 150\n * config.addRule(rangeValueRule(\"age\", 0, 150));\n */\nexport function rangeValueRule<T extends Entity, K extends keyof T & string>(\n field: K,\n minValue: number,\n maxValue: number,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n // Check min and max value rules. Because these are called without opts, it should be safe to treat them as sync.\n const minValueResult = minValueRule<T, K>(field, minValue)(entity) as ValidationRuleResult;\n const maxValueResult = maxValueRule<T, K>(field, maxValue)(entity) as ValidationRuleResult;\n // Return any errors or nothing\n if (minValueResult) return minValueResult;\n if (maxValueResult) return maxValueResult;\n return;\n });\n}\n"],"mappings":";;;;;;;;;;;;AASA,IAAY,iBAAL,yBAAA,gBAAA;CACL,eAAA,cAAA;CACA,eAAA,qBAAA;CACA,eAAA,qBAAA;CACA,eAAA,aAAA;CACA,eAAA,cAAA;CACA,eAAA,cAAA;;AACF,EAAA,CAAA,CAAA;AAiCA,SAAS,aAAa,QAAmC;CACvD,IAAI,OAAO,WAAW,GACpB,OAAO,qBAAqB,OAAO,EAAE,CAAC,OAAO,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC;MAChE;EACL,MAAM,UAAU,CAAC,GAAGA,cAAAA,QAAQ,SAAS,MAAM,EAAE,OAAO,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CACvE,KAAK,CAAC,gBAAgB,YAAY,GAAG,eAAe,GAAG,OAAO,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CACjG,KAAK,IAAI;EACZ,OAAO,sBAAsB,OAAO,OAAO,KAAK;CAClD;AACF;AAEA,IAAa,mBAAb,cAAsC,MAAM;CAC1C;CACA;CAGA,YAAY,iBAA6C;EACvD,MAAM,OAAO,oBAAoB,WAAW,kBAAkB,aAAa,eAAe,CAAC;EAC3F,KAAK,SAAS,OAAO,oBAAoB,WAAW,CAAC,EAAE,SAAS,gBAAgB,CAAC,IAAI;EAGrF,KAAK,eAAe,qBAAqB,KAAK;CAChD;AACF;AAEA,SAAS,aACP,MACA,IACmB;CACnB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ACpC,MAAM,QAAQ,OAAO;EAErB,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM;EAE3C,IAAI,OAAO,UAAU,UACnB,OAAO;GAAE;GAAO,MAAA;GAA8B,SAAS,GAAG,MAAM;EAAmB;EAGrF,IAAI,QAAQ,UACV,OAAO;GACL;GACA,MAAA;GACA,SAAS,GAAG,MAAM,oCAAoC;EACxD;CAGJ,CAAC;AACH;;;;;;;;;;;;;;;AAgBA,SAAgB,aACd,OACA,UACA,OAA8B,CAAC,GACZ;CACnB,OAAO,aAAa,OAAO,WAAW;EACpC,MAAM,QAAQ,OAAO;EAErB,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM;EAE3C,IAAI,OAAO,UAAU,UACnB,OAAO;GAAE;GAAO,MAAA;GAA8B,SAAS,GAAG,MAAM;EAAmB;EAGrF,IAAI,QAAQ,UACV,OAAO;GACL;GACA,MAAA;GACA,SAAS,GAAG,MAAM,oCAAoC;EACxD;CAGJ,CAAC;AACH;;;;;;;;;;;;;;;AAgBA,SAAgB,eACd,OACA,UACA,UACA,OAA8B,CAAC,GACZ;CACnB,OAAO,aAAa,OAAO,WAAW;EAEpC,MAAM,iBAAiB,aAAmB,OAAO,QAAQ,CAAC,CAAC,MAAM;EACjE,MAAM,iBAAiB,aAAmB,OAAO,QAAQ,CAAC,CAAC,MAAM;EAEjE,IAAI,gBAAgB,OAAO;EAC3B,IAAI,gBAAgB,OAAO;CAE7B,CAAC;AACH"}
1
+ {"version":3,"file":"rules.cjs","names":["groupBy","maybePromiseThen","getField","isAsyncReactiveField","isLoadedReference","getEmInternalApi"],"sources":["../src/rules.ts"],"sourcesContent":["import { type Changes, type EntityChanges } from \"./changes.ts\";\nimport { type Entity } from \"./Entity.ts\";\nimport { getEmInternalApi } from \"./EntityManager.ts\";\nimport { getField } from \"./fields.ts\";\nimport type { ReactiveHint } from \"./reactivity/reactiveHints.ts\";\nimport { type ManyToOneReferenceImpl, isAsyncReactiveField, isLoadedReference } from \"./relations/index.ts\";\nimport { type FieldsOf } from \"./typeMap.ts\";\nimport { type MaybePromise, groupBy, maybePromiseThen } from \"./utils.ts\";\n\nexport enum ValidationCode {\n required = \"required\",\n cannotBeUpdated = \"not-updatable\",\n cannotBeChanged = \"not-changeable\",\n numeric = \"not-numeric\",\n minValue = \"under-min\",\n maxValue = \"over-max\",\n}\n\n/**\n * The return type of `ValidationRule` lambdas.\n *\n * We're flexible and allow rules to return a variety of shapes, like just a string, string[], etc.\n *\n * Returning `undefined` means the rule passed.\n */\nexport type ValidationRuleResult = string | string[] | GenericError | GenericError[] | undefined | void;\n\n/** An entity validation rule. */\nexport type ValidationRule<T extends Entity> = (entity: T) => MaybePromise<ValidationRuleResult>;\n\n/** Internal metadata for an async/reactive validation rule. */\nexport type ValidationRuleInternal<T extends Entity> = {\n name: string;\n hint: ReactiveHint<T> | undefined;\n fn: ValidationRule<T>;\n};\n\n/** A generic error which contains a message, and optional field/codes. */\nexport type GenericError = { message: string; field?: string; code?: string };\n\n/** Combines the GenericError with the `entity` that caused it. */\nexport type ValidationError = { entity: Entity } & GenericError;\n\nexport type ValidationRuleOptsFn<T extends Entity> = (entity: T) => MaybePromise<boolean>;\nexport type ValidationRuleOpts<T extends Entity> = {\n unless?: ValidationRuleOptsFn<T>;\n if?: ValidationRuleOptsFn<T>;\n};\n\nfunction errorMessage(errors: ValidationError[]): string {\n if (errors.length === 1) {\n return `Validation error: ${errors[0].entity.toString()} ${errors[0].message}`;\n } else {\n const message = [...groupBy(errors, (e) => e.entity.toString()).entries()]\n .map(([entityToString, errors]) => `${entityToString} ${errors.map((e) => e.message).join(\", \")}`)\n .join(\", \");\n return `Validation errors (${errors.length}): ${message}`;\n }\n}\n\nexport class ValidationErrors extends Error {\n public errors: Array<GenericError | ValidationError>;\n public readonly toJSON: () => string;\n constructor(errors: ValidationError[]);\n constructor(message: string);\n constructor(messageOrErrors: ValidationError[] | string) {\n super(typeof messageOrErrors === \"string\" ? messageOrErrors : errorMessage(messageOrErrors));\n this.errors = typeof messageOrErrors === \"string\" ? [{ message: messageOrErrors }] : messageOrErrors;\n // Jest clones without prototype, so explictly setting this as a property rather than a class method\n // https://github.com/jestjs/jest/issues/11958\n this.toJSON = () => `ValidationErrors: ${this.message}`;\n }\n}\n\nfunction ruleWithOpts<T extends Entity>(\n opts: ValidationRuleOpts<T> | undefined,\n fn: (entity: T) => ValidationRuleResult,\n): ValidationRule<T> {\n return (entity) => {\n // Since all of our rules are sync, we run the rule first, then check if we should have run it second since this\n // may be an async operation. This way we can avoid running promises if we don't have to.\n const result = fn(entity);\n if (result === undefined) return;\n const { unless, if: _if } = opts ?? {};\n if (unless === undefined && _if === undefined) return result;\n const shouldRun = [unless ?? (() => false), _if ?? (() => true)].map((fn) => fn(entity));\n return maybePromiseThen(\n shouldRun.some((r) => r instanceof Promise) ? Promise.all(shouldRun) : (shouldRun as boolean[]),\n ([unless, _if]) => (!unless && _if ? result : undefined),\n );\n };\n}\n\n/**\n * The fields of `F` that have their own column, i.e. what a required rule can check.\n *\n * The filter is an allow-list (\"keep kinds primitive/enum/m2o/poly\"), not a deny-list (\"drop kind\n * o2o\"), because of how it degrades when `T` is generic/uninferred: `FieldsOf<T>` is then `never`,\n * and `never extends X` is true for any `X`, so an allow-list keeps every key (permissive, exactly\n * like the unfiltered `keyof FieldsOf<T>` before it) while a deny-list would drop every key and\n * break valid calls like `newRequiredRule(\"city\")`.\n */\ntype ColumnBackedFields<F> = {\n [K in keyof F as F[K] extends { kind: \"primitive\" | \"enum\" | \"m2o\" | \"poly\" } ? K : never]: F[K];\n};\n\n/**\n * Creates a validation rule for required fields.\n *\n * This is added automatically by codegen to entities based on FK not-nulls.\n */\nexport function newRequiredRule<T extends Entity>(\n key: keyof ColumnBackedFields<FieldsOf<T>> & string,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n // Use getField so that we peer through relations\n if (getField(entity, key) === undefined) {\n // Sanity check for AsyncReactiveFields--this should be cheap to just always do; alternatively we could\n // have a RQF-specific `rqfRequiredRule` so that other `newRequiredRule` users don't pay the cost of these\n // two `if` checks`.\n if (entity.isNewEntity && isAsyncReactiveField((entity as any)[key])) {\n throw new Error(\n `AsyncReactiveField ${entity.constructor.name}.${key} must have a default value, either in the database or with config.setDefault (see the 4th step in https://joist-orm.io/modeling/reactive-fields/#async-reactive-fields.`,\n );\n }\n return { field: key, code: ValidationCode.required, message: `${key} is required` };\n }\n });\n}\n\n/**\n * Like `newRequiredRule`, but for `lazy` columns (i.e. codegen only wires this up for `lazy` fields).\n *\n * On an already-persisted entity that hasn't loaded the column, we skip the check rather than force-load\n * (or falsely fail) a value that was required when the row was last saved. It still fires on create and\n * when the field is explicitly loaded-then-unset.\n */\nexport function newRequiredLazyFieldRule<T extends Entity>(\n key: keyof FieldsOf<T> & string,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n if (!entity.isNewEntity && !(entity as any)[key].isLoaded) return;\n if (getField(entity, key) === undefined) {\n return { field: key, code: ValidationCode.required, message: `${key} is required` };\n }\n });\n}\n\n/**\n * Creates a validation rule that a field cannot be updated; it can only be set on creation.\n *\n * If the optional `unless` function returns true, then the update is allowed.\n */\nexport function cannotBeUpdated<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n opts?: ValidationRuleOpts<T>,\n): CannotBeUpdatedRule<T>;\nexport function cannotBeUpdated<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n unless?: ValidationRuleOptsFn<T>,\n): CannotBeUpdatedRule<T>;\nexport function cannotBeUpdated<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n optsOrUnless?: ValidationRuleOpts<T> | ValidationRuleOptsFn<T>,\n): CannotBeUpdatedRule<T> {\n const opts = typeof optsOrUnless === \"function\" ? { unless: optsOrUnless } : (optsOrUnless ?? {});\n const fn = ruleWithOpts(opts, (entity: T) => {\n // For now putting the `EntityChanges` cast here to avoid breaking cannotBeUpdated rules\n // on base types, see Publisher.ts's `cannotBeUpdated(\"type\")` repro.\n if ((entity as any as EntityChanges<T>).changes[field].hasUpdated) {\n const value = (entity as any)[field];\n // If we're being changed b/c of an em.merge, that is okay\n if (isLoadedReference(value) && getEmInternalApi(entity.em).isMerging(value.get)) return;\n return { field, code: ValidationCode.cannotBeUpdated, message: `${field} cannot be updated` };\n }\n return;\n });\n return Object.assign(fn, { field, immutable: opts.unless === undefined && opts.if === undefined });\n}\n\n/**\n * Creates a validation rule that a field cannot be changed once set.\n *\n * If the optional `unless` function returns true, then the update is allowed.\n */\nexport function cannotBeChanged<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n opts?: ValidationRuleOpts<T>,\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity: T) => {\n const changes = (entity as any as EntityChanges<T>).changes[field];\n if (changes.kind === \"m2m\" || changes.kind === \"o2m\" || changes.kind === \"m2mEnum\") {\n throw new Error(\"cannotBeChanged is only supported on primitive & m2o fields\");\n } else if (changes.hasUpdated) {\n const originalValue = changes.originalValue;\n if (originalValue === undefined) return;\n const value = getField(entity, field);\n if (getEmInternalApi(entity.em).isMerging(value)) return;\n return { field, code: ValidationCode.cannotBeChanged, message: `${field} cannot be changed` };\n }\n return;\n });\n}\n\ntype CannotBeUpdatedRule<T extends Entity> = ValidationRule<T> & { field: string; immutable: boolean };\n\nexport function isCannotBeUpdatedRule(rule: Function): rule is CannotBeUpdatedRule<any> {\n return \"field\" in rule && \"immutable\" in rule;\n}\n\n/** For STI, enforces subtype-specific relations/FKs at runtime. */\nexport function mustBeSubType<T extends Entity, K extends keyof Changes<T> & string>(\n relationName: K,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n const m2o = (entity as any)[relationName] as ManyToOneReferenceImpl<any, any, any>;\n const other = m2o.get;\n const otherCstr = m2o.otherMeta.cstr;\n if (other && !(other instanceof otherCstr)) {\n return `${relationName} must be a ${otherCstr.name} not ${other}`;\n }\n });\n}\n\n/**\n * Creates a validation rule that a field value cannot be smaller than a\n * certain value.\n *\n * @param field The field to validate\n * @param minValue The inclusive minimum value. e.g 0 range is [0, Infinity]\n * @param opts Optional validation rule options that control when the rule should run:\n * - unless: Function that returns true to skip validation\n * - if: Function that returns true to run validation\n *\n * @example\n * // Age cannot be smaller than 0\n * config.addRule(minValueRule(\"age\", 0));\n */\nexport function minValueRule<T extends Entity, K extends keyof T & string>(\n field: K,\n minValue: number,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n const value = entity[field];\n // Ignore undefined and null values. These should be handled by required rules\n if (value === undefined || value === null) return;\n // Show an error when the value type is not a number\n if (typeof value !== \"number\") {\n return { field, code: ValidationCode.numeric, message: `${field} must be a number` };\n }\n // Show an error when the value is smaller than the minimum value\n if (value < minValue) {\n return {\n field,\n code: ValidationCode.minValue,\n message: `${field} must be greater than or equal to ${minValue}`,\n };\n }\n return;\n });\n}\n\n/**\n * Creates a validation rule that a field value cannot be greater than a\n * certain value.\n *\n * @param field The field to validate\n * @param maxValue The include maximum value. e.g 10 range is [-Infinity, 10]\n * @param opts Optional validation rule options that control when the rule should run:\n * - unless: Function that returns true to skip validation\n * - if: Function that returns true to run validation\n *\n * @example\n * // Age cannot be greater than 150\n * config.addRule(maxValueRule(\"age\", 150));\n */\nexport function maxValueRule<T extends Entity, K extends keyof T & string>(\n field: K,\n maxValue: number,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n const value = entity[field];\n // Ignore undefined and null values. These should be handled by required rules\n if (value === undefined || value === null) return;\n // Show an error when the value type is not a number\n if (typeof value !== \"number\") {\n return { field, code: ValidationCode.numeric, message: `${field} must be a number` };\n }\n // Show an error when the value is smaller than the minimum value\n if (value > maxValue) {\n return {\n field,\n code: ValidationCode.maxValue,\n message: `${field} must be smaller than or equal to ${maxValue}`,\n };\n }\n return;\n });\n}\n\n/**\n * Creates a validation rule that a field value must be within a range of\n * certain values\n *\n * @param field The field to validate\n * @param minValue The inclusive minimum value. e.g 0 [0, Infinity]\n * @param maxValue The include maximum value. e.g 10 [-Infinity, 10]\n * @param opts Optional validation rule options that control when the rule should run:\n * - unless: Function that returns true to skip validation\n * - if: Function that returns true to run validation * @example\n *\n * // Age must be between 0 and 150\n * config.addRule(rangeValueRule(\"age\", 0, 150));\n */\nexport function rangeValueRule<T extends Entity, K extends keyof T & string>(\n field: K,\n minValue: number,\n maxValue: number,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n // Check min and max value rules. Because these are called without opts, it should be safe to treat them as sync.\n const minValueResult = minValueRule<T, K>(field, minValue)(entity) as ValidationRuleResult;\n const maxValueResult = maxValueRule<T, K>(field, maxValue)(entity) as ValidationRuleResult;\n // Return any errors or nothing\n if (minValueResult) return minValueResult;\n if (maxValueResult) return maxValueResult;\n return;\n });\n}\n"],"mappings":";;;;;;;;;;;AASA,IAAY,iBAAL,yBAAA,gBAAA;CACL,eAAA,cAAA;CACA,eAAA,qBAAA;CACA,eAAA,qBAAA;CACA,eAAA,aAAA;CACA,eAAA,cAAA;CACA,eAAA,cAAA;;AACF,EAAA,CAAA,CAAA;AAiCA,SAAS,aAAa,QAAmC;CACvD,IAAI,OAAO,WAAW,GACpB,OAAO,qBAAqB,OAAO,EAAE,CAAC,OAAO,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC;MAChE;EACL,MAAM,UAAU,CAAC,GAAGA,cAAAA,QAAQ,SAAS,MAAM,EAAE,OAAO,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CACvE,KAAK,CAAC,gBAAgB,YAAY,GAAG,eAAe,GAAG,OAAO,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CACjG,KAAK,IAAI;EACZ,OAAO,sBAAsB,OAAO,OAAO,KAAK;CAClD;AACF;AAEA,IAAa,mBAAb,cAAsC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2
  import { Changes } from "./changes.cjs";
3
3
  import { MaybePromise } from "./utils.cjs";
4
- import { ReactiveHint } from "./reactiveHints.cjs";
4
+ import { ReactiveHint } from "./reactivity/reactiveHints.cjs";
5
5
  import { Entity } from "./Entity.cjs";
6
6
  //#region src/rules.d.ts
7
7
  declare enum ValidationCode {
package/build/rules.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { FieldsOf } from "./typeMap.mjs";
2
2
  import { Changes } from "./changes.mjs";
3
3
  import { MaybePromise } from "./utils.mjs";
4
- import { ReactiveHint } from "./reactiveHints.mjs";
4
+ import { ReactiveHint } from "./reactivity/reactiveHints.mjs";
5
5
  import { Entity } from "./Entity.mjs";
6
6
  //#region src/rules.d.ts
7
7
  declare enum ValidationCode {
package/build/rules.js CHANGED
@@ -1,11 +1,10 @@
1
1
  import { getField } from "./fields.js";
2
- import "./typeMap.js";
3
- import "./changes.js";
4
2
  import { isLoadedReference } from "./relations/Reference.js";
5
- import "./reactiveHints.js";
6
- import { groupBy, maybePromiseThen } from "./utils.js";
7
3
  import { isAsyncReactiveField } from "./relations/AsyncReactiveField.js";
8
4
  import "./relations/index.js";
5
+ import { groupBy, maybePromiseThen } from "./utils.js";
6
+ import "./typeMap.js";
7
+ import "./changes.js";
9
8
  import { getEmInternalApi } from "./EntityManager.js";
10
9
  import "./Entity.js";
11
10
  //#region src/rules.ts
@@ -1 +1 @@
1
- {"version":3,"file":"rules.js","names":[],"sources":["../src/rules.ts"],"sourcesContent":["import { type Changes, type EntityChanges } from \"./changes.ts\";\nimport { type Entity } from \"./Entity.ts\";\nimport { getEmInternalApi } from \"./EntityManager.ts\";\nimport { getField } from \"./fields.ts\";\nimport { type ReactiveHint } from \"./reactiveHints.ts\";\nimport { type ManyToOneReferenceImpl, isAsyncReactiveField, isLoadedReference } from \"./relations/index.ts\";\nimport { type FieldsOf } from \"./typeMap.ts\";\nimport { type MaybePromise, groupBy, maybePromiseThen } from \"./utils.ts\";\n\nexport enum ValidationCode {\n required = \"required\",\n cannotBeUpdated = \"not-updatable\",\n cannotBeChanged = \"not-changeable\",\n numeric = \"not-numeric\",\n minValue = \"under-min\",\n maxValue = \"over-max\",\n}\n\n/**\n * The return type of `ValidationRule` lambdas.\n *\n * We're flexible and allow rules to return a variety of shapes, like just a string, string[], etc.\n *\n * Returning `undefined` means the rule passed.\n */\nexport type ValidationRuleResult = string | string[] | GenericError | GenericError[] | undefined | void;\n\n/** An entity validation rule. */\nexport type ValidationRule<T extends Entity> = (entity: T) => MaybePromise<ValidationRuleResult>;\n\n/** Internal metadata for an async/reactive validation rule. */\nexport type ValidationRuleInternal<T extends Entity> = {\n name: string;\n hint: ReactiveHint<T> | undefined;\n fn: ValidationRule<T>;\n};\n\n/** A generic error which contains a message, and optional field/codes. */\nexport type GenericError = { message: string; field?: string; code?: string };\n\n/** Combines the GenericError with the `entity` that caused it. */\nexport type ValidationError = { entity: Entity } & GenericError;\n\nexport type ValidationRuleOptsFn<T extends Entity> = (entity: T) => MaybePromise<boolean>;\nexport type ValidationRuleOpts<T extends Entity> = {\n unless?: ValidationRuleOptsFn<T>;\n if?: ValidationRuleOptsFn<T>;\n};\n\nfunction errorMessage(errors: ValidationError[]): string {\n if (errors.length === 1) {\n return `Validation error: ${errors[0].entity.toString()} ${errors[0].message}`;\n } else {\n const message = [...groupBy(errors, (e) => e.entity.toString()).entries()]\n .map(([entityToString, errors]) => `${entityToString} ${errors.map((e) => e.message).join(\", \")}`)\n .join(\", \");\n return `Validation errors (${errors.length}): ${message}`;\n }\n}\n\nexport class ValidationErrors extends Error {\n public errors: Array<GenericError | ValidationError>;\n public readonly toJSON: () => string;\n constructor(errors: ValidationError[]);\n constructor(message: string);\n constructor(messageOrErrors: ValidationError[] | string) {\n super(typeof messageOrErrors === \"string\" ? messageOrErrors : errorMessage(messageOrErrors));\n this.errors = typeof messageOrErrors === \"string\" ? [{ message: messageOrErrors }] : messageOrErrors;\n // Jest clones without prototype, so explictly setting this as a property rather than a class method\n // https://github.com/jestjs/jest/issues/11958\n this.toJSON = () => `ValidationErrors: ${this.message}`;\n }\n}\n\nfunction ruleWithOpts<T extends Entity>(\n opts: ValidationRuleOpts<T> | undefined,\n fn: (entity: T) => ValidationRuleResult,\n): ValidationRule<T> {\n return (entity) => {\n // Since all of our rules are sync, we run the rule first, then check if we should have run it second since this\n // may be an async operation. This way we can avoid running promises if we don't have to.\n const result = fn(entity);\n if (result === undefined) return;\n const { unless, if: _if } = opts ?? {};\n if (unless === undefined && _if === undefined) return result;\n const shouldRun = [unless ?? (() => false), _if ?? (() => true)].map((fn) => fn(entity));\n return maybePromiseThen(\n shouldRun.some((r) => r instanceof Promise) ? Promise.all(shouldRun) : (shouldRun as boolean[]),\n ([unless, _if]) => (!unless && _if ? result : undefined),\n );\n };\n}\n\n/**\n * The fields of `F` that have their own column, i.e. what a required rule can check.\n *\n * The filter is an allow-list (\"keep kinds primitive/enum/m2o/poly\"), not a deny-list (\"drop kind\n * o2o\"), because of how it degrades when `T` is generic/uninferred: `FieldsOf<T>` is then `never`,\n * and `never extends X` is true for any `X`, so an allow-list keeps every key (permissive, exactly\n * like the unfiltered `keyof FieldsOf<T>` before it) while a deny-list would drop every key and\n * break valid calls like `newRequiredRule(\"city\")`.\n */\ntype ColumnBackedFields<F> = {\n [K in keyof F as F[K] extends { kind: \"primitive\" | \"enum\" | \"m2o\" | \"poly\" } ? K : never]: F[K];\n};\n\n/**\n * Creates a validation rule for required fields.\n *\n * This is added automatically by codegen to entities based on FK not-nulls.\n */\nexport function newRequiredRule<T extends Entity>(\n key: keyof ColumnBackedFields<FieldsOf<T>> & string,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n // Use getField so that we peer through relations\n if (getField(entity, key) === undefined) {\n // Sanity check for AsyncReactiveFields--this should be cheap to just always do; alternatively we could\n // have a RQF-specific `rqfRequiredRule` so that other `newRequiredRule` users don't pay the cost of these\n // two `if` checks`.\n if (entity.isNewEntity && isAsyncReactiveField((entity as any)[key])) {\n throw new Error(\n `AsyncReactiveField ${entity.constructor.name}.${key} must have a default value, either in the database or with config.setDefault (see the 4th step in https://joist-orm.io/modeling/reactive-fields/#async-reactive-fields.`,\n );\n }\n return { field: key, code: ValidationCode.required, message: `${key} is required` };\n }\n });\n}\n\n/**\n * Like `newRequiredRule`, but for `lazy` columns (i.e. codegen only wires this up for `lazy` fields).\n *\n * On an already-persisted entity that hasn't loaded the column, we skip the check rather than force-load\n * (or falsely fail) a value that was required when the row was last saved. It still fires on create and\n * when the field is explicitly loaded-then-unset.\n */\nexport function newRequiredLazyFieldRule<T extends Entity>(\n key: keyof FieldsOf<T> & string,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n if (!entity.isNewEntity && !(entity as any)[key].isLoaded) return;\n if (getField(entity, key) === undefined) {\n return { field: key, code: ValidationCode.required, message: `${key} is required` };\n }\n });\n}\n\n/**\n * Creates a validation rule that a field cannot be updated; it can only be set on creation.\n *\n * If the optional `unless` function returns true, then the update is allowed.\n */\nexport function cannotBeUpdated<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n opts?: ValidationRuleOpts<T>,\n): CannotBeUpdatedRule<T>;\nexport function cannotBeUpdated<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n unless?: ValidationRuleOptsFn<T>,\n): CannotBeUpdatedRule<T>;\nexport function cannotBeUpdated<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n optsOrUnless?: ValidationRuleOpts<T> | ValidationRuleOptsFn<T>,\n): CannotBeUpdatedRule<T> {\n const opts = typeof optsOrUnless === \"function\" ? { unless: optsOrUnless } : (optsOrUnless ?? {});\n const fn = ruleWithOpts(opts, (entity: T) => {\n // For now putting the `EntityChanges` cast here to avoid breaking cannotBeUpdated rules\n // on base types, see Publisher.ts's `cannotBeUpdated(\"type\")` repro.\n if ((entity as any as EntityChanges<T>).changes[field].hasUpdated) {\n const value = (entity as any)[field];\n // If we're being changed b/c of an em.merge, that is okay\n if (isLoadedReference(value) && getEmInternalApi(entity.em).isMerging(value.get)) return;\n return { field, code: ValidationCode.cannotBeUpdated, message: `${field} cannot be updated` };\n }\n return;\n });\n return Object.assign(fn, { field, immutable: opts.unless === undefined && opts.if === undefined });\n}\n\n/**\n * Creates a validation rule that a field cannot be changed once set.\n *\n * If the optional `unless` function returns true, then the update is allowed.\n */\nexport function cannotBeChanged<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n opts?: ValidationRuleOpts<T>,\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity: T) => {\n const changes = (entity as any as EntityChanges<T>).changes[field];\n if (changes.kind === \"m2m\" || changes.kind === \"o2m\" || changes.kind === \"m2mEnum\") {\n throw new Error(\"cannotBeChanged is only supported on primitive & m2o fields\");\n } else if (changes.hasUpdated) {\n const originalValue = changes.originalValue;\n if (originalValue === undefined) return;\n const value = getField(entity, field);\n if (getEmInternalApi(entity.em).isMerging(value)) return;\n return { field, code: ValidationCode.cannotBeChanged, message: `${field} cannot be changed` };\n }\n return;\n });\n}\n\ntype CannotBeUpdatedRule<T extends Entity> = ValidationRule<T> & { field: string; immutable: boolean };\n\nexport function isCannotBeUpdatedRule(rule: Function): rule is CannotBeUpdatedRule<any> {\n return \"field\" in rule && \"immutable\" in rule;\n}\n\n/** For STI, enforces subtype-specific relations/FKs at runtime. */\nexport function mustBeSubType<T extends Entity, K extends keyof Changes<T> & string>(\n relationName: K,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n const m2o = (entity as any)[relationName] as ManyToOneReferenceImpl<any, any, any>;\n const other = m2o.get;\n const otherCstr = m2o.otherMeta.cstr;\n if (other && !(other instanceof otherCstr)) {\n return `${relationName} must be a ${otherCstr.name} not ${other}`;\n }\n });\n}\n\n/**\n * Creates a validation rule that a field value cannot be smaller than a\n * certain value.\n *\n * @param field The field to validate\n * @param minValue The inclusive minimum value. e.g 0 range is [0, Infinity]\n * @param opts Optional validation rule options that control when the rule should run:\n * - unless: Function that returns true to skip validation\n * - if: Function that returns true to run validation\n *\n * @example\n * // Age cannot be smaller than 0\n * config.addRule(minValueRule(\"age\", 0));\n */\nexport function minValueRule<T extends Entity, K extends keyof T & string>(\n field: K,\n minValue: number,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n const value = entity[field];\n // Ignore undefined and null values. These should be handled by required rules\n if (value === undefined || value === null) return;\n // Show an error when the value type is not a number\n if (typeof value !== \"number\") {\n return { field, code: ValidationCode.numeric, message: `${field} must be a number` };\n }\n // Show an error when the value is smaller than the minimum value\n if (value < minValue) {\n return {\n field,\n code: ValidationCode.minValue,\n message: `${field} must be greater than or equal to ${minValue}`,\n };\n }\n return;\n });\n}\n\n/**\n * Creates a validation rule that a field value cannot be greater than a\n * certain value.\n *\n * @param field The field to validate\n * @param maxValue The include maximum value. e.g 10 range is [-Infinity, 10]\n * @param opts Optional validation rule options that control when the rule should run:\n * - unless: Function that returns true to skip validation\n * - if: Function that returns true to run validation\n *\n * @example\n * // Age cannot be greater than 150\n * config.addRule(maxValueRule(\"age\", 150));\n */\nexport function maxValueRule<T extends Entity, K extends keyof T & string>(\n field: K,\n maxValue: number,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n const value = entity[field];\n // Ignore undefined and null values. These should be handled by required rules\n if (value === undefined || value === null) return;\n // Show an error when the value type is not a number\n if (typeof value !== \"number\") {\n return { field, code: ValidationCode.numeric, message: `${field} must be a number` };\n }\n // Show an error when the value is smaller than the minimum value\n if (value > maxValue) {\n return {\n field,\n code: ValidationCode.maxValue,\n message: `${field} must be smaller than or equal to ${maxValue}`,\n };\n }\n return;\n });\n}\n\n/**\n * Creates a validation rule that a field value must be within a range of\n * certain values\n *\n * @param field The field to validate\n * @param minValue The inclusive minimum value. e.g 0 [0, Infinity]\n * @param maxValue The include maximum value. e.g 10 [-Infinity, 10]\n * @param opts Optional validation rule options that control when the rule should run:\n * - unless: Function that returns true to skip validation\n * - if: Function that returns true to run validation * @example\n *\n * // Age must be between 0 and 150\n * config.addRule(rangeValueRule(\"age\", 0, 150));\n */\nexport function rangeValueRule<T extends Entity, K extends keyof T & string>(\n field: K,\n minValue: number,\n maxValue: number,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n // Check min and max value rules. Because these are called without opts, it should be safe to treat them as sync.\n const minValueResult = minValueRule<T, K>(field, minValue)(entity) as ValidationRuleResult;\n const maxValueResult = maxValueRule<T, K>(field, maxValue)(entity) as ValidationRuleResult;\n // Return any errors or nothing\n if (minValueResult) return minValueResult;\n if (maxValueResult) return maxValueResult;\n return;\n });\n}\n"],"mappings":";;;;;;;;;;;AASA,IAAY,iBAAL,yBAAA,gBAAA;CACL,eAAA,cAAA;CACA,eAAA,qBAAA;CACA,eAAA,qBAAA;CACA,eAAA,aAAA;CACA,eAAA,cAAA;CACA,eAAA,cAAA;;AACF,EAAA,CAAA,CAAA;AAiCA,SAAS,aAAa,QAAmC;CACvD,IAAI,OAAO,WAAW,GACpB,OAAO,qBAAqB,OAAO,EAAE,CAAC,OAAO,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC;MAChE;EACL,MAAM,UAAU,CAAC,GAAG,QAAQ,SAAS,MAAM,EAAE,OAAO,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CACvE,KAAK,CAAC,gBAAgB,YAAY,GAAG,eAAe,GAAG,OAAO,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CACjG,KAAK,IAAI;EACZ,OAAO,sBAAsB,OAAO,OAAO,KAAK;CAClD;AACF;AAEA,IAAa,mBAAb,cAAsC,MAAM;CAC1C;CACA;CAGA,YAAY,iBAA6C;EACvD,MAAM,OAAO,oBAAoB,WAAW,kBAAkB,aAAa,eAAe,CAAC;EAC3F,KAA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A,SAAgB,aACd,OACA,UACA,OAA8B,CAAC,GACZ;CACnB,OAAO,aAAa,OAAO,WAAW;EACpC,MAAM,QAAQ,OAAO;EAErB,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM;EAE3C,IAAI,OAAO,UAAU,UACnB,OAAO;GAAE;GAAO,MAAA;GAA8B,SAAS,GAAG,MAAM;EAAmB;EAGrF,IAAI,QAAQ,UACV,OAAO;GACL;GACA,MAAA;GACA,SAAS,GAAG,MAAM,oCAAoC;EACxD;CAGJ,CAAC;AACH;;;;;;;;;;;;;;;AAgBA,SAAgB,aACd,OACA,UACA,OAA8B,CAAC,GACZ;CACnB,OAAO,aAAa,OAAO,WAAW;EACpC,MAAM,QAAQ,OAAO;EAErB,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM;EAE3C,IAAI,OAAO,UAAU,UACnB,OAAO;GAAE;GAAO,MAAA;GAA8B,SAAS,GAAG,MAAM;EAAmB;EAGrF,IAAI,QAAQ,UACV,OAAO;GACL;GACA,MAAA;GACA,SAAS,GAAG,MAAM,oCAAoC;EACxD;CAGJ,CAAC;AACH;;;;;;;;;;;;;;;AAgBA,SAAgB,eACd,OACA,UACA,UACA,OAA8B,CAAC,GACZ;CACnB,OAAO,aAAa,OAAO,WAAW;EAEpC,MAAM,iBAAiB,aAAmB,OAAO,QAAQ,CAAC,CAAC,MAAM;EACjE,MAAM,iBAAiB,aAAmB,OAAO,QAAQ,CAAC,CAAC,MAAM;EAEjE,IAAI,gBAAgB,OAAO;EAC3B,IAAI,gBAAgB,OAAO;CAE7B,CAAC;AACH"}
1
+ {"version":3,"file":"rules.js","names":[],"sources":["../src/rules.ts"],"sourcesContent":["import { type Changes, type EntityChanges } from \"./changes.ts\";\nimport { type Entity } from \"./Entity.ts\";\nimport { getEmInternalApi } from \"./EntityManager.ts\";\nimport { getField } from \"./fields.ts\";\nimport type { ReactiveHint } from \"./reactivity/reactiveHints.ts\";\nimport { type ManyToOneReferenceImpl, isAsyncReactiveField, isLoadedReference } from \"./relations/index.ts\";\nimport { type FieldsOf } from \"./typeMap.ts\";\nimport { type MaybePromise, groupBy, maybePromiseThen } from \"./utils.ts\";\n\nexport enum ValidationCode {\n required = \"required\",\n cannotBeUpdated = \"not-updatable\",\n cannotBeChanged = \"not-changeable\",\n numeric = \"not-numeric\",\n minValue = \"under-min\",\n maxValue = \"over-max\",\n}\n\n/**\n * The return type of `ValidationRule` lambdas.\n *\n * We're flexible and allow rules to return a variety of shapes, like just a string, string[], etc.\n *\n * Returning `undefined` means the rule passed.\n */\nexport type ValidationRuleResult = string | string[] | GenericError | GenericError[] | undefined | void;\n\n/** An entity validation rule. */\nexport type ValidationRule<T extends Entity> = (entity: T) => MaybePromise<ValidationRuleResult>;\n\n/** Internal metadata for an async/reactive validation rule. */\nexport type ValidationRuleInternal<T extends Entity> = {\n name: string;\n hint: ReactiveHint<T> | undefined;\n fn: ValidationRule<T>;\n};\n\n/** A generic error which contains a message, and optional field/codes. */\nexport type GenericError = { message: string; field?: string; code?: string };\n\n/** Combines the GenericError with the `entity` that caused it. */\nexport type ValidationError = { entity: Entity } & GenericError;\n\nexport type ValidationRuleOptsFn<T extends Entity> = (entity: T) => MaybePromise<boolean>;\nexport type ValidationRuleOpts<T extends Entity> = {\n unless?: ValidationRuleOptsFn<T>;\n if?: ValidationRuleOptsFn<T>;\n};\n\nfunction errorMessage(errors: ValidationError[]): string {\n if (errors.length === 1) {\n return `Validation error: ${errors[0].entity.toString()} ${errors[0].message}`;\n } else {\n const message = [...groupBy(errors, (e) => e.entity.toString()).entries()]\n .map(([entityToString, errors]) => `${entityToString} ${errors.map((e) => e.message).join(\", \")}`)\n .join(\", \");\n return `Validation errors (${errors.length}): ${message}`;\n }\n}\n\nexport class ValidationErrors extends Error {\n public errors: Array<GenericError | ValidationError>;\n public readonly toJSON: () => string;\n constructor(errors: ValidationError[]);\n constructor(message: string);\n constructor(messageOrErrors: ValidationError[] | string) {\n super(typeof messageOrErrors === \"string\" ? messageOrErrors : errorMessage(messageOrErrors));\n this.errors = typeof messageOrErrors === \"string\" ? [{ message: messageOrErrors }] : messageOrErrors;\n // Jest clones without prototype, so explictly setting this as a property rather than a class method\n // https://github.com/jestjs/jest/issues/11958\n this.toJSON = () => `ValidationErrors: ${this.message}`;\n }\n}\n\nfunction ruleWithOpts<T extends Entity>(\n opts: ValidationRuleOpts<T> | undefined,\n fn: (entity: T) => ValidationRuleResult,\n): ValidationRule<T> {\n return (entity) => {\n // Since all of our rules are sync, we run the rule first, then check if we should have run it second since this\n // may be an async operation. This way we can avoid running promises if we don't have to.\n const result = fn(entity);\n if (result === undefined) return;\n const { unless, if: _if } = opts ?? {};\n if (unless === undefined && _if === undefined) return result;\n const shouldRun = [unless ?? (() => false), _if ?? (() => true)].map((fn) => fn(entity));\n return maybePromiseThen(\n shouldRun.some((r) => r instanceof Promise) ? Promise.all(shouldRun) : (shouldRun as boolean[]),\n ([unless, _if]) => (!unless && _if ? result : undefined),\n );\n };\n}\n\n/**\n * The fields of `F` that have their own column, i.e. what a required rule can check.\n *\n * The filter is an allow-list (\"keep kinds primitive/enum/m2o/poly\"), not a deny-list (\"drop kind\n * o2o\"), because of how it degrades when `T` is generic/uninferred: `FieldsOf<T>` is then `never`,\n * and `never extends X` is true for any `X`, so an allow-list keeps every key (permissive, exactly\n * like the unfiltered `keyof FieldsOf<T>` before it) while a deny-list would drop every key and\n * break valid calls like `newRequiredRule(\"city\")`.\n */\ntype ColumnBackedFields<F> = {\n [K in keyof F as F[K] extends { kind: \"primitive\" | \"enum\" | \"m2o\" | \"poly\" } ? K : never]: F[K];\n};\n\n/**\n * Creates a validation rule for required fields.\n *\n * This is added automatically by codegen to entities based on FK not-nulls.\n */\nexport function newRequiredRule<T extends Entity>(\n key: keyof ColumnBackedFields<FieldsOf<T>> & string,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n // Use getField so that we peer through relations\n if (getField(entity, key) === undefined) {\n // Sanity check for AsyncReactiveFields--this should be cheap to just always do; alternatively we could\n // have a RQF-specific `rqfRequiredRule` so that other `newRequiredRule` users don't pay the cost of these\n // two `if` checks`.\n if (entity.isNewEntity && isAsyncReactiveField((entity as any)[key])) {\n throw new Error(\n `AsyncReactiveField ${entity.constructor.name}.${key} must have a default value, either in the database or with config.setDefault (see the 4th step in https://joist-orm.io/modeling/reactive-fields/#async-reactive-fields.`,\n );\n }\n return { field: key, code: ValidationCode.required, message: `${key} is required` };\n }\n });\n}\n\n/**\n * Like `newRequiredRule`, but for `lazy` columns (i.e. codegen only wires this up for `lazy` fields).\n *\n * On an already-persisted entity that hasn't loaded the column, we skip the check rather than force-load\n * (or falsely fail) a value that was required when the row was last saved. It still fires on create and\n * when the field is explicitly loaded-then-unset.\n */\nexport function newRequiredLazyFieldRule<T extends Entity>(\n key: keyof FieldsOf<T> & string,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n if (!entity.isNewEntity && !(entity as any)[key].isLoaded) return;\n if (getField(entity, key) === undefined) {\n return { field: key, code: ValidationCode.required, message: `${key} is required` };\n }\n });\n}\n\n/**\n * Creates a validation rule that a field cannot be updated; it can only be set on creation.\n *\n * If the optional `unless` function returns true, then the update is allowed.\n */\nexport function cannotBeUpdated<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n opts?: ValidationRuleOpts<T>,\n): CannotBeUpdatedRule<T>;\nexport function cannotBeUpdated<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n unless?: ValidationRuleOptsFn<T>,\n): CannotBeUpdatedRule<T>;\nexport function cannotBeUpdated<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n optsOrUnless?: ValidationRuleOpts<T> | ValidationRuleOptsFn<T>,\n): CannotBeUpdatedRule<T> {\n const opts = typeof optsOrUnless === \"function\" ? { unless: optsOrUnless } : (optsOrUnless ?? {});\n const fn = ruleWithOpts(opts, (entity: T) => {\n // For now putting the `EntityChanges` cast here to avoid breaking cannotBeUpdated rules\n // on base types, see Publisher.ts's `cannotBeUpdated(\"type\")` repro.\n if ((entity as any as EntityChanges<T>).changes[field].hasUpdated) {\n const value = (entity as any)[field];\n // If we're being changed b/c of an em.merge, that is okay\n if (isLoadedReference(value) && getEmInternalApi(entity.em).isMerging(value.get)) return;\n return { field, code: ValidationCode.cannotBeUpdated, message: `${field} cannot be updated` };\n }\n return;\n });\n return Object.assign(fn, { field, immutable: opts.unless === undefined && opts.if === undefined });\n}\n\n/**\n * Creates a validation rule that a field cannot be changed once set.\n *\n * If the optional `unless` function returns true, then the update is allowed.\n */\nexport function cannotBeChanged<T extends Entity, K extends keyof Changes<T> & string>(\n field: K,\n opts?: ValidationRuleOpts<T>,\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity: T) => {\n const changes = (entity as any as EntityChanges<T>).changes[field];\n if (changes.kind === \"m2m\" || changes.kind === \"o2m\" || changes.kind === \"m2mEnum\") {\n throw new Error(\"cannotBeChanged is only supported on primitive & m2o fields\");\n } else if (changes.hasUpdated) {\n const originalValue = changes.originalValue;\n if (originalValue === undefined) return;\n const value = getField(entity, field);\n if (getEmInternalApi(entity.em).isMerging(value)) return;\n return { field, code: ValidationCode.cannotBeChanged, message: `${field} cannot be changed` };\n }\n return;\n });\n}\n\ntype CannotBeUpdatedRule<T extends Entity> = ValidationRule<T> & { field: string; immutable: boolean };\n\nexport function isCannotBeUpdatedRule(rule: Function): rule is CannotBeUpdatedRule<any> {\n return \"field\" in rule && \"immutable\" in rule;\n}\n\n/** For STI, enforces subtype-specific relations/FKs at runtime. */\nexport function mustBeSubType<T extends Entity, K extends keyof Changes<T> & string>(\n relationName: K,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n const m2o = (entity as any)[relationName] as ManyToOneReferenceImpl<any, any, any>;\n const other = m2o.get;\n const otherCstr = m2o.otherMeta.cstr;\n if (other && !(other instanceof otherCstr)) {\n return `${relationName} must be a ${otherCstr.name} not ${other}`;\n }\n });\n}\n\n/**\n * Creates a validation rule that a field value cannot be smaller than a\n * certain value.\n *\n * @param field The field to validate\n * @param minValue The inclusive minimum value. e.g 0 range is [0, Infinity]\n * @param opts Optional validation rule options that control when the rule should run:\n * - unless: Function that returns true to skip validation\n * - if: Function that returns true to run validation\n *\n * @example\n * // Age cannot be smaller than 0\n * config.addRule(minValueRule(\"age\", 0));\n */\nexport function minValueRule<T extends Entity, K extends keyof T & string>(\n field: K,\n minValue: number,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n const value = entity[field];\n // Ignore undefined and null values. These should be handled by required rules\n if (value === undefined || value === null) return;\n // Show an error when the value type is not a number\n if (typeof value !== \"number\") {\n return { field, code: ValidationCode.numeric, message: `${field} must be a number` };\n }\n // Show an error when the value is smaller than the minimum value\n if (value < minValue) {\n return {\n field,\n code: ValidationCode.minValue,\n message: `${field} must be greater than or equal to ${minValue}`,\n };\n }\n return;\n });\n}\n\n/**\n * Creates a validation rule that a field value cannot be greater than a\n * certain value.\n *\n * @param field The field to validate\n * @param maxValue The include maximum value. e.g 10 range is [-Infinity, 10]\n * @param opts Optional validation rule options that control when the rule should run:\n * - unless: Function that returns true to skip validation\n * - if: Function that returns true to run validation\n *\n * @example\n * // Age cannot be greater than 150\n * config.addRule(maxValueRule(\"age\", 150));\n */\nexport function maxValueRule<T extends Entity, K extends keyof T & string>(\n field: K,\n maxValue: number,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n const value = entity[field];\n // Ignore undefined and null values. These should be handled by required rules\n if (value === undefined || value === null) return;\n // Show an error when the value type is not a number\n if (typeof value !== \"number\") {\n return { field, code: ValidationCode.numeric, message: `${field} must be a number` };\n }\n // Show an error when the value is smaller than the minimum value\n if (value > maxValue) {\n return {\n field,\n code: ValidationCode.maxValue,\n message: `${field} must be smaller than or equal to ${maxValue}`,\n };\n }\n return;\n });\n}\n\n/**\n * Creates a validation rule that a field value must be within a range of\n * certain values\n *\n * @param field The field to validate\n * @param minValue The inclusive minimum value. e.g 0 [0, Infinity]\n * @param maxValue The include maximum value. e.g 10 [-Infinity, 10]\n * @param opts Optional validation rule options that control when the rule should run:\n * - unless: Function that returns true to skip validation\n * - if: Function that returns true to run validation * @example\n *\n * // Age must be between 0 and 150\n * config.addRule(rangeValueRule(\"age\", 0, 150));\n */\nexport function rangeValueRule<T extends Entity, K extends keyof T & string>(\n field: K,\n minValue: number,\n maxValue: number,\n opts: ValidationRuleOpts<T> = {},\n): ValidationRule<T> {\n return ruleWithOpts(opts, (entity) => {\n // Check min and max value rules. Because these are called without opts, it should be safe to treat them as sync.\n const minValueResult = minValueRule<T, K>(field, minValue)(entity) as ValidationRuleResult;\n const maxValueResult = maxValueRule<T, K>(field, maxValue)(entity) as ValidationRuleResult;\n // Return any errors or nothing\n if (minValueResult) return minValueResult;\n if (maxValueResult) return maxValueResult;\n return;\n });\n}\n"],"mappings":";;;;;;;;;;AASA,IAAY,iBAAL,yBAAA,gBAAA;CACL,eAAA,cAAA;CACA,eAAA,qBAAA;CACA,eAAA,qBAAA;CACA,eAAA,aAAA;CACA,eAAA,cAAA;CACA,eAAA,cAAA;;AACF,EAAA,CAAA,CAAA;AAiCA,SAAS,aAAa,QAAmC;CACvD,IAAI,OAAO,WAAW,GACpB,OAAO,qBAAqB,OAAO,EAAE,CAAC,OAAO,SAAS,EAAE,GAAG,OAAO,EAAE,CAAC;MAChE;EACL,MAAM,UAAU,CAAC,GAAG,QAAQ,SAAS,MAAM,EAAE,OAAO,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CACvE,KAAK,CAAC,gBAAgB,YAAY,GAAG,eAAe,GAAG,OAAO,KAAK,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CACjG,KAAK,IAAI;EACZ,OAAO,sBAAsB,OAAO,OAAO,KAAK;CAClD;AACF;AAEA,IAAa,mBAA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C,IAAI,SAAS,EAAE,iBAAiB,YAC9B,OAAO,GAAG,aAAa,aAAa,UAAU,KAAK,OAAO;CAE9D,CAAC;AACH;;;;;;;;;;;;;;;AAgBA,SAAgB,aACd,OACA,UACA,OAA8B,CAAC,GACZ;CACnB,OAAO,aAAa,OAAO,WAAW;EACpC,MAAM,QAAQ,OAAO;EAErB,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM;EAE3C,IAAI,OAAO,UAAU,UACnB,OAAO;GAAE;GAAO,MAAA;GAA8B,SAAS,GAAG,MAAM;EAAmB;EAGrF,IAAI,QAAQ,UACV,OAAO;GACL;GACA,MAAA;GACA,SAAS,GAAG,MAAM,oCAAoC;EACxD;CAGJ,CAAC;AACH;;;;;;;;;;;;;;;AAgBA,SAAgB,aACd,OACA,UACA,OAA8B,CAAC,GACZ;CACnB,OAAO,aAAa,OAAO,WAAW;EACpC,MAAM,QAAQ,OAAO;EAErB,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM;EAE3C,IAAI,OAAO,UAAU,UACnB,OAAO;GAAE;GAAO,MAAA;GAA8B,SAAS,GAAG,MAAM;EAAmB;EAGrF,IAAI,QAAQ,UACV,OAAO;GACL;GACA,MAAA;GACA,SAAS,GAAG,MAAM,oCAAoC;EACxD;CAGJ,CAAC;AACH;;;;;;;;;;;;;;;AAgBA,SAAgB,eACd,OACA,UACA,UACA,OAA8B,CAAC,GACZ;CACnB,OAAO,aAAa,OAAO,WAAW;EAEpC,MAAM,iBAAiB,aAAmB,OAAO,QAAQ,CAAC,CAAC,MAAM;EACjE,MAAM,iBAAiB,aAAmB,OAAO,QAAQ,CAAC,CAAC,MAAM;EAEjE,IAAI,gBAAgB,OAAO;EAC3B,IAAI,gBAAgB,OAAO;CAE7B,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/TypeInfo.ts
2
+ //#region src/serde/TypeInfo.ts
3
3
  /**
4
4
  * Normalizes known PostgreSQL type synonyms without treating coercible types or user types as equal.
5
5
  * The output compatibility checks compare these names, so normalize only spellings of the same type.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeInfo.cjs","names":[],"sources":["../../src/serde/TypeInfo.ts"],"sourcesContent":["// Keep compatibility metadata a runtime leaf in both CJS and ESM builds.\nimport type { EntityMetadata } from \"../EntityMetadata.ts\";\n\n/**\n * Runtime proof that values can share scalar conversions.\n *\n * PostgreSQL compares projected SQL rows and chooses a common SQL type before Joist decodes them.\n * A compound uses one decoder per output column and retains an encoder for later comparisons and\n * coalesce fallbacks. TypeScript result types are erased, and equal SQL storage types do not imply\n * equal logical domains.\n *\n * I.e. Author.id and Book.author_id are compatible Author IDs despite having separate serdes, while\n * Book.id must not decode as an Author ID just because both use int4. Author.age and Author.age.sum()\n * both expose TypeScript numbers but produce int4 and int8 driver values. Enum, custom-mapper, and\n * JSON-schema domain tokens also prevent unrelated conversions from mixing.\n *\n * Compatibility requires exact equality of canonical `dbType`, `domain`, and `idMeta`. An absent\n * descriptor is unknown, not an identity codec. `idMeta` identifies scalar IDs only; arrays retain\n * their element domain separately so they cannot select a polymorphic IN component. Raw `sql<R>`\n * annotations supply no runtime evidence. This descriptor does not implement conversions.\n */\nexport interface TypeInfo {\n dbType: string;\n domain: unknown;\n idMeta?: EntityMetadata;\n /** Internal conversion proof, consistent for equal dbType/domain/idMeta; not another compatibility key. */\n arrayElementSafe?: boolean;\n}\n\n/**\n * Normalizes known PostgreSQL type synonyms without treating coercible types or user types as equal.\n * The output compatibility checks compare these names, so normalize only spellings of the same type.\n *\n * I.e. `integer` and `int` both mean `int4`; `integer[]` and `int4[]` also describe the same SQL type.\n * Keeping these spellings distinct would reject compatible outputs just because their serdes use\n * different names for the same representation.\n *\n * I.e. `int4` can be promoted to `int8`, but they are not synonyms: classic pg returns int4 as a number\n * and int8 as a string. Treating them as equal could admit a compound whose first operand's decoder\n * cannot handle the common SQL type. This function does not choose or apply a conversion.\n *\n * I.e. `citext` must stay distinct from `text`: they disagree on whether 'Alice' and 'alice' are equal,\n * which matters when a set operation compares rows. A user-defined `app.email` domain over text can\n * also impose constraints that text does not. Unknown names remain unchanged, including their schema\n * and quoting; neither coercibility nor a shared base type proves that their outputs are compatible.\n */\nexport function canonicalDbType(dbType: string): string {\n if (dbType.endsWith(\"[]\")) return `${canonicalDbType(dbType.slice(0, -2))}[]`;\n switch (dbType) {\n case \"smallint\":\n return \"int2\";\n case \"int\":\n case \"integer\":\n return \"int4\";\n case \"bigint\":\n return \"int8\";\n case \"decimal\":\n return \"numeric\";\n case \"real\":\n return \"float4\";\n case \"double precision\":\n return \"float8\";\n case \"boolean\":\n return \"bool\";\n case \"character varying\":\n return \"varchar\";\n case \"character\":\n return \"bpchar\";\n case \"timestamp without time zone\":\n return \"timestamp\";\n case \"timestamp with time zone\":\n return \"timestamptz\";\n case \"time without time zone\":\n return \"time\";\n case \"time with time zone\":\n return \"timetz\";\n default:\n return dbType;\n }\n}\n\nconst arrayDomains = new Map<unknown, Map<EntityMetadata | undefined, symbol>>();\n\n// Both classic pg and lazy binary reads decode these physical arrays, not an unparsed array string.\nconst arrayElementDbTypes = new Set([\n \"bool\",\n \"bytea\",\n \"int2\",\n \"int4\",\n \"int8\",\n \"float4\",\n \"float8\",\n \"numeric\",\n \"text\",\n \"varchar\",\n \"bpchar\",\n \"uuid\",\n \"json\",\n \"jsonb\",\n]);\n\n/**\n * Describes elementwise conversion only for known physical array parsers and stable domain conversion.\n *\n * I.e. `a.id.arrayAgg()` wraps Author's tag and `idMeta` in its domain token, but has no scalar\n * `idMeta` of its own. Repeated expressions share the token; IDs of subtypes with a shared tag do not.\n * Native enum/citext, date/time, and nested SQL arrays remain unknown. Numeric elements can be numbers\n * in classic pg and strings in lazy binary reads, so a scalar string-only mapper is not sufficient.\n */\nexport function arrayOutputType(outputType: TypeInfo | undefined): TypeInfo | undefined {\n if (!outputType?.arrayElementSafe || !arrayElementDbTypes.has(outputType.dbType)) return undefined;\n let domains = arrayDomains.get(outputType.domain);\n if (!domains) arrayDomains.set(outputType.domain, (domains = new Map()));\n let domain = domains.get(outputType.idMeta);\n if (!domain) domains.set(outputType.idMeta, (domain = Symbol(\"joist.arrayOutput\")));\n return { dbType: `${outputType.dbType}[]`, domain };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,gBAAgB,QAAwB;CACtD,IAAI,OAAO,SAAS,IAAI,GAAG,OAAO,GAAG,gBAAgB,OAAO,MAAM,GAAG,EAAE,CAAC,EAAE;CAC1E,QAAQ,QAAR;EACE,KAAK,YACH,OAAO;EACT,KAAK;EACL,KAAK,WACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,oBACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,qBACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,+BACH,OAAO;EACT,KAAK,4BACH,OAAO;EACT,KAAK,0BACH,OAAO;EACT,KAAK,uBACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,MAAM,+BAAe,IAAI,IAAsD;AAG/E,MAAM,sCAAsB,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;;;AAUD,SAAgB,gBAAgB,YAAwD;CACtF,IAAI,CAAC,YAAY,oBAAoB,CAAC,oBAAoB,IAAI,WAAW,MAAM,GAAG,OAAO,KAAA;CACzF,IAAI,UAAU,aAAa,IAAI,WAAW,MAAM;CAChD,IAAI,CAAC,SAAS,aAAa,IAAI,WAAW,QAAS,0BAAU,IAAI,IAAI,CAAE;CACvE,IAAI,SAAS,QAAQ,IAAI,WAAW,MAAM;CAC1C,IAAI,CAAC,QAAQ,QAAQ,IAAI,WAAW,QAAS,SAAS,OAAO,mBAAmB,CAAE;CAClF,OAAO;EAAE,QAAQ,GAAG,WAAW,OAAO;EAAK;CAAO;AACpD"}
@@ -1,5 +1,5 @@
1
- import { EntityMetadata } from "./EntityMetadata.cjs";
2
- //#region src/TypeInfo.d.ts
1
+ import { EntityMetadata } from "../EntityMetadata.cjs";
2
+ //#region src/serde/TypeInfo.d.ts
3
3
  /**
4
4
  * Runtime proof that values can share scalar conversions.
5
5
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeInfo.d.cts","names":[],"sources":["../../src/serde/TypeInfo.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;UAqBiB;EACf;EACA;EACA,SAAS;;EAET;;;;;;;;;;;;;;;;;;;iBAoBc,gBAAgB;;;;;;;;;iBA+DhB,gBAAgB,YAAY,uBAAuB"}
@@ -1,5 +1,5 @@
1
- import { EntityMetadata } from "./EntityMetadata.mjs";
2
- //#region src/TypeInfo.d.ts
1
+ import { EntityMetadata } from "../EntityMetadata.mjs";
2
+ //#region src/serde/TypeInfo.d.ts
3
3
  /**
4
4
  * Runtime proof that values can share scalar conversions.
5
5
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeInfo.d.mts","names":[],"sources":["../../src/serde/TypeInfo.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;UAqBiB;EACf;EACA;EACA,SAAS;;EAET;;;;;;;;;;;;;;;;;;;iBAoBc,gBAAgB;;;;;;;;;iBA+DhB,gBAAgB,YAAY,uBAAuB"}