@expo/entity 0.41.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/AuthorizationResultBasedEntityAssociationLoader.d.ts +16 -16
- package/build/AuthorizationResultBasedEntityAssociationLoader.js.map +1 -1
- package/build/AuthorizationResultBasedEntityLoader.d.ts +39 -67
- package/build/AuthorizationResultBasedEntityLoader.js +85 -62
- package/build/AuthorizationResultBasedEntityLoader.js.map +1 -1
- package/build/AuthorizationResultBasedEntityMutator.d.ts +16 -16
- package/build/AuthorizationResultBasedEntityMutator.js.map +1 -1
- package/build/ComposedEntityCacheAdapter.d.ts +7 -6
- package/build/ComposedEntityCacheAdapter.js +28 -28
- package/build/ComposedEntityCacheAdapter.js.map +1 -1
- package/build/ComposedSecondaryEntityCache.d.ts +1 -1
- package/build/ComposedSecondaryEntityCache.js.map +1 -1
- package/build/EnforcingEntityAssociationLoader.d.ts +15 -15
- package/build/EnforcingEntityAssociationLoader.js.map +1 -1
- package/build/EnforcingEntityCreator.d.ts +2 -2
- package/build/EnforcingEntityDeleter.d.ts +2 -2
- package/build/EnforcingEntityLoader.d.ts +104 -18
- package/build/EnforcingEntityLoader.js +113 -12
- package/build/EnforcingEntityLoader.js.map +1 -1
- package/build/EnforcingEntityUpdater.d.ts +2 -2
- package/build/Entity.d.ts +10 -10
- package/build/Entity.js.map +1 -1
- package/build/EntityAssociationLoader.d.ts +3 -3
- package/build/EntityCompanion.d.ts +5 -5
- package/build/EntityCompanion.js.map +1 -1
- package/build/EntityCompanionProvider.d.ts +6 -6
- package/build/EntityCompanionProvider.js.map +1 -1
- package/build/EntityConfiguration.d.ts +46 -5
- package/build/EntityConfiguration.js +39 -1
- package/build/EntityConfiguration.js.map +1 -1
- package/build/EntityCreator.d.ts +4 -4
- package/build/EntityDatabaseAdapter.d.ts +15 -14
- package/build/EntityDatabaseAdapter.js +20 -12
- package/build/EntityDatabaseAdapter.js.map +1 -1
- package/build/EntityDeleter.d.ts +4 -4
- package/build/EntityFieldDefinition.d.ts +20 -10
- package/build/EntityFieldDefinition.js +3 -1
- package/build/EntityFieldDefinition.js.map +1 -1
- package/build/EntityFields.d.ts +14 -12
- package/build/EntityFields.js.map +1 -1
- package/build/EntityLoader.d.ts +5 -5
- package/build/EntityLoaderFactory.d.ts +3 -3
- package/build/EntityLoaderFactory.js.map +1 -1
- package/build/EntityLoaderUtils.d.ts +2 -2
- package/build/EntityLoaderUtils.js +27 -1
- package/build/EntityLoaderUtils.js.map +1 -1
- package/build/EntityMutationInfo.d.ts +2 -2
- package/build/EntityMutationTriggerConfiguration.d.ts +14 -14
- package/build/EntityMutationTriggerConfiguration.js.map +1 -1
- package/build/EntityMutationValidator.d.ts +2 -2
- package/build/EntityMutatorFactory.d.ts +5 -5
- package/build/EntityMutatorFactory.js.map +1 -1
- package/build/EntityPrivacyPolicy.d.ts +14 -14
- package/build/EntityPrivacyPolicy.js.map +1 -1
- package/build/EntitySecondaryCacheLoader.d.ts +4 -4
- package/build/EntityUpdater.d.ts +4 -4
- package/build/GenericEntityCacheAdapter.d.ts +7 -6
- package/build/GenericEntityCacheAdapter.js +13 -14
- package/build/GenericEntityCacheAdapter.js.map +1 -1
- package/build/GenericSecondaryEntityCache.d.ts +3 -3
- package/build/GenericSecondaryEntityCache.js.map +1 -1
- package/build/IEntityCacheAdapter.d.ts +17 -16
- package/build/IEntityCacheAdapterProvider.d.ts +1 -1
- package/build/IEntityDatabaseAdapterProvider.d.ts +1 -1
- package/build/IEntityGenericCacher.d.ts +15 -5
- package/build/ReadonlyEntity.d.ts +8 -8
- package/build/ReadonlyEntity.js.map +1 -1
- package/build/ViewerContext.d.ts +1 -1
- package/build/ViewerScopedEntityCompanion.d.ts +5 -5
- package/build/ViewerScopedEntityCompanionProvider.d.ts +1 -1
- package/build/ViewerScopedEntityLoaderFactory.d.ts +3 -3
- package/build/ViewerScopedEntityMutatorFactory.d.ts +5 -5
- package/build/entityUtils.d.ts +1 -1
- package/build/entityUtils.js.map +1 -1
- package/build/errors/EntityInvalidFieldValueError.d.ts +2 -2
- package/build/errors/EntityNotAuthorizedError.d.ts +1 -1
- package/build/errors/EntityNotFoundError.d.ts +2 -2
- package/build/index.d.ts +7 -7
- package/build/index.js +8 -13
- package/build/index.js.map +1 -1
- package/build/internal/CompositeFieldHolder.d.ts +48 -0
- package/build/internal/CompositeFieldHolder.js +116 -0
- package/build/internal/CompositeFieldHolder.js.map +1 -0
- package/build/internal/CompositeFieldValueMap.d.ts +15 -0
- package/build/internal/CompositeFieldValueMap.js +51 -0
- package/build/internal/CompositeFieldValueMap.js.map +1 -0
- package/build/internal/EntityDataManager.d.ts +16 -16
- package/build/internal/EntityDataManager.js +42 -45
- package/build/internal/EntityDataManager.js.map +1 -1
- package/build/internal/EntityFieldTransformationUtils.d.ts +5 -5
- package/build/internal/EntityFieldTransformationUtils.js.map +1 -1
- package/build/internal/EntityLoadInterfaces.d.ts +104 -0
- package/build/internal/EntityLoadInterfaces.js +25 -0
- package/build/internal/EntityLoadInterfaces.js.map +1 -0
- package/build/internal/EntityTableDataCoordinator.d.ts +6 -6
- package/build/internal/EntityTableDataCoordinator.js.map +1 -1
- package/build/internal/ReadThroughEntityCache.d.ts +17 -16
- package/build/internal/ReadThroughEntityCache.js +36 -36
- package/build/internal/ReadThroughEntityCache.js.map +1 -1
- package/build/internal/SingleFieldHolder.d.ts +34 -0
- package/build/internal/SingleFieldHolder.js +90 -0
- package/build/internal/SingleFieldHolder.js.map +1 -0
- package/build/metrics/EntityMetricsUtils.d.ts +2 -1
- package/build/metrics/EntityMetricsUtils.js.map +1 -1
- package/build/metrics/IEntityMetricsAdapter.d.ts +5 -0
- package/build/metrics/IEntityMetricsAdapter.js.map +1 -1
- package/build/rules/AlwaysAllowPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysAllowPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysDenyPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysDenyPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysSkipPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysSkipPrivacyPolicyRule.js.map +1 -1
- package/build/rules/PrivacyPolicyRule.d.ts +2 -2
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/build/utils/EntityPrivacyUtils.d.ts +4 -4
- package/build/utils/EntityPrivacyUtils.js.map +1 -1
- package/build/utils/collections/SerializableKeyMap.d.ts +27 -0
- package/build/utils/collections/SerializableKeyMap.js +60 -0
- package/build/utils/collections/SerializableKeyMap.js.map +1 -0
- package/build/utils/collections/maps.js +1 -2
- package/build/utils/collections/maps.js.map +1 -1
- package/build/utils/collections/sets.d.ts +1 -0
- package/build/utils/collections/sets.js +7 -0
- package/build/utils/collections/sets.js.map +1 -0
- package/build/utils/mergeEntityMutationTriggerConfigurations.d.ts +1 -1
- package/package.json +8 -5
- package/src/AuthorizationResultBasedEntityAssociationLoader.ts +56 -49
- package/src/AuthorizationResultBasedEntityLoader.ts +194 -81
- package/src/AuthorizationResultBasedEntityMutator.ts +71 -45
- package/src/ComposedEntityCacheAdapter.ts +55 -46
- package/src/ComposedSecondaryEntityCache.ts +5 -2
- package/src/EnforcingEntityAssociationLoader.ts +52 -44
- package/src/EnforcingEntityCreator.ts +5 -5
- package/src/EnforcingEntityDeleter.ts +5 -5
- package/src/EnforcingEntityLoader.ts +158 -21
- package/src/EnforcingEntityUpdater.ts +5 -5
- package/src/Entity.ts +39 -39
- package/src/EntityAssociationLoader.ts +6 -6
- package/src/EntityCompanion.ts +11 -11
- package/src/EntityCompanionProvider.ts +21 -18
- package/src/EntityConfiguration.ts +123 -9
- package/src/EntityCreator.ts +7 -7
- package/src/EntityDatabaseAdapter.ts +51 -28
- package/src/EntityDeleter.ts +7 -7
- package/src/EntityFieldDefinition.ts +32 -12
- package/src/EntityFields.ts +49 -12
- package/src/EntityLoader.ts +8 -8
- package/src/EntityLoaderFactory.ts +8 -8
- package/src/EntityLoaderUtils.ts +39 -10
- package/src/EntityMutationInfo.ts +6 -6
- package/src/EntityMutationTriggerConfiguration.ts +68 -20
- package/src/EntityMutationValidator.ts +4 -4
- package/src/EntityMutatorFactory.ts +13 -13
- package/src/EntityPrivacyPolicy.ts +50 -26
- package/src/EntitySecondaryCacheLoader.ts +6 -6
- package/src/EntityUpdater.ts +7 -7
- package/src/GenericEntityCacheAdapter.ts +39 -28
- package/src/GenericSecondaryEntityCache.ts +6 -3
- package/src/IEntityCacheAdapter.ts +45 -25
- package/src/IEntityCacheAdapterProvider.ts +3 -3
- package/src/IEntityDatabaseAdapterProvider.ts +3 -3
- package/src/IEntityGenericCacher.ts +33 -5
- package/src/ReadonlyEntity.ts +24 -24
- package/src/ViewerContext.ts +5 -5
- package/src/ViewerScopedEntityCompanion.ts +7 -7
- package/src/ViewerScopedEntityCompanionProvider.ts +6 -6
- package/src/ViewerScopedEntityLoaderFactory.ts +7 -7
- package/src/ViewerScopedEntityMutatorFactory.ts +8 -8
- package/src/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.ts +4 -4
- package/src/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.ts +14 -13
- package/src/__tests__/AuthorizationResultBasedEntityLoader-test.ts +367 -69
- package/src/__tests__/ComposedCacheAdapter-test.ts +235 -117
- package/src/__tests__/EnforcingEntityLoader-test.ts +135 -1
- package/src/__tests__/Entity-test.ts +2 -2
- package/src/__tests__/EntityAssociationLoader-test.ts +2 -2
- package/src/__tests__/EntityCommonUseCases-test.ts +11 -11
- package/src/__tests__/EntityCompanion-test.ts +4 -4
- package/src/__tests__/EntityCompanionProvider-test.ts +9 -8
- package/src/__tests__/EntityConfiguration-test.ts +85 -6
- package/src/__tests__/EntityDatabaseAdapter-test.ts +113 -17
- package/src/__tests__/EntityEdges-test.ts +97 -72
- package/src/__tests__/EntityFields-test.ts +2 -2
- package/src/__tests__/EntityLoader-test.ts +2 -2
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +11 -11
- package/src/__tests__/EntityMutator-SingleCompositeFieldCacheConsistency-test.ts +73 -0
- package/src/__tests__/EntityMutator-test.ts +74 -46
- package/src/__tests__/EntityPrivacyPolicy-test.ts +51 -74
- package/src/__tests__/EntityQueryContext-test.ts +1 -1
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +3 -3
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +64 -39
- package/src/__tests__/GenericEntityCacheAdapter-test.ts +83 -28
- package/src/__tests__/ReadonlyEntity-test.ts +3 -3
- package/src/__tests__/ViewerContext-test.ts +1 -1
- package/src/__tests__/ViewerScopedEntityCompanion-test.ts +5 -2
- package/src/__tests__/ViewerScopedEntityCompanionProvider-test.ts +1 -1
- package/src/__tests__/ViewerScopedEntityMutatorFactory-test.ts +12 -3
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +12 -12
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +12 -12
- package/src/entityUtils.ts +4 -1
- package/src/errors/EntityInvalidFieldValueError.ts +5 -5
- package/src/errors/EntityNotAuthorizedError.ts +3 -3
- package/src/errors/EntityNotFoundError.ts +5 -5
- package/src/index.ts +7 -7
- package/src/internal/CompositeFieldHolder.ts +218 -0
- package/src/internal/CompositeFieldValueMap.ts +78 -0
- package/src/internal/EntityDataManager.ts +107 -96
- package/src/internal/EntityFieldTransformationUtils.ts +33 -14
- package/src/internal/EntityLoadInterfaces.ts +143 -0
- package/src/internal/EntityTableDataCoordinator.ts +8 -5
- package/src/internal/ReadThroughEntityCache.ts +63 -50
- package/src/internal/SingleFieldHolder.ts +131 -0
- package/src/internal/__tests__/CompositeFieldHolder-test.ts +25 -0
- package/src/internal/__tests__/CompositeFieldValueMap-test.ts +43 -0
- package/src/internal/__tests__/EntityDataManager-test.ts +308 -91
- package/src/internal/__tests__/EntityFieldTransformationUtils-test.ts +3 -2
- package/src/internal/__tests__/ReadThroughEntityCache-test.ts +315 -107
- package/src/metrics/EntityMetricsUtils.ts +7 -2
- package/src/metrics/IEntityMetricsAdapter.ts +6 -0
- package/src/rules/AlwaysAllowPrivacyPolicyRule.ts +5 -5
- package/src/rules/AlwaysDenyPrivacyPolicyRule.ts +5 -5
- package/src/rules/AlwaysSkipPrivacyPolicyRule.ts +5 -5
- package/src/rules/PrivacyPolicyRule.ts +4 -4
- package/src/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.ts +1 -1
- package/src/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.ts +1 -1
- package/src/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.ts +1 -1
- package/src/utils/EntityPrivacyUtils.ts +72 -30
- package/src/utils/{testing → __testfixtures__}/PrivacyPolicyRuleTestUtils.ts +26 -26
- package/src/{testfixtures → utils/__testfixtures__}/SimpleTestEntity.ts +16 -15
- package/src/utils/__testfixtures__/StubCacheAdapter.ts +164 -0
- package/src/utils/{testing → __testfixtures__}/StubDatabaseAdapter.ts +19 -12
- package/src/utils/{testing → __testfixtures__}/StubDatabaseAdapterProvider.ts +4 -4
- package/src/utils/__testfixtures__/TSMockitoExtensions.ts +69 -0
- package/src/{testfixtures → utils/__testfixtures__}/TestEntity.ts +21 -15
- package/src/{testfixtures → utils/__testfixtures__}/TestEntity2.ts +16 -15
- package/src/{testfixtures → utils/__testfixtures__}/TestEntityWithMutationTriggers.ts +23 -22
- package/src/{testfixtures → utils/__testfixtures__}/TestViewerContext.ts +1 -1
- package/src/utils/{testing → __testfixtures__}/describeFieldTestCase.ts +1 -1
- package/src/utils/__tests__/EntityPrivacyUtils-test.ts +62 -66
- package/src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.ts +29 -25
- package/src/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.ts +1 -1
- package/src/utils/collections/SerializableKeyMap.ts +84 -0
- package/src/utils/collections/__tests__/SerializableKeyMap-test.ts +119 -0
- package/src/utils/collections/__tests__/sets-test.ts +17 -0
- package/src/utils/collections/maps.ts +7 -8
- package/src/utils/collections/sets.ts +3 -0
- package/src/utils/mergeEntityMutationTriggerConfigurations.ts +5 -5
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.d.ts +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js +0 -242
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js.map +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.d.ts +0 -26
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.js +0 -110
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.js.map +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.d.ts +0 -1
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.js +0 -401
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.js.map +0 -1
- package/build/__tests__/ComposedCacheAdapter-test.d.ts +0 -1
- package/build/__tests__/ComposedCacheAdapter-test.js +0 -229
- package/build/__tests__/ComposedCacheAdapter-test.js.map +0 -1
- package/build/__tests__/ComposedSecondaryEntityCache-test.d.ts +0 -1
- package/build/__tests__/ComposedSecondaryEntityCache-test.js +0 -66
- package/build/__tests__/ComposedSecondaryEntityCache-test.js.map +0 -1
- package/build/__tests__/EnforcingEntityAssociationLoader-test.d.ts +0 -1
- package/build/__tests__/EnforcingEntityAssociationLoader-test.js +0 -115
- package/build/__tests__/EnforcingEntityAssociationLoader-test.js.map +0 -1
- package/build/__tests__/EnforcingEntityLoader-test.d.ts +0 -1
- package/build/__tests__/EnforcingEntityLoader-test.js +0 -253
- package/build/__tests__/EnforcingEntityLoader-test.js.map +0 -1
- package/build/__tests__/Entity-test.d.ts +0 -1
- package/build/__tests__/Entity-test.js +0 -94
- package/build/__tests__/Entity-test.js.map +0 -1
- package/build/__tests__/EntityAssociationLoader-test.d.ts +0 -1
- package/build/__tests__/EntityAssociationLoader-test.js +0 -30
- package/build/__tests__/EntityAssociationLoader-test.js.map +0 -1
- package/build/__tests__/EntityCommonUseCases-test.d.ts +0 -1
- package/build/__tests__/EntityCommonUseCases-test.js +0 -146
- package/build/__tests__/EntityCommonUseCases-test.js.map +0 -1
- package/build/__tests__/EntityCompanion-test.d.ts +0 -1
- package/build/__tests__/EntityCompanion-test.js +0 -77
- package/build/__tests__/EntityCompanion-test.js.map +0 -1
- package/build/__tests__/EntityCompanionProvider-test.d.ts +0 -1
- package/build/__tests__/EntityCompanionProvider-test.js +0 -54
- package/build/__tests__/EntityCompanionProvider-test.js.map +0 -1
- package/build/__tests__/EntityConfiguration-test.d.ts +0 -1
- package/build/__tests__/EntityConfiguration-test.js +0 -103
- package/build/__tests__/EntityConfiguration-test.js.map +0 -1
- package/build/__tests__/EntityDatabaseAdapter-test.d.ts +0 -1
- package/build/__tests__/EntityDatabaseAdapter-test.js +0 -146
- package/build/__tests__/EntityDatabaseAdapter-test.js.map +0 -1
- package/build/__tests__/EntityEdges-test.d.ts +0 -1
- package/build/__tests__/EntityEdges-test.js +0 -723
- package/build/__tests__/EntityEdges-test.js.map +0 -1
- package/build/__tests__/EntityFields-test.d.ts +0 -1
- package/build/__tests__/EntityFields-test.js +0 -63
- package/build/__tests__/EntityFields-test.js.map +0 -1
- package/build/__tests__/EntityLoader-test.d.ts +0 -1
- package/build/__tests__/EntityLoader-test.js +0 -36
- package/build/__tests__/EntityLoader-test.js.map +0 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.d.ts +0 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +0 -73
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +0 -1
- package/build/__tests__/EntityMutator-test.d.ts +0 -1
- package/build/__tests__/EntityMutator-test.js +0 -741
- package/build/__tests__/EntityMutator-test.js.map +0 -1
- package/build/__tests__/EntityPrivacyPolicy-test.d.ts +0 -1
- package/build/__tests__/EntityPrivacyPolicy-test.js +0 -463
- package/build/__tests__/EntityPrivacyPolicy-test.js.map +0 -1
- package/build/__tests__/EntityQueryContext-test.d.ts +0 -1
- package/build/__tests__/EntityQueryContext-test.js +0 -116
- package/build/__tests__/EntityQueryContext-test.js.map +0 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.d.ts +0 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.js +0 -60
- package/build/__tests__/EntitySecondaryCacheLoader-test.js.map +0 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.d.ts +0 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.js +0 -201
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +0 -1
- package/build/__tests__/GenericEntityCacheAdapter-test.d.ts +0 -1
- package/build/__tests__/GenericEntityCacheAdapter-test.js +0 -80
- package/build/__tests__/GenericEntityCacheAdapter-test.js.map +0 -1
- package/build/__tests__/ReadonlyEntity-test.d.ts +0 -1
- package/build/__tests__/ReadonlyEntity-test.js +0 -211
- package/build/__tests__/ReadonlyEntity-test.js.map +0 -1
- package/build/__tests__/ViewerContext-test.d.ts +0 -1
- package/build/__tests__/ViewerContext-test.js +0 -30
- package/build/__tests__/ViewerContext-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityCompanion-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityCompanion-test.js +0 -20
- package/build/__tests__/ViewerScopedEntityCompanion-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js +0 -20
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js +0 -23
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js.map +0 -1
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.d.ts +0 -1
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js +0 -22
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js.map +0 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.d.ts +0 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +0 -123
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +0 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.d.ts +0 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +0 -121
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +0 -1
- package/build/__tests__/entityUtils-test.d.ts +0 -1
- package/build/__tests__/entityUtils-test.js +0 -87
- package/build/__tests__/entityUtils-test.js.map +0 -1
- package/build/internal/__tests__/EntityDataManager-test.d.ts +0 -1
- package/build/internal/__tests__/EntityDataManager-test.js +0 -373
- package/build/internal/__tests__/EntityDataManager-test.js.map +0 -1
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.d.ts +0 -1
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js +0 -136
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js.map +0 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.d.ts +0 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.js +0 -206
- package/build/internal/__tests__/ReadThroughEntityCache-test.js.map +0 -1
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.d.ts +0 -1
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js +0 -21
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js.map +0 -1
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.d.ts +0 -1
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js +0 -21
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js.map +0 -1
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.d.ts +0 -1
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js +0 -21
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js.map +0 -1
- package/build/testfixtures/DateIDTestEntity.d.ts +0 -19
- package/build/testfixtures/DateIDTestEntity.js +0 -48
- package/build/testfixtures/DateIDTestEntity.js.map +0 -1
- package/build/testfixtures/SimpleTestEntity.d.ts +0 -20
- package/build/testfixtures/SimpleTestEntity.js +0 -48
- package/build/testfixtures/SimpleTestEntity.js.map +0 -1
- package/build/testfixtures/TestEntity.d.ts +0 -30
- package/build/testfixtures/TestEntity.js +0 -93
- package/build/testfixtures/TestEntity.js.map +0 -1
- package/build/testfixtures/TestEntity2.d.ts +0 -20
- package/build/testfixtures/TestEntity2.js +0 -51
- package/build/testfixtures/TestEntity2.js.map +0 -1
- package/build/testfixtures/TestEntityNumberKey.d.ts +0 -19
- package/build/testfixtures/TestEntityNumberKey.js +0 -48
- package/build/testfixtures/TestEntityNumberKey.js.map +0 -1
- package/build/testfixtures/TestEntityWithMutationTriggers.d.ts +0 -36
- package/build/testfixtures/TestEntityWithMutationTriggers.js +0 -82
- package/build/testfixtures/TestEntityWithMutationTriggers.js.map +0 -1
- package/build/testfixtures/TestViewerContext.d.ts +0 -3
- package/build/testfixtures/TestViewerContext.js +0 -10
- package/build/testfixtures/TestViewerContext.js.map +0 -1
- package/build/utils/__tests__/EntityPrivacyUtils-test.d.ts +0 -1
- package/build/utils/__tests__/EntityPrivacyUtils-test.js +0 -486
- package/build/utils/__tests__/EntityPrivacyUtils-test.js.map +0 -1
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.d.ts +0 -1
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js +0 -178
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js.map +0 -1
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.d.ts +0 -1
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js +0 -26
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js.map +0 -1
- package/build/utils/collections/__tests__/maps-test.d.ts +0 -1
- package/build/utils/collections/__tests__/maps-test.js +0 -120
- package/build/utils/collections/__tests__/maps-test.js.map +0 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.d.ts +0 -28
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js +0 -52
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js.map +0 -1
- package/build/utils/testing/StubCacheAdapter.d.ts +0 -27
- package/build/utils/testing/StubCacheAdapter.js +0 -86
- package/build/utils/testing/StubCacheAdapter.js.map +0 -1
- package/build/utils/testing/StubDatabaseAdapter.d.ts +0 -25
- package/build/utils/testing/StubDatabaseAdapter.js +0 -191
- package/build/utils/testing/StubDatabaseAdapter.js.map +0 -1
- package/build/utils/testing/StubDatabaseAdapterProvider.d.ts +0 -7
- package/build/utils/testing/StubDatabaseAdapterProvider.js +0 -14
- package/build/utils/testing/StubDatabaseAdapterProvider.js.map +0 -1
- package/build/utils/testing/StubQueryContextProvider.d.ts +0 -7
- package/build/utils/testing/StubQueryContextProvider.js +0 -19
- package/build/utils/testing/StubQueryContextProvider.js.map +0 -1
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.d.ts +0 -1
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js +0 -42
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js.map +0 -1
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.d.ts +0 -1
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js +0 -402
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js.map +0 -1
- package/build/utils/testing/createUnitTestEntityCompanionProvider.d.ts +0 -7
- package/build/utils/testing/createUnitTestEntityCompanionProvider.js +0 -36
- package/build/utils/testing/createUnitTestEntityCompanionProvider.js.map +0 -1
- package/build/utils/testing/describeFieldTestCase.d.ts +0 -2
- package/build/utils/testing/describeFieldTestCase.js +0 -18
- package/build/utils/testing/describeFieldTestCase.js.map +0 -1
- package/src/testfixtures/DateIDTestEntity.ts +0 -59
- package/src/testfixtures/TestEntityNumberKey.ts +0 -59
- package/src/utils/testing/StubCacheAdapter.ts +0 -122
- package/src/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.ts +0 -42
- package/src/utils/testing/__tests__/StubDatabaseAdapter-test.ts +0 -548
- /package/src/utils/{testing → __testfixtures__}/StubQueryContextProvider.ts +0 -0
- /package/src/utils/{testing → __testfixtures__}/createUnitTestEntityCompanionProvider.ts +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AuthorizationResultBasedEntityLoader from './AuthorizationResultBasedEntityLoader';
|
|
2
|
+
import { EntityCompositeField, EntityCompositeFieldValue } from './EntityConfiguration';
|
|
2
3
|
import { FieldEqualityCondition, QuerySelectionModifiers, QuerySelectionModifiersWithOrderByRaw } from './EntityDatabaseAdapter';
|
|
3
4
|
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
4
5
|
import ReadonlyEntity from './ReadonlyEntity';
|
|
@@ -8,59 +9,144 @@ import ViewerContext from './ViewerContext';
|
|
|
8
9
|
* cached, and authorized against the entity's EntityPrivacyPolicy. All loads
|
|
9
10
|
* through this loader will throw if the load is not successful.
|
|
10
11
|
*/
|
|
11
|
-
export default class EnforcingEntityLoader<TFields extends
|
|
12
|
+
export default class EnforcingEntityLoader<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
|
|
12
13
|
private readonly entityLoader;
|
|
13
|
-
constructor(entityLoader: AuthorizationResultBasedEntityLoader<TFields,
|
|
14
|
+
constructor(entityLoader: AuthorizationResultBasedEntityLoader<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>);
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Load many entities where fieldName is one of fieldValues.
|
|
17
|
+
* @param fieldName - entity field being queried
|
|
18
|
+
* @param fieldValues - fieldName field values being queried
|
|
19
|
+
* @returns map from fieldValue to entities that match the query for that fieldValue
|
|
16
20
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
17
21
|
*/
|
|
18
22
|
loadManyByFieldEqualingManyAsync<N extends keyof Pick<TFields, TSelectedFields>>(fieldName: N, fieldValues: readonly NonNullable<TFields[N]>[]): Promise<ReadonlyMap<NonNullable<TFields[N]>, readonly TEntity[]>>;
|
|
19
23
|
/**
|
|
20
|
-
*
|
|
24
|
+
* Load many entities where compositeField is one of compositeFieldValues.
|
|
25
|
+
* @param compositeField - composite field being queried
|
|
26
|
+
* @param compositeFieldValues - compositeField values being queried
|
|
27
|
+
* @returns map from compositeFieldValue to entities that match the query for that compositeFieldValue
|
|
28
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
29
|
+
*/
|
|
30
|
+
loadManyByCompositeFieldEqualingManyAsync<N extends EntityCompositeField<Pick<TFields, TSelectedFields>>>(compositeField: N, compositeFieldValues: readonly EntityCompositeFieldValue<Pick<TFields, TSelectedFields>, N>[]): Promise<ReadonlyMap<EntityCompositeFieldValue<TFields, N>, readonly TEntity[]>>;
|
|
31
|
+
/**
|
|
32
|
+
* Load many entities where fieldName equals fieldValue.
|
|
33
|
+
* @param fieldName - entity field being queried
|
|
34
|
+
* @param fieldValue - fieldName field value being queried
|
|
35
|
+
* @returns array of entities that match the query for fieldValue
|
|
21
36
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
22
37
|
*/
|
|
23
38
|
loadManyByFieldEqualingAsync<N extends keyof Pick<TFields, TSelectedFields>>(fieldName: N, fieldValue: NonNullable<TFields[N]>): Promise<readonly TEntity[]>;
|
|
24
39
|
/**
|
|
25
|
-
*
|
|
40
|
+
* Load many entities where compositeField equals compositeFieldValue.
|
|
41
|
+
* @param compositeField - composite field being queried
|
|
42
|
+
* @param compositeFieldValue - compositeField value being queried
|
|
43
|
+
* @returns array of entities that match the query for compositeFieldValue
|
|
44
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
45
|
+
*/
|
|
46
|
+
loadManyByCompositeFieldEqualingAsync<N extends EntityCompositeField<Pick<TFields, TSelectedFields>>>(compositeField: N, compositeFieldValue: EntityCompositeFieldValue<Pick<TFields, TSelectedFields>, N>): Promise<readonly TEntity[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Load an entity where fieldName equals fieldValue, or null if no entity exists.
|
|
49
|
+
* @param uniqueFieldName - entity field being queried
|
|
50
|
+
* @param fieldValue - uniqueFieldName field value being queried
|
|
51
|
+
* @returns entity where uniqueFieldName equals fieldValue, or null if no entity matches the condition.
|
|
52
|
+
* @throws when multiple entities match the condition
|
|
26
53
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
27
|
-
* @throws when multiple entities are found matching the condition
|
|
28
54
|
*/
|
|
29
55
|
loadByFieldEqualingAsync<N extends keyof Pick<TFields, TSelectedFields>>(uniqueFieldName: N, fieldValue: NonNullable<TFields[N]>): Promise<TEntity | null>;
|
|
30
56
|
/**
|
|
31
|
-
*
|
|
57
|
+
* Load an entity where compositeField equals compositeFieldValue, or null if no entity exists.
|
|
58
|
+
* @param compositeField - composite field being queried
|
|
59
|
+
* @param compositeFieldValue - compositeField value being queried
|
|
60
|
+
* @returns entity where compositeField equals compositeFieldValue, or null if no entity matches the condition.
|
|
61
|
+
* @throws when multiple entities match the condition
|
|
62
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
63
|
+
*/
|
|
64
|
+
loadByCompositeFieldEqualingAsync<N extends EntityCompositeField<Pick<TFields, TSelectedFields>>>(compositeField: N, compositeFieldValue: EntityCompositeFieldValue<Pick<TFields, TSelectedFields>, N>): Promise<TEntity | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Loads an entity by a specified ID.
|
|
67
|
+
* @param id - ID of the entity
|
|
68
|
+
* @returns entity matching ID
|
|
32
69
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
70
|
+
* @throws EntityNotFoundError when no entity exists for ID
|
|
33
71
|
*/
|
|
34
|
-
loadByIDAsync(id:
|
|
72
|
+
loadByIDAsync(id: TFields[TIDField]): Promise<TEntity>;
|
|
35
73
|
/**
|
|
36
|
-
*
|
|
74
|
+
* Load an entity by a specified ID, or return null if non-existent.
|
|
75
|
+
* @param id - ID of the entity
|
|
76
|
+
* @returns entity for matching ID, or null if no entity exists for ID.
|
|
37
77
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
38
78
|
* @throws when multiple entities are found matching the condition
|
|
39
79
|
*/
|
|
40
|
-
loadByIDNullableAsync(id:
|
|
80
|
+
loadByIDNullableAsync(id: TFields[TIDField]): Promise<TEntity | null>;
|
|
41
81
|
/**
|
|
42
|
-
*
|
|
82
|
+
* Loads many entities for a list of IDs.
|
|
83
|
+
* @param ids - IDs of the entities to load
|
|
84
|
+
* @returns map from ID to corresponding entity result, where result error can be UnauthorizedError or EntityNotFoundError.
|
|
43
85
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
86
|
+
* @throws EntityNotFoundError when no entity exists for one or more of the IDs
|
|
44
87
|
*/
|
|
45
|
-
loadManyByIDsAsync(ids: readonly
|
|
88
|
+
loadManyByIDsAsync(ids: readonly TFields[TIDField][]): Promise<ReadonlyMap<TFields[TIDField], TEntity>>;
|
|
46
89
|
/**
|
|
47
|
-
*
|
|
90
|
+
* Loads many entities for a list of IDs, returning null for any IDs that are non-existent.
|
|
91
|
+
* @param ids - IDs of the entities to load
|
|
92
|
+
* @returns map from ID to nullable corresponding entity
|
|
48
93
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
49
94
|
*/
|
|
50
|
-
loadManyByIDsNullableAsync(ids: readonly
|
|
95
|
+
loadManyByIDsNullableAsync(ids: readonly TFields[TIDField][]): Promise<ReadonlyMap<TFields[TIDField], TEntity | null>>;
|
|
51
96
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
97
|
+
* Loads the first entity matching the selection constructed from the conjunction of specified
|
|
98
|
+
* operands, or null if no matching entity exists. Entities loaded using this method are not
|
|
99
|
+
* batched or cached.
|
|
100
|
+
*
|
|
101
|
+
* This is a convenience method for {@link loadManyByFieldEqualityConjunctionAsync}. However, the
|
|
102
|
+
* `orderBy` option must be specified to define what "first" means. If ordering doesn't matter,
|
|
103
|
+
* explicitly pass in an empty array.
|
|
104
|
+
*
|
|
105
|
+
* @param fieldEqualityOperands - list of field equality selection operand specifications
|
|
106
|
+
* @param querySelectionModifiers - orderBy and optional offset for the query
|
|
107
|
+
* @returns the first entity that matches the query or null if no entity matches the query
|
|
108
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
54
109
|
*/
|
|
55
110
|
loadFirstByFieldEqualityConjunctionAsync<N extends keyof Pick<TFields, TSelectedFields>>(fieldEqualityOperands: FieldEqualityCondition<TFields, N>[], querySelectionModifiers: Omit<QuerySelectionModifiers<TFields>, 'limit'> & Required<Pick<QuerySelectionModifiers<TFields>, 'orderBy'>>): Promise<TEntity | null>;
|
|
56
111
|
/**
|
|
57
|
-
*
|
|
112
|
+
* Loads many entities matching the selection constructed from the conjunction of specified operands.
|
|
113
|
+
* Entities loaded using this method are not batched or cached.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* fieldEqualityOperands:
|
|
117
|
+
* `[{fieldName: 'hello', fieldValue: 1}, {fieldName: 'world', fieldValues: [2, 3]}]`
|
|
118
|
+
* Entities returned with a SQL EntityDatabaseAdapter:
|
|
119
|
+
* `WHERE hello = 1 AND world = ANY({2, 3})`
|
|
120
|
+
*
|
|
121
|
+
* @param fieldEqualityOperands - list of field equality selection operand specifications
|
|
122
|
+
* @param querySelectionModifiers - limit, offset, and orderBy for the query
|
|
123
|
+
* @returns array of entities that match the query
|
|
58
124
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
59
125
|
*/
|
|
60
126
|
loadManyByFieldEqualityConjunctionAsync<N extends keyof Pick<TFields, TSelectedFields>>(fieldEqualityOperands: FieldEqualityCondition<TFields, N>[], querySelectionModifiers?: QuerySelectionModifiers<TFields>): Promise<readonly TEntity[]>;
|
|
61
127
|
/**
|
|
62
|
-
*
|
|
128
|
+
* Loads many entities matching the raw WHERE clause. Corresponds to the knex `whereRaw` argument format.
|
|
129
|
+
*
|
|
130
|
+
* @remarks
|
|
131
|
+
* Important notes:
|
|
132
|
+
* - Fields in clause are database column names instead of transformed entity field names.
|
|
133
|
+
* - Entities loaded using this method are not batched or cached.
|
|
134
|
+
* - Not all database adapters implement the ability to execute this method of fetching entities.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* rawWhereClause: `id = ?`
|
|
138
|
+
* bindings: `[1]`
|
|
139
|
+
* Entites returned `WHERE id = 1`
|
|
140
|
+
*
|
|
141
|
+
* http://knexjs.org/#Builder-whereRaw
|
|
142
|
+
* http://knexjs.org/#Raw-Bindings
|
|
143
|
+
*
|
|
144
|
+
* @param rawWhereClause - parameterized SQL WHERE clause with positional binding placeholders or named binding placeholders
|
|
145
|
+
* @param bindings - array of positional bindings or object of named bindings
|
|
146
|
+
* @param querySelectionModifiers - limit, offset, orderBy, and orderByRaw for the query
|
|
147
|
+
* @returns array of entities that match the query
|
|
63
148
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
149
|
+
* @throws Error when rawWhereClause or bindings are invalid
|
|
64
150
|
*/
|
|
65
151
|
loadManyByRawWhereClauseAsync(rawWhereClause: string, bindings: any[] | object, querySelectionModifiers?: QuerySelectionModifiersWithOrderByRaw<TFields>): Promise<readonly TEntity[]>;
|
|
66
152
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const CompositeFieldHolder_1 = require("./internal/CompositeFieldHolder");
|
|
4
|
+
const CompositeFieldValueMap_1 = require("./internal/CompositeFieldValueMap");
|
|
3
5
|
const maps_1 = require("./utils/collections/maps");
|
|
4
6
|
/**
|
|
5
7
|
* Enforcing entity loader. All normal loads are batched,
|
|
@@ -12,7 +14,10 @@ class EnforcingEntityLoader {
|
|
|
12
14
|
this.entityLoader = entityLoader;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
17
|
+
* Load many entities where fieldName is one of fieldValues.
|
|
18
|
+
* @param fieldName - entity field being queried
|
|
19
|
+
* @param fieldValues - fieldName field values being queried
|
|
20
|
+
* @returns map from fieldValue to entities that match the query for that fieldValue
|
|
16
21
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
17
22
|
*/
|
|
18
23
|
async loadManyByFieldEqualingManyAsync(fieldName, fieldValues) {
|
|
@@ -20,7 +25,26 @@ class EnforcingEntityLoader {
|
|
|
20
25
|
return (0, maps_1.mapMap)(fieldValuesToResults, (results) => results.map((result) => result.enforceValue()));
|
|
21
26
|
}
|
|
22
27
|
/**
|
|
23
|
-
*
|
|
28
|
+
* Load many entities where compositeField is one of compositeFieldValues.
|
|
29
|
+
* @param compositeField - composite field being queried
|
|
30
|
+
* @param compositeFieldValues - compositeField values being queried
|
|
31
|
+
* @returns map from compositeFieldValue to entities that match the query for that compositeFieldValue
|
|
32
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
33
|
+
*/
|
|
34
|
+
async loadManyByCompositeFieldEqualingManyAsync(compositeField, compositeFieldValues) {
|
|
35
|
+
const compositeFieldValuesToResults = await this.entityLoader.loadManyByCompositeFieldEqualingManyAsync(compositeField, compositeFieldValues);
|
|
36
|
+
return new CompositeFieldValueMap_1.CompositeFieldValueMap(Array.from(compositeFieldValuesToResults.entries()).map(([compositeFieldValue, results]) => {
|
|
37
|
+
return [
|
|
38
|
+
new CompositeFieldHolder_1.CompositeFieldValueHolder(compositeFieldValue),
|
|
39
|
+
results.map((result) => result.enforceValue()),
|
|
40
|
+
];
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Load many entities where fieldName equals fieldValue.
|
|
45
|
+
* @param fieldName - entity field being queried
|
|
46
|
+
* @param fieldValue - fieldName field value being queried
|
|
47
|
+
* @returns array of entities that match the query for fieldValue
|
|
24
48
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
25
49
|
*/
|
|
26
50
|
async loadManyByFieldEqualingAsync(fieldName, fieldValue) {
|
|
@@ -28,24 +52,55 @@ class EnforcingEntityLoader {
|
|
|
28
52
|
return entityResults.map((result) => result.enforceValue());
|
|
29
53
|
}
|
|
30
54
|
/**
|
|
31
|
-
*
|
|
55
|
+
* Load many entities where compositeField equals compositeFieldValue.
|
|
56
|
+
* @param compositeField - composite field being queried
|
|
57
|
+
* @param compositeFieldValue - compositeField value being queried
|
|
58
|
+
* @returns array of entities that match the query for compositeFieldValue
|
|
59
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
60
|
+
*/
|
|
61
|
+
async loadManyByCompositeFieldEqualingAsync(compositeField, compositeFieldValue) {
|
|
62
|
+
const entityResults = await this.entityLoader.loadManyByCompositeFieldEqualingAsync(compositeField, compositeFieldValue);
|
|
63
|
+
return entityResults.map((result) => result.enforceValue());
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Load an entity where fieldName equals fieldValue, or null if no entity exists.
|
|
67
|
+
* @param uniqueFieldName - entity field being queried
|
|
68
|
+
* @param fieldValue - uniqueFieldName field value being queried
|
|
69
|
+
* @returns entity where uniqueFieldName equals fieldValue, or null if no entity matches the condition.
|
|
70
|
+
* @throws when multiple entities match the condition
|
|
32
71
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
33
|
-
* @throws when multiple entities are found matching the condition
|
|
34
72
|
*/
|
|
35
73
|
async loadByFieldEqualingAsync(uniqueFieldName, fieldValue) {
|
|
36
74
|
const entityResult = await this.entityLoader.loadByFieldEqualingAsync(uniqueFieldName, fieldValue);
|
|
37
75
|
return entityResult ? entityResult.enforceValue() : null;
|
|
38
76
|
}
|
|
39
77
|
/**
|
|
40
|
-
*
|
|
78
|
+
* Load an entity where compositeField equals compositeFieldValue, or null if no entity exists.
|
|
79
|
+
* @param compositeField - composite field being queried
|
|
80
|
+
* @param compositeFieldValue - compositeField value being queried
|
|
81
|
+
* @returns entity where compositeField equals compositeFieldValue, or null if no entity matches the condition.
|
|
82
|
+
* @throws when multiple entities match the condition
|
|
83
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
84
|
+
*/
|
|
85
|
+
async loadByCompositeFieldEqualingAsync(compositeField, compositeFieldValue) {
|
|
86
|
+
const entityResult = await this.entityLoader.loadByCompositeFieldEqualingAsync(compositeField, compositeFieldValue);
|
|
87
|
+
return entityResult ? entityResult.enforceValue() : null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Loads an entity by a specified ID.
|
|
91
|
+
* @param id - ID of the entity
|
|
92
|
+
* @returns entity matching ID
|
|
41
93
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
94
|
+
* @throws EntityNotFoundError when no entity exists for ID
|
|
42
95
|
*/
|
|
43
96
|
async loadByIDAsync(id) {
|
|
44
97
|
const entityResult = await this.entityLoader.loadByIDAsync(id);
|
|
45
98
|
return entityResult.enforceValue();
|
|
46
99
|
}
|
|
47
100
|
/**
|
|
48
|
-
*
|
|
101
|
+
* Load an entity by a specified ID, or return null if non-existent.
|
|
102
|
+
* @param id - ID of the entity
|
|
103
|
+
* @returns entity for matching ID, or null if no entity exists for ID.
|
|
49
104
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
50
105
|
* @throws when multiple entities are found matching the condition
|
|
51
106
|
*/
|
|
@@ -54,15 +109,20 @@ class EnforcingEntityLoader {
|
|
|
54
109
|
return entityResult ? entityResult.enforceValue() : null;
|
|
55
110
|
}
|
|
56
111
|
/**
|
|
57
|
-
*
|
|
112
|
+
* Loads many entities for a list of IDs.
|
|
113
|
+
* @param ids - IDs of the entities to load
|
|
114
|
+
* @returns map from ID to corresponding entity result, where result error can be UnauthorizedError or EntityNotFoundError.
|
|
58
115
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
116
|
+
* @throws EntityNotFoundError when no entity exists for one or more of the IDs
|
|
59
117
|
*/
|
|
60
118
|
async loadManyByIDsAsync(ids) {
|
|
61
119
|
const entityResults = await this.entityLoader.loadManyByIDsAsync(ids);
|
|
62
120
|
return (0, maps_1.mapMap)(entityResults, (result) => result.enforceValue());
|
|
63
121
|
}
|
|
64
122
|
/**
|
|
65
|
-
*
|
|
123
|
+
* Loads many entities for a list of IDs, returning null for any IDs that are non-existent.
|
|
124
|
+
* @param ids - IDs of the entities to load
|
|
125
|
+
* @returns map from ID to nullable corresponding entity
|
|
66
126
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
67
127
|
*/
|
|
68
128
|
async loadManyByIDsNullableAsync(ids) {
|
|
@@ -70,15 +130,36 @@ class EnforcingEntityLoader {
|
|
|
70
130
|
return (0, maps_1.mapMap)(entityResults, (result) => result?.enforceValue() ?? null);
|
|
71
131
|
}
|
|
72
132
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
133
|
+
* Loads the first entity matching the selection constructed from the conjunction of specified
|
|
134
|
+
* operands, or null if no matching entity exists. Entities loaded using this method are not
|
|
135
|
+
* batched or cached.
|
|
136
|
+
*
|
|
137
|
+
* This is a convenience method for {@link loadManyByFieldEqualityConjunctionAsync}. However, the
|
|
138
|
+
* `orderBy` option must be specified to define what "first" means. If ordering doesn't matter,
|
|
139
|
+
* explicitly pass in an empty array.
|
|
140
|
+
*
|
|
141
|
+
* @param fieldEqualityOperands - list of field equality selection operand specifications
|
|
142
|
+
* @param querySelectionModifiers - orderBy and optional offset for the query
|
|
143
|
+
* @returns the first entity that matches the query or null if no entity matches the query
|
|
144
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
75
145
|
*/
|
|
76
146
|
async loadFirstByFieldEqualityConjunctionAsync(fieldEqualityOperands, querySelectionModifiers) {
|
|
77
147
|
const entityResult = await this.entityLoader.loadFirstByFieldEqualityConjunctionAsync(fieldEqualityOperands, querySelectionModifiers);
|
|
78
148
|
return entityResult ? entityResult.enforceValue() : null;
|
|
79
149
|
}
|
|
80
150
|
/**
|
|
81
|
-
*
|
|
151
|
+
* Loads many entities matching the selection constructed from the conjunction of specified operands.
|
|
152
|
+
* Entities loaded using this method are not batched or cached.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* fieldEqualityOperands:
|
|
156
|
+
* `[{fieldName: 'hello', fieldValue: 1}, {fieldName: 'world', fieldValues: [2, 3]}]`
|
|
157
|
+
* Entities returned with a SQL EntityDatabaseAdapter:
|
|
158
|
+
* `WHERE hello = 1 AND world = ANY({2, 3})`
|
|
159
|
+
*
|
|
160
|
+
* @param fieldEqualityOperands - list of field equality selection operand specifications
|
|
161
|
+
* @param querySelectionModifiers - limit, offset, and orderBy for the query
|
|
162
|
+
* @returns array of entities that match the query
|
|
82
163
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
83
164
|
*/
|
|
84
165
|
async loadManyByFieldEqualityConjunctionAsync(fieldEqualityOperands, querySelectionModifiers = {}) {
|
|
@@ -86,8 +167,28 @@ class EnforcingEntityLoader {
|
|
|
86
167
|
return entityResults.map((result) => result.enforceValue());
|
|
87
168
|
}
|
|
88
169
|
/**
|
|
89
|
-
*
|
|
170
|
+
* Loads many entities matching the raw WHERE clause. Corresponds to the knex `whereRaw` argument format.
|
|
171
|
+
*
|
|
172
|
+
* @remarks
|
|
173
|
+
* Important notes:
|
|
174
|
+
* - Fields in clause are database column names instead of transformed entity field names.
|
|
175
|
+
* - Entities loaded using this method are not batched or cached.
|
|
176
|
+
* - Not all database adapters implement the ability to execute this method of fetching entities.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* rawWhereClause: `id = ?`
|
|
180
|
+
* bindings: `[1]`
|
|
181
|
+
* Entites returned `WHERE id = 1`
|
|
182
|
+
*
|
|
183
|
+
* http://knexjs.org/#Builder-whereRaw
|
|
184
|
+
* http://knexjs.org/#Raw-Bindings
|
|
185
|
+
*
|
|
186
|
+
* @param rawWhereClause - parameterized SQL WHERE clause with positional binding placeholders or named binding placeholders
|
|
187
|
+
* @param bindings - array of positional bindings or object of named bindings
|
|
188
|
+
* @param querySelectionModifiers - limit, offset, orderBy, and orderByRaw for the query
|
|
189
|
+
* @returns array of entities that match the query
|
|
90
190
|
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
191
|
+
* @throws Error when rawWhereClause or bindings are invalid
|
|
91
192
|
*/
|
|
92
193
|
async loadManyByRawWhereClauseAsync(rawWhereClause, bindings, querySelectionModifiers = {}) {
|
|
93
194
|
const entityResults = await this.entityLoader.loadManyByRawWhereClauseAsync(rawWhereClause, bindings, querySelectionModifiers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnforcingEntityLoader.js","sourceRoot":"","sources":["../src/EnforcingEntityLoader.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"EnforcingEntityLoader.js","sourceRoot":"","sources":["../src/EnforcingEntityLoader.ts"],"names":[],"mappings":";;AAUA,0EAA4E;AAC5E,8EAA2E;AAC3E,mDAAkD;AAElD;;;;GAIG;AACH,MAAqB,qBAAqB;IAerB;IADnB,YACmB,YAOhB;QAPgB,iBAAY,GAAZ,YAAY,CAO5B;IACA,CAAC;IAEJ;;;;;;OAMG;IACH,KAAK,CAAC,gCAAgC,CACpC,SAAY,EACZ,WAA+C;QAE/C,MA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,EACR,uBAAuB,CACxB,CAAC;QACF,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF;AAnSD,wCAmSC"}
|
|
@@ -6,9 +6,9 @@ import ViewerContext from './ViewerContext';
|
|
|
6
6
|
* Enforcing entity updater. All updates
|
|
7
7
|
* through this updater will throw if authorization is not successful.
|
|
8
8
|
*/
|
|
9
|
-
export default class EnforcingEntityUpdater<TFields extends
|
|
9
|
+
export default class EnforcingEntityUpdater<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
|
|
10
10
|
private readonly entityUpdater;
|
|
11
|
-
constructor(entityUpdater: AuthorizationResultBasedUpdateMutator<TFields,
|
|
11
|
+
constructor(entityUpdater: AuthorizationResultBasedUpdateMutator<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>);
|
|
12
12
|
/**
|
|
13
13
|
* Set the value for entity field.
|
|
14
14
|
* @param fieldName - entity field being updated
|
package/build/Entity.d.ts
CHANGED
|
@@ -25,57 +25,57 @@ import ViewerContext from './ViewerContext';
|
|
|
25
25
|
* All concrete entity implementations should extend this class and provide their
|
|
26
26
|
* own EntityCompanionDefinition.
|
|
27
27
|
*/
|
|
28
|
-
export default abstract class Entity<TFields extends
|
|
28
|
+
export default abstract class Entity<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TSelectedFields extends keyof TFields = keyof TFields> extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields> {
|
|
29
29
|
/**
|
|
30
30
|
* Vend mutator for creating a new entity in given query context.
|
|
31
31
|
* @param viewerContext - viewer context of creating user
|
|
32
32
|
* @param queryContext - query context in which to perform the create
|
|
33
33
|
* @returns mutator for creating an entity
|
|
34
34
|
*/
|
|
35
|
-
static creator<TMFields extends object,
|
|
35
|
+
static creator<TMFields extends object, TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMIDField, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, viewerContext: TMViewerContext2, queryContext?: EntityQueryContext): EnforcingEntityCreator<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
|
|
36
36
|
/**
|
|
37
37
|
* Vend mutator for creating a new entity in given query context.
|
|
38
38
|
* @param viewerContext - viewer context of creating user
|
|
39
39
|
* @param queryContext - query context in which to perform the create
|
|
40
40
|
* @returns mutator for creating an entity
|
|
41
41
|
*/
|
|
42
|
-
static creatorWithAuthorizationResults<TMFields extends object,
|
|
42
|
+
static creatorWithAuthorizationResults<TMFields extends object, TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMIDField, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, viewerContext: TMViewerContext2, queryContext?: EntityQueryContext): AuthorizationResultBasedCreateMutator<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
|
|
43
43
|
/**
|
|
44
44
|
* Vend mutator for updating an existing entity in given query context.
|
|
45
45
|
* @param existingEntity - entity to update
|
|
46
46
|
* @param queryContext - query context in which to perform the update
|
|
47
47
|
* @returns mutator for updating existingEntity
|
|
48
48
|
*/
|
|
49
|
-
static updater<TMFields extends object,
|
|
49
|
+
static updater<TMFields extends object, TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMIDField, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): EnforcingEntityUpdater<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
|
|
50
50
|
/**
|
|
51
51
|
* Vend mutator for updating an existing entity in given query context.
|
|
52
52
|
* @param existingEntity - entity to update
|
|
53
53
|
* @param queryContext - query context in which to perform the update
|
|
54
54
|
* @returns mutator for updating existingEntity
|
|
55
55
|
*/
|
|
56
|
-
static updaterWithAuthorizationResults<TMFields extends object,
|
|
56
|
+
static updaterWithAuthorizationResults<TMFields extends object, TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMIDField, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): AuthorizationResultBasedUpdateMutator<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
|
|
57
57
|
/**
|
|
58
58
|
* Vend mutator for deleting an existing entity in given query context.
|
|
59
59
|
* @param existingEntity - entity to delete
|
|
60
60
|
* @param queryContext - query context in which to perform the delete
|
|
61
61
|
* @returns mutator for deleting existingEntity
|
|
62
62
|
*/
|
|
63
|
-
static deleter<TMFields extends object,
|
|
63
|
+
static deleter<TMFields extends object, TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMIDField, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): EnforcingEntityDeleter<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
|
|
64
64
|
/**
|
|
65
65
|
* Vend mutator for deleting an existing entity in given query context.
|
|
66
66
|
* @param existingEntity - entity to delete
|
|
67
67
|
* @param queryContext - query context in which to perform the delete
|
|
68
68
|
* @returns mutator for deleting existingEntity
|
|
69
69
|
*/
|
|
70
|
-
static deleterWithAuthorizationResults<TMFields extends object,
|
|
70
|
+
static deleterWithAuthorizationResults<TMFields extends object, TMIDField extends keyof NonNullable<Pick<TMFields, TMSelectedFields>>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMIDField, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMIDField, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): AuthorizationResultBasedDeleteMutator<TMFields, TMIDField, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* An interface to pass in constructor (class) of an Entity as a function argument.
|
|
74
74
|
*/
|
|
75
|
-
export interface IEntityClass<TFields extends
|
|
75
|
+
export interface IEntityClass<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields = keyof TFields> {
|
|
76
76
|
new (constructorParam: {
|
|
77
77
|
viewerContext: TViewerContext;
|
|
78
|
-
id:
|
|
78
|
+
id: TFields[TIDField];
|
|
79
79
|
databaseFields: Readonly<TFields>;
|
|
80
80
|
selectedFields: Readonly<Pick<TFields, TSelectedFields>>;
|
|
81
81
|
}): TEntity;
|
|
@@ -84,5 +84,5 @@ export interface IEntityClass<TFields extends object, TID extends NonNullable<TF
|
|
|
84
84
|
*
|
|
85
85
|
* Memoized by the entity framework.
|
|
86
86
|
*/
|
|
87
|
-
defineCompanionDefinition(): EntityCompanionDefinition<TFields,
|
|
87
|
+
defineCompanionDefinition(): EntityCompanionDefinition<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
|
88
88
|
}
|
package/build/Entity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.js","sourceRoot":"","sources":["../src/Entity.ts"],"names":[],"mappings":";;;;;AASA,oEAA4C;AAC5C,oEAA4C;AAG5C,oEAA4C;AAC5C,sEAA8C;AAG9C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAA8B,MAK5B,SAAQ,
|
|
1
|
+
{"version":3,"file":"Entity.js","sourceRoot":"","sources":["../src/Entity.ts"],"names":[],"mappings":";;;;;AASA,oEAA4C;AAC5C,oEAA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AAc;SAC9C,gBAAgB,EAAE;SAClB,sCAAsC,CAAC,IAAI,CAAC;SAC5C,uBAAuB,EAAE;SACzB,eAAe,EAAE;QASpB,OAAO,IAAI,uBAAa,CAAC,cAAc,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC3E,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,+BAA+B,CAsBpC,cAAwB,EACxB,eAAmC,cAAc;SAC9C,gBAAgB,EAAE;SAClB,sCAAsC,CAAC,IAAI,CAAC;SAC5C,uBAAuB,EAAE;SACzB,eAAe,EAAE;QASpB,OAAO,IAAI,uBAAa,CAAC,cAAc,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,wBAAwB,EAAE,CAAC;IAC1F,CAAC;CACF;AAnRD,yBAmRC"}
|
|
@@ -8,7 +8,7 @@ import ViewerContext from './ViewerContext';
|
|
|
8
8
|
* associated with an entity. In relational databases, these entities are often referenced
|
|
9
9
|
* by foreign keys.
|
|
10
10
|
*/
|
|
11
|
-
export default class EntityAssociationLoader<TFields extends
|
|
11
|
+
export default class EntityAssociationLoader<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TSelectedFields extends keyof TFields> {
|
|
12
12
|
private readonly entity;
|
|
13
13
|
private readonly queryContext;
|
|
14
14
|
constructor(entity: TEntity, queryContext?: EntityQueryContext);
|
|
@@ -17,11 +17,11 @@ export default class EntityAssociationLoader<TFields extends object, TID extends
|
|
|
17
17
|
* guaranteed to be the values of successful results (or null for some loader methods),
|
|
18
18
|
* and will throw otherwise.
|
|
19
19
|
*/
|
|
20
|
-
enforcing(): EnforcingEntityAssociationLoader<TFields,
|
|
20
|
+
enforcing(): EnforcingEntityAssociationLoader<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>;
|
|
21
21
|
/**
|
|
22
22
|
* Authorization-result-based entity loader. All loads through this
|
|
23
23
|
* loader are results, where an unsuccessful result
|
|
24
24
|
* means an authorization error or entity construction error occurred. Other errors are thrown.
|
|
25
25
|
*/
|
|
26
|
-
withAuthorizationResults(): AuthorizationResultBasedEntityAssociationLoader<TFields,
|
|
26
|
+
withAuthorizationResults(): AuthorizationResultBasedEntityAssociationLoader<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>;
|
|
27
27
|
}
|
|
@@ -13,17 +13,17 @@ export interface IPrivacyPolicyClass<TPrivacyPolicy> {
|
|
|
13
13
|
/**
|
|
14
14
|
* Composition root responsible for orchestrating setup of Entity mutators and loaders.
|
|
15
15
|
*/
|
|
16
|
-
export default class EntityCompanion<TFields extends
|
|
16
|
+
export default class EntityCompanion<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
|
|
17
17
|
readonly entityCompanionProvider: EntityCompanionProvider;
|
|
18
|
-
readonly entityCompanionDefinition: EntityCompanionDefinition<TFields,
|
|
18
|
+
readonly entityCompanionDefinition: EntityCompanionDefinition<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
|
19
19
|
private readonly tableDataCoordinator;
|
|
20
20
|
private readonly metricsAdapter;
|
|
21
21
|
readonly privacyPolicy: TPrivacyPolicy;
|
|
22
22
|
private readonly entityLoaderFactory;
|
|
23
23
|
private readonly entityMutatorFactory;
|
|
24
|
-
constructor(entityCompanionProvider: EntityCompanionProvider, entityCompanionDefinition: EntityCompanionDefinition<TFields,
|
|
25
|
-
getLoaderFactory(): EntityLoaderFactory<TFields,
|
|
26
|
-
getMutatorFactory(): EntityMutatorFactory<TFields,
|
|
24
|
+
constructor(entityCompanionProvider: EntityCompanionProvider, entityCompanionDefinition: EntityCompanionDefinition<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>, tableDataCoordinator: EntityTableDataCoordinator<TFields, TIDField>, metricsAdapter: IEntityMetricsAdapter);
|
|
25
|
+
getLoaderFactory(): EntityLoaderFactory<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
|
26
|
+
getMutatorFactory(): EntityMutatorFactory<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
|
27
27
|
/**
|
|
28
28
|
* Get the query context provider for this entity.
|
|
29
29
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityCompanion.js","sourceRoot":"","sources":["../src/EntityCompanion.ts"],"names":[],"mappings":";;;;;AACA,gFAAwD;AACxD,kFAA0D;AAO1D,+GAA4G;AAM5G;;GAEG;AACH,MAAqB,eAAe;IAkChB;IACA;IAQC;IACA;IA9BH,aAAa,CAAiB;IAE7B,mBAAmB,CAOlC;IACe,oBAAoB,CAOnC;IAEF,YACkB,uBAAgD,EAChD,yBAOf,EACgB,
|
|
1
|
+
{"version":3,"file":"EntityCompanion.js","sourceRoot":"","sources":["../src/EntityCompanion.ts"],"names":[],"mappings":";;;;;AACA,gFAAwD;AACxD,kFAA0D;AAO1D,+GAA4G;AAM5G;;GAEG;AACH,MAAqB,eAAe;IAkChB;IACA;IAQC;IACA;IA9BH,aAAa,CAAiB;IAE7B,mBAAmB,CAOlC;IACe,oBAAoB,CAOnC;IAEF,YACkB,uBAAgD,EAChD,yBAOf,EACgB,oBAAmE,EACnE,cAAqC;QAVtC,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,8BAAyB,GAAzB,yBAAyB,CAOxC;QACgB,yBAAoB,GAApB,oBAAoB,CAA+C;QACnE,mBAAc,GAAd,cAAc,CAAuB;QAEtD,IAAI,CAAC,aAAa,GAAG,IAAI,yBAAyB,CAAC,kBAAkB,EAAE,CAAC;QACxE,IAAI,CAAC,mBAAmB,GAAG,IAAI,6BAAmB,CAOhD,IAAI,EAAE,oBAAoB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAC1D,IAAI,CAAC,oBAAoB,GAAG,IAAI,8BAAoB,CAClD,uBAAuB,EACvB,oBAAoB,CAAC,mBAAmB,EACxC,yBAAyB,CAAC,WAAW,EACrC,IAAI,CAAC,aAAa,EAClB,yBAAyB,CAAC,kBAAkB,IAAI,EAAE,EAClD,IAAA,mFAAwC,EACtC,yBAAyB,CAAC,gBAAgB,IAAI,EAAE,EAChD,uBAAuB,CAAC,sBAAsB,IAAI,EAAE,CACrD,EACD,IAAI,CAAC,mBAAmB,EACxB,oBAAoB,CAAC,eAAe,EACpC,cAAc,CACf,CAAC;IACJ,CAAC;IAED,gBAAgB;QAQd,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IAED,iBAAiB;QAQf,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,uBAAuB;QACrB,OAAO,IAAI,CAAC,oBAAoB,CAAC,uBAAuB,EAAE,CAAC;IAC7D,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;CACF;AA1GD,kCA0GC"}
|
|
@@ -40,15 +40,15 @@ export interface CacheAdapterFlavorDefinition {
|
|
|
40
40
|
* Definition for constructing a companion for an entity. Defines the core set of objects
|
|
41
41
|
* used to power the entity framework for a particular type of entity.
|
|
42
42
|
*/
|
|
43
|
-
export interface EntityCompanionDefinition<TFields extends
|
|
43
|
+
export interface EntityCompanionDefinition<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields = keyof TFields> {
|
|
44
44
|
/**
|
|
45
45
|
* The concrete Entity class for which this is the definition.
|
|
46
46
|
*/
|
|
47
|
-
readonly entityClass: IEntityClass<TFields,
|
|
47
|
+
readonly entityClass: IEntityClass<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
|
48
48
|
/**
|
|
49
49
|
* The EntityConfiguration for this entity.
|
|
50
50
|
*/
|
|
51
|
-
readonly entityConfiguration: EntityConfiguration<TFields>;
|
|
51
|
+
readonly entityConfiguration: EntityConfiguration<TFields, TIDField>;
|
|
52
52
|
/**
|
|
53
53
|
* The EntityPrivacyPolicy class for this entity.
|
|
54
54
|
*/
|
|
@@ -56,11 +56,11 @@ export interface EntityCompanionDefinition<TFields extends object, TID extends N
|
|
|
56
56
|
/**
|
|
57
57
|
* An optional list of EntityMutationValidator for this entity.
|
|
58
58
|
*/
|
|
59
|
-
readonly mutationValidators?: EntityMutationValidator<TFields,
|
|
59
|
+
readonly mutationValidators?: EntityMutationValidator<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>[];
|
|
60
60
|
/**
|
|
61
61
|
* An optional list of EntityMutationTrigger for this entity.
|
|
62
62
|
*/
|
|
63
|
-
readonly mutationTriggers?: EntityMutationTriggerConfiguration<TFields,
|
|
63
|
+
readonly mutationTriggers?: EntityMutationTriggerConfiguration<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>;
|
|
64
64
|
/**
|
|
65
65
|
* An optional subset of fields defined in the EntityConfiguration which belong to this entity.
|
|
66
66
|
* For use when multiple types of entities are backed by a single table (EntityConfiguration) yet
|
|
@@ -99,7 +99,7 @@ export default class EntityCompanionProvider {
|
|
|
99
99
|
*
|
|
100
100
|
* @param entityClass - entity class to load
|
|
101
101
|
*/
|
|
102
|
-
getCompanionForEntity<TFields extends
|
|
102
|
+
getCompanionForEntity<TFields extends Record<string, any>, TIDField extends keyof NonNullable<Pick<TFields, TSelectedFields>>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TIDField, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields>(entityClass: IEntityClass<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>): EntityCompanion<TFields, TIDField, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
|
103
103
|
getQueryContextProviderForDatabaseAdaptorFlavor(databaseAdapterFlavor: DatabaseAdapterFlavor): EntityQueryContextProvider;
|
|
104
104
|
private getTableDataCoordinatorForEntity;
|
|
105
105
|
}
|