openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.78 kB
JavaScript
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{n as formatConcreteConfigPath}from"./dot-path-B1bYAWM5.mjs";import{n as sanitizeTerminalText}from"./safe-text-B_QTgn0s.mjs";
//!src/config/issue-format.ts
function normalizeConfigIssue(e){const t=Array.isArray(e.allowedValues)&&e.allowedValues.length>0;const n={path:normalizeOptionalString(e.path)??`<root>`,message:e.message,...t?{allowedValues:e.allowedValues}:{},...t&&typeof e.allowedValuesHiddenCount===`number`&&e.allowedValuesHiddenCount>0?{allowedValuesHiddenCount:e.allowedValuesHiddenCount}:{}};if(e.pathSegments)Object.defineProperty(n,"pathSegments",{value:e.pathSegments,enumerable:false});return n}function normalizeConfigIssues(e){return e.map(e=>normalizeConfigIssue(e))}function resolveIssueLocationPrefix(e,t){const n=normalizeOptionalString(e.sourceFile)??normalizeOptionalString(t?.sourceFile);if(!n||typeof e.line!==`number`||e.line<=0)return``;return`${sanitizeTerminalText(n)}:${e.line} — `}function formatConfigIssueLine(e,t=`-`,n){const r=t?`${t} `:``;const i=resolveIssueLocationPrefix(e,n);const a=e.pathSegments?.length?formatConcreteConfigPath(e.pathSegments):e.path;return`${r}${i}${sanitizeTerminalText(n?.normalizeRoot?normalizeOptionalString(a)??`<root>`:typeof a===`string`?a:``)}: ${sanitizeTerminalText(e.message)}`}function formatConfigIssueLines(e,t=`-`,n){return e.map(e=>formatConfigIssueLine(e,t,n))}function formatConfigIssueSummary(e){if(e.length===0)return null;const t=e.slice(0,5);const n=formatConfigIssueLines(t,``,{normalizeRoot:true});const r=e.length-t.length;if(r<=0)return n.join(`; `);return`${n.join(`; `)}; and ${r} more`}export{normalizeConfigIssues as i,formatConfigIssueLines as n,formatConfigIssueSummary as r,formatConfigIssueLine as t};