contentful-export 7.19.30 → 7.19.32

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.
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.calculateExpiryTimestamp = calculateExpiryTimestamp;
7
7
  exports.isEmbargoedAsset = isEmbargoedAsset;
8
+ exports.shouldCreateNewCacheItem = void 0;
8
9
  exports.signUrl = signUrl;
9
10
  var _jsonwebtoken = _interopRequireDefault(require("jsonwebtoken"));
10
11
  var _nodeFetch = _interopRequireDefault(require("node-fetch"));
@@ -24,10 +25,12 @@ function createAssetKey(host, accessToken, spaceId, environmentId, expiresAtMs)
24
25
  }
25
26
  });
26
27
  }
28
+ const shouldCreateNewCacheItem = (cacheItem, currentExpiresAtMs) => !cacheItem || currentExpiresAtMs - cacheItem.expiresAtMs > SIX_HOURS_IN_MS;
29
+ exports.shouldCreateNewCacheItem = shouldCreateNewCacheItem;
27
30
  async function createCachedAssetKey(host, accessToken, spaceId, environmentId, minExpiresAtMs) {
28
31
  const cacheKey = `${host}:${spaceId}:${environmentId}`;
29
32
  let cacheItem = assetKeyCache.get(cacheKey);
30
- if (!cacheItem || cacheItem.expiresAtMs < minExpiresAtMs) {
33
+ if (shouldCreateNewCacheItem(cacheItem, minExpiresAtMs)) {
31
34
  const expiresAtMs = calculateExpiryTimestamp();
32
35
  if (minExpiresAtMs > expiresAtMs) {
33
36
  throw new Error(`Cannot fetch an asset key so far in the future: ${minExpiresAtMs} > ${expiresAtMs}`);
@@ -38,7 +41,7 @@ async function createCachedAssetKey(host, accessToken, spaceId, environmentId, m
38
41
  const result = await resolvedAssetKeyPromise.json();
39
42
  cacheItem = {
40
43
  expiresAtMs,
41
- result: result
44
+ result
42
45
  };
43
46
  assetKeyCache.set(cacheKey, cacheItem);
44
47
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentful-export",
3
- "version": "7.19.30",
3
+ "version": "7.19.32",
4
4
  "description": "this tool allows you to export a space to a JSON dump",
5
5
  "main": "dist/index.js",
6
6
  "types": "types.d.ts",