@expo/entity 0.60.0 → 0.62.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/src/AuthorizationResultBasedEntityAssociationLoader.d.ts +6 -6
- package/build/src/AuthorizationResultBasedEntityAssociationLoader.js +5 -10
- package/build/src/AuthorizationResultBasedEntityLoader.d.ts +9 -9
- package/build/src/AuthorizationResultBasedEntityLoader.js +27 -35
- package/build/src/AuthorizationResultBasedEntityMutator.d.ts +13 -13
- package/build/src/AuthorizationResultBasedEntityMutator.js +54 -65
- package/build/src/ComposedEntityCacheAdapter.d.ts +3 -3
- package/build/src/ComposedEntityCacheAdapter.js +15 -23
- package/build/src/ComposedSecondaryEntityCache.d.ts +1 -1
- package/build/src/ComposedSecondaryEntityCache.js +4 -12
- package/build/src/EnforcingEntityAssociationLoader.d.ts +5 -5
- package/build/src/EnforcingEntityAssociationLoader.js +6 -11
- package/build/src/EnforcingEntityCreator.d.ts +4 -4
- package/build/src/EnforcingEntityCreator.js +3 -8
- package/build/src/EnforcingEntityDeleter.d.ts +4 -4
- package/build/src/EnforcingEntityDeleter.js +3 -8
- package/build/src/EnforcingEntityLoader.d.ts +5 -5
- package/build/src/EnforcingEntityLoader.js +9 -14
- package/build/src/EnforcingEntityUpdater.d.ts +4 -4
- package/build/src/EnforcingEntityUpdater.js +3 -8
- package/build/src/Entity.d.ts +9 -9
- package/build/src/Entity.js +11 -16
- package/build/src/EntityAssociationLoader.d.ts +5 -5
- package/build/src/EntityAssociationLoader.js +5 -10
- package/build/src/EntityCompanion.d.ts +9 -9
- package/build/src/EntityCompanion.js +6 -11
- package/build/src/EntityCompanionProvider.d.ts +13 -12
- package/build/src/EntityCompanionProvider.js +13 -21
- package/build/src/EntityConfiguration.d.ts +4 -4
- package/build/src/EntityConfiguration.js +14 -23
- package/build/src/EntityConstructionUtils.d.ts +8 -8
- package/build/src/EntityConstructionUtils.js +15 -23
- package/build/src/EntityCreator.d.ts +7 -7
- package/build/src/EntityCreator.js +3 -8
- package/build/src/EntityDatabaseAdapter.d.ts +4 -4
- package/build/src/EntityDatabaseAdapter.js +19 -27
- package/build/src/EntityDeleter.d.ts +7 -7
- package/build/src/EntityDeleter.js +3 -8
- package/build/src/EntityFieldDefinition.d.ts +4 -4
- package/build/src/EntityFieldDefinition.js +5 -10
- package/build/src/EntityFields.d.ts +2 -1
- package/build/src/EntityFields.js +12 -27
- package/build/src/EntityInvalidationUtils.d.ts +8 -10
- package/build/src/EntityInvalidationUtils.js +5 -10
- package/build/src/EntityLoader.d.ts +7 -7
- package/build/src/EntityLoader.js +3 -8
- package/build/src/EntityLoaderFactory.d.ts +11 -11
- package/build/src/EntityLoaderFactory.js +7 -12
- package/build/src/EntityMutationInfo.d.ts +2 -2
- package/build/src/EntityMutationInfo.js +2 -6
- package/build/src/EntityMutationTriggerConfiguration.d.ts +4 -4
- package/build/src/EntityMutationTriggerConfiguration.js +2 -8
- package/build/src/EntityMutationValidatorConfiguration.d.ts +4 -4
- package/build/src/EntityMutationValidatorConfiguration.js +1 -6
- package/build/src/EntityMutatorFactory.d.ts +13 -13
- package/build/src/EntityMutatorFactory.js +5 -10
- package/build/src/EntityPrivacyPolicy.d.ts +7 -7
- package/build/src/EntityPrivacyPolicy.js +22 -27
- package/build/src/EntityQueryContext.d.ts +1 -1
- package/build/src/EntityQueryContext.js +11 -22
- package/build/src/EntityQueryContextProvider.d.ts +2 -1
- package/build/src/EntityQueryContextProvider.js +7 -12
- package/build/src/EntitySecondaryCacheLoader.d.ts +7 -7
- package/build/src/EntitySecondaryCacheLoader.js +4 -9
- package/build/src/EntityUpdater.d.ts +7 -7
- package/build/src/EntityUpdater.js +3 -8
- package/build/src/GenericEntityCacheAdapter.d.ts +4 -4
- package/build/src/GenericEntityCacheAdapter.js +5 -13
- package/build/src/GenericSecondaryEntityCache.d.ts +2 -2
- package/build/src/GenericSecondaryEntityCache.js +10 -18
- package/build/src/IEntityCacheAdapter.d.ts +2 -2
- package/build/src/IEntityCacheAdapter.js +1 -3
- package/build/src/IEntityCacheAdapterProvider.d.ts +2 -2
- package/build/src/IEntityCacheAdapterProvider.js +1 -3
- package/build/src/IEntityDatabaseAdapterProvider.d.ts +2 -2
- package/build/src/IEntityDatabaseAdapterProvider.js +1 -3
- package/build/src/IEntityGenericCacher.d.ts +2 -2
- package/build/src/IEntityGenericCacher.js +1 -3
- package/build/src/ReadonlyEntity.d.ts +10 -10
- package/build/src/ReadonlyEntity.js +9 -17
- package/build/src/ViewerContext.d.ts +6 -6
- package/build/src/ViewerContext.js +3 -8
- package/build/src/ViewerScopedEntityCompanion.d.ts +8 -8
- package/build/src/ViewerScopedEntityCompanion.js +5 -10
- package/build/src/ViewerScopedEntityCompanionProvider.d.ts +6 -6
- package/build/src/ViewerScopedEntityCompanionProvider.js +3 -8
- package/build/src/ViewerScopedEntityLoaderFactory.d.ts +9 -9
- package/build/src/ViewerScopedEntityLoaderFactory.js +1 -6
- package/build/src/ViewerScopedEntityMutatorFactory.d.ts +7 -7
- package/build/src/ViewerScopedEntityMutatorFactory.js +1 -6
- package/build/src/entityUtils.d.ts +1 -1
- package/build/src/entityUtils.js +9 -21
- package/build/src/errors/EntityCacheAdapterError.d.ts +1 -1
- package/build/src/errors/EntityCacheAdapterError.js +5 -11
- package/build/src/errors/EntityDatabaseAdapterError.d.ts +1 -1
- package/build/src/errors/EntityDatabaseAdapterError.js +41 -59
- package/build/src/errors/EntityError.js +5 -10
- package/build/src/errors/EntityInvalidFieldValueError.d.ts +5 -5
- package/build/src/errors/EntityInvalidFieldValueError.js +4 -9
- package/build/src/errors/EntityNotAuthorizedError.d.ts +4 -4
- package/build/src/errors/EntityNotAuthorizedError.js +6 -11
- package/build/src/errors/EntityNotFoundError.d.ts +5 -5
- package/build/src/errors/EntityNotFoundError.js +4 -9
- package/build/src/index.d.ts +77 -77
- package/build/src/index.js +77 -94
- package/build/src/internal/CompositeFieldHolder.d.ts +3 -2
- package/build/src/internal/CompositeFieldHolder.js +11 -21
- package/build/src/internal/CompositeFieldValueMap.d.ts +2 -2
- package/build/src/internal/CompositeFieldValueMap.js +7 -12
- package/build/src/internal/EntityDataManager.d.ts +6 -6
- package/build/src/internal/EntityDataManager.js +25 -33
- package/build/src/internal/EntityFieldTransformationUtils.d.ts +1 -1
- package/build/src/internal/EntityFieldTransformationUtils.js +11 -23
- package/build/src/internal/EntityLoadInterfaces.d.ts +3 -2
- package/build/src/internal/EntityLoadInterfaces.js +4 -9
- package/build/src/internal/EntityTableDataCoordinator.d.ts +8 -8
- package/build/src/internal/EntityTableDataCoordinator.js +4 -9
- package/build/src/internal/ReadThroughEntityCache.d.ts +3 -3
- package/build/src/internal/ReadThroughEntityCache.js +7 -15
- package/build/src/internal/SingleFieldHolder.d.ts +3 -2
- package/build/src/internal/SingleFieldHolder.js +9 -19
- package/build/src/metrics/EntityMetricsUtils.d.ts +3 -3
- package/build/src/metrics/EntityMetricsUtils.js +6 -14
- package/build/src/metrics/IEntityMetricsAdapter.d.ts +2 -2
- package/build/src/metrics/IEntityMetricsAdapter.js +8 -12
- package/build/src/metrics/NoOpEntityMetricsAdapter.d.ts +1 -1
- package/build/src/metrics/NoOpEntityMetricsAdapter.js +1 -6
- package/build/src/rules/AllowIfAllSubRulesAllowPrivacyPolicyRule.d.ts +5 -5
- package/build/src/rules/AllowIfAllSubRulesAllowPrivacyPolicyRule.js +5 -10
- package/build/src/rules/AllowIfAnySubRuleAllowsPrivacyPolicyRule.d.ts +5 -5
- package/build/src/rules/AllowIfAnySubRuleAllowsPrivacyPolicyRule.js +5 -10
- package/build/src/rules/AllowIfInParentCascadeDeletionPrivacyPolicyRule.d.ts +6 -6
- package/build/src/rules/AllowIfInParentCascadeDeletionPrivacyPolicyRule.js +6 -11
- package/build/src/rules/AlwaysAllowPrivacyPolicyRule.d.ts +5 -5
- package/build/src/rules/AlwaysAllowPrivacyPolicyRule.js +3 -8
- package/build/src/rules/AlwaysDenyPrivacyPolicyRule.d.ts +5 -5
- package/build/src/rules/AlwaysDenyPrivacyPolicyRule.js +3 -8
- package/build/src/rules/AlwaysSkipPrivacyPolicyRule.d.ts +5 -5
- package/build/src/rules/AlwaysSkipPrivacyPolicyRule.js +3 -8
- package/build/src/rules/EvaluateIfEntityFieldPredicatePrivacyPolicyRule.d.ts +5 -5
- package/build/src/rules/EvaluateIfEntityFieldPredicatePrivacyPolicyRule.js +3 -8
- package/build/src/rules/PrivacyPolicyRule.d.ts +4 -4
- package/build/src/rules/PrivacyPolicyRule.js +3 -8
- package/build/src/utils/EntityCreationUtils.d.ts +5 -5
- package/build/src/utils/EntityCreationUtils.js +6 -11
- package/build/src/utils/EntityPrivacyUtils.d.ts +5 -5
- package/build/src/utils/EntityPrivacyUtils.js +20 -27
- package/build/src/utils/collections/SerializableKeyMap.js +1 -6
- package/build/src/utils/collections/maps.js +11 -27
- package/build/src/utils/collections/sets.js +1 -5
- package/build/src/utils/mergeEntityMutationTriggerConfigurations.d.ts +3 -3
- package/build/src/utils/mergeEntityMutationTriggerConfigurations.js +1 -5
- package/package.json +8 -7
- package/src/AuthorizationResultBasedEntityAssociationLoader.ts +7 -6
- package/src/AuthorizationResultBasedEntityLoader.ts +19 -17
- package/src/AuthorizationResultBasedEntityMutator.ts +24 -22
- package/src/ComposedEntityCacheAdapter.ts +5 -4
- package/src/ComposedSecondaryEntityCache.ts +2 -2
- package/src/EnforcingEntityAssociationLoader.ts +7 -7
- package/src/EnforcingEntityCreator.ts +4 -4
- package/src/EnforcingEntityDeleter.ts +4 -4
- package/src/EnforcingEntityLoader.ts +8 -8
- package/src/EnforcingEntityUpdater.ts +4 -4
- package/src/Entity.ts +13 -13
- package/src/EntityAssociationLoader.ts +6 -6
- package/src/EntityCompanion.ts +13 -10
- package/src/EntityCompanionProvider.ts +15 -14
- package/src/EntityConfiguration.ts +6 -8
- package/src/EntityConstructionUtils.ts +16 -12
- package/src/EntityCreator.ts +7 -7
- package/src/EntityDatabaseAdapter.ts +6 -6
- package/src/EntityDeleter.ts +7 -7
- package/src/EntityFieldDefinition.ts +4 -4
- package/src/EntityFields.ts +3 -3
- package/src/EntityInvalidationUtils.ts +8 -25
- package/src/EntityLoader.ts +7 -7
- package/src/EntityLoaderFactory.ts +13 -12
- package/src/EntityMutationInfo.ts +2 -2
- package/src/EntityMutationTriggerConfiguration.ts +4 -4
- package/src/EntityMutationValidatorConfiguration.ts +4 -4
- package/src/EntityMutatorFactory.ts +13 -13
- package/src/EntityPrivacyPolicy.ts +9 -10
- package/src/EntityQueryContext.ts +1 -1
- package/src/EntityQueryContextProvider.ts +2 -2
- package/src/EntitySecondaryCacheLoader.ts +8 -8
- package/src/EntityUpdater.ts +7 -7
- package/src/GenericEntityCacheAdapter.ts +5 -5
- package/src/GenericSecondaryEntityCache.ts +4 -4
- package/src/IEntityCacheAdapter.ts +2 -2
- package/src/IEntityCacheAdapterProvider.ts +2 -2
- package/src/IEntityDatabaseAdapterProvider.ts +2 -2
- package/src/IEntityGenericCacher.ts +2 -2
- package/src/ReadonlyEntity.ts +12 -19
- package/src/ViewerContext.ts +8 -8
- package/src/ViewerScopedEntityCompanion.ts +8 -8
- package/src/ViewerScopedEntityCompanionProvider.ts +6 -6
- package/src/ViewerScopedEntityLoaderFactory.ts +11 -9
- package/src/ViewerScopedEntityMutatorFactory.ts +8 -8
- package/src/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.ts +6 -6
- package/src/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.ts +16 -15
- package/src/__tests__/AuthorizationResultBasedEntityLoader-test.ts +21 -21
- package/src/__tests__/ComposedCacheAdapter-test.ts +8 -7
- package/src/__tests__/ComposedSecondaryEntityCache-test.ts +3 -3
- package/src/__tests__/EnforcingEntityAssociationLoader-test.ts +2 -2
- package/src/__tests__/EnforcingEntityLoader-test.ts +4 -4
- package/src/__tests__/Entity-test.ts +8 -8
- package/src/__tests__/EntityAssociationLoader-test.ts +6 -6
- package/src/__tests__/EntityCommonUseCases-test.ts +17 -13
- package/src/__tests__/EntityCompanion-test.ts +11 -11
- package/src/__tests__/EntityCompanionProvider-test.ts +8 -7
- package/src/__tests__/EntityConfiguration-test.ts +3 -3
- package/src/__tests__/EntityDatabaseAdapter-test.ts +11 -7
- package/src/__tests__/EntityEdges-test.ts +17 -19
- package/src/__tests__/EntityFields-test.ts +3 -3
- package/src/__tests__/EntityLoader-test.ts +7 -7
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +12 -11
- package/src/__tests__/EntityMutator-SingleCompositeFieldCacheConsistency-test.ts +4 -4
- package/src/__tests__/EntityMutator-test.ts +32 -36
- package/src/__tests__/EntityPrivacyPolicy-test.ts +19 -19
- package/src/__tests__/EntityQueryContext-test.ts +9 -9
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +8 -7
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +12 -12
- package/src/__tests__/GenericEntityCacheAdapter-test.ts +6 -6
- package/src/__tests__/GenericSecondaryEntityCache-test.ts +16 -18
- package/src/__tests__/ReadonlyEntity-test.ts +10 -10
- package/src/__tests__/ViewerContext-test.ts +3 -3
- package/src/__tests__/ViewerScopedEntityCompanion-test.ts +7 -7
- package/src/__tests__/ViewerScopedEntityCompanionProvider-test.ts +5 -5
- package/src/__tests__/ViewerScopedEntityLoaderFactory-test.ts +5 -5
- package/src/__tests__/ViewerScopedEntityMutatorFactory-test.ts +6 -6
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +9 -9
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +8 -8
- package/src/__tests__/entityUtils-test.ts +4 -4
- package/src/entityUtils.ts +1 -1
- package/src/errors/EntityCacheAdapterError.ts +1 -1
- package/src/errors/EntityDatabaseAdapterError.ts +1 -1
- package/src/errors/EntityInvalidFieldValueError.ts +5 -5
- package/src/errors/EntityNotAuthorizedError.ts +4 -4
- package/src/errors/EntityNotFoundError.ts +5 -5
- package/src/errors/__tests__/EntityDatabaseAdapterError-test.ts +2 -2
- package/src/errors/__tests__/EntityError-test.ts +7 -7
- package/src/index.ts +77 -77
- package/src/internal/CompositeFieldHolder.ts +6 -10
- package/src/internal/CompositeFieldValueMap.ts +3 -5
- package/src/internal/EntityDataManager.ts +11 -14
- package/src/internal/EntityFieldTransformationUtils.ts +2 -2
- package/src/internal/EntityLoadInterfaces.ts +3 -2
- package/src/internal/EntityTableDataCoordinator.ts +9 -9
- package/src/internal/ReadThroughEntityCache.ts +4 -4
- package/src/internal/SingleFieldHolder.ts +4 -8
- package/src/internal/__tests__/CompositeFieldHolder-test.ts +1 -1
- package/src/internal/__tests__/CompositeFieldValueMap-test.ts +3 -3
- package/src/internal/__tests__/EntityDataManager-test.ts +15 -18
- package/src/internal/__tests__/EntityFieldTransformationUtils-test.ts +3 -3
- package/src/internal/__tests__/ReadThroughEntityCache-test.ts +6 -6
- package/src/metrics/EntityMetricsUtils.ts +5 -5
- package/src/metrics/IEntityMetricsAdapter.ts +3 -3
- package/src/metrics/NoOpEntityMetricsAdapter.ts +2 -2
- package/src/metrics/__tests__/EntityMetricsUtils-test.ts +4 -7
- package/src/rules/AllowIfAllSubRulesAllowPrivacyPolicyRule.ts +5 -5
- package/src/rules/AllowIfAnySubRuleAllowsPrivacyPolicyRule.ts +5 -5
- package/src/rules/AllowIfInParentCascadeDeletionPrivacyPolicyRule.ts +9 -6
- package/src/rules/AlwaysAllowPrivacyPolicyRule.ts +5 -5
- package/src/rules/AlwaysDenyPrivacyPolicyRule.ts +5 -5
- package/src/rules/AlwaysSkipPrivacyPolicyRule.ts +5 -5
- package/src/rules/EvaluateIfEntityFieldPredicatePrivacyPolicyRule.ts +5 -5
- package/src/rules/PrivacyPolicyRule.ts +4 -4
- package/src/rules/__tests__/AllowIfAllSubRulesAllowPrivacyPolicyRule-test.ts +8 -8
- package/src/rules/__tests__/AllowIfAnySubRuleAllowsPrivacyPolicyRule-test.ts +8 -8
- package/src/rules/__tests__/AllowIfInParentCascadeDeletionPrivacyPolicyRule-test.ts +7 -7
- package/src/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.ts +5 -5
- package/src/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.ts +5 -5
- package/src/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.ts +5 -5
- package/src/rules/__tests__/EvaluateIfEntityFieldPredicatePrivacyPolicyRule-test.ts +9 -8
- package/src/utils/EntityCreationUtils.ts +7 -7
- package/src/utils/EntityPrivacyUtils.ts +13 -9
- package/src/utils/__testfixtures__/PrivacyPolicyRuleTestUtils.ts +6 -5
- package/src/utils/__testfixtures__/SimpleTestEntity.ts +7 -7
- package/src/utils/__testfixtures__/StubCacheAdapter.ts +6 -5
- package/src/utils/__testfixtures__/StubDatabaseAdapter.ts +6 -6
- package/src/utils/__testfixtures__/StubDatabaseAdapterProvider.ts +4 -4
- package/src/utils/__testfixtures__/StubQueryContextProvider.ts +2 -2
- package/src/utils/__testfixtures__/TSMockitoExtensions.ts +5 -5
- package/src/utils/__testfixtures__/TestEntity.ts +9 -8
- package/src/utils/__testfixtures__/TestEntity2.ts +7 -7
- package/src/utils/__testfixtures__/TestEntityWithMutationTriggers.ts +10 -10
- package/src/utils/__testfixtures__/TestViewerContext.ts +1 -1
- package/src/utils/__testfixtures__/createUnitTestEntityCompanionProvider.ts +6 -6
- package/src/utils/__testfixtures__/describeFieldTestCase.ts +1 -1
- package/src/utils/__tests__/EntityCreationUtils-test.ts +7 -7
- package/src/utils/__tests__/EntityPrivacyUtils-test.ts +20 -21
- package/src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.ts +12 -12
- package/src/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.ts +2 -2
- package/src/utils/collections/__tests__/SerializableKeyMap-test.ts +2 -1
- package/src/utils/collections/__tests__/maps-test.ts +5 -5
- package/src/utils/collections/__tests__/sets-test.ts +1 -1
- package/src/utils/mergeEntityMutationTriggerConfigurations.ts +3 -3
- package/build/src/AuthorizationResultBasedEntityAssociationLoader.js.map +0 -1
- package/build/src/AuthorizationResultBasedEntityLoader.js.map +0 -1
- package/build/src/AuthorizationResultBasedEntityMutator.js.map +0 -1
- package/build/src/ComposedEntityCacheAdapter.js.map +0 -1
- package/build/src/ComposedSecondaryEntityCache.js.map +0 -1
- package/build/src/EnforcingEntityAssociationLoader.js.map +0 -1
- package/build/src/EnforcingEntityCreator.js.map +0 -1
- package/build/src/EnforcingEntityDeleter.js.map +0 -1
- package/build/src/EnforcingEntityLoader.js.map +0 -1
- package/build/src/EnforcingEntityUpdater.js.map +0 -1
- package/build/src/Entity.js.map +0 -1
- package/build/src/EntityAssociationLoader.js.map +0 -1
- package/build/src/EntityCompanion.js.map +0 -1
- package/build/src/EntityCompanionProvider.js.map +0 -1
- package/build/src/EntityConfiguration.js.map +0 -1
- package/build/src/EntityConstructionUtils.js.map +0 -1
- package/build/src/EntityCreator.js.map +0 -1
- package/build/src/EntityDatabaseAdapter.js.map +0 -1
- package/build/src/EntityDeleter.js.map +0 -1
- package/build/src/EntityFieldDefinition.js.map +0 -1
- package/build/src/EntityFields.js.map +0 -1
- package/build/src/EntityInvalidationUtils.js.map +0 -1
- package/build/src/EntityLoader.js.map +0 -1
- package/build/src/EntityLoaderFactory.js.map +0 -1
- package/build/src/EntityMutationInfo.js.map +0 -1
- package/build/src/EntityMutationTriggerConfiguration.js.map +0 -1
- package/build/src/EntityMutationValidatorConfiguration.js.map +0 -1
- package/build/src/EntityMutatorFactory.js.map +0 -1
- package/build/src/EntityPrivacyPolicy.js.map +0 -1
- package/build/src/EntityQueryContext.js.map +0 -1
- package/build/src/EntityQueryContextProvider.js.map +0 -1
- package/build/src/EntitySecondaryCacheLoader.js.map +0 -1
- package/build/src/EntityUpdater.js.map +0 -1
- package/build/src/GenericEntityCacheAdapter.js.map +0 -1
- package/build/src/GenericSecondaryEntityCache.js.map +0 -1
- package/build/src/IEntityCacheAdapter.js.map +0 -1
- package/build/src/IEntityCacheAdapterProvider.js.map +0 -1
- package/build/src/IEntityDatabaseAdapterProvider.js.map +0 -1
- package/build/src/IEntityGenericCacher.js.map +0 -1
- package/build/src/ReadonlyEntity.js.map +0 -1
- package/build/src/ViewerContext.js.map +0 -1
- package/build/src/ViewerScopedEntityCompanion.js.map +0 -1
- package/build/src/ViewerScopedEntityCompanionProvider.js.map +0 -1
- package/build/src/ViewerScopedEntityLoaderFactory.js.map +0 -1
- package/build/src/ViewerScopedEntityMutatorFactory.js.map +0 -1
- package/build/src/entityUtils.js.map +0 -1
- package/build/src/errors/EntityCacheAdapterError.js.map +0 -1
- package/build/src/errors/EntityDatabaseAdapterError.js.map +0 -1
- package/build/src/errors/EntityError.js.map +0 -1
- package/build/src/errors/EntityInvalidFieldValueError.js.map +0 -1
- package/build/src/errors/EntityNotAuthorizedError.js.map +0 -1
- package/build/src/errors/EntityNotFoundError.js.map +0 -1
- package/build/src/index.js.map +0 -1
- package/build/src/internal/CompositeFieldHolder.js.map +0 -1
- package/build/src/internal/CompositeFieldValueMap.js.map +0 -1
- package/build/src/internal/EntityDataManager.js.map +0 -1
- package/build/src/internal/EntityFieldTransformationUtils.js.map +0 -1
- package/build/src/internal/EntityLoadInterfaces.js.map +0 -1
- package/build/src/internal/EntityTableDataCoordinator.js.map +0 -1
- package/build/src/internal/ReadThroughEntityCache.js.map +0 -1
- package/build/src/internal/SingleFieldHolder.js.map +0 -1
- package/build/src/metrics/EntityMetricsUtils.js.map +0 -1
- package/build/src/metrics/IEntityMetricsAdapter.js.map +0 -1
- package/build/src/metrics/NoOpEntityMetricsAdapter.js.map +0 -1
- package/build/src/rules/AllowIfAllSubRulesAllowPrivacyPolicyRule.js.map +0 -1
- package/build/src/rules/AllowIfAnySubRuleAllowsPrivacyPolicyRule.js.map +0 -1
- package/build/src/rules/AllowIfInParentCascadeDeletionPrivacyPolicyRule.js.map +0 -1
- package/build/src/rules/AlwaysAllowPrivacyPolicyRule.js.map +0 -1
- package/build/src/rules/AlwaysDenyPrivacyPolicyRule.js.map +0 -1
- package/build/src/rules/AlwaysSkipPrivacyPolicyRule.js.map +0 -1
- package/build/src/rules/EvaluateIfEntityFieldPredicatePrivacyPolicyRule.js.map +0 -1
- package/build/src/rules/PrivacyPolicyRule.js.map +0 -1
- package/build/src/utils/EntityCreationUtils.js.map +0 -1
- package/build/src/utils/EntityPrivacyUtils.js.map +0 -1
- package/build/src/utils/collections/SerializableKeyMap.js.map +0 -1
- package/build/src/utils/collections/maps.js.map +0 -1
- package/build/src/utils/collections/sets.js.map +0 -1
- package/build/src/utils/mergeEntityMutationTriggerConfigurations.js.map +0 -1
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const EntityNotAuthorizedError_1 = require("./errors/EntityNotAuthorizedError");
|
|
5
|
-
const IEntityMetricsAdapter_1 = require("./metrics/IEntityMetricsAdapter");
|
|
6
|
-
const PrivacyPolicyRule_1 = require("./rules/PrivacyPolicyRule");
|
|
1
|
+
import { EntityNotAuthorizedError } from "./errors/EntityNotAuthorizedError.js";
|
|
2
|
+
import { EntityMetricsAuthorizationResult } from "./metrics/IEntityMetricsAdapter.js";
|
|
3
|
+
import { RuleEvaluationResult } from "./rules/PrivacyPolicyRule.js";
|
|
7
4
|
/**
|
|
8
5
|
* Evaluation mode for a EntityPrivacyPolicy. Useful when transitioning to
|
|
9
6
|
* using Entity for privacy.
|
|
10
7
|
*/
|
|
11
|
-
var EntityPrivacyPolicyEvaluationMode;
|
|
8
|
+
export var EntityPrivacyPolicyEvaluationMode;
|
|
12
9
|
(function (EntityPrivacyPolicyEvaluationMode) {
|
|
13
10
|
/**
|
|
14
11
|
* Enforce this privacy policy. Throw upon denial.
|
|
@@ -22,14 +19,14 @@ var EntityPrivacyPolicyEvaluationMode;
|
|
|
22
19
|
* Enforce this privacy policy. Throw and log upon denial.
|
|
23
20
|
*/
|
|
24
21
|
EntityPrivacyPolicyEvaluationMode[EntityPrivacyPolicyEvaluationMode["ENFORCE_AND_LOG"] = 2] = "ENFORCE_AND_LOG";
|
|
25
|
-
})(EntityPrivacyPolicyEvaluationMode || (
|
|
26
|
-
var EntityAuthorizationAction;
|
|
22
|
+
})(EntityPrivacyPolicyEvaluationMode || (EntityPrivacyPolicyEvaluationMode = {}));
|
|
23
|
+
export var EntityAuthorizationAction;
|
|
27
24
|
(function (EntityAuthorizationAction) {
|
|
28
25
|
EntityAuthorizationAction[EntityAuthorizationAction["CREATE"] = 0] = "CREATE";
|
|
29
26
|
EntityAuthorizationAction[EntityAuthorizationAction["READ"] = 1] = "READ";
|
|
30
27
|
EntityAuthorizationAction[EntityAuthorizationAction["UPDATE"] = 2] = "UPDATE";
|
|
31
28
|
EntityAuthorizationAction[EntityAuthorizationAction["DELETE"] = 3] = "DELETE";
|
|
32
|
-
})(EntityAuthorizationAction || (
|
|
29
|
+
})(EntityAuthorizationAction || (EntityAuthorizationAction = {}));
|
|
33
30
|
/**
|
|
34
31
|
* Privacy policy for an entity.
|
|
35
32
|
*
|
|
@@ -51,7 +48,7 @@ var EntityAuthorizationAction;
|
|
|
51
48
|
* return not authorized if all rules skip
|
|
52
49
|
* ```
|
|
53
50
|
*/
|
|
54
|
-
class EntityPrivacyPolicy {
|
|
51
|
+
export class EntityPrivacyPolicy {
|
|
55
52
|
/**
|
|
56
53
|
* List of rules to evaluate for create authorization.
|
|
57
54
|
*/
|
|
@@ -143,19 +140,19 @@ class EntityPrivacyPolicy {
|
|
|
143
140
|
metricsAdapter.logAuthorizationEvent({
|
|
144
141
|
entityClassName: entity.constructor.name,
|
|
145
142
|
action,
|
|
146
|
-
evaluationResult:
|
|
143
|
+
evaluationResult: EntityMetricsAuthorizationResult.ALLOW,
|
|
147
144
|
privacyPolicyEvaluationMode: privacyPolicyEvaluator.mode,
|
|
148
145
|
});
|
|
149
146
|
return result;
|
|
150
147
|
}
|
|
151
148
|
catch (e) {
|
|
152
|
-
if (!(e instanceof
|
|
149
|
+
if (!(e instanceof EntityNotAuthorizedError)) {
|
|
153
150
|
throw e;
|
|
154
151
|
}
|
|
155
152
|
metricsAdapter.logAuthorizationEvent({
|
|
156
153
|
entityClassName: entity.constructor.name,
|
|
157
154
|
action,
|
|
158
|
-
evaluationResult:
|
|
155
|
+
evaluationResult: EntityMetricsAuthorizationResult.DENY,
|
|
159
156
|
privacyPolicyEvaluationMode: privacyPolicyEvaluator.mode,
|
|
160
157
|
});
|
|
161
158
|
throw e;
|
|
@@ -166,20 +163,20 @@ class EntityPrivacyPolicy {
|
|
|
166
163
|
metricsAdapter.logAuthorizationEvent({
|
|
167
164
|
entityClassName: entity.constructor.name,
|
|
168
165
|
action,
|
|
169
|
-
evaluationResult:
|
|
166
|
+
evaluationResult: EntityMetricsAuthorizationResult.ALLOW,
|
|
170
167
|
privacyPolicyEvaluationMode: privacyPolicyEvaluator.mode,
|
|
171
168
|
});
|
|
172
169
|
return result;
|
|
173
170
|
}
|
|
174
171
|
catch (e) {
|
|
175
|
-
if (!(e instanceof
|
|
172
|
+
if (!(e instanceof EntityNotAuthorizedError)) {
|
|
176
173
|
throw e;
|
|
177
174
|
}
|
|
178
175
|
privacyPolicyEvaluator.denyHandler(e);
|
|
179
176
|
metricsAdapter.logAuthorizationEvent({
|
|
180
177
|
entityClassName: entity.constructor.name,
|
|
181
178
|
action,
|
|
182
|
-
evaluationResult:
|
|
179
|
+
evaluationResult: EntityMetricsAuthorizationResult.DENY,
|
|
183
180
|
privacyPolicyEvaluationMode: privacyPolicyEvaluator.mode,
|
|
184
181
|
});
|
|
185
182
|
throw e;
|
|
@@ -190,20 +187,20 @@ class EntityPrivacyPolicy {
|
|
|
190
187
|
metricsAdapter.logAuthorizationEvent({
|
|
191
188
|
entityClassName: entity.constructor.name,
|
|
192
189
|
action,
|
|
193
|
-
evaluationResult:
|
|
190
|
+
evaluationResult: EntityMetricsAuthorizationResult.ALLOW,
|
|
194
191
|
privacyPolicyEvaluationMode: privacyPolicyEvaluator.mode,
|
|
195
192
|
});
|
|
196
193
|
return result;
|
|
197
194
|
}
|
|
198
195
|
catch (e) {
|
|
199
|
-
if (!(e instanceof
|
|
196
|
+
if (!(e instanceof EntityNotAuthorizedError)) {
|
|
200
197
|
throw e;
|
|
201
198
|
}
|
|
202
199
|
privacyPolicyEvaluator.denyHandler(e);
|
|
203
200
|
metricsAdapter.logAuthorizationEvent({
|
|
204
201
|
entityClassName: entity.constructor.name,
|
|
205
202
|
action,
|
|
206
|
-
evaluationResult:
|
|
203
|
+
evaluationResult: EntityMetricsAuthorizationResult.DENY,
|
|
207
204
|
privacyPolicyEvaluationMode: privacyPolicyEvaluator.mode,
|
|
208
205
|
});
|
|
209
206
|
return entity;
|
|
@@ -215,18 +212,16 @@ class EntityPrivacyPolicy {
|
|
|
215
212
|
const rule = ruleset[i];
|
|
216
213
|
const ruleEvaluationResult = await rule.evaluateAsync(viewerContext, queryContext, { ...evaluationContext, action }, entity);
|
|
217
214
|
switch (ruleEvaluationResult) {
|
|
218
|
-
case
|
|
219
|
-
throw new
|
|
220
|
-
case
|
|
215
|
+
case RuleEvaluationResult.DENY:
|
|
216
|
+
throw new EntityNotAuthorizedError(entity, viewerContext, action, i);
|
|
217
|
+
case RuleEvaluationResult.SKIP:
|
|
221
218
|
continue;
|
|
222
|
-
case
|
|
219
|
+
case RuleEvaluationResult.ALLOW:
|
|
223
220
|
return entity;
|
|
224
221
|
default:
|
|
225
222
|
throw new Error(`Invalid RuleEvaluationResult returned from rule: ${entity} (viewer = ${viewerContext}, action = ${EntityAuthorizationAction[action]}, ruleIndex = ${i})`);
|
|
226
223
|
}
|
|
227
224
|
}
|
|
228
|
-
throw new
|
|
225
|
+
throw new EntityNotAuthorizedError(entity, viewerContext, action, -1);
|
|
229
226
|
}
|
|
230
227
|
}
|
|
231
|
-
exports.EntityPrivacyPolicy = EntityPrivacyPolicy;
|
|
232
|
-
//# sourceMappingURL=EntityPrivacyPolicy.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityQueryContextProvider } from './EntityQueryContextProvider';
|
|
1
|
+
import type { EntityQueryContextProvider } from './EntityQueryContextProvider.ts';
|
|
2
2
|
export type PostCommitCallback = (...args: any) => Promise<any>;
|
|
3
3
|
export type PreCommitCallback = (queryContext: EntityTransactionalQueryContext, ...args: any) => Promise<any>;
|
|
4
4
|
export declare enum TransactionIsolationLevel {
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EntityNestedTransactionalQueryContext = exports.EntityTransactionalQueryContext = exports.EntityNonTransactionalQueryContext = exports.EntityQueryContext = exports.TransactionalDataLoaderMode = exports.TransactionIsolationLevel = void 0;
|
|
7
|
-
const assert_1 = __importDefault(require("assert"));
|
|
8
|
-
var TransactionIsolationLevel;
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
export var TransactionIsolationLevel;
|
|
9
3
|
(function (TransactionIsolationLevel) {
|
|
10
4
|
TransactionIsolationLevel["READ_COMMITTED"] = "READ_COMMITTED";
|
|
11
5
|
TransactionIsolationLevel["REPEATABLE_READ"] = "REPEATABLE_READ";
|
|
12
6
|
TransactionIsolationLevel["SERIALIZABLE"] = "SERIALIZABLE";
|
|
13
|
-
})(TransactionIsolationLevel || (
|
|
14
|
-
var TransactionalDataLoaderMode;
|
|
7
|
+
})(TransactionIsolationLevel || (TransactionIsolationLevel = {}));
|
|
8
|
+
export var TransactionalDataLoaderMode;
|
|
15
9
|
(function (TransactionalDataLoaderMode) {
|
|
16
10
|
TransactionalDataLoaderMode["ENABLED"] = "ENABLED";
|
|
17
11
|
TransactionalDataLoaderMode["ENABLED_BATCH_ONLY"] = "ENABLED_BATCH_ONLY";
|
|
18
12
|
TransactionalDataLoaderMode["DISABLED"] = "DISABLED";
|
|
19
|
-
})(TransactionalDataLoaderMode || (
|
|
13
|
+
})(TransactionalDataLoaderMode || (TransactionalDataLoaderMode = {}));
|
|
20
14
|
/**
|
|
21
15
|
* Entity framework representation of transactional and non-transactional database
|
|
22
16
|
* query execution units.
|
|
@@ -24,7 +18,7 @@ var TransactionalDataLoaderMode;
|
|
|
24
18
|
* The behavior of EntityMutator and EntityLoader
|
|
25
19
|
* differs when in a transactional context.
|
|
26
20
|
*/
|
|
27
|
-
class EntityQueryContext {
|
|
21
|
+
export class EntityQueryContext {
|
|
28
22
|
queryInterface;
|
|
29
23
|
constructor(queryInterface) {
|
|
30
24
|
this.queryInterface = queryInterface;
|
|
@@ -33,14 +27,13 @@ class EntityQueryContext {
|
|
|
33
27
|
return this.queryInterface;
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
|
-
exports.EntityQueryContext = EntityQueryContext;
|
|
37
30
|
/**
|
|
38
31
|
* Entity framework representation of a non-transactional query execution unit.
|
|
39
32
|
* When supplied to EntityMutator and EntityLoader methods, they will be
|
|
40
33
|
* run independently of any running transaction (though mutations start their own
|
|
41
34
|
* independent transactions internally when not being run in a transaction).
|
|
42
35
|
*/
|
|
43
|
-
class EntityNonTransactionalQueryContext extends EntityQueryContext {
|
|
36
|
+
export class EntityNonTransactionalQueryContext extends EntityQueryContext {
|
|
44
37
|
entityQueryContextProvider;
|
|
45
38
|
constructor(queryInterface, entityQueryContextProvider) {
|
|
46
39
|
super(queryInterface);
|
|
@@ -53,13 +46,12 @@ class EntityNonTransactionalQueryContext extends EntityQueryContext {
|
|
|
53
46
|
return await this.entityQueryContextProvider.runInTransactionAsync(transactionScope, transactionConfig);
|
|
54
47
|
}
|
|
55
48
|
}
|
|
56
|
-
exports.EntityNonTransactionalQueryContext = EntityNonTransactionalQueryContext;
|
|
57
49
|
/**
|
|
58
50
|
* Entity framework representation of a transactional query execution unit. When supplied
|
|
59
51
|
* to EntityMutator and EntityLoader methods, those methods and their
|
|
60
52
|
* dependent triggers and validators will run within the transaction.
|
|
61
53
|
*/
|
|
62
|
-
class EntityTransactionalQueryContext extends EntityQueryContext {
|
|
54
|
+
export class EntityTransactionalQueryContext extends EntityQueryContext {
|
|
63
55
|
entityQueryContextProvider;
|
|
64
56
|
transactionId;
|
|
65
57
|
transactionalDataLoaderMode;
|
|
@@ -89,7 +81,7 @@ class EntityTransactionalQueryContext extends EntityQueryContext {
|
|
|
89
81
|
* with higher numbers running later than lower numbers.
|
|
90
82
|
*/
|
|
91
83
|
appendPreCommitCallback(callback, order) {
|
|
92
|
-
(
|
|
84
|
+
assert(order >= Number.MIN_SAFE_INTEGER && order <= Number.MAX_SAFE_INTEGER, `Invalid order specified: ${order}`);
|
|
93
85
|
this.preCommitCallbacks.push({ callback, order });
|
|
94
86
|
}
|
|
95
87
|
/**
|
|
@@ -138,14 +130,13 @@ class EntityTransactionalQueryContext extends EntityQueryContext {
|
|
|
138
130
|
return false;
|
|
139
131
|
}
|
|
140
132
|
async runInTransactionIfNotInTransactionAsync(transactionScope, transactionConfig) {
|
|
141
|
-
(
|
|
133
|
+
assert(transactionConfig === undefined, 'Should not pass transactionConfig to a nested transaction');
|
|
142
134
|
return await transactionScope(this);
|
|
143
135
|
}
|
|
144
136
|
async runInNestedTransactionAsync(transactionScope) {
|
|
145
137
|
return await this.entityQueryContextProvider.runInNestedTransactionAsync(this, transactionScope);
|
|
146
138
|
}
|
|
147
139
|
}
|
|
148
|
-
exports.EntityTransactionalQueryContext = EntityTransactionalQueryContext;
|
|
149
140
|
/**
|
|
150
141
|
* Entity framework representation of a nested transactional query execution unit. When supplied
|
|
151
142
|
* to EntityMutator and EntityLoader methods, those methods and their
|
|
@@ -154,7 +145,7 @@ exports.EntityTransactionalQueryContext = EntityTransactionalQueryContext;
|
|
|
154
145
|
* This exists to forward post-commit callbacks to the parent query context but only after
|
|
155
146
|
* successful commit of the nested transaction.
|
|
156
147
|
*/
|
|
157
|
-
class EntityNestedTransactionalQueryContext extends EntityTransactionalQueryContext {
|
|
148
|
+
export class EntityNestedTransactionalQueryContext extends EntityTransactionalQueryContext {
|
|
158
149
|
parentQueryContext;
|
|
159
150
|
postCommitInvalidationCallbacksToTransfer = [];
|
|
160
151
|
postCommitCallbacksToTransfer = [];
|
|
@@ -208,5 +199,3 @@ class EntityNestedTransactionalQueryContext extends EntityTransactionalQueryCont
|
|
|
208
199
|
}
|
|
209
200
|
}
|
|
210
201
|
}
|
|
211
|
-
exports.EntityNestedTransactionalQueryContext = EntityNestedTransactionalQueryContext;
|
|
212
|
-
//# sourceMappingURL=EntityQueryContext.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TransactionConfig } from './EntityQueryContext.ts';
|
|
2
|
+
import { EntityNestedTransactionalQueryContext, EntityNonTransactionalQueryContext, EntityTransactionalQueryContext, TransactionalDataLoaderMode } from './EntityQueryContext.ts';
|
|
2
3
|
/**
|
|
3
4
|
* A query context provider vends transactional and non-transactional query contexts.
|
|
4
5
|
*/
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.EntityQueryContextProvider = void 0;
|
|
4
|
-
const node_crypto_1 = require("node:crypto");
|
|
5
|
-
const EntityQueryContext_1 = require("./EntityQueryContext");
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { EntityNestedTransactionalQueryContext, EntityNonTransactionalQueryContext, EntityTransactionalQueryContext, TransactionalDataLoaderMode, } from "./EntityQueryContext.js";
|
|
6
3
|
/**
|
|
7
4
|
* A query context provider vends transactional and non-transactional query contexts.
|
|
8
5
|
*/
|
|
9
|
-
class EntityQueryContextProvider {
|
|
6
|
+
export class EntityQueryContextProvider {
|
|
10
7
|
/**
|
|
11
8
|
* Vend a regular (non-transactional) entity query context.
|
|
12
9
|
*/
|
|
13
10
|
getQueryContext() {
|
|
14
|
-
return new
|
|
11
|
+
return new EntityNonTransactionalQueryContext(this.getQueryInterface(), this);
|
|
15
12
|
}
|
|
16
13
|
/**
|
|
17
14
|
* @returns true if the transactional dataloader should be disabled for all transactions.
|
|
18
15
|
*/
|
|
19
16
|
defaultTransactionalDataLoaderMode() {
|
|
20
|
-
return
|
|
17
|
+
return TransactionalDataLoaderMode.ENABLED;
|
|
21
18
|
}
|
|
22
19
|
/**
|
|
23
20
|
* Start a transaction and execute the provided transaction-scoped closure within the transaction.
|
|
@@ -25,7 +22,7 @@ class EntityQueryContextProvider {
|
|
|
25
22
|
*/
|
|
26
23
|
async runInTransactionAsync(transactionScope, transactionConfig) {
|
|
27
24
|
const [returnedValue, queryContext] = await this.createTransactionRunner(transactionConfig)(async (queryInterface) => {
|
|
28
|
-
const queryContext = new
|
|
25
|
+
const queryContext = new EntityTransactionalQueryContext(queryInterface, this, randomUUID(), transactionConfig?.transactionalDataLoaderMode ?? this.defaultTransactionalDataLoaderMode());
|
|
29
26
|
const result = await transactionScope(queryContext);
|
|
30
27
|
await queryContext.runPreCommitCallbacksAsync();
|
|
31
28
|
return [result, queryContext];
|
|
@@ -41,7 +38,7 @@ class EntityQueryContextProvider {
|
|
|
41
38
|
*/
|
|
42
39
|
async runInNestedTransactionAsync(outerQueryContext, transactionScope) {
|
|
43
40
|
const [returnedValue, innerQueryContext] = await this.createNestedTransactionRunner(outerQueryContext.getQueryInterface())(async (innerQueryInterface) => {
|
|
44
|
-
const innerQueryContext = new
|
|
41
|
+
const innerQueryContext = new EntityNestedTransactionalQueryContext(innerQueryInterface, outerQueryContext, this, randomUUID(), outerQueryContext.transactionalDataLoaderMode);
|
|
45
42
|
const result = await transactionScope(innerQueryContext);
|
|
46
43
|
await innerQueryContext.runPreCommitCallbacksAsync();
|
|
47
44
|
return [result, innerQueryContext];
|
|
@@ -51,5 +48,3 @@ class EntityQueryContextProvider {
|
|
|
51
48
|
return returnedValue;
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
|
-
exports.EntityQueryContextProvider = EntityQueryContextProvider;
|
|
55
|
-
//# sourceMappingURL=EntityQueryContextProvider.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Result } from '@expo/results';
|
|
2
|
-
import { IEntityClass } from './Entity';
|
|
3
|
-
import { EntityConstructionUtils } from './EntityConstructionUtils';
|
|
4
|
-
import { EntityPrivacyPolicy } from './EntityPrivacyPolicy';
|
|
5
|
-
import { EntityQueryContext } from './EntityQueryContext';
|
|
6
|
-
import { ReadonlyEntity } from './ReadonlyEntity';
|
|
7
|
-
import { ViewerContext } from './ViewerContext';
|
|
1
|
+
import type { Result } from '@expo/results';
|
|
2
|
+
import type { IEntityClass } from './Entity.ts';
|
|
3
|
+
import type { EntityConstructionUtils } from './EntityConstructionUtils.ts';
|
|
4
|
+
import type { EntityPrivacyPolicy } from './EntityPrivacyPolicy.ts';
|
|
5
|
+
import type { EntityQueryContext } from './EntityQueryContext.ts';
|
|
6
|
+
import type { ReadonlyEntity } from './ReadonlyEntity.ts';
|
|
7
|
+
import type { ViewerContext } from './ViewerContext.ts';
|
|
8
8
|
/**
|
|
9
9
|
* An interface that knows how to load many objects from a cache by load params and invalidate
|
|
10
10
|
* those same load params.
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntitySecondaryCacheLoader = void 0;
|
|
4
|
-
const maps_1 = require("./utils/collections/maps");
|
|
1
|
+
import { mapMap } from "./utils/collections/maps.js";
|
|
5
2
|
/**
|
|
6
3
|
* A secondary cache loader allows for arbitrary cache keying for load params, which are a set of params used to load
|
|
7
4
|
* a single entity field object.
|
|
@@ -13,7 +10,7 @@ const maps_1 = require("./utils/collections/maps");
|
|
|
13
10
|
* due to use of a non-unique-field-based EntityLoader method like `loadManyByFieldEqualityConjunctionAsync` or
|
|
14
11
|
* `loadManyByRawWhereClauseAsync`.
|
|
15
12
|
*/
|
|
16
|
-
class EntitySecondaryCacheLoader {
|
|
13
|
+
export class EntitySecondaryCacheLoader {
|
|
17
14
|
secondaryEntityCache;
|
|
18
15
|
constructionUtils;
|
|
19
16
|
constructor(secondaryEntityCache, constructionUtils) {
|
|
@@ -28,8 +25,8 @@ class EntitySecondaryCacheLoader {
|
|
|
28
25
|
async loadManyAsync(loadParamsArray) {
|
|
29
26
|
const loadParamsToFieldObjects = await this.secondaryEntityCache.loadManyThroughAsync(loadParamsArray, this.fetchObjectsFromDatabaseAsync.bind(this));
|
|
30
27
|
// convert value to and from array to reuse complex code
|
|
31
|
-
const entitiesMap = await this.constructionUtils.constructAndAuthorizeEntitiesAsync(
|
|
32
|
-
return
|
|
28
|
+
const entitiesMap = await this.constructionUtils.constructAndAuthorizeEntitiesAsync(mapMap(loadParamsToFieldObjects, (fieldObject) => (fieldObject ? [fieldObject] : [])));
|
|
29
|
+
return mapMap(entitiesMap, (fieldObjects) => fieldObjects[0] ?? null);
|
|
33
30
|
}
|
|
34
31
|
/**
|
|
35
32
|
* Invalidate the cache for objects cached by loadParams.
|
|
@@ -57,5 +54,3 @@ class EntitySecondaryCacheLoader {
|
|
|
57
54
|
.constructionUtils(queryContext, { previousValue: null, cascadingDeleteCause: null });
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
|
-
exports.EntitySecondaryCacheLoader = EntitySecondaryCacheLoader;
|
|
61
|
-
//# sourceMappingURL=EntitySecondaryCacheLoader.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AuthorizationResultBasedUpdateMutator } from './AuthorizationResultBasedEntityMutator';
|
|
2
|
-
import { EnforcingEntityUpdater } from './EnforcingEntityUpdater';
|
|
3
|
-
import { IEntityClass } from './Entity';
|
|
4
|
-
import { EntityPrivacyPolicy } from './EntityPrivacyPolicy';
|
|
5
|
-
import { EntityQueryContext } from './EntityQueryContext';
|
|
6
|
-
import { ReadonlyEntity } from './ReadonlyEntity';
|
|
7
|
-
import { ViewerContext } from './ViewerContext';
|
|
1
|
+
import type { AuthorizationResultBasedUpdateMutator } from './AuthorizationResultBasedEntityMutator.ts';
|
|
2
|
+
import { EnforcingEntityUpdater } from './EnforcingEntityUpdater.ts';
|
|
3
|
+
import type { IEntityClass } from './Entity.ts';
|
|
4
|
+
import type { EntityPrivacyPolicy } from './EntityPrivacyPolicy.ts';
|
|
5
|
+
import type { EntityQueryContext } from './EntityQueryContext.ts';
|
|
6
|
+
import type { ReadonlyEntity } from './ReadonlyEntity.ts';
|
|
7
|
+
import type { ViewerContext } from './ViewerContext.ts';
|
|
8
8
|
/**
|
|
9
9
|
* The primary interface for updating entities.
|
|
10
10
|
*/
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntityUpdater = void 0;
|
|
4
|
-
const EnforcingEntityUpdater_1 = require("./EnforcingEntityUpdater");
|
|
1
|
+
import { EnforcingEntityUpdater } from "./EnforcingEntityUpdater.js";
|
|
5
2
|
/**
|
|
6
3
|
* The primary interface for updating entities.
|
|
7
4
|
*/
|
|
8
|
-
class EntityUpdater {
|
|
5
|
+
export class EntityUpdater {
|
|
9
6
|
existingEntity;
|
|
10
7
|
queryContext;
|
|
11
8
|
entityClass;
|
|
@@ -19,7 +16,7 @@ class EntityUpdater {
|
|
|
19
16
|
* guaranteed to be successful and will throw otherwise.
|
|
20
17
|
*/
|
|
21
18
|
enforcing() {
|
|
22
|
-
return new
|
|
19
|
+
return new EnforcingEntityUpdater(this.withAuthorizationResults());
|
|
23
20
|
}
|
|
24
21
|
/**
|
|
25
22
|
* Authorization-result-based entity updater. All updates through this
|
|
@@ -34,5 +31,3 @@ class EntityUpdater {
|
|
|
34
31
|
.forUpdate(this.existingEntity, this.queryContext, /* cascadingDeleteCause */ null);
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
exports.EntityUpdater = EntityUpdater;
|
|
38
|
-
//# sourceMappingURL=EntityUpdater.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IEntityCacheAdapter } from './IEntityCacheAdapter';
|
|
2
|
-
import { IEntityGenericCacher } from './IEntityGenericCacher';
|
|
3
|
-
import { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces';
|
|
4
|
-
import { CacheLoadResult } from './internal/ReadThroughEntityCache';
|
|
1
|
+
import type { IEntityCacheAdapter } from './IEntityCacheAdapter.ts';
|
|
2
|
+
import type { IEntityGenericCacher } from './IEntityGenericCacher.ts';
|
|
3
|
+
import type { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces.ts';
|
|
4
|
+
import type { CacheLoadResult } from './internal/ReadThroughEntityCache.ts';
|
|
5
5
|
/**
|
|
6
6
|
* A standard IEntityCacheAdapter that coordinates caching through an IEntityGenericCacher.
|
|
7
7
|
*/
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GenericEntityCacheAdapter = void 0;
|
|
7
|
-
const invariant_1 = __importDefault(require("invariant"));
|
|
8
|
-
const maps_1 = require("./utils/collections/maps");
|
|
1
|
+
import invariant from 'invariant';
|
|
2
|
+
import { mapKeys } from "./utils/collections/maps.js";
|
|
9
3
|
/**
|
|
10
4
|
* A standard IEntityCacheAdapter that coordinates caching through an IEntityGenericCacher.
|
|
11
5
|
*/
|
|
12
|
-
class GenericEntityCacheAdapter {
|
|
6
|
+
export class GenericEntityCacheAdapter {
|
|
13
7
|
genericCacher;
|
|
14
8
|
constructor(genericCacher) {
|
|
15
9
|
this.genericCacher = genericCacher;
|
|
@@ -20,13 +14,13 @@ class GenericEntityCacheAdapter {
|
|
|
20
14
|
const result = key.vendNewLoadValueMap();
|
|
21
15
|
for (const [redisCacheKey, cacheResult] of cacheResults) {
|
|
22
16
|
const fieldValue = redisCacheKeyToFieldValueMapping.get(redisCacheKey);
|
|
23
|
-
(
|
|
17
|
+
invariant(fieldValue !== undefined, 'Unspecified cache key %s returned from generic cacher', redisCacheKey);
|
|
24
18
|
result.set(fieldValue, cacheResult);
|
|
25
19
|
}
|
|
26
20
|
return result;
|
|
27
21
|
}
|
|
28
22
|
async cacheManyAsync(key, objectMap) {
|
|
29
|
-
await this.genericCacher.cacheManyAsync(
|
|
23
|
+
await this.genericCacher.cacheManyAsync(mapKeys(objectMap, (value) => this.genericCacher.makeCacheKeyForStorage(key, value)));
|
|
30
24
|
}
|
|
31
25
|
async cacheDBMissesAsync(key, values) {
|
|
32
26
|
await this.genericCacher.cacheDBMissesAsync(values.map((value) => this.genericCacher.makeCacheKeyForStorage(key, value)));
|
|
@@ -35,5 +29,3 @@ class GenericEntityCacheAdapter {
|
|
|
35
29
|
await this.genericCacher.invalidateManyAsync(values.flatMap((value) => this.genericCacher.makeCacheKeysForInvalidation(key, value)));
|
|
36
30
|
}
|
|
37
31
|
}
|
|
38
|
-
exports.GenericEntityCacheAdapter = GenericEntityCacheAdapter;
|
|
39
|
-
//# sourceMappingURL=GenericEntityCacheAdapter.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ISecondaryEntityCache } from './EntitySecondaryCacheLoader';
|
|
2
|
-
import { IEntityGenericCacher } from './IEntityGenericCacher';
|
|
1
|
+
import type { ISecondaryEntityCache } from './EntitySecondaryCacheLoader.ts';
|
|
2
|
+
import type { IEntityGenericCacher } from './IEntityGenericCacher.ts';
|
|
3
3
|
/**
|
|
4
4
|
* A custom secondary read-through entity cache is a way to add a custom second layer of caching for a particular
|
|
5
5
|
* single entity load. One common way this may be used is to add a second layer of caching in a hot path that makes
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GenericSecondaryEntityCache = void 0;
|
|
7
|
-
const invariant_1 = __importDefault(require("invariant"));
|
|
8
|
-
const ReadThroughEntityCache_1 = require("./internal/ReadThroughEntityCache");
|
|
9
|
-
const maps_1 = require("./utils/collections/maps");
|
|
1
|
+
import invariant from 'invariant';
|
|
2
|
+
import { CacheStatus } from "./internal/ReadThroughEntityCache.js";
|
|
3
|
+
import { filterMap, zipToMap } from "./utils/collections/maps.js";
|
|
10
4
|
/**
|
|
11
5
|
* A custom secondary read-through entity cache is a way to add a custom second layer of caching for a particular
|
|
12
6
|
* single entity load. One common way this may be used is to add a second layer of caching in a hot path that makes
|
|
13
7
|
* a call to EntityLoader.loadManyByFieldEqualityConjunctionAsync is guaranteed to return at most one entity.
|
|
14
8
|
*/
|
|
15
|
-
class GenericSecondaryEntityCache {
|
|
9
|
+
export class GenericSecondaryEntityCache {
|
|
16
10
|
cacher;
|
|
17
11
|
constructCacheKey;
|
|
18
12
|
constructor(cacher, constructCacheKey) {
|
|
@@ -21,16 +15,16 @@ class GenericSecondaryEntityCache {
|
|
|
21
15
|
}
|
|
22
16
|
async loadManyThroughAsync(loadParamsArray, fetcher) {
|
|
23
17
|
const cacheKeys = loadParamsArray.map(this.constructCacheKey);
|
|
24
|
-
const cacheKeyToLoadParamsMap =
|
|
18
|
+
const cacheKeyToLoadParamsMap = zipToMap(cacheKeys, loadParamsArray);
|
|
25
19
|
const cacheLoadResults = await this.cacher.loadManyAsync(cacheKeys);
|
|
26
|
-
(
|
|
27
|
-
const cacheKeysToFetch = Array.from(
|
|
20
|
+
invariant(cacheLoadResults.size === loadParamsArray.length, `${this.constructor.name} loadMany should return a result for each key`);
|
|
21
|
+
const cacheKeysToFetch = Array.from(filterMap(cacheLoadResults, (cacheLoadResult) => cacheLoadResult.status === CacheStatus.MISS).keys());
|
|
28
22
|
// put cache hits in result map
|
|
29
23
|
const results = new Map();
|
|
30
24
|
cacheLoadResults.forEach((cacheLoadResult, cacheKey) => {
|
|
31
|
-
if (cacheLoadResult.status ===
|
|
25
|
+
if (cacheLoadResult.status === CacheStatus.HIT) {
|
|
32
26
|
const loadParams = cacheKeyToLoadParamsMap.get(cacheKey);
|
|
33
|
-
(
|
|
27
|
+
invariant(loadParams !== undefined, 'load params should be in cache key map');
|
|
34
28
|
results.set(loadParams, cacheLoadResult.item);
|
|
35
29
|
}
|
|
36
30
|
});
|
|
@@ -38,7 +32,7 @@ class GenericSecondaryEntityCache {
|
|
|
38
32
|
if (cacheKeysToFetch.length > 0) {
|
|
39
33
|
const loadParamsToFetch = cacheKeysToFetch.map((cacheKey) => {
|
|
40
34
|
const loadParams = cacheKeyToLoadParamsMap.get(cacheKey);
|
|
41
|
-
(
|
|
35
|
+
invariant(loadParams !== undefined, 'load params should be in cache key map');
|
|
42
36
|
return loadParams;
|
|
43
37
|
});
|
|
44
38
|
const fetchResults = await fetcher(loadParamsToFetch);
|
|
@@ -73,5 +67,3 @@ class GenericSecondaryEntityCache {
|
|
|
73
67
|
return this.cacher.invalidateManyAsync(cacheKeys);
|
|
74
68
|
}
|
|
75
69
|
}
|
|
76
|
-
exports.GenericSecondaryEntityCache = GenericSecondaryEntityCache;
|
|
77
|
-
//# sourceMappingURL=GenericSecondaryEntityCache.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces';
|
|
2
|
-
import { CacheLoadResult } from './internal/ReadThroughEntityCache';
|
|
1
|
+
import type { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces.ts';
|
|
2
|
+
import type { CacheLoadResult } from './internal/ReadThroughEntityCache.ts';
|
|
3
3
|
/**
|
|
4
4
|
* A cache adapter is an interface by which objects can be
|
|
5
5
|
* cached, fetched from cache, and removed from cache (invalidated).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EntityConfiguration } from './EntityConfiguration';
|
|
2
|
-
import { IEntityCacheAdapter } from './IEntityCacheAdapter';
|
|
1
|
+
import type { EntityConfiguration } from './EntityConfiguration.ts';
|
|
2
|
+
import type { IEntityCacheAdapter } from './IEntityCacheAdapter.ts';
|
|
3
3
|
/**
|
|
4
4
|
* A cache adapter provider vends cache adapters for a particular cache adapter type.
|
|
5
5
|
* Allows for passing global configuration to cache adapters.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EntityConfiguration } from './EntityConfiguration';
|
|
2
|
-
import { EntityDatabaseAdapter } from './EntityDatabaseAdapter';
|
|
1
|
+
import type { EntityConfiguration } from './EntityConfiguration.ts';
|
|
2
|
+
import type { EntityDatabaseAdapter } from './EntityDatabaseAdapter.ts';
|
|
3
3
|
/**
|
|
4
4
|
* A database adapter provider vends database adapters for a particular database adapter type.
|
|
5
5
|
* Allows for passing global configuration to databse adapters, making testing easier.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces';
|
|
2
|
-
import { CacheLoadResult } from './internal/ReadThroughEntityCache';
|
|
1
|
+
import type { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces.ts';
|
|
2
|
+
import type { CacheLoadResult } from './internal/ReadThroughEntityCache.ts';
|
|
3
3
|
/**
|
|
4
4
|
* A generic cacher stores and loads key-value pairs. It also supports negative caching - it stores the absence
|
|
5
5
|
* of keys that don't exist in the backing datastore. It is also responsible for cache key creation.
|