contentful 9.3.3 → 9.3.4
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/dist/contentful.browser.js +79 -17
- package/dist/contentful.browser.js.map +1 -1
- package/dist/contentful.browser.min.js +3 -3
- package/dist/contentful.node.js +79 -17
- package/dist/contentful.node.js.map +1 -1
- package/dist/contentful.node.min.js +2 -2
- package/dist/es-modules/contentful.js +1 -1
- package/package.json +2 -2
package/dist/contentful.node.js
CHANGED
|
@@ -4347,6 +4347,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4347
4347
|
/* harmony import */ var fast_copy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fast-copy */ "../node_modules/fast-copy/dist/fast-copy.esm.js");
|
|
4348
4348
|
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; };
|
|
4349
4349
|
|
|
4350
|
+
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"); } }; }();
|
|
4351
|
+
|
|
4350
4352
|
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); } }
|
|
4351
4353
|
|
|
4352
4354
|
|
|
@@ -4363,32 +4365,83 @@ var isLink = function isLink(object) {
|
|
|
4363
4365
|
};
|
|
4364
4366
|
|
|
4365
4367
|
/**
|
|
4366
|
-
*
|
|
4368
|
+
* isResourceLink Function
|
|
4369
|
+
* Checks if the object has sys.type "ResourceLink"
|
|
4370
|
+
* @param object
|
|
4371
|
+
*/
|
|
4372
|
+
var isResourceLink = function isResourceLink(object) {
|
|
4373
|
+
return object && object.sys && object.sys.type === 'ResourceLink';
|
|
4374
|
+
};
|
|
4375
|
+
|
|
4376
|
+
/**
|
|
4377
|
+
* Creates a key with spaceId and a key without for entityMap
|
|
4367
4378
|
*
|
|
4368
4379
|
* @param {*} sys
|
|
4369
4380
|
* @param {String} sys.type
|
|
4370
4381
|
* @param {String} sys.id
|
|
4382
|
+
* @param {*} sys.space
|
|
4383
|
+
* @param {*} sys.space.sys
|
|
4384
|
+
* @param {String} sys.space.id
|
|
4385
|
+
* @return {string[]}
|
|
4386
|
+
*/
|
|
4387
|
+
var makeEntityMapKeys = function makeEntityMapKeys(sys) {
|
|
4388
|
+
return sys.space ? [sys.type + '!' + sys.id, sys.space.sys.id + '!' + sys.type + '!' + sys.id] : [sys.type + '!' + sys.id];
|
|
4389
|
+
};
|
|
4390
|
+
|
|
4391
|
+
/**
|
|
4392
|
+
* Looks up in entityMap
|
|
4393
|
+
*
|
|
4394
|
+
* @param entityMap
|
|
4395
|
+
* @param {*} linkData
|
|
4396
|
+
* @param {String} linkData.type
|
|
4397
|
+
* @param {String} linkData.linkType
|
|
4398
|
+
* @param {String} linkData.id
|
|
4399
|
+
* @param {String} linkData.urn
|
|
4371
4400
|
* @return {String}
|
|
4372
4401
|
*/
|
|
4373
|
-
var
|
|
4374
|
-
|
|
4402
|
+
var lookupInEntityMap = function lookupInEntityMap(entityMap, linkData) {
|
|
4403
|
+
var entryId = linkData.entryId,
|
|
4404
|
+
linkType = linkData.linkType,
|
|
4405
|
+
spaceId = linkData.spaceId;
|
|
4406
|
+
|
|
4407
|
+
if (spaceId) {
|
|
4408
|
+
return entityMap.get(spaceId + '!' + linkType + '!' + entryId);
|
|
4409
|
+
}
|
|
4410
|
+
return entityMap.get(linkType + '!' + entryId);
|
|
4375
4411
|
};
|
|
4376
4412
|
|
|
4377
4413
|
/**
|
|
4378
|
-
*
|
|
4414
|
+
* getResolvedLink Function
|
|
4379
4415
|
*
|
|
4380
|
-
* @param
|
|
4416
|
+
* @param entityMap
|
|
4381
4417
|
* @param link
|
|
4382
4418
|
* @return {undefined}
|
|
4383
4419
|
*/
|
|
4384
|
-
var
|
|
4420
|
+
var getResolvedLink = function getResolvedLink(entityMap, link) {
|
|
4385
4421
|
var _link$sys = link.sys,
|
|
4386
|
-
type = _link$sys.
|
|
4387
|
-
|
|
4422
|
+
type = _link$sys.type,
|
|
4423
|
+
linkType = _link$sys.linkType;
|
|
4424
|
+
|
|
4425
|
+
if (type === 'ResourceLink') {
|
|
4426
|
+
var urn = link.sys.urn;
|
|
4427
|
+
|
|
4428
|
+
var regExp = /.*:spaces\/([A-Za-z0-9]*)\/entries\/([A-Za-z0-9]*)/;
|
|
4429
|
+
if (!regExp.test(urn)) {
|
|
4430
|
+
return UNRESOLVED_LINK;
|
|
4431
|
+
}
|
|
4388
4432
|
|
|
4389
|
-
|
|
4433
|
+
var _urn$match = urn.match(regExp),
|
|
4434
|
+
_urn$match2 = _slicedToArray(_urn$match, 3),
|
|
4435
|
+
_ = _urn$match2[0],
|
|
4436
|
+
spaceId = _urn$match2[1],
|
|
4437
|
+
_entryId = _urn$match2[2];
|
|
4390
4438
|
|
|
4391
|
-
|
|
4439
|
+
var extractedLinkType = linkType.split(':')[1];
|
|
4440
|
+
return lookupInEntityMap(entityMap, { linkType: extractedLinkType, entryId: _entryId, spaceId: spaceId }) || UNRESOLVED_LINK;
|
|
4441
|
+
}
|
|
4442
|
+
var entryId = link.sys.id;
|
|
4443
|
+
|
|
4444
|
+
return lookupInEntityMap(entityMap, { linkType: linkType, entryId: entryId }) || UNRESOLVED_LINK;
|
|
4392
4445
|
};
|
|
4393
4446
|
|
|
4394
4447
|
/**
|
|
@@ -4416,6 +4469,7 @@ var cleanUpLinks = function cleanUpLinks(input) {
|
|
|
4416
4469
|
* @param input
|
|
4417
4470
|
* @param predicate
|
|
4418
4471
|
* @param mutator
|
|
4472
|
+
* @param removeUnresolved
|
|
4419
4473
|
* @return {*}
|
|
4420
4474
|
*/
|
|
4421
4475
|
var walkMutate = function walkMutate(input, predicate, mutator, removeUnresolved) {
|
|
@@ -4438,7 +4492,7 @@ var walkMutate = function walkMutate(input, predicate, mutator, removeUnresolved
|
|
|
4438
4492
|
};
|
|
4439
4493
|
|
|
4440
4494
|
var normalizeLink = function normalizeLink(entityMap, link, removeUnresolved) {
|
|
4441
|
-
var resolvedLink =
|
|
4495
|
+
var resolvedLink = getResolvedLink(entityMap, link);
|
|
4442
4496
|
if (resolvedLink === UNRESOLVED_LINK) {
|
|
4443
4497
|
return removeUnresolved ? resolvedLink : link;
|
|
4444
4498
|
}
|
|
@@ -4479,16 +4533,24 @@ var resolveResponse = function resolveResponse(response, options) {
|
|
|
4479
4533
|
return [].concat(_toConsumableArray(all), _toConsumableArray(response.includes[type]));
|
|
4480
4534
|
}, []);
|
|
4481
4535
|
|
|
4482
|
-
var allEntries = [].concat(_toConsumableArray(responseClone.items), _toConsumableArray(allIncludes))
|
|
4536
|
+
var allEntries = [].concat(_toConsumableArray(responseClone.items), _toConsumableArray(allIncludes)).filter(function (entity) {
|
|
4537
|
+
return Boolean(entity.sys);
|
|
4538
|
+
});
|
|
4483
4539
|
|
|
4484
|
-
var entityMap = new Map(allEntries.
|
|
4485
|
-
|
|
4486
|
-
|
|
4540
|
+
var entityMap = new Map(allEntries.reduce(function (acc, entity) {
|
|
4541
|
+
var entries = makeEntityMapKeys(entity.sys).map(function (key) {
|
|
4542
|
+
return [key, entity];
|
|
4543
|
+
});
|
|
4544
|
+
acc.push.apply(acc, _toConsumableArray(entries));
|
|
4545
|
+
return acc;
|
|
4546
|
+
}, []));
|
|
4487
4547
|
|
|
4488
4548
|
allEntries.forEach(function (item) {
|
|
4489
4549
|
var entryObject = makeEntryObject(item, options.itemEntryPoints);
|
|
4490
4550
|
|
|
4491
|
-
Object.assign(item, walkMutate(entryObject,
|
|
4551
|
+
Object.assign(item, walkMutate(entryObject, function (x) {
|
|
4552
|
+
return isLink(x) || isResourceLink(x);
|
|
4553
|
+
}, function (link) {
|
|
4492
4554
|
return normalizeLink(entityMap, link, options.removeUnresolved);
|
|
4493
4555
|
}, options.removeUnresolved));
|
|
4494
4556
|
});
|
|
@@ -10079,7 +10141,7 @@ function createClient(params) {
|
|
|
10079
10141
|
environment: 'master'
|
|
10080
10142
|
};
|
|
10081
10143
|
const config = _objectSpread(_objectSpread({}, defaultConfig), params);
|
|
10082
|
-
const userAgentHeader = Object(contentful_sdk_core__WEBPACK_IMPORTED_MODULE_1__["getUserAgentHeader"])(`contentful.js/${"9.3.
|
|
10144
|
+
const userAgentHeader = Object(contentful_sdk_core__WEBPACK_IMPORTED_MODULE_1__["getUserAgentHeader"])(`contentful.js/${"9.3.4"}`, config.application, config.integration);
|
|
10083
10145
|
config.headers = _objectSpread(_objectSpread({}, config.headers), {}, {
|
|
10084
10146
|
'Content-Type': 'application/vnd.contentful.delivery.v1+json',
|
|
10085
10147
|
'X-Contentful-User-Agent': userAgentHeader
|