@expo/entity 0.40.0 → 0.41.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.
Files changed (54) hide show
  1. package/build/AuthorizationResultBasedEntityAssociationLoader.js +2 -4
  2. package/build/AuthorizationResultBasedEntityAssociationLoader.js.map +1 -1
  3. package/build/Entity.d.ts +28 -6
  4. package/build/Entity.js +41 -3
  5. package/build/Entity.js.map +1 -1
  6. package/build/ReadonlyEntity.d.ts +24 -5
  7. package/build/ReadonlyEntity.js +31 -3
  8. package/build/ReadonlyEntity.js.map +1 -1
  9. package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js +37 -68
  10. package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js.map +1 -1
  11. package/build/__tests__/Entity-test.js +49 -9
  12. package/build/__tests__/Entity-test.js.map +1 -1
  13. package/build/__tests__/EntityAssociationLoader-test.js +4 -4
  14. package/build/__tests__/EntityAssociationLoader-test.js.map +1 -1
  15. package/build/__tests__/EntityCommonUseCases-test.js +9 -17
  16. package/build/__tests__/EntityCommonUseCases-test.js.map +1 -1
  17. package/build/__tests__/EntityEdges-test.js +32 -64
  18. package/build/__tests__/EntityEdges-test.js.map +1 -1
  19. package/build/__tests__/EntityLoader-test.js +3 -3
  20. package/build/__tests__/EntityLoader-test.js.map +1 -1
  21. package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +4 -8
  22. package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +1 -1
  23. package/build/__tests__/EntitySecondaryCacheLoader-test.js +6 -6
  24. package/build/__tests__/EntitySecondaryCacheLoader-test.js.map +1 -1
  25. package/build/__tests__/EntitySelfReferentialEdges-test.js +35 -81
  26. package/build/__tests__/EntitySelfReferentialEdges-test.js.map +1 -1
  27. package/build/__tests__/ReadonlyEntity-test.js +39 -6
  28. package/build/__tests__/ReadonlyEntity-test.js.map +1 -1
  29. package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +4 -10
  30. package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +1 -1
  31. package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +7 -22
  32. package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +1 -1
  33. package/build/utils/__tests__/EntityPrivacyUtils-test.js +13 -47
  34. package/build/utils/__tests__/EntityPrivacyUtils-test.js.map +1 -1
  35. package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js +2 -5
  36. package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js.map +1 -1
  37. package/package.json +2 -2
  38. package/src/AuthorizationResultBasedEntityAssociationLoader.ts +2 -4
  39. package/src/Entity.ts +163 -7
  40. package/src/ReadonlyEntity.ts +119 -6
  41. package/src/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.ts +37 -68
  42. package/src/__tests__/Entity-test.ts +62 -9
  43. package/src/__tests__/EntityAssociationLoader-test.ts +4 -6
  44. package/src/__tests__/EntityCommonUseCases-test.ts +14 -17
  45. package/src/__tests__/EntityEdges-test.ts +36 -64
  46. package/src/__tests__/EntityLoader-test.ts +3 -5
  47. package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +6 -8
  48. package/src/__tests__/EntitySecondaryCacheLoader-test.ts +6 -6
  49. package/src/__tests__/EntitySelfReferentialEdges-test.ts +53 -81
  50. package/src/__tests__/ReadonlyEntity-test.ts +46 -6
  51. package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +13 -15
  52. package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +16 -22
  53. package/src/utils/__tests__/EntityPrivacyUtils-test.ts +19 -47
  54. package/src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.ts +2 -5
@@ -527,42 +527,36 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
527
527
  const companionProvider = createUnitTestEntityCompanionProvider();
528
528
  const viewerContext = new TestViewerContext(companionProvider);
529
529
 
530
- const parent = await ParentEntity.creator(viewerContext).enforcing().createAsync();
530
+ const parent = await ParentEntity.creator(viewerContext).createAsync();
531
531
  const child = await ChildEntity.creator(viewerContext)
532
- .enforcing()
533
532
  .setField('parent_id', parent.getID())
534
533
  .createAsync();
535
534
  const grandchild = await GrandChildEntity.creator(viewerContext)
536
- .enforcing()
537
535
  .setField('parent_id', child.getID())
538
536
  .createAsync();
539
537
 
540
538
  await expect(
541
- ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
539
+ ParentEntity.loader(viewerContext).loadByIDNullableAsync(parent.getID()),
542
540
  ).resolves.not.toBeNull();
543
541
  await expect(
544
- ChildEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(child.getID()),
542
+ ChildEntity.loader(viewerContext).loadByIDNullableAsync(child.getID()),
545
543
  ).resolves.not.toBeNull();
546
544
  await expect(
547
- GrandChildEntity.loader(viewerContext)
548
- .enforcing()
549
- .loadByIDNullableAsync(grandchild.getID()),
545
+ GrandChildEntity.loader(viewerContext).loadByIDNullableAsync(grandchild.getID()),
550
546
  ).resolves.not.toBeNull();
551
547
 
552
548
  privacyPolicyEvaluationRecords.shouldRecord = true;
553
- await ParentEntity.deleter(parent).enforcing().deleteAsync();
549
+ await ParentEntity.deleter(parent).deleteAsync();
554
550
  privacyPolicyEvaluationRecords.shouldRecord = false;
555
551
 
556
552
  await expect(
557
- ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
553
+ ParentEntity.loader(viewerContext).loadByIDNullableAsync(parent.getID()),
558
554
  ).resolves.toBeNull();
559
555
  await expect(
560
- ChildEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(child.getID()),
556
+ ChildEntity.loader(viewerContext).loadByIDNullableAsync(child.getID()),
561
557
  ).resolves.toBeNull();
562
558
  await expect(
563
- GrandChildEntity.loader(viewerContext)
564
- .enforcing()
565
- .loadByIDNullableAsync(grandchild.getID()),
559
+ GrandChildEntity.loader(viewerContext).loadByIDNullableAsync(grandchild.getID()),
566
560
  ).resolves.toBeNull();
567
561
 
568
562
  // two calls for each trigger, one beforeDelete, one afterDelete
@@ -651,44 +645,38 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
651
645
  const companionProvider = createUnitTestEntityCompanionProvider();
652
646
  const viewerContext = new TestViewerContext(companionProvider);
653
647
 
654
- const parent = await ParentEntity.creator(viewerContext).enforcing().createAsync();
648
+ const parent = await ParentEntity.creator(viewerContext).createAsync();
655
649
  const child = await ChildEntity.creator(viewerContext)
656
- .enforcing()
657
650
  .setField('parent_id', parent.getID())
658
651
  .createAsync();
659
652
  const grandchild = await GrandChildEntity.creator(viewerContext)
660
- .enforcing()
661
653
  .setField('parent_id', child.getID())
662
654
  .createAsync();
663
655
 
664
656
  await expect(
665
- ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
657
+ ParentEntity.loader(viewerContext).loadByIDNullableAsync(parent.getID()),
666
658
  ).resolves.not.toBeNull();
667
659
  await expect(
668
- ChildEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(child.getID()),
660
+ ChildEntity.loader(viewerContext).loadByIDNullableAsync(child.getID()),
669
661
  ).resolves.not.toBeNull();
670
662
  await expect(
671
- GrandChildEntity.loader(viewerContext)
672
- .enforcing()
673
- .loadByIDNullableAsync(grandchild.getID()),
663
+ GrandChildEntity.loader(viewerContext).loadByIDNullableAsync(grandchild.getID()),
674
664
  ).resolves.not.toBeNull();
675
665
 
676
666
  privacyPolicyEvaluationRecords.shouldRecord = true;
677
- await ParentEntity.deleter(parent).enforcing().deleteAsync();
667
+ await ParentEntity.deleter(parent).deleteAsync();
678
668
  privacyPolicyEvaluationRecords.shouldRecord = false;
679
669
 
680
670
  await expect(
681
- ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
671
+ ParentEntity.loader(viewerContext).loadByIDNullableAsync(parent.getID()),
682
672
  ).resolves.toBeNull();
683
673
 
684
- const loadedChild = await ChildEntity.loader(viewerContext)
685
- .enforcing()
686
- .loadByIDAsync(child.getID());
674
+ const loadedChild = await ChildEntity.loader(viewerContext).loadByIDAsync(child.getID());
687
675
  expect(loadedChild.getField('parent_id')).toBeNull();
688
676
 
689
- const loadedGrandchild = await GrandChildEntity.loader(viewerContext)
690
- .enforcing()
691
- .loadByIDAsync(grandchild.getID());
677
+ const loadedGrandchild = await GrandChildEntity.loader(viewerContext).loadByIDAsync(
678
+ grandchild.getID(),
679
+ );
692
680
  expect(loadedGrandchild.getField('parent_id')).toEqual(loadedChild.getID());
693
681
 
694
682
  // two calls for only parent trigger, one beforeDelete, one afterDelete
@@ -766,28 +754,22 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
766
754
  const companionProvider = createUnitTestEntityCompanionProvider();
767
755
  const viewerContext = new TestViewerContext(companionProvider);
768
756
 
769
- const parent = await ParentEntity.creator(viewerContext).enforcing().createAsync();
757
+ const parent = await ParentEntity.creator(viewerContext).createAsync();
770
758
  const child = await ChildEntity.creator(viewerContext)
771
- .enforcing()
772
759
  .setField('parent_id', parent.getID())
773
760
  .createAsync();
774
761
  const grandchild = await GrandChildEntity.creator(viewerContext)
775
- .enforcing()
776
762
  .setField('parent_id', child.getID())
777
763
  .createAsync();
778
764
 
779
765
  await expect(
780
- ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
766
+ ParentEntity.loader(viewerContext).loadByIDNullableAsync(parent.getID()),
781
767
  ).resolves.not.toBeNull();
782
768
  await expect(
783
- ChildEntity.loader(viewerContext)
784
- .enforcing()
785
- .loadByFieldEqualingAsync('parent_id', parent.getID()),
769
+ ChildEntity.loader(viewerContext).loadByFieldEqualingAsync('parent_id', parent.getID()),
786
770
  ).resolves.not.toBeNull();
787
771
  await expect(
788
- GrandChildEntity.loader(viewerContext)
789
- .enforcing()
790
- .loadByFieldEqualingAsync('parent_id', child.getID()),
772
+ GrandChildEntity.loader(viewerContext).loadByFieldEqualingAsync('parent_id', child.getID()),
791
773
  ).resolves.not.toBeNull();
792
774
 
793
775
  const childCacheAdapter = viewerContext.getViewerScopedEntityCompanionForClass(ChildEntity)[
@@ -809,7 +791,7 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
809
791
  expect(grandChildCachedBefore.get(child.getID())?.status).toEqual(CacheStatus.HIT);
810
792
 
811
793
  privacyPolicyEvaluationRecords.shouldRecord = true;
812
- await ParentEntity.deleter(parent).enforcing().deleteAsync();
794
+ await ParentEntity.deleter(parent).deleteAsync();
813
795
  privacyPolicyEvaluationRecords.shouldRecord = false;
814
796
 
815
797
  const childCachedAfter = await childCacheAdapter.loadManyAsync('parent_id', [parent.getID()]);
@@ -821,17 +803,15 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
821
803
  expect(grandChildCachedAfter.get(child.getID())?.status).toEqual(CacheStatus.HIT);
822
804
 
823
805
  await expect(
824
- ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
806
+ ParentEntity.loader(viewerContext).loadByIDNullableAsync(parent.getID()),
825
807
  ).resolves.toBeNull();
826
808
 
827
- const loadedChild = await ChildEntity.loader(viewerContext)
828
- .enforcing()
829
- .loadByIDAsync(child.getID());
809
+ const loadedChild = await ChildEntity.loader(viewerContext).loadByIDAsync(child.getID());
830
810
  expect(loadedChild).not.toBeNull();
831
811
 
832
- const loadedGrandchild = await GrandChildEntity.loader(viewerContext)
833
- .enforcing()
834
- .loadByIDAsync(grandchild.getID());
812
+ const loadedGrandchild = await GrandChildEntity.loader(viewerContext).loadByIDAsync(
813
+ grandchild.getID(),
814
+ );
835
815
  expect(loadedGrandchild.getField('parent_id')).toEqual(loadedChild.getID());
836
816
 
837
817
  // two calls for only parent trigger, one beforeDelete, one afterDelete
@@ -907,28 +887,22 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
907
887
  const companionProvider = createUnitTestEntityCompanionProvider();
908
888
  const viewerContext = new TestViewerContext(companionProvider);
909
889
 
910
- const parent = await ParentEntity.creator(viewerContext).enforcing().createAsync();
890
+ const parent = await ParentEntity.creator(viewerContext).createAsync();
911
891
  const child = await ChildEntity.creator(viewerContext)
912
- .enforcing()
913
892
  .setField('parent_id', parent.getID())
914
893
  .createAsync();
915
894
  const grandchild = await GrandChildEntity.creator(viewerContext)
916
- .enforcing()
917
895
  .setField('parent_id', child.getID())
918
896
  .createAsync();
919
897
 
920
898
  await expect(
921
- ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
899
+ ParentEntity.loader(viewerContext).loadByIDNullableAsync(parent.getID()),
922
900
  ).resolves.not.toBeNull();
923
901
  await expect(
924
- ChildEntity.loader(viewerContext)
925
- .enforcing()
926
- .loadByFieldEqualingAsync('parent_id', parent.getID()),
902
+ ChildEntity.loader(viewerContext).loadByFieldEqualingAsync('parent_id', parent.getID()),
927
903
  ).resolves.not.toBeNull();
928
904
  await expect(
929
- GrandChildEntity.loader(viewerContext)
930
- .enforcing()
931
- .loadByFieldEqualingAsync('parent_id', child.getID()),
905
+ GrandChildEntity.loader(viewerContext).loadByFieldEqualingAsync('parent_id', child.getID()),
932
906
  ).resolves.not.toBeNull();
933
907
 
934
908
  const childCacheAdapter = viewerContext.getViewerScopedEntityCompanionForClass(ChildEntity)[
@@ -950,7 +924,7 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
950
924
  expect(grandChildCachedBefore.get(child.getID())?.status).toEqual(CacheStatus.HIT);
951
925
 
952
926
  privacyPolicyEvaluationRecords.shouldRecord = true;
953
- await ParentEntity.deleter(parent).enforcing().deleteAsync();
927
+ await ParentEntity.deleter(parent).deleteAsync();
954
928
  privacyPolicyEvaluationRecords.shouldRecord = false;
955
929
 
956
930
  const childCachedAfter = await childCacheAdapter.loadManyAsync('parent_id', [parent.getID()]);
@@ -962,15 +936,13 @@ describe('EntityMutator.processEntityDeletionForInboundEdgesAsync', () => {
962
936
  expect(grandChildCachedAfter.get(child.getID())?.status).toEqual(CacheStatus.MISS);
963
937
 
964
938
  await expect(
965
- ParentEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(parent.getID()),
939
+ ParentEntity.loader(viewerContext).loadByIDNullableAsync(parent.getID()),
966
940
  ).resolves.toBeNull();
967
941
  await expect(
968
- ChildEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(child.getID()),
942
+ ChildEntity.loader(viewerContext).loadByIDNullableAsync(child.getID()),
969
943
  ).resolves.not.toBeNull();
970
944
  await expect(
971
- GrandChildEntity.loader(viewerContext)
972
- .enforcing()
973
- .loadByIDNullableAsync(grandchild.getID()),
945
+ GrandChildEntity.loader(viewerContext).loadByIDNullableAsync(grandchild.getID()),
974
946
  ).resolves.not.toBeNull();
975
947
 
976
948
  // two calls for each trigger, one beforeDelete, one afterDelete
@@ -11,9 +11,7 @@ describe(EntityLoader, () => {
11
11
  it('creates a new EnforcingEntityLoader', async () => {
12
12
  const companionProvider = createUnitTestEntityCompanionProvider();
13
13
  const viewerContext = new ViewerContext(companionProvider);
14
- expect(SimpleTestEntity.loader(viewerContext).enforcing()).toBeInstanceOf(
15
- EnforcingEntityLoader,
16
- );
14
+ expect(SimpleTestEntity.loader(viewerContext)).toBeInstanceOf(EnforcingEntityLoader);
17
15
  });
18
16
  });
19
17
 
@@ -21,7 +19,7 @@ describe(EntityLoader, () => {
21
19
  it('creates a new AuthorizationResultBasedEntityLoader', async () => {
22
20
  const companionProvider = createUnitTestEntityCompanionProvider();
23
21
  const viewerContext = new ViewerContext(companionProvider);
24
- expect(SimpleTestEntity.loader(viewerContext).withAuthorizationResults()).toBeInstanceOf(
22
+ expect(SimpleTestEntity.loaderWithAuthorizationResults(viewerContext)).toBeInstanceOf(
25
23
  AuthorizationResultBasedEntityLoader,
26
24
  );
27
25
  });
@@ -31,7 +29,7 @@ describe(EntityLoader, () => {
31
29
  it('returns a instance of EntityLoaderUtils', async () => {
32
30
  const companionProvider = createUnitTestEntityCompanionProvider();
33
31
  const viewerContext = new ViewerContext(companionProvider);
34
- expect(SimpleTestEntity.loader(viewerContext).utils()).toBeInstanceOf(EntityLoaderUtils);
32
+ expect(SimpleTestEntity.loaderUtils(viewerContext)).toBeInstanceOf(EntityLoaderUtils);
35
33
  });
36
34
  });
37
35
  });
@@ -76,9 +76,9 @@ class TestNonTransactionalMutationTrigger extends EntityNonTransactionalMutation
76
76
  mutationInfo: EntityTriggerMutationInfo<BlahFields, string, ViewerContext, BlahEntity>,
77
77
  ): Promise<void> {
78
78
  if (mutationInfo.type === EntityMutationType.DELETE) {
79
- const entityLoaded = await BlahEntity.loader(viewerContext)
80
- .enforcing()
81
- .loadByIDNullableAsync(entity.getID());
79
+ const entityLoaded = await BlahEntity.loader(viewerContext).loadByIDNullableAsync(
80
+ entity.getID(),
81
+ );
82
82
  if (entityLoaded) {
83
83
  throw new Error(
84
84
  'should not have been able to re-load the entity after delete. this means the cache has not been cleared',
@@ -94,11 +94,9 @@ describe(EntityMutatorFactory, () => {
94
94
  const viewerContext = new ViewerContext(companionProvider);
95
95
 
96
96
  // put it in cache
97
- const entity = await BlahEntity.creator(viewerContext).enforcing().createAsync();
98
- const entityLoaded = await BlahEntity.loader(viewerContext)
99
- .enforcing()
100
- .loadByIDAsync(entity.getID());
97
+ const entity = await BlahEntity.creator(viewerContext).createAsync();
98
+ const entityLoaded = await BlahEntity.loader(viewerContext).loadByIDAsync(entity.getID());
101
99
 
102
- await BlahEntity.deleter(entityLoaded).enforcing().deleteAsync();
100
+ await BlahEntity.deleter(entityLoaded).deleteAsync();
103
101
  });
104
102
  });
@@ -32,7 +32,7 @@ describe(EntitySecondaryCacheLoader, () => {
32
32
  it('calls into secondary cache with correct params', async () => {
33
33
  const vc1 = new ViewerContext(createUnitTestEntityCompanionProvider());
34
34
 
35
- const createdEntity = await SimpleTestEntity.creator(vc1).enforcing().createAsync();
35
+ const createdEntity = await SimpleTestEntity.creator(vc1).createAsync();
36
36
  const loadParams = { id: createdEntity.getID() };
37
37
 
38
38
  const secondaryEntityCacheMock =
@@ -44,7 +44,7 @@ describe(EntitySecondaryCacheLoader, () => {
44
44
 
45
45
  const secondaryCacheLoader = new TestSecondaryRedisCacheLoader(
46
46
  secondaryEntityCache,
47
- SimpleTestEntity.loader(vc1).withAuthorizationResults(),
47
+ SimpleTestEntity.loaderWithAuthorizationResults(vc1),
48
48
  );
49
49
 
50
50
  await secondaryCacheLoader.loadManyAsync([loadParams]);
@@ -57,7 +57,7 @@ describe(EntitySecondaryCacheLoader, () => {
57
57
  it('constructs and authorizes entities', async () => {
58
58
  const vc1 = new ViewerContext(createUnitTestEntityCompanionProvider());
59
59
 
60
- const createdEntity = await SimpleTestEntity.creator(vc1).enforcing().createAsync();
60
+ const createdEntity = await SimpleTestEntity.creator(vc1).createAsync();
61
61
  const loadParams = { id: createdEntity.getID() };
62
62
 
63
63
  const secondaryEntityCacheMock =
@@ -67,7 +67,7 @@ describe(EntitySecondaryCacheLoader, () => {
67
67
  ).thenResolve(new Map([[loadParams, createdEntity.getAllFields()]]));
68
68
  const secondaryEntityCache = instance(secondaryEntityCacheMock);
69
69
 
70
- const loader = SimpleTestEntity.loader(vc1).withAuthorizationResults();
70
+ const loader = SimpleTestEntity.loaderWithAuthorizationResults(vc1);
71
71
  const spiedPrivacyPolicy = spy(loader.utils['privacyPolicy']);
72
72
  const secondaryCacheLoader = new TestSecondaryRedisCacheLoader(secondaryEntityCache, loader);
73
73
 
@@ -90,13 +90,13 @@ describe(EntitySecondaryCacheLoader, () => {
90
90
  it('calls invalidate on the secondary cache', async () => {
91
91
  const vc1 = new ViewerContext(createUnitTestEntityCompanionProvider());
92
92
 
93
- const createdEntity = await SimpleTestEntity.creator(vc1).enforcing().createAsync();
93
+ const createdEntity = await SimpleTestEntity.creator(vc1).createAsync();
94
94
  const loadParams = { id: createdEntity.getID() };
95
95
 
96
96
  const secondaryEntityCacheMock =
97
97
  mock<ISecondaryEntityCache<SimpleTestFields, TestLoadParams>>();
98
98
  const secondaryEntityCache = instance(secondaryEntityCacheMock);
99
- const loader = SimpleTestEntity.loader(vc1).withAuthorizationResults();
99
+ const loader = SimpleTestEntity.loaderWithAuthorizationResults(vc1);
100
100
  const secondaryCacheLoader = new TestSecondaryRedisCacheLoader(secondaryEntityCache, loader);
101
101
  await secondaryCacheLoader.invalidateManyAsync([loadParams]);
102
102
 
@@ -87,44 +87,34 @@ describe('EntityEdgeDeletionBehavior.CASCADE_DELETE', () => {
87
87
  const companionProvider = createUnitTestEntityCompanionProvider();
88
88
  const viewerContext = new TestViewerContext(companionProvider);
89
89
 
90
- const parentCategory = await CategoryEntity.creator(viewerContext).enforcing().createAsync();
90
+ const parentCategory = await CategoryEntity.creator(viewerContext).createAsync();
91
91
  const subCategory = await CategoryEntity.creator(viewerContext)
92
- .enforcing()
93
92
  .setField('parent_category_id', parentCategory.getID())
94
93
  .createAsync();
95
94
  const subSubCategory = await CategoryEntity.creator(viewerContext)
96
- .enforcing()
97
95
  .setField('parent_category_id', subCategory.getID())
98
96
  .createAsync();
99
97
 
100
98
  await expect(
101
- CategoryEntity.loader(viewerContext)
102
- .enforcing()
103
- .loadByIDNullableAsync(parentCategory.getID()),
99
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(parentCategory.getID()),
104
100
  ).resolves.not.toBeNull();
105
101
  await expect(
106
- CategoryEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(subCategory.getID()),
102
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(subCategory.getID()),
107
103
  ).resolves.not.toBeNull();
108
104
  await expect(
109
- CategoryEntity.loader(viewerContext)
110
- .enforcing()
111
- .loadByIDNullableAsync(subSubCategory.getID()),
105
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(subSubCategory.getID()),
112
106
  ).resolves.not.toBeNull();
113
107
 
114
- await CategoryEntity.deleter(parentCategory).enforcing().deleteAsync();
108
+ await CategoryEntity.deleter(parentCategory).deleteAsync();
115
109
 
116
110
  await expect(
117
- CategoryEntity.loader(viewerContext)
118
- .enforcing()
119
- .loadByIDNullableAsync(parentCategory.getID()),
111
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(parentCategory.getID()),
120
112
  ).resolves.toBeNull();
121
113
  await expect(
122
- CategoryEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(subCategory.getID()),
114
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(subCategory.getID()),
123
115
  ).resolves.toBeNull();
124
116
  await expect(
125
- CategoryEntity.loader(viewerContext)
126
- .enforcing()
127
- .loadByIDNullableAsync(subSubCategory.getID()),
117
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(subSubCategory.getID()),
128
118
  ).resolves.toBeNull();
129
119
  });
130
120
 
@@ -134,23 +124,21 @@ describe('EntityEdgeDeletionBehavior.CASCADE_DELETE', () => {
134
124
  const companionProvider = createUnitTestEntityCompanionProvider();
135
125
  const viewerContext = new TestViewerContext(companionProvider);
136
126
 
137
- const categoryA = await CategoryEntity.creator(viewerContext).enforcing().createAsync();
127
+ const categoryA = await CategoryEntity.creator(viewerContext).createAsync();
138
128
  const categoryB = await CategoryEntity.creator(viewerContext)
139
- .enforcing()
140
129
  .setField('parent_category_id', categoryA.getID())
141
130
  .createAsync();
142
131
  await CategoryEntity.updater(categoryA)
143
- .enforcing()
144
132
  .setField('parent_category_id', categoryB.getID())
145
133
  .updateAsync();
146
134
 
147
- await CategoryEntity.deleter(categoryA).enforcing().deleteAsync();
135
+ await CategoryEntity.deleter(categoryA).deleteAsync();
148
136
 
149
137
  await expect(
150
- CategoryEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(categoryA.getID()),
138
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(categoryA.getID()),
151
139
  ).resolves.toBeNull();
152
140
  await expect(
153
- CategoryEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(categoryB.getID()),
141
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(categoryB.getID()),
154
142
  ).resolves.toBeNull();
155
143
  });
156
144
  });
@@ -162,46 +150,38 @@ describe('EntityEdgeDeletionBehavior.SET_NULL', () => {
162
150
  const companionProvider = createUnitTestEntityCompanionProvider();
163
151
  const viewerContext = new TestViewerContext(companionProvider);
164
152
 
165
- const parentCategory = await CategoryEntity.creator(viewerContext).enforcing().createAsync();
153
+ const parentCategory = await CategoryEntity.creator(viewerContext).createAsync();
166
154
  const subCategory = await CategoryEntity.creator(viewerContext)
167
- .enforcing()
168
155
  .setField('parent_category_id', parentCategory.getID())
169
156
  .createAsync();
170
157
  const subSubCategory = await CategoryEntity.creator(viewerContext)
171
- .enforcing()
172
158
  .setField('parent_category_id', subCategory.getID())
173
159
  .createAsync();
174
160
 
175
161
  await expect(
176
- CategoryEntity.loader(viewerContext)
177
- .enforcing()
178
- .loadByIDNullableAsync(parentCategory.getID()),
162
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(parentCategory.getID()),
179
163
  ).resolves.not.toBeNull();
180
164
  await expect(
181
- CategoryEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(subCategory.getID()),
165
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(subCategory.getID()),
182
166
  ).resolves.not.toBeNull();
183
167
  await expect(
184
- CategoryEntity.loader(viewerContext)
185
- .enforcing()
186
- .loadByIDNullableAsync(subSubCategory.getID()),
168
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(subSubCategory.getID()),
187
169
  ).resolves.not.toBeNull();
188
170
 
189
- await CategoryEntity.deleter(parentCategory).enforcing().deleteAsync();
171
+ await CategoryEntity.deleter(parentCategory).deleteAsync();
190
172
 
191
173
  await expect(
192
- CategoryEntity.loader(viewerContext)
193
- .enforcing()
194
- .loadByIDNullableAsync(parentCategory.getID()),
174
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(parentCategory.getID()),
195
175
  ).resolves.toBeNull();
196
176
 
197
- const loadedSubCategory = await CategoryEntity.loader(viewerContext)
198
- .enforcing()
199
- .loadByIDAsync(subCategory.getID());
177
+ const loadedSubCategory = await CategoryEntity.loader(viewerContext).loadByIDAsync(
178
+ subCategory.getID(),
179
+ );
200
180
  expect(loadedSubCategory.getField('parent_category_id')).toBeNull();
201
181
 
202
- const loadedSubSubCategory = await CategoryEntity.loader(viewerContext)
203
- .enforcing()
204
- .loadByIDAsync(subSubCategory.getID());
182
+ const loadedSubSubCategory = await CategoryEntity.loader(viewerContext).loadByIDAsync(
183
+ subSubCategory.getID(),
184
+ );
205
185
  expect(loadedSubSubCategory.getField('parent_category_id')).not.toBeNull();
206
186
  });
207
187
 
@@ -211,21 +191,19 @@ describe('EntityEdgeDeletionBehavior.SET_NULL', () => {
211
191
  const companionProvider = createUnitTestEntityCompanionProvider();
212
192
  const viewerContext = new TestViewerContext(companionProvider);
213
193
 
214
- const categoryA = await CategoryEntity.creator(viewerContext).enforcing().createAsync();
194
+ const categoryA = await CategoryEntity.creator(viewerContext).createAsync();
215
195
  const categoryB = await CategoryEntity.creator(viewerContext)
216
- .enforcing()
217
196
  .setField('parent_category_id', categoryA.getID())
218
197
  .createAsync();
219
198
  await CategoryEntity.updater(categoryA)
220
- .enforcing()
221
199
  .setField('parent_category_id', categoryB.getID())
222
200
  .updateAsync();
223
201
 
224
- await CategoryEntity.deleter(categoryA).enforcing().deleteAsync();
202
+ await CategoryEntity.deleter(categoryA).deleteAsync();
225
203
 
226
- const loadedCategoryB = await CategoryEntity.loader(viewerContext)
227
- .enforcing()
228
- .loadByIDAsync(categoryB.getID());
204
+ const loadedCategoryB = await CategoryEntity.loader(viewerContext).loadByIDAsync(
205
+ categoryB.getID(),
206
+ );
229
207
  expect(loadedCategoryB.getField('parent_category_id')).toBeNull();
230
208
  });
231
209
  });
@@ -239,30 +217,28 @@ describe('EntityEdgeDeletionBehavior.CASCADE_DELETE_INVALIDATE_CACHE', () => {
239
217
  const companionProvider = createUnitTestEntityCompanionProvider();
240
218
  const viewerContext = new TestViewerContext(companionProvider);
241
219
 
242
- const parentCategory = await CategoryEntity.creator(viewerContext).enforcing().createAsync();
220
+ const parentCategory = await CategoryEntity.creator(viewerContext).createAsync();
243
221
  const subCategory = await CategoryEntity.creator(viewerContext)
244
- .enforcing()
245
222
  .setField('parent_category_id', parentCategory.getID())
246
223
  .createAsync();
247
224
  const subSubCategory = await CategoryEntity.creator(viewerContext)
248
- .enforcing()
249
225
  .setField('parent_category_id', subCategory.getID())
250
226
  .createAsync();
251
227
 
252
228
  await expect(
253
- CategoryEntity.loader(viewerContext)
254
- .enforcing()
255
- .loadByIDNullableAsync(parentCategory.getID()),
229
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(parentCategory.getID()),
256
230
  ).resolves.not.toBeNull();
257
231
  await expect(
258
- CategoryEntity.loader(viewerContext)
259
- .enforcing()
260
- .loadByFieldEqualingAsync('parent_category_id', parentCategory.getID()),
232
+ CategoryEntity.loader(viewerContext).loadByFieldEqualingAsync(
233
+ 'parent_category_id',
234
+ parentCategory.getID(),
235
+ ),
261
236
  ).resolves.not.toBeNull();
262
237
  await expect(
263
- CategoryEntity.loader(viewerContext)
264
- .enforcing()
265
- .loadByFieldEqualingAsync('parent_category_id', subCategory.getID()),
238
+ CategoryEntity.loader(viewerContext).loadByFieldEqualingAsync(
239
+ 'parent_category_id',
240
+ subCategory.getID(),
241
+ ),
266
242
  ).resolves.not.toBeNull();
267
243
 
268
244
  const categoryCacheAdapter = viewerContext.getViewerScopedEntityCompanionForClass(
@@ -281,7 +257,7 @@ describe('EntityEdgeDeletionBehavior.CASCADE_DELETE_INVALIDATE_CACHE', () => {
281
257
  );
282
258
  expect(subSubCategoryCachedBefore.get(subCategory.getID())?.status).toEqual(CacheStatus.HIT);
283
259
 
284
- await CategoryEntity.deleter(parentCategory).enforcing().deleteAsync();
260
+ await CategoryEntity.deleter(parentCategory).deleteAsync();
285
261
 
286
262
  const subCategoryCachedAfter = await categoryCacheAdapter.loadManyAsync('parent_category_id', [
287
263
  parentCategory.getID(),
@@ -295,17 +271,13 @@ describe('EntityEdgeDeletionBehavior.CASCADE_DELETE_INVALIDATE_CACHE', () => {
295
271
  expect(subSubCategoryCachedAfter.get(subCategory.getID())?.status).toEqual(CacheStatus.MISS);
296
272
 
297
273
  await expect(
298
- CategoryEntity.loader(viewerContext)
299
- .enforcing()
300
- .loadByIDNullableAsync(parentCategory.getID()),
274
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(parentCategory.getID()),
301
275
  ).resolves.toBeNull();
302
276
  await expect(
303
- CategoryEntity.loader(viewerContext).enforcing().loadByIDNullableAsync(subCategory.getID()),
277
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(subCategory.getID()),
304
278
  ).resolves.not.toBeNull();
305
279
  await expect(
306
- CategoryEntity.loader(viewerContext)
307
- .enforcing()
308
- .loadByIDNullableAsync(subSubCategory.getID()),
280
+ CategoryEntity.loader(viewerContext).loadByIDNullableAsync(subSubCategory.getID()),
309
281
  ).resolves.not.toBeNull();
310
282
  });
311
283
 
@@ -317,25 +289,25 @@ describe('EntityEdgeDeletionBehavior.CASCADE_DELETE_INVALIDATE_CACHE', () => {
317
289
  const companionProvider = createUnitTestEntityCompanionProvider();
318
290
  const viewerContext = new TestViewerContext(companionProvider);
319
291
 
320
- const categoryA = await CategoryEntity.creator(viewerContext).enforcing().createAsync();
292
+ const categoryA = await CategoryEntity.creator(viewerContext).createAsync();
321
293
  const categoryB = await CategoryEntity.creator(viewerContext)
322
- .enforcing()
323
294
  .setField('parent_category_id', categoryA.getID())
324
295
  .createAsync();
325
296
  await CategoryEntity.updater(categoryA)
326
- .enforcing()
327
297
  .setField('parent_category_id', categoryB.getID())
328
298
  .updateAsync();
329
299
 
330
300
  await expect(
331
- CategoryEntity.loader(viewerContext)
332
- .enforcing()
333
- .loadByFieldEqualingAsync('parent_category_id', categoryA.getID()),
301
+ CategoryEntity.loader(viewerContext).loadByFieldEqualingAsync(
302
+ 'parent_category_id',
303
+ categoryA.getID(),
304
+ ),
334
305
  ).resolves.not.toBeNull();
335
306
  await expect(
336
- CategoryEntity.loader(viewerContext)
337
- .enforcing()
338
- .loadByFieldEqualingAsync('parent_category_id', categoryB.getID()),
307
+ CategoryEntity.loader(viewerContext).loadByFieldEqualingAsync(
308
+ 'parent_category_id',
309
+ categoryB.getID(),
310
+ ),
339
311
  ).resolves.not.toBeNull();
340
312
 
341
313
  const categoryCacheAdapter = viewerContext.getViewerScopedEntityCompanionForClass(
@@ -350,7 +322,7 @@ describe('EntityEdgeDeletionBehavior.CASCADE_DELETE_INVALIDATE_CACHE', () => {
350
322
  expect(categoriesCachedBefore.get(categoryA.getID())?.status).toEqual(CacheStatus.HIT);
351
323
  expect(categoriesCachedBefore.get(categoryB.getID())?.status).toEqual(CacheStatus.HIT);
352
324
 
353
- await CategoryEntity.deleter(categoryA).enforcing().deleteAsync();
325
+ await CategoryEntity.deleter(categoryA).deleteAsync();
354
326
 
355
327
  const categoriesCachedAfter = await categoryCacheAdapter.loadManyAsync('parent_category_id', [
356
328
  categoryA.getID(),