@expo/entity 0.35.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 +0 -27
- package/build/Entity.js +0 -50
- package/build/Entity.js.map +1 -1
- package/build/EntityAssociationLoader.d.ts +1 -1
- package/build/EntityAssociationLoader.js +17 -8
- 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/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.js +5 -1
- package/build/ReadonlyEntity.js.map +1 -1
- package/build/ViewerContext.js +2 -0
- 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 +0 -132
- package/build/__tests__/Entity-test.js.map +1 -1
- package/build/__tests__/EntityAssociationLoader-test.js +6 -2
- package/build/__tests__/EntityAssociationLoader-test.js.map +1 -1
- package/build/__tests__/EntityCommonUseCases-test.js +24 -22
- 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 +61 -20
- 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 +16 -17
- package/build/__tests__/EntityLoader-constructor-test.js.map +1 -1
- package/build/__tests__/EntityLoader-test.js +74 -22
- package/build/__tests__/EntityLoader-test.js.map +1 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +12 -15
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +1 -1
- package/build/__tests__/EntityMutator-test.js +54 -9
- 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__/EntitySelfReferentialEdges-test.js +42 -25
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +1 -1
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +20 -18
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +12 -15
- 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 +6 -1
- 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__/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.js +12 -15
- package/build/testfixtures/SimpleTestEntity.js.map +1 -1
- package/build/testfixtures/TestEntity.js +12 -15
- package/build/testfixtures/TestEntity.js.map +1 -1
- 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/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 +11 -126
- package/src/EntityAssociationLoader.ts +40 -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 +5 -5
- 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 +5 -5
- package/src/ViewerContext.ts +5 -5
- 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 +0 -202
- package/src/__tests__/EntityAssociationLoader-test.ts +29 -25
- package/src/__tests__/EntityCommonUseCases-test.ts +29 -13
- 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 +108 -36
- package/src/__tests__/EntityFields-test.ts +14 -2
- package/src/__tests__/EntityLoader-constructor-test.ts +20 -7
- package/src/__tests__/EntityLoader-test.ts +214 -86
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +2 -2
- package/src/__tests__/EntityMutator-test.ts +281 -96
- package/src/__tests__/EntityPrivacyPolicy-test.ts +166 -53
- package/src/__tests__/EntityQueryContext-test.ts +30 -12
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +7 -7
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +46 -26
- package/src/__tests__/GenericEntityCacheAdapter-test.ts +2 -2
- package/src/__tests__/ViewerContext-test.ts +1 -1
- 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 +19 -19
- 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 +24 -24
- 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 +51 -51
- 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/TestEntity.ts +1 -1
- package/src/testfixtures/TestEntityWithMutationTriggers.ts +156 -0
- 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
|
@@ -48,7 +48,7 @@ class TestEntityDatabaseAdapter extends EntityDatabaseAdapter<TestFields> {
|
|
|
48
48
|
_queryInterface: any,
|
|
49
49
|
_tableName: string,
|
|
50
50
|
_tableField: string,
|
|
51
|
-
_tableValues: readonly any[]
|
|
51
|
+
_tableValues: readonly any[],
|
|
52
52
|
): Promise<object[]> {
|
|
53
53
|
return this.fetchResults;
|
|
54
54
|
}
|
|
@@ -57,7 +57,7 @@ class TestEntityDatabaseAdapter extends EntityDatabaseAdapter<TestFields> {
|
|
|
57
57
|
_queryInterface: any,
|
|
58
58
|
_tableName: string,
|
|
59
59
|
_rawWhereClause: string,
|
|
60
|
-
_bindings: object | any[]
|
|
60
|
+
_bindings: object | any[],
|
|
61
61
|
): Promise<object[]> {
|
|
62
62
|
return this.fetchRawWhereResults;
|
|
63
63
|
}
|
|
@@ -66,7 +66,7 @@ class TestEntityDatabaseAdapter extends EntityDatabaseAdapter<TestFields> {
|
|
|
66
66
|
_queryInterface: any,
|
|
67
67
|
_tableName: string,
|
|
68
68
|
_tableFieldSingleValueEqualityOperands: TableFieldSingleValueEqualityCondition[],
|
|
69
|
-
_tableFieldMultiValueEqualityOperands: TableFieldMultiValueEqualityCondition[]
|
|
69
|
+
_tableFieldMultiValueEqualityOperands: TableFieldMultiValueEqualityCondition[],
|
|
70
70
|
): Promise<object[]> {
|
|
71
71
|
return this.fetchEqualityConditionResults;
|
|
72
72
|
}
|
|
@@ -74,7 +74,7 @@ class TestEntityDatabaseAdapter extends EntityDatabaseAdapter<TestFields> {
|
|
|
74
74
|
protected async insertInternalAsync(
|
|
75
75
|
_queryInterface: any,
|
|
76
76
|
_tableName: string,
|
|
77
|
-
_object: object
|
|
77
|
+
_object: object,
|
|
78
78
|
): Promise<object[]> {
|
|
79
79
|
return this.insertResults;
|
|
80
80
|
}
|
|
@@ -84,7 +84,7 @@ class TestEntityDatabaseAdapter extends EntityDatabaseAdapter<TestFields> {
|
|
|
84
84
|
_tableName: string,
|
|
85
85
|
_tableIdField: string,
|
|
86
86
|
_id: any,
|
|
87
|
-
_object: object
|
|
87
|
+
_object: object,
|
|
88
88
|
): Promise<object[]> {
|
|
89
89
|
return this.updateResults;
|
|
90
90
|
}
|
|
@@ -93,7 +93,7 @@ class TestEntityDatabaseAdapter extends EntityDatabaseAdapter<TestFields> {
|
|
|
93
93
|
_queryInterface: any,
|
|
94
94
|
_tableName: string,
|
|
95
95
|
_tableIdField: string,
|
|
96
|
-
_id: any
|
|
96
|
+
_id: any,
|
|
97
97
|
): Promise<number> {
|
|
98
98
|
return this.deleteCount;
|
|
99
99
|
}
|
|
@@ -166,7 +166,7 @@ describe(EntityDatabaseAdapter, () => {
|
|
|
166
166
|
const queryContext = instance(mock(EntityQueryContext));
|
|
167
167
|
const adapter = new TestEntityDatabaseAdapter({ insertResults: [] });
|
|
168
168
|
await expect(adapter.insertAsync(queryContext, {} as any)).rejects.toThrowError(
|
|
169
|
-
'Empty results from database adapter insert'
|
|
169
|
+
'Empty results from database adapter insert',
|
|
170
170
|
);
|
|
171
171
|
});
|
|
172
172
|
|
|
@@ -176,7 +176,7 @@ describe(EntityDatabaseAdapter, () => {
|
|
|
176
176
|
insertResults: [{ string_field: 'hello' }, { string_field: 'hello2' }],
|
|
177
177
|
});
|
|
178
178
|
await expect(adapter.insertAsync(queryContext, {} as any)).rejects.toThrowError(
|
|
179
|
-
'Excessive results from database adapter insert'
|
|
179
|
+
'Excessive results from database adapter insert',
|
|
180
180
|
);
|
|
181
181
|
});
|
|
182
182
|
});
|
|
@@ -193,7 +193,7 @@ describe(EntityDatabaseAdapter, () => {
|
|
|
193
193
|
const queryContext = instance(mock(EntityQueryContext));
|
|
194
194
|
const adapter = new TestEntityDatabaseAdapter({ updateResults: [] });
|
|
195
195
|
await expect(
|
|
196
|
-
adapter.updateAsync(queryContext, 'customIdField', 'wat', {} as any)
|
|
196
|
+
adapter.updateAsync(queryContext, 'customIdField', 'wat', {} as any),
|
|
197
197
|
).rejects.toThrowError('Empty results from database adapter update');
|
|
198
198
|
});
|
|
199
199
|
|
|
@@ -203,7 +203,7 @@ describe(EntityDatabaseAdapter, () => {
|
|
|
203
203
|
updateResults: [{ string_field: 'hello' }, { string_field: 'hello2' }],
|
|
204
204
|
});
|
|
205
205
|
await expect(
|
|
206
|
-
adapter.updateAsync(queryContext, 'customIdField', 'wat', {} as any)
|
|
206
|
+
adapter.updateAsync(queryContext, 'customIdField', 'wat', {} as any),
|
|
207
207
|
).rejects.toThrowError('Excessive results from database adapter update');
|
|
208
208
|
});
|
|
209
209
|
});
|
|
@@ -213,7 +213,7 @@ describe(EntityDatabaseAdapter, () => {
|
|
|
213
213
|
const queryContext = instance(mock(EntityQueryContext));
|
|
214
214
|
const adapter = new TestEntityDatabaseAdapter({ deleteCount: 2 });
|
|
215
215
|
await expect(adapter.deleteAsync(queryContext, 'customIdField', 'wat')).rejects.toThrowError(
|
|
216
|
-
'Excessive deletions from database adapter delet'
|
|
216
|
+
'Excessive deletions from database adapter delet',
|
|
217
217
|
);
|
|
218
218
|
});
|
|
219
219
|
});
|
|
@@ -18,12 +18,17 @@ import TestViewerContext from '../testfixtures/TestViewerContext';
|
|
|
18
18
|
import { InMemoryFullCacheStubCacheAdapter } from '../utils/testing/StubCacheAdapter';
|
|
19
19
|
import { createUnitTestEntityCompanionProvider } from '../utils/testing/createUnitTestEntityCompanionProvider';
|
|
20
20
|
|
|
21
|
+
interface OtherFields {
|
|
22
|
+
id: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
interface ParentFields {
|
|
22
26
|
id: string;
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
interface ChildFields {
|
|
26
30
|
id: string;
|
|
31
|
+
unused_other_edge_id: string | null;
|
|
27
32
|
parent_id: string;
|
|
28
33
|
}
|
|
29
34
|
|
|
@@ -80,12 +85,18 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
80
85
|
async evaluateAsync(
|
|
81
86
|
_viewerContext: TestViewerContext,
|
|
82
87
|
_queryContext: EntityQueryContext,
|
|
83
|
-
evaluationContext: EntityPrivacyPolicyEvaluationContext
|
|
84
|
-
|
|
88
|
+
evaluationContext: EntityPrivacyPolicyEvaluationContext<
|
|
89
|
+
any,
|
|
90
|
+
string,
|
|
91
|
+
TestViewerContext,
|
|
92
|
+
any,
|
|
93
|
+
any
|
|
94
|
+
>,
|
|
95
|
+
entity: any,
|
|
85
96
|
): Promise<RuleEvaluationResult> {
|
|
86
97
|
if (privacyPolicyEvaluationRecords.shouldRecord) {
|
|
87
98
|
(privacyPolicyEvaluationRecords as any)[entity.constructor.name][this.action].push(
|
|
88
|
-
evaluationContext
|
|
99
|
+
evaluationContext,
|
|
89
100
|
);
|
|
90
101
|
}
|
|
91
102
|
return RuleEvaluationResult.ALLOW;
|
|
@@ -123,7 +134,12 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
123
134
|
_viewerContext: TestViewerContext,
|
|
124
135
|
_queryContext: EntityTransactionalQueryContext,
|
|
125
136
|
_entity: ParentEntity,
|
|
126
|
-
mutationInfo: EntityTriggerMutationInfo<
|
|
137
|
+
mutationInfo: EntityTriggerMutationInfo<
|
|
138
|
+
ParentFields,
|
|
139
|
+
string,
|
|
140
|
+
TestViewerContext,
|
|
141
|
+
ParentEntity
|
|
142
|
+
>,
|
|
127
143
|
): Promise<void> {
|
|
128
144
|
invariant(mutationInfo.type === EntityMutationType.DELETE, 'invalid EntityMutationType');
|
|
129
145
|
if (mutationInfo.cascadingDeleteCause !== null) {
|
|
@@ -144,7 +160,12 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
144
160
|
_viewerContext: TestViewerContext,
|
|
145
161
|
_queryContext: EntityTransactionalQueryContext,
|
|
146
162
|
_entity: ParentEntity,
|
|
147
|
-
mutationInfo: EntityTriggerMutationInfo<
|
|
163
|
+
mutationInfo: EntityTriggerMutationInfo<
|
|
164
|
+
ParentFields,
|
|
165
|
+
string,
|
|
166
|
+
TestViewerContext,
|
|
167
|
+
ParentEntity
|
|
168
|
+
>,
|
|
148
169
|
): Promise<void> {
|
|
149
170
|
invariant(mutationInfo.type === EntityMutationType.UPDATE, 'invalid EntityMutationType');
|
|
150
171
|
if (mutationInfo.cascadingDeleteCause !== null) {
|
|
@@ -165,7 +186,7 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
165
186
|
_viewerContext: TestViewerContext,
|
|
166
187
|
_queryContext: EntityTransactionalQueryContext,
|
|
167
188
|
_entity: ChildEntity,
|
|
168
|
-
mutationInfo: EntityTriggerMutationInfo<ChildFields, string, TestViewerContext, ChildEntity
|
|
189
|
+
mutationInfo: EntityTriggerMutationInfo<ChildFields, string, TestViewerContext, ChildEntity>,
|
|
169
190
|
): Promise<void> {
|
|
170
191
|
invariant(mutationInfo.type === EntityMutationType.DELETE, 'invalid EntityMutationType');
|
|
171
192
|
if (mutationInfo.cascadingDeleteCause === null) {
|
|
@@ -197,7 +218,7 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
197
218
|
_viewerContext: TestViewerContext,
|
|
198
219
|
_queryContext: EntityTransactionalQueryContext,
|
|
199
220
|
_entity: ChildEntity,
|
|
200
|
-
mutationInfo: EntityTriggerMutationInfo<ChildFields, string, TestViewerContext, ChildEntity
|
|
221
|
+
mutationInfo: EntityTriggerMutationInfo<ChildFields, string, TestViewerContext, ChildEntity>,
|
|
201
222
|
): Promise<void> {
|
|
202
223
|
invariant(mutationInfo.type === EntityMutationType.UPDATE, 'invalid EntityMutationType');
|
|
203
224
|
if (mutationInfo.cascadingDeleteCause === null) {
|
|
@@ -234,7 +255,7 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
234
255
|
string,
|
|
235
256
|
TestViewerContext,
|
|
236
257
|
GrandChildEntity
|
|
237
|
-
|
|
258
|
+
>,
|
|
238
259
|
): Promise<void> {
|
|
239
260
|
invariant(mutationInfo.type === EntityMutationType.DELETE, 'invalid EntityMutationType');
|
|
240
261
|
if (mutationInfo.cascadingDeleteCause === null) {
|
|
@@ -244,7 +265,7 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
244
265
|
const cascadingDeleteCauseEntity = mutationInfo.cascadingDeleteCause.entity;
|
|
245
266
|
if (!(cascadingDeleteCauseEntity instanceof ChildEntity)) {
|
|
246
267
|
throw new Error(
|
|
247
|
-
'GrandChild entity should have cascade delete cause entity of type ChildEntity'
|
|
268
|
+
'GrandChild entity should have cascade delete cause entity of type ChildEntity',
|
|
248
269
|
);
|
|
249
270
|
}
|
|
250
271
|
|
|
@@ -257,7 +278,7 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
257
278
|
const secondLevelCascadingDeleteCauseEntity = secondLevelCascadingDeleteCause.entity;
|
|
258
279
|
if (!(secondLevelCascadingDeleteCauseEntity instanceof ParentEntity)) {
|
|
259
280
|
throw new Error(
|
|
260
|
-
'GrandChild entity should have second level casade delete cause entity of type ParentEntity'
|
|
281
|
+
'GrandChild entity should have second level casade delete cause entity of type ParentEntity',
|
|
261
282
|
);
|
|
262
283
|
}
|
|
263
284
|
|
|
@@ -285,7 +306,7 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
285
306
|
string,
|
|
286
307
|
TestViewerContext,
|
|
287
308
|
GrandChildEntity
|
|
288
|
-
|
|
309
|
+
>,
|
|
289
310
|
): Promise<void> {
|
|
290
311
|
invariant(mutationInfo.type === EntityMutationType.UPDATE, 'invalid EntityMutationType');
|
|
291
312
|
if (mutationInfo.cascadingDeleteCause === null) {
|
|
@@ -295,7 +316,7 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
295
316
|
const cascadingDeleteCauseEntity = mutationInfo.cascadingDeleteCause.entity;
|
|
296
317
|
if (!(cascadingDeleteCauseEntity instanceof ChildEntity)) {
|
|
297
318
|
throw new Error(
|
|
298
|
-
'GrandChild entity should have cascade delete cause entity of type ChildEntity'
|
|
319
|
+
'GrandChild entity should have cascade delete cause entity of type ChildEntity',
|
|
299
320
|
);
|
|
300
321
|
}
|
|
301
322
|
|
|
@@ -308,7 +329,7 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
308
329
|
const secondLevelCascadingDeleteCauseEntity = secondLevelCascadingDeleteCause.entity;
|
|
309
330
|
if (!(secondLevelCascadingDeleteCauseEntity instanceof ParentEntity)) {
|
|
310
331
|
throw new Error(
|
|
311
|
-
'GrandChild entity should have second level casade delete cause entity of type ParentEntity'
|
|
332
|
+
'GrandChild entity should have second level casade delete cause entity of type ParentEntity',
|
|
312
333
|
);
|
|
313
334
|
}
|
|
314
335
|
|
|
@@ -321,6 +342,22 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
321
342
|
}
|
|
322
343
|
}
|
|
323
344
|
|
|
345
|
+
class OtherEntity extends Entity<OtherFields, string, TestViewerContext> {
|
|
346
|
+
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
347
|
+
OtherFields,
|
|
348
|
+
string,
|
|
349
|
+
TestViewerContext,
|
|
350
|
+
OtherEntity,
|
|
351
|
+
TestEntityPrivacyPolicy
|
|
352
|
+
> {
|
|
353
|
+
return {
|
|
354
|
+
entityClass: ParentEntity,
|
|
355
|
+
entityConfiguration: otherEntityConfiguration,
|
|
356
|
+
privacyPolicyClass: TestEntityPrivacyPolicy,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
324
361
|
class ParentEntity extends Entity<ParentFields, string, TestViewerContext> {
|
|
325
362
|
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
326
363
|
ParentFields,
|
|
@@ -390,6 +427,19 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
390
427
|
}
|
|
391
428
|
}
|
|
392
429
|
|
|
430
|
+
const otherEntityConfiguration = new EntityConfiguration<OtherFields>({
|
|
431
|
+
idField: 'id',
|
|
432
|
+
tableName: 'others',
|
|
433
|
+
schema: {
|
|
434
|
+
id: new UUIDField({
|
|
435
|
+
columnName: 'id',
|
|
436
|
+
cache: true,
|
|
437
|
+
}),
|
|
438
|
+
},
|
|
439
|
+
databaseAdapterFlavor: 'postgres',
|
|
440
|
+
cacheAdapterFlavor: 'redis',
|
|
441
|
+
});
|
|
442
|
+
|
|
393
443
|
const parentEntityConfiguration = new EntityConfiguration<ParentFields>({
|
|
394
444
|
idField: 'id',
|
|
395
445
|
tableName: 'parents',
|
|
@@ -413,11 +463,19 @@ const makeEntityClasses = (edgeDeletionBehavior: EntityEdgeDeletionBehavior) =>
|
|
|
413
463
|
columnName: 'id',
|
|
414
464
|
cache: true,
|
|
415
465
|
}),
|
|
466
|
+
unused_other_edge_id: new UUIDField({
|
|
467
|
+
columnName: 'unused_other_edge_id',
|
|
468
|
+
association: {
|
|
469
|
+
associatedEntityClass: OtherEntity,
|
|
470
|
+
edgeDeletionBehavior,
|
|
471
|
+
},
|
|
472
|
+
}),
|
|
416
473
|
parent_id: new UUIDField({
|
|
417
474
|
columnName: 'parent_id',
|
|
418
475
|
cache: true,
|
|
419
476
|
association: {
|
|
420
477
|
associatedEntityClass: ParentEntity,
|
|
478
|
+
associatedEntityLookupByField: 'id', // sanity check that this functionality works by using it for one edge
|
|
421
479
|
edgeDeletionBehavior,
|
|
422
480
|
},
|
|
423
481
|
}),
|
|
@@ -478,13 +536,15 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
|
|
|
478
536
|
.enforceCreateAsync();
|
|
479
537
|
|
|
480
538
|
await expect(
|
|
481
|
-
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID())
|
|
539
|
+
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
|
|
482
540
|
).resolves.not.toBeNull();
|
|
483
541
|
await expect(
|
|
484
|
-
ChildEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(child.getID())
|
|
542
|
+
ChildEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(child.getID()),
|
|
485
543
|
).resolves.not.toBeNull();
|
|
486
544
|
await expect(
|
|
487
|
-
GrandChildEntity.loader(viewerContext)
|
|
545
|
+
GrandChildEntity.loader(viewerContext)
|
|
546
|
+
.enforcing()
|
|
547
|
+
.loadByIDNullableAsync(grandchild.getID()),
|
|
488
548
|
).resolves.not.toBeNull();
|
|
489
549
|
|
|
490
550
|
privacyPolicyEvaluationRecords.shouldRecord = true;
|
|
@@ -492,13 +552,15 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
|
|
|
492
552
|
privacyPolicyEvaluationRecords.shouldRecord = false;
|
|
493
553
|
|
|
494
554
|
await expect(
|
|
495
|
-
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID())
|
|
555
|
+
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
|
|
496
556
|
).resolves.toBeNull();
|
|
497
557
|
await expect(
|
|
498
|
-
ChildEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(child.getID())
|
|
558
|
+
ChildEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(child.getID()),
|
|
499
559
|
).resolves.toBeNull();
|
|
500
560
|
await expect(
|
|
501
|
-
GrandChildEntity.loader(viewerContext)
|
|
561
|
+
GrandChildEntity.loader(viewerContext)
|
|
562
|
+
.enforcing()
|
|
563
|
+
.loadByIDNullableAsync(grandchild.getID()),
|
|
502
564
|
).resolves.toBeNull();
|
|
503
565
|
|
|
504
566
|
// two calls for each trigger, one beforeDelete, one afterDelete
|
|
@@ -596,13 +658,15 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
|
|
|
596
658
|
.enforceCreateAsync();
|
|
597
659
|
|
|
598
660
|
await expect(
|
|
599
|
-
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID())
|
|
661
|
+
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
|
|
600
662
|
).resolves.not.toBeNull();
|
|
601
663
|
await expect(
|
|
602
|
-
ChildEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(child.getID())
|
|
664
|
+
ChildEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(child.getID()),
|
|
603
665
|
).resolves.not.toBeNull();
|
|
604
666
|
await expect(
|
|
605
|
-
GrandChildEntity.loader(viewerContext)
|
|
667
|
+
GrandChildEntity.loader(viewerContext)
|
|
668
|
+
.enforcing()
|
|
669
|
+
.loadByIDNullableAsync(grandchild.getID()),
|
|
606
670
|
).resolves.not.toBeNull();
|
|
607
671
|
|
|
608
672
|
privacyPolicyEvaluationRecords.shouldRecord = true;
|
|
@@ -610,7 +674,7 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
|
|
|
610
674
|
privacyPolicyEvaluationRecords.shouldRecord = false;
|
|
611
675
|
|
|
612
676
|
await expect(
|
|
613
|
-
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID())
|
|
677
|
+
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
|
|
614
678
|
).resolves.toBeNull();
|
|
615
679
|
|
|
616
680
|
const loadedChild = await ChildEntity.loader(viewerContext)
|
|
@@ -707,17 +771,17 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
|
|
|
707
771
|
.enforceCreateAsync();
|
|
708
772
|
|
|
709
773
|
await expect(
|
|
710
|
-
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID())
|
|
774
|
+
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
|
|
711
775
|
).resolves.not.toBeNull();
|
|
712
776
|
await expect(
|
|
713
777
|
ChildEntity.loader(viewerContext)
|
|
714
778
|
.enforcing()
|
|
715
|
-
.loadByFieldEqualingAsync('parent_id', parent.getID())
|
|
779
|
+
.loadByFieldEqualingAsync('parent_id', parent.getID()),
|
|
716
780
|
).resolves.not.toBeNull();
|
|
717
781
|
await expect(
|
|
718
782
|
GrandChildEntity.loader(viewerContext)
|
|
719
783
|
.enforcing()
|
|
720
|
-
.loadByFieldEqualingAsync('parent_id', child.getID())
|
|
784
|
+
.loadByFieldEqualingAsync('parent_id', child.getID()),
|
|
721
785
|
).resolves.not.toBeNull();
|
|
722
786
|
|
|
723
787
|
const childCacheAdapter = viewerContext.getViewerScopedEntityCompanionForClass(ChildEntity)[
|
|
@@ -729,7 +793,7 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
|
|
|
729
793
|
expect(childCachedBefore.get(parent.getID())?.status).toEqual(CacheStatus.HIT);
|
|
730
794
|
|
|
731
795
|
const grandChildCacheAdapter = viewerContext.getViewerScopedEntityCompanionForClass(
|
|
732
|
-
GrandChildEntity
|
|
796
|
+
GrandChildEntity,
|
|
733
797
|
)['entityCompanion']['tableDataCoordinator'][
|
|
734
798
|
'cacheAdapter'
|
|
735
799
|
] as InMemoryFullCacheStubCacheAdapter<ChildFields>;
|
|
@@ -751,7 +815,7 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
|
|
|
751
815
|
expect(grandChildCachedAfter.get(child.getID())?.status).toEqual(CacheStatus.HIT);
|
|
752
816
|
|
|
753
817
|
await expect(
|
|
754
|
-
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID())
|
|
818
|
+
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
|
|
755
819
|
).resolves.toBeNull();
|
|
756
820
|
|
|
757
821
|
const loadedChild = await ChildEntity.loader(viewerContext)
|
|
@@ -787,7 +851,7 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
|
|
|
787
851
|
ChildEntity: {
|
|
788
852
|
[EntityAuthorizationAction.CREATE]: [],
|
|
789
853
|
|
|
790
|
-
//
|
|
854
|
+
// two READs auth action for child in order to update via cascade
|
|
791
855
|
// no other entities are read since it is not cascaded past first entity
|
|
792
856
|
[EntityAuthorizationAction.READ]: [
|
|
793
857
|
{
|
|
@@ -796,6 +860,12 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
|
|
|
796
860
|
cascadingDeleteCause: null,
|
|
797
861
|
},
|
|
798
862
|
},
|
|
863
|
+
{
|
|
864
|
+
cascadingDeleteCause: {
|
|
865
|
+
entity: expect.any(ParentEntity),
|
|
866
|
+
cascadingDeleteCause: null,
|
|
867
|
+
},
|
|
868
|
+
},
|
|
799
869
|
],
|
|
800
870
|
// one UPDATE to set null
|
|
801
871
|
[EntityAuthorizationAction.UPDATE]: [
|
|
@@ -840,17 +910,17 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
|
|
|
840
910
|
.enforceCreateAsync();
|
|
841
911
|
|
|
842
912
|
await expect(
|
|
843
|
-
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID())
|
|
913
|
+
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
|
|
844
914
|
).resolves.not.toBeNull();
|
|
845
915
|
await expect(
|
|
846
916
|
ChildEntity.loader(viewerContext)
|
|
847
917
|
.enforcing()
|
|
848
|
-
.loadByFieldEqualingAsync('parent_id', parent.getID())
|
|
918
|
+
.loadByFieldEqualingAsync('parent_id', parent.getID()),
|
|
849
919
|
).resolves.not.toBeNull();
|
|
850
920
|
await expect(
|
|
851
921
|
GrandChildEntity.loader(viewerContext)
|
|
852
922
|
.enforcing()
|
|
853
|
-
.loadByFieldEqualingAsync('parent_id', child.getID())
|
|
923
|
+
.loadByFieldEqualingAsync('parent_id', child.getID()),
|
|
854
924
|
).resolves.not.toBeNull();
|
|
855
925
|
|
|
856
926
|
const childCacheAdapter = viewerContext.getViewerScopedEntityCompanionForClass(ChildEntity)[
|
|
@@ -862,7 +932,7 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
|
|
|
862
932
|
expect(childCachedBefore.get(parent.getID())?.status).toEqual(CacheStatus.HIT);
|
|
863
933
|
|
|
864
934
|
const grandChildCacheAdapter = viewerContext.getViewerScopedEntityCompanionForClass(
|
|
865
|
-
GrandChildEntity
|
|
935
|
+
GrandChildEntity,
|
|
866
936
|
)['entityCompanion']['tableDataCoordinator'][
|
|
867
937
|
'cacheAdapter'
|
|
868
938
|
] as InMemoryFullCacheStubCacheAdapter<ChildFields>;
|
|
@@ -884,13 +954,15 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
|
|
|
884
954
|
expect(grandChildCachedAfter.get(child.getID())?.status).toEqual(CacheStatus.MISS);
|
|
885
955
|
|
|
886
956
|
await expect(
|
|
887
|
-
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID())
|
|
957
|
+
ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
|
|
888
958
|
).resolves.toBeNull();
|
|
889
959
|
await expect(
|
|
890
|
-
ChildEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(child.getID())
|
|
960
|
+
ChildEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(child.getID()),
|
|
891
961
|
).resolves.not.toBeNull();
|
|
892
962
|
await expect(
|
|
893
|
-
GrandChildEntity.loader(viewerContext)
|
|
963
|
+
GrandChildEntity.loader(viewerContext)
|
|
964
|
+
.enforcing()
|
|
965
|
+
.loadByIDNullableAsync(grandchild.getID()),
|
|
894
966
|
).resolves.not.toBeNull();
|
|
895
967
|
|
|
896
968
|
// two calls for each trigger, one beforeDelete, one afterDelete
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
StringArrayField,
|
|
12
12
|
JSONObjectField,
|
|
13
13
|
EnumField,
|
|
14
|
+
StrictEnumField,
|
|
14
15
|
} from '../EntityFields';
|
|
15
16
|
import describeFieldTestCase from '../utils/testing/describeFieldTestCase';
|
|
16
17
|
|
|
@@ -62,7 +63,7 @@ describeFieldTestCase(
|
|
|
62
63
|
uuidv5('wat', uuidv5.DNS),
|
|
63
64
|
/* UUIDv7 */ '018ebfda-dc80-782d-a891-22a0aa057d52',
|
|
64
65
|
],
|
|
65
|
-
[uuidv4().replace('-', ''), '', 'hello']
|
|
66
|
+
[uuidv4().replace('-', ''), '', 'hello'],
|
|
66
67
|
);
|
|
67
68
|
describeFieldTestCase(new DateField({ columnName: 'wat' }), [new Date()], [Date.now()]);
|
|
68
69
|
describeFieldTestCase(new BooleanField({ columnName: 'wat' }), [true, false], [0, 1, '']);
|
|
@@ -71,7 +72,18 @@ describeFieldTestCase(new FloatField({ columnName: 'wat' }), [1, 0.5, -0.5], ['1
|
|
|
71
72
|
describeFieldTestCase(
|
|
72
73
|
new StringArrayField({ columnName: 'wat' }),
|
|
73
74
|
[[['what']] as any, [[]] as any], // jest test cases need extra wrapping array
|
|
74
|
-
['hello']
|
|
75
|
+
['hello'],
|
|
75
76
|
);
|
|
76
77
|
describeFieldTestCase(new JSONObjectField({ columnName: 'wat' }), [{}], [true, 'hello']);
|
|
77
78
|
describeFieldTestCase(new EnumField({ columnName: 'wat' }), ['hello', 1], [true]);
|
|
79
|
+
|
|
80
|
+
enum TestEnum {
|
|
81
|
+
HELLO = 'world',
|
|
82
|
+
WHO = 'wat',
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
describeFieldTestCase(
|
|
86
|
+
new StrictEnumField({ columnName: 'wat', enum: TestEnum }),
|
|
87
|
+
[TestEnum.HELLO, TestEnum.WHO, 'world'],
|
|
88
|
+
['what', 1, true],
|
|
89
|
+
);
|
|
@@ -121,7 +121,18 @@ export default class TestEntity extends Entity<
|
|
|
121
121
|
describe(EntityLoader, () => {
|
|
122
122
|
it('handles thrown errors and literals from constructor', async () => {
|
|
123
123
|
const viewerContext = instance(mock(ViewerContext));
|
|
124
|
-
const privacyPolicyEvaluationContext =
|
|
124
|
+
const privacyPolicyEvaluationContext =
|
|
125
|
+
instance(
|
|
126
|
+
mock<
|
|
127
|
+
EntityPrivacyPolicyEvaluationContext<
|
|
128
|
+
TestFields,
|
|
129
|
+
string,
|
|
130
|
+
ViewerContext,
|
|
131
|
+
TestEntity,
|
|
132
|
+
TestFieldSelection
|
|
133
|
+
>
|
|
134
|
+
>(),
|
|
135
|
+
);
|
|
125
136
|
const metricsAdapter = instance(mock<IEntityMetricsAdapter>());
|
|
126
137
|
const queryContext = StubQueryContextProvider.getQueryContext();
|
|
127
138
|
|
|
@@ -141,8 +152,8 @@ describe(EntityLoader, () => {
|
|
|
141
152
|
},
|
|
142
153
|
],
|
|
143
154
|
],
|
|
144
|
-
])
|
|
145
|
-
)
|
|
155
|
+
]),
|
|
156
|
+
),
|
|
146
157
|
);
|
|
147
158
|
const privacyPolicy = new TestEntityPrivacyPolicy();
|
|
148
159
|
const cacheAdapterProvider = new NoCacheStubCacheAdapterProvider();
|
|
@@ -153,7 +164,7 @@ describe(EntityLoader, () => {
|
|
|
153
164
|
entityCache,
|
|
154
165
|
StubQueryContextProvider,
|
|
155
166
|
metricsAdapter,
|
|
156
|
-
TestEntity.name
|
|
167
|
+
TestEntity.name,
|
|
157
168
|
);
|
|
158
169
|
const entityLoader = new EntityLoader(
|
|
159
170
|
viewerContext,
|
|
@@ -164,19 +175,21 @@ describe(EntityLoader, () => {
|
|
|
164
175
|
/* entitySelectedFields */ undefined,
|
|
165
176
|
privacyPolicy,
|
|
166
177
|
dataManager,
|
|
167
|
-
metricsAdapter
|
|
178
|
+
metricsAdapter,
|
|
168
179
|
);
|
|
169
180
|
|
|
170
181
|
let capturedThrownThing1: any;
|
|
171
182
|
try {
|
|
172
|
-
await entityLoader.loadByIDAsync(ID_SENTINEL_THROW_LITERAL);
|
|
183
|
+
await entityLoader.withAuthorizationResults().loadByIDAsync(ID_SENTINEL_THROW_LITERAL);
|
|
173
184
|
} catch (e) {
|
|
174
185
|
capturedThrownThing1 = e;
|
|
175
186
|
}
|
|
176
187
|
expect(capturedThrownThing1).not.toBeInstanceOf(Error);
|
|
177
188
|
expect(capturedThrownThing1).toEqual('hello');
|
|
178
189
|
|
|
179
|
-
const result = await entityLoader
|
|
190
|
+
const result = await entityLoader
|
|
191
|
+
.withAuthorizationResults()
|
|
192
|
+
.loadByIDAsync(ID_SENTINEL_THROW_ERROR);
|
|
180
193
|
expect(result.ok).toBe(false);
|
|
181
194
|
expect(result.enforceError().message).toEqual('world');
|
|
182
195
|
});
|