@expo/entity 0.16.0 → 0.20.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 +5 -78
- package/build/EntityFields.js +19 -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 +13 -0
- package/build/EntityQueryContext.js +18 -0
- package/build/EntityQueryContext.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 -26
- 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 +81 -73
- 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 +138 -136
- 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__/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 +12 -12
- 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 +21 -21
- 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 +6 -6
- package/build/testfixtures/TestEntity.js +4 -4
- 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 +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 +7 -7
- package/build/utils/testing/StubDatabaseAdapter.js.map +1 -1
- package/build/utils/testing/__tests__/StubDatabaseAdapter-test.js +26 -26
- 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 +11 -126
- 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 +20 -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 +6 -23
- package/src/__tests__/EntityLoader-constructor-test.ts +177 -0
- package/src/__tests__/EntityLoader-test.ts +48 -20
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +105 -0
- package/src/__tests__/EntityMutator-test.ts +153 -146
- package/src/__tests__/EntityPrivacyPolicy-test.ts +215 -78
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +7 -9
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +6 -5
- package/src/__tests__/ReadonlyEntity-test.ts +1 -1
- 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 +6 -6
- 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 +8 -8
- package/src/testfixtures/TestEntity2.ts +4 -4
- package/src/testfixtures/TestEntityNumberKey.ts +6 -6
- package/src/utils/testing/StubDatabaseAdapter.ts +4 -4
- package/src/utils/testing/__tests__/StubDatabaseAdapter-test.ts +18 -18
- package/src/utils/testing/describeFieldTestCase.ts +21 -0
- package/CHANGELOG.md +0 -241
|
@@ -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,
|
|
@@ -332,7 +349,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
332
349
|
customIdField: id1,
|
|
333
350
|
stringField: 'huh',
|
|
334
351
|
testIndexedField: '4',
|
|
335
|
-
|
|
352
|
+
intField: 1,
|
|
336
353
|
dateField: new Date(),
|
|
337
354
|
nullableField: null,
|
|
338
355
|
},
|
|
@@ -340,7 +357,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
340
357
|
customIdField: id2,
|
|
341
358
|
stringField: 'huh',
|
|
342
359
|
testIndexedField: '5',
|
|
343
|
-
|
|
360
|
+
intField: 1,
|
|
344
361
|
dateField: new Date(),
|
|
345
362
|
nullableField: null,
|
|
346
363
|
},
|
|
@@ -363,7 +380,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
363
380
|
customIdField: id1,
|
|
364
381
|
stringField: 'huh',
|
|
365
382
|
testIndexedField: '4',
|
|
366
|
-
|
|
383
|
+
intField: 1,
|
|
367
384
|
dateField: new Date(),
|
|
368
385
|
nullableField: null,
|
|
369
386
|
},
|
|
@@ -371,7 +388,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
371
388
|
customIdField: id2,
|
|
372
389
|
stringField: 'huh',
|
|
373
390
|
testIndexedField: '5',
|
|
374
|
-
|
|
391
|
+
intField: 1,
|
|
375
392
|
dateField: new Date(),
|
|
376
393
|
nullableField: null,
|
|
377
394
|
},
|
|
@@ -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
|
});
|
|
@@ -404,7 +422,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
404
422
|
customIdField: id1,
|
|
405
423
|
stringField: 'huh',
|
|
406
424
|
testIndexedField: '4',
|
|
407
|
-
|
|
425
|
+
intField: 1,
|
|
408
426
|
dateField: new Date(),
|
|
409
427
|
nullableField: null,
|
|
410
428
|
},
|
|
@@ -412,7 +430,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
412
430
|
customIdField: id2,
|
|
413
431
|
stringField: 'huh',
|
|
414
432
|
testIndexedField: '5',
|
|
415
|
-
|
|
433
|
+
intField: 1,
|
|
416
434
|
dateField: new Date(),
|
|
417
435
|
nullableField: null,
|
|
418
436
|
},
|
|
@@ -451,7 +469,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
451
469
|
customIdField: id1,
|
|
452
470
|
stringField: 'huh',
|
|
453
471
|
testIndexedField: '4',
|
|
454
|
-
|
|
472
|
+
intField: 1,
|
|
455
473
|
dateField: new Date(),
|
|
456
474
|
nullableField: null,
|
|
457
475
|
},
|
|
@@ -459,7 +477,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
459
477
|
customIdField: id2,
|
|
460
478
|
stringField: 'huh',
|
|
461
479
|
testIndexedField: '5',
|
|
462
|
-
|
|
480
|
+
intField: 1,
|
|
463
481
|
dateField: new Date(),
|
|
464
482
|
nullableField: null,
|
|
465
483
|
},
|
|
@@ -488,7 +506,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
488
506
|
customIdField: id1,
|
|
489
507
|
stringField: 'huh',
|
|
490
508
|
testIndexedField: '3',
|
|
491
|
-
|
|
509
|
+
intField: 3,
|
|
492
510
|
dateField: new Date(),
|
|
493
511
|
nullableField: null,
|
|
494
512
|
},
|
|
@@ -496,7 +514,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
496
514
|
customIdField: id2,
|
|
497
515
|
stringField: 'huh',
|
|
498
516
|
testIndexedField: '4',
|
|
499
|
-
|
|
517
|
+
intField: 3,
|
|
500
518
|
dateField: new Date(),
|
|
501
519
|
nullableField: null,
|
|
502
520
|
},
|
|
@@ -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
|
|
|
@@ -682,7 +692,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
682
692
|
customIdField: id1,
|
|
683
693
|
stringField: 'huh',
|
|
684
694
|
testIndexedField: '3',
|
|
685
|
-
|
|
695
|
+
intField: 3,
|
|
686
696
|
dateField: new Date(),
|
|
687
697
|
nullableField: null,
|
|
688
698
|
},
|
|
@@ -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
|
|
|
@@ -824,7 +828,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
824
828
|
customIdField: id1,
|
|
825
829
|
stringField: 'huh',
|
|
826
830
|
testIndexedField: '3',
|
|
827
|
-
|
|
831
|
+
intField: 3,
|
|
828
832
|
dateField: new Date(),
|
|
829
833
|
nullableField: null,
|
|
830
834
|
},
|
|
@@ -861,7 +865,7 @@ describe(EntityMutatorFactory, () => {
|
|
|
861
865
|
customIdField: id1,
|
|
862
866
|
stringField: 'huh',
|
|
863
867
|
testIndexedField: '3',
|
|
864
|
-
|
|
868
|
+
intField: 3,
|
|
865
869
|
dateField: new Date(),
|
|
866
870
|
nullableField: null,
|
|
867
871
|
},
|
|
@@ -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
|
|