@expo/entity 0.41.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/AuthorizationResultBasedEntityAssociationLoader.d.ts +16 -16
- package/build/AuthorizationResultBasedEntityAssociationLoader.js.map +1 -1
- package/build/AuthorizationResultBasedEntityLoader.d.ts +39 -67
- package/build/AuthorizationResultBasedEntityLoader.js +85 -62
- package/build/AuthorizationResultBasedEntityLoader.js.map +1 -1
- package/build/AuthorizationResultBasedEntityMutator.d.ts +16 -16
- package/build/AuthorizationResultBasedEntityMutator.js.map +1 -1
- package/build/ComposedEntityCacheAdapter.d.ts +7 -6
- package/build/ComposedEntityCacheAdapter.js +28 -28
- package/build/ComposedEntityCacheAdapter.js.map +1 -1
- package/build/ComposedSecondaryEntityCache.d.ts +1 -1
- package/build/ComposedSecondaryEntityCache.js.map +1 -1
- package/build/EnforcingEntityAssociationLoader.d.ts +15 -15
- package/build/EnforcingEntityAssociationLoader.js.map +1 -1
- package/build/EnforcingEntityCreator.d.ts +2 -2
- package/build/EnforcingEntityDeleter.d.ts +2 -2
- package/build/EnforcingEntityLoader.d.ts +104 -18
- package/build/EnforcingEntityLoader.js +113 -12
- package/build/EnforcingEntityLoader.js.map +1 -1
- package/build/EnforcingEntityUpdater.d.ts +2 -2
- package/build/Entity.d.ts +10 -10
- package/build/Entity.js.map +1 -1
- package/build/EntityAssociationLoader.d.ts +3 -3
- package/build/EntityCompanion.d.ts +5 -5
- package/build/EntityCompanion.js.map +1 -1
- package/build/EntityCompanionProvider.d.ts +6 -6
- package/build/EntityCompanionProvider.js.map +1 -1
- package/build/EntityConfiguration.d.ts +46 -5
- package/build/EntityConfiguration.js +39 -1
- package/build/EntityConfiguration.js.map +1 -1
- package/build/EntityCreator.d.ts +4 -4
- package/build/EntityDatabaseAdapter.d.ts +15 -14
- package/build/EntityDatabaseAdapter.js +20 -12
- package/build/EntityDatabaseAdapter.js.map +1 -1
- package/build/EntityDeleter.d.ts +4 -4
- package/build/EntityFieldDefinition.d.ts +20 -10
- package/build/EntityFieldDefinition.js +3 -1
- package/build/EntityFieldDefinition.js.map +1 -1
- package/build/EntityFields.d.ts +14 -12
- package/build/EntityFields.js.map +1 -1
- package/build/EntityLoader.d.ts +5 -5
- package/build/EntityLoaderFactory.d.ts +3 -3
- package/build/EntityLoaderFactory.js.map +1 -1
- package/build/EntityLoaderUtils.d.ts +2 -2
- package/build/EntityLoaderUtils.js +27 -1
- package/build/EntityLoaderUtils.js.map +1 -1
- package/build/EntityMutationInfo.d.ts +2 -2
- package/build/EntityMutationTriggerConfiguration.d.ts +14 -14
- package/build/EntityMutationTriggerConfiguration.js.map +1 -1
- package/build/EntityMutationValidator.d.ts +2 -2
- package/build/EntityMutatorFactory.d.ts +5 -5
- package/build/EntityMutatorFactory.js.map +1 -1
- package/build/EntityPrivacyPolicy.d.ts +14 -14
- package/build/EntityPrivacyPolicy.js.map +1 -1
- package/build/EntitySecondaryCacheLoader.d.ts +4 -4
- package/build/EntityUpdater.d.ts +4 -4
- package/build/GenericEntityCacheAdapter.d.ts +7 -6
- package/build/GenericEntityCacheAdapter.js +13 -14
- package/build/GenericEntityCacheAdapter.js.map +1 -1
- package/build/GenericSecondaryEntityCache.d.ts +3 -3
- package/build/GenericSecondaryEntityCache.js.map +1 -1
- package/build/IEntityCacheAdapter.d.ts +17 -16
- package/build/IEntityCacheAdapterProvider.d.ts +1 -1
- package/build/IEntityDatabaseAdapterProvider.d.ts +1 -1
- package/build/IEntityGenericCacher.d.ts +15 -5
- package/build/ReadonlyEntity.d.ts +8 -8
- package/build/ReadonlyEntity.js.map +1 -1
- package/build/ViewerContext.d.ts +1 -1
- package/build/ViewerScopedEntityCompanion.d.ts +5 -5
- package/build/ViewerScopedEntityCompanionProvider.d.ts +1 -1
- package/build/ViewerScopedEntityLoaderFactory.d.ts +3 -3
- package/build/ViewerScopedEntityMutatorFactory.d.ts +5 -5
- package/build/entityUtils.d.ts +1 -1
- package/build/entityUtils.js.map +1 -1
- package/build/errors/EntityInvalidFieldValueError.d.ts +2 -2
- package/build/errors/EntityNotAuthorizedError.d.ts +1 -1
- package/build/errors/EntityNotFoundError.d.ts +2 -2
- package/build/index.d.ts +7 -7
- package/build/index.js +8 -13
- package/build/index.js.map +1 -1
- package/build/internal/CompositeFieldHolder.d.ts +48 -0
- package/build/internal/CompositeFieldHolder.js +116 -0
- package/build/internal/CompositeFieldHolder.js.map +1 -0
- package/build/internal/CompositeFieldValueMap.d.ts +15 -0
- package/build/internal/CompositeFieldValueMap.js +51 -0
- package/build/internal/CompositeFieldValueMap.js.map +1 -0
- package/build/internal/EntityDataManager.d.ts +16 -16
- package/build/internal/EntityDataManager.js +42 -45
- package/build/internal/EntityDataManager.js.map +1 -1
- package/build/internal/EntityFieldTransformationUtils.d.ts +5 -5
- package/build/internal/EntityFieldTransformationUtils.js.map +1 -1
- package/build/internal/EntityLoadInterfaces.d.ts +104 -0
- package/build/internal/EntityLoadInterfaces.js +25 -0
- package/build/internal/EntityLoadInterfaces.js.map +1 -0
- package/build/internal/EntityTableDataCoordinator.d.ts +6 -6
- package/build/internal/EntityTableDataCoordinator.js.map +1 -1
- package/build/internal/ReadThroughEntityCache.d.ts +17 -16
- package/build/internal/ReadThroughEntityCache.js +36 -36
- package/build/internal/ReadThroughEntityCache.js.map +1 -1
- package/build/internal/SingleFieldHolder.d.ts +34 -0
- package/build/internal/SingleFieldHolder.js +90 -0
- package/build/internal/SingleFieldHolder.js.map +1 -0
- package/build/metrics/EntityMetricsUtils.d.ts +2 -1
- package/build/metrics/EntityMetricsUtils.js.map +1 -1
- package/build/metrics/IEntityMetricsAdapter.d.ts +5 -0
- package/build/metrics/IEntityMetricsAdapter.js.map +1 -1
- package/build/rules/AlwaysAllowPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysAllowPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysDenyPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysDenyPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysSkipPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysSkipPrivacyPolicyRule.js.map +1 -1
- package/build/rules/PrivacyPolicyRule.d.ts +2 -2
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/build/utils/EntityPrivacyUtils.d.ts +4 -4
- package/build/utils/EntityPrivacyUtils.js.map +1 -1
- package/build/utils/collections/SerializableKeyMap.d.ts +27 -0
- package/build/utils/collections/SerializableKeyMap.js +60 -0
- package/build/utils/collections/SerializableKeyMap.js.map +1 -0
- package/build/utils/collections/maps.js +1 -2
- package/build/utils/collections/maps.js.map +1 -1
- package/build/utils/collections/sets.d.ts +1 -0
- package/build/utils/collections/sets.js +7 -0
- package/build/utils/collections/sets.js.map +1 -0
- package/build/utils/mergeEntityMutationTriggerConfigurations.d.ts +1 -1
- package/package.json +8 -5
- package/src/AuthorizationResultBasedEntityAssociationLoader.ts +56 -49
- package/src/AuthorizationResultBasedEntityLoader.ts +194 -81
- package/src/AuthorizationResultBasedEntityMutator.ts +71 -45
- package/src/ComposedEntityCacheAdapter.ts +55 -46
- package/src/ComposedSecondaryEntityCache.ts +5 -2
- package/src/EnforcingEntityAssociationLoader.ts +52 -44
- package/src/EnforcingEntityCreator.ts +5 -5
- package/src/EnforcingEntityDeleter.ts +5 -5
- package/src/EnforcingEntityLoader.ts +158 -21
- package/src/EnforcingEntityUpdater.ts +5 -5
- package/src/Entity.ts +39 -39
- package/src/EntityAssociationLoader.ts +6 -6
- package/src/EntityCompanion.ts +11 -11
- package/src/EntityCompanionProvider.ts +21 -18
- package/src/EntityConfiguration.ts +123 -9
- package/src/EntityCreator.ts +7 -7
- package/src/EntityDatabaseAdapter.ts +51 -28
- package/src/EntityDeleter.ts +7 -7
- package/src/EntityFieldDefinition.ts +32 -12
- package/src/EntityFields.ts +49 -12
- package/src/EntityLoader.ts +8 -8
- package/src/EntityLoaderFactory.ts +8 -8
- package/src/EntityLoaderUtils.ts +39 -10
- package/src/EntityMutationInfo.ts +6 -6
- package/src/EntityMutationTriggerConfiguration.ts +68 -20
- package/src/EntityMutationValidator.ts +4 -4
- package/src/EntityMutatorFactory.ts +13 -13
- package/src/EntityPrivacyPolicy.ts +50 -26
- package/src/EntitySecondaryCacheLoader.ts +6 -6
- package/src/EntityUpdater.ts +7 -7
- package/src/GenericEntityCacheAdapter.ts +39 -28
- package/src/GenericSecondaryEntityCache.ts +6 -3
- package/src/IEntityCacheAdapter.ts +45 -25
- package/src/IEntityCacheAdapterProvider.ts +3 -3
- package/src/IEntityDatabaseAdapterProvider.ts +3 -3
- package/src/IEntityGenericCacher.ts +33 -5
- package/src/ReadonlyEntity.ts +24 -24
- package/src/ViewerContext.ts +5 -5
- package/src/ViewerScopedEntityCompanion.ts +7 -7
- package/src/ViewerScopedEntityCompanionProvider.ts +6 -6
- package/src/ViewerScopedEntityLoaderFactory.ts +7 -7
- package/src/ViewerScopedEntityMutatorFactory.ts +8 -8
- package/src/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.ts +4 -4
- package/src/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.ts +14 -13
- package/src/__tests__/AuthorizationResultBasedEntityLoader-test.ts +367 -69
- package/src/__tests__/ComposedCacheAdapter-test.ts +235 -117
- package/src/__tests__/EnforcingEntityLoader-test.ts +135 -1
- package/src/__tests__/Entity-test.ts +2 -2
- package/src/__tests__/EntityAssociationLoader-test.ts +2 -2
- package/src/__tests__/EntityCommonUseCases-test.ts +11 -11
- package/src/__tests__/EntityCompanion-test.ts +4 -4
- package/src/__tests__/EntityCompanionProvider-test.ts +9 -8
- package/src/__tests__/EntityConfiguration-test.ts +85 -6
- package/src/__tests__/EntityDatabaseAdapter-test.ts +113 -17
- package/src/__tests__/EntityEdges-test.ts +97 -72
- package/src/__tests__/EntityFields-test.ts +2 -2
- package/src/__tests__/EntityLoader-test.ts +2 -2
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +11 -11
- package/src/__tests__/EntityMutator-SingleCompositeFieldCacheConsistency-test.ts +73 -0
- package/src/__tests__/EntityMutator-test.ts +74 -46
- package/src/__tests__/EntityPrivacyPolicy-test.ts +51 -74
- package/src/__tests__/EntityQueryContext-test.ts +1 -1
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +3 -3
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +64 -39
- package/src/__tests__/GenericEntityCacheAdapter-test.ts +83 -28
- package/src/__tests__/ReadonlyEntity-test.ts +3 -3
- package/src/__tests__/ViewerContext-test.ts +1 -1
- package/src/__tests__/ViewerScopedEntityCompanion-test.ts +5 -2
- package/src/__tests__/ViewerScopedEntityCompanionProvider-test.ts +1 -1
- package/src/__tests__/ViewerScopedEntityMutatorFactory-test.ts +12 -3
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +12 -12
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +12 -12
- package/src/entityUtils.ts +4 -1
- package/src/errors/EntityInvalidFieldValueError.ts +5 -5
- package/src/errors/EntityNotAuthorizedError.ts +3 -3
- package/src/errors/EntityNotFoundError.ts +5 -5
- package/src/index.ts +7 -7
- package/src/internal/CompositeFieldHolder.ts +218 -0
- package/src/internal/CompositeFieldValueMap.ts +78 -0
- package/src/internal/EntityDataManager.ts +107 -96
- package/src/internal/EntityFieldTransformationUtils.ts +33 -14
- package/src/internal/EntityLoadInterfaces.ts +143 -0
- package/src/internal/EntityTableDataCoordinator.ts +8 -5
- package/src/internal/ReadThroughEntityCache.ts +63 -50
- package/src/internal/SingleFieldHolder.ts +131 -0
- package/src/internal/__tests__/CompositeFieldHolder-test.ts +25 -0
- package/src/internal/__tests__/CompositeFieldValueMap-test.ts +43 -0
- package/src/internal/__tests__/EntityDataManager-test.ts +308 -91
- package/src/internal/__tests__/EntityFieldTransformationUtils-test.ts +3 -2
- package/src/internal/__tests__/ReadThroughEntityCache-test.ts +315 -107
- package/src/metrics/EntityMetricsUtils.ts +7 -2
- package/src/metrics/IEntityMetricsAdapter.ts +6 -0
- package/src/rules/AlwaysAllowPrivacyPolicyRule.ts +5 -5
- package/src/rules/AlwaysDenyPrivacyPolicyRule.ts +5 -5
- package/src/rules/AlwaysSkipPrivacyPolicyRule.ts +5 -5
- package/src/rules/PrivacyPolicyRule.ts +4 -4
- package/src/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.ts +1 -1
- package/src/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.ts +1 -1
- package/src/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.ts +1 -1
- package/src/utils/EntityPrivacyUtils.ts +72 -30
- package/src/utils/{testing → __testfixtures__}/PrivacyPolicyRuleTestUtils.ts +26 -26
- package/src/{testfixtures → utils/__testfixtures__}/SimpleTestEntity.ts +16 -15
- package/src/utils/__testfixtures__/StubCacheAdapter.ts +164 -0
- package/src/utils/{testing → __testfixtures__}/StubDatabaseAdapter.ts +19 -12
- package/src/utils/{testing → __testfixtures__}/StubDatabaseAdapterProvider.ts +4 -4
- package/src/utils/__testfixtures__/TSMockitoExtensions.ts +69 -0
- package/src/{testfixtures → utils/__testfixtures__}/TestEntity.ts +21 -15
- package/src/{testfixtures → utils/__testfixtures__}/TestEntity2.ts +16 -15
- package/src/{testfixtures → utils/__testfixtures__}/TestEntityWithMutationTriggers.ts +23 -22
- package/src/{testfixtures → utils/__testfixtures__}/TestViewerContext.ts +1 -1
- package/src/utils/{testing → __testfixtures__}/describeFieldTestCase.ts +1 -1
- package/src/utils/__tests__/EntityPrivacyUtils-test.ts +62 -66
- package/src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.ts +29 -25
- package/src/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.ts +1 -1
- package/src/utils/collections/SerializableKeyMap.ts +84 -0
- package/src/utils/collections/__tests__/SerializableKeyMap-test.ts +119 -0
- package/src/utils/collections/__tests__/sets-test.ts +17 -0
- package/src/utils/collections/maps.ts +7 -8
- package/src/utils/collections/sets.ts +3 -0
- package/src/utils/mergeEntityMutationTriggerConfigurations.ts +5 -5
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.d.ts +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js +0 -242
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js.map +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.d.ts +0 -26
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.js +0 -110
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.js.map +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.d.ts +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.js +0 -401
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.js.map +0 -1
- package/build/__tests__/ComposedCacheAdapter-test.d.ts +0 -1
- package/build/__tests__/ComposedCacheAdapter-test.js +0 -229
- package/build/__tests__/ComposedCacheAdapter-test.js.map +0 -1
- package/build/__tests__/ComposedSecondaryEntityCache-test.d.ts +0 -1
- package/build/__tests__/ComposedSecondaryEntityCache-test.js +0 -66
- package/build/__tests__/ComposedSecondaryEntityCache-test.js.map +0 -1
- package/build/__tests__/EnforcingEntityAssociationLoader-test.d.ts +0 -1
- package/build/__tests__/EnforcingEntityAssociationLoader-test.js +0 -115
- package/build/__tests__/EnforcingEntityAssociationLoader-test.js.map +0 -1
- package/build/__tests__/EnforcingEntityLoader-test.d.ts +0 -1
- package/build/__tests__/EnforcingEntityLoader-test.js +0 -253
- package/build/__tests__/EnforcingEntityLoader-test.js.map +0 -1
- package/build/__tests__/Entity-test.d.ts +0 -1
- package/build/__tests__/Entity-test.js +0 -94
- package/build/__tests__/Entity-test.js.map +0 -1
- package/build/__tests__/EntityAssociationLoader-test.d.ts +0 -1
- package/build/__tests__/EntityAssociationLoader-test.js +0 -30
- package/build/__tests__/EntityAssociationLoader-test.js.map +0 -1
- package/build/__tests__/EntityCommonUseCases-test.d.ts +0 -1
- package/build/__tests__/EntityCommonUseCases-test.js +0 -146
- package/build/__tests__/EntityCommonUseCases-test.js.map +0 -1
- package/build/__tests__/EntityCompanion-test.d.ts +0 -1
- package/build/__tests__/EntityCompanion-test.js +0 -77
- package/build/__tests__/EntityCompanion-test.js.map +0 -1
- package/build/__tests__/EntityCompanionProvider-test.d.ts +0 -1
- package/build/__tests__/EntityCompanionProvider-test.js +0 -54
- package/build/__tests__/EntityCompanionProvider-test.js.map +0 -1
- package/build/__tests__/EntityConfiguration-test.d.ts +0 -1
- package/build/__tests__/EntityConfiguration-test.js +0 -103
- package/build/__tests__/EntityConfiguration-test.js.map +0 -1
- package/build/__tests__/EntityDatabaseAdapter-test.d.ts +0 -1
- package/build/__tests__/EntityDatabaseAdapter-test.js +0 -146
- package/build/__tests__/EntityDatabaseAdapter-test.js.map +0 -1
- package/build/__tests__/EntityEdges-test.d.ts +0 -1
- package/build/__tests__/EntityEdges-test.js +0 -723
- package/build/__tests__/EntityEdges-test.js.map +0 -1
- package/build/__tests__/EntityFields-test.d.ts +0 -1
- package/build/__tests__/EntityFields-test.js +0 -63
- package/build/__tests__/EntityFields-test.js.map +0 -1
- package/build/__tests__/EntityLoader-test.d.ts +0 -1
- package/build/__tests__/EntityLoader-test.js +0 -36
- package/build/__tests__/EntityLoader-test.js.map +0 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.d.ts +0 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +0 -73
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +0 -1
- package/build/__tests__/EntityMutator-test.d.ts +0 -1
- package/build/__tests__/EntityMutator-test.js +0 -741
- package/build/__tests__/EntityMutator-test.js.map +0 -1
- package/build/__tests__/EntityPrivacyPolicy-test.d.ts +0 -1
- package/build/__tests__/EntityPrivacyPolicy-test.js +0 -463
- package/build/__tests__/EntityPrivacyPolicy-test.js.map +0 -1
- package/build/__tests__/EntityQueryContext-test.d.ts +0 -1
- package/build/__tests__/EntityQueryContext-test.js +0 -116
- package/build/__tests__/EntityQueryContext-test.js.map +0 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.d.ts +0 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.js +0 -60
- package/build/__tests__/EntitySecondaryCacheLoader-test.js.map +0 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.d.ts +0 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.js +0 -201
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +0 -1
- package/build/__tests__/GenericEntityCacheAdapter-test.d.ts +0 -1
- package/build/__tests__/GenericEntityCacheAdapter-test.js +0 -80
- package/build/__tests__/GenericEntityCacheAdapter-test.js.map +0 -1
- package/build/__tests__/ReadonlyEntity-test.d.ts +0 -1
- package/build/__tests__/ReadonlyEntity-test.js +0 -211
- package/build/__tests__/ReadonlyEntity-test.js.map +0 -1
- package/build/__tests__/ViewerContext-test.d.ts +0 -1
- package/build/__tests__/ViewerContext-test.js +0 -30
- package/build/__tests__/ViewerContext-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityCompanion-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityCompanion-test.js +0 -20
- package/build/__tests__/ViewerScopedEntityCompanion-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js +0 -20
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js +0 -23
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js +0 -22
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js.map +0 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.d.ts +0 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +0 -123
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +0 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.d.ts +0 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +0 -121
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +0 -1
- package/build/__tests__/entityUtils-test.d.ts +0 -1
- package/build/__tests__/entityUtils-test.js +0 -87
- package/build/__tests__/entityUtils-test.js.map +0 -1
- package/build/internal/__tests__/EntityDataManager-test.d.ts +0 -1
- package/build/internal/__tests__/EntityDataManager-test.js +0 -373
- package/build/internal/__tests__/EntityDataManager-test.js.map +0 -1
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.d.ts +0 -1
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js +0 -136
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js.map +0 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.d.ts +0 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.js +0 -206
- package/build/internal/__tests__/ReadThroughEntityCache-test.js.map +0 -1
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.d.ts +0 -1
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js +0 -21
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js.map +0 -1
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.d.ts +0 -1
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js +0 -21
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js.map +0 -1
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.d.ts +0 -1
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js +0 -21
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js.map +0 -1
- package/build/testfixtures/DateIDTestEntity.d.ts +0 -19
- package/build/testfixtures/DateIDTestEntity.js +0 -48
- package/build/testfixtures/DateIDTestEntity.js.map +0 -1
- package/build/testfixtures/SimpleTestEntity.d.ts +0 -20
- package/build/testfixtures/SimpleTestEntity.js +0 -48
- package/build/testfixtures/SimpleTestEntity.js.map +0 -1
- package/build/testfixtures/TestEntity.d.ts +0 -30
- package/build/testfixtures/TestEntity.js +0 -93
- package/build/testfixtures/TestEntity.js.map +0 -1
- package/build/testfixtures/TestEntity2.d.ts +0 -20
- package/build/testfixtures/TestEntity2.js +0 -51
- package/build/testfixtures/TestEntity2.js.map +0 -1
- package/build/testfixtures/TestEntityNumberKey.d.ts +0 -19
- package/build/testfixtures/TestEntityNumberKey.js +0 -48
- package/build/testfixtures/TestEntityNumberKey.js.map +0 -1
- package/build/testfixtures/TestEntityWithMutationTriggers.d.ts +0 -36
- package/build/testfixtures/TestEntityWithMutationTriggers.js +0 -82
- package/build/testfixtures/TestEntityWithMutationTriggers.js.map +0 -1
- package/build/testfixtures/TestViewerContext.d.ts +0 -3
- package/build/testfixtures/TestViewerContext.js +0 -10
- package/build/testfixtures/TestViewerContext.js.map +0 -1
- package/build/utils/__tests__/EntityPrivacyUtils-test.d.ts +0 -1
- package/build/utils/__tests__/EntityPrivacyUtils-test.js +0 -486
- package/build/utils/__tests__/EntityPrivacyUtils-test.js.map +0 -1
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.d.ts +0 -1
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js +0 -178
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js.map +0 -1
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.d.ts +0 -1
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js +0 -26
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js.map +0 -1
- package/build/utils/collections/__tests__/maps-test.d.ts +0 -1
- package/build/utils/collections/__tests__/maps-test.js +0 -120
- package/build/utils/collections/__tests__/maps-test.js.map +0 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.d.ts +0 -28
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js +0 -52
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js.map +0 -1
- package/build/utils/testing/StubCacheAdapter.d.ts +0 -27
- package/build/utils/testing/StubCacheAdapter.js +0 -86
- package/build/utils/testing/StubCacheAdapter.js.map +0 -1
- package/build/utils/testing/StubDatabaseAdapter.d.ts +0 -25
- package/build/utils/testing/StubDatabaseAdapter.js +0 -191
- package/build/utils/testing/StubDatabaseAdapter.js.map +0 -1
- package/build/utils/testing/StubDatabaseAdapterProvider.d.ts +0 -7
- package/build/utils/testing/StubDatabaseAdapterProvider.js +0 -14
- package/build/utils/testing/StubDatabaseAdapterProvider.js.map +0 -1
- package/build/utils/testing/StubQueryContextProvider.d.ts +0 -7
- package/build/utils/testing/StubQueryContextProvider.js +0 -19
- package/build/utils/testing/StubQueryContextProvider.js.map +0 -1
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.d.ts +0 -1
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js +0 -42
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js.map +0 -1
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.d.ts +0 -1
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js +0 -402
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js.map +0 -1
- package/build/utils/testing/createUnitTestEntityCompanionProvider.d.ts +0 -7
- package/build/utils/testing/createUnitTestEntityCompanionProvider.js +0 -36
- package/build/utils/testing/createUnitTestEntityCompanionProvider.js.map +0 -1
- package/build/utils/testing/describeFieldTestCase.d.ts +0 -2
- package/build/utils/testing/describeFieldTestCase.js +0 -18
- package/build/utils/testing/describeFieldTestCase.js.map +0 -1
- package/src/testfixtures/DateIDTestEntity.ts +0 -59
- package/src/testfixtures/TestEntityNumberKey.ts +0 -59
- package/src/utils/testing/StubCacheAdapter.ts +0 -122
- package/src/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.ts +0 -42
- package/src/utils/testing/__tests__/StubDatabaseAdapter-test.ts +0 -548
- /package/src/utils/{testing → __testfixtures__}/StubQueryContextProvider.ts +0 -0
- /package/src/utils/{testing → __testfixtures__}/createUnitTestEntityCompanionProvider.ts +0 -0
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { mock, when, instance, anything, verify,
|
|
1
|
+
import { mock, when, instance, anything, verify, deepEqual } from 'ts-mockito';
|
|
2
2
|
|
|
3
3
|
import GenericEntityCacheAdapter from '../GenericEntityCacheAdapter';
|
|
4
4
|
import IEntityGenericCacher from '../IEntityGenericCacher';
|
|
5
5
|
import { CacheStatus } from '../internal/ReadThroughEntityCache';
|
|
6
|
+
import {
|
|
7
|
+
SingleFieldHolder,
|
|
8
|
+
SingleFieldValueHolder,
|
|
9
|
+
SingleFieldValueHolderMap,
|
|
10
|
+
} from '../internal/SingleFieldHolder';
|
|
11
|
+
import { deepEqualEntityAware } from '../utils/__testfixtures__/TSMockitoExtensions';
|
|
6
12
|
|
|
7
13
|
type BlahFields = {
|
|
8
14
|
id: string;
|
|
@@ -11,9 +17,14 @@ type BlahFields = {
|
|
|
11
17
|
describe(GenericEntityCacheAdapter, () => {
|
|
12
18
|
describe('loadManyAsync', () => {
|
|
13
19
|
it('returns appropriate cache results', async () => {
|
|
14
|
-
const mockGenericCacher = mock<IEntityGenericCacher<BlahFields>>();
|
|
15
|
-
when(
|
|
16
|
-
|
|
20
|
+
const mockGenericCacher = mock<IEntityGenericCacher<BlahFields, 'id'>>();
|
|
21
|
+
when(
|
|
22
|
+
mockGenericCacher.makeCacheKeyForStorage(
|
|
23
|
+
deepEqualEntityAware(new SingleFieldHolder('id')),
|
|
24
|
+
anything(),
|
|
25
|
+
),
|
|
26
|
+
).thenCall((fieldHolder, fieldValueHolder) => {
|
|
27
|
+
return `${fieldHolder.fieldName}.${fieldValueHolder.fieldValue}`;
|
|
17
28
|
});
|
|
18
29
|
when(mockGenericCacher.loadManyAsync(deepEqual(['id.wat', 'id.who', 'id.why']))).thenResolve(
|
|
19
30
|
new Map([
|
|
@@ -25,34 +36,56 @@ describe(GenericEntityCacheAdapter, () => {
|
|
|
25
36
|
|
|
26
37
|
const cacheAdapter = new GenericEntityCacheAdapter(instance(mockGenericCacher));
|
|
27
38
|
|
|
28
|
-
const results = await cacheAdapter.loadManyAsync('id', [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
const results = await cacheAdapter.loadManyAsync(new SingleFieldHolder('id'), [
|
|
40
|
+
new SingleFieldValueHolder('wat'),
|
|
41
|
+
new SingleFieldValueHolder('who'),
|
|
42
|
+
new SingleFieldValueHolder('why'),
|
|
43
|
+
]);
|
|
44
|
+
expect(results.get(new SingleFieldValueHolder('wat'))).toMatchObject({
|
|
45
|
+
status: CacheStatus.HIT,
|
|
46
|
+
item: { id: 'wat' },
|
|
47
|
+
});
|
|
48
|
+
expect(results.get(new SingleFieldValueHolder('who'))).toMatchObject({
|
|
49
|
+
status: CacheStatus.NEGATIVE,
|
|
50
|
+
});
|
|
51
|
+
expect(results.get(new SingleFieldValueHolder('why'))).toMatchObject({
|
|
52
|
+
status: CacheStatus.MISS,
|
|
53
|
+
});
|
|
32
54
|
expect(results.size).toBe(3);
|
|
33
55
|
|
|
34
56
|
verify(mockGenericCacher.loadManyAsync(anything())).once();
|
|
35
57
|
});
|
|
36
58
|
|
|
37
|
-
it('returns empty map when passed empty array of
|
|
38
|
-
const mockGenericCacher = mock<IEntityGenericCacher<BlahFields>>();
|
|
59
|
+
it('returns empty map when passed empty array of load values', async () => {
|
|
60
|
+
const mockGenericCacher = mock<IEntityGenericCacher<BlahFields, 'id'>>();
|
|
39
61
|
when(mockGenericCacher.loadManyAsync(deepEqual([]))).thenResolve(new Map([]));
|
|
40
62
|
|
|
41
63
|
const cacheAdapter = new GenericEntityCacheAdapter(instance(mockGenericCacher));
|
|
42
|
-
const results = await cacheAdapter.loadManyAsync(
|
|
43
|
-
|
|
64
|
+
const results = await cacheAdapter.loadManyAsync(
|
|
65
|
+
new SingleFieldHolder<BlahFields, 'id', 'id'>('id'),
|
|
66
|
+
[] as SingleFieldValueHolder<BlahFields, 'id'>[],
|
|
67
|
+
);
|
|
68
|
+
expect(results).toEqual(new SingleFieldValueHolderMap(new Map()));
|
|
44
69
|
});
|
|
45
70
|
});
|
|
46
71
|
|
|
47
72
|
describe('cacheManyAsync', () => {
|
|
48
73
|
it('correctly caches all objects', async () => {
|
|
49
|
-
const mockGenericCacher = mock<IEntityGenericCacher<BlahFields>>();
|
|
50
|
-
when(
|
|
51
|
-
|
|
74
|
+
const mockGenericCacher = mock<IEntityGenericCacher<BlahFields, 'id'>>();
|
|
75
|
+
when(
|
|
76
|
+
mockGenericCacher.makeCacheKeyForStorage(
|
|
77
|
+
deepEqualEntityAware(new SingleFieldHolder('id')),
|
|
78
|
+
anything(),
|
|
79
|
+
),
|
|
80
|
+
).thenCall((fieldHolder, fieldValueHolder) => {
|
|
81
|
+
return `${fieldHolder.fieldName}.${fieldValueHolder.fieldValue}`;
|
|
52
82
|
});
|
|
53
83
|
|
|
54
84
|
const cacheAdapter = new GenericEntityCacheAdapter(instance(mockGenericCacher));
|
|
55
|
-
await cacheAdapter.cacheManyAsync(
|
|
85
|
+
await cacheAdapter.cacheManyAsync(
|
|
86
|
+
new SingleFieldHolder('id'),
|
|
87
|
+
new Map([[new SingleFieldValueHolder('wat'), { id: 'wat' }]]),
|
|
88
|
+
);
|
|
56
89
|
|
|
57
90
|
verify(
|
|
58
91
|
mockGenericCacher.cacheManyAsync(deepEqual(new Map([['id.wat', { id: 'wat' }]]))),
|
|
@@ -62,13 +95,20 @@ describe(GenericEntityCacheAdapter, () => {
|
|
|
62
95
|
|
|
63
96
|
describe('cacheDBMissesAsync', () => {
|
|
64
97
|
it('correctly caches misses', async () => {
|
|
65
|
-
const mockGenericCacher = mock<IEntityGenericCacher<BlahFields>>();
|
|
66
|
-
when(
|
|
67
|
-
|
|
98
|
+
const mockGenericCacher = mock<IEntityGenericCacher<BlahFields, 'id'>>();
|
|
99
|
+
when(
|
|
100
|
+
mockGenericCacher.makeCacheKeyForStorage(
|
|
101
|
+
deepEqualEntityAware(new SingleFieldHolder('id')),
|
|
102
|
+
anything(),
|
|
103
|
+
),
|
|
104
|
+
).thenCall((fieldHolder, fieldValueHolder) => {
|
|
105
|
+
return `${fieldHolder.fieldName}.${fieldValueHolder.fieldValue}`;
|
|
68
106
|
});
|
|
69
107
|
|
|
70
108
|
const cacheAdapter = new GenericEntityCacheAdapter(instance(mockGenericCacher));
|
|
71
|
-
await cacheAdapter.cacheDBMissesAsync('id', [
|
|
109
|
+
await cacheAdapter.cacheDBMissesAsync(new SingleFieldHolder('id'), [
|
|
110
|
+
new SingleFieldValueHolder('wat'),
|
|
111
|
+
]);
|
|
72
112
|
|
|
73
113
|
verify(mockGenericCacher.cacheDBMissesAsync(deepEqual(['id.wat']))).once();
|
|
74
114
|
});
|
|
@@ -76,25 +116,40 @@ describe(GenericEntityCacheAdapter, () => {
|
|
|
76
116
|
|
|
77
117
|
describe('invalidateManyAsync', () => {
|
|
78
118
|
it('invalidates correctly', async () => {
|
|
79
|
-
const mockGenericCacher = mock<IEntityGenericCacher<BlahFields>>();
|
|
80
|
-
when(
|
|
81
|
-
|
|
119
|
+
const mockGenericCacher = mock<IEntityGenericCacher<BlahFields, 'id'>>();
|
|
120
|
+
when(
|
|
121
|
+
mockGenericCacher.makeCacheKeysForInvalidation(
|
|
122
|
+
deepEqualEntityAware(new SingleFieldHolder('id')),
|
|
123
|
+
anything(),
|
|
124
|
+
),
|
|
125
|
+
).thenCall((fieldHolder, fieldValueHolder) => {
|
|
126
|
+
return `${fieldHolder.fieldName}.${fieldValueHolder.fieldValue}`;
|
|
82
127
|
});
|
|
83
128
|
|
|
84
129
|
const cacheAdapter = new GenericEntityCacheAdapter(instance(mockGenericCacher));
|
|
85
|
-
await cacheAdapter.invalidateManyAsync('id', [
|
|
130
|
+
await cacheAdapter.invalidateManyAsync(new SingleFieldHolder('id'), [
|
|
131
|
+
new SingleFieldValueHolder('wat'),
|
|
132
|
+
]);
|
|
86
133
|
|
|
87
134
|
verify(mockGenericCacher.invalidateManyAsync(deepEqual(['id.wat']))).once();
|
|
88
135
|
});
|
|
89
136
|
|
|
90
137
|
it('returns when passed empty array of fieldValues', async () => {
|
|
91
|
-
const mockGenericCacher = mock<IEntityGenericCacher<BlahFields>>();
|
|
92
|
-
when(
|
|
93
|
-
|
|
138
|
+
const mockGenericCacher = mock<IEntityGenericCacher<BlahFields, 'id'>>();
|
|
139
|
+
when(
|
|
140
|
+
mockGenericCacher.makeCacheKeysForInvalidation(
|
|
141
|
+
deepEqualEntityAware(new SingleFieldHolder('id')),
|
|
142
|
+
anything(),
|
|
143
|
+
),
|
|
144
|
+
).thenCall((fieldHolder, fieldValueHolder) => {
|
|
145
|
+
return `${fieldHolder.fieldName}.${fieldValueHolder.fieldValue}`;
|
|
94
146
|
});
|
|
95
147
|
|
|
96
148
|
const cacheAdapter = new GenericEntityCacheAdapter(instance(mockGenericCacher));
|
|
97
|
-
await cacheAdapter.invalidateManyAsync(
|
|
149
|
+
await cacheAdapter.invalidateManyAsync(
|
|
150
|
+
new SingleFieldHolder<BlahFields, 'id', 'id'>('id'),
|
|
151
|
+
[] as SingleFieldValueHolder<BlahFields, 'id'>[],
|
|
152
|
+
);
|
|
98
153
|
|
|
99
154
|
verify(mockGenericCacher.invalidateManyAsync(deepEqual([]))).once();
|
|
100
155
|
});
|
|
@@ -7,9 +7,9 @@ import EnforcingEntityLoader from '../EnforcingEntityLoader';
|
|
|
7
7
|
import EntityLoaderUtils from '../EntityLoaderUtils';
|
|
8
8
|
import ReadonlyEntity from '../ReadonlyEntity';
|
|
9
9
|
import ViewerContext from '../ViewerContext';
|
|
10
|
-
import SimpleTestEntity from '../
|
|
11
|
-
import TestEntity from '../
|
|
12
|
-
import { createUnitTestEntityCompanionProvider } from '../utils/
|
|
10
|
+
import SimpleTestEntity from '../utils/__testfixtures__/SimpleTestEntity';
|
|
11
|
+
import TestEntity from '../utils/__testfixtures__/TestEntity';
|
|
12
|
+
import { createUnitTestEntityCompanionProvider } from '../utils/__testfixtures__/createUnitTestEntityCompanionProvider';
|
|
13
13
|
|
|
14
14
|
describe(ReadonlyEntity, () => {
|
|
15
15
|
describe('getID', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EntityQueryContext } from '../EntityQueryContext';
|
|
2
2
|
import ViewerContext from '../ViewerContext';
|
|
3
|
-
import { createUnitTestEntityCompanionProvider } from '../utils/
|
|
3
|
+
import { createUnitTestEntityCompanionProvider } from '../utils/__testfixtures__/createUnitTestEntityCompanionProvider';
|
|
4
4
|
|
|
5
5
|
describe(ViewerContext, () => {
|
|
6
6
|
describe('getQueryContextForDatabaseAdaptorFlavor', () => {
|
|
@@ -5,7 +5,10 @@ import ViewerContext from '../ViewerContext';
|
|
|
5
5
|
import ViewerScopedEntityCompanion from '../ViewerScopedEntityCompanion';
|
|
6
6
|
import ViewerScopedEntityLoaderFactory from '../ViewerScopedEntityLoaderFactory';
|
|
7
7
|
import ViewerScopedEntityMutatorFactory from '../ViewerScopedEntityMutatorFactory';
|
|
8
|
-
import TestEntity, {
|
|
8
|
+
import TestEntity, {
|
|
9
|
+
TestFields,
|
|
10
|
+
TestEntityPrivacyPolicy,
|
|
11
|
+
} from '../utils/__testfixtures__/TestEntity';
|
|
9
12
|
|
|
10
13
|
describe(ViewerScopedEntityCompanion, () => {
|
|
11
14
|
it('returns viewer scoped loader and mutator factory', () => {
|
|
@@ -14,7 +17,7 @@ describe(ViewerScopedEntityCompanion, () => {
|
|
|
14
17
|
mock<
|
|
15
18
|
EntityCompanion<
|
|
16
19
|
TestFields,
|
|
17
|
-
|
|
20
|
+
'customIdField',
|
|
18
21
|
ViewerContext,
|
|
19
22
|
TestEntity,
|
|
20
23
|
TestEntityPrivacyPolicy,
|
|
@@ -4,7 +4,7 @@ import EntityCompanionProvider from '../EntityCompanionProvider';
|
|
|
4
4
|
import ViewerContext from '../ViewerContext';
|
|
5
5
|
import ViewerScopedEntityCompanion from '../ViewerScopedEntityCompanion';
|
|
6
6
|
import ViewerScopedEntityCompanionProvider from '../ViewerScopedEntityCompanionProvider';
|
|
7
|
-
import TestEntity from '../
|
|
7
|
+
import TestEntity from '../utils/__testfixtures__/TestEntity';
|
|
8
8
|
|
|
9
9
|
describe(ViewerScopedEntityCompanionProvider, () => {
|
|
10
10
|
it('returns viewer scoped entity companion', () => {
|
|
@@ -4,7 +4,10 @@ import EntityMutatorFactory from '../EntityMutatorFactory';
|
|
|
4
4
|
import { EntityQueryContext } from '../EntityQueryContext';
|
|
5
5
|
import ViewerContext from '../ViewerContext';
|
|
6
6
|
import ViewerScopedEntityMutatorFactory from '../ViewerScopedEntityMutatorFactory';
|
|
7
|
-
import TestEntity, {
|
|
7
|
+
import TestEntity, {
|
|
8
|
+
TestFields,
|
|
9
|
+
TestEntityPrivacyPolicy,
|
|
10
|
+
} from '../utils/__testfixtures__/TestEntity';
|
|
8
11
|
|
|
9
12
|
describe(ViewerScopedEntityMutatorFactory, () => {
|
|
10
13
|
it('correctly scopes viewer to entity mutations', async () => {
|
|
@@ -12,13 +15,19 @@ describe(ViewerScopedEntityMutatorFactory, () => {
|
|
|
12
15
|
const queryContext = instance(mock(EntityQueryContext));
|
|
13
16
|
const baseMutatorFactory =
|
|
14
17
|
mock<
|
|
15
|
-
EntityMutatorFactory<
|
|
18
|
+
EntityMutatorFactory<
|
|
19
|
+
TestFields,
|
|
20
|
+
'customIdField',
|
|
21
|
+
ViewerContext,
|
|
22
|
+
TestEntity,
|
|
23
|
+
TestEntityPrivacyPolicy
|
|
24
|
+
>
|
|
16
25
|
>(EntityMutatorFactory);
|
|
17
26
|
const baseMutatorFactoryInstance = instance(baseMutatorFactory);
|
|
18
27
|
|
|
19
28
|
const viewerScopedEntityLoader = new ViewerScopedEntityMutatorFactory<
|
|
20
29
|
TestFields,
|
|
21
|
-
|
|
30
|
+
'customIdField',
|
|
22
31
|
ViewerContext,
|
|
23
32
|
TestEntity,
|
|
24
33
|
TestEntityPrivacyPolicy,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Entity from '../../Entity';
|
|
2
2
|
import { EntityCompanionDefinition } from '../../EntityCompanionProvider';
|
|
3
3
|
import EntityConfiguration from '../../EntityConfiguration';
|
|
4
|
-
import {
|
|
4
|
+
import { StringField, StrictEnumField, UUIDField } from '../../EntityFields';
|
|
5
5
|
import EntityPrivacyPolicy from '../../EntityPrivacyPolicy';
|
|
6
6
|
import ViewerContext from '../../ViewerContext';
|
|
7
7
|
import { successfulResults, failedResults } from '../../entityUtils';
|
|
8
8
|
import AlwaysAllowPrivacyPolicyRule from '../../rules/AlwaysAllowPrivacyPolicyRule';
|
|
9
|
-
import { createUnitTestEntityCompanionProvider } from '../../utils/
|
|
9
|
+
import { createUnitTestEntityCompanionProvider } from '../../utils/__testfixtures__/createUnitTestEntityCompanionProvider';
|
|
10
10
|
|
|
11
11
|
describe('Two entities backed by the same table', () => {
|
|
12
12
|
test('load by different types', async () => {
|
|
@@ -83,7 +83,7 @@ interface TestFields {
|
|
|
83
83
|
type OneTestFields = 'id' | 'entity_type' | 'common_other_field';
|
|
84
84
|
type TwoTestFields = 'id' | 'other_field' | 'entity_type' | 'common_other_field';
|
|
85
85
|
|
|
86
|
-
const testEntityConfiguration = new EntityConfiguration<TestFields>({
|
|
86
|
+
const testEntityConfiguration = new EntityConfiguration<TestFields, 'id'>({
|
|
87
87
|
idField: 'id',
|
|
88
88
|
tableName: 'entities',
|
|
89
89
|
schema: {
|
|
@@ -106,22 +106,22 @@ const testEntityConfiguration = new EntityConfiguration<TestFields>({
|
|
|
106
106
|
cacheAdapterFlavor: 'redis',
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
class TestEntityPrivacyPolicy extends EntityPrivacyPolicy<any,
|
|
109
|
+
class TestEntityPrivacyPolicy extends EntityPrivacyPolicy<any, 'id', ViewerContext, any, any> {
|
|
110
110
|
protected override readonly readRules = [
|
|
111
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
111
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
112
112
|
];
|
|
113
113
|
protected override readonly createRules = [
|
|
114
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
114
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
115
115
|
];
|
|
116
116
|
protected override readonly updateRules = [
|
|
117
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
117
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
118
118
|
];
|
|
119
119
|
protected override readonly deleteRules = [
|
|
120
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
120
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
121
121
|
];
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
class OneTestEntity extends Entity<TestFields,
|
|
124
|
+
class OneTestEntity extends Entity<TestFields, 'id', ViewerContext, OneTestFields> {
|
|
125
125
|
constructor(constructorParams: {
|
|
126
126
|
viewerContext: ViewerContext;
|
|
127
127
|
id: string;
|
|
@@ -136,7 +136,7 @@ class OneTestEntity extends Entity<TestFields, string, ViewerContext, OneTestFie
|
|
|
136
136
|
|
|
137
137
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
138
138
|
TestFields,
|
|
139
|
-
|
|
139
|
+
'id',
|
|
140
140
|
ViewerContext,
|
|
141
141
|
OneTestEntity,
|
|
142
142
|
TestEntityPrivacyPolicy,
|
|
@@ -151,7 +151,7 @@ class OneTestEntity extends Entity<TestFields, string, ViewerContext, OneTestFie
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
class TwoTestEntity extends Entity<TestFields,
|
|
154
|
+
class TwoTestEntity extends Entity<TestFields, 'id', ViewerContext, TwoTestFields> {
|
|
155
155
|
constructor(constructorParams: {
|
|
156
156
|
viewerContext: ViewerContext;
|
|
157
157
|
id: string;
|
|
@@ -166,7 +166,7 @@ class TwoTestEntity extends Entity<TestFields, string, ViewerContext, TwoTestFie
|
|
|
166
166
|
|
|
167
167
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
168
168
|
TestFields,
|
|
169
|
-
|
|
169
|
+
'id',
|
|
170
170
|
ViewerContext,
|
|
171
171
|
TwoTestEntity,
|
|
172
172
|
TestEntityPrivacyPolicy,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import Entity from '../../Entity';
|
|
2
2
|
import { EntityCompanionDefinition } from '../../EntityCompanionProvider';
|
|
3
3
|
import EntityConfiguration from '../../EntityConfiguration';
|
|
4
|
-
import {
|
|
4
|
+
import { StringField, UUIDField } from '../../EntityFields';
|
|
5
5
|
import EntityPrivacyPolicy from '../../EntityPrivacyPolicy';
|
|
6
6
|
import ViewerContext from '../../ViewerContext';
|
|
7
7
|
import AlwaysAllowPrivacyPolicyRule from '../../rules/AlwaysAllowPrivacyPolicyRule';
|
|
8
|
-
import { createUnitTestEntityCompanionProvider } from '../../utils/
|
|
8
|
+
import { createUnitTestEntityCompanionProvider } from '../../utils/__testfixtures__/createUnitTestEntityCompanionProvider';
|
|
9
9
|
|
|
10
10
|
describe('Two entities backed by the same table', () => {
|
|
11
11
|
test('mutate through different types and keep consistent cache and dataloader', async () => {
|
|
@@ -90,7 +90,7 @@ interface TestFields {
|
|
|
90
90
|
type OneTestFields = 'id' | 'fake_field';
|
|
91
91
|
type TwoTestFields = 'id' | 'other_field' | 'fake_field';
|
|
92
92
|
|
|
93
|
-
const testEntityConfiguration = new EntityConfiguration<TestFields>({
|
|
93
|
+
const testEntityConfiguration = new EntityConfiguration<TestFields, 'id'>({
|
|
94
94
|
idField: 'id',
|
|
95
95
|
tableName: 'entities',
|
|
96
96
|
schema: {
|
|
@@ -111,25 +111,25 @@ const testEntityConfiguration = new EntityConfiguration<TestFields>({
|
|
|
111
111
|
cacheAdapterFlavor: 'redis',
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
class TestEntityPrivacyPolicy extends EntityPrivacyPolicy<any,
|
|
114
|
+
class TestEntityPrivacyPolicy extends EntityPrivacyPolicy<any, 'id', ViewerContext, any, any> {
|
|
115
115
|
protected override readonly readRules = [
|
|
116
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
116
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
117
117
|
];
|
|
118
118
|
protected override readonly createRules = [
|
|
119
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
119
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
120
120
|
];
|
|
121
121
|
protected override readonly updateRules = [
|
|
122
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
122
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
123
123
|
];
|
|
124
124
|
protected override readonly deleteRules = [
|
|
125
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
125
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
126
126
|
];
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
class OneTestEntity extends Entity<TestFields,
|
|
129
|
+
class OneTestEntity extends Entity<TestFields, 'id', ViewerContext, OneTestFields> {
|
|
130
130
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
131
131
|
TestFields,
|
|
132
|
-
|
|
132
|
+
'id',
|
|
133
133
|
ViewerContext,
|
|
134
134
|
OneTestEntity,
|
|
135
135
|
TestEntityPrivacyPolicy,
|
|
@@ -144,10 +144,10 @@ class OneTestEntity extends Entity<TestFields, string, ViewerContext, OneTestFie
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
class TwoTestEntity extends Entity<TestFields,
|
|
147
|
+
class TwoTestEntity extends Entity<TestFields, 'id', ViewerContext, TwoTestFields> {
|
|
148
148
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
149
149
|
TestFields,
|
|
150
|
-
|
|
150
|
+
'id',
|
|
151
151
|
ViewerContext,
|
|
152
152
|
TwoTestEntity,
|
|
153
153
|
TestEntityPrivacyPolicy,
|
package/src/entityUtils.ts
CHANGED
|
@@ -109,7 +109,10 @@ const isError = <T>(value: T | Error): value is Error => {
|
|
|
109
109
|
return value instanceof Error;
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
export const pick = <T extends object, U extends keyof T>(
|
|
112
|
+
export const pick = <T extends object, U extends keyof T>(
|
|
113
|
+
object: T,
|
|
114
|
+
props: readonly U[],
|
|
115
|
+
): Pick<T, U> => {
|
|
113
116
|
const propsSet = new Set(props);
|
|
114
117
|
return Object.fromEntries(
|
|
115
118
|
Object.entries(object).filter((entry) => propsSet.has(entry[0] as any)),
|
|
@@ -5,13 +5,13 @@ import ReadonlyEntity from '../ReadonlyEntity';
|
|
|
5
5
|
import ViewerContext from '../ViewerContext';
|
|
6
6
|
|
|
7
7
|
export default class EntityInvalidFieldValueError<
|
|
8
|
-
TFields extends
|
|
9
|
-
|
|
8
|
+
TFields extends Record<string, any>,
|
|
9
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
10
10
|
TViewerContext extends ViewerContext,
|
|
11
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
11
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
12
12
|
TPrivacyPolicy extends EntityPrivacyPolicy<
|
|
13
13
|
TFields,
|
|
14
|
-
|
|
14
|
+
TIDField,
|
|
15
15
|
TViewerContext,
|
|
16
16
|
TEntity,
|
|
17
17
|
TSelectedFields
|
|
@@ -25,7 +25,7 @@ export default class EntityInvalidFieldValueError<
|
|
|
25
25
|
constructor(
|
|
26
26
|
entityClass: IEntityClass<
|
|
27
27
|
TFields,
|
|
28
|
-
|
|
28
|
+
TIDField,
|
|
29
29
|
TViewerContext,
|
|
30
30
|
TEntity,
|
|
31
31
|
TPrivacyPolicy,
|
|
@@ -4,10 +4,10 @@ import ReadonlyEntity from '../ReadonlyEntity';
|
|
|
4
4
|
import ViewerContext from '../ViewerContext';
|
|
5
5
|
|
|
6
6
|
export default class EntityNotAuthorizedError<
|
|
7
|
-
TFields extends
|
|
8
|
-
|
|
7
|
+
TFields extends Record<string, any>,
|
|
8
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
9
9
|
TViewerContext extends ViewerContext,
|
|
10
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
10
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
11
11
|
TSelectedFields extends keyof TFields = keyof TFields,
|
|
12
12
|
> extends EntityError {
|
|
13
13
|
public readonly state = EntityErrorState.PERMANENT;
|
|
@@ -5,13 +5,13 @@ import ReadonlyEntity from '../ReadonlyEntity';
|
|
|
5
5
|
import ViewerContext from '../ViewerContext';
|
|
6
6
|
|
|
7
7
|
export default class EntityNotFoundError<
|
|
8
|
-
TFields extends
|
|
9
|
-
|
|
8
|
+
TFields extends Record<string, any>,
|
|
9
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
10
10
|
TViewerContext extends ViewerContext,
|
|
11
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
11
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
12
12
|
TPrivacyPolicy extends EntityPrivacyPolicy<
|
|
13
13
|
TFields,
|
|
14
|
-
|
|
14
|
+
TIDField,
|
|
15
15
|
TViewerContext,
|
|
16
16
|
TEntity,
|
|
17
17
|
TSelectedFields
|
|
@@ -25,7 +25,7 @@ export default class EntityNotFoundError<
|
|
|
25
25
|
constructor(
|
|
26
26
|
entityClass: IEntityClass<
|
|
27
27
|
TFields,
|
|
28
|
-
|
|
28
|
+
TIDField,
|
|
29
29
|
TViewerContext,
|
|
30
30
|
TEntity,
|
|
31
31
|
TPrivacyPolicy,
|
package/src/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ export * from './EntityCompanion';
|
|
|
23
23
|
export { default as EntityCompanionProvider } from './EntityCompanionProvider';
|
|
24
24
|
export * from './EntityCompanionProvider';
|
|
25
25
|
export { default as EntityConfiguration } from './EntityConfiguration';
|
|
26
|
+
export * from './EntityConfiguration';
|
|
26
27
|
export { default as EntityCreator } from './EntityCreator';
|
|
27
28
|
export { default as EntityDatabaseAdapter } from './EntityDatabaseAdapter';
|
|
28
29
|
export * from './EntityDatabaseAdapter';
|
|
@@ -66,11 +67,15 @@ export * from './errors/EntityError';
|
|
|
66
67
|
export { default as EntityInvalidFieldValueError } from './errors/EntityInvalidFieldValueError';
|
|
67
68
|
export { default as EntityNotAuthorizedError } from './errors/EntityNotAuthorizedError';
|
|
68
69
|
export { default as EntityNotFoundError } from './errors/EntityNotFoundError';
|
|
70
|
+
export * from './internal/CompositeFieldHolder';
|
|
71
|
+
export * from './internal/CompositeFieldValueMap';
|
|
69
72
|
export { default as EntityDataManager } from './internal/EntityDataManager';
|
|
70
73
|
export * from './internal/EntityFieldTransformationUtils';
|
|
74
|
+
export * from './internal/EntityLoadInterfaces';
|
|
71
75
|
export { default as EntityTableDataCoordinator } from './internal/EntityTableDataCoordinator';
|
|
72
76
|
export { default as ReadThroughEntityCache } from './internal/ReadThroughEntityCache';
|
|
73
77
|
export * from './internal/ReadThroughEntityCache';
|
|
78
|
+
export * from './internal/SingleFieldHolder';
|
|
74
79
|
export * from './metrics/EntityMetricsUtils';
|
|
75
80
|
export { type default as IEntityMetricsAdapter } from './metrics/IEntityMetricsAdapter';
|
|
76
81
|
export * from './metrics/IEntityMetricsAdapter';
|
|
@@ -83,10 +88,5 @@ export * from './rules/PrivacyPolicyRule';
|
|
|
83
88
|
export * from './utils/EntityPrivacyUtils';
|
|
84
89
|
export * from './utils/mergeEntityMutationTriggerConfigurations';
|
|
85
90
|
export * from './utils/collections/maps';
|
|
86
|
-
export * from './utils/
|
|
87
|
-
export
|
|
88
|
-
export * from './utils/testing/PrivacyPolicyRuleTestUtils';
|
|
89
|
-
export * from './utils/testing/StubCacheAdapter';
|
|
90
|
-
export { default as StubDatabaseAdapter } from './utils/testing/StubDatabaseAdapter';
|
|
91
|
-
export { default as StubDatabaseAdapterProvider } from './utils/testing/StubDatabaseAdapterProvider';
|
|
92
|
-
export { default as StubQueryContextProvider } from './utils/testing/StubQueryContextProvider';
|
|
91
|
+
export * from './utils/collections/SerializableKeyMap';
|
|
92
|
+
export * from './utils/collections/sets';
|