/** * Mapping of human-readable component names (kebab-case) to their sys_ids */ const COMPONENT_NAME_TO_SYSID: Record = { area: 'aba8630dc2ccc9b3c1774af1b6820696', boxplot: 'c5d01636ff2602109bd2ffffffffff0a', bubble: '50dbc52a13c8b4691f7c60e0246bf28c', 'calendar-report': '259e0221ff18a75c5f5f0fb28fa5d32f', column: '2bd5dc19a7ad083941b7c992a966dd78', 'compatibility-mode-widget': '0805a7bf91a93efbdf0a975b38b01051', dial: '63f050cf050137731a828878839e0b33', donut: 'a2b0596cec6b9d49dd1ff9bf76b5084b', gauge: '037bd8ea3013833fd049186779528b70', geomap: '9c8c44bd78fe5918950e0db8e286211d', heading: '1f6e0643eca7a637e36bd7833549ec9e', heatmap: 'd1f6c60ce95607ea1ef236430d5fdec9', 'horizontal-bar': '85855283b7e03010097cb81cde11a91d', image: '15fe506403f8a98575b6df59008ea8f1', 'indicator-scorecard': '9d31ba4d773ce32ef350d4A555b673f6e', line: '18ac962264404bcc0039359d184b15f3', list: '7ff373544303121093711347efb8f23c', pareto: '53e0a2b49e3ff92ba54ea7ea6f0d0583', pie: '96abe7e38d8790718022c5630a92176c', 'pivot-table': '06f6aacbd1818110f877d87436272684', 'rich-text': '2d56f06d55f46bbd4e79b5e624beb940', scatter: 'e3aade757ef3da131076d005cada40d5', 'semi-donut': '3809c6583b8dd540a0bf735ed493bae2', 'single-score': 'd24d53f60350de7a652caf3188a46ed2', spline: '0f1e76928c4814e1430774fb864003f0', step: '7fa5f7264941fabfb1542985da30e0b8', 'vertical-bar': '23051643b7e03010097cb81cde11a910', } /** * Mapping of sys_ids to human-readable component names (kebab-case) */ const COMPONENT_SYSID_TO_NAME: Record = Object.fromEntries( Object.entries(COMPONENT_NAME_TO_SYSID).map(([name, sysid]) => [sysid, name]) ) /** * Resolves a component value to its sys_id. * If the value is already a sys_id (32-char hex), returns it as-is. * If the value is a component name (case-insensitive), returns the corresponding sys_id. * Otherwise, returns the value unchanged. */ export function resolveComponentToSysId(component: string): string { // If it's already a sys_id (32 hex chars), return as-is if (/^[0-9a-f]{32}$/i.test(component)) { return component } // Normalize to lowercase for case-insensitive lookup const normalized = component.toLowerCase() // If it's a known component name, resolve to sys_id if (COMPONENT_NAME_TO_SYSID[normalized]) { return COMPONENT_NAME_TO_SYSID[normalized] } // Otherwise return as-is (could be a custom component reference) return component } /** * Resolves a sys_id to its human-readable component name (kebab-case). * If the sys_id has a known name, returns the name. * Otherwise, returns the sys_id unchanged. */ export function resolveComponentToName(sysid: string): string { return COMPONENT_SYSID_TO_NAME[sysid] || sysid }