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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tables.js","names":[],"sources":["../../../src/queries/sql/Tables.ts"],"sourcesContent":["import { groupBy } from \"joist-utils\";\n\n// Load configure first: otherwise the built cjs/esm module graph evaluates relations/* before their\n// base classes exist (\"Class extends value undefined\").\nimport { getConstructorFromTaggedId } from \"../../configure.ts\";\nimport { type Entity, isEntity } from \"../../Entity.ts\";\nimport type { IdOf, MaybeAbstractEntityConstructor, TaggedId } from \"../../EntityManager.ts\";\nimport {\n type EntityMetadata,\n type Field,\n type LargeOneToManyField,\n type ManyToManyField,\n type OneToManyField,\n type OneToOneField,\n type PolymorphicField,\n type PolymorphicFieldComponent,\n getBaseAndSelfMetas,\n getBaseMeta,\n getBaseSelfAndSubMetas,\n getMetadata,\n} from \"../../EntityMetadata.ts\";\nimport { maybeResolveReferenceToId, toIdOf } from \"../../keys.ts\";\nimport type { Column } from \"../../serde/columns.ts\";\nimport type { TypeInfo } from \"../../serde/TypeInfo.ts\";\nimport type { ColumnsOf, FieldsOf, FilterOf, TypeMap, TypeNameOf } from \"../../typeMap.ts\";\nimport { fail } from \"../../utils.ts\";\nimport type { SqlCondition } from \"../conditions.ts\";\nimport type { ParsedValueFilter } from \"../parsedConditions.ts\";\nimport { buildValueCondition } from \"../renderConditions.ts\";\nimport { skipCondition } from \"../skipCondition.ts\";\nimport { makeLike, mapToDb, parseEntityFilter, parseValueFilter } from \"../valueFilters.ts\";\nimport {\n BaseExpr,\n type Expr,\n type ExprContext,\n type ExprLike,\n type InnerJoin,\n type LeftJoin,\n type SqlFragment,\n asNode,\n deferredCondition,\n isExpr,\n} from \"./Expr.ts\";\nimport { kqDot } from \"./keywords.ts\";\n\n/** Creates physical column expressions and relationship joins for `T`. */\nexport function table<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>): Table<T>;\n/**\n * Creates a table with an explicit type-level name, i.e. `table(Author, \"m\")` for a self-join.\n *\n * The name is the table's source key in `em.query`: two bare `table(Author)`s share the key `\"Author\"`,\n * so a left-joined mentor would also mark the mentee's columns nullable; a named alias has its own key.\n */\nexport function table<T extends Entity, Name extends string>(\n cstr: MaybeAbstractEntityConstructor<T>,\n name: Name,\n): Table<T, Name>;\nexport function table<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>, _name?: string): unknown {\n // The name only exists at the type level; the SQL alias is still assigned by the query parser\n return newTableProxy(cstr);\n}\n\n/** Creates multiple physical table handles. */\nexport function tables<T extends readonly MaybeAbstractEntityConstructor<any>[]>(\n ...type: T\n): { [P in keyof T]: T[P] extends MaybeAbstractEntityConstructor<infer E extends Entity> ? Table<E> : never } {\n return type.map((t) => newTableProxy(t)) as any;\n}\n\n/**\n * The runtime management interface plus phantom type information for `em.query`.\n *\n * `__entity` lets `QueryRow` recover `T` for entity mode (you cannot `infer T` back out of a mapped\n * type), and `__name` is the table's source key (see `Expr`).\n */\nexport interface TableBrand<T, Name extends string> extends TableMgmt {\n readonly __entity: T;\n readonly __name: Name;\n}\n\n/**\n * A physical table for `T`: one expression per SQL column, with relationship names as join factories.\n * Selecting the table itself retains entity hydration; selecting columns returns decoded SQL values.\n *\n * Unlike an Alias, a Table is an explicit SQL source, not a place to bind in an em.find relationship\n * tree. I.e. with `a = table(Author)`, `{ from: a }` registers that handle in the query's scope.\n * Its columns already know their physical column and codec, but their SQL name still depends on the\n * query: the same Author handle might be `a` in one query and `a1` in a nested query.\n *\n * Each predicate occurrence renders through ExprContext.aliasFor using the current scope (or an\n * enclosing scope for a correlation). Rendering returns SQL, ordered bindings, and source references\n * together. A comparison records both sides' references; templates and subqueries carry their\n * references too. Join pruning follows these references and join dependencies, rather than guessing\n * which tables a SQL string mentions. It also accounts for select/order/group expressions and keep.\n *\n * I.e. if a joined Author is used only by `a.firstName.eq(name)`, supplying undefined removes that\n * predicate and lets the unused join prune. Both APIs share this undefined-condition pruning rule;\n * they differ in how they get the references: Alias resolves domain conditions against a relationship\n * tree, while Table renders SQL expressions against explicit sources. Neither caches SQL names on\n * the reusable handle or predicate, so one parse cannot overwrite another parse's bindings.\n *\n * `Name` is the table's type-level source key, defaulting to the entity's own type name, so a\n * LEFT-joined SmallPublisher does not make Publisher columns nullable. `table(Author, \"m\")`\n * gives a self-join table its own key.\n */\nexport type Table<T extends Entity, Name extends string = TableNameOf<T>> = TableShape<T, Name> &\n (\"where\" extends keyof TableShape<T, Name>\n ? {}\n : {\n /** Builds an AND condition from local domain fields, without implicit joins. */\n where(filter: TableFilter<T>): SqlCondition;\n });\n\n/** Domain filters for fields stored on this physical table, without relationship traversal. */\nexport type TableFilter<T extends Entity> = {\n [K in LocalFieldNames<T> & keyof FieldsOf<T>]?: FieldsOf<T>[K] extends {\n kind: \"m2o\";\n type: infer U extends Entity;\n nullable: infer N;\n }\n ? TableReferenceFilter<U, N extends undefined ? null : never>\n : FilterOf<T>[K];\n};\n\n/** Generated column ownership excludes CTI base fields and polymorphic components. */\ntype LocalFieldNames<T> = ColumnsOf<T>[keyof ColumnsOf<T>] extends { fieldName: infer F }\n ? Extract<F, keyof FilterOf<T>>\n : never;\n\n/** The owning-reference subset of find filters that only compares a foreign key. */\ntype TableReferenceFilter<T extends Entity, N> =\n | T\n | IdOf<T>\n | readonly (T | IdOf<T>)[]\n | boolean\n | N\n | undefined\n | { ne: T | IdOf<T> | N | undefined };\n\ntype TableShape<T extends Entity, Name extends string> = {\n readonly [tableMgmt]: TableBrand<T, Name>;\n} & {\n [P in keyof ColumnsOf<T>]: P extends \"id\"\n ? EntityColumn<T, never, Name>\n : ColumnsOf<T>[P] extends { entity: infer U extends Entity; nullable: infer N }\n ? ReferenceColumn<U, N extends true ? null : never, Name>\n : ColumnsOf<T>[P] extends { type: infer V; nullable: infer N }\n ? PrimitiveColumn<V, N extends true ? null : never, Name>\n : never;\n} & {\n [\n P in keyof FieldsOf<T> as P extends keyof ColumnsOf<T>\n ? never\n : FieldsOf<T>[P] extends { kind: \"m2o\" | \"poly\" | \"o2m\" | \"lo2m\" | \"m2m\" | \"o2o\" }\n ? P\n : never\n ]: FieldsOf<T>[P] extends { kind: \"m2o\"; type: infer U extends Entity; nullable: infer N }\n ? ReferenceJoin<U, N extends undefined ? null : never, Name>\n : FieldsOf<T>[P] extends { kind: \"poly\"; type: infer U extends Entity; nullable: infer N }\n ? PolyReference<U, N extends undefined ? null : never, Name>\n : FieldsOf<T>[P] extends { kind: \"o2m\" | \"lo2m\" | \"m2m\" | \"o2o\"; type: infer U extends Entity }\n ? CollectionJoin<U>\n : never;\n} & {\n [\n K in keyof TypeMap as TypeMap[K] extends {\n entityType: infer U extends Entity & { __type: { 0: TypeNameOf<T>; 1: string } };\n }\n ? Uncapitalize<TypeNameOf<U> & string>\n : never\n ]: TypeMap[K] extends { entityType: infer U extends Entity } ? SubtypeJoin<U> : never;\n};\n\n/** Keeps explicit base and subtype sources independent, with generic entities untracked. */\ntype TableNameOf<T> = T extends { __type: { 0: string } } ? TypeNameOf<T> & string : string;\n\n/** Provides fluent methods for creating joins through an owning reference relationship. */\nexport interface ReferenceJoin<U extends Entity, N extends null | never, Src extends string = string> {\n /**\n * Required reference joins like `b.author.as(a)` are INNER unless `b` is already a LEFT-joined alias.\n * Nullable references are always LEFT joined.\n */\n as<A extends TableFor<U>>(other: A): [N] extends [never] ? DefaultReferenceJoin<A, Src> : LeftJoin<A>;\n inner<A extends TableFor<U>>(other: A): InnerJoin<A>;\n left<A extends TableFor<U>>(other: A): LeftJoin<A>;\n}\n\n/** The source of a default reference join, used to inherit optional paths within each query. */\nexport const referenceJoinSource: unique symbol = Symbol(\"joist.referenceJoinSource\");\n\n/** A required reference defaults to INNER unless its source was LEFT joined. */\nexport type DefaultReferenceJoin<A, Src extends string> = InnerJoin<A> & {\n readonly [referenceJoinSource]: Src;\n};\n\n/** Any table whose entity is (a subtype of) `U`, i.e. what a relation join factory accepts. */\nexport type TableFor<U> = { readonly [tableMgmt]: TableBrand<U, string> };\n\n/**\n * A collection relation (o2m/o2o/m2m) as a join factory: `a.books.as(b)` returns the same\n * `{ left: b, on: ... }` entry the expanded form writes, with the FK condition built from metadata, so\n * join-list inference, nullability, scope checking, and pruning are unchanged and both forms mix freely.\n *\n * `as` binds the joined alias, the same way em.find's `{ books: { as: b } }` does. The default is LEFT\n * (a collection may be empty, and a LEFT join never filters rows, so pruning it is always safe);\n * `.inner(b)` opts into filtering. An m2m entry carries a hidden second join through the join table,\n * which the parser expands; the pair prunes together.\n */\nexport interface CollectionJoin<U extends Entity> {\n as<A extends TableFor<U>>(other: A): LeftJoin<A>;\n inner<A extends TableFor<U>>(other: A): InnerJoin<A>;\n left<A extends TableFor<U>>(other: A): LeftJoin<A>;\n}\n\n/** A named subtype join, defaulting to LEFT because a root row may belong to another subtype. */\ninterface SubtypeJoin<U extends Entity> extends CollectionJoin<U> {\n <A extends TableFor<U>>(other: A): LeftJoin<A>;\n}\n\n/**\n * A physical FK column expression (`b.authorId` selects/compares the `author_id` FK) plus a join factory\n * (`b.authorId.as(a)` joins). The default join kind follows physical column nullability:\n * a NOT NULL FK is INNER unless its source was LEFT joined, a nullable one is LEFT, and the row type reflects it.\n */\nexport interface ReferenceColumn<U extends Entity, N extends null | never, Src extends string>\n extends EntityColumn<U, N, Src>, ReferenceJoin<U, N, Src> {}\n\n/**\n * A polymorphic reference: condition methods (each resolving the component column from the value), plus\n * a join factory that picks the component from the argument's entity, i.e. `c.parent.as(a)` joins\n * through `parent_author_id`, like an explicit join with `on: c.parent.eq(a.id)`.\n */\nexport interface PolyReference<\n U extends Entity,\n N extends null | never,\n Src extends string = string,\n> extends ReferenceJoin<U, N, Src> {\n eq(value: U | TaggedId | ExprLike<IdOf<U> | null> | null | undefined): SqlCondition;\n ne(value: U | TaggedId | ExprLike<IdOf<U> | null> | null | undefined): SqlCondition;\n in(values: readonly (U | TaggedId)[] | ExprLike<IdOf<U> | null> | undefined): SqlCondition;\n /** Applies an IN condition unless the list is empty or undefined. */\n inNonEmpty(values: readonly (U | TaggedId)[] | undefined): SqlCondition;\n}\n\nexport interface PrimitiveColumn<V, N extends null | never, Src extends string = string> extends Expr<V | N, Src> {\n eq(value: V | ExprLike<V | N> | N | undefined): SqlCondition;\n ne(value: V | ExprLike<V | N> | N | undefined): SqlCondition;\n in(values: readonly (V | null)[] | ExprLike<V | null> | undefined): SqlCondition;\n /** Applies an IN condition unless the list is empty or undefined. */\n inNonEmpty(values: readonly (V | null)[] | undefined): SqlCondition;\n nin(values: readonly (V | null)[] | ExprLike<V | null> | undefined): SqlCondition;\n gt(value: V | ExprLike<V | N> | undefined): SqlCondition;\n gte(value: V | ExprLike<V | N> | undefined): SqlCondition;\n lt(value: V | ExprLike<V | N> | undefined): SqlCondition;\n lte(value: V | ExprLike<V | N> | undefined): SqlCondition;\n like(value: V | undefined): SqlCondition;\n ilike(value: V | undefined): SqlCondition;\n search(value: V | undefined): SqlCondition;\n between(v1: V | undefined, v2: V | undefined): SqlCondition;\n // need to move to ArrayColumn\n // ...added the `string` to support jsonb contains like `WHERE profile @> '{\"age\": 25}'`\n // Ideally this would go in a JsonbColumn\n contains(value: string | V | PrimitiveColumn<V, any> | N | undefined): SqlCondition;\n ncontains(value: string | V | PrimitiveColumn<V, any> | N | undefined): SqlCondition;\n overlaps(value: V | PrimitiveColumn<V, any> | N | undefined): SqlCondition;\n noverlaps(value: V | PrimitiveColumn<V, any> | N | undefined): SqlCondition;\n\n /**\n * Adds a JSON path existence condition, using the `@?` operator.\n *\n * Any values should be embedded directly within the `jsonPath`, because postgres does not\n * support parameterized JSON path expressions. The entire `jsonPath` is treated as a parameter,\n * so this is safe from SQL injection.\n */\n pathExists(jsonPath: string | undefined): SqlCondition;\n\n /**\n * Adds a JSON path predicate condition, using the `@@` operator.\n *\n * Any values should be embedded directly within the `jsonPath`, because postgres does not\n * support parameterized JSON path expressions. The entire `jsonPath` is treated as a parameter,\n * so this is safe from SQL injection.\n */\n pathIsTrue(jsonPath: string | undefined): SqlCondition;\n\n /**\n * Add `exp` to the query, which should include the operator & expression and any\n * bound parameters (but not include the column name).\n *\n * We use knex-style placeholders, i.e. `?` and `\\\\?` to escape question marks, i.e.\n *\n * ```ts\n * a.address.raw(\"@\\\\? ?\", ['$.street ? (@ == \"rr2\")'])`\n * ```\n */\n raw(exp: string, bindings: readonly any[] | undefined): SqlCondition;\n}\n\nexport interface EntityColumn<T, N extends null | never = never, Src extends string = string> extends Expr<\n IdOf<T> | N,\n Src\n> {\n eq(value: T | IdOf<T> | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition;\n ne(value: T | IdOf<T> | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition;\n // Adding `| null` for GraphQL support\n in(value: readonly (T | IdOf<T> | null)[] | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition;\n /** Applies an IN condition unless the list is empty, null, or undefined. */\n inNonEmpty(value: readonly (T | IdOf<T> | null)[] | null | undefined): SqlCondition;\n nin(value: readonly (T | IdOf<T> | null)[] | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition;\n gt(value: IdOf<T> | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition;\n gte(value: IdOf<T> | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition;\n lt(value: IdOf<T> | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition;\n lte(value: IdOf<T> | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition;\n raw(exp: string, bindings: readonly any[] | undefined): SqlCondition;\n}\n\nexport const tableMgmt = Symbol(\"tableMgmt\");\n\nexport function getTableMgmt(table: TableFor<unknown>): TableMgmt {\n return table[tableMgmt];\n}\n\n/** The identity SQL queries bind a table by, plus its original entity metadata. */\nexport interface TableMgmt {\n tableName: string;\n /**\n * The metadata this table was created with, i.e. `table(TaskNew)` keeps `taskNewMeta`.\n *\n * It cannot be re-derived from `tableName`: STI subtypes share their base's table (`Task`, `TaskNew`,\n * and `TaskOld` are all `tasks`), so a `getMetadataForTable(\"tasks\")` lookup can only return the base\n * `Task`, and the alias would lose its subtype identity for explicit subtype joins and entity hydration.\n */\n meta: EntityMetadata;\n}\n\n/** Returns the metadata for the entity that `table` is bound to. */\nexport function getTableMetadata<T extends Entity>(table: TableFor<T>): EntityMetadata<T> {\n const mgmt = table[tableMgmt];\n return mgmt.meta as EntityMetadata<T>;\n}\n\nexport function newTableProxy<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>): Table<T> {\n const meta = getMetadata(cstr);\n // The identity SQL queries bind to a source, retaining STI subtype metadata.\n const mgmt: TableMgmt = { tableName: meta.tableName, meta };\n const subtypes = new Map(meta.subTypes.map((m) => [m.type[0].toLowerCase() + m.type.slice(1), m]));\n const proxy: any = new Proxy(cstr, {\n /** Create a physical column expression or a relation join factory. */\n get(_, key: PropertyKey): any {\n if (key === tableMgmt) {\n return mgmt;\n }\n if (typeof key !== \"string\") return undefined;\n const descriptor = Object.hasOwn(meta.columns, key) ? meta.columns[key] : undefined;\n if (descriptor) {\n return descriptor.idMetadata && key !== \"id\"\n ? new EntityColumnImpl(meta, descriptor, mgmt)\n : new PrimitiveColumnImpl(meta, descriptor, mgmt);\n }\n const subtype = subtypes.get(key);\n if (subtype) {\n const join = new SubtypeJoinImpl(proxy, subtype);\n return Object.assign(join.as.bind(join), {\n as: join.as.bind(join),\n inner: join.inner.bind(join),\n left: join.left.bind(join),\n });\n }\n const relation = physicalRelation(meta, key);\n if (key === \"where\" && !isRelation(meta.allFields[key])) {\n return (filter: TableFilter<T>) => tableWhere(mgmt, filter);\n }\n const field = relation ?? fail(`No physical field ${key} on ${cstr.name}; join its base table explicitly`);\n switch (field.kind) {\n case \"m2o\":\n return new ReferenceJoinImpl(new EntityColumnImpl(meta, field.serde.columns[0].column, mgmt));\n case \"poly\":\n return new PolyReferenceImpl(meta, mgmt, field);\n case \"o2m\":\n case \"o2o\":\n case \"lo2m\":\n return new OneToManyJoinImpl(proxy, field);\n case \"m2m\":\n return new ManyToManyJoinImpl(proxy, field);\n default:\n throw new Error(`Unsupported table field kind ${field.kind}`);\n }\n },\n\n has(_, key) {\n return (\n key === tableMgmt ||\n (typeof key === \"string\" &&\n (key === \"where\" || Object.hasOwn(meta.columns, key) || !!physicalRelation(meta, key) || subtypes.has(key)))\n );\n },\n });\n return proxy;\n}\n\nexport function isTable(obj: unknown): obj is Table<any, any> {\n // Oddly enough `typeof` will be a function b/c we are proxying the constructors\n return typeof obj === \"function\" && tableMgmt in obj;\n}\n\n/**\n * A physical table column implements `Expr`: it renders as `alias.\"column\"`, decodes result\n * values through the column's shared scalar codec, and inherits aggregate methods from `BaseExpr`.\n */\nclass TableColumn extends BaseExpr {\n public constructor(\n readonly meta: EntityMetadata,\n readonly column: Column,\n readonly mgmt: TableMgmt,\n ) {\n super();\n }\n\n /** Author.id, Book.authorId, and Comment.parentAuthorId use the same Author ID domain. */\n get outputType(): TypeInfo | undefined {\n return this.column.outputType;\n }\n\n get sqlNullable(): boolean | undefined {\n return this.column.sqlNullable;\n }\n\n get sqlSource(): object {\n return this.mgmt;\n }\n\n toSql(ctx: ExprContext): SqlFragment {\n const alias = ctx.aliasFor(this.mgmt);\n return { sql: kqDot(alias, this.column.columnName), bindings: [], refs: [alias] };\n }\n\n /** Decodes result-set values with public PK/FK ids, while hydration keeps internal tagged ids. */\n decode(value: unknown): unknown {\n if (value === null || value === undefined) return value;\n const idMeta = this.idMetadata;\n if (idMeta) return toIdOf(idMeta, this.column.mapFromDb(value) as TaggedId | undefined);\n return this.column.mapFromDb(value);\n }\n\n encode(value: unknown): unknown {\n return this.column.mapToDb(value);\n }\n\n /** Identifies the ID domain of a primary key, FK, or physical polymorphic component. */\n get idMetadata(): EntityMetadata | undefined {\n return this.column.idMetadata?.();\n }\n\n /** Encodes literals when the condition is created and renders with each query's aliases. */\n addCondition(value: ParsedValueFilter<unknown>): SqlCondition {\n const encoded = mapToDb(this.column, value);\n return deferredCondition((ctx) => {\n const left = this.toSql(ctx);\n const [sql, bindings] = buildValueCondition(left.sql, encoded);\n return { sql, bindings: [...left.bindings, ...bindings], refs: left.refs };\n });\n }\n\n /** Renders raw operators against the same quoted column SQL as other expressions. */\n protected addRawCondition(exp: string, bindings: readonly any[]): SqlCondition {\n return deferredCondition((ctx) => {\n const left = this.toSql(ctx);\n return { sql: `${left.sql} ${exp}`, bindings: [...left.bindings, ...bindings], refs: left.refs };\n });\n }\n\n /** Uses column filter conversions for literals and shared comparisons for expressions and null equality. */\n protected compare(op: string, value: unknown): SqlCondition {\n if (value === undefined || isExpr(value) || (value === null && (op === \"=\" || op === \"!=\"))) {\n return super.compare(op, value);\n }\n // Primitive relational comparisons historically bind null through mapToDb.\n const kind = ({ \"=\": \"eq\", \"!=\": \"ne\", \">\": \"gt\", \">=\": \"gte\", \"<\": \"lt\", \"<=\": \"lte\" } as const)[op];\n if (!kind) return fail(`Invalid operator ${op}`);\n return this.addCondition({ kind, value });\n }\n\n /**\n * Compares this column to another expression.\n *\n * Table columns, aggregates, subquery columns, and `sql` templates use the expression context\n * to render their complete SQL.\n * Negated array operators wrap the complete comparison in NOT.\n */\n protected compareToExpr(op: string, value: ExprLike<any>, negate = false): SqlCondition {\n if (negate) {\n return deferredCondition((ctx) => {\n const comparison = ctx.conditionToSql(this.compareToExpr(op, value))!;\n return { ...comparison, sql: `NOT (${comparison.sql})` };\n });\n }\n return super.compare(op, value);\n }\n}\n\nclass PrimitiveColumnImpl<V, N extends null | never> extends TableColumn implements PrimitiveColumn<V, N> {\n between(v1: V | undefined, v2: V | undefined): SqlCondition {\n if (v1 === undefined || v2 === undefined) return skipCondition;\n return this.addCondition({ kind: \"between\", value: [v1, v2] });\n }\n\n like(value: V | undefined): SqlCondition {\n if (value === undefined) return skipCondition;\n return this.addCondition({ kind: \"like\", value });\n }\n\n ilike(value: V | undefined): SqlCondition {\n if (value === undefined) return skipCondition;\n return this.addCondition({ kind: \"ilike\", value });\n }\n\n search(value: V | undefined): SqlCondition {\n // Check !value so that empty strings are pruned\n if (!value) return skipCondition;\n return this.addCondition({ kind: \"ilike\", value: makeLike(value) });\n }\n\n in(values: readonly (V | null)[] | ExprLike<V | null> | undefined): SqlCondition {\n if (values === undefined) return skipCondition;\n if (isExpr(values)) return this.inList(\"IN\", values);\n if (values.includes(null)) {\n const isNull = this.addCondition({ kind: \"is-null\" });\n const hasValue = this.addCondition({ kind: \"in\", value: values.filter((v) => v !== null) });\n return { or: [isNull, hasValue] };\n } else {\n return this.addCondition({ kind: \"in\", value: values as V[] });\n }\n }\n\n /** Applies an IN condition unless the list is empty or undefined. */\n inNonEmpty(values: readonly (V | null)[] | undefined): SqlCondition {\n return values === undefined || values.length === 0 ? skipCondition : this.in(values);\n }\n\n nin(values: readonly (V | null)[] | ExprLike<V | null> | undefined): SqlCondition {\n if (values === undefined) return skipCondition;\n if (isExpr(values)) return this.inList(\"NOT IN\", values);\n return this.addCondition({ kind: \"nin\", value: values.filter((v) => v !== null) as V[] });\n }\n\n // V will already be an array\n contains(v1: string | V | PrimitiveColumn<V, any> | N | undefined): SqlCondition {\n if (v1 === undefined) return skipCondition;\n if (isExpr(v1)) return this.compareToExpr(\"@>\", v1);\n return this.addCondition({ kind: \"contains\", value: v1 as any });\n }\n\n // V will already be an array\n ncontains(v1: string | V | PrimitiveColumn<V, any> | N | undefined): SqlCondition {\n if (v1 === undefined) return skipCondition;\n if (isExpr(v1)) return this.compareToExpr(\"@>\", v1, true);\n return this.addCondition({ kind: \"ncontains\", value: v1 as any });\n }\n\n // V will already be an array\n overlaps(v1: V | PrimitiveColumn<V, any> | N | undefined): SqlCondition {\n if (v1 === undefined) return skipCondition;\n if (isExpr(v1)) return this.compareToExpr(\"&&\", v1);\n return this.addCondition({ kind: \"overlaps\", value: v1 as any });\n }\n\n noverlaps(v1: V | PrimitiveColumn<V, any> | N | undefined): SqlCondition {\n if (v1 === undefined) return skipCondition;\n if (isExpr(v1)) return this.compareToExpr(\"&&\", v1, true);\n return this.addCondition({ kind: \"noverlaps\", value: v1 as any });\n }\n\n pathExists(jsonPath: string | undefined): SqlCondition {\n if (jsonPath === undefined) return skipCondition;\n return this.addCondition({ kind: \"jsonPathExists\", value: jsonPath });\n }\n\n pathIsTrue(jsonPath: string | undefined): SqlCondition {\n if (jsonPath === undefined) return skipCondition;\n return this.addCondition({ kind: \"jsonPathPredicate\", value: jsonPath });\n }\n\n raw(exp: string, bindings: readonly any[] | undefined): SqlCondition {\n if (bindings === undefined) return skipCondition;\n return this.addRawCondition(exp, bindings);\n }\n}\n\nclass EntityColumnImpl<T> extends TableColumn implements EntityColumn<T> {\n in(values: readonly (T | IdOf<T> | null)[] | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition {\n if (values === undefined) {\n return skipCondition;\n } else if (values === null) {\n throw new Error(\"Unsupported\");\n } else if (isExpr(values)) {\n return this.inList(\"IN\", values);\n } else if (values.includes(null)) {\n // Like `PrimitiveColumn.in`, split `[a1, null]` into `IS NULL OR IN (...)`\n const isNull = this.addCondition({ kind: \"is-null\" });\n const hasValue = this.addCondition({ kind: \"in\", value: values.filter((v) => v !== null) as any });\n return { or: [isNull, hasValue] };\n } else {\n return this.addCondition({ kind: \"in\", value: values as any });\n }\n }\n\n /** Applies an IN condition unless the list is empty, null, or undefined. */\n inNonEmpty(values: readonly (T | IdOf<T> | null)[] | null | undefined): SqlCondition {\n return values === null || values === undefined || values.length === 0 ? skipCondition : this.in(values);\n }\n\n nin(values: readonly (T | IdOf<T> | null)[] | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition {\n if (values === undefined) {\n return skipCondition;\n } else if (values === null) {\n throw new Error(\"Unsupported\");\n } else if (isExpr(values)) {\n return this.inList(\"NOT IN\", values);\n } else {\n return this.addCondition({ kind: \"nin\", value: values.filter((v) => v !== null) as any });\n }\n }\n\n gt(value: IdOf<T> | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition {\n return this.compareId(\">\", \"gt\", value);\n }\n\n gte(value: IdOf<T> | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition {\n return this.compareId(\">=\", \"gte\", value);\n }\n\n lt(value: IdOf<T> | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition {\n return this.compareId(\"<\", \"lt\", value);\n }\n\n lte(value: IdOf<T> | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition {\n return this.compareId(\"<=\", \"lte\", value);\n }\n\n raw(exp: string, bindings: readonly any[] | undefined): SqlCondition {\n if (bindings === undefined) return skipCondition;\n return this.addRawCondition(exp, bindings);\n }\n\n /** Joins via this FK, inheriting the source's LEFT join for otherwise required references. */\n as(other: object): object {\n return {\n ...this.joinEntry(this.sqlNullable === false ? \"inner\" : \"left\", other),\n [referenceJoinSource]: this.mgmt,\n };\n }\n\n inner(other: object): object {\n return this.joinEntry(\"inner\", other);\n }\n\n left(other: object): object {\n return this.joinEntry(\"left\", other);\n }\n\n private joinEntry(kind: JoinKind, other: object): object {\n return { [kind]: requireTable(other), on: this.eq(idColumnOf(other)) };\n }\n\n private compareId(op: string, kind: \"gt\" | \"gte\" | \"lt\" | \"lte\", value: unknown): SqlCondition {\n if (value === undefined) return skipCondition;\n if (value === null) throw new Error(\"Unsupported\");\n if (isExpr(value)) return this.compareToExpr(op, value);\n return this.addCondition({ kind, value: value as any });\n }\n}\n\nclass PolyReferenceImpl<T extends Entity> {\n public constructor(\n private meta: EntityMetadata,\n private mgmt: TableMgmt,\n private field: PolymorphicField,\n ) {}\n\n /** Compares to a tagged id, an entity, or another table's id column, which picks the component (`c.parent.eq(a.id)`). */\n eq(value: T | TaggedId | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition {\n return this.addEqOrNe(\"eq\", value);\n }\n\n ne(value: T | TaggedId | ExprLike<IdOf<T> | null> | null | undefined): SqlCondition {\n return this.addEqOrNe(\"ne\", value);\n }\n\n // We required tagged ids for polys\n in(values: readonly (T | TaggedId)[] | ExprLike<IdOf<T> | null> | undefined): SqlCondition {\n if (values === undefined) return skipCondition;\n if (isExpr(values)) return this.inSubquery(values);\n // Split up the ids by constructor\n const idsByConstructor = groupBy(values, (id) => getConstructorFromTaggedId(maybeResolveReferenceToId(id)!).name);\n // Or together `parent_book_id in (1,2,3) OR parent_author_id IN (4,5,6)`\n return {\n or: Object.entries(idsByConstructor).map(([cstrName, ids]) => {\n const comp =\n this.field.components.find((p) => p.otherMetadata().cstr.name === cstrName) ??\n fail(`No component for ${cstrName}`);\n return this.componentColumn(comp).addCondition({ kind: \"in\", value: ids });\n }),\n };\n }\n\n /** Applies an IN condition unless the list is empty or undefined. */\n inNonEmpty(values: readonly (T | TaggedId)[] | undefined): SqlCondition {\n return values === undefined || values.length === 0 ? skipCondition : this.in(values);\n }\n\n /** Joins via this poly's component, inheriting the source's LEFT join when the poly is required. */\n as(other: object): object {\n return { ...this.joinEntry(this.field.required ? \"inner\" : \"left\", other), [referenceJoinSource]: this.mgmt };\n }\n\n inner(other: object): object {\n return this.joinEntry(\"inner\", other);\n }\n\n left(other: object): object {\n return this.joinEntry(\"left\", other);\n }\n\n private joinEntry(kind: JoinKind, other: object): object {\n return { [kind]: requireTable(other), on: this.eq(idColumnOf(other) as any) };\n }\n\n /**\n * i.e. `c.parent.in(query({ from: a, ..., select: a.id }))`: like `eq` against a table column, the\n * subquery's agreed ID domain picks the component, i.e. authors pick `parent_author_id`.\n */\n private inSubquery(values: ExprLike<any>): SqlCondition {\n // Only actual subqueries expose this getter; importing query.ts would create a load-order cycle.\n const selected = asNode(values).subquerySelect;\n const outputType = selected?.outputType;\n let otherMeta = outputType?.idMeta;\n if (!otherMeta) {\n // Ordinary reads can select an unknown key serde. Compounds validate codecs before exposing a select.\n if (!outputType && selected instanceof TableColumn) {\n otherMeta = selected.idMetadata;\n }\n if (!otherMeta) {\n return fail(\n selected instanceof TableColumn\n ? `${this.field.fieldName} \\`in\\` needs an id or FK column, got ${selected.column.columnName}`\n : `${this.field.fieldName} is polymorphic, so \\`in\\` needs a subquery selecting an id or FK column`,\n );\n }\n }\n const comp =\n this.field.components.find((p) => getBaseAndSelfMetas(otherMeta).includes(p.otherMetadata())) ??\n fail(`${this.field.fieldName} has no component for ${otherMeta.type}`);\n return this.componentColumn(comp).in(values);\n }\n\n private addEqOrNe(\n kind: \"eq\" | \"ne\",\n value: T | TaggedId | ExprLike<IdOf<T> | null> | null | undefined,\n ): SqlCondition {\n if (value === undefined) {\n return skipCondition;\n } else if (value instanceof TableColumn) {\n // Joining through the poly, i.e. `c.parent.eq(a.id)`: the other table column's ID domain picks the component\n const otherMeta = value.idMetadata ?? fail(`${this.field.fieldName} needs an id or FK column`);\n const comp =\n this.field.components.find((p) => getBaseAndSelfMetas(otherMeta).includes(p.otherMetadata())) ??\n fail(`${this.field.fieldName} has no component for ${otherMeta.type}`);\n return this.componentColumn(comp)[kind](value);\n } else if (isExpr(value)) {\n return fail(\n `${this.field.fieldName} is polymorphic, so it can only be compared to tagged ids or entity table columns`,\n );\n } else if (value === null) {\n // We can AND each of the components as many conditions\n const value = kind === \"eq\" ? ({ kind: \"is-null\" } as const) : ({ kind: \"not-null\" } as const);\n return {\n and: this.field.components.map((p) => this.componentColumn(p).addCondition(value)),\n };\n } else {\n // If we have a value, we can find the component\n const comp =\n this.field.components.find(\n (p) => p.otherMetadata().cstr === getConstructorFromTaggedId(maybeResolveReferenceToId(value) as string),\n ) || fail(`Could not find component for ${value}`);\n return this.componentColumn(comp)[kind](value);\n }\n }\n\n /** Returns the physical FK expression for one polymorphic target. */\n private componentColumn(comp: PolymorphicFieldComponent): EntityColumnImpl<T> {\n const descriptor = comp.column;\n return new EntityColumnImpl<T>(this.meta, descriptor, this.mgmt);\n }\n}\n\n/**\n * Marks a sugar join entry whose target is a *collection* (o2m/m2m), which filter soft-deletes like\n * em.find's \"collections filter out soft-deletes, but m2o/o2o references still return them\"; see\n * `QueryParser.addSoftDeleteCondition`'s call site. Reference joins and explicit joins are unmarked.\n */\nexport const collectionJoin: unique symbol = Symbol(\"joist.collectionJoin\");\n\n/** Marks a sugar m2m join entry (`a.tags.as(t)`) with its hidden join-table join; `parseQuery` expands it. */\nexport const m2mJoinTable: unique symbol = Symbol(\"joist.m2mJoinTable\");\n\nexport interface M2mJoinTable {\n handle: JoinTableHandle;\n on: SqlCondition;\n}\n\n/** The runtime identity of an m2m join table in a query, i.e. `authors_to_tags`; it has no entity. */\nexport class JoinTableHandle {\n constructor(readonly joinTableName: string) {}\n}\n\ntype JoinKind = \"inner\" | \"left\";\n\n/**\n * The `as`/`inner`/`left` join factory for collection relations, i.e. `a.books.as(b)` joins with the\n * relation's default kind (LEFT: a collection may be empty) and `.inner`/`.left` override. m2o/poly\n * relations implement the same three methods on their join factories. Physical FKs such as\n * `b.author_id` are expressions that also expose a join factory.\n */\nabstract class CollectionJoinImpl {\n as(other: object): object {\n return this.joinEntry(\"left\", requireTable(other));\n }\n\n inner(other: object): object {\n return this.joinEntry(\"inner\", requireTable(other));\n }\n\n left(other: object): object {\n return this.joinEntry(\"left\", requireTable(other));\n }\n\n protected abstract joinEntry(kind: JoinKind, other: TableFor<Entity>): object;\n}\n\n/** Joins a named subtype explicitly; only STI subtype sugar adds a discriminator to its ON. */\nclass SubtypeJoinImpl extends CollectionJoinImpl {\n constructor(\n private proxy: TableFor<Entity>,\n private subtype: EntityMetadata,\n ) {\n super();\n }\n\n protected joinEntry(kind: JoinKind, other: TableFor<Entity>): object {\n if (getTableMetadata(other) !== this.subtype) {\n return fail(`Expected table(${this.subtype.type}) for the explicit subtype join`);\n }\n const on = idColumnOf(this.proxy).eq(idColumnOf(other));\n if (this.subtype.inheritanceType !== \"sti\" || this.subtype.stiDiscriminatorValue === undefined) {\n return { [kind]: other, on };\n }\n const base = this.subtype.baseTypes.find((m) => m.stiDiscriminatorField !== undefined)!;\n const columnName = base.fields[base.stiDiscriminatorField!].serde!.columns[0].columnName;\n // Discriminator values are database enum ids, not domain enum values to pass through the field codec.\n const discriminator = deferredCondition((ctx) => {\n const alias = ctx.aliasFor(other[tableMgmt]);\n return {\n sql: `${kqDot(alias, columnName)} = ?`,\n bindings: [this.subtype.stiDiscriminatorValue],\n refs: [alias],\n };\n });\n return { [kind]: other, on: { and: [on, discriminator] } };\n }\n}\n\n/** An o2m/lo2m/o2o relation: the ON is the other side's FK (an m2o or a poly component) back to our id. */\nclass OneToManyJoinImpl extends CollectionJoinImpl {\n constructor(\n private proxy: any,\n private field: OneToManyField | LargeOneToManyField | OneToOneField,\n ) {\n super();\n }\n\n protected joinEntry(kind: JoinKind, other: TableFor<Entity>): object {\n const { field } = this;\n const otherMeta = getTableMetadata(other);\n const descriptor = Object.values(otherMeta.columns).find((column) => column.columnName === field.otherColumnName);\n if (!descriptor) {\n return fail(\n `Cannot join ${getTableMetadata(this.proxy).type}.${field.fieldName} to ${otherMeta.type}: ` +\n `${field.otherColumnName} is not physically present on ${otherMeta.tableName}; join the base table explicitly`,\n );\n }\n const column = new EntityColumnImpl(otherMeta, descriptor, other[tableMgmt]);\n const on = column.eq(this.proxy.id);\n // Collections (o2m/lo2m) filter soft-deletes like em.find; o2o references resolve them\n const filtered = field.kind === \"o2m\" ? field.softDeletes !== \"include\" : field.kind === \"lo2m\";\n return { [kind]: other, on, [collectionJoin]: filtered };\n }\n}\n\n/**\n * An m2m relation, i.e. `a.tags.as(t)`.\n *\n * The entry's own ON is `t.id = att.tag_id`, and the hidden `[m2mJoinTable]` half is\n * `att.author_id = a.id`; only the target's ON references the join table, so reference pruning keeps\n * or drops the pair together. Both are deferred conditions: the join table has no entity metadata, so\n * its alias only exists once the parser registers it.\n */\nclass ManyToManyJoinImpl extends CollectionJoinImpl {\n constructor(\n private proxy: any,\n private field: ManyToManyField,\n ) {\n super();\n }\n\n protected joinEntry(kind: JoinKind, other: TableFor<Entity>): object {\n const { joinTableName, columnNames } = this.field;\n const [ourColumn, otherColumn] = columnNames;\n const jt = new JoinTableHandle(joinTableName);\n const ourId = idColumnOf(this.proxy);\n const otherId = idColumnOf(other);\n const jtOn = deferredCondition((ctx) => {\n const jtAlias = ctx.aliasFor(jt);\n const id = ourId.toSql(ctx);\n return { sql: `${kqDot(jtAlias, ourColumn)} = ${id.sql}`, bindings: id.bindings, refs: id.refs };\n });\n const on = deferredCondition((ctx) => {\n const jtAlias = ctx.aliasFor(jt);\n const id = otherId.toSql(ctx);\n return { sql: `${id.sql} = ${kqDot(jtAlias, otherColumn)}`, bindings: id.bindings, refs: [...id.refs, jtAlias] };\n });\n const filtered = this.field.softDeletes !== \"include\";\n return {\n [kind]: other,\n on,\n [collectionJoin]: filtered,\n [m2mJoinTable]: { handle: jt, on: jtOn } satisfies M2mJoinTable,\n };\n }\n}\n\n/** Fails fast when a join factory is passed something other than a table. */\nfunction requireTable(other: object): TableFor<Entity> {\n if (!isTable(other)) return fail(`Expected a table to join, got ${other}`);\n return other;\n}\n\n/** The id column of a joined table, for building sugar ON conditions. */\nfunction idColumnOf(other: object): TableColumn {\n return (other as any).id;\n}\n\n/** Keeps relation names join-only; physical FK columns retain expression methods. */\nclass ReferenceJoinImpl {\n constructor(private column: EntityColumnImpl<unknown>) {}\n\n as(other: object): object {\n return this.column.as(other);\n }\n\n inner(other: object): object {\n return this.column.inner(other);\n }\n\n left(other: object): object {\n return this.column.left(other);\n }\n}\n\n/** Identifies domain relationship keys exposed alongside physical columns. */\nfunction isRelation(field: Field | undefined): boolean {\n return field !== undefined && [\"m2o\", \"poly\", \"o2m\", \"lo2m\", \"m2m\", \"o2o\"].includes(field.kind);\n}\n\n/** Resolves relationship sugar only from domain fields owned by this physical table. */\nfunction physicalRelation(meta: EntityMetadata, key: string): Field | undefined {\n const owners = [meta, ...getBaseSelfAndSubMetas(getBaseMeta(meta))];\n const owner = owners.find((owner) => owner.tableName === meta.tableName && Object.hasOwn(owner.fields, key));\n const field = owner?.fields[key];\n if (!isRelation(field)) return undefined;\n // I.e. TaskNew.copiedFrom uses Task's original FK domain, not its specialized TaskNew target.\n if (field?.kind === \"m2o\" || field?.kind === \"poly\") {\n if (!field.serde.columns.every((binding) => Object.values(meta.columns).includes(binding.column))) return undefined;\n return field.kind === \"poly\"\n ? {\n ...field,\n components: field.components.map((component) => ({\n column: component.column,\n columnName: component.columnName,\n otherFieldName: component.otherFieldName,\n otherMetadata: component.column.idMetadata!,\n })),\n }\n : field;\n }\n return field;\n}\n\n/**\n * Maps local domain fields to table-bound conditions, encoding each leaf once.\n * I.e. Author.firstName uses the first_name column but resolves its alias in each query scope.\n * Collections, polymorphic references, and inherited nonlocal fields require explicit expressions.\n */\nfunction tableWhere(mgmt: TableMgmt, filter: object): SqlCondition {\n const { meta } = mgmt;\n const conditions: SqlCondition[] = [];\n if (!filter || typeof filter !== \"object\" || Array.isArray(filter)) {\n throw new Error(`Expected a domain field filter for ${meta.type}`);\n }\n for (const [key, value] of Object.entries(filter)) {\n // CTI allFields.id points at the base key; the subtype has its own physical key.\n const field = key === \"id\" ? meta.fields.id : Object.hasOwn(meta.allFields, key) ? meta.allFields[key] : undefined;\n if (\n !field ||\n ![\"primaryKey\", \"primitive\", \"enum\", \"m2o\"].includes(field.kind) ||\n !field.serde ||\n field.serde.columns.length !== 1 ||\n !field.serde.columns.every((binding) => Object.values(meta.columns).includes(binding.column))\n ) {\n throw new Error(`Unsupported table filter field ${meta.type}.${key}; use an explicit join`);\n }\n const column = new TableColumn(meta, field.serde.columns[0].column, mgmt);\n let leaves: ParsedValueFilter<unknown>[];\n if (field.kind === \"m2o\") {\n if (!isTableReferenceFilter(value)) {\n throw new Error(`Unsupported table reference filter ${meta.type}.${key}; use an entity or ID`);\n }\n const parsed = parseEntityFilter(field.otherMetadata(), value);\n if (parsed?.kind === \"join\") {\n throw new Error(`Unsupported table reference filter ${meta.type}.${key}; use an entity or ID`);\n }\n leaves = parsed ? [parsed] : [];\n } else {\n leaves = parseValueFilter(value);\n }\n for (const leaf of leaves) {\n if (leaf.kind === \"between\" && leaf.value.some((v) => v === undefined)) {\n if (leaf.value[0] !== undefined) conditions.push(column.addCondition({ kind: \"gte\", value: leaf.value[0] }));\n if (leaf.value[1] !== undefined) conditions.push(column.addCondition({ kind: \"lte\", value: leaf.value[1] }));\n } else if (leaf.kind === \"in\" && !column.column.isArray && leaf.value.includes(null)) {\n conditions.push({\n or: [\n column.addCondition({ kind: \"is-null\" }),\n column.addCondition({ kind: \"in\", value: leaf.value.filter((v) => v !== null) }),\n ],\n });\n } else {\n conditions.push(column.addCondition(leaf));\n }\n }\n }\n return conditions.length === 0 ? skipCondition : { and: conditions };\n}\n\n/** Rejects nested relations, scopes, and aliases before parsing owning-reference values. */\nfunction isTableReferenceFilter(value: unknown): boolean {\n if (value == null || typeof value === \"boolean\" || isTableReferenceValue(value)) return true;\n if (Array.isArray(value)) return value.every(isTableReferenceValue);\n if (typeof value === \"object\" && Object.keys(value).length === 1 && Object.hasOwn(value, \"ne\")) {\n const excluded = (value as { ne: unknown }).ne;\n return excluded == null || isTableReferenceValue(excluded);\n }\n return false;\n}\n\n/** Recognizes an entity or public ID without accepting another filter object. */\nfunction isTableReferenceValue(value: unknown): boolean {\n return typeof value === \"string\" || typeof value === \"number\" || isEntity(value);\n}\n"],"mappings":";;;;;;;;;;;;AAyDA,SAAgB,MAAwB,MAAyC,OAAyB;CAExG,OAAO,cAAc,IAAI;AAC3B;;AAGA,SAAgB,OACd,GAAG,MACyG;CAC5G,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC,CAAC;AACzC;;AAyHA,MAAa,sBAAqC,OAAO,2BAA2B;AAgIpF,MAAa,YAAY,OAAO,WAAW;AAE3C,SAAgB,aAAa,OAAqC;CAChE,OAAO,MAAM;AACf;;AAgBA,SAAgB,iBAAmC,OAAuC;CAExF,OADa,MAAM,UACR,CAAC;AACd;AAEA,SAAgB,cAAgC,MAAmD;CACjG,MAAM,OAAO,YAAY,IAAI;CAE7B,MAAM,OAAkB;EAAE,WAAW,KAAK;EAAW;CAAK;CAC1D,MAAM,WAAW,IAAI,IAAI,KAAK,SAAS,KAAK,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,YAAY,IAAI,EAAE,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;CACjG,MAAM,QAAa,IAAI,MAAM,MAAM;;EAEjC,IAAI,GAAG,KAAuB;GAC5B,IAAI,QAAQ,WACV,OAAO;GAET,IAAI,OA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AAK,EACd,IAAI,CACF,OAAO,aAAa,EAAE,MAAM,UAAU,CAAC,GACvC,OAAO,aAAa;GAAE,MAAM;GAAM,OAAO,KAAK,MAAM,QAAQ,MAAM,MAAM,IAAI;EAAE,CAAC,CACjF,EACF,CAAC;OAED,WAAW,KAAK,OAAO,aAAa,IAAI,CAAC;CAG/C;CACA,OAAO,WAAW,WAAW,IAAI,gBAAgB,EAAE,KAAK,WAAW;AACrE;;AAGA,SAAS,uBAAuB,OAAyB;CACvD,IAAI,SAAS,QAAQ,OAAO,UAAU,aAAa,sBAAsB,KAAK,GAAG,OAAO;CACxF,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,MAAM,qBAAqB;CAClE,IAAI,OAAO,UAAU,YAAY,OAAO,KAAK,KAAK,CAAC,CAAC,WAAW,KAAK,OAAO,OAAO,OAAO,IAAI,GAAG;EAC9F,MAAM,WAAY,MAA0B;EAC5C,OAAO,YAAY,QAAQ,sBAAsB,QAAQ;CAC3D;CACA,OAAO;AACT;;AAGA,SAAS,sBAAsB,OAAyB;CACtD,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,SAAS,KAAK;AACjF"}
@@ -0,0 +1,236 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_keys = require("../../keys.cjs");
3
+ const require_queries_sql_keywords = require("./keywords.cjs");
4
+ const require_queries_sql_Expr = require("./Expr.cjs");
5
+ const require_utils = require("../../utils.cjs");
6
+ const require_queries_sql_AliasAssigner = require("./AliasAssigner.cjs");
7
+ const require_queries_sql_Tables = require("./Tables.cjs");
8
+ const require_queries_sql_query = require("./query.cjs");
9
+ const require_Entity = require("../../Entity.cjs");
10
+ //#region src/queries/sql/execute.ts
11
+ /** Classifies mutation roots before EntityManager applies write permissions, including malformed roots. */
12
+ function isMutation(arg) {
13
+ return typeof arg === "object" && arg !== null && !require_queries_sql_query.isReadQueryValue(arg) && [
14
+ "insert",
15
+ "update",
16
+ "delete"
17
+ ].some((key) => key in arg);
18
+ }
19
+ /**
20
+ * Compiles one immediate statement using the read compiler's scopes, projections, and codecs.
21
+ * INSERT SELECT keeps source rows in PostgreSQL; only RETURNING rows pass through JS decoders.
22
+ * An undefined plan represents a validated standalone empty VALUES array, not DEFAULT VALUES.
23
+ */
24
+ function parseStatement(arg) {
25
+ if (!isMutation(arg)) return require_queries_sql_query.parseUserQuery(arg);
26
+ const statement = arg;
27
+ const roots = [
28
+ "insert",
29
+ "update",
30
+ "delete"
31
+ ].filter((key) => key in statement);
32
+ if (roots.length !== 1) require_utils.fail("A mutation requires exactly one insert, update, or delete root");
33
+ const operation = roots[0];
34
+ checkPojo(statement, operation === "insert" ? [
35
+ "insert",
36
+ "values",
37
+ "from",
38
+ "returning",
39
+ "with"
40
+ ] : [
41
+ operation,
42
+ "where",
43
+ "allowAll",
44
+ "softDeletes",
45
+ "returning",
46
+ "with",
47
+ ...operation === "update" ? ["set"] : []
48
+ ], `SQL ${operation}`);
49
+ const target = statement[operation];
50
+ if (!require_queries_sql_Tables.isTable(target)) require_utils.fail("A mutation target must be an entity table");
51
+ const mgmt = require_queries_sql_Tables.getTableMgmt(target);
52
+ const meta = mgmt.meta;
53
+ if (meta.inheritanceType || meta.baseType || meta.baseTypes.length || meta.subTypes.length) require_utils.fail("SQL mutations do not support CTI/STI targets or inherited table families");
54
+ if (meta.supportsEmExecute !== true) require_utils.fail(`SQL mutations require supported physical metadata for ${meta.type}; run codegen`);
55
+ const fields = Object.entries(meta.columns);
56
+ for (const [, field] of fields) requireColumnMetadata(meta, field);
57
+ const assigner = new require_queries_sql_AliasAssigner.AliasAssigner();
58
+ const withCtx = new require_queries_sql_query.Ctx(assigner, void 0);
59
+ const ctes = require_queries_sql_query.registerCtes(statement, withCtx, assigner);
60
+ const refs = [];
61
+ const ctx = new require_queries_sql_query.Ctx(assigner, withCtx);
62
+ const alias = assigner.getAlias(meta.tableName);
63
+ ctx.register(mgmt, alias);
64
+ const returning = statement.returning === void 0 ? void 0 : require_queries_sql_query.projectionToSql(statement.returning, ctx);
65
+ if (returning) for (const select of returning.selects) refs.push(...select.refs);
66
+ let sql = `${operation === "delete" ? "DELETE FROM" : operation.toUpperCase() + (operation === "insert" ? " INTO" : "")} ${require_queries_sql_keywords.kq(meta.tableName)} AS ${require_queries_sql_keywords.kq(alias)}`;
67
+ const bindings = [];
68
+ if (operation === "insert") {
69
+ if ("values" in statement === "from" in statement) require_utils.fail("INSERT requires exactly one of values or from");
70
+ const required = fields.filter(([, column]) => column.insert === "required");
71
+ if ("values" in statement) {
72
+ const rows = Array.isArray(statement.values) ? statement.values : [statement.values];
73
+ const valuesCtx = new require_queries_sql_query.Ctx(assigner, withCtx);
74
+ const entries = rows.map((row) => assignments(meta, row, "insert"));
75
+ for (const row of entries) for (const [key] of required) if (!row.some((entry) => entry[0] === key)) require_utils.fail(`INSERT requires ${meta.type}.${key}`);
76
+ if (rows.length === 0) return void 0;
77
+ const keys = fields.filter(([key]) => entries.some((row) => row.some((entry) => entry[0] === key)));
78
+ sql += ` (${keys.map(([, field]) => require_queries_sql_keywords.kq(field.columnName)).join(", ")}) VALUES `;
79
+ sql += entries.map((row) => {
80
+ return `(${keys.map(([key, field]) => {
81
+ const entry = row.find((entry) => entry[0] === key);
82
+ if (!entry) return "DEFAULT";
83
+ const cell = assignmentToSql(meta, field, entry[1], valuesCtx);
84
+ bindings.push(...cell.bindings);
85
+ refs.push(...cell.refs);
86
+ return cell.sql;
87
+ }).join(", ")})`;
88
+ }).join(", ");
89
+ } else {
90
+ const source = require_queries_sql_query.parseNestedQuery(statement.from, withCtx, assigner);
91
+ if (source.output.kind !== "pojo") require_utils.fail("INSERT SELECT requires named POJO output columns");
92
+ const columns = source.output.columns;
93
+ for (const [key] of required) if (!columns.some((column) => column[0] === key)) require_utils.fail(`INSERT requires ${meta.type}.${key}`);
94
+ for (const [key, expr] of columns) {
95
+ const field = writableField(meta, key, "insert");
96
+ const left = field.outputType;
97
+ const right = expr.outputType;
98
+ if (!left || !right || left.dbType !== right.dbType || left.domain !== right.domain || left.idMeta !== right.idMeta) require_utils.fail(`INSERT SELECT ${meta.type}.${key} has incompatible or unknown storage codecs`);
99
+ if (!field.sqlNullable && expr.sqlNullable === true) require_utils.fail(`INSERT SELECT ${meta.type}.${key} cannot accept a nullable output`);
100
+ }
101
+ const keys = fields.filter(([key]) => columns.some((column) => column[0] === key));
102
+ const sourceAlias = require_queries_sql_keywords.safeKq(assigner.getLiteralAlias("sq"));
103
+ sql += ` (${keys.map(([, field]) => require_queries_sql_keywords.kq(field.columnName)).join(", ")}) SELECT ${keys.map(([key]) => `${sourceAlias}.${require_queries_sql_keywords.safeKq(key)}`).join(", ")} FROM (${source.sql}) AS ${sourceAlias}`;
104
+ bindings.push(...source.bindings);
105
+ refs.push(...source.outerRefs);
106
+ }
107
+ } else {
108
+ if (statement.allowAll !== void 0 && typeof statement.allowAll !== "boolean") require_utils.fail("allowAll must be a boolean");
109
+ if (statement.softDeletes !== void 0 && statement.softDeletes !== "include" && statement.softDeletes !== "exclude") require_utils.fail("softDeletes must be 'include' or 'exclude'");
110
+ const user = mutationCondition(statement.where, ctx);
111
+ if (!user && statement.allowAll !== true) require_utils.fail("UPDATE and DELETE require a nonempty user where or allowAll: true");
112
+ if (operation === "update") {
113
+ const entries = assignments(meta, statement.set, "update");
114
+ sql += " SET " + entries.map((entry) => {
115
+ const [key, value] = entry;
116
+ const field = writableField(meta, key, "update");
117
+ const cell = assignmentToSql(meta, field, value, ctx);
118
+ bindings.push(...cell.bindings);
119
+ refs.push(...cell.refs);
120
+ return `${require_queries_sql_keywords.kq(field.columnName)} = ${cell.sql}`;
121
+ }).join(", ");
122
+ }
123
+ const conditions = [user, require_queries_sql_query.conditionToSql({ and: require_queries_sql_query.injectedConditions({
124
+ meta,
125
+ alias
126
+ }, statement.softDeletes ?? "exclude") }, ctx, true)].filter((condition) => condition !== void 0);
127
+ if (conditions.length) {
128
+ sql += ` WHERE ${conditions.map((condition) => `(${condition.sql})`).join(" AND ")}`;
129
+ for (const condition of conditions) {
130
+ bindings.push(...condition.bindings);
131
+ refs.push(...condition.refs);
132
+ }
133
+ }
134
+ }
135
+ if (returning) {
136
+ sql += ` RETURNING ${returning.selects.map((select) => select.sql).join(", ")}`;
137
+ for (const select of returning.selects) bindings.push(...select.bindings);
138
+ }
139
+ const keptCtes = require_queries_sql_query.pruneCtes(ctes, new Set(refs));
140
+ if (keptCtes.length > 0) {
141
+ const clause = require_queries_sql_query.withFragment(keptCtes);
142
+ sql = clause.sql + sql;
143
+ bindings.unshift(...clause.bindings);
144
+ }
145
+ return {
146
+ sql,
147
+ bindings,
148
+ outerRefs: [],
149
+ output: returning?.output ?? {
150
+ kind: "pojo",
151
+ columns: []
152
+ },
153
+ decodeRows: returning?.decodeRows ?? (() => [])
154
+ };
155
+ }
156
+ /** Retains native counts even when no rows return, and propagates decoding failures after execution. */
157
+ function decodeStatementResult(em, plan, result) {
158
+ if (typeof result.rowCount !== "number" || !Number.isInteger(result.rowCount) || result.rowCount < 0) require_utils.fail("The driver did not return a numeric command rowCount");
159
+ return {
160
+ rowCount: result.rowCount,
161
+ rows: plan.decodeRows(em, result.rows)
162
+ };
163
+ }
164
+ /** SQL mutations require complete physical metadata. */
165
+ function requireColumnMetadata(meta, column) {
166
+ if (typeof column.sqlNullable !== "boolean" || typeof column.hasDefault !== "boolean" || typeof column.isGenerated !== "boolean") require_utils.fail(`Missing physical metadata for ${meta.type}.${column.columnName}; run codegen`);
167
+ }
168
+ /** Validates every supplied key, including undefined fields, before pruning omitted values. */
169
+ function assignments(meta, value, operation) {
170
+ if (!value || typeof value !== "object" || Array.isArray(value) || require_queries_sql_Expr.isExpr(value) || require_Entity.isEntity(value)) require_utils.fail(`${operation} assignments must be a field POJO`);
171
+ const entries = Object.entries(value);
172
+ for (const [key] of entries) writableField(meta, key, operation);
173
+ checkPojo(value, Object.keys(meta.columns), `${operation} assignments`);
174
+ const defined = entries.filter((entry) => entry[1] !== void 0);
175
+ if (!defined.length) require_utils.fail(`${operation} requires at least one defined field; empty rows/sets are not DEFAULT VALUES`);
176
+ return defined;
177
+ }
178
+ /** Applies physical write restrictions, not ORM-derived, protected, or business-immutable flags. */
179
+ function writableField(meta, key, operation) {
180
+ const column = Object.hasOwn(meta.columns, key) ? meta.columns[key] : void 0;
181
+ if (!column) require_utils.fail(`Unsupported SQL mutation field ${meta.type}.${key}`);
182
+ requireColumnMetadata(meta, column);
183
+ if (operation === "update" && key === "id") require_utils.fail("UPDATE primary-key assignments are not supported");
184
+ if (column.isGenerated) require_utils.fail(`Generated field ${meta.type}.${key} is omit-only`);
185
+ if (operation === "update" ? !column.update : column.insert === "never") require_utils.fail(`Unsupported SQL mutation field ${meta.type}.${key}`);
186
+ return column;
187
+ }
188
+ /**
189
+ * Classifies SQL expressions and SQL NULL before invoking the column's entity-independent write codec.
190
+ * Normalizes public PK/FK ids to internal tagged ids using the target entity's idType.
191
+ */
192
+ function assignmentToSql(meta, column, value, ctx) {
193
+ if (require_queries_sql_Expr.isExpr(value)) return require_queries_sql_Expr.asNode(value).toSql(ctx);
194
+ if (value === null) {
195
+ if (!column.sqlNullable) require_utils.fail(`${meta.type}.${column.columnName} is physically NOT NULL`);
196
+ return {
197
+ sql: "NULL",
198
+ bindings: [],
199
+ refs: []
200
+ };
201
+ }
202
+ if (column.idMetadata) {
203
+ const other = column.idMetadata();
204
+ if (require_Entity.isEntity(value)) {
205
+ if (column.columnName === "id" || !(value instanceof other.cstr)) require_utils.fail(`Expected a ${other.type} reference`);
206
+ if (value.isNewEntity || value.idTaggedMaybe === void 0) require_utils.fail(`Cannot reference an unflushed ${other.type}, even with an assigned ID`);
207
+ value = value.idTaggedMaybe;
208
+ } else if (typeof value !== (other.idType === "number" ? "number" : "string")) require_utils.fail(`Expected a persisted ${other.type} or its ID; nested creation is not supported`);
209
+ else value = other.idType === "untagged-string" ? require_keys.keyToTaggedId(other, value) : require_keys.toTaggedId(other, value);
210
+ }
211
+ if (!column.codec.mapToDbValue) require_utils.fail(`The codec for ${meta.type}.${column.columnName} does not support SQL value writes`);
212
+ return {
213
+ sql: "?",
214
+ bindings: [column.mapToDbValue(value)],
215
+ refs: []
216
+ };
217
+ }
218
+ /** Checks the user predicate independently so metadata filters cannot turn a pruned guard into consent. */
219
+ function mutationCondition(value, ctx) {
220
+ if (require_queries_sql_Expr.isExpr(value)) return require_queries_sql_Expr.asNode(value).toSql(ctx);
221
+ return require_queries_sql_query.conditionToSql(value, ctx, true);
222
+ }
223
+ /** Only own enumerable POJO clauses count as input or explicit full-table consent. */
224
+ function checkPojo(value, allowed, description) {
225
+ if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) require_utils.fail(`${description} must be a plain POJO`);
226
+ for (const key of Reflect.ownKeys(value)) {
227
+ if (!allowed.includes(key)) require_utils.fail(`${description} does not support '${String(key)}'`);
228
+ if (typeof key === "string" && !Object.prototype.propertyIsEnumerable.call(value, key)) require_utils.fail(`${description} requires enumerable fields`);
229
+ }
230
+ }
231
+ //#endregion
232
+ exports.decodeStatementResult = decodeStatementResult;
233
+ exports.isMutation = isMutation;
234
+ exports.parseStatement = parseStatement;
235
+
236
+ //# sourceMappingURL=execute.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute.cjs","names":["isReadQueryValue","parseUserQuery","isTable","getTableMgmt","AliasAssigner","Ctx","registerCtes","projectionToSql","kq","parseNestedQuery","safeKq","conditionToSql","injectedConditions","pruneCtes","withFragment","isExpr","isEntity","asNode","keyToTaggedId","toTaggedId"],"sources":["../../../src/queries/sql/execute.ts"],"sourcesContent":["import type { DriverQueryResult } from \"../../drivers/Driver.ts\";\nimport { type Entity, isEntity } from \"../../Entity.ts\";\nimport type { IdOf } from \"../../EntityManager.ts\";\nimport type { EntityMetadata } from \"../../EntityMetadata.ts\";\nimport { keyToTaggedId, toTaggedId } from \"../../keys.ts\";\nimport type { Column } from \"../../serde/columns.ts\";\nimport type { ColumnsOf, TypeMapEntry } from \"../../typeMap.ts\";\nimport { fail } from \"../../utils.ts\";\nimport type { SqlCondition } from \"../conditions.ts\";\nimport { AliasAssigner } from \"./AliasAssigner.ts\";\nimport { type ExprBrand, type ExprLike, type SqlFragment, asNode, exprBrand, isExpr } from \"./Expr.ts\";\nimport { kq, safeKq } from \"./keywords.ts\";\nimport {\n type CheckReadQuery,\n type CheckScope,\n type CheckSetQuery,\n Ctx,\n type EntityHydrator,\n type NameOf,\n type Plan,\n type Query,\n type QueryJoins,\n type QueryRow,\n type ReadQueryRow,\n type SetOperand,\n type SetOperation,\n type SetQuery,\n type Subquery,\n type WithInput,\n conditionToSql,\n entityQueryBrand,\n injectedConditions,\n isReadQueryValue,\n parseNestedQuery,\n parseUserQuery,\n projectionToSql,\n pruneCtes,\n registerCtes,\n subqueryBrand,\n withFragment,\n} from \"./query.ts\";\nimport { type TableFor, getTableMgmt, isTable, tableMgmt } from \"./Tables.ts\";\n\n/** The native command count and decoded rows from one immediate SQL statement. */\nexport interface ExecuteResult<R> {\n rowCount: number;\n rows: R[];\n}\n\n/** A mutation's RETURNING projection: one SQL expression or a named object of expressions. */\nexport type MutationReturning = (ExprLike<unknown> | Readonly<Record<string, ExprLike<unknown>>>) & {\n readonly [tableMgmt]?: never;\n readonly [subqueryBrand]?: never;\n readonly [entityQueryBrand]?: never;\n};\n\n/** SQL INSERT inputs, based on physical storage rather than entity creation options. */\nexport type InsertValues<T extends Entity> = {\n [K in RequiredInsertKey<T>]: Assignment<T, K>;\n} & {\n [K in Exclude<InsertKey<T>, RequiredInsertKey<T>>]?: Assignment<T, K> | undefined;\n};\n\n/** SQL UPDATE inputs include persisted derived columns, but never primary keys. */\nexport type UpdateValues<T extends Entity> = {\n [K in UpdateKey<T>]?: Assignment<T, K> | undefined;\n};\n\n/** A reusable INSERT POJO; use a concrete Q for annotated INSERT SELECT source checking. */\nexport type InsertStatement<\n T extends Entity,\n R extends MutationReturning | undefined = MutationReturning | undefined,\n Q extends SetOperand = Query<InsertProjection<T>, []> | Subquery<InsertSourceRow<T>, string>,\n> = {\n readonly insert: MutationTarget<T>;\n readonly returning?: R;\n readonly update?: never;\n readonly delete?: never;\n readonly set?: never;\n readonly where?: never;\n readonly allowAll?: never;\n readonly softDeletes?: never;\n /** CTEs to add to a `WITH` before the INSERT; see `Clauses.with`. */\n readonly with?: WithInput;\n} & NoMutationReadClauses &\n (\n | { readonly values: InsertValues<T> | readonly InsertValues<T>[]; readonly from?: never }\n | { readonly from: Q & CheckInsertSource<T, Q>; readonly values?: never }\n );\n\n/** A reusable guarded UPDATE POJO. Undefined assignments leave existing columns unchanged. */\nexport type UpdateStatement<\n T extends Entity,\n R extends MutationReturning | undefined = MutationReturning | undefined,\n> = {\n readonly update: MutationTarget<T>;\n readonly set: UpdateValues<T>;\n readonly returning?: R;\n readonly insert?: never;\n readonly delete?: never;\n readonly values?: never;\n readonly from?: never;\n /** CTEs to add to a `WITH` before the UPDATE; see `Clauses.with`. */\n readonly with?: WithInput;\n} & MutationFilter &\n NoMutationReadClauses;\n\n/** A reusable guarded physical DELETE POJO, not an ORM soft delete. */\nexport type DeleteStatement<\n T extends Entity,\n R extends MutationReturning | undefined = MutationReturning | undefined,\n> = {\n readonly delete: MutationTarget<T>;\n readonly returning?: R;\n readonly insert?: never;\n readonly update?: never;\n readonly values?: never;\n readonly from?: never;\n readonly set?: never;\n /** CTEs to add to a `WITH` before the DELETE; see `Clauses.with`. */\n readonly with?: WithInput;\n} & MutationFilter &\n NoMutationReadClauses;\n\n/** Public statement annotations retain the target's physical field policy. */\nexport type MutationStatement<\n T extends Entity,\n R extends MutationReturning | undefined = MutationReturning | undefined,\n> = InsertStatement<T, R> | UpdateStatement<T, R> | DeleteStatement<T, R>;\n\n/** Inference starts with the literal POJO; CheckMutation checks its target and every supplied key. */\nexport type MutationInput = (\n | { readonly insert: TableFor<Entity>; readonly values: object | readonly object[]; readonly from?: never }\n | { readonly insert: TableFor<Entity>; readonly from: SetOperand; readonly values?: never }\n | { readonly update: TableFor<Entity>; readonly set: object }\n | { readonly delete: TableFor<Entity> }\n) & { readonly returning?: MutationReturning; readonly with?: WithInput } & MutationFilter;\n\n/** Without RETURNING the row type is never; scalar expressions produce scalar rows. */\nexport type MutationRow<M> = M extends { readonly returning?: infer R }\n ? R extends MutationReturning\n ? R extends ExprLike<unknown>\n ? QueryRow<R>\n : { -readonly [K in keyof QueryRow<R>]: QueryRow<R>[K] }\n : never\n : never;\n\n/** Checks nonliteral statements as well as fresh literals without widening their inferred result. */\nexport type CheckMutation<M> = M extends unknown\n ? TargetEntity<M> extends infer T extends Entity\n ? TypeMapEntry<T, \"supportsEmExecute\"> extends true\n ? { readonly [K in keyof M]: K extends MutationClause<M> ? unknown : never } & {\n readonly returning?: M extends { readonly returning?: infer R }\n ? CheckReturning<R, NameOf<TargetTable<M>>>\n : never;\n } & (\n | (M extends { readonly values: infer V } ? { readonly values: CheckValues<T, V> } : never)\n | (M extends { readonly from: infer Q extends SetOperand }\n ? { readonly from: CheckInsertSource<T, Q> }\n : never)\n | (M extends { readonly set: infer V }\n ? { readonly set: CheckAssignments<V, UpdateValues<T>, NameOf<TargetTable<M>>> }\n : never)\n | (M extends { readonly delete: unknown } ? unknown : never)\n )\n : \"SQL mutations require a supported non-inherited target and regenerated metadata\"\n : never\n : never;\n\n/** Classifies mutation roots before EntityManager applies write permissions, including malformed roots. */\nexport function isMutation(arg: unknown): boolean {\n return (\n typeof arg === \"object\" &&\n arg !== null &&\n !isReadQueryValue(arg) &&\n [\"insert\", \"update\", \"delete\"].some((key) => key in arg)\n );\n}\n\n/**\n * Compiles one immediate statement using the read compiler's scopes, projections, and codecs.\n * INSERT SELECT keeps source rows in PostgreSQL; only RETURNING rows pass through JS decoders.\n * An undefined plan represents a validated standalone empty VALUES array, not DEFAULT VALUES.\n */\nexport function parseStatement(arg: unknown): Plan | undefined {\n if (!isMutation(arg)) return parseUserQuery(arg);\n const statement = arg as Record<string, unknown>;\n const roots = [\"insert\", \"update\", \"delete\"].filter((key) => key in statement);\n if (roots.length !== 1) fail(\"A mutation requires exactly one insert, update, or delete root\");\n const operation = roots[0];\n const allowed =\n operation === \"insert\"\n ? [\"insert\", \"values\", \"from\", \"returning\", \"with\"]\n : [\n operation,\n \"where\",\n \"allowAll\",\n \"softDeletes\",\n \"returning\",\n \"with\",\n ...(operation === \"update\" ? [\"set\"] : []),\n ];\n checkPojo(statement, allowed, `SQL ${operation}`);\n const target = statement[operation];\n if (!isTable(target)) fail(\"A mutation target must be an entity table\");\n const mgmt = getTableMgmt(target);\n const meta = mgmt.meta;\n if (meta.inheritanceType || meta.baseType || meta.baseTypes.length || meta.subTypes.length) {\n fail(\"SQL mutations do not support CTI/STI targets or inherited table families\");\n }\n if (meta.supportsEmExecute !== true)\n fail(`SQL mutations require supported physical metadata for ${meta.type}; run codegen`);\n const fields = Object.entries(meta.columns);\n for (const [, field] of fields) {\n requireColumnMetadata(meta, field);\n }\n const assigner = new AliasAssigner();\n // A CTE is in scope for the whole statement, so its scope is the parent of every other one here. It\n // deliberately holds no target alias, which is what lets INSERT VALUES cells and the INSERT SELECT\n // source read the CTEs without also seeing the row being written.\n const withCtx = new Ctx(assigner, undefined);\n const ctes = registerCtes(statement, withCtx, assigner);\n // Aliases the rest of the statement reads, so an unread CTE prunes like it does on a read query.\n const refs: string[] = [];\n const ctx = new Ctx(assigner, withCtx);\n const alias = assigner.getAlias(meta.tableName);\n ctx.register(mgmt, alias);\n const returning = statement.returning === undefined ? undefined : projectionToSql(statement.returning, ctx);\n if (returning) for (const select of returning.selects) refs.push(...select.refs);\n let sql = `${operation === \"delete\" ? \"DELETE FROM\" : operation.toUpperCase() + (operation === \"insert\" ? \" INTO\" : \"\")} ${kq(meta.tableName)} AS ${kq(alias)}`;\n const bindings: unknown[] = [];\n if (operation === \"insert\") {\n if (\"values\" in statement === \"from\" in statement) fail(\"INSERT requires exactly one of values or from\");\n const required = fields.filter(([, column]) => column.insert === \"required\");\n if (\"values\" in statement) {\n const rows = Array.isArray(statement.values) ? statement.values : [statement.values];\n // A VALUES cell *is* the new row, so there is no existing row for it to read: this scope skips\n // the `ctx.register(mgmt, alias)` above, so a cell naming the target fails instead of emitting a\n // `b` with no FROM clause. I.e. an UPDATE can say `set: { title: b.title }`; an INSERT cannot.\n // A value subquery still works, because it brings its own sources, and the parent here is the CTE\n // scope rather than `ctx`, so a cell can read a `with` entry but not the row being written.\n const valuesCtx = new Ctx(assigner, withCtx);\n const entries = rows.map((row) => assignments(meta, row, \"insert\"));\n for (const row of entries) {\n for (const [key] of required) {\n if (!row.some((entry) => entry[0] === key)) fail(`INSERT requires ${meta.type}.${key}`);\n }\n }\n if (rows.length === 0) return undefined;\n const keys = fields.filter(([key]) => entries.some((row) => row.some((entry) => entry[0] === key)));\n sql += ` (${keys.map(([, field]) => kq(field.columnName)).join(\", \")}) VALUES `;\n sql += entries\n .map((row) => {\n const cells = keys.map(([key, field]) => {\n const entry = row.find((entry) => entry[0] === key);\n if (!entry) return \"DEFAULT\";\n const cell = assignmentToSql(meta, field, entry[1], valuesCtx);\n bindings.push(...cell.bindings);\n refs.push(...cell.refs);\n return cell.sql;\n });\n return `(${cells.join(\", \")})`;\n })\n .join(\", \");\n } else {\n const source = parseNestedQuery(statement.from, withCtx, assigner);\n if (source.output.kind !== \"pojo\") fail(\"INSERT SELECT requires named POJO output columns\");\n const columns = source.output.columns;\n for (const [key] of required) {\n if (!columns.some((column) => column[0] === key)) fail(`INSERT requires ${meta.type}.${key}`);\n }\n for (const [key, expr] of columns) {\n const field = writableField(meta, key, \"insert\");\n const left = field.outputType;\n const right = expr.outputType;\n if (\n !left ||\n !right ||\n left.dbType !== right.dbType ||\n left.domain !== right.domain ||\n left.idMeta !== right.idMeta\n ) {\n fail(`INSERT SELECT ${meta.type}.${key} has incompatible or unknown storage codecs`);\n }\n if (!field.sqlNullable && expr.sqlNullable === true)\n fail(`INSERT SELECT ${meta.type}.${key} cannot accept a nullable output`);\n }\n const keys = fields.filter(([key]) => columns.some((column) => column[0] === key));\n const sourceAlias = safeKq(assigner.getLiteralAlias(\"sq\"));\n sql += ` (${keys.map(([, field]) => kq(field.columnName)).join(\", \")}) SELECT ${keys.map(([key]) => `${sourceAlias}.${safeKq(key)}`).join(\", \")} FROM (${source.sql}) AS ${sourceAlias}`;\n bindings.push(...source.bindings);\n refs.push(...source.outerRefs);\n }\n } else {\n if (statement.allowAll !== undefined && typeof statement.allowAll !== \"boolean\") fail(\"allowAll must be a boolean\");\n if (\n statement.softDeletes !== undefined &&\n statement.softDeletes !== \"include\" &&\n statement.softDeletes !== \"exclude\"\n )\n fail(\"softDeletes must be 'include' or 'exclude'\");\n const user = mutationCondition(statement.where, ctx);\n if (!user && statement.allowAll !== true) fail(\"UPDATE and DELETE require a nonempty user where or allowAll: true\");\n if (operation === \"update\") {\n const entries = assignments(meta, statement.set, \"update\");\n sql +=\n \" SET \" +\n entries\n .map((entry) => {\n const [key, value] = entry;\n const field = writableField(meta, key, \"update\");\n const cell = assignmentToSql(meta, field, value, ctx);\n bindings.push(...cell.bindings);\n refs.push(...cell.refs);\n return `${kq(field.columnName)} = ${cell.sql}`;\n })\n .join(\", \");\n }\n const injected = conditionToSql(\n { and: injectedConditions({ meta, alias }, statement.softDeletes ?? \"exclude\") },\n ctx,\n true,\n );\n const conditions = [user, injected].filter((condition) => condition !== undefined);\n if (conditions.length) {\n sql += ` WHERE ${conditions.map((condition) => `(${condition.sql})`).join(\" AND \")}`;\n for (const condition of conditions) {\n bindings.push(...condition.bindings);\n refs.push(...condition.refs);\n }\n }\n }\n if (returning) {\n sql += ` RETURNING ${returning.selects.map((select) => select.sql).join(\", \")}`;\n for (const select of returning.selects) bindings.push(...select.bindings);\n }\n const keptCtes = pruneCtes(ctes, new Set(refs));\n if (keptCtes.length > 0) {\n const clause = withFragment(keptCtes);\n sql = clause.sql + sql;\n bindings.unshift(...clause.bindings);\n }\n return {\n sql,\n bindings,\n outerRefs: [],\n output: returning?.output ?? { kind: \"pojo\", columns: [] },\n decodeRows: returning?.decodeRows ?? (() => []),\n };\n}\n\n/** Retains native counts even when no rows return, and propagates decoding failures after execution. */\nexport function decodeStatementResult(\n em: EntityHydrator,\n plan: Plan,\n result: DriverQueryResult,\n): ExecuteResult<unknown> {\n if (typeof result.rowCount !== \"number\" || !Number.isInteger(result.rowCount) || result.rowCount < 0)\n fail(\"The driver did not return a numeric command rowCount\");\n return { rowCount: result.rowCount, rows: plan.decodeRows(em, result.rows) };\n}\n\ntype MutationTarget<T extends Entity> = TableFor<T> &\n (TypeMapEntry<T, \"supportsEmExecute\"> extends true ? unknown : never);\ntype MutationFilter = {\n readonly where?: SqlCondition | ExprLike<boolean>;\n readonly allowAll?: boolean;\n readonly softDeletes?: \"include\" | \"exclude\";\n};\ntype NoMutationReadClauses = Partial<\n Record<\n | \"select\"\n | \"join\"\n | \"groupBy\"\n | \"having\"\n | \"orderBy\"\n | \"limit\"\n | \"offset\"\n | \"distinct\"\n | \"pruneJoins\"\n | \"as\"\n | \"union\"\n | \"unionAll\"\n | \"intersect\"\n | \"intersectAll\"\n | \"except\"\n | \"exceptAll\"\n | \"ctes\"\n | \"using\"\n | \"onConflict\",\n never\n >\n>;\n/** Column keys allowed in INSERT, i.e. Book's optional `id` and required `authorId`. */\ntype InsertKey<T> = {\n [K in keyof ColumnsOf<T>]: ColumnsOf<T>[K] extends { insert: \"required\" | \"optional\" } ? K : never;\n}[keyof ColumnsOf<T>];\n/** Column keys that each INSERT row must supply, i.e. Book's `authorId` despite its ORM default. */\ntype RequiredInsertKey<T> = {\n [K in keyof ColumnsOf<T>]: ColumnsOf<T>[K] extends { insert: \"required\" } ? K : never;\n}[keyof ColumnsOf<T>];\n/** Column keys allowed in UPDATE SET, i.e. Book's `title` and `authorId`, but not `id`. */\ntype UpdateKey<T> = {\n [K in keyof ColumnsOf<T>]: ColumnsOf<T>[K] extends { update: true } ? K : never;\n}[keyof ColumnsOf<T>];\n/** A column's domain value before SQL nullability is added, i.e. Book's `id` is BookId and `authorId` is AuthorId. */\ntype DomainValue<T, K extends keyof ColumnsOf<T>> = K extends \"id\"\n ? IdOf<T>\n : ColumnsOf<T>[K] extends { entity: infer U }\n ? IdOf<U>\n : ColumnsOf<T>[K] extends { type: infer V }\n ? V\n : never;\ntype SqlValue<T, K extends keyof ColumnsOf<T>> =\n | DomainValue<T, K>\n | (ColumnsOf<T>[K] extends { nullable: true } ? null : never);\ntype Assignment<T, K extends keyof ColumnsOf<T>> =\n | SqlValue<T, K>\n | ExprLike<SqlValue<T, K>>\n | (K extends \"id\" ? never : ColumnsOf<T>[K] extends { entity: infer U } ? U : never);\ntype InsertSourceRow<T> = { [K in RequiredInsertKey<T>]: SqlValue<T, K> } & {\n [K in Exclude<InsertKey<T>, RequiredInsertKey<T>>]?: SqlValue<T, K>;\n};\ntype InsertProjection<T> = { [K in RequiredInsertKey<T>]: ExprLike<SqlValue<T, K>> } & {\n [K in Exclude<InsertKey<T>, RequiredInsertKey<T>>]?: ExprLike<SqlValue<T, K>>;\n};\ntype UnionKeys<V> = V extends unknown ? keyof V : never;\n/** Collects every alternative before scope checking; a valid branch cannot hide an unrelated alias. */\ntype UnionValue<V, K extends PropertyKey> = V extends unknown ? (K extends keyof V ? V[K] : never) : never;\ntype ExprSource<V> = V extends { readonly [exprBrand]: ExprBrand<unknown, infer Src> } ? Src : never;\ntype CheckExprScope<V, Scope> =\n string extends ExprSource<V>\n ? unknown\n : [Exclude<ExprSource<V>, Scope>] extends [never]\n ? unknown\n : \"Expression source is not in the statement scope\";\ntype ReturningExpr<R> = R extends ExprLike<unknown> ? R : R extends undefined ? never : R[keyof R];\ntype EmptyReturning<R> = R extends object ? (keyof R extends never ? true : false) : false;\ntype CheckReturning<R, Scope> = true extends EmptyReturning<R> ? never : CheckExprScope<ReturningExpr<R>, Scope>;\ntype CheckAssignments<V, Allowed, Scope> = [Exclude<UnionKeys<V>, keyof Allowed>] extends [never]\n ? Allowed & {\n [K in UnionKeys<V>]?: CheckExprScope<UnionValue<V, K>, Scope>;\n }\n : \"SQL assignments have unknown target fields\";\ntype CheckValues<T extends Entity, V> =\n | ([Extract<V, readonly unknown[]>] extends [never]\n ? never\n : readonly CheckAssignments<Extract<V, readonly unknown[]>[number], InsertValues<T>, never>[])\n | ([Exclude<V, readonly unknown[]>] extends [never]\n ? never\n : CheckAssignments<Exclude<V, readonly unknown[]>, InsertValues<T>, never>);\ntype CheckSourceScope<Q> = Q extends { readonly select: infer S; readonly from: infer F }\n ? CheckScope<S, F, \"join\" extends keyof Q ? Extract<Q[keyof Q & \"join\"], QueryJoins> : []>\n : {\n [K in keyof Q]: K extends SetOperation\n ? Q[K] extends readonly unknown[]\n ? { [I in keyof Q[K]]: CheckSourceScope<Q[K][I]> }\n : unknown\n : unknown;\n };\ntype CheckInsertSource<T, Q extends SetOperand> = SetOperand extends Q\n ? \"INSERT source was typed too generically; retain its named output fields\"\n : ReadQueryRow<Q> extends InsertSourceRow<T>\n ? Exclude<UnionKeys<ReadQueryRow<Q>>, InsertKey<T>> extends never\n ? CheckReadQuery<Q> &\n CheckSourceScope<Q> &\n (Q extends SetQuery<readonly SetOperand[]> ? CheckSetQuery<Q> : unknown)\n : \"INSERT SELECT has unknown target fields\"\n : \"INSERT SELECT requires compatible values for all SQL-required fields\";\ntype TargetEntity<M> = M extends\n | { readonly insert: TableFor<infer T> }\n | { readonly update: TableFor<infer T> }\n | { readonly delete: TableFor<infer T> }\n ? T\n : never;\ntype TargetTable<M> = M extends\n | { readonly insert: infer A }\n | { readonly update: infer A }\n | { readonly delete: infer A }\n ? A\n : never;\ntype MutationClause<M> =\n | \"returning\"\n | \"with\"\n | (M extends { readonly insert: unknown }\n ? \"insert\" | (M extends { readonly values: unknown } ? \"values\" : \"from\")\n : \"where\" | \"allowAll\" | \"softDeletes\" | (M extends { readonly update: unknown } ? \"update\" | \"set\" : \"delete\"));\n/** SQL mutations require complete physical metadata. */\nfunction requireColumnMetadata(meta: EntityMetadata, column: Column): void {\n if (\n typeof column.sqlNullable !== \"boolean\" ||\n typeof column.hasDefault !== \"boolean\" ||\n typeof column.isGenerated !== \"boolean\"\n )\n fail(`Missing physical metadata for ${meta.type}.${column.columnName}; run codegen`);\n}\n\n/** Validates every supplied key, including undefined fields, before pruning omitted values. */\nfunction assignments(meta: EntityMetadata, value: unknown, operation: \"insert\" | \"update\"): [string, unknown][] {\n if (!value || typeof value !== \"object\" || Array.isArray(value) || isExpr(value) || isEntity(value))\n fail(`${operation} assignments must be a field POJO`);\n const entries = Object.entries(value);\n for (const [key] of entries) writableField(meta, key, operation);\n checkPojo(value, Object.keys(meta.columns), `${operation} assignments`);\n const defined = entries.filter((entry) => entry[1] !== undefined);\n if (!defined.length) fail(`${operation} requires at least one defined field; empty rows/sets are not DEFAULT VALUES`);\n return defined;\n}\n\n/** Applies physical write restrictions, not ORM-derived, protected, or business-immutable flags. */\nfunction writableField(meta: EntityMetadata, key: string, operation: \"insert\" | \"update\"): Column {\n const column = Object.hasOwn(meta.columns, key) ? meta.columns[key] : undefined;\n if (!column) fail(`Unsupported SQL mutation field ${meta.type}.${key}`);\n requireColumnMetadata(meta, column);\n if (operation === \"update\" && key === \"id\") fail(\"UPDATE primary-key assignments are not supported\");\n if (column.isGenerated) fail(`Generated field ${meta.type}.${key} is omit-only`);\n if (operation === \"update\" ? !column.update : column.insert === \"never\")\n fail(`Unsupported SQL mutation field ${meta.type}.${key}`);\n return column;\n}\n\n/**\n * Classifies SQL expressions and SQL NULL before invoking the column's entity-independent write codec.\n * Normalizes public PK/FK ids to internal tagged ids using the target entity's idType.\n */\nfunction assignmentToSql(meta: EntityMetadata, column: Column, value: unknown, ctx: Ctx): SqlFragment {\n if (isExpr(value)) return asNode(value).toSql(ctx);\n if (value === null) {\n if (!column.sqlNullable) fail(`${meta.type}.${column.columnName} is physically NOT NULL`);\n return { sql: \"NULL\", bindings: [], refs: [] };\n }\n if (column.idMetadata) {\n const other = column.idMetadata();\n if (isEntity(value)) {\n if (column.columnName === \"id\" || !(value instanceof other.cstr)) fail(`Expected a ${other.type} reference`);\n if (value.isNewEntity || value.idTaggedMaybe === undefined)\n fail(`Cannot reference an unflushed ${other.type}, even with an assigned ID`);\n value = value.idTaggedMaybe;\n } else if (typeof value !== (other.idType === \"number\" ? \"number\" : \"string\")) {\n fail(`Expected a persisted ${other.type} or its ID; nested creation is not supported`);\n } else {\n // Public untagged TEXT ids may contain delimiters or start with the entity tag.\n value =\n other.idType === \"untagged-string\"\n ? keyToTaggedId(other, value as string)\n : toTaggedId(other, value as string | number);\n }\n }\n if (!column.codec.mapToDbValue)\n fail(`The codec for ${meta.type}.${column.columnName} does not support SQL value writes`);\n return { sql: \"?\", bindings: [column.mapToDbValue(value)], refs: [] };\n}\n\n/** Checks the user predicate independently so metadata filters cannot turn a pruned guard into consent. */\nfunction mutationCondition(value: unknown, ctx: Ctx): SqlFragment | undefined {\n if (isExpr(value)) return asNode(value).toSql(ctx);\n return conditionToSql(value as SqlCondition | undefined, ctx, true);\n}\n\n/** Only own enumerable POJO clauses count as input or explicit full-table consent. */\nfunction checkPojo(value: object, allowed: readonly PropertyKey[], description: string): void {\n if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)\n fail(`${description} must be a plain POJO`);\n for (const key of Reflect.ownKeys(value)) {\n if (!allowed.includes(key)) fail(`${description} does not support '${String(key)}'`);\n if (typeof key === \"string\" && !Object.prototype.propertyIsEnumerable.call(value, key))\n fail(`${description} requires enumerable fields`);\n }\n}\n"],"mappings":";;;;;;;;;;;AA0KA,SAAgB,WAAW,KAAuB;CAChD,OACE,OAAO,QAAQ,YACf,QAAQ,QACR,CAACA,0BAAAA,iBAAiB,GAAG,KACrB;EAAC;EAAU;EAAU;CAAQ,CAAC,CAAC,MAAM,QAAQ,OAAO,GAAG;AAE3D;;;;;;AAOA,SAAgB,eAAe,KAAgC;CAC7D,IAAI,CAAC,WAAW,GAAG,GAAG,OAAOC,0BAAAA,eAAe,GAAG;CAC/C,MAAM,YAAY;CAClB,MAAM,QAAQ;EAAC;EAAU;EAAU;CAAQ,CAAC,CA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