import { normalizeComparableValue } from '@admin/utils/audit/normalize-comparable-value' import { shouldTrackField } from '@admin/utils/audit/should-track-field' export function getChangedFieldNames( previous: Record | null | undefined, next: Record | null | undefined ): string[] { if (!next) return [] return Object.keys(next) .filter(shouldTrackField) .filter((fieldName) => { const previousValue = previous?.[fieldName] const nextValue = next[fieldName] return normalizeComparableValue(previousValue) !== normalizeComparableValue(nextValue) }) .sort((a, b) => a.localeCompare(b)) }