New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@craftercms/content

Package Overview
Dependencies
Maintainers
0
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@craftercms/content - npm Package Compare versions

Comparing version 4.1.8 to 4.2.0

877

bundles/content.umd.js

@@ -17,460 +17,449 @@ /*

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@craftercms/classes'), require('@craftercms/utils'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define('@craftercms/content', ['exports', '@craftercms/classes', '@craftercms/utils', 'rxjs/operators'], factory) :
(global = global || self, factory((global.craftercms = global.craftercms || {}, global.craftercms.content = {}), global.craftercms.classes, global.craftercms.utils, global.rxjs.operators));
}(this, (function (exports, classes, utils, operators) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@craftercms/classes'), require('@craftercms/utils'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define('@craftercms/content', ['exports', '@craftercms/classes', '@craftercms/utils', 'rxjs/operators'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.craftercms = global.craftercms || {}, global.craftercms.content = {}), global.craftercms.classes, global.craftercms.utils, global.rxjs.operators));
})(this, (function (exports, classes, utils, operators) { 'use strict';
/*
* 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 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* 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 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/******************************************************************************
Copyright (c) Microsoft Corporation.
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
/*
* Copyright (C) 2007-2021 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 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 Lesser General Public License for more details.
*
* 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/.
*/
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 }, config.headers);
}
function getDescriptor(path, config) {
var cfg = classes.crafterConf.mix(config);
return classes.SDKService.httpGet(utils.composeUrl(cfg, cfg.endpoints.GET_DESCRIPTOR), {
url: path,
crafterSite: cfg.site,
flatten: Boolean(config === null || config === void 0 ? void 0 : config.flatten)
}, cfg.headers).pipe(
// Manually introduce the path into the response as descriptor endpoint does not return it.
operators.map(function (descriptor) {
var _a;
var prop = typeof descriptor.page === 'undefined' ? 'component' : 'page';
return _a = {},
_a[prop] = __assign(__assign({}, descriptor[prop]), { localId: path }),
_a;
}));
}
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 }, config.headers);
}
function getTree(path, depth, config) {
if (depth === void 0) { depth = 1; }
if (typeof depth === 'object') {
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 }, config.headers);
}
var ContentStoreService = {
getItem: getItem,
getDescriptor: getDescriptor,
getChildren: getChildren,
getTree: getTree
};
/*
* Copyright (C) 2007-2021 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 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 Lesser General Public License for more details.
*
* 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/.
*/
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 }, config.headers);
}
function getDescriptor(path, config) {
var cfg = classes.crafterConf.mix(config);
return classes.SDKService.httpGet(utils.composeUrl(cfg, cfg.endpoints.GET_DESCRIPTOR), {
url: path,
crafterSite: cfg.site,
flatten: Boolean(config === null || config === void 0 ? void 0 : config.flatten)
}, cfg.headers).pipe(
// Manually introduce the path into the response as descriptor endpoint does not return it.
operators.map(function (descriptor) {
var _a;
var prop = typeof descriptor.page === 'undefined' ? 'component' : 'page';
return _a = {},
_a[prop] = __assign(__assign({}, descriptor[prop]), { localId: path }),
_a;
}));
}
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 }, config.headers);
}
function getTree(path, depth, config) {
if (depth === void 0) { depth = 1; }
if (typeof depth === 'object') {
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 }, config.headers);
}
var ContentStoreService = {
getItem: getItem,
getDescriptor: getDescriptor,
getChildren: getChildren,
getTree: getTree
};
/*
* Copyright (C) 2007-2021 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 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 Lesser General Public License for more details.
*
* 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/.
*/
function getNavTree(path, depth, currentPageUrl, config) {
if (depth === void 0) { depth = 1; }
if (currentPageUrl === void 0) { 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
}, config.headers);
}
function getNavBreadcrumb(path, root, config) {
if (root === void 0) { 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
}, config.headers);
}
/**
* Navigation Service API
*/
var NavigationService = {
getNavTree: getNavTree,
getNavBreadcrumb: getNavBreadcrumb
};
/*
* Copyright (C) 2007-2021 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 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 Lesser General Public License for more details.
*
* 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/.
*/
function getNavTree(path, depth, currentPageUrl, config) {
if (depth === void 0) { depth = 1; }
if (currentPageUrl === void 0) { 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
}, config.headers);
}
function getNavBreadcrumb(path, root, config) {
if (root === void 0) { 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
}, config.headers);
}
/**
* Navigation Service API
*/
var NavigationService = {
getNavTree: getNavTree,
getNavBreadcrumb: getNavBreadcrumb
};
/*
* Copyright (C) 2007-2021 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 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 Lesser General Public License for more details.
*
* 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/.
*/
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
}, config.headers);
}
/**
* URL Transformation Service API
*/
var UrlTransformationService = {
transform: urlTransform,
urlTransform: urlTransform
};
/*
* Copyright (C) 2007-2021 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 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 Lesser General Public License for more details.
*
* 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/.
*/
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
}, config.headers);
}
/**
* URL Transformation Service API
*/
var UrlTransformationService = {
transform: urlTransform,
urlTransform: urlTransform
};
/*
* Copyright (C) 2007-2021 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 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 Lesser General Public License for more details.
*
* 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/.
*/
var 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',
orderDefault_f: 'orderInNav'
};
var ignoredProps = [
'merge-strategy',
'display-template',
'objectGroupId',
'folder-name',
'createdDate',
'lastModifiedDate',
'no-template-required'
];
var systemProps = Object.keys(systemPropMap).concat(Object.values(systemPropMap));
function mixParseDescriptorOptions(options) {
if (options === void 0) { options = {}; }
return Object.assign({
systemPropMap: systemPropMap,
ignoredProps: ignoredProps,
systemProps: systemProps,
parseFieldValueTypes: false
}, options);
}
function parseDescriptor(data, options) {
options = mixParseDescriptorOptions(options);
if (data == null) {
return null;
}
else if (Array.isArray(data)) {
return data.map(function (item) { return parseDescriptor(item, options); });
}
else if (data.children) {
return parseDescriptor(extractChildren(data.children), options);
}
else if (data.descriptorDom === null && data.descriptorUrl) {
// This path catches calls to getChildren (/api/1/site/content_store/children.json?url=&crafterSite=)
// The getChildren call contains certain items that can't be parsed into content items.
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.');
}
var parsed = {
craftercms: {
id: null,
path: null,
label: null,
contentTypeId: null,
dateCreated: null,
dateModified: null,
disabled: false
}
};
return parseProps(extractContent(data), parsed, options);
}
function parseProps(props, parsed, options) {
if (parsed === void 0) { parsed = {}; }
options = mixParseDescriptorOptions(options);
var systemPropMap = options.systemPropMap, ignoredProps = options.ignoredProps, systemProps = options.systemProps;
Object.entries(props).forEach(function (_a) {
var _b, _c;
var prop = _a[0], value = _a[1];
if (ignoredProps.includes(prop)) {
return; // continue, skip prop.
}
// TODO: The source attributes will no longer be coming. This can be removed on the following releases.
// https://github.com/craftercms/craftercms/issues/6526
if (value === null || value === void 0 ? void 0 : 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)) {
var propName = (_b = systemPropMap[prop]) !== null && _b !== void 0 ? _b : prop;
var parsedValue = value;
switch (propName) {
case 'disabled':
parsedValue = value === 'true';
break;
case 'orderInNav':
parsedValue = parseFloat(value);
// Should never happen but just in case the value is not numeric, rollback to original string
if (isNaN(parsedValue))
parsedValue = value;
break;
case 'placeInNav':
parsedValue = value === 'true';
break;
}
// @ts-ignore
parsed.craftercms[propName] = parsedValue;
// Is there a risk prop name that matches what's considered a system prop?
// In that case, here, parsed.craftercms might not be in the target object
// and throw. We could do the below to de-risk but feels this needs assessment.
// if (parsed.craftercms) {
// parsed.craftercms[systemPropMap[prop] ?? prop] = value;
// } else {
// parsed[prop] = value;
// }
}
else if (prop.endsWith('_o')) {
parsed[prop] = (_c = value === null || value === void 0 ? void 0 : value.item) !== null && _c !== void 0 ? _c : [];
if (!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;
if ((item.component) || (item.key && item.include)) {
// Components
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
: (component === null || component === void 0 ? void 0 : component.path) ? component.path : null) });
return parseDescriptor(newComponent, options);
}
else {
// Repeat group items or key/value pairs
return parseProps(item, void 0, options);
}
});
}
else {
parsed[prop] = value != null
? options.parseFieldValueTypes ? parseFieldValue(prop, value) : value
: null;
}
});
return parsed;
}
function parseFieldValue(propName, propValue) {
var suffix = propName.substr(propName.lastIndexOf('_'));
switch (suffix) {
/*
_i For integer number.
_l For long integer number.
_f For floating point number.
_d For long floating point number.
_to For time
_dt For date in ISO 8601
*/
case '_b':
return propValue.toLowerCase().trim() === 'true';
case '_i':
case '_l':
case '_f':
case '_d':
return parseFloat(propValue);
default:
return propValue;
}
}
function fetchModelByPath(path, options) {
var pdo = mixParseDescriptorOptions(__assign({ parseFieldValueTypes: true }, options));
return getDescriptor(path, __assign({ flatten: true }, options)).pipe(operators.map(function (descriptor) { return parseDescriptor(descriptor, pdo); }));
}
function fetchModelByUrl(webUrl, options) {
var pdo = mixParseDescriptorOptions(__assign({ parseFieldValueTypes: true }, options));
return urlTransform('renderUrlToStoreUrl', webUrl).pipe(operators.switchMap(function (path) { return getDescriptor(path, __assign({ flatten: true }, options)); }), operators.map(function (descriptor) { return parseDescriptor(descriptor, pdo); }));
}
/**
* Inspects the data for getItem or getDescriptor responses and returns the inner content object
*/
function extractContent(data) {
var output = data;
if (data.descriptorDom) {
return __assign(__assign({}, (data.descriptorDom.page || data.descriptorDom.component)), { path: data.url });
}
else if (data.page) {
return data.page;
}
else if (data.component) {
return data.component;
}
return output;
}
/**
* Flattens a getChildren response into a flat list of content items
*/
function extractChildren(children) {
return children.flatMap(function (child) {
return child.children ? extractChildren(child.children) : child;
});
}
var propsToRemove = [
'rootId',
'crafterSite',
'crafterPublishedDate',
'crafterPublishedDate_dt',
'inheritsFrom_smv'
];
function preParseSearchResults(source) {
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;
if (!Array.isArray(collection.item)) {
source[prop] = { item: [collection.item] };
}
source[prop].item.forEach(function (item, i) {
source[prop].item[i] = preParseSearchResults(item);
if (item.component) {
source[prop].item[i].component = preParseSearchResults(item.component);
}
});
}
});
return source;
}
/*
* Copyright (C) 2007-2021 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 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 Lesser General Public License for more details.
*
* 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/.
*/
var 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',
orderDefault_f: 'orderInNav'
};
var ignoredProps = [
'merge-strategy',
'display-template',
'objectGroupId',
'folder-name',
'createdDate',
'lastModifiedDate',
'no-template-required'
];
var systemProps = Object.keys(systemPropMap).concat(Object.values(systemPropMap));
function mixParseDescriptorOptions(options) {
if (options === void 0) { options = {}; }
return Object.assign({
systemPropMap: systemPropMap,
ignoredProps: ignoredProps,
systemProps: systemProps,
parseFieldValueTypes: false
}, options);
}
function parseDescriptor(data, options) {
options = mixParseDescriptorOptions(options);
if (data == null) {
return null;
}
else if (Array.isArray(data)) {
return data.map(function (item) { return parseDescriptor(item, options); });
}
else if (data.children) {
return parseDescriptor(extractChildren(data.children), options);
}
else if (data.descriptorDom === null && data.descriptorUrl) {
// This path catches calls to getChildren (/api/1/site/content_store/children.json?url=&crafterSite=)
// The getChildren call contains certain items that can't be parsed into content items.
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.');
}
var parsed = {
craftercms: {
id: null,
path: null,
label: null,
contentTypeId: null,
dateCreated: null,
dateModified: null,
disabled: false
}
};
return parseProps(extractContent(data), parsed, options);
}
function parseProps(props, parsed, options) {
if (parsed === void 0) { parsed = {}; }
options = mixParseDescriptorOptions(options);
var systemPropMap = options.systemPropMap, ignoredProps = options.ignoredProps, systemProps = options.systemProps;
Object.entries(props).forEach(function (_a) {
var _b, _c;
var prop = _a[0], value = _a[1];
if (ignoredProps.includes(prop)) {
return; // continue, skip prop.
}
if (systemProps.includes(prop)) {
var propName = (_b = systemPropMap[prop]) !== null && _b !== void 0 ? _b : prop;
var parsedValue = value;
switch (propName) {
case 'disabled':
parsedValue = value === 'true';
break;
case 'orderInNav':
parsedValue = parseFloat(value);
// Should never happen but just in case the value is not numeric, rollback to original string
if (isNaN(parsedValue))
parsedValue = value;
break;
case 'placeInNav':
parsedValue = value === 'true';
break;
}
// @ts-ignore
parsed.craftercms[propName] = parsedValue;
// Is there a risk prop name that matches what's considered a system prop?
// In that case, here, parsed.craftercms might not be in the target object
// and throw. We could do the below to de-risk but feels this needs assessment.
// if (parsed.craftercms) {
// parsed.craftercms[systemPropMap[prop] ?? prop] = value;
// } else {
// parsed[prop] = value;
// }
}
else if (prop.endsWith('_o')) {
parsed[prop] = (_c = value === null || value === void 0 ? void 0 : value.item) !== null && _c !== void 0 ? _c : [];
if (!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;
if ((item.component) || (item.key && item.include)) {
// Components
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
: (component === null || component === void 0 ? void 0 : component.path) ? component.path : null) });
return parseDescriptor(newComponent, options);
}
else {
// Repeat group items or key/value pairs
return parseProps(item, void 0, options);
}
});
}
else {
parsed[prop] = value != null
? options.parseFieldValueTypes ? parseFieldValue(prop, value) : value
: null;
}
});
return parsed;
}
function parseFieldValue(propName, propValue) {
var suffix = propName.substr(propName.lastIndexOf('_'));
switch (suffix) {
/*
_i For integer number.
_l For long integer number.
_f For floating point number.
_d For long floating point number.
_to For time
_dt For date in ISO 8601
*/
case '_b':
return propValue.toLowerCase().trim() === 'true';
case '_i':
case '_l':
case '_f':
case '_d':
return parseFloat(propValue);
default:
return propValue;
}
}
function fetchModelByPath(path, options) {
var pdo = mixParseDescriptorOptions(__assign({ parseFieldValueTypes: true }, options));
return getDescriptor(path, __assign({ flatten: true }, options)).pipe(operators.map(function (descriptor) { return parseDescriptor(descriptor, pdo); }));
}
function fetchModelByUrl(webUrl, options) {
var pdo = mixParseDescriptorOptions(__assign({ parseFieldValueTypes: true }, options));
return urlTransform('renderUrlToStoreUrl', webUrl).pipe(operators.switchMap(function (path) { return getDescriptor(path, __assign({ flatten: true }, options)); }), operators.map(function (descriptor) { return parseDescriptor(descriptor, pdo); }));
}
/**
* Inspects the data for getItem or getDescriptor responses and returns the inner content object
*/
function extractContent(data) {
var output = data;
if (data.descriptorDom) {
return __assign(__assign({}, (data.descriptorDom.page || data.descriptorDom.component)), { path: data.url });
}
else if (data.page) {
return data.page;
}
else if (data.component) {
return data.component;
}
return output;
}
/**
* Flattens a getChildren response into a flat list of content items
*/
function extractChildren(children) {
return children.flatMap(function (child) {
return child.children ? extractChildren(child.children) : child;
});
}
var propsToRemove = [
'rootId',
'crafterSite',
'crafterPublishedDate',
'crafterPublishedDate_dt',
'inheritsFrom_smv'
];
function preParseSearchResults(source) {
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;
if (!Array.isArray(collection.item)) {
source[prop] = { item: [collection.item] };
}
source[prop].item.forEach(function (item, i) {
source[prop].item[i] = preParseSearchResults(item);
if (item.component) {
source[prop].item[i].component = preParseSearchResults(item.component);
}
});
}
});
return source;
}
exports.ContentStoreService = ContentStoreService;
exports.NavigationService = NavigationService;
exports.UrlTransformationService = UrlTransformationService;
exports.extractChildren = extractChildren;
exports.extractContent = extractContent;
exports.fetchModelByPath = fetchModelByPath;
exports.fetchModelByUrl = fetchModelByUrl;
exports.getChildren = getChildren;
exports.getDescriptor = getDescriptor;
exports.getItem = getItem;
exports.getNavBreadcrumb = getNavBreadcrumb;
exports.getNavTree = getNavTree;
exports.getTree = getTree;
exports.ignoredProps = ignoredProps;
exports.parseDescriptor = parseDescriptor;
exports.parseFieldValue = parseFieldValue;
exports.parseProps = parseProps;
exports.preParseSearchResults = preParseSearchResults;
exports.systemPropMap = systemPropMap;
exports.systemProps = systemProps;
exports.urlTransform = urlTransform;
exports.ContentStoreService = ContentStoreService;
exports.NavigationService = NavigationService;
exports.UrlTransformationService = UrlTransformationService;
exports.extractChildren = extractChildren;
exports.extractContent = extractContent;
exports.fetchModelByPath = fetchModelByPath;
exports.fetchModelByUrl = fetchModelByUrl;
exports.getChildren = getChildren;
exports.getDescriptor = getDescriptor;
exports.getItem = getItem;
exports.getNavBreadcrumb = getNavBreadcrumb;
exports.getNavTree = getNavTree;
exports.getTree = getTree;
exports.ignoredProps = ignoredProps;
exports.parseDescriptor = parseDescriptor;
exports.parseFieldValue = parseFieldValue;
exports.parseProps = parseProps;
exports.preParseSearchResults = preParseSearchResults;
exports.systemPropMap = systemPropMap;
exports.systemProps = systemProps;
exports.urlTransform = urlTransform;
Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, '__esModule', { value: true });
})));
}));
//# sourceMappingURL=content.umd.js.map

@@ -1,1 +0,1 @@

!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@craftercms/classes"),require("@craftercms/utils"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@craftercms/content",["exports","@craftercms/classes","@craftercms/utils","rxjs/operators"],factory):factory(((global=global||self).craftercms=global.craftercms||{},global.craftercms.content={}),global.craftercms.classes,global.craftercms.utils,global.rxjs.operators)}(this,function(exports,classes,utils,operators){"use strict";var __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)};"function"==typeof SuppressedError&&SuppressedError;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},config.headers)}function getDescriptor(path,config){var cfg=classes.crafterConf.mix(config);return classes.SDKService.httpGet(utils.composeUrl(cfg,cfg.endpoints.GET_DESCRIPTOR),{url:path,crafterSite:cfg.site,flatten:Boolean(null===config||void 0===config?void 0:config.flatten)},cfg.headers).pipe(operators.map(function(descriptor){var _a,prop=void 0===descriptor.page?"component":"page";return(_a={})[prop]=__assign(__assign({},descriptor[prop]),{localId:path}),_a}))}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},config.headers)}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},config.headers)}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},config.headers)}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},config.headers)}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},config.headers)}var UrlTransformationService={transform:urlTransform,urlTransform:urlTransform},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",orderDefault_f:"orderInNav"},ignoredProps=["merge-strategy","display-template","objectGroupId","folder-name","createdDate","lastModifiedDate","no-template-required"],systemProps=Object.keys(systemPropMap).concat(Object.values(systemPropMap));function mixParseDescriptorOptions(options){return void 0===options&&(options={}),Object.assign({systemPropMap:systemPropMap,ignoredProps:ignoredProps,systemProps:systemProps,parseFieldValueTypes:!1},options)}function parseDescriptor(data,options){if(options=mixParseDescriptorOptions(options),null==data)return null;if(Array.isArray(data))return data.map(function(item){return parseDescriptor(item,options)});if(data.children)return parseDescriptor(extractChildren(data.children),options);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(extractContent(data),{craftercms:{id:null,path:null,label:null,contentTypeId:null,dateCreated:null,dateModified:null,disabled:!1}},options)}function parseProps(props,parsed,options){void 0===parsed&&(parsed={});var systemPropMap=(options=mixParseDescriptorOptions(options)).systemPropMap,ignoredProps=options.ignoredProps,systemProps=options.systemProps;return Object.entries(props).forEach(function(_a){var _b,_c,prop=_a[0],value=_a[1];if(!ignoredProps.includes(prop))if((null===value||void 0===value?void 0:value["crafter-source-content-type-id"])&&("string"==typeof value.text?value=value.text:2===Object.keys(value).length&&(value=null)),systemProps.includes(prop)){var propName=null!==(_b=systemPropMap[prop])&&void 0!==_b?_b:prop,parsedValue=value;switch(propName){case"disabled":parsedValue="true"===value;break;case"orderInNav":parsedValue=parseFloat(value),isNaN(parsedValue)&&(parsedValue=value);break;case"placeInNav":parsedValue="true"===value}parsed.craftercms[propName]=parsedValue}else 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.include?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===component||void 0===component?void 0:component.path)?component.path:null}),options):parseProps(item,void 0,options)})):parsed[prop]=null!=value?options.parseFieldValueTypes?parseFieldValue(prop,value):value:null}),parsed}function parseFieldValue(propName,propValue){switch(propName.substr(propName.lastIndexOf("_"))){case"_b":return"true"===propValue.toLowerCase().trim();case"_i":case"_l":case"_f":case"_d":return parseFloat(propValue);default:return propValue}}function extractContent(data){var output=data;return data.descriptorDom?__assign(__assign({},data.descriptorDom.page||data.descriptorDom.component),{path:data.url}):data.page?data.page:data.component?data.component:output}function extractChildren(children){return children.flatMap(function(child){return child.children?extractChildren(child.children):child})}var propsToRemove=["rootId","crafterSite","crafterPublishedDate","crafterPublishedDate_dt","inheritsFrom_smv"];exports.ContentStoreService=ContentStoreService,exports.NavigationService=NavigationService,exports.UrlTransformationService=UrlTransformationService,exports.extractChildren=extractChildren,exports.extractContent=extractContent,exports.fetchModelByPath=function(path,options){var pdo=mixParseDescriptorOptions(__assign({parseFieldValueTypes:!0},options));return getDescriptor(path,__assign({flatten:!0},options)).pipe(operators.map(function(descriptor){return parseDescriptor(descriptor,pdo)}))},exports.fetchModelByUrl=function(webUrl,options){var pdo=mixParseDescriptorOptions(__assign({parseFieldValueTypes:!0},options));return urlTransform("renderUrlToStoreUrl",webUrl).pipe(operators.switchMap(function(path){return getDescriptor(path,__assign({flatten:!0},options))}),operators.map(function(descriptor){return parseDescriptor(descriptor,pdo)}))},exports.getChildren=getChildren,exports.getDescriptor=getDescriptor,exports.getItem=getItem,exports.getNavBreadcrumb=getNavBreadcrumb,exports.getNavTree=getNavTree,exports.getTree=getTree,exports.ignoredProps=ignoredProps,exports.parseDescriptor=parseDescriptor,exports.parseFieldValue=parseFieldValue,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.systemPropMap=systemPropMap,exports.systemProps=systemProps,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"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@craftercms/content",["exports","@craftercms/classes","@craftercms/utils","rxjs/operators"],factory):factory(((global="undefined"!=typeof globalThis?globalThis:global||self).craftercms=global.craftercms||{},global.craftercms.content={}),global.craftercms.classes,global.craftercms.utils,global.rxjs.operators)}(this,(function(exports,classes,utils,operators){"use strict";var __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},__assign.apply(this,arguments)};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},config.headers)}function getDescriptor(path,config){var cfg=classes.crafterConf.mix(config);return classes.SDKService.httpGet(utils.composeUrl(cfg,cfg.endpoints.GET_DESCRIPTOR),{url:path,crafterSite:cfg.site,flatten:Boolean(null==config?void 0:config.flatten)},cfg.headers).pipe(operators.map((function(descriptor){var _a,prop=void 0===descriptor.page?"component":"page";return(_a={})[prop]=__assign(__assign({},descriptor[prop]),{localId:path}),_a})))}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},config.headers)}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},config.headers)}"function"==typeof SuppressedError&&SuppressedError;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},config.headers)}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},config.headers)}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},config.headers)}var UrlTransformationService={transform:urlTransform,urlTransform:urlTransform},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",orderDefault_f:"orderInNav"},ignoredProps=["merge-strategy","display-template","objectGroupId","folder-name","createdDate","lastModifiedDate","no-template-required"],systemProps=Object.keys(systemPropMap).concat(Object.values(systemPropMap));function mixParseDescriptorOptions(options){return void 0===options&&(options={}),Object.assign({systemPropMap:systemPropMap,ignoredProps:ignoredProps,systemProps:systemProps,parseFieldValueTypes:!1},options)}function parseDescriptor(data,options){if(options=mixParseDescriptorOptions(options),null==data)return null;if(Array.isArray(data))return data.map((function(item){return parseDescriptor(item,options)}));if(data.children)return parseDescriptor(extractChildren(data.children),options);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(extractContent(data),{craftercms:{id:null,path:null,label:null,contentTypeId:null,dateCreated:null,dateModified:null,disabled:!1}},options)}function parseProps(props,parsed,options){void 0===parsed&&(parsed={});var systemPropMap=(options=mixParseDescriptorOptions(options)).systemPropMap,ignoredProps=options.ignoredProps,systemProps=options.systemProps;return Object.entries(props).forEach((function(_a){var _b,_c,prop=_a[0],value=_a[1];if(!ignoredProps.includes(prop))if(systemProps.includes(prop)){var propName=null!==(_b=systemPropMap[prop])&&void 0!==_b?_b:prop,parsedValue=value;switch(propName){case"disabled":case"placeInNav":parsedValue="true"===value;break;case"orderInNav":parsedValue=parseFloat(value),isNaN(parsedValue)&&(parsedValue=value)}parsed.craftercms[propName]=parsedValue}else prop.endsWith("_o")?(parsed[prop]=null!==(_c=null==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.include?parseDescriptor(__assign(__assign({label:value},component),{path:(null==key?void 0:key.startsWith("/"))?key:(null==include?void 0:include.startsWith("/"))?include:(null==component?void 0:component.path)?component.path:null}),options):parseProps(item,void 0,options)}))):parsed[prop]=null!=value?options.parseFieldValueTypes?parseFieldValue(prop,value):value:null})),parsed}function parseFieldValue(propName,propValue){switch(propName.substr(propName.lastIndexOf("_"))){case"_b":return"true"===propValue.toLowerCase().trim();case"_i":case"_l":case"_f":case"_d":return parseFloat(propValue);default:return propValue}}function extractContent(data){var output=data;return data.descriptorDom?__assign(__assign({},data.descriptorDom.page||data.descriptorDom.component),{path:data.url}):data.page?data.page:data.component?data.component:output}function extractChildren(children){return children.flatMap((function(child){return child.children?extractChildren(child.children):child}))}var propsToRemove=["rootId","crafterSite","crafterPublishedDate","crafterPublishedDate_dt","inheritsFrom_smv"];exports.ContentStoreService=ContentStoreService,exports.NavigationService=NavigationService,exports.UrlTransformationService=UrlTransformationService,exports.extractChildren=extractChildren,exports.extractContent=extractContent,exports.fetchModelByPath=function(path,options){var pdo=mixParseDescriptorOptions(__assign({parseFieldValueTypes:!0},options));return getDescriptor(path,__assign({flatten:!0},options)).pipe(operators.map((function(descriptor){return parseDescriptor(descriptor,pdo)})))},exports.fetchModelByUrl=function(webUrl,options){var pdo=mixParseDescriptorOptions(__assign({parseFieldValueTypes:!0},options));return urlTransform("renderUrlToStoreUrl",webUrl).pipe(operators.switchMap((function(path){return getDescriptor(path,__assign({flatten:!0},options))})),operators.map((function(descriptor){return parseDescriptor(descriptor,pdo)})))},exports.getChildren=getChildren,exports.getDescriptor=getDescriptor,exports.getItem=getItem,exports.getNavBreadcrumb=getNavBreadcrumb,exports.getNavTree=getNavTree,exports.getTree=getTree,exports.ignoredProps=ignoredProps,exports.parseDescriptor=parseDescriptor,exports.parseFieldValue=parseFieldValue,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.systemPropMap=systemPropMap,exports.systemProps=systemProps,exports.urlTransform=urlTransform,Object.defineProperty(exports,"__esModule",{value:!0})}));

@@ -95,13 +95,2 @@ /*

}
// TODO: The source attributes will no longer be coming. This can be removed on the following releases.
// https://github.com/craftercms/craftercms/issues/6526
if (value === null || value === void 0 ? void 0 : 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)) {

@@ -108,0 +97,0 @@ let propName = (_a = systemPropMap[prop]) !== null && _a !== void 0 ? _a : prop;

@@ -99,13 +99,2 @@ /*

}
// TODO: The source attributes will no longer be coming. This can be removed on the following releases.
// https://github.com/craftercms/craftercms/issues/6526
if (value === null || value === void 0 ? void 0 : 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)) {

@@ -112,0 +101,0 @@ var propName = (_b = systemPropMap[prop]) !== null && _b !== void 0 ? _b : prop;

@@ -241,13 +241,2 @@ /*

}
// TODO: The source attributes will no longer be coming. This can be removed on the following releases.
// https://github.com/craftercms/craftercms/issues/6526
if (value === null || value === void 0 ? void 0 : 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)) {

@@ -254,0 +243,0 @@ let propName = (_a = systemPropMap[prop]) !== null && _a !== void 0 ? _a : prop;

@@ -241,13 +241,2 @@ /*

}
// TODO: The source attributes will no longer be coming. This can be removed on the following releases.
// https://github.com/craftercms/craftercms/issues/6526
if (value === null || value === void 0 ? void 0 : 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)) {

@@ -254,0 +243,0 @@ let propName = (_a = systemPropMap[prop]) !== null && _a !== void 0 ? _a : prop;

@@ -36,15 +36,15 @@ /*

var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};

@@ -281,13 +281,2 @@

}
// TODO: The source attributes will no longer be coming. This can be removed on the following releases.
// https://github.com/craftercms/craftercms/issues/6526
if (value === null || value === void 0 ? void 0 : 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)) {

@@ -294,0 +283,0 @@ var propName = (_b = systemPropMap[prop]) !== null && _b !== void 0 ? _b : prop;

@@ -36,15 +36,15 @@ /*

var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};

@@ -281,13 +281,2 @@

}
// TODO: The source attributes will no longer be coming. This can be removed on the following releases.
// https://github.com/craftercms/craftercms/issues/6526
if (value === null || value === void 0 ? void 0 : 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)) {

@@ -294,0 +283,0 @@ var propName = (_b = systemPropMap[prop]) !== null && _b !== void 0 ? _b : prop;

{
"name": "@craftercms/content",
"version": "4.1.8",
"version": "4.2.0",
"description": "Crafter CMS services for content and navigation retrieval",

@@ -11,3 +11,3 @@ "main": "./bundles/content.umd.js",

"type": "git",
"url": "git+https://github.com/craftercms/craftercms-sdk-js.git"
"url": "https://github.com/craftercms/craftercms-sdk-js.git"
},

@@ -29,20 +29,22 @@ "keywords": [

"dependencies": {
"@craftercms/classes": "4.1.8",
"@craftercms/models": "4.1.8",
"@craftercms/utils": "4.1.8",
"@craftercms/classes": "4.2.0",
"@craftercms/models": "4.2.0",
"@craftercms/utils": "4.2.0",
"rxjs": "^7.8.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-node-resolve": "^7.1.3",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/mocha": "^10.0.7",
"isomorphic-fetch": "^3.0.0",
"chai": "^5.1.1",
"mocha": "^10.7.3",
"rollup": "^1.32.1",
"rollup-plugin-sourcemaps": "^0.5.0",
"nock": "^13.3.3",
"node-fetch": "2",
"rollup": "^2.79.1",
"rollup-plugin-sourcemaps": "^0.6.3",
"terser": "^5.30.1",
"ts-node": "^10.9.2",
"uglify-es": "^3.3.10",
"url-search-params-polyfill": "^8.2.5",
"whatwg-fetch": "^3.6.19",
"xhr-mock": "^2.5.1"
}
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc