@arcteryx/js-cms
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.2.0](https://bitbucket.org/arcteryx/arcteryx-js-helpers/compare/@arcteryx/js-cms@2.1.1...@arcteryx/js-cms@2.2.0) (2022-04-04) | ||
### Features | ||
* Create helper to fetch cms message by field name ([1e24324](https://bitbucket.org/arcteryx/arcteryx-js-helpers/commits/1e24324b41b2b913456ef025a23e1fa0265a59b8)) | ||
## [2.1.1](https://bitbucket.org/arcteryx/arcteryx-js-helpers/compare/@arcteryx/js-cms@2.1.0...@arcteryx/js-cms@2.1.1) (2021-12-08) | ||
@@ -8,0 +19,0 @@ |
@@ -375,3 +375,27 @@ 'use strict'; | ||
}; | ||
/** | ||
* Query CMS message content type, filtering by market, country, language and field name. | ||
* | ||
* @param {string} cmsUrl | ||
* @param {string} market | ||
* @param {string} country | ||
* @param {string} language | ||
* @param {string} messageFieldName | ||
* @returns {string|null} | ||
*/ | ||
const getCmsMessageByFieldName = async (cmsUrl, market, country, language, messageFieldName) => { | ||
var _data$0$field_content, _data$; | ||
let queryStrings = `filter[field_market]=${market}&filter[field_allowed_countries]=${country}&fields[node--message]=field_content`; | ||
if (messageFieldName) { | ||
queryStrings += `&filter[field_name]=${messageFieldName}`; | ||
} | ||
const messageUrl = `${cmsUrl}/${language}/jsonapi/node/message?${queryStrings}`; | ||
const data = await getDrupalData(messageUrl); | ||
return (_data$0$field_content = (_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.field_content.processed) !== null && _data$0$field_content !== void 0 ? _data$0$field_content : null; | ||
}; | ||
exports.GetDrupalData = GetDrupalData; | ||
@@ -385,2 +409,3 @@ exports.flattenCMSJson = flattenCMSJson; | ||
exports.getCmsApiForCategoryIntro = getCmsApiForCategoryIntro; | ||
exports.getCmsMessageByFieldName = getCmsMessageByFieldName; | ||
exports.getCsPhoneNumber = getCsPhoneNumber; | ||
@@ -387,0 +412,0 @@ exports.getDrupalData = getDrupalData; |
@@ -371,4 +371,28 @@ /** | ||
}; | ||
/** | ||
* Query CMS message content type, filtering by market, country, language and field name. | ||
* | ||
* @param {string} cmsUrl | ||
* @param {string} market | ||
* @param {string} country | ||
* @param {string} language | ||
* @param {string} messageFieldName | ||
* @returns {string|null} | ||
*/ | ||
export { GetDrupalData, flattenCMSJson, generateRequestUrls, getBasicBlock, getCategoryIntro, getCategoryIntroId, getCategoryIntroPaths, getCmsApiForCategoryIntro, getCsPhoneNumber, getDrupalData, getReusableData, getReusableText, getSimplePage, queryOptionsForBasicBlock, queryOptionsForCategoryIntros, queryOptionsForReusableString, queryOptionsForSimplePages }; | ||
const getCmsMessageByFieldName = async (cmsUrl, market, country, language, messageFieldName) => { | ||
var _data$0$field_content, _data$; | ||
let queryStrings = `filter[field_market]=${market}&filter[field_allowed_countries]=${country}&fields[node--message]=field_content`; | ||
if (messageFieldName) { | ||
queryStrings += `&filter[field_name]=${messageFieldName}`; | ||
} | ||
const messageUrl = `${cmsUrl}/${language}/jsonapi/node/message?${queryStrings}`; | ||
const data = await getDrupalData(messageUrl); | ||
return (_data$0$field_content = (_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.field_content.processed) !== null && _data$0$field_content !== void 0 ? _data$0$field_content : null; | ||
}; | ||
export { GetDrupalData, flattenCMSJson, generateRequestUrls, getBasicBlock, getCategoryIntro, getCategoryIntroId, getCategoryIntroPaths, getCmsApiForCategoryIntro, getCmsMessageByFieldName, getCsPhoneNumber, getDrupalData, getReusableData, getReusableText, getSimplePage, queryOptionsForBasicBlock, queryOptionsForCategoryIntros, queryOptionsForReusableString, queryOptionsForSimplePages }; | ||
//# sourceMappingURL=index.js.map |
@@ -382,3 +382,27 @@ (function (global, factory) { | ||
}; | ||
/** | ||
* Query CMS message content type, filtering by market, country, language and field name. | ||
* | ||
* @param {string} cmsUrl | ||
* @param {string} market | ||
* @param {string} country | ||
* @param {string} language | ||
* @param {string} messageFieldName | ||
* @returns {string|null} | ||
*/ | ||
const getCmsMessageByFieldName = async (cmsUrl, market, country, language, messageFieldName) => { | ||
var _data$0$field_content, _data$; | ||
let queryStrings = `filter[field_market]=${market}&filter[field_allowed_countries]=${country}&fields[node--message]=field_content`; | ||
if (messageFieldName) { | ||
queryStrings += `&filter[field_name]=${messageFieldName}`; | ||
} | ||
const messageUrl = `${cmsUrl}/${language}/jsonapi/node/message?${queryStrings}`; | ||
const data = await getDrupalData(messageUrl); | ||
return (_data$0$field_content = (_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.field_content.processed) !== null && _data$0$field_content !== void 0 ? _data$0$field_content : null; | ||
}; | ||
exports.GetDrupalData = GetDrupalData; | ||
@@ -392,2 +416,3 @@ exports.flattenCMSJson = flattenCMSJson; | ||
exports.getCmsApiForCategoryIntro = getCmsApiForCategoryIntro; | ||
exports.getCmsMessageByFieldName = getCmsMessageByFieldName; | ||
exports.getCsPhoneNumber = getCsPhoneNumber; | ||
@@ -394,0 +419,0 @@ exports.getDrupalData = getDrupalData; |
{ | ||
"name": "@arcteryx/js-cms", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"source": "src/index.js", | ||
@@ -32,3 +32,3 @@ "main": "dist/cjs/index.js", | ||
"license": "ISC", | ||
"gitHead": "82643c56a9881b14242aa6764845e1ae56b658aa", | ||
"gitHead": "d0a58ddc88f88a88e2d433170765cdac412ea21b", | ||
"files": [ | ||
@@ -35,0 +35,0 @@ "dist", |
@@ -359,1 +359,24 @@ import { toQueryParams } from "@arcteryx/js-url"; | ||
}; | ||
/** | ||
* Query CMS message content type, filtering by market, country, language and field name. | ||
* | ||
* @param {string} cmsUrl | ||
* @param {string} market | ||
* @param {string} country | ||
* @param {string} language | ||
* @param {string} messageFieldName | ||
* @returns {string|null} | ||
*/ | ||
export const getCmsMessageByFieldName = async (cmsUrl, market, country, language, messageFieldName) => { | ||
let queryStrings = `filter[field_market]=${market}&filter[field_allowed_countries]=${country}&fields[node--message]=field_content`; | ||
if (messageFieldName) { | ||
queryStrings += `&filter[field_name]=${messageFieldName}`; | ||
} | ||
const messageUrl = `${cmsUrl}/${language}/jsonapi/node/message?${queryStrings}`; | ||
const data = await getDrupalData(messageUrl); | ||
return data[0]?.field_content.processed ?? null; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
175679
1437