@expo/entity 0.25.3 → 0.27.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/LICENSE +21 -0
- package/build/ComposedEntityCacheAdapter.d.ts +4 -2
- package/build/ComposedEntityCacheAdapter.js +39 -3
- package/build/ComposedEntityCacheAdapter.js.map +1 -1
- package/build/ComposedSecondaryEntityCache.d.ts +3 -2
- package/build/ComposedSecondaryEntityCache.js +3 -2
- package/build/ComposedSecondaryEntityCache.js.map +1 -1
- package/build/EnforcingEntityLoader.d.ts +10 -10
- package/build/EnforcingEntityLoader.js +8 -8
- package/build/EnforcingEntityLoader.js.map +1 -1
- package/build/Entity.d.ts +5 -5
- package/build/Entity.js +9 -9
- package/build/Entity.js.map +1 -1
- package/build/EntityAssociationLoader.d.ts +9 -4
- package/build/EntityAssociationLoader.js +5 -0
- package/build/EntityAssociationLoader.js.map +1 -1
- package/build/EntityCacheAdapter.d.ts +1 -1
- package/build/EntityCompanion.d.ts +1 -1
- package/build/EntityCompanion.js +1 -1
- package/build/EntityCompanionProvider.d.ts +9 -9
- package/build/EntityCompanionProvider.js +3 -3
- package/build/EntityConfiguration.d.ts +2 -2
- package/build/EntityDatabaseAdapter.d.ts +15 -6
- package/build/EntityDatabaseAdapter.js +8 -2
- package/build/EntityDatabaseAdapter.js.map +1 -1
- package/build/EntityFieldDefinition.d.ts +16 -8
- package/build/EntityFieldDefinition.js +12 -5
- package/build/EntityFieldDefinition.js.map +1 -1
- package/build/EntityFields.d.ts +11 -11
- package/build/EntityFields.js +11 -11
- package/build/EntityLoader.d.ts +7 -7
- package/build/EntityLoader.js +7 -7
- package/build/EntityLoader.js.map +1 -1
- package/build/EntityMutationInfo.d.ts +2 -0
- package/build/EntityMutationTriggerConfiguration.d.ts +1 -1
- package/build/EntityMutationTriggerConfiguration.js +1 -1
- package/build/EntityMutator.d.ts +7 -9
- package/build/EntityMutator.js +59 -47
- package/build/EntityMutator.js.map +1 -1
- package/build/EntityMutatorFactory.d.ts +4 -4
- package/build/EntityMutatorFactory.js +6 -6
- package/build/EntityMutatorFactory.js.map +1 -1
- package/build/EntityPrivacyPolicy.d.ts +18 -5
- package/build/EntityPrivacyPolicy.js +18 -5
- package/build/EntityPrivacyPolicy.js.map +1 -1
- package/build/EntityQueryContext.d.ts +12 -1
- package/build/EntityQueryContext.js +12 -1
- package/build/EntityQueryContext.js.map +1 -1
- package/build/EntityQueryContextProvider.d.ts +1 -1
- package/build/EntitySecondaryCacheLoader.d.ts +1 -1
- package/build/EntitySecondaryCacheLoader.js +1 -1
- package/build/GenericSecondaryEntityCache.d.ts +1 -1
- package/build/GenericSecondaryEntityCache.js +1 -1
- package/build/ReadonlyEntity.d.ts +1 -1
- package/build/ReadonlyEntity.js +1 -1
- package/build/ViewerContext.d.ts +2 -2
- package/build/ViewerContext.js +2 -2
- package/build/ViewerScopedEntityCompanion.d.ts +2 -2
- package/build/ViewerScopedEntityCompanion.js +2 -2
- package/build/ViewerScopedEntityLoaderFactory.d.ts +1 -1
- package/build/ViewerScopedEntityLoaderFactory.js +1 -1
- package/build/ViewerScopedEntityMutatorFactory.d.ts +5 -5
- package/build/ViewerScopedEntityMutatorFactory.js +7 -7
- package/build/ViewerScopedEntityMutatorFactory.js.map +1 -1
- package/build/__tests__/ComposedCacheAdapter-test.js +37 -4
- package/build/__tests__/ComposedCacheAdapter-test.js.map +1 -1
- package/build/__tests__/EntityCommonUseCases-test.js +5 -1
- package/build/__tests__/EntityCommonUseCases-test.js.map +1 -1
- package/build/__tests__/EntityCompanion-test.js +5 -1
- package/build/__tests__/EntityCompanion-test.js.map +1 -1
- package/build/__tests__/EntityCompanionProvider-test.js +5 -1
- package/build/__tests__/EntityCompanionProvider-test.js.map +1 -1
- package/build/__tests__/EntityEdges-test.js +199 -33
- package/build/__tests__/EntityEdges-test.js.map +1 -1
- package/build/__tests__/EntityLoader-test.js +5 -1
- package/build/__tests__/EntityLoader-test.js.map +1 -1
- package/build/__tests__/EntityMutator-test.js +38 -53
- package/build/__tests__/EntityMutator-test.js.map +1 -1
- package/build/__tests__/EntityPrivacyPolicy-test.js +5 -1
- package/build/__tests__/EntityPrivacyPolicy-test.js.map +1 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.js +2 -2
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +1 -1
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js +5 -1
- package/build/__tests__/ViewerScopedEntityCompanionProvider-test.js.map +1 -1
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js +2 -3
- package/build/__tests__/ViewerScopedEntityMutatorFactory-test.js.map +1 -1
- package/build/errors/EntityCacheAdapterError.js +5 -1
- package/build/errors/EntityCacheAdapterError.js.map +1 -1
- package/build/errors/EntityDatabaseAdapterError.js +5 -1
- package/build/errors/EntityDatabaseAdapterError.js.map +1 -1
- package/build/errors/EntityInvalidFieldValueError.js +6 -2
- package/build/errors/EntityInvalidFieldValueError.js.map +1 -1
- package/build/errors/EntityNotAuthorizedError.js +5 -1
- package/build/errors/EntityNotAuthorizedError.js.map +1 -1
- package/build/errors/EntityNotFoundError.js +6 -2
- package/build/errors/EntityNotFoundError.js.map +1 -1
- package/build/index.js +5 -1
- package/build/index.js.map +1 -1
- package/build/internal/EntityDataManager.d.ts +5 -5
- package/build/internal/EntityDataManager.js +10 -7
- package/build/internal/EntityDataManager.js.map +1 -1
- package/build/internal/EntityFieldTransformationUtils.js +1 -1
- package/build/internal/EntityFieldTransformationUtils.js.map +1 -1
- package/build/internal/ReadThroughEntityCache.d.ts +2 -2
- package/build/internal/ReadThroughEntityCache.js +3 -3
- package/build/internal/ReadThroughEntityCache.js.map +1 -1
- package/build/internal/__tests__/EntityDataManager-test.js +12 -7
- package/build/internal/__tests__/EntityDataManager-test.js.map +1 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.js +5 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.js.map +1 -1
- package/build/metrics/IEntityMetricsAdapter.d.ts +63 -18
- package/build/metrics/IEntityMetricsAdapter.js +17 -1
- package/build/metrics/IEntityMetricsAdapter.js.map +1 -1
- package/build/metrics/NoOpEntityMetricsAdapter.d.ts +1 -3
- package/build/metrics/NoOpEntityMetricsAdapter.js +1 -3
- package/build/metrics/NoOpEntityMetricsAdapter.js.map +1 -1
- package/build/rules/AlwaysAllowPrivacyPolicyRule.js +5 -1
- package/build/rules/AlwaysAllowPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysDenyPrivacyPolicyRule.js +5 -1
- package/build/rules/AlwaysDenyPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysSkipPrivacyPolicyRule.js +5 -1
- 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/utils/collections/maps.d.ts +1 -1
- package/build/utils/collections/maps.js +1 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.d.ts +1 -2
- package/build/utils/testing/StubDatabaseAdapter.js +6 -2
- package/build/utils/testing/StubDatabaseAdapter.js.map +1 -1
- package/build/utils/testing/StubQueryContextProvider.d.ts +1 -1
- package/build/utils/testing/StubQueryContextProvider.js +2 -0
- package/build/utils/testing/StubQueryContextProvider.js.map +1 -1
- package/package.json +3 -2
- package/src/ComposedEntityCacheAdapter.ts +44 -3
- package/src/ComposedSecondaryEntityCache.ts +3 -2
- package/src/EnforcingEntityLoader.ts +14 -10
- package/src/Entity.ts +9 -9
- package/src/EntityAssociationLoader.ts +9 -4
- package/src/EntityCacheAdapter.ts +1 -1
- package/src/EntityCompanion.ts +1 -1
- package/src/EntityCompanionProvider.ts +9 -9
- package/src/EntityConfiguration.ts +2 -2
- package/src/EntityDatabaseAdapter.ts +33 -6
- package/src/EntityFieldDefinition.ts +15 -6
- package/src/EntityFields.ts +11 -11
- package/src/EntityLoader.ts +11 -8
- package/src/EntityMutationInfo.ts +2 -0
- package/src/EntityMutationTriggerConfiguration.ts +1 -1
- package/src/EntityMutator.ts +99 -68
- package/src/EntityMutatorFactory.ts +4 -10
- package/src/EntityPrivacyPolicy.ts +20 -5
- package/src/EntityQueryContext.ts +12 -1
- package/src/EntityQueryContextProvider.ts +1 -1
- package/src/EntitySecondaryCacheLoader.ts +1 -1
- package/src/GenericSecondaryEntityCache.ts +1 -1
- package/src/ReadonlyEntity.ts +1 -1
- package/src/ViewerContext.ts +2 -2
- package/src/ViewerScopedEntityCompanion.ts +2 -2
- package/src/ViewerScopedEntityLoaderFactory.ts +1 -1
- package/src/ViewerScopedEntityMutatorFactory.ts +8 -23
- package/src/__tests__/ComposedCacheAdapter-test.ts +43 -4
- package/src/__tests__/EntityEdges-test.ts +287 -32
- package/src/__tests__/EntityMutator-test.ts +33 -54
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +2 -2
- package/src/__tests__/ViewerScopedEntityMutatorFactory-test.ts +2 -6
- package/src/errors/EntityInvalidFieldValueError.ts +1 -1
- package/src/errors/EntityNotFoundError.ts +1 -1
- package/src/internal/EntityDataManager.ts +18 -9
- package/src/internal/EntityFieldTransformationUtils.ts +1 -1
- package/src/internal/ReadThroughEntityCache.ts +5 -3
- package/src/internal/__tests__/EntityDataManager-test.ts +11 -8
- package/src/metrics/IEntityMetricsAdapter.ts +73 -20
- package/src/metrics/NoOpEntityMetricsAdapter.ts +1 -5
- package/src/rules/PrivacyPolicyRule.ts +1 -1
- package/src/utils/collections/maps.ts +1 -1
- package/src/utils/testing/PrivacyPolicyRuleTestUtils.ts +1 -1
- package/src/utils/testing/StubDatabaseAdapter.ts +4 -1
- package/src/utils/testing/StubQueryContextProvider.ts +1 -1
|
@@ -4,10 +4,25 @@ export declare enum EntityMetricsLoadType {
|
|
|
4
4
|
LOAD_MANY_EQUALITY_CONJUNCTION = 1,
|
|
5
5
|
LOAD_MANY_RAW = 2
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Event about a single call to an EntityLoader method.
|
|
9
|
+
*/
|
|
7
10
|
export interface EntityMetricsLoadEvent {
|
|
11
|
+
/**
|
|
12
|
+
* EntityMetricsLoadType for this load.
|
|
13
|
+
*/
|
|
8
14
|
type: EntityMetricsLoadType;
|
|
15
|
+
/**
|
|
16
|
+
* Class name of the Entity being loaded.
|
|
17
|
+
*/
|
|
9
18
|
entityClassName: string;
|
|
19
|
+
/**
|
|
20
|
+
* Total duration of this load, including fetch and construction of entities.
|
|
21
|
+
*/
|
|
10
22
|
duration: number;
|
|
23
|
+
/**
|
|
24
|
+
* Number of entities returned for this load.
|
|
25
|
+
*/
|
|
11
26
|
count: number;
|
|
12
27
|
}
|
|
13
28
|
export declare enum EntityMetricsMutationType {
|
|
@@ -16,19 +31,62 @@ export declare enum EntityMetricsMutationType {
|
|
|
16
31
|
DELETE = 2
|
|
17
32
|
}
|
|
18
33
|
export interface EntityMetricsMutationEvent {
|
|
34
|
+
/**
|
|
35
|
+
* EntityMetricsMutationType for this mutation.
|
|
36
|
+
*/
|
|
19
37
|
type: EntityMetricsMutationType;
|
|
38
|
+
/**
|
|
39
|
+
* Class name of the Entity being mutated.
|
|
40
|
+
*/
|
|
20
41
|
entityClassName: string;
|
|
42
|
+
/**
|
|
43
|
+
* Total duration of this mutation.
|
|
44
|
+
*/
|
|
21
45
|
duration: number;
|
|
22
46
|
}
|
|
47
|
+
export declare enum IncrementLoadCountEventType {
|
|
48
|
+
/**
|
|
49
|
+
* Type for when a dataloader load is initiated via the standard load methods
|
|
50
|
+
* since all loads go through a dataloader.
|
|
51
|
+
*/
|
|
52
|
+
DATALOADER = 0,
|
|
53
|
+
/**
|
|
54
|
+
* Type for when a cache load is initiated due to a dataloader miss.
|
|
55
|
+
*/
|
|
56
|
+
CACHE = 1,
|
|
57
|
+
/**
|
|
58
|
+
* Type for when a database load is initiated due to a dataloader and cache miss, when an entity query doesn't support caching, or during a transaction.
|
|
59
|
+
*/
|
|
60
|
+
DATABASE = 2
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Event used to record dataloader, cache, and database load counts in EntityDataManager.
|
|
64
|
+
*/
|
|
23
65
|
export interface IncrementLoadCountEvent {
|
|
66
|
+
/**
|
|
67
|
+
* Type of this event.
|
|
68
|
+
*/
|
|
69
|
+
type: IncrementLoadCountEventType;
|
|
70
|
+
/**
|
|
71
|
+
* Number of field values being loaded for this call.
|
|
72
|
+
*/
|
|
24
73
|
fieldValueCount: number;
|
|
74
|
+
/**
|
|
75
|
+
* Class name of the Entity being loaded.
|
|
76
|
+
*/
|
|
25
77
|
entityClassName: string;
|
|
26
78
|
}
|
|
27
79
|
export declare enum EntityMetricsAuthorizationResult {
|
|
28
80
|
DENY = 0,
|
|
29
81
|
ALLOW = 1
|
|
30
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Event used to record a singe EntityPrivacyPolicy authorization.
|
|
85
|
+
*/
|
|
31
86
|
export interface EntityMetricsAuthorizationEvent {
|
|
87
|
+
/**
|
|
88
|
+
* Class name of the Entity being authorized.
|
|
89
|
+
*/
|
|
32
90
|
entityClassName: string;
|
|
33
91
|
action: EntityAuthorizationAction;
|
|
34
92
|
evaluationResult: EntityMetricsAuthorizationResult;
|
|
@@ -40,7 +98,7 @@ export interface EntityMetricsAuthorizationEvent {
|
|
|
40
98
|
*/
|
|
41
99
|
export default interface IEntityMetricsAdapter {
|
|
42
100
|
/**
|
|
43
|
-
* Called when a
|
|
101
|
+
* Called when a EntityPrivacyPolicy authorization succeeds or fails.
|
|
44
102
|
* @param authorizationEvent - info about the authorization event
|
|
45
103
|
*/
|
|
46
104
|
logAuthorizationEvent(authorizationEvent: EntityMetricsAuthorizationEvent): void;
|
|
@@ -55,23 +113,10 @@ export default interface IEntityMetricsAdapter {
|
|
|
55
113
|
*/
|
|
56
114
|
logMutatorMutationEvent(mutationEvent: EntityMetricsMutationEvent): void;
|
|
57
115
|
/**
|
|
58
|
-
* Called when a dataloader load is initiated via the standard
|
|
59
|
-
* load methods (not equality conjunction or raw).
|
|
60
|
-
*
|
|
61
|
-
*/
|
|
62
|
-
incrementDataManagerDataloaderLoadCount(incrementLoadCountEvent: IncrementLoadCountEvent): void;
|
|
63
|
-
/**
|
|
64
|
-
* Called when a cache load is initiated via the standard
|
|
65
|
-
* load methods (not equality conjunction or raw). Occurs upon a dataloader
|
|
66
|
-
* miss.
|
|
67
|
-
* @param fieldValueCount - count of field values being loaded for a field
|
|
68
|
-
*/
|
|
69
|
-
incrementDataManagerCacheLoadCount(incrementLoadCountEvent: IncrementLoadCountEvent): void;
|
|
70
|
-
/**
|
|
71
|
-
* Called when a database load is initiated via the standard
|
|
72
|
-
* load methods (not equality conjunction or raw). Occurs upon a cache
|
|
73
|
-
* miss or when fetching an uncacheable field.
|
|
116
|
+
* Called when a dataloader, cache, or database load is initiated via the standard
|
|
117
|
+
* load methods (not equality conjunction or raw). Most commonly used for logging
|
|
118
|
+
* a waterfall to determine dataloader and cache hit rates and ratios.
|
|
74
119
|
* @param fieldValueCount - count of field values being loaded for a field
|
|
75
120
|
*/
|
|
76
|
-
|
|
121
|
+
incrementDataManagerLoadCount(incrementLoadCountEvent: IncrementLoadCountEvent): void;
|
|
77
122
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntityMetricsAuthorizationResult = exports.EntityMetricsMutationType = exports.EntityMetricsLoadType = void 0;
|
|
3
|
+
exports.EntityMetricsAuthorizationResult = exports.IncrementLoadCountEventType = exports.EntityMetricsMutationType = exports.EntityMetricsLoadType = void 0;
|
|
4
4
|
var EntityMetricsLoadType;
|
|
5
5
|
(function (EntityMetricsLoadType) {
|
|
6
6
|
EntityMetricsLoadType[EntityMetricsLoadType["LOAD_MANY"] = 0] = "LOAD_MANY";
|
|
@@ -13,6 +13,22 @@ var EntityMetricsMutationType;
|
|
|
13
13
|
EntityMetricsMutationType[EntityMetricsMutationType["UPDATE"] = 1] = "UPDATE";
|
|
14
14
|
EntityMetricsMutationType[EntityMetricsMutationType["DELETE"] = 2] = "DELETE";
|
|
15
15
|
})(EntityMetricsMutationType = exports.EntityMetricsMutationType || (exports.EntityMetricsMutationType = {}));
|
|
16
|
+
var IncrementLoadCountEventType;
|
|
17
|
+
(function (IncrementLoadCountEventType) {
|
|
18
|
+
/**
|
|
19
|
+
* Type for when a dataloader load is initiated via the standard load methods
|
|
20
|
+
* since all loads go through a dataloader.
|
|
21
|
+
*/
|
|
22
|
+
IncrementLoadCountEventType[IncrementLoadCountEventType["DATALOADER"] = 0] = "DATALOADER";
|
|
23
|
+
/**
|
|
24
|
+
* Type for when a cache load is initiated due to a dataloader miss.
|
|
25
|
+
*/
|
|
26
|
+
IncrementLoadCountEventType[IncrementLoadCountEventType["CACHE"] = 1] = "CACHE";
|
|
27
|
+
/**
|
|
28
|
+
* Type for when a database load is initiated due to a dataloader and cache miss, when an entity query doesn't support caching, or during a transaction.
|
|
29
|
+
*/
|
|
30
|
+
IncrementLoadCountEventType[IncrementLoadCountEventType["DATABASE"] = 2] = "DATABASE";
|
|
31
|
+
})(IncrementLoadCountEventType = exports.IncrementLoadCountEventType || (exports.IncrementLoadCountEventType = {}));
|
|
16
32
|
var EntityMetricsAuthorizationResult;
|
|
17
33
|
(function (EntityMetricsAuthorizationResult) {
|
|
18
34
|
EntityMetricsAuthorizationResult[EntityMetricsAuthorizationResult["DENY"] = 0] = "DENY";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IEntityMetricsAdapter.js","sourceRoot":"","sources":["../../src/metrics/IEntityMetricsAdapter.ts"],"names":[],"mappings":";;;AAKA,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,2EAAS,CAAA;IACT,qHAA8B,CAAA;IAC9B,mFAAa,CAAA;AACf,CAAC,EAJW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAIhC;
|
|
1
|
+
{"version":3,"file":"IEntityMetricsAdapter.js","sourceRoot":"","sources":["../../src/metrics/IEntityMetricsAdapter.ts"],"names":[],"mappings":";;;AAKA,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,2EAAS,CAAA;IACT,qHAA8B,CAAA;IAC9B,mFAAa,CAAA;AACf,CAAC,EAJW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAIhC;AA2BD,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACnC,6EAAM,CAAA;IACN,6EAAM,CAAA;IACN,6EAAM,CAAA;AACR,CAAC,EAJW,yBAAyB,GAAzB,iCAAyB,KAAzB,iCAAyB,QAIpC;AAmBD,IAAY,2BAgBX;AAhBD,WAAY,2BAA2B;IACrC;;;OAGG;IACH,yFAAU,CAAA;IAEV;;OAEG;IACH,+EAAK,CAAA;IAEL;;OAEG;IACH,qFAAQ,CAAA;AACV,CAAC,EAhBW,2BAA2B,GAA3B,mCAA2B,KAA3B,mCAA2B,QAgBtC;AAsBD,IAAY,gCAGX;AAHD,WAAY,gCAAgC;IAC1C,uFAAI,CAAA;IACJ,yFAAK,CAAA;AACP,CAAC,EAHW,gCAAgC,GAAhC,wCAAgC,KAAhC,wCAAgC,QAG3C"}
|
|
@@ -3,7 +3,5 @@ export default class NoOpEntityMetricsAdapter implements IEntityMetricsAdapter {
|
|
|
3
3
|
logAuthorizationEvent(_authorizationEvent: EntityMetricsAuthorizationEvent): void;
|
|
4
4
|
logDataManagerLoadEvent(_loadEvent: EntityMetricsLoadEvent): void;
|
|
5
5
|
logMutatorMutationEvent(_mutationEvent: EntityMetricsMutationEvent): void;
|
|
6
|
-
|
|
7
|
-
incrementDataManagerCacheLoadCount(_incrementLoadCountEvent: IncrementLoadCountEvent): void;
|
|
8
|
-
incrementDataManagerDatabaseLoadCount(_incrementLoadCountEvent: IncrementLoadCountEvent): void;
|
|
6
|
+
incrementDataManagerLoadCount(_incrementLoadCountEvent: IncrementLoadCountEvent): void;
|
|
9
7
|
}
|
|
@@ -4,9 +4,7 @@ class NoOpEntityMetricsAdapter {
|
|
|
4
4
|
logAuthorizationEvent(_authorizationEvent) { }
|
|
5
5
|
logDataManagerLoadEvent(_loadEvent) { }
|
|
6
6
|
logMutatorMutationEvent(_mutationEvent) { }
|
|
7
|
-
|
|
8
|
-
incrementDataManagerCacheLoadCount(_incrementLoadCountEvent) { }
|
|
9
|
-
incrementDataManagerDatabaseLoadCount(_incrementLoadCountEvent) { }
|
|
7
|
+
incrementDataManagerLoadCount(_incrementLoadCountEvent) { }
|
|
10
8
|
}
|
|
11
9
|
exports.default = NoOpEntityMetricsAdapter;
|
|
12
10
|
//# sourceMappingURL=NoOpEntityMetricsAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoOpEntityMetricsAdapter.js","sourceRoot":"","sources":["../../src/metrics/NoOpEntityMetricsAdapter.ts"],"names":[],"mappings":";;AAOA,MAAqB,wBAAwB;IAC3C,qBAAqB,CAAC,mBAAoD,IAAS,CAAC;IACpF,uBAAuB,CAAC,UAAkC,IAAS,CAAC;IACpE,uBAAuB,CAAC,cAA0C,IAAS,CAAC;IAC5E,
|
|
1
|
+
{"version":3,"file":"NoOpEntityMetricsAdapter.js","sourceRoot":"","sources":["../../src/metrics/NoOpEntityMetricsAdapter.ts"],"names":[],"mappings":";;AAOA,MAAqB,wBAAwB;IAC3C,qBAAqB,CAAC,mBAAoD,IAAS,CAAC;IACpF,uBAAuB,CAAC,UAAkC,IAAS,CAAC;IACpE,uBAAuB,CAAC,cAA0C,IAAS,CAAC;IAC5E,6BAA6B,CAAC,wBAAiD,IAAS,CAAC;CAC1F;AALD,2CAKC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlwaysAllowPrivacyPolicyRule.js","sourceRoot":"","sources":["../../src/rules/AlwaysAllowPrivacyPolicyRule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AlwaysAllowPrivacyPolicyRule.js","sourceRoot":"","sources":["../../src/rules/AlwaysAllowPrivacyPolicyRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yEAA8E;AAE9E;;GAEG;AACH,MAAqB,4BAMnB,SAAQ,2BAAyE;IACjF,KAAK,CAAC,aAAa,CACjB,cAA8B,EAC9B,aAAiC,EACjC,kBAAwD,EACxD,OAAgB;QAEhB,OAAO,wCAAoB,CAAC,KAAK,CAAC;IACpC,CAAC;CACF;AAfD,+CAeC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlwaysDenyPrivacyPolicyRule.js","sourceRoot":"","sources":["../../src/rules/AlwaysDenyPrivacyPolicyRule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AlwaysDenyPrivacyPolicyRule.js","sourceRoot":"","sources":["../../src/rules/AlwaysDenyPrivacyPolicyRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yEAA8E;AAE9E;;GAEG;AACH,MAAqB,2BAMnB,SAAQ,2BAAyE;IACjF,KAAK,CAAC,aAAa,CACjB,cAA8B,EAC9B,aAAiC,EACjC,kBAAwD,EACxD,OAAgB;QAEhB,OAAO,wCAAoB,CAAC,IAAI,CAAC;IACnC,CAAC;CACF;AAfD,8CAeC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlwaysSkipPrivacyPolicyRule.js","sourceRoot":"","sources":["../../src/rules/AlwaysSkipPrivacyPolicyRule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AlwaysSkipPrivacyPolicyRule.js","sourceRoot":"","sources":["../../src/rules/AlwaysSkipPrivacyPolicyRule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yEAA8E;AAE9E;;GAEG;AACH,MAAqB,2BAMnB,SAAQ,2BAAyE;IACjF,KAAK,CAAC,aAAa,CACjB,cAA8B,EAC9B,aAAiC,EACjC,kBAAwD,EACxD,OAAgB;QAEhB,OAAO,wCAAoB,CAAC,IAAI,CAAC;IACnC,CAAC;CACF;AAfD,8CAeC"}
|
|
@@ -28,7 +28,7 @@ export declare enum RuleEvaluationResult {
|
|
|
28
28
|
* rule in the privacy policy. If all rules in the policy SKIP, the policy is denied.
|
|
29
29
|
*
|
|
30
30
|
* Returning DENY from a rule is useful in a few notable cases:
|
|
31
|
-
* - Preventing a CRUD action on an entity (
|
|
31
|
+
* - Preventing a CRUD action on an entity (AlwaysDenyPrivacyPolicyRule)
|
|
32
32
|
* - Blocking. For example, a user blocks another user from seeing their posts, and the rule
|
|
33
33
|
* would be named something like `DenyIfViewerHasBeenBlockedPrivacyPolicyRule`.
|
|
34
34
|
*/
|
|
@@ -28,7 +28,7 @@ var RuleEvaluationResult;
|
|
|
28
28
|
* rule in the privacy policy. If all rules in the policy SKIP, the policy is denied.
|
|
29
29
|
*
|
|
30
30
|
* Returning DENY from a rule is useful in a few notable cases:
|
|
31
|
-
* - Preventing a CRUD action on an entity (
|
|
31
|
+
* - Preventing a CRUD action on an entity (AlwaysDenyPrivacyPolicyRule)
|
|
32
32
|
* - Blocking. For example, a user blocks another user from seeing their posts, and the rule
|
|
33
33
|
* would be named something like `DenyIfViewerHasBeenBlockedPrivacyPolicyRule`.
|
|
34
34
|
*/
|
|
@@ -23,7 +23,7 @@ export declare const mapMap: <K, V, M>(map: ReadonlyMap<K, V>, mapper: (value: V
|
|
|
23
23
|
export declare const mapMapAsync: <K, V, M>(map: ReadonlyMap<K, V>, mapper: (value: V, key: K) => Promise<M>) => Promise<Map<K, M>>;
|
|
24
24
|
/**
|
|
25
25
|
* Create a new Map by associating the value of each key with mapper executed for each key in the source map.
|
|
26
|
-
* The opposite of
|
|
26
|
+
* The opposite of mapMap. In the event two source keys map to the same result key, the second source key's
|
|
27
27
|
* value will overwrite the first, in which case the cardinality of the returned map may be smaller than the
|
|
28
28
|
* source map's.
|
|
29
29
|
*
|
|
@@ -53,7 +53,7 @@ const mapMapAsync = async function (map, mapper) {
|
|
|
53
53
|
exports.mapMapAsync = mapMapAsync;
|
|
54
54
|
/**
|
|
55
55
|
* Create a new Map by associating the value of each key with mapper executed for each key in the source map.
|
|
56
|
-
* The opposite of
|
|
56
|
+
* The opposite of mapMap. In the event two source keys map to the same result key, the second source key's
|
|
57
57
|
* value will overwrite the first, in which case the cardinality of the returned map may be smaller than the
|
|
58
58
|
* source map's.
|
|
59
59
|
*
|
|
@@ -9,7 +9,7 @@ export interface Case<TFields, TID extends NonNullable<TFields[TSelectedFields]>
|
|
|
9
9
|
evaluationContext: EntityPrivacyPolicyEvaluationContext;
|
|
10
10
|
entity: TEntity;
|
|
11
11
|
}
|
|
12
|
-
declare type CaseMap<TFields, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TSelectedFields extends keyof TFields> = Map<string, () => Promise<Case<TFields, TID, TViewerContext, TEntity, TSelectedFields>>>;
|
|
12
|
+
export declare type CaseMap<TFields, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TSelectedFields extends keyof TFields> = Map<string, () => Promise<Case<TFields, TID, TViewerContext, TEntity, TSelectedFields>>>;
|
|
13
13
|
/**
|
|
14
14
|
* Useful for defining test cases that have async preconditions.
|
|
15
15
|
*/
|
|
@@ -26,4 +26,3 @@ export declare const describePrivacyPolicyRule: <TFields, TID extends NonNullabl
|
|
|
26
26
|
skipCases?: Case<TFields, TID, TViewerContext, TEntity, TSelectedFields>[];
|
|
27
27
|
denyCases?: Case<TFields, TID, TViewerContext, TEntity, TSelectedFields>[];
|
|
28
28
|
}) => void;
|
|
29
|
-
export {};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -122,7 +126,7 @@ class StubDatabaseAdapter extends EntityDatabaseAdapter_1.default {
|
|
|
122
126
|
}
|
|
123
127
|
generateRandomID() {
|
|
124
128
|
const idSchemaField = this.entityConfiguration2.schema.get(this.entityConfiguration2.idField);
|
|
125
|
-
(0, invariant_1.default)(idSchemaField, `No schema field found for ${this.entityConfiguration2.idField}`);
|
|
129
|
+
(0, invariant_1.default)(idSchemaField, `No schema field found for ${String(this.entityConfiguration2.idField)}`);
|
|
126
130
|
if (idSchemaField instanceof EntityFields_1.StringField) {
|
|
127
131
|
return (0, uuid_1.v4)();
|
|
128
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StubDatabaseAdapter.js","sourceRoot":"","sources":["../../../src/utils/testing/StubDatabaseAdapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StubDatabaseAdapter.js","sourceRoot":"","sources":["../../../src/utils/testing/StubDatabaseAdapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAkC;AAClC,+BAAoC;AAGpC,qFAKqC;AACrC,qDAA2D;AAC3D,kGAIuD;AACvD,8CAA8D;AAE9D,MAAqB,mBAAuB,SAAQ,+BAAwB;IAC1E,YACmB,oBAA4C,EAC5C,SAA0D;QAE3E,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAHX,yBAAoB,GAApB,oBAAoB,CAAwB;QAC5C,cAAS,GAAT,SAA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MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;YACpC,MAAM,IAAI,KAAK,CAAC,iBAAiB,YAAY,MAAM,EAAE,GAAG,CAAC,CAAC;SAC3D;QAED,MAAM,gBAAgB,GAAG,IAAI,CAAC,2BAA2B,CAAC,SAAS,CAAC,CAAC;QAErE,MAAM,WAAW,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;YACrD,OAAO,GAAG,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,IAAA,mBAAS,EAAC,WAAW,IAAI,CAAC,EAAE,cAAc,CAAC,CAAC;QAC5C,gBAAgB,CAAC,WAAW,CAAC,GAAG;YAC9B,GAAG,gBAAgB,CAAC,WAAW,CAAC;YAChC,GAAG,MAAM;SACV,CAAC;QACF,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAE,CAAC,CAAC;IAC1C,CAAC;IAES,KAAK,CAAC,mBAAmB,CACjC,eAAoB,EACpB,SAAiB,EACjB,YAAoB,EACpB,EAAO;QAEP,MAAM,gBAAgB,GAAG,IAAI,CAAC,2BAA2B,CAAC,SAAS,CAAC,CAAC;QAErE,MAAM,WAAW,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;YACrD,OAAO,GAAG,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,IAAI,WAAW,GAAG,CAAC,EAAE;YACnB,OAAO,CAAC,CAAC;SACV;QACD,gBAAgB,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QACxC,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AA1ND,sCA0NC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import EntityQueryContextProvider from '../../EntityQueryContextProvider';
|
|
2
|
-
declare class StubQueryContextProvider extends EntityQueryContextProvider {
|
|
2
|
+
export declare class StubQueryContextProvider extends EntityQueryContextProvider {
|
|
3
3
|
protected getQueryInterface(): any;
|
|
4
4
|
protected createTransactionRunner<T>(): (transactionScope: (queryInterface: any) => Promise<T>) => Promise<T>;
|
|
5
5
|
}
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StubQueryContextProvider = void 0;
|
|
6
7
|
const EntityQueryContextProvider_1 = __importDefault(require("../../EntityQueryContextProvider"));
|
|
7
8
|
class StubQueryContextProvider extends EntityQueryContextProvider_1.default {
|
|
8
9
|
getQueryInterface() {
|
|
@@ -12,5 +13,6 @@ class StubQueryContextProvider extends EntityQueryContextProvider_1.default {
|
|
|
12
13
|
return (transactionScope) => Promise.resolve(transactionScope({}));
|
|
13
14
|
}
|
|
14
15
|
}
|
|
16
|
+
exports.StubQueryContextProvider = StubQueryContextProvider;
|
|
15
17
|
exports.default = new StubQueryContextProvider();
|
|
16
18
|
//# sourceMappingURL=StubQueryContextProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StubQueryContextProvider.js","sourceRoot":"","sources":["../../../src/utils/testing/StubQueryContextProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StubQueryContextProvider.js","sourceRoot":"","sources":["../../../src/utils/testing/StubQueryContextProvider.ts"],"names":[],"mappings":";;;;;;AAAA,kGAA0E;AAE1E,MAAa,wBAAyB,SAAQ,oCAA0B;IAC5D,iBAAiB;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAES,uBAAuB;QAG/B,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC;IACrE,CAAC;CACF;AAVD,4DAUC;AAED,kBAAe,IAAI,wBAAwB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/entity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "A privacy-first data model",
|
|
5
5
|
"files": [
|
|
6
6
|
"build",
|
|
@@ -32,5 +32,6 @@
|
|
|
32
32
|
"es6-error": "^4.1.1",
|
|
33
33
|
"invariant": "^2.2.4",
|
|
34
34
|
"uuid": "^8.3.0"
|
|
35
|
-
}
|
|
35
|
+
},
|
|
36
|
+
"gitHead": "813e72bd53291ad6087fbcd0782946d6b125347d"
|
|
36
37
|
}
|
|
@@ -4,14 +4,16 @@ import EntityCacheAdapter from './EntityCacheAdapter';
|
|
|
4
4
|
import EntityConfiguration from './EntityConfiguration';
|
|
5
5
|
import { CacheStatus, CacheLoadResult } from './internal/ReadThroughEntityCache';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A EntityCacheAdapter that composes other EntityCacheAdapter instances.
|
|
9
|
+
*/
|
|
7
10
|
export default class ComposedEntityCacheAdapter<TFields> extends EntityCacheAdapter<TFields> {
|
|
8
11
|
/**
|
|
9
|
-
* A {@link EntityCacheAdapter} that composes other {@link EntityCacheAdapter} instances.
|
|
10
|
-
*
|
|
11
12
|
* @param entityConfiguration - configuration for entity being loaded
|
|
12
13
|
* @param cacheAdapters - list of cache adapters to compose in order of precedence.
|
|
13
14
|
* Earlier cache adapters are read from first and written to (including invalidations) last.
|
|
14
15
|
* Typically, caches closer to the application should be ordered before caches closer to the database.
|
|
16
|
+
* A lower layer cache is closer to the database, while a higher layer cache is closer to the application.
|
|
15
17
|
*/
|
|
16
18
|
constructor(
|
|
17
19
|
entityConfiguration: EntityConfiguration<TFields>,
|
|
@@ -25,9 +27,14 @@ export default class ComposedEntityCacheAdapter<TFields> extends EntityCacheAdap
|
|
|
25
27
|
fieldValues: readonly NonNullable<TFields[N]>[]
|
|
26
28
|
): Promise<ReadonlyMap<NonNullable<TFields[N]>, CacheLoadResult<TFields>>> {
|
|
27
29
|
const retMap = new Map<NonNullable<TFields[N]>, CacheLoadResult<TFields>>();
|
|
30
|
+
const fulfilledFieldValuesByCacheIndex: NonNullable<TFields[N]>[][] = Array.from(
|
|
31
|
+
{ length: this.cacheAdapters.length },
|
|
32
|
+
() => []
|
|
33
|
+
);
|
|
28
34
|
|
|
29
35
|
let unfulfilledFieldValues = fieldValues;
|
|
30
|
-
for (
|
|
36
|
+
for (let i = 0; i < this.cacheAdapters.length; i++) {
|
|
37
|
+
const cacheAdapter = nullthrows(this.cacheAdapters[i]);
|
|
31
38
|
const cacheResultsFromAdapter = await cacheAdapter.loadManyAsync(
|
|
32
39
|
fieldName,
|
|
33
40
|
unfulfilledFieldValues
|
|
@@ -39,9 +46,43 @@ export default class ComposedEntityCacheAdapter<TFields> extends EntityCacheAdap
|
|
|
39
46
|
newUnfulfilledFieldValues.push(fieldValue);
|
|
40
47
|
} else {
|
|
41
48
|
retMap.set(fieldValue, cacheResult);
|
|
49
|
+
nullthrows(fulfilledFieldValuesByCacheIndex[i]).push(fieldValue);
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
unfulfilledFieldValues = newUnfulfilledFieldValues;
|
|
53
|
+
if (unfulfilledFieldValues.length === 0) {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Recache values from lower layers that were not found in higher layers
|
|
59
|
+
// Write to lower layers first
|
|
60
|
+
for (let i = this.cacheAdapters.length - 1; i >= 0; i--) {
|
|
61
|
+
const cacheAdapter = nullthrows(this.cacheAdapters[i]);
|
|
62
|
+
const hitsToCache = new Map<NonNullable<TFields[N]>, Readonly<TFields>>();
|
|
63
|
+
const negativesToCache: NonNullable<TFields[N]>[] = [];
|
|
64
|
+
|
|
65
|
+
// Loop over all lower layer caches to collect hits and misses
|
|
66
|
+
for (let j = i + 1; j < this.cacheAdapters.length; j++) {
|
|
67
|
+
const fulfilledFieldValues = nullthrows(fulfilledFieldValuesByCacheIndex[j]);
|
|
68
|
+
fulfilledFieldValues.forEach((fieldValue) => {
|
|
69
|
+
const cacheResult = nullthrows(retMap.get(fieldValue));
|
|
70
|
+
if (cacheResult.status === CacheStatus.HIT) {
|
|
71
|
+
hitsToCache.set(fieldValue, cacheResult.item);
|
|
72
|
+
} else if (cacheResult.status === CacheStatus.NEGATIVE) {
|
|
73
|
+
negativesToCache.push(fieldValue);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const promises = [];
|
|
79
|
+
if (hitsToCache.size > 0) {
|
|
80
|
+
promises.push(cacheAdapter.cacheManyAsync(fieldName, hitsToCache));
|
|
81
|
+
}
|
|
82
|
+
if (negativesToCache.length > 0) {
|
|
83
|
+
promises.push(cacheAdapter.cacheDBMissesAsync(fieldName, negativesToCache));
|
|
84
|
+
}
|
|
85
|
+
await Promise.all(promises);
|
|
45
86
|
}
|
|
46
87
|
|
|
47
88
|
for (const fieldValue of unfulfilledFieldValues) {
|
|
@@ -2,12 +2,13 @@ import nullthrows from 'nullthrows';
|
|
|
2
2
|
|
|
3
3
|
import { ISecondaryEntityCache } from './EntitySecondaryCacheLoader';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A ISecondaryEntityCache that composes other ISecondaryEntityCache instances.
|
|
7
|
+
*/
|
|
5
8
|
export default class ComposedSecondaryEntityCache<TLoadParams, TFields>
|
|
6
9
|
implements ISecondaryEntityCache<TFields, TLoadParams>
|
|
7
10
|
{
|
|
8
11
|
/**
|
|
9
|
-
* A {@link ISecondaryEntityCache} that composes other {@link ISecondaryEntityCache} instances.
|
|
10
|
-
*
|
|
11
12
|
* @param secondaryEntityCaches - list of caches to compose in order of precedence.
|
|
12
13
|
* Earlier caches are read from first and written to (including invalidations) last.
|
|
13
14
|
* Typically, caches closer to the application should be ordered before caches closer to the database.
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FieldEqualityCondition,
|
|
3
|
+
QuerySelectionModifiers,
|
|
4
|
+
QuerySelectionModifiersWithOrderByRaw,
|
|
5
|
+
} from './EntityDatabaseAdapter';
|
|
2
6
|
import EntityLoader from './EntityLoader';
|
|
3
7
|
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
4
8
|
import ReadonlyEntity from './ReadonlyEntity';
|
|
@@ -36,7 +40,7 @@ export default class EnforcingEntityLoader<
|
|
|
36
40
|
|
|
37
41
|
/**
|
|
38
42
|
* Enforcing version of entity loader method by the same name.
|
|
39
|
-
* @throws
|
|
43
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
40
44
|
*/
|
|
41
45
|
async loadManyByFieldEqualingManyAsync<N extends keyof Pick<TFields, TSelectedFields>>(
|
|
42
46
|
fieldName: N,
|
|
@@ -53,7 +57,7 @@ export default class EnforcingEntityLoader<
|
|
|
53
57
|
|
|
54
58
|
/**
|
|
55
59
|
* Enforcing version of entity loader method by the same name.
|
|
56
|
-
* @throws
|
|
60
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
57
61
|
*/
|
|
58
62
|
async loadManyByFieldEqualingAsync<N extends keyof Pick<TFields, TSelectedFields>>(
|
|
59
63
|
fieldName: N,
|
|
@@ -68,7 +72,7 @@ export default class EnforcingEntityLoader<
|
|
|
68
72
|
|
|
69
73
|
/**
|
|
70
74
|
* Enforcing version of entity loader method by the same name.
|
|
71
|
-
* @throws
|
|
75
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
72
76
|
* @throws when multiple entities are found matching the condition
|
|
73
77
|
*/
|
|
74
78
|
async loadByFieldEqualingAsync<N extends keyof Pick<TFields, TSelectedFields>>(
|
|
@@ -84,7 +88,7 @@ export default class EnforcingEntityLoader<
|
|
|
84
88
|
|
|
85
89
|
/**
|
|
86
90
|
* Enforcing version of entity loader method by the same name.
|
|
87
|
-
* @throws
|
|
91
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
88
92
|
*/
|
|
89
93
|
async loadByIDAsync(id: TID): Promise<TEntity> {
|
|
90
94
|
const entityResult = await this.entityLoader.loadByIDAsync(id);
|
|
@@ -93,7 +97,7 @@ export default class EnforcingEntityLoader<
|
|
|
93
97
|
|
|
94
98
|
/**
|
|
95
99
|
* Enforcing version of entity loader method by the same name.
|
|
96
|
-
* @throws
|
|
100
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view the returned entity
|
|
97
101
|
* @throws when multiple entities are found matching the condition
|
|
98
102
|
*/
|
|
99
103
|
async loadByIDNullableAsync(id: TID): Promise<TEntity | null> {
|
|
@@ -103,7 +107,7 @@ export default class EnforcingEntityLoader<
|
|
|
103
107
|
|
|
104
108
|
/**
|
|
105
109
|
* Enforcing version of entity loader method by the same name.
|
|
106
|
-
* @throws
|
|
110
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
107
111
|
*/
|
|
108
112
|
async loadManyByIDsAsync(ids: readonly TID[]): Promise<ReadonlyMap<TID, TEntity>> {
|
|
109
113
|
const entityResults = await this.entityLoader.loadManyByIDsAsync(ids);
|
|
@@ -112,7 +116,7 @@ export default class EnforcingEntityLoader<
|
|
|
112
116
|
|
|
113
117
|
/**
|
|
114
118
|
* Enforcing version of entity loader method by the same name.
|
|
115
|
-
* @throws
|
|
119
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
116
120
|
*/
|
|
117
121
|
async loadManyByFieldEqualityConjunctionAsync<N extends keyof Pick<TFields, TSelectedFields>>(
|
|
118
122
|
fieldEqualityOperands: FieldEqualityCondition<TFields, N>[],
|
|
@@ -127,12 +131,12 @@ export default class EnforcingEntityLoader<
|
|
|
127
131
|
|
|
128
132
|
/**
|
|
129
133
|
* Enforcing version of entity loader method by the same name.
|
|
130
|
-
* @throws
|
|
134
|
+
* @throws EntityNotAuthorizedError when viewer is not authorized to view one or more of the returned entities
|
|
131
135
|
*/
|
|
132
136
|
async loadManyByRawWhereClauseAsync(
|
|
133
137
|
rawWhereClause: string,
|
|
134
138
|
bindings: any[] | object,
|
|
135
|
-
querySelectionModifiers:
|
|
139
|
+
querySelectionModifiers: QuerySelectionModifiersWithOrderByRaw<TFields> = {}
|
|
136
140
|
): Promise<readonly TEntity[]> {
|
|
137
141
|
const entityResults = await this.entityLoader.loadManyByRawWhereClauseAsync(
|
|
138
142
|
rawWhereClause,
|