@expo/entity 0.17.0 → 0.21.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/EnforcingEntityLoader.js +2 -2
- package/build/EnforcingEntityLoader.js.map +1 -1
- package/build/Entity.js +8 -2
- package/build/Entity.js.map +1 -1
- package/build/EntityAssociationLoader.js +3 -3
- package/build/EntityAssociationLoader.js.map +1 -1
- package/build/EntityCompanion.d.ts +5 -0
- package/build/EntityCompanion.js +8 -1
- package/build/EntityCompanion.js.map +1 -1
- package/build/EntityCompanionProvider.d.ts +1 -1
- package/build/EntityCompanionProvider.js +5 -5
- package/build/EntityCompanionProvider.js.map +1 -1
- package/build/EntityConfiguration.d.ts +1 -1
- package/build/EntityConfiguration.js +3 -3
- package/build/EntityConfiguration.js.map +1 -1
- package/build/EntityDatabaseAdapter.d.ts +4 -4
- package/build/EntityDatabaseAdapter.js +13 -13
- package/build/EntityDatabaseAdapter.js.map +1 -1
- package/build/EntityFieldDefinition.d.ts +77 -0
- package/build/EntityFieldDefinition.js +53 -0
- package/build/EntityFieldDefinition.js.map +1 -0
- package/build/EntityFields.d.ts +1 -77
- package/build/EntityFields.js +13 -61
- package/build/EntityFields.js.map +1 -1
- package/build/EntityLoader.d.ts +3 -1
- package/build/EntityLoader.js +19 -15
- package/build/EntityLoader.js.map +1 -1
- package/build/EntityLoaderFactory.d.ts +3 -1
- package/build/EntityLoaderFactory.js +3 -2
- package/build/EntityLoaderFactory.js.map +1 -1
- package/build/EntityMutationInfo.d.ts +26 -0
- package/build/EntityMutationInfo.js +10 -0
- package/build/EntityMutationInfo.js.map +1 -0
- package/build/EntityMutationTriggerConfiguration.d.ts +4 -4
- package/build/EntityMutationValidator.d.ts +3 -3
- package/build/EntityMutationValidator.js.map +1 -1
- package/build/EntityMutator.d.ts +5 -16
- package/build/EntityMutator.js +62 -58
- package/build/EntityMutator.js.map +1 -1
- package/build/EntityPrivacyPolicy.d.ts +5 -4
- package/build/EntityPrivacyPolicy.js +60 -12
- package/build/EntityPrivacyPolicy.js.map +1 -1
- package/build/EntityQueryContext.d.ts +24 -0
- package/build/EntityQueryContext.js +43 -0
- package/build/EntityQueryContext.js.map +1 -1
- package/build/EntityQueryContextProvider.js +1 -0
- package/build/EntityQueryContextProvider.js.map +1 -1
- package/build/EntitySecondaryCacheLoader.js +2 -2
- package/build/EntitySecondaryCacheLoader.js.map +1 -1
- package/build/ReadonlyEntity.js +3 -4
- package/build/ReadonlyEntity.js.map +1 -1
- package/build/ViewerScopedEntityCompanion.d.ts +5 -0
- package/build/ViewerScopedEntityCompanion.js +6 -0
- package/build/ViewerScopedEntityCompanion.js.map +1 -1
- package/build/__tests__/EnforcingEntityLoader-test.js +82 -82
- package/build/__tests__/EnforcingEntityLoader-test.js.map +1 -1
- package/build/__tests__/Entity-test.js +6 -6
- package/build/__tests__/Entity-test.js.map +1 -1
- package/build/__tests__/EntityAssociationLoader-test.js +40 -40
- package/build/__tests__/EntityAssociationLoader-test.js.map +1 -1
- package/build/__tests__/EntityCommonUseCases-test.js +11 -11
- package/build/__tests__/EntityCommonUseCases-test.js.map +1 -1
- package/build/__tests__/EntityCompanion-test.js +3 -3
- package/build/__tests__/EntityCompanion-test.js.map +1 -1
- package/build/__tests__/EntityCompanionProvider-test.js +1 -1
- package/build/__tests__/EntityCompanionProvider-test.js.map +1 -1
- package/build/__tests__/EntityDatabaseAdapter-test.js +12 -12
- package/build/__tests__/EntityDatabaseAdapter-test.js.map +1 -1
- package/build/__tests__/EntityEdges-test.js +103 -6
- package/build/__tests__/EntityEdges-test.js.map +1 -1
- package/build/__tests__/EntityFields-test.js +18 -27
- package/build/__tests__/EntityFields-test.js.map +1 -1
- package/build/__tests__/EntityLoader-constructor-test.d.ts +22 -0
- package/build/__tests__/EntityLoader-constructor-test.js +111 -0
- package/build/__tests__/EntityLoader-constructor-test.js.map +1 -0
- package/build/__tests__/EntityLoader-test.js +72 -64
- package/build/__tests__/EntityLoader-test.js.map +1 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.d.ts +1 -0
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +81 -0
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +1 -0
- package/build/__tests__/EntityMutator-test.js +116 -114
- package/build/__tests__/EntityMutator-test.js.map +1 -1
- package/build/__tests__/EntityPrivacyPolicy-test.js +143 -67
- package/build/__tests__/EntityPrivacyPolicy-test.js.map +1 -1
- package/build/__tests__/EntityQueryContext-test.d.ts +1 -0
- package/build/__tests__/EntityQueryContext-test.js +56 -0
- package/build/__tests__/EntityQueryContext-test.js.map +1 -0
- package/build/__tests__/EntitySecondaryCacheLoader-test.js +15 -15
- package/build/__tests__/EntitySecondaryCacheLoader-test.js.map +1 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.js +13 -12
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +1 -1
- package/build/__tests__/ReadonlyEntity-test.js +11 -11
- 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__/ViewerScopedEntityCompanion-test.js +2 -2
- package/build/__tests__/ViewerScopedEntityCompanion-test.js.map +1 -1
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js +2 -2
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js.map +1 -1
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js +5 -5
- package/build/__tests__/ViewerScopedEntityLoaderFactory-test.js.map +1 -1
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js +5 -5
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +5 -5
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +2 -2
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +1 -1
- package/build/__tests__/entityUtils-test.js +21 -21
- package/build/__tests__/entityUtils-test.js.map +1 -1
- package/build/index.d.ts +3 -0
- package/build/index.js +5 -1
- package/build/index.js.map +1 -1
- package/build/internal/EntityDataManager.js +8 -7
- package/build/internal/EntityDataManager.js.map +1 -1
- package/build/internal/EntityFieldTransformationUtils.js +2 -2
- package/build/internal/EntityFieldTransformationUtils.js.map +1 -1
- package/build/internal/ReadThroughEntityCache.js +4 -4
- package/build/internal/ReadThroughEntityCache.js.map +1 -1
- package/build/internal/__tests__/EntityDataManager-test.js +17 -17
- package/build/internal/__tests__/EntityDataManager-test.js.map +1 -1
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js +8 -8
- package/build/internal/__tests__/EntityFieldTransformationUtils-test.js.map +1 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.js +48 -48
- package/build/internal/__tests__/ReadThroughEntityCache-test.js.map +1 -1
- package/build/metrics/EntityMetricsUtils.js +1 -1
- package/build/metrics/EntityMetricsUtils.js.map +1 -1
- package/build/metrics/IEntityMetricsAdapter.d.ts +16 -0
- package/build/metrics/IEntityMetricsAdapter.js +6 -1
- package/build/metrics/IEntityMetricsAdapter.js.map +1 -1
- package/build/metrics/NoOpEntityMetricsAdapter.d.ts +2 -1
- package/build/metrics/NoOpEntityMetricsAdapter.js +1 -0
- package/build/metrics/NoOpEntityMetricsAdapter.js.map +1 -1
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js +4 -4
- package/build/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.js.map +1 -1
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js +4 -4
- package/build/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.js.map +1 -1
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js +4 -4
- package/build/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.js.map +1 -1
- package/build/testfixtures/DateIDTestEntity.js.map +1 -1
- package/build/testfixtures/SimpleTestEntity.js.map +1 -1
- package/build/testfixtures/TestEntity.d.ts +5 -5
- package/build/testfixtures/TestEntity.js +2 -2
- package/build/testfixtures/TestEntity.js.map +1 -1
- package/build/testfixtures/TestEntity2.d.ts +5 -5
- package/build/testfixtures/TestEntity2.js.map +1 -1
- package/build/testfixtures/TestEntityNumberKey.js.map +1 -1
- package/build/utils/collections/__tests__/maps-test.js +13 -13
- package/build/utils/collections/__tests__/maps-test.js.map +1 -1
- package/build/utils/collections/maps.js +1 -1
- package/build/utils/collections/maps.js.map +1 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.d.ts +6 -6
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js +1 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js.map +1 -1
- package/build/utils/testing/StubCacheAdapter.js +1 -1
- package/build/utils/testing/StubCacheAdapter.js.map +1 -1
- package/build/utils/testing/StubDatabaseAdapter.js +6 -6
- package/build/utils/testing/StubDatabaseAdapter.js.map +1 -1
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js +9 -9
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js.map +1 -1
- package/build/utils/testing/describeFieldTestCase.d.ts +2 -0
- package/build/utils/testing/describeFieldTestCase.js +18 -0
- package/build/utils/testing/describeFieldTestCase.js.map +1 -0
- package/package.json +2 -1
- package/src/Entity.ts +10 -2
- package/src/EntityAssociationLoader.ts +1 -1
- package/src/EntityCompanion.ts +10 -2
- package/src/EntityCompanionProvider.ts +5 -9
- package/src/EntityConfiguration.ts +1 -1
- package/src/EntityDatabaseAdapter.ts +10 -8
- package/src/EntityFieldDefinition.ts +124 -0
- package/src/EntityFields.ts +2 -125
- package/src/EntityLoader.ts +12 -4
- package/src/EntityLoaderFactory.ts +5 -2
- package/src/EntityMutationInfo.ts +47 -0
- package/src/EntityMutationTriggerConfiguration.ts +5 -5
- package/src/EntityMutationValidator.ts +10 -4
- package/src/EntityMutator.ts +98 -76
- package/src/EntityPrivacyPolicy.ts +77 -19
- package/src/EntityQueryContext.ts +54 -0
- package/src/EntityQueryContextProvider.ts +1 -0
- package/src/ReadonlyEntity.ts +3 -2
- package/src/ViewerScopedEntityCompanion.ts +8 -0
- package/src/__tests__/Entity-test.ts +8 -8
- package/src/__tests__/EntityCommonUseCases-test.ts +4 -4
- package/src/__tests__/EntityEdges-test.ts +169 -14
- package/src/__tests__/EntityFields-test.ts +2 -21
- package/src/__tests__/EntityLoader-constructor-test.ts +177 -0
- package/src/__tests__/EntityLoader-test.ts +39 -11
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +105 -0
- package/src/__tests__/EntityMutator-test.ts +140 -133
- package/src/__tests__/EntityPrivacyPolicy-test.ts +215 -78
- package/src/__tests__/EntityQueryContext-test.ts +82 -0
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +7 -9
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +6 -5
- package/src/__tests__/ViewerContext-test.ts +7 -6
- package/src/__tests__/ViewerScopedEntityCompanion-test.ts +11 -10
- package/src/__tests__/ViewerScopedEntityMutatorFactory-test.ts +4 -3
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +6 -6
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +4 -4
- package/src/index.ts +3 -0
- package/src/internal/EntityDataManager.ts +2 -1
- package/src/internal/__tests__/EntityDataManager-test.ts +2 -2
- package/src/internal/__tests__/ReadThroughEntityCache-test.ts +15 -13
- package/src/metrics/EntityMetricsUtils.ts +56 -50
- package/src/metrics/IEntityMetricsAdapter.ts +23 -0
- package/src/metrics/NoOpEntityMetricsAdapter.ts +2 -0
- package/src/testfixtures/DateIDTestEntity.ts +4 -4
- package/src/testfixtures/SimpleTestEntity.ts +4 -4
- package/src/testfixtures/TestEntity.ts +4 -4
- package/src/testfixtures/TestEntity2.ts +4 -4
- package/src/testfixtures/TestEntityNumberKey.ts +4 -4
- package/src/utils/testing/StubDatabaseAdapter.ts +2 -2
- package/src/utils/testing/__tests__/StubDatabaseAdapter-test.ts +1 -1
- package/src/utils/testing/describeFieldTestCase.ts +21 -0
- package/CHANGELOG.md +0 -252
|
@@ -14,12 +14,16 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
14
14
|
|
|
15
15
|
import EntityDatabaseAdapter from '../EntityDatabaseAdapter';
|
|
16
16
|
import EntityLoaderFactory from '../EntityLoaderFactory';
|
|
17
|
+
import {
|
|
18
|
+
EntityMutationType,
|
|
19
|
+
EntityTriggerMutationInfo,
|
|
20
|
+
EntityValidatorMutationInfo,
|
|
21
|
+
} from '../EntityMutationInfo';
|
|
17
22
|
import EntityMutationTriggerConfiguration, {
|
|
18
23
|
EntityMutationTrigger,
|
|
19
24
|
EntityNonTransactionalMutationTrigger,
|
|
20
25
|
} from '../EntityMutationTriggerConfiguration';
|
|
21
26
|
import EntityMutationValidator from '../EntityMutationValidator';
|
|
22
|
-
import { EntityMutationInfo, EntityMutationType } from '../EntityMutator';
|
|
23
27
|
import EntityMutatorFactory from '../EntityMutatorFactory';
|
|
24
28
|
import { EntityTransactionalQueryContext, EntityQueryContext } from '../EntityQueryContext';
|
|
25
29
|
import ViewerContext from '../ViewerContext';
|
|
@@ -53,7 +57,7 @@ class TestMutationTrigger extends EntityMutationTrigger<
|
|
|
53
57
|
_viewerContext: ViewerContext,
|
|
54
58
|
_queryContext: EntityQueryContext,
|
|
55
59
|
_entity: TestEntity,
|
|
56
|
-
_mutationInfo:
|
|
60
|
+
_mutationInfo: EntityTriggerMutationInfo<
|
|
57
61
|
TestFields,
|
|
58
62
|
string,
|
|
59
63
|
ViewerContext,
|
|
@@ -95,7 +99,13 @@ const verifyValidatorCounts = (
|
|
|
95
99
|
keyof TestFields
|
|
96
100
|
>[],
|
|
97
101
|
expectedCalls: number,
|
|
98
|
-
mutationInfo:
|
|
102
|
+
mutationInfo: EntityValidatorMutationInfo<
|
|
103
|
+
TestFields,
|
|
104
|
+
string,
|
|
105
|
+
ViewerContext,
|
|
106
|
+
TestEntity,
|
|
107
|
+
keyof TestFields
|
|
108
|
+
>
|
|
99
109
|
): void => {
|
|
100
110
|
for (const validator of mutationValidatorSpies) {
|
|
101
111
|
verify(
|
|
@@ -125,15 +135,15 @@ const setUpMutationTriggerSpies = (
|
|
|
125
135
|
keyof TestFields
|
|
126
136
|
> => {
|
|
127
137
|
return {
|
|
128
|
-
beforeCreate: [spy(mutationTriggers.beforeCreate![0])],
|
|
129
|
-
afterCreate: [spy(mutationTriggers.afterCreate![0])],
|
|
130
|
-
beforeUpdate: [spy(mutationTriggers.beforeUpdate![0])],
|
|
131
|
-
afterUpdate: [spy(mutationTriggers.afterUpdate![0])],
|
|
132
|
-
beforeDelete: [spy(mutationTriggers.beforeDelete![0])],
|
|
133
|
-
afterDelete: [spy(mutationTriggers.afterDelete![0])],
|
|
134
|
-
beforeAll: [spy(mutationTriggers.beforeAll![0])],
|
|
135
|
-
afterAll: [spy(mutationTriggers.afterAll![0])],
|
|
136
|
-
afterCommit: [spy(mutationTriggers.afterCommit![0])],
|
|
138
|
+
beforeCreate: [spy(mutationTriggers.beforeCreate![0]!)],
|
|
139
|
+
afterCreate: [spy(mutationTriggers.afterCreate![0]!)],
|
|
140
|
+
beforeUpdate: [spy(mutationTriggers.beforeUpdate![0]!)],
|
|
141
|
+
afterUpdate: [spy(mutationTriggers.afterUpdate![0]!)],
|
|
142
|
+
beforeDelete: [spy(mutationTriggers.beforeDelete![0]!)],
|
|
143
|
+
afterDelete: [spy(mutationTriggers.afterDelete![0]!)],
|
|
144
|
+
beforeAll: [spy(mutationTriggers.beforeAll![0]!)],
|
|
145
|
+
afterAll: [spy(mutationTriggers.afterAll![0]!)],
|
|
146
|
+
afterCommit: [spy(mutationTriggers.afterCommit![0]!)],
|
|
137
147
|
};
|
|
138
148
|
};
|
|
139
149
|
|
|
@@ -164,7 +174,13 @@ const verifyTriggerCounts = (
|
|
|
164
174
|
>,
|
|
165
175
|
boolean
|
|
166
176
|
>,
|
|
167
|
-
mutationInfo:
|
|
177
|
+
mutationInfo: EntityTriggerMutationInfo<
|
|
178
|
+
TestFields,
|
|
179
|
+
string,
|
|
180
|
+
ViewerContext,
|
|
181
|
+
TestEntity,
|
|
182
|
+
keyof TestFields
|
|
183
|
+
>
|
|
168
184
|
): void => {
|
|
169
185
|
Object.keys(executed).forEach((s) => {
|
|
170
186
|
if ((executed as any)[s]) {
|
|
@@ -189,7 +205,7 @@ const verifyTriggerCounts = (
|
|
|
189
205
|
});
|
|
190
206
|
|
|
191
207
|
verify(
|
|
192
|
-
mutationTriggerSpies.beforeAll![0]
|
|
208
|
+
mutationTriggerSpies.beforeAll![0]!.executeAsync(
|
|
193
209
|
viewerContext,
|
|
194
210
|
anyOfClass(EntityTransactionalQueryContext),
|
|
195
211
|
anyOfClass(TestEntity),
|
|
@@ -198,7 +214,7 @@ const verifyTriggerCounts = (
|
|
|
198
214
|
).once();
|
|
199
215
|
|
|
200
216
|
verify(
|
|
201
|
-
mutationTriggerSpies.afterAll![0]
|
|
217
|
+
mutationTriggerSpies.afterAll![0]!.executeAsync(
|
|
202
218
|
viewerContext,
|
|
203
219
|
anyOfClass(EntityTransactionalQueryContext),
|
|
204
220
|
anyOfClass(TestEntity),
|
|
@@ -207,7 +223,7 @@ const verifyTriggerCounts = (
|
|
|
207
223
|
).once();
|
|
208
224
|
|
|
209
225
|
verify(
|
|
210
|
-
mutationTriggerSpies.afterCommit![0]
|
|
226
|
+
mutationTriggerSpies.afterCommit![0]!.executeAsync(
|
|
211
227
|
viewerContext,
|
|
212
228
|
anyOfClass(TestEntity),
|
|
213
229
|
deepEqual(mutationInfo)
|
|
@@ -297,7 +313,8 @@ const createEntityMutatorFactory = (
|
|
|
297
313
|
testEntityConfiguration,
|
|
298
314
|
TestEntity,
|
|
299
315
|
privacyPolicy,
|
|
300
|
-
dataManager
|
|
316
|
+
dataManager,
|
|
317
|
+
metricsAdapter
|
|
301
318
|
);
|
|
302
319
|
const entityMutatorFactory = new EntityMutatorFactory(
|
|
303
320
|
testEntityConfiguration,
|
|
@@ -388,7 +405,8 @@ describe(EntityMutatorFactory, () => {
|
|
|
388
405
|
spiedPrivacyPolicy.authorizeCreateAsync(
|
|
389
406
|
viewerContext,
|
|
390
407
|
anyOfClass(EntityTransactionalQueryContext),
|
|
391
|
-
anyOfClass(TestEntity)
|
|
408
|
+
anyOfClass(TestEntity),
|
|
409
|
+
anything()
|
|
392
410
|
)
|
|
393
411
|
).once();
|
|
394
412
|
});
|
|
@@ -527,28 +545,25 @@ describe(EntityMutatorFactory, () => {
|
|
|
527
545
|
|
|
528
546
|
const id1 = uuidv4();
|
|
529
547
|
const id2 = uuidv4();
|
|
530
|
-
const {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
nullableField: null,
|
|
550
|
-
},
|
|
551
|
-
]);
|
|
548
|
+
const { privacyPolicy, entityMutatorFactory, entityLoaderFactory } =
|
|
549
|
+
createEntityMutatorFactory([
|
|
550
|
+
{
|
|
551
|
+
customIdField: id1,
|
|
552
|
+
stringField: 'huh',
|
|
553
|
+
testIndexedField: '3',
|
|
554
|
+
intField: 3,
|
|
555
|
+
dateField: new Date(),
|
|
556
|
+
nullableField: null,
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
customIdField: id2,
|
|
560
|
+
stringField: 'huh',
|
|
561
|
+
testIndexedField: '4',
|
|
562
|
+
intField: 3,
|
|
563
|
+
dateField: new Date(),
|
|
564
|
+
nullableField: null,
|
|
565
|
+
},
|
|
566
|
+
]);
|
|
552
567
|
|
|
553
568
|
const spiedPrivacyPolicy = spy(privacyPolicy);
|
|
554
569
|
|
|
@@ -565,7 +580,8 @@ describe(EntityMutatorFactory, () => {
|
|
|
565
580
|
spiedPrivacyPolicy.authorizeUpdateAsync(
|
|
566
581
|
viewerContext,
|
|
567
582
|
anyOfClass(EntityTransactionalQueryContext),
|
|
568
|
-
anyOfClass(TestEntity)
|
|
583
|
+
anyOfClass(TestEntity),
|
|
584
|
+
anything()
|
|
569
585
|
)
|
|
570
586
|
).once();
|
|
571
587
|
});
|
|
@@ -576,28 +592,25 @@ describe(EntityMutatorFactory, () => {
|
|
|
576
592
|
|
|
577
593
|
const id1 = uuidv4();
|
|
578
594
|
const id2 = uuidv4();
|
|
579
|
-
const {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
nullableField: null,
|
|
599
|
-
},
|
|
600
|
-
]);
|
|
595
|
+
const { mutationTriggers, entityMutatorFactory, entityLoaderFactory } =
|
|
596
|
+
createEntityMutatorFactory([
|
|
597
|
+
{
|
|
598
|
+
customIdField: id1,
|
|
599
|
+
stringField: 'huh',
|
|
600
|
+
testIndexedField: '3',
|
|
601
|
+
intField: 3,
|
|
602
|
+
dateField: new Date(),
|
|
603
|
+
nullableField: null,
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
customIdField: id2,
|
|
607
|
+
stringField: 'huh',
|
|
608
|
+
testIndexedField: '4',
|
|
609
|
+
intField: 3,
|
|
610
|
+
dateField: new Date(),
|
|
611
|
+
nullableField: null,
|
|
612
|
+
},
|
|
613
|
+
]);
|
|
601
614
|
|
|
602
615
|
const triggerSpies = setUpMutationTriggerSpies(mutationTriggers);
|
|
603
616
|
|
|
@@ -630,28 +643,25 @@ describe(EntityMutatorFactory, () => {
|
|
|
630
643
|
|
|
631
644
|
const id1 = uuidv4();
|
|
632
645
|
const id2 = uuidv4();
|
|
633
|
-
const {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
nullableField: null,
|
|
653
|
-
},
|
|
654
|
-
]);
|
|
646
|
+
const { mutationValidators, entityMutatorFactory, entityLoaderFactory } =
|
|
647
|
+
createEntityMutatorFactory([
|
|
648
|
+
{
|
|
649
|
+
customIdField: id1,
|
|
650
|
+
stringField: 'huh',
|
|
651
|
+
testIndexedField: '3',
|
|
652
|
+
intField: 3,
|
|
653
|
+
dateField: new Date(),
|
|
654
|
+
nullableField: null,
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
customIdField: id2,
|
|
658
|
+
stringField: 'huh',
|
|
659
|
+
testIndexedField: '4',
|
|
660
|
+
intField: 3,
|
|
661
|
+
dateField: new Date(),
|
|
662
|
+
nullableField: null,
|
|
663
|
+
},
|
|
664
|
+
]);
|
|
655
665
|
|
|
656
666
|
const validatorSpies = setUpMutationValidatorSpies(mutationValidators);
|
|
657
667
|
|
|
@@ -707,20 +717,17 @@ describe(EntityMutatorFactory, () => {
|
|
|
707
717
|
const queryContext = StubQueryContextProvider.getQueryContext();
|
|
708
718
|
|
|
709
719
|
const id1 = uuidv4();
|
|
710
|
-
const {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
nullableField: null,
|
|
722
|
-
},
|
|
723
|
-
]);
|
|
720
|
+
const { privacyPolicy, entityMutatorFactory, entityLoaderFactory } =
|
|
721
|
+
createEntityMutatorFactory([
|
|
722
|
+
{
|
|
723
|
+
customIdField: id1,
|
|
724
|
+
stringField: 'huh',
|
|
725
|
+
testIndexedField: '3',
|
|
726
|
+
intField: 3,
|
|
727
|
+
dateField: new Date(),
|
|
728
|
+
nullableField: null,
|
|
729
|
+
},
|
|
730
|
+
]);
|
|
724
731
|
|
|
725
732
|
const spiedPrivacyPolicy = spy(privacyPolicy);
|
|
726
733
|
|
|
@@ -734,7 +741,8 @@ describe(EntityMutatorFactory, () => {
|
|
|
734
741
|
spiedPrivacyPolicy.authorizeDeleteAsync(
|
|
735
742
|
viewerContext,
|
|
736
743
|
anyOfClass(EntityTransactionalQueryContext),
|
|
737
|
-
anyOfClass(TestEntity)
|
|
744
|
+
anyOfClass(TestEntity),
|
|
745
|
+
anything()
|
|
738
746
|
)
|
|
739
747
|
).once();
|
|
740
748
|
});
|
|
@@ -744,20 +752,17 @@ describe(EntityMutatorFactory, () => {
|
|
|
744
752
|
const queryContext = StubQueryContextProvider.getQueryContext();
|
|
745
753
|
|
|
746
754
|
const id1 = uuidv4();
|
|
747
|
-
const {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
nullableField: null,
|
|
759
|
-
},
|
|
760
|
-
]);
|
|
755
|
+
const { mutationTriggers, entityMutatorFactory, entityLoaderFactory } =
|
|
756
|
+
createEntityMutatorFactory([
|
|
757
|
+
{
|
|
758
|
+
customIdField: id1,
|
|
759
|
+
stringField: 'huh',
|
|
760
|
+
testIndexedField: '3',
|
|
761
|
+
intField: 3,
|
|
762
|
+
dateField: new Date(),
|
|
763
|
+
nullableField: null,
|
|
764
|
+
},
|
|
765
|
+
]);
|
|
761
766
|
|
|
762
767
|
const triggerSpies = setUpMutationTriggerSpies(mutationTriggers);
|
|
763
768
|
|
|
@@ -778,7 +783,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
778
783
|
beforeDelete: true,
|
|
779
784
|
afterDelete: true,
|
|
780
785
|
},
|
|
781
|
-
{ type: EntityMutationType.DELETE }
|
|
786
|
+
{ type: EntityMutationType.DELETE, cascadingDeleteCause: null }
|
|
782
787
|
);
|
|
783
788
|
});
|
|
784
789
|
|
|
@@ -787,20 +792,17 @@ describe(EntityMutatorFactory, () => {
|
|
|
787
792
|
const queryContext = StubQueryContextProvider.getQueryContext();
|
|
788
793
|
|
|
789
794
|
const id1 = uuidv4();
|
|
790
|
-
const {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
nullableField: null,
|
|
802
|
-
},
|
|
803
|
-
]);
|
|
795
|
+
const { mutationValidators, entityMutatorFactory, entityLoaderFactory } =
|
|
796
|
+
createEntityMutatorFactory([
|
|
797
|
+
{
|
|
798
|
+
customIdField: id1,
|
|
799
|
+
stringField: 'huh',
|
|
800
|
+
testIndexedField: '3',
|
|
801
|
+
intField: 3,
|
|
802
|
+
dateField: new Date(),
|
|
803
|
+
nullableField: null,
|
|
804
|
+
},
|
|
805
|
+
]);
|
|
804
806
|
|
|
805
807
|
const validatorSpies = setUpMutationValidatorSpies(mutationValidators);
|
|
806
808
|
|
|
@@ -810,7 +812,9 @@ describe(EntityMutatorFactory, () => {
|
|
|
810
812
|
|
|
811
813
|
await entityMutatorFactory.forDelete(existingEntity, queryContext).enforceDeleteAsync();
|
|
812
814
|
|
|
813
|
-
verifyValidatorCounts(viewerContext, validatorSpies, 0, {
|
|
815
|
+
verifyValidatorCounts(viewerContext, validatorSpies, 0, {
|
|
816
|
+
type: EntityMutationType.DELETE as any,
|
|
817
|
+
});
|
|
814
818
|
});
|
|
815
819
|
});
|
|
816
820
|
|
|
@@ -912,21 +916,24 @@ describe(EntityMutatorFactory, () => {
|
|
|
912
916
|
privacyPolicyMock.authorizeCreateAsync(
|
|
913
917
|
viewerContext,
|
|
914
918
|
anyOfClass(EntityTransactionalQueryContext),
|
|
915
|
-
anyOfClass(SimpleTestEntity)
|
|
919
|
+
anyOfClass(SimpleTestEntity),
|
|
920
|
+
anything()
|
|
916
921
|
)
|
|
917
922
|
).thenReject(rejectionError);
|
|
918
923
|
when(
|
|
919
924
|
privacyPolicyMock.authorizeUpdateAsync(
|
|
920
925
|
viewerContext,
|
|
921
926
|
anyOfClass(EntityTransactionalQueryContext),
|
|
922
|
-
anyOfClass(SimpleTestEntity)
|
|
927
|
+
anyOfClass(SimpleTestEntity),
|
|
928
|
+
anything()
|
|
923
929
|
)
|
|
924
930
|
).thenReject(rejectionError);
|
|
925
931
|
when(
|
|
926
932
|
privacyPolicyMock.authorizeDeleteAsync(
|
|
927
933
|
viewerContext,
|
|
928
934
|
anyOfClass(EntityTransactionalQueryContext),
|
|
929
|
-
anyOfClass(SimpleTestEntity)
|
|
935
|
+
anyOfClass(SimpleTestEntity),
|
|
936
|
+
anything()
|
|
930
937
|
)
|
|
931
938
|
).thenReject(rejectionError);
|
|
932
939
|
|