@expo/entity 0.34.0 → 0.36.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/AuthorizationResultBasedEntityLoader.d.ts +128 -0
- package/build/AuthorizationResultBasedEntityLoader.js +196 -0
- package/build/AuthorizationResultBasedEntityLoader.js.map +1 -0
- package/build/ComposedEntityCacheAdapter.js +1 -0
- package/build/ComposedEntityCacheAdapter.js.map +1 -1
- package/build/ComposedSecondaryEntityCache.js +1 -0
- package/build/ComposedSecondaryEntityCache.js.map +1 -1
- package/build/EnforcingEntityLoader.d.ts +5 -4
- package/build/EnforcingEntityLoader.js +4 -2
- package/build/EnforcingEntityLoader.js.map +1 -1
- package/build/Entity.d.ts +4 -31
- package/build/Entity.js +19 -46
- package/build/Entity.js.map +1 -1
- package/build/EntityAssociationLoader.d.ts +9 -9
- package/build/EntityAssociationLoader.js +37 -12
- package/build/EntityAssociationLoader.js.map +1 -1
- package/build/EntityCompanion.js +9 -1
- package/build/EntityCompanion.js.map +1 -1
- package/build/EntityCompanionProvider.d.ts +3 -1
- package/build/EntityCompanionProvider.js +10 -4
- package/build/EntityCompanionProvider.js.map +1 -1
- package/build/EntityConfiguration.d.ts +2 -1
- package/build/EntityConfiguration.js +19 -1
- package/build/EntityConfiguration.js.map +1 -1
- package/build/EntityDatabaseAdapter.d.ts +2 -2
- package/build/EntityDatabaseAdapter.js +5 -3
- package/build/EntityDatabaseAdapter.js.map +1 -1
- package/build/EntityFieldDefinition.d.ts +21 -10
- package/build/EntityFieldDefinition.js +8 -9
- package/build/EntityFieldDefinition.js.map +1 -1
- package/build/EntityFields.d.ts +10 -0
- package/build/EntityFields.js +15 -1
- package/build/EntityFields.js.map +1 -1
- package/build/EntityLoader.d.ts +12 -125
- package/build/EntityLoader.js +24 -239
- package/build/EntityLoader.js.map +1 -1
- package/build/EntityLoaderFactory.d.ts +1 -1
- package/build/EntityLoaderFactory.js +3 -0
- package/build/EntityLoaderFactory.js.map +1 -1
- package/build/EntityLoaderUtils.d.ts +58 -0
- package/build/EntityLoaderUtils.js +109 -0
- package/build/EntityLoaderUtils.js.map +1 -0
- package/build/EntityMutator.d.ts +1 -0
- package/build/EntityMutator.js +71 -56
- package/build/EntityMutator.js.map +1 -1
- package/build/EntityMutatorFactory.js +9 -0
- package/build/EntityMutatorFactory.js.map +1 -1
- package/build/EntityPrivacyPolicy.d.ts +11 -5
- package/build/EntityPrivacyPolicy.js +5 -7
- package/build/EntityPrivacyPolicy.js.map +1 -1
- package/build/EntityQueryContext.d.ts +2 -1
- package/build/EntityQueryContext.js +11 -6
- package/build/EntityQueryContext.js.map +1 -1
- package/build/EntityQueryContextProvider.d.ts +1 -1
- package/build/EntityQueryContextProvider.js +1 -1
- package/build/EntityQueryContextProvider.js.map +1 -1
- package/build/EntitySecondaryCacheLoader.js +5 -1
- package/build/EntitySecondaryCacheLoader.js.map +1 -1
- package/build/GenericEntityCacheAdapter.js +1 -0
- package/build/GenericEntityCacheAdapter.js.map +1 -1
- package/build/GenericSecondaryEntityCache.js +2 -0
- package/build/GenericSecondaryEntityCache.js.map +1 -1
- package/build/IEntityCacheAdapterProvider.d.ts +1 -1
- package/build/IEntityDatabaseAdapterProvider.d.ts +1 -1
- package/build/ReadonlyEntity.d.ts +1 -1
- package/build/ReadonlyEntity.js +9 -2
- package/build/ReadonlyEntity.js.map +1 -1
- package/build/ViewerContext.d.ts +2 -2
- package/build/ViewerContext.js +5 -3
- package/build/ViewerContext.js.map +1 -1
- package/build/ViewerScopedEntityCompanion.js +2 -0
- package/build/ViewerScopedEntityCompanion.js.map +1 -1
- package/build/ViewerScopedEntityCompanionProvider.d.ts +0 -1
- package/build/ViewerScopedEntityCompanionProvider.js +2 -1
- package/build/ViewerScopedEntityCompanionProvider.js.map +1 -1
- package/build/ViewerScopedEntityLoaderFactory.d.ts +1 -1
- package/build/ViewerScopedEntityLoaderFactory.js +2 -0
- package/build/ViewerScopedEntityLoaderFactory.js.map +1 -1
- package/build/ViewerScopedEntityMutatorFactory.js +2 -0
- package/build/ViewerScopedEntityMutatorFactory.js.map +1 -1
- package/build/__tests__/ComposedCacheAdapter-test.js +2 -0
- package/build/__tests__/ComposedCacheAdapter-test.js.map +1 -1
- package/build/__tests__/ComposedSecondaryEntityCache-test.js +1 -0
- package/build/__tests__/ComposedSecondaryEntityCache-test.js.map +1 -1
- package/build/__tests__/EnforcingEntityLoader-test.js +101 -113
- package/build/__tests__/EnforcingEntityLoader-test.js.map +1 -1
- package/build/__tests__/Entity-test.js +5 -137
- package/build/__tests__/Entity-test.js.map +1 -1
- package/build/__tests__/EntityAssociationLoader-test.js +37 -65
- package/build/__tests__/EntityAssociationLoader-test.js.map +1 -1
- package/build/__tests__/EntityCommonUseCases-test.js +31 -37
- package/build/__tests__/EntityCommonUseCases-test.js.map +1 -1
- package/build/__tests__/EntityCompanion-test.js +26 -3
- package/build/__tests__/EntityCompanion-test.js.map +1 -1
- package/build/__tests__/EntityConfiguration-test.js +103 -0
- package/build/__tests__/EntityConfiguration-test.js.map +1 -0
- package/build/__tests__/EntityDatabaseAdapter-test.js +6 -0
- package/build/__tests__/EntityDatabaseAdapter-test.js.map +1 -1
- package/build/__tests__/EntityEdges-test.js +89 -80
- package/build/__tests__/EntityEdges-test.js.map +1 -1
- package/build/__tests__/EntityFields-test.js +6 -0
- package/build/__tests__/EntityFields-test.js.map +1 -1
- package/build/__tests__/EntityLoader-constructor-test.js +17 -18
- package/build/__tests__/EntityLoader-constructor-test.js.map +1 -1
- package/build/__tests__/EntityLoader-test.js +93 -41
- package/build/__tests__/EntityLoader-test.js.map +1 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +18 -21
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +1 -1
- package/build/__tests__/EntityMutator-test.js +74 -29
- package/build/__tests__/EntityMutator-test.js.map +1 -1
- package/build/__tests__/EntityPrivacyPolicy-test.js +77 -59
- package/build/__tests__/EntityPrivacyPolicy-test.js.map +1 -1
- package/build/__tests__/EntityQueryContext-test.js +9 -0
- package/build/__tests__/EntityQueryContext-test.js.map +1 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.js +10 -10
- package/build/__tests__/EntitySecondaryCacheLoader-test.js.map +1 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.js +59 -74
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +1 -1
- package/build/__tests__/ReadonlyEntity-test.js +13 -13
- package/build/__tests__/ReadonlyEntity-test.js.map +1 -1
- package/build/__tests__/ViewerContext-test.js +2 -2
- package/build/__tests__/ViewerContext-test.js.map +1 -1
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +26 -28
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +25 -30
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +1 -1
- package/build/entityUtils.d.ts +1 -1
- package/build/entityUtils.js.map +1 -1
- package/build/errors/EntityCacheAdapterError.js +2 -5
- package/build/errors/EntityCacheAdapterError.js.map +1 -1
- package/build/errors/EntityDatabaseAdapterError.js +14 -35
- package/build/errors/EntityDatabaseAdapterError.js.map +1 -1
- package/build/errors/EntityError.js +1 -0
- package/build/errors/EntityError.js.map +1 -1
- package/build/errors/EntityInvalidFieldValueError.js +2 -2
- package/build/errors/EntityInvalidFieldValueError.js.map +1 -1
- package/build/errors/EntityNotAuthorizedError.js +3 -2
- package/build/errors/EntityNotAuthorizedError.js.map +1 -1
- package/build/errors/EntityNotFoundError.js +2 -2
- package/build/errors/EntityNotFoundError.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/internal/EntityDataManager.d.ts +1 -1
- package/build/internal/EntityDataManager.js +7 -2
- package/build/internal/EntityDataManager.js.map +1 -1
- package/build/internal/EntityFieldTransformationUtils.d.ts +5 -5
- package/build/internal/EntityFieldTransformationUtils.js +5 -8
- package/build/internal/EntityFieldTransformationUtils.js.map +1 -1
- package/build/internal/EntityTableDataCoordinator.d.ts +1 -1
- package/build/internal/EntityTableDataCoordinator.js +5 -0
- package/build/internal/EntityTableDataCoordinator.js.map +1 -1
- package/build/internal/ReadThroughEntityCache.d.ts +1 -1
- package/build/internal/ReadThroughEntityCache.js +2 -0
- package/build/internal/ReadThroughEntityCache.js.map +1 -1
- package/build/internal/__tests__/EntityDataManager-test.js +11 -11
- package/build/internal/__tests__/EntityDataManager-test.js.map +1 -1
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js +6 -2
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js.map +1 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.js +33 -0
- package/build/internal/__tests__/ReadThroughEntityCache-test.js.map +1 -1
- package/build/metrics/IEntityMetricsAdapter.d.ts +1 -1
- package/build/rules/AlwaysAllowPrivacyPolicyRule.d.ts +1 -1
- package/build/rules/AlwaysAllowPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysDenyPrivacyPolicyRule.d.ts +1 -1
- package/build/rules/AlwaysDenyPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysSkipPrivacyPolicyRule.d.ts +1 -1
- package/build/rules/AlwaysSkipPrivacyPolicyRule.js.map +1 -1
- package/build/rules/PrivacyPolicyRule.d.ts +1 -1
- package/build/rules/PrivacyPolicyRule.js.map +1 -1
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js.map +1 -1
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js.map +1 -1
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js.map +1 -1
- package/build/testfixtures/DateIDTestEntity.js +12 -15
- package/build/testfixtures/DateIDTestEntity.js.map +1 -1
- package/build/testfixtures/SimpleTestEntity.d.ts +8 -8
- package/build/testfixtures/SimpleTestEntity.js +12 -15
- package/build/testfixtures/SimpleTestEntity.js.map +1 -1
- package/build/testfixtures/TestEntity.d.ts +12 -12
- package/build/testfixtures/TestEntity.js +12 -15
- package/build/testfixtures/TestEntity.js.map +1 -1
- package/build/testfixtures/TestEntity2.d.ts +8 -8
- package/build/testfixtures/TestEntity2.js +12 -15
- package/build/testfixtures/TestEntity2.js.map +1 -1
- package/build/testfixtures/TestEntityNumberKey.js +12 -15
- package/build/testfixtures/TestEntityNumberKey.js.map +1 -1
- package/build/testfixtures/TestEntityWithMutationTriggers.d.ts +36 -0
- package/build/testfixtures/TestEntityWithMutationTriggers.js +82 -0
- package/build/testfixtures/TestEntityWithMutationTriggers.js.map +1 -0
- package/build/testfixtures/TestViewerContext.d.ts +0 -3
- package/build/testfixtures/TestViewerContext.js +0 -6
- package/build/testfixtures/TestViewerContext.js.map +1 -1
- package/build/utils/EntityPrivacyUtils.d.ts +34 -0
- package/build/utils/EntityPrivacyUtils.js +160 -0
- package/build/utils/EntityPrivacyUtils.js.map +1 -0
- package/build/utils/__tests__/EntityPrivacyUtils-test.d.ts +1 -0
- package/build/utils/__tests__/EntityPrivacyUtils-test.js +395 -0
- package/build/utils/__tests__/EntityPrivacyUtils-test.js.map +1 -0
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.d.ts +1 -0
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js +26 -0
- package/build/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.js.map +1 -0
- package/build/utils/collections/maps.js.map +1 -1
- package/build/utils/mergeEntityMutationTriggerConfigurations.d.ts +4 -0
- package/build/utils/mergeEntityMutationTriggerConfigurations.js +28 -0
- package/build/utils/mergeEntityMutationTriggerConfigurations.js.map +1 -0
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.d.ts +1 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js.map +1 -1
- package/build/utils/testing/StubCacheAdapter.d.ts +3 -3
- package/build/utils/testing/StubCacheAdapter.js +3 -3
- package/build/utils/testing/StubCacheAdapter.js.map +1 -1
- package/build/utils/testing/StubDatabaseAdapter.d.ts +2 -2
- package/build/utils/testing/StubDatabaseAdapter.js +4 -2
- package/build/utils/testing/StubDatabaseAdapter.js.map +1 -1
- package/build/utils/testing/StubDatabaseAdapterProvider.d.ts +1 -1
- package/build/utils/testing/StubDatabaseAdapterProvider.js +1 -3
- package/build/utils/testing/StubDatabaseAdapterProvider.js.map +1 -1
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.d.ts +1 -0
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js +42 -0
- package/build/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.js.map +1 -0
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js +53 -0
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js.map +1 -1
- package/build/utils/testing/describeFieldTestCase.js.map +1 -1
- package/package.json +4 -3
- package/src/AuthorizationResultBasedEntityLoader.ts +297 -0
- package/src/ComposedEntityCacheAdapter.ts +6 -6
- package/src/ComposedSecondaryEntityCache.ts +8 -8
- package/src/EnforcingEntityLoader.ts +20 -19
- package/src/Entity.ts +26 -118
- package/src/EntityAssociationLoader.ts +56 -41
- package/src/EntityCompanion.ts +8 -4
- package/src/EntityCompanionProvider.ts +24 -16
- package/src/EntityConfiguration.ts +18 -7
- package/src/EntityDatabaseAdapter.ts +41 -41
- package/src/EntityFieldDefinition.ts +28 -18
- package/src/EntityFields.ts +15 -0
- package/src/EntityLoader.ts +63 -357
- package/src/EntityLoaderFactory.ts +10 -4
- package/src/EntityLoaderUtils.ts +149 -0
- package/src/EntityMutationInfo.ts +2 -2
- package/src/EntityMutationTriggerConfiguration.ts +5 -5
- package/src/EntityMutationValidator.ts +2 -2
- package/src/EntityMutator.ts +146 -144
- package/src/EntityMutatorFactory.ts +8 -8
- package/src/EntityPrivacyPolicy.ts +78 -28
- package/src/EntityQueryContext.ts +14 -13
- package/src/EntityQueryContextProvider.ts +6 -6
- package/src/EntitySecondaryCacheLoader.ts +13 -11
- package/src/GenericEntityCacheAdapter.ts +10 -10
- package/src/GenericSecondaryEntityCache.ts +6 -6
- package/src/IEntityCacheAdapter.ts +4 -4
- package/src/IEntityCacheAdapterProvider.ts +2 -2
- package/src/IEntityDatabaseAdapterProvider.ts +2 -2
- package/src/ReadonlyEntity.ts +8 -5
- package/src/ViewerContext.ts +10 -10
- package/src/ViewerScopedEntityCompanion.ts +4 -4
- package/src/ViewerScopedEntityCompanionProvider.ts +4 -5
- package/src/ViewerScopedEntityLoaderFactory.ts +10 -4
- package/src/ViewerScopedEntityMutatorFactory.ts +5 -5
- package/src/__tests__/ComposedCacheAdapter-test.ts +12 -10
- package/src/__tests__/ComposedSecondaryEntityCache-test.ts +8 -8
- package/src/__tests__/EnforcingEntityLoader-test.ts +236 -159
- package/src/__tests__/Entity-test.ts +5 -223
- package/src/__tests__/EntityAssociationLoader-test.ts +91 -169
- package/src/__tests__/EntityCommonUseCases-test.ts +36 -38
- package/src/__tests__/EntityCompanion-test.ts +57 -5
- package/src/__tests__/EntityConfiguration-test.ts +118 -0
- package/src/__tests__/EntityDatabaseAdapter-test.ts +11 -11
- package/src/__tests__/EntityEdges-test.ts +128 -118
- package/src/__tests__/EntityFields-test.ts +14 -2
- package/src/__tests__/EntityLoader-constructor-test.ts +21 -8
- package/src/__tests__/EntityLoader-test.ts +233 -105
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +17 -20
- package/src/__tests__/EntityMutator-test.ts +342 -163
- package/src/__tests__/EntityPrivacyPolicy-test.ts +166 -53
- package/src/__tests__/EntityQueryContext-test.ts +30 -12
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +17 -26
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +67 -115
- package/src/__tests__/GenericEntityCacheAdapter-test.ts +2 -2
- package/src/__tests__/ReadonlyEntity-test.ts +13 -15
- package/src/__tests__/ViewerContext-test.ts +3 -4
- package/src/__tests__/ViewerScopedEntityCompanion-test.ts +2 -2
- package/src/__tests__/ViewerScopedEntityCompanionProvider-test.ts +2 -2
- package/src/__tests__/ViewerScopedEntityLoaderFactory-test.ts +2 -1
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +34 -45
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +22 -30
- package/src/__tests__/entityUtils-test.ts +2 -2
- package/src/entityUtils.ts +4 -4
- package/src/errors/EntityError.ts +4 -1
- package/src/errors/EntityInvalidFieldValueError.ts +2 -2
- package/src/errors/EntityNotAuthorizedError.ts +3 -3
- package/src/errors/EntityNotFoundError.ts +2 -2
- package/src/index.ts +1 -0
- package/src/internal/EntityDataManager.ts +25 -25
- package/src/internal/EntityFieldTransformationUtils.ts +39 -32
- package/src/internal/EntityTableDataCoordinator.ts +3 -3
- package/src/internal/ReadThroughEntityCache.ts +9 -9
- package/src/internal/__tests__/EntityDataManager-test.ts +62 -62
- package/src/internal/__tests__/EntityFieldTransformationUtils-test.ts +14 -10
- package/src/internal/__tests__/ReadThroughEntityCache-test.ts +74 -18
- package/src/metrics/EntityMetricsUtils.ts +4 -4
- package/src/metrics/IEntityMetricsAdapter.ts +1 -1
- package/src/rules/AlwaysAllowPrivacyPolicyRule.ts +9 -3
- package/src/rules/AlwaysDenyPrivacyPolicyRule.ts +9 -3
- package/src/rules/AlwaysSkipPrivacyPolicyRule.ts +9 -3
- package/src/rules/PrivacyPolicyRule.ts +9 -3
- package/src/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.ts +2 -1
- package/src/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.ts +2 -1
- package/src/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.ts +2 -1
- package/src/testfixtures/SimpleTestEntity.ts +8 -8
- package/src/testfixtures/TestEntity.ts +13 -16
- package/src/testfixtures/TestEntity2.ts +8 -8
- package/src/testfixtures/TestEntityWithMutationTriggers.ts +156 -0
- package/src/testfixtures/TestViewerContext.ts +1 -12
- package/src/utils/EntityPrivacyUtils.ts +325 -0
- package/src/utils/__tests__/EntityPrivacyUtils-test.ts +570 -0
- package/src/utils/__tests__/mergeEntityMutationTriggerConfigurations-test.ts +29 -0
- package/src/utils/collections/__tests__/maps-test.ts +2 -2
- package/src/utils/collections/maps.ts +11 -11
- package/src/utils/mergeEntityMutationTriggerConfigurations.ts +44 -0
- package/src/utils/testing/PrivacyPolicyRuleTestUtils.ts +25 -22
- package/src/utils/testing/StubCacheAdapter.ts +17 -15
- package/src/utils/testing/StubDatabaseAdapter.ts +35 -30
- package/src/utils/testing/StubDatabaseAdapterProvider.ts +2 -2
- package/src/utils/testing/StubQueryContextProvider.ts +2 -2
- package/src/utils/testing/__tests__/PrivacyPolicyRuleTestUtils-test.ts +42 -0
- package/src/utils/testing/__tests__/StubDatabaseAdapter-test.ts +111 -29
- package/src/utils/testing/createUnitTestEntityCompanionProvider.ts +2 -2
- package/src/utils/testing/describeFieldTestCase.ts +1 -1
- package/build/__tests__/EntityDataConfiguration-test.js +0 -68
- package/build/__tests__/EntityDataConfiguration-test.js.map +0 -1
- package/src/__tests__/EntityDataConfiguration-test.ts +0 -77
- /package/build/__tests__/{EntityDataConfiguration-test.d.ts → EntityConfiguration-test.d.ts} +0 -0
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
import Entity from '../Entity';
|
|
2
|
-
import { EntityCompanionDefinition } from '../EntityCompanionProvider';
|
|
3
|
-
import EntityConfiguration from '../EntityConfiguration';
|
|
4
|
-
import { UUIDField } from '../EntityFields';
|
|
5
2
|
import { CreateMutator, UpdateMutator } from '../EntityMutator';
|
|
6
|
-
import
|
|
7
|
-
import AlwaysAllowPrivacyPolicyRule from '../rules/AlwaysAllowPrivacyPolicyRule';
|
|
8
|
-
import AlwaysDenyPrivacyPolicyRule from '../rules/AlwaysDenyPrivacyPolicyRule';
|
|
3
|
+
import ViewerContext from '../ViewerContext';
|
|
9
4
|
import SimpleTestEntity from '../testfixtures/SimpleTestEntity';
|
|
10
|
-
import TestViewerContext from '../testfixtures/TestViewerContext';
|
|
11
5
|
import { createUnitTestEntityCompanionProvider } from '../utils/testing/createUnitTestEntityCompanionProvider';
|
|
12
6
|
|
|
13
7
|
describe(Entity, () => {
|
|
14
8
|
describe('creator', () => {
|
|
15
9
|
it('creates a new CreateMutator', () => {
|
|
16
10
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
17
|
-
const viewerContext = new
|
|
18
|
-
expect(
|
|
19
|
-
SimpleTestEntity.creator(viewerContext, viewerContext.getQueryContext())
|
|
20
|
-
).toBeInstanceOf(CreateMutator);
|
|
11
|
+
const viewerContext = new ViewerContext(companionProvider);
|
|
12
|
+
expect(SimpleTestEntity.creator(viewerContext)).toBeInstanceOf(CreateMutator);
|
|
21
13
|
});
|
|
22
14
|
});
|
|
23
15
|
|
|
24
16
|
describe('updater', () => {
|
|
25
17
|
it('creates a new UpdateMutator', () => {
|
|
26
18
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
27
|
-
const viewerContext = new
|
|
19
|
+
const viewerContext = new ViewerContext(companionProvider);
|
|
28
20
|
const data = {
|
|
29
21
|
id: 'what',
|
|
30
22
|
};
|
|
@@ -34,217 +26,7 @@ describe(Entity, () => {
|
|
|
34
26
|
databaseFields: data,
|
|
35
27
|
selectedFields: data,
|
|
36
28
|
});
|
|
37
|
-
expect(SimpleTestEntity.updater(testEntity
|
|
38
|
-
UpdateMutator
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('canViewerUpdateAsync', () => {
|
|
44
|
-
it('appropriately executes update privacy policy', async () => {
|
|
45
|
-
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
46
|
-
const viewerContext = new TestViewerContext(companionProvider);
|
|
47
|
-
const data = {
|
|
48
|
-
id: 'what',
|
|
49
|
-
};
|
|
50
|
-
const testEntity = new SimpleTestDenyDeleteEntity({
|
|
51
|
-
viewerContext,
|
|
52
|
-
id: 'what',
|
|
53
|
-
databaseFields: data,
|
|
54
|
-
selectedFields: data,
|
|
55
|
-
});
|
|
56
|
-
const canViewerUpdate = await SimpleTestDenyDeleteEntity.canViewerUpdateAsync(
|
|
57
|
-
testEntity,
|
|
58
|
-
viewerContext.getQueryContext()
|
|
59
|
-
);
|
|
60
|
-
expect(canViewerUpdate).toBe(true);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('denies when policy denies', async () => {
|
|
64
|
-
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
65
|
-
const viewerContext = new TestViewerContext(companionProvider);
|
|
66
|
-
const data = {
|
|
67
|
-
id: 'what',
|
|
68
|
-
};
|
|
69
|
-
const testEntity = new SimpleTestDenyUpdateEntity({
|
|
70
|
-
viewerContext,
|
|
71
|
-
id: 'what',
|
|
72
|
-
databaseFields: data,
|
|
73
|
-
selectedFields: data,
|
|
74
|
-
});
|
|
75
|
-
const canViewerUpdate = await SimpleTestDenyUpdateEntity.canViewerUpdateAsync(
|
|
76
|
-
testEntity,
|
|
77
|
-
viewerContext.getQueryContext()
|
|
78
|
-
);
|
|
79
|
-
expect(canViewerUpdate).toBe(false);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe('canViewerDeleteAsync', () => {
|
|
84
|
-
it('appropriately executes update privacy policy', async () => {
|
|
85
|
-
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
86
|
-
const viewerContext = new TestViewerContext(companionProvider);
|
|
87
|
-
const data = {
|
|
88
|
-
id: 'what',
|
|
89
|
-
};
|
|
90
|
-
const testEntity = new SimpleTestDenyUpdateEntity({
|
|
91
|
-
viewerContext,
|
|
92
|
-
id: 'what',
|
|
93
|
-
databaseFields: data,
|
|
94
|
-
selectedFields: data,
|
|
95
|
-
});
|
|
96
|
-
const canViewerDelete = await SimpleTestDenyUpdateEntity.canViewerDeleteAsync(
|
|
97
|
-
testEntity,
|
|
98
|
-
viewerContext.getQueryContext()
|
|
99
|
-
);
|
|
100
|
-
expect(canViewerDelete).toBe(true);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('denies when policy denies', async () => {
|
|
104
|
-
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
105
|
-
const viewerContext = new TestViewerContext(companionProvider);
|
|
106
|
-
const data = {
|
|
107
|
-
id: 'what',
|
|
108
|
-
};
|
|
109
|
-
const testEntity = new SimpleTestDenyDeleteEntity({
|
|
110
|
-
viewerContext,
|
|
111
|
-
id: 'what',
|
|
112
|
-
databaseFields: data,
|
|
113
|
-
selectedFields: data,
|
|
114
|
-
});
|
|
115
|
-
const canViewerDelete = await SimpleTestDenyDeleteEntity.canViewerDeleteAsync(
|
|
116
|
-
testEntity,
|
|
117
|
-
viewerContext.getQueryContext()
|
|
118
|
-
);
|
|
119
|
-
expect(canViewerDelete).toBe(false);
|
|
29
|
+
expect(SimpleTestEntity.updater(testEntity)).toBeInstanceOf(UpdateMutator);
|
|
120
30
|
});
|
|
121
31
|
});
|
|
122
32
|
});
|
|
123
|
-
|
|
124
|
-
type TestEntityFields = {
|
|
125
|
-
id: string;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const testEntityConfiguration = new EntityConfiguration<TestEntityFields>({
|
|
129
|
-
idField: 'id',
|
|
130
|
-
tableName: 'blah',
|
|
131
|
-
schema: {
|
|
132
|
-
id: new UUIDField({
|
|
133
|
-
columnName: 'custom_id',
|
|
134
|
-
}),
|
|
135
|
-
},
|
|
136
|
-
databaseAdapterFlavor: 'postgres',
|
|
137
|
-
cacheAdapterFlavor: 'redis',
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
class SimpleTestDenyUpdateEntityPrivacyPolicy extends EntityPrivacyPolicy<
|
|
141
|
-
TestEntityFields,
|
|
142
|
-
string,
|
|
143
|
-
TestViewerContext,
|
|
144
|
-
SimpleTestDenyUpdateEntity
|
|
145
|
-
> {
|
|
146
|
-
protected override readonly readRules = [
|
|
147
|
-
new AlwaysAllowPrivacyPolicyRule<
|
|
148
|
-
TestEntityFields,
|
|
149
|
-
string,
|
|
150
|
-
TestViewerContext,
|
|
151
|
-
SimpleTestDenyUpdateEntity
|
|
152
|
-
>(),
|
|
153
|
-
];
|
|
154
|
-
protected override readonly createRules = [
|
|
155
|
-
new AlwaysAllowPrivacyPolicyRule<
|
|
156
|
-
TestEntityFields,
|
|
157
|
-
string,
|
|
158
|
-
TestViewerContext,
|
|
159
|
-
SimpleTestDenyUpdateEntity
|
|
160
|
-
>(),
|
|
161
|
-
];
|
|
162
|
-
protected override readonly updateRules = [
|
|
163
|
-
new AlwaysDenyPrivacyPolicyRule<
|
|
164
|
-
TestEntityFields,
|
|
165
|
-
string,
|
|
166
|
-
TestViewerContext,
|
|
167
|
-
SimpleTestDenyUpdateEntity
|
|
168
|
-
>(),
|
|
169
|
-
];
|
|
170
|
-
protected override readonly deleteRules = [
|
|
171
|
-
new AlwaysAllowPrivacyPolicyRule<
|
|
172
|
-
TestEntityFields,
|
|
173
|
-
string,
|
|
174
|
-
TestViewerContext,
|
|
175
|
-
SimpleTestDenyUpdateEntity
|
|
176
|
-
>(),
|
|
177
|
-
];
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
class SimpleTestDenyDeleteEntityPrivacyPolicy extends EntityPrivacyPolicy<
|
|
181
|
-
TestEntityFields,
|
|
182
|
-
string,
|
|
183
|
-
TestViewerContext,
|
|
184
|
-
SimpleTestDenyDeleteEntity
|
|
185
|
-
> {
|
|
186
|
-
protected override readonly readRules = [
|
|
187
|
-
new AlwaysAllowPrivacyPolicyRule<
|
|
188
|
-
TestEntityFields,
|
|
189
|
-
string,
|
|
190
|
-
TestViewerContext,
|
|
191
|
-
SimpleTestDenyDeleteEntity
|
|
192
|
-
>(),
|
|
193
|
-
];
|
|
194
|
-
protected override readonly createRules = [
|
|
195
|
-
new AlwaysAllowPrivacyPolicyRule<
|
|
196
|
-
TestEntityFields,
|
|
197
|
-
string,
|
|
198
|
-
TestViewerContext,
|
|
199
|
-
SimpleTestDenyDeleteEntity
|
|
200
|
-
>(),
|
|
201
|
-
];
|
|
202
|
-
protected override readonly updateRules = [
|
|
203
|
-
new AlwaysAllowPrivacyPolicyRule<
|
|
204
|
-
TestEntityFields,
|
|
205
|
-
string,
|
|
206
|
-
TestViewerContext,
|
|
207
|
-
SimpleTestDenyDeleteEntity
|
|
208
|
-
>(),
|
|
209
|
-
];
|
|
210
|
-
protected override readonly deleteRules = [
|
|
211
|
-
new AlwaysDenyPrivacyPolicyRule<
|
|
212
|
-
TestEntityFields,
|
|
213
|
-
string,
|
|
214
|
-
TestViewerContext,
|
|
215
|
-
SimpleTestDenyDeleteEntity
|
|
216
|
-
>(),
|
|
217
|
-
];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
class SimpleTestDenyUpdateEntity extends Entity<TestEntityFields, string, TestViewerContext> {
|
|
221
|
-
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
222
|
-
TestEntityFields,
|
|
223
|
-
string,
|
|
224
|
-
TestViewerContext,
|
|
225
|
-
SimpleTestDenyUpdateEntity,
|
|
226
|
-
SimpleTestDenyUpdateEntityPrivacyPolicy
|
|
227
|
-
> {
|
|
228
|
-
return {
|
|
229
|
-
entityClass: SimpleTestDenyUpdateEntity,
|
|
230
|
-
entityConfiguration: testEntityConfiguration,
|
|
231
|
-
privacyPolicyClass: SimpleTestDenyUpdateEntityPrivacyPolicy,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
class SimpleTestDenyDeleteEntity extends Entity<TestEntityFields, string, TestViewerContext> {
|
|
237
|
-
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
238
|
-
TestEntityFields,
|
|
239
|
-
string,
|
|
240
|
-
TestViewerContext,
|
|
241
|
-
SimpleTestDenyDeleteEntity,
|
|
242
|
-
SimpleTestDenyDeleteEntityPrivacyPolicy
|
|
243
|
-
> {
|
|
244
|
-
return {
|
|
245
|
-
entityClass: SimpleTestDenyDeleteEntity,
|
|
246
|
-
entityConfiguration: testEntityConfiguration,
|
|
247
|
-
privacyPolicyClass: SimpleTestDenyDeleteEntityPrivacyPolicy,
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
}
|
|
@@ -14,24 +14,20 @@ describe(EntityAssociationLoader, () => {
|
|
|
14
14
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
15
15
|
const viewerContext = new TestViewerContext(companionProvider);
|
|
16
16
|
const testOtherEntity = await enforceAsyncResult(
|
|
17
|
-
TestEntity.creator(viewerContext
|
|
17
|
+
TestEntity.creator(viewerContext).createAsync(),
|
|
18
18
|
);
|
|
19
19
|
const testEntity = await enforceAsyncResult(
|
|
20
|
-
TestEntity.creator(viewerContext
|
|
20
|
+
TestEntity.creator(viewerContext)
|
|
21
21
|
.setField('stringField', testOtherEntity.getID())
|
|
22
|
-
.createAsync()
|
|
22
|
+
.createAsync(),
|
|
23
23
|
);
|
|
24
24
|
const loadedOther = await enforceAsyncResult(
|
|
25
|
-
testEntity
|
|
26
|
-
.associationLoader()
|
|
27
|
-
.loadAssociatedEntityAsync('stringField', TestEntity, viewerContext.getQueryContext())
|
|
25
|
+
testEntity.associationLoader().loadAssociatedEntityAsync('stringField', TestEntity),
|
|
28
26
|
);
|
|
29
27
|
expect(loadedOther.getID()).toEqual(testOtherEntity.getID());
|
|
30
28
|
|
|
31
29
|
const loadedOther2 = await enforceAsyncResult(
|
|
32
|
-
testEntity
|
|
33
|
-
.associationLoader()
|
|
34
|
-
.loadAssociatedEntityAsync('nullableField', TestEntity, viewerContext.getQueryContext())
|
|
30
|
+
testEntity.associationLoader().loadAssociatedEntityAsync('nullableField', TestEntity),
|
|
35
31
|
);
|
|
36
32
|
expect(loadedOther2).toBeNull();
|
|
37
33
|
});
|
|
@@ -41,27 +37,15 @@ describe(EntityAssociationLoader, () => {
|
|
|
41
37
|
it('loads many associated entities referencing this entity', async () => {
|
|
42
38
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
43
39
|
const viewerContext = new TestViewerContext(companionProvider);
|
|
44
|
-
const testEntity = await enforceAsyncResult(
|
|
45
|
-
TestEntity.creator(viewerContext, viewerContext.getQueryContext()).createAsync()
|
|
46
|
-
);
|
|
40
|
+
const testEntity = await enforceAsyncResult(TestEntity.creator(viewerContext).createAsync());
|
|
47
41
|
const testOtherEntity1 = await enforceAsyncResult(
|
|
48
|
-
TestEntity.creator(viewerContext,
|
|
49
|
-
.setField('stringField', testEntity.getID())
|
|
50
|
-
.createAsync()
|
|
42
|
+
TestEntity.creator(viewerContext).setField('stringField', testEntity.getID()).createAsync(),
|
|
51
43
|
);
|
|
52
44
|
const testOtherEntity2 = await enforceAsyncResult(
|
|
53
|
-
TestEntity.creator(viewerContext,
|
|
54
|
-
.setField('stringField', testEntity.getID())
|
|
55
|
-
.createAsync()
|
|
45
|
+
TestEntity.creator(viewerContext).setField('stringField', testEntity.getID()).createAsync(),
|
|
56
46
|
);
|
|
57
47
|
const loaded = await enforceResultsAsync(
|
|
58
|
-
testEntity
|
|
59
|
-
.associationLoader()
|
|
60
|
-
.loadManyAssociatedEntitiesAsync(
|
|
61
|
-
TestEntity,
|
|
62
|
-
'stringField',
|
|
63
|
-
viewerContext.getQueryContext()
|
|
64
|
-
)
|
|
48
|
+
testEntity.associationLoader().loadManyAssociatedEntitiesAsync(TestEntity, 'stringField'),
|
|
65
49
|
);
|
|
66
50
|
expect(loaded).toHaveLength(2);
|
|
67
51
|
expect(loaded.find((e) => e.getID() === testOtherEntity1.getID())).not.toBeUndefined();
|
|
@@ -74,21 +58,16 @@ describe(EntityAssociationLoader, () => {
|
|
|
74
58
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
75
59
|
const viewerContext = new TestViewerContext(companionProvider);
|
|
76
60
|
const testOtherEntity = await enforceAsyncResult(
|
|
77
|
-
TestEntity.creator(viewerContext
|
|
61
|
+
TestEntity.creator(viewerContext).createAsync(),
|
|
78
62
|
);
|
|
79
63
|
const testEntity = await enforceAsyncResult(
|
|
80
|
-
TestEntity.creator(viewerContext
|
|
64
|
+
TestEntity.creator(viewerContext)
|
|
81
65
|
.setField('stringField', testOtherEntity.getID())
|
|
82
|
-
.createAsync()
|
|
66
|
+
.createAsync(),
|
|
83
67
|
);
|
|
84
68
|
const loadedOtherResult = await testEntity
|
|
85
69
|
.associationLoader()
|
|
86
|
-
.loadAssociatedEntityByFieldEqualingAsync(
|
|
87
|
-
'stringField',
|
|
88
|
-
TestEntity,
|
|
89
|
-
'customIdField',
|
|
90
|
-
viewerContext.getQueryContext()
|
|
91
|
-
);
|
|
70
|
+
.loadAssociatedEntityByFieldEqualingAsync('stringField', TestEntity, 'customIdField');
|
|
92
71
|
expect(loadedOtherResult?.enforceValue().getID()).toEqual(testOtherEntity.getID());
|
|
93
72
|
});
|
|
94
73
|
|
|
@@ -96,18 +75,11 @@ describe(EntityAssociationLoader, () => {
|
|
|
96
75
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
97
76
|
const viewerContext = new TestViewerContext(companionProvider);
|
|
98
77
|
const testEntity = await enforceAsyncResult(
|
|
99
|
-
TestEntity.creator(viewerContext,
|
|
100
|
-
.setField('stringField', uuidv4())
|
|
101
|
-
.createAsync()
|
|
78
|
+
TestEntity.creator(viewerContext).setField('stringField', uuidv4()).createAsync(),
|
|
102
79
|
);
|
|
103
80
|
const loadedOtherResult = await testEntity
|
|
104
81
|
.associationLoader()
|
|
105
|
-
.loadAssociatedEntityByFieldEqualingAsync(
|
|
106
|
-
'stringField',
|
|
107
|
-
TestEntity,
|
|
108
|
-
'customIdField',
|
|
109
|
-
viewerContext.getQueryContext()
|
|
110
|
-
);
|
|
82
|
+
.loadAssociatedEntityByFieldEqualingAsync('stringField', TestEntity, 'customIdField');
|
|
111
83
|
expect(loadedOtherResult).toBeNull();
|
|
112
84
|
});
|
|
113
85
|
|
|
@@ -115,18 +87,11 @@ describe(EntityAssociationLoader, () => {
|
|
|
115
87
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
116
88
|
const viewerContext = new TestViewerContext(companionProvider);
|
|
117
89
|
const testEntity = await enforceAsyncResult(
|
|
118
|
-
TestEntity.creator(viewerContext,
|
|
119
|
-
.setField('stringField', 'blah')
|
|
120
|
-
.createAsync()
|
|
90
|
+
TestEntity.creator(viewerContext).setField('stringField', 'blah').createAsync(),
|
|
121
91
|
);
|
|
122
92
|
const loadedOtherResult = await testEntity
|
|
123
93
|
.associationLoader()
|
|
124
|
-
.loadAssociatedEntityByFieldEqualingAsync(
|
|
125
|
-
'nullableField',
|
|
126
|
-
TestEntity,
|
|
127
|
-
'customIdField',
|
|
128
|
-
viewerContext.getQueryContext()
|
|
129
|
-
);
|
|
94
|
+
.loadAssociatedEntityByFieldEqualingAsync('nullableField', TestEntity, 'customIdField');
|
|
130
95
|
expect(loadedOtherResult).toBeNull();
|
|
131
96
|
});
|
|
132
97
|
});
|
|
@@ -135,18 +100,12 @@ describe(EntityAssociationLoader, () => {
|
|
|
135
100
|
it('loads many associated entities by field equaling', async () => {
|
|
136
101
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
137
102
|
const viewerContext = new TestViewerContext(companionProvider);
|
|
138
|
-
const testEntity = await enforceAsyncResult(
|
|
139
|
-
TestEntity.creator(viewerContext, viewerContext.getQueryContext()).createAsync()
|
|
140
|
-
);
|
|
103
|
+
const testEntity = await enforceAsyncResult(TestEntity.creator(viewerContext).createAsync());
|
|
141
104
|
const testOtherEntity1 = await enforceAsyncResult(
|
|
142
|
-
TestEntity.creator(viewerContext,
|
|
143
|
-
.setField('stringField', testEntity.getID())
|
|
144
|
-
.createAsync()
|
|
105
|
+
TestEntity.creator(viewerContext).setField('stringField', testEntity.getID()).createAsync(),
|
|
145
106
|
);
|
|
146
107
|
const testOtherEntity2 = await enforceAsyncResult(
|
|
147
|
-
TestEntity.creator(viewerContext,
|
|
148
|
-
.setField('stringField', testEntity.getID())
|
|
149
|
-
.createAsync()
|
|
108
|
+
TestEntity.creator(viewerContext).setField('stringField', testEntity.getID()).createAsync(),
|
|
150
109
|
);
|
|
151
110
|
const loaded = await enforceResultsAsync(
|
|
152
111
|
testEntity
|
|
@@ -155,8 +114,7 @@ describe(EntityAssociationLoader, () => {
|
|
|
155
114
|
'customIdField',
|
|
156
115
|
TestEntity,
|
|
157
116
|
'stringField',
|
|
158
|
-
|
|
159
|
-
)
|
|
117
|
+
),
|
|
160
118
|
);
|
|
161
119
|
expect(loaded).toHaveLength(2);
|
|
162
120
|
expect(loaded.find((e) => e.getID() === testOtherEntity1.getID())).not.toBeUndefined();
|
|
@@ -166,9 +124,7 @@ describe(EntityAssociationLoader, () => {
|
|
|
166
124
|
it('returns empty results when field being queried by is null', async () => {
|
|
167
125
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
168
126
|
const viewerContext = new TestViewerContext(companionProvider);
|
|
169
|
-
const testEntity = await enforceAsyncResult(
|
|
170
|
-
TestEntity.creator(viewerContext, viewerContext.getQueryContext()).createAsync()
|
|
171
|
-
);
|
|
127
|
+
const testEntity = await enforceAsyncResult(TestEntity.creator(viewerContext).createAsync());
|
|
172
128
|
const loaded = await enforceResultsAsync(
|
|
173
129
|
testEntity
|
|
174
130
|
.associationLoader()
|
|
@@ -176,8 +132,7 @@ describe(EntityAssociationLoader, () => {
|
|
|
176
132
|
'nullableField',
|
|
177
133
|
TestEntity,
|
|
178
134
|
'stringField',
|
|
179
|
-
|
|
180
|
-
)
|
|
135
|
+
),
|
|
181
136
|
);
|
|
182
137
|
expect(loaded).toHaveLength(0);
|
|
183
138
|
});
|
|
@@ -187,68 +142,57 @@ describe(EntityAssociationLoader, () => {
|
|
|
187
142
|
it('chain loads associated entities', async () => {
|
|
188
143
|
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
189
144
|
const viewerContext = new TestViewerContext(companionProvider);
|
|
190
|
-
const testEntity4 = await enforceAsyncResult(
|
|
191
|
-
TestEntity.creator(viewerContext, viewerContext.getQueryContext()).createAsync()
|
|
192
|
-
);
|
|
145
|
+
const testEntity4 = await enforceAsyncResult(TestEntity.creator(viewerContext).createAsync());
|
|
193
146
|
const testEntity3 = await enforceAsyncResult(
|
|
194
|
-
TestEntity2.creator(viewerContext
|
|
147
|
+
TestEntity2.creator(viewerContext)
|
|
195
148
|
.setField('foreignKey', testEntity4.getID())
|
|
196
|
-
.createAsync()
|
|
149
|
+
.createAsync(),
|
|
197
150
|
);
|
|
198
151
|
const testEntity2 = await enforceAsyncResult(
|
|
199
|
-
TestEntity.creator(viewerContext
|
|
152
|
+
TestEntity.creator(viewerContext)
|
|
200
153
|
.setField('testIndexedField', testEntity3.getID())
|
|
201
|
-
.createAsync()
|
|
154
|
+
.createAsync(),
|
|
202
155
|
);
|
|
203
156
|
const testEntity = await enforceAsyncResult(
|
|
204
|
-
TestEntity2.creator(viewerContext
|
|
157
|
+
TestEntity2.creator(viewerContext)
|
|
205
158
|
.setField('foreignKey', testEntity2.getID())
|
|
206
|
-
.createAsync()
|
|
159
|
+
.createAsync(),
|
|
207
160
|
);
|
|
208
161
|
|
|
209
|
-
const loaded2Result = await testEntity.associationLoader().loadAssociatedEntityThroughAsync(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
],
|
|
216
|
-
viewerContext.getQueryContext()
|
|
217
|
-
);
|
|
162
|
+
const loaded2Result = await testEntity.associationLoader().loadAssociatedEntityThroughAsync([
|
|
163
|
+
{
|
|
164
|
+
associatedEntityClass: TestEntity,
|
|
165
|
+
fieldIdentifyingAssociatedEntity: 'foreignKey',
|
|
166
|
+
},
|
|
167
|
+
]);
|
|
218
168
|
expect(loaded2Result?.enforceValue().getID()).toEqual(testEntity2.getID());
|
|
219
169
|
|
|
220
|
-
const loaded3Result = await testEntity.associationLoader().loadAssociatedEntityThroughAsync(
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
],
|
|
231
|
-
viewerContext.getQueryContext()
|
|
232
|
-
);
|
|
170
|
+
const loaded3Result = await testEntity.associationLoader().loadAssociatedEntityThroughAsync([
|
|
171
|
+
{
|
|
172
|
+
associatedEntityClass: TestEntity,
|
|
173
|
+
fieldIdentifyingAssociatedEntity: 'foreignKey',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
associatedEntityClass: TestEntity2,
|
|
177
|
+
fieldIdentifyingAssociatedEntity: 'testIndexedField',
|
|
178
|
+
},
|
|
179
|
+
]);
|
|
233
180
|
expect(loaded3Result?.enforceValue().getID()).toEqual(testEntity3.getID());
|
|
234
181
|
|
|
235
|
-
const loaded4Result = await testEntity.associationLoader().loadAssociatedEntityThroughAsync(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
],
|
|
250
|
-
viewerContext.getQueryContext()
|
|
251
|
-
);
|
|
182
|
+
const loaded4Result = await testEntity.associationLoader().loadAssociatedEntityThroughAsync([
|
|
183
|
+
{
|
|
184
|
+
associatedEntityClass: TestEntity,
|
|
185
|
+
fieldIdentifyingAssociatedEntity: 'foreignKey',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
associatedEntityClass: TestEntity2,
|
|
189
|
+
fieldIdentifyingAssociatedEntity: 'testIndexedField',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
associatedEntityClass: TestEntity,
|
|
193
|
+
fieldIdentifyingAssociatedEntity: 'foreignKey',
|
|
194
|
+
},
|
|
195
|
+
]);
|
|
252
196
|
expect(loaded4Result?.enforceValue().getID()).toEqual(testEntity4.getID());
|
|
253
197
|
});
|
|
254
198
|
|
|
@@ -257,20 +201,15 @@ describe(EntityAssociationLoader, () => {
|
|
|
257
201
|
const viewerContext = new TestViewerContext(companionProvider);
|
|
258
202
|
|
|
259
203
|
const testEntity = await enforceAsyncResult(
|
|
260
|
-
TestEntity2.creator(viewerContext,
|
|
261
|
-
.setField('foreignKey', uuidv4())
|
|
262
|
-
.createAsync()
|
|
204
|
+
TestEntity2.creator(viewerContext).setField('foreignKey', uuidv4()).createAsync(),
|
|
263
205
|
);
|
|
264
206
|
|
|
265
|
-
const loadResult = await testEntity.associationLoader().loadAssociatedEntityThroughAsync(
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
],
|
|
272
|
-
viewerContext.getQueryContext()
|
|
273
|
-
);
|
|
207
|
+
const loadResult = await testEntity.associationLoader().loadAssociatedEntityThroughAsync([
|
|
208
|
+
{
|
|
209
|
+
associatedEntityClass: TestEntity,
|
|
210
|
+
fieldIdentifyingAssociatedEntity: 'foreignKey',
|
|
211
|
+
},
|
|
212
|
+
]);
|
|
274
213
|
expect(loadResult?.ok).toBe(false);
|
|
275
214
|
});
|
|
276
215
|
|
|
@@ -280,26 +219,19 @@ describe(EntityAssociationLoader, () => {
|
|
|
280
219
|
|
|
281
220
|
const fieldValue = uuidv4();
|
|
282
221
|
const testEntity2 = await enforceAsyncResult(
|
|
283
|
-
TestEntity.creator(viewerContext,
|
|
284
|
-
.setField('stringField', fieldValue)
|
|
285
|
-
.createAsync()
|
|
222
|
+
TestEntity.creator(viewerContext).setField('stringField', fieldValue).createAsync(),
|
|
286
223
|
);
|
|
287
224
|
const testEntity = await enforceAsyncResult(
|
|
288
|
-
TestEntity2.creator(viewerContext,
|
|
289
|
-
.setField('foreignKey', fieldValue)
|
|
290
|
-
.createAsync()
|
|
225
|
+
TestEntity2.creator(viewerContext).setField('foreignKey', fieldValue).createAsync(),
|
|
291
226
|
);
|
|
292
227
|
|
|
293
|
-
const loaded2Result = await testEntity.associationLoader().loadAssociatedEntityThroughAsync(
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
],
|
|
301
|
-
viewerContext.getQueryContext()
|
|
302
|
-
);
|
|
228
|
+
const loaded2Result = await testEntity.associationLoader().loadAssociatedEntityThroughAsync([
|
|
229
|
+
{
|
|
230
|
+
associatedEntityClass: TestEntity,
|
|
231
|
+
fieldIdentifyingAssociatedEntity: 'foreignKey',
|
|
232
|
+
associatedEntityLookupByField: 'stringField',
|
|
233
|
+
},
|
|
234
|
+
]);
|
|
303
235
|
expect(loaded2Result?.enforceValue().getID()).toEqual(testEntity2.getID());
|
|
304
236
|
});
|
|
305
237
|
|
|
@@ -308,21 +240,16 @@ describe(EntityAssociationLoader, () => {
|
|
|
308
240
|
const viewerContext = new TestViewerContext(companionProvider);
|
|
309
241
|
|
|
310
242
|
const testEntity = await enforceAsyncResult(
|
|
311
|
-
TestEntity2.creator(viewerContext,
|
|
312
|
-
.setField('foreignKey', uuidv4())
|
|
313
|
-
.createAsync()
|
|
243
|
+
TestEntity2.creator(viewerContext).setField('foreignKey', uuidv4()).createAsync(),
|
|
314
244
|
);
|
|
315
245
|
|
|
316
|
-
const loaded2Result = await testEntity.associationLoader().loadAssociatedEntityThroughAsync(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
],
|
|
324
|
-
viewerContext.getQueryContext()
|
|
325
|
-
);
|
|
246
|
+
const loaded2Result = await testEntity.associationLoader().loadAssociatedEntityThroughAsync([
|
|
247
|
+
{
|
|
248
|
+
associatedEntityClass: TestEntity,
|
|
249
|
+
fieldIdentifyingAssociatedEntity: 'foreignKey',
|
|
250
|
+
associatedEntityLookupByField: 'stringField',
|
|
251
|
+
},
|
|
252
|
+
]);
|
|
326
253
|
expect(loaded2Result).toBeNull();
|
|
327
254
|
});
|
|
328
255
|
|
|
@@ -331,20 +258,15 @@ describe(EntityAssociationLoader, () => {
|
|
|
331
258
|
const viewerContext = new TestViewerContext(companionProvider);
|
|
332
259
|
|
|
333
260
|
const testEntity = await enforceAsyncResult(
|
|
334
|
-
TestEntity.creator(viewerContext,
|
|
335
|
-
.setField('nullableField', null)
|
|
336
|
-
.createAsync()
|
|
261
|
+
TestEntity.creator(viewerContext).setField('nullableField', null).createAsync(),
|
|
337
262
|
);
|
|
338
263
|
|
|
339
|
-
const loadedResult = await testEntity.associationLoader().loadAssociatedEntityThroughAsync(
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
],
|
|
346
|
-
viewerContext.getQueryContext()
|
|
347
|
-
);
|
|
264
|
+
const loadedResult = await testEntity.associationLoader().loadAssociatedEntityThroughAsync([
|
|
265
|
+
{
|
|
266
|
+
associatedEntityClass: TestEntity,
|
|
267
|
+
fieldIdentifyingAssociatedEntity: 'nullableField',
|
|
268
|
+
},
|
|
269
|
+
]);
|
|
348
270
|
expect(loadedResult).toBeNull();
|
|
349
271
|
});
|
|
350
272
|
});
|