@expo/entity 0.41.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/AuthorizationResultBasedEntityAssociationLoader.d.ts +16 -16
- package/build/AuthorizationResultBasedEntityAssociationLoader.js.map +1 -1
- package/build/AuthorizationResultBasedEntityLoader.d.ts +39 -67
- package/build/AuthorizationResultBasedEntityLoader.js +85 -62
- package/build/AuthorizationResultBasedEntityLoader.js.map +1 -1
- package/build/AuthorizationResultBasedEntityMutator.d.ts +16 -16
- package/build/AuthorizationResultBasedEntityMutator.js.map +1 -1
- package/build/ComposedEntityCacheAdapter.d.ts +7 -6
- package/build/ComposedEntityCacheAdapter.js +28 -28
- package/build/ComposedEntityCacheAdapter.js.map +1 -1
- package/build/ComposedSecondaryEntityCache.d.ts +1 -1
- package/build/ComposedSecondaryEntityCache.js.map +1 -1
- package/build/EnforcingEntityAssociationLoader.d.ts +15 -15
- package/build/EnforcingEntityAssociationLoader.js.map +1 -1
- package/build/EnforcingEntityCreator.d.ts +2 -2
- package/build/EnforcingEntityDeleter.d.ts +2 -2
- package/build/EnforcingEntityLoader.d.ts +104 -18
- package/build/EnforcingEntityLoader.js +113 -12
- package/build/EnforcingEntityLoader.js.map +1 -1
- package/build/EnforcingEntityUpdater.d.ts +2 -2
- package/build/Entity.d.ts +10 -10
- package/build/Entity.js.map +1 -1
- package/build/EntityAssociationLoader.d.ts +3 -3
- package/build/EntityCompanion.d.ts +5 -5
- package/build/EntityCompanion.js.map +1 -1
- package/build/EntityCompanionProvider.d.ts +6 -6
- package/build/EntityCompanionProvider.js.map +1 -1
- package/build/EntityConfiguration.d.ts +46 -5
- package/build/EntityConfiguration.js +39 -1
- package/build/EntityConfiguration.js.map +1 -1
- package/build/EntityCreator.d.ts +4 -4
- package/build/EntityDatabaseAdapter.d.ts +15 -14
- package/build/EntityDatabaseAdapter.js +20 -12
- package/build/EntityDatabaseAdapter.js.map +1 -1
- package/build/EntityDeleter.d.ts +4 -4
- package/build/EntityFieldDefinition.d.ts +20 -10
- package/build/EntityFieldDefinition.js +3 -1
- package/build/EntityFieldDefinition.js.map +1 -1
- package/build/EntityFields.d.ts +14 -12
- package/build/EntityFields.js.map +1 -1
- package/build/EntityLoader.d.ts +5 -5
- package/build/EntityLoaderFactory.d.ts +3 -3
- package/build/EntityLoaderFactory.js.map +1 -1
- package/build/EntityLoaderUtils.d.ts +2 -2
- package/build/EntityLoaderUtils.js +27 -1
- package/build/EntityLoaderUtils.js.map +1 -1
- package/build/EntityMutationInfo.d.ts +2 -2
- package/build/EntityMutationTriggerConfiguration.d.ts +14 -14
- package/build/EntityMutationTriggerConfiguration.js.map +1 -1
- package/build/EntityMutationValidator.d.ts +2 -2
- package/build/EntityMutatorFactory.d.ts +5 -5
- package/build/EntityMutatorFactory.js.map +1 -1
- package/build/EntityPrivacyPolicy.d.ts +14 -14
- package/build/EntityPrivacyPolicy.js.map +1 -1
- package/build/EntitySecondaryCacheLoader.d.ts +4 -4
- package/build/EntityUpdater.d.ts +4 -4
- package/build/GenericEntityCacheAdapter.d.ts +7 -6
- package/build/GenericEntityCacheAdapter.js +13 -14
- package/build/GenericEntityCacheAdapter.js.map +1 -1
- package/build/GenericSecondaryEntityCache.d.ts +3 -3
- package/build/GenericSecondaryEntityCache.js.map +1 -1
- package/build/IEntityCacheAdapter.d.ts +17 -16
- package/build/IEntityCacheAdapterProvider.d.ts +1 -1
- package/build/IEntityDatabaseAdapterProvider.d.ts +1 -1
- package/build/IEntityGenericCacher.d.ts +15 -5
- package/build/ReadonlyEntity.d.ts +8 -8
- package/build/ReadonlyEntity.js.map +1 -1
- package/build/ViewerContext.d.ts +1 -1
- package/build/ViewerScopedEntityCompanion.d.ts +5 -5
- package/build/ViewerScopedEntityCompanionProvider.d.ts +1 -1
- package/build/ViewerScopedEntityLoaderFactory.d.ts +3 -3
- package/build/ViewerScopedEntityMutatorFactory.d.ts +5 -5
- package/build/entityUtils.d.ts +1 -1
- package/build/entityUtils.js.map +1 -1
- package/build/errors/EntityInvalidFieldValueError.d.ts +2 -2
- package/build/errors/EntityNotAuthorizedError.d.ts +1 -1
- package/build/errors/EntityNotFoundError.d.ts +2 -2
- package/build/index.d.ts +7 -7
- package/build/index.js +8 -13
- package/build/index.js.map +1 -1
- package/build/internal/CompositeFieldHolder.d.ts +48 -0
- package/build/internal/CompositeFieldHolder.js +116 -0
- package/build/internal/CompositeFieldHolder.js.map +1 -0
- package/build/internal/CompositeFieldValueMap.d.ts +15 -0
- package/build/internal/CompositeFieldValueMap.js +51 -0
- package/build/internal/CompositeFieldValueMap.js.map +1 -0
- package/build/internal/EntityDataManager.d.ts +16 -16
- package/build/internal/EntityDataManager.js +42 -45
- package/build/internal/EntityDataManager.js.map +1 -1
- package/build/internal/EntityFieldTransformationUtils.d.ts +5 -5
- package/build/internal/EntityFieldTransformationUtils.js.map +1 -1
- package/build/internal/EntityLoadInterfaces.d.ts +104 -0
- package/build/internal/EntityLoadInterfaces.js +25 -0
- package/build/internal/EntityLoadInterfaces.js.map +1 -0
- package/build/internal/EntityTableDataCoordinator.d.ts +6 -6
- package/build/internal/EntityTableDataCoordinator.js.map +1 -1
- package/build/internal/ReadThroughEntityCache.d.ts +17 -16
- package/build/internal/ReadThroughEntityCache.js +36 -36
- package/build/internal/ReadThroughEntityCache.js.map +1 -1
- package/build/internal/SingleFieldHolder.d.ts +34 -0
- package/build/internal/SingleFieldHolder.js +90 -0
- package/build/internal/SingleFieldHolder.js.map +1 -0
- package/build/metrics/EntityMetricsUtils.d.ts +2 -1
- package/build/metrics/EntityMetricsUtils.js.map +1 -1
- package/build/metrics/IEntityMetricsAdapter.d.ts +5 -0
- package/build/metrics/IEntityMetricsAdapter.js.map +1 -1
- package/build/rules/AlwaysAllowPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysAllowPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysDenyPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysDenyPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysSkipPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysSkipPrivacyPolicyRule.js.map +1 -1
- package/build/rules/PrivacyPolicyRule.d.ts +2 -2
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/build/utils/EntityPrivacyUtils.d.ts +4 -4
- package/build/utils/EntityPrivacyUtils.js.map +1 -1
- package/build/utils/collections/SerializableKeyMap.d.ts +27 -0
- package/build/utils/collections/SerializableKeyMap.js +60 -0
- package/build/utils/collections/SerializableKeyMap.js.map +1 -0
- package/build/utils/collections/maps.js +1 -2
- package/build/utils/collections/maps.js.map +1 -1
- package/build/utils/collections/sets.d.ts +1 -0
- package/build/utils/collections/sets.js +7 -0
- package/build/utils/collections/sets.js.map +1 -0
- package/build/utils/mergeEntityMutationTriggerConfigurations.d.ts +1 -1
- package/package.json +8 -5
- package/src/AuthorizationResultBasedEntityAssociationLoader.ts +56 -49
- package/src/AuthorizationResultBasedEntityLoader.ts +194 -81
- package/src/AuthorizationResultBasedEntityMutator.ts +71 -45
- package/src/ComposedEntityCacheAdapter.ts +55 -46
- package/src/ComposedSecondaryEntityCache.ts +5 -2
- package/src/EnforcingEntityAssociationLoader.ts +52 -44
- package/src/EnforcingEntityCreator.ts +5 -5
- package/src/EnforcingEntityDeleter.ts +5 -5
- package/src/EnforcingEntityLoader.ts +158 -21
- package/src/EnforcingEntityUpdater.ts +5 -5
- package/src/Entity.ts +39 -39
- package/src/EntityAssociationLoader.ts +6 -6
- package/src/EntityCompanion.ts +11 -11
- package/src/EntityCompanionProvider.ts +21 -18
- package/src/EntityConfiguration.ts +123 -9
- package/src/EntityCreator.ts +7 -7
- package/src/EntityDatabaseAdapter.ts +51 -28
- package/src/EntityDeleter.ts +7 -7
- package/src/EntityFieldDefinition.ts +32 -12
- package/src/EntityFields.ts +49 -12
- package/src/EntityLoader.ts +8 -8
- package/src/EntityLoaderFactory.ts +8 -8
- package/src/EntityLoaderUtils.ts +39 -10
- package/src/EntityMutationInfo.ts +6 -6
- package/src/EntityMutationTriggerConfiguration.ts +68 -20
- package/src/EntityMutationValidator.ts +4 -4
- package/src/EntityMutatorFactory.ts +13 -13
- package/src/EntityPrivacyPolicy.ts +50 -26
- package/src/EntitySecondaryCacheLoader.ts +6 -6
- package/src/EntityUpdater.ts +7 -7
- package/src/GenericEntityCacheAdapter.ts +39 -28
- package/src/GenericSecondaryEntityCache.ts +6 -3
- package/src/IEntityCacheAdapter.ts +45 -25
- package/src/IEntityCacheAdapterProvider.ts +3 -3
- package/src/IEntityDatabaseAdapterProvider.ts +3 -3
- package/src/IEntityGenericCacher.ts +33 -5
- package/src/ReadonlyEntity.ts +24 -24
- package/src/ViewerContext.ts +5 -5
- package/src/ViewerScopedEntityCompanion.ts +7 -7
- package/src/ViewerScopedEntityCompanionProvider.ts +6 -6
- package/src/ViewerScopedEntityLoaderFactory.ts +7 -7
- package/src/ViewerScopedEntityMutatorFactory.ts +8 -8
- package/src/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.ts +4 -4
- package/src/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.ts +14 -13
- package/src/__tests__/AuthorizationResultBasedEntityLoader-test.ts +367 -69
- package/src/__tests__/ComposedCacheAdapter-test.ts +235 -117
- package/src/__tests__/EnforcingEntityLoader-test.ts +135 -1
- package/src/__tests__/Entity-test.ts +2 -2
- package/src/__tests__/EntityAssociationLoader-test.ts +2 -2
- package/src/__tests__/EntityCommonUseCases-test.ts +11 -11
- package/src/__tests__/EntityCompanion-test.ts +4 -4
- package/src/__tests__/EntityCompanionProvider-test.ts +9 -8
- package/src/__tests__/EntityConfiguration-test.ts +85 -6
- package/src/__tests__/EntityDatabaseAdapter-test.ts +113 -17
- package/src/__tests__/EntityEdges-test.ts +97 -72
- package/src/__tests__/EntityFields-test.ts +2 -2
- package/src/__tests__/EntityLoader-test.ts +2 -2
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +11 -11
- package/src/__tests__/EntityMutator-SingleCompositeFieldCacheConsistency-test.ts +73 -0
- package/src/__tests__/EntityMutator-test.ts +74 -46
- package/src/__tests__/EntityPrivacyPolicy-test.ts +51 -74
- package/src/__tests__/EntityQueryContext-test.ts +1 -1
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +3 -3
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +64 -39
- package/src/__tests__/GenericEntityCacheAdapter-test.ts +83 -28
- package/src/__tests__/ReadonlyEntity-test.ts +3 -3
- package/src/__tests__/ViewerContext-test.ts +1 -1
- package/src/__tests__/ViewerScopedEntityCompanion-test.ts +5 -2
- package/src/__tests__/ViewerScopedEntityCompanionProvider-test.ts +1 -1
- package/src/__tests__/ViewerScopedEntityMutatorFactory-test.ts +12 -3
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +12 -12
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +12 -12
- package/src/entityUtils.ts +4 -1
- package/src/errors/EntityInvalidFieldValueError.ts +5 -5
- package/src/errors/EntityNotAuthorizedError.ts +3 -3
- package/src/errors/EntityNotFoundError.ts +5 -5
- package/src/index.ts +7 -7
- package/src/internal/CompositeFieldHolder.ts +218 -0
- package/src/internal/CompositeFieldValueMap.ts +78 -0
- package/src/internal/EntityDataManager.ts +107 -96
- package/src/internal/EntityFieldTransformationUtils.ts +33 -14
- package/src/internal/EntityLoadInterfaces.ts +143 -0
- package/src/internal/EntityTableDataCoordinator.ts +8 -5
- package/src/internal/ReadThroughEntityCache.ts +63 -50
- package/src/internal/SingleFieldHolder.ts +131 -0
- package/src/internal/__tests__/CompositeFieldHolder-test.ts +25 -0
- package/src/internal/__tests__/CompositeFieldValueMap-test.ts +43 -0
- package/src/internal/__tests__/EntityDataManager-test.ts +308 -91
- package/src/internal/__tests__/EntityFieldTransformationUtils-test.ts +3 -2
- package/src/internal/__tests__/ReadThroughEntityCache-test.ts +315 -107
- package/src/metrics/EntityMetricsUtils.ts +7 -2
- package/src/metrics/IEntityMetricsAdapter.ts +6 -0
- package/src/rules/AlwaysAllowPrivacyPolicyRule.ts +5 -5
- package/src/rules/AlwaysDenyPrivacyPolicyRule.ts +5 -5
- package/src/rules/AlwaysSkipPrivacyPolicyRule.ts +5 -5
- package/src/rules/PrivacyPolicyRule.ts +4 -4
- package/src/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.ts +1 -1
- package/src/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.ts +1 -1
- package/src/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.ts +1 -1
- package/src/utils/EntityPrivacyUtils.ts +72 -30
- package/src/utils/{testing → __testfixtures__}/PrivacyPolicyRuleTestUtils.ts +26 -26
- package/src/{testfixtures → utils/__testfixtures__}/SimpleTestEntity.ts +16 -15
- package/src/utils/__testfixtures__/StubCacheAdapter.ts +164 -0
- package/src/utils/{testing → __testfixtures__}/StubDatabaseAdapter.ts +19 -12
- package/src/utils/{testing → __testfixtures__}/StubDatabaseAdapterProvider.ts +4 -4
- package/src/utils/__testfixtures__/TSMockitoExtensions.ts +69 -0
- package/src/{testfixtures → utils/__testfixtures__}/TestEntity.ts +21 -15
- package/src/{testfixtures → utils/__testfixtures__}/TestEntity2.ts +16 -15
- package/src/{testfixtures → utils/__testfixtures__}/TestEntityWithMutationTriggers.ts +23 -22
- package/src/{testfixtures → utils/__testfixtures__}/TestViewerContext.ts +1 -1
- package/src/utils/{testing → __testfixtures__}/describeFieldTestCase.ts +1 -1
- package/src/utils/__tests__/EntityPrivacyUtils-test.ts +62 -66
- package/src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.ts +29 -25
- package/src/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.ts +1 -1
- package/src/utils/collections/SerializableKeyMap.ts +84 -0
- package/src/utils/collections/__tests__/SerializableKeyMap-test.ts +119 -0
- package/src/utils/collections/__tests__/sets-test.ts +17 -0
- package/src/utils/collections/maps.ts +7 -8
- package/src/utils/collections/sets.ts +3 -0
- package/src/utils/mergeEntityMutationTriggerConfigurations.ts +5 -5
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.d.ts +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js +0 -242
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js.map +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.d.ts +0 -26
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.js +0 -110
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.js.map +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.d.ts +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.js +0 -401
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.js.map +0 -1
- package/build/__tests__/ComposedCacheAdapter-test.d.ts +0 -1
- package/build/__tests__/ComposedCacheAdapter-test.js +0 -229
- package/build/__tests__/ComposedCacheAdapter-test.js.map +0 -1
- package/build/__tests__/ComposedSecondaryEntityCache-test.d.ts +0 -1
- package/build/__tests__/ComposedSecondaryEntityCache-test.js +0 -66
- package/build/__tests__/ComposedSecondaryEntityCache-test.js.map +0 -1
- package/build/__tests__/EnforcingEntityAssociationLoader-test.d.ts +0 -1
- package/build/__tests__/EnforcingEntityAssociationLoader-test.js +0 -115
- package/build/__tests__/EnforcingEntityAssociationLoader-test.js.map +0 -1
- package/build/__tests__/EnforcingEntityLoader-test.d.ts +0 -1
- package/build/__tests__/EnforcingEntityLoader-test.js +0 -253
- package/build/__tests__/EnforcingEntityLoader-test.js.map +0 -1
- package/build/__tests__/Entity-test.d.ts +0 -1
- package/build/__tests__/Entity-test.js +0 -94
- package/build/__tests__/Entity-test.js.map +0 -1
- package/build/__tests__/EntityAssociationLoader-test.d.ts +0 -1
- package/build/__tests__/EntityAssociationLoader-test.js +0 -30
- package/build/__tests__/EntityAssociationLoader-test.js.map +0 -1
- package/build/__tests__/EntityCommonUseCases-test.d.ts +0 -1
- package/build/__tests__/EntityCommonUseCases-test.js +0 -146
- package/build/__tests__/EntityCommonUseCases-test.js.map +0 -1
- package/build/__tests__/EntityCompanion-test.d.ts +0 -1
- package/build/__tests__/EntityCompanion-test.js +0 -77
- package/build/__tests__/EntityCompanion-test.js.map +0 -1
- package/build/__tests__/EntityCompanionProvider-test.d.ts +0 -1
- package/build/__tests__/EntityCompanionProvider-test.js +0 -54
- package/build/__tests__/EntityCompanionProvider-test.js.map +0 -1
- package/build/__tests__/EntityConfiguration-test.d.ts +0 -1
- package/build/__tests__/EntityConfiguration-test.js +0 -103
- package/build/__tests__/EntityConfiguration-test.js.map +0 -1
- package/build/__tests__/EntityDatabaseAdapter-test.d.ts +0 -1
- package/build/__tests__/EntityDatabaseAdapter-test.js +0 -146
- package/build/__tests__/EntityDatabaseAdapter-test.js.map +0 -1
- package/build/__tests__/EntityEdges-test.d.ts +0 -1
- package/build/__tests__/EntityEdges-test.js +0 -723
- package/build/__tests__/EntityEdges-test.js.map +0 -1
- package/build/__tests__/EntityFields-test.d.ts +0 -1
- package/build/__tests__/EntityFields-test.js +0 -63
- package/build/__tests__/EntityFields-test.js.map +0 -1
- package/build/__tests__/EntityLoader-test.d.ts +0 -1
- package/build/__tests__/EntityLoader-test.js +0 -36
- package/build/__tests__/EntityLoader-test.js.map +0 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.d.ts +0 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +0 -73
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +0 -1
- package/build/__tests__/EntityMutator-test.d.ts +0 -1
- package/build/__tests__/EntityMutator-test.js +0 -741
- package/build/__tests__/EntityMutator-test.js.map +0 -1
- package/build/__tests__/EntityPrivacyPolicy-test.d.ts +0 -1
- package/build/__tests__/EntityPrivacyPolicy-test.js +0 -463
- package/build/__tests__/EntityPrivacyPolicy-test.js.map +0 -1
- package/build/__tests__/EntityQueryContext-test.d.ts +0 -1
- package/build/__tests__/EntityQueryContext-test.js +0 -116
- package/build/__tests__/EntityQueryContext-test.js.map +0 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.d.ts +0 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.js +0 -60
- package/build/__tests__/EntitySecondaryCacheLoader-test.js.map +0 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.d.ts +0 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.js +0 -201
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +0 -1
- package/build/__tests__/GenericEntityCacheAdapter-test.d.ts +0 -1
- package/build/__tests__/GenericEntityCacheAdapter-test.js +0 -80
- package/build/__tests__/GenericEntityCacheAdapter-test.js.map +0 -1
- package/build/__tests__/ReadonlyEntity-test.d.ts +0 -1
- package/build/__tests__/ReadonlyEntity-test.js +0 -211
- package/build/__tests__/ReadonlyEntity-test.js.map +0 -1
- package/build/__tests__/ViewerContext-test.d.ts +0 -1
- package/build/__tests__/ViewerContext-test.js +0 -30
- package/build/__tests__/ViewerContext-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityCompanion-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityCompanion-test.js +0 -20
- package/build/__tests__/ViewerScopedEntityCompanion-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js +0 -20
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js +0 -23
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js +0 -22
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js.map +0 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.d.ts +0 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +0 -123
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +0 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.d.ts +0 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +0 -121
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +0 -1
- package/build/__tests__/entityUtils-test.d.ts +0 -1
- package/build/__tests__/entityUtils-test.js +0 -87
- package/build/__tests__/entityUtils-test.js.map +0 -1
- package/build/internal/__tests__/EntityDataManager-test.d.ts +0 -1
- package/build/internal/__tests__/EntityDataManager-test.js +0 -373
- package/build/internal/__tests__/EntityDataManager-test.js.map +0 -1
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.d.ts +0 -1
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js +0 -136
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js.map +0 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.d.ts +0 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.js +0 -206
- package/build/internal/__tests__/ReadThroughEntityCache-test.js.map +0 -1
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.d.ts +0 -1
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js +0 -21
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js.map +0 -1
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.d.ts +0 -1
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js +0 -21
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js.map +0 -1
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.d.ts +0 -1
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js +0 -21
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js.map +0 -1
- package/build/testfixtures/DateIDTestEntity.d.ts +0 -19
- package/build/testfixtures/DateIDTestEntity.js +0 -48
- package/build/testfixtures/DateIDTestEntity.js.map +0 -1
- package/build/testfixtures/SimpleTestEntity.d.ts +0 -20
- package/build/testfixtures/SimpleTestEntity.js +0 -48
- package/build/testfixtures/SimpleTestEntity.js.map +0 -1
- package/build/testfixtures/TestEntity.d.ts +0 -30
- package/build/testfixtures/TestEntity.js +0 -93
- package/build/testfixtures/TestEntity.js.map +0 -1
- package/build/testfixtures/TestEntity2.d.ts +0 -20
- package/build/testfixtures/TestEntity2.js +0 -51
- package/build/testfixtures/TestEntity2.js.map +0 -1
- package/build/testfixtures/TestEntityNumberKey.d.ts +0 -19
- package/build/testfixtures/TestEntityNumberKey.js +0 -48
- package/build/testfixtures/TestEntityNumberKey.js.map +0 -1
- package/build/testfixtures/TestEntityWithMutationTriggers.d.ts +0 -36
- package/build/testfixtures/TestEntityWithMutationTriggers.js +0 -82
- package/build/testfixtures/TestEntityWithMutationTriggers.js.map +0 -1
- package/build/testfixtures/TestViewerContext.d.ts +0 -3
- package/build/testfixtures/TestViewerContext.js +0 -10
- package/build/testfixtures/TestViewerContext.js.map +0 -1
- package/build/utils/__tests__/EntityPrivacyUtils-test.d.ts +0 -1
- package/build/utils/__tests__/EntityPrivacyUtils-test.js +0 -486
- package/build/utils/__tests__/EntityPrivacyUtils-test.js.map +0 -1
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.d.ts +0 -1
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js +0 -178
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js.map +0 -1
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.d.ts +0 -1
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js +0 -26
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js.map +0 -1
- package/build/utils/collections/__tests__/maps-test.d.ts +0 -1
- package/build/utils/collections/__tests__/maps-test.js +0 -120
- package/build/utils/collections/__tests__/maps-test.js.map +0 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.d.ts +0 -28
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js +0 -52
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js.map +0 -1
- package/build/utils/testing/StubCacheAdapter.d.ts +0 -27
- package/build/utils/testing/StubCacheAdapter.js +0 -86
- package/build/utils/testing/StubCacheAdapter.js.map +0 -1
- package/build/utils/testing/StubDatabaseAdapter.d.ts +0 -25
- package/build/utils/testing/StubDatabaseAdapter.js +0 -191
- package/build/utils/testing/StubDatabaseAdapter.js.map +0 -1
- package/build/utils/testing/StubDatabaseAdapterProvider.d.ts +0 -7
- package/build/utils/testing/StubDatabaseAdapterProvider.js +0 -14
- package/build/utils/testing/StubDatabaseAdapterProvider.js.map +0 -1
- package/build/utils/testing/StubQueryContextProvider.d.ts +0 -7
- package/build/utils/testing/StubQueryContextProvider.js +0 -19
- package/build/utils/testing/StubQueryContextProvider.js.map +0 -1
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.d.ts +0 -1
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js +0 -42
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js.map +0 -1
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.d.ts +0 -1
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js +0 -402
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js.map +0 -1
- package/build/utils/testing/createUnitTestEntityCompanionProvider.d.ts +0 -7
- package/build/utils/testing/createUnitTestEntityCompanionProvider.js +0 -36
- package/build/utils/testing/createUnitTestEntityCompanionProvider.js.map +0 -1
- package/build/utils/testing/describeFieldTestCase.d.ts +0 -2
- package/build/utils/testing/describeFieldTestCase.js +0 -18
- package/build/utils/testing/describeFieldTestCase.js.map +0 -1
- package/src/testfixtures/DateIDTestEntity.ts +0 -59
- package/src/testfixtures/TestEntityNumberKey.ts +0 -59
- package/src/utils/testing/StubCacheAdapter.ts +0 -122
- package/src/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.ts +0 -42
- package/src/utils/testing/__tests__/StubDatabaseAdapter-test.ts +0 -548
- /package/src/utils/{testing → __testfixtures__}/StubQueryContextProvider.ts +0 -0
- /package/src/utils/{testing → __testfixtures__}/createUnitTestEntityCompanionProvider.ts +0 -0
package/src/Entity.ts
CHANGED
|
@@ -34,11 +34,11 @@ import ViewerContext from './ViewerContext';
|
|
|
34
34
|
* own EntityCompanionDefinition.
|
|
35
35
|
*/
|
|
36
36
|
export default abstract class Entity<
|
|
37
|
-
TFields extends
|
|
38
|
-
|
|
37
|
+
TFields extends Record<string, any>,
|
|
38
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
39
39
|
TViewerContext extends ViewerContext,
|
|
40
40
|
TSelectedFields extends keyof TFields = keyof TFields,
|
|
41
|
-
> extends ReadonlyEntity<TFields,
|
|
41
|
+
> extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields> {
|
|
42
42
|
/**
|
|
43
43
|
* Vend mutator for creating a new entity in given query context.
|
|
44
44
|
* @param viewerContext - viewer context of creating user
|
|
@@ -47,13 +47,13 @@ export default abstract class Entity<
|
|
|
47
47
|
*/
|
|
48
48
|
static creator<
|
|
49
49
|
TMFields extends object,
|
|
50
|
-
|
|
50
|
+
TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>,
|
|
51
51
|
TMViewerContext extends ViewerContext,
|
|
52
52
|
TMViewerContext2 extends TMViewerContext,
|
|
53
|
-
TMEntity extends Entity<TMFields,
|
|
53
|
+
TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>,
|
|
54
54
|
TMPrivacyPolicy extends EntityPrivacyPolicy<
|
|
55
55
|
TMFields,
|
|
56
|
-
|
|
56
|
+
TMIDField,
|
|
57
57
|
TMViewerContext,
|
|
58
58
|
TMEntity,
|
|
59
59
|
TMSelectedFields
|
|
@@ -62,7 +62,7 @@ export default abstract class Entity<
|
|
|
62
62
|
>(
|
|
63
63
|
this: IEntityClass<
|
|
64
64
|
TMFields,
|
|
65
|
-
|
|
65
|
+
TMIDField,
|
|
66
66
|
TMViewerContext,
|
|
67
67
|
TMEntity,
|
|
68
68
|
TMPrivacyPolicy,
|
|
@@ -75,7 +75,7 @@ export default abstract class Entity<
|
|
|
75
75
|
.getQueryContext(),
|
|
76
76
|
): EnforcingEntityCreator<
|
|
77
77
|
TMFields,
|
|
78
|
-
|
|
78
|
+
TMIDField,
|
|
79
79
|
TMViewerContext,
|
|
80
80
|
TMEntity,
|
|
81
81
|
TMPrivacyPolicy,
|
|
@@ -92,13 +92,13 @@ export default abstract class Entity<
|
|
|
92
92
|
*/
|
|
93
93
|
static creatorWithAuthorizationResults<
|
|
94
94
|
TMFields extends object,
|
|
95
|
-
|
|
95
|
+
TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>,
|
|
96
96
|
TMViewerContext extends ViewerContext,
|
|
97
97
|
TMViewerContext2 extends TMViewerContext,
|
|
98
|
-
TMEntity extends Entity<TMFields,
|
|
98
|
+
TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>,
|
|
99
99
|
TMPrivacyPolicy extends EntityPrivacyPolicy<
|
|
100
100
|
TMFields,
|
|
101
|
-
|
|
101
|
+
TMIDField,
|
|
102
102
|
TMViewerContext,
|
|
103
103
|
TMEntity,
|
|
104
104
|
TMSelectedFields
|
|
@@ -107,7 +107,7 @@ export default abstract class Entity<
|
|
|
107
107
|
>(
|
|
108
108
|
this: IEntityClass<
|
|
109
109
|
TMFields,
|
|
110
|
-
|
|
110
|
+
TMIDField,
|
|
111
111
|
TMViewerContext,
|
|
112
112
|
TMEntity,
|
|
113
113
|
TMPrivacyPolicy,
|
|
@@ -120,7 +120,7 @@ export default abstract class Entity<
|
|
|
120
120
|
.getQueryContext(),
|
|
121
121
|
): AuthorizationResultBasedCreateMutator<
|
|
122
122
|
TMFields,
|
|
123
|
-
|
|
123
|
+
TMIDField,
|
|
124
124
|
TMViewerContext,
|
|
125
125
|
TMEntity,
|
|
126
126
|
TMPrivacyPolicy,
|
|
@@ -137,12 +137,12 @@ export default abstract class Entity<
|
|
|
137
137
|
*/
|
|
138
138
|
static updater<
|
|
139
139
|
TMFields extends object,
|
|
140
|
-
|
|
140
|
+
TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>,
|
|
141
141
|
TMViewerContext extends ViewerContext,
|
|
142
|
-
TMEntity extends Entity<TMFields,
|
|
142
|
+
TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>,
|
|
143
143
|
TMPrivacyPolicy extends EntityPrivacyPolicy<
|
|
144
144
|
TMFields,
|
|
145
|
-
|
|
145
|
+
TMIDField,
|
|
146
146
|
TMViewerContext,
|
|
147
147
|
TMEntity,
|
|
148
148
|
TMSelectedFields
|
|
@@ -151,7 +151,7 @@ export default abstract class Entity<
|
|
|
151
151
|
>(
|
|
152
152
|
this: IEntityClass<
|
|
153
153
|
TMFields,
|
|
154
|
-
|
|
154
|
+
TMIDField,
|
|
155
155
|
TMViewerContext,
|
|
156
156
|
TMEntity,
|
|
157
157
|
TMPrivacyPolicy,
|
|
@@ -165,7 +165,7 @@ export default abstract class Entity<
|
|
|
165
165
|
.getQueryContext(),
|
|
166
166
|
): EnforcingEntityUpdater<
|
|
167
167
|
TMFields,
|
|
168
|
-
|
|
168
|
+
TMIDField,
|
|
169
169
|
TMViewerContext,
|
|
170
170
|
TMEntity,
|
|
171
171
|
TMPrivacyPolicy,
|
|
@@ -182,12 +182,12 @@ export default abstract class Entity<
|
|
|
182
182
|
*/
|
|
183
183
|
static updaterWithAuthorizationResults<
|
|
184
184
|
TMFields extends object,
|
|
185
|
-
|
|
185
|
+
TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>,
|
|
186
186
|
TMViewerContext extends ViewerContext,
|
|
187
|
-
TMEntity extends Entity<TMFields,
|
|
187
|
+
TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>,
|
|
188
188
|
TMPrivacyPolicy extends EntityPrivacyPolicy<
|
|
189
189
|
TMFields,
|
|
190
|
-
|
|
190
|
+
TMIDField,
|
|
191
191
|
TMViewerContext,
|
|
192
192
|
TMEntity,
|
|
193
193
|
TMSelectedFields
|
|
@@ -196,7 +196,7 @@ export default abstract class Entity<
|
|
|
196
196
|
>(
|
|
197
197
|
this: IEntityClass<
|
|
198
198
|
TMFields,
|
|
199
|
-
|
|
199
|
+
TMIDField,
|
|
200
200
|
TMViewerContext,
|
|
201
201
|
TMEntity,
|
|
202
202
|
TMPrivacyPolicy,
|
|
@@ -210,7 +210,7 @@ export default abstract class Entity<
|
|
|
210
210
|
.getQueryContext(),
|
|
211
211
|
): AuthorizationResultBasedUpdateMutator<
|
|
212
212
|
TMFields,
|
|
213
|
-
|
|
213
|
+
TMIDField,
|
|
214
214
|
TMViewerContext,
|
|
215
215
|
TMEntity,
|
|
216
216
|
TMPrivacyPolicy,
|
|
@@ -227,12 +227,12 @@ export default abstract class Entity<
|
|
|
227
227
|
*/
|
|
228
228
|
static deleter<
|
|
229
229
|
TMFields extends object,
|
|
230
|
-
|
|
230
|
+
TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>,
|
|
231
231
|
TMViewerContext extends ViewerContext,
|
|
232
|
-
TMEntity extends Entity<TMFields,
|
|
232
|
+
TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>,
|
|
233
233
|
TMPrivacyPolicy extends EntityPrivacyPolicy<
|
|
234
234
|
TMFields,
|
|
235
|
-
|
|
235
|
+
TMIDField,
|
|
236
236
|
TMViewerContext,
|
|
237
237
|
TMEntity,
|
|
238
238
|
TMSelectedFields
|
|
@@ -241,7 +241,7 @@ export default abstract class Entity<
|
|
|
241
241
|
>(
|
|
242
242
|
this: IEntityClass<
|
|
243
243
|
TMFields,
|
|
244
|
-
|
|
244
|
+
TMIDField,
|
|
245
245
|
TMViewerContext,
|
|
246
246
|
TMEntity,
|
|
247
247
|
TMPrivacyPolicy,
|
|
@@ -255,7 +255,7 @@ export default abstract class Entity<
|
|
|
255
255
|
.getQueryContext(),
|
|
256
256
|
): EnforcingEntityDeleter<
|
|
257
257
|
TMFields,
|
|
258
|
-
|
|
258
|
+
TMIDField,
|
|
259
259
|
TMViewerContext,
|
|
260
260
|
TMEntity,
|
|
261
261
|
TMPrivacyPolicy,
|
|
@@ -272,12 +272,12 @@ export default abstract class Entity<
|
|
|
272
272
|
*/
|
|
273
273
|
static deleterWithAuthorizationResults<
|
|
274
274
|
TMFields extends object,
|
|
275
|
-
|
|
275
|
+
TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>,
|
|
276
276
|
TMViewerContext extends ViewerContext,
|
|
277
|
-
TMEntity extends Entity<TMFields,
|
|
277
|
+
TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>,
|
|
278
278
|
TMPrivacyPolicy extends EntityPrivacyPolicy<
|
|
279
279
|
TMFields,
|
|
280
|
-
|
|
280
|
+
TMIDField,
|
|
281
281
|
TMViewerContext,
|
|
282
282
|
TMEntity,
|
|
283
283
|
TMSelectedFields
|
|
@@ -286,7 +286,7 @@ export default abstract class Entity<
|
|
|
286
286
|
>(
|
|
287
287
|
this: IEntityClass<
|
|
288
288
|
TMFields,
|
|
289
|
-
|
|
289
|
+
TMIDField,
|
|
290
290
|
TMViewerContext,
|
|
291
291
|
TMEntity,
|
|
292
292
|
TMPrivacyPolicy,
|
|
@@ -300,7 +300,7 @@ export default abstract class Entity<
|
|
|
300
300
|
.getQueryContext(),
|
|
301
301
|
): AuthorizationResultBasedDeleteMutator<
|
|
302
302
|
TMFields,
|
|
303
|
-
|
|
303
|
+
TMIDField,
|
|
304
304
|
TMViewerContext,
|
|
305
305
|
TMEntity,
|
|
306
306
|
TMPrivacyPolicy,
|
|
@@ -314,13 +314,13 @@ export default abstract class Entity<
|
|
|
314
314
|
* An interface to pass in constructor (class) of an Entity as a function argument.
|
|
315
315
|
*/
|
|
316
316
|
export interface IEntityClass<
|
|
317
|
-
TFields extends
|
|
318
|
-
|
|
317
|
+
TFields extends Record<string, any>,
|
|
318
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
319
319
|
TViewerContext extends ViewerContext,
|
|
320
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
320
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
321
321
|
TPrivacyPolicy extends EntityPrivacyPolicy<
|
|
322
322
|
TFields,
|
|
323
|
-
|
|
323
|
+
TIDField,
|
|
324
324
|
TViewerContext,
|
|
325
325
|
TEntity,
|
|
326
326
|
TSelectedFields
|
|
@@ -329,7 +329,7 @@ export interface IEntityClass<
|
|
|
329
329
|
> {
|
|
330
330
|
new (constructorParam: {
|
|
331
331
|
viewerContext: TViewerContext;
|
|
332
|
-
id:
|
|
332
|
+
id: TFields[TIDField];
|
|
333
333
|
databaseFields: Readonly<TFields>;
|
|
334
334
|
selectedFields: Readonly<Pick<TFields, TSelectedFields>>;
|
|
335
335
|
}): TEntity;
|
|
@@ -341,7 +341,7 @@ export interface IEntityClass<
|
|
|
341
341
|
*/
|
|
342
342
|
defineCompanionDefinition(): EntityCompanionDefinition<
|
|
343
343
|
TFields,
|
|
344
|
-
|
|
344
|
+
TIDField,
|
|
345
345
|
TViewerContext,
|
|
346
346
|
TEntity,
|
|
347
347
|
TPrivacyPolicy,
|
|
@@ -11,10 +11,10 @@ import ViewerContext from './ViewerContext';
|
|
|
11
11
|
* by foreign keys.
|
|
12
12
|
*/
|
|
13
13
|
export default class EntityAssociationLoader<
|
|
14
|
-
TFields extends
|
|
15
|
-
|
|
14
|
+
TFields extends Record<string, any>,
|
|
15
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
16
16
|
TViewerContext extends ViewerContext,
|
|
17
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
17
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
18
18
|
TSelectedFields extends keyof TFields,
|
|
19
19
|
> {
|
|
20
20
|
constructor(
|
|
@@ -24,7 +24,7 @@ export default class EntityAssociationLoader<
|
|
|
24
24
|
.getViewerScopedEntityCompanionForClass(
|
|
25
25
|
entity.constructor as IEntityClass<
|
|
26
26
|
TFields,
|
|
27
|
-
|
|
27
|
+
TIDField,
|
|
28
28
|
TViewerContext,
|
|
29
29
|
TEntity,
|
|
30
30
|
any,
|
|
@@ -42,7 +42,7 @@ export default class EntityAssociationLoader<
|
|
|
42
42
|
*/
|
|
43
43
|
enforcing(): EnforcingEntityAssociationLoader<
|
|
44
44
|
TFields,
|
|
45
|
-
|
|
45
|
+
TIDField,
|
|
46
46
|
TViewerContext,
|
|
47
47
|
TEntity,
|
|
48
48
|
TSelectedFields
|
|
@@ -57,7 +57,7 @@ export default class EntityAssociationLoader<
|
|
|
57
57
|
*/
|
|
58
58
|
withAuthorizationResults(): AuthorizationResultBasedEntityAssociationLoader<
|
|
59
59
|
TFields,
|
|
60
|
-
|
|
60
|
+
TIDField,
|
|
61
61
|
TViewerContext,
|
|
62
62
|
TEntity,
|
|
63
63
|
TSelectedFields
|
package/src/EntityCompanion.ts
CHANGED
|
@@ -17,13 +17,13 @@ export interface IPrivacyPolicyClass<TPrivacyPolicy> {
|
|
|
17
17
|
* Composition root responsible for orchestrating setup of Entity mutators and loaders.
|
|
18
18
|
*/
|
|
19
19
|
export default class EntityCompanion<
|
|
20
|
-
TFields extends
|
|
21
|
-
|
|
20
|
+
TFields extends Record<string, any>,
|
|
21
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
22
22
|
TViewerContext extends ViewerContext,
|
|
23
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
23
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
24
24
|
TPrivacyPolicy extends EntityPrivacyPolicy<
|
|
25
25
|
TFields,
|
|
26
|
-
|
|
26
|
+
TIDField,
|
|
27
27
|
TViewerContext,
|
|
28
28
|
TEntity,
|
|
29
29
|
TSelectedFields
|
|
@@ -34,7 +34,7 @@ export default class EntityCompanion<
|
|
|
34
34
|
|
|
35
35
|
private readonly entityLoaderFactory: EntityLoaderFactory<
|
|
36
36
|
TFields,
|
|
37
|
-
|
|
37
|
+
TIDField,
|
|
38
38
|
TViewerContext,
|
|
39
39
|
TEntity,
|
|
40
40
|
TPrivacyPolicy,
|
|
@@ -42,7 +42,7 @@ export default class EntityCompanion<
|
|
|
42
42
|
>;
|
|
43
43
|
private readonly entityMutatorFactory: EntityMutatorFactory<
|
|
44
44
|
TFields,
|
|
45
|
-
|
|
45
|
+
TIDField,
|
|
46
46
|
TViewerContext,
|
|
47
47
|
TEntity,
|
|
48
48
|
TPrivacyPolicy,
|
|
@@ -53,19 +53,19 @@ export default class EntityCompanion<
|
|
|
53
53
|
public readonly entityCompanionProvider: EntityCompanionProvider,
|
|
54
54
|
public readonly entityCompanionDefinition: EntityCompanionDefinition<
|
|
55
55
|
TFields,
|
|
56
|
-
|
|
56
|
+
TIDField,
|
|
57
57
|
TViewerContext,
|
|
58
58
|
TEntity,
|
|
59
59
|
TPrivacyPolicy,
|
|
60
60
|
TSelectedFields
|
|
61
61
|
>,
|
|
62
|
-
private readonly tableDataCoordinator: EntityTableDataCoordinator<TFields>,
|
|
62
|
+
private readonly tableDataCoordinator: EntityTableDataCoordinator<TFields, TIDField>,
|
|
63
63
|
private readonly metricsAdapter: IEntityMetricsAdapter,
|
|
64
64
|
) {
|
|
65
65
|
this.privacyPolicy = new entityCompanionDefinition.privacyPolicyClass();
|
|
66
66
|
this.entityLoaderFactory = new EntityLoaderFactory<
|
|
67
67
|
TFields,
|
|
68
|
-
|
|
68
|
+
TIDField,
|
|
69
69
|
TViewerContext,
|
|
70
70
|
TEntity,
|
|
71
71
|
TPrivacyPolicy,
|
|
@@ -89,7 +89,7 @@ export default class EntityCompanion<
|
|
|
89
89
|
|
|
90
90
|
getLoaderFactory(): EntityLoaderFactory<
|
|
91
91
|
TFields,
|
|
92
|
-
|
|
92
|
+
TIDField,
|
|
93
93
|
TViewerContext,
|
|
94
94
|
TEntity,
|
|
95
95
|
TPrivacyPolicy,
|
|
@@ -100,7 +100,7 @@ export default class EntityCompanion<
|
|
|
100
100
|
|
|
101
101
|
getMutatorFactory(): EntityMutatorFactory<
|
|
102
102
|
TFields,
|
|
103
|
-
|
|
103
|
+
TIDField,
|
|
104
104
|
TViewerContext,
|
|
105
105
|
TEntity,
|
|
106
106
|
TPrivacyPolicy,
|
|
@@ -50,13 +50,13 @@ export interface CacheAdapterFlavorDefinition {
|
|
|
50
50
|
* used to power the entity framework for a particular type of entity.
|
|
51
51
|
*/
|
|
52
52
|
export interface EntityCompanionDefinition<
|
|
53
|
-
TFields extends
|
|
54
|
-
|
|
53
|
+
TFields extends Record<string, any>,
|
|
54
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
55
55
|
TViewerContext extends ViewerContext,
|
|
56
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
56
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
57
57
|
TPrivacyPolicy extends EntityPrivacyPolicy<
|
|
58
58
|
TFields,
|
|
59
|
-
|
|
59
|
+
TIDField,
|
|
60
60
|
TViewerContext,
|
|
61
61
|
TEntity,
|
|
62
62
|
TSelectedFields
|
|
@@ -68,7 +68,7 @@ export interface EntityCompanionDefinition<
|
|
|
68
68
|
*/
|
|
69
69
|
readonly entityClass: IEntityClass<
|
|
70
70
|
TFields,
|
|
71
|
-
|
|
71
|
+
TIDField,
|
|
72
72
|
TViewerContext,
|
|
73
73
|
TEntity,
|
|
74
74
|
TPrivacyPolicy,
|
|
@@ -78,7 +78,7 @@ export interface EntityCompanionDefinition<
|
|
|
78
78
|
/**
|
|
79
79
|
* The EntityConfiguration for this entity.
|
|
80
80
|
*/
|
|
81
|
-
readonly entityConfiguration: EntityConfiguration<TFields>;
|
|
81
|
+
readonly entityConfiguration: EntityConfiguration<TFields, TIDField>;
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* The EntityPrivacyPolicy class for this entity.
|
|
@@ -90,7 +90,7 @@ export interface EntityCompanionDefinition<
|
|
|
90
90
|
*/
|
|
91
91
|
readonly mutationValidators?: EntityMutationValidator<
|
|
92
92
|
TFields,
|
|
93
|
-
|
|
93
|
+
TIDField,
|
|
94
94
|
TViewerContext,
|
|
95
95
|
TEntity,
|
|
96
96
|
TSelectedFields
|
|
@@ -101,7 +101,7 @@ export interface EntityCompanionDefinition<
|
|
|
101
101
|
*/
|
|
102
102
|
readonly mutationTriggers?: EntityMutationTriggerConfiguration<
|
|
103
103
|
TFields,
|
|
104
|
-
|
|
104
|
+
TIDField,
|
|
105
105
|
TViewerContext,
|
|
106
106
|
TEntity,
|
|
107
107
|
TSelectedFields
|
|
@@ -131,7 +131,7 @@ export default class EntityCompanionProvider {
|
|
|
131
131
|
> = new Map();
|
|
132
132
|
private readonly companionMap: Map<string, EntityCompanion<any, any, any, any, any, any>> =
|
|
133
133
|
new Map();
|
|
134
|
-
private readonly tableDataCoordinatorMap: Map<string, EntityTableDataCoordinator<any>> =
|
|
134
|
+
private readonly tableDataCoordinatorMap: Map<string, EntityTableDataCoordinator<any, any>> =
|
|
135
135
|
new Map();
|
|
136
136
|
|
|
137
137
|
/**
|
|
@@ -167,13 +167,13 @@ export default class EntityCompanionProvider {
|
|
|
167
167
|
* @param entityClass - entity class to load
|
|
168
168
|
*/
|
|
169
169
|
getCompanionForEntity<
|
|
170
|
-
TFields extends
|
|
171
|
-
|
|
170
|
+
TFields extends Record<string, any>,
|
|
171
|
+
TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>,
|
|
172
172
|
TViewerContext extends ViewerContext,
|
|
173
|
-
TEntity extends ReadonlyEntity<TFields,
|
|
173
|
+
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
|
|
174
174
|
TPrivacyPolicy extends EntityPrivacyPolicy<
|
|
175
175
|
TFields,
|
|
176
|
-
|
|
176
|
+
TIDField,
|
|
177
177
|
TViewerContext,
|
|
178
178
|
TEntity,
|
|
179
179
|
TSelectedFields
|
|
@@ -182,13 +182,13 @@ export default class EntityCompanionProvider {
|
|
|
182
182
|
>(
|
|
183
183
|
entityClass: IEntityClass<
|
|
184
184
|
TFields,
|
|
185
|
-
|
|
185
|
+
TIDField,
|
|
186
186
|
TViewerContext,
|
|
187
187
|
TEntity,
|
|
188
188
|
TPrivacyPolicy,
|
|
189
189
|
TSelectedFields
|
|
190
190
|
>,
|
|
191
|
-
): EntityCompanion<TFields,
|
|
191
|
+
): EntityCompanion<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields> {
|
|
192
192
|
const entityCompanionDefinition = computeIfAbsent(
|
|
193
193
|
this.companionDefinitionMap,
|
|
194
194
|
entityClass.name,
|
|
@@ -220,10 +220,13 @@ export default class EntityCompanionProvider {
|
|
|
220
220
|
return entityDatabaseAdapterFlavor.queryContextProvider;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
private getTableDataCoordinatorForEntity<
|
|
224
|
-
|
|
223
|
+
private getTableDataCoordinatorForEntity<
|
|
224
|
+
TFields extends Record<string, any>,
|
|
225
|
+
TIDField extends keyof TFields,
|
|
226
|
+
>(
|
|
227
|
+
entityConfiguration: EntityConfiguration<TFields, TIDField>,
|
|
225
228
|
entityClassName: string,
|
|
226
|
-
): EntityTableDataCoordinator<TFields> {
|
|
229
|
+
): EntityTableDataCoordinator<TFields, TIDField> {
|
|
227
230
|
return computeIfAbsent(this.tableDataCoordinatorMap, entityConfiguration.tableName, () => {
|
|
228
231
|
const entityDatabaseAdapterFlavor = this.databaseAdapterFlavors.get(
|
|
229
232
|
entityConfiguration.databaseAdapterFlavor,
|
|
@@ -1,20 +1,120 @@
|
|
|
1
|
+
import invariant from 'invariant';
|
|
2
|
+
|
|
1
3
|
import { IEntityClass } from './Entity';
|
|
2
4
|
import { DatabaseAdapterFlavor, CacheAdapterFlavor } from './EntityCompanionProvider';
|
|
3
5
|
import { EntityFieldDefinition } from './EntityFieldDefinition';
|
|
6
|
+
import {
|
|
7
|
+
CompositeFieldHolder,
|
|
8
|
+
SerializedCompositeFieldHolder,
|
|
9
|
+
} from './internal/CompositeFieldHolder';
|
|
4
10
|
import { mapMap, invertMap, reduceMap } from './utils/collections/maps';
|
|
5
11
|
|
|
12
|
+
/**
|
|
13
|
+
* A composite field is an unordered set of fields by which entities can be loaded in a batched
|
|
14
|
+
* and (optionally) cached manner akin to how normal fieldName loads are batched and (optionally) cached.
|
|
15
|
+
*/
|
|
16
|
+
export type EntityCompositeField<TFields extends Record<string, any>> = readonly (keyof TFields)[];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Specification of composite field for an entity and whether it can be cached.
|
|
20
|
+
*/
|
|
21
|
+
export type EntityCompositeFieldDefinition<TFields extends Record<string, any>> = {
|
|
22
|
+
/**
|
|
23
|
+
* The composite field.
|
|
24
|
+
*/
|
|
25
|
+
compositeField: EntityCompositeField<TFields>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether or not to cache loaded instances of the entity by this composite field. The column names in
|
|
29
|
+
* the composite field are used to derive a cache key for the cache entry. If true, the set of columns
|
|
30
|
+
* must be able uniquely identify the entity and the database must have a unique constraint on the
|
|
31
|
+
* set of columns.
|
|
32
|
+
*/
|
|
33
|
+
cache: boolean;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A composite field value is a mapping of fields to values for a composite field.
|
|
38
|
+
*/
|
|
39
|
+
export type EntityCompositeFieldValue<
|
|
40
|
+
TFields extends Record<string, any>,
|
|
41
|
+
TCompositeField extends EntityCompositeField<TFields>,
|
|
42
|
+
> = Record<TCompositeField[number], NonNullable<TFields[TCompositeField[number]]>>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Helper class to validate and store composite field information.
|
|
46
|
+
*/
|
|
47
|
+
export class CompositeFieldInfo<
|
|
48
|
+
TFields extends Record<string, any>,
|
|
49
|
+
TIDField extends keyof TFields,
|
|
50
|
+
> {
|
|
51
|
+
private readonly compositeFieldInfoMap: ReadonlyMap<
|
|
52
|
+
SerializedCompositeFieldHolder,
|
|
53
|
+
{
|
|
54
|
+
compositeFieldHolder: CompositeFieldHolder<TFields, TIDField>;
|
|
55
|
+
cache: boolean;
|
|
56
|
+
}
|
|
57
|
+
>;
|
|
58
|
+
|
|
59
|
+
constructor(compositeFieldsDefinitions: EntityCompositeFieldDefinition<TFields>[]) {
|
|
60
|
+
this.compositeFieldInfoMap = new Map(
|
|
61
|
+
compositeFieldsDefinitions.map((keyDefinition) => {
|
|
62
|
+
invariant(
|
|
63
|
+
keyDefinition.compositeField.length >= 2,
|
|
64
|
+
'Composite field must have at least two sub-fields',
|
|
65
|
+
);
|
|
66
|
+
invariant(
|
|
67
|
+
keyDefinition.compositeField.length === new Set(keyDefinition.compositeField).size,
|
|
68
|
+
'Composite field must have unique sub-fields',
|
|
69
|
+
);
|
|
70
|
+
const compositeFieldHolder = new CompositeFieldHolder(keyDefinition.compositeField);
|
|
71
|
+
return [
|
|
72
|
+
compositeFieldHolder.serialize(),
|
|
73
|
+
{ compositeFieldHolder, cache: keyDefinition.cache ?? false },
|
|
74
|
+
];
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public getCompositeFieldHolderForCompositeField(
|
|
80
|
+
compositeField: EntityCompositeField<TFields>,
|
|
81
|
+
): CompositeFieldHolder<TFields, TIDField> | undefined {
|
|
82
|
+
return this.compositeFieldInfoMap.get(new CompositeFieldHolder(compositeField).serialize())
|
|
83
|
+
?.compositeFieldHolder;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public getAllCompositeFieldHolders(): readonly CompositeFieldHolder<TFields, TIDField>[] {
|
|
87
|
+
return Array.from(this.compositeFieldInfoMap.values()).map((v) => v.compositeFieldHolder);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public canCacheCompositeField(compositeField: EntityCompositeField<TFields>): boolean {
|
|
91
|
+
const compositeFieldInfo = this.compositeFieldInfoMap.get(
|
|
92
|
+
new CompositeFieldHolder(compositeField).serialize(),
|
|
93
|
+
);
|
|
94
|
+
invariant(
|
|
95
|
+
compositeFieldInfo,
|
|
96
|
+
`Composite field (${compositeField.join(',')}) not found in entity configuration`,
|
|
97
|
+
);
|
|
98
|
+
return compositeFieldInfo.cache;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
6
102
|
/**
|
|
7
103
|
* The data storage configuration for a type of Entity. Contains information relating to IDs,
|
|
8
104
|
* cachable fields, field mappings, and types of cache and database adapter.
|
|
9
105
|
*/
|
|
10
|
-
export default class EntityConfiguration<
|
|
106
|
+
export default class EntityConfiguration<
|
|
107
|
+
TFields extends Record<string, any>,
|
|
108
|
+
TIDField extends keyof TFields,
|
|
109
|
+
> {
|
|
11
110
|
readonly idField: keyof TFields;
|
|
12
111
|
readonly tableName: string;
|
|
13
112
|
readonly cacheableKeys: ReadonlySet<keyof TFields>;
|
|
113
|
+
readonly compositeFieldInfo: CompositeFieldInfo<TFields, TIDField>;
|
|
14
114
|
readonly cacheKeyVersion: number;
|
|
15
115
|
|
|
16
116
|
readonly inboundEdges: IEntityClass<any, any, any, any, any, any>[];
|
|
17
|
-
readonly schema: ReadonlyMap<keyof TFields, EntityFieldDefinition<any>>;
|
|
117
|
+
readonly schema: ReadonlyMap<keyof TFields, EntityFieldDefinition<any, any>>;
|
|
18
118
|
readonly entityToDBFieldsKeyMapping: ReadonlyMap<keyof TFields, string>;
|
|
19
119
|
readonly dbToEntityFieldsKeyMapping: ReadonlyMap<string, keyof TFields>;
|
|
20
120
|
|
|
@@ -27,13 +127,14 @@ export default class EntityConfiguration<TFields extends Record<string, any>> {
|
|
|
27
127
|
schema,
|
|
28
128
|
inboundEdges = [],
|
|
29
129
|
cacheKeyVersion = 0,
|
|
130
|
+
compositeFieldDefinitions,
|
|
30
131
|
databaseAdapterFlavor,
|
|
31
132
|
cacheAdapterFlavor,
|
|
32
133
|
}: {
|
|
33
134
|
/**
|
|
34
135
|
* The field used to identify this entity. Must be a unique field in the table.
|
|
35
136
|
*/
|
|
36
|
-
idField:
|
|
137
|
+
idField: TIDField;
|
|
37
138
|
|
|
38
139
|
/**
|
|
39
140
|
* The name of the table where entities of this type are stored.
|
|
@@ -43,7 +144,8 @@ export default class EntityConfiguration<TFields extends Record<string, any>> {
|
|
|
43
144
|
/**
|
|
44
145
|
* Map from each entity field to an EntityFieldDefinition specifying information about the field.
|
|
45
146
|
*/
|
|
46
|
-
schema: Record<keyof TFields, EntityFieldDefinition<any
|
|
147
|
+
schema: Omit<Record<keyof TFields, EntityFieldDefinition<any, false>>, TIDField> &
|
|
148
|
+
Record<TIDField, EntityFieldDefinition<any, true>>;
|
|
47
149
|
|
|
48
150
|
/**
|
|
49
151
|
* List of other entity types that reference this type in EntityFieldDefinition associations.
|
|
@@ -56,6 +158,11 @@ export default class EntityConfiguration<TFields extends Record<string, any>> {
|
|
|
56
158
|
*/
|
|
57
159
|
cacheKeyVersion?: number;
|
|
58
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Composite field definitions for this entity.
|
|
163
|
+
*/
|
|
164
|
+
compositeFieldDefinitions?: EntityCompositeFieldDefinition<TFields>[];
|
|
165
|
+
|
|
59
166
|
/**
|
|
60
167
|
* Backing database and transaction type for this entity.
|
|
61
168
|
*/
|
|
@@ -75,17 +182,24 @@ export default class EntityConfiguration<TFields extends Record<string, any>> {
|
|
|
75
182
|
|
|
76
183
|
// external schema is a Record to typecheck that all fields have FieldDefinitions,
|
|
77
184
|
// but internally the most useful representation is a map for lookups
|
|
78
|
-
EntityConfiguration.validateSchema(schema);
|
|
185
|
+
EntityConfiguration.validateSchema<TFields, TIDField>(schema);
|
|
79
186
|
this.schema = new Map(Object.entries(schema));
|
|
80
187
|
|
|
81
188
|
this.cacheableKeys = EntityConfiguration.computeCacheableKeys(this.schema);
|
|
189
|
+
this.compositeFieldInfo = new CompositeFieldInfo(compositeFieldDefinitions ?? []);
|
|
82
190
|
this.entityToDBFieldsKeyMapping = EntityConfiguration.computeEntityToDBFieldsKeyMapping(
|
|
83
191
|
this.schema,
|
|
84
192
|
);
|
|
85
193
|
this.dbToEntityFieldsKeyMapping = invertMap(this.entityToDBFieldsKeyMapping);
|
|
86
194
|
}
|
|
87
195
|
|
|
88
|
-
private static validateSchema<
|
|
196
|
+
private static validateSchema<
|
|
197
|
+
TFields extends Record<string, any>,
|
|
198
|
+
TIDField extends keyof TFields,
|
|
199
|
+
>(
|
|
200
|
+
schema: Omit<Record<keyof TFields, EntityFieldDefinition<any, false>>, TIDField> &
|
|
201
|
+
Record<TIDField, EntityFieldDefinition<any, true>>,
|
|
202
|
+
): void {
|
|
89
203
|
const disallowedFieldsKeys = Object.getOwnPropertyNames(Object.prototype);
|
|
90
204
|
for (const disallowedFieldsKey of disallowedFieldsKeys) {
|
|
91
205
|
if (Object.hasOwn(schema, disallowedFieldsKey)) {
|
|
@@ -96,8 +210,8 @@ export default class EntityConfiguration<TFields extends Record<string, any>> {
|
|
|
96
210
|
}
|
|
97
211
|
}
|
|
98
212
|
|
|
99
|
-
private static computeCacheableKeys<TFields
|
|
100
|
-
schema: ReadonlyMap<keyof TFields, EntityFieldDefinition<any>>,
|
|
213
|
+
private static computeCacheableKeys<TFields extends Record<string, any>>(
|
|
214
|
+
schema: ReadonlyMap<keyof TFields, EntityFieldDefinition<any, any>>,
|
|
101
215
|
): ReadonlySet<keyof TFields> {
|
|
102
216
|
return reduceMap(
|
|
103
217
|
schema,
|
|
@@ -112,7 +226,7 @@ export default class EntityConfiguration<TFields extends Record<string, any>> {
|
|
|
112
226
|
}
|
|
113
227
|
|
|
114
228
|
private static computeEntityToDBFieldsKeyMapping<TFields>(
|
|
115
|
-
schema: ReadonlyMap<keyof TFields, EntityFieldDefinition<any>>,
|
|
229
|
+
schema: ReadonlyMap<keyof TFields, EntityFieldDefinition<any, any>>,
|
|
116
230
|
): ReadonlyMap<keyof TFields, string> {
|
|
117
231
|
return mapMap(schema, (v) => v.columnName);
|
|
118
232
|
}
|