@expo/entity 0.41.0 → 0.42.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 (430) hide show
  1. package/build/AuthorizationResultBasedEntityAssociationLoader.d.ts +16 -16
  2. package/build/AuthorizationResultBasedEntityAssociationLoader.js.map +1 -1
  3. package/build/AuthorizationResultBasedEntityLoader.d.ts +39 -67
  4. package/build/AuthorizationResultBasedEntityLoader.js +85 -62
  5. package/build/AuthorizationResultBasedEntityLoader.js.map +1 -1
  6. package/build/AuthorizationResultBasedEntityMutator.d.ts +16 -16
  7. package/build/AuthorizationResultBasedEntityMutator.js.map +1 -1
  8. package/build/ComposedEntityCacheAdapter.d.ts +7 -6
  9. package/build/ComposedEntityCacheAdapter.js +28 -28
  10. package/build/ComposedEntityCacheAdapter.js.map +1 -1
  11. package/build/ComposedSecondaryEntityCache.d.ts +1 -1
  12. package/build/ComposedSecondaryEntityCache.js.map +1 -1
  13. package/build/EnforcingEntityAssociationLoader.d.ts +15 -15
  14. package/build/EnforcingEntityAssociationLoader.js.map +1 -1
  15. package/build/EnforcingEntityCreator.d.ts +2 -2
  16. package/build/EnforcingEntityDeleter.d.ts +2 -2
  17. package/build/EnforcingEntityLoader.d.ts +104 -18
  18. package/build/EnforcingEntityLoader.js +113 -12
  19. package/build/EnforcingEntityLoader.js.map +1 -1
  20. package/build/EnforcingEntityUpdater.d.ts +2 -2
  21. package/build/Entity.d.ts +10 -10
  22. package/build/Entity.js.map +1 -1
  23. package/build/EntityAssociationLoader.d.ts +3 -3
  24. package/build/EntityCompanion.d.ts +5 -5
  25. package/build/EntityCompanion.js.map +1 -1
  26. package/build/EntityCompanionProvider.d.ts +6 -6
  27. package/build/EntityCompanionProvider.js.map +1 -1
  28. package/build/EntityConfiguration.d.ts +46 -5
  29. package/build/EntityConfiguration.js +39 -1
  30. package/build/EntityConfiguration.js.map +1 -1
  31. package/build/EntityCreator.d.ts +4 -4
  32. package/build/EntityDatabaseAdapter.d.ts +15 -14
  33. package/build/EntityDatabaseAdapter.js +20 -12
  34. package/build/EntityDatabaseAdapter.js.map +1 -1
  35. package/build/EntityDeleter.d.ts +4 -4
  36. package/build/EntityFieldDefinition.d.ts +20 -10
  37. package/build/EntityFieldDefinition.js +3 -1
  38. package/build/EntityFieldDefinition.js.map +1 -1
  39. package/build/EntityFields.d.ts +14 -12
  40. package/build/EntityFields.js.map +1 -1
  41. package/build/EntityLoader.d.ts +5 -5
  42. package/build/EntityLoaderFactory.d.ts +3 -3
  43. package/build/EntityLoaderFactory.js.map +1 -1
  44. package/build/EntityLoaderUtils.d.ts +2 -2
  45. package/build/EntityLoaderUtils.js +27 -1
  46. package/build/EntityLoaderUtils.js.map +1 -1
  47. package/build/EntityMutationInfo.d.ts +2 -2
  48. package/build/EntityMutationTriggerConfiguration.d.ts +14 -14
  49. package/build/EntityMutationTriggerConfiguration.js.map +1 -1
  50. package/build/EntityMutationValidator.d.ts +2 -2
  51. package/build/EntityMutatorFactory.d.ts +5 -5
  52. package/build/EntityMutatorFactory.js.map +1 -1
  53. package/build/EntityPrivacyPolicy.d.ts +14 -14
  54. package/build/EntityPrivacyPolicy.js.map +1 -1
  55. package/build/EntitySecondaryCacheLoader.d.ts +4 -4
  56. package/build/EntityUpdater.d.ts +4 -4
  57. package/build/GenericEntityCacheAdapter.d.ts +7 -6
  58. package/build/GenericEntityCacheAdapter.js +13 -14
  59. package/build/GenericEntityCacheAdapter.js.map +1 -1
  60. package/build/GenericSecondaryEntityCache.d.ts +3 -3
  61. package/build/GenericSecondaryEntityCache.js.map +1 -1
  62. package/build/IEntityCacheAdapter.d.ts +17 -16
  63. package/build/IEntityCacheAdapterProvider.d.ts +1 -1
  64. package/build/IEntityDatabaseAdapterProvider.d.ts +1 -1
  65. package/build/IEntityGenericCacher.d.ts +15 -5
  66. package/build/ReadonlyEntity.d.ts +8 -8
  67. package/build/ReadonlyEntity.js.map +1 -1
  68. package/build/ViewerContext.d.ts +1 -1
  69. package/build/ViewerScopedEntityCompanion.d.ts +5 -5
  70. package/build/ViewerScopedEntityCompanionProvider.d.ts +1 -1
  71. package/build/ViewerScopedEntityLoaderFactory.d.ts +3 -3
  72. package/build/ViewerScopedEntityMutatorFactory.d.ts +5 -5
  73. package/build/entityUtils.d.ts +1 -1
  74. package/build/entityUtils.js.map +1 -1
  75. package/build/errors/EntityInvalidFieldValueError.d.ts +2 -2
  76. package/build/errors/EntityNotAuthorizedError.d.ts +1 -1
  77. package/build/errors/EntityNotFoundError.d.ts +2 -2
  78. package/build/index.d.ts +7 -7
  79. package/build/index.js +8 -13
  80. package/build/index.js.map +1 -1
  81. package/build/internal/CompositeFieldHolder.d.ts +48 -0
  82. package/build/internal/CompositeFieldHolder.js +116 -0
  83. package/build/internal/CompositeFieldHolder.js.map +1 -0
  84. package/build/internal/CompositeFieldValueMap.d.ts +15 -0
  85. package/build/internal/CompositeFieldValueMap.js +51 -0
  86. package/build/internal/CompositeFieldValueMap.js.map +1 -0
  87. package/build/internal/EntityDataManager.d.ts +16 -16
  88. package/build/internal/EntityDataManager.js +42 -45
  89. package/build/internal/EntityDataManager.js.map +1 -1
  90. package/build/internal/EntityFieldTransformationUtils.d.ts +5 -5
  91. package/build/internal/EntityFieldTransformationUtils.js.map +1 -1
  92. package/build/internal/EntityLoadInterfaces.d.ts +104 -0
  93. package/build/internal/EntityLoadInterfaces.js +25 -0
  94. package/build/internal/EntityLoadInterfaces.js.map +1 -0
  95. package/build/internal/EntityTableDataCoordinator.d.ts +6 -6
  96. package/build/internal/EntityTableDataCoordinator.js.map +1 -1
  97. package/build/internal/ReadThroughEntityCache.d.ts +17 -16
  98. package/build/internal/ReadThroughEntityCache.js +36 -36
  99. package/build/internal/ReadThroughEntityCache.js.map +1 -1
  100. package/build/internal/SingleFieldHolder.d.ts +34 -0
  101. package/build/internal/SingleFieldHolder.js +90 -0
  102. package/build/internal/SingleFieldHolder.js.map +1 -0
  103. package/build/metrics/EntityMetricsUtils.d.ts +2 -1
  104. package/build/metrics/EntityMetricsUtils.js.map +1 -1
  105. package/build/metrics/IEntityMetricsAdapter.d.ts +5 -0
  106. package/build/metrics/IEntityMetricsAdapter.js.map +1 -1
  107. package/build/rules/AlwaysAllowPrivacyPolicyRule.d.ts +2 -2
  108. package/build/rules/AlwaysAllowPrivacyPolicyRule.js.map +1 -1
  109. package/build/rules/AlwaysDenyPrivacyPolicyRule.d.ts +2 -2
  110. package/build/rules/AlwaysDenyPrivacyPolicyRule.js.map +1 -1
  111. package/build/rules/AlwaysSkipPrivacyPolicyRule.d.ts +2 -2
  112. package/build/rules/AlwaysSkipPrivacyPolicyRule.js.map +1 -1
  113. package/build/rules/PrivacyPolicyRule.d.ts +2 -2
  114. package/build/tsconfig.build.tsbuildinfo +1 -0
  115. package/build/utils/EntityPrivacyUtils.d.ts +4 -4
  116. package/build/utils/EntityPrivacyUtils.js.map +1 -1
  117. package/build/utils/collections/SerializableKeyMap.d.ts +27 -0
  118. package/build/utils/collections/SerializableKeyMap.js +60 -0
  119. package/build/utils/collections/SerializableKeyMap.js.map +1 -0
  120. package/build/utils/collections/maps.js +1 -2
  121. package/build/utils/collections/maps.js.map +1 -1
  122. package/build/utils/collections/sets.d.ts +1 -0
  123. package/build/utils/collections/sets.js +7 -0
  124. package/build/utils/collections/sets.js.map +1 -0
  125. package/build/utils/mergeEntityMutationTriggerConfigurations.d.ts +1 -1
  126. package/package.json +8 -5
  127. package/src/AuthorizationResultBasedEntityAssociationLoader.ts +56 -49
  128. package/src/AuthorizationResultBasedEntityLoader.ts +194 -81
  129. package/src/AuthorizationResultBasedEntityMutator.ts +71 -45
  130. package/src/ComposedEntityCacheAdapter.ts +55 -46
  131. package/src/ComposedSecondaryEntityCache.ts +5 -2
  132. package/src/EnforcingEntityAssociationLoader.ts +52 -44
  133. package/src/EnforcingEntityCreator.ts +5 -5
  134. package/src/EnforcingEntityDeleter.ts +5 -5
  135. package/src/EnforcingEntityLoader.ts +158 -21
  136. package/src/EnforcingEntityUpdater.ts +5 -5
  137. package/src/Entity.ts +39 -39
  138. package/src/EntityAssociationLoader.ts +6 -6
  139. package/src/EntityCompanion.ts +11 -11
  140. package/src/EntityCompanionProvider.ts +21 -18
  141. package/src/EntityConfiguration.ts +123 -9
  142. package/src/EntityCreator.ts +7 -7
  143. package/src/EntityDatabaseAdapter.ts +51 -28
  144. package/src/EntityDeleter.ts +7 -7
  145. package/src/EntityFieldDefinition.ts +32 -12
  146. package/src/EntityFields.ts +49 -12
  147. package/src/EntityLoader.ts +8 -8
  148. package/src/EntityLoaderFactory.ts +8 -8
  149. package/src/EntityLoaderUtils.ts +39 -10
  150. package/src/EntityMutationInfo.ts +6 -6
  151. package/src/EntityMutationTriggerConfiguration.ts +68 -20
  152. package/src/EntityMutationValidator.ts +4 -4
  153. package/src/EntityMutatorFactory.ts +13 -13
  154. package/src/EntityPrivacyPolicy.ts +50 -26
  155. package/src/EntitySecondaryCacheLoader.ts +6 -6
  156. package/src/EntityUpdater.ts +7 -7
  157. package/src/GenericEntityCacheAdapter.ts +39 -28
  158. package/src/GenericSecondaryEntityCache.ts +6 -3
  159. package/src/IEntityCacheAdapter.ts +45 -25
  160. package/src/IEntityCacheAdapterProvider.ts +3 -3
  161. package/src/IEntityDatabaseAdapterProvider.ts +3 -3
  162. package/src/IEntityGenericCacher.ts +33 -5
  163. package/src/ReadonlyEntity.ts +24 -24
  164. package/src/ViewerContext.ts +5 -5
  165. package/src/ViewerScopedEntityCompanion.ts +7 -7
  166. package/src/ViewerScopedEntityCompanionProvider.ts +6 -6
  167. package/src/ViewerScopedEntityLoaderFactory.ts +7 -7
  168. package/src/ViewerScopedEntityMutatorFactory.ts +8 -8
  169. package/src/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.ts +4 -4
  170. package/src/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.ts +14 -13
  171. package/src/__tests__/AuthorizationResultBasedEntityLoader-test.ts +367 -69
  172. package/src/__tests__/ComposedCacheAdapter-test.ts +235 -117
  173. package/src/__tests__/EnforcingEntityLoader-test.ts +135 -1
  174. package/src/__tests__/Entity-test.ts +2 -2
  175. package/src/__tests__/EntityAssociationLoader-test.ts +2 -2
  176. package/src/__tests__/EntityCommonUseCases-test.ts +11 -11
  177. package/src/__tests__/EntityCompanion-test.ts +4 -4
  178. package/src/__tests__/EntityCompanionProvider-test.ts +9 -8
  179. package/src/__tests__/EntityConfiguration-test.ts +85 -6
  180. package/src/__tests__/EntityDatabaseAdapter-test.ts +113 -17
  181. package/src/__tests__/EntityEdges-test.ts +97 -72
  182. package/src/__tests__/EntityFields-test.ts +2 -2
  183. package/src/__tests__/EntityLoader-test.ts +2 -2
  184. package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +11 -11
  185. package/src/__tests__/EntityMutator-SingleCompositeFieldCacheConsistency-test.ts +73 -0
  186. package/src/__tests__/EntityMutator-test.ts +74 -46
  187. package/src/__tests__/EntityPrivacyPolicy-test.ts +51 -74
  188. package/src/__tests__/EntityQueryContext-test.ts +1 -1
  189. package/src/__tests__/EntitySecondaryCacheLoader-test.ts +3 -3
  190. package/src/__tests__/EntitySelfReferentialEdges-test.ts +64 -39
  191. package/src/__tests__/GenericEntityCacheAdapter-test.ts +83 -28
  192. package/src/__tests__/ReadonlyEntity-test.ts +3 -3
  193. package/src/__tests__/ViewerContext-test.ts +1 -1
  194. package/src/__tests__/ViewerScopedEntityCompanion-test.ts +5 -2
  195. package/src/__tests__/ViewerScopedEntityCompanionProvider-test.ts +1 -1
  196. package/src/__tests__/ViewerScopedEntityMutatorFactory-test.ts +12 -3
  197. package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +12 -12
  198. package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +12 -12
  199. package/src/entityUtils.ts +4 -1
  200. package/src/errors/EntityInvalidFieldValueError.ts +5 -5
  201. package/src/errors/EntityNotAuthorizedError.ts +3 -3
  202. package/src/errors/EntityNotFoundError.ts +5 -5
  203. package/src/index.ts +7 -7
  204. package/src/internal/CompositeFieldHolder.ts +218 -0
  205. package/src/internal/CompositeFieldValueMap.ts +78 -0
  206. package/src/internal/EntityDataManager.ts +107 -96
  207. package/src/internal/EntityFieldTransformationUtils.ts +33 -14
  208. package/src/internal/EntityLoadInterfaces.ts +143 -0
  209. package/src/internal/EntityTableDataCoordinator.ts +8 -5
  210. package/src/internal/ReadThroughEntityCache.ts +63 -50
  211. package/src/internal/SingleFieldHolder.ts +131 -0
  212. package/src/internal/__tests__/CompositeFieldHolder-test.ts +25 -0
  213. package/src/internal/__tests__/CompositeFieldValueMap-test.ts +43 -0
  214. package/src/internal/__tests__/EntityDataManager-test.ts +308 -91
  215. package/src/internal/__tests__/EntityFieldTransformationUtils-test.ts +3 -2
  216. package/src/internal/__tests__/ReadThroughEntityCache-test.ts +315 -107
  217. package/src/metrics/EntityMetricsUtils.ts +7 -2
  218. package/src/metrics/IEntityMetricsAdapter.ts +6 -0
  219. package/src/rules/AlwaysAllowPrivacyPolicyRule.ts +5 -5
  220. package/src/rules/AlwaysDenyPrivacyPolicyRule.ts +5 -5
  221. package/src/rules/AlwaysSkipPrivacyPolicyRule.ts +5 -5
  222. package/src/rules/PrivacyPolicyRule.ts +4 -4
  223. package/src/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.ts +1 -1
  224. package/src/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.ts +1 -1
  225. package/src/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.ts +1 -1
  226. package/src/utils/EntityPrivacyUtils.ts +72 -30
  227. package/src/utils/{testing → __testfixtures__}/PrivacyPolicyRuleTestUtils.ts +26 -26
  228. package/src/{testfixtures → utils/__testfixtures__}/SimpleTestEntity.ts +16 -15
  229. package/src/utils/__testfixtures__/StubCacheAdapter.ts +164 -0
  230. package/src/utils/{testing → __testfixtures__}/StubDatabaseAdapter.ts +19 -12
  231. package/src/utils/{testing → __testfixtures__}/StubDatabaseAdapterProvider.ts +4 -4
  232. package/src/utils/__testfixtures__/TSMockitoExtensions.ts +69 -0
  233. package/src/{testfixtures → utils/__testfixtures__}/TestEntity.ts +21 -15
  234. package/src/{testfixtures → utils/__testfixtures__}/TestEntity2.ts +16 -15
  235. package/src/{testfixtures → utils/__testfixtures__}/TestEntityWithMutationTriggers.ts +23 -22
  236. package/src/{testfixtures → utils/__testfixtures__}/TestViewerContext.ts +1 -1
  237. package/src/utils/{testing → __testfixtures__}/describeFieldTestCase.ts +1 -1
  238. package/src/utils/__tests__/EntityPrivacyUtils-test.ts +62 -66
  239. package/src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.ts +29 -25
  240. package/src/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.ts +1 -1
  241. package/src/utils/collections/SerializableKeyMap.ts +84 -0
  242. package/src/utils/collections/__tests__/SerializableKeyMap-test.ts +119 -0
  243. package/src/utils/collections/__tests__/sets-test.ts +17 -0
  244. package/src/utils/collections/maps.ts +7 -8
  245. package/src/utils/collections/sets.ts +3 -0
  246. package/src/utils/mergeEntityMutationTriggerConfigurations.ts +5 -5
  247. package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.d.ts +0 -1
  248. package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js +0 -242
  249. package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js.map +0 -1
  250. package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.d.ts +0 -26
  251. package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.js +0 -110
  252. package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.js.map +0 -1
  253. package/build/__tests__/AuthorizationResultBasedEntityLoader-test.d.ts +0 -1
  254. package/build/__tests__/AuthorizationResultBasedEntityLoader-test.js +0 -401
  255. package/build/__tests__/AuthorizationResultBasedEntityLoader-test.js.map +0 -1
  256. package/build/__tests__/ComposedCacheAdapter-test.d.ts +0 -1
  257. package/build/__tests__/ComposedCacheAdapter-test.js +0 -229
  258. package/build/__tests__/ComposedCacheAdapter-test.js.map +0 -1
  259. package/build/__tests__/ComposedSecondaryEntityCache-test.d.ts +0 -1
  260. package/build/__tests__/ComposedSecondaryEntityCache-test.js +0 -66
  261. package/build/__tests__/ComposedSecondaryEntityCache-test.js.map +0 -1
  262. package/build/__tests__/EnforcingEntityAssociationLoader-test.d.ts +0 -1
  263. package/build/__tests__/EnforcingEntityAssociationLoader-test.js +0 -115
  264. package/build/__tests__/EnforcingEntityAssociationLoader-test.js.map +0 -1
  265. package/build/__tests__/EnforcingEntityLoader-test.d.ts +0 -1
  266. package/build/__tests__/EnforcingEntityLoader-test.js +0 -253
  267. package/build/__tests__/EnforcingEntityLoader-test.js.map +0 -1
  268. package/build/__tests__/Entity-test.d.ts +0 -1
  269. package/build/__tests__/Entity-test.js +0 -94
  270. package/build/__tests__/Entity-test.js.map +0 -1
  271. package/build/__tests__/EntityAssociationLoader-test.d.ts +0 -1
  272. package/build/__tests__/EntityAssociationLoader-test.js +0 -30
  273. package/build/__tests__/EntityAssociationLoader-test.js.map +0 -1
  274. package/build/__tests__/EntityCommonUseCases-test.d.ts +0 -1
  275. package/build/__tests__/EntityCommonUseCases-test.js +0 -146
  276. package/build/__tests__/EntityCommonUseCases-test.js.map +0 -1
  277. package/build/__tests__/EntityCompanion-test.d.ts +0 -1
  278. package/build/__tests__/EntityCompanion-test.js +0 -77
  279. package/build/__tests__/EntityCompanion-test.js.map +0 -1
  280. package/build/__tests__/EntityCompanionProvider-test.d.ts +0 -1
  281. package/build/__tests__/EntityCompanionProvider-test.js +0 -54
  282. package/build/__tests__/EntityCompanionProvider-test.js.map +0 -1
  283. package/build/__tests__/EntityConfiguration-test.d.ts +0 -1
  284. package/build/__tests__/EntityConfiguration-test.js +0 -103
  285. package/build/__tests__/EntityConfiguration-test.js.map +0 -1
  286. package/build/__tests__/EntityDatabaseAdapter-test.d.ts +0 -1
  287. package/build/__tests__/EntityDatabaseAdapter-test.js +0 -146
  288. package/build/__tests__/EntityDatabaseAdapter-test.js.map +0 -1
  289. package/build/__tests__/EntityEdges-test.d.ts +0 -1
  290. package/build/__tests__/EntityEdges-test.js +0 -723
  291. package/build/__tests__/EntityEdges-test.js.map +0 -1
  292. package/build/__tests__/EntityFields-test.d.ts +0 -1
  293. package/build/__tests__/EntityFields-test.js +0 -63
  294. package/build/__tests__/EntityFields-test.js.map +0 -1
  295. package/build/__tests__/EntityLoader-test.d.ts +0 -1
  296. package/build/__tests__/EntityLoader-test.js +0 -36
  297. package/build/__tests__/EntityLoader-test.js.map +0 -1
  298. package/build/__tests__/EntityMutator-MutationCacheConsistency-test.d.ts +0 -1
  299. package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +0 -73
  300. package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +0 -1
  301. package/build/__tests__/EntityMutator-test.d.ts +0 -1
  302. package/build/__tests__/EntityMutator-test.js +0 -741
  303. package/build/__tests__/EntityMutator-test.js.map +0 -1
  304. package/build/__tests__/EntityPrivacyPolicy-test.d.ts +0 -1
  305. package/build/__tests__/EntityPrivacyPolicy-test.js +0 -463
  306. package/build/__tests__/EntityPrivacyPolicy-test.js.map +0 -1
  307. package/build/__tests__/EntityQueryContext-test.d.ts +0 -1
  308. package/build/__tests__/EntityQueryContext-test.js +0 -116
  309. package/build/__tests__/EntityQueryContext-test.js.map +0 -1
  310. package/build/__tests__/EntitySecondaryCacheLoader-test.d.ts +0 -1
  311. package/build/__tests__/EntitySecondaryCacheLoader-test.js +0 -60
  312. package/build/__tests__/EntitySecondaryCacheLoader-test.js.map +0 -1
  313. package/build/__tests__/EntitySelfReferentialEdges-test.d.ts +0 -1
  314. package/build/__tests__/EntitySelfReferentialEdges-test.js +0 -201
  315. package/build/__tests__/EntitySelfReferentialEdges-test.js.map +0 -1
  316. package/build/__tests__/GenericEntityCacheAdapter-test.d.ts +0 -1
  317. package/build/__tests__/GenericEntityCacheAdapter-test.js +0 -80
  318. package/build/__tests__/GenericEntityCacheAdapter-test.js.map +0 -1
  319. package/build/__tests__/ReadonlyEntity-test.d.ts +0 -1
  320. package/build/__tests__/ReadonlyEntity-test.js +0 -211
  321. package/build/__tests__/ReadonlyEntity-test.js.map +0 -1
  322. package/build/__tests__/ViewerContext-test.d.ts +0 -1
  323. package/build/__tests__/ViewerContext-test.js +0 -30
  324. package/build/__tests__/ViewerContext-test.js.map +0 -1
  325. package/build/__tests__/ViewerScopedEntityCompanion-test.d.ts +0 -1
  326. package/build/__tests__/ViewerScopedEntityCompanion-test.js +0 -20
  327. package/build/__tests__/ViewerScopedEntityCompanion-test.js.map +0 -1
  328. package/build/__tests__/ViewerScopedEntityCompanionProvider-test.d.ts +0 -1
  329. package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js +0 -20
  330. package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js.map +0 -1
  331. package/build/__tests__/ViewerScopedEntityLoaderFactory-test.d.ts +0 -1
  332. package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js +0 -23
  333. package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js.map +0 -1
  334. package/build/__tests__/ViewerScopedEntityMutatorFactory-test.d.ts +0 -1
  335. package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js +0 -22
  336. package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js.map +0 -1
  337. package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.d.ts +0 -1
  338. package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +0 -123
  339. package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +0 -1
  340. package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.d.ts +0 -1
  341. package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +0 -121
  342. package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +0 -1
  343. package/build/__tests__/entityUtils-test.d.ts +0 -1
  344. package/build/__tests__/entityUtils-test.js +0 -87
  345. package/build/__tests__/entityUtils-test.js.map +0 -1
  346. package/build/internal/__tests__/EntityDataManager-test.d.ts +0 -1
  347. package/build/internal/__tests__/EntityDataManager-test.js +0 -373
  348. package/build/internal/__tests__/EntityDataManager-test.js.map +0 -1
  349. package/build/internal/__tests__/EntityFieldTransformationUtils-test.d.ts +0 -1
  350. package/build/internal/__tests__/EntityFieldTransformationUtils-test.js +0 -136
  351. package/build/internal/__tests__/EntityFieldTransformationUtils-test.js.map +0 -1
  352. package/build/internal/__tests__/ReadThroughEntityCache-test.d.ts +0 -1
  353. package/build/internal/__tests__/ReadThroughEntityCache-test.js +0 -206
  354. package/build/internal/__tests__/ReadThroughEntityCache-test.js.map +0 -1
  355. package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.d.ts +0 -1
  356. package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js +0 -21
  357. package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js.map +0 -1
  358. package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.d.ts +0 -1
  359. package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js +0 -21
  360. package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js.map +0 -1
  361. package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.d.ts +0 -1
  362. package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js +0 -21
  363. package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js.map +0 -1
  364. package/build/testfixtures/DateIDTestEntity.d.ts +0 -19
  365. package/build/testfixtures/DateIDTestEntity.js +0 -48
  366. package/build/testfixtures/DateIDTestEntity.js.map +0 -1
  367. package/build/testfixtures/SimpleTestEntity.d.ts +0 -20
  368. package/build/testfixtures/SimpleTestEntity.js +0 -48
  369. package/build/testfixtures/SimpleTestEntity.js.map +0 -1
  370. package/build/testfixtures/TestEntity.d.ts +0 -30
  371. package/build/testfixtures/TestEntity.js +0 -93
  372. package/build/testfixtures/TestEntity.js.map +0 -1
  373. package/build/testfixtures/TestEntity2.d.ts +0 -20
  374. package/build/testfixtures/TestEntity2.js +0 -51
  375. package/build/testfixtures/TestEntity2.js.map +0 -1
  376. package/build/testfixtures/TestEntityNumberKey.d.ts +0 -19
  377. package/build/testfixtures/TestEntityNumberKey.js +0 -48
  378. package/build/testfixtures/TestEntityNumberKey.js.map +0 -1
  379. package/build/testfixtures/TestEntityWithMutationTriggers.d.ts +0 -36
  380. package/build/testfixtures/TestEntityWithMutationTriggers.js +0 -82
  381. package/build/testfixtures/TestEntityWithMutationTriggers.js.map +0 -1
  382. package/build/testfixtures/TestViewerContext.d.ts +0 -3
  383. package/build/testfixtures/TestViewerContext.js +0 -10
  384. package/build/testfixtures/TestViewerContext.js.map +0 -1
  385. package/build/utils/__tests__/EntityPrivacyUtils-test.d.ts +0 -1
  386. package/build/utils/__tests__/EntityPrivacyUtils-test.js +0 -486
  387. package/build/utils/__tests__/EntityPrivacyUtils-test.js.map +0 -1
  388. package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.d.ts +0 -1
  389. package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js +0 -178
  390. package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js.map +0 -1
  391. package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.d.ts +0 -1
  392. package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js +0 -26
  393. package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js.map +0 -1
  394. package/build/utils/collections/__tests__/maps-test.d.ts +0 -1
  395. package/build/utils/collections/__tests__/maps-test.js +0 -120
  396. package/build/utils/collections/__tests__/maps-test.js.map +0 -1
  397. package/build/utils/testing/PrivacyPolicyRuleTestUtils.d.ts +0 -28
  398. package/build/utils/testing/PrivacyPolicyRuleTestUtils.js +0 -52
  399. package/build/utils/testing/PrivacyPolicyRuleTestUtils.js.map +0 -1
  400. package/build/utils/testing/StubCacheAdapter.d.ts +0 -27
  401. package/build/utils/testing/StubCacheAdapter.js +0 -86
  402. package/build/utils/testing/StubCacheAdapter.js.map +0 -1
  403. package/build/utils/testing/StubDatabaseAdapter.d.ts +0 -25
  404. package/build/utils/testing/StubDatabaseAdapter.js +0 -191
  405. package/build/utils/testing/StubDatabaseAdapter.js.map +0 -1
  406. package/build/utils/testing/StubDatabaseAdapterProvider.d.ts +0 -7
  407. package/build/utils/testing/StubDatabaseAdapterProvider.js +0 -14
  408. package/build/utils/testing/StubDatabaseAdapterProvider.js.map +0 -1
  409. package/build/utils/testing/StubQueryContextProvider.d.ts +0 -7
  410. package/build/utils/testing/StubQueryContextProvider.js +0 -19
  411. package/build/utils/testing/StubQueryContextProvider.js.map +0 -1
  412. package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.d.ts +0 -1
  413. package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js +0 -42
  414. package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js.map +0 -1
  415. package/build/utils/testing/__tests__/StubDatabaseAdapter-test.d.ts +0 -1
  416. package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js +0 -402
  417. package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js.map +0 -1
  418. package/build/utils/testing/createUnitTestEntityCompanionProvider.d.ts +0 -7
  419. package/build/utils/testing/createUnitTestEntityCompanionProvider.js +0 -36
  420. package/build/utils/testing/createUnitTestEntityCompanionProvider.js.map +0 -1
  421. package/build/utils/testing/describeFieldTestCase.d.ts +0 -2
  422. package/build/utils/testing/describeFieldTestCase.js +0 -18
  423. package/build/utils/testing/describeFieldTestCase.js.map +0 -1
  424. package/src/testfixtures/DateIDTestEntity.ts +0 -59
  425. package/src/testfixtures/TestEntityNumberKey.ts +0 -59
  426. package/src/utils/testing/StubCacheAdapter.ts +0 -122
  427. package/src/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.ts +0 -42
  428. package/src/utils/testing/__tests__/StubDatabaseAdapter-test.ts +0 -548
  429. /package/src/utils/{testing → __testfixtures__}/StubQueryContextProvider.ts +0 -0
  430. /package/src/utils/{testing → __testfixtures__}/createUnitTestEntityCompanionProvider.ts +0 -0
@@ -1,4 +1,5 @@
1
1
  import AuthorizationResultBasedEntityLoader from './AuthorizationResultBasedEntityLoader';
2
+ import { EntityCompositeField, EntityCompositeFieldValue } from './EntityConfiguration';
2
3
  import { FieldEqualityCondition, QuerySelectionModifiers, QuerySelectionModifiersWithOrderByRaw } from './EntityDatabaseAdapter';
3
4
  import EntityPrivacyPolicy from './EntityPrivacyPolicy';
4
5
  import ReadonlyEntity from './ReadonlyEntity';
@@ -8,59 +9,144 @@ import ViewerContext from './ViewerContext';
8
9
  * cached, and authorized against the entity's EntityPrivacyPolicy. All loads
9
10
  * through this loader will throw if the load is not successful.
10
11
  */
11
- export default class EnforcingEntityLoader<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
12
+ export default class EnforcingEntityLoader<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
12
13
  private readonly entityLoader;
13
- constructor(entityLoader: AuthorizationResultBasedEntityLoader<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>);
14
+ constructor(entityLoader: AuthorizationResultBasedEntityLoader<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>);
14
15
  /**
15
- * Enforcing version of entity loader method by the same name.
16
+ * Load many entities where fieldName is one of fieldValues.
17
+ * @param fieldName - entity field being queried
18
+ * @param fieldValues - fieldName field values being queried
19
+ * @returns map from fieldValue to entities that match the query for that fieldValue
16
20
  * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
17
21
  */
18
22
  loadManyByFieldEqualingManyAsync<N extends keyof Pick<TFields, TSelectedFields>>(fieldName: N, fieldValues: readonly NonNullable<TFields[N]>[]): Promise<ReadonlyMap<NonNullable<TFields[N]>, readonly TEntity[]>>;
19
23
  /**
20
- * Enforcing version of entity loader method by the same name.
24
+ * Load many entities where compositeField is one of compositeFieldValues.
25
+ * @param compositeField - composite field being queried
26
+ * @param compositeFieldValues - compositeField values being queried
27
+ * @returns map from compositeFieldValue to entities that match the query for that compositeFieldValue
28
+ * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
29
+ */
30
+ loadManyByCompositeFieldEqualingManyAsync<N extends EntityCompositeField<Pick<TFields, TSelectedFields>>>(compositeField: N, compositeFieldValues: readonly EntityCompositeFieldValue<Pick<TFields, TSelectedFields>, N>[]): Promise<ReadonlyMap<EntityCompositeFieldValue<TFields, N>, readonly TEntity[]>>;
31
+ /**
32
+ * Load many entities where fieldName equals fieldValue.
33
+ * @param fieldName - entity field being queried
34
+ * @param fieldValue - fieldName field value being queried
35
+ * @returns array of entities that match the query for fieldValue
21
36
  * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
22
37
  */
23
38
  loadManyByFieldEqualingAsync<N extends keyof Pick<TFields, TSelectedFields>>(fieldName: N, fieldValue: NonNullable<TFields[N]>): Promise<readonly TEntity[]>;
24
39
  /**
25
- * Enforcing version of entity loader method by the same name.
40
+ * Load many entities where compositeField equals compositeFieldValue.
41
+ * @param compositeField - composite field being queried
42
+ * @param compositeFieldValue - compositeField value being queried
43
+ * @returns array of entities that match the query for compositeFieldValue
44
+ * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
45
+ */
46
+ loadManyByCompositeFieldEqualingAsync<N extends EntityCompositeField<Pick<TFields, TSelectedFields>>>(compositeField: N, compositeFieldValue: EntityCompositeFieldValue<Pick<TFields, TSelectedFields>, N>): Promise<readonly TEntity[]>;
47
+ /**
48
+ * Load an entity where fieldName equals fieldValue, or null if no entity exists.
49
+ * @param uniqueFieldName - entity field being queried
50
+ * @param fieldValue - uniqueFieldName field value being queried
51
+ * @returns entity where uniqueFieldName equals fieldValue, or null if no entity matches the condition.
52
+ * @throws when multiple entities match the condition
26
53
  * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
27
- * @throws when multiple entities are found matching the condition
28
54
  */
29
55
  loadByFieldEqualingAsync<N extends keyof Pick<TFields, TSelectedFields>>(uniqueFieldName: N, fieldValue: NonNullable<TFields[N]>): Promise<TEntity | null>;
30
56
  /**
31
- * Enforcing version of entity loader method by the same name.
57
+ * Load an entity where compositeField equals compositeFieldValue, or null if no entity exists.
58
+ * @param compositeField - composite field being queried
59
+ * @param compositeFieldValue - compositeField value being queried
60
+ * @returns entity where compositeField equals compositeFieldValue, or null if no entity matches the condition.
61
+ * @throws when multiple entities match the condition
62
+ * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
63
+ */
64
+ loadByCompositeFieldEqualingAsync<N extends EntityCompositeField<Pick<TFields, TSelectedFields>>>(compositeField: N, compositeFieldValue: EntityCompositeFieldValue<Pick<TFields, TSelectedFields>, N>): Promise<TEntity | null>;
65
+ /**
66
+ * Loads an entity by a specified ID.
67
+ * @param id - ID of the entity
68
+ * @returns entity matching ID
32
69
  * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
70
+ * @throws EntityNotFoundError when no entity exists for ID
33
71
  */
34
- loadByIDAsync(id: TID): Promise<TEntity>;
72
+ loadByIDAsync(id: TFields[TIDField]): Promise<TEntity>;
35
73
  /**
36
- * Enforcing version of entity loader method by the same name.
74
+ * Load an entity by a specified ID, or return null if non-existent.
75
+ * @param id - ID of the entity
76
+ * @returns entity for matching ID, or null if no entity exists for ID.
37
77
  * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
38
78
  * @throws when multiple entities are found matching the condition
39
79
  */
40
- loadByIDNullableAsync(id: TID): Promise<TEntity | null>;
80
+ loadByIDNullableAsync(id: TFields[TIDField]): Promise<TEntity | null>;
41
81
  /**
42
- * Enforcing version of entity loader method by the same name.
82
+ * Loads many entities for a list of IDs.
83
+ * @param ids - IDs of the entities to load
84
+ * @returns map from ID to corresponding entity result, where result error can be UnauthorizedError or EntityNotFoundError.
43
85
  * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
86
+ * @throws EntityNotFoundError when no entity exists for one or more of the IDs
44
87
  */
45
- loadManyByIDsAsync(ids: readonly TID[]): Promise<ReadonlyMap<TID, TEntity>>;
88
+ loadManyByIDsAsync(ids: readonly TFields[TIDField][]): Promise<ReadonlyMap<TFields[TIDField], TEntity>>;
46
89
  /**
47
- * Enforcing version of entity loader method by the same name.
90
+ * Loads many entities for a list of IDs, returning null for any IDs that are non-existent.
91
+ * @param ids - IDs of the entities to load
92
+ * @returns map from ID to nullable corresponding entity
48
93
  * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
49
94
  */
50
- loadManyByIDsNullableAsync(ids: readonly TID[]): Promise<ReadonlyMap<TID, TEntity | null>>;
95
+ loadManyByIDsNullableAsync(ids: readonly TFields[TIDField][]): Promise<ReadonlyMap<TFields[TIDField], TEntity | null>>;
51
96
  /**
52
- * Enforcing version of entity loader method by the same name.
53
- * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
97
+ * Loads the first entity matching the selection constructed from the conjunction of specified
98
+ * operands, or null if no matching entity exists. Entities loaded using this method are not
99
+ * batched or cached.
100
+ *
101
+ * This is a convenience method for {@link loadManyByFieldEqualityConjunctionAsync}. However, the
102
+ * `orderBy` option must be specified to define what "first" means. If ordering doesn't matter,
103
+ * explicitly pass in an empty array.
104
+ *
105
+ * @param fieldEqualityOperands - list of field equality selection operand specifications
106
+ * @param querySelectionModifiers - orderBy and optional offset for the query
107
+ * @returns the first entity that matches the query or null if no entity matches the query
108
+ * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
54
109
  */
55
110
  loadFirstByFieldEqualityConjunctionAsync<N extends keyof Pick<TFields, TSelectedFields>>(fieldEqualityOperands: FieldEqualityCondition<TFields, N>[], querySelectionModifiers: Omit<QuerySelectionModifiers<TFields>, 'limit'> & Required<Pick<QuerySelectionModifiers<TFields>, 'orderBy'>>): Promise<TEntity | null>;
56
111
  /**
57
- * Enforcing version of entity loader method by the same name.
112
+ * Loads many entities matching the selection constructed from the conjunction of specified operands.
113
+ * Entities loaded using this method are not batched or cached.
114
+ *
115
+ * @example
116
+ * fieldEqualityOperands:
117
+ * `[{fieldName: 'hello', fieldValue: 1}, {fieldName: 'world', fieldValues: [2, 3]}]`
118
+ * Entities returned with a SQL EntityDatabaseAdapter:
119
+ * `WHERE hello = 1 AND world = ANY({2, 3})`
120
+ *
121
+ * @param fieldEqualityOperands - list of field equality selection operand specifications
122
+ * @param querySelectionModifiers - limit, offset, and orderBy for the query
123
+ * @returns array of entities that match the query
58
124
  * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
59
125
  */
60
126
  loadManyByFieldEqualityConjunctionAsync<N extends keyof Pick<TFields, TSelectedFields>>(fieldEqualityOperands: FieldEqualityCondition<TFields, N>[], querySelectionModifiers?: QuerySelectionModifiers<TFields>): Promise<readonly TEntity[]>;
61
127
  /**
62
- * Enforcing version of entity loader method by the same name.
128
+ * Loads many entities matching the raw WHERE clause. Corresponds to the knex `whereRaw` argument format.
129
+ *
130
+ * @remarks
131
+ * Important notes:
132
+ * - Fields in clause are database column names instead of transformed entity field names.
133
+ * - Entities loaded using this method are not batched or cached.
134
+ * - Not all database adapters implement the ability to execute this method of fetching entities.
135
+ *
136
+ * @example
137
+ * rawWhereClause: `id = ?`
138
+ * bindings: `[1]`
139
+ * Entites returned `WHERE id = 1`
140
+ *
141
+ * http://knexjs.org/#Builder-whereRaw
142
+ * http://knexjs.org/#Raw-Bindings
143
+ *
144
+ * @param rawWhereClause - parameterized SQL WHERE clause with positional binding placeholders or named binding placeholders
145
+ * @param bindings - array of positional bindings or object of named bindings
146
+ * @param querySelectionModifiers - limit, offset, orderBy, and orderByRaw for the query
147
+ * @returns array of entities that match the query
63
148
  * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
149
+ * @throws Error when rawWhereClause or bindings are invalid
64
150
  */
65
151
  loadManyByRawWhereClauseAsync(rawWhereClause: string, bindings: any[] | object, querySelectionModifiers?: QuerySelectionModifiersWithOrderByRaw<TFields>): Promise<readonly TEntity[]>;
66
152
  }
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const CompositeFieldHolder_1 = require("./internal/CompositeFieldHolder");
4
+ const CompositeFieldValueMap_1 = require("./internal/CompositeFieldValueMap");
3
5
  const maps_1 = require("./utils/collections/maps");
4
6
  /**
5
7
  * Enforcing entity loader. All normal loads are batched,
@@ -12,7 +14,10 @@ class EnforcingEntityLoader {
12
14
  this.entityLoader = entityLoader;
13
15
  }
14
16
  /**
15
- * Enforcing version of entity loader method by the same name.
17
+ * Load many entities where fieldName is one of fieldValues.
18
+ * @param fieldName - entity field being queried
19
+ * @param fieldValues - fieldName field values being queried
20
+ * @returns map from fieldValue to entities that match the query for that fieldValue
16
21
  * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
17
22
  */
18
23
  async loadManyByFieldEqualingManyAsync(fieldName, fieldValues) {
@@ -20,7 +25,26 @@ class EnforcingEntityLoader {
20
25
  return (0, maps_1.mapMap)(fieldValuesToResults, (results) => results.map((result) => result.enforceValue()));
21
26
  }
22
27
  /**
23
- * Enforcing version of entity loader method by the same name.
28
+ * Load many entities where compositeField is one of compositeFieldValues.
29
+ * @param compositeField - composite field being queried
30
+ * @param compositeFieldValues - compositeField values being queried
31
+ * @returns map from compositeFieldValue to entities that match the query for that compositeFieldValue
32
+ * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
33
+ */
34
+ async loadManyByCompositeFieldEqualingManyAsync(compositeField, compositeFieldValues) {
35
+ const compositeFieldValuesToResults = await this.entityLoader.loadManyByCompositeFieldEqualingManyAsync(compositeField, compositeFieldValues);
36
+ return new CompositeFieldValueMap_1.CompositeFieldValueMap(Array.from(compositeFieldValuesToResults.entries()).map(([compositeFieldValue, results]) => {
37
+ return [
38
+ new CompositeFieldHolder_1.CompositeFieldValueHolder(compositeFieldValue),
39
+ results.map((result) => result.enforceValue()),
40
+ ];
41
+ }));
42
+ }
43
+ /**
44
+ * Load many entities where fieldName equals fieldValue.
45
+ * @param fieldName - entity field being queried
46
+ * @param fieldValue - fieldName field value being queried
47
+ * @returns array of entities that match the query for fieldValue
24
48
  * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
25
49
  */
26
50
  async loadManyByFieldEqualingAsync(fieldName, fieldValue) {
@@ -28,24 +52,55 @@ class EnforcingEntityLoader {
28
52
  return entityResults.map((result) => result.enforceValue());
29
53
  }
30
54
  /**
31
- * Enforcing version of entity loader method by the same name.
55
+ * Load many entities where compositeField equals compositeFieldValue.
56
+ * @param compositeField - composite field being queried
57
+ * @param compositeFieldValue - compositeField value being queried
58
+ * @returns array of entities that match the query for compositeFieldValue
59
+ * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
60
+ */
61
+ async loadManyByCompositeFieldEqualingAsync(compositeField, compositeFieldValue) {
62
+ const entityResults = await this.entityLoader.loadManyByCompositeFieldEqualingAsync(compositeField, compositeFieldValue);
63
+ return entityResults.map((result) => result.enforceValue());
64
+ }
65
+ /**
66
+ * Load an entity where fieldName equals fieldValue, or null if no entity exists.
67
+ * @param uniqueFieldName - entity field being queried
68
+ * @param fieldValue - uniqueFieldName field value being queried
69
+ * @returns entity where uniqueFieldName equals fieldValue, or null if no entity matches the condition.
70
+ * @throws when multiple entities match the condition
32
71
  * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
33
- * @throws when multiple entities are found matching the condition
34
72
  */
35
73
  async loadByFieldEqualingAsync(uniqueFieldName, fieldValue) {
36
74
  const entityResult = await this.entityLoader.loadByFieldEqualingAsync(uniqueFieldName, fieldValue);
37
75
  return entityResult ? entityResult.enforceValue() : null;
38
76
  }
39
77
  /**
40
- * Enforcing version of entity loader method by the same name.
78
+ * Load an entity where compositeField equals compositeFieldValue, or null if no entity exists.
79
+ * @param compositeField - composite field being queried
80
+ * @param compositeFieldValue - compositeField value being queried
81
+ * @returns entity where compositeField equals compositeFieldValue, or null if no entity matches the condition.
82
+ * @throws when multiple entities match the condition
83
+ * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
84
+ */
85
+ async loadByCompositeFieldEqualingAsync(compositeField, compositeFieldValue) {
86
+ const entityResult = await this.entityLoader.loadByCompositeFieldEqualingAsync(compositeField, compositeFieldValue);
87
+ return entityResult ? entityResult.enforceValue() : null;
88
+ }
89
+ /**
90
+ * Loads an entity by a specified ID.
91
+ * @param id - ID of the entity
92
+ * @returns entity matching ID
41
93
  * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
94
+ * @throws EntityNotFoundError when no entity exists for ID
42
95
  */
43
96
  async loadByIDAsync(id) {
44
97
  const entityResult = await this.entityLoader.loadByIDAsync(id);
45
98
  return entityResult.enforceValue();
46
99
  }
47
100
  /**
48
- * Enforcing version of entity loader method by the same name.
101
+ * Load an entity by a specified ID, or return null if non-existent.
102
+ * @param id - ID of the entity
103
+ * @returns entity for matching ID, or null if no entity exists for ID.
49
104
  * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
50
105
  * @throws when multiple entities are found matching the condition
51
106
  */
@@ -54,15 +109,20 @@ class EnforcingEntityLoader {
54
109
  return entityResult ? entityResult.enforceValue() : null;
55
110
  }
56
111
  /**
57
- * Enforcing version of entity loader method by the same name.
112
+ * Loads many entities for a list of IDs.
113
+ * @param ids - IDs of the entities to load
114
+ * @returns map from ID to corresponding entity result, where result error can be UnauthorizedError or EntityNotFoundError.
58
115
  * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
116
+ * @throws EntityNotFoundError when no entity exists for one or more of the IDs
59
117
  */
60
118
  async loadManyByIDsAsync(ids) {
61
119
  const entityResults = await this.entityLoader.loadManyByIDsAsync(ids);
62
120
  return (0, maps_1.mapMap)(entityResults, (result) => result.enforceValue());
63
121
  }
64
122
  /**
65
- * Enforcing version of entity loader method by the same name.
123
+ * Loads many entities for a list of IDs, returning null for any IDs that are non-existent.
124
+ * @param ids - IDs of the entities to load
125
+ * @returns map from ID to nullable corresponding entity
66
126
  * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
67
127
  */
68
128
  async loadManyByIDsNullableAsync(ids) {
@@ -70,15 +130,36 @@ class EnforcingEntityLoader {
70
130
  return (0, maps_1.mapMap)(entityResults, (result) => result?.enforceValue() ?? null);
71
131
  }
72
132
  /**
73
- * Enforcing version of entity loader method by the same name.
74
- * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
133
+ * Loads the first entity matching the selection constructed from the conjunction of specified
134
+ * operands, or null if no matching entity exists. Entities loaded using this method are not
135
+ * batched or cached.
136
+ *
137
+ * This is a convenience method for {@link loadManyByFieldEqualityConjunctionAsync}. However, the
138
+ * `orderBy` option must be specified to define what "first" means. If ordering doesn't matter,
139
+ * explicitly pass in an empty array.
140
+ *
141
+ * @param fieldEqualityOperands - list of field equality selection operand specifications
142
+ * @param querySelectionModifiers - orderBy and optional offset for the query
143
+ * @returns the first entity that matches the query or null if no entity matches the query
144
+ * @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
75
145
  */
76
146
  async loadFirstByFieldEqualityConjunctionAsync(fieldEqualityOperands, querySelectionModifiers) {
77
147
  const entityResult = await this.entityLoader.loadFirstByFieldEqualityConjunctionAsync(fieldEqualityOperands, querySelectionModifiers);
78
148
  return entityResult ? entityResult.enforceValue() : null;
79
149
  }
80
150
  /**
81
- * Enforcing version of entity loader method by the same name.
151
+ * Loads many entities matching the selection constructed from the conjunction of specified operands.
152
+ * Entities loaded using this method are not batched or cached.
153
+ *
154
+ * @example
155
+ * fieldEqualityOperands:
156
+ * `[{fieldName: 'hello', fieldValue: 1}, {fieldName: 'world', fieldValues: [2, 3]}]`
157
+ * Entities returned with a SQL EntityDatabaseAdapter:
158
+ * `WHERE hello = 1 AND world = ANY({2, 3})`
159
+ *
160
+ * @param fieldEqualityOperands - list of field equality selection operand specifications
161
+ * @param querySelectionModifiers - limit, offset, and orderBy for the query
162
+ * @returns array of entities that match the query
82
163
  * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
83
164
  */
84
165
  async loadManyByFieldEqualityConjunctionAsync(fieldEqualityOperands, querySelectionModifiers = {}) {
@@ -86,8 +167,28 @@ class EnforcingEntityLoader {
86
167
  return entityResults.map((result) => result.enforceValue());
87
168
  }
88
169
  /**
89
- * Enforcing version of entity loader method by the same name.
170
+ * Loads many entities matching the raw WHERE clause. Corresponds to the knex `whereRaw` argument format.
171
+ *
172
+ * @remarks
173
+ * Important notes:
174
+ * - Fields in clause are database column names instead of transformed entity field names.
175
+ * - Entities loaded using this method are not batched or cached.
176
+ * - Not all database adapters implement the ability to execute this method of fetching entities.
177
+ *
178
+ * @example
179
+ * rawWhereClause: `id = ?`
180
+ * bindings: `[1]`
181
+ * Entites returned `WHERE id = 1`
182
+ *
183
+ * http://knexjs.org/#Builder-whereRaw
184
+ * http://knexjs.org/#Raw-Bindings
185
+ *
186
+ * @param rawWhereClause - parameterized SQL WHERE clause with positional binding placeholders or named binding placeholders
187
+ * @param bindings - array of positional bindings or object of named bindings
188
+ * @param querySelectionModifiers - limit, offset, orderBy, and orderByRaw for the query
189
+ * @returns array of entities that match the query
90
190
  * @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
191
+ * @throws Error when rawWhereClause or bindings are invalid
91
192
  */
92
193
  async loadManyByRawWhereClauseAsync(rawWhereClause, bindings, querySelectionModifiers = {}) {
93
194
  const entityResults = await this.entityLoader.loadManyByRawWhereClauseAsync(rawWhereClause, bindings, querySelectionModifiers);
@@ -1 +1 @@
1
- {"version":3,"file":"EnforcingEntityLoader.js","sourceRoot":"","sources":["../src/EnforcingEntityLoader.ts"],"names":[],"mappings":";;AASA,mDAAkD;AAElD;;;;GAIG;AACH,MAAqB,qBAAqB;IAerB;IADnB,YACmB,YAOhB;QAPgB,iBAAY,GAAZ,YAAY,CAO5B;IACA,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,gCAAgC,CACpC,SAAY,EACZ,WAA+C;QAE/C,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,gCAAgC,CACnF,SAAS,EACT,WAAW,CACZ,CAAC;QACF,OAAO,IAAA,aAAM,EAAC,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE,CAC9C,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAC/C,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,4BAA4B,CAChC,SAAY,EACZ,UAAmC;QAEnC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,4BAA4B,CACxE,SAAS,EACT,UAAU,CACX,CAAC;QACF,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,wBAAwB,CAC5B,eAAkB,EAClB,UAAmC;QAEnC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,wBAAwB,CACnE,eAAe,EACf,UAAU,CACX,CAAC;QACF,OAAO,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa,CAAC,EAAO;QACzB,MAAM,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aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,IAAI,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,wCAAwC,CAC5C,qBAA2D,EAC3D,uBAC6D;QAE7D,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,wCAAwC,CACnF,qBAAqB,EACrB,uBAAuB,CACxB,CAAC;QACF,OAAO,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3D,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,uCAAuC,CAC3C,qBAA2D,EAC3D,0BAA4D,EAAE;QAE9D,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,uCAAuC,CACnF,qBAAqB,EACrB,uBAAuB,CACxB,CAAC;QACF,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,KAAK,CAAC,6BAA6B,CACjC,cAAsB,EACtB,QAAwB,EACxB,0BAA0E,EAAE;QAE5E,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,6BAA6B,CACzE,cAAc,EACd,QAAQ,EACR,uBAAuB,CACxB,CAAC;QACF,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF;AAnSD,wCAmSC"}
@@ -6,9 +6,9 @@ import ViewerContext from './ViewerContext';
6
6
  * Enforcing entity updater. All updates
7
7
  * through this updater will throw if authorization is not successful.
8
8
  */
9
- export default class EnforcingEntityUpdater<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
9
+ export default class EnforcingEntityUpdater<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
10
10
  private readonly entityUpdater;
11
- constructor(entityUpdater: AuthorizationResultBasedUpdateMutator<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>);
11
+ constructor(entityUpdater: AuthorizationResultBasedUpdateMutator<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>);
12
12
  /**
13
13
  * Set the value for entity field.
14
14
  * @param fieldName - entity field being updated
package/build/Entity.d.ts CHANGED
@@ -25,57 +25,57 @@ import ViewerContext from './ViewerContext';
25
25
  * All concrete entity implementations should extend this class and provide their
26
26
  * own EntityCompanionDefinition.
27
27
  */
28
- export default abstract class Entity<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TSelectedFields extends keyof TFields = keyof TFields> extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields> {
28
+ export default abstract class Entity<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TSelectedFields extends keyof TFields = keyof TFields> extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields> {
29
29
  /**
30
30
  * Vend mutator for creating a new entity in given query context.
31
31
  * @param viewerContext - viewer context of creating user
32
32
  * @param queryContext - query context in which to perform the create
33
33
  * @returns mutator for creating an entity
34
34
  */
35
- static creator<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMID, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, viewerContext: TMViewerContext2, queryContext?: EntityQueryContext): EnforcingEntityCreator<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
35
+ static creator<TMFields extends object, TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMIDField, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, viewerContext: TMViewerContext2, queryContext?: EntityQueryContext): EnforcingEntityCreator<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
36
36
  /**
37
37
  * Vend mutator for creating a new entity in given query context.
38
38
  * @param viewerContext - viewer context of creating user
39
39
  * @param queryContext - query context in which to perform the create
40
40
  * @returns mutator for creating an entity
41
41
  */
42
- static creatorWithAuthorizationResults<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMID, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, viewerContext: TMViewerContext2, queryContext?: EntityQueryContext): AuthorizationResultBasedCreateMutator<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
42
+ static creatorWithAuthorizationResults<TMFields extends object, TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMIDField, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, viewerContext: TMViewerContext2, queryContext?: EntityQueryContext): AuthorizationResultBasedCreateMutator<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
43
43
  /**
44
44
  * Vend mutator for updating an existing entity in given query context.
45
45
  * @param existingEntity - entity to update
46
46
  * @param queryContext - query context in which to perform the update
47
47
  * @returns mutator for updating existingEntity
48
48
  */
49
- static updater<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMID, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): EnforcingEntityUpdater<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
49
+ static updater<TMFields extends object, TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMIDField, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): EnforcingEntityUpdater<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
50
50
  /**
51
51
  * Vend mutator for updating an existing entity in given query context.
52
52
  * @param existingEntity - entity to update
53
53
  * @param queryContext - query context in which to perform the update
54
54
  * @returns mutator for updating existingEntity
55
55
  */
56
- static updaterWithAuthorizationResults<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMID, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): AuthorizationResultBasedUpdateMutator<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
56
+ static updaterWithAuthorizationResults<TMFields extends object, TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMIDField, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): AuthorizationResultBasedUpdateMutator<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
57
57
  /**
58
58
  * Vend mutator for deleting an existing entity in given query context.
59
59
  * @param existingEntity - entity to delete
60
60
  * @param queryContext - query context in which to perform the delete
61
61
  * @returns mutator for deleting existingEntity
62
62
  */
63
- static deleter<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMID, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): EnforcingEntityDeleter<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
63
+ static deleter<TMFields extends object, TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMIDField, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): EnforcingEntityDeleter<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
64
64
  /**
65
65
  * Vend mutator for deleting an existing entity in given query context.
66
66
  * @param existingEntity - entity to delete
67
67
  * @param queryContext - query context in which to perform the delete
68
68
  * @returns mutator for deleting existingEntity
69
69
  */
70
- static deleterWithAuthorizationResults<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMID, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): AuthorizationResultBasedDeleteMutator<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
70
+ static deleterWithAuthorizationResults<TMFields extends object, TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMIDField, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): AuthorizationResultBasedDeleteMutator<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
71
71
  }
72
72
  /**
73
73
  * An interface to pass in constructor (class) of an Entity as a function argument.
74
74
  */
75
- export interface IEntityClass<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields = keyof TFields> {
75
+ export interface IEntityClass<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields = keyof TFields> {
76
76
  new (constructorParam: {
77
77
  viewerContext: TViewerContext;
78
- id: TID;
78
+ id: TFields[TIDField];
79
79
  databaseFields: Readonly<TFields>;
80
80
  selectedFields: Readonly<Pick<TFields, TSelectedFields>>;
81
81
  }): TEntity;
@@ -84,5 +84,5 @@ export interface IEntityClass<TFields extends object, TID extends NonNullable<TF
84
84
  *
85
85
  * Memoized by the entity framework.
86
86
  */
87
- defineCompanionDefinition(): EntityCompanionDefinition<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
87
+ defineCompanionDefinition(): EntityCompanionDefinition<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
88
88
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Entity.js","sourceRoot":"","sources":["../src/Entity.ts"],"names":[],"mappings":";;;;;AASA,oEAA4C;AAC5C,oEAA4C;AAG5C,oEAA4C;AAC5C,sEAA8C;AAG9C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAA8B,MAK5B,SAAQ,wBAA6D;IACrE;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAuBZ,aAA+B,EAC/B,eAAmC,aAAa;SAC7C,sCAAsC,CAAC,IAAI,CAAC;SAC5C,uBAAuB,EAAE;SACzB,eAAe,EAAE;QASpB,OAAO,IAAI,uBAAa,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC1E,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,+BAA+B,CAuBpC,aAA+B,EAC/B,eAAmC,aAAa;SAC7C,sCAAsC,CAAC,IAAI,CAAC;SAC5C,uBAAuB,EAAE;SACzB,eAAe,EAAE;QASpB,OAAO,IAAI,uBAAa,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,wBAAwB,EAAE,CAAC;IACzF,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAsBZ,cAAwB,EACxB,eAAmC,cAAc;SAC9C,gBAAgB,EAAE;SAClB,sCAAsC,CAAC,IAAI,CAAC;SAC5C,uBAAuB,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,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3E,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,+BAA+B,CAsBpC,cAAwB,EACxB,eAAmC,cAAc;SAC9C,gBAAgB,EAAE;SAClB,sCAAsC,CAAC,IAAI,CAAC;SAC5C,uBAAuB,EAAE;SACzB,eAAe,EAAE;QASpB,OAAO,IAAI,uBAAa,CAAC,cAAc,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,wBAAwB,EAAE,CAAC;IAC1F,CAAC;CACF;AAnRD,yBAmRC"}
@@ -8,7 +8,7 @@ import ViewerContext from './ViewerContext';
8
8
  * associated with an entity. In relational databases, these entities are often referenced
9
9
  * by foreign keys.
10
10
  */
11
- export default class EntityAssociationLoader<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TSelectedFields extends keyof TFields> {
11
+ export default class EntityAssociationLoader<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TSelectedFields extends keyof TFields> {
12
12
  private readonly entity;
13
13
  private readonly queryContext;
14
14
  constructor(entity: TEntity, queryContext?: EntityQueryContext);
@@ -17,11 +17,11 @@ export default class EntityAssociationLoader<TFields extends object, TID extends
17
17
  * guaranteed to be the values of successful results (or null for some loader methods),
18
18
  * and will throw otherwise.
19
19
  */
20
- enforcing(): EnforcingEntityAssociationLoader<TFields, TID, TViewerContext, TEntity, TSelectedFields>;
20
+ enforcing(): EnforcingEntityAssociationLoader<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>;
21
21
  /**
22
22
  * Authorization-result-based entity loader. All loads through this
23
23
  * loader are results, where an unsuccessful result
24
24
  * means an authorization error or entity construction error occurred. Other errors are thrown.
25
25
  */
26
- withAuthorizationResults(): AuthorizationResultBasedEntityAssociationLoader<TFields, TID, TViewerContext, TEntity, TSelectedFields>;
26
+ withAuthorizationResults(): AuthorizationResultBasedEntityAssociationLoader<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>;
27
27
  }
@@ -13,17 +13,17 @@ export interface IPrivacyPolicyClass<TPrivacyPolicy> {
13
13
  /**
14
14
  * Composition root responsible for orchestrating setup of Entity mutators and loaders.
15
15
  */
16
- export default class EntityCompanion<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
16
+ export default class EntityCompanion<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
17
17
  readonly entityCompanionProvider: EntityCompanionProvider;
18
- readonly entityCompanionDefinition: EntityCompanionDefinition<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
18
+ readonly entityCompanionDefinition: EntityCompanionDefinition<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
19
19
  private readonly tableDataCoordinator;
20
20
  private readonly metricsAdapter;
21
21
  readonly privacyPolicy: TPrivacyPolicy;
22
22
  private readonly entityLoaderFactory;
23
23
  private readonly entityMutatorFactory;
24
- constructor(entityCompanionProvider: EntityCompanionProvider, entityCompanionDefinition: EntityCompanionDefinition<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>, tableDataCoordinator: EntityTableDataCoordinator<TFields>, metricsAdapter: IEntityMetricsAdapter);
25
- getLoaderFactory(): EntityLoaderFactory<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
26
- getMutatorFactory(): EntityMutatorFactory<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
24
+ constructor(entityCompanionProvider: EntityCompanionProvider, entityCompanionDefinition: EntityCompanionDefinition<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>, tableDataCoordinator: EntityTableDataCoordinator<TFields, TIDField>, metricsAdapter: IEntityMetricsAdapter);
25
+ getLoaderFactory(): EntityLoaderFactory<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
26
+ getMutatorFactory(): EntityMutatorFactory<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
27
27
  /**
28
28
  * Get the query context provider for this entity.
29
29
  */
@@ -1 +1 @@
1
- {"version":3,"file":"EntityCompanion.js","sourceRoot":"","sources":["../src/EntityCompanion.ts"],"names":[],"mappings":";;;;;AACA,gFAAwD;AACxD,kFAA0D;AAO1D,+GAA4G;AAM5G;;GAEG;AACH,MAAqB,eAAe;IAkChB;IACA;IAQC;IACA;IA9BH,aAAa,CAAiB;IAE7B,mBAAmB,CAOlC;IACe,oBAAoB,CAOnC;IAEF,YACkB,uBAAgD,EAChD,yBAOf,EACgB,oBAAyD,EACzD,cAAqC;QAVtC,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,8BAAyB,GAAzB,yBAAyB,CAOxC;QACgB,yBAAoB,GAApB,oBAAoB,CAAqC;QACzD,mBAAc,GAAd,cAAc,CAAuB;QAEtD,IAAI,CAAC,aAAa,GAAG,IAAI,yBAAyB,CAAC,kBAAkB,EAAE,CAAC;QACxE,IAAI,CAAC,mBAAmB,GAAG,IAAI,6BAAmB,CAOhD,IAAI,EAAE,oBAAoB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAC1D,IAAI,CAAC,oBAAoB,GAAG,IAAI,8BAAoB,CAClD,uBAAuB,EACvB,oBAAoB,CAAC,mBAAmB,EACxC,yBAAyB,CAAC,WA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AC,oBAAoB,GAAG,IAAI,8BAAoB,CAClD,uBAAuB,EACvB,oBAAoB,CAAC,mBAAmB,EACxC,yBAAyB,CAAC,WAAW,EACrC,IAAI,CAAC,aAAa,EAClB,yBAAyB,CAAC,kBAAkB,IAAI,EAAE,EAClD,IAAA,mFAAwC,EACtC,yBAAyB,CAAC,gBAAgB,IAAI,EAAE,EAChD,uBAAuB,CAAC,sBAAsB,IAAI,EAAE,CACrD,EACD,IAAI,CAAC,mBAAmB,EACxB,oBAAoB,CAAC,eAAe,EACpC,cAAc,CACf,CAAC;IACJ,CAAC;IAED,gBAAgB;QAQd,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IAED,iBAAiB;QAQf,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,uBAAuB;QACrB,OAAO,IAAI,CAAC,oBAAoB,CAAC,uBAAuB,EAAE,CAAC;IAC7D,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;CACF;AA1GD,kCA0GC"}
@@ -40,15 +40,15 @@ export interface CacheAdapterFlavorDefinition {
40
40
  * Definition for constructing a companion for an entity. Defines the core set of objects
41
41
  * used to power the entity framework for a particular type of entity.
42
42
  */
43
- export interface EntityCompanionDefinition<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields = keyof TFields> {
43
+ export interface EntityCompanionDefinition<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields = keyof TFields> {
44
44
  /**
45
45
  * The concrete Entity class for which this is the definition.
46
46
  */
47
- readonly entityClass: IEntityClass<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
47
+ readonly entityClass: IEntityClass<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
48
48
  /**
49
49
  * The EntityConfiguration for this entity.
50
50
  */
51
- readonly entityConfiguration: EntityConfiguration<TFields>;
51
+ readonly entityConfiguration: EntityConfiguration<TFields, TIDField>;
52
52
  /**
53
53
  * The EntityPrivacyPolicy class for this entity.
54
54
  */
@@ -56,11 +56,11 @@ export interface EntityCompanionDefinition<TFields extends object, TID extends N
56
56
  /**
57
57
  * An optional list of EntityMutationValidator for this entity.
58
58
  */
59
- readonly mutationValidators?: EntityMutationValidator<TFields, TID, TViewerContext, TEntity, TSelectedFields>[];
59
+ readonly mutationValidators?: EntityMutationValidator<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>[];
60
60
  /**
61
61
  * An optional list of EntityMutationTrigger for this entity.
62
62
  */
63
- readonly mutationTriggers?: EntityMutationTriggerConfiguration<TFields, TID, TViewerContext, TEntity, TSelectedFields>;
63
+ readonly mutationTriggers?: EntityMutationTriggerConfiguration<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>;
64
64
  /**
65
65
  * An optional subset of fields defined in the EntityConfiguration which belong to this entity.
66
66
  * For use when multiple types of entities are backed by a single table (EntityConfiguration) yet
@@ -99,7 +99,7 @@ export default class EntityCompanionProvider {
99
99
  *
100
100
  * @param entityClass - entity class to load
101
101
  */
102
- getCompanionForEntity<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields>(entityClass: IEntityClass<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>): EntityCompanion<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
102
+ getCompanionForEntity<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields>(entityClass: IEntityClass<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>): EntityCompanion<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
103
103
  getQueryContextProviderForDatabaseAdaptorFlavor(databaseAdapterFlavor: DatabaseAdapterFlavor): EntityQueryContextProvider;
104
104
  private getTableDataCoordinatorForEntity;
105
105
  }