@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
|
@@ -9,10 +9,28 @@ export enum EntityMetricsLoadType {
|
|
|
9
9
|
LOAD_MANY_RAW,
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Event about a single call to an EntityLoader method.
|
|
14
|
+
*/
|
|
12
15
|
export interface EntityMetricsLoadEvent {
|
|
16
|
+
/**
|
|
17
|
+
* EntityMetricsLoadType for this load.
|
|
18
|
+
*/
|
|
13
19
|
type: EntityMetricsLoadType;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Class name of the Entity being loaded.
|
|
23
|
+
*/
|
|
14
24
|
entityClassName: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Total duration of this load, including fetch and construction of entities.
|
|
28
|
+
*/
|
|
15
29
|
duration: number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Number of entities returned for this load.
|
|
33
|
+
*/
|
|
16
34
|
count: number;
|
|
17
35
|
}
|
|
18
36
|
|
|
@@ -23,13 +41,57 @@ export enum EntityMetricsMutationType {
|
|
|
23
41
|
}
|
|
24
42
|
|
|
25
43
|
export interface EntityMetricsMutationEvent {
|
|
44
|
+
/**
|
|
45
|
+
* EntityMetricsMutationType for this mutation.
|
|
46
|
+
*/
|
|
26
47
|
type: EntityMetricsMutationType;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Class name of the Entity being mutated.
|
|
51
|
+
*/
|
|
27
52
|
entityClassName: string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Total duration of this mutation.
|
|
56
|
+
*/
|
|
28
57
|
duration: number;
|
|
29
58
|
}
|
|
30
59
|
|
|
60
|
+
export enum IncrementLoadCountEventType {
|
|
61
|
+
/**
|
|
62
|
+
* Type for when a dataloader load is initiated via the standard load methods
|
|
63
|
+
* since all loads go through a dataloader.
|
|
64
|
+
*/
|
|
65
|
+
DATALOADER,
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Type for when a cache load is initiated due to a dataloader miss.
|
|
69
|
+
*/
|
|
70
|
+
CACHE,
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 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.
|
|
74
|
+
*/
|
|
75
|
+
DATABASE,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Event used to record dataloader, cache, and database load counts in EntityDataManager.
|
|
80
|
+
*/
|
|
31
81
|
export interface IncrementLoadCountEvent {
|
|
82
|
+
/**
|
|
83
|
+
* Type of this event.
|
|
84
|
+
*/
|
|
85
|
+
type: IncrementLoadCountEventType;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Number of field values being loaded for this call.
|
|
89
|
+
*/
|
|
32
90
|
fieldValueCount: number;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Class name of the Entity being loaded.
|
|
94
|
+
*/
|
|
33
95
|
entityClassName: string;
|
|
34
96
|
}
|
|
35
97
|
|
|
@@ -38,7 +100,13 @@ export enum EntityMetricsAuthorizationResult {
|
|
|
38
100
|
ALLOW,
|
|
39
101
|
}
|
|
40
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Event used to record a singe EntityPrivacyPolicy authorization.
|
|
105
|
+
*/
|
|
41
106
|
export interface EntityMetricsAuthorizationEvent {
|
|
107
|
+
/**
|
|
108
|
+
* Class name of the Entity being authorized.
|
|
109
|
+
*/
|
|
42
110
|
entityClassName: string;
|
|
43
111
|
action: EntityAuthorizationAction;
|
|
44
112
|
evaluationResult: EntityMetricsAuthorizationResult;
|
|
@@ -51,7 +119,7 @@ export interface EntityMetricsAuthorizationEvent {
|
|
|
51
119
|
*/
|
|
52
120
|
export default interface IEntityMetricsAdapter {
|
|
53
121
|
/**
|
|
54
|
-
* Called when a
|
|
122
|
+
* Called when a EntityPrivacyPolicy authorization succeeds or fails.
|
|
55
123
|
* @param authorizationEvent - info about the authorization event
|
|
56
124
|
*/
|
|
57
125
|
logAuthorizationEvent(authorizationEvent: EntityMetricsAuthorizationEvent): void;
|
|
@@ -69,25 +137,10 @@ export default interface IEntityMetricsAdapter {
|
|
|
69
137
|
logMutatorMutationEvent(mutationEvent: EntityMetricsMutationEvent): void;
|
|
70
138
|
|
|
71
139
|
/**
|
|
72
|
-
* Called when a dataloader load is initiated via the standard
|
|
73
|
-
* load methods (not equality conjunction or raw).
|
|
74
|
-
*
|
|
75
|
-
*/
|
|
76
|
-
incrementDataManagerDataloaderLoadCount(incrementLoadCountEvent: IncrementLoadCountEvent): void;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Called when a cache load is initiated via the standard
|
|
80
|
-
* load methods (not equality conjunction or raw). Occurs upon a dataloader
|
|
81
|
-
* miss.
|
|
82
|
-
* @param fieldValueCount - count of field values being loaded for a field
|
|
83
|
-
*/
|
|
84
|
-
incrementDataManagerCacheLoadCount(incrementLoadCountEvent: IncrementLoadCountEvent): void;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Called when a database load is initiated via the standard
|
|
88
|
-
* load methods (not equality conjunction or raw). Occurs upon a cache
|
|
89
|
-
* miss or when fetching an uncacheable field.
|
|
140
|
+
* Called when a dataloader, cache, or database load is initiated via the standard
|
|
141
|
+
* load methods (not equality conjunction or raw). Most commonly used for logging
|
|
142
|
+
* a waterfall to determine dataloader and cache hit rates and ratios.
|
|
90
143
|
* @param fieldValueCount - count of field values being loaded for a field
|
|
91
144
|
*/
|
|
92
|
-
|
|
145
|
+
incrementDataManagerLoadCount(incrementLoadCountEvent: IncrementLoadCountEvent): void;
|
|
93
146
|
}
|
|
@@ -9,9 +9,5 @@ export default class NoOpEntityMetricsAdapter implements IEntityMetricsAdapter {
|
|
|
9
9
|
logAuthorizationEvent(_authorizationEvent: EntityMetricsAuthorizationEvent): void {}
|
|
10
10
|
logDataManagerLoadEvent(_loadEvent: EntityMetricsLoadEvent): void {}
|
|
11
11
|
logMutatorMutationEvent(_mutationEvent: EntityMetricsMutationEvent): void {}
|
|
12
|
-
|
|
13
|
-
_incrementLoadCountEvent: IncrementLoadCountEvent
|
|
14
|
-
): void {}
|
|
15
|
-
incrementDataManagerCacheLoadCount(_incrementLoadCountEvent: IncrementLoadCountEvent): void {}
|
|
16
|
-
incrementDataManagerDatabaseLoadCount(_incrementLoadCountEvent: IncrementLoadCountEvent): void {}
|
|
12
|
+
incrementDataManagerLoadCount(_incrementLoadCountEvent: IncrementLoadCountEvent): void {}
|
|
17
13
|
}
|
|
@@ -32,7 +32,7 @@ export enum RuleEvaluationResult {
|
|
|
32
32
|
* rule in the privacy policy. If all rules in the policy SKIP, the policy is denied.
|
|
33
33
|
*
|
|
34
34
|
* Returning DENY from a rule is useful in a few notable cases:
|
|
35
|
-
* - Preventing a CRUD action on an entity (
|
|
35
|
+
* - Preventing a CRUD action on an entity (AlwaysDenyPrivacyPolicyRule)
|
|
36
36
|
* - Blocking. For example, a user blocks another user from seeing their posts, and the rule
|
|
37
37
|
* would be named something like `DenyIfViewerHasBeenBlockedPrivacyPolicyRule`.
|
|
38
38
|
*/
|
|
@@ -60,7 +60,7 @@ export const mapMapAsync = async function <K, V, M>(
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Create a new Map by associating the value of each key with mapper executed for each key in the source map.
|
|
63
|
-
* The opposite of
|
|
63
|
+
* The opposite of mapMap. In the event two source keys map to the same result key, the second source key's
|
|
64
64
|
* value will overwrite the first, in which case the cardinality of the returned map may be smaller than the
|
|
65
65
|
* source map's.
|
|
66
66
|
*
|
|
@@ -158,7 +158,10 @@ export default class StubDatabaseAdapter<T> extends EntityDatabaseAdapter<T> {
|
|
|
158
158
|
|
|
159
159
|
private generateRandomID(): any {
|
|
160
160
|
const idSchemaField = this.entityConfiguration2.schema.get(this.entityConfiguration2.idField);
|
|
161
|
-
invariant(
|
|
161
|
+
invariant(
|
|
162
|
+
idSchemaField,
|
|
163
|
+
`No schema field found for ${String(this.entityConfiguration2.idField)}`
|
|
164
|
+
);
|
|
162
165
|
if (idSchemaField instanceof StringField) {
|
|
163
166
|
return uuidv4();
|
|
164
167
|
} else if (idSchemaField instanceof IntField) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EntityQueryContextProvider from '../../EntityQueryContextProvider';
|
|
2
2
|
|
|
3
|
-
class StubQueryContextProvider extends EntityQueryContextProvider {
|
|
3
|
+
export class StubQueryContextProvider extends EntityQueryContextProvider {
|
|
4
4
|
protected getQueryInterface(): any {
|
|
5
5
|
return {};
|
|
6
6
|
}
|