@craftercms/content
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -42,12 +42,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -62,3 +62,7 @@ function getItem(path, config) { | ||
var requestURL = utils.composeUrl(config, config.endpoints.GET_DESCRIPTOR); | ||
return classes.SDKService.httpGet(requestURL, { url: path, crafterSite: config.site }); | ||
return classes.SDKService.httpGet(requestURL, { | ||
url: path, | ||
crafterSite: config.site, | ||
flatten: Boolean(config.flatten) | ||
}); | ||
} | ||
@@ -91,12 +95,12 @@ function getChildren(path, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -137,12 +141,12 @@ function getNavTree(path, depth, currentPageUrl, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -196,12 +200,12 @@ function urlTransform(transformerName, url, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -261,3 +265,4 @@ var systemPropMap = { | ||
dateCreated: null, | ||
dateModified: null | ||
dateModified: null, | ||
sourceMap: {} | ||
} | ||
@@ -270,10 +275,21 @@ }; | ||
Object.entries(props).forEach(function (_a) { | ||
var _b, _c; | ||
var prop = _a[0], value = _a[1]; | ||
var _b, _c, _d; | ||
if (ignoreProps.includes(prop)) { | ||
return; // continue, skip prop. | ||
} | ||
if (value === null || value === void 0 ? void 0 : value['crafter-source-content-type-id']) { | ||
// @ts-ignore | ||
parsed.craftercms.sourceMap[prop] = value['crafter-source-content-type-id']; | ||
if (typeof value.text === 'string') { | ||
value = value.text; | ||
} | ||
else if (Object.keys(value).length === 2) { | ||
// Only has `crafter-source` & `crafter-source-content-type-id`. Empty value for the actual prop. | ||
value = null; | ||
} | ||
} | ||
if (systemProps.includes(prop)) { | ||
// @ts-ignore | ||
parsed.craftercms[_b = systemPropMap[prop], (_b !== null && _b !== void 0 ? _b : prop)] = value; | ||
parsed.craftercms[(_b = systemPropMap[prop]) !== null && _b !== void 0 ? _b : prop] = value; | ||
// Is there a risk prop name that matches what's considered a system prop? | ||
@@ -289,3 +305,3 @@ // In that case, here, parsed.craftercms might not be in the target object | ||
else if (prop.endsWith('_o')) { | ||
parsed[prop] = (_d = (_c = value) === null || _c === void 0 ? void 0 : _c.item, (_d !== null && _d !== void 0 ? _d : [])); | ||
parsed[prop] = (_c = value === null || value === void 0 ? void 0 : value.item) !== null && _c !== void 0 ? _c : []; | ||
if (!Array.isArray(parsed[prop])) { | ||
@@ -295,7 +311,6 @@ parsed[prop] = [parsed[prop]]; | ||
parsed[prop] = parsed[prop].map(function (item) { | ||
var _a, _b; | ||
var key = item.key, value = item.value, component = item.component, include = item.include; | ||
if ((item.component) || (item.key && item.value)) { | ||
// Components | ||
var newComponent = __assign(__assign({ label: value }, component), { path: ((_a = key) === null || _a === void 0 ? void 0 : _a.startsWith('/')) ? key : (((_b = include) === null || _b === void 0 ? void 0 : _b.startsWith('/')) ? include : null) }); | ||
var newComponent = __assign(__assign({ label: value }, component), { path: (key === null || key === void 0 ? void 0 : key.startsWith('/')) ? key : ((include === null || include === void 0 ? void 0 : include.startsWith('/')) ? include : null) }); | ||
return parseDescriptor(newComponent); | ||
@@ -310,3 +325,3 @@ } | ||
else { | ||
parsed[prop] = (value !== null && value !== void 0 ? value : null); | ||
parsed[prop] = value !== null && value !== void 0 ? value : null; | ||
} | ||
@@ -313,0 +328,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@craftercms/classes"),require("@craftercms/utils")):"function"==typeof define&&define.amd?define("@craftercms/content",["exports","@craftercms/classes","@craftercms/utils"],factory):factory(((global=global||self).craftercms=global.craftercms||{},global.craftercms.content={}),global.craftercms.classes,global.craftercms.utils)}(this,function(exports,classes,utils){"use strict";function getItem(path,config){config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.GET_ITEM_URL);return classes.SDKService.httpGet(requestURL,{url:path,crafterSite:config.site})}function getDescriptor(path,config){config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.GET_DESCRIPTOR);return classes.SDKService.httpGet(requestURL,{url:path,crafterSite:config.site})}function getChildren(path,config){config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.GET_CHILDREN);return classes.SDKService.httpGet(requestURL,{url:path,crafterSite:config.site})}function getTree(path,depth,config){void 0===depth&&(depth=1),"object"==typeof depth&&(config=depth,depth=1),config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.GET_TREE);return classes.SDKService.httpGet(requestURL,{url:path,depth:depth,crafterSite:config.site})}var ContentStoreService={getItem:getItem,getDescriptor:getDescriptor,getChildren:getChildren,getTree:getTree};function getNavTree(path,depth,currentPageUrl,config){void 0===depth&&(depth=1),void 0===currentPageUrl&&(currentPageUrl=""),config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.GET_NAV_TREE);return classes.SDKService.httpGet(requestURL,{crafterSite:config.site,currentPageUrl:currentPageUrl,url:path,depth:depth})}function getNavBreadcrumb(path,root,config){void 0===root&&(root=""),config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.GET_BREADCRUMB);return classes.SDKService.httpGet(requestURL,{crafterSite:config.site,url:path,root:root})}var NavigationService={getNavTree:getNavTree,getNavBreadcrumb:getNavBreadcrumb};function urlTransform(transformerName,url,config){config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.TRANSFORM_URL);return classes.SDKService.httpGet(requestURL,{crafterSite:config.site,transformerName:transformerName,url:url})}var UrlTransformationService={transform:urlTransform,urlTransform:urlTransform},__assign=function(){return(__assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t}).apply(this,arguments)},systemPropMap={guid:"id",cmsId:"id",objectId:"id",localId:"path","file-name":"fileName",file__name:"fileName",placeInNav:"placeInNav","internal-name":"label",internal__name:"label","content-type":"contentTypeId",content__type:"contentTypeId",createdDate_dt:"dateCreated",lastModifiedDate_dt:"dateModified",disabled:"disabled"},ignoreProps=["orderDefault_f","merge-strategy","display-template","objectGroupId","folder-name","createdDate","lastModifiedDate","no-template-required"],systemProps=Object.keys(systemPropMap).concat(Object.values(systemPropMap));function parseDescriptor(data){if(null==data)return null;if(Array.isArray(data))return data.map(function(item){return parseDescriptor(item)});if(data.children)return parseDescriptor(function extractChildren(children){return children.flatMap(function(child){return child.children?extractChildren(child.children):child})}(data.children));if(null===data.descriptorDom&&data.descriptorUrl)throw new Error("[parseDescriptor] Invalid descriptor supplied. Did you call parseDescriptor with a `getChildren` API response? The `getChildren` API response may contain certain items that are not parsable into ContentInstances. Try a different API (getItem, getDescriptor or getTree) or filter out the metadata items which descriptorDom property has a `page` or `component` property with the content item.");return parseProps(function(data){var output=data;if(data.descriptorDom)return __assign(__assign({},data.descriptorDom.page||data.descriptorDom.component),{path:data.url});if(data.page)return data.page;if(data.component)return data.component;return output}(data),{craftercms:{id:null,path:null,label:null,contentTypeId:null,dateCreated:null,dateModified:null}})}function parseProps(props,parsed){return void 0===parsed&&(parsed={}),Object.entries(props).forEach(function(_a){var _b,_c,_d,prop=_a[0],value=_a[1];ignoreProps.includes(prop)||(systemProps.includes(prop)?parsed.craftercms[(_b=systemPropMap[prop],null!==_b&&void 0!==_b?_b:prop)]=value:prop.endsWith("_o")?(parsed[prop]=null!==(_d=null===(_c=value)||void 0===_c?void 0:_c.item)&&void 0!==_d?_d:[],Array.isArray(parsed[prop])||(parsed[prop]=[parsed[prop]]),parsed[prop]=parsed[prop].map(function(item){var _a,_b,key=item.key,value=item.value,component=item.component,include=item.include;return item.component||item.key&&item.value?parseDescriptor(__assign(__assign({label:value},component),{path:(null===(_a=key)||void 0===_a?void 0:_a.startsWith("/"))?key:(null===(_b=include)||void 0===_b?void 0:_b.startsWith("/"))?include:null})):parseProps(item)})):parsed[prop]=null!==value&&void 0!==value?value:null)}),parsed}var propsToRemove=["rootId","crafterSite","crafterPublishedDate","crafterPublishedDate_dt","inheritsFrom_smv"];exports.ContentStoreService=ContentStoreService,exports.NavigationService=NavigationService,exports.UrlTransformationService=UrlTransformationService,exports.getChildren=getChildren,exports.getDescriptor=getDescriptor,exports.getItem=getItem,exports.getNavBreadcrumb=getNavBreadcrumb,exports.getNavTree=getNavTree,exports.getTree=getTree,exports.parseDescriptor=parseDescriptor,exports.parseProps=parseProps,exports.preParseSearchResults=function preParseSearchResults(source){return Object.entries(source).forEach(function(_a){var prop=_a[0],value=_a[1];if(propsToRemove.includes(prop))delete source[prop];else if(prop.endsWith("_o")){var collection=value;Array.isArray(collection.item)||(source[prop]={item:[collection.item]}),source[prop].item.forEach(function(item,i){source[prop].item[i]=preParseSearchResults(item),item.component&&(source[prop].item[i].component=preParseSearchResults(item.component))})}}),source},exports.urlTransform=urlTransform,Object.defineProperty(exports,"__esModule",{value:!0})}); | ||
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@craftercms/classes"),require("@craftercms/utils")):"function"==typeof define&&define.amd?define("@craftercms/content",["exports","@craftercms/classes","@craftercms/utils"],factory):factory(((global=global||self).craftercms=global.craftercms||{},global.craftercms.content={}),global.craftercms.classes,global.craftercms.utils)}(this,function(exports,classes,utils){"use strict";function getItem(path,config){config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.GET_ITEM_URL);return classes.SDKService.httpGet(requestURL,{url:path,crafterSite:config.site})}function getDescriptor(path,config){config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.GET_DESCRIPTOR);return classes.SDKService.httpGet(requestURL,{url:path,crafterSite:config.site,flatten:Boolean(config.flatten)})}function getChildren(path,config){config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.GET_CHILDREN);return classes.SDKService.httpGet(requestURL,{url:path,crafterSite:config.site})}function getTree(path,depth,config){void 0===depth&&(depth=1),"object"==typeof depth&&(config=depth,depth=1),config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.GET_TREE);return classes.SDKService.httpGet(requestURL,{url:path,depth:depth,crafterSite:config.site})}var ContentStoreService={getItem:getItem,getDescriptor:getDescriptor,getChildren:getChildren,getTree:getTree};function getNavTree(path,depth,currentPageUrl,config){void 0===depth&&(depth=1),void 0===currentPageUrl&&(currentPageUrl=""),config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.GET_NAV_TREE);return classes.SDKService.httpGet(requestURL,{crafterSite:config.site,currentPageUrl:currentPageUrl,url:path,depth:depth})}function getNavBreadcrumb(path,root,config){void 0===root&&(root=""),config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.GET_BREADCRUMB);return classes.SDKService.httpGet(requestURL,{crafterSite:config.site,url:path,root:root})}var NavigationService={getNavTree:getNavTree,getNavBreadcrumb:getNavBreadcrumb};function urlTransform(transformerName,url,config){config=classes.crafterConf.mix(config);var requestURL=utils.composeUrl(config,config.endpoints.TRANSFORM_URL);return classes.SDKService.httpGet(requestURL,{crafterSite:config.site,transformerName:transformerName,url:url})}var UrlTransformationService={transform:urlTransform,urlTransform:urlTransform},__assign=function(){return(__assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t}).apply(this,arguments)},systemPropMap={guid:"id",cmsId:"id",objectId:"id",localId:"path","file-name":"fileName",file__name:"fileName",placeInNav:"placeInNav","internal-name":"label",internal__name:"label","content-type":"contentTypeId",content__type:"contentTypeId",createdDate_dt:"dateCreated",lastModifiedDate_dt:"dateModified",disabled:"disabled"},ignoreProps=["orderDefault_f","merge-strategy","display-template","objectGroupId","folder-name","createdDate","lastModifiedDate","no-template-required"],systemProps=Object.keys(systemPropMap).concat(Object.values(systemPropMap));function parseDescriptor(data){if(null==data)return null;if(Array.isArray(data))return data.map(function(item){return parseDescriptor(item)});if(data.children)return parseDescriptor(function extractChildren(children){return children.flatMap(function(child){return child.children?extractChildren(child.children):child})}(data.children));if(null===data.descriptorDom&&data.descriptorUrl)throw new Error("[parseDescriptor] Invalid descriptor supplied. Did you call parseDescriptor with a `getChildren` API response? The `getChildren` API response may contain certain items that are not parsable into ContentInstances. Try a different API (getItem, getDescriptor or getTree) or filter out the metadata items which descriptorDom property has a `page` or `component` property with the content item.");return parseProps(function(data){var output=data;if(data.descriptorDom)return __assign(__assign({},data.descriptorDom.page||data.descriptorDom.component),{path:data.url});if(data.page)return data.page;if(data.component)return data.component;return output}(data),{craftercms:{id:null,path:null,label:null,contentTypeId:null,dateCreated:null,dateModified:null,sourceMap:{}}})}function parseProps(props,parsed){return void 0===parsed&&(parsed={}),Object.entries(props).forEach(function(_a){var _b,_c,prop=_a[0],value=_a[1];ignoreProps.includes(prop)||((null===value||void 0===value?void 0:value["crafter-source-content-type-id"])&&(parsed.craftercms.sourceMap[prop]=value["crafter-source-content-type-id"],"string"==typeof value.text?value=value.text:2===Object.keys(value).length&&(value=null)),systemProps.includes(prop)?parsed.craftercms[null!==(_b=systemPropMap[prop])&&void 0!==_b?_b:prop]=value:prop.endsWith("_o")?(parsed[prop]=null!==(_c=null===value||void 0===value?void 0:value.item)&&void 0!==_c?_c:[],Array.isArray(parsed[prop])||(parsed[prop]=[parsed[prop]]),parsed[prop]=parsed[prop].map(function(item){var key=item.key,value=item.value,component=item.component,include=item.include;return item.component||item.key&&item.value?parseDescriptor(__assign(__assign({label:value},component),{path:(null===key||void 0===key?void 0:key.startsWith("/"))?key:(null===include||void 0===include?void 0:include.startsWith("/"))?include:null})):parseProps(item)})):parsed[prop]=null!==value&&void 0!==value?value:null)}),parsed}var propsToRemove=["rootId","crafterSite","crafterPublishedDate","crafterPublishedDate_dt","inheritsFrom_smv"];exports.ContentStoreService=ContentStoreService,exports.NavigationService=NavigationService,exports.UrlTransformationService=UrlTransformationService,exports.getChildren=getChildren,exports.getDescriptor=getDescriptor,exports.getItem=getItem,exports.getNavBreadcrumb=getNavBreadcrumb,exports.getNavTree=getNavTree,exports.getTree=getTree,exports.parseDescriptor=parseDescriptor,exports.parseProps=parseProps,exports.preParseSearchResults=function preParseSearchResults(source){return Object.entries(source).forEach(function(_a){var prop=_a[0],value=_a[1];if(propsToRemove.includes(prop))delete source[prop];else if(prop.endsWith("_o")){var collection=value;Array.isArray(collection.item)||(source[prop]={item:[collection.item]}),source[prop].item.forEach(function(item,i){source[prop].item[i]=preParseSearchResults(item),item.component&&(source[prop].item[i].component=preParseSearchResults(item.component))})}}),source},exports.urlTransform=urlTransform,Object.defineProperty(exports,"__esModule",{value:!0})}); |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -9,0 +8,0 @@ * This program is distributed in the hope that it will be useful, |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -9,0 +8,0 @@ * This program is distributed in the hope that it will be useful, |
@@ -5,12 +5,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -27,3 +27,7 @@ import { crafterConf, SDKService } from '@craftercms/classes'; | ||
const requestURL = composeUrl(config, config.endpoints.GET_DESCRIPTOR); | ||
return SDKService.httpGet(requestURL, { url: path, crafterSite: config.site }); | ||
return SDKService.httpGet(requestURL, { | ||
url: path, | ||
crafterSite: config.site, | ||
flatten: Boolean(config.flatten) | ||
}); | ||
} | ||
@@ -30,0 +34,0 @@ export function getChildren(path, config) { |
@@ -5,12 +5,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -17,0 +17,0 @@ import { crafterConf, SDKService } from '@craftercms/classes'; |
@@ -5,12 +5,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -17,0 +17,0 @@ import { crafterConf, SDKService } from '@craftercms/classes'; |
@@ -5,12 +5,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -70,3 +70,4 @@ const systemPropMap = { | ||
dateCreated: null, | ||
dateModified: null | ||
dateModified: null, | ||
sourceMap: {} | ||
} | ||
@@ -78,9 +79,20 @@ }; | ||
Object.entries(props).forEach(([prop, value]) => { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
if (ignoreProps.includes(prop)) { | ||
return; // continue, skip prop. | ||
} | ||
if (value === null || value === void 0 ? void 0 : value['crafter-source-content-type-id']) { | ||
// @ts-ignore | ||
parsed.craftercms.sourceMap[prop] = value['crafter-source-content-type-id']; | ||
if (typeof value.text === 'string') { | ||
value = value.text; | ||
} | ||
else if (Object.keys(value).length === 2) { | ||
// Only has `crafter-source` & `crafter-source-content-type-id`. Empty value for the actual prop. | ||
value = null; | ||
} | ||
} | ||
if (systemProps.includes(prop)) { | ||
// @ts-ignore | ||
parsed.craftercms[_a = systemPropMap[prop], (_a !== null && _a !== void 0 ? _a : prop)] = value; | ||
parsed.craftercms[(_a = systemPropMap[prop]) !== null && _a !== void 0 ? _a : prop] = value; | ||
// Is there a risk prop name that matches what's considered a system prop? | ||
@@ -96,3 +108,3 @@ // In that case, here, parsed.craftercms might not be in the target object | ||
else if (prop.endsWith('_o')) { | ||
parsed[prop] = (_c = (_b = value) === null || _b === void 0 ? void 0 : _b.item, (_c !== null && _c !== void 0 ? _c : [])); | ||
parsed[prop] = (_b = value === null || value === void 0 ? void 0 : value.item) !== null && _b !== void 0 ? _b : []; | ||
if (!Array.isArray(parsed[prop])) { | ||
@@ -102,7 +114,6 @@ parsed[prop] = [parsed[prop]]; | ||
parsed[prop] = parsed[prop].map((item) => { | ||
var _a, _b; | ||
const { key, value, component, include } = item; | ||
if ((item.component) || (item.key && item.value)) { | ||
// Components | ||
const newComponent = Object.assign(Object.assign({ label: value }, component), { path: ((_a = key) === null || _a === void 0 ? void 0 : _a.startsWith('/')) ? key : (((_b = include) === null || _b === void 0 ? void 0 : _b.startsWith('/')) ? include : null) }); | ||
const newComponent = Object.assign(Object.assign({ label: value }, component), { path: (key === null || key === void 0 ? void 0 : key.startsWith('/')) ? key : ((include === null || include === void 0 ? void 0 : include.startsWith('/')) ? include : null) }); | ||
return parseDescriptor(newComponent); | ||
@@ -117,3 +128,3 @@ } | ||
else { | ||
parsed[prop] = (value !== null && value !== void 0 ? value : null); | ||
parsed[prop] = value !== null && value !== void 0 ? value : null; | ||
} | ||
@@ -120,0 +131,0 @@ }); |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -9,0 +8,0 @@ * This program is distributed in the hope that it will be useful, |
/* | ||
* Copyright (C) 2007-2019 Crafter Software Corporation. All rights reserved. | ||
* Copyright (C) 2007-2020 Crafter Software Corporation. All Rights Reserved. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
@@ -9,0 +8,0 @@ * This program is distributed in the hope that it will be useful, |
@@ -5,12 +5,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -27,3 +27,7 @@ import { crafterConf, SDKService } from '@craftercms/classes'; | ||
var requestURL = composeUrl(config, config.endpoints.GET_DESCRIPTOR); | ||
return SDKService.httpGet(requestURL, { url: path, crafterSite: config.site }); | ||
return SDKService.httpGet(requestURL, { | ||
url: path, | ||
crafterSite: config.site, | ||
flatten: Boolean(config.flatten) | ||
}); | ||
} | ||
@@ -30,0 +34,0 @@ export function getChildren(path, config) { |
@@ -5,12 +5,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -17,0 +17,0 @@ import { crafterConf, SDKService } from '@craftercms/classes'; |
@@ -5,12 +5,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -17,0 +17,0 @@ import { crafterConf, SDKService } from '@craftercms/classes'; |
@@ -5,12 +5,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -71,3 +71,4 @@ import { __assign } from "tslib"; | ||
dateCreated: null, | ||
dateModified: null | ||
dateModified: null, | ||
sourceMap: {} | ||
} | ||
@@ -80,10 +81,21 @@ }; | ||
Object.entries(props).forEach(function (_a) { | ||
var _b, _c; | ||
var prop = _a[0], value = _a[1]; | ||
var _b, _c, _d; | ||
if (ignoreProps.includes(prop)) { | ||
return; // continue, skip prop. | ||
} | ||
if (value === null || value === void 0 ? void 0 : value['crafter-source-content-type-id']) { | ||
// @ts-ignore | ||
parsed.craftercms.sourceMap[prop] = value['crafter-source-content-type-id']; | ||
if (typeof value.text === 'string') { | ||
value = value.text; | ||
} | ||
else if (Object.keys(value).length === 2) { | ||
// Only has `crafter-source` & `crafter-source-content-type-id`. Empty value for the actual prop. | ||
value = null; | ||
} | ||
} | ||
if (systemProps.includes(prop)) { | ||
// @ts-ignore | ||
parsed.craftercms[_b = systemPropMap[prop], (_b !== null && _b !== void 0 ? _b : prop)] = value; | ||
parsed.craftercms[(_b = systemPropMap[prop]) !== null && _b !== void 0 ? _b : prop] = value; | ||
// Is there a risk prop name that matches what's considered a system prop? | ||
@@ -99,3 +111,3 @@ // In that case, here, parsed.craftercms might not be in the target object | ||
else if (prop.endsWith('_o')) { | ||
parsed[prop] = (_d = (_c = value) === null || _c === void 0 ? void 0 : _c.item, (_d !== null && _d !== void 0 ? _d : [])); | ||
parsed[prop] = (_c = value === null || value === void 0 ? void 0 : value.item) !== null && _c !== void 0 ? _c : []; | ||
if (!Array.isArray(parsed[prop])) { | ||
@@ -105,7 +117,6 @@ parsed[prop] = [parsed[prop]]; | ||
parsed[prop] = parsed[prop].map(function (item) { | ||
var _a, _b; | ||
var key = item.key, value = item.value, component = item.component, include = item.include; | ||
if ((item.component) || (item.key && item.value)) { | ||
// Components | ||
var newComponent = __assign(__assign({ label: value }, component), { path: ((_a = key) === null || _a === void 0 ? void 0 : _a.startsWith('/')) ? key : (((_b = include) === null || _b === void 0 ? void 0 : _b.startsWith('/')) ? include : null) }); | ||
var newComponent = __assign(__assign({ label: value }, component), { path: (key === null || key === void 0 ? void 0 : key.startsWith('/')) ? key : ((include === null || include === void 0 ? void 0 : include.startsWith('/')) ? include : null) }); | ||
return parseDescriptor(newComponent); | ||
@@ -120,3 +131,3 @@ } | ||
else { | ||
parsed[prop] = (value !== null && value !== void 0 ? value : null); | ||
parsed[prop] = value !== null && value !== void 0 ? value : null; | ||
} | ||
@@ -123,0 +134,0 @@ }); |
@@ -23,12 +23,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -43,3 +43,7 @@ function getItem(path, config) { | ||
const requestURL = composeUrl(config, config.endpoints.GET_DESCRIPTOR); | ||
return SDKService.httpGet(requestURL, { url: path, crafterSite: config.site }); | ||
return SDKService.httpGet(requestURL, { | ||
url: path, | ||
crafterSite: config.site, | ||
flatten: Boolean(config.flatten) | ||
}); | ||
} | ||
@@ -71,12 +75,12 @@ function getChildren(path, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -114,12 +118,12 @@ function getNavTree(path, depth = 1, currentPageUrl = '', config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -147,12 +151,12 @@ function urlTransform(transformerName, url, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -212,3 +216,4 @@ const systemPropMap = { | ||
dateCreated: null, | ||
dateModified: null | ||
dateModified: null, | ||
sourceMap: {} | ||
} | ||
@@ -220,9 +225,20 @@ }; | ||
Object.entries(props).forEach(([prop, value]) => { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
if (ignoreProps.includes(prop)) { | ||
return; // continue, skip prop. | ||
} | ||
if (value === null || value === void 0 ? void 0 : value['crafter-source-content-type-id']) { | ||
// @ts-ignore | ||
parsed.craftercms.sourceMap[prop] = value['crafter-source-content-type-id']; | ||
if (typeof value.text === 'string') { | ||
value = value.text; | ||
} | ||
else if (Object.keys(value).length === 2) { | ||
// Only has `crafter-source` & `crafter-source-content-type-id`. Empty value for the actual prop. | ||
value = null; | ||
} | ||
} | ||
if (systemProps.includes(prop)) { | ||
// @ts-ignore | ||
parsed.craftercms[_a = systemPropMap[prop], (_a !== null && _a !== void 0 ? _a : prop)] = value; | ||
parsed.craftercms[(_a = systemPropMap[prop]) !== null && _a !== void 0 ? _a : prop] = value; | ||
// Is there a risk prop name that matches what's considered a system prop? | ||
@@ -238,3 +254,3 @@ // In that case, here, parsed.craftercms might not be in the target object | ||
else if (prop.endsWith('_o')) { | ||
parsed[prop] = (_c = (_b = value) === null || _b === void 0 ? void 0 : _b.item, (_c !== null && _c !== void 0 ? _c : [])); | ||
parsed[prop] = (_b = value === null || value === void 0 ? void 0 : value.item) !== null && _b !== void 0 ? _b : []; | ||
if (!Array.isArray(parsed[prop])) { | ||
@@ -244,7 +260,6 @@ parsed[prop] = [parsed[prop]]; | ||
parsed[prop] = parsed[prop].map((item) => { | ||
var _a, _b; | ||
const { key, value, component, include } = item; | ||
if ((item.component) || (item.key && item.value)) { | ||
// Components | ||
const newComponent = Object.assign(Object.assign({ label: value }, component), { path: ((_a = key) === null || _a === void 0 ? void 0 : _a.startsWith('/')) ? key : (((_b = include) === null || _b === void 0 ? void 0 : _b.startsWith('/')) ? include : null) }); | ||
const newComponent = Object.assign(Object.assign({ label: value }, component), { path: (key === null || key === void 0 ? void 0 : key.startsWith('/')) ? key : ((include === null || include === void 0 ? void 0 : include.startsWith('/')) ? include : null) }); | ||
return parseDescriptor(newComponent); | ||
@@ -259,3 +274,3 @@ } | ||
else { | ||
parsed[prop] = (value !== null && value !== void 0 ? value : null); | ||
parsed[prop] = value !== null && value !== void 0 ? value : null; | ||
} | ||
@@ -262,0 +277,0 @@ }); |
@@ -23,12 +23,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -43,3 +43,7 @@ function getItem(path, config) { | ||
const requestURL = composeUrl(config, config.endpoints.GET_DESCRIPTOR); | ||
return SDKService.httpGet(requestURL, { url: path, crafterSite: config.site }); | ||
return SDKService.httpGet(requestURL, { | ||
url: path, | ||
crafterSite: config.site, | ||
flatten: Boolean(config.flatten) | ||
}); | ||
} | ||
@@ -71,12 +75,12 @@ function getChildren(path, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -114,12 +118,12 @@ function getNavTree(path, depth = 1, currentPageUrl = '', config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -147,12 +151,12 @@ function urlTransform(transformerName, url, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -212,3 +216,4 @@ const systemPropMap = { | ||
dateCreated: null, | ||
dateModified: null | ||
dateModified: null, | ||
sourceMap: {} | ||
} | ||
@@ -220,9 +225,20 @@ }; | ||
Object.entries(props).forEach(([prop, value]) => { | ||
var _a, _b, _c; | ||
var _a, _b; | ||
if (ignoreProps.includes(prop)) { | ||
return; // continue, skip prop. | ||
} | ||
if (value === null || value === void 0 ? void 0 : value['crafter-source-content-type-id']) { | ||
// @ts-ignore | ||
parsed.craftercms.sourceMap[prop] = value['crafter-source-content-type-id']; | ||
if (typeof value.text === 'string') { | ||
value = value.text; | ||
} | ||
else if (Object.keys(value).length === 2) { | ||
// Only has `crafter-source` & `crafter-source-content-type-id`. Empty value for the actual prop. | ||
value = null; | ||
} | ||
} | ||
if (systemProps.includes(prop)) { | ||
// @ts-ignore | ||
parsed.craftercms[_a = systemPropMap[prop], (_a !== null && _a !== void 0 ? _a : prop)] = value; | ||
parsed.craftercms[(_a = systemPropMap[prop]) !== null && _a !== void 0 ? _a : prop] = value; | ||
// Is there a risk prop name that matches what's considered a system prop? | ||
@@ -238,3 +254,3 @@ // In that case, here, parsed.craftercms might not be in the target object | ||
else if (prop.endsWith('_o')) { | ||
parsed[prop] = (_c = (_b = value) === null || _b === void 0 ? void 0 : _b.item, (_c !== null && _c !== void 0 ? _c : [])); | ||
parsed[prop] = (_b = value === null || value === void 0 ? void 0 : value.item) !== null && _b !== void 0 ? _b : []; | ||
if (!Array.isArray(parsed[prop])) { | ||
@@ -244,7 +260,6 @@ parsed[prop] = [parsed[prop]]; | ||
parsed[prop] = parsed[prop].map((item) => { | ||
var _a, _b; | ||
const { key, value, component, include } = item; | ||
if ((item.component) || (item.key && item.value)) { | ||
// Components | ||
const newComponent = Object.assign(Object.assign({ label: value }, component), { path: ((_a = key) === null || _a === void 0 ? void 0 : _a.startsWith('/')) ? key : (((_b = include) === null || _b === void 0 ? void 0 : _b.startsWith('/')) ? include : null) }); | ||
const newComponent = Object.assign(Object.assign({ label: value }, component), { path: (key === null || key === void 0 ? void 0 : key.startsWith('/')) ? key : ((include === null || include === void 0 ? void 0 : include.startsWith('/')) ? include : null) }); | ||
return parseDescriptor(newComponent); | ||
@@ -259,3 +274,3 @@ } | ||
else { | ||
parsed[prop] = (value !== null && value !== void 0 ? value : null); | ||
parsed[prop] = value !== null && value !== void 0 ? value : null; | ||
} | ||
@@ -262,0 +277,0 @@ }); |
@@ -23,12 +23,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -43,3 +43,7 @@ function getItem(path, config) { | ||
var requestURL = composeUrl(config, config.endpoints.GET_DESCRIPTOR); | ||
return SDKService.httpGet(requestURL, { url: path, crafterSite: config.site }); | ||
return SDKService.httpGet(requestURL, { | ||
url: path, | ||
crafterSite: config.site, | ||
flatten: Boolean(config.flatten) | ||
}); | ||
} | ||
@@ -72,12 +76,12 @@ function getChildren(path, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -118,12 +122,12 @@ function getNavTree(path, depth, currentPageUrl, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -177,12 +181,12 @@ function urlTransform(transformerName, url, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -242,3 +246,4 @@ var systemPropMap = { | ||
dateCreated: null, | ||
dateModified: null | ||
dateModified: null, | ||
sourceMap: {} | ||
} | ||
@@ -251,10 +256,21 @@ }; | ||
Object.entries(props).forEach(function (_a) { | ||
var _b, _c; | ||
var prop = _a[0], value = _a[1]; | ||
var _b, _c, _d; | ||
if (ignoreProps.includes(prop)) { | ||
return; // continue, skip prop. | ||
} | ||
if (value === null || value === void 0 ? void 0 : value['crafter-source-content-type-id']) { | ||
// @ts-ignore | ||
parsed.craftercms.sourceMap[prop] = value['crafter-source-content-type-id']; | ||
if (typeof value.text === 'string') { | ||
value = value.text; | ||
} | ||
else if (Object.keys(value).length === 2) { | ||
// Only has `crafter-source` & `crafter-source-content-type-id`. Empty value for the actual prop. | ||
value = null; | ||
} | ||
} | ||
if (systemProps.includes(prop)) { | ||
// @ts-ignore | ||
parsed.craftercms[_b = systemPropMap[prop], (_b !== null && _b !== void 0 ? _b : prop)] = value; | ||
parsed.craftercms[(_b = systemPropMap[prop]) !== null && _b !== void 0 ? _b : prop] = value; | ||
// Is there a risk prop name that matches what's considered a system prop? | ||
@@ -270,3 +286,3 @@ // In that case, here, parsed.craftercms might not be in the target object | ||
else if (prop.endsWith('_o')) { | ||
parsed[prop] = (_d = (_c = value) === null || _c === void 0 ? void 0 : _c.item, (_d !== null && _d !== void 0 ? _d : [])); | ||
parsed[prop] = (_c = value === null || value === void 0 ? void 0 : value.item) !== null && _c !== void 0 ? _c : []; | ||
if (!Array.isArray(parsed[prop])) { | ||
@@ -276,7 +292,6 @@ parsed[prop] = [parsed[prop]]; | ||
parsed[prop] = parsed[prop].map(function (item) { | ||
var _a, _b; | ||
var key = item.key, value = item.value, component = item.component, include = item.include; | ||
if ((item.component) || (item.key && item.value)) { | ||
// Components | ||
var newComponent = __assign(__assign({ label: value }, component), { path: ((_a = key) === null || _a === void 0 ? void 0 : _a.startsWith('/')) ? key : (((_b = include) === null || _b === void 0 ? void 0 : _b.startsWith('/')) ? include : null) }); | ||
var newComponent = __assign(__assign({ label: value }, component), { path: (key === null || key === void 0 ? void 0 : key.startsWith('/')) ? key : ((include === null || include === void 0 ? void 0 : include.startsWith('/')) ? include : null) }); | ||
return parseDescriptor(newComponent); | ||
@@ -291,3 +306,3 @@ } | ||
else { | ||
parsed[prop] = (value !== null && value !== void 0 ? value : null); | ||
parsed[prop] = value !== null && value !== void 0 ? value : null; | ||
} | ||
@@ -294,0 +309,0 @@ }); |
@@ -23,12 +23,12 @@ /* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -43,3 +43,7 @@ function getItem(path, config) { | ||
var requestURL = composeUrl(config, config.endpoints.GET_DESCRIPTOR); | ||
return SDKService.httpGet(requestURL, { url: path, crafterSite: config.site }); | ||
return SDKService.httpGet(requestURL, { | ||
url: path, | ||
crafterSite: config.site, | ||
flatten: Boolean(config.flatten) | ||
}); | ||
} | ||
@@ -72,12 +76,12 @@ function getChildren(path, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -118,12 +122,12 @@ function getNavTree(path, depth, currentPageUrl, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -177,12 +181,12 @@ function urlTransform(transformerName, url, config) { | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as published by | ||
* the Free Software Foundation. | ||
* it under the terms of the GNU Lesser General Public License version 3 | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
@@ -242,3 +246,4 @@ var systemPropMap = { | ||
dateCreated: null, | ||
dateModified: null | ||
dateModified: null, | ||
sourceMap: {} | ||
} | ||
@@ -251,10 +256,21 @@ }; | ||
Object.entries(props).forEach(function (_a) { | ||
var _b, _c; | ||
var prop = _a[0], value = _a[1]; | ||
var _b, _c, _d; | ||
if (ignoreProps.includes(prop)) { | ||
return; // continue, skip prop. | ||
} | ||
if (value === null || value === void 0 ? void 0 : value['crafter-source-content-type-id']) { | ||
// @ts-ignore | ||
parsed.craftercms.sourceMap[prop] = value['crafter-source-content-type-id']; | ||
if (typeof value.text === 'string') { | ||
value = value.text; | ||
} | ||
else if (Object.keys(value).length === 2) { | ||
// Only has `crafter-source` & `crafter-source-content-type-id`. Empty value for the actual prop. | ||
value = null; | ||
} | ||
} | ||
if (systemProps.includes(prop)) { | ||
// @ts-ignore | ||
parsed.craftercms[_b = systemPropMap[prop], (_b !== null && _b !== void 0 ? _b : prop)] = value; | ||
parsed.craftercms[(_b = systemPropMap[prop]) !== null && _b !== void 0 ? _b : prop] = value; | ||
// Is there a risk prop name that matches what's considered a system prop? | ||
@@ -270,3 +286,3 @@ // In that case, here, parsed.craftercms might not be in the target object | ||
else if (prop.endsWith('_o')) { | ||
parsed[prop] = (_d = (_c = value) === null || _c === void 0 ? void 0 : _c.item, (_d !== null && _d !== void 0 ? _d : [])); | ||
parsed[prop] = (_c = value === null || value === void 0 ? void 0 : value.item) !== null && _c !== void 0 ? _c : []; | ||
if (!Array.isArray(parsed[prop])) { | ||
@@ -276,7 +292,6 @@ parsed[prop] = [parsed[prop]]; | ||
parsed[prop] = parsed[prop].map(function (item) { | ||
var _a, _b; | ||
var key = item.key, value = item.value, component = item.component, include = item.include; | ||
if ((item.component) || (item.key && item.value)) { | ||
// Components | ||
var newComponent = __assign(__assign({ label: value }, component), { path: ((_a = key) === null || _a === void 0 ? void 0 : _a.startsWith('/')) ? key : (((_b = include) === null || _b === void 0 ? void 0 : _b.startsWith('/')) ? include : null) }); | ||
var newComponent = __assign(__assign({ label: value }, component), { path: (key === null || key === void 0 ? void 0 : key.startsWith('/')) ? key : ((include === null || include === void 0 ? void 0 : include.startsWith('/')) ? include : null) }); | ||
return parseDescriptor(newComponent); | ||
@@ -291,3 +306,3 @@ } | ||
else { | ||
parsed[prop] = (value !== null && value !== void 0 ? value : null); | ||
parsed[prop] = value !== null && value !== void 0 ? value : null; | ||
} | ||
@@ -294,0 +309,0 @@ }); |
{ | ||
"name": "@craftercms/content", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "Crafter CMS services for content and navigation retrieval", | ||
@@ -29,7 +29,6 @@ "main": "./bundles/content.umd.js", | ||
"dependencies": { | ||
"@craftercms/classes": "1.2.3", | ||
"@craftercms/models": "1.2.3", | ||
"@craftercms/utils": "1.2.3", | ||
"rxjs": "^6.5.4", | ||
"tslib": "^1.10.0" | ||
"@craftercms/classes": "1.2.4", | ||
"@craftercms/models": "1.2.4", | ||
"@craftercms/utils": "1.2.4", | ||
"rxjs": "^6.5.4" | ||
}, | ||
@@ -43,3 +42,2 @@ "devDependencies": { | ||
"rollup-plugin-sourcemaps": "^0.5.0", | ||
"typescript": "^3.7.5", | ||
"uglify-es": "^3.3.9", | ||
@@ -46,0 +44,0 @@ "xhr-mock": "^2.5.1" |
133
README.md
@@ -9,2 +9,4 @@  | ||
All of Crafter CMS packages can be used either via npm or in plain html/javascript via regular script imports. | ||
### Via npm | ||
@@ -16,25 +18,5 @@ | ||
- Import and use the service(s) you need | ||
- You may pre-configure content services to a certain configuration and then you may omit the config param on subsequent calls | ||
```typescript | ||
import { Item } from '@craftercms/models'; | ||
import { getItem } from '@craftercms/content'; | ||
import { crafterConf } from '@craftercms/classes'; | ||
### Via html script imports | ||
// Configure crafter services "globally". Your config will be cached. | ||
// All content services use the specified configuration on subsequent calls. | ||
crafterConf.configure({ | ||
baseUrl: 'http://authoring.company.com', | ||
site: 'editorial' | ||
}); | ||
// Second param "config" will use "http://authoring.company.com" as | ||
// crafter base url and "editorial" as the site to query | ||
getItem('/site/website/index.xml').subscribe((item: Item) => { | ||
console.log(item); | ||
}); | ||
``` | ||
## Via html script imports | ||
- Download the bundle and import them in your page. | ||
@@ -44,5 +26,5 @@ - The bundle declare a global variable named `craftercms`. You can access all craftercms' packages and functions under this root. | ||
**Tip**: Once you've imported the scripts, type `craftercms` on your browser's dev tools console to inspect the package(s) | ||
**Tip**: Once you've imported the scripts, type `craftercms` on your browser's dev tools console to inspect the package(s) | ||
### Vanilla html/js example | ||
#### Vanilla html/js example | ||
```html | ||
@@ -77,3 +59,31 @@ <div id="myFeature"></div> | ||
## parseDescriptor | ||
### Service pre-configuration | ||
You may pre-configure content services to a certain configuration to then you may omit the config param on subsequent calls to services | ||
```typescript | ||
import { Item } from '@craftercms/models'; | ||
import { getItem } from '@craftercms/content'; | ||
import { crafterConf } from '@craftercms/classes'; | ||
// Configure crafter services "globally". Your config will be cached. | ||
// All content services use the specified configuration on subsequent calls. | ||
crafterConf.configure({ | ||
baseUrl: 'http://authoring.company.com', | ||
site: 'editorial' | ||
}); | ||
// Second param "config" will use "http://authoring.company.com" as | ||
// crafter base url and "editorial" as the site to query | ||
getItem('/site/website/index.xml').subscribe((item: Item) => { | ||
console.log(item); | ||
}); | ||
``` | ||
## Package Index | ||
The examples below assume usage in the style of using via npm. If you're using the bundles, | ||
directly importing as a script in the browser, these functions will be under the global variable | ||
named `craftercms.content` (i.e. `window.craftercms.content`). | ||
### parseDescriptor | ||
Parse a [Descriptor](../models/src/descriptor.ts), [Item](../models/src/item.ts) or a GraphQL response into a [Content Instance](../models/src/ContentInstance.ts). It could also be a collection of any of these types. | ||
@@ -87,7 +97,7 @@ | ||
### Returns | ||
#### Returns | ||
[ContentInstance](../models/src/ContentInstance.ts) | ||
### Examples | ||
#### Examples | ||
@@ -114,3 +124,32 @@ - If you want a cleaner/parsed response, you may use `parseDescriptor` util to parse the response for you. You may use it to parse getItem, getDescriptor or GraphQL responses. | ||
## Get Item | ||
### preParseSearchResults | ||
Inspects and parses elasticsearch hits and pre-parses objects before they can be sent to parseDescriptor | ||
@see https://github.com/craftercms/craftercms/issues/4057 | ||
```js | ||
import { createQuery, search } from '@craftercms/search'; | ||
import { parseDescriptor, preParseSearchResults } from '@craftercms/content'; | ||
search( | ||
createQuery('elasticsearch', { | ||
query: { | ||
bool: { | ||
filter: [/*...*/] | ||
} | ||
} | ||
}), | ||
{ baseUrl: 'http://localhost:8080', site: 'editorial' } | ||
).pipe( | ||
map(({ hits, ...rest }) => ({ | ||
...rest, | ||
hits: hits.map(({ _source }) => parseDescriptor( | ||
preParseSearchResults(_source) | ||
)) | ||
})) | ||
).subscribe((results) => { | ||
// Do stuff with results... | ||
}); | ||
``` | ||
### Get Item | ||
Get an Item from the content store. | ||
@@ -125,7 +164,7 @@ | ||
### Returns | ||
#### Returns | ||
[Item](../models/README.md#Item) - from the content store | ||
### Examples | ||
#### Examples | ||
@@ -157,3 +196,3 @@ - Get the index page from the site: | ||
## Get Descriptor | ||
### Get Descriptor | ||
Get the descriptor data of an Item in the content store. | ||
@@ -168,7 +207,7 @@ | ||
### Returns | ||
#### Returns | ||
[Descriptor](../models/README.md#Descriptor) - from the content store | ||
### Examples | ||
#### Examples | ||
@@ -197,3 +236,3 @@ - Get the index page from the site: | ||
## Get Children | ||
### Get Children | ||
Get the list of Items directly under a folder in the content store. | ||
@@ -208,7 +247,7 @@ | ||
### Returns | ||
#### Returns | ||
[Item](../models/README.md#Item)[] - List of Items from the content store | ||
### Examples | ||
#### Examples | ||
@@ -231,3 +270,3 @@ - Get the children items under root folder from the site: | ||
## Get Tree | ||
### Get Tree | ||
Get the complete Item hierarchy under the specified folder in the content store. | ||
@@ -243,7 +282,7 @@ | ||
### Returns | ||
#### Returns | ||
[Item](../models/README.md#Item) - from the content store | ||
### Examples | ||
#### Examples | ||
@@ -268,3 +307,3 @@ - Get the items tree under root folder from the site: | ||
## Get Navigation Tree | ||
### Get Navigation Tree | ||
Returns the navigation tree with the specified depth for the specified store URL. | ||
@@ -281,7 +320,7 @@ | ||
### Returns | ||
#### Returns | ||
[NavigationItem](../models/README.md#NavigationItem) - from the content store | ||
### Examples | ||
#### Examples | ||
@@ -304,3 +343,3 @@ - Get the navigation tree of the root folder from the site (depth = 3): | ||
## Get Navigation Breadcrumb | ||
### Get Navigation Breadcrumb | ||
Returns the navigation items that form the breadcrumb for the specified store URL. | ||
@@ -316,7 +355,7 @@ | ||
### Returns | ||
#### Returns | ||
[NavigationItem](../models/README.md#NavigationItem)[] - List of NavigationItem from the content store | ||
### Examples | ||
#### Examples | ||
@@ -339,3 +378,3 @@ - Get the breadcrumb for the root folder from the site: | ||
## Transform | ||
### Transform | ||
Transforms a URL, based on the current site’s configuration. | ||
@@ -351,7 +390,7 @@ | ||
### Returns | ||
#### Returns | ||
string - URL transformed according to transformer applied. | ||
### Examples | ||
#### Examples | ||
@@ -358,0 +397,0 @@ - Transform a store path into a render path |
@@ -9,8 +9,12 @@ import { Observable } from 'rxjs'; | ||
export declare function getItem(path: string, config: CrafterConfig): Observable<Item>; | ||
export interface GetDescriptorConfig { | ||
flatten: boolean; | ||
} | ||
/** | ||
* Returns the descriptor data of an Item in the content store. | ||
* @param {string} path - The item’s path | ||
* @param {CrafterConfig & GetDescriptorConfig} config? - The config override options to use | ||
*/ | ||
export declare function getDescriptor(path: string): Observable<Descriptor>; | ||
export declare function getDescriptor(path: string, config: CrafterConfig): Observable<Descriptor>; | ||
export declare function getDescriptor(path: string, config: Partial<CrafterConfig & GetDescriptorConfig>): Observable<Descriptor>; | ||
/** | ||
@@ -17,0 +21,0 @@ * Returns the list of Items directly under a folder in the content store. |
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
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
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
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
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
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
353966
4
8
45
2511
411
+ Added@craftercms/classes@1.2.4(transitive)
+ Added@craftercms/models@1.2.4(transitive)
+ Added@craftercms/utils@1.2.4(transitive)
- Removedtslib@^1.10.0
- Removed@craftercms/classes@1.2.3(transitive)
- Removed@craftercms/models@1.2.3(transitive)
- Removed@craftercms/utils@1.2.3(transitive)
Updated@craftercms/classes@1.2.4
Updated@craftercms/models@1.2.4
Updated@craftercms/utils@1.2.4