joist-core 2.5.0-next.2 → 2.5.0-next.21

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 (1056) hide show
  1. package/build/BaseEntity.cjs +33 -3
  2. package/build/BaseEntity.cjs.map +1 -1
  3. package/build/BaseEntity.d.cts +6 -4
  4. package/build/BaseEntity.d.cts.map +1 -1
  5. package/build/BaseEntity.d.mts +6 -4
  6. package/build/BaseEntity.d.mts.map +1 -1
  7. package/build/BaseEntity.js +33 -4
  8. package/build/BaseEntity.js.map +1 -1
  9. package/build/Entity.cjs +2 -3
  10. package/build/Entity.d.cts +0 -2
  11. package/build/Entity.d.cts.map +1 -1
  12. package/build/Entity.d.mts +0 -2
  13. package/build/Entity.d.mts.map +1 -1
  14. package/build/Entity.js +2 -3
  15. package/build/EntityFields.d.cts +0 -2
  16. package/build/EntityFields.d.cts.map +1 -1
  17. package/build/EntityFields.d.mts +0 -2
  18. package/build/EntityFields.d.mts.map +1 -1
  19. package/build/EntityManager.cjs +185 -103
  20. package/build/EntityManager.cjs.map +1 -1
  21. package/build/EntityManager.d.cts +50 -37
  22. package/build/EntityManager.d.cts.map +1 -1
  23. package/build/EntityManager.d.mts +50 -37
  24. package/build/EntityManager.d.mts.map +1 -1
  25. package/build/EntityManager.js +185 -104
  26. package/build/EntityManager.js.map +1 -1
  27. package/build/EntityMetadata.cjs +3 -4
  28. package/build/EntityMetadata.cjs.map +1 -1
  29. package/build/EntityMetadata.d.cts +8 -6
  30. package/build/EntityMetadata.d.cts.map +1 -1
  31. package/build/EntityMetadata.d.mts +8 -6
  32. package/build/EntityMetadata.d.mts.map +1 -1
  33. package/build/EntityMetadata.js +3 -4
  34. package/build/EntityMetadata.js.map +1 -1
  35. package/build/EnumMetadata.d.cts +0 -2
  36. package/build/EnumMetadata.d.cts.map +1 -1
  37. package/build/EnumMetadata.d.mts +0 -2
  38. package/build/EnumMetadata.d.mts.map +1 -1
  39. package/build/IndexManager.cjs +4 -5
  40. package/build/IndexManager.d.cts +1 -3
  41. package/build/IndexManager.d.cts.map +1 -1
  42. package/build/IndexManager.d.mts +1 -3
  43. package/build/IndexManager.d.mts.map +1 -1
  44. package/build/IndexManager.js +4 -5
  45. package/build/InstanceData.cjs +12 -6
  46. package/build/InstanceData.cjs.map +1 -1
  47. package/build/InstanceData.d.cts +9 -5
  48. package/build/InstanceData.d.cts.map +1 -1
  49. package/build/InstanceData.d.mts +9 -5
  50. package/build/InstanceData.d.mts.map +1 -1
  51. package/build/InstanceData.js +12 -6
  52. package/build/InstanceData.js.map +1 -1
  53. package/build/PluginManager.cjs +21 -8
  54. package/build/PluginManager.cjs.map +1 -1
  55. package/build/PluginManager.d.cts +19 -7
  56. package/build/PluginManager.d.cts.map +1 -1
  57. package/build/PluginManager.d.mts +19 -7
  58. package/build/PluginManager.d.mts.map +1 -1
  59. package/build/PluginManager.js +21 -8
  60. package/build/PluginManager.js.map +1 -1
  61. package/build/RowData.cjs +1 -2
  62. package/build/RowData.d.cts +0 -2
  63. package/build/RowData.d.cts.map +1 -1
  64. package/build/RowData.d.mts +0 -2
  65. package/build/RowData.d.mts.map +1 -1
  66. package/build/RowData.js +1 -2
  67. package/build/_virtual/_rolldown/runtime.cjs +1 -2
  68. package/build/batchloaders/BatchLoader.cjs +1 -2
  69. package/build/batchloaders/BatchLoader.d.cts +0 -2
  70. package/build/batchloaders/BatchLoader.d.cts.map +1 -1
  71. package/build/batchloaders/BatchLoader.d.mts +0 -2
  72. package/build/batchloaders/BatchLoader.d.mts.map +1 -1
  73. package/build/batchloaders/BatchLoader.js +1 -2
  74. package/build/batchloaders/enumCollectionBatchLoader.cjs +4 -5
  75. package/build/batchloaders/enumCollectionBatchLoader.cjs.map +1 -1
  76. package/build/batchloaders/enumCollectionBatchLoader.d.cts +1 -3
  77. package/build/batchloaders/enumCollectionBatchLoader.d.cts.map +1 -1
  78. package/build/batchloaders/enumCollectionBatchLoader.d.mts +1 -3
  79. package/build/batchloaders/enumCollectionBatchLoader.d.mts.map +1 -1
  80. package/build/batchloaders/enumCollectionBatchLoader.js +4 -5
  81. package/build/batchloaders/enumCollectionBatchLoader.js.map +1 -1
  82. package/build/batchloaders/loadBatchLoader.cjs +9 -9
  83. package/build/batchloaders/loadBatchLoader.cjs.map +1 -1
  84. package/build/batchloaders/loadBatchLoader.d.cts +3 -5
  85. package/build/batchloaders/loadBatchLoader.d.cts.map +1 -1
  86. package/build/batchloaders/loadBatchLoader.d.mts +3 -5
  87. package/build/batchloaders/loadBatchLoader.d.mts.map +1 -1
  88. package/build/batchloaders/loadBatchLoader.js +9 -9
  89. package/build/batchloaders/loadBatchLoader.js.map +1 -1
  90. package/build/batchloaders/manyToManyBatchLoader.cjs +5 -6
  91. package/build/batchloaders/manyToManyBatchLoader.cjs.map +1 -1
  92. package/build/batchloaders/manyToManyBatchLoader.d.cts +1 -3
  93. package/build/batchloaders/manyToManyBatchLoader.d.cts.map +1 -1
  94. package/build/batchloaders/manyToManyBatchLoader.d.mts +1 -3
  95. package/build/batchloaders/manyToManyBatchLoader.d.mts.map +1 -1
  96. package/build/batchloaders/manyToManyBatchLoader.js +5 -6
  97. package/build/batchloaders/manyToManyBatchLoader.js.map +1 -1
  98. package/build/batchloaders/oneToManyBatchLoader.cjs +5 -6
  99. package/build/batchloaders/oneToManyBatchLoader.cjs.map +1 -1
  100. package/build/batchloaders/oneToManyBatchLoader.d.cts +2 -4
  101. package/build/batchloaders/oneToManyBatchLoader.d.cts.map +1 -1
  102. package/build/batchloaders/oneToManyBatchLoader.d.mts +2 -4
  103. package/build/batchloaders/oneToManyBatchLoader.d.mts.map +1 -1
  104. package/build/batchloaders/oneToManyBatchLoader.js +6 -7
  105. package/build/batchloaders/oneToManyBatchLoader.js.map +1 -1
  106. package/build/batchloaders/oneToOneBatchLoader.cjs +7 -8
  107. package/build/batchloaders/oneToOneBatchLoader.cjs.map +1 -1
  108. package/build/batchloaders/oneToOneBatchLoader.d.cts +2 -4
  109. package/build/batchloaders/oneToOneBatchLoader.d.cts.map +1 -1
  110. package/build/batchloaders/oneToOneBatchLoader.d.mts +2 -4
  111. package/build/batchloaders/oneToOneBatchLoader.d.mts.map +1 -1
  112. package/build/batchloaders/oneToOneBatchLoader.js +7 -8
  113. package/build/batchloaders/oneToOneBatchLoader.js.map +1 -1
  114. package/build/batchloaders/populateBatchLoader.cjs +14 -18
  115. package/build/batchloaders/populateBatchLoader.cjs.map +1 -1
  116. package/build/batchloaders/populateBatchLoader.d.cts +2 -4
  117. package/build/batchloaders/populateBatchLoader.d.cts.map +1 -1
  118. package/build/batchloaders/populateBatchLoader.d.mts +2 -4
  119. package/build/batchloaders/populateBatchLoader.d.mts.map +1 -1
  120. package/build/batchloaders/populateBatchLoader.js +14 -18
  121. package/build/batchloaders/populateBatchLoader.js.map +1 -1
  122. package/build/batchloaders/recursiveChildrenBatchLoader.cjs +11 -11
  123. package/build/batchloaders/recursiveChildrenBatchLoader.cjs.map +1 -1
  124. package/build/batchloaders/recursiveChildrenBatchLoader.d.cts +2 -4
  125. package/build/batchloaders/recursiveChildrenBatchLoader.d.cts.map +1 -1
  126. package/build/batchloaders/recursiveChildrenBatchLoader.d.mts +2 -4
  127. package/build/batchloaders/recursiveChildrenBatchLoader.d.mts.map +1 -1
  128. package/build/batchloaders/recursiveChildrenBatchLoader.js +11 -11
  129. package/build/batchloaders/recursiveChildrenBatchLoader.js.map +1 -1
  130. package/build/batchloaders/recursiveM2mBatchLoader.cjs +7 -8
  131. package/build/batchloaders/recursiveM2mBatchLoader.cjs.map +1 -1
  132. package/build/batchloaders/recursiveM2mBatchLoader.d.cts +2 -4
  133. package/build/batchloaders/recursiveM2mBatchLoader.d.cts.map +1 -1
  134. package/build/batchloaders/recursiveM2mBatchLoader.d.mts +2 -4
  135. package/build/batchloaders/recursiveM2mBatchLoader.d.mts.map +1 -1
  136. package/build/batchloaders/recursiveM2mBatchLoader.js +7 -8
  137. package/build/batchloaders/recursiveM2mBatchLoader.js.map +1 -1
  138. package/build/batchloaders/recursiveParentsBatchLoader.cjs +7 -8
  139. package/build/batchloaders/recursiveParentsBatchLoader.cjs.map +1 -1
  140. package/build/batchloaders/recursiveParentsBatchLoader.d.cts +2 -4
  141. package/build/batchloaders/recursiveParentsBatchLoader.d.cts.map +1 -1
  142. package/build/batchloaders/recursiveParentsBatchLoader.d.mts +2 -4
  143. package/build/batchloaders/recursiveParentsBatchLoader.d.mts.map +1 -1
  144. package/build/batchloaders/recursiveParentsBatchLoader.js +7 -8
  145. package/build/batchloaders/recursiveParentsBatchLoader.js.map +1 -1
  146. package/build/changes.cjs +7 -8
  147. package/build/changes.d.cts +3 -5
  148. package/build/changes.d.cts.map +1 -1
  149. package/build/changes.d.mts +3 -5
  150. package/build/changes.d.mts.map +1 -1
  151. package/build/changes.js +7 -8
  152. package/build/config.cjs +9 -10
  153. package/build/config.d.cts +6 -8
  154. package/build/config.d.cts.map +1 -1
  155. package/build/config.d.mts +6 -8
  156. package/build/config.d.mts.map +1 -1
  157. package/build/config.js +9 -10
  158. package/build/configure.cjs +11 -12
  159. package/build/configure.d.cts +3 -5
  160. package/build/configure.d.cts.map +1 -1
  161. package/build/configure.d.mts +3 -5
  162. package/build/configure.d.mts.map +1 -1
  163. package/build/configure.js +11 -12
  164. package/build/dataloaders/buildCandidateBatchQuery.cjs +499 -0
  165. package/build/dataloaders/buildCandidateBatchQuery.cjs.map +1 -0
  166. package/build/dataloaders/buildCandidateBatchQuery.d.cts +57 -0
  167. package/build/dataloaders/buildCandidateBatchQuery.d.cts.map +1 -0
  168. package/build/dataloaders/buildCandidateBatchQuery.d.mts +57 -0
  169. package/build/dataloaders/buildCandidateBatchQuery.d.mts.map +1 -0
  170. package/build/dataloaders/buildCandidateBatchQuery.js +498 -0
  171. package/build/dataloaders/buildCandidateBatchQuery.js.map +1 -0
  172. package/build/dataloaders/collectFindArguments.cjs +48 -0
  173. package/build/dataloaders/collectFindArguments.cjs.map +1 -0
  174. package/build/dataloaders/collectFindArguments.d.cts +31 -0
  175. package/build/dataloaders/collectFindArguments.d.cts.map +1 -0
  176. package/build/dataloaders/collectFindArguments.d.mts +31 -0
  177. package/build/dataloaders/collectFindArguments.d.mts.map +1 -0
  178. package/build/dataloaders/collectFindArguments.js +47 -0
  179. package/build/dataloaders/collectFindArguments.js.map +1 -0
  180. package/build/dataloaders/fastWhereFilterHash.cjs +3 -4
  181. package/build/dataloaders/fastWhereFilterHash.d.cts +0 -2
  182. package/build/dataloaders/fastWhereFilterHash.d.cts.map +1 -1
  183. package/build/dataloaders/fastWhereFilterHash.d.mts +0 -2
  184. package/build/dataloaders/fastWhereFilterHash.d.mts.map +1 -1
  185. package/build/dataloaders/fastWhereFilterHash.js +3 -4
  186. package/build/dataloaders/findByUniqueDataLoader.cjs +2 -3
  187. package/build/dataloaders/findByUniqueDataLoader.d.cts +2 -4
  188. package/build/dataloaders/findByUniqueDataLoader.d.cts.map +1 -1
  189. package/build/dataloaders/findByUniqueDataLoader.d.mts +2 -4
  190. package/build/dataloaders/findByUniqueDataLoader.d.mts.map +1 -1
  191. package/build/dataloaders/findByUniqueDataLoader.js +2 -3
  192. package/build/dataloaders/findCountDataLoader.cjs +8 -9
  193. package/build/dataloaders/findCountDataLoader.d.cts +3 -5
  194. package/build/dataloaders/findCountDataLoader.d.cts.map +1 -1
  195. package/build/dataloaders/findCountDataLoader.d.mts +3 -5
  196. package/build/dataloaders/findCountDataLoader.d.mts.map +1 -1
  197. package/build/dataloaders/findCountDataLoader.js +8 -9
  198. package/build/dataloaders/findDataLoader.cjs +48 -77
  199. package/build/dataloaders/findDataLoader.cjs.map +1 -1
  200. package/build/dataloaders/findDataLoader.d.cts +5 -7
  201. package/build/dataloaders/findDataLoader.d.cts.map +1 -1
  202. package/build/dataloaders/findDataLoader.d.mts +5 -7
  203. package/build/dataloaders/findDataLoader.d.mts.map +1 -1
  204. package/build/dataloaders/findDataLoader.js +48 -77
  205. package/build/dataloaders/findDataLoader.js.map +1 -1
  206. package/build/dataloaders/findIdsDataLoader.cjs +6 -7
  207. package/build/dataloaders/findIdsDataLoader.d.cts +2 -4
  208. package/build/dataloaders/findIdsDataLoader.d.cts.map +1 -1
  209. package/build/dataloaders/findIdsDataLoader.d.mts +2 -4
  210. package/build/dataloaders/findIdsDataLoader.d.mts.map +1 -1
  211. package/build/dataloaders/findIdsDataLoader.js +6 -7
  212. package/build/dataloaders/findOrCreateDataLoader.cjs +7 -8
  213. package/build/dataloaders/findOrCreateDataLoader.d.cts +2 -4
  214. package/build/dataloaders/findOrCreateDataLoader.d.cts.map +1 -1
  215. package/build/dataloaders/findOrCreateDataLoader.d.mts +2 -4
  216. package/build/dataloaders/findOrCreateDataLoader.d.mts.map +1 -1
  217. package/build/dataloaders/findOrCreateDataLoader.js +7 -8
  218. package/build/dataloaders/findPaginatedDataLoader.cjs +6 -7
  219. package/build/dataloaders/findPaginatedDataLoader.d.cts +3 -5
  220. package/build/dataloaders/findPaginatedDataLoader.d.cts.map +1 -1
  221. package/build/dataloaders/findPaginatedDataLoader.d.mts +3 -5
  222. package/build/dataloaders/findPaginatedDataLoader.d.mts.map +1 -1
  223. package/build/dataloaders/findPaginatedDataLoader.js +6 -7
  224. package/build/dataloaders/lensDataLoader.cjs +5 -6
  225. package/build/dataloaders/lensDataLoader.d.cts +1 -3
  226. package/build/dataloaders/lensDataLoader.d.cts.map +1 -1
  227. package/build/dataloaders/lensDataLoader.d.mts +1 -3
  228. package/build/dataloaders/lensDataLoader.d.mts.map +1 -1
  229. package/build/dataloaders/lensDataLoader.js +5 -6
  230. package/build/dataloaders/manyToManyFindDataLoader.cjs +1 -2
  231. package/build/dataloaders/manyToManyFindDataLoader.d.cts +2 -4
  232. package/build/dataloaders/manyToManyFindDataLoader.d.cts.map +1 -1
  233. package/build/dataloaders/manyToManyFindDataLoader.d.mts +2 -4
  234. package/build/dataloaders/manyToManyFindDataLoader.d.mts.map +1 -1
  235. package/build/dataloaders/manyToManyFindDataLoader.js +1 -2
  236. package/build/dataloaders/oneToManyFindDataLoader.cjs +7 -5
  237. package/build/dataloaders/oneToManyFindDataLoader.cjs.map +1 -1
  238. package/build/dataloaders/oneToManyFindDataLoader.d.cts +2 -4
  239. package/build/dataloaders/oneToManyFindDataLoader.d.cts.map +1 -1
  240. package/build/dataloaders/oneToManyFindDataLoader.d.mts +2 -4
  241. package/build/dataloaders/oneToManyFindDataLoader.d.mts.map +1 -1
  242. package/build/dataloaders/oneToManyFindDataLoader.js +8 -6
  243. package/build/dataloaders/oneToManyFindDataLoader.js.map +1 -1
  244. package/build/defaults.cjs +7 -8
  245. package/build/defaults.d.cts +2 -4
  246. package/build/defaults.d.cts.map +1 -1
  247. package/build/defaults.d.mts +2 -4
  248. package/build/defaults.d.mts.map +1 -1
  249. package/build/defaults.js +7 -8
  250. package/build/drivers/Driver.cjs +1 -1
  251. package/build/drivers/Driver.d.cts +2 -4
  252. package/build/drivers/Driver.d.cts.map +1 -1
  253. package/build/drivers/Driver.d.mts +2 -4
  254. package/build/drivers/Driver.d.mts.map +1 -1
  255. package/build/drivers/Driver.js +1 -1
  256. package/build/drivers/EntityWriter.cjs +6 -7
  257. package/build/drivers/EntityWriter.d.cts +1 -3
  258. package/build/drivers/EntityWriter.d.cts.map +1 -1
  259. package/build/drivers/EntityWriter.d.mts +1 -3
  260. package/build/drivers/EntityWriter.d.mts.map +1 -1
  261. package/build/drivers/EntityWriter.js +6 -7
  262. package/build/drivers/IdAssigner.cjs +7 -4
  263. package/build/drivers/IdAssigner.cjs.map +1 -1
  264. package/build/drivers/IdAssigner.d.cts +1 -2
  265. package/build/drivers/IdAssigner.d.cts.map +1 -1
  266. package/build/drivers/IdAssigner.d.mts +1 -2
  267. package/build/drivers/IdAssigner.d.mts.map +1 -1
  268. package/build/drivers/IdAssigner.js +7 -4
  269. package/build/drivers/IdAssigner.js.map +1 -1
  270. package/build/drivers/driverApi.cjs +4 -5
  271. package/build/drivers/driverApi.d.cts +2 -4
  272. package/build/drivers/driverApi.d.cts.map +1 -1
  273. package/build/drivers/driverApi.d.mts +2 -4
  274. package/build/drivers/driverApi.d.mts.map +1 -1
  275. package/build/drivers/driverApi.js +4 -5
  276. package/build/drivers/index.d.cts +1 -1
  277. package/build/drivers/index.d.mts +1 -1
  278. package/build/fields.cjs +87 -17
  279. package/build/fields.cjs.map +1 -1
  280. package/build/fields.d.cts +8 -2
  281. package/build/fields.d.cts.map +1 -1
  282. package/build/fields.d.mts +8 -2
  283. package/build/fields.d.mts.map +1 -1
  284. package/build/fields.js +87 -19
  285. package/build/fields.js.map +1 -1
  286. package/build/flush/FlushLock.cjs +1 -2
  287. package/build/flush/FlushLock.cjs.map +1 -1
  288. package/build/flush/FlushLock.d.cts +0 -2
  289. package/build/flush/FlushLock.d.cts.map +1 -1
  290. package/build/flush/FlushLock.d.mts +0 -2
  291. package/build/flush/FlushLock.d.mts.map +1 -1
  292. package/build/flush/FlushLock.js +1 -2
  293. package/build/flush/JoinRows.cjs +10 -10
  294. package/build/flush/JoinRows.cjs.map +1 -1
  295. package/build/flush/JoinRows.d.cts +2 -4
  296. package/build/flush/JoinRows.d.cts.map +1 -1
  297. package/build/flush/JoinRows.d.mts +2 -4
  298. package/build/flush/JoinRows.d.mts.map +1 -1
  299. package/build/flush/JoinRows.js +10 -10
  300. package/build/flush/JoinRows.js.map +1 -1
  301. package/build/flush/PendingChanges.d.cts +0 -2
  302. package/build/flush/PendingChanges.d.cts.map +1 -1
  303. package/build/flush/PendingChanges.d.mts +0 -2
  304. package/build/flush/PendingChanges.d.mts.map +1 -1
  305. package/build/flush/ReadDrift.cjs +7 -8
  306. package/build/flush/ReadDrift.cjs.map +1 -1
  307. package/build/flush/ReadDrift.d.cts +2 -4
  308. package/build/flush/ReadDrift.d.cts.map +1 -1
  309. package/build/flush/ReadDrift.d.mts +2 -4
  310. package/build/flush/ReadDrift.d.mts.map +1 -1
  311. package/build/flush/ReadDrift.js +7 -8
  312. package/build/flush/ReadDrift.js.map +1 -1
  313. package/build/flush/Todo.cjs +3 -4
  314. package/build/flush/Todo.d.cts +2 -4
  315. package/build/flush/Todo.d.cts.map +1 -1
  316. package/build/flush/Todo.d.mts +2 -4
  317. package/build/flush/Todo.d.mts.map +1 -1
  318. package/build/flush/Todo.js +3 -4
  319. package/build/getProperties.cjs +3 -4
  320. package/build/getProperties.d.cts +0 -2
  321. package/build/getProperties.d.cts.map +1 -1
  322. package/build/getProperties.d.mts +0 -2
  323. package/build/getProperties.d.mts.map +1 -1
  324. package/build/getProperties.js +3 -4
  325. package/build/index.cjs +59 -57
  326. package/build/index.cjs.map +1 -1
  327. package/build/index.d.cts +51 -53
  328. package/build/index.d.cts.map +1 -1
  329. package/build/index.d.mts +51 -53
  330. package/build/index.d.mts.map +1 -1
  331. package/build/index.js +59 -58
  332. package/build/index.js.map +1 -1
  333. package/build/json.cjs +12 -13
  334. package/build/json.cjs.map +1 -1
  335. package/build/json.d.cts +5 -7
  336. package/build/json.d.cts.map +1 -1
  337. package/build/json.d.mts +5 -7
  338. package/build/json.d.mts.map +1 -1
  339. package/build/json.js +12 -13
  340. package/build/json.js.map +1 -1
  341. package/build/k.cjs +1 -2
  342. package/build/k.js +1 -2
  343. package/build/keys.cjs +5 -6
  344. package/build/keys.d.cts +3 -5
  345. package/build/keys.d.cts.map +1 -1
  346. package/build/keys.d.mts +3 -5
  347. package/build/keys.d.mts.map +1 -1
  348. package/build/keys.js +5 -6
  349. package/build/loading/HintTree.cjs +1 -2
  350. package/build/loading/HintTree.d.cts +2 -4
  351. package/build/loading/HintTree.d.cts.map +1 -1
  352. package/build/loading/HintTree.d.mts +2 -4
  353. package/build/loading/HintTree.d.mts.map +1 -1
  354. package/build/loading/HintTree.js +1 -2
  355. package/build/loading/IsLoadedCache.cjs +1 -2
  356. package/build/loading/IsLoadedCache.d.cts +0 -2
  357. package/build/loading/IsLoadedCache.d.cts.map +1 -1
  358. package/build/loading/IsLoadedCache.d.mts +0 -2
  359. package/build/loading/IsLoadedCache.d.mts.map +1 -1
  360. package/build/loading/IsLoadedCache.js +1 -2
  361. package/build/loading/loadHints.cjs +1 -2
  362. package/build/loading/loadHints.d.cts +4 -6
  363. package/build/loading/loadHints.d.cts.map +1 -1
  364. package/build/loading/loadHints.d.mts +4 -6
  365. package/build/loading/loadHints.d.mts.map +1 -1
  366. package/build/loading/loadHints.js +1 -2
  367. package/build/loading/loadLens.cjs +11 -8
  368. package/build/loading/loadLens.cjs.map +1 -1
  369. package/build/loading/loadLens.d.cts +2 -4
  370. package/build/loading/loadLens.d.cts.map +1 -1
  371. package/build/loading/loadLens.d.mts +2 -4
  372. package/build/loading/loadLens.d.mts.map +1 -1
  373. package/build/loading/loadLens.js +11 -8
  374. package/build/loading/loadLens.js.map +1 -1
  375. package/build/loading/withLoaded.cjs +1 -2
  376. package/build/loading/withLoaded.d.cts +2 -4
  377. package/build/loading/withLoaded.d.cts.map +1 -1
  378. package/build/loading/withLoaded.d.mts +2 -4
  379. package/build/loading/withLoaded.d.mts.map +1 -1
  380. package/build/loading/withLoaded.js +1 -2
  381. package/build/logging/FactoryLogger.cjs +2 -3
  382. package/build/logging/FactoryLogger.d.cts +1 -3
  383. package/build/logging/FactoryLogger.d.cts.map +1 -1
  384. package/build/logging/FactoryLogger.d.mts +1 -3
  385. package/build/logging/FactoryLogger.d.mts.map +1 -1
  386. package/build/logging/FactoryLogger.js +2 -3
  387. package/build/logging/FieldLogger.cjs +1 -2
  388. package/build/logging/FieldLogger.d.cts +0 -2
  389. package/build/logging/FieldLogger.d.cts.map +1 -1
  390. package/build/logging/FieldLogger.d.mts +0 -2
  391. package/build/logging/FieldLogger.d.mts.map +1 -1
  392. package/build/logging/FieldLogger.js +1 -2
  393. package/build/logging/ReactionLogger.cjs +3 -4
  394. package/build/logging/ReactionLogger.d.cts +3 -5
  395. package/build/logging/ReactionLogger.d.cts.map +1 -1
  396. package/build/logging/ReactionLogger.d.mts +3 -5
  397. package/build/logging/ReactionLogger.d.mts.map +1 -1
  398. package/build/logging/ReactionLogger.js +3 -4
  399. package/build/metrics/EntityMetrics.cjs +1 -2
  400. package/build/metrics/EntityMetrics.d.cts +0 -2
  401. package/build/metrics/EntityMetrics.d.cts.map +1 -1
  402. package/build/metrics/EntityMetrics.d.mts +0 -2
  403. package/build/metrics/EntityMetrics.d.mts.map +1 -1
  404. package/build/metrics/EntityMetrics.js +1 -2
  405. package/build/newEntity.cjs +5 -6
  406. package/build/newEntity.cjs.map +1 -1
  407. package/build/newEntity.d.cts +2 -4
  408. package/build/newEntity.d.cts.map +1 -1
  409. package/build/newEntity.d.mts +2 -4
  410. package/build/newEntity.d.mts.map +1 -1
  411. package/build/newEntity.js +5 -6
  412. package/build/newEntity.js.map +1 -1
  413. package/build/newTestInstance.cjs +9 -10
  414. package/build/newTestInstance.d.cts +3 -5
  415. package/build/newTestInstance.d.cts.map +1 -1
  416. package/build/newTestInstance.d.mts +3 -5
  417. package/build/newTestInstance.d.mts.map +1 -1
  418. package/build/newTestInstance.js +9 -10
  419. package/build/normalizeHints.cjs +1 -2
  420. package/build/normalizeHints.d.cts +1 -3
  421. package/build/normalizeHints.d.cts.map +1 -1
  422. package/build/normalizeHints.d.mts +1 -3
  423. package/build/normalizeHints.d.mts.map +1 -1
  424. package/build/normalizeHints.js +1 -2
  425. package/build/nowUTC.cjs +1 -2
  426. package/build/nowUTC.d.cts +0 -2
  427. package/build/nowUTC.d.cts.map +1 -1
  428. package/build/nowUTC.d.mts +0 -2
  429. package/build/nowUTC.d.mts.map +1 -1
  430. package/build/nowUTC.js +1 -2
  431. package/build/plugins/ImmutableEntitiesPlugin.cjs +3 -4
  432. package/build/plugins/ImmutableEntitiesPlugin.d.cts +1 -3
  433. package/build/plugins/ImmutableEntitiesPlugin.d.cts.map +1 -1
  434. package/build/plugins/ImmutableEntitiesPlugin.d.mts +1 -3
  435. package/build/plugins/ImmutableEntitiesPlugin.d.mts.map +1 -1
  436. package/build/plugins/ImmutableEntitiesPlugin.js +3 -4
  437. package/build/plugins/PreloadPlugin.cjs +1 -1
  438. package/build/plugins/PreloadPlugin.d.cts +4 -6
  439. package/build/plugins/PreloadPlugin.d.cts.map +1 -1
  440. package/build/plugins/PreloadPlugin.d.mts +4 -6
  441. package/build/plugins/PreloadPlugin.d.mts.map +1 -1
  442. package/build/plugins/PreloadPlugin.js +1 -1
  443. package/build/preloading/JsonAggregatePreloader.cjs +13 -13
  444. package/build/preloading/JsonAggregatePreloader.cjs.map +1 -1
  445. package/build/preloading/JsonAggregatePreloader.d.cts +3 -5
  446. package/build/preloading/JsonAggregatePreloader.d.cts.map +1 -1
  447. package/build/preloading/JsonAggregatePreloader.d.mts +3 -5
  448. package/build/preloading/JsonAggregatePreloader.d.mts.map +1 -1
  449. package/build/preloading/JsonAggregatePreloader.js +13 -13
  450. package/build/preloading/JsonAggregatePreloader.js.map +1 -1
  451. package/build/preloading/canPreload.cjs +1 -2
  452. package/build/preloading/canPreload.d.cts +0 -2
  453. package/build/preloading/canPreload.d.cts.map +1 -1
  454. package/build/preloading/canPreload.d.mts +0 -2
  455. package/build/preloading/canPreload.d.mts.map +1 -1
  456. package/build/preloading/canPreload.js +1 -2
  457. package/build/preloading/partitionHint.cjs +4 -5
  458. package/build/preloading/partitionHint.d.cts +1 -3
  459. package/build/preloading/partitionHint.d.cts.map +1 -1
  460. package/build/preloading/partitionHint.d.mts +1 -3
  461. package/build/preloading/partitionHint.d.mts.map +1 -1
  462. package/build/preloading/partitionHint.js +4 -5
  463. package/build/queries/ConditionBuilder.cjs +2 -3
  464. package/build/queries/ConditionBuilder.d.cts +1 -3
  465. package/build/queries/ConditionBuilder.d.cts.map +1 -1
  466. package/build/queries/ConditionBuilder.d.mts +1 -3
  467. package/build/queries/ConditionBuilder.d.mts.map +1 -1
  468. package/build/queries/ConditionBuilder.js +2 -3
  469. package/build/queries/conditions.cjs +1 -2
  470. package/build/queries/conditions.d.cts +0 -2
  471. package/build/queries/conditions.d.cts.map +1 -1
  472. package/build/queries/conditions.d.mts +0 -2
  473. package/build/queries/conditions.d.mts.map +1 -1
  474. package/build/queries/conditions.js +1 -2
  475. package/build/queries/entityQueryUtils.cjs +2 -3
  476. package/build/queries/entityQueryUtils.d.cts +1 -3
  477. package/build/queries/entityQueryUtils.d.cts.map +1 -1
  478. package/build/queries/entityQueryUtils.d.mts +1 -3
  479. package/build/queries/entityQueryUtils.d.mts.map +1 -1
  480. package/build/queries/entityQueryUtils.js +2 -3
  481. package/build/queries/find/Aliases.cjs +4 -5
  482. package/build/queries/find/Aliases.d.cts +5 -7
  483. package/build/queries/find/Aliases.d.cts.map +1 -1
  484. package/build/queries/find/Aliases.d.mts +5 -7
  485. package/build/queries/find/Aliases.d.mts.map +1 -1
  486. package/build/queries/find/Aliases.js +4 -5
  487. package/build/queries/find/DeferredAlias.cjs +1 -2
  488. package/build/queries/find/DeferredAlias.d.cts +2 -4
  489. package/build/queries/find/DeferredAlias.d.cts.map +1 -1
  490. package/build/queries/find/DeferredAlias.d.mts +2 -4
  491. package/build/queries/find/DeferredAlias.d.mts.map +1 -1
  492. package/build/queries/find/DeferredAlias.js +1 -2
  493. package/build/queries/find/EntityFilter.cjs +1 -2
  494. package/build/queries/find/EntityFilter.d.cts +3 -5
  495. package/build/queries/find/EntityFilter.d.cts.map +1 -1
  496. package/build/queries/find/EntityFilter.d.mts +3 -5
  497. package/build/queries/find/EntityFilter.d.mts.map +1 -1
  498. package/build/queries/find/EntityFilter.js +1 -2
  499. package/build/queries/find/EntityGraphQLFilter.cjs +1 -2
  500. package/build/queries/find/EntityGraphQLFilter.d.cts +2 -4
  501. package/build/queries/find/EntityGraphQLFilter.d.cts.map +1 -1
  502. package/build/queries/find/EntityGraphQLFilter.d.mts +2 -4
  503. package/build/queries/find/EntityGraphQLFilter.d.mts.map +1 -1
  504. package/build/queries/find/EntityGraphQLFilter.js +1 -2
  505. package/build/queries/find/QueryParser.cjs +9 -10
  506. package/build/queries/find/QueryParser.cjs.map +1 -1
  507. package/build/queries/find/QueryParser.collectionJoins.cjs +1 -2
  508. package/build/queries/find/QueryParser.collectionJoins.d.cts +0 -2
  509. package/build/queries/find/QueryParser.collectionJoins.d.cts.map +1 -1
  510. package/build/queries/find/QueryParser.collectionJoins.d.mts +0 -2
  511. package/build/queries/find/QueryParser.collectionJoins.d.mts.map +1 -1
  512. package/build/queries/find/QueryParser.collectionJoins.js +1 -2
  513. package/build/queries/find/QueryParser.d.cts +4 -4
  514. package/build/queries/find/QueryParser.d.cts.map +1 -1
  515. package/build/queries/find/QueryParser.d.mts +4 -4
  516. package/build/queries/find/QueryParser.d.mts.map +1 -1
  517. package/build/queries/find/QueryParser.js +9 -10
  518. package/build/queries/find/QueryParser.js.map +1 -1
  519. package/build/queries/find/QueryParser.pruning.cjs +2 -3
  520. package/build/queries/find/QueryParser.pruning.d.cts +0 -2
  521. package/build/queries/find/QueryParser.pruning.d.cts.map +1 -1
  522. package/build/queries/find/QueryParser.pruning.d.mts +0 -2
  523. package/build/queries/find/QueryParser.pruning.d.mts.map +1 -1
  524. package/build/queries/find/QueryParser.pruning.js +2 -3
  525. package/build/queries/find/QueryVisitor.cjs +1 -2
  526. package/build/queries/find/QueryVisitor.d.cts +0 -2
  527. package/build/queries/find/QueryVisitor.d.cts.map +1 -1
  528. package/build/queries/find/QueryVisitor.d.mts +0 -2
  529. package/build/queries/find/QueryVisitor.d.mts.map +1 -1
  530. package/build/queries/find/QueryVisitor.js +1 -2
  531. package/build/queries/find/buildFindQuery.cjs +5 -6
  532. package/build/queries/find/buildFindQuery.cjs.map +1 -1
  533. package/build/queries/find/buildFindQuery.d.cts +0 -2
  534. package/build/queries/find/buildFindQuery.d.cts.map +1 -1
  535. package/build/queries/find/buildFindQuery.d.mts +0 -2
  536. package/build/queries/find/buildFindQuery.d.mts.map +1 -1
  537. package/build/queries/find/buildFindQuery.js +5 -6
  538. package/build/queries/find/buildFindQuery.js.map +1 -1
  539. package/build/queries/find/scopes.cjs +1 -2
  540. package/build/queries/find/scopes.d.cts +5 -7
  541. package/build/queries/find/scopes.d.cts.map +1 -1
  542. package/build/queries/find/scopes.d.mts +5 -7
  543. package/build/queries/find/scopes.d.mts.map +1 -1
  544. package/build/queries/find/scopes.js +1 -2
  545. package/build/queries/parsedConditions.cjs +1 -2
  546. package/build/queries/parsedConditions.d.cts +0 -2
  547. package/build/queries/parsedConditions.d.cts.map +1 -1
  548. package/build/queries/parsedConditions.d.mts +0 -2
  549. package/build/queries/parsedConditions.d.mts.map +1 -1
  550. package/build/queries/parsedConditions.js +1 -2
  551. package/build/queries/renderConditions.cjs +3 -4
  552. package/build/queries/renderConditions.d.cts +0 -2
  553. package/build/queries/renderConditions.d.cts.map +1 -1
  554. package/build/queries/renderConditions.d.mts +0 -2
  555. package/build/queries/renderConditions.d.mts.map +1 -1
  556. package/build/queries/renderConditions.js +3 -4
  557. package/build/queries/skipCondition.cjs +1 -2
  558. package/build/queries/skipCondition.d.cts +0 -2
  559. package/build/queries/skipCondition.d.cts.map +1 -1
  560. package/build/queries/skipCondition.d.mts +0 -2
  561. package/build/queries/skipCondition.d.mts.map +1 -1
  562. package/build/queries/skipCondition.js +1 -2
  563. package/build/queries/sql/AliasAssigner.cjs +1 -2
  564. package/build/queries/sql/AliasAssigner.d.cts +0 -2
  565. package/build/queries/sql/AliasAssigner.d.cts.map +1 -1
  566. package/build/queries/sql/AliasAssigner.d.mts +0 -2
  567. package/build/queries/sql/AliasAssigner.d.mts.map +1 -1
  568. package/build/queries/sql/AliasAssigner.js +1 -2
  569. package/build/queries/sql/Expr.cjs +3 -4
  570. package/build/queries/sql/Expr.d.cts +2 -4
  571. package/build/queries/sql/Expr.d.cts.map +1 -1
  572. package/build/queries/sql/Expr.d.mts +2 -4
  573. package/build/queries/sql/Expr.d.mts.map +1 -1
  574. package/build/queries/sql/Expr.js +3 -4
  575. package/build/queries/sql/JoinTree.cjs +3 -4
  576. package/build/queries/sql/JoinTree.d.cts +5 -7
  577. package/build/queries/sql/JoinTree.d.cts.map +1 -1
  578. package/build/queries/sql/JoinTree.d.mts +5 -7
  579. package/build/queries/sql/JoinTree.d.mts.map +1 -1
  580. package/build/queries/sql/JoinTree.js +3 -4
  581. package/build/queries/sql/Tables.cjs +8 -9
  582. package/build/queries/sql/Tables.d.cts +5 -7
  583. package/build/queries/sql/Tables.d.cts.map +1 -1
  584. package/build/queries/sql/Tables.d.mts +5 -7
  585. package/build/queries/sql/Tables.d.mts.map +1 -1
  586. package/build/queries/sql/Tables.js +8 -9
  587. package/build/queries/sql/custom.cjs +1 -2
  588. package/build/queries/sql/custom.d.cts +2 -4
  589. package/build/queries/sql/custom.d.cts.map +1 -1
  590. package/build/queries/sql/custom.d.mts +2 -4
  591. package/build/queries/sql/custom.d.mts.map +1 -1
  592. package/build/queries/sql/custom.js +1 -2
  593. package/build/queries/sql/execute.cjs +6 -7
  594. package/build/queries/sql/execute.d.cts +6 -8
  595. package/build/queries/sql/execute.d.cts.map +1 -1
  596. package/build/queries/sql/execute.d.mts +6 -8
  597. package/build/queries/sql/execute.d.mts.map +1 -1
  598. package/build/queries/sql/execute.js +6 -7
  599. package/build/queries/sql/expressions/arrayAgg.cjs +2 -3
  600. package/build/queries/sql/expressions/arrayAgg.d.cts +1 -3
  601. package/build/queries/sql/expressions/arrayAgg.d.cts.map +1 -1
  602. package/build/queries/sql/expressions/arrayAgg.d.mts +1 -3
  603. package/build/queries/sql/expressions/arrayAgg.d.mts.map +1 -1
  604. package/build/queries/sql/expressions/arrayAgg.js +2 -3
  605. package/build/queries/sql/expressions/case.cjs +2 -3
  606. package/build/queries/sql/expressions/case.d.cts +1 -3
  607. package/build/queries/sql/expressions/case.d.cts.map +1 -1
  608. package/build/queries/sql/expressions/case.d.mts +1 -3
  609. package/build/queries/sql/expressions/case.d.mts.map +1 -1
  610. package/build/queries/sql/expressions/case.js +2 -3
  611. package/build/queries/sql/expressions/coalesce.cjs +2 -3
  612. package/build/queries/sql/expressions/coalesce.d.cts +1 -3
  613. package/build/queries/sql/expressions/coalesce.d.cts.map +1 -1
  614. package/build/queries/sql/expressions/coalesce.d.mts +1 -3
  615. package/build/queries/sql/expressions/coalesce.d.mts.map +1 -1
  616. package/build/queries/sql/expressions/coalesce.js +2 -3
  617. package/build/queries/sql/expressions/codecs.cjs +2 -3
  618. package/build/queries/sql/expressions/codecs.d.cts +0 -2
  619. package/build/queries/sql/expressions/codecs.d.cts.map +1 -1
  620. package/build/queries/sql/expressions/codecs.d.mts +0 -2
  621. package/build/queries/sql/expressions/codecs.d.mts.map +1 -1
  622. package/build/queries/sql/expressions/codecs.js +2 -3
  623. package/build/queries/sql/expressions/expression.cjs +4 -5
  624. package/build/queries/sql/expressions/expression.d.cts +2 -4
  625. package/build/queries/sql/expressions/expression.d.cts.map +1 -1
  626. package/build/queries/sql/expressions/expression.d.mts +2 -4
  627. package/build/queries/sql/expressions/expression.d.mts.map +1 -1
  628. package/build/queries/sql/expressions/expression.js +4 -5
  629. package/build/queries/sql/expressions/greatest.cjs +2 -3
  630. package/build/queries/sql/expressions/greatest.d.cts +1 -3
  631. package/build/queries/sql/expressions/greatest.d.cts.map +1 -1
  632. package/build/queries/sql/expressions/greatest.d.mts +1 -3
  633. package/build/queries/sql/expressions/greatest.d.mts.map +1 -1
  634. package/build/queries/sql/expressions/greatest.js +2 -3
  635. package/build/queries/sql/expressions/least.cjs +2 -3
  636. package/build/queries/sql/expressions/least.d.cts +1 -3
  637. package/build/queries/sql/expressions/least.d.cts.map +1 -1
  638. package/build/queries/sql/expressions/least.d.mts +1 -3
  639. package/build/queries/sql/expressions/least.d.mts.map +1 -1
  640. package/build/queries/sql/expressions/least.js +2 -3
  641. package/build/queries/sql/expressions/nullIf.cjs +2 -3
  642. package/build/queries/sql/expressions/nullIf.d.cts +1 -3
  643. package/build/queries/sql/expressions/nullIf.d.cts.map +1 -1
  644. package/build/queries/sql/expressions/nullIf.d.mts +1 -3
  645. package/build/queries/sql/expressions/nullIf.d.mts.map +1 -1
  646. package/build/queries/sql/expressions/nullIf.js +2 -3
  647. package/build/queries/sql/expressions/parseExpression.cjs +3 -4
  648. package/build/queries/sql/expressions/parseExpression.d.cts +0 -2
  649. package/build/queries/sql/expressions/parseExpression.d.cts.map +1 -1
  650. package/build/queries/sql/expressions/parseExpression.d.mts +0 -2
  651. package/build/queries/sql/expressions/parseExpression.d.mts.map +1 -1
  652. package/build/queries/sql/expressions/parseExpression.js +3 -4
  653. package/build/queries/sql/expressions/types.d.cts +1 -3
  654. package/build/queries/sql/expressions/types.d.cts.map +1 -1
  655. package/build/queries/sql/expressions/types.d.mts +1 -3
  656. package/build/queries/sql/expressions/types.d.mts.map +1 -1
  657. package/build/queries/sql/keywords.cjs +1 -2
  658. package/build/queries/sql/keywords.d.cts +0 -2
  659. package/build/queries/sql/keywords.d.cts.map +1 -1
  660. package/build/queries/sql/keywords.d.mts +0 -2
  661. package/build/queries/sql/keywords.d.mts.map +1 -1
  662. package/build/queries/sql/keywords.js +1 -2
  663. package/build/queries/sql/query.cjs +9 -10
  664. package/build/queries/sql/query.d.cts +6 -8
  665. package/build/queries/sql/query.d.cts.map +1 -1
  666. package/build/queries/sql/query.d.mts +6 -8
  667. package/build/queries/sql/query.d.mts.map +1 -1
  668. package/build/queries/sql/query.js +9 -10
  669. package/build/queries/unnest.cjs +1 -2
  670. package/build/queries/unnest.d.cts +1 -3
  671. package/build/queries/unnest.d.cts.map +1 -1
  672. package/build/queries/unnest.d.mts +1 -3
  673. package/build/queries/unnest.d.mts.map +1 -1
  674. package/build/queries/unnest.js +1 -2
  675. package/build/queries/valueFilters.cjs +3 -4
  676. package/build/queries/valueFilters.d.cts +2 -4
  677. package/build/queries/valueFilters.d.cts.map +1 -1
  678. package/build/queries/valueFilters.d.mts +2 -4
  679. package/build/queries/valueFilters.d.mts.map +1 -1
  680. package/build/queries/valueFilters.js +3 -4
  681. package/build/reactivity/ReactionsManager.cjs +6 -7
  682. package/build/reactivity/ReactionsManager.d.cts +2 -4
  683. package/build/reactivity/ReactionsManager.d.cts.map +1 -1
  684. package/build/reactivity/ReactionsManager.d.mts +2 -4
  685. package/build/reactivity/ReactionsManager.d.mts.map +1 -1
  686. package/build/reactivity/ReactionsManager.js +6 -7
  687. package/build/reactivity/reactiveHints.cjs +8 -9
  688. package/build/reactivity/reactiveHints.d.cts +8 -10
  689. package/build/reactivity/reactiveHints.d.cts.map +1 -1
  690. package/build/reactivity/reactiveHints.d.mts +8 -10
  691. package/build/reactivity/reactiveHints.d.mts.map +1 -1
  692. package/build/reactivity/reactiveHints.js +8 -9
  693. package/build/relations/AbstractPropertyImpl.cjs +1 -2
  694. package/build/relations/AbstractPropertyImpl.d.cts +0 -2
  695. package/build/relations/AbstractPropertyImpl.d.cts.map +1 -1
  696. package/build/relations/AbstractPropertyImpl.d.mts +0 -2
  697. package/build/relations/AbstractPropertyImpl.d.mts.map +1 -1
  698. package/build/relations/AbstractPropertyImpl.js +1 -2
  699. package/build/relations/AbstractRelationImpl.cjs +1 -2
  700. package/build/relations/AbstractRelationImpl.d.cts +0 -2
  701. package/build/relations/AbstractRelationImpl.d.cts.map +1 -1
  702. package/build/relations/AbstractRelationImpl.d.mts +0 -2
  703. package/build/relations/AbstractRelationImpl.d.mts.map +1 -1
  704. package/build/relations/AbstractRelationImpl.js +1 -2
  705. package/build/relations/AsyncProperty.cjs +3 -4
  706. package/build/relations/AsyncProperty.d.cts +2 -4
  707. package/build/relations/AsyncProperty.d.cts.map +1 -1
  708. package/build/relations/AsyncProperty.d.mts +2 -4
  709. package/build/relations/AsyncProperty.d.mts.map +1 -1
  710. package/build/relations/AsyncProperty.js +3 -4
  711. package/build/relations/AsyncReactiveField.cjs +10 -11
  712. package/build/relations/AsyncReactiveField.d.cts +4 -6
  713. package/build/relations/AsyncReactiveField.d.cts.map +1 -1
  714. package/build/relations/AsyncReactiveField.d.mts +4 -6
  715. package/build/relations/AsyncReactiveField.d.mts.map +1 -1
  716. package/build/relations/AsyncReactiveField.js +10 -11
  717. package/build/relations/Collection.cjs +3 -4
  718. package/build/relations/Collection.d.cts +2 -4
  719. package/build/relations/Collection.d.cts.map +1 -1
  720. package/build/relations/Collection.d.mts +2 -4
  721. package/build/relations/Collection.d.mts.map +1 -1
  722. package/build/relations/Collection.js +3 -4
  723. package/build/relations/CustomCollection.cjs +40 -8
  724. package/build/relations/CustomCollection.cjs.map +1 -1
  725. package/build/relations/CustomCollection.d.cts +6 -6
  726. package/build/relations/CustomCollection.d.cts.map +1 -1
  727. package/build/relations/CustomCollection.d.mts +6 -6
  728. package/build/relations/CustomCollection.d.mts.map +1 -1
  729. package/build/relations/CustomCollection.js +40 -8
  730. package/build/relations/CustomCollection.js.map +1 -1
  731. package/build/relations/CustomReference.cjs +36 -8
  732. package/build/relations/CustomReference.cjs.map +1 -1
  733. package/build/relations/CustomReference.d.cts +8 -8
  734. package/build/relations/CustomReference.d.cts.map +1 -1
  735. package/build/relations/CustomReference.d.mts +8 -8
  736. package/build/relations/CustomReference.d.mts.map +1 -1
  737. package/build/relations/CustomReference.js +36 -8
  738. package/build/relations/CustomReference.js.map +1 -1
  739. package/build/relations/EnumCollection.cjs +4 -5
  740. package/build/relations/EnumCollection.d.cts +3 -5
  741. package/build/relations/EnumCollection.d.cts.map +1 -1
  742. package/build/relations/EnumCollection.d.mts +3 -5
  743. package/build/relations/EnumCollection.d.mts.map +1 -1
  744. package/build/relations/EnumCollection.js +4 -5
  745. package/build/relations/LargeCollection.cjs +2 -2
  746. package/build/relations/LargeCollection.d.cts +2 -4
  747. package/build/relations/LargeCollection.d.cts.map +1 -1
  748. package/build/relations/LargeCollection.d.mts +2 -4
  749. package/build/relations/LargeCollection.d.mts.map +1 -1
  750. package/build/relations/LargeCollection.js +2 -2
  751. package/build/relations/LazyField.cjs +14 -15
  752. package/build/relations/LazyField.cjs.map +1 -1
  753. package/build/relations/LazyField.d.cts +2 -4
  754. package/build/relations/LazyField.d.cts.map +1 -1
  755. package/build/relations/LazyField.d.mts +2 -4
  756. package/build/relations/LazyField.d.mts.map +1 -1
  757. package/build/relations/LazyField.js +14 -15
  758. package/build/relations/LazyField.js.map +1 -1
  759. package/build/relations/ManyToManyCollection.cjs +68 -13
  760. package/build/relations/ManyToManyCollection.cjs.map +1 -1
  761. package/build/relations/ManyToManyCollection.d.cts +2 -4
  762. package/build/relations/ManyToManyCollection.d.cts.map +1 -1
  763. package/build/relations/ManyToManyCollection.d.mts +2 -4
  764. package/build/relations/ManyToManyCollection.d.mts.map +1 -1
  765. package/build/relations/ManyToManyCollection.js +68 -13
  766. package/build/relations/ManyToManyCollection.js.map +1 -1
  767. package/build/relations/ManyToManyLargeCollection.cjs +35 -13
  768. package/build/relations/ManyToManyLargeCollection.cjs.map +1 -1
  769. package/build/relations/ManyToManyLargeCollection.d.cts +6 -8
  770. package/build/relations/ManyToManyLargeCollection.d.cts.map +1 -1
  771. package/build/relations/ManyToManyLargeCollection.d.mts +6 -8
  772. package/build/relations/ManyToManyLargeCollection.d.mts.map +1 -1
  773. package/build/relations/ManyToManyLargeCollection.js +35 -13
  774. package/build/relations/ManyToManyLargeCollection.js.map +1 -1
  775. package/build/relations/ManyToOneReference.cjs +35 -19
  776. package/build/relations/ManyToOneReference.cjs.map +1 -1
  777. package/build/relations/ManyToOneReference.d.cts +6 -8
  778. package/build/relations/ManyToOneReference.d.cts.map +1 -1
  779. package/build/relations/ManyToOneReference.d.mts +6 -8
  780. package/build/relations/ManyToOneReference.d.mts.map +1 -1
  781. package/build/relations/ManyToOneReference.js +35 -19
  782. package/build/relations/ManyToOneReference.js.map +1 -1
  783. package/build/relations/OneToManyCollection.cjs +71 -15
  784. package/build/relations/OneToManyCollection.cjs.map +1 -1
  785. package/build/relations/OneToManyCollection.d.cts +3 -5
  786. package/build/relations/OneToManyCollection.d.cts.map +1 -1
  787. package/build/relations/OneToManyCollection.d.mts +3 -5
  788. package/build/relations/OneToManyCollection.d.mts.map +1 -1
  789. package/build/relations/OneToManyCollection.js +71 -15
  790. package/build/relations/OneToManyCollection.js.map +1 -1
  791. package/build/relations/OneToManyLargeCollection.cjs +25 -10
  792. package/build/relations/OneToManyLargeCollection.cjs.map +1 -1
  793. package/build/relations/OneToManyLargeCollection.d.cts +4 -6
  794. package/build/relations/OneToManyLargeCollection.d.cts.map +1 -1
  795. package/build/relations/OneToManyLargeCollection.d.mts +4 -6
  796. package/build/relations/OneToManyLargeCollection.d.mts.map +1 -1
  797. package/build/relations/OneToManyLargeCollection.js +25 -10
  798. package/build/relations/OneToManyLargeCollection.js.map +1 -1
  799. package/build/relations/OneToOneReference.cjs +41 -13
  800. package/build/relations/OneToOneReference.cjs.map +1 -1
  801. package/build/relations/OneToOneReference.d.cts +6 -8
  802. package/build/relations/OneToOneReference.d.cts.map +1 -1
  803. package/build/relations/OneToOneReference.d.mts +6 -8
  804. package/build/relations/OneToOneReference.d.mts.map +1 -1
  805. package/build/relations/OneToOneReference.js +41 -13
  806. package/build/relations/OneToOneReference.js.map +1 -1
  807. package/build/relations/PolymorphicReference.cjs +33 -17
  808. package/build/relations/PolymorphicReference.cjs.map +1 -1
  809. package/build/relations/PolymorphicReference.d.cts +5 -7
  810. package/build/relations/PolymorphicReference.d.cts.map +1 -1
  811. package/build/relations/PolymorphicReference.d.mts +5 -7
  812. package/build/relations/PolymorphicReference.d.mts.map +1 -1
  813. package/build/relations/PolymorphicReference.js +33 -17
  814. package/build/relations/PolymorphicReference.js.map +1 -1
  815. package/build/relations/PropertySymbols.cjs +1 -2
  816. package/build/relations/PropertySymbols.d.cts +0 -2
  817. package/build/relations/PropertySymbols.d.cts.map +1 -1
  818. package/build/relations/PropertySymbols.d.mts +0 -2
  819. package/build/relations/PropertySymbols.d.mts.map +1 -1
  820. package/build/relations/PropertySymbols.js +1 -2
  821. package/build/relations/ReactiveField.cjs +9 -10
  822. package/build/relations/ReactiveField.d.cts +4 -6
  823. package/build/relations/ReactiveField.d.cts.map +1 -1
  824. package/build/relations/ReactiveField.d.mts +4 -6
  825. package/build/relations/ReactiveField.d.mts.map +1 -1
  826. package/build/relations/ReactiveField.js +9 -10
  827. package/build/relations/ReactiveGetter.cjs +2 -3
  828. package/build/relations/ReactiveGetter.d.cts +2 -4
  829. package/build/relations/ReactiveGetter.d.cts.map +1 -1
  830. package/build/relations/ReactiveGetter.d.mts +2 -4
  831. package/build/relations/ReactiveGetter.d.mts.map +1 -1
  832. package/build/relations/ReactiveGetter.js +2 -3
  833. package/build/relations/ReactiveManyToMany.cjs +59 -17
  834. package/build/relations/ReactiveManyToMany.cjs.map +1 -1
  835. package/build/relations/ReactiveManyToMany.d.cts +7 -6
  836. package/build/relations/ReactiveManyToMany.d.cts.map +1 -1
  837. package/build/relations/ReactiveManyToMany.d.mts +7 -6
  838. package/build/relations/ReactiveManyToMany.d.mts.map +1 -1
  839. package/build/relations/ReactiveManyToMany.js +59 -17
  840. package/build/relations/ReactiveManyToMany.js.map +1 -1
  841. package/build/relations/ReactiveManyToManyOtherSide.cjs +41 -10
  842. package/build/relations/ReactiveManyToManyOtherSide.cjs.map +1 -1
  843. package/build/relations/ReactiveManyToManyOtherSide.d.cts +4 -6
  844. package/build/relations/ReactiveManyToManyOtherSide.d.cts.map +1 -1
  845. package/build/relations/ReactiveManyToManyOtherSide.d.mts +4 -6
  846. package/build/relations/ReactiveManyToManyOtherSide.d.mts.map +1 -1
  847. package/build/relations/ReactiveManyToManyOtherSide.js +41 -10
  848. package/build/relations/ReactiveManyToManyOtherSide.js.map +1 -1
  849. package/build/relations/ReactiveReference.cjs +29 -12
  850. package/build/relations/ReactiveReference.cjs.map +1 -1
  851. package/build/relations/ReactiveReference.d.cts +7 -9
  852. package/build/relations/ReactiveReference.d.cts.map +1 -1
  853. package/build/relations/ReactiveReference.d.mts +7 -9
  854. package/build/relations/ReactiveReference.d.mts.map +1 -1
  855. package/build/relations/ReactiveReference.js +29 -12
  856. package/build/relations/ReactiveReference.js.map +1 -1
  857. package/build/relations/ReadOnlyCollection.cjs +3 -4
  858. package/build/relations/ReadOnlyCollection.d.cts +1 -3
  859. package/build/relations/ReadOnlyCollection.d.cts.map +1 -1
  860. package/build/relations/ReadOnlyCollection.d.mts +1 -3
  861. package/build/relations/ReadOnlyCollection.d.mts.map +1 -1
  862. package/build/relations/ReadOnlyCollection.js +3 -4
  863. package/build/relations/RecursiveCollection.cjs +60 -11
  864. package/build/relations/RecursiveCollection.cjs.map +1 -1
  865. package/build/relations/RecursiveCollection.d.cts +3 -5
  866. package/build/relations/RecursiveCollection.d.cts.map +1 -1
  867. package/build/relations/RecursiveCollection.d.mts +3 -5
  868. package/build/relations/RecursiveCollection.d.mts.map +1 -1
  869. package/build/relations/RecursiveCollection.js +60 -11
  870. package/build/relations/RecursiveCollection.js.map +1 -1
  871. package/build/relations/RecursiveCycleError.cjs +1 -2
  872. package/build/relations/RecursiveCycleError.d.cts +0 -2
  873. package/build/relations/RecursiveCycleError.d.cts.map +1 -1
  874. package/build/relations/RecursiveCycleError.d.mts +0 -2
  875. package/build/relations/RecursiveCycleError.d.mts.map +1 -1
  876. package/build/relations/RecursiveCycleError.js +1 -2
  877. package/build/relations/Reference.cjs +4 -5
  878. package/build/relations/Reference.d.cts +3 -5
  879. package/build/relations/Reference.d.cts.map +1 -1
  880. package/build/relations/Reference.d.mts +3 -5
  881. package/build/relations/Reference.d.mts.map +1 -1
  882. package/build/relations/Reference.js +4 -5
  883. package/build/relations/ReferenceSymbols.cjs +1 -2
  884. package/build/relations/ReferenceSymbols.d.cts +0 -2
  885. package/build/relations/ReferenceSymbols.d.cts.map +1 -1
  886. package/build/relations/ReferenceSymbols.d.mts +0 -2
  887. package/build/relations/ReferenceSymbols.d.mts.map +1 -1
  888. package/build/relations/ReferenceSymbols.js +1 -2
  889. package/build/relations/Relation.cjs +3 -4
  890. package/build/relations/Relation.d.cts +1 -3
  891. package/build/relations/Relation.d.cts.map +1 -1
  892. package/build/relations/Relation.d.mts +1 -3
  893. package/build/relations/Relation.d.mts.map +1 -1
  894. package/build/relations/Relation.js +3 -4
  895. package/build/relations/RelationSymbols.cjs +1 -2
  896. package/build/relations/RelationSymbols.d.cts +0 -2
  897. package/build/relations/RelationSymbols.d.cts.map +1 -1
  898. package/build/relations/RelationSymbols.d.mts +0 -2
  899. package/build/relations/RelationSymbols.d.mts.map +1 -1
  900. package/build/relations/RelationSymbols.js +1 -2
  901. package/build/relations/hasAsyncMethod.cjs +6 -7
  902. package/build/relations/hasAsyncMethod.d.cts +2 -4
  903. package/build/relations/hasAsyncMethod.d.cts.map +1 -1
  904. package/build/relations/hasAsyncMethod.d.mts +2 -4
  905. package/build/relations/hasAsyncMethod.d.mts.map +1 -1
  906. package/build/relations/hasAsyncMethod.js +6 -7
  907. package/build/relations/hasManyDerived.cjs +5 -6
  908. package/build/relations/hasManyDerived.cjs.map +1 -1
  909. package/build/relations/hasManyDerived.d.cts +2 -4
  910. package/build/relations/hasManyDerived.d.cts.map +1 -1
  911. package/build/relations/hasManyDerived.d.mts +2 -4
  912. package/build/relations/hasManyDerived.d.mts.map +1 -1
  913. package/build/relations/hasManyDerived.js +5 -6
  914. package/build/relations/hasManyDerived.js.map +1 -1
  915. package/build/relations/hasManyThrough.cjs +4 -5
  916. package/build/relations/hasManyThrough.cjs.map +1 -1
  917. package/build/relations/hasManyThrough.d.cts +0 -2
  918. package/build/relations/hasManyThrough.d.cts.map +1 -1
  919. package/build/relations/hasManyThrough.d.mts +0 -2
  920. package/build/relations/hasManyThrough.d.mts.map +1 -1
  921. package/build/relations/hasManyThrough.js +4 -5
  922. package/build/relations/hasManyThrough.js.map +1 -1
  923. package/build/relations/hasOneDerived.cjs +5 -6
  924. package/build/relations/hasOneDerived.cjs.map +1 -1
  925. package/build/relations/hasOneDerived.d.cts +2 -4
  926. package/build/relations/hasOneDerived.d.cts.map +1 -1
  927. package/build/relations/hasOneDerived.d.mts +2 -4
  928. package/build/relations/hasOneDerived.d.mts.map +1 -1
  929. package/build/relations/hasOneDerived.js +5 -6
  930. package/build/relations/hasOneDerived.js.map +1 -1
  931. package/build/relations/hasOneThrough.cjs +4 -5
  932. package/build/relations/hasOneThrough.cjs.map +1 -1
  933. package/build/relations/hasOneThrough.d.cts +0 -2
  934. package/build/relations/hasOneThrough.d.cts.map +1 -1
  935. package/build/relations/hasOneThrough.d.mts +0 -2
  936. package/build/relations/hasOneThrough.d.mts.map +1 -1
  937. package/build/relations/hasOneThrough.js +4 -5
  938. package/build/relations/hasOneThrough.js.map +1 -1
  939. package/build/relations/hasProperty.cjs +5 -6
  940. package/build/relations/hasProperty.d.cts +2 -4
  941. package/build/relations/hasProperty.d.cts.map +1 -1
  942. package/build/relations/hasProperty.d.mts +2 -4
  943. package/build/relations/hasProperty.d.mts.map +1 -1
  944. package/build/relations/hasProperty.js +5 -6
  945. package/build/relations/hasReactiveAsyncMethod.cjs +5 -6
  946. package/build/relations/hasReactiveAsyncMethod.d.cts +3 -5
  947. package/build/relations/hasReactiveAsyncMethod.d.cts.map +1 -1
  948. package/build/relations/hasReactiveAsyncMethod.d.mts +3 -5
  949. package/build/relations/hasReactiveAsyncMethod.d.mts.map +1 -1
  950. package/build/relations/hasReactiveAsyncMethod.js +5 -6
  951. package/build/relations/index.cjs +9 -9
  952. package/build/relations/index.d.cts +3 -3
  953. package/build/relations/index.d.mts +3 -3
  954. package/build/relations/index.js +9 -9
  955. package/build/relations/isCascadeDelete.cjs +1 -2
  956. package/build/relations/isCascadeDelete.d.cts +0 -2
  957. package/build/relations/isCascadeDelete.d.cts.map +1 -1
  958. package/build/relations/isCascadeDelete.d.mts +0 -2
  959. package/build/relations/isCascadeDelete.d.mts.map +1 -1
  960. package/build/relations/isCascadeDelete.js +1 -2
  961. package/build/relations/relationVisibility.cjs +51 -0
  962. package/build/relations/relationVisibility.cjs.map +1 -0
  963. package/build/relations/relationVisibility.d.cts +10 -0
  964. package/build/relations/relationVisibility.d.cts.map +1 -0
  965. package/build/relations/relationVisibility.d.mts +10 -0
  966. package/build/relations/relationVisibility.d.mts.map +1 -0
  967. package/build/relations/relationVisibility.js +47 -0
  968. package/build/relations/relationVisibility.js.map +1 -0
  969. package/build/resurrection.cjs +4 -5
  970. package/build/resurrection.d.cts +2 -4
  971. package/build/resurrection.d.cts.map +1 -1
  972. package/build/resurrection.d.mts +2 -4
  973. package/build/resurrection.d.mts.map +1 -1
  974. package/build/resurrection.js +4 -5
  975. package/build/rules.cjs +6 -7
  976. package/build/rules.d.cts +3 -5
  977. package/build/rules.d.cts.map +1 -1
  978. package/build/rules.d.mts +3 -5
  979. package/build/rules.d.mts.map +1 -1
  980. package/build/rules.js +6 -7
  981. package/build/runtimeConfig.cjs +1 -2
  982. package/build/runtimeConfig.d.cts +0 -2
  983. package/build/runtimeConfig.d.cts.map +1 -1
  984. package/build/runtimeConfig.d.mts +0 -2
  985. package/build/runtimeConfig.d.mts.map +1 -1
  986. package/build/runtimeConfig.js +1 -2
  987. package/build/serde/TypeInfo.cjs +1 -2
  988. package/build/serde/TypeInfo.d.cts +0 -2
  989. package/build/serde/TypeInfo.d.cts.map +1 -1
  990. package/build/serde/TypeInfo.d.mts +0 -2
  991. package/build/serde/TypeInfo.d.mts.map +1 -1
  992. package/build/serde/TypeInfo.js +1 -2
  993. package/build/serde/columns.cjs +1 -2
  994. package/build/serde/columns.d.cts +2 -4
  995. package/build/serde/columns.d.cts.map +1 -1
  996. package/build/serde/columns.d.mts +2 -4
  997. package/build/serde/columns.d.mts.map +1 -1
  998. package/build/serde/columns.js +1 -2
  999. package/build/serde/fieldSerde.cjs +4 -5
  1000. package/build/serde/fieldSerde.d.cts +4 -6
  1001. package/build/serde/fieldSerde.d.cts.map +1 -1
  1002. package/build/serde/fieldSerde.d.mts +4 -6
  1003. package/build/serde/fieldSerde.d.mts.map +1 -1
  1004. package/build/serde/fieldSerde.js +4 -5
  1005. package/build/serde/serde.cjs +4 -5
  1006. package/build/serde/serde.cjs.map +1 -1
  1007. package/build/serde/serde.d.cts +0 -2
  1008. package/build/serde/serde.d.cts.map +1 -1
  1009. package/build/serde/serde.d.mts +0 -2
  1010. package/build/serde/serde.d.mts.map +1 -1
  1011. package/build/serde/serde.js +4 -5
  1012. package/build/serde/temporal.cjs +1 -2
  1013. package/build/serde/temporal.cjs.map +1 -1
  1014. package/build/serde/temporal.d.cts +0 -2
  1015. package/build/serde/temporal.d.cts.map +1 -1
  1016. package/build/serde/temporal.d.mts +0 -2
  1017. package/build/serde/temporal.d.mts.map +1 -1
  1018. package/build/serde/temporal.js +1 -2
  1019. package/build/serde/temporalMappers.cjs +1 -2
  1020. package/build/serde/temporalMappers.d.cts +1 -3
  1021. package/build/serde/temporalMappers.d.cts.map +1 -1
  1022. package/build/serde/temporalMappers.d.mts +1 -3
  1023. package/build/serde/temporalMappers.d.mts.map +1 -1
  1024. package/build/serde/temporalMappers.js +1 -2
  1025. package/build/transitions.cjs +2 -3
  1026. package/build/transitions.d.cts +3 -5
  1027. package/build/transitions.d.cts.map +1 -1
  1028. package/build/transitions.d.mts +3 -5
  1029. package/build/transitions.d.mts.map +1 -1
  1030. package/build/transitions.js +2 -3
  1031. package/build/trusted.cjs +1 -2
  1032. package/build/trusted.cjs.map +1 -1
  1033. package/build/trusted.d.cts +0 -2
  1034. package/build/trusted.d.cts.map +1 -1
  1035. package/build/trusted.d.mts +0 -2
  1036. package/build/trusted.d.mts.map +1 -1
  1037. package/build/trusted.js +1 -2
  1038. package/build/typeMap.cjs +1 -1
  1039. package/build/typeMap.d.cts +1 -3
  1040. package/build/typeMap.d.cts.map +1 -1
  1041. package/build/typeMap.d.mts +1 -3
  1042. package/build/typeMap.d.mts.map +1 -1
  1043. package/build/typeMap.js +1 -1
  1044. package/build/upsert.cjs +7 -8
  1045. package/build/upsert.d.cts +3 -5
  1046. package/build/upsert.d.cts.map +1 -1
  1047. package/build/upsert.d.mts +3 -5
  1048. package/build/upsert.d.mts.map +1 -1
  1049. package/build/upsert.js +7 -8
  1050. package/build/utils.cjs +3 -4
  1051. package/build/utils.d.cts +2 -4
  1052. package/build/utils.d.cts.map +1 -1
  1053. package/build/utils.d.mts +2 -4
  1054. package/build/utils.d.mts.map +1 -1
  1055. package/build/utils.js +3 -4
  1056. package/package.json +6 -6
package/build/index.js CHANGED
@@ -1,27 +1,28 @@
1
- import { Temporal, maybeRequireTemporal, requireTemporal } from "./serde/temporal.js";
1
+ import { BaseEntity, getInstanceData } from "./BaseEntity.js";
2
+ import { getDefaultDependencies } from "./defaults.js";
2
3
  import { isCollection, isLoadedCollection } from "./relations/Collection.js";
3
- import { UnknownProperty, getLazyFields, getProperties } from "./getProperties.js";
4
- import { lazyField } from "./newEntity.js";
5
- import { AbstractRelationImpl } from "./relations/AbstractRelationImpl.js";
4
+ import { isEntity } from "./Entity.js";
5
+ import { EntityManager, FailedFlushError, NotFoundError, ReadOnlyError, TooManyError, appendStack, createRowFromEntityData, driverAfterBegin, driverAfterCommit, driverBeforeBegin, driverBeforeCommit, getDefaultEntityLimit, getEmInternalApi, hasVisibilityHook, invokeRule, isDefined, isId, isKey, resetDefaultEntityLimit, sameEntity, sameReference, setDefaultEntityLimit, setLastNow } from "./EntityManager.js";
6
+ import { getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getMetadata, getMetadataForField, getSubMetas, isCollectionField, isManyToManyEnumField, isManyToManyField, isManyToOneField, isOneToManyField, isOneToOneField, isPolymorphicField, isReferenceField } from "./EntityMetadata.js";
6
7
  import { CustomCollection, hasCustomCollection } from "./relations/CustomCollection.js";
7
8
  import { EnumCollectionImpl, hasEnumCollection } from "./relations/EnumCollection.js";
8
9
  import { CustomReference, hasCustomReference } from "./relations/CustomReference.js";
9
- import { deepNormalizeHint, normalizeHint } from "./normalizeHints.js";
10
- import { EntityMetrics } from "./metrics/EntityMetrics.js";
10
+ import { getField, isChangeableField, isFieldSet, setField } from "./fields.js";
11
+ import { UnknownProperty, getLazyFields, getProperties } from "./getProperties.js";
11
12
  import { hasReactiveAsyncMethod } from "./relations/hasReactiveAsyncMethod.js";
12
13
  import { hasReactiveGetter, isReactiveGetter } from "./relations/ReactiveGetter.js";
13
14
  import { isRelation } from "./relations/Relation.js";
14
15
  import { isLoadedReadOnlyCollection, isReadOnlyCollection } from "./relations/ReadOnlyCollection.js";
15
16
  import { RecursiveCycleError } from "./relations/RecursiveCycleError.js";
16
17
  import { hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents } from "./relations/RecursiveCollection.js";
17
- import { convertToLoadHint, isTypeOrSubType, reverseReactiveHint } from "./reactivity/reactiveHints.js";
18
- import { assertLoaded, ensureLoaded, isLoaded, isNew, maybePopulateThen, unsafeLoaded } from "./loading/loadHints.js";
18
+ import { getLens, getLensPath, isAllSqlPaths, isLensLoaded, isLensLoadedPath, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, mapPathsToTarget } from "./loading/loadLens.js";
19
+ import { FactoryInitialValue, defaultValue, factories, getTestIndex, isFactoryCreation, maybeBranchValue, maybeNew, maybeNewPoly, newTestInstance, noValue, setFactoryLogging, testIndex } from "./newTestInstance.js";
19
20
  import { hasAsyncMethod } from "./relations/hasAsyncMethod.js";
20
21
  import { PropertyImpl, hasProperty, hasReactiveProperty, isLoadedProperty, isProperty } from "./relations/hasProperty.js";
21
22
  import { AsyncPropertyImpl, hasAsyncProperty, isAsyncProperty, isLoadedAsyncProperty } from "./relations/AsyncProperty.js";
22
- import { assertIdIsTagged, assertIdsAreTagged, deTagId, deTagIds, ensureTagged, isTaggedId, keyToNumber, keyToTaggedId, maybeResolveReferenceToId, setTaggedIdDelimiter, tagFromId, tagId, tagIds, taggedIdPrefix, toIdOf, toTaggedId, unsafeDeTagIds } from "./keys.js";
23
- import { kq, kqDot, kqStar } from "./queries/sql/keywords.js";
24
- import { PojoRowData, emptyRowData } from "./RowData.js";
23
+ import { partitionHint } from "./preloading/partitionHint.js";
24
+ import { buildValueCondition, buildWhereClause } from "./queries/renderConditions.js";
25
+ import { AbstractRelationImpl } from "./relations/AbstractRelationImpl.js";
25
26
  import { LazyFieldImpl, hasLazyField, isLazyField, isLoadedLazyField } from "./relations/LazyField.js";
26
27
  import { hasManyDerived } from "./relations/hasManyDerived.js";
27
28
  import { hasManyThrough } from "./relations/hasManyThrough.js";
@@ -30,78 +31,77 @@ import { hasOneDerived } from "./relations/hasOneDerived.js";
30
31
  import { hasOneThrough } from "./relations/hasOneThrough.js";
31
32
  import { ManyToManyCollection, hasManyToMany } from "./relations/ManyToManyCollection.js";
32
33
  import { ManyToManyLargeCollection, hasLargeManyToMany } from "./relations/ManyToManyLargeCollection.js";
33
- import { skipCondition } from "./queries/skipCondition.js";
34
+ import { AsyncReactiveFieldImpl, hasAsyncReactiveField, isAsyncReactiveField } from "./relations/AsyncReactiveField.js";
35
+ import "./relations/index.js";
36
+ import { ReactiveFieldImpl, hasReactiveField, isReactiveField } from "./relations/ReactiveField.js";
37
+ import "./typeMap.js";
38
+ import { abbreviation, asNew, assertNever, cleanSql, cleanStringValue, fail, failIfAnyRejected, indexBy, partition, zeroTo } from "./utils.js";
39
+ import { AliasAssigner } from "./queries/sql/AliasAssigner.js";
34
40
  import { alias, aliases, getAliasMetadata, getAliasMgmt, getMaybeCtiAlias, isAlias, newAliasProxy } from "./queries/find/Aliases.js";
35
- import { isScope, isScopeJoinFilter, isSelectAllFilter, newScopeFn, resolveScope } from "./queries/find/scopes.js";
36
- import { makeLike, mapToDb, parseEntityFilter, parseValueFilter } from "./queries/valueFilters.js";
37
- import { ConditionBuilder } from "./queries/ConditionBuilder.js";
38
- import { filterSoftDeletes, lazyExcludedSelects, maybeAddNotSoftDeleted, stiSubtypeFilter } from "./queries/entityQueryUtils.js";
39
- import { visitConditions } from "./queries/find/QueryVisitor.js";
40
- import { exprBrand } from "./queries/sql/Expr.js";
41
- import { addTablePerClassJoinsAndClassTag, findFilterField, getTables, maybeAddIdNotNulls, maybeAddOrderBy, parseAlias, parseFindQuery } from "./queries/find/QueryParser.js";
41
+ import { getTableMetadata, getTableMgmt, isTable, newTableProxy, table, tableMgmt, tables } from "./queries/sql/Tables.js";
42
+ import { declareTable } from "./queries/sql/custom.js";
42
43
  import { OneToManyCollection, hasMany } from "./relations/OneToManyCollection.js";
43
44
  import { ManyToOneReferenceImpl, hasOne, isManyToOneReference } from "./relations/ManyToOneReference.js";
44
45
  import { OneToManyLargeCollection, hasLargeMany } from "./relations/OneToManyLargeCollection.js";
45
46
  import { ReactiveReferenceImpl, hasReactiveReference, isReactiveReference } from "./relations/ReactiveReference.js";
46
47
  import { OneToOneReferenceImpl, hasOneToOne, isLoadedOneToOneReference, isOneToOneReference } from "./relations/OneToOneReference.js";
47
48
  import { PolymorphicReferenceImpl, hasOnePolymorphic, isPolymorphicReference } from "./relations/PolymorphicReference.js";
48
- import { ReactiveFieldImpl, hasReactiveField, isReactiveField } from "./relations/ReactiveField.js";
49
+ import { ConditionBuilder } from "./queries/ConditionBuilder.js";
49
50
  import { ReactiveManyToManyImpl, hasReactiveManyToMany, isReactiveManyToMany } from "./relations/ReactiveManyToMany.js";
50
51
  import { ReactiveManyToManyOtherSideImpl, hasReactiveManyToManyOtherSide, isReactiveManyToManyOtherSide } from "./relations/ReactiveManyToManyOtherSide.js";
51
- import { AsyncReactiveFieldImpl, hasAsyncReactiveField, isAsyncReactiveField } from "./relations/AsyncReactiveField.js";
52
- import "./relations/index.js";
53
- import { abbreviation, asNew, assertNever, cleanSql, cleanStringValue, fail, failIfAnyRejected, indexBy, partition, zeroTo } from "./utils.js";
54
- import { getField, isChangeableField, isFieldSet, setField } from "./fields.js";
55
- import { ReadDriftError } from "./flush/ReadDrift.js";
56
- import "./typeMap.js";
57
- import { newChangesProxy } from "./changes.js";
58
- import { ValidationCode, ValidationErrors, cannotBeChanged, cannotBeUpdated, maxValueRule, minValueRule, mustBeSubType, newRequiredLazyFieldRule, newRequiredRule, rangeValueRule } from "./rules.js";
59
- import { ConfigApi, resetBootFlag } from "./config.js";
60
- import { getRuntimeConfig, setRuntimeConfig } from "./runtimeConfig.js";
61
- import { FieldColumn, PolyComponent, PolymorphicKeySerde, SimpleFieldSerde, hasSerde, polymorphicField } from "./serde/fieldSerde.js";
62
- import { configureMetadata, getConstructorFromTaggedId, getMetadataForTable, getMetadataForType, maybeGetConstructorFromReference } from "./configure.js";
63
- import { getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getMetadata, getMetadataForField, getSubMetas, isCollectionField, isManyToManyEnumField, isManyToManyField, isManyToOneField, isOneToManyField, isOneToOneField, isPolymorphicField, isReferenceField } from "./EntityMetadata.js";
64
- import { isInTrustedContext, runInTrustedContext } from "./trusted.js";
65
- import { getDefaultDependencies } from "./defaults.js";
66
- import { getLens, getLensPath, isAllSqlPaths, isLensLoaded, isLensLoadedPath, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, mapPathsToTarget } from "./loading/loadLens.js";
67
- import { setFactoryWriter } from "./logging/FactoryLogger.js";
68
- import { FactoryInitialValue, defaultValue, factories, getTestIndex, isFactoryCreation, maybeBranchValue, maybeNew, maybeNewPoly, newTestInstance, noValue, setFactoryLogging, testIndex } from "./newTestInstance.js";
69
- import { partitionHint } from "./preloading/partitionHint.js";
70
- import { opToFn, operators } from "./queries/find/EntityGraphQLFilter.js";
71
- import { buildValueCondition, buildWhereClause } from "./queries/renderConditions.js";
72
- import { AliasAssigner } from "./queries/sql/AliasAssigner.js";
73
- import { Column } from "./serde/columns.js";
74
- import { plainDateMapper, plainDateTimeMapper, plainTimeMapper, zonedDateTimeMapper } from "./serde/temporalMappers.js";
75
- import { BigIntSerde, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, EnumArrayFieldSerde, EnumFieldSerde, JsonSerde, KeySerde, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, PrimitiveSerde, SuperstructSerde, VectorSerde, ZodSerde, ZonedDateTimeSerde } from "./serde/serde.js";
76
- import { declareTable } from "./queries/sql/custom.js";
77
- import { getTableMetadata, getTableMgmt, isTable, newTableProxy, table, tableMgmt, tables } from "./queries/sql/Tables.js";
78
52
  import { mergeFindOptions } from "./queries/find/EntityFilter.js";
53
+ import { opToFn, operators } from "./queries/find/EntityGraphQLFilter.js";
54
+ import { ReadDriftError } from "./flush/ReadDrift.js";
55
+ import { EntityMetrics } from "./metrics/EntityMetrics.js";
56
+ import { exprBrand } from "./queries/sql/Expr.js";
79
57
  import { expr } from "./queries/sql/expressions/expression.js";
58
+ import { skipCondition } from "./queries/skipCondition.js";
80
59
  import { InstanceData } from "./InstanceData.js";
81
60
  import { JoinRowOperation } from "./flush/JoinRows.js";
82
61
  import { Plugin } from "./PluginManager.js";
62
+ import { addTablePerClassJoinsAndClassTag, findFilterField, getTables, maybeAddIdNotNulls, maybeAddOrderBy, parseAlias, parseFindQuery } from "./queries/find/QueryParser.js";
83
63
  import { buildCteSql, buildRawQuery } from "./queries/find/buildFindQuery.js";
64
+ import { makeLike, mapToDb, parseEntityFilter, parseValueFilter } from "./queries/valueFilters.js";
65
+ import { filterSoftDeletes, lazyExcludedSelects, maybeAddNotSoftDeleted, stiSubtypeFilter } from "./queries/entityQueryUtils.js";
84
66
  import { optimizeCollectionJoins } from "./queries/find/QueryParser.collectionJoins.js";
67
+ import { visitConditions } from "./queries/find/QueryVisitor.js";
68
+ import { PojoRowData, emptyRowData } from "./RowData.js";
85
69
  import { Todo } from "./flush/Todo.js";
86
- import { buildUnnestCte, ensureRectangularArraySizes } from "./queries/unnest.js";
87
- import { generateOps } from "./drivers/EntityWriter.js";
70
+ import { newChangesProxy } from "./changes.js";
71
+ import { ConfigApi, resetBootFlag } from "./config.js";
72
+ import { configureMetadata, getConstructorFromTaggedId, getMetadataForTable, getMetadataForType, maybeGetConstructorFromReference } from "./configure.js";
88
73
  import { driverApi } from "./drivers/driverApi.js";
89
- import { RandomUuidAssigner, SequenceIdAssigner, TestUuidAssigner } from "./drivers/IdAssigner.js";
90
74
  import "./drivers/index.js";
91
75
  import { toJSON } from "./json.js";
76
+ import { assertIdIsTagged, assertIdsAreTagged, deTagId, deTagIds, ensureTagged, isTaggedId, keyToNumber, keyToTaggedId, maybeResolveReferenceToId, setTaggedIdDelimiter, tagFromId, tagId, tagIds, taggedIdPrefix, toIdOf, toTaggedId, unsafeDeTagIds } from "./keys.js";
77
+ import { kq, kqDot, kqStar } from "./queries/sql/keywords.js";
78
+ import { assertLoaded, ensureLoaded, isLoaded, isNew, maybePopulateThen, unsafeLoaded } from "./loading/loadHints.js";
79
+ import { setFactoryWriter } from "./logging/FactoryLogger.js";
92
80
  import { FieldLogger, noopFieldLogger } from "./logging/FieldLogger.js";
93
81
  import { ReactionLogger, setReactionLogging } from "./logging/ReactionLogger.js";
82
+ import { lazyField } from "./newEntity.js";
83
+ import { deepNormalizeHint, normalizeHint } from "./normalizeHints.js";
94
84
  import { ImmutableEntitiesPlugin } from "./plugins/ImmutableEntitiesPlugin.js";
95
85
  import { JsonAggregatePreloader } from "./preloading/JsonAggregatePreloader.js";
96
86
  import { entityQueryBrand, query, queryMaybe, recursiveQuery, sql, subqueryBrand } from "./queries/sql/query.js";
87
+ import { generateOps } from "./drivers/EntityWriter.js";
88
+ import { convertToLoadHint, isTypeOrSubType, reverseReactiveHint } from "./reactivity/reactiveHints.js";
89
+ import { RandomUuidAssigner, SequenceIdAssigner, TestUuidAssigner } from "./drivers/IdAssigner.js";
90
+ import { ValidationCode, ValidationErrors, cannotBeChanged, cannotBeUpdated, maxValueRule, minValueRule, mustBeSubType, newRequiredLazyFieldRule, newRequiredRule, rangeValueRule } from "./rules.js";
91
+ import { getRuntimeConfig, setRuntimeConfig } from "./runtimeConfig.js";
97
92
  import { nowUTC } from "./nowUTC.js";
93
+ import { BigIntSerde, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, EnumArrayFieldSerde, EnumFieldSerde, JsonSerde, KeySerde, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, PrimitiveSerde, SuperstructSerde, VectorSerde, ZodSerde, ZonedDateTimeSerde } from "./serde/serde.js";
94
+ import { Column } from "./serde/columns.js";
95
+ import { FieldColumn, PolyComponent, PolymorphicKeySerde, SimpleFieldSerde, hasSerde, polymorphicField } from "./serde/fieldSerde.js";
96
+ import { isScope, isScopeJoinFilter, isSelectAllFilter, newScopeFn, resolveScope } from "./queries/find/scopes.js";
97
+ import { Temporal, maybeRequireTemporal, requireTemporal } from "./serde/temporal.js";
98
+ import { plainDateMapper, plainDateTimeMapper, plainTimeMapper, zonedDateTimeMapper } from "./serde/temporalMappers.js";
99
+ import { isInTrustedContext, runInTrustedContext } from "./trusted.js";
100
+ import { buildUnnestCte, ensureRectangularArraySizes } from "./queries/unnest.js";
98
101
  import { updatePartial, upsert } from "./upsert.js";
99
102
  import { StubbedRelation, ensureWithLoaded, withLoaded } from "./loading/withLoaded.js";
100
- import { EntityManager, FailedFlushError, NotFoundError, ReadOnlyError, TooManyError, appendStack, createRowFromEntityData, driverAfterBegin, driverAfterCommit, driverBeforeBegin, driverBeforeCommit, getDefaultEntityLimit, getEmInternalApi, invokeRule, isDefined, isId, isKey, resetDefaultEntityLimit, sameEntity, sameReference, setDefaultEntityLimit, setLastNow } from "./EntityManager.js";
101
- import { isEntity } from "./Entity.js";
102
- import { BaseEntity, getInstanceData } from "./BaseEntity.js";
103
103
  import { newPgConnectionConfig } from "joist-utils";
104
- //#region src/index.ts
104
+ // src/index.ts
105
105
  const testing = {
106
106
  isAllSqlPaths,
107
107
  getDefaultDependencies,
@@ -159,8 +159,10 @@ function setOpt(meta, entity, key, _value, partial = false, calledFromConstructo
159
159
  } else if (value instanceof FactoryInitialValue) {
160
160
  entity[key] = value.value;
161
161
  getEmInternalApi(entity.em).rm.forgetCreationTransition(entity, key);
162
- } else if (key === "id" && entity.isNewEntity) setField(entity, key, value);
163
- else entity[key] = value;
162
+ } else if (key === "id" && entity.isNewEntity) {
163
+ if (current !== void 0 && current !== value) fail(`Cannot change assigned id of ${meta.type}`);
164
+ setField(entity, key, value);
165
+ } else entity[key] = value;
164
166
  }
165
167
  function ensureNotDeleted(entity, ignore) {
166
168
  if (entity.isDeletedEntity && (ignore === void 0 || getInstanceData(entity).isDeletedAndFlushed)) fail(`${entity} is marked as deleted`);
@@ -198,7 +200,6 @@ function failNoIdYet(entity) {
198
200
  function isNewEntity(entity) {
199
201
  return entity.isNewEntity;
200
202
  }
201
- //#endregion
202
- export { AliasAssigner, AsyncPropertyImpl, BaseEntity, BigIntSerde, Column, ConditionBuilder, ConfigApi, CustomCollection, CustomReference, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, EntityManager, EntityMetrics, EnumArrayFieldSerde, EnumCollectionImpl, EnumFieldSerde, FailedFlushError, FieldColumn, FieldLogger, ImmutableEntitiesPlugin, InstanceData, JoinRowOperation, JsonAggregatePreloader, JsonSerde, KeySerde, LazyFieldImpl, ManyToManyCollection, ManyToManyLargeCollection, ManyToOneReferenceImpl, NoIdError, NotFoundError, OneToManyCollection, OneToManyLargeCollection, OneToOneReferenceImpl, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, PolyComponent, PolymorphicKeySerde, PolymorphicReferenceImpl, PrimitiveSerde, PropertyImpl, RandomUuidAssigner, ReactionLogger, ReactiveManyToManyImpl, ReactiveManyToManyOtherSideImpl, ReactiveReferenceImpl, ReadDriftError, ReadOnlyError, RecursiveCycleError, SequenceIdAssigner, SimpleFieldSerde, StubbedRelation, SuperstructSerde, Temporal, TestUuidAssigner, Todo, TooManyError, UnknownProperty, ValidationCode, ValidationErrors, VectorSerde, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, declareTable, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, expr, exprBrand, factories, fail, failIfAnyRejected, failNoIdYet, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRelationEntries, getRelations, getRequiredKeys, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveAsyncMethod, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, indexBy, internals, invokeRule, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isNewEntity, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, queryMaybe, rangeValueRule, recursiveQuery, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, taggedIdPrefix, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
203
+ export { AliasAssigner, AsyncPropertyImpl, BaseEntity, BigIntSerde, Column, ConditionBuilder, ConfigApi, CustomCollection, CustomReference, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, EntityManager, EntityMetrics, EnumArrayFieldSerde, EnumCollectionImpl, EnumFieldSerde, FailedFlushError, FieldColumn, FieldLogger, ImmutableEntitiesPlugin, InstanceData, JoinRowOperation, JsonAggregatePreloader, JsonSerde, KeySerde, LazyFieldImpl, ManyToManyCollection, ManyToManyLargeCollection, ManyToOneReferenceImpl, NoIdError, NotFoundError, OneToManyCollection, OneToManyLargeCollection, OneToOneReferenceImpl, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, PolyComponent, PolymorphicKeySerde, PolymorphicReferenceImpl, PrimitiveSerde, PropertyImpl, RandomUuidAssigner, ReactionLogger, ReactiveManyToManyImpl, ReactiveManyToManyOtherSideImpl, ReactiveReferenceImpl, ReadDriftError, ReadOnlyError, RecursiveCycleError, SequenceIdAssigner, SimpleFieldSerde, StubbedRelation, SuperstructSerde, Temporal, TestUuidAssigner, Todo, TooManyError, UnknownProperty, ValidationCode, ValidationErrors, VectorSerde, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, declareTable, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, expr, exprBrand, factories, fail, failIfAnyRejected, failNoIdYet, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRelationEntries, getRelations, getRequiredKeys, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveAsyncMethod, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, hasVisibilityHook, indexBy, internals, invokeRule, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isNewEntity, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, queryMaybe, rangeValueRule, recursiveQuery, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, taggedIdPrefix, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
203
204
 
204
205
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { getInstanceData } from \"src/BaseEntity.ts\";\nimport { getDefaultDependencies } from \"src/defaults.ts\";\nimport { type Entity } from \"src/Entity.ts\";\nimport { type EntityConstructor, type MaybeAbstractEntityConstructor, getEmInternalApi } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, getBaseMeta, getMetadata } from \"src/EntityMetadata.ts\";\nimport { getField, setField } from \"src/fields.ts\";\nimport { getProperties } from \"src/getProperties.ts\";\nimport type { New } from \"src/loading/loadHints.ts\";\nimport { isAllSqlPaths } from \"src/loading/loadLens.ts\";\nimport { FactoryInitialValue } from \"src/newTestInstance.ts\";\nimport { partitionHint } from \"src/preloading/partitionHint.ts\";\nimport { buildWhereClause } from \"src/queries/renderConditions.ts\";\nimport { AbstractRelationImpl } from \"src/relations/AbstractRelationImpl.ts\";\nimport { AsyncReactiveFieldImpl } from \"src/relations/AsyncReactiveField.ts\";\nimport {\n isAsyncProperty,\n isAsyncReactiveField,\n isLazyField,\n isProperty,\n isReactiveField,\n isReactiveGetter,\n} from \"src/relations/index.ts\";\nimport { ReactiveFieldImpl } from \"src/relations/ReactiveField.ts\";\nimport { type OptsOf } from \"src/typeMap.ts\";\nimport { fail } from \"src/utils.ts\";\n\nexport const testing = { isAllSqlPaths, getDefaultDependencies, partitionHint };\nexport const internals = { buildWhereClause };\nexport { newPgConnectionConfig } from \"joist-utils\";\nexport { AliasAssigner } from \"src/queries/sql/AliasAssigner.ts\";\nexport type { JoinTree } from \"src/queries/sql/JoinTree.ts\";\nexport {\n type AndCondition,\n type ConditionGroup,\n type DomainPredicate,\n type OrCondition,\n type PredicateBrand,\n type SqlCondition,\n type SqlPredicate,\n} from \"src/queries/conditions.ts\";\n// Domain aliases belong to em.find; physical table expressions belong to em.query/em.execute.\nexport {\n alias,\n aliases,\n getAliasMetadata,\n getAliasMgmt,\n getMaybeCtiAlias,\n isAlias,\n newAliasProxy,\n type Alias,\n type AliasBrand,\n type AliasMgmt,\n type AliasColumn,\n type EntityAlias,\n type PolyAlias,\n type PrimitiveAlias,\n} from \"src/queries/find/Aliases.ts\";\nexport {\n table,\n tables,\n tableMgmt,\n getTableMetadata,\n getTableMgmt,\n isTable,\n newTableProxy,\n type Table,\n type TableFilter,\n type TableBrand,\n type TableSourceBrand,\n type TableFor,\n type TableMgmt,\n type TableSourceMgmt,\n type ReferenceJoin,\n type PrimitiveColumn,\n type EntityColumn,\n type ReferenceColumn,\n type CollectionJoin,\n type PolyReference,\n} from \"src/queries/sql/Tables.ts\";\nexport {\n declareTable,\n type CustomColumnConfig,\n type CustomColumnInput,\n type CustomColumnInputs,\n type CustomColumnType,\n type CustomTable,\n type CustomTableDefinition,\n type CustomTableFor,\n} from \"src/queries/sql/custom.ts\";\nexport { BaseEntity, getInstanceData } from \"src/BaseEntity.ts\";\nexport { ConditionBuilder } from \"src/queries/ConditionBuilder.ts\";\nexport { type Entity, type IdType, isEntity } from \"src/Entity.ts\";\nexport type * from \"src/EntityFields.ts\";\nexport * from \"src/queries/find/EntityFilter.ts\";\nexport * from \"src/queries/find/EntityGraphQLFilter.ts\";\nexport * from \"src/EntityManager.ts\";\nexport { ReadDriftError, type ReadDrift } from \"src/flush/ReadDrift.ts\";\nexport { EntityMetrics, type EntityMetricsSnapshot, type EvaluationStats } from \"src/metrics/EntityMetrics.ts\";\nexport * from \"src/EntityMetadata.ts\";\nexport type {\n DeleteStatement,\n ExecuteResult,\n InsertStatement,\n InsertValues,\n MutationReturning,\n MutationStatement,\n UpdateStatement,\n UpdateValues,\n} from \"src/queries/sql/execute.ts\";\nexport type { EnumMetadata } from \"src/EnumMetadata.ts\";\n// `em.query`'s expression surface. Only the user-facing types are re-exported: the runtime half\n// (BaseExpr, asNode, deferredCondition, the FnExpr/TemplateExpr node classes) stays internal to\n// joist-core, so `toSql`/`decode`/`encode` never show up as something a user could call.\nexport {\n type ArrayAggOptions,\n type Expr,\n type ExprBrand,\n exprBrand,\n type ExprLike,\n type InnerJoin,\n type LeftJoin,\n} from \"src/queries/sql/Expr.ts\";\nexport {\n expr,\n type CaseElse,\n type CaseWhen,\n type ExprFromInput,\n type ExprInput,\n} from \"src/queries/sql/expressions/expression.ts\";\nexport { skipCondition } from \"src/queries/skipCondition.ts\";\nexport type { EntityOrId, HintNode } from \"src/loading/HintTree.ts\";\nexport { InstanceData } from \"src/InstanceData.ts\";\nexport { type JoinColumnValue, type JoinRow, JoinRowOperation, type ManyToManyLike } from \"src/flush/JoinRows.ts\";\nexport type * from \"src/flush/PendingChanges.ts\";\nexport { Plugin } from \"src/PluginManager.ts\";\nexport * from \"src/queries/find/QueryParser.ts\";\nexport * from \"src/queries/find/buildFindQuery.ts\";\nexport * from \"src/queries/renderConditions.ts\";\nexport type {\n ColumnCondition,\n ExistsCondition,\n ParsedExpressionCondition,\n ParsedExpressionFilter,\n ParsedValueFilter,\n RawCondition,\n} from \"src/queries/parsedConditions.ts\";\nexport {\n type ParsedEntityFilter,\n makeLike,\n mapToDb,\n parseEntityFilter,\n parseValueFilter,\n} from \"src/queries/valueFilters.ts\";\nexport {\n filterSoftDeletes,\n lazyExcludedSelects,\n maybeAddNotSoftDeleted,\n stiSubtypeFilter,\n} from \"src/queries/entityQueryUtils.ts\";\nexport * from \"src/queries/find/QueryParser.collectionJoins.ts\";\nexport { visitConditions } from \"src/queries/find/QueryVisitor.ts\";\nexport * from \"src/RowData.ts\";\nexport { type JoinRowTodo, Todo } from \"src/flush/Todo.ts\";\nexport * from \"src/changes.ts\";\nexport { ConfigApi, type EntityHook, resetBootFlag } from \"src/config.ts\";\nexport { type GuardTransitionMatch, type OnTransitionMatch, type TransitionTable } from \"src/transitions.ts\";\nexport {\n configureMetadata,\n getConstructorFromTaggedId,\n getMetadataForTable,\n getMetadataForType,\n maybeGetConstructorFromReference,\n} from \"src/configure.ts\";\nexport { driverApi } from \"src/drivers/driverApi.ts\";\nexport * from \"src/drivers/index.ts\";\nexport { getField, isChangeableField, isFieldSet, setField } from \"src/fields.ts\";\nexport * from \"src/getProperties.ts\";\nexport * from \"src/json.ts\";\nexport * from \"src/keys.ts\";\nexport { kq, kqDot, kqStar } from \"src/queries/sql/keywords.ts\";\nexport {\n assertLoaded,\n type DeepNew,\n ensureLoaded,\n isLoaded,\n isNew,\n type Loadable,\n type Loaded,\n type LoadHint,\n type MarkLoaded,\n maybePopulateThen,\n type NestedLoadHint,\n type New,\n type RelationsIn,\n unsafeLoaded,\n} from \"src/loading/loadHints.ts\";\nexport * from \"src/loading/loadLens.ts\";\nexport { setFactoryWriter } from \"src/logging/FactoryLogger.ts\";\nexport * from \"src/logging/FieldLogger.ts\";\nexport { ReactionLogger, setReactionLogging } from \"src/logging/ReactionLogger.ts\";\nexport { lazyField } from \"src/newEntity.ts\";\nexport {\n defaultValue,\n factories,\n type FactoryEntityOpt,\n type FactoryOpts,\n getTestIndex,\n isFactoryCreation,\n maybeBranchValue,\n maybeNew,\n maybeNewPoly,\n newTestInstance,\n noValue,\n setFactoryLogging,\n testIndex,\n} from \"src/newTestInstance.ts\";\nexport { deepNormalizeHint, normalizeHint } from \"src/normalizeHints.ts\";\nexport { ImmutableEntitiesPlugin } from \"src/plugins/ImmutableEntitiesPlugin.ts\";\nexport type { JoinResult, PreloadHydrator, PreloadPlugin } from \"src/plugins/PreloadPlugin.ts\";\nexport { JsonAggregatePreloader } from \"src/preloading/JsonAggregatePreloader.ts\";\n// `em.query`'s query surface; the parse pipeline (SubqueryHandle, parseRootQuery, Plan) stays internal\nexport {\n type CheckScope,\n type Clauses,\n type EntityQuery,\n type ExpressionOrderBy,\n type ExistsQuery,\n entityQueryBrand,\n type MaybeNull,\n type NameOf,\n type NotWidened,\n type OrderByDirection,\n type OrderByKeys,\n type Query,\n type QueryArg,\n type QueryCondition,\n type QueryJoin,\n type QueryJoinInput,\n type QueryJoinList,\n type QueryRow,\n type QuerySelect,\n type QuerySource,\n type QueryValue,\n recursiveQuery,\n type RecursiveOptions,\n type ResolvedJoins,\n type ScalarQuery,\n type SetQuery,\n query,\n queryMaybe,\n sql,\n type QueryTable,\n type QueryTableBrand,\n type Subquery,\n type SubqueryBrand,\n subqueryBrand,\n type WithInput,\n type WithSource,\n} from \"src/queries/sql/query.ts\";\nexport {\n convertToLoadHint,\n isTypeOrSubType,\n type Reactable,\n type Reacted,\n type ReactiveHint,\n type ReactiveTarget,\n reverseReactiveHint,\n} from \"src/reactivity/reactiveHints.ts\";\nexport * from \"src/relations/index.ts\";\nexport {\n cannotBeChanged,\n cannotBeUpdated,\n type GenericError,\n maxValueRule,\n minValueRule,\n mustBeSubType,\n newRequiredLazyFieldRule,\n newRequiredRule,\n rangeValueRule,\n ValidationCode,\n type ValidationError,\n ValidationErrors,\n type ValidationRule,\n type ValidationRuleInternal,\n type ValidationRuleResult,\n} from \"src/rules.ts\";\nexport { getRuntimeConfig, setRuntimeConfig, type RuntimeConfig } from \"src/runtimeConfig.ts\";\nexport { nowUTC } from \"src/nowUTC.ts\";\nexport * from \"src/serde/serde.ts\";\nexport * from \"src/serde/columns.ts\";\nexport * from \"src/serde/fieldSerde.ts\";\nexport * from \"src/queries/find/scopes.ts\";\nexport { maybeRequireTemporal, requireTemporal, Temporal } from \"src/serde/temporal.ts\";\nexport * from \"src/serde/temporalMappers.ts\";\nexport { isInTrustedContext, runInTrustedContext } from \"src/trusted.ts\";\nexport type * from \"src/typeMap.ts\";\nexport { buildUnnestCte, ensureRectangularArraySizes } from \"src/queries/unnest.ts\";\nexport { type DeepPartialOrNull, updatePartial, upsert } from \"src/upsert.ts\";\nexport {\n abbreviation,\n asNew,\n assertNever,\n cleanSql,\n cleanStringValue,\n fail,\n failIfAnyRejected,\n indexBy,\n partition,\n zeroTo,\n} from \"src/utils.ts\";\nexport { ensureWithLoaded, StubbedRelation, type WithLoaded, withLoaded } from \"src/loading/withLoaded.ts\";\n\n// https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/\ninterface Flavoring<FlavorT> {\n _type?: FlavorT;\n}\n\nexport type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;\n\n/**\n * Sets each value in `values` on the current entity.\n *\n * The default behavior is that passing a value as either `null` or `undefined` will set\n * the field as `undefined`, i.e. automatic `null` to `undefined` conversion.\n *\n * However, if you pass `ignoreUndefined: true`, then any opt that is `undefined` will be treated\n * as \"do not set\", and `null` will still mean \"set to `undefined`\". This is useful for implementing\n * APIs were an input of `undefined` means \"do not set / noop\" and `null` means \"unset\".\n *\n * Note that constructors _always_ call this method, but if the call is coming from `em.hydrate`, we\n * use `values` being a primary key to short-circuit and let hydration callers assign the values\n * returned by the serde `fromRow` methods.\n */\nexport function setOpts<T extends Entity>(\n entity: T,\n values: Partial<OptsOf<T>> | undefined,\n opts?: { partial?: boolean; calledFromConstructor?: boolean },\n): void {\n const { calledFromConstructor = false, partial } = opts || {};\n // If `values` is undefined, we're being called by `createPartial` that will do its\n // own opt handling, but we still want the sync defaults applied after this opts handling.\n if (values !== undefined) {\n const meta = getMetadata(entity);\n for (const [key, _value] of Object.entries(values as {})) {\n setOpt(meta, entity, key, _value, partial, calledFromConstructor);\n }\n }\n}\n\n/**\n * Applies some standard behavior & protections to `entity[key] = value`. I.e.\n *\n * - We don't set over AsyncProperties/relations/etc., and instead call current.set(value)\n * - We catch missing/invalid field names\n * - We handle FactoryInitialValues\n */\nexport function setOpt<T extends Entity>(\n meta: EntityMetadata<T>,\n entity: T,\n key: string,\n _value: any,\n partial = false,\n calledFromConstructor = false,\n): void {\n const field = meta.allFields[key];\n if (!field) {\n // Allow setting non-field properties like fullName setters\n const prop = getProperties(meta)[key];\n if (!prop) {\n throw new Error(`Unknown field ${key}`);\n }\n }\n\n // If partial is set, we treat undefined as a noop\n if (partial && _value === undefined) return;\n // Ignore the STI discriminator, em.register will set this accordingly\n if (meta.inheritanceType === \"sti\" && getBaseMeta(meta).stiDiscriminatorField === key) return;\n\n // We let optional opts fields be `| null` for convenience, and convert to undefined.\n const value = _value === null ? undefined : _value;\n\n // Use `getField` to side-step `id` blowing up on new entities that are setting an\n // explicit id. Read configured fields as internal so applying opts does not mark the entity for read locking.\n // Otherwise use `entity[key]` to get back the relation.\n const current = key === \"id\" || field?.assertUnchanged ? getField(entity, key, true) : (entity as any)[key];\n\n if (current instanceof AbstractRelationImpl) {\n if (calledFromConstructor) {\n current.setFromOpts(value);\n } else {\n current.set(value);\n }\n } else if (isLazyField(current)) {\n current.set(value);\n } else if (isProperty(current) || isAsyncProperty(current) || isReactiveGetter(current)) {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n } else if (isReactiveField(current) || isAsyncReactiveField(current)) {\n if (value instanceof FactoryInitialValue) {\n if (current instanceof ReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else if (current instanceof AsyncReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else {\n throw new Error(`Unhandled case ${current.constructor.name}`);\n }\n } else {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n }\n } else if (value instanceof FactoryInitialValue) {\n // A factory's `withStatus`-style opt: trust the created value, so its `addTransitionReaction`s don't fire\n (entity as any)[key] = value.value;\n getEmInternalApi(entity.em).rm.forgetCreationTransition(entity, key);\n } else {\n // If setting an explicit id, go through setField, otherwise use\n // `entity[key]` to set the value directly to that we go through setters.\n if (key === \"id\" && entity.isNewEntity) {\n setField(entity, key, value);\n } else {\n (entity as any)[key] = value;\n }\n }\n}\n\nexport function ensureNotDeleted(entity: Entity, ignore?: \"pending\"): void {\n if (entity.isDeletedEntity && (ignore === undefined || getInstanceData(entity).isDeletedAndFlushed)) {\n fail(`${entity} is marked as deleted`);\n }\n}\n\n/** Adds `null` to every key in `T` to accept partial-update-style input. */\nexport type PartialOrNull<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport function getRequiredKeys<T extends Entity>(entity: T): string[];\nexport function getRequiredKeys<T extends Entity>(type: EntityConstructor<T>): string[];\nexport function getRequiredKeys<T extends Entity>(entityOrType: T | EntityConstructor<T>): string[] {\n return Object.values(getMetadata(entityOrType as any).fields)\n .filter((f) => f.required)\n .map((f) => f.fieldName);\n}\n\nexport function getRelations(entity: Entity): AbstractRelationImpl<any, any>[] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => (entity as any)[name]);\n}\n\nexport function getRelationEntries(entity: Entity): [string, AbstractRelationImpl<any, any>][] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => [name, (entity as any)[name]]);\n}\n\n/** Casts a \"maybe abstract\" cstr to a concrete cstr when the calling code knows it's safe. */\nexport function asConcreteCstr<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>): EntityConstructor<T> {\n return cstr as any;\n}\n\n/**\n * Thrown when `.id` is accessed on an entity that does not have an id yet.\n *\n * For Postgres, entities are actually allowed to have ids pre-INSERT, if you call\n * `em.assignNewIds()`. Other databases typically require INSERTs to trigger the auto\n * id assignment.\n */\nexport class NoIdError extends Error {}\n\n/** Throws a `NoIdError` for `entity`, i.e. because `id` was called before being saved. */\nexport function failNoIdYet(entity: string): never {\n throw new NoIdError(`${entity} has no id yet`);\n}\n\n/**\n * Add a static function since getters can't have type guards.\n *\n * See https://github.com/microsoft/TypeScript/issues/43368\n */\nexport function isNewEntity<T extends Entity>(entity: T): entity is New<T> {\n return entity.isNewEntity;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;AASA,IAAa,YAAb,cAA+B,MAAM,CAAC;;AAGtC,SAAgB,YAAY,QAAuB;CACjD,MAAM,IAAI,UAAU,GAAG,OAAO,eAAe;AAC/C;;;;;;AAOA,SAAgB,YAA8B,QAA6B;CACzE,OAAO,OAAO;AAChB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { getInstanceData } from \"src/BaseEntity.ts\";\nimport { getDefaultDependencies } from \"src/defaults.ts\";\nimport { type Entity } from \"src/Entity.ts\";\nimport { type EntityConstructor, type MaybeAbstractEntityConstructor, getEmInternalApi } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, getBaseMeta, getMetadata } from \"src/EntityMetadata.ts\";\nimport { getField, setField } from \"src/fields.ts\";\nimport { getProperties } from \"src/getProperties.ts\";\nimport type { New } from \"src/loading/loadHints.ts\";\nimport { isAllSqlPaths } from \"src/loading/loadLens.ts\";\nimport { FactoryInitialValue } from \"src/newTestInstance.ts\";\nimport { partitionHint } from \"src/preloading/partitionHint.ts\";\nimport { buildWhereClause } from \"src/queries/renderConditions.ts\";\nimport { AbstractRelationImpl } from \"src/relations/AbstractRelationImpl.ts\";\nimport { AsyncReactiveFieldImpl } from \"src/relations/AsyncReactiveField.ts\";\nimport {\n isAsyncProperty,\n isAsyncReactiveField,\n isLazyField,\n isProperty,\n isReactiveField,\n isReactiveGetter,\n} from \"src/relations/index.ts\";\nimport { ReactiveFieldImpl } from \"src/relations/ReactiveField.ts\";\nimport { type OptsOf } from \"src/typeMap.ts\";\nimport { fail } from \"src/utils.ts\";\n\nexport const testing = { isAllSqlPaths, getDefaultDependencies, partitionHint };\nexport const internals = { buildWhereClause };\nexport { newPgConnectionConfig } from \"joist-utils\";\nexport { AliasAssigner } from \"src/queries/sql/AliasAssigner.ts\";\nexport type { JoinTree } from \"src/queries/sql/JoinTree.ts\";\nexport {\n type AndCondition,\n type ConditionGroup,\n type DomainPredicate,\n type OrCondition,\n type PredicateBrand,\n type SqlCondition,\n type SqlPredicate,\n} from \"src/queries/conditions.ts\";\n// Domain aliases belong to em.find; physical table expressions belong to em.query/em.execute.\nexport {\n alias,\n aliases,\n getAliasMetadata,\n getAliasMgmt,\n getMaybeCtiAlias,\n isAlias,\n newAliasProxy,\n type Alias,\n type AliasBrand,\n type AliasMgmt,\n type AliasColumn,\n type EntityAlias,\n type PolyAlias,\n type PrimitiveAlias,\n} from \"src/queries/find/Aliases.ts\";\nexport {\n table,\n tables,\n tableMgmt,\n getTableMetadata,\n getTableMgmt,\n isTable,\n newTableProxy,\n type Table,\n type TableFilter,\n type TableBrand,\n type TableSourceBrand,\n type TableFor,\n type TableMgmt,\n type TableSourceMgmt,\n type ReferenceJoin,\n type PrimitiveColumn,\n type EntityColumn,\n type ReferenceColumn,\n type CollectionJoin,\n type PolyReference,\n} from \"src/queries/sql/Tables.ts\";\nexport {\n declareTable,\n type CustomColumnConfig,\n type CustomColumnInput,\n type CustomColumnInputs,\n type CustomColumnType,\n type CustomTable,\n type CustomTableDefinition,\n type CustomTableFor,\n} from \"src/queries/sql/custom.ts\";\nexport { BaseEntity, getInstanceData } from \"src/BaseEntity.ts\";\nexport { ConditionBuilder } from \"src/queries/ConditionBuilder.ts\";\nexport { type Entity, type IdType, isEntity } from \"src/Entity.ts\";\nexport type * from \"src/EntityFields.ts\";\nexport * from \"src/queries/find/EntityFilter.ts\";\nexport * from \"src/queries/find/EntityGraphQLFilter.ts\";\nexport * from \"src/EntityManager.ts\";\nexport { ReadDriftError, type ReadDrift } from \"src/flush/ReadDrift.ts\";\nexport { EntityMetrics, type EntityMetricsSnapshot, type EvaluationStats } from \"src/metrics/EntityMetrics.ts\";\nexport * from \"src/EntityMetadata.ts\";\nexport type {\n DeleteStatement,\n ExecuteResult,\n InsertStatement,\n InsertValues,\n MutationReturning,\n MutationStatement,\n UpdateStatement,\n UpdateValues,\n} from \"src/queries/sql/execute.ts\";\nexport type { EnumMetadata } from \"src/EnumMetadata.ts\";\n// `em.query`'s expression surface. Only the user-facing types are re-exported: the runtime half\n// (BaseExpr, asNode, deferredCondition, the FnExpr/TemplateExpr node classes) stays internal to\n// joist-core, so `toSql`/`decode`/`encode` never show up as something a user could call.\nexport {\n type ArrayAggOptions,\n type Expr,\n type ExprBrand,\n exprBrand,\n type ExprLike,\n type InnerJoin,\n type LeftJoin,\n} from \"src/queries/sql/Expr.ts\";\nexport {\n expr,\n type CaseElse,\n type CaseWhen,\n type ExprFromInput,\n type ExprInput,\n} from \"src/queries/sql/expressions/expression.ts\";\nexport { skipCondition } from \"src/queries/skipCondition.ts\";\nexport type { EntityOrId, HintNode } from \"src/loading/HintTree.ts\";\nexport { InstanceData } from \"src/InstanceData.ts\";\nexport { type JoinColumnValue, type JoinRow, JoinRowOperation, type ManyToManyLike } from \"src/flush/JoinRows.ts\";\nexport type * from \"src/flush/PendingChanges.ts\";\nexport { Plugin } from \"src/PluginManager.ts\";\nexport * from \"src/queries/find/QueryParser.ts\";\nexport * from \"src/queries/find/buildFindQuery.ts\";\nexport * from \"src/queries/renderConditions.ts\";\nexport type {\n ColumnCondition,\n ExistsCondition,\n ParsedExpressionCondition,\n ParsedExpressionFilter,\n ParsedValueFilter,\n RawCondition,\n} from \"src/queries/parsedConditions.ts\";\nexport {\n type ParsedEntityFilter,\n makeLike,\n mapToDb,\n parseEntityFilter,\n parseValueFilter,\n} from \"src/queries/valueFilters.ts\";\nexport {\n filterSoftDeletes,\n lazyExcludedSelects,\n maybeAddNotSoftDeleted,\n stiSubtypeFilter,\n} from \"src/queries/entityQueryUtils.ts\";\nexport * from \"src/queries/find/QueryParser.collectionJoins.ts\";\nexport { visitConditions } from \"src/queries/find/QueryVisitor.ts\";\nexport * from \"src/RowData.ts\";\nexport { type JoinRowTodo, Todo } from \"src/flush/Todo.ts\";\nexport * from \"src/changes.ts\";\nexport { ConfigApi, type EntityHook, resetBootFlag } from \"src/config.ts\";\nexport { type GuardTransitionMatch, type OnTransitionMatch, type TransitionTable } from \"src/transitions.ts\";\nexport {\n configureMetadata,\n getConstructorFromTaggedId,\n getMetadataForTable,\n getMetadataForType,\n maybeGetConstructorFromReference,\n} from \"src/configure.ts\";\nexport { driverApi } from \"src/drivers/driverApi.ts\";\nexport * from \"src/drivers/index.ts\";\nexport { getField, isChangeableField, isFieldSet, setField } from \"src/fields.ts\";\nexport * from \"src/getProperties.ts\";\nexport * from \"src/json.ts\";\nexport * from \"src/keys.ts\";\nexport { kq, kqDot, kqStar } from \"src/queries/sql/keywords.ts\";\nexport {\n assertLoaded,\n type DeepNew,\n ensureLoaded,\n isLoaded,\n isNew,\n type Loadable,\n type Loaded,\n type LoadHint,\n type MarkLoaded,\n maybePopulateThen,\n type NestedLoadHint,\n type New,\n type RelationsIn,\n unsafeLoaded,\n} from \"src/loading/loadHints.ts\";\nexport * from \"src/loading/loadLens.ts\";\nexport { setFactoryWriter } from \"src/logging/FactoryLogger.ts\";\nexport * from \"src/logging/FieldLogger.ts\";\nexport { ReactionLogger, setReactionLogging } from \"src/logging/ReactionLogger.ts\";\nexport { lazyField } from \"src/newEntity.ts\";\nexport {\n defaultValue,\n factories,\n type FactoryEntityOpt,\n type FactoryOpts,\n getTestIndex,\n isFactoryCreation,\n maybeBranchValue,\n maybeNew,\n maybeNewPoly,\n newTestInstance,\n noValue,\n setFactoryLogging,\n testIndex,\n} from \"src/newTestInstance.ts\";\nexport { deepNormalizeHint, normalizeHint } from \"src/normalizeHints.ts\";\nexport { ImmutableEntitiesPlugin } from \"src/plugins/ImmutableEntitiesPlugin.ts\";\nexport type { JoinResult, PreloadHydrator, PreloadPlugin } from \"src/plugins/PreloadPlugin.ts\";\nexport { JsonAggregatePreloader } from \"src/preloading/JsonAggregatePreloader.ts\";\n// `em.query`'s query surface; the parse pipeline (SubqueryHandle, parseRootQuery, Plan) stays internal\nexport {\n type CheckScope,\n type Clauses,\n type EntityQuery,\n type ExpressionOrderBy,\n type ExistsQuery,\n entityQueryBrand,\n type MaybeNull,\n type NameOf,\n type NotWidened,\n type OrderByDirection,\n type OrderByKeys,\n type Query,\n type QueryArg,\n type QueryCondition,\n type QueryJoin,\n type QueryJoinInput,\n type QueryJoinList,\n type QueryRow,\n type QuerySelect,\n type QuerySource,\n type QueryValue,\n recursiveQuery,\n type RecursiveOptions,\n type ResolvedJoins,\n type ScalarQuery,\n type SetQuery,\n query,\n queryMaybe,\n sql,\n type QueryTable,\n type QueryTableBrand,\n type Subquery,\n type SubqueryBrand,\n subqueryBrand,\n type WithInput,\n type WithSource,\n} from \"src/queries/sql/query.ts\";\nexport {\n convertToLoadHint,\n isTypeOrSubType,\n type Reactable,\n type Reacted,\n type ReactiveHint,\n type ReactiveTarget,\n reverseReactiveHint,\n} from \"src/reactivity/reactiveHints.ts\";\nexport * from \"src/relations/index.ts\";\nexport {\n cannotBeChanged,\n cannotBeUpdated,\n type GenericError,\n maxValueRule,\n minValueRule,\n mustBeSubType,\n newRequiredLazyFieldRule,\n newRequiredRule,\n rangeValueRule,\n ValidationCode,\n type ValidationError,\n ValidationErrors,\n type ValidationRule,\n type ValidationRuleInternal,\n type ValidationRuleResult,\n} from \"src/rules.ts\";\nexport { getRuntimeConfig, setRuntimeConfig, type RuntimeConfig } from \"src/runtimeConfig.ts\";\nexport { nowUTC } from \"src/nowUTC.ts\";\nexport * from \"src/serde/serde.ts\";\nexport * from \"src/serde/columns.ts\";\nexport * from \"src/serde/fieldSerde.ts\";\nexport * from \"src/queries/find/scopes.ts\";\nexport { maybeRequireTemporal, requireTemporal, Temporal } from \"src/serde/temporal.ts\";\nexport * from \"src/serde/temporalMappers.ts\";\nexport { isInTrustedContext, runInTrustedContext } from \"src/trusted.ts\";\nexport type * from \"src/typeMap.ts\";\nexport { buildUnnestCte, ensureRectangularArraySizes } from \"src/queries/unnest.ts\";\nexport { type DeepPartialOrNull, updatePartial, upsert } from \"src/upsert.ts\";\nexport {\n abbreviation,\n asNew,\n assertNever,\n cleanSql,\n cleanStringValue,\n fail,\n failIfAnyRejected,\n indexBy,\n partition,\n zeroTo,\n} from \"src/utils.ts\";\nexport { ensureWithLoaded, StubbedRelation, type WithLoaded, withLoaded } from \"src/loading/withLoaded.ts\";\n\n// https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/\ninterface Flavoring<FlavorT> {\n _type?: FlavorT;\n}\n\nexport type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;\n\n/**\n * Sets each value in `values` on the current entity.\n *\n * The default behavior is that passing a value as either `null` or `undefined` will set\n * the field as `undefined`, i.e. automatic `null` to `undefined` conversion.\n *\n * However, if you pass `ignoreUndefined: true`, then any opt that is `undefined` will be treated\n * as \"do not set\", and `null` will still mean \"set to `undefined`\". This is useful for implementing\n * APIs were an input of `undefined` means \"do not set / noop\" and `null` means \"unset\".\n *\n * Note that constructors _always_ call this method, but if the call is coming from `em.hydrate`, we\n * use `values` being a primary key to short-circuit and let hydration callers assign the values\n * returned by the serde `fromRow` methods.\n */\nexport function setOpts<T extends Entity>(\n entity: T,\n values: Partial<OptsOf<T>> | undefined,\n opts?: { partial?: boolean; calledFromConstructor?: boolean },\n): void {\n const { calledFromConstructor = false, partial } = opts || {};\n // If `values` is undefined, we're being called by `createPartial` that will do its\n // own opt handling, but we still want the sync defaults applied after this opts handling.\n if (values !== undefined) {\n const meta = getMetadata(entity);\n for (const [key, _value] of Object.entries(values as {})) {\n setOpt(meta, entity, key, _value, partial, calledFromConstructor);\n }\n }\n}\n\n/**\n * Applies some standard behavior & protections to `entity[key] = value`. I.e.\n *\n * - We don't set over AsyncProperties/relations/etc., and instead call current.set(value)\n * - We catch missing/invalid field names\n * - We handle FactoryInitialValues\n */\nexport function setOpt<T extends Entity>(\n meta: EntityMetadata<T>,\n entity: T,\n key: string,\n _value: any,\n partial = false,\n calledFromConstructor = false,\n): void {\n const field = meta.allFields[key];\n if (!field) {\n // Allow setting non-field properties like fullName setters\n const prop = getProperties(meta)[key];\n if (!prop) {\n throw new Error(`Unknown field ${key}`);\n }\n }\n\n // If partial is set, we treat undefined as a noop\n if (partial && _value === undefined) return;\n // Ignore the STI discriminator, em.register will set this accordingly\n if (meta.inheritanceType === \"sti\" && getBaseMeta(meta).stiDiscriminatorField === key) return;\n\n // We let optional opts fields be `| null` for convenience, and convert to undefined.\n const value = _value === null ? undefined : _value;\n\n // Use `getField` to side-step `id` blowing up on new entities that are setting an\n // explicit id. Read configured fields as internal so applying opts does not mark the entity for read locking.\n // Otherwise use `entity[key]` to get back the relation.\n const current = key === \"id\" || field?.assertUnchanged ? getField(entity, key, true) : (entity as any)[key];\n\n if (current instanceof AbstractRelationImpl) {\n if (calledFromConstructor) {\n current.setFromOpts(value);\n } else {\n current.set(value);\n }\n } else if (isLazyField(current)) {\n current.set(value);\n } else if (isProperty(current) || isAsyncProperty(current) || isReactiveGetter(current)) {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n } else if (isReactiveField(current) || isAsyncReactiveField(current)) {\n if (value instanceof FactoryInitialValue) {\n if (current instanceof ReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else if (current instanceof AsyncReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else {\n throw new Error(`Unhandled case ${current.constructor.name}`);\n }\n } else {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n }\n } else if (value instanceof FactoryInitialValue) {\n // A factory's `withStatus`-style opt: trust the created value, so its `addTransitionReaction`s don't fire\n (entity as any)[key] = value.value;\n getEmInternalApi(entity.em).rm.forgetCreationTransition(entity, key);\n } else {\n // If setting an explicit id, go through setField, otherwise use\n // `entity[key]` to set the value directly to that we go through setters.\n if (key === \"id\" && entity.isNewEntity) {\n // Reject ID changes even before insertion: they would invalidate identity-map entries and cached ID conversions.\n if (current !== undefined && current !== value) fail(`Cannot change assigned id of ${meta.type}`);\n setField(entity, key, value);\n } else {\n (entity as any)[key] = value;\n }\n }\n}\n\nexport function ensureNotDeleted(entity: Entity, ignore?: \"pending\"): void {\n if (entity.isDeletedEntity && (ignore === undefined || getInstanceData(entity).isDeletedAndFlushed)) {\n fail(`${entity} is marked as deleted`);\n }\n}\n\n/** Adds `null` to every key in `T` to accept partial-update-style input. */\nexport type PartialOrNull<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport function getRequiredKeys<T extends Entity>(entity: T): string[];\nexport function getRequiredKeys<T extends Entity>(type: EntityConstructor<T>): string[];\nexport function getRequiredKeys<T extends Entity>(entityOrType: T | EntityConstructor<T>): string[] {\n return Object.values(getMetadata(entityOrType as any).fields)\n .filter((f) => f.required)\n .map((f) => f.fieldName);\n}\n\nexport function getRelations(entity: Entity): AbstractRelationImpl<any, any>[] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => (entity as any)[name]);\n}\n\nexport function getRelationEntries(entity: Entity): [string, AbstractRelationImpl<any, any>][] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => [name, (entity as any)[name]]);\n}\n\n/** Casts a \"maybe abstract\" cstr to a concrete cstr when the calling code knows it's safe. */\nexport function asConcreteCstr<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>): EntityConstructor<T> {\n return cstr as any;\n}\n\n/**\n * Thrown when `.id` is accessed on an entity that does not have an id yet.\n *\n * For Postgres, entities are actually allowed to have ids pre-INSERT, if you call\n * `em.assignNewIds()`. Other databases typically require INSERTs to trigger the auto\n * id assignment.\n */\nexport class NoIdError extends Error {}\n\n/** Throws a `NoIdError` for `entity`, i.e. because `id` was called before being saved. */\nexport function failNoIdYet(entity: string): never {\n throw new NoIdError(`${entity} has no id yet`);\n}\n\n/**\n * Add a static function since getters can't have type guards.\n *\n * See https://github.com/microsoft/TypeScript/issues/43368\n */\nexport function isNewEntity<T extends Entity>(entity: T): entity is New<T> {\n return entity.isNewEntity;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C9G,OAAO;AACT;;;;;;;;AASA,IAAa,YAAb,cAA+B,MAAM,CAAC;;AAGtC,SAAgB,YAAY,QAAuB;CACjD,MAAM,IAAI,UAAU,GAAG,OAAO,eAAe;AAC/C;;;;;;AAOA,SAAgB,YAA8B,QAA6B;CACzE,OAAO,OAAO;AAChB"}
package/build/json.cjs CHANGED
@@ -1,16 +1,16 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_relations_AbstractRelationImpl = require("./relations/AbstractRelationImpl.cjs");
2
+ const require_Entity = require("./Entity.cjs");
3
+ require("./EntityManager.cjs");
4
+ const require_EntityMetadata = require("./EntityMetadata.cjs");
3
5
  const require_normalizeHints = require("./normalizeHints.cjs");
4
- const require_relations_ReactiveGetter = require("./relations/ReactiveGetter.cjs");
5
6
  const require_reactivity_reactiveHints = require("./reactivity/reactiveHints.cjs");
6
- const require_relations_hasProperty = require("./relations/hasProperty.cjs");
7
- const require_relations_ReactiveField = require("./relations/ReactiveField.cjs");
7
+ const require_relations_AbstractRelationImpl = require("./relations/AbstractRelationImpl.cjs");
8
8
  const require_relations_AsyncReactiveField = require("./relations/AsyncReactiveField.cjs");
9
+ const require_relations_hasProperty = require("./relations/hasProperty.cjs");
9
10
  require("./relations/index.cjs");
10
- const require_EntityMetadata = require("./EntityMetadata.cjs");
11
- require("./EntityManager.cjs");
12
- const require_Entity = require("./Entity.cjs");
13
- //#region src/json.ts
11
+ const require_relations_ReactiveField = require("./relations/ReactiveField.cjs");
12
+ const require_relations_ReactiveGetter = require("./relations/ReactiveGetter.cjs");
13
+ // src/json.ts
14
14
  async function toJSON(entityOrList, hint) {
15
15
  if (Array.isArray(entityOrList) && entityOrList.length === 0) return [];
16
16
  const entity = Array.isArray(entityOrList) ? entityOrList[0] : entityOrList;
@@ -44,8 +44,8 @@ async function copyToPayload(payload, entity, hint) {
44
44
  if (typeof nestedHint !== "function") throw new Error(`Entity does not have a property ${payloadKey}`);
45
45
  payload[payloadKey] = await nestedHint(entity);
46
46
  } else {
47
- const value = entity[entityKey];
48
- if (isPrimitive(value)) payload[payloadKey] = value;
47
+ const value = entityKey === "id" ? entity.idMaybe ?? null : entity[entityKey];
48
+ if (isPrimitive(value) || value instanceof Date) payload[payloadKey] = value;
49
49
  else if (value instanceof require_relations_AbstractRelationImpl.AbstractRelationImpl || value instanceof require_relations_ReactiveField.ReactiveFieldImpl || value instanceof require_relations_ReactiveGetter.ReactiveGetterImpl || value instanceof require_relations_AsyncReactiveField.AsyncReactiveFieldImpl || value instanceof require_relations_hasProperty.PropertyImpl) await copyToPayloadValue(payload, payloadKey, value.get, nextHint);
50
50
  else throw new Error(`Unable to encode value ${value} to JSON`);
51
51
  }
@@ -57,7 +57,7 @@ function copyToPayloadValue(payload, key, value, nextHint) {
57
57
  if (nextHint && Object.keys(nextHint).length > 0) {
58
58
  payload[key] = {};
59
59
  return copyToPayload(payload[key], value, nextHint);
60
- } else payload[key] = value.id;
60
+ } else payload[key] = value.idMaybe ?? null;
61
61
  } else if (Array.isArray(value)) {
62
62
  const list = [];
63
63
  payload[key] = list;
@@ -67,13 +67,12 @@ function copyToPayloadValue(payload, key, value, nextHint) {
67
67
  return copyToPayload(list[i], item, nextHint);
68
68
  } else list[i] = item;
69
69
  }));
70
- else for (const item of value) list.push(item.id);
70
+ else for (const item of value) list.push(item.idMaybe ?? null);
71
71
  } else payload[key] = value;
72
72
  }
73
73
  function isPrimitive(value) {
74
74
  return value === null || typeof value !== "object";
75
75
  }
76
- //#endregion
77
76
  exports.toJSON = toJSON;
78
77
 
79
78
  //# sourceMappingURL=json.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"json.cjs","names":["convertToLoadHint","getMetadata","normalizeHint","AbstractRelationImpl","ReactiveFieldImpl","ReactiveGetterImpl","AsyncReactiveFieldImpl","PropertyImpl","isEntity"],"sources":["../src/json.ts"],"sourcesContent":["import { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type IdOf } from \"src/EntityManager.ts\";\nimport { getMetadata } from \"src/EntityMetadata.ts\";\nimport { normalizeHint } from \"src/normalizeHints.ts\";\nimport { convertToLoadHint } from \"src/reactivity/reactiveHints.ts\";\nimport { AbstractRelationImpl } from \"src/relations/AbstractRelationImpl.ts\";\nimport { AsyncReactiveFieldImpl } from \"src/relations/AsyncReactiveField.ts\";\nimport { PropertyImpl } from \"src/relations/hasProperty.ts\";\nimport {\n type AsyncMethod,\n type Collection,\n type Property,\n type ReactiveGetter,\n type Reference,\n} from \"src/relations/index.ts\";\nimport { ReactiveFieldImpl } from \"src/relations/ReactiveField.ts\";\nimport { ReactiveGetterImpl } from \"src/relations/ReactiveGetter.ts\";\n\n/**\n * A JSON hint of a single key, multiple keys, or nested keys and sub-hints.\n *\n * JSON hints are much like load hints/reactive hints:\n *\n * - Similar to load hints, they specify which relations should be loaded from the database\n * - Similar to reactive hints, they include specific fields to output\n * - Unlike either, they can include completely custom keys that are lambdas to generate custom values\n */\nexport type JsonHint<T extends Entity> =\n | (keyof Jsonable<T> & string)\n | ReadonlyArray<keyof Jsonable<T> & string>\n | NestedJsonHint<T>;\n\n/** For object literal/nested hints, we allow mapping both entity keys 1:1 & custom keys via a lambdas. */\nexport type NestedJsonHint<T extends Entity> = EntityKeyJsonHint<T> | CustomJsonKeyHint<T>;\n\n/** Foreach `Jsonable` key, we can provide a sub-hint, or just a boolean to include/exclude. */\nexport type EntityKeyJsonHint<T extends Entity> = {\n // The `as K` makes `bookIds` as a hint work...\n [K in keyof Jsonable<T> as `${K}`]?: (Jsonable<T>[K] extends infer U extends Entity ? JsonHint<U> : {}) | boolean;\n};\n\nexport type CustomJsonKeyHint<T> = {\n [key: string]: (entity: T) => any;\n};\n\n/**\n * Describes the JSON payload for `Entity.toJSON` to produce.\n *\n * - `[\"firstName\", \"lastName\"]` will produce a JSON payload with just those fields\n * - `{ author: { books: \"title\" } }` will produce a JSON payload with the author's books' titles\n *\n * We only accept object literals & arrays to `toJSON` to avoid a `JSON.stringify` oddity.\n */\nexport type ToJsonHint<T extends Entity> = NestedJsonHint<T> | ReadonlyArray<keyof Jsonable<T> & string>;\n\n/** The keys in `T` that we can put into a JSON payload. */\nexport type Jsonable<T extends Entity> = {\n -readonly [K in keyof T as JsonableValue<T[K]> extends never ? never : K]: JsonableValue<T[K]>;\n};\n\n// this should probably be `keyof T` as long as they aren't methods/AsyncMethods.\n// so primitives, enums, references, collections, async properties, but also random getters.\nexport type JsonableValue<V> =\n V extends Reference<any, infer U, any>\n ? U\n : V extends Collection<any, infer U>\n ? U\n : V extends AsyncMethod<any, any, any>\n ? never\n : V extends Property<any, infer P>\n ? DropUndefined<P>\n : V extends ReactiveGetter<any, infer P>\n ? P\n : V;\n\n/**\n * Provides an API to put an entity, or list of entities, into a JSON payload.\n *\n * The `hint` parameter is a JSON hint that describes what to include in the payload,\n *\n * - fields like `id`, `name`, etc.\n * - relations like m2o, o2m, m2m, and o2o\n * - relations are allowed to provide nested hints, just like nested load hints\n * - custom fields like `fullName: (entity) => entity.firstName + ' ' + entity.lastName`\n */\nexport async function toJSON<T extends Entity, const H extends JsonHint<T>>(\n entity: T,\n hint: H,\n): Promise<JsonPayload<T, H>>;\n\n/**\n * Provides an API to put an entity, or list of entities, into a JSON payload.\n *\n * The `hint` parameter is a JSON hint that describes what to include in the payload,\n *\n * - fields like `id`, `name`, etc.\n * - relations like m2o, o2m, m2m, and o2o\n * - relations are allowed to provide nested hints, just like nested load hints\n * - custom fields like `fullName: (entity) => entity.firstName + ' ' + entity.lastName`\n */\nexport async function toJSON<T extends Entity, const H extends JsonHint<T>>(\n entities: readonly T[],\n hint: H,\n): Promise<JsonPayload<T, H>[]>;\nexport async function toJSON<T extends Entity, const H extends JsonHint<T>>(\n entityOrList: T | readonly T[],\n hint: H,\n): Promise<JsonPayload<T, H> | JsonPayload<T, H>[]> {\n // If called with a list, and nothing there, just early return\n if (Array.isArray(entityOrList) && entityOrList.length === 0) return [];\n\n // Otherwise probe to get our first entity\n const entity = Array.isArray(entityOrList) ? entityOrList[0] : entityOrList;\n const loadHint = convertToLoadHint(getMetadata(entity), hint as any, true);\n await entity.em.populate(entityOrList, loadHint);\n const normHint = normalizeHint(hint as any);\n\n if (Array.isArray(entityOrList)) {\n const list = [] as any;\n await Promise.all(\n entityOrList.map((entity) => {\n const json = {};\n list.push(json);\n return copyToPayload(json, entity, normHint);\n }),\n );\n return list;\n } else {\n const json = {};\n await copyToPayload(json, entity, normHint);\n return json as any;\n }\n}\n\n/**\n * Statically types the return value of `toJSON` based on the given `hint`.\n */\nexport type JsonPayload<T, H> = {\n [HK in keyof NormalizeHint<H> & string]: HK extends keyof T\n ? JsonPayloadKey<T, H, HK, HK>\n : HK extends `${infer TK extends string & keyof T}Id`\n ? JsonPayloadKey<T, H, TK, HK>\n : HK extends `${infer SK extends string}Ids` // bookIds -> books\n ? // Very naive singularization to see if the guessed bookIds -> books actually exists on T to map 1:1\n `${SK}s` extends keyof T\n ? JsonPayloadKey<T, H, `${SK}s`, HK>\n : JsonPayloadCustom<NormalizeHint<H>[HK]>\n : JsonPayloadCustom<NormalizeHint<H>[HK]>;\n};\n\ntype JsonPayloadKey<T, H, TK extends keyof T, HK extends keyof NormalizeHint<H>> =\n T[TK] extends Reference<any, infer U, any>\n ? JsonPayloadReference<U, NormalizeHint<H>[HK]>\n : T[TK] extends Collection<any, infer U>\n ? JsonPayloadCollection<U, NormalizeHint<H>[HK]>\n : T[TK] extends Property<any, infer U>\n ? JsonPayloadProperty<U, NormalizeHint<H>[HK]>\n : T[TK] extends ReactiveGetter<any, infer V>\n ? V\n : T[TK];\n\n// If the hint is empty, we just output the id as a string.\ntype JsonPayloadReference<U, H> = IsEmpty<H> extends true ? string : JsonPayload<U, H>;\n\ntype JsonPayloadCollection<U extends Entity, H> =\n // If this is `books: true`, use the id\n H extends true\n ? IdOf<U>[]\n : // If this is `{}`, use the id\n IsEmpty<H> extends true\n ? IdOf<U>[]\n : // Otherwise it's a nested hint\n JsonPayload<U, H>[];\n\ntype JsonPayloadProperty<P, H> =\n // If an async property returns an entity, treat it like a reference\n P extends Entity | undefined\n ? JsonPayloadReference<P, H>\n : // If an async property returns an entity[], treat it like a collection\n P extends (infer U extends Entity)[] | undefined\n ? JsonPayloadCollection<U, H>\n : // Otherwise leave it as-is\n P;\n\ntype JsonPayloadCustom<H> = H extends (...args: any) => infer V ? UnwrapPromise<V> : H;\n\ntype UnwrapPromise<T> = T extends Promise<infer U> ? U : T;\n\n/** Recursively copies the fields of `hint` from `entity` into the `payload`. */\nasync function copyToPayload(payload: Record<string, {}>, entity: any, hint: object): Promise<void> {\n // Look at each key in the hint and determine\n for (const [payloadKey, nestedHint] of Object.entries(hint)) {\n const nextHint = normalizeHint(nestedHint);\n // Watch for `companyId`\n let entityKey = payloadKey;\n if (!(entityKey in entity)) {\n const field = Object.values(getMetadata(entity).allFields).find((f) => f.fieldIdName === payloadKey);\n if (field) {\n entityKey = field.fieldName;\n }\n }\n // Look for custom props\n if (!(entityKey in entity)) {\n if (typeof nestedHint !== \"function\") {\n throw new Error(`Entity does not have a property ${payloadKey}`);\n }\n payload[payloadKey] = await nestedHint(entity);\n } else {\n const value = entity[entityKey];\n if (isPrimitive(value)) {\n payload[payloadKey] = value;\n } else if (\n value instanceof AbstractRelationImpl ||\n value instanceof ReactiveFieldImpl ||\n value instanceof ReactiveGetterImpl ||\n value instanceof AsyncReactiveFieldImpl ||\n value instanceof PropertyImpl\n ) {\n await copyToPayloadValue(payload, payloadKey, value.get, nextHint);\n } else {\n throw new Error(`Unable to encode value ${value} to JSON`);\n }\n }\n }\n}\n\nfunction copyToPayloadValue(payload: any, key: any, value: any, nextHint: any): Promise<unknown> | undefined {\n if (value === undefined || value === null || isPrimitive(value)) {\n payload[key] = value;\n } else if (isEntity(value)) {\n if (nextHint && Object.keys(nextHint).length > 0) {\n payload[key] = {};\n return copyToPayload(payload[key], value, nextHint);\n } else {\n payload[key] = value.id;\n }\n } else if (Array.isArray(value)) {\n const list = [] as any[];\n payload[key] = list;\n if (nextHint && Object.keys(nextHint).length > 0) {\n return Promise.all(\n value.map(async (item, i) => {\n if (isEntity(item)) {\n list[i] = {};\n return copyToPayload(list[i], item, nextHint);\n } else {\n // This is probably undefined\n list[i] = item;\n }\n }),\n );\n } else {\n // This is assuming an array of entities...\n for (const item of value) list.push(item.id);\n }\n } else {\n payload[key] = value;\n }\n}\n\nfunction isPrimitive(value: any): boolean {\n return value === null || typeof value !== \"object\";\n}\n\ntype DropUndefined<T> = T extends infer U extends Entity | undefined ? U : T;\n\n// A copy/paste of NormalizeHint w/o the `DropSuffix` stuff\ntype NormalizeHint<H> = H extends string\n ? Record<H, {}>\n : H extends ReadonlyArray<any>\n ? Record<H[number], {}>\n : { [K in keyof H]: H[K] };\n\ntype IsEmpty<T> = keyof T extends never ? true : false;\n"],"mappings":";;;;;;;;;;;;;AAwGA,eAAsB,OACpB,cACA,MACkD;CAElD,IAAI,MAAM,QAAQ,YAAY,KAAK,aAAa,WAAW,GAAG,OAAO,CAAC;CAGtE,MAAM,SAAS,MAAM,QAAQ,YAAY,IAAI,aAAa,KAAK;CAC/D,MAAM,WAAWA,iCAAAA,kBAAkBC,uBAAAA,YAAY,MAAM,GAAG,MAAa,IAAI;CACzE,MAAM,OAAO,GAAG,SAAS,cAAc,QAAQ;CAC/C,MAAM,WAAWC,uBAAAA,cAAc,IAAW;CAE1C,IAAI,MAAM,QAAQ,YAAY,GAAG;EAC/B,MAAM,OAAO,CAAC;EACd,MAAM,QAAQ,IACZ,aAAa,KAAK,WAAW;GAC3B,MAAM,OAAO,CAAC;GACd,KAAK,KAAK,IAAI;GACd,OAAO,cAAc,MAAM,QAAQ,QAAQ;EAC7C,CAAC,CACH;EACA,OAAO;CACT,OAAO;EACL,MAAM,OAAO,CAAC;EACd,MAAM,cAAc,MAAM,QAAQ,QAAQ;EAC1C,OAAO;CACT;AACF;;AAyDA,eAAe,cAAc,SAA6B,QAAa,MAA6B;CAElG,KAAK,MAAM,CAAC,YAAY,eAAe,OAAO,QAAQ,IAAI,GAAG;E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A,eAAAA,SAAS,IAAI,GAAG;IAClB,KAAK,KAAK,CAAC;IACX,OAAO,cAAc,KAAK,IAAI,MAAM,QAAQ;GAC9C,OAEE,KAAK,KAAK;EAEd,CAAC,CACH;OAGA,KAAK,MAAM,QAAQ,OAAO,KAAK,KAAK,KAAK,EAAE;CAE/C,OACE,QAAQ,OAAO;AAEnB;AAEA,SAAS,YAAY,OAAqB;CACxC,OAAO,UAAU,QAAQ,OAAO,UAAU;AAC5C"}
1
+ {"version":3,"file":"json.cjs","names":["convertToLoadHint","getMetadata","normalizeHint","AbstractRelationImpl","ReactiveFieldImpl","ReactiveGetterImpl","AsyncReactiveFieldImpl","PropertyImpl","isEntity"],"sources":["../src/json.ts"],"sourcesContent":["import { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type IdOf } from \"src/EntityManager.ts\";\nimport { getMetadata } from \"src/EntityMetadata.ts\";\nimport { normalizeHint } from \"src/normalizeHints.ts\";\nimport { convertToLoadHint } from \"src/reactivity/reactiveHints.ts\";\nimport { AbstractRelationImpl } from \"src/relations/AbstractRelationImpl.ts\";\nimport { AsyncReactiveFieldImpl } from \"src/relations/AsyncReactiveField.ts\";\nimport { PropertyImpl } from \"src/relations/hasProperty.ts\";\nimport {\n type AsyncMethod,\n type Collection,\n type Property,\n type ReactiveGetter,\n type Reference,\n} from \"src/relations/index.ts\";\nimport { ReactiveFieldImpl } from \"src/relations/ReactiveField.ts\";\nimport { ReactiveGetterImpl } from \"src/relations/ReactiveGetter.ts\";\n\n/**\n * A JSON hint of a single key, multiple keys, or nested keys and sub-hints.\n *\n * JSON hints are much like load hints/reactive hints:\n *\n * - Similar to load hints, they specify which relations should be loaded from the database\n * - Similar to reactive hints, they include specific fields to output\n * - Unlike either, they can include completely custom keys that are lambdas to generate custom values\n */\nexport type JsonHint<T extends Entity> =\n | (keyof Jsonable<T> & string)\n | ReadonlyArray<keyof Jsonable<T> & string>\n | NestedJsonHint<T>;\n\n/** For object literal/nested hints, we allow mapping both entity keys 1:1 & custom keys via a lambdas. */\nexport type NestedJsonHint<T extends Entity> = EntityKeyJsonHint<T> | CustomJsonKeyHint<T>;\n\n/** Foreach `Jsonable` key, we can provide a sub-hint, or just a boolean to include/exclude. */\nexport type EntityKeyJsonHint<T extends Entity> = {\n // The `as K` makes `bookIds` as a hint work...\n [K in keyof Jsonable<T> as `${K}`]?: (Jsonable<T>[K] extends infer U extends Entity ? JsonHint<U> : {}) | boolean;\n};\n\nexport type CustomJsonKeyHint<T> = {\n [key: string]: (entity: T) => any;\n};\n\n/**\n * Describes the JSON payload for `Entity.toJSON` to produce.\n *\n * - `[\"firstName\", \"lastName\"]` will produce a JSON payload with just those fields\n * - `{ author: { books: \"title\" } }` will produce a JSON payload with the author's books' titles\n *\n * We only accept object literals & arrays to `toJSON` to avoid a `JSON.stringify` oddity.\n */\nexport type ToJsonHint<T extends Entity> = NestedJsonHint<T> | ReadonlyArray<keyof Jsonable<T> & string>;\n\n/** The keys in `T` that we can put into a JSON payload. */\nexport type Jsonable<T extends Entity> = {\n -readonly [K in keyof T as JsonableValue<T[K]> extends never ? never : K]: JsonableValue<T[K]>;\n};\n\n// this should probably be `keyof T` as long as they aren't methods/AsyncMethods.\n// so primitives, enums, references, collections, async properties, but also random getters.\nexport type JsonableValue<V> =\n V extends Reference<any, infer U, any>\n ? U\n : V extends Collection<any, infer U>\n ? U\n : V extends AsyncMethod<any, any, any>\n ? never\n : V extends Property<any, infer P>\n ? DropUndefined<P>\n : V extends ReactiveGetter<any, infer P>\n ? P\n : V;\n\n/**\n * Provides an API to put an entity, or list of entities, into a JSON payload.\n *\n * The `hint` parameter is a JSON hint that describes what to include in the payload,\n *\n * - fields like `id`, `name`, etc.\n * - relations like m2o, o2m, m2m, and o2o\n * - relations are allowed to provide nested hints, just like nested load hints\n * - custom fields like `fullName: (entity) => entity.firstName + ' ' + entity.lastName`\n */\nexport async function toJSON<T extends Entity, const H extends JsonHint<T>>(\n entity: T,\n hint: H,\n): Promise<JsonPayload<T, H>>;\n\n/**\n * Provides an API to put an entity, or list of entities, into a JSON payload.\n *\n * The `hint` parameter is a JSON hint that describes what to include in the payload,\n *\n * - fields like `id`, `name`, etc.\n * - relations like m2o, o2m, m2m, and o2o\n * - relations are allowed to provide nested hints, just like nested load hints\n * - custom fields like `fullName: (entity) => entity.firstName + ' ' + entity.lastName`\n */\nexport async function toJSON<T extends Entity, const H extends JsonHint<T>>(\n entities: readonly T[],\n hint: H,\n): Promise<JsonPayload<T, H>[]>;\nexport async function toJSON<T extends Entity, const H extends JsonHint<T>>(\n entityOrList: T | readonly T[],\n hint: H,\n): Promise<JsonPayload<T, H> | JsonPayload<T, H>[]> {\n // If called with a list, and nothing there, just early return\n if (Array.isArray(entityOrList) && entityOrList.length === 0) return [];\n\n // Otherwise probe to get our first entity\n const entity = Array.isArray(entityOrList) ? entityOrList[0] : entityOrList;\n const loadHint = convertToLoadHint(getMetadata(entity), hint as any, true);\n await entity.em.populate(entityOrList, loadHint);\n const normHint = normalizeHint(hint as any);\n\n if (Array.isArray(entityOrList)) {\n const list = [] as any;\n await Promise.all(\n entityOrList.map((entity) => {\n const json = {};\n list.push(json);\n return copyToPayload(json, entity, normHint);\n }),\n );\n return list;\n } else {\n const json = {};\n await copyToPayload(json, entity, normHint);\n return json as any;\n }\n}\n\n/**\n * Statically types the return value of `toJSON` based on the given `hint`.\n */\nexport type JsonPayload<T, H> = {\n [HK in keyof NormalizeHint<H> & string]: HK extends keyof T\n ? JsonPayloadKey<T, H, HK, HK>\n : HK extends `${infer TK extends string & keyof T}Id`\n ? JsonPayloadKey<T, H, TK, HK>\n : HK extends `${infer SK extends string}Ids` // bookIds -> books\n ? // Very naive singularization to see if the guessed bookIds -> books actually exists on T to map 1:1\n `${SK}s` extends keyof T\n ? JsonPayloadKey<T, H, `${SK}s`, HK>\n : JsonPayloadCustom<NormalizeHint<H>[HK]>\n : JsonPayloadCustom<NormalizeHint<H>[HK]>;\n};\n\ntype JsonPayloadKey<T, H, TK extends keyof T, HK extends keyof NormalizeHint<H>> =\n T[TK] extends Reference<any, infer U, any>\n ? JsonPayloadReference<U, NormalizeHint<H>[HK]>\n : T[TK] extends Collection<any, infer U>\n ? JsonPayloadCollection<U, NormalizeHint<H>[HK]>\n : T[TK] extends Property<any, infer U>\n ? JsonPayloadProperty<U, NormalizeHint<H>[HK]>\n : T[TK] extends ReactiveGetter<any, infer V>\n ? V\n : TK extends \"id\"\n ? T[TK] | null\n : T[TK];\n\n// If the hint is true or empty, output the id, or null if no id has been assigned.\ntype JsonPayloadReference<U, H> = H extends true\n ? string | null\n : IsEmpty<H> extends true\n ? string | null\n : JsonPayload<U, H>;\n\ntype JsonPayloadCollection<U extends Entity, H> =\n // If this is `books: true`, use the id\n H extends true\n ? (IdOf<U> | null)[]\n : // If this is `{}`, use the id\n IsEmpty<H> extends true\n ? (IdOf<U> | null)[]\n : // Otherwise it's a nested hint\n JsonPayload<U, H>[];\n\ntype JsonPayloadProperty<P, H> =\n // If an async property returns an entity, treat it like a reference\n P extends Entity | undefined\n ? JsonPayloadReference<P, H>\n : // If an async property returns an entity[], treat it like a collection\n P extends (infer U extends Entity)[] | undefined\n ? JsonPayloadCollection<U, H>\n : // Otherwise leave it as-is\n P;\n\ntype JsonPayloadCustom<H> = H extends (...args: any) => infer V ? UnwrapPromise<V> : H;\n\ntype UnwrapPromise<T> = T extends Promise<infer U> ? U : T;\n\n/** Recursively copies the fields of `hint` from `entity` into the `payload`. */\nasync function copyToPayload(payload: Record<string, {}>, entity: any, hint: object): Promise<void> {\n // Look at each key in the hint and determine\n for (const [payloadKey, nestedHint] of Object.entries(hint)) {\n const nextHint = normalizeHint(nestedHint);\n // Watch for `companyId`\n let entityKey = payloadKey;\n if (!(entityKey in entity)) {\n const field = Object.values(getMetadata(entity).allFields).find((f) => f.fieldIdName === payloadKey);\n if (field) {\n entityKey = field.fieldName;\n }\n }\n // Look for custom props\n if (!(entityKey in entity)) {\n if (typeof nestedHint !== \"function\") {\n throw new Error(`Entity does not have a property ${payloadKey}`);\n }\n payload[payloadKey] = await nestedHint(entity);\n } else {\n // Match the safe no-hint default: a new entity has no id until it is flushed.\n const value = entityKey === \"id\" ? (entity.idMaybe ?? null) : entity[entityKey];\n if (isPrimitive(value) || value instanceof Date) {\n payload[payloadKey] = value;\n } else if (\n value instanceof AbstractRelationImpl ||\n value instanceof ReactiveFieldImpl ||\n value instanceof ReactiveGetterImpl ||\n value instanceof AsyncReactiveFieldImpl ||\n value instanceof PropertyImpl\n ) {\n await copyToPayloadValue(payload, payloadKey, value.get, nextHint);\n } else {\n throw new Error(`Unable to encode value ${value} to JSON`);\n }\n }\n }\n}\n\nfunction copyToPayloadValue(payload: any, key: any, value: any, nextHint: any): Promise<unknown> | undefined {\n if (value === undefined || value === null || isPrimitive(value)) {\n payload[key] = value;\n } else if (isEntity(value)) {\n if (nextHint && Object.keys(nextHint).length > 0) {\n payload[key] = {};\n return copyToPayload(payload[key], value, nextHint);\n } else {\n payload[key] = value.idMaybe ?? null;\n }\n } else if (Array.isArray(value)) {\n const list = [] as any[];\n payload[key] = list;\n if (nextHint && Object.keys(nextHint).length > 0) {\n return Promise.all(\n value.map(async (item, i) => {\n if (isEntity(item)) {\n list[i] = {};\n return copyToPayload(list[i], item, nextHint);\n } else {\n // This is probably undefined\n list[i] = item;\n }\n }),\n );\n } else {\n // This is assuming an array of entities...\n for (const item of value) list.push(item.idMaybe ?? null);\n }\n } else {\n payload[key] = value;\n }\n}\n\nfunction isPrimitive(value: any): boolean {\n return value === null || typeof value !== \"object\";\n}\n\ntype DropUndefined<T> = T extends infer U extends Entity | undefined ? U : T;\n\n// A copy/paste of NormalizeHint w/o the `DropSuffix` stuff\ntype NormalizeHint<H> = H extends string\n ? Record<H, {}>\n : H extends ReadonlyArray<any>\n ? Record<H[number], {}>\n : { [K in keyof H]: H[K] };\n\ntype IsEmpty<T> = keyof T extends never ? true : false;\n"],"mappings":";;;;;;;;;;;;;AAwGA,eAAsB,OACpB,cACA,MACkD;CAElD,IAAI,M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AiBC,gCAAAA,qBACjB,iBAAiBC,iCAAAA,sBACjB,iBAAiBC,qCAAAA,0BACjB,iBAAiBC,8BAAAA,cAEjB,MAAM,mBAAmB,SAAS,YAAY,MAAM,KAAK,QAAQ;QAEjE,MAAM,IAAI,MAAM,0BAA0B,MAAM,SAAS;EAE7D;CACF;AACF;AAEA,SAAS,mBAAmB,SAAc,KAAU,OAAY,UAA6C;CAC3G,IAAI,UAAU,KAAA,KAAa,UAAU,QAAQ,YAAY,KAAK,GAC5D,QAAQ,OAAO;MACV,IAAIC,eAAAA,SAAS,KAAK,GAAG;EAC1B,IAAI,YAAY,OAAO,KAAK,QAAQ,CAAC,CAAC,SAAS,GAAG;GAChD,QAAQ,OAAO,CAAC;GAChB,OAAO,cAAc,QAAQ,MAAM,OAAO,QAAQ;EACpD,OACE,QAAQ,OAAO,MAAM,WAAW;CAEpC,OAAO,IAAI,MAAM,QAAQ,KAAK,GAAG;EAC/B,MAAM,OAAO,CAAC;EACd,QAAQ,OAAO;EACf,IAAI,YAAY,OAAO,KAAK,QAAQ,CAAC,CAAC,SAAS,GAC7C,OAAO,QAAQ,IACb,MAAM,IAAI,OAAO,MAAM,MAAM;GAC3B,IAAIA,eAAAA,SAAS,IAAI,GAAG;IAClB,KAAK,KAAK,CAAC;IACX,OAAO,cAAc,KAAK,IAAI,MAAM,QAAQ;GAC9C,OAEE,KAAK,KAAK;EAEd,CAAC,CACH;OAGA,KAAK,MAAM,QAAQ,OAAO,KAAK,KAAK,KAAK,WAAW,IAAI;CAE5D,OACE,QAAQ,OAAO;AAEnB;AAEA,SAAS,YAAY,OAAqB;CACxC,OAAO,UAAU,QAAQ,OAAO,UAAU;AAC5C"}
package/build/json.d.cts CHANGED
@@ -3,10 +3,9 @@ import { AsyncMethod } from "./relations/hasAsyncMethod.cjs";
3
3
  import { Property } from "./relations/hasProperty.cjs";
4
4
  import { Reference } from "./relations/Reference.cjs";
5
5
  import { ReactiveGetter } from "./relations/ReactiveGetter.cjs";
6
- import "./relations/index.cjs";
7
- import { IdOf } from "./EntityManager.cjs";
8
6
  import { Entity } from "./Entity.cjs";
9
- //#region src/json.d.ts
7
+ import { IdOf } from "./EntityManager.cjs";
8
+ import "./relations/index.cjs";
10
9
  /**
11
10
  * A JSON hint of a single key, multiple keys, or nested keys and sub-hints.
12
11
  *
@@ -62,15 +61,14 @@ export declare function toJSON<T extends Entity, const H extends JsonHint<T>>(en
62
61
  * Statically types the return value of `toJSON` based on the given `hint`.
63
62
  */
64
63
  export type JsonPayload<T, H> = { [HK in keyof NormalizeHint<H> & string]: HK extends keyof T ? JsonPayloadKey<T, H, HK, HK> : HK extends `${infer TK extends string & keyof T}Id` ? JsonPayloadKey<T, H, TK, HK> : HK extends `${infer SK extends string}Ids` ? `${SK}s` extends keyof T ? JsonPayloadKey<T, H, `${SK}s`, HK> : JsonPayloadCustom<NormalizeHint<H>[HK]> : JsonPayloadCustom<NormalizeHint<H>[HK]>; };
65
- type JsonPayloadKey<T, H, TK extends keyof T, HK extends keyof NormalizeHint<H>> = T[TK] extends Reference<any, infer U, any> ? JsonPayloadReference<U, NormalizeHint<H>[HK]> : T[TK] extends Collection<any, infer U> ? JsonPayloadCollection<U, NormalizeHint<H>[HK]> : T[TK] extends Property<any, infer U> ? JsonPayloadProperty<U, NormalizeHint<H>[HK]> : T[TK] extends ReactiveGetter<any, infer V> ? V : T[TK];
66
- type JsonPayloadReference<U, H> = IsEmpty<H> extends true ? string : JsonPayload<U, H>;
67
- type JsonPayloadCollection<U extends Entity, H> = H extends true ? IdOf<U>[] : IsEmpty<H> extends true ? IdOf<U>[] : JsonPayload<U, H>[];
64
+ type JsonPayloadKey<T, H, TK extends keyof T, HK extends keyof NormalizeHint<H>> = T[TK] extends Reference<any, infer U, any> ? JsonPayloadReference<U, NormalizeHint<H>[HK]> : T[TK] extends Collection<any, infer U> ? JsonPayloadCollection<U, NormalizeHint<H>[HK]> : T[TK] extends Property<any, infer U> ? JsonPayloadProperty<U, NormalizeHint<H>[HK]> : T[TK] extends ReactiveGetter<any, infer V> ? V : TK extends "id" ? T[TK] | null : T[TK];
65
+ type JsonPayloadReference<U, H> = H extends true ? string | null : IsEmpty<H> extends true ? string | null : JsonPayload<U, H>;
66
+ type JsonPayloadCollection<U extends Entity, H> = H extends true ? (IdOf<U> | null)[] : IsEmpty<H> extends true ? (IdOf<U> | null)[] : JsonPayload<U, H>[];
68
67
  type JsonPayloadProperty<P, H> = P extends Entity | undefined ? JsonPayloadReference<P, H> : P extends (infer U extends Entity)[] | undefined ? JsonPayloadCollection<U, H> : P;
69
68
  type JsonPayloadCustom<H> = H extends ((...args: any) => infer V) ? UnwrapPromise<V> : H;
70
69
  type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
71
70
  type DropUndefined<T> = T extends (infer U extends Entity | undefined) ? U : T;
72
71
  type NormalizeHint<H> = H extends string ? Record<H, {}> : H extends ReadonlyArray<any> ? Record<H[number], {}> : { [K in keyof H]: H[K]; };
73
72
  type IsEmpty<T> = keyof T extends never ? true : false;
74
- //#endregion
75
73
  export {};
76
74
  //# sourceMappingURL=json.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.cts","names":[],"sources":["../src/json.ts"],"mappings":";;;;;;;;;;;;;;;;;;YA2BY,SAAS,UAAU,iBACpB,SAAS,eAChB,oBAAoB,SAAS,eAC7B,eAAe;;YAGP,eAAe,UAAU,UAAU,kBAAkB,KAAK,kBAAkB;;YAG5E,kBAAkB,UAAU,aAErC,WAAW,SAAS,SAAS,QAAQ,SAAS,GAAG,kBAAiB,UAAU,UAAS,SAAS;YAGrF,kBAAkB;GAC3B,eAAe,QAAQ;;;;;;;;;;YAWd,WAAW,UAAU,UAAU,eAAe,KAAK,oBAAoB,SAAS;;YAGhF,SAAS,UAAU,uBAClB,WAAW,KAAK,cAAc,EAAE,4BAA4B,IAAI,cAAc,EAAE;YAKjF,cAAc,KACxB,UAAU,qBAAqB,UAC3B,IACA,UAAU,sBAAsB,KAC9B,IACA,UAAU,q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EAAE,YAAY,sBAAsB,KAClC,sBAAsB,GAAG,cAAc,GAAG,OAC1C,EAAE,YAAY,oBAAoB,KAChC,oBAAoB,GAAG,cAAc,GAAG,OACxC,EAAE,YAAY,0BAA0B,KACtC,IACA,kBACE,EAAE,aACF,EAAE;KAGX,qBAAqB,GAAG,KAAK,iCAE9B,QAAQ,kCAEN,YAAY,GAAG;KAEhB,sBAAsB,UAAU,QAAQ,KAE3C,kBACK,KAAK,eAEN,QAAQ,mBACL,KAAK,eAEN,YAAY,GAAG;KAElB,oBAAoB,GAAG,KAE1B,UAAU,qBACN,qBAAqB,GAAG,KAExB,iBAAiB,UAAU,wBACzB,sBAAsB,GAAG,KAEzB;KAEH,kBAAkB,KAAK,eAAc,oBAAoB,KAAI,cAAc,KAAK;KAEhF,cAAc,KAAK,UAAU,cAAc,KAAK,IAAI;KA+EpD,cAAc,KAAK,iBAAgB,UAAU,sBAAqB,IAAI;KAGtE,cAAc,KAAK,mBACpB,OAAO,SACP,UAAU,qBACR,OAAO,oBACJ,WAAW,IAAI,EAAE;KAErB,QAAQ,WAAW"}
package/build/json.d.mts CHANGED
@@ -3,10 +3,9 @@ import { AsyncMethod } from "./relations/hasAsyncMethod.mjs";
3
3
  import { Property } from "./relations/hasProperty.mjs";
4
4
  import { Reference } from "./relations/Reference.mjs";
5
5
  import { ReactiveGetter } from "./relations/ReactiveGetter.mjs";
6
- import "./relations/index.mjs";
7
- import { IdOf } from "./EntityManager.mjs";
8
6
  import { Entity } from "./Entity.mjs";
9
- //#region src/json.d.ts
7
+ import { IdOf } from "./EntityManager.mjs";
8
+ import "./relations/index.mjs";
10
9
  /**
11
10
  * A JSON hint of a single key, multiple keys, or nested keys and sub-hints.
12
11
  *
@@ -62,15 +61,14 @@ export declare function toJSON<T extends Entity, const H extends JsonHint<T>>(en
62
61
  * Statically types the return value of `toJSON` based on the given `hint`.
63
62
  */
64
63
  export type JsonPayload<T, H> = { [HK in keyof NormalizeHint<H> & string]: HK extends keyof T ? JsonPayloadKey<T, H, HK, HK> : HK extends `${infer TK extends string & keyof T}Id` ? JsonPayloadKey<T, H, TK, HK> : HK extends `${infer SK extends string}Ids` ? `${SK}s` extends keyof T ? JsonPayloadKey<T, H, `${SK}s`, HK> : JsonPayloadCustom<NormalizeHint<H>[HK]> : JsonPayloadCustom<NormalizeHint<H>[HK]>; };
65
- type JsonPayloadKey<T, H, TK extends keyof T, HK extends keyof NormalizeHint<H>> = T[TK] extends Reference<any, infer U, any> ? JsonPayloadReference<U, NormalizeHint<H>[HK]> : T[TK] extends Collection<any, infer U> ? JsonPayloadCollection<U, NormalizeHint<H>[HK]> : T[TK] extends Property<any, infer U> ? JsonPayloadProperty<U, NormalizeHint<H>[HK]> : T[TK] extends ReactiveGetter<any, infer V> ? V : T[TK];
66
- type JsonPayloadReference<U, H> = IsEmpty<H> extends true ? string : JsonPayload<U, H>;
67
- type JsonPayloadCollection<U extends Entity, H> = H extends true ? IdOf<U>[] : IsEmpty<H> extends true ? IdOf<U>[] : JsonPayload<U, H>[];
64
+ type JsonPayloadKey<T, H, TK extends keyof T, HK extends keyof NormalizeHint<H>> = T[TK] extends Reference<any, infer U, any> ? JsonPayloadReference<U, NormalizeHint<H>[HK]> : T[TK] extends Collection<any, infer U> ? JsonPayloadCollection<U, NormalizeHint<H>[HK]> : T[TK] extends Property<any, infer U> ? JsonPayloadProperty<U, NormalizeHint<H>[HK]> : T[TK] extends ReactiveGetter<any, infer V> ? V : TK extends "id" ? T[TK] | null : T[TK];
65
+ type JsonPayloadReference<U, H> = H extends true ? string | null : IsEmpty<H> extends true ? string | null : JsonPayload<U, H>;
66
+ type JsonPayloadCollection<U extends Entity, H> = H extends true ? (IdOf<U> | null)[] : IsEmpty<H> extends true ? (IdOf<U> | null)[] : JsonPayload<U, H>[];
68
67
  type JsonPayloadProperty<P, H> = P extends Entity | undefined ? JsonPayloadReference<P, H> : P extends (infer U extends Entity)[] | undefined ? JsonPayloadCollection<U, H> : P;
69
68
  type JsonPayloadCustom<H> = H extends ((...args: any) => infer V) ? UnwrapPromise<V> : H;
70
69
  type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
71
70
  type DropUndefined<T> = T extends (infer U extends Entity | undefined) ? U : T;
72
71
  type NormalizeHint<H> = H extends string ? Record<H, {}> : H extends ReadonlyArray<any> ? Record<H[number], {}> : { [K in keyof H]: H[K]; };
73
72
  type IsEmpty<T> = keyof T extends never ? true : false;
74
- //#endregion
75
73
  export {};
76
74
  //# sourceMappingURL=json.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.mts","names":[],"sources":["../src/json.ts"],"mappings":";;;;;;;;;;;;;;;;;;YA2BY,SAAS,UAAU,iBACpB,SAAS,eAChB,oBAAoB,SAAS,eAC7B,eAAe;;YAGP,eAAe,UAAU,UAAU,kBAAkB,KAAK,kBAAkB;;YAG5E,kBAAkB,UAAU,aAErC,WAAW,SAAS,SAAS,QAAQ,SAAS,GAAG,kBAAiB,UAAU,UAAS,SAAS;YAGrF,kBAAkB;GAC3B,eAAe,QAAQ;;;;;;;;;;YAWd,WAAW,UAAU,UAAU,eAAe,KAAK,oBAAoB,SAAS;;YAGhF,SAAS,UAAU,uBAClB,WAAW,KAAK,cAAc,EAAE,4BAA4B,IAAI,cAAc,EAAE;YAKjF,cAAc,KACxB,UAAU,qBAAqB,UAC3B,IACA,UAAU,sBAAsB,KAC9B,IACA,UAAU,qCAER,UAAU,oBAAoB,KAC5B,cAAc,KACd,UAAU,0BAA0B,KAClC,IACA;;;;;;;;;;;wBAYQ,OAAO,UAAU,cAAc,UAAU,SAAS,IACtE,QAAQ,GACR,MAAM,IACL,QAAQ,YAAY,GAAG;;;;;;;;;;;wBAYJ,OAAO,UAAU,cAAc,UAAU,SAAS,IACtE,mBAAmB,KACnB,MAAM,IACL,QAAQ,YAAY,GAAG;;;;YAkCd,YAAY,GAAG,QACxB,YAAY,cAAc,cAAc,iBAAiB,IACtD,eAAe,GAAG,GAAG,IAAI,MACzB,oBAAoB,0BAA0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AAqB,GAAG,KAExB,iBAAiB,UAAU,wBACzB,sBAAsB,GAAG,KAEzB;KAEH,kBAAkB,KAAK,eAAc,oBAAoB,KAAI,cAAc,KAAK;KAEhF,cAAc,KAAK,UAAU,cAAc,KAAK,IAAI;KA+EpD,cAAc,KAAK,iBAAgB,UAAU,sBAAqB,IAAI;KAGtE,cAAc,KAAK,mBACpB,OAAO,SACP,UAAU,qBACR,OAAO,oBACJ,WAAW,IAAI,EAAE;KAErB,QAAQ,WAAW"}
package/build/json.js CHANGED
@@ -1,15 +1,15 @@
1
- import { AbstractRelationImpl } from "./relations/AbstractRelationImpl.js";
1
+ import { isEntity } from "./Entity.js";
2
+ import "./EntityManager.js";
3
+ import { getMetadata } from "./EntityMetadata.js";
2
4
  import { normalizeHint } from "./normalizeHints.js";
3
- import { ReactiveGetterImpl } from "./relations/ReactiveGetter.js";
4
5
  import { convertToLoadHint } from "./reactivity/reactiveHints.js";
5
- import { PropertyImpl } from "./relations/hasProperty.js";
6
- import { ReactiveFieldImpl } from "./relations/ReactiveField.js";
6
+ import { AbstractRelationImpl } from "./relations/AbstractRelationImpl.js";
7
7
  import { AsyncReactiveFieldImpl } from "./relations/AsyncReactiveField.js";
8
+ import { PropertyImpl } from "./relations/hasProperty.js";
8
9
  import "./relations/index.js";
9
- import { getMetadata } from "./EntityMetadata.js";
10
- import "./EntityManager.js";
11
- import { isEntity } from "./Entity.js";
12
- //#region src/json.ts
10
+ import { ReactiveFieldImpl } from "./relations/ReactiveField.js";
11
+ import { ReactiveGetterImpl } from "./relations/ReactiveGetter.js";
12
+ // src/json.ts
13
13
  async function toJSON(entityOrList, hint) {
14
14
  if (Array.isArray(entityOrList) && entityOrList.length === 0) return [];
15
15
  const entity = Array.isArray(entityOrList) ? entityOrList[0] : entityOrList;
@@ -43,8 +43,8 @@ async function copyToPayload(payload, entity, hint) {
43
43
  if (typeof nestedHint !== "function") throw new Error(`Entity does not have a property ${payloadKey}`);
44
44
  payload[payloadKey] = await nestedHint(entity);
45
45
  } else {
46
- const value = entity[entityKey];
47
- if (isPrimitive(value)) payload[payloadKey] = value;
46
+ const value = entityKey === "id" ? entity.idMaybe ?? null : entity[entityKey];
47
+ if (isPrimitive(value) || value instanceof Date) payload[payloadKey] = value;
48
48
  else if (value instanceof AbstractRelationImpl || value instanceof ReactiveFieldImpl || value instanceof ReactiveGetterImpl || value instanceof AsyncReactiveFieldImpl || value instanceof PropertyImpl) await copyToPayloadValue(payload, payloadKey, value.get, nextHint);
49
49
  else throw new Error(`Unable to encode value ${value} to JSON`);
50
50
  }
@@ -56,7 +56,7 @@ function copyToPayloadValue(payload, key, value, nextHint) {
56
56
  if (nextHint && Object.keys(nextHint).length > 0) {
57
57
  payload[key] = {};
58
58
  return copyToPayload(payload[key], value, nextHint);
59
- } else payload[key] = value.id;
59
+ } else payload[key] = value.idMaybe ?? null;
60
60
  } else if (Array.isArray(value)) {
61
61
  const list = [];
62
62
  payload[key] = list;
@@ -66,13 +66,12 @@ function copyToPayloadValue(payload, key, value, nextHint) {
66
66
  return copyToPayload(list[i], item, nextHint);
67
67
  } else list[i] = item;
68
68
  }));
69
- else for (const item of value) list.push(item.id);
69
+ else for (const item of value) list.push(item.idMaybe ?? null);
70
70
  } else payload[key] = value;
71
71
  }
72
72
  function isPrimitive(value) {
73
73
  return value === null || typeof value !== "object";
74
74
  }
75
- //#endregion
76
75
  export { toJSON };
77
76
 
78
77
  //# sourceMappingURL=json.js.map