@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
|
@@ -1,22 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthorizationResultBasedCreateMutator,
|
|
3
|
+
AuthorizationResultBasedDeleteMutator,
|
|
4
|
+
AuthorizationResultBasedUpdateMutator,
|
|
5
|
+
} from '../AuthorizationResultBasedEntityMutator';
|
|
6
|
+
import EnforcingEntityCreator from '../EnforcingEntityCreator';
|
|
7
|
+
import EnforcingEntityDeleter from '../EnforcingEntityDeleter';
|
|
8
|
+
import EnforcingEntityUpdater from '../EnforcingEntityUpdater';
|
|
1
9
|
import Entity from '../Entity';
|
|
2
|
-
import EntityCreator from '../EntityCreator';
|
|
3
|
-
import EntityDeleter from '../EntityDeleter';
|
|
4
|
-
import EntityUpdater from '../EntityUpdater';
|
|
5
10
|
import ViewerContext from '../ViewerContext';
|
|
6
|
-
import SimpleTestEntity from '../
|
|
7
|
-
import { createUnitTestEntityCompanionProvider } from '../utils/
|
|
11
|
+
import SimpleTestEntity from '../utils/__testfixtures__/SimpleTestEntity';
|
|
12
|
+
import { createUnitTestEntityCompanionProvider } from '../utils/__testfixtures__/createUnitTestEntityCompanionProvider';
|
|
8
13
|
|
|
9
14
|
describe(Entity, () => {
|
|
10
15
|
describe('creator', () => {
|
|
11
|
-
it('creates a new
|
|
16
|
+
it('creates a new EnforcingEntityCreator', () => {
|
|
12
17
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
13
18
|
const viewerContext = new ViewerContext(companionProvider);
|
|
14
|
-
expect(SimpleTestEntity.creator(viewerContext)).toBeInstanceOf(
|
|
19
|
+
expect(SimpleTestEntity.creator(viewerContext)).toBeInstanceOf(EnforcingEntityCreator);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('creatorWithAuthorizationResults', () => {
|
|
24
|
+
it('creates a new AuthorizationResultBasedCreateMutator', () => {
|
|
25
|
+
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
26
|
+
const viewerContext = new ViewerContext(companionProvider);
|
|
27
|
+
expect(SimpleTestEntity.creatorWithAuthorizationResults(viewerContext)).toBeInstanceOf(
|
|
28
|
+
AuthorizationResultBasedCreateMutator,
|
|
29
|
+
);
|
|
15
30
|
});
|
|
16
31
|
});
|
|
17
32
|
|
|
18
33
|
describe('updater', () => {
|
|
19
|
-
it('creates a new
|
|
34
|
+
it('creates a new EnforcingEntityUpdater', () => {
|
|
20
35
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
21
36
|
const viewerContext = new ViewerContext(companionProvider);
|
|
22
37
|
const data = {
|
|
@@ -28,12 +43,48 @@ describe(Entity, () => {
|
|
|
28
43
|
databaseFields: data,
|
|
29
44
|
selectedFields: data,
|
|
30
45
|
});
|
|
31
|
-
expect(SimpleTestEntity.updater(testEntity)).toBeInstanceOf(
|
|
46
|
+
expect(SimpleTestEntity.updater(testEntity)).toBeInstanceOf(EnforcingEntityUpdater);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('updaterWithAuthorizationResults', () => {
|
|
51
|
+
it('creates a new AuthorizationResultBasedUpdateMutator', () => {
|
|
52
|
+
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
53
|
+
const viewerContext = new ViewerContext(companionProvider);
|
|
54
|
+
const data = {
|
|
55
|
+
id: 'what',
|
|
56
|
+
};
|
|
57
|
+
const testEntity = new SimpleTestEntity({
|
|
58
|
+
viewerContext,
|
|
59
|
+
id: 'what',
|
|
60
|
+
databaseFields: data,
|
|
61
|
+
selectedFields: data,
|
|
62
|
+
});
|
|
63
|
+
expect(SimpleTestEntity.updaterWithAuthorizationResults(testEntity)).toBeInstanceOf(
|
|
64
|
+
AuthorizationResultBasedUpdateMutator,
|
|
65
|
+
);
|
|
32
66
|
});
|
|
33
67
|
});
|
|
34
68
|
|
|
35
69
|
describe('deleter', () => {
|
|
36
|
-
it('creates a new
|
|
70
|
+
it('creates a new EnforcingEntityDeleter', () => {
|
|
71
|
+
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
72
|
+
const viewerContext = new ViewerContext(companionProvider);
|
|
73
|
+
const data = {
|
|
74
|
+
id: 'what',
|
|
75
|
+
};
|
|
76
|
+
const testEntity = new SimpleTestEntity({
|
|
77
|
+
viewerContext,
|
|
78
|
+
id: 'what',
|
|
79
|
+
databaseFields: data,
|
|
80
|
+
selectedFields: data,
|
|
81
|
+
});
|
|
82
|
+
expect(SimpleTestEntity.deleter(testEntity)).toBeInstanceOf(EnforcingEntityDeleter);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('deleterWithAuthorizationResults', () => {
|
|
87
|
+
it('creates a new AuthorizationResultBasedDeleteMutator', () => {
|
|
37
88
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
38
89
|
const viewerContext = new ViewerContext(companionProvider);
|
|
39
90
|
const data = {
|
|
@@ -45,7 +96,9 @@ describe(Entity, () => {
|
|
|
45
96
|
databaseFields: data,
|
|
46
97
|
selectedFields: data,
|
|
47
98
|
});
|
|
48
|
-
expect(SimpleTestEntity.
|
|
99
|
+
expect(SimpleTestEntity.deleterWithAuthorizationResults(testEntity)).toBeInstanceOf(
|
|
100
|
+
AuthorizationResultBasedDeleteMutator,
|
|
101
|
+
);
|
|
49
102
|
});
|
|
50
103
|
});
|
|
51
104
|
});
|
|
@@ -2,18 +2,16 @@ import AuthorizationResultBasedEntityAssociationLoader from '../AuthorizationRes
|
|
|
2
2
|
import EnforcingEntityAssociationLoader from '../EnforcingEntityAssociationLoader';
|
|
3
3
|
import EntityAssociationLoader from '../EntityAssociationLoader';
|
|
4
4
|
import ViewerContext from '../ViewerContext';
|
|
5
|
-
import SimpleTestEntity from '../
|
|
6
|
-
import { createUnitTestEntityCompanionProvider } from '../utils/
|
|
5
|
+
import SimpleTestEntity from '../utils/__testfixtures__/SimpleTestEntity';
|
|
6
|
+
import { createUnitTestEntityCompanionProvider } from '../utils/__testfixtures__/createUnitTestEntityCompanionProvider';
|
|
7
7
|
|
|
8
8
|
describe(EntityAssociationLoader, () => {
|
|
9
9
|
describe('enforcing', () => {
|
|
10
10
|
it('creates a new EnforcingEntityLoader', async () => {
|
|
11
11
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
12
12
|
const viewerContext = new ViewerContext(companionProvider);
|
|
13
|
-
const testEntity = await SimpleTestEntity.creator(viewerContext).
|
|
14
|
-
expect(testEntity.associationLoader()
|
|
15
|
-
EnforcingEntityAssociationLoader,
|
|
16
|
-
);
|
|
13
|
+
const testEntity = await SimpleTestEntity.creator(viewerContext).createAsync();
|
|
14
|
+
expect(testEntity.associationLoader()).toBeInstanceOf(EnforcingEntityAssociationLoader);
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
17
|
|
|
@@ -21,8 +19,8 @@ describe(EntityAssociationLoader, () => {
|
|
|
21
19
|
it('creates a new AuthorizationResultBasedEntityAssociationLoader', async () => {
|
|
22
20
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
23
21
|
const viewerContext = new ViewerContext(companionProvider);
|
|
24
|
-
const testEntity = await SimpleTestEntity.creator(viewerContext).
|
|
25
|
-
expect(testEntity.
|
|
22
|
+
const testEntity = await SimpleTestEntity.creator(viewerContext).createAsync();
|
|
23
|
+
expect(testEntity.associationLoaderWithAuthorizationResults()).toBeInstanceOf(
|
|
26
24
|
AuthorizationResultBasedEntityAssociationLoader,
|
|
27
25
|
);
|
|
28
26
|
});
|
|
@@ -13,7 +13,7 @@ import EntityNotAuthorizedError from '../errors/EntityNotAuthorizedError';
|
|
|
13
13
|
import AlwaysAllowPrivacyPolicyRule from '../rules/AlwaysAllowPrivacyPolicyRule';
|
|
14
14
|
import AlwaysDenyPrivacyPolicyRule from '../rules/AlwaysDenyPrivacyPolicyRule';
|
|
15
15
|
import PrivacyPolicyRule, { RuleEvaluationResult } from '../rules/PrivacyPolicyRule';
|
|
16
|
-
import { createUnitTestEntityCompanionProvider } from '../utils/
|
|
16
|
+
import { createUnitTestEntityCompanionProvider } from '../utils/__testfixtures__/createUnitTestEntityCompanionProvider';
|
|
17
17
|
|
|
18
18
|
class TestUserViewerContext extends ViewerContext {
|
|
19
19
|
constructor(
|
|
@@ -33,17 +33,17 @@ type BlahFields = {
|
|
|
33
33
|
ownerID: string;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
class BlahEntity extends Entity<BlahFields,
|
|
36
|
+
class BlahEntity extends Entity<BlahFields, 'id', TestUserViewerContext> {
|
|
37
37
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
38
38
|
BlahFields,
|
|
39
|
-
|
|
39
|
+
'id',
|
|
40
40
|
TestUserViewerContext,
|
|
41
41
|
BlahEntity,
|
|
42
42
|
BlahEntityPrivacyPolicy
|
|
43
43
|
> {
|
|
44
44
|
return {
|
|
45
45
|
entityClass: BlahEntity,
|
|
46
|
-
entityConfiguration: new EntityConfiguration<BlahFields>({
|
|
46
|
+
entityConfiguration: new EntityConfiguration<BlahFields, 'id'>({
|
|
47
47
|
idField: 'id',
|
|
48
48
|
tableName: 'blah_table',
|
|
49
49
|
schema: {
|
|
@@ -65,7 +65,7 @@ class BlahEntity extends Entity<BlahFields, string, TestUserViewerContext> {
|
|
|
65
65
|
|
|
66
66
|
class DenyIfNotOwnerPrivacyPolicyRule extends PrivacyPolicyRule<
|
|
67
67
|
BlahFields,
|
|
68
|
-
|
|
68
|
+
'id',
|
|
69
69
|
TestUserViewerContext,
|
|
70
70
|
BlahEntity
|
|
71
71
|
> {
|
|
@@ -74,7 +74,7 @@ class DenyIfNotOwnerPrivacyPolicyRule extends PrivacyPolicyRule<
|
|
|
74
74
|
_queryContext: EntityQueryContext,
|
|
75
75
|
_evaluationContext: EntityPrivacyPolicyEvaluationContext<
|
|
76
76
|
BlahFields,
|
|
77
|
-
|
|
77
|
+
'id',
|
|
78
78
|
TestUserViewerContext,
|
|
79
79
|
BlahEntity
|
|
80
80
|
>,
|
|
@@ -89,24 +89,24 @@ class DenyIfNotOwnerPrivacyPolicyRule extends PrivacyPolicyRule<
|
|
|
89
89
|
|
|
90
90
|
class BlahEntityPrivacyPolicy extends EntityPrivacyPolicy<
|
|
91
91
|
BlahFields,
|
|
92
|
-
|
|
92
|
+
'id',
|
|
93
93
|
ViewerContext,
|
|
94
94
|
BlahEntity
|
|
95
95
|
> {
|
|
96
96
|
protected override readonly createRules = [
|
|
97
97
|
new DenyIfNotOwnerPrivacyPolicyRule(),
|
|
98
|
-
new AlwaysAllowPrivacyPolicyRule<BlahFields,
|
|
98
|
+
new AlwaysAllowPrivacyPolicyRule<BlahFields, 'id', ViewerContext, BlahEntity>(),
|
|
99
99
|
];
|
|
100
100
|
protected override readonly readRules = [
|
|
101
101
|
new DenyIfNotOwnerPrivacyPolicyRule(),
|
|
102
|
-
new AlwaysAllowPrivacyPolicyRule<BlahFields,
|
|
102
|
+
new AlwaysAllowPrivacyPolicyRule<BlahFields, 'id', ViewerContext, BlahEntity>(),
|
|
103
103
|
];
|
|
104
104
|
protected override readonly updateRules = [
|
|
105
105
|
new DenyIfNotOwnerPrivacyPolicyRule(),
|
|
106
|
-
new AlwaysAllowPrivacyPolicyRule<BlahFields,
|
|
106
|
+
new AlwaysAllowPrivacyPolicyRule<BlahFields, 'id', ViewerContext, BlahEntity>(),
|
|
107
107
|
];
|
|
108
108
|
protected override readonly deleteRules = [
|
|
109
|
-
new AlwaysDenyPrivacyPolicyRule<BlahFields,
|
|
109
|
+
new AlwaysDenyPrivacyPolicyRule<BlahFields, 'id', ViewerContext, BlahEntity>(),
|
|
110
110
|
];
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -118,22 +118,19 @@ it('runs through a common workflow', async () => {
|
|
|
118
118
|
const vc2 = new TestUserViewerContext(entityCompanionProvider, uuidv4());
|
|
119
119
|
|
|
120
120
|
const blahOwner1 = await enforceAsyncResult(
|
|
121
|
-
BlahEntity.
|
|
122
|
-
.withAuthorizationResults()
|
|
121
|
+
BlahEntity.creatorWithAuthorizationResults(vc1)
|
|
123
122
|
.setField('ownerID', vc1.getUserID())
|
|
124
123
|
.createAsync(),
|
|
125
124
|
);
|
|
126
125
|
|
|
127
126
|
await enforceAsyncResult(
|
|
128
|
-
BlahEntity.
|
|
129
|
-
.withAuthorizationResults()
|
|
127
|
+
BlahEntity.creatorWithAuthorizationResults(vc1)
|
|
130
128
|
.setField('ownerID', vc1.getUserID())
|
|
131
129
|
.createAsync(),
|
|
132
130
|
);
|
|
133
131
|
|
|
134
132
|
const blahOwner2 = await enforceAsyncResult(
|
|
135
|
-
BlahEntity.
|
|
136
|
-
.withAuthorizationResults()
|
|
133
|
+
BlahEntity.creatorWithAuthorizationResults(vc2)
|
|
137
134
|
.setField('ownerID', vc2.getUserID())
|
|
138
135
|
.createAsync(),
|
|
139
136
|
);
|
|
@@ -145,43 +142,43 @@ it('runs through a common workflow', async () => {
|
|
|
145
142
|
// check that two people can't read each others data
|
|
146
143
|
await expect(
|
|
147
144
|
enforceAsyncResult(
|
|
148
|
-
BlahEntity.
|
|
145
|
+
BlahEntity.loaderWithAuthorizationResults(vc1).loadByIDAsync(blahOwner2.getID()),
|
|
149
146
|
),
|
|
150
147
|
).rejects.toBeInstanceOf(EntityNotAuthorizedError);
|
|
151
148
|
await expect(
|
|
152
149
|
enforceAsyncResult(
|
|
153
|
-
BlahEntity.
|
|
150
|
+
BlahEntity.loaderWithAuthorizationResults(vc2).loadByIDAsync(blahOwner1.getID()),
|
|
154
151
|
),
|
|
155
152
|
).rejects.toBeInstanceOf(EntityNotAuthorizedError);
|
|
156
153
|
|
|
157
154
|
// check that all of owner 1's objects can be loaded
|
|
158
155
|
const results = await enforceResultsAsync(
|
|
159
|
-
BlahEntity.
|
|
160
|
-
|
|
161
|
-
|
|
156
|
+
BlahEntity.loaderWithAuthorizationResults(vc1).loadManyByFieldEqualingAsync(
|
|
157
|
+
'ownerID',
|
|
158
|
+
vc1.getUserID(),
|
|
159
|
+
),
|
|
162
160
|
);
|
|
163
161
|
expect(results).toHaveLength(2);
|
|
164
162
|
|
|
165
163
|
// check that two people can't create objects owned by others
|
|
166
164
|
await expect(
|
|
167
165
|
enforceAsyncResult(
|
|
168
|
-
BlahEntity.
|
|
169
|
-
.withAuthorizationResults()
|
|
166
|
+
BlahEntity.creatorWithAuthorizationResults(vc2)
|
|
170
167
|
.setField('ownerID', blahOwner1.getID())
|
|
171
168
|
.createAsync(),
|
|
172
169
|
),
|
|
173
170
|
).rejects.toBeInstanceOf(EntityNotAuthorizedError);
|
|
174
171
|
|
|
175
172
|
// check that empty load many returns nothing
|
|
176
|
-
const results2 = await BlahEntity.
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
const results2 = await BlahEntity.loaderWithAuthorizationResults(
|
|
174
|
+
vc1,
|
|
175
|
+
).loadManyByFieldEqualingManyAsync('ownerID', []);
|
|
179
176
|
for (const value in results2.values) {
|
|
180
177
|
expect(value).toHaveLength(0);
|
|
181
178
|
}
|
|
182
179
|
|
|
183
180
|
// check that the user can't delete their own data (as specified by privacy rules)
|
|
184
181
|
await expect(
|
|
185
|
-
enforceAsyncResult(BlahEntity.
|
|
182
|
+
enforceAsyncResult(BlahEntity.deleterWithAuthorizationResults(blahOwner2).deleteAsync()),
|
|
186
183
|
).rejects.toBeInstanceOf(EntityNotAuthorizedError);
|
|
187
184
|
});
|
|
@@ -13,13 +13,13 @@ import TestEntityWithMutationTriggers, {
|
|
|
13
13
|
TestMTFields,
|
|
14
14
|
testEntityMTConfiguration,
|
|
15
15
|
TestMutationTrigger,
|
|
16
|
-
} from '../
|
|
16
|
+
} from '../utils/__testfixtures__/TestEntityWithMutationTriggers';
|
|
17
17
|
|
|
18
18
|
describe(EntityCompanion, () => {
|
|
19
19
|
it('correctly instantiates mutator and loader factories', () => {
|
|
20
20
|
const entityCompanionProvider = instance(mock<EntityCompanionProvider>());
|
|
21
21
|
|
|
22
|
-
const tableDataCoordinatorMock = mock<EntityTableDataCoordinator<TestMTFields>>();
|
|
22
|
+
const tableDataCoordinatorMock = mock<EntityTableDataCoordinator<TestMTFields, 'id'>>();
|
|
23
23
|
when(tableDataCoordinatorMock.entityConfiguration).thenReturn(testEntityMTConfiguration);
|
|
24
24
|
|
|
25
25
|
const companion = new EntityCompanion(
|
|
@@ -35,7 +35,7 @@ describe(EntityCompanion, () => {
|
|
|
35
35
|
it('correctly merges local and global mutation triggers', () => {
|
|
36
36
|
const globalMutationTriggers: EntityMutationTriggerConfiguration<
|
|
37
37
|
TestMTFields,
|
|
38
|
-
|
|
38
|
+
'id',
|
|
39
39
|
ViewerContext,
|
|
40
40
|
TestEntityWithMutationTriggers,
|
|
41
41
|
keyof TestMTFields
|
|
@@ -53,7 +53,7 @@ describe(EntityCompanion, () => {
|
|
|
53
53
|
globalMutationTriggers,
|
|
54
54
|
);
|
|
55
55
|
|
|
56
|
-
const tableDataCoordinatorMock = mock<EntityTableDataCoordinator<TestMTFields>>();
|
|
56
|
+
const tableDataCoordinatorMock = mock<EntityTableDataCoordinator<TestMTFields, 'id'>>();
|
|
57
57
|
when(tableDataCoordinatorMock.entityConfiguration).thenReturn(testEntityMTConfiguration);
|
|
58
58
|
|
|
59
59
|
const companion = new EntityCompanion(
|
|
@@ -4,28 +4,29 @@ import EntityConfiguration from '../EntityConfiguration';
|
|
|
4
4
|
import { StringField } from '../EntityFields';
|
|
5
5
|
import EntityPrivacyPolicy from '../EntityPrivacyPolicy';
|
|
6
6
|
import ViewerContext from '../ViewerContext';
|
|
7
|
-
import { createUnitTestEntityCompanionProvider } from '../utils/
|
|
7
|
+
import { createUnitTestEntityCompanionProvider } from '../utils/__testfixtures__/createUnitTestEntityCompanionProvider';
|
|
8
8
|
|
|
9
9
|
type BlahFields = {
|
|
10
10
|
hello: string;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const blahConfiguration = new EntityConfiguration<BlahFields>({
|
|
13
|
+
const blahConfiguration = new EntityConfiguration<BlahFields, 'hello'>({
|
|
14
14
|
idField: 'hello',
|
|
15
15
|
tableName: 'wat',
|
|
16
16
|
schema: {
|
|
17
17
|
hello: new StringField({
|
|
18
18
|
columnName: 'hello',
|
|
19
|
+
cache: false,
|
|
19
20
|
}),
|
|
20
21
|
},
|
|
21
22
|
databaseAdapterFlavor: 'postgres',
|
|
22
23
|
cacheAdapterFlavor: 'redis',
|
|
23
24
|
});
|
|
24
25
|
|
|
25
|
-
class Blah1Entity extends Entity<BlahFields,
|
|
26
|
+
class Blah1Entity extends Entity<BlahFields, 'hello', ViewerContext> {
|
|
26
27
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
27
28
|
BlahFields,
|
|
28
|
-
|
|
29
|
+
'hello',
|
|
29
30
|
ViewerContext,
|
|
30
31
|
Blah1Entity,
|
|
31
32
|
NoOpTest1PrivacyPolicy
|
|
@@ -38,10 +39,10 @@ class Blah1Entity extends Entity<BlahFields, string, ViewerContext> {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
class Blah2Entity extends Entity<BlahFields,
|
|
42
|
+
class Blah2Entity extends Entity<BlahFields, 'hello', ViewerContext> {
|
|
42
43
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
43
44
|
BlahFields,
|
|
44
|
-
|
|
45
|
+
'hello',
|
|
45
46
|
ViewerContext,
|
|
46
47
|
Blah2Entity,
|
|
47
48
|
NoOpTest2PrivacyPolicy
|
|
@@ -56,13 +57,13 @@ class Blah2Entity extends Entity<BlahFields, string, ViewerContext> {
|
|
|
56
57
|
|
|
57
58
|
class NoOpTest1PrivacyPolicy extends EntityPrivacyPolicy<
|
|
58
59
|
BlahFields,
|
|
59
|
-
|
|
60
|
+
'hello',
|
|
60
61
|
ViewerContext,
|
|
61
62
|
Blah1Entity
|
|
62
63
|
> {}
|
|
63
64
|
class NoOpTest2PrivacyPolicy extends EntityPrivacyPolicy<
|
|
64
65
|
BlahFields,
|
|
65
|
-
|
|
66
|
+
'hello',
|
|
66
67
|
ViewerContext,
|
|
67
68
|
Blah2Entity
|
|
68
69
|
> {}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import EntityConfiguration from '../EntityConfiguration';
|
|
2
|
-
import {
|
|
2
|
+
import { StringField, UUIDField } from '../EntityFields';
|
|
3
|
+
import { CompositeFieldHolder } from '../internal/CompositeFieldHolder';
|
|
3
4
|
|
|
4
5
|
describe(EntityConfiguration, () => {
|
|
5
6
|
describe('when valid', () => {
|
|
@@ -13,12 +14,13 @@ describe(EntityConfiguration, () => {
|
|
|
13
14
|
id: string;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
const blahEntityConfiguration = new EntityConfiguration<BlahT>({
|
|
17
|
+
const blahEntityConfiguration = new EntityConfiguration<BlahT, 'id'>({
|
|
17
18
|
idField: 'id',
|
|
18
19
|
tableName: 'blah_table',
|
|
19
20
|
schema: {
|
|
20
21
|
id: new UUIDField({
|
|
21
22
|
columnName: 'id',
|
|
23
|
+
cache: false,
|
|
22
24
|
}),
|
|
23
25
|
cacheable: new StringField({
|
|
24
26
|
columnName: 'cacheable',
|
|
@@ -30,6 +32,10 @@ describe(EntityConfiguration, () => {
|
|
|
30
32
|
},
|
|
31
33
|
databaseAdapterFlavor: 'postgres',
|
|
32
34
|
cacheAdapterFlavor: 'redis',
|
|
35
|
+
compositeFieldDefinitions: [
|
|
36
|
+
{ compositeField: ['id', 'cacheable'], cache: true },
|
|
37
|
+
{ compositeField: ['id', 'uniqueButNotCacheable'], cache: false },
|
|
38
|
+
],
|
|
33
39
|
});
|
|
34
40
|
|
|
35
41
|
it('returns correct fields', () => {
|
|
@@ -37,20 +43,91 @@ describe(EntityConfiguration, () => {
|
|
|
37
43
|
expect(blahEntityConfiguration.tableName).toEqual('blah_table');
|
|
38
44
|
expect(blahEntityConfiguration.databaseAdapterFlavor).toEqual('postgres');
|
|
39
45
|
expect(blahEntityConfiguration.cacheAdapterFlavor).toEqual('redis');
|
|
46
|
+
expect(blahEntityConfiguration.compositeFieldInfo.getAllCompositeFieldHolders()).toEqual([
|
|
47
|
+
new CompositeFieldHolder(['id', 'cacheable']),
|
|
48
|
+
new CompositeFieldHolder(['id', 'uniqueButNotCacheable']),
|
|
49
|
+
]);
|
|
40
50
|
});
|
|
41
51
|
|
|
42
52
|
it('filters cacheable fields', () => {
|
|
43
53
|
expect(blahEntityConfiguration.cacheableKeys).toEqual(new Set(['cacheable']));
|
|
44
54
|
});
|
|
45
55
|
|
|
56
|
+
it('correctly returns cacheable composite fields', () => {
|
|
57
|
+
expect(
|
|
58
|
+
blahEntityConfiguration.compositeFieldInfo.canCacheCompositeField(['id', 'cacheable']),
|
|
59
|
+
).toBe(true);
|
|
60
|
+
expect(
|
|
61
|
+
blahEntityConfiguration.compositeFieldInfo.canCacheCompositeField([
|
|
62
|
+
'id',
|
|
63
|
+
'uniqueButNotCacheable',
|
|
64
|
+
]),
|
|
65
|
+
).toBe(false);
|
|
66
|
+
|
|
67
|
+
expect(() =>
|
|
68
|
+
blahEntityConfiguration.compositeFieldInfo.canCacheCompositeField(['id']),
|
|
69
|
+
).toThrow('Composite field (id) not found in entity configuration');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('validates composite fields', () => {
|
|
73
|
+
expect(
|
|
74
|
+
() =>
|
|
75
|
+
new EntityConfiguration<BlahT, 'id'>({
|
|
76
|
+
idField: 'id',
|
|
77
|
+
tableName: 'blah_table',
|
|
78
|
+
schema: {
|
|
79
|
+
id: new UUIDField({
|
|
80
|
+
columnName: 'id',
|
|
81
|
+
cache: false,
|
|
82
|
+
}),
|
|
83
|
+
cacheable: new StringField({
|
|
84
|
+
columnName: 'cacheable',
|
|
85
|
+
cache: true,
|
|
86
|
+
}),
|
|
87
|
+
uniqueButNotCacheable: new StringField({
|
|
88
|
+
columnName: 'unique_but_not_cacheable',
|
|
89
|
+
}),
|
|
90
|
+
},
|
|
91
|
+
databaseAdapterFlavor: 'postgres',
|
|
92
|
+
cacheAdapterFlavor: 'redis',
|
|
93
|
+
compositeFieldDefinitions: [{ compositeField: ['id', 'id'], cache: true }],
|
|
94
|
+
}),
|
|
95
|
+
).toThrow('Composite field must have unique sub-fields');
|
|
96
|
+
|
|
97
|
+
expect(
|
|
98
|
+
() =>
|
|
99
|
+
new EntityConfiguration<BlahT, 'id'>({
|
|
100
|
+
idField: 'id',
|
|
101
|
+
tableName: 'blah_table',
|
|
102
|
+
schema: {
|
|
103
|
+
id: new UUIDField({
|
|
104
|
+
columnName: 'id',
|
|
105
|
+
cache: false,
|
|
106
|
+
}),
|
|
107
|
+
cacheable: new StringField({
|
|
108
|
+
columnName: 'cacheable',
|
|
109
|
+
cache: true,
|
|
110
|
+
}),
|
|
111
|
+
uniqueButNotCacheable: new StringField({
|
|
112
|
+
columnName: 'unique_but_not_cacheable',
|
|
113
|
+
}),
|
|
114
|
+
},
|
|
115
|
+
databaseAdapterFlavor: 'postgres',
|
|
116
|
+
cacheAdapterFlavor: 'redis',
|
|
117
|
+
compositeFieldDefinitions: [{ compositeField: ['id'], cache: true }],
|
|
118
|
+
}),
|
|
119
|
+
).toThrow('Composite field must have at least two sub-fields');
|
|
120
|
+
});
|
|
121
|
+
|
|
46
122
|
describe('cache key version', () => {
|
|
47
123
|
it('defaults to 0', () => {
|
|
48
|
-
const entityConfiguration = new EntityConfiguration<Blah2T>({
|
|
124
|
+
const entityConfiguration = new EntityConfiguration<Blah2T, 'id'>({
|
|
49
125
|
idField: 'id',
|
|
50
126
|
tableName: 'blah',
|
|
51
127
|
schema: {
|
|
52
128
|
id: new UUIDField({
|
|
53
129
|
columnName: 'id',
|
|
130
|
+
cache: false,
|
|
54
131
|
}),
|
|
55
132
|
},
|
|
56
133
|
databaseAdapterFlavor: 'postgres',
|
|
@@ -60,12 +137,13 @@ describe(EntityConfiguration, () => {
|
|
|
60
137
|
});
|
|
61
138
|
|
|
62
139
|
it('sets to custom version', () => {
|
|
63
|
-
const entityConfiguration = new EntityConfiguration<Blah2T>({
|
|
140
|
+
const entityConfiguration = new EntityConfiguration<Blah2T, 'id'>({
|
|
64
141
|
idField: 'id',
|
|
65
142
|
tableName: 'blah',
|
|
66
143
|
schema: {
|
|
67
144
|
id: new UUIDField({
|
|
68
145
|
columnName: 'id',
|
|
146
|
+
cache: false,
|
|
69
147
|
}),
|
|
70
148
|
},
|
|
71
149
|
databaseAdapterFlavor: 'postgres',
|
|
@@ -95,17 +173,18 @@ describe(EntityConfiguration, () => {
|
|
|
95
173
|
])('disallows %p as field key', (keyName) => {
|
|
96
174
|
expect(
|
|
97
175
|
() =>
|
|
98
|
-
new EntityConfiguration<any>({
|
|
176
|
+
new EntityConfiguration<any, 'id'>({
|
|
99
177
|
idField: 'id',
|
|
100
178
|
tableName: 'blah_table',
|
|
101
179
|
schema: {
|
|
102
180
|
id: new UUIDField({
|
|
103
181
|
columnName: 'id',
|
|
182
|
+
cache: false,
|
|
104
183
|
}),
|
|
105
184
|
[keyName]: new StringField({
|
|
106
185
|
columnName: 'any',
|
|
107
186
|
}),
|
|
108
|
-
},
|
|
187
|
+
} as any,
|
|
109
188
|
databaseAdapterFlavor: 'postgres',
|
|
110
189
|
cacheAdapterFlavor: 'redis',
|
|
111
190
|
}),
|