(filter, { includeId = false } = {})
| 92 | } |
| 93 | |
| 94 | function normalizeChartFilter(filter, { includeId = false } = {}) { |
| 95 | if (!filter || !hasConditionValue(filter)) return null; |
| 96 | |
| 97 | const normalizedFilter = { |
| 98 | type: filter.type || "field", |
| 99 | field: filter.field, |
| 100 | operator: filter.operator, |
| 101 | value: filter.value, |
| 102 | exposed: Boolean(filter.exposed), |
| 103 | cdcId: filter.cdcId ?? null, |
| 104 | origin: "chart", |
| 105 | scope: filter.cdcId ? "cdc" : "chart", |
| 106 | clientOnly: Boolean(filter.clientOnly) || CLIENT_ONLY_FILTER_TYPES.has(filter.type || "field"), |
| 107 | }; |
| 108 | |
| 109 | if (includeId) { |
| 110 | normalizedFilter.id = filter.id; |
| 111 | } |
| 112 | |
| 113 | return normalizedFilter; |
| 114 | } |
| 115 | |
| 116 | export function getChartRuntimeFilterState(chartFilters = {}, chartId) { |
| 117 | if (!chartId) return []; |
no test coverage detected