joist-core 2.4.0 → 2.5.0-next.1

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 (903) hide show
  1. package/build/BaseEntity.d.cts +3 -4
  2. package/build/BaseEntity.d.cts.map +1 -1
  3. package/build/BaseEntity.d.mts +3 -4
  4. package/build/BaseEntity.d.mts.map +1 -1
  5. package/build/Entity.d.cts +3 -4
  6. package/build/Entity.d.cts.map +1 -1
  7. package/build/Entity.d.mts +3 -4
  8. package/build/Entity.d.mts.map +1 -1
  9. package/build/EntityFields.d.cts +3 -4
  10. package/build/EntityFields.d.cts.map +1 -1
  11. package/build/EntityFields.d.mts +3 -4
  12. package/build/EntityFields.d.mts.map +1 -1
  13. package/build/EntityManager.cjs +102 -22
  14. package/build/EntityManager.cjs.map +1 -1
  15. package/build/EntityManager.d.cts +99 -54
  16. package/build/EntityManager.d.cts.map +1 -1
  17. package/build/EntityManager.d.mts +99 -54
  18. package/build/EntityManager.d.mts.map +1 -1
  19. package/build/EntityManager.js +102 -24
  20. package/build/EntityManager.js.map +1 -1
  21. package/build/EntityMetadata.cjs +0 -1
  22. package/build/EntityMetadata.cjs.map +1 -1
  23. package/build/EntityMetadata.d.cts +47 -36
  24. package/build/EntityMetadata.d.cts.map +1 -1
  25. package/build/EntityMetadata.d.mts +47 -36
  26. package/build/EntityMetadata.d.mts.map +1 -1
  27. package/build/EntityMetadata.js +0 -1
  28. package/build/EntityMetadata.js.map +1 -1
  29. package/build/EnumMetadata.d.cts +1 -2
  30. package/build/EnumMetadata.d.cts.map +1 -1
  31. package/build/EnumMetadata.d.mts +1 -2
  32. package/build/EnumMetadata.d.mts.map +1 -1
  33. package/build/IndexManager.cjs +25 -5
  34. package/build/IndexManager.cjs.map +1 -1
  35. package/build/IndexManager.d.cts +2 -3
  36. package/build/IndexManager.d.cts.map +1 -1
  37. package/build/IndexManager.d.mts +2 -3
  38. package/build/IndexManager.d.mts.map +1 -1
  39. package/build/IndexManager.js +25 -5
  40. package/build/IndexManager.js.map +1 -1
  41. package/build/InstanceData.cjs.map +1 -1
  42. package/build/InstanceData.d.cts +1 -2
  43. package/build/InstanceData.d.cts.map +1 -1
  44. package/build/InstanceData.d.mts +1 -2
  45. package/build/InstanceData.d.mts.map +1 -1
  46. package/build/InstanceData.js.map +1 -1
  47. package/build/PluginManager.cjs.map +1 -1
  48. package/build/PluginManager.d.cts +4 -4
  49. package/build/PluginManager.d.cts.map +1 -1
  50. package/build/PluginManager.d.mts +4 -4
  51. package/build/PluginManager.d.mts.map +1 -1
  52. package/build/PluginManager.js.map +1 -1
  53. package/build/RowData.d.cts +3 -4
  54. package/build/RowData.d.cts.map +1 -1
  55. package/build/RowData.d.mts +3 -4
  56. package/build/RowData.d.mts.map +1 -1
  57. package/build/batchloaders/BatchLoader.cjs.map +1 -1
  58. package/build/batchloaders/BatchLoader.d.cts +1 -2
  59. package/build/batchloaders/BatchLoader.d.cts.map +1 -1
  60. package/build/batchloaders/BatchLoader.d.mts +1 -2
  61. package/build/batchloaders/BatchLoader.d.mts.map +1 -1
  62. package/build/batchloaders/BatchLoader.js.map +1 -1
  63. package/build/batchloaders/enumCollectionBatchLoader.d.cts +2 -3
  64. package/build/batchloaders/enumCollectionBatchLoader.d.cts.map +1 -1
  65. package/build/batchloaders/enumCollectionBatchLoader.d.mts +2 -3
  66. package/build/batchloaders/enumCollectionBatchLoader.d.mts.map +1 -1
  67. package/build/batchloaders/loadBatchLoader.d.cts +2 -3
  68. package/build/batchloaders/loadBatchLoader.d.cts.map +1 -1
  69. package/build/batchloaders/loadBatchLoader.d.mts +2 -3
  70. package/build/batchloaders/loadBatchLoader.d.mts.map +1 -1
  71. package/build/batchloaders/manyToManyBatchLoader.d.cts +2 -3
  72. package/build/batchloaders/manyToManyBatchLoader.d.cts.map +1 -1
  73. package/build/batchloaders/manyToManyBatchLoader.d.mts +2 -3
  74. package/build/batchloaders/manyToManyBatchLoader.d.mts.map +1 -1
  75. package/build/batchloaders/oneToManyBatchLoader.cjs +1 -1
  76. package/build/batchloaders/oneToManyBatchLoader.d.cts +2 -3
  77. package/build/batchloaders/oneToManyBatchLoader.d.cts.map +1 -1
  78. package/build/batchloaders/oneToManyBatchLoader.d.mts +2 -3
  79. package/build/batchloaders/oneToManyBatchLoader.d.mts.map +1 -1
  80. package/build/batchloaders/oneToManyBatchLoader.js +1 -1
  81. package/build/batchloaders/oneToOneBatchLoader.cjs +1 -1
  82. package/build/batchloaders/oneToOneBatchLoader.d.cts +2 -3
  83. package/build/batchloaders/oneToOneBatchLoader.d.cts.map +1 -1
  84. package/build/batchloaders/oneToOneBatchLoader.d.mts +2 -3
  85. package/build/batchloaders/oneToOneBatchLoader.d.mts.map +1 -1
  86. package/build/batchloaders/oneToOneBatchLoader.js +1 -1
  87. package/build/batchloaders/populateBatchLoader.d.cts +2 -3
  88. package/build/batchloaders/populateBatchLoader.d.cts.map +1 -1
  89. package/build/batchloaders/populateBatchLoader.d.mts +2 -3
  90. package/build/batchloaders/populateBatchLoader.d.mts.map +1 -1
  91. package/build/batchloaders/recursiveChildrenBatchLoader.cjs +1 -1
  92. package/build/batchloaders/recursiveChildrenBatchLoader.d.cts +2 -3
  93. package/build/batchloaders/recursiveChildrenBatchLoader.d.cts.map +1 -1
  94. package/build/batchloaders/recursiveChildrenBatchLoader.d.mts +2 -3
  95. package/build/batchloaders/recursiveChildrenBatchLoader.d.mts.map +1 -1
  96. package/build/batchloaders/recursiveChildrenBatchLoader.js +1 -1
  97. package/build/batchloaders/recursiveM2mBatchLoader.d.cts +2 -3
  98. package/build/batchloaders/recursiveM2mBatchLoader.d.cts.map +1 -1
  99. package/build/batchloaders/recursiveM2mBatchLoader.d.mts +2 -3
  100. package/build/batchloaders/recursiveM2mBatchLoader.d.mts.map +1 -1
  101. package/build/batchloaders/recursiveParentsBatchLoader.cjs +1 -1
  102. package/build/batchloaders/recursiveParentsBatchLoader.d.cts +2 -3
  103. package/build/batchloaders/recursiveParentsBatchLoader.d.cts.map +1 -1
  104. package/build/batchloaders/recursiveParentsBatchLoader.d.mts +2 -3
  105. package/build/batchloaders/recursiveParentsBatchLoader.d.mts.map +1 -1
  106. package/build/batchloaders/recursiveParentsBatchLoader.js +1 -1
  107. package/build/changes.cjs +1 -1
  108. package/build/changes.cjs.map +1 -1
  109. package/build/changes.d.cts +9 -10
  110. package/build/changes.d.cts.map +1 -1
  111. package/build/changes.d.mts +9 -10
  112. package/build/changes.d.mts.map +1 -1
  113. package/build/changes.js +1 -1
  114. package/build/changes.js.map +1 -1
  115. package/build/config.cjs +165 -26
  116. package/build/config.cjs.map +1 -1
  117. package/build/config.d.cts +111 -19
  118. package/build/config.d.cts.map +1 -1
  119. package/build/config.d.mts +111 -19
  120. package/build/config.d.mts.map +1 -1
  121. package/build/config.js +165 -26
  122. package/build/config.js.map +1 -1
  123. package/build/configure.cjs +32 -2
  124. package/build/configure.cjs.map +1 -1
  125. package/build/configure.d.cts +8 -9
  126. package/build/configure.d.cts.map +1 -1
  127. package/build/configure.d.mts +8 -9
  128. package/build/configure.d.mts.map +1 -1
  129. package/build/configure.js +32 -2
  130. package/build/configure.js.map +1 -1
  131. package/build/dataloaders/fastWhereFilterHash.d.cts +1 -2
  132. package/build/dataloaders/fastWhereFilterHash.d.cts.map +1 -1
  133. package/build/dataloaders/fastWhereFilterHash.d.mts +1 -2
  134. package/build/dataloaders/fastWhereFilterHash.d.mts.map +1 -1
  135. package/build/dataloaders/findByUniqueDataLoader.d.cts +2 -3
  136. package/build/dataloaders/findByUniqueDataLoader.d.cts.map +1 -1
  137. package/build/dataloaders/findByUniqueDataLoader.d.mts +2 -3
  138. package/build/dataloaders/findByUniqueDataLoader.d.mts.map +1 -1
  139. package/build/dataloaders/findCountDataLoader.d.cts +4 -5
  140. package/build/dataloaders/findCountDataLoader.d.cts.map +1 -1
  141. package/build/dataloaders/findCountDataLoader.d.mts +4 -5
  142. package/build/dataloaders/findCountDataLoader.d.mts.map +1 -1
  143. package/build/dataloaders/findDataLoader.cjs +1 -1
  144. package/build/dataloaders/findDataLoader.d.cts +11 -12
  145. package/build/dataloaders/findDataLoader.d.cts.map +1 -1
  146. package/build/dataloaders/findDataLoader.d.mts +11 -12
  147. package/build/dataloaders/findDataLoader.d.mts.map +1 -1
  148. package/build/dataloaders/findDataLoader.js +1 -1
  149. package/build/dataloaders/findIdsDataLoader.d.cts +2 -3
  150. package/build/dataloaders/findIdsDataLoader.d.cts.map +1 -1
  151. package/build/dataloaders/findIdsDataLoader.d.mts +2 -3
  152. package/build/dataloaders/findIdsDataLoader.d.mts.map +1 -1
  153. package/build/dataloaders/findOrCreateDataLoader.cjs +6 -2
  154. package/build/dataloaders/findOrCreateDataLoader.cjs.map +1 -1
  155. package/build/dataloaders/findOrCreateDataLoader.d.cts +3 -3
  156. package/build/dataloaders/findOrCreateDataLoader.d.cts.map +1 -1
  157. package/build/dataloaders/findOrCreateDataLoader.d.mts +3 -3
  158. package/build/dataloaders/findOrCreateDataLoader.d.mts.map +1 -1
  159. package/build/dataloaders/findOrCreateDataLoader.js +7 -3
  160. package/build/dataloaders/findOrCreateDataLoader.js.map +1 -1
  161. package/build/dataloaders/findPaginatedDataLoader.cjs +10 -12
  162. package/build/dataloaders/findPaginatedDataLoader.cjs.map +1 -1
  163. package/build/dataloaders/findPaginatedDataLoader.d.cts +1 -2
  164. package/build/dataloaders/findPaginatedDataLoader.d.cts.map +1 -1
  165. package/build/dataloaders/findPaginatedDataLoader.d.mts +1 -2
  166. package/build/dataloaders/findPaginatedDataLoader.d.mts.map +1 -1
  167. package/build/dataloaders/findPaginatedDataLoader.js +10 -12
  168. package/build/dataloaders/findPaginatedDataLoader.js.map +1 -1
  169. package/build/dataloaders/lensDataLoader.d.cts +2 -3
  170. package/build/dataloaders/lensDataLoader.d.cts.map +1 -1
  171. package/build/dataloaders/lensDataLoader.d.mts +2 -3
  172. package/build/dataloaders/lensDataLoader.d.mts.map +1 -1
  173. package/build/dataloaders/manyToManyFindDataLoader.d.cts +2 -3
  174. package/build/dataloaders/manyToManyFindDataLoader.d.cts.map +1 -1
  175. package/build/dataloaders/manyToManyFindDataLoader.d.mts +2 -3
  176. package/build/dataloaders/manyToManyFindDataLoader.d.mts.map +1 -1
  177. package/build/dataloaders/oneToManyFindDataLoader.d.cts +2 -3
  178. package/build/dataloaders/oneToManyFindDataLoader.d.cts.map +1 -1
  179. package/build/dataloaders/oneToManyFindDataLoader.d.mts +2 -3
  180. package/build/dataloaders/oneToManyFindDataLoader.d.mts.map +1 -1
  181. package/build/defaults.cjs +1 -1
  182. package/build/defaults.cjs.map +1 -1
  183. package/build/defaults.d.cts +7 -7
  184. package/build/defaults.d.cts.map +1 -1
  185. package/build/defaults.d.mts +7 -7
  186. package/build/defaults.d.mts.map +1 -1
  187. package/build/defaults.js +1 -1
  188. package/build/defaults.js.map +1 -1
  189. package/build/drivers/Driver.d.cts +2 -3
  190. package/build/drivers/Driver.d.cts.map +1 -1
  191. package/build/drivers/Driver.d.mts +2 -3
  192. package/build/drivers/Driver.d.mts.map +1 -1
  193. package/build/drivers/EntityWriter.cjs +4 -3
  194. package/build/drivers/EntityWriter.cjs.map +1 -1
  195. package/build/drivers/EntityWriter.d.cts +19 -7
  196. package/build/drivers/EntityWriter.d.cts.map +1 -1
  197. package/build/drivers/EntityWriter.d.mts +19 -7
  198. package/build/drivers/EntityWriter.d.mts.map +1 -1
  199. package/build/drivers/EntityWriter.js +5 -4
  200. package/build/drivers/EntityWriter.js.map +1 -1
  201. package/build/drivers/IdAssigner.cjs.map +1 -1
  202. package/build/drivers/IdAssigner.d.cts +5 -5
  203. package/build/drivers/IdAssigner.d.cts.map +1 -1
  204. package/build/drivers/IdAssigner.d.mts +5 -5
  205. package/build/drivers/IdAssigner.d.mts.map +1 -1
  206. package/build/drivers/IdAssigner.js.map +1 -1
  207. package/build/drivers/driverApi.d.cts +2 -3
  208. package/build/drivers/driverApi.d.cts.map +1 -1
  209. package/build/drivers/driverApi.d.mts +2 -3
  210. package/build/drivers/driverApi.d.mts.map +1 -1
  211. package/build/fields.cjs +12 -9
  212. package/build/fields.cjs.map +1 -1
  213. package/build/fields.d.cts +10 -11
  214. package/build/fields.d.cts.map +1 -1
  215. package/build/fields.d.mts +10 -11
  216. package/build/fields.d.mts.map +1 -1
  217. package/build/fields.js +12 -9
  218. package/build/fields.js.map +1 -1
  219. package/build/flush/FlushLock.cjs.map +1 -1
  220. package/build/flush/FlushLock.d.cts +1 -2
  221. package/build/flush/FlushLock.d.cts.map +1 -1
  222. package/build/flush/FlushLock.d.mts +1 -2
  223. package/build/flush/FlushLock.d.mts.map +1 -1
  224. package/build/flush/FlushLock.js.map +1 -1
  225. package/build/flush/JoinRows.cjs.map +1 -1
  226. package/build/flush/JoinRows.d.cts +5 -6
  227. package/build/flush/JoinRows.d.cts.map +1 -1
  228. package/build/flush/JoinRows.d.mts +5 -6
  229. package/build/flush/JoinRows.d.mts.map +1 -1
  230. package/build/flush/JoinRows.js.map +1 -1
  231. package/build/flush/PendingChanges.d.cts +5 -6
  232. package/build/flush/PendingChanges.d.cts.map +1 -1
  233. package/build/flush/PendingChanges.d.mts +5 -6
  234. package/build/flush/PendingChanges.d.mts.map +1 -1
  235. package/build/flush/ReadDrift.cjs +90 -0
  236. package/build/flush/ReadDrift.cjs.map +1 -0
  237. package/build/flush/ReadDrift.d.cts +25 -0
  238. package/build/flush/ReadDrift.d.cts.map +1 -0
  239. package/build/flush/ReadDrift.d.mts +25 -0
  240. package/build/flush/ReadDrift.d.mts.map +1 -0
  241. package/build/flush/ReadDrift.js +87 -0
  242. package/build/flush/ReadDrift.js.map +1 -0
  243. package/build/flush/Todo.d.cts +5 -6
  244. package/build/flush/Todo.d.cts.map +1 -1
  245. package/build/flush/Todo.d.mts +5 -6
  246. package/build/flush/Todo.d.mts.map +1 -1
  247. package/build/getProperties.cjs +1 -1
  248. package/build/getProperties.d.cts +3 -4
  249. package/build/getProperties.d.cts.map +1 -1
  250. package/build/getProperties.d.mts +3 -4
  251. package/build/getProperties.d.mts.map +1 -1
  252. package/build/getProperties.js +1 -1
  253. package/build/index.cjs +20 -7
  254. package/build/index.cjs.map +1 -1
  255. package/build/index.d.cts +23 -19
  256. package/build/index.d.cts.map +1 -1
  257. package/build/index.d.mts +23 -19
  258. package/build/index.d.mts.map +1 -1
  259. package/build/index.js +17 -10
  260. package/build/index.js.map +1 -1
  261. package/build/json.d.cts +11 -11
  262. package/build/json.d.cts.map +1 -1
  263. package/build/json.d.mts +11 -11
  264. package/build/json.d.mts.map +1 -1
  265. package/build/keys.d.cts +27 -27
  266. package/build/keys.d.cts.map +1 -1
  267. package/build/keys.d.mts +27 -27
  268. package/build/keys.d.mts.map +1 -1
  269. package/build/loading/HintTree.d.cts +3 -4
  270. package/build/loading/HintTree.d.cts.map +1 -1
  271. package/build/loading/HintTree.d.mts +3 -4
  272. package/build/loading/HintTree.d.mts.map +1 -1
  273. package/build/loading/IsLoadedCache.cjs +2 -2
  274. package/build/loading/IsLoadedCache.cjs.map +1 -1
  275. package/build/loading/IsLoadedCache.d.cts +3 -4
  276. package/build/loading/IsLoadedCache.d.cts.map +1 -1
  277. package/build/loading/IsLoadedCache.d.mts +3 -4
  278. package/build/loading/IsLoadedCache.d.mts.map +1 -1
  279. package/build/loading/IsLoadedCache.js +2 -2
  280. package/build/loading/IsLoadedCache.js.map +1 -1
  281. package/build/loading/loadHints.d.cts +17 -17
  282. package/build/loading/loadHints.d.cts.map +1 -1
  283. package/build/loading/loadHints.d.mts +17 -17
  284. package/build/loading/loadHints.d.mts.map +1 -1
  285. package/build/loading/loadLens.d.cts +13 -13
  286. package/build/loading/loadLens.d.cts.map +1 -1
  287. package/build/loading/loadLens.d.mts +13 -13
  288. package/build/loading/loadLens.d.mts.map +1 -1
  289. package/build/loading/withLoaded.d.cts +5 -6
  290. package/build/loading/withLoaded.d.cts.map +1 -1
  291. package/build/loading/withLoaded.d.mts +5 -6
  292. package/build/loading/withLoaded.d.mts.map +1 -1
  293. package/build/logging/FactoryLogger.cjs +1 -1
  294. package/build/logging/FactoryLogger.cjs.map +1 -1
  295. package/build/logging/FactoryLogger.d.cts +3 -4
  296. package/build/logging/FactoryLogger.d.cts.map +1 -1
  297. package/build/logging/FactoryLogger.d.mts +3 -4
  298. package/build/logging/FactoryLogger.d.mts.map +1 -1
  299. package/build/logging/FactoryLogger.js +2 -2
  300. package/build/logging/FactoryLogger.js.map +1 -1
  301. package/build/logging/FieldLogger.cjs.map +1 -1
  302. package/build/logging/FieldLogger.d.cts +4 -5
  303. package/build/logging/FieldLogger.d.cts.map +1 -1
  304. package/build/logging/FieldLogger.d.mts +4 -5
  305. package/build/logging/FieldLogger.d.mts.map +1 -1
  306. package/build/logging/FieldLogger.js.map +1 -1
  307. package/build/logging/ReactionLogger.d.cts +7 -7
  308. package/build/logging/ReactionLogger.d.cts.map +1 -1
  309. package/build/logging/ReactionLogger.d.mts +7 -7
  310. package/build/logging/ReactionLogger.d.mts.map +1 -1
  311. package/build/metrics/EntityMetrics.cjs +81 -0
  312. package/build/metrics/EntityMetrics.cjs.map +1 -0
  313. package/build/metrics/EntityMetrics.d.cts +55 -0
  314. package/build/metrics/EntityMetrics.d.cts.map +1 -0
  315. package/build/metrics/EntityMetrics.d.mts +55 -0
  316. package/build/metrics/EntityMetrics.d.mts.map +1 -0
  317. package/build/metrics/EntityMetrics.js +79 -0
  318. package/build/metrics/EntityMetrics.js.map +1 -0
  319. package/build/newEntity.cjs +1 -1
  320. package/build/newEntity.cjs.map +1 -1
  321. package/build/newEntity.d.cts +4 -5
  322. package/build/newEntity.d.cts.map +1 -1
  323. package/build/newEntity.d.mts +4 -5
  324. package/build/newEntity.d.mts.map +1 -1
  325. package/build/newEntity.js +1 -1
  326. package/build/newEntity.js.map +1 -1
  327. package/build/newTestInstance.cjs +1 -0
  328. package/build/newTestInstance.cjs.map +1 -1
  329. package/build/newTestInstance.d.cts +21 -21
  330. package/build/newTestInstance.d.cts.map +1 -1
  331. package/build/newTestInstance.d.mts +21 -21
  332. package/build/newTestInstance.d.mts.map +1 -1
  333. package/build/newTestInstance.js +1 -0
  334. package/build/newTestInstance.js.map +1 -1
  335. package/build/normalizeHints.d.cts +7 -8
  336. package/build/normalizeHints.d.cts.map +1 -1
  337. package/build/normalizeHints.d.mts +7 -8
  338. package/build/normalizeHints.d.mts.map +1 -1
  339. package/build/nowUTC.d.cts +4 -5
  340. package/build/nowUTC.d.cts.map +1 -1
  341. package/build/nowUTC.d.mts +4 -5
  342. package/build/nowUTC.d.mts.map +1 -1
  343. package/build/plugins/ImmutableEntitiesPlugin.d.cts +1 -2
  344. package/build/plugins/ImmutableEntitiesPlugin.d.cts.map +1 -1
  345. package/build/plugins/ImmutableEntitiesPlugin.d.mts +1 -2
  346. package/build/plugins/ImmutableEntitiesPlugin.d.mts.map +1 -1
  347. package/build/plugins/PreloadPlugin.d.cts +3 -4
  348. package/build/plugins/PreloadPlugin.d.cts.map +1 -1
  349. package/build/plugins/PreloadPlugin.d.mts +3 -4
  350. package/build/plugins/PreloadPlugin.d.mts.map +1 -1
  351. package/build/preloading/JsonAggregatePreloader.d.cts +1 -2
  352. package/build/preloading/JsonAggregatePreloader.d.cts.map +1 -1
  353. package/build/preloading/JsonAggregatePreloader.d.mts +1 -2
  354. package/build/preloading/JsonAggregatePreloader.d.mts.map +1 -1
  355. package/build/preloading/canPreload.d.cts +1 -2
  356. package/build/preloading/canPreload.d.cts.map +1 -1
  357. package/build/preloading/canPreload.d.mts +1 -2
  358. package/build/preloading/canPreload.d.mts.map +1 -1
  359. package/build/preloading/partitionHint.cjs +1 -1
  360. package/build/preloading/partitionHint.d.cts +1 -2
  361. package/build/preloading/partitionHint.d.cts.map +1 -1
  362. package/build/preloading/partitionHint.d.mts +1 -2
  363. package/build/preloading/partitionHint.d.mts.map +1 -1
  364. package/build/preloading/partitionHint.js +1 -1
  365. package/build/queries/ConditionBuilder.d.cts +2 -2
  366. package/build/queries/ConditionBuilder.d.cts.map +1 -1
  367. package/build/queries/ConditionBuilder.d.mts +2 -2
  368. package/build/queries/ConditionBuilder.d.mts.map +1 -1
  369. package/build/queries/conditions.d.cts +11 -12
  370. package/build/queries/conditions.d.cts.map +1 -1
  371. package/build/queries/conditions.d.mts +11 -12
  372. package/build/queries/conditions.d.mts.map +1 -1
  373. package/build/queries/entityQueryUtils.d.cts +4 -5
  374. package/build/queries/entityQueryUtils.d.cts.map +1 -1
  375. package/build/queries/entityQueryUtils.d.mts +4 -5
  376. package/build/queries/entityQueryUtils.d.mts.map +1 -1
  377. package/build/queries/find/Aliases.d.cts +16 -16
  378. package/build/queries/find/Aliases.d.cts.map +1 -1
  379. package/build/queries/find/Aliases.d.mts +16 -16
  380. package/build/queries/find/Aliases.d.mts.map +1 -1
  381. package/build/queries/find/DeferredAlias.d.cts +5 -6
  382. package/build/queries/find/DeferredAlias.d.cts.map +1 -1
  383. package/build/queries/find/DeferredAlias.d.mts +5 -6
  384. package/build/queries/find/DeferredAlias.d.mts.map +1 -1
  385. package/build/queries/find/EntityFilter.d.cts +12 -13
  386. package/build/queries/find/EntityFilter.d.cts.map +1 -1
  387. package/build/queries/find/EntityFilter.d.mts +12 -13
  388. package/build/queries/find/EntityFilter.d.mts.map +1 -1
  389. package/build/queries/find/EntityGraphQLFilter.d.cts +8 -9
  390. package/build/queries/find/EntityGraphQLFilter.d.cts.map +1 -1
  391. package/build/queries/find/EntityGraphQLFilter.d.mts +8 -9
  392. package/build/queries/find/EntityGraphQLFilter.d.mts.map +1 -1
  393. package/build/queries/find/QueryParser.cjs +18 -7
  394. package/build/queries/find/QueryParser.cjs.map +1 -1
  395. package/build/queries/find/QueryParser.collectionJoins.cjs +2 -1
  396. package/build/queries/find/QueryParser.collectionJoins.cjs.map +1 -1
  397. package/build/queries/find/QueryParser.collectionJoins.d.cts +1 -2
  398. package/build/queries/find/QueryParser.collectionJoins.d.cts.map +1 -1
  399. package/build/queries/find/QueryParser.collectionJoins.d.mts +1 -2
  400. package/build/queries/find/QueryParser.collectionJoins.d.mts.map +1 -1
  401. package/build/queries/find/QueryParser.collectionJoins.js +2 -1
  402. package/build/queries/find/QueryParser.collectionJoins.js.map +1 -1
  403. package/build/queries/find/QueryParser.d.cts +39 -18
  404. package/build/queries/find/QueryParser.d.cts.map +1 -1
  405. package/build/queries/find/QueryParser.d.mts +39 -18
  406. package/build/queries/find/QueryParser.d.mts.map +1 -1
  407. package/build/queries/find/QueryParser.js +18 -7
  408. package/build/queries/find/QueryParser.js.map +1 -1
  409. package/build/queries/find/QueryParser.pruning.cjs +50 -1
  410. package/build/queries/find/QueryParser.pruning.cjs.map +1 -1
  411. package/build/queries/find/QueryParser.pruning.d.cts +15 -3
  412. package/build/queries/find/QueryParser.pruning.d.cts.map +1 -1
  413. package/build/queries/find/QueryParser.pruning.d.mts +15 -3
  414. package/build/queries/find/QueryParser.pruning.d.mts.map +1 -1
  415. package/build/queries/find/QueryParser.pruning.js +50 -1
  416. package/build/queries/find/QueryParser.pruning.js.map +1 -1
  417. package/build/queries/find/QueryVisitor.d.cts +4 -4
  418. package/build/queries/find/QueryVisitor.d.cts.map +1 -1
  419. package/build/queries/find/QueryVisitor.d.mts +4 -4
  420. package/build/queries/find/QueryVisitor.d.mts.map +1 -1
  421. package/build/queries/find/buildFindQuery.d.cts +3 -3
  422. package/build/queries/find/buildFindQuery.d.cts.map +1 -1
  423. package/build/queries/find/buildFindQuery.d.mts +3 -3
  424. package/build/queries/find/buildFindQuery.d.mts.map +1 -1
  425. package/build/queries/find/scopes.cjs.map +1 -1
  426. package/build/queries/find/scopes.d.cts +12 -13
  427. package/build/queries/find/scopes.d.cts.map +1 -1
  428. package/build/queries/find/scopes.d.mts +12 -13
  429. package/build/queries/find/scopes.d.mts.map +1 -1
  430. package/build/queries/find/scopes.js.map +1 -1
  431. package/build/queries/parsedConditions.d.cts +7 -8
  432. package/build/queries/parsedConditions.d.cts.map +1 -1
  433. package/build/queries/parsedConditions.d.mts +7 -8
  434. package/build/queries/parsedConditions.d.mts.map +1 -1
  435. package/build/queries/renderConditions.d.cts +3 -4
  436. package/build/queries/renderConditions.d.cts.map +1 -1
  437. package/build/queries/renderConditions.d.mts +3 -4
  438. package/build/queries/renderConditions.d.mts.map +1 -1
  439. package/build/queries/skipCondition.d.cts +1 -2
  440. package/build/queries/skipCondition.d.cts.map +1 -1
  441. package/build/queries/skipCondition.d.mts +1 -2
  442. package/build/queries/skipCondition.d.mts.map +1 -1
  443. package/build/queries/sql/AliasAssigner.cjs.map +1 -1
  444. package/build/queries/sql/AliasAssigner.d.cts +1 -2
  445. package/build/queries/sql/AliasAssigner.d.cts.map +1 -1
  446. package/build/queries/sql/AliasAssigner.d.mts +1 -2
  447. package/build/queries/sql/AliasAssigner.d.mts.map +1 -1
  448. package/build/queries/sql/AliasAssigner.js.map +1 -1
  449. package/build/queries/sql/Expr.cjs +38 -0
  450. package/build/queries/sql/Expr.cjs.map +1 -1
  451. package/build/queries/sql/Expr.d.cts +45 -27
  452. package/build/queries/sql/Expr.d.cts.map +1 -1
  453. package/build/queries/sql/Expr.d.mts +45 -27
  454. package/build/queries/sql/Expr.d.mts.map +1 -1
  455. package/build/queries/sql/Expr.js +38 -1
  456. package/build/queries/sql/Expr.js.map +1 -1
  457. package/build/queries/sql/JoinTree.d.cts +5 -5
  458. package/build/queries/sql/JoinTree.d.cts.map +1 -1
  459. package/build/queries/sql/JoinTree.d.mts +5 -5
  460. package/build/queries/sql/JoinTree.d.mts.map +1 -1
  461. package/build/queries/sql/Tables.cjs +9 -0
  462. package/build/queries/sql/Tables.cjs.map +1 -1
  463. package/build/queries/sql/Tables.d.cts +46 -39
  464. package/build/queries/sql/Tables.d.cts.map +1 -1
  465. package/build/queries/sql/Tables.d.mts +46 -39
  466. package/build/queries/sql/Tables.d.mts.map +1 -1
  467. package/build/queries/sql/Tables.js +10 -1
  468. package/build/queries/sql/Tables.js.map +1 -1
  469. package/build/queries/sql/custom.d.cts +14 -14
  470. package/build/queries/sql/custom.d.cts.map +1 -1
  471. package/build/queries/sql/custom.d.mts +14 -14
  472. package/build/queries/sql/custom.d.mts.map +1 -1
  473. package/build/queries/sql/execute.cjs +68 -89
  474. package/build/queries/sql/execute.cjs.map +1 -1
  475. package/build/queries/sql/execute.d.cts +49 -32
  476. package/build/queries/sql/execute.d.cts.map +1 -1
  477. package/build/queries/sql/execute.d.mts +49 -32
  478. package/build/queries/sql/execute.d.mts.map +1 -1
  479. package/build/queries/sql/execute.js +70 -91
  480. package/build/queries/sql/execute.js.map +1 -1
  481. package/build/queries/sql/expressions/arrayAgg.d.cts +5 -6
  482. package/build/queries/sql/expressions/arrayAgg.d.cts.map +1 -1
  483. package/build/queries/sql/expressions/arrayAgg.d.mts +5 -6
  484. package/build/queries/sql/expressions/arrayAgg.d.mts.map +1 -1
  485. package/build/queries/sql/expressions/case.d.cts +10 -10
  486. package/build/queries/sql/expressions/case.d.cts.map +1 -1
  487. package/build/queries/sql/expressions/case.d.mts +10 -10
  488. package/build/queries/sql/expressions/case.d.mts.map +1 -1
  489. package/build/queries/sql/expressions/coalesce.d.cts +5 -6
  490. package/build/queries/sql/expressions/coalesce.d.cts.map +1 -1
  491. package/build/queries/sql/expressions/coalesce.d.mts +5 -6
  492. package/build/queries/sql/expressions/coalesce.d.mts.map +1 -1
  493. package/build/queries/sql/expressions/codecs.d.cts +1 -2
  494. package/build/queries/sql/expressions/codecs.d.cts.map +1 -1
  495. package/build/queries/sql/expressions/codecs.d.mts +1 -2
  496. package/build/queries/sql/expressions/codecs.d.mts.map +1 -1
  497. package/build/queries/sql/expressions/expression.d.cts +6 -6
  498. package/build/queries/sql/expressions/expression.d.cts.map +1 -1
  499. package/build/queries/sql/expressions/expression.d.mts +6 -6
  500. package/build/queries/sql/expressions/expression.d.mts.map +1 -1
  501. package/build/queries/sql/expressions/greatest.d.cts +5 -6
  502. package/build/queries/sql/expressions/greatest.d.cts.map +1 -1
  503. package/build/queries/sql/expressions/greatest.d.mts +5 -6
  504. package/build/queries/sql/expressions/greatest.d.mts.map +1 -1
  505. package/build/queries/sql/expressions/least.d.cts +5 -6
  506. package/build/queries/sql/expressions/least.d.cts.map +1 -1
  507. package/build/queries/sql/expressions/least.d.mts +5 -6
  508. package/build/queries/sql/expressions/least.d.mts.map +1 -1
  509. package/build/queries/sql/expressions/nullIf.d.cts +5 -6
  510. package/build/queries/sql/expressions/nullIf.d.cts.map +1 -1
  511. package/build/queries/sql/expressions/nullIf.d.mts +5 -6
  512. package/build/queries/sql/expressions/nullIf.d.mts.map +1 -1
  513. package/build/queries/sql/expressions/parseExpression.d.cts +5 -6
  514. package/build/queries/sql/expressions/parseExpression.d.cts.map +1 -1
  515. package/build/queries/sql/expressions/parseExpression.d.mts +5 -6
  516. package/build/queries/sql/expressions/parseExpression.d.mts.map +1 -1
  517. package/build/queries/sql/expressions/types.d.cts +11 -11
  518. package/build/queries/sql/expressions/types.d.cts.map +1 -1
  519. package/build/queries/sql/expressions/types.d.mts +11 -11
  520. package/build/queries/sql/expressions/types.d.mts.map +1 -1
  521. package/build/queries/sql/keywords.d.cts +4 -5
  522. package/build/queries/sql/keywords.d.cts.map +1 -1
  523. package/build/queries/sql/keywords.d.mts +4 -5
  524. package/build/queries/sql/keywords.d.mts.map +1 -1
  525. package/build/queries/sql/query.cjs +77 -30
  526. package/build/queries/sql/query.cjs.map +1 -1
  527. package/build/queries/sql/query.d.cts +119 -76
  528. package/build/queries/sql/query.d.cts.map +1 -1
  529. package/build/queries/sql/query.d.mts +119 -76
  530. package/build/queries/sql/query.d.mts.map +1 -1
  531. package/build/queries/sql/query.js +75 -30
  532. package/build/queries/sql/query.js.map +1 -1
  533. package/build/queries/unnest.cjs +4 -5
  534. package/build/queries/unnest.cjs.map +1 -1
  535. package/build/queries/unnest.d.cts +2 -3
  536. package/build/queries/unnest.d.cts.map +1 -1
  537. package/build/queries/unnest.d.mts +2 -3
  538. package/build/queries/unnest.d.mts.map +1 -1
  539. package/build/queries/unnest.js +4 -5
  540. package/build/queries/unnest.js.map +1 -1
  541. package/build/queries/valueFilters.d.cts +5 -6
  542. package/build/queries/valueFilters.d.cts.map +1 -1
  543. package/build/queries/valueFilters.d.mts +5 -6
  544. package/build/queries/valueFilters.d.mts.map +1 -1
  545. package/build/reactivity/ReactionsManager.cjs +171 -2
  546. package/build/reactivity/ReactionsManager.cjs.map +1 -1
  547. package/build/reactivity/ReactionsManager.d.cts +56 -4
  548. package/build/reactivity/ReactionsManager.d.cts.map +1 -1
  549. package/build/reactivity/ReactionsManager.d.mts +56 -4
  550. package/build/reactivity/ReactionsManager.d.mts.map +1 -1
  551. package/build/reactivity/ReactionsManager.js +172 -3
  552. package/build/reactivity/ReactionsManager.js.map +1 -1
  553. package/build/reactivity/reactiveHints.cjs +9 -3
  554. package/build/reactivity/reactiveHints.cjs.map +1 -1
  555. package/build/reactivity/reactiveHints.d.cts +19 -18
  556. package/build/reactivity/reactiveHints.d.cts.map +1 -1
  557. package/build/reactivity/reactiveHints.d.mts +19 -18
  558. package/build/reactivity/reactiveHints.d.mts.map +1 -1
  559. package/build/reactivity/reactiveHints.js +9 -3
  560. package/build/reactivity/reactiveHints.js.map +1 -1
  561. package/build/relations/AbstractPropertyImpl.cjs.map +1 -1
  562. package/build/relations/AbstractPropertyImpl.d.cts +1 -2
  563. package/build/relations/AbstractPropertyImpl.d.cts.map +1 -1
  564. package/build/relations/AbstractPropertyImpl.d.mts +1 -2
  565. package/build/relations/AbstractPropertyImpl.d.mts.map +1 -1
  566. package/build/relations/AbstractPropertyImpl.js.map +1 -1
  567. package/build/relations/AbstractRelationImpl.d.cts +1 -2
  568. package/build/relations/AbstractRelationImpl.d.cts.map +1 -1
  569. package/build/relations/AbstractRelationImpl.d.mts +1 -2
  570. package/build/relations/AbstractRelationImpl.d.mts.map +1 -1
  571. package/build/relations/AsyncProperty.cjs +1 -1
  572. package/build/relations/AsyncProperty.cjs.map +1 -1
  573. package/build/relations/AsyncProperty.d.cts +5 -6
  574. package/build/relations/AsyncProperty.d.cts.map +1 -1
  575. package/build/relations/AsyncProperty.d.mts +5 -6
  576. package/build/relations/AsyncProperty.d.mts.map +1 -1
  577. package/build/relations/AsyncProperty.js +1 -1
  578. package/build/relations/AsyncProperty.js.map +1 -1
  579. package/build/relations/AsyncReactiveField.cjs +23 -5
  580. package/build/relations/AsyncReactiveField.cjs.map +1 -1
  581. package/build/relations/AsyncReactiveField.d.cts +7 -6
  582. package/build/relations/AsyncReactiveField.d.cts.map +1 -1
  583. package/build/relations/AsyncReactiveField.d.mts +7 -6
  584. package/build/relations/AsyncReactiveField.d.mts.map +1 -1
  585. package/build/relations/AsyncReactiveField.js +23 -5
  586. package/build/relations/AsyncReactiveField.js.map +1 -1
  587. package/build/relations/Collection.d.cts +4 -5
  588. package/build/relations/Collection.d.cts.map +1 -1
  589. package/build/relations/Collection.d.mts +4 -5
  590. package/build/relations/Collection.d.mts.map +1 -1
  591. package/build/relations/CustomCollection.cjs +1 -1
  592. package/build/relations/CustomCollection.cjs.map +1 -1
  593. package/build/relations/CustomCollection.d.cts +3 -4
  594. package/build/relations/CustomCollection.d.cts.map +1 -1
  595. package/build/relations/CustomCollection.d.mts +3 -4
  596. package/build/relations/CustomCollection.d.mts.map +1 -1
  597. package/build/relations/CustomCollection.js +1 -1
  598. package/build/relations/CustomCollection.js.map +1 -1
  599. package/build/relations/CustomReference.cjs +2 -2
  600. package/build/relations/CustomReference.cjs.map +1 -1
  601. package/build/relations/CustomReference.d.cts +3 -4
  602. package/build/relations/CustomReference.d.cts.map +1 -1
  603. package/build/relations/CustomReference.d.mts +3 -4
  604. package/build/relations/CustomReference.d.mts.map +1 -1
  605. package/build/relations/CustomReference.js +2 -2
  606. package/build/relations/CustomReference.js.map +1 -1
  607. package/build/relations/EnumCollection.cjs +1 -1
  608. package/build/relations/EnumCollection.cjs.map +1 -1
  609. package/build/relations/EnumCollection.d.cts +5 -5
  610. package/build/relations/EnumCollection.d.cts.map +1 -1
  611. package/build/relations/EnumCollection.d.mts +5 -5
  612. package/build/relations/EnumCollection.d.mts.map +1 -1
  613. package/build/relations/EnumCollection.js +1 -1
  614. package/build/relations/EnumCollection.js.map +1 -1
  615. package/build/relations/LargeCollection.d.cts +1 -2
  616. package/build/relations/LargeCollection.d.cts.map +1 -1
  617. package/build/relations/LargeCollection.d.mts +1 -2
  618. package/build/relations/LargeCollection.d.mts.map +1 -1
  619. package/build/relations/LazyField.cjs +16 -2
  620. package/build/relations/LazyField.cjs.map +1 -1
  621. package/build/relations/LazyField.d.cts +13 -8
  622. package/build/relations/LazyField.d.cts.map +1 -1
  623. package/build/relations/LazyField.d.mts +13 -8
  624. package/build/relations/LazyField.d.mts.map +1 -1
  625. package/build/relations/LazyField.js +16 -2
  626. package/build/relations/LazyField.js.map +1 -1
  627. package/build/relations/ManyToManyCollection.cjs +1 -1
  628. package/build/relations/ManyToManyCollection.cjs.map +1 -1
  629. package/build/relations/ManyToManyCollection.d.cts +2 -3
  630. package/build/relations/ManyToManyCollection.d.cts.map +1 -1
  631. package/build/relations/ManyToManyCollection.d.mts +2 -3
  632. package/build/relations/ManyToManyCollection.d.mts.map +1 -1
  633. package/build/relations/ManyToManyCollection.js +1 -1
  634. package/build/relations/ManyToManyCollection.js.map +1 -1
  635. package/build/relations/ManyToManyLargeCollection.cjs +1 -1
  636. package/build/relations/ManyToManyLargeCollection.d.cts +2 -3
  637. package/build/relations/ManyToManyLargeCollection.d.cts.map +1 -1
  638. package/build/relations/ManyToManyLargeCollection.d.mts +2 -3
  639. package/build/relations/ManyToManyLargeCollection.d.mts.map +1 -1
  640. package/build/relations/ManyToManyLargeCollection.js +1 -1
  641. package/build/relations/ManyToOneReference.cjs +2 -2
  642. package/build/relations/ManyToOneReference.cjs.map +1 -1
  643. package/build/relations/ManyToOneReference.d.cts +6 -7
  644. package/build/relations/ManyToOneReference.d.cts.map +1 -1
  645. package/build/relations/ManyToOneReference.d.mts +6 -7
  646. package/build/relations/ManyToOneReference.d.mts.map +1 -1
  647. package/build/relations/ManyToOneReference.js +2 -2
  648. package/build/relations/ManyToOneReference.js.map +1 -1
  649. package/build/relations/OneToManyCollection.cjs +1 -1
  650. package/build/relations/OneToManyCollection.cjs.map +1 -1
  651. package/build/relations/OneToManyCollection.d.cts +2 -3
  652. package/build/relations/OneToManyCollection.d.cts.map +1 -1
  653. package/build/relations/OneToManyCollection.d.mts +2 -3
  654. package/build/relations/OneToManyCollection.d.mts.map +1 -1
  655. package/build/relations/OneToManyCollection.js +1 -1
  656. package/build/relations/OneToManyCollection.js.map +1 -1
  657. package/build/relations/OneToManyLargeCollection.cjs +1 -1
  658. package/build/relations/OneToManyLargeCollection.cjs.map +1 -1
  659. package/build/relations/OneToManyLargeCollection.d.cts +2 -3
  660. package/build/relations/OneToManyLargeCollection.d.cts.map +1 -1
  661. package/build/relations/OneToManyLargeCollection.d.mts +2 -3
  662. package/build/relations/OneToManyLargeCollection.d.mts.map +1 -1
  663. package/build/relations/OneToManyLargeCollection.js +1 -1
  664. package/build/relations/OneToManyLargeCollection.js.map +1 -1
  665. package/build/relations/OneToOneReference.cjs +2 -2
  666. package/build/relations/OneToOneReference.cjs.map +1 -1
  667. package/build/relations/OneToOneReference.d.cts +7 -7
  668. package/build/relations/OneToOneReference.d.cts.map +1 -1
  669. package/build/relations/OneToOneReference.d.mts +7 -7
  670. package/build/relations/OneToOneReference.d.mts.map +1 -1
  671. package/build/relations/OneToOneReference.js +2 -2
  672. package/build/relations/OneToOneReference.js.map +1 -1
  673. package/build/relations/PolymorphicReference.cjs +2 -2
  674. package/build/relations/PolymorphicReference.cjs.map +1 -1
  675. package/build/relations/PolymorphicReference.d.cts +4 -5
  676. package/build/relations/PolymorphicReference.d.cts.map +1 -1
  677. package/build/relations/PolymorphicReference.d.mts +4 -5
  678. package/build/relations/PolymorphicReference.d.mts.map +1 -1
  679. package/build/relations/PolymorphicReference.js +2 -2
  680. package/build/relations/PolymorphicReference.js.map +1 -1
  681. package/build/relations/PropertySymbols.d.cts +1 -2
  682. package/build/relations/PropertySymbols.d.cts.map +1 -1
  683. package/build/relations/PropertySymbols.d.mts +1 -2
  684. package/build/relations/PropertySymbols.d.mts.map +1 -1
  685. package/build/relations/ReactiveField.cjs +27 -6
  686. package/build/relations/ReactiveField.cjs.map +1 -1
  687. package/build/relations/ReactiveField.d.cts +11 -7
  688. package/build/relations/ReactiveField.d.cts.map +1 -1
  689. package/build/relations/ReactiveField.d.mts +11 -7
  690. package/build/relations/ReactiveField.d.mts.map +1 -1
  691. package/build/relations/ReactiveField.js +27 -6
  692. package/build/relations/ReactiveField.js.map +1 -1
  693. package/build/relations/ReactiveGetter.cjs +1 -1
  694. package/build/relations/ReactiveGetter.cjs.map +1 -1
  695. package/build/relations/ReactiveGetter.d.cts +4 -5
  696. package/build/relations/ReactiveGetter.d.cts.map +1 -1
  697. package/build/relations/ReactiveGetter.d.mts +4 -5
  698. package/build/relations/ReactiveGetter.d.mts.map +1 -1
  699. package/build/relations/ReactiveGetter.js +1 -1
  700. package/build/relations/ReactiveGetter.js.map +1 -1
  701. package/build/relations/ReactiveManyToMany.cjs +1 -1
  702. package/build/relations/ReactiveManyToMany.cjs.map +1 -1
  703. package/build/relations/ReactiveManyToMany.d.cts +4 -5
  704. package/build/relations/ReactiveManyToMany.d.cts.map +1 -1
  705. package/build/relations/ReactiveManyToMany.d.mts +4 -5
  706. package/build/relations/ReactiveManyToMany.d.mts.map +1 -1
  707. package/build/relations/ReactiveManyToMany.js +1 -1
  708. package/build/relations/ReactiveManyToMany.js.map +1 -1
  709. package/build/relations/ReactiveManyToManyOtherSide.cjs +1 -1
  710. package/build/relations/ReactiveManyToManyOtherSide.cjs.map +1 -1
  711. package/build/relations/ReactiveManyToManyOtherSide.d.cts +4 -5
  712. package/build/relations/ReactiveManyToManyOtherSide.d.cts.map +1 -1
  713. package/build/relations/ReactiveManyToManyOtherSide.d.mts +4 -5
  714. package/build/relations/ReactiveManyToManyOtherSide.d.mts.map +1 -1
  715. package/build/relations/ReactiveManyToManyOtherSide.js +1 -1
  716. package/build/relations/ReactiveManyToManyOtherSide.js.map +1 -1
  717. package/build/relations/ReactiveReference.cjs +2 -2
  718. package/build/relations/ReactiveReference.cjs.map +1 -1
  719. package/build/relations/ReactiveReference.d.cts +6 -7
  720. package/build/relations/ReactiveReference.d.cts.map +1 -1
  721. package/build/relations/ReactiveReference.d.mts +6 -7
  722. package/build/relations/ReactiveReference.d.mts.map +1 -1
  723. package/build/relations/ReactiveReference.js +2 -2
  724. package/build/relations/ReactiveReference.js.map +1 -1
  725. package/build/relations/ReadOnlyCollection.d.cts +4 -5
  726. package/build/relations/ReadOnlyCollection.d.cts.map +1 -1
  727. package/build/relations/ReadOnlyCollection.d.mts +4 -5
  728. package/build/relations/ReadOnlyCollection.d.mts.map +1 -1
  729. package/build/relations/RecursiveCollection.cjs +1 -1
  730. package/build/relations/RecursiveCollection.cjs.map +1 -1
  731. package/build/relations/RecursiveCollection.d.cts +10 -10
  732. package/build/relations/RecursiveCollection.d.cts.map +1 -1
  733. package/build/relations/RecursiveCollection.d.mts +10 -10
  734. package/build/relations/RecursiveCollection.d.mts.map +1 -1
  735. package/build/relations/RecursiveCollection.js +1 -1
  736. package/build/relations/RecursiveCollection.js.map +1 -1
  737. package/build/relations/RecursiveCycleError.d.cts +2 -2
  738. package/build/relations/RecursiveCycleError.d.cts.map +1 -1
  739. package/build/relations/RecursiveCycleError.d.mts +2 -2
  740. package/build/relations/RecursiveCycleError.d.mts.map +1 -1
  741. package/build/relations/Reference.d.cts +5 -5
  742. package/build/relations/Reference.d.cts.map +1 -1
  743. package/build/relations/Reference.d.mts +5 -5
  744. package/build/relations/Reference.d.mts.map +1 -1
  745. package/build/relations/ReferenceSymbols.d.cts +1 -2
  746. package/build/relations/ReferenceSymbols.d.cts.map +1 -1
  747. package/build/relations/ReferenceSymbols.d.mts +1 -2
  748. package/build/relations/ReferenceSymbols.d.mts.map +1 -1
  749. package/build/relations/Relation.d.cts +3 -3
  750. package/build/relations/Relation.d.cts.map +1 -1
  751. package/build/relations/Relation.d.mts +3 -3
  752. package/build/relations/Relation.d.mts.map +1 -1
  753. package/build/relations/RelationSymbols.d.cts +2 -3
  754. package/build/relations/RelationSymbols.d.cts.map +1 -1
  755. package/build/relations/RelationSymbols.d.mts +2 -3
  756. package/build/relations/RelationSymbols.d.mts.map +1 -1
  757. package/build/relations/hasAsyncMethod.cjs +24 -5
  758. package/build/relations/hasAsyncMethod.cjs.map +1 -1
  759. package/build/relations/hasAsyncMethod.d.cts +9 -8
  760. package/build/relations/hasAsyncMethod.d.cts.map +1 -1
  761. package/build/relations/hasAsyncMethod.d.mts +9 -8
  762. package/build/relations/hasAsyncMethod.d.mts.map +1 -1
  763. package/build/relations/hasAsyncMethod.js +24 -6
  764. package/build/relations/hasAsyncMethod.js.map +1 -1
  765. package/build/relations/hasManyDerived.cjs +1 -1
  766. package/build/relations/hasManyDerived.d.cts +2 -2
  767. package/build/relations/hasManyDerived.d.cts.map +1 -1
  768. package/build/relations/hasManyDerived.d.mts +2 -2
  769. package/build/relations/hasManyDerived.d.mts.map +1 -1
  770. package/build/relations/hasManyDerived.js +1 -1
  771. package/build/relations/hasManyThrough.cjs +1 -1
  772. package/build/relations/hasManyThrough.d.cts +1 -2
  773. package/build/relations/hasManyThrough.d.cts.map +1 -1
  774. package/build/relations/hasManyThrough.d.mts +1 -2
  775. package/build/relations/hasManyThrough.d.mts.map +1 -1
  776. package/build/relations/hasManyThrough.js +1 -1
  777. package/build/relations/hasOneDerived.cjs +1 -1
  778. package/build/relations/hasOneDerived.d.cts +1 -2
  779. package/build/relations/hasOneDerived.d.cts.map +1 -1
  780. package/build/relations/hasOneDerived.d.mts +1 -2
  781. package/build/relations/hasOneDerived.d.mts.map +1 -1
  782. package/build/relations/hasOneDerived.js +1 -1
  783. package/build/relations/hasOneThrough.cjs +1 -1
  784. package/build/relations/hasOneThrough.d.cts +1 -2
  785. package/build/relations/hasOneThrough.d.cts.map +1 -1
  786. package/build/relations/hasOneThrough.d.mts +1 -2
  787. package/build/relations/hasOneThrough.d.mts.map +1 -1
  788. package/build/relations/hasOneThrough.js +1 -1
  789. package/build/relations/hasProperty.cjs +1 -1
  790. package/build/relations/hasProperty.cjs.map +1 -1
  791. package/build/relations/hasProperty.d.cts +8 -8
  792. package/build/relations/hasProperty.d.cts.map +1 -1
  793. package/build/relations/hasProperty.d.mts +8 -8
  794. package/build/relations/hasProperty.d.mts.map +1 -1
  795. package/build/relations/hasProperty.js +1 -1
  796. package/build/relations/hasProperty.js.map +1 -1
  797. package/build/relations/hasReactiveAsyncMethod.cjs +87 -0
  798. package/build/relations/hasReactiveAsyncMethod.cjs.map +1 -0
  799. package/build/relations/hasReactiveAsyncMethod.d.cts +32 -0
  800. package/build/relations/hasReactiveAsyncMethod.d.cts.map +1 -0
  801. package/build/relations/hasReactiveAsyncMethod.d.mts +32 -0
  802. package/build/relations/hasReactiveAsyncMethod.d.mts.map +1 -0
  803. package/build/relations/hasReactiveAsyncMethod.js +85 -0
  804. package/build/relations/hasReactiveAsyncMethod.js.map +1 -0
  805. package/build/relations/index.cjs +2 -0
  806. package/build/relations/index.d.cts +2 -1
  807. package/build/relations/index.d.mts +2 -1
  808. package/build/relations/index.js +2 -1
  809. package/build/relations/isCascadeDelete.d.cts +1 -2
  810. package/build/relations/isCascadeDelete.d.cts.map +1 -1
  811. package/build/relations/isCascadeDelete.d.mts +1 -2
  812. package/build/relations/isCascadeDelete.d.mts.map +1 -1
  813. package/build/resurrection.cjs +11 -1
  814. package/build/resurrection.cjs.map +1 -1
  815. package/build/resurrection.d.cts +5 -3
  816. package/build/resurrection.d.cts.map +1 -1
  817. package/build/resurrection.d.mts +5 -3
  818. package/build/resurrection.d.mts.map +1 -1
  819. package/build/resurrection.js +11 -2
  820. package/build/resurrection.js.map +1 -1
  821. package/build/rules.cjs +1 -1
  822. package/build/rules.cjs.map +1 -1
  823. package/build/rules.d.cts +25 -20
  824. package/build/rules.d.cts.map +1 -1
  825. package/build/rules.d.mts +25 -20
  826. package/build/rules.d.mts.map +1 -1
  827. package/build/rules.js +1 -1
  828. package/build/rules.js.map +1 -1
  829. package/build/runtimeConfig.d.cts +4 -5
  830. package/build/runtimeConfig.d.cts.map +1 -1
  831. package/build/runtimeConfig.d.mts +4 -5
  832. package/build/runtimeConfig.d.mts.map +1 -1
  833. package/build/serde/TypeInfo.d.cts +3 -4
  834. package/build/serde/TypeInfo.d.cts.map +1 -1
  835. package/build/serde/TypeInfo.d.mts +3 -4
  836. package/build/serde/TypeInfo.d.mts.map +1 -1
  837. package/build/serde/columns.cjs +3 -0
  838. package/build/serde/columns.cjs.map +1 -1
  839. package/build/serde/columns.d.cts +3 -3
  840. package/build/serde/columns.d.cts.map +1 -1
  841. package/build/serde/columns.d.mts +3 -3
  842. package/build/serde/columns.d.mts.map +1 -1
  843. package/build/serde/columns.js +3 -0
  844. package/build/serde/columns.js.map +1 -1
  845. package/build/serde/fieldSerde.cjs +3 -0
  846. package/build/serde/fieldSerde.cjs.map +1 -1
  847. package/build/serde/fieldSerde.d.cts +10 -9
  848. package/build/serde/fieldSerde.d.cts.map +1 -1
  849. package/build/serde/fieldSerde.d.mts +10 -9
  850. package/build/serde/fieldSerde.d.mts.map +1 -1
  851. package/build/serde/fieldSerde.js +3 -0
  852. package/build/serde/fieldSerde.js.map +1 -1
  853. package/build/serde/serde.cjs +60 -0
  854. package/build/serde/serde.cjs.map +1 -1
  855. package/build/serde/serde.d.cts +58 -19
  856. package/build/serde/serde.d.cts.map +1 -1
  857. package/build/serde/serde.d.mts +58 -19
  858. package/build/serde/serde.d.mts.map +1 -1
  859. package/build/serde/serde.js +60 -1
  860. package/build/serde/serde.js.map +1 -1
  861. package/build/serde/temporal.cjs +7 -12
  862. package/build/serde/temporal.cjs.map +1 -1
  863. package/build/serde/temporal.d.cts +6 -6
  864. package/build/serde/temporal.d.cts.map +1 -1
  865. package/build/serde/temporal.d.mts +6 -6
  866. package/build/serde/temporal.d.mts.map +1 -1
  867. package/build/serde/temporal.js +7 -12
  868. package/build/serde/temporal.js.map +1 -1
  869. package/build/serde/temporalMappers.cjs +8 -4
  870. package/build/serde/temporalMappers.cjs.map +1 -1
  871. package/build/serde/temporalMappers.d.cts +4 -5
  872. package/build/serde/temporalMappers.d.cts.map +1 -1
  873. package/build/serde/temporalMappers.d.mts +4 -5
  874. package/build/serde/temporalMappers.d.mts.map +1 -1
  875. package/build/serde/temporalMappers.js +8 -4
  876. package/build/serde/temporalMappers.js.map +1 -1
  877. package/build/transitions.cjs +91 -0
  878. package/build/transitions.cjs.map +1 -0
  879. package/build/transitions.d.cts +115 -0
  880. package/build/transitions.d.cts.map +1 -0
  881. package/build/transitions.d.mts +115 -0
  882. package/build/transitions.d.mts.map +1 -0
  883. package/build/transitions.js +86 -0
  884. package/build/transitions.js.map +1 -0
  885. package/build/trusted.d.cts +2 -3
  886. package/build/trusted.d.cts.map +1 -1
  887. package/build/trusted.d.mts +2 -3
  888. package/build/trusted.d.mts.map +1 -1
  889. package/build/typeMap.d.cts +17 -17
  890. package/build/typeMap.d.cts.map +1 -1
  891. package/build/typeMap.d.mts +17 -17
  892. package/build/typeMap.d.mts.map +1 -1
  893. package/build/upsert.cjs +1 -1
  894. package/build/upsert.d.cts +4 -4
  895. package/build/upsert.d.cts.map +1 -1
  896. package/build/upsert.d.mts +4 -4
  897. package/build/upsert.d.mts.map +1 -1
  898. package/build/upsert.js +1 -1
  899. package/build/utils.d.cts +27 -28
  900. package/build/utils.d.cts.map +1 -1
  901. package/build/utils.d.mts +27 -28
  902. package/build/utils.d.mts.map +1 -1
  903. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"serde.js","names":[],"sources":["../../src/serde/serde.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { isDefined } from \"src/EntityManager.ts\";\nimport { keyToNumber, keyToTaggedId, maybeResolveReferenceToId } from \"src/keys.ts\";\nimport { getRuntimeConfig } from \"src/runtimeConfig.ts\";\nimport { type Temporal, requireTemporal } from \"src/serde/temporal.ts\";\nimport {\n plainDateMapper,\n plainDateTimeMapper,\n plainTimeMapper,\n zonedDateTimeMapper,\n} from \"src/serde/temporalMappers.ts\";\nimport { type TypeInfo, arrayOutputType, canonicalDbType } from \"src/serde/TypeInfo.ts\";\n\nconst runtimeRequire = createRequire(import.meta.url);\n\n/** Scalar conversion only: no field names, entity hydration, or FK fixups. */\nexport interface ScalarCodec {\n dbType: string;\n isArray: boolean;\n /** Compatibility evidence for scalar conversion, absent for unknown codecs. */\n readonly outputType?: TypeInfo;\n /** Encodes a domain value for a filter, i.e. an em.find WHERE parameter. */\n mapToDb(value: any): any;\n /**\n * Encodes a domain value for an INSERT or UPDATE binding.\n *\n * Callers must handle omission, SQL NULL, and SQL expressions before encoding. JSON null and\n * codec defaults can differ from SQL NULL. Direct mutations must validate reference targets\n * and reject new or unflushed entities before encoding.\n */\n mapToDbValue?(value: unknown): unknown;\n /** Converts a driver value to its domain value, including the codec's null/default handling. */\n mapFromDb(value: unknown): unknown;\n /**\n * Converts a json_agg cell to a driver-row value, not a domain value.\n *\n * Lazy field hydration subsequently calls mapFromDb. I.e. Date codecs reconstruct a Date\n * from the JSON string, while Temporal codecs retain the driver's string representation.\n */\n mapFromJsonAgg(value: any): any;\n /** Reconstructs a driver value from a domain value, not a SQL binding. */\n mapToRow(value: any): any;\n}\n\n/** Converts the ORM clock to the timestamp's domain representation. */\nexport interface TimestampCodec<T> extends ScalarCodec {\n mapFromNow(now: Date): T;\n}\n\n/**\n * Provides a simplified, public API for mapping between db/domain values.\n *\n * Joist's internal `FieldSerde` API is admittedly a little crufty, and so this\n * API is intended to be a simpler, more user-friendly way to define custom types.\n */\nexport interface CustomSerde<DomainType, DbType> {\n toDb(value: DomainType): DbType;\n fromDb(value: DbType): DomainType;\n}\n\nexport class CustomSerdeAdapter implements ScalarCodec {\n isArray: boolean = false;\n\n constructor(\n public dbType: string,\n private mapper: CustomSerde<any, any>,\n isArray?: boolean,\n ) {\n if (isArray !== undefined) this.isArray = isArray;\n }\n\n /** Only known adapters share their mapper's identity and elementwise array conversion. */\n get outputType(): TypeInfo | undefined {\n if (\n this.isArray !== this.dbType.endsWith(\"[]\") ||\n (this.constructor !== CustomSerdeAdapter &&\n this.constructor !== PlainDateSerde &&\n this.constructor !== PlainTimeSerde &&\n this.constructor !== PlainDateTimeSerde &&\n this.constructor !== ZonedDateTimeSerde)\n ) {\n return undefined;\n }\n const dbType = canonicalDbType(this.dbType);\n // A numeric mapper may require scalar text; classic pg decodes numeric[] elements as numbers.\n const elementType = this.isArray ? dbType.slice(0, -2) : dbType;\n const outputType = { dbType: elementType, domain: this.mapper, arrayElementSafe: elementType !== \"numeric\" };\n if (!this.isArray) return outputType;\n // Physical arrays pass null elements to the mapper, unlike scalar arrayAgg; keep their domains distinct.\n return arrayOutputType(outputType) || [\"date\", \"time\", \"timestamp\", \"timestamptz\"].includes(elementType)\n ? { dbType, domain: this.mapper }\n : undefined;\n }\n\n /** Encodes each physical array element once. */\n mapToDbValue(value: unknown): unknown {\n return value !== undefined\n ? this.isArray\n ? (value as readonly unknown[]).map((element) => this.mapper.toDb(element))\n : this.mapper.toDb(value)\n : undefined;\n }\n\n mapToRow(value: any): any {\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any): any {\n return value === null\n ? value\n : this.isArray\n ? value.map((element: unknown) => this.mapper.toDb(element))\n : this.mapper.toDb(value);\n }\n\n /** Converts a driver value with the custom mapper, including array elements. */\n mapFromDb(value: unknown): unknown {\n const dbValue = maybeNullToUndefined(value);\n return dbValue !== undefined\n ? this.isArray\n ? dbValue.map((value: unknown) => this.mapper.fromDb(value))\n : this.mapper.fromDb(dbValue)\n : undefined;\n }\n\n mapFromJsonAgg(value: any): any {\n // Assume the database JSON value matches the ResultSet value\n return value;\n // return value === null\n // ? value\n // : this.isArray\n // ? value.map((value: any) => this.mapper.fromDb(value))\n // : this.mapper.fromDb(value);\n }\n}\n\n/**\n * Supports `string`, `int`, etc., as well as `string[]`, `int[]`, etc.\n *\n * This is not generally meant for subclassing, because it assumes things like\n * `string[]`s can be mapped 1:1. See `CustomSerdeAdapter` a good base class\n * that will handle converting individual elements.\n */\nexport class PrimitiveSerde implements ScalarCodec {\n constructor(\n public dbType: string,\n public isArray = false,\n ) {}\n\n /** Exact-class checks prevent an unknown subclass's overridden converters from sharing this codec. */\n get outputType(): TypeInfo | undefined {\n if (this.constructor !== PrimitiveSerde) return undefined;\n const dbType = canonicalDbType(this.dbType);\n const elementType = dbType.endsWith(\"[]\") ? dbType.slice(0, -2) : dbType;\n if (this.isArray !== dbType.endsWith(\"[]\")) return undefined;\n const outputType = {\n dbType: elementType,\n domain: primitiveOutputDomain(elementType),\n arrayElementSafe: elementType !== \"numeric\",\n };\n return this.isArray ? arrayOutputType(outputType) : outputType;\n }\n\n /** Primitive writes share their scalar/filter conversion, including subclass overrides. */\n mapToDbValue(value: unknown): unknown {\n return this.mapToDb(value);\n }\n\n mapToRow(value: any): any {\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any) {\n return value;\n }\n\n /** Keeps driver values as-is, with SQL NULL represented as an unset entity field. */\n mapFromDb(value: unknown): unknown {\n return maybeNullToUndefined(value);\n }\n\n mapFromJsonAgg(value: any): any {\n return value;\n }\n}\n\nexport class DateSerde extends PrimitiveSerde implements TimestampCodec<Date> {\n /** Date bindings use ISO strings; mapToDb does not support physical Date arrays. */\n get outputType(): TypeInfo | undefined {\n return this.constructor === DateSerde && !this.isArray && !this.dbType.endsWith(\"[]\")\n ? { dbType: canonicalDbType(this.dbType), domain: DateSerde }\n : undefined;\n }\n\n /** Accept the caller's date as-is. */\n mapFromNow(now: Date): Date {\n return now;\n }\n\n mapFromJsonAgg(value: any): any {\n if (value === null) return value;\n return new Date(value);\n }\n\n /**\n * Returns the `Date` a driver hands back on a read, and not `mapToDb`'s ISO string.\n *\n * Otherwise callers that round-trip a row through `rowValue` and back through `fromRow` (i.e.\n * `RunPlugin` mirroring writes into the test em) turn every date into a string, because our\n * `mapFromDb` returns the row value as-is.\n */\n mapToRow(value: any): any {\n return value;\n }\n\n mapToDb(value: Date) {\n // bun.sql needs this, node-pg does it out of the box\n return value?.toISOString();\n }\n}\n\n/** Converts `DATE`s `Temporal.PlainDate`s. */\nexport class PlainDateSerde extends CustomSerdeAdapter {\n constructor(dbType: string, isArray = false) {\n super(dbType, plainDateMapper, isArray);\n }\n}\n\n/** Converts `TIME`s to `Temporal.PlainTime`s. */\nexport class PlainTimeSerde extends CustomSerdeAdapter {\n constructor(dbType: string, isArray = false) {\n super(dbType, plainTimeMapper, isArray);\n }\n}\n\n/** Converts `TIMESTAMP`s to `Temporal.PlainDateTime`s. */\nexport class PlainDateTimeSerde extends CustomSerdeAdapter implements TimestampCodec<Temporal.PlainDateTime> {\n constructor(dbType: string, isArray = false) {\n super(dbType, plainDateTimeMapper, isArray);\n }\n\n mapFromNow(now: Date): Temporal.PlainDateTime {\n const { timeZone } = getRuntimeConfig().temporal as any;\n return requireTemporal().toTemporalInstant.call(now).toZonedDateTimeISO(timeZone).toPlainDateTime();\n }\n}\n\n/** Converts `TIMESTAMP WITH TIME ZONE`s to `Temporal.ZonedDateTime`s. */\nexport class ZonedDateTimeSerde extends CustomSerdeAdapter implements TimestampCodec<Temporal.ZonedDateTime> {\n constructor(dbType: string, isArray = false) {\n super(dbType, zonedDateTimeMapper, isArray);\n }\n\n mapFromNow(now: Date): Temporal.ZonedDateTime {\n const { timeZone } = getRuntimeConfig().temporal as any;\n return requireTemporal().toTemporalInstant.call(now).toZonedDateTimeISO(timeZone);\n }\n}\n\nexport class BigIntSerde implements ScalarCodec {\n dbType: string;\n\n constructor(public isArray = false) {\n this.dbType = isArray ? \"bigint[]\" : \"bigint\";\n }\n\n /** BigInt conversion is distinct from both the driver's int8 value and Number aggregates. */\n get outputType(): TypeInfo | undefined {\n if (this.constructor !== BigIntSerde) return undefined;\n const elementType = { dbType: \"int8\", domain: BigIntSerde, arrayElementSafe: true };\n return this.isArray ? arrayOutputType(elementType) : elementType;\n }\n\n /** Drivers accept native bigint values without conversion. */\n mapToDbValue(value: unknown): unknown {\n if (this.isArray) assertFlatNumericArray(value);\n return value;\n }\n\n mapToRow(value: any): any {\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any) {\n return value;\n }\n\n /** Converts the driver's bigint representation to the entity value. */\n mapFromDb(value: unknown): unknown {\n const dbValue = maybeNullToUndefined(value);\n if (this.isArray && dbValue !== undefined) {\n assertFlatNumericArray(dbValue);\n return dbValue.map((element: string | bigint | number | null) => (element === null ? null : BigInt(element)));\n }\n return dbValue ? BigInt(dbValue) : dbValue;\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : this.isArray ? this.mapFromDb(value) : BigInt(value);\n }\n}\n\n/**\n * Maps `decimal(...)` database types to the JS `number`.\n *\n * Note that we assume the db values are within the range of the JS `number`;\n * we should eventually sanity check that.\n *\n * Also note that knex/pg accept `number`s as input, so we only need\n * to handle from-database -> to JS translation.\n */\nexport class DecimalToNumberSerde implements ScalarCodec {\n dbType: string;\n\n constructor(public isArray = false) {\n this.dbType = isArray ? \"numeric[]\" : \"decimal\";\n }\n\n /** Numeric aggregates use the same Number conversion and identity binding encoder. */\n get outputType(): TypeInfo | undefined {\n if (this.constructor !== DecimalToNumberSerde) return undefined;\n const elementType = { dbType: \"numeric\", domain: Number, arrayElementSafe: true };\n return this.isArray ? arrayOutputType(elementType) : elementType;\n }\n\n /** Drivers accept decimal numbers without conversion. */\n mapToDbValue(value: unknown): unknown {\n if (this.isArray) assertFlatNumericArray(value);\n return value;\n }\n\n mapToRow(value: any): any {\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any) {\n return value;\n }\n\n /** Converts a driver decimal value to a JavaScript number. */\n mapFromDb(value: unknown): unknown {\n const dbValue = maybeNullToUndefined(value);\n if (this.isArray && dbValue !== undefined) {\n assertFlatNumericArray(dbValue);\n return dbValue.map((element: string | number | null) => (element === null ? null : Number(element)));\n }\n return dbValue !== undefined ? Number(dbValue) : dbValue;\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : this.isArray ? this.mapFromDb(value) : Number(value);\n }\n}\n\n/** Maps physical integer keys to logical string IDs \"because GraphQL\". */\nexport class KeySerde implements ScalarCodec {\n isArray = false;\n\n private meta: {\n tagName: string;\n idDbType: \"bigint\" | \"int\" | \"uuid\" | \"text\";\n };\n\n constructor(\n tagName: string,\n public dbType: \"bigint\" | \"int\" | \"uuid\" | \"text\",\n ) {\n this.meta = {\n tagName,\n idDbType: dbType,\n };\n }\n\n /** PKs and FKs share a tag and SQL representation; the alias supplies the exact target idMeta. */\n get outputType(): TypeInfo | undefined {\n return this.constructor === KeySerde && !this.isArray\n ? { dbType: canonicalDbType(this.dbType), domain: `key:${this.meta.tagName}`, arrayElementSafe: true }\n : undefined;\n }\n\n /** Resolves references and tagged, untagged, or numeric ids using the column's tag and storage type. */\n mapToDbValue(value: unknown): unknown {\n return keyToNumber(\n this.meta,\n typeof value === \"number\"\n ? value\n : maybeResolveReferenceToId(value as Parameters<typeof maybeResolveReferenceToId>[0]),\n );\n }\n\n mapToRow(value: any): any {\n // we don't have any fixups since we are trying to recreate what comes out of the db, so this is safe\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any) {\n // Numeric IDs are already database values; tagged string IDs still need to be resolved and untagged.\n if (value === null || typeof value === \"number\") return value;\n // We go through `maybeResolveReferenceToId` because filters like `in: [a1, a2]` pass entities directly.\n return keyToNumber(this.meta, maybeResolveReferenceToId(value));\n }\n\n /** Converts a physical primary or foreign key to a tagged id. */\n mapFromDb(value: unknown): string | undefined {\n return keyToTaggedId(this.meta, value as string | number);\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : value;\n }\n}\n\nexport class EnumFieldSerde implements ScalarCodec {\n isArray = false;\n\n constructor(\n public dbType: \"int\" | \"uuid\",\n private enumObject: any,\n ) {}\n\n /** Separate fields of the same generated enum share its code/id mapping. */\n get outputType(): TypeInfo | undefined {\n return this.constructor === EnumFieldSerde && !this.isArray\n ? { dbType: canonicalDbType(this.dbType), domain: this.enumObject, arrayElementSafe: true }\n : undefined;\n }\n\n /** Resolves the enum code to its stored id, leaving an unknown code unset. */\n mapToDbValue(value: unknown): unknown {\n return this.enumObject.findByCode(value)?.id;\n }\n\n mapToRow(value: any): any {\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any) {\n return this.enumObject.findByCode(value)?.id;\n }\n\n /** Converts a stored enum id to its enum code. */\n mapFromDb(value: unknown): unknown {\n return this.enumObject.findById(value)?.code;\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : value;\n }\n}\n\nexport class EnumArrayFieldSerde implements ScalarCodec {\n isArray = true;\n\n constructor(\n public dbType: \"int[]\" | \"uuid[]\",\n private enumObject: any,\n ) {}\n\n /** Physical enum arrays reject null elements, unlike scalar enum arrayAgg; leave them unknown. */\n get outputType(): undefined {\n return undefined;\n }\n\n /** Resolves each enum code to its stored id, retaining the entity's empty-array default. */\n mapToDbValue(value: unknown): unknown {\n return (value as readonly unknown[] | null | undefined)?.map((code) => this.enumObject.getByCode(code).id) || [];\n }\n\n mapToRow(value: any): any {\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any) {\n return !value ? [] : value.map((code: any) => this.enumObject.getByCode(code).id);\n }\n\n /** Converts stored enum ids to codes, defaulting an unset entity field to an empty array. */\n mapFromDb(value: unknown): unknown[] {\n return (value as readonly unknown[] | null | undefined)?.map((id) => this.enumObject.findById(id).code) || [];\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : value;\n }\n}\n\n/** Similar to SimpleSerde, but applies the superstruct `assert` function when reading values from the db. */\nexport class SuperstructSerde implements ScalarCodec {\n dbType = \"jsonb\";\n isArray = false;\n\n // Use a dynamic require so that downstream projects don't have to depend on superstruct\n // until they want to, i.e. we don't have superstruct in the joist-orm package.json.\n private assert = runtimeRequire(\"superstruct\").assert;\n\n constructor(private superstruct: any) {}\n\n /** JSON schemas describe a jsonb value, even when that value is a JSON array. */\n get outputType(): TypeInfo | undefined {\n return this.constructor === SuperstructSerde && !this.isArray\n ? { dbType: canonicalDbType(this.dbType), domain: this.superstruct, arrayElementSafe: true }\n : undefined;\n }\n\n /** Serializes the domain JSON value without running the read-time schema validation. */\n mapToDbValue(value: unknown): unknown {\n return JSON.stringify(value);\n }\n\n // JSON is returned by postgres already parsed, so we should just be able to return our data directly. Unlike with\n // JsonSerde, we can assume that superstruct would have parsed any complex types in the json correctly so we don't\n // need to do a round trip through JSON.stringify.\n mapToRow(value: any): any {\n return value;\n }\n\n mapToDb(value: any) {\n return JSON.stringify(value);\n }\n\n /** Validates a driver JSON value with the field's Superstruct schema. */\n mapFromDb(value: unknown): unknown {\n const dbValue = maybeNullToUndefined(value);\n if (dbValue) this.assert(dbValue, this.superstruct);\n return dbValue;\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : value;\n }\n}\n\nexport class JsonSerde implements ScalarCodec {\n dbType = \"jsonb\";\n isArray = false;\n\n constructor() {}\n\n /** Unvalidated JSON uses its own encoder, not a primitive or schema-specific codec. */\n get outputType(): TypeInfo | undefined {\n return this.constructor === JsonSerde && !this.isArray\n ? { dbType: canonicalDbType(this.dbType), domain: JsonSerde, arrayElementSafe: true }\n : undefined;\n }\n\n /** Serializes the whole JSON value, including JSON arrays and custom toJSON methods. */\n mapToDbValue(value: unknown): unknown {\n return JSON.stringify(value);\n }\n\n // JSON is returned by postgres already parsed, so if we are trying to recreate then we need to stringify, then parse.\n // It's necessary to do this instead of just returning the object directly because any complex types in the json need\n // to be stringified to correctly reflect the db value.\n mapToRow(value: any): any {\n const json = JSON.stringify(value);\n return isDefined(json) ? JSON.parse(json) : undefined;\n }\n\n mapToDb(value: any) {\n return JSON.stringify(value);\n }\n\n /** Keeps the driver's parsed JSON value, normalizing SQL NULL for entity fields. */\n mapFromDb(value: unknown): unknown {\n return maybeNullToUndefined(value);\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : value;\n }\n}\n\n/** Similar to SimpleSerde, but applies the zod's `parse` function when reading values from the db. */\nexport class ZodSerde implements ScalarCodec {\n dbType = \"jsonb\";\n isArray = false;\n\n constructor(private zodSchema: any) {}\n\n /** Parsing and transformations are compatible only for the same schema object. */\n get outputType(): TypeInfo | undefined {\n return this.constructor === ZodSerde && !this.isArray\n ? { dbType: canonicalDbType(this.dbType), domain: this.zodSchema, arrayElementSafe: true }\n : undefined;\n }\n\n /** Serializes the domain JSON value without running the read-time Zod parser or transforms. */\n mapToDbValue(value: unknown): unknown {\n return JSON.stringify(value);\n }\n\n // JSON is returned by postgres already parsed, so we should just be able to return our data directly. Unlike with\n // JsonSerde, we can assume that zod would have parsed any complex types in the json correctly so we don't need to\n // do a round trip through JSON.stringify.\n mapToRow(value: any): any {\n return value;\n }\n\n mapToDb(value: any) {\n return JSON.stringify(value);\n }\n\n /** Parses a driver JSON value with the field's Zod schema. */\n mapFromDb(value: unknown): unknown {\n const dbValue = maybeNullToUndefined(value);\n return dbValue ? this.zodSchema.parse(dbValue) : dbValue;\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : value;\n }\n}\n\n/** PostgreSQL does not enforce declared array dimensions; reject nested values rather than coercing subarrays. */\nfunction assertFlatNumericArray(value: unknown): void {\n if (Array.isArray(value) && value.some(Array.isArray)) {\n throw new Error(\"Native numeric arrays must be one-dimensional\");\n }\n}\n\n/** Only driver-native numbers agree with Number aggregates; int8/numeric identity values do not. */\nfunction primitiveOutputDomain(dbType: string): unknown {\n switch (dbType) {\n case \"int2\":\n case \"int4\":\n case \"float4\":\n case \"float8\":\n return Number;\n case \"text\":\n case \"varchar\":\n case \"bpchar\":\n return String;\n default:\n return PrimitiveSerde;\n }\n}\n\n/** Normalizes SQL NULL to an unset entity field. */\nfunction maybeNullToUndefined(value: any): any {\n return value === null ? undefined : value;\n}\n"],"mappings":";;;;;;;;AAcA,MAAM,iBAAiB,cAAc,YAAY,GAAG;AA+CpD,IAAa,qBAAb,MAAa,mBAA0C;CAI5C;CACC;CAJV,UAAmB;CAEnB,YACE,QACA,QACA,SACA;EAHO,KAAA,SAAA;EACC,KAAA,SAAA;EAGR,IAAI,YAAY,KAAA,GAAW,KAAK,UAAU;CAC5C;;CAGA,IA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M,OAAO,GAClD,MAAM,IAAI,MAAM,+CAA+C;AAEnE;;AAGA,SAAS,sBAAsB,QAAyB;CACtD,QAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,UACH,OAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK,UACH,OAAO;EACT,SACE,OAAO;CACX;AACF;;AAGA,SAAS,qBAAqB,OAAiB;CAC7C,OAAO,UAAU,OAAO,KAAA,IAAY;AACtC"}
1
+ {"version":3,"file":"serde.js","names":[],"sources":["../../src/serde/serde.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { isDefined } from \"src/EntityManager.ts\";\nimport { keyToNumber, keyToTaggedId, maybeResolveReferenceToId } from \"src/keys.ts\";\nimport { getRuntimeConfig } from \"src/runtimeConfig.ts\";\nimport { type Temporal, requireTemporal } from \"src/serde/temporal.ts\";\nimport {\n plainDateMapper,\n plainDateTimeMapper,\n plainTimeMapper,\n zonedDateTimeMapper,\n} from \"src/serde/temporalMappers.ts\";\nimport { type TypeInfo, arrayOutputType, canonicalDbType } from \"src/serde/TypeInfo.ts\";\n\nconst runtimeRequire = createRequire(import.meta.url);\n\n/** Scalar conversion only: no field names, entity hydration, or FK fixups. */\nexport interface ScalarCodec {\n dbType: string;\n isArray: boolean;\n /** The unnest null/set marker as the physical db type; never persisted in the column. */\n readonly notNullMarker?: unknown;\n /** Compatibility evidence for scalar conversion, absent for unknown codecs. */\n readonly outputType?: TypeInfo;\n /** Encodes a domain value for a filter, i.e. an em.find WHERE parameter. */\n mapToDb(value: any): any;\n /**\n * Encodes a domain value for an INSERT or UPDATE binding.\n *\n * Callers must handle omission, SQL NULL, and SQL expressions before encoding. JSON null and\n * codec defaults can differ from SQL NULL. Direct mutations must validate reference targets\n * and reject new or unflushed entities before encoding.\n */\n mapToDbValue?(value: unknown): unknown;\n /** Converts a driver value to its domain value, including the codec's null/default handling. */\n mapFromDb(value: unknown): unknown;\n /**\n * Converts a json_agg cell to a driver-row value, not a domain value.\n *\n * Lazy field hydration subsequently calls mapFromDb. I.e. Date codecs reconstruct a Date\n * from the JSON string, while Temporal codecs retain the driver's string representation.\n */\n mapFromJsonAgg(value: any): any;\n /** Reconstructs a driver value from a domain value, not a SQL binding. */\n mapToRow(value: any): any;\n}\n\n/** Converts the ORM clock to the timestamp's domain representation. */\nexport interface TimestampCodec<T> extends ScalarCodec {\n mapFromNow(now: Date): T;\n}\n\n/**\n * Provides a simplified, public API for mapping between db/domain values.\n *\n * Joist's internal `FieldSerde` API is admittedly a little crufty, and so this\n * API is intended to be a simpler, more user-friendly way to define custom types.\n */\nexport interface CustomSerde<DomainType, DbType> {\n toDb(value: DomainType): DbType;\n fromDb(value: DbType): DomainType;\n /**\n * Return a domain value for the unnest null/set marker, before conversion to the physical db type.\n *\n * Optional to preserve legacy serdes, including scalar serdes that never need markers.\n * Without this hook, the adapter passes a default physical db value through fromDb, then converts it\n * back with the normal array writer. Temporal mappers and restricted custom domains can provide an\n * accepted domain value instead.\n */\n getUnnestMarker?(): DomainType;\n}\n\nexport class CustomSerdeAdapter implements ScalarCodec {\n isArray: boolean = false;\n\n constructor(\n public dbType: string,\n private mapper: CustomSerde<any, any>,\n isArray?: boolean,\n ) {\n if (isArray !== undefined) this.isArray = isArray;\n }\n\n /** Return the unnest null/set marker as the physical db type. */\n get notNullMarker(): unknown {\n const seed = this.mapper.getUnnestMarker\n ? this.mapper.getUnnestMarker()\n : this.mapper.fromDb(defaultArrayElementMarker(this.dbType));\n return (this.mapToDbValue([seed]) as unknown[])[0];\n }\n\n /** Only known adapters share their mapper's identity and elementwise array conversion. */\n get outputType(): TypeInfo | undefined {\n if (\n this.isArray !== this.dbType.endsWith(\"[]\") ||\n (this.constructor !== CustomSerdeAdapter &&\n this.constructor !== PlainDateSerde &&\n this.constructor !== PlainTimeSerde &&\n this.constructor !== PlainDateTimeSerde &&\n this.constructor !== ZonedDateTimeSerde)\n ) {\n return undefined;\n }\n const dbType = canonicalDbType(this.dbType);\n // A numeric mapper may require scalar text; classic pg decodes numeric[] elements as numbers.\n const elementType = this.isArray ? dbType.slice(0, -2) : dbType;\n const outputType = { dbType: elementType, domain: this.mapper, arrayElementSafe: elementType !== \"numeric\" };\n if (!this.isArray) return outputType;\n // Physical arrays pass null elements to the mapper, unlike scalar arrayAgg; keep their domains distinct.\n return arrayOutputType(outputType) || [\"date\", \"time\", \"timestamp\", \"timestamptz\"].includes(elementType)\n ? { dbType, domain: this.mapper }\n : undefined;\n }\n\n /** Encodes each physical array element once. */\n mapToDbValue(value: unknown): unknown {\n return value !== undefined\n ? this.isArray\n ? (value as readonly unknown[]).map((element) => this.mapper.toDb(element))\n : this.mapper.toDb(value)\n : undefined;\n }\n\n mapToRow(value: any): any {\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any): any {\n return value === null\n ? value\n : this.isArray\n ? value.map((element: unknown) => this.mapper.toDb(element))\n : this.mapper.toDb(value);\n }\n\n /** Converts a driver value with the custom mapper, including array elements. */\n mapFromDb(value: unknown): unknown {\n const dbValue = maybeNullToUndefined(value);\n return dbValue !== undefined\n ? this.isArray\n ? dbValue.map((value: unknown) => this.mapper.fromDb(value))\n : this.mapper.fromDb(dbValue)\n : undefined;\n }\n\n mapFromJsonAgg(value: any): any {\n // Assume the database JSON value matches the ResultSet value\n return value;\n // return value === null\n // ? value\n // : this.isArray\n // ? value.map((value: any) => this.mapper.fromDb(value))\n // : this.mapper.fromDb(value);\n }\n}\n\n/**\n * Supports `string`, `int`, etc., as well as `string[]`, `int[]`, etc.\n *\n * This is not generally meant for subclassing, because it assumes things like\n * `string[]`s can be mapped 1:1. See `CustomSerdeAdapter` a good base class\n * that will handle converting individual elements.\n */\nexport class PrimitiveSerde implements ScalarCodec {\n constructor(\n public dbType: string,\n public isArray = false,\n ) {}\n\n /** Return the unnest null/set marker as the physical db type. */\n get notNullMarker(): unknown {\n const seed = defaultArrayElementMarker(this.dbType);\n return this.isArray ? (this.mapToDbValue([seed]) as unknown[])[0] : this.mapToDbValue(seed);\n }\n\n /** Exact-class checks prevent an unknown subclass's overridden converters from sharing this codec. */\n get outputType(): TypeInfo | undefined {\n if (this.constructor !== PrimitiveSerde) return undefined;\n const dbType = canonicalDbType(this.dbType);\n const elementType = dbType.endsWith(\"[]\") ? dbType.slice(0, -2) : dbType;\n if (this.isArray !== dbType.endsWith(\"[]\")) return undefined;\n const outputType = {\n dbType: elementType,\n domain: primitiveOutputDomain(elementType),\n arrayElementSafe: elementType !== \"numeric\",\n };\n return this.isArray ? arrayOutputType(outputType) : outputType;\n }\n\n /** Primitive writes share their scalar/filter conversion, including subclass overrides. */\n mapToDbValue(value: unknown): unknown {\n return this.mapToDb(value);\n }\n\n mapToRow(value: any): any {\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any) {\n return value;\n }\n\n /** Keeps driver values as-is, with SQL NULL represented as an unset entity field. */\n mapFromDb(value: unknown): unknown {\n return maybeNullToUndefined(value);\n }\n\n mapFromJsonAgg(value: any): any {\n return value;\n }\n}\n\nexport class DateSerde extends PrimitiveSerde implements TimestampCodec<Date> {\n /** Date bindings use ISO strings; mapToDb does not support physical Date arrays. */\n get outputType(): TypeInfo | undefined {\n return this.constructor === DateSerde && !this.isArray && !this.dbType.endsWith(\"[]\")\n ? { dbType: canonicalDbType(this.dbType), domain: DateSerde }\n : undefined;\n }\n\n /** Accept the caller's date as-is. */\n mapFromNow(now: Date): Date {\n return now;\n }\n\n mapFromJsonAgg(value: any): any {\n if (value === null) return value;\n return new Date(value);\n }\n\n /**\n * Returns the `Date` a driver hands back on a read, and not `mapToDb`'s ISO string.\n *\n * Otherwise callers that round-trip a row through `rowValue` and back through `fromRow` (i.e.\n * `RunPlugin` mirroring writes into the test em) turn every date into a string, because our\n * `mapFromDb` returns the row value as-is.\n */\n mapToRow(value: any): any {\n return value;\n }\n\n mapToDb(value: Date) {\n // bun.sql needs this, node-pg does it out of the box\n return value?.toISOString();\n }\n}\n\n/** Converts `DATE`s `Temporal.PlainDate`s. */\nexport class PlainDateSerde extends CustomSerdeAdapter {\n constructor(dbType: string, isArray = false) {\n super(dbType, plainDateMapper, isArray);\n }\n}\n\n/** Converts `TIME`s to `Temporal.PlainTime`s. */\nexport class PlainTimeSerde extends CustomSerdeAdapter {\n constructor(dbType: string, isArray = false) {\n super(dbType, plainTimeMapper, isArray);\n }\n}\n\n/** Converts `TIMESTAMP`s to `Temporal.PlainDateTime`s. */\nexport class PlainDateTimeSerde extends CustomSerdeAdapter implements TimestampCodec<Temporal.PlainDateTime> {\n constructor(dbType: string, isArray = false) {\n super(dbType, plainDateTimeMapper, isArray);\n }\n\n mapFromNow(now: Date): Temporal.PlainDateTime {\n const { timeZone } = getRuntimeConfig().temporal as any;\n return requireTemporal().toTemporalInstant.call(now).toZonedDateTimeISO(timeZone).toPlainDateTime();\n }\n}\n\n/** Converts `TIMESTAMP WITH TIME ZONE`s to `Temporal.ZonedDateTime`s. */\nexport class ZonedDateTimeSerde extends CustomSerdeAdapter implements TimestampCodec<Temporal.ZonedDateTime> {\n constructor(dbType: string, isArray = false) {\n super(dbType, zonedDateTimeMapper, isArray);\n }\n\n mapFromNow(now: Date): Temporal.ZonedDateTime {\n const { timeZone } = getRuntimeConfig().temporal as any;\n return requireTemporal().toTemporalInstant.call(now).toZonedDateTimeISO(timeZone);\n }\n}\n\nexport class BigIntSerde implements ScalarCodec {\n dbType: string;\n\n constructor(public isArray = false) {\n this.dbType = isArray ? \"bigint[]\" : \"bigint\";\n }\n\n /** BigInt conversion is distinct from both the driver's int8 value and Number aggregates. */\n get outputType(): TypeInfo | undefined {\n if (this.constructor !== BigIntSerde) return undefined;\n const elementType = { dbType: \"int8\", domain: BigIntSerde, arrayElementSafe: true };\n return this.isArray ? arrayOutputType(elementType) : elementType;\n }\n\n /** Drivers accept native bigint values without conversion. */\n mapToDbValue(value: unknown): unknown {\n if (this.isArray) assertFlatNumericArray(value);\n return value;\n }\n\n mapToRow(value: any): any {\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any) {\n return value;\n }\n\n /** Converts the driver's bigint representation to the entity value. */\n mapFromDb(value: unknown): unknown {\n const dbValue = maybeNullToUndefined(value);\n if (this.isArray && dbValue !== undefined) {\n assertFlatNumericArray(dbValue);\n return dbValue.map((element: string | bigint | number | null) => (element === null ? null : BigInt(element)));\n }\n return dbValue ? BigInt(dbValue) : dbValue;\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : this.isArray ? this.mapFromDb(value) : BigInt(value);\n }\n}\n\n/**\n * Maps `decimal(...)` database types to the JS `number`.\n *\n * Note that we assume the db values are within the range of the JS `number`;\n * we should eventually sanity check that.\n *\n * Also note that knex/pg accept `number`s as input, so we only need\n * to handle from-database -> to JS translation.\n */\nexport class DecimalToNumberSerde implements ScalarCodec {\n dbType: string;\n\n constructor(public isArray = false) {\n this.dbType = isArray ? \"numeric[]\" : \"decimal\";\n }\n\n /** Numeric aggregates use the same Number conversion and identity binding encoder. */\n get outputType(): TypeInfo | undefined {\n if (this.constructor !== DecimalToNumberSerde) return undefined;\n const elementType = { dbType: \"numeric\", domain: Number, arrayElementSafe: true };\n return this.isArray ? arrayOutputType(elementType) : elementType;\n }\n\n /** Drivers accept decimal numbers without conversion. */\n mapToDbValue(value: unknown): unknown {\n if (this.isArray) assertFlatNumericArray(value);\n return value;\n }\n\n mapToRow(value: any): any {\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any) {\n return value;\n }\n\n /** Converts a driver decimal value to a JavaScript number. */\n mapFromDb(value: unknown): unknown {\n const dbValue = maybeNullToUndefined(value);\n if (this.isArray && dbValue !== undefined) {\n assertFlatNumericArray(dbValue);\n return dbValue.map((element: string | number | null) => (element === null ? null : Number(element)));\n }\n return dbValue !== undefined ? Number(dbValue) : dbValue;\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : this.isArray ? this.mapFromDb(value) : Number(value);\n }\n}\n\n/** Maps physical integer keys to logical string IDs \"because GraphQL\". */\nexport class KeySerde implements ScalarCodec {\n isArray = false;\n\n private meta: {\n tagName: string;\n idDbType: \"bigint\" | \"int\" | \"uuid\" | \"text\";\n };\n\n constructor(\n tagName: string,\n public dbType: \"bigint\" | \"int\" | \"uuid\" | \"text\",\n ) {\n this.meta = {\n tagName,\n idDbType: dbType,\n };\n }\n\n /** PKs and FKs share a tag and SQL representation; the alias supplies the exact target idMeta. */\n get outputType(): TypeInfo | undefined {\n return this.constructor === KeySerde && !this.isArray\n ? { dbType: canonicalDbType(this.dbType), domain: `key:${this.meta.tagName}`, arrayElementSafe: true }\n : undefined;\n }\n\n /** Resolves references and tagged, untagged, or numeric ids using the column's tag and storage type. */\n mapToDbValue(value: unknown): unknown {\n return keyToNumber(\n this.meta,\n typeof value === \"number\"\n ? value\n : maybeResolveReferenceToId(value as Parameters<typeof maybeResolveReferenceToId>[0]),\n );\n }\n\n mapToRow(value: any): any {\n // we don't have any fixups since we are trying to recreate what comes out of the db, so this is safe\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any) {\n // Numeric IDs are already database values; tagged string IDs still need to be resolved and untagged.\n if (value === null || typeof value === \"number\") return value;\n // We go through `maybeResolveReferenceToId` because filters like `in: [a1, a2]` pass entities directly.\n return keyToNumber(this.meta, maybeResolveReferenceToId(value));\n }\n\n /** Converts a physical primary or foreign key to a tagged id. */\n mapFromDb(value: unknown): string | undefined {\n return keyToTaggedId(this.meta, value as string | number);\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : value;\n }\n}\n\nexport class EnumFieldSerde implements ScalarCodec {\n isArray = false;\n\n constructor(\n public dbType: \"int\" | \"uuid\",\n private enumObject: any,\n ) {}\n\n /** Separate fields of the same generated enum share its code/id mapping. */\n get outputType(): TypeInfo | undefined {\n return this.constructor === EnumFieldSerde && !this.isArray\n ? { dbType: canonicalDbType(this.dbType), domain: this.enumObject, arrayElementSafe: true }\n : undefined;\n }\n\n /** Resolves the enum code to its stored id, leaving an unknown code unset. */\n mapToDbValue(value: unknown): unknown {\n return this.enumObject.findByCode(value)?.id;\n }\n\n mapToRow(value: any): any {\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any) {\n return this.enumObject.findByCode(value)?.id;\n }\n\n /** Converts a stored enum id to its enum code. */\n mapFromDb(value: unknown): unknown {\n return this.enumObject.findById(value)?.code;\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : value;\n }\n}\n\nexport class EnumArrayFieldSerde implements ScalarCodec {\n isArray = true;\n\n constructor(\n public dbType: \"int[]\" | \"uuid[]\",\n private enumObject: any,\n ) {}\n\n /**\n * Return the unnest null/set marker as the physical db type.\n *\n * The marker is removed before enum IDs are stored, so it need not identify an enum row.\n */\n get notNullMarker(): unknown {\n return defaultArrayElementMarker(this.dbType);\n }\n\n /** Physical enum arrays reject null elements, unlike scalar enum arrayAgg; leave them unknown. */\n get outputType(): undefined {\n return undefined;\n }\n\n /** Resolves each enum code to its stored id, retaining the entity's empty-array default. */\n mapToDbValue(value: unknown): unknown {\n return (value as readonly unknown[] | null | undefined)?.map((code) => this.enumObject.getByCode(code).id) || [];\n }\n\n mapToRow(value: any): any {\n return this.mapToDbValue(value);\n }\n\n mapToDb(value: any) {\n return !value ? [] : value.map((code: any) => this.enumObject.getByCode(code).id);\n }\n\n /** Converts stored enum ids to codes, defaulting an unset entity field to an empty array. */\n mapFromDb(value: unknown): unknown[] {\n return (value as readonly unknown[] | null | undefined)?.map((id) => this.enumObject.findById(id).code) || [];\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : value;\n }\n}\n\n/** Similar to SimpleSerde, but applies the superstruct `assert` function when reading values from the db. */\nexport class SuperstructSerde implements ScalarCodec {\n dbType = \"jsonb\";\n isArray = false;\n\n // Use a dynamic require so that downstream projects don't have to depend on superstruct\n // until they want to, i.e. we don't have superstruct in the joist-orm package.json.\n private assert = runtimeRequire(\"superstruct\").assert;\n\n constructor(private superstruct: any) {}\n\n /** JSON schemas describe a jsonb value, even when that value is a JSON array. */\n get outputType(): TypeInfo | undefined {\n return this.constructor === SuperstructSerde && !this.isArray\n ? { dbType: canonicalDbType(this.dbType), domain: this.superstruct, arrayElementSafe: true }\n : undefined;\n }\n\n /** Serializes the domain JSON value without running the read-time schema validation. */\n mapToDbValue(value: unknown): unknown {\n return JSON.stringify(value);\n }\n\n // JSON is returned by postgres already parsed, so we should just be able to return our data directly. Unlike with\n // JsonSerde, we can assume that superstruct would have parsed any complex types in the json correctly so we don't\n // need to do a round trip through JSON.stringify.\n mapToRow(value: any): any {\n return value;\n }\n\n mapToDb(value: any) {\n return JSON.stringify(value);\n }\n\n /** Validates a driver JSON value with the field's Superstruct schema. */\n mapFromDb(value: unknown): unknown {\n const dbValue = maybeNullToUndefined(value);\n if (dbValue) this.assert(dbValue, this.superstruct);\n return dbValue;\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : value;\n }\n}\n\nexport class JsonSerde implements ScalarCodec {\n dbType = \"jsonb\";\n isArray = false;\n\n constructor() {}\n\n /** Unvalidated JSON uses its own encoder, not a primitive or schema-specific codec. */\n get outputType(): TypeInfo | undefined {\n return this.constructor === JsonSerde && !this.isArray\n ? { dbType: canonicalDbType(this.dbType), domain: JsonSerde, arrayElementSafe: true }\n : undefined;\n }\n\n /** Serializes the whole JSON value, including JSON arrays and custom toJSON methods. */\n mapToDbValue(value: unknown): unknown {\n return JSON.stringify(value);\n }\n\n // JSON is returned by postgres already parsed, so if we are trying to recreate then we need to stringify, then parse.\n // It's necessary to do this instead of just returning the object directly because any complex types in the json need\n // to be stringified to correctly reflect the db value.\n mapToRow(value: any): any {\n const json = JSON.stringify(value);\n return isDefined(json) ? JSON.parse(json) : undefined;\n }\n\n mapToDb(value: any) {\n return JSON.stringify(value);\n }\n\n /** Keeps the driver's parsed JSON value, normalizing SQL NULL for entity fields. */\n mapFromDb(value: unknown): unknown {\n return maybeNullToUndefined(value);\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : value;\n }\n}\n\n/**\n * Maps pgvector `vector(N)` columns to `number[]`s.\n *\n * pgvector has no pg array OID, so text results are its `[1,2,3]` literal, which is also valid\n * JSON (pgvector rejects NaN/Infinity elements). Writes send the same literal, which the batch\n * `unnest(?::vector[])` casts, because node-pg would otherwise encode a JS array as `{1,2,3}`.\n */\nexport class VectorSerde implements ScalarCodec {\n dbType = \"vector\";\n isArray = false;\n\n get outputType(): TypeInfo | undefined {\n return this.constructor === VectorSerde ? { dbType: this.dbType, domain: VectorSerde } : undefined;\n }\n\n mapToDbValue(value: unknown): unknown {\n return JSON.stringify(value);\n }\n\n mapToRow(value: any): any {\n return JSON.stringify(value);\n }\n\n mapToDb(value: any) {\n return value === null ? value : JSON.stringify(value);\n }\n\n /** Parses the text literal, and passes through arrays already decoded by the binary row path. */\n mapFromDb(value: unknown): unknown {\n return typeof value === \"string\" ? JSON.parse(value) : maybeNullToUndefined(value);\n }\n\n /** `to_json(vector)` falls back to the text literal, i.e. the same value as a driver row. */\n mapFromJsonAgg(value: any): any {\n return value;\n }\n}\n\n/** Similar to SimpleSerde, but applies the zod's `parse` function when reading values from the db. */\nexport class ZodSerde implements ScalarCodec {\n dbType = \"jsonb\";\n isArray = false;\n\n constructor(private zodSchema: any) {}\n\n /** Parsing and transformations are compatible only for the same schema object. */\n get outputType(): TypeInfo | undefined {\n return this.constructor === ZodSerde && !this.isArray\n ? { dbType: canonicalDbType(this.dbType), domain: this.zodSchema, arrayElementSafe: true }\n : undefined;\n }\n\n /** Serializes the domain JSON value without running the read-time Zod parser or transforms. */\n mapToDbValue(value: unknown): unknown {\n return JSON.stringify(value);\n }\n\n // JSON is returned by postgres already parsed, so we should just be able to return our data directly. Unlike with\n // JsonSerde, we can assume that zod would have parsed any complex types in the json correctly so we don't need to\n // do a round trip through JSON.stringify.\n mapToRow(value: any): any {\n return value;\n }\n\n mapToDb(value: any) {\n return JSON.stringify(value);\n }\n\n /** Parses a driver JSON value with the field's Zod schema. */\n mapFromDb(value: unknown): unknown {\n const dbValue = maybeNullToUndefined(value);\n return dbValue ? this.zodSchema.parse(dbValue) : dbValue;\n }\n\n mapFromJsonAgg(value: any): any {\n return value === null ? value : value;\n }\n}\n\n/** Return a default unnest null/set marker as the physical db type, before codec-specific conversion. */\nfunction defaultArrayElementMarker(dbType: string): unknown {\n if (dbType.startsWith(\"varchar\") || dbType.startsWith(\"character\") || dbType.startsWith(\"text\")) {\n return \"\";\n } else if (dbType.startsWith(\"int\")) {\n return 1;\n } else if (dbType.startsWith(\"date\") || dbType.startsWith(\"timestamp\")) {\n return new Date(\"2000-01-01T00:00:00.000Z\");\n } else {\n throw new Error(\"Unhandled nullable array column type \" + dbType);\n }\n}\n\n/** PostgreSQL does not enforce declared array dimensions; reject nested values rather than coercing subarrays. */\nfunction assertFlatNumericArray(value: unknown): void {\n if (Array.isArray(value) && value.some(Array.isArray)) {\n throw new Error(\"Native numeric arrays must be one-dimensional\");\n }\n}\n\n/** Only driver-native numbers agree with Number aggregates; int8/numeric identity values do not. */\nfunction primitiveOutputDomain(dbType: string): unknown {\n switch (dbType) {\n case \"int2\":\n case \"int4\":\n case \"float4\":\n case \"float8\":\n return Number;\n case \"text\":\n case \"varchar\":\n case \"bpchar\":\n return String;\n default:\n return PrimitiveSerde;\n }\n}\n\n/** Normalizes SQL NULL to an unset entity field. */\nfunction maybeNullToUndefined(value: any): any {\n return value === null ? undefined : value;\n}\n"],"mappings":";;;;;;;;AAcA,MAAM,iBAAiB,cAAc,YAAY,GAAG;AA0DpD,IAAa,qBAAb,MAAa,mBAA0C;CAI5C;CACC;CAJV,UAAmB;CAEnB,YACE,QACA,QACA,SACA;EAHO,KAAA,SAAA;EACC,KAAA,SAAA;EAGR,IAAI,YAAY,KAAA,GAAW,KAAK,UAAU;CAC5C;;CAGA,IAAI,gBAAyB;EAC3B,MAAM,OAAO,KAAK,OAAO,kBACrB,KAAK,OAAO,gBAAgB,IAC5B,KAAK,OAAO,OAAO,0BAA0B,KAAK,MAAM,CAAC;EAC7D,OAAQ,KAAK,aAAa,CAAC,IAAI,CAAC,CAAC,CAAe;CAClD;;CAGA,IAAI,aAAm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;AAGA,SAAS,qBAAqB,OAAiB;CAC7C,OAAO,UAAU,OAAO,KAAA,IAAY;AACtC"}
@@ -18,7 +18,7 @@ const Temporal = new Proxy({}, { get(_target, property, receiver) {
18
18
  return Reflect.get(requireTemporal().Temporal, property, receiver);
19
19
  } });
20
20
  /**
21
- * Conditionally/dynamically requires `temporal-polyfill`.
21
+ * Installs temporal-polyfill globally when native Temporal is unavailable.
22
22
  *
23
23
  * We want to avoid directly importing/requiring `temporal-polyfill` because
24
24
  * it will introduce the dependency to all users of Joist.
@@ -26,22 +26,17 @@ const Temporal = new Proxy({}, { get(_target, property, receiver) {
26
26
  function maybeRequireTemporal() {
27
27
  if (temporal === false) return void 0;
28
28
  if (temporal) return temporal;
29
- if ("Temporal" in global && "Intl" in global) {
29
+ if (typeof globalThis.Temporal === "undefined") try {
30
+ runtimeRequire("temporal-polyfill/global");
31
+ } catch (e) {}
32
+ if (typeof globalThis.Temporal !== "undefined") {
30
33
  temporal = {
31
- Temporal: global.Temporal,
34
+ Temporal: globalThis.Temporal,
32
35
  toTemporalInstant: Date.prototype.toTemporalInstant,
33
- Intl: global.Intl
36
+ Intl: globalThis.Intl
34
37
  };
35
38
  return temporal;
36
39
  }
37
- try {
38
- temporal = runtimeRequire("temporal-polyfill");
39
- return temporal;
40
- } catch (e) {}
41
- try {
42
- temporal = runtimeRequire("@js-temporal/polyfill");
43
- return temporal;
44
- } catch (e) {}
45
40
  temporal = false;
46
41
  }
47
42
  function requireTemporal() {
@@ -1 +1 @@
1
- {"version":3,"file":"temporal.cjs","names":["createRequire"],"sources":["../../src/serde/temporal.ts"],"sourcesContent":["/// <reference types=\"temporal-spec/global\" preserve=\"true\" />\n\nimport { createRequire } from \"node:module\";\n\nconst runtimeRequire = createRequire(import.meta.url);\n\n// Native Temporal and both supported polyfills expose this shape; use the shared spec types instead of duplicating it.\ntype TemporalModule = typeof import(\"temporal-spec\");\nlet temporal: TemporalModule | undefined | false;\n\n/**\n * Lazily exposes Joist's native-first / polyfill-fallback Temporal detection.\n *\n * This is useful while the joist-orm repo itself has both pre-Node 26, and post-Node 26\n * test coverage, b/c our CI test suite needs the same a) codegen output and b) test suites\n * to \"just work\" with either Node 24/25 or Node 26, which means they can't have an explicit\n * import to either `temporal-polyfill` or the `Temporal` global.\n *\n * This is exactly what Joist's internal temporal resolution was already working around, so\n * this just exposes an `import { Temporal } from joist-orm` that lets the codegen & tests\n * reuse the same abstraction.\n */\nexport const Temporal = new Proxy(\n {},\n {\n get(_target, property, receiver) {\n return Reflect.get(requireTemporal().Temporal, property, receiver);\n },\n },\n) as typeof globalThis.Temporal;\n\n/**\n * A type-only `Temporal` namespace that merges with the `const Temporal` above.\n *\n * The `const` is only a value, so using `Temporal.PlainDate` / `Temporal.ZonedDateTime` as a\n * type needs a namespace to resolve against. Node 26 has that as a global, but older Node\n * versions don't, so `temporal-spec/global` supplies the same global namespace as a fallback.\n */\nexport declare namespace Temporal {\n export type Instant = globalThis.Temporal.Instant;\n export type ZonedDateTime = globalThis.Temporal.ZonedDateTime;\n export type PlainDate = globalThis.Temporal.PlainDate;\n export type PlainTime = globalThis.Temporal.PlainTime;\n export type PlainDateTime = globalThis.Temporal.PlainDateTime;\n export type PlainYearMonth = globalThis.Temporal.PlainYearMonth;\n export type PlainMonthDay = globalThis.Temporal.PlainMonthDay;\n export type Duration = globalThis.Temporal.Duration;\n}\n\n/**\n * Conditionally/dynamically requires `temporal-polyfill`.\n *\n * We want to avoid directly importing/requiring `temporal-polyfill` because\n * it will introduce the dependency to all users of Joist.\n */\nexport function maybeRequireTemporal(): TemporalModule | undefined {\n // if we've already failed to find a temporal implementation before, early exit\n if (temporal === false) return undefined;\n // if we already required temporal, just return that\n if (temporal) return temporal;\n // use built in temporal if present\n if (\"Temporal\" in global && \"Intl\" in global) {\n temporal = {\n Temporal: global.Temporal as typeof globalThis.Temporal,\n toTemporalInstant: Date.prototype.toTemporalInstant,\n Intl: global.Intl,\n };\n return temporal;\n }\n // preferentially try to use temporal-polyfill\n try {\n temporal = runtimeRequire(\"temporal-polyfill\");\n return temporal as TemporalModule;\n } catch (e) {}\n // last resort, try to use @js-temporal/polyfill\n try {\n temporal = runtimeRequire(\"@js-temporal/polyfill\");\n return temporal as TemporalModule;\n } catch (e) {}\n // don't try to load temporal again\n temporal = false;\n return undefined;\n}\n\nexport function requireTemporal(): TemporalModule {\n const temporal = maybeRequireTemporal();\n if (!temporal) throw new Error(\"Unable to find a Temporal implementation\");\n return temporal;\n}\n"],"mappings":";;AAIA,MAAM,kBAAA,wBAAiBA,CAAAA,CAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IAA6B;AAIpD,IAAI;;;;;;;;;;;;;AAcJ,MAAa,WAAW,IAAI,MAC1B,CAAC,GACD,EACE,IAAI,SAAS,UAAU,UAAU;CAC/B,OAAO,QAAQ,IAAI,gBAAgB,CAAC,CAAC,UAAU,UAAU,QAAQ;AACnE,EACF,CACF;;;;;;;AA0BA,SAAgB,uBAAmD;CAEjE,IAAI,aAAa,OAAO,OAAO,KAAA;CAE/B,IAAI,UAAU,OAAO;CAErB,IAAI,cAAc,UAAU,UAAU,QAAQ;EAC5C,WAAW;GACT,UAAU,OAAO;GACjB,mBAAmB,KAAK,UAAU;GAClC,MAAM,OAAO;EACf;EACA,OAAO;CACT;CAEA,IAAI;EACF,WAAW,eAAe,mBAAmB;EAC7C,OAAO;CACT,SAAS,GAAG,CAAC;CAEb,IAAI;EACF,WAAW,eAAe,uBAAuB;EACjD,OAAO;CACT,SAAS,GAAG,CAAC;CAEb,WAAW;AAEb;AAEA,SAAgB,kBAAkC;CAChD,MAAM,WAAW,qBAAqB;CACtC,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,0CAA0C;CACzE,OAAO;AACT"}
1
+ {"version":3,"file":"temporal.cjs","names":["createRequire"],"sources":["../../src/serde/temporal.ts"],"sourcesContent":["/// <reference types=\"temporal-spec/global\" preserve=\"true\" />\n\nimport { createRequire } from \"node:module\";\n\nconst runtimeRequire = createRequire(import.meta.url);\n\n// Native Temporal and temporal-polyfill expose this shape; use the shared spec types instead of duplicating it.\ntype TemporalModule = typeof import(\"temporal-spec\");\nlet temporal: TemporalModule | undefined | false;\n\n/**\n * Lazily exposes Joist's native-first / polyfill-fallback Temporal detection.\n *\n * This is useful while the joist-orm repo itself has both pre-Node 26, and post-Node 26\n * test coverage, b/c our CI test suite needs the same a) codegen output and b) test suites\n * to \"just work\" with either Node 24/25 or Node 26, which means they can't have an explicit\n * import to either `temporal-polyfill` or the `Temporal` global.\n *\n * This is exactly what Joist's internal temporal resolution was already working around, so\n * this just exposes an `import { Temporal } from joist-orm` that lets the codegen & tests\n * reuse the same abstraction.\n */\nexport const Temporal = new Proxy(\n {},\n {\n get(_target, property, receiver) {\n return Reflect.get(requireTemporal().Temporal, property, receiver);\n },\n },\n) as typeof globalThis.Temporal;\n\n/**\n * A type-only `Temporal` namespace that merges with the `const Temporal` above.\n *\n * The `const` is only a value, so using `Temporal.PlainDate` / `Temporal.ZonedDateTime` as a\n * type needs a namespace to resolve against. Node 26 has that as a global, but older Node\n * versions don't, so `temporal-spec/global` supplies the same global namespace as a fallback.\n */\nexport declare namespace Temporal {\n export type Instant = globalThis.Temporal.Instant;\n export type ZonedDateTime = globalThis.Temporal.ZonedDateTime;\n export type PlainDate = globalThis.Temporal.PlainDate;\n export type PlainTime = globalThis.Temporal.PlainTime;\n export type PlainDateTime = globalThis.Temporal.PlainDateTime;\n export type PlainYearMonth = globalThis.Temporal.PlainYearMonth;\n export type PlainMonthDay = globalThis.Temporal.PlainMonthDay;\n export type Duration = globalThis.Temporal.Duration;\n}\n\n/**\n * Installs temporal-polyfill globally when native Temporal is unavailable.\n *\n * We want to avoid directly importing/requiring `temporal-polyfill` because\n * it will introduce the dependency to all users of Joist.\n */\nexport function maybeRequireTemporal(): TemporalModule | undefined {\n // if we've already failed to find a temporal implementation before, early exit\n if (temporal === false) return undefined;\n // if we already required temporal, just return that\n if (temporal) return temporal;\n // Share one implementation with database clients that resolve Temporal from the global.\n if (typeof globalThis.Temporal === \"undefined\") {\n try {\n runtimeRequire(\"temporal-polyfill/global\");\n } catch (e) {}\n }\n // use built in temporal or the installed polyfill\n if (typeof globalThis.Temporal !== \"undefined\") {\n temporal = {\n Temporal: globalThis.Temporal,\n toTemporalInstant: Date.prototype.toTemporalInstant,\n Intl: globalThis.Intl,\n };\n return temporal;\n }\n // don't try to load temporal again\n temporal = false;\n return undefined;\n}\n\nexport function requireTemporal(): TemporalModule {\n const temporal = maybeRequireTemporal();\n if (!temporal) throw new Error(\"Unable to find a Temporal implementation\");\n return temporal;\n}\n"],"mappings":";;AAIA,MAAM,kBAAA,wBAAiBA,CAAAA,CAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IAA6B;AAIpD,IAAI;;;;;;;;;;;;;AAcJ,MAAa,WAAW,IAAI,MAC1B,CAAC,GACD,EACE,IAAI,SAAS,UAAU,UAAU;CAC/B,OAAO,QAAQ,IAAI,gBAAgB,CAAC,CAAC,UAAU,UAAU,QAAQ;AACnE,EACF,CACF;;;;;;;AA0BA,SAAgB,uBAAmD;CAEjE,IAAI,aAAa,OAAO,OAAO,KAAA;CAE/B,IAAI,UAAU,OAAO;CAErB,IAAI,OAAO,WAAW,aAAa,aACjC,IAAI;EACF,eAAe,0BAA0B;CAC3C,SAAS,GAAG,CAAC;CAGf,IAAI,OAAO,WAAW,aAAa,aAAa;EAC9C,WAAW;GACT,UAAU,WAAW;GACrB,mBAAmB,KAAK,UAAU;GAClC,MAAM,WAAW;EACnB;EACA,OAAO;CACT;CAEA,WAAW;AAEb;AAEA,SAAgB,kBAAkC;CAChD,MAAM,WAAW,qBAAqB;CACtC,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,0CAA0C;CACzE,OAAO;AACT"}
@@ -13,7 +13,7 @@ type TemporalModule = typeof import("temporal-spec");
13
13
  * this just exposes an `import { Temporal } from joist-orm` that lets the codegen & tests
14
14
  * reuse the same abstraction.
15
15
  */
16
- declare const Temporal: typeof globalThis.Temporal;
16
+ export declare const Temporal: typeof globalThis.Temporal;
17
17
  /**
18
18
  * A type-only `Temporal` namespace that merges with the `const Temporal` above.
19
19
  *
@@ -21,7 +21,7 @@ declare const Temporal: typeof globalThis.Temporal;
21
21
  * type needs a namespace to resolve against. Node 26 has that as a global, but older Node
22
22
  * versions don't, so `temporal-spec/global` supplies the same global namespace as a fallback.
23
23
  */
24
- declare namespace Temporal {
24
+ export declare namespace Temporal {
25
25
  type Instant = globalThis.Temporal.Instant;
26
26
  type ZonedDateTime = globalThis.Temporal.ZonedDateTime;
27
27
  type PlainDate = globalThis.Temporal.PlainDate;
@@ -32,13 +32,13 @@ declare namespace Temporal {
32
32
  type Duration = globalThis.Temporal.Duration;
33
33
  }
34
34
  /**
35
- * Conditionally/dynamically requires `temporal-polyfill`.
35
+ * Installs temporal-polyfill globally when native Temporal is unavailable.
36
36
  *
37
37
  * We want to avoid directly importing/requiring `temporal-polyfill` because
38
38
  * it will introduce the dependency to all users of Joist.
39
39
  */
40
- declare function maybeRequireTemporal(): TemporalModule | undefined;
41
- declare function requireTemporal(): TemporalModule;
40
+ export declare function maybeRequireTemporal(): TemporalModule | undefined;
41
+ export declare function requireTemporal(): TemporalModule;
42
42
  //#endregion
43
- export { Temporal, maybeRequireTemporal, requireTemporal };
43
+ export {};
44
44
  //# sourceMappingURL=temporal.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"temporal.d.cts","names":[],"sources":["../../src/serde/temporal.ts"],"mappings":";;KAOK;;;;;;;;;;;;;cAeQ,iBAOD,WAAW;;;;;;;;kBASE;OACX,UAAU,WAAW,SAAS;OAC9B,gBAAgB,WAAW,SAAS;OACpC,YAAY,WAAW,SAAS;OAChC,YAAY,WAAW,SAAS;OAChC,gBAAgB,WAAW,SAAS;OACpC,iBAAiB,WAAW,SAAS;OACrC,gBAAgB,WAAW,SAAS;OACpC,WAAW,WAAW,SAAS;;;;;;;;iBAS7B,wBAAwB;iBA6BxB,mBAAmB"}
1
+ {"version":3,"file":"temporal.d.cts","names":[],"sources":["../../src/serde/temporal.ts"],"mappings":";;KAOK;;;;;;;;;;;;;qBAeQ,iBAOD,WAAW;;;;;;;;yBASE;OACX,UAAU,WAAW,SAAS;OAC9B,gBAAgB,WAAW,SAAS;OACpC,YAAY,WAAW,SAAS;OAChC,YAAY,WAAW,SAAS;OAChC,gBAAgB,WAAW,SAAS;OACpC,iBAAiB,WAAW,SAAS;OACrC,gBAAgB,WAAW,SAAS;OACpC,WAAW,WAAW,SAAS;;;;;;;;wBAS7B,wBAAwB;wBAyBxB,mBAAmB"}
@@ -13,7 +13,7 @@ type TemporalModule = typeof import("temporal-spec");
13
13
  * this just exposes an `import { Temporal } from joist-orm` that lets the codegen & tests
14
14
  * reuse the same abstraction.
15
15
  */
16
- declare const Temporal: typeof globalThis.Temporal;
16
+ export declare const Temporal: typeof globalThis.Temporal;
17
17
  /**
18
18
  * A type-only `Temporal` namespace that merges with the `const Temporal` above.
19
19
  *
@@ -21,7 +21,7 @@ declare const Temporal: typeof globalThis.Temporal;
21
21
  * type needs a namespace to resolve against. Node 26 has that as a global, but older Node
22
22
  * versions don't, so `temporal-spec/global` supplies the same global namespace as a fallback.
23
23
  */
24
- declare namespace Temporal {
24
+ export declare namespace Temporal {
25
25
  type Instant = globalThis.Temporal.Instant;
26
26
  type ZonedDateTime = globalThis.Temporal.ZonedDateTime;
27
27
  type PlainDate = globalThis.Temporal.PlainDate;
@@ -32,13 +32,13 @@ declare namespace Temporal {
32
32
  type Duration = globalThis.Temporal.Duration;
33
33
  }
34
34
  /**
35
- * Conditionally/dynamically requires `temporal-polyfill`.
35
+ * Installs temporal-polyfill globally when native Temporal is unavailable.
36
36
  *
37
37
  * We want to avoid directly importing/requiring `temporal-polyfill` because
38
38
  * it will introduce the dependency to all users of Joist.
39
39
  */
40
- declare function maybeRequireTemporal(): TemporalModule | undefined;
41
- declare function requireTemporal(): TemporalModule;
40
+ export declare function maybeRequireTemporal(): TemporalModule | undefined;
41
+ export declare function requireTemporal(): TemporalModule;
42
42
  //#endregion
43
- export { Temporal, maybeRequireTemporal, requireTemporal };
43
+ export {};
44
44
  //# sourceMappingURL=temporal.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"temporal.d.mts","names":[],"sources":["../../src/serde/temporal.ts"],"mappings":";;KAOK;;;;;;;;;;;;;cAeQ,iBAOD,WAAW;;;;;;;;kBASE;OACX,UAAU,WAAW,SAAS;OAC9B,gBAAgB,WAAW,SAAS;OACpC,YAAY,WAAW,SAAS;OAChC,YAAY,WAAW,SAAS;OAChC,gBAAgB,WAAW,SAAS;OACpC,iBAAiB,WAAW,SAAS;OACrC,gBAAgB,WAAW,SAAS;OACpC,WAAW,WAAW,SAAS;;;;;;;;iBAS7B,wBAAwB;iBA6BxB,mBAAmB"}
1
+ {"version":3,"file":"temporal.d.mts","names":[],"sources":["../../src/serde/temporal.ts"],"mappings":";;KAOK;;;;;;;;;;;;;qBAeQ,iBAOD,WAAW;;;;;;;;yBASE;OACX,UAAU,WAAW,SAAS;OAC9B,gBAAgB,WAAW,SAAS;OACpC,YAAY,WAAW,SAAS;OAChC,YAAY,WAAW,SAAS;OAChC,gBAAgB,WAAW,SAAS;OACpC,iBAAiB,WAAW,SAAS;OACrC,gBAAgB,WAAW,SAAS;OACpC,WAAW,WAAW,SAAS;;;;;;;;wBAS7B,wBAAwB;wBAyBxB,mBAAmB"}
@@ -18,7 +18,7 @@ const Temporal = new Proxy({}, { get(_target, property, receiver) {
18
18
  return Reflect.get(requireTemporal().Temporal, property, receiver);
19
19
  } });
20
20
  /**
21
- * Conditionally/dynamically requires `temporal-polyfill`.
21
+ * Installs temporal-polyfill globally when native Temporal is unavailable.
22
22
  *
23
23
  * We want to avoid directly importing/requiring `temporal-polyfill` because
24
24
  * it will introduce the dependency to all users of Joist.
@@ -26,22 +26,17 @@ const Temporal = new Proxy({}, { get(_target, property, receiver) {
26
26
  function maybeRequireTemporal() {
27
27
  if (temporal === false) return void 0;
28
28
  if (temporal) return temporal;
29
- if ("Temporal" in global && "Intl" in global) {
29
+ if (typeof globalThis.Temporal === "undefined") try {
30
+ runtimeRequire("temporal-polyfill/global");
31
+ } catch (e) {}
32
+ if (typeof globalThis.Temporal !== "undefined") {
30
33
  temporal = {
31
- Temporal: global.Temporal,
34
+ Temporal: globalThis.Temporal,
32
35
  toTemporalInstant: Date.prototype.toTemporalInstant,
33
- Intl: global.Intl
36
+ Intl: globalThis.Intl
34
37
  };
35
38
  return temporal;
36
39
  }
37
- try {
38
- temporal = runtimeRequire("temporal-polyfill");
39
- return temporal;
40
- } catch (e) {}
41
- try {
42
- temporal = runtimeRequire("@js-temporal/polyfill");
43
- return temporal;
44
- } catch (e) {}
45
40
  temporal = false;
46
41
  }
47
42
  function requireTemporal() {
@@ -1 +1 @@
1
- {"version":3,"file":"temporal.js","names":[],"sources":["../../src/serde/temporal.ts"],"sourcesContent":["/// <reference types=\"temporal-spec/global\" preserve=\"true\" />\n\nimport { createRequire } from \"node:module\";\n\nconst runtimeRequire = createRequire(import.meta.url);\n\n// Native Temporal and both supported polyfills expose this shape; use the shared spec types instead of duplicating it.\ntype TemporalModule = typeof import(\"temporal-spec\");\nlet temporal: TemporalModule | undefined | false;\n\n/**\n * Lazily exposes Joist's native-first / polyfill-fallback Temporal detection.\n *\n * This is useful while the joist-orm repo itself has both pre-Node 26, and post-Node 26\n * test coverage, b/c our CI test suite needs the same a) codegen output and b) test suites\n * to \"just work\" with either Node 24/25 or Node 26, which means they can't have an explicit\n * import to either `temporal-polyfill` or the `Temporal` global.\n *\n * This is exactly what Joist's internal temporal resolution was already working around, so\n * this just exposes an `import { Temporal } from joist-orm` that lets the codegen & tests\n * reuse the same abstraction.\n */\nexport const Temporal = new Proxy(\n {},\n {\n get(_target, property, receiver) {\n return Reflect.get(requireTemporal().Temporal, property, receiver);\n },\n },\n) as typeof globalThis.Temporal;\n\n/**\n * A type-only `Temporal` namespace that merges with the `const Temporal` above.\n *\n * The `const` is only a value, so using `Temporal.PlainDate` / `Temporal.ZonedDateTime` as a\n * type needs a namespace to resolve against. Node 26 has that as a global, but older Node\n * versions don't, so `temporal-spec/global` supplies the same global namespace as a fallback.\n */\nexport declare namespace Temporal {\n export type Instant = globalThis.Temporal.Instant;\n export type ZonedDateTime = globalThis.Temporal.ZonedDateTime;\n export type PlainDate = globalThis.Temporal.PlainDate;\n export type PlainTime = globalThis.Temporal.PlainTime;\n export type PlainDateTime = globalThis.Temporal.PlainDateTime;\n export type PlainYearMonth = globalThis.Temporal.PlainYearMonth;\n export type PlainMonthDay = globalThis.Temporal.PlainMonthDay;\n export type Duration = globalThis.Temporal.Duration;\n}\n\n/**\n * Conditionally/dynamically requires `temporal-polyfill`.\n *\n * We want to avoid directly importing/requiring `temporal-polyfill` because\n * it will introduce the dependency to all users of Joist.\n */\nexport function maybeRequireTemporal(): TemporalModule | undefined {\n // if we've already failed to find a temporal implementation before, early exit\n if (temporal === false) return undefined;\n // if we already required temporal, just return that\n if (temporal) return temporal;\n // use built in temporal if present\n if (\"Temporal\" in global && \"Intl\" in global) {\n temporal = {\n Temporal: global.Temporal as typeof globalThis.Temporal,\n toTemporalInstant: Date.prototype.toTemporalInstant,\n Intl: global.Intl,\n };\n return temporal;\n }\n // preferentially try to use temporal-polyfill\n try {\n temporal = runtimeRequire(\"temporal-polyfill\");\n return temporal as TemporalModule;\n } catch (e) {}\n // last resort, try to use @js-temporal/polyfill\n try {\n temporal = runtimeRequire(\"@js-temporal/polyfill\");\n return temporal as TemporalModule;\n } catch (e) {}\n // don't try to load temporal again\n temporal = false;\n return undefined;\n}\n\nexport function requireTemporal(): TemporalModule {\n const temporal = maybeRequireTemporal();\n if (!temporal) throw new Error(\"Unable to find a Temporal implementation\");\n return temporal;\n}\n"],"mappings":";;AAIA,MAAM,iBAAiB,cAAc,YAAY,GAAG;AAIpD,IAAI;;;;;;;;;;;;;AAcJ,MAAa,WAAW,IAAI,MAC1B,CAAC,GACD,EACE,IAAI,SAAS,UAAU,UAAU;CAC/B,OAAO,QAAQ,IAAI,gBAAgB,CAAC,CAAC,UAAU,UAAU,QAAQ;AACnE,EACF,CACF;;;;;;;AA0BA,SAAgB,uBAAmD;CAEjE,IAAI,aAAa,OAAO,OAAO,KAAA;CAE/B,IAAI,UAAU,OAAO;CAErB,IAAI,cAAc,UAAU,UAAU,QAAQ;EAC5C,WAAW;GACT,UAAU,OAAO;GACjB,mBAAmB,KAAK,UAAU;GAClC,MAAM,OAAO;EACf;EACA,OAAO;CACT;CAEA,IAAI;EACF,WAAW,eAAe,mBAAmB;EAC7C,OAAO;CACT,SAAS,GAAG,CAAC;CAEb,IAAI;EACF,WAAW,eAAe,uBAAuB;EACjD,OAAO;CACT,SAAS,GAAG,CAAC;CAEb,WAAW;AAEb;AAEA,SAAgB,kBAAkC;CAChD,MAAM,WAAW,qBAAqB;CACtC,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,0CAA0C;CACzE,OAAO;AACT"}
1
+ {"version":3,"file":"temporal.js","names":[],"sources":["../../src/serde/temporal.ts"],"sourcesContent":["/// <reference types=\"temporal-spec/global\" preserve=\"true\" />\n\nimport { createRequire } from \"node:module\";\n\nconst runtimeRequire = createRequire(import.meta.url);\n\n// Native Temporal and temporal-polyfill expose this shape; use the shared spec types instead of duplicating it.\ntype TemporalModule = typeof import(\"temporal-spec\");\nlet temporal: TemporalModule | undefined | false;\n\n/**\n * Lazily exposes Joist's native-first / polyfill-fallback Temporal detection.\n *\n * This is useful while the joist-orm repo itself has both pre-Node 26, and post-Node 26\n * test coverage, b/c our CI test suite needs the same a) codegen output and b) test suites\n * to \"just work\" with either Node 24/25 or Node 26, which means they can't have an explicit\n * import to either `temporal-polyfill` or the `Temporal` global.\n *\n * This is exactly what Joist's internal temporal resolution was already working around, so\n * this just exposes an `import { Temporal } from joist-orm` that lets the codegen & tests\n * reuse the same abstraction.\n */\nexport const Temporal = new Proxy(\n {},\n {\n get(_target, property, receiver) {\n return Reflect.get(requireTemporal().Temporal, property, receiver);\n },\n },\n) as typeof globalThis.Temporal;\n\n/**\n * A type-only `Temporal` namespace that merges with the `const Temporal` above.\n *\n * The `const` is only a value, so using `Temporal.PlainDate` / `Temporal.ZonedDateTime` as a\n * type needs a namespace to resolve against. Node 26 has that as a global, but older Node\n * versions don't, so `temporal-spec/global` supplies the same global namespace as a fallback.\n */\nexport declare namespace Temporal {\n export type Instant = globalThis.Temporal.Instant;\n export type ZonedDateTime = globalThis.Temporal.ZonedDateTime;\n export type PlainDate = globalThis.Temporal.PlainDate;\n export type PlainTime = globalThis.Temporal.PlainTime;\n export type PlainDateTime = globalThis.Temporal.PlainDateTime;\n export type PlainYearMonth = globalThis.Temporal.PlainYearMonth;\n export type PlainMonthDay = globalThis.Temporal.PlainMonthDay;\n export type Duration = globalThis.Temporal.Duration;\n}\n\n/**\n * Installs temporal-polyfill globally when native Temporal is unavailable.\n *\n * We want to avoid directly importing/requiring `temporal-polyfill` because\n * it will introduce the dependency to all users of Joist.\n */\nexport function maybeRequireTemporal(): TemporalModule | undefined {\n // if we've already failed to find a temporal implementation before, early exit\n if (temporal === false) return undefined;\n // if we already required temporal, just return that\n if (temporal) return temporal;\n // Share one implementation with database clients that resolve Temporal from the global.\n if (typeof globalThis.Temporal === \"undefined\") {\n try {\n runtimeRequire(\"temporal-polyfill/global\");\n } catch (e) {}\n }\n // use built in temporal or the installed polyfill\n if (typeof globalThis.Temporal !== \"undefined\") {\n temporal = {\n Temporal: globalThis.Temporal,\n toTemporalInstant: Date.prototype.toTemporalInstant,\n Intl: globalThis.Intl,\n };\n return temporal;\n }\n // don't try to load temporal again\n temporal = false;\n return undefined;\n}\n\nexport function requireTemporal(): TemporalModule {\n const temporal = maybeRequireTemporal();\n if (!temporal) throw new Error(\"Unable to find a Temporal implementation\");\n return temporal;\n}\n"],"mappings":";;AAIA,MAAM,iBAAiB,cAAc,YAAY,GAAG;AAIpD,IAAI;;;;;;;;;;;;;AAcJ,MAAa,WAAW,IAAI,MAC1B,CAAC,GACD,EACE,IAAI,SAAS,UAAU,UAAU;CAC/B,OAAO,QAAQ,IAAI,gBAAgB,CAAC,CAAC,UAAU,UAAU,QAAQ;AACnE,EACF,CACF;;;;;;;AA0BA,SAAgB,uBAAmD;CAEjE,IAAI,aAAa,OAAO,OAAO,KAAA;CAE/B,IAAI,UAAU,OAAO;CAErB,IAAI,OAAO,WAAW,aAAa,aACjC,IAAI;EACF,eAAe,0BAA0B;CAC3C,SAAS,GAAG,CAAC;CAGf,IAAI,OAAO,WAAW,aAAa,aAAa;EAC9C,WAAW;GACT,UAAU,WAAW;GACrB,mBAAmB,KAAK,UAAU;GAClC,MAAM,WAAW;EACnB;EACA,OAAO;CACT;CAEA,WAAW;AAEb;AAEA,SAAgB,kBAAkC;CAChD,MAAM,WAAW,qBAAqB;CACtC,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,0CAA0C;CACzE,OAAO;AACT"}
@@ -15,12 +15,14 @@ const temporalNotAvailable = {
15
15
  */
16
16
  const plainDateMapper = t ? {
17
17
  fromDb: (value) => value instanceof t.PlainDate ? value : t.PlainDate.from(value),
18
- toDb: (p) => p.toString()
18
+ toDb: (p) => p.toString(),
19
+ getUnnestMarker: () => t.PlainDate.from("2000-01-01")
19
20
  } : temporalNotAvailable;
20
21
  /** Converts Postgres `TIME` to/from Temporal.PlainTime; `fromDb` also passes binary-decoded instances through. */
21
22
  const plainTimeMapper = t ? {
22
23
  fromDb: (value) => value instanceof t.PlainTime ? value : t.PlainTime.from(value),
23
- toDb: (pt) => pt.toString()
24
+ toDb: (pt) => pt.toString(),
25
+ getUnnestMarker: () => t.PlainTime.from("00:00:00")
24
26
  } : temporalNotAvailable;
25
27
  /**
26
28
  * Converts Postgres `TIMESTAMP` / `TIMESTAMP WITHOUT TIME ZONE` to/from Temporal.PlainDateTime;
@@ -28,7 +30,8 @@ const plainTimeMapper = t ? {
28
30
  */
29
31
  const plainDateTimeMapper = t ? {
30
32
  fromDb: (value) => value instanceof t.PlainDateTime ? value : t.PlainDateTime.from(value),
31
- toDb: (p) => p.toString()
33
+ toDb: (p) => p.toString(),
34
+ getUnnestMarker: () => t.PlainDateTime.from("2000-01-01T00:00:00")
32
35
  } : temporalNotAvailable;
33
36
  /**
34
37
  * Converts Postgres `TIMESTAMPTZ`, `TIMESTAMPTZ WITH TIME ZONE` to/from Temporal.ZonedDateTime.
@@ -51,7 +54,8 @@ const zonedDateTimeMapper = t ? {
51
54
  const [offset] = value.match(/([+-]\d{2}(?::?\d{2})?)$/) ?? [];
52
55
  return t.ZonedDateTime.from(`${value}[${!offset || /^\+00(:?00)?$/.test(offset) ? "UTC" : offset}]`);
53
56
  },
54
- toDb: (zdt) => zdt.toString({ timeZoneName: "never" })
57
+ toDb: (zdt) => zdt.toString({ timeZoneName: "never" }),
58
+ getUnnestMarker: () => t.ZonedDateTime.from("2000-01-01T00:00:00+00:00[UTC]")
55
59
  } : temporalNotAvailable;
56
60
  //#endregion
57
61
  exports.plainDateMapper = plainDateMapper;
@@ -1 +1 @@
1
- {"version":3,"file":"temporalMappers.cjs","names":["maybeRequireTemporal","fail"],"sources":["../../src/serde/temporalMappers.ts"],"sourcesContent":["import type { CustomSerde } from \"src/serde/serde.ts\";\nimport { type Temporal, maybeRequireTemporal } from \"src/serde/temporal.ts\";\nimport { fail } from \"src/utils.ts\";\n\nconst { Temporal: t } = maybeRequireTemporal() ?? {};\nconst temporalNotAvailable = {\n fromDb: () => fail(\"Temporal not available\"),\n toDb: () => fail(\"Temporal not available\"),\n};\n\n/**\n * Converts Postgres `DATE` to/from Temporal.PlainDate.\n *\n * `fromDb` accepts either pg's text form (classic/knex text queries, json_agg preloads) or an\n * already-constructed `PlainDate` (lazy binary queries decode wire bytes -> Temporal directly).\n */\nexport const plainDateMapper: CustomSerde<Temporal.PlainDate, string> = t\n ? {\n fromDb: (value: string | Temporal.PlainDate) => (value instanceof t.PlainDate ? value : t.PlainDate.from(value)),\n toDb: (p) => p.toString(),\n }\n : temporalNotAvailable;\n\n/** Converts Postgres `TIME` to/from Temporal.PlainTime; `fromDb` also passes binary-decoded instances through. */\nexport const plainTimeMapper: CustomSerde<Temporal.PlainTime, string> = t\n ? {\n fromDb: (value: string | Temporal.PlainTime) => (value instanceof t.PlainTime ? value : t.PlainTime.from(value)),\n toDb: (pt) => pt.toString(),\n }\n : temporalNotAvailable;\n\n/**\n * Converts Postgres `TIMESTAMP` / `TIMESTAMP WITHOUT TIME ZONE` to/from Temporal.PlainDateTime;\n * `fromDb` also passes binary-decoded instances through.\n */\nexport const plainDateTimeMapper: CustomSerde<Temporal.PlainDateTime, string> = t\n ? {\n // Text values look like `2018-01-01 10:00:00`\n fromDb: (value: string | Temporal.PlainDateTime) =>\n value instanceof t.PlainDateTime ? value : t.PlainDateTime.from(value),\n toDb: (p) => p.toString(),\n }\n : temporalNotAvailable;\n\n/**\n * Converts Postgres `TIMESTAMPTZ`, `TIMESTAMPTZ WITH TIME ZONE` to/from Temporal.ZonedDateTime.\n *\n * Specifically, Postgres uses ISO 8601, which Temporal supports as well, except that PG ouputs a space instead of `T`\n * between the date/time for output.\n *\n * Additionally, `Temporal.ZonedDateTime.from` expects a time zone literal name to be supplied as part of the string,\n * but this is not stored by postgres.\n *\n * As such, we parse the offset and append it to string passed to `from` as the time zone. This means that if we did a\n * round trip of generating a db value then parsing it, then it may not strictly equal the original zdt.\n *\n * Finally, PG stores dates as UTC and converts them to its local time zone for output, so we could get any offset\n * theoretically. If, somehow, we don't get an offset, then we assume UTC.\n */\nexport const zonedDateTimeMapper: CustomSerde<Temporal.ZonedDateTime, string> = t\n ? {\n // Produce a ZDT from a PG output like \"2021-01-01 12:00:00-05:00\"; binary-decoded\n // instances (lazy queries construct ZonedDateTimes directly) pass through\n fromDb: (value: string | Temporal.ZonedDateTime) => {\n if (typeof value !== \"string\") return value;\n const [offset] = value.match(/([+-]\\d{2}(?::?\\d{2})?)$/) ?? [];\n return t.ZonedDateTime.from(`${value}[${!offset || /^\\+00(:?00)?$/.test(offset) ? \"UTC\" : offset}]`);\n },\n // Match a PG `TIMESTAMPTZ` input format, i.e. \"2021-01-01T12:00:00-05:00\"\n toDb: (zdt) => zdt.toString({ timeZoneName: \"never\" }),\n }\n : temporalNotAvailable;\n"],"mappings":";;;;AAIA,MAAM,EAAE,UAAU,MAAMA,uBAAAA,qBAAqB,KAAK,CAAC;AACnD,MAAM,uBAAuB;CAC3B,cAAcC,cAAAA,KAAK,wBAAwB;CAC3C,YAAYA,cAAAA,KAAK,wBAAwB;AAC3C;;;;;;;AAQA,MAAa,kBAA2D,IACpE;CACE,SAAS,UAAwC,iBAAiB,EAAE,YAAY,QAAQ,EAAE,UAAU,KAAK,KAAK;CAC9G,OAAO,MAAM,EAAE,SAAS;AAC1B,IACA;;AAGJ,MAAa,kBAA2D,IACpE;CACE,SAAS,UAAwC,iBAAiB,EAAE,YAAY,QAAQ,EAAE,UAAU,KAAK,KAAK;CAC9G,OAAO,OAAO,GAAG,SAAS;AAC5B,IACA;;;;;AAMJ,MAAa,sBAAmE,IAC5E;CAEE,SAAS,UACP,iBAAiB,EAAE,gBAAgB,QAAQ,EAAE,cAAc,KAAK,KAAK;CACvE,OAAO,MAAM,EAAE,SAAS;AAC1B,IACA;;;;;;;;;;;;;;;;AAiBJ,MAAa,sBAAmE,IAC5E;CAGE,SAAS,UAA2C;EAClD,IAAI,OAAO,UAAU,UAAU,OAAO;EACtC,MAAM,CAAC,UAAU,MAAM,MAAM,0BAA0B,KAAK,CAAC;EAC7D,OAAO,EAAE,cAAc,KAAK,GAAG,MAAM,GAAG,CAAC,UAAU,gBAAgB,KAAK,MAAM,IAAI,QAAQ,OAAO,EAAE;CACrG;CAEA,OAAO,QAAQ,IAAI,SAAS,EAAE,cAAc,QAAQ,CAAC;AACvD,IACA"}
1
+ {"version":3,"file":"temporalMappers.cjs","names":["maybeRequireTemporal","fail"],"sources":["../../src/serde/temporalMappers.ts"],"sourcesContent":["import type { CustomSerde } from \"src/serde/serde.ts\";\nimport { type Temporal, maybeRequireTemporal } from \"src/serde/temporal.ts\";\nimport { fail } from \"src/utils.ts\";\n\nconst { Temporal: t } = maybeRequireTemporal() ?? {};\nconst temporalNotAvailable = {\n fromDb: () => fail(\"Temporal not available\"),\n toDb: () => fail(\"Temporal not available\"),\n};\n\n/**\n * Converts Postgres `DATE` to/from Temporal.PlainDate.\n *\n * `fromDb` accepts either pg's text form (classic/knex text queries, json_agg preloads) or an\n * already-constructed `PlainDate` (lazy binary queries decode wire bytes -> Temporal directly).\n */\nexport const plainDateMapper: CustomSerde<Temporal.PlainDate, string> = t\n ? {\n fromDb: (value: string | Temporal.PlainDate) => (value instanceof t.PlainDate ? value : t.PlainDate.from(value)),\n toDb: (p) => p.toString(),\n getUnnestMarker: () => t.PlainDate.from(\"2000-01-01\"),\n }\n : temporalNotAvailable;\n\n/** Converts Postgres `TIME` to/from Temporal.PlainTime; `fromDb` also passes binary-decoded instances through. */\nexport const plainTimeMapper: CustomSerde<Temporal.PlainTime, string> = t\n ? {\n fromDb: (value: string | Temporal.PlainTime) => (value instanceof t.PlainTime ? value : t.PlainTime.from(value)),\n toDb: (pt) => pt.toString(),\n getUnnestMarker: () => t.PlainTime.from(\"00:00:00\"),\n }\n : temporalNotAvailable;\n\n/**\n * Converts Postgres `TIMESTAMP` / `TIMESTAMP WITHOUT TIME ZONE` to/from Temporal.PlainDateTime;\n * `fromDb` also passes binary-decoded instances through.\n */\nexport const plainDateTimeMapper: CustomSerde<Temporal.PlainDateTime, string> = t\n ? {\n // Text values look like `2018-01-01 10:00:00`\n fromDb: (value: string | Temporal.PlainDateTime) =>\n value instanceof t.PlainDateTime ? value : t.PlainDateTime.from(value),\n toDb: (p) => p.toString(),\n getUnnestMarker: () => t.PlainDateTime.from(\"2000-01-01T00:00:00\"),\n }\n : temporalNotAvailable;\n\n/**\n * Converts Postgres `TIMESTAMPTZ`, `TIMESTAMPTZ WITH TIME ZONE` to/from Temporal.ZonedDateTime.\n *\n * Specifically, Postgres uses ISO 8601, which Temporal supports as well, except that PG ouputs a space instead of `T`\n * between the date/time for output.\n *\n * Additionally, `Temporal.ZonedDateTime.from` expects a time zone literal name to be supplied as part of the string,\n * but this is not stored by postgres.\n *\n * As such, we parse the offset and append it to string passed to `from` as the time zone. This means that if we did a\n * round trip of generating a db value then parsing it, then it may not strictly equal the original zdt.\n *\n * Finally, PG stores dates as UTC and converts them to its local time zone for output, so we could get any offset\n * theoretically. If, somehow, we don't get an offset, then we assume UTC.\n */\nexport const zonedDateTimeMapper: CustomSerde<Temporal.ZonedDateTime, string> = t\n ? {\n // Produce a ZDT from a PG output like \"2021-01-01 12:00:00-05:00\"; binary-decoded\n // instances (lazy queries construct ZonedDateTimes directly) pass through\n fromDb: (value: string | Temporal.ZonedDateTime) => {\n if (typeof value !== \"string\") return value;\n const [offset] = value.match(/([+-]\\d{2}(?::?\\d{2})?)$/) ?? [];\n return t.ZonedDateTime.from(`${value}[${!offset || /^\\+00(:?00)?$/.test(offset) ? \"UTC\" : offset}]`);\n },\n // Match a PG `TIMESTAMPTZ` input format, i.e. \"2021-01-01T12:00:00-05:00\"\n toDb: (zdt) => zdt.toString({ timeZoneName: \"never\" }),\n getUnnestMarker: () => t.ZonedDateTime.from(\"2000-01-01T00:00:00+00:00[UTC]\"),\n }\n : temporalNotAvailable;\n"],"mappings":";;;;AAIA,MAAM,EAAE,UAAU,MAAMA,uBAAAA,qBAAqB,KAAK,CAAC;AACnD,MAAM,uBAAuB;CAC3B,cAAcC,cAAAA,KAAK,wBAAwB;CAC3C,YAAYA,cAAAA,KAAK,wBAAwB;AAC3C;;;;;;;AAQA,MAAa,kBAA2D,IACpE;CACE,SAAS,UAAwC,iBAAiB,EAAE,YAAY,QAAQ,EAAE,UAAU,KAAK,KAAK;CAC9G,OAAO,MAAM,EAAE,SAAS;CACxB,uBAAuB,EAAE,UAAU,KAAK,YAAY;AACtD,IACA;;AAGJ,MAAa,kBAA2D,IACpE;CACE,SAAS,UAAwC,iBAAiB,EAAE,YAAY,QAAQ,EAAE,UAAU,KAAK,KAAK;CAC9G,OAAO,OAAO,GAAG,SAAS;CAC1B,uBAAuB,EAAE,UAAU,KAAK,UAAU;AACpD,IACA;;;;;AAMJ,MAAa,sBAAmE,IAC5E;CAEE,SAAS,UACP,iBAAiB,EAAE,gBAAgB,QAAQ,EAAE,cAAc,KAAK,KAAK;CACvE,OAAO,MAAM,EAAE,SAAS;CACxB,uBAAuB,EAAE,cAAc,KAAK,qBAAqB;AACnE,IACA;;;;;;;;;;;;;;;;AAiBJ,MAAa,sBAAmE,IAC5E;CAGE,SAAS,UAA2C;EAClD,IAAI,OAAO,UAAU,UAAU,OAAO;EACtC,MAAM,CAAC,UAAU,MAAM,MAAM,0BAA0B,KAAK,CAAC;EAC7D,OAAO,EAAE,cAAc,KAAK,GAAG,MAAM,GAAG,CAAC,UAAU,gBAAgB,KAAK,MAAM,IAAI,QAAQ,OAAO,EAAE;CACrG;CAEA,OAAO,QAAQ,IAAI,SAAS,EAAE,cAAc,QAAQ,CAAC;CACrD,uBAAuB,EAAE,cAAc,KAAK,gCAAgC;AAC9E,IACA"}
@@ -7,14 +7,14 @@ import { CustomSerde } from "./serde.cjs";
7
7
  * `fromDb` accepts either pg's text form (classic/knex text queries, json_agg preloads) or an
8
8
  * already-constructed `PlainDate` (lazy binary queries decode wire bytes -> Temporal directly).
9
9
  */
10
- declare const plainDateMapper: CustomSerde<Temporal.PlainDate, string>;
10
+ export declare const plainDateMapper: CustomSerde<Temporal.PlainDate, string>;
11
11
  /** Converts Postgres `TIME` to/from Temporal.PlainTime; `fromDb` also passes binary-decoded instances through. */
12
- declare const plainTimeMapper: CustomSerde<Temporal.PlainTime, string>;
12
+ export declare const plainTimeMapper: CustomSerde<Temporal.PlainTime, string>;
13
13
  /**
14
14
  * Converts Postgres `TIMESTAMP` / `TIMESTAMP WITHOUT TIME ZONE` to/from Temporal.PlainDateTime;
15
15
  * `fromDb` also passes binary-decoded instances through.
16
16
  */
17
- declare const plainDateTimeMapper: CustomSerde<Temporal.PlainDateTime, string>;
17
+ export declare const plainDateTimeMapper: CustomSerde<Temporal.PlainDateTime, string>;
18
18
  /**
19
19
  * Converts Postgres `TIMESTAMPTZ`, `TIMESTAMPTZ WITH TIME ZONE` to/from Temporal.ZonedDateTime.
20
20
  *
@@ -30,7 +30,6 @@ declare const plainDateTimeMapper: CustomSerde<Temporal.PlainDateTime, string>;
30
30
  * Finally, PG stores dates as UTC and converts them to its local time zone for output, so we could get any offset
31
31
  * theoretically. If, somehow, we don't get an offset, then we assume UTC.
32
32
  */
33
- declare const zonedDateTimeMapper: CustomSerde<Temporal.ZonedDateTime, string>;
33
+ export declare const zonedDateTimeMapper: CustomSerde<Temporal.ZonedDateTime, string>;
34
34
  //#endregion
35
- export { plainDateMapper, plainDateTimeMapper, plainTimeMapper, zonedDateTimeMapper };
36
35
  //# sourceMappingURL=temporalMappers.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"temporalMappers.d.cts","names":[],"sources":["../../src/serde/temporalMappers.ts"],"mappings":";;;;;;;;;cAgBa,iBAAiB,YAAY,SAAS;;cAQtC,iBAAiB,YAAY,SAAS;;;;;cAWtC,qBAAqB,YAAY,SAAS;;;;;;;;;;;;;;;;cAwB1C,qBAAqB,YAAY,SAAS"}
1
+ {"version":3,"file":"temporalMappers.d.cts","names":[],"sources":["../../src/serde/temporalMappers.ts"],"mappings":";;;;;;;;;qBAgBa,iBAAiB,YAAY,SAAS;;qBAStC,iBAAiB,YAAY,SAAS;;;;;qBAYtC,qBAAqB,YAAY,SAAS;;;;;;;;;;;;;;;;qBAyB1C,qBAAqB,YAAY,SAAS"}
@@ -7,14 +7,14 @@ import { CustomSerde } from "./serde.mjs";
7
7
  * `fromDb` accepts either pg's text form (classic/knex text queries, json_agg preloads) or an
8
8
  * already-constructed `PlainDate` (lazy binary queries decode wire bytes -> Temporal directly).
9
9
  */
10
- declare const plainDateMapper: CustomSerde<Temporal.PlainDate, string>;
10
+ export declare const plainDateMapper: CustomSerde<Temporal.PlainDate, string>;
11
11
  /** Converts Postgres `TIME` to/from Temporal.PlainTime; `fromDb` also passes binary-decoded instances through. */
12
- declare const plainTimeMapper: CustomSerde<Temporal.PlainTime, string>;
12
+ export declare const plainTimeMapper: CustomSerde<Temporal.PlainTime, string>;
13
13
  /**
14
14
  * Converts Postgres `TIMESTAMP` / `TIMESTAMP WITHOUT TIME ZONE` to/from Temporal.PlainDateTime;
15
15
  * `fromDb` also passes binary-decoded instances through.
16
16
  */
17
- declare const plainDateTimeMapper: CustomSerde<Temporal.PlainDateTime, string>;
17
+ export declare const plainDateTimeMapper: CustomSerde<Temporal.PlainDateTime, string>;
18
18
  /**
19
19
  * Converts Postgres `TIMESTAMPTZ`, `TIMESTAMPTZ WITH TIME ZONE` to/from Temporal.ZonedDateTime.
20
20
  *
@@ -30,7 +30,6 @@ declare const plainDateTimeMapper: CustomSerde<Temporal.PlainDateTime, string>;
30
30
  * Finally, PG stores dates as UTC and converts them to its local time zone for output, so we could get any offset
31
31
  * theoretically. If, somehow, we don't get an offset, then we assume UTC.
32
32
  */
33
- declare const zonedDateTimeMapper: CustomSerde<Temporal.ZonedDateTime, string>;
33
+ export declare const zonedDateTimeMapper: CustomSerde<Temporal.ZonedDateTime, string>;
34
34
  //#endregion
35
- export { plainDateMapper, plainDateTimeMapper, plainTimeMapper, zonedDateTimeMapper };
36
35
  //# sourceMappingURL=temporalMappers.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"temporalMappers.d.mts","names":[],"sources":["../../src/serde/temporalMappers.ts"],"mappings":";;;;;;;;;cAgBa,iBAAiB,YAAY,SAAS;;cAQtC,iBAAiB,YAAY,SAAS;;;;;cAWtC,qBAAqB,YAAY,SAAS;;;;;;;;;;;;;;;;cAwB1C,qBAAqB,YAAY,SAAS"}
1
+ {"version":3,"file":"temporalMappers.d.mts","names":[],"sources":["../../src/serde/temporalMappers.ts"],"mappings":";;;;;;;;;qBAgBa,iBAAiB,YAAY,SAAS;;qBAStC,iBAAiB,YAAY,SAAS;;;;;qBAYtC,qBAAqB,YAAY,SAAS;;;;;;;;;;;;;;;;qBAyB1C,qBAAqB,YAAY,SAAS"}
@@ -14,12 +14,14 @@ const temporalNotAvailable = {
14
14
  */
15
15
  const plainDateMapper = t ? {
16
16
  fromDb: (value) => value instanceof t.PlainDate ? value : t.PlainDate.from(value),
17
- toDb: (p) => p.toString()
17
+ toDb: (p) => p.toString(),
18
+ getUnnestMarker: () => t.PlainDate.from("2000-01-01")
18
19
  } : temporalNotAvailable;
19
20
  /** Converts Postgres `TIME` to/from Temporal.PlainTime; `fromDb` also passes binary-decoded instances through. */
20
21
  const plainTimeMapper = t ? {
21
22
  fromDb: (value) => value instanceof t.PlainTime ? value : t.PlainTime.from(value),
22
- toDb: (pt) => pt.toString()
23
+ toDb: (pt) => pt.toString(),
24
+ getUnnestMarker: () => t.PlainTime.from("00:00:00")
23
25
  } : temporalNotAvailable;
24
26
  /**
25
27
  * Converts Postgres `TIMESTAMP` / `TIMESTAMP WITHOUT TIME ZONE` to/from Temporal.PlainDateTime;
@@ -27,7 +29,8 @@ const plainTimeMapper = t ? {
27
29
  */
28
30
  const plainDateTimeMapper = t ? {
29
31
  fromDb: (value) => value instanceof t.PlainDateTime ? value : t.PlainDateTime.from(value),
30
- toDb: (p) => p.toString()
32
+ toDb: (p) => p.toString(),
33
+ getUnnestMarker: () => t.PlainDateTime.from("2000-01-01T00:00:00")
31
34
  } : temporalNotAvailable;
32
35
  /**
33
36
  * Converts Postgres `TIMESTAMPTZ`, `TIMESTAMPTZ WITH TIME ZONE` to/from Temporal.ZonedDateTime.
@@ -50,7 +53,8 @@ const zonedDateTimeMapper = t ? {
50
53
  const [offset] = value.match(/([+-]\d{2}(?::?\d{2})?)$/) ?? [];
51
54
  return t.ZonedDateTime.from(`${value}[${!offset || /^\+00(:?00)?$/.test(offset) ? "UTC" : offset}]`);
52
55
  },
53
- toDb: (zdt) => zdt.toString({ timeZoneName: "never" })
56
+ toDb: (zdt) => zdt.toString({ timeZoneName: "never" }),
57
+ getUnnestMarker: () => t.ZonedDateTime.from("2000-01-01T00:00:00+00:00[UTC]")
54
58
  } : temporalNotAvailable;
55
59
  //#endregion
56
60
  export { plainDateMapper, plainDateTimeMapper, plainTimeMapper, zonedDateTimeMapper };
@@ -1 +1 @@
1
- {"version":3,"file":"temporalMappers.js","names":[],"sources":["../../src/serde/temporalMappers.ts"],"sourcesContent":["import type { CustomSerde } from \"src/serde/serde.ts\";\nimport { type Temporal, maybeRequireTemporal } from \"src/serde/temporal.ts\";\nimport { fail } from \"src/utils.ts\";\n\nconst { Temporal: t } = maybeRequireTemporal() ?? {};\nconst temporalNotAvailable = {\n fromDb: () => fail(\"Temporal not available\"),\n toDb: () => fail(\"Temporal not available\"),\n};\n\n/**\n * Converts Postgres `DATE` to/from Temporal.PlainDate.\n *\n * `fromDb` accepts either pg's text form (classic/knex text queries, json_agg preloads) or an\n * already-constructed `PlainDate` (lazy binary queries decode wire bytes -> Temporal directly).\n */\nexport const plainDateMapper: CustomSerde<Temporal.PlainDate, string> = t\n ? {\n fromDb: (value: string | Temporal.PlainDate) => (value instanceof t.PlainDate ? value : t.PlainDate.from(value)),\n toDb: (p) => p.toString(),\n }\n : temporalNotAvailable;\n\n/** Converts Postgres `TIME` to/from Temporal.PlainTime; `fromDb` also passes binary-decoded instances through. */\nexport const plainTimeMapper: CustomSerde<Temporal.PlainTime, string> = t\n ? {\n fromDb: (value: string | Temporal.PlainTime) => (value instanceof t.PlainTime ? value : t.PlainTime.from(value)),\n toDb: (pt) => pt.toString(),\n }\n : temporalNotAvailable;\n\n/**\n * Converts Postgres `TIMESTAMP` / `TIMESTAMP WITHOUT TIME ZONE` to/from Temporal.PlainDateTime;\n * `fromDb` also passes binary-decoded instances through.\n */\nexport const plainDateTimeMapper: CustomSerde<Temporal.PlainDateTime, string> = t\n ? {\n // Text values look like `2018-01-01 10:00:00`\n fromDb: (value: string | Temporal.PlainDateTime) =>\n value instanceof t.PlainDateTime ? value : t.PlainDateTime.from(value),\n toDb: (p) => p.toString(),\n }\n : temporalNotAvailable;\n\n/**\n * Converts Postgres `TIMESTAMPTZ`, `TIMESTAMPTZ WITH TIME ZONE` to/from Temporal.ZonedDateTime.\n *\n * Specifically, Postgres uses ISO 8601, which Temporal supports as well, except that PG ouputs a space instead of `T`\n * between the date/time for output.\n *\n * Additionally, `Temporal.ZonedDateTime.from` expects a time zone literal name to be supplied as part of the string,\n * but this is not stored by postgres.\n *\n * As such, we parse the offset and append it to string passed to `from` as the time zone. This means that if we did a\n * round trip of generating a db value then parsing it, then it may not strictly equal the original zdt.\n *\n * Finally, PG stores dates as UTC and converts them to its local time zone for output, so we could get any offset\n * theoretically. If, somehow, we don't get an offset, then we assume UTC.\n */\nexport const zonedDateTimeMapper: CustomSerde<Temporal.ZonedDateTime, string> = t\n ? {\n // Produce a ZDT from a PG output like \"2021-01-01 12:00:00-05:00\"; binary-decoded\n // instances (lazy queries construct ZonedDateTimes directly) pass through\n fromDb: (value: string | Temporal.ZonedDateTime) => {\n if (typeof value !== \"string\") return value;\n const [offset] = value.match(/([+-]\\d{2}(?::?\\d{2})?)$/) ?? [];\n return t.ZonedDateTime.from(`${value}[${!offset || /^\\+00(:?00)?$/.test(offset) ? \"UTC\" : offset}]`);\n },\n // Match a PG `TIMESTAMPTZ` input format, i.e. \"2021-01-01T12:00:00-05:00\"\n toDb: (zdt) => zdt.toString({ timeZoneName: \"never\" }),\n }\n : temporalNotAvailable;\n"],"mappings":";;;AAIA,MAAM,EAAE,UAAU,MAAM,qBAAqB,KAAK,CAAC;AACnD,MAAM,uBAAuB;CAC3B,cAAc,KAAK,wBAAwB;CAC3C,YAAY,KAAK,wBAAwB;AAC3C;;;;;;;AAQA,MAAa,kBAA2D,IACpE;CACE,SAAS,UAAwC,iBAAiB,EAAE,YAAY,QAAQ,EAAE,UAAU,KAAK,KAAK;CAC9G,OAAO,MAAM,EAAE,SAAS;AAC1B,IACA;;AAGJ,MAAa,kBAA2D,IACpE;CACE,SAAS,UAAwC,iBAAiB,EAAE,YAAY,QAAQ,EAAE,UAAU,KAAK,KAAK;CAC9G,OAAO,OAAO,GAAG,SAAS;AAC5B,IACA;;;;;AAMJ,MAAa,sBAAmE,IAC5E;CAEE,SAAS,UACP,iBAAiB,EAAE,gBAAgB,QAAQ,EAAE,cAAc,KAAK,KAAK;CACvE,OAAO,MAAM,EAAE,SAAS;AAC1B,IACA;;;;;;;;;;;;;;;;AAiBJ,MAAa,sBAAmE,IAC5E;CAGE,SAAS,UAA2C;EAClD,IAAI,OAAO,UAAU,UAAU,OAAO;EACtC,MAAM,CAAC,UAAU,MAAM,MAAM,0BAA0B,KAAK,CAAC;EAC7D,OAAO,EAAE,cAAc,KAAK,GAAG,MAAM,GAAG,CAAC,UAAU,gBAAgB,KAAK,MAAM,IAAI,QAAQ,OAAO,EAAE;CACrG;CAEA,OAAO,QAAQ,IAAI,SAAS,EAAE,cAAc,QAAQ,CAAC;AACvD,IACA"}
1
+ {"version":3,"file":"temporalMappers.js","names":[],"sources":["../../src/serde/temporalMappers.ts"],"sourcesContent":["import type { CustomSerde } from \"src/serde/serde.ts\";\nimport { type Temporal, maybeRequireTemporal } from \"src/serde/temporal.ts\";\nimport { fail } from \"src/utils.ts\";\n\nconst { Temporal: t } = maybeRequireTemporal() ?? {};\nconst temporalNotAvailable = {\n fromDb: () => fail(\"Temporal not available\"),\n toDb: () => fail(\"Temporal not available\"),\n};\n\n/**\n * Converts Postgres `DATE` to/from Temporal.PlainDate.\n *\n * `fromDb` accepts either pg's text form (classic/knex text queries, json_agg preloads) or an\n * already-constructed `PlainDate` (lazy binary queries decode wire bytes -> Temporal directly).\n */\nexport const plainDateMapper: CustomSerde<Temporal.PlainDate, string> = t\n ? {\n fromDb: (value: string | Temporal.PlainDate) => (value instanceof t.PlainDate ? value : t.PlainDate.from(value)),\n toDb: (p) => p.toString(),\n getUnnestMarker: () => t.PlainDate.from(\"2000-01-01\"),\n }\n : temporalNotAvailable;\n\n/** Converts Postgres `TIME` to/from Temporal.PlainTime; `fromDb` also passes binary-decoded instances through. */\nexport const plainTimeMapper: CustomSerde<Temporal.PlainTime, string> = t\n ? {\n fromDb: (value: string | Temporal.PlainTime) => (value instanceof t.PlainTime ? value : t.PlainTime.from(value)),\n toDb: (pt) => pt.toString(),\n getUnnestMarker: () => t.PlainTime.from(\"00:00:00\"),\n }\n : temporalNotAvailable;\n\n/**\n * Converts Postgres `TIMESTAMP` / `TIMESTAMP WITHOUT TIME ZONE` to/from Temporal.PlainDateTime;\n * `fromDb` also passes binary-decoded instances through.\n */\nexport const plainDateTimeMapper: CustomSerde<Temporal.PlainDateTime, string> = t\n ? {\n // Text values look like `2018-01-01 10:00:00`\n fromDb: (value: string | Temporal.PlainDateTime) =>\n value instanceof t.PlainDateTime ? value : t.PlainDateTime.from(value),\n toDb: (p) => p.toString(),\n getUnnestMarker: () => t.PlainDateTime.from(\"2000-01-01T00:00:00\"),\n }\n : temporalNotAvailable;\n\n/**\n * Converts Postgres `TIMESTAMPTZ`, `TIMESTAMPTZ WITH TIME ZONE` to/from Temporal.ZonedDateTime.\n *\n * Specifically, Postgres uses ISO 8601, which Temporal supports as well, except that PG ouputs a space instead of `T`\n * between the date/time for output.\n *\n * Additionally, `Temporal.ZonedDateTime.from` expects a time zone literal name to be supplied as part of the string,\n * but this is not stored by postgres.\n *\n * As such, we parse the offset and append it to string passed to `from` as the time zone. This means that if we did a\n * round trip of generating a db value then parsing it, then it may not strictly equal the original zdt.\n *\n * Finally, PG stores dates as UTC and converts them to its local time zone for output, so we could get any offset\n * theoretically. If, somehow, we don't get an offset, then we assume UTC.\n */\nexport const zonedDateTimeMapper: CustomSerde<Temporal.ZonedDateTime, string> = t\n ? {\n // Produce a ZDT from a PG output like \"2021-01-01 12:00:00-05:00\"; binary-decoded\n // instances (lazy queries construct ZonedDateTimes directly) pass through\n fromDb: (value: string | Temporal.ZonedDateTime) => {\n if (typeof value !== \"string\") return value;\n const [offset] = value.match(/([+-]\\d{2}(?::?\\d{2})?)$/) ?? [];\n return t.ZonedDateTime.from(`${value}[${!offset || /^\\+00(:?00)?$/.test(offset) ? \"UTC\" : offset}]`);\n },\n // Match a PG `TIMESTAMPTZ` input format, i.e. \"2021-01-01T12:00:00-05:00\"\n toDb: (zdt) => zdt.toString({ timeZoneName: \"never\" }),\n getUnnestMarker: () => t.ZonedDateTime.from(\"2000-01-01T00:00:00+00:00[UTC]\"),\n }\n : temporalNotAvailable;\n"],"mappings":";;;AAIA,MAAM,EAAE,UAAU,MAAM,qBAAqB,KAAK,CAAC;AACnD,MAAM,uBAAuB;CAC3B,cAAc,KAAK,wBAAwB;CAC3C,YAAY,KAAK,wBAAwB;AAC3C;;;;;;;AAQA,MAAa,kBAA2D,IACpE;CACE,SAAS,UAAwC,iBAAiB,EAAE,YAAY,QAAQ,EAAE,UAAU,KAAK,KAAK;CAC9G,OAAO,MAAM,EAAE,SAAS;CACxB,uBAAuB,EAAE,UAAU,KAAK,YAAY;AACtD,IACA;;AAGJ,MAAa,kBAA2D,IACpE;CACE,SAAS,UAAwC,iBAAiB,EAAE,YAAY,QAAQ,EAAE,UAAU,KAAK,KAAK;CAC9G,OAAO,OAAO,GAAG,SAAS;CAC1B,uBAAuB,EAAE,UAAU,KAAK,UAAU;AACpD,IACA;;;;;AAMJ,MAAa,sBAAmE,IAC5E;CAEE,SAAS,UACP,iBAAiB,EAAE,gBAAgB,QAAQ,EAAE,cAAc,KAAK,KAAK;CACvE,OAAO,MAAM,EAAE,SAAS;CACxB,uBAAuB,EAAE,cAAc,KAAK,qBAAqB;AACnE,IACA;;;;;;;;;;;;;;;;AAiBJ,MAAa,sBAAmE,IAC5E;CAGE,SAAS,UAA2C;EAClD,IAAI,OAAO,UAAU,UAAU,OAAO;EACtC,MAAM,CAAC,UAAU,MAAM,MAAM,0BAA0B,KAAK,CAAC;EAC7D,OAAO,EAAE,cAAc,KAAK,GAAG,MAAM,GAAG,CAA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