UNPKG

cspace-ui

Version:
35 lines (34 loc) 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getContentPath = exports.default = void 0; var _get = _interopRequireDefault(require("lodash/get")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const getContentPath = (config, recordType, vocabulary, csid, subresource, recordData) => { if (!csid) { return null; } const subresourceName = typeof subresource === 'function' ? subresource(recordData) : subresource; const recordTypeConfig = (0, _get.default)(config, ['recordTypes', recordType]); const vocabularyConfig = (0, _get.default)(recordTypeConfig, ['vocabularies', vocabulary]); const subresourceConfig = (0, _get.default)(config, ['subresources', subresourceName]); const recordServicePath = (0, _get.default)(recordTypeConfig, ['serviceConfig', 'servicePath']); const vocabularyServicePath = (0, _get.default)(vocabularyConfig, ['serviceConfig', 'servicePath']); const pathParts = [recordServicePath]; if (vocabularyServicePath) { pathParts.push(vocabularyServicePath); pathParts.push('items'); } pathParts.push(csid); if (subresourceConfig) { const subresourceServicePath = (0, _get.default)(subresourceConfig, ['serviceConfig', 'servicePath']); if (subresourceServicePath) { pathParts.push(subresourceServicePath); } } pathParts.push('content'); return pathParts.join('/'); }; exports.getContentPath = getContentPath; var _default = exports.default = {};