joist-core 2.3.0-next.96 → 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 (1190) hide show
  1. package/build/EntityManager.cjs +55 -59
  2. package/build/EntityManager.cjs.map +1 -1
  3. package/build/EntityManager.d.cts +11 -11
  4. package/build/EntityManager.d.mts +11 -11
  5. package/build/EntityManager.js +30 -34
  6. package/build/EntityManager.js.map +1 -1
  7. package/build/EntityMetadata.cjs +2 -4
  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 +2 -4
  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/InstanceData.cjs +1 -1
  16. package/build/InstanceData.js +1 -1
  17. package/build/PluginManager.cjs +0 -2
  18. package/build/PluginManager.cjs.map +1 -1
  19. package/build/PluginManager.d.cts +2 -2
  20. package/build/PluginManager.d.mts +2 -2
  21. package/build/PluginManager.js +0 -2
  22. package/build/PluginManager.js.map +1 -1
  23. package/build/batchloaders/enumCollectionBatchLoader.d.cts +1 -1
  24. package/build/batchloaders/enumCollectionBatchLoader.d.mts +1 -1
  25. package/build/batchloaders/loadBatchLoader.cjs +7 -7
  26. package/build/batchloaders/loadBatchLoader.cjs.map +1 -1
  27. package/build/batchloaders/loadBatchLoader.d.cts +1 -1
  28. package/build/batchloaders/loadBatchLoader.d.cts.map +1 -1
  29. package/build/batchloaders/loadBatchLoader.d.mts +1 -1
  30. package/build/batchloaders/loadBatchLoader.d.mts.map +1 -1
  31. package/build/batchloaders/loadBatchLoader.js +4 -4
  32. package/build/batchloaders/loadBatchLoader.js.map +1 -1
  33. package/build/batchloaders/manyToManyBatchLoader.d.cts +1 -1
  34. package/build/batchloaders/manyToManyBatchLoader.d.mts +1 -1
  35. package/build/batchloaders/oneToManyBatchLoader.cjs +3 -3
  36. package/build/batchloaders/oneToManyBatchLoader.cjs.map +1 -1
  37. package/build/batchloaders/oneToManyBatchLoader.js +2 -2
  38. package/build/batchloaders/oneToOneBatchLoader.cjs +5 -5
  39. package/build/batchloaders/oneToOneBatchLoader.cjs.map +1 -1
  40. package/build/batchloaders/oneToOneBatchLoader.js +4 -4
  41. package/build/batchloaders/populateBatchLoader.cjs +15 -16
  42. package/build/batchloaders/populateBatchLoader.cjs.map +1 -1
  43. package/build/batchloaders/populateBatchLoader.d.cts +1 -1
  44. package/build/batchloaders/populateBatchLoader.d.mts +1 -1
  45. package/build/batchloaders/populateBatchLoader.js +8 -9
  46. package/build/batchloaders/populateBatchLoader.js.map +1 -1
  47. package/build/batchloaders/recursiveChildrenBatchLoader.cjs +8 -8
  48. package/build/batchloaders/recursiveChildrenBatchLoader.cjs.map +1 -1
  49. package/build/batchloaders/recursiveChildrenBatchLoader.js +5 -5
  50. package/build/batchloaders/recursiveM2mBatchLoader.cjs +5 -5
  51. package/build/batchloaders/recursiveM2mBatchLoader.cjs.map +1 -1
  52. package/build/batchloaders/recursiveM2mBatchLoader.js +2 -2
  53. package/build/batchloaders/recursiveParentsBatchLoader.cjs +7 -7
  54. package/build/batchloaders/recursiveParentsBatchLoader.cjs.map +1 -1
  55. package/build/batchloaders/recursiveParentsBatchLoader.js +4 -4
  56. package/build/changes.cjs +3 -4
  57. package/build/changes.cjs.map +1 -1
  58. package/build/changes.js +3 -4
  59. package/build/changes.js.map +1 -1
  60. package/build/config.cjs +6 -6
  61. package/build/config.cjs.map +1 -1
  62. package/build/config.d.cts +2 -2
  63. package/build/config.d.mts +2 -2
  64. package/build/config.js +4 -4
  65. package/build/config.js.map +1 -1
  66. package/build/configure.cjs +13 -13
  67. package/build/configure.cjs.map +1 -1
  68. package/build/configure.js +8 -8
  69. package/build/configure.js.map +1 -1
  70. package/build/dataloaders/fastWhereFilterHash.cjs +9 -9
  71. package/build/dataloaders/fastWhereFilterHash.cjs.map +1 -1
  72. package/build/dataloaders/fastWhereFilterHash.d.cts.map +1 -1
  73. package/build/dataloaders/fastWhereFilterHash.d.mts.map +1 -1
  74. package/build/dataloaders/fastWhereFilterHash.js +3 -3
  75. package/build/dataloaders/fastWhereFilterHash.js.map +1 -1
  76. package/build/dataloaders/findByUniqueDataLoader.cjs +5 -6
  77. package/build/dataloaders/findByUniqueDataLoader.cjs.map +1 -1
  78. package/build/dataloaders/findByUniqueDataLoader.d.cts.map +1 -1
  79. package/build/dataloaders/findByUniqueDataLoader.d.mts.map +1 -1
  80. package/build/dataloaders/findByUniqueDataLoader.js +3 -4
  81. package/build/dataloaders/findByUniqueDataLoader.js.map +1 -1
  82. package/build/dataloaders/findCountDataLoader.cjs +12 -15
  83. package/build/dataloaders/findCountDataLoader.cjs.map +1 -1
  84. package/build/dataloaders/findCountDataLoader.d.cts +2 -2
  85. package/build/dataloaders/findCountDataLoader.d.mts +2 -2
  86. package/build/dataloaders/findCountDataLoader.js +5 -8
  87. package/build/dataloaders/findCountDataLoader.js.map +1 -1
  88. package/build/dataloaders/findDataLoader.cjs +21 -25
  89. package/build/dataloaders/findDataLoader.cjs.map +1 -1
  90. package/build/dataloaders/findDataLoader.d.cts +3 -3
  91. package/build/dataloaders/findDataLoader.d.cts.map +1 -1
  92. package/build/dataloaders/findDataLoader.d.mts +3 -3
  93. package/build/dataloaders/findDataLoader.d.mts.map +1 -1
  94. package/build/dataloaders/findDataLoader.js +8 -12
  95. package/build/dataloaders/findDataLoader.js.map +1 -1
  96. package/build/dataloaders/findIdsDataLoader.cjs +8 -11
  97. package/build/dataloaders/findIdsDataLoader.cjs.map +1 -1
  98. package/build/dataloaders/findIdsDataLoader.d.cts +1 -1
  99. package/build/dataloaders/findIdsDataLoader.d.mts +1 -1
  100. package/build/dataloaders/findIdsDataLoader.js +4 -7
  101. package/build/dataloaders/findIdsDataLoader.js.map +1 -1
  102. package/build/dataloaders/findOrCreateDataLoader.cjs +1 -2
  103. package/build/dataloaders/findOrCreateDataLoader.cjs.map +1 -1
  104. package/build/dataloaders/findOrCreateDataLoader.js +1 -2
  105. package/build/dataloaders/findOrCreateDataLoader.js.map +1 -1
  106. package/build/dataloaders/findPaginatedDataLoader.cjs +8 -11
  107. package/build/dataloaders/findPaginatedDataLoader.cjs.map +1 -1
  108. package/build/dataloaders/findPaginatedDataLoader.d.cts +2 -2
  109. package/build/dataloaders/findPaginatedDataLoader.d.mts +2 -2
  110. package/build/dataloaders/findPaginatedDataLoader.js +4 -7
  111. package/build/dataloaders/findPaginatedDataLoader.js.map +1 -1
  112. package/build/dataloaders/lensDataLoader.cjs +6 -6
  113. package/build/dataloaders/lensDataLoader.cjs.map +1 -1
  114. package/build/dataloaders/lensDataLoader.js +3 -3
  115. package/build/dataloaders/lensDataLoader.js.map +1 -1
  116. package/build/dataloaders/manyToManyFindDataLoader.cjs +0 -3
  117. package/build/dataloaders/manyToManyFindDataLoader.cjs.map +1 -1
  118. package/build/dataloaders/manyToManyFindDataLoader.d.cts +0 -1
  119. package/build/dataloaders/manyToManyFindDataLoader.d.cts.map +1 -1
  120. package/build/dataloaders/manyToManyFindDataLoader.d.mts +0 -1
  121. package/build/dataloaders/manyToManyFindDataLoader.d.mts.map +1 -1
  122. package/build/dataloaders/manyToManyFindDataLoader.js +0 -3
  123. package/build/dataloaders/manyToManyFindDataLoader.js.map +1 -1
  124. package/build/dataloaders/oneToManyFindDataLoader.cjs +2 -5
  125. package/build/dataloaders/oneToManyFindDataLoader.cjs.map +1 -1
  126. package/build/dataloaders/oneToManyFindDataLoader.d.cts +0 -1
  127. package/build/dataloaders/oneToManyFindDataLoader.d.cts.map +1 -1
  128. package/build/dataloaders/oneToManyFindDataLoader.d.mts +0 -1
  129. package/build/dataloaders/oneToManyFindDataLoader.d.mts.map +1 -1
  130. package/build/dataloaders/oneToManyFindDataLoader.js +1 -4
  131. package/build/dataloaders/oneToManyFindDataLoader.js.map +1 -1
  132. package/build/defaults.cjs +6 -6
  133. package/build/defaults.cjs.map +1 -1
  134. package/build/defaults.d.cts +1 -1
  135. package/build/defaults.d.mts +1 -1
  136. package/build/defaults.js +5 -5
  137. package/build/defaults.js.map +1 -1
  138. package/build/drivers/Driver.cjs +0 -2
  139. package/build/drivers/Driver.d.cts +2 -2
  140. package/build/drivers/Driver.d.mts +2 -2
  141. package/build/drivers/Driver.js +0 -2
  142. package/build/drivers/EntityWriter.cjs +7 -8
  143. package/build/drivers/EntityWriter.cjs.map +1 -1
  144. package/build/drivers/EntityWriter.d.cts +1 -1
  145. package/build/drivers/EntityWriter.d.mts +1 -1
  146. package/build/drivers/EntityWriter.js +3 -4
  147. package/build/drivers/EntityWriter.js.map +1 -1
  148. package/build/drivers/IdAssigner.cjs +0 -1
  149. package/build/drivers/IdAssigner.cjs.map +1 -1
  150. package/build/drivers/IdAssigner.d.cts +1 -1
  151. package/build/drivers/IdAssigner.d.mts +1 -1
  152. package/build/drivers/IdAssigner.js +0 -1
  153. package/build/drivers/IdAssigner.js.map +1 -1
  154. package/build/drivers/driverApi.cjs +19 -0
  155. package/build/drivers/driverApi.cjs.map +1 -0
  156. package/build/drivers/driverApi.d.cts +22 -0
  157. package/build/drivers/driverApi.d.cts.map +1 -0
  158. package/build/drivers/driverApi.d.mts +22 -0
  159. package/build/drivers/driverApi.d.mts.map +1 -0
  160. package/build/drivers/driverApi.js +18 -0
  161. package/build/drivers/driverApi.js.map +1 -0
  162. package/build/drivers/index.cjs +0 -6
  163. package/build/drivers/index.d.cts +1 -3
  164. package/build/drivers/index.d.mts +1 -3
  165. package/build/drivers/index.js +1 -3
  166. package/build/fields.cjs +3 -3
  167. package/build/fields.cjs.map +1 -1
  168. package/build/fields.js +2 -2
  169. package/build/fields.js.map +1 -1
  170. package/build/flush/FlushLock.cjs +51 -0
  171. package/build/flush/FlushLock.cjs.map +1 -0
  172. package/build/flush/FlushLock.d.cts +29 -0
  173. package/build/flush/FlushLock.d.cts.map +1 -0
  174. package/build/flush/FlushLock.d.mts +29 -0
  175. package/build/flush/FlushLock.d.mts.map +1 -0
  176. package/build/flush/FlushLock.js +51 -0
  177. package/build/flush/FlushLock.js.map +1 -0
  178. package/build/flush/JoinRows.cjs +263 -0
  179. package/build/flush/JoinRows.cjs.map +1 -0
  180. package/build/flush/JoinRows.d.cts +120 -0
  181. package/build/flush/JoinRows.d.cts.map +1 -0
  182. package/build/flush/JoinRows.d.mts +120 -0
  183. package/build/flush/JoinRows.d.mts.map +1 -0
  184. package/build/flush/JoinRows.js +261 -0
  185. package/build/flush/JoinRows.js.map +1 -0
  186. package/build/flush/PendingChanges.d.cts +29 -0
  187. package/build/flush/PendingChanges.d.cts.map +1 -0
  188. package/build/flush/PendingChanges.d.mts +29 -0
  189. package/build/flush/PendingChanges.d.mts.map +1 -0
  190. package/build/flush/Todo.cjs +71 -0
  191. package/build/flush/Todo.cjs.map +1 -0
  192. package/build/flush/Todo.d.cts +38 -0
  193. package/build/flush/Todo.d.cts.map +1 -0
  194. package/build/flush/Todo.d.mts +38 -0
  195. package/build/flush/Todo.d.mts.map +1 -0
  196. package/build/flush/Todo.js +67 -0
  197. package/build/flush/Todo.js.map +1 -0
  198. package/build/getProperties.cjs +1 -1
  199. package/build/getProperties.js +1 -1
  200. package/build/index.cjs +168 -166
  201. package/build/index.cjs.map +1 -1
  202. package/build/index.d.cts +42 -39
  203. package/build/index.d.cts.map +1 -1
  204. package/build/index.d.mts +42 -39
  205. package/build/index.d.mts.map +1 -1
  206. package/build/index.js +52 -50
  207. package/build/index.js.map +1 -1
  208. package/build/json.cjs +4 -4
  209. package/build/json.cjs.map +1 -1
  210. package/build/json.js +3 -3
  211. package/build/json.js.map +1 -1
  212. package/build/keys.cjs +1 -1
  213. package/build/keys.js +1 -1
  214. package/build/loading/HintTree.cjs +67 -0
  215. package/build/loading/HintTree.cjs.map +1 -0
  216. package/build/loading/HintTree.d.cts +45 -0
  217. package/build/loading/HintTree.d.cts.map +1 -0
  218. package/build/loading/HintTree.d.mts +45 -0
  219. package/build/loading/HintTree.d.mts.map +1 -0
  220. package/build/loading/HintTree.js +66 -0
  221. package/build/loading/HintTree.js.map +1 -0
  222. package/build/loading/IsLoadedCache.cjs +58 -0
  223. package/build/loading/IsLoadedCache.cjs.map +1 -0
  224. package/build/loading/IsLoadedCache.d.cts +35 -0
  225. package/build/loading/IsLoadedCache.d.cts.map +1 -0
  226. package/build/loading/IsLoadedCache.d.mts +35 -0
  227. package/build/loading/IsLoadedCache.d.mts.map +1 -0
  228. package/build/loading/IsLoadedCache.js +57 -0
  229. package/build/loading/IsLoadedCache.js.map +1 -0
  230. package/build/loading/loadHints.cjs +95 -0
  231. package/build/loading/loadHints.cjs.map +1 -0
  232. package/build/loading/loadHints.d.cts +116 -0
  233. package/build/loading/loadHints.d.cts.map +1 -0
  234. package/build/loading/loadHints.d.mts +116 -0
  235. package/build/loading/loadHints.d.mts.map +1 -0
  236. package/build/loading/loadHints.js +88 -0
  237. package/build/loading/loadHints.js.map +1 -0
  238. package/build/loading/loadLens.cjs +212 -0
  239. package/build/loading/loadLens.cjs.map +1 -0
  240. package/build/loading/loadLens.d.cts +77 -0
  241. package/build/loading/loadLens.d.cts.map +1 -0
  242. package/build/loading/loadLens.d.mts +77 -0
  243. package/build/loading/loadLens.d.mts.map +1 -0
  244. package/build/loading/loadLens.js +201 -0
  245. package/build/loading/loadLens.js.map +1 -0
  246. package/build/loading/withLoaded.cjs +64 -0
  247. package/build/loading/withLoaded.cjs.map +1 -0
  248. package/build/loading/withLoaded.d.cts +65 -0
  249. package/build/loading/withLoaded.d.cts.map +1 -0
  250. package/build/loading/withLoaded.d.mts +65 -0
  251. package/build/loading/withLoaded.d.mts.map +1 -0
  252. package/build/loading/withLoaded.js +61 -0
  253. package/build/loading/withLoaded.js.map +1 -0
  254. package/build/logging/FactoryLogger.cjs +1 -1
  255. package/build/logging/FactoryLogger.js +1 -1
  256. package/build/logging/FieldLogger.cjs +1 -1
  257. package/build/logging/FieldLogger.js +1 -1
  258. package/build/logging/ReactionLogger.cjs +1 -3
  259. package/build/logging/ReactionLogger.cjs.map +1 -1
  260. package/build/logging/ReactionLogger.d.cts +2 -2
  261. package/build/logging/ReactionLogger.d.mts +2 -2
  262. package/build/logging/ReactionLogger.js +1 -3
  263. package/build/logging/ReactionLogger.js.map +1 -1
  264. package/build/newEntity.cjs +1 -1
  265. package/build/newEntity.js +1 -1
  266. package/build/newTestInstance.cjs +4 -4
  267. package/build/newTestInstance.cjs.map +1 -1
  268. package/build/newTestInstance.d.cts +1 -1
  269. package/build/newTestInstance.d.mts +1 -1
  270. package/build/newTestInstance.js +3 -3
  271. package/build/newTestInstance.js.map +1 -1
  272. package/build/normalizeHints.cjs +0 -2
  273. package/build/normalizeHints.cjs.map +1 -1
  274. package/build/normalizeHints.d.cts +2 -2
  275. package/build/normalizeHints.d.mts +2 -2
  276. package/build/normalizeHints.js +0 -2
  277. package/build/normalizeHints.js.map +1 -1
  278. package/build/nowUTC.cjs +2 -2
  279. package/build/nowUTC.cjs.map +1 -1
  280. package/build/nowUTC.d.cts +1 -1
  281. package/build/nowUTC.d.mts +1 -1
  282. package/build/nowUTC.js +1 -1
  283. package/build/nowUTC.js.map +1 -1
  284. package/build/plugins/PreloadPlugin.cjs +0 -3
  285. package/build/plugins/PreloadPlugin.d.cts +3 -3
  286. package/build/plugins/PreloadPlugin.d.mts +3 -3
  287. package/build/plugins/PreloadPlugin.js +0 -3
  288. package/build/preloading/JsonAggregatePreloader.cjs +30 -33
  289. package/build/preloading/JsonAggregatePreloader.cjs.map +1 -1
  290. package/build/preloading/JsonAggregatePreloader.d.cts +3 -3
  291. package/build/preloading/JsonAggregatePreloader.d.mts +3 -3
  292. package/build/preloading/JsonAggregatePreloader.js +5 -8
  293. package/build/preloading/JsonAggregatePreloader.js.map +1 -1
  294. package/build/preloading/partitionHint.cjs +2 -3
  295. package/build/preloading/partitionHint.cjs.map +1 -1
  296. package/build/preloading/partitionHint.d.cts +1 -1
  297. package/build/preloading/partitionHint.d.mts +1 -1
  298. package/build/preloading/partitionHint.js +2 -3
  299. package/build/preloading/partitionHint.js.map +1 -1
  300. package/build/queries/ConditionBuilder.cjs +106 -0
  301. package/build/queries/ConditionBuilder.cjs.map +1 -0
  302. package/build/queries/ConditionBuilder.d.cts +31 -0
  303. package/build/queries/ConditionBuilder.d.cts.map +1 -0
  304. package/build/queries/ConditionBuilder.d.mts +31 -0
  305. package/build/queries/ConditionBuilder.d.mts.map +1 -0
  306. package/build/queries/ConditionBuilder.js +105 -0
  307. package/build/queries/ConditionBuilder.js.map +1 -0
  308. package/build/queries/conditions.cjs +15 -0
  309. package/build/queries/conditions.cjs.map +1 -0
  310. package/build/queries/conditions.d.cts +38 -0
  311. package/build/queries/conditions.d.cts.map +1 -0
  312. package/build/queries/conditions.d.mts +38 -0
  313. package/build/queries/conditions.d.mts.map +1 -0
  314. package/build/queries/conditions.js +13 -0
  315. package/build/queries/conditions.js.map +1 -0
  316. package/build/queries/entityQueryUtils.cjs +60 -0
  317. package/build/queries/entityQueryUtils.cjs.map +1 -0
  318. package/build/queries/entityQueryUtils.d.cts +19 -0
  319. package/build/queries/entityQueryUtils.d.cts.map +1 -0
  320. package/build/queries/entityQueryUtils.d.mts +19 -0
  321. package/build/queries/entityQueryUtils.d.mts.map +1 -0
  322. package/build/queries/entityQueryUtils.js +56 -0
  323. package/build/queries/entityQueryUtils.js.map +1 -0
  324. package/build/queries/find/Aliases.cjs +301 -0
  325. package/build/queries/find/Aliases.cjs.map +1 -0
  326. package/build/queries/find/Aliases.d.cts +122 -0
  327. package/build/queries/find/Aliases.d.cts.map +1 -0
  328. package/build/queries/find/Aliases.d.mts +122 -0
  329. package/build/queries/find/Aliases.d.mts.map +1 -0
  330. package/build/queries/find/Aliases.js +293 -0
  331. package/build/queries/find/Aliases.js.map +1 -0
  332. package/build/queries/find/DeferredAlias.cjs +25 -0
  333. package/build/queries/find/DeferredAlias.cjs.map +1 -0
  334. package/build/queries/find/DeferredAlias.d.cts +22 -0
  335. package/build/queries/find/DeferredAlias.d.cts.map +1 -0
  336. package/build/queries/find/DeferredAlias.d.mts +22 -0
  337. package/build/queries/find/DeferredAlias.d.mts.map +1 -0
  338. package/build/queries/find/DeferredAlias.js +22 -0
  339. package/build/queries/find/DeferredAlias.js.map +1 -0
  340. package/build/queries/find/EntityFilter.cjs +27 -0
  341. package/build/queries/find/EntityFilter.cjs.map +1 -0
  342. package/build/queries/find/EntityFilter.d.cts +127 -0
  343. package/build/queries/find/EntityFilter.d.cts.map +1 -0
  344. package/build/queries/find/EntityFilter.d.mts +127 -0
  345. package/build/queries/find/EntityFilter.d.mts.map +1 -0
  346. package/build/queries/find/EntityFilter.js +26 -0
  347. package/build/queries/find/EntityFilter.js.map +1 -0
  348. package/build/queries/find/EntityGraphQLFilter.cjs +52 -0
  349. package/build/queries/find/EntityGraphQLFilter.cjs.map +1 -0
  350. package/build/queries/find/EntityGraphQLFilter.d.cts +59 -0
  351. package/build/queries/find/EntityGraphQLFilter.d.cts.map +1 -0
  352. package/build/queries/find/EntityGraphQLFilter.d.mts +59 -0
  353. package/build/queries/find/EntityGraphQLFilter.d.mts.map +1 -0
  354. package/build/queries/find/EntityGraphQLFilter.js +50 -0
  355. package/build/queries/find/EntityGraphQLFilter.js.map +1 -0
  356. package/build/queries/find/QueryParser.cjs +554 -0
  357. package/build/queries/find/QueryParser.cjs.map +1 -0
  358. package/build/queries/find/QueryParser.collectionJoins.cjs +353 -0
  359. package/build/queries/find/QueryParser.collectionJoins.cjs.map +1 -0
  360. package/build/queries/find/QueryParser.collectionJoins.d.cts +30 -0
  361. package/build/queries/find/QueryParser.collectionJoins.d.cts.map +1 -0
  362. package/build/queries/find/QueryParser.collectionJoins.d.mts +30 -0
  363. package/build/queries/find/QueryParser.collectionJoins.d.mts.map +1 -0
  364. package/build/queries/find/QueryParser.collectionJoins.js +352 -0
  365. package/build/queries/find/QueryParser.collectionJoins.js.map +1 -0
  366. package/build/queries/find/QueryParser.d.cts +192 -0
  367. package/build/queries/find/QueryParser.d.cts.map +1 -0
  368. package/build/queries/find/QueryParser.d.mts +192 -0
  369. package/build/queries/find/QueryParser.d.mts.map +1 -0
  370. package/build/queries/find/QueryParser.js +547 -0
  371. package/build/queries/find/QueryParser.js.map +1 -0
  372. package/build/queries/find/QueryParser.pruning.cjs +115 -0
  373. package/build/queries/find/QueryParser.pruning.cjs.map +1 -0
  374. package/build/queries/find/QueryParser.pruning.d.cts +8 -0
  375. package/build/queries/find/QueryParser.pruning.d.cts.map +1 -0
  376. package/build/queries/find/QueryParser.pruning.d.mts +8 -0
  377. package/build/queries/find/QueryParser.pruning.d.mts.map +1 -0
  378. package/build/queries/find/QueryParser.pruning.js +113 -0
  379. package/build/queries/find/QueryParser.pruning.js.map +1 -0
  380. package/build/queries/find/QueryVisitor.cjs +60 -0
  381. package/build/queries/find/QueryVisitor.cjs.map +1 -0
  382. package/build/queries/find/QueryVisitor.d.cts +22 -0
  383. package/build/queries/find/QueryVisitor.d.cts.map +1 -0
  384. package/build/queries/find/QueryVisitor.d.mts +22 -0
  385. package/build/queries/find/QueryVisitor.d.mts.map +1 -0
  386. package/build/queries/find/QueryVisitor.js +58 -0
  387. package/build/queries/find/QueryVisitor.js.map +1 -0
  388. package/build/queries/find/buildFindQuery.cjs +112 -0
  389. package/build/queries/find/buildFindQuery.cjs.map +1 -0
  390. package/build/queries/find/buildFindQuery.d.cts +24 -0
  391. package/build/queries/find/buildFindQuery.d.cts.map +1 -0
  392. package/build/queries/find/buildFindQuery.d.mts +24 -0
  393. package/build/queries/find/buildFindQuery.d.mts.map +1 -0
  394. package/build/queries/find/buildFindQuery.js +110 -0
  395. package/build/queries/find/buildFindQuery.js.map +1 -0
  396. package/build/queries/find/scopes.cjs +301 -0
  397. package/build/queries/find/scopes.cjs.map +1 -0
  398. package/build/queries/find/scopes.d.cts +188 -0
  399. package/build/queries/find/scopes.d.cts.map +1 -0
  400. package/build/queries/find/scopes.d.mts +188 -0
  401. package/build/queries/find/scopes.d.mts.map +1 -0
  402. package/build/queries/find/scopes.js +296 -0
  403. package/build/queries/find/scopes.js.map +1 -0
  404. package/build/queries/parsedConditions.cjs +21 -0
  405. package/build/queries/parsedConditions.cjs.map +1 -0
  406. package/build/queries/parsedConditions.d.cts +127 -0
  407. package/build/queries/parsedConditions.d.cts.map +1 -0
  408. package/build/queries/parsedConditions.d.mts +127 -0
  409. package/build/queries/parsedConditions.d.mts.map +1 -0
  410. package/build/queries/parsedConditions.js +20 -0
  411. package/build/queries/parsedConditions.js.map +1 -0
  412. package/build/queries/renderConditions.cjs +66 -0
  413. package/build/queries/renderConditions.cjs.map +1 -0
  414. package/build/queries/renderConditions.d.cts +15 -0
  415. package/build/queries/renderConditions.d.cts.map +1 -0
  416. package/build/queries/renderConditions.d.mts +15 -0
  417. package/build/queries/renderConditions.d.mts.map +1 -0
  418. package/build/queries/renderConditions.js +64 -0
  419. package/build/queries/renderConditions.js.map +1 -0
  420. package/build/queries/skipCondition.cjs +14 -0
  421. package/build/queries/skipCondition.cjs.map +1 -0
  422. package/build/queries/skipCondition.d.cts +7 -0
  423. package/build/queries/skipCondition.d.cts.map +1 -0
  424. package/build/queries/skipCondition.d.mts +7 -0
  425. package/build/queries/skipCondition.d.mts.map +1 -0
  426. package/build/queries/skipCondition.js +13 -0
  427. package/build/queries/skipCondition.js.map +1 -0
  428. package/build/queries/sql/AliasAssigner.cjs +35 -0
  429. package/build/queries/sql/AliasAssigner.cjs.map +1 -0
  430. package/build/queries/sql/AliasAssigner.d.cts +13 -0
  431. package/build/queries/sql/AliasAssigner.d.cts.map +1 -0
  432. package/build/queries/sql/AliasAssigner.d.mts +13 -0
  433. package/build/queries/sql/AliasAssigner.d.mts.map +1 -0
  434. package/build/queries/sql/AliasAssigner.js +34 -0
  435. package/build/queries/sql/AliasAssigner.js.map +1 -0
  436. package/build/queries/sql/Expr.cjs +512 -0
  437. package/build/queries/sql/Expr.cjs.map +1 -0
  438. package/build/queries/sql/Expr.d.cts +274 -0
  439. package/build/queries/sql/Expr.d.cts.map +1 -0
  440. package/build/queries/sql/Expr.d.mts +274 -0
  441. package/build/queries/sql/Expr.d.mts.map +1 -0
  442. package/build/queries/sql/Expr.js +496 -0
  443. package/build/queries/sql/Expr.js.map +1 -0
  444. package/build/queries/sql/Tables.cjs +706 -0
  445. package/build/queries/sql/Tables.cjs.map +1 -0
  446. package/build/queries/sql/Tables.d.cts +263 -0
  447. package/build/queries/sql/Tables.d.cts.map +1 -0
  448. package/build/queries/sql/Tables.d.mts +263 -0
  449. package/build/queries/sql/Tables.d.mts.map +1 -0
  450. package/build/queries/sql/Tables.js +695 -0
  451. package/build/queries/sql/Tables.js.map +1 -0
  452. package/build/queries/sql/execute.cjs +236 -0
  453. package/build/queries/sql/execute.cjs.map +1 -0
  454. package/build/queries/sql/execute.d.cts +195 -0
  455. package/build/queries/sql/execute.d.cts.map +1 -0
  456. package/build/queries/sql/execute.d.mts +195 -0
  457. package/build/queries/sql/execute.d.mts.map +1 -0
  458. package/build/queries/sql/execute.js +233 -0
  459. package/build/queries/sql/execute.js.map +1 -0
  460. package/build/queries/sql/expressions/arrayAgg.cjs +63 -0
  461. package/build/queries/sql/expressions/arrayAgg.cjs.map +1 -0
  462. package/build/queries/sql/expressions/arrayAgg.d.cts +24 -0
  463. package/build/queries/sql/expressions/arrayAgg.d.cts.map +1 -0
  464. package/build/queries/sql/expressions/arrayAgg.d.mts +24 -0
  465. package/build/queries/sql/expressions/arrayAgg.d.mts.map +1 -0
  466. package/build/queries/sql/expressions/arrayAgg.js +61 -0
  467. package/build/queries/sql/expressions/arrayAgg.js.map +1 -0
  468. package/build/queries/sql/expressions/case.cjs +71 -0
  469. package/build/queries/sql/expressions/case.cjs.map +1 -0
  470. package/build/queries/sql/expressions/case.d.cts +57 -0
  471. package/build/queries/sql/expressions/case.d.cts.map +1 -0
  472. package/build/queries/sql/expressions/case.d.mts +57 -0
  473. package/build/queries/sql/expressions/case.d.mts.map +1 -0
  474. package/build/queries/sql/expressions/case.js +68 -0
  475. package/build/queries/sql/expressions/case.js.map +1 -0
  476. package/build/queries/sql/expressions/coalesce.cjs +25 -0
  477. package/build/queries/sql/expressions/coalesce.cjs.map +1 -0
  478. package/build/queries/sql/expressions/coalesce.d.cts +21 -0
  479. package/build/queries/sql/expressions/coalesce.d.cts.map +1 -0
  480. package/build/queries/sql/expressions/coalesce.d.mts +21 -0
  481. package/build/queries/sql/expressions/coalesce.d.mts.map +1 -0
  482. package/build/queries/sql/expressions/coalesce.js +22 -0
  483. package/build/queries/sql/expressions/coalesce.js.map +1 -0
  484. package/build/queries/sql/expressions/codecs.cjs +126 -0
  485. package/build/queries/sql/expressions/codecs.cjs.map +1 -0
  486. package/build/queries/sql/expressions/codecs.d.cts +11 -0
  487. package/build/queries/sql/expressions/codecs.d.cts.map +1 -0
  488. package/build/queries/sql/expressions/codecs.d.mts +11 -0
  489. package/build/queries/sql/expressions/codecs.d.mts.map +1 -0
  490. package/build/queries/sql/expressions/codecs.js +125 -0
  491. package/build/queries/sql/expressions/codecs.js.map +1 -0
  492. package/build/queries/sql/expressions/expression.cjs +102 -0
  493. package/build/queries/sql/expressions/expression.cjs.map +1 -0
  494. package/build/queries/sql/expressions/expression.d.cts +23 -0
  495. package/build/queries/sql/expressions/expression.d.cts.map +1 -0
  496. package/build/queries/sql/expressions/expression.d.mts +23 -0
  497. package/build/queries/sql/expressions/expression.d.mts.map +1 -0
  498. package/build/queries/sql/expressions/expression.js +97 -0
  499. package/build/queries/sql/expressions/expression.js.map +1 -0
  500. package/build/queries/sql/expressions/greatest.cjs +25 -0
  501. package/build/queries/sql/expressions/greatest.cjs.map +1 -0
  502. package/build/queries/sql/expressions/greatest.d.cts +21 -0
  503. package/build/queries/sql/expressions/greatest.d.cts.map +1 -0
  504. package/build/queries/sql/expressions/greatest.d.mts +21 -0
  505. package/build/queries/sql/expressions/greatest.d.mts.map +1 -0
  506. package/build/queries/sql/expressions/greatest.js +22 -0
  507. package/build/queries/sql/expressions/greatest.js.map +1 -0
  508. package/build/queries/sql/expressions/least.cjs +25 -0
  509. package/build/queries/sql/expressions/least.cjs.map +1 -0
  510. package/build/queries/sql/expressions/least.d.cts +21 -0
  511. package/build/queries/sql/expressions/least.d.cts.map +1 -0
  512. package/build/queries/sql/expressions/least.d.mts +21 -0
  513. package/build/queries/sql/expressions/least.d.mts.map +1 -0
  514. package/build/queries/sql/expressions/least.js +22 -0
  515. package/build/queries/sql/expressions/least.js.map +1 -0
  516. package/build/queries/sql/expressions/nullIf.cjs +27 -0
  517. package/build/queries/sql/expressions/nullIf.cjs.map +1 -0
  518. package/build/queries/sql/expressions/nullIf.d.cts +22 -0
  519. package/build/queries/sql/expressions/nullIf.d.cts.map +1 -0
  520. package/build/queries/sql/expressions/nullIf.d.mts +22 -0
  521. package/build/queries/sql/expressions/nullIf.d.mts.map +1 -0
  522. package/build/queries/sql/expressions/nullIf.js +24 -0
  523. package/build/queries/sql/expressions/nullIf.js.map +1 -0
  524. package/build/queries/sql/expressions/parseExpression.cjs +75 -0
  525. package/build/queries/sql/expressions/parseExpression.cjs.map +1 -0
  526. package/build/queries/sql/expressions/parseExpression.d.cts +19 -0
  527. package/build/queries/sql/expressions/parseExpression.d.cts.map +1 -0
  528. package/build/queries/sql/expressions/parseExpression.d.mts +19 -0
  529. package/build/queries/sql/expressions/parseExpression.d.mts.map +1 -0
  530. package/build/queries/sql/expressions/parseExpression.js +70 -0
  531. package/build/queries/sql/expressions/parseExpression.js.map +1 -0
  532. package/build/queries/sql/expressions/types.cjs +1 -0
  533. package/build/queries/sql/expressions/types.d.cts +114 -0
  534. package/build/queries/sql/expressions/types.d.cts.map +1 -0
  535. package/build/queries/sql/expressions/types.d.mts +114 -0
  536. package/build/queries/sql/expressions/types.d.mts.map +1 -0
  537. package/build/queries/sql/expressions/types.js +1 -0
  538. package/build/queries/sql/keywords.cjs +136 -0
  539. package/build/queries/sql/keywords.cjs.map +1 -0
  540. package/build/queries/sql/keywords.d.cts +18 -0
  541. package/build/queries/sql/keywords.d.cts.map +1 -0
  542. package/build/queries/sql/keywords.d.mts +18 -0
  543. package/build/queries/sql/keywords.d.mts.map +1 -0
  544. package/build/queries/sql/keywords.js +132 -0
  545. package/build/queries/sql/keywords.js.map +1 -0
  546. package/build/queries/sql/query.cjs +1548 -0
  547. package/build/queries/sql/query.cjs.map +1 -0
  548. package/build/queries/sql/query.d.cts +794 -0
  549. package/build/queries/sql/query.d.cts.map +1 -0
  550. package/build/queries/sql/query.d.mts +794 -0
  551. package/build/queries/sql/query.d.mts.map +1 -0
  552. package/build/queries/sql/query.js +1530 -0
  553. package/build/queries/sql/query.js.map +1 -0
  554. package/build/queries/unnest.cjs +62 -0
  555. package/build/queries/unnest.cjs.map +1 -0
  556. package/build/queries/unnest.d.cts +16 -0
  557. package/build/queries/unnest.d.cts.map +1 -0
  558. package/build/queries/unnest.d.mts +16 -0
  559. package/build/queries/unnest.d.mts.map +1 -0
  560. package/build/queries/unnest.js +60 -0
  561. package/build/queries/unnest.js.map +1 -0
  562. package/build/queries/valueFilters.cjs +248 -0
  563. package/build/queries/valueFilters.cjs.map +1 -0
  564. package/build/queries/valueFilters.d.cts +28 -0
  565. package/build/queries/valueFilters.d.cts.map +1 -0
  566. package/build/queries/valueFilters.d.mts +28 -0
  567. package/build/queries/valueFilters.d.mts.map +1 -0
  568. package/build/queries/valueFilters.js +243 -0
  569. package/build/queries/valueFilters.js.map +1 -0
  570. package/build/reactivity/ReactionsManager.cjs +264 -0
  571. package/build/reactivity/ReactionsManager.cjs.map +1 -0
  572. package/build/reactivity/ReactionsManager.d.cts +98 -0
  573. package/build/reactivity/ReactionsManager.d.cts.map +1 -0
  574. package/build/reactivity/ReactionsManager.d.mts +98 -0
  575. package/build/reactivity/ReactionsManager.d.mts.map +1 -0
  576. package/build/reactivity/ReactionsManager.js +263 -0
  577. package/build/reactivity/ReactionsManager.js.map +1 -0
  578. package/build/reactivity/reactiveHints.cjs +328 -0
  579. package/build/reactivity/reactiveHints.cjs.map +1 -0
  580. package/build/reactivity/reactiveHints.d.cts +143 -0
  581. package/build/reactivity/reactiveHints.d.cts.map +1 -0
  582. package/build/reactivity/reactiveHints.d.mts +143 -0
  583. package/build/reactivity/reactiveHints.d.mts.map +1 -0
  584. package/build/reactivity/reactiveHints.js +321 -0
  585. package/build/reactivity/reactiveHints.js.map +1 -0
  586. package/build/relations/AbstractRelationImpl.cjs +0 -5
  587. package/build/relations/AbstractRelationImpl.cjs.map +1 -1
  588. package/build/relations/AbstractRelationImpl.d.cts +1 -2
  589. package/build/relations/AbstractRelationImpl.d.cts.map +1 -1
  590. package/build/relations/AbstractRelationImpl.d.mts +1 -2
  591. package/build/relations/AbstractRelationImpl.d.mts.map +1 -1
  592. package/build/relations/AbstractRelationImpl.js +1 -5
  593. package/build/relations/AbstractRelationImpl.js.map +1 -1
  594. package/build/relations/AsyncProperty.cjs +1 -1
  595. package/build/relations/AsyncProperty.js +1 -1
  596. package/build/relations/AsyncReactiveField.cjs +7 -7
  597. package/build/relations/AsyncReactiveField.cjs.map +1 -1
  598. package/build/relations/AsyncReactiveField.d.cts +1 -1
  599. package/build/relations/AsyncReactiveField.d.mts +1 -1
  600. package/build/relations/AsyncReactiveField.js +5 -5
  601. package/build/relations/AsyncReactiveField.js.map +1 -1
  602. package/build/relations/CustomCollection.cjs +1 -1
  603. package/build/relations/CustomCollection.d.cts +1 -1
  604. package/build/relations/CustomCollection.d.mts +1 -1
  605. package/build/relations/CustomCollection.js +1 -1
  606. package/build/relations/CustomReference.cjs +3 -3
  607. package/build/relations/CustomReference.d.cts +1 -1
  608. package/build/relations/CustomReference.d.mts +1 -1
  609. package/build/relations/CustomReference.js +3 -3
  610. package/build/relations/EnumCollection.cjs +2 -2
  611. package/build/relations/EnumCollection.d.cts +1 -1
  612. package/build/relations/EnumCollection.d.mts +1 -1
  613. package/build/relations/EnumCollection.js +2 -2
  614. package/build/relations/LazyField.cjs +6 -7
  615. package/build/relations/LazyField.cjs.map +1 -1
  616. package/build/relations/LazyField.js +5 -6
  617. package/build/relations/LazyField.js.map +1 -1
  618. package/build/relations/ManyToManyCollection.cjs +5 -4
  619. package/build/relations/ManyToManyCollection.cjs.map +1 -1
  620. package/build/relations/ManyToManyCollection.d.cts.map +1 -1
  621. package/build/relations/ManyToManyCollection.d.mts.map +1 -1
  622. package/build/relations/ManyToManyCollection.js +5 -4
  623. package/build/relations/ManyToManyCollection.js.map +1 -1
  624. package/build/relations/ManyToManyLargeCollection.cjs +3 -3
  625. package/build/relations/ManyToManyLargeCollection.js +3 -3
  626. package/build/relations/ManyToOneReference.cjs +6 -5
  627. package/build/relations/ManyToOneReference.cjs.map +1 -1
  628. package/build/relations/ManyToOneReference.d.cts.map +1 -1
  629. package/build/relations/ManyToOneReference.d.mts.map +1 -1
  630. package/build/relations/ManyToOneReference.js +6 -5
  631. package/build/relations/ManyToOneReference.js.map +1 -1
  632. package/build/relations/OneToManyCollection.cjs +7 -7
  633. package/build/relations/OneToManyCollection.cjs.map +1 -1
  634. package/build/relations/OneToManyCollection.d.cts +1 -1
  635. package/build/relations/OneToManyCollection.d.cts.map +1 -1
  636. package/build/relations/OneToManyCollection.d.mts +1 -1
  637. package/build/relations/OneToManyCollection.d.mts.map +1 -1
  638. package/build/relations/OneToManyCollection.js +5 -5
  639. package/build/relations/OneToManyCollection.js.map +1 -1
  640. package/build/relations/OneToManyLargeCollection.cjs +2 -2
  641. package/build/relations/OneToManyLargeCollection.js +2 -2
  642. package/build/relations/OneToOneReference.cjs +5 -4
  643. package/build/relations/OneToOneReference.cjs.map +1 -1
  644. package/build/relations/OneToOneReference.d.cts.map +1 -1
  645. package/build/relations/OneToOneReference.d.mts.map +1 -1
  646. package/build/relations/OneToOneReference.js +5 -4
  647. package/build/relations/OneToOneReference.js.map +1 -1
  648. package/build/relations/PolymorphicReference.cjs +7 -6
  649. package/build/relations/PolymorphicReference.cjs.map +1 -1
  650. package/build/relations/PolymorphicReference.d.cts.map +1 -1
  651. package/build/relations/PolymorphicReference.d.mts.map +1 -1
  652. package/build/relations/PolymorphicReference.js +7 -6
  653. package/build/relations/PolymorphicReference.js.map +1 -1
  654. package/build/relations/ReactiveField.cjs +6 -7
  655. package/build/relations/ReactiveField.cjs.map +1 -1
  656. package/build/relations/ReactiveField.d.cts +2 -2
  657. package/build/relations/ReactiveField.d.mts +2 -2
  658. package/build/relations/ReactiveField.js +4 -5
  659. package/build/relations/ReactiveField.js.map +1 -1
  660. package/build/relations/ReactiveGetter.cjs +1 -2
  661. package/build/relations/ReactiveGetter.cjs.map +1 -1
  662. package/build/relations/ReactiveGetter.d.cts +1 -1
  663. package/build/relations/ReactiveGetter.d.mts +1 -1
  664. package/build/relations/ReactiveGetter.js +1 -2
  665. package/build/relations/ReactiveGetter.js.map +1 -1
  666. package/build/relations/ReactiveManyToMany.cjs +8 -8
  667. package/build/relations/ReactiveManyToMany.cjs.map +1 -1
  668. package/build/relations/ReactiveManyToMany.d.cts +2 -2
  669. package/build/relations/ReactiveManyToMany.d.cts.map +1 -1
  670. package/build/relations/ReactiveManyToMany.d.mts +2 -2
  671. package/build/relations/ReactiveManyToMany.d.mts.map +1 -1
  672. package/build/relations/ReactiveManyToMany.js +6 -6
  673. package/build/relations/ReactiveManyToMany.js.map +1 -1
  674. package/build/relations/ReactiveManyToManyOtherSide.cjs +1 -3
  675. package/build/relations/ReactiveManyToManyOtherSide.cjs.map +1 -1
  676. package/build/relations/ReactiveManyToManyOtherSide.d.cts +2 -2
  677. package/build/relations/ReactiveManyToManyOtherSide.d.mts +2 -2
  678. package/build/relations/ReactiveManyToManyOtherSide.js +1 -3
  679. package/build/relations/ReactiveManyToManyOtherSide.js.map +1 -1
  680. package/build/relations/ReactiveReference.cjs +10 -10
  681. package/build/relations/ReactiveReference.cjs.map +1 -1
  682. package/build/relations/ReactiveReference.d.cts +2 -2
  683. package/build/relations/ReactiveReference.d.cts.map +1 -1
  684. package/build/relations/ReactiveReference.d.mts +2 -2
  685. package/build/relations/ReactiveReference.d.mts.map +1 -1
  686. package/build/relations/ReactiveReference.js +8 -8
  687. package/build/relations/ReactiveReference.js.map +1 -1
  688. package/build/relations/RecursiveCollection.cjs +5 -6
  689. package/build/relations/RecursiveCollection.cjs.map +1 -1
  690. package/build/relations/RecursiveCollection.d.cts +1 -1
  691. package/build/relations/RecursiveCollection.d.mts +1 -1
  692. package/build/relations/RecursiveCollection.js +5 -6
  693. package/build/relations/RecursiveCollection.js.map +1 -1
  694. package/build/relations/hasAsyncMethod.cjs +2 -2
  695. package/build/relations/hasAsyncMethod.cjs.map +1 -1
  696. package/build/relations/hasAsyncMethod.d.cts +1 -1
  697. package/build/relations/hasAsyncMethod.d.mts +1 -1
  698. package/build/relations/hasAsyncMethod.js +1 -1
  699. package/build/relations/hasAsyncMethod.js.map +1 -1
  700. package/build/relations/hasManyDerived.cjs +3 -3
  701. package/build/relations/hasManyDerived.cjs.map +1 -1
  702. package/build/relations/hasManyDerived.d.cts +1 -1
  703. package/build/relations/hasManyDerived.d.mts +1 -1
  704. package/build/relations/hasManyDerived.js +2 -2
  705. package/build/relations/hasManyDerived.js.map +1 -1
  706. package/build/relations/hasManyThrough.cjs +6 -6
  707. package/build/relations/hasManyThrough.cjs.map +1 -1
  708. package/build/relations/hasManyThrough.d.cts +1 -1
  709. package/build/relations/hasManyThrough.d.mts +1 -1
  710. package/build/relations/hasManyThrough.js +2 -2
  711. package/build/relations/hasOneDerived.cjs +3 -3
  712. package/build/relations/hasOneDerived.cjs.map +1 -1
  713. package/build/relations/hasOneDerived.d.cts +1 -1
  714. package/build/relations/hasOneDerived.d.mts +1 -1
  715. package/build/relations/hasOneDerived.js +2 -2
  716. package/build/relations/hasOneDerived.js.map +1 -1
  717. package/build/relations/hasOneThrough.cjs +7 -7
  718. package/build/relations/hasOneThrough.cjs.map +1 -1
  719. package/build/relations/hasOneThrough.d.cts +1 -1
  720. package/build/relations/hasOneThrough.d.mts +1 -1
  721. package/build/relations/hasOneThrough.js +2 -2
  722. package/build/relations/hasProperty.cjs +6 -6
  723. package/build/relations/hasProperty.cjs.map +1 -1
  724. package/build/relations/hasProperty.d.cts +2 -2
  725. package/build/relations/hasProperty.d.mts +2 -2
  726. package/build/relations/hasProperty.js +4 -4
  727. package/build/relations/hasProperty.js.map +1 -1
  728. package/build/relations/index.cjs +5 -5
  729. package/build/relations/index.js +5 -5
  730. package/build/relations/isCascadeDelete.cjs +11 -0
  731. package/build/relations/isCascadeDelete.cjs.map +1 -0
  732. package/build/relations/isCascadeDelete.d.cts +7 -0
  733. package/build/relations/isCascadeDelete.d.cts.map +1 -0
  734. package/build/relations/isCascadeDelete.d.mts +7 -0
  735. package/build/relations/isCascadeDelete.d.mts.map +1 -0
  736. package/build/relations/isCascadeDelete.js +10 -0
  737. package/build/relations/isCascadeDelete.js.map +1 -0
  738. package/build/resurrection.cjs +1 -1
  739. package/build/resurrection.js +1 -1
  740. package/build/rules.cjs +3 -4
  741. package/build/rules.cjs.map +1 -1
  742. package/build/rules.d.cts +1 -1
  743. package/build/rules.d.mts +1 -1
  744. package/build/rules.js +3 -4
  745. package/build/rules.js.map +1 -1
  746. package/build/serde/TypeInfo.cjs +80 -0
  747. package/build/serde/TypeInfo.cjs.map +1 -0
  748. package/build/serde/TypeInfo.d.cts +57 -0
  749. package/build/serde/TypeInfo.d.cts.map +1 -0
  750. package/build/serde/TypeInfo.d.mts +57 -0
  751. package/build/serde/TypeInfo.d.mts.map +1 -0
  752. package/build/serde/TypeInfo.js +78 -0
  753. package/build/serde/TypeInfo.js.map +1 -0
  754. package/build/serde/columns.cjs +63 -0
  755. package/build/serde/columns.cjs.map +1 -0
  756. package/build/serde/columns.d.cts +38 -0
  757. package/build/serde/columns.d.cts.map +1 -0
  758. package/build/serde/columns.d.mts +38 -0
  759. package/build/serde/columns.d.mts.map +1 -0
  760. package/build/serde/columns.js +62 -0
  761. package/build/serde/columns.js.map +1 -0
  762. package/build/serde/fieldSerde.cjs +188 -0
  763. package/build/serde/fieldSerde.cjs.map +1 -0
  764. package/build/serde/fieldSerde.d.cts +87 -0
  765. package/build/serde/fieldSerde.d.cts.map +1 -0
  766. package/build/serde/fieldSerde.d.mts +87 -0
  767. package/build/serde/fieldSerde.d.mts.map +1 -0
  768. package/build/serde/fieldSerde.js +182 -0
  769. package/build/serde/fieldSerde.js.map +1 -0
  770. package/build/serde/serde.cjs +499 -0
  771. package/build/serde/serde.cjs.map +1 -0
  772. package/build/serde/serde.d.cts +248 -0
  773. package/build/serde/serde.d.cts.map +1 -0
  774. package/build/serde/serde.d.mts +248 -0
  775. package/build/serde/serde.d.mts.map +1 -0
  776. package/build/serde/serde.js +485 -0
  777. package/build/serde/serde.js.map +1 -0
  778. package/build/serde/temporal.cjs +57 -0
  779. package/build/serde/temporal.cjs.map +1 -0
  780. package/build/serde/temporal.d.cts +44 -0
  781. package/build/serde/temporal.d.cts.map +1 -0
  782. package/build/serde/temporal.d.mts +44 -0
  783. package/build/serde/temporal.d.mts.map +1 -0
  784. package/build/serde/temporal.js +55 -0
  785. package/build/serde/temporal.js.map +1 -0
  786. package/build/serde/temporalMappers.cjs +62 -0
  787. package/build/serde/temporalMappers.cjs.map +1 -0
  788. package/build/serde/temporalMappers.d.cts +36 -0
  789. package/build/serde/temporalMappers.d.cts.map +1 -0
  790. package/build/serde/temporalMappers.d.mts +36 -0
  791. package/build/serde/temporalMappers.d.mts.map +1 -0
  792. package/build/serde/temporalMappers.js +58 -0
  793. package/build/serde/temporalMappers.js.map +1 -0
  794. package/build/upsert.cjs +4 -4
  795. package/build/upsert.js +4 -4
  796. package/build/utils.cjs +0 -2
  797. package/build/utils.cjs.map +1 -1
  798. package/build/utils.d.cts +2 -2
  799. package/build/utils.d.mts +2 -2
  800. package/build/utils.js +0 -2
  801. package/build/utils.js.map +1 -1
  802. package/package.json +2 -2
  803. package/build/AliasAssigner.cjs +0 -36
  804. package/build/AliasAssigner.cjs.map +0 -1
  805. package/build/AliasAssigner.d.cts +0 -13
  806. package/build/AliasAssigner.d.cts.map +0 -1
  807. package/build/AliasAssigner.d.mts +0 -13
  808. package/build/AliasAssigner.d.mts.map +0 -1
  809. package/build/AliasAssigner.js +0 -35
  810. package/build/AliasAssigner.js.map +0 -1
  811. package/build/Aliases.cjs +0 -306
  812. package/build/Aliases.cjs.map +0 -1
  813. package/build/Aliases.d.cts +0 -122
  814. package/build/Aliases.d.cts.map +0 -1
  815. package/build/Aliases.d.mts +0 -122
  816. package/build/Aliases.d.mts.map +0 -1
  817. package/build/Aliases.js +0 -298
  818. package/build/Aliases.js.map +0 -1
  819. package/build/ConditionBuilder.cjs +0 -107
  820. package/build/ConditionBuilder.cjs.map +0 -1
  821. package/build/ConditionBuilder.d.cts +0 -31
  822. package/build/ConditionBuilder.d.cts.map +0 -1
  823. package/build/ConditionBuilder.d.mts +0 -31
  824. package/build/ConditionBuilder.d.mts.map +0 -1
  825. package/build/ConditionBuilder.js +0 -106
  826. package/build/ConditionBuilder.js.map +0 -1
  827. package/build/DeferredAlias.cjs +0 -28
  828. package/build/DeferredAlias.cjs.map +0 -1
  829. package/build/DeferredAlias.d.cts +0 -22
  830. package/build/DeferredAlias.d.cts.map +0 -1
  831. package/build/DeferredAlias.d.mts +0 -22
  832. package/build/DeferredAlias.d.mts.map +0 -1
  833. package/build/DeferredAlias.js +0 -25
  834. package/build/DeferredAlias.js.map +0 -1
  835. package/build/EntityFilter.cjs +0 -32
  836. package/build/EntityFilter.cjs.map +0 -1
  837. package/build/EntityFilter.d.cts +0 -127
  838. package/build/EntityFilter.d.cts.map +0 -1
  839. package/build/EntityFilter.d.mts +0 -127
  840. package/build/EntityFilter.d.mts.map +0 -1
  841. package/build/EntityFilter.js +0 -31
  842. package/build/EntityFilter.js.map +0 -1
  843. package/build/EntityGraphQLFilter.cjs +0 -56
  844. package/build/EntityGraphQLFilter.cjs.map +0 -1
  845. package/build/EntityGraphQLFilter.d.cts +0 -59
  846. package/build/EntityGraphQLFilter.d.cts.map +0 -1
  847. package/build/EntityGraphQLFilter.d.mts +0 -59
  848. package/build/EntityGraphQLFilter.d.mts.map +0 -1
  849. package/build/EntityGraphQLFilter.js +0 -54
  850. package/build/EntityGraphQLFilter.js.map +0 -1
  851. package/build/Expr.cjs +0 -512
  852. package/build/Expr.cjs.map +0 -1
  853. package/build/Expr.d.cts +0 -274
  854. package/build/Expr.d.cts.map +0 -1
  855. package/build/Expr.d.mts +0 -274
  856. package/build/Expr.d.mts.map +0 -1
  857. package/build/Expr.js +0 -496
  858. package/build/Expr.js.map +0 -1
  859. package/build/FlushLock.cjs +0 -51
  860. package/build/FlushLock.cjs.map +0 -1
  861. package/build/FlushLock.d.cts +0 -29
  862. package/build/FlushLock.d.cts.map +0 -1
  863. package/build/FlushLock.d.mts +0 -29
  864. package/build/FlushLock.d.mts.map +0 -1
  865. package/build/FlushLock.js +0 -51
  866. package/build/FlushLock.js.map +0 -1
  867. package/build/HintTree.cjs +0 -70
  868. package/build/HintTree.cjs.map +0 -1
  869. package/build/HintTree.d.cts +0 -45
  870. package/build/HintTree.d.cts.map +0 -1
  871. package/build/HintTree.d.mts +0 -45
  872. package/build/HintTree.d.mts.map +0 -1
  873. package/build/HintTree.js +0 -69
  874. package/build/HintTree.js.map +0 -1
  875. package/build/IsLoadedCache.cjs +0 -59
  876. package/build/IsLoadedCache.cjs.map +0 -1
  877. package/build/IsLoadedCache.d.cts +0 -35
  878. package/build/IsLoadedCache.d.cts.map +0 -1
  879. package/build/IsLoadedCache.d.mts +0 -35
  880. package/build/IsLoadedCache.d.mts.map +0 -1
  881. package/build/IsLoadedCache.js +0 -58
  882. package/build/IsLoadedCache.js.map +0 -1
  883. package/build/JoinRows.cjs +0 -266
  884. package/build/JoinRows.cjs.map +0 -1
  885. package/build/JoinRows.d.cts +0 -120
  886. package/build/JoinRows.d.cts.map +0 -1
  887. package/build/JoinRows.d.mts +0 -120
  888. package/build/JoinRows.d.mts.map +0 -1
  889. package/build/JoinRows.js +0 -264
  890. package/build/JoinRows.js.map +0 -1
  891. package/build/PendingChanges.cjs +0 -2
  892. package/build/PendingChanges.d.cts +0 -29
  893. package/build/PendingChanges.d.cts.map +0 -1
  894. package/build/PendingChanges.d.mts +0 -29
  895. package/build/PendingChanges.d.mts.map +0 -1
  896. package/build/PendingChanges.js +0 -2
  897. package/build/QueryParser.cjs +0 -842
  898. package/build/QueryParser.cjs.map +0 -1
  899. package/build/QueryParser.collectionJoins.cjs +0 -353
  900. package/build/QueryParser.collectionJoins.cjs.map +0 -1
  901. package/build/QueryParser.collectionJoins.d.cts +0 -30
  902. package/build/QueryParser.collectionJoins.d.cts.map +0 -1
  903. package/build/QueryParser.collectionJoins.d.mts +0 -30
  904. package/build/QueryParser.collectionJoins.d.mts.map +0 -1
  905. package/build/QueryParser.collectionJoins.js +0 -352
  906. package/build/QueryParser.collectionJoins.js.map +0 -1
  907. package/build/QueryParser.d.cts +0 -346
  908. package/build/QueryParser.d.cts.map +0 -1
  909. package/build/QueryParser.d.mts +0 -346
  910. package/build/QueryParser.d.mts.map +0 -1
  911. package/build/QueryParser.js +0 -827
  912. package/build/QueryParser.js.map +0 -1
  913. package/build/QueryParser.pruning.cjs +0 -129
  914. package/build/QueryParser.pruning.cjs.map +0 -1
  915. package/build/QueryParser.pruning.d.cts +0 -10
  916. package/build/QueryParser.pruning.d.cts.map +0 -1
  917. package/build/QueryParser.pruning.d.mts +0 -10
  918. package/build/QueryParser.pruning.d.mts.map +0 -1
  919. package/build/QueryParser.pruning.js +0 -126
  920. package/build/QueryParser.pruning.js.map +0 -1
  921. package/build/QueryVisitor.cjs +0 -61
  922. package/build/QueryVisitor.cjs.map +0 -1
  923. package/build/QueryVisitor.d.cts +0 -21
  924. package/build/QueryVisitor.d.cts.map +0 -1
  925. package/build/QueryVisitor.d.mts +0 -21
  926. package/build/QueryVisitor.d.mts.map +0 -1
  927. package/build/QueryVisitor.js +0 -59
  928. package/build/QueryVisitor.js.map +0 -1
  929. package/build/ReactionsManager.cjs +0 -266
  930. package/build/ReactionsManager.cjs.map +0 -1
  931. package/build/ReactionsManager.d.cts +0 -99
  932. package/build/ReactionsManager.d.cts.map +0 -1
  933. package/build/ReactionsManager.d.mts +0 -99
  934. package/build/ReactionsManager.d.mts.map +0 -1
  935. package/build/ReactionsManager.js +0 -265
  936. package/build/ReactionsManager.js.map +0 -1
  937. package/build/Tables.cjs +0 -710
  938. package/build/Tables.cjs.map +0 -1
  939. package/build/Tables.d.cts +0 -264
  940. package/build/Tables.d.cts.map +0 -1
  941. package/build/Tables.d.mts +0 -264
  942. package/build/Tables.d.mts.map +0 -1
  943. package/build/Tables.js +0 -699
  944. package/build/Tables.js.map +0 -1
  945. package/build/Todo.cjs +0 -73
  946. package/build/Todo.cjs.map +0 -1
  947. package/build/Todo.d.cts +0 -38
  948. package/build/Todo.d.cts.map +0 -1
  949. package/build/Todo.d.mts +0 -38
  950. package/build/Todo.d.mts.map +0 -1
  951. package/build/Todo.js +0 -69
  952. package/build/Todo.js.map +0 -1
  953. package/build/TypeInfo.cjs +0 -80
  954. package/build/TypeInfo.cjs.map +0 -1
  955. package/build/TypeInfo.d.cts +0 -57
  956. package/build/TypeInfo.d.cts.map +0 -1
  957. package/build/TypeInfo.d.mts +0 -57
  958. package/build/TypeInfo.d.mts.map +0 -1
  959. package/build/TypeInfo.js +0 -78
  960. package/build/TypeInfo.js.map +0 -1
  961. package/build/columns.cjs +0 -63
  962. package/build/columns.cjs.map +0 -1
  963. package/build/columns.d.cts +0 -38
  964. package/build/columns.d.cts.map +0 -1
  965. package/build/columns.d.mts +0 -38
  966. package/build/columns.d.mts.map +0 -1
  967. package/build/columns.js +0 -62
  968. package/build/columns.js.map +0 -1
  969. package/build/conditions.cjs +0 -16
  970. package/build/conditions.cjs.map +0 -1
  971. package/build/conditions.d.cts +0 -38
  972. package/build/conditions.d.cts.map +0 -1
  973. package/build/conditions.d.mts +0 -38
  974. package/build/conditions.d.mts.map +0 -1
  975. package/build/conditions.js +0 -14
  976. package/build/conditions.js.map +0 -1
  977. package/build/driverApi.cjs +0 -19
  978. package/build/driverApi.cjs.map +0 -1
  979. package/build/driverApi.d.cts +0 -22
  980. package/build/driverApi.d.cts.map +0 -1
  981. package/build/driverApi.d.mts +0 -22
  982. package/build/driverApi.d.mts.map +0 -1
  983. package/build/driverApi.js +0 -18
  984. package/build/driverApi.js.map +0 -1
  985. package/build/drivers/buildRawQuery.cjs +0 -113
  986. package/build/drivers/buildRawQuery.cjs.map +0 -1
  987. package/build/drivers/buildRawQuery.d.cts +0 -24
  988. package/build/drivers/buildRawQuery.d.cts.map +0 -1
  989. package/build/drivers/buildRawQuery.d.mts +0 -24
  990. package/build/drivers/buildRawQuery.d.mts.map +0 -1
  991. package/build/drivers/buildRawQuery.js +0 -111
  992. package/build/drivers/buildRawQuery.js.map +0 -1
  993. package/build/drivers/buildUtils.cjs +0 -67
  994. package/build/drivers/buildUtils.cjs.map +0 -1
  995. package/build/drivers/buildUtils.d.cts +0 -14
  996. package/build/drivers/buildUtils.d.cts.map +0 -1
  997. package/build/drivers/buildUtils.d.mts +0 -14
  998. package/build/drivers/buildUtils.d.mts.map +0 -1
  999. package/build/drivers/buildUtils.js +0 -65
  1000. package/build/drivers/buildUtils.js.map +0 -1
  1001. package/build/execute.cjs +0 -241
  1002. package/build/execute.cjs.map +0 -1
  1003. package/build/execute.d.cts +0 -195
  1004. package/build/execute.d.cts.map +0 -1
  1005. package/build/execute.d.mts +0 -195
  1006. package/build/execute.d.mts.map +0 -1
  1007. package/build/execute.js +0 -238
  1008. package/build/execute.js.map +0 -1
  1009. package/build/expressions/arrayAgg.cjs +0 -63
  1010. package/build/expressions/arrayAgg.cjs.map +0 -1
  1011. package/build/expressions/arrayAgg.d.cts +0 -24
  1012. package/build/expressions/arrayAgg.d.cts.map +0 -1
  1013. package/build/expressions/arrayAgg.d.mts +0 -24
  1014. package/build/expressions/arrayAgg.d.mts.map +0 -1
  1015. package/build/expressions/arrayAgg.js +0 -61
  1016. package/build/expressions/arrayAgg.js.map +0 -1
  1017. package/build/expressions/case.cjs +0 -71
  1018. package/build/expressions/case.cjs.map +0 -1
  1019. package/build/expressions/case.d.cts +0 -57
  1020. package/build/expressions/case.d.cts.map +0 -1
  1021. package/build/expressions/case.d.mts +0 -57
  1022. package/build/expressions/case.d.mts.map +0 -1
  1023. package/build/expressions/case.js +0 -68
  1024. package/build/expressions/case.js.map +0 -1
  1025. package/build/expressions/coalesce.cjs +0 -25
  1026. package/build/expressions/coalesce.cjs.map +0 -1
  1027. package/build/expressions/coalesce.d.cts +0 -21
  1028. package/build/expressions/coalesce.d.cts.map +0 -1
  1029. package/build/expressions/coalesce.d.mts +0 -21
  1030. package/build/expressions/coalesce.d.mts.map +0 -1
  1031. package/build/expressions/coalesce.js +0 -22
  1032. package/build/expressions/coalesce.js.map +0 -1
  1033. package/build/expressions/codecs.cjs +0 -126
  1034. package/build/expressions/codecs.cjs.map +0 -1
  1035. package/build/expressions/codecs.d.cts +0 -11
  1036. package/build/expressions/codecs.d.cts.map +0 -1
  1037. package/build/expressions/codecs.d.mts +0 -11
  1038. package/build/expressions/codecs.d.mts.map +0 -1
  1039. package/build/expressions/codecs.js +0 -125
  1040. package/build/expressions/codecs.js.map +0 -1
  1041. package/build/expressions/expression.cjs +0 -102
  1042. package/build/expressions/expression.cjs.map +0 -1
  1043. package/build/expressions/expression.d.cts +0 -23
  1044. package/build/expressions/expression.d.cts.map +0 -1
  1045. package/build/expressions/expression.d.mts +0 -23
  1046. package/build/expressions/expression.d.mts.map +0 -1
  1047. package/build/expressions/expression.js +0 -97
  1048. package/build/expressions/expression.js.map +0 -1
  1049. package/build/expressions/greatest.cjs +0 -25
  1050. package/build/expressions/greatest.cjs.map +0 -1
  1051. package/build/expressions/greatest.d.cts +0 -21
  1052. package/build/expressions/greatest.d.cts.map +0 -1
  1053. package/build/expressions/greatest.d.mts +0 -21
  1054. package/build/expressions/greatest.d.mts.map +0 -1
  1055. package/build/expressions/greatest.js +0 -22
  1056. package/build/expressions/greatest.js.map +0 -1
  1057. package/build/expressions/least.cjs +0 -25
  1058. package/build/expressions/least.cjs.map +0 -1
  1059. package/build/expressions/least.d.cts +0 -21
  1060. package/build/expressions/least.d.cts.map +0 -1
  1061. package/build/expressions/least.d.mts +0 -21
  1062. package/build/expressions/least.d.mts.map +0 -1
  1063. package/build/expressions/least.js +0 -22
  1064. package/build/expressions/least.js.map +0 -1
  1065. package/build/expressions/nullIf.cjs +0 -27
  1066. package/build/expressions/nullIf.cjs.map +0 -1
  1067. package/build/expressions/nullIf.d.cts +0 -22
  1068. package/build/expressions/nullIf.d.cts.map +0 -1
  1069. package/build/expressions/nullIf.d.mts +0 -22
  1070. package/build/expressions/nullIf.d.mts.map +0 -1
  1071. package/build/expressions/nullIf.js +0 -24
  1072. package/build/expressions/nullIf.js.map +0 -1
  1073. package/build/expressions/parseExpression.cjs +0 -75
  1074. package/build/expressions/parseExpression.cjs.map +0 -1
  1075. package/build/expressions/parseExpression.d.cts +0 -19
  1076. package/build/expressions/parseExpression.d.cts.map +0 -1
  1077. package/build/expressions/parseExpression.d.mts +0 -19
  1078. package/build/expressions/parseExpression.d.mts.map +0 -1
  1079. package/build/expressions/parseExpression.js +0 -70
  1080. package/build/expressions/parseExpression.js.map +0 -1
  1081. package/build/expressions/types.d.cts +0 -114
  1082. package/build/expressions/types.d.cts.map +0 -1
  1083. package/build/expressions/types.d.mts +0 -114
  1084. package/build/expressions/types.d.mts.map +0 -1
  1085. package/build/fieldSerde.cjs +0 -188
  1086. package/build/fieldSerde.cjs.map +0 -1
  1087. package/build/fieldSerde.d.cts +0 -87
  1088. package/build/fieldSerde.d.cts.map +0 -1
  1089. package/build/fieldSerde.d.mts +0 -87
  1090. package/build/fieldSerde.d.mts.map +0 -1
  1091. package/build/fieldSerde.js +0 -182
  1092. package/build/fieldSerde.js.map +0 -1
  1093. package/build/keywords.cjs +0 -136
  1094. package/build/keywords.cjs.map +0 -1
  1095. package/build/keywords.d.cts +0 -18
  1096. package/build/keywords.d.cts.map +0 -1
  1097. package/build/keywords.d.mts +0 -18
  1098. package/build/keywords.d.mts.map +0 -1
  1099. package/build/keywords.js +0 -132
  1100. package/build/keywords.js.map +0 -1
  1101. package/build/loadHints.cjs +0 -100
  1102. package/build/loadHints.cjs.map +0 -1
  1103. package/build/loadHints.d.cts +0 -116
  1104. package/build/loadHints.d.cts.map +0 -1
  1105. package/build/loadHints.d.mts +0 -116
  1106. package/build/loadHints.d.mts.map +0 -1
  1107. package/build/loadHints.js +0 -93
  1108. package/build/loadHints.js.map +0 -1
  1109. package/build/loadLens.cjs +0 -213
  1110. package/build/loadLens.cjs.map +0 -1
  1111. package/build/loadLens.d.cts +0 -77
  1112. package/build/loadLens.d.cts.map +0 -1
  1113. package/build/loadLens.d.mts +0 -77
  1114. package/build/loadLens.d.mts.map +0 -1
  1115. package/build/loadLens.js +0 -202
  1116. package/build/loadLens.js.map +0 -1
  1117. package/build/query.cjs +0 -1549
  1118. package/build/query.cjs.map +0 -1
  1119. package/build/query.d.cts +0 -794
  1120. package/build/query.d.cts.map +0 -1
  1121. package/build/query.d.mts +0 -794
  1122. package/build/query.d.mts.map +0 -1
  1123. package/build/query.js +0 -1531
  1124. package/build/query.js.map +0 -1
  1125. package/build/reactiveHints.cjs +0 -332
  1126. package/build/reactiveHints.cjs.map +0 -1
  1127. package/build/reactiveHints.d.cts +0 -143
  1128. package/build/reactiveHints.d.cts.map +0 -1
  1129. package/build/reactiveHints.d.mts +0 -143
  1130. package/build/reactiveHints.d.mts.map +0 -1
  1131. package/build/reactiveHints.js +0 -325
  1132. package/build/reactiveHints.js.map +0 -1
  1133. package/build/scopes.cjs +0 -302
  1134. package/build/scopes.cjs.map +0 -1
  1135. package/build/scopes.d.cts +0 -188
  1136. package/build/scopes.d.cts.map +0 -1
  1137. package/build/scopes.d.mts +0 -188
  1138. package/build/scopes.d.mts.map +0 -1
  1139. package/build/scopes.js +0 -297
  1140. package/build/scopes.js.map +0 -1
  1141. package/build/serde.cjs +0 -500
  1142. package/build/serde.cjs.map +0 -1
  1143. package/build/serde.d.cts +0 -248
  1144. package/build/serde.d.cts.map +0 -1
  1145. package/build/serde.d.mts +0 -248
  1146. package/build/serde.d.mts.map +0 -1
  1147. package/build/serde.js +0 -486
  1148. package/build/serde.js.map +0 -1
  1149. package/build/skipCondition.cjs +0 -15
  1150. package/build/skipCondition.cjs.map +0 -1
  1151. package/build/skipCondition.d.cts +0 -7
  1152. package/build/skipCondition.d.cts.map +0 -1
  1153. package/build/skipCondition.d.mts +0 -7
  1154. package/build/skipCondition.d.mts.map +0 -1
  1155. package/build/skipCondition.js +0 -14
  1156. package/build/skipCondition.js.map +0 -1
  1157. package/build/temporal.cjs +0 -57
  1158. package/build/temporal.cjs.map +0 -1
  1159. package/build/temporal.d.cts +0 -44
  1160. package/build/temporal.d.cts.map +0 -1
  1161. package/build/temporal.d.mts +0 -44
  1162. package/build/temporal.d.mts.map +0 -1
  1163. package/build/temporal.js +0 -55
  1164. package/build/temporal.js.map +0 -1
  1165. package/build/temporalMappers.cjs +0 -63
  1166. package/build/temporalMappers.cjs.map +0 -1
  1167. package/build/temporalMappers.d.cts +0 -36
  1168. package/build/temporalMappers.d.cts.map +0 -1
  1169. package/build/temporalMappers.d.mts +0 -36
  1170. package/build/temporalMappers.d.mts.map +0 -1
  1171. package/build/temporalMappers.js +0 -59
  1172. package/build/temporalMappers.js.map +0 -1
  1173. package/build/unnest.cjs +0 -64
  1174. package/build/unnest.cjs.map +0 -1
  1175. package/build/unnest.d.cts +0 -16
  1176. package/build/unnest.d.cts.map +0 -1
  1177. package/build/unnest.d.mts +0 -16
  1178. package/build/unnest.d.mts.map +0 -1
  1179. package/build/unnest.js +0 -62
  1180. package/build/unnest.js.map +0 -1
  1181. package/build/withLoaded.cjs +0 -65
  1182. package/build/withLoaded.cjs.map +0 -1
  1183. package/build/withLoaded.d.cts +0 -65
  1184. package/build/withLoaded.d.cts.map +0 -1
  1185. package/build/withLoaded.d.mts +0 -65
  1186. package/build/withLoaded.d.mts.map +0 -1
  1187. package/build/withLoaded.js +0 -62
  1188. package/build/withLoaded.js.map +0 -1
  1189. /package/build/{expressions/types.cjs → flush/PendingChanges.cjs} +0 -0
  1190. /package/build/{expressions/types.js → flush/PendingChanges.js} +0 -0
@@ -1,10 +1,10 @@
1
- import { lazyField } from "../newEntity.js";
2
1
  import { PropertyT } from "./PropertySymbols.js";
3
2
  import { RecursiveCycleError } from "./RecursiveCycleError.js";
4
- import { getMetadata } from "../EntityMetadata.js";
5
- import { convertToLoadHint } from "../reactiveHints.js";
6
- import { isLoaded } from "../loadHints.js";
3
+ import { convertToLoadHint } from "../reactivity/reactiveHints.js";
4
+ import { isLoaded } from "../loading/loadHints.js";
7
5
  import { tryResolve } from "../utils.js";
6
+ import { lazyField } from "../newEntity.js";
7
+ import { getMetadata } from "../EntityMetadata.js";
8
8
  import "../Entity.js";
9
9
  //#region src/relations/hasProperty.ts
10
10
  /**
@@ -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,OAAO,IAAI,aAAa,QAAQ,WAAW,UAAU,EAAE;CACzD,CAAC;AACH;;;;;;;;;AAUA,SAAgB,oBACd,cACA,IACgB;C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AAKJ,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"}
@@ -3,8 +3,12 @@ const require_relations_Collection = require("./Collection.cjs");
3
3
  const require_relations_CustomCollection = require("./CustomCollection.cjs");
4
4
  const require_relations_EnumCollection = require("./EnumCollection.cjs");
5
5
  const require_relations_CustomReference = require("./CustomReference.cjs");
6
- const require_relations_hasAsyncMethod = require("./hasAsyncMethod.cjs");
6
+ const require_relations_ReactiveGetter = require("./ReactiveGetter.cjs");
7
+ const require_relations_Relation = require("./Relation.cjs");
8
+ const require_relations_ReadOnlyCollection = require("./ReadOnlyCollection.cjs");
7
9
  const require_relations_RecursiveCycleError = require("./RecursiveCycleError.cjs");
10
+ const require_relations_RecursiveCollection = require("./RecursiveCollection.cjs");
11
+ const require_relations_hasAsyncMethod = require("./hasAsyncMethod.cjs");
8
12
  const require_relations_hasProperty = require("./hasProperty.cjs");
9
13
  const require_relations_AsyncProperty = require("./AsyncProperty.cjs");
10
14
  const require_relations_LazyField = require("./LazyField.cjs");
@@ -14,7 +18,6 @@ const require_relations_Reference = require("./Reference.cjs");
14
18
  const require_relations_hasOneDerived = require("./hasOneDerived.cjs");
15
19
  const require_relations_hasOneThrough = require("./hasOneThrough.cjs");
16
20
  const require_relations_ManyToManyCollection = require("./ManyToManyCollection.cjs");
17
- const require_relations_Relation = require("./Relation.cjs");
18
21
  const require_relations_ManyToManyLargeCollection = require("./ManyToManyLargeCollection.cjs");
19
22
  const require_relations_OneToManyCollection = require("./OneToManyCollection.cjs");
20
23
  const require_relations_ManyToOneReference = require("./ManyToOneReference.cjs");
@@ -23,12 +26,9 @@ const require_relations_ReactiveReference = require("./ReactiveReference.cjs");
23
26
  const require_relations_OneToOneReference = require("./OneToOneReference.cjs");
24
27
  const require_relations_PolymorphicReference = require("./PolymorphicReference.cjs");
25
28
  const require_relations_ReactiveField = require("./ReactiveField.cjs");
26
- const require_relations_ReactiveGetter = require("./ReactiveGetter.cjs");
27
29
  const require_relations_ReactiveManyToMany = require("./ReactiveManyToMany.cjs");
28
30
  const require_relations_ReactiveManyToManyOtherSide = require("./ReactiveManyToManyOtherSide.cjs");
29
31
  const require_relations_AsyncReactiveField = require("./AsyncReactiveField.cjs");
30
- const require_relations_RecursiveCollection = require("./RecursiveCollection.cjs");
31
- const require_relations_ReadOnlyCollection = require("./ReadOnlyCollection.cjs");
32
32
  exports.AsyncPropertyImpl = require_relations_AsyncProperty.AsyncPropertyImpl;
33
33
  exports.CustomCollection = require_relations_CustomCollection.CustomCollection;
34
34
  exports.CustomReference = require_relations_CustomReference.CustomReference;
@@ -2,8 +2,12 @@ import { isCollection, isLoadedCollection } from "./Collection.js";
2
2
  import { CustomCollection, hasCustomCollection } from "./CustomCollection.js";
3
3
  import { EnumCollectionImpl, hasEnumCollection } from "./EnumCollection.js";
4
4
  import { CustomReference, hasCustomReference } from "./CustomReference.js";
5
- import { hasAsyncMethod } from "./hasAsyncMethod.js";
5
+ import { hasReactiveGetter, isReactiveGetter } from "./ReactiveGetter.js";
6
+ import { isRelation } from "./Relation.js";
7
+ import { isLoadedReadOnlyCollection, isReadOnlyCollection } from "./ReadOnlyCollection.js";
6
8
  import { RecursiveCycleError } from "./RecursiveCycleError.js";
9
+ import { hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents } from "./RecursiveCollection.js";
10
+ import { hasAsyncMethod } from "./hasAsyncMethod.js";
7
11
  import { PropertyImpl, hasProperty, hasReactiveProperty, isLoadedProperty, isProperty } from "./hasProperty.js";
8
12
  import { AsyncPropertyImpl, hasAsyncProperty, isAsyncProperty, isLoadedAsyncProperty } from "./AsyncProperty.js";
9
13
  import { LazyFieldImpl, hasLazyField, isLazyField, isLoadedLazyField } from "./LazyField.js";
@@ -13,7 +17,6 @@ import { isLoadedReference, isReference } from "./Reference.js";
13
17
  import { hasOneDerived } from "./hasOneDerived.js";
14
18
  import { hasOneThrough } from "./hasOneThrough.js";
15
19
  import { ManyToManyCollection, hasManyToMany } from "./ManyToManyCollection.js";
16
- import { isRelation } from "./Relation.js";
17
20
  import { ManyToManyLargeCollection, hasLargeManyToMany } from "./ManyToManyLargeCollection.js";
18
21
  import { OneToManyCollection, hasMany } from "./OneToManyCollection.js";
19
22
  import { ManyToOneReferenceImpl, hasOne, isManyToOneReference } from "./ManyToOneReference.js";
@@ -22,10 +25,7 @@ import { ReactiveReferenceImpl, hasReactiveReference, isReactiveReference } from
22
25
  import { OneToOneReferenceImpl, hasOneToOne, isLoadedOneToOneReference, isOneToOneReference } from "./OneToOneReference.js";
23
26
  import { PolymorphicReferenceImpl, hasOnePolymorphic, isPolymorphicReference } from "./PolymorphicReference.js";
24
27
  import { hasReactiveField, isReactiveField } from "./ReactiveField.js";
25
- import { hasReactiveGetter, isReactiveGetter } from "./ReactiveGetter.js";
26
28
  import { ReactiveManyToManyImpl, hasReactiveManyToMany, isReactiveManyToMany } from "./ReactiveManyToMany.js";
27
29
  import { ReactiveManyToManyOtherSideImpl, hasReactiveManyToManyOtherSide, isReactiveManyToManyOtherSide } from "./ReactiveManyToManyOtherSide.js";
28
30
  import { hasAsyncReactiveField, isAsyncReactiveField } from "./AsyncReactiveField.js";
29
- import { hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents } from "./RecursiveCollection.js";
30
- import { isLoadedReadOnlyCollection, isReadOnlyCollection } from "./ReadOnlyCollection.js";
31
31
  export { AsyncPropertyImpl, CustomCollection, CustomReference, EnumCollectionImpl, LazyFieldImpl, ManyToManyCollection, ManyToManyLargeCollection, ManyToOneReferenceImpl, OneToManyCollection, OneToManyLargeCollection, OneToOneReferenceImpl, PolymorphicReferenceImpl, PropertyImpl, ReactiveManyToManyImpl, ReactiveManyToManyOtherSideImpl, ReactiveReferenceImpl, RecursiveCycleError, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, isAsyncProperty, isAsyncReactiveField, isCollection, isLazyField, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToOneReference, isOneToOneReference, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isRelation };
@@ -0,0 +1,11 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_EntityMetadata = require("../EntityMetadata.cjs");
3
+ //#region src/relations/isCascadeDelete.ts
4
+ /** Returns whether this relation is configured for cascade deletion on the entity or a base type. */
5
+ function isCascadeDelete(relation, fieldName) {
6
+ return require_EntityMetadata.getBaseAndSelfMetas(require_EntityMetadata.getMetadata(relation.entity)).some((meta) => meta.config.__data.cascadeDeleteFields.includes(fieldName));
7
+ }
8
+ //#endregion
9
+ exports.isCascadeDelete = isCascadeDelete;
10
+
11
+ //# sourceMappingURL=isCascadeDelete.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isCascadeDelete.cjs","names":["getBaseAndSelfMetas","getMetadata"],"sources":["../../src/relations/isCascadeDelete.ts"],"sourcesContent":["import { getBaseAndSelfMetas, getMetadata } from \"../EntityMetadata.ts\";\nimport type { AbstractRelationImpl } from \"./AbstractRelationImpl.ts\";\n\n// Keep metadata imports out of AbstractRelationImpl so query imports cannot evaluate a relation\n// subclass before its base class has initialized.\n/** Returns whether this relation is configured for cascade deletion on the entity or a base type. */\nexport function isCascadeDelete(relation: AbstractRelationImpl<any, any>, fieldName: string): boolean {\n return getBaseAndSelfMetas(getMetadata(relation.entity)).some((meta) =>\n meta.config.__data.cascadeDeleteFields.includes(fieldName as any),\n );\n}\n"],"mappings":";;;;AAMA,SAAgB,gBAAgB,UAA0C,WAA4B;CACpG,OAAOA,uBAAAA,oBAAoBC,uBAAAA,YAAY,SAAS,MAAM,CAAC,CAAC,CAAC,MAAM,SAC7D,KAAK,OAAO,OAAO,oBAAoB,SAAS,SAAgB,CAClE;AACF"}
@@ -0,0 +1,7 @@
1
+ import { AbstractRelationImpl } from "./AbstractRelationImpl.cjs";
2
+ //#region src/relations/isCascadeDelete.d.ts
3
+ /** Returns whether this relation is configured for cascade deletion on the entity or a base type. */
4
+ declare function isCascadeDelete(relation: AbstractRelationImpl<any, any>, fieldName: string): boolean;
5
+ //#endregion
6
+ export { isCascadeDelete };
7
+ //# sourceMappingURL=isCascadeDelete.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isCascadeDelete.d.cts","names":[],"sources":["../../src/relations/isCascadeDelete.ts"],"mappings":";;;iBAMgB,gBAAgB,UAAU,gCAAgC"}
@@ -0,0 +1,7 @@
1
+ import { AbstractRelationImpl } from "./AbstractRelationImpl.mjs";
2
+ //#region src/relations/isCascadeDelete.d.ts
3
+ /** Returns whether this relation is configured for cascade deletion on the entity or a base type. */
4
+ declare function isCascadeDelete(relation: AbstractRelationImpl<any, any>, fieldName: string): boolean;
5
+ //#endregion
6
+ export { isCascadeDelete };
7
+ //# sourceMappingURL=isCascadeDelete.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isCascadeDelete.d.mts","names":[],"sources":["../../src/relations/isCascadeDelete.ts"],"mappings":";;;iBAMgB,gBAAgB,UAAU,gCAAgC"}
@@ -0,0 +1,10 @@
1
+ import { getBaseAndSelfMetas, getMetadata } from "../EntityMetadata.js";
2
+ //#region src/relations/isCascadeDelete.ts
3
+ /** Returns whether this relation is configured for cascade deletion on the entity or a base type. */
4
+ function isCascadeDelete(relation, fieldName) {
5
+ return getBaseAndSelfMetas(getMetadata(relation.entity)).some((meta) => meta.config.__data.cascadeDeleteFields.includes(fieldName));
6
+ }
7
+ //#endregion
8
+ export { isCascadeDelete };
9
+
10
+ //# sourceMappingURL=isCascadeDelete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isCascadeDelete.js","names":[],"sources":["../../src/relations/isCascadeDelete.ts"],"sourcesContent":["import { getBaseAndSelfMetas, getMetadata } from \"../EntityMetadata.ts\";\nimport type { AbstractRelationImpl } from \"./AbstractRelationImpl.ts\";\n\n// Keep metadata imports out of AbstractRelationImpl so query imports cannot evaluate a relation\n// subclass before its base class has initialized.\n/** Returns whether this relation is configured for cascade deletion on the entity or a base type. */\nexport function isCascadeDelete(relation: AbstractRelationImpl<any, any>, fieldName: string): boolean {\n return getBaseAndSelfMetas(getMetadata(relation.entity)).some((meta) =>\n meta.config.__data.cascadeDeleteFields.includes(fieldName as any),\n );\n}\n"],"mappings":";;;AAMA,SAAgB,gBAAgB,UAA0C,WAA4B;CACpG,OAAO,oBAAoB,YAAY,SAAS,MAAM,CAAC,CAAC,CAAC,MAAM,SAC7D,KAAK,OAAO,OAAO,oBAAoB,SAAS,SAAgB,CAClE;AACF"}
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_EntityMetadata = require("./EntityMetadata.cjs");
3
2
  const require_fields = require("./fields.cjs");
3
+ const require_EntityMetadata = require("./EntityMetadata.cjs");
4
4
  const require_EntityManager = require("./EntityManager.cjs");
5
5
  const require_Entity = require("./Entity.cjs");
6
6
  //#region src/resurrection.ts
@@ -1,5 +1,5 @@
1
- import { getBaseMeta, getMetadata } from "./EntityMetadata.js";
2
1
  import { setField } from "./fields.js";
2
+ import { getBaseMeta, getMetadata } from "./EntityMetadata.js";
3
3
  import { TooManyError } from "./EntityManager.js";
4
4
  import { isEntity } from "./Entity.js";
5
5
  //#region src/resurrection.ts
package/build/rules.cjs CHANGED
@@ -1,12 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("./typeMap.cjs");
2
+ const require_fields = require("./fields.cjs");
3
3
  const require_relations_Reference = require("./relations/Reference.cjs");
4
4
  const require_relations_AsyncReactiveField = require("./relations/AsyncReactiveField.cjs");
5
5
  require("./relations/index.cjs");
6
- const require_fields = require("./fields.cjs");
7
- require("./changes.cjs");
8
- require("./reactiveHints.cjs");
9
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,QAAQ,WAAW;EAGjB,MAAM,SAAS,GAAG,MAAM;EACxB,IAAI,WAAW,KAAA,GAAW;EAC1B,MAAM,EAAE,QAAQ,IAAI,QAAQ,QAA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A;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,MAAM;CAC1C;CACA;CAGA,YAAY,iBAA6C;EACvD,MAAM,OAAO,oBAAoB,WAAW,kBAAkB,aAAa,eAAe,CAAC;EAC3F,KAAK,SAAS,O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a,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"}
package/build/rules.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { FieldsOf } from "./typeMap.cjs";
2
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
- import "./typeMap.js";
1
+ import { getField } from "./fields.js";
2
2
  import { isLoadedReference } from "./relations/Reference.js";
3
3
  import { isAsyncReactiveField } from "./relations/AsyncReactiveField.js";
4
4
  import "./relations/index.js";
5
- import { getField } from "./fields.js";
6
- import "./changes.js";
7
- import "./reactiveHints.js";
8
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,KAAK,SAAS,OAAO,oBAAoB,WAAW,CAAC,EAAE,SAAS,gBAAgB,CAAC,IAAI;EAGrF,KAAK,eAAe,qBAAqB,KAAK;CAChD;AACF;AAEA,SAAS,aACP,MACA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U,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,mBAAb,cAAsC,MAAM;CAC1C;CACA;CAGA,YAAY,iBAA6C;EACvD,MAAM,OAAO,oBAAoB,WAAW,kBAAkB,aAAa,eAAe,CAAC;EAC3F,KAAK,SAAS,OAAO,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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"}
@@ -0,0 +1,80 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/serde/TypeInfo.ts
3
+ /**
4
+ * Normalizes known PostgreSQL type synonyms without treating coercible types or user types as equal.
5
+ * The output compatibility checks compare these names, so normalize only spellings of the same type.
6
+ *
7
+ * I.e. `integer` and `int` both mean `int4`; `integer[]` and `int4[]` also describe the same SQL type.
8
+ * Keeping these spellings distinct would reject compatible outputs just because their serdes use
9
+ * different names for the same representation.
10
+ *
11
+ * I.e. `int4` can be promoted to `int8`, but they are not synonyms: classic pg returns int4 as a number
12
+ * and int8 as a string. Treating them as equal could admit a compound whose first operand's decoder
13
+ * cannot handle the common SQL type. This function does not choose or apply a conversion.
14
+ *
15
+ * I.e. `citext` must stay distinct from `text`: they disagree on whether 'Alice' and 'alice' are equal,
16
+ * which matters when a set operation compares rows. A user-defined `app.email` domain over text can
17
+ * also impose constraints that text does not. Unknown names remain unchanged, including their schema
18
+ * and quoting; neither coercibility nor a shared base type proves that their outputs are compatible.
19
+ */
20
+ function canonicalDbType(dbType) {
21
+ if (dbType.endsWith("[]")) return `${canonicalDbType(dbType.slice(0, -2))}[]`;
22
+ switch (dbType) {
23
+ case "smallint": return "int2";
24
+ case "int":
25
+ case "integer": return "int4";
26
+ case "bigint": return "int8";
27
+ case "decimal": return "numeric";
28
+ case "real": return "float4";
29
+ case "double precision": return "float8";
30
+ case "boolean": return "bool";
31
+ case "character varying": return "varchar";
32
+ case "character": return "bpchar";
33
+ case "timestamp without time zone": return "timestamp";
34
+ case "timestamp with time zone": return "timestamptz";
35
+ case "time without time zone": return "time";
36
+ case "time with time zone": return "timetz";
37
+ default: return dbType;
38
+ }
39
+ }
40
+ const arrayDomains = /* @__PURE__ */ new Map();
41
+ const arrayElementDbTypes = /* @__PURE__ */ new Set([
42
+ "bool",
43
+ "bytea",
44
+ "int2",
45
+ "int4",
46
+ "int8",
47
+ "float4",
48
+ "float8",
49
+ "numeric",
50
+ "text",
51
+ "varchar",
52
+ "bpchar",
53
+ "uuid",
54
+ "json",
55
+ "jsonb"
56
+ ]);
57
+ /**
58
+ * Describes elementwise conversion only for known physical array parsers and stable domain conversion.
59
+ *
60
+ * I.e. `a.id.arrayAgg()` wraps Author's tag and `idMeta` in its domain token, but has no scalar
61
+ * `idMeta` of its own. Repeated expressions share the token; IDs of subtypes with a shared tag do not.
62
+ * Native enum/citext, date/time, and nested SQL arrays remain unknown. Numeric elements can be numbers
63
+ * in classic pg and strings in lazy binary reads, so a scalar string-only mapper is not sufficient.
64
+ */
65
+ function arrayOutputType(outputType) {
66
+ if (!outputType?.arrayElementSafe || !arrayElementDbTypes.has(outputType.dbType)) return void 0;
67
+ let domains = arrayDomains.get(outputType.domain);
68
+ if (!domains) arrayDomains.set(outputType.domain, domains = /* @__PURE__ */ new Map());
69
+ let domain = domains.get(outputType.idMeta);
70
+ if (!domain) domains.set(outputType.idMeta, domain = Symbol("joist.arrayOutput"));
71
+ return {
72
+ dbType: `${outputType.dbType}[]`,
73
+ domain
74
+ };
75
+ }
76
+ //#endregion
77
+ exports.arrayOutputType = arrayOutputType;
78
+ exports.canonicalDbType = canonicalDbType;
79
+
80
+ //# sourceMappingURL=TypeInfo.cjs.map
@@ -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"}
@@ -0,0 +1,57 @@
1
+ import { EntityMetadata } from "../EntityMetadata.cjs";
2
+ //#region src/serde/TypeInfo.d.ts
3
+ /**
4
+ * Runtime proof that values can share scalar conversions.
5
+ *
6
+ * PostgreSQL compares projected SQL rows and chooses a common SQL type before Joist decodes them.
7
+ * A compound uses one decoder per output column and retains an encoder for later comparisons and
8
+ * coalesce fallbacks. TypeScript result types are erased, and equal SQL storage types do not imply
9
+ * equal logical domains.
10
+ *
11
+ * I.e. Author.id and Book.author_id are compatible Author IDs despite having separate serdes, while
12
+ * Book.id must not decode as an Author ID just because both use int4. Author.age and Author.age.sum()
13
+ * both expose TypeScript numbers but produce int4 and int8 driver values. Enum, custom-mapper, and
14
+ * JSON-schema domain tokens also prevent unrelated conversions from mixing.
15
+ *
16
+ * Compatibility requires exact equality of canonical `dbType`, `domain`, and `idMeta`. An absent
17
+ * descriptor is unknown, not an identity codec. `idMeta` identifies scalar IDs only; arrays retain
18
+ * their element domain separately so they cannot select a polymorphic IN component. Raw `sql<R>`
19
+ * annotations supply no runtime evidence. This descriptor does not implement conversions.
20
+ */
21
+ interface TypeInfo {
22
+ dbType: string;
23
+ domain: unknown;
24
+ idMeta?: EntityMetadata;
25
+ /** Internal conversion proof, consistent for equal dbType/domain/idMeta; not another compatibility key. */
26
+ arrayElementSafe?: boolean;
27
+ }
28
+ /**
29
+ * Normalizes known PostgreSQL type synonyms without treating coercible types or user types as equal.
30
+ * The output compatibility checks compare these names, so normalize only spellings of the same type.
31
+ *
32
+ * I.e. `integer` and `int` both mean `int4`; `integer[]` and `int4[]` also describe the same SQL type.
33
+ * Keeping these spellings distinct would reject compatible outputs just because their serdes use
34
+ * different names for the same representation.
35
+ *
36
+ * I.e. `int4` can be promoted to `int8`, but they are not synonyms: classic pg returns int4 as a number
37
+ * and int8 as a string. Treating them as equal could admit a compound whose first operand's decoder
38
+ * cannot handle the common SQL type. This function does not choose or apply a conversion.
39
+ *
40
+ * I.e. `citext` must stay distinct from `text`: they disagree on whether 'Alice' and 'alice' are equal,
41
+ * which matters when a set operation compares rows. A user-defined `app.email` domain over text can
42
+ * also impose constraints that text does not. Unknown names remain unchanged, including their schema
43
+ * and quoting; neither coercibility nor a shared base type proves that their outputs are compatible.
44
+ */
45
+ declare function canonicalDbType(dbType: string): string;
46
+ /**
47
+ * Describes elementwise conversion only for known physical array parsers and stable domain conversion.
48
+ *
49
+ * I.e. `a.id.arrayAgg()` wraps Author's tag and `idMeta` in its domain token, but has no scalar
50
+ * `idMeta` of its own. Repeated expressions share the token; IDs of subtypes with a shared tag do not.
51
+ * Native enum/citext, date/time, and nested SQL arrays remain unknown. Numeric elements can be numbers
52
+ * in classic pg and strings in lazy binary reads, so a scalar string-only mapper is not sufficient.
53
+ */
54
+ declare function arrayOutputType(outputType: TypeInfo | undefined): TypeInfo | undefined;
55
+ //#endregion
56
+ export { TypeInfo, arrayOutputType, canonicalDbType };
57
+ //# sourceMappingURL=TypeInfo.d.cts.map
@@ -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"}