@expo/entity 0.21.0 → 0.24.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/EntityCacheAdapter.d.ts +2 -9
- package/build/EntityCacheAdapter.js.map +1 -1
- package/build/EntityFieldDefinition.d.ts +8 -0
- package/build/EntityFieldDefinition.js +5 -0
- package/build/EntityFieldDefinition.js.map +1 -1
- package/build/EntityFields.d.ts +38 -0
- package/build/EntityFields.js +38 -0
- package/build/EntityFields.js.map +1 -1
- package/build/GenericSecondaryEntityCache.d.ts +19 -0
- package/build/GenericSecondaryEntityCache.js +74 -0
- package/build/GenericSecondaryEntityCache.js.map +1 -0
- package/build/IEntityGenericCacher.d.ts +11 -0
- package/build/IEntityGenericCacher.js +3 -0
- package/build/IEntityGenericCacher.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/internal/ReadThroughEntityCache.d.ts +2 -3
- package/build/internal/ReadThroughEntityCache.js +2 -6
- package/build/internal/ReadThroughEntityCache.js.map +1 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.js +0 -32
- package/build/internal/__tests__/ReadThroughEntityCache-test.js.map +1 -1
- package/build/utils/testing/StubCacheAdapter.d.ts +6 -9
- package/build/utils/testing/StubCacheAdapter.js +0 -6
- package/build/utils/testing/StubCacheAdapter.js.map +1 -1
- package/package.json +1 -1
- package/src/EntityCacheAdapter.ts +2 -10
- package/src/EntityFieldDefinition.ts +8 -0
- package/src/EntityFields.ts +45 -0
- package/src/GenericSecondaryEntityCache.ts +98 -0
- package/src/IEntityGenericCacher.ts +15 -0
- package/src/index.ts +2 -0
- package/src/internal/ReadThroughEntityCache.ts +6 -28
- package/src/internal/__tests__/ReadThroughEntityCache-test.ts +0 -44
- package/src/utils/testing/StubCacheAdapter.ts +11 -17
|
@@ -3,7 +3,6 @@ import invariant from 'invariant';
|
|
|
3
3
|
import EntityCacheAdapter from '../../EntityCacheAdapter';
|
|
4
4
|
import EntityConfiguration from '../../EntityConfiguration';
|
|
5
5
|
import IEntityCacheAdapterProvider from '../../IEntityCacheAdapterProvider';
|
|
6
|
-
import { FieldTransformerMap } from '../../internal/EntityFieldTransformationUtils';
|
|
7
6
|
import { CacheStatus, CacheLoadResult } from '../../internal/ReadThroughEntityCache';
|
|
8
7
|
|
|
9
8
|
export class NoCacheStubCacheAdapterProvider implements IEntityCacheAdapterProvider {
|
|
@@ -15,15 +14,11 @@ export class NoCacheStubCacheAdapterProvider implements IEntityCacheAdapterProvi
|
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export class NoCacheStubCacheAdapter<TFields> extends EntityCacheAdapter<TFields> {
|
|
18
|
-
public getFieldTransformerMap(): FieldTransformerMap {
|
|
19
|
-
return new Map();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
17
|
public async loadManyAsync<N extends keyof TFields>(
|
|
23
18
|
_fieldName: N,
|
|
24
19
|
fieldValues: readonly NonNullable<TFields[N]>[]
|
|
25
|
-
): Promise<ReadonlyMap<NonNullable<TFields[N]>, CacheLoadResult
|
|
26
|
-
return fieldValues.reduce((acc: Map<NonNullable<TFields[N]>, CacheLoadResult
|
|
20
|
+
): Promise<ReadonlyMap<NonNullable<TFields[N]>, CacheLoadResult<TFields>>> {
|
|
21
|
+
return fieldValues.reduce((acc: Map<NonNullable<TFields[N]>, CacheLoadResult<TFields>>, v) => {
|
|
27
22
|
acc.set(v, {
|
|
28
23
|
status: CacheStatus.MISS,
|
|
29
24
|
});
|
|
@@ -33,7 +28,7 @@ export class NoCacheStubCacheAdapter<TFields> extends EntityCacheAdapter<TFields
|
|
|
33
28
|
|
|
34
29
|
public async cacheManyAsync<N extends keyof TFields>(
|
|
35
30
|
_fieldName: N,
|
|
36
|
-
_objectMap: ReadonlyMap<NonNullable<TFields[N]>,
|
|
31
|
+
_objectMap: ReadonlyMap<NonNullable<TFields[N]>, Readonly<TFields>>
|
|
37
32
|
): Promise<void> {}
|
|
38
33
|
|
|
39
34
|
public async cacheDBMissesAsync<N extends keyof TFields>(
|
|
@@ -53,27 +48,26 @@ export class InMemoryFullCacheStubCacheAdapterProvider implements IEntityCacheAd
|
|
|
53
48
|
getCacheAdapter<TFields>(
|
|
54
49
|
entityConfiguration: EntityConfiguration<TFields>
|
|
55
50
|
): EntityCacheAdapter<TFields> {
|
|
56
|
-
return new InMemoryFullCacheStubCacheAdapter(
|
|
51
|
+
return new InMemoryFullCacheStubCacheAdapter(
|
|
52
|
+
entityConfiguration,
|
|
53
|
+
this.cache as Map<string, Readonly<TFields>>
|
|
54
|
+
);
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
export class InMemoryFullCacheStubCacheAdapter<TFields> extends EntityCacheAdapter<TFields> {
|
|
61
59
|
constructor(
|
|
62
60
|
entityConfiguration: EntityConfiguration<TFields>,
|
|
63
|
-
readonly cache: Map<string, Readonly<
|
|
61
|
+
readonly cache: Map<string, Readonly<TFields>>
|
|
64
62
|
) {
|
|
65
63
|
super(entityConfiguration);
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
public getFieldTransformerMap(): FieldTransformerMap {
|
|
69
|
-
return new Map();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
66
|
public async loadManyAsync<N extends keyof TFields>(
|
|
73
67
|
fieldName: N,
|
|
74
68
|
fieldValues: readonly NonNullable<TFields[N]>[]
|
|
75
|
-
): Promise<ReadonlyMap<NonNullable<TFields[N]>, CacheLoadResult
|
|
76
|
-
const results = new Map<NonNullable<TFields[N]>, CacheLoadResult
|
|
69
|
+
): Promise<ReadonlyMap<NonNullable<TFields[N]>, CacheLoadResult<TFields>>> {
|
|
70
|
+
const results = new Map<NonNullable<TFields[N]>, CacheLoadResult<TFields>>();
|
|
77
71
|
fieldValues.forEach((fieldValue) => {
|
|
78
72
|
const cacheKey = this.createCacheKey(fieldName, fieldValue);
|
|
79
73
|
if (!this.cache.has(cacheKey)) {
|
|
@@ -94,7 +88,7 @@ export class InMemoryFullCacheStubCacheAdapter<TFields> extends EntityCacheAdapt
|
|
|
94
88
|
|
|
95
89
|
public async cacheManyAsync<N extends keyof TFields>(
|
|
96
90
|
fieldName: N,
|
|
97
|
-
objectMap: ReadonlyMap<NonNullable<TFields[N]>,
|
|
91
|
+
objectMap: ReadonlyMap<NonNullable<TFields[N]>, Readonly<TFields>>
|
|
98
92
|
): Promise<void> {
|
|
99
93
|
objectMap.forEach((obj, fieldValue) => {
|
|
100
94
|
const cacheKey = this.createCacheKey(fieldName, fieldValue);
|