@expo/entity 0.60.0 → 0.61.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 -8
- package/build/src/EntityInvalidationUtils.js +4 -9
- package/build/src/EntityLoader.d.ts +7 -7
- package/build/src/EntityLoader.js +3 -8
- package/build/src/EntityLoaderFactory.d.ts +10 -10
- 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 +9 -9
- 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 +8 -8
- 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 +7 -6
- 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 +10 -10
- package/src/EntityLoader.ts +7 -7
- package/src/EntityLoaderFactory.ts +13 -10
- 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 +11 -11
- package/src/ViewerContext.ts +8 -8
- package/src/ViewerScopedEntityCompanion.ts +8 -8
- package/src/ViewerScopedEntityCompanionProvider.ts +6 -6
- package/src/ViewerScopedEntityLoaderFactory.ts +11 -8
- 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 -18
- 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,15 +1,16 @@
|
|
|
1
|
-
import { IEntityClass } from './Entity';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
1
|
+
import type { IEntityClass } from './Entity.ts';
|
|
2
|
+
import type { IPrivacyPolicyClass } from './EntityCompanion.ts';
|
|
3
|
+
import { EntityCompanion } from './EntityCompanion.ts';
|
|
4
|
+
import type { EntityConfiguration } from './EntityConfiguration.ts';
|
|
5
|
+
import type { EntityMutationTriggerConfiguration } from './EntityMutationTriggerConfiguration.ts';
|
|
6
|
+
import type { EntityMutationValidatorConfiguration } from './EntityMutationValidatorConfiguration.ts';
|
|
7
|
+
import type { EntityPrivacyPolicy } from './EntityPrivacyPolicy.ts';
|
|
8
|
+
import type { EntityQueryContextProvider } from './EntityQueryContextProvider.ts';
|
|
9
|
+
import type { IEntityCacheAdapterProvider } from './IEntityCacheAdapterProvider.ts';
|
|
10
|
+
import type { IEntityDatabaseAdapterProvider } from './IEntityDatabaseAdapterProvider.ts';
|
|
11
|
+
import type { ReadonlyEntity } from './ReadonlyEntity.ts';
|
|
12
|
+
import type { ViewerContext } from './ViewerContext.ts';
|
|
13
|
+
import type { IEntityMetricsAdapter } from './metrics/IEntityMetricsAdapter.ts';
|
|
13
14
|
/**
|
|
14
15
|
* Backing database and transaction type for an entity. The definitions and implementations
|
|
15
16
|
* are provided by injection in the root EntityCompanionProvider to allow for mocking and sharing.
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EntityCompanionProvider = void 0;
|
|
7
|
-
const invariant_1 = __importDefault(require("invariant"));
|
|
8
|
-
const EntityCompanion_1 = require("./EntityCompanion");
|
|
9
|
-
const EntityTableDataCoordinator_1 = require("./internal/EntityTableDataCoordinator");
|
|
10
|
-
const maps_1 = require("./utils/collections/maps");
|
|
1
|
+
import invariant from 'invariant';
|
|
2
|
+
import { EntityCompanion } from "./EntityCompanion.js";
|
|
3
|
+
import { EntityTableDataCoordinator } from "./internal/EntityTableDataCoordinator.js";
|
|
4
|
+
import { computeIfAbsent } from "./utils/collections/maps.js";
|
|
11
5
|
/**
|
|
12
6
|
* An instance of the Entity framework.
|
|
13
7
|
*
|
|
@@ -17,7 +11,7 @@ const maps_1 = require("./utils/collections/maps");
|
|
|
17
11
|
* Internally, this is a lazy entity companion factory that instantiates and caches one
|
|
18
12
|
* EntityCompanion for each type of Entity.
|
|
19
13
|
*/
|
|
20
|
-
class EntityCompanionProvider {
|
|
14
|
+
export class EntityCompanionProvider {
|
|
21
15
|
metricsAdapter;
|
|
22
16
|
databaseAdapterFlavors;
|
|
23
17
|
cacheAdapterFlavors;
|
|
@@ -45,26 +39,24 @@ class EntityCompanionProvider {
|
|
|
45
39
|
* @param entityClass - entity class to load
|
|
46
40
|
*/
|
|
47
41
|
getCompanionForEntity(entityClass) {
|
|
48
|
-
const entityCompanionDefinition =
|
|
42
|
+
const entityCompanionDefinition = computeIfAbsent(this.companionDefinitionMap, entityClass.name, () => entityClass.defineCompanionDefinition());
|
|
49
43
|
const tableDataCoordinator = this.getTableDataCoordinatorForEntity(entityCompanionDefinition.entityConfiguration, entityClass.name);
|
|
50
|
-
return
|
|
51
|
-
return new
|
|
44
|
+
return computeIfAbsent(this.companionMap, entityClass.name, () => {
|
|
45
|
+
return new EntityCompanion(this, entityCompanionDefinition, tableDataCoordinator, this.metricsAdapter);
|
|
52
46
|
});
|
|
53
47
|
}
|
|
54
48
|
getQueryContextProviderForDatabaseAdapterFlavor(databaseAdapterFlavor) {
|
|
55
49
|
const entityDatabaseAdapterFlavor = this.databaseAdapterFlavors.get(databaseAdapterFlavor);
|
|
56
|
-
(
|
|
50
|
+
invariant(entityDatabaseAdapterFlavor, `No database adapter configuration found for flavor: ${databaseAdapterFlavor}`);
|
|
57
51
|
return entityDatabaseAdapterFlavor.queryContextProvider;
|
|
58
52
|
}
|
|
59
53
|
getTableDataCoordinatorForEntity(entityConfiguration, entityClassName) {
|
|
60
|
-
return
|
|
54
|
+
return computeIfAbsent(this.tableDataCoordinatorMap, entityConfiguration.tableName, () => {
|
|
61
55
|
const entityDatabaseAdapterFlavor = this.databaseAdapterFlavors.get(entityConfiguration.databaseAdapterFlavor);
|
|
62
|
-
(
|
|
56
|
+
invariant(entityDatabaseAdapterFlavor, `No database adapter configuration found for flavor: ${entityConfiguration.databaseAdapterFlavor}`);
|
|
63
57
|
const entityCacheAdapterFlavor = this.cacheAdapterFlavors.get(entityConfiguration.cacheAdapterFlavor);
|
|
64
|
-
(
|
|
65
|
-
return new
|
|
58
|
+
invariant(entityCacheAdapterFlavor, `No cache adapter configuration found for flavor: ${entityConfiguration.cacheAdapterFlavor}`);
|
|
59
|
+
return new EntityTableDataCoordinator(entityConfiguration, entityDatabaseAdapterFlavor.adapterProvider, entityCacheAdapterFlavor.cacheAdapterProvider, entityDatabaseAdapterFlavor.queryContextProvider, this.metricsAdapter, entityClassName);
|
|
66
60
|
});
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
|
-
exports.EntityCompanionProvider = EntityCompanionProvider;
|
|
70
|
-
//# sourceMappingURL=EntityCompanionProvider.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IEntityClass } from './Entity';
|
|
2
|
-
import { CacheAdapterFlavor, DatabaseAdapterFlavor } from './EntityCompanionProvider';
|
|
3
|
-
import { EntityFieldDefinition } from './EntityFieldDefinition';
|
|
4
|
-
import { CompositeFieldHolder } from './internal/CompositeFieldHolder';
|
|
1
|
+
import type { IEntityClass } from './Entity.ts';
|
|
2
|
+
import type { CacheAdapterFlavor, DatabaseAdapterFlavor } from './EntityCompanionProvider.ts';
|
|
3
|
+
import type { EntityFieldDefinition } from './EntityFieldDefinition.ts';
|
|
4
|
+
import { CompositeFieldHolder } from './internal/CompositeFieldHolder.ts';
|
|
5
5
|
/**
|
|
6
6
|
* A composite field is an unordered set of fields by which entities can be loaded in a batched
|
|
7
7
|
* and (optionally) cached manner akin to how normal fieldName loads are batched and (optionally) cached.
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EntityConfiguration = exports.CompositeFieldInfo = void 0;
|
|
7
|
-
const invariant_1 = __importDefault(require("invariant"));
|
|
8
|
-
const CompositeFieldHolder_1 = require("./internal/CompositeFieldHolder");
|
|
9
|
-
const maps_1 = require("./utils/collections/maps");
|
|
1
|
+
import invariant from 'invariant';
|
|
2
|
+
import { CompositeFieldHolder } from "./internal/CompositeFieldHolder.js";
|
|
3
|
+
import { invertMap, mapMap, reduceMap } from "./utils/collections/maps.js";
|
|
10
4
|
/**
|
|
11
5
|
* Helper class to validate and store composite field information.
|
|
12
6
|
*/
|
|
13
|
-
class CompositeFieldInfo {
|
|
7
|
+
export class CompositeFieldInfo {
|
|
14
8
|
compositeFieldInfoMap;
|
|
15
9
|
constructor(compositeFieldsDefinitions) {
|
|
16
10
|
this.compositeFieldInfoMap = new Map(compositeFieldsDefinitions.map((keyDefinition) => {
|
|
17
|
-
(
|
|
18
|
-
(
|
|
19
|
-
const compositeFieldHolder = new
|
|
11
|
+
invariant(keyDefinition.compositeField.length >= 2, 'Composite field must have at least two sub-fields');
|
|
12
|
+
invariant(keyDefinition.compositeField.length === new Set(keyDefinition.compositeField).size, 'Composite field must have unique sub-fields');
|
|
13
|
+
const compositeFieldHolder = new CompositeFieldHolder(keyDefinition.compositeField);
|
|
20
14
|
return [
|
|
21
15
|
compositeFieldHolder.serialize(),
|
|
22
16
|
{ compositeFieldHolder, cache: keyDefinition.cache ?? false },
|
|
@@ -24,23 +18,22 @@ class CompositeFieldInfo {
|
|
|
24
18
|
}));
|
|
25
19
|
}
|
|
26
20
|
getCompositeFieldHolderForCompositeField(compositeField) {
|
|
27
|
-
return this.compositeFieldInfoMap.get(new
|
|
21
|
+
return this.compositeFieldInfoMap.get(new CompositeFieldHolder(compositeField).serialize())?.compositeFieldHolder;
|
|
28
22
|
}
|
|
29
23
|
getAllCompositeFieldHolders() {
|
|
30
24
|
return Array.from(this.compositeFieldInfoMap.values()).map((v) => v.compositeFieldHolder);
|
|
31
25
|
}
|
|
32
26
|
canCacheCompositeField(compositeField) {
|
|
33
|
-
const compositeFieldInfo = this.compositeFieldInfoMap.get(new
|
|
34
|
-
(
|
|
27
|
+
const compositeFieldInfo = this.compositeFieldInfoMap.get(new CompositeFieldHolder(compositeField).serialize());
|
|
28
|
+
invariant(compositeFieldInfo, `Composite field (${compositeField.join(',')}) not found in entity configuration`);
|
|
35
29
|
return compositeFieldInfo.cache;
|
|
36
30
|
}
|
|
37
31
|
}
|
|
38
|
-
exports.CompositeFieldInfo = CompositeFieldInfo;
|
|
39
32
|
/**
|
|
40
33
|
* The data storage configuration for a type of Entity. Contains information relating to IDs,
|
|
41
34
|
* cachable fields, field mappings, and types of cache and database adapter.
|
|
42
35
|
*/
|
|
43
|
-
class EntityConfiguration {
|
|
36
|
+
export class EntityConfiguration {
|
|
44
37
|
idField;
|
|
45
38
|
tableName;
|
|
46
39
|
cacheableKeys;
|
|
@@ -66,7 +59,7 @@ class EntityConfiguration {
|
|
|
66
59
|
this.cacheableKeys = EntityConfiguration.computeCacheableKeys(this.schema);
|
|
67
60
|
this.compositeFieldInfo = new CompositeFieldInfo(compositeFieldDefinitions ?? []);
|
|
68
61
|
this.entityToDBFieldsKeyMapping = EntityConfiguration.computeEntityToDBFieldsKeyMapping(this.schema);
|
|
69
|
-
this.dbToEntityFieldsKeyMapping =
|
|
62
|
+
this.dbToEntityFieldsKeyMapping = invertMap(this.entityToDBFieldsKeyMapping);
|
|
70
63
|
}
|
|
71
64
|
static validateSchema(schema) {
|
|
72
65
|
const disallowedFieldsKeys = Object.getOwnPropertyNames(Object.prototype);
|
|
@@ -77,7 +70,7 @@ class EntityConfiguration {
|
|
|
77
70
|
}
|
|
78
71
|
}
|
|
79
72
|
static computeCacheableKeys(schema) {
|
|
80
|
-
return
|
|
73
|
+
return reduceMap(schema, (acc, v, k) => {
|
|
81
74
|
if (v.cache) {
|
|
82
75
|
acc.add(k);
|
|
83
76
|
}
|
|
@@ -85,8 +78,6 @@ class EntityConfiguration {
|
|
|
85
78
|
}, new Set());
|
|
86
79
|
}
|
|
87
80
|
static computeEntityToDBFieldsKeyMapping(schema) {
|
|
88
|
-
return
|
|
81
|
+
return mapMap(schema, (v) => v.columnName);
|
|
89
82
|
}
|
|
90
83
|
}
|
|
91
|
-
exports.EntityConfiguration = EntityConfiguration;
|
|
92
|
-
//# sourceMappingURL=EntityConfiguration.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Result } from '@expo/results';
|
|
2
|
-
import { IEntityClass } from './Entity';
|
|
3
|
-
import { EntityConfiguration } from './EntityConfiguration';
|
|
4
|
-
import { EntityPrivacyPolicy, EntityPrivacyPolicyEvaluationContext } from './EntityPrivacyPolicy';
|
|
5
|
-
import { EntityQueryContext } from './EntityQueryContext';
|
|
6
|
-
import { ReadonlyEntity } from './ReadonlyEntity';
|
|
7
|
-
import { ViewerContext } from './ViewerContext';
|
|
8
|
-
import { IEntityMetricsAdapter } from './metrics/IEntityMetricsAdapter';
|
|
1
|
+
import type { Result } from '@expo/results';
|
|
2
|
+
import type { IEntityClass } from './Entity.ts';
|
|
3
|
+
import type { EntityConfiguration } from './EntityConfiguration.ts';
|
|
4
|
+
import type { EntityPrivacyPolicy, EntityPrivacyPolicyEvaluationContext } 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
|
+
import type { IEntityMetricsAdapter } from './metrics/IEntityMetricsAdapter.ts';
|
|
9
9
|
/**
|
|
10
10
|
* Common entity loader utilities for entity construction and authorization.
|
|
11
11
|
* Methods are exposed publicly since in rare cases they may need to be called manually.
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const results_1 = require("@expo/results");
|
|
8
|
-
const invariant_1 = __importDefault(require("invariant"));
|
|
9
|
-
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
10
|
-
const entityUtils_1 = require("./entityUtils");
|
|
11
|
-
const EntityInvalidFieldValueError_1 = require("./errors/EntityInvalidFieldValueError");
|
|
12
|
-
const maps_1 = require("./utils/collections/maps");
|
|
1
|
+
import nullthrows from '@expo/nullthrows';
|
|
2
|
+
import { asyncResult, result } from '@expo/results';
|
|
3
|
+
import invariant from 'invariant';
|
|
4
|
+
import { pick } from "./entityUtils.js";
|
|
5
|
+
import { EntityInvalidFieldValueError } from "./errors/EntityInvalidFieldValueError.js";
|
|
6
|
+
import { mapMapAsync } from "./utils/collections/maps.js";
|
|
13
7
|
/**
|
|
14
8
|
* Common entity loader utilities for entity construction and authorization.
|
|
15
9
|
* Methods are exposed publicly since in rare cases they may need to be called manually.
|
|
16
10
|
*/
|
|
17
|
-
class EntityConstructionUtils {
|
|
11
|
+
export class EntityConstructionUtils {
|
|
18
12
|
viewerContext;
|
|
19
13
|
queryContext;
|
|
20
14
|
privacyPolicyEvaluationContext;
|
|
@@ -41,9 +35,9 @@ class EntityConstructionUtils {
|
|
|
41
35
|
*/
|
|
42
36
|
constructEntity(fieldsObject) {
|
|
43
37
|
const idField = this.entityConfiguration.idField;
|
|
44
|
-
const id = (
|
|
38
|
+
const id = nullthrows(fieldsObject[idField], 'must provide ID to create an entity');
|
|
45
39
|
const entitySelectedFields = this.entitySelectedFields ?? Array.from(this.entityConfiguration.schema.keys());
|
|
46
|
-
const selectedFields =
|
|
40
|
+
const selectedFields = pick(fieldsObject, entitySelectedFields);
|
|
47
41
|
return new this.entityClass({
|
|
48
42
|
viewerContext: this.viewerContext,
|
|
49
43
|
id: id,
|
|
@@ -58,7 +52,7 @@ class EntityConstructionUtils {
|
|
|
58
52
|
* @param map - map from an arbitrary key type to an array of entity field objects
|
|
59
53
|
*/
|
|
60
54
|
async constructAndAuthorizeEntitiesAsync(map) {
|
|
61
|
-
return await
|
|
55
|
+
return await mapMapAsync(map, async (fieldObjects) => {
|
|
62
56
|
return await this.constructAndAuthorizeEntitiesArrayAsync(fieldObjects);
|
|
63
57
|
});
|
|
64
58
|
}
|
|
@@ -76,7 +70,7 @@ class EntityConstructionUtils {
|
|
|
76
70
|
if (!uncheckedEntityResult.ok) {
|
|
77
71
|
return uncheckedEntityResult;
|
|
78
72
|
}
|
|
79
|
-
return await
|
|
73
|
+
return await asyncResult(this.privacyPolicy.authorizeReadAsync(this.viewerContext, this.queryContext, this.privacyPolicyEvaluationContext, uncheckedEntityResult.value, this.metricsAdapter));
|
|
80
74
|
}
|
|
81
75
|
async constructAndAuthorizeEntityAsync(fieldsObject) {
|
|
82
76
|
const uncheckedEntityResult = this.tryConstructEntity(fieldsObject);
|
|
@@ -91,11 +85,11 @@ class EntityConstructionUtils {
|
|
|
91
85
|
*/
|
|
92
86
|
validateFieldAndValues(fieldName, fieldValues) {
|
|
93
87
|
const fieldDefinition = this.entityConfiguration.schema.get(fieldName);
|
|
94
|
-
(
|
|
88
|
+
invariant(fieldDefinition, `must have field definition for field = ${String(fieldName)}`);
|
|
95
89
|
for (const fieldValue of fieldValues) {
|
|
96
90
|
const isInputValid = fieldDefinition.validateInputValue(fieldValue);
|
|
97
91
|
if (!isInputValid) {
|
|
98
|
-
throw new
|
|
92
|
+
throw new EntityInvalidFieldValueError(this.entityClass, fieldName, fieldValue);
|
|
99
93
|
}
|
|
100
94
|
}
|
|
101
95
|
}
|
|
@@ -104,15 +98,13 @@ class EntityConstructionUtils {
|
|
|
104
98
|
}
|
|
105
99
|
tryConstructEntity(fieldsObject) {
|
|
106
100
|
try {
|
|
107
|
-
return
|
|
101
|
+
return result(this.constructEntity(fieldsObject));
|
|
108
102
|
}
|
|
109
103
|
catch (e) {
|
|
110
104
|
if (!(e instanceof Error)) {
|
|
111
105
|
throw e;
|
|
112
106
|
}
|
|
113
|
-
return
|
|
107
|
+
return result(e);
|
|
114
108
|
}
|
|
115
109
|
}
|
|
116
110
|
}
|
|
117
|
-
exports.EntityConstructionUtils = EntityConstructionUtils;
|
|
118
|
-
//# sourceMappingURL=EntityConstructionUtils.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AuthorizationResultBasedCreateMutator } from './AuthorizationResultBasedEntityMutator';
|
|
2
|
-
import { EnforcingEntityCreator } from './EnforcingEntityCreator';
|
|
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 { AuthorizationResultBasedCreateMutator } from './AuthorizationResultBasedEntityMutator.ts';
|
|
2
|
+
import { EnforcingEntityCreator } from './EnforcingEntityCreator.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 creating entities.
|
|
10
10
|
*/
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntityCreator = void 0;
|
|
4
|
-
const EnforcingEntityCreator_1 = require("./EnforcingEntityCreator");
|
|
1
|
+
import { EnforcingEntityCreator } from "./EnforcingEntityCreator.js";
|
|
5
2
|
/**
|
|
6
3
|
* The primary interface for creating entities.
|
|
7
4
|
*/
|
|
8
|
-
class EntityCreator {
|
|
5
|
+
export class EntityCreator {
|
|
9
6
|
viewerContext;
|
|
10
7
|
queryContext;
|
|
11
8
|
entityClass;
|
|
@@ -19,7 +16,7 @@ class EntityCreator {
|
|
|
19
16
|
* guaranteed to be successful and will throw otherwise.
|
|
20
17
|
*/
|
|
21
18
|
enforcing() {
|
|
22
|
-
return new
|
|
19
|
+
return new EnforcingEntityCreator(this.withAuthorizationResults());
|
|
23
20
|
}
|
|
24
21
|
/**
|
|
25
22
|
* Authorization-result-based entity creator. All creates through this
|
|
@@ -33,5 +30,3 @@ class EntityCreator {
|
|
|
33
30
|
.forCreate(this.queryContext);
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
|
-
exports.EntityCreator = EntityCreator;
|
|
37
|
-
//# sourceMappingURL=EntityCreator.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EntityConfiguration } from './EntityConfiguration';
|
|
2
|
-
import { EntityQueryContext } from './EntityQueryContext';
|
|
3
|
-
import { FieldTransformerMap } from './internal/EntityFieldTransformationUtils';
|
|
4
|
-
import { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces';
|
|
1
|
+
import type { EntityConfiguration } from './EntityConfiguration.ts';
|
|
2
|
+
import type { EntityQueryContext } from './EntityQueryContext.ts';
|
|
3
|
+
import type { FieldTransformerMap } from './internal/EntityFieldTransformationUtils.ts';
|
|
4
|
+
import type { IEntityLoadKey, IEntityLoadValue } from './internal/EntityLoadInterfaces.ts';
|
|
5
5
|
/**
|
|
6
6
|
* A database adapter is an interface by which entity objects can be
|
|
7
7
|
* fetched, inserted, updated, and deleted from a database. This base class
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EntityDatabaseAdapter = void 0;
|
|
7
|
-
const invariant_1 = __importDefault(require("invariant"));
|
|
8
|
-
const EntityDatabaseAdapterError_1 = require("./errors/EntityDatabaseAdapterError");
|
|
9
|
-
const EntityFieldTransformationUtils_1 = require("./internal/EntityFieldTransformationUtils");
|
|
1
|
+
import invariant from 'invariant';
|
|
2
|
+
import { EntityDatabaseAdapterEmptyInsertResultError, EntityDatabaseAdapterEmptyUpdateResultError, EntityDatabaseAdapterExcessiveDeleteResultError, EntityDatabaseAdapterExcessiveInsertResultError, EntityDatabaseAdapterExcessiveUpdateResultError, } from "./errors/EntityDatabaseAdapterError.js";
|
|
3
|
+
import { getDatabaseFieldForEntityField, transformDatabaseObjectToFields, transformFieldsToDatabaseObject, } from "./internal/EntityFieldTransformationUtils.js";
|
|
10
4
|
/**
|
|
11
5
|
* A database adapter is an interface by which entity objects can be
|
|
12
6
|
* fetched, inserted, updated, and deleted from a database. This base class
|
|
13
7
|
* handles all entity field transformation. Subclasses are responsible for
|
|
14
8
|
* implementing database-specific logic for a type of database.
|
|
15
9
|
*/
|
|
16
|
-
class EntityDatabaseAdapter {
|
|
10
|
+
export class EntityDatabaseAdapter {
|
|
17
11
|
entityConfiguration;
|
|
18
12
|
fieldTransformerMap;
|
|
19
13
|
constructor(entityConfiguration) {
|
|
@@ -32,16 +26,16 @@ class EntityDatabaseAdapter {
|
|
|
32
26
|
const keyDatabaseColumns = key.getDatabaseColumns(this.entityConfiguration);
|
|
33
27
|
const valueDatabaseValues = values.map((value) => key.getDatabaseValues(value));
|
|
34
28
|
const results = await this.fetchManyWhereInternalAsync(queryContext.getQueryInterface(), this.entityConfiguration.tableName, keyDatabaseColumns, valueDatabaseValues);
|
|
35
|
-
const objects = results.map((result) =>
|
|
29
|
+
const objects = results.map((result) => transformDatabaseObjectToFields(this.entityConfiguration, this.fieldTransformerMap, result));
|
|
36
30
|
const objectMap = key.vendNewLoadValueMap();
|
|
37
31
|
for (const value of values) {
|
|
38
32
|
objectMap.set(value, []);
|
|
39
33
|
}
|
|
40
34
|
objects.forEach((object) => {
|
|
41
35
|
const objectMapKeyForObject = key.getLoadValueForObject(object);
|
|
42
|
-
(
|
|
36
|
+
invariant(objectMapKeyForObject !== null, `One or more fields from the object is invalid for key ${key}; ${JSON.stringify(object)}. This may indicate a faulty database adapter implementation.`);
|
|
43
37
|
const objectList = objectMap.get(objectMapKeyForObject);
|
|
44
|
-
(
|
|
38
|
+
invariant(objectList !== undefined, `Unexpected object field value during database result transformation: ${objectMapKeyForObject}. This should never happen.`);
|
|
45
39
|
objectList.push(object);
|
|
46
40
|
});
|
|
47
41
|
return objectMap;
|
|
@@ -63,7 +57,7 @@ class EntityDatabaseAdapter {
|
|
|
63
57
|
if (!result) {
|
|
64
58
|
return null;
|
|
65
59
|
}
|
|
66
|
-
return
|
|
60
|
+
return transformDatabaseObjectToFields(this.entityConfiguration, this.fieldTransformerMap, result);
|
|
67
61
|
}
|
|
68
62
|
/**
|
|
69
63
|
* Insert an object.
|
|
@@ -73,18 +67,18 @@ class EntityDatabaseAdapter {
|
|
|
73
67
|
* @returns the inserted object
|
|
74
68
|
*/
|
|
75
69
|
async insertAsync(queryContext, object) {
|
|
76
|
-
const dbObject =
|
|
70
|
+
const dbObject = transformFieldsToDatabaseObject(this.entityConfiguration, this.fieldTransformerMap, object);
|
|
77
71
|
const results = await this.insertInternalAsync(queryContext.getQueryInterface(), this.entityConfiguration.tableName, dbObject);
|
|
78
72
|
// These should never happen with a properly implemented database adapter unless the underlying database has weird triggers
|
|
79
73
|
// or something.
|
|
80
74
|
// These errors are exposed to help application developers detect and diagnose such issues.
|
|
81
75
|
if (results.length > 1) {
|
|
82
|
-
throw new
|
|
76
|
+
throw new EntityDatabaseAdapterExcessiveInsertResultError(`Excessive results from database adapter insert: ${this.entityConfiguration.tableName}`);
|
|
83
77
|
}
|
|
84
78
|
else if (results.length === 0) {
|
|
85
|
-
throw new
|
|
79
|
+
throw new EntityDatabaseAdapterEmptyInsertResultError(`Empty results from database adapter insert: ${this.entityConfiguration.tableName}`);
|
|
86
80
|
}
|
|
87
|
-
return
|
|
81
|
+
return transformDatabaseObjectToFields(this.entityConfiguration, this.fieldTransformerMap, results[0]);
|
|
88
82
|
}
|
|
89
83
|
/**
|
|
90
84
|
* Update an object.
|
|
@@ -96,19 +90,19 @@ class EntityDatabaseAdapter {
|
|
|
96
90
|
* @returns the updated object
|
|
97
91
|
*/
|
|
98
92
|
async updateAsync(queryContext, idField, id, object) {
|
|
99
|
-
const idColumn =
|
|
100
|
-
const dbObject =
|
|
93
|
+
const idColumn = getDatabaseFieldForEntityField(this.entityConfiguration, idField);
|
|
94
|
+
const dbObject = transformFieldsToDatabaseObject(this.entityConfiguration, this.fieldTransformerMap, object);
|
|
101
95
|
const results = await this.updateInternalAsync(queryContext.getQueryInterface(), this.entityConfiguration.tableName, idColumn, id, dbObject);
|
|
102
96
|
if (results.length > 1) {
|
|
103
97
|
// This should never happen with a properly implemented database adapter unless the underlying table has a non-unique
|
|
104
98
|
// primary key column.
|
|
105
|
-
throw new
|
|
99
|
+
throw new EntityDatabaseAdapterExcessiveUpdateResultError(`Excessive results from database adapter update: ${this.entityConfiguration.tableName}(id = ${id})`);
|
|
106
100
|
}
|
|
107
101
|
else if (results.length === 0) {
|
|
108
102
|
// This happens when the object to update does not exist. It may have been deleted by another process.
|
|
109
|
-
throw new
|
|
103
|
+
throw new EntityDatabaseAdapterEmptyUpdateResultError(`Empty results from database adapter update: ${this.entityConfiguration.tableName}(id = ${id})`);
|
|
110
104
|
}
|
|
111
|
-
return
|
|
105
|
+
return transformDatabaseObjectToFields(this.entityConfiguration, this.fieldTransformerMap, results[0]);
|
|
112
106
|
}
|
|
113
107
|
/**
|
|
114
108
|
* Delete an object by ID.
|
|
@@ -118,12 +112,10 @@ class EntityDatabaseAdapter {
|
|
|
118
112
|
* @param id - the value of the ID field in the object
|
|
119
113
|
*/
|
|
120
114
|
async deleteAsync(queryContext, idField, id) {
|
|
121
|
-
const idColumn =
|
|
115
|
+
const idColumn = getDatabaseFieldForEntityField(this.entityConfiguration, idField);
|
|
122
116
|
const numDeleted = await this.deleteInternalAsync(queryContext.getQueryInterface(), this.entityConfiguration.tableName, idColumn, id);
|
|
123
117
|
if (numDeleted > 1) {
|
|
124
|
-
throw new
|
|
118
|
+
throw new EntityDatabaseAdapterExcessiveDeleteResultError(`Excessive deletions from database adapter delete: ${this.entityConfiguration.tableName}(id = ${id})`);
|
|
125
119
|
}
|
|
126
120
|
}
|
|
127
121
|
}
|
|
128
|
-
exports.EntityDatabaseAdapter = EntityDatabaseAdapter;
|
|
129
|
-
//# sourceMappingURL=EntityDatabaseAdapter.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AuthorizationResultBasedDeleteMutator } from './AuthorizationResultBasedEntityMutator';
|
|
2
|
-
import { EnforcingEntityDeleter } from './EnforcingEntityDeleter';
|
|
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 { AuthorizationResultBasedDeleteMutator } from './AuthorizationResultBasedEntityMutator.ts';
|
|
2
|
+
import { EnforcingEntityDeleter } from './EnforcingEntityDeleter.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 deleting entities.
|
|
10
10
|
*/
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntityDeleter = void 0;
|
|
4
|
-
const EnforcingEntityDeleter_1 = require("./EnforcingEntityDeleter");
|
|
1
|
+
import { EnforcingEntityDeleter } from "./EnforcingEntityDeleter.js";
|
|
5
2
|
/**
|
|
6
3
|
* The primary interface for deleting entities.
|
|
7
4
|
*/
|
|
8
|
-
class EntityDeleter {
|
|
5
|
+
export class EntityDeleter {
|
|
9
6
|
existingEntity;
|
|
10
7
|
queryContext;
|
|
11
8
|
entityClass;
|
|
@@ -19,7 +16,7 @@ class EntityDeleter {
|
|
|
19
16
|
* guaranteed to be successful and will throw otherwise.
|
|
20
17
|
*/
|
|
21
18
|
enforcing() {
|
|
22
|
-
return new
|
|
19
|
+
return new EnforcingEntityDeleter(this.withAuthorizationResults());
|
|
23
20
|
}
|
|
24
21
|
/**
|
|
25
22
|
* Authorization-result-based entity deleter. All deletes through this
|
|
@@ -34,5 +31,3 @@ class EntityDeleter {
|
|
|
34
31
|
.forDelete(this.existingEntity, this.queryContext, /* cascadingDeleteCause */ null);
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
exports.EntityDeleter = EntityDeleter;
|
|
38
|
-
//# sourceMappingURL=EntityDeleter.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IEntityClass } from './Entity';
|
|
2
|
-
import { EntityPrivacyPolicy } from './EntityPrivacyPolicy';
|
|
3
|
-
import { ReadonlyEntity } from './ReadonlyEntity';
|
|
4
|
-
import { ViewerContext } from './ViewerContext';
|
|
1
|
+
import type { IEntityClass } from './Entity.ts';
|
|
2
|
+
import type { EntityPrivacyPolicy } from './EntityPrivacyPolicy.ts';
|
|
3
|
+
import type { ReadonlyEntity } from './ReadonlyEntity.ts';
|
|
4
|
+
import type { ViewerContext } from './ViewerContext.ts';
|
|
5
5
|
export declare enum EntityEdgeDeletionBehavior {
|
|
6
6
|
/**
|
|
7
7
|
* Invalidate the cache for all entities that reference the entity
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntityFieldDefinition = exports.EntityEdgeDeletionAuthorizationInferenceBehavior = exports.EntityEdgeDeletionBehavior = void 0;
|
|
4
|
-
var EntityEdgeDeletionBehavior;
|
|
1
|
+
export var EntityEdgeDeletionBehavior;
|
|
5
2
|
(function (EntityEdgeDeletionBehavior) {
|
|
6
3
|
/**
|
|
7
4
|
* Invalidate the cache for all entities that reference the entity
|
|
@@ -30,8 +27,8 @@ var EntityEdgeDeletionBehavior;
|
|
|
30
27
|
* This will also invalidate the cached referencing entities.
|
|
31
28
|
*/
|
|
32
29
|
EntityEdgeDeletionBehavior[EntityEdgeDeletionBehavior["SET_NULL"] = 3] = "SET_NULL";
|
|
33
|
-
})(EntityEdgeDeletionBehavior || (
|
|
34
|
-
var EntityEdgeDeletionAuthorizationInferenceBehavior;
|
|
30
|
+
})(EntityEdgeDeletionBehavior || (EntityEdgeDeletionBehavior = {}));
|
|
31
|
+
export var EntityEdgeDeletionAuthorizationInferenceBehavior;
|
|
35
32
|
(function (EntityEdgeDeletionAuthorizationInferenceBehavior) {
|
|
36
33
|
/**
|
|
37
34
|
* Authorization to delete (when CASCADE_DELETE_INVALIDATE_CACHE_ONLY or CASCADE_DELETE) or update
|
|
@@ -58,12 +55,12 @@ var EntityEdgeDeletionAuthorizationInferenceBehavior;
|
|
|
58
55
|
* of canViewerDeleteAsync. Each entity being deleted will still check deletion privacy during actual deletion.
|
|
59
56
|
*/
|
|
60
57
|
EntityEdgeDeletionAuthorizationInferenceBehavior[EntityEdgeDeletionAuthorizationInferenceBehavior["ONE_IMPLIES_ALL"] = 1] = "ONE_IMPLIES_ALL";
|
|
61
|
-
})(EntityEdgeDeletionAuthorizationInferenceBehavior || (
|
|
58
|
+
})(EntityEdgeDeletionAuthorizationInferenceBehavior || (EntityEdgeDeletionAuthorizationInferenceBehavior = {}));
|
|
62
59
|
/**
|
|
63
60
|
* Definition for a field referencing a column in the underlying database. Specifies things like
|
|
64
61
|
* cache behavior and associations, and handles input validation.
|
|
65
62
|
*/
|
|
66
|
-
class EntityFieldDefinition {
|
|
63
|
+
export class EntityFieldDefinition {
|
|
67
64
|
columnName;
|
|
68
65
|
cache;
|
|
69
66
|
association;
|
|
@@ -90,5 +87,3 @@ class EntityFieldDefinition {
|
|
|
90
87
|
return this.validateInputValueInternal(value);
|
|
91
88
|
}
|
|
92
89
|
}
|
|
93
|
-
exports.EntityFieldDefinition = EntityFieldDefinition;
|
|
94
|
-
//# sourceMappingURL=EntityFieldDefinition.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { EntityFieldDefinitionOptions, EntityFieldDefinitionOptionsExplicitCache } from './EntityFieldDefinition.ts';
|
|
2
|
+
import { EntityFieldDefinition } from './EntityFieldDefinition.ts';
|
|
2
3
|
/**
|
|
3
4
|
* EntityFieldDefinition for a column with a JS string type.
|
|
4
5
|
*/
|