@arcteryx/js-cms
Advanced tools
Comparing version 1.27.8 to 1.27.9
@@ -6,2 +6,10 @@ # Change Log | ||
## [1.27.9](https://bitbucket.org/arcteryx/arcteryx-js-helpers/compare/@arcteryx/js-cms@1.27.5...@arcteryx/js-cms@1.27.9) (2020-02-06) | ||
**Note:** Version bump only for package @arcteryx/js-cms | ||
## [1.27.8](https://bitbucket.org/arcteryx/arcteryx-js-helpers/compare/@arcteryx/js-cms@1.27.5...@arcteryx/js-cms@1.27.8) (2020-02-06) | ||
@@ -8,0 +16,0 @@ |
@@ -1,4 +0,4 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -22,6 +22,6 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
return function() { | ||
var self = this, | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
args = arguments; | ||
return new Promise(function(resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
@@ -56,13 +56,16 @@ | ||
function toQueryParams(obj) { | ||
var url = Object.keys(obj).map(function (x) { | ||
if (Array.isArray(obj[x])) { | ||
return obj[x].map(function (i) { | ||
return "".concat(encodeURIComponent(x), "=").concat(encodeURIComponent(i)); | ||
}).join("&"); | ||
} | ||
var url = Object.keys(obj) | ||
.map(function(x) { | ||
if (Array.isArray(obj[x])) { | ||
return obj[x] | ||
.map(function(i) { | ||
return "".concat(encodeURIComponent(x), "=").concat(encodeURIComponent(i)); | ||
}) | ||
.join("&"); | ||
} | ||
return "".concat(encodeURIComponent(x), "=").concat(encodeURIComponent(obj[x])); | ||
}).join("&"); | ||
return "".concat(encodeURIComponent(x), "=").concat(encodeURIComponent(obj[x])); | ||
}) | ||
.join("&"); | ||
return url; | ||
@@ -86,9 +89,12 @@ } | ||
returnObject[key] = item.relationships[key].data.map(function (related) { | ||
returnObject[key] = item.relationships[key].data.map(function(related) { | ||
// 6) call getAttributes on the real entity object, put the results into the new member on the return object (from 3) | ||
if (typeof included !== "undefined" && related !== null) { | ||
return flattenCMSJson( // 5) get the real entity object from the "included" array | ||
included.filter(function (include) { | ||
return related.id === include.id; | ||
})[0], included); | ||
return flattenCMSJson( | ||
// 5) get the real entity object from the "included" array | ||
included.filter(function(include) { | ||
return related.id === include.id; | ||
})[0], | ||
included | ||
); | ||
} | ||
@@ -110,9 +116,13 @@ }); | ||
"filter[field_allowed_countries]": country.toUpperCase(), | ||
"fields[node--simple_page]": "title,field_meta_page_title,field_meta_page_description,field_simple_page_sections,field_simple_page_breadcrumbs,field_simple_page_title,field_share_image", | ||
include: "field_simple_page_sections,field_simple_page_title,field_simple_page_sections.field_simple_blocks,field_simple_page_sections.field_simple_blocks.field_background_image,field_simple_page_sections.field_simple_blocks.field_cta,field_share_image", | ||
"fields[paragraph--simple_page_section]": "field_simple_page_section_header,field_simple_page_section_layout,field_simple_blocks", | ||
"fields[node--simple_block]": "title,field_background_image_x_focal,field_background_image_y_focal,field_content_align_x,field_content_align_y,field_header_text,field_header_svg,field_sub_header_text,field_video_link,field_video_background,field_background_image,field_cta,field_raw", | ||
"fields[node--simple_page]": | ||
"title,field_meta_page_title,field_meta_page_description,field_simple_page_sections,field_simple_page_breadcrumbs,field_simple_page_title,field_share_image", | ||
include: | ||
"field_simple_page_sections,field_simple_page_title,field_simple_page_sections.field_simple_blocks,field_simple_page_sections.field_simple_blocks.field_background_image,field_simple_page_sections.field_simple_blocks.field_cta,field_share_image", | ||
"fields[paragraph--simple_page_section]": | ||
"field_simple_page_section_header,field_simple_page_section_layout,field_simple_blocks", | ||
"fields[node--simple_block]": | ||
"title,field_background_image_x_focal,field_background_image_y_focal,field_content_align_x,field_content_align_y,field_header_text,field_header_svg,field_sub_header_text,field_video_link,field_video_background,field_background_image,field_cta,field_raw", | ||
"fields[file--file]": "uri", | ||
"fields[paragraph--cta]": "field_link,field_style", | ||
"fields[node--reusable_string]": "field_reusable_string_text" | ||
"fields[node--reusable_string]": "field_reusable_string_text", | ||
}); | ||
@@ -124,3 +134,3 @@ } | ||
"filter[title]": title, | ||
"fields[node--basic_block]": "title,field_basic_content,field_css_class_names" | ||
"fields[node--basic_block]": "title,field_basic_content,field_css_class_names", | ||
}); | ||
@@ -148,3 +158,2 @@ } | ||
function GetDrupalData(_x) { | ||
@@ -166,33 +175,39 @@ return _GetDrupalData.apply(this, arguments); | ||
_GetDrupalData = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee(fetchUrl) { | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return fetch(fetchUrl).then(function (resp) { | ||
return resp.json(); | ||
}).then(function (json) { | ||
var _json$data; | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee(fetchUrl) { | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch ((_context.prev = _context.next)) { | ||
case 0: | ||
_context.next = 2; | ||
return fetch(fetchUrl) | ||
.then(function(resp) { | ||
return resp.json(); | ||
}) | ||
.then(function(json) { | ||
var _json$data; | ||
return (_json$data = json.data) === null || _json$data === void 0 ? void 0 : _json$data.map(function (label) { | ||
return flattenCMSJson(label, json.included); | ||
}); | ||
})["catch"](function (e) { | ||
console.error("Error retrieving data from CMS"); | ||
console.error(e.message); | ||
return null; | ||
}); | ||
return (_json$data = json.data) === null || _json$data === void 0 | ||
? void 0 | ||
: _json$data.map(function(label) { | ||
return flattenCMSJson(label, json.included); | ||
}); | ||
}) | ||
["catch"](function(e) { | ||
console.error("Error retrieving data from CMS"); | ||
console.error(e.message); | ||
return null; | ||
}); | ||
case 2: | ||
return _context.abrupt("return", _context.sent); | ||
case 2: | ||
return _context.abrupt("return", _context.sent); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
}, _callee); | ||
}) | ||
); | ||
return _GetDrupalData.apply(this, arguments); | ||
@@ -215,23 +230,24 @@ } | ||
_GetSimplePage = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee2(cmsUrl, market, country, language, path) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/simple_page/?"); | ||
_context2.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForSimplePages(market, country, path)); | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee2(cmsUrl, market, country, language, path) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch ((_context2.prev = _context2.next)) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/simple_page/?"); | ||
_context2.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForSimplePages(market, country, path)); | ||
case 3: | ||
return _context2.abrupt("return", _context2.sent); | ||
case 3: | ||
return _context2.abrupt("return", _context2.sent); | ||
case 4: | ||
case "end": | ||
return _context2.stop(); | ||
case 4: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
} | ||
}, _callee2); | ||
})); | ||
}, _callee2); | ||
}) | ||
); | ||
return _GetSimplePage.apply(this, arguments); | ||
@@ -254,23 +270,24 @@ } | ||
_GetBasicBlock = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee3(cmsUrl, title, language) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/basic_block/?"); | ||
_context3.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForBasicBlock(title)); | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee3(cmsUrl, title, language) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch ((_context3.prev = _context3.next)) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/basic_block/?"); | ||
_context3.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForBasicBlock(title)); | ||
case 3: | ||
return _context3.abrupt("return", _context3.sent); | ||
case 3: | ||
return _context3.abrupt("return", _context3.sent); | ||
case 4: | ||
case "end": | ||
return _context3.stop(); | ||
case 4: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
} | ||
}, _callee3); | ||
})); | ||
}, _callee3); | ||
}) | ||
); | ||
return _GetBasicBlock.apply(this, arguments); | ||
@@ -296,23 +313,24 @@ } | ||
_GetReusableData = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee4(cmsUrl, stringsArray, language) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/reusable_string/?"); | ||
_context4.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForReusableString(stringsArray)); | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee4(cmsUrl, stringsArray, language) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch ((_context4.prev = _context4.next)) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/reusable_string/?"); | ||
_context4.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForReusableString(stringsArray)); | ||
case 3: | ||
return _context4.abrupt("return", _context4.sent); | ||
case 3: | ||
return _context4.abrupt("return", _context4.sent); | ||
case 4: | ||
case "end": | ||
return _context4.stop(); | ||
case 4: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
} | ||
}, _callee4); | ||
})); | ||
}, _callee4); | ||
}) | ||
); | ||
return _GetReusableData.apply(this, arguments); | ||
@@ -319,0 +337,0 @@ } |
@@ -18,6 +18,6 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
return function() { | ||
var self = this, | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
args = arguments; | ||
return new Promise(function(resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
@@ -52,13 +52,16 @@ | ||
function toQueryParams(obj) { | ||
var url = Object.keys(obj).map(function (x) { | ||
if (Array.isArray(obj[x])) { | ||
return obj[x].map(function (i) { | ||
return "".concat(encodeURIComponent(x), "=").concat(encodeURIComponent(i)); | ||
}).join("&"); | ||
} | ||
var url = Object.keys(obj) | ||
.map(function(x) { | ||
if (Array.isArray(obj[x])) { | ||
return obj[x] | ||
.map(function(i) { | ||
return "".concat(encodeURIComponent(x), "=").concat(encodeURIComponent(i)); | ||
}) | ||
.join("&"); | ||
} | ||
return "".concat(encodeURIComponent(x), "=").concat(encodeURIComponent(obj[x])); | ||
}).join("&"); | ||
return "".concat(encodeURIComponent(x), "=").concat(encodeURIComponent(obj[x])); | ||
}) | ||
.join("&"); | ||
return url; | ||
@@ -82,9 +85,12 @@ } | ||
returnObject[key] = item.relationships[key].data.map(function (related) { | ||
returnObject[key] = item.relationships[key].data.map(function(related) { | ||
// 6) call getAttributes on the real entity object, put the results into the new member on the return object (from 3) | ||
if (typeof included !== "undefined" && related !== null) { | ||
return flattenCMSJson( // 5) get the real entity object from the "included" array | ||
included.filter(function (include) { | ||
return related.id === include.id; | ||
})[0], included); | ||
return flattenCMSJson( | ||
// 5) get the real entity object from the "included" array | ||
included.filter(function(include) { | ||
return related.id === include.id; | ||
})[0], | ||
included | ||
); | ||
} | ||
@@ -106,9 +112,13 @@ }); | ||
"filter[field_allowed_countries]": country.toUpperCase(), | ||
"fields[node--simple_page]": "title,field_meta_page_title,field_meta_page_description,field_simple_page_sections,field_simple_page_breadcrumbs,field_simple_page_title,field_share_image", | ||
include: "field_simple_page_sections,field_simple_page_title,field_simple_page_sections.field_simple_blocks,field_simple_page_sections.field_simple_blocks.field_background_image,field_simple_page_sections.field_simple_blocks.field_cta,field_share_image", | ||
"fields[paragraph--simple_page_section]": "field_simple_page_section_header,field_simple_page_section_layout,field_simple_blocks", | ||
"fields[node--simple_block]": "title,field_background_image_x_focal,field_background_image_y_focal,field_content_align_x,field_content_align_y,field_header_text,field_header_svg,field_sub_header_text,field_video_link,field_video_background,field_background_image,field_cta,field_raw", | ||
"fields[node--simple_page]": | ||
"title,field_meta_page_title,field_meta_page_description,field_simple_page_sections,field_simple_page_breadcrumbs,field_simple_page_title,field_share_image", | ||
include: | ||
"field_simple_page_sections,field_simple_page_title,field_simple_page_sections.field_simple_blocks,field_simple_page_sections.field_simple_blocks.field_background_image,field_simple_page_sections.field_simple_blocks.field_cta,field_share_image", | ||
"fields[paragraph--simple_page_section]": | ||
"field_simple_page_section_header,field_simple_page_section_layout,field_simple_blocks", | ||
"fields[node--simple_block]": | ||
"title,field_background_image_x_focal,field_background_image_y_focal,field_content_align_x,field_content_align_y,field_header_text,field_header_svg,field_sub_header_text,field_video_link,field_video_background,field_background_image,field_cta,field_raw", | ||
"fields[file--file]": "uri", | ||
"fields[paragraph--cta]": "field_link,field_style", | ||
"fields[node--reusable_string]": "field_reusable_string_text" | ||
"fields[node--reusable_string]": "field_reusable_string_text", | ||
}); | ||
@@ -120,3 +130,3 @@ } | ||
"filter[title]": title, | ||
"fields[node--basic_block]": "title,field_basic_content,field_css_class_names" | ||
"fields[node--basic_block]": "title,field_basic_content,field_css_class_names", | ||
}); | ||
@@ -144,3 +154,2 @@ } | ||
function GetDrupalData(_x) { | ||
@@ -162,33 +171,39 @@ return _GetDrupalData.apply(this, arguments); | ||
_GetDrupalData = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee(fetchUrl) { | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return fetch(fetchUrl).then(function (resp) { | ||
return resp.json(); | ||
}).then(function (json) { | ||
var _json$data; | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee(fetchUrl) { | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch ((_context.prev = _context.next)) { | ||
case 0: | ||
_context.next = 2; | ||
return fetch(fetchUrl) | ||
.then(function(resp) { | ||
return resp.json(); | ||
}) | ||
.then(function(json) { | ||
var _json$data; | ||
return (_json$data = json.data) === null || _json$data === void 0 ? void 0 : _json$data.map(function (label) { | ||
return flattenCMSJson(label, json.included); | ||
}); | ||
})["catch"](function (e) { | ||
console.error("Error retrieving data from CMS"); | ||
console.error(e.message); | ||
return null; | ||
}); | ||
return (_json$data = json.data) === null || _json$data === void 0 | ||
? void 0 | ||
: _json$data.map(function(label) { | ||
return flattenCMSJson(label, json.included); | ||
}); | ||
}) | ||
["catch"](function(e) { | ||
console.error("Error retrieving data from CMS"); | ||
console.error(e.message); | ||
return null; | ||
}); | ||
case 2: | ||
return _context.abrupt("return", _context.sent); | ||
case 2: | ||
return _context.abrupt("return", _context.sent); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
}, _callee); | ||
}) | ||
); | ||
return _GetDrupalData.apply(this, arguments); | ||
@@ -211,23 +226,24 @@ } | ||
_GetSimplePage = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee2(cmsUrl, market, country, language, path) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/simple_page/?"); | ||
_context2.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForSimplePages(market, country, path)); | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee2(cmsUrl, market, country, language, path) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch ((_context2.prev = _context2.next)) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/simple_page/?"); | ||
_context2.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForSimplePages(market, country, path)); | ||
case 3: | ||
return _context2.abrupt("return", _context2.sent); | ||
case 3: | ||
return _context2.abrupt("return", _context2.sent); | ||
case 4: | ||
case "end": | ||
return _context2.stop(); | ||
case 4: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
} | ||
}, _callee2); | ||
})); | ||
}, _callee2); | ||
}) | ||
); | ||
return _GetSimplePage.apply(this, arguments); | ||
@@ -250,23 +266,24 @@ } | ||
_GetBasicBlock = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee3(cmsUrl, title, language) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/basic_block/?"); | ||
_context3.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForBasicBlock(title)); | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee3(cmsUrl, title, language) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch ((_context3.prev = _context3.next)) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/basic_block/?"); | ||
_context3.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForBasicBlock(title)); | ||
case 3: | ||
return _context3.abrupt("return", _context3.sent); | ||
case 3: | ||
return _context3.abrupt("return", _context3.sent); | ||
case 4: | ||
case "end": | ||
return _context3.stop(); | ||
case 4: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
} | ||
}, _callee3); | ||
})); | ||
}, _callee3); | ||
}) | ||
); | ||
return _GetBasicBlock.apply(this, arguments); | ||
@@ -292,23 +309,24 @@ } | ||
_GetReusableData = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee4(cmsUrl, stringsArray, language) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/reusable_string/?"); | ||
_context4.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForReusableString(stringsArray)); | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee4(cmsUrl, stringsArray, language) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch ((_context4.prev = _context4.next)) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/reusable_string/?"); | ||
_context4.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForReusableString(stringsArray)); | ||
case 3: | ||
return _context4.abrupt("return", _context4.sent); | ||
case 3: | ||
return _context4.abrupt("return", _context4.sent); | ||
case 4: | ||
case "end": | ||
return _context4.stop(); | ||
case 4: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
} | ||
}, _callee4); | ||
})); | ||
}, _callee4); | ||
}) | ||
); | ||
return _GetReusableData.apply(this, arguments); | ||
@@ -329,3 +347,11 @@ } | ||
export { flattenCMSJson, queryOptionsForSimplePages, GetDrupalData, GetSimplePage, GetBasicBlock, GetReusableData, GetReusableText }; | ||
export { | ||
flattenCMSJson, | ||
queryOptionsForSimplePages, | ||
GetDrupalData, | ||
GetSimplePage, | ||
GetBasicBlock, | ||
GetReusableData, | ||
GetReusableText, | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,6 +0,9 @@ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.ARCTERYX = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
(function(global, factory) { | ||
typeof exports === "object" && typeof module !== "undefined" | ||
? factory(exports) | ||
: typeof define === "function" && define.amd | ||
? define(["exports"], factory) | ||
: factory((global.ARCTERYX = {})); | ||
})(this, function(exports) { | ||
"use strict"; | ||
@@ -24,6 +27,6 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
return function() { | ||
var self = this, | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
args = arguments; | ||
return new Promise(function(resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
@@ -58,13 +61,16 @@ | ||
function toQueryParams(obj) { | ||
var url = Object.keys(obj).map(function (x) { | ||
if (Array.isArray(obj[x])) { | ||
return obj[x].map(function (i) { | ||
return "".concat(encodeURIComponent(x), "=").concat(encodeURIComponent(i)); | ||
}).join("&"); | ||
} | ||
var url = Object.keys(obj) | ||
.map(function(x) { | ||
if (Array.isArray(obj[x])) { | ||
return obj[x] | ||
.map(function(i) { | ||
return "".concat(encodeURIComponent(x), "=").concat(encodeURIComponent(i)); | ||
}) | ||
.join("&"); | ||
} | ||
return "".concat(encodeURIComponent(x), "=").concat(encodeURIComponent(obj[x])); | ||
}).join("&"); | ||
return "".concat(encodeURIComponent(x), "=").concat(encodeURIComponent(obj[x])); | ||
}) | ||
.join("&"); | ||
return url; | ||
@@ -88,9 +94,12 @@ } | ||
returnObject[key] = item.relationships[key].data.map(function (related) { | ||
returnObject[key] = item.relationships[key].data.map(function(related) { | ||
// 6) call getAttributes on the real entity object, put the results into the new member on the return object (from 3) | ||
if (typeof included !== "undefined" && related !== null) { | ||
return flattenCMSJson( // 5) get the real entity object from the "included" array | ||
included.filter(function (include) { | ||
return related.id === include.id; | ||
})[0], included); | ||
return flattenCMSJson( | ||
// 5) get the real entity object from the "included" array | ||
included.filter(function(include) { | ||
return related.id === include.id; | ||
})[0], | ||
included | ||
); | ||
} | ||
@@ -112,9 +121,13 @@ }); | ||
"filter[field_allowed_countries]": country.toUpperCase(), | ||
"fields[node--simple_page]": "title,field_meta_page_title,field_meta_page_description,field_simple_page_sections,field_simple_page_breadcrumbs,field_simple_page_title,field_share_image", | ||
include: "field_simple_page_sections,field_simple_page_title,field_simple_page_sections.field_simple_blocks,field_simple_page_sections.field_simple_blocks.field_background_image,field_simple_page_sections.field_simple_blocks.field_cta,field_share_image", | ||
"fields[paragraph--simple_page_section]": "field_simple_page_section_header,field_simple_page_section_layout,field_simple_blocks", | ||
"fields[node--simple_block]": "title,field_background_image_x_focal,field_background_image_y_focal,field_content_align_x,field_content_align_y,field_header_text,field_header_svg,field_sub_header_text,field_video_link,field_video_background,field_background_image,field_cta,field_raw", | ||
"fields[node--simple_page]": | ||
"title,field_meta_page_title,field_meta_page_description,field_simple_page_sections,field_simple_page_breadcrumbs,field_simple_page_title,field_share_image", | ||
include: | ||
"field_simple_page_sections,field_simple_page_title,field_simple_page_sections.field_simple_blocks,field_simple_page_sections.field_simple_blocks.field_background_image,field_simple_page_sections.field_simple_blocks.field_cta,field_share_image", | ||
"fields[paragraph--simple_page_section]": | ||
"field_simple_page_section_header,field_simple_page_section_layout,field_simple_blocks", | ||
"fields[node--simple_block]": | ||
"title,field_background_image_x_focal,field_background_image_y_focal,field_content_align_x,field_content_align_y,field_header_text,field_header_svg,field_sub_header_text,field_video_link,field_video_background,field_background_image,field_cta,field_raw", | ||
"fields[file--file]": "uri", | ||
"fields[paragraph--cta]": "field_link,field_style", | ||
"fields[node--reusable_string]": "field_reusable_string_text" | ||
"fields[node--reusable_string]": "field_reusable_string_text", | ||
}); | ||
@@ -126,3 +139,3 @@ } | ||
"filter[title]": title, | ||
"fields[node--basic_block]": "title,field_basic_content,field_css_class_names" | ||
"fields[node--basic_block]": "title,field_basic_content,field_css_class_names", | ||
}); | ||
@@ -150,3 +163,2 @@ } | ||
function GetDrupalData(_x) { | ||
@@ -168,33 +180,39 @@ return _GetDrupalData.apply(this, arguments); | ||
_GetDrupalData = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee(fetchUrl) { | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return fetch(fetchUrl).then(function (resp) { | ||
return resp.json(); | ||
}).then(function (json) { | ||
var _json$data; | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee(fetchUrl) { | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch ((_context.prev = _context.next)) { | ||
case 0: | ||
_context.next = 2; | ||
return fetch(fetchUrl) | ||
.then(function(resp) { | ||
return resp.json(); | ||
}) | ||
.then(function(json) { | ||
var _json$data; | ||
return (_json$data = json.data) === null || _json$data === void 0 ? void 0 : _json$data.map(function (label) { | ||
return flattenCMSJson(label, json.included); | ||
}); | ||
})["catch"](function (e) { | ||
console.error("Error retrieving data from CMS"); | ||
console.error(e.message); | ||
return null; | ||
}); | ||
return (_json$data = json.data) === null || _json$data === void 0 | ||
? void 0 | ||
: _json$data.map(function(label) { | ||
return flattenCMSJson(label, json.included); | ||
}); | ||
}) | ||
["catch"](function(e) { | ||
console.error("Error retrieving data from CMS"); | ||
console.error(e.message); | ||
return null; | ||
}); | ||
case 2: | ||
return _context.abrupt("return", _context.sent); | ||
case 2: | ||
return _context.abrupt("return", _context.sent); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
}, _callee); | ||
}) | ||
); | ||
return _GetDrupalData.apply(this, arguments); | ||
@@ -217,23 +235,24 @@ } | ||
_GetSimplePage = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee2(cmsUrl, market, country, language, path) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/simple_page/?"); | ||
_context2.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForSimplePages(market, country, path)); | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee2(cmsUrl, market, country, language, path) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch ((_context2.prev = _context2.next)) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/simple_page/?"); | ||
_context2.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForSimplePages(market, country, path)); | ||
case 3: | ||
return _context2.abrupt("return", _context2.sent); | ||
case 3: | ||
return _context2.abrupt("return", _context2.sent); | ||
case 4: | ||
case "end": | ||
return _context2.stop(); | ||
case 4: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
} | ||
}, _callee2); | ||
})); | ||
}, _callee2); | ||
}) | ||
); | ||
return _GetSimplePage.apply(this, arguments); | ||
@@ -256,23 +275,24 @@ } | ||
_GetBasicBlock = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee3(cmsUrl, title, language) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/basic_block/?"); | ||
_context3.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForBasicBlock(title)); | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee3(cmsUrl, title, language) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch ((_context3.prev = _context3.next)) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/basic_block/?"); | ||
_context3.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForBasicBlock(title)); | ||
case 3: | ||
return _context3.abrupt("return", _context3.sent); | ||
case 3: | ||
return _context3.abrupt("return", _context3.sent); | ||
case 4: | ||
case "end": | ||
return _context3.stop(); | ||
case 4: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
} | ||
}, _callee3); | ||
})); | ||
}, _callee3); | ||
}) | ||
); | ||
return _GetBasicBlock.apply(this, arguments); | ||
@@ -298,23 +318,24 @@ } | ||
_GetReusableData = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee4(cmsUrl, stringsArray, language) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/reusable_string/?"); | ||
_context4.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForReusableString(stringsArray)); | ||
/*#__PURE__*/ | ||
regeneratorRuntime.mark(function _callee4(cmsUrl, stringsArray, language) { | ||
var cmsApi; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch ((_context4.prev = _context4.next)) { | ||
case 0: | ||
cmsApi = "".concat(cmsUrl, "/").concat(language, "/jsonapi/node/reusable_string/?"); | ||
_context4.next = 3; | ||
return GetDrupalData(cmsApi + queryOptionsForReusableString(stringsArray)); | ||
case 3: | ||
return _context4.abrupt("return", _context4.sent); | ||
case 3: | ||
return _context4.abrupt("return", _context4.sent); | ||
case 4: | ||
case "end": | ||
return _context4.stop(); | ||
case 4: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
} | ||
}, _callee4); | ||
})); | ||
}, _callee4); | ||
}) | ||
); | ||
return _GetReusableData.apply(this, arguments); | ||
@@ -343,5 +364,4 @@ } | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@arcteryx/js-cms", | ||
"version": "1.27.8", | ||
"version": "1.27.9", | ||
"source": "src/index.js", | ||
@@ -15,3 +15,3 @@ "main": "dist/cjs/index.js", | ||
"dependencies": { | ||
"@arcteryx/js-url": "^1.27.8" | ||
"@arcteryx/js-url": "^1.27.9" | ||
}, | ||
@@ -33,3 +33,3 @@ "lint-staged": { | ||
"license": "ISC", | ||
"gitHead": "7ba99f591c4c1283535b6ee103bc3f3d2e0a836d" | ||
"gitHead": "c75f236b38d80f2a0eae1fb2a6820072d2b12e86" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
221198
3075
Updated@arcteryx/js-url@^1.27.9