@expo/entity 0.41.0 → 0.43.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.
- package/build/AuthorizationResultBasedEntityAssociationLoader.d.ts +16 -16
- package/build/AuthorizationResultBasedEntityAssociationLoader.js.map +1 -1
- package/build/AuthorizationResultBasedEntityLoader.d.ts +39 -67
- package/build/AuthorizationResultBasedEntityLoader.js +85 -62
- package/build/AuthorizationResultBasedEntityLoader.js.map +1 -1
- package/build/AuthorizationResultBasedEntityMutator.d.ts +16 -16
- package/build/AuthorizationResultBasedEntityMutator.js.map +1 -1
- package/build/ComposedEntityCacheAdapter.d.ts +7 -6
- package/build/ComposedEntityCacheAdapter.js +28 -28
- package/build/ComposedEntityCacheAdapter.js.map +1 -1
- package/build/ComposedSecondaryEntityCache.d.ts +1 -1
- package/build/ComposedSecondaryEntityCache.js.map +1 -1
- package/build/EnforcingEntityAssociationLoader.d.ts +15 -15
- package/build/EnforcingEntityAssociationLoader.js.map +1 -1
- package/build/EnforcingEntityCreator.d.ts +2 -2
- package/build/EnforcingEntityDeleter.d.ts +2 -2
- package/build/EnforcingEntityLoader.d.ts +104 -18
- package/build/EnforcingEntityLoader.js +113 -12
- package/build/EnforcingEntityLoader.js.map +1 -1
- package/build/EnforcingEntityUpdater.d.ts +2 -2
- package/build/Entity.d.ts +10 -10
- package/build/Entity.js.map +1 -1
- package/build/EntityAssociationLoader.d.ts +3 -3
- package/build/EntityCompanion.d.ts +5 -5
- package/build/EntityCompanion.js.map +1 -1
- package/build/EntityCompanionProvider.d.ts +6 -6
- package/build/EntityCompanionProvider.js.map +1 -1
- package/build/EntityConfiguration.d.ts +46 -5
- package/build/EntityConfiguration.js +39 -1
- package/build/EntityConfiguration.js.map +1 -1
- package/build/EntityCreator.d.ts +4 -4
- package/build/EntityDatabaseAdapter.d.ts +15 -14
- package/build/EntityDatabaseAdapter.js +20 -12
- package/build/EntityDatabaseAdapter.js.map +1 -1
- package/build/EntityDeleter.d.ts +4 -4
- package/build/EntityFieldDefinition.d.ts +20 -10
- package/build/EntityFieldDefinition.js +3 -1
- package/build/EntityFieldDefinition.js.map +1 -1
- package/build/EntityFields.d.ts +14 -12
- package/build/EntityFields.js.map +1 -1
- package/build/EntityLoader.d.ts +5 -5
- package/build/EntityLoaderFactory.d.ts +3 -3
- package/build/EntityLoaderFactory.js.map +1 -1
- package/build/EntityLoaderUtils.d.ts +2 -2
- package/build/EntityLoaderUtils.js +27 -1
- package/build/EntityLoaderUtils.js.map +1 -1
- package/build/EntityMutationInfo.d.ts +2 -2
- package/build/EntityMutationTriggerConfiguration.d.ts +14 -14
- package/build/EntityMutationTriggerConfiguration.js.map +1 -1
- package/build/EntityMutationValidator.d.ts +2 -2
- package/build/EntityMutatorFactory.d.ts +5 -5
- package/build/EntityMutatorFactory.js.map +1 -1
- package/build/EntityPrivacyPolicy.d.ts +14 -14
- package/build/EntityPrivacyPolicy.js.map +1 -1
- package/build/EntitySecondaryCacheLoader.d.ts +4 -4
- package/build/EntityUpdater.d.ts +4 -4
- package/build/GenericEntityCacheAdapter.d.ts +7 -6
- package/build/GenericEntityCacheAdapter.js +13 -14
- package/build/GenericEntityCacheAdapter.js.map +1 -1
- package/build/GenericSecondaryEntityCache.d.ts +3 -3
- package/build/GenericSecondaryEntityCache.js.map +1 -1
- package/build/IEntityCacheAdapter.d.ts +17 -16
- package/build/IEntityCacheAdapterProvider.d.ts +1 -1
- package/build/IEntityDatabaseAdapterProvider.d.ts +1 -1
- package/build/IEntityGenericCacher.d.ts +15 -5
- package/build/ReadonlyEntity.d.ts +8 -8
- package/build/ReadonlyEntity.js.map +1 -1
- package/build/ViewerContext.d.ts +1 -1
- package/build/ViewerScopedEntityCompanion.d.ts +5 -5
- package/build/ViewerScopedEntityCompanionProvider.d.ts +1 -1
- package/build/ViewerScopedEntityLoaderFactory.d.ts +3 -3
- package/build/ViewerScopedEntityMutatorFactory.d.ts +5 -5
- package/build/entityUtils.d.ts +1 -1
- package/build/entityUtils.js.map +1 -1
- package/build/errors/EntityInvalidFieldValueError.d.ts +2 -2
- package/build/errors/EntityNotAuthorizedError.d.ts +1 -1
- package/build/errors/EntityNotFoundError.d.ts +2 -2
- package/build/index.d.ts +7 -7
- package/build/index.js +8 -13
- package/build/index.js.map +1 -1
- package/build/internal/CompositeFieldHolder.d.ts +48 -0
- package/build/internal/CompositeFieldHolder.js +116 -0
- package/build/internal/CompositeFieldHolder.js.map +1 -0
- package/build/internal/CompositeFieldValueMap.d.ts +15 -0
- package/build/internal/CompositeFieldValueMap.js +51 -0
- package/build/internal/CompositeFieldValueMap.js.map +1 -0
- package/build/internal/EntityDataManager.d.ts +16 -16
- package/build/internal/EntityDataManager.js +42 -45
- package/build/internal/EntityDataManager.js.map +1 -1
- package/build/internal/EntityFieldTransformationUtils.d.ts +5 -5
- package/build/internal/EntityFieldTransformationUtils.js.map +1 -1
- package/build/internal/EntityLoadInterfaces.d.ts +104 -0
- package/build/internal/EntityLoadInterfaces.js +25 -0
- package/build/internal/EntityLoadInterfaces.js.map +1 -0
- package/build/internal/EntityTableDataCoordinator.d.ts +6 -6
- package/build/internal/EntityTableDataCoordinator.js.map +1 -1
- package/build/internal/ReadThroughEntityCache.d.ts +17 -16
- package/build/internal/ReadThroughEntityCache.js +36 -36
- package/build/internal/ReadThroughEntityCache.js.map +1 -1
- package/build/internal/SingleFieldHolder.d.ts +34 -0
- package/build/internal/SingleFieldHolder.js +90 -0
- package/build/internal/SingleFieldHolder.js.map +1 -0
- package/build/metrics/EntityMetricsUtils.d.ts +2 -1
- package/build/metrics/EntityMetricsUtils.js.map +1 -1
- package/build/metrics/IEntityMetricsAdapter.d.ts +5 -0
- package/build/metrics/IEntityMetricsAdapter.js.map +1 -1
- package/build/rules/AlwaysAllowPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysAllowPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysDenyPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysDenyPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysSkipPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysSkipPrivacyPolicyRule.js.map +1 -1
- package/build/rules/PrivacyPolicyRule.d.ts +2 -2
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/build/utils/EntityPrivacyUtils.d.ts +4 -4
- package/build/utils/EntityPrivacyUtils.js.map +1 -1
- package/build/utils/collections/SerializableKeyMap.d.ts +27 -0
- package/build/utils/collections/SerializableKeyMap.js +60 -0
- package/build/utils/collections/SerializableKeyMap.js.map +1 -0
- package/build/utils/collections/maps.js +1 -2
- package/build/utils/collections/maps.js.map +1 -1
- package/build/utils/collections/sets.d.ts +1 -0
- package/build/utils/collections/sets.js +7 -0
- package/build/utils/collections/sets.js.map +1 -0
- package/build/utils/mergeEntityMutationTriggerConfigurations.d.ts +1 -1
- package/package.json +8 -5
- package/src/AuthorizationResultBasedEntityAssociationLoader.ts +56 -49
- package/src/AuthorizationResultBasedEntityLoader.ts +194 -81
- package/src/AuthorizationResultBasedEntityMutator.ts +71 -45
- package/src/ComposedEntityCacheAdapter.ts +55 -46
- package/src/ComposedSecondaryEntityCache.ts +5 -2
- package/src/EnforcingEntityAssociationLoader.ts +52 -44
- package/src/EnforcingEntityCreator.ts +5 -5
- package/src/EnforcingEntityDeleter.ts +5 -5
- package/src/EnforcingEntityLoader.ts +158 -21
- package/src/EnforcingEntityUpdater.ts +5 -5
- package/src/Entity.ts +39 -39
- package/src/EntityAssociationLoader.ts +6 -6
- package/src/EntityCompanion.ts +11 -11
- package/src/EntityCompanionProvider.ts +21 -18
- package/src/EntityConfiguration.ts +123 -9
- package/src/EntityCreator.ts +7 -7
- package/src/EntityDatabaseAdapter.ts +51 -28
- package/src/EntityDeleter.ts +7 -7
- package/src/EntityFieldDefinition.ts +32 -12
- package/src/EntityFields.ts +49 -12
- package/src/EntityLoader.ts +8 -8
- package/src/EntityLoaderFactory.ts +8 -8
- package/src/EntityLoaderUtils.ts +39 -10
- package/src/EntityMutationInfo.ts +6 -6
- package/src/EntityMutationTriggerConfiguration.ts +68 -20
- package/src/EntityMutationValidator.ts +4 -4
- package/src/EntityMutatorFactory.ts +13 -13
- package/src/EntityPrivacyPolicy.ts +50 -26
- package/src/EntitySecondaryCacheLoader.ts +6 -6
- package/src/EntityUpdater.ts +7 -7
- package/src/GenericEntityCacheAdapter.ts +39 -28
- package/src/GenericSecondaryEntityCache.ts +6 -3
- package/src/IEntityCacheAdapter.ts +45 -25
- package/src/IEntityCacheAdapterProvider.ts +3 -3
- package/src/IEntityDatabaseAdapterProvider.ts +3 -3
- package/src/IEntityGenericCacher.ts +33 -5
- package/src/ReadonlyEntity.ts +24 -24
- package/src/ViewerContext.ts +5 -5
- package/src/ViewerScopedEntityCompanion.ts +7 -7
- package/src/ViewerScopedEntityCompanionProvider.ts +6 -6
- package/src/ViewerScopedEntityLoaderFactory.ts +7 -7
- package/src/ViewerScopedEntityMutatorFactory.ts +8 -8
- package/src/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.ts +4 -4
- package/src/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.ts +14 -13
- package/src/__tests__/AuthorizationResultBasedEntityLoader-test.ts +367 -69
- package/src/__tests__/ComposedCacheAdapter-test.ts +235 -117
- package/src/__tests__/EnforcingEntityLoader-test.ts +135 -1
- package/src/__tests__/Entity-test.ts +2 -2
- package/src/__tests__/EntityAssociationLoader-test.ts +2 -2
- package/src/__tests__/EntityCommonUseCases-test.ts +11 -11
- package/src/__tests__/EntityCompanion-test.ts +4 -4
- package/src/__tests__/EntityCompanionProvider-test.ts +9 -8
- package/src/__tests__/EntityConfiguration-test.ts +85 -6
- package/src/__tests__/EntityDatabaseAdapter-test.ts +113 -17
- package/src/__tests__/EntityEdges-test.ts +97 -72
- package/src/__tests__/EntityFields-test.ts +2 -2
- package/src/__tests__/EntityLoader-test.ts +2 -2
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +11 -11
- package/src/__tests__/EntityMutator-SingleCompositeFieldCacheConsistency-test.ts +73 -0
- package/src/__tests__/EntityMutator-test.ts +74 -46
- package/src/__tests__/EntityPrivacyPolicy-test.ts +51 -74
- package/src/__tests__/EntityQueryContext-test.ts +1 -1
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +3 -3
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +64 -39
- package/src/__tests__/GenericEntityCacheAdapter-test.ts +83 -28
- package/src/__tests__/ReadonlyEntity-test.ts +3 -3
- package/src/__tests__/ViewerContext-test.ts +1 -1
- package/src/__tests__/ViewerScopedEntityCompanion-test.ts +5 -2
- package/src/__tests__/ViewerScopedEntityCompanionProvider-test.ts +1 -1
- package/src/__tests__/ViewerScopedEntityMutatorFactory-test.ts +12 -3
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +12 -12
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +12 -12
- package/src/entityUtils.ts +4 -1
- package/src/errors/EntityInvalidFieldValueError.ts +5 -5
- package/src/errors/EntityNotAuthorizedError.ts +3 -3
- package/src/errors/EntityNotFoundError.ts +5 -5
- package/src/index.ts +7 -7
- package/src/internal/CompositeFieldHolder.ts +218 -0
- package/src/internal/CompositeFieldValueMap.ts +78 -0
- package/src/internal/EntityDataManager.ts +107 -96
- package/src/internal/EntityFieldTransformationUtils.ts +33 -14
- package/src/internal/EntityLoadInterfaces.ts +143 -0
- package/src/internal/EntityTableDataCoordinator.ts +8 -5
- package/src/internal/ReadThroughEntityCache.ts +63 -50
- package/src/internal/SingleFieldHolder.ts +131 -0
- package/src/internal/__tests__/CompositeFieldHolder-test.ts +25 -0
- package/src/internal/__tests__/CompositeFieldValueMap-test.ts +43 -0
- package/src/internal/__tests__/EntityDataManager-test.ts +308 -91
- package/src/internal/__tests__/EntityFieldTransformationUtils-test.ts +3 -2
- package/src/internal/__tests__/ReadThroughEntityCache-test.ts +315 -107
- package/src/metrics/EntityMetricsUtils.ts +7 -2
- package/src/metrics/IEntityMetricsAdapter.ts +6 -0
- package/src/rules/AlwaysAllowPrivacyPolicyRule.ts +5 -5
- package/src/rules/AlwaysDenyPrivacyPolicyRule.ts +5 -5
- package/src/rules/AlwaysSkipPrivacyPolicyRule.ts +5 -5
- package/src/rules/PrivacyPolicyRule.ts +4 -4
- package/src/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.ts +1 -1
- package/src/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.ts +1 -1
- package/src/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.ts +1 -1
- package/src/utils/EntityPrivacyUtils.ts +72 -30
- package/src/utils/{testing → __testfixtures__}/PrivacyPolicyRuleTestUtils.ts +26 -26
- package/src/{testfixtures → utils/__testfixtures__}/SimpleTestEntity.ts +16 -15
- package/src/utils/__testfixtures__/StubCacheAdapter.ts +164 -0
- package/src/utils/{testing → __testfixtures__}/StubDatabaseAdapter.ts +19 -12
- package/src/utils/{testing → __testfixtures__}/StubDatabaseAdapterProvider.ts +4 -4
- package/src/utils/__testfixtures__/TSMockitoExtensions.ts +69 -0
- package/src/{testfixtures → utils/__testfixtures__}/TestEntity.ts +21 -15
- package/src/{testfixtures → utils/__testfixtures__}/TestEntity2.ts +16 -15
- package/src/{testfixtures → utils/__testfixtures__}/TestEntityWithMutationTriggers.ts +23 -22
- package/src/{testfixtures → utils/__testfixtures__}/TestViewerContext.ts +1 -1
- package/src/utils/{testing → __testfixtures__}/describeFieldTestCase.ts +1 -1
- package/src/utils/__tests__/EntityPrivacyUtils-test.ts +62 -66
- package/src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.ts +29 -25
- package/src/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.ts +1 -1
- package/src/utils/collections/SerializableKeyMap.ts +84 -0
- package/src/utils/collections/__tests__/SerializableKeyMap-test.ts +119 -0
- package/src/utils/collections/__tests__/sets-test.ts +17 -0
- package/src/utils/collections/maps.ts +7 -8
- package/src/utils/collections/sets.ts +3 -0
- package/src/utils/mergeEntityMutationTriggerConfigurations.ts +5 -5
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.d.ts +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js +0 -242
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js.map +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.d.ts +0 -26
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.js +0 -110
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.js.map +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.d.ts +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.js +0 -401
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.js.map +0 -1
- package/build/__tests__/ComposedCacheAdapter-test.d.ts +0 -1
- package/build/__tests__/ComposedCacheAdapter-test.js +0 -229
- package/build/__tests__/ComposedCacheAdapter-test.js.map +0 -1
- package/build/__tests__/ComposedSecondaryEntityCache-test.d.ts +0 -1
- package/build/__tests__/ComposedSecondaryEntityCache-test.js +0 -66
- package/build/__tests__/ComposedSecondaryEntityCache-test.js.map +0 -1
- package/build/__tests__/EnforcingEntityAssociationLoader-test.d.ts +0 -1
- package/build/__tests__/EnforcingEntityAssociationLoader-test.js +0 -115
- package/build/__tests__/EnforcingEntityAssociationLoader-test.js.map +0 -1
- package/build/__tests__/EnforcingEntityLoader-test.d.ts +0 -1
- package/build/__tests__/EnforcingEntityLoader-test.js +0 -253
- package/build/__tests__/EnforcingEntityLoader-test.js.map +0 -1
- package/build/__tests__/Entity-test.d.ts +0 -1
- package/build/__tests__/Entity-test.js +0 -94
- package/build/__tests__/Entity-test.js.map +0 -1
- package/build/__tests__/EntityAssociationLoader-test.d.ts +0 -1
- package/build/__tests__/EntityAssociationLoader-test.js +0 -30
- package/build/__tests__/EntityAssociationLoader-test.js.map +0 -1
- package/build/__tests__/EntityCommonUseCases-test.d.ts +0 -1
- package/build/__tests__/EntityCommonUseCases-test.js +0 -146
- package/build/__tests__/EntityCommonUseCases-test.js.map +0 -1
- package/build/__tests__/EntityCompanion-test.d.ts +0 -1
- package/build/__tests__/EntityCompanion-test.js +0 -77
- package/build/__tests__/EntityCompanion-test.js.map +0 -1
- package/build/__tests__/EntityCompanionProvider-test.d.ts +0 -1
- package/build/__tests__/EntityCompanionProvider-test.js +0 -54
- package/build/__tests__/EntityCompanionProvider-test.js.map +0 -1
- package/build/__tests__/EntityConfiguration-test.d.ts +0 -1
- package/build/__tests__/EntityConfiguration-test.js +0 -103
- package/build/__tests__/EntityConfiguration-test.js.map +0 -1
- package/build/__tests__/EntityDatabaseAdapter-test.d.ts +0 -1
- package/build/__tests__/EntityDatabaseAdapter-test.js +0 -146
- package/build/__tests__/EntityDatabaseAdapter-test.js.map +0 -1
- package/build/__tests__/EntityEdges-test.d.ts +0 -1
- package/build/__tests__/EntityEdges-test.js +0 -723
- package/build/__tests__/EntityEdges-test.js.map +0 -1
- package/build/__tests__/EntityFields-test.d.ts +0 -1
- package/build/__tests__/EntityFields-test.js +0 -63
- package/build/__tests__/EntityFields-test.js.map +0 -1
- package/build/__tests__/EntityLoader-test.d.ts +0 -1
- package/build/__tests__/EntityLoader-test.js +0 -36
- package/build/__tests__/EntityLoader-test.js.map +0 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.d.ts +0 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +0 -73
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +0 -1
- package/build/__tests__/EntityMutator-test.d.ts +0 -1
- package/build/__tests__/EntityMutator-test.js +0 -741
- package/build/__tests__/EntityMutator-test.js.map +0 -1
- package/build/__tests__/EntityPrivacyPolicy-test.d.ts +0 -1
- package/build/__tests__/EntityPrivacyPolicy-test.js +0 -463
- package/build/__tests__/EntityPrivacyPolicy-test.js.map +0 -1
- package/build/__tests__/EntityQueryContext-test.d.ts +0 -1
- package/build/__tests__/EntityQueryContext-test.js +0 -116
- package/build/__tests__/EntityQueryContext-test.js.map +0 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.d.ts +0 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.js +0 -60
- package/build/__tests__/EntitySecondaryCacheLoader-test.js.map +0 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.d.ts +0 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.js +0 -201
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +0 -1
- package/build/__tests__/GenericEntityCacheAdapter-test.d.ts +0 -1
- package/build/__tests__/GenericEntityCacheAdapter-test.js +0 -80
- package/build/__tests__/GenericEntityCacheAdapter-test.js.map +0 -1
- package/build/__tests__/ReadonlyEntity-test.d.ts +0 -1
- package/build/__tests__/ReadonlyEntity-test.js +0 -211
- package/build/__tests__/ReadonlyEntity-test.js.map +0 -1
- package/build/__tests__/ViewerContext-test.d.ts +0 -1
- package/build/__tests__/ViewerContext-test.js +0 -30
- package/build/__tests__/ViewerContext-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityCompanion-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityCompanion-test.js +0 -20
- package/build/__tests__/ViewerScopedEntityCompanion-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js +0 -20
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js +0 -23
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js +0 -22
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js.map +0 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.d.ts +0 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +0 -123
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +0 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.d.ts +0 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +0 -121
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +0 -1
- package/build/__tests__/entityUtils-test.d.ts +0 -1
- package/build/__tests__/entityUtils-test.js +0 -87
- package/build/__tests__/entityUtils-test.js.map +0 -1
- package/build/internal/__tests__/EntityDataManager-test.d.ts +0 -1
- package/build/internal/__tests__/EntityDataManager-test.js +0 -373
- package/build/internal/__tests__/EntityDataManager-test.js.map +0 -1
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.d.ts +0 -1
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js +0 -136
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js.map +0 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.d.ts +0 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.js +0 -206
- package/build/internal/__tests__/ReadThroughEntityCache-test.js.map +0 -1
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.d.ts +0 -1
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js +0 -21
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js.map +0 -1
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.d.ts +0 -1
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js +0 -21
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js.map +0 -1
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.d.ts +0 -1
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js +0 -21
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js.map +0 -1
- package/build/testfixtures/DateIDTestEntity.d.ts +0 -19
- package/build/testfixtures/DateIDTestEntity.js +0 -48
- package/build/testfixtures/DateIDTestEntity.js.map +0 -1
- package/build/testfixtures/SimpleTestEntity.d.ts +0 -20
- package/build/testfixtures/SimpleTestEntity.js +0 -48
- package/build/testfixtures/SimpleTestEntity.js.map +0 -1
- package/build/testfixtures/TestEntity.d.ts +0 -30
- package/build/testfixtures/TestEntity.js +0 -93
- package/build/testfixtures/TestEntity.js.map +0 -1
- package/build/testfixtures/TestEntity2.d.ts +0 -20
- package/build/testfixtures/TestEntity2.js +0 -51
- package/build/testfixtures/TestEntity2.js.map +0 -1
- package/build/testfixtures/TestEntityNumberKey.d.ts +0 -19
- package/build/testfixtures/TestEntityNumberKey.js +0 -48
- package/build/testfixtures/TestEntityNumberKey.js.map +0 -1
- package/build/testfixtures/TestEntityWithMutationTriggers.d.ts +0 -36
- package/build/testfixtures/TestEntityWithMutationTriggers.js +0 -82
- package/build/testfixtures/TestEntityWithMutationTriggers.js.map +0 -1
- package/build/testfixtures/TestViewerContext.d.ts +0 -3
- package/build/testfixtures/TestViewerContext.js +0 -10
- package/build/testfixtures/TestViewerContext.js.map +0 -1
- package/build/utils/__tests__/EntityPrivacyUtils-test.d.ts +0 -1
- package/build/utils/__tests__/EntityPrivacyUtils-test.js +0 -486
- package/build/utils/__tests__/EntityPrivacyUtils-test.js.map +0 -1
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.d.ts +0 -1
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js +0 -178
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js.map +0 -1
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.d.ts +0 -1
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js +0 -26
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js.map +0 -1
- package/build/utils/collections/__tests__/maps-test.d.ts +0 -1
- package/build/utils/collections/__tests__/maps-test.js +0 -120
- package/build/utils/collections/__tests__/maps-test.js.map +0 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.d.ts +0 -28
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js +0 -52
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js.map +0 -1
- package/build/utils/testing/StubCacheAdapter.d.ts +0 -27
- package/build/utils/testing/StubCacheAdapter.js +0 -86
- package/build/utils/testing/StubCacheAdapter.js.map +0 -1
- package/build/utils/testing/StubDatabaseAdapter.d.ts +0 -25
- package/build/utils/testing/StubDatabaseAdapter.js +0 -191
- package/build/utils/testing/StubDatabaseAdapter.js.map +0 -1
- package/build/utils/testing/StubDatabaseAdapterProvider.d.ts +0 -7
- package/build/utils/testing/StubDatabaseAdapterProvider.js +0 -14
- package/build/utils/testing/StubDatabaseAdapterProvider.js.map +0 -1
- package/build/utils/testing/StubQueryContextProvider.d.ts +0 -7
- package/build/utils/testing/StubQueryContextProvider.js +0 -19
- package/build/utils/testing/StubQueryContextProvider.js.map +0 -1
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.d.ts +0 -1
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js +0 -42
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js.map +0 -1
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.d.ts +0 -1
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js +0 -402
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js.map +0 -1
- package/build/utils/testing/createUnitTestEntityCompanionProvider.d.ts +0 -7
- package/build/utils/testing/createUnitTestEntityCompanionProvider.js +0 -36
- package/build/utils/testing/createUnitTestEntityCompanionProvider.js.map +0 -1
- package/build/utils/testing/describeFieldTestCase.d.ts +0 -2
- package/build/utils/testing/describeFieldTestCase.js +0 -18
- package/build/utils/testing/describeFieldTestCase.js.map +0 -1
- package/src/testfixtures/DateIDTestEntity.ts +0 -59
- package/src/testfixtures/TestEntityNumberKey.ts +0 -59
- package/src/utils/testing/StubCacheAdapter.ts +0 -122
- package/src/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.ts +0 -42
- package/src/utils/testing/__tests__/StubDatabaseAdapter-test.ts +0 -548
- /package/src/utils/{testing → __testfixtures__}/StubQueryContextProvider.ts +0 -0
- /package/src/utils/{testing → __testfixtures__}/createUnitTestEntityCompanionProvider.ts +0 -0
|
@@ -3,7 +3,10 @@ import invariant from 'invariant';
|
|
|
3
3
|
import nullthrows from 'nullthrows';
|
|
4
4
|
|
|
5
5
|
import { IEntityClass } from './Entity';
|
|
6
|
-
import EntityConfiguration
|
|
6
|
+
import EntityConfiguration, {
|
|
7
|
+
EntityCompositeField,
|
|
8
|
+
EntityCompositeFieldValue,
|
|
9
|
+
} from './EntityConfiguration';
|
|
7
10
|
import {
|
|
8
11
|
FieldEqualityCondition,
|
|
9
12
|
QuerySelectionModifiers,
|
|
@@ -17,9 +20,13 @@ import ReadonlyEntity from './ReadonlyEntity';
|
|
|
17
20
|
import ViewerContext from './ViewerContext';
|
|
18
21
|
import EntityInvalidFieldValueError from './errors/EntityInvalidFieldValueError';
|
|
19
22
|
import EntityNotFoundError from './errors/EntityNotFoundError';
|
|
23
|
+
import { CompositeFieldValueHolder, CompositeFieldHolder } from './internal/CompositeFieldHolder';
|
|
24
|
+
import { CompositeFieldValueMap } from './internal/CompositeFieldValueMap';
|
|
20
25
|
import EntityDataManager from './internal/EntityDataManager';
|
|
26
|
+
import { SingleFieldHolder, SingleFieldValueHolder } from './internal/SingleFieldHolder';
|
|
21
27
|
import IEntityMetricsAdapter from './metrics/IEntityMetricsAdapter';
|
|
22
|
-
import { mapMap } from './utils/collections/maps';
|
|
28
|
+
import { mapKeys, mapMap } from './utils/collections/maps';
|
|
29
|
+
import { areSetsEqual } from './utils/collections/sets';
|
|
23
30
|
|
|
24
31
|
/**
|
|
25
32
|
* Authorization-result-based entity loader. All normal loads are batched,
|
|
@@ -28,13 +35,13 @@ import { mapMap } from './utils/collections/maps';
|
|
|
28
35
|
* means an authorization error or entity construction error occurred. Other errors are thrown.
|
|
29
36
|
*/
|
|
30
37
|
export default class AuthorizationResultBasedEntityLoader<
|
|
31
|
-
TFields extends
|
|
32
|
-
|
|
38
|
+
TFields extends Record<string, any>,
|
|
39
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
33
40
|
TViewerContext extends ViewerContext,
|
|
34
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
41
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
35
42
|
TPrivacyPolicy extends EntityPrivacyPolicy<
|
|
36
43
|
TFields,
|
|
37
|
-
|
|
44
|
+
TIDField,
|
|
38
45
|
TViewerContext,
|
|
39
46
|
TEntity,
|
|
40
47
|
TSelectedFields
|
|
@@ -43,20 +50,20 @@ export default class AuthorizationResultBasedEntityLoader<
|
|
|
43
50
|
> {
|
|
44
51
|
constructor(
|
|
45
52
|
private readonly queryContext: EntityQueryContext,
|
|
46
|
-
private readonly entityConfiguration: EntityConfiguration<TFields>,
|
|
53
|
+
private readonly entityConfiguration: EntityConfiguration<TFields, TIDField>,
|
|
47
54
|
private readonly entityClass: IEntityClass<
|
|
48
55
|
TFields,
|
|
49
|
-
|
|
56
|
+
TIDField,
|
|
50
57
|
TViewerContext,
|
|
51
58
|
TEntity,
|
|
52
59
|
TPrivacyPolicy,
|
|
53
60
|
TSelectedFields
|
|
54
61
|
>,
|
|
55
|
-
private readonly dataManager: EntityDataManager<TFields>,
|
|
62
|
+
private readonly dataManager: EntityDataManager<TFields, TIDField>,
|
|
56
63
|
protected readonly metricsAdapter: IEntityMetricsAdapter,
|
|
57
64
|
public readonly utils: EntityLoaderUtils<
|
|
58
65
|
TFields,
|
|
59
|
-
|
|
66
|
+
TIDField,
|
|
60
67
|
TViewerContext,
|
|
61
68
|
TEntity,
|
|
62
69
|
TPrivacyPolicy,
|
|
@@ -65,9 +72,7 @@ export default class AuthorizationResultBasedEntityLoader<
|
|
|
65
72
|
) {}
|
|
66
73
|
|
|
67
74
|
/**
|
|
68
|
-
*
|
|
69
|
-
* @param fieldName - entity field being queried
|
|
70
|
-
* @param fieldValues - fieldName field values being queried
|
|
75
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
71
76
|
* @returns map from fieldValue to entity results that match the query for that fieldValue,
|
|
72
77
|
* where result errors can be UnauthorizedError
|
|
73
78
|
*/
|
|
@@ -75,21 +80,51 @@ export default class AuthorizationResultBasedEntityLoader<
|
|
|
75
80
|
fieldName: N,
|
|
76
81
|
fieldValues: readonly NonNullable<TFields[N]>[],
|
|
77
82
|
): Promise<ReadonlyMap<NonNullable<TFields[N]>, readonly Result<TEntity>[]>> {
|
|
78
|
-
this.
|
|
79
|
-
|
|
80
|
-
const fieldValuesToFieldObjects = await this.dataManager.loadManyByFieldEqualingAsync(
|
|
81
|
-
this.queryContext,
|
|
83
|
+
const { loadKey, loadValues } = this.validateFieldAndValuesAndConvertToHolders(
|
|
82
84
|
fieldName,
|
|
83
85
|
fieldValues,
|
|
84
86
|
);
|
|
85
87
|
|
|
88
|
+
const loadValuesToFieldObjects = await this.dataManager.loadManyEqualingAsync(
|
|
89
|
+
this.queryContext,
|
|
90
|
+
loadKey,
|
|
91
|
+
loadValues,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const fieldValuesToFieldObjects = mapKeys(
|
|
95
|
+
loadValuesToFieldObjects,
|
|
96
|
+
(loadValue) => loadValue.fieldValue,
|
|
97
|
+
);
|
|
86
98
|
return await this.utils.constructAndAuthorizeEntitiesAsync(fieldValuesToFieldObjects);
|
|
87
99
|
}
|
|
88
100
|
|
|
89
101
|
/**
|
|
90
|
-
*
|
|
91
|
-
* @
|
|
92
|
-
*
|
|
102
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
103
|
+
* @returns map from compositeField to entity results that match the query for that compositeField,
|
|
104
|
+
* where result errors can be UnauthorizedError
|
|
105
|
+
*/
|
|
106
|
+
async loadManyByCompositeFieldEqualingManyAsync<
|
|
107
|
+
N extends EntityCompositeField<Pick<TFields, TSelectedFields>>,
|
|
108
|
+
>(
|
|
109
|
+
compositeField: N,
|
|
110
|
+
compositeFieldValues: readonly EntityCompositeFieldValue<Pick<TFields, TSelectedFields>, N>[],
|
|
111
|
+
): Promise<ReadonlyMap<EntityCompositeFieldValue<TFields, N>, readonly Result<TEntity>[]>> {
|
|
112
|
+
const { compositeFieldHolder, compositeFieldValueHolders } =
|
|
113
|
+
this.validateCompositeFieldAndValuesAndConvertToHolders(compositeField, compositeFieldValues);
|
|
114
|
+
|
|
115
|
+
const compositeFieldValuesToFieldObjects = await this.dataManager.loadManyEqualingAsync(
|
|
116
|
+
this.queryContext,
|
|
117
|
+
compositeFieldHolder,
|
|
118
|
+
compositeFieldValueHolders,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
return await this.constructAndAuthorizeEntitiesFromCompositeFieldValueHolderMapAsync(
|
|
122
|
+
compositeFieldValuesToFieldObjects,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
93
128
|
* @returns array of entity results that match the query for fieldValue, where result error can be UnauthorizedError
|
|
94
129
|
*/
|
|
95
130
|
async loadManyByFieldEqualingAsync<N extends keyof Pick<TFields, TSelectedFields>>(
|
|
@@ -106,9 +141,28 @@ export default class AuthorizationResultBasedEntityLoader<
|
|
|
106
141
|
}
|
|
107
142
|
|
|
108
143
|
/**
|
|
109
|
-
*
|
|
110
|
-
* @
|
|
111
|
-
|
|
144
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
145
|
+
* @returns array of entity results that match the query for compositeFieldValue, where result error can be UnauthorizedError
|
|
146
|
+
*/
|
|
147
|
+
async loadManyByCompositeFieldEqualingAsync<
|
|
148
|
+
N extends EntityCompositeField<Pick<TFields, TSelectedFields>>,
|
|
149
|
+
>(
|
|
150
|
+
compositeField: N,
|
|
151
|
+
compositeFieldValue: EntityCompositeFieldValue<Pick<TFields, TSelectedFields>, N>,
|
|
152
|
+
): Promise<readonly Result<TEntity>[]> {
|
|
153
|
+
const entityResults = await this.loadManyByCompositeFieldEqualingManyAsync(compositeField, [
|
|
154
|
+
compositeFieldValue,
|
|
155
|
+
]);
|
|
156
|
+
const entityResultForCompositeFieldValue = entityResults.get(compositeFieldValue);
|
|
157
|
+
invariant(
|
|
158
|
+
entityResultForCompositeFieldValue !== undefined,
|
|
159
|
+
`${compositeFieldValue} should be guaranteed to be present in returned map of entities`,
|
|
160
|
+
);
|
|
161
|
+
return entityResultForCompositeFieldValue;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
112
166
|
* @returns entity result where uniqueFieldName equals fieldValue, or null if no entity matches the condition.
|
|
113
167
|
* @throws when multiple entities match the condition
|
|
114
168
|
*/
|
|
@@ -127,22 +181,41 @@ export default class AuthorizationResultBasedEntityLoader<
|
|
|
127
181
|
}
|
|
128
182
|
|
|
129
183
|
/**
|
|
130
|
-
*
|
|
131
|
-
* @
|
|
184
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
185
|
+
* @returns entity result where uniqueFieldName equals fieldValue, where result error can be UnauthorizedError.
|
|
186
|
+
*/
|
|
187
|
+
async loadByCompositeFieldEqualingAsync<
|
|
188
|
+
N extends EntityCompositeField<Pick<TFields, TSelectedFields>>,
|
|
189
|
+
>(
|
|
190
|
+
compositeField: N,
|
|
191
|
+
compositeFieldValue: EntityCompositeFieldValue<Pick<TFields, TSelectedFields>, N>,
|
|
192
|
+
): Promise<Result<TEntity> | null> {
|
|
193
|
+
const entityResults = await this.loadManyByCompositeFieldEqualingAsync(
|
|
194
|
+
compositeField,
|
|
195
|
+
compositeFieldValue,
|
|
196
|
+
);
|
|
197
|
+
invariant(
|
|
198
|
+
entityResults.length <= 1,
|
|
199
|
+
`loadByCompositeFieldEqualing: Multiple entities of type ${this.entityClass.name} found for composite field (${compositeField.join(',')})=${JSON.stringify(compositeFieldValue)}`,
|
|
200
|
+
);
|
|
201
|
+
return entityResults[0] ?? null;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
132
206
|
* @returns entity result for matching ID, where result error can be UnauthorizedError or EntityNotFoundError.
|
|
133
207
|
*/
|
|
134
|
-
async loadByIDAsync(id:
|
|
208
|
+
async loadByIDAsync(id: TFields[TIDField]): Promise<Result<TEntity>> {
|
|
135
209
|
const entityResults = await this.loadManyByIDsAsync([id]);
|
|
136
210
|
// loadManyByIDsAsync is always populated for each id supplied
|
|
137
211
|
return nullthrows(entityResults.get(id));
|
|
138
212
|
}
|
|
139
213
|
|
|
140
214
|
/**
|
|
141
|
-
*
|
|
142
|
-
* @param id - ID of the entity
|
|
215
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
143
216
|
* @returns entity result for matching ID, or null if no entity exists for ID.
|
|
144
217
|
*/
|
|
145
|
-
async loadByIDNullableAsync(id:
|
|
218
|
+
async loadByIDNullableAsync(id: TFields[TIDField]): Promise<Result<TEntity> | null> {
|
|
146
219
|
return await this.loadByFieldEqualingAsync(
|
|
147
220
|
this.entityConfiguration.idField as TSelectedFields,
|
|
148
221
|
id,
|
|
@@ -150,15 +223,16 @@ export default class AuthorizationResultBasedEntityLoader<
|
|
|
150
223
|
}
|
|
151
224
|
|
|
152
225
|
/**
|
|
153
|
-
*
|
|
154
|
-
* @param ids - IDs of the entities to load
|
|
226
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
155
227
|
* @returns map from ID to corresponding entity result, where result error can be UnauthorizedError or EntityNotFoundError.
|
|
156
228
|
*/
|
|
157
|
-
async loadManyByIDsAsync(
|
|
229
|
+
async loadManyByIDsAsync(
|
|
230
|
+
ids: readonly TFields[TIDField][],
|
|
231
|
+
): Promise<ReadonlyMap<TFields[TIDField], Result<TEntity>>> {
|
|
158
232
|
const entityResults = (await this.loadManyByFieldEqualingManyAsync(
|
|
159
233
|
this.entityConfiguration.idField as TSelectedFields,
|
|
160
234
|
ids,
|
|
161
|
-
)) as ReadonlyMap<
|
|
235
|
+
)) as ReadonlyMap<TFields[TIDField], readonly Result<TEntity>[]>;
|
|
162
236
|
return mapMap(entityResults, (entityResultsForId, id) => {
|
|
163
237
|
const entityResult = entityResultsForId[0];
|
|
164
238
|
return (
|
|
@@ -169,33 +243,23 @@ export default class AuthorizationResultBasedEntityLoader<
|
|
|
169
243
|
}
|
|
170
244
|
|
|
171
245
|
/**
|
|
172
|
-
*
|
|
173
|
-
* @
|
|
174
|
-
* @returns map from ID to nullable corresponding entity result, where result error can be UnauthorizedError or EntityNotFoundError.
|
|
246
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
247
|
+
* @returns map from ID to nullable corresponding entity result, where result error can be UnauthorizedError.
|
|
175
248
|
*/
|
|
176
249
|
async loadManyByIDsNullableAsync(
|
|
177
|
-
ids: readonly
|
|
178
|
-
): Promise<ReadonlyMap<
|
|
250
|
+
ids: readonly TFields[TIDField][],
|
|
251
|
+
): Promise<ReadonlyMap<TFields[TIDField], Result<TEntity> | null>> {
|
|
179
252
|
const entityResults = (await this.loadManyByFieldEqualingManyAsync(
|
|
180
253
|
this.entityConfiguration.idField as TSelectedFields,
|
|
181
254
|
ids,
|
|
182
|
-
)) as ReadonlyMap<
|
|
255
|
+
)) as ReadonlyMap<TFields[TIDField], readonly Result<TEntity>[]>;
|
|
183
256
|
return mapMap(entityResults, (entityResultsForId) => {
|
|
184
257
|
return entityResultsForId[0] ?? null;
|
|
185
258
|
});
|
|
186
259
|
}
|
|
187
260
|
|
|
188
261
|
/**
|
|
189
|
-
*
|
|
190
|
-
* operands, or null if no matching entity exists. Entities loaded using this method are not
|
|
191
|
-
* batched or cached.
|
|
192
|
-
*
|
|
193
|
-
* This is a convenience method for {@link loadManyByFieldEqualityConjunctionAsync}. However, the
|
|
194
|
-
* `orderBy` option must be specified to define what "first" means. If ordering doesn't matter,
|
|
195
|
-
* explicitly pass in an empty array.
|
|
196
|
-
*
|
|
197
|
-
* @param fieldEqualityOperands - list of field equality selection operand specifications
|
|
198
|
-
* @param querySelectionModifiers - orderBy and optional offset for the query
|
|
262
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
199
263
|
* @returns the first entity results that matches the query, where result error can be
|
|
200
264
|
* UnauthorizedError
|
|
201
265
|
*/
|
|
@@ -212,17 +276,7 @@ export default class AuthorizationResultBasedEntityLoader<
|
|
|
212
276
|
}
|
|
213
277
|
|
|
214
278
|
/**
|
|
215
|
-
*
|
|
216
|
-
* Entities loaded using this method are not batched or cached.
|
|
217
|
-
*
|
|
218
|
-
* @example
|
|
219
|
-
* fieldEqualityOperands:
|
|
220
|
-
* `[{fieldName: 'hello', fieldValue: 1}, {fieldName: 'world', fieldValues: [2, 3]}]`
|
|
221
|
-
* Entities returned with a SQL EntityDatabaseAdapter:
|
|
222
|
-
* `WHERE hello = 1 AND world = ANY({2, 3})`
|
|
223
|
-
*
|
|
224
|
-
* @param fieldEqualityOperands - list of field equality selection operand specifications
|
|
225
|
-
* @param querySelectionModifiers - limit, offset, and orderBy for the query
|
|
279
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
226
280
|
* @returns array of entity results that match the query, where result error can be UnauthorizedError
|
|
227
281
|
*/
|
|
228
282
|
async loadManyByFieldEqualityConjunctionAsync<N extends keyof Pick<TFields, TSelectedFields>>(
|
|
@@ -233,7 +287,7 @@ export default class AuthorizationResultBasedEntityLoader<
|
|
|
233
287
|
const fieldValues = isSingleValueFieldEqualityCondition(fieldEqualityOperand)
|
|
234
288
|
? [fieldEqualityOperand.fieldValue]
|
|
235
289
|
: fieldEqualityOperand.fieldValues;
|
|
236
|
-
this.
|
|
290
|
+
this.validateFieldAndValues(fieldEqualityOperand.fieldName, fieldValues);
|
|
237
291
|
}
|
|
238
292
|
|
|
239
293
|
const fieldObjects = await this.dataManager.loadManyByFieldEqualityConjunctionAsync(
|
|
@@ -245,25 +299,7 @@ export default class AuthorizationResultBasedEntityLoader<
|
|
|
245
299
|
}
|
|
246
300
|
|
|
247
301
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
* @remarks
|
|
251
|
-
* Important notes:
|
|
252
|
-
* - Fields in clause are database column names instead of transformed entity field names.
|
|
253
|
-
* - Entities loaded using this method are not batched or cached.
|
|
254
|
-
* - Not all database adapters implement the ability to execute this method of fetching entities.
|
|
255
|
-
*
|
|
256
|
-
* @example
|
|
257
|
-
* rawWhereClause: `id = ?`
|
|
258
|
-
* bindings: `[1]`
|
|
259
|
-
* Entites returned `WHERE id = 1`
|
|
260
|
-
*
|
|
261
|
-
* http://knexjs.org/#Builder-whereRaw
|
|
262
|
-
* http://knexjs.org/#Raw-Bindings
|
|
263
|
-
*
|
|
264
|
-
* @param rawWhereClause - parameterized SQL WHERE clause with positional binding placeholders or named binding placeholders
|
|
265
|
-
* @param bindings - array of positional bindings or object of named bindings
|
|
266
|
-
* @param querySelectionModifiers - limit, offset, orderBy, and orderByRaw for the query
|
|
302
|
+
* Authorization-result-based version of the EnforcingEntityLoader method by the same name.
|
|
267
303
|
* @returns array of entity results that match the query, where result error can be UnauthorizedError
|
|
268
304
|
* @throws Error when rawWhereClause or bindings are invalid
|
|
269
305
|
*/
|
|
@@ -281,7 +317,7 @@ export default class AuthorizationResultBasedEntityLoader<
|
|
|
281
317
|
return await this.utils.constructAndAuthorizeEntitiesArrayAsync(fieldObjects);
|
|
282
318
|
}
|
|
283
319
|
|
|
284
|
-
private
|
|
320
|
+
private validateFieldAndValues<N extends keyof Pick<TFields, TSelectedFields>>(
|
|
285
321
|
fieldName: N,
|
|
286
322
|
fieldValues: readonly TFields[N][],
|
|
287
323
|
): void {
|
|
@@ -294,4 +330,81 @@ export default class AuthorizationResultBasedEntityLoader<
|
|
|
294
330
|
}
|
|
295
331
|
}
|
|
296
332
|
}
|
|
333
|
+
|
|
334
|
+
private validateFieldAndValuesAndConvertToHolders<N extends keyof Pick<TFields, TSelectedFields>>(
|
|
335
|
+
fieldName: N,
|
|
336
|
+
fieldValues: readonly NonNullable<TFields[N]>[],
|
|
337
|
+
): {
|
|
338
|
+
loadKey: SingleFieldHolder<TFields, TIDField, N>;
|
|
339
|
+
loadValues: readonly SingleFieldValueHolder<TFields, N>[];
|
|
340
|
+
} {
|
|
341
|
+
this.validateFieldAndValues(fieldName, fieldValues);
|
|
342
|
+
|
|
343
|
+
return {
|
|
344
|
+
loadKey: new SingleFieldHolder<TFields, TIDField, N>(fieldName),
|
|
345
|
+
loadValues: fieldValues.map(
|
|
346
|
+
(fieldValue) => new SingleFieldValueHolder<TFields, N>(fieldValue),
|
|
347
|
+
),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
private validateCompositeFieldAndValuesAndConvertToHolders<
|
|
352
|
+
N extends EntityCompositeField<Pick<TFields, TSelectedFields>>,
|
|
353
|
+
>(
|
|
354
|
+
compositeField: N,
|
|
355
|
+
compositeFieldValues: readonly EntityCompositeFieldValue<TFields, N>[],
|
|
356
|
+
): {
|
|
357
|
+
compositeFieldHolder: CompositeFieldHolder<TFields, TIDField>;
|
|
358
|
+
compositeFieldValueHolders: readonly CompositeFieldValueHolder<TFields, N>[];
|
|
359
|
+
} {
|
|
360
|
+
// validate that the composite field input is defined in the entity configuration
|
|
361
|
+
const compositeFieldHolder =
|
|
362
|
+
this.entityConfiguration.compositeFieldInfo.getCompositeFieldHolderForCompositeField(
|
|
363
|
+
compositeField,
|
|
364
|
+
);
|
|
365
|
+
invariant(
|
|
366
|
+
compositeFieldHolder,
|
|
367
|
+
`must have composite field definition for composite field = ${String(compositeField)}`,
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
const cacheableCompositeFieldFieldsSet = compositeFieldHolder.getFieldSet();
|
|
371
|
+
|
|
372
|
+
const compositeFieldValueHolders = compositeFieldValues.map(
|
|
373
|
+
(compositeFieldValue) => new CompositeFieldValueHolder(compositeFieldValue),
|
|
374
|
+
);
|
|
375
|
+
|
|
376
|
+
// validate that the composite field values are valid
|
|
377
|
+
for (const compositeFieldValueHolder of compositeFieldValueHolders) {
|
|
378
|
+
invariant(
|
|
379
|
+
areSetsEqual(cacheableCompositeFieldFieldsSet, compositeFieldValueHolder.getFieldSet()),
|
|
380
|
+
`composite field values must contain exactly the fields defined in the composite field definition: ${compositeField}`,
|
|
381
|
+
);
|
|
382
|
+
for (const field of compositeField) {
|
|
383
|
+
const fieldValue = compositeFieldValueHolder.compositeFieldValue[field];
|
|
384
|
+
this.validateFieldAndValues(field, [fieldValue]);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return {
|
|
389
|
+
compositeFieldHolder,
|
|
390
|
+
compositeFieldValueHolders,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
private async constructAndAuthorizeEntitiesFromCompositeFieldValueHolderMapAsync<
|
|
395
|
+
N extends EntityCompositeField<Pick<TFields, TSelectedFields>>,
|
|
396
|
+
>(
|
|
397
|
+
map: ReadonlyMap<CompositeFieldValueHolder<TFields, N>, readonly Readonly<TFields>[]>,
|
|
398
|
+
): Promise<ReadonlyMap<EntityCompositeFieldValue<TFields, N>, readonly Result<TEntity>[]>> {
|
|
399
|
+
return new CompositeFieldValueMap(
|
|
400
|
+
await Promise.all(
|
|
401
|
+
Array.from(map.entries()).map(async ([compositeFieldValueHolder, fieldObjects]) => {
|
|
402
|
+
return [
|
|
403
|
+
compositeFieldValueHolder,
|
|
404
|
+
await this.utils.constructAndAuthorizeEntitiesArrayAsync(fieldObjects),
|
|
405
|
+
];
|
|
406
|
+
}),
|
|
407
|
+
),
|
|
408
|
+
);
|
|
409
|
+
}
|
|
297
410
|
}
|