joist-core 2.4.0-next.37 → 2.4.0-next.39

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 (691) hide show
  1. package/build/BaseEntity.d.cts +3 -4
  2. package/build/BaseEntity.d.cts.map +1 -1
  3. package/build/BaseEntity.d.mts +3 -4
  4. package/build/BaseEntity.d.mts.map +1 -1
  5. package/build/Entity.d.cts +3 -4
  6. package/build/Entity.d.cts.map +1 -1
  7. package/build/Entity.d.mts +3 -4
  8. package/build/Entity.d.mts.map +1 -1
  9. package/build/EntityFields.d.cts +3 -4
  10. package/build/EntityFields.d.cts.map +1 -1
  11. package/build/EntityFields.d.mts +3 -4
  12. package/build/EntityFields.d.mts.map +1 -1
  13. package/build/EntityManager.cjs +11 -3
  14. package/build/EntityManager.cjs.map +1 -1
  15. package/build/EntityManager.d.cts +47 -41
  16. package/build/EntityManager.d.cts.map +1 -1
  17. package/build/EntityManager.d.mts +47 -41
  18. package/build/EntityManager.d.mts.map +1 -1
  19. package/build/EntityManager.js +11 -3
  20. package/build/EntityManager.js.map +1 -1
  21. package/build/EntityMetadata.d.cts +31 -32
  22. package/build/EntityMetadata.d.cts.map +1 -1
  23. package/build/EntityMetadata.d.mts +31 -32
  24. package/build/EntityMetadata.d.mts.map +1 -1
  25. package/build/EnumMetadata.d.cts +1 -2
  26. package/build/EnumMetadata.d.cts.map +1 -1
  27. package/build/EnumMetadata.d.mts +1 -2
  28. package/build/EnumMetadata.d.mts.map +1 -1
  29. package/build/IndexManager.cjs.map +1 -1
  30. package/build/IndexManager.d.cts +2 -3
  31. package/build/IndexManager.d.cts.map +1 -1
  32. package/build/IndexManager.d.mts +2 -3
  33. package/build/IndexManager.d.mts.map +1 -1
  34. package/build/IndexManager.js.map +1 -1
  35. package/build/InstanceData.cjs.map +1 -1
  36. package/build/InstanceData.d.cts +1 -2
  37. package/build/InstanceData.d.cts.map +1 -1
  38. package/build/InstanceData.d.mts +1 -2
  39. package/build/InstanceData.d.mts.map +1 -1
  40. package/build/InstanceData.js.map +1 -1
  41. package/build/PluginManager.cjs.map +1 -1
  42. package/build/PluginManager.d.cts +4 -4
  43. package/build/PluginManager.d.cts.map +1 -1
  44. package/build/PluginManager.d.mts +4 -4
  45. package/build/PluginManager.d.mts.map +1 -1
  46. package/build/PluginManager.js.map +1 -1
  47. package/build/RowData.d.cts +3 -4
  48. package/build/RowData.d.cts.map +1 -1
  49. package/build/RowData.d.mts +3 -4
  50. package/build/RowData.d.mts.map +1 -1
  51. package/build/batchloaders/BatchLoader.cjs.map +1 -1
  52. package/build/batchloaders/BatchLoader.d.cts +1 -2
  53. package/build/batchloaders/BatchLoader.d.cts.map +1 -1
  54. package/build/batchloaders/BatchLoader.d.mts +1 -2
  55. package/build/batchloaders/BatchLoader.d.mts.map +1 -1
  56. package/build/batchloaders/BatchLoader.js.map +1 -1
  57. package/build/batchloaders/enumCollectionBatchLoader.d.cts +2 -3
  58. package/build/batchloaders/enumCollectionBatchLoader.d.cts.map +1 -1
  59. package/build/batchloaders/enumCollectionBatchLoader.d.mts +2 -3
  60. package/build/batchloaders/enumCollectionBatchLoader.d.mts.map +1 -1
  61. package/build/batchloaders/loadBatchLoader.d.cts +2 -3
  62. package/build/batchloaders/loadBatchLoader.d.cts.map +1 -1
  63. package/build/batchloaders/loadBatchLoader.d.mts +2 -3
  64. package/build/batchloaders/loadBatchLoader.d.mts.map +1 -1
  65. package/build/batchloaders/manyToManyBatchLoader.d.cts +2 -3
  66. package/build/batchloaders/manyToManyBatchLoader.d.cts.map +1 -1
  67. package/build/batchloaders/manyToManyBatchLoader.d.mts +2 -3
  68. package/build/batchloaders/manyToManyBatchLoader.d.mts.map +1 -1
  69. package/build/batchloaders/oneToManyBatchLoader.d.cts +2 -3
  70. package/build/batchloaders/oneToManyBatchLoader.d.cts.map +1 -1
  71. package/build/batchloaders/oneToManyBatchLoader.d.mts +2 -3
  72. package/build/batchloaders/oneToManyBatchLoader.d.mts.map +1 -1
  73. package/build/batchloaders/oneToOneBatchLoader.d.cts +2 -3
  74. package/build/batchloaders/oneToOneBatchLoader.d.cts.map +1 -1
  75. package/build/batchloaders/oneToOneBatchLoader.d.mts +2 -3
  76. package/build/batchloaders/oneToOneBatchLoader.d.mts.map +1 -1
  77. package/build/batchloaders/populateBatchLoader.d.cts +2 -3
  78. package/build/batchloaders/populateBatchLoader.d.cts.map +1 -1
  79. package/build/batchloaders/populateBatchLoader.d.mts +2 -3
  80. package/build/batchloaders/populateBatchLoader.d.mts.map +1 -1
  81. package/build/batchloaders/recursiveChildrenBatchLoader.d.cts +2 -3
  82. package/build/batchloaders/recursiveChildrenBatchLoader.d.cts.map +1 -1
  83. package/build/batchloaders/recursiveChildrenBatchLoader.d.mts +2 -3
  84. package/build/batchloaders/recursiveChildrenBatchLoader.d.mts.map +1 -1
  85. package/build/batchloaders/recursiveM2mBatchLoader.d.cts +2 -3
  86. package/build/batchloaders/recursiveM2mBatchLoader.d.cts.map +1 -1
  87. package/build/batchloaders/recursiveM2mBatchLoader.d.mts +2 -3
  88. package/build/batchloaders/recursiveM2mBatchLoader.d.mts.map +1 -1
  89. package/build/batchloaders/recursiveParentsBatchLoader.d.cts +2 -3
  90. package/build/batchloaders/recursiveParentsBatchLoader.d.cts.map +1 -1
  91. package/build/batchloaders/recursiveParentsBatchLoader.d.mts +2 -3
  92. package/build/batchloaders/recursiveParentsBatchLoader.d.mts.map +1 -1
  93. package/build/changes.cjs.map +1 -1
  94. package/build/changes.d.cts +9 -10
  95. package/build/changes.d.cts.map +1 -1
  96. package/build/changes.d.mts +9 -10
  97. package/build/changes.d.mts.map +1 -1
  98. package/build/changes.js.map +1 -1
  99. package/build/config.d.cts +17 -17
  100. package/build/config.d.cts.map +1 -1
  101. package/build/config.d.mts +17 -17
  102. package/build/config.d.mts.map +1 -1
  103. package/build/configure.d.cts +8 -9
  104. package/build/configure.d.cts.map +1 -1
  105. package/build/configure.d.mts +8 -9
  106. package/build/configure.d.mts.map +1 -1
  107. package/build/dataloaders/fastWhereFilterHash.d.cts +1 -2
  108. package/build/dataloaders/fastWhereFilterHash.d.cts.map +1 -1
  109. package/build/dataloaders/fastWhereFilterHash.d.mts +1 -2
  110. package/build/dataloaders/fastWhereFilterHash.d.mts.map +1 -1
  111. package/build/dataloaders/findByUniqueDataLoader.d.cts +2 -3
  112. package/build/dataloaders/findByUniqueDataLoader.d.cts.map +1 -1
  113. package/build/dataloaders/findByUniqueDataLoader.d.mts +2 -3
  114. package/build/dataloaders/findByUniqueDataLoader.d.mts.map +1 -1
  115. package/build/dataloaders/findCountDataLoader.d.cts +4 -5
  116. package/build/dataloaders/findCountDataLoader.d.cts.map +1 -1
  117. package/build/dataloaders/findCountDataLoader.d.mts +4 -5
  118. package/build/dataloaders/findCountDataLoader.d.mts.map +1 -1
  119. package/build/dataloaders/findDataLoader.d.cts +11 -12
  120. package/build/dataloaders/findDataLoader.d.cts.map +1 -1
  121. package/build/dataloaders/findDataLoader.d.mts +11 -12
  122. package/build/dataloaders/findDataLoader.d.mts.map +1 -1
  123. package/build/dataloaders/findIdsDataLoader.d.cts +2 -3
  124. package/build/dataloaders/findIdsDataLoader.d.cts.map +1 -1
  125. package/build/dataloaders/findIdsDataLoader.d.mts +2 -3
  126. package/build/dataloaders/findIdsDataLoader.d.mts.map +1 -1
  127. package/build/dataloaders/findOrCreateDataLoader.d.cts +3 -3
  128. package/build/dataloaders/findOrCreateDataLoader.d.cts.map +1 -1
  129. package/build/dataloaders/findOrCreateDataLoader.d.mts +3 -3
  130. package/build/dataloaders/findOrCreateDataLoader.d.mts.map +1 -1
  131. package/build/dataloaders/findPaginatedDataLoader.d.cts +1 -2
  132. package/build/dataloaders/findPaginatedDataLoader.d.cts.map +1 -1
  133. package/build/dataloaders/findPaginatedDataLoader.d.mts +1 -2
  134. package/build/dataloaders/findPaginatedDataLoader.d.mts.map +1 -1
  135. package/build/dataloaders/lensDataLoader.d.cts +2 -3
  136. package/build/dataloaders/lensDataLoader.d.cts.map +1 -1
  137. package/build/dataloaders/lensDataLoader.d.mts +2 -3
  138. package/build/dataloaders/lensDataLoader.d.mts.map +1 -1
  139. package/build/dataloaders/manyToManyFindDataLoader.d.cts +2 -3
  140. package/build/dataloaders/manyToManyFindDataLoader.d.cts.map +1 -1
  141. package/build/dataloaders/manyToManyFindDataLoader.d.mts +2 -3
  142. package/build/dataloaders/manyToManyFindDataLoader.d.mts.map +1 -1
  143. package/build/dataloaders/oneToManyFindDataLoader.d.cts +2 -3
  144. package/build/dataloaders/oneToManyFindDataLoader.d.cts.map +1 -1
  145. package/build/dataloaders/oneToManyFindDataLoader.d.mts +2 -3
  146. package/build/dataloaders/oneToManyFindDataLoader.d.mts.map +1 -1
  147. package/build/defaults.cjs.map +1 -1
  148. package/build/defaults.d.cts +7 -7
  149. package/build/defaults.d.cts.map +1 -1
  150. package/build/defaults.d.mts +7 -7
  151. package/build/defaults.d.mts.map +1 -1
  152. package/build/defaults.js.map +1 -1
  153. package/build/drivers/Driver.d.cts +2 -3
  154. package/build/drivers/Driver.d.cts.map +1 -1
  155. package/build/drivers/Driver.d.mts +2 -3
  156. package/build/drivers/Driver.d.mts.map +1 -1
  157. package/build/drivers/EntityWriter.d.cts +7 -7
  158. package/build/drivers/EntityWriter.d.cts.map +1 -1
  159. package/build/drivers/EntityWriter.d.mts +7 -7
  160. package/build/drivers/EntityWriter.d.mts.map +1 -1
  161. package/build/drivers/IdAssigner.cjs.map +1 -1
  162. package/build/drivers/IdAssigner.d.cts +5 -5
  163. package/build/drivers/IdAssigner.d.cts.map +1 -1
  164. package/build/drivers/IdAssigner.d.mts +5 -5
  165. package/build/drivers/IdAssigner.d.mts.map +1 -1
  166. package/build/drivers/IdAssigner.js.map +1 -1
  167. package/build/drivers/driverApi.d.cts +2 -3
  168. package/build/drivers/driverApi.d.cts.map +1 -1
  169. package/build/drivers/driverApi.d.mts +2 -3
  170. package/build/drivers/driverApi.d.mts.map +1 -1
  171. package/build/fields.d.cts +6 -7
  172. package/build/fields.d.cts.map +1 -1
  173. package/build/fields.d.mts +6 -7
  174. package/build/fields.d.mts.map +1 -1
  175. package/build/flush/FlushLock.cjs.map +1 -1
  176. package/build/flush/FlushLock.d.cts +1 -2
  177. package/build/flush/FlushLock.d.cts.map +1 -1
  178. package/build/flush/FlushLock.d.mts +1 -2
  179. package/build/flush/FlushLock.d.mts.map +1 -1
  180. package/build/flush/FlushLock.js.map +1 -1
  181. package/build/flush/JoinRows.cjs.map +1 -1
  182. package/build/flush/JoinRows.d.cts +5 -6
  183. package/build/flush/JoinRows.d.cts.map +1 -1
  184. package/build/flush/JoinRows.d.mts +5 -6
  185. package/build/flush/JoinRows.d.mts.map +1 -1
  186. package/build/flush/JoinRows.js.map +1 -1
  187. package/build/flush/PendingChanges.d.cts +5 -6
  188. package/build/flush/PendingChanges.d.cts.map +1 -1
  189. package/build/flush/PendingChanges.d.mts +5 -6
  190. package/build/flush/PendingChanges.d.mts.map +1 -1
  191. package/build/flush/Todo.d.cts +5 -6
  192. package/build/flush/Todo.d.cts.map +1 -1
  193. package/build/flush/Todo.d.mts +5 -6
  194. package/build/flush/Todo.d.mts.map +1 -1
  195. package/build/getProperties.d.cts +3 -4
  196. package/build/getProperties.d.cts.map +1 -1
  197. package/build/getProperties.d.mts +3 -4
  198. package/build/getProperties.d.mts.map +1 -1
  199. package/build/index.d.cts +17 -17
  200. package/build/index.d.cts.map +1 -1
  201. package/build/index.d.mts +17 -17
  202. package/build/index.d.mts.map +1 -1
  203. package/build/json.d.cts +11 -11
  204. package/build/json.d.cts.map +1 -1
  205. package/build/json.d.mts +11 -11
  206. package/build/json.d.mts.map +1 -1
  207. package/build/keys.d.cts +27 -27
  208. package/build/keys.d.cts.map +1 -1
  209. package/build/keys.d.mts +27 -27
  210. package/build/keys.d.mts.map +1 -1
  211. package/build/loading/HintTree.d.cts +3 -4
  212. package/build/loading/HintTree.d.cts.map +1 -1
  213. package/build/loading/HintTree.d.mts +3 -4
  214. package/build/loading/HintTree.d.mts.map +1 -1
  215. package/build/loading/IsLoadedCache.cjs.map +1 -1
  216. package/build/loading/IsLoadedCache.d.cts +2 -3
  217. package/build/loading/IsLoadedCache.d.cts.map +1 -1
  218. package/build/loading/IsLoadedCache.d.mts +2 -3
  219. package/build/loading/IsLoadedCache.d.mts.map +1 -1
  220. package/build/loading/IsLoadedCache.js.map +1 -1
  221. package/build/loading/loadHints.d.cts +17 -17
  222. package/build/loading/loadHints.d.cts.map +1 -1
  223. package/build/loading/loadHints.d.mts +17 -17
  224. package/build/loading/loadHints.d.mts.map +1 -1
  225. package/build/loading/loadLens.d.cts +13 -13
  226. package/build/loading/loadLens.d.cts.map +1 -1
  227. package/build/loading/loadLens.d.mts +13 -13
  228. package/build/loading/loadLens.d.mts.map +1 -1
  229. package/build/loading/withLoaded.d.cts +5 -6
  230. package/build/loading/withLoaded.d.cts.map +1 -1
  231. package/build/loading/withLoaded.d.mts +5 -6
  232. package/build/loading/withLoaded.d.mts.map +1 -1
  233. package/build/logging/FactoryLogger.d.cts +3 -4
  234. package/build/logging/FactoryLogger.d.cts.map +1 -1
  235. package/build/logging/FactoryLogger.d.mts +3 -4
  236. package/build/logging/FactoryLogger.d.mts.map +1 -1
  237. package/build/logging/FieldLogger.cjs.map +1 -1
  238. package/build/logging/FieldLogger.d.cts +4 -5
  239. package/build/logging/FieldLogger.d.cts.map +1 -1
  240. package/build/logging/FieldLogger.d.mts +4 -5
  241. package/build/logging/FieldLogger.d.mts.map +1 -1
  242. package/build/logging/FieldLogger.js.map +1 -1
  243. package/build/logging/ReactionLogger.d.cts +7 -7
  244. package/build/logging/ReactionLogger.d.cts.map +1 -1
  245. package/build/logging/ReactionLogger.d.mts +7 -7
  246. package/build/logging/ReactionLogger.d.mts.map +1 -1
  247. package/build/newEntity.cjs.map +1 -1
  248. package/build/newEntity.d.cts +4 -5
  249. package/build/newEntity.d.cts.map +1 -1
  250. package/build/newEntity.d.mts +4 -5
  251. package/build/newEntity.d.mts.map +1 -1
  252. package/build/newEntity.js.map +1 -1
  253. package/build/newTestInstance.d.cts +21 -21
  254. package/build/newTestInstance.d.cts.map +1 -1
  255. package/build/newTestInstance.d.mts +21 -21
  256. package/build/newTestInstance.d.mts.map +1 -1
  257. package/build/normalizeHints.d.cts +7 -8
  258. package/build/normalizeHints.d.cts.map +1 -1
  259. package/build/normalizeHints.d.mts +7 -8
  260. package/build/normalizeHints.d.mts.map +1 -1
  261. package/build/nowUTC.d.cts +4 -5
  262. package/build/nowUTC.d.cts.map +1 -1
  263. package/build/nowUTC.d.mts +4 -5
  264. package/build/nowUTC.d.mts.map +1 -1
  265. package/build/plugins/ImmutableEntitiesPlugin.d.cts +1 -2
  266. package/build/plugins/ImmutableEntitiesPlugin.d.cts.map +1 -1
  267. package/build/plugins/ImmutableEntitiesPlugin.d.mts +1 -2
  268. package/build/plugins/ImmutableEntitiesPlugin.d.mts.map +1 -1
  269. package/build/plugins/PreloadPlugin.d.cts +3 -4
  270. package/build/plugins/PreloadPlugin.d.cts.map +1 -1
  271. package/build/plugins/PreloadPlugin.d.mts +3 -4
  272. package/build/plugins/PreloadPlugin.d.mts.map +1 -1
  273. package/build/preloading/JsonAggregatePreloader.d.cts +1 -2
  274. package/build/preloading/JsonAggregatePreloader.d.cts.map +1 -1
  275. package/build/preloading/JsonAggregatePreloader.d.mts +1 -2
  276. package/build/preloading/JsonAggregatePreloader.d.mts.map +1 -1
  277. package/build/preloading/canPreload.d.cts +1 -2
  278. package/build/preloading/canPreload.d.cts.map +1 -1
  279. package/build/preloading/canPreload.d.mts +1 -2
  280. package/build/preloading/canPreload.d.mts.map +1 -1
  281. package/build/preloading/partitionHint.d.cts +1 -2
  282. package/build/preloading/partitionHint.d.cts.map +1 -1
  283. package/build/preloading/partitionHint.d.mts +1 -2
  284. package/build/preloading/partitionHint.d.mts.map +1 -1
  285. package/build/queries/ConditionBuilder.d.cts +2 -2
  286. package/build/queries/ConditionBuilder.d.cts.map +1 -1
  287. package/build/queries/ConditionBuilder.d.mts +2 -2
  288. package/build/queries/ConditionBuilder.d.mts.map +1 -1
  289. package/build/queries/conditions.d.cts +11 -12
  290. package/build/queries/conditions.d.cts.map +1 -1
  291. package/build/queries/conditions.d.mts +11 -12
  292. package/build/queries/conditions.d.mts.map +1 -1
  293. package/build/queries/entityQueryUtils.d.cts +4 -5
  294. package/build/queries/entityQueryUtils.d.cts.map +1 -1
  295. package/build/queries/entityQueryUtils.d.mts +4 -5
  296. package/build/queries/entityQueryUtils.d.mts.map +1 -1
  297. package/build/queries/find/Aliases.d.cts +16 -16
  298. package/build/queries/find/Aliases.d.cts.map +1 -1
  299. package/build/queries/find/Aliases.d.mts +16 -16
  300. package/build/queries/find/Aliases.d.mts.map +1 -1
  301. package/build/queries/find/DeferredAlias.d.cts +5 -6
  302. package/build/queries/find/DeferredAlias.d.cts.map +1 -1
  303. package/build/queries/find/DeferredAlias.d.mts +5 -6
  304. package/build/queries/find/DeferredAlias.d.mts.map +1 -1
  305. package/build/queries/find/EntityFilter.d.cts +12 -13
  306. package/build/queries/find/EntityFilter.d.cts.map +1 -1
  307. package/build/queries/find/EntityFilter.d.mts +12 -13
  308. package/build/queries/find/EntityFilter.d.mts.map +1 -1
  309. package/build/queries/find/EntityGraphQLFilter.d.cts +8 -9
  310. package/build/queries/find/EntityGraphQLFilter.d.cts.map +1 -1
  311. package/build/queries/find/EntityGraphQLFilter.d.mts +8 -9
  312. package/build/queries/find/EntityGraphQLFilter.d.mts.map +1 -1
  313. package/build/queries/find/QueryParser.collectionJoins.d.cts +1 -2
  314. package/build/queries/find/QueryParser.collectionJoins.d.cts.map +1 -1
  315. package/build/queries/find/QueryParser.collectionJoins.d.mts +1 -2
  316. package/build/queries/find/QueryParser.collectionJoins.d.mts.map +1 -1
  317. package/build/queries/find/QueryParser.d.cts +18 -18
  318. package/build/queries/find/QueryParser.d.cts.map +1 -1
  319. package/build/queries/find/QueryParser.d.mts +18 -18
  320. package/build/queries/find/QueryParser.d.mts.map +1 -1
  321. package/build/queries/find/QueryParser.pruning.d.cts +2 -3
  322. package/build/queries/find/QueryParser.pruning.d.cts.map +1 -1
  323. package/build/queries/find/QueryParser.pruning.d.mts +2 -3
  324. package/build/queries/find/QueryParser.pruning.d.mts.map +1 -1
  325. package/build/queries/find/QueryVisitor.d.cts +4 -4
  326. package/build/queries/find/QueryVisitor.d.cts.map +1 -1
  327. package/build/queries/find/QueryVisitor.d.mts +4 -4
  328. package/build/queries/find/QueryVisitor.d.mts.map +1 -1
  329. package/build/queries/find/buildFindQuery.d.cts +3 -3
  330. package/build/queries/find/buildFindQuery.d.cts.map +1 -1
  331. package/build/queries/find/buildFindQuery.d.mts +3 -3
  332. package/build/queries/find/buildFindQuery.d.mts.map +1 -1
  333. package/build/queries/find/scopes.cjs.map +1 -1
  334. package/build/queries/find/scopes.d.cts +12 -13
  335. package/build/queries/find/scopes.d.cts.map +1 -1
  336. package/build/queries/find/scopes.d.mts +12 -13
  337. package/build/queries/find/scopes.d.mts.map +1 -1
  338. package/build/queries/find/scopes.js.map +1 -1
  339. package/build/queries/parsedConditions.d.cts +7 -8
  340. package/build/queries/parsedConditions.d.cts.map +1 -1
  341. package/build/queries/parsedConditions.d.mts +7 -8
  342. package/build/queries/parsedConditions.d.mts.map +1 -1
  343. package/build/queries/renderConditions.d.cts +3 -4
  344. package/build/queries/renderConditions.d.cts.map +1 -1
  345. package/build/queries/renderConditions.d.mts +3 -4
  346. package/build/queries/renderConditions.d.mts.map +1 -1
  347. package/build/queries/skipCondition.d.cts +1 -2
  348. package/build/queries/skipCondition.d.cts.map +1 -1
  349. package/build/queries/skipCondition.d.mts +1 -2
  350. package/build/queries/skipCondition.d.mts.map +1 -1
  351. package/build/queries/sql/AliasAssigner.cjs.map +1 -1
  352. package/build/queries/sql/AliasAssigner.d.cts +1 -2
  353. package/build/queries/sql/AliasAssigner.d.cts.map +1 -1
  354. package/build/queries/sql/AliasAssigner.d.mts +1 -2
  355. package/build/queries/sql/AliasAssigner.d.mts.map +1 -1
  356. package/build/queries/sql/AliasAssigner.js.map +1 -1
  357. package/build/queries/sql/Expr.d.cts +26 -27
  358. package/build/queries/sql/Expr.d.cts.map +1 -1
  359. package/build/queries/sql/Expr.d.mts +26 -27
  360. package/build/queries/sql/Expr.d.mts.map +1 -1
  361. package/build/queries/sql/JoinTree.d.cts +5 -5
  362. package/build/queries/sql/JoinTree.d.cts.map +1 -1
  363. package/build/queries/sql/JoinTree.d.mts +5 -5
  364. package/build/queries/sql/JoinTree.d.mts.map +1 -1
  365. package/build/queries/sql/Tables.d.cts +39 -39
  366. package/build/queries/sql/Tables.d.cts.map +1 -1
  367. package/build/queries/sql/Tables.d.mts +39 -39
  368. package/build/queries/sql/Tables.d.mts.map +1 -1
  369. package/build/queries/sql/custom.d.cts +14 -14
  370. package/build/queries/sql/custom.d.cts.map +1 -1
  371. package/build/queries/sql/custom.d.mts +14 -14
  372. package/build/queries/sql/custom.d.mts.map +1 -1
  373. package/build/queries/sql/execute.d.cts +15 -15
  374. package/build/queries/sql/execute.d.cts.map +1 -1
  375. package/build/queries/sql/execute.d.mts +15 -15
  376. package/build/queries/sql/execute.d.mts.map +1 -1
  377. package/build/queries/sql/expressions/arrayAgg.d.cts +5 -6
  378. package/build/queries/sql/expressions/arrayAgg.d.cts.map +1 -1
  379. package/build/queries/sql/expressions/arrayAgg.d.mts +5 -6
  380. package/build/queries/sql/expressions/arrayAgg.d.mts.map +1 -1
  381. package/build/queries/sql/expressions/case.d.cts +10 -10
  382. package/build/queries/sql/expressions/case.d.cts.map +1 -1
  383. package/build/queries/sql/expressions/case.d.mts +10 -10
  384. package/build/queries/sql/expressions/case.d.mts.map +1 -1
  385. package/build/queries/sql/expressions/coalesce.d.cts +5 -6
  386. package/build/queries/sql/expressions/coalesce.d.cts.map +1 -1
  387. package/build/queries/sql/expressions/coalesce.d.mts +5 -6
  388. package/build/queries/sql/expressions/coalesce.d.mts.map +1 -1
  389. package/build/queries/sql/expressions/codecs.d.cts +1 -2
  390. package/build/queries/sql/expressions/codecs.d.cts.map +1 -1
  391. package/build/queries/sql/expressions/codecs.d.mts +1 -2
  392. package/build/queries/sql/expressions/codecs.d.mts.map +1 -1
  393. package/build/queries/sql/expressions/expression.d.cts +6 -6
  394. package/build/queries/sql/expressions/expression.d.cts.map +1 -1
  395. package/build/queries/sql/expressions/expression.d.mts +6 -6
  396. package/build/queries/sql/expressions/expression.d.mts.map +1 -1
  397. package/build/queries/sql/expressions/greatest.d.cts +5 -6
  398. package/build/queries/sql/expressions/greatest.d.cts.map +1 -1
  399. package/build/queries/sql/expressions/greatest.d.mts +5 -6
  400. package/build/queries/sql/expressions/greatest.d.mts.map +1 -1
  401. package/build/queries/sql/expressions/least.d.cts +5 -6
  402. package/build/queries/sql/expressions/least.d.cts.map +1 -1
  403. package/build/queries/sql/expressions/least.d.mts +5 -6
  404. package/build/queries/sql/expressions/least.d.mts.map +1 -1
  405. package/build/queries/sql/expressions/nullIf.d.cts +5 -6
  406. package/build/queries/sql/expressions/nullIf.d.cts.map +1 -1
  407. package/build/queries/sql/expressions/nullIf.d.mts +5 -6
  408. package/build/queries/sql/expressions/nullIf.d.mts.map +1 -1
  409. package/build/queries/sql/expressions/parseExpression.d.cts +5 -6
  410. package/build/queries/sql/expressions/parseExpression.d.cts.map +1 -1
  411. package/build/queries/sql/expressions/parseExpression.d.mts +5 -6
  412. package/build/queries/sql/expressions/parseExpression.d.mts.map +1 -1
  413. package/build/queries/sql/expressions/types.d.cts +11 -11
  414. package/build/queries/sql/expressions/types.d.cts.map +1 -1
  415. package/build/queries/sql/expressions/types.d.mts +11 -11
  416. package/build/queries/sql/expressions/types.d.mts.map +1 -1
  417. package/build/queries/sql/keywords.d.cts +4 -5
  418. package/build/queries/sql/keywords.d.cts.map +1 -1
  419. package/build/queries/sql/keywords.d.mts +4 -5
  420. package/build/queries/sql/keywords.d.mts.map +1 -1
  421. package/build/queries/sql/query.cjs.map +1 -1
  422. package/build/queries/sql/query.d.cts +67 -67
  423. package/build/queries/sql/query.d.cts.map +1 -1
  424. package/build/queries/sql/query.d.mts +67 -67
  425. package/build/queries/sql/query.d.mts.map +1 -1
  426. package/build/queries/sql/query.js.map +1 -1
  427. package/build/queries/unnest.d.cts +2 -3
  428. package/build/queries/unnest.d.cts.map +1 -1
  429. package/build/queries/unnest.d.mts +2 -3
  430. package/build/queries/unnest.d.mts.map +1 -1
  431. package/build/queries/valueFilters.d.cts +5 -6
  432. package/build/queries/valueFilters.d.cts.map +1 -1
  433. package/build/queries/valueFilters.d.mts +5 -6
  434. package/build/queries/valueFilters.d.mts.map +1 -1
  435. package/build/reactivity/ReactionsManager.cjs.map +1 -1
  436. package/build/reactivity/ReactionsManager.d.cts +2 -3
  437. package/build/reactivity/ReactionsManager.d.cts.map +1 -1
  438. package/build/reactivity/ReactionsManager.d.mts +2 -3
  439. package/build/reactivity/ReactionsManager.d.mts.map +1 -1
  440. package/build/reactivity/ReactionsManager.js.map +1 -1
  441. package/build/reactivity/reactiveHints.d.cts +18 -18
  442. package/build/reactivity/reactiveHints.d.cts.map +1 -1
  443. package/build/reactivity/reactiveHints.d.mts +18 -18
  444. package/build/reactivity/reactiveHints.d.mts.map +1 -1
  445. package/build/relations/AbstractPropertyImpl.cjs.map +1 -1
  446. package/build/relations/AbstractPropertyImpl.d.cts +1 -2
  447. package/build/relations/AbstractPropertyImpl.d.cts.map +1 -1
  448. package/build/relations/AbstractPropertyImpl.d.mts +1 -2
  449. package/build/relations/AbstractPropertyImpl.d.mts.map +1 -1
  450. package/build/relations/AbstractPropertyImpl.js.map +1 -1
  451. package/build/relations/AbstractRelationImpl.d.cts +1 -2
  452. package/build/relations/AbstractRelationImpl.d.cts.map +1 -1
  453. package/build/relations/AbstractRelationImpl.d.mts +1 -2
  454. package/build/relations/AbstractRelationImpl.d.mts.map +1 -1
  455. package/build/relations/AsyncProperty.cjs.map +1 -1
  456. package/build/relations/AsyncProperty.d.cts +5 -6
  457. package/build/relations/AsyncProperty.d.cts.map +1 -1
  458. package/build/relations/AsyncProperty.d.mts +5 -6
  459. package/build/relations/AsyncProperty.d.mts.map +1 -1
  460. package/build/relations/AsyncProperty.js.map +1 -1
  461. package/build/relations/AsyncReactiveField.cjs.map +1 -1
  462. package/build/relations/AsyncReactiveField.d.cts +4 -5
  463. package/build/relations/AsyncReactiveField.d.cts.map +1 -1
  464. package/build/relations/AsyncReactiveField.d.mts +4 -5
  465. package/build/relations/AsyncReactiveField.d.mts.map +1 -1
  466. package/build/relations/AsyncReactiveField.js.map +1 -1
  467. package/build/relations/Collection.d.cts +4 -5
  468. package/build/relations/Collection.d.cts.map +1 -1
  469. package/build/relations/Collection.d.mts +4 -5
  470. package/build/relations/Collection.d.mts.map +1 -1
  471. package/build/relations/CustomCollection.cjs.map +1 -1
  472. package/build/relations/CustomCollection.d.cts +3 -4
  473. package/build/relations/CustomCollection.d.cts.map +1 -1
  474. package/build/relations/CustomCollection.d.mts +3 -4
  475. package/build/relations/CustomCollection.d.mts.map +1 -1
  476. package/build/relations/CustomCollection.js.map +1 -1
  477. package/build/relations/CustomReference.cjs.map +1 -1
  478. package/build/relations/CustomReference.d.cts +3 -4
  479. package/build/relations/CustomReference.d.cts.map +1 -1
  480. package/build/relations/CustomReference.d.mts +3 -4
  481. package/build/relations/CustomReference.d.mts.map +1 -1
  482. package/build/relations/CustomReference.js.map +1 -1
  483. package/build/relations/EnumCollection.cjs.map +1 -1
  484. package/build/relations/EnumCollection.d.cts +5 -5
  485. package/build/relations/EnumCollection.d.cts.map +1 -1
  486. package/build/relations/EnumCollection.d.mts +5 -5
  487. package/build/relations/EnumCollection.d.mts.map +1 -1
  488. package/build/relations/EnumCollection.js.map +1 -1
  489. package/build/relations/LargeCollection.d.cts +1 -2
  490. package/build/relations/LargeCollection.d.cts.map +1 -1
  491. package/build/relations/LargeCollection.d.mts +1 -2
  492. package/build/relations/LargeCollection.d.mts.map +1 -1
  493. package/build/relations/LazyField.cjs.map +1 -1
  494. package/build/relations/LazyField.d.cts +7 -8
  495. package/build/relations/LazyField.d.cts.map +1 -1
  496. package/build/relations/LazyField.d.mts +7 -8
  497. package/build/relations/LazyField.d.mts.map +1 -1
  498. package/build/relations/LazyField.js.map +1 -1
  499. package/build/relations/ManyToManyCollection.cjs.map +1 -1
  500. package/build/relations/ManyToManyCollection.d.cts +2 -3
  501. package/build/relations/ManyToManyCollection.d.cts.map +1 -1
  502. package/build/relations/ManyToManyCollection.d.mts +2 -3
  503. package/build/relations/ManyToManyCollection.d.mts.map +1 -1
  504. package/build/relations/ManyToManyCollection.js.map +1 -1
  505. package/build/relations/ManyToManyLargeCollection.d.cts +2 -3
  506. package/build/relations/ManyToManyLargeCollection.d.cts.map +1 -1
  507. package/build/relations/ManyToManyLargeCollection.d.mts +2 -3
  508. package/build/relations/ManyToManyLargeCollection.d.mts.map +1 -1
  509. package/build/relations/ManyToOneReference.cjs.map +1 -1
  510. package/build/relations/ManyToOneReference.d.cts +6 -7
  511. package/build/relations/ManyToOneReference.d.cts.map +1 -1
  512. package/build/relations/ManyToOneReference.d.mts +6 -7
  513. package/build/relations/ManyToOneReference.d.mts.map +1 -1
  514. package/build/relations/ManyToOneReference.js.map +1 -1
  515. package/build/relations/OneToManyCollection.cjs.map +1 -1
  516. package/build/relations/OneToManyCollection.d.cts +2 -3
  517. package/build/relations/OneToManyCollection.d.cts.map +1 -1
  518. package/build/relations/OneToManyCollection.d.mts +2 -3
  519. package/build/relations/OneToManyCollection.d.mts.map +1 -1
  520. package/build/relations/OneToManyCollection.js.map +1 -1
  521. package/build/relations/OneToManyLargeCollection.cjs.map +1 -1
  522. package/build/relations/OneToManyLargeCollection.d.cts +2 -3
  523. package/build/relations/OneToManyLargeCollection.d.cts.map +1 -1
  524. package/build/relations/OneToManyLargeCollection.d.mts +2 -3
  525. package/build/relations/OneToManyLargeCollection.d.mts.map +1 -1
  526. package/build/relations/OneToManyLargeCollection.js.map +1 -1
  527. package/build/relations/OneToOneReference.cjs.map +1 -1
  528. package/build/relations/OneToOneReference.d.cts +7 -7
  529. package/build/relations/OneToOneReference.d.cts.map +1 -1
  530. package/build/relations/OneToOneReference.d.mts +7 -7
  531. package/build/relations/OneToOneReference.d.mts.map +1 -1
  532. package/build/relations/OneToOneReference.js.map +1 -1
  533. package/build/relations/PolymorphicReference.cjs.map +1 -1
  534. package/build/relations/PolymorphicReference.d.cts +4 -5
  535. package/build/relations/PolymorphicReference.d.cts.map +1 -1
  536. package/build/relations/PolymorphicReference.d.mts +4 -5
  537. package/build/relations/PolymorphicReference.d.mts.map +1 -1
  538. package/build/relations/PolymorphicReference.js.map +1 -1
  539. package/build/relations/PropertySymbols.d.cts +1 -2
  540. package/build/relations/PropertySymbols.d.cts.map +1 -1
  541. package/build/relations/PropertySymbols.d.mts +1 -2
  542. package/build/relations/PropertySymbols.d.mts.map +1 -1
  543. package/build/relations/ReactiveField.cjs.map +1 -1
  544. package/build/relations/ReactiveField.d.cts +4 -5
  545. package/build/relations/ReactiveField.d.cts.map +1 -1
  546. package/build/relations/ReactiveField.d.mts +4 -5
  547. package/build/relations/ReactiveField.d.mts.map +1 -1
  548. package/build/relations/ReactiveField.js.map +1 -1
  549. package/build/relations/ReactiveGetter.cjs.map +1 -1
  550. package/build/relations/ReactiveGetter.d.cts +4 -5
  551. package/build/relations/ReactiveGetter.d.cts.map +1 -1
  552. package/build/relations/ReactiveGetter.d.mts +4 -5
  553. package/build/relations/ReactiveGetter.d.mts.map +1 -1
  554. package/build/relations/ReactiveGetter.js.map +1 -1
  555. package/build/relations/ReactiveManyToMany.cjs.map +1 -1
  556. package/build/relations/ReactiveManyToMany.d.cts +4 -5
  557. package/build/relations/ReactiveManyToMany.d.cts.map +1 -1
  558. package/build/relations/ReactiveManyToMany.d.mts +4 -5
  559. package/build/relations/ReactiveManyToMany.d.mts.map +1 -1
  560. package/build/relations/ReactiveManyToMany.js.map +1 -1
  561. package/build/relations/ReactiveManyToManyOtherSide.cjs.map +1 -1
  562. package/build/relations/ReactiveManyToManyOtherSide.d.cts +4 -5
  563. package/build/relations/ReactiveManyToManyOtherSide.d.cts.map +1 -1
  564. package/build/relations/ReactiveManyToManyOtherSide.d.mts +4 -5
  565. package/build/relations/ReactiveManyToManyOtherSide.d.mts.map +1 -1
  566. package/build/relations/ReactiveManyToManyOtherSide.js.map +1 -1
  567. package/build/relations/ReactiveReference.cjs.map +1 -1
  568. package/build/relations/ReactiveReference.d.cts +5 -6
  569. package/build/relations/ReactiveReference.d.cts.map +1 -1
  570. package/build/relations/ReactiveReference.d.mts +5 -6
  571. package/build/relations/ReactiveReference.d.mts.map +1 -1
  572. package/build/relations/ReactiveReference.js.map +1 -1
  573. package/build/relations/ReadOnlyCollection.d.cts +4 -5
  574. package/build/relations/ReadOnlyCollection.d.cts.map +1 -1
  575. package/build/relations/ReadOnlyCollection.d.mts +4 -5
  576. package/build/relations/ReadOnlyCollection.d.mts.map +1 -1
  577. package/build/relations/RecursiveCollection.cjs.map +1 -1
  578. package/build/relations/RecursiveCollection.d.cts +10 -10
  579. package/build/relations/RecursiveCollection.d.cts.map +1 -1
  580. package/build/relations/RecursiveCollection.d.mts +10 -10
  581. package/build/relations/RecursiveCollection.d.mts.map +1 -1
  582. package/build/relations/RecursiveCollection.js.map +1 -1
  583. package/build/relations/RecursiveCycleError.d.cts +2 -2
  584. package/build/relations/RecursiveCycleError.d.cts.map +1 -1
  585. package/build/relations/RecursiveCycleError.d.mts +2 -2
  586. package/build/relations/RecursiveCycleError.d.mts.map +1 -1
  587. package/build/relations/Reference.d.cts +5 -5
  588. package/build/relations/Reference.d.cts.map +1 -1
  589. package/build/relations/Reference.d.mts +5 -5
  590. package/build/relations/Reference.d.mts.map +1 -1
  591. package/build/relations/ReferenceSymbols.d.cts +1 -2
  592. package/build/relations/ReferenceSymbols.d.cts.map +1 -1
  593. package/build/relations/ReferenceSymbols.d.mts +1 -2
  594. package/build/relations/ReferenceSymbols.d.mts.map +1 -1
  595. package/build/relations/Relation.d.cts +3 -3
  596. package/build/relations/Relation.d.cts.map +1 -1
  597. package/build/relations/Relation.d.mts +3 -3
  598. package/build/relations/Relation.d.mts.map +1 -1
  599. package/build/relations/RelationSymbols.d.cts +2 -3
  600. package/build/relations/RelationSymbols.d.cts.map +1 -1
  601. package/build/relations/RelationSymbols.d.mts +2 -3
  602. package/build/relations/RelationSymbols.d.mts.map +1 -1
  603. package/build/relations/hasAsyncMethod.cjs.map +1 -1
  604. package/build/relations/hasAsyncMethod.d.cts +6 -6
  605. package/build/relations/hasAsyncMethod.d.cts.map +1 -1
  606. package/build/relations/hasAsyncMethod.d.mts +6 -6
  607. package/build/relations/hasAsyncMethod.d.mts.map +1 -1
  608. package/build/relations/hasAsyncMethod.js.map +1 -1
  609. package/build/relations/hasManyDerived.d.cts +2 -2
  610. package/build/relations/hasManyDerived.d.cts.map +1 -1
  611. package/build/relations/hasManyDerived.d.mts +2 -2
  612. package/build/relations/hasManyDerived.d.mts.map +1 -1
  613. package/build/relations/hasManyThrough.d.cts +1 -2
  614. package/build/relations/hasManyThrough.d.cts.map +1 -1
  615. package/build/relations/hasManyThrough.d.mts +1 -2
  616. package/build/relations/hasManyThrough.d.mts.map +1 -1
  617. package/build/relations/hasOneDerived.d.cts +1 -2
  618. package/build/relations/hasOneDerived.d.cts.map +1 -1
  619. package/build/relations/hasOneDerived.d.mts +1 -2
  620. package/build/relations/hasOneDerived.d.mts.map +1 -1
  621. package/build/relations/hasOneThrough.d.cts +1 -2
  622. package/build/relations/hasOneThrough.d.cts.map +1 -1
  623. package/build/relations/hasOneThrough.d.mts +1 -2
  624. package/build/relations/hasOneThrough.d.mts.map +1 -1
  625. package/build/relations/hasProperty.cjs.map +1 -1
  626. package/build/relations/hasProperty.d.cts +8 -8
  627. package/build/relations/hasProperty.d.cts.map +1 -1
  628. package/build/relations/hasProperty.d.mts +8 -8
  629. package/build/relations/hasProperty.d.mts.map +1 -1
  630. package/build/relations/hasProperty.js.map +1 -1
  631. package/build/relations/isCascadeDelete.d.cts +1 -2
  632. package/build/relations/isCascadeDelete.d.cts.map +1 -1
  633. package/build/relations/isCascadeDelete.d.mts +1 -2
  634. package/build/relations/isCascadeDelete.d.mts.map +1 -1
  635. package/build/resurrection.d.cts +3 -4
  636. package/build/resurrection.d.cts.map +1 -1
  637. package/build/resurrection.d.mts +3 -4
  638. package/build/resurrection.d.mts.map +1 -1
  639. package/build/rules.d.cts +20 -20
  640. package/build/rules.d.cts.map +1 -1
  641. package/build/rules.d.mts +20 -20
  642. package/build/rules.d.mts.map +1 -1
  643. package/build/runtimeConfig.d.cts +4 -5
  644. package/build/runtimeConfig.d.cts.map +1 -1
  645. package/build/runtimeConfig.d.mts +4 -5
  646. package/build/runtimeConfig.d.mts.map +1 -1
  647. package/build/serde/TypeInfo.d.cts +3 -4
  648. package/build/serde/TypeInfo.d.cts.map +1 -1
  649. package/build/serde/TypeInfo.d.mts +3 -4
  650. package/build/serde/TypeInfo.d.mts.map +1 -1
  651. package/build/serde/columns.d.cts +2 -3
  652. package/build/serde/columns.d.cts.map +1 -1
  653. package/build/serde/columns.d.mts +2 -3
  654. package/build/serde/columns.d.mts.map +1 -1
  655. package/build/serde/fieldSerde.d.cts +9 -9
  656. package/build/serde/fieldSerde.d.cts.map +1 -1
  657. package/build/serde/fieldSerde.d.mts +9 -9
  658. package/build/serde/fieldSerde.d.mts.map +1 -1
  659. package/build/serde/serde.d.cts +18 -19
  660. package/build/serde/serde.d.cts.map +1 -1
  661. package/build/serde/serde.d.mts +18 -19
  662. package/build/serde/serde.d.mts.map +1 -1
  663. package/build/serde/temporal.d.cts +5 -5
  664. package/build/serde/temporal.d.cts.map +1 -1
  665. package/build/serde/temporal.d.mts +5 -5
  666. package/build/serde/temporal.d.mts.map +1 -1
  667. package/build/serde/temporalMappers.d.cts +4 -5
  668. package/build/serde/temporalMappers.d.cts.map +1 -1
  669. package/build/serde/temporalMappers.d.mts +4 -5
  670. package/build/serde/temporalMappers.d.mts.map +1 -1
  671. package/build/transitions.d.cts +17 -18
  672. package/build/transitions.d.cts.map +1 -1
  673. package/build/transitions.d.mts +17 -18
  674. package/build/transitions.d.mts.map +1 -1
  675. package/build/trusted.d.cts +2 -3
  676. package/build/trusted.d.cts.map +1 -1
  677. package/build/trusted.d.mts +2 -3
  678. package/build/trusted.d.mts.map +1 -1
  679. package/build/typeMap.d.cts +17 -17
  680. package/build/typeMap.d.cts.map +1 -1
  681. package/build/typeMap.d.mts +17 -17
  682. package/build/typeMap.d.mts.map +1 -1
  683. package/build/upsert.d.cts +4 -4
  684. package/build/upsert.d.cts.map +1 -1
  685. package/build/upsert.d.mts +4 -4
  686. package/build/upsert.d.mts.map +1 -1
  687. package/build/utils.d.cts +27 -28
  688. package/build/utils.d.cts.map +1 -1
  689. package/build/utils.d.mts +27 -28
  690. package/build/utils.d.mts.map +1 -1
  691. package/package.json +4 -4
@@ -7,11 +7,11 @@ import { FieldSerde, PolymorphicKeySerde } from "./serde/fieldSerde.cjs";
7
7
  import { EntityManager, MaybeAbstractEntityConstructor, TimestampFields } from "./EntityManager.cjs";
8
8
  import { Entity } from "./Entity.cjs";
9
9
  //#region src/EntityMetadata.d.ts
10
- declare function getMetadata<T extends Entity>(entity: T): EntityMetadata<T>;
11
- declare function getMetadata<T extends Entity>(type: MaybeAbstractEntityConstructor<T>): EntityMetadata<T>;
12
- declare function getMetadata<T extends Entity>(meta: EntityMetadata): EntityMetadata;
10
+ export declare function getMetadata<T extends Entity>(entity: T): EntityMetadata<T>;
11
+ export declare function getMetadata<T extends Entity>(type: MaybeAbstractEntityConstructor<T>): EntityMetadata<T>;
12
+ export declare function getMetadata<T extends Entity>(meta: EntityMetadata): EntityMetadata;
13
13
  /** Returns the metadata layer that declares `fieldName`, i.e. `Task.tags` for `TaskOld.tags`. */
14
- declare function getMetadataForField(meta: EntityMetadata, fieldName: string): EntityMetadata;
14
+ export declare function getMetadataForField(meta: EntityMetadata, fieldName: string): EntityMetadata;
15
15
  /**
16
16
  * Runtime metadata about an entity.
17
17
  *
@@ -22,7 +22,7 @@ declare function getMetadataForField(meta: EntityMetadata, fieldName: string): E
22
22
  * an unknown string/id type, causes issues when we want to generically mix `EntityMetadata`
23
23
  * of different types, that even liberally using `EntityMetadata<any>` did not avoid.
24
24
  */
25
- interface EntityMetadata<T extends Entity = any> {
25
+ export interface EntityMetadata<T extends Entity = any> {
26
26
  cstr: MaybeAbstractEntityConstructor<T>;
27
27
  type: string;
28
28
  /** How the domain entity's id is represented. */
@@ -98,9 +98,9 @@ interface EntityMetadata<T extends Entity = any> {
98
98
  /** If the schema is lacking deferred FKs, this is our insertion order. */
99
99
  nonDeferredFkOrder?: number;
100
100
  }
101
- type Field = PrimaryKeyField | PrimitiveField | EnumField | OneToManyField | LargeOneToManyField | ManyToOneField | ManyToManyField | ManyToManyEnumField | OneToOneField | PolymorphicField;
102
- type SerdeField = PrimaryKeyField | PrimitiveField | EnumField | ManyToOneField | PolymorphicField;
103
- type PrimaryKeyField = {
101
+ export type Field = PrimaryKeyField | PrimitiveField | EnumField | OneToManyField | LargeOneToManyField | ManyToOneField | ManyToManyField | ManyToManyEnumField | OneToOneField | PolymorphicField;
102
+ export type SerdeField = PrimaryKeyField | PrimitiveField | EnumField | ManyToOneField | PolymorphicField;
103
+ export type PrimaryKeyField = {
104
104
  kind: "primaryKey";
105
105
  fieldName: string;
106
106
  fieldIdName: undefined;
@@ -108,7 +108,7 @@ type PrimaryKeyField = {
108
108
  serde: FieldSerde;
109
109
  immutable: true;
110
110
  };
111
- type PrimitiveField = {
111
+ export type PrimitiveField = {
112
112
  kind: "primitive";
113
113
  fieldName: string;
114
114
  fieldIdName: undefined;
@@ -124,7 +124,7 @@ type PrimitiveField = {
124
124
  /** When true, this column is excluded from the entity's default SELECT and lazy-loaded via a `LazyField`. */
125
125
  lazy?: boolean;
126
126
  };
127
- type EnumField = {
127
+ export type EnumField = {
128
128
  kind: "enum";
129
129
  fieldName: string;
130
130
  fieldIdName: undefined;
@@ -139,7 +139,7 @@ type EnumField = {
139
139
  immutable: boolean;
140
140
  default?: "schema" | "config";
141
141
  };
142
- type OneToManyField = {
142
+ export type OneToManyField = {
143
143
  kind: "o2m";
144
144
  fieldName: string;
145
145
  fieldIdName: string;
@@ -157,7 +157,7 @@ type OneToManyField = {
157
157
  /** When `"include"`, this collection's `.get`/`.load` returns soft-deleted entities instead of hiding them. */
158
158
  softDeletes?: "include" | "exclude";
159
159
  };
160
- type LargeOneToManyField = {
160
+ export type LargeOneToManyField = {
161
161
  kind: "lo2m";
162
162
  fieldName: string;
163
163
  fieldIdName: string;
@@ -169,7 +169,7 @@ type LargeOneToManyField = {
169
169
  serde: undefined;
170
170
  immutable: false;
171
171
  };
172
- type ManyToOneField = {
172
+ export type ManyToOneField = {
173
173
  kind: "m2o";
174
174
  fieldName: string;
175
175
  fieldIdName: string;
@@ -181,7 +181,7 @@ type ManyToOneField = {
181
181
  derived: "async" | false;
182
182
  default?: "schema" | "config";
183
183
  };
184
- type ManyToManyField = {
184
+ export type ManyToManyField = {
185
185
  kind: "m2m";
186
186
  fieldName: string;
187
187
  fieldIdName: string;
@@ -205,7 +205,7 @@ type ManyToManyField = {
205
205
  * To the user this looks like an array of enum codes (`Color[]`), but unlike an enum-array column it
206
206
  * is lazy (needs a load hint) because it lives in its own join table.
207
207
  */
208
- type ManyToManyEnumField = {
208
+ export type ManyToManyEnumField = {
209
209
  kind: "m2mEnum";
210
210
  fieldName: string;
211
211
  fieldIdName: undefined;
@@ -221,7 +221,7 @@ type ManyToManyEnumField = {
221
221
  /** Whether the join table has a surrogate `id` PK; if false the FK pair is the composite PK. */
222
222
  hasJoinTableId: boolean;
223
223
  };
224
- type OneToOneField = {
224
+ export type OneToOneField = {
225
225
  kind: "o2o";
226
226
  fieldName: string;
227
227
  fieldIdName: string;
@@ -233,7 +233,7 @@ type OneToOneField = {
233
233
  serde: undefined;
234
234
  immutable: false;
235
235
  };
236
- type PolymorphicField = {
236
+ export type PolymorphicField = {
237
237
  kind: "poly";
238
238
  fieldName: string;
239
239
  fieldIdName: string;
@@ -242,25 +242,24 @@ type PolymorphicField = {
242
242
  serde: PolymorphicKeySerde;
243
243
  immutable: boolean;
244
244
  };
245
- type PolymorphicFieldComponent = {
245
+ export type PolymorphicFieldComponent = {
246
246
  otherMetadata: () => EntityMetadata;
247
247
  otherFieldName: string;
248
248
  columnName: string;
249
249
  column: Column;
250
250
  };
251
- declare function isOneToManyField(ormField: Field): ormField is OneToManyField;
252
- declare function isManyToOneField(ormField: Field): ormField is ManyToOneField;
253
- declare function isManyToManyField(ormField: Field): ormField is ManyToManyField;
254
- declare function isManyToManyEnumField(ormField: Field): ormField is ManyToManyEnumField;
255
- declare function isOneToOneField(ormField: Field): ormField is OneToOneField;
256
- declare function isPolymorphicField(ormField: Field): ormField is PolymorphicField;
257
- declare function isReferenceField(ormField: Field): ormField is ManyToOneField | OneToOneField | PolymorphicField;
258
- declare function isCollectionField(ormField: Field): ormField is OneToManyField | ManyToManyField;
259
- declare function getBaseAndSelfMetas(meta: EntityMetadata): EntityMetadata[];
260
- declare function getBaseAndSelfMetas(entity: Entity): EntityMetadata[];
261
- declare function getBaseSelfAndSubMetas(meta: EntityMetadata): EntityMetadata[];
262
- declare function getSubMetas(meta: EntityMetadata): EntityMetadata[];
263
- declare function getBaseMeta(meta: EntityMetadata): EntityMetadata;
251
+ export declare function isOneToManyField(ormField: Field): ormField is OneToManyField;
252
+ export declare function isManyToOneField(ormField: Field): ormField is ManyToOneField;
253
+ export declare function isManyToManyField(ormField: Field): ormField is ManyToManyField;
254
+ export declare function isManyToManyEnumField(ormField: Field): ormField is ManyToManyEnumField;
255
+ export declare function isOneToOneField(ormField: Field): ormField is OneToOneField;
256
+ export declare function isPolymorphicField(ormField: Field): ormField is PolymorphicField;
257
+ export declare function isReferenceField(ormField: Field): ormField is ManyToOneField | OneToOneField | PolymorphicField;
258
+ export declare function isCollectionField(ormField: Field): ormField is OneToManyField | ManyToManyField;
259
+ export declare function getBaseAndSelfMetas(meta: EntityMetadata): EntityMetadata[];
260
+ export declare function getBaseAndSelfMetas(entity: Entity): EntityMetadata[];
261
+ export declare function getBaseSelfAndSubMetas(meta: EntityMetadata): EntityMetadata[];
262
+ export declare function getSubMetas(meta: EntityMetadata): EntityMetadata[];
263
+ export declare function getBaseMeta(meta: EntityMetadata): EntityMetadata;
264
264
  //#endregion
265
- export { EntityMetadata, EnumField, Field, LargeOneToManyField, ManyToManyEnumField, ManyToManyField, ManyToOneField, OneToManyField, OneToOneField, PolymorphicField, PolymorphicFieldComponent, PrimaryKeyField, PrimitiveField, SerdeField, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getMetadata, getMetadataForField, getSubMetas, isCollectionField, isManyToManyEnumField, isManyToManyField, isManyToOneField, isOneToManyField, isOneToOneField, isPolymorphicField, isReferenceField };
266
265
  //# sourceMappingURL=EntityMetadata.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityMetadata.d.cts","names":[],"sources":["../src/EntityMetadata.ts"],"mappings":";;;;;;;;;iBAWgB,YAAY,UAAU,QAAQ,QAAQ,IAAI,eAAe;iBACzD,YAAY,UAAU,QAAQ,MAAM,+BAA+B,KAAK,eAAe;iBACvF,YAAY,UAAU,QAAQ,MAAM,iBAAiB;;iBAWrD,oBAAoB,MAAM,gBAAgB,oBAAoB;;;;;;;;;;;UAoB7D,eAAe,UAAU;EACxC,MAAM,+BAA+B;EACrC;;EAEA;;EAEA;EACA;;EAEA;;EAEA;EACA;;EAEA;;EAEA;;EAEA;EACA;EACA,QAAQ,eAAe;;EAEvB,SAAS;EACT,WAAW,eAAe;IAAU;IAAqB;;;EAEzD,sBAAsB,eAAe;IAAU;;EAE/C,QAAQ;;EAER,cAAc,oBAAoB;;EAElC,aAAa;;EAEb,oBAAoB,oBAAoB;;EAExC,8BAA8B;;EAE9B,qCAAqC,oBAAoB;;EAEzD,gBAAgB;;EAEhB,sBAAsB;;EAEtB;;EAEA,iBAAiB;;EAEjB;;EAEA;EACA;;EAEA;EACA,iBAAiB;EAEjB,UAAU,IAAI,8BAA8B,eAAe,QAAQ;;EAEnE,WAAW;;EAEX,UAAU;;EAE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;EACA;EACA;EACA;EACA,eAAe;EACf,OAAO;EACP;EACA;EACA;EACA;;EAEA;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA,gBAAgB;IAAoB;;;EAEpC,UAAU;EACV,OAAO;EACP;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;;EAEA;EACA;EACA;EACA;IAAY;IAAe;;;EAE3B;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;;EAEA;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;EACA,OAAO;EACP;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA;EACA,qBAAqB;EACrB;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;;;;;;;;YAUU;EACV;EACA;EACA;EACA;EACA;;EAEA,gBAAgB;EAChB;EACA;EACA;;EAEA;;EAEA;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;;EAEA;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA,YAAY;EACZ,OAAO;EACP;;YAGU;EACV,qBAAqB;EACrB;EACA;EACA,QAAQ;;wBAGM,iBAAiB,UAAU,QAAQ,YAAY;wBAI/C,iBAAiB,UAAU,QAAQ,YAAY;wBAI/C,kBAAkB,UAAU,QAAQ,YAAY;wBAIhD,sBAAsB,UAAU,QAAQ,YAAY;wBAIpD,gBAAgB,UAAU,QAAQ,YAAY;wBAI9C,mBAAmB,UAAU,QAAQ,YAAY;wBAIjD,iBAAiB,UAAU,QAAQ,YAAY,iBAAiB,gBAAgB;wBAIhF,kBAAkB,UAAU,QAAQ,YAAY,iBAAiB;wBAIjE,oBAAoB,MAAM,iBAAiB;wBAC3C,oBAAoB,QAAQ,SAAS;wBAOrC,uBAAuB,MAAM,iBAAiB;wBAI9C,YAAY,MAAM,iBAAiB;wBAKnC,YAAY,MAAM,iBAAiB"}
@@ -7,11 +7,11 @@ import { FieldSerde, PolymorphicKeySerde } from "./serde/fieldSerde.mjs";
7
7
  import { EntityManager, MaybeAbstractEntityConstructor, TimestampFields } from "./EntityManager.mjs";
8
8
  import { Entity } from "./Entity.mjs";
9
9
  //#region src/EntityMetadata.d.ts
10
- declare function getMetadata<T extends Entity>(entity: T): EntityMetadata<T>;
11
- declare function getMetadata<T extends Entity>(type: MaybeAbstractEntityConstructor<T>): EntityMetadata<T>;
12
- declare function getMetadata<T extends Entity>(meta: EntityMetadata): EntityMetadata;
10
+ export declare function getMetadata<T extends Entity>(entity: T): EntityMetadata<T>;
11
+ export declare function getMetadata<T extends Entity>(type: MaybeAbstractEntityConstructor<T>): EntityMetadata<T>;
12
+ export declare function getMetadata<T extends Entity>(meta: EntityMetadata): EntityMetadata;
13
13
  /** Returns the metadata layer that declares `fieldName`, i.e. `Task.tags` for `TaskOld.tags`. */
14
- declare function getMetadataForField(meta: EntityMetadata, fieldName: string): EntityMetadata;
14
+ export declare function getMetadataForField(meta: EntityMetadata, fieldName: string): EntityMetadata;
15
15
  /**
16
16
  * Runtime metadata about an entity.
17
17
  *
@@ -22,7 +22,7 @@ declare function getMetadataForField(meta: EntityMetadata, fieldName: string): E
22
22
  * an unknown string/id type, causes issues when we want to generically mix `EntityMetadata`
23
23
  * of different types, that even liberally using `EntityMetadata<any>` did not avoid.
24
24
  */
25
- interface EntityMetadata<T extends Entity = any> {
25
+ export interface EntityMetadata<T extends Entity = any> {
26
26
  cstr: MaybeAbstractEntityConstructor<T>;
27
27
  type: string;
28
28
  /** How the domain entity's id is represented. */
@@ -98,9 +98,9 @@ interface EntityMetadata<T extends Entity = any> {
98
98
  /** If the schema is lacking deferred FKs, this is our insertion order. */
99
99
  nonDeferredFkOrder?: number;
100
100
  }
101
- type Field = PrimaryKeyField | PrimitiveField | EnumField | OneToManyField | LargeOneToManyField | ManyToOneField | ManyToManyField | ManyToManyEnumField | OneToOneField | PolymorphicField;
102
- type SerdeField = PrimaryKeyField | PrimitiveField | EnumField | ManyToOneField | PolymorphicField;
103
- type PrimaryKeyField = {
101
+ export type Field = PrimaryKeyField | PrimitiveField | EnumField | OneToManyField | LargeOneToManyField | ManyToOneField | ManyToManyField | ManyToManyEnumField | OneToOneField | PolymorphicField;
102
+ export type SerdeField = PrimaryKeyField | PrimitiveField | EnumField | ManyToOneField | PolymorphicField;
103
+ export type PrimaryKeyField = {
104
104
  kind: "primaryKey";
105
105
  fieldName: string;
106
106
  fieldIdName: undefined;
@@ -108,7 +108,7 @@ type PrimaryKeyField = {
108
108
  serde: FieldSerde;
109
109
  immutable: true;
110
110
  };
111
- type PrimitiveField = {
111
+ export type PrimitiveField = {
112
112
  kind: "primitive";
113
113
  fieldName: string;
114
114
  fieldIdName: undefined;
@@ -124,7 +124,7 @@ type PrimitiveField = {
124
124
  /** When true, this column is excluded from the entity's default SELECT and lazy-loaded via a `LazyField`. */
125
125
  lazy?: boolean;
126
126
  };
127
- type EnumField = {
127
+ export type EnumField = {
128
128
  kind: "enum";
129
129
  fieldName: string;
130
130
  fieldIdName: undefined;
@@ -139,7 +139,7 @@ type EnumField = {
139
139
  immutable: boolean;
140
140
  default?: "schema" | "config";
141
141
  };
142
- type OneToManyField = {
142
+ export type OneToManyField = {
143
143
  kind: "o2m";
144
144
  fieldName: string;
145
145
  fieldIdName: string;
@@ -157,7 +157,7 @@ type OneToManyField = {
157
157
  /** When `"include"`, this collection's `.get`/`.load` returns soft-deleted entities instead of hiding them. */
158
158
  softDeletes?: "include" | "exclude";
159
159
  };
160
- type LargeOneToManyField = {
160
+ export type LargeOneToManyField = {
161
161
  kind: "lo2m";
162
162
  fieldName: string;
163
163
  fieldIdName: string;
@@ -169,7 +169,7 @@ type LargeOneToManyField = {
169
169
  serde: undefined;
170
170
  immutable: false;
171
171
  };
172
- type ManyToOneField = {
172
+ export type ManyToOneField = {
173
173
  kind: "m2o";
174
174
  fieldName: string;
175
175
  fieldIdName: string;
@@ -181,7 +181,7 @@ type ManyToOneField = {
181
181
  derived: "async" | false;
182
182
  default?: "schema" | "config";
183
183
  };
184
- type ManyToManyField = {
184
+ export type ManyToManyField = {
185
185
  kind: "m2m";
186
186
  fieldName: string;
187
187
  fieldIdName: string;
@@ -205,7 +205,7 @@ type ManyToManyField = {
205
205
  * To the user this looks like an array of enum codes (`Color[]`), but unlike an enum-array column it
206
206
  * is lazy (needs a load hint) because it lives in its own join table.
207
207
  */
208
- type ManyToManyEnumField = {
208
+ export type ManyToManyEnumField = {
209
209
  kind: "m2mEnum";
210
210
  fieldName: string;
211
211
  fieldIdName: undefined;
@@ -221,7 +221,7 @@ type ManyToManyEnumField = {
221
221
  /** Whether the join table has a surrogate `id` PK; if false the FK pair is the composite PK. */
222
222
  hasJoinTableId: boolean;
223
223
  };
224
- type OneToOneField = {
224
+ export type OneToOneField = {
225
225
  kind: "o2o";
226
226
  fieldName: string;
227
227
  fieldIdName: string;
@@ -233,7 +233,7 @@ type OneToOneField = {
233
233
  serde: undefined;
234
234
  immutable: false;
235
235
  };
236
- type PolymorphicField = {
236
+ export type PolymorphicField = {
237
237
  kind: "poly";
238
238
  fieldName: string;
239
239
  fieldIdName: string;
@@ -242,25 +242,24 @@ type PolymorphicField = {
242
242
  serde: PolymorphicKeySerde;
243
243
  immutable: boolean;
244
244
  };
245
- type PolymorphicFieldComponent = {
245
+ export type PolymorphicFieldComponent = {
246
246
  otherMetadata: () => EntityMetadata;
247
247
  otherFieldName: string;
248
248
  columnName: string;
249
249
  column: Column;
250
250
  };
251
- declare function isOneToManyField(ormField: Field): ormField is OneToManyField;
252
- declare function isManyToOneField(ormField: Field): ormField is ManyToOneField;
253
- declare function isManyToManyField(ormField: Field): ormField is ManyToManyField;
254
- declare function isManyToManyEnumField(ormField: Field): ormField is ManyToManyEnumField;
255
- declare function isOneToOneField(ormField: Field): ormField is OneToOneField;
256
- declare function isPolymorphicField(ormField: Field): ormField is PolymorphicField;
257
- declare function isReferenceField(ormField: Field): ormField is ManyToOneField | OneToOneField | PolymorphicField;
258
- declare function isCollectionField(ormField: Field): ormField is OneToManyField | ManyToManyField;
259
- declare function getBaseAndSelfMetas(meta: EntityMetadata): EntityMetadata[];
260
- declare function getBaseAndSelfMetas(entity: Entity): EntityMetadata[];
261
- declare function getBaseSelfAndSubMetas(meta: EntityMetadata): EntityMetadata[];
262
- declare function getSubMetas(meta: EntityMetadata): EntityMetadata[];
263
- declare function getBaseMeta(meta: EntityMetadata): EntityMetadata;
251
+ export declare function isOneToManyField(ormField: Field): ormField is OneToManyField;
252
+ export declare function isManyToOneField(ormField: Field): ormField is ManyToOneField;
253
+ export declare function isManyToManyField(ormField: Field): ormField is ManyToManyField;
254
+ export declare function isManyToManyEnumField(ormField: Field): ormField is ManyToManyEnumField;
255
+ export declare function isOneToOneField(ormField: Field): ormField is OneToOneField;
256
+ export declare function isPolymorphicField(ormField: Field): ormField is PolymorphicField;
257
+ export declare function isReferenceField(ormField: Field): ormField is ManyToOneField | OneToOneField | PolymorphicField;
258
+ export declare function isCollectionField(ormField: Field): ormField is OneToManyField | ManyToManyField;
259
+ export declare function getBaseAndSelfMetas(meta: EntityMetadata): EntityMetadata[];
260
+ export declare function getBaseAndSelfMetas(entity: Entity): EntityMetadata[];
261
+ export declare function getBaseSelfAndSubMetas(meta: EntityMetadata): EntityMetadata[];
262
+ export declare function getSubMetas(meta: EntityMetadata): EntityMetadata[];
263
+ export declare function getBaseMeta(meta: EntityMetadata): EntityMetadata;
264
264
  //#endregion
265
- export { EntityMetadata, EnumField, Field, LargeOneToManyField, ManyToManyEnumField, ManyToManyField, ManyToOneField, OneToManyField, OneToOneField, PolymorphicField, PolymorphicFieldComponent, PrimaryKeyField, PrimitiveField, SerdeField, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getMetadata, getMetadataForField, getSubMetas, isCollectionField, isManyToManyEnumField, isManyToManyField, isManyToOneField, isOneToManyField, isOneToOneField, isPolymorphicField, isReferenceField };
266
265
  //# sourceMappingURL=EntityMetadata.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityMetadata.d.mts","names":[],"sources":["../src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AChB;EACA;EACA;;EAEA;;EAEA;;YAGU;EACV;EACA;EACA;EACA;EACA,qBAAqB;EACrB;;EAEA;EACA;EACA;;YAGU;EACV;EACA;EACA;EACA;EACA,YAAY;EACZ,OAAO;EACP;;YAGU;EACV,qBAAqB;EACrB;EACA;EACA,QAAQ;;wBAGM,iBAAiB,UAAU,QAAQ,YAAY;wBAI/C,iBAAiB,UAAU,QAAQ,YAAY;wBAI/C,kBAAkB,UAAU,QAAQ,YAAY;wBAIhD,sBAAsB,UAAU,QAAQ,YAAY;wBAIpD,gBAAgB,UAAU,QAAQ,YAAY;wBAI9C,mBAAmB,UAAU,QAAQ,YAAY;wBAIjD,iBAAiB,UAAU,QAAQ,YAAY,iBAAiB,gBAAgB;wBAIhF,kBAAkB,UAAU,QAAQ,YAAY,iBAAiB;wBAIjE,oBAAoB,MAAM,iBAAiB;wBAC3C,oBAAoB,QAAQ,SAAS;wBAOrC,uBAAuB,MAAM,iBAAiB;wBAI9C,YAAY,MAAM,iBAAiB;wBAKnC,YAAY,MAAM,iBAAiB"}
@@ -1,5 +1,5 @@
1
1
  //#region src/EnumMetadata.d.ts
2
- interface EnumMetadata<C, D, I extends number | string = number | string> {
2
+ export interface EnumMetadata<C, D, I extends number | string = number | string> {
3
3
  /** Returns the enum type's name, i.e. `AuthorStatus`. */
4
4
  name: string;
5
5
  /** Gets the `code` details, i.e. `Statuses.getByCode(Status.DRAFT)`. */
@@ -14,5 +14,4 @@ interface EnumMetadata<C, D, I extends number | string = number | string> {
14
14
  getDetails(): ReadonlyArray<D>;
15
15
  }
16
16
  //#endregion
17
- export { EnumMetadata };
18
17
  //# sourceMappingURL=EnumMetadata.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnumMetadata.d.cts","names":[],"sources":["../src/EnumMetadata.ts"],"mappings":";UAAiB,aAAa,GAAG,GAAG;;EAElC;;EAGA,UAAU,MAAM,IAAI;;EAGpB,WAAW,eAAe;;EAG1B,SAAS,IAAI,IAAI;;EAGjB,aAAa,cAAc;;EAG3B,cAAc,cAAc"}
1
+ {"version":3,"file":"EnumMetadata.d.cts","names":[],"sources":["../src/EnumMetadata.ts"],"mappings":";iBAAiB,aAAa,GAAG,GAAG;;EAElC;;EAGA,UAAU,MAAM,IAAI;;EAGpB,WAAW,eAAe;;EAG1B,SAAS,IAAI,IAAI;;EAGjB,aAAa,cAAc;;EAG3B,cAAc,cAAc"}
@@ -1,5 +1,5 @@
1
1
  //#region src/EnumMetadata.d.ts
2
- interface EnumMetadata<C, D, I extends number | string = number | string> {
2
+ export interface EnumMetadata<C, D, I extends number | string = number | string> {
3
3
  /** Returns the enum type's name, i.e. `AuthorStatus`. */
4
4
  name: string;
5
5
  /** Gets the `code` details, i.e. `Statuses.getByCode(Status.DRAFT)`. */
@@ -14,5 +14,4 @@ interface EnumMetadata<C, D, I extends number | string = number | string> {
14
14
  getDetails(): ReadonlyArray<D>;
15
15
  }
16
16
  //#endregion
17
- export { EnumMetadata };
18
17
  //# sourceMappingURL=EnumMetadata.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnumMetadata.d.mts","names":[],"sources":["../src/EnumMetadata.ts"],"mappings":";UAAiB,aAAa,GAAG,GAAG;;EAElC;;EAGA,UAAU,MAAM,IAAI;;EAGpB,WAAW,eAAe;;EAG1B,SAAS,IAAI,IAAI;;EAGjB,aAAa,cAAc;;EAG3B,cAAc,cAAc"}
1
+ {"version":3,"file":"EnumMetadata.d.mts","names":[],"sources":["../src/EnumMetadata.ts"],"mappings":";iBAAiB,aAAa,GAAG,GAAG;;EAElC;;EAGA,UAAU,MAAM,IAAI;;EAGpB,WAAW,eAAe;;EAG1B,SAAS,IAAI,IAAI;;EAGjB,aAAa,cAAc;;EAG3B,cAAc,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"IndexManager.cjs","names":["#indexes","groupBy","getMetadata","isLoadedReference","#valueToEntities","#arrayToEntities","isEntity","fastWhereFilterHash"],"sources":["../src/IndexManager.ts"],"sourcesContent":["import { fastWhereFilterHash } from \"src/dataloaders/fastWhereFilterHash.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type EntityMetadata, type Field, getMetadata } from \"src/EntityMetadata.ts\";\nimport { type ManyToOneReference, type PolymorphicReference, isLoadedReference } from \"src/relations/index.ts\";\nimport { groupBy } from \"src/utils.ts\";\n\ntype FieldValue = any;\ntype FieldName = string;\ntype EntityTag = string;\ntype FieldIndexEntry = {\n field: Field;\n index: FieldIndex;\n /** Tracks how far into the EM's list-per-tag array this field index has been lazily populated. */\n indexedCount: number;\n};\nconst emptySet = new Set<Entity>();\n\n// The test reproducing a n^2 with n=500 went from 100ms to 50ms if indexed\nexport const indexThreshold = 500;\n\n/**\n * IndexManager provides field-based indexing for entity queries to avoid O(n) linear scans of `em.entities`.\n *\n * Key features:\n * - Only indexes entity types with >1000 entities to avoid overhead for small datasets\n * - Supports dual indexing for m2o/poly fields (by ID for saved, by instance for unsaved)\n * - Automatically maintains indexes when fields are updated via setField()\n */\nexport class IndexManager {\n readonly #indexes: Map<EntityTag, Map<FieldName, FieldIndexEntry>> = new Map();\n\n /** @return if we should index entities of this type/count. */\n shouldIndexType(entityCount: number): boolean {\n return entityCount >= indexThreshold;\n }\n\n /** Visible for testing. */\n isIndexed(tagName: string): boolean {\n return this.#indexes.has(tagName);\n }\n\n /** Enables indexing for an entity type and builds indexes for the requested fields. */\n enableIndexingForType<T extends Entity>(meta: EntityMetadata<T>, entities: T[], where: object): void {\n const { tagName } = meta;\n if (!this.#indexes.has(tagName)) {\n this.#indexes.set(tagName, new Map());\n }\n\n const fieldNames = Object.keys(where);\n const fieldIndexes = this.#indexes.get(tagName)!;\n const missingFieldNames = fieldNames.filter((fieldName) => !fieldIndexes.has(fieldName));\n if (missingFieldNames.length === 0) return;\n\n // If subtypes are involved, group by each subtype\n if (meta.baseType || meta.subTypes.length > 0) {\n [...groupBy(entities, (e) => getMetadata(e)).entries()].forEach(([meta, entities]) => {\n this.addEntitiesToIndex(meta, entities, missingFieldNames);\n });\n } else {\n this.addEntitiesToIndex(meta, entities, missingFieldNames);\n }\n }\n\n /** Updates indexes when a field value changes. */\n maybeUpdateFieldIndex(entity: Entity, fieldName: string, oldValue: any, newValue: any): void {\n // Fast return for the common case, which is no indexing\n if (this.#indexes.size === 0) return;\n\n const meta = getMetadata(entity);\n const fieldIndexes = this.#indexes.get(meta.tagName);\n if (!fieldIndexes) return; // Type not indexed\n\n const fieldIndex = fieldIndexes.get(fieldName)?.index;\n if (!fieldIndex) return; // Field is not indexed\n\n fieldIndex.remove(oldValue, entity);\n fieldIndex.add(newValue, entity);\n }\n\n /**\n * Finds entities matching the given where clause using indexes.\n *\n * Returns the raw candidate set (possibly a live internal index set, so do not mutate it);\n * the caller applies its own subtype/deleted filtering while building the final array.\n */\n findMatching<T extends Entity>(meta: EntityMetadata<T>, entities: T[], where: any): ReadonlySet<T> {\n const { tagName } = meta;\n if (!this.#indexes.has(tagName)) {\n throw new Error(`${meta.type} is not indexed`);\n }\n const fieldIndexes = this.#indexes.get(tagName)!;\n // Start with all entities of the 1st condition, then intersect (AND) each subsequent field in `where`\n let candidates: Set<Entity> | undefined;\n for (const [fieldName, value] of Object.entries(where)) {\n this.indexUnindexedEntities(entities, fieldName);\n const fieldCandidates = fieldIndexes.get(fieldName)?.index.get(value);\n if (!candidates) {\n candidates = fieldCandidates ?? emptySet; // This is the 1st clause\n } else {\n candidates = fieldCandidates ? intersectSets(candidates, fieldCandidates) : emptySet;\n }\n // Early exit if no candidates remain\n if (candidates.size === 0) break;\n }\n if (candidates === undefined) {\n throw new Error(`Expected where clause with at least one condition`);\n }\n return candidates as unknown as ReadonlySet<T>;\n }\n\n // `entities` should all be of the exact same subtype\n private addEntitiesToIndex(meta: EntityMetadata, entities: Entity[], fieldNames: string[]): void {\n const { tagName } = meta;\n const indexes = this.#indexes.get(tagName)!;\n // Iterate over each field so we can do a shared fieldIndex lookup\n for (const fieldName of fieldNames) {\n const field = meta.allFields[fieldName];\n if (!field) continue;\n let entry = indexes.get(fieldName);\n if (!entry) {\n entry = { field, index: new FieldIndex(meta.columns[fieldName]?.isArray ?? false), indexedCount: 0 };\n indexes.set(fieldName, entry);\n }\n for (const entity of entities) {\n // Deleted entities never match, and reading a flushed one's relations throws\n if (entity.isDeletedEntity) continue;\n const value = getFieldValue(entity, fieldName, entry.field);\n entry.index.add(value, entity);\n }\n entry.indexedCount = entities.length;\n }\n }\n\n /** Lazily indexes newly-registered entities only for fields that are queried. */\n private indexUnindexedEntities<T extends Entity>(entities: T[], fieldName: string): void {\n const first = entities[0];\n if (first === undefined) return;\n\n const meta = getMetadata(first);\n const entry = this.#indexes.get(meta.tagName)?.get(fieldName);\n if (entry === undefined || entry.indexedCount === entities.length) return;\n\n for (let i = entry.indexedCount; i < entities.length; i++) {\n const entity = entities[i];\n if (entity.isDeletedEntity) continue;\n const value = getFieldValue(entity, fieldName, entry.field);\n entry.index.add(value, entity);\n }\n entry.indexedCount = entities.length;\n }\n}\n\n// Use the same field access pattern as entityMatches\nfunction getFieldValue(entity: Entity, fieldName: string, field: Field): any {\n const fn = fieldName as keyof Entity;\n switch (field.kind) {\n case \"primaryKey\":\n return entity.idTaggedMaybe;\n case \"enum\":\n case \"primitive\":\n return (entity as any)[fn];\n case \"m2o\":\n case \"poly\":\n const relation = (entity as any)[fn] as\n | ManyToOneReference<Entity, any, any>\n | PolymorphicReference<Entity, any, any>;\n if (isLoadedReference(relation)) {\n return relation.get;\n } else if (relation.isSet) {\n return relation.id;\n } else {\n return undefined;\n }\n default:\n return undefined;\n }\n}\n\n/**\n * For a given field, like `firstName`, holds the reverse index of value `bob` -> entities `[a1, a2]`.\n *\n * This also handles indexes `Entity` values as both instances & IDs, to handle both:\n * - new/unpersisted entities not yet having IDs, and\n * - relations not having loaded their instances yet\n */\nclass FieldIndex {\n readonly #valueToEntities = new Map<FieldValue, Set<Entity>>();\n // Keep serialized arrays separate so their keys cannot collide with scalar string values.\n readonly #arrayToEntities = new Map<string, Set<Entity>>();\n\n constructor(private readonly isArray: boolean) {}\n\n /** @return entities that have `value` as their current value for this field. */\n get(value: any): Set<Entity> | undefined {\n if (isEntity(value) && value.idTaggedMaybe) {\n // If `value` is a persisted entity like `a:1`, and entities could have indexed their `author_id=a:1` field\n // values as the unloaded \"just an a:1 string id\" value, before `a:1` was loaded into memory.\n const matchId = this.#valueToEntities.get(value.idTaggedMaybe);\n // But other entities could also have indexes `a:1` as an instance, so go ahead and check both\n const matchInstance = this.#valueToEntities.get(value);\n if (matchId && matchInstance) {\n return new Set([...matchId, ...matchInstance]);\n }\n return matchId ?? matchInstance;\n }\n // Treat null and undefined as equivalent for unset relations\n if (value === null) value = undefined;\n const arrayKey = this.maybeArrayKey(value);\n if (arrayKey !== undefined) return this.#arrayToEntities.get(arrayKey);\n return this.#valueToEntities.get(value);\n }\n\n add(value: any, entity: Entity): void {\n // If this is an entity, store both the entity itself & its ID\n if (isEntity(value) && value.idTaggedMaybe) {\n this.doAdd(value.idTaggedMaybe, entity);\n }\n this.doAdd(value, entity);\n }\n\n remove(value: any, entity: Entity): void {\n if (isEntity(value) && value.idTaggedMaybe) {\n this.doRemove(value.idTaggedMaybe, entity);\n }\n this.doRemove(value, entity);\n }\n\n private doAdd(value: any, entity: Entity): void {\n const arrayKey = this.maybeArrayKey(value);\n const index = arrayKey === undefined ? this.#valueToEntities : this.#arrayToEntities;\n const key = arrayKey ?? value;\n const set = index.get(key) ?? new Set();\n if (set.size === 0) index.set(key, set);\n set.add(entity);\n }\n\n private doRemove(value: any, entity: Entity): void {\n const arrayKey = this.maybeArrayKey(value);\n const index = arrayKey === undefined ? this.#valueToEntities : this.#arrayToEntities;\n const key = arrayKey ?? value;\n const set = index.get(key);\n if (set) {\n set.delete(entity);\n if (set.size === 0) {\n index.delete(key);\n }\n }\n }\n\n /** Preserves array order and element types, including bigint values that JSON cannot encode. */\n private maybeArrayKey(value: unknown): string | undefined {\n return this.isArray && Array.isArray(value) ? fastWhereFilterHash(value) : undefined;\n }\n}\n\nfunction intersectSets<T>(set1: Set<T>, set2: Set<T>): Set<T> {\n const [smaller, larger] = set1.size <= set2.size ? [set1, set2] : [set2, set1];\n const result = new Set<T>();\n for (const item of smaller) {\n if (larger.has(item)) {\n result.add(item);\n }\n }\n return result;\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,2BAAW,IAAI,IAAY;AAGjC,MAAa,iBAAiB;;;;;;;;;AAU9B,IAAa,eAAb,MAA0B;CACxB,2BAAqE,IAAI,IAAI;;CAG7E,gBAAgB,aAA8B;EAC5C,OAAO,eAAA;CACT;;CAGA,UAAU,SAA0B;EAClC,OAAO,KAAKA,SAAS,IAAI,OAAO;CAClC;;CAGA,sBAAwC,MAAyB,UAAe,OAAqB;EACnG,MAAM,EAAE,YAAY;EACpB,IAAI,CAAC,KAAKA,SAAS,IAAI,OAAO,GAC5B,KAAKA,SAAS,IAAI,yBAAS,IAAI,IAAI,CAAC;EAGtC,MAAM,aAAa,OAAO,KAAK,KAAK;EACpC,MAAM,eAAe,KAAKA,SAAS,IAAI,OAAO;EAC9C,MAAM,oBAAoB,WAAW,QAAQ,cAAc,CAAC,aAAa,IAAI,SAAS,CAAC;EACvF,IAAI,kBAAkB,WAAW,GAAG;EAGpC,IAAI,KAAK,YAAY,KAAK,SAAS,SAAS,GAC1C,CAAC,GAAGC,cAAAA,QAAQ,WAAW,MAAMC,uBAAAA,YAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,cAAc;GACpF,KAAK,mBAAmB,MAAM,UAAU,iBAAiB;EAC3D,CAAC;OAED,KAAK,mBAAmB,MAAM,UAAU,iBAAiB;CAE7D;;CAGA,sBAAsB,QAAgB,WAAmB,UAAe,UAAqB;EAE3F,IAAI,KAAKF,SAAS,SAAS,GAAG;EAE9B,MAAM,OAAOE,uBAAAA,YAAY,MAAM;EAC/B,MAAM,eAAe,KAAKF,SAAS,IAAI,KAAK,OAAO;EACnD,IAAI,CAAC,cAAc;EA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AACF;AAEA,SAAS,cAAiB,MAAc,MAAsB;CAC5D,MAAM,CAAC,SAAS,UAAU,KAAK,QAAQ,KAAK,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI;CAC7E,MAAM,yBAAS,IAAI,IAAO;CAC1B,KAAK,MAAM,QAAQ,SACjB,IAAI,OAAO,IAAI,IAAI,GACjB,OAAO,IAAI,IAAI;CAGnB,OAAO;AACT"}
1
+ {"version":3,"file":"IndexManager.cjs","names":["groupBy","getMetadata","isLoadedReference","isEntity","fastWhereFilterHash"],"sources":["../src/IndexManager.ts"],"sourcesContent":["import { fastWhereFilterHash } from \"src/dataloaders/fastWhereFilterHash.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type EntityMetadata, type Field, getMetadata } from \"src/EntityMetadata.ts\";\nimport { type ManyToOneReference, type PolymorphicReference, isLoadedReference } from \"src/relations/index.ts\";\nimport { groupBy } from \"src/utils.ts\";\n\ntype FieldValue = any;\ntype FieldName = string;\ntype EntityTag = string;\ntype FieldIndexEntry = {\n field: Field;\n index: FieldIndex;\n /** Tracks how far into the EM's list-per-tag array this field index has been lazily populated. */\n indexedCount: number;\n};\nconst emptySet = new Set<Entity>();\n\n// The test reproducing a n^2 with n=500 went from 100ms to 50ms if indexed\nexport const indexThreshold = 500;\n\n/**\n * IndexManager provides field-based indexing for entity queries to avoid O(n) linear scans of `em.entities`.\n *\n * Key features:\n * - Only indexes entity types with >1000 entities to avoid overhead for small datasets\n * - Supports dual indexing for m2o/poly fields (by ID for saved, by instance for unsaved)\n * - Automatically maintains indexes when fields are updated via setField()\n */\nexport class IndexManager {\n readonly #indexes: Map<EntityTag, Map<FieldName, FieldIndexEntry>> = new Map();\n\n /** @return if we should index entities of this type/count. */\n shouldIndexType(entityCount: number): boolean {\n return entityCount >= indexThreshold;\n }\n\n /** Visible for testing. */\n isIndexed(tagName: string): boolean {\n return this.#indexes.has(tagName);\n }\n\n /** Enables indexing for an entity type and builds indexes for the requested fields. */\n enableIndexingForType<T extends Entity>(meta: EntityMetadata<T>, entities: T[], where: object): void {\n const { tagName } = meta;\n if (!this.#indexes.has(tagName)) {\n this.#indexes.set(tagName, new Map());\n }\n\n const fieldNames = Object.keys(where);\n const fieldIndexes = this.#indexes.get(tagName)!;\n const missingFieldNames = fieldNames.filter((fieldName) => !fieldIndexes.has(fieldName));\n if (missingFieldNames.length === 0) return;\n\n // If subtypes are involved, group by each subtype\n if (meta.baseType || meta.subTypes.length > 0) {\n [...groupBy(entities, (e) => getMetadata(e)).entries()].forEach(([meta, entities]) => {\n this.addEntitiesToIndex(meta, entities, missingFieldNames);\n });\n } else {\n this.addEntitiesToIndex(meta, entities, missingFieldNames);\n }\n }\n\n /** Updates indexes when a field value changes. */\n maybeUpdateFieldIndex(entity: Entity, fieldName: string, oldValue: any, newValue: any): void {\n // Fast return for the common case, which is no indexing\n if (this.#indexes.size === 0) return;\n\n const meta = getMetadata(entity);\n const fieldIndexes = this.#indexes.get(meta.tagName);\n if (!fieldIndexes) return; // Type not indexed\n\n const fieldIndex = fieldIndexes.get(fieldName)?.index;\n if (!fieldIndex) return; // Field is not indexed\n\n fieldIndex.remove(oldValue, entity);\n fieldIndex.add(newValue, entity);\n }\n\n /**\n * Finds entities matching the given where clause using indexes.\n *\n * Returns the raw candidate set (possibly a live internal index set, so do not mutate it);\n * the caller applies its own subtype/deleted filtering while building the final array.\n */\n findMatching<T extends Entity>(meta: EntityMetadata<T>, entities: T[], where: any): ReadonlySet<T> {\n const { tagName } = meta;\n if (!this.#indexes.has(tagName)) {\n throw new Error(`${meta.type} is not indexed`);\n }\n const fieldIndexes = this.#indexes.get(tagName)!;\n // Start with all entities of the 1st condition, then intersect (AND) each subsequent field in `where`\n let candidates: Set<Entity> | undefined;\n for (const [fieldName, value] of Object.entries(where)) {\n this.indexUnindexedEntities(entities, fieldName);\n const fieldCandidates = fieldIndexes.get(fieldName)?.index.get(value);\n if (!candidates) {\n candidates = fieldCandidates ?? emptySet; // This is the 1st clause\n } else {\n candidates = fieldCandidates ? intersectSets(candidates, fieldCandidates) : emptySet;\n }\n // Early exit if no candidates remain\n if (candidates.size === 0) break;\n }\n if (candidates === undefined) {\n throw new Error(`Expected where clause with at least one condition`);\n }\n return candidates as unknown as ReadonlySet<T>;\n }\n\n // `entities` should all be of the exact same subtype\n private addEntitiesToIndex(meta: EntityMetadata, entities: Entity[], fieldNames: string[]): void {\n const { tagName } = meta;\n const indexes = this.#indexes.get(tagName)!;\n // Iterate over each field so we can do a shared fieldIndex lookup\n for (const fieldName of fieldNames) {\n const field = meta.allFields[fieldName];\n if (!field) continue;\n let entry = indexes.get(fieldName);\n if (!entry) {\n entry = { field, index: new FieldIndex(meta.columns[fieldName]?.isArray ?? false), indexedCount: 0 };\n indexes.set(fieldName, entry);\n }\n for (const entity of entities) {\n // Deleted entities never match, and reading a flushed one's relations throws\n if (entity.isDeletedEntity) continue;\n const value = getFieldValue(entity, fieldName, entry.field);\n entry.index.add(value, entity);\n }\n entry.indexedCount = entities.length;\n }\n }\n\n /** Lazily indexes newly-registered entities only for fields that are queried. */\n private indexUnindexedEntities<T extends Entity>(entities: T[], fieldName: string): void {\n const first = entities[0];\n if (first === undefined) return;\n\n const meta = getMetadata(first);\n const entry = this.#indexes.get(meta.tagName)?.get(fieldName);\n if (entry === undefined || entry.indexedCount === entities.length) return;\n\n for (let i = entry.indexedCount; i < entities.length; i++) {\n const entity = entities[i];\n if (entity.isDeletedEntity) continue;\n const value = getFieldValue(entity, fieldName, entry.field);\n entry.index.add(value, entity);\n }\n entry.indexedCount = entities.length;\n }\n}\n\n// Use the same field access pattern as entityMatches\nfunction getFieldValue(entity: Entity, fieldName: string, field: Field): any {\n const fn = fieldName as keyof Entity;\n switch (field.kind) {\n case \"primaryKey\":\n return entity.idTaggedMaybe;\n case \"enum\":\n case \"primitive\":\n return (entity as any)[fn];\n case \"m2o\":\n case \"poly\":\n const relation = (entity as any)[fn] as\n | ManyToOneReference<Entity, any, any>\n | PolymorphicReference<Entity, any, any>;\n if (isLoadedReference(relation)) {\n return relation.get;\n } else if (relation.isSet) {\n return relation.id;\n } else {\n return undefined;\n }\n default:\n return undefined;\n }\n}\n\n/**\n * For a given field, like `firstName`, holds the reverse index of value `bob` -> entities `[a1, a2]`.\n *\n * This also handles indexes `Entity` values as both instances & IDs, to handle both:\n * - new/unpersisted entities not yet having IDs, and\n * - relations not having loaded their instances yet\n */\nclass FieldIndex {\n readonly #valueToEntities = new Map<FieldValue, Set<Entity>>();\n // Keep serialized arrays separate so their keys cannot collide with scalar string values.\n readonly #arrayToEntities = new Map<string, Set<Entity>>();\n\n constructor(private readonly isArray: boolean) {}\n\n /** @return entities that have `value` as their current value for this field. */\n get(value: any): Set<Entity> | undefined {\n if (isEntity(value) && value.idTaggedMaybe) {\n // If `value` is a persisted entity like `a:1`, and entities could have indexed their `author_id=a:1` field\n // values as the unloaded \"just an a:1 string id\" value, before `a:1` was loaded into memory.\n const matchId = this.#valueToEntities.get(value.idTaggedMaybe);\n // But other entities could also have indexes `a:1` as an instance, so go ahead and check both\n const matchInstance = this.#valueToEntities.get(value);\n if (matchId && matchInstance) {\n return new Set([...matchId, ...matchInstance]);\n }\n return matchId ?? matchInstance;\n }\n // Treat null and undefined as equivalent for unset relations\n if (value === null) value = undefined;\n const arrayKey = this.maybeArrayKey(value);\n if (arrayKey !== undefined) return this.#arrayToEntities.get(arrayKey);\n return this.#valueToEntities.get(value);\n }\n\n add(value: any, entity: Entity): void {\n // If this is an entity, store both the entity itself & its ID\n if (isEntity(value) && value.idTaggedMaybe) {\n this.doAdd(value.idTaggedMaybe, entity);\n }\n this.doAdd(value, entity);\n }\n\n remove(value: any, entity: Entity): void {\n if (isEntity(value) && value.idTaggedMaybe) {\n this.doRemove(value.idTaggedMaybe, entity);\n }\n this.doRemove(value, entity);\n }\n\n private doAdd(value: any, entity: Entity): void {\n const arrayKey = this.maybeArrayKey(value);\n const index = arrayKey === undefined ? this.#valueToEntities : this.#arrayToEntities;\n const key = arrayKey ?? value;\n const set = index.get(key) ?? new Set();\n if (set.size === 0) index.set(key, set);\n set.add(entity);\n }\n\n private doRemove(value: any, entity: Entity): void {\n const arrayKey = this.maybeArrayKey(value);\n const index = arrayKey === undefined ? this.#valueToEntities : this.#arrayToEntities;\n const key = arrayKey ?? value;\n const set = index.get(key);\n if (set) {\n set.delete(entity);\n if (set.size === 0) {\n index.delete(key);\n }\n }\n }\n\n /** Preserves array order and element types, including bigint values that JSON cannot encode. */\n private maybeArrayKey(value: unknown): string | undefined {\n return this.isArray && Array.isArray(value) ? fastWhereFilterHash(value) : undefined;\n }\n}\n\nfunction intersectSets<T>(set1: Set<T>, set2: Set<T>): Set<T> {\n const [smaller, larger] = set1.size <= set2.size ? [set1, set2] : [set2, set1];\n const result = new Set<T>();\n for (const item of smaller) {\n if (larger.has(item)) {\n result.add(item);\n }\n }\n return result;\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,2BAAW,IAAI,IAAY;AAGjC,MAAa,iBAAiB;;;;;;;;;AAU9B,IAAa,eAAb,MAA0B;CACxB,2BAAqE,IAAI,IAAI;;CAG7E,gBAAgB,aAA8B;EAC5C,OAAO,eAAA;CACT;;CAGA,UAAU,SAA0B;EAClC,OAAO,KAAK,SAAS,IAAI,OAAO;CAClC;;CAGA,sBAAwC,MAAyB,UAAe,OAAqB;EACnG,MAAM,EAAE,YAAY;EACpB,IAAI,CAAC,KAAK,SAAS,IAAI,OAAO,GAC5B,KAAK,SAAS,IAAI,yBAAS,IAAI,IAAI,CAAC;EAGtC,MAAM,aAAa,OAAO,KAAK,KAAK;EACpC,MAAM,eAAe,KAAK,SAAS,IAAI,OAAO;EAC9C,MAAM,oBAAoB,WAAW,QAAQ,cAAc,CAAC,aAAa,IAAI,SAAS,CAAC;EACvF,IAAI,kBAAkB,WAAW,GAAG;EAGpC,IAAI,KAAK,YAAY,KAAK,SAAS,SAAS,GAC1C,CAAC,GAAGA,cAAAA,QAAQ,WAAW,MAAMC,uBAAAA,YAAY,C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WAAW,KAAK,cAAc,KAAK;EACzC,MAAM,QAAQ,aAAa,KAAA,IAAY,KAAK,mBAAmB,KAAK;EACpE,MAAM,MAAM,YAAY;EACxB,MAAM,MAAM,MAAM,IAAI,GAAG;EACzB,IAAI,KAAK;GACP,IAAI,OAAO,MAAM;GACjB,IAAI,IAAI,SAAS,GACf,MAAM,OAAO,GAAG;EAEpB;CACF;;CAGA,cAAsB,OAAoC;EACxD,OAAO,KAAK,WAAW,MAAM,QAAQ,KAAK,IAAIC,wCAAAA,oBAAoB,KAAK,IAAI,KAAA;CAC7E;AACF;AAEA,SAAS,cAAiB,MAAc,MAAsB;CAC5D,MAAM,CAAC,SAAS,UAAU,KAAK,QAAQ,KAAK,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI;CAC7E,MAAM,yBAAS,IAAI,IAAO;CAC1B,KAAK,MAAM,QAAQ,SACjB,IAAI,OAAO,IAAI,IAAI,GACjB,OAAO,IAAI,IAAI;CAGnB,OAAO;AACT"}
@@ -1,7 +1,7 @@
1
1
  import { EntityMetadata } from "./EntityMetadata.cjs";
2
2
  import { Entity } from "./Entity.cjs";
3
3
  //#region src/IndexManager.d.ts
4
- declare const indexThreshold = 500;
4
+ export declare const indexThreshold = 500;
5
5
  /**
6
6
  * IndexManager provides field-based indexing for entity queries to avoid O(n) linear scans of `em.entities`.
7
7
  *
@@ -10,7 +10,7 @@ declare const indexThreshold = 500;
10
10
  * - Supports dual indexing for m2o/poly fields (by ID for saved, by instance for unsaved)
11
11
  * - Automatically maintains indexes when fields are updated via setField()
12
12
  */
13
- declare class IndexManager {
13
+ export declare class IndexManager {
14
14
  #private;
15
15
  /** @return if we should index entities of this type/count. */
16
16
  shouldIndexType(entityCount: number): boolean;
@@ -32,5 +32,4 @@ declare class IndexManager {
32
32
  private indexUnindexedEntities;
33
33
  }
34
34
  //#endregion
35
- export { IndexManager, indexThreshold };
36
35
  //# sourceMappingURL=IndexManager.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IndexManager.d.cts","names":[],"sources":["../src/IndexManager.ts"],"mappings":";;;cAkBa;;;;;;;;;cAUA;;;EAIX,gBAAgB;;EAKhB,UAAU;;EAKV,sBAAsB,UAAU,QAAQ,MAAM,eAAe,IAAI,UAAU,KAAK;;EAsBhF,sBAAsB,QAAQ,QAAQ,mBAAmB,eAAe;;;;;;;EAqBxE,aAAa,UAAU,QAAQ,MAAM,eAAe,IAAI,UAAU,KAAK,aAAa,YAAY;UA0BxF;;UAuBA"}
1
+ {"version":3,"file":"IndexManager.d.cts","names":[],"sources":["../src/IndexManager.ts"],"mappings":";;;qBAkBa;;;;;;;;;qBAUA;;;EAIX,gBAAgB;;EAKhB,UAAU;;EAKV,sBAAsB,UAAU,QAAQ,MAAM,eAAe,IAAI,UAAU,KAAK;;EAsBhF,sBAAsB,QAAQ,QAAQ,mBAAmB,eAAe;;;;;;;EAqBxE,aAAa,UAAU,QAAQ,MAAM,eAAe,IAAI,UAAU,KAAK,aAAa,YAAY;UA0BxF;;UAuBA"}
@@ -1,7 +1,7 @@
1
1
  import { EntityMetadata } from "./EntityMetadata.mjs";
2
2
  import { Entity } from "./Entity.mjs";
3
3
  //#region src/IndexManager.d.ts
4
- declare const indexThreshold = 500;
4
+ export declare const indexThreshold = 500;
5
5
  /**
6
6
  * IndexManager provides field-based indexing for entity queries to avoid O(n) linear scans of `em.entities`.
7
7
  *
@@ -10,7 +10,7 @@ declare const indexThreshold = 500;
10
10
  * - Supports dual indexing for m2o/poly fields (by ID for saved, by instance for unsaved)
11
11
  * - Automatically maintains indexes when fields are updated via setField()
12
12
  */
13
- declare class IndexManager {
13
+ export declare class IndexManager {
14
14
  #private;
15
15
  /** @return if we should index entities of this type/count. */
16
16
  shouldIndexType(entityCount: number): boolean;
@@ -32,5 +32,4 @@ declare class IndexManager {
32
32
  private indexUnindexedEntities;
33
33
  }
34
34
  //#endregion
35
- export { IndexManager, indexThreshold };
36
35
  //# sourceMappingURL=IndexManager.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IndexManager.d.mts","names":[],"sources":["../src/IndexManager.ts"],"mappings":";;;cAkBa;;;;;;;;;cAUA;;;EAIX,gBAAgB;;EAKhB,UAAU;;EAKV,sBAAsB,UAAU,QAAQ,MAAM,eAAe,IAAI,UAAU,KAAK;;EAsBhF,sBAAsB,QAAQ,QAAQ,mBAAmB,eAAe;;;;;;;EAqBxE,aAAa,UAAU,QAAQ,MAAM,eAAe,IAAI,UAAU,KAAK,aAAa,YAAY;UA0BxF;;UAuBA"}
1
+ {"version":3,"file":"IndexManager.d.mts","names":[],"sources":["../src/IndexManager.ts"],"mappings":";;;qBAkBa;;;;;;;;;qBAUA;;;EAIX,gBAAgB;;EAKhB,UAAU;;EAKV,sBAAsB,UAAU,QAAQ,MAAM,eAAe,IAAI,UAAU,KAAK;;EAsBhF,sBAAsB,QAAQ,QAAQ,mBAAmB,eAAe;;;;;;;EAqBxE,aAAa,UAAU,QAAQ,MAAM,eAAe,IAAI,UAAU,KAAK,aAAa,YAAY;UA0BxF;;UAuBA"}
@@ -1 +1 @@
1
- {"version":3,"file":"IndexManager.js","names":["#indexes","#valueToEntities","#arrayToEntities"],"sources":["../src/IndexManager.ts"],"sourcesContent":["import { fastWhereFilterHash } from \"src/dataloaders/fastWhereFilterHash.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type EntityMetadata, type Field, getMetadata } from \"src/EntityMetadata.ts\";\nimport { type ManyToOneReference, type PolymorphicReference, isLoadedReference } from \"src/relations/index.ts\";\nimport { groupBy } from \"src/utils.ts\";\n\ntype FieldValue = any;\ntype FieldName = string;\ntype EntityTag = string;\ntype FieldIndexEntry = {\n field: Field;\n index: FieldIndex;\n /** Tracks how far into the EM's list-per-tag array this field index has been lazily populated. */\n indexedCount: number;\n};\nconst emptySet = new Set<Entity>();\n\n// The test reproducing a n^2 with n=500 went from 100ms to 50ms if indexed\nexport const indexThreshold = 500;\n\n/**\n * IndexManager provides field-based indexing for entity queries to avoid O(n) linear scans of `em.entities`.\n *\n * Key features:\n * - Only indexes entity types with >1000 entities to avoid overhead for small datasets\n * - Supports dual indexing for m2o/poly fields (by ID for saved, by instance for unsaved)\n * - Automatically maintains indexes when fields are updated via setField()\n */\nexport class IndexManager {\n readonly #indexes: Map<EntityTag, Map<FieldName, FieldIndexEntry>> = new Map();\n\n /** @return if we should index entities of this type/count. */\n shouldIndexType(entityCount: number): boolean {\n return entityCount >= indexThreshold;\n }\n\n /** Visible for testing. */\n isIndexed(tagName: string): boolean {\n return this.#indexes.has(tagName);\n }\n\n /** Enables indexing for an entity type and builds indexes for the requested fields. */\n enableIndexingForType<T extends Entity>(meta: EntityMetadata<T>, entities: T[], where: object): void {\n const { tagName } = meta;\n if (!this.#indexes.has(tagName)) {\n this.#indexes.set(tagName, new Map());\n }\n\n const fieldNames = Object.keys(where);\n const fieldIndexes = this.#indexes.get(tagName)!;\n const missingFieldNames = fieldNames.filter((fieldName) => !fieldIndexes.has(fieldName));\n if (missingFieldNames.length === 0) return;\n\n // If subtypes are involved, group by each subtype\n if (meta.baseType || meta.subTypes.length > 0) {\n [...groupBy(entities, (e) => getMetadata(e)).entries()].forEach(([meta, entities]) => {\n this.addEntitiesToIndex(meta, entities, missingFieldNames);\n });\n } else {\n this.addEntitiesToIndex(meta, entities, missingFieldNames);\n }\n }\n\n /** Updates indexes when a field value changes. */\n maybeUpdateFieldIndex(entity: Entity, fieldName: string, oldValue: any, newValue: any): void {\n // Fast return for the common case, which is no indexing\n if (this.#indexes.size === 0) return;\n\n const meta = getMetadata(entity);\n const fieldIndexes = this.#indexes.get(meta.tagName);\n if (!fieldIndexes) return; // Type not indexed\n\n const fieldIndex = fieldIndexes.get(fieldName)?.index;\n if (!fieldIndex) return; // Field is not indexed\n\n fieldIndex.remove(oldValue, entity);\n fieldIndex.add(newValue, entity);\n }\n\n /**\n * Finds entities matching the given where clause using indexes.\n *\n * Returns the raw candidate set (possibly a live internal index set, so do not mutate it);\n * the caller applies its own subtype/deleted filtering while building the final array.\n */\n findMatching<T extends Entity>(meta: EntityMetadata<T>, entities: T[], where: any): ReadonlySet<T> {\n const { tagName } = meta;\n if (!this.#indexes.has(tagName)) {\n throw new Error(`${meta.type} is not indexed`);\n }\n const fieldIndexes = this.#indexes.get(tagName)!;\n // Start with all entities of the 1st condition, then intersect (AND) each subsequent field in `where`\n let candidates: Set<Entity> | undefined;\n for (const [fieldName, value] of Object.entries(where)) {\n this.indexUnindexedEntities(entities, fieldName);\n const fieldCandidates = fieldIndexes.get(fieldName)?.index.get(value);\n if (!candidates) {\n candidates = fieldCandidates ?? emptySet; // This is the 1st clause\n } else {\n candidates = fieldCandidates ? intersectSets(candidates, fieldCandidates) : emptySet;\n }\n // Early exit if no candidates remain\n if (candidates.size === 0) break;\n }\n if (candidates === undefined) {\n throw new Error(`Expected where clause with at least one condition`);\n }\n return candidates as unknown as ReadonlySet<T>;\n }\n\n // `entities` should all be of the exact same subtype\n private addEntitiesToIndex(meta: EntityMetadata, entities: Entity[], fieldNames: string[]): void {\n const { tagName } = meta;\n const indexes = this.#indexes.get(tagName)!;\n // Iterate over each field so we can do a shared fieldIndex lookup\n for (const fieldName of fieldNames) {\n const field = meta.allFields[fieldName];\n if (!field) continue;\n let entry = indexes.get(fieldName);\n if (!entry) {\n entry = { field, index: new FieldIndex(meta.columns[fieldName]?.isArray ?? false), indexedCount: 0 };\n indexes.set(fieldName, entry);\n }\n for (const entity of entities) {\n // Deleted entities never match, and reading a flushed one's relations throws\n if (entity.isDeletedEntity) continue;\n const value = getFieldValue(entity, fieldName, entry.field);\n entry.index.add(value, entity);\n }\n entry.indexedCount = entities.length;\n }\n }\n\n /** Lazily indexes newly-registered entities only for fields that are queried. */\n private indexUnindexedEntities<T extends Entity>(entities: T[], fieldName: string): void {\n const first = entities[0];\n if (first === undefined) return;\n\n const meta = getMetadata(first);\n const entry = this.#indexes.get(meta.tagName)?.get(fieldName);\n if (entry === undefined || entry.indexedCount === entities.length) return;\n\n for (let i = entry.indexedCount; i < entities.length; i++) {\n const entity = entities[i];\n if (entity.isDeletedEntity) continue;\n const value = getFieldValue(entity, fieldName, entry.field);\n entry.index.add(value, entity);\n }\n entry.indexedCount = entities.length;\n }\n}\n\n// Use the same field access pattern as entityMatches\nfunction getFieldValue(entity: Entity, fieldName: string, field: Field): any {\n const fn = fieldName as keyof Entity;\n switch (field.kind) {\n case \"primaryKey\":\n return entity.idTaggedMaybe;\n case \"enum\":\n case \"primitive\":\n return (entity as any)[fn];\n case \"m2o\":\n case \"poly\":\n const relation = (entity as any)[fn] as\n | ManyToOneReference<Entity, any, any>\n | PolymorphicReference<Entity, any, any>;\n if (isLoadedReference(relation)) {\n return relation.get;\n } else if (relation.isSet) {\n return relation.id;\n } else {\n return undefined;\n }\n default:\n return undefined;\n }\n}\n\n/**\n * For a given field, like `firstName`, holds the reverse index of value `bob` -> entities `[a1, a2]`.\n *\n * This also handles indexes `Entity` values as both instances & IDs, to handle both:\n * - new/unpersisted entities not yet having IDs, and\n * - relations not having loaded their instances yet\n */\nclass FieldIndex {\n readonly #valueToEntities = new Map<FieldValue, Set<Entity>>();\n // Keep serialized arrays separate so their keys cannot collide with scalar string values.\n readonly #arrayToEntities = new Map<string, Set<Entity>>();\n\n constructor(private readonly isArray: boolean) {}\n\n /** @return entities that have `value` as their current value for this field. */\n get(value: any): Set<Entity> | undefined {\n if (isEntity(value) && value.idTaggedMaybe) {\n // If `value` is a persisted entity like `a:1`, and entities could have indexed their `author_id=a:1` field\n // values as the unloaded \"just an a:1 string id\" value, before `a:1` was loaded into memory.\n const matchId = this.#valueToEntities.get(value.idTaggedMaybe);\n // But other entities could also have indexes `a:1` as an instance, so go ahead and check both\n const matchInstance = this.#valueToEntities.get(value);\n if (matchId && matchInstance) {\n return new Set([...matchId, ...matchInstance]);\n }\n return matchId ?? matchInstance;\n }\n // Treat null and undefined as equivalent for unset relations\n if (value === null) value = undefined;\n const arrayKey = this.maybeArrayKey(value);\n if (arrayKey !== undefined) return this.#arrayToEntities.get(arrayKey);\n return this.#valueToEntities.get(value);\n }\n\n add(value: any, entity: Entity): void {\n // If this is an entity, store both the entity itself & its ID\n if (isEntity(value) && value.idTaggedMaybe) {\n this.doAdd(value.idTaggedMaybe, entity);\n }\n this.doAdd(value, entity);\n }\n\n remove(value: any, entity: Entity): void {\n if (isEntity(value) && value.idTaggedMaybe) {\n this.doRemove(value.idTaggedMaybe, entity);\n }\n this.doRemove(value, entity);\n }\n\n private doAdd(value: any, entity: Entity): void {\n const arrayKey = this.maybeArrayKey(value);\n const index = arrayKey === undefined ? this.#valueToEntities : this.#arrayToEntities;\n const key = arrayKey ?? value;\n const set = index.get(key) ?? new Set();\n if (set.size === 0) index.set(key, set);\n set.add(entity);\n }\n\n private doRemove(value: any, entity: Entity): void {\n const arrayKey = this.maybeArrayKey(value);\n const index = arrayKey === undefined ? this.#valueToEntities : this.#arrayToEntities;\n const key = arrayKey ?? value;\n const set = index.get(key);\n if (set) {\n set.delete(entity);\n if (set.size === 0) {\n index.delete(key);\n }\n }\n }\n\n /** Preserves array order and element types, including bigint values that JSON cannot encode. */\n private maybeArrayKey(value: unknown): string | undefined {\n return this.isArray && Array.isArray(value) ? fastWhereFilterHash(value) : undefined;\n }\n}\n\nfunction intersectSets<T>(set1: Set<T>, set2: Set<T>): Set<T> {\n const [smaller, larger] = set1.size <= set2.size ? [set1, set2] : [set2, set1];\n const result = new Set<T>();\n for (const item of smaller) {\n if (larger.has(item)) {\n result.add(item);\n }\n }\n return result;\n}\n"],"mappings":";;;;;;;AAeA,MAAM,2BAAW,IAAI,IAAY;AAGjC,MAAa,iBAAiB;;;;;;;;;AAU9B,IAAa,eAAb,MAA0B;CACxB,2BAAqE,IAAI,IAAI;;CAG7E,gBAAgB,aAA8B;EAC5C,OAAO,eAAA;CACT;;CAGA,UAAU,SAA0B;EAClC,OAAO,KAAKA,SAAS,IAAI,OAAO;CAClC;;CAGA,sBAAwC,MAAyB,UAAe,OAAqB;EACnG,MAAM,EAAE,YAA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AC7B;CAEA,MAAc,OAAY,QAAsB;EAC9C,MAAM,WAAW,KAAK,cAAc,KAAK;EACzC,MAAM,QAAQ,aAAa,KAAA,IAAY,KAAKA,mBAAmB,KAAKC;EACpE,MAAM,MAAM,YAAY;EACxB,MAAM,MAAM,MAAM,IAAI,GAAG,qBAAK,IAAI,IAAI;EACtC,IAAI,IAAI,SAAS,GAAG,MAAM,IAAI,KAAK,GAAG;EACtC,IAAI,IAAI,MAAM;CAChB;CAEA,SAAiB,OAAY,QAAsB;EACjD,MAAM,WAAW,KAAK,cAAc,KAAK;EACzC,MAAM,QAAQ,aAAa,KAAA,IAAY,KAAKD,mBAAmB,KAAKC;EACpE,MAAM,MAAM,YAAY;EACxB,MAAM,MAAM,MAAM,IAAI,GAAG;EACzB,IAAI,KAAK;GACP,IAAI,OAAO,MAAM;GACjB,IAAI,IAAI,SAAS,GACf,MAAM,OAAO,GAAG;EAEpB;CACF;;CAGA,cAAsB,OAAoC;EACxD,OAAO,KAAK,WAAW,MAAM,QAAQ,KAAK,IAAI,oBAAoB,KAAK,IAAI,KAAA;CAC7E;AACF;AAEA,SAAS,cAAiB,MAAc,MAAsB;CAC5D,MAAM,CAAC,SAAS,UAAU,KAAK,QAAQ,KAAK,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI;CAC7E,MAAM,yBAAS,IAAI,IAAO;CAC1B,KAAK,MAAM,QAAQ,SACjB,IAAI,OAAO,IAAI,IAAI,GACjB,OAAO,IAAI,IAAI;CAGnB,OAAO;AACT"}
1
+ {"version":3,"file":"IndexManager.js","names":[],"sources":["../src/IndexManager.ts"],"sourcesContent":["import { fastWhereFilterHash } from \"src/dataloaders/fastWhereFilterHash.ts\";\nimport { type Entity, isEntity } from \"src/Entity.ts\";\nimport { type EntityMetadata, type Field, getMetadata } from \"src/EntityMetadata.ts\";\nimport { type ManyToOneReference, type PolymorphicReference, isLoadedReference } from \"src/relations/index.ts\";\nimport { groupBy } from \"src/utils.ts\";\n\ntype FieldValue = any;\ntype FieldName = string;\ntype EntityTag = string;\ntype FieldIndexEntry = {\n field: Field;\n index: FieldIndex;\n /** Tracks how far into the EM's list-per-tag array this field index has been lazily populated. */\n indexedCount: number;\n};\nconst emptySet = new Set<Entity>();\n\n// The test reproducing a n^2 with n=500 went from 100ms to 50ms if indexed\nexport const indexThreshold = 500;\n\n/**\n * IndexManager provides field-based indexing for entity queries to avoid O(n) linear scans of `em.entities`.\n *\n * Key features:\n * - Only indexes entity types with >1000 entities to avoid overhead for small datasets\n * - Supports dual indexing for m2o/poly fields (by ID for saved, by instance for unsaved)\n * - Automatically maintains indexes when fields are updated via setField()\n */\nexport class IndexManager {\n readonly #indexes: Map<EntityTag, Map<FieldName, FieldIndexEntry>> = new Map();\n\n /** @return if we should index entities of this type/count. */\n shouldIndexType(entityCount: number): boolean {\n return entityCount >= indexThreshold;\n }\n\n /** Visible for testing. */\n isIndexed(tagName: string): boolean {\n return this.#indexes.has(tagName);\n }\n\n /** Enables indexing for an entity type and builds indexes for the requested fields. */\n enableIndexingForType<T extends Entity>(meta: EntityMetadata<T>, entities: T[], where: object): void {\n const { tagName } = meta;\n if (!this.#indexes.has(tagName)) {\n this.#indexes.set(tagName, new Map());\n }\n\n const fieldNames = Object.keys(where);\n const fieldIndexes = this.#indexes.get(tagName)!;\n const missingFieldNames = fieldNames.filter((fieldName) => !fieldIndexes.has(fieldName));\n if (missingFieldNames.length === 0) return;\n\n // If subtypes are involved, group by each subtype\n if (meta.baseType || meta.subTypes.length > 0) {\n [...groupBy(entities, (e) => getMetadata(e)).entries()].forEach(([meta, entities]) => {\n this.addEntitiesToIndex(meta, entities, missingFieldNames);\n });\n } else {\n this.addEntitiesToIndex(meta, entities, missingFieldNames);\n }\n }\n\n /** Updates indexes when a field value changes. */\n maybeUpdateFieldIndex(entity: Entity, fieldName: string, oldValue: any, newValue: any): void {\n // Fast return for the common case, which is no indexing\n if (this.#indexes.size === 0) return;\n\n const meta = getMetadata(entity);\n const fieldIndexes = this.#indexes.get(meta.tagName);\n if (!fieldIndexes) return; // Type not indexed\n\n const fieldIndex = fieldIndexes.get(fieldName)?.index;\n if (!fieldIndex) return; // Field is not indexed\n\n fieldIndex.remove(oldValue, entity);\n fieldIndex.add(newValue, entity);\n }\n\n /**\n * Finds entities matching the given where clause using indexes.\n *\n * Returns the raw candidate set (possibly a live internal index set, so do not mutate it);\n * the caller applies its own subtype/deleted filtering while building the final array.\n */\n findMatching<T extends Entity>(meta: EntityMetadata<T>, entities: T[], where: any): ReadonlySet<T> {\n const { tagName } = meta;\n if (!this.#indexes.has(tagName)) {\n throw new Error(`${meta.type} is not indexed`);\n }\n const fieldIndexes = this.#indexes.get(tagName)!;\n // Start with all entities of the 1st condition, then intersect (AND) each subsequent field in `where`\n let candidates: Set<Entity> | undefined;\n for (const [fieldName, value] of Object.entries(where)) {\n this.indexUnindexedEntities(entities, fieldName);\n const fieldCandidates = fieldIndexes.get(fieldName)?.index.get(value);\n if (!candidates) {\n candidates = fieldCandidates ?? emptySet; // This is the 1st clause\n } else {\n candidates = fieldCandidates ? intersectSets(candidates, fieldCandidates) : emptySet;\n }\n // Early exit if no candidates remain\n if (candidates.size === 0) break;\n }\n if (candidates === undefined) {\n throw new Error(`Expected where clause with at least one condition`);\n }\n return candidates as unknown as ReadonlySet<T>;\n }\n\n // `entities` should all be of the exact same subtype\n private addEntitiesToIndex(meta: EntityMetadata, entities: Entity[], fieldNames: string[]): void {\n const { tagName } = meta;\n const indexes = this.#indexes.get(tagName)!;\n // Iterate over each field so we can do a shared fieldIndex lookup\n for (const fieldName of fieldNames) {\n const field = meta.allFields[fieldName];\n if (!field) continue;\n let entry = indexes.get(fieldName);\n if (!entry) {\n entry = { field, index: new FieldIndex(meta.columns[fieldName]?.isArray ?? false), indexedCount: 0 };\n indexes.set(fieldName, entry);\n }\n for (const entity of entities) {\n // Deleted entities never match, and reading a flushed one's relations throws\n if (entity.isDeletedEntity) continue;\n const value = getFieldValue(entity, fieldName, entry.field);\n entry.index.add(value, entity);\n }\n entry.indexedCount = entities.length;\n }\n }\n\n /** Lazily indexes newly-registered entities only for fields that are queried. */\n private indexUnindexedEntities<T extends Entity>(entities: T[], fieldName: string): void {\n const first = entities[0];\n if (first === undefined) return;\n\n const meta = getMetadata(first);\n const entry = this.#indexes.get(meta.tagName)?.get(fieldName);\n if (entry === undefined || entry.indexedCount === entities.length) return;\n\n for (let i = entry.indexedCount; i < entities.length; i++) {\n const entity = entities[i];\n if (entity.isDeletedEntity) continue;\n const value = getFieldValue(entity, fieldName, entry.field);\n entry.index.add(value, entity);\n }\n entry.indexedCount = entities.length;\n }\n}\n\n// Use the same field access pattern as entityMatches\nfunction getFieldValue(entity: Entity, fieldName: string, field: Field): any {\n const fn = fieldName as keyof Entity;\n switch (field.kind) {\n case \"primaryKey\":\n return entity.idTaggedMaybe;\n case \"enum\":\n case \"primitive\":\n return (entity as any)[fn];\n case \"m2o\":\n case \"poly\":\n const relation = (entity as any)[fn] as\n | ManyToOneReference<Entity, any, any>\n | PolymorphicReference<Entity, any, any>;\n if (isLoadedReference(relation)) {\n return relation.get;\n } else if (relation.isSet) {\n return relation.id;\n } else {\n return undefined;\n }\n default:\n return undefined;\n }\n}\n\n/**\n * For a given field, like `firstName`, holds the reverse index of value `bob` -> entities `[a1, a2]`.\n *\n * This also handles indexes `Entity` values as both instances & IDs, to handle both:\n * - new/unpersisted entities not yet having IDs, and\n * - relations not having loaded their instances yet\n */\nclass FieldIndex {\n readonly #valueToEntities = new Map<FieldValue, Set<Entity>>();\n // Keep serialized arrays separate so their keys cannot collide with scalar string values.\n readonly #arrayToEntities = new Map<string, Set<Entity>>();\n\n constructor(private readonly isArray: boolean) {}\n\n /** @return entities that have `value` as their current value for this field. */\n get(value: any): Set<Entity> | undefined {\n if (isEntity(value) && value.idTaggedMaybe) {\n // If `value` is a persisted entity like `a:1`, and entities could have indexed their `author_id=a:1` field\n // values as the unloaded \"just an a:1 string id\" value, before `a:1` was loaded into memory.\n const matchId = this.#valueToEntities.get(value.idTaggedMaybe);\n // But other entities could also have indexes `a:1` as an instance, so go ahead and check both\n const matchInstance = this.#valueToEntities.get(value);\n if (matchId && matchInstance) {\n return new Set([...matchId, ...matchInstance]);\n }\n return matchId ?? matchInstance;\n }\n // Treat null and undefined as equivalent for unset relations\n if (value === null) value = undefined;\n const arrayKey = this.maybeArrayKey(value);\n if (arrayKey !== undefined) return this.#arrayToEntities.get(arrayKey);\n return this.#valueToEntities.get(value);\n }\n\n add(value: any, entity: Entity): void {\n // If this is an entity, store both the entity itself & its ID\n if (isEntity(value) && value.idTaggedMaybe) {\n this.doAdd(value.idTaggedMaybe, entity);\n }\n this.doAdd(value, entity);\n }\n\n remove(value: any, entity: Entity): void {\n if (isEntity(value) && value.idTaggedMaybe) {\n this.doRemove(value.idTaggedMaybe, entity);\n }\n this.doRemove(value, entity);\n }\n\n private doAdd(value: any, entity: Entity): void {\n const arrayKey = this.maybeArrayKey(value);\n const index = arrayKey === undefined ? this.#valueToEntities : this.#arrayToEntities;\n const key = arrayKey ?? value;\n const set = index.get(key) ?? new Set();\n if (set.size === 0) index.set(key, set);\n set.add(entity);\n }\n\n private doRemove(value: any, entity: Entity): void {\n const arrayKey = this.maybeArrayKey(value);\n const index = arrayKey === undefined ? this.#valueToEntities : this.#arrayToEntities;\n const key = arrayKey ?? value;\n const set = index.get(key);\n if (set) {\n set.delete(entity);\n if (set.size === 0) {\n index.delete(key);\n }\n }\n }\n\n /** Preserves array order and element types, including bigint values that JSON cannot encode. */\n private maybeArrayKey(value: unknown): string | undefined {\n return this.isArray && Array.isArray(value) ? fastWhereFilterHash(value) : undefined;\n }\n}\n\nfunction intersectSets<T>(set1: Set<T>, set2: Set<T>): Set<T> {\n const [smaller, larger] = set1.size <= set2.size ? [set1, set2] : [set2, set1];\n const result = new Set<T>();\n for (const item of smaller) {\n if (larger.has(item)) {\n result.add(item);\n }\n }\n return result;\n}\n"],"mappings":";;;;;;;AAeA,MAAM,2BAAW,IAAI,IAAY;AAG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