import assertUnreachable from '../utils/assertUnreachable';
import { getItemType } from '../utils/item';
import { DimensionType, MetricType, TableCalculationType, } from './field';
export const isResultValue = (value) => typeof value === 'object' &&
    value !== null &&
    'value' in value &&
    typeof value.value === 'object' &&
    value.value !== null &&
    'raw' in value.value &&
    'formatted' in value.value;
export function convertItemTypeToDimensionType(item) {
    const type = getItemType(item);
    switch (type) {
        case DimensionType.STRING:
        case MetricType.STRING:
        case TableCalculationType.STRING:
            return DimensionType.STRING;
        case DimensionType.NUMBER:
        case MetricType.NUMBER:
        case MetricType.PERCENTILE:
        case MetricType.MEDIAN:
        case MetricType.AVERAGE:
        case MetricType.COUNT:
        case MetricType.COUNT_DISTINCT:
        case MetricType.SUM:
        case MetricType.SUM_DISTINCT:
        case MetricType.AVERAGE_DISTINCT:
        case MetricType.MIN:
        case MetricType.MAX:
        case MetricType.PERCENT_OF_PREVIOUS:
        case MetricType.PERCENT_OF_TOTAL:
        case MetricType.RUNNING_TOTAL:
        case TableCalculationType.NUMBER:
            return DimensionType.NUMBER;
        case DimensionType.TIMESTAMP:
        case MetricType.TIMESTAMP:
        case TableCalculationType.TIMESTAMP:
            return DimensionType.TIMESTAMP;
        case DimensionType.DATE:
        case MetricType.DATE:
        case TableCalculationType.DATE:
            return DimensionType.DATE;
        case DimensionType.BOOLEAN:
        case MetricType.BOOLEAN:
        case TableCalculationType.BOOLEAN:
            return DimensionType.BOOLEAN;
        default: {
            return assertUnreachable(type, `No dimension type found for field type: ${type}`);
        }
    }
}
export const isRawResultRow = (value) => typeof value !== 'object' || value === null;
//# sourceMappingURL=results.js.map