| 147 | } |
| 148 | |
| 149 | const isSortConditionArray = (value: unknown): value is SortRule[] => { |
| 150 | if (!Array.isArray(value) || value.length === 0) return false |
| 151 | const firstItem = value[0] |
| 152 | return ( |
| 153 | typeof firstItem === 'object' && |
| 154 | firstItem !== null && |
| 155 | 'column' in firstItem && |
| 156 | 'direction' in firstItem && |
| 157 | typeof firstItem.column === 'string' && |
| 158 | (firstItem.direction === 'asc' || firstItem.direction === 'desc') |
| 159 | ) |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Attempts to parse a JSON string, returning the parsed value or the |