@expo/entity-cache-adapter-redis 0.60.0 → 0.62.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.
Files changed (28) hide show
  1. package/build/src/GenericRedisCacher.d.ts +1 -1
  2. package/build/src/GenericRedisCacher.js +17 -22
  3. package/build/src/RedisCacheAdapterProvider.d.ts +2 -2
  4. package/build/src/RedisCacheAdapterProvider.js +4 -9
  5. package/build/src/RedisCommon.js +4 -8
  6. package/build/src/errors/wrapNativeRedisCallAsync.js +3 -7
  7. package/build/src/index.d.ts +5 -5
  8. package/build/src/index.js +5 -22
  9. package/build/src/utils/getSurroundingCacheKeyVersionsForInvalidation.js +1 -5
  10. package/package.json +7 -6
  11. package/src/GenericRedisCacher.ts +7 -5
  12. package/src/RedisCacheAdapterProvider.ts +4 -3
  13. package/src/__integration-tests__/BatchedRedisCacheAdapter-integration-test.ts +9 -18
  14. package/src/__integration-tests__/GenericRedisCacher-full-integration-test.ts +7 -9
  15. package/src/__integration-tests__/GenericRedisCacher-integration-test.ts +6 -9
  16. package/src/__integration-tests__/errors-test.ts +5 -8
  17. package/src/__testfixtures__/RedisTestEntity.ts +1 -2
  18. package/src/__testfixtures__/createRedisIntegrationTestEntityCompanionProvider.ts +4 -7
  19. package/src/__tests__/GenericRedisCacher-test.ts +2 -2
  20. package/src/errors/__tests__/wrapNativeRedisCallAsync-test.ts +1 -1
  21. package/src/index.ts +5 -5
  22. package/src/utils/__tests__/getSurroundingCacheKeyVersionsForInvalidation-test.ts +1 -1
  23. package/build/src/GenericRedisCacher.js.map +0 -1
  24. package/build/src/RedisCacheAdapterProvider.js.map +0 -1
  25. package/build/src/RedisCommon.js.map +0 -1
  26. package/build/src/errors/wrapNativeRedisCallAsync.js.map +0 -1
  27. package/build/src/index.js.map +0 -1
  28. package/build/src/utils/getSurroundingCacheKeyVersionsForInvalidation.js.map +0 -1
@@ -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 interface IRedisTransaction {
3
3
  set(key: string, value: string, secondsToken: 'EX', seconds: number): this;
4
4
  exec(): Promise<any>;
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GenericRedisCacher = exports.RedisCacheInvalidationStrategy = void 0;
4
- const entity_1 = require("@expo/entity");
5
- const RedisCommon_1 = require("./RedisCommon");
6
- const wrapNativeRedisCallAsync_1 = require("./errors/wrapNativeRedisCallAsync");
7
- const getSurroundingCacheKeyVersionsForInvalidation_1 = require("./utils/getSurroundingCacheKeyVersionsForInvalidation");
1
+ import { CacheStatus, transformCacheObjectToFields, transformFieldsToCacheObject, } from '@expo/entity';
2
+ import { redisTransformerMap } from "./RedisCommon.js";
3
+ import { wrapNativeRedisCallAsync } from "./errors/wrapNativeRedisCallAsync.js";
4
+ import { getSurroundingCacheKeyVersionsForInvalidation } from "./utils/getSurroundingCacheKeyVersionsForInvalidation.js";
8
5
  // Sentinel value we store in Redis to negatively cache a database miss.
9
6
  // The sentinel value is distinct from any (positively) cached value.
10
7
  const DOES_NOT_EXIST_REDIS = '';
11
8
  /**
12
9
  * The strategy for generating the set of cache keys to invalidate in the Redis cache after entity mutation.
13
10
  */
14
- var RedisCacheInvalidationStrategy;
11
+ export var RedisCacheInvalidationStrategy;
15
12
  (function (RedisCacheInvalidationStrategy) {
16
13
  /**
17
14
  * Invalidate just the cache key(s) for the current cacheKeyVersion of the entity.
@@ -29,8 +26,8 @@ var RedisCacheInvalidationStrategy;
29
26
  * versions to invalidate.
30
27
  */
31
28
  RedisCacheInvalidationStrategy["CUSTOM"] = "custom";
32
- })(RedisCacheInvalidationStrategy || (exports.RedisCacheInvalidationStrategy = RedisCacheInvalidationStrategy = {}));
33
- class GenericRedisCacher {
29
+ })(RedisCacheInvalidationStrategy || (RedisCacheInvalidationStrategy = {}));
30
+ export class GenericRedisCacher {
34
31
  context;
35
32
  entityConfiguration;
36
33
  constructor(context, entityConfiguration) {
@@ -41,25 +38,25 @@ class GenericRedisCacher {
41
38
  if (keys.length === 0) {
42
39
  return new Map();
43
40
  }
44
- const redisResults = await (0, wrapNativeRedisCallAsync_1.wrapNativeRedisCallAsync)(() => this.context.redisClient.mget(...keys));
41
+ const redisResults = await wrapNativeRedisCallAsync(() => this.context.redisClient.mget(...keys));
45
42
  const results = new Map();
46
43
  for (let i = 0; i < keys.length; i++) {
47
44
  const key = keys[i];
48
45
  const redisResult = redisResults[i];
49
46
  if (redisResult === DOES_NOT_EXIST_REDIS) {
50
47
  results.set(key, {
51
- status: entity_1.CacheStatus.NEGATIVE,
48
+ status: CacheStatus.NEGATIVE,
52
49
  });
53
50
  }
54
51
  else if (redisResult) {
55
52
  results.set(key, {
56
- status: entity_1.CacheStatus.HIT,
57
- item: (0, entity_1.transformCacheObjectToFields)(this.entityConfiguration, RedisCommon_1.redisTransformerMap, JSON.parse(redisResult)),
53
+ status: CacheStatus.HIT,
54
+ item: transformCacheObjectToFields(this.entityConfiguration, redisTransformerMap, JSON.parse(redisResult)),
58
55
  });
59
56
  }
60
57
  else {
61
58
  results.set(key, {
62
- status: entity_1.CacheStatus.MISS,
59
+ status: CacheStatus.MISS,
63
60
  });
64
61
  }
65
62
  }
@@ -71,9 +68,9 @@ class GenericRedisCacher {
71
68
  }
72
69
  let redisTransaction = this.context.redisClient.multi();
73
70
  objectMap.forEach((object, key) => {
74
- redisTransaction = redisTransaction.set(key, JSON.stringify((0, entity_1.transformFieldsToCacheObject)(this.entityConfiguration, RedisCommon_1.redisTransformerMap, object)), 'EX', this.context.ttlSecondsPositive);
71
+ redisTransaction = redisTransaction.set(key, JSON.stringify(transformFieldsToCacheObject(this.entityConfiguration, redisTransformerMap, object)), 'EX', this.context.ttlSecondsPositive);
75
72
  });
76
- await (0, wrapNativeRedisCallAsync_1.wrapNativeRedisCallAsync)(() => redisTransaction.exec());
73
+ await wrapNativeRedisCallAsync(() => redisTransaction.exec());
77
74
  }
78
75
  async cacheDBMissesAsync(keys) {
79
76
  if (keys.length === 0) {
@@ -83,13 +80,13 @@ class GenericRedisCacher {
83
80
  keys.forEach((key) => {
84
81
  redisTransaction = redisTransaction.set(key, DOES_NOT_EXIST_REDIS, 'EX', this.context.ttlSecondsNegative);
85
82
  });
86
- await (0, wrapNativeRedisCallAsync_1.wrapNativeRedisCallAsync)(() => redisTransaction.exec());
83
+ await wrapNativeRedisCallAsync(() => redisTransaction.exec());
87
84
  }
88
85
  async invalidateManyAsync(keys) {
89
86
  if (keys.length === 0) {
90
87
  return;
91
88
  }
92
- await (0, wrapNativeRedisCallAsync_1.wrapNativeRedisCallAsync)(() => this.context.redisClient.del(...keys));
89
+ await wrapNativeRedisCallAsync(() => this.context.redisClient.del(...keys));
93
90
  }
94
91
  makeCacheKeyForCacheKeyVersion(key, value, cacheKeyVersion) {
95
92
  const cacheKeyType = key.getLoadMethodType();
@@ -106,7 +103,7 @@ class GenericRedisCacher {
106
103
  this.makeCacheKeyForCacheKeyVersion(key, value, this.entityConfiguration.cacheKeyVersion),
107
104
  ];
108
105
  case RedisCacheInvalidationStrategy.SURROUNDING_CACHE_KEY_VERSIONS:
109
- return (0, getSurroundingCacheKeyVersionsForInvalidation_1.getSurroundingCacheKeyVersionsForInvalidation)(this.entityConfiguration.cacheKeyVersion).map((cacheKeyVersion) => this.makeCacheKeyForCacheKeyVersion(key, value, cacheKeyVersion));
106
+ return getSurroundingCacheKeyVersionsForInvalidation(this.entityConfiguration.cacheKeyVersion).map((cacheKeyVersion) => this.makeCacheKeyForCacheKeyVersion(key, value, cacheKeyVersion));
110
107
  case RedisCacheInvalidationStrategy.CUSTOM:
111
108
  return this.context.invalidationConfig
112
109
  .cacheKeyVersionsToInvalidateFn(this.entityConfiguration.cacheKeyVersion)
@@ -114,5 +111,3 @@ class GenericRedisCacher {
114
111
  }
115
112
  }
116
113
  }
117
- exports.GenericRedisCacher = GenericRedisCacher;
118
- //# sourceMappingURL=GenericRedisCacher.js.map
@@ -1,5 +1,5 @@
1
- import { EntityConfiguration, IEntityCacheAdapter, IEntityCacheAdapterProvider } from '@expo/entity';
2
- import { GenericRedisCacheContext } from './GenericRedisCacher';
1
+ import type { EntityConfiguration, IEntityCacheAdapter, IEntityCacheAdapterProvider } from '@expo/entity';
2
+ import type { GenericRedisCacheContext } from './GenericRedisCacher.ts';
3
3
  export declare class RedisCacheAdapterProvider implements IEntityCacheAdapterProvider {
4
4
  private readonly context;
5
5
  constructor(context: GenericRedisCacheContext);
@@ -1,16 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RedisCacheAdapterProvider = void 0;
4
- const entity_1 = require("@expo/entity");
5
- const GenericRedisCacher_1 = require("./GenericRedisCacher");
6
- class RedisCacheAdapterProvider {
1
+ import { GenericEntityCacheAdapter } from '@expo/entity';
2
+ import { GenericRedisCacher } from "./GenericRedisCacher.js";
3
+ export class RedisCacheAdapterProvider {
7
4
  context;
8
5
  constructor(context) {
9
6
  this.context = context;
10
7
  }
11
8
  getCacheAdapter(entityConfiguration) {
12
- return new entity_1.GenericEntityCacheAdapter(new GenericRedisCacher_1.GenericRedisCacher(this.context, entityConfiguration));
9
+ return new GenericEntityCacheAdapter(new GenericRedisCacher(this.context, entityConfiguration));
13
10
  }
14
11
  }
15
- exports.RedisCacheAdapterProvider = RedisCacheAdapterProvider;
16
- //# sourceMappingURL=RedisCacheAdapterProvider.js.map
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.redisTransformerMap = void 0;
4
- const entity_1 = require("@expo/entity");
5
- exports.redisTransformerMap = new Map([
1
+ import { BufferField, DateField } from '@expo/entity';
2
+ export const redisTransformerMap = new Map([
6
3
  [
7
- entity_1.DateField.name,
4
+ DateField.name,
8
5
  {
9
6
  /**
10
7
  * All Redis fields are serialized to JSON before being written.
@@ -25,7 +22,7 @@ exports.redisTransformerMap = new Map([
25
22
  },
26
23
  ],
27
24
  [
28
- entity_1.BufferField.name,
25
+ BufferField.name,
29
26
  {
30
27
  /**
31
28
  * All Redis fields are serialized to JSON before being written.
@@ -46,4 +43,3 @@ exports.redisTransformerMap = new Map([
46
43
  },
47
44
  ],
48
45
  ]);
49
- //# sourceMappingURL=RedisCommon.js.map
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrapNativeRedisCallAsync = wrapNativeRedisCallAsync;
4
- const entity_1 = require("@expo/entity");
5
- async function wrapNativeRedisCallAsync(fn) {
1
+ import { EntityCacheAdapterTransientError } from '@expo/entity';
2
+ export async function wrapNativeRedisCallAsync(fn) {
6
3
  try {
7
4
  return await fn();
8
5
  }
@@ -10,11 +7,10 @@ async function wrapNativeRedisCallAsync(fn) {
10
7
  if (!(e instanceof Error)) {
11
8
  throw e;
12
9
  }
13
- const error = new entity_1.EntityCacheAdapterTransientError(e.message, e);
10
+ const error = new EntityCacheAdapterTransientError(e.message, e);
14
11
  if (e.stack) {
15
12
  error.stack = e.stack;
16
13
  }
17
14
  throw error;
18
15
  }
19
16
  }
20
- //# sourceMappingURL=wrapNativeRedisCallAsync.js.map
@@ -2,8 +2,8 @@
2
2
  * @packageDocumentation
3
3
  * @module @expo/entity-cache-adapter-redis
4
4
  */
5
- export * from './GenericRedisCacher';
6
- export * from './RedisCacheAdapterProvider';
7
- export * from './RedisCommon';
8
- export * from './errors/wrapNativeRedisCallAsync';
9
- export * from './utils/getSurroundingCacheKeyVersionsForInvalidation';
5
+ export * from './GenericRedisCacher.ts';
6
+ export * from './RedisCacheAdapterProvider.ts';
7
+ export * from './RedisCommon.ts';
8
+ export * from './errors/wrapNativeRedisCallAsync.ts';
9
+ export * from './utils/getSurroundingCacheKeyVersionsForInvalidation.ts';
@@ -1,27 +1,10 @@
1
- "use strict";
2
1
  /* eslint-disable tsdoc/syntax */
3
2
  /**
4
3
  * @packageDocumentation
5
4
  * @module @expo/entity-cache-adapter-redis
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("./GenericRedisCacher"), exports);
23
- __exportStar(require("./RedisCacheAdapterProvider"), exports);
24
- __exportStar(require("./RedisCommon"), exports);
25
- __exportStar(require("./errors/wrapNativeRedisCallAsync"), exports);
26
- __exportStar(require("./utils/getSurroundingCacheKeyVersionsForInvalidation"), exports);
27
- //# sourceMappingURL=index.js.map
6
+ export * from "./GenericRedisCacher.js";
7
+ export * from "./RedisCacheAdapterProvider.js";
8
+ export * from "./RedisCommon.js";
9
+ export * from "./errors/wrapNativeRedisCallAsync.js";
10
+ export * from "./utils/getSurroundingCacheKeyVersionsForInvalidation.js";
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSurroundingCacheKeyVersionsForInvalidation = getSurroundingCacheKeyVersionsForInvalidation;
4
- function getSurroundingCacheKeyVersionsForInvalidation(cacheKeyVersion) {
1
+ export function getSurroundingCacheKeyVersionsForInvalidation(cacheKeyVersion) {
5
2
  return [
6
3
  ...(cacheKeyVersion === 0 ? [] : [cacheKeyVersion - 1]),
7
4
  cacheKeyVersion,
8
5
  cacheKeyVersion + 1,
9
6
  ];
10
7
  }
11
- //# sourceMappingURL=getSurroundingCacheKeyVersionsForInvalidation.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/entity-cache-adapter-redis",
3
- "version": "0.60.0",
3
+ "version": "0.62.0",
4
4
  "description": "Redis cache adapter for @expo/entity",
5
5
  "files": [
6
6
  "build",
@@ -20,26 +20,27 @@
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.62.0"
32
33
  },
33
34
  "peerDependencies": {
34
35
  "ioredis": ">=5"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@expo/batcher": "1.0.0",
38
- "@expo/entity-testing-utils": "^0.60.0",
39
- "@jest/globals": "30.2.0",
39
+ "@expo/entity-testing-utils": "^0.62.0",
40
+ "@jest/globals": "30.3.0",
40
41
  "ioredis": "5.10.0",
41
42
  "ts-mockito": "2.6.1",
42
43
  "typescript": "5.9.3"
43
44
  },
44
- "gitHead": "e36dc81bd22ce92a7a11ccd1976173b464da5e76"
45
+ "gitHead": "4965cc238882982e6315beca48a68679ed45456b"
45
46
  }
@@ -1,17 +1,19 @@
1
- import {
1
+ import type {
2
2
  CacheLoadResult,
3
- CacheStatus,
4
3
  EntityConfiguration,
5
4
  IEntityGenericCacher,
6
5
  IEntityLoadKey,
7
6
  IEntityLoadValue,
7
+ } from '@expo/entity';
8
+ import {
9
+ CacheStatus,
8
10
  transformCacheObjectToFields,
9
11
  transformFieldsToCacheObject,
10
12
  } from '@expo/entity';
11
13
 
12
- import { redisTransformerMap } from './RedisCommon';
13
- import { wrapNativeRedisCallAsync } from './errors/wrapNativeRedisCallAsync';
14
- import { getSurroundingCacheKeyVersionsForInvalidation } from './utils/getSurroundingCacheKeyVersionsForInvalidation';
14
+ import { redisTransformerMap } from './RedisCommon.ts';
15
+ import { wrapNativeRedisCallAsync } from './errors/wrapNativeRedisCallAsync.ts';
16
+ import { getSurroundingCacheKeyVersionsForInvalidation } from './utils/getSurroundingCacheKeyVersionsForInvalidation.ts';
15
17
 
16
18
  // Sentinel value we store in Redis to negatively cache a database miss.
17
19
  // The sentinel value is distinct from any (positively) cached value.
@@ -1,11 +1,12 @@
1
- import {
1
+ import type {
2
2
  EntityConfiguration,
3
- GenericEntityCacheAdapter,
4
3
  IEntityCacheAdapter,
5
4
  IEntityCacheAdapterProvider,
6
5
  } from '@expo/entity';
6
+ import { GenericEntityCacheAdapter } from '@expo/entity';
7
7
 
8
- import { GenericRedisCacheContext, GenericRedisCacher } from './GenericRedisCacher';
8
+ import type { GenericRedisCacheContext } from './GenericRedisCacher.ts';
9
+ import { GenericRedisCacher } from './GenericRedisCacher.ts';
9
10
 
10
11
  export class RedisCacheAdapterProvider implements IEntityCacheAdapterProvider {
11
12
  constructor(private readonly context: GenericRedisCacheContext) {}
@@ -1,27 +1,18 @@
1
1
  import { Batcher } from '@expo/batcher';
2
- import {
3
- GenericEntityCacheAdapter,
4
- SingleFieldHolder,
5
- SingleFieldValueHolder,
6
- ViewerContext,
7
- zipToMap,
8
- } from '@expo/entity';
2
+ import type { GenericEntityCacheAdapter } from '@expo/entity';
3
+ import { SingleFieldHolder, SingleFieldValueHolder, ViewerContext, zipToMap } from '@expo/entity';
4
+ import nullthrows from '@expo/nullthrows';
9
5
  import { afterAll, beforeAll, beforeEach, describe, expect, it, jest } from '@jest/globals';
10
6
  import invariant from 'invariant';
11
- import Redis from 'ioredis';
12
- import nullthrows from 'nullthrows';
7
+ import { Redis } from 'ioredis';
13
8
  import { URL } from 'url';
14
9
  import { v4 as uuidv4 } from 'uuid';
15
10
 
16
- import {
17
- GenericRedisCacheContext,
18
- GenericRedisCacher,
19
- IRedis,
20
- IRedisTransaction,
21
- RedisCacheInvalidationStrategy,
22
- } from '../GenericRedisCacher';
23
- import { RedisTestEntity, RedisTestEntityFields } from '../__testfixtures__/RedisTestEntity';
24
- import { createRedisIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createRedisIntegrationTestEntityCompanionProvider';
11
+ import type { GenericRedisCacheContext, IRedis, IRedisTransaction } from '../GenericRedisCacher.ts';
12
+ import { GenericRedisCacher, RedisCacheInvalidationStrategy } from '../GenericRedisCacher.ts';
13
+ import type { RedisTestEntityFields } from '../__testfixtures__/RedisTestEntity.ts';
14
+ import { RedisTestEntity } from '../__testfixtures__/RedisTestEntity.ts';
15
+ import { createRedisIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createRedisIntegrationTestEntityCompanionProvider.ts';
25
16
 
26
17
  class BatchedRedis implements IRedis {
27
18
  private readonly mgetBatcher = new Batcher<string[], (string | null)[]>(
@@ -1,24 +1,22 @@
1
+ import type { GenericEntityCacheAdapter } from '@expo/entity';
1
2
  import {
2
3
  CompositeFieldHolder,
3
4
  CompositeFieldValueHolder,
4
- GenericEntityCacheAdapter,
5
5
  SingleFieldHolder,
6
6
  SingleFieldValueHolder,
7
7
  ViewerContext,
8
8
  } from '@expo/entity';
9
9
  import { enforceAsyncResult } from '@expo/results';
10
10
  import { afterAll, beforeAll, beforeEach, describe, expect, it } from '@jest/globals';
11
- import Redis from 'ioredis';
11
+ import { Redis } from 'ioredis';
12
12
  import { URL } from 'url';
13
13
  import { v4 as uuidv4 } from 'uuid';
14
14
 
15
- import {
16
- GenericRedisCacheContext,
17
- GenericRedisCacher,
18
- RedisCacheInvalidationStrategy,
19
- } from '../GenericRedisCacher';
20
- import { RedisTestEntity, RedisTestEntityFields } from '../__testfixtures__/RedisTestEntity';
21
- import { createRedisIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createRedisIntegrationTestEntityCompanionProvider';
15
+ import type { GenericRedisCacheContext } from '../GenericRedisCacher.ts';
16
+ import { GenericRedisCacher, RedisCacheInvalidationStrategy } from '../GenericRedisCacher.ts';
17
+ import type { RedisTestEntityFields } from '../__testfixtures__/RedisTestEntity.ts';
18
+ import { RedisTestEntity } from '../__testfixtures__/RedisTestEntity.ts';
19
+ import { createRedisIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createRedisIntegrationTestEntityCompanionProvider.ts';
22
20
 
23
21
  class TestViewerContext extends ViewerContext {}
24
22
 
@@ -1,19 +1,16 @@
1
1
  import { CacheStatus, ViewerContext } from '@expo/entity';
2
2
  import { afterAll, beforeAll, beforeEach, describe, expect, it } from '@jest/globals';
3
- import Redis from 'ioredis';
3
+ import { Redis } from 'ioredis';
4
4
  import { URL } from 'url';
5
5
 
6
- import {
7
- GenericRedisCacheContext,
8
- GenericRedisCacher,
9
- RedisCacheInvalidationStrategy,
10
- } from '../GenericRedisCacher';
6
+ import type { GenericRedisCacheContext } from '../GenericRedisCacher.ts';
7
+ import { GenericRedisCacher, RedisCacheInvalidationStrategy } from '../GenericRedisCacher.ts';
8
+ import type { RedisTestEntityFields } from '../__testfixtures__/RedisTestEntity.ts';
11
9
  import {
12
10
  RedisTestEntity,
13
11
  redisTestEntityConfiguration,
14
- RedisTestEntityFields,
15
- } from '../__testfixtures__/RedisTestEntity';
16
- import { createRedisIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createRedisIntegrationTestEntityCompanionProvider';
12
+ } from '../__testfixtures__/RedisTestEntity.ts';
13
+ import { createRedisIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createRedisIntegrationTestEntityCompanionProvider.ts';
17
14
 
18
15
  class TestViewerContext extends ViewerContext {}
19
16
 
@@ -1,15 +1,12 @@
1
1
  import { EntityCacheAdapterTransientError, ViewerContext } from '@expo/entity';
2
2
  import { beforeAll, beforeEach, describe, expect, it } from '@jest/globals';
3
- import Redis from 'ioredis';
3
+ import { Redis } from 'ioredis';
4
4
  import { URL } from 'url';
5
5
 
6
- import {
7
- GenericRedisCacheContext,
8
- GenericRedisCacher,
9
- RedisCacheInvalidationStrategy,
10
- } from '../GenericRedisCacher';
11
- import { RedisTestEntity } from '../__testfixtures__/RedisTestEntity';
12
- import { createRedisIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createRedisIntegrationTestEntityCompanionProvider';
6
+ import type { GenericRedisCacheContext } from '../GenericRedisCacher.ts';
7
+ import { GenericRedisCacher, RedisCacheInvalidationStrategy } from '../GenericRedisCacher.ts';
8
+ import { RedisTestEntity } from '../__testfixtures__/RedisTestEntity.ts';
9
+ import { createRedisIntegrationTestEntityCompanionProvider } from '../__testfixtures__/createRedisIntegrationTestEntityCompanionProvider.ts';
13
10
 
14
11
  class TestViewerContext extends ViewerContext {}
15
12
 
@@ -1,14 +1,13 @@
1
+ import type { EntityCompanionDefinition, ViewerContext } from '@expo/entity';
1
2
  import {
2
3
  AlwaysAllowPrivacyPolicyRule,
3
4
  BufferField,
4
5
  DateField,
5
6
  Entity,
6
- EntityCompanionDefinition,
7
7
  EntityConfiguration,
8
8
  EntityPrivacyPolicy,
9
9
  StringField,
10
10
  UUIDField,
11
- ViewerContext,
12
11
  } from '@expo/entity';
13
12
 
14
13
  export type RedisTestEntityFields = {
@@ -1,12 +1,9 @@
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
 
8
- import { GenericRedisCacheContext } from '../GenericRedisCacher';
9
- import { RedisCacheAdapterProvider } from '../RedisCacheAdapterProvider';
5
+ import type { GenericRedisCacheContext } from '../GenericRedisCacher.ts';
6
+ import { RedisCacheAdapterProvider } from '../RedisCacheAdapterProvider.ts';
10
7
 
11
8
  // share across all in calls in test to simulate postgres
12
9
  const adapterProvider = new StubDatabaseAdapterProvider();
@@ -6,10 +6,10 @@ import {
6
6
  UUIDField,
7
7
  } from '@expo/entity';
8
8
  import { describe, expect, it } from '@jest/globals';
9
- import { Pipeline, Redis } from 'ioredis';
9
+ import type { Pipeline, Redis } from 'ioredis';
10
10
  import { anything, instance, mock, verify, when } from 'ts-mockito';
11
11
 
12
- import { GenericRedisCacher, RedisCacheInvalidationStrategy } from '../GenericRedisCacher';
12
+ import { GenericRedisCacher, RedisCacheInvalidationStrategy } from '../GenericRedisCacher.ts';
13
13
 
14
14
  type BlahFields = {
15
15
  id: string;
@@ -1,7 +1,7 @@
1
1
  import { EntityCacheAdapterTransientError } from '@expo/entity';
2
2
  import { describe, expect, it } from '@jest/globals';
3
3
 
4
- import { wrapNativeRedisCallAsync } from '../wrapNativeRedisCallAsync';
4
+ import { wrapNativeRedisCallAsync } from '../wrapNativeRedisCallAsync.ts';
5
5
 
6
6
  describe(wrapNativeRedisCallAsync, () => {
7
7
  it('rethrows literals', async () => {
package/src/index.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  * @module @expo/entity-cache-adapter-redis
5
5
  */
6
6
 
7
- export * from './GenericRedisCacher';
8
- export * from './RedisCacheAdapterProvider';
9
- export * from './RedisCommon';
10
- export * from './errors/wrapNativeRedisCallAsync';
11
- export * from './utils/getSurroundingCacheKeyVersionsForInvalidation';
7
+ export * from './GenericRedisCacher.ts';
8
+ export * from './RedisCacheAdapterProvider.ts';
9
+ export * from './RedisCommon.ts';
10
+ export * from './errors/wrapNativeRedisCallAsync.ts';
11
+ export * from './utils/getSurroundingCacheKeyVersionsForInvalidation.ts';
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from '@jest/globals';
2
2
 
3
- import { getSurroundingCacheKeyVersionsForInvalidation } from '../getSurroundingCacheKeyVersionsForInvalidation';
3
+ import { getSurroundingCacheKeyVersionsForInvalidation } from '../getSurroundingCacheKeyVersionsForInvalidation.ts';
4
4
 
5
5
  describe(getSurroundingCacheKeyVersionsForInvalidation, () => {
6
6
  it('returns the correct cache key versions to invalidate', ()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AiB;QAChC,QAAQ,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,oBAAoB,EAAE,CAAC;YAC7D,KAAK,8BAA8B,CAAC,yBAAyB;gBAC3D,OAAO;oBACL,IAAI,CAAC,8BAA8B,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC;iBAC1F,CAAC;YACJ,KAAK,8BAA8B,CAAC,8BAA8B;gBAChE,OAAO,IAAA,6FAA6C,EAClD,IAAI,CAAC,mBAAmB,CAAC,eAAe,CACzC,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE,CACxB,IAAI,CAAC,8BAA8B,CAAC,GAAG,EAAE,KAAK,EAAE,eAAe,CAAC,CACjE,CAAC;YACJ,KAAK,8BAA8B,CAAC,MAAM;gBACxC,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB;qBACnC,8BAA8B,CAAC,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC;qBACxE,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE,CACvB,IAAI,CAAC,8BAA8B,CAAC,GAAG,EAAE,KAAK,EAAE,eAAe,CAAC,CACjE,CAAC;QACR,CAAC;IACH,CAAC;CACF;AA/ID,gDA+IC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"RedisCacheAdapterProvider.js","sourceRoot":"","sources":["../../src/RedisCacheAdapterProvider.ts"],"names":[],"mappings":";;;AAAA,yCAKsB;AAEtB,6DAAoF;AAEpF,MAAa,yBAAyB;IACP;IAA7B,YAA6B,OAAiC;QAAjC,YAAO,GAAP,OAAO,CAA0B;IAAG,CAAC;IAElE,eAAe,CACb,mBAA2D;QAE3D,OAAO,IAAI,kCAAyB,CAAC,IAAI,uCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAClG,CAAC;CACF;AARD,8DAQC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"RedisCommon.js","sourceRoot":"","sources":["../../src/RedisCommon.ts"],"names":[],"mappings":";;;AAAA,yCAAsD;AAEzC,QAAA,mBAAmB,GAAG,IAAI,GAAG,CAAC;IACzC;QACE,kBAAS,CAAC,IAAI;QACd;YACE;;;;;;;;;;;;;eAaG;YACH,KAAK,EAAE,CAAC,GAAS,EAAE,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,IAAI;YAChD,IAAI,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;SAChD;KACF;IACD;QACE,oBAAW,CAAC,IAAI;QAChB;YACE;;;;;;;;;;;;;eAaG;YACH,KAAK,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAC7D,IAAI,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;SAC7D;KACF;CACF,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapNativeRedisCallAsync.js","sourceRoot":"","sources":["../../../src/errors/wrapNativeRedisCallAsync.ts"],"names":[],"mappings":";;AAEA,4DAcC;AAhBD,yCAAgE;AAEzD,KAAK,UAAU,wBAAwB,CAAI,EAAoB;IACpE,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,EAAE,CAAC;YAC1B,MAAM,CAAC,CAAC;QACV,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,yCAAgC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACjE,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;YACZ,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;QACxB,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC;;;GAGG;;;;;;;;;;;;;;;;AAEH,uDAAqC;AACrC,8DAA4C;AAC5C,gDAA8B;AAC9B,oEAAkD;AAClD,wFAAsE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"getSurroundingCacheKeyVersionsForInvalidation.js","sourceRoot":"","sources":["../../../src/utils/getSurroundingCacheKeyVersionsForInvalidation.ts"],"names":[],"mappings":";;AAAA,sGAQC;AARD,SAAgB,6CAA6C,CAC3D,eAAuB;IAEvB,OAAO;QACL,GAAG,CAAC,eAAe,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC;QACvD,eAAe;QACf,eAAe,GAAG,CAAC;KACpB,CAAC;AACJ,CAAC"}