@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.
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { enforceAsyncResult } from '@expo/results';
|
|
2
|
-
import { mock, instance, verify, spy,
|
|
2
|
+
import { mock, instance, verify, spy, anyOfClass, anything, when } from 'ts-mockito';
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
4
|
|
|
5
5
|
import AuthorizationResultBasedEntityLoader from '../AuthorizationResultBasedEntityLoader';
|
|
@@ -9,17 +9,24 @@ import { EntityPrivacyPolicyEvaluationContext } from '../EntityPrivacyPolicy';
|
|
|
9
9
|
import ViewerContext from '../ViewerContext';
|
|
10
10
|
import { enforceResultsAsync } from '../entityUtils';
|
|
11
11
|
import EntityNotFoundError from '../errors/EntityNotFoundError';
|
|
12
|
+
import { CompositeFieldHolder, CompositeFieldValueHolder } from '../internal/CompositeFieldHolder';
|
|
12
13
|
import EntityDataManager from '../internal/EntityDataManager';
|
|
13
14
|
import ReadThroughEntityCache from '../internal/ReadThroughEntityCache';
|
|
15
|
+
import {
|
|
16
|
+
SingleFieldHolder,
|
|
17
|
+
SingleFieldValueHolder,
|
|
18
|
+
SingleFieldValueHolderMap,
|
|
19
|
+
} from '../internal/SingleFieldHolder';
|
|
14
20
|
import IEntityMetricsAdapter from '../metrics/IEntityMetricsAdapter';
|
|
21
|
+
import { NoCacheStubCacheAdapterProvider } from '../utils/__testfixtures__/StubCacheAdapter';
|
|
22
|
+
import StubDatabaseAdapter from '../utils/__testfixtures__/StubDatabaseAdapter';
|
|
23
|
+
import StubQueryContextProvider from '../utils/__testfixtures__/StubQueryContextProvider';
|
|
24
|
+
import { deepEqualEntityAware } from '../utils/__testfixtures__/TSMockitoExtensions';
|
|
15
25
|
import TestEntity, {
|
|
16
26
|
TestFields,
|
|
17
27
|
TestEntityPrivacyPolicy,
|
|
18
28
|
testEntityConfiguration,
|
|
19
|
-
} from '../
|
|
20
|
-
import { NoCacheStubCacheAdapterProvider } from '../utils/testing/StubCacheAdapter';
|
|
21
|
-
import StubDatabaseAdapter from '../utils/testing/StubDatabaseAdapter';
|
|
22
|
-
import StubQueryContextProvider from '../utils/testing/StubQueryContextProvider';
|
|
29
|
+
} from '../utils/__testfixtures__/TestEntity';
|
|
23
30
|
|
|
24
31
|
describe(AuthorizationResultBasedEntityLoader, () => {
|
|
25
32
|
it('loads entities', async () => {
|
|
@@ -27,14 +34,21 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
27
34
|
const viewerContext = instance(mock(ViewerContext));
|
|
28
35
|
const privacyPolicyEvaluationContext =
|
|
29
36
|
instance(
|
|
30
|
-
mock<
|
|
37
|
+
mock<
|
|
38
|
+
EntityPrivacyPolicyEvaluationContext<
|
|
39
|
+
TestFields,
|
|
40
|
+
'customIdField',
|
|
41
|
+
ViewerContext,
|
|
42
|
+
TestEntity
|
|
43
|
+
>
|
|
44
|
+
>(),
|
|
31
45
|
);
|
|
32
46
|
const metricsAdapter = instance(mock<IEntityMetricsAdapter>());
|
|
33
47
|
const queryContext = new StubQueryContextProvider().getQueryContext();
|
|
34
48
|
|
|
35
49
|
const id1 = uuidv4();
|
|
36
50
|
const id2 = uuidv4();
|
|
37
|
-
const databaseAdapter = new StubDatabaseAdapter<TestFields>(
|
|
51
|
+
const databaseAdapter = new StubDatabaseAdapter<TestFields, 'customIdField'>(
|
|
38
52
|
testEntityConfiguration,
|
|
39
53
|
StubDatabaseAdapter.convertFieldObjectsToDataStore(
|
|
40
54
|
testEntityConfiguration,
|
|
@@ -141,13 +155,185 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
141
155
|
);
|
|
142
156
|
});
|
|
143
157
|
|
|
158
|
+
it('loads entities by composite fields', async () => {
|
|
159
|
+
const dateToInsert = new Date();
|
|
160
|
+
const viewerContext = instance(mock(ViewerContext));
|
|
161
|
+
const privacyPolicyEvaluationContext =
|
|
162
|
+
instance(
|
|
163
|
+
mock<
|
|
164
|
+
EntityPrivacyPolicyEvaluationContext<
|
|
165
|
+
TestFields,
|
|
166
|
+
'customIdField',
|
|
167
|
+
ViewerContext,
|
|
168
|
+
TestEntity
|
|
169
|
+
>
|
|
170
|
+
>(),
|
|
171
|
+
);
|
|
172
|
+
const metricsAdapter = instance(mock<IEntityMetricsAdapter>());
|
|
173
|
+
const queryContext = new StubQueryContextProvider().getQueryContext();
|
|
174
|
+
|
|
175
|
+
const id1 = uuidv4();
|
|
176
|
+
const id2 = uuidv4();
|
|
177
|
+
const id3 = uuidv4();
|
|
178
|
+
const id4 = uuidv4();
|
|
179
|
+
const databaseAdapter = new StubDatabaseAdapter<TestFields, 'customIdField'>(
|
|
180
|
+
testEntityConfiguration,
|
|
181
|
+
StubDatabaseAdapter.convertFieldObjectsToDataStore(
|
|
182
|
+
testEntityConfiguration,
|
|
183
|
+
new Map([
|
|
184
|
+
[
|
|
185
|
+
testEntityConfiguration.tableName,
|
|
186
|
+
[
|
|
187
|
+
{
|
|
188
|
+
customIdField: id1,
|
|
189
|
+
testIndexedField: 'h1',
|
|
190
|
+
intField: 5,
|
|
191
|
+
stringField: 'huh',
|
|
192
|
+
dateField: dateToInsert,
|
|
193
|
+
nullableField: null,
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
customIdField: id2,
|
|
197
|
+
testIndexedField: 'h2',
|
|
198
|
+
intField: 5,
|
|
199
|
+
stringField: 'huh',
|
|
200
|
+
dateField: dateToInsert,
|
|
201
|
+
nullableField: null,
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
customIdField: id3,
|
|
205
|
+
testIndexedField: 'h2',
|
|
206
|
+
intField: 3,
|
|
207
|
+
stringField: 'huh',
|
|
208
|
+
dateField: dateToInsert,
|
|
209
|
+
nullableField: null,
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
customIdField: id4,
|
|
213
|
+
stringField: 'huh3',
|
|
214
|
+
intField: 4,
|
|
215
|
+
testIndexedField: '7',
|
|
216
|
+
dateField: new Date(),
|
|
217
|
+
nullableField: 'non-null-nullable-field',
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
],
|
|
221
|
+
]),
|
|
222
|
+
),
|
|
223
|
+
);
|
|
224
|
+
const privacyPolicy = new TestEntityPrivacyPolicy();
|
|
225
|
+
const cacheAdapterProvider = new NoCacheStubCacheAdapterProvider();
|
|
226
|
+
const cacheAdapter = cacheAdapterProvider.getCacheAdapter(testEntityConfiguration);
|
|
227
|
+
const entityCache = new ReadThroughEntityCache(testEntityConfiguration, cacheAdapter);
|
|
228
|
+
const dataManager = new EntityDataManager(
|
|
229
|
+
databaseAdapter,
|
|
230
|
+
entityCache,
|
|
231
|
+
new StubQueryContextProvider(),
|
|
232
|
+
instance(mock<IEntityMetricsAdapter>()),
|
|
233
|
+
TestEntity.name,
|
|
234
|
+
);
|
|
235
|
+
const utils = new EntityLoaderUtils(
|
|
236
|
+
viewerContext,
|
|
237
|
+
queryContext,
|
|
238
|
+
privacyPolicyEvaluationContext,
|
|
239
|
+
testEntityConfiguration,
|
|
240
|
+
TestEntity,
|
|
241
|
+
/* entitySelectedFields */ undefined,
|
|
242
|
+
privacyPolicy,
|
|
243
|
+
dataManager,
|
|
244
|
+
metricsAdapter,
|
|
245
|
+
);
|
|
246
|
+
const entityLoader = new AuthorizationResultBasedEntityLoader(
|
|
247
|
+
queryContext,
|
|
248
|
+
testEntityConfiguration,
|
|
249
|
+
TestEntity,
|
|
250
|
+
dataManager,
|
|
251
|
+
metricsAdapter,
|
|
252
|
+
utils,
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
const entities = await enforceResultsAsync(
|
|
256
|
+
entityLoader.loadManyByCompositeFieldEqualingAsync(['stringField', 'intField'], {
|
|
257
|
+
stringField: 'huh',
|
|
258
|
+
intField: 5,
|
|
259
|
+
}),
|
|
260
|
+
);
|
|
261
|
+
expect(entities.map((m) => m.getID())).toEqual([id1, id2]);
|
|
262
|
+
|
|
263
|
+
const entityNullableCompositeValueResult = await entityLoader.loadByCompositeFieldEqualingAsync(
|
|
264
|
+
['nullableField', 'testIndexedField'],
|
|
265
|
+
{
|
|
266
|
+
nullableField: 'non-null-nullable-field',
|
|
267
|
+
testIndexedField: '7',
|
|
268
|
+
},
|
|
269
|
+
);
|
|
270
|
+
expect(entityNullableCompositeValueResult?.enforceValue().getID()).toBe(id4);
|
|
271
|
+
|
|
272
|
+
const entityResultDuplicateValues =
|
|
273
|
+
await entityLoader.loadManyByCompositeFieldEqualingManyAsync(
|
|
274
|
+
['stringField', 'intField'],
|
|
275
|
+
[
|
|
276
|
+
{ stringField: 'huh', intField: 5 },
|
|
277
|
+
{ stringField: 'huh', intField: 5 },
|
|
278
|
+
],
|
|
279
|
+
);
|
|
280
|
+
expect(entityResultDuplicateValues.size).toBe(1);
|
|
281
|
+
expect(
|
|
282
|
+
entityResultDuplicateValues
|
|
283
|
+
.get({ stringField: 'huh', intField: 5 })
|
|
284
|
+
?.map((m) => m.enforceValue().getID()),
|
|
285
|
+
).toEqual([id1, id2]);
|
|
286
|
+
|
|
287
|
+
const entityResultNoValues = await entityLoader.loadManyByCompositeFieldEqualingAsync(
|
|
288
|
+
['stringField', 'intField'],
|
|
289
|
+
{ stringField: 'huh', intField: 999 },
|
|
290
|
+
);
|
|
291
|
+
expect(entityResultNoValues).toHaveLength(0);
|
|
292
|
+
|
|
293
|
+
await expect(
|
|
294
|
+
entityLoader.loadByCompositeFieldEqualingAsync(['stringField', 'intField'], {
|
|
295
|
+
stringField: 'huh',
|
|
296
|
+
intField: 5,
|
|
297
|
+
}),
|
|
298
|
+
).rejects.toThrowError(
|
|
299
|
+
'loadByCompositeFieldEqualing: Multiple entities of type TestEntity found for composite field (stringField,intField)={"stringField":"huh","intField":5}',
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
// test the result map
|
|
303
|
+
const entityResultMap = await entityLoader.loadManyByCompositeFieldEqualingManyAsync(
|
|
304
|
+
['stringField', 'intField'],
|
|
305
|
+
[
|
|
306
|
+
{ stringField: 'huh', intField: 5 },
|
|
307
|
+
{ stringField: 'huh', intField: 3 },
|
|
308
|
+
],
|
|
309
|
+
);
|
|
310
|
+
expect(entityResultMap.size).toBe(2);
|
|
311
|
+
expect(
|
|
312
|
+
entityResultMap
|
|
313
|
+
.get({ stringField: 'huh', intField: 5 })
|
|
314
|
+
?.map((m) => m.enforceValue().getID()),
|
|
315
|
+
).toEqual([id1, id2]);
|
|
316
|
+
expect(
|
|
317
|
+
entityResultMap
|
|
318
|
+
.get({ stringField: 'huh', intField: 3 })
|
|
319
|
+
?.map((m) => m.enforceValue().getID()),
|
|
320
|
+
).toEqual([id3]);
|
|
321
|
+
});
|
|
322
|
+
|
|
144
323
|
it('loads entities with loadManyByFieldEqualityConjunction', async () => {
|
|
145
324
|
const privacyPolicy = new TestEntityPrivacyPolicy();
|
|
146
325
|
const spiedPrivacyPolicy = spy(privacyPolicy);
|
|
147
326
|
const viewerContext = instance(mock(ViewerContext));
|
|
148
327
|
const privacyPolicyEvaluationContext =
|
|
149
328
|
instance(
|
|
150
|
-
mock<
|
|
329
|
+
mock<
|
|
330
|
+
EntityPrivacyPolicyEvaluationContext<
|
|
331
|
+
TestFields,
|
|
332
|
+
'customIdField',
|
|
333
|
+
ViewerContext,
|
|
334
|
+
TestEntity
|
|
335
|
+
>
|
|
336
|
+
>(),
|
|
151
337
|
);
|
|
152
338
|
const metricsAdapter = instance(mock<IEntityMetricsAdapter>());
|
|
153
339
|
const queryContext = new StubQueryContextProvider().getQueryContext();
|
|
@@ -155,7 +341,7 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
155
341
|
const id1 = uuidv4();
|
|
156
342
|
const id2 = uuidv4();
|
|
157
343
|
const id3 = uuidv4();
|
|
158
|
-
const databaseAdapter = new StubDatabaseAdapter<TestFields>(
|
|
344
|
+
const databaseAdapter = new StubDatabaseAdapter<TestFields, 'customIdField'>(
|
|
159
345
|
testEntityConfiguration,
|
|
160
346
|
StubDatabaseAdapter.convertFieldObjectsToDataStore(
|
|
161
347
|
testEntityConfiguration,
|
|
@@ -257,7 +443,14 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
257
443
|
const viewerContext = instance(mock(ViewerContext));
|
|
258
444
|
const privacyPolicyEvaluationContext =
|
|
259
445
|
instance(
|
|
260
|
-
mock<
|
|
446
|
+
mock<
|
|
447
|
+
EntityPrivacyPolicyEvaluationContext<
|
|
448
|
+
TestFields,
|
|
449
|
+
'customIdField',
|
|
450
|
+
ViewerContext,
|
|
451
|
+
TestEntity
|
|
452
|
+
>
|
|
453
|
+
>(),
|
|
261
454
|
);
|
|
262
455
|
const metricsAdapter = instance(mock<IEntityMetricsAdapter>());
|
|
263
456
|
const queryContext = new StubQueryContextProvider().getQueryContext();
|
|
@@ -265,7 +458,7 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
265
458
|
const id1 = uuidv4();
|
|
266
459
|
const id2 = uuidv4();
|
|
267
460
|
const id3 = uuidv4();
|
|
268
|
-
const databaseAdapter = new StubDatabaseAdapter<TestFields>(
|
|
461
|
+
const databaseAdapter = new StubDatabaseAdapter<TestFields, 'customIdField'>(
|
|
269
462
|
testEntityConfiguration,
|
|
270
463
|
StubDatabaseAdapter.convertFieldObjectsToDataStore(
|
|
271
464
|
testEntityConfiguration,
|
|
@@ -364,12 +557,19 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
364
557
|
const viewerContext = instance(mock(ViewerContext));
|
|
365
558
|
const privacyPolicyEvaluationContext =
|
|
366
559
|
instance(
|
|
367
|
-
mock<
|
|
560
|
+
mock<
|
|
561
|
+
EntityPrivacyPolicyEvaluationContext<
|
|
562
|
+
TestFields,
|
|
563
|
+
'customIdField',
|
|
564
|
+
ViewerContext,
|
|
565
|
+
TestEntity
|
|
566
|
+
>
|
|
567
|
+
>(),
|
|
368
568
|
);
|
|
369
569
|
const metricsAdapter = instance(mock<IEntityMetricsAdapter>());
|
|
370
570
|
const queryContext = new StubQueryContextProvider().getQueryContext();
|
|
371
571
|
|
|
372
|
-
const dataManagerMock = mock<EntityDataManager<TestFields>>(EntityDataManager);
|
|
572
|
+
const dataManagerMock = mock<EntityDataManager<TestFields, 'customIdField'>>(EntityDataManager);
|
|
373
573
|
when(
|
|
374
574
|
dataManagerMock.loadManyByRawWhereClauseAsync(
|
|
375
575
|
queryContext,
|
|
@@ -432,13 +632,20 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
432
632
|
const viewerContext = instance(mock(ViewerContext));
|
|
433
633
|
const privacyPolicyEvaluationContext =
|
|
434
634
|
instance(
|
|
435
|
-
mock<
|
|
635
|
+
mock<
|
|
636
|
+
EntityPrivacyPolicyEvaluationContext<
|
|
637
|
+
TestFields,
|
|
638
|
+
'customIdField',
|
|
639
|
+
ViewerContext,
|
|
640
|
+
TestEntity
|
|
641
|
+
>
|
|
642
|
+
>(),
|
|
436
643
|
);
|
|
437
644
|
const metricsAdapter = instance(mock<IEntityMetricsAdapter>());
|
|
438
645
|
const queryContext = new StubQueryContextProvider().getQueryContext();
|
|
439
646
|
|
|
440
647
|
const id1 = uuidv4();
|
|
441
|
-
const databaseAdapter = new StubDatabaseAdapter<TestFields>(
|
|
648
|
+
const databaseAdapter = new StubDatabaseAdapter<TestFields, 'customIdField'>(
|
|
442
649
|
testEntityConfiguration,
|
|
443
650
|
StubDatabaseAdapter.convertFieldObjectsToDataStore(
|
|
444
651
|
testEntityConfiguration,
|
|
@@ -504,12 +711,19 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
504
711
|
const viewerContext = instance(mock(ViewerContext));
|
|
505
712
|
const privacyPolicyEvaluationContext =
|
|
506
713
|
instance(
|
|
507
|
-
mock<
|
|
714
|
+
mock<
|
|
715
|
+
EntityPrivacyPolicyEvaluationContext<
|
|
716
|
+
TestFields,
|
|
717
|
+
'customIdField',
|
|
718
|
+
ViewerContext,
|
|
719
|
+
TestEntity
|
|
720
|
+
>
|
|
721
|
+
>(),
|
|
508
722
|
);
|
|
509
723
|
const metricsAdapter = instance(mock<IEntityMetricsAdapter>());
|
|
510
724
|
const queryContext = new StubQueryContextProvider().getQueryContext();
|
|
511
725
|
const privacyPolicy = instance(mock(TestEntityPrivacyPolicy));
|
|
512
|
-
const dataManagerMock = mock<EntityDataManager<TestFields>>();
|
|
726
|
+
const dataManagerMock = mock<EntityDataManager<TestFields, 'customIdField'>>();
|
|
513
727
|
const dataManagerInstance = instance(dataManagerMock);
|
|
514
728
|
|
|
515
729
|
const id1 = uuidv4();
|
|
@@ -532,48 +746,54 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
532
746
|
metricsAdapter,
|
|
533
747
|
utils,
|
|
534
748
|
);
|
|
535
|
-
await entityLoader.utils.invalidateFieldsAsync({ customIdField: id1 } as any);
|
|
536
749
|
|
|
537
|
-
|
|
538
|
-
dataManagerMock.invalidateObjectFieldsAsync(deepEqual({ customIdField: id1 } as any)),
|
|
539
|
-
).once();
|
|
540
|
-
});
|
|
750
|
+
const date = new Date();
|
|
541
751
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
const privacyPolicy = instance(mock(TestEntityPrivacyPolicy));
|
|
551
|
-
const dataManagerMock = mock<EntityDataManager<TestFields>>();
|
|
552
|
-
const dataManagerInstance = instance(dataManagerMock);
|
|
752
|
+
await entityLoader.utils.invalidateFieldsAsync({
|
|
753
|
+
customIdField: id1,
|
|
754
|
+
testIndexedField: 'h1',
|
|
755
|
+
intField: 5,
|
|
756
|
+
stringField: 'huh',
|
|
757
|
+
dateField: date,
|
|
758
|
+
nullableField: null,
|
|
759
|
+
});
|
|
553
760
|
|
|
554
|
-
|
|
555
|
-
const utils = new EntityLoaderUtils(
|
|
556
|
-
viewerContext,
|
|
557
|
-
queryContext,
|
|
558
|
-
privacyPolicyEvaluationContext,
|
|
559
|
-
testEntityConfiguration,
|
|
560
|
-
TestEntity,
|
|
561
|
-
/* entitySelectedFields */ undefined,
|
|
562
|
-
privacyPolicy,
|
|
563
|
-
dataManagerInstance,
|
|
564
|
-
metricsAdapter,
|
|
565
|
-
);
|
|
566
|
-
const entityLoader = new AuthorizationResultBasedEntityLoader(
|
|
567
|
-
queryContext,
|
|
568
|
-
testEntityConfiguration,
|
|
569
|
-
TestEntity,
|
|
570
|
-
dataManagerInstance,
|
|
571
|
-
metricsAdapter,
|
|
572
|
-
utils,
|
|
573
|
-
);
|
|
574
|
-
await entityLoader.utils.invalidateFieldsAsync({ customIdField: id1 } as any);
|
|
761
|
+
verify(dataManagerMock.invalidateKeyValuePairsAsync(anything())).once();
|
|
575
762
|
verify(
|
|
576
|
-
dataManagerMock.
|
|
763
|
+
dataManagerMock.invalidateKeyValuePairsAsync(
|
|
764
|
+
deepEqualEntityAware([
|
|
765
|
+
[
|
|
766
|
+
new SingleFieldHolder<TestFields, 'customIdField', 'customIdField'>('customIdField'),
|
|
767
|
+
new SingleFieldValueHolder<TestFields, 'customIdField'>(id1),
|
|
768
|
+
],
|
|
769
|
+
[
|
|
770
|
+
new SingleFieldHolder<TestFields, 'customIdField', 'testIndexedField'>(
|
|
771
|
+
'testIndexedField',
|
|
772
|
+
),
|
|
773
|
+
new SingleFieldValueHolder<TestFields, 'testIndexedField'>('h1'),
|
|
774
|
+
],
|
|
775
|
+
[
|
|
776
|
+
new SingleFieldHolder<TestFields, 'customIdField', 'intField'>('intField'),
|
|
777
|
+
new SingleFieldValueHolder<TestFields, 'intField'>(5),
|
|
778
|
+
],
|
|
779
|
+
[
|
|
780
|
+
new SingleFieldHolder<TestFields, 'customIdField', 'stringField'>('stringField'),
|
|
781
|
+
new SingleFieldValueHolder<TestFields, 'stringField'>('huh'),
|
|
782
|
+
],
|
|
783
|
+
[
|
|
784
|
+
new SingleFieldHolder<TestFields, 'customIdField', 'dateField'>('dateField'),
|
|
785
|
+
new SingleFieldValueHolder<TestFields, 'dateField'>(date),
|
|
786
|
+
],
|
|
787
|
+
[
|
|
788
|
+
new CompositeFieldHolder(['stringField', 'intField']),
|
|
789
|
+
new CompositeFieldValueHolder({ stringField: 'huh', intField: 5 }),
|
|
790
|
+
],
|
|
791
|
+
[
|
|
792
|
+
new CompositeFieldHolder(['stringField', 'testIndexedField']),
|
|
793
|
+
new CompositeFieldValueHolder({ stringField: 'huh', testIndexedField: 'h1' }),
|
|
794
|
+
],
|
|
795
|
+
]),
|
|
796
|
+
),
|
|
577
797
|
).once();
|
|
578
798
|
});
|
|
579
799
|
|
|
@@ -581,17 +801,33 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
581
801
|
const viewerContext = instance(mock(ViewerContext));
|
|
582
802
|
const privacyPolicyEvaluationContext =
|
|
583
803
|
instance(
|
|
584
|
-
mock<
|
|
804
|
+
mock<
|
|
805
|
+
EntityPrivacyPolicyEvaluationContext<
|
|
806
|
+
TestFields,
|
|
807
|
+
'customIdField',
|
|
808
|
+
ViewerContext,
|
|
809
|
+
TestEntity
|
|
810
|
+
>
|
|
811
|
+
>(),
|
|
585
812
|
);
|
|
586
813
|
const metricsAdapter = instance(mock<IEntityMetricsAdapter>());
|
|
587
814
|
const queryContext = new StubQueryContextProvider().getQueryContext();
|
|
588
815
|
const privacyPolicy = instance(mock(TestEntityPrivacyPolicy));
|
|
589
|
-
const dataManagerMock = mock<EntityDataManager<TestFields>>();
|
|
816
|
+
const dataManagerMock = mock<EntityDataManager<TestFields, 'customIdField'>>();
|
|
590
817
|
const dataManagerInstance = instance(dataManagerMock);
|
|
591
818
|
|
|
592
819
|
const id1 = uuidv4();
|
|
593
820
|
const entityMock = mock(TestEntity);
|
|
594
|
-
|
|
821
|
+
const date = new Date();
|
|
822
|
+
|
|
823
|
+
when(entityMock.getAllDatabaseFields()).thenReturn({
|
|
824
|
+
customIdField: id1,
|
|
825
|
+
testIndexedField: 'h1',
|
|
826
|
+
intField: 5,
|
|
827
|
+
stringField: 'huh',
|
|
828
|
+
dateField: date,
|
|
829
|
+
nullableField: null,
|
|
830
|
+
});
|
|
595
831
|
const entityInstance = instance(entityMock);
|
|
596
832
|
|
|
597
833
|
const utils = new EntityLoaderUtils(
|
|
@@ -614,8 +850,43 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
614
850
|
utils,
|
|
615
851
|
);
|
|
616
852
|
await entityLoader.utils.invalidateEntityAsync(entityInstance);
|
|
853
|
+
|
|
854
|
+
verify(dataManagerMock.invalidateKeyValuePairsAsync(anything())).once();
|
|
617
855
|
verify(
|
|
618
|
-
dataManagerMock.
|
|
856
|
+
dataManagerMock.invalidateKeyValuePairsAsync(
|
|
857
|
+
deepEqualEntityAware([
|
|
858
|
+
[
|
|
859
|
+
new SingleFieldHolder<TestFields, 'customIdField', 'customIdField'>('customIdField'),
|
|
860
|
+
new SingleFieldValueHolder<TestFields, 'customIdField'>(id1),
|
|
861
|
+
],
|
|
862
|
+
[
|
|
863
|
+
new SingleFieldHolder<TestFields, 'customIdField', 'testIndexedField'>(
|
|
864
|
+
'testIndexedField',
|
|
865
|
+
),
|
|
866
|
+
new SingleFieldValueHolder<TestFields, 'testIndexedField'>('h1'),
|
|
867
|
+
],
|
|
868
|
+
[
|
|
869
|
+
new SingleFieldHolder<TestFields, 'customIdField', 'intField'>('intField'),
|
|
870
|
+
new SingleFieldValueHolder<TestFields, 'intField'>(5),
|
|
871
|
+
],
|
|
872
|
+
[
|
|
873
|
+
new SingleFieldHolder<TestFields, 'customIdField', 'stringField'>('stringField'),
|
|
874
|
+
new SingleFieldValueHolder<TestFields, 'stringField'>('huh'),
|
|
875
|
+
],
|
|
876
|
+
[
|
|
877
|
+
new SingleFieldHolder<TestFields, 'customIdField', 'dateField'>('dateField'),
|
|
878
|
+
new SingleFieldValueHolder<TestFields, 'dateField'>(date),
|
|
879
|
+
],
|
|
880
|
+
[
|
|
881
|
+
new CompositeFieldHolder(['stringField', 'intField']),
|
|
882
|
+
new CompositeFieldValueHolder({ stringField: 'huh', intField: 5 }),
|
|
883
|
+
],
|
|
884
|
+
[
|
|
885
|
+
new CompositeFieldHolder(['stringField', 'testIndexedField']),
|
|
886
|
+
new CompositeFieldValueHolder({ stringField: 'huh', testIndexedField: 'h1' }),
|
|
887
|
+
],
|
|
888
|
+
]),
|
|
889
|
+
),
|
|
619
890
|
).once();
|
|
620
891
|
});
|
|
621
892
|
|
|
@@ -623,17 +894,37 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
623
894
|
const viewerContext = instance(mock(ViewerContext));
|
|
624
895
|
const privacyPolicyEvaluationContext =
|
|
625
896
|
instance(
|
|
626
|
-
mock<
|
|
897
|
+
mock<
|
|
898
|
+
EntityPrivacyPolicyEvaluationContext<
|
|
899
|
+
TestFields,
|
|
900
|
+
'customIdField',
|
|
901
|
+
ViewerContext,
|
|
902
|
+
TestEntity
|
|
903
|
+
>
|
|
904
|
+
>(),
|
|
627
905
|
);
|
|
628
906
|
const metricsAdapter = instance(mock<IEntityMetricsAdapter>());
|
|
629
907
|
const queryContext = new StubQueryContextProvider().getQueryContext();
|
|
630
908
|
const privacyPolicyMock = mock(TestEntityPrivacyPolicy);
|
|
631
|
-
const dataManagerMock = mock<EntityDataManager<TestFields>>();
|
|
909
|
+
const dataManagerMock = mock<EntityDataManager<TestFields, 'customIdField'>>();
|
|
632
910
|
|
|
633
911
|
const id1 = uuidv4();
|
|
634
|
-
when(
|
|
635
|
-
|
|
636
|
-
|
|
912
|
+
when(dataManagerMock.loadManyEqualingAsync(anything(), anything(), anything())).thenResolve(
|
|
913
|
+
new SingleFieldValueHolderMap<
|
|
914
|
+
TestFields,
|
|
915
|
+
'customIdField',
|
|
916
|
+
readonly Readonly<TestFields>[]
|
|
917
|
+
>().set(new SingleFieldValueHolder(id1), [
|
|
918
|
+
{
|
|
919
|
+
customIdField: id1,
|
|
920
|
+
testIndexedField: '',
|
|
921
|
+
stringField: '',
|
|
922
|
+
intField: 0,
|
|
923
|
+
dateField: new Date(),
|
|
924
|
+
nullableField: null,
|
|
925
|
+
},
|
|
926
|
+
]),
|
|
927
|
+
);
|
|
637
928
|
|
|
638
929
|
const rejectionError = new Error();
|
|
639
930
|
|
|
@@ -680,18 +971,25 @@ describe(AuthorizationResultBasedEntityLoader, () => {
|
|
|
680
971
|
const viewerContext = instance(mock(ViewerContext));
|
|
681
972
|
const privacyPolicyEvaluationContext =
|
|
682
973
|
instance(
|
|
683
|
-
mock<
|
|
974
|
+
mock<
|
|
975
|
+
EntityPrivacyPolicyEvaluationContext<
|
|
976
|
+
TestFields,
|
|
977
|
+
'customIdField',
|
|
978
|
+
ViewerContext,
|
|
979
|
+
TestEntity
|
|
980
|
+
>
|
|
981
|
+
>(),
|
|
684
982
|
);
|
|
685
983
|
const metricsAdapter = instance(mock<IEntityMetricsAdapter>());
|
|
686
984
|
const queryContext = new StubQueryContextProvider().getQueryContext();
|
|
687
985
|
const privacyPolicy = instance(mock(TestEntityPrivacyPolicy));
|
|
688
|
-
const dataManagerMock = mock<EntityDataManager<TestFields>>();
|
|
986
|
+
const dataManagerMock = mock<EntityDataManager<TestFields, 'customIdField'>>();
|
|
689
987
|
|
|
690
988
|
const error = new Error();
|
|
691
989
|
|
|
692
|
-
when(
|
|
693
|
-
|
|
694
|
-
)
|
|
990
|
+
when(dataManagerMock.loadManyEqualingAsync(anything(), anything(), anything())).thenReject(
|
|
991
|
+
error,
|
|
992
|
+
);
|
|
695
993
|
|
|
696
994
|
const dataManagerInstance = instance(dataManagerMock);
|
|
697
995
|
|