joist-orm 1.294.0 → 2.0.0

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 (482) hide show
  1. package/build/{drivers/PostgresDriver.d.ts → PostgresDriver.d.ts} +1 -4
  2. package/build/PostgresDriver.d.ts.map +1 -0
  3. package/build/{drivers/PostgresDriver.js → PostgresDriver.js} +49 -58
  4. package/build/PostgresDriver.js.map +1 -0
  5. package/build/codegen.d.ts +2 -0
  6. package/build/codegen.d.ts.map +1 -0
  7. package/build/codegen.js +29 -0
  8. package/build/codegen.js.map +1 -0
  9. package/build/graphql-codegen-export.d.ts +2 -0
  10. package/build/graphql-codegen-export.d.ts.map +1 -0
  11. package/build/{drivers/index.js → graphql-codegen-export.js} +3 -5
  12. package/build/graphql-codegen-export.js.map +1 -0
  13. package/build/graphql-export.d.ts +2 -0
  14. package/build/graphql-export.d.ts.map +1 -0
  15. package/build/graphql-export.js +19 -0
  16. package/build/graphql-export.js.map +1 -0
  17. package/build/index.d.ts +3 -128
  18. package/build/index.d.ts.map +1 -1
  19. package/build/index.js +8 -284
  20. package/build/index.js.map +1 -1
  21. package/build/knex-export.d.ts +2 -0
  22. package/build/knex-export.d.ts.map +1 -0
  23. package/build/knex-export.js +19 -0
  24. package/build/knex-export.js.map +1 -0
  25. package/build/pg-migrate.d.ts +2 -0
  26. package/build/pg-migrate.d.ts.map +1 -0
  27. package/build/pg-migrate.js +30 -0
  28. package/build/pg-migrate.js.map +1 -0
  29. package/build/postgres-driver.d.ts +2 -0
  30. package/build/postgres-driver.d.ts.map +1 -0
  31. package/build/postgres-driver.js +7 -0
  32. package/build/postgres-driver.js.map +1 -0
  33. package/build/tests-export.d.ts +2 -0
  34. package/build/tests-export.d.ts.map +1 -0
  35. package/build/tests-export.js +19 -0
  36. package/build/tests-export.js.map +1 -0
  37. package/package.json +85 -16
  38. package/build/AliasAssigner.d.ts +0 -7
  39. package/build/AliasAssigner.d.ts.map +0 -1
  40. package/build/AliasAssigner.js +0 -30
  41. package/build/AliasAssigner.js.map +0 -1
  42. package/build/Aliases.d.ts +0 -110
  43. package/build/Aliases.d.ts.map +0 -1
  44. package/build/Aliases.js +0 -456
  45. package/build/Aliases.js.map +0 -1
  46. package/build/BaseEntity.d.ts +0 -66
  47. package/build/BaseEntity.d.ts.map +0 -1
  48. package/build/BaseEntity.js +0 -120
  49. package/build/BaseEntity.js.map +0 -1
  50. package/build/ConditionBuilder.d.ts +0 -50
  51. package/build/ConditionBuilder.d.ts.map +0 -1
  52. package/build/ConditionBuilder.js +0 -178
  53. package/build/ConditionBuilder.js.map +0 -1
  54. package/build/Entity.d.ts +0 -38
  55. package/build/Entity.d.ts.map +0 -1
  56. package/build/Entity.js +0 -8
  57. package/build/Entity.js.map +0 -1
  58. package/build/EntityFields.d.ts +0 -37
  59. package/build/EntityFields.d.ts.map +0 -1
  60. package/build/EntityFields.js +0 -3
  61. package/build/EntityFields.js.map +0 -1
  62. package/build/EntityFilter.d.ts +0 -113
  63. package/build/EntityFilter.d.ts.map +0 -1
  64. package/build/EntityFilter.js +0 -3
  65. package/build/EntityFilter.js.map +0 -1
  66. package/build/EntityGraphQLFilter.d.ts +0 -51
  67. package/build/EntityGraphQLFilter.d.ts.map +0 -1
  68. package/build/EntityGraphQLFilter.js +0 -54
  69. package/build/EntityGraphQLFilter.js.map +0 -1
  70. package/build/EntityManager.d.ts +0 -734
  71. package/build/EntityManager.d.ts.map +0 -1
  72. package/build/EntityManager.js +0 -2075
  73. package/build/EntityManager.js.map +0 -1
  74. package/build/EntityMetadata.d.ts +0 -185
  75. package/build/EntityMetadata.d.ts.map +0 -1
  76. package/build/EntityMetadata.js +0 -61
  77. package/build/EntityMetadata.js.map +0 -1
  78. package/build/EnumMetadata.d.ts +0 -15
  79. package/build/EnumMetadata.d.ts.map +0 -1
  80. package/build/EnumMetadata.js +0 -3
  81. package/build/EnumMetadata.js.map +0 -1
  82. package/build/FlushLock.d.ts +0 -26
  83. package/build/FlushLock.d.ts.map +0 -1
  84. package/build/FlushLock.js +0 -57
  85. package/build/FlushLock.js.map +0 -1
  86. package/build/HintTree.d.ts +0 -42
  87. package/build/HintTree.d.ts.map +0 -1
  88. package/build/HintTree.js +0 -64
  89. package/build/HintTree.js.map +0 -1
  90. package/build/IndexManager.d.ts +0 -30
  91. package/build/IndexManager.d.ts.map +0 -1
  92. package/build/IndexManager.js +0 -206
  93. package/build/IndexManager.js.map +0 -1
  94. package/build/InstanceData.d.ts +0 -59
  95. package/build/InstanceData.d.ts.map +0 -1
  96. package/build/InstanceData.js +0 -162
  97. package/build/InstanceData.js.map +0 -1
  98. package/build/IsLoadedCache.d.ts +0 -32
  99. package/build/IsLoadedCache.d.ts.map +0 -1
  100. package/build/IsLoadedCache.js +0 -80
  101. package/build/IsLoadedCache.js.map +0 -1
  102. package/build/JoinRows.d.ts +0 -75
  103. package/build/JoinRows.d.ts.map +0 -1
  104. package/build/JoinRows.js +0 -246
  105. package/build/JoinRows.js.map +0 -1
  106. package/build/PluginManager.d.ts +0 -90
  107. package/build/PluginManager.d.ts.map +0 -1
  108. package/build/PluginManager.js +0 -97
  109. package/build/PluginManager.js.map +0 -1
  110. package/build/QueryParser.d.ts +0 -271
  111. package/build/QueryParser.d.ts.map +0 -1
  112. package/build/QueryParser.js +0 -853
  113. package/build/QueryParser.js.map +0 -1
  114. package/build/QueryParser.pruning.d.ts +0 -5
  115. package/build/QueryParser.pruning.d.ts.map +0 -1
  116. package/build/QueryParser.pruning.js +0 -118
  117. package/build/QueryParser.pruning.js.map +0 -1
  118. package/build/QueryVisitor.d.ts +0 -19
  119. package/build/QueryVisitor.d.ts.map +0 -1
  120. package/build/QueryVisitor.js +0 -84
  121. package/build/QueryVisitor.js.map +0 -1
  122. package/build/ReactionsManager.d.ts +0 -84
  123. package/build/ReactionsManager.d.ts.map +0 -1
  124. package/build/ReactionsManager.js +0 -308
  125. package/build/ReactionsManager.js.map +0 -1
  126. package/build/Todo.d.ts +0 -31
  127. package/build/Todo.d.ts.map +0 -1
  128. package/build/Todo.js +0 -73
  129. package/build/Todo.js.map +0 -1
  130. package/build/caches.d.ts +0 -6
  131. package/build/caches.d.ts.map +0 -1
  132. package/build/caches.js +0 -42
  133. package/build/caches.js.map +0 -1
  134. package/build/changes.d.ts +0 -79
  135. package/build/changes.d.ts.map +0 -1
  136. package/build/changes.js +0 -251
  137. package/build/changes.js.map +0 -1
  138. package/build/config.d.ts +0 -237
  139. package/build/config.d.ts.map +0 -1
  140. package/build/config.js +0 -298
  141. package/build/config.js.map +0 -1
  142. package/build/config.test.d.ts +0 -2
  143. package/build/config.test.d.ts.map +0 -1
  144. package/build/config.test.js +0 -53
  145. package/build/config.test.js.map +0 -1
  146. package/build/configure.d.ts +0 -13
  147. package/build/configure.d.ts.map +0 -1
  148. package/build/configure.js +0 -329
  149. package/build/configure.js.map +0 -1
  150. package/build/dataloaders/findByUniqueDataLoader.d.ts +0 -7
  151. package/build/dataloaders/findByUniqueDataLoader.d.ts.map +0 -1
  152. package/build/dataloaders/findByUniqueDataLoader.js +0 -47
  153. package/build/dataloaders/findByUniqueDataLoader.js.map +0 -1
  154. package/build/dataloaders/findCountDataLoader.d.ts +0 -7
  155. package/build/dataloaders/findCountDataLoader.d.ts.map +0 -1
  156. package/build/dataloaders/findCountDataLoader.js +0 -74
  157. package/build/dataloaders/findCountDataLoader.js.map +0 -1
  158. package/build/dataloaders/findDataLoader.d.ts +0 -37
  159. package/build/dataloaders/findDataLoader.d.ts.map +0 -1
  160. package/build/dataloaders/findDataLoader.js +0 -337
  161. package/build/dataloaders/findDataLoader.js.map +0 -1
  162. package/build/dataloaders/findIdsDataLoader.d.ts +0 -7
  163. package/build/dataloaders/findIdsDataLoader.d.ts.map +0 -1
  164. package/build/dataloaders/findIdsDataLoader.js +0 -74
  165. package/build/dataloaders/findIdsDataLoader.js.map +0 -1
  166. package/build/dataloaders/findOrCreateDataLoader.d.ts +0 -13
  167. package/build/dataloaders/findOrCreateDataLoader.d.ts.map +0 -1
  168. package/build/dataloaders/findOrCreateDataLoader.js +0 -174
  169. package/build/dataloaders/findOrCreateDataLoader.js.map +0 -1
  170. package/build/dataloaders/lensDataLoader.d.ts +0 -12
  171. package/build/dataloaders/lensDataLoader.d.ts.map +0 -1
  172. package/build/dataloaders/lensDataLoader.js +0 -180
  173. package/build/dataloaders/lensDataLoader.js.map +0 -1
  174. package/build/dataloaders/loadDataLoader.d.ts +0 -11
  175. package/build/dataloaders/loadDataLoader.d.ts.map +0 -1
  176. package/build/dataloaders/loadDataLoader.js +0 -54
  177. package/build/dataloaders/loadDataLoader.js.map +0 -1
  178. package/build/dataloaders/manyToManyDataLoader.d.ts +0 -8
  179. package/build/dataloaders/manyToManyDataLoader.d.ts.map +0 -1
  180. package/build/dataloaders/manyToManyDataLoader.js +0 -74
  181. package/build/dataloaders/manyToManyDataLoader.js.map +0 -1
  182. package/build/dataloaders/manyToManyFindDataLoader.d.ts +0 -8
  183. package/build/dataloaders/manyToManyFindDataLoader.d.ts.map +0 -1
  184. package/build/dataloaders/manyToManyFindDataLoader.js +0 -70
  185. package/build/dataloaders/manyToManyFindDataLoader.js.map +0 -1
  186. package/build/dataloaders/oneToManyDataLoader.d.ts +0 -7
  187. package/build/dataloaders/oneToManyDataLoader.d.ts.map +0 -1
  188. package/build/dataloaders/oneToManyDataLoader.js +0 -60
  189. package/build/dataloaders/oneToManyDataLoader.js.map +0 -1
  190. package/build/dataloaders/oneToManyFindDataLoader.d.ts +0 -8
  191. package/build/dataloaders/oneToManyFindDataLoader.d.ts.map +0 -1
  192. package/build/dataloaders/oneToManyFindDataLoader.js +0 -71
  193. package/build/dataloaders/oneToManyFindDataLoader.js.map +0 -1
  194. package/build/dataloaders/oneToOneDataLoader.d.ts +0 -7
  195. package/build/dataloaders/oneToOneDataLoader.d.ts.map +0 -1
  196. package/build/dataloaders/oneToOneDataLoader.js +0 -59
  197. package/build/dataloaders/oneToOneDataLoader.js.map +0 -1
  198. package/build/dataloaders/populateDataLoader.d.ts +0 -13
  199. package/build/dataloaders/populateDataLoader.d.ts.map +0 -1
  200. package/build/dataloaders/populateDataLoader.js +0 -148
  201. package/build/dataloaders/populateDataLoader.js.map +0 -1
  202. package/build/dataloaders/recursiveChildrenDataLoader.d.ts +0 -7
  203. package/build/dataloaders/recursiveChildrenDataLoader.d.ts.map +0 -1
  204. package/build/dataloaders/recursiveChildrenDataLoader.js +0 -77
  205. package/build/dataloaders/recursiveChildrenDataLoader.js.map +0 -1
  206. package/build/dataloaders/recursiveParentsDataLoader.d.ts +0 -7
  207. package/build/dataloaders/recursiveParentsDataLoader.d.ts.map +0 -1
  208. package/build/dataloaders/recursiveParentsDataLoader.js +0 -59
  209. package/build/dataloaders/recursiveParentsDataLoader.js.map +0 -1
  210. package/build/defaults.d.ts +0 -54
  211. package/build/defaults.d.ts.map +0 -1
  212. package/build/defaults.js +0 -282
  213. package/build/defaults.js.map +0 -1
  214. package/build/driverApi.d.ts +0 -19
  215. package/build/driverApi.d.ts.map +0 -1
  216. package/build/driverApi.js +0 -17
  217. package/build/driverApi.js.map +0 -1
  218. package/build/drivers/Driver.d.ts +0 -26
  219. package/build/drivers/Driver.d.ts.map +0 -1
  220. package/build/drivers/Driver.js +0 -3
  221. package/build/drivers/Driver.js.map +0 -1
  222. package/build/drivers/EntityWriter.d.ts +0 -64
  223. package/build/drivers/EntityWriter.d.ts.map +0 -1
  224. package/build/drivers/EntityWriter.js +0 -237
  225. package/build/drivers/EntityWriter.js.map +0 -1
  226. package/build/drivers/IdAssigner.d.ts +0 -50
  227. package/build/drivers/IdAssigner.d.ts.map +0 -1
  228. package/build/drivers/IdAssigner.js +0 -133
  229. package/build/drivers/IdAssigner.js.map +0 -1
  230. package/build/drivers/PostgresDriver.d.ts.map +0 -1
  231. package/build/drivers/PostgresDriver.js.map +0 -1
  232. package/build/drivers/buildRawQuery.d.ts +0 -20
  233. package/build/drivers/buildRawQuery.d.ts.map +0 -1
  234. package/build/drivers/buildRawQuery.js +0 -148
  235. package/build/drivers/buildRawQuery.js.map +0 -1
  236. package/build/drivers/buildUtils.d.ts +0 -4
  237. package/build/drivers/buildUtils.d.ts.map +0 -1
  238. package/build/drivers/buildUtils.js +0 -79
  239. package/build/drivers/buildUtils.js.map +0 -1
  240. package/build/drivers/index.d.ts +0 -5
  241. package/build/drivers/index.d.ts.map +0 -1
  242. package/build/drivers/index.js.map +0 -1
  243. package/build/fields.d.ts +0 -24
  244. package/build/fields.d.ts.map +0 -1
  245. package/build/fields.js +0 -162
  246. package/build/fields.js.map +0 -1
  247. package/build/getProperties.d.ts +0 -28
  248. package/build/getProperties.d.ts.map +0 -1
  249. package/build/getProperties.js +0 -141
  250. package/build/getProperties.js.map +0 -1
  251. package/build/json.d.ts +0 -77
  252. package/build/json.d.ts.map +0 -1
  253. package/build/json.js +0 -116
  254. package/build/json.js.map +0 -1
  255. package/build/k.d.ts +0 -2
  256. package/build/k.d.ts.map +0 -1
  257. package/build/k.js +0 -9
  258. package/build/k.js.map +0 -1
  259. package/build/keys.d.ts +0 -49
  260. package/build/keys.d.ts.map +0 -1
  261. package/build/keys.js +0 -195
  262. package/build/keys.js.map +0 -1
  263. package/build/keywords.d.ts +0 -5
  264. package/build/keywords.d.ts.map +0 -1
  265. package/build/keywords.js +0 -124
  266. package/build/keywords.js.map +0 -1
  267. package/build/loadHints.d.ts +0 -112
  268. package/build/loadHints.d.ts.map +0 -1
  269. package/build/loadHints.js +0 -75
  270. package/build/loadHints.js.map +0 -1
  271. package/build/loadLens.d.ts +0 -66
  272. package/build/loadLens.d.ts.map +0 -1
  273. package/build/loadLens.js +0 -287
  274. package/build/loadLens.js.map +0 -1
  275. package/build/logging/FactoryLogger.d.ts +0 -24
  276. package/build/logging/FactoryLogger.d.ts.map +0 -1
  277. package/build/logging/FactoryLogger.js +0 -77
  278. package/build/logging/FactoryLogger.js.map +0 -1
  279. package/build/logging/FieldLogger.d.ts +0 -27
  280. package/build/logging/FieldLogger.d.ts.map +0 -1
  281. package/build/logging/FieldLogger.js +0 -69
  282. package/build/logging/FieldLogger.js.map +0 -1
  283. package/build/logging/ReactionLogger.d.ts +0 -23
  284. package/build/logging/ReactionLogger.d.ts.map +0 -1
  285. package/build/logging/ReactionLogger.js +0 -65
  286. package/build/logging/ReactionLogger.js.map +0 -1
  287. package/build/newEntity.d.ts +0 -45
  288. package/build/newEntity.d.ts.map +0 -1
  289. package/build/newEntity.js +0 -106
  290. package/build/newEntity.js.map +0 -1
  291. package/build/newTestInstance.d.ts +0 -193
  292. package/build/newTestInstance.d.ts.map +0 -1
  293. package/build/newTestInstance.js +0 -738
  294. package/build/newTestInstance.js.map +0 -1
  295. package/build/normalizeHints.d.ts +0 -16
  296. package/build/normalizeHints.d.ts.map +0 -1
  297. package/build/normalizeHints.js +0 -31
  298. package/build/normalizeHints.js.map +0 -1
  299. package/build/plugins/ImmutableEntitiesPlugin.d.ts +0 -9
  300. package/build/plugins/ImmutableEntitiesPlugin.d.ts.map +0 -1
  301. package/build/plugins/ImmutableEntitiesPlugin.js +0 -21
  302. package/build/plugins/ImmutableEntitiesPlugin.js.map +0 -1
  303. package/build/plugins/PreloadPlugin.d.ts +0 -69
  304. package/build/plugins/PreloadPlugin.d.ts.map +0 -1
  305. package/build/plugins/PreloadPlugin.js +0 -3
  306. package/build/plugins/PreloadPlugin.js.map +0 -1
  307. package/build/preloading/JsonAggregatePreloader.d.ts +0 -16
  308. package/build/preloading/JsonAggregatePreloader.d.ts.map +0 -1
  309. package/build/preloading/JsonAggregatePreloader.js +0 -238
  310. package/build/preloading/JsonAggregatePreloader.js.map +0 -1
  311. package/build/preloading/canPreload.d.ts +0 -3
  312. package/build/preloading/canPreload.d.ts.map +0 -1
  313. package/build/preloading/canPreload.js +0 -21
  314. package/build/preloading/canPreload.js.map +0 -1
  315. package/build/preloading/partitionHint.d.ts +0 -5
  316. package/build/preloading/partitionHint.d.ts.map +0 -1
  317. package/build/preloading/partitionHint.js +0 -56
  318. package/build/preloading/partitionHint.js.map +0 -1
  319. package/build/reactiveHints.d.ts +0 -129
  320. package/build/reactiveHints.d.ts.map +0 -1
  321. package/build/reactiveHints.js +0 -458
  322. package/build/reactiveHints.js.map +0 -1
  323. package/build/relations/AbstractPropertyImpl.d.ts +0 -8
  324. package/build/relations/AbstractPropertyImpl.d.ts.map +0 -1
  325. package/build/relations/AbstractPropertyImpl.js +0 -15
  326. package/build/relations/AbstractPropertyImpl.js.map +0 -1
  327. package/build/relations/AbstractRelationImpl.d.ts +0 -36
  328. package/build/relations/AbstractRelationImpl.d.ts.map +0 -1
  329. package/build/relations/AbstractRelationImpl.js +0 -19
  330. package/build/relations/AbstractRelationImpl.js.map +0 -1
  331. package/build/relations/Collection.d.ts +0 -28
  332. package/build/relations/Collection.d.ts.map +0 -1
  333. package/build/relations/Collection.js +0 -18
  334. package/build/relations/Collection.js.map +0 -1
  335. package/build/relations/CustomCollection.d.ts +0 -69
  336. package/build/relations/CustomCollection.d.ts.map +0 -1
  337. package/build/relations/CustomCollection.js +0 -166
  338. package/build/relations/CustomCollection.js.map +0 -1
  339. package/build/relations/CustomReference.d.ts +0 -71
  340. package/build/relations/CustomReference.d.ts.map +0 -1
  341. package/build/relations/CustomReference.js +0 -152
  342. package/build/relations/CustomReference.js.map +0 -1
  343. package/build/relations/LargeCollection.d.ts +0 -19
  344. package/build/relations/LargeCollection.d.ts.map +0 -1
  345. package/build/relations/LargeCollection.js +0 -3
  346. package/build/relations/LargeCollection.js.map +0 -1
  347. package/build/relations/ManyToManyCollection.d.ts +0 -44
  348. package/build/relations/ManyToManyCollection.d.ts.map +0 -1
  349. package/build/relations/ManyToManyCollection.js +0 -268
  350. package/build/relations/ManyToManyCollection.js.map +0 -1
  351. package/build/relations/ManyToManyLargeCollection.d.ts +0 -30
  352. package/build/relations/ManyToManyLargeCollection.d.ts.map +0 -1
  353. package/build/relations/ManyToManyLargeCollection.js +0 -119
  354. package/build/relations/ManyToManyLargeCollection.js.map +0 -1
  355. package/build/relations/ManyToOneReference.d.ts +0 -121
  356. package/build/relations/ManyToOneReference.d.ts.map +0 -1
  357. package/build/relations/ManyToOneReference.js +0 -389
  358. package/build/relations/ManyToOneReference.js.map +0 -1
  359. package/build/relations/OneToManyCollection.d.ts +0 -58
  360. package/build/relations/OneToManyCollection.d.ts.map +0 -1
  361. package/build/relations/OneToManyCollection.js +0 -347
  362. package/build/relations/OneToManyCollection.js.map +0 -1
  363. package/build/relations/OneToManyLargeCollection.d.ts +0 -26
  364. package/build/relations/OneToManyLargeCollection.d.ts.map +0 -1
  365. package/build/relations/OneToManyLargeCollection.js +0 -102
  366. package/build/relations/OneToManyLargeCollection.js.map +0 -1
  367. package/build/relations/OneToOneReference.d.ts +0 -93
  368. package/build/relations/OneToOneReference.d.ts.map +0 -1
  369. package/build/relations/OneToOneReference.js +0 -228
  370. package/build/relations/OneToOneReference.js.map +0 -1
  371. package/build/relations/PolymorphicReference.d.ts +0 -89
  372. package/build/relations/PolymorphicReference.d.ts.map +0 -1
  373. package/build/relations/PolymorphicReference.js +0 -244
  374. package/build/relations/PolymorphicReference.js.map +0 -1
  375. package/build/relations/ReactiveField.d.ts +0 -87
  376. package/build/relations/ReactiveField.d.ts.map +0 -1
  377. package/build/relations/ReactiveField.js +0 -149
  378. package/build/relations/ReactiveField.js.map +0 -1
  379. package/build/relations/ReactiveGetter.d.ts +0 -30
  380. package/build/relations/ReactiveGetter.d.ts.map +0 -1
  381. package/build/relations/ReactiveGetter.js +0 -38
  382. package/build/relations/ReactiveGetter.js.map +0 -1
  383. package/build/relations/ReactiveManyToMany.d.ts +0 -56
  384. package/build/relations/ReactiveManyToMany.d.ts.map +0 -1
  385. package/build/relations/ReactiveManyToMany.js +0 -243
  386. package/build/relations/ReactiveManyToMany.js.map +0 -1
  387. package/build/relations/ReactiveManyToManyOtherSide.d.ts +0 -47
  388. package/build/relations/ReactiveManyToManyOtherSide.d.ts.map +0 -1
  389. package/build/relations/ReactiveManyToManyOtherSide.js +0 -155
  390. package/build/relations/ReactiveManyToManyOtherSide.js.map +0 -1
  391. package/build/relations/ReactiveQueryField.d.ts +0 -41
  392. package/build/relations/ReactiveQueryField.d.ts.map +0 -1
  393. package/build/relations/ReactiveQueryField.js +0 -125
  394. package/build/relations/ReactiveQueryField.js.map +0 -1
  395. package/build/relations/ReactiveReference.d.ts +0 -119
  396. package/build/relations/ReactiveReference.d.ts.map +0 -1
  397. package/build/relations/ReactiveReference.js +0 -333
  398. package/build/relations/ReactiveReference.js.map +0 -1
  399. package/build/relations/ReadOnlyCollection.d.ts +0 -19
  400. package/build/relations/ReadOnlyCollection.d.ts.map +0 -1
  401. package/build/relations/ReadOnlyCollection.js +0 -15
  402. package/build/relations/ReadOnlyCollection.js.map +0 -1
  403. package/build/relations/RecursiveCollection.d.ts +0 -84
  404. package/build/relations/RecursiveCollection.d.ts.map +0 -1
  405. package/build/relations/RecursiveCollection.js +0 -296
  406. package/build/relations/RecursiveCollection.js.map +0 -1
  407. package/build/relations/Reference.d.ts +0 -35
  408. package/build/relations/Reference.d.ts.map +0 -1
  409. package/build/relations/Reference.js +0 -21
  410. package/build/relations/Reference.js.map +0 -1
  411. package/build/relations/Relation.d.ts +0 -14
  412. package/build/relations/Relation.d.ts.map +0 -1
  413. package/build/relations/Relation.js +0 -12
  414. package/build/relations/Relation.js.map +0 -1
  415. package/build/relations/hasAsyncMethod.d.ts +0 -27
  416. package/build/relations/hasAsyncMethod.d.ts.map +0 -1
  417. package/build/relations/hasAsyncMethod.js +0 -47
  418. package/build/relations/hasAsyncMethod.js.map +0 -1
  419. package/build/relations/hasAsyncProperty.d.ts +0 -49
  420. package/build/relations/hasAsyncProperty.d.ts.map +0 -1
  421. package/build/relations/hasAsyncProperty.js +0 -98
  422. package/build/relations/hasAsyncProperty.js.map +0 -1
  423. package/build/relations/hasManyDerived.d.ts +0 -22
  424. package/build/relations/hasManyDerived.d.ts.map +0 -1
  425. package/build/relations/hasManyDerived.js +0 -32
  426. package/build/relations/hasManyDerived.js.map +0 -1
  427. package/build/relations/hasManyThrough.d.ts +0 -10
  428. package/build/relations/hasManyThrough.d.ts.map +0 -1
  429. package/build/relations/hasManyThrough.js +0 -24
  430. package/build/relations/hasManyThrough.js.map +0 -1
  431. package/build/relations/hasOneDerived.d.ts +0 -12
  432. package/build/relations/hasOneDerived.d.ts.map +0 -1
  433. package/build/relations/hasOneDerived.js +0 -24
  434. package/build/relations/hasOneDerived.js.map +0 -1
  435. package/build/relations/hasOneThrough.d.ts +0 -10
  436. package/build/relations/hasOneThrough.d.ts.map +0 -1
  437. package/build/relations/hasOneThrough.js +0 -24
  438. package/build/relations/hasOneThrough.js.map +0 -1
  439. package/build/relations/index.d.ts +0 -28
  440. package/build/relations/index.d.ts.map +0 -1
  441. package/build/relations/index.js +0 -88
  442. package/build/relations/index.js.map +0 -1
  443. package/build/rules.d.ts +0 -123
  444. package/build/rules.d.ts.map +0 -1
  445. package/build/rules.js +0 -231
  446. package/build/rules.js.map +0 -1
  447. package/build/runtimeConfig.d.ts +0 -17
  448. package/build/runtimeConfig.d.ts.map +0 -1
  449. package/build/runtimeConfig.js +0 -18
  450. package/build/runtimeConfig.js.map +0 -1
  451. package/build/serde.d.ts +0 -277
  452. package/build/serde.d.ts.map +0 -1
  453. package/build/serde.js +0 -517
  454. package/build/serde.js.map +0 -1
  455. package/build/temporal.d.ts +0 -16
  456. package/build/temporal.d.ts.map +0 -1
  457. package/build/temporal.js +0 -48
  458. package/build/temporal.js.map +0 -1
  459. package/build/temporalMappers.d.ts +0 -25
  460. package/build/temporalMappers.d.ts.map +0 -1
  461. package/build/temporalMappers.js +0 -59
  462. package/build/temporalMappers.js.map +0 -1
  463. package/build/typeMap.d.ts +0 -68
  464. package/build/typeMap.d.ts.map +0 -1
  465. package/build/typeMap.js +0 -3
  466. package/build/typeMap.js.map +0 -1
  467. package/build/unnest.d.ts +0 -13
  468. package/build/unnest.d.ts.map +0 -1
  469. package/build/unnest.js +0 -85
  470. package/build/unnest.js.map +0 -1
  471. package/build/upsert.d.ts +0 -42
  472. package/build/upsert.d.ts.map +0 -1
  473. package/build/upsert.js +0 -265
  474. package/build/upsert.js.map +0 -1
  475. package/build/utils.d.ts +0 -58
  476. package/build/utils.d.ts.map +0 -1
  477. package/build/utils.js +0 -236
  478. package/build/utils.js.map +0 -1
  479. package/build/withLoaded.d.ts +0 -56
  480. package/build/withLoaded.d.ts.map +0 -1
  481. package/build/withLoaded.js +0 -76
  482. package/build/withLoaded.js.map +0 -1
@@ -1,734 +0,0 @@
1
- import DataLoader, { BatchLoadFn, Options } from "dataloader";
2
- import { IndexManager } from "./IndexManager";
3
- import { findByUniqueOperation } from "./dataloaders/findByUniqueDataLoader";
4
- import { findCountOperation } from "./dataloaders/findCountDataLoader";
5
- import { findOperation } from "./dataloaders/findDataLoader";
6
- import { findIdsOperation } from "./dataloaders/findIdsDataLoader";
7
- import { lensOperation } from "./dataloaders/lensDataLoader";
8
- import { loadOperation } from "./dataloaders/loadDataLoader";
9
- import { manyToManyLoadOperation } from "./dataloaders/manyToManyDataLoader";
10
- import { manyToManyFindOperation } from "./dataloaders/manyToManyFindDataLoader";
11
- import { oneToManyLoadOperation } from "./dataloaders/oneToManyDataLoader";
12
- import { oneToManyFindOperation } from "./dataloaders/oneToManyFindDataLoader";
13
- import { oneToOneLoadOperation } from "./dataloaders/oneToOneDataLoader";
14
- import { populateOperation } from "./dataloaders/populateDataLoader";
15
- import { recursiveChildrenOperation } from "./dataloaders/recursiveChildrenDataLoader";
16
- import { recursiveParentsOperation } from "./dataloaders/recursiveParentsDataLoader";
17
- import { Driver } from "./drivers";
18
- import { Entity, Entity as EntityW } from "./Entity";
19
- import { DeepPartialOrNull, EntityMetadata, ExpressionFilter, FieldLogger, FilterWithAlias, GraphQLFilterWithAlias, InstanceData, Lens, OneToManyCollection, PartialOrNull, Plugin, ReactionLogger, ReactiveHint, Reference, UniqueFilter } from "./index";
20
- import { IsLoadedCache } from "./IsLoadedCache";
21
- import { JoinRows, ManyToManyLike } from "./JoinRows";
22
- import { Loaded, LoadHint, New } from "./loadHints";
23
- import { PluginManager } from "./PluginManager";
24
- import { PreloadPlugin } from "./plugins/PreloadPlugin";
25
- import { ReactionsManager } from "./ReactionsManager";
26
- import { OptsOf, OrderOf } from "./typeMap";
27
- import { MaybePromise } from "./utils";
28
- /**
29
- * The constructor for concrete entity types.
30
- *
31
- * Abstract entity types, like a base `Publisher` class that is marked `abstract`, cannot
32
- * implement this and instead only have the `AbsEntityConstructor` type.
33
- */
34
- export interface EntityConstructor<T> {
35
- /** The pseudo-public constructor for entities; only the `EntityManager` should actually instantiate entities. */
36
- new (em: EntityManager<any, any, any>): T;
37
- tagName: any;
38
- metadata: EntityMetadata;
39
- /** Returns the private `InstanceData` for the given entity. */
40
- getInstanceData(entity: Entity): InstanceData;
41
- }
42
- /** Options for the auto-batchable `em.find` queries, i.e. limit & offset aren't allowed. */
43
- export interface FindFilterOptions<T extends Entity> {
44
- conditions?: ExpressionFilter;
45
- orderBy?: OrderOf<T> | OrderOf<T>[];
46
- softDeletes?: "include" | "exclude";
47
- }
48
- /**
49
- * Options for the non-batchable `em.findPaginated` queries, i.e. limit & offset are allowed.
50
- *
51
- * We allow `offset` to be optional, b/c sometimes queries will just want to do a `limit`, but we
52
- * require `limit` to ensure the caller is using `findPaginated` for its intended purpose.
53
- */
54
- export interface FindPaginatedFilterOptions<T extends Entity> extends FindFilterOptions<T> {
55
- limit: number | undefined;
56
- offset?: number;
57
- }
58
- export interface FindGqlPaginatedFilterOptions<T extends Entity> extends FindFilterOptions<T> {
59
- limit?: number | null;
60
- offset?: number | null;
61
- }
62
- /** Options for the `findCount`. */
63
- export interface FindCountFilterOptions<T extends Entity> {
64
- conditions?: ExpressionFilter;
65
- softDeletes?: "include" | "exclude";
66
- }
67
- /**
68
- * Constructors for either concrete or abstract entity types.
69
- *
70
- * I.e. this is more like "MaybeAbstractEntityConstructor".
71
- */
72
- export type MaybeAbstractEntityConstructor<T> = abstract new (em: EntityManager<any, any, any>, opts: any) => T;
73
- /** Pulls the entity's id type out of a given entity type T. */
74
- export type IdOf<T> = T extends {
75
- id: infer I;
76
- } ? I : never;
77
- export type TaggedId = string;
78
- export declare function isId(value: any): value is IdOf<unknown>;
79
- export type EntityManagerHook = "beforeBegin" | "afterBegin" | "beforeCommit" | "afterCommit";
80
- type HookFn<TX> = (em: EntityManager, txn: TX) => MaybePromise<any>;
81
- export type LoaderCache = Record<string, DataLoader<any, any>>;
82
- export interface TimestampFields {
83
- updatedAt: string | undefined;
84
- createdAt: string | undefined;
85
- deletedAt: string | undefined;
86
- }
87
- export type EntityManagerOpts<TX = unknown> = ({
88
- driver: Driver<TX>;
89
- em?: undefined;
90
- } | {
91
- driver?: undefined;
92
- em: EntityManager<any, any, any>;
93
- }) & {
94
- preloadPlugin?: PreloadPlugin;
95
- };
96
- export interface FlushOptions {
97
- /** Skip all validations, including reactive validations, when flushing */
98
- skipValidation?: boolean;
99
- }
100
- /**
101
- * Describes the EntityManager read/write mode.
102
- *
103
- * - `read-only` -- any entity mutations or `em.flush` calls will fail fast
104
- * - `in-memory-writes` -- allows entity mutations and `em.flush` w/o a `COMMIT`
105
- * - `writes` -- allows entity mutations and `em.flush` will `COMMIT` writes
106
- */
107
- export type EntityManagerMode = "read-only" | "in-memory-writes" | "writes";
108
- export type FindOperation = typeof findOperation | "findPaginated" | typeof findByUniqueOperation | typeof findCountOperation | typeof findIdsOperation | typeof lensOperation | typeof loadOperation | typeof manyToManyLoadOperation | typeof manyToManyFindOperation | typeof oneToManyLoadOperation | typeof oneToManyFindOperation | typeof oneToOneLoadOperation | typeof populateOperation | typeof recursiveChildrenOperation | typeof recursiveParentsOperation;
109
- /**
110
- * The EntityManager is the primary way nearly all code, i.e. anything that finds/creates/updates/deletes entities,
111
- * will interact with the database.
112
- *
113
- * It acts both an Identity Cache (preventing loading the same row twice into memory as separate entities, and then
114
- * having drift between the two instances) and as a Unit of Work (tracking all changes to entities and then batch
115
- * flushing only the entities that have changed).
116
- *
117
- * Note that the type parameters (C, I, and Entity) will be filled in by codegen with the values specific to your
118
- * application, so you can import your app-specific EntityManager like:
119
- *
120
- * ```ts
121
- * import { EntityManager } from "src/entities";
122
- * ```
123
- *
124
- * @param C The type of your application-specific app-wide/request-wide Context object that will be passed to hooks
125
- * @typeParam C - the application-specific context (typically the request-level context)
126
- * @typeParam Entity - the application's based entity type (i.e. with number ids or string ids)
127
- * @typeParamTX - the application's Transaction type, i.e. `Knex`
128
- */
129
- export declare class EntityManager<C = unknown, Entity extends EntityW = EntityW, TX extends unknown = unknown> {
130
- #private;
131
- readonly ctx: C;
132
- driver: Driver<TX>;
133
- /** When we're flushing, the connection/transaction. */
134
- txn: TX | undefined;
135
- entityLimit: number;
136
- private __api;
137
- mode: EntityManagerMode;
138
- constructor(ctx: C, opts: EntityManagerOpts<TX>);
139
- constructor(ctx: C, driver: Driver<TX>);
140
- /** Returns a read-only shallow copy of the currently-loaded entities. */
141
- get entities(): ReadonlyArray<Entity>;
142
- /** Returns a read-only list of the currently-loaded entities of `type`. */
143
- getEntities<T extends Entity>(type: MaybeAbstractEntityConstructor<T>): ReadonlyArray<T>;
144
- /** Looks up `id` in the list of already-loaded entities. */
145
- getEntity<T extends Entity & {
146
- id: string;
147
- }>(id: IdOf<T>): T | undefined;
148
- getEntity(id: TaggedId): Entity | undefined;
149
- /**
150
- * Finds entities of `type` with the `where` filter, with auto-batching, so this method
151
- * will not cause N+1s if called in a loop.
152
- *
153
- * The `where` filter is one of Joist's "join literals", which can combine both joining into
154
- * related entities and simple column conditions in a single literal. All conditions are ANDed.
155
- * For more complex conditions, use the `find` overload that has a `conditions` option.
156
- *
157
- * This method is batch-friendly, i.e. if called in a loop, it will be automatically batched
158
- * to avoid N+1s. Because of this, it cannot be used with queries that want to use `LIMIT`
159
- * or `OFFSET`; for those, see `findPaginated`.
160
- */
161
- find<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>): Promise<T[]>;
162
- find<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options?: FindFilterOptions<T> & {
163
- populate?: H;
164
- }): Promise<Loaded<T, H>[]>;
165
- /**
166
- * Finds entities of `type` with the `where` filter, without auto-batching, so this method
167
- * may call N+1s if called in a loop.
168
- *
169
- * The `where` filter is one of Joist's "join literals", which can combine both joining into
170
- * related entities and simple column conditions in a single literal. All conditions are ANDed.
171
- * For more complex conditions, use the `find` overload that has a `conditions` option.
172
- *
173
- * This method is *NOT* batch-friendly, i.e. if called in a loop, it will cause N+1s. Because
174
- * of this, you should prefer using `find`, unless you explicitly pagination support.
175
- */
176
- findPaginated<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options: FindPaginatedFilterOptions<T>): Promise<T[]>;
177
- findPaginated<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options: FindPaginatedFilterOptions<T> & {
178
- populate: H;
179
- }): Promise<Loaded<T, H>[]>;
180
- private executeFind;
181
- /**
182
- * Works exactly like `find` but accepts "less than greatly typed" GraphQL filters.
183
- *
184
- * I.e. filtering by `null` on fields that are non-`nullable`.
185
- */
186
- findGql<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: GraphQLFilterWithAlias<T>): Promise<T[]>;
187
- findGql<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: GraphQLFilterWithAlias<T>, options?: FindFilterOptions<T> & {
188
- populate?: H;
189
- }): Promise<Loaded<T, H>[]>;
190
- /**
191
- * Works exactly like `findPaginated` but accepts "less than greatly typed" GraphQL filters.
192
- *
193
- * I.e. filtering by `null` on fields that are non-`nullable`.
194
- */
195
- findGqlPaginated<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: GraphQLFilterWithAlias<T>, options: FindGqlPaginatedFilterOptions<T>): Promise<T[]>;
196
- findGqlPaginated<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: GraphQLFilterWithAlias<T>, options: FindGqlPaginatedFilterOptions<T> & {
197
- populate: H;
198
- }): Promise<Loaded<T, H>[]>;
199
- findOne<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>): Promise<T | undefined>;
200
- findOne<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options?: FindFilterOptions<T> & {
201
- populate?: H;
202
- }): Promise<Loaded<T, H> | undefined>;
203
- /** Executes a given query filter and returns exactly one result, otherwise throws `NotFoundError` or `TooManyError`. */
204
- findOneOrFail<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>): Promise<T>;
205
- findOneOrFail<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options: FindFilterOptions<T> & {
206
- populate?: H;
207
- }): Promise<Loaded<T, H>>;
208
- findByUnique<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: UniqueFilter<T>): Promise<T | undefined>;
209
- findByUnique<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, where: UniqueFilter<T>, options?: {
210
- populate?: H;
211
- softDeletes?: "include" | "exclude";
212
- }): Promise<Loaded<T, H> | undefined>;
213
- /**
214
- * Returns the count of entities that match the `where` clause.
215
- *
216
- * The `where` clause, and any options.conditions, matches the same syntax
217
- * as `em.find`.
218
- *
219
- * Note: this method is not currently auto-batched, so it will cause N+1s if called in a loop.
220
- */
221
- findCount<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options?: FindCountFilterOptions<T>): Promise<number>;
222
- /**
223
- * Returns the IDs of entities that match the `where` clause.
224
- *
225
- * The `where` clause, and any options.conditions, matches the same syntax
226
- * as `em.find`.
227
- */
228
- findIds<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, where: FilterWithAlias<T>, options?: FindCountFilterOptions<T>): Promise<string[]>;
229
- /**
230
- * Looks for entities that match `where`, both in the database and any just-created or just-changed entities.
231
- *
232
- * Because we evaluate this `where` clause in memory (against any WIP changes made to entities
233
- * that have not yet been `em.flush`ed to the database), the `where` clause is limited to fields
234
- * immediately available on the entity, i.e. primitives, enums, and many-to-ones, without any
235
- * nested, cross-table joins/conditions.
236
- *
237
- * For `m2o` fields, `undefined` will be pruned, just like `em.find`s. I.e. `{ publisher: undefined }` will
238
- * be pruned and not filter on `publisher` at all, where as `{ publisher: null }` will filter for `publisher`
239
- * is unset.
240
- *
241
- * @param type the entity type to find
242
- * @param where the fields to look up the existing entity by
243
- */
244
- findWithNewOrChanged<T extends Entity, F extends Partial<OptsOf<T>>>(type: EntityConstructor<T>, where: F): Promise<T[]>;
245
- findWithNewOrChanged<T extends Entity, F extends Partial<OptsOf<T>>, const H extends LoadHint<T>>(type: EntityConstructor<T>, where: F, options?: {
246
- populate?: H;
247
- softDeletes?: "include" | "exclude";
248
- }): Promise<Loaded<T, H>[]>;
249
- /**
250
- * Conditionally finds or creates (or upserts) an Entity.
251
- *
252
- * The `where` param is used to find the existing/if any entity; if not found,
253
- * then one will be created.
254
- *
255
- * The `ifNew` param will be used, if no entity is found, for the `em.create` call;
256
- * it is typed such that it will require all opts necessary for the `em.create` to
257
- * be valid, _unless_ those opts are already included in either the `where` or
258
- * `upsert` params.
259
- *
260
- * The optional `upsert` param are fields to always set/update, regardless of whether
261
- * the entity is created or not.
262
- *
263
- * @param type the entity type to find/create
264
- * @param where the fields to look up the existing entity by
265
- * @param ifNew the fields to set if the entity is new
266
- * @param upsert the fields to update if the entity is either existing or new
267
- */
268
- findOrCreate<T extends EntityW, F extends Partial<OptsOf<T>>, U extends Partial<OptsOf<T>> | {}, N extends Omit<OptsOf<T>, keyof F | keyof U>>(type: EntityConstructor<T>, where: F, ifNew: N, upsert?: U): Promise<T>;
269
- findOrCreate<T extends EntityW, F extends Partial<OptsOf<T>>, U extends Partial<OptsOf<T>> | {}, N extends Omit<OptsOf<T>, keyof F | keyof U>, const H extends LoadHint<T>>(type: EntityConstructor<T>, where: F, ifNew: N, upsert?: U, options?: {
270
- populate?: H;
271
- softDeletes?: "include" | "exclude";
272
- }): Promise<Loaded<T, H>>;
273
- /** Creates a new `type` and marks it as loaded, i.e. we know its collections are all safe to access in memory. */
274
- create<T extends EntityW, O extends OptsOf<T>>(type: EntityConstructor<T>, opts: O): New<T, O>;
275
- /**
276
- * Creates a new `type` but with `opts` that are nullable, to accept partial-update-style input.
277
- *
278
- * Note that `createPartial` doesn't support the full upsert behavior, i.e. this method:
279
- *
280
- * - always creates,
281
- * - does not support relation markers like `op`, `delete`, and `remove`,
282
- * - does not accept deep input, but
283
- * - fields set to `undefined` will be skipped instead of unset
284
- *
285
- * See `upsert` for the upsert/deep upsert behavior.
286
- */
287
- createPartial<T extends EntityW>(type: EntityConstructor<T>, opts: PartialOrNull<OptsOf<T>>): T;
288
- /**
289
- * Create or updates `type` based on partial-update-style `input`.
290
- *
291
- * This supports upsert behavior, i.e.:
292
- *
293
- * - findOrCreate the primary entity being updated (based on the `id` key being provided),
294
- * - upsert relation markers like `op`, `delete`, and `remove` are supported,
295
- * - deep input is supported, i.e. `{ firstName: "Bob", books: [{ title: "b1" } ] }`, and
296
- * - fields set to `undefined` will be skipped instead of unset
297
- */
298
- upsert<T extends EntityW>(type: EntityConstructor<T>, input: DeepPartialOrNull<T>): Promise<T>;
299
- /**
300
- * Utility to clone an entity and its nested relations, as determined by a populate hint
301
- *
302
- * @param entity - Any entity
303
- * @param opts - Options to control the clone behaviour
304
- * @param deep - Populate hint of the nested tree of objects to clone
305
- * @param skip - Keys that will be skipped in the clone
306
- * @param skipIf - Predicate for determining if a specific entity should be skipped (and any entities beneath it
307
- * @param postClone - Function to be called for each original/clone entity for any post-processing needed
308
- * @returns The `Loaded` cloned entity or fails if the clone could not be made
309
- *
310
- * @example
311
- * // This will duplicate the author
312
- * const duplicatedAuthor = await em.clone(author)
313
- *
314
- * @example
315
- * // This will duplicate the author and all their related book entities
316
- * const duplicatedAuthorAndBooks = await em.clone(author, { deep: "books" })
317
- *
318
- * @example
319
- * // This will duplicate the author, all their books, and the images for those books
320
- * const duplicatedAuthorAndBooksAndImages = await em.clone(author, { deep: { books: "image" } })
321
- *
322
- * @example
323
- * // This will duplicate the author, and rename
324
- * const duplicatedAuthor = await em.clone(author, { postClone: (_original, clone) => clone.firstName = clone.firstName + " COPY" })
325
- *
326
- * @example
327
- * // This will duplicate the author, but skip any book where the title includes `sea`
328
- * const duplicatedAuthor = await em.clone(author, { skipIf: (original) => original.title?.includes("sea") })
329
- */
330
- clone<T extends Entity, H extends LoadHint<T>, const K = ReactiveHint<T>>(entity: T, opts?: {
331
- deep?: H;
332
- skip?: K;
333
- skipIf?: (entity: Entity) => boolean;
334
- postClone?: (original: Entity, clone: Entity) => void;
335
- }): Promise<Loaded<T, H>>;
336
- /**
337
- * Utility to clone an entity and its nested relations, as determined by a populate hint.
338
- *
339
- * @param entities - Any homogeneous list of entities
340
- * @param opts - Options to control the clone behaviour
341
- * @param deep - Populate hint of the nested tree of objects to clone
342
- * @param skip - Keys that will be skipped in the clone
343
- * @param skipIf - Predicate for determining if a specific entity should be skipped (and any entities beneath it
344
- * @param postClone - Function to be called for each original/clone entity for any post-processing needed
345
- * @returns Array of `Loaded` cloned entities from the provided list or empty array if all are skipped
346
- *
347
- * @example
348
- * // This will duplicate the author's books
349
- * const duplicatedBooks = await em.clone(author.books.get)
350
- *
351
- * @example
352
- * // This will duplicate the author's books, all their books, and the images for those books
353
- * const duplicatedBooksAndImages = await em.clone(author.books.get, { deep: { books: "image" } })
354
- *
355
- * @example
356
- * // This will duplicate the author's books, and assign them to a different author
357
- * const duplicatedBooks = await em.clone(author.books.get, { postClone: (_original, clone) => clone.author.set(author2) })
358
- *
359
- * @example
360
- * // This will duplicate the author's books, but skip any book where the title includes `sea`
361
- * const duplicatedBooks = await em.clone(author.books.get, { skipIf: (original) => original.title.includes("sea") })
362
- */
363
- clone<T extends Entity, H extends LoadHint<T>, const K = ReactiveHint<T>>(entities: readonly T[], opts?: {
364
- deep?: H;
365
- skip?: K;
366
- skipIf?: (entity: Entity) => boolean;
367
- postClone?: (original: Entity, clone: Entity) => void;
368
- }): Promise<Loaded<T, H>[]>;
369
- /**
370
- * Merges multiple source entities into a target entity by updating all references that point
371
- * to the source entities to instead point to the target entity.
372
- *
373
- * This method loads all relations from the source entities, updates any entity that
374
- * references a source entity to reference the target entity instead, and then automatically
375
- * deletes the source entities.
376
- *
377
- * @param target - The entity that will become the target of all merged references
378
- * @param sources - Array of entities whose references will be redirected to the target
379
- * @param opts - Options to control merge behavior
380
- * @param autoDelete - Whether to automatically delete source entities (default: true)
381
- * @returns Promise that resolves when all references have been updated and sources deleted
382
- *
383
- * @example
384
- * // Merge duplicate authors - all books pointing to author2 will now point to author1
385
- * // author2 will be automatically deleted
386
- * await em.merge(author1, [author2]);
387
- *
388
- * @example
389
- * // Merge multiple duplicate publishers into one
390
- * // publisher2 and publisher3 will be automatically deleted
391
- * await em.merge(publisher1, [publisher2, publisher3]);
392
- *
393
- * @example
394
- * // Merge without auto-deleting sources (for custom cleanup logic)
395
- * await em.merge(author1, [author2], { autoDelete: false });
396
- * // Custom logic here...
397
- * em.delete(author2);
398
- */
399
- merge<T extends Entity>(target: T, sources: T[], opts?: {
400
- autoDelete?: boolean;
401
- }): Promise<Entity[]>;
402
- /** Returns an instance of `type` for the given `id`, resolving to an existing instance if in our Unit of Work. */
403
- load<T extends EntityW & {
404
- id: string;
405
- }>(id: IdOf<T>): Promise<T>;
406
- load(id: TaggedId): Promise<Entity>;
407
- load<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, id: IdOf<T> | TaggedId): Promise<T>;
408
- load<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, id: IdOf<T> | TaggedId, populate: H): Promise<Loaded<T, H>>;
409
- /** Returns instances of `type` for the given `ids`, resolving to an existing instance if in our Unit of Work. */
410
- loadAll<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, ids: readonly string[]): Promise<T[]>;
411
- loadAll<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, ids: readonly string[], populate: H): Promise<Loaded<T, H>[]>;
412
- /**
413
- * Returns instances of `type` for the given `ids`, resolving to an existing instance if in our Unit of Work. Ignores
414
- * IDs that are not found.
415
- */
416
- loadAllIfExists<T extends EntityW>(type: EntityConstructor<T>, ids: readonly string[]): Promise<T[]>;
417
- loadAllIfExists<T extends EntityW, const H extends LoadHint<T>>(type: EntityConstructor<T>, ids: readonly string[], populate: H): Promise<Loaded<T, H>[]>;
418
- /**
419
- * Loads entities found, when starting at `entities`, via the "path" given by the `fn` lens function.
420
- *
421
- * Results are unique, i.e. if doing `em.loadLens([b1, b2], b => b.author.publisher)` point to the
422
- * same `Publisher`, it will only be returned as a single value.
423
- */
424
- loadLens<T extends EntityW, U, V>(entities: readonly T[], fn: (lens: Lens<T>) => Lens<U, V>): Promise<U[]>;
425
- loadLens<T extends EntityW, U extends EntityW, V, const H extends LoadHint<U>>(entities: readonly T[], fn: (lens: Lens<T>) => Lens<U, V>, populate: H): Promise<Loaded<U, H>[]>;
426
- /**
427
- * Loads entities from database rows that were queried directly using a query builder.
428
- *
429
- * This overload is synchronous since there is no population/querying to do.
430
- */
431
- loadFromQuery<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, rows: readonly unknown[]): T[];
432
- /**
433
- * Loads entities from database rows from a Knex-ish query builder that needs an `await`.
434
- *
435
- * This overload is async because it triggers the `rows` query.
436
- */
437
- loadFromQuery<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, rows: PromiseLike<readonly unknown[]>): Promise<T[]>;
438
- /**
439
- * Loads & populates entities from database rows that were queried directly using a query builder.
440
- */
441
- loadFromQuery<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, rows: readonly unknown[], populate: H): Promise<Loaded<T, H>[]>;
442
- /**
443
- * Loads & populates entities from database rows from a Knex-ish query builder that needs an `await`.
444
- */
445
- loadFromQuery<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, rows: PromiseLike<readonly unknown[]>, populate: H): Promise<Loaded<T, H>[]>;
446
- /** Loads entities from rows. */
447
- loadFromRows<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, rows: unknown[]): Promise<T[]>;
448
- loadFromRows<T extends EntityW, const H extends LoadHint<T>>(type: MaybeAbstractEntityConstructor<T>, rows: unknown[], populate: H): Promise<Loaded<T, H>[]>;
449
- /** Given a hint `H` (a field, array of fields, or nested hash), pre-load that data into `entity` for sync access. */
450
- populate<T extends EntityW, const H extends LoadHint<T>, V = Loaded<T, H>>(entity: T, hint: H, fn?: (entity: Loaded<T, H>) => V): Promise<V>;
451
- populate<T extends EntityW, const H extends LoadHint<T>, V = Loaded<T, H>>(entity: T, opts: {
452
- hint: H;
453
- forceReload?: boolean;
454
- }, fn?: (entity: Loaded<T, H>) => V): Promise<V>;
455
- populate<T extends EntityW, const H extends LoadHint<T>>(entities: ReadonlyArray<T>, hint: H): Promise<Loaded<T, H>[]>;
456
- populate<T extends EntityW, const H extends LoadHint<T>>(entities: ReadonlyArray<T>, opts: {
457
- hint: H;
458
- forceReload?: boolean;
459
- }): Promise<Loaded<T, H>[]>;
460
- /**
461
- * Executes `fn` with a transaction, and automatically calls `flush`/`commit` at the end.
462
- *
463
- * This ensures both any `.find` and `.flush` operations happen within the same
464
- * transaction, which is useful for enforcing cross-table/application-level invariants that
465
- * cannot be enforced with database-level constraints.
466
- */
467
- transaction<T>(fn: (txn: TX) => Promise<T>): Promise<T>;
468
- /**
469
- * Marks an instance to be deleted.
470
- *
471
- * Any loaded collections that are currently "pointing to" this entity will be updated to
472
- * no longer include this entity, i.e. if you `em.delete(b1)`, then `author.books` will have
473
- * `b1` removed (if needed).
474
- *
475
- * This is done for all currently-loaded collections; i.e. technically unloaded collections
476
- * may still point to this entity. We defer unsetting these not-currently-loaded references
477
- * until `EntityManager.flush`, when we can make the async calls to load-and-unset them.
478
- */
479
- delete(entity: Entity): void;
480
- /**
481
- * Marks entities to be deleted.
482
- *
483
- * Any loaded collections that are currently "pointing to" this entity will be updated to
484
- * no longer include this entity, i.e. if you `em.delete(b1)`, then `author.books` will have
485
- * `b1` removed (if needed).
486
- *
487
- * This is done for all currently-loaded collections; i.e. technically unloaded collections
488
- * may still point to this entity. We defer unsetting these not-currently-loaded references
489
- * until `EntityManager.flush`, when we can make the async calls to load-and-unset them.
490
- */
491
- delete(entities: Entity[]): void;
492
- assignNewIds(): Promise<void>;
493
- /**
494
- * Immediately assigns async defaults to `entities`.
495
- *
496
- * Normally async defaults wait until `em.flush` to run, because their async nature requires
497
- * an `await` / `Promise` to be evaluated, and `em.create` is synchronous.
498
- *
499
- * This `assignDefaults` methods like you move that up, and immediately invoke
500
- * any default logic against the `entities`.
501
- */
502
- setDefaults(entities: Entity[]): Promise<void>;
503
- /**
504
- * Flushes the SQL for any changed entities to the database.
505
- *
506
- * If this is run outside of an existing transaction, it will `BEGIN` and `COMMIT`
507
- * a new transaction on every `.flush()` call so that all of the `INSERT`s/etc.
508
- * happen atomically.
509
- *
510
- * If this is run within an existing transaction, i.e. `EntityManager.transaction`,
511
- * then it will only issue `INSERT`s/etc. and defer to the caller to `COMMIT`
512
- * the transaction.
513
- *
514
- * It returns entities that have changed (an entity is considered changed if it has been deleted, inserted, or updated)
515
- */
516
- flush(flushOptions?: FlushOptions): Promise<Entity[]>;
517
- /**
518
- * A very simple toJSON.
519
- *
520
- * This is not really meant to be useful, it's to prevent huge/circular output if
521
- * an EntityManager accidentally ends up getting logged to something like pino that
522
- * over-zealous toJSONs anything it touches.
523
- */
524
- toJSON(): string;
525
- /**
526
- * For all entities in the current `EntityManager`, load their latest data from the database.
527
- *
528
- * This is primarily useful in tests, i.e. having 1 `EntityManager` with some test data, running business
529
- * logic in a dedicated `EntityManager`, and then `refresh`-ing the test data `EntityManager` to assert
530
- * against the latest values.
531
- *
532
- * This works with primitive fields as well as references and collections.
533
- *
534
- * TODO Newly-found collection entries will not have prior load hints applied to this, unless using
535
- * `deepLoad` which should only be used by tests to avoid loading your entire database in memory.
536
- */
537
- refresh(opts?: {
538
- deepLoad?: boolean;
539
- }): Promise<void>;
540
- refresh(entity: EntityW): Promise<void>;
541
- refresh(entities: ReadonlyArray<EntityW>): Promise<void>;
542
- get numberOfEntities(): number;
543
- findExistingInstance<T extends EntityW>(id: string): T | undefined;
544
- /**
545
- * Takes a result `row` from a custom query and maps the db values into a new-or-existing domain object for that row.
546
- *
547
- * The `overwriteExisting` controls whether `row`'s values should overwrite the existing fields on
548
- * an entity. By default this is true, as we assume the user calling this means they know the DB has
549
- * updated values that should be put into the entities. A few internal callers set this to false,
550
- * i.e. when we're loading collections and have db results that are potentially stale compared to
551
- * the WIP entity state.
552
- */
553
- hydrate<T extends EntityW>(type: MaybeAbstractEntityConstructor<T>, rows: readonly any[], options?: {
554
- overwriteExisting?: boolean;
555
- }): T[];
556
- /**
557
- * Mark an entity as needing to be flushed regardless of its state.
558
- *
559
- * This will:
560
- *
561
- * - Bump the entity's `updated_at` timestamp (if available),
562
- * - Run `beforeUpdate` and `beforeFlush` hooks.
563
- */
564
- touch(entity: EntityW): void;
565
- touch(entities: EntityW[]): void;
566
- /**
567
- * Recalculates the reactive fields for an entity, and any downstream reactive fields or reactions that depend on them.
568
- *
569
- * You shouldn't need to call this unless the derived fields have drifted from the underlying data, which
570
- * should only happen if:
571
- *
572
- * - The underlying data was changed by a raw SQL query, or
573
- * - You've changed the field's business logic and want to update the database to the latest value.
574
- *
575
- * You can also trigger a recalc for specific fields by calling `.load()` on the property, i.e.
576
- * `author.numberOfBooks.load()`. This `recalc` method is just a helper method to call `load` for
577
- * all derived fields on the given entity/entities.
578
- */
579
- recalc(entity: EntityW): Promise<void>;
580
- recalc(entities: EntityW[]): Promise<void>;
581
- beforeBegin(fn: HookFn<TX>): void;
582
- afterBegin(fn: HookFn<TX>): void;
583
- beforeCommit(fn: HookFn<TX>): void;
584
- afterCommit(fn: HookFn<TX>): void;
585
- /**
586
- * Returns an EntityManager-scoped (i.e. request scoped) data loader.
587
- *
588
- * @param operation the operation being batched, i.e. `load` or `o2m-load`, to avoid clashing batch keys
589
- * across fundamentally different operations
590
- * @param batchKey for a given operation, i.e. `load`, a batch key `Author` to batch all Author loads together
591
- * @param fn the batch load function, i.e. that will accept all `.load(...)`-d Author ids to load as a single db call
592
- * @param opts optional DataLoader options
593
- * @returns a DataLoader scoped to the `operation` + `batchKey` combination
594
- */
595
- getLoader<K, V>(operation: string, batchKey: string, fn: BatchLoadFn<K, V>, opts?: Options<K, V>): DataLoader<K, V>;
596
- toString(): string;
597
- /** Recursively cascades any pending deletions. */
598
- private flushDeletes;
599
- setReactionLogging(logger: ReactionLogger): void;
600
- setReactionLogging(enabled: boolean): void;
601
- /** Accepts `Author` or `Author.firstName,lastName` or `Author.lastName!`. */
602
- setFieldLogging(spec: string): void;
603
- /** Accepts `["Author.firstName,lastName", "Book.title"]`. */
604
- setFieldLogging(spec: string[]): void;
605
- /** Sets this EntityManager's field logger. */
606
- setFieldLogging(logger: FieldLogger): void;
607
- /** Enables/disables field logging for all fields. */
608
- setFieldLogging(enabled: boolean): void;
609
- [Symbol.asyncDispose](): Promise<void>;
610
- /** Returns entities matching the filter using indexed search when available. */
611
- filterEntities<T extends Entity>(cstr: EntityConstructor<T>, where: Partial<OptsOf<T>>): T[];
612
- /**
613
- * Creates a new EntityManager that shares the same entities as the current one but allows independent changes.
614
- *
615
- * This is useful for scenarios where you want to:
616
- *
617
- * - Preload data for use as a cache
618
- * - Make speculative changes that may or may not be committed
619
- * - Escape a transaction scope
620
- *
621
- * The fork will:
622
- *
623
- * - Copy all currently loaded entities to the new EntityManager
624
- * - Copy any loaded relation data to keep `.isLoaded` / `.get` state consistent
625
- * - Copy and update references to the EntityManager and its entities in the context, which is itself shallowly copied
626
- *
627
- * The fork will NOT:
628
- *
629
- * - Copy any pending changes (must call .flush() first)
630
- * - Share any changes made in either EntityManager with the other
631
- *
632
- * @param opts options to control the fork behavior
633
- * - allowPendingChanges - allows the em being forked to have pending changes and forces the resulting em to have
634
- * `mode` set to "in-memory-writes". Changes to entities in the original em will be copied to the resulting em.
635
- * Optional. default: false
636
- *
637
- * @throws {Error} If called on an EntityManager with pending changes
638
- * @returns A new EntityManager with copied entity state
639
- */
640
- fork(opts?: {
641
- allowPendingChanges?: boolean;
642
- }): EntityManager<C, Entity, TX>;
643
- /**
644
- * Copies an entity from one EntityManager to another, ensuring all relations specified in the hint are
645
- * also copied.
646
- *
647
- * This method is primarily used when you need to move entities between different EntityManager instances
648
- * while preserving their loaded state and relationships. This is useful for scenarios like:
649
- *
650
- * - Moving entities between transaction boundaries
651
- * - Creating test fixtures that reference entities from a different EntityManager
652
- * - Sharing entities between different parts of your application
653
- *
654
- * The migration process:
655
- * 1. If the entity already exists in this EntityManager, returns it
656
- * 2. Otherwise, creates a new instance with the same data
657
- * 3. Recursively migrates any loaded relations specified in the hint
658
- *
659
- * @param source - The entity to migrate from another EntityManager
660
- * @param hint - The load hint specifying which relations to migrate
661
- * @returns The migrated entity with all specified relations loaded
662
- */
663
- importEntity<T extends Entity>(original: T): T;
664
- importEntity<T extends Entity, H extends LoadHint<T>, L extends Loaded<T, H>>(original: L, hint: H): L;
665
- addPlugin(plugin: Plugin): void;
666
- getPlugins(): readonly Plugin[];
667
- get isRefreshing(): boolean;
668
- get isFlushing(): boolean;
669
- }
670
- /** Provides an internal API to the `EntityManager`. */
671
- export interface EntityManagerInternalApi {
672
- joinRows: (m2m: ManyToManyLike) => JoinRows;
673
- /** Map of taggedId -> fieldName -> pending children. */
674
- pendingChildren: Map<string, Map<string, {
675
- adds: Entity[];
676
- removes: Entity[];
677
- }>>;
678
- /** List of mutated o2m collections to reset added/removed post-flush. */
679
- mutatedCollections: Set<OneToManyCollection<any, any>>;
680
- /** Map of taggedId -> fieldName -> join-loaded data. */
681
- getPreloadedRelation<U>(taggedId: string, fieldName: string): U[] | undefined;
682
- setPreloadedRelation<U>(taggedId: string, fieldName: string, children: U[]): void;
683
- hooks: Record<EntityManagerHook, HookFn<any>[]>;
684
- rm: ReactionsManager;
685
- indexManager: IndexManager;
686
- preloader: PreloadPlugin | undefined;
687
- isValidating: boolean;
688
- checkWritesAllowed: () => void;
689
- isMerging: (entity: Entity) => boolean;
690
- get fieldLogger(): FieldLogger | undefined;
691
- get isLoadedCache(): IsLoadedCache;
692
- pluginManager: PluginManager;
693
- clearDataloaders(): void;
694
- clearPreloadedRelations(): void;
695
- setIsRefreshing(isRefreshing: boolean): void;
696
- }
697
- export declare function getEmInternalApi(em: EntityManager): EntityManagerInternalApi;
698
- export declare function getDefaultEntityLimit(): number;
699
- export declare function setDefaultEntityLimit(limit: number): void;
700
- export declare function resetDefaultEntityLimit(): void;
701
- export declare function isKey(k: any): k is string;
702
- /** Compares `a` to `b`, where `b` might be an id. */
703
- export declare function sameEntity(a: Entity | string | number | undefined, b: Entity | string | number | undefined): boolean;
704
- /** Compares the value `a` to `b`, with handling of new entities w/o ids assigned yet. */
705
- export declare function sameReference<T extends Entity>(a: Reference<any, T, any>, b: Reference<any, T, any>): boolean;
706
- /** Thrown by `findOneOrFail`, 'load' & 'loadAll' if an entity is not found. */
707
- export declare class NotFoundError extends Error {
708
- }
709
- /** Thrown by `findOne` and `findOneOrFail` if more than one entity is found. */
710
- export declare class TooManyError extends Error {
711
- constructor(message: string);
712
- }
713
- export declare function driverBeforeBegin<TXN>(em: EntityManager<any, any, TXN>, txn: TXN): Promise<unknown>;
714
- export declare function driverAfterBegin<TXN>(em: EntityManager<any, any, TXN>, txn: TXN): Promise<unknown>;
715
- export declare function driverBeforeCommit<TXN>(em: EntityManager<any, any, TXN>, txn: TXN): Promise<unknown>;
716
- export declare function driverAfterCommit<TXN>(em: EntityManager<any, any, TXN>, txn: TXN): Promise<unknown>;
717
- export declare function isDefined<T extends any>(param: T | undefined | null): param is T;
718
- export declare function setLastNow(now: Date | undefined): void;
719
- /** An error thrown when `em.mode === "read-only"` but entities are mutated/flushed. */
720
- export declare class ReadOnlyError extends Error {
721
- constructor();
722
- }
723
- /**
724
- * Given an `err` thrown in "a different context", i.e. a database error or dataloader error
725
- * that doesn't include our stack trace, append our stack for better debugging.
726
- *
727
- * See https://github.com/brianc/node-postgres/pull/2983
728
- */
729
- export declare function appendStack(err: unknown, dummy: Error): unknown;
730
- export declare function createRowFromEntityData(e: Entity, opts?: {
731
- preferOriginalData?: boolean;
732
- }): Record<string, any>;
733
- export {};
734
- //# sourceMappingURL=EntityManager.d.ts.map