contentful-resolve-response 1.9.8 → 1.9.9

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/README.md CHANGED
@@ -48,3 +48,8 @@ Note that:
48
48
 
49
49
  - Multiple links to the same resource will point to the same object
50
50
  - Circular references are possible, still!!
51
+
52
+ ## For AI Agents
53
+
54
+ <!-- Generated by seed-golden-context | Last updated: 2026-05-07 -->
55
+ If you are an AI coding agent working in this repository, read [AGENTS.md](./AGENTS.md) first. It tells you where to find architectural context, development setup, decision records, and repo-specific rules.
package/dist/cjs/index.js CHANGED
@@ -1,19 +1,22 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
8
-
9
- var _fastCopy = require('fast-copy');
10
-
11
- var _fastCopy2 = _interopRequireDefault(_fastCopy);
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
16
-
6
+ exports.default = void 0;
7
+ var _fastCopy = _interopRequireDefault(require("fast-copy"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
10
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
12
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
13
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
14
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
15
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
17
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
18
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
19
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
17
20
  var UNRESOLVED_LINK = {}; // unique object to avoid polyfill bloat using Symbol()
18
21
 
19
22
  /**
@@ -49,7 +52,6 @@ var makeEntityMapKeys = function makeEntityMapKeys(sys) {
49
52
  if (sys.space && sys.environment) {
50
53
  return [`${sys.type}!${sys.id}`, `${sys.space.sys.id}!${sys.environment.sys.id}!${sys.type}!${sys.id}`];
51
54
  }
52
-
53
55
  return [`${sys.type}!${sys.id}`];
54
56
  };
55
57
 
@@ -66,36 +68,33 @@ var makeEntityMapKeys = function makeEntityMapKeys(sys) {
66
68
  */
67
69
  var lookupInEntityMap = function lookupInEntityMap(entityMap, linkData) {
68
70
  var entryId = linkData.entryId,
69
- linkType = linkData.linkType,
70
- spaceId = linkData.spaceId,
71
- environmentId = linkData.environmentId;
72
-
73
-
71
+ linkType = linkData.linkType,
72
+ spaceId = linkData.spaceId,
73
+ environmentId = linkData.environmentId;
74
74
  if (spaceId && environmentId) {
75
75
  return entityMap.get(`${spaceId}!${environmentId}!${linkType}!${entryId}`);
76
76
  }
77
-
78
77
  return entityMap.get(`${linkType}!${entryId}`);
79
78
  };
80
-
81
79
  var getIdsFromUrn = function getIdsFromUrn(urn) {
82
80
  var regExp = /.*:spaces\/([^/]+)(?:\/environments\/([^/]+))?\/entries\/([^/]+)$/;
83
-
84
81
  if (!regExp.test(urn)) {
85
82
  return undefined;
86
83
  }
87
84
 
88
85
  // eslint-disable-next-line no-unused-vars
89
-
90
86
  var _urn$match = urn.match(regExp),
91
- _urn$match2 = _slicedToArray(_urn$match, 4),
92
- _ = _urn$match2[0],
93
- spaceId = _urn$match2[1],
94
- _urn$match2$ = _urn$match2[2],
95
- environmentId = _urn$match2$ === undefined ? 'master' : _urn$match2$,
96
- entryId = _urn$match2[3];
97
-
98
- return { spaceId, environmentId, entryId };
87
+ _urn$match2 = _slicedToArray(_urn$match, 4),
88
+ _ = _urn$match2[0],
89
+ spaceId = _urn$match2[1],
90
+ _urn$match2$ = _urn$match2[2],
91
+ environmentId = _urn$match2$ === void 0 ? 'master' : _urn$match2$,
92
+ entryId = _urn$match2[3];
93
+ return {
94
+ spaceId,
95
+ environmentId,
96
+ entryId
97
+ };
99
98
  };
100
99
 
101
100
  /**
@@ -107,23 +106,18 @@ var getIdsFromUrn = function getIdsFromUrn(urn) {
107
106
  */
108
107
  var getResolvedLink = function getResolvedLink(entityMap, link) {
109
108
  var _link$sys = link.sys,
110
- type = _link$sys.type,
111
- linkType = _link$sys.linkType;
112
-
109
+ type = _link$sys.type,
110
+ linkType = _link$sys.linkType;
113
111
  if (type === 'ResourceLink') {
114
112
  if (!linkType.startsWith('Contentful:')) {
115
113
  return link;
116
114
  }
117
-
118
115
  var urn = link.sys.urn;
119
-
120
116
  var _getIdsFromUrn = getIdsFromUrn(urn),
121
- spaceId = _getIdsFromUrn.spaceId,
122
- environmentId = _getIdsFromUrn.environmentId,
123
- _entryId = _getIdsFromUrn.entryId;
124
-
117
+ spaceId = _getIdsFromUrn.spaceId,
118
+ environmentId = _getIdsFromUrn.environmentId,
119
+ _entryId = _getIdsFromUrn.entryId;
125
120
  var extractedLinkType = linkType.split(':')[1];
126
-
127
121
  return lookupInEntityMap(entityMap, {
128
122
  linkType: extractedLinkType,
129
123
  entryId: _entryId,
@@ -131,10 +125,11 @@ var getResolvedLink = function getResolvedLink(entityMap, link) {
131
125
  environmentId
132
126
  }) || UNRESOLVED_LINK;
133
127
  }
134
-
135
128
  var entryId = link.sys.id;
136
-
137
- return lookupInEntityMap(entityMap, { linkType, entryId }) || UNRESOLVED_LINK;
129
+ return lookupInEntityMap(entityMap, {
130
+ linkType,
131
+ entryId
132
+ }) || UNRESOLVED_LINK;
138
133
  };
139
134
 
140
135
  /**
@@ -165,16 +160,15 @@ var cleanUpLinks = function cleanUpLinks(input) {
165
160
  * @param removeUnresolved
166
161
  * @return {*}
167
162
  */
168
- var walkMutate = function walkMutate(input, predicate, mutator, removeUnresolved) {
163
+ var _walkMutate = function walkMutate(input, predicate, mutator, removeUnresolved) {
169
164
  if (predicate(input)) {
170
165
  return mutator(input);
171
166
  }
172
-
173
- if (input && typeof input === 'object') {
167
+ if (input && _typeof(input) === 'object') {
174
168
  for (var key in input) {
175
169
  // eslint-disable-next-line no-prototype-builtins
176
170
  if (input.hasOwnProperty(key)) {
177
- input[key] = walkMutate(input[key], predicate, mutator, removeUnresolved);
171
+ input[key] = _walkMutate(input[key], predicate, mutator, removeUnresolved);
178
172
  }
179
173
  }
180
174
  if (removeUnresolved) {
@@ -183,7 +177,6 @@ var walkMutate = function walkMutate(input, predicate, mutator, removeUnresolved
183
177
  }
184
178
  return input;
185
179
  };
186
-
187
180
  var normalizeLink = function normalizeLink(entityMap, link, removeUnresolved) {
188
181
  var resolvedLink = getResolvedLink(entityMap, link);
189
182
  if (resolvedLink === UNRESOLVED_LINK) {
@@ -191,16 +184,13 @@ var normalizeLink = function normalizeLink(entityMap, link, removeUnresolved) {
191
184
  }
192
185
  return resolvedLink;
193
186
  };
194
-
195
187
  var makeEntryObject = function makeEntryObject(item, itemEntryPoints) {
196
188
  if (!Array.isArray(itemEntryPoints)) {
197
189
  return item;
198
190
  }
199
-
200
191
  var entryPoints = Object.keys(item).filter(function (ownKey) {
201
192
  return itemEntryPoints.indexOf(ownKey) !== -1;
202
193
  });
203
-
204
194
  return entryPoints.reduce(function (entryObj, entryPoint) {
205
195
  entryObj[entryPoint] = item[entryPoint];
206
196
  return entryObj;
@@ -221,15 +211,13 @@ var resolveResponse = function resolveResponse(response, options) {
221
211
  if (!response.items) {
222
212
  return [];
223
213
  }
224
- var responseClone = (0, _fastCopy2.default)(response);
214
+ var responseClone = (0, _fastCopy.default)(response);
225
215
  var allIncludes = Object.keys(responseClone.includes || {}).reduce(function (all, type) {
226
216
  return [].concat(_toConsumableArray(all), _toConsumableArray(responseClone.includes[type]));
227
217
  }, []);
228
-
229
218
  var allEntries = [].concat(_toConsumableArray(responseClone.items), _toConsumableArray(allIncludes)).filter(function (entity) {
230
219
  return Boolean(entity.sys);
231
220
  });
232
-
233
221
  var entityMap = new Map(allEntries.reduce(function (acc, entity) {
234
222
  var entries = makeEntityMapKeys(entity.sys).map(function (key) {
235
223
  return [key, entity];
@@ -237,19 +225,15 @@ var resolveResponse = function resolveResponse(response, options) {
237
225
  acc.push.apply(acc, _toConsumableArray(entries));
238
226
  return acc;
239
227
  }, []));
240
-
241
228
  allEntries.forEach(function (item) {
242
229
  var entryObject = makeEntryObject(item, options.itemEntryPoints);
243
-
244
- Object.assign(item, walkMutate(entryObject, function (x) {
230
+ Object.assign(item, _walkMutate(entryObject, function (x) {
245
231
  return isLink(x) || isResourceLink(x);
246
232
  }, function (link) {
247
233
  return normalizeLink(entityMap, link, options.removeUnresolved);
248
234
  }, options.removeUnresolved));
249
235
  });
250
-
251
236
  return responseClone.items;
252
237
  };
253
-
254
- exports.default = resolveResponse;
238
+ var _default = exports.default = resolveResponse;
255
239
  module.exports = exports.default;
package/dist/esm/index.js CHANGED
@@ -1,11 +1,15 @@
1
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
2
-
3
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
4
-
5
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
6
-
1
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
4
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
5
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
6
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
7
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
9
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
10
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
11
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
12
  import copy from 'fast-copy';
8
-
9
13
  var UNRESOLVED_LINK = {}; // unique object to avoid polyfill bloat using Symbol()
10
14
 
11
15
  /**
@@ -39,10 +43,9 @@ var isResourceLink = function isResourceLink(object) {
39
43
  */
40
44
  var makeEntityMapKeys = function makeEntityMapKeys(sys) {
41
45
  if (sys.space && sys.environment) {
42
- return [sys.type + '!' + sys.id, sys.space.sys.id + '!' + sys.environment.sys.id + '!' + sys.type + '!' + sys.id];
46
+ return ["".concat(sys.type, "!").concat(sys.id), "".concat(sys.space.sys.id, "!").concat(sys.environment.sys.id, "!").concat(sys.type, "!").concat(sys.id)];
43
47
  }
44
-
45
- return [sys.type + '!' + sys.id];
48
+ return ["".concat(sys.type, "!").concat(sys.id)];
46
49
  };
47
50
 
48
51
  /**
@@ -58,36 +61,33 @@ var makeEntityMapKeys = function makeEntityMapKeys(sys) {
58
61
  */
59
62
  var lookupInEntityMap = function lookupInEntityMap(entityMap, linkData) {
60
63
  var entryId = linkData.entryId,
61
- linkType = linkData.linkType,
62
- spaceId = linkData.spaceId,
63
- environmentId = linkData.environmentId;
64
-
65
-
64
+ linkType = linkData.linkType,
65
+ spaceId = linkData.spaceId,
66
+ environmentId = linkData.environmentId;
66
67
  if (spaceId && environmentId) {
67
- return entityMap.get(spaceId + '!' + environmentId + '!' + linkType + '!' + entryId);
68
+ return entityMap.get("".concat(spaceId, "!").concat(environmentId, "!").concat(linkType, "!").concat(entryId));
68
69
  }
69
-
70
- return entityMap.get(linkType + '!' + entryId);
70
+ return entityMap.get("".concat(linkType, "!").concat(entryId));
71
71
  };
72
-
73
72
  var getIdsFromUrn = function getIdsFromUrn(urn) {
74
73
  var regExp = /.*:spaces\/([^/]+)(?:\/environments\/([^/]+))?\/entries\/([^/]+)$/;
75
-
76
74
  if (!regExp.test(urn)) {
77
75
  return undefined;
78
76
  }
79
77
 
80
78
  // eslint-disable-next-line no-unused-vars
81
-
82
79
  var _urn$match = urn.match(regExp),
83
- _urn$match2 = _slicedToArray(_urn$match, 4),
84
- _ = _urn$match2[0],
85
- spaceId = _urn$match2[1],
86
- _urn$match2$ = _urn$match2[2],
87
- environmentId = _urn$match2$ === undefined ? 'master' : _urn$match2$,
88
- entryId = _urn$match2[3];
89
-
90
- return { spaceId: spaceId, environmentId: environmentId, entryId: entryId };
80
+ _urn$match2 = _slicedToArray(_urn$match, 4),
81
+ _ = _urn$match2[0],
82
+ spaceId = _urn$match2[1],
83
+ _urn$match2$ = _urn$match2[2],
84
+ environmentId = _urn$match2$ === void 0 ? 'master' : _urn$match2$,
85
+ entryId = _urn$match2[3];
86
+ return {
87
+ spaceId: spaceId,
88
+ environmentId: environmentId,
89
+ entryId: entryId
90
+ };
91
91
  };
92
92
 
93
93
  /**
@@ -99,23 +99,18 @@ var getIdsFromUrn = function getIdsFromUrn(urn) {
99
99
  */
100
100
  var getResolvedLink = function getResolvedLink(entityMap, link) {
101
101
  var _link$sys = link.sys,
102
- type = _link$sys.type,
103
- linkType = _link$sys.linkType;
104
-
102
+ type = _link$sys.type,
103
+ linkType = _link$sys.linkType;
105
104
  if (type === 'ResourceLink') {
106
105
  if (!linkType.startsWith('Contentful:')) {
107
106
  return link;
108
107
  }
109
-
110
108
  var urn = link.sys.urn;
111
-
112
109
  var _getIdsFromUrn = getIdsFromUrn(urn),
113
- spaceId = _getIdsFromUrn.spaceId,
114
- environmentId = _getIdsFromUrn.environmentId,
115
- _entryId = _getIdsFromUrn.entryId;
116
-
110
+ spaceId = _getIdsFromUrn.spaceId,
111
+ environmentId = _getIdsFromUrn.environmentId,
112
+ _entryId = _getIdsFromUrn.entryId;
117
113
  var extractedLinkType = linkType.split(':')[1];
118
-
119
114
  return lookupInEntityMap(entityMap, {
120
115
  linkType: extractedLinkType,
121
116
  entryId: _entryId,
@@ -123,10 +118,11 @@ var getResolvedLink = function getResolvedLink(entityMap, link) {
123
118
  environmentId: environmentId
124
119
  }) || UNRESOLVED_LINK;
125
120
  }
126
-
127
121
  var entryId = link.sys.id;
128
-
129
- return lookupInEntityMap(entityMap, { linkType: linkType, entryId: entryId }) || UNRESOLVED_LINK;
122
+ return lookupInEntityMap(entityMap, {
123
+ linkType: linkType,
124
+ entryId: entryId
125
+ }) || UNRESOLVED_LINK;
130
126
  };
131
127
 
132
128
  /**
@@ -157,16 +153,15 @@ var cleanUpLinks = function cleanUpLinks(input) {
157
153
  * @param removeUnresolved
158
154
  * @return {*}
159
155
  */
160
- var walkMutate = function walkMutate(input, predicate, mutator, removeUnresolved) {
156
+ var _walkMutate = function walkMutate(input, predicate, mutator, removeUnresolved) {
161
157
  if (predicate(input)) {
162
158
  return mutator(input);
163
159
  }
164
-
165
- if (input && (typeof input === 'undefined' ? 'undefined' : _typeof(input)) === 'object') {
160
+ if (input && _typeof(input) === 'object') {
166
161
  for (var key in input) {
167
162
  // eslint-disable-next-line no-prototype-builtins
168
163
  if (input.hasOwnProperty(key)) {
169
- input[key] = walkMutate(input[key], predicate, mutator, removeUnresolved);
164
+ input[key] = _walkMutate(input[key], predicate, mutator, removeUnresolved);
170
165
  }
171
166
  }
172
167
  if (removeUnresolved) {
@@ -175,7 +170,6 @@ var walkMutate = function walkMutate(input, predicate, mutator, removeUnresolved
175
170
  }
176
171
  return input;
177
172
  };
178
-
179
173
  var normalizeLink = function normalizeLink(entityMap, link, removeUnresolved) {
180
174
  var resolvedLink = getResolvedLink(entityMap, link);
181
175
  if (resolvedLink === UNRESOLVED_LINK) {
@@ -183,16 +177,13 @@ var normalizeLink = function normalizeLink(entityMap, link, removeUnresolved) {
183
177
  }
184
178
  return resolvedLink;
185
179
  };
186
-
187
180
  var makeEntryObject = function makeEntryObject(item, itemEntryPoints) {
188
181
  if (!Array.isArray(itemEntryPoints)) {
189
182
  return item;
190
183
  }
191
-
192
184
  var entryPoints = Object.keys(item).filter(function (ownKey) {
193
185
  return itemEntryPoints.indexOf(ownKey) !== -1;
194
186
  });
195
-
196
187
  return entryPoints.reduce(function (entryObj, entryPoint) {
197
188
  entryObj[entryPoint] = item[entryPoint];
198
189
  return entryObj;
@@ -217,11 +208,9 @@ var resolveResponse = function resolveResponse(response, options) {
217
208
  var allIncludes = Object.keys(responseClone.includes || {}).reduce(function (all, type) {
218
209
  return [].concat(_toConsumableArray(all), _toConsumableArray(responseClone.includes[type]));
219
210
  }, []);
220
-
221
211
  var allEntries = [].concat(_toConsumableArray(responseClone.items), _toConsumableArray(allIncludes)).filter(function (entity) {
222
212
  return Boolean(entity.sys);
223
213
  });
224
-
225
214
  var entityMap = new Map(allEntries.reduce(function (acc, entity) {
226
215
  var entries = makeEntityMapKeys(entity.sys).map(function (key) {
227
216
  return [key, entity];
@@ -229,18 +218,14 @@ var resolveResponse = function resolveResponse(response, options) {
229
218
  acc.push.apply(acc, _toConsumableArray(entries));
230
219
  return acc;
231
220
  }, []));
232
-
233
221
  allEntries.forEach(function (item) {
234
222
  var entryObject = makeEntryObject(item, options.itemEntryPoints);
235
-
236
- Object.assign(item, walkMutate(entryObject, function (x) {
223
+ Object.assign(item, _walkMutate(entryObject, function (x) {
237
224
  return isLink(x) || isResourceLink(x);
238
225
  }, function (link) {
239
226
  return normalizeLink(entityMap, link, options.removeUnresolved);
240
227
  }, options.removeUnresolved));
241
228
  });
242
-
243
229
  return responseClone.items;
244
230
  };
245
-
246
231
  export default resolveResponse;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentful-resolve-response",
3
- "version": "1.9.8",
3
+ "version": "1.9.9",
4
4
  "description": "",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -8,7 +8,7 @@
8
8
  "scripts": {
9
9
  "build": "BABEL_ENV=cjs babel index.js -d dist/cjs/ && BABEL_ENV=esm babel index.js -d dist/esm/",
10
10
  "lint": "eslint index.js test",
11
- "test": "BABEL_ENV=cjs mocha --require babel-register 'test/**/*-test.js'",
11
+ "test": "BABEL_ENV=cjs mocha --require @babel/register 'test/**/*-test.js'",
12
12
  "test-watch": "npm run test -- --watch",
13
13
  "format:fix": "npm run format:check -- --write",
14
14
  "format:check": "prettier --check \"{*.js,**/*.js,*.ts,**/*.ts,*.json,**/*.json}\"",
@@ -26,21 +26,21 @@
26
26
  "fast-copy": "^3.0.2"
27
27
  },
28
28
  "devDependencies": {
29
- "@commitlint/cli": "^20.0.0",
29
+ "@commitlint/cli": "^21.0.0",
30
30
  "@commitlint/config-conventional": "^18.0.0",
31
31
  "@eslint/js": "^10.0.1",
32
32
  "@semantic-release/changelog": "^6.0.1",
33
33
  "@semantic-release/git": "^10.0.1",
34
- "babel-cli": "^6.26.0",
34
+ "@babel/cli": "^7.0.0",
35
+ "@babel/preset-env": "^7.0.0",
36
+ "@babel/register": "^7.0.0",
35
37
  "babel-plugin-add-module-exports": "^1.0.2",
36
- "babel-preset-env": "^1.7.0",
37
- "babel-register": "^6.26.0",
38
38
  "chai": "^4.3.6",
39
39
  "dirty-chai": "^2.0.1",
40
40
  "eslint": "^10.0.0",
41
41
  "eslint-plugin-mocha": "^11.0.0",
42
42
  "husky": "^9.0.6",
43
- "lint-staged": "^16.2.6",
43
+ "lint-staged": "^17.0.2",
44
44
  "mocha": "^11.0.1",
45
45
  "prettier": "^3.0.0",
46
46
  "semantic-release": "^25.0.2"