@expo/entity-cache-adapter-local-memory 0.60.0 → 0.61.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.
@@ -1,4 +1,4 @@
1
- import { CacheLoadResult, EntityConfiguration, IEntityGenericCacher, IEntityLoadKey, IEntityLoadValue } from '@expo/entity';
1
+ import type { CacheLoadResult, EntityConfiguration, IEntityGenericCacher, IEntityLoadKey, IEntityLoadValue } from '@expo/entity';
2
2
  export declare const DOES_NOT_EXIST_LOCAL_MEMORY_CACHE: unique symbol;
3
3
  /**
4
4
  * Type of value stored in the local memory cache. This is either the cached fields, or the
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GenericLocalMemoryCacher = exports.DOES_NOT_EXIST_LOCAL_MEMORY_CACHE = void 0;
4
- const entity_1 = require("@expo/entity");
1
+ import { CacheStatus } from '@expo/entity';
5
2
  // Sentinel value we store in local memory to negatively cache a database miss.
6
3
  // The sentinel value is distinct from any (positively) cached value.
7
- exports.DOES_NOT_EXIST_LOCAL_MEMORY_CACHE = Symbol('doesNotExist');
8
- class GenericLocalMemoryCacher {
4
+ export const DOES_NOT_EXIST_LOCAL_MEMORY_CACHE = Symbol('doesNotExist');
5
+ export class GenericLocalMemoryCacher {
9
6
  entityConfiguration;
10
7
  localMemoryCache;
11
8
  constructor(entityConfiguration, localMemoryCache) {
@@ -25,20 +22,20 @@ class GenericLocalMemoryCacher {
25
22
  const cacheResults = new Map();
26
23
  for (const key of keys) {
27
24
  const cacheResult = this.localMemoryCache.get(key);
28
- if (cacheResult === exports.DOES_NOT_EXIST_LOCAL_MEMORY_CACHE) {
25
+ if (cacheResult === DOES_NOT_EXIST_LOCAL_MEMORY_CACHE) {
29
26
  cacheResults.set(key, {
30
- status: entity_1.CacheStatus.NEGATIVE,
27
+ status: CacheStatus.NEGATIVE,
31
28
  });
32
29
  }
33
30
  else if (cacheResult) {
34
31
  cacheResults.set(key, {
35
- status: entity_1.CacheStatus.HIT,
32
+ status: CacheStatus.HIT,
36
33
  item: cacheResult,
37
34
  });
38
35
  }
39
36
  else {
40
37
  cacheResults.set(key, {
41
- status: entity_1.CacheStatus.MISS,
38
+ status: CacheStatus.MISS,
42
39
  });
43
40
  }
44
41
  }
@@ -51,7 +48,7 @@ class GenericLocalMemoryCacher {
51
48
  }
52
49
  async cacheDBMissesAsync(keys) {
53
50
  for (const key of keys) {
54
- this.localMemoryCache.set(key, exports.DOES_NOT_EXIST_LOCAL_MEMORY_CACHE);
51
+ this.localMemoryCache.set(key, DOES_NOT_EXIST_LOCAL_MEMORY_CACHE);
55
52
  }
56
53
  }
57
54
  async invalidateManyAsync(keys) {
@@ -78,5 +75,3 @@ class GenericLocalMemoryCacher {
78
75
  return [this.makeCacheKeyForStorage(key, value)];
79
76
  }
80
77
  }
81
- exports.GenericLocalMemoryCacher = GenericLocalMemoryCacher;
82
- //# sourceMappingURL=GenericLocalMemoryCacher.js.map
@@ -1,5 +1,5 @@
1
- import { EntityConfiguration, IEntityCacheAdapter, IEntityCacheAdapterProvider } from '@expo/entity';
2
- import { ILocalMemoryCache } from './GenericLocalMemoryCacher';
1
+ import type { EntityConfiguration, IEntityCacheAdapter, IEntityCacheAdapterProvider } from '@expo/entity';
2
+ import type { ILocalMemoryCache } from './GenericLocalMemoryCacher.ts';
3
3
  export type LocalMemoryCacheCreator = <TFields extends Record<string, any>>() => ILocalMemoryCache<TFields>;
4
4
  /**
5
5
  * Vends local memory cache adapters. An instance of this class may be shared across requests to
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocalMemoryCacheAdapterProvider = void 0;
4
- const entity_1 = require("@expo/entity");
5
- const GenericLocalMemoryCacher_1 = require("./GenericLocalMemoryCacher");
1
+ import { computeIfAbsent, GenericEntityCacheAdapter } from '@expo/entity';
2
+ import { GenericLocalMemoryCacher } from "./GenericLocalMemoryCacher.js";
6
3
  /**
7
4
  * Vends local memory cache adapters. An instance of this class may be shared across requests to
8
5
  * share the local memory cache.
9
6
  */
10
- class LocalMemoryCacheAdapterProvider {
7
+ export class LocalMemoryCacheAdapterProvider {
11
8
  localMemoryCacheCreator;
12
9
  /**
13
10
  * @returns a no-op local memory cache adapter provider, or one that doesn't cache at all.
14
11
  */
15
12
  static createNoOpProvider() {
16
- return new LocalMemoryCacheAdapterProvider(() => GenericLocalMemoryCacher_1.GenericLocalMemoryCacher.createNoOpCache());
13
+ return new LocalMemoryCacheAdapterProvider(() => GenericLocalMemoryCacher.createNoOpCache());
17
14
  }
18
15
  /**
19
16
  * @returns a local memory cache adapter provider configured with the supplied local memory cache creator function.
@@ -26,11 +23,9 @@ class LocalMemoryCacheAdapterProvider {
26
23
  this.localMemoryCacheCreator = localMemoryCacheCreator;
27
24
  }
28
25
  getCacheAdapter(entityConfiguration) {
29
- return (0, entity_1.computeIfAbsent)(this.localMemoryCacheAdapterMap, entityConfiguration.tableName, () => {
26
+ return computeIfAbsent(this.localMemoryCacheAdapterMap, entityConfiguration.tableName, () => {
30
27
  const localMemoryCache = this.localMemoryCacheCreator();
31
- return new entity_1.GenericEntityCacheAdapter(new GenericLocalMemoryCacher_1.GenericLocalMemoryCacher(entityConfiguration, localMemoryCache));
28
+ return new GenericEntityCacheAdapter(new GenericLocalMemoryCacher(entityConfiguration, localMemoryCache));
32
29
  });
33
30
  }
34
31
  }
35
- exports.LocalMemoryCacheAdapterProvider = LocalMemoryCacheAdapterProvider;
36
- //# sourceMappingURL=LocalMemoryCacheAdapterProvider.js.map
@@ -2,5 +2,5 @@
2
2
  * @packageDocumentation
3
3
  * @module @expo/entity-cache-adapter-local-memory
4
4
  */
5
- export * from './GenericLocalMemoryCacher';
6
- export * from './LocalMemoryCacheAdapterProvider';
5
+ export * from './GenericLocalMemoryCacher.ts';
6
+ export * from './LocalMemoryCacheAdapterProvider.ts';
@@ -1,24 +1,7 @@
1
- "use strict";
2
1
  /* eslint-disable tsdoc/syntax */
3
2
  /**
4
3
  * @packageDocumentation
5
4
  * @module @expo/entity-cache-adapter-local-memory
6
5
  */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- __exportStar(require("./GenericLocalMemoryCacher"), exports);
23
- __exportStar(require("./LocalMemoryCacheAdapterProvider"), exports);
24
- //# sourceMappingURL=index.js.map
6
+ export * from "./GenericLocalMemoryCacher.js";
7
+ export * from "./LocalMemoryCacheAdapterProvider.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/entity-cache-adapter-local-memory",
3
- "version": "0.60.0",
3
+ "version": "0.61.0",
4
4
  "description": "Cross-request local memory cache adapter for @expo/entity",
5
5
  "files": [
6
6
  "build",
@@ -20,21 +20,22 @@
20
20
  "integration": "yarn integration:all --rootDir $(pwd)"
21
21
  },
22
22
  "engines": {
23
- "node": ">=16"
23
+ "node": ">=18"
24
24
  },
25
25
  "keywords": [
26
26
  "entity"
27
27
  ],
28
28
  "author": "Expo",
29
29
  "license": "MIT",
30
+ "type": "module",
30
31
  "dependencies": {
31
- "@expo/entity": "^0.60.0"
32
+ "@expo/entity": "^0.61.0"
32
33
  },
33
34
  "devDependencies": {
34
- "@expo/entity-testing-utils": "^0.60.0",
35
+ "@expo/entity-testing-utils": "^0.61.0",
35
36
  "@isaacs/ttlcache": "2.1.4",
36
37
  "@jest/globals": "30.2.0",
37
38
  "typescript": "5.9.3"
38
39
  },
39
- "gitHead": "e36dc81bd22ce92a7a11ccd1976173b464da5e76"
40
+ "gitHead": "a6f1dd723262cb1c3e8022d3a8799c17602cd15b"
40
41
  }
@@ -1,11 +1,11 @@
1
- import {
1
+ import type {
2
2
  CacheLoadResult,
3
- CacheStatus,
4
3
  EntityConfiguration,
5
4
  IEntityGenericCacher,
6
5
  IEntityLoadKey,
7
6
  IEntityLoadValue,
8
7
  } from '@expo/entity';
8
+ import { CacheStatus } from '@expo/entity';
9
9
 
10
10
  // Sentinel value we store in local memory to negatively cache a database miss.
11
11
  // The sentinel value is distinct from any (positively) cached value.
@@ -1,12 +1,12 @@
1
- import {
2
- computeIfAbsent,
1
+ import type {
3
2
  EntityConfiguration,
4
- GenericEntityCacheAdapter,
5
3
  IEntityCacheAdapter,
6
4
  IEntityCacheAdapterProvider,
7
5
  } from '@expo/entity';
6
+ import { computeIfAbsent, GenericEntityCacheAdapter } from '@expo/entity';
8
7
 
9
- import { GenericLocalMemoryCacher, ILocalMemoryCache } from './GenericLocalMemoryCacher';
8
+ import type { ILocalMemoryCache } from './GenericLocalMemoryCacher.ts';
9
+ import { GenericLocalMemoryCacher } from './GenericLocalMemoryCacher.ts';
10
10
 
11
11
  export type LocalMemoryCacheCreator = <
12
12
  TFields extends Record<string, any>,
@@ -1,13 +1,12 @@
1
+ import type { EntityCompanionDefinition, ViewerContext } from '@expo/entity';
1
2
  import {
2
3
  AlwaysAllowPrivacyPolicyRule,
3
4
  DateField,
4
5
  Entity,
5
- EntityCompanionDefinition,
6
6
  EntityConfiguration,
7
7
  EntityPrivacyPolicy,
8
8
  StringField,
9
9
  UUIDField,
10
- ViewerContext,
11
10
  } from '@expo/entity';
12
11
 
13
12
  export type LocalMemoryTestEntityFields = {
@@ -1,13 +1,10 @@
1
- import {
2
- EntityCompanionProvider,
3
- IEntityMetricsAdapter,
4
- NoOpEntityMetricsAdapter,
5
- } from '@expo/entity';
1
+ import type { IEntityMetricsAdapter } from '@expo/entity';
2
+ import { EntityCompanionProvider, NoOpEntityMetricsAdapter } from '@expo/entity';
6
3
  import { StubDatabaseAdapterProvider, StubQueryContextProvider } from '@expo/entity-testing-utils';
7
4
  import { TTLCache } from '@isaacs/ttlcache';
8
5
 
9
- import { ILocalMemoryCache, LocalMemoryCacheValue } from '../GenericLocalMemoryCacher';
10
- import { LocalMemoryCacheAdapterProvider } from '../LocalMemoryCacheAdapterProvider';
6
+ import type { ILocalMemoryCache, LocalMemoryCacheValue } from '../GenericLocalMemoryCacher.ts';
7
+ import { LocalMemoryCacheAdapterProvider } from '../LocalMemoryCacheAdapterProvider.ts';
11
8
 
12
9
  const queryContextProvider = new StubQueryContextProvider();
13
10
 
@@ -1,7 +1,6 @@
1
+ import type { GenericEntityCacheAdapter, IEntityGenericCacher } from '@expo/entity';
1
2
  import {
2
3
  CacheStatus,
3
- GenericEntityCacheAdapter,
4
- IEntityGenericCacher,
5
4
  SingleFieldHolder,
6
5
  SingleFieldValueHolder,
7
6
  ViewerContext,
@@ -9,16 +8,14 @@ import {
9
8
  import { describe, expect, it } from '@jest/globals';
10
9
  import { v4 as uuidv4 } from 'uuid';
11
10
 
12
- import { GenericLocalMemoryCacher } from '../GenericLocalMemoryCacher';
13
- import { LocalMemoryCacheAdapterProvider } from '../LocalMemoryCacheAdapterProvider';
14
- import {
15
- LocalMemoryTestEntity,
16
- LocalMemoryTestEntityFields,
17
- } from '../__testfixtures__/LocalMemoryTestEntity';
11
+ import { GenericLocalMemoryCacher } from '../GenericLocalMemoryCacher.ts';
12
+ import type { LocalMemoryCacheAdapterProvider } from '../LocalMemoryCacheAdapterProvider.ts';
13
+ import type { LocalMemoryTestEntityFields } from '../__testfixtures__/LocalMemoryTestEntity.ts';
14
+ import { LocalMemoryTestEntity } from '../__testfixtures__/LocalMemoryTestEntity.ts';
18
15
  import {
19
16
  createLocalMemoryTestEntityCompanionProvider,
20
17
  createNoOpLocalMemoryIntegrationTestEntityCompanionProvider,
21
- } from '../__testfixtures__/createLocalMemoryTestEntityCompanionProvider';
18
+ } from '../__testfixtures__/createLocalMemoryTestEntityCompanionProvider.ts';
22
19
 
23
20
  describe(GenericLocalMemoryCacher, () => {
24
21
  it('has correct caching behavior', async () => {
@@ -10,12 +10,11 @@ import {
10
10
  import { TTLCache } from '@isaacs/ttlcache';
11
11
  import { describe, expect, it } from '@jest/globals';
12
12
 
13
+ import type { ILocalMemoryCache, LocalMemoryCacheValue } from '../GenericLocalMemoryCacher.ts';
13
14
  import {
14
15
  DOES_NOT_EXIST_LOCAL_MEMORY_CACHE,
15
16
  GenericLocalMemoryCacher,
16
- ILocalMemoryCache,
17
- LocalMemoryCacheValue,
18
- } from '../GenericLocalMemoryCacher';
17
+ } from '../GenericLocalMemoryCacher.ts';
19
18
 
20
19
  type BlahFields = {
21
20
  id: string;
package/src/index.ts CHANGED
@@ -4,5 +4,5 @@
4
4
  * @module @expo/entity-cache-adapter-local-memory
5
5
  */
6
6
 
7
- export * from './GenericLocalMemoryCacher';
8
- export * from './LocalMemoryCacheAdapterProvider';
7
+ export * from './GenericLocalMemoryCacher.ts';
8
+ export * from './LocalMemoryCacheAdapterProvider.ts';
@@ -1 +0,0 @@
1
- {"version":3,"file":"GenericLocalMemoryCacher.js","sourceRoot":"","sources":["../../src/GenericLocalMemoryCacher.ts"],"names":[],"mappings":";;;AAAA,yCAOsB;AAEtB,+EAA+E;AAC/E,qEAAqE;AACxD,QAAA,iCAAiC,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AAoCxE,MAAa,wBAAwB;IAKhB;IACA;IAFnB,YACmB,mBAA2D,EAC3D,gBAA4C;QAD5C,wBAAmB,GAAnB,mBAAmB,CAAwC;QAC3D,qBAAgB,GAAhB,gBAAgB,CAA4B;IAC5D,CAAC;IAEJ,MAAM,CAAC,eAAe;QACpB,OAAO;YACL,GAAG,CAAC,IAAY;gBACd,OAAO,SAAS,CAAC;YACnB,CAAC;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vB,OAAO,IAAI,+BAA+B,CAAC,GAAwC,EAAE,CACnF,mDAAwB,CAAC,eAAe,EAAW,CACpD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,8BAA8B,CACnC,YAAqC;QAErC,OAAO,IAAI,+BAA+B,CAAC,YAAY,CAAC,CAAC;IAC3D,CAAC;IAEgB,0BAA0B,GAAG,IAAI,GAAG,EAGlD,CAAC;IAEJ,YAAqC,uBAAgD;QAAhD,4BAAuB,GAAvB,uBAAuB,CAAyB;IAAG,CAAC;IAElF,eAAe,CACpB,mBAA2D;QAE3D,OAAO,IAAA,wBAAe,EAAC,IAAI,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,SAAS,EAAE,GAAG,EAAE;YAC1F,MAAM,gBAAgB,GAAG,IAAI,CAAC,uBAAuB,EAAW,CAAC;YACjE,OAAO,IAAI,kCAAyB,CAClC,IAAI,mDAAwB,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CACpE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AApCD,0EAoCC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC;;;GAGG;;;;;;;;;;;;;;;;AAEH,6DAA2C;AAC3C,oEAAkD"}