@expo/entity 0.31.1 → 0.33.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/ComposedEntityCacheAdapter.d.ts +4 -6
- package/build/ComposedEntityCacheAdapter.js +3 -6
- package/build/ComposedEntityCacheAdapter.js.map +1 -1
- package/build/EnforcingEntityLoader.d.ts +6 -1
- package/build/EnforcingEntityLoader.js +8 -0
- package/build/EnforcingEntityLoader.js.map +1 -1
- package/build/Entity.d.ts +20 -10
- package/build/Entity.js +2 -2
- package/build/Entity.js.map +1 -1
- package/build/EntityAssociationLoader.d.ts +9 -9
- package/build/EntityCompanion.d.ts +6 -5
- package/build/EntityCompanion.js +6 -4
- package/build/EntityCompanion.js.map +1 -1
- package/build/EntityCompanionProvider.d.ts +28 -36
- package/build/EntityCompanionProvider.js +4 -19
- package/build/EntityCompanionProvider.js.map +1 -1
- package/build/EntityConfiguration.d.ts +3 -3
- package/build/EntityConfiguration.js +2 -2
- package/build/EntityConfiguration.js.map +1 -1
- package/build/EntityDatabaseAdapter.d.ts +1 -1
- package/build/EntityDatabaseAdapter.js +1 -1
- package/build/EntityDatabaseAdapter.js.map +1 -1
- package/build/EntityFieldDefinition.d.ts +2 -2
- package/build/EntityFieldDefinition.js +1 -1
- package/build/EntityFieldDefinition.js.map +1 -1
- package/build/EntityLoader.d.ts +10 -2
- package/build/EntityLoader.js +32 -7
- package/build/EntityLoader.js.map +1 -1
- package/build/EntityLoaderFactory.d.ts +4 -7
- package/build/EntityLoaderFactory.js +3 -5
- package/build/EntityLoaderFactory.js.map +1 -1
- package/build/EntityMutationInfo.d.ts +3 -3
- package/build/EntityMutationInfo.js +1 -1
- package/build/EntityMutationInfo.js.map +1 -1
- package/build/EntityMutationTriggerConfiguration.d.ts +3 -3
- package/build/EntityMutationValidator.d.ts +1 -1
- package/build/EntityMutator.d.ts +9 -7
- package/build/EntityMutator.js +21 -21
- package/build/EntityMutator.js.map +1 -1
- package/build/EntityMutatorFactory.d.ts +4 -2
- package/build/EntityMutatorFactory.js +5 -4
- package/build/EntityMutatorFactory.js.map +1 -1
- package/build/EntityPrivacyPolicy.d.ts +3 -3
- package/build/EntityPrivacyPolicy.js +2 -2
- package/build/EntityPrivacyPolicy.js.map +1 -1
- package/build/EntityQueryContext.d.ts +13 -5
- package/build/EntityQueryContext.js +11 -4
- package/build/EntityQueryContext.js.map +1 -1
- package/build/EntityQueryContextProvider.d.ts +3 -3
- package/build/EntityQueryContextProvider.js +2 -2
- package/build/EntityQueryContextProvider.js.map +1 -1
- package/build/EntitySecondaryCacheLoader.d.ts +1 -1
- package/build/EntitySecondaryCacheLoader.js +1 -1
- package/build/EntitySecondaryCacheLoader.js.map +1 -1
- package/build/GenericEntityCacheAdapter.d.ts +14 -0
- package/build/GenericEntityCacheAdapter.js +38 -0
- package/build/GenericEntityCacheAdapter.js.map +1 -0
- package/build/{EntityCacheAdapter.d.ts → IEntityCacheAdapter.d.ts} +5 -8
- package/build/IEntityCacheAdapter.js +3 -0
- package/build/IEntityCacheAdapter.js.map +1 -0
- package/build/IEntityCacheAdapterProvider.d.ts +2 -2
- package/build/IEntityGenericCacher.d.ts +31 -2
- package/build/ReadonlyEntity.d.ts +19 -7
- package/build/ReadonlyEntity.js +15 -13
- package/build/ReadonlyEntity.js.map +1 -1
- package/build/ViewerContext.d.ts +3 -3
- package/build/ViewerContext.js +3 -3
- package/build/ViewerContext.js.map +1 -1
- package/build/ViewerScopedEntityCompanion.d.ts +2 -2
- package/build/ViewerScopedEntityCompanion.js.map +1 -1
- package/build/ViewerScopedEntityCompanionProvider.d.ts +3 -3
- package/build/ViewerScopedEntityCompanionProvider.js +3 -3
- package/build/ViewerScopedEntityCompanionProvider.js.map +1 -1
- package/build/ViewerScopedEntityLoaderFactory.d.ts +1 -1
- package/build/ViewerScopedEntityMutatorFactory.d.ts +1 -1
- package/build/__tests__/ComposedCacheAdapter-test.js +4 -8
- package/build/__tests__/ComposedCacheAdapter-test.js.map +1 -1
- package/build/__tests__/EnforcingEntityLoader-test.js +28 -0
- package/build/__tests__/EnforcingEntityLoader-test.js.map +1 -1
- package/build/__tests__/Entity-test.js +42 -20
- package/build/__tests__/Entity-test.js.map +1 -1
- package/build/__tests__/EntityAssociationLoader-test.js +6 -6
- package/build/__tests__/EntityAssociationLoader-test.js.map +1 -1
- package/build/__tests__/EntityCommonUseCases-test.js +20 -22
- package/build/__tests__/EntityCommonUseCases-test.js.map +1 -1
- package/build/__tests__/EntityCompanion-test.js +2 -1
- package/build/__tests__/EntityCompanion-test.js.map +1 -1
- package/build/__tests__/EntityCompanionProvider-test.js +15 -40
- package/build/__tests__/EntityCompanionProvider-test.js.map +1 -1
- package/build/__tests__/EntityEdges-test.js +48 -54
- package/build/__tests__/EntityEdges-test.js.map +1 -1
- package/build/__tests__/EntityLoader-constructor-test.d.ts +9 -5
- package/build/__tests__/EntityLoader-constructor-test.js +13 -14
- package/build/__tests__/EntityLoader-constructor-test.js.map +1 -1
- package/build/__tests__/EntityLoader-test.js +22 -12
- package/build/__tests__/EntityLoader-test.js.map +1 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +20 -22
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +1 -1
- package/build/__tests__/EntityMutator-test.js +67 -14
- package/build/__tests__/EntityMutator-test.js.map +1 -1
- package/build/__tests__/EntityPrivacyPolicy-test.js +82 -29
- package/build/__tests__/EntityPrivacyPolicy-test.js.map +1 -1
- package/build/__tests__/EntityQueryContext-test.js +12 -0
- package/build/__tests__/EntityQueryContext-test.js.map +1 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.js +1 -2
- package/build/__tests__/EntitySecondaryCacheLoader-test.js.map +1 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.js +16 -20
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +1 -1
- package/build/__tests__/GenericEntityCacheAdapter-test.d.ts +1 -0
- package/build/__tests__/GenericEntityCacheAdapter-test.js +80 -0
- package/build/__tests__/GenericEntityCacheAdapter-test.js.map +1 -0
- package/build/__tests__/ReadonlyEntity-test.js +79 -13
- package/build/__tests__/ReadonlyEntity-test.js.map +1 -1
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js +2 -25
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +20 -23
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +17 -20
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +1 -1
- package/build/errors/EntityError.js +2 -2
- package/build/errors/EntityError.js.map +1 -1
- package/build/errors/EntityInvalidFieldValueError.d.ts +2 -2
- package/build/errors/EntityInvalidFieldValueError.js.map +1 -1
- package/build/errors/EntityNotAuthorizedError.d.ts +2 -2
- package/build/errors/EntityNotAuthorizedError.js +1 -1
- package/build/errors/EntityNotAuthorizedError.js.map +1 -1
- package/build/errors/EntityNotFoundError.d.ts +2 -2
- package/build/errors/EntityNotFoundError.js.map +1 -1
- package/build/index.d.ts +2 -1
- package/build/index.js +3 -3
- package/build/index.js.map +1 -1
- package/build/internal/EntityDataManager.d.ts +1 -1
- package/build/internal/EntityDataManager.js +1 -1
- package/build/internal/EntityDataManager.js.map +1 -1
- package/build/internal/EntityFieldTransformationUtils.d.ts +1 -1
- package/build/internal/EntityFieldTransformationUtils.js +4 -4
- package/build/internal/EntityFieldTransformationUtils.js.map +1 -1
- package/build/internal/EntityTableDataCoordinator.d.ts +3 -3
- package/build/internal/EntityTableDataCoordinator.js.map +1 -1
- package/build/internal/ReadThroughEntityCache.d.ts +3 -3
- package/build/internal/ReadThroughEntityCache.js +1 -1
- package/build/internal/ReadThroughEntityCache.js.map +1 -1
- package/build/internal/__tests__/EntityDataManager-test.js +1 -1
- package/build/internal/__tests__/EntityDataManager-test.js.map +1 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.js.map +1 -1
- package/build/metrics/EntityMetricsUtils.js.map +1 -1
- package/build/metrics/IEntityMetricsAdapter.js +4 -4
- package/build/metrics/IEntityMetricsAdapter.js.map +1 -1
- package/build/rules/AlwaysAllowPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysAllowPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysDenyPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysDenyPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysSkipPrivacyPolicyRule.d.ts +2 -2
- package/build/rules/AlwaysSkipPrivacyPolicyRule.js.map +1 -1
- package/build/rules/PrivacyPolicyRule.d.ts +1 -1
- package/build/rules/PrivacyPolicyRule.js +1 -1
- package/build/rules/PrivacyPolicyRule.js.map +1 -1
- package/build/testfixtures/DateIDTestEntity.d.ts +2 -3
- package/build/testfixtures/DateIDTestEntity.js +7 -9
- package/build/testfixtures/DateIDTestEntity.js.map +1 -1
- package/build/testfixtures/SimpleTestEntity.d.ts +3 -4
- package/build/testfixtures/SimpleTestEntity.js +7 -9
- package/build/testfixtures/SimpleTestEntity.js.map +1 -1
- package/build/testfixtures/TestEntity.d.ts +2 -3
- package/build/testfixtures/TestEntity.js +14 -10
- package/build/testfixtures/TestEntity.js.map +1 -1
- package/build/testfixtures/TestEntity2.d.ts +2 -3
- package/build/testfixtures/TestEntity2.js +7 -9
- package/build/testfixtures/TestEntity2.js.map +1 -1
- package/build/testfixtures/TestEntityNumberKey.d.ts +2 -3
- package/build/testfixtures/TestEntityNumberKey.js +7 -9
- package/build/testfixtures/TestEntityNumberKey.js.map +1 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.d.ts +4 -4
- package/build/utils/testing/StubCacheAdapter.d.ts +6 -5
- package/build/utils/testing/StubCacheAdapter.js +5 -6
- package/build/utils/testing/StubCacheAdapter.js.map +1 -1
- package/build/utils/testing/StubDatabaseAdapterProvider.js.map +1 -1
- package/build/utils/testing/StubQueryContextProvider.d.ts +2 -1
- package/build/utils/testing/StubQueryContextProvider.js +1 -1
- package/build/utils/testing/StubQueryContextProvider.js.map +1 -1
- package/build/utils/testing/createUnitTestEntityCompanionProvider.js +2 -2
- package/build/utils/testing/createUnitTestEntityCompanionProvider.js.map +1 -1
- package/package.json +3 -3
- package/src/ComposedEntityCacheAdapter.ts +4 -11
- package/src/EnforcingEntityLoader.ts +10 -1
- package/src/Entity.ts +23 -12
- package/src/EntityAssociationLoader.ts +12 -12
- package/src/EntityCompanion.ts +13 -32
- package/src/EntityCompanionProvider.ts +41 -80
- package/src/EntityConfiguration.ts +4 -5
- package/src/EntityFieldDefinition.ts +2 -2
- package/src/EntityLoader.ts +36 -2
- package/src/EntityLoaderFactory.ts +7 -9
- package/src/EntityMutationInfo.ts +2 -2
- package/src/EntityMutationTriggerConfiguration.ts +3 -3
- package/src/EntityMutationValidator.ts +1 -1
- package/src/EntityMutator.ts +38 -31
- package/src/EntityMutatorFactory.ts +6 -1
- package/src/EntityPrivacyPolicy.ts +2 -2
- package/src/EntityQueryContext.ts +24 -4
- package/src/EntityQueryContextProvider.ts +7 -5
- package/src/EntitySecondaryCacheLoader.ts +1 -1
- package/src/GenericEntityCacheAdapter.ts +65 -0
- package/src/{EntityCacheAdapter.ts → IEntityCacheAdapter.ts} +5 -8
- package/src/IEntityCacheAdapterProvider.ts +2 -2
- package/src/IEntityGenericCacher.ts +32 -2
- package/src/ReadonlyEntity.ts +32 -32
- package/src/ViewerContext.ts +10 -8
- package/src/ViewerScopedEntityCompanion.ts +2 -2
- package/src/ViewerScopedEntityCompanionProvider.ts +4 -12
- package/src/ViewerScopedEntityLoaderFactory.ts +1 -1
- package/src/ViewerScopedEntityMutatorFactory.ts +1 -1
- package/src/__tests__/ComposedCacheAdapter-test.ts +6 -11
- package/src/__tests__/EnforcingEntityLoader-test.ts +44 -0
- package/src/__tests__/Entity-test.ts +42 -21
- package/src/__tests__/EntityCommonUseCases-test.ts +20 -22
- package/src/__tests__/EntityCompanion-test.ts +6 -9
- package/src/__tests__/EntityCompanionProvider-test.ts +14 -26
- package/src/__tests__/EntityEdges-test.ts +43 -49
- package/src/__tests__/EntityLoader-constructor-test.ts +16 -12
- package/src/__tests__/EntityLoader-test.ts +14 -1
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +20 -22
- package/src/__tests__/EntityMutator-test.ts +119 -19
- package/src/__tests__/EntityPrivacyPolicy-test.ts +82 -29
- package/src/__tests__/EntityQueryContext-test.ts +23 -1
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +8 -10
- package/src/__tests__/GenericEntityCacheAdapter-test.ts +102 -0
- package/src/__tests__/ReadonlyEntity-test.ts +79 -13
- package/src/__tests__/ViewerScopedEntityCompanionProvider-test.ts +2 -5
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +30 -24
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +14 -18
- package/src/errors/EntityInvalidFieldValueError.ts +2 -2
- package/src/errors/EntityNotAuthorizedError.ts +2 -2
- package/src/errors/EntityNotFoundError.ts +2 -2
- package/src/index.ts +2 -1
- package/src/internal/EntityDataManager.ts +1 -1
- package/src/internal/EntityTableDataCoordinator.ts +4 -4
- package/src/internal/ReadThroughEntityCache.ts +2 -2
- package/src/internal/__tests__/EntityDataManager-test.ts +2 -1
- package/src/internal/__tests__/ReadThroughEntityCache-test.ts +8 -8
- package/src/metrics/EntityMetricsUtils.ts +1 -1
- package/src/rules/AlwaysAllowPrivacyPolicyRule.ts +2 -2
- package/src/rules/AlwaysDenyPrivacyPolicyRule.ts +2 -2
- package/src/rules/AlwaysSkipPrivacyPolicyRule.ts +2 -2
- package/src/rules/PrivacyPolicyRule.ts +1 -1
- package/src/testfixtures/DateIDTestEntity.ts +6 -8
- package/src/testfixtures/SimpleTestEntity.ts +6 -8
- package/src/testfixtures/TestEntity.ts +19 -15
- package/src/testfixtures/TestEntity2.ts +6 -8
- package/src/testfixtures/TestEntityNumberKey.ts +6 -8
- package/src/utils/testing/PrivacyPolicyRuleTestUtils.ts +4 -4
- package/src/utils/testing/StubCacheAdapter.ts +9 -11
- package/src/utils/testing/StubDatabaseAdapterProvider.ts +1 -1
- package/src/utils/testing/StubQueryContextProvider.ts +4 -3
- package/src/utils/testing/createUnitTestEntityCompanionProvider.ts +3 -3
- package/build/EntityCacheAdapter.js +0 -13
- package/build/EntityCacheAdapter.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { verify, deepEqual, mock, instance, when, anything } from 'ts-mockito';
|
|
2
2
|
|
|
3
|
-
import EntityCacheAdapter from '../../EntityCacheAdapter';
|
|
4
3
|
import EntityConfiguration from '../../EntityConfiguration';
|
|
5
4
|
import { UUIDField } from '../../EntityFields';
|
|
5
|
+
import IEntityCacheAdapter from '../../IEntityCacheAdapter';
|
|
6
6
|
import ReadThroughEntityCache, { CacheStatus } from '../ReadThroughEntityCache';
|
|
7
7
|
|
|
8
8
|
type BlahFields = {
|
|
@@ -39,7 +39,7 @@ const createIdFetcher =
|
|
|
39
39
|
describe(ReadThroughEntityCache, () => {
|
|
40
40
|
describe('readManyThroughAsync', () => {
|
|
41
41
|
it('fetches from DB upon cache miss and caches the result', async () => {
|
|
42
|
-
const cacheAdapterMock = mock<
|
|
42
|
+
const cacheAdapterMock = mock<IEntityCacheAdapter<BlahFields>>();
|
|
43
43
|
const cacheAdapter = instance(cacheAdapterMock);
|
|
44
44
|
const entityCache = new ReadThroughEntityCache(makeEntityConfiguration(true), cacheAdapter);
|
|
45
45
|
const fetcher = createIdFetcher(['wat', 'who']);
|
|
@@ -75,7 +75,7 @@ describe(ReadThroughEntityCache, () => {
|
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
it('does not fetch from the DB or cache results when all cache fetches are hits', async () => {
|
|
78
|
-
const cacheAdapterMock = mock<
|
|
78
|
+
const cacheAdapterMock = mock<IEntityCacheAdapter<BlahFields>>();
|
|
79
79
|
const cacheAdapter = instance(cacheAdapterMock);
|
|
80
80
|
const entityCache = new ReadThroughEntityCache(makeEntityConfiguration(true), cacheAdapter);
|
|
81
81
|
const fetcher = createIdFetcher(['wat', 'who']);
|
|
@@ -111,7 +111,7 @@ describe(ReadThroughEntityCache, () => {
|
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
it('negatively caches db misses', async () => {
|
|
114
|
-
const cacheAdapterMock = mock<
|
|
114
|
+
const cacheAdapterMock = mock<IEntityCacheAdapter<BlahFields>>();
|
|
115
115
|
const cacheAdapter = instance(cacheAdapterMock);
|
|
116
116
|
const entityCache = new ReadThroughEntityCache(makeEntityConfiguration(true), cacheAdapter);
|
|
117
117
|
|
|
@@ -131,7 +131,7 @@ describe(ReadThroughEntityCache, () => {
|
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
it('does not return or fetch negatively cached results from DB', async () => {
|
|
134
|
-
const cacheAdapterMock = mock<
|
|
134
|
+
const cacheAdapterMock = mock<IEntityCacheAdapter<BlahFields>>();
|
|
135
135
|
const cacheAdapter = instance(cacheAdapterMock);
|
|
136
136
|
const entityCache = new ReadThroughEntityCache(makeEntityConfiguration(true), cacheAdapter);
|
|
137
137
|
const fetcher = createIdFetcher([]);
|
|
@@ -148,7 +148,7 @@ describe(ReadThroughEntityCache, () => {
|
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
it('does a mix and match of hit, miss, and negative', async () => {
|
|
151
|
-
const cacheAdapterMock = mock<
|
|
151
|
+
const cacheAdapterMock = mock<IEntityCacheAdapter<BlahFields>>();
|
|
152
152
|
const cacheAdapter = instance(cacheAdapterMock);
|
|
153
153
|
const entityCache = new ReadThroughEntityCache(makeEntityConfiguration(true), cacheAdapter);
|
|
154
154
|
const fetcher = createIdFetcher(['wat', 'who', 'why']);
|
|
@@ -183,7 +183,7 @@ describe(ReadThroughEntityCache, () => {
|
|
|
183
183
|
});
|
|
184
184
|
|
|
185
185
|
it('does not call into cache for field that is not cacheable', async () => {
|
|
186
|
-
const cacheAdapterMock = mock<
|
|
186
|
+
const cacheAdapterMock = mock<IEntityCacheAdapter<BlahFields>>();
|
|
187
187
|
const cacheAdapter = instance(cacheAdapterMock);
|
|
188
188
|
const entityCache = new ReadThroughEntityCache(makeEntityConfiguration(false), cacheAdapter);
|
|
189
189
|
const fetcher = createIdFetcher(['wat']);
|
|
@@ -195,7 +195,7 @@ describe(ReadThroughEntityCache, () => {
|
|
|
195
195
|
|
|
196
196
|
describe('invalidateManyAsync', () => {
|
|
197
197
|
it('calls cache adapter invalidate', async () => {
|
|
198
|
-
const cacheAdapterMock = mock<
|
|
198
|
+
const cacheAdapterMock = mock<IEntityCacheAdapter<BlahFields>>();
|
|
199
199
|
const cacheAdapter = instance(cacheAdapterMock);
|
|
200
200
|
const entityCache = new ReadThroughEntityCache(makeEntityConfiguration(true), cacheAdapter);
|
|
201
201
|
await entityCache.invalidateManyAsync('id', ['wat']);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { reduceMap } from '../utils/collections/maps';
|
|
2
1
|
import IEntityMetricsAdapter, {
|
|
3
2
|
EntityMetricsLoadType,
|
|
4
3
|
EntityMetricsMutationType,
|
|
5
4
|
} from './IEntityMetricsAdapter';
|
|
5
|
+
import { reduceMap } from '../utils/collections/maps';
|
|
6
6
|
|
|
7
7
|
export const timeAndLogLoadEventAsync =
|
|
8
8
|
(
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import PrivacyPolicyRule, { RuleEvaluationResult } from './PrivacyPolicyRule';
|
|
1
2
|
import { EntityPrivacyPolicyEvaluationContext } from '../EntityPrivacyPolicy';
|
|
2
3
|
import { EntityQueryContext } from '../EntityQueryContext';
|
|
3
4
|
import ReadonlyEntity from '../ReadonlyEntity';
|
|
4
5
|
import ViewerContext from '../ViewerContext';
|
|
5
|
-
import PrivacyPolicyRule, { RuleEvaluationResult } from './PrivacyPolicyRule';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Privacy policy rule that always allows.
|
|
9
9
|
*/
|
|
10
10
|
export default class AlwaysAllowPrivacyPolicyRule<
|
|
11
|
-
TFields,
|
|
11
|
+
TFields extends object,
|
|
12
12
|
TID extends NonNullable<TFields[TSelectedFields]>,
|
|
13
13
|
TViewerContext extends ViewerContext,
|
|
14
14
|
TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import PrivacyPolicyRule, { RuleEvaluationResult } from './PrivacyPolicyRule';
|
|
1
2
|
import { EntityPrivacyPolicyEvaluationContext } from '../EntityPrivacyPolicy';
|
|
2
3
|
import { EntityQueryContext } from '../EntityQueryContext';
|
|
3
4
|
import ReadonlyEntity from '../ReadonlyEntity';
|
|
4
5
|
import ViewerContext from '../ViewerContext';
|
|
5
|
-
import PrivacyPolicyRule, { RuleEvaluationResult } from './PrivacyPolicyRule';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Privacy policy rule that always denies.
|
|
9
9
|
*/
|
|
10
10
|
export default class AlwaysDenyPrivacyPolicyRule<
|
|
11
|
-
TFields,
|
|
11
|
+
TFields extends object,
|
|
12
12
|
TID extends NonNullable<TFields[TSelectedFields]>,
|
|
13
13
|
TViewerContext extends ViewerContext,
|
|
14
14
|
TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import PrivacyPolicyRule, { RuleEvaluationResult } from './PrivacyPolicyRule';
|
|
1
2
|
import { EntityPrivacyPolicyEvaluationContext } from '../EntityPrivacyPolicy';
|
|
2
3
|
import { EntityQueryContext } from '../EntityQueryContext';
|
|
3
4
|
import ReadonlyEntity from '../ReadonlyEntity';
|
|
4
5
|
import ViewerContext from '../ViewerContext';
|
|
5
|
-
import PrivacyPolicyRule, { RuleEvaluationResult } from './PrivacyPolicyRule';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* A no-op policy rule that always skips.
|
|
9
9
|
*/
|
|
10
10
|
export default class AlwaysSkipPrivacyPolicyRule<
|
|
11
|
-
TFields,
|
|
11
|
+
TFields extends object,
|
|
12
12
|
TID extends NonNullable<TFields[TSelectedFields]>,
|
|
13
13
|
TViewerContext extends ViewerContext,
|
|
14
14
|
TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>,
|
|
@@ -37,7 +37,7 @@ export enum RuleEvaluationResult {
|
|
|
37
37
|
* would be named something like `DenyIfViewerHasBeenBlockedPrivacyPolicyRule`.
|
|
38
38
|
*/
|
|
39
39
|
export default abstract class PrivacyPolicyRule<
|
|
40
|
-
TFields,
|
|
40
|
+
TFields extends object,
|
|
41
41
|
TID extends NonNullable<TFields[TSelectedFields]>,
|
|
42
42
|
TViewerContext extends ViewerContext,
|
|
43
43
|
TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>,
|
|
@@ -43,19 +43,17 @@ export class DateIDTestEntityPrivacyPolicy extends EntityPrivacyPolicy<
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export default class DateIDTestEntity extends Entity<DateIDTestFields, Date, ViewerContext> {
|
|
46
|
-
static
|
|
46
|
+
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
47
47
|
DateIDTestFields,
|
|
48
48
|
Date,
|
|
49
49
|
ViewerContext,
|
|
50
50
|
DateIDTestEntity,
|
|
51
51
|
DateIDTestEntityPrivacyPolicy
|
|
52
52
|
> {
|
|
53
|
-
return
|
|
53
|
+
return {
|
|
54
|
+
entityClass: DateIDTestEntity,
|
|
55
|
+
entityConfiguration: dateIDTestEntityConfiguration,
|
|
56
|
+
privacyPolicyClass: DateIDTestEntityPrivacyPolicy,
|
|
57
|
+
};
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
|
-
|
|
57
|
-
export const dateIDTestEntityCompanion = new EntityCompanionDefinition({
|
|
58
|
-
entityClass: DateIDTestEntity,
|
|
59
|
-
entityConfiguration: dateIDTestEntityConfiguration,
|
|
60
|
-
privacyPolicyClass: DateIDTestEntityPrivacyPolicy,
|
|
61
|
-
});
|
|
@@ -75,7 +75,7 @@ export default class SimpleTestEntity extends Entity<
|
|
|
75
75
|
ViewerContext,
|
|
76
76
|
SimpleTestFieldSelection
|
|
77
77
|
> {
|
|
78
|
-
static
|
|
78
|
+
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
79
79
|
SimpleTestFields,
|
|
80
80
|
string,
|
|
81
81
|
ViewerContext,
|
|
@@ -83,12 +83,10 @@ export default class SimpleTestEntity extends Entity<
|
|
|
83
83
|
SimpleTestEntityPrivacyPolicy,
|
|
84
84
|
SimpleTestFieldSelection
|
|
85
85
|
> {
|
|
86
|
-
return
|
|
86
|
+
return {
|
|
87
|
+
entityClass: SimpleTestEntity,
|
|
88
|
+
entityConfiguration: simpleTestEntityConfiguration,
|
|
89
|
+
privacyPolicyClass: SimpleTestEntityPrivacyPolicy,
|
|
90
|
+
};
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
|
-
|
|
90
|
-
export const testEntityCompanion = new EntityCompanionDefinition({
|
|
91
|
-
entityClass: SimpleTestEntity,
|
|
92
|
-
entityConfiguration: simpleTestEntityConfiguration,
|
|
93
|
-
privacyPolicyClass: SimpleTestEntityPrivacyPolicy,
|
|
94
|
-
});
|
|
@@ -66,14 +66,18 @@ export class TestEntityPrivacyPolicy extends EntityPrivacyPolicy<
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export default class TestEntity extends Entity<TestFields, string, ViewerContext> {
|
|
69
|
-
static
|
|
69
|
+
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
70
70
|
TestFields,
|
|
71
71
|
string,
|
|
72
72
|
ViewerContext,
|
|
73
73
|
TestEntity,
|
|
74
74
|
TestEntityPrivacyPolicy
|
|
75
75
|
> {
|
|
76
|
-
return
|
|
76
|
+
return {
|
|
77
|
+
entityClass: TestEntity,
|
|
78
|
+
entityConfiguration: testEntityConfiguration,
|
|
79
|
+
privacyPolicyClass: TestEntityPrivacyPolicy,
|
|
80
|
+
};
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
getBlah(): string {
|
|
@@ -81,14 +85,20 @@ export default class TestEntity extends Entity<TestFields, string, ViewerContext
|
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
static async hello(viewerContext: ViewerContext, testValue: string): Promise<Result<TestEntity>> {
|
|
88
|
+
const fields = {
|
|
89
|
+
customIdField: testValue,
|
|
90
|
+
testIndexedField: 'hello',
|
|
91
|
+
stringField: 'hello',
|
|
92
|
+
intField: 1,
|
|
93
|
+
dateField: new Date(),
|
|
94
|
+
nullableField: null,
|
|
95
|
+
};
|
|
84
96
|
return result(
|
|
85
|
-
new TestEntity(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
dateField: new Date(),
|
|
91
|
-
nullableField: null,
|
|
97
|
+
new TestEntity({
|
|
98
|
+
viewerContext,
|
|
99
|
+
id: testValue,
|
|
100
|
+
databaseFields: fields,
|
|
101
|
+
selectedFields: fields,
|
|
92
102
|
})
|
|
93
103
|
);
|
|
94
104
|
}
|
|
@@ -105,9 +115,3 @@ export default class TestEntity extends Entity<TestFields, string, ViewerContext
|
|
|
105
115
|
return testValue;
|
|
106
116
|
}
|
|
107
117
|
}
|
|
108
|
-
|
|
109
|
-
export const testEntityCompanion = new EntityCompanionDefinition({
|
|
110
|
-
entityClass: TestEntity,
|
|
111
|
-
entityConfiguration: testEntityConfiguration,
|
|
112
|
-
privacyPolicyClass: TestEntityPrivacyPolicy,
|
|
113
|
-
});
|
|
@@ -47,19 +47,17 @@ export class TestEntity2PrivacyPolicy extends EntityPrivacyPolicy<
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export default class TestEntity2 extends Entity<Test2Fields, string, ViewerContext> {
|
|
50
|
-
static
|
|
50
|
+
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
51
51
|
Test2Fields,
|
|
52
52
|
string,
|
|
53
53
|
ViewerContext,
|
|
54
54
|
TestEntity2,
|
|
55
55
|
TestEntity2PrivacyPolicy
|
|
56
56
|
> {
|
|
57
|
-
return
|
|
57
|
+
return {
|
|
58
|
+
entityClass: TestEntity2,
|
|
59
|
+
entityConfiguration: testEntity2Configuration,
|
|
60
|
+
privacyPolicyClass: TestEntity2PrivacyPolicy,
|
|
61
|
+
};
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
|
-
|
|
61
|
-
export const testEntity2Companion = new EntityCompanionDefinition({
|
|
62
|
-
entityClass: TestEntity2,
|
|
63
|
-
entityConfiguration: testEntity2Configuration,
|
|
64
|
-
privacyPolicyClass: TestEntity2PrivacyPolicy,
|
|
65
|
-
});
|
|
@@ -43,19 +43,17 @@ export class NumberKeyPrivacyPolicy extends EntityPrivacyPolicy<
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export default class NumberKeyEntity extends Entity<NumberKeyFields, number, ViewerContext> {
|
|
46
|
-
static
|
|
46
|
+
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
47
47
|
NumberKeyFields,
|
|
48
48
|
number,
|
|
49
49
|
ViewerContext,
|
|
50
50
|
NumberKeyEntity,
|
|
51
51
|
NumberKeyPrivacyPolicy
|
|
52
52
|
> {
|
|
53
|
-
return
|
|
53
|
+
return {
|
|
54
|
+
entityClass: NumberKeyEntity,
|
|
55
|
+
entityConfiguration: numberKeyEntityConfiguration,
|
|
56
|
+
privacyPolicyClass: NumberKeyPrivacyPolicy,
|
|
57
|
+
};
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
|
-
|
|
57
|
-
export const numberKeyEntityCompanion = new EntityCompanionDefinition({
|
|
58
|
-
entityClass: NumberKeyEntity,
|
|
59
|
-
entityConfiguration: numberKeyEntityConfiguration,
|
|
60
|
-
privacyPolicyClass: NumberKeyPrivacyPolicy,
|
|
61
|
-
});
|
|
@@ -5,7 +5,7 @@ import ViewerContext from '../../ViewerContext';
|
|
|
5
5
|
import PrivacyPolicyRule, { RuleEvaluationResult } from '../../rules/PrivacyPolicyRule';
|
|
6
6
|
|
|
7
7
|
export interface Case<
|
|
8
|
-
TFields,
|
|
8
|
+
TFields extends object,
|
|
9
9
|
TID extends NonNullable<TFields[TSelectedFields]>,
|
|
10
10
|
TViewerContext extends ViewerContext,
|
|
11
11
|
TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>,
|
|
@@ -18,7 +18,7 @@ export interface Case<
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export type CaseMap<
|
|
21
|
-
TFields,
|
|
21
|
+
TFields extends object,
|
|
22
22
|
TID extends NonNullable<TFields[TSelectedFields]>,
|
|
23
23
|
TViewerContext extends ViewerContext,
|
|
24
24
|
TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>,
|
|
@@ -29,7 +29,7 @@ export type CaseMap<
|
|
|
29
29
|
* Useful for defining test cases that have async preconditions.
|
|
30
30
|
*/
|
|
31
31
|
export const describePrivacyPolicyRuleWithAsyncTestCase = <
|
|
32
|
-
TFields,
|
|
32
|
+
TFields extends object,
|
|
33
33
|
TID extends NonNullable<TFields[TSelectedFields]>,
|
|
34
34
|
TViewerContext extends ViewerContext,
|
|
35
35
|
TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>,
|
|
@@ -92,7 +92,7 @@ export const describePrivacyPolicyRuleWithAsyncTestCase = <
|
|
|
92
92
|
* For test simple privacy rules that don't have complex async preconditions.
|
|
93
93
|
*/
|
|
94
94
|
export const describePrivacyPolicyRule = <
|
|
95
|
-
TFields,
|
|
95
|
+
TFields extends object,
|
|
96
96
|
TID extends NonNullable<TFields[TSelectedFields]>,
|
|
97
97
|
TViewerContext extends ViewerContext,
|
|
98
98
|
TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import invariant from 'invariant';
|
|
2
2
|
|
|
3
|
-
import EntityCacheAdapter from '../../EntityCacheAdapter';
|
|
4
3
|
import EntityConfiguration from '../../EntityConfiguration';
|
|
4
|
+
import IEntityCacheAdapter from '../../IEntityCacheAdapter';
|
|
5
5
|
import IEntityCacheAdapterProvider from '../../IEntityCacheAdapterProvider';
|
|
6
6
|
import { CacheStatus, CacheLoadResult } from '../../internal/ReadThroughEntityCache';
|
|
7
7
|
|
|
8
8
|
export class NoCacheStubCacheAdapterProvider implements IEntityCacheAdapterProvider {
|
|
9
9
|
getCacheAdapter<TFields>(
|
|
10
|
-
|
|
11
|
-
):
|
|
12
|
-
return new NoCacheStubCacheAdapter(
|
|
10
|
+
_entityConfiguration: EntityConfiguration<TFields>
|
|
11
|
+
): IEntityCacheAdapter<TFields> {
|
|
12
|
+
return new NoCacheStubCacheAdapter();
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export class NoCacheStubCacheAdapter<TFields>
|
|
16
|
+
export class NoCacheStubCacheAdapter<TFields> implements IEntityCacheAdapter<TFields> {
|
|
17
17
|
public async loadManyAsync<N extends keyof TFields>(
|
|
18
18
|
_fieldName: N,
|
|
19
19
|
fieldValues: readonly NonNullable<TFields[N]>[]
|
|
@@ -47,7 +47,7 @@ export class InMemoryFullCacheStubCacheAdapterProvider implements IEntityCacheAd
|
|
|
47
47
|
|
|
48
48
|
getCacheAdapter<TFields>(
|
|
49
49
|
entityConfiguration: EntityConfiguration<TFields>
|
|
50
|
-
):
|
|
50
|
+
): IEntityCacheAdapter<TFields> {
|
|
51
51
|
return new InMemoryFullCacheStubCacheAdapter(
|
|
52
52
|
entityConfiguration,
|
|
53
53
|
this.cache as Map<string, Readonly<TFields>>
|
|
@@ -55,13 +55,11 @@ export class InMemoryFullCacheStubCacheAdapterProvider implements IEntityCacheAd
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
export class InMemoryFullCacheStubCacheAdapter<TFields>
|
|
58
|
+
export class InMemoryFullCacheStubCacheAdapter<TFields> implements IEntityCacheAdapter<TFields> {
|
|
59
59
|
constructor(
|
|
60
|
-
entityConfiguration: EntityConfiguration<TFields>,
|
|
60
|
+
private readonly entityConfiguration: EntityConfiguration<TFields>,
|
|
61
61
|
readonly cache: Map<string, Readonly<TFields>>
|
|
62
|
-
) {
|
|
63
|
-
super(entityConfiguration);
|
|
64
|
-
}
|
|
62
|
+
) {}
|
|
65
63
|
|
|
66
64
|
public async loadManyAsync<N extends keyof TFields>(
|
|
67
65
|
fieldName: N,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import StubDatabaseAdapter from './StubDatabaseAdapter';
|
|
1
2
|
import EntityConfiguration from '../../EntityConfiguration';
|
|
2
3
|
import EntityDatabaseAdapter from '../../EntityDatabaseAdapter';
|
|
3
4
|
import IEntityDatabaseAdapterProvider from '../../IEntityDatabaseAdapterProvider';
|
|
4
|
-
import StubDatabaseAdapter from './StubDatabaseAdapter';
|
|
5
5
|
|
|
6
6
|
export default class StubDatabaseAdapterProvider implements IEntityDatabaseAdapterProvider {
|
|
7
7
|
private readonly objectCollection = new Map();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TransactionConfig } from '../../EntityQueryContext';
|
|
1
2
|
import EntityQueryContextProvider from '../../EntityQueryContextProvider';
|
|
2
3
|
|
|
3
4
|
export class StubQueryContextProvider extends EntityQueryContextProvider {
|
|
@@ -5,9 +6,9 @@ export class StubQueryContextProvider extends EntityQueryContextProvider {
|
|
|
5
6
|
return {};
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
protected createTransactionRunner<T>(
|
|
9
|
-
|
|
10
|
-
) => Promise<T> {
|
|
9
|
+
protected createTransactionRunner<T>(
|
|
10
|
+
_transactionConfig?: TransactionConfig
|
|
11
|
+
): (transactionScope: (queryInterface: any) => Promise<T>) => Promise<T> {
|
|
11
12
|
return (transactionScope) => Promise.resolve(transactionScope({}));
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import EntityCompanionProvider from '../../EntityCompanionProvider';
|
|
2
|
-
import IEntityMetricsAdapter from '../../metrics/IEntityMetricsAdapter';
|
|
3
|
-
import NoOpEntityMetricsAdapter from '../../metrics/NoOpEntityMetricsAdapter';
|
|
4
1
|
import { InMemoryFullCacheStubCacheAdapterProvider } from './StubCacheAdapter';
|
|
5
2
|
import StubDatabaseAdapterProvider from './StubDatabaseAdapterProvider';
|
|
6
3
|
import StubQueryContextProvider from './StubQueryContextProvider';
|
|
4
|
+
import EntityCompanionProvider from '../../EntityCompanionProvider';
|
|
5
|
+
import IEntityMetricsAdapter from '../../metrics/IEntityMetricsAdapter';
|
|
6
|
+
import NoOpEntityMetricsAdapter from '../../metrics/NoOpEntityMetricsAdapter';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Entity companion provider for use in unit tests. All database and cache implementations
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* A cache adapter is an interface by which objects can be
|
|
5
|
-
* cached, fetched from cache, and removed from cache (invalidated).
|
|
6
|
-
*/
|
|
7
|
-
class EntityCacheAdapter {
|
|
8
|
-
constructor(entityConfiguration) {
|
|
9
|
-
this.entityConfiguration = entityConfiguration;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.default = EntityCacheAdapter;
|
|
13
|
-
//# sourceMappingURL=EntityCacheAdapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EntityCacheAdapter.js","sourceRoot":"","sources":["../src/EntityCacheAdapter.ts"],"names":[],"mappings":";;AAGA;;;GAGG;AACH,MAA8B,kBAAkB;IAC9C,YAA+B,mBAAiD;QAAjD,wBAAmB,GAAnB,mBAAmB,CAA8B;IAAG,CAAC;CA2CrF;AA5CD,qCA4CC"}
|