@expo/entity 0.40.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 +2 -4
- 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 +32 -10
- package/build/Entity.js +41 -3
- 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 +27 -8
- package/build/ReadonlyEntity.js +31 -3
- 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 +58 -53
- 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 +185 -29
- 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 +129 -16
- 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 +41 -72
- 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 +64 -11
- package/src/__tests__/EntityAssociationLoader-test.ts +6 -8
- package/src/__tests__/EntityCommonUseCases-test.ts +25 -28
- 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 +135 -138
- package/src/__tests__/EntityFields-test.ts +2 -2
- package/src/__tests__/EntityLoader-test.ts +5 -7
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +17 -19
- 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 +9 -9
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +119 -122
- package/src/__tests__/GenericEntityCacheAdapter-test.ts +83 -28
- package/src/__tests__/ReadonlyEntity-test.ts +49 -9
- 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 +25 -27
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +28 -34
- 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 +81 -113
- package/src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.ts +31 -30
- 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 -273
- 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 -54
- 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 -154
- 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 -755
- 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 -77
- 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 -247
- 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 -178
- 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 -129
- 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 -136
- 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 -520
- 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 -181
- 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
|
@@ -12,10 +12,10 @@ import PrivacyPolicyRule, { RuleEvaluationResult } from './rules/PrivacyPolicyRu
|
|
|
12
12
|
* Information about the reason this privacy policy is being evaluated.
|
|
13
13
|
*/
|
|
14
14
|
export type EntityPrivacyPolicyEvaluationContext<
|
|
15
|
-
TFields extends
|
|
16
|
-
|
|
15
|
+
TFields extends Record<string, any>,
|
|
16
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
17
17
|
TViewerContext extends ViewerContext,
|
|
18
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
18
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
19
19
|
TSelectedFields extends keyof TFields = keyof TFields,
|
|
20
20
|
> = {
|
|
21
21
|
/**
|
|
@@ -53,10 +53,10 @@ export enum EntityPrivacyPolicyEvaluationMode {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export type EntityPrivacyPolicyEvaluator<
|
|
56
|
-
TFields extends
|
|
57
|
-
|
|
56
|
+
TFields extends Record<string, any>,
|
|
57
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
58
58
|
TViewerContext extends ViewerContext,
|
|
59
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
59
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
60
60
|
TSelectedFields extends keyof TFields = keyof TFields,
|
|
61
61
|
> =
|
|
62
62
|
| {
|
|
@@ -65,13 +65,25 @@ export type EntityPrivacyPolicyEvaluator<
|
|
|
65
65
|
| {
|
|
66
66
|
mode: EntityPrivacyPolicyEvaluationMode.DRY_RUN;
|
|
67
67
|
denyHandler: (
|
|
68
|
-
error: EntityNotAuthorizedError<
|
|
68
|
+
error: EntityNotAuthorizedError<
|
|
69
|
+
TFields,
|
|
70
|
+
TIDField,
|
|
71
|
+
TViewerContext,
|
|
72
|
+
TEntity,
|
|
73
|
+
TSelectedFields
|
|
74
|
+
>,
|
|
69
75
|
) => void;
|
|
70
76
|
}
|
|
71
77
|
| {
|
|
72
78
|
mode: EntityPrivacyPolicyEvaluationMode.ENFORCE_AND_LOG;
|
|
73
79
|
denyHandler: (
|
|
74
|
-
error: EntityNotAuthorizedError<
|
|
80
|
+
error: EntityNotAuthorizedError<
|
|
81
|
+
TFields,
|
|
82
|
+
TIDField,
|
|
83
|
+
TViewerContext,
|
|
84
|
+
TEntity,
|
|
85
|
+
TSelectedFields
|
|
86
|
+
>,
|
|
75
87
|
) => void;
|
|
76
88
|
};
|
|
77
89
|
|
|
@@ -104,36 +116,36 @@ export enum EntityAuthorizationAction {
|
|
|
104
116
|
* ```
|
|
105
117
|
*/
|
|
106
118
|
export default abstract class EntityPrivacyPolicy<
|
|
107
|
-
TFields extends
|
|
108
|
-
|
|
119
|
+
TFields extends Record<string, any>,
|
|
120
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
109
121
|
TViewerContext extends ViewerContext,
|
|
110
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
122
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
111
123
|
TSelectedFields extends keyof TFields = keyof TFields,
|
|
112
124
|
> {
|
|
113
125
|
protected readonly createRules: readonly PrivacyPolicyRule<
|
|
114
126
|
TFields,
|
|
115
|
-
|
|
127
|
+
TIDField,
|
|
116
128
|
TViewerContext,
|
|
117
129
|
TEntity,
|
|
118
130
|
TSelectedFields
|
|
119
131
|
>[] = [];
|
|
120
132
|
protected readonly readRules: readonly PrivacyPolicyRule<
|
|
121
133
|
TFields,
|
|
122
|
-
|
|
134
|
+
TIDField,
|
|
123
135
|
TViewerContext,
|
|
124
136
|
TEntity,
|
|
125
137
|
TSelectedFields
|
|
126
138
|
>[] = [];
|
|
127
139
|
protected readonly updateRules: readonly PrivacyPolicyRule<
|
|
128
140
|
TFields,
|
|
129
|
-
|
|
141
|
+
TIDField,
|
|
130
142
|
TViewerContext,
|
|
131
143
|
TEntity,
|
|
132
144
|
TSelectedFields
|
|
133
145
|
>[] = [];
|
|
134
146
|
protected readonly deleteRules: readonly PrivacyPolicyRule<
|
|
135
147
|
TFields,
|
|
136
|
-
|
|
148
|
+
TIDField,
|
|
137
149
|
TViewerContext,
|
|
138
150
|
TEntity,
|
|
139
151
|
TSelectedFields
|
|
@@ -149,7 +161,7 @@ export default abstract class EntityPrivacyPolicy<
|
|
|
149
161
|
*/
|
|
150
162
|
protected getPrivacyPolicyEvaluator(
|
|
151
163
|
_viewerContext: TViewerContext,
|
|
152
|
-
): EntityPrivacyPolicyEvaluator<TFields,
|
|
164
|
+
): EntityPrivacyPolicyEvaluator<TFields, TIDField, TViewerContext, TEntity, TSelectedFields> {
|
|
153
165
|
return {
|
|
154
166
|
mode: EntityPrivacyPolicyEvaluationMode.ENFORCE,
|
|
155
167
|
};
|
|
@@ -168,7 +180,7 @@ export default abstract class EntityPrivacyPolicy<
|
|
|
168
180
|
queryContext: EntityQueryContext,
|
|
169
181
|
evaluationContext: EntityPrivacyPolicyEvaluationContext<
|
|
170
182
|
TFields,
|
|
171
|
-
|
|
183
|
+
TIDField,
|
|
172
184
|
TViewerContext,
|
|
173
185
|
TEntity,
|
|
174
186
|
TSelectedFields
|
|
@@ -200,7 +212,7 @@ export default abstract class EntityPrivacyPolicy<
|
|
|
200
212
|
queryContext: EntityQueryContext,
|
|
201
213
|
evaluationContext: EntityPrivacyPolicyEvaluationContext<
|
|
202
214
|
TFields,
|
|
203
|
-
|
|
215
|
+
TIDField,
|
|
204
216
|
TViewerContext,
|
|
205
217
|
TEntity,
|
|
206
218
|
TSelectedFields
|
|
@@ -232,7 +244,7 @@ export default abstract class EntityPrivacyPolicy<
|
|
|
232
244
|
queryContext: EntityQueryContext,
|
|
233
245
|
evaluationContext: EntityPrivacyPolicyEvaluationContext<
|
|
234
246
|
TFields,
|
|
235
|
-
|
|
247
|
+
TIDField,
|
|
236
248
|
TViewerContext,
|
|
237
249
|
TEntity,
|
|
238
250
|
TSelectedFields
|
|
@@ -264,7 +276,7 @@ export default abstract class EntityPrivacyPolicy<
|
|
|
264
276
|
queryContext: EntityQueryContext,
|
|
265
277
|
evaluationContext: EntityPrivacyPolicyEvaluationContext<
|
|
266
278
|
TFields,
|
|
267
|
-
|
|
279
|
+
TIDField,
|
|
268
280
|
TViewerContext,
|
|
269
281
|
TEntity,
|
|
270
282
|
TSelectedFields
|
|
@@ -284,12 +296,18 @@ export default abstract class EntityPrivacyPolicy<
|
|
|
284
296
|
}
|
|
285
297
|
|
|
286
298
|
private async authorizeForRulesetAsync(
|
|
287
|
-
ruleset: readonly PrivacyPolicyRule<
|
|
299
|
+
ruleset: readonly PrivacyPolicyRule<
|
|
300
|
+
TFields,
|
|
301
|
+
TIDField,
|
|
302
|
+
TViewerContext,
|
|
303
|
+
TEntity,
|
|
304
|
+
TSelectedFields
|
|
305
|
+
>[],
|
|
288
306
|
viewerContext: TViewerContext,
|
|
289
307
|
queryContext: EntityQueryContext,
|
|
290
308
|
evaluationContext: EntityPrivacyPolicyEvaluationContext<
|
|
291
309
|
TFields,
|
|
292
|
-
|
|
310
|
+
TIDField,
|
|
293
311
|
TViewerContext,
|
|
294
312
|
TEntity,
|
|
295
313
|
TSelectedFields
|
|
@@ -393,12 +411,18 @@ export default abstract class EntityPrivacyPolicy<
|
|
|
393
411
|
}
|
|
394
412
|
|
|
395
413
|
private async authorizeForRulesetInnerAsync(
|
|
396
|
-
ruleset: readonly PrivacyPolicyRule<
|
|
414
|
+
ruleset: readonly PrivacyPolicyRule<
|
|
415
|
+
TFields,
|
|
416
|
+
TIDField,
|
|
417
|
+
TViewerContext,
|
|
418
|
+
TEntity,
|
|
419
|
+
TSelectedFields
|
|
420
|
+
>[],
|
|
397
421
|
viewerContext: TViewerContext,
|
|
398
422
|
queryContext: EntityQueryContext,
|
|
399
423
|
evaluationContext: EntityPrivacyPolicyEvaluationContext<
|
|
400
424
|
TFields,
|
|
401
|
-
|
|
425
|
+
TIDField,
|
|
402
426
|
TViewerContext,
|
|
403
427
|
TEntity,
|
|
404
428
|
TSelectedFields
|
|
@@ -418,7 +442,7 @@ export default abstract class EntityPrivacyPolicy<
|
|
|
418
442
|
case RuleEvaluationResult.DENY:
|
|
419
443
|
throw new EntityNotAuthorizedError<
|
|
420
444
|
TFields,
|
|
421
|
-
|
|
445
|
+
TIDField,
|
|
422
446
|
TViewerContext,
|
|
423
447
|
TEntity,
|
|
424
448
|
TSelectedFields
|
|
@@ -434,7 +458,7 @@ export default abstract class EntityPrivacyPolicy<
|
|
|
434
458
|
}
|
|
435
459
|
}
|
|
436
460
|
|
|
437
|
-
throw new EntityNotAuthorizedError<TFields,
|
|
461
|
+
throw new EntityNotAuthorizedError<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>(
|
|
438
462
|
entity,
|
|
439
463
|
viewerContext,
|
|
440
464
|
action,
|
|
@@ -10,7 +10,7 @@ import { mapMap } from './utils/collections/maps';
|
|
|
10
10
|
* An interface that knows how to load many objects from a cache by load params and invalidate
|
|
11
11
|
* those same load params.
|
|
12
12
|
*/
|
|
13
|
-
export interface ISecondaryEntityCache<TFields, TLoadParams> {
|
|
13
|
+
export interface ISecondaryEntityCache<TFields extends Record<string, any>, TLoadParams> {
|
|
14
14
|
/**
|
|
15
15
|
* Read-through cache function.
|
|
16
16
|
* @param loadParamsArray - array of loadParams to load from the cache
|
|
@@ -45,13 +45,13 @@ export interface ISecondaryEntityCache<TFields, TLoadParams> {
|
|
|
45
45
|
*/
|
|
46
46
|
export default abstract class EntitySecondaryCacheLoader<
|
|
47
47
|
TLoadParams,
|
|
48
|
-
TFields extends
|
|
49
|
-
|
|
48
|
+
TFields extends Record<string, any>,
|
|
49
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
50
50
|
TViewerContext extends ViewerContext,
|
|
51
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
51
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
52
52
|
TPrivacyPolicy extends EntityPrivacyPolicy<
|
|
53
53
|
TFields,
|
|
54
|
-
|
|
54
|
+
TIDField,
|
|
55
55
|
TViewerContext,
|
|
56
56
|
TEntity,
|
|
57
57
|
TSelectedFields
|
|
@@ -62,7 +62,7 @@ export default abstract class EntitySecondaryCacheLoader<
|
|
|
62
62
|
private readonly secondaryEntityCache: ISecondaryEntityCache<TFields, TLoadParams>,
|
|
63
63
|
protected readonly entityLoader: AuthorizationResultBasedEntityLoader<
|
|
64
64
|
TFields,
|
|
65
|
-
|
|
65
|
+
TIDField,
|
|
66
66
|
TViewerContext,
|
|
67
67
|
TEntity,
|
|
68
68
|
TPrivacyPolicy,
|
package/src/EntityUpdater.ts
CHANGED
|
@@ -10,13 +10,13 @@ import ViewerContext from './ViewerContext';
|
|
|
10
10
|
* The primary interface for updating entities.
|
|
11
11
|
*/
|
|
12
12
|
export default class EntityUpdater<
|
|
13
|
-
TFields extends
|
|
14
|
-
|
|
13
|
+
TFields extends Record<string, any>,
|
|
14
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
15
15
|
TViewerContext extends ViewerContext,
|
|
16
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
16
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
17
17
|
TPrivacyPolicy extends EntityPrivacyPolicy<
|
|
18
18
|
TFields,
|
|
19
|
-
|
|
19
|
+
TIDField,
|
|
20
20
|
TViewerContext,
|
|
21
21
|
TEntity,
|
|
22
22
|
TSelectedFields
|
|
@@ -28,7 +28,7 @@ export default class EntityUpdater<
|
|
|
28
28
|
private readonly queryContext: EntityQueryContext,
|
|
29
29
|
private readonly entityClass: IEntityClass<
|
|
30
30
|
TFields,
|
|
31
|
-
|
|
31
|
+
TIDField,
|
|
32
32
|
TViewerContext,
|
|
33
33
|
TEntity,
|
|
34
34
|
TPrivacyPolicy,
|
|
@@ -42,7 +42,7 @@ export default class EntityUpdater<
|
|
|
42
42
|
*/
|
|
43
43
|
enforcing(): EnforcingEntityUpdater<
|
|
44
44
|
TFields,
|
|
45
|
-
|
|
45
|
+
TIDField,
|
|
46
46
|
TViewerContext,
|
|
47
47
|
TEntity,
|
|
48
48
|
TPrivacyPolicy,
|
|
@@ -58,7 +58,7 @@ export default class EntityUpdater<
|
|
|
58
58
|
*/
|
|
59
59
|
withAuthorizationResults(): AuthorizationResultBasedUpdateMutator<
|
|
60
60
|
TFields,
|
|
61
|
-
|
|
61
|
+
TIDField,
|
|
62
62
|
TViewerContext,
|
|
63
63
|
TEntity,
|
|
64
64
|
TPrivacyPolicy,
|
|
@@ -2,64 +2,75 @@ import invariant from 'invariant';
|
|
|
2
2
|
|
|
3
3
|
import IEntityCacheAdapter from './IEntityCacheAdapter';
|
|
4
4
|
import IEntityGenericCacher from './IEntityGenericCacher';
|
|
5
|
+
import { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces';
|
|
5
6
|
import { CacheLoadResult } from './internal/ReadThroughEntityCache';
|
|
6
7
|
import { mapKeys } from './utils/collections/maps';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* A standard IEntityCacheAdapter that coordinates caching through an IEntityGenericCacher.
|
|
10
11
|
*/
|
|
11
|
-
export default class GenericEntityCacheAdapter<
|
|
12
|
-
|
|
12
|
+
export default class GenericEntityCacheAdapter<
|
|
13
|
+
TFields extends Record<string, any>,
|
|
14
|
+
TIDField extends keyof TFields,
|
|
15
|
+
> implements IEntityCacheAdapter<TFields, TIDField>
|
|
16
|
+
{
|
|
17
|
+
constructor(private readonly genericCacher: IEntityGenericCacher<TFields, TIDField>) {}
|
|
13
18
|
|
|
14
|
-
public async loadManyAsync<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
public async loadManyAsync<
|
|
20
|
+
TLoadKey extends IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
|
|
21
|
+
TSerializedLoadValue,
|
|
22
|
+
TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
|
|
23
|
+
>(
|
|
24
|
+
key: TLoadKey,
|
|
25
|
+
values: readonly TLoadValue[],
|
|
26
|
+
): Promise<ReadonlyMap<TLoadValue, CacheLoadResult<TFields>>> {
|
|
18
27
|
const redisCacheKeyToFieldValueMapping = new Map(
|
|
19
|
-
|
|
20
|
-
this.genericCacher.makeCacheKey(fieldName, fieldValue),
|
|
21
|
-
fieldValue,
|
|
22
|
-
]),
|
|
28
|
+
values.map((value) => [this.genericCacher.makeCacheKeyForStorage(key, value), value]),
|
|
23
29
|
);
|
|
24
30
|
const cacheResults = await this.genericCacher.loadManyAsync(
|
|
25
31
|
Array.from(redisCacheKeyToFieldValueMapping.keys()),
|
|
26
32
|
);
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
const result = key.vendNewLoadValueMap<CacheLoadResult<TFields>>();
|
|
35
|
+
for (const [redisCacheKey, cacheResult] of cacheResults) {
|
|
29
36
|
const fieldValue = redisCacheKeyToFieldValueMapping.get(redisCacheKey);
|
|
30
37
|
invariant(
|
|
31
38
|
fieldValue !== undefined,
|
|
32
39
|
'Unspecified cache key %s returned from generic cacher',
|
|
33
40
|
redisCacheKey,
|
|
34
41
|
);
|
|
35
|
-
|
|
36
|
-
}
|
|
42
|
+
result.set(fieldValue, cacheResult);
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
37
45
|
}
|
|
38
46
|
|
|
39
|
-
public async cacheManyAsync<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
public async cacheManyAsync<
|
|
48
|
+
TLoadKey extends IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
|
|
49
|
+
TSerializedLoadValue,
|
|
50
|
+
TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
|
|
51
|
+
>(key: TLoadKey, objectMap: ReadonlyMap<TLoadValue, Readonly<TFields>>): Promise<void> {
|
|
43
52
|
await this.genericCacher.cacheManyAsync(
|
|
44
|
-
mapKeys(objectMap, (
|
|
53
|
+
mapKeys(objectMap, (value) => this.genericCacher.makeCacheKeyForStorage(key, value)),
|
|
45
54
|
);
|
|
46
55
|
}
|
|
47
56
|
|
|
48
|
-
public async cacheDBMissesAsync<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
public async cacheDBMissesAsync<
|
|
58
|
+
TLoadKey extends IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
|
|
59
|
+
TSerializedLoadValue,
|
|
60
|
+
TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
|
|
61
|
+
>(key: TLoadKey, values: readonly TLoadValue[]): Promise<void> {
|
|
52
62
|
await this.genericCacher.cacheDBMissesAsync(
|
|
53
|
-
|
|
63
|
+
values.map((value) => this.genericCacher.makeCacheKeyForStorage(key, value)),
|
|
54
64
|
);
|
|
55
65
|
}
|
|
56
66
|
|
|
57
|
-
public async invalidateManyAsync<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
67
|
+
public async invalidateManyAsync<
|
|
68
|
+
TLoadKey extends IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
|
|
69
|
+
TSerializedLoadValue,
|
|
70
|
+
TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
|
|
71
|
+
>(key: TLoadKey, values: readonly TLoadValue[]): Promise<void> {
|
|
61
72
|
await this.genericCacher.invalidateManyAsync(
|
|
62
|
-
|
|
73
|
+
values.flatMap((value) => this.genericCacher.makeCacheKeysForInvalidation(key, value)),
|
|
63
74
|
);
|
|
64
75
|
}
|
|
65
76
|
}
|
|
@@ -10,11 +10,14 @@ import { filterMap, zipToMap } from './utils/collections/maps';
|
|
|
10
10
|
* single entity load. One common way this may be used is to add a second layer of caching in a hot path that makes
|
|
11
11
|
* a call to EntityLoader.loadManyByFieldEqualityConjunctionAsync is guaranteed to return at most one entity.
|
|
12
12
|
*/
|
|
13
|
-
export default abstract class GenericSecondaryEntityCache<
|
|
14
|
-
|
|
13
|
+
export default abstract class GenericSecondaryEntityCache<
|
|
14
|
+
TFields extends Record<string, any>,
|
|
15
|
+
TIDField extends keyof TFields,
|
|
16
|
+
TLoadParams,
|
|
17
|
+
> implements ISecondaryEntityCache<TFields, TLoadParams>
|
|
15
18
|
{
|
|
16
19
|
constructor(
|
|
17
|
-
protected readonly cacher: IEntityGenericCacher<TFields>,
|
|
20
|
+
protected readonly cacher: IEntityGenericCacher<TFields, TIDField>,
|
|
18
21
|
protected readonly constructCacheKey: (params: Readonly<TLoadParams>) => string,
|
|
19
22
|
) {}
|
|
20
23
|
|
|
@@ -1,49 +1,69 @@
|
|
|
1
|
+
import { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces';
|
|
1
2
|
import { CacheLoadResult } from './internal/ReadThroughEntityCache';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* A cache adapter is an interface by which objects can be
|
|
5
6
|
* cached, fetched from cache, and removed from cache (invalidated).
|
|
6
7
|
*/
|
|
7
|
-
export default interface IEntityCacheAdapter<
|
|
8
|
+
export default interface IEntityCacheAdapter<
|
|
9
|
+
TFields extends Record<string, any>,
|
|
10
|
+
TIDField extends keyof TFields,
|
|
11
|
+
> {
|
|
8
12
|
/**
|
|
9
13
|
* Load many objects from cache.
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @returns map from all
|
|
14
|
+
* @param key - load key to load
|
|
15
|
+
* @param values - load values to load for the key
|
|
16
|
+
* @returns map from all load values to a CacheLoadResult for that value
|
|
13
17
|
*/
|
|
14
|
-
loadManyAsync<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
loadManyAsync<
|
|
19
|
+
TLoadKey extends IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
|
|
20
|
+
TSerializedLoadValue,
|
|
21
|
+
TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
|
|
22
|
+
>(
|
|
23
|
+
key: TLoadKey,
|
|
24
|
+
values: readonly TLoadValue[],
|
|
25
|
+
): Promise<ReadonlyMap<TLoadValue, CacheLoadResult<TFields>>>;
|
|
18
26
|
|
|
19
27
|
/**
|
|
20
28
|
* Cache many objects fetched from the DB.
|
|
21
|
-
* @param
|
|
22
|
-
* @param objectMap - map from
|
|
29
|
+
* @param key - load key to cache
|
|
30
|
+
* @param objectMap - map from load value to object to cache for the key
|
|
23
31
|
*/
|
|
24
|
-
cacheManyAsync<
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
cacheManyAsync<
|
|
33
|
+
TLoadKey extends IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
|
|
34
|
+
TSerializedLoadValue,
|
|
35
|
+
TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
|
|
36
|
+
>(
|
|
37
|
+
key: TLoadKey,
|
|
38
|
+
objectMap: ReadonlyMap<TLoadValue, Readonly<TFields>>,
|
|
27
39
|
): Promise<void>;
|
|
28
40
|
|
|
29
41
|
/**
|
|
30
42
|
* Negatively cache objects that could not be found in the cache or DB.
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
*
|
|
43
|
+
* @param key - load key to cache misses for
|
|
44
|
+
* @param values - load values for objects reported as CacheStatus.NEGATIVE
|
|
45
|
+
* in the cache and not found in the DB.
|
|
34
46
|
*/
|
|
35
|
-
cacheDBMissesAsync<
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
cacheDBMissesAsync<
|
|
48
|
+
TLoadKey extends IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
|
|
49
|
+
TSerializedLoadValue,
|
|
50
|
+
TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
|
|
51
|
+
>(
|
|
52
|
+
key: TLoadKey,
|
|
53
|
+
values: readonly TLoadValue[],
|
|
38
54
|
): Promise<void>;
|
|
39
55
|
|
|
40
56
|
/**
|
|
41
|
-
* Invalidate the cache for objects cached by (
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
57
|
+
* Invalidate the cache for objects cached by (key, value).
|
|
58
|
+
* @param key - load key to invalidate
|
|
59
|
+
* @param values - load values to be invalidated for the key
|
|
44
60
|
*/
|
|
45
|
-
invalidateManyAsync<
|
|
46
|
-
|
|
47
|
-
|
|
61
|
+
invalidateManyAsync<
|
|
62
|
+
TLoadKey extends IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
|
|
63
|
+
TSerializedLoadValue,
|
|
64
|
+
TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
|
|
65
|
+
>(
|
|
66
|
+
key: TLoadKey,
|
|
67
|
+
values: readonly TLoadValue[],
|
|
48
68
|
): Promise<void>;
|
|
49
69
|
}
|
|
@@ -9,7 +9,7 @@ export default interface IEntityCacheAdapterProvider {
|
|
|
9
9
|
/**
|
|
10
10
|
* Vend a cache adapter for an entity configuration.
|
|
11
11
|
*/
|
|
12
|
-
getCacheAdapter<TFields extends Record<string, any
|
|
13
|
-
entityConfiguration: EntityConfiguration<TFields>,
|
|
14
|
-
): IEntityCacheAdapter<TFields>;
|
|
12
|
+
getCacheAdapter<TFields extends Record<string, any>, TIDField extends keyof TFields>(
|
|
13
|
+
entityConfiguration: EntityConfiguration<TFields, TIDField>,
|
|
14
|
+
): IEntityCacheAdapter<TFields, TIDField>;
|
|
15
15
|
}
|
|
@@ -9,7 +9,7 @@ export default interface IEntityDatabaseAdapterProvider {
|
|
|
9
9
|
/**
|
|
10
10
|
* Vend a database adapter.
|
|
11
11
|
*/
|
|
12
|
-
getDatabaseAdapter<TFields extends Record<string, any
|
|
13
|
-
entityConfiguration: EntityConfiguration<TFields>,
|
|
14
|
-
): EntityDatabaseAdapter<TFields>;
|
|
12
|
+
getDatabaseAdapter<TFields extends Record<string, any>, TIDField extends keyof TFields>(
|
|
13
|
+
entityConfiguration: EntityConfiguration<TFields, TIDField>,
|
|
14
|
+
): EntityDatabaseAdapter<TFields, TIDField>;
|
|
15
15
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces';
|
|
1
2
|
import { CacheLoadResult } from './internal/ReadThroughEntityCache';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* A generic cacher stores and loads key-value pairs. It also supports negative caching - it stores the absence
|
|
5
6
|
* of keys that don't exist in the backing datastore. It is also responsible for cache key creation.
|
|
6
7
|
*/
|
|
7
|
-
export default interface IEntityGenericCacher<
|
|
8
|
+
export default interface IEntityGenericCacher<
|
|
9
|
+
TFields extends Record<string, any>,
|
|
10
|
+
TIDField extends keyof TFields,
|
|
11
|
+
> {
|
|
8
12
|
/**
|
|
9
13
|
* Load many keys from the cache. Return info in a format that is useful for read-through caching and
|
|
10
14
|
* negative caching.
|
|
@@ -36,10 +40,34 @@ export default interface IEntityGenericCacher<TFields> {
|
|
|
36
40
|
invalidateManyAsync(keys: readonly string[]): Promise<void>;
|
|
37
41
|
|
|
38
42
|
/**
|
|
39
|
-
* Create a cache key for a
|
|
43
|
+
* Create a cache key for a load key and load value of an object being cached (or negatively cached).
|
|
40
44
|
*
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
45
|
+
* @param key - load key of the cache key
|
|
46
|
+
* @param value - load value of the cache key
|
|
43
47
|
*/
|
|
44
|
-
|
|
48
|
+
makeCacheKeyForStorage<
|
|
49
|
+
TLoadKey extends IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
|
|
50
|
+
TSerializedLoadValue,
|
|
51
|
+
TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
|
|
52
|
+
>(
|
|
53
|
+
key: TLoadKey,
|
|
54
|
+
value: TLoadValue,
|
|
55
|
+
): string;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Create a cache key for a load key and load values of an object being invalidated. This is separate
|
|
59
|
+
* from makeCacheKeyForStorage because invalidation can optionally be configured to invalidate a larger set of keys than
|
|
60
|
+
* the one for just the current cache version, which can be useful for things like push safety.
|
|
61
|
+
*
|
|
62
|
+
* @param key - load key of the cache key
|
|
63
|
+
* @param values - load values of the cache key
|
|
64
|
+
*/
|
|
65
|
+
makeCacheKeysForInvalidation<
|
|
66
|
+
TLoadKey extends IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
|
|
67
|
+
TSerializedLoadValue,
|
|
68
|
+
TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
|
|
69
|
+
>(
|
|
70
|
+
key: TLoadKey,
|
|
71
|
+
value: TLoadValue,
|
|
72
|
+
): readonly string[];
|
|
45
73
|
}
|