@expo/entity 0.55.0 → 0.57.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/src/AuthorizationResultBasedEntityAssociationLoader.d.ts +1 -1
- package/build/src/AuthorizationResultBasedEntityAssociationLoader.js.map +1 -1
- package/build/src/AuthorizationResultBasedEntityLoader.d.ts +18 -24
- package/build/src/AuthorizationResultBasedEntityLoader.js +37 -56
- package/build/src/AuthorizationResultBasedEntityLoader.js.map +1 -1
- package/build/src/AuthorizationResultBasedEntityMutator.js +26 -19
- package/build/src/AuthorizationResultBasedEntityMutator.js.map +1 -1
- package/build/src/EnforcingEntityCreator.d.ts +1 -1
- package/build/src/EnforcingEntityCreator.js +1 -1
- package/build/src/EnforcingEntityLoader.d.ts +1 -58
- package/build/src/EnforcingEntityLoader.js +0 -65
- package/build/src/EnforcingEntityLoader.js.map +1 -1
- package/build/src/Entity.d.ts +6 -0
- package/build/src/Entity.js +6 -0
- package/build/src/Entity.js.map +1 -1
- package/build/src/EntityCompanion.d.ts +2 -2
- package/build/src/EntityCompanion.js.map +1 -1
- package/build/src/EntityCompanionProvider.d.ts +1 -1
- package/build/src/EntityCompanionProvider.js +4 -4
- package/build/src/EntityConfiguration.d.ts +1 -1
- package/build/src/EntityConfiguration.js +1 -2
- package/build/src/EntityConfiguration.js.map +1 -1
- package/build/src/{EntityLoaderUtils.d.ts → EntityConstructionUtils.d.ts} +15 -29
- package/build/src/EntityConstructionUtils.js +118 -0
- package/build/src/EntityConstructionUtils.js.map +1 -0
- package/build/src/EntityDatabaseAdapter.d.ts +10 -108
- package/build/src/EntityDatabaseAdapter.js +14 -76
- package/build/src/EntityDatabaseAdapter.js.map +1 -1
- package/build/src/EntityFieldDefinition.d.ts +1 -1
- package/build/src/EntityInvalidationUtils.d.ts +41 -0
- package/build/src/EntityInvalidationUtils.js +71 -0
- package/build/src/EntityInvalidationUtils.js.map +1 -0
- package/build/src/EntityLoader.d.ts +0 -6
- package/build/src/EntityLoader.js +0 -7
- package/build/src/EntityLoader.js.map +1 -1
- package/build/src/EntityLoaderFactory.d.ts +4 -0
- package/build/src/EntityLoaderFactory.js +10 -3
- package/build/src/EntityLoaderFactory.js.map +1 -1
- package/build/src/EntityPrivacyPolicy.d.ts +27 -0
- package/build/src/EntityPrivacyPolicy.js +22 -1
- package/build/src/EntityPrivacyPolicy.js.map +1 -1
- package/build/src/EntitySecondaryCacheLoader.d.ts +14 -3
- package/build/src/EntitySecondaryCacheLoader.js +21 -4
- package/build/src/EntitySecondaryCacheLoader.js.map +1 -1
- package/build/src/ReadonlyEntity.d.ts +4 -5
- package/build/src/ReadonlyEntity.js +7 -8
- package/build/src/ReadonlyEntity.js.map +1 -1
- package/build/src/ViewerContext.d.ts +6 -6
- package/build/src/ViewerContext.js +8 -8
- package/build/src/ViewerScopedEntityCompanion.d.ts +1 -1
- package/build/src/ViewerScopedEntityCompanion.js.map +1 -1
- package/build/src/ViewerScopedEntityLoaderFactory.d.ts +4 -0
- package/build/src/ViewerScopedEntityLoaderFactory.js +6 -0
- package/build/src/ViewerScopedEntityLoaderFactory.js.map +1 -1
- package/build/src/errors/EntityDatabaseAdapterError.d.ts +4 -0
- package/build/src/errors/EntityDatabaseAdapterError.js +13 -1
- package/build/src/errors/EntityDatabaseAdapterError.js.map +1 -1
- package/build/src/errors/EntityError.d.ts +2 -1
- package/build/src/errors/EntityError.js +1 -0
- package/build/src/errors/EntityError.js.map +1 -1
- package/build/src/index.d.ts +2 -1
- package/build/src/index.js +2 -1
- package/build/src/index.js.map +1 -1
- package/build/src/internal/EntityDataManager.d.ts +8 -16
- package/build/src/internal/EntityDataManager.js +8 -18
- package/build/src/internal/EntityDataManager.js.map +1 -1
- package/build/src/internal/EntityFieldTransformationUtils.js.map +1 -1
- package/build/src/internal/EntityLoadInterfaces.d.ts +2 -0
- package/build/src/internal/EntityLoadInterfaces.js +2 -0
- package/build/src/internal/EntityLoadInterfaces.js.map +1 -1
- package/build/src/internal/EntityTableDataCoordinator.d.ts +2 -0
- package/build/src/internal/EntityTableDataCoordinator.js +4 -0
- package/build/src/internal/EntityTableDataCoordinator.js.map +1 -1
- package/build/src/metrics/EntityMetricsUtils.d.ts +1 -0
- package/build/src/metrics/EntityMetricsUtils.js +15 -1
- package/build/src/metrics/EntityMetricsUtils.js.map +1 -1
- package/build/src/metrics/IEntityMetricsAdapter.d.ts +4 -1
- package/build/src/metrics/IEntityMetricsAdapter.js +3 -0
- package/build/src/metrics/IEntityMetricsAdapter.js.map +1 -1
- package/build/src/rules/AllowIfAllSubRulesAllowPrivacyPolicyRule.d.ts +2 -2
- package/build/src/rules/AllowIfAnySubRuleAllowsPrivacyPolicyRule.d.ts +2 -2
- package/build/src/rules/EvaluateIfEntityFieldPredicatePrivacyPolicyRule.d.ts +2 -2
- package/build/src/rules/PrivacyPolicyRule.d.ts +2 -2
- package/build/src/utils/EntityPrivacyUtils.js +11 -20
- package/build/src/utils/EntityPrivacyUtils.js.map +1 -1
- package/build/src/utils/collections/maps.d.ts +2 -2
- package/build/src/utils/collections/maps.js +2 -2
- package/package.json +4 -4
- package/src/AuthorizationResultBasedEntityAssociationLoader.ts +4 -7
- package/src/AuthorizationResultBasedEntityLoader.ts +58 -88
- package/src/AuthorizationResultBasedEntityMutator.ts +35 -20
- package/src/EnforcingEntityCreator.ts +1 -1
- package/src/EnforcingEntityLoader.ts +1 -95
- package/src/Entity.ts +6 -0
- package/src/EntityCompanion.ts +2 -2
- package/src/EntityCompanionProvider.ts +4 -4
- package/src/EntityConfiguration.ts +8 -5
- package/src/EntityConstructionUtils.ts +168 -0
- package/src/EntityDatabaseAdapter.ts +32 -222
- package/src/EntityFieldDefinition.ts +1 -1
- package/src/{EntityLoaderUtils.ts → EntityInvalidationUtils.ts} +5 -96
- package/src/EntityLoader.ts +0 -16
- package/src/EntityLoaderFactory.ts +50 -10
- package/src/EntityPrivacyPolicy.ts +44 -1
- package/src/EntitySecondaryCacheLoader.ts +54 -3
- package/src/ReadonlyEntity.ts +9 -11
- package/src/ViewerContext.ts +10 -10
- package/src/ViewerScopedEntityCompanion.ts +1 -1
- package/src/ViewerScopedEntityLoaderFactory.ts +37 -0
- package/src/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.ts +3 -5
- package/src/__tests__/AuthorizationResultBasedEntityLoader-test.ts +34 -419
- package/src/__tests__/ComposedCacheAdapter-test.ts +3 -3
- package/src/__tests__/EnforcingEntityLoader-test.ts +2 -134
- package/src/__tests__/EntityCompanion-test.ts +18 -0
- package/src/__tests__/EntityConfiguration-test.ts +4 -4
- package/src/__tests__/EntityDatabaseAdapter-test.ts +33 -68
- package/src/__tests__/EntityEdges-test.ts +10 -10
- package/src/__tests__/EntityLoader-test.ts +6 -4
- package/src/__tests__/EntityMutator-test.ts +27 -15
- package/src/__tests__/EntityPrivacyPolicy-test.ts +102 -0
- package/src/__tests__/EntityQueryContext-test.ts +11 -11
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +10 -5
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +6 -6
- package/src/__tests__/GenericEntityCacheAdapter-test.ts +18 -15
- package/src/__tests__/GenericSecondaryEntityCache-test.ts +27 -5
- package/src/__tests__/ReadonlyEntity-test.ts +6 -4
- package/src/__tests__/ViewerContext-test.ts +4 -4
- package/src/__tests__/ViewerScopedEntityCompanion-test.ts +1 -0
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +0 -17
- package/src/errors/EntityDatabaseAdapterError.ts +14 -0
- package/src/errors/EntityError.ts +1 -0
- package/src/errors/__tests__/EntityDatabaseAdapterError-test.ts +9 -0
- package/src/errors/__tests__/EntityError-test.ts +13 -5
- package/src/index.ts +2 -1
- package/src/internal/EntityDataManager.ts +19 -54
- package/src/internal/EntityFieldTransformationUtils.ts +5 -5
- package/src/internal/EntityLoadInterfaces.ts +2 -0
- package/src/internal/EntityTableDataCoordinator.ts +2 -2
- package/src/internal/__tests__/CompositeFieldHolder-test.ts +8 -2
- package/src/internal/__tests__/EntityDataManager-test.ts +71 -202
- package/src/internal/__tests__/ReadThroughEntityCache-test.ts +39 -24
- package/src/metrics/EntityMetricsUtils.ts +23 -0
- package/src/metrics/IEntityMetricsAdapter.ts +3 -0
- package/src/metrics/__tests__/EntityMetricsUtils-test.ts +120 -0
- package/src/rules/AllowIfAllSubRulesAllowPrivacyPolicyRule.ts +2 -2
- package/src/rules/AllowIfAnySubRuleAllowsPrivacyPolicyRule.ts +2 -2
- package/src/rules/EvaluateIfEntityFieldPredicatePrivacyPolicyRule.ts +2 -2
- package/src/rules/PrivacyPolicyRule.ts +2 -2
- package/src/rules/__tests__/AllowIfAllSubRulesAllowPrivacyPolicyRule-test.ts +4 -4
- package/src/rules/__tests__/AllowIfAnySubRuleAllowsPrivacyPolicyRule-test.ts +4 -4
- package/src/rules/__tests__/AllowIfInParentCascadeDeletionPrivacyPolicyRule-test.ts +11 -1
- package/src/rules/__tests__/AlwaysAllowPrivacyPolicyRule-test.ts +2 -2
- package/src/rules/__tests__/AlwaysDenyPrivacyPolicyRule-test.ts +2 -2
- package/src/rules/__tests__/AlwaysSkipPrivacyPolicyRule-test.ts +2 -2
- package/src/rules/__tests__/EvaluateIfEntityFieldPredicatePrivacyPolicyRule-test.ts +3 -3
- package/src/utils/EntityPrivacyUtils.ts +18 -29
- package/src/utils/__testfixtures__/PrivacyPolicyRuleTestUtils.ts +2 -2
- package/src/utils/__testfixtures__/StubDatabaseAdapter.ts +13 -101
- package/src/utils/__tests__/EntityCreationUtils-test.ts +6 -6
- package/src/utils/__tests__/EntityPrivacyUtils-test.ts +2 -2
- package/src/utils/collections/maps.ts +2 -2
- package/build/src/EntityLoaderUtils.js +0 -147
- package/build/src/EntityLoaderUtils.js.map +0 -1
package/src/index.ts
CHANGED
|
@@ -19,14 +19,15 @@ export * from './EntityAssociationLoader';
|
|
|
19
19
|
export * from './EntityCompanion';
|
|
20
20
|
export * from './EntityCompanionProvider';
|
|
21
21
|
export * from './EntityConfiguration';
|
|
22
|
+
export * from './EntityConstructionUtils';
|
|
22
23
|
export * from './EntityCreator';
|
|
23
24
|
export * from './EntityDatabaseAdapter';
|
|
24
25
|
export * from './EntityDeleter';
|
|
25
26
|
export * from './EntityFieldDefinition';
|
|
26
27
|
export * from './EntityFields';
|
|
28
|
+
export * from './EntityInvalidationUtils';
|
|
27
29
|
export * from './EntityLoader';
|
|
28
30
|
export * from './EntityLoaderFactory';
|
|
29
|
-
export * from './EntityLoaderUtils';
|
|
30
31
|
export * from './EntityMutationInfo';
|
|
31
32
|
export * from './EntityMutationTriggerConfiguration';
|
|
32
33
|
export * from './EntityMutationValidatorConfiguration';
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import DataLoader from 'dataloader';
|
|
2
2
|
import invariant from 'invariant';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
EntityDatabaseAdapter,
|
|
6
|
-
FieldEqualityCondition,
|
|
7
|
-
QuerySelectionModifiers,
|
|
8
|
-
QuerySelectionModifiersWithOrderByRaw,
|
|
9
|
-
} from '../EntityDatabaseAdapter';
|
|
4
|
+
import { EntityDatabaseAdapter } from '../EntityDatabaseAdapter';
|
|
10
5
|
import {
|
|
11
6
|
EntityQueryContext,
|
|
12
7
|
EntityTransactionalQueryContext,
|
|
@@ -17,8 +12,8 @@ import { partitionErrors } from '../entityUtils';
|
|
|
17
12
|
import { IEntityLoadKey, IEntityLoadValue, LoadPair } from './EntityLoadInterfaces';
|
|
18
13
|
import { ReadThroughEntityCache } from './ReadThroughEntityCache';
|
|
19
14
|
import {
|
|
20
|
-
timeAndLogLoadEventAsync,
|
|
21
15
|
timeAndLogLoadMapEventAsync,
|
|
16
|
+
timeAndLogLoadOneEventAsync,
|
|
22
17
|
} from '../metrics/EntityMetricsUtils';
|
|
23
18
|
import {
|
|
24
19
|
EntityMetricsLoadType,
|
|
@@ -252,61 +247,31 @@ export class EntityDataManager<
|
|
|
252
247
|
}
|
|
253
248
|
|
|
254
249
|
/**
|
|
255
|
-
*
|
|
256
|
-
*
|
|
250
|
+
* Load one object matching load key and load value if at least one matching object exists.
|
|
251
|
+
* Returned object is not guaranteed to be deterministic.
|
|
257
252
|
*
|
|
258
|
-
*
|
|
259
|
-
* @param fieldEqualityOperands - list of field equality where clause operand specifications
|
|
260
|
-
* @param querySelectionModifiers - limit, offset, and orderBy for the query
|
|
261
|
-
* @returns array of objects matching the query
|
|
262
|
-
*/
|
|
263
|
-
async loadManyByFieldEqualityConjunctionAsync<N extends keyof TFields>(
|
|
264
|
-
queryContext: EntityQueryContext,
|
|
265
|
-
fieldEqualityOperands: FieldEqualityCondition<TFields, N>[],
|
|
266
|
-
querySelectionModifiers: QuerySelectionModifiers<TFields>,
|
|
267
|
-
): Promise<readonly Readonly<TFields>[]> {
|
|
268
|
-
return await timeAndLogLoadEventAsync(
|
|
269
|
-
this.metricsAdapter,
|
|
270
|
-
EntityMetricsLoadType.LOAD_MANY_EQUALITY_CONJUNCTION,
|
|
271
|
-
this.entityClassName,
|
|
272
|
-
queryContext,
|
|
273
|
-
)(
|
|
274
|
-
this.databaseAdapter.fetchManyByFieldEqualityConjunctionAsync(
|
|
275
|
-
queryContext,
|
|
276
|
-
fieldEqualityOperands,
|
|
277
|
-
querySelectionModifiers,
|
|
278
|
-
),
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Loads many objects matching the raw WHERE clause.
|
|
253
|
+
* Used when evaluating EntityEdgeDeletionAuthorizationInferenceBehavior.ONE_IMPLIES_ALL.
|
|
284
254
|
*
|
|
285
255
|
* @param queryContext - query context in which to perform the load
|
|
286
|
-
* @param
|
|
287
|
-
* @param
|
|
288
|
-
* @
|
|
289
|
-
* @returns array of objects matching the query
|
|
256
|
+
* @param key - load key being queried
|
|
257
|
+
* @param values - load value being queried for the key
|
|
258
|
+
* @returns at most one that match the query for that load value
|
|
290
259
|
*/
|
|
291
|
-
async
|
|
260
|
+
public async loadOneEqualingAsync<
|
|
261
|
+
TLoadKey extends IEntityLoadKey<TFields, TIDField, TSerializedLoadValue, TLoadValue>,
|
|
262
|
+
TSerializedLoadValue,
|
|
263
|
+
TLoadValue extends IEntityLoadValue<TSerializedLoadValue>,
|
|
264
|
+
>(
|
|
292
265
|
queryContext: EntityQueryContext,
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return await timeAndLogLoadEventAsync(
|
|
266
|
+
key: TLoadKey,
|
|
267
|
+
value: TLoadValue,
|
|
268
|
+
): Promise<Readonly<TFields> | null> {
|
|
269
|
+
return await timeAndLogLoadOneEventAsync(
|
|
298
270
|
this.metricsAdapter,
|
|
299
|
-
EntityMetricsLoadType.
|
|
271
|
+
EntityMetricsLoadType.LOAD_ONE,
|
|
300
272
|
this.entityClassName,
|
|
301
273
|
queryContext,
|
|
302
|
-
)(
|
|
303
|
-
this.databaseAdapter.fetchManyByRawWhereClauseAsync(
|
|
304
|
-
queryContext,
|
|
305
|
-
rawWhereClause,
|
|
306
|
-
bindings,
|
|
307
|
-
querySelectionModifiers,
|
|
308
|
-
),
|
|
309
|
-
);
|
|
274
|
+
)(this.databaseAdapter.fetchOneWhereAsync(queryContext, key, value));
|
|
310
275
|
}
|
|
311
276
|
|
|
312
277
|
private async invalidateOneAsync<
|
|
@@ -51,7 +51,7 @@ export const transformDatabaseObjectToFields = <
|
|
|
51
51
|
fieldTransformerMap: FieldTransformerMap,
|
|
52
52
|
databaseObject: { [key: string]: any },
|
|
53
53
|
): Readonly<TFields> => {
|
|
54
|
-
const fields: TFields = {}
|
|
54
|
+
const fields: Partial<TFields> = {};
|
|
55
55
|
for (const k in databaseObject) {
|
|
56
56
|
const val = databaseObject[k];
|
|
57
57
|
const fieldsKey = entityConfiguration.dbToEntityFieldsKeyMapping.get(k);
|
|
@@ -64,7 +64,7 @@ export const transformDatabaseObjectToFields = <
|
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
return fields
|
|
67
|
+
return fields as Readonly<TFields>;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -81,7 +81,7 @@ export const transformFieldsToDatabaseObject = <
|
|
|
81
81
|
const databaseObject: { [key: string]: any } = {};
|
|
82
82
|
for (const k in fields) {
|
|
83
83
|
const val = fields[k]!;
|
|
84
|
-
const databaseKey = entityConfiguration.entityToDBFieldsKeyMapping.get(k
|
|
84
|
+
const databaseKey = entityConfiguration.entityToDBFieldsKeyMapping.get(k);
|
|
85
85
|
invariant(databaseKey, `must be database key for field: ${k}`);
|
|
86
86
|
databaseObject[databaseKey] = maybeTransformFieldValueToDatabaseValue(
|
|
87
87
|
entityConfiguration,
|
|
@@ -104,7 +104,7 @@ export const transformCacheObjectToFields = <
|
|
|
104
104
|
fieldTransformerMap: FieldTransformerMap,
|
|
105
105
|
cacheObject: { [key: string]: any },
|
|
106
106
|
): Readonly<TFields> => {
|
|
107
|
-
const fields: TFields = {}
|
|
107
|
+
const fields: Partial<TFields> = {};
|
|
108
108
|
for (const fieldsKey in cacheObject) {
|
|
109
109
|
const val = cacheObject[fieldsKey]!;
|
|
110
110
|
fields[fieldsKey as keyof TFields] = maybeTransformCacheValueToFieldValue(
|
|
@@ -114,7 +114,7 @@ export const transformCacheObjectToFields = <
|
|
|
114
114
|
val,
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
|
-
return fields
|
|
117
|
+
return fields as Readonly<TFields>;
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
/**
|
|
@@ -28,8 +28,8 @@ export class EntityTableDataCoordinator<
|
|
|
28
28
|
databaseAdapterProvider: IEntityDatabaseAdapterProvider,
|
|
29
29
|
cacheAdapterProvider: IEntityCacheAdapterProvider,
|
|
30
30
|
private readonly queryContextProvider: EntityQueryContextProvider,
|
|
31
|
-
metricsAdapter: IEntityMetricsAdapter,
|
|
32
|
-
entityClassName: string,
|
|
31
|
+
public readonly metricsAdapter: IEntityMetricsAdapter,
|
|
32
|
+
public readonly entityClassName: string,
|
|
33
33
|
) {
|
|
34
34
|
this.databaseAdapter = databaseAdapterProvider.getDatabaseAdapter(entityConfiguration);
|
|
35
35
|
this.cacheAdapter = cacheAdapterProvider.getCacheAdapter(entityConfiguration);
|
|
@@ -2,10 +2,16 @@ import { describe, expect, it } from '@jest/globals';
|
|
|
2
2
|
|
|
3
3
|
import { CompositeFieldHolder, CompositeFieldValueHolder } from '../CompositeFieldHolder';
|
|
4
4
|
|
|
5
|
+
type TestFields = {
|
|
6
|
+
id: string;
|
|
7
|
+
field1: string;
|
|
8
|
+
field2: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
5
11
|
describe(CompositeFieldHolder, () => {
|
|
6
12
|
it('is order-agnostic for serialization', () => {
|
|
7
|
-
const compositeFieldHolder = new CompositeFieldHolder(['field1', 'field2']);
|
|
8
|
-
const compositeFieldHolder2 = new CompositeFieldHolder(['field2', 'field1']);
|
|
13
|
+
const compositeFieldHolder = new CompositeFieldHolder<TestFields, 'id'>(['field1', 'field2']);
|
|
14
|
+
const compositeFieldHolder2 = new CompositeFieldHolder<TestFields, 'id'>(['field2', 'field1']);
|
|
9
15
|
|
|
10
16
|
expect(compositeFieldHolder.serialize()).toEqual(compositeFieldHolder2.serialize());
|
|
11
17
|
});
|