{"version":3,"file":"general-helper.mjs","sources":["../../../lib/data-provider-interface/utils/general-helper.js"],"sourcesContent":["import { isEmpty, isNil, has, cloneDeep } from \"lodash\";\nimport axios from \"axios\";\nimport { getTranslationFor } from \"../../utils/helpers\";\n\n/**\n * Merges multiple Objects nested within an object into one main objects with al key-value-pairs originally located within the nested objects\n * @param {Object} data Object containing nested objects\n * @returns Object with key-value pairs merged from nested objects\n */\nfunction mergeNestedObjects(data) {\n  let mergedObject = {};\n  for (const key in data) {\n    mergedObject = Object.assign(mergedObject, data[key]);\n  }\n  return mergedObject;\n}\n\n/**\n *\n * @param {*} prefix\n * @returns\n */\nfunction addNamespace(prefix, dpiConfig) {\n  // the prefix had the following format: namespace:property (e.g. dct:title)\n  // the short version of the namespace noe should be replaced by the long version (e.g. http://purl.org/dc/terms/title)\n  let fullDescriptor;\n\n  // console.log(prefix);\n//   if (prefix === \"pv:DistributionType\") {\n//     return \"pv:DistributionType\";\n//   } else {\n    const colonIndex = prefix.indexOf(\":\");\n\n    // there are also prefixes with no namespace which should sty the same\n    if (colonIndex !== -1) {\n      const namespaceAbbreviation = prefix.substr(0, colonIndex);\n      const propertyName = prefix.substr(colonIndex + 1);\n\n      // the long version of the namespace is saved within the context.json (config)\n      // there is an object containing the namespace abbreviation(key) and the corresponding value is the long version of the namespace\n\n      const longNamespace = dpiConfig.prefixes[namespaceAbbreviation];\n      fullDescriptor = `${longNamespace}${propertyName}`;\n    } else {\n      fullDescriptor = prefix;\n    }\n\n    return fullDescriptor;\n  }\n// }\n\n/**\n * Removes long namespace and replaces it with the abbreviation of the namespace\n * @param {*} longValue Long value with long namespace (e.g. https://....#type)\n * @returns Returns value with short namespace (e.g. rdf:type)\n */\nfunction removeNamespace(longValue, dpiConfig) {\n  let lastIndex;\n\n  // long namespace either ends with an # or a \\\n  if (longValue.includes(\"#\")) {\n    lastIndex = longValue.lastIndexOf(\"#\");\n  } else {\n    lastIndex = longValue.lastIndexOf(\"/\");\n  }\n\n  const shortValue = longValue.substr(lastIndex + 1);\n  const longPrefix = longValue.substr(0, lastIndex + 1);\n  const shortPrefix = Object.keys(dpiConfig.prefixes).find(\n    (key) => dpiConfig.prefixes[key] === longPrefix\n  );\n\n  return `${shortPrefix}:${shortValue}`;\n}\n\n/**\n * Returns list of keys as shortned version from given data\n * @param {*} data An array of quads with keys as predicate\n * @returns Array of shortened keys\n */\nfunction getNestedKeys(data, dpiConfig) {\n  const keys = [];\n\n  for (let el of data) {\n    keys.push(removeNamespace(el.predicate.value, dpiConfig));\n  }\n\n  return keys;\n}\n\n/**\n * Creates a random string\n * @param {*} length Length of string to be created\n * @returns String formed of random characters with given length\n */\nfunction makeId(length) {\n  var result = \"\";\n  var characters =\n    \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n  var charactersLength = characters.length;\n  for (var i = 0; i < length; i++) {\n    result += characters.charAt(Math.floor(Math.random() * charactersLength));\n  }\n  return result;\n}\n\n/**\n * Methods checks if given string is an Url\n * @param {*} string String to test\n * @returns Boolean determining if given string is an Url\n */\nfunction isUrl(string) {\n  let url;\n  try {\n    url = new URL(string);\n  } catch (_) {\n    return false;\n  }\n  return url.protocol === \"http:\" || url.protocol === \"https:\";\n}\n\n/**\n * Fetches data from given endpoint using token and returns data\n * @param {*} url Endpoint from where to fetch the data\n * @param {*} token User token for authentication (if needed)\n * @returns Returns promise of fetched data\n */\nasync function fetchLinkedData(endpoint, token) {\n  let response;\n  let requestOptions;\n\n  // if token is given, provide token (for drafts and other non-public elements)\n  if (token !== \"\") {\n    requestOptions = {\n      method: \"GET\",\n      headers: {\n        Authorization: `Bearer ${token}`,\n      },\n      url: endpoint,\n    };\n  } else {\n    requestOptions = {\n      method: \"GET\",\n      url: endpoint,\n    };\n  }\n\n  try {\n    response = fetch(endpoint, requestOptions)\n      .then((response) => {\n        const reader = response?.body?.getReader();\n        return new ReadableStream({\n          start(controller) {\n            // The following function handles each data chunk\n            function push() {\n              // \"done\" is a Boolean and value a \"Uint8Array\"\n              reader?.read().then(({ done, value }) => {\n                // If there is no more data to read\n                if (done) {\n                  controller.close();\n                  return;\n                }\n                // Get the data and send it to the browser via the controller\n                controller.enqueue(value);\n                // Check chunks by logging to the console\n                push();\n              });\n            }\n\n            push();\n          },\n        });\n      })\n      .then((stream) =>\n        new Response(stream, {\n          headers: { \"Content-Type\": \"text/html\" },\n        }).text()\n      );\n  } catch (err) {\n    // TODO: Handle (network) errors\n    throw Error(`Error occured during fetching endpoint: ${endpoint}`);\n  }\n  return response;\n}\n\n/**\n * Exracts keynames (e.g. dct:title) using the page-content-config for each element\n * @param {*} property Property (datasets/distributions/catalogues)\n * @param {*} formDefinitions Form definition of properties including name\n * @param {*} pageContent Config file containing definition of which property will be displayed on which page\n * @returns Object containing keys of properties for each page\n */\nfunction getPagePrefixedNames(property, formDefinitions, pageContent) {\n  const prefixedNames = {\n    datasets: {},\n    distributions: {},\n    catalogues: {},\n  };\n\n  // get property keys for each page\n  for (let pageName in pageContent[property]) {\n    prefixedNames[property][pageName] = [];\n    const propertyKeys = pageContent[property][pageName];\n    for (\n      let propertyindex = 0;\n      propertyindex < propertyKeys.length;\n      propertyindex++\n    ) {\n      const propertyName = propertyKeys[propertyindex];\n      const prefixedName = formDefinitions[property][propertyName].name; // form definition includes name-property which contains key\n      if (prefixedName !== undefined)\n        prefixedNames[property][pageName].push(prefixedName);\n    }\n  }\n\n  return prefixedNames;\n}\n\nfunction isValid(id) {\n  return /^[a-z0-9-]*$/.test(id);\n}\n\n/**\n * Get file id from accessUrl, if it is a file upload url.\n * accessUrls are file upload urls, iff they start with fileUploadUrl.\n * @param {string} accessUrl\n * @param {string} fileUploadUrl\n * @returns {string|null}\n */\nfunction getFileIdByAccessUrl({ accessUrl, fileUploadUrl }) {\n  const accessUrlWithTrailingSlash = accessUrl.endsWith(\"/\")\n    ? accessUrl\n    : `${accessUrl}/`;\n  const fileUploadUrlWithTrailingSlash = fileUploadUrl.endsWith(\"/\")\n    ? fileUploadUrl\n    : `${fileUploadUrl}/`;\n\n  // Check if accessUrl starts with fileUploadApi\n  if (accessUrlWithTrailingSlash.startsWith(fileUploadUrlWithTrailingSlash)) {\n    const accessUrlParts = accessUrlWithTrailingSlash.split(\"/\");\n    const fileId = accessUrlParts[accessUrlParts.length - 2];\n\n    return fileId || null;\n  }\n\n  return null;\n}\n\n/**\n * Adds given key to format type\n * @param {String} key\n * @param {String} format\n * @param {String} property\n * @param {Object} typeDefinition\n */\nfunction addKeyToFormatType(key, format, property, typeDefinition) {\n  typeDefinition[format][property].push(key);\n}\n\n/**\n * Removes key from format type\n * @param {String} key\n * @param {String} format\n * @param {String} property\n * @param {Object} typeDefinition\n */\nfunction removeKeyFromFormatType(key, format, property, typeDefinition) {\n  typeDefinition[format][property].splice(\n    typeDefinition[format][property].indexOf(key),\n    1\n  );\n}\n\nfunction propertyObjectHasValues(objectData) {\n  let objectHasValues = false;\n  if (!isNil(objectData) && !isEmpty(objectData)) {\n    // language tag is always given\n    let copiedData = cloneDeep(objectData);\n\n    if (has(copiedData, \"@language\")) {\n      delete copiedData[\"@language\"];\n    }\n\n    // removing all falsy values (undefined, null, \"\", '', NaN, 0)\n    const actualValues = Object.values(copiedData).filter((el) => el); // filters all real values\n    if (!isEmpty(actualValues)) {\n      // there are keys containing an object or array as value\n      for (let valueIndex = 0; valueIndex < actualValues.length; valueIndex++) {\n        // if at least one elemnt within the array is set, return true\n        const currentValue = actualValues[valueIndex];\n\n        // testing content of array\n        if (Array.isArray(currentValue)) {\n          // there are only objects wihtin those arrays\n          for (let arrIndex = 0; arrIndex < currentValue.length; arrIndex++) {\n            if (propertyObjectHasValues(currentValue[arrIndex]))\n              objectHasValues = true;\n          }\n        } else if (typeof currentValue === \"object\") {\n          // testing content of object\n          if (propertyObjectHasValues(currentValue)) objectHasValues = true;\n        } else {\n          objectHasValues = true;\n        }\n      }\n    }\n  }\n\n  return objectHasValues;\n}\n\nfunction propertyHasValue(data) {\n  let isSet = false;\n\n  if (data !== undefined && data !== \"\" && !isEmpty(data) && !isNil(data)) {\n    // testing array data\n    if (Array.isArray(data)) {\n      // there are arreay of objects or arrays of values\n      if (data.every((el) => typeof el === \"string\")) {\n        isSet = !isEmpty(data.filter((el) => el));\n      } else if (data.every((el) => typeof el === \"object\")) {\n        for (let index = 0; index < data.length; index++) {\n          // if at least one array element is set, return true\n          if (propertyObjectHasValues(data[index])) isSet = true;\n        }\n      }\n    } else if (typeof data === \"object\") {\n      // testing object data\n      isSet = propertyObjectHasValues(data);\n    } else {\n      isSet = true;\n    }\n  }\n\n  return isSet;\n}\n\n/**\n *\n */\nasync function requestUriLabel(uri, dpiConfig, envs) {\n  // get vocabulary by finding vocab-url within given URI\n  const voc = Object.keys(dpiConfig.vocabPrefixes).find((key) =>\n    uri.includes(dpiConfig.vocabPrefixes[key])\n  );\n\n  try {\n    let req;\n\n    // vocabularies for spdx checksum and inana-media-types are structured differently in the backend then other vocabularies\n    if (voc === \"iana-media-types\" || voc === \"spdx-checksum-algorithm\") {\n      req = `${envs.api.baseUrl}vocabularies/${voc}`;\n    } else {\n      const value = uri.replace(dpiConfig.vocabPrefixes[voc], \"\");\n      req = `${envs.api.baseUrl}vocabularies/${voc}/${value}`;\n    }\n\n    return new Promise((resolve, reject) => {\n      axios\n        .get(req)\n        .then((res) => {\n          resolve(res);\n        })\n        .catch((err) => {\n          reject(err);\n        });\n    });\n  } catch (error) {\n    //\n  }\n}\n\n/**\n *\n */\nasync function getUriLabel(uri, dpiConfig, locale, envs) {\n  let URIlabel;\n\n  const voc = Object.keys(dpiConfig.vocabPrefixes).find((key) =>\n    uri.includes(dpiConfig.vocabPrefixes[key])\n  );\n\n  // if vocabulary iana media type or spdx checksum endpoint returns values in a different way\n  let vocMatch =\n    voc === \"iana-media-types\" || voc === \"spdx-checksum-algorithm\";\n\n  await requestUriLabel(uri, dpiConfig, envs).then((response) => {\n    let result = vocMatch\n      ? response.data.result.results\n          .filter((dataset) => dataset.resource === uri)\n          .map((dataset) => dataset.pref_label)[0].en\n      : getTranslationFor(response.data.result.pref_label, locale, []);\n\n    URIlabel = result;\n  });\n\n  return URIlabel;\n}\n\nexport default {\n  mergeNestedObjects,\n  addNamespace,\n  makeId,\n  isUrl,\n  fetchLinkedData,\n  getPagePrefixedNames,\n  getNestedKeys,\n  removeNamespace,\n  getFileIdByAccessUrl,\n  addKeyToFormatType,\n  removeKeyFromFormatType,\n  propertyHasValue,\n  getUriLabel,\n};\n"],"names":["mergeNestedObjects","data","mergedObject","key","addNamespace","prefix","dpiConfig","fullDescriptor","colonIndex","namespaceAbbreviation","propertyName","removeNamespace","longValue","lastIndex","shortValue","longPrefix","getNestedKeys","keys","el","makeId","length","result","characters","charactersLength","i","isUrl","string","url","fetchLinkedData","endpoint","token","response","requestOptions","reader","_a","controller","push","done","value","stream","getPagePrefixedNames","property","formDefinitions","pageContent","prefixedNames","pageName","propertyKeys","propertyindex","prefixedName","getFileIdByAccessUrl","accessUrl","fileUploadUrl","accessUrlWithTrailingSlash","fileUploadUrlWithTrailingSlash","accessUrlParts","addKeyToFormatType","format","typeDefinition","removeKeyFromFormatType","propertyObjectHasValues","objectData","objectHasValues","isNil","isEmpty","copiedData","cloneDeep","has","actualValues","valueIndex","currentValue","arrIndex","propertyHasValue","isSet","index","requestUriLabel","uri","envs","voc","req","resolve","reject","axios","res","err","getUriLabel","locale","URIlabel","vocMatch","dataset","getTranslationFor","generalHelper"],"mappings":";;;AASA,SAASA,EAAmBC,GAAM;AAChC,MAAIC,IAAe,CAAA;AACnB,aAAWC,KAAOF;AAChB,IAAAC,IAAe,OAAO,OAAOA,GAAcD,EAAKE,CAAG,CAAC;AAEtD,SAAOD;AACT;AAOA,SAASE,EAAaC,GAAQC,GAAW;AAGvC,MAAIC;AAMF,QAAMC,IAAaH,EAAO,QAAQ,GAAG;AAGrC,MAAIG,MAAe,IAAI;AACrB,UAAMC,IAAwBJ,EAAO,OAAO,GAAGG,CAAU,GACnDE,IAAeL,EAAO,OAAOG,IAAa,CAA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