UNPKG

monday-sdk-js

Version:

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/mondaycom/monday-sdk-js/blob/master/LICENSE)   [![npm version](https://img.shields.io/npm/v/monday-sdk-js.svg?style=flat)](https://www.npmjs.com/package/monday-

44 lines (35 loc) 1.17 kB
const logWarnings = res => { const warnings = res && res.extensions && res.extensions.warnings; if (!warnings || !Array.isArray(warnings)) return res; warnings.forEach(warning => { if (!warning || !warning.message) return; try { const locations = warning.locations && warning.locations.map(loc => `line ${loc.line}, column ${loc.column}`).join("; "); const path = warning.path && warning.path.join(" → "); let message = warning.message; // remove the dot at the end of the message message = message.replace(/\.$/, ""); // start the message with lower case letter message = message.charAt(0).toLowerCase() + message.slice(1); const messageParts = [ "[monday API]", `${path}:`, message, locations && `@ ${locations}`, warning.extensions ? ["\n\nAdditional details:", warning.extensions] : undefined ] .flat() .filter(Boolean); console.warn(...messageParts); } catch (e) { if (warning) { console.warn("[monday API] Warning:", warning); } } }); return res; }; module.exports = { logWarnings };