@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,12 +1,15 @@
|
|
|
1
1
|
import { instance, mock } from 'ts-mockito';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import AuthorizationResultBasedEntityAssociationLoader from '../AuthorizationResultBasedEntityAssociationLoader';
|
|
4
|
+
import AuthorizationResultBasedEntityLoader from '../AuthorizationResultBasedEntityLoader';
|
|
5
|
+
import EnforcingEntityAssociationLoader from '../EnforcingEntityAssociationLoader';
|
|
6
|
+
import EnforcingEntityLoader from '../EnforcingEntityLoader';
|
|
7
|
+
import EntityLoaderUtils from '../EntityLoaderUtils';
|
|
5
8
|
import ReadonlyEntity from '../ReadonlyEntity';
|
|
6
9
|
import ViewerContext from '../ViewerContext';
|
|
7
|
-
import SimpleTestEntity from '../
|
|
8
|
-
import TestEntity from '../
|
|
9
|
-
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';
|
|
10
13
|
|
|
11
14
|
describe(ReadonlyEntity, () => {
|
|
12
15
|
describe('getID', () => {
|
|
@@ -157,7 +160,7 @@ describe(ReadonlyEntity, () => {
|
|
|
157
160
|
});
|
|
158
161
|
|
|
159
162
|
describe('associationLoader', () => {
|
|
160
|
-
it('returns a new
|
|
163
|
+
it('returns a new EnforcingEntityAssociationLoader', () => {
|
|
161
164
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
162
165
|
const viewerContext = new ViewerContext(companionProvider);
|
|
163
166
|
const data = {
|
|
@@ -169,15 +172,52 @@ describe(ReadonlyEntity, () => {
|
|
|
169
172
|
databaseFields: data,
|
|
170
173
|
selectedFields: data,
|
|
171
174
|
});
|
|
172
|
-
expect(testEntity.associationLoader()).toBeInstanceOf(
|
|
175
|
+
expect(testEntity.associationLoader()).toBeInstanceOf(EnforcingEntityAssociationLoader);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
describe('associationLoaderWithAuthorizationResults', () => {
|
|
180
|
+
it('returns a new AuthorizationResultBasedEntityAssociationLoader', () => {
|
|
181
|
+
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
182
|
+
const viewerContext = new ViewerContext(companionProvider);
|
|
183
|
+
const data = {
|
|
184
|
+
id: 'what',
|
|
185
|
+
};
|
|
186
|
+
const testEntity = new SimpleTestEntity({
|
|
187
|
+
viewerContext,
|
|
188
|
+
id: 'what',
|
|
189
|
+
databaseFields: data,
|
|
190
|
+
selectedFields: data,
|
|
191
|
+
});
|
|
192
|
+
expect(testEntity.associationLoaderWithAuthorizationResults()).toBeInstanceOf(
|
|
193
|
+
AuthorizationResultBasedEntityAssociationLoader,
|
|
194
|
+
);
|
|
173
195
|
});
|
|
174
196
|
});
|
|
175
197
|
|
|
176
198
|
describe('loader', () => {
|
|
177
|
-
it('creates a new
|
|
199
|
+
it('creates a new EnforcingEntityLoader', async () => {
|
|
200
|
+
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
201
|
+
const viewerContext = new ViewerContext(companionProvider);
|
|
202
|
+
expect(SimpleTestEntity.loader(viewerContext)).toBeInstanceOf(EnforcingEntityLoader);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe('loaderWithAuthorizationResults', () => {
|
|
207
|
+
it('creates a new AuthorizationResultBasedEntityLoader', async () => {
|
|
208
|
+
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
209
|
+
const viewerContext = new ViewerContext(companionProvider);
|
|
210
|
+
expect(SimpleTestEntity.loaderWithAuthorizationResults(viewerContext)).toBeInstanceOf(
|
|
211
|
+
AuthorizationResultBasedEntityLoader,
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe('loaderUtils', () => {
|
|
217
|
+
it('creates a new EntityLoaderUtils', async () => {
|
|
178
218
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
179
219
|
const viewerContext = new ViewerContext(companionProvider);
|
|
180
|
-
expect(SimpleTestEntity.
|
|
220
|
+
expect(SimpleTestEntity.loaderUtils(viewerContext)).toBeInstanceOf(EntityLoaderUtils);
|
|
181
221
|
});
|
|
182
222
|
});
|
|
183
223
|
});
|
|
@@ -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 () => {
|
|
@@ -14,13 +14,11 @@ describe('Two entities backed by the same table', () => {
|
|
|
14
14
|
const viewerContext = new ViewerContext(companionProvider);
|
|
15
15
|
|
|
16
16
|
const one = await OneTestEntity.creator(viewerContext)
|
|
17
|
-
.enforcing()
|
|
18
17
|
.setField('entity_type', EntityType.ONE)
|
|
19
18
|
.setField('common_other_field', 'wat')
|
|
20
19
|
.createAsync();
|
|
21
20
|
|
|
22
21
|
const two = await TwoTestEntity.creator(viewerContext)
|
|
23
|
-
.enforcing()
|
|
24
22
|
.setField('entity_type', EntityType.TWO)
|
|
25
23
|
.setField('other_field', 'blah')
|
|
26
24
|
.setField('common_other_field', 'wat')
|
|
@@ -30,16 +28,16 @@ describe('Two entities backed by the same table', () => {
|
|
|
30
28
|
expect(two).toBeInstanceOf(TwoTestEntity);
|
|
31
29
|
|
|
32
30
|
await expect(
|
|
33
|
-
TwoTestEntity.loader(viewerContext).
|
|
31
|
+
TwoTestEntity.loader(viewerContext).loadByIDAsync(one.getID()),
|
|
34
32
|
).rejects.toThrowError('TwoTestEntity must be instantiated with two data');
|
|
35
33
|
|
|
36
34
|
await expect(
|
|
37
|
-
OneTestEntity.loader(viewerContext).
|
|
35
|
+
OneTestEntity.loader(viewerContext).loadByIDAsync(two.getID()),
|
|
38
36
|
).rejects.toThrowError('OneTestEntity must be instantiated with one data');
|
|
39
37
|
|
|
40
|
-
const manyResults = await OneTestEntity.
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
const manyResults = await OneTestEntity.loaderWithAuthorizationResults(
|
|
39
|
+
viewerContext,
|
|
40
|
+
).loadManyByFieldEqualingAsync('common_other_field', 'wat');
|
|
43
41
|
const successfulManyResults = successfulResults(manyResults);
|
|
44
42
|
const failedManyResults = failedResults(manyResults);
|
|
45
43
|
|
|
@@ -51,14 +49,14 @@ describe('Two entities backed by the same table', () => {
|
|
|
51
49
|
'OneTestEntity must be instantiated with one data',
|
|
52
50
|
);
|
|
53
51
|
|
|
54
|
-
const fieldEqualityConjunctionResults = await OneTestEntity.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
const fieldEqualityConjunctionResults = await OneTestEntity.loaderWithAuthorizationResults(
|
|
53
|
+
viewerContext,
|
|
54
|
+
).loadManyByFieldEqualityConjunctionAsync([
|
|
55
|
+
{
|
|
56
|
+
fieldName: 'common_other_field',
|
|
57
|
+
fieldValue: 'wat',
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
62
60
|
const successfulfieldEqualityConjunctionResultsResults = successfulResults(
|
|
63
61
|
fieldEqualityConjunctionResults,
|
|
64
62
|
);
|
|
@@ -85,7 +83,7 @@ interface TestFields {
|
|
|
85
83
|
type OneTestFields = 'id' | 'entity_type' | 'common_other_field';
|
|
86
84
|
type TwoTestFields = 'id' | 'other_field' | 'entity_type' | 'common_other_field';
|
|
87
85
|
|
|
88
|
-
const testEntityConfiguration = new EntityConfiguration<TestFields>({
|
|
86
|
+
const testEntityConfiguration = new EntityConfiguration<TestFields, 'id'>({
|
|
89
87
|
idField: 'id',
|
|
90
88
|
tableName: 'entities',
|
|
91
89
|
schema: {
|
|
@@ -108,22 +106,22 @@ const testEntityConfiguration = new EntityConfiguration<TestFields>({
|
|
|
108
106
|
cacheAdapterFlavor: 'redis',
|
|
109
107
|
});
|
|
110
108
|
|
|
111
|
-
class TestEntityPrivacyPolicy extends EntityPrivacyPolicy<any,
|
|
109
|
+
class TestEntityPrivacyPolicy extends EntityPrivacyPolicy<any, 'id', ViewerContext, any, any> {
|
|
112
110
|
protected override readonly readRules = [
|
|
113
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
111
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
114
112
|
];
|
|
115
113
|
protected override readonly createRules = [
|
|
116
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
114
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
117
115
|
];
|
|
118
116
|
protected override readonly updateRules = [
|
|
119
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
117
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
120
118
|
];
|
|
121
119
|
protected override readonly deleteRules = [
|
|
122
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
120
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
123
121
|
];
|
|
124
122
|
}
|
|
125
123
|
|
|
126
|
-
class OneTestEntity extends Entity<TestFields,
|
|
124
|
+
class OneTestEntity extends Entity<TestFields, 'id', ViewerContext, OneTestFields> {
|
|
127
125
|
constructor(constructorParams: {
|
|
128
126
|
viewerContext: ViewerContext;
|
|
129
127
|
id: string;
|
|
@@ -138,7 +136,7 @@ class OneTestEntity extends Entity<TestFields, string, ViewerContext, OneTestFie
|
|
|
138
136
|
|
|
139
137
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
140
138
|
TestFields,
|
|
141
|
-
|
|
139
|
+
'id',
|
|
142
140
|
ViewerContext,
|
|
143
141
|
OneTestEntity,
|
|
144
142
|
TestEntityPrivacyPolicy,
|
|
@@ -153,7 +151,7 @@ class OneTestEntity extends Entity<TestFields, string, ViewerContext, OneTestFie
|
|
|
153
151
|
}
|
|
154
152
|
}
|
|
155
153
|
|
|
156
|
-
class TwoTestEntity extends Entity<TestFields,
|
|
154
|
+
class TwoTestEntity extends Entity<TestFields, 'id', ViewerContext, TwoTestFields> {
|
|
157
155
|
constructor(constructorParams: {
|
|
158
156
|
viewerContext: ViewerContext;
|
|
159
157
|
id: string;
|
|
@@ -168,7 +166,7 @@ class TwoTestEntity extends Entity<TestFields, string, ViewerContext, TwoTestFie
|
|
|
168
166
|
|
|
169
167
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
170
168
|
TestFields,
|
|
171
|
-
|
|
169
|
+
'id',
|
|
172
170
|
ViewerContext,
|
|
173
171
|
TwoTestEntity,
|
|
174
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 () => {
|
|
@@ -13,18 +13,14 @@ describe('Two entities backed by the same table', () => {
|
|
|
13
13
|
const viewerContext = new ViewerContext(companionProvider);
|
|
14
14
|
|
|
15
15
|
const entity1 = await OneTestEntity.creator(viewerContext)
|
|
16
|
-
.enforcing()
|
|
17
16
|
.setField('fake_field', 'hello')
|
|
18
17
|
.createAsync();
|
|
19
18
|
expect(entity1).toBeInstanceOf(OneTestEntity);
|
|
20
19
|
|
|
21
|
-
const entity2 = await TwoTestEntity.loader(viewerContext)
|
|
22
|
-
.enforcing()
|
|
23
|
-
.loadByIDAsync(entity1.getID());
|
|
20
|
+
const entity2 = await TwoTestEntity.loader(viewerContext).loadByIDAsync(entity1.getID());
|
|
24
21
|
expect(entity2).toBeInstanceOf(TwoTestEntity);
|
|
25
22
|
|
|
26
23
|
const updated2 = await TwoTestEntity.updater(entity2)
|
|
27
|
-
.enforcing()
|
|
28
24
|
.setField('fake_field', 'world')
|
|
29
25
|
.setField('other_field', 'wat')
|
|
30
26
|
.updateAsync();
|
|
@@ -34,9 +30,7 @@ describe('Two entities backed by the same table', () => {
|
|
|
34
30
|
fake_field: 'world',
|
|
35
31
|
});
|
|
36
32
|
|
|
37
|
-
const loaded1 = await OneTestEntity.loader(viewerContext)
|
|
38
|
-
.enforcing()
|
|
39
|
-
.loadByIDAsync(entity1.getID());
|
|
33
|
+
const loaded1 = await OneTestEntity.loader(viewerContext).loadByIDAsync(entity1.getID());
|
|
40
34
|
expect(loaded1.getAllFields()).toMatchObject({
|
|
41
35
|
id: updated2.getID(),
|
|
42
36
|
fake_field: 'world',
|
|
@@ -48,37 +42,37 @@ describe('Two entities backed by the same table', () => {
|
|
|
48
42
|
const viewerContext = new ViewerContext(companionProvider);
|
|
49
43
|
|
|
50
44
|
const entity = await TwoTestEntity.creator(viewerContext)
|
|
51
|
-
.enforcing()
|
|
52
45
|
.setField('fake_field', 'hello')
|
|
53
46
|
.setField('other_field', 'huh')
|
|
54
47
|
.createAsync();
|
|
55
48
|
|
|
56
|
-
const loadedEntity = await TwoTestEntity.loader(viewerContext)
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
const loadedEntity = await TwoTestEntity.loader(viewerContext).loadByFieldEqualingAsync(
|
|
50
|
+
'other_field',
|
|
51
|
+
'huh',
|
|
52
|
+
);
|
|
59
53
|
expect(loadedEntity?.getAllFields()).toMatchObject({
|
|
60
54
|
id: entity.getID(),
|
|
61
55
|
fake_field: 'hello',
|
|
62
56
|
other_field: 'huh',
|
|
63
57
|
});
|
|
64
58
|
|
|
65
|
-
const loaded1 = await OneTestEntity.loader(viewerContext)
|
|
66
|
-
|
|
67
|
-
.loadByIDAsync(entity.getID());
|
|
68
|
-
await OneTestEntity.updater(loaded1).enforcing().setField('fake_field', 'world').updateAsync();
|
|
59
|
+
const loaded1 = await OneTestEntity.loader(viewerContext).loadByIDAsync(entity.getID());
|
|
60
|
+
await OneTestEntity.updater(loaded1).setField('fake_field', 'world').updateAsync();
|
|
69
61
|
|
|
70
|
-
const loaded2 = await TwoTestEntity.loader(viewerContext)
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
const loaded2 = await TwoTestEntity.loader(viewerContext).loadByFieldEqualingAsync(
|
|
63
|
+
'other_field',
|
|
64
|
+
'huh',
|
|
65
|
+
);
|
|
73
66
|
expect(loaded2?.getAllFields()).toMatchObject({
|
|
74
67
|
id: entity.getID(),
|
|
75
68
|
fake_field: 'world',
|
|
76
69
|
other_field: 'huh',
|
|
77
70
|
});
|
|
78
71
|
|
|
79
|
-
const loaded22 = await TwoTestEntity.loader(viewerContext)
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
const loaded22 = await TwoTestEntity.loader(viewerContext).loadByFieldEqualingAsync(
|
|
73
|
+
'fake_field',
|
|
74
|
+
'world',
|
|
75
|
+
);
|
|
82
76
|
expect(loaded22?.getAllFields()).toMatchObject({
|
|
83
77
|
id: entity.getID(),
|
|
84
78
|
fake_field: 'world',
|
|
@@ -96,7 +90,7 @@ interface TestFields {
|
|
|
96
90
|
type OneTestFields = 'id' | 'fake_field';
|
|
97
91
|
type TwoTestFields = 'id' | 'other_field' | 'fake_field';
|
|
98
92
|
|
|
99
|
-
const testEntityConfiguration = new EntityConfiguration<TestFields>({
|
|
93
|
+
const testEntityConfiguration = new EntityConfiguration<TestFields, 'id'>({
|
|
100
94
|
idField: 'id',
|
|
101
95
|
tableName: 'entities',
|
|
102
96
|
schema: {
|
|
@@ -117,25 +111,25 @@ const testEntityConfiguration = new EntityConfiguration<TestFields>({
|
|
|
117
111
|
cacheAdapterFlavor: 'redis',
|
|
118
112
|
});
|
|
119
113
|
|
|
120
|
-
class TestEntityPrivacyPolicy extends EntityPrivacyPolicy<any,
|
|
114
|
+
class TestEntityPrivacyPolicy extends EntityPrivacyPolicy<any, 'id', ViewerContext, any, any> {
|
|
121
115
|
protected override readonly readRules = [
|
|
122
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
116
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
123
117
|
];
|
|
124
118
|
protected override readonly createRules = [
|
|
125
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
119
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
126
120
|
];
|
|
127
121
|
protected override readonly updateRules = [
|
|
128
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
122
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
129
123
|
];
|
|
130
124
|
protected override readonly deleteRules = [
|
|
131
|
-
new AlwaysAllowPrivacyPolicyRule<any,
|
|
125
|
+
new AlwaysAllowPrivacyPolicyRule<any, 'id', ViewerContext, any, any>(),
|
|
132
126
|
];
|
|
133
127
|
}
|
|
134
128
|
|
|
135
|
-
class OneTestEntity extends Entity<TestFields,
|
|
129
|
+
class OneTestEntity extends Entity<TestFields, 'id', ViewerContext, OneTestFields> {
|
|
136
130
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
137
131
|
TestFields,
|
|
138
|
-
|
|
132
|
+
'id',
|
|
139
133
|
ViewerContext,
|
|
140
134
|
OneTestEntity,
|
|
141
135
|
TestEntityPrivacyPolicy,
|
|
@@ -150,10 +144,10 @@ class OneTestEntity extends Entity<TestFields, string, ViewerContext, OneTestFie
|
|
|
150
144
|
}
|
|
151
145
|
}
|
|
152
146
|
|
|
153
|
-
class TwoTestEntity extends Entity<TestFields,
|
|
147
|
+
class TwoTestEntity extends Entity<TestFields, 'id', ViewerContext, TwoTestFields> {
|
|
154
148
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
155
149
|
TestFields,
|
|
156
|
-
|
|
150
|
+
'id',
|
|
157
151
|
ViewerContext,
|
|
158
152
|
TwoTestEntity,
|
|
159
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';
|